コード例 #1
0
ファイル: Currency.php プロジェクト: x33n/ImpressPages
 public function searchQuery($searchVariables)
 {
     if (isset($searchVariables[$this->field]) && $searchVariables[$this->field] !== '') {
         return ' `' . $this->field . '` = ' . ipDb()->getConnection()->quote($searchVariables[$this->field] * 100) . '';
     }
     return null;
 }
コード例 #2
0
ファイル: Unique.php プロジェクト: Umz/ImpressPages
 /**
  * Get error
  *
  * @param array $values
  * @param int $valueKey
  * @param $environment
  * @return string|bool
  */
 public function getError($values, $valueKey, $environment)
 {
     if (!array_key_exists($valueKey, $values)) {
         return false;
     }
     if ($values[$valueKey] == '' && empty($this->data['allowEmpty'])) {
         return false;
     }
     $table = $this->data['table'];
     $idField = empty($this->data['idField']) ? 'id' : $this->data['idField'];
     $row = ipDb()->selectRow($table, '*', array($valueKey => $values[$valueKey]));
     if (!$row) {
         return false;
     }
     if (isset($values[$idField]) && $values[$idField] == $row[$idField]) {
         return false;
     }
     if ($this->errorMessage !== null) {
         return $this->errorMessage;
     }
     if ($environment == \Ip\Form::ENVIRONMENT_ADMIN) {
         $errorText = __('The value should be unique', 'Ip-admin');
     } else {
         $errorText = __('The value should be unique', 'Ip');
     }
     return $errorText;
 }
コード例 #3
0
ファイル: JsTreeHelper.php プロジェクト: Umz/ImpressPages
 /**
  * @param string $languageCode
  * @param int $parentId
  * @return array
  */
 protected static function getList($languageCode, $parentId)
 {
     $pages = ipDb()->selectAll('page', '*', array('parentId' => $parentId, 'isDeleted' => 0), 'ORDER BY `pageOrder`');
     $answer = array();
     //generate jsTree response array
     foreach ($pages as $page) {
         $pageData = array();
         $pageData['state'] = 'closed';
         $jsTreeId = 'page_' . $page['id'];
         if (!empty($_SESSION['Pages.nodeOpen'][$jsTreeId])) {
             $pageData['state'] = 'open';
         }
         $children = self::getList($languageCode, $page['id']);
         if (count($children) === 0) {
             $pageData['children'] = false;
             $pageData['state'] = 'leaf';
         }
         $pageData['children'] = $children;
         if ($page['isVisible']) {
             $icon = '';
         } else {
             $icon = ipFileUrl('Ip/Internal/Pages/assets/img/file_hidden.png');
         }
         $pageData['li_attr'] = array('id' => $jsTreeId, 'rel' => 'page', 'languageId' => $languageCode, 'pageId' => $page['id']);
         $pageData['data'] = array('title' => $page['title'] . '', 'icon' => $icon);
         //transform null into empty string. Null break JStree into infinite loop
         $pageData['text'] = htmlspecialchars($page['title']);
         $answer[] = $pageData;
     }
     return $answer;
 }
コード例 #4
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;
 }
コード例 #5
0
ファイル: Checkboxes.php プロジェクト: Umz/ImpressPages
 public function searchQuery($searchVariables)
 {
     if (isset($searchVariables[$this->field]) && $searchVariables[$this->field] !== '') {
         return ' `' . $this->field . '` like ' . ipDb()->getConnection()->quote('%' . json_encode($searchVariables[$this->field]) . '%') . '';
     }
     return null;
 }
