function _t($key = '', $default = null) { if (!class_exists('iaLanguage') || empty($key)) { return false; } iaDebug::debug($key, 'Deprecated language phrase obtaining'); return iaLanguage::get($key, $default); }
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 static function get($key, $default = null) { if (empty($key)) { return false; } if (self::exists($key)) { return self::$_phrases[$key]; } else { if (INTELLI_DEBUG && is_null($default)) { $iaCore = iaCore::instance(); $cache = $iaCore->iaCache->get('nonexistent_phrases', 0, true); if (empty($cache)) { $cache = array(); } if (!in_array($key, $cache)) { $cache[] = $key; $iaCore->iaCache->write('nonexistent_phrases', serialize($cache)); } iaDebug::debug($key, 'Phrases do not exist', 'error'); } return is_null($default) ? '{' . $key . '}' : $default; } }
public static function error($errno = 0, $errstr = '', $errfile = '', $errline = 0) { $exit = false; $errfile = str_replace(IA_HOME, '', $errfile); $errortype = array(0 => 'Parsing Error', E_ERROR => 'Fatal Error', 2048 => 'Error', E_WARNING => 'Warning', E_PARSE => 'Parsing Error', E_NOTICE => 'Notice', E_CORE_ERROR => 'Core Error', E_CORE_WARNING => 'Core Warning', E_COMPILE_ERROR => 'Compile Error', E_COMPILE_WARNING => 'Compile Warning', E_USER_ERROR => 'User Error', E_USER_WARNING => 'User Warning', E_USER_NOTICE => 'User Notice'); $error = ' ' . $errstr . ' <i><br> ' . ($errline != 0 ? 'on line <b>' . $errline . '</b>' : '') . ' in file <span style="font-weight:bold; text-shadow: 1px 1px 1px white; text-decoration: underline;">' . $errfile . '</span></i>'; switch ($errno) { case 2048: $text = ''; break; case 0: case E_COMPILE_ERROR: case E_PARSE: case E_ERROR: case E_USER_ERROR: $text = '<span style="font-weight:bold;color:red;">' . $errortype[$errno] . ':</span> ' . $error . '<br>'; $exit = true; break; case E_WARNING: case E_USER_WARNING: $text = '<span class="e_warning">' . $errortype[$errno] . ':</span> ' . $error; break; case E_NOTICE: case E_USER_NOTICE: $text = '<span class="e_notice">' . $errortype[$errno] . ':</span> ' . $error; break; default: $text = (!isset($errortype[$errno]) ? 'Unknown error type [' . $errno . ']:' : $errortype[$errno]) . ' ' . $error; } $backTrace = debug_backtrace(); $traceList = array(); if ($errno == 0) { iaDebug::debug($backTrace, 'Backtrace<span style="display:none;">' . mt_rand(10000, 99999) . '</span>', 'error'); return $text; } else { if ($backTrace) { foreach ($backTrace as $v) { $file = ''; if (isset($v['line'])) { $file .= 'on line [' . $v['line'] . '] '; } if (isset($v['file'])) { $file .= 'in file [' . str_replace(IA_HOME, '', $v['file']) . '] '; } $trace = ''; if (isset($v['class'])) { $trace .= 'in class ' . $v['class'] . '::' . $v['function'] . '('; if (isset($v['args'])) { $separator = ''; foreach ($v['args'] as $argument) { $trace .= $separator . htmlspecialchars(self::_getArgument($argument)); $separator = ', '; } } $trace .= ')'; } elseif (isset($v['function'])) { $trace .= 'in function ' . $v['function'] . '('; if (isset($v['args'])) { $separator = ''; foreach ($v['args'] as $argument) { $trace .= $separator . htmlspecialchars(self::_getArgument($argument)); $separator = ', '; } } $trace .= ')'; } if ($file) { $trace = '<b style="color: #F00;">' . $trace . '</b><br><b>' . $file . '</b><hr>'; } $traceList[] = $trace; } unset($traceList[count($traceList) - 1]); $traceList = array_reverse($traceList); } } if ($text) { iaDebug::debug($text, null, 'error'); iaDebug::debug($traceList, 'Backtrace<span style="display:none;">' . mt_rand(10000, 99999) . '</span>', 'error'); iaDebug::debug('<div class="hr"> </div>', null, 'error'); } if ($exit) { exit('Aborting...'); } return true; }
public static function add_js(array $params) { $iaView =& iaCore::instance()->iaView; $order = isset($params['order']) ? $params['order'] : iaView::RESOURCE_ORDER_REGULAR; if (isset($params['files'])) { $iaCore = iaCore::instance(); $files = $params['files']; if (is_string($files)) { $files = explode(',', $files); } foreach ($files as $filename) { $filename = trim($filename); if (empty($filename)) { continue; } $compress = true; $remote = false; if (false !== stristr($filename, 'http://') || false !== stristr($filename, 'https://')) { $remote = true; $compress = false; $url = $filename; } elseif (strstr($filename, '_IA_TPL_')) { $url = str_replace('_IA_TPL_', IA_TPL_URL . 'js' . IA_URL_DELIMITER, $filename) . self::EXTENSION_JS; $file = str_replace('_IA_TPL_', IA_HOME . 'templates' . IA_DS . $iaCore->get('tmpl') . IA_DS . 'js' . IA_DS, $filename) . self::EXTENSION_JS; $tmp = str_replace('_IA_TPL_', 'compress/', $filename); } elseif (strstr($filename, '_IA_URL_')) { $url = str_replace('_IA_URL_', $iaView->assetsUrl, $filename) . self::EXTENSION_JS; $file = str_replace('_IA_URL_', IA_HOME, $filename) . self::EXTENSION_JS; $tmp = str_replace('_IA_URL_', 'compress/', $filename); } else { $url = $iaView->assetsUrl . 'js/' . $filename . self::EXTENSION_JS; $file = IA_HOME . 'js/' . $filename . self::EXTENSION_JS; $tmp = 'compress/' . $filename; } $lastModified = 0; if ($compress) { $excludedFiles = array('ckeditor/ckeditor', 'jquery/jquery', 'extjs/ext-all', '_IA_TPL_bootstrap.min'); // lang cache if (file_exists($file)) { $lastModified = filemtime($file); } if ($filename == '_IA_URL_tmp/cache/intelli.admin.lang.en') { $url = str_replace('_IA_URL_', $iaView->assetsUrl, $filename) . self::EXTENSION_JS; $file = str_replace('_IA_URL_', IA_HOME, $filename) . self::EXTENSION_JS; $tmp = str_replace('_IA_URL_', 'compress/', $filename); } // start compress if ($iaCore->get('compress_js', false) && !in_array($filename, $excludedFiles)) { $minifiedFilename = IA_TMP . $tmp . self::EXTENSION_JS; $minifiedLastModifiedTime = 0; // modified time of the compressed file if (file_exists($minifiedFilename)) { $minifiedLastModifiedTime = filemtime($minifiedFilename); } else { $compileDir = IA_TMP . implode(IA_DS, array_slice(explode(IA_DS, $tmp), 0, -1)); iaCore::util()->makeDirCascade($compileDir, 0777, true); } if (file_exists($file)) { $lastModified = filemtime($file); } if (($lastModified > $minifiedLastModifiedTime || $minifiedLastModifiedTime == 0) && $lastModified != 0) { // need to compress iaDebug::debug($minifiedFilename . ' - ' . $lastModified . ' - ' . $minifiedLastModifiedTime, 'compress', 'info'); require_once IA_INCLUDES . 'utils' . IA_DS . 'Minifier.php'; $minifiedCode = \JShrink\Minifier::minify(file_get_contents($file)); file_put_contents($minifiedFilename, $minifiedCode); $lastModified = time(); } $url = $iaView->assetsUrl . 'tmp/' . $tmp . self::EXTENSION_JS; } } if (!$remote && $lastModified > 0) { $url .= '?fm=' . $lastModified; } $iaView->resources->js->{$url} = $order; } } elseif (isset($params['code'])) { $iaView->resources->js->{'code:' . $params['code']} = $order; } elseif (isset($params['text'])) { $iaView->resources->js->{'text:' . $params['text']} = $order; } }
public function factoryPlugin($plugin, $type = self::FRONT, $name = null) { if (empty($name)) { $name = $plugin; } $class = self::CLASSNAME_PREFIX . ucfirst(strtolower($name)); if (!isset($this->_classInstances[$class])) { $fileSize = $this->loadClass($type, $name, $plugin); if (false === $fileSize) { return false; } iaDebug::debug('<b>plugin:</b> ia.' . $type . '.' . $name . ' (' . iaSystem::byteView($fileSize) . ')', 'Initialized Classes List', 'info'); $this->_classInstances[$class] = new $class(); $this->_classInstances[$class]->init(); } return $this->_classInstances[$class]; }
private function _checkForUpdates() { $url = sprintf(iaUtil::REMOTE_TOOLS_URL . 'get/updates/%s/', IA_VERSION); $content = iaUtil::getPageContent($url); if (!$content) { return; } $content = iaUtil::jsonDecode($content); if (is_array($content) && $content) { $messages = array(); foreach ($content as $entry) { switch ($entry['type']) { case self::UPDATE_TYPE_INFO: $messages[] = array($entry['id'], $entry['message']); break; case self::UPDATE_TYPE_PATCH: $version = explode('.', $entry['version']); if (count($version) > 3) { if ($this->_iaCore->get('auto_apply_critical_upgrades')) { $result = iaSystem::forceUpgrade($entry['version']); if (is_bool($result) && $result) { $this->_iaCore->factory('cache')->clearGlobalCache(); $message = iaLanguage::getf('script_upgraded', array('version' => $entry['version'])); $this->_iaCore->iaView->setMessages($message, iaView::SUCCESS); iaUtil::go_to(IA_SELF); } else { iaDebug::debug($result, 'Forced upgrade to the version ' . $entry['version']); } } } else { $url = sprintf('%sinstall/upgrade/check/%s/', IA_CLEAR_URL, $entry['version']); $this->_iaCore->iaView->setMessages(iaLanguage::getf('upgrade_available', array('url' => $url, 'version' => $entry['version'])), iaView::SYSTEM); } } } $this->_iaCore->iaView->assign('updatesInfo', $messages); } }
public function send($clearAddresses = true) { $this->_applyReplacements(); $result = (bool) parent::send(); if ($clearAddresses) { parent::clearAddresses(); } if (!$result) { iaDebug::debug($this->ErrorInfo, 'Email submission'); } return $result; }
protected function _indexPage(&$iaView) { $iaView->display('index'); $iaCore =& $this->_iaCore; $iaDb =& $this->_iaDb; if (isset($_GET['reset']) || isset($_GET['save'])) { $data = isset($_GET['list']) ? $_GET['list'] : ''; if ($iaDb->update(array('admin_columns' => $data), iaDb::convertIds(iaUsers::getIdentity()->id), null, iaUsers::getTable())) { iaUsers::reloadIdentity(); } $iaView->setMessages(iaLanguage::get('saved'), iaView::SUCCESS); iaUtil::go_to(IA_SELF); } $disabledWidgets = iaUsers::getIdentity()->admin_columns; $disabledWidgets = empty($disabledWidgets) ? array() : explode(',', trim($disabledWidgets, ',')); $iaView->assign('disabled_widgets', $disabledWidgets); $customizationMode = isset($_GET['customize']) && empty($_GET['customize']); if ($customizationMode) { $iaView->setMessages(iaLanguage::get('customization_mode_alert')); $iaView->assign('customization_mode', true); } // populate statistics $iaItem = $iaCore->factory('item'); $itemsList = $iaItem->getPackageItems(); $validSizes = array('small', 'medium', 'package'); $iaCore->startHook('adminDashboardStatistics', array('items' => &$itemsList)); natcasesort($itemsList); $statistics = array(); foreach ($validSizes as $size) { $statistics[$size] = array(); } foreach ($itemsList as $itemName => $pluginType) { $itemName = substr($itemName, 0, -1); switch ($pluginType) { case 'core': $classInstance = $iaCore->factory('member' == $itemName ? 'users' : $itemName); break; case 'plugin': $array = explode(':', $itemName); $itemName = isset($array[1]) ? $array[1] : $itemName; $classInstance = $iaCore->factoryPlugin($array[0], iaCore::ADMIN, isset($array[1]) ? $array[1] : null); break; default: $classInstance = $iaCore->factoryPackage($itemName, $pluginType, iaCore::ADMIN); } if (!$customizationMode && in_array($itemName, $disabledWidgets)) { continue; } if ($classInstance) { if (method_exists($classInstance, self::STATISTICS_GETTER_METHOD)) { if ($classInstance->dashboardStatistics) { $data = $classInstance->{self::STATISTICS_GETTER_METHOD}(); isset($data['icon']) || ($data['icon'] = $itemName); isset($data['caption']) || ($data['caption'] = $itemName); $data['caption'] = iaLanguage::get($data['caption'], $data['caption']); $widgetFormat = isset($data['_format']) && in_array($data['_format'], $validSizes) ? $data['_format'] : $validSizes[0]; $statistics[$widgetFormat][$itemName] = $data; } } } } $iaView->assign('statistics', $statistics); // if (($customizationMode || !in_array('changelog', $disabledWidgets)) && $iaCore->get('display_changelog') && is_file(IA_HOME . 'changelog.txt')) { $index = 0; $log = array(); $titles = array(); $lines = file(IA_HOME . 'changelog.txt'); foreach ($lines as $line_num => $line) { $line = trim($line); if ($line) { if ($line[0] == '>') { $index++; $log[$index] = array('title' => trim($line, '<> '), 'added' => '', 'modified' => '', 'bugfixes' => '', 'other' => ''); $titles[trim($line, '<> ')] = $index; } elseif ($index > 0) { switch ($line[0]) { case '+': $class = 'added'; break; case '-': $class = 'bugfixes'; break; case '*': $class = 'modified'; break; default: $class = 'other'; } $issue = preg_replace('/#(\\d+)/', '<a href="http://dev.subrion.org/issues/$1" target="_blank">#$1</a>', ltrim($line, '+-* ')); $log[$index][$class] .= '<li>' . $issue . '</li>'; } } } unset($log[0]); ksort($titles); $titles = array_reverse($titles); $iaView->assign('changelog_titles', $titles); $iaView->assign('changelog', $log); } // twitter widget if ($customizationMode || !in_array('twitter', $disabledWidgets)) { $data = iaUtil::getPageContent('http://tools.intelliants.com/timeline/'); $iaView->assign('timeline', iaUtil::jsonDecode($data)); } if ($customizationMode || !in_array('recent-activity', $disabledWidgets)) { $data = $iaCore->factory('log')->get(); $iaView->assign('activity_log', $data); } if ($customizationMode || !in_array('website-visits', $disabledWidgets)) { $data = $iaCore->factory('users')->getVisitorsInfo(); $iaView->assign('online_members', $data); } if ($iaCore->get('check_for_updates')) { if ($content = iaUtil::getPageContent(iaUtil::REMOTE_TOOLS_URL . 'get/patch/')) { $content = iaUtil::jsonDecode($content); if (is_array($content) && $content) { foreach ($content as $versionFrom => $versionTo) { if (version_compare($versionFrom, IA_VERSION) === 0 && version_compare($versionTo, IA_VERSION)) { $version = explode('.', $versionTo); if (count($version) > 3) { if ($iaCore->get('auto_apply_critical_upgrades')) { $result = iaSystem::forceUpgrade($versionTo); if (is_bool($result) && $result) { $iaCore->factory('cache')->clearGlobalCache(); $message = iaLanguage::getf('script_upgraded', array('version' => $versionTo)); $iaView->setMessages($message, iaView::SUCCESS); iaUtil::go_to(IA_SELF); } else { iaDebug::debug($result, 'Forced upgrade to the version ' . $versionTo); } } } else { $url = sprintf('%sinstall/upgrade/check/%s/', IA_CLEAR_URL, $versionTo); $iaView->setMessages(iaLanguage::getf('upgrade_available', array('url' => $url, 'version' => $versionTo)), iaView::SYSTEM); } } } } } } }