Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1:/tmp/cvs-serv25535
Modified Files:
serendipity_functions.inc.php
Log Message:
!!!!ATTENTION - UPDATE YOUR DATABASE STRUCTURE!!!!
Modify the entries table, so that there is a field 'trackbacks'.
Similar to the comments field (int4, unsigned, default 0).
Trackbacks are now seperately counted.
Index: serendipity_functions.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_functions.inc.php,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- serendipity_functions.inc.php 21 May 2003 22:01:29 -0000 1.41
+++ serendipity_functions.inc.php 22 May 2003 21:08:27 -0000 1.42
@@ -27,7 +27,7 @@
<td class="serendipity_commentsValue"><textarea rows="10" cols="40" name="serendipity[comment]"></textarea></td>
</tr>
</table>
-<?=REMEMBER_INFO?>
+<?=REMEMBER_INFO?>
<input type="checkbox" name="serendipity_remember" /><br />
<input type="submit" value="<?=SUBMIT_COMMENT?>" />
</form>
@@ -87,7 +87,7 @@
$endts = mktime(0, 0, 0, $month + 1, 1, $year);
// Find out about diary entries
- $querystring = "SELECT timestamp from $serendipity[dbPrefix]entries WHERE timestamp >= $ts and timestamp <= $endts";
+ $querystring = "SELECT timestamp from $serendipity[dbPrefix]entries WHERE timestamp >= $ts and timestamp <= $endts";
$rows = serendipity_db_query($querystring);
$activeDays = array();
if (is_array($rows)) {
@@ -136,7 +136,7 @@
if ($y==6) $cellProp = "LastInRow";
if ($x==4) $cellProp = "LastRow";
if ($x==4 && $y==6) $cellProp = "LastInLastRow";
-
+
// Start printing
if (($x>0 || $y>=$firstDayWeekDay) && $currDay<=$nrOfDays) {
/*
@@ -154,7 +154,7 @@
print ($currDay);
if ($activeDays[$currDay] > 1) print ("</A>");
if (date("m") == $month && date("Y") == $year && $currDay == date("j")) echo "</I>";
-
+
print("</TD>");
$currDay++;
}
@@ -232,7 +232,7 @@
if ($authorid === null) {
$authorid = $serendipity['authorid'];
}
-
+
$querystring = "SELECT * FROM ".$serendipity['dbPrefix']."category WHERE authorid = $authorid";
return serendipity_db_query($querystring);
@@ -260,7 +260,7 @@
/* pre-walk the array to collect them keyed by date */
$bydate = array();
-
+
if (!is_array($entries)) {
echo "<br />".NO_ENTRIES_TO_PRINT;
return;
@@ -271,7 +271,7 @@
$d = date(DATE_FORMAT_1, $entries[$x]["timestamp"]);
$bydate[$d][] = $entries[$x];
}
-
+
foreach ($bydate as $date => $ents) {
echo "<div class='serendipity_Entry_Date'>";
echo "<div class='serendipity_date'>$date</div>";
@@ -280,13 +280,13 @@
echo "<div class='serendipity_title'>";
echo htmlentities($entry['title']);
echo "</div>";
-
+
echo "<div class='serendipity_entry'>";
echo nl2br(serendipity_emoticate(serendipity_markup_text($entry['body'], $entry['id'])));
if ($extended && strlen($entry['extended'])) {
echo '<a name="#extended"></a>';
echo nl2br(serendipity_emoticate(serendipity_markup_text($entry['extended'], $entry['id'])));
- }
+ }
if ($entry['exflag'] && !$extended) {
echo "<br><div class='serendipity_time'><a href=\""
. $serendipity['serendipityHTTPPath']
@@ -294,7 +294,7 @@
. $entry['id']
. ".html#extended\">View Extended Entry</a></div><br>";
}
-
+
echo "<div class='serendipity_time'><br><a href=\""
. $serendipity['serendipityHTTPPath']
. "archives/e_"
@@ -312,9 +312,9 @@
. "onClick=\"window.open(this.href, 'comments', 'width=480,height=480,scrollbars=yes'); return false;\">"
. $entry['comments'] . " $label</a>";
}
-
+
echo "</div>"; // serendipity_time
-
+
echo "\n<!--\n";
@@ -362,9 +362,9 @@
} else {
die('What are you up to? You need to be an admin to delete comments');
}
-}
+}
-function serendipity_fetchComments($id, $limit = null)
+function serendipity_fetchComments($id, $limit = null)
{
global $serendipity;
@@ -398,7 +398,7 @@
<a name="c<?=$comment['id']?>"></a>
<?=nl2br(serendipity_markup_text(serendipity_emoticate($comment['body'])))?><br />
<div class="serendipity_comment_source">
- <?=$type?> <?=($link ? "<a href=\"$link\">$name</a>" : $name)?> <?=ON?>
+ <?=$type?> <?=($link ? "<a href=\"$link\">$name</a>" : $name)?> <?=ON?>
<a href="<?=$PHP_SELF?>#comment<?=$comment['id']?>"><?=date("M d, h:i", $comment['timestamp'])?></a>
<?php
if ($_SESSION["serendipityAuthedUser"] === true) {
@@ -422,24 +422,26 @@
$commentsFixed = serendipity_db_escape_string($commentInfo['comment']);
$name = serendipity_db_escape_string($commentInfo['name']);
$url = serendipity_db_escape_string($commentInfo['url']);
- $email = serendipity_db_escape_string($commentInfo['email']);
+ $email = serendipity_db_escape_string($commentInfo['email']);
$t = time();
- $query = "INSERT INTO {$serendipity['dbPrefix']}comments (entry_id, author, email, url, body, type, timestamp, title)";
+ $query = "INSERT INTO {$serendipity['dbPrefix']}comments (entry_id, author, email, url, body, type, timestamp, title)";
$query .= " VALUES ('$id', '$name', '$email', '$url', '$commentsFixed', '$type', '$t', '$title')";
serendipity_db_query($query);
- $query = "UPDATE {$serendipity['dbPrefix']}entries SET comments=comments+1 WHERE id='$id'";
- serendipity_db_query($query);
+ $field = ($type=='NORMAL' ? 'comments' : 'trackbacks');
- $query = "SELECT email, title, mail_comments
+ $query = "UPDATE {$serendipity['dbPrefix']}entries SET $field=$field+1 WHERE id='$id'";
+ var_dump(serendipity_db_query($query));
+
+ $query = "SELECT email, title, mail_comments
FROM {$serendipity['dbPrefix']}entries e, {$serendipity['dbPrefix']}authors a
WHERE e.id = '$id'
AND e.authorid = a.authorid";
$row = serendipity_db_query($query, true);
if($row['mail_comments']) {
- serendipity_sendComment($row['email'], $name, $email, $url, $id,
+ serendipity_sendComment($row['email'], $name, $email, $url, $id,
$row['title'], $comments);
}
serendipity_purgeEntry($id, $t);
@@ -447,7 +449,7 @@
function serendipity_sendComment($to, $fromName, $fromEmail, $fromUrl, $id, $title, $comment) {
global $serendipity;
- $text =
+ $text =
sprintf(A_NEW_COMMENT_BLAHBLAH, $serendipity[blogTitle],$id)."
IP Address: $_SERVER[REMOTE_ADDR]
@@ -459,13 +461,13 @@
$comment
---
+--
Powered by serendipity.
My blog runs on PHP. Yours can too.
http://php-blog.sf.net/ to find out how.";
mail($to, "[$serendipity[blogTitle]] New comment posted to $title", $text,
"From: $fromName <$fromEmail>\r\n");
-
+
}
function serendipity_fetchReferences($id)
@@ -490,7 +492,7 @@
// extract author information
$query = "select email from {$serendipity['dbPrefix']}authors where username='{$entry['username']}'";
$results = serendipity_db_query($query);
- echo '<author>' . htmlentities($results[0]['email']) . ' (' . htmlentities($entry['username']) . ")</author>\n";
+ echo '<author>' . htmlentities($results[0]['email']) . ' (' . htmlentities($entry['username']) . ")</author>\n";
echo "<content:encoded>\n";
echo utf8_encode(htmlspecialchars(serendipity_emoticate(serendipity_markup_text($entry['body']))));
echo "\n</content:encoded>\n";
@@ -522,7 +524,7 @@
$ret = preg_replace('/#([[:alnum:]]+?)#/','&\1;',$ret);
$ret = preg_replace('/\b_([\S ]+?)_\b/','<u>\1</u>',$ret);
$ret = str_replace(chr(1), '\_', $ret);
-
+
//bold
$ret = str_replace('\*',chr(1),$ret);
$ret = str_replace('**',chr(2),$ret);
@@ -611,7 +613,7 @@
@unlink("{$serendipity['serendipityPath']}/feeds/index.rss");
@unlink("{$serendipity['serendipityPath']}/feeds/index.rss2");
@unlink("{$serendipity['serendipityPath']}/index.html");
-}
+}
/**
@@ -640,9 +642,9 @@
$pingback = $_SERVER['X-PINGBACK'];
}
else if(preg_match('@<link rel="pingback" href="([^"]+)" ?/?>@', $body, $matches)) {
- $pingback = $matches[1];
+ $pingback = $matches[1];
}
- else {
+ else {
return;
}
// xml-rpc hack
@@ -662,7 +664,7 @@
</methodCall>";
_serendipity_send($pingback, $query);
return;
-}
+}
/**
* Send a trackback ping
@@ -716,8 +718,8 @@
function serendipity_reference_autodiscover($loc, $url, $author, $title, $text) {
$fp = @fopen($loc, "r");
- if(!$fp) {
- return;
+ if(!$fp) {
+ return;
}
while(!feof($fp)) {
$res .= fgets($fp, 1024);
@@ -732,7 +734,7 @@
*/
function
add_trackback ($id, $title, $url, $name, $excerpt)
-{
+{
global $serendipity;
$comment['title'] = $title;
@@ -741,13 +743,13 @@
$comment['comment'] = $excerpt;
serendipity_saveComment($id, $comment, 'TRACKBACK');
-
+
return 1;
-}
+}
function
add_pingback ($id, $postdata)
-{
+{
global $serendipity;
if(preg_match('@<methodcall>\s*<methodName>\s*pingback.ping\s*</methodName>\s*<params>\s*<param>\s*<value>\s*<string>([^<])*</string>\s*</value>\s*</param>\s*<param>\s*<value>\s*<string>([^<])*</string>\s*</value>\s*</param>\s*</params>\s*</methodCall>@i', $postdata, $matches)) {
@@ -756,18 +758,18 @@
$comment['title'] = '';
$comment['url'] = $remote;
$comment['comment'] = '';
- $comment['name'] = '';
- serendipity_saveComment($id, $comment, 'PINGBACK');
+ $comment['name'] = '';
+ serendipity_($id, $comment, 'PINGBACK');
return 1;
}
return 0;
-}
+}
/**
* Cut text
*/
function
-serendipity_trackback_excerpt($text)
+serendipity_trackback_excerpt($text)
{
return substr($text, 0, 255);
}
@@ -794,7 +796,7 @@
}
function report_pingback_success ()
-{
+{
print <<<SUCCESS
<?xml version="1.0"?>
<methodResponse>
@@ -822,11 +824,11 @@
/**
* search through link body, and automatically send a trackback ping.
*/
-function
+function
serendipity_handle_references($id, $author, $title, $text)
{
global $serendipity;
-
+
if (!preg_match_all('@<a[^>]+?href\s*=\s*["\']?([^\'" >]+?)[ \'"]?>([^<]*)</a>@i', $text, $matches)) {
return;
}
@@ -885,11 +887,11 @@
$newEntry = 0;
$exflag = 0;
-
+
if (!is_numeric($entry["timestamp"])) {
$entry["timestamp"] = time();
}
-
+
if(strlen($entry["extended"])) {
$exflag = 1;
}
@@ -903,9 +905,9 @@
unset($entry['id']);
$entry['comments'] = 0;
-
+
$res = serendipity_db_insert("entries", $entry);
-
+
$entry['id'] = serendipity_db_insert_id();
$newEntry = 1;
} else {
@@ -918,7 +920,7 @@
if (is_string($res)) {
return $res;
}
-
+
if($exflag) {
serendipity_handle_references($entry['id'], $serendipity['blogTitle'], $entry['title'], $entry['extended'], $newEntry);
}
@@ -927,7 +929,7 @@
}
serendipity_purgeEntry($entry['id'], $entry['timestamp']);
-
+
return (int)$entry['id'];
}
@@ -943,7 +945,7 @@
if(strlen($entry["extended"])) {
$exflag = 1;
}
- $querystring = "UPDATE ".$serendipity["dbPrefix"]."entries
+ $querystring = "UPDATE ".$serendipity["dbPrefix"]."entries
SET title = '".serendipity_db_escape_string($entry["title"])."',
body = '".serendipity_db_escape_string($entry["body"])."',
extended = '".serendipity_db_escape_string($entry["extended"])."',
@@ -997,7 +999,7 @@
} else {
$res = serendipity_db_update('css', array('cssid' => $css['cssid']), $css);
}
-
+
if (is_string($res)) {
return $res;
}
@@ -1048,19 +1050,19 @@
$loadfn = "imagecreatefromgif";
$savefn = "imagegif";
break;
-
+
case 'jpeg':
case 'jpg':
case 'jfif':
$loadfn = "imagecreatefromjpeg";
$savefn = "imagejpeg";
break;
-
+
case 'png':
$loadfn = "imagecreatefrompng";
$savefn = "imagepng";
break;
-
+
default:
return false;
}
@@ -1090,10 +1092,10 @@
$t = serendipity_parseFileName($file);
$f = $t[0];
$suf = $t[1];
-
+
$infile = $serendipity["serendipityPath"] . $serendipity["uploadPath"] . $file;
$outfile = $serendipity["serendipityPath"] . $serendipity["uploadPath"] . $f . "." . $serendipity["thumbSuffix"] . "." . $suf;
-
+
if ($serendipity["magick"] !== true) {
return serendipity_resize_image_gd($infile, $outfile, $size, $size);
}
@@ -1117,7 +1119,7 @@
if($serendipity["magick"] !== true) {
return serendipity_resize_image_gd($infile, $outfile, $width, $height);
}
-
+
$cmd = $serendipity["convert"]." -scale ".$width."x$height $infile $outfile";
$res = `$cmd`;
return $res;
@@ -1131,7 +1133,7 @@
$i=0;
serendipity_fetchImages();
-
+
$files = $serendipity["imageList"];
for($x=0; $x<count($files); $x++) {
$f = serendipity_parseFileName($files[$x]);
@@ -1214,7 +1216,7 @@
</tr>
<tr>
<td colspan="2"><?=ENTRY_BODY?></td>
- </tr>
+ </tr>
<tr>
<td colspan="2">
<textarea name="serendipity[body]" id="serendipity[body]" cols=80 rows=20><?=$entry["body"]?></textarea>
@@ -1222,7 +1224,7 @@
</tr>
<tr>
<td colspan="2"><?=EXTENDED_BODY?></td>
- </tr>
+ </tr>
<tr>
<td colspan="2">
<textarea name="serendipity[extended]" id="serendipity[extended]" cols=80 rows=20><?=htmlentities($entry["extended"])?></textarea>
@@ -1269,7 +1271,7 @@
</tr>
<tr>
<td colspan="2"><?=ENTRY_BODY?></td>
- </tr>
+ </tr>
<tr>
<td colspan="2">
<textarea name="serendipity[body]" cols=80 rows=20><?=htmlentities($entry["body"])?></textarea>
@@ -1277,7 +1279,7 @@
</tr>
<tr>
<td colspan="2"><?=EXTENDED_BODY?></td>
- </tr>
+ </tr>
<tr>
<td colspan="2">
<textarea name="serendipity[extended]" cols=80 rows=20><?=htmlentities($entry["extended"])?></textarea>
@@ -1322,7 +1324,7 @@
$marker = "";
}
-
+
$avail_options .= ">$marker" . htmlentities($cssname) . "</option>";
}
}
@@ -1349,7 +1351,7 @@
</tr>
<tr>
<td colspan="2">CSS</td>
- </tr>
+ </tr>
<tr>
<td colspan="2">
<textarea name="serendipity[data]" cols=80 rows=20><?=htmlentities($css["data"])?></textarea>
@@ -1379,7 +1381,7 @@
</td>
</tr>
<tr>
- <td>
+ <td>
<input type="submit" name="NEW" value="<?=CREATE_NEW_STYLESHEET?>">
</td>
</tr>
@@ -1405,7 +1407,7 @@
return 1;
}
$password = md5($password);
- $query = "SELECT
+ $query = "SELECT
*
FROM
$serendipity[dbPrefix]authors
@@ -1433,16 +1435,16 @@
}
$url_parts = parse_url($_SERVER['HTTP_REFERER']);
- if (!$url_parts['host'] ||
+ if (!$url_parts['host'] ||
strstr($_url_parts['host'], $_SERVER['SERVER_NAME'])) {
return;
}
if (rand(0, 100) < 1) {
serendipity_track_referrer_gc();
- }
+ }
- $suppressq = "SELECT count(1)
+ $suppressq = "SELECT count(1)
FROM $serendipity[dbPrefix]suppress
WHERE ip = '$_SERVER[REMOTE_ADDR]'
AND scheme = '$url_parts[scheme]'
@@ -1452,7 +1454,7 @@
AND query = '$url_parts[query]'
AND last > now() - 900";
- $suppressp = "DELETE FROM $serendipity[dbPrefix]suppress
+ $suppressp = "DELETE FROM $serendipity[dbPrefix]suppress
WHERE ip = '$_SERVER[REMOTE_ADDR]'
AND scheme = '$url_parts[scheme]'
AND host = '$url_parts[host]'
@@ -1460,7 +1462,7 @@
AND query = '$url_parts[query]'
AND path = '$url_parts[path]'";
$suppressu = "INSERT INTO $serendipity[dbPrefix]suppress
- (ip, last, scheme, host, port, path, query)
+ (ip, last, scheme, host, port, path, query)
VALUES ('$_SERVER[REMOTE_ADDR]', now(), '$url_parts[scheme]', '$url_parts[host]', '$url_parts[port]', '$url_parts[path]', '$url_parts[query]')";
$count = serendipity_db_query($suppressq, true);
@@ -1468,17 +1470,17 @@
if ($count[0] > 0) {
serendipity_db_query($suppressu);
return;
- }
+ }
serendipity_db_query($suppressp);
serendipity_db_query($suppressu);
serendipity_track_url('referrers', $_SERVER['HTTP_REFERER'], $entry);
-}
+}
function serendipity_track_referrer_gc() {
global $serendipity;
-
+
$gc = "DELETE FROM $serendipity[dbPrefix]suppress where last < now() - 900";
serendipity_db_query($gc);
}
@@ -1542,10 +1544,10 @@
$query = "SELECT host, SUM(count) AS total
FROM {$serendipity['dbPrefix']}$list
- GROUP BY host
+ GROUP BY host
ORDER BY total DESC, host
LIMIT $limit";
-
+
$rows = serendipity_db_query($query);
if (is_array($rows)) {
@@ -1584,7 +1586,7 @@
global $serendipity;
$names = array();
-
+
$query = "SELECT cssid, name FROM $serendipity[dbPrefix]css ORDER BY name";
$rows = serendipity_db_query($query);
foreach ($rows as $row) {
@@ -1615,7 +1617,7 @@
{
static $init = false;
global $serendipity;
-
+
if (isset ($serendipity["wysiwyg"]) && $serendipity["wysiwyg"]) {
if (!$init) {
|