jeudi 7 mai 2015

Inhalt wird nicht oder falsch in Datenbank aufgenommen

Hallo,

ich bin neu hier und das ist mein erster Beitrag. Bislang bin ich ganz gut ohne Hilfestellung zurechtgekommen, aber nun habe ich ein Problem, das ich seit 3 Tagen schon zu lösen versuche, leider erfolglos.

Ich hoffe, jemand hier kann mir helfen. Ich wäre auch bereit, diese Hilfestellung zu entlohnen.

Und zwar geht es darum ...

Ich stelle dem Nutzer ein Texterea-Feld zur Verfügung, wo er etwas hineinschreiben kann, aber leider wird dieser Inhalt nicht in die Datenbank aufgenommen, sondern nur diese Klammern () !

Ich habe das wie folgt in die .php.datei eingetragen:

Zeile 128 $beispieltext= JRequest::getVar('textbeispiel');
Zeile 137 $value = (explode(" ", $beispieltext));
Zeile 170 ... , '$db->quote($beispieltext)', ...


Java Code:

  1. public static function repin() {
  2. $db = JFactory::getDBO();
  3.  
  4.  
  5. if (JRequest::getVar('repin_id')) {
  6. ob_start();
  7. $res['board_id'] = JRequest::getVar('board_id');
  8. $res['description'] = JRequest::getVar('description');
  9. $res['repin_id'] = JRequest::getVar('repin_id');
  10. $res['pin_real_pin_id'] = JRequest::getVar('pin_real_pin_id');
  11. $res['pin_user_id'] = JRequest::getVar('pin_user_id');
  12. $repin = $res['repin_id'];
  13. $query = "select pin_category_id,pin_real_pin_id,pin_repin_count,pin_type_id,pin_url,pin_image,link_type from #__pin_pins where pin_id=$repin";
  14. $db->setQuery($query);
  15. $pins = $db->loadObjectList();
  16. $pin_type_id = $pins[0]->pin_type_id;
  17. $pin_url = $pins[0]->pin_url;
  18. $pin_image = $pins[0]->pin_image;
  19. $pin_link_type = $pins[0]->link_type;
  20. $pin_category_id = $pins[0]->pin_category_id;
  21. $board_id = $res['board_id'];
  22. $description = $res['description'];
  23. $repin_count = $pins[0]->pin_repin_count + 1;
  24. $pin_repin_id = $repin;
  25. $pin_real_pin_id = $pins[0]->pin_real_pin_id;
  26. $pin_user_id = $res['pin_user_id'];
  27. $date = JFactory::getDate();
  28. $current_date = $date->format("Y-m-d H:i:s");
  29. if ($pin_real_pin_id == 0) {
  30.  
  31. $pin_real_pin_id = $repin;
  32. }
  33. $mailer = JFactory::getMailer(); //define joomla mailer
  34. $app = JFactory::getApplication();
  35. $db = JFactory::getDBO();
  36. $query = "SELECT a.pin_board_id,a.pin_description,a.pin_image,a.link_type,a.pin_id,a.pin_description,b.first_name,b.last_name,b.email
  37. FROM #__pin_pins AS a
  38. INNER JOIN #__pin_user_settings AS b
  39. ON a.pin_user_id=b.user_id
  40. WHERE pin_id=$pin_real_pin_id";
  41.  
  42. $db->setQuery($query);
  43. $pin_email = $db->loadObjectList();
  44.  
  45. $query = "SELECT board_name
  46. FROM #__pin_boards
  47. WHERE board_id=" . $board_id;
  48.  
  49. $db->setQuery($query);
  50. $board_name = $db->loadResult();
  51.  
  52.  
  53.  
  54. $query = "SELECT first_name,last_name,email,user_image
  55. FROM #__pin_user_settings
  56. WHERE user_id=$pin_user_id";
  57. $db->setQuery($query);
  58. $pin_user_info = $db->loadObjectList();
  59.  
  60. $user_image = $pin_user_info[0]->user_image;
  61.  
  62. if ($user_image != '') {
  63. $user_image = JURI::base() . 'images/socialpinboard/avatars/' . rawurlencode($user_image);
  64. } else {
  65. $user_image = JURI::Base() . '/components/com_socialpinboard/images/no_user.jpg';
  66. }
  67.  
  68. //mail functionality
  69. $config = JFactory::getConfig();
  70. $sender = $config->get('mailfrom');
  71. $site_name = $config->get('sitename');
  72. $mailer->setSender($sender);
  73.  
  74.  
  75. //set the body
  76. $templateparams = $app->getTemplate(true)->params; // get the tempalte parameters
  77. $logo = $templateparams->get('logo'); //get the logo
  78.  
  79. if ($logo != null) {
  80. $image_source = JURI::base() . '/' . htmlspecialchars($logo);
  81. } else {
  82. $image_source = JURI::base() . '/templates/socialpinboard/images/logo-large.png';
  83. }
  84.  
  85. $email = $pin_email[0]->email;
  86.  
  87. $link_type = $pin_email[0]->link_type;
  88. $strImgName = $pin_email[0]->pin_image;
  89. $pin_description = $pin_email[0]->pin_description;
  90. if ($link_type == 'youtube' || $link_type == 'vimeo') {
  91. $strImgPath = $strImgName;
  92. } else {
  93. $strImgPath = JURI::base() . '/images/pin_thumb/' . $strImgName;
  94. }
  95.  
  96. //set recipient
  97. $mailer->addRecipient($email);
  98. $Pin_user_name = $pin_email[0]->first_name . ' ' . $pin_email[0]->last_name;
  99. $pin_affect_user = $pin_user_info[0]->first_name . ' ' . $pin_user_info[0]->last_name;
  100. $pin_description = $pin_email[0]->pin_description;
  101. $pin_id = $pin_email[0]->pin_id;
  102.  
  103. $subject = $pin_user_info[0]->first_name . ' repinned your pin';
  104. $baseurl = JURI::base();
  105. $repinned_user_url = JURI::base() . 'index.php?option=com_socialpinboard&view=boarddisplay&uid=' . $pin_user_id;
  106. $repinned_pin_url = JURI::base() . 'index.php?option=com_socialpinboard&view=pin&pinid=' . $pin_id;
  107. $repinned_new_board_url = JURI::base() . 'index.php?option=com_socialpinboard&view=boardpage&bId=' . $board_id;
  108. $message = file_get_contents(JURI::base() . '/templates/emailtemplate/repin.html');
  109. $message = str_replace("{baseurl}", $baseurl, $message);
  110. $message = str_replace("{site_name}", $site_name, $message);
  111. $message = str_replace("{site_logo}", $image_source, $message);
  112. $message = str_replace("{Pin_user_name}", $Pin_user_name, $message);
  113. $message = str_replace("{repinned_user_url}", $repinned_user_url, $message);
  114. $message = str_replace("{repinned_user}", $pin_affect_user, $message);
  115. $message = str_replace("{repinned_user_image}", $user_image, $message);
  116. $message = str_replace("{repinned_pin_url}", $repinned_pin_url, $message);
  117. $message = str_replace("{repin_image}", $strImgPath, $message);
  118. $message = str_replace("{pin_description}", $pin_description, $message);
  119. $message = str_replace("{repinned_new_board_url}", $repinned_new_board_url, $message);
  120. $message = str_replace("{new_board}", $board_name, $message);
  121. $mailer->isHTML(true);
  122. $mailer->setSubject($subject);
  123. $mailer->Encoding = 'base64';
  124. $mailer->setBody($message);
  125. $send = $mailer->Send();
  126.  
  127. $repin = JRequest::getVar('repin_id');
  128. $beispieltext= JRequest::getVar('textbeispiel');
  129. $query = "UPDATE `#__pin_pins` SET `pin_repin_count`=$repin_count,`updated_date`='$current_date' WHERE pin_id=$repin";
  130.  
  131. $db->setQuery($query);
  132. if (!$db->query()) {
  133. $this->setError($db->getErrorMsg());
  134. return false;
  135. }
  136. $price = $gift = '';
  137. $value = (explode(" ", $description));
  138. $value = (explode(" ", $beispieltext));
  139. $count = count($value);
  140. $query = "SELECT setting_currency from #__pin_site_settings";
  141. $db->setQuery($query);
  142. $currency = $db->loadResult();
  143.  
  144. for ($i = 0; $i <= $count - 1; $i++) {
  145. if (preg_match("/^[" . $currency . "]|[0-9]+[.]+$/", $value[$i])) {
  146. $price = $value[$i];
  147. $price = (explode($currency, $price));
  148. $price=$price[1];
  149. if ($price != '' && $price) {
  150. $query = "SELECT setting_currency from #__pin_site_settings";
  151. $db->setQuery($query);
  152. $currency = $db->loadResult();
  153.  
  154. if (preg_match("/[" . $currency . "]/", $value[$i])) {
  155. $query = "SELECT setting_currency from #__pin_site_settings";
  156. $db->setQuery($query);
  157. $currency = $db->loadResult();
  158. $is_price = explode($currency, $value[$i]);
  159. if (is_numeric($is_price[1])) {
  160. $gift = '1';
  161. }
  162. }
  163. } else {
  164. $gift = '0';
  165. }
  166. }
  167. }
  168.  
  169. $query = "INSERT INTO `#__pin_pins` (`pin_id`, `pin_board_id`, `pin_user_id`, `pin_category_id`, `pin_description`, `pin_tag_one`, `price`,`gift`, `pin_type_id`, `pin_url`, `pin_image`, `pin_repin_id`, `pin_real_pin_id`, `pin_repin_count`, `pin_likes_count`, `pin_comments_count`, `pin_views`, `status`,`link_type`, `created_date`, `updated_date`) VALUES
  170. ('', $board_id, $pin_user_id, $pin_category_id, '$description', '$db->quote($beispieltext)', '$price','$gift', $pin_type_id, '$pin_url', '$pin_image', $pin_repin_id, $pin_real_pin_id, 0, 0, 0, 0, 1,'$pin_link_type', NOW(),NOW())";
  171. $db->setQuery($query);
  172. if (!$db->query()) {
  173. $this->setError($db->getErrorMsg());
  174. return false;
  175. }
  176. return $db->insertid();
  177. }
  178. }
  179.  
  180. function rgb2html($r, $g=-1, $b=-1) {
  181. if (is_array($r) && sizeof($r) == 3)
  182. list($r, $g, $b) = $r;
  183.  
  184. $r = intval($r);
  185. $g = intval($g);
  186. $b = intval($b);
  187.  
  188. $r = dechex($r < 0 ? 0 : ($r > 255 ? 255 : $r));
  189. $g = dechex($g < 0 ? 0 : ($g > 255 ? 255 : $g));
  190. $b = dechex($b < 0 ? 0 : ($b > 255 ? 255 : $b));
  191.  
  192. $color = (strlen($r) < 2 ? '0' : '') . $r;
  193. $color .= ( strlen($g) < 2 ? '0' : '') . $g;
  194. $color .= ( strlen($b) < 2 ? '0' : '') . $b;
  195. return '#' . $color;
  196. }
  197.  
  198. public static function showRequest() {
  199.  
  200.  
  201. $db = JFactory::getDBO();
  202. $query = "SELECT setting_show_request FROM #__pin_site_settings";
  203. $db->setQuery($query);
  204. $show_request = $db->loadResult();
  205.  
  206. return $show_request;
  207. }


Anhang 7749

Was muss in dem Code geändert werden, damit der richtige Inhalt übertragen wird?


Inhalt wird nicht oder falsch in Datenbank aufgenommen

0 commentaires:

Enregistrer un commentaire