コード例 #1
0
ファイル: Model.php プロジェクト: Umz/ImpressPages
 private static function generatePasswordResetSecret($userId)
 {
     $secret = md5(ipConfig()->get('sessionName') . uniqid());
     $data = array('resetSecret' => $secret, 'resetTime' => time());
     ipDb()->update('administrator', $data, array('id' => $userId));
     return $secret;
 }
コード例 #2
0
ファイル: Event.php プロジェクト: Umz/ImpressPages
 protected static function initConfig()
 {
     ipAddCss('Ip/Internal/Core/assets/admin/admin.css');
     ipAddJs('Ip/Internal/Core/assets/js/jquery-ui/jquery-ui.js');
     ipAddJsVariable('ipTranslationSaving', __('Saving...', 'Ip-admin', false));
     ipAddJs('Ip/Internal/Design/assets/optionsBox.js');
     ipAddJsVariable('ipModuleDesignConfiguration', Helper::getConfigurationBoxHtml());
     if (file_exists(ipThemeFile(Model::INSTALL_DIR . 'Options.js'))) {
         ipAddJs(ipThemeUrl(Model::INSTALL_DIR . 'Options.js'));
     } elseif (file_exists(ipThemeFile(Model::INSTALL_DIR . 'options.js'))) {
         ipAddJs(ipThemeUrl(Model::INSTALL_DIR . 'options.js'));
     }
     $model = Model::instance();
     $theme = $model->getTheme(ipConfig()->theme());
     if (!$theme) {
         throw new \Ip\Exception("Theme doesn't exist");
     }
     $options = $theme->getOptionsAsArray();
     $fieldNames = array();
     foreach ($options as $option) {
         if (empty($option['name'])) {
             continue;
         }
         $fieldNames[] = $option['name'];
     }
     ipAddJsVariable('ipModuleDesignOptionNames', $fieldNames);
 }
コード例 #3
0
ファイル: Antispam.php プロジェクト: Umz/ImpressPages
    /**
     * Render field
     *
     * @param string $doctype
     * @param $environment
     * @return string
     */
    public function render($doctype, $environment)
    {
        return '
<input ' . $this->getAttributesStr($doctype) . ' style="display:none;" class="' . implode(' ', $this->getClasses()) . '" name="' . htmlspecialchars($this->getName()) . '[]"  ' . $this->getValidationAttributesStr($doctype) . ' type="hidden" value="" />
<input ' . $this->getAttributesStr($doctype) . ' style="display:none;" class="' . implode(' ', $this->getClasses()) . '" name="' . htmlspecialchars($this->getName()) . '[]"  ' . $this->getValidationAttributesStr($doctype) . ' type="hidden" value="' . htmlspecialchars(md5(date('Y-m-d') . ipConfig()->get('sessionName'))) . '" />
';
    }
コード例 #4
0
ファイル: Db.php プロジェクト: Umz/ImpressPages
 /**
  * Get database connection object
  *
  * @throws \Ip\Exception\Db
  * @return \PDO
  */
 public function getConnection()
 {
     if ($this->pdoConnection) {
         return $this->pdoConnection;
     }
     $dbConfig = ipConfig()->get('db');
     ipConfig()->set('db', null);
     if (empty($dbConfig)) {
         throw new \Ip\Exception\Db("Can't connect to database. No connection config found or \\Ip\\Db::disconnect() has been used.");
     }
     try {
         if (array_key_exists('driver', $dbConfig) && $dbConfig['driver'] == 'sqlite') {
             $dsn = 'sqlite:' . $dbConfig['database'];
             $this->pdoConnection = new \PDO($dsn);
             $this->pdoConnection->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
         } else {
             $dsn = 'mysql:host=' . str_replace(':', ';port=', $dbConfig['hostname']);
             if (!empty($dbConfig['database'])) {
                 $dsn .= ';dbname=' . $dbConfig['database'];
             }
             $this->pdoConnection = new \PDO($dsn, $dbConfig['username'], $dbConfig['password']);
             $this->pdoConnection->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
             $dt = new \DateTime();
             $offset = $dt->format("P");
             $this->pdoConnection->exec("SET time_zone='{$offset}';");
             $this->pdoConnection->exec("SET CHARACTER SET " . $dbConfig['charset']);
         }
     } catch (\PDOException $e) {
         throw new \Ip\Exception\Db("Can't connect to database. Stack trace hidden for security reasons");
         //PHP traces all details of error including DB password. This could be a disaster on live server. So we hide that data.
     }
     $this->tablePrefix = $dbConfig['tablePrefix'];
     return $this->pdoConnection;
 }
コード例 #5
0
 /**
  * @ignore
  * @param int $callLevel
  * @return string
  * @throws \Ip\Exception
  */
 public static function ipRelativeDir($callLevel = 0)
 {
     $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, $callLevel + 1);
     if (!isset($backtrace[$callLevel]['file'])) {
         throw new \Ip\Exception("Can't find caller");
     }
     $absoluteFile = $backtrace[$callLevel]['file'];
     if (DIRECTORY_SEPARATOR == '\\') {
         // Replace windows paths
         $absoluteFile = str_replace('\\', '/', $absoluteFile);
     }
     $overrides = ipConfig()->get('fileOverrides');
     if ($overrides) {
         foreach ($overrides as $relativePath => $fullPath) {
             if (DIRECTORY_SEPARATOR == '\\') {
                 // Replace windows paths
                 $fullPath = str_replace('\\', '/', $fullPath);
             }
             if (strpos($absoluteFile, $fullPath) === 0) {
                 $relativeFile = substr_replace($absoluteFile, $relativePath, 0, strlen($fullPath));
                 return substr($relativeFile, 0, strrpos($relativeFile, '/') + 1);
             }
         }
     }
     $baseDir = ipConfig()->get('baseDir');
     $baseDir = str_replace('\\', '/', $baseDir);
     if (strpos($absoluteFile, $baseDir) !== 0) {
         throw new \Ip\Exception('Cannot find relative path for file ' . esc($absoluteFile));
     }
     $relativeFile = substr($absoluteFile, strlen($baseDir) + 1);
     return substr($relativeFile, 0, strrpos($relativeFile, '/') + 1);
 }
