// All rights reserved. This script is part of PHPWCMS. The PHPWCMS web content management system 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 2 of the License, or (at your option) any later version. The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html A copy is found in the textfile GPL.txt and important notices to the license from the author is found in LICENSE.txt distributed with these scripts. This script 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. This copyright notice MUST APPEAR in all copies of the script! *************************************************************************************/ // ---------------------------------------------------------------- // obligate check for phpwcms constants if (!defined('PHPWCMS_ROOT')) { die("You Cannot Access This Script Directly, Have a Nice Day."); } // ---------------------------------------------------------------- // general functions used in backend only function update_cache() { // used to update cache setting all current cache entries // will be forced to update cache but will not be deleted //$sql = "UPDATE ".DB_PREPEND."phpwcms_cache SET cache_timeout='0'"; //mysql_query($sql, $GLOBALS['db']) or die("error while updating cache"); } function set_chat_focus($do, $p) { //set_chat_focus("chat", 1) if($do == "chat" && $p == 1) { echo "\n"; } } function forward_to($to, $link, $time=2500) { //Javascript forwarding if($to) echo "\n"; } function subnavtext($text, $link, $is, $should, $getback=1, $js='') { //generate subnavigation based on text $id = "subnavid".randpassword(5); $sn = ''; if($is == $should) { $sn .= ''; $sn .= ''.$text.''; } else { $sn .= "\"\""; $sn .= "".$text.""; } $sn .= "\n"; if(!$getback) { return $sn; } else { echo $sn; } } function subnavtextext($text, $link, $target='_blank', $getback=1) { //generate subnavigation based on text and links to new page $id = 'subnavid'.randpassword(5); $sn = ''; $sn .= ''; $sn .= "\n"; if(!$getback) { return $sn; } else { echo $sn; } } function subnavback($text, $link, $h_before=0, $h_after=0) { $id = "subbackid".randpassword(5); $sn = "\n"; $sn .= (intval($h_before)) ? "\n" : ""; $sn .= ""; $sn .= ""; $sn .= ""; $sn .= "\n"; $sn .= (intval($h_after)) ? "\n" : ""; $sn .= "
\"\"
\"\" ".$text."
\"\"
\n"; echo $sn; } function clearfilename($formvar) { //Filename anpassen und säubern $formvar = trim($formvar); if( get_magic_quotes_gpc() ) $formvar = stripslashes ($formvar); $formvar = str_replace(array("'", ':', '/', '\\', '"'), '_', $formvar); return $formvar; } function check_image_extension($file, $filename='') { // only checks against correct image extension $image_info = getimagesize($file); $result = false; if(false != $image_info) { switch($image_info[2]) { case 1: $result = 'gif'; break; case 2: $result = 'jpg'; break; case 3: $result = 'png'; break; case 4: $result = 'swf'; break; case 5: $result = 'psd'; break; case 6: $result = 'bmp'; break; case 7: $result = 'tif'; break; //(intel byte order), case 8: $result = 'tif'; break; //(motorola byte order), case 9: $result = 'jpc'; break; case 10: $result = 'jp2'; break; case 11: $result = 'jpx'; break; case 12: $result = 'jb2'; break; case 13: // there is a problem in some cases swf -> swc ? why ever! // do an additional extension check and compare against swf $result = (strtolower(which_ext($file)) == 'swf') ? 'swf' : 'swc'; break; case 14: $result = 'iff'; break; case 15: // there seems to be a problem with getimagesize and Quicktime VR // mov -> wmbf ? why ever! // do an additional extension check and compare against mov $result = (strtolower(which_ext( empty($filename) ? $file : $filename )) == 'mov') ? 'mov' : 'wbmp'; break; case 16: $result = 'xbm'; break; } } return $result; } function getParentStructArray($structID) { $structID = intval($structID); $sql = "SELECT * FROM ".DB_PREPEND."phpwcms_articlecat WHERE acat_id=".$structID." LIMIT 1"; if($result = mysql_query($sql, $GLOBALS['db'])) { if($row = mysql_fetch_assoc($result)) { return $row; } mysql_free_result($result); } return $GLOBALS['indexpage']; } /* * Get sort value for an article based on category */ function getArticleSortValue($cat_id=0) { // default sort value $sort = 0; $cat_id = intval($cat_id); $count = 0; $max_sort = 0; // Count all articles within the given structure ID $sql = "SELECT article_id, article_sort FROM ".DB_PREPEND."phpwcms_article "; $sql .= "WHERE article_cid=".$cat_id." "; $sql .= "ORDER BY article_sort DESC"; if($result = mysql_query($sql, $GLOBALS['db'])) { // this is the max articles in structure $count = mysql_num_rows($result); // but neccessary trying to get the highest article sort value if($row = mysql_fetch_assoc($result)) { $max_sort = $row['article_sort']; } mysql_free_result($result); } $count = ($count + 1) * 10; $count = ($max_sort < $count) ? $count : $max_sort + 10; return $count; } /* * Make a re-sort for given structure ID and * return new sorted articles as array */ function getArticleReSorted(& $cat_id, & $ordered_by) { // get all articles including deleted and update sorting // in correct sort order by adding sort + 10 $sort = 10; $sort_multiply_by = 1; $count_article = 0; $ao = get_order_sort($ordered_by); $sql = "SELECT article_id, article_cid, article_title, article_public, article_aktiv, article_uid, "; $sql .= "date_format(article_tstamp, '%Y-%m-%d %H:%i:%s') AS article_date, article_sort, article_deleted, article_tstamp "; $sql .= "FROM ".DB_PREPEND."phpwcms_article "; $sql .= "WHERE article_cid='".$cat_id."' ORDER BY ".$ao[2]; if($result = mysql_query($sql, $GLOBALS['db'])) { // now check if it's sorted manually and DESC // then sort has to be lowerd by -10 if($ao[0] == 0 && $ao[1] == 1) { $max_article_count = mysql_num_rows($result); $sort = ($max_article_count + 1) * 10; $sort_multiply_by = -1; } // take all entries and build new array with it while($row = mysql_fetch_assoc($result)) { // SQL update query with new sort value $update_sql = "UPDATE ".DB_PREPEND."phpwcms_article SET "; $update_sql .= "article_sort=".$sort.", "; $update_sql .= "article_tstamp='".$row['article_tstamp']."' "; $update_sql .= "WHERE article_id=".$row['article_id']." LIMIT 1"; @mysql_query($update_sql, $GLOBALS['db']); // add entry to the returning array only for article_deleted=0 // drops all deleted articles or articles having another status if($row['article_deleted'] == 0) { $article[$count_article] = $row; $article[$count_article]['article_sort'] = $sort; // count up for article array index $count_article++; } // count sort up by 10 $sort = $sort + (10 * $sort_multiply_by); } mysql_free_result($result); } return $article; } function phpwcmsversionCheck() { // Check for new version global $phpwcms; global $BL; if(empty($phpwcms['version_check'])) return ''; $errno = 0; $errstr = ''; $version_info = ''; if ($fsock = @fsockopen('www.phpwcms.de', 80, $errno, $errstr, 10)) { $identify = '?version='.rawurlencode(PHPWCMS_VERSION.'-'.str_replace('/', '', PHPWCMS_RELEASE_DATE)).'&hash='.md5($_SERVER['REQUEST_URI']); @fputs($fsock, "GET /versioncheck/phpwcms_releaseinfo.txt".$identify." HTTP/1.1\r\n"); @fputs($fsock, "HOST: www.phpwcms.de\r\n"); @fputs($fsock, "Connection: close\r\n\r\n"); $get_info = false; while (!@feof($fsock)) { if ($get_info) { $version_info .= @fread($fsock, 1024); } else { if (@fgets($fsock, 1024) == "\r\n") { $get_info = true; } } } @fclose($fsock); $version_info = explode("\n", $version_info); $latest_version = trim($version_info[0]); $latest_revdate = trim($version_info[1]); $latest_revision = intval(trim($version_info[2])); // do version check $check = $latest_revision > $phpwcms['revision'] ? false : true; if ($check) { $version_info = '

