function check() { //initialize $this->_error = null; $this->oldurl = JString::trim($this->oldurl); $this->newurl = JString::trim($this->newurl); // check for valid URLs if ($this->oldurl == '' || $this->newurl == '') { $this->_error .= JTExt::_('COM_SH404SEF_EMPTYURL'); return false; } if (JString::substr($this->oldurl, 0, 1) == '/') { $this->_error .= JText::_('COM_SH404SEF_NOLEADSLASH'); } if (JString::substr($this->newurl, 0, 9) != 'index.php') { $this->_error .= JText::_('COM_SH404SEF_BADURL'); } // V 1.2.4.t remove this check. We check for pre-existing non-sef instead of SEF if (is_null($this->_error)) { // check for existing URLS $this->_db->setQuery("SELECT id,oldurl FROM #__sh404sef_urls WHERE `newurl` LIKE " . $this->_db->Quote($this->newurl)); $xid = $this->_db->loadObject(); // V 1.3.1 don't raise error if both newurl and old url are same. It means we may have changed alias list if ($xid && $xid->id != intval($this->id)) { $this->_error = JText::_('COM_SH404SEF_URLEXIST'); return false; } $identical = $xid->id == intval($this->id) && $xid->oldurl == $this->oldurl; return $identical ? 'identical' : true; } else { return false; } }
function fetchElement($name, $value, &$node, $control_name) { if (!function_exists('curl_init') or !function_exists('curl_exec')) { return JTExt::_('VMPAYMENT_KLARNA_CURL_LIBRARY_NOT_INSTALLED'); } else { return ""; } }
function fetchElement($name, $value, &$node, $control_name) { JPlugin::loadLanguage('com_virtuemart', JPATH_ADMINISTRATOR); if (!function_exists('curl_init')) { return JTExt::_('VMPAYMENT_AUTHORIZENET_CURL_LIBRARY_NOT_INSTALLED'); } else { return JTExt::_('VMPAYMENT_AUTHORIZENET_CURL_LIBRARY_INSTALLED'); } }
function paymentReturn() { $app = JFactory::getApplication(); $id = JRequest::getInt("id", ""); $cid = JRequest::getInt("cid", ""); $itemid = JRequest::getInt("Itemid", ""); $r = JRequest::getVar("r", ""); if ($r == 'ok') { //$redirect= 'index.php?option=com_djclassifieds&view=item&id='.$id.'&cid='.$cid.'&Itemid='.$itemid; $message = JTExt::_('COM_DJCLASSIFIEDS_THANKS_FOR_PAYMENT_WAIT_FOR_CONFIRMATION'); } else { $message = JTExt::_('COM_DJCLASSIFIEDS_PAYMENT_CANCELED'); } //$redirect= 'index.php?option=com_djclassifieds&view=items&cid=0&Itemid='.$itemid; $redirect = DJClassifiedsSEO::getCategoryRoute('0:all'); $redirect = JRoute::_($redirect); $app->redirect($redirect, $message); }
function checkCFImages() { $app = JFactory::getApplication(); $db = JFactory::getDBO(); $query = "SELECT count(id) FROM #__djcf_items WHERE image_url!='' "; $db->setQuery($query); $item_with_img = $db->loadResult(); if ($item_with_img) { $app->enqueueMessage(JTExt::_('COM_DJCLASSIFIEDS_YOU_HAVE_OLD_STRUCTURE_OF_ADVERTS_IMAGES') . ' <a href="index.php?option=com_djclassifieds&task=items.migrateImages">' . JText::_('COM_DJCLASSIFIEDS_MIGRATE_IMAGES') . '</a>', 'error'); } $query = "SELECT count(id) FROM #__djcf_categories WHERE icon_url!='' "; $db->setQuery($query); $item_with_img = $db->loadResult(); if ($item_with_img) { $app->enqueueMessage(JTExt::_('COM_DJCLASSIFIEDS_YOU_HAVE_OLD_STRUCTURE_OF_CATEGORIES_IMAGES') . ' <a href="index.php?option=com_djclassifieds&task=items.migrateCatImages">' . JText::_('COM_DJCLASSIFIEDS_MIGRATE_IMAGES') . '</a>', 'error'); } return null; }
function _notify_url() { require_once JPATH_BASE . '/plugins/djclassifiedspayment/djcfAuthorizeNET/djcfAuthorizeNET/anet_php_sdk/AuthorizeNet.php'; $db = JFactory::getDBO(); $app = JFactory::getApplication(); $account_type = $this->params["account_type"]; $Itemid = JRequest::getInt("Itemid", '0'); $merchant_id = $this->params["login_id"]; $merchant_key = $this->params["transaction_key"]; $currency = $this->params["currency_code"]; $user = JFactory::getUser(); $id = JRequest::getInt('id', '0'); $ptype = JRequest::getVar('ptype'); $par =& JComponentHelper::getParams('com_djclassifieds'); $type = JRequest::getVar('type', ''); $row =& JTable::getInstance('Payments', 'DJClassifiedsTable'); if ($type == 'prom_top') { $query = "SELECT i.* FROM #__djcf_items i " . "WHERE i.id=" . $id . " LIMIT 1"; $db->setQuery($query); $item = $db->loadObject(); if (!isset($item)) { $message = JText::_('COM_DJCLASSIFIEDS_WRONG_AD'); $redirect = "index.php?option=com_djclassifieds&view=items&cid=0"; } $row->item_id = $id; $row->user_id = $user->id; $row->method = $ptype; $row->status = 'Start'; $row->ip_address = $_SERVER['REMOTE_ADDR']; $row->price = $par->get('promotion_move_top_price', 0); $row->type = 2; $row->store(); $amount = $par->get('promotion_move_top_price', 0); $itemname = $item->name; $item_id = $row->id; $item_cid = '&cid=' . $item->cat_id; } else { if ($type == 'points') { $query = "SELECT p.* FROM #__djcf_points p " . "WHERE p.id=" . $id . " LIMIT 1"; $db->setQuery($query); $points = $db->loadObject(); if (!isset($item)) { $message = JText::_('COM_DJCLASSIFIEDS_WRONG_POINTS_PACKAGE'); $redirect = "index.php?option=com_djclassifieds&view=items&cid=0"; } $row->item_id = $id; $row->user_id = $user->id; $row->method = $ptype; $row->status = 'Start'; $row->ip_address = $_SERVER['REMOTE_ADDR']; $row->price = $points->price; $row->type = 1; $row->store(); $amount = $points->price; $itemname = $points->name; $item_id = $row->id; $item_cid = ''; } else { $query = "SELECT i.*, c.price as c_price FROM #__djcf_items i " . "LEFT JOIN #__djcf_categories c ON c.id=i.cat_id " . "WHERE i.id=" . $id . " LIMIT 1"; $db->setQuery($query); $item = $db->loadObject(); if (!isset($item)) { $message = JText::_('COM_DJCLASSIFIEDS_WRONG_AD'); $redirect = "index.php?option=com_djclassifieds&view=items&cid=0"; } $amount = 0; if (strstr($item->pay_type, 'cat')) { $amount += $item->c_price / 100; } if (strstr($item->pay_type, 'duration_renew')) { $query = "SELECT d.price_renew FROM #__djcf_days d " . "WHERE d.days=" . $item->exp_days; $db->setQuery($query); $amount += $db->loadResult(); } else { if (strstr($item->pay_type, 'duration')) { $query = "SELECT d.price FROM #__djcf_days d " . "WHERE d.days=" . $item->exp_days; $db->setQuery($query); $amount += $db->loadResult(); } } $query = "SELECT p.* FROM #__djcf_promotions p " . "WHERE p.published=1 ORDER BY p.id "; $db->setQuery($query); $promotions = $db->loadObjectList(); foreach ($promotions as $prom) { if (strstr($item->pay_type, $prom->name)) { $amount += $prom->price; } } /*$query = 'DELETE FROM #__djcf_payments WHERE item_id= "'.$id.'" '; $db->setQuery($query); $db->query(); $query = 'INSERT INTO #__djcf_payments ( item_id,user_id,method, status)' . ' VALUES ( "'.$id.'" ,"'.$user->id.'","'.$ptype.'" ,"Start" )' ; $db->setQuery($query); $db->query();*/ $row->item_id = $id; $row->user_id = $user->id; $row->method = $ptype; $row->status = 'Start'; $row->ip_address = $_SERVER['REMOTE_ADDR']; $row->price = $amount; $row->type = 0; $row->store(); $itemname = $item->name; $item_id = $row->id; $item_cid = '&cid=' . $item->cat_id; } } $query = "SELECT p.* FROM #__djcf_payments p " . "WHERE p.id='" . $item_id . "' "; $db->setQuery($query); $payment = $db->loadObject(); $login_id = $this->params["login_id"]; $transaction_key = $this->params["transaction_key"]; $card_no = JRequest::getVar('card_no'); $msg_style = ''; //include_once "phpcreditcard.php"; $card_num = JRequest::getVar('card_no', '0', '', 'string'); $card_type = JRequest::getVar('card_type'); $exp_date = JRequest::getVar('exp_date', '0', '', 'int') . '/' . JRequest::getVar('exp_year', '0', '', 'int'); $cvv = JRequest::getVar('card_code', '0', '', 'int'); if ($card_num == 0 || $cvv == '0') { $message = JText::_('COM_DJCLASSIFIEDS_ENTER_ALL_VALUES'); $redirect = 'index.php?option=com_djclassifieds&view=payment&id=' . $id . '&Itemid=' . $Itemid; $app->redirect($redirect, $message, 'Error'); } define("AUTHORIZENET_API_LOGIN_ID", $merchant_id); define("AUTHORIZENET_TRANSACTION_KEY", $merchant_key); if ($account_type == 'secure') { define("AUTHORIZENET_SANDBOX", false); } else { define("AUTHORIZENET_SANDBOX", true); } $sale = new AuthorizeNetAIM(); $sale->amount = $amount; $sale->card_num = $card_num; $sale->exp_date = $exp_date; //$sale->card_num = '4007000000027'; //$sale->exp_date = $exp_date; //$sale->card_type = 'V'; $sale->auth_code = JRequest::getVar('auth_code', '0', '', 'int'); $response = $sale->authorizeAndCapture(); //echo '<pre>'; print_r($response);die(); if ($response->approved) { $query = "UPDATE #__djcf_payments SET status='Completed' " . "WHERE id=" . $item_id . " AND method='djcfAuthorizeNET'"; $db->setQuery($query); $db->query(); if ($type == 'prom_top') { $date_sort = date("Y-m-d H:i:s"); $query = "UPDATE #__djcf_items SET date_sort='" . $date_sort . "' " . "WHERE id=" . $id . " "; $db->setQuery($query); $db->query(); } else { if ($type == 'points') { $query = "SELECT p.points FROM #__djcf_points p WHERE p.id='" . $id . "' "; $db->setQuery($query); $points = $db->loadResult(); $query = "INSERT INTO #__djcf_users_points (`user_id`,`points`,`description`) " . "VALUES ('" . $payment->user_id . "','" . $points . "','" . JText::_('COM_DJCLASSIFIEDS_POINTS_PACKAGE') . " AuthorizeNET <br />" . JText::_('COM_DJCLASSIFIEDS_PAYMENT_ID') . ' ' . $payment->id . "')"; $db->setQuery($query); $db->query(); } else { $query = "SELECT c.* FROM #__djcf_items i, #__djcf_categories c " . "WHERE i.cat_id=c.id AND i.id='" . $id . "' "; $db->setQuery($query); $cat = $db->loadObject(); $pub = 0; if ($cat->autopublish == '1' || $cat->autopublish == '0' && $par->get('autopublish') == '1') { $pub = 1; } $query = "UPDATE #__djcf_items SET payed=1, pay_type='', published='" . $pub . "' " . "WHERE id=" . $id . " "; $db->setQuery($query); $db->query(); } } $message = JTExt::_('COM_DJCLASSIFIEDS_THANKS_FOR_PAYMENT_WAIT_FOR_CONFIRMATION'); $redirect = 'index.php?option=com_djclassifieds&view=items&cid=0&Itemid=' . $Itemid; } else { $message = $response->response_reason_text; $redirect = 'index.php?option=com_djclassifieds&view=payment&id=' . $id . '&Itemid=' . $Itemid; $msg_style = 'Error'; } $app->redirect($redirect, $message, $msg_style); }
function custom_css() { $mainframe = JFactory::getApplication(); //Hold on... Are you a super user? $user = JFactory::getUser(); if (!$user->authorise('core.admin')) { $msg = JTExt::_('JEV_ERROR_NOT_AUTH_CSS'); $msgType = 'Error'; $mainframe->enqueueMessage($msg, $msgType); $mainframe->redirect('index.php?option=com_jevents&msg=' . $msg . '&msgtype=' . $msgType . ''); return; } //Get the view $this->view = $this->getView("cpanel", "html"); // Set the layout $this->view->setLayout('custom_css'); $this->view->assign('title', JText::_('CONTROL_PANEL')); $this->view->display(); }
function save() { $app = JFactory::getApplication(); $user = JFactory::getUser(); $db = JFactory::getDBO(); $par = JComponentHelper::getParams('com_djclassifieds'); if ($user->id == '0') { $uri = DJClassifiedsSEO::getCategoryRoute('0:all'); $app->redirect('index.php?option=com_users&view=login&return=' . base64_encode($uri), JText::_('COM_DJCLASSIFIEDS_PLEASE_LOGIN')); } $del_avatar_id = JRequest::getInt('del_avatar', 0); if ($del_avatar_id) { $query = "SELECT * FROM #__djcf_images WHERE item_id=" . $user->id . " AND type='profile' ORDER BY ordering LIMIT 1"; $db->setQuery($query); $avatar = $db->loadObject(); if ($avatar) { $path_to_delete = JPATH_SITE . $avatar->path . $avatar->name; $del_avatar_ext = $avatar->ext; if (JFile::exists($path_to_delete . '.' . $del_avatar_ext)) { JFile::delete($path_to_delete . '.' . $del_avatar_ext); } if (JFile::exists($path_to_delete . '_th.' . $del_avatar_ext)) { JFile::delete($path_to_delete . '_th.' . $del_avatar_ext); } if (JFile::exists($path_to_delete . '_ths.' . $del_avatar_ext)) { JFile::delete($path_to_delete . '_ths.' . $del_avatar_ext); } $query = "DELETE FROM #__djcf_images WHERE type='profile' AND item_id=" . $user->id . " AND id=" . $avatar->id . " "; $db->setQuery($query); $db->query(); } } $new_avatar = $_FILES['new_avatar']; if (substr($new_avatar['type'], 0, 5) == "image") { $query = "SELECT * FROM #__djcf_images WHERE item_id=" . $user->id . " AND type='profile' ORDER BY ordering LIMIT 1"; $db->setQuery($query); $avatar = $db->loadObject(); if ($avatar) { $path_to_delete = JPATH_SITE . $avatar->path . $avatar->name; $del_avatar_ext = $avatar->ext; if (JFile::exists($path_to_delete . '.' . $del_avatar_ext)) { JFile::delete($path_to_delete . '.' . $del_avatar_ext); } if (JFile::exists($path_to_delete . '_th.' . $del_avatar_ext)) { JFile::delete($path_to_delete . '_th.' . $del_avatar_ext); } if (JFile::exists($path_to_delete . '_ths.' . $del_avatar_ext)) { JFile::delete($path_to_delete . '_ths.' . $del_avatar_ext); } $query = "DELETE FROM #__djcf_images WHERE type='profile' AND item_id=" . $user->id . " AND id=" . $avatar->id . " "; $db->setQuery($query); $db->query(); } $lang = JFactory::getLanguage(); $icon_name = str_ireplace(' ', '_', $new_avatar['name']); $icon_name = $lang->transliterate($icon_name); $icon_name = strtolower($icon_name); $icon_name = JFile::makeSafe($icon_name); $icon_name = $user->id . '_' . $icon_name; $icon_url = $icon_name; $path = JPATH_SITE . "/components/com_djclassifieds/images/profile/" . $icon_name; move_uploaded_file($new_avatar['tmp_name'], $path); $nw = $par->get('profth_width', 120); $nh = $par->get('profth_height', 120); $nws = $par->get('prof_smallth_width', 50); $nhs = $par->get('prof_smallth_height', 50); $name_parts = pathinfo($path); $img_name = $name_parts['filename']; $img_ext = $name_parts['extension']; $new_path = JPATH_SITE . "/components/com_djclassifieds/images/profile/"; //DJClassifiedsImage::makeThumb($path, $nw, $nh, 'ths'); DJClassifiedsImage::makeThumb($path, $new_path . $img_name . '_th.' . $img_ext, $nw, $nh); DJClassifiedsImage::makeThumb($path, $new_path . $img_name . '_ths.' . $img_ext, $nws, $nhs); $query = "INSERT INTO #__djcf_images(`item_id`,`type`,`name`,`ext`,`path`,`caption`,`ordering`) VALUES "; $query .= "('" . $user->id . "','profile','" . $img_name . "','" . $img_ext . "','/components/com_djclassifieds/images/profile/','','1'); "; $db->setQuery($query); $db->query(); } $query = "DELETE FROM #__djcf_fields_values_profile WHERE user_id= " . $user->id . " "; $db->setQuery($query); $db->query(); $query = "SELECT f.* FROM #__djcf_fields f WHERE f.source=2 "; $db->setQuery($query); $fields_list = $db->loadObjectList(); //echo '<pre>'; print_r($db);print_r($fields_list);die(); $a_tags_cf = ''; if ((int) $par->get('allow_htmltags_cf', '0')) { $allowed_tags_cf = explode(';', $par->get('allowed_htmltags_cf', '')); for ($a = 0; $a < count($allowed_tags_cf); $a++) { $a_tags_cf .= '<' . $allowed_tags_cf[$a] . '>'; } } $ins = 0; if (count($fields_list) > 0) { $query = "INSERT INTO #__djcf_fields_values_profile(`field_id`,`user_id`,`value`,`value_date`) VALUES "; foreach ($fields_list as $fl) { if ($fl->type == 'checkbox') { if (isset($_POST[$fl->name])) { $field_v = $_POST[$fl->name]; $f_value = ';'; for ($fv = 0; $fv < count($field_v); $fv++) { $f_value .= $field_v[$fv] . ';'; } $query .= "('" . $fl->id . "','" . $user->id . "','" . $db->escape($f_value) . "',''), "; $ins++; } } else { if ($fl->type == 'date') { if (isset($_POST[$fl->name])) { $f_var = JRequest::getVar($fl->name, '', '', 'string'); $query .= "('" . $fl->id . "','" . $user->id . "','','" . $db->escape($f_var) . "'), "; $ins++; } } else { if (isset($_POST[$fl->name])) { if ($a_tags_cf) { $f_var = JRequest::getVar($fl->name, '', '', 'string', JREQUEST_ALLOWRAW); $f_var = strip_tags($f_var, $a_tags_cf); } else { $f_var = JRequest::getVar($fl->name, '', '', 'string'); } $query .= "('" . $fl->id . "','" . $user->id . "','" . $db->escape($f_var) . "',''), "; $ins++; } } } } } //print_r($query);die(); if ($ins > 0) { $query = substr($query, 0, -2) . ';'; $db->setQuery($query); $db->query(); } $menus = JSite::getMenu(); $menu_profile = $menus->getItems('link', 'index.php?option=com_djclassifieds&view=profile', 1); $menu_item = $menus->getItems('link', 'index.php?option=com_djclassifieds&view=items&cid=0', 1); $menu_item_blog = $menus->getItems('link', 'index.php?option=com_djclassifieds&view=items&layout=blog&cid=0', 1); $redirect = 'index.php?option=com_djclassifieds&view=profile'; if ($menu_profile) { $redirect .= '&Itemid=' . $menu_profile->id; } else { if ($menu_item) { $redirect .= '&Itemid=' . $menu_item->id; } else { if ($menu_item_blog) { $redirect .= '&Itemid=' . $menu_item_blog->id; } } } $message = JTExt::_('COM_DJCLASSIFIEDS_PROFILE_SAVED_SUCCESSFULLY'); $redirect = JRoute::_($redirect, false); $app->redirect($redirect, $message); }
* @copyright Copyright (C) 2008 Julien Vonthron. All rights reserved. * @license GNU/GPL, see LICENSE.php * Joomla Tracks is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * See COPYRIGHT.php for copyright notices and details. */ // no direct access defined('_JEXEC') or die('Restricted access'); if ($this->data->vehicle_picture || $this->data->vehicle_description) { ?> <div id="teamvehicle"> <h2><?php echo JTExt::_('COM_TRACKS_VIEW_TEAM_VEHICLE'); ?> </h2> <?php if ($this->data->vehicle_picture) { ?> <div id="vehicle-pic"> <?php echo TrackslibHelperImage::modalimage(JPATH_SITE . '/' . $this->data->vehicle_picture, Jtext::_('COM_TRACKS_TEAM_VEHICLE_PICTURE'), 400); ?> </div> <?php } ?>
function save() { $app = JFactory::getApplication(); JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables'); jimport('joomla.database.table'); JPluginHelper::importPlugin('djclassifieds'); $row = JTable::getInstance('Items', 'DJClassifiedsTable'); $par = JComponentHelper::getParams('com_djclassifieds'); $user = JFactory::getUser(); $lang = JFactory::getLanguage(); $dispatcher = JDispatcher::getInstance(); $db = JFactory::getDBO(); $id = JRequest::getVar('id', 0, '', 'int'); $token = JRequest::getCMD('token', ''); $redirect = ''; $menus = $app->getMenu('site'); $menu_item = $menus->getItems('link', 'index.php?option=com_djclassifieds&view=items&cid=0', 1); $menu_item_blog = $menus->getItems('link', 'index.php?option=com_djclassifieds&view=items&layout=blog&cid=0', 1); $itemid = ''; if ($menu_item) { $itemid = '&Itemid=' . $menu_item->id; } else { if ($menu_item_blog) { $itemid = '&Itemid=' . $menu_item_blog->id; } } $menu_newad_itemid = $menus->getItems('link', 'index.php?option=com_djclassifieds&view=additem', 1); $new_ad_link = 'index.php?option=com_djclassifieds&view=additem'; if ($menu_newad_itemid) { $new_ad_link .= '&Itemid=' . $menu_newad_itemid->id; } $new_ad_link = JRoute::_($new_ad_link); if ($user->id == 0 && $id > 0) { $message = JText::_('COM_DJCLASSIFIEDS_WRONG_AD'); //$redirect="index.php?option=com_djclassifieds&view=items&cid=0".$itemid; $redirect = DJClassifiedsSEO::getCategoryRoute('0:all'); $redirect = JRoute::_($redirect); $app->redirect($redirect, $message, 'error'); } $db = JFactory::getDBO(); if ($id > 0) { $query = "SELECT user_id FROM #__djcf_items WHERE id='" . $id . "' LIMIT 1"; $db->setQuery($query); $item_user_id = $db->loadResult(); if ($item_user_id != $user->id) { $message = JText::_('COM_DJCLASSIFIEDS_WRONG_AD'); $redirect = DJClassifiedsSEO::getCategoryRoute('0:all'); $redirect = JRoute::_($redirect); $app->redirect($redirect, $message, 'error'); } } if ($par->get('user_type') == 1 && $user->id == '0') { //$uri = "index.php?option=com_djclassifieds&view=items&cid=0".$itemid; $uri = DJClassifiedsSEO::getCategoryRoute('0:all'); $app->redirect('index.php?option=com_users&view=login&return=' . base64_encode($uri), JText::_('COM_DJCLASSIFIEDS_PLEASE_LOGIN')); } $row->bind(JRequest::get('post')); if ($token && !$user->id && !$id) { $query = "SELECT i.id FROM #__djcf_items i " . "WHERE i.user_id=0 AND i.token=" . $db->Quote($db->escape($token)); $db->setQuery($query); $ad_id = $db->loadResult(); if ($ad_id) { $row->id = $ad_id; } else { $uri = DJClassifiedsSEO::getCategoryRoute('0:all'); $app->redirect('index.php?option=com_users&view=login&return=' . base64_encode($uri), JText::_('COM_DJCLASSIFIEDS_WRONG_TOKEN')); } } $dispatcher->trigger('onAfterInitialiseDJClassifiedsSaveAdvert', array(&$row, &$par)); if ($par->get('title_char_limit', '0') > 0) { $row->name = mb_substr($row->name, 0, $par->get('title_char_limit', '100'), "UTF-8"); } if ((int) $par->get('allow_htmltags', '0')) { $row->description = JRequest::getVar('description', '', 'post', 'string', JREQUEST_ALLOWRAW); $allowed_tags = explode(';', $par->get('allowed_htmltags', '')); $a_tags = ''; for ($a = 0; $a < count($allowed_tags); $a++) { $a_tags .= '<' . $allowed_tags[$a] . '>'; } $row->description = strip_tags($row->description, $a_tags); } else { $row->description = nl2br(JRequest::getVar('description', '', 'post', 'string')); } $row->intro_desc = mb_substr(strip_tags(nl2br($row->intro_desc)), 0, $par->get('introdesc_char_limit', '120'), "UTF-8"); if (!$row->intro_desc) { $row->intro_desc = mb_substr(strip_tags($row->description), 0, $par->get('introdesc_char_limit', '120'), "UTF-8"); } $row->contact = nl2br(JRequest::getVar('contact', '', 'post', 'string')); $row->price_negotiable = JRequest::getInt('price_negotiable', '0'); $row->bid_min = str_ireplace(',', '.', JRequest::getVar('bid_min', '', 'post', 'string')); $row->bid_max = str_ireplace(',', '.', JRequest::getVar('bid_max', '', 'post', 'string')); $row->price_reserve = str_ireplace(',', '.', JRequest::getVar('price_reserve', '', 'post', 'string')); if (!$id && !$token && !$user->id && $par->get('guest_can_edit', 0)) { $characters = '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; $row->token = ''; for ($p = 0; $p < 20; $p++) { $row->token .= $characters[mt_rand(0, strlen($characters))]; } } /* //removing images from folder and from database $path = JPATH_BASE."/components/com_djclassifieds/images/"; $images = $row->image_url; if(isset($_POST['del_img'])){ $del_image = $_POST['del_img']; }else{ $del_image = array(); } for ($i = 0; $i < count($del_image); $i++){ $images = str_replace($del_image[$i].';', '', $images); //deleting the main image if (JFile::exists($path.$del_image[$i])){ JFile::delete($path.$del_image[$i]); } //deleting thumbnail of image if (JFile::exists($path.$del_image[$i].'.thb.jpg')){ JFile::delete($path.$del_image[$i].'.thb.jpg'); } if (JFile::exists($path.$del_image[$i].'.th.jpg')){ JFile::delete($path.$del_image[$i].'.th.jpg'); } if (JFile::exists($path.$del_image[$i].'.thm.jpg')){ JFile::delete($path.$del_image[$i].'.thm.jpg'); } if (JFile::exists($path.$del_image[$i].'.ths.jpg')){ JFile::delete($path.$del_image[$i].'.ths.jpg'); } } //add images $new_files = $_FILES['image']; if(count($new_files['name'])>0 && $row->id==0){ $query = "SELECT id FROM #__djcf_items ORDER BY id DESC LIMIT 1"; $db->setQuery($query); $last_id =$db->loadResult(); $last_id++; }else{ $last_id= $row->id; } $nw = (int)$par->get('th_width',-1); $nh = (int)$par->get('th_height',-1); $nws = $par->get('smallth_width',-1); $nhs = $par->get('smallth_height',-1); $nwm = $par->get('middleth_width',-1); $nhm = $par->get('middleth_height',-1); $nwb = $par->get('bigth_width',-1); $nhb = $par->get('bigth_height',-1); $img_maxsize = $par->get('img_maxsize',0); if($img_maxsize>0){ $img_maxsize = $img_maxsize*1024*1024; } $lang = JFactory::getLanguage(); for ($i = 0; $i < count($new_files['name']); $i++) { if (substr($new_files['type'][$i], 0, 5) == "image") { if($img_maxsize>0 && $new_files['size'][$i]>$img_maxsize){ $app->enqueueMessage(JText::_('COM_DJCLASSIFIEDS_TO_BIG_IMAGE').' : \''.$new_files['name'][$i].'\'','error'); continue; } if(!getimagesize($new_files['tmp_name'][$i])){ $app->enqueueMessage(JText::_('COM_DJCLASSIFIEDS_WRONG_IMAGE_TYPE').' : \''.$new_files['name'][$i].'\'','error'); continue; } $n_name = $last_id.'_'.$new_files['name'][$i]; $n_name = $lang->transliterate($n_name); $n_name = strtolower($n_name); $n_name = JFile::makeSafe($n_name); $new_path = JPATH_BASE."/components/com_djclassifieds/images/".$n_name; $nimg= 0; while(JFile::exists($new_path)){ $nimg++; $n_name = $last_id.'_'.$nimg.'_'.$new_files['name'][$i]; $n_name = $lang->transliterate($n_name); $n_name = strtolower($n_name); $n_name = JFile::makeSafe($n_name); $new_path = JPATH_BASE."/components/com_djclassifieds/images/".$n_name; } $images .= $n_name.';'; move_uploaded_file($new_files['tmp_name'][$i], $new_path); //DJClassifiedsImage::makeThumb($new_path, $nw, $nh, 'th'); DJClassifiedsImage::makeThumb($new_path, $nws, $nhs, 'ths'); DJClassifiedsImage::makeThumb($new_path, $nwm, $nhm, 'thm'); DJClassifiedsImage::makeThumb($new_path, $nwb, $nhb, 'thb'); }else if($new_files['name'][$i]){ $app->enqueueMessage(JText::_('COM_DJCLASSIFIEDS_WRONG_IMAGE_TYPE').' : \''.$new_files['name'][$i].'\'','error'); } } $row->image_url = $images; */ $row->image_url = ''; $duration_price = 0; if ($row->id == 0) { if ($par->get('durations_list', '')) { $exp_days = JRequest::getVar('exp_days', $par->get('exp_days'), '', 'int'); $query = "SELECT * FROM #__djcf_days WHERE days = " . $exp_days; $db->setQuery($query); $duration = $db->loadObject(); if ($duration) { $duration_price = $duration->price; } else { //$exp_days = $par->get('exp_days','7'); $message = JText::_('COM_DJCLASSIFIEDS_WRONG_DURATION_LIMIT'); $app->redirect($new_ad_link, $message, 'error'); } } else { $exp_days = $par->get('exp_days', '7'); } if ($exp_days == 0) { $row->date_exp = "2038-01-01 00:00:00"; } else { $row->date_exp = date("Y-m-d G:i:s", mktime(date("G"), date("i"), date("s"), date("m"), date("d") + $exp_days, date("Y"))); } if ($row->date_exp == '1970-01-01 1:00:00') { $row->date_exp = '2038-01-19 00:00:00'; } $row->exp_days = $exp_days; $row->date_start = date("Y-m-d H:i:s"); } $row->cat_id = end($_POST['cats']); if (!$row->cat_id) { $row->cat_id = $_POST['cats'][count($_POST['cats']) - 2]; } $row->cat_id = str_ireplace('p', '', $row->cat_id); /*if($par->get('region_add_type','1')){ $g_area = JRequest::getVar('g_area',''); $g_locality = JRequest::getVar('g_locality',''); $g_country = JRequest::getVar('g_country',''); $latlong = str_ireplace(array('(',')'), array('',''), JRequest::getVar('latlong','')); $query = "SELECT id FROM #__djcf_regions WHERE name = '".$g_area."'"; $db->setQuery($query); $parent_r_id = $db->loadResult(); if($parent_r_id){ $query = "SELECT id FROM #__djcf_regions WHERE name = '".$g_locality."' AND parent_id=".$parent_r_id; $db->setQuery($query); $region_id = $db->loadResult(); if($region_id){ $row->region_id=$region_id; }else{ $region_row = &JTable::getInstance('Regions', 'DJClassifiedsTable'); $region_row->country=0; $region_row->city=1; $region_row->name=$g_locality; $region_row->parent_id=$parent_r_id; //$ll = explode(',', $latlong); //$region_row->latitude=$ll[0]; //$region_row->longitude=$ll[0]; $region_row->published=1; //echo '<pre>';print_r($region_row);die(); if (!$region_row->store()){ exit (); } $row->region_id=$region_row->id; } }else{ $query = "SELECT id FROM #__djcf_regions WHERE name = '".$g_country."' "; $db->setQuery($query); $country_id = $db->loadResult(); if(!$country_id){$country_id=0;} $area_row = &JTable::getInstance('Regions', 'DJClassifiedsTable'); $area_row->country=0; $area_row->city=0; $area_row->name=$g_area; $area_row->parent_id=$country_id; $area_row->published=1; //echo '<pre>';print_r($region_row);die(); if (!$area_row->store()){ exit (); } $region_row = &JTable::getInstance('Regions', 'DJClassifiedsTable'); $region_row->country=0; $region_row->city=1; $region_row->name=$g_locality; $region_row->parent_id=$area_row->id; //$ll = explode(',', $latlong); //$region_row->latitude=$ll[0]; //$region_row->longitude=$ll[0]; $region_row->published=1; //echo '<pre>';print_r($region_row);die(); if (!$region_row->store()){ exit (); } $row->region_id=$region_row->id; } }else{*/ $row->region_id = end($_POST['regions']); if (!$row->region_id) { $row->region_id = $_POST['regions'][count($_POST['regions']) - 2]; } //} if (($row->region_id || $row->address) && ($row->latitude == '0.000000000000000' && $row->longitude == '0.000000000000000' || !$row->latitude && !$row->longitude)) { $address = ''; if ($row->region_id) { $reg_path = DJClassifiedsRegion::getParentPath($row->region_id); for ($r = count($reg_path) - 1; $r >= 0; $r--) { if ($reg_path[$r]->country) { $address = $reg_path[$r]->name; } if ($reg_path[$r]->city) { if ($address) { $address .= ', '; } $address .= $reg_path[$r]->name; } } } if ($address) { $address .= ', '; } $address .= $row->address; if ($row->post_code) { $address .= ', ' . $row->post_code; } $loc_coord = DJClassifiedsGeocode::getLocation($address); if (is_array($loc_coord)) { $row->latitude = $loc_coord['lat']; $row->longitude = $loc_coord['lng']; } } //echo '<pre>';print_r($row);die(); $row->user_id = $user->id; $row->ip_address = $_SERVER['REMOTE_ADDR']; $row->promotions = ''; if ($par->get('promotion', '1') == '1') { $query = "SELECT p.* FROM #__djcf_promotions p WHERE p.published=1 ORDER BY p.id "; $db->setQuery($query); $promotions = $db->loadObjectList(); foreach ($promotions as $prom) { if (JRequest::getVar($prom->name, '0')) { $row->promotions .= $prom->name . ','; } } if ($row->promotions) { $row->promotions = substr($row->promotions, 0, -1); } } else { if ($row->id > 0) { $row->promotions = $old_row->promotions; } } if (strstr($row->promotions, 'p_first')) { $row->special = 1; } else { $row->special = 0; } $cat = ''; if ($row->cat_id) { $query = "SELECT name,alias,price,autopublish FROM #__djcf_categories WHERE id = " . $row->cat_id; $db->setQuery($query); $cat = $db->loadObject(); if (!$cat->alias) { $cat->alias = DJClassifiedsSEO::getAliasName($cat->name); } } $is_new = 1; if ($row->id > 0) { $query = "SELECT * FROM #__djcf_items WHERE id = " . $row->id; $db->setQuery($query); $old_row = $db->loadObject(); $query = "DELETE FROM #__djcf_fields_values WHERE item_id= " . $row->id . " "; $db->setQuery($query); $db->query(); $query = "DELETE FROM #__djcf_fields_values_sale WHERE item_id= " . $row->id . " "; $db->setQuery($query); $db->query(); $row->payed = $old_row->payed; $row->pay_type = $old_row->pay_type; $row->exp_days = $old_row->exp_days; $row->alias = $old_row->alias; $row->published = $old_row->published; $is_new = 0; } if (!$row->alias) { $row->alias = DJClassifiedsSEO::getAliasName($row->name); } $dispatcher->trigger('onBeforePaymentsDJClassifiedsSaveAdvert', array(&$row, $is_new, &$cat, &$promotions)); if ($cat->autopublish == '0') { if ($par->get('autopublish') == '1') { $row->published = 1; if ($row->id) { $message = JText::_('COM_DJCLASSIFIEDS_AD_SAVED_SUCCESSFULLY'); } else { $message = JText::_('COM_DJCLASSIFIEDS_AD_ADDED_SUCCESSFULLY'); } } else { $row->published = 0; if ($row->id) { $message = JText::_('COM_DJCLASSIFIEDS_AD_SAVED_SUCCESSFULLY_WAITING_FOR_PUBLISH'); } else { $message = JText::_('COM_DJCLASSIFIEDS_AD_ADDED_SUCCESSFULLY_WAITING_FOR_PUBLISH'); } //$redirect="index.php?option=com_djclassifieds&view=items&cid=0".$itemid; $redirect = DJClassifiedsSEO::getItemRoute($row->id . ':' . $row->alias, $row->cat_id . ':' . $i->c_alias); } } elseif ($cat->autopublish == '1') { $row->published = 1; if ($row->id) { $message = JText::_('COM_DJCLASSIFIEDS_AD_SAVED_SUCCESSFULLY'); } else { $message = JText::_('COM_DJCLASSIFIEDS_AD_ADDED_SUCCESSFULLY'); } } elseif ($cat->autopublish == '2') { $row->published = 0; if ($row->id) { $message = JText::_('COM_DJCLASSIFIEDS_AD_SAVED_SUCCESSFULLY_WAITING_FOR_PUBLISH'); } else { $message = JText::_('COM_DJCLASSIFIEDS_AD_ADDED_SUCCESSFULLY_WAITING_FOR_PUBLISH'); } $redirect = DJClassifiedsSEO::getCategoryRoute('0:all'); } $pay_redirect = 0; $row->pay_type = ''; $row->payed = 1; //echo '<pre>';print_r($old_row);print_r($row);die(); if (isset($old_row)) { if ($cat->price == 0 && $row->promotions == '' && !strstr($old_row->pay_type, 'duration')) { $row->payed = 1; $row->pay_type = ''; } else { if ($old_row->cat_id != $row->cat_id && $cat->price > 0 || $old_row->promotions != $row->promotions || strstr($old_row->pay_type, 'duration') || $old_row->pay_type) { $row->pay_type = ''; if ($old_row->cat_id != $row->cat_id && $cat->price > 0) { $row->pay_type = 'cat,'; } else { if ($old_row->cat_id == $row->cat_id && $cat->price > 0 && strstr($old_row->pay_type, 'cat')) { $row->pay_type = 'cat,'; } } //if($old_row->promotions!=$row->promotions){ $prom_new = explode(',', $row->promotions); for ($pn = 0; $pn < count($prom_new); $pn++) { if (!strstr($old_row->promotions, $prom_new[$pn]) || strstr($old_row->pay_type, $prom_new[$pn])) { $row->pay_type .= $prom_new[$pn] . ','; } } //} if (strstr($old_row->pay_type, 'duration')) { $row->pay_type .= 'duration,'; } if ($row->pay_type) { $row->published = 0; $row->payed = 0; $pay_redirect = 1; } //echo $row->pay_type;print_r($old_row); //print_r($row);echo $pay_redirect;die(); } else { if ($row->payed == 0 && ($cat->price > 0 || $row->promotions != '')) { $row->payed = 0; $row->published = 0; $pay_redirect = 1; } } } } else { if ($cat->price > 0 || $row->promotions != '' || $duration_price > 0) { if ($cat->price > 0) { $row->pay_type .= 'cat,'; } if ($duration_price > 0) { $row->pay_type .= 'duration,'; } if ($row->promotions != '') { $row->pay_type .= $row->promotions; } $row->published = 0; $row->payed = 0; $pay_redirect = 1; } else { $row->payed = 1; $row->pay_type = ''; } } //check for free promotions if (!strstr($row->pay_type, 'cat') && !strstr($row->pay_type, 'duration') && strstr($row->pay_type, 'p_')) { $prom_to_pay = explode(',', $row->pay_type); $prom_price = 0; for ($pp = 0; $pp < count($prom_to_pay); $pp++) { foreach ($promotions as $prom) { if ($prom->name == $prom_to_pay[$pp]) { $prom_price += $prom->price; } } } if ($prom_price == 0) { $row->pay_type = ''; $redirect = ''; $pay_redirect = 0; if ($cat->autopublish == '0' && $par->get('autopublish') == '1' || $cat->autopublish == '1') { $row->published = 1; } } } //echo '<pre>';print_r($row);die();echo '</pre>'; $dispatcher->trigger('onBeforeDJClassifiedsSaveAdvert', array(&$row, $is_new)); if (!$row->store()) { //echo $row->getError();exit (); } if ($is_new) { $query = "UPDATE #__djcf_items SET date_sort=date_start WHERE id=" . $row->id . " "; $db->setQuery($query); $db->query(); } $item_images = ''; $images_c = 0; if (!$is_new) { $query = "SELECT * FROM #__djcf_images WHERE item_id=" . $row->id . " AND type='item' "; $db->setQuery($query); $item_images = $db->loadObjectList('id'); $images_c = count($item_images); } $img_ids = JRequest::getVar('img_id', array(), 'post', 'array'); $img_captions = JRequest::getVar('img_caption', array(), 'post', 'array'); $img_images = JRequest::getVar('img_image', array(), 'post', 'array'); $img_id_to_del = ''; if ($item_images) { foreach ($item_images as $item_img) { $img_to_del = 1; foreach ($img_ids as $img_id) { if ($item_img->id == $img_id) { $img_to_del = 0; break; } } if ($img_to_del) { $images_c--; $path_to_delete = JPATH_ROOT . $item_img->path . $item_img->name; if (JFile::exists($path_to_delete . '.' . $item_img->ext)) { JFile::delete($path_to_delete . '.' . $item_img->ext); } if (JFile::exists($path_to_delete . '_ths.' . $item_img->ext)) { JFile::delete($path_to_delete . '_ths.' . $item_img->ext); } if (JFile::exists($path_to_delete . '_thm.' . $item_img->ext)) { JFile::delete($path_to_delete . '_thm.' . $item_img->ext); } if (JFile::exists($path_to_delete . '_thb.' . $item_img->ext)) { JFile::delete($path_to_delete . '_thb.' . $item_img->ext); } $img_id_to_del .= $item_img->id . ','; } } if ($img_id_to_del) { $query = "DELETE FROM #__djcf_images WHERE item_id=" . $row->id . " AND type='item' AND ID IN (" . substr($img_id_to_del, 0, -1) . ") "; $db->setQuery($query); $db->query(); } } $last_id = $row->id; $imglimit = $par->get('img_limit', '3'); $nw = (int) $par->get('th_width', -1); $nh = (int) $par->get('th_height', -1); $nws = (int) $par->get('smallth_width', -1); $nhs = (int) $par->get('smallth_height', -1); $nwm = (int) $par->get('middleth_width', -1); $nhm = (int) $par->get('middleth_height', -1); $nwb = (int) $par->get('bigth_width', -1); $nhb = (int) $par->get('bigth_height', -1); $img_ord = 1; $img_to_insert = 0; $query_img = "INSERT INTO #__djcf_images(`item_id`,`type`,`name`,`ext`,`path`,`caption`,`ordering`) VALUES "; $new_img_path = JPATH_SITE . "/components/com_djclassifieds/images/item/"; for ($im = 0; $im < count($img_ids); $im++) { if ($img_ids[$im]) { if ($item_images[$img_ids[$im]]->ordering != $img_ord || $item_images[$img_ids[$im]]->caption != $img_captions[$im]) { $query = "UPDATE #__djcf_images SET ordering='" . $img_ord . "', caption='" . $db->escape($img_captions[$im]) . "' WHERE item_id=" . $row->id . " AND type='item' AND id=" . $img_ids[$im] . " "; $db->setQuery($query); $db->query(); } } else { if ($images_c >= $imglimit) { break; } $new_img_name = explode(';', $img_images[$im]); if (is_array($new_img_name)) { $new_img_name_u = JPATH_ROOT . '/tmp/djupload/' . $new_img_name[0]; if (JFile::exists($new_img_name_u)) { if (getimagesize($new_img_name_u)) { $new_img_n = $last_id . '_' . str_ireplace(' ', '_', $new_img_name[1]); $new_img_n = $lang->transliterate($new_img_n); $new_img_n = strtolower($new_img_n); $new_img_n = JFile::makeSafe($new_img_n); $nimg = 0; $name_parts = pathinfo($new_img_n); $img_name = $name_parts['filename']; $img_ext = $name_parts['extension']; $new_path_check = $new_img_path . $new_img_n; $new_path_check = str_ireplace('.' . $img_ext, '_thm.' . $img_ext, $new_path_check); while (JFile::exists($new_path_check)) { $nimg++; $new_img_n = $last_id . '_' . $nimg . '_' . str_ireplace(' ', '_', $new_img_name[1]); $new_img_n = $lang->transliterate($new_img_n); $new_img_n = strtolower($new_img_n); $new_img_n = JFile::makeSafe($new_img_n); $new_path_check = $new_img_path . $new_img_n; $new_path_check = str_ireplace('.' . $img_ext, '_thm.' . $img_ext, $new_path_check); } rename($new_img_name_u, $new_img_path . $new_img_n); $name_parts = pathinfo($new_img_n); $img_name = $name_parts['filename']; $img_ext = $name_parts['extension']; DJClassifiedsImage::makeThumb($new_img_path . $new_img_n, $new_img_path . $img_name . '_ths.' . $img_ext, $nws, $nhs); DJClassifiedsImage::makeThumb($new_img_path . $new_img_n, $new_img_path . $img_name . '_thm.' . $img_ext, $nwm, $nhm); DJClassifiedsImage::makeThumb($new_img_path . $new_img_n, $new_img_path . $img_name . '_thb.' . $img_ext, $nwb, $nhb); $query_img .= "('" . $row->id . "','item','" . $img_name . "','" . $img_ext . "','/components/com_djclassifieds/images/item/','" . $db->escape($img_captions[$im]) . "','" . $img_ord . "'), "; $img_to_insert++; if ($par->get('store_org_img', '1') == 0) { JFile::delete($new_img_path . $new_img_n); } } } } $images_c++; } $img_ord++; } if ($img_to_insert) { $query_img = substr($query_img, 0, -2) . ';'; $db->setQuery($query_img); $db->query(); } $imgfreelimit = $par->get('img_free_limit', '-1'); if ($imgfreelimit > -1 && $images_c > $imgfreelimit) { $extra_images = $images_c - $imgfreelimit; $images_to_pay = $extra_images; if (!$is_new) { if ($old_row->extra_images >= $images_to_pay) { $images_to_pay = 0; } else { $images_to_pay = $images_to_pay - $old_row->extra_images; } } $images_to_pay = $images_to_pay + $old_row->extra_images_to_pay; if ($images_to_pay > 0) { $row->extra_images = $extra_images; $row->extra_images_to_pay = $images_to_pay; $row->pay_type .= 'extra_img,'; $row->published = 0; $row->payed = 0; $pay_redirect = 1; $row->store(); } } $desc_chars_limit = $par->get('pay_desc_chars_free_limit', 0); $desc_c = strlen($row->description); if ($par->get('pay_desc_chars', 0) && $desc_c > $desc_chars_limit) { $extra_chars = $desc_c - $desc_chars_limit; $chars_to_pay = $extra_chars; if (!$is_new) { if ($old_row->extra_chars >= $chars_to_pay) { $chars_to_pay = 0; } else { $chars_to_pay = $chars_to_pay - $old_row->extra_chars; } } $chars_to_pay = $chars_to_pay + $old_row->extra_chars_to_pay; if ($chars_to_pay > 0) { $row->extra_chars = $extra_chars; $row->extra_chars_to_pay = $chars_to_pay; $row->pay_type .= 'extra_chars,'; $row->published = 0; $row->payed = 0; $pay_redirect = 1; $row->store(); } } $query = "SELECT f.* FROM #__djcf_fields f " . "LEFT JOIN #__djcf_fields_xref fx ON f.id=fx.field_id " . " WHERE fx.cat_id = " . $row->cat_id . " OR f.source=1 "; $db->setQuery($query); $fields_list = $db->loadObjectList(); //echo '<pre>'; print_r($db);print_r($fields_list);die(); $a_tags_cf = ''; if ((int) $par->get('allow_htmltags_cf', '0')) { $allowed_tags_cf = explode(';', $par->get('allowed_htmltags_cf', '')); for ($a = 0; $a < count($allowed_tags_cf); $a++) { $a_tags_cf .= '<' . $allowed_tags_cf[$a] . '>'; } } $ins = 0; if (count($fields_list) > 0) { $query = "INSERT INTO #__djcf_fields_values(`field_id`,`item_id`,`value`,`value_date`) VALUES "; foreach ($fields_list as $fl) { if ($fl->type == 'checkbox') { if (isset($_POST[$fl->name])) { $field_v = $_POST[$fl->name]; $f_value = ';'; for ($fv = 0; $fv < count($field_v); $fv++) { $f_value .= $field_v[$fv] . ';'; } $query .= "('" . $fl->id . "','" . $row->id . "','" . $db->escape($f_value) . "',''), "; $ins++; } } else { if ($fl->type == 'date') { if (isset($_POST[$fl->name])) { $f_var = JRequest::getVar($fl->name, '', '', 'string'); $query .= "('" . $fl->id . "','" . $row->id . "','','" . $db->escape($f_var) . "'), "; $ins++; } } else { if (isset($_POST[$fl->name])) { if ($a_tags_cf) { $f_var = JRequest::getVar($fl->name, '', '', 'string', JREQUEST_ALLOWRAW); $f_var = strip_tags($f_var, $a_tags_cf); } else { $f_var = JRequest::getVar($fl->name, '', '', 'string'); } $query .= "('" . $fl->id . "','" . $row->id . "','" . $db->escape($f_var) . "',''), "; $ins++; } } } } } //print_r($query);die(); if ($ins > 0) { $query = substr($query, 0, -2) . ';'; $db->setQuery($query); $db->query(); } $query = "SELECT f.* FROM #__djcf_fields f " . "LEFT JOIN #__djcf_fields_xref fx ON f.id=fx.field_id " . "WHERE fx.cat_id = " . $row->cat_id . " AND f.in_buynow=1 "; $db->setQuery($query); $fields_list = $db->loadObjectList(); //echo '<pre>'; print_r($_POST);print_r($fields_list);die(); $ins = 0; if (count($fields_list) > 0) { $query = "INSERT INTO #__djcf_fields_values_sale(`item_id`,`quantity`,`options`) VALUES "; $bn_quantity = JRequest::getVar('bn-quantity', array()); $quantity_total = 0; foreach ($fields_list as &$fl) { $fl->bn_values = JRequest::getVar('bn-' . $fl->name, array()); } $bn_options = array(); for ($q = 0; $q < count($bn_quantity); $q++) { if ($bn_quantity[$q] == '' || $bn_quantity[$q] == 0) { continue; } $bn_option = array(); $bn_option['quantity'] = $bn_quantity[$q]; $bn_option['options'] = array(); $quantity_total = $quantity_total + $bn_quantity[$q]; foreach ($fields_list as &$fl) { if ($fl->bn_values[$q]) { $bn_opt = array(); $bn_opt['id'] = $fl->id; $bn_opt['name'] = $fl->name; $bn_opt['label'] = $fl->label; $bn_opt['value'] = $fl->bn_values[$q]; $bn_option['options'][] = $bn_opt; } } if (count($bn_option['options'])) { $bn_options[] = $bn_option; } } if (count($bn_options)) { foreach ($bn_options as $opt) { $query .= "('" . $row->id . "','" . $opt['quantity'] . "','" . $db->escape(json_encode($opt['options'])) . "'), "; $ins++; } if ($ins) { $query = substr($query, 0, -2) . ';'; $db->setQuery($query); $db->query(); $query = "UPDATE #__djcf_items SET quantity=" . $quantity_total . " WHERE id=" . $row->id . " "; $db->setQuery($query); $db->query(); } } } if ($par->get('notify_admin', '0')) { if ($id > 0) { $new_ad = 0; } else { $new_ad = 1; } if ($par->get('notify_admin', '0') == 1) { DJClassifiedsNotify::notifyAdmin($row, $cat, $new_ad); } else { if ($par->get('notify_admin', '0') == 2 && $id == 0) { DJClassifiedsNotify::notifyAdmin($row, $cat, $new_ad); } } } if ($id == 0 && $par->get('user_new_ad_email', '0') && ($user->id > 0 || $par->get('email_for_guest', '0') && $row->email)) { DJClassifiedsNotify::notifyNewAdvertUser($row, $cat); } $dispatcher->trigger('onAfterDJClassifiedsSaveAdvert', array(&$row, $is_new)); if ($pay_redirect == 1) { $menu_uads_itemid = $menus->getItems('link', 'index.php?option=com_djclassifieds&view=useritems', 1); $redirect = 'index.php?option=com_djclassifieds&view=payment&id=' . $row->id; if ($menu_uads_itemid) { $redirect .= '&Itemid=' . $menu_uads_itemid->id; } //$redirect= 'index.php?option=com_djclassifieds&view=payment&id='.$row->id.$itemid; if ($row->id) { $message = JTExt::_('COM_DJCLASSIFIEDS_AD_SAVED_SUCCESSFULLY_CHOOSE_PAYMENT'); } else { $message = JTExt::_('COM_DJCLASSIFIEDS_AD_ADDED_SUCCESSFULLY_CHOOSE_PAYMENT'); } } if (!$redirect) { //$redirect= 'index.php?option=com_djclassifieds&view=item&cid='.$row->cat_id.'&id='.$row->id.$itemid; $redirect = DJClassifiedsSEO::getItemRoute($row->id . ':' . $row->alias, $row->cat_id . ':' . $cat->alias); } $redirect = JRoute::_($redirect, false); $app->redirect($redirect, $message); }
function renew() { $app = JFactory::getApplication(); JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables'); jimport('joomla.database.table'); $row = JTable::getInstance('Items', 'DJClassifiedsTable'); $par = JComponentHelper::getParams('com_djclassifieds'); $user = JFactory::getUser(); $db = JFactory::getDBO(); $id = JRequest::getVar('id', 0, '', 'int'); $it = JRequest::getVar('Itemid', 0, '', 'int'); $order = JRequest::getCmd('order', $par->get('items_ordering', 'date_e')); $ord_t = JRequest::getCmd('ord_t', $par->get('items_ordering_dir', 'desc')); $query = "SELECT i.*, c.price as c_price FROM #__djcf_items i " . "LEFT JOIN #__djcf_categories c ON c.id=i.cat_id " . "WHERE i.id='" . $id . "' LIMIT 1"; $db->setQuery($query); $item = $db->loadObject(); if ($user->id != $item->user_id) { $message = JText::_('COM_DJCLASSIFIEDS_WRONG_AD'); $redirect = "index.php?option=com_djclassifieds&view=useritems&Itemid=" . $it; $redirect = JRoute::_($redirect, false); $app->redirect($redirect, $message, 'error'); } $row->load($item->id); $renew_date = date("Y-m-d G:i:s", mktime(date("G"), date("i"), date("s"), date("m"), date("d") + $par->get('renew_days', '3'), date("Y"))); if ($renew_date <= $row->date_exp) { $message = JText::_('COM_DJCLASSIFIEDS_WRONG_AD'); $redirect = "index.php?option=com_djclassifieds&view=useritems&Itemid=" . $it; $redirect = JRoute::_($redirect, false); $app->redirect($redirect, $message, 'error'); } $days_left = strtotime($row->date_exp) - mktime(); /*$days_to_add=0; if($days_left>86400){ $days_to_add = round($days_left/86400); }*/ $row->date_exp = date("Y-m-d G:i:s", mktime(date("G"), date("i"), date("s") + $days_left, date("m"), date("d") + $row->exp_days, date("Y"))); $row->date_sort = date("Y-m-d H:i:s"); $duration_price = 0; if ($par->get('durations_list', '')) { $query = "SELECT price_renew FROM #__djcf_days WHERE days = " . $row->exp_days; $db->setQuery($query); $duration_price = $db->loadResult(); } if ($item->c_price > 0 || $row->promotions || $duration_price > 0) { $row->pay_type = ''; if ($item->c_price > 0) { $row->pay_type = 'cat,'; } if ($duration_price > 0) { $row->pay_type .= 'duration_renew,'; } if ($row->promotions) { $row->pay_type .= $row->promotions; } $row->published = 0; $row->payed = 0; $pay_redirect = 1; $query = "DELETE FROM #__djcf_payments WHERE item_id = " . $item->id; $db->setQuery($query); $db->query(); } $row->store(); if ($pay_redirect == 1) { $redirect = 'index.php?option=com_djclassifieds&view=payment&id=' . $row->id . '&Itemid=' . $it; $message = JTExt::_('COM_DJCLASSIFIEDS_AD_RENEWED_SUCCESSFULLY_CHOOSE_PAYMENT'); } else { $redirect = 'index.php?option=com_djclassifieds&view=useritems&Itemid=' . $it . '&order=' . $order . '&ord_t=' . $ord_t; $message = JText::_('COM_DJCLASSIFIEDS_AD_RENEWED_SUCCESSFULLY'); } $redirect = JRoute::_($redirect, false); $app->redirect($redirect, $message); }
<?php // echo $this->loadTemplate('social'); ?> </div> <div class="clear"></div> <?php echo $this->loadTemplate('vehicle'); ?> <?php if (count($this->individuals)) { ?> <h3 class="team-inds"><?php echo JTExt::_('COM_TRACKS_VIEW_TEAM_INDIVIDUALS'); ?> </h3> <?php foreach ($this->individuals as $proj) { ?> <div class="project-inds"><span class="project-title"><?php echo current($proj)->project_name; ?> </span> <?php foreach ($proj as $i) { ?> <?php $text = ($i->number ? $i->number . ' ' : '') . $i->first_name . ' ' . $i->last_name; ?>
</table> </fieldset> </td> </tr> <tr> <td colspan="4"> <fieldset><legend><?php echo JText::_('COM_ONEPAGE_GENERAL_PANEL'); ?> </legend> <textarea style="width: 100%;" rows="6"> #<?php echo JTExt::_('COM_ONEPAGE_XML_EXPORT_CRONSETTINGS') . "\n" . '#' . JText::_('COM_ONEPAGE_XML_EXPORT_CRONSETTINGS_DOCUMENTROOT') . ' ' . $_SERVER['DOCUMENT_ROOT'] . "\n" . '#' . JText::_('COM_ONEPAGE_XML_EXPORT_CRONSETTINGS_WGET') . ': ' . $this->xml_live_site . 'index.php?option=com_onepage&view=xmlexport&nosef=1&tmpl=component&format=opchtml' . "\n\n"; ?> 40 1 * * * nice -n 15 php <?php echo JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_onepage' . DS . 'export' . DS . 'export.php'; ?> > /dev/null </textarea></fieldset> </td> </tr> </table> </fieldset> <?php ?>
public function plgVmOnPaymentNotification() { if (JRequest::getVar('pelement') != 'kaznachey') { return null; } if (!class_exists('VirtueMartModelOrders')) { require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php'; } $order_id = JRequest::getVar('order_number'); $order = VirtueMartModelOrders::getOrder($order_id); $error = false; $method = $this->getVmPluginMethod($order['details']['BT']->virtuemart_paymentmethod_id); if ($method) { $request_json = file_get_contents('php://input'); $request = json_decode($request_json, true); $request_sign = md5($request["ErrorCode"] . $request["OrderId"] . $request["MerchantInternalPaymentId"] . $request["MerchantInternalUserId"] . number_format($request["OrderSum"], 2, ".", "") . number_format($request["Sum"], 2, ".", "") . strtoupper($request["Currency"]) . $request["CustomMerchantInfo"] . strtoupper($method->secret_key)); if ($request['SignatureEx'] == $request_sign) { $order['order_status'] = $method->status_success; $order['virtuemart_order_id'] = "{$order_id}"; $order['customer_notified'] = 0; $order['comments'] = JTExt::sprintf('VMPAYMENT_kaznachey_PAYMENT_CONFIRMED', $order_id); if (!class_exists('VirtueMartModelOrders')) { require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php'; } $modelOrder = new VirtueMartModelOrders(); ob_start(); $modelOrder->updateStatusForOneOrder($order_id, $order, true); ob_end_clean(); } else { $error = "WRONG_SIGNATURE"; } if ($error) { $order['order_status'] = $method->status_canceled; $order['virtuemart_order_id'] = "{$order_id}"; $order['customer_notified'] = 0; $order['comments'] = JTExt::sprintf("VMPAYMENT_kaznachey_PAYMENT_ERROR: {$error}", $order_id); if (!class_exists('VirtueMartModelOrders')) { require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php'; } $modelOrder = new VirtueMartModelOrders(); ob_start(); $modelOrder->updateStatusForOneOrder($order_id, $order, true); ob_end_clean(); } } exit; return null; }
/** * logic to save an event * * @access public * @return void * @since 0.9 */ function save() { // Check for request forgeries JRequest::checkToken() or die('Invalid Token'); $db = JFactory::getDBO(); $task = JRequest::getVar('task'); $post = JRequest::get('post', 4); /* Get the form fields to display */ $showfields = ''; foreach ($post as $field => $value) { if (substr($field, 0, 9) == 'showfield' && $value == "1") { $showfields .= substr($field, 9) . ","; } } $post['showfields'] = substr($showfields, 0, -1); if (!isset($post['checked_out'])) { $post['checked_out'] = 0; } /* Fix the submission types */ if (!$post['submission_types']) { $post['submission_types'] = array(); } else { $post['submission_types'] = implode(',', $post['submission_types']); } $model = $this->getModel('event'); $model_wait = $this->getModel('waitinglist'); if ($returnid = $model->store($post)) { $msg = JText::_('COM_REDEVENT_EVENT_SAVED'); if (isset($post['venueid']) && $post['venueid']) { if (!($xref = $this->_saveInitialSession($returnid))) { $msg .= "\n" . JTExt::_('COM_REDEVENT_EVENT_FAILED_SAVING_INITIAL_SESSION') . ': ' . $this->getError(); } if (JRequest::getVar('task') == 'saveAndTwit') { JPluginHelper::importPlugin('system', 'autotweetredevent'); $dispatcher =& JDispatcher::getInstance(); $res = $dispatcher->trigger('onAfterRedeventSessionSave', array($xref)); } } switch ($task) { case 'apply': $link = 'index.php?option=com_redevent&controller=events&view=event&hidemainmenu=1&cid[]=' . $returnid; break; default: $link = 'index.php?option=com_redevent&view=events'; break; } $cache =& JFactory::getCache('com_redevent'); $cache->clean(); } else { $msg = $model->getError(); $link = 'index.php?option=com_redevent&view=events'; } $model->checkin(); $this->setRedirect($link, $msg); }
function plgVmOnUserPaymentCancel() { if (!class_exists('VirtueMartModelOrders')) { require VMPATH_ADMIN . DS . 'models' . DS . 'orders.php'; } $tp_cart = json_decode($_SESSION['__vm']['vmcart']); $vm_order = VirtueMartModelOrders::getOrderIdByOrderNumber($tp_cart->order_number); $orderModel = VmModel::getModel('orders'); $order = $orderModel->getOrder($vm_order); if ($this->_vmpCtable->virtuemart_paymentmethod_id != $order['details']['BT']->virtuemart_paymentmethod_id) { return NULL; } echo '<script>alert("Pago Cancelado: Por favor intente nuevamente")</script>'; $modelOrder = new VirtueMartModelOrders(); $order['order_status'] = 'X'; $order['virtuemart_order_id'] = $vm_order; $order['customer_notified'] = 1; $order['comments'] = JTExt::sprintf("Pago Rechazado", $vm_order); $modelOrder->updateStatusForOneOrder($vm_order, $order, false); return true; }
</form> <div class="clearfix"></div> <table class="uk-table uk-table-striped"> <tr> <th width="20"><?php echo JText::_("GURU_ID"); ?> </th> <th><?php echo JText::_("GURU_NAME"); ?> </th> <th><?php echo JTExt::_("GURU_PUBLISHED"); ?> </th> </tr> <?php $pid = intval($_REQUEST['cid']); if ($n > 0) { for ($i = 0; $i < $n; $i++) { $file = $this->medias[$i]; $media_to_replace = $_GET['txt']; $id = $file->id; $checked = JHTML::_('grid.id', $i, $id); $asoc_file = $this->get_asoc_file_for_media($id); if ($file->type == 'quiz') { $the_quiz_id = $this->real_quiz_id($file->id);
* @copyright Copyright (C) 2008 Julien Vonthron. All rights reserved. * @license GNU/GPL, see LICENSE.php * Joomla Tracks is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * See COPYRIGHT.php for copyright notices and details. */ // no direct access defined('_JEXEC') or die('Restricted access'); $socials = TrackslibHelperTools::getTeamSocialItems($this->data); if (count($socials)) { ?> <div class="team-social"> <h3><?php echo JTExt::_('COM_TRACKS_TEAM_SOCIAL_LINKS'); ?> </h3> <ul> <?php foreach ($socials as $name => $s) { ?> <li class="ts-<?php echo $name; ?> "><span class="social-lbl"><?php echo $s->label; ?> </span>
} else if ($body == '') { alert("<?php echo JText::_('COM_VIRTUEMART_PRODUCT_EMAIL_ENTER_BODY'); ?> "); } else { var $statut = jQuery('select#order_items_status').val(); jQuery.post($customerMailLink, { subject:$subject, mailbody:$body, statut:$statut, token:'<?php echo JUtility::getToken(); ?> ' }, function (data) { alert('<?php echo addslashes(JTExt::_('COM_VIRTUEMART_PRODUCT_NOTIFY_MESSAGE_SENT')); ?> '); //jQuery("#customers-list-msg").html('<strong><?php echo JText::_('COM_VIRTUEMART_PRODUCT_NOTIFY_MESSAGE_SENT'); ?> </strong>'); //jQuery("#mail-subject").html(''); jQuery("#mail-body").html(''); } ); } } });
function _notify_url() { $db = JFactory::getDBO(); $par = JComponentHelper::getParams('com_djclassifieds'); $user = JFactory::getUser(); $id = JRequest::getInt('id', '0'); $app = JFactory::getApplication(); $itemid = JRequest::getInt("Itemid", ""); $przelewy24_info = $_POST; $przelewy24_ipn = new przelewy24_ipn(); $p24_session_id = $_POST["p24_session_id"]; $p24_order_id = $_POST["p24_order_id"]; $p24_id_sprzedawcy = $this->params["p24_id"]; $query = "SELECT p.* FROM #__djcf_payments p " . "WHERE p.id='" . $id . "' "; $db->setQuery($query); $payment = $db->loadObject(); $p24_kwota = $payment->price * 100; // $p24_kwota = WYNIK POBRANY Z TWOJEJ BAZY (w groszach) $res = $przelewy24_ipn->send_response($p24_id_sprzedawcy, $p24_session_id, $p24_order_id, $p24_kwota, $this->params); //print_R($res);die(); if ($res[0] != 'TRUE') { $message = JTExt::_('PLG_DJCFPRZELEWY24_AFTER_ERROR_MSG'); $redirect = 'index.php?option=com_djclassifieds&view=items&cid=0&Itemid=' . $itemid; $app->redirect($redirect, $message); die; } else { if ($payment) { $query = "UPDATE #__djcf_payments SET status='Completed',transaction_id='" . $p24_session_id . "' " . "WHERE id=" . $id . " AND method='djcfPrzelewy24'"; $db->setQuery($query); $db->query(); if ($payment->type == 2) { $date_sort = date("Y-m-d H:i:s"); $query = "UPDATE #__djcf_items SET date_sort='" . $date_sort . "' " . "WHERE id=" . $payment->item_id . " "; $db->setQuery($query); $db->query(); } else { if ($payment->type == 1) { $query = "SELECT p.points FROM #__djcf_points p WHERE p.id='" . $payment->item_id . "' "; $db->setQuery($query); $points = $db->loadResult(); $query = "INSERT INTO #__djcf_users_points (`user_id`,`points`,`description`) " . "VALUES ('" . $payment->user_id . "','" . $points . "','" . JText::_('COM_DJCLASSIFIEDS_POINTS_PACKAGE') . " Przelewy24 <br />" . JText::_('COM_DJCLASSIFIEDS_PAYMENT_ID') . ' ' . $payment->id . "')"; $db->setQuery($query); $db->query(); } else { $query = "SELECT c.* FROM #__djcf_items i, #__djcf_categories c " . "WHERE i.cat_id=c.id AND i.id='" . $payment->item_id . "' "; $db->setQuery($query); $cat = $db->loadObject(); $pub = 0; if ($cat->autopublish == '1' || $cat->autopublish == '0' && $par->get('autopublish') == '1') { $pub = 1; } $query = "UPDATE #__djcf_items SET payed=1, pay_type='', published='" . $pub . "' " . "WHERE id=" . $payment->item_id . " "; $db->setQuery($query); $db->query(); } } } } $message = JTExt::_('PLG_DJCFPRZELEWY24_AFTER_SUCCESSFULL_MSG'); $redirect = 'index.php?option=com_djclassifieds&view=items&cid=0&Itemid=' . $itemid; $app->redirect($redirect, $message); }
function update_status($status, $order_id, $text = 'VMPAYMENT_SEB_PAYMENT_CANCELED') { if ($order_id) { // send the email only if payment has been accepted if (!class_exists('VirtueMartModelOrders')) { require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php'; } $modelOrder = new VirtueMartModelOrders(); $order['order_status'] = $status; $order['virtuemart_order_id'] = $order_id; $order['customer_notified'] = 1; $order['comments'] = JTExt::sprintf($text, $order_id); $modelOrder->updateStatusForOneOrder($order_id, $order, true); } }
function delete_keywords($ids) { $db =& JFactory::getDBO(); $query = "select count(*) from " . TABLE_CROSSWORDS_QUESTIONS . " where keyid in (" . $ids . ")"; $db->setQuery($query); $count = (int) $db->loadResult(); if ($count == 0) { $query = "delete from " . TABLE_CROSSWORDS_KEYWORDS . " where id in (" . $ids . ")"; $db->setQuery($query); if ($db->query()) { return true; } else { return false; } } else { $this->setError(JTExt::_('MSG_CASCADE_DELETE')); return false; } }
?> </th> <th width="20px"><?php echo JHtml::_('grid.sort', JText::_('COM_JTG_VOTING'), 'vote', @$this->lists['order_Dir'], @$this->lists['order'], 'files'); ?> </th> <th width="20px"><?php echo JHtml::_('grid.sort', JText::_('COM_JTG_DISTANCE'), 'distance', @$this->lists['order_Dir'], @$this->lists['order'], 'files'); ?> </th> </tr> </thead> <tbody> <?php $edit = JTExt::_('edit'); $delete = JTExt::_('delete'); $edit = "title=\"" . $edit . "\" alt=\"" . $edit . "\""; $delete = "title=\"" . $delete . "\" alt=\"" . $delete . "\""; $k = 0; for ($i = 0, $n = count($this->rows); $i < $n; $i++) { $row = $this->rows[$i]; $terrain = JtgHelper::parseMoreTerrains($this->sortedter, $row->terrain, "array"); $terrain = implode(", ", $terrain); if ($this->cfg->unit == "Miles") { $distance = JtgHelper::getLocatedFloat(JtgHelper::getMiles($row->distance, "-", "Miles")); } else { $distance = JtgHelper::getLocatedFloat($row->distance, "-", "km"); } $votes = LayoutHelper::parseVoteFloat($row->vote); $link = JRoute::_('index.php?option=com_jtg&view=files&layout=file&id=' . $row->id, false); $cats = JtgHelper::parseMoreCats($this->cats, $row->catid, "array");
<!-- filters --> <?php $toggle = $this->params->get('filter_toggle', 3); ?> <?php if ($toggle != 1 || $this->params->get('display_limit_select')) { ?> <div id="el_filter" class="floattext"> <?php if ($toggle != 1 || 1) { ?> <?php if ($toggle > 1) { ?> <div id="filters-toggle"><?php echo JTExt::_('COM_REDEVENT_TOGGLE_FILTERS'); ?> </div> <?php } ?> <div class="el_fleft" id="el-events-filters"> <?php if ($this->params->get('filter_text', 1) && $this->lists['filter_type']) { ?> <div id="main-filter"> <?php echo '<label for="filter_type">' . JText::_('COM_REDEVENT_FILTER') . '</label> '; echo $this->lists['filter_type'] . ' '; ?> <input type="text" name="filter" id="filter" value="<?php
?> <?php echo $this->lists['filter_waiting']; ?> <?php echo $this->lists['filter_cancelled']; ?> </td> </tr> </table> <?php if ($this->cancelled) { ?> <div class="cancelled-notice"><?php echo $this->cancelled == 1 ? JTExt::_('COM_REDEVENT_CANCELLED_REGISTRATIONS') : JTExt::_('COM_REDEVENT_ALL_REGISTRATIONS'); ?> </div> <?php } ?> <table class="adminlist"> <thead> <tr> <th width="5">#</th> <th width="5"><input type="checkbox" name="toggle" value="" onClick="checkAll(<?php echo count($this->rows); ?> );" /></th> <th class="title"><?php
/*------------------------------------------------------------------------ # com_guru # ------------------------------------------------------------------------ # author iJoomla # copyright Copyright (C) 2013 ijoomla.com. All Rights Reserved. # @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL # Websites: http://www.ijoomla.com # Technical Support: Forum - http://www.ijoomla.com.com/forum/index/ -------------------------------------------------------------------------*/ defined('_JEXEC') or die('Restricted access'); $plans = $this->plans; $guruModelguruEditplans = new guruModelguruEditplans(); $config = $guruModelguruEditplans->getConfigs(); $currency = $config["0"]["currency"]; $character = JTExt::_("GURU_CURRENCY_" . $currency); $course_id = intval(JRequest::getVar("course_id", "0")); $action = JRequest::getVar("action", ""); $my = JFactory::getUser(); $user_id = $my->id; $db = JFactory::getDBO(); $document = JFactory::getDocument(); jimport('joomla.language.helper'); $lang_value = JLanguageHelper::detectLanguage(); $lang = new JLanguage(); $lang->load('com_guru', JPATH_BASE, $lang_value); $Itemid = JRequest::getVar("Itemid", "0"); ?> <link rel="stylesheet" href="<?php echo JURI::root() . 'components/com_guru/css/uikit.almost-flat.min.css';
function retornaHtmlPagamento($order, $method, $redir) { $lang = JFactory::getLanguage(); $filename = 'com_virtuemart'; $lang->load($filename, JPATH_ADMINISTRATOR); $vendorId = 0; if (isset($order["details"]["ST"])) { $endereco = "ST"; } else { $endereco = "BT"; } $dbValues = array(); $dbValues['payment_name'] = $this->renderPluginName($method); $html = '<table>' . "\n"; $html .= $this->getHtmlRow('STANDARD_PAYMENT_INFO', $dbValues['payment_name']); if (!empty($payment_info)) { $lang =& JFactory::getLanguage(); if ($lang->hasKey($method->payment_info)) { $payment_info = JTExt::_($method->payment_info); } else { $payment_info = $method->payment_info; } $html .= $this->getHtmlRow('STANDARD_PAYMENTINFO', $payment_info); } if (!class_exists('CurrencyDisplay')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php'; } $currency = CurrencyDisplay::getInstance('', $order['details']['BT']->virtuemart_vendor_id); $html .= $this->getHtmlRow('STANDARD_ORDER_NUMBER', $order['details']['BT']->order_number); $html .= $this->getHtmlRow('STANDARD_AMOUNT', $currency->priceDisplay($order['details']['BT']->order_total)); $html .= '</table>' . "\n"; //buscar forma de envio /* $db = &JFactory::getDBO(); $q = 'SELECT `shipment_element` FROM `#__virtuemart_shipmentmethods` WHERE `virtuemart_shipmentmethod_id`="' . $order["details"][$endereco]->virtuemart_shipmentmethod_id . '" '; $db->setQuery($q); $envio = $db->loadResult(); if (stripos($envio, "sedex") === false && stripos($envio, "pac") === false) { $tipo_frete = $method->tipo_frete ? 'SD' : 'EN'; // Encomenda Pac ou Sedex } elseif (stripos($envio, "sedex") !== false) { $tipo_frete = "SD"; } else { $tipo_frete = "EN"; } */ // configuração dos campos $campo_complemento = $method->campo_complemento; $campo_numero = $method->campo_numero; $html .= '<form id="frm_pagseguro" action="https://pagseguro.uol.com.br/v2/checkout/payment.html" method="post" > '; $html .= ' <input type="hidden" name="receiverEmail" value="' . $method->email_cobranca . '" /> <input type="hidden" name="currency" value="BRL" /> <input type="hidden" name="tipo" value="CP" /> <input type="hidden" name="encoding" value="utf-8" />'; if (isset($order["details"][$endereco]) and isset($order["details"][$endereco]->{$campo_complemento})) { $complemento = $order["details"][$endereco]->{$campo_complemento}; } else { $complemento = ''; } if (isset($order["details"][$endereco]) and isset($order["details"][$endereco]->{$campo_numero})) { $numero = $order["details"][$endereco]->{$campo_numero}; } else { $numero = ''; } $html .= '<input name="reference" type="hidden" value="' . ($order["details"][$endereco]->order_number != '' ? $order["details"][$endereco]->order_number : $order["details"]["BT"]->order_number) . '">'; $html .= '<input type="hidden" name="senderName" value="' . ($order["details"][$endereco]->first_name != '' ? $order["details"][$endereco]->first_name : $order["details"]["BT"]->first_name) . ' ' . ($order["details"][$endereco]->last_name != '' ? $order["details"][$endereco]->last_name : $order["details"]["BT"]->last_name) . '" /> <input type="hidden" name="shippingType" value="' . $method->tipo_frete . '" /> <input type="hidden" name="shippingAddressPostalCode" value="' . ($order["details"][$endereco]->zip != '' ? $order["details"][$endereco]->zip : $order["details"]["BT"]->zip) . '" /> <input type="hidden" name="shippingAddressStreet" value="' . ($order["details"][$endereco]->address_1 != '' ? $order["details"][$endereco]->address_1 : $order["details"]["BT"]->address_1) . ' ' . ($order["details"][$endereco]->address_2 != '' ? $order["details"][$endereco]->address_2 : $order["details"]["BT"]->address_2) . '" /> <input type="hidden" name="shippingAddressNumber" value="' . $numero . '" /> <input type="hidden" name="shippingAddressComplement" value="' . $complemento . '" /> <input type="hidden" name="shippingAddressCity" value="' . ($order["details"][$endereco]->city != '' ? $order["details"][$endereco]->city : $order["details"]["BT"]->city) . '" />'; $cod_estado = !empty($order["details"][$endereco]->virtuemart_state_id) ? $order["details"][$endereco]->virtuemart_state_id : $order["details"]["BT"]->virtuemart_state_id; $estado = ShopFunctions::getStateByID($cod_estado, "state_2_code"); $html .= ' <input type="hidden" name="shippingAddressState" value="' . $estado . '" /> <input type="hidden" name="shippingAddressCountry" value="BRA" /> <input type="hidden" name="senderAreaCode" value="" /> <input type="hidden" name="senderPhone" value="' . ($order["details"][$endereco]->phone_1 != '' ? $order["details"][$endereco]->phone_1 : $order["details"]["BT"]->phone_1) . '" /> <input type="hidden" name="senderEmail" value="' . ($order["details"][$endereco]->email != '' ? $order["details"][$endereco]->email : $order["details"]["BT"]->email) . '" />'; // total do frete // configurado para passar o frete do total da compra if (!empty($order["details"]["BT"]->order_shipment)) { $html .= '<input type="hidden" name="itemShippingCost1" value="' . number_format(round($order["details"][$endereco]->order_shipment != '' ? $order["details"][$endereco]->order_shipment : $order["details"]["BT"]->order_shipment, 2), 2, '.', '') . '">'; } else { $html .= '<input type="hidden" name="itemShippingCost1" value="0">'; } // desconto do pedido /* $order_discount = (float)$order["details"]["BT"]->order_discount; if (empty($order_discount) && (!empty($order["details"]["BT"]->coupon_discount))) { $order_discount = (float)$order["details"]["BT"]->coupon_discount; } $order_discount = (-1)*abs($order_discount); if (!empty($order_discount)) { $html .= '<input type="hidden" name="extraAmount" value="'.number_format($order_discount,2,'.','').'" />'; } */ // Cupom de Desconto $desconto_pedido = $order["details"]['BT']->coupon_discount; //$desconto_pedido*= -1; $html .= '<input type="hidden" name="extras" value="' . number_format($desconto_pedido, 2, ",", "") . '" />'; $order_subtotal = $order['details']['BT']->order_subtotal; if (!class_exists('VirtueMartModelCustomfields')) { require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'customfields.php'; } if (!class_exists('VirtueMartModelProduct')) { require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'product.php'; } $i = 0; $product_model = VmModel::getModel('product'); foreach ($order['items'] as $p) { $i++; $valor_produto = $p->product_final_price; // desconto do pedido $valor_item = $valor_produto; $pr = $product_model->getProduct($p->virtuemart_product_id); $product_attribute = strip_tags(VirtueMartModelCustomfields::CustomsFieldOrderDisplay($p, 'FE')); $html .= '<input type="hidden" name="itemId' . $i . '" value="' . $p->virtuemart_order_item_id . '"> <input type="hidden" name="itemDescription' . $i . '" value="' . $p->order_item_name . '"> <input type="hidden" name="itemQuantity' . $i . '" value="' . $p->product_quantity . '"> <input type="hidden" name="itemAmount' . $i . '" value="' . number_format(round($p->product_final_price, 2), 2, '.', '') . '"> <input type="hidden" name="itemWeight' . $i . '" value="1">'; /* <input type="hidden" name="itemWeight' . $i . '" value="' .round( ShopFunctions::convertWeigthUnit($pr->product_weight, $pr->product_weight_uom, "GR"),2) . '"> */ } $url = JURI::root(); $url_lib = $url . DS . 'plugins' . DS . 'vmpayment' . DS . 'pagseguro_virtuemartbrasil' . DS; $url_imagem_pagamento = $url_lib . 'imagens' . DS . 'pagseguro.gif'; // segundos para redirecionar para o Pagseguro if ($redir) { // segundos para redirecionar para o Pagseguro $segundos = $method->segundos_redirecionar; $html .= '<br/><br/>Você será direcionado para a tela de pagamento em ' . $segundos . ' segundo(s), ou então clique logo abaixo:<br />'; $html .= '<script>setTimeout(\'document.getElementById("frm_pagseguro").submit();\',' . $segundos . '000);</script>'; } $html .= '<div align="center"><br /><input type="image" value="Clique aqui para efetuar o pagamento" src="' . $url_imagem_pagamento . '" /></div>'; $html .= '</form>'; return $html; }
} if ($this->config['show_comments_count'] > 0) { ?> <th class="center"><?php echo JText::_('COM_JOOMLEAGUE_RESULTS_COMMENTS'); ?> </th> <?php } } else { ?> <th colspan="<?php echo $nbcols; ?> "><?php echo JHTML::date($date, JTExt::_('COM_JOOMLEAGUE_RESULTS_GAMES_DATE_DAY')); if ($this->config['show_matchday_dateheader']) { echo ' - ' . JText::sprintf('COM_JOOMLEAGUE_RESULTS_GAMEDAY_NB', $this->roundcode); } ?> </th> <?php } ?> </tr> <!-- DATE HEADER END--> <!-- GAMES --> <?php $k = 0; foreach ($games as $game) { $this->assignRef('game', $game);
public function plgVmOnPaymentNotification() { if (JRequest::getVar('pelement') != 'paykeeper') { return null; } if (!class_exists('VirtueMartModelOrders')) { require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php'; } $orderid = JRequest::getInt('WMI_PAYMENT_NO', 0); $postprice = floatval(JRequest::getVar('WMI_PAYMENT_AMOUNT')); $payment = $this->getDataByOrderId($orderid); $method = $this->getVmPluginMethod($payment->virtuemart_paymentmethod_id); $order_model = new VirtueMartModelOrders(); $order_info = $order_model->getOrder($orderid); $order_number = $order_info['details']['BT']->order_number; if (!$method->payment_currency) { $this->getPaymentCurrency($method); } // END printing out HTML Form code (Payment Extra Info) $q = 'SELECT `currency_code_3` FROM `#__virtuemart_currencies` WHERE `virtuemart_currency_id`="' . $method->payment_currency . '" '; $db =& JFactory::getDBO(); $db->setQuery($q); $currency_code_3 = $db->loadResult(); if (!class_exists('CurrencyDisplay')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php'; } $paymentCurrency = CurrencyDisplay::getInstance($method->payment_currency); $totalInPaymentCurrency = round($paymentCurrency->convertCurrencyTo($method->payment_currency, $order_info['details']['BT']->order_total, false), 2); $sig = JRequest::getVar('WMI_SIGNATURE'); $params = JRequest::get('post'); unset($params["WMI_SIGNATURE"]); uksort($params, "strcasecmp"); $values = implode('', $params); $signature = base64_encode(pack("H*", md5($values . $method->paykeeper_secret))); if ($totalInPaymentCurrency == $postprice && $sig == $signature) { switch (JRequest::getVar('WMI_ORDER_STATE')) { case 'Accepted': $status = $method->status_success; $msg = 'оплачен'; break; case 'Rejected': default: $status = $method->status_canceled; $msg = 'отменён'; break; } $order['order_status'] = $status; $order['virtuemart_order_id'] = $orderid; $order['customer_notified'] = 0; $order['comments'] = JTExt::sprintf('VMPAYMENT_PAYKEEPER_PAYMENT_CONFIRMED', $order_number); if (!class_exists('VirtueMartModelOrders')) { require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php'; } $modelOrder = new VirtueMartModelOrders(); ob_start(); $modelOrder->updateStatusForOneOrder($orderid, $order, true); ob_end_clean(); echo 'WMI_RESULT=OK'; exit; } echo 'WMI_RESULT=RETRY&WMI_DESCRIPTION=' . urlencode('Неверная подпись заказа'); return null; }
function _notify_url() { $db = JFactory::getDBO(); $par = JComponentHelper::getParams('com_djclassifieds'); $user = JFactory::getUser(); $id = JRequest::getInt('session_id', '0'); $app = JFactory::getApplication(); $itemid = JRequest::getInt("Itemid", ""); $payu_info = $_POST; $server = 'www.platnosci.pl'; $server_script = '/paygw/ISO/Payment/get'; $PLATNOSCI_POS_ID = $this->params["pos_id"]; $PLATNOSCI_KEY1 = $this->params["md5_key"]; $PLATNOSCI_KEY2 = $this->params["md5_key2"]; /*$fil = fopen('payu_data.txt', 'a'); fwrite($fil, "\n\n--------------------post_first-----------------\n"); $post = $_POST; foreach ($post as $key => $value) { fwrite($fil, $key.' - '.$value."\n"); } fclose($fil);*/ if (!isset($_POST['pos_id']) || !isset($_POST['session_id']) || !isset($_POST['ts']) || !isset($_POST['sig'])) { die('ERROR: EMPTY PARAMETERS'); } //-- brak wszystkich parametrow if ($_POST['pos_id'] != $PLATNOSCI_POS_ID) { die('ERROR: WRONG POS ID'); } //--- błędny numer POS $sig = md5($_POST['pos_id'] . $_POST['session_id'] . $_POST['ts'] . $PLATNOSCI_KEY2); if ($_POST['sig'] != $sig) { die('ERROR: WRONG SIGNATURE'); } //--- błędny podpis $ts = time(); $sig = md5($PLATNOSCI_POS_ID . $_POST['session_id'] . $ts . $PLATNOSCI_KEY1); $parameters = "pos_id=" . $PLATNOSCI_POS_ID . "&session_id=" . $_POST['session_id'] . "&ts=" . $ts . "&sig=" . $sig; $fsocket = false; $curl = false; $result = false; if (PHP_VERSION >= 4.3 && ($fp = @fsockopen('ssl://' . $server, 443, $errno, $errstr, 30))) { $fsocket = true; } elseif (function_exists('curl_exec')) { $curl = true; } if ($fsocket == true) { $header = 'POST ' . $server_script . ' HTTP/1.0' . "\r\n" . 'Host: ' . $server . "\r\n" . 'Content-Type: application/x-www-form-urlencoded' . "\r\n" . 'Content-Length: ' . strlen($parameters) . "\r\n" . 'Connection: close' . "\r\n\r\n"; @fputs($fp, $header . $parameters); $platnosci_response = ''; while (!@feof($fp)) { $res = @fgets($fp, 1024); $platnosci_response .= $res; } @fclose($fp); } elseif ($curl == true) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://" . $server . $server_script); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_TIMEOUT, 20); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $platnosci_response = curl_exec($ch); curl_close($ch); } else { die("ERROR: No connect method ...\n"); } if (eregi("<trans>.*<pos_id>([0-9]*)</pos_id>.*<session_id>(.*)</session_id>.*<order_id>(.*)</order_id>.*<amount>([0-9]*)</amount>.*<status>([0-9]*)</status>.*<desc>(.*)</desc>.*<ts>([0-9]*)</ts>.*<sig>([a-z0-9]*)</sig>.*</trans>", $platnosci_response, $parts)) { $result = $this->get_status($parts); } if ($result['code']) { //--- rozpoznany status transakcji $pos_id = $parts[1]; $session_id = $parts[2]; $order_id = $parts[3]; $amount = $parts[4]; //-- w groszach $status = $parts[5]; $desc = $parts[6]; $ts = $parts[7]; $sig = $parts[8]; /*$fil = fopen('payu_data.txt', 'a'); foreach ($result as $key => $value) { fwrite($fil, $key.' - '.$value."\n"); }*/ /* TODO: zmiana statusu transakcji w systemie Sklepu */ if ($result['code'] == '99') { $query = "SELECT p.* FROM #__djcf_payments p " . "WHERE p.id='" . $id . "' "; $db->setQuery($query); $payment = $db->loadObject(); if ($payment) { $query = "UPDATE #__djcf_payments SET status='Completed',transaction_id='" . $id . "' " . "WHERE id=" . $id . " AND method='djcfPayU'"; $db->setQuery($query); $db->query(); if ($payment->type == 2) { $date_sort = date("Y-m-d H:i:s"); $query = "UPDATE #__djcf_items SET date_sort='" . $date_sort . "' " . "WHERE id=" . $payment->item_id . " "; $db->setQuery($query); $db->query(); } else { if ($payment->type == 1) { $query = "SELECT p.points FROM #__djcf_points p WHERE p.id='" . $payment->item_id . "' "; $db->setQuery($query); $points = $db->loadResult(); $query = "INSERT INTO #__djcf_users_points (`user_id`,`points`,`description`) " . "VALUES ('" . $payment->user_id . "','" . $points . "','" . JText::_('COM_DJCLASSIFIEDS_POINTS_PACKAGE') . " PayU " . JText::_('COM_DJCLASSIFIEDS_PAYMENT_ID') . ' ' . $payment->id . "')"; $db->setQuery($query); $db->query(); } else { $query = "SELECT c.* FROM #__djcf_items i, #__djcf_categories c " . "WHERE i.cat_id=c.id AND i.id='" . $payment->item_id . "' "; $db->setQuery($query); $cat = $db->loadObject(); $pub = 0; if ($cat->autopublish == '1' || $cat->autopublish == '0' && $par->get('autopublish') == '1') { $pub = 1; } $query = "UPDATE #__djcf_items SET payed=1, pay_type='', published='" . $pub . "' " . "WHERE id=" . $payment->item_id . " "; $db->setQuery($query); $db->query(); } } } echo "OK"; exit; // udalo sie zapisac dane wiec odsylamy OK } else { if ($result['code'] == '2') { $query = "UPDATE #__djcf_payments SET status='Cancelled',transaction_id='" . $id . "' " . "WHERE id=" . $id . " AND method='djcfPayU'"; $db->setQuery($query); $db->query(); //if ($this->model->set_status_platnosci($session_id,0)){ echo "OK"; exit; //} // transakcja anulowana mozemy również anulować zamowienie } } // jezeli wszytskie operacje wykonane poprawnie wiec odsylamy ok // w innym przypadku należy wygenerować błąd // if ( wszystko_ok ) { echo "OK"; exit; // } else { // // } } else { /* TODO: obsługa powiadamiania o błędnych statusach transakcji*/ /*$fil = fopen('payu_data.txt', 'a'); fwrite($fil, "\n\n------------------------BLAD--------------\n"); fwrite($fil, "code=" . $result['code'] . " message=" . $result['message'] . "\n"); fwrite($fil, $platnosci_response . "\n\n");*/ // powiadomienie bedzie wysłane ponownie przez platnosci.pl // ewentualnie dodajemy sobie jakis wpis do logow ... } $message = JTExt::_('PLG_DJCFPAYU_AFTER_SUCCESSFULL_MSG'); $redirect = 'index.php?option=com_djclassifieds&view=items&cid=0&Itemid=' . $itemid; $app->redirect($redirect, $message); }