public static function load($languageCode)
 {
     $iaCore = iaCore::instance();
     $stmt = "`code` = :language AND `category` != 'tooltip' AND `category` != :exclusion ORDER BY `extras`";
     $iaCore->iaDb->bind($stmt, array('language' => $languageCode, 'exclusion' => iaCore::ACCESS_FRONT == $iaCore->getAccessType() ? 'admin' : 'frontend'));
     self::$_phrases = $iaCore->iaDb->keyvalue(array('key', 'value'), $stmt, self::getTable());
 }
Exemple #2
0
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);
}
Exemple #3
0
 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;
 }
 public function getDashboardStatistics()
 {
     $statuses = array(iaCore::STATUS_ACTIVE, iaCore::STATUS_INACTIVE);
     $rows = $this->iaDb->keyvalue('`status`, COUNT(*)', '1 GROUP BY `status`', self::getTable());
     $total = 0;
     foreach ($statuses as $status) {
         isset($rows[$status]) || ($rows[$status] = 0);
         $total += $rows[$status];
     }
     return array('icon' => 'quill', 'item' => iaLanguage::get('blogposts'), 'rows' => $rows, 'total' => $total, 'url' => 'blog/');
 }
Exemple #5
0
 protected function _launch($id)
 {
     //$this->getHelper()->run($id);
     // implemented via remote request because potentially some package's cron task
     // may use front classes which will cause conflicts if executed from backend side.
     // otherwise, the only call of iaCore::run() would be enough
     $cronUrl = IA_CLEAR_URL . 'cron/?_t&t=' . (int) $id;
     iaUtil::getPageContent($cronUrl, 300);
     //
     $this->_iaCore->iaView->setMessages(iaLanguage::get('scheduled_task_ran'), iaView::SUCCESS);
     iaUtil::go_to($this->getPath());
 }
 /**
  * Return plan information
  *
  * @param integer $planId plan id
  *
  * @return null|array
  */
 public function getById($planId)
 {
     $plan = null;
     if (!is_array($planId)) {
         $plan = $this->iaDb->row_bind(iaDb::ALL_COLUMNS_SELECTION, '`status` = :status AND `id` = :id', array('status' => iaCore::STATUS_ACTIVE, 'id' => (int) $planId), self::getTable());
         if ($plan) {
             $plan['title'] = iaLanguage::get('plan_title_' . $plan['id']);
             $plan['description'] = iaLanguage::get('plan_description_' . $plan['id']);
         }
     }
     return $plan;
 }
function smarty_function_ia_html_file($params, &$smarty)
{
    $browse = iaLanguage::get('browse');
    $title = iaLanguage::get('title');
    $placeholder = isset($params['value']) && $params['value'] ? $params['value'] : iaLanguage::get('file_click_to_upload');
    $id = isset($params['id']) ? $params['id'] : $params['name'];
    $multiple = isset($params['multiple']) ? $params['multiple'] : false;
    if (!$multiple) {
        $result = <<<OUT
<div class="upload-group">
\t<div class="input-group file-upload">
\t\t<input type="hidden" name="v[{$params['name']}]">
\t\t<input type="file" name="{$params['name']}" id="{$id}">
\t\t<input type="text" class="disabled" placeholder="{$placeholder}" disabled>
\t\t<span class="input-group-btn">
\t\t\t<a class="btn btn-primary js-file-browse" href="#">{$browse}</a>
\t\t</span>
\t</div>
</div>
OUT;
    } else {
        $max_num = isset($params['max_num']) ? $params['max_num'] : 0;
        $hidden = $max_num < 1 ? ' style="display: none;"' : '';
        $title_html = '';
        if (isset($params['title'])) {
            $title_html = <<<TITLE
<div class="input-group">
\t<span class="input-group-addon">{$title}:</span>
\t<input type="text" name="{$params['name']}_title[]" class="file-title">
</div>
TITLE;
        }
        $result = <<<OUT
<div class="upload-group" id="upload-group-{$id}">
\t<div class="file-upload"{$hidden}>
\t\t{$title_html}
\t\t<div class="input-group">
\t\t\t<input type="file" name="{$params['name']}[]">
\t\t\t<input type="text" class="disabled" disabled="disabled" placeholder="{$placeholder}">
\t\t\t<span class="input-group-btn">
\t\t\t\t<a class="btn btn-primary js-file-browse" href="#">{$browse}</a>
\t\t\t\t<a class="btn btn-primary js-file-add" href="#"><i class="i-plus-alt"></i></a>
\t\t\t\t<a class="btn btn-primary js-file-remove" href="#"><i class="i-minus-alt"></i></a>
\t\t\t</span>
\t\t</div>
\t</div>
\t<input type="hidden" value="{$max_num}" id="{$id}">
</div>
OUT;
    }
    return $result;
}
 private function _viewPage(&$iaView, $id)
 {
     $item = $this->getById($id);
     if (!$item) {
         return iaView::errorPage(iaView::ERROR_NOT_FOUND);
     }
     $iaUsers = $this->_iaCore->factory('users');
     $iaView->assign('item', $item);
     $iaView->assign('initiator', $iaUsers->getInfo($item['member_id']));
     iaBreadcrumb::toEnd(iaLanguage::get('claim_details'));
     $iaView->title(iaLanguage::get('claim_details'));
     $iaView->display('view');
 }