コード例 #6
0
ファイル: Model.php プロジェクト: sspaeti/ImpressPages
 public static function checkIfChildren($parentIds, $id)
 {
     $parentIds = implode(',', $parentIds);
     if (empty($parentIds)) {
         return false;
     }
     $table = ipTable('page');
     $sql = "SELECT `id` FROM {$table} WHERE `parentId` IN ({$parentIds}) AND `isVisible` = 1 AND `isDeleted` = 0 ";
     $results = ipDb()->fetchAll($sql);
     $ids = array();
     $found = false;
     foreach ($results as $result) {
         $ids[] = $result['id'];
         if ($result['id'] == $id) {
             $found = true;
             break;
         }
     }
     if ($found) {
         return true;
     } elseif (!empty($ids)) {
         return self::checkIfChildren($ids, $id);
     } else {
         return false;
     }
 }
コード例 #7
0
 public static function removePermission($permission, $administratorId = null)
 {
     if ($administratorId === null) {
         $administratorId = ipAdminId();
     }
     $condition = array('permission' => $permission, 'administratorId' => $administratorId);
     ipDb()->delete('permission', $condition);
 }
コード例 #8
0
ファイル: Language.php プロジェクト: Umz/ImpressPages
 public static function getByCode($languageCode)
 {
     $row = ipDb()->selectRow('language', '*', array('code' => $languageCode));
     if (!$row) {
         return null;
     }
     return new self($row['id'], $row['code'], $row['url'], $row['title'], $row['abbreviation'], $row['isVisible'], $row['textDirection']);
 }
コード例 #9
0
ファイル: Slot.php プロジェクト: sspaeti/ImpressPages
 public static function veryEmail_10($vcode)
 {
     $fcode = substr($vcode, 0, strpos($vcode, '-!'));
     $mail = substr($vcode, strpos($vcode, '-!') + 2, 250);
     ipDb()->update('comments', array('approved' => '1'), array('verification_code' => $fcode, 'email' => $mail));
     $data = array('message' => __('Your email address has been verified. Thank you.', 'Comments'));
     return ipView('view/mailVerified.php', $data)->render();
 }
コード例 #10
0
ファイル: Model.php プロジェクト: Umz/ImpressPages
 /**
  * Find all files bind to particular module
  */
 public function findFiles($plugin, $instanceId = null)
 {
     $where = array('plugin' => $plugin);
     if ($instanceId !== null) {
         $where['instanceId'] = $instanceId;
     }
     return ipDb()->selectAll('repository_file', '*', $where);
 }
コード例 #11
0
ファイル: Event.php プロジェクト: sspaeti/ImpressPages
 public static function ipWidgetDuplicated($data)
 {
     $oldId = $data['oldWidgetId'];
     $newId = $data['newWidgetId'];
     $newRevisionId = ipDb()->selectValue('widget', 'revisionId', array('id' => $newId));
     $widgetTable = ipTable('widget');
     $sql = "\n            UPDATE\n                {$widgetTable}\n            SET\n                `blockName` = REPLACE(`blockName`, 'block_" . (int) $oldId . "', 'block_" . (int) $newId . "')\n            WHERE\n                `revisionId` = :newRevisionId\n            ";
     ipDb()->execute($sql, array('newRevisionId' => $newRevisionId));
 }
コード例 #12
0
ファイル: ValueStorage.php プロジェクト: Umz/ImpressPages
 /**
  * Get all storage values
  *
  * @return array Key=>value array of all storage values
  */
 public function getAll()
 {
     $values = ipDb()->selectAll($this->tableName, array($this->keyColumn, $this->valueColumn), array($this->namespaceColumn => $this->namespace));
     $result = array();
     foreach ($values as $value) {
         $result[$value[$this->keyColumn]] = json_decode($value[$this->valueColumn], true);
     }
     return $result;
 }
コード例 #13
0
ファイル: Worker.php プロジェクト: hmuralt/DataTableWidget
 /**
  * Drops the datatable repository db table
  */
 private function dropDataTableRepository()
 {
     $ipTable = ipTable(TableRepository::DATA_TABLE_REPOSITORY);
     $sql = "\n            DROP TABLE {$ipTable}\n        ";
     try {
         ipDb()->execute($sql);
     } catch (\Ip\Exception\Db $e) {
         ipLog()->error("Could not drop repository table. Statement: {$sql}, Message: " . $e->getMessage());
     }
 }