コード例 #6
0
ファイル: Worker.php プロジェクト: sspaeti/ImpressPages
 public function activate()
 {
     $table = ipTable('comments');
     $sql = "\n        CREATE TABLE IF NOT EXISTS\n           " . $table . "\n        (\n\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t  `language_id` int(11) NOT NULL,\n\t\t  `zone_name` varchar(255) NOT NULL,\n\t\t  `user_id` int(11) DEFAULT NULL,\n\t\t  `name` varchar(255) NOT NULL,\n\t\t  `email` varchar(255) DEFAULT NULL,\n\t\t  `link` varchar(255) DEFAULT NULL,\n\t\t  `text` text NOT NULL,\n\t\t  `ip` varchar(39) NOT NULL,\n\t\t  `approved` tinyint(1) NOT NULL,\n\t\t  `session_id` varchar(255) NOT NULL,\n\t\t  `verification_code` varchar(32) NOT NULL,\n\t\t  `active` tinyint(1) DEFAULT 0,\n\t\t  PRIMARY KEY (`id`),\n\t\t  KEY `user_id` (`user_id`)\n        )";
     ipDb()->execute($sql);
     //add title column if not exist
     $checkSql = "\n        SELECT\n          *\n        FROM\n          information_schema.COLUMNS\n        WHERE\n            TABLE_SCHEMA = :database\n            AND TABLE_NAME = :table\n            AND COLUMN_NAME = :column\n        ";
     $result = ipDb()->fetchAll($checkSql, array('database' => ipConfig()->database(), 'table' => ipConfig()->tablePrefix() . 'comments', 'column' => 'createdAt'));
     if (!$result) {
         $sql = "ALTER TABLE {$table} ADD `createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP;";
         ipDb()->execute($sql);
     }
     $result = ipDb()->fetchAll($checkSql, array('database' => ipConfig()->database(), 'table' => ipConfig()->tablePrefix() . 'comments', 'column' => 'modifiedAt'));
     if (!$result) {
         $sql = "ALTER TABLE {$table} ADD `modifiedAt` timestamp NULL DEFAULT NULL;";
         ipDb()->execute($sql);
     }
     $result = ipDb()->fetchAll($checkSql, array('database' => ipConfig()->database(), 'table' => ipConfig()->tablePrefix() . 'comments', 'column' => 'lastActiveAt'));
     if (!$result) {
         $sql = "ALTER TABLE {$table} ADD `lastActiveAt` timestamp NULL DEFAULT NULL;";
         ipDb()->execute($sql);
     }
     $result = ipDb()->fetchAll($checkSql, array('database' => ipConfig()->database(), 'table' => ipConfig()->tablePrefix() . 'comments', 'column' => 'isDeleted'));
     if (!$result) {
         $sql = "ALTER TABLE {$table} ADD `isDeleted` INT(1) NOT NULL DEFAULT 0;";
         ipDb()->execute($sql);
     }
     $result = ipDb()->fetchAll($checkSql, array('database' => ipConfig()->database(), 'table' => ipConfig()->tablePrefix() . 'comments', 'column' => 'deletedAt'));
     if (!$result) {
         $sql = "ALTER TABLE {$table} ADD `deletedAt` timestamp NULL DEFAULT NULL;";
         ipDb()->execute($sql);
     }
     $result = ipDb()->fetchAll($checkSql, array('database' => ipConfig()->database(), 'table' => ipConfig()->tablePrefix() . 'comments', 'column' => 'isVerified'));
     if (!$result) {
         $sql = "ALTER TABLE {$table} ADD `isVerified` timestamp NULL DEFAULT NULL;";
         ipDb()->execute($sql);
     }
     $result = ipDb()->fetchAll($checkSql, array('database' => ipConfig()->database(), 'table' => ipConfig()->tablePrefix() . 'comments', 'column' => 'verifiedAt'));
     if (!$result) {
         $sql = "ALTER TABLE {$table} ADD `verifiedAt` timestamp NULL DEFAULT NULL;";
         ipDb()->execute($sql);
     }
     try {
         ipDb()->execute("DROP INDEX `language_id` ON {$table} ");
     } catch (\Exception $e) {
         //ignore. We don't care if index doesn't exist. We will create it over again
     }
     try {
         ipDb()->execute("DROP INDEX `zone_name` ON {$table} ");
     } catch (\Exception $e) {
         //ignore. We don't care if index doesn't exist. We will create it over again
     }
     try {
         ipDb()->execute("DROP INDEX `page_id` ON {$table} ");
     } catch (\Exception $e) {
         //ignore. We don't care if index doesn't exist. We will create it over again
     }
     ipDb()->execute("ALTER TABLE {$table} ADD KEY `language_id` (`language_id`) ");
     ipDb()->execute("ALTER TABLE {$table} ADD KEY `zone_name` (`zone_name`) ");
 }
コード例 #7
0
ファイル: AdminController.php プロジェクト: Umz/ImpressPages
 public function index()
 {
     ipAddJsVariable('ipTranslationAreYouSure', __('Are you sure?', 'Ip-admin', false));
     ipAddJs('Ip/Internal/Core/assets/js/angular.js');
     ipAddJs('Ip/Internal/Pages/assets/js/pages.js');
     ipAddJs('Ip/Internal/Pages/assets/js/pagesLayout.js');
     ipAddJs('Ip/Internal/Pages/assets/js/menuList.js');
     ipAddJs('Ip/Internal/Pages/assets/jstree/jstree.min.js');
     ipAddJs('Ip/Internal/Pages/assets/js/jquery.pageTree.js');
     ipAddJs('Ip/Internal/Pages/assets/js/jquery.pageProperties.js');
     ipAddJs('Ip/Internal/Grid/assets/grid.js');
     ipAddJs('Ip/Internal/Grid/assets/gridInit.js');
     ipAddJs('Ip/Internal/Grid/assets/subgridField.js');
     ipAddJsVariable('languageList', Helper::languageList());
     ipAddJsVariable('ipPagesLanguagesPermission', ipAdminPermission('Languages'));
     $menus = Model::getMenuList();
     foreach ($menus as $key => &$menu) {
         $default = 'top';
         if ($key == 0) {
             $default = 'bottom';
         }
         $menu['defaultPosition'] = Model::getDefaultMenuPagePosition($menu['alias'], false, $default);
         $default = 'below';
         $menu['defaultPositionWhenSelected'] = Model::getDefaultMenuPagePosition($menu['alias'], true, $default);
     }
     $menus = ipFilter('ipPagesMenuList', $menus);
     ipAddJsVariable('menuList', $menus);
     $variables = array('addPageForm' => Helper::addPageForm(), 'addMenuForm' => Helper::addMenuForm(), 'languagesUrl' => ipConfig()->baseUrl() . '?aa=Languages.index');
     $layout = ipView('view/layout.php', $variables);
     ipResponse()->setLayoutVariable('removeAdminContentWrapper', true);
     ipAddJsVariable('listStylePageSize', ipGetOption('Pages.pageListSize', 30));
     return $layout->render();
 }
