コード例 #1
0
ファイル: ia.admin.grid.php プロジェクト: kamilklkn/subrion
 public function gridRead($params, $columns, array $filterParams = array(), array $persistentConditions = array())
 {
     $params || ($params = array());
     $start = isset($params['start']) ? (int) $params['start'] : 0;
     $limit = isset($params['limit']) ? (int) $params['limit'] : 15;
     $sort = $params['sort'];
     $dir = in_array($params['dir'], array(iaDb::ORDER_ASC, iaDb::ORDER_DESC)) ? $params['dir'] : iaDb::ORDER_ASC;
     $order = $sort && $dir ? " ORDER BY `{$sort}` {$dir}" : '';
     $where = $values = array();
     foreach ($filterParams as $name => $type) {
         if (isset($params[$name]) && $params[$name]) {
             $value = iaSanitize::sql($params[$name]);
             switch ($type) {
                 case 'equal':
                     $where[] = sprintf('`%s` = :%s', $name, $name);
                     $values[$name] = $value;
                     break;
                 case 'like':
                     $where[] = sprintf('`%s` LIKE :%s', $name, $name);
                     $values[$name] = '%' . $value . '%';
             }
         }
     }
     $where = array_merge($where, $persistentConditions);
     $where || ($where[] = iaDb::EMPTY_CONDITION);
     $where = implode(' AND ', $where);
     $this->_iaDb->bind($where, $values);
     if (is_array($columns)) {
         $columns = array_merge(array('id', 'update' => 1, 'delete' => 1), $columns);
     }
     return array('data' => $this->_iaDb->all($columns, $where . $order, $start, $limit), 'total' => (int) $this->_iaDb->one(iaDb::STMT_COUNT_ROWS, $where));
 }
コード例 #2
0
 protected function _modifyGridParams(&$conditions, &$values)
 {
     if (!empty($_GET['text'])) {
         $conditions[] = '(`title` LIKE :text OR `body` LIKE :text)';
         $values['text'] = '%' . iaSanitize::sql($_GET['text']) . '%';
     }
 }
コード例 #3
0
ファイル: hooks.php プロジェクト: rentpad/subrion
 protected function _modifyGridParams(&$conditions, &$values)
 {
     if (isset($_GET['item']) && $_GET['item']) {
         $value = 'core' == strtolower($_GET['item']) ? '' : iaSanitize::sql($_GET['item']);
         $conditions[] = '`extras` = :extras';
         $values['extras'] = $value;
     }
 }
コード例 #4
0
ファイル: transactions.php プロジェクト: kamilklkn/subrion
 protected function _gridRead($params)
 {
     $action = 1 == count($this->_iaCore->requestPath) ? $this->_iaCore->requestPath[0] : null;
     switch ($action) {
         case 'items':
             $output = array('data' => null);
             if ($items = $this->_iaCore->factory('item')->getItems(true)) {
                 foreach ($items as $key => $item) {
                     $output['data'][] = array('title' => iaLanguage::get($item), 'value' => $item);
                 }
             }
             break;
         case 'plans':
             $output = array('data' => null);
             $stmt = '';
             if (!isset($params['itemname']) || isset($params['itemname']) && iaUsers::getItemName() == $params['itemname']) {
                 $stmt = iaDb::convertIds(iaUsers::getItemName(), 'item');
                 $output['data'][] = array('title' => iaLanguage::get('funds'), 'value' => 0);
             } elseif (!empty($params['itemname'])) {
                 $stmt = iaDb::convertIds($params['itemname'], 'item');
             }
             $this->_iaCore->factory('plan');
             if ($planIds = $this->_iaDb->onefield(iaDb::ID_COLUMN_SELECTION, $stmt, null, null, iaPlan::getTable())) {
                 foreach ($planIds as $planId) {
                     $output['data'][] = array('title' => iaLanguage::get('plan_title_' . $planId), 'value' => $planId);
                 }
             }
             break;
         case 'gateways':
             $output = array('data' => null);
             if ($items = $this->getHelper()->getPaymentGateways()) {
                 foreach ($items as $name => $title) {
                     $output['data'][] = array('value' => $name, 'title' => $title);
                 }
             }
             break;
         case 'members':
             $output = array('data' => null);
             if (!empty($params['query'])) {
                 $where[] = 'CONCAT(`username`, `fullname`) LIKE :username';
                 $values['username'] = '******' . iaSanitize::sql($params['query']) . '%';
             }
             $where || ($where[] = iaDb::EMPTY_CONDITION);
             $where = implode(' AND ', $where);
             $this->_iaDb->bind($where, $values);
             if ($members = $this->_iaDb->all(array('id', 'username', 'fullname'), $where, null, null, iaUsers::getTable())) {
                 foreach ($members as $member) {
                     $output['data'][] = array('title' => $member['username'], 'value' => $member['id']);
                 }
             }
             break;
         default:
             $output = parent::_gridRead($params);
     }
     return $output;
 }