コード例 #14
0
ファイル: Content.php プロジェクト: Umz/ImpressPages
 /**
  * @param string $alias
  * @param string|null $languageCode
  * @return \Ip\Page
  */
 public function getPageByAlias($alias, $languageCode = null)
 {
     if ($languageCode === null) {
         $languageCode = ipContent()->getCurrentLanguage()->getCode();
     }
     $row = ipDb()->selectRow('page', '*', array('alias' => $alias, 'languageCode' => $languageCode, 'isDeleted' => 0));
     if (!$row) {
         return null;
     }
     return new \Ip\Page($row);
 }
コード例 #15
0
ファイル: Helper.php プロジェクト: Umz/ImpressPages
 public static function emptyPageForm()
 {
     $form = new \Ip\Form();
     $form->setEnvironment(\Ip\Form::ENVIRONMENT_ADMIN);
     $pages = ipDb()->selectAll('page', 'id, title', array('isDeleted' => 1));
     foreach ($pages as $page) {
         $field = new \Ip\Form\Field\Checkbox(array('name' => 'page[]', 'label' => $page['title'], 'value' => true, 'postValue' => $page['id']));
         $form->addField($field);
     }
     return $form;
 }
コード例 #16
0
ファイル: Db.php プロジェクト: Umz/ImpressPages
 public static function newUrl($preferredUrl)
 {
     $suffix = '';
     $url = ipDb()->selectAll('language', 'id', array('url' => $preferredUrl . $suffix));
     if (empty($url)) {
         return $preferredUrl;
     }
     while (!empty($url)) {
         $suffix++;
         $url = ipDb()->selectAll('language', 'id', array('url' => $preferredUrl . $suffix));
     }
     return $preferredUrl . $suffix;
 }
コード例 #17
0
ファイル: Model.php プロジェクト: Umz/ImpressPages
 public static function importData($tablePrefix)
 {
     $errors = array();
     $sqlFile = self::ipFile('Plugin/Install/sql/data.sql');
     $fh = fopen($sqlFile, 'r');
     $sql = fread($fh, utf8_decode(filesize($sqlFile)));
     fclose($fh);
     $sql = str_replace("INSERT INTO `ip_", "INSERT INTO `" . $tablePrefix, $sql);
     $sql = str_replace("[[[[version]]]]", ipApplication()->getVersion(), $sql);
     $sql = str_replace("[[[[dbversion]]]]", \Ip\Internal\Update\Model::getDbVersion(), $sql);
     $sql = str_replace("[[[[time]]]]", date('Y-m-d H:i:s'), $sql);
     $sql = str_replace("[[[[timestamp]]]]", time(), $sql);
     ipDb()->execute($sql);
     return $errors;
 }
コード例 #18
0
ファイル: Logger.php プロジェクト: Umz/ImpressPages
 /**
  * Logs with an arbitrary level.
  *
  * @param mixed $level
  * @param string $message
  * @param array $context
  * @return null
  */
 public function log($level, $message, array $context = array())
 {
     if (!ipDb()->isConnected()) {
         // do not log things if we have no database connection
         return;
     }
     if (!is_string($message)) {
         // Probably programmer made a mistake, used Logger::log($message, $context)
         $row = array('level' => \Psr\Log\LogLevel::ERROR, 'message' => 'Code uses ipLog()->log() without giving $level info.', 'context' => json_encode(array('args' => func_get_args())));
         ipDb()->insert('log', $row);
         return;
     }
     $row = array('level' => $level, 'message' => $message, 'context' => json_encode($context));
     ipDb()->insert('log', $row);
 }