Exemple #9
0
 protected function _gridRead($params)
 {
     if (isset($_POST['action'])) {
         $output = array();
         switch ($_POST['action']) {
             case 'get':
                 $output['code'] = $this->_iaDb->one_bind('`code`', iaDb::convertIds((int) $_POST['id']));
                 break;
             case 'set':
                 $output['result'] = (bool) $this->_iaDb->update(array('code' => $_POST['code']), iaDb::convertIds($_POST['id']));
                 $output['message'] = iaLanguage::get($output['result'] ? 'saved' : 'db_error');
         }
         return $output;
     }
     return parent::_gridRead($params);
 }
Exemple #10
0
 protected function _gridRead($params)
 {
     $output = array();
     switch ($this->_iaCore->requestPath[0]) {
         case 'get':
             $output['code'] = $this->_iaDb->one_bind('`code`', iaDb::convertIds((int) $_GET['id']));
             break;
         case 'set':
             $this->_iaDb->update(array('code' => $_POST['code']), iaDb::convertIds($_POST['id']));
             $output['result'] = 0 == $this->_iaDb->getErrorNumber();
             $output['message'] = iaLanguage::get($output['result'] ? 'saved' : 'db_error');
             break;
         default:
             $output = parent::_gridRead($params);
     }
     return $output;
 }
 public function createQueue($fromName, $fromMail, $subject, $body, $html, $groups, $status)
 {
     $error = false;
     $rcptsPerRun = 15;
     $messages = array();
     $data = array();
     $data['from_name'] = $fromName;
     $data['subj'] = $subject;
     $data['html'] = $html;
     if (empty($fromMail) || !iaValidate::isEmail($fromMail)) {
         $error = true;
         $messages[] = iaLanguage::get('from_email_err');
     } else {
         $data['from_mail'] = $fromMail;
     }
     if (empty($body)) {
         $error = true;
         $messages[] = iaLanguage::get('err_message');
     } else {
         $data['body'] = $body;
     }
     $usergrp = empty($groups) ? 0 : array_sum($groups);
     $status = empty($status) ? array() : $status;
     $status = implode("','", $status);
     $rcpt = $this->iaDb->onefield('email', "`usergroup_id` & {$usergrp} AND `status` IN ('{$status}')", 0, 0, 'members');
     if (empty($rcpt)) {
         $error = true;
         $messages[] = iaLanguage::get('no_rcpt');
     }
     if (!$error) {
         $data['total'] = count($rcpt);
         $messageId = $this->iaDb->insert($data, null, self::getTableMessages());
         foreach ($rcpt as $index => $addr) {
             $rcptCart[] = $addr;
             if (($index + 1) % $rcptsPerRun == 0 || $index + 1 == $data['total']) {
                 $this->iaDb->insert(array('message_id' => $messageId, 'recipients' => implode(',', $rcptCart)), null, self::getTableRecipients());
                 $rcptCart = array();
             }
         }
         $messages[] = iaLanguage::get('queue_added');
     }
     return array($error, $messages);
 }
 function httpCheckFile($url)
 {
     $curl = curl_init($url);
     curl_setopt($curl, CURLOPT_NOBODY, true);
     curl_setopt($curl, CURLOPT_HEADER, true);
     curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
     curl_exec($curl);
     $info = curl_getinfo($curl);
     curl_close($curl);
     if (200 !== $info['http_code']) {
         return array(false, iaLanguage::getf('http_status_error', array('code' => $info['http_code'])));
     } elseif (0 !== $info['redirect_count']) {
         return array(false, iaLanguage::get('extra_redirects_error'));
     } elseif (0 !== $info['download_content_length'] && -1 != $info['download_content_length']) {
         return array(false, iaLanguage::getf('remote_file_is_not_empty', array('bytes' => $info['download_content_length'])));
     } else {
         return array(true, iaLanguage::get('remote_file_validation_success'));
     }
 }
Exemple #13
0
 public function getGroups(array $exclusions = array())
 {
     $stmt = '`status` = :status AND `service` = 0';
     if ($exclusions) {
         $stmt .= " AND `name` NOT IN ('" . implode("','", array_map(array('iaSanitize', 'sql'), $exclusions)) . "')";
     }
     $this->iaDb->bind($stmt, array('status' => iaCore::STATUS_ACTIVE));
     $pages = array();
     $result = array();
     $rows = $this->iaDb->all(array('id', 'name', 'group'), $stmt, null, null, self::getTable());
     foreach ($rows as $page) {
         $page['group'] || ($page['group'] = 1);
         $pages[$page['group']][$page['id']] = iaLanguage::get('page_title_' . $page['name']);
     }
     $rows = $this->iaDb->all(array('title', 'id', 'name'), null, null, null, self::getAdminGroupsTable());
     foreach ($rows as $row) {
         if (isset($pages[$row['id']])) {
             $result[$row['id']] = array('title' => $row['title'], 'children' => $pages[$row['id']]);
         }
     }
     return $result;
 }
