Subrion - open source content management system Copyright (C) 2016 Intelliants, LLC This file is part of Subrion. Subrion is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Subrion is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Subrion. If not, see .
Esempio n. 1
0
 public static function instance()
 {
     if (is_null(self::$_instance)) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Esempio n. 2
0
 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')));
 }
Esempio n. 3
0
 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;
 }
Esempio n. 4
0
 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;
 }
Esempio n. 5
0
 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;
 }
 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;
}
Esempio n. 9
0
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;
}
Esempio n. 10
0
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;
}
Esempio n. 11
0
 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));
 }
Esempio n. 12
0
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']);
                }
            }
        }
    }
}
Esempio n. 13
0
 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());
 }
 public function url($action, $data = array(), $generate = false)
 {
     $data['action'] = $action;
     $data['alias'] = isset($data['genre_alias']) ? $data['genre_alias'] : $data['title_alias'];
     if (!isset($this->patterns[$action])) {
         $action = 'view';
     }
     if ($generate) {
         iaCore::util();
         if (!defined('IA_NOUTF')) {
             iaUtf8::loadUTF8Core();
             iaUtf8::loadUTF8Util('ascii', 'validation', 'bad', 'utf8_to_ascii');
         }
         if (!utf8_is_ascii($data['alias'])) {
             $data['alias'] = $iaCore->convertStr(utf8_to_ascii($data['alias']));
         }
     }
     $url = iaDb::printf($this->patterns[$action], $data);
     return $this->iaCore->packagesData[self::PACKAGE_NAME]['url'] . $url;
 }
