Exemplo n.º 1
0
 /**
  * validate the captcha
  *
  * @since 2.2.0
  *
  * @param string $raw plain answer
  * @param string $hash hashed solution
  *
  * @return integer
  */
 public function validate($raw = null, $hash = null)
 {
     $output = Validator::FAILED;
     /* validate raw again hash */
     if (sha1($raw) === $hash || Db::getSettings('captcha') == 0) {
         $output = Validator::PASSED;
     }
     return $output;
 }
 /**
  * automate run
  *
  * @since 2.1.0
  */
 protected function _autorun()
 {
     $root = $this->_registry->get('root');
     $dbStatus = $this->_registry->get('dbStatus');
     $lastTable = $this->_registry->get('lastTable');
     $lastId = $this->_registry->get('lastId');
     /* detect language */
     $this->_detect(array('query' => $this->_request->getQuery('l'), 'session' => $this->_request->getSession($root . '/language'), 'contents' => $lastTable ? Db::forTablePrefix($lastTable)->where('id', $lastId)->findOne()->language : null, 'settings' => $dbStatus === 2 ? Db::getSettings('language') : null, 'browser' => substr($this->_request->getServer('HTTP_ACCEPT_LANGUAGE'), 0, 2), 'fallback' => 'en'), 'language', 'languages/' . $this->_filePlaceholder . '.json');
 }
 /**
  * validate the captcha
  *
  * @since 2.2.0
  *
  * @param string $task plain task
  * @param string $hash hashed solution
  *
  * @return integer
  */
 public function validate($task = null, $hash = null)
 {
     $output = ValidatorInterface::FAILED;
     $captchaHash = new Hash(Config::getInstance());
     /* validate captcha */
     if ($task && $captchaHash->validate($task, $hash) || Db::getSettings('captcha') < 1) {
         $output = ValidatorInterface::PASSED;
     }
     return $output;
 }
 /**
  * init the class
  *
  * @since 2.6.0
  *
  * @param array $options options of the breadcrumb
  */
 public function init($options = array())
 {
     if (is_array($options)) {
         $this->_options = array_merge($this->_options, $options);
     }
     if (!$this->_options['divider']) {
         $this->_options['divider'] = Db::getSettings('divider');
     }
     $this->_create();
 }
 /**
  * automate run
  *
  * @since 2.1.0
  */
 protected function _autorun()
 {
     $root = $this->_registry->get('root');
     $dbStatus = $this->_registry->get('dbStatus');
     $lastTable = $this->_registry->get('lastTable');
     $lastId = $this->_registry->get('lastId');
     $fileInstall = $this->_registry->get('file') === 'install.php';
     $partial = $fileInstall ? 'install.phtml' : 'index.phtml';
     /* detect template */
     $this->_detect(array('query' => $this->_request->getQuery('t'), 'session' => $this->_request->getSession($root . '/template'), 'contents' => $lastTable ? Db::forTablePrefix($lastTable)->where('id', $lastId)->findOne()->template : null, 'settings' => $dbStatus === 2 ? Db::getSettings('template') : null, 'install' => $fileInstall ? 'install' : null, 'fallback' => 'default'), 'template', 'templates/' . $this->_filePlaceholder . '/' . $partial);
 }
Exemplo n.º 6
0
 /**
  * sanitize the html
  *
  * @since 2.4.0
  *
  * @param string $html target html
  * @param boolean $filter optional filter nodes
  *
  * @return string
  */
 public function sanitize($html = null, $filter = true)
 {
     $charset = Db::getSettings('charset');
     $html = mb_convert_encoding($html, 'html-entities', $charset);
     $doc = $this->_createDocument($html);
     $doc = $this->_cleanDocument($doc);
     /* filter nodes */
     if ($filter === true) {
         $doc = $this->_stripTags($doc);
         $doc = $this->_stripAttributes($doc);
         $doc = $this->_stripValues($doc);
     }
     /* collect output */
     $output = trim($doc->saveHTML());
     return $output;
 }