Exemple #14
0
 public function gridDelete($params, $languagePhraseKey = 'deleted')
 {
     $result = array('result' => false, 'message' => iaLanguage::get('invalid_parameters'));
     if (isset($params['id']) && is_array($params['id']) && $params['id']) {
         $total = count($params['id']);
         $affected = 0;
         foreach ($params['id'] as $id) {
             if ($this->delete($id)) {
                 $affected++;
             }
         }
         if ($affected) {
             $result['result'] = true;
             if (1 == $total) {
                 $result['message'] = iaLanguage::get($languagePhraseKey);
             } else {
                 $result['message'] = $affected == $total ? iaLanguage::getf('items_deleted', array('num' => $affected)) : iaLanguage::getf('items_deleted_of', array('num' => $affected, 'total' => $total));
             }
         } else {
             $result['message'] = iaLanguage::get('db_error');
         }
     }
     return $result;
 }
//##copyright##
define('INTELLI_REALM', 'manage_tiers');
$iaXp = $iaCore->factoryPackages('elitius', 'admin', 'elitius');
$id = (int) $_GET['id'];
if ((int) $_GET['delete'] > 0) {
    $iaXp->deleteMultiLevel((int) $_GET['delete']);
    $msg = iaLanguage::get('msg_payout_level_deleted');
}
if (isset($_POST['task'])) {
    if ($_POST['task'] == 'save') {
        foreach ($_POST as $key => $value) {
            if (strstr($key, 'amt_')) {
                $num = substr($key, 4);
                $level[$num] = $value;
            }
        }
        for ($i = 1; $i <= count($level); $i++) {
            $iaXp->saveMultiLevel($i, $level[$i]);
        }
        $msg = iaLanguage::get('msg_changes_success_saved');
    } elseif ($_POST['task'] == 'add') {
        $iaXp->addMultiLevel($_POST['level'], $_POST['percent']);
        $msg = iaLanguage::get('msg_new_payout_level_added');
    }
}
$paylevels = $iaXp->getMultiLevels();
$max = $iaXp->getMaxMultilevel();
$max_percent = $iaXp->getMaxMultiPercent();
$iaCore->assign('paylevels', $paylevels);
$iaCore->assign('max', $max);
$iaCore->assign('max_percent', $max_percent);
Exemple #16
0
 protected function _gridUpdate($params)
 {
     if (isset($params['id']) && is_array($params['id']) && 2 == count($params) && isset($params['status'])) {
         $currentUserId = iaUsers::getIdentity()->id;
         if (in_array($currentUserId, $params['id'])) {
             $totalAdminsCount = (int) $this->_iaDb->one_bind(iaDb::STMT_COUNT_ROWS, '`usergroup_id` = :group AND `status` = :status AND `id` != :id', array('group' => iaUsers::MEMBERSHIP_ADMINISTRATOR, 'status' => iaCore::STATUS_ACTIVE, 'id' => $currentUserId));
             if (0 == $totalAdminsCount && $params['status'] != iaCore::STATUS_ACTIVE) {
                 return array('result' => false, 'message' => iaLanguage::get('action_not_allowed_since_you_only_admin'));
             }
         }
     }
     return parent::_gridUpdate($params);
 }
