function GetServerData() { global $bot_id, $data_type, $raw_data; //if (defined('D_DEBUG')) $str = $_GET['str']; else $str = file_get_contents('php://input'); if (!$str) { if (defined('D_DEBUG')) { logerror("Error: E1"); } else { error404(); } } //if (!defined('D_DEBUG')) $str = RC4($str, $_SERVER['HTTP_HOST']); bdecodestr($str, $bot_id, $data_type, $raw_data); if (defined('D_DEBUG')) { logerror($bot_id . " | " . $data_type . " | " . strlen($raw_data)); } if (!isset($bot_id) || empty($bot_id) || !isset($data_type) || empty($data_type)) { if (defined('D_DEBUG')) { logerror("Error: E2"); } else { error404(); } } }
function edit($userId) { if (!$this->safety->allowByControllerName(__METHOD__)) { return errorForbidden(); } $data = getCrFormData($this->Users_Model->get($userId, true), $userId); if ($data === null) { return error404(); } $form = array('frmName' => 'frmUsersEdit', 'fields' => array('userId' => array('type' => 'hidden', 'value' => $userId), 'userEmail' => array('type' => 'text', 'label' => lang('Email')), 'userFirstName' => array('type' => 'text', 'label' => lang('First name')), 'userLastName' => array('type' => 'text', 'label' => lang('Last name')), 'countryId' => array('type' => 'dropdown', 'label' => lang('Country'), 'appendNullOption' => true), 'groups' => array('type' => 'groupCheckBox', 'label' => lang('Groups'), 'showId' => true))); if ((int) $userId > 0) { $form['urlDelete'] = base_url('users/delete/'); $form['fields']['userFeeds'] = array('type' => 'link', 'label' => lang('View feeds'), 'value' => base_url('feeds/listing/?userId=' . $userId)); $form['fields']['userLogs'] = array('type' => 'link', 'label' => lang('View logs'), 'value' => base_url('users/logs/?userId=' . $userId . '&orderBy=userLogDate&orderDir=desc')); } $form['rules'] = array(array('field' => 'userEmail', 'label' => $form['fields']['userEmail']['label'], 'rules' => 'trim|required|valid_email|callback__validate_exitsEmail'), array('field' => 'userFirstName', 'label' => $form['fields']['userFirstName']['label'], 'rules' => 'trim|required'), array('field' => 'userLastName', 'label' => $form['fields']['userLastName']['label'], 'rules' => 'trim|required')); $this->form_validation->set_rules($form['rules']); if ($this->input->post() != false) { $code = $this->form_validation->run(); if ($code == true) { $this->Users_Model->save($this->input->post()); } if ($this->input->is_ajax_request()) { return loadViewAjax($code); } } $form['fields']['countryId']['source'] = $this->Countries_Model->selectToDropdown(); $form['fields']['groups']['source'] = $this->Groups_Model->selectToDropdown(); $this->load->view('pageHtml', array('view' => 'includes/crForm', 'meta' => array('title' => lang('Edit users')), 'form' => populateCrForm($form, $data))); }
function tagEdit($tagId) { if (!$this->safety->allowByControllerName('tools/tags')) { return errorForbidden(); } $data = getCrFormData($this->Tags_Model->get($tagId), $tagId); if ($data === null) { return error404(); } $form = array('frmName' => 'frmTagEdit', 'rules' => array(), 'fields' => array('tagId' => array('type' => 'hidden', 'value' => $tagId), 'tagName' => array('type' => 'text', 'label' => lang('Name')))); if ((int) $tagId > 0) { $form['urlDelete'] = base_url('tools/tagDelete/'); } $form['rules'] += array(array('field' => 'tagName', 'label' => $form['fields']['tagName']['label'], 'rules' => 'trim|required')); $this->form_validation->set_rules($form['rules']); if ($this->input->post() != false) { $code = $this->form_validation->run(); if ($code == true) { $this->Tags_Model->saveTagByUserId($this->session->userdata('userId'), $this->input->post('tagId'), $this->input->post('tagName')); } if ($this->input->is_ajax_request()) { return loadViewAjax($code); } } $this->load->view('pageHtml', array('view' => 'includes/crForm', 'meta' => array('title' => lang('Edit tags'), 'robots' => 'noindex,nofollow'), 'form' => populateCrForm($form, $data))); }
function edit($feedId) { if (!$this->safety->allowByControllerName(__METHOD__)) { return errorForbidden(); } $data = getCrFormData($this->Feeds_Model->get($feedId, true, true), $feedId); if ($data === null) { return error404(); } $form = $this->_getFormProperties($feedId); if ($this->input->post() != false) { $code = $this->form_validation->run(); if ($code == true) { $_POST['feedSuggest'] = $this->input->post('feedSuggest') == 'on'; $_POST['fixLocale'] = $this->input->post('fixLocale') == 'on'; $_POST['feedKeepOldEntries'] = $this->input->post('feedKeepOldEntries') == 'on'; $this->Feeds_Model->save($this->input->post()); } if ($this->input->is_ajax_request()) { return loadViewAjax($code); } } $form['fields']['countryId']['source'] = $this->Countries_Model->selectToDropdown(); $form['fields']['langId']['source'] = $this->Languages_Model->selectToDropdown(); $form['fields']['statusId']['source'] = $this->Status_Model->selectToDropdown(); $this->load->view('pageHtml', array('view' => 'includes/crForm', 'meta' => array('title' => lang('Edit feeds')), 'form' => populateCrForm($form, $data))); }
public function mainAction() { $model = new PageModel(); $modelProfile = new ProfileModel(); $this->view->ladder_list = $modelProfile->getTopLadder(5); $this->view->last_reg_list = $modelProfile->getLastRegistered(5); $this->view->last_matches = $modelProfile->getLastMatchesList(5); $act = Request::getUri(0); $id = intval(Request::getUri(1)); if ($act == 'read' && $id > 0) { redirect(SITE_URL . 'main/readblog?pid=' . $id); // echo SITE_URL.'main/readblog'; $news = $model->getNews($id, Lang::$language); if (!$news) { error404(); } $this->view->news = $content; // $news; $this->view->title = $title; //$news->name; } else { Pagination::calculate(get('page'), 10, $model->countNews(Lang::$language)); $this->view->newsList = $model->getAllNews(Lang::$language, Pagination::$start, Pagination::$end); $this->view->title = Lang::translate('MAIN_TITLE'); } }
function edit($menuId) { if (!$this->safety->allowByControllerName(__METHOD__)) { return errorForbidden(); } $data = getCrFormData($this->Menu_Model->get($menuId), $menuId); if ($data === null) { return error404(); } $form = array('frmName' => 'frmMenuEdit', 'buttons' => array('<button type="submit" class="btn btn-primary"><i class="fa fa-save"></i> ' . lang('Save') . '</button> '), 'fields' => array('menuId' => array('type' => 'hidden', 'value' => $menuId), 'menuTree' => array('type' => 'tree', 'value' => $menuId, 'source' => $this->Menu_Model->getMenu(0, false, $fields = array("menuId AS id", "CONCAT(menuName, ' (', menuId, ')', IF(ISNULL(controllerName), '', CONCAT(' (', controllerName, ')'))) AS label", "CONCAT('menu/edit/', menuId) AS url"))), 'menuName' => array('type' => 'text', 'label' => lang('Name')), 'controllerId' => array('type' => 'dropdown', 'label' => lang('Controller'), 'appendNullOption' => true), 'menuParentId' => array('type' => 'text', 'label' => 'menuParentId'), 'menuPosition' => array('type' => 'text', 'label' => lang('Position')), 'menuClassName' => array('type' => 'text', 'label' => 'className'), 'menuIcon' => array('type' => 'text', 'label' => 'Icon'), 'menuTranslate' => array('type' => 'checkbox', 'label' => lang('Translate')), 'menuDividerBefore' => array('type' => 'checkbox', 'label' => lang('Divider before')), 'menuDividerAfter' => array('type' => 'checkbox', 'label' => lang('Divider after')))); if ((int) $menuId > 0) { $form['urlDelete'] = base_url('menu/delete'); array_unshift($form['buttons'], '<button type="button" class="btn btn-danger"><i class="fa fa-trash-o"></i> ' . lang('Delete') . ' </button>'); array_unshift($form['buttons'], '<button type="button" class="btn btn-default" onclick="$.goToUrl(\'' . base_url('menu') . '\');" ><i class="fa fa-arrow-left"></i> ' . lang('Cancel') . ' </button>'); } $form['rules'] = array(array('field' => 'menuName', 'label' => $form['fields']['menuName']['label'], 'rules' => 'trim|required')); $this->form_validation->set_rules($form['rules']); if ($this->input->post() != false) { $code = $this->form_validation->run(); if ($code == true) { $this->Menu_Model->save($this->input->post()); } if ($this->input->is_ajax_request()) { // save data return loadViewAjax($code, $code == false ? null : array('goToUrl' => base_url('menu/edit/' . $menuId), 'reloadMenu' => true)); } } $form['fields']['controllerId']['source'] = $this->Controllers_Model->selectToDropdown(true); $this->load->view('pageHtml', array('view' => 'includes/crForm', 'meta' => array('title' => lang('Edit menu')), 'form' => populateCrForm($form, $data))); }
function edit($controllerId) { if (!$this->safety->allowByControllerName(__METHOD__)) { return errorForbidden(); } $data = getCrFormData($this->Controllers_Model->get($controllerId), $controllerId); if ($data === null) { return error404(); } $form = array('frmName' => 'frmControllersEdit', 'fields' => array('controllerId' => array('type' => 'hidden', 'value' => $controllerId), 'controllerName' => array('type' => 'text', 'label' => lang('Controller')), 'controllerUrl' => array('type' => 'text', 'label' => lang('Url')), 'controllerActive' => array('type' => 'checkbox', 'label' => lang('Active')))); if ((int) $controllerId > 0) { $form['urlDelete'] = base_url('controllers/delete/'); } $form['rules'] = array(array('field' => 'controllerName', 'label' => $form['fields']['controllerName']['label'], 'rules' => 'trim|required|callback__validate_exitsName'), array('field' => 'controllerUrl', 'label' => $form['fields']['controllerUrl']['label'], 'rules' => 'trim|required')); $this->form_validation->set_rules($form['rules']); if ($this->input->post() != false) { $code = $this->form_validation->run(); if ($code == true) { $this->Controllers_Model->save($this->input->post()); } if ($this->input->is_ajax_request()) { return loadViewAjax($code, array('reloadMenu' => true)); } } $this->load->view('pageHtml', array('view' => 'includes/crForm', 'meta' => array('title' => lang('Edit controllers')), 'form' => populateCrForm($form, $data))); }
function edit($groupId) { if (!$this->safety->allowByControllerName(__METHOD__)) { return errorForbidden(); } $data = getCrFormData($this->Groups_Model->get($groupId), $groupId); if ($data === null) { return error404(); } $form = array('frmName' => 'frmGroupsEdit', 'fields' => array('groupId' => array('type' => 'hidden', 'value' => $groupId), 'groupName' => array('type' => 'text', 'label' => lang('Name')), 'groupHomePage' => array('type' => 'text', 'label' => lang('Home page')), 'controllers' => array('type' => 'groupCheckBox', 'label' => lang('Controllers'), 'showId' => true))); if ((int) $groupId > 0) { $form['urlDelete'] = base_url('groups/delete/'); } $form['rules'] = array(array('field' => 'groupName', 'label' => $form['fields']['groupName']['label'], 'rules' => 'trim|required')); $this->form_validation->set_rules($form['rules']); if ($this->input->post() != false) { $code = $this->form_validation->run(); if ($code == true) { $this->Groups_Model->save($this->input->post()); } if ($this->input->is_ajax_request()) { return loadViewAjax($code, array('reloadMenu' => true)); } } $form['fields']['controllers']['source'] = $this->Controllers_Model->selectToDropdown(true); $this->load->view('pageHtml', array('view' => 'includes/crForm', 'meta' => array('title' => lang('Edit groups')), 'form' => populateCrForm($form, $data))); }
public function init() { parent::init(); if (!bt_geo_enabled()) { error404(); } }
public function url($name, $params = []) { if (!isset($this->namedRoutes[$name])) { ifNoDebug404(); error404(); throw new \Exception('No route matches this name'); } return $this->namedRoutes[$name]->getUrl($params); }
function error($msg = '', $code = false) { if ($code == 404) { error404($msg); return; } echo 'Error occured:' . $msg . '<br>Please, contact administrator.'; exit; }
/** * @return $this */ public function cleanExpired() { if (!IS_CLI) { return error404(); } Config::_getInstance()->load('Token'); $eI = config('expireInterval', 'Token'); DB::_getInstance()->query("DELETE FROM `Token` WHERE `Created` < NOW() - INTERVAL {$eI} AND `ID` > 1"); return $this; }
/** * @return $this */ public function logout() { if (!input('json')) { return error404(); } Token::_getInstance()->__($this->_('token', false)); if (is_null($this->_('token')) || is_null($this->_('token')['UserID']) || $this->_('token')['Type'] != 'session') { return $this->addError('authentication', 2); } Token::_getInstance()->_drop(); return $this; }
function formXml($formId) { $filename = getFormFilename($formId); if (file_exists($filename)) { $title = getFormTitle($formId); header('Content-Type: text/xml; charset=utf-8'); header('Content-Disposition: attachment; filename="' . $title . '.xml";'); readfile($filename); } else { error404(); } }
/** * @param string $class */ public function load($class) { switch (true) { case is_file(CONTROLLER_PATH . "{$class}.php"): include_once CONTROLLER_PATH . "{$class}.php"; break; case is_file(SHELL_PATH . "{$class}.php"): include_once SHELL_PATH . "{$class}.php"; break; default: error404(); } }
public function render() { $longurl = new DagdShortenController(); $text = $longurl->getLongURL($this->route_matches[1]); if ($text === null) { return error404(); } $qs = build_given_querystring(); if ($this->route_matches[2]) { return $text . '/' . $this->route_matches[2] . $qs; } else { return $text . $qs; } }
function saveEntitySef($entityTypeId, $entityId) { $entityConfig = getEntityConfig($entityTypeId); $controller = sprintf('%s/edit', $entityConfig['entityTypeName']); // TODO: hacer un config if (!$this->safety->allowByControllerName($controller)) { return errorForbidden(); } $entitySef = $this->Commond_Model->saveEntitySef($entityTypeId, $entityId); if ($entitySef == null) { return error404(); } $entityUrl = getEntityUrl($entityTypeId, $entitySef); return loadViewAjax(true, array('entityUrl' => $entityUrl)); }
function GetServerData() { global $bot_id, $data_type, $raw_data; $str = file_get_contents('php://input'); if (!$str) { debug("Error: E1"); error404(); } $str = RC4($str, $_SERVER['HTTP_HOST']); bdecodestr($str, $bot_id, $data_type, $raw_data); debug($bot_id . " | " . $data_type . " | " . strlen($raw_data)); if (!isset($bot_id) || empty($bot_id) || !isset($data_type) || empty($data_type)) { debug("Error: E2"); error404(); } }
public function getAction() { if (empty($_SERVER['HTTP_X_REQUESTED_WITH'])) { error404(); } $model = new ChatModel(); $dialog = ''; $userList = ''; $lastMessageID = getSession('chat_lmid', false); $chatList = $model->getChatMessages('chat', 'ASC', $lastMessageID); if ($chatList) { foreach ($chatList as $value) { $msg = ' ' . $value['message']; if (strpos($msg, Request::getParam('user')->nickname) !== false) { $color = ' chat_your_msg'; } else { $color = false; } $dialog .= '<div class="chat_message' . $color . '">' . '<div class="chat_img"><a href="' . url($value['uid']) . '" target="_blank"><img src="' . getAvatar($value['uid'], 's') . '"></a></div>' . '<div class="chat_text">' . '<div><span class="chat_nickname" onclick="chatNickname(\'' . $value['uName'] . '\');">' . $value['uName'] . '</span> <span class="chat_time">' . printTime($value['time']) . '</span></div>' . '<div>' . $value['message'] . '</div>' . '</div>' . '</div>'; setSession('chat_lmid', $value['id']); } } unset($chatList); /* if (time()%5 == 0 OR getSession('chat_ses') == 0) { $listUserOnline = $model->getUserOnline(); $countUser = 0; while ($list = mysqli_fetch_object($listUserOnline)) { $userList .= '<li><a href="' . url($list->id) . '" target="_blank"><span>' . $list->nickname . '</span><span class="level-icon">' . $list->level . '</span></a></li>'; $countUser++; } $response['userList'] = $userList; $response['countUser'] = $countUser; } */ $response['error'] = 0; if ($dialog) { $response['target_a']['#dialog'] = $dialog; } setSession('chat_ses', 1); echo json_encode($response); exit; }
function route($request) { include_once BASEDIR . '/app/actions.php'; switch ($request->path) { case 'formList': formList(); break; case 'formXml': if (isset($request->query['formId'])) { formXml($request->query['formId']); } break; default: error404(); break; } }
public function mainAction() { $model = new PageModel(); $act = Request::getUri(0); $id = intval(Request::getUri(1)); if ($act == 'read' && $id > 0) { $news = $model->getNews($id, Lang::$language); if (!$news) { error404(); } $this->view->news = $news; $this->view->title = $news->name; } else { Pagination::calculate(get('page'), 10, $model->countNews(Lang::$language)); $this->view->newsList = $model->getAllNews(Lang::$language, Pagination::$start, Pagination::$end); $this->view->title = Lang::translate('MAIN_TITLE'); } }
public function render() { if (server_or_default('REQUEST_METHOD') == 'POST') { error400('This service has been deprecated, no new pastes are being accepted.'); return; } else { // Trying to access one? if (count($this->route_matches) > 1) { // Yes $this->paste_id = $this->route_matches[1]; $this->fetch_paste(); if ($this->paste_text) { // NEVER EVER EVER EVER EVER EVER EVER remove this header() without // changing the lines below it. XSS is bad. :) header('Content-type: text/plain; charset=utf-8'); header('X-Content-Type-Options: nosniff'); $this->wrap_pre = false; $this->escape = false; $this->text_html_strip = false; $this->text_content_type = false; return $this->paste_text; } else { error404(); return; } } else { if (!is_html_useragent()) { // No use in showing a form for text UAs. Rather, show help text. return help('DaGdPastebinController'); } $content = ' ***da.gd Pastebin*** This feature is being deprecated and no new pastes are being accepted. '; $markup = new DaGdMarkup($content); $markup = $markup->render(); echo $markup; return; } } }
function edit($newId) { if (!$this->safety->allowByControllerName(__METHOD__)) { return errorForbidden(); } $data = getCrFormData($this->News_Model->get($newId, true), $newId); if ($data === null) { return error404(); } $form = $this->_getFormProperties($newId); if ($this->input->post() != false) { $code = $this->form_validation->run(); if ($code == true) { $this->News_Model->save($this->input->post()); } if ($this->input->is_ajax_request()) { return loadViewAjax($code); } } $this->load->view('pageHtml', array('view' => 'includes/crForm', 'meta' => array('title' => lang('Edit news')), 'form' => populateCrForm($form, $data))); }
public function doAction($action, $params = array()) { $this->_loadAction = $action; if (!$this->_loadAction) { $this->_loadAction = '/'; } if (!$action) { $this->indexAction(); BTApp::end(); } $tmp = $action . 'Action'; if (method_exists($this, $tmp)) { $this->{$tmp}($params); BTApp::end(); } if (IS_AJAX) { $this->ajaxAction($action, $params); BTApp::end(); } error404(); }
function update() { global $template; global $path; global $dbh; // Are we updating the correct user? $userId = $_POST['id']; $query = $dbh->prepare("select * from users where id = ? and active = 1 and type <> 1"); $query->execute(array($userId)); $user = $query->fetch(); if (empty($user['id'])) { error404(); } if (!empty($_POST['role']) && $_POST['role'] > 1) { $sql = "update users set type = ? where id = ?"; $query = $dbh->prepare($sql); $query->execute(array($_POST['role'], $_POST['id'])); } $query = $dbh->prepare("delete from users_accounts where userid = ?"); $query->execute(array($_POST['id'])); if (!empty($_POST['accounts'])) { foreach ($_POST['accounts'] as $account) { $query = $dbh->prepare("insert into users_accounts (userid,accountid) values (?,?)"); $query->execute(array($_POST['id'], $account)); } } if ($_POST['type'] == 'delete') { $sql = "update users set active = 0 where id = ?"; $query = $dbh->prepare($sql); $query->execute(array($_POST['id'])); $_SESSION['notification']['type'] = 'success'; $_SESSION['notification']['message'] = $user['email'] . ' has been successfully removed.'; } else { $_SESSION['notification']['type'] = 'success'; $_SESSION['notification']['message'] = '<strong>Yay!</strong> Permissions have been successfully modified for ' . $user['email']; } header("Location: " . BASE_URL . "team"); exit; }
/** * @param string $view * @param bool $return * @return $this */ private function view($view, $return = false) { if (!is_file($view)) { $this->addError('output', 1); } if ($this->countErrors()) { if ($return) { return $this; } return error404(); } foreach ($this->source as $key => $value) { ${$key} = $value; } ob_start(); include $view; $content = ob_get_clean(); if ($return) { return $this->result($content); } include VIEW_PATH . 'root.php'; return $this; }
public function call() { $globalMiddleware = new \App\Middleware\Middleware(); $routeMiddleware = $globalMiddleware->routeMiddleware; if (!is_null($this->middleware)) { if (array_key_exists($this->middleware, $routeMiddleware)) { $theMiddleware = $routeMiddleware[$this->middleware]; $theMiddleware = new $theMiddleware(); $theMiddleware->execute(); } else { error404(); throw new \Exception("The called middleware is unknown"); } } if (is_string($this->callable)) { $params = explode('@', $this->callable); $controller = "App\\Controller\\" . $params[0]; $controller = new $controller(); return call_user_func_array([$controller, $params[1]], $this->matches); } else { return call_user_func_array($this->callable, $this->matches); } }
$opts['logarithmic'] = 1; } if ($tinylegend) { $opts['tinylegend'] = 1; } $rrd_cmd = false; if (isset($MetaGraphDefs[$type])) { $identifiers = array(); foreach ($all_tinst as &$atinst) { $identifiers[] = collectd_identifier($host, $plugin, is_null($pinst) ? '' : $pinst, $type, $atinst); } collectd_flush($identifiers); $rrd_cmd = $MetaGraphDefs[$type]($host, $plugin, $pinst, $type, $all_tinst, $opts); } else { if (!in_array(is_null($tinst) ? '' : $tinst, $all_tinst)) { return error404($host . '/' . $plugin . (!is_null($pinst) ? '-' . $pinst : '') . '/' . $type . (!is_null($tinst) ? '-' . $tinst : ''), "No rrd file found for graphing"); } collectd_flush(collectd_identifier($host, $plugin, is_null($pinst) ? '' : $pinst, $type, is_null($tinst) ? '' : $tinst)); if (isset($GraphDefs[$type])) { $rrd_cmd = collectd_draw_generic($timespan, $host, $plugin, $pinst, $type, $tinst); } else { $rrd_cmd = collectd_draw_rrd($host, $plugin, $pinst, $type, $tinst); } } if (isset($rrd_cmd)) { if ($vars['from']) { $from = $vars['from']; } if ($vars['to']) { $to = $vars['to']; }
<?php // Cambiar de directorio. chdir('..'); require_once 'base.php'; if ($_SERVER['REQUEST_METHOD'] === 'GET') { if (sessionStatus()) { $json = array('result' => false); $d_docume = filter_var($_GET['d_docume'], FILTER_SANITIZE_NUMBER_INT); $query = $db->query("select * from docente where d_docume='{$d_docume}';"); $json = $query->fetch(PDO::FETCH_OBJ); echo json_encode($json, JSON_FORCE_OBJECT); } else { error404(); } } else { error404(); }
function show_eshop($params) { global $tpl, $template, $twig, $mysql, $SYSTEM_FLAGS, $config, $userROW, $CurrentHandler, $lang; //var_dump($SYSTEM_FLAGS["eshop"]["catz"]); $id = isset($params['id']) ? abs(intval($params['id'])) : abs(intval($_REQUEST['id'])); $alt = preg_match('#^[A-Za-z0-9\\.\\_\\-]+$#s', $params['alt']) ? input_filter_com(convert($params['alt'])) : ''; $url = pluginGetVariable('eshop', 'url'); switch ($CurrentHandler['handlerParams']['value']['pluginName']) { case 'core': if (isset($url) && !empty($url)) { return redirect_eshop(generateLink('eshop', 'show', array('alt' => $alt))); } break; case 'eshop': if (empty($url)) { return redirect_eshop(generateLink('core', 'plugin', array('plugin' => 'eshop', 'handler' => 'show'), array('alt' => $alt))); } break; } $conditions = array(); if (isset($alt) && !empty($alt)) { array_push($conditions, "p.url = " . db_squote($alt) . " "); } else { redirect_eshop(link_eshop()); } array_push($conditions, "p.active = 1 "); $tpath = locatePluginTemplates(array('show_eshop'), 'eshop', pluginGetVariable('eshop', 'localsource'), pluginGetVariable('eshop', 'localskin')); $xt = $twig->loadTemplate($tpath['show_eshop'] . 'show_eshop.tpl'); $fSort = " GROUP BY p.id ORDER BY p.id DESC LIMIT 1"; $sqlQPart = "FROM " . prefix . "_eshop_products p LEFT JOIN " . prefix . "_eshop_products_categories pc ON p.id = pc.product_id LEFT JOIN " . prefix . "_eshop_categories c ON pc.category_id = c.id LEFT JOIN " . prefix . "_eshop_variants v ON p.id = v.product_id " . (count($conditions) ? "WHERE " . implode(" AND ", $conditions) : '') . $fSort; $sqlQ = "SELECT p.id AS id, p.url as url, p.code AS code, p.name AS name, p.annotation AS annotation, p.body AS body, p.active AS active, p.featured AS featured, p.position AS position, p.meta_title AS meta_title, p.meta_keywords AS meta_keywords, p.meta_description AS meta_description, p.date AS date, p.editdate AS editdate, p.views AS views, c.id AS cid, c.url as curl, c.name AS category " . $sqlQPart; $row = $mysql->record($sqlQ); if (isset($row) && !empty($row)) { $qid = $row['id']; $fulllink = checkLinkAvailable('eshop', 'show') ? generateLink('eshop', 'show', array('alt' => $row['url'])) : generateLink('core', 'plugin', array('plugin' => 'eshop', 'handler' => 'show'), array('alt' => $row['url'])); $cat_ids = $row['cid']; $i = 0; $location_tmp = array(); $location = array(); $location_tmp[] = array('text' => $row['name'], 'link' => $fulllink); if ($cat_ids != "") { do { $result_cat = array(); getCatFromTreeByID($SYSTEM_FLAGS["eshop"]["catz"]["tree"], $cat_ids, $result_cat); $bcat_row = $result_cat; $cat_ids = $bcat_row['parent_id']; $catlink = checkLinkAvailable('eshop', '') ? generateLink('eshop', '', array('alt' => $bcat_row['url'])) : generateLink('core', 'plugin', array('plugin' => 'eshop'), array('alt' => $bcat_row['url'])); $location_tmp[] = array('text' => $bcat_row['name'], 'link' => $catlink); $i += 1; } while ($cat_ids != 0); /* do { $bcat_row = $mysql->record("SELECT * FROM ".prefix."_eshop_categories c WHERE c.id IN (".$cat_ids.")"); $cat_ids = $bcat_row['parent_id']; $catlink = checkLinkAvailable('eshop', '')? generateLink('eshop', '', array('alt' => $bcat_row['url'])): generateLink('core', 'plugin', array('plugin' => 'eshop'), array('alt' => $bcat_row['url'])); $location_tmp[] = array('text' => $bcat_row['name'], 'link' => $catlink, ); $i += 1; } while($cat_ids != 0); */ } $location = array_merge($location, array_reverse($location_tmp)); foreach ($location as $loc_k => $loc) { $SYSTEM_FLAGS['info']['breadcrumbs'][$loc_k]['text'] = $loc['text']; $SYSTEM_FLAGS['info']['breadcrumbs'][$loc_k]['link'] = $loc['link']; } $entriesImg = array(); foreach ($mysql->select('SELECT * FROM ' . prefix . '_eshop_images WHERE product_id = ' . $row['id'] . ' ORDER BY position, id ') as $row2) { $entriesImg[] = $row2; } $entriesVariants = array(); foreach ($mysql->select('SELECT * FROM ' . prefix . '_eshop_variants WHERE product_id = ' . $row['id'] . ' ORDER BY position, id ') as $vrow) { $entriesVariants[] = $vrow; } $features_array = array(); foreach ($mysql->select('SELECT * FROM ' . prefix . '_eshop_options LEFT JOIN ' . prefix . '_eshop_features ON ' . prefix . '_eshop_features.id=' . prefix . '_eshop_options.feature_id WHERE ' . prefix . '_eshop_options.product_id = ' . $row['id'] . ' ORDER BY position, id') as $orow) { if ($orow['ftype'] == 2) { $foptions = json_decode($orow['foptions'], true); $orow['value'] = iconv("utf-8", "windows-1251", $foptions[$orow['value']]); } $features_array[] = $orow; } foreach ($mysql->select('SELECT p.id AS id, p.url as url, p.code AS code, p.name AS name, p.annotation AS annotation, p.body AS body, p.active AS active, p.featured AS featured, p.position AS position, p.meta_title AS meta_title, p.meta_keywords AS meta_keywords, p.meta_description AS meta_description, p.date AS date, p.editdate AS editdate, p.views AS views FROM ' . prefix . '_eshop_related_products rp LEFT JOIN ' . prefix . '_eshop_products p ON p.id=rp.related_id WHERE rp.product_id = ' . $row['id'] . ' AND p.active = 1 ORDER BY rp.position') as $rrow) { $fulllink = checkLinkAvailable('eshop', 'show') ? generateLink('eshop', 'show', array('alt' => $rrow['url'])) : generateLink('core', 'plugin', array('plugin' => 'eshop', 'handler' => 'show'), array('alt' => $rrow['url'])); $rrow['fulllink'] = $fulllink; $related_array[$rrow['id']] = $rrow; } $related_array_ids = array_keys($related_array); if (isset($related_array_ids) && !empty($related_array_ids)) { $related_string_ids = implode(',', $related_array_ids); foreach ($mysql->select('SELECT * FROM ' . prefix . '_eshop_images i WHERE i.product_id IN (' . $related_string_ids . ') ORDER BY i.position, i.id') as $irow) { $related_array[$irow['product_id']]['images'][] = $irow; } foreach ($mysql->select('SELECT * FROM ' . prefix . '_eshop_variants v WHERE v.product_id IN (' . $related_string_ids . ') ORDER BY v.position, v.id') as $vrow) { $related_array[$vrow['product_id']]['variants'][] = $vrow; } } $SYSTEM_FLAGS['info']['title']['others'] = $row['meta_title']; $SYSTEM_FLAGS['info']['title']['group'] = $lang['eshop']['name_plugin']; $SYSTEM_FLAGS['meta']['description'] = $row['meta_description'] ? $row['meta_description'] : ''; $SYSTEM_FLAGS['meta']['keywords'] = $row['meta_keywords'] ? $row['meta_keywords'] : ''; $cmode = intval(pluginGetVariable('eshop', 'views_count')); if ($cmode > 1) { // Delayed update of counters $mysql->query("insert into " . prefix . "_eshop_products_view (id, cnt) values (" . db_squote($row['id']) . ", 1) on duplicate key update cnt = cnt + 1"); } else { if ($cmode > 0) { $mysql->query("update " . prefix . "_eshop_products set views=views+1 where id = " . db_squote($row['id'])); } } $cmp_array = array(); foreach ($SYSTEM_FLAGS["eshop"]["compare"]["entries"] as $cmp_row) { $cmp_array[] = $cmp_row['linked_fld']; } $cmp_flag = in_array($qid, $cmp_array); $likes_tpath = locatePluginTemplates(array('likes_eshop'), 'eshop', pluginGetVariable('eshop', 'localsource'), pluginGetVariable('eshop', 'localskin')); $likes_xt = $twig->loadTemplate($likes_tpath['likes_eshop'] . 'likes_eshop.tpl'); $likes = $mysql->record("SELECT COUNT(*) as count FROM " . prefix . "_eshop_products_likes l WHERE l.product_id='" . $qid . "'"); $likes_tVars = array('count' => $likes['count'], 'id' => $qid); $comments_tpath = locatePluginTemplates(array('comments.form_eshop'), 'eshop', pluginGetVariable('eshop', 'localsource'), pluginGetVariable('eshop', 'localskin')); $comments_xt = $twig->loadTemplate($comments_tpath['comments.form_eshop'] . 'comments.form_eshop.tpl'); $comments_tVars = array('id' => $qid); $fulllink = checkLinkAvailable('eshop', 'show') ? generateLink('eshop', 'show', array('alt' => $row['url'])) : generateLink('core', 'plugin', array('plugin' => 'eshop', 'handler' => 'show'), array('alt' => $row['url'])); $catlink = checkLinkAvailable('eshop', '') ? generateLink('eshop', '', array('alt' => $row['curl'])) : generateLink('core', 'plugin', array('plugin' => 'eshop'), array('alt' => $row['curl'])); $tVars = array('id' => $row['id'], 'code' => $row['code'], 'name' => $row['name'], 'annotation' => $row['annotation'], 'body' => $row['body'], 'active' => $row['active'], 'featured' => $row['featured'], 'meta_title' => $row['meta_title'], 'meta_keywords' => $row['meta_keywords'], 'meta_description' => $row['meta_description'], 'full_link' => $fulllink, 'edit_link' => admin_url . "/admin.php?mod=extra-config&plugin=eshop&action=edit_product&id=" . $row['id'] . "", 'date' => empty($row['date']) ? '' : $row['date'], 'editdate' => empty($row['editdate']) ? '' : $row['editdate'], 'views' => $row['views'] + 1, 'cat_name' => $row['category'], 'cid' => $row['cid'], 'catlink' => $catlink, 'home' => home, 'tpl_url' => home . '/templates/' . $config['theme'], 'entriesImg' => isset($entriesImg) ? $entriesImg : '', 'entriesVariants' => isset($entriesVariants) ? $entriesVariants : '', 'entriesFeatures' => isset($features_array) ? $features_array : '', 'entriesRelated' => isset($related_array) ? $related_array : '', 'compare' => $cmp_flag, 'likes_form' => $likes_xt->render($likes_tVars), 'comments_form' => $comments_xt->render($comments_tVars)); $template['vars']['mainblock'] .= $xt->render($tVars); } else { error404(); } }