From 25a101d128ada4cac4e634b1c0fdd881551fd376 Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Sun, 7 Dec 2008 20:25:36 -0500 Subject: Redid multiple tag system This new tag system has a seperate table for tags. This way, a tag cloud can be made much more easily than if using the previous system. This changeset requires manual maintinence. --- includes/functions.php | 42 +++++++++++++++++++++++++++++++++++++++--- includes/updatePending.php | 2 +- 2 files changed, 40 insertions(+), 4 deletions(-) (limited to 'includes') diff --git a/includes/functions.php b/includes/functions.php index c71e69f..73a6e17 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -115,9 +115,15 @@ function postBlogPost($title,$author,$tags,$content) { $slug = generateSlug($title,'updates'); - $inspost = "INSERT INTO updates (title,slug,author,tags,text) VALUES (\"" . $title . "\",\"" . $slug . "\",\"" . $author . "\",\"" . $tags . "\",\"" . addslashes($content) . "\")"; + $inspost = "INSERT INTO updates (title,slug,author,text) VALUES (\"" . $title . "\",\"" . $slug . "\",\"" . $author . "\",\"" . addslashes($content) . "\")"; $inspost2 = mysql_query($inspost); + $getpost = "SELECT * FROM updates WHERE slug = \"" . $slug . "\""; + $getpost2 = mysql_query($getpost); + $getpost3 = mysql_fetch_array($getpost2); + + addTags($getpost3['id'], $tags); + $upconf = "UPDATE config SET value = \"" . date('md') . "\" WHERE name = \"lastUpdate\""; $upconf2 = mysql_query($upconf); @@ -144,7 +150,7 @@ function postBlogPost($title,$author,$tags,$content) if (preg_match('/send($msg); } @@ -153,7 +159,7 @@ function postBlogPost($title,$author,$tags,$content) $client = new xmlrpc_client('http://rpc.pingomatic.com'); $msg = new xmlrpcmsg("weblogUpdates.ping", array( new xmlrpcval('Four Island', 'string'), - new xmlrpcval('http://www.fourisland.com/', 'string'))); + new xmlrpcval('http://fourisland.com/', 'string'))); $client->send($msg); } @@ -215,4 +221,34 @@ function verifyUser($username, $password) return (($_POST['username'] != '') && ($getuser3['username'] == $_POST['username'])); } +function getTags($id, $type = 'published') +{ + $gettags = "SELECT * FROM tags WHERE post_id = " . $id . " AND post_type = \"" . $type . "\""; + $gettags2 = mysql_query($gettags); + $i=0; + $tags = array(); + while ($gettags3[$i] = mysql_fetch_array($gettags2)) + { + $tags[] = $gettags3[$i]['tag']; + $i++; + } + + return $tags; +} + +function addTags($id, $tags, $type = 'published') +{ + foreach ($tags as $tag) + { + $instag = "INSERT INTO tags (post_id,post_type,tag) VALUES (" . $id . ",\"" . $type . "\",\"" . $tag . "\")"; + $instag2 = mysql_query($instag); + } +} + +function removeTags($id, $type = 'published') +{ + $deltags = "DELETE FROM tags WHERE post_id = " . $id . " AND post_type = \"" . $type . "\""; + $deltags2 = mysql_query($deltags); +} + ?> diff --git a/includes/updatePending.php b/includes/updatePending.php index 79ab1c4..9a9b508 100755 --- a/includes/updatePending.php +++ b/includes/updatePending.php @@ -40,7 +40,7 @@ if ((!isset($disablePendingQueue)) && (date('j') != 'Sat')) $getpost2 = mysql_query($getpost); $getpost3 = mysql_fetch_array($getpost2); - postBlogPost($getpost3['title'], $getpost3['author'], $getpost3['tags'], $getpost3['text']); + postBlogPost($getpost3['title'], $getpost3['author'], explode(',', $getpost3['tags']), $getpost3['text']); $delpost = "DELETE FROM pending WHERE id = " . $getpost3['id']; $delpost2 = mysql_query($delpost); -- cgit 1.4.1