[Comoblog-commit] comoblog/admin comment_edit.php, 1.1, 1.2 manage_modules.php, 1.3, 1.4 manage_com
Status: Inactive
Brought to you by:
markwallis
|
From: iamdecal <iam...@us...> - 2006-10-22 11:44:35
|
Update of /cvsroot/comoblog/comoblog/admin In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv27709/admin Modified Files: comment_edit.php manage_modules.php manage_comments.php comment_del.php post_edit.php Log Message: work in progress, ditching this server cos its borked ;( Index: comment_del.php =================================================================== RCS file: /cvsroot/comoblog/comoblog/admin/comment_del.php,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- comment_del.php 16 Aug 2006 01:27:28 -0000 1.1 +++ comment_del.php 22 Oct 2006 11:44:01 -0000 1.2 @@ -1,18 +1,29 @@ -<?php -require_once ('include/admin.inc.php'); - -$offset = 0; -if (isset($_GET['o'])) $offset = $_GET['o'] + 0; - -$post_id = ''; -if (isset($_GET['i'])) $post_id = $_GET['i']; - - -post_del ($post_id); - - -mysql_close(); - -Header ('Location: manage_posts.php?d=y&o='.$offset); -exit(); +<?php +require_once ('include/admin.inc.php'); + +$offset = 0; +if (isset($_GET['o'])) $offset = $_GET['o'] + 0; + +$comment_id = ''; +if (isset($_GET['i'])) $comment_id = $_GET['i']; + + +comment_del ($comment_id); + + +mysql_close(); + +Header ('Location: manage_comments.php?d=y&o='.$offset); +exit(); + + +function comment_del ($post_id) { + $query = "delete from ".CFG_MYSQL_TABPREFIX."comments where comment_id = '".$post_id."'"; + $res = mysql_query($query); + //TODO - clear cache? + + +} + + ?> \ No newline at end of file Index: post_edit.php =================================================================== RCS file: /cvsroot/comoblog/comoblog/admin/post_edit.php,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- post_edit.php 5 Jul 2006 00:20:46 -0000 1.11 +++ post_edit.php 22 Oct 2006 11:44:01 -0000 1.12 @@ -2,15 +2,15 @@ require ('include/admin.inc.php'); // date localization -setlocale (LC_TIME, $SET_LOCALE); +setlocale (LC_TIME, $SET_LOCALE); if (strtoupper($_SERVER['REQUEST_METHOD'] == 'POST')) { $errors = array(); foreach ($_POST as $k => $v) - $post[$k] = trim($v); - + $post[$k] = trim($v); + foreach($_POST as $k => $v) { if (substr($k, 0, 11) == 'comment_id_') { $comment_cnt = substr($k, 11); @@ -31,21 +31,21 @@ comment_author='".$comment['comment_author']."' where comment_id=".$comment['comment_id']; echo $query; - $res = mysql_query($query); + $res = mysql_query($query); } } if (substr($k, 0, 9) == 'image_id_') { - + $image_cnt = substr($k, 9); $img = array(); $img['img_id'] = $post['image_id_'.$image_cnt]; $img['file'] = $_FILES['image_file_'.$image_cnt]; $img['delete'] = $post['image_delete_'.$image_cnt]; $img['ext'] = $post['image_ext_'.$image_cnt]; - + // if substitute image if ($img['file']['error'] == 0) { - + $imgsize = @getimagesize($img['file']['tmp_name']); if ($imgsize) { @@ -59,7 +59,7 @@ else { $errors[] = 'Image '.($image_cnt+1).': not supported format (use gif, jpg or png)'; } - + // delete old image @unlink (CFG_BASE_PATH.'/img/posts/'.$img['img_id'].'.'.$img['ext']); if (file_exists(CFG_BASE_PATH.'/img/posts/'.$img['img_id'].'_thumb.'.$img['ext'])) @@ -79,9 +79,9 @@ $res = mysql_query($query); } - + // if delete image - if (count($errors) == 0) { + if (count($errors) == 0) { if ($img['delete'] == $img['img_id']) { @unlink (CFG_BASE_PATH.'/img/posts/'.$img['img_id'].'.'.$img['ext']); if (file_exists(CFG_BASE_PATH.'/img/posts/'.$img['img_id'].'_thumb.'.$img['ext'])) @@ -89,7 +89,7 @@ $query = "delete from ".CFG_MYSQL_TABPREFIX."images where img_id = '".$img['img_id']."'"; $res = mysql_query($query); - + $post['post_images'] -= 1; } } @@ -107,7 +107,7 @@ $title = filter_html($post['post_mail_body']); $post['post_mail_subject'] = substr($title,0,150) ."..."; - } + } // apply post filters if (count($POST_PRE_FILTERS) > 0) { @@ -122,7 +122,7 @@ if ($post['post_date_option'] == "now") { - $post['post_mail_date'] = time(); + $post['post_mail_date'] = time(); } else if ($post['post_date_option'] == "change") { @@ -131,10 +131,10 @@ else { $post['post_mail_date'] = strtotime($post['post_mail_date_orig']); - } + } $query = " - update + update ".CFG_MYSQL_TABPREFIX."posts set post_mail_from = '".$post['post_mail_from'] ."', @@ -142,10 +142,10 @@ post_mail_body = '".$post['post_mail_body'] ."', post_images = '".$post['post_images'] ."', post_mail_date = '".$post['post_mail_date'] ."', - post_ctype = '".$post['post_ctype'] ."', + post_ctype = '".$post['post_ctype'] ."', post_added = '".$post['post_mail_date'] ."', topic_id = '".$post['topic_id'] ."' - where + where post_id = '".$post['post_id'] ."' "; $res = mysql_query($query); @@ -155,8 +155,8 @@ for ($filter_cnt = 0; $filter_cnt < count($POST_POST_FILTERS); $filter_cnt++) { include_once (CFG_BASE_PATH.'/modules/'.$POST_POST_FILTERS[$filter_cnt].'/'.$POST_POST_FILTERS[$filter_cnt].'_post_filter.php'); } - } - + } + echo '<html><head></head><body><script language="javascript">opener.location.reload();this.close();</script></body></html>'; exit(); } @@ -172,7 +172,7 @@ $tpl = new XTemplate('templates/post_edit.tpl.htm'); if (isset($_GET['i'])) $post_id = $_GET['i']; - + $post = post_details($post_id); @@ -195,17 +195,17 @@ on t.img_id = i.img_id order by t.topic_name"; $res = mysql_query($query); - + if (mysql_num_rows($res) > 0) { while ($row = mysql_fetch_assoc($res)) { $tpl->assign('TOPIC', $row); if ($row['topic_id'] == $post['topic_id']) $tpl->parse('main.topics.topic.selected'); - $tpl->parse('main.topics.topic'); + $tpl->parse('main.topics.topic'); } $tpl->parse('main.topics'); } - + if ($post['post_images'] > 0) { $query = " select img_id,img_extension @@ -225,7 +225,7 @@ $tpl->parse('main.images'); } - $comments = comment_list($post_id); + $comments = comment_admin_list($post_id); if ($comments) { for ($c = 0; $c < count($comments); $c++) { @@ -248,4 +248,29 @@ $tpl->parse('main'); $tpl->out('main'); + + +function comment_admin_list ($post_id) { + $query = "select c.* from ".CFG_MYSQL_TABPREFIX."comments c where c.post_id = '".$post_id."' order by c.comment_added "; //TODO:: add param fro . CFG_COMMENT_SORT_ORDER + + error_log($query); + $res = mysql_query($query); + + if (!$res || !mysql_num_rows($res)){ + error_log("RES - " . mysql_errno() . " : " . mysql_error(). " : " .$query . " : " . $res); + return (false); + } + + $c = 0; + while ($row = mysql_fetch_array($res)) { + $comments[$c] = $row; + $comments[$c]['comment_date'] = getdate($row['comment_added']); + if ($comments[$c]['comment_date']['hours'] < 10) $comments[$c]['comment_date']['hours'] = '0'.$comments[$c]['comment_date']['hours']; + if ($comments[$c]['comment_date']['minutes'] < 10) $comments[$c]['comment_date']['minutes'] = '0'.$comments[$c]['comment_date']['minutes']; + error_log("Processed comment " . $c); + $c++; + } + + return ($comments); +} ?> Index: manage_comments.php =================================================================== RCS file: /cvsroot/comoblog/comoblog/admin/manage_comments.php,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- manage_comments.php 16 Aug 2006 01:27:28 -0000 1.1 +++ manage_comments.php 22 Oct 2006 11:44:00 -0000 1.2 @@ -1,13 +1,13 @@ <?php require ('include/admin.inc.php'); -$tpl = new XTemplate ('templates/manage_posts.tpl.htm'); +$tpl = new XTemplate ('templates/manage_comments.tpl.htm'); $offset = 0; -if (isset($_GET['o'])) $offset = $_GET['o'] + 0; +if (isset($_GET['o'])) { $offset = $_GET['o'] + 0;} $delete = 'n'; -if (isset($_GET['d']) && $_GET['d'] == 'y') $delete = 'y'; +if ((isset($_GET['d']) && $_GET['d'] == 'y')) { $delete = 'y';} @@ -16,62 +16,71 @@ -if ($delete == 'y') +if ($delete == 'y'){ $tpl->parse('main.deleted'); - +} $display = 10; -$posts = posts_list ($offset, $display); +$comments = comments_list($offset, $display); -if ($posts) { +if ($comments) { - for ($cnt = 0; $cnt < count($posts); $cnt++) { + for ($cnt = 0; $cnt < count($comments); $cnt++) { if ($cnt % 2) $tpl->assign('BGCOLOR', '#ffffff'); else $tpl->assign('BGCOLOR', '#efefef'); - - $posts[$cnt]['post_mail_from'] = htmlentities(antispam($posts[$cnt]['post_mail_from'])); - $posts[$cnt]['post_mail_date'] = strftime('%D %T',$posts[$cnt]['post_mail_date']); - if ( $posts[$cnt]['post_mail_subject'] == ""){ + + $comments[$cnt]['comment_author'] = htmlentities(antispam($comments[$cnt]['comment_author'])); + $comments[$cnt]['comment_added'] = strftime('%D %T',$comments[$cnt]['comment_added']); + // need to to strip html incase we break across a tag - $title = filter_html($posts[$cnt]['post_mail_body']); - $posts[$cnt]['post_mail_subject'] = substr($title,0,150) ."..." ; + $title = filter_html($comments[$cnt]['comment_text']); + $comments[$cnt]['comment_title'] = substr($title,0,150) ."..." ; + + + if ( $comments[$cnt]['comment_live'] == "Y"){ + // need to to strip html incase we break across a tag + $comments[$cnt]['comment_live'] = "Live"; } - - $tpl->assign('POST', $posts[$cnt]); - $tpl->parse('main.posts.post'); + else{ + $comments[$cnt]['comment_live'] = "Not Live"; + } + + + $tpl->assign('COMMENT', $comments[$cnt]); + $tpl->parse('main.comments.COMMENT'); } - - $howmany = posts_howmany(); + + $howmany = comments_howmany(); $tpl->assign("OFFSET", $offset); $tpl->assign("FIRST", $offset + 1); $tpl->assign("LAST", $offset + $cnt); $tpl->assign("TOTAL", $howmany); - + if ($howmany > ($offset + $display)) { $next_offset = $offset + $display; $tpl->assign("NEXT_OFFSET", $next_offset); - $tpl->parse("main.posts.next"); + $tpl->parse("main.comments.next"); } - + if (($offset - $display) >= 0) { $prev_offset = $offset - $display; $tpl->assign("PREV_OFFSET", $prev_offset); - $tpl->parse("main.posts.prev"); + $tpl->parse("main.comments.prev"); } - $tpl->parse('main.posts'); + $tpl->parse('main.comments'); } else { - $tpl->parse('main.no_posts'); + $tpl->parse('main.no_comments'); } $tpl->parse('main.home'); @@ -81,4 +90,35 @@ // close db connection mysql_close (); + + +function comments_list ($offset, $howmany) { + + if (CFG_USE_PATH_INFO == 'no'){ + $iisbug = '?'; + } + else{ + $iisbug = ''; + } + $query = " + select c.* from ".CFG_MYSQL_TABPREFIX."comments c + order by c.comment_added desc + limit ".$offset.",".$howmany." + "; + $res = mysql_query($query); + + if (!$res || !mysql_num_rows($res)){ + error_log($query); + + return (false); + } + $comments = array(); + while ($row = mysql_fetch_array($res)) { + $comments[] = $row; + } + return ($comments); +} + + + ?> Index: comment_edit.php =================================================================== RCS file: /cvsroot/comoblog/comoblog/admin/comment_edit.php,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- comment_edit.php 16 Aug 2006 01:27:28 -0000 1.1 +++ comment_edit.php 22 Oct 2006 11:44:00 -0000 1.2 @@ -1,251 +1,124 @@ <?php -require ('include/admin.inc.php'); - -// date localization -setlocale (LC_TIME, $SET_LOCALE); +require_once ('include/admin.inc.php'); -if (strtoupper($_SERVER['REQUEST_METHOD'] == 'POST')) { +$offset = 0; +if (isset($_GET['o'])) { $offset = $_GET['o'] + 0;} - $errors = array(); +$comment_id = ''; +if (isset($_GET['i'])) {$comment_id = $_GET['i'];} - foreach ($_POST as $k => $v) - $post[$k] = trim($v); - - foreach($_POST as $k => $v) { - if (substr($k, 0, 11) == 'comment_id_') { - $comment_cnt = substr($k, 11); - $comment = array(); - $comment['comment_id'] = $post['comment_id_'.$comment_cnt]; - $comment['comment_text'] = $post['comment_text_'.$comment_cnt]; - $comment['comment_author'] = $post['comment_author_'.$comment_cnt]; - $comment['comment_delete'] = $post['comment_delete_'.$comment_cnt]; +comment_get($comment_id); - if ($comment['comment_delete'] == $comment['comment_id']) { - $query = "delete from ".CFG_MYSQL_TABPREFIX."comments - where comment_id=".$comment['comment_id']; - $res = mysql_query($query); - } - else { - $query = "update ".CFG_MYSQL_TABPREFIX."comments - set comment_text='".$comment['comment_text']."', - comment_author='".$comment['comment_author']."' - where comment_id=".$comment['comment_id']; -echo $query; - $res = mysql_query($query); - } - } - if (substr($k, 0, 9) == 'image_id_') { - - $image_cnt = substr($k, 9); - $img = array(); - $img['img_id'] = $post['image_id_'.$image_cnt]; - $img['file'] = $_FILES['image_file_'.$image_cnt]; - $img['delete'] = $post['image_delete_'.$image_cnt]; - $img['ext'] = $post['image_ext_'.$image_cnt]; - - // if substitute image - if ($img['file']['error'] == 0) { - - $imgsize = @getimagesize($img['file']['tmp_name']); +$tpl = new XTemplate ("templates/comment_edit.tpl.htm"); +$tpl->assign('TXT', $TXT); - if ($imgsize) { - if ($imgsize[2] == 1) { $ctype = 'image/gif'; $ext = 'gif'; } - elseif($imgsize[2] == 2) { $ctype = 'image/jpg'; $ext = 'jpg'; } - elseif($imgsize[2] == 3) { $ctype = 'image/png'; $ext = 'png'; } - else { - $errors[] = 'Image '.($image_cnt+1).': not supported format (use gif, jpg or png)'; - } - } - else { - $errors[] = 'Image '.($image_cnt+1).': not supported format (use gif, jpg or png)'; - } - - // delete old image - @unlink (CFG_BASE_PATH.'/img/posts/'.$img['img_id'].'.'.$img['ext']); - if (file_exists(CFG_BASE_PATH.'/img/posts/'.$img['img_id'].'_thumb.'.$img['ext'])) - @unlink (CFG_BASE_PATH.'/img/posts/'.$img['img_id'].'_thumb.'.$img['ext']); +$tpl->assign('CFG_BODY_BGCOLOR', CFG_BODY_BGCOLOR); +$tpl->assign('CFG_BACKGROUND_COLOR', CFG_BACKGROUND_COLOR); - // copy new image - move_uploaded_file ($img['file']['tmp_name'], CFG_BASE_PATH.'/img/posts/'.$img['img_id'].'.'.$ext); +$form['comment_id'] = ''; +if(isset($_POST['comment_id'])) $form['comment_id'] = $_POST['comment_id']; +elseif(isset($_GET['i'])) $form['comment_id'] = $_GET['i']; +else exit(); - // create thumbnail - $thumb = create_thumbnail ($img['img_id'], $ext, CFG_IMG_MAX_W, CFG_IMG_MAX_H, CFG_GD_VERSION); +$form['comment_author'] = ''; +if (isset($_POST['comment_author'])) +{ $form['comment_author'] = $_POST['comment_author'];} - // update table - if ($thumb) - $query = "update ".CFG_MYSQL_TABPREFIX."images set img_mime = '".$ctype."', img_extension = '".$ext."', img_thumb = 'Y', img_height = '".$imgsize[1]."', img_width = '".$imgsize[0]."' where img_id = '".$img['img_id']."'"; - else - $query = "update ".CFG_MYSQL_TABPREFIX."images set img_mime = '".$ctype."', img_extension = '".$ext."', img_thumb = 'N', img_height = '', img_width = '' where img_id = '".$img['img_id']."'"; +$form['comment_author_email'] == ''; +if (isset($_POST['comment_author_email'])) +{ $form['comment_author_email'] = $_POST['comment_author_email'];} - $res = mysql_query($query); - } - - // if delete image - if (count($errors) == 0) { - if ($img['delete'] == $img['img_id']) { - @unlink (CFG_BASE_PATH.'/img/posts/'.$img['img_id'].'.'.$img['ext']); - if (file_exists(CFG_BASE_PATH.'/img/posts/'.$img['img_id'].'_thumb.'.$img['ext'])) - @unlink (CFG_BASE_PATH.'/img/posts/'.$img['img_id'].'_thumb.'.$img['ext']); +$form['comment_author_url'] == ''; +if (isset($_POST['comment_author_url'])) +{ $form['comment_author_url'] = $_POST['comment_author_url'];} - $query = "delete from ".CFG_MYSQL_TABPREFIX."images where img_id = '".$img['img_id']."'"; - $res = mysql_query($query); - - $post['post_images'] -= 1; - } - } - } - } +$form['comment_text'] == '';{ +if (isset($_POST['comment_text'])) $form['comment_text'] = $_POST['comment_text'];} - if (count($errors) == 0) { +// addition to allow HTML in comments if flagged - needs an admin option to turn on or off +$form['comment_convert'] == ''; +if (isset($_POST['comment_convert'])) { $form['comment_convert'] = $_POST['comment_convert'];} - foreach($post as $k => $v) { - if (get_magic_quotes_gpc() == 1) - $post[$k] = stripslashes($v); - } - if ($post['post_mail_subject'] == "") { - $title = filter_html($post['post_mail_body']); - $post['post_mail_subject'] = substr($title,0,150) ."..."; - } +if ($_SERVER['REQUEST_METHOD'] == 'POST') { + $errors = array(); - // apply post filters - if (count($POST_PRE_FILTERS) > 0) { - for ($filter_cnt = 0; $filter_cnt < count($POST_PRE_FILTERS); $filter_cnt++) { - include_once (CFG_BASE_PATH.'/modules/'.$POST_PRE_FILTERS[$filter_cnt].'/'.$POST_PRE_FILTERS[$filter_cnt].'_post_filter.php'); - } - } + if ($form['comment_author'] == '') + array_push ($errors, 'Please type your name'); - foreach($post as $k => $v) { - $post[$k] = addslashes($v); - } + if ($form['comment_author_email'] != '' && !is_valid_email($form['comment_author_email'])) + array_push ($errors, 'Invalid email address'); - if ($post['post_date_option'] == "now") - { - $post['post_mail_date'] = time(); - } - else if ($post['post_date_option'] == "change") - { - $post['post_mail_date'] = strtotime($post['post_mail_date']); - } - else - { - $post['post_mail_date'] = strtotime($post['post_mail_date_orig']); - } + if ($form['comment_text'] == '') + array_push ($errors, 'Please write your comment'); - $query = " - update - ".CFG_MYSQL_TABPREFIX."posts - set - post_mail_from = '".$post['post_mail_from'] ."', - post_mail_subject = '".$post['post_mail_subject'] ."', - post_mail_body = '".$post['post_mail_body'] ."', - post_images = '".$post['post_images'] ."', - post_mail_date = '".$post['post_mail_date'] ."', - post_ctype = '".$post['post_ctype'] ."', - post_added = '".$post['post_mail_date'] ."', - topic_id = '".$post['topic_id'] ."' - where - post_id = '".$post['post_id'] ."' - "; - $res = mysql_query($query); + if (count($errors) == 0) { + $comment = $form; - // apply post filters - if (count($POST_POST_FILTERS) > 0) { - for ($filter_cnt = 0; $filter_cnt < count($POST_POST_FILTERS); $filter_cnt++) { - include_once (CFG_BASE_PATH.'/modules/'.$POST_POST_FILTERS[$filter_cnt].'/'.$POST_POST_FILTERS[$filter_cnt].'_post_filter.php'); - } - } - - echo '<html><head></head><body><script language="javascript">opener.location.reload();this.close();</script></body></html>'; + $comment = comment_update ($comment); + Header ("Location: list_comments.php?i=".$comment['comment_id']); exit(); } else { - foreach($errors as $k => $v) { - $tpl->assign('ERROR', $v); - $tpl->parse('main.errors.error'); + foreach ($errors as $key=>$value) { + $tpl->assign("ERROR", $value); + $tpl->parse("main.form_errors.error"); } - $tpl->parse('main.errors'); + $tpl->parse("main.form_errors"); } } -$tpl = new XTemplate('templates/post_edit.tpl.htm'); -if (isset($_GET['i'])) $post_id = $_GET['i']; - -$post = post_details($post_id); +$tpl->assign("ACTION", basename($_SERVER['PHP_SELF'])); -if ($post) { +if (isset($_COOKIE['comment_name'])) + $form['comment_author'] = $_COOKIE['comment_name']; +if (isset($_COOKIE['comment_email'])) + $form['comment_author_email'] = $_COOKIE['comment_email']; +if (isset($_COOKIE['comment_url'])) + $form['comment_author_url'] = $_COOKIE['comment_url']; - $strdate = strftime("%D %H:%M", $post['post_mail_date']); - $post['post_mail_date'] = $strdate; - $post['post_mail_from'] = htmlentities(antispam($post['post_mail_from'])); - $post['post_mail_body'] = htmlentities($post['post_mail_body']); +$tpl->assign("FORM", $form); - $tpl->assign('POST', $post); - // topics - $query = "select t.*, concat(i.img_id,'.',i.img_extension) as img - from ".CFG_MYSQL_TABPREFIX."topics t - left join ".CFG_MYSQL_TABPREFIX."images i - on t.img_id = i.img_id - order by t.topic_name"; - $res = mysql_query($query); - - if (mysql_num_rows($res) > 0) { - while ($row = mysql_fetch_assoc($res)) { - $tpl->assign('TOPIC', $row); - if ($row['topic_id'] == $post['topic_id']) - $tpl->parse('main.topics.topic.selected'); - $tpl->parse('main.topics.topic'); - } - $tpl->parse('main.topics'); - } - - if ($post['post_images'] > 0) { - $query = " - select img_id,img_extension - from ".CFG_MYSQL_TABPREFIX."images - where post_id = '".$post_id."' - "; - $res = mysql_query($query); - $i = 0; - while ($row = mysql_fetch_array($res)) { - $tpl->assign('COUNTER', $i); - $tpl->assign('COUNTER_TXT', $i + 1); - $tpl->assign('IMAGE', $row); - $tpl->parse('main.images.image'); - $i++; - } - $tpl->parse('main.images'); - } - $comments = comment_list($post_id); +$tpl->parse("main"); +$tpl->out("main"); - if ($comments) { - for ($c = 0; $c < count($comments); $c++) { - $comments[$c]['comment_author_email'] = antispam ($comments[$c]['comment_a -uthor_email'], true); - $tpl->assign("COMMENT", $comments[$c]); - $tpl->assign("COUNTER", $c); - if ($comments[$c]['comment_author_email'] != '') - $tpl->parse("main.comments.comment.email"); - $tpl->parse("main.comments.comment"); - } - $tpl->parse("main.comments"); + +mysql_close(); +function comment_get ($comment_id) { + $query = "select c.* from ".CFG_MYSQL_TABPREFIX."comments c where c.comment_id = '".$comment_id."'"; + + error_log($query); + $res = mysql_query($query); + + if (!$res || !mysql_num_rows($res)){ + error_log("RES - " . mysql_errno() . " : " . mysql_error(). " : " .$query . " : " . $res); + return (false); } + + $c = 0; + while ($row = mysql_fetch_array($res)) { + $comments[$c] = $row; + $comments[$c]['comment_date'] = getdate($row['comment_added']); + if ($comments[$c]['comment_date']['hours'] < 10) $comments[$c]['comment_date']['hours'] = '0'.$comments[$c]['comment_date']['hours']; + if ($comments[$c]['comment_date']['minutes'] < 10) $comments[$c]['comment_date']['minutes'] = '0'.$comments[$c]['comment_date']['minutes']; + error_log("Processed comment " . $c); + $c++; + } + + return ($comments); } -$tpl->assign('ACTION', basename($_SERVER['PHP_SELF'])); -$tpl->parse('main'); -$tpl->out('main'); -?> +?> \ No newline at end of file Index: manage_modules.php =================================================================== RCS file: /cvsroot/comoblog/comoblog/admin/manage_modules.php,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- manage_modules.php 18 Nov 2005 08:24:51 -0000 1.3 +++ manage_modules.php 22 Oct 2006 11:44:00 -0000 1.4 @@ -1,264 +1,264 @@ -<?php -require ('include/admin.inc.php'); -require ('include/modules.inc.php'); - -$tpl = new XTemplate ('templates/manage_modules.tpl.htm'); - -/* - check if there are new modules to be installed - */ - require('include/xml2array.inc.php'); - - $new = 0; - $upgrade = 0; - $failed = 0; - if ($dir = @opendir('../modules')) { - while (($file = readdir($dir)) !== false) { - if (substr($file,0,4) == 'mod_' && is_dir('../modules/'.$file)) { - $query = "select mod_name,mod_version from ".CFG_MYSQL_TABPREFIX."modules where mod_name = '".$file."'"; - $res = mysql_query($query); - $install_file = '../modules/'.$file.'/install/'.$file.'.xml'; - $new_version = get_module_version_from_xml($install_file); - if (mysql_num_rows($res) == 0 && file_exists($install_file)) { // found new module!!! - $module_install = module_install($file); // install it - if ($module_install) { - $tpl->assign('MOD_NAME', $file); - $tpl->assign('ERROR', $module_install); - $tpl->parse('main.failed.module'); - $failed += 1; - } - else { // installed! - $tpl->assign('MOD_NAME', $file); - $tpl->parse('main.installed.module'); - $new += 1; - } - } - else { - $old_version = mysql_result($res, 0, 'mod_version'); - if ($old_version < $new_version) { - $module_install = module_install($file); // upgrade it - if ($module_install) { - $tpl->assign('MOD_NAME', $file); - $tpl->assign('ERROR', $module_install); - $tpl->parse('main.failed.module'); - $failed += 1; - } - else { // installed! - $tpl->assign('MOD_NAME', $file); - $tpl->parse('main.upgraded.module'); - $upgrade += 1; - } - } - } - } - } - closedir($dir); - } - - if ($new > 0) // if new modules were installed - $tpl->parse('main.installed'); - - if ($upgrade > 0) - $tpl->parse('main.upgraded'); - - if ($failed > 0) // if new modules failed to install - $tpl->parse('main.failed'); - - -/* - */ - - - -/* - list of available modules - */ - -$counter = 0; -$uncertified_found = false; - -$modules = module_list ('top'); -if ($modules) { - for ($m = 0; $m < count($modules); $m++) { - if ($m % 2) - $tpl->assign('BGCOLOR', '#ffffff'); - else - $tpl->assign('BGCOLOR', '#efefef'); - - $allowed_pos = explode('|', $modules[$m]['mod_allowed_pos']); - for ($p = 0; $p < count($allowed_pos); $p++) { - $tpl->assign('POS', $allowed_pos[$p]); - if ($modules[$m]['mod_pos'] == $allowed_pos[$p]) - $tpl->parse('main.modules.module.pos.selected'); - - $tpl->parse('main.modules.module.pos'); - } - - $tpl->assign('COUNTER', $counter); - $tpl->assign('MODULE', $modules[$m]); - - if ($m == 0 && count($modules) > 1) { - $tpl->parse('main.modules.module.down'); - } - elseif ($m == count($modules)-1 && count($modules) > 1) { - $tpl->parse('main.modules.module.up'); - } - elseif (count($modules) > 1) { - $tpl->parse('main.modules.module.down'); - $tpl->parse('main.modules.module.up'); - } - - if (!is_module_certified($modules[$m]['mod_name'])) { - $uncertified_found = true; - $tpl->parse('main.modules.module.uncertified'); - } - - $tpl->parse('main.modules.module'); - - $counter++; - } - $tpl->parse('main.modules'); - - -} - - - -$modules = module_list ('sidebar'); -if ($modules) { - for ($m = 0; $m < count($modules); $m++) { - if ($m % 2) - $tpl->assign('BGCOLOR', '#ffffff'); - else - $tpl->assign('BGCOLOR', '#efefef'); - - $allowed_pos = explode('|', $modules[$m]['mod_allowed_pos']); - for ($p = 0; $p < count($allowed_pos); $p++) { - $tpl->assign('POS', $allowed_pos[$p]); - - if ($modules[$m]['mod_pos'] == $allowed_pos[$p]) - $tpl->parse('main.modules.module.pos.selected'); - - $tpl->parse('main.modules.module.pos'); - } - - $tpl->assign('COUNTER', $counter); - $tpl->assign('MODULE', $modules[$m]); - - if ($m == 0 && count($modules) > 1) { - $tpl->parse('main.modules.module.down'); - } - elseif ($m == count($modules)-1 && count($modules) > 1) { - $tpl->parse('main.modules.module.up'); - } - elseif (count($modules) > 1) { - $tpl->parse('main.modules.module.down'); - $tpl->parse('main.modules.module.up'); - } - - if (!is_module_certified($modules[$m]['mod_name'])) { - $uncertified_found = true; - $tpl->parse('main.modules.module.uncertified'); - } - - $tpl->parse('main.modules.module'); - - $counter++; - } - $tpl->parse('main.modules'); -} - - - - -$modules = module_list ('not_visible'); -if ($modules) { - for ($m = 0; $m < count($modules); $m++) { - if ($m % 2) - $tpl->assign('BGCOLOR', '#ffffff'); - else - $tpl->assign('BGCOLOR', '#efefef'); - - $allowed_pos = explode('|', $modules[$m]['mod_allowed_pos']); - for ($p = 0; $p < count($allowed_pos); $p++) { - $tpl->assign('POS', $allowed_pos[$p]); - if ($modules[$m]['mod_pos'] == $allowed_pos[$p]) - $tpl->parse('main.modules.module.pos.selected'); - - $tpl->parse('main.modules.module.pos'); - } - - $tpl->assign('COUNTER', $counter); - $tpl->assign('MODULE', $modules[$m]); - - if ($m == 0 && count($modules) > 1) { - $tpl->parse('main.modules.module.down'); - } - elseif ($m == count($modules)-1 && count($modules) > 1) { - $tpl->parse('main.modules.module.up'); - } - elseif (count($modules) > 1) { - $tpl->parse('main.modules.module.down'); - $tpl->parse('main.modules.module.up'); - } - - if (!is_module_certified($modules[$m]['mod_name'])) { - $uncertified_found = true; - $tpl->parse('main.modules.module.uncertified'); - } - - $tpl->parse('main.modules.module'); - - $counter++; - } - $tpl->parse('main.modules'); - - -} - - - - -$modules = module_list (''); -if ($modules) { - for ($m = 0; $m < count($modules); $m++) { - if ($m % 2) - $tpl->assign('BGCOLOR', '#ffffff'); - else - $tpl->assign('BGCOLOR', '#efefef'); - - $allowed_pos = explode('|', $modules[$m]['mod_allowed_pos']); - - $tpl->parse('main.modules.module.pos_inactive'); - for ($p = 0; $p < count($allowed_pos); $p++) { - $tpl->assign('POS', $allowed_pos[$p]); - $tpl->parse('main.modules.module.pos'); - } - - if (!is_module_certified($modules[$m]['mod_name'])) { - $uncertified_found = true; - $tpl->parse('main.modules.module.uncertified'); - } - - $tpl->assign('COUNTER', $counter); - $tpl->assign('MODULE', $modules[$m]); - $tpl->parse('main.modules.module'); - - $counter++; - } - $tpl->parse('main.modules'); -} -/* - */ - -if ($uncertified_found == true) - $tpl->parse('main.uncertified_warning'); - -$tpl->assign('ACTION', 'module_pos.php'); - -$tpl->parse('main.home'); -$tpl->parse('main'); -$tpl->out('main'); - -mysql_close(); -?> +<?php +require ('include/admin.inc.php'); +require ('include/modules.inc.php'); + +$tpl = new XTemplate ('templates/manage_modules.tpl.htm'); + +/* + check if there are new modules to be installed + */ + require_once('include/xml2array.inc.php'); + + $new = 0; + $upgrade = 0; + $failed = 0; + if ($dir = @opendir('../modules')) { + while (($file = readdir($dir)) !== false) { + if (substr($file,0,4) == 'mod_' && is_dir('../modules/'.$file)) { + $query = "select mod_name,mod_version from ".CFG_MYSQL_TABPREFIX."modules where mod_name = '".$file."'"; + $res = mysql_query($query); + $install_file = '../modules/'.$file.'/install/'.$file.'.xml'; + $new_version = get_module_version_from_xml($install_file); + if (mysql_num_rows($res) == 0 && file_exists($install_file)) { // found new module!!! + $module_install = module_install($file); // install it + if ($module_install) { + $tpl->assign('MOD_NAME', $file); + $tpl->assign('ERROR', $module_install); + $tpl->parse('main.failed.module'); + $failed += 1; + } + else { // installed! + $tpl->assign('MOD_NAME', $file); + $tpl->parse('main.installed.module'); + $new += 1; + } + } + else { + $old_version = mysql_result($res, 0, 'mod_version'); + if ($old_version < $new_version) { + $module_install = module_install($file); // upgrade it + if ($module_install) { + $tpl->assign('MOD_NAME', $file); + $tpl->assign('ERROR', $module_install); + $tpl->parse('main.failed.module'); + $failed += 1; + } + else { // installed! + $tpl->assign('MOD_NAME', $file); + $tpl->parse('main.upgraded.module'); + $upgrade += 1; + } + } + } + } + } + closedir($dir); + } + + if ($new > 0) // if new modules were installed + $tpl->parse('main.installed'); + + if ($upgrade > 0) + $tpl->parse('main.upgraded'); + + if ($failed > 0) // if new modules failed to install + $tpl->parse('main.failed'); + + +/* + */ + + + +/* + list of available modules + */ + +$counter = 0; +$uncertified_found = false; + +$modules = module_list ('top'); +if ($modules) { + for ($m = 0; $m < count($modules); $m++) { + if ($m % 2) + $tpl->assign('BGCOLOR', '#ffffff'); + else + $tpl->assign('BGCOLOR', '#efefef'); + + $allowed_pos = explode('|', $modules[$m]['mod_allowed_pos']); + for ($p = 0; $p < count($allowed_pos); $p++) { + $tpl->assign('POS', $allowed_pos[$p]); + if ($modules[$m]['mod_pos'] == $allowed_pos[$p]) + $tpl->parse('main.modules.module.pos.selected'); + + $tpl->parse('main.modules.module.pos'); + } + + $tpl->assign('COUNTER', $counter); + $tpl->assign('MODULE', $modules[$m]); + + if ($m == 0 && count($modules) > 1) { + $tpl->parse('main.modules.module.down'); + } + elseif ($m == count($modules)-1 && count($modules) > 1) { + $tpl->parse('main.modules.module.up'); + } + elseif (count($modules) > 1) { + $tpl->parse('main.modules.module.down'); + $tpl->parse('main.modules.module.up'); + } + + if (!is_module_certified($modules[$m]['mod_name'])) { + $uncertified_found = true; + $tpl->parse('main.modules.module.uncertified'); + } + + $tpl->parse('main.modules.module'); + + $counter++; + } + $tpl->parse('main.modules'); + + +} + + + +$modules = module_list ('sidebar'); +if ($modules) { + for ($m = 0; $m < count($modules); $m++) { + if ($m % 2) + $tpl->assign('BGCOLOR', '#ffffff'); + else + $tpl->assign('BGCOLOR', '#efefef'); + + $allowed_pos = explode('|', $modules[$m]['mod_allowed_pos']); + for ($p = 0; $p < count($allowed_pos); $p++) { + $tpl->assign('POS', $allowed_pos[$p]); + + if ($modules[$m]['mod_pos'] == $allowed_pos[$p]) + $tpl->parse('main.modules.module.pos.selected'); + + $tpl->parse('main.modules.module.pos'); + } + + $tpl->assign('COUNTER', $counter); + $tpl->assign('MODULE', $modules[$m]); + + if ($m == 0 && count($modules) > 1) { + $tpl->parse('main.modules.module.down'); + } + elseif ($m == count($modules)-1 && count($modules) > 1) { + $tpl->parse('main.modules.module.up'); + } + elseif (count($modules) > 1) { + $tpl->parse('main.modules.module.down'); + $tpl->parse('main.modules.module.up'); + } + + if (!is_module_certified($modules[$m]['mod_name'])) { + $uncertified_found = true; + $tpl->parse('main.modules.module.uncertified'); + } + + $tpl->parse('main.modules.module'); + + $counter++; + } + $tpl->parse('main.modules'); +} + + + + +$modules = module_list ('not_visible'); +if ($modules) { + for ($m = 0; $m < count($modules); $m++) { + if ($m % 2) + $tpl->assign('BGCOLOR', '#ffffff'); + else + $tpl->assign('BGCOLOR', '#efefef'); + + $allowed_pos = explode('|', $modules[$m]['mod_allowed_pos']); + for ($p = 0; $p < count($allowed_pos); $p++) { + $tpl->assign('POS', $allowed_pos[$p]); + if ($modules[$m]['mod_pos'] == $allowed_pos[$p]) + $tpl->parse('main.modules.module.pos.selected'); + + $tpl->parse('main.modules.module.pos'); + } + + $tpl->assign('COUNTER', $counter); + $tpl->assign('MODULE', $modules[$m]); + + if ($m == 0 && count($modules) > 1) { + $tpl->parse('main.modules.module.down'); + } + elseif ($m == count($modules)-1 && count($modules) > 1) { + $tpl->parse('main.modules.module.up'); + } + elseif (count($modules) > 1) { + $tpl->parse('main.modules.module.down'); + $tpl->parse('main.modules.module.up'); + } + + if (!is_module_certified($modules[$m]['mod_name'])) { + $uncertified_found = true; + $tpl->parse('main.modules.module.uncertified'); + } + + $tpl->parse('main.modules.module'); + + $counter++; + } + $tpl->parse('main.modules'); + + +} + + + + +$modules = module_list (''); +if ($modules) { + for ($m = 0; $m < count($modules); $m++) { + if ($m % 2) + $tpl->assign('BGCOLOR', '#ffffff'); + else + $tpl->assign('BGCOLOR', '#efefef'); + + $allowed_pos = explode('|', $modules[$m]['mod_allowed_pos']); + + $tpl->parse('main.modules.module.pos_inactive'); + for ($p = 0; $p < count($allowed_pos); $p++) { + $tpl->assign('POS', $allowed_pos[$p]); + $tpl->parse('main.modules.module.pos'); + } + + if (!is_module_certified($modules[$m]['mod_name'])) { + $uncertified_found = true; + $tpl->parse('main.modules.module.uncertified'); + } + + $tpl->assign('COUNTER', $counter); + $tpl->assign('MODULE', $modules[$m]); + $tpl->parse('main.modules.module'); + + $counter++; + } + $tpl->parse('main.modules'); +} +/* + */ + +if ($uncertified_found == true) + $tpl->parse('main.uncertified_warning'); + +$tpl->assign('ACTION', 'module_pos.php'); + +$tpl->parse('main.home'); +$tpl->parse('main'); +$tpl->out('main'); + +mysql_close(); +?> |