' . $BL['Version_up_to_date'] . '

'; $version_info .= '

'.sprintf($BL['Latest_version_info'], $latest_version.' ('.$latest_revdate.', r'.$latest_revision.')'). ' '; $version_info .= sprintf($BL['Current_version_info'], PHPWCMS_VERSION.' ('.PHPWCMS_RELEASE_DATE.', r'.PHPWCMS_REVISION.')') . '

'; } else { $version_info = '

' . $BL['Version_not_up_to_date'] . '

'; $version_info .= '

'.sprintf($BL['Latest_version_info'], ' ' . $latest_version . ' ('.$latest_revdate.', r'.$latest_revision.')'). ' '; $version_info .= sprintf($BL['Current_version_info'], PHPWCMS_VERSION.' ('.PHPWCMS_RELEASE_DATE.', r'.PHPWCMS_REVISION.')') . '

'; } } else { if ($errstr) { $version_info = '

' . sprintf($BL['Connect_socket_error'], $errstr) . '

'; } else { $version_info = '

' . $BL['Socket_functions_disabled'] . '

'; } } //$version_info .= '

' . $BL['Mailing_list_subscribe_reminder'] . '

'; return '

'.$BL['Version_information'].'

'.$version_info.'
'; } function createOptionTransferSelectList($id='', $leftData, $rightData, $option = array()) { // used to create global $BL; $id_left = $id.'_left'; $id_right = $id.'_right'; $id_left_box = $id_left.'list'; $id_right_box = $id_right.'list'; $option_object = generic_string(4, 4); $table = ''; $option['rows'] = empty($option['rows']) || !intval($option['rows']) ? 5 : $option['rows']; $option['delimeter'] = empty($option['delimeter']) ? ',' : $option['delimeter']; $option['encode'] = (isset($option['encode']) && $option['encode'] === false) ? false : true; $option['style'] = empty($option['style']) ? '' : ' style="'.$option['style'].'"'; $option['class'] = empty($option['class']) ? ' class="#SIDE#"' : ' class="#SIDE# '.$option['class'].'"'; $option['formname'] = empty($option['formname']) ? 'document.forms[0]' : 'document.getElementById(\''.$option['formname'].'\')'; $GLOBALS['BE']['HEADER']['optionselect.js'] = getJavaScriptSourceLink('include/inc_js/optionselect.js'); $table .= ''.LF.''.LF; // left select list $table .= ''.LF; // left <-> right buttons $table .= ''; $table .= ''.LF; $table .= ''.LF; // right select list $table .= ''.LF; $table .= ''.LF; $table .= ''.LF.''.LF; $table .= ''.LF; $table .= ''.LF; $table .= ''.LF.'
'; $table .= ''; $table .= ''; $table .= ''; $table .= ''; $table .= 'Move selected to right'; $table .= ''; $table .= 'Move all to right'; $table .= ''; $table .= 'Move selected to left'; $table .= ''; $table .= 'Move all to left'; $table .= '
'.LF; $table .= ''; $table .= ''; $table .= ''.LF; return $table; } function countNewsletterRecipients($target) { // try to count all recipients for special newsletter $recipients = _dbQuery('SELECT * FROM '.DB_PREPEND.'phpwcms_address WHERE address_verified=1'); $counter = 0; $check = (empty($target) || !is_array($target) || !count($target)) ? false : true; foreach($recipients as $value) { if(empty($value['address_subscription'])) { $counter++; continue; } elseif($check) { $value['address_subscription'] = unserialize($value['address_subscription']); if(is_array($value['address_subscription'])) { foreach($value['address_subscription'] as $subscr) { if(in_array(intval($subscr), $target)) { $counter++; break; } } } } } return $counter; } function getContentPartOptionTag($value='', $text='', $selected='', $module='') { $result = ''; // neccessary plugin check if($value == 30) { if(!isset($GLOBALS['temp_count'])) { $GLOBALS['temp_count'] = 0; } foreach($GLOBALS['phpwcms']['modules'] as $module_value) { if($module_value['cntp'] && file_exists($module_value['path'].'inc/cnt.list.php')) { $result .= '
'); $html_pos2 = strpos($BE['HTML'], ''); if($html_pos1 !== false && $html_pos2 !== false) { $html_pos1 += strlen(''); $html_pos2 -= 1; } $html = trim( preg_replace('/\s+/', ' ', substr($BE['HTML'], $html_pos1, $html_pos2-$html_pos1) ) ); $BE['HTML'] = substr($BE['HTML'], 0, $html_pos1) . substr($BE['HTML'], $html_pos2); // load MooTools too if(empty($phpwcms['mootools_mode'])) { initMootools(); } // init language replacements $regexp = array( 'search' => array(), 'replace' => array() ); $bracket = array('BBCODE_OPEN' => '[', 'BRACECODE_OPEN' => '{', 'BBCODE_CLOSE' => ']', 'BRACECODE_CLOSE' => '}'); $cookie = (empty($_COOKIE['phpwcms_be_parse_lang']) || !in_array($_COOKIE['phpwcms_be_parse_lang'], $phpwcms['allowed_lang'])) ? false : $_COOKIE['phpwcms_be_parse_lang']; // init menu $menu = array( ''; // wrap current lang/html with
$BE['HTML'] = replace_tmpl_section('BE_MAIN_CONTENT', $BE['HTML'], '
' . (empty($new_html) ? $html : $new_html) . '
'); backend_language_replace( implode(LF, $menu) ); } function backend_language_replace($result) { $GLOBALS['BE']['HTML'] = str_replace('{BE_PARSE_LANG}', $result, $GLOBALS['BE']['HTML']); return NULL; } ?>