Ejemplo n.º 1
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());
 }
Ejemplo n.º 2
0
 protected function _indexPage(&$iaView)
 {
     // set default template
     if (isset($_POST['install']) || isset($_POST['reinstall'])) {
         if ($this->_installTemplate()) {
             $iaView->setMessages(iaLanguage::getf('template_installed', array('name' => $this->getHelper()->title)), iaView::SUCCESS);
             $this->_iaCore->iaCache->clearAll();
             $this->_iaCore->factory('log')->write(iaLog::ACTION_INSTALL, array('type' => 'template', 'name' => $this->getHelper()->title));
             iaUtil::go_to(IA_SELF);
         }
     }
     // download template
     if (isset($_POST['download'])) {
         if ($this->_downloadTemplate()) {
             $this->_iaCore->iaCache->remove('subrion_templates.inc');
         }
     }
     $templates = $this->_getList();
     if ($this->_messages) {
         $iaView->setMessages($this->_messages, $this->_error ? iaView::ERROR : iaView::SUCCESS);
     }
     $iaView->assign('templates', $templates);
     $iaView->assign('tmpl', $this->_iaCore->get('tmpl'));
 }
Ejemplo n.º 3
0
 private function _processAction(&$iaView)
 {
     $iaAcl = $this->_iaCore->factory('acl');
     $iaLog = $this->_iaCore->factory('log');
     $package = iaSanitize::sql($this->_iaCore->requestPath[0]);
     $action = $this->_iaCore->requestPath[1];
     $error = false;
     switch ($action) {
         case 'activate':
         case 'deactivate':
             if (!$iaAcl->isAccessible($this->getName(), 'activate')) {
                 return iaView::accessDenied();
             }
             if ($this->_activate($package, 'deactivate' == $action)) {
                 $type = 'deactivate' == $action ? iaLog::ACTION_DISABLE : iaLog::ACTION_ENABLE;
                 $iaLog->write($type, array('type' => iaExtra::TYPE_PACKAGE, 'name' => $package), $package);
             } else {
                 $error = true;
             }
             break;
         case 'set_default':
             if (!$iaAcl->isAccessible($this->getName(), $action)) {
                 return iaView::accessDenied();
             }
             $error = !$this->_setDefault($package);
             break;
         case 'reset':
             if (!$iaAcl->isAccessible($this->getName(), 'set_default')) {
                 return iaView::accessDenied();
             }
             $error = !$this->_reset($iaView->domain);
             break;
         case iaExtra::ACTION_INSTALL:
         case iaExtra::ACTION_UPGRADE:
             if (!$iaAcl->isAccessible($this->getName(), $action)) {
                 return iaView::accessDenied();
             }
             if ($this->_install($package, $action, $iaView->domain)) {
                 // log this event
                 $action = $this->getHelper()->isUpgrade ? iaLog::ACTION_UPGRADE : iaLog::ACTION_INSTALL;
                 $iaLog->write($action, array('type' => iaExtra::TYPE_PACKAGE, 'name' => $package, 'to' => $this->getHelper()->itemData['info']['version']), $package);
                 //
                 $iaSitemap = $this->_iaCore->factory('sitemap', iaCore::ADMIN);
                 $iaSitemap->generate();
             } else {
                 $error = true;
             }
             break;
         case iaExtra::ACTION_UNINSTALL:
             if (!$iaAcl->isAccessible($this->getName(), $action)) {
                 return iaView::accessDenied();
             }
             if ($this->_uninstall($package)) {
                 $iaLog->write(iaLog::ACTION_UNINSTALL, array('type' => iaExtra::TYPE_PACKAGE, 'name' => $package), $package);
             } else {
                 $error = true;
             }
     }
     $this->_iaCore->iaCache->clearAll();
     $iaView->setMessages($this->getMessages(), $error ? iaView::ERROR : iaView::SUCCESS);
     iaUtil::go_to($this->getPath());
 }
 protected function _reopen($option, $action)
 {
     $options = array('add' => $this->getPath() . 'add/', 'list' => $this->getPath(), 'stay' => $this->getPath() . 'edit/' . $this->getEntryId() . '/');
     $option = isset($options[$option]) ? $option : 'list';
     if (iaCore::ACTION_EDIT == $action && 'stay' != $option || iaCore::ACTION_ADD == $action) {
         $this->_iaCore->factory('util');
         iaUtil::go_to($options[$option]);
     }
 }
