| [ PHPXref.com ] | [ Generated: Sun Jul 20 20:03:44 2008 ] | [ PluggedOut Blog 1.9.9e ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 #=========================================================================== 4 #= Project: PluggedOut Blog 5 #= File : lib/html.php 6 #= Version: 1.9.9e (2006-04-12) 7 #= Author : Jonathan Beckett 8 #= Email : jonbeckett@pluggedout.com 9 #= Website: http://www.pluggedout.com/index.php?pk=dev_blog 10 #= Support: http://www.pluggedout.com/development/forums/viewforum.php?f=26 11 #=========================================================================== 12 #= Copyright (c) 2005 Jonathan Beckett 13 #= You are free to use and modify this script as long as this header 14 #= section stays intact. This file is part of PluggedOut Blog. 15 #= 16 #= This program is free software; you can redistribute it and/or modify 17 #= it under the terms of the GNU General Public License as published by 18 #= the Free Software Foundation; either version 2 of the License, or 19 #= (at your option) any later version. 20 #= 21 #= This program is distributed in the hope that it will be useful, 22 #= but WITHOUT ANY WARRANTY; without even the implied warranty of 23 #= MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 #= GNU General Public License for more details. 25 #= 26 #= You should have received a copy of the GNU General Public License 27 #= along with CMS files; if not, write to the Free Software 28 #= Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 29 #=========================================================================== 30 */ 31 32 // ***************************************************************************************** 33 // ** PRIVATE FUNCTIONS ** 34 // ***************************************************************************************** 35 36 37 // Description : Constructs the HTML representing a month-view calendar 38 // Arguments : year - The year the calendar should show 39 // month - The month the calendar should show 40 // Returns : HTML 41 // Last Change : 2005-04-02 42 // Author : Jonathan Beckett (jonbeckett@pluggedout.com) 43 function build_calendar($year="",$month="") { 44 45 global $theme; 46 47 // validate data 48 if ($month==""){ 49 // if we have no month, make it THIS month 50 $month = date("n"); 51 } 52 53 if ($year==""){ 54 // if we have no year, make it THIS year 55 $year = date("Y"); 56 } 57 58 global $monthnames_long; 59 global $monthnames_short; 60 global $daynames_long; 61 global $daynames_short; 62 63 // fill an array with number of entries per day for hilighting purposes 64 $con = db_connect(); 65 $sql = db_sql_calendar_counts($year,$month); 66 $result = mysql_query($sql,$con); 67 if ($result!=false){ 68 while($row =@ mysql_fetch_array($result)){ 69 $calendar_counts[$row["nDay"]] = $row["nCount"]; 70 } 71 } else { 72 report_problem(1,"<b>build_calendar</b>\n\n".mysql_error()."\n\n".$sql); 73 } 74 75 define ('ADAY', (60*60*24)); 76 77 // make arrays of values representing the first of the month 78 $datearray = getdate(mktime(0,0,0,$month,1,$year)); 79 $start = mktime(0,0,0,$month,1,$year); 80 81 $firstdayarray = getdate($start); 82 83 // work out the URLs for previous and next buttons 84 // default 85 $prev_month = $month - 1; 86 $prev_year = $year; 87 $next_month = $month + 1; 88 $next_year = $year; 89 90 // handle exceptions 91 // end of year 92 if ($month==12) { 93 $prev_month = $month - 1; 94 $prev_year = $year; 95 $next_month = 1; 96 $next_year = $year + 1; 97 } 98 // start of year 99 if ($month==1) { 100 $prev_month = 12; 101 $prev_year = $year - 1; 102 $next_month = $month + 1; 103 $next_year = $year; 104 } 105 $url_next = $_SERVER["PHP_SELF"]."?month=".$next_month."&year=".$next_year; 106 $url_prev = $_SERVER["PHP_SELF"]."?month=".$prev_month."&year=".$prev_year; 107 108 109 // get template for entire calendar area 110 $html = theme_calendar_section(); 111 112 // do the replacements 113 $html = str_replace("<!--month_previous_url-->",$url_prev,$html); 114 $html = str_replace("<!--month_current_url-->","index.php?year=".$year."&month=".$month,$html); 115 $html = str_replace("<!--month_next_url-->",$url_next,$html); 116 117 $html = str_replace("<!--monthname_long-->",$monthnames_long[$datearray["mon"]-1],$html); 118 $html = str_replace("<!--year-->",$year,$html); 119 120 // get templates for various squares 121 $t_day_heading = theme_calendar_day_heading(); 122 $t_day_empty = theme_calendar_day_empty(); 123 $t_day_on = theme_calendar_day_on(); 124 $t_day_off = theme_calendar_day_off(); 125 $t_day_today = theme_calendar_day_today(); 126 $t_calendar_sep = theme_calendar_row_seperator(); 127 128 foreach($daynames_short as $day) 129 { 130 $day_heading = $t_day_heading; 131 $day_heading = str_replace("<!--day_heading-->",$day,$day_heading); 132 $day_headings .= $day_heading; 133 } 134 135 $html = str_replace("<!--day_headings-->",$day_headings,$html); 136 137 // Create the rows of days 138 for ($count=1;$count<(6*7+1);$count++){ 139 140 $dayarray = getdate($start); 141 142 // new rows on mondays 143 if((($count) % 7) == 1) { 144 if($dayarray['mon'] != $datearray['mon']) break; 145 $html_days .= $t_calendar_sep; 146 } 147 148 if ($firstdayarray["wday"]==0) { 149 $firstday = 7; 150 } else { 151 $firstday = $firstdayarray["wday"]; 152 } 153 154 if($count < $firstday || $dayarray['mon'] != $month) { 155 156 $html_days .= $t_day_empty; 157 158 } else { 159 160 // build the html for a day within the calendar 161 $date_url = "index.php?year=".$dayarray["year"]."&month=".$dayarray["mon"]."&day=".$dayarray["mday"]; 162 163 $today = getdate(); 164 165 // work out if the current day is today 166 if ( ($today["year"] == $dayarray["year"]) && ($today["mon"] == $dayarray["mon"]) && ($today["mday"] == $dayarray["mday"]) ){ 167 $html_day = $t_day_today; 168 $html_day = str_replace("<!--day-->","<a class='calendar_link' href='".$date_url."'>".$dayarray[mday]."</a>",$html_day); 169 } else { 170 if ($calendar_counts[$dayarray[mday]]>0){ 171 $html_day = $t_day_on; 172 $html_day = str_replace("<!--day-->","<a class='calendar_link' href='".$date_url."'>".$dayarray[mday]."</a>",$html_day); 173 } else { 174 $html_day = $t_day_off; 175 $html_day = str_replace("<!--day-->",$dayarray[mday],$html_day); 176 } 177 } 178 179 $html_days .= $html_day; 180 181 $start += ADAY; 182 183 // check that day has moved on (to solve the daylight savings problem) 184 $testday = getdate($start); 185 if ($testday["yday"]==$dayarray["yday"]){ 186 $start += (ADAY/2); 187 } 188 } 189 } 190 191 // put the days into the calendar 192 $html = str_replace("<!--calendar_days-->",$html_days,$html); 193 194 db_disconnect($con); 195 196 return $html; 197 } 198 199 200 // Description : Constructs the HTML representing the <!--entry_list--> section of a page 201 // Arguments : sql_entrylist - the SQL required to provide records to build the HTML 202 // Returns : HTML 203 // Last Change : 2005-04-02 204 // Author : Jonathan Beckett (jonbeckett@pluggedout.com) 205 function build_entrylist($sql_entrylist){ 206 207 global $theme; 208 global $daynames_long; 209 global $daynames_short; 210 global $monthnames_long; 211 global $monthnames_short; 212 213 $con = db_connect(); 214 $result_entrylist = mysql_query($sql_entrylist,$con); 215 if ($result_entrylist!=false){ 216 217 // get the entries from the database 218 if (mysql_num_rows($result_entrylist)>0){ 219 220 // loop throught the entries 221 while ($row =@ mysql_fetch_array($result_entrylist)){ 222 223 // get the template for one item in the list 224 $html_item = theme_entrylist_item(); 225 226 // do replaces against that template to put data in place 227 $html_item = str_replace("<!--entryid-->",$row["nEntryId"],$html_item); 228 $html_item = str_replace("<!--url-->","index.php?entryid=".$row["nEntryId"],$html_item); 229 $html_item = str_replace("<!--title-->",stripslashes($row["cTitle"]),$html_item); 230 $html_item = str_replace("<!--user_added-->",stripslashes($row["cUserAdded"]),$html_item); 231 $html_item = str_replace("<!--user_edited-->",stripslashes($row["cUserEdited"]),$html_item); 232 $html_item = str_replace("<!--comments_num-->",$row["dEdited"],$html_item); 233 234 // do date added replacements 235 $a_date_added = db_datetoarray($row["dAdded"]); 236 $html_item = str_replace("<!--date_added-->",$row["dAdded"],$html_item); 237 $html_item = str_replace("<!--date_added_daynum-->",$a_date_added["mday"]+1,$html_item); 238 $html_item = str_replace("<!--date_added_dayname_long-->",$daynames_long[$a_date_added["wday"]],$html_item); 239 $html_item = str_replace("<!--date_added_dayname_short-->",$daynames_short[$a_date_added["wday"]],$html_item); 240 $html_item = str_replace("<!--date_added_monthnum-->",$a_date_added["mon"]+1,$html_item); 241 $html_item = str_replace("<!--date_added_monthname_long-->",$monthnames_long[$a_date_added["mon"]],$html_item); 242 $html_item = str_replace("<!--date_added_monthname_short-->",$monthnames_short[$a_date_added["mon"]],$html_item); 243 $html_item = str_replace("<!--date_added_yearnum-->",$a_date_added["year"],$html_item); 244 $html_item = str_replace("<!--date_added_hour-->",$a_date_added["hours"],$html_item); 245 $html_item = str_replace("<!--date_added_minute-->",$a_date_added["minutes"],$html_item); 246 $html_item = str_replace("<!--date_added_second-->",$a_date_added["seconds"],$html_item); 247 248 // do date edited replacements 249 $a_date_edited = db_datetoarray($row["dEdited"]); 250 $html_item = str_replace("<!--date_edited-->",$row["dEdited"],$html_item); 251 $html_item = str_replace("<!--date_edited_daynum-->",$a_date_edited["mday"]+1,$html_item); 252 $html_item = str_replace("<!--date_edited_dayname_long-->",$daynames_long[$a_date_edited["wday"]],$html_item); 253 $html_item = str_replace("<!--date_edited_dayname_short-->",$daynames_short[$a_date_edited["wday"]],$html_item); 254 $html_item = str_replace("<!--date_edited_monthnum-->",$a_date_edited["mon"]+1,$html_item); 255 $html_item = str_replace("<!--date_edited_monthname_long-->",$monthnames_long[$a_date_edited["mon"]],$html_item); 256 $html_item = str_replace("<!--date_edited_monthname_short-->",$monthnames_short[$a_date_edited["mon"]],$html_item); 257 $html_item = str_replace("<!--date_edited_yearnum-->",$a_date_edited["year"],$html_item); 258 $html_item = str_replace("<!--date_edited_hour-->",$a_date_edited["hours"],$html_item); 259 $html_item = str_replace("<!--date_edited_minute-->",$a_date_edited["minutes"],$html_item); 260 $html_item = str_replace("<!--date_edited_second-->",$a_date_edited["seconds"],$html_item); 261 262 // put the constructed item inside an array 263 $a_html_items[] = $html_item; 264 } 265 // construct the section 266 $html_items = implode(theme_entrylist_seperator(),$a_html_items); 267 268 } else { 269 // no entries 270 $html_items = theme_entrylist_noitems(); 271 } 272 273 // get the section template 274 $html_section = theme_entrylist_section(); 275 276 // put the entries within the section template 277 $html_section = str_replace("<!--items-->",$html_items,$html_section); 278 279 } else { 280 report_problem(1,"build_entrylist ".$sql_entrylist); 281 } 282 283 db_disconnect($con); 284 285 return $html_section; 286 287 } 288 289 290 // Description : Constructs the HTML representing the <!--entry_view--> section of a page 291 // Arguments : sql_entryview - the SQL required to provide records to build the HTML 292 // Returns : HTML 293 // Last Change : 2005-04-02 294 // Author : Jonathan Beckett (jonbeckett@pluggedout.com) 295 function build_entryview($sql_entryview){ 296 297 global $theme; 298 global $daynames_long; 299 global $daynames_short; 300 global $monthnames_long; 301 global $monthnames_short; 302 303 // get any settings required later 304 $parse_smilies = get_setting("parse_smilies"); 305 $parse_crlf = get_setting("parse_crlf"); 306 $timezone = get_setting("timezone"); 307 308 $con = db_connect(); 309 $result_entryview = mysql_query($sql_entryview,$con);# 310 if ($result_entryview!=false){ 311 312 // get the entries from the database 313 if (mysql_num_rows($result_entryview)>0){ 314 315 // loop throught the entries 316 while ($row =@ mysql_fetch_array($result_entryview)){ 317 318 // prepare the body text 319 $body = stripslashes($row["cBody"]); 320 321 // Change carriage returns to line breaks 322 if ($parse_crlf!=""){ 323 $body = nl2br($body); 324 } 325 326 // Implement BBCode 327 $body = bbcode($body); 328 329 if ($parse_smilies=="x"){ 330 $body = parse_smilies($body); 331 } 332 333 // get the template for one item in the list 334 $html_item = theme_entryview_item(); 335 336 $date_added = $row["dAdded"]; 337 338 // do replaces against that template to put data in place 339 $html_item = str_replace("<!--entryid-->",$row["nEntryId"],$html_item); 340 $html_item = str_replace("<!--entry_url-->","index.php?entryid=".$row["nEntryId"],$html_item); 341 $html_item = str_replace("<!--title-->",strip_tags(stripslashes($row["cTitle"])),$html_item); 342 $html_item = str_replace("<!--body-->",$body,$html_item); 343 $html_item = str_replace("<!--user_added-->",strip_tags(stripslashes($row["cUserAdded"])),$html_item); 344 $html_item = str_replace("<!--user_edited-->",strip_tags(stripslashes($row["cUserEdited"])),$html_item); 345 $html_item = str_replace("<!--comment_count-->",$row["nComments"],$html_item); 346 $html_item = str_replace("<!--comment_url-->","index.php?entryid=".$row["nEntryId"],$html_item); 347 348 // do date added replacements 349 $a_date_added = db_datetoarray($row["dAdded"]); 350 $html_item = str_replace("<!--date_added-->",$row["dAdded"],$html_item); 351 $html_item = str_replace("<!--date_added_daynum-->",$a_date_added["mday"]+1,$html_item); 352 $html_item = str_replace("<!--date_added_dayname_long-->",$daynames_long[$a_date_added["wday"]],$html_item); 353 $html_item = str_replace("<!--date_added_dayname_short-->",$daynames_short[$a_date_added["wday"]],$html_item); 354 $html_item = str_replace("<!--date_added_monthnum-->",$a_date_added["mon"]+1,$html_item); 355 $html_item = str_replace("<!--date_added_monthname_long-->",$monthnames_long[$a_date_added["mon"]],$html_item); 356 $html_item = str_replace("<!--date_added_monthname_short-->",$monthnames_short[$a_date_added["mon"]],$html_item); 357 $html_item = str_replace("<!--date_added_yearnum-->",$a_date_added["year"],$html_item); 358 $html_item = str_replace("<!--date_added_hour-->",$a_date_added["hours"],$html_item); 359 $html_item = str_replace("<!--date_added_minute-->",$a_date_added["minutes"],$html_item); 360 $html_item = str_replace("<!--date_added_second-->",$a_date_added["seconds"],$html_item); 361 362 // do date edited replacements 363 $a_date_edited = db_datetoarray($row["dEdited"]); 364 $html_item = str_replace("<!--date_edited-->",$row["dEdited"],$html_item); 365 $html_item = str_replace("<!--date_edited_daynum-->",$a_date_edited["mday"]+1,$html_item); 366 $html_item = str_replace("<!--date_edited_dayname_long-->",$daynames_long[$a_date_edited["wday"]],$html_item); 367 $html_item = str_replace("<!--date_edited_dayname_short-->",$daynames_short[$a_date_edited["wday"]],$html_item); 368 $html_item = str_replace("<!--date_edited_monthnum-->",$a_date_edited["mon"]+1,$html_item); 369 $html_item = str_replace("<!--date_edited_monthname_long-->",$monthnames_long[$a_date_edited["mon"]],$html_item); 370 $html_item = str_replace("<!--date_edited_monthname_short-->",$monthnames_short[$a_date_edited["mon"]],$html_item); 371 $html_item = str_replace("<!--date_edited_yearnum-->",$a_date_edited["year"],$html_item); 372 $html_item = str_replace("<!--date_edited_hour-->",$a_date_edited["hours"],$html_item); 373 $html_item = str_replace("<!--date_edited_minute-->",$a_date_edited["minutes"],$html_item); 374 $html_item = str_replace("<!--date_edited_second-->",$a_date_edited["seconds"],$html_item); 375 376 // build a list of categories that the entry is filed against and put them in the template 377 $sql = db_sql_entry_categorylist($row["nEntryId"]); 378 $result = mysql_query($sql,$con); 379 if ($result!=false){ 380 if (mysql_num_rows($result)>0){ 381 unset($a_items); 382 while ($row=@mysql_fetch_array($result)){ 383 $catlist_item = theme_entry_categorylist_item(); 384 $catlist_item = str_replace("<!--item_url-->","index.php?categoryid=".$row["nCategoryId"],$catlist_item); 385 386 $a_items[] = "<a href='index.php?categoryid=".$row["nCategoryId"]."'>".stripslashes($row["cCategoryName"])."</a>"; 387 } 388 $html_catlist_items = implode("<!--entry_categorylist_seperator-->",$a_items); 389 $html_catlist_items = str_replace("<!--entry_categorylist_seperator-->",theme_entry_categorylist_seperator(),$html_catlist_items); 390 } else { 391 $html_catlist_items = theme_entry_categorylist_noitems(); 392 } 393 } 394 $html_catlist_section = theme_entry_categorylist_section(); 395 $html_catlist_section = str_replace("<!--items-->",$html_catlist_items,$html_catlist_section); 396 397 $html_item = str_replace("<!--entry_categorylist-->",$html_catlist_section,$html_item); 398 399 // Replace the next and previous links 400 if (isset($_GET["entryid"])){ 401 if ($_GET["entryid"]!=""){ 402 $html_entry_link_section = theme_entry_link_section(); 403 $html_entry_link_section = str_replace("<!--link_previous-->",build_previouslink($date_added),$html_entry_link_section); 404 $html_entry_link_section = str_replace("<!--link_next-->",build_nextlink($date_added),$html_entry_link_section); 405 $html_item = str_replace("<!--entry_link_section-->",$html_entry_link_section,$html_item); 406 407 } 408 } 409 410 // put the constructed item inside an array 411 $a_html_items[] = $html_item; 412 } 413 // construct the section 414 $html_items = implode(theme_entryview_seperator(),$a_html_items); 415 416 } else { 417 // no entries 418 $html_items = theme_entryview_noitems(); 419 } 420 421 // get the section template 422 $html_section = theme_entryview_section(); 423 424 // put the entries within the section template 425 $html_section = str_replace("<!--items-->",$html_items,$html_section); 426 427 } else { 428 report_problem(1,"build_entryview ".$sql_entryview); 429 } 430 431 db_disconnect($con); 432 433 return $html_section; 434 } 435 436 437 // Description : Constructs the HTML representing the <!--category_list--> section of a page 438 // Arguments : sql_categories - the SQL required to provide records to build the HTML 439 // Returns : HTML 440 // Last Change : 2005-04-02 441 // Author : Jonathan Beckett (jonbeckett@pluggedout.com) 442 function build_categorylist($sql_categories){ 443 444 global $theme; 445 446 $con = db_connect(); 447 $result_categories = mysql_query($sql_categories,$con); 448 449 if ($result_categories!=false){ 450 451 if (mysql_num_rows($result_categories)>0){ 452 while ($row =@ mysql_fetch_array($result_categories)){ 453 454 // get the template for an item in the category list 455 $html_item = theme_categorylist_item(); 456 457 // replace data into it from the category data 458 $html_item = str_replace("<!--url-->","index.php?categoryid=".stripslashes($row["nCategoryId"]),$html_item); 459 $html_item = str_replace("<!--name-->",strip_tags(stripslashes($row["cCategoryName"]))." (".$row["nCount"].")",$html_item); 460 461 $a_html_items[] = $html_item; 462 } 463 $html_items = implode(theme_categorylist_seperator(),$a_html_items); 464 } else { 465 $html_items = theme_categorylist_noitems(); 466 } 467 468 // get the category list section template 469 $html_section = theme_categorylist_section(); 470 471 // put the categories into the template 472 $html_section = str_replace("<!--items-->",$html_items,$html_section); 473 474 } else { 475 report_problem(1,"build_categorylist ".$sql_categories); 476 } 477 478 db_disconnect($con); 479 480 return $html_section; 481 } 482 483 484 // Description : Constructs the HTML representing the <!--comments--> section of a page 485 // Arguments : sql_comments - the SQL required to provide records to build the HTML 486 // Returns : HTML 487 // Last Change : 2005-04-02 488 // Author : Jonathan Beckett (jonbeckett@pluggedout.com) 489 function build_comments($sql_comments){ 490 491 global $theme; 492 global $daynames_short; 493 global $daynames_long; 494 global $monthnames_short; 495 global $monthnames_long; 496 497 global $lang; 498 499 $con = db_connect(); 500 $result_comments = mysql_query($sql_comments,$con); 501 if ($result_comments!=false){ 502 503 if (mysql_num_rows($result_comments)>0){ 504 while ($row =@ mysql_fetch_array($result_comments)){ 505 // get the template for a comment list item 506 $html_item = theme_commentlist_item(); 507 508 // replace data into the template from the comment record source 509 $html_item = str_replace("<!--name-->",strip_tags(stripslashes($row["cName"])),$html_item); 510 $html_item = str_replace("<!--email-->",strip_tags(stripslashes($row["cEMail"])),$html_item); 511 $html_item = str_replace("<!--url-->",strip_tags(stripslashes($row["cURL"])),$html_item); 512 $html_item = str_replace("<!--comment-->",nl2br(strip_tags(stripslashes($row["cComment"]))),$html_item); 513 514 $a_date_added = db_datetoarray($row["dAdded"]); 515 $html_item = str_replace("<!--date_added-->",$row["dAdded"],$html_item); 516 $html_item = str_replace("<!--date_added_daynum-->",$a_date_added["mday"]+1,$html_item); 517 $html_item = str_replace("<!--date_added_dayname_long-->",$daynames_long[$a_date_added["wday"]],$html_item); 518 $html_item = str_replace("<!--date_added_dayname_short-->",$daynames_short[$a_date_added["wday"]],$html_item); 519 $html_item = str_replace("<!--date_added_monthnum-->",$a_date_added["mon"]+1,$html_item); 520 $html_item = str_replace("<!--date_added_monthname_long-->",$monthnames_long[$a_date_added["mon"]],$html_item); 521 $html_item = str_replace("<!--date_added_monthname_short-->",$monthnames_short[$a_date_added["mon"]],$html_item); 522 $html_item = str_replace("<!--date_added_yearnum-->",$a_date_added["year"],$html_item); 523 $html_item = str_replace("<!--date_added_hour-->",$a_date_added["hours"],$html_item); 524 $html_item = str_replace("<!--date_added_minute-->",$a_date_added["minutes"],$html_item); 525 $html_item = str_replace("<!--date_added_second-->",$a_date_added["seconds"],$html_item); 526 527 $a_html_items[] = $html_item; 528 } 529 $html_items = implode(theme_commentlist_seperator(),$a_html_items); 530 } else { 531 $html_items = theme_commentlist_noitems(); 532 } 533 534 // get the comment section and form templates 535 $html_section = theme_commentlist_section(); 536 $html_comment_form = theme_comment_form(); 537 538 // put the comments into the template 539 $html_section = str_replace("<!--items-->",$html_items,$html_section); 540 541 // put the verify code into the comment form, and keep track of it in the session 542 543 // make the code 544 $code = ""; 545 $sourcedata = array("a","b","c","d","e","f","1","2","3","4","5","6","7","8","9"); 546 for ($i=0;$i<8;$i++){ 547 $code .= $sourcedata[rand(0,15)]; 548 } 549 $_SESSION["blog_verifycode"] = $code; 550 551 // put the verify code into the template 552 $html_comment_form = str_replace("<!--verify_code-->","<img src='lib/code_image.php' width='80' height='20'>",$html_comment_form); 553 554 // substitute the entryid placeholder 555 $html_comment_form = str_replace("<!--entryid-->",$_REQUEST["entryid"],$html_comment_form); 556 557 // reset the variables 558 $name = ""; 559 $email = ""; 560 $url = ""; 561 562 // if the form values are in the COOKIES get them 563 $name = $_COOKIE["pluggedout_blog_name"]; 564 $email = $_COOKIE["pluggedout_blog_email"]; 565 $url = $_COOKIE["pluggedout_blog_url"]; 566 567 // if the cookies were found, tick the remember box 568 if ($name!=""){ 569 $html_comment_form = str_replace("name='remember'","name='remember' checked",$html_comment_form); 570 } 571 572 // if the form values are in the GET variables, use them instead 573 // (they may have changed them if they are a previous commenter) 574 if (isset($_REQUEST["name"])) $name = $_REQUEST["name"]; 575 if (isset($_REQUEST["email"])) $email = $_REQUEST["email"]; 576 if (isset($_REQUEST["url"])) $url = $_REQUEST["url"]; 577 578 // put previous values into the comment form (they will be populated if the verify code was wrong) 579 $html_comment_form = str_replace("<!--name-->",urldecode($name),$html_comment_form); 580 $html_comment_form = str_replace("<!--email-->",urldecode($email),$html_comment_form); 581 $html_comment_form = str_replace("<!--url-->",urldecode($url),$html_comment_form); 582 $html_comment_form = str_replace("<!--comment-->",urldecode($_REQUEST["comment"]),$html_comment_form); 583 584 // put the comment form into the section template 585 $html_section = str_replace("<!--comment_form-->",$html_comment_form,$html_section); 586 587 } else { 588 report_problem(1,"build_comments ".$sql_comments); 589 } 590 591 db_disconnect($con); 592 593 return $html_section; 594 } 595 596 597 function build_previouslink($datetime){ 598 599 global $db_prefix; 600 601 $con = db_connect(); 602 603 $sql = "SELECT nEntryId,cTitle FROM ".$db_prefix."entries WHERE dAdded<'".$datetime."' ORDER BY dAdded DESC LIMIT 1"; 604 $result = mysql_query($sql,$con); 605 if ($result!=false){ 606 $row = mysql_fetch_array($result); 607 $entryid = $row["nEntryId"]; 608 } 609 610 $html_previouslink = "<a href='index.php?entryid=".$entryid."'>".stripslashes($row["cTitle"])."</a>"; 611 612 //db_disconnect($con); 613 614 return $html_previouslink; 615 616 } 617 618 619 function build_nextlink($datetime){ 620 621 global $db_prefix; 622 623 $con = db_connect(); 624 625 $sql = "SELECT nEntryId,cTitle FROM ".$db_prefix."entries WHERE dAdded>'".$datetime."' ORDER BY dAdded LIMIT 1"; 626 $result = mysql_query($sql,$con); 627 if ($result!=false){ 628 $row = mysql_fetch_array($result); 629 $entryid = $row["nEntryId"]; 630 } 631 632 $html_nextlink = "<a href='index.php?entryid=".$entryid."'>".stripslashes($row["cTitle"])."</a>"; 633 634 //db_disconnect($con); 635 636 return $html_nextlink; 637 } 638 639 640 // Description : Retrieves data from the database determined by the SQL passed to it 641 // and then calls the functions (above) to generate HTML which is then 642 // substituted into the page template. 643 // Arguments : sql_list - the SQL required to provide records for the entry list 644 // sql_view - the SQL required to provide records for the entry views 645 // sql_categories - the SQL required to provide records for the category list 646 // sql_comments - the SQL required to provide records for the comments on an entry 647 // Returns : HTML 648 // Last Change : 2005-04-02 649 // Author : Jonathan Beckett (jonbeckett@pluggedout.com) 650 function build_page($sql_list,$sql_view,$sql_categories="",$sql_comments=""){ 651 652 global $theme; 653 654 // work out the current theme (allow for an override though) 655 if (isset($_REQUEST["theme"])){ 656 $theme = $_REQUEST["theme"]; 657 } else { 658 $theme = theme_get_name(); 659 } 660 661 // include the theme (in order for following function calls to work) 662 if (file_exists("themes/".$theme."/theme.php")){ 663 require "themes/".$theme."/theme.php"; 664 } else { 665 header("Location: problem.php?f=build_page&p=theme_not_found"); 666 } 667 668 // look in the includes directory for any files and include them 669 if ($handle = opendir('./includes')) { 670 while (false !== ($file = readdir($handle))) { 671 if ($file!="." && $file!=".."){ 672 include "includes/".$file; 673 } 674 } 675 } 676 677 // Call functions to build the relavant sections of the theme 678 679 // Calendar 680 $html_calendar_section = build_calendar($_REQUEST["year"],$_REQUEST["month"]); 681 682 // Entry List 683 $html_entrylist_section = build_entrylist($sql_list); 684 685 // Entry View 686 $html_entryview_section = build_entryview($sql_view); 687 688 // Category List 689 $html_categorylist_section = build_categorylist($sql_categories); 690 691 // Comments 692 if (isset($_REQUEST["entryid"])){ 693 $html_comment_section = build_comments($sql_comments); 694 } 695 696 // Replace the sections into the page template 697 $html_page = theme_page(); 698 $html_page = str_replace("<!--calendar-->",$html_calendar_section,$html_page); 699 $html_page = str_replace("<!--entry_list-->",$html_entrylist_section,$html_page); 700 $html_page = str_replace("<!--entry_view-->",$html_entryview_section,$html_page); 701 $html_page = str_replace("<!--category_list-->",$html_categorylist_section,$html_page); 702 $html_page = str_replace("<!--comment_list-->",$html_comment_section,$html_page); 703 704 // process the includes 705 $html_page = process_includes($html_page); 706 707 // insert a copyright notice 708 $html_page = str_replace("<head>","<head>\n<meta name='generator' content='PluggedOut Blog (http://www.pluggedout.com/index.php?pk=dev_blog)'/>\n<!-- This blog is based upon the PluggedOut Blog script by Jonathan Beckett -->\n",$html_page); 709 710 return $html_page; 711 } 712 713 714 // Description : accepts text and replaces tags with smilies where appropriate 715 // Arguments : html - the data you want to be parsed for smilies 716 // Returns : HTML 717 // Last Change : 2005-04-02 718 // Author : Jonathan Beckett (jonbeckett@pluggedout.com) 719 function parse_smilies($html){ 720 721 $html = str_replace(":D","<img src='images/smilies/icon_biggrin.gif' width='15' height='15' title='Big Grin'>",$html); 722 $html = str_replace(":)","<img src='images/smilies/icon_smile.gif' width='15' height='15' title='Big Grin'>",$html); 723 $html = str_replace(":(","<img src='images/smilies/icon_sad.gif' width='15' height='15' title='Big Grin'>",$html); 724 $html = str_replace(":o","<img src='images/smilies/icon_surprised.gif' width='15' height='15' title='Big Grin'>",$html); 725 $html = str_replace(":shock:","<img src='images/smilies/icon_eek.gif' width='15' height='15' title='Big Grin'>",$html); 726 $html = str_replace(":?","<img src='images/smilies/icon_confused.gif' width='15' height='15' title='Big Grin'>",$html); 727 $html = str_replace("8)","<img src='images/smilies/icon_cool.gif' width='15' height='15' title='Big Grin'>",$html); 728 $html = str_replace(":lol:","<img src='images/smilies/icon_lol.gif' width='15' height='15' title='Big Grin'>",$html); 729 $html = str_replace(":x","<img src='images/smilies/icon_mad.gif' width='15' height='15' title='Big Grin'>",$html); 730 $html = str_replace(":P","<img src='images/smilies/icon_razz.gif' width='15' height='15' title='Big Grin'>",$html); 731 $html = str_replace(":oops:","<img src='images/smilies/icon_redface.gif' width='15' height='15' title='Big Grin'>",$html); 732 $html = str_replace(":cry:","<img src='images/smilies/icon_cry.gif' width='15' height='15' title='Big Grin'>",$html); 733 $html = str_replace(":evil:","<img src='images/smilies/icon_evil.gif' width='15' height='15' title='Big Grin'>",$html); 734 $html = str_replace(":twisted:","<img src='images/smilies/icon_twisted.gif' width='15' height='15' title='Big Grin'>",$html); 735 $html = str_replace(":roll:","<img src='images/smilies/icon_rolleyes.gif' width='15' height='15' title='Big Grin'>",$html); 736 $html = str_replace(":wink:","<img src='images/smilies/icon_wink.gif' width='15' height='15' title='Big Grin'>",$html); 737 $html = str_replace(":!:","<img src='images/smilies/icon_exclaim.gif' width='15' height='15' title='Big Grin'>",$html); 738 $html = str_replace(":?:","<img src='images/smilies/icon_question.gif' width='15' height='15' title='Big Grin'>",$html); 739 $html = str_replace(":idea:","<img src='images/smilies/icon_idea.gif' width='15' height='15' title='Big Grin'>",$html); 740 $html = str_replace(":arrow:","<img src='images/smilies/icon_arrow.gif' width='15' height='15' title='Big Grin'>",$html); 741 742 return $html; 743 } 744 745 746 // ***************************************************************************************** 747 // ** PUBLIC FUNCTIONS ** 748 // ***************************************************************************************** 749 750 751 // Description : Calls functions from the database library to generate appropriate SQL 752 // statements to show the blog interface with one entry 753 // Arguments : entryid - the ID of one entry to show 754 // Returns : HTML 755 // Last Change : 2005-04-02 756 // Author : Jonathan Beckett (jonbeckett@pluggedout.com) 757 function html_view_entry($entryid){ 758 759 // Prepare SQL 760 $sql_list = db_sql_entries_entry($entryid); 761 $sql_view = db_sql_entries_entry($entryid); 762 $sql_categories = db_sql_categorylist(); 763 $sql_comments = db_sql_comments($entryid); 764 765 // Build the page 766 $html = build_page($sql_list,$sql_view,$sql_categories,$sql_comments); 767 768 return $html; 769 } 770 771 772 // Description : Calls functions from the database library to generate appropriate SQL 773 // statements to show the blog interface with all the entries matching 774 // the category passed in, then calls build_page in order to construct 775 // HTML for the page 776 // Arguments : categoryid - the id of the one category to show entries for 777 // Returns : HTML 778 // Last Change : 2005-04-02 779 // Author : Jonathan Beckett (jonbeckett@pluggedout.com) 780 function html_view_category($categoryid){ 781 782 // Prepare SQL 783 $sql_list = db_sql_entries_category($categoryid); 784 $sql_view = db_sql_entries_category($categoryid); 785 $sql_categories = db_sql_categorylist(); 786 787 // Build the page 788 $html = build_page($sql_list,$sql_view,$sql_categories,$sql_comments); 789 790 return $html; 791 } 792 793 794 // Description : Calls functions from the database library to generate appropriate SQL 795 // statements to show the blog interface with all the entries matching 796 // the search keywords passed in, then calls build_page in order to 797 // construct HTML for the page 798 // Arguments : keywords - the keywords to filter entries by 799 // Returns : HTML 800 // Last Change : 2005-04-02 801 // Author : Jonathan Beckett (jonbeckett@pluggedout.com) 802 function html_view_search($keywords){ 803 804 // Prepare SQL 805 $sql_list = db_sql_entries_search($keywords); 806 $sql_view = db_sql_entries_search($keywords); 807 $sql_categories = db_sql_categorylist(); 808 809 // Build the page 810 $html = build_page($sql_list,$sql_view,$sql_categories,$sql_comments); 811 812 return $html; 813 } 814 815 816 // Description : Calls functions from the database library to generate appropriate SQL 817 // statements to show the blog interface with all the entries posted on 818 // the year and month passed in, then calls build_page in order to 819 // construct HTML for the page 820 // Arguments : year - the year to show entries for 821 // month - the month to show entries for 822 // Returns : HTML 823 // Last Change : 2005-04-02 824 // Author : Jonathan Beckett (jonbeckett@pluggedout.com) 825 function html_view_month($year,$month){ 826 827 // Prepare SQL 828 $sql_list = db_sql_entries_month($year,$month); 829 $sql_view = db_sql_entries_month($year,$month); 830 $sql_categories = db_sql_categorylist(); 831 832 // Build the page 833 $html = build_page($sql_list,$sql_view,$sql_categories,$sql_comments); 834 835 return $html; 836 } 837 838 839 // Description : Calls functions from the database library to generate appropriate SQL 840 // statements to show the blog interface with all the entries posted on 841 // the year, month and day passed in, then calls build_page in order to 842 // construct HTML for the page 843 // Arguments : year - the year to show entries for 844 // month - the month to show entries for 845 // day - the day to show entries for 846 // Returns : HTML 847 // Last Change : 2005-04-02 848 // Author : Jonathan Beckett (jonbeckett@pluggedout.com) 849 function html_view_day($year,$month,$day){ 850 851 // Prepare SQL 852 $sql_list = db_sql_entries_day($year,$month,$day); 853 $sql_view = db_sql_entries_day($year,$month,$day); 854 $sql_categories = db_sql_categorylist(); 855 856 // Build the page 857 $html = build_page($sql_list,$sql_view,$sql_categories,$sql_comments); 858 859 return $html; 860 861 } 862 863 // Description : Calls functions from the database library to generate appropriate SQL 864 // statements to show the blog interface with the last N entries (global 865 // variable set in the Config file), then calls build_page in order to 866 // construct HTML for the page 867 // Arguments : None (it uses the settings table to default itself) 868 // Returns : HTML 869 // Last Change : 2005-04-02 870 // Author : Jonathan Beckett (jonbeckett@pluggedout.com) 871 function html_view_default(){ 872 873 // get the number of entries to show from the settings table 874 $limit = get_setting("default_entry_list_limit"); 875 876 // prepare SQL 877 $sql_list = db_sql_entries_default($limit); 878 $sql_view = db_sql_entries_default($limit); 879 $sql_categories = db_sql_categorylist(); 880 881 // Build the page 882 $html = build_page($sql_list,$sql_view,$sql_categories,$sql_comments); 883 884 return $html; 885 886 } 887 888 889 890 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| [ Powered by PHPXref - Served by Debian GNU/Linux ] |