Exemplo n.º 7
0
 /**
  * sanitize the html
  *
  * @since 2.4.0
  *
  * @param string $html target html
  * @param boolean $filter optional filter nodes
  *
  * @return string
  */
 public function sanitize($html = null, $filter = true)
 {
     $charset = Db::getSettings('charset');
     $html = mb_convert_encoding($html, 'html-entities', $charset);
     $doc = $this->_createDocument($html);
     $doc = $this->_cleanDocument($doc);
     /* filter nodes */
     if ($filter === true) {
         /* disable errors */
         libxml_use_internal_errors(true);
         /* strip tags and attributes */
         $doc = $this->_stripTags($doc);
         $doc = $this->_stripAttributes($doc);
         /* clear errors */
         libxml_clear_errors();
     }
     /* collect output */
     $output = trim($doc->saveHTML());
     return $output;
 }
Exemplo n.º 8
0
 /**
  * render
  *
  * @since 2.2.0
  *
  * @param string $fileName
  * @param string $type
  * @param string $unit
  *
  * @return string
  */
 public static function render($fileName = null, $type = 'size', $unit = 'kb')
 {
     $output = '';
     /* size */
     if ($type === 'size') {
         $output = filesize($fileName);
         /* calculate output */
         if ($unit === 'kb' || $unit === 'mb') {
             $output = $output / 1024;
         }
         if ($unit === 'mb') {
             $output = $output / 1024;
         }
         $output = ceil($output);
     } else {
         if ($type === 'date') {
             $output = date(Db::getSettings('date'), filectime($fileName));
         }
     }
     return $output;
 }