コード例 #19
0
ファイル: PublicController.php プロジェクト: Umz/ImpressPages
 public static function download()
 {
     $requestFile = ipFile('') . ipRequest()->getRelativePath();
     $fileDir = ipFile('file/');
     if (mb_strpos($requestFile, $fileDir) !== 0) {
         return null;
     }
     $file = mb_substr($requestFile, mb_strlen($fileDir));
     $file = urldecode($file);
     if (empty($file)) {
         throw new \Ip\Exception('Required parameter is missing');
     }
     $absoluteSource = realpath(ipFile('file/' . $file));
     if (!$absoluteSource || !is_file($absoluteSource)) {
         throw new \Ip\Exception\Repository\Transform("File doesn't exist", array('filename' => $absoluteSource));
     }
     if (strpos($absoluteSource, realpath(ipFile('file/'))) !== 0 || strpos($absoluteSource, realpath(ipFile('file/secure'))) === 0) {
         throw new \Exception("Requested file (" . $file . ") is outside of public dir");
     }
     $mime = \Ip\Internal\File\Functions::getMimeType($absoluteSource);
     $fsize = filesize($absoluteSource);
     // set headers
     header("Pragma: public");
     header("Expires: 0");
     header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
     header("Cache-Control: public");
     header('Content-type: ' . $mime);
     header("Content-Transfer-Encoding: binary");
     header("Content-Length: " . $fsize);
     // download
     // @readfile($file_path);
     $file = @fopen($absoluteSource, "rb");
     if ($file) {
         while (!feof($file)) {
             print fread($file, 1024 * 8);
             flush();
             if (connection_status() != 0) {
                 @fclose($file);
                 die;
             }
         }
         @fclose($file);
     }
     //TODO provide method to stop any output by ImpressPages
     ipDb()->disconnect();
     exit;
 }
コード例 #20
0
ファイル: Model.php プロジェクト: sspaeti/ImpressPages
 public static function getMenus()
 {
     $menuAliases = self::getMenuAliases();
     $currLangCode = ipContent()->getCurrentLanguage()->getCode();
     if (!empty($menuAliases)) {
         $menuPages = array();
         foreach ($menuAliases as $menuAlias) {
             $menuRec = ipDb()->selectAll('page', 'id, title, alias', array('isDeleted' => 0, 'alias' => $menuAlias, 'parentId' => 0, 'isDisabled' => 0, 'isSecured' => 0, 'languageCode' => $currLangCode), 'ORDER BY `pageOrder`');
             if (!empty($menuRec)) {
                 $menuPages = array_merge($menuPages, $menuRec);
             }
         }
     } else {
         $menuPages = ipDb()->selectAll('page', 'id, title, alias', array('isDeleted' => 0, 'alias' => $menuAlias, 'parentId' => 0, 'isDisabled' => 0, 'isSecured' => 0, 'languageCode' => $currLangCode), 'ORDER BY `pageOrder`');
     }
     return $menuPages;
 }
コード例 #21
0
ファイル: Worker.php プロジェクト: sspaeti/ImpressPages
    public function activate()
    {
        $sql = '
        CREATE TABLE IF NOT EXISTS
           ' . ipTable(\Plugin\MasonryGrid\Config::TABLE_NAME) . '
        (
        `id` int(11) NOT NULL AUTO_INCREMENT,
        `itemOrder` double,
        `widgetId` int(11),
        `title` varchar(255),
        `image` varchar(255),
		`description` text,
		`url` varchar(255),
        `isVisible` int(1),
        PRIMARY KEY (`id`)
        )';
        ipDb()->execute($sql);
    }
