public function init() { $this->_iaCore = iaCore::instance(); $this->CharSet = 'UTF-8'; $this->From = $this->_iaCore->get('site_email'); $this->FromName = $this->_iaCore->get('site_from_name', 'Subrion CMS'); $this->SingleTo = true; $this->isHTML($this->_iaCore->get('mimetype')); switch ($this->_iaCore->get('mail_function')) { case 'smtp': $this->isSMTP(); $this->Host = $this->_iaCore->get('smtp_server'); $this->SMTPAuth = (bool) $this->_iaCore->get('smtp_auth'); $this->Username = $this->_iaCore->get('smtp_user'); $this->Password = $this->_iaCore->get('smtp_password'); $this->SMTPSecure = 'ssl'; if ($port = $this->_iaCore->get('smtp_port')) { $this->Port = (int) $port; } break; case 'sendmail': $this->isSendmail(); $this->Sendmail = $this->_iaCore->get('sendmail_path'); break; default: // PHP's mail function $this->isMail(); } // global patterns $this->setReplacements(array('site_url' => IA_URL, 'site_name' => $this->_iaCore->get('site'), 'site_email' => $this->_iaCore->get('site_email'))); }
protected function _launchFile($file) { ignore_user_abort(1); @set_time_limit(0); $iaCore = iaCore::instance(); $iaDb =& $iaCore->iaDb; $iaView =& $iaCore->iaView; include IA_HOME . $file; }
private function _getExtraType($extraName) { if (is_null(self::$_extraTypes)) { $iaCore = iaCore::instance(); $iaCore->factory('item'); self::$_extraTypes = $iaCore->iaDb->keyvalue(array('name', 'type'), iaDb::convertIds(iaCore::STATUS_ACTIVE, 'status'), iaItem::getExtrasTable()); } return isset(self::$_extraTypes[$extraName]) ? self::$_extraTypes[$extraName] : null; }
public static function reloadIdentity() { $sql = 'SELECT u.*, g.`name` `usergroup` ' . 'FROM `:prefix_:table_users` u ' . 'LEFT JOIN `:prefix_:table_groups` g ON (g.`id` = u.`usergroup_id`) ' . "WHERE u.`id` = :id AND u.`status` = ':status' " . 'LIMIT 1'; $iaDb = iaCore::instance()->iaDb; $sql = iaDb::printf($sql, array('prefix_' => $iaDb->prefix, 'table_users' => self::getTable(), 'table_groups' => self::getUsergroupsTable(), 'id' => self::getIdentity()->id, 'status' => iaCore::STATUS_ACTIVE)); $row = $iaDb->getRow($sql); self::_setIdentity($row); return (bool) $row; }
public function init() { parent::init(); $this->_cachingEnabled = true; if (!file_exists($this->_savePath)) { iaCore::instance()->util()->makeDirCascade($this->_savePath, 0777); } $mask = !function_exists('posix_getuid') || function_exists('posix_getuid') && posix_getuid() != fileowner(IA_HOME . 'index' . iaSystem::EXECUTABLE_FILE_EXT) ? 0777 : 0755; chmod($this->_savePath, $mask); }
public function __construct() { $this->_iaCore = iaCore::instance(); $this->_iaDb =& $this->_iaCore->iaDb; $this->_gridQueryMainTableAlias = empty($this->_gridQueryMainTableAlias) ? '' : $this->_gridQueryMainTableAlias . '.'; $this->_iaCore->factory('util'); $this->_table || $this->setTable($this->getName()); $this->_path = IA_ADMIN_URL . $this->getName() . IA_URL_DELIMITER; $this->_template = $this->getName(); }
function getAccountsToBePaid($aStart, $aLimit) { $iaCore =& iaCore::instance(); $sql = "SELECT SQL_CALC_FOUND_ROWS s.`aff_id` as `id`, SUM(payment) AS `Total`, COUNT(s.`id`) AS `Sales`, s.`aff_id`, a.`username`, 1 as `remove` "; $sql .= "FROM `{$this->mPrefix}sales` s, `{$this->mPrefix}accounts` a "; $sql .= "WHERE s.`status` = 'active' AND a.`id` = s.`aff_id` "; $sql .= "GROUP BY s.`aff_id` "; $sql .= "HAVING `Total` >= '" . $iaCore->get('payout_balance') * 100 / $iaCore->get('payout_percent') . "' "; $sql .= $aLimit ? "LIMIT {$aStart}, {$aLimit}" : ''; return $this->iaDb->getAll($sql); }
function sitemap_recipes($tpl = '<url><loc>{url}</loc></url>') { $iaCore = iaCore::instance(); $iaDb =& $iaCore->iaDb; $iaRecipe = $iaCore->factoryPackages('recipes', 'front', 'recipe'); $text = ''; $recipes = $iaRecipe->getRecipes(); foreach ($recipes as $row) { list($url, $output) = $iaRecipe->goToItem(array('item' => $row)); $text .= str_replace(array('{url}', '{site}'), array($url, ''), $tpl); } return $text; }
function albums_search($aQuery, $aFields, $aStart, $aLimit, &$aNumAll, $aWhere = '', $cond = 'AND') { $iaCore =& iaCore::instance(); $iaAlbum = $iaCore->factoryPackage('album', 'lyrics'); $ret = array(); $where = "`title` LIKE '%{$aQuery}%' OR `description` LIKE '%{$aQuery}%'"; $albums = $iaCore->iaDb->all('sql_calc_found_rows `title`, `title_alias`, `artist_alias`', $where, $aStart, $aLimit, iaAlbum::getTable()); $aNumAll += $iaCore->iaDb->foundRows(); foreach ($albums as $album) { $album_url = $iaCore->iaSmarty->ia_url(array('item' => $iaAlbum->getItemName(), 'data' => $album, 'type' => 'url')); $ret[] = sprintf('<p><a href="%s">%s</a></p>', $album_url, $album['title']); } return $ret; }
function recipes_search($aQuery, $aFields, $aStart, $aLimit, &$aNumAll, $aWhere = '', $cond = 'AND') { $iaCore =& iaCore::instance(); $ret = array(); $match = array(); if ($aQuery) { $match[] = sprintf(" MATCH (`title`, `ingredients`, `procedures`) AGAINST('%s') ", $iaCore->sql($aQuery)); } if ($aWhere) { $match[] = '' . $aWhere; } // additional fields if ($aFields && is_array($aFields)) { foreach ($aFields as $fname => $data) { if ('LIKE' == $data['cond']) { $data['val'] = "%{$data['val']}%"; } // for multiple values, like combo or checkboxes if (is_array($data['val'])) { if ('!=' == $data['cond']) { $data['cond'] = count($data['val']) > 1 ? 'NOT IN' : '!='; } else { $data['cond'] = count($data['val']) > 1 ? 'IN' : '='; } $data['val'] = count($data['val']) > 1 ? '(' . implode(',', $data['val']) . ')' : array_shift($data['val']); } else { if (preg_match('/^(\\d+)\\s*-\\s*(\\d+)$/', $data['val'], $range)) { // search in range $data['cond'] = sprintf('BETWEEN %d AND %d', $range[1], $range[2]); $data['val'] = ''; } else { $data['val'] = "'" . $iaCore->sql($data['val']) . "'"; } } $match[] = "`{$fname}` {$data['cond']} {$data['val']} "; } } $iaRecipe = $iaCore->factoryPackages('recipes', 'front', 'recipe'); $recipes = $match ? $iaRecipe->getRecipes(' AND (' . implode(' ' . $cond . ' ', $match) . ')', $aStart, $aLimit) : array(); $aNumAll = $iaRecipe->getRecipesNum(' AND (' . implode(' ' . $cond . ' ', $match) . ')'); if ($recipes && SMARTY) { $iaCore->iaSmarty->assign('all_items', $recipes); $fields = $iaCore->getAcoFieldsList('recipes_home', 'recipes', '', true); $iaCore->iaSmarty->assign_by_ref('all_item_fields', $fields); $iaCore->iaSmarty->assign('all_item_type', 'recipes'); $ret[] = $iaCore->iaSmarty->fetch('all-items-page.tpl'); } return $ret; }
public function init() { $this->iaCore = iaCore::instance(); parent::init(); foreach ($this->iaCore->packagesData as $packageName => $packageData) { $this->registerResource($packageName, $this->_createPackageTemplateHandlers($packageName)); } iaSystem::renderTime('main', 'afterSmartyFuncInit'); $this->assign('tabs_content', array()); $this->assign('tabs_before', array()); $this->assign('tabs_after', array()); $this->assign('fieldset_before', array()); $this->assign('fieldset_after', array()); $this->assign('field_before', array()); $this->assign('field_after', array()); $this->resources = array('jquery' => 'text:Loading jQuery API..., js:jquery/jquery', 'subrion' => 'text:Loading Subrion Awesome Stuff..., js:intelli/intelli, js:_IA_URL_tmp/cache/intelli.config, ' . (iaCore::ACCESS_ADMIN == $this->iaCore->getAccessType() ? 'js:_IA_TPL_bootstrap.min, js:bootstrap/js/bootstrap-switch.min, js:bootstrap/js/passfield.min, js:intelli/intelli.admin, js:admin/footer, css:_IA_URL_js/bootstrap/css/passfield' : 'js:intelli/intelli.minmax, js:frontend/footer') . ',js:_IA_URL_tmp/cache/intelli' . (iaCore::ACCESS_ADMIN == $this->iaCore->getAccessType() ? '.admin' : '') . '.lang.' . $this->iaCore->iaView->language, 'extjs' => 'text:Loading ExtJS..., css:_IA_URL_js/extjs/resources/ext-theme-neptune/ext-theme-neptune-all' . ($this->iaCore->get('sap_style', false) ? '-' . $this->iaCore->get('sap_style') : '') . ', js:extjs/ext-all', 'manage_mode' => 'css:_IA_URL_js/visual/css/visual, js:visual/js/slidebars.min, js:visual/js/jqueryui.min, js:visual/js/visual', 'tree' => 'js:jquery/plugins/jstree/jstree.min, js:intelli/intelli.tree, css:_IA_URL_js/jquery/plugins/jstree/themes/default/style', 'jcal' => 'js:jquery/plugins/jcal/jquery.jcal, css:_IA_URL_js/jquery/plugins/jcal/jquery.jcal', 'bootstrap' => 'js:bootstrap/js/bootstrap.min, css:iabootstrap, css:iabootstrap-responsive, css:user-style', 'datepicker' => 'js:bootstrap/js/datepicker/bootstrap-datepicker, js:bootstrap/js/datepicker/locales/bootstrap-datepicker.' . $this->iaCore->get('lang') . ', css:_IA_URL_js/bootstrap/css/datepicker' . (iaCore::ACCESS_ADMIN == $this->iaCore->getAccessType() ? '3' : ''), 'tagsinput' => 'js:jquery/plugins/tagsinput/jquery.tagsinput.min, css:_IA_URL_js/jquery/plugins/tagsinput/jquery.tagsinput', 'underscore' => 'js:utils/underscore.min', 'iadropdown' => 'js:jquery/plugins/jquery.ia-dropdown.min', 'flexslider' => 'js:jquery/plugins/flexslider/jquery.flexslider.min, css:_IA_URL_js/jquery/plugins/flexslider/flexslider'); $this->iaCore->startHook('phpSmartyAfterMediaInit', array('iaSmarty' => &$this)); }
function smarty_function_ia_hooker($params, &$smarty) { if (!isset($params['name'])) { return; } $name = $params['name']; iaDebug::debug('smarty', $name, 'hooks'); iaSystem::renderTime('smarty', $name); $iaCore = iaCore::instance(); $hooks = $iaCore->getHooks(); if (!array_key_exists($name, $hooks) || empty($hooks[$name])) { return; } foreach ($hooks[$name] as $hook) { $hook['type'] = in_array($hook['type'], array('php', 'html', 'plain', 'smarty')) ? $hook['type'] : 'php'; if (empty($hook['pages']) || in_array($iaCore->iaView->name(), $hook['pages'])) { if ($hook['filename']) { switch ($hook['type']) { case 'php': if (file_exists(IA_HOME . $hook['filename'])) { include IA_HOME . $hook['filename']; } break; case 'smarty': echo $smarty->fetch(IA_HOME . $hook['filename']); } } else { switch ($hook['type']) { case 'php': eval($hook['code']); break; case 'smarty': echo $smarty->fetch('eval:' . $hook['code']); break; case 'html': echo $hook['code']; break; case 'plain': echo iaSanitize::html($hook['code']); } } } } }
public function write($actionCode, $params = null, $pluginName = null) { if (!in_array($actionCode, $this->_validActions)) { return false; } if (iaUsers::hasIdentity()) { $params['user'] = iaUsers::getIdentity()->fullname; } empty($params['title']) || ($params['title'] = iaSanitize::html($params['title'])); $row = array('date' => date(iaDb::DATETIME_FORMAT), 'action' => $actionCode, 'user_id' => iaUsers::hasIdentity() ? iaUsers::getIdentity()->id : null, 'params' => serialize($params)); if ($pluginName) { $row['extras'] = $pluginName; } else { $iaView =& iaCore::instance()->iaView; if ($value = $iaView->get('extras')) { $row['extras'] = $value; } } return (bool) $this->iaDb->insert($row, null, self::getTable()); }
/** * Smarty plugin * @package Smarty * @subpackage plugins */ function smarty_function_ia_print_img($params, &$smarty) { $out = IA_CLEAR_URL; $folder = isset($params['folder']) ? $params['folder'] : ''; if (isset($params['ups']) && !empty($params['ups'])) { $out .= 'uploads/' . $folder . $params['fl']; } elseif (isset($params['pl']) && !empty($params['pl'])) { $admin = isset($params['admin']) && $params['admin'] ? 'admin/' : 'front/'; $out .= 'plugins/' . $params['pl'] . '/' . $admin . 'templates/img/' . $folder . $params['fl']; } elseif (isset($params['package']) && $params['package']) { $iaCore = iaCore::instance(); $packages = $iaCore->packagesData; $template = $iaCore->iaView->theme; $admin = isset($params['admin']) && $params['admin']; $design = $admin ? 'admin/' : $template . '/'; if (isset($packages[$params['package']])) { $out = $packages[$params['package']]['tpl_url'] . $design . 'images/' . $folder . $params['fl']; } else { $out = ($admin ? 'admin/' : '') . 'templates/' . $template . '/img/' . $folder . $params['fl']; } } else { $admin = isset($params['admin']) && $params['admin'] ? 'admin/templates/' : ''; if ($admin) { $out .= $admin . 'default/img/' . $folder . $params['fl']; } else { $out .= 'templates/' . $smarty->tmpl . '/img/' . $folder . $params['fl']; } } // prints including image tag if (isset($params['full'])) { $attrs = array('id', 'title', 'width', 'height', 'border', 'style', 'class', 'alt'); $params['alt'] = isset($params['alt']) ? $params['alt'] : ''; $atrs = ''; foreach ($params as $key => $attr) { $atrs .= in_array($key, $attrs) && isset($attr) ? $key . '="' . $attr . '" ' : ''; } $out = '<img src="' . $out . '" ' . $atrs . '/>'; } echo $out; }
public static function setDebugMode() { if ($debuggerPassword = iaCore::instance()->get('debug_pass')) { if (isset($_GET['debugger']) && $debuggerPassword == $_GET['debugger']) { $_SESSION['debugger'] = $_GET['debugger']; } if (isset($_SESSION['debugger']) && $debuggerPassword == $_SESSION['debugger']) { define('INTELLI_QDEBUG', true); } } defined('INTELLI_QDEBUG') || define('INTELLI_QDEBUG', false); }
if (!in_array($chunks[1], array('co', 'com', 'net', 'org', 'gov', 'ltd', 'ac', 'edu'))) { $domain = implode('.', array($chunks[1], $chunks[0])); if ($chunks[2] != 'www') { $domain = implode('.', array($chunks[2], $chunks[1], $chunks[0])); } } } $domain = '.' . $domain; } ini_set('session.gc_maxlifetime', 1800); // 30 minutes //session_set_cookie_params(1800, '/', $domain, false, true); session_name('INTELLI_' . substr(md5(IA_HOME), 0, 10)); session_start(); setcookie(session_name(), session_id(), time() + 1800); require_once IA_CLASSES . 'ia.system.php'; require_once IA_INCLUDES . 'function.php'; if (function_exists('spl_autoload_register')) { spl_autoload_register(array('iaSystem', 'autoload')); } iaSystem::renderTime('start'); if (INTELLI_DEBUG) { register_shutdown_function(array('iaSystem', 'shutdown')); ob_start(array('iaSystem', 'output')); } else { error_reporting(0); } set_error_handler(array('iaSystem', 'error')); iaSystem::renderTime('Core started'); iaCore::instance()->init();
protected function _debugHooks() { $output = ''; $i = 0; $total = 0; $listLoaded = iaCore::instance()->getHooks(); $listUnused = $listLoaded; // needs to be pre-populated foreach (self::$_data['hooks'] as $name => $type) { $i++; if (isset($listLoaded[$name])) { unset($listUnused[$name]); $hooksContent = array(); $j = 0; foreach ($listLoaded[$name] as $pluginName => $hookData) { $j++; $pluginName = empty($pluginName) ? 'core' : $pluginName; $hooksContent['hooks'][$j]['header'] = '<div style="margin: 10px 0 5px 0;"><b>Type:</b> ' . $hookData['type'] . '<b style="margin-left: 30px;">Extension:</b> ' . $pluginName . '</div>'; $hooksContent['hooks'][$j]['type'] = $hookData['type']; $hooksContent['hooks'][$j]['filename'] = $hookData['filename']; $hooksContent['hooks'][$j]['code'] = iaSanitize::html($hookData['code'], 0, 100); } $name = '<span style="color: green;">(' . count($listLoaded[$name]) . ')</span> ' . $name; ob_start(); self::dump($hooksContent, $name, true); $cellContent = ob_get_clean(); } else { $cellContent = '<b>' . $name . '</b>'; } $type = is_array($type) ? $type[0] : $type; $output .= '<tr><td class="iterator">' . $i . '</td><td width="60"><i>' . $type . '</i></td><td>' . $cellContent . '</td></tr>'; } foreach ($listLoaded as $hooks) { $total += count($hooks); } empty($listUnused) || self::dump($listUnused, 'Hooks loaded, but weren\'t executed'); echo '<h4>Hooks List</h4><table>' . $output . '</table>'; return "[{$total}/{$i}]"; }
/** * Checks if captcha is correct * * @return bool */ public static function isCaptchaValid() { $iaCore = iaCore::instance(); $result = true; if ($iaCore->get('captcha', false)) { if ($pluginName = $iaCore->get('captcha_name')) { $iaCaptcha = $iaCore->factoryPlugin($pluginName, iaCore::FRONT, 'captcha'); $result = (bool) $iaCaptcha->validate(); } } return $result; }
if (!$iaExtrasInstaller->getNotes()) { $result = $iaExtrasInstaller->install(); } } } } } $template = iaHelper::getPost('tmpl', $template); } $iaOutput->errorList = $errorList; $iaOutput->template = $template; $iaOutput->templates = $templates; break; case 'download': if (class_exists('iaCore')) { iaCore::instance()->iaView->set('nodebug', true); } header('Content-Type: text/x-delimtext; name="config.inc.php"'); header('Content-disposition: attachment; filename="config.inc.php"'); echo get_magic_quotes_gpc() ? stripslashes($_POST['config_content']) : $_POST['config_content']; exit; case 'plugins': if (iaHelper::isAjaxRequest()) { if (isset($_POST['plugin']) && $_POST['plugin']) { echo iaHelper::installRemotePlugin($_POST['plugin']) ? 'installed successfully' : 'installation is not performed'; exit; } } else { if ($plugins = iaHelper::getRemotePluginsList(IA_VERSION)) { $iaOutput->plugins = $plugins; } else {
public static function errorPage($errorCode, $message = null) { if (!in_array($errorCode, array(self::ERROR_UNAUTHORIZED, self::ERROR_FORBIDDEN, self::ERROR_NOT_FOUND, self::ERROR_INTERNAL)) && is_null($message)) { $message = $errorCode; $errorCode = self::ERROR_FORBIDDEN; } elseif (is_null($message)) { $message = iaLanguage::get((string) $errorCode, $errorCode); } $iaCore = iaCore::instance(); $iaView =& $iaCore->iaView; $iaView->name(self::PAGE_ERROR); $iaView->_setParams(array('caption' => iaLanguage::get('error', 'Error page') . ' ' . $errorCode, 'filename' => null, 'name' => self::PAGE_ERROR, 'parent' => '', 'title' => $errorCode, 'group' => 0)); switch ($iaView->getRequestType()) { case self::REQUEST_JSON: $iaView->assign(array('error' => true, 'message' => $message, 'code' => $errorCode)); break; case self::REQUEST_HTML: // http://dev.subrion.com/issues/842 // some Apache servers stop with Authorization Required error // because of enabled DEFLATE directives in the .htaccess file // below is the workaround if (self::ERROR_UNAUTHORIZED != $errorCode && iaCore::ACCESS_ADMIN != $iaCore->getAccessType()) { header('HTTP/1.0 ' . $errorCode); } $iaView->setMessages($message); $iaView->assign('code', $errorCode); $body = self::PAGE_ERROR; $positions =& $iaView->blocks; unset($positions['left'], $positions['right'], $positions['top'], $positions['bottom'], $positions['user1'], $positions['user2']); $iaAcl = $iaCore->factory('acl'); if (iaCore::ACCESS_ADMIN == $iaCore->getAccessType() && ($errorCode == self::ERROR_FORBIDDEN && !$iaAcl->isAdmin() || !iaUsers::hasIdentity())) { $iaView->disableLayout(); if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], 'install') === false && !isset($_SESSION['IA_EXIT'])) { $iaView->title(iaLanguage::get('access_denied')); } else { $iaView->title(iaLanguage::get('login')); if (isset($_SESSION['IA_EXIT'])) { unset($_SESSION['IA_EXIT']); } } $body = 'login'; } elseif (iaCore::ACCESS_FRONT == $iaView->iaCore->getAccessType() && $errorCode == self::ERROR_UNAUTHORIZED && !iaUsers::hasIdentity()) { $body = 'login'; } $iaView->display($body); } return true; }
public static function redirect($title, $message, $url = null, $isAjax = false) { $url = $url ? $url : IA_URL; $message = is_array($message) ? implode('<br>', $message) : $message; unset($_SESSION['redir']); $_SESSION['redir'] = array('caption' => $title, 'msg' => $message, 'url' => $url); if (!$isAjax) { $redirectUrl = IA_URL . 'redirect/'; if (iaCore::instance()->get('redirect_time', 4000) == 0) { $redirectUrl = $url; } header('Location: ' . $redirectUrl); exit; } }
public static function ia_print_title($params) { $suffix = iaCore::instance()->get('suffix'); $title = empty($params['title']) ? iaCore::instance()->iaView->get('title') : $params['title']; return $title . ' ' . $suffix; }
public static function delete($key) { $iaDb = iaCore::instance()->iaDb; return (bool) $iaDb->delete(iaDb::convertIds($key, 'key'), self::getTable()); }
protected function _checkDependencies() { if ($this->itemData['dependencies']) { $iaCore = iaCore::instance(); $currentTemplate = $iaCore->get('tmpl'); $iaItem = $iaCore->factory('item'); foreach ($this->itemData['dependencies'] as $extrasName => $dependency) { $shouldBeExist = (bool) $dependency['exist']; switch ($dependency['type']) { case self::DEPENDENCY_TYPE_PACKAGE: case self::DEPENDENCY_TYPE_PLUGIN: $exists = $iaItem->isExtrasExist($extrasName, $dependency['type']); break; case self::DEPENDENCY_TYPE_TEMPLATE: $exists = $extrasName == $currentTemplate; break; } if (isset($exists)) { if (!$exists && $shouldBeExist) { $messageCode = 'installation_extra_requirement_exist'; } elseif ($exists && !$shouldBeExist) { $messageCode = 'installation_extra_requirement_doesnot_exist'; } if (isset($messageCode)) { $this->_notes[] = iaDb::printf(iaLanguage::get($messageCode), array('extra' => ucfirst($extrasName), 'type' => $dependency['type'])); $this->error = true; } } else { $this->setMessage(iaLanguage::get('installation_extra_requirement_incorrect')); } } } }
/** * Sets elements of array according to provided fields structure * * @param array $itemData resulting array * @param array $fields standard fields structure returned by methods of this class * @param array $extraValues values that will be merged to $itemData * @param array $data source data (POST values are used if nothing specified) * * @return void */ public static function keepValues(array &$itemData, array $fields, array $extraValues = array(), $data = null) { if (is_null($data)) { $data = $_POST; } if (empty($data)) { return; } foreach ($fields as $field) { if ($field['type'] != self::PICTURES && $field['type'] != self::IMAGE) { $fieldName = $field['name']; if (isset($data[$fieldName]) && $data[$fieldName]) { $itemData[$fieldName] = in_array($field['type'], array(self::CHECKBOX)) ? implode(',', $data[$fieldName]) : $data[$fieldName]; } } } if (iaCore::ACCESS_ADMIN == iaCore::instance()->getAccessType()) { if (isset($data['featured'])) { $itemData['featured'] = $data['featured']; $itemData['featured_end'] = date(iaDb::DATETIME_SHORT_FORMAT, strtotime($data['featured_end'])); } if (isset($data['sponsored'])) { $itemData['sponsored'] = $data['sponsored']; if (isset($data['sponsored_end'])) { $itemData['sponsored_end'] = date(iaDb::DATETIME_SHORT_FORMAT, strtotime($data['sponsored_end'])); } } empty($data['date_added']) || ($itemData['date_added'] = iaSanitize::html($data['date_added'])); empty($data['status']) || ($itemData['status'] = iaSanitize::html($data['status'])); empty($data['owner']) || ($itemData['owner'] = iaSanitize::html($data['owner'])); } if ($extraValues) { $itemData = array_merge($itemData, $extraValues); } }
protected function _runPhpCode($phpCode) { if (@eval('return true;' . $phpCode)) { $iaCore = iaCore::instance(); eval($phpCode); } }
protected static function _getInstalledPluginsList() { self::loadCoreClass('db', 'core'); $iaDb = iaCore::instance()->iaDb; $list = $iaDb->onefield('name', "type = 'plugin'", 0, null, 'extras'); return empty($list) ? array() : $list; }
/** * @return array */ protected function _searchByBlocks() { $iaCore =& $this->iaCore; $iaDb =& $this->iaDb; $sql = 'SELECT ' . 'b.`name`, b.`external`, b.`filename`, b.`title`, ' . 'b.`extras`, b.`sticky`, b.`contents`, b.`type`, b.`header`, ' . 'o.`page_name` `page` ' . 'FROM `:prefix:table_blocks` b ' . "LEFT JOIN `:prefix:table_objects` o ON (o.`object` = b.`id` AND o.`object_type` = 'blocks' AND o.`access` = 1) " . "WHERE b.`type` IN('plain','smarty','html') " . "AND b.`status` = ':status' " . "AND b.`extras` IN (':extras') " . "AND (CONCAT(b.`contents`,IF(b.`header` = 1, b.`title`, '')) LIKE ':query' OR b.`external` = 1) " . 'AND o.`page_name` IS NOT NULL ' . 'GROUP BY b.`id`'; $sql = iaDb::printf($sql, array('prefix' => $iaDb->prefix, 'table_blocks' => 'blocks', 'table_objects' => 'objects_pages', 'status' => iaCore::STATUS_ACTIVE, 'query' => '%' . iaSanitize::sql($this->_query) . '%', 'extras' => implode("','", $iaCore->get('extras')))); $blocks = array(); if ($rows = $iaDb->getAll($sql)) { $extras = $iaDb->keyvalue(array('name', 'type'), iaDb::convertIds(iaCore::STATUS_ACTIVE, 'status'), 'extras'); foreach ($rows as $row) { $pageName = empty($row['page']) ? $iaCore->get('home_page') : $row['page']; if (empty($pageName)) { continue; } if ($row['external']) { switch ($extras[$row['extras']]) { case 'package': case 'plugin': $fileName = explode(':', $row['filename']); array_shift($fileName); $fileName = explode('/', $fileName[0]); array_shift($fileName); $fileName = $fileName[0] . iaView::TEMPLATE_FILENAME_EXT; $type = $extras[$row['extras']] . 's'; $tpl = IA_HOME . sprintf('templates/%s/%s/%s/%s', iaCore::instance()->get('tmpl'), $type, $row['extras'], $fileName); is_file($tpl) || ($tpl = IA_HOME . sprintf('%s/%s/templates/%s/%s', $type, $row['extras'], 'plugins' == $type ? 'front' : 'common', $fileName)); break; default: $tpl = IA_HOME . 'templates/' . $row['extras'] . IA_DS; } $content = @file_get_contents($tpl); if (false === $content) { continue; } $content = self::_stripSmartyTags(iaSanitize::tags($content)); if (false === stripos($content, $this->_query)) { continue; } } else { switch ($row['type']) { case 'smarty': $content = self::_stripSmartyTags(iaSanitize::tags($row['contents'])); break; case 'html': $content = iaSanitize::tags($row['contents']); break; default: $content = $row['contents']; } } isset($blocks[$pageName]) || ($blocks[$pageName] = array()); $blocks[$pageName][] = array('title' => $row['header'] ? $row['title'] : null, 'content' => $this->_extractSnippet($content)); } } return $blocks; }
break; case 'backup': require_once IA_INSTALL . 'classes/ia.backup.php'; $iaBackup = new iaBackup(); if (iaHelper::isAjaxRequest()) { iaHelper::loadCoreClass('view', 'core')->set('nodebug', true); echo $iaBackup->save() ? 'success' : array_shift($iaBackup->messages); exit; } else { $iaOutput->backupFile = str_replace(IA_HOME, '', $iaBackup->filePath); } break; case 'finish': require_once IA_INSTALL . 'classes/ia.patch.parser.php'; require_once IA_INSTALL . 'classes/ia.patch.applier.php'; $iaOutput->adminPath = iaCore::instance()->iaDb->one_bind('value', '`name` = :name', array('name' => 'admin_page'), iaCore::getConfigTable()); $options = isset($_GET['options']) && is_array($_GET['options']) ? $_GET['options'] : array(); try { $patchFileContent = @file_get_contents(IA_HOME . 'tmp' . IA_DS . 'patch.iap'); if (false === $patchFileContent) { throw new Exception('Could not get downloaded patch file. Please download it again.'); } $patchParser = new iaPatchParser($patchFileContent); $patch = $patchParser->patch; if ($patch['info']['version_from'] != str_replace('.', '', IA_VERSION)) { throw new Exception('Patch is not applicable to your version of Subrion CMS.'); } $patchApplier = new iaPatchApplier(IA_HOME, array('host' => INTELLI_DBHOST . ':' . INTELLI_DBPORT, 'database' => INTELLI_DBNAME, 'user' => INTELLI_DBUSER, 'password' => INTELLI_DBPASS, 'prefix' => INTELLI_DBPREFIX), in_array('force-mode', $options)); $patchApplier->process($patch, $_SESSION['upgrade_to']); $textLog = $patchApplier->getLog(); $logFile = 'upgrade-log-' . $patch['info']['version_to'] . '_' . date('d-m-y-Hi') . '.txt';
public function __construct() { $this->iaCore = iaCore::instance(); $this->prefix = INTELLI_DBPREFIX; $this->_connect(); }