[Comoblog-commit] comoblog/admin comment_del.php, NONE, 1.1 comment_edit.php, NONE, 1.1 manage_comm
Status: Inactive
Brought to you by:
markwallis
|
From: iamdecal <iam...@us...> - 2006-08-16 01:27:33
|
Update of /cvsroot/comoblog/comoblog/admin In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv8431/admin Added Files: comment_del.php comment_edit.php manage_comment_users.php manage_comments.php Log Message: place holder admin php and templates for editing comments and commenters --- NEW FILE: manage_comment_users.php --- <?php require ('include/admin.inc.php'); $tpl = new XTemplate ('templates/manage_posts.tpl.htm'); $offset = 0; if (isset($_GET['o'])) $offset = $_GET['o'] + 0; $delete = 'n'; if (isset($_GET['d']) && $_GET['d'] == 'y') $delete = 'y'; if ($delete == 'y') $tpl->parse('main.deleted'); $display = 10; $posts = posts_list ($offset, $display); if ($posts) { for ($cnt = 0; $cnt < count($posts); $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'] == ""){ // 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) ."..." ; } $tpl->assign('POST', $posts[$cnt]); $tpl->parse('main.posts.post'); } $howmany = posts_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"); } if (($offset - $display) >= 0) { $prev_offset = $offset - $display; $tpl->assign("PREV_OFFSET", $prev_offset); $tpl->parse("main.posts.prev"); } $tpl->parse('main.posts'); } else { $tpl->parse('main.no_posts'); } $tpl->parse('main.home'); $tpl->parse('main'); $tpl->out('main'); // close db connection mysql_close (); ?> --- NEW FILE: comment_del.php --- <?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(); ?> --- NEW FILE: comment_edit.php --- <?php require ('include/admin.inc.php'); // date localization setlocale (LC_TIME, $SET_LOCALE); if (strtoupper($_SERVER['REQUEST_METHOD'] == 'POST')) { $errors = array(); 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]; 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']); 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']); // copy new image move_uploaded_file ($img['file']['tmp_name'], CFG_BASE_PATH.'/img/posts/'.$img['img_id'].'.'.$ext); // create thumbnail $thumb = create_thumbnail ($img['img_id'], $ext, CFG_IMG_MAX_W, CFG_IMG_MAX_H, CFG_GD_VERSION); // 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']."'"; $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']); $query = "delete from ".CFG_MYSQL_TABPREFIX."images where img_id = '".$img['img_id']."'"; $res = mysql_query($query); $post['post_images'] -= 1; } } } } if (count($errors) == 0) { 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) ."..."; } // 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'); } } foreach($post as $k => $v) { $post[$k] = addslashes($v); } 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']); } $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); // 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>'; exit(); } else { foreach($errors as $k => $v) { $tpl->assign('ERROR', $v); $tpl->parse('main.errors.error'); } $tpl->parse('main.errors'); } } $tpl = new XTemplate('templates/post_edit.tpl.htm'); if (isset($_GET['i'])) $post_id = $_GET['i']; $post = post_details($post_id); if ($post) { $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('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); 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"); } } $tpl->assign('ACTION', basename($_SERVER['PHP_SELF'])); $tpl->parse('main'); $tpl->out('main'); ?> --- NEW FILE: manage_comments.php --- <?php require ('include/admin.inc.php'); $tpl = new XTemplate ('templates/manage_posts.tpl.htm'); $offset = 0; if (isset($_GET['o'])) $offset = $_GET['o'] + 0; $delete = 'n'; if (isset($_GET['d']) && $_GET['d'] == 'y') $delete = 'y'; if ($delete == 'y') $tpl->parse('main.deleted'); $display = 10; $posts = posts_list ($offset, $display); if ($posts) { for ($cnt = 0; $cnt < count($posts); $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'] == ""){ // 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) ."..." ; } $tpl->assign('POST', $posts[$cnt]); $tpl->parse('main.posts.post'); } $howmany = posts_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"); } if (($offset - $display) >= 0) { $prev_offset = $offset - $display; $tpl->assign("PREV_OFFSET", $prev_offset); $tpl->parse("main.posts.prev"); } $tpl->parse('main.posts'); } else { $tpl->parse('main.no_posts'); } $tpl->parse('main.home'); $tpl->parse('main'); $tpl->out('main'); // close db connection mysql_close (); ?> |