Esempio n. 15
0
/**
 * 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;
}
<?php

//##copyright##
define('INTELLI_REALM', 'recipecat_view');
if (isset($vals[0])) {
    $recipecat_alias = $vals[0];
    // TODO: perform param validation
}
$iaRecipecat = $iaCore->factoryPackages(IA_CURRENT_PACKAGE, 'front', 'recipecat');
$recipecat = isset($recipecat_alias) ? $iaRecipecat->getRecipecatByAlias($recipecat_alias) : false;
if (empty($recipecat)) {
    iaCore::errorPage('404');
}
$iaCore->startHook('phpViewRecipecatBeforeStart', array('listing' => $recipecat['id'], 'item' => 'recipecats'));
$recipecat['@view'] = true;
// get sections
$sections = $iaCore->getAcoGroupsFields(false, false, "`f`.`type`<>'pictures'", $recipecat);
$pictures_sections = $iaCore->getAcoGroupsFields(false, false, "`f`.`type`='pictures'", $recipecat);
if ($pictures_sections) {
    foreach ($pictures_sections as $onesection) {
        if (isset($onesection['fields']) && !empty($onesection['fields']) && is_array($onesection['fields'])) {
            foreach ($onesection['fields'] as $onefield) {
                if (isset($recipecat[$onefield['name']]) && !empty($recipecat[$onefield['name']])) {
                    $iaCore->assign_by_ref('pictures_sections', $pictures_sections);
                    break 2;
                }
            }
        }
    }
}
$recipecat['item'] = 'recipecats';
Esempio n. 17
0
 protected function _createJsFile($file, $type = 'config')
 {
     $this->iaCore->factory('util');
     // required in order the class iaUtil to be loaded
     $iaDb =& $this->iaCore->iaDb;
     switch ($type) {
         case 'lang':
         case 'admin_lang':
             // get phrases
             $stmt = "`code` = :lang AND `category` NOT IN ('tooltip', 'page', :category)";
             $iaDb->bind($stmt, array('lang' => $this->iaCore->iaView->language, 'category' => $type == 'admin_lang' ? 'frontend' : iaCore::ADMIN));
             $phrases = $iaDb->keyvalue(array('key', 'value'), $stmt, iaLanguage::getTable());
             // get list of languages
             $languagesList = $iaDb->assoc(array('code', 'title', 'direction', 'flagicon', 'iso' => 'code'), 'admin_lang' == $type ? null : "`status` = 'active'", 'languages');
             $fileContent = 'intelli.' . ('admin_lang' == $type ? 'admin.' : '') . 'lang = ' . iaUtil::jsonEncode($phrases) . ';' . 'intelli.languages = ' . iaUtil::jsonEncode($languagesList) . ';';
             break;
         case 'config':
             $stmt = "`private` = 0 && `type` != 'divider' && `config_group` != 'email_templates'";
             $config = $iaDb->keyvalue(array('name', 'value'), $stmt, iaCore::getConfigTable());
             if (file_exists(IA_INCLUDES . 'custom.inc.php')) {
                 include IA_INCLUDES . 'custom.inc.php';
             }
             $config['ia_url'] = IA_CLEAR_URL;
             $config['packages'] = $this->iaCore->setPackagesData();
             $config['items'] = array();
             $config['extras'] = array(array('core', iaLanguage::get('core', 'Core')));
             $array = $iaDb->all(array('name', 'title'), "`status` = 'active' ORDER BY `type`", null, null, 'extras');
             foreach ($array as $item) {
                 $config['extras'][] = array($item['name'], $item['title']);
             }
             $array = $iaDb->onefield('`item`', "`item` != 'transactions'", null, null, 'items');
             foreach ($array as $item) {
                 $config['items'][] = array($item, iaLanguage::get($item, $item));
             }
             $fileContent = 'intelli.config = ' . iaUtil::jsonEncode($config) . ';';
     }
     if (isset($fileContent)) {
         if ($fh = fopen($file, 'w')) {
             fwrite($fh, $fileContent);
             fclose($fh);
         }
     }
 }
Esempio n. 18
0
 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;
 }
Esempio n. 19
0
 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;
     }
 }
Esempio n. 20
0
                         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 {
Esempio n. 21
0
 case 'add':
     iaBreadcrumb::add(iaLanguage::get('albums'), IA_ADMIN_URL . 'lyrics/albums/');
     // these fields are system and used in system template
     $item = array('status' => 'active', 'account_username' => $_SESSION['user']['username'], 'featured' => true);
     if ('edit' == $pageAction) {
         $item = $iaAlbum->getById((int) $_GET['id']);
         if (empty($item)) {
             iaView::errorPage(iaView::ERROR_NOT_FOUND);
         }
     }
     $fields = iaField::getAllFields(true, '', 'albums');
     if (isset($_POST['save'])) {
         $error = false;
         $errorFields = array();
         $messages = array();
         iaCore::util();
         if ($fields) {
             list($data, $error, $messages, $errorFields) = iaField::parsePost($fields, $item, true);
         }
         // validate account
         if (isset($_POST['account']) && !empty($_POST['account'])) {
             $member_id = $iaDb->one('id', "`username` = '{$_POST['account']}' ", iaUsers::getTable());
             if (!$member_id) {
                 $error = true;
                 $messages[] = iaLanguage::get('album_incorrect_account');
             } else {
                 $data['member_id'] = $member_id;
             }
         } else {
             $data['member_id'] = iaUsers::getIdentity()->id;
         }
Esempio n. 22
0
 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;
 }
Esempio n. 23
0
 private function _getParams($groupName)
 {
     $where = "`config_group` = '{$groupName}' AND `type` != 'hidden' " . ($this->_type ? 'AND `custom` = 1' : '') . ' ORDER BY `order`';
     $params = $this->_iaDb->all(iaDb::ALL_COLUMNS_SELECTION, $where, null, null, iaCore::getConfigTable());
     if ($this->_type) {
         $custom = 'user' == $this->_type ? $this->_iaCore->getCustomConfig($this->_typeId) : $this->_iaCore->getCustomConfig(null, $this->_typeId);
         $custom2 = 'user' == $this->_type ? $this->_getUsersSpecificConfig() : array();
     }
     $iaItem = $this->_iaCore->factory('item');
     $itemsList = $iaItem->getItems();
     foreach ($params as &$entry) {
         $className = 'default';
         if ($this->_type) {
             $className = 'custom';
             if (self::TYPE_DIVIDER != $entry['type']) {
                 if (isset($custom2[$entry['name']])) {
                     $entry['default'] = $custom2[$entry['name']];
                     $entry['value'] = $custom2[$entry['name']];
                 } else {
                     $entry['default'] = $this->_iaCore->get($entry['name']);
                 }
                 if (isset($custom[$entry['name']])) {
                     $className = 'common';
                     $entry['value'] = $custom[$entry['name']];
                 }
             }
         }
         if ('itemscheckbox' == $entry['type']) {
             $array = $this->_iaCore->get($entry['extras'] . '_items_implemented');
             $array = $array ? explode(',', $array) : array();
             $array = array_values(array_intersect($array, $itemsList));
             if ($array) {
                 $enabledItems = $iaItem->getEnabledItemsForPlugin($entry['extras']);
                 for ($i = 0; $i < count($array); $i++) {
                     $array[$i] = trim($array[$i]);
                     $entry['items'][] = array('name' => $array[$i], 'title' => iaLanguage::get($array[$i]), 'checked' => (int) in_array($array[$i], $enabledItems));
                 }
             }
         }
         if (self::TYPE_SELECT == $entry['type']) {
             switch ($entry['name']) {
                 case 'timezone':
                     $entry['values'] = iaUtil::getFormattedTimezones();
                     break;
                 case 'lang':
                     $entry['values'] = $this->_iaCore->languages;
                     break;
                 default:
                     $entry['values'] = explode(',', $entry['multiple_values']);
             }
         }
         $entry['class'] = $className;
     }
     return $params;
 }
Esempio n. 24
0
 /**
  * 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);
     }
 }
Esempio n. 25
0
 private function _processCategory(array $entryData, $action = self::ACTION_INSTALL)
 {
     switch ($entryData['category']) {
         case 'payments':
             $iaTransaction = $this->iaCore->factory('transaction');
             if (self::ACTION_INSTALL == $action) {
                 $entry = array('name' => $entryData['name'], 'title' => $entryData['title']);
                 $this->iaDb->insert($entry, null, $iaTransaction->getTableGateways());
             } elseif (self::ACTION_UNINSTALL == $action) {
                 $this->iaDb->delete('`name` = :name', $iaTransaction->getTableGateways(), $entryData);
             }
             break;
         case 'lightbox':
         case 'captchas':
             $configName = 'lightbox' == $entryData['category'] ? 'lightbox_name' : 'captcha_name';
             $stmt = iaDb::convertIds($configName, 'name');
             $this->iaDb->setTable(iaCore::getConfigTable());
             if (self::ACTION_INSTALL == $action) {
                 if ($currentValues = $this->iaDb->one('`multiple_values`', $stmt)) {
                     $values = explode(',', $currentValues);
                 }
                 $values[] = $entryData['name'];
                 $this->iaDb->update(array('multiple_values' => implode(',', $values)), $stmt);
                 if (1 == count($values)) {
                     $this->iaCore->set($configName, $entryData['name'], true);
                 }
             } elseif (self::ACTION_UNINSTALL == $action) {
                 // get possible values
                 if ($values = explode(',', $this->iaDb->one('`multiple_values`', $stmt))) {
                     $installed = array_diff($values, array($entryData['name']));
                     $this->iaDb->update(array('multiple_values' => implode(',', $installed)), $stmt);
                     if ($this->iaCore->get($configName) == $entryData['name']) {
                         $value = empty($installed) ? '' : array_shift($installed);
                         if (in_array($entryData['name'], $this->_builtinPlugins)) {
                             $value = $entryData['name'];
                         }
                         $this->iaCore->set($configName, $value, true);
                     }
                 }
             }
             $this->iaDb->resetTable();
             break;
     }
 }
Esempio n. 26
0
 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}]";
 }
Esempio n. 27
0
        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();
Esempio n. 28
0
 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;
 }
Esempio n. 29
0
 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);
 }
Esempio n. 30
0
 protected function _runPhpCode($phpCode)
 {
     if (@eval('return true;' . $phpCode)) {
         $iaCore = iaCore::instance();
         eval($phpCode);
     }
 }