コード例 #8
0
ファイル: Event.php プロジェクト: Umz/ImpressPages
 public static function ipBeforeController()
 {
     $request = \Ip\ServiceLocator::request();
     $sessionLifetime = ini_get('session.gc_maxlifetime');
     if (!$sessionLifetime) {
         $sessionLifetime = 120;
     }
     if ($sessionLifetime > 30) {
         $sessionLifetime = $sessionLifetime - 20;
     }
     ipAddJsVariable('ipSessionRefresh', $sessionLifetime);
     if (ipConfig()->isDebugMode()) {
         ipAddJs('Ip/Internal/Core/assets/ipCore/jquery.js', null, 10);
         // default, global jQuery
         ipAddJs('Ip/Internal/Core/assets/ipCore/console.log.js', null, 10);
         ipAddJs('Ip/Internal/Core/assets/ipCore/functions.js');
         ipAddJs('Ip/Internal/Core/assets/ipCore/jquery.tools.form.js');
         ipAddJs('Ip/Internal/Core/assets/ipCore/form/color.js');
         ipAddJs('Ip/Internal/Core/assets/ipCore/form/file.js');
         ipAddJs('Ip/Internal/Core/assets/ipCore/form/richtext.js');
         ipAddJs('Ip/Internal/Core/assets/ipCore/form/repositoryFile.js');
         ipAddJs('Ip/Internal/Core/assets/ipCore/form/url.js');
         ipAddJs('Ip/Internal/Core/assets/ipCore/form.js');
         ipAddJs('Ip/Internal/Core/assets/ipCore/validator.js');
         ipAddJs('Ip/Internal/Core/assets/ipCore/widgets.js');
         ipAddJs('Ip/Internal/Core/assets/ipCore/ipCore.js');
     } else {
         ipAddJs('Ip/Internal/Core/assets/ipCore.min.js', null, 10);
     }
     //Form init
     $validatorTranslations = array('Ip-admin' => static::validatorLocalizationData('Ip-admin'), ipContent()->getCurrentLanguage()->getCode() => static::validatorLocalizationData('Ip'));
     ipAddJsVariable('ipValidatorTranslations', $validatorTranslations);
     if (ipAdminId() || \Ip\Internal\Admin\Model::isLoginPage() || \Ip\Internal\Admin\Model::isPasswordResetPage()) {
         if (ipConfig()->isDebugMode()) {
             ipAddJs('Ip/Internal/Core/assets/admin/managementMode.js');
             ipAddJs('Ip/Internal/Core/assets/admin/functions.js');
             ipAddJs('Ip/Internal/Core/assets/admin/validator.js');
             ipAddJs('Ip/Internal/Core/assets/admin/bootstrap/bootstrap.js');
             ipAddJs('Ip/Internal/Core/assets/admin/bootstrap-switch/bootstrap-switch.js');
         } else {
             ipAddJs('Ip/Internal/Core/assets/admin.min.js', null, 10);
         }
         ipAddJs('Ip/Internal/Core/assets/tinymce/pastePreprocess.js');
         ipAddJs('Ip/Internal/Core/assets/tinymce/default.js');
     }
     if (ipAdminId()) {
         ipAddJs('Ip/Internal/Core/assets/js/tiny_mce/jquery.tinymce.min.js');
         ipAddJs('Ip/Internal/Core/assets/js/tiny_mce/tinymce.min.js');
         ipAddJsVariable('ipBrowseLinkModalTemplate', ipView('view/browseLinkModal.php')->render());
         ipAddJs('Ip/Internal/Core/assets/ipCore/plupload/plupload.full.js');
         ipAddJs('Ip/Internal/Core/assets/ipCore/plupload/plupload.browserplus.js');
         ipAddJs('Ip/Internal/Core/assets/ipCore/plupload/plupload.gears.js');
         ipAddJs('Ip/Internal/Core/assets/ipCore/plupload/jquery.plupload.queue/jquery.plupload.queue.js');
         if (is_file(ipThemeFile('setup/admin.js'))) {
             ipAddJs(ipThemeUrl('setup/admin.js'));
         }
         ipAddCss('Ip/Internal/Core/assets/admin/admin.css');
     }
 }
コード例 #9
0
ファイル: Config.php プロジェクト: sspaeti/ImpressPages
 public static function domain()
 {
     $domain = ipGetOption('GoogleAnalytics.domain');
     if (empty($domain)) {
         $domain = parse_url(ipConfig()->baseUrl(), PHP_URL_HOST);
     }
     return $domain;
 }
コード例 #10
0
ファイル: FormHelper.php プロジェクト: Umz/ImpressPages
 public static function getLanguageSelectForm()
 {
     //create form object
     $form = new \Ip\Form();
     $form->setEnvironment(\Ip\Form::ENVIRONMENT_ADMIN);
     $form->addClass('ipsLanguageSelect');
     //add text field to form object
     $field = new \Ip\Form\Field\Select(array('name' => 'languageCode', 'values' => self::getAvailableLocales()));
     $field->setValue(ipConfig()->adminLocale());
     $form->addfield($field);
     return $form;
 }