コード例 #22
0
ファイル: UrlAllocator.php プロジェクト: Umz/ImpressPages
 /**
  * @parem string $languageCode
  * @param $languageCode
  * @param string $urlPath
  * @returns bool true if url is available
  */
 public static function isPathAvailable($languageCode, $urlPath)
 {
     $pageId = ipDb()->selectValue('page', '`id`', array('languageCode' => $languageCode, 'urlPath' => $urlPath, 'isDeleted' => 0));
     if ($pageId) {
         return false;
     }
     //if lash exists, remove. If there is no slash, add it.
     if (substr($urlPath, -1) == '/') {
         $urlPath = substr($urlPath, 0, -1);
     } else {
         $urlPath .= '/';
     }
     $pageId = ipDb()->selectValue('page', '`id`', array('languageCode' => $languageCode, 'urlPath' => $urlPath, 'isDeleted' => 0));
     if (!$pageId) {
         return true;
     }
     return false;
 }
コード例 #23
0
ファイル: Model.php プロジェクト: sspaeti/ImpressPages
 public static function getKeywordData()
 {
     $pageTable = ipTable('page');
     $keywordlistTable = ipTable(self::TABLE_NAME);
     $langCode = ipContent()->getCurrentLanguage()->getCode();
     $excludeFields = ' AND p.IsVisible = 1 AND p.IsDisabled = 0 AND p.IsDeleted = 0';
     $securedPages = ipGetOption('Keywordlist.securedPages') == 1 ? '' : 'AND p.IsSecured = 0';
     if (ipGetOption('Keywordlist.useMetadata') == 1) {
         $sql = "SELECT p.id, p.title, p.urlPath, p.keywords, p.description FROM {$pageTable} p WHERE p.languageCode = '{$langCode}' AND p.keywords != '' {$excludeFields} {$securedPages}";
     } else {
         $sql = "SELECT p.id, p.title, p.urlPath, k.keywords, k.description FROM {$pageTable} p, {$keywordlistTable} k WHERE p.id = k.pageid AND p.languageCode = '{$langCode}' AND k.keywords != '' {$excludeFields} {$securedPages}";
     }
     $keywordArray = array();
     $entries = array();
     $entries = ipDb()->fetchAll($sql);
     $existingChars = array();
     if (!empty($entries)) {
         // prepare array with keywords and pages
         $keywordArray = array();
         $charSource = array('ä', 'ö', 'ü', 'ß', 'Ä', 'Ö', 'Ü');
         $charReplace = array('a', 'o', 'u', 's', 'A', 'O', 'U');
         foreach ($entries as $entry) {
             $keywords = array_map('trim', explode(",", $entry['keywords']));
             foreach ($keywords as $keyword) {
                 $firstChar = strtoupper(str_replace($charSource, $charReplace, mb_substr($keyword, 0, 1, 'UTF-8')));
                 if (is_numeric($firstChar)) {
                     $firstChar = '0-9';
                 }
                 $keywordArray[] = array('keyword' => $keyword, 'char' => $firstChar, 'id' => $entry['id'], 'title' => $entry['title'], 'description' => $entry['description'], 'urlPath' => $entry['urlPath']);
             }
         }
         // sorting keywordarray depending first char of keyword
         foreach ($keywordArray as $key => $row) {
             $char[$key] = $row['char'];
         }
         array_multisort($char, SORT_ASC, SORT_STRING, $keywordArray);
         $existingChars = array_unique($char);
     }
     $keywordData = array();
     $keywordData['entries'] = $keywordArray;
     $keywordData['chars'] = $existingChars;
     return $keywordData;
 }