Exemple #17
0
                $iaView->assign('blog_entry', $entry);
                if ($iaAcl->isAccessible(iaBlog::PAGE_NAME, iaCore::ACTION_EDIT) && iaUsers::hasIdentity() && iaUsers::getIdentity()->id == $entry['member_id']) {
                    $pageActions[] = array('icon' => 'pencil', 'title' => iaLanguage::get('edit_blog_entry'), 'url' => $baseUrl . 'edit/' . $id . '/', 'classes' => 'btn-info');
                    $pageActions[] = array('icon' => 'remove', 'title' => iaLanguage::get('delete'), 'url' => $baseUrl . 'delete/' . $id . '/', 'classes' => 'btn-danger');
                }
            } else {
                $page = empty($_GET['page']) ? 0 : (int) $_GET['page'];
                $page = $page < 1 ? 1 : $page;
                $pagination = array('start' => ($page - 1) * $iaCore->get('blog_number'), 'limit' => (int) $iaCore->get('blog_number'), 'template' => $baseUrl . '?page={page}');
                $entries = $iaBlog->get($pagination['start'], $pagination['limit']);
                $pagination['total'] = $iaDb->foundRows();
                $iaView->assign('tags', $iaBlog->getAllTags());
                $iaView->assign('blog_entries', $entries);
                $iaView->assign('pagination', $pagination);
            }
            if ($iaAcl->isAccessible('blog', iaCore::ACTION_ADD)) {
                $pageActions[] = array('icon' => 'plus', 'title' => iaLanguage::get('add_blog_entry'), 'url' => $baseUrl . 'add/', 'classes' => 'btn-success');
            }
            $pageActions[] = array('icon' => 'rss', 'title' => null, 'url' => IA_URL . 'blog.xml', 'classes' => 'btn-warning');
            $iaView->set('actions', $pageActions);
    }
}
if (iaView::REQUEST_XML == $iaView->getRequestType()) {
    $output = array('title' => $iaCore->get('site') . ' :: ' . $iaView->title(), 'description' => '', 'url' => IA_URL . 'blog', 'item' => array());
    $entries = $iaBlog->get(0, 20);
    foreach ($entries as $entry) {
        $output['item'][] = array('title' => $entry['title'], 'link' => $baseUrl . $entry['id'] . '-' . $entry['alias'], 'pubDate' => date('D, d M Y H:i:s T', strtotime($entry['date_modified'])), 'description' => iaSanitize::tags($entry['body']));
    }
    $iaView->assign('channel', $output);
}
$iaDb->resetTable();
 /**
  * Filling admin dashboard statistics with the financial information
  *
  * @return array
  */
 public function getDashboardStatistics()
 {
     $this->iaDb->setTable(self::getTable());
     $currenciesToSymbolMap = array('USD' => '$', 'EUR' => '€', 'RMB' => '¥', 'CNY' => '¥');
     $currency = strtoupper($this->iaCore->get('currency'));
     $currency = isset($currenciesToSymbolMap[$currency]) ? $currenciesToSymbolMap[$currency] : '';
     $data = array();
     $weekDay = getdate();
     $weekDay = $weekDay['wday'];
     $stmt = '`status` = :status AND DATE(`date`) BETWEEN DATE(DATE_SUB(NOW(), INTERVAL ' . $weekDay . ' DAY)) AND DATE(NOW()) GROUP BY DATE(`date`)';
     $this->iaDb->bind($stmt, array('status' => self::PASSED));
     $rows = $this->iaDb->keyvalue('DAYOFWEEK(DATE(`date`)), SUM(`amount`)', $stmt);
     for ($i = 0; $i < 7; $i++) {
         $data[$i] = isset($rows[$i]) ? $rows[$i] : 0;
     }
     $statuses = array(self::PASSED, self::PENDING, self::REFUNDED, self::FAILED);
     $rows = $this->iaDb->keyvalue('`status`, COUNT(*)', '1 GROUP BY `status`');
     foreach ($statuses as $status) {
         isset($rows[$status]) || ($rows[$status] = 0);
     }
     $total = $this->iaDb->one_bind('ROUND(SUM(`amount`)) `total`', '`status` = :status', array('status' => self::PASSED));
     $total || ($total = 0);
     $this->iaDb->resetTable();
     return array('_format' => 'medium', 'data' => array('array' => implode(',', $data)), 'icon' => 'banknote', 'item' => iaLanguage::get('total_income'), 'rows' => $rows, 'total' => $currency . $total, 'url' => 'transactions/');
 }