コード例 #11
0
ファイル: Service.php プロジェクト: Umz/ImpressPages
 public function getTheme($name = null, $dir = null, $url = null)
 {
     if ($name == null) {
         $name = ipConfig()->theme();
     }
     if ($dir == null) {
         $dir = ipFile('Theme/');
     }
     $model = Model::instance();
     $theme = $model->getTheme($name, $dir, $url);
     return $theme;
 }
コード例 #12
0
 /**
  * Index action adds an item to administration menu
  */
 public function index()
 {
     ipAddJs('view/assets/js/vendor/angular.js', 1);
     ipAddJs('view/assets/js/vendor/angular-animate.min.js');
     ipAddJs('view/assets/js/vendor/angular-sanitize.min.js');
     ipAddJs('view/assets/js/vendor/ngToast.min.js');
     ipAddJs('view/assets/js/Controllers/WidgetCtrl.js', 6);
     ipAddCss('view/assets/css/ngToast.min.css');
     $BasePath = ipConfig()->baseUrl();
     ipAddJsVariable('BASEPATH', $BasePath);
     $data = array();
     return ipView('view/main.php', $data)->render();
 }
コード例 #13
0
ファイル: ErrorHandler.php プロジェクト: Umz/ImpressPages
 public static function ipErrorHandler($errno, $errstr, $errfile, $errline)
 {
     set_error_handler(__CLASS__ . '::ipSilentErrorHandler');
     $type = '';
     switch ($errno) {
         case E_USER_WARNING:
             $type .= 'Warning';
             break;
         case E_USER_NOTICE:
             $type .= 'Notice';
             break;
         case E_WARNING:
             $type .= 'Warning';
             break;
         case E_NOTICE:
             $type .= 'Notice';
             break;
         case E_CORE_WARNING:
             $type .= 'Warning';
             break;
         case E_COMPILE_WARNING:
             $type .= 'Warning';
             break;
         case E_USER_ERROR:
             $type .= 'Error';
             break;
         case E_ERROR:
             $type .= 'Error';
             break;
         case E_PARSE:
             $type .= 'Parse';
             break;
         case E_CORE_ERROR:
             $type .= 'Error';
             break;
         case E_COMPILE_ERROR:
             $type .= 'Error';
             break;
         default:
             $type .= 'Unknown exception';
             break;
     }
     if (class_exists('Ip\\Internal\\Log\\Logger')) {
         ipLog()->error($type . ': ' . $errstr . ' in {file}:{line}', array('file' => $errfile, 'line' => $errline));
     }
     if (ipConfig()->showErrors()) {
         echo "{$errstr} in {$errfile}:{$errline}";
     }
     restore_error_handler();
 }
コード例 #14
0
ファイル: Helper.php プロジェクト: Umz/ImpressPages
 public static function initManagement()
 {
     $widgets = Service::getAvailableWidgets();
     $snippets = array();
     foreach ($widgets as $widget) {
         $snippetHtml = $widget->adminHtmlSnippet();
         if ($snippetHtml != '') {
             $snippets[] = $snippetHtml;
         }
     }
     ipAddJsVariable('ipWidgetSnippets', $snippets);
     ipAddJsVariable('ipContentInit', Model::initManagementData());
     ipAddJs('Ip/Internal/Core/assets/js/jquery-ui/jquery-ui.js');
     ipAddCss('Ip/Internal/Core/assets/js/jquery-ui/jquery-ui.css');
     if (ipConfig()->isDebugMode()) {
         ipAddJs('Ip/Internal/Content/assets/management/ipContentManagementInit.js');
         ipAddJs('Ip/Internal/Content/assets/management/content.js');
         ipAddJs('Ip/Internal/Content/assets/management/jquery.ip.contentManagement.js');
         ipAddJs('Ip/Internal/Content/assets/management/jquery.ip.widgetbutton.js');
         ipAddJs('Ip/Internal/Content/assets/management/jquery.ip.layoutModal.js');
         ipAddJs('Ip/Internal/Content/assets/management/jquery.ip.block.js');
         ipAddJs('Ip/Internal/Content/assets/management/jquery.ip.widget.js');
         ipAddJs('Ip/Internal/Content/assets/management/exampleContent.js');
         ipAddJs('Ip/Internal/Content/assets/management/drag.js');
         ipAddJs('Ip/Internal/Content/Widget/Columns/assets/Columns.js');
         ipAddJs('Ip/Internal/Content/Widget/File/assets/File.js');
         ipAddJs('Ip/Internal/Content/Widget/File/assets/jquery.ipWidgetFile.js');
         ipAddJs('Ip/Internal/Content/Widget/File/assets/jquery.ipWidgetFileContainer.js');
         ipAddJs('Ip/Internal/Content/Widget/Form/assets/Form.js');
         ipAddJs('Ip/Internal/Content/Widget/Form/assets/FormContainer.js');
         ipAddJs('Ip/Internal/Content/Widget/Form/assets/FormField.js');
         ipAddJs('Ip/Internal/Content/Widget/Form/assets/FormOptions.js');
         ipAddJs('Ip/Internal/Content/Widget/Html/assets/Html.js');
         ipAddJs('Ip/Internal/Content/Widget/Video/assets/Video.js');
         ipAddJs('Ip/Internal/Content/Widget/Image/assets/Image.js');
         ipAddJs('Ip/Internal/Content/Widget/Gallery/assets/Gallery.js');
         ipAddJs('Ip/Internal/Content/Widget/Text/assets/Text.js');
         ipAddJs('Ip/Internal/Content/Widget/Heading/assets/Heading.js');
         ipAddJs('Ip/Internal/Content/Widget/Heading/assets/HeadingModal.js');
         ipAddJs('Ip/Internal/Content/Widget/Map/assets/Map.js');
     } else {
         ipAddJs('Ip/Internal/Content/assets/management.min.js');
     }
     ipAddJs('Ip/Internal/Core/assets/js/jquery-tools/jquery.tools.ui.scrollable.js');
     ipAddJs('Ip/Internal/Content/assets/jquery.ip.uploadImage.js');
     ipAddJsVariable('isMobile', \Ip\Internal\Browser::isMobile());
     ipAddJsVariable('ipWidgetLayoutModalTemplate', ipView('view/widgetLayoutModal.php')->render());
 }
