'; print_r($array); echo ''; } function printResponse(){ if(isset($_SESSION['error']) && !empty($_SESSION['error'])){ $exists=array(); echo '
'; unset($_SESSION['error']); } } function errorField($field){ if(isset($_SESSION['errorfield'])){ foreach($_SESSION['errorfield'] as $key=>$value){ if($value==$field){ echo 'background-color:#f15e57;padding:5px;'; unset($_SESSION['errorfield'][$key]); } } } } //Generates pager based on: //total - total number of elements listed //perpae - elements displayed per page //currentpage - page we are currently on function createPager($totalaccounts,$perpage,$currentpage){ if($totalaccounts>0){ $pages=ceil($totalaccounts/$perpage); if($currentpage<=0){ echo ' '.SB('translations:previous').' '; } else { echo ' '.SB('translations:previous').' '; } for($i=1;$i<=$pages;$i++){ if($i==$currentpage+1){ echo ' '.$i.' '; } else { echo ' '.$i.' '; } } if(($currentpage+1)>=$pages){ echo ' '.SB('translations:next').' '; } else { echo ' '.SB('translations:next').' '; } } } //Strips HTML and shortens the text function shortenText($content,$length=330){ $original=strip_tags($content); $target=substr($original,$length); $limiter=explode(' ',$target); $cut=substr($original,0,($length+strlen($limiter[0]))); if($cut!=$original){ $cut=$cut.' ...'; } return $cut; } //Search results //requires 'pages' and 'read more' as translation keys //Add other searches here if needed //THIS WILL BE CHANGED TO RETURN AN ARRAY!!! function searchResults($searchkey){ if($searchkey!='' && strlen($searchkey)>=3){ $found=false; $searchkey=explode(' ',$searchkey); //PAGES $searchterms=array(); foreach($searchkey as $sk){ $searchterms[]='(title LIKE "%'.mysql_real_escape_string($sk).'%" OR content LIKE "%'.mysql_real_escape_string($sk).'%")'; } $pages=dbMatrix('SELECT fullurl,linked_url,title,content FROM '.SANDBOX_TABLE_PAGES.' WHERE searchhidden="0" AND ('.implode(' AND ', $searchterms).') AND '.SANDBOX_ACTIVITY_ALL.';'); if($pages){ $found=true; echo '';
echo ''.$p['title'].''; echo ' | ';
echo '
'; echo shortenText($p['content']); echo ''; echo ' | '; echo '
'.SB('translations:no matches found').'
'; } } else { echo ''.SB('translations:search key too short').'
'; } } /** * * Function for doing systemlog entry * @param $message string Message which will be inserted * @param $module string Module name - made it default to PUBLIC if no value given * @param $objectid * @param $level */ function insertLog($message, $module = 'PUBLIC', $objectid = 0, $level = 0){ if (isset($_SESSION['user_id'])) { $user=dbSingle('SELECT * FROM users WHERE id="'.mysql_real_escape_string($_SESSION['user_id']).'";'); $user_id = $_SESSION['user_id']; } else { $user_id = 0; } $object=dbSingle('SELECT * FROM '.mysql_real_escape_string($module).' WHERE id="'.mysql_real_escape_string($objectid).'";'); if(isset($object['name'])){ $objectname=$object['name']; } else if(isset($object['title'])){ $objectname=$object['title']; } else if(isset($object['title_1'])){ $objectname=$object['title_1']; } else { $objectname='(no name set)'; } if(!$user){ $username='SYSTEM'; } else { $username=$user['username']; } $backtrace = debug_backtrace(); // for debugging $caller_file = mysql_real_escape_string($backtrace[0]['file']); $caller_line = mysql_real_escape_string($backtrace[0]['line']); if($objectid>0){ $query = 'INSERT INTO systemlog SET ip = "'.mysql_real_escape_string($_SERVER['REMOTE_ADDR']).'", host = "'.mysql_real_escape_string(gethostbyaddr($_SERVER['REMOTE_ADDR'])).'", user_id = "'.mysql_real_escape_string($user_id).'", username = "'.mysql_real_escape_string($username).'", user = "'.mysql_real_escape_string($user_id).':'.mysql_real_escape_string($username).'", object_id = "'.mysql_real_escape_string($object['id']).'", object_name = "'.mysql_real_escape_string($objectname).'", object = "'.mysql_real_escape_string($object['id']).':'.mysql_real_escape_string($module).'", time = "'.time().'", module = "'.mysql_real_escape_string($module).'",'; if ($level > 0) { //we only insert caller location for errors $query.= 'caller_location = "Line: '.$caller_line.' in '.$caller_file.'",'; } $query.= ' level = "'.$level.'", message = "'.mysql_real_escape_string($message).'";'; dbCommand($query); } else { $query = 'INSERT INTO systemlog SET ip = "'.mysql_real_escape_string($_SERVER['REMOTE_ADDR']).'", host = "'.mysql_real_escape_string(gethostbyaddr($_SERVER['REMOTE_ADDR'])).'", user_id = "'.mysql_real_escape_string($user_id).'", username = "'.mysql_real_escape_string($username).'", user = "'.mysql_real_escape_string($user_id).':'.mysql_real_escape_string($username).'", object_id = "0", object_name = "PUBLIC", object = "PUBLIC", time = "'.time().'", module = "'.mysql_real_escape_string($module).'",'; if ($level > 0) { //we only insert caller location for errors $query.= 'caller_location = "Line: '.$caller_line.' in '.$caller_file.'",'; } $query.= ' level = "'.$level.'", message = "'.mysql_real_escape_string($message).'";'; dbCommand($query); } } /** * * Function for quick debug * @param mixed $input Input data * @param int $output_type 0 = print_r | 1 = var_dump */ function d($input = '', $output_type = 0) { $debug_backtrace = debug_backtrace(); echo "\n"; echo "Debug line: '{$debug_backtrace[0]['line']}'\n"; echo "Debug file: '{$debug_backtrace[0]['file']}'\n\n"; if ($output_type != 0) { var_dump($input); } else { print_r($input); } echo "\n\n"; } //Returns an array of website sitemap function getSitemap(){ //TO BE ADDED } //Returns pages menu array based on root page function returnMenu($root,$table='pages',$connection='parent_id'){ //TO BE ADDED } //returns an array of feedback form elements function drawFeedback($type){ //TO BE ADDED } //submits data to feedback based on feedback type function submitFeedback($type, $data){ //TO BE ADDED } ?>