Exemple #19
0
 private static function _importDump(&$iaDb)
 {
     $filename = $_FILES ? $_FILES['language_file']['tmp_name'] : $_POST['language_file2'];
     $format = isset($_POST['format']) && in_array($_POST['format'], array('csv', 'sql')) ? $_POST['format'] : 'sql';
     $error = false;
     $messages = array();
     if (empty($filename)) {
         $error = true;
         $messages[] = iaLanguage::get('choose_import_file');
     } elseif (!($f = fopen($filename, 'r'))) {
         $error = true;
         $messages[] = iaLanguage::getf('cant_open_sql', array('filename' => $filename));
     }
     if ($format == 'csv' && isset($_POST['title']) && trim($_POST['title']) == '') {
         $error = true;
         $messages[] = iaLanguage::get('title_is_empty');
     }
     if (!$error) {
         $error = true;
         $languageCode = '';
         if ('sql' == $format) {
             $sql = '';
             while ($s = fgets($f, 10240)) {
                 $s = trim($s);
                 if ($s[0] == '#' || $s[0] == '') {
                     continue;
                 }
                 $sql .= $s;
                 if ($s[strlen($s) - 1] != ';') {
                     continue;
                 }
                 $sql = str_replace('{prefix}', $iaDb->prefix, $sql);
                 $iaDb->query($sql);
                 if (empty($languageCode)) {
                     $matches = array();
                     if (preg_match('#, \'([a-z]{2})\', \'#', $sql, $matches) || preg_match('#,\'([a-z]{2})\',\'#', $sql, $matches)) {
                         $languageCode = $matches[1];
                     }
                 }
                 $sql = '';
             }
             fclose($f);
             $error = false;
         }
         if ('csv' == $format) {
             if ($csvContent = file($filename)) {
                 $array = array();
                 foreach ($csvContent as $i => $row) {
                     if (empty($row)) {
                         break;
                     }
                     $fields = explode('|', trim($row));
                     if (count($fields) != 6) {
                         break;
                     }
                     $fields = array_map(array('iaSanitize', 'sql'), $fields);
                     $languageCode = isset($fields[4]) ? $fields[4] : null;
                     $array[] = "('" . implode("','", $fields) . "')";
                 }
                 if (count($fields) == 6 && strlen($languageCode) == 2) {
                     $error = false;
                     $sql = "INSERT INTO `{$iaDb->prefix}language` (`key`, `original`, `value`, `category`, `code`, `extras`) VALUES ";
                     $sql .= implode(',', $array);
                     $sql .= ';';
                     $iaDb->query($sql);
                 }
             }
         }
         $messages[] = iaLanguage::get($error ? 'incorrect_file_format' : 'saved');
     }
     return array(!$error, $messages, isset($languageCode) ? $languageCode : null);
 }
                $url = $iaCore->get('members_autoapproval') ? IA_URL . 'login/' : IA_URL;
                iaUtil::redirect(iaLanguage::get('reg_confirmation'), $messages, $url);
            } else {
                $messages[] = iaLanguage::get('confirmation_key_incorrect');
            }
            $iaView->assign('success', !$error);
        }
    }
    switch ($iaView->name()) {
        case 'member_password_forgot':
            $template = 'forgot';
            break;
        case 'register_confirm':
            $template = 'registration-confirmation';
            break;
        default:
            if ($memberId) {
                $error = false;
                $template = 'registration-confirmation';
                $messages[] = iaLanguage::get('member_created');
                $iaView->assign('email', $itemData['email']);
            } else {
                $error = true;
                $template = 'registration';
                $iaView->assign('tmp', $itemData);
            }
    }
    $iaView->setMessages($messages, $error ? iaView::ERROR : iaView::SUCCESS);
    $iaView->display($template);
}
$iaDb->resetTable();
Exemple #21
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);
         }
     }
 }
Exemple #22
0
 protected function _assignValues(&$iaView, array &$entryData)
 {
     if (isset($entryData['data'])) {
         $entryData['data'] = unserialize($entryData['data']);
         empty($entryData['data']['fields']) || ($entryData['data']['fields'] = array_reverse($entryData['data']['fields']));
     } else {
         $entryData['data'] = array();
     }
     // populating titles & descriptions
     if (empty($_POST['title'])) {
         $this->_iaDb->setTable(iaLanguage::getTable());
         $stmt = "`key` = 'plan_title_" . $this->getEntryId() . "'";
         $entryData['title'] = $this->_iaDb->keyvalue(array('code', 'value'), $stmt);
         $stmt = "`key` = 'plan_description_" . $this->getEntryId() . "'";
         $entryData['description'] = $this->_iaDb->keyvalue(array('code', 'value'), $stmt);
         $this->_iaDb->resetTable();
     } else {
         list($entryData['title'], $entryData['description']) = array($_POST['title'], $_POST['description']);
     }
     //
     $units = $this->_iaDb->getEnumValues($this->getTable(), 'unit');
     $units = $units ? array_values($units['values']) : array();
     $usergroups = $this->_iaCore->factory('users')->getUsergroups();
     unset($usergroups[iaUsers::MEMBERSHIP_ADMINISTRATOR], $usergroups[iaUsers::MEMBERSHIP_GUEST]);
     $iaView->assign('usergroups', $usergroups);
     $iaView->assign('fields', $this->_fields);
     $iaView->assign('items', $this->_items);
     $iaView->assign('expiration_statuses', $this->_getItemsStatuses());
     $iaView->assign('units', $units);
 }