コード例 #24
0
ファイル: Helper.php プロジェクト: sspaeti/ImpressPages
 private static function arrayToMenuItem($pages, $depth, $curDepth, $order)
 {
     $items = array();
     foreach ($pages as $pageRow) {
         $page = new \Ip\Page($pageRow['id']);
         $item = new Item();
         $subSelected = false;
         if ($curDepth < $depth) {
             $children = ipDb()->selectAll('page', '*', array('parentId' => $page->getId(), 'isVisible' => 1, 'isSecured' => 0, 'isDeleted' => 0), "ORDER BY {$order}");
             if ($children) {
                 $childrenItems = self::arrayToMenuItem($children, $depth, $curDepth + 1, $order);
                 $item->setChildren($childrenItems);
             }
         }
         if ($page->isCurrent() || $page->getRedirectUrl() && $page->getLink() == \Ip\Internal\UrlHelper::getCurrentUrl()) {
             $item->markAsCurrent(true);
         } elseif ($page->isInCurrentBreadcrumb() || $subSelected || $page->getRedirectUrl() && self::existInBreadcrumb($page->getLink())) {
             $item->markAsInCurrentBreadcrumb(true);
         }
         if ($page->isDisabled()) {
             $item->setUrl('');
         } elseif ($page->getRedirectUrl()) {
             $url = $page->getRedirectUrl();
             if (!preg_match('/^((http|https):\\/\\/)/i', $url)) {
                 $url = 'http://' . $url;
             }
             $item->setUrl($url);
         } else {
             $item->setUrl($page->getLink());
         }
         $metaTitle = $page->getMetaTitle();
         $item->setBlank($page->isBlank());
         $item->setTitle($page->getTitle());
         $item->setDepth($curDepth);
         $item->setDisabled($page->isDisabled());
         $item->setId($page->getId());
         $item->setAlias($page->getAlias());
         $item->setPageTitle(empty($metaTitle) ? $page->getTitle() : $metaTitle);
         $items[] = $item;
     }
     return $items;
 }
コード例 #25
0
ファイル: Worker.php プロジェクト: sspaeti/ImpressPages
    public function activate()
    {
        $sql = '
        CREATE TABLE IF NOT EXISTS
           ' . ipTable('slideshow') . '
        (
        `id` int(11) NOT NULL AUTO_INCREMENT,
		`widgetId` int(11),
        `slideshowOrder` double,
        `title` varchar(255),
        `text` varchar(255),
        `url` varchar(255),
        `Enabled` boolean,
        `image` varchar(255),
		`lang` varchar(3),
		`itemOrder` double,
		`isVisible` int(1),
        PRIMARY KEY (`id`)
        )';
        ipDb()->execute($sql);
    }
コード例 #26
0
ファイル: AdminController.php プロジェクト: Umz/ImpressPages
 public function getPages()
 {
     $data = ipRequest()->getRequest();
     if (empty($data['languageId'])) {
         throw new \Ip\Exception("Missing required parameters");
     }
     $language = ipContent()->getLanguage($data['languageId']);
     if (!$language) {
         throw new \Ip\Exception("Language doesn't exist. " . $data['languageId']);
     }
     $languageCode = $language->getCode();
     if (empty($data['menuName'])) {
         throw new \Ip\Exception("Missing required parameters");
     }
     $menuName = $data['menuName'];
     $parentId = ipDb()->selectValue('page', 'id', array('languageCode' => $languageCode, 'alias' => $menuName, 'isDeleted' => 0));
     $tree = JsTreeHelper::getPageTree($languageCode, $parentId);
     $tree = ipFilter('ipPageTree', $tree, array('languageCode' => $languageCode, 'parentId' => $parentId));
     $responseData = array('tree' => $tree);
     return new \Ip\Response\Json($responseData);
 }
コード例 #27
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);
         }
     }
 }
コード例 #28
0
ファイル: Application.php プロジェクト: x33n/ImpressPages
 /**
  * @ignore
  */
 public function close()
 {
     ipEvent('ipBeforeApplicationClosed');
     ipDb()->disconnect();
 }
コード例 #29
0
ファイル: Worker.php プロジェクト: sspaeti/ImpressPages
 public function remove()
 {
     $sql = 'DROP TABLE IF EXISTS ' . ipTable('comments');
     ipDb()->execute($sql);
 }
コード例 #30
0
ファイル: Db.php プロジェクト: Umz/ImpressPages
 public static function deleteOldLogs($days)
 {
     $logTable = ipTable('log');
     ipDb()->execute("delete from {$logTable} where  (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(`time`)) > ?", array($days * 24 * 60 * 60));
 }