function save() { $data = JRequest::getVar('jform', array(), 'post', 'NONE', 4); $id = (int) $data['id']; if (empty($id)) { if (!igGeneralHelper::authorise('core.igalleryfront.create')) { return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); } } else { if (!igGeneralHelper::authorise('core.igalleryfront.edit', $id)) { return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); } } $model = $this->getModel(); $msg = ''; if (!$model->save($data)) { JError::raise(2, 500, $model->getError()); } else { $msg = JText::_('SUCCESSFULLY_SAVED'); } switch ($this->task) { case 'apply': $url = 'index.php?option=com_igallery&view=icategory&id=' . $id; break; case 'save': $url = 'index.php?option=com_igallery&view=categories'; } $this->setRedirect(JRoute::_($url, false), $msg); }
public function edit() { $input = JFactory::getApplication()->input; $id = $input->getInt('id'); $refid = $input->get('refid'); $adapter = JalangHelper::getHelperContent(); if ($adapter) { $linkEdit = $adapter->getEditLink($id); if (!$linkEdit) { JError::raise(E_WARNING, 300, $adapter->getError()); $this->setRedirect(JRoute::_('index.php?option=com_jalang&view=items', false)); return false; } /*$return = JRoute::_('index.php?option=com_jalang&view=items', false); $return = urlencode(base64_encode($return));*/ $linkEdit = JRoute::_($linkEdit . '&jaref=' . $adapter->table . '.' . $refid, false); if ($adapter->edit_context) { $app = JFactory::getApplication(); $this->holdEditId($adapter->edit_context, $id); $app->setUserState($adapter->edit_context . '.data', null); } $this->setRedirect($linkEdit); } else { JError::raise(E_ERROR, 500, JText::_('INVALID_REQUEST')); } }
/** * Method to set the setup language for the application. * * @return void * @since 1.6 */ public function setlanguage() { // Get the application object. $app = JFactory::getApplication(); // Check for potentially unwritable session $session = JFactory::getSession(); if ($session->isNew()) { JError::setErrorHandling(E_ERROR, 'message'); JError::raise(E_ERROR, 500, JText::_('INSTL_COOKIES_NOT_ENABLED')); return false; } // Check for request forgeries. JRequest::checkToken() or jexit(JText::_('JINVALID_TOKEN')); // Get the setup model. $model = $this->getModel('Setup', 'JInstallationModel', array('dbo' => null)); // Get the posted values from the request and validate them. $data = JRequest::getVar('jform', array(), 'post', 'array'); $return = $model->validate($data, 'language'); // Check for validation errors. if ($return === false) { // Get the validation messages. $errors = $model->getErrors(); // Push up to three validation messages out to the user. for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) { if (JError::isError($errors[$i])) { $app->enqueueMessage($errors[$i]->getMessage(), 'warning'); } else { $app->enqueueMessage($errors[$i], 'warning'); } } // Redirect back to the language selection screen. $this->setRedirect('index.php?view=language'); return false; } // Store the options in the session. $vars = $model->storeOptions($return); // Redirect to the next page. $this->setRedirect('index.php?view=preinstall'); }
function reportImage() { $model = $this->getModel(); $msg = ''; if (!$model->reportImage()) { JError::raise(2, 500, $model->getError()); return false; } else { $msg = JText::_('YOUR_MESSAGE_SENT'); $session = JFactory::getSession(); $url = $session->get('ig_report_url', JURI::root()) . '#!' . $model->urlHash; $this->setRedirect($url, $msg); } }
/** * Displays the form * * @param string $tpl - The templates * * @return mixed|void */ public function display($tpl = null) { $orga_id = JFactory::getApplication()->input->get('id', 0); $model = $this->getModel(); $params = JComponentHelper::getParams('com_matukio'); $menuitemid = JFactory::getApplication()->input->get('Itemid'); if ($menuitemid) { $site = new JSite(); $menu = $site->getMenu(); $menuparams = $menu->getParams($menuitemid); $params->merge($menuparams); } if (empty($orga_id)) { $orga_id = $params->get('organizerId', 0); } // Raise error if (empty($orga_id)) { JError::raise(E_ERROR, 403, JText::_("COM_MATUKIO_NO_ID")); } $organizer = $model->getOrganizer($orga_id); if (!empty($organizer)) { // Get the Joomla user obj $organizer_user = JFactory::getUser($organizer->userId); } else { $organizer_user = null; } $ue_title = $params->get('title', ''); if (empty($ue_title)) { // Set the title to the name $ue_title = $organizer->name; } $title = JFactory::getDocument()->getTitle(); JFactory::getDocument()->setTitle($title . " - " . JText::_($organizer->name)); // Plugin support $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('content'); $this->jevent = new stdClass(); $results = $dispatcher->trigger('onContentAfterDisplay', array('com_matukio.organizer', &$organizer, &$params, 0)); $this->jevent->afterDisplayContent = trim(implode("\n", $results)); $this->organizer = $organizer; $this->organizer_user = $organizer_user; $this->title = $ue_title; $this->user = JFactory::getUser(); // Upcoming events since 3.1 if (MatukioHelperSettings::getSettings("organizer_show_upcoming", 1) && !empty($organizer_user)) { $this->upcoming_events = $model->getUpcomingEvents($organizer_user->id); } parent::display($tpl); }
/** * Shows the form * * @param string $tpl - The tmpl * * @return bool|mixed|object */ public function display($tpl = null) { $uuid = JFactory::getApplication()->input->get('uuid', 0); if (empty($uuid)) { JError::raise(E_ERROR, 404, JText::_("COM_MATUKIO_NO_ID")); } $model = $this->getModel(); $booking = $model->getBooking($uuid); $event = $model->getEvent($booking->semid); if (empty($booking)) { JError::raise(E_ERROR, 404, JText::_("COM_MATUKIO_NO_ID")); } $this->uuid = $uuid; $this->booking = $booking; $this->event = $event; parent::display($tpl); }
function applyJob($options) { $query = "Insert into candidate (candidate_id,site_id,last_name,first_name,phone_home,phone_cell,phone_work,address,city,state,zip,key_skills,entered_by,owner,date_created,email1,best_time_to_call) values (NULL,'1','" . $options['lastname'] . "','" . $options['firstname'] . "','" . $options['homephone'] . "','" . $options['mobilephone'] . "','" . $options['workphone'] . "','" . $options['mailingaddress'] . "','" . $options['city'] . "','" . $options['state'] . "','" . $options['zip'] . "','" . $options['skill'] . "','" . $user->id . "','" . $user->id . "','" . date('Y-m-d H:i:s') . "','" . $options['email_address'] . "','" . $options['besttimetocall'] . "')"; $this->CatsDb->setQuery($query); $this->CatsDb->query(); $id = $this->CatsDb->insertID(); $query1 = "Insert into candidate_joborder (candidate_joborder_id,candidate_id,joborder_id,site_id,status,date_submitted,date_created,rating_value) values (NULL,'" . $id . "','" . $options['joborder_id'] . "','1','100','" . date('Y-m-d H:i:s') . "','" . date('Y-m-d H:i:s') . "','-1')"; $this->CatsDb->setQuery($query1); $this->CatsDb->query(); include_once JPATH_COMPONENT . DS . 'lib' . DS . 'Attachments.php'; $attachmentCreator = new AttachmentCreator(1, $this->CatsDb); if (!$attachmentCreator->createFromUpload('100', $id, 'cv', false, 1)) { jimport('joomla.error.error'); JError::raise(E_WARNING, 500, 'Problem uploading attachment<br>' . $attachmentCreator->getError(), $attachmentCreator->getError()); } //Inset vao bang activity $this->CatsDb->setQuery("Insert into activity (activity_id,data_item_id,data_item_type,joborder_id,site_id,entered_by,date_created,type,notes,date_modified) values (NULL,'" . $id . "','100','" . $options['joborder_id'] . "','1','1250','" . date('Y-m-d H:i:s') . "','400','User applied through candidate portal','" . date('Y-m-d H:i:s') . "')"); $this->CatsDb->query(); //Send mail to the manager job is to inform new people apply //fetch recruiter $this->CatsDb->setQuery("Select recruiter,title from joborder where joborder_id = '" . $options['joborder_id'] . "'"); $r = $this->CatsDb->loadObjectList(); $r = $r[0]; $this->CatsDb->setQuery("Select * from user where user_id = '" . $r->recruiter . "'"); $userRow = $this->CatsDb->loadObjectList(); $userRow = $userRow[0]; $htmlMessage = "<html><head><title>Recruiter Notification</title></head><body>"; $htmlMessage .= "<table cellpadding=0 cellspacing=0 width=100% style='border:1px solid #cccccc;padding:20px;'>"; $htmlMessage .= "<tr><td width=100%>"; $htmlMessage .= "<b>Dear " . $userRow->last_name . "</b>"; $htmlMessage .= "<br>This e-mail is a confirmation that new candidates have applied to your vacancy through our online recruitment system .."; $htmlMessage .= "<br><Br><b>Vacancy name:</b> " . $r->title; $htmlMessage .= "<br><b>Applicant Name : </b>" . $options['firstname'] . " " . $options['lastname'] . "."; $htmlMessage .= "<br><b>Candidate URL : </b> <a href='" . $this->Cats_install . "index.php?m=candidates&a=show&candidateID=" . $id . "'>" . $this->Cats_install . "index.php?m=candidates&a=show&candidateID=" . $id . "</a>."; $htmlMessage .= "<br><b>Job Order URL : </b> <a href='" . $this->Cats_install . "index.php?m=joborders&a=show&jobOrderID=" . $options['joborder_id'] . "'>" . $this->Cats_install . "index.php?m=joborders&a=show&jobOrderID=" . $options['joborder_id'] . "</a>."; $htmlMessage .= "<br><br>Administrator<br>Recruiter notification."; $htmlMessage .= "</td></tr></table></body></html>"; //Gui mail JUtility::sendMail($this->email, 'Recruiter notification', $userRow->email, 'Administrator - Candidate applied to an OpenCATS vacancy.', $htmlMessage, 1); $this->CatsDb->setQuery("Select questionnaire_id from joborder where joborder_id = '" . $options['joborder_id'] . "'"); $question = $this->CatsDb->loadResult(); $q['question'] = $question; $q['id'] = $id; return $q; }
function remove() { if (!igGeneralHelper::authorise('core.admin')) { return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); } if (!igGeneralHelper::authorise('core.delete')) { return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); } $model = $this->getModel(); if (!$model->checkAssigned()) { $this->setRedirect('index.php?option=com_igallery&view=profiles'); return; } if (!$model->delete()) { $msg = ''; JError::raise(2, 500, $model->getError()); } else { $msg = JText::_('SUCCESSFULLY_SAVED'); } $this->setRedirect('index.php?option=com_igallery&view=profiles', $msg); }
public function display($tpl = null) { $show_prices = VmConfig::get('show_prices', 1); if ($show_prices == '1') { if (!class_exists('calculationHelper')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'calculationh.php'; } } $this->assignRef('show_prices', $show_prices); if (!class_exists('shopFunctionsF')) { require VMPATH_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php'; } $document = JFactory::getDocument(); $app = JFactory::getApplication(); $pathway = $app->getPathway(); if (!class_exists('VmImage')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'image.php'; } // set search and keyword if ($keyword = vRequest::getString('keyword', false)) { //uword('keyword', false, ' ,-,+,.,_')) { $pathway->addItem($keyword); //$title .=' ('.$keyword.')'; } //$search = vRequest::uword('keyword', null); $this->searchcustom = ''; $this->searchCustomValues = ''; //if (!empty($keyword)) { $this->getSearchCustom(); $search = $keyword; /*} else { $keyword =''; $search = NULL; }*/ $this->assignRef('keyword', $keyword); $this->assignRef('search', $search); $menus = $app->getMenu(); $menu = $menus->getActive(); if (!empty($menu->id)) { ShopFunctionsF::setLastVisitedItemId($menu->id); } else { if ($itemId = vRequest::getInt('Itemid', false)) { ShopFunctionsF::setLastVisitedItemId($itemId); } } $virtuemart_manufacturer_id = vRequest::getInt('virtuemart_manufacturer_id', -1); if ($virtuemart_manufacturer_id === -1 and !empty($menu->query['virtuemart_manufacturer_id'])) { $virtuemart_manufacturer_id = $menu->query['virtuemart_manufacturer_id']; vRequest::setVar('virtuemart_manufacturer_id', $virtuemart_manufacturer_id); } $this->categoryId = vRequest::getInt('virtuemart_category_id', -1); if ($this->categoryId === -1 and !empty($menu->query['virtuemart_category_id'])) { $this->categoryId = $menu->query['virtuemart_category_id']; vRequest::setVar('virtuemart_category_id', $this->categoryId); } else { if ($this->categoryId === -1 and $virtuemart_manufacturer_id === -1) { $this->categoryId = ShopFunctionsF::getLastVisitedCategoryId(); } } $this->setCanonicalLink($tpl, $document, $this->categoryId, $virtuemart_manufacturer_id); if (($this->categoryId === -1 or $this->categoryId === 0) and $virtuemart_manufacturer_id) { $this->categoryId = 0; $catType = 'manufacturer'; $this->setCanonicalLink($tpl, $document, $virtuemart_manufacturer_id, $catType); } $categoryModel = VmModel::getModel('category'); $productModel = VmModel::getModel('product'); if ($this->categoryId === -1) { $this->categoryId = 0; } $vendorId = 1; $category = $categoryModel->getCategory($this->categoryId); if (!isset($menu->query['showproducts'])) { $menu->query['showproducts'] = 1; } $this->showproducts = vRequest::getInt('showproducts', $menu->query['showproducts']); if (!empty($category)) { $vendorId = $category->virtuemart_vendor_id; if ($this->showproducts) { //if(empty($category->category_layout) or $category->category_layout != 'categories') { // Load the products in the given category $ids = $productModel->sortSearchListQuery(TRUE, $this->categoryId); $this->perRow = empty($category->products_per_row) ? VmConfig::get('products_per_row', 3) : $category->products_per_row; $this->vmPagination = $productModel->getPagination($this->perRow); $ratingModel = VmModel::getModel('ratings'); $this->showRating = $ratingModel->showRating(); $productModel->withRating = $this->showRating; $this->orderByList = $productModel->getOrderByList($this->categoryId); $this->products = $productModel->getProducts($ids); //$products = $productModel->getProductsInCategory($this->categoryId); $imgAmount = VmConfig::get('prodimg_browse', 1); $productModel->addImages($this->products, $imgAmount); if ($this->products) { $currency = CurrencyDisplay::getInstance(); $this->assignRef('currency', $currency); $display_stock = VmConfig::get('display_stock', 1); $showCustoms = VmConfig::get('show_pcustoms', 1); if ($display_stock or $showCustoms) { if (!$showCustoms) { foreach ($this->products as $i => $productItem) { $productItem->stock = $productModel->getStockIndicator($productItem); } } else { shopFunctionsF::sortLoadProductCustomsStockInd($this->products, $productModel); } } // add javascript for price and cart, need even for quantity buttons, so we need it almost anywhere vmJsApi::jPrice(); } // Add feed links if ($this->showproducts and $this->products && VmConfig::get('feed_cat_published', 0) == 1) { $link = '&format=feed&limitstart='; $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'); $document->addHeadLink(JRoute::_($link . '&type=rss', FALSE), 'alternate', 'rel', $attribs); $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'); $document->addHeadLink(JRoute::_($link . '&type=atom', FALSE), 'alternate', 'rel', $attribs); } $user = JFactory::getUser(); $this->showBasePrice = (vmAccess::manager() or vmAccess::isSuperVendor()); } //No redirect here, for category id = 0 means show ALL categories! note by Max Milbers if (!empty($this->categoryId) and $this->categoryId !== -1 and (empty($category->slug) or !$category->published)) { if (empty($category->slug)) { vmInfo(vmText::_('COM_VIRTUEMART_CAT_NOT_FOUND')); } else { if ($category->virtuemart_id !== 0 and !$category->published) { vmInfo('COM_VIRTUEMART_CAT_NOT_PUBL', $category->category_name, $this->categoryId); } } //Fallback $categoryLink = ''; if ($category->category_parent_id) { $categoryLink = '&view=category&virtuemart_category_id=' . $category->category_parent_id; } else { $last_category_id = shopFunctionsF::getLastVisitedCategoryId(); if (!$last_category_id or $this->categoryId == $last_category_id) { $last_category_id = vRequest::getInt('virtuemart_category_id', false); } if ($last_category_id and $this->categoryId != $last_category_id) { $categoryLink = '&view=category&virtuemart_category_id=' . $last_category_id; } } if (VmConfig::get('handle_404', 1)) { $app->redirect(JRoute::_('index.php?option=com_virtuemart' . $categoryLink . '&error=404', FALSE)); } else { JError::raise(E_ERROR, '404', 'Not found'); } return; } shopFunctionsF::setLastVisitedCategoryId($this->categoryId); shopFunctionsF::setLastVisitedManuId($virtuemart_manufacturer_id); // Add the category name to the pathway if ($category->parents) { foreach ($category->parents as $c) { $pathway->addItem(strip_tags(vmText::_($c->category_name)), JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $c->virtuemart_category_id, FALSE)); } } $catImgAmount = VmConfig::get('catimg_browse', 1); $categoryModel->addImages($category, $catImgAmount); if (!isset($menu->query['showcategory'])) { $menu->query['showcategory'] = 1; } $this->showcategory = vRequest::getInt('showcategory', $menu->query['showcategory']); //$this->showcategory = vRequest::getInt('showcategory',true); if ($this->showcategory) { //if($category->category_layout == 'categories' or ($this->categoryId >0 and $virtuemart_manufacturer_id <1)){ $category->children = $categoryModel->getChildCategoryList($vendorId, $this->categoryId, $categoryModel->getDefaultOrdering(), $categoryModel->_selectedOrderingDir); $categoryModel->addImages($category->children, $catImgAmount); } else { $category->children = false; } if (VmConfig::get('enable_content_plugin', 0)) { shopFunctionsF::triggerContentPlugin($category, 'category', 'category_description'); } $metadesc = ''; $metakey = ''; $metarobot = ''; if (isset($menu->params)) { $metadesc = $menu->params->get('menu-meta_description'); $metakey = $menu->params->get('menu-meta_keywords'); $metarobot = $menu->params->get('robots'); } if ($category->metadesc) { $metadesc = $category->metadesc; } if ($category->metakey) { $metakey = $category->metakey; } if ($category->metarobot) { $metarobot = $category->metarobot; } $document->setDescription($metadesc); $document->setMetaData('keywords', $metakey); $document->setMetaData('robots', $metarobot); if ($app->getCfg('MetaAuthor') == '1' and !empty($category->metaauthor)) { $document->setMetaData('author', $category->metaauthor); } if (empty($category->category_template)) { $category->category_template = VmConfig::get('categorytemplate'); } if (!empty($menu->query['categorylayout'])) { //if(!empty($menu->query['categorylayout']) and $menu->query['virtuemart_category_id']==$this->categoryId){ $category->category_layout = $menu->query['categorylayout']; } $productsLayout = VmConfig::get('productsublayout', 'products'); if (empty($productsLayout)) { $productsLayout = 'products'; } $this->productsLayout = empty($menu->query['productsublayout']) ? $productsLayout : $menu->query['productsublayout']; shopFunctionsF::setVmTemplate($this, $category->category_template, 0, $category->category_layout); } else { //Backward compatibility if (!isset($category)) { $category = new stdClass(); $category->category_name = ''; $category->category_description = ''; $category->haschildren = false; } } $this->assignRef('category', $category); // Set the titles if (!empty($category->customtitle)) { $title = strip_tags($category->customtitle); } elseif (!empty($category->category_name)) { $title = strip_tags($category->category_name); } else { $title = $this->setTitleByJMenu($app); } $title = vmText::_($title); if (vRequest::getInt('error')) { $title .= ' ' . vmText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND'); } if (!empty($keyword)) { $title .= ' (' . strip_tags(htmlspecialchars_decode($keyword)) . ')'; } if ($virtuemart_manufacturer_id > 0 and !empty($this->products[0])) { $title .= ' ' . $this->products[0]->mf_name; } $document->setTitle($title); // Override Category name when viewing manufacturers products !IMPORTANT AFTER page title. if ($virtuemart_manufacturer_id > 0 and !empty($this->products[0]) and isset($category->category_name)) { $category->category_name = $this->products[0]->mf_name; } if ($app->getCfg('MetaTitle') == '1') { $document->setMetaData('title', $title); } parent::display($tpl); }
/** * Method to store item(s) * * @access public * * @param array the project round ids to copy * @param int the destination project id * * @return boolean True on success * @since 1.5 */ public function assign($cids, $project_id) { $row = $this->getTable(); $i = 0; for ($i = 0, $n = count($cids); $i < $n; $i++) { $cid =& $cids[$i]; $query = 'SELECT *' . ' FROM #__tracks_projects_rounds ' . ' WHERE id = ' . intval($cid); $this->_db->setQuery($query); $round = $this->_db->loadObject(); if (!$round) { JError::raise(500, 'Round not found. ' . $this->_db->getErrorMsg()); } if (!$round) { // not found... break; } $row->reset(); $row->bind($round); $row->id = null; $row->project_id = $project_id; $row->checked_out = 0; $row->checked_out_time = null; // Store the item to the database if (!$row->store()) { $this->setError($this->_db->getErrorMsg()); JError::raise(500, 'Failed to copy round. ' . $this->_db->getErrorMsg()); } // now copy subrounds $query = ' SELECT * ' . ' FROM #__tracks_projects_subrounds' . ' WHERE projectround_id = ' . $cid; $this->_db->setQuery($query); $subrounds = $this->_db->loadObjectList(); if (is_array($subrounds)) { $subround = $this->getTable('Subround'); foreach ($subrounds as $s) { $subround->reset(); $subround->bind($s); $subround->id = null; $subround->projectround_id = $row->id; $subround->checked_out = 0; $subround->checked_out_time = null; if (!$subround->store()) { $this->setError($this->_db->getErrorMsg()); JError::raise(500, 'Failed to copy subround. ' . $this->_db->getErrorMsg()); } } } } return true; }
/** * Display a message to the user * * @param integer $level The error level - use any of PHP's own error levels * for this: E_ERROR, E_WARNING, E_NOTICE, E_USER_ERROR, * E_USER_WARNING, E_USER_NOTICE. * @param string $msg Error message, shown to user if need be. * * @return void * * @deprecated 12.1 * @since 11.1 */ public static function customErrorHandler($level, $msg) { // Deprecation warning. JLog::add('JError::customErrorHandler() is deprecated.', JLog::WARNING, 'deprecated'); JError::raise($level, '', $msg); }
function save($data) { $db = $this->getDbo(); $row = $this->getTable('igallery_img'); if (!$row->bind($data)) { $this->setError($db->getErrorMsg()); return false; } if (strpos($row->description, 'class="des_div"') > 0) { JError::raise(2, 500, 'Error: Html formatting has been copied from the gallery frontend into the description, please paste plain text'); } $row->alt_text = htmlspecialchars($row->alt_text, ENT_QUOTES); $raw = JRequest::getVar('jform', array(), 'post', 'NONE', JREQUEST_ALLOWRAW); $row->description = JComponentHelper::filterText($raw['description']); if (!$row->store()) { $this->setError($db->getErrorMsg()); return false; } if (JFactory::getApplication()->isSite()) { $data = JRequest::getVar('jform', array(), 'post', 'NONE', 4); $id = (int) $data['id']; } else { $id = JRequest::getInt('id', 0); } $query = 'SELECT gallery_id, ordering from #__igallery_img WHERE id = ' . (int) $id; $db->setQuery($query); $currentRow = $db->loadObject(); $nextOrdering = $currentRow->ordering + 1; $query = 'SELECT id from #__igallery_img WHERE gallery_id = ' . (int) $currentRow->gallery_id . ' AND ordering = ' . (int) $nextOrdering . ' LIMIT 1'; $db->setQuery($query); $nextRow = $db->loadObject(); return $nextRow->id; }
/** * Display a custom error page and exit gracefully * * @param integer $level The error level - use any of PHP's own error levels for this: E_ERROR, E_WARNING, E_NOTICE, E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE. * @param string $msg Error message, shown to user if need be. * * @return void * * @deprecated * @since 11.1 */ public static function customErrorHandler($level, $msg) { JError::raise($level, '', $msg); }
defined('_JEXEC') or die('Restricted Access'); // Check for PHP4 if(defined('PHP_VERSION')) { $version = PHP_VERSION; } elseif(function_exists('phpversion')) { $version = phpversion(); } else { // No version info. I'll lie and hope for the best. $version = '5.0.0'; } // Old PHP version detected. EJECT! EJECT! EJECT! if(!version_compare($version, '5.2.0', '>=')) { return JError::raise(E_ERROR, 500, 'PHP 4.x, 5.0 and 5.1 is no longer supported by Akeeba Backup.','The version of PHP used on your site is obsolete and contains known security vulenrabilities. Moreover, it is missing features required by Akeeba Backup to work properly or at all. Please ask your host to upgrade your server to the latest PHP 5.2 or 5.3 release. Thank you!'); } // Timezone fix; avoids errors printed out by PHP 5.3.3+ (thanks Yannick!) if(function_exists('date_default_timezone_get') && function_exists('date_default_timezone_set')) { if(function_exists('error_reporting')) { $oldLevel = error_reporting(0); } $serverTimezone = @date_default_timezone_get(); if(empty($serverTimezone) || !is_string($serverTimezone)) $serverTimezone = 'UTC'; if(function_exists('error_reporting')) { error_reporting($oldLevel); } @date_default_timezone_set( $serverTimezone); }
* @copyright Copyright (C) 2010 - 2011 ThemeXpert * @license http://www.gnu.org/licenses/gpl-3.0.html GNU/GPLv3 **/ // Protect from unauthorized access defined('_JEXEC') or die('Restricted Access'); // Check for PHP4 if (defined('PHP_VERSION')) { $version = PHP_VERSION; } elseif (function_exists('phpversion')) { $version = phpversion(); } else { $version = '5.0.0'; } // if older version detect, raise an error if (!version_compare($version, '5.0.0', '>=')) { return JError::raise(E_ERROR, 500, 'PHP 4 is not supported by Expose Framework'); } if (!defined('EXPOSE_VERSION')) { // Define framework version. define('EXPOSE_VERSION', '4.2.3'); //define directory separator defined('DS') or define('DS', '/'); if (version_compare(JVERSION, '2.5', 'ge') && version_compare(JVERSION, '3.0', 'lt')) { define('EXPOSE_JVERSION', '25'); } else { define('EXPOSE_JVERSION', '30'); } //declare global ver global $expose; expose_import('core.core'); $expose = ExposeCore::getInstance();
public function saveCategoryImage($pk, $table, &$data) { $app = JFactory::getApplication(); $jInput = $app->input; if ($pk > 0) { if ($jInput->post->getInt('remove_jform_images_intro_image', 0) == 1 || $jInput->post->getInt('remove_jform_images_detail_image', 0) == 1 && $jInput->post->getInt('use_detail_image', 0) == 1) { $intro_image_dir = JPATH_ROOT . "/" . JUDownloadFrontHelper::getDirectory("category_intro_image_directory", "media/com_judownload/images/category/intro/") . $data['images']['intro_image']; $ori_intro_image_dir = JPATH_ROOT . "/" . JUDownloadFrontHelper::getDirectory("category_intro_image_directory", "media/com_judownload/images/category/intro/") . 'original/' . $data['images']['intro_image']; $data['images']['intro_image'] = ''; $data['images']['intro_image_alt'] = ''; $data['images']['intro_image_caption'] = ''; JFile::delete($ori_intro_image_dir); JFile::delete($intro_image_dir); } if ($jInput->post->getInt('remove_jform_images_detail_image', 0) == 1) { $full_image_dir = JPATH_ROOT . "/" . JUDownloadFrontHelper::getDirectory("category_detail_image_directory", "media/com_judownload/images/category/detail/") . $data['images']['detail_image']; $ori_full_image_dir = JPATH_ROOT . "/" . JUDownloadFrontHelper::getDirectory("category_detail_image_directory", "media/com_judownload/images/category/detail/") . "original/" . $data['images']['detail_image']; $data['images']['detail_image'] = ''; $data['images']['detail_image_alt'] = ''; $data['images']['detail_image_caption'] = ''; JFile::delete($full_image_dir); JFile::delete($ori_full_image_dir); } } $mime_types = array("image/jpeg", "image/pjpeg", "image/png", "image/gif", "image/bmp", "image/x-windows-bmp"); $num_files_failed_mime_type = 0; $images = $app->input->files->get('images', array()); $old_ori_intro_image_path = isset($data['images']['intro_image']) && $data['images']['intro_image'] ? JUDownloadFrontHelper::getDirectory("category_intro_image_directory", "media/com_judownload/images/category/intro/") . 'original/' . $data['images']['intro_image'] : ''; $old_intro_image_path = $old_ori_intro_image_path ? JUDownloadFrontHelper::getDirectory("category_intro_image_directory", "media/com_judownload/images/category/intro/") . $data['images']['intro_image'] : ''; $old_ori_detail_image_path = isset($data['images']['detail_image']) && $data['images']['detail_image'] ? JUDownloadFrontHelper::getDirectory("category_detail_image_directory", "media/com_judownload/images/category/detail/") . 'original/' . $data['images']['detail_image'] : ''; $old_detail_image_path = $old_ori_detail_image_path ? JUDownloadFrontHelper::getDirectory("category_detail_image_directory", "media/com_judownload/images/category/detail/") . $data['images']['detail_image'] : ''; foreach ($images as $key => $image) { if ($image['name']) { if (!in_array($image['type'], $mime_types)) { $num_files_failed_mime_type++; continue; } $info = pathinfo($image['name']); $replace = array('id' => $table->id, 'document' => '', 'category' => $table->title, 'image_name' => $info['filename']); $image['name'] = JUDownloadHelper::parseImageNameByTags($replace, 'category', $table->id, null) . '.' . $info['extension']; if ($key == 'intro' && $app->input->post->get('use_detail_image', 0) != 1) { $new_ori_image_path = JUDownloadFrontHelper::getDirectory("category_intro_image_directory", "media/com_judownload/images/category/intro/") . 'original/' . $image['name']; $new_image_path = JUDownloadFrontHelper::getDirectory("category_intro_image_directory", "media/com_judownload/images/category/intro/") . $image['name']; if (!JFile::upload($image['tmp_name'], JPATH_ROOT . "/" . $new_ori_image_path) || !JUDownloadHelper::renderImages(JPATH_ROOT . "/" . $new_ori_image_path, JPATH_ROOT . "/" . $new_image_path, "category_intro", true, $table->id)) { unset($images['intro']); } else { $delete_old_intro_image = $data['images']['intro_image'] && $data['images']['intro_image'] !== $image['name'] ? true : false; $data['images']['intro_image'] = $image['name']; } if ($delete_old_intro_image) { if ($old_intro_image_path && JFile::exists(JPATH_ROOT . "/" . $old_intro_image_path)) { JFile::delete(JPATH_ROOT . "/" . $old_ori_intro_image_path); JFile::delete(JPATH_ROOT . "/" . $old_intro_image_path); } } } if ($key == 'detail') { $new_ori_image_path = JUDownloadFrontHelper::getDirectory("category_detail_image_directory", "media/com_judownload/images/category/detail/") . 'original/' . $image['name']; $new_image_path = JUDownloadFrontHelper::getDirectory("category_detail_image_directory", "media/com_judownload/images/category/detail/") . $image['name']; if (!JFile::upload($image['tmp_name'], JPATH_ROOT . "/" . $new_ori_image_path) || !JUDownloadHelper::renderImages(JPATH_ROOT . "/" . $new_ori_image_path, JPATH_ROOT . "/" . $new_image_path, "category_detail", true, $table->id)) { unset($images['detail']); } else { if ($data['images']['detail_image'] && $data['images']['detail_image'] !== $image['name']) { if ($old_detail_image_path && JFile::exists(JPATH_ROOT . "/" . $old_detail_image_path)) { JFile::delete(JPATH_ROOT . "/" . $old_ori_detail_image_path); JFile::delete(JPATH_ROOT . "/" . $old_detail_image_path); } } $data['images']['detail_image'] = $image['name']; } } } } if ($num_files_failed_mime_type) { JError::raise(E_NOTICE, 500, JText::plural('COM_JUDOWNLOAD_N_IMAGES_ARE_NOT_VALID_MIMETYPE', $num_files_failed_mime_type, implode(",", $mime_types))); } if ($app->input->post->get('use_detail_image', 0) == 1 && $data['images']['detail_image']) { $old_ori_detail_image_path = JUDownloadFrontHelper::getDirectory("category_detail_image_directory", "media/com_judownload/images/category/detail/") . 'original/' . $data['images']['detail_image']; $new_ori_intro_image_path = JUDownloadFrontHelper::getDirectory("category_intro_image_directory", "media/com_judownload/images/category/intro/") . 'original/' . $data['images']['detail_image']; $new_image_path = JUDownloadFrontHelper::getDirectory("category_intro_image_directory", "media/com_judownload/images/category/intro/") . $data['images']['detail_image']; if (JFile::copy(JPATH_ROOT . "/" . $old_ori_detail_image_path, JPATH_ROOT . "/" . $new_ori_intro_image_path) && JUDownloadHelper::renderImages(JPATH_ROOT . "/" . $new_ori_intro_image_path, JPATH_ROOT . "/" . $new_image_path, 'category_intro', true, $table->id)) { if ($data['images']['intro_image'] && $data['images']['intro_image'] !== $data['images']['detail_image']) { if (JFile::exists(JPATH_ROOT . "/" . $old_ori_intro_image_path)) { JFile::delete(JPATH_ROOT . "/" . $old_ori_intro_image_path); } if (JFile::exists(JPATH_ROOT . "/" . $old_intro_image_path)) { JFile::delete(JPATH_ROOT . "/" . $old_intro_image_path); } } $data['images']['intro_image'] = $data['images']['detail_image']; } } if (!empty($data['images'])) { $registry = new JRegistry(); $registry->loadArray($data['images']); $table->images = (string) $registry; $table->store(); } }
/** * Collect all data to show on the template * * @author RolandD, Max Milbers */ function display($tpl = null) { //TODO get plugins running // $dispatcher = JDispatcher::getInstance(); // $limitstart = JRequest::getVar('limitstart', 0, '', 'int'); VmConfig::loadJLang('com_virtuemart', true); $show_prices = VmConfig::get('show_prices', 1); if ($show_prices == '1') { if (!class_exists('calculationHelper')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'calculationh.php'; } } $this->assignRef('show_prices', $show_prices); $document = JFactory::getDocument(); // add javascript for price and cart, need even for quantity buttons, so we need it almost anywhere vmJsApi::jPrice(); $mainframe = JFactory::getApplication(); $pathway = $mainframe->getPathway(); $task = JRequest::getCmd('task'); if (!class_exists('VmImage')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'image.php'; } // Load the product //$product = $this->get('product'); //Why it is sensefull to use this construction? Imho it makes it just harder $product_model = VmModel::getModel('product'); $this->assignRef('product_model', $product_model); $virtuemart_product_idArray = JRequest::getVar('virtuemart_product_id', 0); if (is_array($virtuemart_product_idArray) and count($virtuemart_product_idArray) > 0) { $virtuemart_product_id = (int) $virtuemart_product_idArray[0]; } else { $virtuemart_product_id = (int) $virtuemart_product_idArray; } $quantityArray = JRequest::getVar('quantity', array()); //is sanitized then JArrayHelper::toInteger($quantityArray); $quantity = 1; if (!empty($quantityArray[0])) { $quantity = $quantityArray[0]; } $product = $product_model->getProduct($virtuemart_product_id, TRUE, TRUE, TRUE, $quantity); if (!class_exists('shopFunctionsF')) { require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php'; } $last_category_id = shopFunctionsF::getLastVisitedCategoryId(); if (empty($product->slug)) { //Todo this should be redesigned to fit better for SEO $mainframe->enqueueMessage(JText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND')); $categoryLink = ''; if (!$last_category_id) { $last_category_id = JRequest::getInt('virtuemart_category_id', false); } if ($last_category_id) { $categoryLink = '&virtuemart_category_id=' . $last_category_id; } if (VmConfig::get('handle_404', 1)) { $mainframe->redirect(JRoute::_('index.php?option=com_virtuemart&view=category' . $categoryLink . '&error=404', FALSE)); } else { JError::raise(E_ERROR, '404', 'Not found'); } return; } if (!empty($product->customfields)) { foreach ($product->customfields as $k => $custom) { if (!empty($custom->layout_pos)) { $product->customfieldsSorted[$custom->layout_pos][] = $custom; unset($product->customfields[$k]); } } $product->customfieldsSorted['normal'] = $product->customfields; unset($product->customfields); } $product->event = new stdClass(); $product->event->afterDisplayTitle = ''; $product->event->beforeDisplayContent = ''; $product->event->afterDisplayContent = ''; if (VmConfig::get('enable_content_plugin', 0)) { shopFunctionsF::triggerContentPlugin($product, 'productdetails', 'product_desc'); } $product_model->addImages($product); $this->assignRef('product', $product); if (isset($product->min_order_level) && (int) $product->min_order_level > 0) { $min_order_level = $product->min_order_level; } else { $min_order_level = 1; } $this->assignRef('min_order_level', $min_order_level); if (isset($product->step_order_level) && (int) $product->step_order_level > 0) { $step_order_level = $product->step_order_level; } else { $step_order_level = 1; } $this->assignRef('step_order_level', $step_order_level); // Load the neighbours if (VmConfig::get('product_navigation', 1)) { $product->neighbours = $product_model->getNeighborProducts($product); } // Load the category $category_model = VmModel::getModel('category'); shopFunctionsF::setLastVisitedCategoryId($product->virtuemart_category_id); if ($category_model) { $category = $category_model->getCategory($product->virtuemart_category_id); $category_model->addImages($category, 1); $this->assignRef('category', $category); //Seems we dont need this anylonger, destroyed the breadcrumb if ($category->parents) { foreach ($category->parents as $c) { if (is_object($c) and isset($c->category_name)) { $pathway->addItem(strip_tags($c->category_name), JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $c->virtuemart_category_id, FALSE)); } else { vmdebug('Error, parent category has no name, breadcrumb maybe broken, category', $c); } } } $category->children = $category_model->getChildCategoryList($product->virtuemart_vendor_id, $product->virtuemart_category_id); $category_model->addImages($category->children, 1); } if (!empty($tpl)) { $format = $tpl; } else { $format = JRequest::getWord('format', 'html'); } if ($format == 'html') { // Set Canonic link $document->addHeadLink($product->canonical, 'canonical', 'rel', ''); } $pathway->addItem(strip_tags($product->product_name)); // Set the titles // $document->setTitle should be after the additem pathway if ($product->customtitle) { $document->setTitle(strip_tags($product->customtitle)); } else { $document->setTitle(strip_tags(($category->category_name ? $category->category_name . ' : ' : '') . $product->product_name)); } $ratingModel = VmModel::getModel('ratings'); $allowReview = $ratingModel->allowReview($product->virtuemart_product_id); $this->assignRef('allowReview', $allowReview); $showReview = $ratingModel->showReview($product->virtuemart_product_id); $this->assignRef('showReview', $showReview); if ($showReview) { $review = $ratingModel->getReviewByProduct($product->virtuemart_product_id); $this->assignRef('review', $review); $rating_reviews = $ratingModel->getReviews($product->virtuemart_product_id); $this->assignRef('rating_reviews', $rating_reviews); } $showRating = $ratingModel->showRating($product->virtuemart_product_id); $this->assignRef('showRating', $showRating); if ($showRating) { $vote = $ratingModel->getVoteByProduct($product->virtuemart_product_id); $this->assignRef('vote', $vote); $rating = $ratingModel->getRatingByProduct($product->virtuemart_product_id); $this->assignRef('rating', $rating); } $allowRating = $ratingModel->allowRating($product->virtuemart_product_id); $this->assignRef('allowRating', $allowRating); // Check for editing access // @todo build edit page if (!class_exists('Permissions')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'permissions.php'; } //if (Permissions::getInstance()->check("admin,storeadmin")) { $perm = Permissions::getInstance(); $admin = $perm->check("admin"); if (!$admin) { vmdebug('No admin'); } $storeadmin = $perm->check("admin,storeadmin"); if (!$storeadmin) { vmdebug('No $storeadmin'); } $superVendor = $perm->isSuperVendor(); if (!$superVendor) { vmdebug('No $superVendor'); } if ($admin or $perm->isSuperVendor() == $product->virtuemart_vendor_id and $storeadmin) { $edit_link = JURI::root() . 'index.php?option=com_virtuemart&tmpl=component&view=product&task=edit&virtuemart_product_id=' . $product->virtuemart_product_id; $edit_link = $this->linkIcon($edit_link, 'COM_VIRTUEMART_PRODUCT_FORM_EDIT_PRODUCT', 'edit', false, false); } else { $edit_link = ""; } $this->assignRef('edit_link', $edit_link); // todo: atm same form for "call for price" and "ask a question". Title of the form should be different $askquestion_url = JRoute::_('index.php?option=com_virtuemart&view=productdetails&task=askquestion&virtuemart_product_id=' . $product->virtuemart_product_id . '&virtuemart_category_id=' . $product->virtuemart_category_id . '&tmpl=component', FALSE); $this->assignRef('askquestion_url', $askquestion_url); // Load the user details $user = JFactory::getUser(); $this->assignRef('user', $user); // More reviews link $uri = JURI::getInstance(); $uri->setVar('showall', 1); $uristring = vmURI::getCleanUrl(); $this->assignRef('more_reviews', $uristring); if ($product->metadesc) { $document->setDescription($product->metadesc); } if ($product->metakey) { $document->setMetaData('keywords', $product->metakey); } if ($product->metarobot) { $document->setMetaData('robots', $product->metarobot); } if ($mainframe->getCfg('MetaTitle') == '1') { $document->setMetaData('title', $product->product_name); //Maybe better product_name } if ($mainframe->getCfg('MetaAuthor') == '1') { $document->setMetaData('author', $product->metaauthor); } $showBasePrice = Permissions::getInstance()->check('admin'); //todo add config settings $this->assignRef('showBasePrice', $showBasePrice); $productDisplayShipments = array(); $productDisplayPayments = array(); if (!class_exists('vmPSPlugin')) { require JPATH_VM_PLUGINS . DS . 'vmpsplugin.php'; } JPluginHelper::importPlugin('vmshipment'); JPluginHelper::importPlugin('vmpayment'); $dispatcher = JDispatcher::getInstance(); $returnValues = $dispatcher->trigger('plgVmOnProductDisplayShipment', array($product, &$productDisplayShipments)); $returnValues = $dispatcher->trigger('plgVmOnProductDisplayPayment', array($product, &$productDisplayPayments)); $this->assignRef('productDisplayPayments', $productDisplayPayments); $this->assignRef('productDisplayShipments', $productDisplayShipments); if (empty($category->category_template)) { $category->category_template = VmConfig::get('categorytemplate'); } shopFunctionsF::setVmTemplate($this, $category->category_template, $product->product_template, $category->category_product_layout, $product->layout); shopFunctionsF::addProductToRecent($virtuemart_product_id); $currency = CurrencyDisplay::getInstance(); $this->assignRef('currency', $currency); if (JRequest::getCmd('layout', 'default') == 'notify') { $this->setLayout('notify'); } //Added by Seyi Awofadeju to catch notify layout parent::display($tpl); }
function assignMenuImage() { if (!igGeneralHelper::authorise('core.igalleryfront.editimage.state', null, JRequest::getInt('id', 0))) { return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); } $model = $this->getModel(); if (!$model->assignMenuImage()) { JError::raise(2, 500, $model->getError()); } $this->setRedirect(JRoute::_('index.php?option=com_igallery&view=images&catid=' . JRequest::getInt('catid'), false)); }
$articleId = shGetArticleIdString($id, $view, $option, $shLangName); $title = sef_404::getContentSlugsArray($view, $id, $layout, $Itemid, $shLangName, $customConfig); if (!empty($articleId)) { $lastBit = array_pop($title); $lastBit .= ' [' . $articleId . ']'; array_push($title, $lastBit); } $pageNumber = ''; // V 1.2.4.t try better handling of multipages article (use of mospagebreak) if ($view == 'article' && !empty($limitstart)) { // this is multipage article $shPageTitle = ''; try { $contentElement = ShlDbHelper::selectObject('#__content', array('id', 'fulltext', 'introtext'), array('id' => $id)); } catch (Exception $e) { JError::raise(E_ERROR, 500, $e->getMessage()); } $contentText = $contentElement->introtext . $contentElement->fulltext; if (!empty($contentElement) && empty($showall) && strpos($contentText, 'class="system-pagebreak') !== false) { // search for mospagebreak tags // copied over from pagebreak plugin // expression to search for //$regex = '/{(mospagebreak)\s*(.*?)}/i'; $regex = '#<hr([^>]*)class=\\"system-pagebreak\\"([^>]*)\\/>#iUu'; // find all instances of mambot and put in $matches $shMatches = array(); preg_match_all($regex, $contentText, $shMatches, PREG_SET_ORDER); // adds heading or title to <site> Title if (empty($limitstart)) { // if first page use heading of first mospagebreak } else {
/** * Collect all data to show on the template * * @author RolandD, Max Milbers */ function display($tpl = null) { $show_prices = VmConfig::get('show_prices', 1); $this->assignRef('show_prices', $show_prices); $document = JFactory::getDocument(); $app = JFactory::getApplication(); $menus = $app->getMenu(); $menu = $menus->getActive(); if (!empty($menu->id)) { ShopFunctionsF::setLastVisitedItemId($menu->id); } else { if ($itemId = vRequest::getInt('Itemid', false)) { ShopFunctionsF::setLastVisitedItemId($itemId); } } $pathway = $app->getPathway(); $task = vRequest::getCmd('task'); if (!class_exists('VmImage')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'image.php'; } // Load the product //$product = $this->get('product'); //Why it is sensefull to use this construction? Imho it makes it just harder $product_model = VmModel::getModel('product'); $this->assignRef('product_model', $product_model); $virtuemart_product_idArray = vRequest::getInt('virtuemart_product_id', 0); if (is_array($virtuemart_product_idArray) and count($virtuemart_product_idArray) > 0) { $virtuemart_product_id = (int) $virtuemart_product_idArray[0]; } else { $virtuemart_product_id = (int) $virtuemart_product_idArray; } $quantityArray = vRequest::getInt('quantity', array()); //is sanitized then $quantity = 1; if (!empty($quantityArray[0])) { $quantity = $quantityArray[0]; } $ratingModel = VmModel::getModel('ratings'); $product_model->withRating = $this->showRating = $ratingModel->showRating($virtuemart_product_id); $product = $product_model->getProduct($virtuemart_product_id, TRUE, TRUE, TRUE, $quantity); if (!class_exists('shopFunctionsF')) { require VMPATH_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php'; } $last_category_id = shopFunctionsF::getLastVisitedCategoryId(); $customfieldsModel = VmModel::getModel('Customfields'); if ($product->customfields) { if (!class_exists('vmCustomPlugin')) { require JPATH_VM_PLUGINS . DS . 'vmcustomplugin.php'; } $customfieldsModel->displayProductCustomfieldFE($product, $product->customfields); } if (empty($product->slug)) { //Todo this should be redesigned to fit better for SEO $app->enqueueMessage(vmText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND')); $categoryLink = ''; if (!$last_category_id) { $last_category_id = vRequest::getInt('virtuemart_category_id', false); } if ($last_category_id) { $categoryLink = '&virtuemart_category_id=' . $last_category_id; } if (VmConfig::get('handle_404', 1)) { $app->redirect(JRoute::_('index.php?option=com_virtuemart&view=category' . $categoryLink . '&error=404', FALSE)); } else { JError::raise(E_ERROR, '404', 'Not found'); } return; } $isCustomVariant = false; if (!empty($product->customfields)) { foreach ($product->customfields as $k => $custom) { if ($custom->field_type == 'C' and $custom->virtuemart_product_id != $virtuemart_product_id) { $isCustomVariant = $custom; } if (!empty($custom->layout_pos)) { $product->customfieldsSorted[$custom->layout_pos][] = $custom; } else { $product->customfieldsSorted['normal'][] = $custom; } unset($product->customfields); } } $product->event = new stdClass(); $product->event->afterDisplayTitle = ''; $product->event->beforeDisplayContent = ''; $product->event->afterDisplayContent = ''; if (VmConfig::get('enable_content_plugin', 0)) { shopFunctionsF::triggerContentPlugin($product, 'productdetails', 'product_desc'); } $product_model->addImages($product); if (isset($product->min_order_level) && (int) $product->min_order_level > 0) { $this->min_order_level = $product->min_order_level; } else { $this->min_order_level = 1; } if (isset($product->step_order_level) && (int) $product->step_order_level > 0) { $this->step_order_level = $product->step_order_level; } else { $this->step_order_level = 1; } // Load the neighbours if (VmConfig::get('product_navigation', 1)) { $product->neighbours = $product_model->getNeighborProducts($product); } $this->assignRef('product', $product); if (VmConfig::get('show_manufacturers', 1) && !empty($this->product->virtuemart_manufacturer_id)) { $manModel = VmModel::getModel('manufacturer'); $mans = array(); // Gebe die Hersteller aus foreach ($this->product->virtuemart_manufacturer_id as $manufacturer_id) { $manufacturer = $manModel->getManufacturer($manufacturer_id); $manModel->addImages($manufacturer, 1); $mans[] = $manufacturer; } $this->product->manufacturers = $mans; } // Load the category $category_model = VmModel::getModel('category'); shopFunctionsF::setLastVisitedCategoryId($product->virtuemart_category_id); if ($category_model) { $category = $category_model->getCategory($product->virtuemart_category_id); $category_model->addImages($category, 1); $this->assignRef('category', $category); //Seems we dont need this anylonger, destroyed the breadcrumb if ($category->parents) { foreach ($category->parents as $c) { if (is_object($c) and isset($c->category_name)) { $pathway->addItem(strip_tags(vmText::_($c->category_name)), JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $c->virtuemart_category_id, FALSE)); } else { vmdebug('Error, parent category has no name, breadcrumb maybe broken, category', $c); } } } $category->children = $category_model->getChildCategoryList($product->virtuemart_vendor_id, $product->virtuemart_category_id); $category_model->addImages($category->children, 1); } $pathway->addItem(strip_tags(html_entity_decode($product->product_name, ENT_QUOTES))); if (!empty($tpl)) { $format = $tpl; } else { $format = vRequest::getCmd('format', 'html'); } if ($format == 'html') { // remove joomla canonical before adding it foreach ($document->_links as $k => $array) { if ($array['relation'] == 'canonical') { unset($document->_links[$k]); break; } } // Set Canonic link if ($isCustomVariant !== false and !empty($isCustomVariant->usecanonical) and !empty($product->product_parent_id)) { $parent = $product_model->getProduct($product->product_parent_id); $document->addHeadLink($parent->canonical, 'canonical', 'rel', ''); } else { $document->addHeadLink($product->canonical, 'canonical', 'rel', ''); } } else { if ($format == 'pdf') { defined('K_PATH_IMAGES') or define('K_PATH_IMAGES', VMPATH_ROOT); } } // Set the titles // $document->setTitle should be after the additem pathway if ($product->customtitle) { $document->setTitle(strip_tags(html_entity_decode($product->customtitle, ENT_QUOTES))); } else { $document->setTitle(strip_tags(html_entity_decode(($category->category_name ? vmText::_($category->category_name) . ' : ' : '') . $product->product_name, ENT_QUOTES))); } $this->allowReview = $ratingModel->allowReview($product->virtuemart_product_id); $this->showReview = $ratingModel->showReview($product->virtuemart_product_id); $this->rating_reviews = ''; if ($this->showReview) { $this->review = $ratingModel->getReviewByProduct($product->virtuemart_product_id); $this->rating_reviews = $ratingModel->getReviews($product->virtuemart_product_id); } if ($this->showRating) { $this->vote = $ratingModel->getVoteByProduct($product->virtuemart_product_id); } $this->allowRating = $ratingModel->allowRating($product->virtuemart_product_id); $superVendor = vmAccess::isSuperVendor(); if ($superVendor == 1 or $superVendor == $product->virtuemart_vendor_id or $superVendor) { $edit_link = JURI::root() . 'index.php?option=com_virtuemart&tmpl=component&manage=1&view=product&task=edit&virtuemart_product_id=' . $product->virtuemart_product_id; $this->edit_link = $this->linkIcon($edit_link, 'COM_VIRTUEMART_PRODUCT_FORM_EDIT_PRODUCT', 'edit', false, false); } else { $this->edit_link = ""; } // Load the user details $this->user = JFactory::getUser(); // More reviews link $uri = JURI::getInstance(); $uri->setVar('showall', 1); $uristring = vmURI::getCleanUrl(); $this->assignRef('more_reviews', $uristring); if ($product->metadesc) { $document->setDescription(strip_tags(html_entity_decode($product->metadesc, ENT_QUOTES))); } else { $document->setDescription(strip_tags(html_entity_decode($product->product_name, ENT_QUOTES)) . " " . $category->category_name . " " . strip_tags(html_entity_decode($product->product_s_desc, ENT_QUOTES))); } if ($product->metakey) { $document->setMetaData('keywords', $product->metakey); } if ($product->metarobot) { $document->setMetaData('robots', $product->metarobot); } if ($app->getCfg('MetaTitle') == '1') { $document->setMetaData('title', $product->product_name); //Maybe better product_name } if ($app->getCfg('MetaAuthor') == '1') { $document->setMetaData('author', $product->metaauthor); } $user = JFactory::getUser(); $showBasePrice = (vmAccess::manager() or vmAccess::isSuperVendor()); $this->assignRef('showBasePrice', $showBasePrice); $productDisplayShipments = array(); $productDisplayPayments = array(); if (!class_exists('vmPSPlugin')) { require JPATH_VM_PLUGINS . DS . 'vmpsplugin.php'; } JPluginHelper::importPlugin('vmshipment'); JPluginHelper::importPlugin('vmpayment'); $dispatcher = JDispatcher::getInstance(); $returnValues = $dispatcher->trigger('plgVmOnProductDisplayShipment', array($product, &$productDisplayShipments)); $returnValues = $dispatcher->trigger('plgVmOnProductDisplayPayment', array($product, &$productDisplayPayments)); $this->assignRef('productDisplayPayments', $productDisplayPayments); $this->assignRef('productDisplayShipments', $productDisplayShipments); if (empty($category->category_template)) { $category->category_template = VmConfig::get('categorytemplate'); } shopFunctionsF::setVmTemplate($this, $category->category_template, $product->product_template, $category->category_product_layout, $product->layout); shopFunctionsF::addProductToRecent($virtuemart_product_id); $currency = CurrencyDisplay::getInstance(); $this->assignRef('currency', $currency); if (vRequest::getCmd('layout', 'default') == 'notify') { $this->setLayout('notify'); } //Added by Seyi Awofadeju to catch notify layout VmConfig::loadJLang('com_virtuemart'); vmJsApi::chosenDropDowns(); //This must be loaded after the customfields are rendered (they may need to overwrite the handlers) if (VmConfig::get('jdynupdate', TRUE) or $app->isAdmin()) { vmJsApi::jDynUpdate(); } if ($show_prices == '1') { if (!class_exists('calculationHelper')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'calculationh.php'; } vmJsApi::jPrice(); } parent::display($tpl); }
function getModelName() { JError::raise(500, "getModelName() not implemented"); }
defined('_JEXEC') or die('Restricted Access'); // Check for PHP4 if(defined('PHP_VERSION')) { $version = PHP_VERSION; } elseif(function_exists('phpversion')) { $version = phpversion(); } else { // No version info. I'll lie and hope for the best. $version = '5.0.0'; } // Old PHP version detected. EJECT! EJECT! EJECT! if(!version_compare($version, '5.0.0', '>=')) { return JError::raise(E_ERROR, 500, 'PHP 4 is not supported by Akeeba Backup'); } // Timezone fix; avoids errors printed out by PHP 5.3.3+ (thanks Yannick!) if(function_exists('date_default_timezone_get') && function_exists('date_default_timezone_set')) { if(function_exists('error_reporting')) { $oldLevel = error_reporting(0); } $serverTimezone = @date_default_timezone_get(); if(empty($serverTimezone) || !is_string($serverTimezone)) $serverTimezone = 'UTC'; if(function_exists('error_reporting')) { error_reporting($oldLevel); } @date_default_timezone_set( $serverTimezone); }
/** * Displays information from groups within a particular category * * @since 1.2 * @access public * @param string * @return */ public function category() { // Check if this feature is enabled. $this->checkFeature(); // Check for user profile completeness FD::checkCompleteProfile(); // Get the category id from the query $id = JRequest::getInt('id'); $category = FD::table('GroupCategory'); $category->load($id); // Check if the category is valid if (!$id || !$category->id) { return JError::raise(E_ERROR, 404, JText::_('COM_EASYSOCIAL_GROUPS_INVALID_GROUP_ID')); } // Load backend language file FD::language()->loadAdmin(); // Set the page title to this category FD::page()->title($category->get('title')); // Set the breadcrumbs FD::page()->breadcrumb(JText::_('COM_EASYSOCIAL_PAGE_TITLE_GROUPS'), FRoute::groups()); FD::page()->breadcrumb($category->get('title')); // Get recent 10 groups from this category $options = array('sort' => 'random', 'category' => $category->id); $model = FD::model('Groups'); $groups = $model->getGroups($options); // Get random members from this category $randomMembers = $model->getRandomCategoryMembers($category->id, SOCIAL_CLUSTER_CATEGORY_MEMBERS_LIMIT); // Get group creation stats for this category $stats = $model->getCreationStats($category->id); // Get total groups within a category $totalGroups = $model->getTotalGroups(array('category_id' => $category->id)); // Get total albums within a category $totalAlbums = $model->getTotalAlbums(array('category_id' => $category->id)); // Get the stream for this group $stream = FD::stream(); $stream->get(array('clusterCategory' => $category->id, 'clusterType' => SOCIAL_TYPE_GROUP)); // Get random albums for groups in this category $randomAlbums = $model->getRandomAlbums(array('category_id' => $category->id, 'core' => false)); $this->set('randomAlbums', $randomAlbums); $this->set('stream', $stream); $this->set('totalGroups', $totalGroups); $this->set('stats', $stats); $this->set('randomMembers', $randomMembers); $this->set('groups', $groups); $this->set('category', $category); $this->set('totalAlbums', $totalAlbums); parent::display('site/groups/category.item'); }
/** * Calls the cache server to purge the cache * * @access public * @param string|bool $message Message to be displayed if purge is successful. If this param is false no output would be done * @return null */ private function _purgeCache($message = true) { $purgeRequest = $this->_applicationPath . '(.*)'; // Check if caching server is online $hostname = trim(file_get_contents('/etc/sgcache_ip', true)); $cacheServerSocket = fsockopen($hostname, 80, $errno, $errstr, 2); if (!$cacheServerSocket) { JError::raise(E_ERROR, 500, JText::_('Connection to cache server failed!')); JError::raise(E_ERROR, 500, JText::_($errstr($errno))); return; } $request = "BAN {$purgeRequest} HTTP/1.0\r\nHost: {$_SERVER['SERVER_NAME']}\r\nConnection: Close\r\n\r\n"; if (preg_match('/^www\\./', $_SERVER['SERVER_NAME'])) { $domain_no_www = preg_replace('/^www\\./', '', $_SERVER['SERVER_NAME']); $request2 = "BAN {$purgeRequest} HTTP/1.0\r\nHost: {$domain_no_www}\r\nConnection: Close\r\n\r\n"; } else { $request2 = "BAN {$purgeRequest} HTTP/1.0\r\nHost: www.{$_SERVER['SERVER_NAME']}\r\nConnection: Close\r\n\r\n"; } fwrite($cacheServerSocket, $request); $response = fgets($cacheServerSocket); fclose($cacheServerSocket); $cacheServerSocket = fsockopen($hostname, 80, $errno, $errstr, 2); fwrite($cacheServerSocket, $request2); fclose($cacheServerSocket); if ($message !== false) { if (preg_match('/200/', $response)) { if ($message === true) { JFactory::getApplication()->enqueueMessage(JText::_('SG Cache Successfully Purged!')); } else { JFactory::getApplication()->enqueueMessage(JText::_($message)); } } else { JError::raise(E_NOTICE, 501, JText::_('SG Cache: Purge was not successful!')); JError::raise(E_NOTICE, 501, jText::_('Error: ' . $response)); } } }
/** * Load the connection associated with the table * * @return object database object using connection details false if connection error */ function &getDb() { static $dbs; if (!isset($dbs)) { $dbs = array(); } $cn = $this->getConnection(); $session = JFactory::getSession(); if (JRequest::getCmd('task') == 'test') { $session->clear('fabrik.connection.' . $cn->id); $dbs = array(); $this->_connection = null; $cn = $this->getConnection(); } if (!array_key_exists($cn->id, $dbs)) { // $$$rob lets see if we have an exact config match with J db if so just return that $conf = JFactory::getConfig(); $host = $conf->get('host'); $user = $conf->get('user'); $password = $conf->get('password'); $database = $conf->get('db'); $prefix = $conf->get('dbprefix'); $driver = $conf->get('dbtype'); $debug = $conf->get('debug'); $default_options = array('driver' => $driver, 'host' => $host, 'user' => $user, 'password' => $password, 'database' => $database, 'prefix' => $prefix); $options = $this->getConnectionOptions($cn); if ($this->_compareConnectionOpts($default_options, $options)) { $dbs[$cn->id] = FabrikWorker::getDbo(); } else { $dbs[$cn->id] = JDatabase::getInstance($options); } if (JError::isError($dbs[$cn->id]) || is_a($dbs[$cn->id], 'JException') || $dbs[$cn->id]->getErrorNum() !== 0) { /** * $$$Rob - not sure why this is happening on badmintonrochelais.com (mySQL 4.0.24) but it seems like * you can only use one connection on the site? As JDatabase::getInstance() forces a new connection if its options * signature is not found, then fabrik's default connection won't be created, hence defaulting to that one */ if ($cn->default == 1 && JRequest::getCmd('task') !== 'test') { $dbs[$cn->id] = FabrikWorker::getDbo(); // $$$rob remove the error from the error stack // if we dont do this the form is not rendered JError::getError(true); } else { $app = JFactory::getApplication(); if (!$app->isAdmin()) { JError::raiseError(E_ERROR, 'Could not connection to database', $default_options); jexit('Could not connection to database - possibly a menu item which doesn\'t link to a fabrik table'); } else { // $$$ rob - unset the connection as caching it will mean that changes we make to the incorrect connection in admin, will not result // in the test connection link informing the user that the changed connection properties are now correct if (JRequest::getCmd('task') == 'test') { $session->clear('fabrik.connection.' . $cn->id); $this->_connection = null; $level = E_NOTICE; } else { $level = E_ERROR; } return JError::raise($level, 500, 'Could not connection to database cid = ' . $cn->id); } } } } return $dbs[$cn->id]; }
/** * Creates or updates the database schema * * @return void * * @throws Exception When a database query fails and it doesn't have the canfail flag */ public function updateSchema() { // Get the schema XML file $xml = $this->findSchemaXml(); if (empty($xml)) { return; } // Make sure there are SQL commands in this file if (!$xml->sql) { return; } // Walk the sql > action tags to find all tables $tables = array(); /** @var SimpleXMLElement $actions */ $actions = $xml->sql->children(); /** @var SimpleXMLElement $action */ foreach ($actions as $action) { // Get the attributes $attributes = $action->attributes(); // Get the table / view name $table = $attributes->table ? $attributes->table : ''; if (empty($table)) { continue; } // Am I allowed to let this action fail? $canFailAction = $attributes->canfail ? $attributes->canfail : 0; // Evaluate conditions $shouldExecute = true; /** @var SimpleXMLElement $node */ foreach ($action->children() as $node) { if ($node->getName() == 'condition') { // Get the operator $operator = $node->attributes()->operator ? (string) $node->attributes()->operator : 'and'; $operator = empty($operator) ? 'and' : $operator; $condition = $this->conditionMet($table, $node); switch ($operator) { case 'not': $shouldExecute = $shouldExecute && !$condition; break; case 'or': $shouldExecute = $shouldExecute || $condition; break; case 'nor': $shouldExecute = $shouldExecute || !$condition; break; case 'xor': $shouldExecute = ($shouldExecute xor $condition); break; case 'maybe': $shouldExecute = $condition ? true : $shouldExecute; break; default: $shouldExecute = $shouldExecute && $condition; break; } } if (!$shouldExecute) { break; } } // Make sure all conditions are met if (!$shouldExecute) { continue; } // Execute queries foreach ($action->children() as $node) { if ($node->getName() == 'query') { $canFail = $node->attributes->canfail ? $node->attributes->canfail : $canFailAction; $this->db->setQuery((string) $node); try { if (version_compare(JVERSION, '3.1', 'lt')) { $handlers = array(E_NOTICE => JError::getErrorHandling(E_NOTICE), E_WARNING => JError::getErrorHandling(E_WARNING), E_ERROR => JError::getErrorHandling(E_ERROR)); $handlers[E_NOTICE]['options'] = isset($handlers[E_NOTICE]['options']) ? $handlers[E_NOTICE]['options'] : null; $handlers[E_WARNING]['options'] = isset($handlers[E_WARNING]['options']) ? $handlers[E_WARNING]['options'] : null; $handlers[E_ERROR]['options'] = isset($handlers[E_ERROR]['options']) ? $handlers[E_ERROR]['options'] : null; JError::setErrorHandling(E_NOTICE, 'ignore'); JError::setErrorHandling(E_WARNING, 'ignore'); JError::setErrorHandling(E_ERROR, 'ignore'); } $this->db->execute(); if (version_compare(JVERSION, '3.1', 'lt')) { JError::setErrorHandling(E_NOTICE, $handlers[E_NOTICE]['mode'], $handlers[E_NOTICE]['options']); JError::setErrorHandling(E_WARNING, $handlers[E_WARNING]['mode'], $handlers[E_WARNING]['options']); JError::setErrorHandling(E_ERROR, $handlers[E_ERROR]['mode'], $handlers[E_ERROR]['options']); } if (version_compare(JVERSION, '3.1', 'lt') && $this->db->getErrorNum()) { if (!$canFail) { JError::raise(E_WARNING, $this->db->getErrorNum(), $this->db->getErrorMsg()); } } /**/ } catch (Exception $e) { // If we are not allowed to fail, throw back the exception we caught if (!$canFail) { throw $e; } } } } } }
/** * @package AkeebaBackup * @copyright Copyright (c)2009-2014 Nicholas K. Dionysopoulos * @license GNU General Public License version 3, or later * * @since 1.3 */ // Protect from unauthorized access defined('_JEXEC') or die; JDEBUG ? define('AKEEBADEBUG', 1) : null; // Check for PHP4 if (defined('PHP_VERSION')) { $version = PHP_VERSION; } elseif (function_exists('phpversion')) { $version = phpversion(); } else { // No version info. I'll lie and hope for the best. $version = '5.0.0'; } // Old PHP version detected. EJECT! EJECT! EJECT! if (!version_compare($version, '5.3.0', '>=')) { return JError::raise(E_ERROR, 500, 'This version of PHP is not compatible with Akeeba Backup'); } JLoader::import('joomla.application.component.model'); // Load F0F include_once JPATH_SITE . '/libraries/f0f/include.php'; if (!defined('F0F_INCLUDED') || !class_exists('F0FForm', true)) { JError::raiseError('500', 'Your Akeeba Backup installation is broken; please re-install. Alternatively, extract the installation archive and copy the fof directory inside your site\'s libraries directory.'); } F0FDispatcher::getTmpInstance('com_akeeba')->dispatch();
if (!class_exists($_class)) { require $basePath . DS . 'controllers' . DS . $_controller . '.php'; } } else { // try plugins JPluginHelper::importPlugin('vmextended'); $dispatcher = JDispatcher::getInstance(); $rets = $dispatcher->trigger($trigger, array($_controller)); foreach ($rets as $ret) { if ($ret) { return true; } } } if (class_exists($_class)) { $controller = new $_class(); $controller->execute($task); //vmTime($_class.' Finished task '.$task,'Start'); vmRam('End'); vmRamPeak('Peak'); /* Redirect if set by the controller */ $controller->redirect(); } else { vmDebug('VirtueMart controller not found: ' . $_class); if (tsmConfig::get('handle_404', 1)) { $mainframe = Jfactory::getApplication(); $mainframe->redirect(JRoute::_('index.php?option=com_virtuemart&view=tsmart', FALSE)); } else { JError::raise(E_ERROR, '404', 'Not found'); } }
protected function addIcon($image, $locationTable) { if ($image['name']) { $mime_types = array("image/jpeg", "image/pjpeg", "image/png", "image/gif", "image/bmp", "image/x-windows-bmp"); if (in_array($image['type'], $mime_types)) { $this->removeIcon($locationTable); $imageOriginalDirectory = JPATH_ROOT . "/media/com_judirectory/images/location/original/" . $this->listing_id . "/"; $imageDirectory = JPATH_ROOT . "/media/com_judirectory/images/location/" . $this->listing_id . "/"; if (!JFolder::exists($imageOriginalDirectory)) { $file_index = $imageOriginalDirectory . 'index.html'; $buffer = "<!DOCTYPE html><title></title>"; JFile::write($file_index, $buffer); } if (!JFolder::exists($imageDirectory)) { $file_index = $imageDirectory . 'index.html'; $buffer = "<!DOCTYPE html><title></title>"; JFile::write($file_index, $buffer); } $image_file_name = $locationTable->id . "_" . JUDirectoryHelper::fileNameFilter($image['name']); if (JFile::upload($image['tmp_name'], $imageOriginalDirectory . $image_file_name) && JUDirectoryHelper::renderImages($imageOriginalDirectory . $image_file_name, $imageDirectory . $image_file_name, 'location_image', true, null, $this->listing_id)) { $locationTable->image = $image_file_name; $locationTable->store(); } } else { JError::raise(E_NOTICE, 500, JText::sprintf('COM_JUDIRECTORY_LOCATION_ICON_IS_NOT_VALID_MIME_TYPE', implode(",", $mime_types))); } } }
static function raiseError($message, $refresh) { if ($refresh == true) { JError::raise(2, 500, $message); } else { echo $message; } }