コード例 #15
0
ファイル: PageAssets.php プロジェクト: Umz/ImpressPages
 public function generateJavascript()
 {
     $cacheVersion = $this->getCacheVersion();
     $javascriptFiles = $this->getJavascript();
     $javascriptFilesSorted = array();
     foreach ($javascriptFiles as $level) {
         foreach ($level as &$file) {
             if ($file['type'] == 'file' && $file['cacheFix']) {
                 $file['value'] .= (strpos($file['value'], '?') !== false ? '&' : '?') . $cacheVersion;
             }
         }
         $javascriptFilesSorted = array_merge($javascriptFilesSorted, $level);
     }
     $data = array('ip' => array('baseUrl' => ipConfig()->baseUrl(), 'languageId' => null, 'languageUrl' => '', 'theme' => ipConfig()->get('theme'), 'pageId' => null, 'securityToken' => \Ip\ServiceLocator::application()->getSecurityToken(), 'developmentEnvironment' => ipConfig()->isDevelopmentEnvironment(), 'debugMode' => ipconfig()->isDebugMode(), 'isManagementState' => false, 'isAdminState' => false, 'isAdminNavbarDisabled' => false), 'javascriptVariables' => $this->getJavascriptVariables(), 'javascript' => $javascriptFilesSorted);
     return ipView(ipFile('Ip/Internal/Config/view/javascript.php'), $data)->render();
 }
コード例 #16
0
ファイル: Event.php プロジェクト: Umz/ImpressPages
 public static function ipBeforeController()
 {
     if (ipIsManagementState() || ipRoute()->isAdmin() || ipRequest()->getQuery('ipDesignPreview')) {
         ipAddJs('Ip/Internal/Core/assets/js/jquery-ui/jquery-ui.js');
         ipAddJs('Ip/Internal/Repository/assets/ipRepository.js');
         ipAddJs('Ip/Internal/Repository/assets/ipRepositoryUploader.js');
         ipAddJs('Ip/Internal/Repository/assets/ipRepositoryAll.js');
         ipAddJs('Ip/Internal/Repository/assets/ipRepositoryBuy.js');
         ipAddJs('Ip/Internal/System/assets/market.js');
         ipAddJs('Ip/Internal/Core/assets/js/easyXDM/easyXDM.min.js');
         $marketUrl = ipConfig()->get('imageMarketUrl', 'http://market.impresspages.org/images-v1/');
         $popupData = array('marketUrl' => $marketUrl, 'allowUpload' => ipAdminPermission('Repository upload'), 'allowRepository' => ipAdminPermission('Repository'));
         ipAddJsVariable('ipRepositoryHtml', ipView('view/popup.php', $popupData)->render());
         ipAddJsVariable('ipRepositoryTranslate_confirm_delete', __('Are you sure you want to delete selected files?', 'Ip-admin'));
         ipAddJsVariable('ipRepositoryTranslate_delete_warning', __('Some of the selected files are still used somewhere on your website. Do you still want to remove them? ', 'Ip-admin'));
     }
 }
コード例 #17
0
 /**
  * @param string $file relative path from file/repository
  * @param array $options - image cropping options
  * @param string $desiredName - desired file name. If reflection is missing, service will try to create new one with name as possible similar to desired
  * @param bool $onDemand transformation will be create on the fly when image accessed for the first time
  * @return string - file name from BASE_DIR
  * @throws \Ip\Exception\Repository\Transform
  */
 public function getReflection($file, $options, $desiredName = null, $onDemand = true)
 {
     $reflectionModel = ReflectionModel::instance();
     try {
         $reflection = $reflectionModel->getReflection($file, $options, $desiredName, $onDemand);
         if (ipConfig()->get('rewritesDisabled') && !is_file(ipFile('file/' . $reflection)) || !ipConfig()->get('realTimeReflections', true)) {
             //create reflections immediately if mod_rewrite is disabled
             $reflectionRecord = $reflectionModel->getReflectionByReflection($reflection);
             $reflectionModel->createReflection($reflectionRecord['original'], $reflectionRecord['reflection'], json_decode($reflectionRecord['options'], true));
         }
     } catch (\Exception $e) {
         ipLog()->error($e->getMessage(), array('errorTrace' => $e->getTraceAsString()));
         $this->lastException = $e;
         return false;
     }
     return 'file/' . $reflection;
 }
コード例 #18
0
ファイル: PageNotFound.php プロジェクト: Umz/ImpressPages
 /**
  * Find the reason why the user come to non-existent URL
  * @return string error message
  */
 protected function error404Message()
 {
     $message = '';
     if (!isset($_SERVER['HTTP_REFERER']) || $_SERVER['HTTP_REFERER'] == '') {
         //mistyped URL
         $message = __('Sorry, but the page you were trying to get to does not exist.', 'Ip', false);
     } else {
         if (strpos($_SERVER['HTTP_REFERER'], ipConfig()->baseUrl()) < 5 && strpos($_SERVER['HTTP_REFERER'], ipConfig()->baseUrl()) !== false) {
             //Broken internal link
             $message = '<p>' . __('Sorry, but the page you were trying to get to does not exist.', 'Ip') . '</p>';
         } elseif (strpos($_SERVER['HTTP_REFERER'], ipConfig()->baseUrl()) === false) {
             //Broken external link
             $message = '<p>' . __('Sorry, but the page you were trying to get to does not exist.', 'Ip') . '</p>';
         }
     }
     return $message;
 }
コード例 #19
0
ファイル: Form.php プロジェクト: Umz/ImpressPages
 public function __construct()
 {
     $this->fieldsets = array();
     $this->method = self::METHOD_POST;
     $this->action = ipConfig()->baseUrl();
     $this->attributes = array();
     $this->classes = array();
     $this->ajaxSubmit = true;
     $this->validate = true;
     $this->addClass('ipsAjaxSubmit');
     if (ipRoute()->isAdmin()) {
         $this->setEnvironment(self::ENVIRONMENT_ADMIN);
     } else {
         $this->addClass('ipModuleForm');
         $this->setEnvironment(self::ENVIRONMENT_PUBLIC);
     }
     $this->addCsrfCheck();
     $this->addSpamCheck();
 }