コード例 #5
0
ファイル: actions.php プロジェクト: TalehFarzaliey/subrion
 private function _deleteFile($params)
 {
     $result = array('error' => true, 'message' => iaLanguage::get('invalid_parameters'));
     $item = isset($params['item']) ? iaSanitize::sql($params['item']) : null;
     $field = isset($params['field']) ? iaSanitize::sql($params['field']) : null;
     $path = isset($params['path']) ? iaSanitize::sql($params['path']) : null;
     $itemId = isset($params['itemid']) ? (int) $params['itemid'] : null;
     if ($itemId && $item && $field && $path) {
         $tableName = $this->_iaCore->factory('item')->getItemTable($item);
         $itemValue = $this->_iaDb->one($field, iaDb::convertIds($itemId), $tableName);
         $iaAcl = $this->_iaCore->factory('acl');
         if ($iaAcl->isAdmin() && $itemValue) {
             $pictures = $itemValue[1] == ':' ? unserialize($itemValue) : $itemValue;
             $key = null;
             if (is_array($pictures)) {
                 if ($primitive = !is_array($pictures[key($pictures)])) {
                     $pictures = array($pictures);
                 }
                 foreach ($pictures as $k => $v) {
                     if ($path == $v['path']) {
                         $key = $k;
                         break;
                     }
                 }
                 if (!is_null($key)) {
                     unset($pictures[$key]);
                 }
                 $newItemValue = $primitive ? '' : serialize($pictures);
             } else {
                 // single image
                 $newItemValue = '';
                 if ($pictures == $path) {
                     $key = true;
                 }
             }
             if (!is_null($key)) {
                 if ($this->_iaCore->factory('picture')->delete($path)) {
                     if ($this->_iaDb->update(array($field => $newItemValue), iaDb::convertIds($itemId), null, $tableName)) {
                         if (iaUsers::getItemName() == $item) {
                             // update current profile data
                             if ($itemId == iaUsers::getIdentity()->id) {
                                 iaUsers::reloadIdentity();
                             }
                         }
                     }
                     $result['error'] = false;
                     $result['message'] = iaLanguage::get('deleted');
                 } else {
                     $result['message'] = iaLanguage::get('error');
                 }
             }
         }
     }
     return $result;
 }
コード例 #6
0
function lyrics_search($aQuery, $aFields, $aStart, $aLimit, &$aNumAll, $aWhere = '', $cond = 'AND')
{
    $iaCore =& iaCore::instance();
    $iaLyric = $iaCore->factoryPackage('lyric', 'lyrics');
    $ret = array();
    $match = array();
    // 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'] = "'" . iaSanitize::sql($data['val']) . "'";
                }
            }
            $match[] = "t1.`{$fname}` {$data['cond']} {$data['val']} ";
        }
    }
    $lyrics = array();
    $lyrics = $match ? $iaLyric->getSearchLyrics($aStart, $aLimit, ' AND (' . implode(' ' . $cond . ' ', $match) . ')') : array();
    $aNumAll += $iaCore->iaDb->foundRows();
    foreach ($lyrics as $lyric) {
        $iaCore->iaSmarty->assign('lyric', $lyric);
        $lyricinfo = $iaLyric->goToItem(array('item' => $lyric));
        //$ret[] = $iaCore->iaSmarty->fetch(IA_PACKAGES . 'lyrics/templates/common/brief_article.tpl');
        $ret[] = sprintf('<p><a href="%s">%s</a></p>', $lyricinfo[0], $lyric['title']);
    }
    return $ret;
}
コード例 #7
0
 /**
  * Internal utility function used to generate SET stmt
  *
  * @param array $values values to be set checking by type
  * @param array $rawValues values to be set without processing
  *
  * @return string
  */
 protected function _wrapValues($values, $rawValues)
 {
     $result = '';
     // no need for further processing
     if (empty($values) && empty($rawValues)) {
         return $result;
     }
     $array = array();
     if (is_array($values)) {
         foreach ($values as $columnName => $value) {
             $pattern = "`%s` = '%s'";
             switch (true) {
                 case is_bool($value):
                     $pattern = '`%s` = %s';
                     $value = $value ? 1 : 0;
                     break;
                 case is_null($value):
                     $pattern = '`%s` = %s';
                     $value = 'NULL';
                     break;
                 case is_scalar($value):
                     $value = iaSanitize::sql($value);
                     break;
                 default:
                     // arrays, objects & resources are now actually ignored
                     continue;
             }
             $array[] = sprintf($pattern, $columnName, $value);
         }
     }
     if (is_array($rawValues) && $rawValues) {
         foreach ($rawValues as $field => $value) {
             $array[] = "`{$field}` = {$value}";
         }
     }
     $result = implode(', ', $array);
     return $result;
 }
