Location: PHPKode > projects > Bloggie Lite > admin/edit_list.php
<?

// Copyright (C) Bloggie Lite Written by : Sean
// http://www.mywebland.com , http://mybloggie.mywebland.com

// You are requested to retain this copyright notice in order to use
// this software.

//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either version 2
//of the License, or (at your option) any later version.

//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

if ( !defined('IN_BLOGGIE') )
{
    die("You are not allowed to access this page directly !");
}

if (!authenticate()) {
    error($lang['Error'], "Request terminated due to abnormal operations");
}


$pno = ( isset($_GET['pno']) ) ? intval($_GET['pno']) : 0;
$editlimt = ( isset($_GET['limit']) ) ? intval($_GET['limit']) : 0;
if ( isset($_GET['action']) ) $action = $_GET['action'];
$post_id = ( isset($_GET['post_id']) ) ? intval($_GET['post_id']) : 0;
if ( !isset($editlimit) ) $editlimit = 5;

if (isset($_POST['delete'])) {
//if($delete){

if  (isset($_POST['checkbox'])) { $checkbox = $_POST['checkbox'] ;  }
//print_r  ($checkbox) ;
$del_id = $_POST['checkbox'];

    for ($i=0; $i<count($del_id); $i++ ) {
  //for ($i=0; $i<count($checkbox); $i++ ) {
     if ($userlevel==1) {
        echo  "Deleted :".$del_id[$i] ;
        $sql = "DELETE FROM ".POST_TBL." WHERE post_id='$del_id[$i]'";
        } elseif ($userlevel==2) {
        $sql = "DELETE FROM ".POST_TBL." WHERE post_id='$del_id[$i]' AND id='$userid'";
        }
        if( !($result = $db->sql_query($sql)) )
           {
            $sql_error = $db->sql_error();
            echo $sql_error['message'];
           }
        $template->assign_block_vars('status', array(
            'STATUS'          => $lang['Post_Del_Info'],
        ));
   }
}

if (isset($action)) {

    switch ($action) {
    case "del":
     if ($userlevel==1) {
        $sql = "DELETE FROM ".POST_TBL." WHERE post_id='$post_id'";
        } elseif ($userlevel==2) {
        $sql = "DELETE FROM ".POST_TBL." WHERE post_id='$post_id' AND id='$userid'";
        }
        if( !($result = $db->sql_query($sql)) )
           {
            $sql_error = $db->sql_error();
            echo $sql_error['message'];
           } else
           {
              $template->assign_block_vars('status', array(
               'STATUS'          => $lang['Post_Del_Info']." id # ".$post_id,
               ));
           }

    break;
    default:
    $template->assign_vars(array(
     'VERSION_INFO'      => versioncheck($pref_data['version']),
    ));
    $template->pparse('admincontent') ; break;
    }
}

$sql = "SELECT post_id FROM " . POST_TBL;
if ( !($result = $db->sql_query($sql)) )
    { $sql_error = $db->sql_error();  echo $sql_error['message']; }

$row= ( $db->sql_numrows($result) ) ? $db->sql_numrows($result) : 0;