コード例 #20
0
ファイル: Event.php プロジェクト: Umz/ImpressPages
 public static function ipBeforeController()
 {
     if (ipIsManagementState()) {
         if (ipConfig()->isDebugMode()) {
             ipAddJs('Ip/Internal/InlineManagement/assets/src/inlineManagement.js');
             ipAddJs('Ip/Internal/InlineManagement/assets/src/inlineManagementControls.js');
             ipAddJs('Ip/Internal/InlineManagement/assets/src/inlineManagementImage.js');
             ipAddJs('Ip/Internal/InlineManagement/assets/src/inlineManagementLogo.js');
             ipAddJs('Ip/Internal/InlineManagement/assets/src/inlineManagementText.js');
             ipAddJs('Ip/Internal/InlineManagement/assets/src/jquery.fontselector.js');
         } else {
             ipAddJs('Ip/Internal/InlineManagement/assets/inlineManagement.min.js');
         }
         ipAddJsVariable('ipModuleInlineManagementControls', ipView('view/management/controls.php')->render());
         ipAddJs('Ip/Internal/Content/assets/jquery.ip.uploadImage.js');
         ipAddJs('Ip/Internal/Core/assets/js/bootstrap-colorpicker/js/bootstrap-colorpicker.min.js');
         ipAddCss('Ip/Internal/Core/assets/js/bootstrap-colorpicker/css/bootstrap-colorpicker.css');
     }
 }
コード例 #21
0
ファイル: Event.php プロジェクト: Umz/ImpressPages
 public static function ipBeforeController()
 {
     $ipUrlOverrides = ipConfig()->get('urlOverrides');
     if (!$ipUrlOverrides) {
         $ipUrlOverrides = array();
     }
     ipAddJsVariable('ipUrlOverrides', $ipUrlOverrides);
     // Add widgets
     //TODO cache found assets to decrease file system usage
     $widgets = Service::getAvailableWidgets();
     if (ipIsManagementState()) {
         foreach ($widgets as $widget) {
             if (!$widget->isCore()) {
                 //core widget assets are included automatically in one minified file
                 static::addWidgetAssets($widget);
             }
         }
         ipAddJsVariable('ipPublishTranslation', __('Publish', 'Ip-admin', false));
     }
 }
コード例 #22
0
ファイル: JsonLoader.php プロジェクト: Umz/ImpressPages
 /**
  * load(): defined by FileLoaderInterface.
  *
  * @see    FileLoaderInterface::load()
  * @param  string $locale
  * @param  string $filename
  * @return TextDomain|null
  * @throws Exception\InvalidArgumentException
  */
 public function load($locale, $filename)
 {
     if (!is_file($filename) || !is_readable($filename)) {
         throw new Exception\InvalidArgumentException(sprintf('Could not open file %s for reading', $filename));
     }
     $messages = json_decode(file_get_contents($filename), true);
     if (!is_array($messages)) {
         if (ipConfig()->isDevelopmentEnvironment()) {
             throw new Exception\InvalidArgumentException(sprintf('Expected an array, but received %s', gettype($messages)));
         } else {
             return null;
         }
     }
     $textDomain = new TextDomain($messages);
     if (array_key_exists('', $textDomain)) {
         if (isset($textDomain['']['plural_forms'])) {
             $textDomain->setPluralRule(PluralRule::fromString($textDomain['']['plural_forms']));
         }
         unset($textDomain['']);
     }
     return $textDomain;
 }
コード例 #23
0
ファイル: ConfigModel.php プロジェクト: Umz/ImpressPages
 public function getAllConfigValues($theme)
 {
     $data = ipRequest()->getRequest();
     if (isset($data['restoreDefault'])) {
         $config = array();
         //overwrite current config with default theme values
         $model = Model::instance();
         $theme = $model->getTheme(ipConfig()->theme());
         $options = $theme->getOptionsAsArray();
         foreach ($options as $option) {
             if (isset($option['name']) && isset($option['default'])) {
                 $config[$option['name']] = $option['default'];
             }
         }
         return $config;
     } else {
         $config = $this->getLiveConfig();
         if (!empty($config)) {
             return $config;
         }
     }
     return ipThemeStorage($theme)->getAll();
 }
コード例 #24
0
ファイル: Controller.php プロジェクト: sspaeti/ImpressPages
 public function generateHtml($revisionId, $widgetId, $data, $skin)
 {
     $items = Model::widgetItems($widgetId);
     // If it has not been configured yet, sets some default values
     if (empty($data['options'])) {
         $data['options'] = array('gutter' => 10, 'columnWidth' => 320, 'isFitWidth' => true, 'isOriginLeft' => true);
     }
     $image_options = array('type' => 'width', 'width' => $data['options']['columnWidth'] - 10);
     foreach ($items as $key => $item) {
         // Clean Up the URL
         $link = '';
         if ($item['url'] != '') {
             $protocol = parse_url($item['url'], PHP_URL_SCHEME);
             $target = '_self';
             $base_url = ipConfig()->baseUrl();
             // If it is an absolute URL don't make any transformation
             if ($protocol == 'http' or $protocol == 'https') {
                 $link = $item['url'];
                 // If the URL is pointing to another domain, open in a new page.
                 if (strpos($link, $base_url) === false) {
                     $target = '_blank';
                 }
             } else {
                 // Asume it is a reference to a local page
                 $link = ipFileUrl($item['url']);
             }
             $items[$key]['link_target'] = $target;
         }
         $items[$key]['clean_url'] = $link;
         // Create Image path
         $items[$key]['image_url'] = ipFileUrl(ipReflection($item['image'], $image_options));
     }
     $data['container_id'] = "masonry_wd_{$widgetId}";
     $data['widgetId'] = $widgetId;
     $data['items'] = $items;
     return parent::generateHtml($revisionId, $widgetId, $data, $skin);
 }