Exemple #23
0
 private function _getAdminToolbarActions()
 {
     $result = array();
     $stmt = "`pages` REGEXP('[[:<:]]:page(::action)?(,|\$)') AND `type` = 'regular' ORDER BY `order` DESC";
     $stmt = iaDb::printf($stmt, array('page' => $this->name(), 'action' => $this->get('action')));
     $iaAcl = $this->iaCore->factory('acl');
     $rows = $this->iaCore->iaDb->all(array('attributes', 'name', 'icon', 'text', 'url'), $stmt, null, null, 'admin_actions');
     foreach ($rows as $entry) {
         if ($iaAcl->checkAccess(iaAcl::OBJECT_ADMIN_PAGE, $entry['name'])) {
             $result[] = array('attributes' => $entry['attributes'], 'icon' => empty($entry['icon']) ? '' : 'i-' . $entry['icon'], 'title' => iaLanguage::get($entry['text'], $entry['text']), 'url' => iaDb::printf($entry['url'], $this->iaCore->iaView->get('toolbarActionsReplacements', array())));
         }
     }
     return $result;
 }
                        $data['artist_alias'] = $artist_info['title_alias'];
                    }
                    $data['status'] = check_post('status');
                    if ('add' == $pageAction) {
                        $iaCore->startHook("phpAdminBeforeAlbumAdd");
                        $data['id'] = $iaAlbum->insert($data);
                        // implement common hook for all items
                        $iaCore->startHook('phpAddItemAfterAll', array('type' => 'admin', 'listing' => $data['id'], 'item' => 'albums', 'data' => $data, 'old' => $item));
                        $iaView->setMessages(iaLanguage::get('album_added'), 'success');
                        $url = IA_ADMIN_URL . 'manage/albums/';
                        $goto = array('add' => $url . 'add/', 'list' => $url, 'stay' => $url . 'edit/?id=' . $data['id']);
                        $iaCore->post_goto($goto);
                    } elseif ('edit' == $pageAction) {
                        $data['id'] = $item['id'];
                        $iaCore->startHook("phpAdminBeforeAlbumUpdate");
                        $iaAlbum->update($data);
                        $messages = iaLanguage::get('changes_saved');
                    }
                } else {
                    unset($data['title_alias']);
                }
                $item = array_merge($item, $data);
                $iaView->setMessages($messages, $error ? 'error' : 'success');
            }
            $iaView->assign('item', $item);
            $fields_groups = $iaFields->getFieldsGroups(true, false, 'albums');
            $iaView->assign('fields_groups', $fields_groups);
            $iaView->display('albums');
            break;
    }
}
 public function delete($id, $log = true)
 {
     $iaDb =& $this->iaDb;
     $row = $iaDb->row(iaDb::ALL_COLUMNS_SELECTION, iaDb::convertIds($id));
     $title = self::LANG_PATTERN_TITLE . $id;
     $title = iaLanguage::exists($title) ? iaLanguage::get($title) : $row['title'];
     $this->iaCore->startHook('beforeBlockDelete', array('block' => &$row));
     $result = parent::delete($id);
     if ($result) {
         $iaDb->delete('`object_type` = :object && `object` = :id', self::getPagesTable(), array('id' => $id, 'object' => 'blocks'));
         $iaDb->delete('`key` = :title OR `key` = :content', iaLanguage::getTable(), array('title' => self::LANG_PATTERN_TITLE . $id, 'content' => self::LANG_PATTERN_CONTENT . $id));
         if ($log) {
             $this->iaCore->factory('log')->write(iaLog::ACTION_DELETE, array('item' => 'block', 'name' => $title, 'id' => $id));
         }
     }
     $this->iaCore->startHook('afterBlockDelete', array('block' => &$row));
     return $result;
 }