Exemplo n.º 9
0
 /**
  * render
  *
  * @since 2.2.0
  *
  * @return string
  */
 public static function render()
 {
     /* fetch categories */
     $categories = Db::forTablePrefix('categories')->where('status', 1)->whereNull('access')->orderByAsc('rank')->findArray();
     /* fetch articles */
     $articles = Db::forTablePrefix('articles')->where('status', 1)->whereNull('access')->orderByAsc('rank')->findArray();
     /* collect output */
     $output = '<?xml version="1.0" encoding="' . Db::getSettings('charset') . '"?>';
     $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
     $output .= '<url><loc>' . Registry::get('root') . '</loc></url>';
     /* process categories */
     foreach ($categories as $value) {
         $route = $value['parent'] < 1 ? $value['alias'] : build_route('categories', $value['id']);
         $output .= '<url><loc>' . Registry::get('root') . '/' . Registry::get('rewriteRoute') . $route . '</loc></url>';
     }
     /* process articles */
     foreach ($articles as $value) {
         $route = $value['category'] < 1 ? $value['alias'] : build_route('articles', $value['id']);
         $output .= '<url><loc>' . Registry::get('root') . '/' . Registry::get('rewriteRoute') . $route . '</loc></url>';
     }
     $output .= '</urlset>';
     return $output;
 }
 /**
  * render
  *
  * @since 2.6.0
  *
  * @param string $directory
  * @param array $options
  *
  * @return string
  */
 public static function render($directory = null, $options = null)
 {
     $output = null;
     $outputDirectory = null;
     $outputFile = null;
     /* hash option */
     if ($options['hash']) {
         $hashString = '#' . $options['hash'];
     }
     /* handle query */
     $directoryQuery = Request::getQuery('d');
     if ($directoryQuery && $directory !== $directoryQuery) {
         $pathFilter = new Filter\Path();
         $directory = $pathFilter->sanitize($directoryQuery);
         $parentDirectory = $pathFilter->sanitize(dirname($directory));
     }
     /* has directory */
     if (is_dir($directory)) {
         /* html elements */
         $linkElement = new Html\Element();
         $linkElement->init('a', array('class' => self::$_config['className']['link']));
         $textSizeElement = new Html\Element();
         $textSizeElement->init('span', array('class' => self::$_config['className']['textSize']));
         $textDateElement = new Html\Element();
         $textDateElement->init('span', array('class' => self::$_config['className']['textDate']));
         $listElement = new Html\Element();
         $listElement->init('ul', array('class' => self::$_config['className']['list']));
         /* list directory object */
         $listDirectory = new Directory();
         $listDirectory->init($directory);
         $listDirectoryArray = $listDirectory->getArray();
         /* date format */
         $dateFormat = Db::getSettings('date');
         /* parent directory */
         if (is_dir($parentDirectory)) {
             $outputDirectory .= '<li>';
             $outputDirectory .= $linkElement->copy()->attr(array('href' => Registry::get('rewriteRoute') . Registry::get('fullRoute') . '&d=' . $parentDirectory . $hashString, 'title' => Language::get('directory_parent', '_directory_lister')))->addClass(self::$_config['className']['types']['directoryParent'])->text(Language::get('directory_parent', '_directory_lister'));
             $outputDirectory .= '</li>';
         }
         /* process directory */
         foreach ($listDirectoryArray as $key => $value) {
             $path = $directory . '/' . $value;
             $fileExtension = pathinfo($path, PATHINFO_EXTENSION);
             $text = $value;
             /* replace option */
             if ($options['replace']) {
                 foreach ($options['replace'] as $replaceKey => $replaceValue) {
                     if ($replaceKey === self::$_config['replaceKey']['extension']) {
                         $replaceKey = $fileExtension;
                     }
                     $text = str_replace($replaceKey, $replaceValue, $text);
                 }
             }
             /* handle directory */
             if (is_dir($path)) {
                 $outputDirectory .= '<li>';
                 $outputDirectory .= $linkElement->copy()->attr(array('href' => Registry::get('rewriteRoute') . Registry::get('fullRoute') . '&d=' . $path . $hashString, 'title' => Language::get('directory', '_directory_lister')))->addClass(self::$_config['className']['types']['directory'])->text($text);
                 $outputDirectory .= $textSizeElement->copy();
                 $outputDirectory .= $textDateElement->copy()->text(date($dateFormat, filectime($path)));
                 $outputDirectory .= '</li>';
             } else {
                 if (is_file($path)) {
                     if (array_key_exists($fileExtension, self::$_config['extension'])) {
                         $fileType = self::$_config['extension'][$fileExtension];
                         $outputFile .= '<li>';
                         $outputFile .= $linkElement->copy()->attr(array('href' => $path, 'target' => '_blank', 'title' => Language::get('file', '_directory_lister')))->addClass(self::$_config['className']['types'][$fileType])->text($text);
                         $outputFile .= $textSizeElement->copy()->attr('data-unit', self::$_config['size']['unit'])->html(ceil(filesize($path) / self::$_config['size']['divider']));
                         $outputFile .= $textDateElement->copy()->html(date($dateFormat, filectime($path)));
                         $outputFile .= '</li>';
                     }
                 }
             }
         }
         /* collect list output */
         if ($outputDirectory || $outputFile) {
             $output = $listElement->html($outputDirectory . $outputFile);
         }
     }
     return $output;
 }
Exemplo n.º 11
0
 /**
  * send
  *
  * @since 2.6.0
  *
  * @param array $postData
  */
 public static function _send($postData = array())
 {
     $toArray = array(Db::getSettings('author') => Db::getSettings('email'));
     $fromArray = array($postData['author'] => $postData['email']);
     $subject = Language::get('contact');
     $bodyArray = array(Language::get('author') . Language::get('colon') . ' ' . $postData['author'], '<br />', Language::get('email') . Language::get('colon') . ' <a href="mailto:' . $postData['email'] . '">' . $postData['email'] . '</a>', '<br />', Language::get('url') . Language::get('colon') . ' <a href="' . $postData['url'] . '">' . $postData['url'] . '</a>', '<br />', Language::get('message') . Language::get('colon') . ' ' . $postData['text']);
     /* send message */
     $mailer = new Mailer();
     $mailer->init($toArray, $fromArray, $subject, $bodyArray);
     $mailer->send();
 }