コード例 #25
0
ファイル: Event.php プロジェクト: Umz/ImpressPages
 public static function ipBeforeApplicationClosed()
 {
     /*
      Automatic execution of cron.
      The best solution is to setup cron service to launch file www.yoursite.com/ip_cron.php few times a day.
      By default fake cron is enabled
     */
     if (\Ip\Internal\Admin\Model::isSafeMode() || !ipGetOption('Config.automaticCron', 1)) {
         return;
     }
     $lastExecution = \Ip\ServiceLocator::storage()->get('Cron', 'lastExecutionStart');
     if ($lastExecution && date('Y-m-d H') == date('Y-m-d H', $lastExecution)) {
         // we execute cron once an hour and cron has been executed this hour
         return;
     }
     if (function_exists('curl_init')) {
         $ch = curl_init();
         $url = ipConfig()->baseUrl() . '?pa=Cron&pass='******'Config.cronPassword'));
         curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch, CURLOPT_REFERER, ipConfig()->baseUrl());
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($ch, CURLOPT_TIMEOUT, ipGetOption('Config.cronTimeout', 10));
         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
         $fakeCronAnswer = curl_exec($ch);
         if ($fakeCronAnswer != __('OK', 'Ip-admin', false)) {
             ipLog()->error('Cron.failedFakeCron', array('result' => $fakeCronAnswer, 'type' => 'curl', 'error' => curl_error($ch)));
         }
     } else {
         $request = new \Ip\Request();
         $request->setQuery(array('pa' => 'Cron', 'pass' => ipGetOption('Config.cronPassword')));
         $fakeCronAnswer = \Ip\ServiceLocator::application()->handleRequest($request)->getContent();
         if ($fakeCronAnswer != __('OK', 'Ip-admin', false)) {
             ipLog()->error('Cron.failedFakeCron', array('result' => $fakeCronAnswer, 'type' => 'subrequest'));
         }
     }
 }
コード例 #26
0
ファイル: Model.php プロジェクト: Umz/ImpressPages
 protected static function updateTableUrl($oldUrl, $newUrl, $table, $keyFields)
 {
     $old = parse_url($oldUrl);
     $new = parse_url($newUrl);
     $oldPart = $old['host'] . $old['path'];
     $newPart = $new['host'] . $new['path'];
     $quotedPart = substr(ipDb()->getConnection()->quote('://' . $oldPart), 1, -1);
     $search = '%' . addslashes($quotedPart) . '%';
     $tableWithPrefix = ipTable($table);
     $records = ipDb()->fetchAll("SELECT * FROM {$tableWithPrefix} WHERE `value` LIKE ?", array($search));
     if (!$records) {
         return;
     }
     if ($newUrl == ipConfig()->baseUrl()) {
         //the website has been moved
         $search = '%\\b(https?://)' . preg_quote($oldPart, '%') . '%';
     } else {
         //internal page url has changed
         // \b - start at word boundary
         // (https?://) - protocol
         // (/?) - allow optional slash at the end of url
         // (?= ) - symbols expected after url
         // \Z - end of subject or end of line
         $search = '%\\b(https?://)' . preg_quote($oldPart, '%') . '(/?)(?=["\'?]|\\s|\\Z)%';
     }
     foreach ($records as $row) {
         // ${1} - protocol, ${2} - optional '/'
         $after = preg_replace($search, '${1}' . $newPart . '${2}', $row['value']);
         if ($after != $row['value']) {
             $where = array();
             foreach ($keyFields as $keyField) {
                 $where[$keyField] = $row[$keyField];
             }
             ipDb()->update($table, array('value' => $after), $where);
         }
     }
 }
コード例 #27
0
ファイル: Antispam.php プロジェクト: Umz/ImpressPages
 /**
  * Get error
  *
  * @param array $values
  * @param int $valueKey
  * @param $environment
  * @return string|bool
  */
 public function getError($values, $valueKey, $environment)
 {
     if ($environment == \Ip\Form::ENVIRONMENT_ADMIN) {
         $errorText = __('Form security check has failed. Please refresh the page.', 'Ip-admin');
     } else {
         $errorText = __('Form security check has failed. Please refresh the page.', 'Ip');
     }
     if (empty($values[$valueKey])) {
         return $errorText;
     }
     $value = $values[$valueKey];
     if (!is_array($value) || count($value) != 2) {
         return $errorText;
     }
     // First value should stay empty. Or its a bot :O)
     if (!isset($value[0]) || $value[0] != '') {
         return $errorText;
     }
     // Second value should be encoded today or yesterday date. Yesterday date is needed if user started to fill in data at 23:59
     if (!isset($value[1]) || $value[1] != md5(date('Y-m-d') . ipConfig()->get('sessionName')) && $value[1] != date('Y-m-d', time() - 24 * 60 * 60)) {
         return $errorText;
     }
     return false;
 }
