 |
Energy Saving Tips
# This is code is only for development and must be commented or deleted
# when the script is parsed and not working locally:
# require_once("../data_sbp.php");
# $user_id = 9;
#Clear all variables
unset($archive_show);
unset($archive_start);
unset($archive_count);
unset($topic_id);
unset($ucb_quote_archive);
unset($quote_list);
#Client database identifier
$client_db = $scp_identifier."_".$user_id;
require_once("/home/htdocs/users/sitecrea/sitecrea/businesscreatorpro.com/"."admin/includes/dirtree.php"); #directory functions
require_once("/home/htdocs/users/sitecrea/sitecrea/businesscreatorpro.com/"."admin/includes/updater_lib.php");#updater functions
$display_dates = get_general_option('display_dates');
$display_navigation = get_general_option('display_navigation');
$display_arch_desc = get_general_option('display_arch_desc');
$display_max_updates = get_general_option('display_max_updates');
$date_format = get_general_option('date_format');
$ucb_quote_archive = "";
# $scp_identifier, $user_id and $MYSQL_DB are hardcoded inside the page
# Do not use null as variable because it is replaced by the parser!
$topic_id = (int) "null";
$today_date = date("Y-m-d");
#Extend for topic_id
if($topic_id == "null")
$topic_ext = "";
else
$topic_ext = "AND quotes.topic_id = '".$topic_id."'";
#Extend for the date
$date_ext = "AND quotes_schedule.date <= '$today_date'";
#Select client database
$mysql = mysql_select_db($client_db );
$mysql = mysql_query($mysql_query = "
SELECT DISTINCT
quotes.text AS `text`,
quotes.topic_id AS `topic_id`,
quotes.author AS `author`,
quotes.page_id AS `page_id`,
quotes_schedule.date AS `date`
FROM `quotes`,`quotes_schedule`
WHERE quotes.id = quotes_schedule.quote_id
$topic_ext
$date_ext
ORDER BY `date` DESC");
$archive_count = (int) mysql_num_rows($mysql);
if(isset($_POST['archive_show_'.$topic_id])){
$archive_show = (int) $_POST['archive_show_'.$topic_id];
}
elseif( isset($_SESSION['archive_show_'.$topic_id]) ){
$archive_show = (int) $_SESSION['archive_show_'.$topic_id];
}
else{
$archive_show = 0;
};
$_SESSION['archive_show_'.$topic_id] = $archive_show;
if(isset($_POST['archive_start_'.$topic_id])){
$archive_start = (int) $_POST['archive_start_'.$topic_id];
}
elseif( isset($_SESSION['archive_start_'.$topic_id]) ){
$archive_start = (int) $_SESSION['archive_start_'.$topic_id];
}
else{
$archive_start = 1;
};
if($archive_show != 0 and $archive_start > $archive_count)
$archive_start = 1+$archive_show*floor($archive_count/$archive_show);
if($archive_start < 1)
$archive_start = 1;
#$archive_show logic depedend on general options
if($display_navigation != "on"){
if($display_max_updates == "unknown" or empty($display_max_updates) )
$archive_show = 0;
else
$archive_show = $display_max_updates;
};
$_SESSION['archive_start_'.$topic_id] = $archive_start;
if($archive_show == 0)
$limit_ext = "";
else
$limit_ext = "LIMIT ".($archive_start-1).",".($archive_show);
####################
## Database query ##
####################
$mysql = mysql_query($mysql_query = "
SELECT DISTINCT
quotes.text AS `text`,
quotes.topic_id AS `topic_id`,
quotes.author AS `author`,
quotes.page_id AS `page_id`,
quotes_schedule.date AS `date`
FROM `quotes`,`quotes_schedule`
WHERE quotes.id = quotes_schedule.quote_id
$topic_ext
$date_ext
ORDER BY `date` DESC
$limit_ext");
//echo($mysql_query);
if($mysql != false){
if(mysql_num_rows($mysql) > 0){
for($i = 0; $i < mysql_num_rows($mysql); $i++){
$quote_row = mysql_fetch_assoc($mysql);
#Preapre a short text up to 9 words
$quote_word = explode(" ", strip_tags($quote_row['text']) );
$quote_short_text = "";
for($j = 0; ($j < count($quote_word)) and ($j < 9); $j++){
$quote_short_text .= " ".$quote_word[$j];
};
$quote_list[$i]['short_text'] = $quote_short_text;
$quote_list[$i]['author'] = $quote_row['author'];
$quote_list[$i]['page_id'] = (int) $quote_row['page_id'];
if($date_format == "mm-dd-yyyy"){
# yyyy-mm-dd
$year = substr($quote_row['date'],0,4);
$month = substr($quote_row['date'],5,2);
$day = substr($quote_row['date'],8,2);
$quote_list[$i]['date'] = "$month-$day-$year";
}
else{
$quote_list[$i]['date'] = $quote_row['date'];
}
# From main database
$mysql_2 = mysql_select_db($MYSQL_DB);
$mysql_2 = mysql_query("
SELECT `dir_id`,`file_name`,`title`,`description`
FROM `page`
WHERE `page_id` = '".$quote_list[$i]['page_id']."'");
$page_row = mysql_fetch_row($mysql_2);
$quote_list[$i]['title'] = $page_row[2];
$quote_list[$i]['description'] = $page_row[3];
$quote_list[$i]['href'] = getDirPath((int) $page_row[0])."/".$page_row[1];
if( !defined( "BCPCWB_PUBLISHED" ) )
$quote_list[$i]['href'] = "/sites/"."$user_name".getDirPath((int) $page_row[0])."/".$page_row[1];
}#end for
}# end if
}# end if
#########################
#Consruct archive page ##
#########################
$ucb_quote_archive .= "
";
}
else{
$ucb_quote_archive .= "
| No entries |
|
";
};#end if(count($quote_list) > 0)
#Back to main database
$mysql = mysql_select_db($MYSQL_DB);
echo($ucb_quote_archive);
?>
|
|
|