Exemplo n.º 12
0
 /**
  * testGetSettings
  *
  * @since 2.2.0
  *
  */
 public function testGetSettings()
 {
     /* actual */
     $actual = Db::getSettings('charset');
     /* compare */
     $this->assertEquals('utf-8', $actual);
 }
Exemplo n.º 13
0
 /**
  * render the breadcrumb trail as an unordered list
  *
  * @since 2.1.0
  *
  * @return string
  */
 public function render()
 {
     $output = Hook::trigger('breadcrumb_start');
     /* breadcrumb keys */
     $breadcrumbKeys = array_keys($this->_breadcrumbArray);
     $last = end($breadcrumbKeys);
     /* collect item output */
     foreach ($this->_breadcrumbArray as $key => $value) {
         $title = array_key_exists('title', $value) ? $value['title'] : null;
         $route = array_key_exists('route', $value) ? $value['route'] : null;
         if ($title) {
             $output .= '<li>';
             /* build link if route */
             if ($route) {
                 $output .= '<a href="' . $this->_registry->get('rewriteRoute') . $route . '" title="' . $title . '">' . $title . '</a>';
             } else {
                 $output .= $title;
             }
             $output .= '</li>';
             /* add divider */
             if ($last !== $key) {
                 $output .= '<li class="' . $this->_options['className']['divider'] . '">' . Db::getSettings('divider') . '</li>';
             }
         }
     }
     /* collect list output */
     if ($output) {
         $output = '<ul class="' . $this->_options['className']['list'] . '">' . $output . '</ul>';
     }
     $output .= Hook::trigger('breadcrumb_end');
     return $output;
 }
Exemplo n.º 14
0
 /**
  * render
  *
  * @since 2.3.0
  *
  * @param string $table
  *
  * @return string
  */
 public static function render($table = 'articles')
 {
     $output = '';
     /* fetch result */
     $result = Db::forTablePrefix($table)->where('status', 1)->where('access', 0)->where('language', Request::getQuery('l') ? Registry::get('language') : '')->orderGlobal('rank')->limitGlobal()->findArray();
     /* process result */
     if ($result) {
         $route = Registry::get('root') . '/' . Registry::get('rewriteRoute') . Registry::get('fullRoute');
         if (Request::getQuery('l')) {
             $route .= Registry::get('languageRoute') . Registry::get('language');
         }
         $title = Db::getSettings('title');
         $description = Db::getSettings('description');
         $author = Db::getSettings('author');
         $copyright = Db::getSettings('copyright');
         /* collect output */
         $output = '<?xml version="1.0" encoding="' . Db::getSettings('charset') . '"?>';
         $output .= '<feed xmlns="http://www.w3.org/2005/Atom">';
         $output .= '<id>' . $route . '</id>';
         $output .= '<link type="application/atom+xml" href="' . $route . '" rel="self" />';
         $output .= '<updated>' . date('c', strtotime(Registry::get('now'))) . '</updated>';
         /* title */
         if ($title) {
             $output .= '<title>' . $title . '</title>';
         }
         /* description */
         if ($description) {
             $output .= '<subtitle>' . $description . '</subtitle>';
         }
         /* author */
         if ($author) {
             $output .= '<author><name>' . $author . '</name></author>';
         }
         /* copyright */
         if ($copyright) {
             $output .= '<rights>' . $copyright . '</rights>';
         }
         /* generator */
         $output .= '<generator>' . Language::get('name', '_package') . ' ' . Language::get('version', '_package') . '</generator>';
         /* collect body output */
         foreach ($result as $value) {
             $route = Registry::get('root') . '/' . Registry::get('rewriteRoute');
             $route .= $value['category'] < 1 ? $value['alias'] : build_route($table, $value['id']);
             /* collect entry output */
             $output .= '<entry>';
             $output .= '<id>' . $route . '</id>';
             $output .= '<link href="' . $route . '" />';
             $output .= '<updated>' . date('c', strtotime($value['date'])) . '</updated>';
             /* title */
             $output .= '<title>' . ($table === 'comments' ? $value['author'] : $value['title']) . '</title>';
             /* description */
             if ($value['description']) {
                 $output .= '<summary>' . $value['description'] . '</summary>';
             }
             /* text */
             $output .= '<content>' . strip_tags($value['text']) . '</content>';
             /* author */
             if ($value['author']) {
                 $output .= '<author><name>' . $value['author'] . '</name></author>';
             }
             $output .= '</entry>';
         }
         $output .= '</feed>';
     }
     return $output;
 }