コード例 #28
0
ファイル: Application.php プロジェクト: x33n/ImpressPages
 /**
  * @ignore
  * @param Request $request
  * @param array $options
  * @param bool $subrequest
  * @return Response\Json|Response\PageNotFound|Response\Redirect
  * @throws Exception
  * @ignore
  */
 public function _handleOnlyRequest(\Ip\Request $request, $options = array(), $subrequest = true)
 {
     if (empty($options['skipInitEvents'])) {
         \Ip\ServiceLocator::dispatcher()->_bindApplicationEvents();
     }
     $result = ipJob('ipRouteLanguage', array('request' => $request, 'relativeUri' => $request->getRelativePath()));
     if ($result) {
         $requestLanguage = $result['language'];
         $routeLanguage = $requestLanguage->getCode();
         ipRequest()->_setRoutePath($result['relativeUri']);
     } else {
         $routeLanguage = null;
         $requestLanguage = ipJob('ipRequestLanguage', array('request' => $request));
         ipRequest()->_setRoutePath($request->getRelativePath());
     }
     //find out and set locale
     $locale = $requestLanguage->getCode();
     if (strlen($locale) == '2') {
         $locale = strtolower($locale) . '_' . strtoupper($locale);
     } else {
         $locale = str_replace('-', '_', $locale);
     }
     $locale .= '.utf8';
     if ($locale == "tr_TR.utf8" && (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 5)) {
         //Overcoming this bug https://bugs.php.net/bug.php?id=18556
         setlocale(LC_COLLATE, $locale);
         setlocale(LC_MONETARY, $locale);
         setlocale(LC_NUMERIC, $locale);
         setlocale(LC_TIME, $locale);
         setlocale(LC_MESSAGES, $locale);
         setlocale(LC_CTYPE, "en_US.utf8");
     } else {
         setLocale(LC_ALL, $locale);
     }
     setlocale(LC_NUMERIC, "C");
     //user standard C syntax for numbers. Otherwise you will get funny things with when autogenerating CSS, etc.
     ipContent()->_setCurrentLanguage($requestLanguage);
     $_SESSION['ipLastLanguageId'] = $requestLanguage->getId();
     if (empty($options['skipTranslationsInit'])) {
         if (!empty($options['translationsLanguageCode'])) {
             $languageCode = $options['translationsLanguageCode'];
         } else {
             $languageCode = $requestLanguage->getCode();
         }
         $this->initTranslations($languageCode);
     }
     if (empty($options['skipModuleInit'])) {
         $this->modulesInit();
     }
     ipEvent('ipInitFinished');
     $routeAction = ipJob('ipRouteAction', array('request' => $request, 'relativeUri' => ipRequest()->getRoutePath(), 'routeLanguage' => $routeLanguage));
     if (!empty($routeAction)) {
         if (!empty($routeAction['page'])) {
             ipContent()->_setCurrentPage($routeAction['page']);
         }
         if (!empty($routeAction['environment'])) {
             ipRoute()->setEnvironment($routeAction['environment']);
         } else {
             if (!empty($routeAction['controller']) && $routeAction['controller'] == 'AdminController') {
                 ipRoute()->setEnvironment(\Ip\Route::ENVIRONMENT_ADMIN);
             } else {
                 ipRoute()->setEnvironment(\Ip\Route::ENVIRONMENT_PUBLIC);
             }
         }
         if (!empty($routeAction['controller'])) {
             ipRoute()->setController($routeAction['controller']);
         }
         if (!empty($routeAction['plugin'])) {
             ipRoute()->setPlugin($routeAction['plugin']);
         }
         if (!empty($routeAction['name'])) {
             ipRoute()->setName($routeAction['name']);
         }
         if (!empty($routeAction['action'])) {
             ipRoute()->setAction($routeAction['action']);
         }
     }
     //check for CSRF attack
     if (empty($options['skipCsrfCheck']) && $request->isPost() && $request->getPost('securityToken') != $this->getSecurityToken() && (empty($routeAction['controller']) || $routeAction['controller'] != 'PublicController')) {
         ipLog()->error('Core.possibleCsrfAttack', array('post' => ipRequest()->getPost()));
         $data = array('status' => 'error');
         if (ipConfig()->isDevelopmentEnvironment()) {
             $data['errors'] = array('securityToken' => __('Possible CSRF attack. Please pass correct securityToken.', 'Ip-admin'));
         }
         // TODO JSONRPC
         return new \Ip\Response\Json($data);
     }
     if (empty($routeAction)) {
         $routeAction = array('plugin' => 'Core', 'controller' => 'PublicController', 'action' => 'pageNotFound');
     }
     $eventInfo = $routeAction;
     if (!empty($routeAction['plugin'])) {
         $plugin = $routeAction['plugin'];
         $controller = $routeAction['controller'];
         if (in_array($plugin, \Ip\Internal\Plugins\Model::getModules())) {
             $controllerClass = 'Ip\\Internal\\' . $plugin . '\\' . $controller;
         } else {
             if (!in_array($plugin, \Ip\Internal\Plugins\Service::getActivePluginNames())) {
                 throw new \Ip\Exception("Plugin '" . esc($plugin) . "' doesn't exist or isn't activated.");
             }
             $controllerClass = 'Plugin\\' . $plugin . '\\' . $controller;
         }
         if (!class_exists($controllerClass)) {
             throw new \Ip\Exception('Requested controller doesn\'t exist. ' . esc($controllerClass));
         }
         // check if user is logged in
         if ($controller == 'AdminController' && !\Ip\Internal\Admin\Backend::userId()) {
             if (ipConfig()->get('rewritesDisabled')) {
                 return new \Ip\Response\Redirect(ipConfig()->baseUrl() . 'index.php/admin');
             } else {
                 return new \Ip\Response\Redirect(ipConfig()->baseUrl() . 'admin');
             }
         }
         if ($controller == 'AdminController') {
             if (!ipAdminPermission($plugin)) {
                 throw new \Ip\Exception('User has no permission to access ' . esc($plugin) . '');
             }
         }
         $eventInfo['controllerClass'] = $controllerClass;
         $eventInfo['controllerType'] = $controller;
     }
     if (empty($eventInfo['page'])) {
         $eventInfo['page'] = null;
     }
     // change layout if safe mode
     if (\Ip\Internal\Admin\Service::isSafeMode()) {
         ipSetLayout(ipFile('Ip/Internal/Admin/view/safeModeLayout.php'));
     } else {
         if ($eventInfo['page']) {
             ipSetLayout($eventInfo['page']->getLayout());
         }
     }
     ipEvent('ipBeforeController', $eventInfo);
     $controllerAnswer = ipJob('ipExecuteController', $eventInfo);
     return $controllerAnswer;
 }
コード例 #29
0
ファイル: AdminController.php プロジェクト: Umz/ImpressPages
 protected function indexUrl()
 {
     return ipConfig()->baseUrl() . '?aa=System.index';
 }
コード例 #30
0
ファイル: View.php プロジェクト: impresspages/impresspages
 /**
  * PHP can't handle exceptions in __toString method. Try to avoid it every time possible. Use render() method instead.
  * @ignore
  * @return string
  */
 public function __toString()
 {
     try {
         $content = $this->render();
     } catch (\Exception $e) {
         /*
         __toString method can't throw exceptions. In case of exception you will end with unclear error message.
         We can't avoid that here. So just logging clear error message in logs and rethrowing the same exception.
         */
         ipLog()->error('View.toStringException: Exception in View::__toString() method.', array('exception' => $e, 'view' => $this->file));
         if (ipConfig()->isDevelopmentEnvironment()) {
             return "<pre class=\"error\">\n" . $e->getMessage() . "\n" . $e->getTraceAsString() . "\n</pre>";
         } else {
             return '';
         }
     }
     return $content;
 }