phpslash-commit Mailing List for phpSlash (Page 50)
Brought to you by:
joestewart,
nhruby
You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(11) |
Nov
(59) |
Dec
(60) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(52) |
Feb
(77) |
Mar
(118) |
Apr
(76) |
May
(106) |
Jun
(145) |
Jul
(9) |
Aug
(15) |
Sep
(78) |
Oct
(83) |
Nov
(105) |
Dec
(51) |
2003 |
Jan
(105) |
Feb
(100) |
Mar
(111) |
Apr
(149) |
May
(95) |
Jun
(56) |
Jul
(8) |
Aug
(2) |
Sep
|
Oct
(22) |
Nov
(117) |
Dec
(6) |
2004 |
Jan
(1) |
Feb
|
Mar
(3) |
Apr
(25) |
May
|
Jun
(11) |
Jul
(26) |
Aug
(85) |
Sep
(119) |
Oct
(312) |
Nov
(271) |
Dec
(5) |
2005 |
Jan
(6) |
Feb
|
Mar
|
Apr
(12) |
May
(7) |
Jun
(8) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2009 |
Jan
(5) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Luis M <le...@us...> - 2003-04-25 15:11:42
|
Update of /cvsroot/phpslash/phpslash-dev/include/modules/mailinglist In directory sc8-pr-cvs1:/tmp/cvs-serv25841 Modified Files: MailingList.class Log Message: put tmpDay check back in newsletterSend() Index: MailingList.class =================================================================== RCS file: /cvsroot/phpslash/phpslash-dev/include/modules/mailinglist/MailingList.class,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** MailingList.class 24 Apr 2003 02:09:25 -0000 1.4 --- MailingList.class 25 Apr 2003 15:11:36 -0000 1.5 *************** *** 355,359 **** $db->query($q); ! $this->templ->set_block("messagebodymail", "row", "rows"); $success = false; --- 355,359 ---- $db->query($q); ! $this->templ->set_block("messagebodymail", "row", "rowS"); $success = false; *************** *** 452,466 **** $this->message .= "To: $email <$name>"; - // TODO BUG?: - // is this buggy? picture this: - // dayback = 7 for e/a user who picked a weekly email - // looping thru all of them will set dayback to 7 - // and after the first iteration tmpDay is also 7 - // thus the rest of the users who get weekly emails - // will not get anything? ... luis ! // TODO put this back!! ! // ($dayback != $tmpDay) && ! if ( ( !($ary['override']) ) ) { $ary['body'] = $this->build_body($ary,$dayback); } --- 452,457 ---- $this->message .= "To: $email <$name>"; ! if (($dayback != $tmpDay) && ( !($ary['override']) ) ) { $ary['body'] = $this->build_body($ary,$dayback); } |
From: Luis M <le...@us...> - 2003-04-24 02:10:21
|
Update of /cvsroot/phpslash/phpslash-dev/include/templates/en/basic In directory sc8-pr-cvs1:/tmp/cvs-serv24328/en/basic Modified Files: mailinglistAdmin.tpl Log Message: added frequency column Index: mailinglistAdmin.tpl =================================================================== RCS file: /cvsroot/phpslash/phpslash-dev/include/templates/en/basic/mailinglistAdmin.tpl,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** mailinglistAdmin.tpl 12 Mar 2003 16:12:52 -0000 1.1.1.1 --- mailinglistAdmin.tpl 24 Apr 2003 02:10:17 -0000 1.2 *************** *** 1,70 **** ! <!-- Start mailinglistAdmin.tpl --> ! {TITLEBAR} ! <div id="mailingListAdmin"> ! <h3><a href="mailinglistAdmin.php?action=newsletter">Send a new newsletter to the list</a></h3> ! <p>Go here to send a personalized message to the list or just send the headlines.</p> ! <hr /> ! ! <p>Individual subscription and unsubscription options</p> ! ! <form action="{ACTION_URL}" method="post"> ! <table border="0"> ! <tr> ! <td class="descr">Subscribe</td> ! <td><input type="text" name="subscribe_address" value="" size="20" /></td> ! <td><input type="submit" name="action" value="subscribe" /></td> ! <td> ! <input type="radio" name="freq" value="daily" checked="checked" /> Daily<br /> ! <input type="radio" name="freq" value="weekly" /> ! Weekly on ! <select name="week_freq"> ! <option value="SUNDAY">Sunday</option> ! <option value="MONDAY">Monday</option> ! <option value="TUESDAY">Tuesday</option> ! <option value="WEDNESDAY">Wednesday</option> ! <option value="THURSDAY">Thursday</option> ! <option value="FRIDAY">Friday</option> ! <option value="SATURDAY">Saturday</option> ! </select><br /> ! <input type="radio" name="freq" value="monthly" /> Monthly ! </td> ! </tr> ! <tr> ! <td class="descr">Unsubscribe</td> ! <td><input type="text" name="unsubscribe_address" value="" size="20" /></td> ! <td><input type="submit" name="action" value="unsubscribe" /></td> ! <td></td> ! </tr> ! </table> ! <hr> ! <p class="massDel">Subscription List and Mass Deletetion Options</p> ! ! <table border="0" cellpadding="3"> ! <tr> ! <th>ID</th> ! <th>Name</th> ! <th>E-mail</th> ! <th>Time / Date subscribed</th> ! </tr> ! <!-- BEGIN row --> ! <tr> ! <td>Delete?<br /><input type="checkbox" name="mass_del[]" value="{EMAIL}">{ID}</td> ! <td>{NAME}</td> ! <td>{EMAIL}</td> ! <td>{TIME}</td> ! </tr> ! <!-- END row --> ! <tr> ! <td colspan="4"> ! <input type="submit" name="action" value="mass_delete" /> ! Click this button to delete the addresses you checked off above. ! </td> ! </tr> ! </table> ! ! </form> ! </div> <!-- id="mailingListAdmin" --> ! <!-- End mailinglistAdmin.tpl --> ! ! ! --- 1,72 ---- ! <!-- Start mailinglistAdmin.tpl --> ! {TITLEBAR} ! <div id="mailingListAdmin"> ! <h3><a href="mailinglistAdmin.php?action=newsletter">Send a new newsletter to the list</a></h3> ! <p>Go here to send a personalized message to the list or just send the headlines.</p> ! <hr /> ! ! <p>Individual subscription and unsubscription options</p> ! ! <form action="{ACTION_URL}" method="post"> ! <table border="0"> ! <tr> ! <td class="descr">Subscribe</td> ! <td><input type="text" name="subscribe_address" value="" size="20" /></td> ! <td><input type="submit" name="action" value="subscribe" /></td> ! <td> ! <input type="radio" name="freq" value="daily" checked="checked" /> Daily<br /> ! <input type="radio" name="freq" value="weekly" /> ! Weekly on ! <select name="week_freq"> ! <option value="SUNDAY">Sunday</option> ! <option value="MONDAY">Monday</option> ! <option value="TUESDAY">Tuesday</option> ! <option value="WEDNESDAY">Wednesday</option> ! <option value="THURSDAY">Thursday</option> ! <option value="FRIDAY">Friday</option> ! <option value="SATURDAY">Saturday</option> ! </select><br /> ! <input type="radio" name="freq" value="monthly" /> Monthly ! </td> ! </tr> ! <tr> ! <td class="descr">Unsubscribe</td> ! <td><input type="text" name="unsubscribe_address" value="" size="20" /></td> ! <td><input type="submit" name="action" value="unsubscribe" /></td> ! <td></td> ! </tr> ! </table> ! <hr> ! <p class="massDel">Subscription List and Mass Deletetion Options</p> ! ! <table border="0" cellpadding="3"> ! <tr> ! <th>ID</th> ! <th>Name</th> ! <th>E-mail</th> ! <th>Frequency</th> ! <th>Time / Date subscribed</th> ! </tr> ! <!-- BEGIN row --> ! <tr> ! <td>Delete?<br /><input type="checkbox" name="mass_del[]" value="{EMAIL}">{ID}</td> ! <td>{NAME}</td> ! <td>{EMAIL}</td> ! <td>{FREQ}</td> ! <td>{TIME}</td> ! </tr> ! <!-- END row --> ! <tr> ! <td colspan="4"> ! <input type="submit" name="action" value="mass_delete" /> ! Click this button to delete the addresses you checked off above. ! </td> ! </tr> ! </table> ! ! </form> ! </div> <!-- id="mailingListAdmin" --> ! <!-- End mailinglistAdmin.tpl --> ! ! ! |
From: Luis M <le...@us...> - 2003-04-24 02:09:30
|
Update of /cvsroot/phpslash/phpslash-dev/include/modules/mailinglist In directory sc8-pr-cvs1:/tmp/cvs-serv24043 Modified Files: MailingList.class Log Message: closer to making newsletters be sent to users who get weekly news. some bugs being investigated. This is unstable right now Index: MailingList.class =================================================================== RCS file: /cvsroot/phpslash/phpslash-dev/include/modules/mailinglist/MailingList.class,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** MailingList.class 23 Apr 2003 15:51:20 -0000 1.3 --- MailingList.class 24 Apr 2003 02:09:25 -0000 1.4 *************** *** 246,255 **** function AdminMenu() { ! ! $q = "SELECT id, ! name, ! email, ! date_created ! FROM psl_mailinglist"; $this->db->query($q); --- 246,256 ---- function AdminMenu() { ! // to avoid ambiguity, since we need all fields, ! // I changed this from plain "id" or "psl_mailinglist.id" ! // to "*". luis ! $q = "SELECT * ! FROM psl_mailinglist, ! psl_mailinglist_frequency ! WHERE psl_mailinglist.id = psl_mailinglist_frequency.id"; $this->db->query($q); *************** *** 264,267 **** --- 265,269 ---- 'ID' => $this->db->f("id"), 'EMAIL' => $this->db->f("email"), + 'FREQ' => $this->db->f("frequency"), 'TIME' => psl_dateTimeShort($this->db->f("date_created")) )); *************** *** 304,329 **** function build_body($ary, $offset) { //BEGIN FUNCTION - - $db = pslNew("slashDB"); - - if ($ary['dateoverride']) { - - $ary['bday'] = date("d"); - $ary['bday'] = $bday - $offset; - - $ary['bmonth'] = date("m"); - $ary['bmonth'] = $ary[bmonth] - 1; ! $ary['byear'] = date("Y"); ! $ary['eday'] = date("d"); ! $ary['emonth'] = date("m"); ! $ary['eyear'] = date("Y"); } ! $begtimestamp = mktime(0,0,0,$ary['bmonth'],$ary['bday'],$ary['byear']); ! $endtimestamp = mktime(0,0,0,$ary['emonth'],$ary['eday'] + 1,$ary['eyear']); $begdate = date("Y-m-d H:i:s", $begtimestamp); $enddate = date("Y-m-d H:i:s", $endtimestamp); $q = "SELECT story.story_id, --- 306,341 ---- function build_body($ary, $offset) { //BEGIN FUNCTION ! $db = pslNew("slashDB"); ! ! if ( $offset > 1 ) { ! $ary["bday"] = $ary["eday"] - $offset; ! $ary["bday"] = ($ary["bday"]>0) ? $ary["bday"] : (30 + $ary["bday"]); } + //$this->message .= " bday: ".$ary["bday"]; ! if ($ary["dateoverride"]) { ! // end-date ! $ary["eday"] = date("d"); ! $ary["emonth"] = date("m"); ! $ary["eyear"] = date("Y"); ! // begin-date ! $ary["byear"] = date("Y"); ! $ary["bday"] = $ary["eday"] - $offset; ! $ary["bmonth"] = $ary["emonth"] - 1; ! } + $begtimestamp = mktime(0,0,0,$ary["bmonth"],$ary["bday"],$ary["byear"]); + // TODO BUG?: + // the +1 to $ary[eday] could make that future stories get emailed + // before being posted to the page, is this really necessary? + // note that the query does a "<=" (less than OR equal) comparison. + // Luis + $endtimestamp = mktime(0,0,0,$ary["emonth"],$ary["eday"] + 1,$ary["eyear"]); + $begdate = date("Y-m-d H:i:s", $begtimestamp); $enddate = date("Y-m-d H:i:s", $endtimestamp); + + $this->message .= " bday ".$ary["bday"]." begin-time: $begtimestamp\t end-time: $endtimestamp "; $q = "SELECT story.story_id, *************** *** 346,349 **** --- 358,371 ---- $success = false; + + // TODO + // is this loop right? + // this is looping and setting the variables every time + // so, if there is more than one story pulled from the database + // only the last story pulled will be emailed... + // shouldn't it be creating a list of all stories? + // Unless of course that's what parse("rows","row",true) is doing + // Luis + while($db->next_record()) { *************** *** 358,364 **** )); $this->templ->parse("rows","row",true); ! $success = true; ! } //End While next_record if ($success == true) { return $this->templ->parse('OUT',array("messagebodymail")); --- 380,387 ---- )); $this->templ->parse("rows","row",true); ! $success = true; ! } //End While next_record ! if ($success == true) { return $this->templ->parse('OUT',array("messagebodymail")); *************** *** 429,434 **** $this->message .= "To: $email <$name>"; ! if ( ($dayback != $tmpDay) && ( !($ary['override']) ) ) { $ary['body'] = $this->build_body($ary,$dayback); } --- 452,466 ---- $this->message .= "To: $email <$name>"; + // TODO BUG?: + // is this buggy? picture this: + // dayback = 7 for e/a user who picked a weekly email + // looping thru all of them will set dayback to 7 + // and after the first iteration tmpDay is also 7 + // thus the rest of the users who get weekly emails + // will not get anything? ... luis ! // TODO put this back!! ! // ($dayback != $tmpDay) && ! if ( ( !($ary['override']) ) ) { $ary['body'] = $this->build_body($ary,$dayback); } *************** *** 436,441 **** $today = date("m/d/Y"); ! $this->message .= " Frequency: $frequency"; ! switch ($frequency) { case "DAY": --- 468,474 ---- $today = date("m/d/Y"); ! //$this->message .= " Frequency: $frequency"; ! ! // TODO use this switch/case to set the bday var in $ary switch ($frequency) { case "DAY": *************** *** 448,451 **** --- 481,494 ---- $mail_subject = $ary['subject']." for the past month ($today)"; break; + case "SUNDAY": + case "MONDAY": + case "TUESDAY": + case "WEDNESDAY": + case "THURSDAY": + case "FRIDAY": + case "SATURDAY": + + $mail_subject = $ary['subject']." since last ".$frequency; + break; default: $mail_subject = $ary['subject']; *************** *** 461,465 **** if(empty($ary['body']) && empty($extra_message)){ ! $this->message .= pslgetText("Nothing to send"); } elseif ( mail($email, $mail_subject, $final_body, "From: ".$ary['sender']) ) { $this->message .= pslgetText("Mail Sent Successfully!")."<br>\n"; --- 504,508 ---- if(empty($ary['body']) && empty($extra_message)){ ! $this->message .= pslgetText("Nothing to send")."<br />\n"; } elseif ( mail($email, $mail_subject, $final_body, "From: ".$ary['sender']) ) { $this->message .= pslgetText("Mail Sent Successfully!")."<br>\n"; |
From: Luis M <le...@us...> - 2003-04-23 15:51:24
|
Update of /cvsroot/phpslash/phpslash-dev/include/modules/mailinglist In directory sc8-pr-cvs1:/tmp/cvs-serv15289 Modified Files: MailingList.class Log Message: needed updates to solve db array problem Index: MailingList.class =================================================================== RCS file: /cvsroot/phpslash/phpslash-dev/include/modules/mailinglist/MailingList.class,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MailingList.class 21 Apr 2003 15:24:05 -0000 1.2 --- MailingList.class 23 Apr 2003 15:51:20 -0000 1.3 *************** *** 304,309 **** function build_body($ary, $offset) { //BEGIN FUNCTION ! if ($ary['dateoverride']) { $ary['bday'] = date("d"); $ary['bday'] = $bday - $offset; --- 304,312 ---- function build_body($ary, $offset) { //BEGIN FUNCTION ! ! $db = pslNew("slashDB"); ! if ($ary['dateoverride']) { + $ary['bday'] = date("d"); $ary['bday'] = $bday - $offset; *************** *** 338,358 **** ORDER BY date_available"; ! $this->db->query($q); $this->templ->set_block("messagebodymail", "row", "rows"); $success = false; ! while($this->db->next_record()) { ! $url = $this->psl['rooturl'] . "/article.php?story_id=" . $this->db->Record["story_id"]; $this->templ->set_var(array( ! 'AUTHOR_NAME' => $this->db->Record["name"], ! 'TITLE' => $this->db->Record["title"], ! 'DEPT' => $this->db->Record["dept"], ! 'DATE' => psl_DateTimeLong($this->db->Record["date_available"]), ! 'STORY' => format_mail($this->db->Record["intro_text"],76,true), 'URL' => $url )); $this->templ->parse("rows","row",true); $success = true; } //End While next_record --- 341,362 ---- ORDER BY date_available"; ! $db->query($q); $this->templ->set_block("messagebodymail", "row", "rows"); $success = false; ! while($db->next_record()) { ! $url = $this->psl['rooturl'] . "/article.php?story_id=" . $db->Record["story_id"]; $this->templ->set_var(array( ! 'AUTHOR_NAME' => $db->Record["name"], ! 'TITLE' => $db->Record["title"], ! 'DEPT' => $db->Record["dept"], ! 'DATE' => psl_DateTimeLong($db->Record["date_available"]), ! 'STORY' => format_mail($db->Record["intro_text"],76,true), 'URL' => $url )); $this->templ->parse("rows","row",true); + $success = true; } //End While next_record *************** *** 431,434 **** --- 435,441 ---- $today = date("m/d/Y"); + + $this->message .= " Frequency: $frequency"; + switch ($frequency) { case "DAY": *************** *** 444,448 **** $mail_subject = $ary['subject']; } ! $this->message .= " Subject: $mail_subject ->"; $this->templ->set_var(array( --- 451,455 ---- $mail_subject = $ary['subject']; } ! $this->message .= " Subject: $mail_subject -> "; $this->templ->set_var(array( |
From: Luis M <le...@us...> - 2003-04-23 15:42:08
|
Update of /cvsroot/phpslash/phpslash-dev/contrib In directory sc8-pr-cvs1:/tmp/cvs-serv10304 Modified Files: cronmail.php Log Message: new version. works for phpslash-dev using the mailinglist module and the mailinglist class Index: cronmail.php =================================================================== RCS file: /cvsroot/phpslash/phpslash-dev/contrib/cronmail.php,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** cronmail.php 12 Mar 2003 16:12:47 -0000 1.1.1.1 --- cronmail.php 23 Apr 2003 15:42:04 -0000 1.2 *************** *** 2,56 **** // #!/usr/bin/php // $Id$ ! // Written by 'Blake' ! // Modified for phpSlash (v0.65) by: // Luis Mondesi <le...@ho...> ! // Last modified: 2002-Jul-28 // ! // USAGE: create a cron job that calls this file every 15 minutes ! // starting at 1:00 am up to 6:30 am // example: ! // 00,15,30,45 1-6 * * * /usr/bin/php /path/to/cronmail.php 2>&1> /dev/null ! // ! // of course, do not put the 2>&... redirection to /dev/null if you want to ! // get a report on what was done :-) ! // ! // ! // NOTES: ! // The following is an example of how the tables should ! // look like. Check the alter_table...sql script ! // for altering the .65f tables for this script ! // to work... ! // ! // Table structure for table 'psl_mailinglist' ! // ! //CREATE TABLE psl_mailinglist ( ! // id int(30) DEFAULT '0' NOT NULL auto_increment, ! // email varchar(100) DEFAULT '' NOT NULL, ! // name varchar(100), ! // timestamp timestamp(14), ! // html tinyint(2) DEFAULT '0' NOT NULL, ! // PRIMARY KEY (id), ! // UNIQUE email (email) ! //); ! ! // ! // Table structure for table 'mailing_frequency' ! // ! //CREATE TABLE psl_mailinglist_frequency ( ! // id int(30) DEFAULT '0' NOT NULL, ! // frequency char(30) DEFAULT '' NOT NULL, ! // dayback int(11) DEFAULT '0' NOT NULL ! //); ! // ! // Table modifications for existing installations ! // ! // ALTER TABLE psl_mailinglist MODIFY id int(30) DEFAULT '0' NOT NULL auto_increment, MODIFY email varchar(100) DEFAULT '' NOT NULL, MODIFY name varchar(100), MODIFY timestamp timestamp(14), ADD html tinyint(2) DEFAULT '0' NOT NULL; ! // ! // ALTER TABLE psl_mailinglist_frequency MODIFY id int(30) DEFAULT '0' NOT NULL, MODIFY frequency char(30) DEFAULT '' NOT NULL, MODIFY dayback int(11) DEFAULT '0' NOT NULL; ! // ! // ! // Sample header.txt contents: // ! // phpSlash Daily Headline Mailer // // MORE NOTES: --- 2,18 ---- // #!/usr/bin/php // $Id$ ! // Written for phpSlash (v0.7) by: // Luis Mondesi <le...@ho...> ! // Last modified: 2003-Apr-20 // ! // USAGE: create a cron job that calls this file at whichever time ! // is more convenient for you (usually at the end of the day, ! // say starting at 22:00 // example: ! // 00 23 * * * /usr/bin/php4 /path/to/cronmail.php // ! // if you don't care about the report being emailed to you, put ! // the appropriate redirection to /dev/null at the end: ! // ... 2>&1 > /dev/null // // MORE NOTES: *************** *** 58,71 **** // package (from the 'woody' distro: apt-get install php4-cgi) // and then edit their /etc/php/cgi/php.ini ! // to include the extensions for mysql (mysql.so) ! // ! // TODO: ! // 1) Major cleanup necessary... ! // 2) test in a different system ! // 3) use the functions from the classes only ! // (clean up the mysql_pconnect() block and all ! // that mess...) // // CHANGELOG: // 2002-06-27 -took off HTML stuff for some of the code // -fixed formatting for some of the strings --- 20,31 ---- // package (from the 'woody' distro: apt-get install php4-cgi) // and then edit their /etc/php/cgi/php.ini ! // to include the extensions for mysql (mysql.so). If not this script ! // might complaint about missing pmysql_connect() calls... you have ! // been warned! // // CHANGELOG: + // 2003-03-05 - cleanup beautifully. now using only mailinglist + // class + // // 2002-06-27 -took off HTML stuff for some of the code // -fixed formatting for some of the strings *************** *** 75,552 **** // -fixed build_body() to return NULL if there // is no messages pulled from the database - // - // And now the code..... - //.......................... - - //require("/path/to/prepend.php"); - require("/path/to/config.php"); ! $rightnow = date("Hi"); //figures out what time it is ! // Busy server? set this baby to sleep. 0 means it mails as fast as it can ! // it's in seconds ! $sleep = 5; ! //these 2 are used to format the mail to make it shorter and so it wraps at a certain length ! $wraplength = 800; ! $choplength = 600; ! //since you want to include a message daily, it's a separate file ! //remember to make it HTML if you are using the HTML option. ! //tags are stripped for plain text ! $filename = "./header.txt"; ! $fd = fopen ($filename, "r"); ! $header = fread ($fd, filesize ($filename)); ! fclose ($fd); ! // comment this out if you don't care about it ! //$header .= "\n"; ! //$header .= `/usr/games/fortune -s` ; // a little bit of fun! ! //$header .= "\n"; ! $sitename = $_PSL['site_name']; // used in the title, and subject, and body of mail ! $siteurl = $_PSL['rooturl']; ! if ($html==1){ ! $yourtitle = "<h1>$sitename</h1>"; // used in HTML title of email ! $mailsubj = $_PSL['mailinglist_subject']; //change this too, used for HTML Subject of HTML mail ! } else { ! $yourtitle = $site_name; //uh, used not really ! $mailsubj = $_PSL['mailinglist_subject']; // Subject of plain text email ! } ! $sender = preg_replace("/(.*)\@.*/i","noreply",$_PSL['site_owner']); ! // The footer ends up as the last thing in the mail. ! // Tags are stripped for plain text ! // you may want to move this out to a file like ! // the header if you feel the need - // I've split these two - you can't strip the text for international versions as this will do fun things - // with the special characters not compatible with pure text mails. - $footer_text = "\n\t " . pslgetText("To add or remove yourself go to") . ": ".$siteurl."/mailinglist.php"; - $footer_html = "<P><B>\n\t " . $footer_text ."</B><P></BODY></HTML>"; ! /********************************************************* ! **** NO NEED TO CHANGE ANYTHING BELOW THIS LINE ********** ! *********************************************************/ ! if ($rightnow == "0100"){ ! $limit = "0,100"; ! $today = date("w"); ! if($today=="1") { ! $offset = "3"; ! } else { ! $offset = "1"; ! } ! $frequency = "DAY"; ! $html =0; ! } elseif ($rightnow == "0115") { ! $limit = "99,101"; ! $today = date("w"); ! if($today=="1") { ! $offset = "3"; ! } else { ! $offset = "1"; ! } ! $frequency = "DAY"; ! $html =0; ! } elseif ($rightnow == "0130") { ! $limit = "200,100"; ! $today = date("w"); ! if($today=="1") { ! $offset = "3"; ! } else { ! $offset = "1"; ! } ! $frequency = "DAY"; ! $html =0; ! } elseif ($rightnow == "0145") { ! $limit = "300,100"; ! $today = date("w"); ! if($today=="1") { ! $offset = "3"; ! } else { ! $offset = "1"; ! } ! $frequency = "DAY"; ! $html =0; ! } elseif ($rightnow == "0200") { ! $limit = "400,100"; ! $today = date("w"); ! if($today=="1") { ! $offset = "3"; ! } else { ! $offset = "1"; ! } ! $frequency = "DAY"; ! $html =0; ! } elseif ($rightnow == "0215") { ! $limit = "500,100"; ! $today = date("w"); ! if($today=="1") { ! $offset = "3"; ! } else { ! $offset = "1"; ! } ! $frequency = "DAY"; ! $html =0; ! } elseif ($rightnow == "0230") { ! $limit = "600,100"; ! $today = date("w"); ! if($today=="1") { ! $offset = "3"; ! } else { ! $offset = "1"; ! } ! $frequency = "DAY"; ! $html =0; ! } elseif ($rightnow == "0245") { ! $limit = "700,100"; ! $today = date("w"); ! if($today=="1") { ! $offset = "3"; ! } else { ! $offset = "1"; ! } ! $frequency = "DAY"; ! $html =0; ! } elseif ($rightnow == "0300") { ! $limit = "800,100"; ! $today = date("w"); ! if($today=="1") { ! $offset = "3"; ! } else { ! $offset = "1"; ! } ! $frequency = "DAY"; ! $html =0; ! } elseif ($rightnow == "0315") { ! $limit = "900,100"; ! $today = date("w"); ! if($today=="1") { ! $offset = "3"; ! } else { ! $offset = "1"; ! } ! $frequency = "DAY"; ! $html =0; ! } elseif ($rightnow == "0330") { ! $limit = "1000,100"; ! $today = date("w"); ! if($today=="1") { ! $offset = "3"; ! } else { ! $offset = "1"; ! } ! $frequency = "DAY"; ! $html =0; ! } elseif ($rightnow == "0345") { ! $limit = "1100,100"; ! $today = date("w"); ! if($today=="1") { ! $offset = "3"; ! } else { ! $offset = "1"; ! } ! $frequency = "DAY"; ! $html =0; ! } elseif ($rightnow == "0400") { ! $limit = "1200,100"; ! $today = date("w"); ! if($today=="1") { ! $offset = "3"; ! } else { ! $offset = "1"; ! } ! $frequency = "DAY"; ! $html =0; ! } elseif ($rightnow == "0415") { ! $limit = "1300,100"; ! $today = date("w"); ! if($today=="1") { ! $offset = "3"; ! } else { ! $offset = "1"; ! } ! $frequency = "DAY"; ! $html =0; ! } ! //that was the last of the normal daily emails ! elseif ($rightnow == "0430") { ! $limit = "0,200"; ! $today = date("w"); ! $html =0; ! if($today=="1") { ! $offset = "7"; ! $frequency = "MONDAY"; ! } else { ! die; ! } ! } elseif ($rightnow == "0445") { ! $limit = "0,200"; ! $today = date("w"); ! $html =0; ! if($today=="2") { ! $offset = "7"; ! $frequency = "TUESDAY"; ! } else { ! die; ! } ! } elseif ($rightnow == "0500") { ! $limit = "0,200"; ! $today = date("w"); ! $html =0; ! if($today=="3") { ! $offset = "7"; ! $frequency = "WEDNESDAY"; ! } else { ! die; ! } ! } elseif ($rightnow == "0515") { ! $limit = "0,200"; ! $today = date("w"); ! $html =0; ! if($today=="4") { ! $offset = "7"; ! $frequency = "THURSDAY"; ! } else { ! die; ! } ! } elseif ($rightnow == "0530") { ! $limit = "0,200"; ! $today = date("w"); ! $html =0; ! if($today=="5") { ! $offset = "7"; ! $frequency = "FRIDAY"; ! } else { ! die; ! } ! } elseif ($rightnow == "0545") { ! $limit = "0,200"; ! $today = date("w"); ! $html =0; ! if($today=="6") { ! $offset = "7"; ! $frequency = "SATURDAY"; ! } else { ! die; ! } ! } elseif ($rightnow == "0600") { ! $limit = "0,200"; ! $today = date("w"); ! $html =0; ! if($today=="0") { ! $offset = "7"; ! $frequency = "SUNDAY"; ! } else { ! die; ! } ! } ! ///here is the experimental HTML one ! /*elseif ($rightnow == "0615") { ! $limit = "0,100"; ! $today = date("w"); ! if($today=="1") { ! $offset = "3"; ! } else { ! $offset = "2"; ! } ! $frequency = "DAY"; ! $html = 1; ! }*/ ! /* use functions.inc format_mail() so that you can scrub things ;-) ! function format_mail($str, $char_len) ! { ! GLOBAL $wraplength; ! $str = stripslashes($str); ! $str = strip_tags($str); ! $str = eregi_replace("\n"," ",$str); ! $str = eregi_replace("\t"," ",$str); ! $str = ereg_replace("\r\n"," ",$str); ! $str = eregi_replace("[[:space:]]+", " ", $str); ! $str_out .= substr($str, 0, $wraplength); ! $str = substr($str, 0, $wraplength); ! return $str_out; ! } ! */ ! function format_html_mail($str, $char_len) ! { ! GLOBAL $wraplength; ! $str = stripslashes($str); ! $str = eregi_replace("\n"," ",$str); ! $str = eregi_replace("\t"," ",$str); ! $str = ereg_replace("\r\n"," ",$str); ! $str = eregi_replace("[[:space:]]+", " ", $str); ! $str_out .= substr($str, 0, $wraplength); ! $str = substr($str, 0, $wraplength); ! return $str_out; ! } ! function chopit ($str){ ! GLOBAL $choplength; ! $string = substr($str, 0, $choplength); ! $pos = strrpos ($string, "."); ! $finalstring = substr($string, 0, $pos); ! return $finalstring; } ! function build_body($offset) { ! GLOBAL $offset; ! $slash_q = new slashDB; ! $bmonth = date("m"); ! $bday = date("d") - $offset; // pull stories since yesterday or since Friday if today is Monday ! $byear = date("Y"); ! $emonth = date("m"); ! $eday = date("d"); ! $eyear = date("Y"); ! $begdate = date("Y-m-d H:i:s", mktime(0,0,0,$bmonth,$bday,$byear)); ! $enddate = date("Y-m-d H:i:s", mktime(0,0,0,$emonth,$eday,$eyear)); ! // this should get the stories using the class ! // but, for the moment 2002-06-12 luis mondesi: ! $sql="SELECT story_id, title, dept, ". ! " UNIX_TIMESTAMP(time) as pretty_time, ". ! " intro_text FROM psl_story ". ! " WHERE time >= '$begdate' AND time <= '$enddate' ORDER BY time DESC"; ! ! $slash_q->query($sql); ! ! // 2002-06-27 luis: it makes no sense to continue if there ! // is nothing! ! if ( $slash_q->num_rows() > 0 ) { ! while($slash_q->next_record()){ ! GLOBAL $siteurl; ! $headline = "\n" . pslgetText("Story") . ": ".format_mail($slash_q->Record["title"],500,true) . "\n"; ! $headline .= " " . pslgetText("Written") . ": " . psl_dateTimeLong($slash_q->Record["pretty_time"]) . "\n"; ! $headline .= " " . pslgetText("Intro") . ": " . format_mail($slash_q->Record["intro_text"],500,true) . ".\n"; ! $headline .= " ".$siteurl."/article.php?story_id=" . $slash_q->Record["story_id"]."\n"; ! $headline .= "---------------------------------------------------------------------------------------------\n\n"; ! $headline = stripslashes($headline); ! $thisHead .= $headline; ! } // end while() next_record ! return $thisHead; ! } // end if $slash_q is empty ! ! return ""; // return empty string if no records selected ! ! }// end build_body() ! ! function build_html_body($offset) { ! GLOBAL $offset; ! $slash_q = new slashDB; ! $bmonth = date("m"); ! $bday = date("d") - $offset; ! $byear = date("Y"); ! $emonth = date("m"); ! $eday = date("d"); ! $eyear = date("Y"); ! $begdate = date("Y-m-d H:i:s", mktime(0,0,0,$bmonth,$bday,$byear)); ! $enddate = date("Y-m-d H:i:s", mktime(0,0,0,$emonth,$eday + 1,$eyear)); ! $sql=" SELECT story_id, title, dept, ". ! " date_format(time, \"%W %M %d %h %i %p\") as pretty_time, ". ! " intro_text FROM psl_story ". ! " WHERE time >= '$begdate' AND time <= '$enddate' ORDER BY time DESC"; ! ! $slash_q->query($sql); ! ! while($slash_q->next_record()) { ! GLOBAL $siteurl; ! $headline = "<B>".format_mail($slash_q->Record["title"],500,true) . "</B><BR>\n"; ! $headline .= " From the: \"" . $slash_q->Record["dept"] . "\" dept.<BR>\n"; ! $headline .= " Posted on: \"" . $slash_q->Record["pretty_time"] . "<BR>\n"; ! $headline .= " Story: " . format_mail(chopit($slash_q->Record["intro_text"]),500,true) . ".</I><BR>\n"; ! $headline .= "<A HREF=\"".$siteurl."/article.php?story_id=" . $slash_q->Record["story_id"] . "\">Full Story</A>\n"; ! $headline .= "<BR>---------------------------------------------------------------------------------------------<BR>\n\n"; ! $headline = stripslashes($headline); ! $thisHead .= $headline; ! } ! return $thisHead; ! }// end build_html_body() ! ! // mail goes out below here now ! ! // use slashDB class later ... ! // $db = new slashDB; ! $link = mysql_pconnect($_PSL['DB_Host'],$_PSL['DB_User'],$_PSL['DB_Password']); ! ! // limit is blank for some reason... ! $limit = ($limit == '') ? "0,100":$limit; ! // if HTML is null ... then select text ! $html = ($html == '') ? "0":$html; ! // if frequency is null, then select DAY ! $frequency = ($frequency == '') ? "DAY":$frequency; ! ! $sql_query="SELECT email, dayback, frequency" ! ." FROM psl_mailinglist, psl_mailinglist_frequency" ! ." WHERE psl_mailinglist.id = psl_mailinglist_frequency.id" ! ." AND psl_mailinglist_frequency.frequency = '$frequency'" ! ." AND psl_mailinglist.html = '$html'" ! ." ORDER BY psl_mailinglist_frequency.dayback, psl_mailinglist_frequency.frequency" ! ." LIMIT $limit"; ! $db_results = mysql($_PSL['DB_Database'],$sql_query,$link) ! or die("ERROR: $sql_query connecting to ".$_PSL['DB_Database']." with link $link \n "); ! ! ignore_user_abort(); ! flush(); ! ! $tmpDay = ''; ! ! while($row = mysql_fetch_row($db_results)) { ! //while ($db->next_record()) { ! //$row = $db->f(""); ! GLOBAL $sender; ! GLOBAL $html; ! //first part is the plain text email ! // 2002-06-27 luis: no HTML messages. will ! // put it back later ! //if($html==0) { ! //if ( $row[2] > '' ) { ! ! // 2002-06-27 luis: to avoid empty emails ! // we will check to see if build_body() returns ! // something, else we will just die/leave ! ! $my_message = build_body($row[2]); ! ! if ( $my_message > "" ) { ! set_time_limit(0); ! $header= strip_tags($header); ! $body = $header; ! $body .= $my_message; // takes the body from my_message ! $body .= $footer_text; // No need to strip ! $subject = $mailsubj; ! $headers = "Reply-To:$sender\r\n"; ! $headers .= "From:$sender\r\n"; ! if (mail($row[0], $subject, $body, $headers)) ! echo "\n" . $row[0]." ". $row[2] . "\n... sent\n"; ! else ! $errors[] = $row[0]; ! $tmpDay = $row[2]; ! sleep($sleep); ! } // end if $my_message > null ! //} //closes if html=0 so that means the HTML goes out from below here ! /* html disable until further notice ! else { ! set_time_limit(0); ! $body = "<html><head><title>" . $yourtitle."</title><BASE HREF=\"".$siteurl."\"></head><body>\r\n\n\n"; ! $body .= $header; ! $body .= build_html_body($row[2]); ! $body .= $footer; ! $subject = $mailsubj; ! $headers = "Reply-To:$sender\r\n"; ! $headers .= "From:$sender\r\n"; ! $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; ! if (mail($row[0], $subject, $body, $headers)) ! echo "\n" . $row[0]. $row[2] . "\n... sent\n"; ! else ! $errors[] = $row[0]; ! $tmpDay = $row[2]; ! sleep($sleep); ! }//closes else for html = 0 ! */ ! }//closes the mail function ?> --- 35,95 ---- // -fixed build_body() to return NULL if there // is no messages pulled from the database ! // don't cache this page ! $cachetimeout=-1; ! // prepending might not be needed now... just the config.php: ! require("/home/luigi/cvs/phpslash-dev/public_html/config.php"); ! AddClassRequirement("mailinglist",$_PSL['moduledir'] . "/mailinglist/MailingList.class"); ! /* DEBUG */ ! error_reporting(E_ALL,~E_WARN); ! /* END DEBUG */ ! $USE_NO_REPLY_ADDRESS = "true"; // when true, a fake address ! // will be used for the FROM ! // field -- to avoid users ! // being able to reply to it ! $NO_REPLY_STRING = "noreply"; // string which is used for the ! // fake reply address when the ! // variable above is set to "true" ! /********************************************* ! * Nothing to change below this line * ! *********************************************/ ! // when this script runs successfully, something should be reported ! // thus this variable's content will change ! $report = "nothing to report"; ! $list = pslNew("MailingList"); ! // this script is run daily, thus: ! $ary["bmonth"] = date("m"); // beginning today ! $ary["bday"] = date("d"); // today's day ! $ary["byear"] = date("y"); // today's year ! $ary["emonth"] = date("m"); // also ending today ! $ary["eday"] = date("d"); // yaddah today ! $ary["eyear"] = date("y"); // yaddah today ! $ary["sender"] = ($USE_NO_REPLY_ADDRESS == "true") ? preg_replace("/(.*)\@(.*)/i","$NO_REPLY_STRING@$2",$list->psl['site_owner']) : $list->psl['site_owner']; ! //echo $list->psl['site_owner']; ! //echo "\n"; ! $ary["subject"] = $list->psl['mailinglist_subject']; ! //echo "\n"; ! //uncomment this to force emails to be sent ! //$ary["freqoverride"]="true"; ! if($list->newsletterSend($ary)) { ! $report = getMessage($list->getMessage()); } ! // report what was done ! echo $report; ?> |
From: Joe S. <joe...@us...> - 2003-04-23 15:40:21
|
Update of /cvsroot/phpslash/phpslash-dev/include/class In directory sc8-pr-cvs1:/tmp/cvs-serv9269/phpslash-dev/include/class Modified Files: functions.inc Log Message: sync with -ft cvs Index: functions.inc =================================================================== RCS file: /cvsroot/phpslash/phpslash-dev/include/class/functions.inc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** functions.inc 18 Apr 2003 14:26:42 -0000 1.2 --- functions.inc 23 Apr 2003 15:40:15 -0000 1.3 *************** *** 473,483 **** Parameters : $title -> Title of the page being displayed $metaobject -> Extra stuff about the page (Admin, Home, Poll) ! $section -> if supplied, generates blocks for this section *******************************************************************************/ ! function slashhead($title,$metaobject, $section='') { ! echo getHeader($title,$metaobject, $section=''); ! } /****************************************************************************** --- 473,485 ---- Parameters : $title -> Title of the page being displayed $metaobject -> Extra stuff about the page (Admin, Home, Poll) ! $extra_ary -> if supplied, the array keys are used as template ! placeholders with the values substituted. ! $tpl -> optional alternate template *******************************************************************************/ ! function slashhead($title,$metaobject, $extra_ary='', $tpl='') { ! echo getHeader($title, $metaobject, $extra_ary, $tpl); ! } /****************************************************************************** *************** *** 489,500 **** Parameters : $title -> Title of the page being displayed $metaobject -> Extra stuff about the page (Admin, Home, Poll) ! Accepts an array of name/value pairs for metatags. ! Alternative navbar template or menu can be passed in ! navbar_ary[tpl] or navbar_ary[menu_ary]. ! $section -> if supplied, generates blocks for this section ! Accepts an array to pass to getBlocks $tpl -> optional alternate template *******************************************************************************/ ! function getHeader($title,$metaobject, $section='', $tpl='') { --- 491,502 ---- Parameters : $title -> Title of the page being displayed $metaobject -> Extra stuff about the page (Admin, Home, Poll) ! Accepts an array of name/value pairs for metatags. ! Alternative navbar template or menu can be passed in ! navbar_ary[tpl] or navbar_ary[menu_ary]. ! $extra_ary -> if supplied, the array keys are used as template ! placeholders with the values substituted. $tpl -> optional alternate template *******************************************************************************/ ! function getHeader($title, $metaobject, $extra_ary='', $tpl='') { *************** *** 509,526 **** return pslgetText("NO TITLE"); }; - - if (!isset($section)) { - $block = pslNew("Block_i"); - // should be passing array now days - if( is_array($section)) { - $allblocks = $block->getBlocks($section); - } else { - $allblocks = $block->getAllBlocksForIndex($section); - } - } else { - $allblocks = ''; - } - - /* Templates */ --- 511,514 ---- *************** *** 530,549 **** if( $tpl == '') { $templ->set_file( 'header', $default_template); ! } elseif ( $templ->set_file('header' , basename($tpl) . ".tpl" )) { } else { $templ->set_file( 'header', $default_template); ! } $templ->set_block ("header", "each_metatag", "metatag_block"); if ( is_array($metaobject)) { ! $templ->set_var('XSITEOBJECT', $metaobject['object']); unset($metaobject['object']); ! if(!empty($metaobject['navbar_ary'])) { $navbar_ary = $metaobject['navbar_ary']; ! } unset($metaobject['navbar_ary']); ! while( list( $key, $value) = each( $metaobject )) { $templ->set_var (array ( --- 518,537 ---- if( $tpl == '') { $templ->set_file( 'header', $default_template); ! } elseif ( $templ->set_file('header' , basename($tpl) . ".tpl" )) { } else { $templ->set_file( 'header', $default_template); ! } $templ->set_block ("header", "each_metatag", "metatag_block"); if ( is_array($metaobject)) { ! $templ->set_var('XSITEOBJECT', $metaobject['object']); unset($metaobject['object']); ! if(!empty($metaobject['navbar_ary'])) { $navbar_ary = $metaobject['navbar_ary']; ! } unset($metaobject['navbar_ary']); ! while( list( $key, $value) = each( $metaobject )) { $templ->set_var (array ( *************** *** 580,583 **** --- 568,578 ---- } + // parse extra array into template variable placeholder and value + if( is_array($extra_ary)) { + foreach($extra_ary as $key => $value) { + $templ->set_var(array(strtoupper($key) => $value)); + } + } + $templ->set_var(array( 'QUERYSTRING' => $QUERY_STRING, *************** *** 586,590 **** 'SITE_SLOGAN' => $_PSL['site_slogan'], 'SITE_TITLE' => $_PSL['site_title'], - 'SECTION' => $section, 'ROOTDIR' => $_PSL['rooturl'], 'IMAGEDIR' => $_PSL['imageurl'], --- 581,584 ---- *************** *** 593,597 **** 'NAVBAR' => $navbarcontent, // Could be empty if NavBar is not required 'TOPICBAR' => $topicbarcontent, // Could be empty if TopicBar is not required - 'BLOCKS_COLUMN' => $allblocks, 'SKIN' => $_PSL['skin'] )); --- 587,590 ---- *************** *** 607,614 **** Used to generate the footer on the bottom of each page ! Parameters : None *******************************************************************************/ ! function slashfoot() { ! echo getFooter(); } --- 600,609 ---- Used to generate the footer on the bottom of each page ! Parameters : $tpl -> optional alternate template ! $extra_ary -> if supplied, the array keys are used as template ! placeholders with the values substituted. *******************************************************************************/ ! function slashfoot($tpl="", $extra_ary='') { ! echo getFooter($tpl, $extra_ary); } *************** *** 619,626 **** Used to generate the footer on the bottom of each page ! ! Parameters : optional template (no .tpl) *******************************************************************************/ ! function getFooter($tpl="") { global $_PSL; --- 614,623 ---- Used to generate the footer on the bottom of each page ! ! Parameters : $tpl -> optional alternate template ! $extra_ary -> if supplied, the array keys are used as template ! placeholders with the values substituted. *******************************************************************************/ ! function getFooter($tpl="", $extra_ary='') { global $_PSL; *************** *** 635,639 **** /* Templates */ $default_template = "slashFoot.tpl"; ! $templ = pslNew("slashTemplate",$_PSL['templatedir']); $templ->debug = 0; --- 632,636 ---- /* Templates */ $default_template = "slashFoot.tpl"; ! $templ = pslNew("slashTemplate",$_PSL['templatedir']); $templ->debug = 0; *************** *** 641,648 **** if( $tpl == '') { $templ->set_file( 'footer', $default_template); ! } elseif ( $templ->set_file('footer' , basename($tpl) . ".tpl" )) { } else { $templ->set_file( 'footer', $default_template); ! } $templ->set_var(array( --- 638,652 ---- if( $tpl == '') { $templ->set_file( 'footer', $default_template); ! } elseif ( $templ->set_file('footer' , basename($tpl) . ".tpl" )) { } else { $templ->set_file( 'footer', $default_template); ! } ! ! // parse extra array into template variable placeholder and value ! if( is_array($extra_ary)) { ! foreach($extra_ary as $key => $value) { ! $templ->set_var(array(strtoupper($key) => $value)); ! } ! } $templ->set_var(array( *************** *** 669,676 **** if (is_array($dirty)) { while( list( $key, $val) = @each( $dirty )) { ! if ($allow_html) { ! $clean[$key] = str_replace("'","'",(stripslashes($val))); } else { ! $clean[$key] = str_replace("'","'",(htmlspecialchars(stripslashes($val)))); } } --- 673,685 ---- if (is_array($dirty)) { while( list( $key, $val) = @each( $dirty )) { ! if(is_array($val)) { ! // recursively call - if array value is itself an array. ! $clean = clean($val, $allow_html); } else { ! if ($allow_html) { ! $clean[$key] = str_replace("'","'",(stripslashes($val))); ! } else { ! $clean[$key] = str_replace("'","'",(htmlspecialchars(stripslashes($val)))); ! } } } *************** *** 839,844 **** $template->set_var(array( 'DELIMETER' => $delimeter, ! 'LINK' => "?author_id=" . $ary[author_id] . $section_link . $topic_link, ! 'NAME' => $ary[author] )); $template->parse ("crumb_block", "each_crumb", true); --- 848,853 ---- $template->set_var(array( 'DELIMETER' => $delimeter, ! 'LINK' => "?author_id=" . $ary['author_id'] . $section_link . $topic_link, ! 'NAME' => $ary['author'] )); $template->parse ("crumb_block", "each_crumb", true); *************** *** 1076,1084 **** } ! function psl_dateTimeLong($t) { return psl_strftime('date_time_format_long',$t); } ! function psl_dateTimeShort($t) { return psl_strftime('date_time_format_short',$t); } --- 1085,1093 ---- } ! function psl_dateTimeLong($t=false) { return psl_strftime('date_time_format_long',$t); } ! function psl_dateTimeShort($t=false) { return psl_strftime('date_time_format_short',$t); } *************** *** 1120,1124 **** $_PSL['lang'] = basename($new_lang); } ! } elseif( $_SERVER['HTTP_ACCEPT_LANGUAGE']) { // else try to get from browser $lang_ary = split( "[,;]", $_SERVER['HTTP_ACCEPT_LANGUAGE']); $i = 0; --- 1129,1133 ---- $_PSL['lang'] = basename($new_lang); } ! } elseif( array_key_exists('HTTP_ACCEPT_LANGUAGE', $_SERVER)) { // else try to get from browser $lang_ary = split( "[,;]", $_SERVER['HTTP_ACCEPT_LANGUAGE']); $i = 0; *************** *** 1180,1184 **** $templatedir = $templatedir . "/" . basename($new_lang); } ! } elseif( $_SERVER['HTTP_ACCEPT_LANGUAGE']) { // else attempt to get from browser $lang_ary = explode( ",", $_SERVER['HTTP_ACCEPT_LANGUAGE']); $i = 0; --- 1189,1193 ---- $templatedir = $templatedir . "/" . basename($new_lang); } ! } elseif( array_key_exists('HTTP_ACCEPT_LANGUAGE',$_SERVER)) { // else attempt to get from browser $lang_ary = explode( ",", $_SERVER['HTTP_ACCEPT_LANGUAGE']); $i = 0; *************** *** 1571,1617 **** * @return tpl_object */ ! function displayOptions($module, $tpl_object, $template, $options_ary) { global $_PSL; $default_options = "default_".$module."_options"; $optioncount = $module."_optioncount"; $optioncnt = 0; if(count($options_ary) == 0) { $options_ary = ''; } ! if(!empty($_PSL[$default_options])) { $optioncnt = count($_PSL[$default_options]); } ! $tpl_object->set_block($template,"each_default_option", "doptions"); for ($i =0; $i < $optioncnt; $i++) { if(is_array($options_ary)) { reset($options_ary); } $dname = $_PSL[$default_options][$i]['name']; $dvalue = $_PSL[$default_options][$i]['value']; ! if(isset($options_ary[$dname])) { $dvalue = $options_ary[$dname]; $tpl_object->set_var(array( ! 'DOPTION_NAME' => "optionname[]", ! 'DOPTION_NAME_VAL' => $dname, ! 'DOPTION_VALUE' => "optionval[]", ! 'DOPTION_VALUE_VAL' => $dvalue )); ! unset($options_ary[$dname]); ! } else { $tpl_object->set_var(array( - 'DOPTION_NAME' => "optionname[]", - 'DOPTION_NAME_VAL' => $dname, 'DOPTION_VALUE' => "optionval[]", 'DOPTION_VALUE_VAL' => $dvalue ! )); } $tpl_object->parse("doptions", "each_default_option", true); - } ! $tpl_object->set_block($template,"each_option", "options"); if (is_array($options_ary)) { reset($options_ary); --- 1580,1726 ---- * @return tpl_object */ ! ! function displayOptions($module, $tpl_object='', $template='', $options_ary) { global $_PSL; + if(!is_object($tpl_object)) { + $tpl_object = pslNew('slashTemplate'); + } + // $tpl_object->debug = 7; + + // set options template + $tpl_object->set_file('optionfile', 'optionTypes.tpl'); + + // which module's options? $default_options = "default_".$module."_options"; $optioncount = $module."_optioncount"; $optioncnt = 0; + // available default option types + $dtype_ary = array( 'text', + 'radio', + 'select', + 'text_defaultonly'); + + // initialize array and count if(count($options_ary) == 0) { $options_ary = ''; } ! if(!empty($_PSL[$default_options])) { $optioncnt = count($_PSL[$default_options]); + // debug("optioncnt", $optioncnt); } ! ! // set default option type blocks ! foreach($dtype_ary as $key) { ! $tpl_object->set_block('optionfile',"type_".$key, "option".$key); ! // debug("set_block", "type_".$key); ! // debug("set_block", "option".$key); ! ! } ! ! // process default options for ($i =0; $i < $optioncnt; $i++) { + + if(is_array($options_ary)) { reset($options_ary); } + + // get data from default option array $dname = $_PSL[$default_options][$i]['name']; + $ddescription = $_PSL[$default_options][$i]['description']; $dvalue = $_PSL[$default_options][$i]['value']; ! $dtype = $_PSL[$default_options][$i]['type']; ! $dchoices = ''; ! // debug("default_option", $_PSL[$default_options][$i]); ! if(array_key_exists('choices', $_PSL[$default_options][$i])) { ! $dchoices = $_PSL[$default_options][$i]['choices']; ! } ! // debug("varvals", $tpl_object->varvals); ! // debug("varkeys", $tpl_object->varkeys); ! ! // debug("get_var", "option".$dtype); ! $thistype = $tpl_object->get_var("type_".$dtype); ! // debug("thistype", $thistype); ! $tpl_object->set_var("optiontype", $thistype); ! // $tpl_object->varvals['optiontype'] = $thistype; ! // debug('optiontype',$tpl_object->varvals['optiontype'] ); ! // set html form blocks ! $tpl_object->set_block('optiontype',"each_default_selected", "dselected"); ! $tpl_object->set_block('optiontype',"each_default_notselected", "dnotselected"); ! $tpl_object->set_block('optiontype',"each_default_choice", "dchoices"); ! $tpl_object->set_block('optiontype',"each_default_option", "doptions"); ! ! // is there a saved value for this option? ! if(is_array($options_ary) && array_key_exists($dname, $options_ary)) { ! // yes - load the saved value $dvalue = $options_ary[$dname]; + } + // debug("dvalue", $dvalue); + $tpl_object->set_var(array( + 'DOPTION_NAME' => "optionname[]", + 'DOPTION_NAME_VAL' => $dname, + 'DOPTION_DESCRIPTION' => pslgetText($ddescription) + )); + + // option choices + if(is_array($dchoices)) { + // choices available + reset($dchoices); + + // show current option value as selected/checked $tpl_object->set_var(array( ! 'DOPTION_VALUE' => "optionval[]", ! 'DOPTION_VALUE_VAL' => $dvalue, ! 'DOPTION_VALUE_LABEL' => $dvalue )); ! ! // If the current option value is one of the choices, show that label ! if(array_key_exists($dvalue,$dchoices)) { ! $tpl_object->set_var('DOPTION_VALUE_LABEL', $dchoices[$dvalue]); ! } ! $tpl_object->parse("dchoices", "each_default_selected", true); ! ! // display the choices ! foreach($dchoices as $key => $value) { ! $tpl_object->set_var(array( ! 'DOPTION_VALUE' => "optionval[]", ! 'DOPTION_VALUE_VAL' => $key, ! 'DOPTION_VALUE_LABEL' => $value ! )); ! // selected or not ! if($dvalue == $key ) { ! // $tpl_object->parse("dchoices", "each_default_selected", true); ! } else { ! $tpl_object->parse("dchoices", "each_default_notselected", true); ! } ! $tpl_object->parse("dchoices", "each_default_choice", true); ! } ! } else { ! // no choices $tpl_object->set_var(array( 'DOPTION_VALUE' => "optionval[]", 'DOPTION_VALUE_VAL' => $dvalue ! )); } + if(is_array($options_ary) && array_key_exists($dname, $options_ary)) { + // option processed - remove it from queue. + // debug("unset", $dname); + unset($options_ary[$dname]); + } + // debug("parse", $dname); $tpl_object->parse("doptions", "each_default_option", true); ! $tpl_object->set_var(array( ! 'selected' => '', ! 'notselected' => '', ! 'dchoices' => '' ! )); ! } ! ! $tpl_object->set_block('optiontype',"each_option", "options"); if (is_array($options_ary)) { reset($options_ary); *************** *** 1627,1631 **** // debug("current", $current); ! if ($current) { $tpl_object->set_var(array( 'OPTION_NAME' => "optionname[]", --- 1736,1740 ---- // debug("current", $current); ! if ($current) { $tpl_object->set_var(array( 'OPTION_NAME' => "optionname[]", *************** *** 1652,1657 **** $i++; } ! return $tpl_object; } // end of function displayOptions --- 1761,1768 ---- $i++; } + + $options = $tpl_object->parse('OUT', "optiontype"); ! return $options; } // end of function displayOptions |
From: Joe S. <joe...@us...> - 2003-04-23 15:35:08
|
Update of /cvsroot/phpslash/phpslash-dev In directory sc8-pr-cvs1:/tmp/cvs-serv6088/phpslash-dev Modified Files: CHANGES Log Message: sync with -ft cvs |
From: Joe S. <joe...@us...> - 2003-04-23 15:15:45
|
Update of /cvsroot/phpslash/phpslash-dev/include/modules/block In directory sc8-pr-cvs1:/tmp/cvs-serv27125/phpslash-dev/include/modules/block Modified Files: Block.class Block_admin.class Log Message: Block.class - doParse only updates the db if expire length is set. Index: Block.class =================================================================== RCS file: /cvsroot/phpslash/phpslash-dev/include/modules/block/Block.class,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Block.class 21 Apr 2003 20:25:26 -0000 1.4 --- Block.class 23 Apr 2003 15:15:41 -0000 1.5 *************** *** 520,531 **** $this->parser->parse($this->block_info); $this->parsedData = $this->parser->getFinal(); ! // only write to the db if the data is changed if($this->block_info["cache_data"] != $this->parsedData) { ! // debug($this->block_info["title"], "updated"); ! $this->block_info["cache_data"] = $this->parsedData; ! // Don't commit to db if cache_off block option is used. ! if(empty($this->block_info["block_options"]["cache_disabled"])) { ! $this->storeParsed(); ! } } return true; --- 520,530 ---- $this->parser->parse($this->block_info); $this->parsedData = $this->parser->getFinal(); ! // only copy the parsed data if it changed if($this->block_info["cache_data"] != $this->parsedData) { ! $this->block_info["cache_data"] = $this->parsedData; ! } ! // only write to the db if using a cache ! if(intval($this->block_info["expire_length"]) > 0 ) { ! $this->storeParsed(); } return true; *************** *** 571,574 **** --- 570,576 ---- $this->db->query($query); if ($this->db->affected_rows() != 1) { + // This may happen if 'view' is pressed when an update would + // also happen. Mysql evidently returns zero affected rows + // for the second identical query ( query cache?). if ($this->debug) { debug("Block::storeParsed", "DB error, can't store new block data($id)"); Index: Block_admin.class =================================================================== RCS file: /cvsroot/phpslash/phpslash-dev/include/modules/block/Block_admin.class,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Block_admin.class 12 Mar 2003 16:12:55 -0000 1.1.1.1 --- Block_admin.class 23 Apr 2003 15:15:41 -0000 1.2 *************** *** 14,18 **** */ class Block_admin extends Block_i { ! /* class Block_i also defines the following properties * psl, $templ, $debug, $argv_ary */ --- 14,18 ---- */ class Block_admin extends Block_i { ! /* class Block_i also defines the following properties * psl, $templ, $debug, $argv_ary */ *************** *** 71,82 **** ORDER BY section_name"); while ($this->db->next_record()) { ! $this->templ->set_var(array( ! 'SECTION_ID' => $this->db->Record['section_id'], ! 'SELECTED' => "", ! 'SECTION_NAME' => $this->db->Record['section_name'] ! )); ! $this->templ->parse("section_rows","section_row",true); } /* display a blank form */ $this->templ->set_var(array( --- 71,88 ---- ORDER BY section_name"); while ($this->db->next_record()) { ! if (($this->perm->have_perm("blockNew && ". ALLSECTIONS)) || ! ($this->perm->have_perm("blockNew && section_id".$this->db->Record['section_id']))) { ! $this->templ->set_var(array( ! 'SECTION_ID' => $this->db->Record['section_id'], ! 'SELECTED' => "", ! 'SECTION_NAME' => $this->db->Record['section_name'] ! )); ! $this->templ->parse("section_rows","section_row",true); ! } } + // get default options + $options = displayOptions('block', $this->templ, "newblock", ''); + /* display a blank form */ $this->templ->set_var(array( *************** *** 89,96 **** 'CACHE_DATA' => "", 'BLOCK_ID' => "", ! 'ORDERNUM' => "" )); - $this->templ = displayoptions('block', $this->templ, "newblock", ''); return $this->templ->parse('OUT',array("newblock")); --- 95,102 ---- 'CACHE_DATA' => "", 'BLOCK_ID' => "", ! 'ORDERNUM' => "", ! 'OPTIONS' => $options )); return $this->templ->parse('OUT',array("newblock")); *************** *** 108,111 **** --- 114,119 ---- function editBlock($id) { + $section_ary = array(); + $this->getBlock($id); *************** *** 149,165 **** ORDER BY section_name"); while ($this->db->next_record()) { ! $this->templ->set_var(array( ! 'SECTION_ID' => $this->db->Record['section_id'], ! 'SECTION_NAME' => $this->db->Record['section_name'] ! )); ! $this->templ->set_var('SELECTED',""); ! for ($i = 0 ; $i < count($section_ary) ; $i++) { ! if ($section_ary[$i] == $this->db->Record['section_id']) { ! $this->templ->set_var('SELECTED',"SELECTED"); } } - - $this->templ->parse("section_rows","section_row",true); } $temparray=$this->block_info["block_options"]; --- 157,175 ---- ORDER BY section_name"); while ($this->db->next_record()) { ! if (($this->perm->have_perm("blockEdit && ". ALLSECTIONS)) || ! ($this->perm->have_perm("blockEdit && section_id".$this->db->Record['section_id']))) { ! $this->templ->set_var(array( ! 'SECTION_ID' => $this->db->Record['section_id'], ! 'SECTION_NAME' => $this->db->Record['section_name'] ! )); ! $this->templ->set_var('SELECTED',""); ! for ($i = 0 ; $i < count($section_ary) ; $i++) { ! if ($section_ary[$i] == $this->db->Record['section_id']) { ! $this->templ->set_var('SELECTED',"SELECTED"); ! } } + $this->templ->parse("section_rows","section_row",true); } } $temparray=$this->block_info["block_options"]; *************** *** 168,172 **** reset($temparray); } ! $this->templ->set_var(array( 'TITLEBAR' => getTitlebar("100%", "Update a Block"), --- 178,185 ---- reset($temparray); } ! ! // get default and saved options ! $options = displayOptions('block', $this->templ, "editblock", $temparray); ! $this->templ->set_var(array( 'TITLEBAR' => getTitlebar("100%", "Update a Block"), *************** *** 178,186 **** 'CACHE_DATA' => $this->block_info["cache_data"], 'ORDERNUM' => $this->block_info["ordernum"], ! 'BLOCK_ID' => $id )); - $this->templ = displayoptions('block', $this->templ, "editblock", $temparray); - $output = $this->templ->parse('OUT',array("editblock")); // $this->templ->p('OUT'); --- 191,198 ---- 'CACHE_DATA' => $this->block_info["cache_data"], 'ORDERNUM' => $this->block_info["ordernum"], ! 'BLOCK_ID' => $id, ! 'OPTIONS' => $options )); $output = $this->templ->parse('OUT',array("editblock")); // $this->templ->p('OUT'); *************** *** 218,221 **** --- 230,255 ---- $block_id = $this->db->f("id"); + + // get block's sections + $db2 = pslNew("slashDB"); + $db2->query("SELECT section_id + FROM psl_section_block_lut + WHERE block_id = '$block_id' "); + if ($this->perm->have_perm("blockList && ". ALLSECTIONS)) { + $ok = true; + } else { + $ok = false; + } + while ($db2->next_record()) { + // permisssion to any of them? + if ($this->perm->have_perm("blockList && section_id".$db2->Record['section_id'])) { + $ok = true; + break; + } + } + if(!$ok) { + continue; + } + $modifyurl = $this->psl['adminurl'] ."/blockAdmin.php?submit=edit&id=". $block_id; $delurl = $this->psl['adminurl'] ."/blockAdmin.php?submit=delete&id=". $block_id; *************** *** 223,227 **** $this->templ->set_var(array( ! 'TITLEBAR' => getTitlebar("100%", pslgetText("Update the Current Blocks")), 'MODIFYURL' => $modifyurl, 'DELURL' => $delurl, --- 257,261 ---- $this->templ->set_var(array( ! 'TITLEBAR' => getTitlebar("100%", pslgetText("Update the Current Blocks")), 'MODIFYURL' => $modifyurl, 'DELURL' => $delurl, *************** *** 233,245 **** )); if ($i%2 == 0) { ! $this->templ->parse("rows","row","true"); ! } else { $this->templ->parse("rows","row2","true"); ! } ! $i++; } return $this->templ->parse('OUT', array("listblock")); - // $this->templ->p('OUT'); } --- 267,278 ---- )); if ($i%2 == 0) { ! $this->templ->parse("rows","row","true"); ! } else { $this->templ->parse("rows","row2","true"); ! } ! $i++; } return $this->templ->parse('OUT', array("listblock")); } |
From: Joe S. <joe...@us...> - 2003-04-23 15:14:54
|
Update of /cvsroot/phpslash/phpslash-ft In directory sc8-pr-cvs1:/tmp/cvs-serv26604/phpslash-ft Modified Files: CHANGES Log Message: Block.class - doParse only updates the db if expire length is set. Index: CHANGES =================================================================== RCS file: /cvsroot/phpslash/phpslash-ft/CHANGES,v retrieving revision 1.759 retrieving revision 1.760 diff -C2 -d -r1.759 -r1.760 *** CHANGES 21 Apr 2003 17:08:44 -0000 1.759 --- CHANGES 23 Apr 2003 15:14:47 -0000 1.760 *************** *** 13,21 **** 9 - Removal of something (kill -9 :) ! 2003-April-21 12:00PM CST Joe Stewart <joe...@us...> [F] - Block.class - new block option - "cache_disabled". When this is set the block will not be written to the db. ! 2003-April-18 9:00AM CST Joe Stewart <joe...@us...> [B] - Block.class - doParse only calls storeParsed if the block data changed. functions.inc, slash-all.sql - tweaks for new block types. --- 13,28 ---- 9 - Removal of something (kill -9 :) ! 2003-April-23 10:00AM CDT Joe Stewart <joe...@us...> ! [B] - Block.class - doParse only updates the db if expire length is set. ! Removed "cache_disabled" block option. ! ! 2003-April-21 2:00PM CDT Joe Stewart <joe...@us...> ! [W] - slashAuthCR.class - clean up code comments. ! ! 2003-April-21 12:00PM CDT Joe Stewart <joe...@us...> [F] - Block.class - new block option - "cache_disabled". When this is set the block will not be written to the db. ! 2003-April-18 9:00AM CDT Joe Stewart <joe...@us...> [B] - Block.class - doParse only calls storeParsed if the block data changed. functions.inc, slash-all.sql - tweaks for new block types. |
From: Joe S. <joe...@us...> - 2003-04-23 15:14:54
|
Update of /cvsroot/phpslash/phpslash-ft/class In directory sc8-pr-cvs1:/tmp/cvs-serv26604/phpslash-ft/class Modified Files: Block.class Log Message: Block.class - doParse only updates the db if expire length is set. Index: Block.class =================================================================== RCS file: /cvsroot/phpslash/phpslash-ft/class/Block.class,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** Block.class 21 Apr 2003 17:08:46 -0000 1.31 --- Block.class 23 Apr 2003 15:14:47 -0000 1.32 *************** *** 5,9 **** * Database Level access to the PHPSlash Block Engine. * ! * This object is how we retrieve block data from the database. It also * provides the db interface for block management. */ --- 5,9 ---- * Database Level access to the PHPSlash Block Engine. * ! * This object is how we retrieve block data from the database. It also * provides the db interface for block management. */ *************** *** 15,19 **** /** ! * Block - constructor for the Block class * * Atributes of the base block methods setup here --- 15,19 ---- /** ! * Block - constructor for the Block class * * Atributes of the base block methods setup here *************** *** 26,36 **** /* Constructor: Create sub-objects here, etc... */ global $_PSL, $perm; ! $this->db = pslNew("slashDB"); $this->db->Auto_Free = 1; ! $this->psl = $_PSL; $this->perm = &$perm; ! /* Array to store block info in */ $this->block_info = array(); --- 26,36 ---- /* Constructor: Create sub-objects here, etc... */ global $_PSL, $perm; ! $this->db = pslNew("slashDB"); $this->db->Auto_Free = 1; ! $this->psl = $_PSL; $this->perm = &$perm; ! /* Array to store block info in */ $this->block_info = array(); *************** *** 45,49 **** /** ! * reset - Resets object to empty values * * @access public --- 45,49 ---- /** ! * reset - Resets object to empty values * * @access public *************** *** 51,55 **** */ function reset() { ! unset($this->block_info); unset($this->parser); --- 51,55 ---- */ function reset() { ! unset($this->block_info); unset($this->parser); *************** *** 74,78 **** /** * putType - Stores a block Type ! * * @param string type * --- 74,78 ---- /** * putType - Stores a block Type ! * * @param string type * *************** *** 86,93 **** if ($this->db->affected_rows != 1) { $this->message = sprintf(pslgetText("Block Type: %s added with an id of: %s"), $type, $id); ! return true; } else { $this->message = sprintf(pslgetText("Error entering %s!"), $type); ! return false; } } --- 86,93 ---- if ($this->db->affected_rows != 1) { $this->message = sprintf(pslgetText("Block Type: %s added with an id of: %s"), $type, $id); ! return true; } else { $this->message = sprintf(pslgetText("Error entering %s!"), $type); ! return false; } } *************** *** 96,112 **** /* deleteType - deletes the type from the db * ! * Given the type_name, it deletes that from the psl_block_type table. ! * IT check and make sure there are NO blocks associated with this ! * block_type before deleting it. Returns true if block_type is deleted, * false if not. * * @param integer type_name * ! * @access public */ function deleteType($type_name) { $go_ahead = true; ! if (!$type_name) { return false; --- 96,112 ---- /* deleteType - deletes the type from the db * ! * Given the type_name, it deletes that from the psl_block_type table. ! * IT check and make sure there are NO blocks associated with this ! * block_type before deleting it. Returns true if block_type is deleted, * false if not. * * @param integer type_name * ! * @access public */ function deleteType($type_name) { $go_ahead = true; ! if (!$type_name) { return false; *************** *** 118,125 **** FROM psl_block, psl_block_type ! WHERE psl_block.type = psl_block_type.id AND psl_block_type.name = '$type_name'"; $this->db->query($q); ! while ($this->db->next_record()) { $go_ahead = false; $title = $this->db->Record["title"]; --- 118,125 ---- FROM psl_block, psl_block_type ! WHERE psl_block.type = psl_block_type.id AND psl_block_type.name = '$type_name'"; $this->db->query($q); ! while ($this->db->next_record()) { $go_ahead = false; $title = $this->db->Record["title"]; *************** *** 130,134 **** return false; } else { ! $q = "DELETE FROM psl_block_type WHERE name = '$type_name'"; --- 130,134 ---- return false; } else { ! $q = "DELETE FROM psl_block_type WHERE name = '$type_name'"; *************** *** 140,144 **** } ! /** * getBlock - returns a block from an id --- 140,144 ---- } ! /** * getBlock - returns a block from an id *************** *** 166,170 **** block_options FROM psl_block,psl_block_type ! WHERE psl_block.id='$id' AND psl_block.type = psl_block_type.id"; --- 166,170 ---- block_options FROM psl_block,psl_block_type ! WHERE psl_block.id='$id' AND psl_block.type = psl_block_type.id"; *************** *** 203,207 **** * putBlock - Puts the array into the db as a block * ! * @param array block_array * * @access public --- 203,207 ---- * putBlock - Puts the array into the db as a block * ! * @param array block_array * * @access public *************** *** 520,531 **** $this->parser->parse($this->block_info); $this->parsedData = $this->parser->getFinal(); ! // only write to the db if the data is changed if($this->block_info["cache_data"] != $this->parsedData) { ! // debug($this->block_info["title"], "updated"); ! $this->block_info["cache_data"] = $this->parsedData; ! // Don't commit to db if cache_off block option is used. ! if(empty($this->block_info["block_options"]["cache_disabled"])) { ! $this->storeParsed(); ! } } return true; --- 520,530 ---- $this->parser->parse($this->block_info); $this->parsedData = $this->parser->getFinal(); ! // only copy the parsed data if it changed if($this->block_info["cache_data"] != $this->parsedData) { ! $this->block_info["cache_data"] = $this->parsedData; ! } ! // only write to the db if using a cache ! if(intval($this->block_info["expire_length"]) > 0 ) { ! $this->storeParsed(); } return true; *************** *** 571,574 **** --- 570,576 ---- $this->db->query($query); if ($this->db->affected_rows() != 1) { + // This may happen if 'view' is pressed when an update would + // also happen. Mysql evidently returns zero affected rows + // for the second identical query ( query cache?). if ($this->debug) { debug("Block::storeParsed", "DB error, can't store new block data($id)"); |
From: Joe S. <joe...@us...> - 2003-04-21 20:37:05
|
Update of /cvsroot/phpslash/phpslash-dev/include/modules/story In directory sc8-pr-cvs1:/tmp/cvs-serv4880/phpslash-dev/include/modules/story Modified Files: Story.class Story_admin.class Story_base.class Log Message: sync with -ft cvs. Index: Story.class =================================================================== RCS file: /cvsroot/phpslash/phpslash-dev/include/modules/story/Story.class,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Story.class 12 Mar 2003 16:12:54 -0000 1.1.1.1 --- Story.class 21 Apr 2003 20:36:58 -0000 1.2 *************** *** 176,183 **** for( $i=0 ; $i < $stories ; $i++) { if($story_id_ary[$i]["story_id"] == $story_id) { ! $nextsid = $story_id_ary[$i + 1]["story_id"]; ! $nexttitle = $story_id_ary[$i + 1]["title"]; ! $prevsid = $story_id_ary[$i - 1]["story_id"]; ! $prevtitle = $story_id_ary[$i - 1]["title"]; $stories = 0; } --- 176,187 ---- for( $i=0 ; $i < $stories ; $i++) { if($story_id_ary[$i]["story_id"] == $story_id) { ! if(array_key_exists($i + 1, $story_id_ary)) { ! $nextsid = $story_id_ary[$i + 1]["story_id"]; ! $nexttitle = $story_id_ary[$i + 1]["title"]; ! } ! if(array_key_exists($i - 1, $story_id_ary)) { ! $prevsid = $story_id_ary[$i - 1]["story_id"]; ! $prevtitle = $story_id_ary[$i - 1]["title"]; ! } $stories = 0; } *************** *** 191,221 **** $arrows = ""; $link_argv= ""; ! if ( $ary['mode'] != "") { $link_argv .= "&mode=" . $ary['mode']; } ! if ( $ary[section_id] != "") { $link_argv .= "&section_id=" . $ary['section_id']; } elseif ( $ary['section'] != $site_homesection) { $link_argv .= "&section=" . $ary['section']; } ! if ( $ary['topic_id'] != "") { $link_argv .= "&topic_id=" . urlencode($ary['topic_id']); ! } elseif ( $ary['topic'] != "") { $link_argv .= "&topic=" . urlencode($ary['topic']); } ! if ( $ary['author_id'] != "") { $link_argv .= "&author_id=" . $ary['author_id']; ! } elseif ( $ary['author'] != "") { $link_argv .= "&author=" . $ary['author']; } - $turl = $this->psl['phpself'] . "?story_id=$prevsid" . "$link_argv"; if (isset($prevtitle)) { $arrows = "<<\n"; $arrows .= "<a href=\"$turl\">$prevtitle</a> | "; } $arrows .= "<a href=\"" . $this->psl['rooturl'] . "/comment.php?submit=post" . $this->psl['amp'] . "story_id=$story_id" . $this->psl['amp'] . "parent_id=0\"><b>" . pslgetText("Reply") . "</b></a> "; - $turl = $this->psl['phpself'] . "?story_id=$nextsid" . $link_argv; if (isset($nexttitle)) { $arrows .= " | <a href=\"$turl\">$nexttitle</a> "; $arrows .= " >>\n"; --- 195,225 ---- $arrows = ""; $link_argv= ""; ! if ( array_key_exists('mode', $ary) ) { $link_argv .= "&mode=" . $ary['mode']; } ! if ( array_key_exists('section_id', $ary) ) { $link_argv .= "&section_id=" . $ary['section_id']; } elseif ( $ary['section'] != $site_homesection) { $link_argv .= "&section=" . $ary['section']; } ! if (array_key_exists('topic_id', $ary) ) { $link_argv .= "&topic_id=" . urlencode($ary['topic_id']); ! } elseif ( array_key_exists('topic', $ary)) { $link_argv .= "&topic=" . urlencode($ary['topic']); } ! if ( array_key_exists('author_id', $ary)) { $link_argv .= "&author_id=" . $ary['author_id']; ! } elseif ( array_key_exists('author', $ary)) { $link_argv .= "&author=" . $ary['author']; } if (isset($prevtitle)) { + $turl = $this->psl['phpself'] . "?story_id=$prevsid" . "$link_argv"; $arrows = "<<\n"; $arrows .= "<a href=\"$turl\">$prevtitle</a> | "; } $arrows .= "<a href=\"" . $this->psl['rooturl'] . "/comment.php?submit=post" . $this->psl['amp'] . "story_id=$story_id" . $this->psl['amp'] . "parent_id=0\"><b>" . pslgetText("Reply") . "</b></a> "; if (isset($nexttitle)) { + $turl = $this->psl['phpself'] . "?story_id=$nextsid" . $link_argv; $arrows .= " | <a href=\"$turl\">$nexttitle</a> "; $arrows .= " >>\n"; *************** *** 287,291 **** $cache_ary = unserialize($ary["topic_cache"]); ! $cache_ary[$story_name]['expire'] = 0; // default to no story cache $cache_ary[$related_name]['expire'] = 0; // default to no related cache --- 291,295 ---- $cache_ary = unserialize($ary["topic_cache"]); ! $cache_ary['story']['expire'] = 0; // default to no story cache $cache_ary[$related_name]['expire'] = 0; // default to no related cache *************** *** 298,305 **** } ! $name_mod = $argv_ary["section"] . $argv_ary["topic"] . $argv_ary["author"] . $argv_ary["mode"]; $story_name = basename($this->psl['languagefile']) . $this->psl['skin'] ."story" . $name_mod; $cache_ary[$story_name]['expire'] = $cache_ary['story']['expire']; - $thestory = $this->cacheStory($cache_ary, $story_name); if( ($thestory == "") AND ($mode == "full") ) { --- 302,308 ---- } ! $name_mod = implode('', $argv_ary); $story_name = basename($this->psl['languagefile']) . $this->psl['skin'] ."story" . $name_mod; $cache_ary[$story_name]['expire'] = $cache_ary['story']['expire']; $thestory = $this->cacheStory($cache_ary, $story_name); if( ($thestory == "") AND ($mode == "full") ) { *************** *** 312,325 **** } - /* We only need to set the block the first time we use it, beacuse - all the variables stay there -nh */ - if ($this->template->get_var("row") == "") { - $this->template->set_block('template',"alsotext","alsoblock"); - $this->template->set_block('template',"row","rows"); - } - $related = ""; $arrows = ""; ! if( $mode == full) { /* set Related Links here */ $related = $this->cacheStory($cache_ary, $related_name); --- 315,321 ---- } $related = ""; $arrows = ""; ! if( $mode == 'full') { /* set Related Links here */ $related = $this->cacheStory($cache_ary, $related_name); *************** *** 333,338 **** $arrows = $this->getNextPrev($story_id, $argv_ary); } ! $titlebar = getTitleBar("100%", $ary[title]); $this->template->set_var(array( --- 329,341 ---- $arrows = $this->getNextPrev($story_id, $argv_ary); } + + /* We only need to set the block the first time we use it, beacuse + all the variables stay there -nh */ + // if ($this->template->get_var("row") == "") { + $this->template->set_block('template',"alsotext","alsoblock"); + $this->template->set_block('template',"row","rows"); + // } ! $titlebar = getTitleBar("100%", $ary['title']); $this->template->set_var(array( *************** *** 421,425 **** * min = "starting" point [0] * max = maximum returned [10] ! * order = [time], hits, title, etc. * asc = ASC, [DESC] ( Ascending or Descending) * mode = headline, full, [hp] - (maybe only hp needed now) --- 424,428 ---- * min = "starting" point [0] * max = maximum returned [10] ! * order = [date_available], hits, title, etc. * asc = ASC, [DESC] ( Ascending or Descending) * mode = headline, full, [hp] - (maybe only hp needed now) *************** *** 456,465 **** /* We only need to set the block the first time we use it, beacuse all the variables stay there -nh */ ! if ($this->template->get_var("row") == "") { ! $this->template->set_block("template","row","rows"); ! $this->template->set_block("template","alsotext","alsoblock"); $this->template->set_block("printStory","row","rows"); $this->template->set_block("printStory","alsotext","alsoblock"); ! } $this->template->set_block('template', 'each_story', 'stories'); --- 459,472 ---- /* We only need to set the block the first time we use it, beacuse all the variables stay there -nh */ ! // if ($this->template->get_var("row") == "") { ! if($this->template->is_available('template', 'row')) { ! $this->template->set_block("template","row","rows"); ! } ! if($this->template->is_available('template', 'alsotext')) { ! $this->template->set_block("template","alsotext","alsoblock"); ! } $this->template->set_block("printStory","row","rows"); $this->template->set_block("printStory","alsotext","alsoblock"); ! // } $this->template->set_block('template', 'each_story', 'stories'); *************** *** 512,520 **** 'ARROWS' => "" )); ! ! // if(array_key_exists('topic_id_ary', $stories_ary[$i])) { $topic_id_ary = $stories_ary[$i]['topic_id_ary']; ! // } ! $topic_name_ary = $stories_ary[$i]['topic_name_ary']; if (!empty($topic_id_ary)) { --- 519,531 ---- 'ARROWS' => "" )); ! ! $topic_id_ary = ''; ! if(array_key_exists('topic_id_ary', $stories_ary[$i])) { $topic_id_ary = $stories_ary[$i]['topic_id_ary']; ! } ! $topic_name_ary = ''; ! if(array_key_exists('topic_name_ary', $stories_ary[$i])) { ! $topic_name_ary = $stories_ary[$i]['topic_name_ary']; ! } if (!empty($topic_id_ary)) { Index: Story_admin.class =================================================================== RCS file: /cvsroot/phpslash/phpslash-dev/include/modules/story/Story_admin.class,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Story_admin.class 12 Mar 2003 16:12:54 -0000 1.1.1.1 --- Story_admin.class 21 Apr 2003 20:36:58 -0000 1.2 *************** *** 79,85 **** // gotta get the story user_id ! $story_ary = $this->extractStory($story_id, "Full"); $user_id = $story_ary['user_id']; ! if((!$this->perm->have_perm('storydeleteothers')) AND ( $user_id != $this->auth->auth['uid'])) { --- 79,85 ---- // gotta get the story user_id ! $story_ary = $this->extractStory($story_id, "Full"); $user_id = $story_ary['user_id']; ! if((!$this->perm->have_perm('storydeleteothers')) AND ( $user_id != $this->auth->auth['uid'])) { *************** *** 88,128 **** $this->message = pslgetText("The storyid is: ").$story_id."<BR>\n"; - if ($_PSL['module']['Comment']) { - $comment = pslNew("Comment"); - $deleted_comments = $comment->delete("0",$story_id); - $this->message .= sprintf(pslgetText("You deleted %s comments"), $deleted_comments)."<BR>\n"; - } ! $section_del = "DELETE ! FROM psl_section_lut ! WHERE story_id = '$story_id'"; ! $topic_del = "DELETE ! FROM psl_topic_lut ! WHERE story_id = '$story_id'"; ! $story_del = "DELETE ! FROM psl_story ! WHERE story_id = '$story_id'"; ! if ($this->db->query($section_del)) { ! $section_count = $this->db->affected_rows(); ! $this->message .= sprintf(pslgetText("removed %s section pointer(s)"), $section_count)."<BR>\n"; ! } ! if ($this->db->query($topic_del)) { ! $topic_count = $this->db->affected_rows(); ! $this->message .= sprintf(pslgetText("removed %s topic pointer(s)"), $topic_count)."<BR>\n"; ! } ! if ($this->db->query($story_del)) { ! $story_count = $this->db->affected_rows(); ! $this->message .= pslgetText("removed the story")."<BR>\n"; ! } return true; } /* function to allow a story Preview */ ! function showStory($ary) { ! $story = pslNew("Story"); --- 88,185 ---- $this->message = pslgetText("The storyid is: ").$story_id."<BR>\n"; ! if ($this->perm->have_perm("storyDelete && ". ALLSECTIONS)) { ! // all permisssions - so go ahead and delete story ! if ($_PSL['module']['Comment']) { ! $comment = pslNew("Comment"); ! $deleted_comments = $comment->delete("0",$story_id); ! $this->message .= sprintf(pslgetText("You deleted %s comments"), $deleted_comments)."<BR>\n"; ! } ! $section_del = "DELETE ! FROM psl_section_lut ! WHERE story_id = '$story_id'"; ! $topic_del = "DELETE ! FROM psl_topic_lut ! WHERE story_id = '$story_id'"; ! ! $story_del = "DELETE ! FROM psl_story ! WHERE story_id = '$story_id'"; ! if ($this->db->query($section_del)) { ! $section_count = $this->db->affected_rows(); ! $this->message .= sprintf(pslgetText("removed %s section pointer(s)"), $section_count)."<BR>\n"; ! } ! if ($this->db->query($topic_del)) { ! $topic_count = $this->db->affected_rows(); ! $this->message .= sprintf(pslgetText("removed %s topic pointer(s)"), $topic_count)."<BR>\n"; ! } ! if ($this->db->query($story_del)) { ! $story_count = $this->db->affected_rows(); ! $this->message .= pslgetText("removed the story")."<BR>\n"; ! } ! } else { ! // permissions only to certain sections - so delete only that portion ! $section_count = 0; ! ! // get current sections assigned to block ! $section_q = "SELECT section_id ! FROM psl_section_lut ! WHERE story_id = '$story_id' "; ! // debug("section_q", $section_q); ! $this->db->query($section_q); ! $ok = true; // start with allowing story to be deleted ! while($this->db->next_record()) { ! if ($this->perm->have_perm("storyDelete && section_id".$this->db->Record['section_id'])){ ! $section_id =$this->db->Record['section_id']; ! // debug("section_id", $section_id); ! // only delete for the section that the user has permission ! $db2 = pslNew("slashDB"); //create another db object ! $section_lut_del = "DELETE FROM psl_section_lut ! WHERE story_id = '$story_id' ! AND section_id = '$section_id' "; ! // debug("section_lut_del", $section_lut_del); ! if ($db2->query($section_lut_del)) { ! $section_count++; ! } ! } else { ! // don't have permission to this section - so don't allow block to be deleted ! $ok = false; ! } ! } //endwhile ! $this->message .= sprintf(pslgetText("removed %s section pointer(s)"), $section_count)."<BR>\n"; ! ! // if allowed - delete story and associated records ! if($ok) { ! $topic_del = "DELETE ! FROM psl_topic_lut ! WHERE story_id = '$story_id'"; ! ! $story_del = "DELETE ! FROM psl_story ! WHERE story_id = '$story_id'"; ! ! if ($this->db->query($topic_del)) { ! $topic_count = $this->db->affected_rows(); ! $this->message .= sprintf(pslgetText("removed %s topic pointer(s)"), $topic_count)."<BR>\n"; ! } ! if ($this->db->query($story_del)) { ! $story_count = $this->db->affected_rows(); ! $this->message .= pslgetText("removed the story")."<BR>\n"; ! } ! } ! ! ! ! } //endif return true; } /* function to allow a story Preview */ ! function showStory($ary) { ! $story = pslNew("Story"); *************** *** 265,271 **** function listStory($ary, $first) { ! $author_id = $ary['author_id']; ! $topic_id = $ary['topic_id']; ! $section_id = $ary['section_id']; $cmt_list = 10; /* num of stories to display before the "more" link */ --- 322,338 ---- function listStory($ary, $first) { ! $author_id = ''; ! $topic_id = ''; ! $section_id = ''; ! ! if(array_key_exists('author_id',$ary)) { ! $author_id = $ary['author_id']; ! } ! if(array_key_exists('topic_id',$ary)) { ! $topic_id = $ary['topic_id']; ! } ! if(array_key_exists('section_id',$ary)) { ! $section_id = $ary['section_id']; ! } $cmt_list = 10; /* num of stories to display before the "more" link */ *************** *** 287,298 **** } $q .= " psl_commentcount commentcount ! WHERE story.story_id = commentcount.count_id AND author.author_id = story.user_id "; ! $user_id = $this->auth->auth[uid]; // if you're not a storyeditor, then you can only view your own stories. if (!$this->perm->have_perm("storylistothers")) { ! $q .= "AND '$user_id' = story.user_id ! AND '$user_id' = author.author_id "; } if ($author_id) { --- 354,365 ---- } $q .= " psl_commentcount commentcount ! WHERE story.story_id = commentcount.count_id AND author.author_id = story.user_id "; ! $user_id = $this->auth->auth['uid']; // if you're not a storyeditor, then you can only view your own stories. if (!$this->perm->have_perm("storylistothers")) { ! $q .= "AND '$user_id' = story.user_id ! AND '$user_id' = author.author_id "; } if ($author_id) { *************** *** 323,328 **** $topic_array = $topic->getTopics(); $section_array = $section->getSections(); - - $this->template->set_block("liststory", "each_author", "authors"); --- 390,393 ---- *************** *** 336,340 **** $this->template->set_var(array( "AUTHOR_ID" => $cur_Author['id'], ! "AUTHOR_NAME" => $cur_Author['name'], "SELECTED" => "" )); --- 401,405 ---- $this->template->set_var(array( "AUTHOR_ID" => $cur_Author['id'], ! "AUTHOR_NAME" => $cur_Author['name'], "SELECTED" => "" )); *************** *** 353,364 **** "SELECTED" => "" )); ! $this->template->parse("topics", "each_topic", "true"); while (list(, $cur_Topic) = each($topic_array)) { $this->template->set_var(array( ! "TOPIC_NAME" => $cur_Topic[name], ! "TOPIC_ID" => $cur_Topic[id], "SELECTED" => "" )); ! if ($cur_Topic[id] == $topic_id) { $this->template->set_var(array( "SELECTED" => "selected=\"selected\"" --- 418,429 ---- "SELECTED" => "" )); ! $this->template->parse("topics", "each_topic", "true"); while (list(, $cur_Topic) = each($topic_array)) { $this->template->set_var(array( ! "TOPIC_NAME" => $cur_Topic['name'], ! "TOPIC_ID" => $cur_Topic['id'], "SELECTED" => "" )); ! if ($cur_Topic['id'] == $topic_id) { $this->template->set_var(array( "SELECTED" => "selected=\"selected\"" *************** *** 374,382 **** "SELECTED" => "" )); ! $this->template->parse("sections", "each_section", "true"); while (list(, $cur_Section) = each($section_array)) { $this->template->set_var(array( ! "SECTION_NAME" => $cur_Section[name], ! "SECTION_ID" => $cur_Section[id], "SELECTED" => "" )); --- 439,451 ---- "SELECTED" => "" )); ! $this->template->parse("sections", "each_section", "true"); while (list(, $cur_Section) = each($section_array)) { + if ((!$this->perm->have_perm("storyList && ". ALLSECTIONS)) && + (!$this->perm->have_perm("storyList && section_id".$cur_Section['id']))) { + continue; + } $this->template->set_var(array( ! "SECTION_NAME" => $cur_Section['name'], ! "SECTION_ID" => $cur_Section['id'], "SELECTED" => "" )); *************** *** 389,405 **** } ! $this->template->set_var(array( ! 'ACTION_URL' => $this->psl['phpself'], ! 'TOPIC_SELECT' => $topic_select_html, ! 'SECTION_SELECT' => $section_select_html, ! 'AUTHOR_SELECT' => $author_select_html ! )); while ($this->db->next_record()) { $story_id = $this->db->Record["story_id"]; ! $count++; ! if ( ($count > $first) and ($count <= ($first+$cmt_list)) ) { $view_url = $this->psl['rooturl'] . "/article.php?story_id=$story_id"; --- 458,487 ---- } ! $this->template->set_var('ACTION_URL', $this->psl['phpself']); while ($this->db->next_record()) { $story_id = $this->db->Record["story_id"]; ! // $count++; ! // get story's sections ! $db2 = pslNew("slashDB"); ! $db2->query("SELECT section_id ! FROM psl_section_lut ! WHERE story_id = '$story_id' "); ! ! $ok = false; ! $i = 0; ! while ($db2->next_record()) { ! // permisssion to any of them? ! if (($this->perm->have_perm("storyList && ". ALLSECTIONS)) || ! ($this->perm->have_perm("storyList && section_id".$db2->Record['section_id']))) { ! $ok = true; ! $count++; ! break; ! } ! } ! ! if ( ($count > $first) and ($count <= ($first+$cmt_list) and $ok) ) { $view_url = $this->psl['rooturl'] . "/article.php?story_id=$story_id"; *************** *** 409,412 **** --- 491,495 ---- $this->template->set_var(array( 'ORDER_NO' => $this->db->Record["order_no"], + 'STORY_ID' => $story_id, 'COUNT' => $count, 'VIEWURL' => $view_url, *************** *** 420,429 **** if ($i%2 == 0) { ! $this->template->parse("rows","row","true"); ! } else { $this->template->parse("rows","row2","true"); ! } ! $i++; ! } } --- 503,512 ---- if ($i%2 == 0) { ! $this->template->parse("rows","row","true"); ! } else { $this->template->parse("rows","row2","true"); ! } ! $i++; ! } } *************** *** 461,464 **** --- 544,564 ---- // echo "<B>Data_Source: $data_source</B><BR><BR>\n"; + // new story - array is empty + if(array_key_exists('submit', $ary) && + $ary['submit'] == 'new') { + $ary['story_id'] = ''; + $ary['order_no'] = ''; + $ary['dept'] = ''; + $ary['intro_text'] = ''; + $ary['body_text'] = ''; + $ary['title'] = ''; + $ary['story_date'] = ''; + $ary['content'] = ''; + /*$ary['topic_id_ary'] = ''; + $ary['section_id_ary'] = ''; + */ + // $ary['story_options'] = ''; + } + $this->template->set_block("newstory","topic_row","topic_rows"); $this->template->set_block("newstory","section_row","section_rows"); *************** *** 491,499 **** $ary['body_text'] = clean($ary['body_text']); $ary['title'] = clean($ary['title']); ! if( $ary['story_date'] ) { $ary['datetime'] = implode( '-', $ary['story_date']) ." ". implode( ':',$ary['story_time']); ! } else { $ary['datetime'] = date("Y-m-d H:i:s"); ! } $this->template->set_var(array( 'ORDER_NO' => $ary['order_no'], --- 591,599 ---- $ary['body_text'] = clean($ary['body_text']); $ary['title'] = clean($ary['title']); ! if( $ary['story_date'] ) { $ary['datetime'] = implode( '-', $ary['story_date']) ." ". implode( ':',$ary['story_time']); ! } else { $ary['datetime'] = date("Y-m-d H:i:s"); ! } $this->template->set_var(array( 'ORDER_NO' => $ary['order_no'], *************** *** 552,556 **** $this->template->parse("day_rows","day_row",true); } ! // setup hour select box for( $i=1; $i<=24; $i++) { --- 652,656 ---- $this->template->parse("day_rows","day_row",true); } ! // setup hour select box for( $i=1; $i<=24; $i++) { *************** *** 558,562 **** 'TYPE' => 'select', 'SELECTED' => '', ! 'STORYHOUR' => $i )); if( $i == $story_time[0]) { --- 658,662 ---- 'TYPE' => 'select', 'SELECTED' => '', ! 'STORYHOUR' => $i )); if( $i == $story_time[0]) { *************** *** 571,575 **** 'TYPE' => 'select', 'SELECTED' => '', ! 'STORYMINUTE' => sprintf( "%02d", $i) )); if( $i == $story_time[1]) { --- 671,675 ---- 'TYPE' => 'select', 'SELECTED' => '', ! 'STORYMINUTE' => sprintf( "%02d", $i) )); if( $i == $story_time[1]) { *************** *** 593,599 **** $this->template->parse("datetimeset_rows","datetimeset_row",true); } ! ! $this->template = displayOptions('story', $this->template, "newstory", ''); ! if ($ary['content'] == "plain") { $this->template->set_var('PLAIN_CHKBOX',"CHECKED"); --- 693,700 ---- $this->template->parse("datetimeset_rows","datetimeset_row",true); } ! ! $options = displayOptions('story', $this->template, "newstory", ''); ! $this->template->set_var('OPTIONS', $options); ! if ($ary['content'] == "plain") { $this->template->set_var('PLAIN_CHKBOX',"CHECKED"); *************** *** 609,616 **** $this->template->set_var('EXTTRANS_CHKBOX',""); } - - $topic_ary = $ary['topic_id_ary']; - $section_ary = $ary['section_id_ary']; $user_id = $this->auth->auth['uid']; if ( $ary['author_id'] != "") { --- 710,722 ---- $this->template->set_var('EXTTRANS_CHKBOX',""); } + $topic_ary = array(); + if(array_key_exists('topic_id_ary', $ary)) { + $topic_ary = $ary['topic_id_ary']; + } + $section_ary = array(); + if(array_key_exists('section_id_ary', $ary)) { + $section_ary = $ary['section_id_ary']; + } $user_id = $this->auth->auth['uid']; if ( $ary['author_id'] != "") { *************** *** 619,628 **** } elseif ($data_source == "database") { /* this is a story from the DB */ ! /* ! * Get the topic_id's for this story into an array */ ! $q = "SELECT psl_topic.topic_id ! FROM psl_topic,psl_topic_lut ! WHERE psl_topic_lut.story_id = '$story_id' AND psl_topic.topic_id = psl_topic_lut.topic_id"; $this->db->query($q); --- 725,734 ---- } elseif ($data_source == "database") { /* this is a story from the DB */ ! /* ! * Get the topic_id's for this story into an array */ ! $q = "SELECT psl_topic.topic_id ! FROM psl_topic,psl_topic_lut ! WHERE psl_topic_lut.story_id = '$story_id' AND psl_topic.topic_id = psl_topic_lut.topic_id"; $this->db->query($q); *************** *** 633,643 **** $i++; } ! ! /* ! * Get the section_id's for this story into an array */ ! $q = "SELECT psl_section.section_id ! FROM psl_section,psl_section_lut ! WHERE psl_section_lut.story_id = '$story_id' AND psl_section.section_id = psl_section_lut.section_id"; $this->db->query($q); --- 739,749 ---- $i++; } ! ! /* ! * Get the section_id's for this story into an array */ ! $q = "SELECT psl_section.section_id ! FROM psl_section,psl_section_lut ! WHERE psl_section_lut.story_id = '$story_id' AND psl_section.section_id = psl_section_lut.section_id"; $this->db->query($q); *************** *** 652,656 **** $this->db->query("SELECT * from psl_story WHERE story_id = '$story_id'"); $this->db->next_record(); ! /* dates are now implemented as UNIX timestamps. This line pretends that the old field (a MySQL datetime) still exists. --- 758,762 ---- $this->db->query("SELECT * from psl_story WHERE story_id = '$story_id'"); $this->db->next_record(); ! /* dates are now implemented as UNIX timestamps. This line pretends that the old field (a MySQL datetime) still exists. *************** *** 696,700 **** 'STORYYEAR' => $i )); ! if( $i == $story_date[0]) { $this->template->set_var('SELECTED', "selected=\"selected\""); --- 802,806 ---- 'STORYYEAR' => $i )); ! if( $i == $story_date[0]) { $this->template->set_var('SELECTED', "selected=\"selected\""); *************** *** 702,706 **** $this->template->parse("year_rows","year_row",true); } ! // setup month select box for( $i=1; $i<=12; $i++) { --- 808,812 ---- $this->template->parse("year_rows","year_row",true); } ! // setup month select box for( $i=1; $i<=12; $i++) { *************** *** 728,732 **** $this->template->parse("day_rows","day_row",true); } ! // setup hour select box for( $i=1; $i<=24; $i++) { --- 834,838 ---- $this->template->parse("day_rows","day_row",true); } ! // setup hour select box for( $i=1; $i<=24; $i++) { *************** *** 772,777 **** } ! $temparray = unserialize($this->db->Record['story_options']); ! $this->template->set_var(array( 'ACTION_URL' => "storyAdmin.php", --- 878,886 ---- } ! $temparray = ''; ! if(array_key_exists('story_options', $this->db->Record)) { ! $temparray = unserialize($this->db->Record['story_options']); ! } ! $this->template->set_var(array( 'ACTION_URL' => "storyAdmin.php", *************** *** 783,788 **** $this->db->query("SELECT topic_id, ! topic_name ! FROM psl_topic ORDER BY topic_name"); while ($this->db->next_record()) { --- 892,897 ---- $this->db->query("SELECT topic_id, ! topic_name ! FROM psl_topic ORDER BY topic_name"); while ($this->db->next_record()) { *************** *** 807,829 **** $this->db->query("SELECT section_id, ! section_name ! FROM psl_section ORDER BY section_name"); while ($this->db->next_record()) { ! $this->template->set_var(array( ! 'SECTION_ID' => $this->db->Record['section_id'], ! 'SECTION_NAME' => $this->db->Record['section_name'] ! )); ! ! $this->template->set_var('SELECTED',""); ! for ($i = 0 ; $i < count($section_ary) ; $i++) { ! if ($section_ary[$i] == $this->db->Record['section_id']) { ! $this->template->set_var('SELECTED',"SELECTED"); ! } ! } ! $this->template->parse("section_rows","section_row",true); } - if (!$this->perm->have_perm("storylistothers")) { $this->template->set_var(array( --- 916,938 ---- $this->db->query("SELECT section_id, ! section_name ! FROM psl_section ORDER BY section_name"); while ($this->db->next_record()) { ! if (($this->perm->have_perm("storyNew && ". ALLSECTIONS)) || ($this->perm->have_perm("storyNew && section_id".$this->db->Record['section_id']))) { ! $this->template->set_var(array( ! 'SECTION_ID' => $this->db->Record['section_id'], ! 'SECTION_NAME' => $this->db->Record['section_name'] ! )); ! $this->template->set_var('SELECTED',""); ! for ($i = 0 ; $i < count($section_ary) ; $i++) { ! if ($section_ary[$i] == $this->db->Record['section_id']) { ! $this->template->set_var('SELECTED',"SELECTED"); ! } ! } ! $this->template->parse("section_rows","section_row",true); ! } } if (!$this->perm->have_perm("storylistothers")) { $this->template->set_var(array( *************** *** 832,838 **** )); ! # $this->template->set_var('AUTHOR_SELECTED',""); ! $this->template->set_var('AUTHOR_SELECTED',"SELECTED"); ! $this->template->parse("author_rows","author_row",true); } else { --- 941,947 ---- )); ! # $this->template->set_var('AUTHOR_SELECTED',""); ! $this->template->set_var('AUTHOR_SELECTED',"SELECTED"); ! $this->template->parse("author_rows","author_row",true); } else { *************** *** 846,851 **** while ($this->db->next_record()) { $this->template->set_var(array( ! AUTHOR_ID => $this->db->Record['author_id'], ! AUTHOR_NAME => $this->db->Record['author_name'] )); $this->template->set_var('AUTHOR_SELECTED',""); --- 955,960 ---- while ($this->db->next_record()) { $this->template->set_var(array( ! 'AUTHOR_ID' => $this->db->Record['author_id'], ! 'AUTHOR_NAME' => $this->db->Record['author_name'] )); $this->template->set_var('AUTHOR_SELECTED',""); *************** *** 853,863 **** $this->template->set_var('AUTHOR_SELECTED',"SELECTED"); } - - $this->template->parse("author_rows","author_row",true); - } ! $this->template = displayOptions('story', $this->template, "newstory", $temparray); - } $description = sprintf( "%s (%s) added new story %s as userid %s", $this->auth->auth['uname'], $this->auth->auth['uid'], $story_id, $user_id); logwrite("Story Admin", $description); --- 962,972 ---- $this->template->set_var('AUTHOR_SELECTED',"SELECTED"); } ! $this->template->parse("author_rows","author_row",true); ! } ! } ! $options = displayOptions('story', $this->template, "newstory", ''); ! $this->template->set_var('OPTIONS', $options); $description = sprintf( "%s (%s) added new story %s as userid %s", $this->auth->auth['uname'], $this->auth->auth['uid'], $story_id, $user_id); logwrite("Story Admin", $description); *************** *** 865,868 **** --- 974,988 ---- // $this->template->p('OUT'); // return true; + } + + /** + * getMessage - returns message text + * + * simply returns the contents of the message variable + * + * @access public + */ + function getMessage() { + return pslgetText($this->message); } Index: Story_base.class =================================================================== RCS file: /cvsroot/phpslash/phpslash-dev/include/modules/story/Story_base.class,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Story_base.class 12 Mar 2003 16:12:54 -0000 1.1.1.1 --- Story_base.class 21 Apr 2003 20:36:58 -0000 1.2 *************** *** 53,56 **** --- 53,59 ---- function extractStory($story_id, $mode) { + $topic_id_ary = array(); + $topic_name_ary = array(); + /* Sorry for the big long list, but it's so much easier to read! --ajay */ /* S'all right.. We like ex 2 read :) -n */ *************** *** 131,138 **** $count = 0; while ($this->db->next_record()) { - // $id = $this->db->Record["topic_id"]; - // $ancy = $this->db->Record["topic_name"]; - // echo "I'm in the loop ($count - $id - $ancy)<BR>\n"; - $topic_id_ary[$count] = $this->db->Record["topic_id"]; $topic_name_ary[$count] = $this->db->Record["topic_name"]; --- 134,137 ---- *************** *** 163,167 **** * start = "starting" point [0] * max = maximum returned [10] ! * order = [time], hits, title, etc. * asc = ASC, [DESC] ( Ascending or Descending) * query = urlencoded text string --- 162,166 ---- * start = "starting" point [0] * max = maximum returned [10] ! * order = [date_available], hits, title, etc. * asc = ASC, [DESC] ( Ascending or Descending) * query = urlencoded text string *************** *** 271,275 **** break; ! case "author_id": if( $argv_ary["author"] == "" ) { $q .= " AND psl_author.author_id = '$argv_ary[author_id]' "; --- 270,274 ---- break; ! case "author_id": if( $argv_ary["author"] == "" ) { $q .= " AND psl_author.author_id = '$argv_ary[author_id]' "; *************** *** 339,343 **** if (empty($argv_ary['order']) ) { ! $argv_ary['order'] = "date_available"; } if (empty($argv_ary['asc']) ) { --- 338,342 ---- if (empty($argv_ary['order']) ) { ! $argv_ary['order'] = "psl_story.order_no DESC, date_available"; } if (empty($argv_ary['asc']) ) { *************** *** 354,358 **** $q1 = $q; ! $q1 .= "ORDER BY psl_story.order_no DESC, $argv_ary[order] $argv_ary[asc] LIMIT $start, $argv_ary[chunk]"; // debug("Story::extractStories.argv_ary", $argv_ary); --- 353,357 ---- $q1 = $q; ! $q1 .= "ORDER BY $argv_ary[order] $argv_ary[asc] LIMIT $start, $argv_ary[chunk]"; // debug("Story::extractStories.argv_ary", $argv_ary); *************** *** 390,413 **** $count = 0; /* Put everything into an array and return array */ ! $stories_ary[$i]['story_id'] = stripslashes($this->db->Record["story_id"]); ! $stories_ary[$i]['title'] = stripslashes($this->db->Record["title"]); ! $stories_ary[$i]['intro_text'] = stripslashes($this->db->Record["intro_text"]); ! $stories_ary[$i]['body_text'] = stripslashes($this->db->Record["body_text"]); ! $stories_ary[$i]['order_no'] = stripslashes($this->db->Record["order_no"]); ! $stories_ary[$i]['dept'] = stripslashes($this->db->Record["dept"]); ! $stories_ary[$i]['url'] = $this->db->Record["url"]; ! // $stories_ary[$i]['name'] = $this->db->Record["author_name"]; ! $stories_ary[$i]['name'] = $this->db->Record["author_realname"]; ! // $stories_ary[$i]['datef'] = $this->db->Record["dateformat"]; ! $stories_ary[$i]['datef'] = psl_dateTimeLong($this->db->Record['timestamp']); ! $stories_ary[$i]['hits'] = $this->db->Record["hits"]; ! $stories_ary[$i]['topic_id'] = $this->db->Record["topic_id"]; ! $stories_ary[$i]['topic_name'] = $this->db->Record["topic_name"]; ! $stories_ary[$i]['image'] = $this->db->Record["image"]; ! $stories_ary[$i]['width'] = $this->db->Record["width"]; ! $stories_ary[$i]['height'] = $this->db->Record["height"]; ! $stories_ary[$i]['alt_text'] = $this->db->Record["alt_text"]; ! $stories_ary[$i]['cmtcount'] = $this->db->Record["cmtcount"]; ! $stories_ary[$i]['story_options'] = unserialize($this->db->Record["story_options"]); // debug("Story::extractStories.stories_ary", $stories_ary[$i]); } --- 389,416 ---- $count = 0; /* Put everything into an array and return array */ ! foreach($this->db->Record as $key => $value) { ! switch ($key) { ! ! case 'timestamp': ! $stories_ary[$i]['datef'] = psl_dateTimeLong($value); ! break; ! case 'story_options': ! $stories_ary[$i]['story_options'] = unserialize($value); ! break; ! case 'author_realname': ! $stories_ary[$i]['name'] = $value; ! break; ! case 'story_id': ! case 'title': ! case 'intro_text': ! case 'body_text': ! case 'order_no': ! case 'dept': ! $value = stripslashes($value); ! default: ! $stories_ary[$i][$key] = $value; ! break; ! } ! } // debug("Story::extractStories.stories_ary", $stories_ary[$i]); } *************** *** 466,474 **** $topic_id_ary = $ary['topic_id_ary']; ! $section_id_ary = $ary['section_id_ary']; ! ! // echo "TID_ARY[0] = $topic_id_ary[0]<BR>\n"; ! // echo "SID_ARY[0] = $section_id_ary[0]<BR>\n"; ! /* removed because if there's no ID then we insert, else we update... if ($ary['story_id'] == "") { --- 469,482 ---- $topic_id_ary = $ary['topic_id_ary']; ! ! // move the section id's from the array value to the array key ! if(is_array($ary['section_id_ary'])) { ! foreach($ary['section_id_ary'] as $value) { ! $section_id_ary[$value] = true; ! } ! } else { ! $section_id_ary = array(); ! } ! /* removed because if there's no ID then we insert, else we update... if ($ary['story_id'] == "") { *************** *** 481,485 **** return false; } ! if ($section_id_ary[0] == "") { $this->message = "You need to select at least one section in Story.class::saveStory"; return false; --- 489,493 ---- return false; } ! if (count($section_id_ary) < 1) { $this->message = "You need to select at least one section in Story.class::saveStory"; return false; *************** *** 515,523 **** // echo "<BR><BR>STORYID: $ary['story_id']<BR><BR>SID: $story_id<BR><BR>\n"; ! $optionname_ary = $ary[optionname]; ! $optionval_ary = $ary[optionval]; - for( $i=0 ; $i < count($ary[optionname]) ; $i++) { - if( $optionname_ary[$i] != "") { $optname = $optionname_ary[$i]; --- 523,532 ---- // echo "<BR><BR>STORYID: $ary['story_id']<BR><BR>SID: $story_id<BR><BR>\n"; ! $optionname_ary = $ary['optionname']; ! $optionval_ary = $ary['optionval']; ! ! $count = count($ary['optionname']); ! for( $i=0 ; $i < $count ; $i++) { if( $optionname_ary[$i] != "") { $optname = $optionname_ary[$i]; *************** *** 529,543 **** $serial_opts=addslashes(serialize($story_options_ary)); ! $this->db->query("SELECT story_id ! FROM psl_story WHERE story_id = '$ary[story_id]'"); if ($this->db->next_record()) { ! $q = "UPDATE psl_story ! SET user_id = '$ary[author_id]', title = '$ary[title]', date_available = $ary[timestamp], order_no = '$ary[order_no]', ! dept = '$ary[dept]', ! intro_text = '$ary[intro_text]', body_text = '$ary[body_text]', topic_cache = '', --- 538,552 ---- $serial_opts=addslashes(serialize($story_options_ary)); ! $this->db->query("SELECT story_id ! FROM psl_story WHERE story_id = '$ary[story_id]'"); if ($this->db->next_record()) { ! $q = "UPDATE psl_story ! SET user_id = '$ary[author_id]', title = '$ary[title]', date_available = $ary[timestamp], order_no = '$ary[order_no]', ! dept = '$ary[dept]', ! intro_text = '$ary[intro_text]', body_text = '$ary[body_text]', topic_cache = '', *************** *** 548,555 **** $this->db->query($q); ! $topic_del = "DELETE FROM psl_topic_lut ! WHERE story_id='$ary[story_id]'"; ! ! $section_del = "DELETE FROM psl_section_lut WHERE story_id='$ary[story_id]'"; --- 557,561 ---- $this->db->query($q); ! $topic_del = "DELETE FROM psl_topic_lut WHERE story_id='$ary[story_id]'"; *************** *** 557,563 **** $this->db->query($topic_del); - // echo "<H3>SECTION_DEL: $section_del</H3>\n"; - $this->db->query($section_del); } else { --- 563,575 ---- $this->db->query($topic_del); + // get current sections assigned to story + $section_q = "SELECT section_id + FROM psl_section_lut + WHERE story_id = '$ary[story_id]' "; + $this->db->query($section_q); + while($this->db->next_record()) { + $sections_current[$this->db->Record['section_id']] = true; + } } else { *************** *** 566,570 **** // echo "<B>STORY ID: $ary[story_id]</B><BR><BR>\n"; ! # set the formatting options for new submissions only if ($ary['content'] == "exttrans") { $ary['intro_text'] = htmlentities($ary['intro_text']); --- 578,582 ---- // echo "<B>STORY ID: $ary[story_id]</B><BR><BR>\n"; ! # set the formatting options for new submissions only if ($ary['content'] == "exttrans") { $ary['intro_text'] = htmlentities($ary['intro_text']); *************** *** 576,580 **** $ary['intro_text'] = ereg_replace("<br><br>","<br>",$ary['intro_text']); $ary['body_text'] = nl2br($ary[body_text]); ! $ary['body_text'] = ereg_replace("<br><br>","<br>",$ary['body_text']); } --- 588,592 ---- $ary['intro_text'] = ereg_replace("<br><br>","<br>",$ary['intro_text']); $ary['body_text'] = nl2br($ary[body_text]); ! $ary['body_text'] = ereg_replace("<br><br>","<br>",$ary['body_text']); } *************** *** 591,600 **** hits, topic_cache, ! story_options) VALUES ('$ary[story_id]', '$ary[author_id]', ! '$ary[title]', '$ary[order_no]', ! '$ary[dept]', '$ary[intro_text]', '$ary[body_text]', --- 603,612 ---- hits, topic_cache, ! story_options) VALUES ('$ary[story_id]', '$ary[author_id]', ! '$ary[title]', '$ary[order_no]', ! '$ary[dept]', '$ary[intro_text]', '$ary[body_text]', *************** *** 614,617 **** --- 626,632 ---- $this->db->query($cmtcount); + // no current sections for a new story + $sections_current = array(); + } *************** *** 629,643 **** } ! while ( list( $key, $val ) = each( $section_id_ary ) ) { ! $lut_id = generateID("psl_section_lut_seq"); ! $lut_insert = "INSERT INTO psl_section_lut ! (lut_id, ! section_id, ! story_id) ! VALUES ('$lut_id', ! '$val', ! '$ary[story_id]')"; ! // echo "<H3>LUT_INSERT: $lut_insert</H3>\n"; ! $this->db->query($lut_insert); } --- 644,683 ---- } ! // get available sections for this user ( not necessarily the story author) ! $sections_available = array(); ! $section_q = "SELECT section_id ! FROM psl_section "; ! $this->db->query($section_q); ! while ($this->db->next_record() ) { ! if ( ($this->perm->have_perm("storySave && ". ALLSECTIONS) ) || ! ($this->perm->have_perm("storySave && section_id".$this->db->Record['section_id']) ) ) { ! $sections_available[$this->db->Record['section_id']] = true; ! } ! } ! ! foreach( $sections_available as $key => $value) { ! // is section choice already assigned to this story? ! if( !empty($section_id_ary[$key]) && ! !empty($sections_current[$key]) ) { ! // do nothing (skip) ! } elseif (!empty($section_id_ary[$key]) ) { ! // section is chosen - so insert ! $lut_id = generateID("psl_section_lut_seq"); ! $lut_insert = "INSERT INTO psl_section_lut ! (lut_id, ! section_id, ! story_id) ! VALUES ('$lut_id', ! '$key', ! '$ary[story_id]')"; ! $this->db->query($lut_insert); ! } elseif (!empty($sections_current[$key]) ) { ! // section available but not chosen - so delete ! $lut_delete = "DELETE FROM psl_section_lut ! WHERE story_id = '$ary[story_id]' ! AND section_id = '$key' "; ! $this->db->query($lut_delete); ! } ! } *************** *** 649,653 **** // create topic object $topic = pslNew("Topic"); ! // use only the first topic in this array // most people choose one topic per story --- 689,693 ---- // create topic object $topic = pslNew("Topic"); ! // use only the first topic in this array // most people choose one topic per story *************** *** 656,665 **** } } // end if auto_renorm ! return true; } function cacheStory( $ary, $field="", $story_id="") { ! // debug( "Story.class::cacheStory::ary", $ary); // debug( "Story.class::cacheStory::field", $field); --- 696,711 ---- } } // end if auto_renorm ! $this->message .= sprintf(pslgetText("story(%s) saved: %s"), $ary['story_id'], $ary['title']); return true; } function cacheStory( $ary, $field="", $story_id="") { ! ! $cache = ''; ! $expired = ''; ! ! if(!array_key_exists('update', $ary[$field])) { ! $ary[$field]['update'] = 0; ! } // debug( "Story.class::cacheStory::ary", $ary); // debug( "Story.class::cacheStory::field", $field); *************** *** 682,686 **** while ($each_field = each($ary) ) { ! $field_name = $each_field[key]; /* if there are no "expire" fields greater than zero, then, we're not using the cache and so don't write to db --- 728,732 ---- while ($each_field = each($ary) ) { ! $field_name = $each_field['key']; /* if there are no "expire" fields greater than zero, then, we're not using the cache and so don't write to db *************** *** 705,709 **** } ! } // end of Story_base --- 751,755 ---- } ! } // end of Story_base |
From: Joe S. <joe...@us...> - 2003-04-21 20:37:03
|
Update of /cvsroot/phpslash/phpslash-dev/include/class In directory sc8-pr-cvs1:/tmp/cvs-serv4880/phpslash-dev/include/class Modified Files: slashTemplate.class Log Message: sync with -ft cvs. Index: slashTemplate.class =================================================================== RCS file: /cvsroot/phpslash/phpslash-dev/include/class/slashTemplate.class,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** slashTemplate.class 12 Mar 2003 16:12:50 -0000 1.1.1.1 --- slashTemplate.class 21 Apr 2003 20:36:57 -0000 1.2 *************** *** 88,92 **** // no parent skin // see if the defaults work ! if(!$this->set_file($varname, $filename, $this->psl['skin.default'], $this->psl['language.default'])) { // template isn't in the defaults either - bail out $this->message = "set_file: set_file: For varname $varname filename $filepath is invalid."; --- 88,92 ---- // no parent skin // see if the defaults work ! if(!$this->set_file($varname, $filename, $this->psl['defaultskin'], $this->psl['language.default'])) { // template isn't in the defaults either - bail out $this->message = "set_file: set_file: For varname $varname filename $filepath is invalid."; *************** *** 143,146 **** --- 143,167 ---- } return $filename; + } + + + /** + * is_available + * + * Check the contents of the template ($var) for the + * + * @access public + * @param string var + * @param string placeholder + **/ + function is_available($var, $placeholder) { + $status = false; + $str = ' '.$this->get_var($var); + if( strpos($str,"{".$placeholder."}") > 1) { + //found + $status = true; + } + + return $status; } |
From: Joe S. <joe...@us...> - 2003-04-21 20:37:03
|
Update of /cvsroot/phpslash/phpslash-dev In directory sc8-pr-cvs1:/tmp/cvs-serv4880/phpslash-dev Modified Files: CHANGES Log Message: sync with -ft cvs. Index: CHANGES =================================================================== RCS file: /cvsroot/phpslash/phpslash-dev/CHANGES,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** CHANGES 21 Apr 2003 20:15:08 -0000 1.9 --- CHANGES 21 Apr 2003 20:36:56 -0000 1.10 *************** *** 13,16 **** --- 13,21 ---- 9 - Removal of something (kill -9 :) + + 2003-April-21 3:00PM CST Joe Stewart <joe...@us...> + [W] - Story.class, Story_base.class, Story_admin.class, story/admin.php, + slashTemplate - sync with -ft. + 2003-April-21 2:00PM CST Joe Stewart <joe...@us...> [WT] - functions.inc, authorAdmin.php, Block_admin.class, authorNew.tpl, |
From: Joe S. <joe...@us...> - 2003-04-21 20:25:34
|
Update of /cvsroot/phpslash/phpslash-dev/include/modules/block In directory sc8-pr-cvs1:/tmp/cvs-serv25919/phpslash-dev/include/modules/block Modified Files: Block.class Log Message: sync with -ft cvs. Index: Block.class =================================================================== RCS file: /cvsroot/phpslash/phpslash-dev/include/modules/block/Block.class,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Block.class 21 Apr 2003 16:59:36 -0000 1.3 --- Block.class 21 Apr 2003 20:25:26 -0000 1.4 *************** *** 5,9 **** * Database Level access to the PHPSlash Block Engine. * ! * This object is how we retrieve block data from the database. It also * provides the db interface for block management. */ --- 5,9 ---- * Database Level access to the PHPSlash Block Engine. * ! * This object is how we retrieve block data from the database. It also * provides the db interface for block management. */ *************** *** 15,19 **** /** ! * Block - constructor for the Block class * * Atributes of the base block methods setup here --- 15,19 ---- /** ! * Block - constructor for the Block class * * Atributes of the base block methods setup here *************** *** 26,36 **** /* Constructor: Create sub-objects here, etc... */ global $_PSL, $perm; ! $this->db = pslNew("slashDB"); $this->db->Auto_Free = 1; ! $this->psl = $_PSL; $this->perm = &$perm; ! /* Array to store block info in */ $this->block_info = array(); --- 26,36 ---- /* Constructor: Create sub-objects here, etc... */ global $_PSL, $perm; ! $this->db = pslNew("slashDB"); $this->db->Auto_Free = 1; ! $this->psl = $_PSL; $this->perm = &$perm; ! /* Array to store block info in */ $this->block_info = array(); *************** *** 43,49 **** $this->parsedData = ""; } ! /** ! * reset - Resets object to empty values * * @access public --- 43,49 ---- $this->parsedData = ""; } ! /** ! * reset - Resets object to empty values * * @access public *************** *** 51,55 **** */ function reset() { ! unset($this->block_info); unset($this->parser); --- 51,55 ---- */ function reset() { ! unset($this->block_info); unset($this->parser); *************** *** 74,78 **** /** * putType - Stores a block Type ! * * @param string type * --- 74,78 ---- /** * putType - Stores a block Type ! * * @param string type * *************** *** 86,93 **** if ($this->db->affected_rows != 1) { $this->message = sprintf(pslgetText("Block Type: %s added with an id of: %s"), $type, $id); ! return true; } else { $this->message = sprintf(pslgetText("Error entering %s!"), $type); ! return false; } } --- 86,93 ---- if ($this->db->affected_rows != 1) { $this->message = sprintf(pslgetText("Block Type: %s added with an id of: %s"), $type, $id); ! return true; } else { $this->message = sprintf(pslgetText("Error entering %s!"), $type); ! return false; } } *************** *** 96,112 **** /* deleteType - deletes the type from the db * ! * Given the type_name, it deletes that from the psl_block_type table. ! * IT check and make sure there are NO blocks associated with this ! * block_type before deleting it. Returns true if block_type is deleted, * false if not. * * @param integer type_name * ! * @access public */ function deleteType($type_name) { $go_ahead = true; ! if (!$type_name) { return false; --- 96,112 ---- /* deleteType - deletes the type from the db * ! * Given the type_name, it deletes that from the psl_block_type table. ! * IT check and make sure there are NO blocks associated with this ! * block_type before deleting it. Returns true if block_type is deleted, * false if not. * * @param integer type_name * ! * @access public */ function deleteType($type_name) { $go_ahead = true; ! if (!$type_name) { return false; *************** *** 118,125 **** FROM psl_block, psl_block_type ! WHERE psl_block.type = psl_block_type.id AND psl_block_type.name = '$type_name'"; $this->db->query($q); ! while ($this->db->next_record()) { $go_ahead = false; $title = $this->db->Record["title"]; --- 118,125 ---- FROM psl_block, psl_block_type ! WHERE psl_block.type = psl_block_type.id AND psl_block_type.name = '$type_name'"; $this->db->query($q); ! while ($this->db->next_record()) { $go_ahead = false; $title = $this->db->Record["title"]; *************** *** 130,134 **** return false; } else { ! $q = "DELETE FROM psl_block_type WHERE name = '$type_name'"; --- 130,134 ---- return false; } else { ! $q = "DELETE FROM psl_block_type WHERE name = '$type_name'"; *************** *** 140,144 **** } ! /** * getBlock - returns a block from an id --- 140,144 ---- } ! /** * getBlock - returns a block from an id *************** *** 166,170 **** block_options FROM psl_block,psl_block_type ! WHERE psl_block.id='$id' AND psl_block.type = psl_block_type.id"; --- 166,170 ---- block_options FROM psl_block,psl_block_type ! WHERE psl_block.id='$id' AND psl_block.type = psl_block_type.id"; *************** *** 203,207 **** * putBlock - Puts the array into the db as a block * ! * @param array block_array * * @access public --- 203,207 ---- * putBlock - Puts the array into the db as a block * ! * @param array block_array * * @access public *************** *** 209,215 **** */ function putBlock($block_array) { ! if(is_array($block_array)) { ! $optionname_ary = $block_array['optionname']; $optionval_ary = $block_array['optionval']; --- 209,218 ---- */ function putBlock($block_array) { ! ! // db query error status ! $success = true; ! if(is_array($block_array)) { ! $optionname_ary = $block_array['optionname']; $optionval_ary = $block_array['optionval']; *************** *** 223,227 **** } ! $section_id_ary = $block_array['section_id_ary']; $serial_opts=addslashes(serialize($block_options_ary)); --- 226,239 ---- } ! // move the section id's from the array value to the array key ! if(array_key_exists('section_id_ary', $block_array) && ! is_array($block_array['section_id_ary'])) { ! foreach($block_array['section_id_ary'] as $value) { ! $section_id_ary[$value] = true; ! } ! } else { ! $section_id_ary = array(); ! } ! $serial_opts=addslashes(serialize($block_options_ary)); *************** *** 235,269 **** $this->message = sprintf(pslgetText("Updating Block %s. "), $block_array["block_id"]); - - $section_del = "DELETE FROM psl_section_block_lut - WHERE block_id='$block_array[block_id]'"; ! // echo "<H3>SECTION_DEL: $section_del</H3>\n"; ! $this->db->query($section_del); ! $timestamp = time(); ! $query = "UPDATE psl_block ! SET id = '$block_array[block_id]', ! type = '$block_array[block_type]', ! expire_length = '$block_array[expire_length]', ! date_issued = NULL, ! title = '$block_array[block_title]', ! location = '$block_array[location]', ! source_url = '$block_array[source_url]', ! cache_data = '$block_array[cache_data]', ! ordernum = '$block_array[ordernum]', ! block_options = '$serial_opts' ! WHERE id = '$block_array[block_id]'"; ! // debug("Block.class::putBlock::query", $query); $this->db->query($query); - } else { $this->message = pslgetText("Creating new block from submitted info."); ! $timestamp = time(); $block_array["block_id"] = generateID("psl_block_seq"); ! $query = "INSERT INTO psl_block (id, type, --- 247,289 ---- $this->message = sprintf(pslgetText("Updating Block %s. "), $block_array["block_id"]); ! $timestamp = time(); ! $query = "UPDATE psl_block ! SET id = '$block_array[block_id]', ! type = '$block_array[block_type]', ! expire_length = '$block_array[expire_length]', ! date_issued = NULL, ! title = '$block_array[block_title]', ! location = '$block_array[location]', ! source_url = '$block_array[source_url]', ! cache_data = '$block_array[cache_data]', ! ordernum = '$block_array[ordernum]', ! block_options = '$serial_opts' ! WHERE id = '$block_array[block_id]'"; ! // debug("Block.class::putBlock::query", $query); $this->db->query($query); + // should update one record successfully + if ($this->db->affected_rows() != "1") { + $success = false; + } + + // get current sections assigned to block + $section_q = "SELECT section_id + FROM psl_section_block_lut + WHERE block_id = '$block_array[block_id]' "; + $this->db->query($section_q); + while($this->db->next_record()) { + $sections_current[$this->db->Record['section_id']] = true; + } + } else { $this->message = pslgetText("Creating new block from submitted info."); ! $timestamp = time(); $block_array["block_id"] = generateID("psl_block_seq"); ! $query = "INSERT INTO psl_block (id, type, *************** *** 276,324 **** block_options) VALUES ('$block_array[block_id]', ! '$block_array[block_type]', ! '$block_array[expire_length]', ! '$block_array[block_title]', ! '$block_array[location]', ! '$block_array[source_url]', '$block_array[cache_data]', '$block_array[ordernum]', '$serial_opts') ! "; $this->message .= pslgetText("Adding the block to the db..."); $this->db->query($query); } ! ! if(is_array($section_id_ary) ) { ! while ( list( $key, $val ) = each( $section_id_ary ) ) { $lut_id = generateID("psl_section_block_lut_seq"); $lut_insert = "INSERT INTO psl_section_block_lut ! (lut_id, ! section_id, ! block_id) ! VALUES ('$lut_id', ! '$val', ! '$block_array[block_id]')"; ! # echo "<H3>LUT_INSERT: $lut_insert</H3>\n"; $this->db->query($lut_insert); ! } ! } else { ! $this->message .= sprintf(pslgetText("No section chosen. Block will not be displayed on site till a section is chosen for block: %s"), $block_array[block_title]); ! } $this->message .= pslgetText("Checking db..."); ! if ($this->db->affected_rows() == 1) { // $this->message .= "Here's a preview...<br>\n"; - # $testid = $block_array[block_id]; - # echo "<BR><BR><B>Before DoBlock!! -> $testid</B><BR><BR>\n"; logwrite("Block Addition", "Added block " . $block_array['block_id']); $this->message .= $this->doBlock($block_array["block_id"]); } else { $this->message .= pslgetText("Error adding block. Query returned multiple results."); ! return false; } } else { $this->message = pslgetText("Block::putBlock() received data not in an array."); ! return false; } return $this->message; --- 296,387 ---- block_options) VALUES ('$block_array[block_id]', ! '$block_array[block_type]', ! '$block_array[expire_length]', ! '$block_array[block_title]', ! '$block_array[location]', ! '$block_array[source_url]', '$block_array[cache_data]', '$block_array[ordernum]', '$serial_opts') ! "; $this->message .= pslgetText("Adding the block to the db..."); $this->db->query($query); + // should insert one record successfully + if ($this->db->affected_rows() != "1") { + $success = false; + } + + $sections_current = array(); } ! ! // get available sections for this user ( not necessarily the story author) ! $sections_available = array(); ! $section_q = "SELECT section_id ! FROM psl_section "; ! $this->db->query($section_q); ! while ($this->db->next_record() ) { ! if ( ($this->perm->have_perm("blockPut && ". ALLSECTIONS) ) || ! ($this->perm->have_perm("blockPut && section_id".$this->db->Record['section_id']) ) ) { ! $sections_available[$this->db->Record['section_id']] = true; ! } ! } ! ! foreach( $sections_available as $key => $value) { ! // is section choice already assigned to this story? ! if( !empty($section_id_ary[$key]) && ! !empty($sections_current[$key]) ) { ! // do nothing (skip) ! } elseif (!empty($section_id_ary[$key]) ) { ! // section is chosen - so insert $lut_id = generateID("psl_section_block_lut_seq"); $lut_insert = "INSERT INTO psl_section_block_lut ! (lut_id, ! section_id, ! block_id) ! VALUES ('$lut_id', ! '$key', ! '$block_array[block_id]')"; $this->db->query($lut_insert); ! ! // should insert one section lookup successfully ! if ($this->db->affected_rows() != "1") { ! $success = false; ! } ! } elseif (!empty($sections_current[$key]) ) { ! // section available but not chosen - so delete ! $lut_delete = "DELETE FROM psl_section_block_lut ! WHERE block_id = '$block_array[block_id]' ! AND section_id = '$key' "; ! $this->db->query($lut_delete); ! ! // should delete one section lookup successfully ! if ($this->db->affected_rows() != "1") { ! $success = false; ! } ! } ! ! } ! ! // if the block isn't assigned to any sections ! if( (count($section_id_ary) <1) && ! (count($sections_current) < 1) ){ ! $this->message .= sprintf(pslgetText("No section chosen. Block will not be displayed on site till a section is chosen for block: %s"), $block_array['block_title']); ! } $this->message .= pslgetText("Checking db..."); ! ! // check if the above db actions were successful ! if ($success == true) { // $this->message .= "Here's a preview...<br>\n"; logwrite("Block Addition", "Added block " . $block_array['block_id']); $this->message .= $this->doBlock($block_array["block_id"]); } else { $this->message .= pslgetText("Error adding block. Query returned multiple results."); ! return false; } } else { $this->message = pslgetText("Block::putBlock() received data not in an array."); ! return false; } return $this->message; *************** *** 326,333 **** /** ! * checkTime - Check the refresh time and return true ! * if the stored data is ok * ! * @access private * */ --- 389,396 ---- /** ! * checkTime - Check the refresh time and return true ! * if the stored data is ok * ! * @access private * */ *************** *** 363,368 **** $width = "100%"; ! ! if ($id != $this->block_info["id"]) { # echo "<B>before GetBlock</B><BR>\n"; $this->getBlock($id); --- 426,433 ---- $width = "100%"; ! $box_type = ''; ! ! if (!array_key_exists('id', $this->block_info) || ! ($id != $this->block_info['id']) ) { # echo "<B>before GetBlock</B><BR>\n"; $this->getBlock($id); *************** *** 397,404 **** } if (is_array($this->block_info["block_options"])) { ! if (is_string($this->block_info["block_options"]["width"])) { $width = $this->block_info["block_options"]["width"]; } ! if (is_string($this->block_info["block_options"]["box_type"])) { $box_type = $this->block_info["block_options"]["box_type"]; } --- 462,469 ---- } if (is_array($this->block_info["block_options"])) { ! if (array_key_exists('width', $this->block_info['block_options'])) { $width = $this->block_info["block_options"]["width"]; } ! if (array_key_exists('box_type', $this->block_info['block_options'])) { $box_type = $this->block_info["block_options"]["box_type"]; } *************** *** 456,460 **** $this->parsedData = $this->parser->getFinal(); // only write to the db if the data is changed ! if($this->block_info["cache_data"] != $this->parsedData) { // debug($this->block_info["title"], "updated"); $this->block_info["cache_data"] = $this->parsedData; --- 521,525 ---- $this->parsedData = $this->parser->getFinal(); // only write to the db if the data is changed ! if($this->block_info["cache_data"] != $this->parsedData) { // debug($this->block_info["title"], "updated"); $this->block_info["cache_data"] = $this->parsedData; *************** *** 515,522 **** /** * delBlock - delete a Block ! * * @param integer id * ! * @access private * * return boolean success --- 580,587 ---- /** * delBlock - delete a Block ! * * @param integer id * ! * @access private * * return boolean success *************** *** 526,551 **** if (!$id) { return false; ! }; ! $block_del = "DELETE FROM psl_block WHERE id = '$id'"; ! $section_lut_del = "DELETE FROM psl_section_block_lut WHERE block_id = '$id'"; ! // echo "DELBLOCK: $block_del<BR><BR>SECTION: $section_lut_del<BR><BR>\n"; ! if (!$this->db->query($block_del)) { ! return false; ! } ! if (!$this->db->query($section_lut_del)) { ! return false; ! } ! logwrite("Block Admin", "Deleted block $id"); return true; } ! /** * returns an array of blocks * * @param array ary ! * * ary currently accepts: * --- 591,657 ---- if (!$id) { return false; ! } ! if ($this->perm->have_perm("blockDelete && ". ALLSECTIONS)) { ! // debug("ALLSECTIONS-perms", $this->auth->auth['perm']); ! // all permisssions - so go ahead and delete block ! $section_lut_del = "DELETE FROM psl_section_block_lut WHERE block_id = '$id'"; ! if (!$this->db->query($section_lut_del)) { ! return false; ! } ! $block_del = "DELETE FROM psl_block WHERE id = '$id'"; ! if (!$this->db->query($block_del)) { ! return false; ! } ! logwrite("Block Admin", "Deleted block $id"); ! } else { ! // permissions only to certain sections - so delete only that portion ! // get current sections assigned to block ! $section_q = "SELECT section_id ! FROM psl_section_block_lut ! WHERE block_id = '$id' "; ! // debug("section_q", $section_q); ! $this->db->query($section_q); ! $ok = true; // start with allowing block to be deleted ! while($this->db->next_record()) { ! if ($this->perm->have_perm("blockDelete && section_id".$this->db->Record['section_id'])){ ! $section_id =$this->db->Record['section_id']; ! // debug("section_id", $section_id); ! // only delete for the section that the user has permission ! $db2 = pslNew("slashDB"); //create another db object ! $section_lut_del = "DELETE FROM psl_section_block_lut ! WHERE block_id = '$id' ! AND section_id = '$section_id' "; ! // debug("section_lut_del", $section_lut_del); ! if (!$db2->query($section_lut_del)) { ! // debug("query", "failed"); ! return false; ! } ! } else { ! // don't have permission to this section - so don't allow block to be deleted ! $ok = false; ! } ! } //endwhile ! // if allowed - delete block ! if($ok) { ! $block_del = "DELETE FROM psl_block WHERE id = '$id'"; ! if (!$this->db->query($block_del)) { ! return false; ! } ! logwrite("Block Admin", "Deleted block $id"); ! } ! } // endif ! ! // success return true; } ! /** * returns an array of blocks * * @param array ary ! * * ary currently accepts: * |
From: Joe S. <joe...@us...> - 2003-04-21 20:18:59
|
Update of /cvsroot/phpslash/phpslash-dev/include/templates/en/default In directory sc8-pr-cvs1:/tmp/cvs-serv19276/phpslash-dev/include/templates/en/default Modified Files: authorNew.tpl sectionNew.tpl storyNew.tpl Log Message: sync with -ft cvs. Index: authorNew.tpl =================================================================== RCS file: /cvsroot/phpslash/phpslash-dev/include/templates/en/default/authorNew.tpl,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** authorNew.tpl 12 Mar 2003 16:12:53 -0000 1.1.1.1 --- authorNew.tpl 21 Apr 2003 20:18:51 -0000 1.2 *************** *** 31,43 **** <TD><INPUT type="password" name="password" value="{PASSWORD}" SIZE="10"></TD> </TR> ! <!-- BEGIN each_default_option --> ! <TR> ! <TD> ! <INPUT TYPE=hidden name={DOPTION_NAME} value="{DOPTION_NAME_VAL}"><B>{DOPTION_NAME_VAL}</B></TD> ! <TD> ! <INPUT TYPE=text name={DOPTION_VALUE} value="{DOPTION_VALUE_VAL}" size=20> </TD> ! </TR> ! <!-- END each_default_option --> ! <!-- BEGIN each_option --> <TR> <TD> --- 31,35 ---- <TD><INPUT type="password" name="password" value="{PASSWORD}" SIZE="10"></TD> </TR> ! {OPTIONS} <TR> <TD> Index: sectionNew.tpl =================================================================== RCS file: /cvsroot/phpslash/phpslash-dev/include/templates/en/default/sectionNew.tpl,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** sectionNew.tpl 12 Mar 2003 16:12:53 -0000 1.1.1.1 --- sectionNew.tpl 21 Apr 2003 20:18:51 -0000 1.2 *************** *** 15,36 **** </TD> </TR> ! <!-- BEGIN each_default_option --> ! <TR> ! <TD> ! <INPUT TYPE=hidden name={DOPTION_NAME} value="{DOPTION_NAME_VAL}"><B>{DOPTION_NAME_VAL}</B></TD> ! <TD> ! <INPUT TYPE=text name={DOPTION_VALUE} value="{DOPTION_VALUE_VAL}" size=20> </TD> ! </TR> ! <!-- END each_default_option --> ! <!-- BEGIN each_option --> ! <TR> ! <TD> ! <INPUT TYPE=text name={OPTION_NAME} value="{OPTION_NAME_VAL}" size=20> ! </TD> ! <TD> ! <INPUT TYPE=text name={OPTION_VALUE} value="{OPTION_VALUE_VAL}" size=20> ! </TD> ! </TR> ! <!-- END each_option --> <TR> <TD> </TD> --- 15,19 ---- </TD> </TR> ! {OPTIONS} <TR> <TD> </TD> Index: storyNew.tpl =================================================================== RCS file: /cvsroot/phpslash/phpslash-dev/include/templates/en/default/storyNew.tpl,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** storyNew.tpl 12 Mar 2003 16:12:53 -0000 1.1.1.1 --- storyNew.tpl 21 Apr 2003 20:18:52 -0000 1.2 *************** *** 114,138 **** <input type=radio {EXTTRANS_CHKBOX} name=content value="exttrans"> Extended Translation</TD> </TR> ! ! <!-- BEGIN each_default_option --> ! <TR> ! <TD> ! <INPUT TYPE=hidden name={DOPTION_NAME} value="{DOPTION_NAME_VAL}">{DOPTION_NAME_VAL}</TD> ! <TD> ! <INPUT TYPE=text name={DOPTION_VALUE} value="{DOPTION_VALUE_VAL}" size=20> </TD> ! </TR> ! <!-- END each_default_option --> ! ! <!-- BEGIN each_option --> ! <TR> ! <TD> ! <INPUT TYPE=text name={OPTION_NAME} value="{OPTION_NAME_VAL}" size=20> ! </TD> ! <TD> ! <INPUT TYPE=text name={OPTION_VALUE} value="{OPTION_VALUE_VAL}" size=20> ! </TD> ! </TR> ! <!-- END each_option --> ! <TR> <TD> </TD> --- 114,118 ---- <input type=radio {EXTTRANS_CHKBOX} name=content value="exttrans"> Extended Translation</TD> </TR> ! {OPTIONS} <TR> <TD> </TD> |
From: Joe S. <joe...@us...> - 2003-04-21 20:15:44
|
Update of /cvsroot/phpslash/phpslash-dev/public_html In directory sc8-pr-cvs1:/tmp/cvs-serv15258/phpslash-dev/public_html Modified Files: config-dist.php Log Message: sync with -ft cvs. Index: config-dist.php =================================================================== RCS file: /cvsroot/phpslash/phpslash-dev/public_html/config-dist.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** config-dist.php 18 Apr 2003 16:46:00 -0000 1.2 --- config-dist.php 21 Apr 2003 20:15:10 -0000 1.3 *************** *** 74,78 **** $_PSL = parse_ini_file($psl_inifile, TRUE); ! $_PSL['version'] = '0.7'; /**** START DEBUGGING - Comment or delete this for production! ****/ --- 74,78 ---- $_PSL = parse_ini_file($psl_inifile, TRUE); ! $_PSL['version'] = '0.7.1'; /**** START DEBUGGING - Comment or delete this for production! ****/ *************** *** 158,171 **** // should be prepended to all phpSlash pages // comment to enable setting lang in url ! $lang = false; ! $_PSL['languagefile'] = $_PSL['localedir'] . "/" . $_PSL['language'] . ".php"; // comment to disable auto lang detection ! $_PSL['languagefile'] = setLang($lang); // comment to disable auto tpl lang detection ! $_PSL['templatedir'] = setLangTpl($lang); // comment out this block to disable setting theme in url --- 158,178 ---- // should be prepended to all phpSlash pages + // set config language as default + $_PSL['language.default'] = $_PSL['language']; + + if(!empty($HTTP_GET_VARS['lang'])) { + $_PSL['language.choice'] = $HTTP_GET_VARS['lang']; + } + // comment to enable setting lang in url ! $_PSL['language.choice'] = false; ! $_PSL['languagefile'] = $_PSL['localedir'] . "/" . basename($_PSL['language']) .".php3"; // comment to disable auto lang detection ! $_PSL['languagefile'] = setLang($_PSL['language.choice']); // comment to disable auto tpl lang detection ! $_PSL['templatedir'] = setLangTpl($_PSL['language.choice']); // comment out this block to disable setting theme in url *************** *** 303,310 **** // collection is executed. Please check // first if this works on your mySQL! ! // Standard jpcache functions // require $_PSL['jpcachedir']. "/jpcache-main.php"; addLibraryRequirement("jpcache",$_PSL['jpcachedir'] . "/jpcache-main.php"); // Type specific jpcache implementations if ('phplib' == $JPCACHE_TYPE) { --- 310,318 ---- // collection is executed. Please check // first if this works on your mySQL! ! $JPCACHE_VERSION = "2.0.0rc1"; // Standard jpcache functions // require $_PSL['jpcachedir']. "/jpcache-main.php"; addLibraryRequirement("jpcache",$_PSL['jpcachedir'] . "/jpcache-main.php"); + // Type specific jpcache implementations if ('phplib' == $JPCACHE_TYPE) { *************** *** 636,640 **** */ // to enable setting of time zone in URL ! set_TZ($HTTP_GET_VARS['TZ'],'cookie'); // to disable setting in URL and to set $_PSL['timezone']['name'] as the time zone // set_TZ(); --- 644,652 ---- */ // to enable setting of time zone in URL ! if(!empty($HTTP_GET_VARS['TZ'])) { ! set_TZ($HTTP_GET_VARS['TZ'],'cookie'); ! } else { ! set_TZ('','cookie'); ! } // to disable setting in URL and to set $_PSL['timezone']['name'] as the time zone // set_TZ(); *************** *** 647,662 **** * default options legend: * ! * name - option name. This option will always be available to the admin. * value - option value. This value will be displayed for the option. The * admin can assign a new value. ! * * To add default option items, add a complete entry below. */ $default_block_options[] = array( 'name' => "column", ! 'value' => "" ); $_PSL['default_block_options'] = $default_block_options; /* ============= Things to deprecate ============= */ --- 659,722 ---- * default options legend: * ! * name - option name. This option will always be available to the admin. ! * description - optional text explanation. * value - option value. This value will be displayed for the option. The * admin can assign a new value. ! * type - type of form input - text, radio, or select. ! * choices - for radio or select form entry, defines * To add default option items, add a complete entry below. */ $default_block_options[] = array( 'name' => "column", ! 'description' => " - main content column is named center", ! 'value' => "right", ! 'type' => "radio", ! 'choices' => array('left' => 'left', ! 'right' => 'right', ! 'center' => 'center')); ! ! $default_block_options[] = array( ! 'name' => "width", ! 'description' => "", ! 'value' => "", ! 'type' => "select", ! 'choices' => array('' => 'Default(100%)', ! '160' => '160', ! '210' => '210', ! '100%' => '100%') ! ); ! /* ! $default_block_options[] = array( ! 'name' => "box_type", ! 'description' => "", ! 'value' => "", ! 'type' => "select", ! 'choices' => array('' => 'Default(fancy)', ! 'open' => 'Open', ! 'framed' => 'Framed', ! 'bordered' => 'Bordered') ); + */ $_PSL['default_block_options'] = $default_block_options; + + /* + $default_story_options[] = array( + 'name' => "storyimage", + 'description' => '', + 'value' => "/images/layout/blank.gif", + 'type' => 'text' + ); + + $_PSL['default_story_options'] = $default_story_options; + */ + + $default_author_options[] = array( + 'name' => "ICQ", + 'description' => '', + 'value' => "", + 'type' => 'text_defaultonly' + ); + $_PSL['default_author_options'] = $default_author_options; /* ============= Things to deprecate ============= */ |
From: Joe S. <joe...@us...> - 2003-04-21 20:15:44
|
Update of /cvsroot/phpslash/phpslash-dev In directory sc8-pr-cvs1:/tmp/cvs-serv15258/phpslash-dev Modified Files: CHANGES Log Message: sync with -ft cvs. Index: CHANGES =================================================================== RCS file: /cvsroot/phpslash/phpslash-dev/CHANGES,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** CHANGES 21 Apr 2003 17:00:21 -0000 1.8 --- CHANGES 21 Apr 2003 20:15:08 -0000 1.9 *************** *** 13,16 **** --- 13,25 ---- 9 - Removal of something (kill -9 :) + 2003-April-21 2:00PM CST Joe Stewart <joe...@us...> + [WT] - functions.inc, authorAdmin.php, Block_admin.class, authorNew.tpl, + blockEdit.tpl, storyNew.tpl, optionTypes.tpl, config-dist.php - + sync with -ft cvs. + + 2003-April-21 2:00PM CST Joe Stewart <joe...@us...> + [W] - slashAuthCR.class - clean up code comments. + Author.class - sync with -ft cvs. + 2003-April-21 10:00AM CST Joe Stewart <joe...@us...> [F] - Block.class - new block option - "cache_disabled". When this is set |
From: Joe S. <joe...@us...> - 2003-04-21 20:15:19
|
Update of /cvsroot/phpslash/phpslash-dev/include/templates/en/default In directory sc8-pr-cvs1:/tmp/cvs-serv15258/phpslash-dev/include/templates/en/default Added Files: optionTypes.tpl Log Message: sync with -ft cvs. --- NEW FILE: optionTypes.tpl --- <!-- optionTypes.tpl --> <!-- BEGIN type_text --> <!-- text field begin --> <!-- BEGIN each_default_option --> <tr> <td><input type="hidden" name="{DOPTION_NAME}" value="{DOPTION_NAME_VAL}" size="15" />{DOPTION_NAME_VAL}</td> <td><input type="text" name="{DOPTION_VALUE}" value="{DOPTION_VALUE_VAL}" size="20" /></td> </tr> <!-- END each_default_option --> <!-- BEGIN each_option --> <tr> <td><input type="text" name="{OPTION_NAME}" value="{OPTION_NAME_VAL}" size="15" /></td> <td><input type="text" name="{OPTION_VALUE}" value="{OPTION_VALUE_VAL}" size="20" /></td> </tr> <!-- END each_option --> <!-- text field end --> <!-- END type_text --> <!-- BEGIN type_radio --> <!-- radio begin --> <!-- BEGIN each_default_option --> <tr> <td><b>{DOPTION_NAME_VAL}</b><i>{DOPTION_DESCRIPTION}</i></td> <td> <input type="hidden" name="{DOPTION_NAME}" value="{DOPTION_NAME_VAL}" /> <!-- BEGIN each_default_choice --> <!-- BEGIN each_default_selected --> <input type="radio" checked=CHECKED name="{DOPTION_VALUE}" value="{DOPTION_VALUE_VAL}" />{DOPTION_VALUE_LABEL}<br /> <!-- END each_default_selected --> <!-- BEGIN each_default_notselected --> <input type="radio" name="{DOPTION_VALUE}" value="{DOPTION_VALUE_VAL}" />{DOPTION_VALUE_LABEL}<br /> <!-- END each_default_notselected --> <!-- END each_default_choice --> </td> </tr> <tr> <td colspan="2"> <br /> </td> </tr> <!-- END each_default_option --> <!-- BEGIN each_option --> <tr> <td><input type="text" name="{OPTION_NAME}" value="{OPTION_NAME_VAL}" size="15" /></td> <td><input type="text" name="{OPTION_VALUE}" value="{OPTION_VALUE_VAL}" size="20" /></td> </tr> <!-- END each_option --> <!-- radio end --> <!-- END type_radio --> <!-- BEGIN type_select --> <!-- select begin --> <!-- BEGIN each_default_option --> <tr> <td><b>{DOPTION_NAME_VAL}</b> <i>{DOPTION_DESCRIPTION}</i></td> <td> <input type="hidden" name="{DOPTION_NAME}" value="{DOPTION_NAME_VAL}" /> <select name="{DOPTION_VALUE}"> <!-- BEGIN each_default_choice --> <!-- BEGIN each_default_selected --> <option value="{DOPTION_VALUE_VAL}" selected=SELECTED>{DOPTION_VALUE_LABEL}</option> <!-- END each_default_selected --> <!-- BEGIN each_default_notselected --> <option value="{DOPTION_VALUE_VAL}">{DOPTION_VALUE_LABEL}</option> <!-- END each_default_notselected --> <!-- END each_default_choice --> </select> </td> </tr> <tr> <td colspan="2"> <br /> </td> </tr> <!-- END each_default_option --> <!-- BEGIN each_option --> <tr> <td><input type="text" name="{OPTION_NAME}" value="{OPTION_NAME_VAL}" size="15" /></td> <td><input type="text" name="{OPTION_VALUE}" value="{OPTION_VALUE_VAL}" size="20" /></td> </tr> <!-- END each_option --> <!-- select end --> <!-- END type_select --> <!-- optionTypes.tpl --> |
From: Joe S. <joe...@us...> - 2003-04-21 20:15:18
|
Update of /cvsroot/phpslash/phpslash-dev/include/templates/en/basic In directory sc8-pr-cvs1:/tmp/cvs-serv15258/phpslash-dev/include/templates/en/basic Modified Files: authorNew.tpl blockEdit.tpl sectionNew.tpl storyNew.tpl Added Files: optionTypes.tpl Log Message: sync with -ft cvs. --- NEW FILE: optionTypes.tpl --- <!-- optionTypes.tpl --> <!-- BEGIN type_text --> <!-- text field begin --> <!-- BEGIN each_default_option --> <tr> <td class="descr"><input type="hidden" name="{DOPTION_NAME}" value="{DOPTION_NAME_VAL}" size="15" />{DOPTION_NAME_VAL}</td> <td class="descr"><input type="text" name="{DOPTION_VALUE}" value="{DOPTION_VALUE_VAL}" size="20" /></td> </tr> <!-- END each_default_option --> <!-- BEGIN each_option --> <tr> <td class="descr"><input type="text" name="{OPTION_NAME}" value="{OPTION_NAME_VAL}" size="15" /></td> <td class="descr"><input type="text" name="{OPTION_VALUE}" value="{OPTION_VALUE_VAL}" size="20" /></td> </tr> <!-- END each_option --> <!-- text field end --> <!-- END type_text --> <!-- BEGIN type_radio --> <!-- radio begin --> <!-- BEGIN each_default_option --> <tr> <td class="descr"><b>{DOPTION_NAME_VAL}</b> <i>{DOPTION_DESCRIPTION}</i></td> <td> <input type="hidden" name="{DOPTION_NAME}" value="{DOPTION_NAME_VAL}" /> <!-- BEGIN each_default_choice --> <!-- BEGIN each_default_selected --> <input type="radio" checked=CHECKED name="{DOPTION_VALUE}" value="{DOPTION_VALUE_VAL}" />{DOPTION_VALUE_LABEL}<br /> <!-- END each_default_selected --> <!-- BEGIN each_default_notselected --> <input type="radio" name="{DOPTION_VALUE}" value="{DOPTION_VALUE_VAL}" />{DOPTION_VALUE_LABEL}<br /> <!-- END each_default_notselected --> <!-- END each_default_choice --> </td> </tr> <tr> <td colspan="2"> <br /> </td> </tr> <!-- END each_default_option --> <!-- BEGIN each_option --> <tr> <td class="descr"><input type="text" name="{OPTION_NAME}" value="{OPTION_NAME_VAL}" size="15" /></td> <td class="descr"><input type="text" name="{OPTION_VALUE}" value="{OPTION_VALUE_VAL}" size="20" /></td> </tr> <!-- END each_option --> <!-- radio end --> <!-- END type_radio --> <!-- BEGIN type_select --> <!-- select begin --> <!-- BEGIN each_default_option --> <tr> <td class="descr"><b>{DOPTION_NAME_VAL}</b> <i>{DOPTION_DESCRIPTION}</i></td> <td> <input type="hidden" name="{DOPTION_NAME}" value="{DOPTION_NAME_VAL}" /> <select name="{DOPTION_VALUE}"> <!-- BEGIN each_default_choice --> <!-- BEGIN each_default_selected --> <option value="{DOPTION_VALUE_VAL}" selected=SELECTED>{DOPTION_VALUE_LABEL}</option> <!-- END each_default_selected --> <!-- BEGIN each_default_notselected --> <option value="{DOPTION_VALUE_VAL}">{DOPTION_VALUE_LABEL}</option> <!-- END each_default_notselected --> <!-- END each_default_choice --> </select> </td> </tr> <tr> <td colspan="2"> <br /> </td> </tr> <!-- END each_default_option --> <!-- BEGIN each_option --> <tr> <td class="descr"><input type="text" name="{OPTION_NAME}" value="{OPTION_NAME_VAL}" size="15" /></td> <td class="descr"><input type="text" name="{OPTION_VALUE}" value="{OPTION_VALUE_VAL}" size="20" /></td> </tr> <!-- END each_option --> <!-- select end --> <!-- END type_select --> <!-- optionTypes.tpl --> Index: authorNew.tpl =================================================================== RCS file: /cvsroot/phpslash/phpslash-dev/include/templates/en/basic/authorNew.tpl,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** authorNew.tpl 12 Mar 2003 16:12:52 -0000 1.1.1.1 --- authorNew.tpl 21 Apr 2003 20:15:10 -0000 1.2 *************** *** 32,47 **** <td><input type="password" name="password" value="{PASSWORD}" size="10" /></td> </tr> ! <!-- BEGIN each_default_option --> ! <tr> ! <td class="descr"><input type="hidden" name="{DOPTION_NAME}" value="{DOPTION_NAME_VAL}" size="15" />{DOPTION_NAME_VAL}</td> ! <td class="text"><input type="text" name="{DOPTION_VALUE}" value="{DOPTION_VALUE_VAL}" size="20" /></td> ! </tr> ! <!-- END each_default_option --> ! <!-- BEGIN each_option --> ! <tr> ! <td class="descr"><input type="text" name="{OPTION_NAME}" value="{OPTION_NAME_VAL}" size="15" /></td> ! <td class="descr"><input type="text" name="{OPTION_VALUE}" value="{OPTION_VALUE_VAL}" size="20" /></td> ! </tr> ! <!-- END each_option --> <tr> <td class="descr">Security <span class="must">*</span></td> --- 32,36 ---- <td><input type="password" name="password" value="{PASSWORD}" size="10" /></td> </tr> ! {OPTIONS} <tr> <td class="descr">Security <span class="must">*</span></td> Index: blockEdit.tpl =================================================================== RCS file: /cvsroot/phpslash/phpslash-dev/include/templates/en/basic/blockEdit.tpl,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** blockEdit.tpl 12 Mar 2003 16:12:52 -0000 1.1.1.1 --- blockEdit.tpl 21 Apr 2003 20:15:10 -0000 1.2 *************** *** 73,92 **** <td class="descr">Variable Value</td> </tr> ! <!-- BEGIN each_default_option --> ! <tr> ! <td class="descr"><input type="hidden" name="{DOPTION_NAME}" value="{DOPTION_NAME_VAL}" size="15" />{DOPTION_NAME_VAL}</td> ! <td class="text"><input type="text" name="{DOPTION_VALUE}" value="{DOPTION_VALUE_VAL}" size="20" /></td> ! </tr> ! <!-- END each_default_option --> ! <!-- BEGIN each_option --> ! <tr> ! <td> ! <input type="text" name="{OPTION_NAME}" value="{OPTION_NAME_VAL}" size="20" /> ! </td> ! <td> ! <input type="text" name="{OPTION_VALUE}" value="{OPTION_VALUE_VAL}" size="20" /> ! </td> ! </tr> ! <!-- END each_option --> <tr> <td> </td> --- 73,77 ---- <td class="descr">Variable Value</td> </tr> ! {OPTIONS} <tr> <td> </td> Index: sectionNew.tpl =================================================================== RCS file: /cvsroot/phpslash/phpslash-dev/include/templates/en/basic/sectionNew.tpl,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** sectionNew.tpl 12 Mar 2003 16:12:52 -0000 1.1.1.1 --- sectionNew.tpl 21 Apr 2003 20:15:11 -0000 1.2 *************** *** 15,30 **** </td> </tr> ! <!-- BEGIN each_default_option --> ! <tr> ! <td class="descr"><input type="hidden" name="{DOPTION_NAME}" value="{DOPTION_NAME_VAL}" size="15" />{DOPTION_NAME_VAL}</td> ! <td class="text"><input type="text" name="{DOPTION_VALUE}" value="{DOPTION_VALUE_VAL}" size="20" /></td> ! </tr> ! <!-- END each_default_option --> ! <!-- BEGIN each_option --> ! <tr> ! <td class="descr"><input type="text" name="{OPTION_NAME}" value="{OPTION_NAME_VAL}" size="15" /></td> ! <td class="descr"><input type="text" name="{OPTION_VALUE}" value="{OPTION_VALUE_VAL}" size="20" /></td> ! <!-- END each_option --> ! <tr> <td> </td> --- 15,19 ---- </td> </tr> ! {OPTIONS} <tr> <td> </td> Index: storyNew.tpl =================================================================== RCS file: /cvsroot/phpslash/phpslash-dev/include/templates/en/basic/storyNew.tpl,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** storyNew.tpl 12 Mar 2003 16:12:53 -0000 1.1.1.1 --- storyNew.tpl 21 Apr 2003 20:15:11 -0000 1.2 *************** *** 112,127 **** </td> </tr> ! <!-- BEGIN each_default_option --> ! <tr> ! <td class="descr"><input type="hidden" name="{DOPTION_NAME}" value="{DOPTION_NAME_VAL}" size="15" />{DOPTION_NAME_VAL}</td> ! <td class="descr"><input type="text" name="{DOPTION_VALUE}" value="{DOPTION_VALUE_VAL}" size="20" /></td> ! </tr> ! <!-- END each_default_option --> ! <!-- BEGIN each_option --> ! <tr> ! <td class="descr"><input type="text" name="{OPTION_NAME}" value="{OPTION_NAME_VAL}" size="15" /></td> ! <td class="descr"><input type="text" name="{OPTION_VALUE}" value="{OPTION_VALUE_VAL}" size="20" /></td> ! <!-- END each_option --> ! <tr> <td> </td> --- 112,116 ---- </td> </tr> ! {OPTIONS} <tr> <td> </td> |
From: Joe S. <joe...@us...> - 2003-04-21 19:28:53
|
Update of /cvsroot/phpslash/phpslash-dev/include/modules/author In directory sc8-pr-cvs1:/tmp/cvs-serv6936/phpslash-dev/include/modules/author Modified Files: Author.class Log Message: clean up code comments./sync with -f cvs. Index: Author.class =================================================================== RCS file: /cvsroot/phpslash/phpslash-dev/include/modules/author/Author.class,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Author.class 12 Mar 2003 16:12:56 -0000 1.1.1.1 --- Author.class 21 Apr 2003 19:28:47 -0000 1.2 *************** *** 220,223 **** --- 220,232 ---- } else { + // if this name exists - bail out + $this->db->query("SELECT author_id, author_name + FROM psl_author + WHERE author_name = '".$ary['author_name']."'"); + if($this->db->next_record() ) { + $this->message .= "This username is already taken. Please choose a different one."; + return false; + } + if ($ary['password'] == "") { $this->message .= "There is no password in Author.class::saveAuthor"; *************** *** 565,569 **** } ! $this->author_templ = displayoptions('author', $this->author_templ, "newauthor", ''); return $this->author_templ->parse('OUT',array("newauthor")); --- 574,579 ---- } ! $options = displayOptions('author', $this->author_templ, "newauthor", ''); ! $this->author_templ->set_var('OPTIONS', $options); return $this->author_templ->parse('OUT',array("newauthor")); *************** *** 628,636 **** */ $q = "SELECT psl_group.group_id, ! psl_group.group_name FROM psl_group, psl_author_group_lut WHERE psl_group.group_id = psl_author_group_lut.group_id ! AND psl_author_group_lut.author_id = '$author_id' "; ! // debug("q", $q); $this->db->query($q); --- 638,646 ---- */ $q = "SELECT psl_group.group_id, ! psl_group.group_name FROM psl_group, psl_author_group_lut WHERE psl_group.group_id = psl_author_group_lut.group_id ! AND psl_author_group_lut.author_id = '$author_id' "; ! // debug("q", $q); $this->db->query($q); *************** *** 739,743 **** } } ! $this->author_templ = displayoptions('author', $this->author_templ, 'template', $temparray); return $this->author_templ->parse('OUT','template'); --- 749,755 ---- } } ! $options = displayOptions('author', $this->author_templ, 'template', $temparray); ! $this->author_templ->set_var('OPTIONS', $options); ! return $this->author_templ->parse('OUT','template'); *************** *** 827,831 **** $q = "SELECT DISTINCT author_id, author_name FROM psl_author "; ! if ( !$ary[mode] == "all") { $q .= ", psl_story WHERE psl_story.user_id = psl_author.author_id "; --- 839,845 ---- $q = "SELECT DISTINCT author_id, author_name FROM psl_author "; ! if ( !is_array($ary) || ! !array_key_exists('mode', $ary) || ! (!$ary['mode'] == "all")) { $q .= ", psl_story WHERE psl_story.user_id = psl_author.author_id "; *************** *** 836,844 **** while ($this->db->next_record()) { $author_array[] = array( ! "id" => $this->db->f("author_id"), ! "name" => $this->db->f("author_name") ! ); } return $author_array; } --- 850,889 ---- while ($this->db->next_record()) { $author_array[] = array( ! "id" => $this->db->f("author_id"), ! "name" => $this->db->f("author_name") ! ); } return $author_array; + } + + /** + * getAuthor - returns array with author record + * + * + * @access public + * @param $ary - id or name + * @return author_array; + */ + function getAuthor($ary) { + + $q = "SELECT DISTINCT author_id, + author_name, + author_realname, + url, + email, + quote, + seclev, + perms, + author_options + FROM psl_author "; + if ( !empty($ary['author_id'])) { + $q .= "WHERE author_id = '".$ary['author_id']."'"; + } elseif ( !empty($ary['author_name'])){ + $q .= "WHERE author_name = '".$ary['author_name']."'"; + } + $this->db->query($q); + + $this->db->next_record(); + return $this->db->Record; } |
From: Joe S. <joe...@us...> - 2003-04-21 19:28:53
|
Update of /cvsroot/phpslash/phpslash-dev/include/class In directory sc8-pr-cvs1:/tmp/cvs-serv6936/phpslash-dev/include/class Modified Files: slashAuthCR.class Log Message: clean up code comments./sync with -f cvs. Index: slashAuthCR.class =================================================================== RCS file: /cvsroot/phpslash/phpslash-dev/include/class/slashAuthCR.class,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** slashAuthCR.class 12 Mar 2003 16:42:50 -0000 1.2 --- slashAuthCR.class 21 Apr 2003 19:28:46 -0000 1.3 *************** *** 1,15 **** <?php ! /* $Id$ */ ! ! /* From the phplib local.inc */ ! ! # A variation of Auth which uses a Challenge-Response ! # Authentication. The password never crosses the net in clear, ! # if the remote system supports JavaScript. Please read the ! # Documentation section about CR Authentication to understand ! # what is going on. ! ! class slashAuth extends Auth { --- 1,19 ---- <?php ! /* $Id$ ! * ! * Provides the authorization functions of PHPSlash ! * ! * Extends the phplib auth class. ! * ! * From the phplib local.inc ! * ! * A variation of Auth which uses a Challenge-Response ! * Authentication. The password never crosses the net in clear, ! * if the remote system supports JavaScript. Please read the ! * Documentation section about CR Authentication to understand ! * what is going on. ! * ! */ class slashAuth extends Auth { *************** *** 23,32 **** var $mode = "log"; var $psl; /** * customizes class names and loads the class definitions ! * ! * @param string classnames (as many as you want) * @return void */ --- 27,37 ---- var $mode = "log"; var $psl; + var $sess; /** * customizes class names and loads the class definitions ! * ! * @param string classnames (as many as you want) * @return void */ *************** *** 34,48 **** $arr = func_get_args(); foreach($arr as $class) { ! $this->$class = pslGetClass($this->$class); ! loadClass($this->$class); } } function start() { ! ! global $_PSL, $HTTP_GET_VARS; $this->psl = &$_PSL; if(!empty($_PSL['magic'])) { $this->magic = $_PSL['magic']; --- 39,63 ---- $arr = func_get_args(); foreach($arr as $class) { ! $this->$class = pslGetClass($this->$class); ! loadClass($this->$class); } } + + + /** + * functions as a class constructor. + * Called from page_open. + * + * @return void + */ function start() { ! ! global $_PSL, $HTTP_GET_VARS, $sess; $this->psl = &$_PSL; + $this->sess = &$sess; + // If the magic word is defined in the config file - use it. if(!empty($_PSL['magic'])) { $this->magic = $_PSL['magic']; *************** *** 53,56 **** --- 68,72 ---- $this->loadClasses("database_class"); + // setup registration mode or login only if (!empty($HTTP_GET_VARS['mode']) && $HTTP_GET_VARS['mode']=='reg') { if( !empty($_PSL['authmode'])) { *************** *** 81,90 **** --- 97,114 ---- } + // call underlying phplib auth Auth::start(); } + + /** + * auth_loginform - displays the login form. + * + * @return void + */ function auth_loginform() { global $_PSL, $challenge, $HTTP_GET_VARS, $HTTP_POST_VARS, $sess, $saved_get, $saved_post; + // preserve the POST variable through the login process $saved_post = $HTTP_POST_VARS; $saved_get = $HTTP_GET_VARS; *************** *** 93,102 **** $sess->register("saved_get"); ! if(!isset($challenge)) { $challenge = md5(uniqid($this->magic)); $sess->register("challenge"); } ! $templ = pslNew("slashTemplate",$_PSL['templatedir']); $templ->set_file(array( 'form' => "loginformCR.tpl" --- 117,128 ---- $sess->register("saved_get"); ! // generate a challenge word if needed. ! if(empty($challenge)) { $challenge = md5(uniqid($this->magic)); $sess->register("challenge"); } ! // create the template object ! $templ = pslNew("slashTemplate"); $templ->set_file(array( 'form' => "loginformCR.tpl" *************** *** 111,115 **** )); ! if (isset($this->auth["uname"])) { $templ->set_var('USERNAME', htmlentities($this->auth["uname"])); } else { --- 137,142 ---- )); ! // Display the previously used name in the form field ! if (isset($this->auth["uname"]) && $this->auth["uname"] != "nobody") { $templ->set_var('USERNAME', htmlentities($this->auth["uname"])); } else { *************** *** 117,120 **** --- 144,149 ---- // $this->auth["error"] = ""; } + + // Display message string if present if (isset($this->auth["error"])) { $templ->set_var('ERROR', $this->auth["error"]); *************** *** 123,135 **** --- 152,173 ---- } + // Link to registration screen if enabled $templ->set_block("form","reg_block","regblock"); if( $_PSL['authmode'] == "reg") { $templ->parse("regblock", "reg_block", true); } + + // display slashhead("Login", "Login"); $templ->pparse('OUT',"form"); slashfoot(); + } + /** + * auth_preauth - allow for auto login or preference loading. + * + * @return int + */ function auth_preauth() { *************** *** 137,144 **** --- 175,185 ---- // debug("auth", "preauth"); + // The preauth cookie is called 'user_info' if( !empty($HTTP_COOKIE_VARS['user_info'])){ + // generate the challenge we expect $cookie_challenge = md5($this->magic .":". $this->psl['basedir']); + // decode the cookie data into an array $cookie_ary = unserialize(base64_decode($HTTP_COOKIE_VARS['user_info'])); *************** *** 152,155 **** --- 193,197 ---- $this->db->query($q); + // if the user is not found - apply any preferences if ($this->db->num_rows() == 0) { if(!empty($cookie_ary['preferences'])) { *************** *** 174,177 **** --- 216,220 ---- } + // user found - now check for correct data while ($this->db->next_record()) { $this->auth["uname"] = $this->db->Record["author_name"]; *************** *** 182,186 **** $md5_pw = $this->db->Record['password']; // this is the raw MD5ed user/pass combo $expected_response = md5("$md5_pw:$cookie_challenge"); ! if( $expected_response == $cookie_ary[0]) { // preauth successful // debug("preauth", "successful"); --- 225,231 ---- $md5_pw = $this->db->Record['password']; // this is the raw MD5ed user/pass combo $expected_response = md5("$md5_pw:$cookie_challenge"); ! ! // compare the response given in the cookie to expected response ! if( $expected_response == $cookie_ary[0]) { // preauth successful // debug("preauth", "successful"); *************** *** 213,216 **** --- 258,263 ---- jpcache_gc('string', "-slashSess-" . $sess->id, "100"); } + + // success is signalled by returning the user's id. return $uid; } else { *************** *** 221,249 **** } } else if ($this->nobody) { ! $uid = $this->auth["uid"] = "nobody"; loadClass('Author'); ! $aid = Author::getId($uid); ! $this->auth["perm"] = $this->get_userperms($aid); ! $this->auth["dname"] = Author::getRealName($aid); ! $this->auth["email"] = ''; ! return $aid; } } ! function auth_validatelogin() { global $HTTP_POST_VARS, $HTTP_GET_VARS, $saved_get, $saved_post, $challenge, $sess; if(empty($HTTP_POST_VARS)) { if(!empty($this->auth['uid']) && ($this->auth['uid'] == 'nobody' || $this->auth['uid'] == 'form')){ ! $uid = $this->auth["uid"] = "nobody"; ! loadClass('Author'); ! $aid = Author::getId($uid); ! $this->auth["perm"] = $this->get_userperms($aid); ! return $aid; } return false; } --- 268,338 ---- } } else if ($this->nobody) { ! ! // no user_info cookie ! // if public access allowed apply the data for user named 'nobody' loadClass('Author'); ! $author_ary = Author::getAuthor(array('author_name' => 'nobody')); ! $this->auth["perm"] = $this->get_userperms($author_ary['author_id']); ! $this->auth["dname"] = $author_ary['author_realname']; ! $this->auth["uname"] = $author_ary['author_name']; ! $this->auth["email"] = $author_ary['email']; ! $this->auth["url"] = $author_ary['url']; ! ! $this->auth['preferences'] = ''; ! // get rid of session variables and use the db author record. ! if($this->sess->is_registered("comment_name")) { ! $this->sess->unregister("comment_name"); ! $_SESSION['comment_name'] = null; ! unset($GLOBALS['comment_name']); ! } ! if($this->sess->is_registered("comment_email")) { ! $this->sess->unregister("comment_email"); ! $_SESSION['comment_email'] = null; ! unset($GLOBALS['comment_email']); ! } ! if($this->sess->is_registered("comment_url")) { ! $this->sess->unregister("comment_url"); ! $_SESSION['comment_url'] = null; ! unset($GLOBALS['comment_url']); ! } ! ! // expire cache for this session ! if(function_exists('jpcache_gc')) { ! jpcache_gc('string', "-slashSess-" . $sess->id, "100"); ! } ! ! // return the id for user 'nobody' ! return $author_ary['author_id']; } } ! /** ! * auth_validatelogin - process the login form. ! * ! * @return int ! */ function auth_validatelogin() { global $HTTP_POST_VARS, $HTTP_GET_VARS, $saved_get, $saved_post, $challenge, $sess; + // If no POST variables this must be an error or user + // abandoned a login form to return to a public area of site if(empty($HTTP_POST_VARS)) { + // This will happen when abandoning a login form + // need to load the data for the 'nobody' user. if(!empty($this->auth['uid']) && ($this->auth['uid'] == 'nobody' || $this->auth['uid'] == 'form')){ ! loadClass('Author'); ! $author_ary = Author::getAuthor(array('author_name' => 'nobody')); ! $this->auth["perm"] = $this->get_userperms($author_ary['author_id']); ! $this->auth["dname"] = $author_ary['author_realname']; ! $this->auth["uname"] = $author_ary['author_name']; ! $this->auth["email"] = $author_ary['email']; ! $this->auth["url"] = $author_ary['url']; ! ! return $author_ary['author_id']; } + return false; } *************** *** 251,258 **** $setcookie = ''; $lostpw = ''; ! ! // TODO: Change there so they aren't undefined indexes :) $username = $HTTP_POST_VARS['username']; ! $password = $HTTP_POST_VARS['password']; // $challenge = $HTTP_POST_VARS['challenge']; // use session variable $response = $HTTP_POST_VARS['response']; --- 340,350 ---- $setcookie = ''; $lostpw = ''; ! ! // set form entries to local variables $username = $HTTP_POST_VARS['username']; ! $password = ''; ! if(array_key_exists('password', $HTTP_POST_VARS)) { ! $password = $HTTP_POST_VARS['password']; ! } // $challenge = $HTTP_POST_VARS['challenge']; // use session variable $response = $HTTP_POST_VARS['response']; *************** *** 263,288 **** $lostpw = $HTTP_POST_VARS['lostpw']; } ! ! /* if(empty($HTTP_POST_VARS['challenge'])) { return false; } ! */ ! if($challenge != $HTTP_POST_VARS['challenge']) { return false; } ! # the login form will save the username if(isset($username)) { $this->auth["uname"] = $username; ! } else if ($this->nobody) { ## provides for "default login cancel" ! $uid = $this->auth["uid"] = "nobody"; ! loadClass('Author'); ! $aid = Author::getId($uid); ! $this->auth["perm"] = $this->get_userperms($aid); ! return $aid; } if ($username == "" || strstr($username,"'")) { // spit out empty login form --- 355,388 ---- $lostpw = $HTTP_POST_VARS['lostpw']; } ! ! // missing challenge - shouldn't happen if(empty($HTTP_POST_VARS['challenge'])) { + // $this->auth["error"] = "debug only - missing challenge"; return false; } ! ! // old loginforms expire - prevents hitting "back" or ! // "refresh" to login if($challenge != $HTTP_POST_VARS['challenge']) { + // $this->auth["error"] = "debug only - wrong challenge"; return false; } ! // the login form will save the username if(isset($username)) { $this->auth["uname"] = $username; ! } else if ($this->nobody) { // provides for "default login cancel" ! loadClass('Author'); ! $author_ary = Author::getAuthor(array('author_name' => 'nobody')); ! $this->auth["perm"] = $this->get_userperms($author_ary['author_id']); ! $this->auth["dname"] = $author_ary['author_realname']; ! $this->auth["uname"] = $author_ary['author_name']; ! $this->auth["email"] = $author_ary['email']; ! $this->auth["url"] = $author_ary['url']; ! ! return $author_ary['author_id']; } + // check for missing name or other shenanigans if ($username == "" || strstr($username,"'")) { // spit out empty login form *************** *** 291,294 **** --- 391,396 ---- } + // If the "Lost password" reminder is checked - call the + // method in Author class. if( $lostpw) { $author = pslNew("Author"); *************** *** 299,303 **** } ! # assume the check is gonna fail $uid = false; --- 401,405 ---- } ! // assume the check is gonna fail $uid = false; *************** *** 308,315 **** --- 410,419 ---- $this->db->query($q); + // username not found - return failure if ($this->db->num_rows() == 0) { return false; } + // username found while ($this->db->next_record()) { $uid = $this->db->f("author_id"); *************** *** 319,322 **** --- 423,427 ---- $this->auth["url"] = $this->db->Record["url"]; + // generate the expected response $md5_pw = $this->db->Record['password']; // this is the raw MD5ed user/pass combo $expected_response = md5("$md5_pw:$challenge"); *************** *** 333,341 **** // Response is set, JS might be enabled... ! if ($expected_response != $response) { $this->auth["error"] = "Either your username or password are invalid.<br>Please try again."; return false; } else { if(!empty($setcookie)){ $cookie_challenge = md5($this->magic .":". $this->psl['basedir']); $md5_pw = $this->db->Record['password']; // this is the raw MD5ed user/pass combo --- 438,452 ---- // Response is set, JS might be enabled... ! // compare the responses ! if ($expected_response != $response) { ! // failed - return with error message $this->auth["error"] = "Either your username or password are invalid.<br>Please try again."; return false; } else { + // success + if(!empty($setcookie)){ + // set preauth cookie so the user won't have + // to log in again $cookie_challenge = md5($this->magic .":". $this->psl['basedir']); $md5_pw = $this->db->Record['password']; // this is the raw MD5ed user/pass combo *************** *** 353,360 **** } $temparray=unserialize($this->db->Record['author_options']); if(!empty($temparray['preferences'])){ $this->auth['preferences'] = $temparray['preferences']; ! // use language preference if(isset($this->auth['preferences']['lang'])) { --- 464,472 ---- } + // apply user's preferences $temparray=unserialize($this->db->Record['author_options']); if(!empty($temparray['preferences'])){ $this->auth['preferences'] = $temparray['preferences']; ! // use language preference if(isset($this->auth['preferences']['lang'])) { *************** *** 362,366 **** $this->psl['templatedir'] = setLangTpl($this->auth['preferences']['lang']); } ! // use skin preference // if(isset($this->auth['preferences']['skin'])) { --- 474,478 ---- $this->psl['templatedir'] = setLangTpl($this->auth['preferences']['lang']); } ! // use skin preference // if(isset($this->auth['preferences']['skin'])) { *************** *** 371,393 **** } ! // may also need to get legacy records $this->auth["perm"] = $this->get_userperms( $uid); $this->auth["error"] = ""; $HTTP_GET_VARS = $saved_get; $HTTP_POST_VARS = $saved_post; $saved_get = ''; $saved_post = ''; $challenge = ''; // expire cache for this session if(function_exists('jpcache_gc')) { jpcache_gc('string', "-slashSess-" . $sess->id, "100"); } return $uid; } ! return false; } --- 483,527 ---- } ! // load the user's permissions/group membership $this->auth["perm"] = $this->get_userperms( $uid); + // successful - no errors $this->auth["error"] = ""; + // restore saved POST variables $HTTP_GET_VARS = $saved_get; $HTTP_POST_VARS = $saved_post; + // clear the session variables $saved_get = ''; $saved_post = ''; $challenge = ''; + // get rid of session variables and use the db author record. + if($this->sess->is_registered("comment_name")) { + $this->sess->unregister("comment_name"); + $_SESSION['comment_name'] = null; + unset($GLOBALS['comment_name']); + } + if($this->sess->is_registered("comment_email")) { + $this->sess->unregister("comment_email"); + $_SESSION['comment_email'] = null; + unset($GLOBALS['comment_email']); + } + if($this->sess->is_registered("comment_url")) { + $this->sess->unregister("comment_url"); + $_SESSION['comment_url'] = null; + unset($GLOBALS['comment_url']); + } + // expire cache for this session if(function_exists('jpcache_gc')) { jpcache_gc('string', "-slashSess-" . $sess->id, "100"); } + + // signal success by returning user id return $uid; } ! return false; } *************** *** 396,408 **** } function auth_registerform() { global $sess; ! $templ = pslNew("slashTemplate",$this->psl['templatedir']); $templ->set_file(array( form => "registerform.tpl" )); ! $templ->set_var(ACTION_URL,$this->psl['rooturl']."/login.php?mode=reg"); $templ->set_var(PHP_SELF,$this->psl[phpself]); if (isset($this->auth["uname"])) { --- 530,550 ---- } + + /** + * auth_registerform - displays the registration form. + * + * @return void + */ function auth_registerform() { global $sess; ! // create the template object ! $templ = pslNew("slashTemplate"); $templ->set_file(array( form => "registerform.tpl" )); ! // Fill out any fields already saved ! $templ->set_var(ACTION_URL,$this->psl['rooturl']."/login.php3?mode=reg"); $templ->set_var(PHP_SELF,$this->psl[phpself]); if (isset($this->auth["uname"])) { *************** *** 443,446 **** --- 585,590 ---- $templ->set_var(ERROR,""); } + + // display the form slashhead("Register", "Register"); $templ->pparse(OUT,"form"); *************** *** 448,456 **** } ! function auth_doregister() { global $HTTP_POST_VARS, $challenge; if(empty($HTTP_POST_VARS)) { return false; --- 592,605 ---- } ! /** ! * auth_doregister - validate the registration. ! * ! * @return void ! */ function auth_doregister() { global $HTTP_POST_VARS, $challenge; + // if no POST variables, this must be an error if(empty($HTTP_POST_VARS)) { return false; *************** *** 458,462 **** ! # the login form will save the username $this->auth["uname"] = $username = $HTTP_POST_VARS['username']; $this->auth["realname"] = $realname = $HTTP_POST_VARS['realname']; --- 607,611 ---- ! // save the entered data - to display the form again with data $this->auth["uname"] = $username = $HTTP_POST_VARS['username']; $this->auth["realname"] = $realname = $HTTP_POST_VARS['realname']; *************** *** 466,472 **** --- 615,623 ---- $this->auth["seclev"] = $seclev = $HTTP_POST_VARS['seclev']; + // password is not saved in the session $pass1 = $HTTP_POST_VARS['pass1']; $pass2 = $HTTP_POST_VARS['pass2']; + // if form empty - complain if ($username == "" || $pass1 == ""){ $this->auth["error"] = "Username or password missing. Please try again."; *************** *** 476,480 **** // $debug = true; ! ## Check the passwords for validity. if ($pass1 != $pass2) { $this->auth["error"] = "Password and repeated password do not match. Please try again."; --- 627,631 ---- // $debug = true; ! // Check the passwords for validity. if ($pass1 != $pass2) { $this->auth["error"] = "Password and repeated password do not match. Please try again."; *************** *** 487,491 **** } ! # assume the check is gonna fail $uid = false; --- 638,642 ---- } ! // assume the check is gonna fail $uid = false; *************** *** 494,498 **** WHERE author_name = '$username' "; ! # debug ("QUERY", $q); $this->db->query($q); --- 645,649 ---- WHERE author_name = '$username' "; ! // debug ("QUERY", $q); $this->db->query($q); *************** *** 532,537 **** $ary["permission"] = $perm_ary; ! // use Author.class saveStory for account creation ! if ($author->saveAuthor($ary)) { // $password = $pass1; $HTTP_POST_VARS['username'] = $username; --- 683,691 ---- $ary["permission"] = $perm_ary; ! // use Author.class saveAuthor for account creation ! if ($author->saveAuthor($ary)) { ! // successful account creation ! // attempt to log in the new user ! // $password = $pass1; $HTTP_POST_VARS['username'] = $username; *************** *** 542,545 **** --- 696,700 ---- // debug("username", $username); // debug("pass1", $pass1); + $uid = $this->auth_validatelogin(); if( $uid == false) { *************** *** 548,551 **** --- 703,707 ---- return $uid; } else { + // account creation failed $this->auth["error"] = "User Registration failed"; return false; *************** *** 554,558 **** } ! function get_userperms($uid) { --- 710,718 ---- } ! /** ! * get_userperms - return an array of the user's group memberships. ! * ! * @return array ! */ function get_userperms($uid) { *************** *** 572,581 **** AND psl_author_group_lut.author_id = '$uid' "; ! // debug("q", $q); $this->db->query($q); while ($this->db->next_record()) { $group_id = $this->db->Record['group_id']; $this->auth['perm'][$this->db->Record['group_name']][$this->db->Record['permission_name']] = true; $q = "SELECT section_id FROM psl_group_section_lut --- 732,744 ---- AND psl_author_group_lut.author_id = '$uid' "; ! // debug("q", $q); $this->db->query($q); while ($this->db->next_record()) { $group_id = $this->db->Record['group_id']; + // Load the group and its permissions $this->auth['perm'][$this->db->Record['group_name']][$this->db->Record['permission_name']] = true; + + // get the available sections for this group $q = "SELECT section_id FROM psl_group_section_lut *************** *** 585,589 **** while ($db2->next_record()) { $section_perm = "section_id". $db2->Record['section_id']; - // debug("section_perm", $section_perm); $this->auth["perm"][$this->db->Record['group_name']][$section_perm] = true; } --- 748,751 ---- *************** *** 604,608 **** $groups_ary[$this->db->Record['group_id']] = $this->db->Record['group_name']; } ! $q = "SELECT psl_group_group_lut.group_id, psl_group_group_lut.childgroup_id --- 766,771 ---- $groups_ary[$this->db->Record['group_id']] = $this->db->Record['group_name']; } ! ! // get the group of groups for this user $q = "SELECT psl_group_group_lut.group_id, psl_group_group_lut.childgroup_id *************** *** 611,615 **** WHERE psl_group_group_lut.group_id = psl_author_group_lut.group_id AND psl_author_group_lut.author_id = '$uid' "; ! // debug("q", $q); $this->db->query($q); --- 774,778 ---- WHERE psl_group_group_lut.group_id = psl_author_group_lut.group_id AND psl_author_group_lut.author_id = '$uid' "; ! // debug("q", $q); $this->db->query($q); *************** *** 619,627 **** $group_name = $groups_ary[$group_id]; ! $childgroup_name = $groups_ary[$childgroup_id]; ! ! if( isset($this->auth['perm'][$childgroup_name])) { $this->auth['perm'][$group_name][$childgroup_name] = $this->auth['perm'][$childgroup_name]; } else { // query to get group perms $q = "SELECT psl_permission.permission_name --- 782,799 ---- $group_name = $groups_ary[$group_id]; ! $childgroup_name = ''; ! if(!empty($groups_ary[$childgroup_id])) { ! $childgroup_name = $groups_ary[$childgroup_id]; ! } ! if(empty($this->auth['perm'])) { ! $this->auth['perm'] = array(); ! ! } ! ! if( array_key_exists($childgroup_name, $this->auth['perm'])) { ! // We already know the perms for this group $this->auth['perm'][$group_name][$childgroup_name] = $this->auth['perm'][$childgroup_name]; } else { + // We don't have the perms for this group so - // query to get group perms $q = "SELECT psl_permission.permission_name *************** *** 637,647 **** $this->auth['perm'][$group_name][$childgroup_name][$db2->Record['permission_name']] = true; $q = "SELECT section_id FROM psl_group_section_lut ! WHERE group_id = '$group_id' "; $db3 = pslNew("slashDB"); $db3->query($q); while ($db3->next_record()) { ! $section_perm = $db3->Record['section_id']; $this->auth["perm"][$group_name][$childgroup_name][$section_perm] = true; } --- 809,821 ---- $this->auth['perm'][$group_name][$childgroup_name][$db2->Record['permission_name']] = true; + // get the available sections for this group $q = "SELECT section_id FROM psl_group_section_lut ! WHERE group_id = '$childgroup_id' "; $db3 = pslNew("slashDB"); $db3->query($q); while ($db3->next_record()) { ! $section_perm = "section_id". $db3->Record['section_id']; ! $this->auth["perm"][$group_name][$childgroup_name][$section_perm] = true; } *************** *** 652,655 **** --- 826,830 ---- } //end while + return $this->auth['perm']; } // end of function get_userperms() |
From: Joe S. <joe...@us...> - 2003-04-21 19:15:10
|
Update of /cvsroot/phpslash/phpslash-ft/class In directory sc8-pr-cvs1:/tmp/cvs-serv25641/phpslash-ft/class Modified Files: slashAuthCR.class Log Message: clean up code comments. Index: slashAuthCR.class =================================================================== RCS file: /cvsroot/phpslash/phpslash-ft/class/slashAuthCR.class,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** slashAuthCR.class 10 Apr 2003 15:29:59 -0000 1.50 --- slashAuthCR.class 21 Apr 2003 19:15:06 -0000 1.51 *************** *** 1,15 **** <?php ! /* $Id$ */ ! ! /* From the phplib local.inc */ ! ! # A variation of Auth which uses a Challenge-Response ! # Authentication. The password never crosses the net in clear, ! # if the remote system supports JavaScript. Please read the ! # Documentation section about CR Authentication to understand ! # what is going on. ! ! class slashAuth extends Auth { --- 1,19 ---- <?php ! /* $Id$ ! * ! * Provides the authorization functions of PHPSlash ! * ! * Extends the phplib auth class. ! * ! * From the phplib local.inc ! * ! * A variation of Auth which uses a Challenge-Response ! * Authentication. The password never crosses the net in clear, ! * if the remote system supports JavaScript. Please read the ! * Documentation section about CR Authentication to understand ! * what is going on. ! * ! */ class slashAuth extends Auth { *************** *** 35,43 **** $arr = func_get_args(); foreach($arr as $class) { ! $this->$class = pslGetClass($this->$class); ! loadClass($this->$class); } } function start() { --- 39,55 ---- $arr = func_get_args(); foreach($arr as $class) { ! $this->$class = pslGetClass($this->$class); ! loadClass($this->$class); } } + + + /** + * functions as a class constructor. + * Called from page_open. + * + * @return void + */ function start() { *************** *** 47,50 **** --- 59,63 ---- $this->sess = &$sess; + // If the magic word is defined in the config file - use it. if(!empty($_PSL['magic'])) { $this->magic = $_PSL['magic']; *************** *** 53,56 **** --- 66,70 ---- $this->loadClasses("database_class"); + // setup registration mode or login only if (!empty($HTTP_GET_VARS['mode']) && $HTTP_GET_VARS['mode']=='reg') { if( !empty($_PSL['authmode'])) { *************** *** 81,90 **** --- 95,112 ---- } + // call underlying phplib auth Auth::start(); } + + /** + * auth_loginform - displays the login form. + * + * @return void + */ function auth_loginform() { global $_PSL, $challenge, $HTTP_GET_VARS, $HTTP_POST_VARS, $sess, $saved_get, $saved_post; + // preserve the POST variable through the login process $saved_post = $HTTP_POST_VARS; $saved_get = $HTTP_GET_VARS; *************** *** 93,96 **** --- 115,119 ---- $sess->register("saved_get"); + // generate a challenge word if needed. if(empty($challenge)) { $challenge = md5(uniqid($this->magic)); *************** *** 98,102 **** } ! $templ = pslNew("slashTemplate",$_PSL['templatedir']); $templ->set_file(array( 'form' => "loginformCR.tpl" --- 121,126 ---- } ! // create the template object ! $templ = pslNew("slashTemplate"); $templ->set_file(array( 'form' => "loginformCR.tpl" *************** *** 111,114 **** --- 135,139 ---- )); + // Display the previously used name in the form field if (isset($this->auth["uname"]) && $this->auth["uname"] != "nobody") { $templ->set_var('USERNAME', htmlentities($this->auth["uname"])); *************** *** 117,120 **** --- 142,147 ---- // $this->auth["error"] = ""; } + + // Display message string if present if (isset($this->auth["error"])) { $templ->set_var('ERROR', $this->auth["error"]); *************** *** 123,135 **** --- 150,171 ---- } + // Link to registration screen if enabled $templ->set_block("form","reg_block","regblock"); if( $_PSL['authmode'] == "reg") { $templ->parse("regblock", "reg_block", true); } + + // display slashhead("Login", "Login"); $templ->pparse('OUT',"form"); slashfoot(); + } + /** + * auth_preauth - allow for auto login or preference loading. + * + * @return int + */ function auth_preauth() { *************** *** 137,144 **** --- 173,183 ---- // debug("auth", "preauth"); + // The preauth cookie is called 'user_info' if( !empty($HTTP_COOKIE_VARS['user_info'])){ + // generate the challenge we expect $cookie_challenge = md5($this->magic .":". $this->psl['basedir']); + // decode the cookie data into an array $cookie_ary = unserialize(base64_decode($HTTP_COOKIE_VARS['user_info'])); *************** *** 152,155 **** --- 191,195 ---- $this->db->query($q); + // if the user is not found - apply any preferences if ($this->db->num_rows() == 0) { if(!empty($cookie_ary['preferences'])) { *************** *** 174,177 **** --- 214,218 ---- } + // user found - now check for correct data while ($this->db->next_record()) { $this->auth["uname"] = $this->db->Record["author_name"]; *************** *** 182,186 **** $md5_pw = $this->db->Record['password']; // this is the raw MD5ed user/pass combo $expected_response = md5("$md5_pw:$cookie_challenge"); ! if( $expected_response == $cookie_ary[0]) { // preauth successful // debug("preauth", "successful"); --- 223,229 ---- $md5_pw = $this->db->Record['password']; // this is the raw MD5ed user/pass combo $expected_response = md5("$md5_pw:$cookie_challenge"); ! ! // compare the response given in the cookie to expected response ! if( $expected_response == $cookie_ary[0]) { // preauth successful // debug("preauth", "successful"); *************** *** 213,216 **** --- 256,261 ---- jpcache_gc('string', "-slashSess-" . $sess->id, "100"); } + + // success is signalled by returning the user's id. return $uid; } else { *************** *** 221,224 **** --- 266,272 ---- } } else if ($this->nobody) { + + // no user_info cookie + // if public access allowed apply the data for user named 'nobody' loadClass('Author'); $author_ary = Author::getAuthor(array('author_name' => 'nobody')); *************** *** 252,255 **** --- 300,304 ---- } + // return the id for user 'nobody' return $author_ary['author_id']; } *************** *** 257,266 **** } ! function auth_validatelogin() { global $HTTP_POST_VARS, $HTTP_GET_VARS, $saved_get, $saved_post, $challenge, $sess; if(empty($HTTP_POST_VARS)) { if(!empty($this->auth['uid']) && ($this->auth['uid'] == 'nobody' || $this->auth['uid'] == 'form')){ --- 306,323 ---- } ! /** ! * auth_validatelogin - process the login form. ! * ! * @return int ! */ function auth_validatelogin() { global $HTTP_POST_VARS, $HTTP_GET_VARS, $saved_get, $saved_post, $challenge, $sess; + // If no POST variables this must be an error or user + // abandoned a login form to return to a public area of site if(empty($HTTP_POST_VARS)) { + // This will happen when abandoning a login form + // need to load the data for the 'nobody' user. if(!empty($this->auth['uid']) && ($this->auth['uid'] == 'nobody' || $this->auth['uid'] == 'form')){ *************** *** 275,278 **** --- 332,336 ---- return $author_ary['author_id']; } + return false; } *************** *** 280,285 **** $setcookie = ''; $lostpw = ''; ! ! // TODO: Change there so they aren't undefined indexes :) $username = $HTTP_POST_VARS['username']; $password = ''; --- 338,343 ---- $setcookie = ''; $lostpw = ''; ! ! // set form entries to local variables $username = $HTTP_POST_VARS['username']; $password = ''; *************** *** 302,306 **** } ! // old loginforms expire if($challenge != $HTTP_POST_VARS['challenge']) { // $this->auth["error"] = "debug only - wrong challenge"; --- 360,365 ---- } ! // old loginforms expire - prevents hitting "back" or ! // "refresh" to login if($challenge != $HTTP_POST_VARS['challenge']) { // $this->auth["error"] = "debug only - wrong challenge"; *************** *** 308,315 **** } ! # the login form will save the username if(isset($username)) { $this->auth["uname"] = $username; ! } else if ($this->nobody) { ## provides for "default login cancel" loadClass('Author'); $author_ary = Author::getAuthor(array('author_name' => 'nobody')); --- 367,374 ---- } ! // the login form will save the username if(isset($username)) { $this->auth["uname"] = $username; ! } else if ($this->nobody) { // provides for "default login cancel" loadClass('Author'); $author_ary = Author::getAuthor(array('author_name' => 'nobody')); *************** *** 323,326 **** --- 382,386 ---- } + // check for missing name or other shenanigans if ($username == "" || strstr($username,"'")) { // spit out empty login form *************** *** 329,332 **** --- 389,394 ---- } + // If the "Lost password" reminder is checked - call the + // method in Author class. if( $lostpw) { $author = pslNew("Author"); *************** *** 337,341 **** } ! # assume the check is gonna fail $uid = false; --- 399,403 ---- } ! // assume the check is gonna fail $uid = false; *************** *** 346,353 **** --- 408,417 ---- $this->db->query($q); + // username not found - return failure if ($this->db->num_rows() == 0) { return false; } + // username found while ($this->db->next_record()) { $uid = $this->db->f("author_id"); *************** *** 357,360 **** --- 421,425 ---- $this->auth["url"] = $this->db->Record["url"]; + // generate the expected response $md5_pw = $this->db->Record['password']; // this is the raw MD5ed user/pass combo $expected_response = md5("$md5_pw:$challenge"); *************** *** 371,379 **** --- 436,450 ---- // Response is set, JS might be enabled... + // compare the responses if ($expected_response != $response) { + // failed - return with error message $this->auth["error"] = "Either your username or password are invalid.<br>Please try again."; return false; } else { + // success + if(!empty($setcookie)){ + // set preauth cookie so the user won't have + // to log in again $cookie_challenge = md5($this->magic .":". $this->psl['basedir']); $md5_pw = $this->db->Record['password']; // this is the raw MD5ed user/pass combo *************** *** 391,394 **** --- 462,466 ---- } + // apply user's preferences $temparray=unserialize($this->db->Record['author_options']); if(!empty($temparray['preferences'])){ *************** *** 409,420 **** } ! // may also need to get legacy records $this->auth["perm"] = $this->get_userperms( $uid); $this->auth["error"] = ""; $HTTP_GET_VARS = $saved_get; $HTTP_POST_VARS = $saved_post; $saved_get = ''; $saved_post = ''; --- 481,495 ---- } ! // load the user's permissions/group membership $this->auth["perm"] = $this->get_userperms( $uid); + // successful - no errors $this->auth["error"] = ""; + // restore saved POST variables $HTTP_GET_VARS = $saved_get; $HTTP_POST_VARS = $saved_post; + // clear the session variables $saved_get = ''; $saved_post = ''; *************** *** 442,448 **** jpcache_gc('string', "-slashSess-" . $sess->id, "100"); } return $uid; } ! return false; } --- 517,525 ---- jpcache_gc('string', "-slashSess-" . $sess->id, "100"); } + + // signal success by returning user id return $uid; } ! return false; } *************** *** 451,462 **** } function auth_registerform() { global $sess; ! $templ = pslNew("slashTemplate",$this->psl['templatedir']); $templ->set_file(array( form => "registerform.tpl" )); $templ->set_var(ACTION_URL,$this->psl['rooturl']."/login.php3?mode=reg"); $templ->set_var(PHP_SELF,$this->psl[phpself]); --- 528,547 ---- } + + /** + * auth_registerform - displays the registration form. + * + * @return void + */ function auth_registerform() { global $sess; ! // create the template object ! $templ = pslNew("slashTemplate"); $templ->set_file(array( form => "registerform.tpl" )); + // Fill out any fields already saved $templ->set_var(ACTION_URL,$this->psl['rooturl']."/login.php3?mode=reg"); $templ->set_var(PHP_SELF,$this->psl[phpself]); *************** *** 498,501 **** --- 583,588 ---- $templ->set_var(ERROR,""); } + + // display the form slashhead("Register", "Register"); $templ->pparse(OUT,"form"); *************** *** 503,511 **** } ! function auth_doregister() { global $HTTP_POST_VARS, $challenge; if(empty($HTTP_POST_VARS)) { return false; --- 590,603 ---- } ! /** ! * auth_doregister - validate the registration. ! * ! * @return void ! */ function auth_doregister() { global $HTTP_POST_VARS, $challenge; + // if no POST variables, this must be an error if(empty($HTTP_POST_VARS)) { return false; *************** *** 513,517 **** ! # the login form will save the username $this->auth["uname"] = $username = $HTTP_POST_VARS['username']; $this->auth["realname"] = $realname = $HTTP_POST_VARS['realname']; --- 605,609 ---- ! // save the entered data - to display the form again with data $this->auth["uname"] = $username = $HTTP_POST_VARS['username']; $this->auth["realname"] = $realname = $HTTP_POST_VARS['realname']; *************** *** 521,527 **** --- 613,621 ---- $this->auth["seclev"] = $seclev = $HTTP_POST_VARS['seclev']; + // password is not saved in the session $pass1 = $HTTP_POST_VARS['pass1']; $pass2 = $HTTP_POST_VARS['pass2']; + // if form empty - complain if ($username == "" || $pass1 == ""){ $this->auth["error"] = "Username or password missing. Please try again."; *************** *** 531,535 **** // $debug = true; ! ## Check the passwords for validity. if ($pass1 != $pass2) { $this->auth["error"] = "Password and repeated password do not match. Please try again."; --- 625,629 ---- // $debug = true; ! // Check the passwords for validity. if ($pass1 != $pass2) { $this->auth["error"] = "Password and repeated password do not match. Please try again."; *************** *** 542,546 **** } ! # assume the check is gonna fail $uid = false; --- 636,640 ---- } ! // assume the check is gonna fail $uid = false; *************** *** 549,553 **** WHERE author_name = '$username' "; ! # debug ("QUERY", $q); $this->db->query($q); --- 643,647 ---- WHERE author_name = '$username' "; ! // debug ("QUERY", $q); $this->db->query($q); *************** *** 587,592 **** $ary["permission"] = $perm_ary; ! // use Author.class saveStory for account creation ! if ($author->saveAuthor($ary)) { // $password = $pass1; $HTTP_POST_VARS['username'] = $username; --- 681,689 ---- $ary["permission"] = $perm_ary; ! // use Author.class saveAuthor for account creation ! if ($author->saveAuthor($ary)) { ! // successful account creation ! // attempt to log in the new user ! // $password = $pass1; $HTTP_POST_VARS['username'] = $username; *************** *** 597,600 **** --- 694,698 ---- // debug("username", $username); // debug("pass1", $pass1); + $uid = $this->auth_validatelogin(); if( $uid == false) { *************** *** 603,606 **** --- 701,705 ---- return $uid; } else { + // account creation failed $this->auth["error"] = "User Registration failed"; return false; *************** *** 609,613 **** } ! function get_userperms($uid) { --- 708,716 ---- } ! /** ! * get_userperms - return an array of the user's group memberships. ! * ! * @return array ! */ function get_userperms($uid) { *************** *** 632,636 **** --- 735,742 ---- while ($this->db->next_record()) { $group_id = $this->db->Record['group_id']; + // Load the group and its permissions $this->auth['perm'][$this->db->Record['group_name']][$this->db->Record['permission_name']] = true; + + // get the available sections for this group $q = "SELECT section_id FROM psl_group_section_lut *************** *** 658,662 **** $groups_ary[$this->db->Record['group_id']] = $this->db->Record['group_name']; } ! $q = "SELECT psl_group_group_lut.group_id, psl_group_group_lut.childgroup_id --- 764,769 ---- $groups_ary[$this->db->Record['group_id']] = $this->db->Record['group_name']; } ! ! // get the group of groups for this user $q = "SELECT psl_group_group_lut.group_id, psl_group_group_lut.childgroup_id *************** *** 681,687 **** --- 788,797 ---- } + if( array_key_exists($childgroup_name, $this->auth['perm'])) { + // We already know the perms for this group $this->auth['perm'][$group_name][$childgroup_name] = $this->auth['perm'][$childgroup_name]; } else { + // We don't have the perms for this group so - // query to get group perms $q = "SELECT psl_permission.permission_name *************** *** 697,700 **** --- 807,811 ---- $this->auth['perm'][$group_name][$childgroup_name][$db2->Record['permission_name']] = true; + // get the available sections for this group $q = "SELECT section_id FROM psl_group_section_lut *************** *** 713,716 **** --- 824,828 ---- } //end while + return $this->auth['perm']; } // end of function get_userperms() |
From: Joe S. <joe...@us...> - 2003-04-21 17:08:53
|
Update of /cvsroot/phpslash/phpslash-ft/class In directory sc8-pr-cvs1:/tmp/cvs-serv19752/phpslash-ft/class Modified Files: Block.class Log Message: new block option - cache_disabled. Index: Block.class =================================================================== RCS file: /cvsroot/phpslash/phpslash-ft/class/Block.class,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** Block.class 18 Apr 2003 14:35:41 -0000 1.30 --- Block.class 21 Apr 2003 17:08:46 -0000 1.31 *************** *** 520,528 **** $this->parser->parse($this->block_info); $this->parsedData = $this->parser->getFinal(); ! // only write to the db if the data is changed if($this->block_info["cache_data"] != $this->parsedData) { ! $this->block_info["cache_data"] = $this->parsedData; ! $this->storeParsed(); ! } return true; } else { --- 520,532 ---- $this->parser->parse($this->block_info); $this->parsedData = $this->parser->getFinal(); ! // only write to the db if the data is changed if($this->block_info["cache_data"] != $this->parsedData) { ! // debug($this->block_info["title"], "updated"); ! $this->block_info["cache_data"] = $this->parsedData; ! // Don't commit to db if cache_off block option is used. ! if(empty($this->block_info["block_options"]["cache_disabled"])) { ! $this->storeParsed(); ! } ! } return true; } else { |
From: Joe S. <joe...@us...> - 2003-04-21 17:08:51
|
Update of /cvsroot/phpslash/phpslash-ft In directory sc8-pr-cvs1:/tmp/cvs-serv19752/phpslash-ft Modified Files: CHANGES Log Message: new block option - cache_disabled. Index: CHANGES =================================================================== RCS file: /cvsroot/phpslash/phpslash-ft/CHANGES,v retrieving revision 1.758 retrieving revision 1.759 diff -C2 -d -r1.758 -r1.759 *** CHANGES 18 Apr 2003 14:35:40 -0000 1.758 --- CHANGES 21 Apr 2003 17:08:44 -0000 1.759 *************** *** 13,16 **** --- 13,20 ---- 9 - Removal of something (kill -9 :) + 2003-April-21 12:00PM CST Joe Stewart <joe...@us...> + [F] - Block.class - new block option - "cache_disabled". When this is set + the block will not be written to the db. + 2003-April-18 9:00AM CST Joe Stewart <joe...@us...> [B] - Block.class - doParse only calls storeParsed if the block data changed. |
From: Joe S. <joe...@us...> - 2003-04-21 17:00:39
|
Update of /cvsroot/phpslash/phpslash-dev In directory sc8-pr-cvs1:/tmp/cvs-serv11614/phpslash-dev Modified Files: CHANGES Log Message: new block option - cache_disabled. Index: CHANGES =================================================================== RCS file: /cvsroot/phpslash/phpslash-dev/CHANGES,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** CHANGES 21 Apr 2003 15:24:26 -0000 1.7 --- CHANGES 21 Apr 2003 17:00:21 -0000 1.8 *************** *** 14,17 **** --- 14,21 ---- 2003-April-21 10:00AM CST Joe Stewart <joe...@us...> + [F] - Block.class - new block option - "cache_disabled". When this is set + the block will not be written to the db. + + 2003-April-21 10:00AM CST Joe Stewart <joe...@us...> [B] - Mailinglist.class - sync with -ft cvs. |