Ejemplo n.º 5
0
         } else {
             $iaView->assign('pay_message', iaLanguage::getf('wait_for_gateway_answer', array('url' => IA_SELF . '?repay')));
         }
         break;
     case iaTransaction::PASSED:
         if ('ipn' == $action) {
             $iaTransaction->createIpn($transaction);
         } else {
             $iaView->setMessages(iaLanguage::get('this_transaction_already_passed'), iaView::ALERT);
             iaUtil::go_to($iaPage->getUrlByName('member_funds'));
         }
         break;
     case iaTransaction::REFUNDED:
     case iaTransaction::FAILED:
         $iaView->setMessages($messages);
         iaUtil::go_to($iaPage->getUrlByName('member_funds'));
         break;
     default:
         $error = true;
         $messages[] = 'Unknown status';
 }
 $iaView->setMessages($messages, $error ? iaView::ERROR : iaView::SUCCESS);
 $memberBalance = iaUsers::hasIdentity() ? iaUsers::getIdentity()->funds : 0;
 iaLanguage::set('funds_in_your_account', iaLanguage::getf('funds_in_your_account', array('sum' => $memberBalance, 'currency' => $iaCore->get('currency'))));
 $isBalancePayment = iaUsers::hasIdentity() && iaTransaction::TRANSACTION_MEMBER_BALANCE == $transaction['item'] && iaUsers::getIdentity()->id == $transaction['item_id'];
 $isFundsEnough = (bool) (!$isBalancePayment && iaUsers::hasIdentity() && iaUsers::getIdentity()->funds >= $transaction['amount']);
 // FIXME: solution to prevent csrf catching.
 // Should be replaced once it is possible to disable csrf checking for a single page.
 if (isset($_POST)) {
     $paymentPost = $_POST;
     if (isset($_SERVER['HTTP_ORIGIN'])) {
Ejemplo n.º 6
0
                            $results['num'] += count($array);
                            $results['html'][$i] = implode('', $array);
                        }
                    }
                }
                $start = $start > 0 ? $start + $results['num'] - $results['all'] : $start;
                $limit = $results['num'] < $limit ? $limit - $results['num'] : 0;
            }
        }
    }
    if ($results['all']) {
        if (isset($_POST['q'])) {
            $search['terms'] = serialize($search['terms']);
            $searchId = $iaDb->insert($search, array('time' => 'UNIX_TIMESTAMP()'));
            $url = IA_URL . ($adv ? 'adv' : '') . 'search/?id=' . $searchId;
            iaUtil::go_to($url);
        }
    }
    // searched terms for additional fields
    if ($fields && $search['terms']['items']) {
        foreach ($search['terms']['items'] as $i => $f) {
            foreach ($f as $fname => $fval) {
                $fields[$i][$fname]['val'] = iaSanitize::html($fval['val']);
                $fields[$i][$fname]['cond'] = $fval['cond'];
            }
        }
    }
}
$iaDb->resetTable();
$iaView->assign('items', $adv ? array_keys($items) : array());
$iaView->assign('adv', $adv);
Ejemplo n.º 7
0
     $tags = iaCore::ACTION_ADD == $pageAction ? '' : $iaBlog->getTagsString($id);
     $iaView->assign('item', $entry);
     $iaView->assign('tags', $tags);
     break;
 case iaCore::ACTION_DELETE:
     if (1 != count($iaCore->requestPath)) {
         return iaView::errorPage(iaView::ERROR_NOT_FOUND);
     }
     $id = (int) $iaCore->requestPath[0];
     $entry = $iaDb->row(iaDb::ALL_COLUMNS_SELECTION, iaDb::convertIds($id));
     if (!$entry) {
         return iaView::errorPage(iaView::ERROR_NOT_FOUND);
     }
     $result = $iaBlog->delete($id);
     $iaView->setMessages(iaLanguage::get($result ? 'deleted' : 'db_error'), $result ? iaView::SUCCESS : iaView::ERROR);
     iaUtil::go_to($baseUrl);
     break;
 default:
     $iaView->display('index');
     $pageActions = array();
     if (isset($iaCore->requestPath[0])) {
         $id = (int) $iaCore->requestPath[0];
         if (!$id) {
             return iaView::errorPage(iaView::ERROR_NOT_FOUND);
         }
         $entry = $iaBlog->getById($id);
         if (empty($entry)) {
             return iaView::errorPage(iaView::ERROR_NOT_FOUND);
         }
         $title = iaSanitize::tags($entry['title']);
         iaBreadcrumb::toEnd($title);
Ejemplo n.º 8
0
 protected function _indexPage(&$iaView)
 {
     if ('phrases' == $iaView->get('name')) {
         iaBreadcrumb::preEnd(iaLanguage::get('languages'), IA_ADMIN_URL . 'languages/');
         $iaView->assign('action', 'phrases');
         $iaView->display('languages');
         return true;
     }
     $action = isset($this->_iaCore->requestPath[0]) ? $this->_iaCore->requestPath[0] : 'list';
     $iaView->assign('action', $action);
     switch ($action) {
         case 'search':
             $pageCaption = iaLanguage::get('search_in_phrases');
             break;
         case 'download':
             $pageCaption = iaLanguage::get('export_language');
             if (isset($_POST['lang']) && $_POST['lang'] || isset($this->_iaCore->requestPath[1]) && array_key_exists($this->_iaCore->requestPath[1], $this->_iaCore->languages)) {
                 $this->_downloadLanguage($iaView);
             }
             break;
         case 'comparison':
             $pageCaption = iaLanguage::get('languages_comparison');
             $this->_compareLanguages($iaView);
             break;
         case 'rm':
             // TODO: set checkAccess
             $this->_removeLanguage($iaView);
             iaUtil::go_to($this->getPath());
             break;
         case 'default':
             $this->_setLanguageAsDefault($iaView);
             iaUtil::go_to($this->getPath());
             break;
         case 'import':
             $result = $this->_importLanguage($iaView);
             iaUtil::go_to($this->getPath() . ($result ? '' : 'download/'));
             break;
     }
     if (isset($pageCaption)) {
         iaBreadcrumb::toEnd($pageCaption, IA_SELF);
         $iaView->title($pageCaption);
     }
 }
Ejemplo n.º 9
0
 private function _previewPage($action)
 {
     if (iaCore::ACTION_ADD == $action) {
         $_POST['save'] = true;
     } else {
         iaUtil::loadUTF8Functions('ascii', 'validation', 'bad', 'utf8_to_ascii');
         $newPage = array();
         $name = strtolower($_POST['name'] = !utf8_is_ascii($_POST['name']) ? utf8_to_ascii($_POST['name']) : $_POST['name']);
         if (isset($_POST['contents']) && is_array($_POST['contents'])) {
             function utf8_validation(&$item)
             {
                 $item = !utf8_is_valid($item) ? utf8_bad_replace($item) : $item;
             }
             foreach ($_POST['contents'] as $key => $content) {
                 utf8_validation($_POST['contents'][$key]);
             }
             $newPage['contents'] = $_POST['contents'];
         }
         $newPage['titles'] = $_POST['titles'];
         $newPage['passw'] = iaSanitize::sql($_POST['passw']);
         isset($_SESSION['preview_pages']) || ($_SESSION['preview_pages'] = array());
         $_SESSION['preview_pages'][$name] = $newPage;
         $languagesEnabled = $this->_iaCore->get('language_switch', false) && count($this->_iaCore->languages);
         $redirectUrl = IA_CLEAR_URL . ($languagesEnabled ? $_POST['language'] . IA_URL_DELIMITER : '') . 'page' . IA_URL_DELIMITER . $name . IA_URL_DELIMITER . '?preview';
         iaUtil::go_to($redirectUrl);
     }
 }
Ejemplo n.º 10
0
                $info = array('image_width' => 500, 'image_height' => 500, 'thumb_width' => 150, 'thumb_height' => 150, 'resize_mode' => iaPicture::CROP);
                if ($image = $iaPicture->processImage($_FILES['image'], '', iaUtil::generateToken(), $info)) {
                    empty($guestbook['avatar']) || $iaPicture->delete($guestbook['avatar']);
                    // already has an assigned image
                    $guestbook['avatar'] = $image;
                }
            }
            if (isset($_POST['status'])) {
                $guestbook['status'] = isset($_POST['status']) && !empty($_POST['status']) && in_array($_POST['status'], array(iaCore::STATUS_ACTIVE, iaCore::STATUS_INACTIVE)) ? $_POST['status'] : 'inactive';
            }
            if (isset($_POST['email']) && iaValidate::isEmail($_POST['email'])) {
                $guestbook['email'] = $_POST['email'];
            }
            if (!$error && iaCore::ACTION_EDIT == $pageAction) {
                $id = $guestbook['id'] = (int) $iaCore->requestPath[0];
                $result = $iaDb->update($guestbook);
                $messages[] = iaLanguage::get('saved');
                if ($result) {
                    $iaCore->factory('log')->write(iaLog::ACTION_UPDATE, array('item' => '', 'name' => iaLanguage::get('guestbook_message'), 'id' => $id, 'module' => 'guestbook'));
                }
            }
            $iaView->setMessages($messages, $error ? iaView::ERROR : iaView::SUCCESS);
            iaUtil::go_to(IA_ADMIN_URL . 'guestbook/');
        }
        $iaView->assign('guestbook', $guestbook);
        $iaView->display('index');
    } else {
        $iaView->grid('_IA_URL_plugins/guestbook/js/admin/index');
    }
}
$iaDb->resetTable();
                    }
                    if (!utf8_is_ascii($data['title_alias'])) {
                        $data['title_alias'] = utf8_to_ascii($data['title_alias']);
                    }
                }
                $data['title_alias'] = $iaCore->convertStr($data['title_alias']);
                if (empty($recipecat)) {
                    $iaCore->startHook("phpAdminBeforeRecipecatAdd");
                    $data['id'] = $iaRecipecat->add($data);
                    $msg = _t('recipecat_added');
                } else {
                    $data['id'] = $recipecat['id'];
                    $iaCore->startHook("phpAdminBeforeRecipecatUpdate");
                    $iaRecipecat->update($data);
                    $msg = _t('changes_saved');
                }
                $recipecat = $iaDb->row('*', sprintf("`id`=%d", $data['id']));
                $iaCore->msg($msg, $error ? 'error' : 'success');
                if (isset($_POST['goto'])) {
                    iaUtil::go_to(IA_ADMIN_URL . 'manage/recipecats/' . ($_POST['goto'] == 'add' ? 'add/' : ''));
                }
            }
        }
        $fields_groups = $iaCore->getFieldsGroups();
        $iaCore->assign('fields_groups', $fields_groups);
        $iaCore->assign('recipecat', $recipecat);
        $iaCore->assign('isView', false);
        $iaCore->display('recipecats');
    }
}
$iaDb->resetTable();
Ejemplo n.º 12
0
         } else {
             $iaView->assign('pay_message', iaLanguage::getf('wait_for_gateway_answer', array('url' => IA_SELF . '?repay')));
         }
         break;
     case iaTransaction::PASSED:
         if ('ipn' == $action) {
             $iaTransaction->createIpn($transaction);
         } else {
             $iaView->setMessages(iaLanguage::get('this_transaction_already_passed'), iaView::ALERT);
             iaUtil::go_to($iaPage->getUrlByName('member_balance'));
         }
         break;
     case iaTransaction::REFUNDED:
     case iaTransaction::FAILED:
         $iaView->setMessages($messages);
         iaUtil::go_to($iaPage->getUrlByName('member_balance'));
         break;
     default:
         $error = true;
         $messages[] = 'Unknown status';
 }
 $iaView->setMessages($messages, $error ? iaView::ERROR : iaView::SUCCESS);
 $memberBalance = iaUsers::hasIdentity() ? iaUsers::getIdentity()->funds : 0;
 iaLanguage::set('balance_in_your_account', iaLanguage::getf('balance_in_your_account', array('sum' => $memberBalance, 'currency' => $iaCore->get('currency'))));
 $isBalancePayment = iaUsers::hasIdentity() && 'balance' == $transaction['item'] && iaUsers::getIdentity()->id == $transaction['item_id'];
 $isFundsEnough = (bool) (!$isBalancePayment && iaUsers::hasIdentity() && iaUsers::getIdentity()->funds >= $transaction['amount']);
 // FIXME: solution to prevent csrf catching.
 // Should be replaced once it is possible to disable csrf checking for a single page.
 if (isset($_POST)) {
     $paymentPost = $_POST;
     if (isset($_SERVER['HTTP_ORIGIN'])) {
Ejemplo n.º 13
0
}
if (iaView::REQUEST_HTML == $iaView->getRequestType()) {
    if (iaCore::ACTION_ADD == $pageAction) {
        $html = 0;
        if (isset($_POST['save'])) {
            if ($_POST['type'] == 'text') {
                $body = str_replace("'", "\\'", $_POST['body']);
            } else {
                $body = str_replace("'", "\\'", $_POST['html_body']);
                $html = 1;
            }
            list($error, $msg) = $iaMailerPlugin->createQueue($_POST['from_name'], $_POST['from_mail'], $_POST['subj'], $body, $html, $_POST['groups'], $_POST['st']);
            $iaView->setMessages($msg, $error ? iaView::ERROR : iaView::SUCCESS);
            if (!$error) {
                $iaUtil = iaCore::util();
                iaUtil::go_to(IA_ADMIN_URL . 'mailer/');
            }
        }
        if (empty($_POST)) {
            $data = array('from_name' => iaUsers::getIdentity()->fullname, 'from_mail' => iaUsers::getIdentity()->email, 'type' => 'html', 'subj' => '', 'body' => '');
        } else {
            $data = $_POST;
        }
        $statuses = $iaMailerPlugin->getAccountsStatusList();
        $iaView->assign('data', $data);
        $iaView->assign('statuses', $statuses);
        $iaView->assign('usergroups', $iaCore->factory('users')->getUsergroups());
        $iaView->assign('check', !empty($_POST['type']) && 'html' == $_POST['type'] ? true : false);
    } else {
        if ($queue = $iaMailerPlugin->getQueues()) {
            $iaView->assign('queue', $queue);
Ejemplo n.º 14
0
<?php

//##copyright##
if (iaView::REQUEST_HTML == $iaView->getRequestType()) {
    // affiliate member id
    $memberId = isset($iaCore->requestPath[0]) ? (int) $iaCore->requestPath[0] : 0;
    // affiliate product id used for tracking
    $productId = isset($iaCore->requestPath[1]) ? (int) $iaCore->requestPath[1] : 0;
    // check referer
    $visitorReferrer = getenv('HTTP_REFERER');
    if ($memberId) {
        $iaVisitor = $iaCore->factoryPackage('visitor', IA_CURRENT_PACKAGE);
        // get unique tracking ID for a visitor in case it's not set
        $trackingSalt = isset($_COOKIE['IA_AFF_TRACKING']) ? $_COOKIE['IA_AFF_TRACKING'] : $memberId . iaUtil::generateToken(20);
        // update tracking record
        $iaVisitor->updateTrackingRecords($trackingSalt, $memberId, $productId, $visitorReferrer);
    }
    // redirect to the page
    $redirectUrl = $iaCore->get('aff_incoming_page', IA_URL);
    if ($productId) {
        $redirectUrl = $iaDb->one('`url`', iaDb::convertIds($productId), 'affiliates_products');
    }
    iaUtil::go_to($redirectUrl);
}
Ejemplo n.º 15
0
 private function _checkForUpdates()
 {
     $url = sprintf(iaUtil::REMOTE_TOOLS_URL . 'get/updates/%s/', IA_VERSION);
     $content = iaUtil::getPageContent($url);
     if (!$content) {
         return;
     }
     $content = iaUtil::jsonDecode($content);
     if (is_array($content) && $content) {
         $messages = array();
         foreach ($content as $entry) {
             switch ($entry['type']) {
                 case self::UPDATE_TYPE_INFO:
                     $messages[] = array($entry['id'], $entry['message']);
                     break;
                 case self::UPDATE_TYPE_PATCH:
                     $version = explode('.', $entry['version']);
                     if (count($version) > 3) {
                         if ($this->_iaCore->get('auto_apply_critical_upgrades')) {
                             $result = iaSystem::forceUpgrade($entry['version']);
                             if (is_bool($result) && $result) {
                                 $this->_iaCore->factory('cache')->clearGlobalCache();
                                 $message = iaLanguage::getf('script_upgraded', array('version' => $entry['version']));
                                 $this->_iaCore->iaView->setMessages($message, iaView::SUCCESS);
                                 iaUtil::go_to(IA_SELF);
                             } else {
                                 iaDebug::debug($result, 'Forced upgrade to the version ' . $entry['version']);
                             }
                         }
                     } else {
                         $url = sprintf('%sinstall/upgrade/check/%s/', IA_CLEAR_URL, $entry['version']);
                         $this->_iaCore->iaView->setMessages(iaLanguage::getf('upgrade_available', array('url' => $url, 'version' => $entry['version'])), iaView::SYSTEM);
                     }
             }
         }
         $this->_iaCore->iaView->assign('updatesInfo', $messages);
     }
 }
Ejemplo n.º 16
0
         $messages[] = iaLanguage::get('incorrect_file');
     }
     if (file_exists($file['path'] . $file['name'])) {
         $error = true;
         $messages[] = iaLanguage::get('file_already_exists');
     }
     if (!fopen($file['url'], 'r')) {
         $error = true;
         $messages[] = iaLanguage::get('cant_get_file');
     }
     if (!$error) {
         $return = file_put_contents($file['path'] . $file['name'], fopen($file['url'], 'r'));
         if ($return) {
             $messages[] = iaLanguage::get('file_uploaded');
             $iaView->setMessages($messages, $error ? iaView::ERROR : iaView::SUCCESS);
             iaUtil::go_to(IA_ADMIN_URL . 'importer/');
         } else {
             $error = true;
             $messages[] = iaLanguage::get('upload_failed');
             $iaView->setMessages($messages, $error ? iaView::ERROR : iaView::SUCCESS);
         }
     } else {
         $iaView->setMessages($messages, $error ? iaView::ERROR : iaView::SUCCESS);
     }
 }
 if (!file_exists($file['path'])) {
     mkdir($file['path'], 0755);
 }
 $permissions = is_writable($file['path']);
 if (!$permissions) {
     $permissions = chmod($file['path'], 755);
Ejemplo n.º 17
0
 private function _save(&$iaView)
 {
     $iaAcl = $this->_iaCore->factory('acl');
     if (!$iaAcl->checkAccess($iaView->name() . iaAcl::SEPARATOR . iaCore::ACTION_EDIT)) {
         return iaView::accessDenied();
     }
     $where = "`type` != 'hidden' " . ($this->_type ? 'AND `custom` = 1' : '');
     $params = $this->_iaDb->keyvalue(array('name', 'type'), $where, iaCore::getConfigTable());
     // correct admin dashboard URL generation
     $adminPage = $this->_iaCore->get('admin_page');
     iaUtil::loadUTF8Functions('ascii', 'validation', 'bad', 'utf8_to_ascii');
     $messages = array();
     $error = false;
     if ($_POST['v'] && is_array($_POST['v'])) {
         $values = $_POST['v'];
         $this->_iaCore->startHook('phpConfigurationChange', array('configurationValues' => &$values));
         $this->_iaDb->setTable(iaCore::getConfigTable());
         foreach ($values as $key => $value) {
             $s = strpos($key, '_items_enabled');
             if ($s !== false) {
                 $p = $this->_iaCore->get($key, '', !is_null($this->_type));
                 $array = $p ? explode(',', $p) : array();
                 $data = array();
                 array_shift($value);
                 if ($diff = array_diff($value, $array)) {
                     foreach ($diff as $item) {
                         array_push($data, array('action' => '+', 'item' => $item));
                     }
                 }
                 if ($diff = array_diff($array, $value)) {
                     foreach ($diff as $item) {
                         array_push($data, array('action' => '-', 'item' => $item));
                     }
                 }
                 $extra = substr($key, 0, $s);
                 $this->_iaCore->startHook('phpPackageItemChangedForPlugin', array('data' => $data), $extra);
             }
             if (is_array($value)) {
                 $value = implode(',', $value);
             }
             if (!utf8_is_valid($value)) {
                 $value = utf8_bad_replace($value);
                 trigger_error('Bad UTF-8 detected (replacing with "?") in configuration', E_USER_NOTICE);
             }
             if (self::TYPE_IMAGE == $params[$key]) {
                 if (isset($_POST['delete'][$key])) {
                     $value = '';
                 } elseif (!empty($_FILES[$key]['name'])) {
                     if (!(bool) $_FILES[$key]['error']) {
                         if (@is_uploaded_file($_FILES[$key]['tmp_name'])) {
                             $ext = strtolower(utf8_substr($_FILES[$key]['name'], -3));
                             // if jpeg
                             if ($ext == 'peg') {
                                 $ext = 'jpg';
                             }
                             if (!array_key_exists(strtolower($_FILES[$key]['type']), $this->_imageTypes) || !in_array($ext, $this->_imageTypes, true) || !getimagesize($_FILES[$key]['tmp_name'])) {
                                 $error = true;
                                 $messages[] = iaLanguage::getf('file_type_error', array('extension' => implode(', ', array_unique($this->_imageTypes))));
                             } else {
                                 if ($this->_iaCore->get($key) && file_exists(IA_UPLOADS . $this->_iaCore->get($key))) {
                                     iaUtil::deleteFile(IA_UPLOADS . $this->_iaCore->get($key));
                                 }
                                 $value = $fileName = $key . '.' . $ext;
                                 @move_uploaded_file($_FILES[$key]['tmp_name'], IA_UPLOADS . $fileName);
                                 @chmod(IA_UPLOADS . $fileName, 0777);
                             }
                         }
                     }
                 } else {
                     $value = $this->_iaCore->get($key, '', !is_null($this->_type));
                 }
             }
             if ($this->_type) {
                 $where = sprintf("`name` = '%s' AND `type` = '%s' AND `type_id` = %d", $key, $this->_type, $this->_typeId);
                 $this->_iaDb->setTable(iaCore::getCustomConfigTable());
                 if ($_POST['c'][$key]) {
                     $values = array('name' => $key, 'value' => $value, 'type' => $this->_type, 'type_id' => $this->_typeId);
                     if ($this->_iaDb->exists($where)) {
                         unset($values['value']);
                         $this->_iaDb->bind($where, $values);
                         $this->_iaDb->update(array('value' => $value), $where);
                     } else {
                         $this->_iaDb->insert($values);
                     }
                 } else {
                     $this->_iaDb->delete($where);
                 }
                 $this->_iaDb->resetTable();
             } else {
                 $this->_iaDb->update(array('value' => $value), iaDb::convertIds($key, 'name'));
             }
         }
         $this->_iaDb->resetTable();
         $this->_iaCore->iaCache->clearAll();
     }
     if (!$error) {
         $iaView->setMessages(iaLanguage::get('saved'), iaView::SUCCESS);
         if (isset($_POST['param']['admin_page']) && $_POST['param']['admin_page'] != $adminPage) {
             iaUtil::go_to(IA_URL . $_POST['param']['admin_page'] . '/configuration/general/');
         }
     } elseif ($messages) {
         $iaView->setMessages($messages);
     }
 }
Ejemplo n.º 18
0
 protected function _htmlAction(&$iaView)
 {
     $_SESSION['manageMode'] = 'mode';
     iaUtil::go_to(IA_URL);
 }
Ejemplo n.º 19
0
 /**
  * Generates invoice for an item
  *
  * @param string $title plan title
  * @param double $cost plan cost
  * @param string $itemName item name
  * @param array $itemData item details
  * @param string $returnUrl return URL
  * @param int $planId plan id
  * @param bool $return true redirects to invoice payment URL
  *
  * @return string
  */
 public function createInvoice($title, $cost, $itemName = 'members', $itemData = array(), $returnUrl = '', $planId = 0, $return = false)
 {
     if (!isset($itemData['id'])) {
         $itemData['id'] = 0;
     }
     $title = empty($title) ? iaLanguage::get('plan_title_' . $planId) : $title;
     $title .= $itemData['id'] ? ' - #' . $itemData['id'] : '';
     $transactionId = uniqid('t');
     $transaction = array('member_id' => (int) (isset($itemData['member_id']) && $itemData['member_id'] ? $itemData['member_id'] : iaUsers::getIdentity()->id), 'item' => $itemName, 'item_id' => $itemData['id'], 'amount' => $cost, 'currency' => $this->iaCore->get('currency'), 'sec_key' => $transactionId, 'status' => self::PENDING, 'plan_id' => $planId, 'return_url' => $returnUrl, 'operation' => $title, 'date' => date(iaDb::DATETIME_FORMAT));
     $result = (bool) $this->iaDb->insert($transaction, null, $this->getTable());
     $return || iaUtil::go_to(IA_URL . 'pay' . IA_URL_DELIMITER . $transactionId . IA_URL_DELIMITER);
     return $result ? $transactionId : false;
 }
                    }
                    if (!utf8_is_ascii($data['title_alias'])) {
                        $data['title_alias'] = utf8_to_ascii($data['title_alias']);
                    }
                }
                $data['title_alias'] = $iaCore->convertStr($data['title_alias']);
                if (empty($cookbook)) {
                    $iaCore->startHook("phpAdminBeforeCookbookAdd");
                    $data['id'] = $iaCookbook->add($data);
                    $msg = _t('cookbook_added');
                } else {
                    $data['id'] = $cookbook['id'];
                    $iaCore->startHook("phpAdminBeforeCookbookUpdate");
                    $iaCookbook->update($data);
                    $msg = _t('changes_saved');
                }
                $cookbook = $iaCookbook->getCookbookById($data['id']);
                $iaCore->msg($msg, $error ? 'error' : 'success');
                if (isset($_POST['goto'])) {
                    iaUtil::go_to(IA_ADMIN_URL . 'manage/cookbooks/' . ($_POST['goto'] == 'add' ? 'add/' : ''));
                }
            }
        }
        $fields_groups = $iaCore->getFieldsGroups();
        $iaCore->assign('fields_groups', $fields_groups);
        $iaCore->assign('cookbook', $cookbook);
        $iaCore->assign('isView', false);
        $iaCore->display('cookbooks');
    }
}
$iaDb->resetTable();
Ejemplo n.º 21
0
            }
        } elseif ($_POST && empty($_POST['email'])) {
            $error = true;
            $message = iaLanguage::get('error_email_incorrect');
        }
        $iaView->assign('message', $message);
        $iaView->assign('result', !$error);
    }
}
if (iaView::REQUEST_HTML == $iaView->getRequestType()) {
    if (!$iaCore->get('members_enabled')) {
        return iaView::errorPage(iaView::ERROR_NOT_FOUND);
    }
    $iaCore->factory('util');
    if (iaUsers::hasIdentity()) {
        iaUtil::go_to(IA_URL . 'profile/');
    }
    $memberId = null;
    $error = false;
    $messages = array();
    $itemData = array();
    if ('member_password_forgot' == $iaView->name()) {
        $code = isset($_GET['code']) ? trim($_GET['code']) : false;
        $email = isset($_POST['email']) ? $_POST['email'] : (isset($_GET['email']) ? $_GET['email'] : '');
        $form = false === $code ? 'request' : 'confirm';
        if ($email) {
            if ($form != 'confirm' && !iaValidate::isCaptchaValid()) {
                $error = true;
                $messages[] = iaLanguage::get('confirmation_code_incorrect');
            }
            if (!iaValidate::isEmail($email)) {
Ejemplo n.º 22
0
 private function _buildSitemap(&$iaView)
 {
     $iaSitemap = $this->_iaCore->factory('sitemap', iaCore::ADMIN);
     $iaSitemap->generate() ? $iaView->setMessages(iaLanguage::getf('sitemap_regenerated', array('url' => IA_CLEAR_URL . iaSitemap::FILENAME)), iaView::SUCCESS) : $iaView->setMessages(iaLanguage::get('sitemap_error'));
     if (isset($_SERVER['HTTP_REFERER'])) {
         iaUtil::go_to($_SERVER['HTTP_REFERER']);
     }
 }