Exemplo n.º 15
0
 /**
  * init the class
  *
  * @since 2.1.0
  */
 public function init()
 {
     $this->_detect(array('query' => Request::getQuery('t'), 'session' => Request::getSession($this->_registry->get('root') . '/template'), 'contents' => $this->_registry->get('lastTable') ? Db::forPrefixTable($this->_registry->get('lastTable'))->where('id', $this->_registry->get('lastId'))->findOne()->template : null, 'settings' => Db::getSettings('template'), 'fallback' => 'default'), 'template', 'templates/{value}/index.phtml');
 }
Exemplo n.º 16
0
 /**
  * init the class
  *
  * @since 2.1.0
  */
 public function init()
 {
     $this->_detect(array('query' => Request::getQuery('l'), 'session' => Request::getSession($this->_registry->get('root') . '/language'), 'contents' => $this->_registry->get('lastTable') ? Db::forPrefixTable($this->_registry->get('lastTable'))->where('id', $this->_registry->get('lastId'))->findOne()->language : null, 'settings' => Db::getSettings('language'), 'browser' => substr(Request::getServer('HTTP_ACCEPT_LANGUAGE'), 0, 2), 'fallback' => 'en'), 'language', 'languages/{value}.json');
 }
Exemplo n.º 17
0
 /**
  * getImageData
  *
  * @since 2.6.0
  *
  * @param string $file
  *
  * @return array
  */
 public static function _getImageData($file = null)
 {
     $output = array();
     if (function_exists('exif_read_data')) {
         $exifData = exif_read_data($file);
     }
     /* has image data */
     if ($exifData) {
         $output['artist'] = $exifData['Artist'];
         $output['date'] = $exifData['DateTime'] ? date(Db::getSettings('data'), strtotime($exifData['DateTime'])) : null;
         $output['description'] = $exifData['ImageDescription'];
     }
     return $output;
 }
Exemplo n.º 18
0
 /**
  * render the breadcrumb trail as an unordered list
  *
  * @since 2.1.0
  *
  * @return string
  */
 public function render()
 {
     $output = Hook::trigger('breadcrumb_start');
     $outputItem = '';
     /* breadcrumb keys */
     $breadcrumbKeys = array_keys($this->_breadcrumbArray);
     $lastKey = end($breadcrumbKeys);
     /* html elements */
     $linkElement = new Element('a');
     $itemElement = new Element('li');
     $listElement = new Element('ul', array('class' => $this->_options['className']['list']));
     /* collect item output */
     foreach ($this->_breadcrumbArray as $key => $value) {
         $title = array_key_exists('title', $value) ? $value['title'] : null;
         $route = array_key_exists('route', $value) ? $value['route'] : null;
         if ($title) {
             $outputItem .= '<li>';
             /* build link if route */
             if ($route) {
                 $outputItem .= $linkElement->attr(array('href' => $this->_registry->get('rewriteRoute') . $route, 'title' => $title))->text($title);
             } else {
                 $outputItem .= $title;
             }
             $outputItem .= '</li>';
             /* add divider */
             if ($key !== $lastKey) {
                 $outputItem .= $itemElement->addClass($this->_options['className']['divider'])->text(Db::getSettings('divider'));
             }
         }
     }
     /* collect list output */
     if ($outputItem) {
         $output = $listElement->html($outputItem);
     }
     $output .= Hook::trigger('breadcrumb_end');
     return $output;
 }