+Message: getMessage(); ?>
+Code: getCode(); ?>
+File: getFile(); ?>
+Line: getLine(); ?>
+
'; +print_r($exception); +echo ''; + +echo '
'; +print_r($GLOBALS); +echo ''; +*/ +?> + + + + +
diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..5c04848 --- /dev/null +++ b/.htaccess @@ -0,0 +1,4 @@ +RewriteEngine On +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule ^(.*)$ index.php?qs=$1 [L] diff --git a/cms/cache/.dummy b/cms/cache/.dummy new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/cms/cache/.dummy @@ -0,0 +1 @@ + diff --git a/cms/config/.htaccess b/cms/config/.htaccess new file mode 100644 index 0000000..8d2f256 --- /dev/null +++ b/cms/config/.htaccess @@ -0,0 +1 @@ +deny from all diff --git a/cms/config/db_settings.conf.php b/cms/config/db_settings.conf.php new file mode 100644 index 0000000..29dc146 --- /dev/null +++ b/cms/config/db_settings.conf.php @@ -0,0 +1,20 @@ + diff --git a/cms/config/page_types.conf.php b/cms/config/page_types.conf.php new file mode 100644 index 0000000..5356d6a --- /dev/null +++ b/cms/config/page_types.conf.php @@ -0,0 +1,90 @@ + 'page_type_default', +'requires_parameter' => false +); + +$page_types['commentable_page'] = array( +'page_type' => 'commentable_page.php', +'page_type_label' => 'page_type_commentable', +'requires_parameter' => false +); + +$page_types['overview'] = array( +'page_type' => 'overview.php', +'page_type_label' => 'page_type_overview', +'requires_parameter' => false +); + +$page_types['news'] = array( +'page_type' => 'news.php', +'page_type_label' => 'page_type_news', +'requires_parameter' => false +); + +$page_types['simple_news'] = array( +'page_type' => 'simple_news.php', +'page_type_label' => 'page_type_simple_news', +'requires_parameter' => false +); + +$page_types['gallery'] = array( +'page_type' => 'gallery.php', +'page_type_label' => 'page_type_gallery', +'requires_parameter' => true +); + +$page_types['formmailer'] = array( +'page_type' => 'formmailer.php', +'page_type_label' => 'page_type_formmailer', +'requires_parameter' => true +); + +$page_types['redirect'] = array( +'page_type' => 'redirect.php', +'page_type_label' => 'page_type_redirect', +'requires_parameter' => true +); + +$page_types['notes'] = array( +'page_type' => 'notes.php', +'page_type_label' => 'page_type_notes', +'requires_parameter' => true +); + +$page_types['newsletter'] = array( +'page_type' => 'newsletter.php', +'page_type_label' => 'page_type_newsletter', +'requires_parameter' => false +); + +$page_types['search'] = array( +'page_type' => 'search.php', +'page_type_label' => 'page_type_search', +'requires_parameter' => false +); + +$page_types['lang_redirect'] = array( +'page_type' => 'language_redirect.php', +'page_type_label' => 'page_type_language_redirect', +'requires_parameter' => false +); + +$page_types['rss'] = array( +'page_type' => 'rss.php', +'page_type_label' => 'page_type_rss_feed', +'requires_parameter' => false +); + +$page_types['notes_rss'] = array( +'page_type' => 'notes_rss.php', +'page_type_label' => 'page_type_notes_rss_feed', +'requires_parameter' => true +); + +$page_types['sitemap'] = array( +'page_type' => 'sitemap.php', +'page_type_label' => 'page_type_sitemap', +'requires_parameter' => false +); +?> diff --git a/cms/config/smilies.conf.php b/cms/config/smilies.conf.php new file mode 100644 index 0000000..788a2a2 --- /dev/null +++ b/cms/config/smilies.conf.php @@ -0,0 +1,9 @@ +Welcome to phpSQLiteCMS with MySQL!\r\n\r\n
phpSQLiteCMS is a simple and lightweight open source web content management system (CMS) based on PHP and SQLite. It''s licensed under the GNU General Public License.
\r\n\r\nphpSQLiteCMS is good if you want to quickly set up a small website without needing to spend a lot of time studying, installing and configuring (as SQLite is file-based, it just runs "out of the box"). But note that it is no large scale content management system - it''s a tiny and simple one!
\r\n\r\nphpSQLiteCMS is a simple and lightweight open source web content management system (CMS) based on PHP and SQLite. It''s licensed under the GNU General Public License.
\r\n\r\nphpSQLiteCMS is good if you want to quickly set up a small website without needing to spend a lot of time studying, installing and configuring (as SQLite is file-based, it just runs "out of the box"). But note that it is no large scale content management system - it''s a tiny and simple one!
\r\n\r\nphpSQLiteCMS is a simple and lightweight open source web content management system (CMS) based on PHP and SQLite. It''s licensed under the GNU General Public License.
\r\n\r\nphpSQLiteCMS is good if you want to quickly set up a small website without needing to spend a lot of time studying, installing and configuring (as SQLite is file-based, it just runs "out of the box"). But note that it is no large scale content management system - it''s a tiny and simple one!
\r\n\r\n
+ * $comment = array(
+ * 'author' => 'viagra-test-123',
+ * 'email' => 'test@example.com',
+ * 'website' => 'http://www.example.com/',
+ * 'body' => 'This is a test comment',
+ * 'permalink' => 'http://yourdomain.com/yourblogpost.url',
+ * );
+ *
+ * $akismet = new Akismet('http://www.yourdomain.com/', 'YOUR_WORDPRESS_API_KEY', $comment);
+ *
+ * if($akismet->errorsExist()) {
+ * echo"Couldn't connected to Akismet server!";
+ * } else {
+ * if($akismet->isSpam()) {
+ * echo"Spam detected";
+ * } else {
+ * echo"yay, no spam!";
+ * }
+ * }
+ *
+ *
+ * @author Bret Kuhns {@link www.miphp.net}
+ * @link http://www.miphp.net/blog/view/new_akismet_class/
+ * @version 0.3.4
+ * @license http://www.opensource.org/licenses/mit-license.php MIT License
+ */
+
+
+
+// Error constants
+define("AKISMET_SERVER_NOT_FOUND", 0);
+define("AKISMET_RESPONSE_FAILED", 1);
+define("AKISMET_INVALID_KEY", 2);
+
+
+
+// Base class to assist in error handling between Akismet classes
+class AkismetObject {
+ var $errors = array();
+
+
+ /**
+ * Add a new error to the errors array in the object
+ *
+ * @param String $name A name (array key) for the error
+ * @param String $string The error message
+ * @return void
+ */
+ // Set an error in the object
+ function setError($name, $message) {
+ $this->errors[$name] = $message;
+ }
+
+
+ /**
+ * Return a specific error message from the errors array
+ *
+ * @param String $name The name of the error you want
+ * @return mixed Returns a String if the error exists, a false boolean if it does not exist
+ */
+ function getError($name) {
+ if($this->isError($name)) {
+ return $this->errors[$name];
+ } else {
+ return false;
+ }
+ }
+
+
+ /**
+ * Return all errors in the object
+ *
+ * @return String[]
+ */
+ function getErrors() {
+ return (array)$this->errors;
+ }
+
+
+ /**
+ * Check if a certain error exists
+ *
+ * @param String $name The name of the error you want
+ * @return boolean
+ */
+ function isError($name) {
+ return isset($this->errors[$name]);
+ }
+
+
+ /**
+ * Check if any errors exist
+ *
+ * @return boolean
+ */
+ function errorsExist() {
+ return (count($this->errors) > 0);
+ }
+
+
+}
+
+
+
+
+
+// Used by the Akismet class to communicate with the Akismet service
+class AkismetHttpClient extends AkismetObject {
+ var $akismetVersion = '1.1';
+ var $con;
+ var $host;
+ var $port;
+ var $apiKey;
+ var $blogUrl;
+ var $errors = array();
+
+
+ // Constructor
+ function AkismetHttpClient($host, $blogUrl, $apiKey, $port = 80) {
+ $this->host = $host;
+ $this->port = $port;
+ $this->blogUrl = $blogUrl;
+ $this->apiKey = $apiKey;
+ }
+
+
+ // Use the connection active in $con to get a response from the server and return that response
+ function getResponse($request, $path, $type = "post", $responseLength = 1160) {
+ $this->_connect();
+
+ if($this->con && !$this->isError(AKISMET_SERVER_NOT_FOUND)) {
+ $request =
+ strToUpper($type)." /{$this->akismetVersion}/$path HTTP/1.0\r\n" .
+ "Host: ".((!empty($this->apiKey)) ? $this->apiKey."." : null)."{$this->host}\r\n" .
+ "Content-Type: application/x-www-form-urlencoded; charset=utf-8\r\n" .
+ "Content-Length: ".strlen($request)."\r\n" .
+ "User-Agent: Akismet PHP4 Class\r\n" .
+ "\r\n" .
+ $request
+ ;
+ $response = "";
+
+ @fwrite($this->con, $request);
+
+ while(!feof($this->con)) {
+ $response .= @fgets($this->con, $responseLength);
+ }
+
+ $response = explode("\r\n\r\n", $response, 2);
+ return $response[1];
+ } else {
+ $this->setError(AKISMET_RESPONSE_FAILED, "The response could not be retrieved.");
+ }
+
+ $this->_disconnect();
+ }
+
+
+ // Connect to the Akismet server and store that connection in the instance variable $con
+ function _connect() {
+ if(!($this->con = @fsockopen($this->host, $this->port, $errno, $errstr, 25))) {
+ $this->setError(AKISMET_SERVER_NOT_FOUND, "Could not connect to akismet server.");
+ }
+ }
+
+
+ // Close the connection to the Akismet server
+ function _disconnect() {
+ @fclose($this->con);
+ }
+
+
+}
+
+
+
+
+
+// The controlling class. This is the ONLY class the user should instantiate in
+// order to use the Akismet service!
+class Akismet extends AkismetObject {
+ var $apiPort = 80;
+ var $akismetServer = 'rest.akismet.com';
+ var $akismetVersion = '1.1';
+ var $http;
+
+ var $ignore = array(
+ 'HTTP_COOKIE',
+ 'HTTP_X_FORWARDED_FOR',
+ 'HTTP_X_FORWARDED_HOST',
+ 'HTTP_MAX_FORWARDS',
+ 'HTTP_X_FORWARDED_SERVER',
+ 'REDIRECT_STATUS',
+ 'SERVER_PORT',
+ 'PATH',
+ 'DOCUMENT_ROOT',
+ 'SERVER_ADMIN',
+ 'QUERY_STRING',
+ 'PHP_SELF',
+ 'argv'
+ );
+
+ var $blogUrl = "";
+ var $apiKey = "";
+ var $comment = array();
+
+
+ /**
+ * Constructor
+ *
+ * Set instance variables, connect to Akismet, and check API key
+ *
+ * @param String $blogUrl The URL to your own blog
+ * @param String $apiKey Your wordpress API key
+ * @param String[] $comment A formatted comment array to be examined by the Akismet service
+ * @return Akismet
+ */
+ function Akismet($blogUrl, $apiKey, $comment = array()) {
+ $this->blogUrl = $blogUrl;
+ $this->apiKey = $apiKey;
+ $this->setComment($comment);
+
+ // Connect to the Akismet server and populate errors if they exist
+ $this->http = new AkismetHttpClient($this->akismetServer, $blogUrl, $apiKey);
+ if($this->http->errorsExist()) {
+ $this->errors = array_merge($this->errors, $this->http->getErrors());
+ }
+
+ // Check if the API key is valid
+ if(!$this->_isValidApiKey($apiKey)) {
+ $this->setError(AKISMET_INVALID_KEY, "Your Akismet API key is not valid.");
+ }
+ }
+
+
+ /**
+ * Query the Akismet and determine if the comment is spam or not
+ *
+ * @return boolean
+ */
+ function isSpam() {
+ $response = $this->http->getResponse($this->_getQueryString(), 'comment-check');
+
+ return ($response == "true");
+ }
+
+
+ /**
+ * Submit this comment as an unchecked spam to the Akismet server
+ *
+ * @return void
+ */
+ function submitSpam() {
+ $this->http->getResponse($this->_getQueryString(), 'submit-spam');
+ }
+
+
+ /**
+ * Submit a false-positive comment as "ham" to the Akismet server
+ *
+ * @return void
+ */
+ function submitHam() {
+ $this->http->getResponse($this->_getQueryString(), 'submit-ham');
+ }
+
+
+ /**
+ * Manually set the comment value of the instantiated object.
+ *
+ * @param Array $comment
+ * @return void
+ */
+ function setComment($comment) {
+ $this->comment = $comment;
+ if(!empty($comment)) {
+ $this->_formatCommentArray();
+ $this->_fillCommentValues();
+ }
+ }
+
+
+ /**
+ * Returns the current value of the object's comment array.
+ *
+ * @return Array
+ */
+ function getComment() {
+ return $this->comment;
+ }
+
+
+ /**
+ * Check with the Akismet server to determine if the API key is valid
+ *
+ * @access Protected
+ * @param String $key The Wordpress API key passed from the constructor argument
+ * @return boolean
+ */
+ function _isValidApiKey($key) {
+ $keyCheck = $this->http->getResponse("key=".$this->apiKey."&blog=".$this->blogUrl, 'verify-key');
+
+ return ($keyCheck == "valid");
+ }
+
+
+ /**
+ * Format the comment array in accordance to the Akismet API
+ *
+ * @access Protected
+ * @return void
+ */
+ function _formatCommentArray() {
+ $format = array(
+ 'type' => 'comment_type',
+ 'author' => 'comment_author',
+ 'email' => 'comment_author_email',
+ 'website' => 'comment_author_url',
+ 'body' => 'comment_content'
+ );
+
+ foreach($format as $short => $long) {
+ if(isset($this->comment[$short])) {
+ $this->comment[$long] = $this->comment[$short];
+ unset($this->comment[$short]);
+ }
+ }
+ }
+
+
+ /**
+ * Fill any values not provided by the developer with available values.
+ *
+ * @return void
+ */
+ function _fillCommentValues() {
+ if(!isset($this->comment['user_ip'])) {
+ $this->comment['user_ip'] = ($_SERVER['REMOTE_ADDR'] != getenv('SERVER_ADDR')) ? $_SERVER['REMOTE_ADDR'] : getenv('HTTP_X_FORWARDED_FOR');
+ }
+ if(!isset($this->comment['user_agent'])) {
+ $this->comment['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
+ }
+ if(!isset($this->comment['referrer'])) {
+ $this->comment['referrer'] = $_SERVER['HTTP_REFERER'];
+ }
+ if(!isset($this->comment['blog'])) {
+ $this->comment['blog'] = $this->blogUrl;
+ }
+ }
+
+
+ /**
+ * Build a query string for use with HTTP requests
+ *
+ * @access Protected
+ * @return String
+ */
+ function _getQueryString() {
+ foreach($_SERVER as $key => $value) {
+ if(!in_array($key, $this->ignore)) {
+ if($key == 'REMOTE_ADDR') {
+ $this->comment[$key] = $this->comment['user_ip'];
+ } else {
+ $this->comment[$key] = $value;
+ }
+ }
+ }
+
+ $query_string = '';
+
+ foreach($this->comment as $key => $data) {
+ $query_string .= $key . '=' . urlencode(stripslashes($data)) . '&';
+ }
+
+ return $query_string;
+ }
+
+
+}
+?>
diff --git a/cms/includes/classes/Cache.class.php b/cms/includes/classes/Cache.class.php
new file mode 100644
index 0000000..e5df5a0
--- /dev/null
+++ b/cms/includes/classes/Cache.class.php
@@ -0,0 +1,136 @@
+_cacheDir = $cacheDir;
+ $this->_settings = $settings;
+ }
+
+ public function createCacheContent($content, $content_type, $charset)
+ {
+ $cacheContent = ''.gzencode($content, 9).''.$content.''.$content.'';
+ return $cacheContent;
+ }
+
+ public function createChacheFile($content)
+ {
+ if($this->cacheId && $this->doCaching)
+ {
+ #$cacheFile = $this->_cacheDir . str_replace('/','%',$this->cacheId).'.cache';
+ $cacheFile = $this->_cacheDir . rawurlencode(strtolower($this->cacheId)).'.cache';
+ if(!file_exists($cacheFile))
+ {
+ $content = str_replace('', $content);
+ $fp = @fopen($cacheFile, 'w');
+ @flock($fp, 2);
+ @fwrite($fp, $content);
+ @flock($fp, 3);
+ @fclose($fp);
+ }
+ }
+
+ if(!file_exists($this->_cacheDir.'settings.php'))
+ {
+ $this->_createCacheSettingsFile();
+ }
+ }
+
+ private function _createCacheSettingsFile()
+ {
+ $content = "_settings['session_prefix'].'\';'."\n";
+ $content .= '$settings[\'index_page\'] = \''.$this->_settings['index_page'].'\';'."\n";
+ #$content .= '$settings[\'caching\'] = '.$this->_settings['caching'].';'."\n";
+ $content .= '?'.'>';
+ $fp = @fopen($this->_cacheDir.'settings.php', 'w');
+ @flock($fp, 2);
+ @fwrite($fp, $content);
+ @flock($fp, 3);
+ @fclose($fp);
+ }
+
+ public function clear($page=false)
+ {
+ if(!$page)
+ {
+ // delete all cache files (settings.php and *.cache):
+ foreach(glob($this->_cacheDir.'{settings.php,*.cache}', GLOB_BRACE) as $cacheFile)
+ {
+ @unlink($cacheFile);
+ }
+ }
+ else
+ {
+ // delete cache files of a specifid page:
+ $page = rawurlencode(strtolower($page));
+ // select page.cache and page,*.cahe
+ foreach(glob($this->_cacheDir.'{'.$page.'.cache,'.$page.'%2C*.cache}', GLOB_BRACE) as $cacheFile) // "%2C" = ","
+ {
+ @unlink($cacheFile);
+ }
+ }
+ }
+
+ public function clearPhoto($id)
+ {
+ // select *,photo,[id].cache and *,photo,[id],*.cache
+ foreach(glob($this->_cacheDir.'{*%2C'.IMAGE_IDENTIFIER.'%2C'.$id.'.cache,*%2C'.IMAGE_IDENTIFIER.'%2C'.$id.'%2C*.cache}', GLOB_BRACE) as $cacheFile)
+ {
+ @unlink($cacheFile);
+ }
+ }
+
+ function clearRelated($page)
+ {
+ $dbr = Database::$content->prepare("SELECT include_page FROM ".Database::$db_settings['pages_table']." WHERE lower(page)=lower(:page) LIMIT 1");
+ $dbr->bindParam(':page', $page, PDO::PARAM_STR);
+ $dbr->execute();
+ $data = $dbr->fetch();
+ if(isset($data['include_page']))
+ {
+ $dbr2 = Database::$content->prepare("SELECT page, type FROM ".Database::$db_settings['pages_table']." WHERE id=:id LIMIT 1");
+ $dbr2->bindParam(':id', $data['include_page'], PDO::PARAM_INT);
+ $dbr2->execute();
+ $data2 = $dbr2->fetch();
+ if(isset($data2['page']))
+ {
+ #if($data2['type']=='news')
+ # {
+ $this->clear($data2['page']);
+ # }
+ }
+ }
+ }
+ }
+?>
diff --git a/cms/includes/classes/Comment.class.php b/cms/includes/classes/Comment.class.php
new file mode 100644
index 0000000..9b6af52
--- /dev/null
+++ b/cms/includes/classes/Comment.class.php
@@ -0,0 +1,624 @@
+_localization = Localization::getInstance();
+ $this->type = $type;
+ $this->page = $page;
+ $this->comment_id = $comment_id;
+ $this->form_values['comment_text'] = isset($_POST['comment_text']) ? htmlspecialchars($_POST['comment_text']) : '';
+ $this->form_values['name'] = isset($_POST['name']) ? htmlspecialchars($_POST['name']) : '';
+ $this->form_values['email_hp'] = isset($_POST['email_hp']) ? htmlspecialchars($_POST['email_hp']) : '';
+ $this->_form_session = 'comment_form_session_'.$this->comment_id.'_'.$this->type;
+
+ if($this->type==1)
+ {
+ if(isset($_GET['get_5'])) $this->current_page = intval($_GET['get_5']); else $this->current_page = 1;
+ }
+ else
+ {
+ if(isset($_GET['get_1'])) $this->current_page = intval($_GET['get_1']); else $this->current_page = 1;
+ }
+
+ if($this->current_page==0) $this->current_page = 1;
+
+
+ if(isset($_SESSION[$this->_form_session]))
+ {
+ $this->form_session = $_SESSION[$this->_form_session];
+ $form_session_data['name'] = session_name();
+ $form_session_data['id'] = session_id();
+ $this->form_session_data = $form_session_data;
+ }
+ }
+
+ public function set_admin_mode()
+ {
+ $this->admin_mode = true;
+ }
+
+ public function get_comments($rss=false)
+ {
+ // count:
+ $this->total_comments = $this->count_comments($this->comment_id);
+
+ $this->total_pages = ceil($this->total_comments / $this->comments_per_page);
+ if($this->current_page>$this->total_pages) $this->current_page = $this->total_pages;
+
+ #$this->comment_page = $current_page;
+
+ if($this->total_comments > 0)
+ {
+ if($rss) $dbr = Database::$entries->prepare("SELECT id, time, name, email_hp, comment, ip FROM ".Database::$db_settings['comment_table']." WHERE type=:type AND comment_id=:comment_id AND comment!='' ORDER BY id ASC LIMIT ".$this->comments_per_page);
+ else $dbr = Database::$entries->prepare("SELECT id, time, name, email_hp, comment, ip FROM ".Database::$db_settings['comment_table']." WHERE type=:type AND comment_id=:comment_id AND comment!='' ORDER BY id DESC LIMIT ".$this->comments_per_page." OFFSET ".(intval($this->current_page)-1)*$this->comments_per_page);
+ $dbr->bindParam(':type', $this->type, PDO::PARAM_INT);
+ $dbr->bindParam(':comment_id', $this->comment_id, PDO::PARAM_INT);
+ $dbr->execute();
+
+ $nr = 1;
+ $i = 0;
+ while($data = $dbr->fetch())
+ {
+ #if ($data['name'] != "") $name = htmlspecialchars(stripslashes($data['name'])); else $name = $this->settings['anonym'];
+ if($data['email_hp']!='')
+ {
+ $email_hp = htmlspecialchars($data['email_hp']);
+ if(preg_match("/^[^@]+@.+\.\D{2,5}$/", $email_hp))
+ {
+ if($this->admin_mode)
+ {
+ $comments[$i]['email'] = $email_hp;
+ }
+ }
+ else
+ {
+ $comments[$i]['hp'] = add_http_if_no_protocol($email_hp);
+ }
+ }
+ $comments[$i]['id'] = $data['id'];
+ $comments[$i]['nr'] = $this->total_comments + 1 - ($nr + ($this->current_page-1) * $this->comments_per_page);
+ $comments[$i]['name'] = htmlspecialchars($data['name']);
+ $comments[$i]['time'] = $data['time'];
+ #$comments[$i]['formated_time'] = format_time(TIME_FORMAT_FULL,$data['time']);
+ $comments[$i]['comment'] = $this->format_comment($data['comment']);
+ $comments[$i]['ip'] = $data['ip'];
+
+ $this->_localization->bindId('comment_time', $data['id']);
+ $this->_localization->replacePlaceholderBound('time', $data['time'], 'comment_time', $data['id'], Localization::FORMAT_TIME);
+
+ ++$nr;
+ ++$i;
+ } // end foreach
+
+ // reverse array for ascending order:
+ if($this->comment_order == 1) $comments = array_reverse($comments);
+
+ $this->_localization->replacePlaceholder('total_comments', $this->total_comments, 'comments_pagination_info');
+ $this->_localization->replacePlaceholder('current_page', $this->current_page, 'comments_pagination_info');
+ $this->_localization->replacePlaceholder('total_pages', $this->total_pages, 'comments_pagination_info');
+
+ #$this->assign_lang_placeholder('total_comments', $this->total_comments, 'comments_pagination_info');
+ #$this->assign_lang_placeholder('current_page', $this->current_page, 'comments_pagination_info');
+ #$this->assign_lang_placeholder('total_pages', $this->total_pages, 'comments_pagination_info');
+
+ } // end if ($comment_count > 0)
+
+ $this->form_values = $this->get_form_values();
+
+ if(isset($comments))
+ {
+ return $comments;
+ }
+ return false;
+ }
+
+ public function get_pingbacks()
+ {
+ $dbr = Database::$entries->prepare("SELECT id, time, name, email_hp, comment, ip FROM ".Database::$db_settings['comment_table']." WHERE type=:type AND comment_id=:comment_id AND comment='' ORDER BY id DESC");
+ $dbr->bindParam(':type', $this->type, PDO::PARAM_INT);
+ $dbr->bindParam(':comment_id', $this->comment_id, PDO::PARAM_INT);
+ $dbr->execute();
+
+ $nr = 1;
+ $i = 0;
+ while($data = $dbr->fetch())
+ {
+ $pingbacks[$i]['hp'] = $data['email_hp'];
+ $pingbacks[$i]['id'] = $data['id'];
+ $pingbacks[$i]['nr'] = $this->total_comments + 1 - ($nr + ($this->current_page-1) * $this->comments_per_page);
+ $pingbacks[$i]['name'] = htmlspecialchars($data['name']);
+ $pingbacks[$i]['time'] = $data['time'];
+ #$pingbacks[$i]['formated_time'] = format_time(TIME_FORMAT_FULL,$data['time']);
+ #$pingbacks[$i]['comment'] = $this->format_comment($data['comment']);
+ $pingbacks[$i]['ip'] = $data['ip'];
+
+ $this->_localization->bindId('comment_time', $data['id']);
+ $this->_localization->replacePlaceholderBound('time', $data['time'], 'comment_time', $data['id'], Localization::FORMAT_TIME);
+
+ ++$nr;
+ ++$i;
+ } // end foreach
+
+ // reverse array for ascending order:
+ if($this->comment_order == 1 && isset($pingbacks)) $pingbacks = array_reverse($pingbacks);
+
+
+ #$this->form_values = $this->get_form_values();
+
+ if(isset($pingbacks))
+ {
+ return $pingbacks;
+ }
+ return false;
+ }
+
+ public function save()
+ {
+ if(empty($_SESSION[$this->_form_session]))
+ {
+ #$this->preview();
+ }
+ else
+ {
+ // if comment entered::
+ $data['comment_text'] = isset($_POST['comment_text']) ? trim(filter_control_characters($_POST['comment_text'])) : '';
+ $data['name'] = isset($_POST['name']) ? trim(filter_control_characters($_POST['name'])) : '';
+ $data['email_hp'] = isset($_POST['email_hp']) ? trim(filter_control_characters($_POST['email_hp'])) : '';
+
+ // check posted data:
+ $this->check_data($data, true);
+
+ // save if no errors:
+ if($this->errors==false)
+ {
+ $dbr = Database::$entries->prepare("INSERT INTO ".Database::$db_settings['comment_table']." (type, comment_id, time, ip, name, email_hp, comment) VALUES (:type, :comment_id, :time, :ip, :name, :email_hp, :comment)");
+ $dbr->bindParam(':type', $this->type, PDO::PARAM_INT);
+ $dbr->bindParam(':comment_id', $this->comment_id, PDO::PARAM_INT);
+ $dbr->bindValue(':time', time(), PDO::PARAM_INT);
+ $dbr->bindParam(':ip', $_SERVER['REMOTE_ADDR'], PDO::PARAM_STR);
+ $dbr->bindParam(':name', $data['name'], PDO::PARAM_STR);
+ $dbr->bindParam(':email_hp', $data['email_hp'], PDO::PARAM_STR);
+ $dbr->bindParam(':comment', $data['comment_text'], PDO::PARAM_STR);
+ $dbr->execute();
+ #$this->clear_cache();
+ #showme(Database::$entries->errorInfo());
+ #$this->form_values = array();
+
+ unset($_SESSION[$this->_form_session]);
+ $this->form_session=false;
+ $this->form_session_data=false;
+
+ // E-mail notification to admin:
+ if($this->settings['comment_notification'] && $this->settings['email'] != '')
+ {
+ $this->_localization->replacePlaceholder('page', PAGE, 'comment_notification_subject');
+ $name = $data['name'];
+ if($data['email_hp']) $name .= ' '.$data['email_hp'];
+ $this->_localization->replacePlaceholder('name', $name, 'comment_notification_message');
+ $this->_localization->replacePlaceholder('comment', $data['comment_text'], 'comment_notification_message');
+ $this->_localization->replacePlaceholder('link', BASE_URL.PAGE, 'comment_notification_message');
+ $mail = new Mail();
+ $mail->set_charset(CHARSET);
+ $mail->send($this->settings['email'], $this->settings['email'], Localization::$lang['comment_notification_subject'], Localization::$lang['comment_notification_message'], $this->settings['mail_parameter']);
+ }
+ return true;
+ }
+ }
+ $_SESSION[$this->_form_session] = time();
+ $this->form_session = $_SESSION[$this->_form_session];
+ return false;
+ }
+
+ public function preview()
+ {
+ $data['comment_text'] = isset($_POST['comment_text']) ? trim($_POST['comment_text']) : '';
+ $data['name'] = isset($_POST['name']) ? trim($_POST['name']) : '';
+ $data['email_hp'] = isset($_POST['email_hp']) ? trim($_POST['email_hp']) : '';
+
+ // check posted data:
+ $this->check_data($data);
+
+ $preview['name'] = htmlspecialchars($data['name']);
+ $preview['timestamp'] = time();
+ $preview['time'] = time();
+ #$preview['formated_time'] = format_time(TIME_FORMAT_FULL,time());
+ $preview['comment_text'] = $this->format_comment($data['comment_text']);
+ $email_hp = htmlspecialchars($data['email_hp']);
+ if(preg_match("/^[^@]+@.+\.\D{2,5}$/", $email_hp))
+ {
+ if($this->admin_mode)
+ {
+ $preview['email'] = $email_hp;
+ }
+ }
+ elseif($email_hp!='')
+ {
+ $preview['hp'] = add_http_if_no_protocol($email_hp);
+ }
+
+ $this->_localization->bindId('comment_time', 'preview');
+ $this->_localization->replacePlaceholderBound('time', $preview['time'], 'comment_time', 'preview', Localization::FORMAT_TIME);
+
+ $_SESSION[$this->_form_session] = time();
+ $this->form_session = $_SESSION[$this->_form_session];
+
+ if(isset($preview))
+ {
+ return $preview;
+ }
+ return false;
+ }
+
+ private function check_data($data, $save=false)
+ {
+ if($this->comments_closed!=false)
+ {
+ $this->errors[] = 'comment_error_closed';
+ }
+
+ if(empty($this->errors) && $save) // only if submitted in order to save
+ {
+ if(empty($_SESSION[$this->_form_session]))
+ {
+ $this->errors[] = 'comment_error_invalid_request';
+ }
+ else
+ {
+ if(time()-$_SESSION[$this->_form_session]<2)
+ {
+ $this->errors[] = 'comment_error_too_fast';
+ }
+ }
+ }
+
+ if(empty($this->errors))
+ {
+ // check for not accepted words:
+ $joined_message = mb_strtolower($data['name'].' '.$data['email_hp'].' '.$data['comment_text']);
+ $not_accepted_words = get_not_accepted_words($joined_message);
+ if($not_accepted_words!=false)
+ {
+ $not_accepted_words_listing = htmlspecialchars(implode(', ',$not_accepted_words));
+ if(count($not_accepted_words)==1)
+ {
+ $this->errors[] = 'error_not_accepted_word';
+ #$this->assign_lang_placeholder('not_accepted_word', $not_accepted_words_listing, 'error_not_accepted_word');
+ $this->_localization->replacePlaceholder('not_accepted_word', $not_accepted_words_listing, 'error_not_accepted_word');
+ }
+ else
+ {
+ $this->errors[] = 'error_not_accepted_words';
+ #$this->assign_lang_placeholder('not_accepted_words', $not_accepted_words_listing, 'error_not_accepted_words');
+ $this->_localization->replacePlaceholder('not_accepted_words', $not_accepted_wordss_listing, 'error_not_accepted_words');
+ }
+ }
+ if(empty($data['name']))
+ {
+ $this->errors[] = 'comment_error_no_name';
+ }
+ if(empty($data['comment_text']))
+ {
+ $this->errors[] = 'comment_error_no_text';
+ }
+ if(mb_strlen($data['name']) > $this->name_maxlength)
+ {
+ $this->errors[] = 'comment_error_name_too_long';
+ }
+ if(mb_strlen($data['email_hp']) > $this->email_hp_maxlength)
+ {
+ $this->errors[] = 'comment_error_email_hp_too_long';
+ }
+ if(!empty($data['email_hp']) && strpos($data['email_hp'], '.')===false)
+ {
+ $this->errors[] = 'comment_error_email_hp_invalid';
+ }
+ if(mb_strlen($data['comment_text']) > $this->comment_maxlength)
+ {
+ $text_length = mb_strlen($data['comment_text']);
+ $this->errors[] = 'comment_error_text_too_long';
+ $this->_localization->replacePlaceholder('characters', $text_length, 'comment_error_text_too_long');
+ $this->_localization->replacePlaceholder('max_characters', $this->comment_maxlength, 'comment_error_text_too_long');
+ }
+ }
+
+ if(empty($this->errors))
+ {
+ if($too_long_words = too_long_words(strip_tags($this->format_comment($data['comment_text'])),$this->word_maxlength))
+ {
+ foreach($too_long_words as $too_long_word)
+ {
+ $stripped_too_long_words[] = htmlspecialchars(mb_substr($too_long_word,0,$this->word_maxlength)).'...';
+ }
+ $too_long_words_listing = implode(', ',$stripped_too_long_words);
+
+ if(count($too_long_words)==1)
+ {
+ $this->errors[] = 'comment_error_too_long_word';
+ #$this->assign_lang_placeholder('word', $too_long_words_listing, 'comment_error_too_long_word');
+ $this->_localization->replacePlaceholder('word', $too_long_word_listing, 'comment_error_too_long_word');
+ }
+ else
+ {
+ $this->errors[] = 'comment_error_too_long_words';
+ #$this->assign_lang_placeholder('words', $too_long_words_listing, 'comment_error_too_long_words');
+ $this->_localization->replacePlaceholder('words', $too_long_words_listing, 'comment_error_too_long_words');
+ }
+ }
+
+ // check for double and repeated entries:
+ $dbr = Database::$entries->prepare("SELECT COUNT(*) FROM ".Database::$db_settings['comment_table']." WHERE time>:time AND comment_id=:comment_id AND name=:name AND email_hp=:email_hp AND comment=:comment");
+ $time = time()-300; // last 5 minutes
+ $dbr->bindParam(':time', $time, PDO::PARAM_INT);
+ $dbr->bindParam(':comment_id', $this->comment_id, PDO::PARAM_INT);
+ $dbr->bindParam(':name', $data['name'], PDO::PARAM_STR);
+ $dbr->bindParam(':email_hp', $data['email_hp'], PDO::PARAM_STR);
+ $dbr->bindParam(':comment', $data['comment_text'], PDO::PARAM_STR);
+ $dbr->execute();
+ if($dbr->fetchColumn()>0)
+ {
+ $this->errors[] = 'comment_error_entry_exists';
+ }
+ if($this->prevent_repeated_posts_minutes > 0)
+ {
+ $dbr = Database::$entries->prepare("SELECT COUNT(*) FROM ".Database::$db_settings['comment_table']." WHERE time>:time AND comment_id=:comment_id AND ip=:ip");
+ $time = time() - $this->prevent_repeated_posts_minutes * 60;
+ $dbr->bindParam(':time', $time, PDO::PARAM_INT);
+ $dbr->bindParam(':comment_id', $this->comment_id, PDO::PARAM_INT);
+ $dbr->bindParam(':ip', $_SERVER["REMOTE_ADDR"], PDO::PARAM_STR);
+ $dbr->execute();
+ if($dbr->fetchColumn()>0)
+ {
+ $this->errors[] = 'comment_error_repeated_post';
+ }
+ }
+
+ if($save)
+ {
+ // Akismet spam check:
+ if($this->akismet_key!='' && $this->akismet_entry_check==1)
+ {
+ #require('./cms/modules/akismet/akismet.class.php');
+ $check_posting['author'] = $data['name'];
+ if($data['email_hp']!='')
+ {
+ if(preg_match("/^[^@]+@.+\.\D{2,5}$/", $email_hp))
+ {
+ $check_posting['email'] = $data['email_hp'];
+ }
+ else
+ {
+ $check_posting['website'] = $data['email_hp'];
+ }
+ }
+ $check_posting['body'] = $data['comment_text'];
+
+ $akismet = new Akismet(BASE_URL, $this->akismet_key, $check_posting);
+
+ // test for errors
+ if($akismet->errorsExist()) // returns true if any errors exist
+ {
+ if($akismet->isError(AKISMET_INVALID_KEY))
+ {
+ $this->errors[] = 'akismet_error_api_key';
+ }
+ elseif($akismet->isError(AKISMET_RESPONSE_FAILED))
+ {
+ $this->errors[] = 'akismet_error_connection';
+ }
+ elseif($akismet->isError(AKISMET_SERVER_NOT_FOUND))
+ {
+ $this->errors[] = 'akismet_error_connection';
+ }
+ }
+ else
+ {
+ // No errors, check for spam
+ if($akismet->isSpam())
+ {
+ $this->errors[] = 'akismet_spam_suspicion';
+ }
+ }
+ }
+ } // end if($save)
+ }
+ }
+
+ public function get_edit_data($id)
+ {
+ if($this->admin_mode)
+ {
+ $dbr = Database::$entries->prepare("SELECT id, name, email_hp, comment FROM ".Database::$db_settings['comment_table']." WHERE id=:id LIMIT 1");
+ $dbr->bindParam(':id', $id, PDO::PARAM_INT);
+ $dbr->execute();
+ $data = $dbr->fetch();
+ if(isset($data['id']))
+ {
+ $this->edit_form['id'] = $data['id'];
+ $this->edit_form['name'] = htmlspecialchars($data['name']);
+ $this->edit_form['email_hp'] = htmlspecialchars($data['email_hp']);
+ $this->edit_form['comment'] = htmlspecialchars($data['comment']);
+ $this->edit_form['current_page'] = $this->current_page;
+ return $this->edit_form;
+ }
+ return false;
+ }
+ }
+
+ public function edit_save()
+ {
+ if($this->admin_mode)
+ {
+ $dbr = Database::$entries->prepare("UPDATE ".Database::$db_settings['comment_table']." SET name=:name, email_hp=:email_hp, comment=:comment WHERE id=:id");
+ $dbr->bindParam(':id', $_POST['id'], PDO::PARAM_INT);
+ $dbr->bindParam(':name', $_POST['name'], PDO::PARAM_STR);
+ $dbr->bindParam(':email_hp', $_POST['email_hp'], PDO::PARAM_STR);
+ $dbr->bindParam(':comment', $_POST['comment_text'], PDO::PARAM_STR);
+ $dbr->execute();
+ if(isset($_POST['current_page']))
+ {
+ $this->current_page = intval($_POST['current_page']);
+ }
+ }
+ }
+
+ public function openclose($close=true)
+ {
+ if($this->admin_mode)
+ {
+ if($close) $new_type_addition = 'closed';
+ else $new_type_addition = '';
+
+ $dbr = Database::$content->prepare("UPDATE ".Database::$db_settings['pages_table']." SET type_addition=:type_addition WHERE page=:page");
+ $dbr->bindParam(':type_addition', $new_type_addition, PDO::PARAM_STR);
+ $dbr->bindValue(':page', PAGE, PDO::PARAM_STR);
+ $dbr->execute();
+ }
+ }
+
+
+ public function delete($id)
+ {
+ if($this->admin_mode)
+ {
+ $dbr = Database::$entries->prepare("DELETE FROM ".Database::$db_settings['comment_table']." WHERE id=:id");
+ $dbr->bindParam(':id', $id, PDO::PARAM_INT);
+ $dbr->execute();
+ #$this->clear_cache();
+ }
+ }
+
+ /*
+ private function clear_cache()
+ {
+ if($this->settings['caching']==1)
+ {
+ if($this->type==1)
+ {
+ $cachefile = "../cache/".$this->page.".cache";
+ if(file_exists($cachefile)) @unlink($cachefile);
+ unset($cachefile);
+ $cachefile = "../cache/".$this->page.",photo,".$this->comment_id.".cache";
+ if(file_exists($cachefile)) @unlink($cachefile);
+ unset($cachefile);
+ foreach(glob("../cache/".$this->page.",photo,".$this->comment_id.",*.cache") as $cachefile)
+ {
+ @unlink($cachefile);
+ }
+ }
+ else
+ {
+ $cachefile = "../cache/".$this->page.".cache";
+ if(file_exists($cachefile)) @unlink($cachefile);
+ unset($cachefile);
+ foreach(glob("../cache/".$this->page.",*.cache") as $cachefile)
+ {
+ @unlink($cachefile);
+ }
+ }
+ }
+ }
+ */
+
+ private function format_comment($string)
+ {
+ $string = htmlspecialchars($string);
+ if($this->remove_blank_lines==1)
+ {
+ $string = preg_replace("/\015\012|\015|\012/", "\n", $string);
+ $string_array = explode("\n", $string);
+ $string = '';
+ foreach($string_array as $string_line)
+ {
+ $string_line = trim($string_line);
+ if($string_line!='')
+ {
+ $string .= $string_line."\n";
+ }
+ }
+ }
+ $string = nl2br($string);
+ if($this->auto_link==1)
+ {
+ $string = make_link($string);
+ }
+ if($this->smilies==1)
+ {
+ $string = smilies($string);
+ }
+ return $string;
+ }
+
+ /*
+ function make_link($string)
+ {
+ $string = ' ' . $string;
+ $string = preg_replace("#(^|[\n ])([\w]+?://.*?[^ \"\n\r\t<]*)#is", "\\1\\2", $string);
+ $string = preg_replace("#(^|[\n ])((www|ftp)\.[\w\-]+\.[\w\-.\~]+(?:/[^ \"\t\n\r<]*)?)#is", "\\1\\2", $string);
+ $string = preg_replace("#(^|[\n ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1\\2@\\3", $string);
+ $string = substr($string, 1);
+ return $string;
+ }
+
+ function smilies($string)
+ {
+ global $this->settings;
+ require 'config/smilies.conf.php';
+ foreach($smilies as $smiley)
+ {
+ $string = str_replace($smiley[0], "Database type not supported.
diff --git a/cms/includes/classes/FileUpload.class.php b/cms/includes/classes/FileUpload.class.php new file mode 100644 index 0000000..6589547 --- /dev/null +++ b/cms/includes/classes/FileUpload.class.php @@ -0,0 +1,176 @@ +upload = $upload; + $this->uploadDir = $uploadDir; + + if($upload['error']) + { + $this->error = true; + } + elseif($upload['size']==0) + { + $this->error = true; + #$this->fileError = true; + $this->fileEmpty = true; + } + elseif($upload['size']>$this->maxAcceptedFilesize*1000) + { + $this->error = true; + #$this->fileError = true; + $this->fileTooLarge = true; + } + + if($image=getimagesize($upload['tmp_name'])) + { + $this->isImage = true; + $this->imageWidth = $image[0]; + $this->imageHeight = $image[1]; + if($image[2]==1) $this->imageType = 'gif'; + if($image[2]==2) $this->imageType = 'jpeg'; + if($image[2]==3) $this->imageType = 'png'; + } + + if(!preg_match('/^[a-zA-Z0-9._\-]+$/', $this->uploadFileName) || mb_substr($this->uploadFileName, 0, 1)=='_') + { + #$this->error = true; + #$this->fileError = true; + $this->fileNameInvalid = true; + } + if(file_exists($this->uploadDir.$this->uploadFileName)) + { + #$this->fileError = true; + $this->fileExists = true; + } + + if(!$this->fileError) + { + $tempFileName = uniqid(rand()).'.tmp'; + if(move_uploaded_file($this->upload['tmp_name'],$this->uploadDir.$tempFileName)) + { + $this->tempFile = $tempFileName; + } + else + { + $this->uploadError = true; + } + } + } + + /** + * saves the uploaded file + * + * @param ... + */ + public function saveFile($filename='') + { + if(empty($filename)) + { + if($this->fileNameInvalid) return false; + $filename = $this->uploadFileName; + } + if(copy($this->uploadDir.$this->tempFile, $this->uploadDir.$filename)) return true; + else return false; + } + + /** + * modifies and saves the uploaded image + * + * @param ... + */ + public function saveModifiedImage($width, $height, $compression, $filename='') + { + if(empty($filename)) + { + if($this->fileNameInvalid) return false; + $filename = $this->uploadFileName; + } + if($this->_resize_image($this->uploadDir.$this->tempFile, $this->uploadDir.$filename, $width, $height, $compression)) return true; + else return false; + } + +/** + * resizes uploaded images + * + * @param string $uploaded_file : uploaded file + * @param string $file : destination file + * @param int $new_width : new width + * @param int $new_height : new height + * @param int $compression : compression rate + * @return bool + */ +private function _resize_image($uploaded_file, $file, $new_width, $new_height, $compression=80) + { + if(file_exists($file)) + { + #@chmod($file, 0777); + @unlink($file); + } + #$image_info = getimagesize($uploaded_file); + if(!$this->isImage || empty($this->imageType)) $error = true; + if(empty($error)) + { + if($this->imageType=='gif') + { + $current_image = @imagecreatefromgif($uploaded_file) or $error = true; + if(empty($error)) $new_image = @imagecreate($new_width,$new_height) or $error = true; + if(empty($error)) @imagecopyresampled($new_image,$current_image,0,0,0,0,$new_width,$new_height,$this->imageWidth,$this->imageWidth) or $error=true; + if(empty($error)) @imagegif($new_image, $file) or $error = true; + } + elseif($this->imageType=='jpeg') + { + $current_image = @imagecreatefromjpeg($uploaded_file) or $error = true; + if(empty($error)) $new_image=@imagecreatetruecolor($new_width,$new_height) or $error = true; + if(empty($error)) @imagecopyresampled($new_image,$current_image,0,0,0,0,$new_width,$new_height,$this->imageWidth,$this->imageHeight) or $error = true; + if(empty($error)) @imagejpeg($new_image, $file, $compression) or $error = true; + } + elseif($this->imageType=='png') + { + $current_image = @imagecreatefrompng($uploaded_file) or $error = true; + if(empty($error)) $new_image=@imagecreatetruecolor($new_width,$new_height) or $error = true; + if(empty($error)) @imagecopyresampled($new_image,$current_image,0,0,0,0,$new_width,$new_height,$this->imageWidth,$this->imageHeight) or $error = true; + if(empty($error)) @imagepng($new_image, $file) or $error = $true; + } + } + if(empty($error)) return true; + else return false; + } + + function __destruct() + { + if($this->tempFile) + { + unlink($this->uploadDir.$this->tempFile); + } + } + } +?> diff --git a/cms/includes/classes/Gallery.class.php b/cms/includes/classes/Gallery.class.php new file mode 100644 index 0000000..41811da --- /dev/null +++ b/cms/includes/classes/Gallery.class.php @@ -0,0 +1,56 @@ +_localization = Localization::getInstance(); + + $dbr = Database::$content->prepare('SELECT id, photo_thumbnail, photo_normal, title, subtitle, description, photos_per_row FROM '.Database::$db_settings['photo_table'].' WHERE gallery=:gallery ORDER BY sequence ASC'); + $dbr->bindParam(':gallery', $gallery, PDO::PARAM_STR); + $dbr->execute(); + + $i=0; + while($photo_data = $dbr->fetch()) + { + if($commentable==1) + { + $count_result = Database::$entries->prepare('SELECT COUNT(*) AS comments FROM '.Database::$db_settings['comment_table'].' WHERE comment_id=:id AND type=1'); + $count_result->bindValue(':id', $photo_data['id'], PDO::PARAM_INT); + $count_result->execute(); + $count_data = $count_result->fetch(); + $this->photos[$i]['comments'] = $count_data['comments']; + $this->_localization->bindId('number_of_comments', $photo_data['id']); + switch($count_data['comments']) + { + case 0: + $this->_localization->selectBoundVariant('number_of_comments', $photo_data['id'], 0); + break; + case 1: + $this->_localization->selectBoundVariant('number_of_comments', $photo_data['id'], 1); + break; + default: + $this->_localization->selectBoundVariant('number_of_comments', $photo_data['id'], 2); + $this->_localization->replacePlaceholderBound('comments', $count_data['comments'], 'number_of_comments', $photo_data['id']); + } + } + $this->photos[$i]['id'] = $photo_data['id']; + $this->photos[$i]['photo_thumbnail'] = $photo_data['photo_thumbnail']; + $this->photos[$i]['photo_normal'] = $photo_data['photo_normal']; + $this->photos[$i]['title'] = htmlspecialchars($photo_data['title']); + $this->photos[$i]['subtitle'] = htmlspecialchars($photo_data['subtitle']); + $this->photos[$i]['description'] = htmlspecialchars($photo_data['description']); + $thumbnail_info = getimagesize(MEDIA_DIR.$photo_data['photo_thumbnail']); + $this->photos[$i]['width'] = $thumbnail_info[0]; + $this->photos[$i]['height'] = $thumbnail_info[1]; + $this->photos_per_row = $photo_data['photos_per_row']; + $i++; + } + $this->number_of_photos = $i; + } + } +?> diff --git a/cms/includes/classes/Localization.class.php b/cms/includes/classes/Localization.class.php new file mode 100644 index 0000000..49499bf --- /dev/null +++ b/cms/includes/classes/Localization.class.php @@ -0,0 +1,126 @@ +replacement = $replacement; + self::$lang[$index] = preg_replace_callback('/\['.$placeholder.'\|(.*?)\]/', array(&$this, '_callbackFormatTimeWrapper'), self::$lang[$index]); + } + else + { + self::$lang[$index] = str_replace('['.$placeholder.']', $replacement, self::$lang[$index]); + } + } + + public function replacePlaceholderBound($placeholder, $replacement, $index, $id, $format_time=false) + { + if($format_time) + { + $this->replacement = $replacement; + self::$lang[$index][$id] = preg_replace_callback('/\['.$placeholder.'\|(.*?)\]/', array(&$this, '_callbackFormatTimeWrapper'), self::$lang[$index][$id]); + } + else + { + self::$lang[$index][$id] = str_replace('['.$placeholder.']', $replacement, self::$lang[$index][$id]); + } + } + + public function bindId($index, $id) + { + if(empty(self::$_lang[$index])) + { + self::$_lang[$index] = self::$lang[$index]; + unset(self::$lang[$index]); + } + self::$lang[$index][$id] = self::$_lang[$index]; + } + + public function bindReplacePlaceholder($id, $placeholder, $replacement, $index, $format_time=false) + { + $this->bindId($index, $id); + $this->replacePlaceholderBound($placeholder, $replacement, $index, $id, $format_time); + } + + public function selectVariant($index, $i) + { + self::$lang[$index] = self::$lang[$index][$i]; + } + + public function selectBoundVariant($index, $id, $i) + { + self::$lang[$index][$id] = self::$lang[$index][$id][$i]; + } + + public function replaceLink($link, $index) + { + self::$lang[$index] = str_replace('[[', '', self::$lang[$index]); + self::$lang[$index] = str_replace(']]', '', self::$lang[$index]); + } + + private function _callbackFormatTimeWrapper($matches) + { + return $this->_callbackFormatTime($matches[1], $this->replacement); + } + + private function _callbackFormatTime($format, $timestamp) + { + return strftime($format, $timestamp); + } + } +?> diff --git a/cms/includes/classes/Mail.class.php b/cms/includes/classes/Mail.class.php new file mode 100644 index 0000000..0a0c11b --- /dev/null +++ b/cms/includes/classes/Mail.class.php @@ -0,0 +1,195 @@ + + * @copyright 2010 Mark Alexander Hoschek + */ + +class Mail + { + const MAIL_HEADER_SEPARATOR = "\n"; // "\r\n" complies with RFC 2822 but might cause problems in some cases (see http://php.net/manual/en/function.mail.php) + const MAIL_HEADER_TRANSFER_ENCODING = 'Q'; // 'B' for Base64 or 'Q' for Quoted-Printable + private $charset = 'utf-8'; + + public function __construct() + { + mb_internal_encoding($this->charset); + } + + /** + * Sets charset of the e-mail. + * + * @param string $charset + */ + public function set_charset($charset) + { + $this->charset = $charset; + mb_internal_encoding($this->charset); + } + + /** + * Checks whether an e-mail address is (syntactically) valid or not. + * + * @param string $email + * @return bool + */ + public function is_valid_email($email) + { + if(preg_match("/^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/", $email)) + { + return true; + } + return false; + } + + /** + * escapes double-quotes and encloses display names in double-quotes if necessary + * + * @param string $display_name + * @return string + */ + public function escape_display_name($display_name) + { + $display_name = str_replace('"', '\\"', $display_name); + if(preg_match("/(\.|\;|\")/", $display_name)) + { + return '"'.mb_encode_mimeheader($display_name, $this->charset, self::MAIL_HEADER_TRANSFER_ENCODING, self::MAIL_HEADER_SEPARATOR).'"'; + } + else + { + return mb_encode_mimeheader($display_name, $this->charset, self::MAIL_HEADER_TRANSFER_ENCODING, self::MAIL_HEADER_SEPARATOR); + } + } + + /** + * puts together e-mail display and address (e.g. "Joe Q. Public"'.$response;
+ #exit;
+ }
+ }
+
+ private function _get_url_content($url)
+ {
+ $url_parts = parse_url($url);
+ if(empty($url_parts['path'])) $url_parts['path'] = '/';
+ if(isset($url_parts['query'])) $url_parts['path'] .= '?'.$url_parts['query'];
+ if(isset($url_parts['fragment'])) $url_parts['path'] .= '#'.$url_parts['fragment'];
+
+ if($fp = @fsockopen($url_parts['host'], 80, $error_nr, $error, 3))
+ {
+ $http_request = "GET " . $url_parts['path'] . " HTTP/1.0\r\n";
+ $http_request .= "Host: " . $url_parts['host'] . "\r\n";
+ $http_request .= "User-Agent: phpSQLiteCMS\r\n";
+ #$http_request .= "Content-Type: text/plain; charset=utf-8\r\n";
+ #$http_request .= "Content-Length: " . strlen($request) . "\r\n";
+ $http_request .= "\r\n";
+ #$http_request .= $request;
+ $response = '';
+ fwrite($fp, $http_request);
+ while(!feof($fp))
+ {
+ $response .= fgets($fp, 4096);
+ }
+ fclose($fp);
+ }
+
+ if($response)
+ {
+ // divide header/body:
+ $response = $response;
+ $response_parts = explode("\r\n\r\n", $response, 2);
+ if(isset($response_parts[0]) && isset($response_parts[1]))
+ {
+ return $response_parts;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ return false;
+ }
+
+ private function _import_header($header)
+ {
+ $header = preg_replace("/\015\012|\015|\012/", "\n", $header);
+ $lines = explode("\n", $header);
+ foreach($lines as $line)
+ {
+ if(trim($line)!='')
+ {
+ unset($separator_pos);
+ #$parts = explode(': ', $line);
+ $separator_pos = strpos($line, ':');
+ if($separator_pos!==false)
+ {
+ $key = strtolower(trim(substr($line, 0,$separator_pos)));
+ $val = trim(substr($line, $separator_pos+1));
+ if($key && $val) $header_parts[$key] = $val;
+ }
+ }
+ }
+ if(isset($header_parts)) return $header_parts;
+ else return false;
+ }
+
+ }
+?>
diff --git a/cms/includes/classes/ShowPhoto.class.php b/cms/includes/classes/ShowPhoto.class.php
new file mode 100644
index 0000000..ed56ba7
--- /dev/null
+++ b/cms/includes/classes/ShowPhoto.class.php
@@ -0,0 +1,143 @@
+show_comments = 1;
+ else $this->show_comments = 0;
+
+ $photo_id = intval($photo_id);
+
+ $photo_result = Database::$content->prepare('SELECT id, gallery, sequence, photo_thumbnail, photo_normal, photo_large, width, height, large_height, large_width, title, subtitle, description, description_formatting, template FROM '.Database::$db_settings['photo_table'].' WHERE id=:id LIMIT 1');
+ $photo_result->bindValue(':id', $photo_id, PDO::PARAM_INT);
+ $photo_result->execute();
+ $photo_data = $photo_result->fetch();
+
+ if(isset($photo_data['id']))
+ {
+ // get ids of photos of current gallery:
+ $gallery_result = Database::$content->prepare('SELECT id FROM '.Database::$db_settings['photo_table'].' WHERE gallery=:gallery ORDER BY sequence ASC');
+ $gallery_result->bindValue(':gallery', $photo_data['gallery'], PDO::PARAM_STR);
+ $gallery_result->execute();
+ while($gallery_data = $gallery_result->fetch())
+ {
+ $gallery_items[] = $gallery_data['id'];
+ }
+ $total_photos = count($gallery_items);
+ $current_photo_key = array_search($photo_data['id'], $gallery_items);
+ // get id of first, last, next and previous photo:
+ $first_photo = $gallery_items[0];
+ $last_photo = $gallery_items[$total_photos-1];
+ if(isset($gallery_items[$current_photo_key+1]))
+ {
+ $next_photo = $gallery_items[$current_photo_key+1];
+ }
+ else
+ {
+ $next_photo = $first_photo;
+ }
+ if(isset($gallery_items[$current_photo_key-1]))
+ {
+ $previous_photo = $gallery_items[$current_photo_key-1];
+ }
+ else
+ {
+ $previous_photo = $last_photo;
+ }
+ if($previous_photo==$photo_id)
+ {
+ $previous_photo = 0;
+ $next_photo = 0;
+ }
+
+ $this->photo_data['id'] = $photo_id;
+ $this->photo_data['gallery'] = $photo_data['gallery'];
+ $this->photo_data['gallery_items'] = $gallery_items;
+ $this->photo_data['previous_photo'] = $previous_photo;
+ $this->photo_data['next_photo'] = $next_photo;
+ $this->photo_data['total_photos'] = $total_photos;
+ $this->photo_data['photo_number'] = $current_photo_key+1;
+
+ $this->photo_data['photo_size'] = $photo_size;
+ if($photo_data['photo_large']!='') $this->photo_data['photo_large_available'] = 1;
+
+ if($photo_size==1 && $photo_data['photo_large']!='') $this->photo_data['photo'] = $photo_data['photo_large'];
+ else $this->photo_data['photo'] = $photo_data['photo_normal'];
+ $this->photo_data['photo_large'] = $photo_data['photo_large'];
+ $this->photo_data['thumbnail'] = $photo_data['photo_thumbnail'];
+
+ $this->photo_data['title'] = $photo_data['title'];
+ $this->photo_data['subtitle'] = $photo_data['subtitle'];
+ if($photo_data['description_formatting']==1)
+ {
+ $this->photo_data['description'] = auto_html($photo_data['description']);
+ }
+ else
+ {
+ $this->photo_data['description'] = $photo_data['description'];
+ }
+
+
+ if(substr(strtolower($this->photo_data['photo']), -4) == '.swf')
+ {
+ $this->photo_data['type'] = 'flash';
+ if($this->photo_data['photo_size']==1)
+ {
+ $this->photo_data['width'] = intval($photo_data['large_width']);
+ $this->photo_data['height'] = intval($photo_data['large_height']);
+ }
+ else
+ {
+ $this->photo_data['width'] = intval($photo_data['width']);
+ $this->photo_data['height'] = intval($photo_data['height']);
+ }
+ }
+ elseif(substr(strtolower($this->photo_data['photo']), -4) == '.flv')
+ {
+ $this->photo_data['type'] = 'flv';
+ if($this->photo_data['photo_size']==1)
+ {
+ $this->photo_data['width'] = intval($photo_data['large_width']);
+ $this->photo_data['height'] = intval($photo_data['large_height']);
+ }
+ else
+ {
+ $this->photo_data['width'] = intval($photo_data['width']);
+ $this->photo_data['height'] = intval($photo_data['height']);
+ }
+ }
+ else
+ {
+ $this->photo_data['type'] = 'image';
+ $photo_info = getimagesize(BASE_PATH.MEDIA_DIR.$this -> photo_data['photo']);
+ $this->photo_data['width'] = $photo_info[0];
+ $this->photo_data['height'] = $photo_info[1];
+ }
+ $this->photo_data['template'] = $photo_data['template'];
+ #$this -> photo_data['language_file'] = $photo_data['language_file'];
+ #$this -> photo_data['language_file'] = $language_file;
+ }
+ #return $this->photo_data;
+ }
+
+ function get_photo_data()
+ {
+ return $this->photo_data;
+ }
+
+ function show_comments()
+ {
+ return $this->show_comments;
+ }
+ }
+?>
diff --git a/cms/includes/classes/Template.class.php b/cms/includes/classes/Template.class.php
new file mode 100644
index 0000000..1ae9eaa
--- /dev/null
+++ b/cms/includes/classes/Template.class.php
@@ -0,0 +1,63 @@
+
+ * @copyright 2009 Mark Alexander Hoschek
+ */
+
+class Template
+ {
+ private $_templateVars = false;
+
+ /**
+ * assigns template vars
+ *
+ * @param string $name
+ * @param string $value
+ */
+ public function assign($name,$value)
+ {
+ $this->_templateVars[$name] = $value;
+ }
+
+ /**
+ * displays the template
+ *
+ * @param string $template
+ */
+ public function display($template)
+ {
+ if($this->_templateVars)
+ {
+ foreach($this->_templateVars as $__key => $__val)
+ {
+ $$__key = $__val;
+ }
+ }
+ include($template);
+ }
+
+ /**
+ * returns template content
+ *
+ * @param string $template
+ * @return string
+ */
+ public function fetch($template)
+ {
+ if($this->_templateVars)
+ {
+ foreach($this->_templateVars as $__key => $__val)
+ {
+ $$__key = $__val;
+ }
+ }
+ ob_start();
+ include($template);
+ $data = ob_get_contents();
+ ob_end_clean();
+ return $data;
+ }
+ }
+?>
diff --git a/cms/includes/comments.inc.php b/cms/includes/comments.inc.php
new file mode 100644
index 0000000..4207760
--- /dev/null
+++ b/cms/includes/comments.inc.php
@@ -0,0 +1,402 @@
+assign('type', $type);
+
+ $page = isset($_REQUEST['page']) ? intval($_REQUEST['page']) : 1;
+ $template->assign('page', $page);
+
+ $comment_id = isset($_REQUEST['comment_id']) ? $_REQUEST['comment_id'] : 0;
+ $template->assign('comment_id', $comment_id);
+
+ if(isset($_GET['photos_commentable']))
+ {
+ $photos_commentable = $_GET['photos_commentable']==1 ? 1 : 0;
+ $dbr = Database::$content->prepare("UPDATE ".Database::$db_settings['settings_table']." SET value=:value WHERE name='photos_commentable'");
+ $dbr->bindParam(':value', $photos_commentable, PDO::PARAM_INT);
+ $dbr->execute();
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=comments&type=1');
+ exit;
+ }
+
+ if(isset($_GET['edit']))
+ {
+ $dbr = Database::$entries->prepare("SELECT id, name, email_hp, comment FROM ".Database::$db_settings['comment_table']." WHERE id=:id LIMIT 1");
+ $dbr->bindParam(':id', $_GET['edit'], PDO::PARAM_INT);
+ $dbr->execute();
+ $data = $dbr->fetch();
+ if(isset($data['id']))
+ {
+ $comment['id'] = $data['id'];
+ $comment['name'] = htmlspecialchars($data['name']);
+ $comment['email_hp'] = htmlspecialchars($data['email_hp']);
+ $comment['comment'] = htmlspecialchars($data['comment']);
+ $template->assign('comment', $comment);
+ $action = 'edit';
+ }
+ else
+ {
+ $action = 'invalid_request';
+ }
+ }
+
+ if(isset($_POST['edit_submit']))
+ {
+ $name = isset($_POST['name']) ? trim($_POST['name']) : '';
+ $email_hp = isset($_POST['email_hp']) ? trim($_POST['email_hp']) : '';
+ $comment = isset($_POST['comment']) ? trim($_POST['comment']) : '';
+ $id = isset($_POST['id']) ? intval($_POST['id']) : 0;
+ $dbr = Database::$entries->prepare("UPDATE ".Database::$db_settings['comment_table']." SET name=:name, email_hp=:email_hp, comment=:comment WHERE id=:id");
+ $dbr->bindParam(':id', $id, PDO::PARAM_INT);
+ $dbr->bindParam(':name', $name, PDO::PARAM_STR);
+ $dbr->bindParam(':email_hp', $email_hp, PDO::PARAM_STR);
+ $dbr->bindParam(':comment', $comment, PDO::PARAM_STR);
+ $dbr->execute();
+ if(isset($cache) && $cache->autoClear) $cache->clear();
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=comments&type='.$type.'&comment_id='.$comment_id.'&page='.$page);
+ exit;
+ }
+
+ if(isset($_GET['delete']))
+ {
+ $dbr = Database::$entries->prepare("DELETE FROM ".Database::$db_settings['comment_table']." WHERE id=:id");
+ $dbr->bindParam(':id', $_GET['delete'], PDO::PARAM_INT);
+ $dbr->execute();
+ if(isset($cache) && $cache->autoClear) $cache->clear();
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=comments&type='.$type.'&comment_id='.$comment_id.'&page='.$page);
+ exit;
+ }
+
+ if(isset($_GET['report_spam']))
+ {
+ $dbr = Database::$entries->prepare("SELECT id, time, name, comment FROM ".Database::$db_settings['comment_table']." WHERE id=:id LIMIT 1");
+ $dbr->bindParam(':id', $_GET['report_spam'], PDO::PARAM_INT);
+ $dbr->execute();
+ $data = $dbr->fetch();
+ if(isset($data['id']))
+ {
+ $comment['id'] = $data['id'];
+ $comment['name'] = htmlspecialchars($data['name']);
+ $comment['time'] = $data['time'];
+ $comment['comment'] = htmlspecialchars($data['comment']);
+ $template->assign('comment', $comment);
+ }
+ $action = 'report_spam';
+ }
+
+ if(isset($_POST['report_as_spam']) || isset($_POST['report_as_spam_and_delete']))
+ {
+ if($settings['akismet_key']!='' && $settings['akismet_entry_check']==1)
+ {
+ $dbr = Database::$entries->prepare("SELECT id, name, email_hp, comment FROM ".Database::$db_settings['comment_table']." WHERE id=:id LIMIT 1");
+ $dbr->bindParam(':id', $_POST['id'], PDO::PARAM_INT);
+ $dbr->execute();
+ $data = $dbr->fetch();
+ if(isset($data['id']))
+ {
+ #$comment['id'] = $data['id'];
+ $comment['author'] = $data['name'];
+ if($data['email_hp'] != '')
+ {
+ if(preg_match("/^[^@]+@.+\.\D{2,5}$/", $data['email_hp']))
+ {
+ $comment['email'] = $data['email_hp'];
+ }
+ else
+ {
+ $comment['website'] = $data['email_hp'];
+ }
+ }
+ $comment['body'] = $data['comment'];
+ $akismet = new Akismet(BASE_URL, $settings['akismet_key'], $comment);
+ if(!$akismet->errorsExist())
+ {
+ $akismet->submitSpam();
+ }
+ if(isset($_POST['report_as_spam_and_delete']))
+ {
+ $dbr = Database::$entries->prepare("DELETE FROM ".Database::$db_settings['comment_table']." WHERE id=:id");
+ $dbr->bindParam(':id', $_POST['id'], PDO::PARAM_INT);
+ $dbr->execute();
+ if(isset($cache) && $cache->autoClear) $cache->clear();
+ }
+ }
+ }
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=comments&type='.$type.'&comment_id='.$comment_id.'&page='.$page);
+ exit;
+ }
+
+ if(isset($_POST['delete_checked']))
+ {
+ if(isset($_POST['checked']) && is_array($_POST['checked']))
+ {
+ $dbr = Database::$entries->prepare("SELECT id, name, comment FROM ".Database::$db_settings['comment_table']." WHERE id=:id ORDER BY comment_id ASC");
+ $dbr->bindParam(':id', $checked_id, PDO::PARAM_INT);
+ $i=0;
+ #Database::$entries->beginTransaction();
+ foreach($_POST['checked'] as $checked_id)
+ {
+ $dbr->execute();
+ $data = $dbr->fetch();
+ $comments[$i]['id'] = $data['id'];
+ $comments[$i]['name'] = htmlspecialchars($data['name']);
+ $comments[$i]['comment'] = htmlspecialchars($data['comment']);
+ if(mb_strlen($comments[$i]['comment'],CHARSET) > 50) $comments[$i]['comment'] = mb_substr($comments[$i]['comment'],0,47,CHARSET).'...';
+ ++$i;
+ }
+ #Database::$entries->commit();
+
+ if(isset($comments))
+ {
+ $template->assign('comments',$comments);
+ $action = 'delete_checked';
+ }
+ }
+ }
+
+ if(isset($_POST['delete_all_comments']))
+ {
+ $action = 'delete_all_comments';
+ }
+
+ if(isset($_POST['delete_all_comments_page']))
+ {
+ if($comment_id>0)
+ {
+ $dbr = Database::$content->query("SELECT title FROM ".Database::$db_settings['pages_table']." WHERE id=:id");
+ $dbr->bindParam(':id', $comment_id, PDO::PARAM_INT);
+ $dbr->execute();
+ $data = $dbr->fetch();
+ if(isset($data['title']))
+ {
+ $template->assign('page', htmlspecialchars($data['title']));
+ $action = 'delete_all_comments_page';
+ }
+ }
+ }
+
+ if(isset($_POST['delete_checked_confirmed']))
+ {
+ if(isset($_POST['checked_ids_confirmed']) && is_array($_POST['checked_ids_confirmed']))
+ {
+ $dbr = Database::$entries->prepare("DELETE FROM ".Database::$db_settings['comment_table']." WHERE id=:id");
+ $dbr->bindParam(':id', $delete_id, PDO::PARAM_INT);
+ Database::$entries->beginTransaction();
+ foreach($_POST['checked_ids_confirmed'] as $delete_id)
+ {
+ $dbr->execute();
+ }
+ Database::$entries->commit();
+ if(isset($cache) && $cache->autoClear) $cache->clear();
+ }
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=comments&type='.$type.'&page='.$page);
+ exit;
+ }
+
+ if(isset($_POST['delete_all_comments_confirmed']))
+ {
+ $dbr = Database::$entries->prepare("DELETE FROM ".Database::$db_settings['comment_table']." WHERE type=:type");
+ $dbr->bindParam(':type', $type, PDO::PARAM_INT);
+ $dbr->execute();
+ if(isset($cache) && $cache->autoClear) $cache->clear();
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=comments&type='.$type);
+ exit;
+ }
+
+ if(isset($_POST['delete_all_comments_page_confirmed']))
+ {
+ $dbr = Database::$entries->prepare("DELETE FROM ".Database::$db_settings['comment_table']." WHERE type=:type AND comment_id=:comment_id");
+ $dbr->bindParam(':type', $type, PDO::PARAM_INT);
+ $dbr->bindParam(':comment_id', $_POST['comment_id'], PDO::PARAM_INT);
+ Database::$entries->beginTransaction();
+ $dbr->execute();
+ if(isset($cache) && $cache->autoClear) $cache->clear();
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=comments&type='.$type);
+ exit;
+ }
+
+
+ switch($action)
+ {
+ case 'main':
+ // count comments:
+ if($comment_id==0)
+ {
+ $dbr = Database::$entries->prepare("SELECT COUNT(*) FROM ".Database::$db_settings['comment_table']." WHERE type=:type");
+ $dbr->bindParam(':type', $type, PDO::PARAM_INT);
+ $dbr->execute();
+ $comment_count = $dbr->fetchColumn();
+ }
+ else
+ {
+ $dbr = Database::$entries->prepare("SELECT COUNT(*) FROM ".Database::$db_settings['comment_table']." WHERE type=:type AND comment_id=:comment_id");
+ $dbr->bindParam(':type', $type, PDO::PARAM_INT);
+ $dbr->bindParam(':comment_id', $comment_id, PDO::PARAM_INT);
+ $dbr->execute();
+ $comment_count = $dbr->fetchColumn();
+ // no comments to item, switch to all items:
+ if($comment_count==0)
+ {
+ $comment_id=0;
+ $dbr = Database::$entries->prepare("SELECT COUNT(*) FROM ".Database::$db_settings['comment_table']." WHERE type=:type");
+ $dbr->bindParam(':type', $type, PDO::PARAM_INT);
+ $dbr->execute();
+ $comment_count = $dbr->fetchColumn();
+ }
+ }
+
+ // pages:
+ $pages = ceil($comment_count / $settings['admin_entries_per_page']);
+ if($page < 1) $page=1;
+ if($page > $pages && $page != 1) $page = $pages;
+ $template->assign('page', $page);
+
+ #$pagination = pagination($pages,$page,3,true);
+ $template->assign('pagination',pagination($pages,$page,3,true));
+
+ // get $comment_ids of all comments:
+ $dbr = Database::$entries->prepare("SELECT DISTINCT comment_id FROM ".Database::$db_settings['comment_table']." WHERE type=:type ORDER BY comment_id ASC");
+ $dbr->bindParam(':type', $type, PDO::PARAM_INT);
+ $dbr->execute();
+ while($data = $dbr->fetch())
+ {
+ $comment_ids[] = $data['comment_id'];
+ }
+
+ // get ids, pages, titles etc. of commented items:
+ if(isset($comment_ids))
+ {
+ $comment_ids_list = implode(',',$comment_ids);
+ if($type==0)
+ {
+ $dbr = Database::$content->query("SELECT id, page, title FROM ".Database::$db_settings['pages_table']." WHERE id IN (".$comment_ids_list.")");
+ while($data = $dbr->fetch())
+ {
+ $items[$data['id']]['page'] = htmlspecialchars($data['page']);
+ $items[$data['id']]['title'] = htmlspecialchars($data['title']);
+ }
+ }
+ else
+ {
+ $dbr = Database::$content->query("SELECT id, photo_thumbnail, photo_normal, title FROM ".Database::$db_settings['photo_table']." WHERE id IN (".$comment_ids_list.")");
+ while($data = $dbr->fetch())
+ {
+ $items[$data['id']]['page'] = htmlspecialchars($data['title']);
+ $items[$data['id']]['title'] = htmlspecialchars($data['title']);
+ $items[$data['id']]['photo_thumbnail'] = htmlspecialchars($data['photo_thumbnail']);
+ $items[$data['id']]['photo_normal'] = htmlspecialchars($data['photo_normal']);
+ }
+ }
+ }
+
+ if(isset($items))
+ {
+ asort($items);
+ $template->assign('items', $items);
+ }
+
+ // get comments:
+ if($comment_id==0)
+ {
+ $dbr = Database::$entries->prepare("SELECT id, comment_id, time, name, email_hp, comment, ip FROM ".Database::$db_settings['comment_table']." WHERE type=:type ORDER BY id DESC LIMIT ".$settings['admin_entries_per_page']." OFFSET ".(($page-1)*$settings['admin_entries_per_page']));
+ $dbr->bindParam(':type', $type, PDO::PARAM_INT);
+ $dbr->execute();
+ }
+ else
+ {
+ $dbr = Database::$entries->prepare("SELECT id, comment_id, time, name, email_hp, comment, ip FROM ".Database::$db_settings['comment_table']." WHERE type=:type AND comment_id=:comment_id ORDER BY id DESC LIMIT ".$settings['admin_entries_per_page']." OFFSET ".(($page-1)*$settings['admin_entries_per_page']));
+ $dbr->bindParam(':type', $type, PDO::PARAM_INT);
+ $dbr->bindParam(':comment_id', $comment_id, PDO::PARAM_INT);
+ $dbr->execute();
+ }
+ $i=0;
+ while($data = $dbr->fetch())
+ {
+ #$item_ids[] = $data['comment_id'];
+ $comments[$i]['id'] = $data['id'];
+ $comments[$i]['comment_id'] = $data['comment_id'];
+ $comments[$i]['time'] = $data['time'];
+ $comments[$i]['name'] = htmlspecialchars($data['name']);
+
+ if($data['email_hp'])
+ {
+ if(preg_match("/^[^@]+@.+\.\D{2,5}$/", $data['email_hp']))
+ {
+ $comments[$i]['email_hp'] = 'mailto:'.htmlspecialchars($data['email_hp']);
+ }
+ else
+ {
+ $comments[$i]['email_hp'] = add_http_if_no_protocol(htmlspecialchars($data['email_hp']));
+ }
+ }
+
+ $comments[$i]['comment'] = htmlspecialchars($data['comment']);
+ if($settings['comment_remove_blank_lines']==1)
+ {
+ $entry_array = explode("\n", $comments[$i]['comment']);
+ $comment = '';
+ foreach($entry_array as $entry_line)
+ {
+ $entry_line = trim($entry_line);
+ if($entry_line!='') $comment .= $entry_line."\n";
+ }
+ $comments[$i]['comment'] = $comment;
+ }
+ $comments[$i]['comment'] = nl2br($comments[$i]['comment']);
+ $comments[$i]['ip'] = htmlspecialchars($data['ip']);
+ ++$i;
+ }
+
+ if(isset($comments))
+ {
+ $template->assign('comments', $comments);
+ }
+
+ if(isset($item_titles))
+ {
+ asort($item_titles);
+ $template->assign('item_titles', $item_titles);
+ }
+
+ if($comment_id!=0)
+ {
+ if($type==0) $localization->replacePlaceholder('page', $items[$comment_id]['title'], 'delete_all_comments_page');
+ else $localization->replacePlaceholder('photo', $items[$comment_id]['title'], 'delete_all_comments_photo');
+ }
+ if($type==1)
+ {
+ if($settings['photos_commentable']==1) $localization->replaceLink('index.php?mode=comments&type=1&photos_commentable=0', 'photo_comments_enabled');
+ if($settings['photos_commentable']==0) $localization->replaceLink('index.php?mode=comments&type=1&photos_commentable=1', 'photo_comments_disabled');
+ }
+
+ $template->assign('subtitle', Localization::$lang['comments']);
+ $template->assign('subtemplate', 'comments.inc.tpl');
+ break;
+ case 'edit':
+ $template->assign('subtitle', Localization::$lang['edit_comment']);
+ $template->assign('subtemplate', 'comments_edit.inc.tpl');
+ break;
+ case 'delete_checked':
+ $template->assign('subtitle', Localization::$lang['delete_comments']);
+ $template->assign('subtemplate', 'comments_delete.inc.tpl');
+ break;
+ case 'delete_all_comments':
+ $template->assign('subtitle', Localization::$lang['delete_comments']);
+ $template->assign('subtemplate', 'comments_delete_all.inc.tpl');
+ break;
+ case 'delete_all_comments_page':
+ $template->assign('subtitle', Localization::$lang['delete_comments']);
+ $template->assign('subtemplate', 'comments_delete_all_page.inc.tpl');
+ break;
+ case 'report_spam':
+ $template->assign('subtitle', Localization::$lang['report_spam']);
+ $template->assign('subtemplate', 'comments_report_spam.inc.tpl');
+ break;
+ }
+ }
+?>
diff --git a/cms/includes/content.inc.php b/cms/includes/content.inc.php
new file mode 100644
index 0000000..7cf89f7
--- /dev/null
+++ b/cms/includes/content.inc.php
@@ -0,0 +1,281 @@
+assign('menus', get_menus());
+
+// global content blocks:
+if($settings['global_content_blocks']) $template->assign('gcb', get_global_content_blocks());
+
+// content:
+if(empty($data)) // might already be set if error page was loaded
+ {
+ if($data=get_content(PAGE))
+ {
+ // count views:
+ if($settings['count_views']==1)
+ {
+ $dbr = Database::$content->prepare("UPDATE ".Database::$db_settings['pages_table']." SET views=views+1 WHERE id=:id");
+ $dbr->bindParam(':id', $data['id'], PDO::PARAM_INT);
+ $dbr->execute();
+ }
+ }
+ else
+ {
+ $no_cache = true;
+ if($data=get_content($settings['error_page']))
+ {
+ header($_SERVER['SERVER_PROTOCOL'] . " 404 Not Found");
+ header("Status: 404 Not Found");
+ }
+ else
+ {
+ raise_error('404');
+ }
+ }
+ }
+
+if($data['language']=='') $language_file = $settings['default_page_language'] . '.page.lang.php';
+else $language_file = $data['language'] . '.page.lang.php';
+
+#require('./cms/includes/classes/Localization.class.php');
+#$loc = new Localization('./cms/lang/'.$language_file);
+#$localization = Localization::getInstance(BASE_PATH.'cms/lang/'.$language_file);
+$localization = new Localization(BASE_PATH.'cms/lang/'.$language_file);
+
+mb_internal_encoding(Localization::$lang['charset']);
+
+#require('./cms/lang/'.$language_file);
+#$template->set_lang($lang);
+
+#$template->config_load($language_file);
+#$lang = $template->get_config_vars();
+setlocale(LC_ALL, Localization::$lang['locale']);
+#$template->assign('config_file', $language_file);
+define('CHARSET', Localization::$lang['charset']);
+#define('TIME_FORMAT', Localization::$lang['time_format']);
+#define('TIME_FORMAT_FULL', Localization::$lang['time_format_full']);
+
+// breadcrumbs:
+$template->assign('breadcrumbs', get_breadcrumbs($data['breadcrumbs']));
+
+$page = $data['page'];
+
+$content = $data['content'];
+if($settings['content_auto_link']==1) $content = make_link($content);
+#if($settings['content_smilies']==1) $content = smilies($content);
+if($data['content_formatting']==1) $content = auto_html($content);
+
+$content = parse_special_tags($content);
+
+$sidebar_1 = $data['sidebar_1'];
+if($settings['content_auto_link']==1) $sidebar_1 = make_link($sidebar_1);
+#if($settings['content_smilies']==1) $sidebar_1 = smilies($sidebar_1);
+if($data['sidebar_1_formatting']==1) $sidebar_1 = auto_html($sidebar_1);
+if($sidebar_1!='') $sidebar_1 = parse_special_tags($sidebar_1);
+
+$sidebar_2 = $data['sidebar_2'];
+if($settings['content_auto_link']==1) $sidebar_2 = make_link($sidebar_2);
+#if($settings['content_smilies']==1) $sidebar_2 = smilies($sidebar_2);
+if($data['sidebar_2_formatting']==1) $sidebar_2 = auto_html($sidebar_2);
+if($sidebar_2!='') $sidebar_2 = parse_special_tags($sidebar_2);
+
+$sidebar_3 = $data['sidebar_3'];
+if($settings['content_auto_link']==1) $sidebar_3 = make_link($sidebar_3);
+#if($settings['content_smilies']==1) $sidebar_3 = smilies($sidebar_3);
+if($data['sidebar_3_formatting']==1) $sidebar_3 = auto_html($sidebar_3);
+if($sidebar_3!='') $sidebar_3 = parse_special_tags($sidebar_3);
+
+$sections_array = explode(',',$data['sections']);
+foreach($sections_array as $section)
+ {
+ $sections[] = $section;
+ }
+$template->assign('section', $sections);
+
+$tv_array = explode(',', $data['tv']);
+foreach($tv_array as $tv_item)
+ {
+ if($tv_item)
+ {
+ $tv_item_parts = explode('=', $tv_item);
+ $tv[trim($tv_item_parts[0])] = isset($tv_item_parts[1]) ? trim($tv_item_parts[1]) : true;
+ }
+ }
+if(isset($tv)) $template->assign('tv', $tv);
+
+$page_id = $data['id'];
+
+
+// include news (simple news):
+if($data['include_news'])
+ {
+ $dbr = Database::$content->prepare("SELECT page, type FROM ".Database::$db_settings['pages_table']." WHERE id=:id");
+ $dbr->bindParam(':id', $data['include_news'], PDO::PARAM_INT);
+ $dbr->execute();
+ $include_news_page_data = $dbr->fetch();
+ if(isset($include_news_page_data['page']))
+ {
+ if($include_news_page_data['type']=='simple_news')
+ {
+ $dbr = Database::$content->prepare("SELECT id, time, title, teaser, text, text_formatting, linkname FROM ".Database::$db_settings['news_table']." WHERE page_id=:page_id ORDER BY time DESC LIMIT ".$settings['include_news_items']);
+ }
+ else
+ {
+ $dbr = Database::$content->prepare("SELECT id, time, teaser_headline, headline, title, page_title, page, teaser, teaser_formatting, content, content_formatting, link_name AS linkname FROM ".Database::$db_settings['pages_table']." WHERE include_page=:page_id ORDER BY time DESC LIMIT ".$settings['include_news_items']);
+ }
+ $dbr->bindParam(':page_id', $data['include_news'], PDO::PARAM_INT);
+ $dbr->execute();
+ $i=0;
+ while($include_news_data = $dbr->fetch())
+ {
+ $include_news[$i]['id'] = $include_news_data['id'];
+ $include_news[$i]['time'] = $include_news_data['time'];
+ $include_news[$i]['linkname'] = $include_news_data['linkname'];
+ $localization->bindReplacePlaceholder($include_news_data['id'], 'time', $include_news_data['time'], 'include_news_time', Localization::FORMAT_TIME);
+
+ if($include_news_page_data['type']=='simple_news')
+ {
+ $include_news[$i]['title'] = $include_news_data['title'];
+ if($include_news_data['teaser'])
+ {
+ $include_news[$i]['teaser'] = $include_news_data['teaser'];
+ }
+ else
+ {
+ if($include_news_data['text_formatting']==1) $include_news[$i]['teaser'] = auto_html($include_news_data['text']);
+ else $include_news[$i]['teaser'] = $include_news_data['text'];
+ }
+ $include_news[$i]['link'] = BASE_URL.$include_news_page_data['page'].','.$include_news_data['id'];
+ }
+ else
+ {
+ if($include_news_data['teaser_headline']!='')
+ {
+ $include_news[$i]['title'] = $include_news_data['teaser_headline'];
+ }
+ elseif($include_news_data['headline']!='')
+ {
+ $include_news[$i]['title'] = $include_news_data['headline'];
+ }
+ else
+ {
+ $include_news[$i]['title'] = $include_news_data['title'];
+ }
+ if($include_news_data['teaser']!='')
+ {
+ if($include_news_data['teaser_formatting']==1)
+ {
+ $include_news[$i]['teaser'] = auto_html($include_news_data['teaser']);
+ }
+ else
+ {
+ $include_news[$i]['teaser'] = $include_news_data['teaser'];
+ }
+ }
+ else
+ {
+ if($include_news_data['content_formatting']==1)
+ {
+ $include_news[$i]['teaser'] = auto_html($include_news_data['content']);
+ }
+ else
+ {
+ $include_news[$i]['teaser'] = $include_news_data['content'];
+ }
+ }
+ $include_news[$i]['link'] = BASE_URL.$include_news_data['page'];
+ }
+
+ $i++;
+ }
+ if(isset($include_news))
+ {
+ $template->assign('include_news', $include_news);
+ }
+ }
+ }
+
+$template->assign('id', $data['id']);
+$template->assign('page', $page);
+$template->assign('settings', $settings);
+$template->assign('type', $data['type']);
+$template->assign('title', $data['title']);
+$template->assign('page_title', $data['page_title']);
+
+if($data['keywords']) $template->assign('keywords', $data['keywords']);
+elseif($settings['default_keywords']) $template->assign('keywords', $settings['default_keywords']);
+else $template->assign('keywords', '');
+
+if($data['description']) $template->assign('description', $data['description']);
+elseif($settings['default_description']) $template->assign('description', $settings['default_description']);
+else $template->assign('description', '');
+
+$template->assign('category', htmlspecialchars($data['category']));
+$template->assign('page_info', $data['page_info']);
+$template->assign('headline', $data['headline']);
+$template->assign('content', $content);
+$template->assign('sidebar_1', $sidebar_1);
+$template->assign('sidebar_2', $sidebar_2);
+$template->assign('sidebar_3', $sidebar_3);
+$template->assign('menu_1', $data['menu_1']);
+$template->assign('menu_2', $data['menu_2']);
+$template->assign('menu_3', $data['menu_3']);
+$template->assign('gcb_1', htmlspecialchars($data['gcb_1']));
+$template->assign('gcb_2', htmlspecialchars($data['gcb_2']));
+$template->assign('gcb_3', htmlspecialchars($data['gcb_3']));
+$template->assign('status', intval($data['status']));
+
+if($data['page']==$settings['index_page']) $template->assign('canonical', BASE_URL);
+
+if(isset($_SESSION[$settings['session_prefix'].'user_id']) && is_authorized_to_edit($_SESSION[$settings['session_prefix'].'user_id'],$_SESSION[$settings['session_prefix'].'user_type'],$data['author'],$data['edit_permission'],$data['edit_permission_general']))
+ {
+ $authorized_to_edit = true;
+ }
+else
+ {
+ $authorized_to_edit = false;
+ }
+$template->assign('authorized_to_edit', $authorized_to_edit);
+
+$template->assign('timestamp', $data['time']);
+
+#$template->assign('created', format_time($loc->lang['time_format'], $data['time']));
+#$template->assign('last_modified', format_time($loc->lang['time_format'], $data['last_modified']));
+
+if($data['display_time']==1)
+ {
+ $template->assign('display_time', true);
+ $localization->replacePlaceholder('time', $data['time'], 'page_time', Localization::FORMAT_TIME);
+ }
+else
+ {
+ $template->assign('display_time', false);
+ }
+
+$localization->replacePlaceholder('last_modified', $data['last_modified'], 'page_last_modified', Localization::FORMAT_TIME);
+$localization->replacePlaceholder('created', $data['time'], 'page_last_modified', Localization::FORMAT_TIME);
+
+
+#$template->assign('lang', $lang['lang']);
+
+$content_type = $data['content_type'] ? $data['content_type'] : 'text/html';
+#$charset = $data['charset'] ? $data['charset'] : $loc->lang['charset'];
+$template_file = $data['template'];
+
+if($data['type']!='default')
+ {
+ include(BASE_PATH.'cms/config/page_types.conf.php');
+ if(isset($page_types[$data['type']]['page_type']))
+ {
+ include(BASE_PATH.'cms/includes/page_types/'.$page_types[$data['type']]['page_type']);
+ }
+ }
+else
+ {
+ if(isset($cache) && empty($no_cache))
+ {
+ $cache->cacheId = PAGE;
+ }
+ }
+?>
diff --git a/cms/includes/edit.inc.php b/cms/includes/edit.inc.php
new file mode 100644
index 0000000..7246536
--- /dev/null
+++ b/cms/includes/edit.inc.php
@@ -0,0 +1,647 @@
+prepare("UPDATE ".Database::$db_settings['userdata_table']." SET wysiwyg=1 WHERE id=:id");
+ $dbr->bindParam(':id', $_SESSION[$settings['session_prefix'].'user_id'], PDO::PARAM_INT);
+ $dbr->execute();
+ $_SESSION[$settings['session_prefix'].'wysiwyg'] = 1;
+ }
+ if($wysiwyg_opt && isset($_REQUEST['disable_wysiwyg']))
+ {
+ $wysiwyg = false;
+ $dbr = Database::$userdata->prepare("UPDATE ".Database::$db_settings['userdata_table']." SET wysiwyg=0 WHERE id=:id");
+ $dbr->bindParam(':id', $_SESSION[$settings['session_prefix'].'user_id'], PDO::PARAM_INT);
+ $dbr->execute();
+ $_SESSION[$settings['session_prefix'].'wysiwyg'] = 0;
+ }
+
+ $template->assign('wysiwyg_opt',$wysiwyg_opt);
+ $template->assign('wysiwyg',$wysiwyg);
+
+ #if($wysiwyg) include('./modules/fckeditor/fckeditor.php');
+
+ include(BASE_PATH.'cms/config/page_types.conf.php');
+ $template->assign('page_types',$page_types);
+
+ // users:
+ $user_result = Database::$userdata->query("SELECT id, name FROM ".Database::$db_settings['userdata_table']." ORDER BY id ASC");
+ $i=0;
+ while($data = $user_result->fetch())
+ {
+ $users[$data['id']] = $data['name'];
+ }
+
+ // get data to edit and perform general checks:
+ if(isset($_GET['id']))
+ {
+ $dbr = Database::$content->prepare("SELECT id,page,author,type,type_addition,time,last_modified,display_time,title,page_title,description,keywords,category,page_info,breadcrumbs,sections,include_page,include_order,include_rss,include_sitemap,include_news,link_name,menu_1,menu_2,menu_3,gcb_1,gcb_2,gcb_3,template,language,content_type,charset,headline,teaser_headline,teaser,teaser_formatting,teaser_img,content,content_formatting,sidebar_1,sidebar_1_formatting,sidebar_2,sidebar_2_formatting,sidebar_3,sidebar_3_formatting, page_notes, edit_permission, edit_permission_general, tv, status FROM ".Database::$db_settings['pages_table']." WHERE id=:id LIMIT 1");
+ $dbr->bindParam(':id', $_REQUEST['id'], PDO::PARAM_INT);
+ $dbr->execute();
+ $data = $dbr->fetch();
+ if(!isset($data['id']))
+ {
+ $action='page_doesnt_exist';
+ }
+ elseif(!is_authorized_to_edit($_SESSION[$settings['session_prefix'].'user_id'],$_SESSION[$settings['session_prefix'].'user_type'],$data['author'],$data['edit_permission'],$data['edit_permission_general']))
+ {
+ $action='no_authorization';
+ }
+ else
+ {
+ $page_data['id'] = intval($data['id']);
+ $page_data['page'] = htmlspecialchars($data['page']);
+ $page_data['author'] = intval($data['author']);
+ $page_data['type'] = htmlspecialchars($data['type']);
+ $page_data['type_addition'] = htmlspecialchars($data['type_addition']);
+ $page_data['time'] = date("Y-m-d H:i:s", $data['time']);
+ $page_data['last_modified'] = date("Y-m-d H:i:s");
+ $page_data['display_time'] = intval($data['display_time']);
+ $page_data['title'] = htmlspecialchars($data['title']);
+ $page_data['page_title'] = htmlspecialchars($data['page_title']);
+ $page_data['description'] = htmlspecialchars($data['description']);
+ $page_data['keywords'] = htmlspecialchars($data['keywords']);
+ $page_data['category'] = htmlspecialchars($data['category']);
+ $page_data['page_info'] = htmlspecialchars($data['page_info']);
+ $page_data['breadcrumbs'] = explode(',',htmlspecialchars($data['breadcrumbs']));
+ $page_data['sections'] = str_replace(',',', ',htmlspecialchars($data['sections']));
+ $page_data['include_page'] = intval($data['include_page']);
+ $page_data['include_order'] = intval($data['include_order']);
+ $page_data['include_rss'] = intval($data['include_rss']);
+ $page_data['include_sitemap'] = intval($data['include_sitemap']);
+ $page_data['include_news'] = intval($data['include_news']);
+ $page_data['link_name'] = htmlspecialchars($data['link_name']);
+ $page_data['menu_1'] = htmlspecialchars($data['menu_1']);
+ $page_data['menu_2'] = htmlspecialchars($data['menu_2']);
+ $page_data['menu_3'] = htmlspecialchars($data['menu_3']);
+ $page_data['gcb_1'] = htmlspecialchars($data['gcb_1']);
+ $page_data['gcb_2'] = htmlspecialchars($data['gcb_2']);
+ $page_data['gcb_3'] = htmlspecialchars($data['gcb_3']);
+ $page_data['template'] = htmlspecialchars($data['template']);
+ $page_data['language'] = htmlspecialchars($data['language']);
+ $page_data['content_type'] = htmlspecialchars($data['content_type']);
+ $page_data['charset'] = htmlspecialchars($data['charset']);
+ $page_data['headline'] = htmlspecialchars($data['headline']);
+ $page_data['teaser_headline'] = htmlspecialchars($data['teaser_headline']);
+ $page_data['teaser'] = htmlspecialchars($data['teaser']);
+ $page_data['teaser_formatting'] = intval($data['teaser_formatting']);
+ $page_data['teaser_img'] = htmlspecialchars($data['teaser_img']);
+ $page_data['content_formatting'] = intval($data['content_formatting']);
+ $page_data['sidebar_1'] = htmlspecialchars($data['sidebar_1']);
+ $page_data['sidebar_1_formatting'] = intval($data['sidebar_1_formatting']);
+ $page_data['sidebar_2'] = htmlspecialchars($data['sidebar_2']);
+ $page_data['sidebar_2_formatting'] = intval($data['sidebar_2_formatting']);
+ $page_data['sidebar_3'] = htmlspecialchars($data['sidebar_3']);
+ $page_data['sidebar_3_formatting'] = intval($data['sidebar_3_formatting']);
+ $page_data['page_notes'] = htmlspecialchars($data['page_notes']);
+ $page_data['edit_permission_general'] = intval($data['edit_permission_general']);
+ $page_data['tv'] = str_replace(',',', ',htmlspecialchars($data['tv']));
+ $page_data['status'] = intval($data['status']);
+ $page_data['content'] = htmlspecialchars($data['content']);
+
+ $edit_permission_array = explode(',',$data['edit_permission']);
+ foreach($edit_permission_array as $edit_permission)
+ {
+ $edit_permission = intval(trim($edit_permission));
+ if(isset($users[$edit_permission]))
+ {
+ $permitted_users[] = htmlspecialchars($users[$edit_permission]);
+ }
+ }
+ if(isset($permitted_users))
+ {
+ $page_data['edit_permission'] = implode(', ',$permitted_users);
+ }
+ else
+ {
+ $page_data['edit_permission'] = '';
+ }
+
+ $send_pingbacks = 0;
+ $action='main';
+ }
+ }
+ else
+ {
+ // set default values for new pages:
+ $page_data['time'] = date("Y-m-d H:i:s");
+ $page_data['last_modified'] = date("Y-m-d H:i:s");
+ $page_data['display_time'] = 0;
+ $page_data['teaser_formatting'] = 1;
+ $page_data['content_formatting'] = $settings['default_formatting'];
+ $page_data['sidebar_1_formatting'] = $settings['default_formatting'];
+ $page_data['sidebar_2_formatting'] = $settings['default_formatting'];
+ $page_data['sidebar_3_formatting'] = $settings['default_formatting'];
+ $page_data['include_page'] = 0;
+ $page_data['include_order'] = 0;
+ $page_data['include_rss'] = 0;
+ $page_data['include_sitemap'] = 0;
+ $page_data['include_news'] = 0;
+ $page_data['link_name'] = Localization::$lang['teaser_default_linkname'];
+ $page_data['template'] = $settings['default_template'];
+ $page_data['menu_1'] = $settings['default_menu'];
+ $page_data['edit_permission_general'] = 0;
+ $page_data['status'] = 2;
+ $send_pingbacks = $settings['pingbacks_enabled'] ? 1 : 0;
+ }
+
+ // edit submitted:
+ if(isset($_POST['content']))
+ {
+ if(isset($_POST['id']))
+ {
+ $dbr = Database::$content->prepare("SELECT id,author,edit_permission,edit_permission_general FROM ".Database::$db_settings['pages_table']." WHERE id=:id LIMIT 1");
+ $dbr->bindParam(':id', $_POST['id'], PDO::PARAM_INT);
+ $dbr->execute();
+ $data = $dbr->fetch();
+ if(!isset($data['id']))
+ {
+ $errors[] = 'page_doesnt_exist';
+ }
+ elseif(!is_authorized_to_edit($_SESSION[$settings['session_prefix'].'user_id'],$_SESSION[$settings['session_prefix'].'user_type'],$data['author'],$data['edit_permission'],$data['edit_permission_general']))
+ {
+ $errors[] = 'no_authorization_edit';
+ }
+ }
+
+ if(empty($errors))
+ {
+ $_POST['page'] = isset($_POST['page']) ? trim($_POST['page']) : '';
+ $_POST['title'] = isset($_POST['title']) ? trim($_POST['title']) : '';
+
+ $_POST['gcb_1'] = isset($_POST['gcb_1']) ? trim($_POST['gcb_1']) : '';
+ $_POST['gcb_2'] = isset($_POST['gcb_2']) ? trim($_POST['gcb_2']) : '';
+ $_POST['gcb_3'] = isset($_POST['gcb_3']) ? trim($_POST['gcb_3']) : '';
+
+ $_POST['include_page'] = isset($_POST['include_page']) ? intval($_POST['include_page']) : 0;
+ $_POST['include_rss'] = isset($_POST['include_rss']) ? intval($_POST['include_rss']) : 0;
+ $_POST['include_sitemap'] = isset($_POST['include_sitemap']) ? intval($_POST['include_sitemap']) : 0;
+ $_POST['include_news'] = isset($_POST['include_news']) ? intval($_POST['include_news']) : 0;
+
+ if(empty($_POST['content_formatting'])) $_POST['content_formatting']= 0;
+ if(empty($_POST['teaser_formatting'])) $_POST['teaser_formatting']= 0;
+ if(empty($_POST['sidebar_1_formatting'])) $_POST['sidebar_1_formatting']= 0;
+ if(empty($_POST['sidebar_2_formatting'])) $_POST['sidebar_2_formatting']= 0;
+ if(empty($_POST['sidebar_3_formatting'])) $_POST['sidebar_3_formatting']= 0;
+ if(empty($_POST['rss'])) $_POST['rss'] = 0;
+ if(empty($_POST['sitemap'])) $_POST['sitemap'] = 0;
+ if(empty($_POST['content_type'])) $_POST['content_type'] = '';
+ if(empty($_POST['charset'])) $_POST['charset'] = '';
+ if(empty($_POST['edit_permission_general'])) $_POST['edit_permission_general'] = 0;
+ $_POST['status'] = isset($_POST['status']) ? intval($_POST['status']) : 0;
+ $_POST['display_time'] = isset($_POST['display_time']) && $_POST['display_time']==1 ? 1 : 0;
+ if($_POST['status']>2) $_POST['status'] = 2;
+ $send_pingbacks = isset($_POST['send_pingbacks']) && $_POST['send_pingbacks']==1 ? 1 : 0;
+
+ // trim sections:
+ $sections_array = explode(',',$_POST['sections']);
+ foreach($sections_array as $item)
+ {
+ if(trim($item)!='')
+ {
+ $cleared_sections_array[] = trim($item);
+ }
+ }
+ $_POST['sections'] = '';
+ if(isset($cleared_sections_array))
+ {
+ $cleared_sections_array_count = count($cleared_sections_array);
+ $i=1;
+ foreach($cleared_sections_array as $section)
+ {
+ $_POST['sections'] .= $section;
+ if($i<$cleared_sections_array_count) $_POST['sections'] .= ',';
+ ++$i;
+ }
+ }
+
+ // trim custom values:
+ $tv_array = explode(',', $_POST['tv']);
+ foreach($tv_array as $item)
+ {
+ if(trim($item)!='')
+ {
+ $cleared_tv_array[] = trim($item);
+ }
+ }
+ if(isset($cleared_tv_array)) $_POST['tv'] = implode(',', $cleared_tv_array);
+ else $_POST['tv'] = '';
+
+ // generate breadcrumb list:
+ if(isset($_POST['breadcrumbs']) && is_array($_POST['breadcrumbs']))
+ {
+ foreach($_POST['breadcrumbs'] as $breadcrumb)
+ {
+ if(!empty($breadcrumb)) $cleared_breadcrumbs[] = intval($breadcrumb);
+ }
+ if(isset($cleared_breadcrumbs))
+ {
+ $breadcrumb_list = implode(',',$cleared_breadcrumbs);
+ }
+ }
+ if(empty($breadcrumb_list))
+ {
+ $breadcrumb_list = '';
+ }
+
+ // generate edit permission list:
+ $edit_permission_list = '';
+ $users_array = explode(',',$_POST['edit_permission']);
+ foreach($users_array as $current_user)
+ {
+ if(trim($current_user)!='' && in_array(strtolower(trim($current_user)),$users))
+ {
+ $cleared_users_array[] = strtolower(trim($current_user));
+ }
+ else
+ {
+ if(trim($current_user)!='')
+ {
+ $invalid_username = true;
+ }
+ }
+ }
+ if(isset($cleared_users_array))
+ {
+ $cleared_users_array_count = count($cleared_users_array);
+ $users_trans = array_flip($users);
+ $i=1;
+ foreach($cleared_users_array as $current_user)
+ {
+ $edit_permission_list .= $users_trans[$current_user];
+ if($i<$cleared_users_array_count) $edit_permission_list .= ',';
+ ++$i;
+ }
+ }
+ if(isset($invalid_username))
+ {
+ $errors[] = 'invalid_edit_auth_list';
+ }
+
+ #$page = trim($_POST['page']);
+ $type_addition = trim($_POST['type_addition']);
+ if(empty($_POST['page'])) $errors[] = 'error_page_name_empty';
+ elseif(!preg_match(VALID_URL_CHARACTERS, $_POST['page'])) $errors[] ='error_page_name_spec_chars';
+
+ #if(empty($_POST['title'])) $errors[] = 'error_no_title';
+
+ if($_POST['teaser_img']!='' && !file_exists(BASE_PATH.MEDIA_DIR.$_POST['teaser_img'])) $errors[] = 'err_teaser_img_doesnt_exist';
+
+ if(empty($page_types[$_POST['type']])) $errors[] = 'invalid_page_type';
+ if(isset($page_types[$_POST['type']]) && $page_types[$_POST['type']]['requires_parameter'] == true && trim($type_addition)=='') $errors[] = 'page_type_req_param';
+
+ if(($time = strtotime($_POST['time']))===false) $errors[] = 'time_invalid';
+ if(($last_modified = strtotime($_POST['last_modified']))===false) $errors[] = 'last_modified_invalid';
+
+ }
+
+ if(empty($errors))
+ {
+ $dbr = Database::$content->prepare("SELECT id, page FROM ".Database::$db_settings['pages_table']." WHERE lower(page)=:page LIMIT 1");
+ $dbr->bindValue(':page', strtolower($_POST['page']), PDO::PARAM_STR);
+ $dbr->execute();
+ $data = $dbr->fetch();
+ if(isset($data['id']))
+ {
+ #if(isset($_POST['id']) && intval($_POST['id'])==intval($data['id']) && empty($_POST['edit_mode']))
+ # {
+ # // OK...
+ # }
+ if(!(isset($_POST['id']) && empty($_POST['edit_mode']) && intval($data['id'])==intval($_POST['id']))) $errors[] = 'error_page_name_alr_exists';
+ }
+ }
+
+ if(empty($errors))
+ {
+ #$time = mktime(intval($_POST['hour']),intval($_POST['minute']),0,intval($_POST['month']),intval($_POST['day']),intval($_POST['year']));
+ #$last_modified = mktime(intval($_POST['lm_hour']),intval($_POST['lm_minute']),0,intval($_POST['lm_month']),intval($_POST['lm_day']),intval($_POST['lm_year']));
+
+ if(isset($_POST['id']) && empty($_POST['edit_mode']))
+ {
+ $dbr = Database::$content->prepare("UPDATE ".Database::$db_settings['pages_table']." SET page=?, type=?, type_addition=?, time=?, last_modified=?, display_time=?, last_modified_by=?, title=?, page_title=?, description=?, keywords=?, category=?, page_info=?, breadcrumbs=?, headline=?, teaser_headline=?, teaser=?, teaser_formatting=?, teaser_img=?, content=?, content_formatting=?, sidebar_1=?, sidebar_2=?, sidebar_3=?, sidebar_1_formatting=?, sidebar_2_formatting=?, sidebar_3_formatting=?, sections=?, include_page=?, include_order=?, include_rss=?, include_sitemap=?, include_news=?, link_name=?, menu_1=?, menu_2=?, menu_3=?, gcb_1=?, gcb_2=?, gcb_3=?, template=?, language=?, content_type=?, charset=?, page_notes=?, edit_permission=?, edit_permission_general=?, tv=?, status=? WHERE id=?");
+ $dbr->bindParam(1, $_POST['page'], PDO::PARAM_STR);
+ $dbr->bindParam(2, $_POST['type'], PDO::PARAM_STR);
+ $dbr->bindParam(3, $type_addition, PDO::PARAM_STR);
+ $dbr->bindParam(4, $time, PDO::PARAM_INT);
+ $dbr->bindParam(5, $last_modified, PDO::PARAM_INT);
+ $dbr->bindParam(6, $_POST['display_time'], PDO::PARAM_INT);
+ $dbr->bindParam(7, $_SESSION[$settings['session_prefix'].'user_id'], PDO::PARAM_INT);
+ $dbr->bindParam(8, $_POST['title'], PDO::PARAM_STR);
+ $dbr->bindParam(9, $_POST['page_title'], PDO::PARAM_STR);
+ $dbr->bindParam(10, $_POST['description'], PDO::PARAM_STR);
+ $dbr->bindParam(11, $_POST['keywords'], PDO::PARAM_STR);
+ $dbr->bindParam(12, $_POST['category'], PDO::PARAM_STR);
+ $dbr->bindParam(13, $_POST['page_info'], PDO::PARAM_STR);
+ $dbr->bindParam(14, $breadcrumb_list, PDO::PARAM_STR);
+ $dbr->bindParam(15, $_POST['headline'], PDO::PARAM_STR);
+ $dbr->bindParam(16, $_POST['teaser_headline'], PDO::PARAM_STR);
+ $dbr->bindParam(17, $_POST['teaser'], PDO::PARAM_STR);
+ $dbr->bindParam(18, $_POST['teaser_formatting'], PDO::PARAM_INT);
+ $dbr->bindParam(19, $_POST['teaser_img'], PDO::PARAM_STR);
+ $dbr->bindParam(20, $_POST['content'], PDO::PARAM_STR);
+ $dbr->bindParam(21, $_POST['content_formatting'], PDO::PARAM_INT);
+ $dbr->bindParam(22, $_POST['sidebar_1'], PDO::PARAM_STR);
+ $dbr->bindParam(23, $_POST['sidebar_2'], PDO::PARAM_STR);
+ $dbr->bindParam(24, $_POST['sidebar_3'], PDO::PARAM_STR);
+ $dbr->bindParam(25, $_POST['sidebar_1_formatting'], PDO::PARAM_INT);
+ $dbr->bindParam(26, $_POST['sidebar_2_formatting'], PDO::PARAM_INT);
+ $dbr->bindParam(27, $_POST['sidebar_3_formatting'], PDO::PARAM_INT);
+ $dbr->bindParam(28, $_POST['sections'], PDO::PARAM_STR);
+ $dbr->bindParam(29, $_POST['include_page'], PDO::PARAM_INT);
+ $dbr->bindParam(30, $_POST['include_order'], PDO::PARAM_INT);
+ $dbr->bindParam(31, $_POST['include_rss'], PDO::PARAM_INT);
+ $dbr->bindParam(32, $_POST['include_sitemap'], PDO::PARAM_INT);
+ $dbr->bindParam(33, $_POST['include_news'], PDO::PARAM_INT);
+ $dbr->bindParam(34, $_POST['link_name'], PDO::PARAM_STR);
+ $dbr->bindParam(35, $_POST['menu_1'], PDO::PARAM_STR);
+ $dbr->bindParam(36, $_POST['menu_2'], PDO::PARAM_STR);
+ $dbr->bindParam(37, $_POST['menu_3'], PDO::PARAM_STR);
+ $dbr->bindParam(38, $_POST['gcb_1'], PDO::PARAM_STR);
+ $dbr->bindParam(39, $_POST['gcb_2'], PDO::PARAM_STR);
+ $dbr->bindParam(40, $_POST['gcb_3'], PDO::PARAM_STR);
+ $dbr->bindParam(41, $_POST['template'], PDO::PARAM_STR);
+ $dbr->bindParam(42, $_POST['language'], PDO::PARAM_STR);
+ $dbr->bindParam(43, $_POST['content_type'], PDO::PARAM_STR);
+ $dbr->bindParam(44, $_POST['charset'], PDO::PARAM_STR);
+ $dbr->bindParam(45, $_POST['page_notes'], PDO::PARAM_STR);
+ $dbr->bindParam(46, $edit_permission_list, PDO::PARAM_STR);
+ $dbr->bindParam(47, $_POST['edit_permission_general'], PDO::PARAM_INT);
+ $dbr->bindParam(48, $_POST['tv'], PDO::PARAM_STR);
+ $dbr->bindParam(49, $_POST['status'], PDO::PARAM_INT);
+ $dbr->bindParam(50, $_POST['id'], PDO::PARAM_INT);
+ $dbr->execute();
+ #print_r(Database::$content->errorInfo());
+ }
+ else
+ {
+ if(isset($_POST['edit_mode']))
+ {
+ $time = $last_modified;
+ }
+ $dbr = Database::$content->prepare("INSERT INTO ".Database::$db_settings['pages_table']." (page,type,type_addition,time,last_modified,display_time,last_modified_by,title,page_title,description,keywords,category,page_info,breadcrumbs,headline,teaser_headline,teaser,teaser_formatting,teaser_img,content,content_formatting,sidebar_1,sidebar_2,sidebar_3,sidebar_1_formatting,sidebar_2_formatting,sidebar_3_formatting,sections,include_page,include_order,include_rss,include_sitemap,include_news,link_name,menu_1,menu_2,menu_3,gcb_1,gcb_2,gcb_3,template,language,content_type,charset,page_notes,edit_permission,edit_permission_general,tv,status,author) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
+ $dbr->bindParam(1, $_POST['page'], PDO::PARAM_STR);
+ $dbr->bindParam(2, $_POST['type'], PDO::PARAM_STR);
+ $dbr->bindParam(3, $type_addition, PDO::PARAM_STR);
+ $dbr->bindParam(4, $time, PDO::PARAM_INT);
+ $dbr->bindParam(5, $last_modified, PDO::PARAM_INT);
+ $dbr->bindParam(6, $_POST['display_time'], PDO::PARAM_INT);
+ $dbr->bindParam(7, $_SESSION[$settings['session_prefix'].'user_id'], PDO::PARAM_INT);
+ $dbr->bindParam(8, $_POST['title'], PDO::PARAM_STR);
+ $dbr->bindParam(9, $_POST['page_title'], PDO::PARAM_STR);
+ $dbr->bindParam(10, $_POST['description'], PDO::PARAM_STR);
+ $dbr->bindParam(11, $_POST['keywords'], PDO::PARAM_STR);
+ $dbr->bindParam(12, $_POST['category'], PDO::PARAM_STR);
+ $dbr->bindParam(13, $_POST['page_info'], PDO::PARAM_STR);
+ $dbr->bindParam(14, $breadcrumb_list, PDO::PARAM_STR);
+ $dbr->bindParam(15, $_POST['headline'], PDO::PARAM_STR);
+ $dbr->bindParam(16, $_POST['teaser_headline'], PDO::PARAM_STR);
+ $dbr->bindParam(17, $_POST['teaser'], PDO::PARAM_STR);
+ $dbr->bindParam(18, $_POST['teaser_formatting'], PDO::PARAM_INT);
+ $dbr->bindParam(19, $_POST['teaser_img'], PDO::PARAM_STR);
+ $dbr->bindParam(20, $_POST['content'], PDO::PARAM_STR);
+ $dbr->bindParam(21, $_POST['content_formatting'], PDO::PARAM_INT);
+ $dbr->bindParam(22, $_POST['sidebar_1'], PDO::PARAM_STR);
+ $dbr->bindParam(23, $_POST['sidebar_2'], PDO::PARAM_STR);
+ $dbr->bindParam(24, $_POST['sidebar_3'], PDO::PARAM_STR);
+ $dbr->bindParam(25, $_POST['sidebar_1_formatting'], PDO::PARAM_INT);
+ $dbr->bindParam(26, $_POST['sidebar_2_formatting'], PDO::PARAM_INT);
+ $dbr->bindParam(27, $_POST['sidebar_3_formatting'], PDO::PARAM_INT);
+ $dbr->bindParam(28, $_POST['sections'], PDO::PARAM_STR);
+ $dbr->bindParam(29, $_POST['include_page'], PDO::PARAM_INT);
+ $dbr->bindParam(30, $_POST['include_order'], PDO::PARAM_INT);
+ $dbr->bindParam(31, $_POST['include_rss'], PDO::PARAM_INT);
+ $dbr->bindParam(32, $_POST['include_sitemap'], PDO::PARAM_INT);
+ $dbr->bindParam(33, $_POST['include_news'], PDO::PARAM_INT);
+ $dbr->bindParam(34, $_POST['link_name'], PDO::PARAM_STR);
+ $dbr->bindParam(35, $_POST['menu_1'], PDO::PARAM_STR);
+ $dbr->bindParam(36, $_POST['menu_2'], PDO::PARAM_STR);
+ $dbr->bindParam(37, $_POST['menu_3'], PDO::PARAM_STR);
+ $dbr->bindParam(38, $_POST['gcb_1'], PDO::PARAM_STR);
+ $dbr->bindParam(39, $_POST['gcb_2'], PDO::PARAM_STR);
+ $dbr->bindParam(40, $_POST['gcb_3'], PDO::PARAM_STR);
+ $dbr->bindParam(41, $_POST['template'], PDO::PARAM_STR);
+ $dbr->bindParam(42, $_POST['language'], PDO::PARAM_STR);
+ $dbr->bindParam(43, $_POST['content_type'], PDO::PARAM_STR);
+ $dbr->bindParam(44, $_POST['charset'], PDO::PARAM_STR);
+ $dbr->bindParam(45, $_POST['page_notes'], PDO::PARAM_STR);
+ $dbr->bindParam(46, $edit_permission_list, PDO::PARAM_STR);
+ $dbr->bindParam(47, $_POST['edit_permission_general'], PDO::PARAM_INT);
+ $dbr->bindParam(48, $_POST['tv'], PDO::PARAM_STR);
+ $dbr->bindParam(49, $_POST['status'], PDO::PARAM_INT);
+ $dbr->bindParam(50, $_SESSION[$settings['session_prefix'].'user_id'], PDO::PARAM_INT);
+ $dbr->execute();
+ }
+
+ if(isset($cache) && $cache->autoClear) $cache->clear();
+
+ if($settings['pingbacks_enabled'] && $send_pingbacks)
+ {
+ $page_content = $_POST['content'];
+ if($settings['content_auto_link']==1) $page_content = make_link($page_content);
+ $page_content = parse_special_tags($page_content);
+ $pingback = new Pingback();
+ $pingback->ping(BASE_URL.$_POST['page'], $page_content);
+ }
+
+ if(intval($_POST['status'])==0)
+ {
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=pages');
+ exit;
+ }
+ else
+ {
+ header('Location: '.BASE_URL.$_POST['page']);
+ }
+ }
+ else
+ {
+ $template->assign('errors',$errors);
+ if(isset($_POST['id'])) $page_data['id'] = intval($_POST['id']);
+ $page_data['edit_mode'] = isset($_POST['edit_mode']) ? intval($_POST['edit_mode']) : 0;
+ $page_data['page'] = isset($_POST['page']) ? htmlspecialchars($_POST['page']) : '';
+ $page_data['category'] = isset($_POST['category']) ? htmlspecialchars($_POST['category']) : '';
+ $page_data['page_info'] = isset($_POST['page_info']) ? htmlspecialchars($_POST['page_info']) : '';
+ $page_data['page_title'] = isset($_POST['page_title']) ? htmlspecialchars($_POST['page_title']) : '';
+ $page_data['description'] = isset($_POST['description']) ? htmlspecialchars($_POST['description']) : '';
+ $page_data['keywords'] = isset($_POST['keywords']) ? htmlspecialchars($_POST['keywords']) : '';
+ $page_data['title'] = isset($_POST['title']) ? htmlspecialchars($_POST['title']) : '';
+ $page_data['headline'] = isset($_POST['headline']) ? htmlspecialchars($_POST['headline']) : '';
+ $page_data['teaser'] = isset($_POST['teaser']) ? htmlspecialchars($_POST['teaser']) : '';
+ $page_data['teaser_headline'] = isset($_POST['teaser_headline']) ? htmlspecialchars($_POST['teaser_headline']) : '';
+ $page_data['teaser_img'] = isset($_POST['teaser_img']) ? htmlspecialchars($_POST['teaser_img']) : '';
+ $page_data['teaser_formatting'] = isset($_POST['teaser_formatting']) ? intval($_POST['teaser_formatting']) : 0;
+ $page_data['content_formatting'] = isset($_POST['content_formatting']) ? intval($_POST['content_formatting']) : 0;
+ $page_data['sidebar_1'] = isset($_POST['sidebar_1']) ? htmlspecialchars($_POST['sidebar_1']) : '';
+ $page_data['sidebar_2'] = isset($_POST['sidebar_2']) ? htmlspecialchars($_POST['sidebar_2']) : '';
+ $page_data['sidebar_3'] = isset($_POST['sidebar_3']) ? htmlspecialchars($_POST['sidebar_3']) : '';
+ $page_data['sidebar_1_formatting'] = isset($_POST['sidebar_1_formatting']) ? intval($_POST['sidebar_1_formatting']) : 0;
+ $page_data['sidebar_2_formatting'] = isset($_POST['sidebar_2_formatting']) ? intval($_POST['sidebar_2_formatting']) : 0;
+ $page_data['sidebar_3_formatting'] = isset($_POST['sidebar_3_formatting']) ? intval($_POST['sidebar_3_formatting']) : 0;
+ $page_data['type'] = isset($_POST['type']) ? htmlspecialchars($_POST['type']) : '';
+ $page_data['type_addition'] = isset($_POST['type_addition']) ? htmlspecialchars($_POST['type_addition']) : '';
+ $page_data['time'] = isset($_POST['time']) ? htmlspecialchars($_POST['time']) : '';
+ $page_data['last_modified'] = isset($_POST['last_modified']) ? htmlspecialchars($_POST['last_modified']) : '';
+ $page_data['display_time'] = isset($_POST['display_time']) && $_POST['display_time']==1 ? 1 : 0;
+ $page_data['include_page'] = isset($_POST['include_page']) ? intval($_POST['include_page']) : 0;
+ $page_data['include_order'] = isset($_POST['include_order']) ? intval($_POST['include_order']) : 0;
+ $page_data['include_rss'] = isset($_POST['include_rss']) ? intval($_POST['include_rss']) : 0;
+ $page_data['include_sitemap'] = isset($_POST['include_sitemap']) ? intval($_POST['include_sitemap']) : 0;
+ $page_data['include_news'] = isset($_POST['include_news']) ? intval($_POST['include_news']) : 0;
+ $page_data['link_name'] = isset($_POST['link_name']) ? htmlspecialchars($_POST['link_name']) : Localization::$lang['teaser_default_linkname'];
+ $page_data['template'] = isset($_POST['template']) ? htmlspecialchars($_POST['template']) : $settings['default_template'];
+ $page_data['language'] = isset($_POST['language']) ? htmlspecialchars($_POST['language']) : '';
+ $page_data['content_type'] = isset($_POST['content_type']) ? htmlspecialchars($_POST['content_type']) : '';
+ $page_data['charset'] = isset($_POST['charset']) ? htmlspecialchars($_POST['charset']) : '';
+ $page_data['menu_1'] = isset($_POST['menu_1']) ? htmlspecialchars($_POST['menu_1']) : $settings['default_menu'];;
+ $page_data['menu_2'] = isset($_POST['menu_2']) ? htmlspecialchars($_POST['menu_2']) : '';
+ $page_data['menu_3'] = isset($_POST['menu_3']) ? htmlspecialchars($_POST['menu_3']) : '';
+ $page_data['gcb_1'] = isset($_POST['gcb_1']) ? intval($_POST['gcb_1']) : '';
+ $page_data['gcb_2'] = isset($_POST['gcb_2']) ? intval($_POST['gcb_2']) : '';
+ $page_data['gcb_3'] = isset($_POST['gcb_3']) ? intval($_POST['gcb_3']) : '';
+ $page_data['page_notes'] = isset($_POST['page_notes']) ? htmlspecialchars($_POST['page_notes']) : '';
+ $page_data['sections'] = isset($_POST['sections']) ? htmlspecialchars($_POST['sections']) : '';
+ $page_data['tv'] = isset($_POST['tv']) ? htmlspecialchars($_POST['tv']) : '';
+ $page_data['edit_permission_general'] = isset($_POST['edit_permission_general']) ? intval($_POST['edit_permission_general']) : 0;
+ $page_data['status'] = isset($_POST['status']) ? intval($_POST['status']) : 0;
+
+ if(isset($_POST['breadcrumbs']) && is_array($_POST['breadcrumbs']))
+ {
+ foreach($_POST['breadcrumbs'] as $breadcrumb)
+ {
+ if(!empty($breadcrumb)) $page_data['breadcrumbs'][] = intval($breadcrumb);
+ }
+ }
+
+ $page_data['content'] = isset($_POST['content']) ? htmlspecialchars($_POST['content']) : '';
+
+ $edit_mode = isset($_POST['edit_mode']) && $_POST['edit_mode']==1 ? 1 : 0;
+ }
+ }
+ // end if(isset($_POST['content']))
+
+ switch($action)
+ {
+ case 'main':
+ // get available pages:
+ $dbr = Database::$content->query("SELECT id, page, type FROM ".Database::$db_settings['pages_table']." ORDER BY page ASC");
+ $i=0;
+ $ii=0;
+ while($pages_data = $dbr->fetch())
+ {
+ $pages[$i]['id'] = $pages_data['id'];
+ $pages[$i]['page'] = $pages_data['page'];
+ $pages[$i]['type'] = $pages_data['type'];
+
+ if($pages_data['type']=='news' || $pages_data['type']=='simple_news')
+ {
+ $simple_news_pages[$ii]['id'] = $pages_data['id'];
+ $simple_news_pages[$ii]['page'] = $pages_data['page'];
+ ++$ii;
+ }
+
+ ++$i;
+ }
+ if(isset($pages))
+ {
+ $template->assign('pages',$pages);
+ }
+ if(isset($simple_news_pages))
+ {
+ $template->assign('simple_news_pages',$simple_news_pages);
+ }
+
+ // get menus:
+ $menu_result = Database::$content->query("SELECT DISTINCT menu FROM ".Database::$db_settings['menu_table']." ORDER BY menu ASC");
+ while($menu_data = $menu_result->fetch())
+ {
+ $menus[] = $menu_data['menu'];
+ }
+ if(isset($menus))
+ {
+ $template->assign('menus',$menus);
+ }
+
+ // get global content blocks:
+ $gcb_result = Database::$content->query("SELECT id, identifier FROM ".Database::$db_settings['gcb_table']." ORDER BY id ASC");
+ $i=0;
+ while($gcb_data = $gcb_result->fetch())
+ {
+ $gcbs[$i]['id'] = $gcb_data['id'];
+ $gcbs[$i]['identifier'] = $gcb_data['identifier'];
+ $i++;
+ }
+ if(isset($gcbs))
+ {
+ $template->assign('gcbs',$gcbs);
+ }
+
+ // get available templates:
+ $handle=opendir(BASE_PATH.'cms/templates/');
+ while($file = readdir($handle))
+ {
+ if(preg_match('/\.tpl$/i', $file))
+ {
+ $template_file_array[] = $file;
+ }
+ }
+ closedir($handle);
+ natcasesort($template_file_array);
+ $i=0;
+ foreach($template_file_array as $file)
+ {
+ $template_files[$i] = $file;
+ #$template_files[$i]['name'] = htmlspecialchars($file);
+ $i++;
+ }
+ if(isset($template_files))
+ {
+ $template->assign('template_files',$template_files);
+ }
+
+ $template->assign('page_languages', get_languages());
+
+ if(empty($edit_mode))
+ {
+ $edit_mode=0;
+ }
+ $template->assign('edit_mode',$edit_mode);
+ if(isset($page_data))
+ {
+ $template->assign('page_data', $page_data);
+ $template->assign('send_pingbacks', $send_pingbacks);
+ }
+ $template->assign('subtemplate', 'edit.inc.tpl');
+ break;
+
+ case 'page_doesnt_exist':
+ $template->assign('invalid_request', 'page_doesnt_exist');
+ $template->assign('subtemplate', 'edit.inc.tpl');
+ break;
+ case 'no_authorization':
+ $template->assign('invalid_request', 'no_authorization_edit');
+ $template->assign('subtemplate', 'edit.inc.tpl');
+ break;
+ }
+}
diff --git a/cms/includes/exception.inc.php b/cms/includes/exception.inc.php
new file mode 100644
index 0000000..704e1c0
--- /dev/null
+++ b/cms/includes/exception.inc.php
@@ -0,0 +1,65 @@
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+Message: getMessage(); ?>
+Code: getCode(); ?>
+File: getFile(); ?>
+Line: getLine(); ?>
+
+
+'.$exception->__toString().'';
+echo '';
+print_r($exception);
+echo '
';
+
+echo '';
+print_r($GLOBALS);
+echo '
';
+*/
+?>
+
+
+
+
+
+
+
diff --git a/cms/includes/filemanager.inc.php b/cms/includes/filemanager.inc.php
new file mode 100644
index 0000000..0fb83de
--- /dev/null
+++ b/cms/includes/filemanager.inc.php
@@ -0,0 +1,216 @@
+assign('media_dir', $media_dir);
+$template->assign('file_dir', $file_dir);
+
+$directory = isset($_REQUEST['directory']) && $_REQUEST['directory']==$file_dir ? $file_dir : $media_dir;
+$template->assign('directory', $directory);
+
+$path = BASE_PATH.'static/'.$directory.'/';
+
+if(isset($_SESSION[$settings['session_prefix'].'user_id']))
+ {
+
+ // delete:
+ if(isset($_REQUEST['delete']))
+ {
+ if(isset($_REQUEST['confirmed']))
+ {
+ @chmod($path.$_REQUEST['delete'], 0777);
+ if(!@unlink($path.$_REQUEST['delete'])) $errors[] = Localization::$lang['delete_file_error'];
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=filemanager&directory='.$directory);
+ exit;
+ }
+ else
+ {
+ $template->assign('file', htmlspecialchars($_REQUEST['delete']));
+ $action = 'delete';
+ }
+ }
+
+ if(isset($_POST['upload_file_submit']))
+ {
+ $file_name = isset($_POST['file_name']) ? trim($_POST['file_name']) : '';
+ $upload_mode = isset($_POST['upload_mode']) && $_POST['upload_mode']==2 ? 2 : 1;
+ $compression = isset($_POST['compression']) ? intval($_POST['compression']) : $settings['compression'];
+ $resize_xy = isset($_POST['resize_xy']) && $_POST['resize_xy']=='x' ? 'x' : 'y';
+ $resize = isset($_POST['resize']) ? intval($_POST['resize']) : $settings['resize'];
+ $thumbnail_compression = isset($_POST['thumbnail_compression']) ? intval($_POST['thumbnail_compression']) : $settings['thumbnail_compression'];
+ $thumbnail_resize_xy = isset($_POST['thumbnail_resize_xy']) && $_POST['thumbnail_resize_xy']=='x' ? 'x' : 'y';
+ $thumbnail_resize = isset($_POST['thumbnail_resize']) ? intval($_POST['thumbnail_resize']) : $settings['thumbnail_resize'];
+
+ #if(empty($_FILES['probe']) || $_FILES['probe']['size'] == 0 || $_FILES['probe']['error']) $errors[] = Localization::$lang['error_no_file'];
+ if($compression < 1 || $compression > 100 || $thumbnail_compression < 1 || $thumbnail_compression > 100) $errors[] = 'invalid_compression_value';
+
+ if(empty($errors))
+ {
+ // filename already exists?
+ if($file_name=='') $file_name = basename($_FILES['file']['name']);
+ if(file_exists($path.$file_name) && empty($_POST['overwrite_file']))
+ {
+ #$file_name = '';
+ $errors[] = 'upload_file_exists';
+ }
+ }
+ if(empty($errors))
+ {
+ $upload = new FileUpload($_FILES['file'], $path);
+
+ if($upload_mode==2 && $upload->isImage)
+ {
+ // its an image and it should be manipulated
+ //$upload = new FileUpload($_FILES['file'], BASE_PATH.$directory.'/');
+ if($resize_xy=='x')
+ {
+ $x = $resize;
+ $y = intval($upload->imageHeight*$x/$upload->imageWidth);
+ }
+ else
+ {
+ $y = $resize;
+ $x = intval($upload->imageWidth*$y/$upload->imageHeight);
+ }
+ if(!$upload->saveModifiedImage($x, $y, $compression, $file_name))
+ {
+ $errors[] = 'upload_error';
+ }
+ }
+ else
+ {
+ #move_uploaded_file($_FILES['file']['tmp_name'], BASE_PATH.$directory.'/'.$file_name); // or $errors[] = 'upload_error';
+ $upload->saveFile($file_name);
+ }
+ // create thumbnail:
+ if(isset($_POST['create_thumbnail']) && $upload->isImage)
+ {
+
+ if($thumbnail_resize_xy=='x')
+ {
+ $thumbnail_x = $thumbnail_resize;
+ $thumbnail_y = intval($upload->imageHeight*$thumbnail_x/$upload->imageWidth);
+ }
+ else
+ {
+ $thumbnail_y = $thumbnail_resize;
+ $thumbnail_x = intval($upload->imageWidth*$thumbnail_y/$upload->imageHeight);
+ }
+
+
+ // set thumbnail name:
+ if($settings['thumbnail_prefix'])
+ {
+ $thumbnail_filename = $settings['thumbnail_prefix'].$file_name;
+ }
+ elseif($settings['thumbnail_postfix'])
+ {
+ $ext_pos = strrpos($file_name, '.');
+ $name = substr($file_name, 0, $ext_pos);
+ $ext = substr($file_name, $ext_pos);
+ $thumbnail_filename = $name.$settings['thumbnail_postfix'].$ext;
+ }
+
+ if(!$upload->saveModifiedImage($thumbnail_x, $thumbnail_y, $thumbnail_compression, $thumbnail_filename))
+ {
+ // error...
+ }
+ }
+ }
+ if(empty($errors))
+ {
+ @chmod($path.$file_name, 0644);
+ // save upload defaults:
+ Database::$content->beginTransaction();
+ $dbr = Database::$content->prepare("UPDATE ".Database::$db_settings['settings_table']." SET value=:value WHERE name=:name");
+ $dbr->bindValue(':name', 'resize', PDO::PARAM_STR);
+ $dbr->bindParam(':value', $resize, PDO::PARAM_STR);
+ $dbr->execute();
+ $dbr->bindValue(':name', 'resize_xy', PDO::PARAM_STR);
+ $dbr->bindParam(':value', $resize_xy, PDO::PARAM_STR);
+ $dbr->execute();
+ $dbr->bindValue(':name', 'compression', PDO::PARAM_STR);
+ $dbr->bindParam(':value', $compression, PDO::PARAM_STR);
+ $dbr->execute();
+ $dbr->bindValue(':name', 'thumbnail_resize', PDO::PARAM_STR);
+ $dbr->bindParam(':value', $thumbnail_resize, PDO::PARAM_STR);
+ $dbr->execute();
+ $dbr->bindValue(':name', 'thumbnail_resize_xy', PDO::PARAM_STR);
+ $dbr->bindParam(':value', $thumbnail_resize_xy, PDO::PARAM_STR);
+ $dbr->execute();
+ $dbr->bindValue(':name', 'thumbnail_compression', PDO::PARAM_STR);
+ $dbr->bindParam(':value', $thumbnail_compression, PDO::PARAM_STR);
+ $dbr->execute();
+
+ Database::$content->commit();
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=filemanager&directory='.$directory.'&uploaded=true');
+ exit();
+ }
+ else
+ {
+ $template->assign('errors', $errors);
+ $action='upload';
+ }
+ }
+
+ if(isset($_REQUEST['action'])) $action = $_REQUEST['action'];
+ if(empty($action)) $action = 'main';
+
+ switch($action)
+ {
+ case 'main':
+ $fp=opendir($path);
+ while($file = readdir($fp))
+ {
+ #if($file!='.' && $file!='..')
+ if(is_file($path.$file))
+ {
+ $file_array[] = $file;
+ }
+ }
+ closedir($fp);
+
+ if(isset($file_array))
+ {
+ natcasesort($file_array);
+
+ if(function_exists('mime_content_type'))
+ {
+ $mime_content_type=true;
+ $template->assign('mime_content_type', $mime_content_type);
+ }
+
+ $i=0;
+ foreach($file_array as $file)
+ {
+ $files[$i]['filename'] = htmlspecialchars($file);
+ $files[$i]['size'] = number_format(filesize($path.$file)/1000,1,",",".");
+ $files[$i]['last_modified'] = strftime(Localization::$lang['time_format'], filectime($path.$file));
+ if(isset($mime_content_type))
+ {
+ $files[$i]['mime_content_type'] = mime_content_type($path.$file);
+ }
+ ++$i;
+ }
+ if(isset($files))
+ {
+ $template->assign('files', $files);
+ }
+ }
+ if(isset($_GET['uploaded'])) $template->assign('uploaded', true);
+ $template->assign('subtitle', Localization::$lang['filemanager']);
+ $template->assign('subtemplate', 'filemanager.inc.tpl');
+ break;
+ case 'upload';
+ $template->assign('subtitle', Localization::$lang['upload_file']);
+ $template->assign('subtemplate', 'filemanager_upload.inc.tpl');
+
+ break;
+ case 'delete':
+ $template->assign('subtitle', Localization::$lang['delete_file']);
+ $template->assign('subtemplate', 'filemanager_delete.inc.tpl');
+ break;
+ }
+ }
diff --git a/cms/includes/functions.admin.inc.php b/cms/includes/functions.admin.inc.php
new file mode 100644
index 0000000..570ef14
--- /dev/null
+++ b/cms/includes/functions.admin.inc.php
@@ -0,0 +1,97 @@
+prepare("SELECT ".$section.", sequence FROM ".$table." WHERE id=:id LIMIT 1");
+ $dbr->bindParam(':id', $item, PDO::PARAM_INT);
+ $dbr->execute();
+ $data = $dbr->fetch();
+ if(isset($data['sequence']))
+ {
+ if($data['sequence'] > 1)
+ {
+ Database::$content->beginTransaction();
+ $dbr = Database::$content->prepare("UPDATE ".$table." SET sequence=:new_sequence WHERE ".$section."=:section AND sequence=:sequence");
+ $dbr->bindParam(':section', $data[$section], PDO::PARAM_STR);
+ $dbr->bindValue(':new_sequence', 0, PDO::PARAM_INT);
+ $dbr->bindValue(':sequence', $data['sequence']-1, PDO::PARAM_INT);
+ $dbr->execute();
+ $dbr->bindValue(':new_sequence', $data['sequence']-1, PDO::PARAM_INT);
+ $dbr->bindValue(':sequence', $data['sequence'], PDO::PARAM_INT);
+ $dbr->execute();
+ $dbr->bindValue(':new_sequence', $data['sequence'], PDO::PARAM_INT);
+ $dbr->bindValue(':sequence', 0, PDO::PARAM_INT);
+ $dbr->execute();
+ Database::$content->commit();
+ }
+ return $data[$section];
+ }
+ return false;;
+ }
+
+function move_down($item, $section, $table)
+ {
+ $dbr = Database::$content->prepare("SELECT ".$section.", sequence FROM ".$table." WHERE id=:id LIMIT 1");
+ $dbr->bindParam(':id', $item, PDO::PARAM_INT);
+ $dbr->execute();
+ $data = $dbr->fetch();
+ if(isset($data['sequence']))
+ {
+ $dbr = Database::$content->prepare("SELECT sequence FROM ".$table." WHERE ".$section."=:section ORDER BY sequence DESC LIMIT 1");
+ $dbr->bindParam(':section', $data[$section], PDO::PARAM_STR);
+ $dbr->execute();
+ $last = $dbr->fetchColumn();
+ if($data['sequence'] < $last)
+ {
+ Database::$content->beginTransaction();
+ $dbr = Database::$content->prepare("UPDATE ".$table." SET sequence=:new_sequence WHERE ".$section."=:section AND sequence=:sequence");
+ $dbr->bindParam(':section', $data[$section], PDO::PARAM_STR);
+ $dbr->bindValue(':new_sequence', 0, PDO::PARAM_INT);
+ $dbr->bindValue(':sequence', $data['sequence']+1, PDO::PARAM_INT);
+ $dbr->execute();
+ $dbr->bindValue(':new_sequence', $data['sequence']+1, PDO::PARAM_INT);
+ $dbr->bindValue(':sequence', $data['sequence'], PDO::PARAM_INT);
+ $dbr->execute();
+ $dbr->bindValue(':new_sequence', $data['sequence'], PDO::PARAM_INT);
+ $dbr->bindValue(':sequence', 0, PDO::PARAM_INT);
+ $dbr->execute();
+ Database::$content->commit();
+ }
+ return $data[$section];
+ }
+ return false;
+ }
+
+?>
diff --git a/cms/includes/functions.content.inc.php b/cms/includes/functions.content.inc.php
new file mode 100644
index 0000000..5a1e63a
--- /dev/null
+++ b/cms/includes/functions.content.inc.php
@@ -0,0 +1,8 @@
+
diff --git a/cms/includes/functions.inc.php b/cms/includes/functions.inc.php
new file mode 100644
index 0000000..700560d
--- /dev/null
+++ b/cms/includes/functions.inc.php
@@ -0,0 +1,1027 @@
+';
+ print_r($what);
+ exit;
+ }
+
+/**
+ * fetches settings from database
+ */
+function get_settings()
+ {
+ #global $pdo, $db_settings;
+ #$database = Database::getInstance();
+ $result = Database::$content->query("SELECT name, value FROM ".Database::$db_settings['settings_table']);
+ while($line = $result->fetch())
+ {
+ $settings[$line['name']] = $line['value'];
+ }
+ return $settings;
+ }
+
+function get_base_url($cut=false)
+ {
+ global $settings;
+ if($settings['base_url']!='')
+ {
+ return $settings['base_url'];
+ }
+ if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on')
+ {
+ $protocol = 'https://';
+ }
+ else
+ {
+ $protocol = 'http://';
+ }
+ $base_url = $protocol . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
+ if(substr($base_url, -1) != '/') $base_url = $base_url.'/';
+ if($cut)
+ {
+ $pos = strrpos($base_url, $cut);
+ if($pos!==false)
+ {
+ $base_url = substr($base_url, 0, $pos);
+ }
+ }
+ return $base_url;
+ }
+
+function get_base_path($cut=false)
+ {
+ global $settings;
+ if($settings['base_path']!='')
+ {
+ return $settings['base_path'];
+ }
+ $base_path = dirname($_SERVER['SCRIPT_FILENAME']) . '/';
+ if($cut)
+ {
+ $pos = strrpos($base_path, $cut);
+ if($pos!==false)
+ {
+ $base_path = substr($base_path, 0, $pos);
+ }
+ }
+ return $base_path;
+ }
+
+/**
+ * gets available languages
+ *
+ * @reurn array
+ */
+function get_languages($admin=false)
+ {
+ if($admin) $file_schema = '.admin.lang.php';
+ else $file_schema = '.page.lang.php';
+ $length = 0-strlen($file_schema);
+ foreach (glob(BASE_PATH.'cms/lang/*'.$file_schema) as $filename)
+ {
+ $languages[] = substr(basename($filename), 0, $length); // filename without extension ".[admin|page].lang.php"
+ }
+ if(isset($languages))
+ {
+ natcasesort($languages);
+ $i=0;
+ foreach($languages as $language)
+ {
+ $languages_detailed[$i]['identifier'] = $language;
+ $languages_detailed[$i]['name'] = get_language_name($language);
+ ++$i;
+ }
+ return $languages_detailed;
+ }
+ return false;
+ }
+
+/**
+ * helper function for get_languages()
+ *
+ * @reurn string
+ */
+function get_language_name($string)
+ {
+ $string_parts = explode('_', $string);
+ if(isset($string_parts[1])) $name = ucfirst($string_parts[0]).' ('.$string_parts[1].')';
+ else $name = ucfirst($string);
+ return $name;
+ }
+
+/**
+ * fetches page content from database
+ *
+ * @param string $page
+ * @return mixed
+ */
+function get_content($page)
+ {
+ #global $settings, $db_settings, $pdo;
+ $content_query = "SELECT id, page, author, type, type_addition, time, last_modified, display_time, page_title, title, keywords, description, category, page_info, language, breadcrumbs, headline, teaser_headline, teaser, teaser_formatting, content, content_formatting, sidebar_1, sidebar_1_formatting, sidebar_2, sidebar_2_formatting, sidebar_3, sidebar_3_formatting, sections, menu_1, menu_2, menu_3, gcb_1, gcb_2, gcb_3, include_news, template, content_type, charset, edit_permission, edit_permission_general, tv, status FROM ".Database::$db_settings['pages_table']." WHERE lower(page)=lower(:page) AND status!=0 LIMIT 1";
+ $dbr = Database::$content->prepare($content_query);
+ $dbr->bindParam(':page', $page, PDO::PARAM_STR);
+ $dbr->execute();
+ $data = $dbr->fetch();
+ if(isset($data['id'])) return $data;
+ return false;
+ }
+
+function db_error()
+ {
+ global $error_503;
+ header($_SERVER['SERVER_PROTOCOL'] . " 503 Service Unavailable");
+ header("Status: 503 Service Unavailable");
+ echo $error_503;
+ exit;
+ }
+
+/**
+ * gets the menus
+ *
+ * @return array
+ */
+function get_menus()
+ {
+ #global $db_settings, $pdo;
+ $menu_result = Database::$content->query("SELECT id, menu, name, title, link, section, accesskey FROM ".Database::$db_settings['menu_table']." ORDER BY menu ASC, sequence ASC");
+ $i=0;
+ while($row = $menu_result->fetch())
+ {
+ $menus[$row['menu']][$i]['name'] = $row['name'];
+ $menus[$row['menu']][$i]['title'] = $row['title'];
+ if(mb_substr($row['link'],0,7) != 'http://' && mb_substr($row['link'],0,8) != 'https://' && mb_substr($row['link'],0,6) != 'ftp://' && mb_substr($row['link'],0,9) != 'gopher://' && mb_substr($row['link'],0,7) != 'news://')
+ {
+ $menus[$row['menu']][$i]['link'] = BASE_URL.$row['link'];
+ }
+ else
+ {
+ $menus[$row['menu']][$i]['link'] = $row['link'];
+ }
+ $menus[$row['menu']][$i]['section'] = $row['section'];
+ $menus[$row['menu']][$i]['accesskey'] = $row['accesskey'];
+ ++$i;
+ }
+ if(isset($menus))
+ {
+ return $menus;
+ }
+ return false;
+ }
+
+/**
+ * gets global content blocks
+ *
+ * @return array
+ */
+function get_global_content_blocks()
+ {
+ #global $db_settings, $pdo;
+ $gcb_result = Database::$content->query("SELECT id, identifier, content FROM ".Database::$db_settings['gcb_table']." ORDER BY id ASC");
+ while($row = $gcb_result->fetch())
+ {
+ $gcb[$row['identifier']] = $row['content'];
+ #if($row['content_formatting']==1) $gcb[$row['id']] = auto_html($gcb[$row['id']]);
+ }
+ if(isset($gcb))
+ {
+ return $gcb;
+ }
+ return false;
+ }
+
+/**
+ * gets page names and page titles of breadcrumbs
+ *
+ * @param string $breadcrumbs_id_list
+ * @return array
+ */
+function get_breadcrumbs($breadcrumbs_id_list)
+ {
+ if(trim($breadcrumbs_id_list)!='')
+ {
+ $breadcrumb_ids = explode(',',$breadcrumbs_id_list);
+ $breadcrumb_ids = array_map('intval', $breadcrumb_ids);
+ #if(isset($breadcrumb_ids))
+ # {
+ $ids = implode(',', $breadcrumb_ids);
+ $dbr = Database::$content->query("SELECT id, page, title FROM ".Database::$db_settings['pages_table']." WHERE id IN(".$ids.")");
+ while($data = $dbr->fetch())
+ {
+ $unordered_breadcrumbs[$data['id']]['page'] = $data['page'];
+ $unordered_breadcrumbs[$data['id']]['title'] = $data['title'];
+ }
+ // order:
+ foreach($breadcrumb_ids as $id)
+ {
+ if(isset($unordered_breadcrumbs[$id])) $breadcrumbs[] = $unordered_breadcrumbs[$id];
+ }
+ /* // the same with several database requests (1 per breadcrumb):
+ $dbr = Database::$content->prepare("SELECT page, title FROM ".Database::$db_settings['pages_table']." WHERE id=:id");
+ $i=0;
+ Database::$content->beginTransaction();
+ foreach($breadcrumb_ids as $breadcrumb_id)
+ {
+ $dbr->bindValue(':id', $breadcrumb_id, PDO::PARAM_INT);
+ $dbr->execute();
+ $data = $dbr->fetch();
+ if(isset($data['page']))
+ {
+ $breadcrumbs[$i]['page'] = $data['page'];
+ $breadcrumbs[$i]['title'] = $data['title'];
+ ++$i;
+ unset($data);
+ }
+ }
+ Database::$content->commit();
+ */
+ #}
+ if(isset($breadcrumbs))
+ {
+ return $breadcrumbs;
+ }
+ }
+ return false;
+ }
+
+function is_vailid_photo_page($content, $type, $type_addition, $gallery, $gallery_items)
+ {
+ if($type=='search')
+ {
+ return 1; // valid but not cacheable
+ }
+ if($type=='gallery' && $type_addition==$gallery)
+ {
+ return 2;
+ }
+ if(strpos($content, '[gallery:'.$gallery)!==false)
+ {
+ return 2;
+ }
+ foreach($gallery_items as $gallery_item)
+ {
+ if(strpos($content, '[thumbnail:'.$gallery_item)!==false)
+ {
+ return 2;
+ }
+ }
+ return false;
+ }
+
+/*
+ * formats a paragraph
+ */
+function format_paragraph($string)
+ {
+ $string = nl2br(preg_replace('/\[\[([^|\]]+?)(?:\|([^\]]+))?\]\]/e', "''.(('\$2')?'\$2':'\$1').''", $string));
+ return $string;
+ }
+
+/**
+ * filters control characters
+ *
+ * @param string $string
+ * @return string
+ */
+function filter_control_characters($string)
+ {
+ $char = array(array(), array());
+ $char['char'][0] = chr(0);
+ $char['repl'][0] = '';
+ $char['char'][1] = chr(1);
+ $char['repl'][1] = '';
+ $char['char'][2] = chr(2);
+ $char['repl'][2] = '';
+ $char['char'][3] = chr(3);
+ $char['repl'][3] = '';
+ $char['char'][4] = chr(4);
+ $char['repl'][4] = '';
+ $char['char'][5] = chr(5);
+ $char['repl'][5] = '';
+ $char['char'][6] = chr(6);
+ $char['repl'][6] = '';
+ $char['char'][7] = chr(7);
+ $char['repl'][7] = '';
+ $char['char'][8] = chr(8);
+ $char['repl'][8] = '';
+ $char['char'][9] = chr(9);
+ $char['repl'][9] = ' ';
+ $char['char'][10] = chr(10);
+ $char['repl'][10] = chr(10);
+ $char['char'][11] = chr(11);
+ $char['repl'][11] = '';
+ $char['char'][12] = chr(12);
+ $char['repl'][12] = '';
+ $char['char'][13] = chr(13);
+ $char['repl'][13] = chr(13);
+ $char['char'][14] = chr(14);
+ $char['repl'][14] = '';
+ $char['char'][15] = chr(15);
+ $char['repl'][15] = '';
+ $char['char'][16] = chr(16);
+ $char['repl'][16] = '';
+ $char['char'][17] = chr(17);
+ $char['repl'][17] = '';
+ $char['char'][18] = chr(18);
+ $char['repl'][18] = '';
+ $char['char'][19] = chr(19);
+ $char['repl'][19] = '';
+ $char['char'][20] = chr(20);
+ $char['repl'][20] = '';
+ $char['char'][21] = chr(21);
+ $char['repl'][21] = '';
+ $char['char'][22] = chr(22);
+ $char['repl'][22] = '';
+ $char['char'][23] = chr(23);
+ $char['repl'][23] = '';
+ $char['char'][24] = chr(24);
+ $char['repl'][24] = '';
+ $char['char'][25] = chr(25);
+ $char['repl'][25] = '';
+ $char['char'][26] = chr(26);
+ $char['repl'][26] = '';
+ $char['char'][27] = chr(27);
+ $char['repl'][27] = '';
+ $char['char'][28] = chr(28);
+ $char['repl'][28] = '';
+ $char['char'][29] = chr(29);
+ $char['repl'][29] = '';
+ $char['char'][30] = chr(30);
+ $char['repl'][30] = '';
+ $char['char'][31] = chr(31);
+ $char['repl'][31] = '';
+ $string = str_replace($char['char'], $char['repl'], $string);
+ return $string;
+}
+
+function auto_html($text)
+ {
+ $text = trim($text);
+ if($text!='')
+ {
+ #$text = preg_replace('/\[\[([^|\]]+?)(?:\|([^\]]+))?\]\]/e', "''.(('\$2')?'\$2':'\$1').''", $text);
+ $text = '' . $text . '
';
+ $text = preg_replace("/(\015\012\015\012)|(\015\015)|(\012\012)/","",$text);
+ $text = nl2br($text);
+ }
+ return $text;
+ }
+
+function content_function($function)
+ {
+ return @eval('return '.$function[1].';');
+ }
+
+function create_image($string)
+ {
+ global $template, $settings;
+ $string = explode('|',$string[1]);
+ $file = $string[0];
+ if(isset($string[1]) && $string[1]!='') $img_class = $string[1];
+ if(isset($string[2])) $img_alt = $string[2];
+ else $img_alt = '';
+ if(isset($string[3]) && intval($string[3])>0) $width = intval($string[3]);
+ if(isset($string[4]) && intval($string[4])>0) $height = intval($string[4]);
+ if(file_exists(BASE_PATH.MEDIA_DIR.$file))
+ {
+ if(substr(strtolower($file), -4) == '.swf')
+ {
+ $image['type']='flash';
+ if(isset($width) && isset($height))
+ {
+ $image['width'] = $width;
+ $image['height'] = $height;
+ }
+ else
+ {
+ $image['width'] = $settings['flash_default_width'];
+ $image['height'] = $settings['flash_default_height'];
+ }
+ }
+ elseif(substr(strtolower($file), -4) == '.flv')
+ {
+ $image['type']='flv';
+ if(isset($width) && isset($height))
+ {
+ $image['width'] = $width;
+ $image['height'] = $height;
+ }
+ else
+ {
+ $image['width'] = $settings['flash_default_width'];
+ $image['height'] = $settings['flash_default_height'];
+ }
+ }
+ else
+ {
+ $image['type']='image';
+ if(isset($width) && isset($height))
+ {
+ $image['width'] = $width;
+ $image['height'] = $height;
+ }
+ else
+ {
+ $image_info = getimagesize(BASE_PATH.MEDIA_DIR.$file);
+ $image['width'] = $image_info[0];
+ $image['height'] = $image_info[1];
+ }
+ }
+ $image['image'] = $file;
+ $image['alt'] = htmlspecialchars($img_alt);
+ if(isset($img_class)) $image['class'] = htmlspecialchars($img_class);
+ $template->assign('image', $image);
+ }
+ $image_code = $template->fetch(BASE_PATH.'templates/subtemplates/image.inc.tpl');
+ return $image_code;
+ }
+
+function create_thumbnail($string)
+ {
+ global $template;
+ $page = isset($GLOBALS['parent_page']) && $GLOBALS['parent_page'] ? $GLOBALS['parent_page'] : PAGE;
+ $template->assign('contains_thumbnails', true);
+ $template->assign('page', $page);
+ $string = explode('|',$string[1]);
+ $id = intval($string[0]);
+ if(isset($string[1])) $img_class = $string[1];
+ $dbr = Database::$content->prepare("SELECT id, photo_thumbnail, photo_normal, title, subtitle, description FROM ".Database::$db_settings['photo_table']." WHERE id=:id LIMIT 1");
+ $dbr->bindParam(':id', $id, PDO::PARAM_INT);
+ $dbr->execute();
+ $data = $dbr->fetch();
+ if(isset($data['id']))
+ {
+ $thumbnail['id'] = $data['id'];
+ $thumbnail['image'] = $data['photo_thumbnail'];
+ $thumbnail['photo'] = $data['photo_normal'];
+ $thumbnail_info = getimagesize(BASE_PATH.MEDIA_DIR.$data['photo_thumbnail']);
+ $thumbnail['width'] = $thumbnail_info[0];
+ $thumbnail['height'] = $thumbnail_info[1];
+ if(isset($img_class))
+ {
+ $thumbnail['class'] = htmlspecialchars($img_class);
+ }
+ $thumbnail['title'] = htmlspecialchars(strip_tags($data['title']));
+ $thumbnail['subtitle'] = htmlspecialchars(strip_tags($data['subtitle']));
+ $thumbnail['description'] = htmlspecialchars(strip_tags($data['description']));
+ #else $thumbnail = '
';
+ $template->assign('thumbnail', $thumbnail);
+ }
+ $thumbnail = $template->fetch(BASE_PATH.'cms/templates/subtemplates/thumbnail.inc.tpl');
+ return $thumbnail;
+ }
+
+function create_thumbnail_rss($string)
+ {
+ global $template;
+ $page = isset($GLOBALS['parent_page']) && $GLOBALS['parent_page'] ? $GLOBALS['parent_page'] : PAGE;
+ $template->assign('contains_thumbnails', true);
+ $template->assign('page', $page);
+ $string = explode('|',$string[1]);
+ $id = intval($string[0]);
+ if(isset($string[1])) $img_class = $string[1];
+ $dbr = Database::$content->prepare("SELECT id, photo_thumbnail, title FROM ".Database::$db_settings['photo_table']." WHERE id=:id LIMIT 1");
+ $dbr->bindParam(':id', $id, PDO::PARAM_INT);
+ $dbr->execute();
+ $data = $dbr->fetch();
+ if(isset($data['id']))
+ {
+ $thumbnail['id'] = $data['id'];
+ $thumbnail['image'] = $data['photo_thumbnail'];
+ $thumbnail_info = getimagesize(BASE_PATH.MEDIA_DIR.$data['photo_thumbnail']);
+ $thumbnail['width'] = $thumbnail_info[0];
+ $thumbnail['height'] = $thumbnail_info[1];
+ if(isset($img_class))
+ {
+ $thumbnail['class'] = htmlspecialchars($img_class);
+ }
+ $thumbnail['title'] = htmlspecialchars(strip_tags($data['title']));
+ #else $thumbnail = '
';
+ $template->assign('thumbnail', $thumbnail);
+ }
+ $thumbnail = $template->fetch(BASE_PATH.'templates/subtemplates/thumbnail_rss.inc.tpl');
+ return $thumbnail;
+ }
+
+function create_gallery($string)
+ {
+ global $settings, $template;
+ $page = isset($GLOBALS['parent_page']) && $GLOBALS['parent_page'] ? $GLOBALS['parent_page'] : PAGE;
+ $template->assign('contains_thumbnails', true);
+ $template->assign('page', $page);
+ $string = explode('|',$string[1]);
+ $gallery = $string[0];
+ #if(isset($string[1])) $img_class = $string[1];
+
+ $gallery = new Gallery($gallery);
+ if($gallery->photos)
+ {
+ $template->assign('number_of_photos', $gallery->number_of_photos);
+ $template->assign('photos_per_row', $gallery->photos_per_row);
+ $template->assign('photos', $gallery->photos);
+ }
+ #$template->assign('lang', Localization::$lang);
+ $gallery = $template->fetch(BASE_PATH.'cms/templates/subtemplates/gallery.inc.tpl');
+ return $gallery;
+ }
+
+function create_gallery_rss($string)
+ {
+ global $settings, $template;
+ $page = isset($GLOBALS['parent_page']) && $GLOBALS['parent_page'] ? $GLOBALS['parent_page'] : PAGE;
+ $template->assign('contains_thumbnails', true);
+ $template->assign('page', $page);
+ $string = explode('|',$string[1]);
+ $gallery = $string[0];
+ #if(isset($string[1])) $img_class = $string[1];
+
+ $gallery = new Gallery($gallery);
+ if($gallery->photos)
+ {
+ $template->assign('number_of_photos', $gallery->number_of_photos);
+ $template->assign('photos_per_row', $gallery->photos_per_row);
+ $template->assign('photos', $gallery->photos);
+ }
+ $gallery = $template->fetch(BASE_PATH.'cms/templates/subtemplates/gallery_rss.inc.tpl');
+ return $gallery;
+ }
+
+/**
+ * shortens links
+ *
+ * @param string $string
+ * @return string
+ */
+function shorten_link($string)
+ {
+ global $settings;
+ if(is_array($string))
+ {
+ if(count($string) == 2) { $pre = ""; $url = $string[1]; }
+ else { $pre = $string[1]; $url = $string[2]; }
+ $shortened_url = $url;
+ if (strlen($url) > $settings['word_maxlength']) $shortened_url = mb_substr($url, 0, $settings['word_maxlength']-3, CHARSET) . '...';
+ return $pre.''.$shortened_url.'';
+ }
+ }
+
+/**
+ * replaces urls with links
+ *
+ * @param string $string
+ * @return string
+ */
+function make_link($string)
+ {
+ $string = ' ' . $string;
+ $string = preg_replace_callback("#(^|[\n ])([\w]+?://.*?[^ \"\n\r\t<]*)#is", "shorten_link", $string);
+ $string = preg_replace("#(^|[\n ])((www|ftp)\.[\w\-]+\.[\w\-.\~]+(?:/[^ \"\t\n\r<]*)?)#is", "$1$2", $string);
+ #$string = preg_replace("#(^|[\n ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1\\2@\\3", $string);
+ $string = mb_substr($string, 1, mb_strlen($string, CHARSET), CHARSET);
+ return $string;
+ }
+
+function parse_special_tags($string, $parent_page=false, $rss=false)
+ {
+ global $settings;
+ $GLOBALS['parent_page'] = $parent_page;
+ if($settings['content_functions']==1) $string = preg_replace_callback("#\[function:(.+?)\]#is", "content_function", $string);
+ $string = preg_replace_callback("#\[image:(.+?)\]#is", "create_image", $string);
+ if($rss)
+ {
+ $string = preg_replace_callback("#\[thumbnail:(.+?)\]#is", "create_thumbnail_rss", $string);
+ $string = preg_replace_callback("#\[gallery:(.+?)\]#is", "create_gallery_rss", $string);
+ }
+ else
+ {
+ $string = preg_replace_callback("#\[thumbnail:(.+?)\]#is", "create_thumbnail", $string);
+ $string = preg_replace_callback("#\[gallery:(.+?)\]#is", "create_gallery", $string);
+ }
+ $string = preg_replace('/\[\[([^|\]]+?)(?:\|([^\]]+))?\]\]/e', "''.(('\$2')?'\$2':'\$1').''", $string);
+ return $string;
+ }
+
+/*
+function make_link($string)
+ {
+ $string = ' ' . $string;
+ $string = preg_replace("#(^|[\n ])([\w]+?://.*?[^ \"\n\r\t<]*)#is", "\\1\\2", $string);
+ $string = preg_replace("#(^|[\n ])((www|ftp)\.[\w\-]+\.[\w\-.\~]+(?:/[^ \"\t\n\r<]*)?)#is", "\\1\\2", $string);
+ $string = preg_replace("#(^|[\n ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1\\2@\\3", $string);
+ $string = substr($string, 1);
+ return $string;
+ }
+*/
+
+function smilies($string)
+ {
+ global $settings;
+ require BASE_PATH.'cms/config/smilies.conf.php';
+ foreach($smilies as $smiley)
+ {
+ $string = str_replace($smiley[0], '
', $string);
+ }
+ return $string;
+ }
+
+function format_time($format, $timestamp=0)
+ {
+ if($timestamp==0) $timestamp=time();
+ #if($lang['locale_charset']!=$lang['charset'])
+ # {
+ # $formated_time = iconv($lang['locale_charset'],$lang['charset'],strftime($format,$timestamp));
+ # }
+ #else
+ # {
+ $formated_time = strftime($format,$timestamp);
+ # }
+ return $formated_time;
+ }
+
+/**
+ * generates a random string
+ *
+ * @param int $length
+ * @param string $characters
+ * @return string
+ */
+function random_string($length=8,$characters='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789')
+ {
+ $random_string = '';
+ $characters_length = strlen($characters);
+ for($i=0;$i<$length;$i++)
+ {
+ $random_string .= $characters[mt_rand(0, $characters_length - 1)];
+ }
+ return $random_string;
+ }
+
+function is_authorized_to_edit($editor,$editor_type,$author,$edit_permission,$edit_permission_general)
+ {
+ $authorized_users = explode(',',$edit_permission);
+ foreach($authorized_users as $authorized_user)
+ {
+ if(intval($authorized_user)!=0) $cleared_authorized_users[] = $authorized_user;
+ }
+ if($editor_type>0 || $author==$editor || $edit_permission_general==1 || (isset($cleared_authorized_users) && in_array($editor,$cleared_authorized_users)))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+function is_access_denied()
+ {
+ $dbr = Database::$content->query("SELECT name, list FROM ".Database::$db_settings['banlists_table']." WHERE name='ips' OR name='user_agents'");
+ while($data = $dbr->fetch())
+ {
+ if($data['name'] == 'ips') $ips = $data['list'];
+ if($data['name'] == 'user_agents') $user_agents = $data['list'];
+ }
+ if(isset($ips) && trim($ips) != '')
+ {
+ $banned_ips = explode("\n",$ips);
+ if(is_ip_banned($_SERVER['REMOTE_ADDR'], $banned_ips)) return true;
+ }
+ if(isset($user_agents) && trim($user_agents) != '')
+ {
+ $banned_user_agents = explode("\n",$user_agents);
+ if(is_user_agent_banned($_SERVER['HTTP_USER_AGENT'], $banned_user_agents)) return true;
+ }
+ return false;
+ }
+
+/**
+ * checks if the IP of the user is banned
+ *
+ * @author Nico Hoffmann
+ * @param string $ip
+ * @param array $banned_ips
+ * @reurn bool
+ */
+function is_ip_banned($ip, $banned_ips)
+ {
+ foreach($banned_ips as $banned_ip) // go through every $banned_ip
+ {
+ if(strpos($banned_ip,'*')!==false) // $banned_ip contains "*" = > IP range
+ {
+ $ip_range = substr($banned_ip, 0, strpos($banned_ip, '*')); // fetch part before "*"
+ if(strpos($ip, $ip_range)===0) // check if IP begins with part before "*"
+ {
+ return true;
+ }
+ }
+ elseif(strpos($banned_ip,'/')!==false && preg_match("/(([0-9]{1,3}\.){3}[0-9]{1,3})\/([0-9]{1,2})/", $banned_ip, $regs)) // $banned_ip contains "/" => CIDR notation (the regular expression is only used if $banned_ip contains "/")
+ {
+ // convert IP into bit pattern:
+ $n_user_leiste = '00000000000000000000000000000000'; // 32 bits
+ $n_user_ip = explode('.',trim($ip));
+ for ($i = 0; $i <= 3; $i++) // go through every byte
+ {
+ for ($n_j = 0; $n_j < 8; $n_j++) // ... check every bit
+ {
+ if($n_user_ip[$i] >= pow(2, 7-$n_j)) // set to 1 if necessary
+ {
+ $n_user_ip[$i] = $n_user_ip[$i] - pow(2, 7-$n_j);
+ $n_user_leiste[$n_j + $i*8] = '1';
+ }
+ }
+ }
+ // analyze prefix length:
+ $n_byte_array = explode('.',trim($regs[1])); // IP -> 4 Byte
+ $n_cidr_bereich = $regs[3]; // prefix length
+ // bit pattern:
+ $n_bitleiste = '00000000000000000000000000000000';
+ for ($i = 0; $i <= 3; $i++) // go through every byte
+ {
+ if ($n_byte_array[$i] > 255) // invalid
+ {
+ $n_cidr_bereich = 0;
+ }
+ for ($n_j = 0; $n_j < 8; $n_j++) // ... check every bit
+ {
+ if($n_byte_array[$i] >= pow(2, 7-$n_j)) // set to 1 if necessary
+ {
+ $n_byte_array[$i] = $n_byte_array[$i] - pow(2, 7-$n_j);
+ $n_bitleiste[$n_j + $i*8] = '1';
+ }
+ }
+ }
+ // check if bit patterns match on the first n chracters:
+ if (strncmp($n_bitleiste, $n_user_leiste, $n_cidr_bereich) == 0 && $n_cidr_bereich > 0)
+ {
+ return true;
+ }
+ }
+ else // neither "*" nor "/" => simple comparison:
+ {
+ if($ip == $banned_ip)
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+/**
+ * checks if the user agent is banned
+ *
+ * @param array $banned_user_agents
+ * @reurn bool
+ */
+function is_user_agent_banned($user_agent, $banned_user_agents)
+ {
+ foreach($banned_user_agents as $banned_user_agent)
+ {
+ #if(strpos(strtolower($user_agent),strtolower($banned_user_agent))!==false) // case insensitive
+ #if($banned_user_agent!='' && (preg_match("/".$banned_user_agent."/i",$user_agent))) // case insensitive
+ if(strpos($user_agent,$banned_user_agent)!==false) // case sensitive, faster
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+/**
+ * searches for banned words
+ *
+ * @param string $string
+ * @reurn mixed
+ */
+function get_not_accepted_words($string)
+ {
+ #global $db_settings, $pdo;
+ // check for not accepted words:
+ $dbr = Database::$content->query("SELECT list FROM ".Database::$db_settings['banlists_table']." WHERE name = 'words' LIMIT 1");
+ $data = $dbr->fetch();
+ if(isset($data['list']) && trim($data['list']) != '')
+ {
+ $not_accepted_words = explode("\n",$data['list']);
+ foreach($not_accepted_words as $not_accepted_word)
+ {
+ #if($not_accepted_word!='' && (preg_match("/".$not_accepted_word."/i",$name) || preg_match("/".$not_accepted_word."/i",$text) || preg_match("/".$not_accepted_word."/i",$subject) || preg_match("/".$not_accepted_word."/i",$email) || preg_match("/".$not_accepted_word."/i",$hp) || preg_match("/".$not_accepted_word."/i",$location)))
+ if($not_accepted_word!='' && mb_strpos($string, mb_strtolower($not_accepted_word, CHARSET), 0, CHARSET)!==false)
+ {
+ $found_not_accepted_words[] = $not_accepted_word;
+ }
+ }
+ }
+ if(isset($found_not_accepted_words))
+ {
+ return $found_not_accepted_words;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+/**
+ * add "http://" to url if given without protocol
+ *
+ * @param string $url
+ * @return string
+ */
+function add_http_if_no_protocol($url)
+ {
+ if(mb_substr($url,0,7,CHARSET) != 'http://' && mb_substr($url,0,8,CHARSET) != 'https://' && mb_substr($url,0,6,CHARSET) != 'ftp://' && mb_substr($url,0,9,CHARSET) != 'gopher://' && mb_substr($url,0,7,CHARSET) != 'news://')
+ {
+ $url = 'http://'.$url;
+ }
+ return $url;
+ }
+
+/**
+ * checks strings for too long words
+ */
+function too_long_words($text,$word_maxlength)
+ {
+ $text = preg_replace("/\015\012|\015|\012/", "\n", $text);
+ $text = str_replace("\n", ' ', $text);
+ $words = explode(' ',$text);
+ foreach($words as $word)
+ {
+ $length = mb_strlen(trim($word), CHARSET);
+ if($length > $word_maxlength)
+ {
+ $too_long_words[] = $word;
+ }
+ }
+ if(isset($too_long_words))
+ {
+ return $too_long_words;
+ }
+ return false;
+ }
+
+/**
+ * returns an array for the page navigation
+ *
+ * @param int $page_count : number of pages
+ * @param int $page : current page
+ * @param int $browse_range
+ * @param int $page
+ * @param int $show_last
+ * @return array
+ */
+function pagination($page_count,$page,$browse_range=3,$show_last=true)
+ {
+ if($page_count>1)
+ {
+ $xpagination['current'] = $page;
+ if($page_count > $page)
+ {
+ $xpagination['next'] = $page+1;
+ }
+ else
+ {
+ $xpagination['next'] = 0;
+ }
+ if($page > 1)
+ {
+ $xpagination['previous'] = $page-1;
+ }
+ else
+ {
+ $xpagination['previous'] = 0;
+ }
+ $xpagination['items'][] = 1;
+ if ($page > $browse_range+1) $xpagination['items'][] = 0;
+ $n_range = $page-($browse_range-1);
+ $p_range = $page+$browse_range;
+ for($page_browse=$n_range; $page_browse<$p_range; $page_browse++)
+ {
+ if($page_browse > 1 && $page_browse <= $page_count) $xpagination['items'][] = $page_browse;
+ }
+ if($show_last)
+ {
+ if($page < $page_count-($browse_range)) $xpagination['items'][] = 0;
+ if(!in_array($page_count,$xpagination['items'])) $xpagination['items'][] = $page_count;
+ }
+ return $xpagination;
+ }
+ return false;
+ }
+
+function truncate($string, $maxlength, $cut_string='…')
+ {
+ if(mb_strlen($string) <= $maxlength) return $string;
+ $space_pos = mb_strrpos($string, ' ', -(mb_strlen($string) - $maxlength));
+ if($space_pos!==false)
+ {
+ return mb_substr($string, 0, $space_pos) . ' '.$cut_string;
+ }
+ else
+ {
+ return mb_substr($string, 0, $maxlength) . $cut_string;
+ }
+ }
+
+function mailto($email, $alternative_text)
+ {
+ #$string = 'document.write(\''.$email.'\')';
+ $uid = 'uid'.uniqid();
+ $string = 'document.getElementById(\''.$uid.'\').innerHTML=\''.$email.'\'';
+ $ret = '';
+ $arr = unpack("C*", $string);
+ foreach ($arr as $char)
+ {
+ $ret .= sprintf("%%%X", $char);
+ }
+ return ''.$alternative_text.'';
+}
+
+/**
+ * sends a status code, displays an error message and halts the script
+ *
+ * @param string $status_code
+ */
+function raise_error($error,$error_message='')
+ {
+ global $settings, $localization;
+
+ $website_title = isset($settings['website_title']) ? $settings['website_title'] : 'phpSQLiteCMS';
+ $lang = isset($localization) ? Localization::$lang['lang'] : 'en';
+ $charset = isset($localization) ? Localization::$lang['charset'] : 'utf-8';
+
+ if(empty($lang['language'])) $lang['language'] ='en';
+ if(empty($lang['charset'])) $lang['charset'] ='utf-8';
+ if(empty($settings['website_title'])) $settings['website_title'] = 'phpSQLiteCMS';
+
+ $title = 'Error';
+ $message = '';
+ switch($error)
+ {
+ case '403':
+ header($_SERVER['SERVER_PROTOCOL'] . " 403 Forbidden");
+ header("Status: 403 Forbidden");
+ $title = '403 Forbidden';
+ $message = 'You don\'t have permission to access this page.';
+ break;
+ case '404':
+ header($_SERVER['SERVER_PROTOCOL'] . " 404 Not Found");
+ header("Status: 404 Not Found");
+ $title = '404 Not Found';
+ $message = 'The requested URL was not found on this server.';
+ break;
+ default:
+ header($_SERVER['SERVER_PROTOCOL'] . " 503 Service Unavailable");
+ header("Status: 503 Service Unavailable");
+ $title = '503 Service Temporarily Unavailable';
+ $message = 'The server is currently unable to handle the request.';
+ if($error_message!='') $message = $error_message;
+ else $message = 'The server is currently unable to handle the request.';
+ break;
+ }
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/cms/includes/functions.mb_replacements.inc.php b/cms/includes/functions.mb_replacements.inc.php
new file mode 100644
index 0000000..e32d111
--- /dev/null
+++ b/cms/includes/functions.mb_replacements.inc.php
@@ -0,0 +1,45 @@
+
diff --git a/cms/includes/galleries.inc.php b/cms/includes/galleries.inc.php
new file mode 100644
index 0000000..119ac35
--- /dev/null
+++ b/cms/includes/galleries.inc.php
@@ -0,0 +1,443 @@
+prepare("SELECT id, gallery, sequence, photo_normal, photo_thumbnail, title, subtitle, description, description_formatting FROM ".Database::$db_settings['photo_table']." WHERE gallery=:gallery ORDER BY sequence ASC");
+ $dbr->bindParam(':gallery', $_GET['edit'], PDO::PARAM_STR);
+ $dbr->execute();
+ $i=0;
+ while($data = $dbr->fetch())
+ {
+ $items[$i]['id'] = $data['id'];
+ $items[$i]['gallery'] = $data['gallery'];
+ $items[$i]['sequence'] = $data['sequence'];
+ $items[$i]['photo_normal'] = $data['photo_normal'];
+ $items[$i]['photo_thumbnail'] = $data['photo_thumbnail'];
+ #$items[$i]['photo_large'] = $data['photo_large'];
+ $items[$i]['title'] = $data['title'];
+ $items[$i]['subtitle'] = $data['subtitle'];
+ $items[$i]['description'] = $data['description'];
+ #$items[$i]['description_formatting'] = $data['description_formatting'];
+ #if(mb_strlen($item['description'],CHARSET) > 300) $description = mb_substr($item['description'],0,297,CHARSET)."..."; else $description = $item['description'];
+ if($data['description_formatting']==1)
+ {
+ $items[$i]['description'] = auto_html($data['description']);
+ }
+ else
+ {
+ $items[$i]['description'] = $data['description'];
+ }
+ ++$i;
+ }
+ if(isset($items))
+ {
+ $template->assign('items',$items);
+ }
+ $template->assign('gallery',htmlspecialchars($_GET['edit']));
+ $action = 'edit';
+ }
+
+ if(isset($_GET['new_photo']))
+ {
+ $photo_data['gallery'] = htmlspecialchars($_GET['new_photo']);
+ $photo_data['description_formatting'] = 1;
+ $template->assign('photo_data',$photo_data);
+ $action = 'edit_photo';
+ }
+
+ if(isset($_GET['edit_photo']))
+ {
+ $dbr = Database::$content->prepare("SELECT id, gallery, photo_thumbnail, photo_normal, width, height, large_width, large_height, title, subtitle, description, description_formatting FROM ".Database::$db_settings['photo_table']." WHERE id=:id LIMIT 1");
+ $dbr->bindParam(':id', $_GET['edit_photo'], PDO::PARAM_INT);
+ $dbr->execute();
+ $data = $dbr->fetch();
+ if(isset($data['id']))
+ {
+ $photo_data['id'] = intval($data['id']);
+ $photo_data['gallery'] = htmlspecialchars($data['gallery']);
+ $photo_data['photo_thumbnail'] = htmlspecialchars($data['photo_thumbnail']);
+ $photo_data['photo_normal'] = htmlspecialchars($data['photo_normal']);
+ #$photo_data['photo_large'] = htmlspecialchars($data['photo_large']);
+ $photo_data['width'] = $data['width']>0 ? $data['width'] : '';
+ $photo_data['height'] = $data['height']>0 ? $data['height'] : '';
+ $photo_data['large_width'] = $data['large_width']>0 ? $data['large_width'] : '';
+ $photo_data['large_height'] = $data['large_height']>0 ? $data['large_height'] : '';
+ $photo_data['title'] = htmlspecialchars($data['title']);
+ $photo_data['subtitle'] = htmlspecialchars($data['subtitle']);
+ $photo_data['description'] = htmlspecialchars($data['description']);
+ $photo_data['description_formatting'] = intval($data['description_formatting']);
+ $template->assign('photo_data', $photo_data);
+ }
+ else
+ {
+ $template->assign('invalid_photo', true);
+ }
+ $action = 'edit_photo';
+ }
+
+ if(isset($_REQUEST['delete_gallery']))
+ {
+ if(isset($_REQUEST['confirmed']))
+ {
+ // get photo ids:
+ $dbr = Database::$content->prepare("SELECT id FROM ".Database::$db_settings['photo_table']." WHERE gallery=:gallery");
+ $dbr->bindValue(':gallery', trim($_REQUEST['delete_gallery']), PDO::PARAM_STR);
+ $dbr->execute();
+ // delete comments:
+ $dbr2 = Database::$entries->prepare("DELETE FROM ".Database::$db_settings['comment_table']." WHERE comment_id=:id AND type=1");
+ $dbr2->bindParam(':id', $data['id'], PDO::PARAM_INT);
+ Database::$entries->beginTransaction();
+ while($data = $dbr->fetch())
+ {
+ $dbr2->execute();
+ }
+ Database::$entries->commit();
+ // delete gallery:
+ $dbr = Database::$content->prepare("DELETE FROM ".Database::$db_settings['photo_table']." WHERE gallery=:gallery");
+ $dbr->bindParam(':gallery', $_REQUEST['delete_gallery'], PDO::PARAM_STR);
+ $dbr->execute();
+ if(isset($cache) && $cache->autoClear) $cache->clear();
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=galleries');
+ exit;
+ }
+ else
+ {
+ $template->assign('gallery',htmlspecialchars($_REQUEST['delete_gallery']));
+ $action = 'delete_gallery';
+ }
+ }
+
+ if(isset($_POST['new_gallery_name']))
+ {
+ $dbr = Database::$content->prepare("SELECT COUNT(*) FROM ".Database::$db_settings['photo_table']." WHERE lower(gallery)=:gallery");
+ $dbr->bindValue(':gallery', strtolower($_POST['new_gallery_name']), PDO::PARAM_STR);
+ $dbr->execute();
+ $gallery_count = $dbr-> fetchColumn();
+ if($gallery_count > 0)
+ {
+ $errors[] = 'gallery_name_alr_exists';
+ }
+ elseif(!preg_match(VALID_URL_CHARACTERS, $_POST['new_gallery_name']))
+ {
+ $errors[] = 'error_gallery_spec_chars';
+ }
+ if(empty($errors))
+ {
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=galleries&edit='.trim($_POST['new_gallery_name']));
+ exit;
+ }
+ else
+ {
+ $template->assign('errors', $errors);
+ $template->assign('new_gallery_name', htmlspecialchars($_POST['new_gallery_name']));
+ $action = 'new';
+ }
+ }
+
+ if(isset($_GET['move_up_photo']))
+ {
+ $dbr = Database::$content->prepare("SELECT gallery, sequence FROM ".Database::$db_settings['photo_table']." WHERE id=:id LIMIT 1");
+ $dbr->bindParam(':id', $_GET['move_up_photo'], PDO::PARAM_INT);
+ $dbr->execute();
+ $data = $dbr->fetch();
+ if(isset($data['sequence']) && $data['sequence'] > 1)
+ {
+ Database::$content->beginTransaction();
+ $dbr = Database::$content->prepare("UPDATE ".Database::$db_settings['photo_table']." SET sequence=:new_sequence WHERE gallery=:gallery AND sequence=:sequence");
+ $dbr->bindParam(':gallery', $data['gallery'], PDO::PARAM_STR);
+ $dbr->bindValue(':new_sequence', 0, PDO::PARAM_INT);
+ $dbr->bindValue(':sequence', $data['sequence']-1, PDO::PARAM_INT);
+ $dbr->execute();
+ $dbr->bindValue(':new_sequence', $data['sequence']-1, PDO::PARAM_INT);
+ $dbr->bindValue(':sequence', $data['sequence'], PDO::PARAM_INT);
+ $dbr->execute();
+ $dbr->bindValue(':new_sequence', $data['sequence'], PDO::PARAM_INT);
+ $dbr->bindValue(':sequence', 0, PDO::PARAM_INT);
+ $dbr->execute();
+ Database::$content->commit();
+ }
+ if(isset($cache) && $cache->autoClear) $cache->clear();
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=galleries&edit='.$data['gallery']);
+ exit;
+ }
+
+ if(isset($_GET['move_down_photo']))
+ {
+ $dbr = Database::$content->prepare("SELECT gallery, sequence FROM ".Database::$db_settings['photo_table']." WHERE id=:id LIMIT 1");
+ $dbr->bindParam(':id', $_GET['move_down_photo'], PDO::PARAM_INT);
+ $dbr->execute();
+ $data = $dbr->fetch();
+ if(isset($data['sequence']))
+ {
+ $dbr = Database::$content->prepare("SELECT sequence FROM ".Database::$db_settings['photo_table']." WHERE gallery=:gallery ORDER BY sequence DESC LIMIT 1");
+ $dbr->bindParam(':gallery', $data['gallery'], PDO::PARAM_STR);
+ $dbr->execute();
+ $last = $dbr->fetchColumn();
+ if($data['sequence'] < $last)
+ {
+ Database::$content->beginTransaction();
+ $dbr = Database::$content->prepare("UPDATE ".Database::$db_settings['photo_table']." SET sequence=:new_sequence WHERE gallery=:gallery AND sequence=:sequence");
+ $dbr->bindParam(':gallery', $data['gallery'], PDO::PARAM_STR);
+ $dbr->bindValue(':new_sequence', 0, PDO::PARAM_INT);
+ $dbr->bindValue(':sequence', $data['sequence']+1, PDO::PARAM_INT);
+ $dbr->execute();
+ $dbr->bindValue(':new_sequence', $data['sequence']+1, PDO::PARAM_INT);
+ $dbr->bindValue(':sequence', $data['sequence'], PDO::PARAM_INT);
+ $dbr->execute();
+ $dbr->bindValue(':new_sequence', $data['sequence'], PDO::PARAM_INT);
+ $dbr->bindValue(':sequence', 0, PDO::PARAM_INT);
+ $dbr->execute();
+ Database::$content->commit();
+ }
+ if(isset($cache) && $cache->autoClear) $cache->clear();
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=galleries&edit='.$data['gallery']);
+ exit;
+ }
+ }
+
+ if(isset($_REQUEST['reorder_photos']) && isset($_REQUEST['item']))
+ {
+ $dbr = Database::$content->prepare("UPDATE ".Database::$db_settings['photo_table']." SET sequence=:sequence WHERE id=:id");
+ $dbr->bindParam(':id', $id, PDO::PARAM_INT);
+ $dbr->bindParam(':sequence', $sequence, PDO::PARAM_INT);
+ Database::$content->beginTransaction();
+ $sequence = 1;
+ foreach($_REQUEST['item'] as $id)
+ {
+ $dbr->execute();
+ ++$sequence;
+ }
+ Database::$content->commit();
+ if(isset($cache) && $cache->autoClear) $cache->clear();
+ exit;
+ }
+
+ if(isset($_POST['edit_photo_submitted']))
+ {
+ // get posted data:
+ $gallery = isset($_POST['gallery']) ? trim($_POST['gallery']) : '';
+ $photo_thumbnail = isset($_POST['photo_thumbnail']) ? trim($_POST['photo_thumbnail']) : '';
+ $photo_normal = isset($_POST['photo_normal']) ? trim($_POST['photo_normal']) : '';
+ #$photo_large = isset($_POST['photo_large']) ? trim($_POST['photo_large']) : '';
+ $width = isset($_POST['width']) ? intval($_POST['width']) : 0;
+ $height = isset($_POST['height']) ? intval($_POST['height']) : 0;
+ $large_width = isset($_POST['large_width']) ? intval($_POST['large_width']) : 0;
+ $large_height = isset($_POST['large_height']) ? intval($_POST['large_height']) : 0;
+ $title = isset($_POST['title']) ? trim($_POST['title']) : '';
+ $subtitle = isset($_POST['subtitle']) ? trim($_POST['subtitle']) : '';
+ $description = isset($_POST['description']) ? trim($_POST['description']) : '';
+ $description_formatting = isset($_POST['description_formatting']) && $_POST['description_formatting']==1 ? 1 : 0;
+ #showme($description_formatting);
+ // check data:
+ if(empty($gallery)) $errors[] = 'error_no_gallery';
+ if(empty($photo_thumbnail)) $errors[] = 'error_no_thumbnail';
+ if(empty($photo_normal)) $errors[] = 'error_no_photo';
+ if(empty($title)) $errors[] = 'error_no_photo_title';
+
+ if(empty($errors))
+ {
+ if(!file_exists(BASE_PATH.MEDIA_DIR.$photo_thumbnail))
+ {
+ $errors[] = 'err_photo_t_doesnt_exist';
+ }
+ if(substr(strtolower($photo_thumbnail), -4) != '.jpg' && substr(strtolower($photo_thumbnail), -5)!= '.jpeg' && substr(strtolower($photo_thumbnail), -4)!= '.gif' && substr(strtolower($photo_thumbnail), -4)!= '.png')
+ {
+ $errors[] = 'err_image_type';
+ }
+ if(!file_exists(BASE_PATH.MEDIA_DIR.$photo_normal))
+ {
+ $errors[] = 'err_photo_n_doesnt_exist';
+ }
+ #if(trim($_POST['photo_large']) !='' && !file_exists(BASE_PATH.MEDIA_DIR.$photo_large))
+ # {
+ # $errors[] = 'err_photo_l_doesnt_exist';
+ # }
+ }
+
+ if(empty($errors))
+ {
+ if(isset($_POST['id']))
+ {
+ $dbr = Database::$content->prepare("UPDATE ".Database::$db_settings['photo_table']." SET photo_thumbnail=:photo_thumbnail, photo_normal=:photo_normal, width=:width, height=:height, large_width=:large_width, large_height=:large_height, title=:title, subtitle=:subtitle, description=:description, description_formatting=:description_formatting WHERE id=:id");
+ $dbr->bindParam(':photo_thumbnail', $photo_thumbnail, PDO::PARAM_STR);
+ $dbr->bindParam(':photo_normal', $photo_normal, PDO::PARAM_STR);
+ #$dbr->bindParam(':photo_large', $photo_large, PDO::PARAM_STR);
+ $dbr->bindParam(':width', $width, PDO::PARAM_INT);
+ $dbr->bindParam(':height', $height, PDO::PARAM_INT);
+ $dbr->bindParam(':large_width', $large_width, PDO::PARAM_INT);
+ $dbr->bindParam(':large_height', $large_height, PDO::PARAM_INT);
+ $dbr->bindParam(':title', $title, PDO::PARAM_STR);
+ $dbr->bindParam(':subtitle', $subtitle, PDO::PARAM_STR);
+ $dbr->bindParam(':description', $description, PDO::PARAM_STR);
+ $dbr->bindParam(':description_formatting', $description_formatting, PDO::PARAM_INT);
+ $dbr->bindParam(':id', $_POST['id'], PDO::PARAM_INT);
+ $dbr->execute();
+ }
+ else
+ {
+ // get gallery info and latest order nr.:
+ $dbr = Database::$content->prepare("SELECT sequence,template,photos_per_row FROM ".Database::$db_settings['photo_table']." WHERE gallery=:gallery ORDER BY sequence DESC LIMIT 1");
+ $dbr->bindParam(':gallery', $gallery, PDO::PARAM_STR);
+ $dbr->execute();
+ $data = $dbr->fetch();
+ if(isset($data['sequence']))
+ {
+ $new_sequence = intval($data['sequence'])+1;
+ $template = $data['template'];
+ $photos_per_row = $data['photos_per_row'];
+ }
+ else
+ {
+ $new_sequence = 1;
+ $template = $settings['default_photo_template'];
+ $photos_per_row = $settings['default_photos_per_row'];
+ }
+ // insert photo:
+ $dbr = Database::$content->prepare("INSERT INTO ".Database::$db_settings['photo_table']." (gallery,sequence,photo_thumbnail,photo_normal,width,height,large_width,large_height,title,subtitle,description,description_formatting,template,photos_per_row) VALUES (:gallery, :sequence, :photo_thumbnail, :photo_normal, :width, :height, :large_width, :large_height, :title, :subtitle, :description, :description_formatting, :template, :photos_per_row)");
+ $dbr->bindParam(':gallery', $gallery, PDO::PARAM_STR);
+ $dbr->bindParam(':sequence', $new_sequence, PDO::PARAM_INT);
+ $dbr->bindParam(':photo_thumbnail', $photo_thumbnail, PDO::PARAM_STR);
+ $dbr->bindParam(':photo_normal', $photo_normal, PDO::PARAM_STR);
+ #$dbr->bindParam(':photo_large', $photo_large, PDO::PARAM_STR);
+ $dbr->bindParam(':width', $width, PDO::PARAM_INT);
+ $dbr->bindParam(':height', $height, PDO::PARAM_INT);
+ $dbr->bindParam(':large_width', $large_width, PDO::PARAM_INT);
+ $dbr->bindParam(':large_height', $large_height, PDO::PARAM_INT);
+ $dbr->bindParam(':title', $title, PDO::PARAM_STR);
+ $dbr->bindParam(':subtitle', $subtitle, PDO::PARAM_STR);
+ $dbr->bindParam(':description', $description, PDO::PARAM_STR);
+ $dbr->bindParam(':description_formatting', $description_formatting, PDO::PARAM_INT);
+ $dbr->bindParam(':template', $template, PDO::PARAM_STR);
+ $dbr->bindParam(':photos_per_row', $photos_per_row, PDO::PARAM_INT);
+ $dbr->execute();
+ }
+ if(isset($cache) && $cache->autoClear) $cache->clear();
+ $id = isset($_POST['id']) ? $_POST['id'] : Database::$content->lastInsertId();
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=galleries&edit='.$gallery.'#id_'.$id);
+ exit;
+ }
+ else
+ {
+ if(isset($_POST['id'])) $photo_data['id'] = intval($_POST['id']);
+ $photo_data['gallery'] = isset($_POST['gallery']) ? htmlspecialchars($_POST['gallery']) : '';
+ $photo_data['photo_thumbnail'] = isset($_POST['photo_thumbnail']) ? htmlspecialchars($_POST['photo_thumbnail']) : '';
+ $photo_data['photo_normal'] = isset($_POST['photo_normal']) ? htmlspecialchars($_POST['photo_normal']) : '';
+ #$photo_data['photo_large'] = isset($_POST['photo_large']) ? htmlspecialchars($_POST['photo_large']) : '';
+ $photo_data['width'] = isset($_POST['width']) && $_POST['width'] > 0 ? intval($_POST['width']) : '';
+ $photo_data['height'] = isset($_POST['height']) && $_POST['height'] > 0 ? intval($_POST['height']) : '';
+ $photo_data['large_width'] = isset($_POST['large_width']) && $_POST['large_width'] > 0 ? intval($_POST['large_width']) : '';
+ $photo_data['large_height'] = isset($_POST['large_height']) && $_POST['large_height'] > 0 ? intval($_POST['large_height']) : '';
+ $photo_data['title'] = isset($_POST['title']) ? htmlspecialchars($_POST['title']) : '';
+ $photo_data['subtitle'] = isset($_POST['subtitle']) ? htmlspecialchars($_POST['subtitle']) : '';
+ $photo_data['description'] = isset($_POST['description']) ? htmlspecialchars($_POST['description']) : '';
+ $photo_data['description_formatting'] = isset($_POST['description_formatting']) && $_POST['description_formatting']==1 ? 1 : 0;
+ $template->assign('errors',$errors);
+ $template->assign('photo_data',$photo_data);
+ $action='edit_photo';
+ }
+ }
+
+ if(isset($_GET['delete_photo']))
+ {
+ // get gallery:
+ $dbr = Database::$content->prepare("SELECT gallery FROM ".Database::$db_settings['photo_table']." WHERE id=:id LIMIT 1");
+ $dbr->bindParam(':id', $_GET['delete_photo'], PDO::PARAM_INT);
+ $dbr->execute();
+ $gallery = $dbr->fetchColumn();
+ // delete photo:
+ $dbr = Database::$content->prepare("DELETE FROM ".Database::$db_settings['photo_table']." WHERE id=:id");
+ $dbr->bindParam(':id', $_GET['delete_photo'], PDO::PARAM_INT);
+ $dbr->execute();
+ // delete photo comments:
+ $dbr = Database::$entries->prepare("DELETE FROM ".Database::$db_settings['comment_table']." WHERE type=1 AND comment_id=:id");
+ $dbr->bindParam(':id', $_GET['delete_photo'], PDO::PARAM_INT);
+ $dbr->execute();
+ // reorder photos:
+ $dbr = Database::$content->prepare("SELECT id FROM ".Database::$db_settings['photo_table']." WHERE gallery=:gallery ORDER BY sequence ASC");
+ $dbr->bindParam(':gallery', $gallery, PDO::PARAM_STR);
+ $dbr->execute();
+ while($data = $dbr->fetch())
+ {
+ $ids[] = $data['id'];
+ }
+ if(isset($ids))
+ {
+ $new_sequence = 1;
+ Database::$content->beginTransaction();
+ $dbr = Database::$content->prepare("UPDATE ".Database::$db_settings['photo_table']." SET sequence=:sequence where id=:id");
+ $dbr->bindParam(':sequence', $new_sequence, PDO::PARAM_INT);
+ $dbr->bindParam(':id', $id, PDO::PARAM_INT);
+ foreach($ids as $id)
+ {
+ $dbr->execute();
+ ++$new_sequence;
+ }
+ Database::$content->commit();
+ }
+ if(isset($cache) && $cache->autoClear) $cache->clear();
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=galleries&edit='.$gallery);
+ exit;
+ }
+
+ if(isset($_POST['gallery_properties_submit']))
+ {
+ $template = isset($_POST['template']) ? trim($_POST['template']) : $settings['default_photo_template'];
+ $photos_per_row = isset($_POST['photos_per_row']) ? intval($_POST['photos_per_row']) : $settings['default_photos_per_row'];
+ $gallery = isset($_POST['gallery']) ? trim($_POST['gallery']) : '';
+ if(!empty($gallery))
+ {
+ $dbr = Database::$content->prepare("UPDATE ".Database::$db_settings['photo_table']." SET template=:template, photos_per_row=:photos_per_row WHERE gallery=:gallery");
+ $dbr->bindParam(':template', $template, PDO::PARAM_STR);
+ $dbr->bindParam(':photos_per_row', $photos_per_row, PDO::PARAM_INT);
+ $dbr->bindParam(':gallery', $gallery, PDO::PARAM_STR);
+ $dbr->execute();
+ if(isset($cache) && $cache->autoClear) $cache->clear();
+ }
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=galleries&edit='.htmlspecialchars($_POST['gallery']));
+ exit;
+ }
+
+ if(isset($_GET['action'])) $action = $_GET['action'];
+ if(isset($_POST['action'])) $action = $_POST['action'];
+ if(empty($action)) $action='show_galleries';
+
+ switch($action)
+ {
+ case 'show_galleries':
+ $dbr = Database::$content->query("SELECT DISTINCT gallery FROM ".Database::$db_settings['photo_table']." ORDER BY gallery ASC");
+ while($data = $dbr->fetch())
+ {
+ $galleries[] = htmlspecialchars($data['gallery']);
+ }
+ if(isset($galleries))
+ {
+ $template->assign('galleries',$galleries);
+ }
+ $template->assign('subtitle', Localization::$lang['photo_galleries']);
+ $template->assign('subtemplate', 'galleries.inc.tpl');
+ break;
+ case 'edit':
+ $template->assign('subtitle', Localization::$lang['photo_galleries']);
+ $template->assign('subtemplate','galleries_edit.inc.tpl');
+ break;
+ case 'delete_gallery':
+ $template->assign('subtitle', Localization::$lang['delete_gallery']);
+ $template->assign('subtemplate','galleries_delete.inc.tpl');
+ break;
+ case 'new':
+ $template->assign('subtitle', Localization::$lang['photo_galleries']);
+ $template->assign('subtemplate','galleries_new.inc.tpl');
+ break;
+ case 'gallery_properties':
+ $template->assign('subtitle', Localization::$lang['photo_galleries']);
+ $template->assign('subtemplate','galleries_properties.inc.tpl');
+ break;
+ case 'edit_photo':
+ $template->assign('subtitle', Localization::$lang['photo_galleries']);
+ $template->assign('subtemplate','galleries_edit_photo.inc.tpl');
+ break;
+ }
+ }
diff --git a/cms/includes/gcb.inc.php b/cms/includes/gcb.inc.php
new file mode 100644
index 0000000..f7f1c9e
--- /dev/null
+++ b/cms/includes/gcb.inc.php
@@ -0,0 +1,154 @@
+prepare("SELECT COUNT(*) FROM ".Database::$db_settings['gcb_table']." WHERE lower(identifier)=:identifier AND id!=:id");
+ $dbr->bindParam(':id', $_POST['id'], PDO::PARAM_INT);
+ }
+ else
+ {
+ $dbr = Database::$content->prepare("SELECT COUNT(*) FROM ".Database::$db_settings['gcb_table']." WHERE lower(identifier)=:identifier");
+ }
+ $dbr->bindValue(':identifier', mb_strtolower($identifier, CHARSET), PDO::PARAM_STR);
+ $dbr->execute();
+ if($dbr->fetchColumn()!=0)
+ {
+ $errors[] = 'gcb_identifier_exists_error';
+ }
+
+ if(empty($errors))
+ {
+ if(isset($_POST['id']))
+ {
+ $dbr = Database::$content->prepare("UPDATE ".Database::$db_settings['gcb_table']." SET identifier=:identifier, content=:content WHERE id=:id");
+ $dbr->bindParam(':id', $_POST['id'], PDO::PARAM_INT);
+ }
+ else
+ {
+ $dbr = Database::$content->prepare("INSERT INTO ".Database::$db_settings['gcb_table']." (identifier,content) VALUES (:identifier,:content)");
+ }
+ $dbr->bindParam(':identifier', $identifier, PDO::PARAM_STR);
+ $dbr->bindParam(':content', $content, PDO::PARAM_STR);
+ $dbr->execute();
+ if(isset($cache) && $cache->autoClear) $cache->clear();
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=gcb');
+ exit;
+ }
+ else
+ {
+ if(isset($_POST['id'])) $gcb['id'] = $_POST['id'];
+ $gcb['identifier'] = isset($_POST['identifier']) ? htmlspecialchars($_POST['identifier']) : '';
+ $gcb['content'] = isset($_POST['content']) ? htmlspecialchars($_POST['content']) : '';
+ $template->assign('gcb', $gcb);
+ $template->assign('errors', $errors);
+ $action = 'edit_gcb';
+ }
+ }
+
+ if(isset($_GET['edit']))
+ {
+ $dbr = Database::$content->prepare("SELECT id, identifier, content FROM ".Database::$db_settings['gcb_table']." WHERE id=:id LIMIT 1");
+ $dbr->bindParam(':id', $_GET['edit'], PDO::PARAM_INT);
+ $dbr->execute();
+ $data = $dbr->fetch();
+ if(isset($data['id']))
+ {
+ $gcb['id'] = $data['id'];
+ $gcb['identifier'] = htmlspecialchars($data['identifier']);
+ $gcb['content'] = htmlspecialchars($data['content']);
+ $template->assign('gcb', $gcb);
+ $action = 'edit_gcb';
+ }
+ else
+ {
+ $action = 'invalid_request';
+ }
+ }
+
+ if(isset($_REQUEST['delete']))
+ {
+ if(isset($_REQUEST['confirmed']))
+ {
+ $dbr = Database::$content->prepare("DELETE FROM ".Database::$db_settings['gcb_table']." WHERE id=:id");
+ $dbr->bindParam(':id', $_REQUEST['delete'], PDO::PARAM_INT);
+ $dbr->execute();
+ if(isset($cache) && $cache->autoClear) $cache->clear();
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=gcb');
+ exit;
+ }
+ else
+ {
+ $dbr = Database::$content->prepare("SELECT id, identifier FROM ".Database::$db_settings['gcb_table']." WHERE id=:id LIMIT 1");
+ $dbr->bindParam(':id', $_GET['delete'], PDO::PARAM_INT);
+ $dbr->execute();
+ $data = $dbr->fetch();
+ if(isset($data['id']))
+ {
+ $gcb['id'] = $data['id'];
+ $gcb['identifier'] = htmlspecialchars($data['identifier']);
+ $template->assign('gcb', $gcb);
+ $action = 'delete_gcb';
+ }
+ else
+ {
+ $action = 'invalid_request';
+ }
+ }
+ }
+
+ if(isset($_REQUEST['action'])) $action = $_REQUEST['action'];
+ if(empty($action)) $action='main';
+
+ switch ($action)
+ {
+ case 'main':
+ $dbr = Database::$content->query("SELECT id, identifier, content FROM ".Database::$db_settings['gcb_table']." ORDER BY id ASC");
+ $i=0;
+ while($data = $dbr->fetch())
+ {
+ $gcbs[$i]['id'] = $data['id'];
+ $gcbs[$i]['identifier'] = htmlspecialchars($data['identifier']);
+ $gcbs[$i]['content'] = $data['content'];
+ ++$i;
+ }
+ if(isset($gcbs))
+ {
+ $template->assign('gcbs', $gcbs);
+ }
+ $template->assign('subtitle', Localization::$lang['gcb']);
+ $template->assign('subtemplate', 'gcb.inc.tpl');
+ break;
+ case 'edit_gcb':
+ if(isset($gcb['id']))
+ {
+ $template->assign('subtitle', Localization::$lang['edit_gcb']);
+ }
+ else
+ {
+ $template->assign('subtitle', Localization::$lang['add_gcb']);
+ }
+ $template->assign('subtemplate', 'gcb_edit.inc.tpl');
+ break;
+ case 'delete_gcb':
+ $template->assign('subtitle', Localization::$lang['delete_gcb']);
+ $template->assign('subtemplate', 'gcb_delete.inc.tpl');
+ break;
+ }
+ }
diff --git a/cms/includes/insert_gallery.inc.php b/cms/includes/insert_gallery.inc.php
new file mode 100644
index 0000000..bdf137b
--- /dev/null
+++ b/cms/includes/insert_gallery.inc.php
@@ -0,0 +1,17 @@
+query("SELECT DISTINCT gallery FROM ".Database::$db_settings['photo_table']." ORDER BY gallery ASC");
+ while($data = $dbr->fetch())
+ {
+ $galleries[] = htmlspecialchars($data['gallery']);
+ }
+ if(isset($galleries))
+ {
+ $template->assign('galleries',$galleries);
+ }
+ }
+$template_file = 'insert_gallery.tpl';
+?>
diff --git a/cms/includes/insert_image.inc.php b/cms/includes/insert_image.inc.php
new file mode 100644
index 0000000..2ffbc69
--- /dev/null
+++ b/cms/includes/insert_image.inc.php
@@ -0,0 +1,55 @@
+assign('form',htmlspecialchars($_REQUEST['form']));
+ }
+ if(isset($_REQUEST['field']))
+ {
+ $template->assign('field',htmlspecialchars($_REQUEST['field']));
+ }
+
+ $insert_mode = isset($_REQUEST['insert_mode']) && $_REQUEST['insert_mode']==1 ? 1 : 0;
+ $template->assign('insert_mode',$insert_mode);
+
+ $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'main';
+
+ switch($action)
+ {
+ case 'main':
+ $fp=opendir($img_path);
+ while($file = readdir($fp))
+ {
+ if(preg_match('/\.jpg$/i', $file) || preg_match('/\.jpeg$/i', $file) || preg_match('/\.png$/i', $file) || preg_match('/\.gif$/i', $file) || ($insert_mode==1 && preg_match('/\.swf$/i', $file)) || ($insert_mode==1 && preg_match('/\.flv$/i', $file)))
+ {
+ $images[] = $file;
+ }
+ }
+ closedir($fp);
+
+ if(isset($images))
+ {
+ // Sort filenames
+ natcasesort($images);
+ $template->assign('images', $images);
+
+ $image_classes_untrimmed = explode(',',$settings['image_classes']);
+ foreach($image_classes_untrimmed as $image_class)
+ {
+ $image_classes[] = trim($image_class);
+ }
+ if(isset($image_classes))
+ {
+ $template->assign('image_classes',$image_classes);
+ }
+ }
+ }
+
+ $template_file = 'insert_image.tpl';
+ }
+?>
diff --git a/cms/includes/insert_thumbnail.inc.php b/cms/includes/insert_thumbnail.inc.php
new file mode 100644
index 0000000..b3b953f
--- /dev/null
+++ b/cms/includes/insert_thumbnail.inc.php
@@ -0,0 +1,71 @@
+assign('form',htmlspecialchars($_REQUEST['form']));
+ }
+ if(isset($_REQUEST['field']))
+ {
+ $template->assign('field',htmlspecialchars($_REQUEST['field']));
+ }
+
+ #if(isset($_GET['form'])) $form = $_GET['form'];
+ #if(isset($_GET['field'])) $field = $_GET['field'];
+ #if(isset($_GET['insert_mode'])) $insert_mode = intval($_GET['insert_mode']);
+ #if(isset($_POST['form'])) $form = $_POST['form'];
+ #if(isset($_POST['field'])) $field = $_POST['field'];
+ #if(isset($_POST['insert_mode'])) $insert_mode = intval($_POST['insert_mode']);
+ #if(empty($insert_mode)) $insert_mode = $insert_mode = 0;
+
+ if(isset($_POST['gallery']))
+ {
+ $dbr = Database::$content->prepare("SELECT id, title, photo_thumbnail FROM ".Database::$db_settings['photo_table']." WHERE gallery=:gallery ORDER BY sequence ASC");
+ $dbr->bindParam(':gallery', $_POST['gallery'], PDO::PARAM_STR);
+ $dbr->execute();
+ $i=0;
+ while($data = $dbr->fetch())
+ {
+ $items[$i]['id'] = $data['id'];
+ $items[$i]['title'] = $data['title'];
+ $items[$i]['photo_thumbnail'] = $data['photo_thumbnail'];
+ ++$i;
+ }
+ if(isset($items))
+ {
+ $template->assign('items',$items);
+ }
+
+ $image_classes_untrimmed = explode(',',$settings['image_classes']);
+ foreach($image_classes_untrimmed as $image_class)
+ {
+ $image_classes[] = trim($image_class);
+ }
+ if(isset($image_classes))
+ {
+ $template->assign('image_classes',$image_classes);
+ }
+ }
+
+ if(empty($action)) $action = 'main';
+
+ switch ($action)
+ {
+ case 'main':
+ $dbr = Database::$content->query("SELECT DISTINCT gallery FROM ".Database::$db_settings['photo_table']." ORDER BY gallery ASC");
+ while($data = $dbr->fetch())
+ {
+ $galleries[] = htmlspecialchars($data['gallery']);
+ }
+ if(isset($galleries))
+ {
+ $template->assign('galleries',$galleries);
+ }
+ break;
+ }
+
+ $template_file = 'insert_thumbnail.tpl';
+ }
+?>
diff --git a/cms/includes/login.inc.php b/cms/includes/login.inc.php
new file mode 100644
index 0000000..bc883ed
--- /dev/null
+++ b/cms/includes/login.inc.php
@@ -0,0 +1,68 @@
+prepare('SELECT id, name, pw, type, wysiwyg FROM '.Database::$db_settings['userdata_table'].' WHERE lower(name)=lower(:name) LIMIT 1');
+ #$dbr->bindValue(':name',mb_strtolower($_POST['username'],CHARSET), PDO::PARAM_STR);
+ $dbr->bindValue(':name',$_POST['username'], PDO::PARAM_STR);
+ $dbr->execute();
+ $row = $dbr->fetch();
+ if(isset($row['id']))
+ {
+ if(is_pw_correct($_POST['userpw'],$row['pw']))
+ {
+ $_SESSION[$settings['session_prefix'].'user_id'] = $row['id'];
+ $_SESSION[$settings['session_prefix'].'user_name'] = $row['name'];
+ $_SESSION[$settings['session_prefix'].'user_type'] = $row['type'];
+ $_SESSION[$settings['session_prefix'].'wysiwyg'] = $row['wysiwyg'];
+
+ $dbr = Database::$userdata->prepare('UPDATE '.Database::$db_settings['userdata_table'].' SET last_login=:now WHERE id=:id');
+ $dbr->bindValue(':now', time(), PDO::PARAM_INT);
+ $dbr->bindValue(':id', $row['id'], PDO::PARAM_INT);
+ $dbr->execute();
+ header('Location: ../');
+ exit;
+ }
+ else
+ {
+ $login_failed = true;
+ }
+ }
+ else
+ {
+ $login_failed = true;
+ }
+ }
+ else
+ {
+ $login_failed = true;
+ }
+ if(isset($login_failed))
+ {
+ header('Location: index.php?msg=login_failed');
+ exit;
+ }
+ }
+elseif(empty($_SESSION[$settings['session_prefix'].'user_id']) && empty($action))
+ {
+ $action = "login";
+ }
+
+switch ($action)
+ {
+ case 'login':
+ $template->assign('subtitle', Localization::$lang['login']);
+ $template->assign('subtemplate', 'login.inc.tpl');
+ break;
+ }
+?>
diff --git a/cms/includes/menus.inc.php b/cms/includes/menus.inc.php
new file mode 100644
index 0000000..5a00e14
--- /dev/null
+++ b/cms/includes/menus.inc.php
@@ -0,0 +1,316 @@
+prepare("DELETE FROM ".Database::$db_settings['menu_table']." WHERE menu=:menu");
+ $dbr->bindParam(':menu', $_REQUEST['delete'], PDO::PARAM_STR);
+ $dbr->execute();
+ if(isset($cache) && $cache->autoClear) $cache->clear();
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=menus');
+ exit;
+ }
+ else
+ {
+ $template->assign('menu', htmlspecialchars($_REQUEST['delete']));
+ $action = 'delete';
+ }
+ }
+
+ if(isset($_GET['set_default']))
+ {
+ $dbr = Database::$content->prepare("UPDATE ".Database::$db_settings['settings_table']." SET value=:value WHERE name='default_menu'");
+ $dbr->bindValue(':value', trim($_GET['set_default']), PDO::PARAM_STR);
+ $dbr->execute();
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=menus');
+ exit;
+ }
+
+ if(isset($_POST['new_menu_name']))
+ {
+ $dbr = Database::$content->prepare("SELECT COUNT(*) FROM ".Database::$db_settings['menu_table']." WHERE lower(menu)=:menu");
+ $dbr->bindValue(':menu', trim(strtolower($_POST['new_menu_name'])), PDO::PARAM_STR);
+ $dbr->execute();
+ if($dbr->fetchColumn() > 0)
+ {
+ $errors[] = 'menu_already_exists';
+ $action = 'new';
+ }
+ elseif(!preg_match('/^[a-zA-Z0-9_\-]+$/', $_POST['new_menu_name']))
+ {
+ $errors[] = 'error_menu_spec_chars';
+ $action = 'new';
+ }
+ else
+ {
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=menus&edit='.$_POST['new_menu_name']);
+ exit;
+ }
+ }
+
+ if(isset($_POST['new_menu_item']))
+ {
+ $dbr = Database::$content->prepare("SELECT sequence FROM ".Database::$db_settings['menu_table']." WHERE menu=:menu ORDER BY sequence DESC LIMIT 1");
+ $dbr->bindValue(':menu', trim($_POST['menu']), PDO::PARAM_STR);
+ $dbr->execute();
+ $data = $dbr->fetch();
+ if(!isset($data['sequence']))
+ {
+ $new_sequence = 1;
+ }
+ else
+ {
+ $new_sequence = $data['sequence']+1;
+ }
+ $dbr = Database::$content->prepare("INSERT INTO ".Database::$db_settings['menu_table']." (menu,sequence,name,title,link,section,accesskey) VALUES (:menu,:sequence,:name,:title,:link,:section,:accesskey)");
+ $dbr->bindValue(':menu', trim($_POST['menu']), PDO::PARAM_STR);
+ $dbr->bindValue(':sequence', $new_sequence, PDO::PARAM_INT);
+ $dbr->bindValue(':name', trim($_POST['name']), PDO::PARAM_STR);
+ $dbr->bindValue(':title', trim($_POST['title']), PDO::PARAM_STR);
+ $dbr->bindValue(':link', trim($_POST['link']), PDO::PARAM_STR);
+ $dbr->bindValue(':section', trim($_POST['section']), PDO::PARAM_STR);
+ $dbr->bindValue(':accesskey', trim($_POST['accesskey']), PDO::PARAM_STR);
+ $dbr->execute();
+ if(isset($cache) && $cache->autoClear) $cache->clear();
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=menus&edit='.$_POST['menu']);
+ exit;
+ }
+
+ if(isset($_POST['edit_item']))
+ {
+ $dbr = Database::$content->prepare("UPDATE ".Database::$db_settings['menu_table']." SET name=:name, title=:title, link=:link, section=:section, accesskey=:accesskey WHERE id=:id");
+ $dbr->bindValue(':name', trim($_POST['name']), PDO::PARAM_STR);
+ $dbr->bindValue(':title', trim($_POST['title']), PDO::PARAM_STR);
+ $dbr->bindValue(':link', trim($_POST['link']), PDO::PARAM_STR);
+ $dbr->bindValue(':section', trim($_POST['section']), PDO::PARAM_STR);
+ $dbr->bindValue(':accesskey', trim($_POST['accesskey']), PDO::PARAM_STR);
+ $dbr->bindParam(':id', $_POST['edit_item'], PDO::PARAM_INT);
+ $dbr->execute();
+ if(isset($cache) && $cache->autoClear) $cache->clear();
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=menus&edit='.$_POST['menu']);
+ exit;
+ }
+
+ if(isset($_GET['action'])) $action = $_GET['action'];
+ if(isset($_POST['action'])) $action = $_POST['action'];
+
+ if(empty($action)) $action='show_menus';
+
+ if(isset($_GET['move_up']))
+ {
+ $dbr = Database::$content->prepare("SELECT menu, sequence FROM ".Database::$db_settings['menu_table']." WHERE id=:id LIMIT 1");
+ $dbr->bindParam(':id', $_GET['move_up'], PDO::PARAM_INT);
+ $dbr->execute();
+ $data = $dbr->fetch();
+ if(isset($data['sequence']) && $data['sequence'] > 1)
+ {
+ Database::$content->beginTransaction();
+ $dbr = Database::$content->prepare("UPDATE ".Database::$db_settings['menu_table']." SET sequence=:new_sequence WHERE menu=:menu AND sequence=:sequence");
+ $dbr->bindParam(':menu', $data['menu'], PDO::PARAM_STR);
+ $dbr->bindValue(':new_sequence', 0, PDO::PARAM_INT);
+ $dbr->bindValue(':sequence', $data['sequence']-1, PDO::PARAM_INT);
+ $dbr->execute();
+ $dbr->bindValue(':new_sequence', $data['sequence']-1, PDO::PARAM_INT);
+ $dbr->bindValue(':sequence', $data['sequence'], PDO::PARAM_INT);
+ $dbr->execute();
+ $dbr->bindValue(':new_sequence', $data['sequence'], PDO::PARAM_INT);
+ $dbr->bindValue(':sequence', 0, PDO::PARAM_INT);
+ $dbr->execute();
+ Database::$content->commit();
+ }
+ if(isset($cache) && $cache->autoClear) $cache->clear();
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=menus&edit='.$data['menu']);
+ exit;
+ }
+
+ if(isset($_GET['move_down']))
+ {
+ $dbr = Database::$content->prepare("SELECT menu, sequence FROM ".Database::$db_settings['menu_table']." WHERE id=:id LIMIT 1");
+ $dbr->bindParam(':id', $_GET['move_down'], PDO::PARAM_INT);
+ $dbr->execute();
+ $data = $dbr->fetch();
+ if(isset($data['sequence']))
+ {
+ $dbr = Database::$content->prepare("SELECT sequence FROM ".Database::$db_settings['menu_table']." WHERE menu=:menu ORDER BY sequence DESC LIMIT 1");
+ $dbr->bindParam(':menu', $data['menu'], PDO::PARAM_STR);
+ $dbr->execute();
+ $last = $dbr->fetchColumn();
+ if($data['sequence'] < $last)
+ {
+ Database::$content->beginTransaction();
+ $dbr = Database::$content->prepare("UPDATE ".Database::$db_settings['menu_table']." SET sequence=:new_sequence WHERE menu=:menu AND sequence=:sequence");
+ $dbr->bindParam(':menu', $data['menu'], PDO::PARAM_STR);
+ $dbr->bindValue(':new_sequence', 0, PDO::PARAM_INT);
+ $dbr->bindValue(':sequence', $data['sequence']+1, PDO::PARAM_INT);
+ $dbr->execute();
+ $dbr->bindValue(':new_sequence', $data['sequence']+1, PDO::PARAM_INT);
+ $dbr->bindValue(':sequence', $data['sequence'], PDO::PARAM_INT);
+ $dbr->execute();
+ $dbr->bindValue(':new_sequence', $data['sequence'], PDO::PARAM_INT);
+ $dbr->bindValue(':sequence', 0, PDO::PARAM_INT);
+ $dbr->execute();
+ Database::$content->commit();
+ }
+ if(isset($cache) && $cache->autoClear) $cache->clear();
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=menus&edit='.$data['menu']);
+ exit;
+ }
+ }
+
+ if(isset($_REQUEST['reorder_items']) && isset($_REQUEST['item']))
+ {
+ $dbr = Database::$content->prepare("UPDATE ".Database::$db_settings['menu_table']." SET sequence=:sequence WHERE id=:id");
+ $dbr->bindParam(':id', $id, PDO::PARAM_INT);
+ $dbr->bindParam(':sequence', $sequence, PDO::PARAM_INT);
+ Database::$content->beginTransaction();
+ $sequence = 1;
+ foreach($_REQUEST['item'] as $id)
+ {
+ $dbr->execute();
+ ++$sequence;
+ }
+ Database::$content->commit();
+ if(isset($cache) && $cache->autoClear) $cache->clear();
+ exit;
+ }
+
+ // first actions:
+ switch ($action)
+ {
+ case 'delete_menu_item':
+ {
+ // get menu:
+ $dbr = Database::$content->prepare("SELECT menu FROM ".Database::$db_settings['menu_table']." WHERE id=:id LIMIT 1");
+ $dbr->bindParam(':id', $_GET['id'], PDO::PARAM_INT);
+ $dbr->execute();
+ $menu = $dbr->fetchColumn();
+ // delete menu item:
+ $dbr = Database::$content->prepare("DELETE FROM ".Database::$db_settings['menu_table']." WHERE id=:id");
+ $dbr->bindParam(':id', $_GET['id'], PDO::PARAM_INT);
+ $dbr->execute();
+ // reorder items:
+ $dbr = Database::$content->prepare("SELECT id FROM ".Database::$db_settings['menu_table']." WHERE menu=:menu ORDER BY sequence ASC");
+ $dbr->bindParam(':menu', $menu, PDO::PARAM_STR);
+ $dbr->execute();
+ while($data = $dbr->fetch())
+ {
+ $ids[] = $data['id'];
+ }
+ if(isset($ids))
+ {
+ $new_sequence = 1;
+ Database::$content->beginTransaction();
+ $dbr = Database::$content->prepare("UPDATE ".Database::$db_settings['menu_table']." SET sequence=:sequence WHERE id=:id");
+ $dbr->bindParam(':sequence', $new_sequence, PDO::PARAM_INT);
+ $dbr->bindParam(':id', $id, PDO::PARAM_INT);
+ foreach($ids as $id)
+ {
+ $dbr->execute();
+ ++$new_sequence;
+ }
+ Database::$content->commit();
+ }
+ if(isset($cache) && $cache->autoClear) $cache->clear();
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=menus&edit='.$menu);
+ exit;
+ }
+ break;
+ }
+
+ // second actions:
+ switch ($action)
+ {
+ case 'show_menus':
+ $menu_result = Database::$content->query("SELECT DISTINCT menu FROM ".Database::$db_settings['menu_table']." ORDER BY menu ASC");
+ while($menu_data = $menu_result->fetch())
+ {
+ $menus[] = $menu_data['menu'];
+ }
+ if(isset($menus))
+ {
+ $template->assign('menus', $menus);
+ }
+ $template->assign('subtitle', Localization::$lang['menus']);
+ $template->assign('subtemplate', 'menus.inc.tpl');
+ break;
+ case 'edit':
+ $template->assign('menu', htmlspecialchars($_GET['edit']));
+ $dbr = Database::$content->prepare("SELECT id, name, sequence, title, link, section, accesskey FROM ".Database::$db_settings['menu_table']." WHERE menu=:menu ORDER BY sequence ASC");
+ $dbr->bindValue(':menu', trim($_GET['edit']), PDO::PARAM_STR);
+ $dbr->execute();
+ $i=0;
+ while($data = $dbr->fetch())
+ {
+ $items[$i]['id'] = intval($data['id']);
+ $items[$i]['name'] = htmlspecialchars($data['name']);
+ #$items[$i]['sequence'] = $data['sequence'];
+ $items[$i]['title'] = htmlspecialchars($data['title']);
+ $items[$i]['link'] = htmlspecialchars($data['link']);
+ $items[$i]['section'] = htmlspecialchars($data['section']);
+ $items[$i]['accesskey'] = htmlspecialchars($data['accesskey']);
+ ++$i;
+ }
+ if(isset($items))
+ {
+ $template->assign('items', $items);
+ }
+ $template->assign('subtitle', Localization::$lang['menus']);
+ $template->assign('subtemplate', 'menus_edit.inc.tpl');
+ break;
+ case 'edit_menu_item';
+ $dbr = Database::$content->prepare("SELECT menu FROM ".Database::$db_settings['menu_table']." WHERE id=:id LIMIT 1");
+ $dbr->bindParam(':id', $_GET['id'], PDO::PARAM_INT);
+ $dbr->execute();
+ $menu_data = $dbr->fetch();
+ if(isset($menu_data['menu']))
+ {
+ $dbr = Database::$content->prepare("SELECT id, name, sequence, title, link, section, accesskey FROM ".Database::$db_settings['menu_table']." WHERE menu=:menu ORDER BY sequence ASC");
+ $dbr->bindParam(':menu', $menu_data['menu'], PDO::PARAM_STR);
+ $dbr->execute();
+ $i=0;
+ while($data = $dbr->fetch())
+ {
+ $items[$i]['id'] = intval($data['id']);
+ $items[$i]['name'] = htmlspecialchars($data['name']);
+ $items[$i]['title'] = htmlspecialchars($data['title']);
+ $items[$i]['link'] = htmlspecialchars($data['link']);
+ $items[$i]['section'] = htmlspecialchars($data['section']);
+ $items[$i]['accesskey'] = htmlspecialchars($data['accesskey']);
+ ++$i;
+ }
+ if(isset($items))
+ {
+ $template->assign('items', $items);
+ }
+ $template->assign('menu', htmlspecialchars($menu_data['menu']));
+ $template->assign('edit_item', intval($_GET['id']));
+ $template->assign('subtitle', Localization::$lang['menus']);
+ $template->assign('subtemplate', 'menus_edit.inc.tpl');
+ }
+ break;
+ case 'delete':
+ $template->assign('subtemplate', 'menus_delete.inc.tpl');
+ break;
+ case 'new':
+ if(isset($errors))
+ {
+ $template->assign('errors', $errors);
+ }
+ if(isset($_POST['new_menu_name']))
+ {
+ $template->assign('new_menu_name', htmlspecialchars($_POST['new_menu_name']));
+ }
+ $template->assign('subtemplate', 'menus_new.inc.tpl');
+ break;
+ }
+ }
diff --git a/cms/includes/modal.inc.php b/cms/includes/modal.inc.php
new file mode 100644
index 0000000..f31d281
--- /dev/null
+++ b/cms/includes/modal.inc.php
@@ -0,0 +1,79 @@
+query("SELECT DISTINCT gallery FROM ".Database::$db_settings['photo_table']." ORDER BY gallery ASC");
+ while($data = $dbr->fetch())
+ {
+ $galleries[] = htmlspecialchars($data['gallery']);
+ }
+ if(isset($galleries))
+ {
+ $template->assign('galleries', $galleries);
+ }
+
+ $template_file = 'subtemplates/modal_insert_gallery.tpl';
+ break;
+
+ case 'insert_thumbnail':
+ $dbr = Database::$content->query("SELECT id, title, gallery FROM ".Database::$db_settings['photo_table']." ORDER BY gallery ASC, sequence ASC");
+ $i=0;
+ while($data = $dbr->fetch())
+ {
+ $thumbnails[$i]['id'] = $data['id'];
+ $thumbnails[$i]['gallery'] = htmlspecialchars($data['gallery']);
+ $thumbnails[$i]['title'] = htmlspecialchars($data['title']);
+ ++$i;
+ }
+ if(isset($thumbnails))
+ {
+ $template->assign('thumbnails', $thumbnails);
+ }
+
+ $template_file = 'subtemplates/modal_insert_thumbnail.tpl';
+ break;
+
+ case 'insert_image':
+ $fp=opendir(BASE_PATH.MEDIA_DIR);
+ while($file = readdir($fp))
+ {
+ if(preg_match('/\.jpg$/i', $file) || preg_match('/\.jpeg$/i', $file) || preg_match('/\.png$/i', $file))
+ {
+ $images[] = $file;
+ }
+ }
+ closedir($fp);
+
+ if(isset($images))
+ {
+ natcasesort($images);
+ $template->assign('images', $images);
+ }
+ $template_file = 'subtemplates/modal_insert_image.tpl';
+ break;
+
+ case 'insert_raw_image':
+ $fp=opendir(BASE_PATH.MEDIA_DIR);
+ while($file = readdir($fp))
+ {
+ if(preg_match('/\.jpg$/i', $file) || preg_match('/\.jpeg$/i', $file) || preg_match('/\.png$/i', $file))
+ {
+ $images[] = $file;
+ }
+ }
+ closedir($fp);
+
+ if(isset($images))
+ {
+ natcasesort($images);
+ $template->assign('images', $images);
+ }
+ $template_file = 'subtemplates/modal_insert_raw_image.tpl';
+ break;
+ }
+ }
+?>
diff --git a/cms/includes/notes.inc.php b/cms/includes/notes.inc.php
new file mode 100644
index 0000000..f9bd79f
--- /dev/null
+++ b/cms/includes/notes.inc.php
@@ -0,0 +1,341 @@
+prepare("SELECT id, title, text, text_formatting, link, linkname FROM ".Database::$db_settings['notes_table']." WHERE note_section=:note_section ORDER BY sequence ASC");
+ $dbr->bindParam(':note_section', $_GET['edit'], PDO::PARAM_STR);
+ $dbr->execute();
+ $i=0;
+ while($data = $dbr->fetch())
+ {
+ $notes[$i]['id'] = $data['id'];
+ $notes[$i]['title'] = $data['title'];
+ #$notes[$i]['teaser'] = $data['teaser'];
+ if($data['text_formatting']==1)
+ {
+ $notes[$i]['text'] = auto_html($data['text']);
+ }
+ else
+ {
+ $notes[$i]['text'] = $data['text'];
+ }
+
+ if(substr($data['link'],0,7) != 'http://' && substr($data['link'],0,8) != 'https://')
+ {
+ $notes[$i]['link'] = '../'.$data['link'];
+ }
+ else
+ {
+ $notes[$i]['link'] = $data['link'];
+ }
+ #$notes[$i]['link'] = htmlspecialchars(stripslashes($data['link']));
+ $notes[$i]['linkname'] = $data['linkname'];
+ ++$i;
+ }
+ if(isset($notes))
+ {
+ $template->assign('notes', $notes);
+ }
+ #$note_section = htmlspecialchars(stripslashes($_GET['edit']));
+ $template->assign('note_section', htmlspecialchars($_GET['edit']));
+ $action = 'edit';
+ }
+
+ if(isset($_REQUEST['delete']))
+ {
+ if(isset($_REQUEST['confirmed']))
+ {
+ $dbr = Database::$content->prepare("DELETE FROM ".Database::$db_settings['notes_table']." WHERE note_section=:note_section");
+ $dbr->bindParam(':note_section', $_REQUEST['delete'], PDO::PARAM_STR);
+ $dbr->execute();
+ if(isset($cache) && $cache->autoClear) $cache->clear();
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=notes');
+ exit;
+ }
+ else
+ {
+ $template->assign('note_section', htmlspecialchars($_REQUEST['delete']));
+ $action = 'delete';
+ }
+ }
+
+
+ if(isset($_GET['add_note']))
+ {
+ $note['note_section'] = htmlspecialchars($_GET['add_note']);
+ $note['time'] = date("Y-m-d H:i:s");
+ #$note['text_formatting'] = $settings['default_formatting'];
+ $note['text_formatting'] = 1;
+ $template->assign('note',$note);
+ $action = 'edit_note';
+ }
+
+ if(isset($_POST['new_note_section']))
+ {
+ $new_note_section = isset($_POST['new_note_section']) ? trim($_POST['new_note_section']) : '';
+
+ if(!preg_match('/^[a-zA-Z0-9_\-]+$/', $new_note_section))
+ {
+ $errors[] = 'error_note_sect_name_invalid';
+ }
+ if(empty($errors))
+ {
+ $dbr = Database::$content->prepare("SELECT COUNT(*) FROM ".Database::$db_settings['notes_table']." WHERE lower(note_section)=:note_section");
+ $dbr->bindValue(':note_section', mb_strtolower($new_note_section,CHARSET), PDO::PARAM_STR);
+ $dbr->execute();
+ if($dbr->fetchColumn()!=0)
+ {
+ $errors[] = 'note_section_already_ex';
+ }
+ }
+ if(empty($errors))
+ {
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=notes&edit='.$new_note_section);
+ }
+ else
+ {
+ $template->assign('errors',$errors);
+ $template->assign('new_note_section',htmlspecialchars($new_note_section));
+ $action = 'new';
+ }
+ }
+
+ if(isset($_GET['edit_note']))
+ {
+ $dbr = Database::$content->prepare("SELECT id, note_section, time, title, text, text_formatting, link, linkname FROM ".Database::$db_settings['notes_table']." WHERE id=:id LIMIT 1");
+ $dbr->bindParam(':id', $_GET['edit_note'], PDO::PARAM_STR);
+ $dbr->execute();
+ $data = $dbr->fetch();
+ if(isset($data['id']))
+ {
+ $note['note_section'] = htmlspecialchars($data['note_section']);
+ $note['id'] = $data['id'];
+ $note['title'] = htmlspecialchars($data['title']);
+ #$note['teaser'] = htmlspecialchars($data['teaser']);
+ $note['text'] = $data['text'];
+ $note['text_formatting'] = $data['text_formatting'];
+ $note['link'] = htmlspecialchars($data['link']);
+ $note['linkname'] = htmlspecialchars($data['linkname']);
+ $note['time'] = date("Y-m-d H:i:s", $data['time']);
+
+ $headline = $note['title'];
+
+ $template->assign('note',$note);
+ $action = 'edit_note';
+ }
+ else
+ {
+ $action = 'invalid_request';
+ }
+ }
+
+ if(isset($_GET['move_up']))
+ {
+ if($note_section = move_up($_GET['move_up'], 'note_section', Database::$db_settings['notes_table']))
+ {
+ if(isset($cache) && $cache->autoClear) $cache->clear();
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=notes&edit='.$note_section);
+ exit;
+ }
+ else
+ {
+ $action = 'invalid_request';
+ }
+ }
+
+ if(isset($_GET['move_down']))
+ {
+ if($note_section = move_down($_GET['move_down'], 'note_section', Database::$db_settings['notes_table']))
+ {
+ if(isset($cache) && $cache->autoClear) $cache->clear();
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=notes&edit='.$note_section);
+ exit;
+ }
+ else
+ {
+ $action = 'invalid_request';
+ }
+ }
+
+ if(isset($_REQUEST['reorder_notes']) && isset($_REQUEST['item']))
+ {
+ $dbr = Database::$content->prepare("UPDATE ".Database::$db_settings['notes_table']." SET sequence=:sequence WHERE id=:id");
+ $dbr->bindParam(':id', $id, PDO::PARAM_INT);
+ $dbr->bindParam(':sequence', $sequence, PDO::PARAM_INT);
+ Database::$content->beginTransaction();
+ $sequence = 1;
+ foreach($_REQUEST['item'] as $id)
+ {
+ $dbr->execute();
+ ++$sequence;
+ }
+ Database::$content->commit();
+ if(isset($cache) && $cache->autoClear) $cache->clear();
+ exit;
+ }
+
+ if(isset($_POST['edit_note_submit']))
+ {
+ $title = isset($_POST['title']) ? trim($_POST['title']) : '';
+ #$teaser = isset($_POST['teaser']) ? trim($_POST['teaser']) : '';
+ $text = isset($_POST['text']) ? trim($_POST['text']) : '';
+ $text_formatting = isset($_POST['text_formatting']) && $_POST['text_formatting']==1 ? 1 : 0;
+ $link = isset($_POST['link']) ? trim($_POST['link']) : '';
+ $linkname = isset($_POST['linkname']) ? trim($_POST['linkname']) : '';
+ $time = isset($_POST['time']) ? trim($_POST['time']) : date("Y-m-d H:i:s");
+ $note_section = isset($_POST['note_section']) ? trim($_POST['note_section']) : '';
+
+ if(empty($title))
+ {
+ $errors[] = 'error_notes_no_title';
+ }
+ if(empty($text))
+ {
+ $errors[] = 'error_notes_no_text';
+ }
+ if(($time = strtotime($time))===false)
+ {
+ $errors[] = 'error_notes_time_invalid';
+ }
+ if(!preg_match('/^[a-zA-Z0-9_\-]+$/', $note_section))
+ {
+ $errors[] = 'error_note_sect_name_invalid';
+ }
+
+ if(empty($errors))
+ {
+ if(isset($_POST['id']))
+ {
+ $dbr = Database::$content->prepare("UPDATE ".Database::$db_settings['notes_table']." SET time=:time, title=:title, text=:text, text_formatting=:text_formatting, link=:link, linkname=:linkname WHERE id=:id");
+ $dbr->bindParam(':id', $_POST['id'], PDO::PARAM_INT);
+ $dbr->bindParam(':time', $time, PDO::PARAM_INT);
+ $dbr->bindParam(':title', $title, PDO::PARAM_STR);
+ #$dbr->bindParam(':teaser', $teaser, PDO::PARAM_STR);
+ $dbr->bindParam(':text', $text, PDO::PARAM_STR);
+ $dbr->bindParam(':text_formatting', $text_formatting, PDO::PARAM_INT);
+ $dbr->bindParam(':link', $link, PDO::PARAM_STR);
+ $dbr->bindParam(':linkname', $linkname, PDO::PARAM_STR);
+ $dbr->execute();
+ }
+ else
+ {
+ $dbr = Database::$content->prepare("SELECT sequence FROM ".Database::$db_settings['notes_table']." WHERE note_section=:note_section ORDER BY sequence DESC LIMIT 1");
+ $dbr->bindParam(':note_section', $note_section, PDO::PARAM_STR);
+ $dbr->execute();
+ $sequence = intval($dbr->fetchColumn())+1;
+ $dbr = Database::$content->prepare("INSERT INTO ".Database::$db_settings['notes_table']." (note_section,sequence,time,title,text,text_formatting,link,linkname) VALUES (:note_section,:sequence,:time,:title,:text,:text_formatting,:link,:linkname)");
+ $dbr->bindParam(':note_section', $note_section, PDO::PARAM_STR);
+ $dbr->bindParam(':sequence', $sequence, PDO::PARAM_INT);
+ $dbr->bindParam(':time', $time, PDO::PARAM_INT);
+ $dbr->bindParam(':title', $title, PDO::PARAM_STR);
+ #$dbr->bindParam(':teaser', $teaser, PDO::PARAM_STR);
+ $dbr->bindParam(':text', $text, PDO::PARAM_STR);
+ $dbr->bindParam(':text_formatting', $text_formatting, PDO::PARAM_INT);
+ $dbr->bindParam(':link', $link, PDO::PARAM_STR);
+ $dbr->bindParam(':linkname', $linkname, PDO::PARAM_STR);
+ $dbr->execute();
+ }
+ if(isset($cache) && $cache->autoClear) $cache->clear();
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=notes&edit='.$note_section);
+ exit;
+ }
+ else
+ {
+ if(isset($_POST['id'])) $note['id'] = intval($_POST['id']);
+ $note['title'] = isset($_POST['title']) ? htmlspecialchars($_POST['title']) : '';
+ #$note['teaser'] = isset($_POST['teaser']) ? htmlspecialchars($_POST['teaser']) : '';
+ $note['text'] = isset($_POST['text']) ? htmlspecialchars($_POST['text']) : '';
+ $note['text_formatting'] = isset($_POST['text_formatting']) && $_POST['text_formatting']==1 ? 1 : 0;
+ $note['link'] = isset($_POST['link']) ? htmlspecialchars($_POST['link']) : '';
+ $note['linkname'] = isset($_POST['linkname']) ? htmlspecialchars($_POST['linkname']) : '';
+ $note['time'] = isset($_POST['time']) ? htmlspecialchars($_POST['time']) : date("Y-m-d H:i:s");
+ $note['note_section'] = isset($_POST['note_section']) ? htmlspecialchars($_POST['note_section']) : '';
+ $template->assign('note', $note);
+ $template->assign('errors', $errors);
+ $action = 'edit_note';
+ }
+ }
+
+ if(isset($_GET['delete_note']))
+ {
+ // get note section:
+ $dbr = Database::$content->prepare("SELECT note_section FROM ".Database::$db_settings['notes_table']." WHERE id=:id LIMIT 1");
+ $dbr->bindParam(':id', $_GET['delete_note'], PDO::PARAM_INT);
+ $dbr->execute();
+ $note_section = $dbr->fetchColumn();
+ // delete note:
+ $dbr = Database::$content->prepare("DELETE FROM ".Database::$db_settings['notes_table']." WHERE id=:id");
+ $dbr->bindParam(':id', $_GET['delete_note'], PDO::PARAM_INT);
+ $dbr->execute();
+ // reorder items:
+ $dbr = Database::$content->prepare("SELECT id FROM ".Database::$db_settings['notes_table']." WHERE note_section=:note_section ORDER BY sequence ASC");
+ $dbr->bindParam(':note_section', $note_section, PDO::PARAM_STR);
+ $dbr->execute();
+ while($data = $dbr->fetch())
+ {
+ $ids[] = $data['id'];
+ }
+ if(isset($ids))
+ {
+ $new_sequence = 1;
+ Database::$content->beginTransaction();
+ $dbr = Database::$content->prepare("UPDATE ".Database::$db_settings['notes_table']." SET sequence=:sequence WHERE id=:id");
+ $dbr->bindParam(':sequence', $new_sequence, PDO::PARAM_INT);
+ $dbr->bindParam(':id', $id, PDO::PARAM_INT);
+ foreach($ids as $id)
+ {
+ $dbr->execute();
+ ++$new_sequence;
+ }
+ Database::$content->commit();
+ }
+ if(isset($cache) && $cache->autoClear) $cache->clear();
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=notes&edit='.$note_section);
+ exit;
+ }
+
+ switch($action)
+ {
+ case 'main':
+ $dbr = Database::$content->query("SELECT DISTINCT note_section FROM ".Database::$db_settings['notes_table']." ORDER BY note_section ASC");
+ while($notes_data = $dbr->fetch())
+ {
+ $note_sections[] = htmlspecialchars($notes_data['note_section']);
+ }
+ if(isset($note_sections))
+ {
+ $template->assign('note_sections', $note_sections);
+ }
+ $template->assign('subtitle', Localization::$lang['notes']);
+ $template->assign('subtemplate', 'notes.inc.tpl');
+ break;
+ case 'edit':
+ $template->assign('subtitle', htmlspecialchars($_GET['edit']));
+ $template->assign('subtemplate', 'notes_edit_section.inc.tpl');
+ break;
+ case 'edit_note':
+ if(isset($note['id']))
+ {
+ $template->assign('subtitle', Localization::$lang['edit_note']);
+ }
+ else
+ {
+ $template->assign('subtitle', Localization::$lang['add_note']);
+ }
+ $template->assign('subtemplate', 'notes_edit_note.inc.tpl');
+ break;
+ case 'delete':
+ $template->assign('subtitle', Localization::$lang['delete_note_section']);
+ $template->assign('subtemplate', 'notes_delete_section.inc.tpl');
+ break;
+ case 'new':
+ $template->assign('subtitle', Localization::$lang['create_note_section']);
+ $template->assign('subtemplate', 'notes_new_section.inc.tpl');
+ break;
+ }
+ }
diff --git a/cms/includes/page_types/commentable_page.php b/cms/includes/page_types/commentable_page.php
new file mode 100644
index 0000000..23a5d92
--- /dev/null
+++ b/cms/includes/page_types/commentable_page.php
@@ -0,0 +1,178 @@
+assign('pingback', BASE_URL.PAGE.',pingback');
+
+$comment = new Comment(PAGE, $data['id']);
+
+// settings:
+$comment->comments_per_page = $settings['comments_per_page'];
+$comment->comment_order = $settings['comment_order'];
+$comment->name_maxlength = $settings['name_maxlength'];
+$comment->email_hp_maxlength = $settings['email_hp_maxlength'];
+$comment->word_maxlength = $settings['word_maxlength'];
+$comment->comment_maxlength = $settings['comment_maxlength'];
+$comment->prevent_repeated_posts_minutes = $settings['prevent_repeated_posts_minutes'];
+$comment->akismet_key = $settings['akismet_key'];
+$comment->akismet_entry_check = $settings['akismet_entry_check'];
+$comment->remove_blank_lines = $settings['comment_remove_blank_lines'];
+$comment->auto_link = $settings['comment_auto_link'];
+$comment->smilies = $settings['comment_smilies'];
+$comment->settings = $settings;
+
+if(!empty($data['type_addition']))
+ {
+ $comment->comments_closed = true;
+ $template->assign('comments_closed', true);
+ }
+
+if(isset($_SESSION[$settings['session_prefix'].'user_id']))
+ {
+ $comment->set_admin_mode();
+ }
+
+$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'main';
+
+if(isset($_GET['get_1']) && $_GET['get_1']=='commentrss')
+ {
+ $comment->comments_per_page = $settings['rss_maximum_items'];
+ $comments = $comment->get_comments(true);
+
+ if($comments)
+ {
+ $i=0;
+ foreach($comments as $comment)
+ {
+ $rss_items[$i]['title'] = $comment['name'];
+ $rss_items[$i]['content'] = $comment['comment'];
+ $rss_items[$i]['link'] = BASE_URL.PAGE.'#comment-'.$comment['id'];
+ $rss_items[$i]['pubdate'] = gmdate('r',$comment['time']);
+ $i++;
+ }
+ }
+ if(isset($rss_items)) $template->assign('rss_items', $rss_items);
+
+ $content_type = 'text/xml';
+ $template_file = 'rss.tpl';
+ $template_done = true;
+ }
+elseif(isset($_GET['get_1']) && $_GET['get_1']=='pingback' && $settings['pingbacks_enabled'] && empty($data['type_addition']))
+ {
+ // disable caching:
+ if($settings['caching']) $cache->doCaching = false;
+ $pingback = new Pingback();
+ $pingback->pingback_title_maxlength = $settings['pingback_title_maxlength'];
+ $pingback->settings = $settings;
+ if($pingback->get_pingback($data['id']))
+ {
+ if(isset($cache))
+ {
+ $cache->clear(PAGE);
+ $cache->clearRelated(PAGE);
+ }
+ exit;
+ }
+ else
+ {
+ exit;
+ }
+ }
+elseif(isset($_POST['preview']))
+ {
+ if($preview = $comment->preview())
+ {
+ $template->assign('preview', $preview);
+ }
+ }
+elseif(isset($_POST['save']))
+ {
+ if($comment->form_session==false)
+ {
+ if($preview = $comment->preview())
+ {
+ $template->assign('preview', $preview);
+ }
+ }
+ elseif($comment->save())
+ {
+ if(isset($cache))
+ {
+ $cache->clear(PAGE);
+ $cache->clearRelated(PAGE);
+ }
+ header('Location: '.BASE_URL.PAGE.'#comments');
+ exit;
+ }
+ }
+elseif(isset($_SESSION[$settings['session_prefix'].'user_id']) && isset($_GET['get_2']) && $_GET['get_2']=='edit' && isset($_GET['get_3']))
+ {
+ $template->assign('edit_data', $comment->get_edit_data($_GET['get_3']));
+ $action = 'edit';
+ }
+elseif(isset($_SESSION[$settings['session_prefix'].'user_id']) && isset($_GET['get_1']) && $_GET['get_1']=='openclose')
+ {
+ if($data['type_addition']=='') $close = true;
+ else $close = false;
+ $comment->openclose($close);
+ if(isset($cache))
+ {
+ $cache->clear(PAGE);
+ }
+ header('Location: '.BASE_URL.PAGE.'#comments');
+ exit;
+ }
+elseif(isset($_POST['edit_save']))
+ {
+ $comment->edit_save();
+ if(isset($cache))
+ {
+ $cache->clear(PAGE);
+ }
+ header('Location: '.BASE_URL.PAGE.','.$comment->current_page.'#comments');
+ exit;
+ }
+elseif(isset($_SESSION[$settings['session_prefix'].'user_id']) && isset($_GET['get_2']) && $_GET['get_2']=='delete' && isset($_GET['get_3']))
+ {
+ $comment->delete($_GET['get_3']);
+ if(isset($cache))
+ {
+ $cache->clear(PAGE);
+ $cache->clearRelated(PAGE);
+ }
+ header('Location: '.BASE_URL.PAGE.','.$comment->current_page.'#comments');
+ exit;
+ }
+
+if(empty($template_done))
+ {
+ $comments = $comment->get_comments();
+ $pingbacks = $comment->get_pingbacks();
+
+ $template->assign('comments', $comments);
+ $template->assign('pingbacks', $pingbacks);
+ $template->assign('pagination', pagination($comment->total_pages,$comment->current_page));
+ $template->assign('current_page', $comment->current_page);
+ $template->assign('errors', $comment->errors);
+ $template->assign('form_values', $comment->form_values);
+ $template->assign('form_session_data', $comment->form_session_data);
+ $template->assign('form_session', $comment->form_session);
+
+ $template->assign('subtemplate', 'comments.inc.tpl');
+ }
+
+if(isset($cache))
+ {
+ if(isset($_GET['get_1']) && $_GET['get_1']=='commentrss')
+ {
+ $cache->cacheId = PAGE . ',commentrss';
+ }
+ elseif($comment->current_page > 1)
+ {
+ $cache->cacheId = PAGE . ',' . $comment->current_page;
+ }
+ else
+ {
+ $cache->cacheId = PAGE;
+ }
+ }
+?>
diff --git a/cms/includes/page_types/formmailer.php b/cms/includes/page_types/formmailer.php
new file mode 100644
index 0000000..577a10f
--- /dev/null
+++ b/cms/includes/page_types/formmailer.php
@@ -0,0 +1,109 @@
+is_valid_email($email))
+ {
+ $errors[] = 'formmail_error_email_invalid';
+ }
+ if(empty($message))
+ {
+ $errors[] = 'formmail_error_no_message';
+ }
+ if(mb_strlen($message, CHARSET) > $settings['email_text_maxlength'])
+ {
+ $errors[] = 'formmail_error_text_too_long';
+ }
+ if(mb_strlen($subject, CHARSET) > $settings['email_subject_maxlength'])
+ {
+ $errors[] = 'formmail_error_subj_too_long';
+ }
+ if(empty($errors))
+ {
+ // Akismet spam check:
+ if($settings['akismet_key']!='' && $settings['akismet_mail_check']==1)
+ {
+ #require('./cms/modules/akismet/akismet.class.php');
+ $mail_parts = explode("@", $email);
+ $check_mail['author'] = $mail_parts[0];
+ $check_mail['email'] = $email;
+ $check_mail['body'] = $message;
+ $akismet = new Akismet(BASE_URL, $settings['akismet_key'], $check_mail);
+ // test for errors
+ if($akismet->errorsExist()) // returns true if any errors exist
+ {
+ if($akismet->isError(AKISMET_INVALID_KEY))
+ {
+ $errors[] = 'akismet_error_api_key';
+ }
+ elseif($akismet->isError(AKISMET_RESPONSE_FAILED))
+ {
+ $errors[] = 'akismet_error_connection';
+ }
+ elseif($akismet->isError(AKISMET_SERVER_NOT_FOUND))
+ {
+ $errors[] = 'akismet_error_connection';
+ }
+ }
+ else
+ {
+ // No errors, check for spam
+ if($akismet->isSpam())
+ {
+ $errors[] = 'akismet_spam_suspicion';
+ }
+ }
+ }
+ // End Akismet spam check:
+ }
+ if(empty($errors))
+ {
+ $mail->set_charset(CHARSET);
+ if(empty($subject)) $subject = Localization::$lang['formmailer_no_subject'];
+ foreach($recipients as $recipient)
+ {
+ if($mail->send($recipient, $email, $subject, $message, $settings['mail_parameter']))
+ {
+ $template->assign('mail_sent', true);
+ $template->assign('hide_content', true);
+ }
+ else
+ {
+ $errors[] = 'formmail_error_mailserver';
+ break;
+ }
+ }
+ }
+ }
+
+if(isset($errors))
+ {
+ $template->assign('email', htmlspecialchars($email));
+ $template->assign('subject', htmlspecialchars($subject));
+ $template->assign('message', htmlspecialchars($message));
+ $template->assign('errors', $errors);
+ }
+
+$template->assign('subtemplate', 'formmailer.inc.tpl');
+
+if(isset($cache))
+ {
+ $cache->cacheId = PAGE;
+ }
+?>
diff --git a/cms/includes/page_types/gallery.php b/cms/includes/page_types/gallery.php
new file mode 100644
index 0000000..05c3504
--- /dev/null
+++ b/cms/includes/page_types/gallery.php
@@ -0,0 +1,20 @@
+photos)
+ {
+ $template->assign('number_of_photos', $gallery->number_of_photos);
+ $template->assign('photos_per_row', $gallery->photos_per_row);
+ $template->assign('photos', $gallery->photos);
+ }
+
+$template->assign('contains_thumbnails', true);
+$template->assign('subtemplate', 'gallery.inc.tpl');
+
+if(isset($cache) && empty($no_cache))
+ {
+ $cache->cacheId = PAGE;
+ }
+?>
diff --git a/cms/includes/page_types/language_redirect.php b/cms/includes/page_types/language_redirect.php
new file mode 100644
index 0000000..147efc2
--- /dev/null
+++ b/cms/includes/page_types/language_redirect.php
@@ -0,0 +1,110 @@
+ Standardsprache zurückgeben
+ return $default_language;
+ }
+
+ // Den Header auftrennen
+ $accepted_languages = preg_split('/,\s*/', $lang_variable);
+
+ // Die Standardwerte einstellen
+ $current_lang = $default_language;
+ $current_q = 0;
+
+ // Nun alle mitgegebenen Sprachen abarbeiten
+ foreach ($accepted_languages as $accepted_language) {
+ // Alle Infos über diese Sprache rausholen
+ $res = preg_match ('/^([a-z]{1,8}(?:-[a-z]{1,8})*)'.
+ '(?:;\s*q=(0(?:\.[0-9]{1,3})?|1(?:\.0{1,3})?))?$/i', $accepted_language, $matches);
+
+ // war die Syntax gültig?
+ if (!$res) {
+ // Nein? Dann ignorieren
+ continue;
+ }
+
+ // Sprachcode holen und dann sofort in die Einzelteile trennen
+ $lang_code = explode ('-', $matches[1]);
+
+ // Wurde eine Qualität mitgegeben?
+ if (isset($matches[2])) {
+ // die Qualität benutzen
+ $lang_quality = (float)$matches[2];
+ } else {
+ // Kompabilitätsmodus: Qualität 1 annehmen
+ $lang_quality = 1.0;
+ }
+
+ // Bis der Sprachcode leer ist...
+ while (count ($lang_code)) {
+ // mal sehen, ob der Sprachcode angeboten wird
+ if (in_array (strtolower (join ('-', $lang_code)), $allowed_languages)) {
+ // Qualität anschauen
+ if ($lang_quality > $current_q) {
+ // diese Sprache verwenden
+ $current_lang = strtolower (join ('-', $lang_code));
+ $current_q = $lang_quality;
+ // Hier die innere while-Schleife verlassen
+ break;
+ }
+ }
+ // Wenn wir im strengen Modus sind, die Sprache nicht versuchen zu minimalisieren
+ if ($strict_mode) {
+ // innere While-Schleife aufbrechen
+ break;
+ }
+ // den rechtesten Teil des Sprachcodes abschneiden
+ array_pop ($lang_code);
+ }
+ }
+
+ // die gefundene Sprache zurückgeben
+ return $current_lang;
+}
+
+$lang_pages_parts = explode(';',$data['type_addition']);
+foreach($lang_pages_parts as $lang_pages)
+ {
+ $lang_parts = explode(',',$lang_pages);
+ $allowed_langs[] = trim($lang_parts[0]);
+ $lang_pages_array[trim($lang_parts[0])] = trim($lang_parts[1]);
+ }
+
+$lang = lang_getfrombrowser ($allowed_langs, $allowed_langs[0], null, false);
+
+if(isset($cache) && $cache->doCaching)
+ {
+ $cache->cacheId = PAGE;
+ $cache_content = "";
+ $cache->createChacheFile($cache_content);
+ }
+
+header($_SERVER['SERVER_PROTOCOL'] . ' 303 See Other');
+header('Location: '.BASE_URL.$lang_pages_array[$lang]);
+
+?>
+
+
+
+
+303 See Other
+
+
+
+
+
diff --git a/cms/includes/page_types/news.php b/cms/includes/page_types/news.php
new file mode 100644
index 0000000..78b83a2
--- /dev/null
+++ b/cms/includes/page_types/news.php
@@ -0,0 +1,49 @@
+assign('rss_items', $news->get_feed($settings['rss_maximum_items'], true));
+ if(isset($cache)) $cache->cacheId = PAGE . ',rss-fullfeed';
+ }
+ else
+ {
+ $template->assign('rss_items', $news->get_feed($settings['rss_maximum_items'], false));
+ if(isset($cache)) $cache->cacheId = PAGE . ',rss';
+ }
+ $template->assign('wfw', $news->wfw);
+ $content_type = 'text/xml';
+ $template_file = 'rss.tpl';
+ }
+else
+ {
+ $template->assign('news', $news->get_news());
+ $template->assign('current_category', htmlspecialchars($news->category));
+ $template->assign('current_category_urlencoded', $news->category_urlencoded);
+
+ $template->assign('subtemplate', 'news.inc.tpl');
+ $template->assign('pagination', pagination($news->total_pages,$news->current_page));
+
+ if(isset($cache))
+ {
+ if($news->category && $news->current_page == 1)
+ {
+ $cache->cacheId = PAGE . ',' . CATEGORY_IDENTIFIER . str_replace('&',AMPERSAND_REPLACEMENT,$news->category);
+ }
+ elseif($news->current_page > 1)
+ {
+ if($news->category) $category = CATEGORY_IDENTIFIER . str_replace('&',AMPERSAND_REPLACEMENT,$news->category);
+ else $category = '';
+ $cache->cacheId = PAGE . ',' . $category . ',' . $news->current_page;
+ }
+ else
+ {
+ $cache->cacheId = PAGE;
+ }
+ }
+ }
+?>
diff --git a/cms/includes/page_types/newsletter.php b/cms/includes/page_types/newsletter.php
new file mode 100644
index 0000000..1ac3b25
--- /dev/null
+++ b/cms/includes/page_types/newsletter.php
@@ -0,0 +1,336 @@
+prepare("DELETE FROM ".Database::$db_settings['newsletter_table']." WHERE time < :one_hour_ago AND confirmed = 0");
+$dbr->bindParam(':one_hour_ago', $one_hour_ago, PDO::PARAM_INT);
+$dbr->execute();
+
+if(isset($_GET['get_1']) && $_GET['get_1']=='subscribe')
+ {
+ $no_cache = true;
+ if(empty($_GET['get_2']) || empty($_GET['get_3'])) $error = true;
+ if(empty($error))
+ {
+ if(trim($_GET['get_2'])=='' || trim($_GET['get_3'])=='') $error = true;
+ }
+ if(empty($error))
+ {
+ $dbr = Database::$entries->prepare("SELECT confirmation_code FROM ".Database::$db_settings['newsletter_table']." WHERE id=:id LIMIT 1");
+ $dbr->bindParam(':id', $_GET['get_2'], PDO::PARAM_INT);
+ $dbr->execute();
+ $data = $dbr->fetch();
+ if(isset($data['confirmation_code']) && $_GET['get_3'] == $data['confirmation_code'])
+ {
+ $dbr = Database::$entries->prepare("UPDATE ".Database::$db_settings['newsletter_table']." SET confirmed=1, confirmation_code='' WHERE id=:id");
+ $dbr->bindParam(':id', $_GET['get_2'], PDO::PARAM_INT);
+ $dbr->execute();
+ $action = 'confirmation_ok';
+ }
+ else
+ {
+ $error = true;
+ }
+ }
+ if(isset($error)) $action = 'confirmation_failed';
+ }
+
+if(isset($_GET['get_1']) && $_GET['get_1']=='unsubscribe')
+ {
+ $no_cache = true;
+ if(empty($_GET['get_2']) || empty($_GET['get_3'])) $error = true;
+ if(empty($error))
+ {
+ if(trim($_GET['get_2'])=='' || trim($_GET['get_3'])=='') $error = true;
+ }
+ if(empty($error))
+ {
+ $dbr = Database::$entries->prepare("SELECT confirmation_code FROM ".Database::$db_settings['newsletter_table']." WHERE id=:id LIMIT 1");
+ $dbr->bindParam(':id', $_GET['get_2'], PDO::PARAM_INT);
+ $dbr->execute();
+ $data = $dbr->fetch();
+ if(isset($data['confirmation_code']) && $_GET['get_3'] == $data['confirmation_code'])
+ {
+ $dbr = Database::$entries->prepare("DELETE FROM ".Database::$db_settings['newsletter_table']." WHERE id=:id");
+ $dbr->bindParam(':id', $_GET['get_2'], PDO::PARAM_INT);
+ $dbr->execute();
+ $action = 'delete_ok';
+ }
+ else $error = true;
+ }
+ if(isset($error)) $action = 'confirmation_failed';
+ }
+
+if((isset($_POST['delete_checked']) || isset($_GET['get_1']) && $_GET['get_1']=='delete') && isset($_SESSION[$settings['session_prefix'].'user_id']))
+ {
+ if(isset($_POST['checked'])) $checked_emails = $_POST['checked'];
+ elseif(isset($_GET['get_2'])) $checked_emails[] = $_GET['get_2'];
+
+ if(isset($checked_emails) && is_array($checked_emails))
+ {
+ $dbr = Database::$entries->prepare("SELECT id, email FROM ".Database::$db_settings['newsletter_table']." WHERE id=:id ORDER BY email ASC LIMIT 1");
+ $dbr->bindParam(':id', $checked, PDO::PARAM_INT);
+ $i=0;
+ #Database::$entries->beginTransaction();
+ foreach($checked_emails as $checked)
+ {
+ $dbr->execute();
+ $data = $dbr->fetch();
+ $emails2delete[$i]['id'] = $data['id'];
+ $emails2delete[$i]['email'] = htmlspecialchars($data['email']);
+ ++$i;
+ }
+ #Database::$entries->commit();
+ if(isset($emails2delete))
+ {
+ $template->assign('emails2delete',$emails2delete);
+ $action = 'delete_checked';
+ }
+ }
+ }
+
+if(isset($_POST['delete_confirm']))
+ {
+ if(isset($_POST['checked']) && is_array($_POST['checked']))
+ {
+ $dbr = Database::$entries->prepare("DELETE FROM ".Database::$db_settings['newsletter_table']." WHERE id=:id");
+ $dbr->bindParam(':id', $delete_id, PDO::PARAM_INT);
+ Database::$entries->beginTransaction();
+ foreach($_POST['checked'] as $delete_id)
+ {
+ $dbr->execute();
+ }
+ Database::$entries->commit();
+ }
+ header('Location: '.BASE_URL.PAGE);
+ exit;
+ }
+
+/*
+if(isset($_POST['delete_email']) && isset($_SESSION[$settings['session_prefix'].'user_id']))
+ {
+ $dbr = Database::$entries->prepare("DELETE FROM ".Database::$db_settings['newsletter_table']." WHERE id=:id");
+ $dbr->bindParam(':id', $_POST['email_id'], PDO::PARAM_INT);
+ $dbr->execute();
+ header('Location: '.BASE_URL.PAGE);
+ exit;
+ }
+*/
+
+if(isset($_POST['add_email']) && isset($_SESSION[$settings['session_prefix'].'user_id']))
+ {
+ $mail = new Mail();
+ $mail->set_charset(CHARSET);
+ if(!$mail->is_valid_email($_POST['add_email']))
+ #if(trim($_POST['add_email'])=='' || !preg_match("/^[^@]+@.+\.\D{2,5}$/", $_POST['add_email']))
+ {
+ $template->assign('email', htmlspecialchars($_POST['add_email']));
+ $errors[] = 'newsletter_error_invalid_email';
+ }
+ if(empty($errors))
+ {
+ $dbr = Database::$entries->prepare("SELECT email FROM ".Database::$db_settings['newsletter_table']." WHERE lower(email)=:email LIMIT 1");
+ $dbr->bindValue(':email', mb_strtolower(trim($_POST['add_email']),CHARSET), PDO::PARAM_STR);
+ $dbr->execute();
+ $data = $dbr->fetch();
+ if(isset($data['email']))
+ {
+ $errors[] = 'newsletter_error_email_exists';
+ }
+ }
+ if(empty($errors))
+ {
+ $dbr = Database::$entries->prepare("INSERT INTO ".Database::$db_settings['newsletter_table']." (newsletter_id, time, ip, email, confirmed, confirmation_code) VALUES (:newsletter_id, :time, :ip, :email, 1, '')");
+ $dbr->bindParam(':newsletter_id', $page_id, PDO::PARAM_INT);
+ $dbr->bindValue(':time', time(), PDO::PARAM_INT);
+ $dbr->bindParam(':ip', $_SERVER["REMOTE_ADDR"], PDO::PARAM_STR);
+ $dbr->bindParam(':email', $_POST['add_email'], PDO::PARAM_STR);
+ $dbr->execute();
+ header('Location: '.BASE_URL.PAGE);
+ exit;
+ }
+
+ }
+
+if(isset($_POST['email']) && trim($_POST['email'])!='' && isset($_POST['subscribe']))
+ {
+ $mail = new Mail();
+ $mail->set_charset(CHARSET);
+ $mail->set_sender_name($settings['website_title']);
+ if($settings['mail_parameter']) $mail->set_mail_parameter($settings['mail_parameter']);
+ if($_POST['subscribe']=='subscribe')
+ {
+ if(!$mail->is_valid_email($_POST['email']))
+ #if(trim($_POST['email'])=='' || !preg_match("/^[^@]+@.+\.\D{2,5}$/", $_POST['email']))
+ {
+ $template->assign('email', htmlspecialchars($_POST['email']));
+ $errors[] = 'newsletter_error_invalid_email';
+ }
+ if(empty($errors))
+ {
+ $dbr = Database::$entries->prepare("SELECT email FROM ".Database::$db_settings['newsletter_table']." WHERE lower(email)=:email LIMIT 1");
+ $dbr->bindValue(':email', mb_strtolower(trim($_POST['email']),CHARSET), PDO::PARAM_STR);
+ $dbr->execute();
+ $data = $dbr->fetch();
+ if(isset($data['email']))
+ {
+ $template->assign('email', htmlspecialchars($_POST['email']));
+ $errors[] = 'newsletter_error_email_exists';
+ }
+ }
+ if(empty($errors))
+ {
+ $confirmation_code = md5(uniqid(rand()));
+ $dbr = Database::$entries->prepare("INSERT INTO ".Database::$db_settings['newsletter_table']." (newsletter_id, time, ip, email, confirmed, confirmation_code) VALUES (:newsletter_id, :time, :ip, :email, 0, :confirmation_code)");
+ $dbr->bindParam(':newsletter_id', $page_id, PDO::PARAM_INT);
+ $dbr->bindValue(':time', time(), PDO::PARAM_INT);
+ $dbr->bindParam(':ip', $_SERVER["REMOTE_ADDR"], PDO::PARAM_STR);
+ $dbr->bindParam(':email', $_POST['email'], PDO::PARAM_STR);
+ $dbr->bindParam(':confirmation_code', $confirmation_code, PDO::PARAM_STR);
+ $dbr->execute();
+ // get ID:
+ $dbr = Database::$entries->prepare("SELECT id FROM ".Database::$db_settings['newsletter_table']." WHERE email=:email LIMIT 1");
+ $dbr->bindParam(':email', $_POST['email'], PDO::PARAM_STR);
+ $dbr->execute();
+ $data = $dbr->fetch();
+
+ $confirm_link = BASE_URL.PAGE.',subscribe,'.$data['id'].','.$confirmation_code;
+
+ $email_text = str_replace("[link]",$confirm_link,Localization::$lang['newsletter_subscribe_text']);
+
+ if($mail->send($_POST['email'], $settings['email'], Localization::$lang['newsletter_subscribe_subj'], $email_text))
+ {
+ $action = 'confirm_mail_sent';
+ }
+ else
+ {
+ $dbr = Database::$entries->prepare("DELETE FROM ".Database::$db_settings['newsletter_table']." WHERE id=:id");
+ $dbr->bindParam(':id', $data['id'], PDO::PARAM_INT);
+ $dbr->execute();
+ $errors[] = 'newsletter_error_mail';
+ }
+ }
+ if(isset($errors)) $action = 'main';
+ }
+ elseif($_POST['subscribe']=='unsubscribe')
+ {
+ $dbr = Database::$entries->prepare("SELECT id, email FROM ".Database::$db_settings['newsletter_table']." WHERE lower(email)=:email");
+ $dbr->bindValue(':email', mb_strtolower(trim($_POST['email']),CHARSET), PDO::PARAM_STR);
+ $dbr->execute();
+ $data = $dbr->fetch();
+ if(empty($data['email']))
+ {
+ $errors[] = 'newsletter_error_email_not_exist';
+ }
+ if(empty($errors))
+ {
+ $confirmation_code = md5(uniqid(rand()));
+ $dbr = Database::$entries->prepare("UPDATE ".Database::$db_settings['newsletter_table']." SET confirmation_code=:confirmation_code WHERE id=:id");
+ $dbr->bindParam(':id', $data['id'], PDO::PARAM_INT);
+ $dbr->bindParam(':confirmation_code', $confirmation_code, PDO::PARAM_STR);
+ $dbr->execute();
+
+ $confirm_link = BASE_URL.PAGE.',unsubscribe,'.$data['id'].','.$confirmation_code;
+
+ $email_text = str_replace("[link]",$confirm_link,Localization::$lang['newsletter_unsubscribe_text']);
+
+ if($mail->send($_POST['email'], $settings['email'], Localization::$lang['newsletter_unsubscribe_subj'], $email_text))
+ {
+ $action = 'confirm_mail_sent';
+ }
+ else
+ {
+ $errors[] = 'newsletter_error_mail';
+ }
+ }
+ if(isset($errors)) $action = 'main';
+ }
+
+ }
+
+if(isset($_SESSION[$settings['session_prefix'].'user_id'])) $action = 'admin';
+if(empty($action)) $action = 'main';
+
+switch($action)
+ {
+ case 'main':
+ $form['email'] = '';
+ #$template->assign('newsletterform', true);
+ $template->assign('form', $form);
+ break;
+ case 'confirm_mail_sent':
+ $template->assign('confirm_mail_sent', true);
+ break;
+ case 'confirmation_ok':
+ $template->assign('confirmation_ok', true);
+ break;
+ case 'delete_ok':
+ $template->assign('delete_ok', true);
+ break;
+ case 'confirmation_failed':
+ $template->assign('confirmation_failed', true);
+ break;
+ case 'admin':
+
+ $order = 'email ASC';
+ $order_qs = 'email-asc';
+ if(isset($_GET['get_1']))
+ {
+ switch($_GET['get_1'])
+ {
+ case 'email-asc':
+ $order = 'email ASC';
+ $order_qs = 'email-asc';
+ break;
+ case 'email-desc':
+ $order = 'email DESC';
+ $order_qs = 'email-desc';
+ break;
+ case 'time-asc':
+ $order = 'time ASC';
+ $order_qs = 'time-asc';
+ break;
+ case 'time-desc':
+ $order = 'time DESC';
+ $order_qs = 'time-desc';
+ break;
+ #default:
+ # $order = 'email ASC';
+ }
+ }
+
+ $dbr = Database::$entries->prepare("SELECT id, time, email FROM ".Database::$db_settings['newsletter_table']." WHERE newsletter_id=:page_id AND confirmed=1 ORDER BY ".$order);
+ $dbr->bindParam(':page_id', $page_id, PDO::PARAM_INT);
+ $dbr->execute();
+ $i=0;
+ while($data = $dbr->fetch())
+ {
+ $email_list[] = htmlspecialchars($data['email']);
+ $newsletter_data[$i]['id'] = $data['id'];
+ $newsletter_data[$i]['email'] = htmlspecialchars($data['email']);
+ $newsletter_data[$i]['domain'] = htmlspecialchars(mb_substr(mb_strstr($data['email'], '@'),1));
+ $localization->bindId('newsletter_subscribe_time_format', $data['id']);
+ $localization->replacePlaceholderBound('time', $data['time'], 'newsletter_subscribe_time_format', $data['id'], Localization::FORMAT_TIME);
+ ++$i;
+ }
+ if(isset($newsletter_data))
+ {
+ sort($email_list);
+ $template->assign('order', $order_qs);
+ $template->assign('email_count', $i);
+ $template->assign('email_list', implode(', ',$email_list));
+ $template->assign('newsletter_data', $newsletter_data);
+ }
+ $template->assign('admin', true);
+ break;
+ }
+if(isset($errors)) $template->assign('errors', $errors);
+$template->assign('subtemplate', 'newsletter.inc.tpl');
+
+if(isset($cache) && empty($no_cache))
+ {
+ $cache->cacheId = PAGE;
+ }
+?>
diff --git a/cms/includes/page_types/notes.php b/cms/includes/page_types/notes.php
new file mode 100644
index 0000000..a14081b
--- /dev/null
+++ b/cms/includes/page_types/notes.php
@@ -0,0 +1,103 @@
+prepare("SELECT id, note_section, time, title, text, text_formatting FROM ".Database::$db_settings['notes_table']." WHERE id=:id LIMIT 1");
+ $dbr->bindParam(':id', $_GET['get_1'], PDO::PARAM_STR);
+ $dbr->execute();
+ $note_data = $dbr->fetch();
+ if(isset($note_data['id']) && $note_data['note_section']==$data['type_addition'])
+ {
+ $note['note_section'] = htmlspecialchars($note_data['note_section']);
+ $note['id'] = $note_data['id'];
+ $note['title'] = htmlspecialchars($note_data['title']);
+ $note['text'] = htmlspecialchars($note_data['text']);
+ $note['text_formatting'] = $note_data['text_formatting'];
+ #$note['link'] = htmlspecialchars($note_data['link']);
+ #$note['linkname'] = htmlspecialchars($note_data['linkname']);
+ $note['time'] = date("Y-m-d H:i:s", $note_data['time']);
+
+ #echo $data['title'];
+
+ $template->assign('display_time', true);
+ $localization->replacePlaceholder('time', $note_data['time'], 'page_time', Localization::FORMAT_TIME);
+
+
+ $template->assign('headline', $note_data['title']);
+ #$template->assign('title', $note_data['title']);
+
+ $template->assign('note',$note);
+
+ }
+ else
+ {
+ $no_cache = true;
+ echo '404';
+ exit;
+ }
+ }
+else // overview
+ {
+ $dbr = Database::$content->prepare("SELECT COUNT(*) FROM ".Database::$db_settings['notes_table']." WHERE note_section=:note_section");
+ $dbr->bindParam(':note_section', $data['type_addition'], PDO::PARAM_STR);
+ $dbr->execute();
+ $total_items = $dbr->fetchColumn();
+
+ $total_pages = ceil($total_items / $settings['notes_per_page']);
+
+ if(isset($_GET['get_2'])) $current_page = intval($_GET['get_2']); else $current_page = 1;
+ if($current_page<1) $current_page = 1;
+ if($current_page>$total_pages) $current_page = $total_pages;
+
+ $dbr = Database::$content->prepare("SELECT id, time, title, text, text_formatting, link, linkname FROM ".Database::$db_settings['notes_table']." WHERE note_section=:note_section ORDER BY sequence ASC LIMIT ".(($current_page-1)*$settings['notes_per_page']).", ".$settings['notes_per_page']);
+ $dbr->bindParam(':note_section', $data['type_addition'], PDO::PARAM_STR);
+ $dbr->execute();
+ $i=0;
+ while($notes_data = $dbr->fetch())
+ {
+ $notes[$i]['id'] = $notes_data['id'];
+ $notes[$i]['time'] = $notes_data['time'];
+ $notes[$i]['title'] = $notes_data['title'];
+ if($notes_data['text_formatting']==1) $notes[$i]['text'] = auto_html($notes_data['text']);
+ else $notes[$i]['text'] = $notes_data['text'];
+ #$notes[$i]['text'] = format_paragraph($notes_data['text']);
+ if($notes_data['link']=='')
+ {
+ $notes[$i]['link'] = BASE_URL.PAGE.','.$notes_data['id'];
+ }
+ elseif(mb_substr($notes_data['link'],0,7) != 'http://' && mb_substr($notes_data['link'],0,8) != 'https://' && mb_substr($notes_data['link'],0,6) != 'ftp://' && mb_substr($notes_data['link'],0,9) != 'gopher://' && mb_substr($notes_data['link'],0,7) != 'news://')
+ {
+ $notes[$i]['link'] = BASE_URL.$notes_data['link'];
+ }
+ else
+ {
+ $notes[$i]['link'] = $notes_data['link'];
+ }
+ $notes[$i]['linkname'] = $notes_data['linkname'];
+ $localization->bindReplacePlaceholder($notes_data['id'], 'time', $notes_data['time'], 'note_time', Localization::FORMAT_TIME);
+ $i++;
+ }
+ if(isset($notes))
+ {
+ $template->assign('notes', $notes);
+ }
+
+ $localization->replacePlaceholder('current_page', $current_page, 'pagination');
+ $localization->replacePlaceholder('total_pages', $total_pages, 'pagination');
+
+ $template->assign('pagination', pagination($total_pages,$current_page));
+ }
+
+$template->assign('subtemplate', 'notes.inc.tpl');
+
+if(isset($cache))
+ {
+ if($current_page > 1)
+ {
+ $cache->cacheId = PAGE . ',' . $current_page;
+ }
+ else
+ {
+ $cache->cacheId = PAGE;
+ }
+ }
+?>
diff --git a/cms/includes/page_types/notes_rss.php b/cms/includes/page_types/notes_rss.php
new file mode 100644
index 0000000..5e6030c
--- /dev/null
+++ b/cms/includes/page_types/notes_rss.php
@@ -0,0 +1,38 @@
+prepare("SELECT time, title, text, text_formatting, link FROM ".Database::$db_settings['notes_table']." WHERE note_section=:note_section ORDER BY time DESC LIMIT ".$settings['rss_maximum_items']);
+$dbr->bindParam(':note_section', $data['type_addition'], PDO::PARAM_STR);
+$dbr->execute();
+
+$i=0;
+while($rss_data = $dbr->fetch())
+ {
+ $rss_items[$i]['title'] = htmlspecialchars($rss_data['title']);
+ if($rss_data['text_formatting']==1) $rss_items[$i]['content'] = auto_html($rss_data['text']);
+ else $rss_items[$i]['content'] = $rss_data['text'];
+ if(mb_substr($rss_data['link'],0,7) != 'http://' && mb_substr($rss_data['link'],0,8) != 'https://' && mb_substr($rss_data['link'],0,6) != 'ftp://' && mb_substr($rss_data['link'],0,9) != 'gopher://' && mb_substr($rss_data['link'],0,7) != 'news://')
+ {
+ $rss_items[$i]['link'] = BASE_URL.$rss_data['link'];
+ }
+ else
+ {
+ $rss_items[$i]['link'] = $rss_data['link'];
+ }
+ $rss_items[$i]['pubdate'] = gmdate('r',$rss_data['time']);
+ $i++;
+ }
+
+if(isset($rss_items))
+ {
+ $template->assign('rss_items',$rss_items);
+ }
+
+$content_type = 'text/xml';
+$template_file = 'rss.tpl';
+
+if(isset($cache))
+ {
+ $cache->cacheId = PAGE;
+ }
+?>
diff --git a/cms/includes/page_types/overview.php b/cms/includes/page_types/overview.php
new file mode 100644
index 0000000..f073010
--- /dev/null
+++ b/cms/includes/page_types/overview.php
@@ -0,0 +1,62 @@
+prepare("SELECT id, page, headline, content, content_formatting, teaser_headline, teaser, teaser_formatting, teaser_img, link_name FROM ".Database::$db_settings['pages_table']." WHERE include_page=:include_page ORDER BY include_order ASC");
+$dbr->bindParam(':include_page', $data['id'], PDO::PARAM_INT);
+$dbr->execute();
+$i=0;
+while($included_pages_data = $dbr->fetch())
+ {
+ if($included_pages_data['teaser_headline']=='')
+ {
+ $included_pages[$i]['teaser_headline'] = stripslashes($included_pages_data['headline']);
+ }
+ else
+ {
+ $included_pages[$i]['teaser_headline'] = stripslashes($included_pages_data['teaser_headline']);
+ }
+ if($included_pages_data['teaser']=='')
+ {
+ if($included_pages_data['content_formatting']==1)
+ {
+ $included_pages[$i]['teaser'] = nl2br(stripslashes($included_pages_data['content']));
+ }
+ else
+ {
+ $included_pages[$i]['teaser'] = stripslashes($included_pages_data['content']);
+ }
+ }
+ else
+ {
+ if($included_pages_data['teaser_formatting']==1)
+ {
+ $included_pages[$i]['teaser'] = nl2br(stripslashes($included_pages_data['teaser']));
+ }
+ else
+ {
+ $included_pages[$i]['teaser'] = stripslashes($included_pages_data['teaser']);
+ }
+ }
+ $included_pages[$i]['page'] = $included_pages_data['page'];
+ $included_pages[$i]['teaser_img'] = $included_pages_data['teaser_img'];
+ if(trim($included_pages_data['teaser_img']!=''))
+ {
+ $teaser_img_info = getimagesize(BASE_PATH.MEDIA_DIR.$included_pages_data['teaser_img']);
+ $included_pages[$i]['teaser_img_width'] = $teaser_img_info[0];
+ $included_pages[$i]['teaser_img_height'] = $teaser_img_info[1];
+ }
+ $included_pages[$i]['link_name'] = stripslashes($included_pages_data['link_name']);
+ $i++;
+ }
+if(isset($included_pages))
+ {
+ $template->assign('included_pages_number', count($included_pages));
+ $template->assign('included_pages', $included_pages);
+ }
+$template->assign('subtemplate', 'overview.inc.tpl');
+
+if(isset($cache))
+ {
+ $cache->cacheId = PAGE;
+ }
+?>
diff --git a/cms/includes/page_types/redirect.php b/cms/includes/page_types/redirect.php
new file mode 100644
index 0000000..a609b34
--- /dev/null
+++ b/cms/includes/page_types/redirect.php
@@ -0,0 +1,13 @@
+doCaching)
+ {
+ $cache->cacheId = PAGE;
+ $cache_content = "";
+ $cache->createChacheFile($cache_content);
+ }
+
+header($_SERVER['SERVER_PROTOCOL'] . ' 301 Moved Permanently');
+header('Location: '.$data['type_addition']);
+?>
diff --git a/cms/includes/page_types/rss.php b/cms/includes/page_types/rss.php
new file mode 100644
index 0000000..5c3e0b5
--- /dev/null
+++ b/cms/includes/page_types/rss.php
@@ -0,0 +1,88 @@
+prepare("SELECT id, page, type, category, title, teaser, teaser_formatting, teaser_img, teaser_headline, content, content_formatting, time, last_modified FROM ".Database::$db_settings['pages_table']." WHERE include_rss=:include_rss AND time<=:time AND status!=0 ORDER BY time DESC LIMIT ".$settings['rss_maximum_items']);
+$dbr->bindParam(':include_rss', $page_id, PDO::PARAM_INT);
+$dbr->bindParam(':time', $current_time, PDO::PARAM_INT);
+$dbr->execute();
+
+if(isset($_GET['get_1']) && $_GET['get_1'] == 'fullfeed' && $settings['enable_fullfeeds']) $fullfeed=true;
+else $fullfeed=false;
+
+$i=0;
+while($rss_data = $dbr->fetch())
+ {
+ $rss_items[$i]['category'] = htmlspecialchars($rss_data['category']);
+ $rss_items[$i]['title'] = htmlspecialchars($rss_data['title']);
+
+ #if($rss_data['headline'] && $fullfeed || empty($rss_data['teaser_headline'])) $rss_items[$i]['title'] = htmlspecialchars($rss_data['headline']);
+ if($rss_data['teaser_headline']) $rss_items[$i]['title'] = htmlspecialchars($rss_data['teaser_headline']);
+ else $rss_items[$i]['title'] = htmlspecialchars($rss_data['title']);
+
+ if($fullfeed || $rss_data['teaser']=='')
+ {
+ if($rss_data['content_formatting']==1)
+ {
+ $rss_items[$i]['content'] = auto_html($rss_data['content']);
+ }
+ else
+ {
+ $rss_items[$i]['content'] = $rss_data['content'];
+ }
+ $rss_items[$i]['content'] = parse_special_tags($rss_items[$i]['content'], $parent_page=$rss_data['page'], $rss=true);
+ #$rss_items[$i]['content'] = preg_replace_callback("#\[image:(.+?)\]#is", "create_image", $rss_items[$i]['content']);
+ #$rss_items[$i]['content'] = preg_replace_callback("#\[thumbnail:(.+?)\]#is", "create_thumbnail_rss", $rss_items[$i]['content']);
+ #$rss_items[$i]['content'] = preg_replace_callback("#\[gallery:(.+?)\]#is", "create_gallery_rss", $rss_items[$i]['content']);
+ #$rss_items[$i]['content'] = preg_replace('/\[\[([^|\]]+?)(?:\|([^\]]+))?\]\]/e', "''.(('\$2')?'\$2':'\$1').''", $rss_items[$i]['content']);
+ }
+ else
+ {
+ if($rss_data['teaser_formatting']==1)
+ {
+ $rss_items[$i]['content'] = auto_html($rss_data['teaser']);
+ }
+ else
+ {
+ $rss_items[$i]['content'] = $rss_data['teaser'];
+ }
+ }
+
+ if(!$fullfeed && $rss_data['teaser_img'])
+ {
+ $rss_items[$i]['teaser_img'] = $rss_data['teaser_img'];
+ $teaser_img_info = getimagesize(BASE_PATH.MEDIA_DIR.$rss_data['teaser_img']);
+ $rss_items[$i]['teaser_img_width'] = $teaser_img_info[0];
+ $rss_items[$i]['teaser_img_height'] = $teaser_img_info[1];
+ }
+
+ $rss_items[$i]['link'] = BASE_URL.$rss_data['page'];
+ $rss_items[$i]['pubdate'] = gmdate('r',$rss_data['time']);
+ $wfw = false;
+ if($rss_data['type']=='commentable_page')
+ {
+ $wfw = true;
+ $rss_items[$i]['commentrss'] = BASE_URL.$rss_data['page'].',commentrss';
+ }
+ $i++;
+ }
+
+$template->assign('wfw', $wfw);
+if(isset($rss_items)) $template->assign('rss_items', $rss_items);
+
+$content_type = 'text/xml';
+$template_file = 'rss.tpl';
+
+if(isset($cache))
+ {
+ if($fullfeed)
+ {
+ $cache->cacheId = PAGE . ',full';
+ }
+ else
+ {
+ $cache->cacheId = PAGE;
+ }
+ }
+?>
diff --git a/cms/includes/page_types/search.php b/cms/includes/page_types/search.php
new file mode 100644
index 0000000..d044644
--- /dev/null
+++ b/cms/includes/page_types/search.php
@@ -0,0 +1,242 @@
+assign('q', htmlspecialchars($q));
+ #$template->assign('q_encoded', str_replace('%','~',urlencode(htmlspecialchars($q))));
+ #$q = stripslashes($q);
+ $q = mb_substr($q, 0, 255);
+ $q_encoded = urlencode(htmlspecialchars($q));
+ $template->assign('q_encoded', $q_encoded);
+
+ $cookie_data = $q_encoded.' '.$current_page;
+ setcookie($settings['session_prefix'].'search',$cookie_data);
+
+ $q = str_replace('"', '', $q);
+ #$q = sqlite_escape_string($q);
+ $q_array = explode(" ", $q);
+
+ $number_of_words = count($q_array);
+ // limitation to 3 words:
+ if($number_of_words > 3)
+ {
+ $number_of_words = 3;
+ }
+
+ $dbr = Database::$content->query("SELECT id,page,title,description FROM ".Database::$db_settings['pages_table']." WHERE status>1");
+ $dbr->execute();
+ while($data = $dbr->fetch())
+ {
+ $pages[$data['id']]['page']=$data['page'];
+ $pages[$data['id']]['title']=$data['title'];
+ $pages[$data['id']]['description']=$data['description'];
+ }
+
+ // search pages:
+ $general_search_clause = '';
+ $special_search_clause = '';
+ for($i=0;$i<$number_of_words;++$i)
+ {
+ $general_search_clause .= $general_clause;
+ $special_search_clause .= $special_clause;
+ if($i<$number_of_words-1)
+ {
+ $general_search_clause .= ' AND ';
+ $special_search_clause .= ' AND ';
+ }
+ }
+ // search all fields:
+
+ $dbr = Database::$content->prepare("SELECT id FROM ".Database::$db_settings['pages_table']." WHERE status>1 AND ".$general_search_clause);
+ for($i=0;$i<$number_of_words;++$i)
+ {
+ $dbr->bindValue($i+1, '%'.$q_array[$i].'%', PDO::PARAM_STR);
+ }
+ #$dbr = Database::$content->prepare("SELECT id FROM ".Database::$db_settings['pages_table']." WHERE status>1 AND CONCAT(content, title) LIKE ?");
+ #$dbr->bindValue(1, '%'.$q_array[0].'%', PDO::PARAM_STR);
+
+ $dbr->execute();
+ while($data = $dbr->fetch())
+ {
+ $result_pages[$data['id']]['id'] = $data['id'];
+ $result_pages[$data['id']]['type'] = 0;
+ $result_pages[$data['id']]['relevance'] = 0;
+ $result_pages[$data['id']]['page'] = $pages[$data['id']]['page'];
+ $result_pages[$data['id']]['title'] = $pages[$data['id']]['title'];
+ $result_pages[$data['id']]['description'] = $pages[$data['id']]['description'];
+ }
+ if(isset($pages))
+ {
+ // search in special fields:
+ $dbr = Database::$content->prepare("SELECT id FROM ".Database::$db_settings['pages_table']." WHERE status>1 AND ".$special_search_clause);
+ for($i=0;$i<$number_of_words;++$i)
+ {
+ $dbr->bindValue($i+1, '%'.$q_array[$i].'%', PDO::PARAM_STR);
+ }
+ $dbr->execute();
+ while($data = $dbr->fetch())
+ {
+ // enhance relevace if word found in special fields:
+ if(isset($pages[$data['id']]))
+ {
+ ++$result_pages[$data['id']]['relevance'];
+ }
+ }
+ }
+
+ // search notes:
+ /*
+ $notes_search_string = "linkname || headline || text LIKE '%".implode("%' AND linkname || headline || text LIKE '%",$q_array)."%'";
+ $notes_search_result = @sqlite_query($db_content, "SELECT note_section, order_id FROM ".Database::$db_settings['notes_table']." WHERE ".$notes_search_string." ORDER BY order_id DESC");
+ while($row_n1 = sqlite_fetch_array($notes_search_result))
+ {
+ $notes_pages_result = @sqlite_query($db_content, "SELECT id FROM ".Database::$db_settings['pages_table']." WHERE type='notes' AND type_addition='".$row_n1['note_section']."'");
+ while($row_n2 = sqlite_fetch_array($notes_pages_result))
+ {
+ // discard notes result if page is already in page results:
+ if(empty($found_ids) || isset($found_ids) && !in_array($row_n2['id'],$found_ids))
+ {
+ $found_ids_notes[] = $row_n2['id'];
+ // page nr of notes page
+ $found_page_nr[$row_n2['id']] = ceil($row_n1['order_id'] / $settings['notes_per_page']);
+ }
+ }
+ }
+ */
+
+ // search photos:
+ /*
+ $photo_search_clause = '';
+ for($i=0;$i<$number_of_words;++$i)
+ {
+ $photo_search_clause .= $photo_clause;
+ if($i<$number_of_words-1)
+ {
+ $photo_search_clause .= ' AND ';
+ }
+ }
+ $dbr = Database::$content->prepare("SELECT id,title,subtitle,description FROM ".Database::$db_settings['photo_table']." WHERE ".$photo_search_clause);
+ for($i=0;$i<$number_of_words;++$i)
+ {
+ $dbr->bindValue($i+1, '%'.$q_array[$i].'%', PDO::PARAM_STR);
+ }
+ $dbr->execute();
+ while($data = $dbr->fetch())
+ {
+ $result_photos[$data['id']]['id'] = $data['id'];
+ $result_photos[$data['id']]['type'] = 1;
+ $result_photos[$data['id']]['relevance'] = 0;
+ $result_photos[$data['id']]['page'] = PAGE.','.IMAGE_IDENTIFIER.','.$data['id'];
+ $result_photos[$data['id']]['title'] = $data['title'];
+ $result_photos[$data['id']]['description'] = '';
+ }
+ */
+ // merge results:
+ if(isset($result_pages))
+ {
+ foreach($result_pages as $result_page)
+ {
+ $results[] = $result_page;
+ }
+ }
+ if(isset($result_photos))
+ {
+ foreach($result_photos as $result_photo)
+ {
+ $results[] = $result_photo;
+ }
+ }
+
+
+ if(isset($results))
+ {
+ // sort by relevance:
+ foreach($results as $key => $val)
+ {
+ $relevance[$key] = $val['relevance'];
+ }
+ array_multisort($relevance, SORT_DESC, $results);
+
+ $result_count = count($results);
+
+ $total_pages = ceil($result_count / $settings['search_results_per_page']);
+ if($current_page>$total_pages) $curret_page = $total_pages;
+ if($current_page<1) $current_page=1;
+
+ #$displayed_count = 0;
+ for($i=($current_page-1)*$settings['search_results_per_page'];$i<$current_page*$settings['search_results_per_page'];++$i)
+ {
+ if(isset($results[$i]))
+ {
+ $displayed_results[] = $results[$i];
+ #$displayed_count++;
+ }
+ }
+
+ $template->assign('pagination', pagination($total_pages,$current_page));
+
+ $template->assign('results', $displayed_results);
+
+ switch($result_count)
+ {
+ case 0:
+ $localization->selectVariant('search_number_of_results', 0);
+ break;
+ case 1:
+ $localization->selectVariant('search_number_of_results', 1);
+ break;
+ default:
+ $localization->selectVariant('search_number_of_results', 2);
+ $localization->replacePlaceholder('pages', $result_count, 'search_number_of_results');
+ }
+ #$loc->select_variant('search_number_of_results', 0);
+ $localization->replacePlaceholder('current_page', $current_page, 'pagination');
+ $localization->replacePlaceholder('total_pages', $total_pages, 'pagination');
+ }
+ }
+
+$template->assign('subtemplate', 'search.inc.tpl');
+
+if(isset($cache) && empty($no_cache))
+ {
+ $cache->cacheId = PAGE;
+ }
+?>
diff --git a/cms/includes/page_types/simple_news.php b/cms/includes/page_types/simple_news.php
new file mode 100644
index 0000000..a754dda
--- /dev/null
+++ b/cms/includes/page_types/simple_news.php
@@ -0,0 +1,332 @@
+prepare("DELETE FROM ".Database::$db_settings['news_table']." WHERE id=:id");
+ $dbr->bindParam(':id', $delete_id, PDO::PARAM_INT);
+ $dbr->execute();
+ #if(isset($cache)) $cache->clear(PAGE);
+ if(isset($cache)) $cache->clear();
+ header('Location: '.BASE_URL.PAGE);
+ exit;
+ }
+
+if($authorized_to_edit && isset($_POST['text']))
+ {
+ $title = isset($_POST['title']) ? trim($_POST['title']) : '';
+ $teaser = isset($_POST['teaser']) ? trim($_POST['teaser']) : '';
+ $text = isset($_POST['text']) ? trim($_POST['text']) : '';
+ $text_formatting = isset($_POST['text_formatting']) && $_POST['text_formatting']==1 ? 1 : 0;
+ $linkname = isset($_POST['linkname']) ? trim($_POST['linkname']) : '';
+ $time = isset($_POST['time']) && trim($_POST['time'])!='' ? trim($_POST['time']) : date("Y-m-d H:i:s");
+
+ if(empty($title))
+ {
+ $errors[] = 'error_news_no_title';
+ }
+ if(empty($text))
+ {
+ $errors[] = 'error_news_no_text';
+ }
+ if(($time = strtotime($time))===false)
+ {
+ $errors[] = 'error_news_time_invalid';
+ }
+
+ if(empty($errors))
+ {
+ if(isset($_POST['id']))
+ {
+ $dbr = Database::$content->prepare("UPDATE ".Database::$db_settings['news_table']." SET time=:time, title=:title, teaser=:teaser, text=:text, text_formatting=:text_formatting, linkname=:linkname WHERE id=:id");
+ $dbr->bindParam(':id', $_POST['id'], PDO::PARAM_INT);
+ $dbr->bindParam(':time', $time, PDO::PARAM_INT);
+ $dbr->bindParam(':title', $title, PDO::PARAM_STR);
+ $dbr->bindParam(':teaser', $teaser, PDO::PARAM_STR);
+ $dbr->bindParam(':text', $text, PDO::PARAM_STR);
+ $dbr->bindParam(':text_formatting', $text_formatting, PDO::PARAM_INT);
+ $dbr->bindParam(':linkname', $linkname, PDO::PARAM_STR);
+ $dbr->execute();
+ $id = $_POST['id'];
+ }
+ else
+ {
+ $dbr = Database::$content->prepare("INSERT INTO ".Database::$db_settings['news_table']." (page_id,time,title,teaser,text,text_formatting,linkname) VALUES (:page_id,:time,:title,:teaser,:text,:text_formatting,:linkname)");
+ $dbr->bindParam(':page_id', $data['id'], PDO::PARAM_INT);
+ $dbr->bindParam(':time', $time, PDO::PARAM_INT);
+ $dbr->bindParam(':title', $title, PDO::PARAM_STR);
+ $dbr->bindParam(':teaser', $teaser, PDO::PARAM_STR);
+ $dbr->bindParam(':text', $text, PDO::PARAM_STR);
+ $dbr->bindParam(':text_formatting', $text_formatting, PDO::PARAM_INT);
+ $dbr->bindParam(':linkname', $linkname, PDO::PARAM_STR);
+ $dbr->execute();
+ #$id = $dbr->lastInsertId();
+ // get last insert ID:
+ $dbr = Database::$content->prepare("SELECT id FROM ".Database::$db_settings['news_table']." ORDER BY id DESC LIMIT 1");
+ $dbr->execute();
+ $last_insert_data = $dbr->fetch();
+ if(isset($last_insert_data['id'])) $id = $last_insert_data['id'];
+ }
+ #if(isset($cache)) $cache->clear(PAGE);
+ if(isset($cache)) $cache->clear();
+ if(isset($id)) header('Location: '.BASE_URL.PAGE.','.$id);
+ else header('Location: '.BASE_URL.PAGE);
+ exit;
+ }
+ else
+ {
+ if(isset($_POST['id']))
+ {
+ $edit_news['id'] = intval($_POST['id']);
+ $breadcrumbs = get_breadcrumbs($data['breadcrumbs']);
+ $breadcrumbs[] = array('page'=>PAGE, 'title'=>$data['title']);
+ if(!empty($_POST['title'])) $breadcrumbs[] = array('page'=>PAGE.','.$edit_news['id'], 'title'=>htmlspecialchars($_POST['title']));
+ else $breadcrumbs[] = array('page'=>PAGE.','.$edit_news['id'], 'title'=>'???');
+ $template->assign('breadcrumbs', $breadcrumbs);
+ $template->assign('title', Localization::$lang['simple_news_edit_item']);
+ $template->assign('headline', '');
+ }
+ else
+ {
+ $breadcrumbs = get_breadcrumbs($data['breadcrumbs']);
+ $breadcrumbs[] = array('page'=>PAGE, 'title'=>$data['title']);
+ $template->assign('breadcrumbs', $breadcrumbs);
+ $template->assign('title', Localization::$lang['simple_news_add_item']);
+ #$template->assign('headline', Localization::$lang['simple_news_add_item']);
+ $template->assign('headline', '');
+ }
+ $edit_news['title'] = isset($_POST['title']) ? htmlspecialchars($_POST['title']) : '';
+ $edit_news['teaser'] = isset($_POST['teaser']) ? htmlspecialchars($_POST['teaser']) : '';
+ $edit_news['text'] = isset($_POST['text']) ? htmlspecialchars($_POST['text']) : '';
+ $edit_news['text_formatting'] = isset($_POST['text_formatting']) && $_POST['text_formatting']==1 ? 1 : 0;
+ $edit_news['link'] = isset($_POST['link']) ? htmlspecialchars($_POST['link']) : '';
+ $edit_news['linkname'] = isset($_POST['linkname']) ? htmlspecialchars($_POST['linkname']) : '';
+ $edit_news['time'] = isset($_POST['time']) ? htmlspecialchars($_POST['time']) : date("Y-m-d H:i:s");
+ $edit_news['note_section'] = isset($_POST['note_section']) ? htmlspecialchars($_POST['note_section']) : '';
+ $template->assign('edit_news', $edit_news);
+ $template->assign('errors', $errors);
+ $template->assign('edit_news', $edit_news);
+ if($settings['wysiwyg_editor'] && isset($_SESSION[$settings['session_prefix'].'wysiwyg']) && $_SESSION[$settings['session_prefix'].'wysiwyg']==1) $template->assign('wysiwyg', true);
+ $template->assign('hide_content', true);
+ }
+ }
+
+if($authorized_to_edit && isset($_GET['get_1']) && $_GET['get_1']=='add_item')
+ {
+ $edit_news['text_formatting'] = $settings['default_formatting'];
+ $edit_news['text_formatting'] = 1;
+ $edit_news['linkname'] = Localization::$lang['simple_news_default_linkname'];
+ $edit_news['time'] = date("Y-m-d H:i:s", time());
+ if($settings['wysiwyg_editor'] && isset($_SESSION[$settings['session_prefix'].'wysiwyg']) && $_SESSION[$settings['session_prefix'].'wysiwyg']==1) $template->assign('wysiwyg', true);
+
+ $template->assign('hide_content', true);
+ $template->assign('title', Localization::$lang['simple_news_add_item']);
+
+ $breadcrumbs = get_breadcrumbs($data['breadcrumbs']);
+ $breadcrumbs[] = array('page'=>PAGE, 'title'=>$data['title']);
+ #$breadcrumbs[] = array('page'=>PAGE.','.$edit_news_item_data['id'], 'title'=>htmlspecialchars($edit_news_item_data['title']));
+ $template->assign('breadcrumbs', $breadcrumbs);
+
+ #$template->assign('headline', Localization::$lang['simple_news_add_item']);
+ $template->assign('headline', '');
+ $template->assign('edit_news', $edit_news);
+ }
+elseif($authorized_to_edit && isset($_GET['get_1']) && isset($_GET['get_2']) && $_GET['get_2']=='edit')
+ {
+ $dbr = Database::$content->prepare("SELECT id, time, title, teaser, text, text_formatting, linkname FROM ".Database::$db_settings['news_table']." WHERE id=:id LIMIT 1");
+ $dbr->bindParam(':id', $_GET['get_1'], PDO::PARAM_STR);
+ $dbr->execute();
+ $edit_news_item_data = $dbr->fetch();
+ if(isset($edit_news_item_data['id']))
+ {
+ $edit_news['id'] = $edit_news_item_data['id'];
+ $edit_news['title'] = htmlspecialchars($edit_news_item_data['title']);
+ $edit_news['teaser'] = htmlspecialchars($edit_news_item_data['teaser']);
+ $edit_news['text'] = htmlspecialchars($edit_news_item_data['text']);
+ $edit_news['text_formatting'] = $edit_news_item_data['text_formatting'];
+ $edit_news['linkname'] = htmlspecialchars($edit_news_item_data['linkname']);
+ $edit_news['time'] = date("Y-m-d H:i:s", $edit_news_item_data['time']);
+ $template->assign('edit_news', $edit_news);
+ if($settings['wysiwyg_editor'] && isset($_SESSION[$settings['session_prefix'].'wysiwyg']) && $_SESSION[$settings['session_prefix'].'wysiwyg']==1) $template->assign('wysiwyg', true);
+
+ $template->assign('hide_content', true);
+ $template->assign('title', Localization::$lang['simple_news_edit_item']);
+
+ $breadcrumbs = get_breadcrumbs($data['breadcrumbs']);
+ $breadcrumbs[] = array('page'=>PAGE, 'title'=>$data['title']);
+ $breadcrumbs[] = array('page'=>PAGE.','.$edit_news_item_data['id'], 'title'=>htmlspecialchars($edit_news_item_data['title']));
+ $template->assign('breadcrumbs', $breadcrumbs);
+
+ #$template->assign('headline', Localization::$lang['simple_news_edit_item']);
+ $template->assign('headline', '');
+ }
+ else
+ {
+ #$no_cache = true;
+ header($_SERVER['SERVER_PROTOCOL'] . " 404 Not Found");
+ header("Status: 404 Not Found");
+ header('Location: '.BASE_URL.PAGE);
+ exit;
+ }
+ }
+elseif($authorized_to_edit && isset($_GET['get_1']) && isset($_GET['get_2']) && $_GET['get_2']=='delete')
+ {
+ $dbr = Database::$content->prepare("SELECT id, time, title, teaser, text, text_formatting, linkname FROM ".Database::$db_settings['news_table']." WHERE id=:id LIMIT 1");
+ $dbr->bindParam(':id', $_GET['get_1'], PDO::PARAM_STR);
+ $dbr->execute();
+ $delete_news_item_data = $dbr->fetch();
+ if(isset($delete_news_item_data['id']))
+ {
+ $delete_news['id'] = $delete_news_item_data['id'];
+ $delete_news['title'] = htmlspecialchars($delete_news_item_data['title']);
+
+ $breadcrumbs = get_breadcrumbs($data['breadcrumbs']);
+ $breadcrumbs[] = array('page'=>PAGE, 'title'=>$data['title']);
+ $template->assign('breadcrumbs', $breadcrumbs);
+
+ $template->assign('title', Localization::$lang['delete_news_title']);
+ $template->assign('headline', Localization::$lang['delete_news_title']);
+ $template->assign('delete_news', $delete_news);
+ $template->assign('hide_content', true);
+ }
+ }
+elseif(isset($_GET['get_1']) && $_GET['get_1']=='rss')
+ {
+ $rss = true;
+ $dbr = Database::$content->prepare("SELECT id, time, title, teaser, text, text_formatting, linkname FROM ".Database::$db_settings['news_table']." WHERE page_id=:page_id AND time<=:now ORDER BY time DESC LIMIT ".$settings['rss_maximum_items']);
+ $dbr->bindParam(':page_id', $data['id'], PDO::PARAM_STR);
+ $dbr->bindValue(':now', time(), PDO::PARAM_STR);
+ $dbr->execute();
+ $i=0;
+ while($rss_data = $dbr->fetch())
+ {
+ $rss_items[$i]['title'] = htmlspecialchars($rss_data['title']);
+ if($rss_data['teaser'] && $settings['enable_fullfeeds']==0)
+ {
+ $rss_items[$i]['content'] = $rss_data['teaser'];
+ }
+ else
+ {
+ if($rss_data['text_formatting']==1) $rss_items[$i]['content'] = auto_html($rss_data['text']);
+ else $rss_items[$i]['content'] = $rss_data['text'];
+ }
+ $rss_items[$i]['linkname'] = htmlspecialchars($rss_data['linkname']);
+ $rss_items[$i]['link'] = BASE_URL.PAGE.','.$rss_data['id'];
+ $rss_items[$i]['pubdate'] = gmdate('r',$rss_data['time']);
+ $i++;
+ }
+ if(isset($rss_items)) $template->assign('rss_items', $rss_items);
+ $content_type = 'text/xml';
+ $template_file = 'rss.tpl';
+
+ }
+elseif(isset($_GET['get_1']) && intval($_GET['get_1'])>0) // item opened
+ {
+ $dbr = Database::$content->prepare("SELECT id, time, title, teaser, text, text_formatting FROM ".Database::$db_settings['news_table']." WHERE id=:id LIMIT 1");
+ $dbr->bindParam(':id', $_GET['get_1'], PDO::PARAM_STR);
+ $dbr->execute();
+ $note_data = $dbr->fetch();
+ if(isset($note_data['id']))
+ {
+ $news_item['id'] = $note_data['id'];
+ $news_item['title'] = htmlspecialchars($note_data['title']);
+ $news_item['teaser'] = htmlspecialchars($note_data['teaser']);
+ if($note_data['text_formatting']==1) $news_item['text'] = auto_html($note_data['text']);
+ else $news_item['text'] = $note_data['text'];
+ $news_item['time'] = date("Y-m-d H:i:s", $note_data['time']);
+ $template->assign('display_time', true);
+ $localization->replacePlaceholder('time', $note_data['time'], 'page_time', Localization::FORMAT_TIME);
+
+ $template->assign('hide_content', true);
+ $template->assign('title', $note_data['title']);
+ $template->assign('headline', $note_data['title']);
+ $template->assign('news_item',$news_item);
+
+ $breadcrumbs = get_breadcrumbs($data['breadcrumbs']);
+ $breadcrumbs[] = array('page'=>PAGE, 'title'=>$data['title']);
+ $template->assign('breadcrumbs', $breadcrumbs);
+
+ $template->assign('keywords', '');
+ $template->assign('description', '');
+
+ $news_item_id = $note_data['id'];
+ }
+ else
+ {
+ #$no_cache = true;
+ header($_SERVER['SERVER_PROTOCOL'] . " 404 Not Found");
+ header("Status: 404 Not Found");
+ header('Location: '.BASE_URL.PAGE);
+ exit;
+ }
+ }
+else // overview
+ {
+ $dbr = Database::$content->prepare("SELECT COUNT(*) FROM ".Database::$db_settings['news_table']." WHERE page_id=:page_id"); // AND time<=:now
+ $dbr->bindParam(':page_id', $data['id'], PDO::PARAM_STR);
+ //$dbr->bindValue(':now', time(), PDO::PARAM_STR);
+ $dbr->execute();
+ $total_items = $dbr->fetchColumn();
+
+ $total_pages = ceil($total_items / $settings['simple_news_per_page']);
+
+ if(isset($_GET['get_2'])) $current_page = intval($_GET['get_2']); else $current_page = 1;
+ if($current_page<1) $current_page = 1;
+ if($current_page>$total_pages) $current_page = $total_pages;
+
+ $dbr = Database::$content->prepare("SELECT id, time, title, teaser, text, text_formatting, linkname FROM ".Database::$db_settings['news_table']." WHERE page_id=:page_id ORDER BY time DESC LIMIT ".(($current_page-1)*$settings['simple_news_per_page']).", ".$settings['simple_news_per_page']); // AND time<=:now
+ $dbr->bindParam(':page_id', $data['id'], PDO::PARAM_STR);
+ //$dbr->bindValue(':now', time(), PDO::PARAM_STR);
+ $dbr->execute();
+ $i=0;
+ while($news_data = $dbr->fetch())
+ {
+ $news[$i]['id'] = $news_data['id'];
+ $news[$i]['time'] = $news_data['time'];
+ $news[$i]['title'] = $news_data['title'];
+ $news[$i]['teaser'] = $news_data['teaser'];
+ if($news_data['text_formatting']==1) $news[$i]['text'] = auto_html($news_data['text']);
+ else $news[$i]['text'] = $news_data['text'];
+ $news[$i]['linkname'] = $news_data['linkname'];
+ $localization->bindReplacePlaceholder($news_data['id'], 'time', $news_data['time'], 'simple_news_time', Localization::FORMAT_TIME);
+ $i++;
+ }
+ if(isset($news))
+ {
+ $template->assign('news', $news);
+ }
+
+ $localization->replacePlaceholder('current_page', $current_page, 'pagination');
+ $localization->replacePlaceholder('total_pages', $total_pages, 'pagination');
+
+ $template->assign('pagination', pagination($total_pages,$current_page));
+ }
+
+if(empty($rss)) $template->assign('subtemplate', 'simple_news.inc.tpl');
+
+if(isset($cache))
+ {
+ if(isset($rss))
+ {
+ $cache->cacheId = PAGE . ',rss';
+ }
+ elseif(isset($news_item_id))
+ {
+ $cache->cacheId = PAGE . ',' . $news_item_id;
+ }
+ elseif(isset($current_page) && $current_page > 1)
+ {
+ $cache->cacheId = PAGE . ',,' . $current_page;
+ }
+ else
+ {
+ $cache->cacheId = PAGE;
+ }
+ }
+?>
diff --git a/cms/includes/page_types/sitemap.php b/cms/includes/page_types/sitemap.php
new file mode 100644
index 0000000..cf03e2f
--- /dev/null
+++ b/cms/includes/page_types/sitemap.php
@@ -0,0 +1,32 @@
+prepare("SELECT id, page, title, teaser, time, last_modified FROM ".Database::$db_settings['pages_table']." WHERE include_sitemap=:include_sitemap AND time<=:time AND status!=0 ORDER BY last_modified DESC");
+$dbr->bindParam(':include_sitemap', $page_id, PDO::PARAM_INT);
+$dbr->bindParam(':time', $current_time, PDO::PARAM_INT);
+$dbr->execute();
+$i=0;
+while($data = $dbr->fetch())
+ {
+ if($data['page']==$settings['index_page']) $sitemap_items[$i]['loc'] = addslashes(BASE_URL);
+ else $sitemap_items[$i]['loc'] = addslashes(BASE_URL.$data['page']);
+ $sitemap_items[$i]['lastmod'] = date('Y-m-d',$data['last_modified']);
+ $i++;
+ }
+
+if(isset($sitemap_items))
+ {
+ $template->assign('sitemap_items',$sitemap_items);
+ }
+
+#$localization->assign('charset', 'utf-8');
+$content_type = 'text/xml';
+$template_file = 'sitemap.tpl';
+
+if(isset($cache))
+ {
+ $cache->cacheId = PAGE;
+ }
+?>
diff --git a/cms/includes/pages.inc.php b/cms/includes/pages.inc.php
new file mode 100644
index 0000000..f63f2fb
--- /dev/null
+++ b/cms/includes/pages.inc.php
@@ -0,0 +1,163 @@
+'.$lang['create_new_page'].'';
+
+ // delete page:
+ if(isset($_REQUEST['delete_page']))
+ {
+ $dbr = Database::$content->prepare("SELECT id, page, title, author, edit_permission, edit_permission_general FROM ".Database::$db_settings['pages_table']." WHERE id=:id LIMIT 1");
+ $dbr->bindParam(':id', $_REQUEST['delete_page'], PDO::PARAM_INT);
+ $dbr->execute();
+ $data = $dbr->fetch();
+ if(!isset($data['id']))
+ {
+ $action='invalid_page';
+ }
+ elseif(!is_authorized_to_edit($_SESSION[$settings['session_prefix'].'user_id'],$_SESSION[$settings['session_prefix'].'user_type'],$data['author'],$data['edit_permission'],$data['edit_permission_general']))
+ {
+ $action='no_authorization';
+ }
+ else
+ {
+ if(isset($_REQUEST['confirmed']))
+ {
+ // delete page:
+ $dbr = Database::$content->prepare("DELETE FROM ".Database::$db_settings['pages_table']." WHERE id=:id");
+ $dbr->bindParam(':id', $_REQUEST['delete_page'], PDO::PARAM_INT);
+ $dbr->execute();
+ // delete comments:
+ $dbr = Database::$entries->prepare("DELETE FROM ".Database::$db_settings['comment_table']." WHERE comment_id=:id AND type=0");
+ $dbr->bindParam(':id', $_REQUEST['delete_page'], PDO::PARAM_INT);
+ $dbr->execute();
+ // delete news entries:
+ $dbr = Database::$content->prepare("DELETE FROM ".Database::$db_settings['news_table']." WHERE page_id=:id");
+ $dbr->bindParam(':id', $_REQUEST['delete_page'], PDO::PARAM_INT);
+ $dbr->execute();
+ if(isset($cache) && $cache->autoClear) $cache->clear();
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=pages');
+ exit;
+ }
+ else $action='delete_page';
+ }
+ }
+
+ if(isset($_GET['reset_views']) && $_SESSION[$settings['session_prefix'].'user_type']==1)
+ {
+ $timestamp_now = time();
+ $dbr = Database::$content->query("UPDATE ".Database::$db_settings['pages_table']." SET views=0");
+ $dbr = Database::$content->prepare("UPDATE ".Database::$db_settings['settings_table']." SET value=:value WHERE name='counter_last_resetted'");
+ $dbr->bindParam(':value', $timestamp_now, PDO::PARAM_INT);
+ $dbr->execute();
+ $settings['counter_last_resetted'] = $timestamp_now;
+ $action='main';
+ }
+
+ if(isset($_GET['action'])) $action = $_GET['action'];
+ if(isset($_POST['action'])) $action = $_POST['action'];
+ if(empty($action)) $action = 'main';
+
+ switch($action)
+ {
+ case 'main':
+ if(isset($_GET['order']))
+ {
+ switch($_GET['order'])
+ {
+ case 'title':
+ $order='title';
+ break;
+ case 'time':
+ $order='time';
+ break;
+ case 'last_modified':
+ $order='last_modified';
+ break;
+ case 'views':
+ $order='views';
+ break;
+ default:
+ $order = 'page';
+ }
+ }
+ else
+ {
+ $order = 'page';
+ }
+
+ if(isset($_GET['descasc']) && $_GET['descasc']=='DESC') $descasc = 'DESC'; else $descasc = 'ASC';
+
+ if(empty($order)) $order="id";
+ if(empty($descasc)) $descasc="ASC";
+
+ $template->assign('order',$order);
+ $template->assign('descasc',$descasc);
+
+ // user names:
+ $user_result = Database::$userdata->query("SELECT id, name FROM ".Database::$db_settings['userdata_table']);
+ while($userdata = $user_result->fetch())
+ {
+ $users[$userdata['id']] = htmlspecialchars($userdata['name']);
+ }
+ if(isset($users))
+ {
+ $template->assign('users',$users);
+ }
+
+ #$dbr = Database::$content->prepare("SELECT COUNT(*) FROM ".Database::$db_settings['pages_table']." ORDER BY :order :descasc");
+ #$dbr->bindParam(':order', $order, PDO::PARAM_STR);
+ #$dbr->bindParam(':descasc', $descasc, PDO::PARAM_STR);
+ #$dbr->execute();
+ #$total_pages = $dbr-> fetchColumn();
+
+ $dbr = Database::$content->query("SELECT id, page, author, title, time, last_modified, last_modified_by, status, views, edit_permission, edit_permission_general FROM ".Database::$db_settings['pages_table']." ORDER BY ".$order." ".$descasc);
+ #print_r(Database::$content->errorInfo());
+ #$dbr->bindParam(':order', $order, PDO::PARAM_STR);
+ #$dbr->bindParam(':descasc', $descasc, PDO::PARAM_STR);
+ #$dbr->execute();
+ $i=0;
+ while($row = $dbr->fetch())
+ {
+ $pages_data[$i]['id'] = $row['id'];
+ $pages_data[$i]['page'] = $row['page'];
+ $pages_data[$i]['author'] = $row['author'];
+ $pages_data[$i]['title'] = $row['title'];
+ $pages_data[$i]['time'] = $row['time'];
+ $pages_data[$i]['last_modified'] = $row['last_modified'];
+ $pages_data[$i]['last_modified_by'] = $row['last_modified_by'];
+ $pages_data[$i]['status'] = $row['status'];
+ $pages_data[$i]['views'] = $row['views'];
+ #$pages_data[$i]['edit_permission'] = $row['edit_permission'];
+ #$pages_data[$i]['edit_permission_general'] = $row['edit_permission_general'];
+ if(is_authorized_to_edit($_SESSION[$settings['session_prefix'].'user_id'],$_SESSION[$settings['session_prefix'].'user_type'],$row['author'],$row['edit_permission'],$row['edit_permission_general']))
+ {
+ $pages_data[$i]['edit_permission'] = true;
+ }
+ else
+ {
+ $pages_data[$i]['edit_permission'] = false;
+ }
+ ++$i;
+ }
+
+ if(isset($pages_data))
+ {
+ $template->assign('pages',$pages_data);
+ $template->assign('subtemplate', 'pages.inc.tpl');
+ }
+ break;
+ case 'delete_page':
+ $template->assign('page',$data);
+ $template->assign('subtemplate', 'delete_page.inc.tpl');
+ break;
+ case 'invalid_page':
+ $template->assign('error_message',Localization::$lang['page_doesnt_exist']);
+ break;
+ case 'no_authorization':
+ $template->assign('error_message',Localization::$lang['no_authorization_edit']);
+ break;
+ }
+
+ }
diff --git a/cms/includes/photo.inc.php b/cms/includes/photo.inc.php
new file mode 100644
index 0000000..853f66e
--- /dev/null
+++ b/cms/includes/photo.inc.php
@@ -0,0 +1,106 @@
+prepare($content_query);
+$dbr->bindValue(':page', PAGE, PDO::PARAM_STR);
+$dbr->execute();
+$data = $dbr->fetch();
+if(empty($data['id']))
+ {
+ $no_cache = true;
+ if($data=get_content($settings['error_page']))
+ {
+ header($_SERVER['SERVER_PROTOCOL'] . " 404 Not Found");
+ header("Status: 404 Not Found");
+ include(BASE_PATH.'cms/includes/content.inc.php');
+ }
+ else
+ {
+ raise_error('404');
+ }
+ }
+else
+ {
+ $photo = new ShowPhoto($_GET['get_2']);
+ $photo_data = $photo->get_photo_data();
+ if(isset($photo_data['id']) && $photo_page_check = is_vailid_photo_page($data['content'], $data['type'], $data['type_addition'], $photo_data['gallery'], $photo_data['gallery_items']))
+ {
+ if(empty($data['language'])) $language_file = $settings['default_page_language'].'.page.lang.php';
+ else $language_file = $data['language'].'.page.lang.php';
+
+ #require('./cms/includes/classes/Localization.class.php');
+ #$loc = new Localization('./cms/lang/'.$language_file);
+ $localization = new Localization(BASE_PATH.'cms/lang/'.$language_file);
+
+ mb_internal_encoding(Localization::$lang['charset']);
+
+ #require('./cms/lang/'.$language_file);
+ #$template->set_lang($lang);
+
+ setlocale(LC_ALL, Localization::$lang['locale']);
+ define('CHARSET', Localization::$lang['charset']);
+ #define('TIME_FORMAT', Localization::$lang['time_format']);
+ #define('TIME_FORMAT_FULL', Localization::$lang['time_format_full']);
+ $localization->replacePlaceholder('page', $data['title'], 'back_title');
+
+ $template->assign('website_title', $settings['website_title']);
+ $template->assign('photo_data', $photo_data);
+ $template->assign('page', $data['page']);
+ $template->assign('title', $data['title']);
+
+ $template->assign('settings', $settings);
+ if(isset($_SESSION[$settings['session_prefix'].'user_id'])) $template->assign('admin', true);
+
+ // photo comments:
+ if($settings['photos_commentable'] == 1)
+ {
+ $show_comments = $photo -> show_comments();
+ $template->assign('show_comments', $show_comments);
+ include(BASE_PATH.'cms/includes/photo_comment.inc.php');
+ }
+ #header('Content-Type: text/html; charset='.$lang['charset']);
+ #$template->display('./templates/'.$photo_data['template']);
+
+ $content_type = 'text/html';
+ $charset = Localization::$lang['charset'];
+ $template_file = $photo_data['template'];
+
+ if($photo_page_check==1)
+ {
+ if(isset($_COOKIE[$settings['session_prefix'].'search']))
+ {
+ $cookie_parts = explode(' ', $_COOKIE[$settings['session_prefix'].'search']);
+ $page_addition = ',,'.htmlspecialchars($cookie_parts[0]);
+ if(isset($cookie_parts[1]) && intval($cookie_parts[1])>1)
+ {
+ $page_addition .= ','.intval($cookie_parts[1]);
+ }
+ $template->assign('page_addition', $page_addition);
+ }
+ }
+ elseif($photo_page_check==2 && isset($cache))
+ {
+ $page_addition = ','.IMAGE_IDENTIFIER.','.$photo->photo_data['id'];
+ if($photo->photo_data['photo_size'] > 0) $page_addition .= ',1';
+ elseif($photo->show_comments > 0) $page_addition .= ',0,1';
+ if(isset($photo_comment->comment_page) && $photo_comment->comment_page > 1) $page_addition .= ','.$photo_comment->comment_page;
+ $cache->cacheId = PAGE . $page_addition;
+ }
+ }
+ else
+ {
+ $no_cache = true;
+ if($data=get_content($settings['error_page']))
+ {
+ header($_SERVER['SERVER_PROTOCOL'] . " 404 Not Found");
+ header("Status: 404 Not Found");
+ include('./cms/includes/content.inc.php');
+ }
+ else
+ {
+ raise_error('404');
+ }
+ }
+ }
+?>
diff --git a/cms/includes/photo_comment.inc.php b/cms/includes/photo_comment.inc.php
new file mode 100644
index 0000000..e5f9685
--- /dev/null
+++ b/cms/includes/photo_comment.inc.php
@@ -0,0 +1,95 @@
+comments_per_page = $settings['comments_per_page'];
+$comment->comment_order = $settings['comment_order'];
+$comment->name_maxlength = $settings['name_maxlength'];
+$comment->email_hp_maxlength = $settings['email_hp_maxlength'];
+$comment->word_maxlength = $settings['word_maxlength'];
+$comment->comment_maxlength = $settings['comment_maxlength'];
+$comment->prevent_repeated_posts_minutes = $settings['prevent_repeated_posts_minutes'];
+$comment->akismet_key = $settings['akismet_key'];
+$comment->akismet_entry_check = $settings['akismet_entry_check'];
+$comment->remove_blank_lines = $settings['comment_remove_blank_lines'];
+$comment->auto_link = $settings['comment_auto_link'];
+$comment->smilies = $settings['comment_smilies'];
+
+if(isset($_SESSION[$settings['session_prefix'].'user_id']))
+ {
+ $comment->set_admin_mode();
+ }
+
+#$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'main';
+
+if(isset($_POST['preview']))
+ {
+ if($preview = $comment->preview())
+ {
+ $template->assign('preview', $preview);
+ }
+ #$action = 'preview';
+ }
+elseif(isset($_POST['save']))
+ {
+ if($comment->form_session==false)
+ {
+ if($preview = $comment->preview())
+ {
+ $template->assign('preview', $preview);
+ }
+ }
+ elseif($comment->save())
+ {
+ if(isset($cache)) $cache->clearPhoto($photo_data['id']);
+ header('Location: '.BASE_URL.PAGE.','.IMAGE_IDENTIFIER.','.$photo_data['id'].',0,1#comments');
+ exit;
+ }
+ }
+elseif(isset($_SESSION[$settings['session_prefix'].'user_id']) && isset($_GET['get_3']) && $_GET['get_3']=='edit' && isset($_GET['get_4']))
+ {
+ $template->assign('edit_data', $comment->get_edit_data($_GET['get_4']));
+ #$action = 'edit';
+ }
+elseif(isset($_POST['edit_save']))
+ {
+ $comment->edit_save();
+ if(isset($cache)) $cache->clearPhoto($photo_data['id']);
+ header('Location: '.BASE_URL.PAGE.','.IMAGE_IDENTIFIER.','.$photo_data['id'].',0,1,'.$comment->current_page.'#comments');
+ }
+elseif(isset($_SESSION[$settings['session_prefix'].'user_id']) && isset($_GET['get_3']) && $_GET['get_3']=='delete' && isset($_GET['get_4']))
+ {
+ $comment->delete($_GET['get_4']);
+ if(isset($cache)) $cache->clearPhoto($photo_data['id']);
+ header('Location: '.BASE_URL.PAGE.','.IMAGE_IDENTIFIER.','.$photo_data['id'].',0,1,'.$comment->current_page.'#comments');
+ }
+
+$template->assign('comments', $comment->get_comments());
+$template->assign('total_comments', $comment->total_comments);
+
+switch($comment->total_comments)
+ {
+ case 0:
+ $localization->selectVariant('number_of_comments', 0);
+ break;
+ case 1:
+ $localization->selectVariant('number_of_comments', 1);
+ break;
+ default:
+ $localization->selectVariant('number_of_comments', 2);
+ $localization->replacePlaceholder('comments', $comment->total_comments, 'number_of_comments');
+ }
+
+
+$template->assign('pagination', pagination($comment->total_pages,$comment->current_page));
+$template->assign('current_page', $comment->current_page);
+$template->assign('errors', $comment->errors);
+
+#if($comment->errors) showme($comment->errors);
+
+#$template->assign('pagination', $comment->get_pagination());
+$template->assign('form_values', $comment->form_values);
+$template->assign('form_session_data', $comment->form_session_data);
+$template->assign('form_session', $comment->form_session);
+
+?>
diff --git a/cms/includes/settings.inc.php b/cms/includes/settings.inc.php
new file mode 100644
index 0000000..a0d3dd3
--- /dev/null
+++ b/cms/includes/settings.inc.php
@@ -0,0 +1,114 @@
+beginTransaction();
+ $dbr = Database::$content->prepare("UPDATE ".Database::$db_settings['settings_table']." SET value=:value WHERE name=:name");
+ $dbr->bindParam(':value', $val, PDO::PARAM_STR);
+ $dbr->bindParam(':name', $key, PDO::PARAM_STR);
+ while(list($key, $val) = each($_POST))
+ {
+ if($key!='settings_submitted' && $key!='clear_cache')
+ {
+ $dbr->execute();
+ }
+ }
+ Database::$content->commit();
+ if(isset($cache) && ($cache->autoClear || isset($_POST['clear_cache'])))
+ {
+ $cache->clear();
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=settings&saved=true&cache_cleared=true');
+ }
+ else
+ {
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=settings&saved=true');
+ }
+ #header('Location: '.BASE_URL.ADMIN_DIR.'index.php?msg=settings_saved');
+ exit;
+ }
+
+ if(isset($_GET['delete']))
+ {
+ $dbr = Database::$content->prepare("DELETE FROM ".Database::$db_settings['settings_table']." WHERE name=:name");
+ $dbr->bindParam(':name', $_GET['delete'], PDO::PARAM_STR);
+ $dbr->execute();
+ if(isset($cache) && $cache->autoClear) $cache->clear();
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=settings&action=advanced_settings');
+ exit;
+ }
+
+ if(isset($_POST['new_var_submitted']))
+ {
+ if(!preg_match('/^[a-zA-Z0-9_\-]+$/', $_POST['name']))
+ {
+ $errors[] = 'error_settings_spec_chars';
+ $action = 'advanced_settings';
+ }
+ if(empty($errors))
+ {
+ $dbr = Database::$content->prepare("INSERT INTO ".Database::$db_settings['settings_table']." (name,value) VALUES (:name, :value)");
+ $dbr->bindParam(':name', $_POST['name'], PDO::PARAM_STR);
+ $dbr->bindParam(':value', $_POST['value'], PDO::PARAM_STR);
+ $dbr->execute();
+ if(isset($cache) && $cache->autoClear) $cache->clear();
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=settings&action=advanced_settings');
+ exit;
+ }
+ else
+ {
+ $template->assign('errors', $errors);
+ }
+ }
+
+ if(isset($_GET['action'])) $action = $_GET['action'];
+ if(empty($action)) $action = 'main_settings';
+
+ if(isset($_GET['saved'])) $template->assign('saved', true);
+ if(isset($_GET['cache_cleared'])) $template->assign('cache_cleared', true);
+
+
+ switch($action)
+ {
+ case 'main_settings':
+ // get available pages:
+ $dbr = Database::$content->query("SELECT id, page FROM ".Database::$db_settings['pages_table']." ORDER BY page ASC");
+ $i=0;
+ while($pages_data = $dbr->fetch())
+ {
+ $pages[$i]['id'] = $pages_data['id'];
+ $pages[$i]['page'] = $pages_data['page'];
+ ++$i;
+ }
+ if(isset($pages))
+ {
+ $template->assign('pages',$pages);
+ }
+
+ $template->assign('page_languages', get_languages());
+ $template->assign('admin_languages', get_languages(true));
+
+ $template->assign('subtitle', Localization::$lang['settings']);
+ $template->assign('subtemplate', 'settings.inc.tpl');
+
+ // WYSIWYG editor available?
+ if(file_exists(BASE_PATH.WYSIWYG_EDITOR))
+ {
+ $template->assign('wysiwyg_editor_available', true);
+ }
+
+ break;
+ case 'advanced_settings';
+ $settings_sorted = array_map('htmlspecialchars', $settings);
+ ksort($settings_sorted);
+ $template->assign('settings_sorted', $settings_sorted);
+ $template->assign('subtitle', Localization::$lang['advanced_settings']);
+ $template->assign('subtemplate', 'settings_advanced.inc.tpl');
+ break;
+ }
+ }
+?>
diff --git a/cms/includes/spam_protection.inc.php b/cms/includes/spam_protection.inc.php
new file mode 100644
index 0000000..f912a85
--- /dev/null
+++ b/cms/includes/spam_protection.inc.php
@@ -0,0 +1,130 @@
+beginTransaction();
+ $dbr = Database::$content->prepare("UPDATE ".Database::$db_settings['banlists_table']." SET list=:list WHERE name=:name");
+ $dbr->bindValue(':name', 'ips', PDO::PARAM_STR);
+ $dbr->bindParam(':list', $banned_ips, PDO::PARAM_STR);
+ $dbr->execute();
+ $dbr->bindValue(':name', 'user_agents', PDO::PARAM_STR);
+ $dbr->bindParam(':list', $banned_user_agents, PDO::PARAM_STR);
+ $dbr->execute();
+ $dbr->bindValue(':name', 'words', PDO::PARAM_STR);
+ $dbr->bindParam(':list', $not_accepted_words, PDO::PARAM_STR);
+ $dbr->execute();
+ Database::$content->commit();
+
+ Database::$content->beginTransaction();
+ $dbr = Database::$content->prepare("UPDATE ".Database::$db_settings['settings_table']." SET value=:value WHERE name=:name");
+ $dbr->bindValue(':name', 'akismet_key', PDO::PARAM_STR);
+ $dbr->bindParam(':value', $akismet_key, PDO::PARAM_STR);
+ $dbr->execute();
+ $dbr->bindValue(':name', 'akismet_entry_check', PDO::PARAM_STR);
+ $dbr->bindParam(':value', $akismet_entry_check, PDO::PARAM_STR);
+ $dbr->execute();
+ $dbr->bindValue(':name', 'akismet_mail_check', PDO::PARAM_STR);
+ $dbr->bindParam(':value', $akismet_mail_check, PDO::PARAM_STR);
+ $dbr->execute();
+ $dbr->bindValue(':name', 'check_access_permission', PDO::PARAM_STR);
+ $dbr->bindParam(':value', $check_access_permission, PDO::PARAM_STR);
+ $dbr->execute();
+ Database::$content->commit();
+
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=spam_protection&saved=true');
+ exit;
+ }
+
+ if(isset($errors))
+ {
+ $template->assign('errors',$errors);
+ if(isset($_POST['banned_ips'])) $template->assign('banned_ips',htmlspecialchars(stripslashes($_POST['banned_ips'])));
+ if(isset($_POST['banned_user_agents'])) $template->assign('banned_user_agents',htmlspecialchars(stripslashes($_POST['banned_user_agents'])));
+ if(isset($_POST['not_accepted_words'])) $template->assign('not_accepted_words',htmlspecialchars(stripslashes($_POST['not_accepted_words'])));
+ if(isset($_POST['akismet_key'])) $template->assign('akismet_key',htmlspecialchars(stripslashes($_POST['akismet_key'])));
+ if(isset($_POST['akismet_entry_check'])) $template->assign('akismet_entry_check',intval($_POST['akismet_entry_check']));
+ if(isset($_POST['akismet_mail_check'])) $template->assign('akismet_mail_check',intval($_POST['akismet_mail_check']));
+
+ }
+
+ }
+ else
+ {
+ $dbr = Database::$content->query("SELECT name, list FROM ".Database::$db_settings['banlists_table']);
+ while($data = $dbr->fetch())
+ {
+ switch($data['name'])
+ {
+ case 'ips':
+ $template->assign('banned_ips',htmlspecialchars(stripslashes($data['list'])));
+ break;
+ case 'user_agents':
+ $template->assign('banned_user_agents',htmlspecialchars(stripslashes($data['list'])));
+ break;
+ case 'words':
+ $template->assign('not_accepted_words',htmlspecialchars(stripslashes($data['list'])));
+ break;
+ }
+ }
+ $template->assign('akismet_key',htmlspecialchars(stripslashes($settings['akismet_key'])));
+ $template->assign('akismet_entry_check',intval($settings['akismet_entry_check']));
+ $template->assign('akismet_mail_check',intval($settings['akismet_mail_check']));
+ }
+ if(isset($_GET['saved']))
+ {
+ $template->assign('saved',true);
+ }
+ $template->assign('subtitle',Localization::$lang['spam_protection']);
+ $template->assign('subtemplate','spam_protection.inc.tpl');
+ }
diff --git a/cms/includes/users.inc.php b/cms/includes/users.inc.php
new file mode 100644
index 0000000..dcf6d95
--- /dev/null
+++ b/cms/includes/users.inc.php
@@ -0,0 +1,270 @@
+prepare("SELECT COUNT(*) FROM ".Database::$db_settings['userdata_table']." WHERE lower(name)=:name");
+ $dbr->bindValue(':name', mb_strtolower(trim($_POST['name']),CHARSET), PDO::PARAM_STR);
+ $dbr->execute();
+ if($dbr->fetchColumn()!=0)
+ {
+ $errors[] = 'error_username_alr_exists';
+ }
+ }
+ if(empty($errors))
+ {
+ $pw_hash = generate_pw_hash($_POST['pw']);
+ $dbr = Database::$userdata->prepare("INSERT INTO ".Database::$db_settings['userdata_table']." (name,type,pw,last_login) VALUES (:name,0,:pw,0)");
+ $dbr->bindValue(':name', trim($_POST['name']), PDO::PARAM_STR);
+ $dbr->bindParam(':pw', $pw_hash, PDO::PARAM_STR);
+ $dbr->execute();
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=users');
+ exit;
+ }
+ if(isset($errors))
+ {
+ $template->assign('errors',$errors);
+ }
+ $action='new';
+ }
+
+ if(isset($_REQUEST['delete']))
+ {
+ if($_SESSION[$settings['session_prefix'].'user_id']==intval($_REQUEST['delete']))
+ {
+ $errors[] = 'del_yourself_imposs';
+ $template->assign('errors',$errors);
+ $action = 'main';
+ }
+ if(empty($errors))
+ {
+ if(isset($_REQUEST['confirmed']))
+ {
+ $dbr = Database::$userdata->prepare("DELETE FROM ".Database::$db_settings['userdata_table']." WHERE id=:id");
+ $dbr->bindParam(':id', $_REQUEST['delete'], PDO::PARAM_INT);
+ $dbr->execute();
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=users');
+ exit;
+ }
+ else
+ {
+ $dbr = Database::$userdata->prepare("SELECT id, name FROM ".Database::$db_settings['userdata_table']." WHERE id=:id LIMIT 1");
+ $dbr->bindParam(':id', $_REQUEST['delete'], PDO::PARAM_INT);
+ $dbr->execute();
+ $data = $dbr->fetch();
+ if(isset($data['id']))
+ {
+ $userdata['id'] = $data['id'];
+ $userdata['name'] = htmlspecialchars($data['name']);
+ $template->assign('userdata',$userdata);
+ }
+ $action = 'delete_user';
+ }
+ }
+ }
+
+ if(isset($_GET['edit']))
+ {
+ if($_SESSION[$settings['session_prefix'].'user_type']==1)
+ {
+ $dbr = Database::$userdata->prepare("SELECT id, type, name FROM ".Database::$db_settings['userdata_table']." WHERE id=:id LIMIT 1");
+ #if($_SESSION[$settings['session_prefix'].'user_type']==0)
+ # {
+ # $dbr->bindParam(':id', $_SESSION[$settings['session_prefix'].'user_id'], PDO::PARAM_INT);
+ # }
+ #else
+ # {
+ $dbr->bindParam(':id', $_GET['edit'], PDO::PARAM_INT);
+ # }
+ $dbr->execute();
+ $data = $dbr->fetch();
+ if(isset($data['id']))
+ {
+ $userdata['id'] = $data['id'];
+ $userdata['type'] = $data['type'];
+ $userdata['name'] = htmlspecialchars($data['name']);
+ $template->assign('userdata',$userdata);
+ }
+ }
+ $action = 'edit_user';
+ }
+
+ if(isset($_POST['edit_user_submitted']))
+ {
+ if($_SESSION[$settings['session_prefix'].'user_type']==1)
+ {
+ $name=trim($_POST['name']);
+ $new_pw = $_POST['new_pw'];
+ $new_pw_r = $_POST['new_pw_r'];
+ $type = intval($_POST['type']);
+
+ if(empty($_POST['id']) || trim($_POST['name'])=='')
+ {
+ $errors[] = 'error_form_uncomplete';
+ }
+ if(empty($errors))
+ {
+ $dbr = Database::$userdata->prepare("SELECT COUNT(*) FROM ".Database::$db_settings['userdata_table']." WHERE lower(name)=:name AND id!=:id LIMIT 1");
+ $dbr->bindParam(':id', $_POST['id'], PDO::PARAM_INT);
+ $dbr->bindValue(':name', mb_strtolower(trim($_POST['name']), CHARSET), PDO::PARAM_INT);
+ $dbr->execute();
+ if($dbr->fetchColumn()!=0)
+ {
+ $errors[] = 'error_username_alr_exists';
+ }
+ }
+ if(empty($errors))
+ {
+ if(!empty($_POST['new_pw']) && $_POST['new_pw'] != $_POST['new_pw_r'])
+ {
+ $errors[] = 'error_pw_doesnt_comply';
+ }
+ if(intval($_POST['type'])!=0 && intval($_POST['type'])!=1)
+ {
+ $errors[] = 'invalid_user_type';
+ }
+ if($_SESSION[$settings['session_prefix'].'user_id']==intval($_POST['id']) && intval($_POST['type'])==0)
+ {
+ $errors[] = 'rights_limitation_imposs';
+ }
+ }
+ if(empty($errors))
+ {
+ if($_POST['new_pw']!='')
+ {
+ $pw_hash = generate_pw_hash($_POST['new_pw']);
+ $dbr = Database::$userdata->prepare("UPDATE ".Database::$db_settings['userdata_table']." SET name=:name, type=:type, pw=:pw WHERE id=:id");
+ $dbr->bindParam(':id', $_POST['id'], PDO::PARAM_INT);
+ $dbr->bindParam(':type', $_POST['type'], PDO::PARAM_INT);
+ $dbr->bindValue(':name', trim($_POST['name']), PDO::PARAM_STR);
+ $dbr->bindParam(':pw', $pw_hash, PDO::PARAM_STR);
+ $dbr->execute();
+ }
+ else
+ {
+ $dbr = Database::$userdata->prepare("UPDATE ".Database::$db_settings['userdata_table']." SET name=:name, type=:type WHERE id=:id");
+ $dbr->bindParam(':id', $_POST['id'], PDO::PARAM_INT);
+ $dbr->bindParam(':type', $_POST['type'], PDO::PARAM_INT);
+ $dbr->bindValue(':name', trim($_POST['name']), PDO::PARAM_STR);
+ $dbr->execute();
+ }
+ }
+ if(empty($errors))
+ {
+ header('location: '.BASE_URL.ADMIN_DIR.'index.php?mode=users');
+ exit;
+ }
+ }
+ elseif($_SESSION[$settings['session_prefix'].'user_type']==0)
+ {
+ if(empty($_POST['old_pw']) || empty($_POST['new_pw']) || empty($_POST['new_pw_r']))
+ {
+ $errors[] = 'error_form_uncomplete';
+ }
+ if(empty($errors))
+ {
+ $dbr = Database::$userdata->prepare("SELECT pw FROM ".Database::$db_settings['userdata_table']." WHERE id=:id LIMIT 1");
+ $dbr->bindParam(':id', $_SESSION[$settings['session_prefix'].'user_id'], PDO::PARAM_INT);
+ $dbr->execute();
+ $data = $dbr->fetch();
+ if(!is_pw_correct($_POST['old_pw'], $data['pw']))
+ {
+ $errors[] = 'error_pw_wrong';
+ }
+ if($_POST['new_pw']!==$_POST['new_pw_r'])
+ {
+ $errors[] = 'error_pw_doesnt_comply';
+ }
+ }
+ if(empty($errors))
+ {
+ $pw_hash = generate_pw_hash($_POST['new_pw']);
+ $dbr = Database::$userdata->prepare("UPDATE ".Database::$db_settings['userdata_table']." SET pw=:pw WHERE id=:id");
+ $dbr->bindParam(':pw', $pw_hash, PDO::PARAM_STR);
+ $dbr->bindParam(':id', $_SESSION[$settings['session_prefix'].'user_id'], PDO::PARAM_INT);
+ $dbr->execute();
+ }
+ if(empty($errors))
+ {
+ header('Location: '.BASE_URL.ADMIN_DIR.'index.php?mode=users&edit='.$_SESSION[$settings['session_prefix'].'user_id'].'&saved=true');
+ exit;
+ }
+ }
+ if(isset($errors))
+ {
+ $template->assign('errors',$errors);
+ if(isset($_POST['id'])) $userdata['id'] = intval($_POST['id']);
+ if(isset($_POST['type'])) $userdata['type'] = intval($_POST['type']);
+ if(isset($_POST['name'])) $userdata['name'] = htmlspecialchars($_POST['name']);
+ if(isset($userdata)) $template->assign('userdata', $userdata);
+ $action='edit_user';
+ }
+ }
+
+ if(isset($_GET['action'])) $action = $_GET['action'];
+ if(isset($_POST['action'])) $action = $_POST['action'];
+ if(empty($action)) $action = 'main';
+
+ if($_SESSION[$settings['session_prefix'].'user_type']==0 && $action == 'main')
+ {
+ header('location: '.BASE_URL.ADMIN_DIR.'index.php?mode=users&edit='.$_SESSION[$settings['session_prefix'].'user_id']);
+ exit;
+ }
+
+ #if($action!='main' && $_SESSION[$settings['session_prefix'].'user_type']==1) $admin_sub_menu = '« '.$lang['user_overview'].'';
+
+ switch($action)
+ {
+ case 'main':
+ $dbr = Database::$userdata->query("SELECT id, name, type, last_login FROM ".Database::$db_settings['userdata_table']." ORDER BY id ASC");
+ $dbr->execute();
+ $i=0;
+ while($data = $dbr->fetch())
+ {
+ $users[$i]['id'] = intval($data['id']);
+ $users[$i]['name'] = htmlspecialchars($data['name']);
+ $users[$i]['type'] = intval($data['type']);
+ $users[$i]['last_login'] = intval($data['last_login']);
+ ++$i;
+ }
+ if(isset($users))
+ {
+ $template->assign('users', $users);
+ }
+ $template->assign('subtitle', Localization::$lang['users']);
+ $template->assign('subtemplate', 'users.inc.tpl');
+ break;
+ case 'new':
+ $template->assign('subtitle', Localization::$lang['create_user_account']);
+ $template->assign('subtemplate', 'users_new.inc.tpl');
+ break;
+ case 'delete_user':
+ $template->assign('subtitle', Localization::$lang['delete_user']);
+ $template->assign('subtemplate', 'users_delete.inc.tpl');
+ break;
+ case 'edit_user':
+ if(isset($_GET['saved'])) $template->assign('saved', true);
+ $template->assign('subtitle', Localization::$lang['edit_userdata']);
+ $template->assign('subtemplate', 'users_edit.inc.tpl');
+ break;
+ }
+ }
diff --git a/cms/index.php b/cms/index.php
new file mode 100644
index 0000000..753642a
--- /dev/null
+++ b/cms/index.php
@@ -0,0 +1,147 @@
+
+ * @copyright 2006-2010 Mark Alexander Hoschek
+ * @version 2.0.5
+ * @link http://phpsqlitecms.net/
+ * @package phpSQLiteCMS
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+try
+ {
+ session_start();
+ define('IN_INDEX', TRUE);
+ #include('./config/db_settings.conf.php');
+ require('./includes/functions.inc.php');
+ require('./includes/functions.admin.inc.php');
+
+ // load replacement functions for the multibyte string functions
+ // if they are not available:
+ if(!defined('MB_CASE_LOWER')) require('./includes/functions.mb_replacements.inc.php');
+
+ require('./includes/classes/Database.class.php');
+ $database = new Database(Database::ADMIN);
+
+ $settings = get_settings();
+
+ // access permission check for not registered users:
+ if($settings['check_access_permission']==1 && !isset($_SESSION[$settings['session_prefix'].'user_id']))
+ {
+ if(is_access_denied()) raise_error('403');
+ }
+
+ define('VALID_URL_CHARACTERS', '/^[a-zA-Z0-9._\-\/]+$/');
+ #define('VALID_URL_CHARACTERS', '/.*/');
+ #define('VALID_URL_CHARACTERS', '/^[\p{Cyrillic}a-zA-Z0-9._\-\/]+$/u');
+
+ define('ADMIN_DIR', 'cms/');
+ define('MEDIA_DIR', 'static/media/');
+ define('CACHE_DIR', 'cms/cache/');
+ define('IMAGE_IDENTIFIER', 'photo');
+ define('BASE_URL',get_base_url(ADMIN_DIR));
+ define('STATIC_URL', BASE_URL.'static/');
+ define('BASE_PATH',get_base_path(ADMIN_DIR));
+
+ define('WYSIWYG_EDITOR', 'cms/modules/tiny_mce/tiny_mce.js');
+ define('WYSIWYG_EDITOR_INIT', 'js/wysiwyg_init.js');
+
+ if($settings['caching'])
+ {
+ $cache = new Cache(BASE_PATH.CACHE_DIR, $settings);
+ if(empty($settings['admin_auto_clear_cache'])) $cache->autoClear=false;
+ }
+
+ if(isset($cache) && isset($_GET['clear_cache']) && isset($_SESSION[$settings['session_prefix'].'user_id']))
+ {
+ $cache->clear();
+ header('Location: index.php?msg=cache_cleared');
+ exit;
+ }
+
+ // set timezone:
+ if($settings['time_zone']) date_default_timezone_set($settings['time_zone']);
+
+ #require('./lang/'.$settings['admin_language_file']);
+ $localization = new Localization(BASE_PATH.'cms/lang/'.$settings['admin_language'].'.admin.lang.php');
+ define('CHARSET', Localization::$lang['charset']);
+
+ require('./includes/classes/Template.class.php');
+ $template = new Template();
+ $template->assign('settings', $settings);
+ #$template->set_settings($settings);
+
+ // set local language settings:
+ setlocale(LC_ALL, Localization::$lang['locale']);
+
+ $mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : 'admin_index';
+
+ // go to login if not logged in:
+ if(empty($_SESSION[$settings['session_prefix'].'user_id']))
+ {
+ $mode = 'login';
+ $template->assign('admin',false);
+ }
+ else
+ {
+ $template->assign('admin', true);
+ $template->assign('user_id', $_SESSION[$settings['session_prefix'].'user_id']);
+ $template->assign('user_type', $_SESSION[$settings['session_prefix'].'user_type']);
+ }
+
+ // include required file for mode:
+ switch($mode)
+ {
+ #case 'index': include('./includes/admin_index.inc.php'); break;
+ case 'login': include('./includes/login.inc.php'); break;
+ case 'logout': include('./includes/login.inc.php'); break;
+ case 'edit': include('./includes/edit.inc.php'); break;
+ case 'pages': include('./includes/pages.inc.php'); break;
+ case 'galleries': include('./includes/galleries.inc.php'); break;
+ case 'gcb': include('./includes/gcb.inc.php'); break;
+ case 'notes': include('./includes/notes.inc.php'); break;
+ case 'comments': include('./includes/comments.inc.php'); break;
+ case 'filemanager': include('./includes/filemanager.inc.php'); break;
+ case 'spam_protection': include('./includes/spam_protection.inc.php'); break;
+ case 'users': include('./includes/users.inc.php'); break;
+ case 'settings': include('./includes/settings.inc.php'); break;
+ case 'menus': include('./includes/menus.inc.php'); break;
+ case 'image': include('./includes/insert_image.inc.php'); break;
+ case 'modal': include('./includes/modal.inc.php'); break;
+ case 'thumbnail': include('./includes/insert_thumbnail.inc.php'); break;
+ case 'ajaxprocess': include('./includes/ajaxprocess.inc.php'); break;
+ default: include('./includes/admin_index.inc.php');
+ }
+
+ $template->assign('mode',$mode);
+ $template->assign('lang',Localization::$lang);
+ #$template->set_lang($lang);
+
+ header('Content-Type: text/html; charset='.Localization::$lang['charset']);
+ if(empty($template_file))
+ {
+ $template_file = 'main.tpl';
+ }
+ $template->display(BASE_PATH.'cms/templates/admin/'.$template_file);
+ } // end try
+
+catch(Exception $exception)
+ {
+ include('./includes/exception.inc.php');
+ }
+?>
diff --git a/cms/lang/english.admin.lang.php b/cms/lang/english.admin.lang.php
new file mode 100644
index 0000000..0e2c107
--- /dev/null
+++ b/cms/lang/english.admin.lang.php
@@ -0,0 +1,491 @@
+all comments on all pages?';
+$lang['delete_all_photo_comments'] = 'Do you really want to delete all comments on all photos?';
+$lang['delete_all_comm_page_conf'] = 'Do you really want to delete all comments on [page]?';
+$lang['delete_all_comments_subm'] = 'OK - Delete';
+$lang['comments_name_m'] = 'Name:';
+$lang['comments_email_hp_m'] = 'E-mail or hompage:';
+$lang['report_spam'] = 'Report spam';
+$lang['report_as_spam'] = 'report as spam';
+$lang['report_spam_confirm'] = 'Do you want to report this comment as spam to Akismet?';
+$lang['report_as_spam_submit'] = 'Report as spam';
+$lang['report_as_spam_delete_submit'] = 'Report as spam and delete';
+$lang['pingback'] = 'Pingback';
+
+# photos
+$lang['photo_galleries'] = 'Photo galleries';
+$lang['new_gallery'] = 'New gallery';
+$lang['edit_gallery'] = '[gallery]';
+$lang['edit_photo'] = 'Edit photo';
+$lang['new_photo'] = 'New Photo';
+$lang['gallery_properties_hl'] = 'Properties';
+$lang['gallery_name_alr_exists'] = 'Gallery name already exists';
+$lang['error_gallery_spec_chars'] = 'Gallery name contains special characters';
+$lang['gallery'] = 'Gallery';
+$lang['no_gallery'] = 'No gallery yet.';
+$lang['create_new_gallery'] = 'Create gallery';
+$lang['photo_overview'] = 'Photo overview';
+$lang['add_photo'] = 'Add photo';
+$lang['photo'] = 'Photo';
+$lang['photo_nr'] = 'Nr.';
+$lang['photo_title'] = 'Title';
+$lang['photo_subtitle'] = 'Subtitle';
+$lang['photo_description'] = 'Description';
+$lang['no_photo'] = 'No photo yet.';
+$lang['delete_gallery'] = 'Delete gallery';
+$lang['delete_gallery_confirm'] = 'Delete this gallery?';
+$lang['delete_gallery_submit'] = 'OK - Delete';
+$lang['new_gallery_name'] = 'Gallery name:';
+$lang['edit_photo_thumbnail'] = 'Thumbnail:';
+$lang['edit_photo_normal'] = 'Photo:';
+$lang['edit_photo_large'] = 'Large photo:';
+$lang['edit_photo_size_flash'] = '(only for *.swf/*.flv files)';
+$lang['edit_photo_xlarge'] = 'XLarge Photo:';
+$lang['edit_photo_title'] = 'Title:';
+$lang['edit_photo_subtitle'] = 'Subtitle:';
+$lang['edit_photo_description'] = 'Description:';
+$lang['invalid_photo'] = 'Photo not avilable!';
+$lang['error_no_gallery'] = 'No gallery specified';
+$lang['error_no_thumbnail'] = 'No thumbnail specified';
+$lang['error_no_photo'] = 'No photo specified';
+$lang['error_no_photo_title'] = 'No title specified';
+$lang['select_image'] = 'select image';
+$lang['err_photo_t_doesnt_exist'] = 'Thumbnail doesn\'t exist';
+$lang['err_image_type'] = 'Thumbnail must be an image (JPG/PNG/GIF)';
+$lang['err_photo_n_doesnt_exist'] = 'Photo doesn\'t exist';
+$lang['err_photo_l_doesnt_exist'] = 'Large photo doesn\'t exist';
+$lang['gallery_properties'] = 'Gallery properties';
+$lang['specify_photo_tpl_m'] = 'Photo template';
+$lang['photos_per_row'] = 'Photos per row';
+$lang['delete_photo_confirm'] = 'Delete this photo?';
+
+# user
+$lang['users'] = 'Users';
+$lang['user_name'] = 'Name';
+$lang['user_type'] = 'Type';
+$lang['type_0'] = 'editor';
+$lang['type_1'] = 'admin';
+$lang['last_login'] = 'Last login';
+$lang['no_users'] = 'There are no users.';
+$lang['create_user_account'] = 'Create user account';
+$lang['user_name_m'] = 'Username:';
+$lang['pw_m'] = 'Password:';
+$lang['pw_conf_m'] = 'Repeat password:';
+$lang['delete_user'] = 'Delete user account';
+$lang['delete_user_confirm'] = 'Delete this user?';
+$lang['delete_user_submit'] = 'OK - Delete user';
+$lang['edit_userdata'] = 'Edit user data';
+$lang['edit_userdata_name'] = 'Name:';
+$lang['edit_userdata_type'] = 'Type:';
+$lang['change_pw_old'] = 'Old password:';
+$lang['change_pw_new'] = 'New password:';
+$lang['change_pw_new_conf'] = 'Repeat new password:';
+$lang['change_pw_note'] = '(only if you want to change it)';
+$lang['error_username_special_chars'] = 'Username contains invalid characters';
+$lang['error_username_alr_exists'] = 'Username already exists';
+$lang['error_pw_doesnt_comply'] = 'Password doesn\'t match with the repeated one';
+$lang['error_form_uncomplete'] = 'You didn\'t fill out all form fields';
+$lang['error_pw_wrong'] = 'Password wrong!';
+$lang['invalid_user_type'] = 'Invalid user type';
+$lang['rights_limitation_imposs'] = 'Limitation of your own user rights is not possible';
+$lang['del_yourself_imposs'] = 'You can\'t delete yourself.';
+$lang['userdata_saved_message'] = 'Userdata saved';
+
+#filemanager
+$lang['filemanager'] = 'Filemanager';
+$lang['upload_file'] = 'Upload file';
+$lang['directory'] = 'Directory:';
+$lang['no_files'] = 'No files.';
+$lang['file'] = 'File';
+$lang['file_type'] = 'Type';
+$lang['file_size'] = 'Size (KB)';
+$lang['file_date'] = 'Date';
+$lang['delete_file'] = 'Delete file';
+$lang['delete_file_confirm'] = 'Delete this file?';
+$lang['delete_file_submit'] = 'OK - Delete file';
+$lang['delete_file_error'] = 'Unable to delete the file';
+$lang['file_legend'] = 'File';
+$lang['upload_file_link'] = 'Upload file';
+$lang['upload_file_label'] = 'File:';
+$lang['upload_directory_label'] = 'Upload to:';
+$lang['overwrite_file'] = 'overwrite file with same name';
+$lang['image_options'] = 'Options for images';
+$lang['upload_file_submit'] = 'Upload file';
+$lang['filename_on_server'] = 'Filename on server:';
+$lang['filename_server_same'] = '(blank if unchanged)';
+$lang['upload_file_exists'] = 'There\'s already a file with this name';
+$lang['error_no_file'] = 'No file to upload specified';
+$lang['upload_ok'] = 'File successfully uploaded';
+$lang['delete_image_confirm'] = 'Are you sure you want to delete this image?';
+$lang['delete_image_submit'] = 'OK - Delete';
+$lang['delete_image_cancel'] = 'Cancel';
+$lang['upload_image_exists'] = 'There\'s already an image with this name';
+$lang['upload_overwrite_image'] = 'overwrite image with same name';
+$lang['dont_manipulate_image'] = 'Leave image as it is';
+$lang['manipulate_image'] = 'Modify image:';
+$lang['resize'] = 'Resize:';
+$lang['resize_width'] = 'width';
+$lang['resize_height'] = 'height';
+$lang['compression'] = 'Compression:';
+$lang['compression_jpg_only'] = '(only for JPG images)';
+$lang['image_name_on_server'] = 'Image name on server:';
+$lang['image_name_server_same'] = '(blank if unchanged)';
+$lang['error_no_image'] = 'No image to upload specified';
+$lang['invalid_image_format'] = 'Invalid image format ([format])';
+$lang['invalid_image_name'] = 'Invalid image name';
+$lang['invalid_compression_value'] = 'The value for the compression has to be between 1 and 100';
+$lang['create_thumbnail'] = 'Create thumbnail:';
+
+# settings
+$lang['settings'] = 'Settings';
+$lang['advanced_settings'] = 'Advanced settings';
+$lang['settings_website_title'] = 'Website title';
+$lang['settings_website_subtitle'] = 'Subtitle';
+$lang['settings_website_footnote_1'] = 'Footnote 1';
+$lang['settings_website_footnote_2'] = 'Footnote 2';
+$lang['settings_website_address'] = 'URL';
+$lang['settings_email'] = 'E-mail';
+$lang['settings_index_page'] = 'Main page';
+$lang['settings_error_page'] = 'Error page';
+$lang['default_page_language'] = 'Default page language';
+$lang['admin_language'] = 'Administration language';
+$lang['wysiwyg_editor'] = 'WYSIWYG editor';
+$lang['wysiwyg_editor_enabled'] = 'WYSIWYG editor enabled';
+$lang['settings_caching'] = 'Caching';
+$lang['settings_caching_enabled'] = 'caching enabled';
+$lang['settings_name'] = 'Name';
+$lang['settings_value'] = 'Value';
+$lang['add_new_setting_var'] = 'Add new settings variable';
+$lang['error_settings_spec_chars'] = 'Variable contains special characters';
+$lang['delete_setting_confirm'] = 'Delete this setting variable?';
+$lang['settings_saved'] = 'Settings saved';
+
+# spam protection
+$lang['spam_protection'] = 'Spam protection';
+$lang['akismet'] = 'Akismet';
+$lang['akismet_desc'] = 'Akismet spam protection';
+$lang['akismet_key'] = 'Wordpress API Key:';
+$lang['akismet_entry_check'] = 'check comments';
+$lang['akismet_mail_check'] = 'check contact forms';
+$lang['banned_ips'] = 'Banned IPs';
+$lang['banned_ips_desc'] = 'IP adresses which should not have access. IP ranges (e.g. 10.10.1.*) and CIDR notation (e.g. 10.10.1.32/27) possible. One IP per line.';
+$lang['banned_user_agents'] = 'Banned user agents';
+$lang['banned_user_agents_desc'] = 'Strings in user agents, which should not have access. One string per line.';
+$lang['not_accepted_words'] = 'Not accepted words';
+$lang['not_accepted_words_desc'] = 'Words or domains that should not be accepted in entries and e-mails. One word per line.';
+$lang['spam_protection_submit'] = 'OK - Save';
+$lang['spam_protection_saved'] = 'Saved';
+$lang['error_own_ip_banned'] = 'You banned your own IP!';
+$lang['error_own_user_agent_banned'] = 'You banned your own User Agent!';
+
+# insert_image
+$lang['insert_image'] = 'Insert image';
+$lang['select_image_title'] = 'Insert image';
+$lang['insert_image_button'] = 'Insert image';
+$lang['insert_thumbnail_button'] = 'Insert thumbnail';
+$lang['default_image_alt'] = 'Image';
+$lang['upload_submit'] = 'OK - Upload image';
+$lang['upload_image'] = 'Upload image';
+$lang['upload_image_marking'] = 'Choose image:';
+$lang['available_images'] = 'Available images';
+$lang['no_images'] = 'No images available';
+#$lang['view_image_button'] = 'show';
+#$lang['delete_image_button'] = 'delete';
+
+# insert_thumbnail
+$lang['insert_thumbnail'] = 'Insert thumbnail';
+$lang['thumbnail_select_gallery'] = 'Select gallery:';
+$lang['insert_image_label'] = 'Insert image';
+$lang['insert_thumbnail_label'] = 'Insert thumbnail';
+$lang['insert_gallery_label'] = 'Insert gallery';
+$lang['insert_image_class'] = 'CSS class:';
+$lang['insert_image_alt'] = 'ALT text:';
+$lang['insert_image_width_height'] = 'Width/Height:';
+$lang['delete_error'] = 'Delete error';
+$lang['upload_error'] = 'Upload error - check writing permission of img folder!';
+?>
diff --git a/cms/lang/english.page.lang.php b/cms/lang/english.page.lang.php
new file mode 100644
index 0000000..b19969a
--- /dev/null
+++ b/cms/lang/english.page.lang.php
@@ -0,0 +1,179 @@
+Last modified: [last_modified|%Y-%m-%d, %H:%M]';
+$lang['no_comments'] = 'no comments';
+$lang['one_comment'] = '1 comment';
+$lang['several_comments'] = '[comments] comments';
+$lang['number_of_comments'][0] = 'no comments';
+$lang['number_of_comments'][1] = '1 comment';
+$lang['number_of_comments'][2] = '[comments] comments';
+$lang['pagination'] = 'Page [current_page] of [total_pages]';
+$lang['edit'] = 'edit';
+$lang['delete'] = 'delete';
+$lang['all_categories'] = 'show all categories';
+
+// Admin Menu:
+$lang['admin_menu_home'] = 'Home';
+$lang['admin_menu_admin'] = 'Administration';
+$lang['admin_menu_page_overview'] = 'Page overview';
+$lang['admin_menu_new_page'] = 'Create new page';
+$lang['admin_menu_logout'] = 'Log out';
+$lang['admin_menu_act_page_actions'] = 'This page:';
+$lang['admin_menu_edit_page'] = 'Edit';
+$lang['admin_menu_delete_page'] = 'Delete';
+$lang['admin_menu_delete_page_conf'] = 'Do you really want to delete this page?';
+
+// Comments:
+$lang['comment_headline'] = 'Comments';
+$lang['pingback_headline'] = 'Pingbacks';
+$lang['comment_no_comments'] = 'No comments yet.';
+$lang['comments_closed'] = 'Comments are closed.';
+$lang['comment_time'] = '[time|%A, %B %d, %Y, %H:%M]';
+$lang['comments_pagination_info'] = '[total_comments] comments, page [current_page] of [total_pages]';
+$lang['comments_add_comment'] = 'Add comment';
+$lang['comment_input_text'] = 'Add comment:';
+$lang['comment_edit_text'] = 'Edit comment:';
+$lang['comment_input_name'] = 'Name:';
+$lang['comment_input_email_hp'] = 'E-mail or homepage:';
+$lang['comment_input_submit'] = ' OK ';
+$lang['comment_input_preview'] = 'Preview';
+$lang['comment_preview_hl'] = 'Preview:';
+$lang['error_not_accepted_word'] = 'Not accepted word: [not_accepted_word]';
+$lang['error_not_accepted_words'] = 'Not accepted words: [not_accepted_words]';
+$lang['comment_error_closed'] = 'Comments are closed!';
+$lang['comment_error_no_name'] = 'No name entered';
+$lang['comment_error_no_text'] = 'No comment entered';
+$lang['comment_error_name_too_long'] = 'The name is too long';
+$lang['comment_error_email_hp_too_long'] = 'E-mail/homepage is too long';
+$lang['comment_error_email_hp_invalid'] = 'E-mail/homepage invalid';
+$lang['comment_error_text_too_long'] = 'The text is too long ([characters] charcters; maximum: [max_characters] characters)';
+$lang['comment_error_too_long_word'] = 'Too long word: [word]';
+$lang['comment_error_too_long_words'] = 'Too long words: [words]';
+$lang['comment_error_entry_exists'] = 'This entry already exists';
+$lang['comment_error_repeated_post'] = 'There has just been entered an entry with this IP - please wait a moment!';
+$lang['comment_error_too_fast'] = 'Form was submitted too fast - please try again!';
+$lang['comment_delete_link'] = 'delete';
+$lang['comment_delete_confirm'] = 'Do you really want to delete this comment?';
+$lang['comment_edit_link'] = 'edit';
+$lang['comment_note_email'] = '(optional)';
+$lang['comments_open'] = 'open';
+$lang['comments_close'] = 'Close comments';
+$lang['comment_notification_subject'] = 'Comment to [page]';
+$lang['comment_notification_message'] = "[name]\n\n[comment]\n\n[link]";
+$lang['pingback_notification_subject'] = 'Pingback to [page]';
+$lang['pingback_notification_message'] = "[title]\n[url]\n[link]";
+
+// News:
+$lang['news_time'] = '[time|%A, %B %d, %Y, %H:%M]';
+$lang['no_news'] = 'No news availble';
+
+// Notes:
+$lang['note_time'] = '[time|%A, %B %d, %Y, %H:%M]';
+$lang['no_notes'] = 'No notes availble';
+
+// Formmailer:
+$lang['formmailer_label_email'] = 'E-mail:';
+$lang['formmailer_label_subject'] = 'Subject:';
+$lang['formmailer_label_message'] = 'Message:';
+$lang['formmailer_button_send'] = 'OK - Send';
+$lang['formmail_error_email_invalid'] = 'E-mail address invalid or empty';
+$lang['formmail_error_no_message'] = 'No message entered';
+$lang['formmail_error_text_too_long'] = 'The message is too long';
+$lang['formmail_error_subj_too_long'] = 'The subject is too long';
+$lang['formmail_error_mailserver'] = 'Mailserver error - please try again later!';
+$lang['formmailer_mail_sent'] = 'The message has been sent successfully.';
+$lang['formmailer_no_subject'] = 'No subject';
+
+// Gallery:
+$lang['gallery_no_photo'] = 'No photo in this gallery';
+
+// Photo:
+$lang['photo_headline'] = 'Photo';
+$lang['previous_photo'] = 'Previous image';
+$lang['next_photo'] = 'Next image';
+$lang['enlarge_photo'] = 'Enlarge';
+$lang['reduce_photo'] = 'Reduce';
+$lang['show_large_photo'] = 'Large';
+$lang['show_large_photo_title'] = 'Show large photo';
+$lang['back_link'] = 'back';
+$lang['back_title'] = 'Back to "[page]"';
+$lang['photo_comment_link_title'] = 'Read or write comments to this photo';
+
+// Simple news:
+$lang['simple_news_time'] = '[time|%A, %B %e, %Y]';
+$lang['simple_news_edit_title'] = 'Title:';
+$lang['simple_news_edit_teaser'] = 'Teaser:';
+$lang['simple_news_edit_text'] = 'Text:';
+$lang['simple_news_edit_text_format'] = 'auto formatting';
+$lang['simple_news_edit_linkname'] = 'Link name:';
+$lang['simple_news_default_linkname'] = 'more…';
+$lang['simple_news_edit_time'] = 'Date/time:';
+$lang['simple_news_edit_time_format'] = '(YYYY-MM-DD HH:MM:SS)';
+$lang['simple_news_add_item'] = 'Add entry';
+$lang['simple_news_edit_item'] = 'Edit item';
+$lang['simple_news_delete_confirm'] = 'Do you really want to delete this entry?';
+$lang['error_news_no_title'] = 'No title specified';
+$lang['error_news_no_text'] = 'No text entered';
+$lang['error_news_time_invalid'] = 'invalid date/time format';
+$lang['delete_news_title'] = 'Delete entry';
+$lang['delete_news_confirm_submit'] = 'OK - Delete';
+
+// Newsletter:
+$lang['newsletter_subscr_email'] = 'E-mail address:';
+$lang['newsletter_subscribe'] = 'subscribe';
+$lang['newsletter_unsubscribe'] = 'unsubscribe';
+$lang['newsletter_email'] = 'E-mail';
+$lang['newsletter_subscribe_time'] = 'Subscribed';
+$lang['newsletter_subscribe_time_format'] = '[time|%d.%m.%Y, %H:%M]';
+$lang['newsletter_error_invalid_email'] = 'E-mail address invalid';
+$lang['newsletter_error_email_exists'] = 'This e-mail address already exists';
+$lang['newsletter_error_email_not_exist'] = 'The e-mail address doesn\'t exist';
+$lang['newsletter_error_mail'] = 'Error while sending e-mail - please try again later';
+$lang['newsletter_conf_ok'] = 'Thank you! Your e-mail address has been confirmed.';
+$lang['newsletter_delete_ok'] = 'You have successfully unsubscribed from the newsletter!';
+$lang['newsletter_conf_failed'] = 'Error: Invalid confirmation link (e.g. time period expired)!';
+$lang['newsletter_conf_mail_sent'] = 'An e-mail with a confirmation link has been sent to the specified e-mail address. Please confirm this link within one hour!';
+$lang['newsletter_email_delete'] = 'delete';
+$lang['newsletter_no_emails'] = 'No e-mail addresses available.';
+$lang['newsletter_add_email'] = 'Add e-mail address:';
+$lang['newsletter_email_list'] = 'E-mail list';
+$lang['newsletter_edit_emails'] = 'Edit e-mail addresses';
+$lang['newsletter_email_count'] = '[number] e-mail addresses';
+$lang['newsletter_subscribe_subj'] = 'Subscribe to newsletter';
+$lang['newsletter_subscribe_text'] = "Your e-mail address has been added to our mailing list. Please click the link below to confirm your request. If this e-mail has been sent in error (either by you or someone else) please ignore this e-mail.\n\nLink to confirm the subscription:\n[link]";
+$lang['newsletter_unsubscribe_subj'] = 'Unsubscribe to newsletter';
+$lang['newsletter_unsubscribe_text'] = "Please click the following link to unsubscribe to the newsletter:\n[link]";
+$lang['newsletter_checkall'] = 'check all';
+$lang['newsletter_uncheckall'] = 'uncheck all';
+$lang['newsletter_delete_checked'] = 'Delete checked';
+$lang['newsletter_delete_confirm'] = 'Delete e-mail(s)?';
+$lang['newsletter_delete_confirm_submit'] = 'OK - Delete';
+
+// Search:
+$lang['search_submit'] = 'Search';
+$lang['search_number_of_results'][0] = 'No pages found';
+$lang['search_number_of_results'][1] = '1 page found:';
+$lang['search_number_of_results'][2] = '[pages] pages found:';
+$lang['search_pagination'] = '[total_results] results, page [current_page] of [total_pages]';
+$lang['search_photo'] = 'Photo';
+$lang['search_no_results'] = 'No pages found';
+
+// Akismet:
+$lang['akismet_error_api_key'] = 'Invalid akismet api key';
+$lang['akismet_error_connection'] = 'Server connection error - please try again later';
+$lang['akismet_spam_suspicion'] = 'Spam suspicion!'
+?>
diff --git a/cms/modules/.dummy b/cms/modules/.dummy
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/cms/modules/.dummy
@@ -0,0 +1 @@
+
diff --git a/cms/templates/admin/images/arrow_down.png b/cms/templates/admin/images/arrow_down.png
new file mode 100644
index 0000000..2c4e279
Binary files /dev/null and b/cms/templates/admin/images/arrow_down.png differ
diff --git a/cms/templates/admin/images/arrow_up.png b/cms/templates/admin/images/arrow_up.png
new file mode 100644
index 0000000..1ebb193
Binary files /dev/null and b/cms/templates/admin/images/arrow_up.png differ
diff --git a/cms/templates/admin/images/asc.gif b/cms/templates/admin/images/asc.gif
new file mode 100644
index 0000000..dd79f5c
Binary files /dev/null and b/cms/templates/admin/images/asc.gif differ
diff --git a/cms/templates/admin/images/bg_td.png b/cms/templates/admin/images/bg_td.png
new file mode 100644
index 0000000..de821db
Binary files /dev/null and b/cms/templates/admin/images/bg_td.png differ
diff --git a/cms/templates/admin/images/bg_th.png b/cms/templates/admin/images/bg_th.png
new file mode 100644
index 0000000..a97ce49
Binary files /dev/null and b/cms/templates/admin/images/bg_th.png differ
diff --git a/cms/templates/admin/images/checkall.gif b/cms/templates/admin/images/checkall.gif
new file mode 100644
index 0000000..dc79e9f
Binary files /dev/null and b/cms/templates/admin/images/checkall.gif differ
diff --git a/cms/templates/admin/images/cog.png b/cms/templates/admin/images/cog.png
new file mode 100644
index 0000000..67de2c6
Binary files /dev/null and b/cms/templates/admin/images/cog.png differ
diff --git a/cms/templates/admin/images/comments.png b/cms/templates/admin/images/comments.png
new file mode 100644
index 0000000..39433cf
Binary files /dev/null and b/cms/templates/admin/images/comments.png differ
diff --git a/cms/templates/admin/images/create_page.png b/cms/templates/admin/images/create_page.png
new file mode 100644
index 0000000..aa23dde
Binary files /dev/null and b/cms/templates/admin/images/create_page.png differ
diff --git a/cms/templates/admin/images/default.png b/cms/templates/admin/images/default.png
new file mode 100644
index 0000000..b9d8827
Binary files /dev/null and b/cms/templates/admin/images/default.png differ
diff --git a/cms/templates/admin/images/default_inactive.png b/cms/templates/admin/images/default_inactive.png
new file mode 100644
index 0000000..548e302
Binary files /dev/null and b/cms/templates/admin/images/default_inactive.png differ
diff --git a/cms/templates/admin/images/delete.png b/cms/templates/admin/images/delete.png
new file mode 100644
index 0000000..1514d51
Binary files /dev/null and b/cms/templates/admin/images/delete.png differ
diff --git a/cms/templates/admin/images/desc.gif b/cms/templates/admin/images/desc.gif
new file mode 100644
index 0000000..15d3fbd
Binary files /dev/null and b/cms/templates/admin/images/desc.gif differ
diff --git a/cms/templates/admin/images/edit.png b/cms/templates/admin/images/edit.png
new file mode 100644
index 0000000..b93e776
Binary files /dev/null and b/cms/templates/admin/images/edit.png differ
diff --git a/cms/templates/admin/images/exclamation.png b/cms/templates/admin/images/exclamation.png
new file mode 100644
index 0000000..c37bd06
Binary files /dev/null and b/cms/templates/admin/images/exclamation.png differ
diff --git a/cms/templates/admin/images/folder.png b/cms/templates/admin/images/folder.png
new file mode 100644
index 0000000..784e8fa
Binary files /dev/null and b/cms/templates/admin/images/folder.png differ
diff --git a/cms/templates/admin/images/galleries.png b/cms/templates/admin/images/galleries.png
new file mode 100644
index 0000000..8836fe6
Binary files /dev/null and b/cms/templates/admin/images/galleries.png differ
diff --git a/cms/templates/admin/images/gcb.png b/cms/templates/admin/images/gcb.png
new file mode 100644
index 0000000..ea086b0
Binary files /dev/null and b/cms/templates/admin/images/gcb.png differ
diff --git a/cms/templates/admin/images/gcb_add.png b/cms/templates/admin/images/gcb_add.png
new file mode 100644
index 0000000..6203722
Binary files /dev/null and b/cms/templates/admin/images/gcb_add.png differ
diff --git a/cms/templates/admin/images/home.png b/cms/templates/admin/images/home.png
new file mode 100644
index 0000000..fed6221
Binary files /dev/null and b/cms/templates/admin/images/home.png differ
diff --git a/cms/templates/admin/images/lightning_add.png b/cms/templates/admin/images/lightning_add.png
new file mode 100644
index 0000000..dac3c90
Binary files /dev/null and b/cms/templates/admin/images/lightning_add.png differ
diff --git a/cms/templates/admin/images/logout.png b/cms/templates/admin/images/logout.png
new file mode 100644
index 0000000..c149c2b
Binary files /dev/null and b/cms/templates/admin/images/logout.png differ
diff --git a/cms/templates/admin/images/note.png b/cms/templates/admin/images/note.png
new file mode 100644
index 0000000..244e6ca
Binary files /dev/null and b/cms/templates/admin/images/note.png differ
diff --git a/cms/templates/admin/images/note_add.png b/cms/templates/admin/images/note_add.png
new file mode 100644
index 0000000..abdad91
Binary files /dev/null and b/cms/templates/admin/images/note_add.png differ
diff --git a/cms/templates/admin/images/page.png b/cms/templates/admin/images/page.png
new file mode 100644
index 0000000..8b8b1ca
Binary files /dev/null and b/cms/templates/admin/images/page.png differ
diff --git a/cms/templates/admin/images/page_link.png b/cms/templates/admin/images/page_link.png
new file mode 100644
index 0000000..bf7bd1c
Binary files /dev/null and b/cms/templates/admin/images/page_link.png differ
diff --git a/cms/templates/admin/images/pages.png b/cms/templates/admin/images/pages.png
new file mode 100644
index 0000000..44084ad
Binary files /dev/null and b/cms/templates/admin/images/pages.png differ
diff --git a/cms/templates/admin/images/photo_add.png b/cms/templates/admin/images/photo_add.png
new file mode 100644
index 0000000..63cc355
Binary files /dev/null and b/cms/templates/admin/images/photo_add.png differ
diff --git a/cms/templates/admin/images/refresh.png b/cms/templates/admin/images/refresh.png
new file mode 100644
index 0000000..a270f68
Binary files /dev/null and b/cms/templates/admin/images/refresh.png differ
diff --git a/cms/templates/admin/images/shield.png b/cms/templates/admin/images/shield.png
new file mode 100644
index 0000000..3cb4e25
Binary files /dev/null and b/cms/templates/admin/images/shield.png differ
diff --git a/cms/templates/admin/images/submit.png b/cms/templates/admin/images/submit.png
new file mode 100644
index 0000000..36381e4
Binary files /dev/null and b/cms/templates/admin/images/submit.png differ
diff --git a/cms/templates/admin/images/throbber.gif b/cms/templates/admin/images/throbber.gif
new file mode 100644
index 0000000..329df02
Binary files /dev/null and b/cms/templates/admin/images/throbber.gif differ
diff --git a/cms/templates/admin/images/user.png b/cms/templates/admin/images/user.png
new file mode 100644
index 0000000..79f35cc
Binary files /dev/null and b/cms/templates/admin/images/user.png differ
diff --git a/cms/templates/admin/images/user_add.png b/cms/templates/admin/images/user_add.png
new file mode 100644
index 0000000..deae99b
Binary files /dev/null and b/cms/templates/admin/images/user_add.png differ
diff --git a/cms/templates/admin/main.tpl b/cms/templates/admin/main.tpl
new file mode 100644
index 0000000..533ea31
--- /dev/null
+++ b/cms/templates/admin/main.tpl
@@ -0,0 +1,55 @@
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/cms/templates/admin/subtemplates/admin_index.inc.tpl b/cms/templates/admin/subtemplates/admin_index.inc.tpl
new file mode 100644
index 0000000..47ab5aa
--- /dev/null
+++ b/cms/templates/admin/subtemplates/admin_index.inc.tpl
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
diff --git a/cms/templates/admin/subtemplates/admin_menu.inc.tpl b/cms/templates/admin/subtemplates/admin_menu.inc.tpl
new file mode 100644
index 0000000..f4e5973
--- /dev/null
+++ b/cms/templates/admin/subtemplates/admin_menu.inc.tpl
@@ -0,0 +1,44 @@
+
diff --git a/cms/templates/admin/subtemplates/comments.inc.tpl b/cms/templates/admin/subtemplates/comments.inc.tpl
new file mode 100644
index 0000000..1f4aeb1
--- /dev/null
+++ b/cms/templates/admin/subtemplates/comments.inc.tpl
@@ -0,0 +1,114 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+*/ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/cms/templates/admin/subtemplates/comments_delete.inc.tpl b/cms/templates/admin/subtemplates/comments_delete.inc.tpl
new file mode 100644
index 0000000..e2affad
--- /dev/null
+++ b/cms/templates/admin/subtemplates/comments_delete.inc.tpl
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+ - :
+
+
+
+
diff --git a/cms/templates/admin/subtemplates/comments_delete_all.inc.tpl b/cms/templates/admin/subtemplates/comments_delete_all.inc.tpl
new file mode 100644
index 0000000..aa779ea
--- /dev/null
+++ b/cms/templates/admin/subtemplates/comments_delete_all.inc.tpl
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/cms/templates/admin/subtemplates/comments_delete_all_page.inc.tpl b/cms/templates/admin/subtemplates/comments_delete_all_page.inc.tpl
new file mode 100644
index 0000000..38e1197
--- /dev/null
+++ b/cms/templates/admin/subtemplates/comments_delete_all_page.inc.tpl
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
diff --git a/cms/templates/admin/subtemplates/comments_edit.inc.tpl b/cms/templates/admin/subtemplates/comments_edit.inc.tpl
new file mode 100644
index 0000000..6408aa1
--- /dev/null
+++ b/cms/templates/admin/subtemplates/comments_edit.inc.tpl
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
diff --git a/cms/templates/admin/subtemplates/comments_report_spam.inc.tpl b/cms/templates/admin/subtemplates/comments_report_spam.inc.tpl
new file mode 100644
index 0000000..b60e9f9
--- /dev/null
+++ b/cms/templates/admin/subtemplates/comments_report_spam.inc.tpl
@@ -0,0 +1,18 @@
+ » »
+
+
+
+, :
+
+
+
+
diff --git a/cms/templates/admin/subtemplates/delete_page.inc.tpl b/cms/templates/admin/subtemplates/delete_page.inc.tpl
new file mode 100644
index 0000000..1f36634
--- /dev/null
+++ b/cms/templates/admin/subtemplates/delete_page.inc.tpl
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
diff --git a/cms/templates/admin/subtemplates/edit.inc.tpl b/cms/templates/admin/subtemplates/edit.inc.tpl
new file mode 100644
index 0000000..0c3747c
--- /dev/null
+++ b/cms/templates/admin/subtemplates/edit.inc.tpl
@@ -0,0 +1,456 @@
+
+
+
+
+
+
+