$pagination = pagination("","./admin.php?mode=editlist",$row , $editlimit, $pno);
if ($userlevel==1) {
$sql = "SELECT ".CAT_TBL.".cat_desc, ".POST_TBL.".cat_id, ".CAT_TBL.".cat_id, ".POST_TBL.".post_id, ".POST_TBL.".subject,".POST_TBL.".message, ".USER_TBL.".user, ".POST_TBL.".timestamp, ".USER_TBL.".id, ".POST_TBL.".user_id FROM ".POST_TBL.", ".USER_TBL.", ".CAT_TBL."
WHERE ".POST_TBL.".user_id=".USER_TBL.".id  AND  ".CAT_TBL.".cat_id=".POST_TBL.".cat_id
Order by  ".POST_TBL.".timestamp DESC, ".POST_TBL.".post_id DESC
LIMIT ".$pno." , ".$editlimit;
} elseif ($userlevel==2) {
$sql = "SELECT ".CAT_TBL.".cat_desc, ".POST_TBL.".cat_id, ".CAT_TBL.".cat_id, ".POST_TBL.".post_id, ".POST_TBL.".subject,".POST_TBL.".message, ".USER_TBL.".user, ".POST_TBL.".timestamp, ".USER_TBL.".id, ".POST_TBL.".user_id FROM ".POST_TBL.", ".USER_TBL.", ".CAT_TBL."
WHERE ".POST_TBL.".user_id=".USER_TBL.".id  AND  ".CAT_TBL.".cat_id=".POST_TBL.".cat_id, ".POST_TBL.".user_id='$userid'
Order by  ".POST_TBL.".timestamp DESC, ".POST_TBL.".post_id DESC
LIMIT ".$pno." , ".$editlimit;
}


$result = $db->sql_query($sql) ;
$n = 0;
while ($row = $db->sql_fetchrow($result)) {

/// Query for No of Comments/Trackbacks //
$querycomment  = "SELECT comment_id FROM ".COMMENT_TBL."
WHERE ".COMMENT_TBL.".post_id = '".$row['post_id']."'";

if ( !($commentresult = $db->sql_query($querycomment)) )
    {
    $sql_error = $db->sql_error();
    echo $sql_error['message'];
    }
$nocom = $db->sql_numrows($commentresult) ;

$post_id = $row['post_id'];
$cat_id = $row['cat_id'];
$time = date("H:i", $row['timestamp']) ;
$date = date("d M Y", $row['timestamp']) ;

$template->assign_vars(array(
          'PAGE'             => $pagination,
          'L_CHECK_ALL'      => $lang['Check_All'],
           'L_ACTION'         => $lang['Action'],
           'L_DELETE'         => $lang['Delete'] ,
          'DEL_CONF'         => $lang['Delete_Confirmation'],
          'APP_CONF'         => $lang['Approve_Confirmation'],
           ));


if ( $n % 2 ) { $alt_clr =" class=\"whitebg\""; } else { $alt_clr = " class=\"greybg\""; }

$template->assign_block_vars('listing', array(
          'ALT_CLR'          => $alt_clr,
          'POSTER_NAME'      => $row['user'],
          'SUBJECT'          => "<a class=\"lblock\" href=\"../index.php?mode=read&post_id=".$post_id."\" target=\"_blank\">".$row['subject']."</a>",
          'CATEGORY'         => $row['cat_desc'],
          'COMMENTS'         => "<a class=\"block\" href=\"".$_SERVER['PHP_SELF']."?mode=clist&amp;post_id=".$post_id."\">".$nocom."</a>",
          'ID'               => $post_id ,
          'TIME'             => $time ,
          'DATE'             => $date.", ".$time ,
          'U_EDIT'           => "<a class=\"block\" href=\"".$_SERVER['PHP_SELF']."?mode=edit&cat_id=".$cat_id."&amp;post_id=".$post_id."\">".$lang['Edit']."</a>",
          'L_DEL'            => $lang['Del'] ,
          //'U_DELETE'         => "<a class=\"block\" href=\"".$_SERVER['PHP_SELF']."?mode=del&post_id=".$post_id."\">".$lang['Del']."</a>" ,
          'DEL_CHECKBOX_ID'  => $post_id,
          'DEL_CONF'         => $lang['Delete_Confirmation'],
          'APP_CONF'         => $lang['Approve_Confirmation'],
 )
 );
$n++;
}
$template->pparse('list');
//          'SUBJECT'          => "<a href=\"javascript:void(window.open('./index.php?mode=viewid&post_id=".$post_id."', 'display1', 'left=50,top=50,resizable=yes,scrollbars=yes,width=760,height=450'))\">".$row['subject']."</a>",

?>
Return current item: Bloggie Lite