Exemple #26
0
                             $show['years'] = true;
                         }
                     }
                 }
             }
         }
         if (isset($iaCore->requestPath[0]) && !isset($iaCore->requestPath[1])) {
             iaBreadcrumb::preEnd('Blog Archive', 'blog/date');
             iaBreadcrumb::replaceEnd($iaCore->requestPath[0], IA_SELF);
             $iaView->title($iaCore->requestPath[0]);
         }
         $iaView->assign('show', $show);
         $iaView->assign('years', $years);
         $iaView->assign('months', $months);
     } else {
         $iaView->setMessages(iaLanguage::get('no_blog_entries'), iaView::ALERT);
     }
 } elseif (isset($iaCore->requestPath[0]) && isset($iaCore->requestPath[1])) {
     $page = empty($_GET['page']) ? 0 : (int) $_GET['page'];
     $page = $page < 1 ? 1 : $page;
     $pageUrl = $iaCore->factory('page', iaCore::FRONT)->getUrlByName('blog_date');
     $pagination = array('start' => ($page - 1) * $iaCore->get('blog_number'), 'limit' => (int) $iaCore->get('blog_number'), 'template' => $pageUrl . '?page={page}');
     $stmt = "`status` = 'active' AND MONTH(b.`date_added`) = '" . $iaCore->requestPath[1] . "' AND YEAR(b.`date_added`) = '" . $iaCore->requestPath[0] . "' ";
     $order = 'date' == $iaCore->get('blog_order') ? 'ORDER BY b.`date_added` DESC' : 'ORDER BY b.`title` ASC';
     $sql = 'SELECT SQL_CALC_FOUND_ROWS ' . '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.' . $stmt . $order . ' LIMIT :start, :limit';
     $sql = iaDb::printf($sql, array('prefix' => $iaDb->prefix, 'table_blog_entries' => 'blog_entries', 'table_members' => 'members', 'start' => $pagination['start'], 'limit' => $pagination['limit']));
     $blogs = $iaDb->getAll($sql);
     iaBreadcrumb::toEnd(date("F", mktime(0, 0, 0, $iaCore->requestPath[1], 10)));
     $pagination['total'] = $iaDb->foundRows();
     $iaView->assign('blogs', $blogs);
     $iaView->assign('pagination', $pagination);
Exemple #27
0
 protected function _preSaveEntry(array &$entry, array $data, $action)
 {
     parent::_preSaveEntry($entry, $data, $action);
     iaUtil::loadUTF8Functions('ascii', 'validation', 'bad', 'utf8_to_ascii');
     if (!utf8_is_valid($entry['title'])) {
         $entry['title'] = utf8_bad_replace($entry['title']);
     }
     if (empty($entry['title'])) {
         $this->addMessage('title_is_empty');
     }
     if (!utf8_is_valid($entry['body'])) {
         $entry['body'] = utf8_bad_replace($entry['body']);
     }
     if (empty($entry['body'])) {
         $this->addMessage(iaLanguage::getf('field_is_empty', array('field' => iaLanguage::get('body'))), false);
     }
     if (empty($entry['date_added'])) {
         $entry['date_added'] = date(iaDb::DATETIME_FORMAT);
     }
     $entry['alias'] = $this->getHelper()->titleAlias(empty($entry['alias']) ? $entry['title'] : $entry['alias']);
     if ($this->getMessages()) {
         return false;
     }
     unset($entry['owner'], $entry['tags']);
     if (isset($_FILES['image']['tmp_name']) && $_FILES['image']['tmp_name']) {
         $iaPicture = $this->_iaCore->factory('picture');
         $info = array('image_width' => 1000, 'image_height' => 750, 'thumb_width' => 250, 'thumb_height' => 250, 'resize_mode' => iaPicture::CROP);
         if ($image = $iaPicture->processImage($_FILES['image'], iaUtil::getAccountDir(), iaUtil::generateToken(), $info)) {
             empty($entry['image']) || $iaPicture->delete($entry['image']);
             // already has an assigned image
             $entry['image'] = $image;
         }
     }
     return true;
 }
 /**
  * Process image types here and returns filename to write
  *
  * @param array $aFile uploaded file information
  * @param string $folder the file path
  * @param string $aName the file name
  * @param array $imageInfo image information array: width, height, resize_mode
  *
  * @return bool|string
  * @throws ImageWorkshopException
  * @throws Exception
  */
 public function processImage($aFile, $folder, $aName, $imageInfo)
 {
     $ext = self::_getImageExt($aFile['type']);
     if (empty($ext)) {
         $this->setMessage(iaLanguage::getf('file_type_error', array('extension' => implode(', ', array_unique(self::$_typesMap)))));
         return false;
     }
     try {
         $path = IA_UPLOADS . $folder;
         $image = ImageWorkshop::initFromPath($aFile['tmp_name']);
         // save source image
         $image->save($path, self::SOURCE_PREFIX . $aName . $ext);
         // process thumbnails for files uploaded in CKEditor and other tools
         if (empty($imageInfo)) {
             // apply watermark
             $image = self::_applyWaterMark($image);
             $image->save($path, self::_createFilename($aName, $ext));
             return true;
         }
         // check this is an animated GIF
         if (self::ALLOW_ANIMATED_GIFS && 'image/gif' == $aFile['type']) {
             require_once IA_INCLUDES . 'phpimageworkshop' . IA_DS . 'Core' . IA_DS . 'GifFrameExtractor.php';
             $gifPath = $aFile['tmp_name'];
             if (GifFrameExtractor\GifFrameExtractor::isAnimatedGif($gifPath)) {
                 // Extractions of the GIF frames and their durations
                 $gfe = new GifFrameExtractor\GifFrameExtractor();
                 $frames = $gfe->extract($gifPath);
                 // For each frame, we add a watermark and we resize it
                 $retouchedFrames = array();
                 $thumbFrames = array();
                 foreach ($frames as $frame) {
                     $frameLayer = ImageWorkshop::initFromResourceVar($frame['image']);
                     $thumbLayer = ImageWorkshop::initFromResourceVar($frame['image']);
                     $frameLayer->resizeInPixel($imageInfo['image_width'], $imageInfo['image_height'], true);
                     $frameLayer = self::_applyWaterMark($frameLayer);
                     $retouchedFrames[] = $frameLayer->getResult();
                     $thumbLayer->resizeInPixel($imageInfo['thumb_width'], $imageInfo['thumb_height'], true);
                     $thumbFrames[] = $thumbLayer->getResult();
                 }
                 // Then we re-generate the GIF
                 require_once IA_INCLUDES . 'phpimageworkshop' . IA_DS . 'Core' . IA_DS . 'GifCreator.php';
                 $gc = new GifCreator\GifCreator();
                 $gc->create($retouchedFrames, $gfe->getFrameDurations(), 0);
                 file_put_contents($path . self::_createFilename($aName, $ext), $gc->getGif());
                 $thumbCreator = new GifCreator\GifCreator();
                 $thumbCreator->create($thumbFrames, $gfe->getFrameDurations(), 0);
                 file_put_contents($path . self::_createFilename($aName, $ext, true), $thumbCreator->getGif());
                 return self::_createFilename($folder . $aName, $ext, true);
             }
         }
         // save full image
         $largestSide = $imageInfo['image_width'] > $imageInfo['image_height'] ? $imageInfo['image_width'] : $imageInfo['image_height'];
         if ($largestSide) {
             $image->resizeByLargestSideInPixel($largestSide, true);
         }
         $image = self::_applyWaterMark($image);
         $image->save($path, self::_createFilename($aName, $ext));
         // generate thumbnail
         $thumbWidth = $imageInfo['thumb_width'] ? $imageInfo['thumb_width'] : $this->iaCore->get('thumb_w');
         $thumbHeight = $imageInfo['thumb_height'] ? $imageInfo['thumb_height'] : $this->iaCore->get('thumb_h');
         if ($thumbWidth || $thumbHeight) {
             $thumb = ImageWorkshop::initFromPath($aFile['tmp_name']);
             switch ($imageInfo['resize_mode']) {
                 case self::FIT:
                     $thumb->resizeInPixel($thumbWidth, $thumbHeight, true, 0, 0, 'MM');
                     break;
                 case self::CROP:
                     $largestSide = $thumbWidth > $thumbHeight ? $thumbWidth : $thumbHeight;
                     $thumb->cropMaximumInPixel(0, 0, 'MM');
                     $thumb->resizeInPixel($largestSide, $largestSide);
                     $thumb->cropInPixel($thumbWidth, $thumbHeight, 0, 0, 'MM');
             }
             $thumb->save($path, self::_createFilename($aName, $ext, true));
         }
     } catch (Exception $e) {
         $this->iaView->setMessages(iaLanguage::get('invalid_image_file'));
         return false;
     }
     return self::_createFilename($folder . $aName, $ext, true);
 }
Exemple #29
0
 private function _resendRegistrationEmail()
 {
     $output = array('message' => iaLanguage::get('invalid_params'), 'result' => false);
     if (isset($_POST['id']) && is_numeric($_POST['id'])) {
         $member = $this->_iaDb->row(iaDb::ALL_COLUMNS_SELECTION, iaDb::convertIds($_POST['id']));
         if ($member && iaUsers::STATUS_UNCONFIRMED == $member['status']) {
             $password = $this->getHelper()->createPassword();
             $passwordHash = $this->getHelper()->encodePassword($password);
             if ($this->_iaDb->update(array('password' => $passwordHash), iaDb::convertIds($member['id']))) {
                 $this->getHelper()->sendRegistrationEmail($member['id'], $password, $member);
                 $output['message'] = iaLanguage::get('registration_email_resent');
                 $output['result'] = true;
             }
         }
     }
     return $output;
 }
Exemple #30
0
 private function _importPage(&$iaView)
 {
     if (isset($_POST['import'])) {
         $filename = isset($_POST['sqlfile']) ? $_POST['sqlfile'] : '';
         $extension = '';
         if ($_FILES) {
             $filename = $_FILES['sql_file']['tmp_name'];
             $extension = end(explode('.', $_FILES['sql_file']['name']));
         }
         if (!is_file($filename)) {
             $this->_error = true;
             $this->addMessage('no_file');
         } elseif ($extension && 'sql' != $extension) {
             $this->_error = true;
             $this->addMessage(iaLanguage::getf('cant_open_incorrect_format', array('filename' => $filename)), false);
         } elseif (!($f = fopen($filename, 'r'))) {
             $this->_error = true;
             $this->addMessage(iaLanguage::getf('cant_open_sql', array('filename' => $filename)), false);
         } else {
             $sql = '';
             while ($s = fgets($f, 10240)) {
                 $s = trim($s);
                 if ($s) {
                     if ($s[0] == '#' || $s[0] == '') {
                         continue;
                     }
                 } else {
                     continue;
                 }
                 if ($s[strlen($s) - 1] == ';') {
                     $sql .= $s;
                 } else {
                     $sql .= $s;
                     continue;
                 }
                 $this->_iaDb->query(str_replace('{prefix}', $this->_iaDb->prefix, $sql));
                 $sql = '';
             }
             fclose($f);
             $this->addMessage('upgrade_completed');
             $this->_iaCore->iaCache->clearAll();
         }
     }
     // generate list of available folders for dump files
     $dumpFolders = array('Updates' => IA_HOME . 'updates' . IA_DS);
     $packages = $this->_iaDb->onefield('name', "`type` = 'package' AND `status` = 'active'", null, null, 'extras');
     foreach ($packages as $package) {
         $dumpFolders[iaLanguage::get($package)] = IA_PACKAGES . $package . IA_DS . 'includes' . IA_DS . 'dumps' . IA_DS;
     }
     // generate list of available dump files
     $dumpFiles = array();
     foreach ($dumpFolders as $name => $path) {
         if (is_dir($path)) {
             $files = scandir($path);
             foreach ($files as $file) {
                 if (substr($file, 0, 1) != '.' && is_file($path . $file)) {
                     $dumpFiles[$name][] = array('filename' => $path . $file, 'title' => substr($file, 0, count($file) - 5));
                 }
             }
         }
     }
     $iaView->assign('dumpFiles', $dumpFiles);
 }