コード例 #8
0
ファイル: search.php プロジェクト: nicefirework/subrion
function searchByPages($query, &$results)
{
    $iaCore = iaCore::instance();
    $iaDb =& $iaCore->iaDb;
    $iaSmarty =& $iaCore->iaView->iaSmarty;
    $iaPage = $iaCore->factory('page', iaCore::FRONT);
    $stmt = '`value` LIKE :query AND `category` = :category AND `code` = :language ORDER BY `key`';
    $iaDb->bind($stmt, array('query' => '%' . iaSanitize::sql($query) . '%', 'category' => iaLanguage::CATEGORY_PAGE, 'language' => $iaCore->iaView->language));
    $pages = array();
    if ($rows = $iaDb->all(array('key', 'value'), $stmt, null, null, iaLanguage::getTable())) {
        foreach ($rows as $row) {
            $pageName = str_replace(array('page_title_', 'page_content_'), '', $row['key']);
            $key = false === stripos($row['key'], 'page_content_') ? 'title' : 'content';
            $value = iaSanitize::tags($row['value']);
            isset($pages[$pageName]) || ($pages[$pageName] = array());
            if ('content' == $key) {
                $value = extractSnippet($value, $query);
                if (empty($pages[$pageName]['title'])) {
                    $pages[$pageName]['title'] = iaLanguage::get('page_title_' . $pageName);
                }
            }
            $pages[$pageName]['url'] = $iaPage->getUrlByName($pageName, false);
            $pages[$pageName][$key] = $value;
        }
    }
    // blocks content will be printed out as a pages content
    if ($blocks = searchThroughBlocks($query)) {
        foreach ($blocks as $pageName => $blocksData) {
            if (isset($pages[$pageName])) {
                $pages[$pageName]['extraItems'] = $blocksData;
            } else {
                $pages[$pageName] = array('url' => $iaPage->getUrlByName($pageName), 'title' => iaLanguage::get('page_title_' . $pageName), 'content' => '', 'extraItems' => $blocksData);
            }
        }
    }
    if ($pages) {
        $iaSmarty->assign('pages', $pages);
        $results['num'] += count($pages);
        $results['html']['pages'] = $iaSmarty->fetch('search-list-pages.tpl');
    }
}
コード例 #9
0
//##copyright##
$iaUsers = $iaCore->factory('users');
$iaDb->setTable(iaUsers::getTable());
if (iaView::REQUEST_JSON == $iaView->getRequestType()) {
    if (isset($_GET['email'])) {
        $code = isset($_GET['code']) ? trim($_GET['code']) : false;
        $email = isset($_POST['email']) ? $_POST['email'] : (isset($_GET['email']) ? $_GET['email'] : '');
        $error = false;
        $message = array();
        if ($email) {
            if (!iaValidate::isEmail($email)) {
                $error = true;
                $message = iaLanguage::get('error_email_incorrect');
            }
            $email = iaSanitize::sql($email);
            $member = $iaDb->row_bind(iaDb::ALL_COLUMNS_SELECTION, '`email` = :email', array('email' => $email));
            if (empty($member)) {
                $error = true;
                $message = iaLanguage::get('error_no_member_email');
            }
            if (false !== $code && $member['sec_key'] != $code) {
                $error = true;
                $message = iaLanguage::get('confirmation_code_incorrect');
            }
            if (!$error && false === $code) {
                $mail = array();
                $token = $iaCore->factory('util')->generateToken();
                $confirmationUrl = IA_URL . "forgot/?email={$email}&code={$token}";
                $iaMailer = $iaCore->factory('mailer');
                $iaMailer->loadTemplate('password_restoration');
コード例 #10
0
ファイル: members.php プロジェクト: nicefirework/subrion
 protected function _modifyGridParams(&$conditions, &$values)
 {
     if (!empty($_GET['name'])) {
         $conditions[] = "CONCAT(`username`, `fullname`, `email`) LIKE '%" . iaSanitize::sql($_GET['name']) . "%'";
     }
 }
コード例 #11
0
 public function getImageFields($pluginFilter = null)
 {
     $conditions = array("`type` IN ('image','pictures')");
     empty($pluginFilter) || ($conditions[] = "`extras` = '" . iaSanitize::sql($pluginFilter) . "'");
     $conditions = implode(' AND ', $conditions);
     return $this->iaDb->onefield('name', $conditions, null, null, self::getTable());
 }
コード例 #12
0
ファイル: pages.php プロジェクト: bohmszi/kdbe_cms
 private function _massUpdateAlias($previous, $new, $entryId)
 {
     $previous = iaSanitize::sql($previous);
     $previous = IA_URL_DELIMITER == $previous[strlen($previous) - 1] ? substr($previous, 0, -1) : $previous;
     $new = iaSanitize::sql($new);
     $new = IA_URL_DELIMITER == $new[strlen($new) - 1] ? substr($new, 0, -1) : $new;
     $cond = iaDb::printf("`alias` LIKE ':alias%' AND `id` != :id", array('alias' => $previous, 'id' => $entryId));
     $stmt = array('alias' => "REPLACE(`alias`, '{$previous}', '{$new}')");
     $this->_iaDb->update(null, $cond, $stmt);
 }
コード例 #13
0
ファイル: ia.core.field.php プロジェクト: bohmszi/kdbe_cms
 public function getStorageFields($itemFilter = null)
 {
     $conditions = array("`type` = 'storage'");
     empty($itemFilter) || ($conditions[] = "`item` = '" . iaSanitize::sql($itemFilter) . "'");
     $conditions = implode(' AND ', $conditions);
     return $this->iaDb->onefield('name', $conditions, null, null, self::getTable());
 }
コード例 #14
0
ファイル: tag.php プロジェクト: TalehFarzaliey/subrion
<?php

//##copyright##
if (iaView::REQUEST_HTML == $iaView->getRequestType()) {
    if (isset($iaCore->requestPath[0])) {
        $tag = $iaCore->requestPath[0];
        $page = empty($_GET['page']) ? 0 : (int) $_GET['page'];
        $page = $page < 1 ? 1 : $page;
        $pageUrl = $iaCore->factory('page', iaCore::FRONT)->getUrlByName('tag');
        $pagination = array('start' => ($page - 1) * $iaCore->get('blog_number'), 'limit' => (int) $iaCore->get('blog_number'), 'template' => $pageUrl . '?page={page}');
        $sql = 'SELECT SQL_CALC_FOUND_ROWS ' . 'b.`id`, b.`title`, b.`date_added`, b.`body`, b.`alias`, b.`image`, m.`fullname`, bt.`title` `tag_title`' . 'FROM `:prefix:table_blog_entries` b ' . 'LEFT JOIN `:prefix:table_members` m ON (b.`member_id` = m.`id`) ' . 'LEFT JOIN `:prefix:table_blog_entries_tags` bet ON (b.`id` = bet.`blog_id`) ' . 'LEFT JOIN `:prefix:table_blog_tags` bt ON (bt.`id` = bet.`tag_id`) ' . 'WHERE bt.`alias` = \':tag\' AND bet.`tag_id` = bt.`id` ' . 'AND b.`status` = \':status\' LIMIT :start, :limit';
        $sql = iaDb::printf($sql, array('prefix' => $iaDb->prefix, 'table_blog_entries' => 'blog_entries', 'table_blog_entries_tags' => 'blog_entries_tags', 'table_blog_tags' => 'blog_tags', 'table_members' => 'members', 'tag' => iaSanitize::sql($tag), 'status' => iaCore::STATUS_ACTIVE, 'start' => $pagination['start'], 'limit' => $pagination['limit']));
        $blogEntries = $iaDb->getAll($sql);
        $pagination['total'] = $iaDb->foundRows();
        if (empty($blogEntries)) {
            return iaView::errorPage(iaView::ERROR_NOT_FOUND);
        }
        $title = '#' . $blogEntries[0]['tag_title'];
        iaBreadcrumb::toEnd($title);
        $iaView->title($title);
        $iaView->display('tag');
        $iaView->assign('pagination', $pagination);
        $iaView->assign('blog_entries', $blogEntries);
    } else {
        $page = empty($_GET['page']) ? 0 : (int) $_GET['page'];
        $page = $page < 1 ? 1 : $page;
        $pageUrl = $iaCore->factory('page', iaCore::FRONT)->getUrlByName('tag');
        $pagination = array('start' => ($page - 1) * $iaCore->get('tag_number'), 'limit' => (int) $iaCore->get('tag_number'), 'template' => $pageUrl . '?page={page}');
        $prefix = $iaDb->prefix;
        $sql = 'SELECT DISTINCT SQL_CALC_FOUND_ROWS bt.`id`, bt.`title`, bt.`alias` ' . 'FROM `:prefix:table_blog_tags` bt ' . 'LEFT JOIN `:prefix:table_blog_entries_tags` bet ON (bt.`id` = bet.`tag_id`) ' . 'LEFT JOIN `:prefix:table_blog_entries` b ON (b.`id` = bet.`blog_id`) ' . 'WHERE b.`status` = \':status\' ' . 'GROUP BY bt.`id` ' . 'ORDER BY bt.`title` ' . 'LIMIT :start, :limit';
        $sql = iaDb::printf($sql, array('prefix' => $iaDb->prefix, 'table_blog_entries' => 'blog_entries', 'table_blog_entries_tags' => 'blog_entries_tags', 'table_blog_tags' => 'blog_tags', 'status' => iaCore::STATUS_ACTIVE, 'start' => $pagination['start'], 'limit' => $pagination['limit']));
コード例 #15
0
ファイル: index.php プロジェクト: bohmszi/kdbe_cms
 protected function _assignValues(&$iaView, array &$entryData)
 {
     $iaUsers = $this->_iaCore->factory('users');
     $owner = empty($entryData['member_id']) ? iaUsers::getIdentity(true) : $iaUsers->getInfo($entryData['member_id']);
     $entryData['owner'] = $owner['fullname'];
     //		commented for cases when SET SESSION group_concat_max_len doesn't work
     //		$tagIds = $this->_iaDb->all('tag_id', "`blog_id` = {$this->getEntryId()}",0, null, $this->_tableBlogEntriesTags);
     //		$entryData['tags'] = '';
     //		foreach ($tagIds as $tagId)
     //		{
     //			$tags = $this->_iaDb->all('title', "`id` = {$tagId['tag_id']}",0, null, $this->_tableBlogTags);
     //			$entryData['tags'] .= $tags[0]['title'] . ',';
     //		}
     //		$entryData['tags'] = rtrim($entryData['tags'], ',');
     $this->_iaDb->query("SET SESSION group_concat_max_len = 2000");
     if ($this->getEntryId()) {
         $sql = 'SELECT GROUP_CONCAT(`title`) ' . 'FROM `:prefix:table_blog_tags` bt ' . 'WHERE `id` IN (' . 'SELECT `tag_id` ' . 'FROM `:prefix:table_blog_entries_tags` ' . 'WHERE `blog_id` = :id)';
         $sql = iaDb::printf($sql, array('prefix' => $this->_iaDb->prefix, 'table_blog_tags' => 'blog_tags', 'table_blog_entries_tags' => 'blog_entries_tags', 'id' => $this->getEntryId()));
         $entryData['tags'] = $this->_iaDb->getOne($sql);
     } else {
         if (isset($_POST['tags'])) {
             $entryData['tags'] = iaSanitize::sql($_POST['tags']);
         }
     }
 }
コード例 #16
0
 /**
  * makeDataBackup
  *
  * Return data sql dump
  *
  * @param string $tableName $tableName table name
  * @param bool $aComplete if true use complete inserts
  * @param bool $prefix if true use prefix
  * @access public
  *
  * @return string
  */
 public function makeDataBackup($tableName, $aComplete = false, $prefix = true)
 {
     $tableNameReplacement = $prefix ? $tableName : str_replace($this->iaDb->prefix, '{prefix}', $tableName);
     $out = '';
     $complete = '';
     $this->iaDb->setTable($tableName, false);
     if ($aComplete) {
         $fields = $this->iaDb->describe($tableName, false);
         $complete = ' (';
         foreach ($fields as $value) {
             $complete .= "`" . $value['Field'] . "`, ";
         }
         $complete = preg_replace('/(,\\n|, )?$/', '', $complete);
         $complete .= ')';
     }
     if ($data = $this->iaDb->all()) {
         foreach ($data as $value) {
             $out .= 'INSERT INTO `' . $tableNameReplacement . '`' . $complete . " VALUES (";
             foreach ($value as $key2 => $value2) {
                 if (!isset($value[$key2])) {
                     $out .= "null, ";
                 } elseif ($value[$key2] != '') {
                     $out .= "'" . iaSanitize::sql($value[$key2]) . "', ";
                 } else {
                     $out .= "'', ";
                 }
             }
             $out = rtrim($out, ', ');
             $out .= ');' . PHP_EOL;
         }
     }
     $this->iaDb->resetTable();
     return $out;
 }
コード例 #17
0
ファイル: pay.php プロジェクト: rentpad/subrion
 if (empty($transaction['plan_id'])) {
     $plan['title'] = $transaction['operation'];
     $plan['cost'] = $transaction['amount'];
 } else {
     $plan = $iaPlan->getById($transaction['plan_id']);
 }
 $plan['title'] = $transaction['item'] . ' - ' . $plan['title'];
 $iaView->assign('plan', $plan);
 $iaView->assign('address', $iaCore->factory('invoice')->getAddress($transaction['id']));
 foreach ($gateways as $key => $gateway) {
     $htmlFormTemplate = IA_PLUGINS . $key . IA_DS . 'templates' . IA_DS . 'front' . IA_DS . 'form.tpl';
     $gateways[$key] = file_exists($htmlFormTemplate) ? $htmlFormTemplate : false;
 }
 // process payment button click
 if (isset($_POST['payment_type'])) {
     $gate = iaSanitize::sql($_POST['payment_type']);
     if (isset($gateways[$gate])) {
         $affected = $iaDb->update(array('id' => $transaction['id'], 'gateway' => $gate), null, array('date' => iaDb::FUNCTION_NOW), iaTransaction::getTable());
         $iaCore->factory('invoice')->updateAddress($transaction['id'], $_POST['invaddr']);
         // include pre form send files
         $paymentGatewayHandler = IA_PLUGINS . $gate . IA_DS . 'includes' . IA_DS . 'pre-processing' . iaSystem::EXECUTABLE_FILE_EXT;
         if (file_exists($paymentGatewayHandler)) {
             include $paymentGatewayHandler;
         }
         if (!empty($gateways[$gate])) {
             $data = array('caption' => 'Redirect to ' . $gate . '', 'msg' => 'You will be redirected to ' . $gate . '', 'form' => $gateways[$gate]);
             $iaView->assign('redir', $data);
             $tplFile = 'redirect-gateway';
             $iaView->disableLayout();
         }
     }
コード例 #18
0
 public function uninstall($extraName)
 {
     if (empty($extraName)) {
         $this->error = true;
         $this->setMessage('Extra name is empty.');
         return false;
     }
     $this->iaCore->startHook('phpExtrasUninstallBefore', array('extra' => $extraName));
     if ($this->iaCore->get('default_package', false) == $extraName) {
         $this->iaCore->set('default_package', '', true);
     }
     $this->checkValidity();
     $extraName = iaSanitize::sql($extraName);
     $iaDb =& $this->iaDb;
     $code = $iaDb->row_bind(array('uninstall_code', 'uninstall_sql', 'rollback_data'), '`name` = :name', array('name' => $extraName), self::getTable());
     $pagesList = $iaDb->onefield('`name`', "`extras` = '{$extraName}'", null, null, 'pages');
     $iaDb->delete("`page_name` IN ('" . implode("','", $pagesList) . "')", 'menus');
     if (in_array($this->iaCore->get('home_page'), $pagesList)) {
         $this->iaCore->set('home_page', 'index', true);
     }
     if ($itemsList = $iaDb->onefield('item', "`package` = '{$extraName}'", null, null, 'items')) {
         $stmt = "`item` IN ('" . implode("','", $itemsList) . "')";
         $iaDb->cascadeDelete(array('items_pages', 'favorites', 'views_log'), $stmt);
     }
     if ($pagesList) {
         $iaDb->cascadeDelete(array('objects_pages'), "`page_name` IN ('" . implode("','", $pagesList) . "')");
         $iaDb->setTable(iaLanguage::getTable());
         $iaDb->delete("`key` IN ('page_title_" . implode("','page_title_", $pagesList) . "')");
         $iaDb->delete("`key` IN ('page_content_" . implode("','page_content_", $pagesList) . "')");
         $iaDb->delete("`key` IN ('page_metakeyword_" . implode("','page_metakeyword_", $pagesList) . "')");
         $iaDb->delete("`key` IN ('page_metadescr_" . implode("','page_metadescr_", $pagesList) . "')");
         $iaDb->resetTable();
     }
     $tableList = array('admin_actions', 'admin_pages_groups', 'admin_pages', 'acl_privileges', iaLanguage::getTable(), iaCore::getConfigGroupsTable(), iaCore::getConfigTable(), iaCore::getCustomConfigTable(), 'pages', 'hooks', 'acl_objects', 'fields_groups', 'fields_pages', 'fields_relations', 'fields_tree_nodes', 'cron');
     $iaDb->cascadeDelete($tableList, "`extras` = '{$extraName}'");
     $this->iaCore->factory('field');
     $iaDb->setTable(iaField::getTable());
     $stmt = '`extras` LIKE :extras';
     $this->iaDb->bind($stmt, array('extras' => '%' . $extraName . '%'));
     if ($itemsList) {
         $stmt .= " OR `item` IN ('" . implode("','", $itemsList) . "')";
     }
     if ($fields = $iaDb->all(array('id', 'extras'), $stmt)) {
         foreach ($fields as $field) {
             $pluginsList = explode(',', $field['extras']);
             if (count($pluginsList) > 1) {
                 unset($pluginsList[array_search($extraName, $pluginsList)]);
                 $iaDb->update(array('extras' => implode(',', $pluginsList), 'id' => $field['id']));
             } else {
                 $iaDb->delete(iaDb::convertIds($field['id']));
             }
         }
     }
     $iaDb->resetTable();
     $iaBlock = $this->iaCore->factory('block', iaCore::ADMIN);
     if ($blockIds = $iaDb->onefield(iaDb::ID_COLUMN_SELECTION, "`extras` = '{$extraName}'", null, null, iaBlock::getTable())) {
         foreach ($blockIds as $blockId) {
             $iaBlock->delete($blockId, false);
         }
     }
     if ($code['uninstall_sql']) {
         $code['uninstall_sql'] = unserialize($code['uninstall_sql']);
         if ($code['uninstall_sql'] && is_array($code['uninstall_sql'])) {
             foreach ($code['uninstall_sql'] as $sql) {
                 $iaDb->query(str_replace('{prefix}', $iaDb->prefix, $sql['query']));
             }
         }
     }
     $entry = $iaDb->row_bind(iaDb::ALL_COLUMNS_SELECTION, '`name` = :name', array('name' => $extraName), self::getTable());
     $iaDb->delete('`name` = :plugin', self::getTable(), array('plugin' => $extraName));
     $iaDb->delete('`package` = :plugin', 'items', array('plugin' => $extraName));
     empty($entry) || $this->_processCategory($entry, self::ACTION_UNINSTALL);
     if ($code['uninstall_code']) {
         $this->_runPhpCode($code['uninstall_code']);
     }
     if ($code['rollback_data']) {
         $rollbackData = unserialize($code['rollback_data']);
         if (is_array($rollbackData)) {
             $existPositions = $this->iaView->positions;
             foreach ($rollbackData as $sectionName => $actions) {
                 foreach ($actions as $name => $itemData) {
                     if (isset($itemData['position'])) {
                         if (!in_array($itemData['position'], $existPositions)) {
                             $itemData['position'] = '';
                             $itemData['status'] = iaCore::STATUS_INACTIVE;
                         }
                     }
                     $stmt = iaDb::printf("`name` = ':name'", array('name' => $name));
                     $this->iaDb->update($itemData, $stmt, null, $sectionName);
                 }
             }
         }
     }
     // clear usergroups
     if ($usergroups = $iaDb->all(iaDb::ALL_COLUMNS_SELECTION, iaDb::convertIds($extraName, 'extras'), 0, null, iaUsers::getUsergroupsTable())) {
         $iaUsers = $this->iaCore->factory('users');
         foreach ($usergroups as $usergroup) {
             $iaUsers->deleteUsergroup($usergroup['id']);
         }
     }
     $this->iaCore->startHook('phpExtrasUninstallAfter', array('extra' => $extraName));
     $this->iaCore->iaCache->clearAll();
     return true;
 }
コード例 #19
0
ファイル: actions.php プロジェクト: TalehFarzaliey/subrion
                     $output['message'] = iaLanguage::get('db_error');
                 }
                 if (iaUsers::getItemName() == $item) {
                     // update current profile data
                     if ($itemId == iaUsers::getIdentity()->id) {
                         iaUsers::reloadIdentity();
                     }
                 }
             }
         }
     }
     break;
 case 'delete-file':
     $item = isset($_POST['item']) ? iaSanitize::sql($_POST['item']) : false;
     $field = isset($_POST['field']) ? iaSanitize::sql($_POST['field']) : false;
     $path = isset($_POST['path']) ? iaSanitize::sql($_POST['path']) : false;
     $itemId = isset($_POST['itemid']) ? (int) $_POST['itemid'] : false;
     if ($itemId && $item && $field && $path) {
         $tableName = $iaCore->factory('item')->getItemTable($item);
         if (iaUsers::getItemName() == $item) {
             $itemValue = $iaDb->one($field, iaDb::convertIds($itemId), $tableName);
             $memberId = $itemId;
         } else {
             $row = $iaDb->row($field . ', `member_id` `id`', iaDb::convertIds($itemId), $tableName);
             $itemValue = $row[$field];
             $memberId = $row['id'];
         }
         if (iaUsers::hasIdentity() && $memberId == iaUsers::getIdentity()->id && $itemValue) {
             $pictures = null;
             if ($itemValue[1] == ':') {
                 $array = unserialize($itemValue);
コード例 #20
0
ファイル: menus.php プロジェクト: TalehFarzaliey/subrion
 protected function _gridRead($params)
 {
     $output = array();
     switch ($params['action']) {
         case 'pages':
             $pageGroups = $this->_iaCore->factory('page', iaCore::ADMIN)->getGroups();
             foreach ($pageGroups as $groupId => $group) {
                 $children = array();
                 foreach ($group['children'] as $pageId => $pageTitle) {
                     $children[] = array('text' => $pageTitle, 'leaf' => true, 'id' => $pageId);
                 }
                 $output[] = array('text' => $group['title'], 'id' => 'group_' . $groupId, 'cls' => 'folder', 'draggable' => false, 'children' => $children);
             }
             $output[0]['expanded'] = true;
             break;
         case 'menus':
             function recursiveRead($list, $pid = 0)
             {
                 $result = array();
                 if (isset($list[$pid])) {
                     foreach ($list[$pid] as $child) {
                         $title = iaLanguage::get('page_title_' . $child['el_id'], 'none');
                         if ($title == 'none') {
                             $title = iaLanguage::get('page_title_' . $child['page_name'], 'none');
                             if ($title == 'none' || $child['page_name'] == 'node') {
                                 $title = iaLanguage::get('_page_removed_');
                             }
                         } else {
                             $title .= (int) $child['el_id'] > 0 ? ' (custom)' : ' (no link)';
                         }
                         $item = array('text' => $title, 'id' => $child['el_id'], 'expanded' => true, 'children' => recursiveRead($list, $child['el_id']));
                         $result[] = $item;
                     }
                 }
                 return $result;
             }
             $output = array();
             if ($name = (int) $params['id']) {
                 $rows = $this->_iaDb->all(iaDb::ALL_COLUMNS_SELECTION, '`menu_id` = ' . $name . ' ORDER BY `id`', null, null, 'menus');
                 foreach ($rows as $row) {
                     $output[$row['parent_id']][] = $row;
                 }
                 $output = recursiveRead($output);
             }
             break;
         case 'titles':
             $output['languages'] = array();
             $languagesList = $this->_iaCore->languages;
             $node = isset($params['id']) ? iaSanitize::sql($params['id']) : false;
             $entry = isset($params['menu']) ? iaSanitize::sql($params['menu']) : false;
             if (isset($params['new']) && $params['new']) {
                 ksort($languagesList);
                 foreach ($languagesList as $code => $language) {
                     $output['languages'][] = array('fieldLabel' => $language['title'], 'name' => $code, 'value' => '');
                 }
             } elseif ($node && $entry) {
                 $key = false;
                 $title = iaLanguage::get('page_title_' . $node, 'none');
                 if ($title != 'none') {
                     $key = 'page_title_' . $node;
                 } else {
                     if ($pageId = (int) $node) {
                         $page = $this->_iaDb->one('`name`', iaDb::convertIds($pageId), 'pages');
                         $key = 'page_title_' . $page;
                     } else {
                         $current = isset($params['current']) ? $params['current'] : '';
                         ksort($languagesList);
                         foreach ($languagesList as $code => $language) {
                             $output['languages'][] = array('fieldLabel' => $language['title'], 'name' => $code, 'value' => $current);
                         }
                     }
                 }
                 if ($key) {
                     $titles = $this->_iaDb->all(iaDb::ALL_COLUMNS_SELECTION, "`key` = '{$key}' ORDER BY `code`", null, null, iaLanguage::getTable());
                     foreach ($titles as $row) {
                         if (isset($languagesList[$row['code']])) {
                             $output['languages'][] = array('fieldLabel' => $languagesList[$row['code']]['title'], 'name' => $row['code'], 'value' => $row['value']);
                         }
                     }
                 }
                 $output['key'] = $key;
             }
             break;
         case 'save':
             $output['message'] = iaLanguage::get('invalid_parameters');
             $menu = isset($params['menu']) ? $params['menu'] : null;
             $node = isset($params['node']) ? $params['node'] : null;
             if ($menu && $node) {
                 $rows = array();
                 foreach ($_POST as $code => $value) {
                     $rows[] = array('code' => $code, 'value' => $value, 'extras' => $menu, 'key' => 'page_title_' . $node, 'category' => iaLanguage::CATEGORY_PAGE);
                 }
                 $this->_iaDb->setTable(iaLanguage::getTable());
                 $this->_iaDb->delete('`key` = :key', null, array('key' => 'page_title_' . $node));
                 $this->_iaDb->insert($rows);
                 $this->_iaDb->resetTable();
                 $output['message'] = iaLanguage::get('saved');
                 $output['success'] = true;
                 $this->_iaCore->iaCache->remove('menu_' . $menu . '.inc');
             }
             break;
         default:
             $output = parent::_gridRead($params);
     }
     return $output;
 }
コード例 #21
0
ファイル: page.php プロジェクト: kamilklkn/subrion
             } elseif (isset($newPage['contents'][$iaView->language])) {
                 $iaView->assign('content', $newPage['contents'][$iaView->language]);
             }
         }
         if (isset($newPage['passw']) && $newPage['passw']) {
             $iaView->assign('page_protect', iaLanguage::get('page_protected', 'Page protected'));
         }
     }
 }
 if (isset($_GET['page_preview']) && isset($iaCore->requestPath[0])) {
     $preview = true;
     $name = iaSanitize::sql($iaCore->requestPath[0]);
 }
 $passw = '';
 if (isset($_POST['password'])) {
     $passw = iaSanitize::sql($_POST['password']);
     $_SESSION['page_passwords'][$name] = $passw;
 } elseif (isset($_SESSION['page_passwords'][$name])) {
     $passw = $_SESSION['page_passwords'][$name];
 }
 $iaPage = $iaCore->factory('page', iaCore::FRONT);
 $page = $iaPage->getByName($name, $preview ? iaCore::STATUS_DRAFT : iaCore::STATUS_ACTIVE);
 if (!$previewMode && (empty($page) || $iaCore->requestPath)) {
     return iaView::errorPage(iaView::ERROR_NOT_FOUND);
 }
 // check read permissions
 $page['passw'] = trim($page['passw']);
 if (isset($_POST['password']) && $page['passw'] && $passw != $page['passw']) {
     $iaView->setMessages(iaLanguage::get('password_incorrect'), iaView::ERROR_NOT_FOUND);
 }
 if ($page['passw'] && $passw != $page['passw'] && !$previewMode) {
コード例 #22
0
ファイル: languages.php プロジェクト: kamilklkn/subrion
 private function _downloadLanguage(&$iaView)
 {
     $language = isset($_POST['lang']) ? iaSanitize::paranoid($_POST['lang']) : $this->_iaCore->requestPath[1];
     $format = isset($_POST['file_format']) && in_array($_POST['file_format'], array('csv', 'sql')) ? $_POST['file_format'] : 'sql';
     $phrases = $this->_iaDb->all(iaDb::ALL_COLUMNS_SELECTION, "`code` = '" . $language . "'");
     $fileName = urlencode(isset($_POST['filename']) ? $_POST['filename'] . '.' . $format : 'subrion_' . IA_VERSION . '_' . $this->_iaCore->requestPath[1] . '.' . $format);
     header('Content-Type: text/plain; charset=utf-8');
     header('Content-Disposition: attachment; filename="' . $fileName . '"');
     $stream = fopen('php://output', 'w');
     if ('sql' == $format) {
         fwrite($stream, 'INSERT INTO `{prefix}language` (`id`, `key`, `original`, `value`, `category`, `code`, `extras`) VALUES' . PHP_EOL);
     }
     foreach ($phrases as $i => $entry) {
         switch ($format) {
             case 'sql':
                 $data = '(';
                 foreach ($entry as $key => $value) {
                     $data .= $value ? 'id' == $key ? 'NULL' : "'" . iaSanitize::sql($value) . "'" : "''";
                     $data .= ', ';
                 }
                 $data = substr($data, 0, -2);
                 $data .= isset($phrases[$i + 1]) ? '),' . PHP_EOL : ');';
                 fwrite($stream, $data);
                 break;
             default:
                 unset($entry['id']);
                 $entry['value'] = str_replace(array("\r\n", "\r", "\n"), '\\n', $entry['value']);
                 $entry['original'] = str_replace(array("\r\n", "\r", "\n"), '\\n', $entry['original']);
                 fputcsv($stream, $entry, '|', '"');
         }
     }
     fclose($stream);
     $iaView->set('nodebug', true);
     exit;
 }
コード例 #23
0
ファイル: packages.php プロジェクト: bohmszi/kdbe_cms
 private function _reset($domain)
 {
     $_GET['type'] = isset($_GET['type']) ? $_GET['type'] : 2;
     $url = '';
     switch ($_GET['type']) {
         case 1:
             $url = 'http://' . iaSanitize::sql(str_replace('www.', '', $_GET['url'][1])) . '.' . $domain . IA_URL_DELIMITER;
             break;
         case 2:
             $url = $_GET['url'][2];
     }
     if ($url) {
         $url = trim($url, IA_URL_DELIMITER) . IA_URL_DELIMITER;
         $this->_changeDefault($url);
         $this->addMessage('reset_default_success');
         return true;
     } else {
         return false;
     }
 }
コード例 #24
0
ファイル: index.php プロジェクト: intelliants/subrion
 protected function _assignValues(&$iaView, array &$entryData)
 {
     $iaUsers = $this->_iaCore->factory('users');
     $owner = empty($entryData['member_id']) ? iaUsers::getIdentity(true) : $iaUsers->getInfo($entryData['member_id']);
     $entryData['owner'] = $owner['fullname'] . " ({$owner['email']})";
     /*
     		commented for cases when SET SESSION group_concat_max_len doesn't work
     		$tagIds = $this->_iaDb->all('tag_id', "`blog_id` = {$this->getEntryId()}",0, null, $this->_tableBlogEntriesTags);
     		$entryData['tags'] = '';
     		foreach ($tagIds as $tagId)
     		{
     			$tags = $this->_iaDb->all('title', "`id` = {$tagId['tag_id']}",0, null, $this->_tableBlogTags);
     			$entryData['tags'] .= $tags[0]['title'] . ',';
     		}
     		$entryData['tags'] = rtrim($entryData['tags'], ',');
     */
     $this->_iaDb->query("SET SESSION group_concat_max_len = 2000");
     if ($this->getEntryId()) {
         $entryData['tags'] = $this->getHelper()->getTags($this->getEntryId());
     } else {
         if (isset($_POST['tags'])) {
             $entryData['tags'] = iaSanitize::sql($_POST['tags']);
         }
     }
 }
コード例 #25
0
ファイル: ia.front.search.php プロジェクト: rentpad/subrion
 private function _processSorting(array $sorting)
 {
     if ($sorting[0]) {
         $field = $this->getOption('columnAlias')->{$sorting[0]} ? $this->getOption('columnAlias')->{$sorting[0]} : iaSanitize::sql($sorting[0]);
         $order = empty($sorting[1]) || !in_array($sorting[1], array('asc', 'desc')) ? iaDb::ORDER_ASC : strtoupper($sorting[1]);
         $this->_sorting = sprintf('`%s` %s', $field, $order);
     } else {
         $this->_sorting = '';
     }
 }
コード例 #26
0
ファイル: index.php プロジェクト: TalehFarzaliey/subrion
<?php

//##copyright##
$iaDb->setTable('blog_entries');
if (iaView::REQUEST_HTML == $iaView->getRequestType()) {
    if (isset($iaCore->requestPath[0])) {
        $id = (int) $iaCore->requestPath[0];
        if (!$id) {
            return iaView::errorPage(iaView::ERROR_NOT_FOUND);
        }
        $sql = 'SELECT b.`id`, b.`title`, b.`date_added`, b.`body`, b.`alias`, b.`image`, m.`fullname` ' . 'FROM `:prefix:table_blog_entries` b ' . 'LEFT JOIN `:prefix:table_members` m ON (b.`member_id` = m.`id`) ' . 'WHERE b.`id` = :id AND b.`status` = \':status\' ';
        $sql = iaDb::printf($sql, array('prefix' => $iaDb->prefix, 'table_blog_entries' => 'blog_entries', 'table_members' => iaUsers::getTable(), 'id' => iaSanitize::sql($id), 'status' => iaCore::STATUS_ACTIVE));
        $blogEntry = $iaDb->getRow($sql);
        $sql = 'SELECT DISTINCT bt.`title`, bt.`alias` ' . 'FROM `:prefix:table_blog_tags` bt ' . 'LEFT JOIN `:prefix:table_blog_entries_tags` bet ON (bt.`id` = bet.`tag_id`) ' . 'WHERE bet.`blog_id` = :id';
        $sql = iaDb::printf($sql, array('prefix' => $iaDb->prefix, 'table_blog_entries_tags' => 'blog_entries_tags', 'table_blog_tags' => 'blog_tags', 'id' => iaSanitize::sql($id)));
        $blogTags = $iaDb->getAll($sql);
        if (empty($blogEntry)) {
            return iaView::errorPage(iaView::ERROR_NOT_FOUND);
        }
        $title = iaSanitize::tags($blogEntry['title']);
        iaBreadcrumb::toEnd($title);
        $iaView->title($title);
        // add open graph data
        $openGraph = array('title' => $title, 'url' => IA_SELF, 'description' => $blogEntry['body']);
        if ($blogEntry['image']) {
            $openGraph['image'] = IA_CLEAR_URL . 'uploads/' . $blogEntry['image'];
        }
        $iaView->set('og', $openGraph);
        $iaView->assign('tags', $blogTags);
        $iaView->assign('blog_entry', $blogEntry);
    } else {
コード例 #27
0
 protected function _getQueryStmtByString()
 {
     $statements = array();
     $tableAlias = $this->getOption('tableAlias') ? $this->getOption('tableAlias') . '.' : '';
     $escapedQuery = iaSanitize::sql(strtolower($this->_query));
     foreach ($this->_fieldTypes as $fieldName => $type) {
         switch ($type) {
             case iaField::NUMBER:
                 if (is_numeric($this->_query)) {
                     $statements[] = sprintf('%s = %s', $tableAlias . $fieldName, (int) $this->_query);
                 }
                 break;
             case iaField::TEXT:
             case iaField::TEXTAREA:
                 $statements[] = sprintf("%s LIKE '%s'", $tableAlias . $fieldName, '%' . $escapedQuery . '%');
                 break;
             default:
                 $statements[] = sprintf("%s LIKE '%s'", $tableAlias . $fieldName, '%' . $escapedQuery . '%');
         }
     }
     $extraStatements = $this->getOption('regularSearchStatements');
     $extraStatements || ($extraStatements = array());
     foreach ($extraStatements as $stmt) {
         $statements[] = str_replace(':query', $escapedQuery, $stmt);
     }
     return '(' . implode(' OR ', $statements) . ')';
 }