[ PHPXref.com ] [ Generated: Sun Jul 20 16:35:25 2008 ] [ bBlog 0.7.6 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/bblog/bBlog_plugins/ -> builtin.archives.php (source)

   1  <?php
   2  // admin.archives.php - handles showing a list of entries to edit/delete
   3  /*
   4  ** bBlog Weblog http://www.bblog.com/
   5  ** Copyright (C) 2003  Eaden McKee <email@eadz.co.nz>
   6  **
   7  ** This program is free software; you can redistribute it and/or modify
   8  ** it under the terms of the GNU General Public License as published by
   9  ** the Free Software Foundation; either version 2 of the License, or
  10  ** (at your option) any later version.
  11  **
  12  ** This program is distributed in the hope that it will be useful,
  13  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  14  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15  ** GNU General Public License for more details.
  16  **
  17  ** You should have received a copy of the GNU General Public License
  18  ** along with this program; if not, write to the Free Software
  19  ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  20  */
  21  
  22  // now it may be an idea to do a if(!defined('IN_BBLOG')) die "hacking attempt" type thing but
  23  // i'm not sure it's needed, as without this file being included it hasn't connected to the
  24  // database, and all the functions it calls are in the $bBlog object.
  25  function identify_admin_archives () 
  26  {
  27    return array (
  28      'name'           =>'archives',
  29      'type'           =>'builtin',
  30      'nicename'       =>'Archives Admin',
  31      'description'    =>'Edit archives',
  32      'authors'         =>'Eaden McKee, Tobias Schlottke',
  33      'licence'         =>'GPL'
  34    );
  35  }
  36  
  37  $bBlog->assign('form_type','edit');
  38  $bBlog->get_modifiers();
  39  
  40  if (isset($_GET['delete']) or isset($_POST['delete'])) 
  41      {
  42      if ($_POST['confirm'] == "cd".$_POST['delete'] && is_numeric($_POST['delete'])) 
  43      {
  44          $res = $bBlog->delete_post($_POST['delete']);
  45          $bBlog->assign('showmessage',TRUE);
  46          $bBlog->assign('message_title','Message Deleted');
  47          $bBlog->assign('message_content','The message you selected has now been deleted'); // -1 Redundant  ;)
  48      }
  49      else 
  50      {
  51          $bBlog->assign('showmessage',TRUE);
  52          $bBlog->assign('message_title','Are you sure you want to delete it?');
  53          $bBlog->assign('message_content',"
  54              <form action='index.php' method='POST'>
  55              <input type='hidden' name='b' value='archives'>
  56              <input type='hidden' name='confirm' value='cd".$_POST['delete']."'>
  57              <input type='hidden' name='delete' value='".$_POST['delete']."'>
  58              <center><input type='submit' class='bf' name='submit' value='Delete it'></center>
  59              </form>
  60          ");
  61      }
  62  }
  63  
  64  if (isset($_POST['edit']) && is_numeric($_POST['edit'])) 
  65  {
  66      $epost = $bBlog->get_post($_POST['edit'],TRUE,TRUE);
  67      $bBlog->assign('title_text',htmlspecialchars($epost->title));
  68      $bBlog->assign('body_text',htmlspecialchars($epost->body));
  69      $bBlog->assign('selected_modifier',$epost->modifier);
  70      $bBlog->assign('editpost',TRUE);
  71      $bBlog->assign('showarchives','no');
  72      $bBlog->assign('postid',$_POST['edit']);
  73      $bBlog->assign('timestampform',timestAmpform($epost->posttime));
  74  
  75      // to hide a post from the homepage
  76      if($epost->hidefromhome == 1) $bBlog->assign('hidefromhomevalue'," checked='checked' ");
  77  
  78      // to disable comments either now or in the future
  79      if($epost->allowcomments == 'timed') $bBlog->assign('commentstimedvalue'," checked='checked' ");
  80      elseif($epost->allowcomments == 'disallow') $bBlog->assign('commentsdisallowvalue'," checked='checked' ");
  81      else $bBlog->assign('commentsallowvalue'," checked='checked' ");
  82  
  83  
  84      if($epost->status == 'draft') $bBlog->assign('statusdraft','checked="checked"');
  85      else $bBlog->assign('statuslive','checked="checked"');
  86  
  87      $_post_secs = explode(":",$epost->sections);
  88  
  89      if(is_array($_post_secs))
  90      {
  91          foreach($_post_secs as $_post_sec)
  92          {
  93              $editpostsections[$_post_sec] = TRUE;
  94          }
  95          $bBlog->assign('editpostsections',$editpostsections);
  96      }
  97  
  98      $sects = $bBlog->sections;
  99      $nsects = array();
 100  
 101      foreach($sects as $sect)
 102      {
 103         if(isset($editpostsections[$sect->sectionid])) $sect->checked = TRUE;
 104         $nsects[] = $sect;
 105      }
 106  
 107      $bBlog->assign("sections",$nsects);
 108      $bBlog->assign_by_ref("sections",$nsects);
 109  }
 110  
 111  if ((isset($_POST['postedit'])) && ($_POST['postedit'] == 'true'))
 112  {
 113      // a post to be editited has been submitted
 114      if ((isset($_POST['postedit'])) && (!is_numeric($_POST['postid'])))
 115      {
 116          echo "Provided PostID value is not a Post ID. (Fatal error)";
 117          die;
 118      }
 119  
 120      $newsections = '';
 121  
 122      if ((isset($_POST['sections'])) && (sizeof($_POST['sections']) > 0))
 123      {
 124          $newsections = implode(":",$_POST['sections']);
 125      }
 126  
 127      if ((isset($_POST['edit_timestamp'])) && ($_POST['edit_timestamp'] == 'TRUE'))
 128      {
 129          // the timestamp will be changed.
 130          if (!isset($_POST['ts_day']))       { $_POST['ts_day']      = 0;    }
 131          if (!isset($_POST['ts_month']))     { $_POST['ts_month']    = 0;    }
 132          if (!isset($_POST['ts_year']))      { $_POST['ts_year']     = 0;    }
 133          if (!isset($_POST['ts_hour']))      { $_POST['ts_hour']     = 0;    }
 134          if (!isset($_POST['ts_minute']))    { $_POST['ts_minute']   = 0;    }
 135  
 136          $timestamp = maketimestamp($_POST['ts_day'],$_POST['ts_month'],$_POST['ts_year'],$_POST['ts_hour'],$_POST['ts_minute']);
 137      }
 138      else
 139      {
 140          $timestamp = FALSE;
 141      }
 142  
 143      if($_POST['hidefromhome'] == 'hide') $hidefromhome='hide';
 144          else $hidefromhome='donthide';
 145      // there is a reason for not using booleans here.
 146      // is because the bBlog->edit_post function needs to know if to change it or not.
 147  
 148       $disdays = (int)$_POST['disallowcommentsdays'];
 149       $time = (int)time();
 150       $autodisabledate = $time + $disdays * 3600 * 24;
 151  
 152  
 153      $params = array(
 154          "postid"    => $_POST['postid'],
 155          "title"     => my_addslashes($_POST['title_text']),
 156          "body"      => my_addslashes($_POST['body_text']),
 157          "modifier"  => my_addslashes($_POST['modifier']),
 158          "status"    => my_addslashes($_POST['pubstatus']),
 159          "edit_sections" => TRUE,
 160      "hidefromhome" => $hidefromhome,
 161      "allowcomments" => my_addslashes($_POST['commentoptions']),
 162      "autodisabledate" => $autodisabledate,
 163          "sections"  => $newsections,
 164          "timestamp" => $timestamp
 165      );
 166  
 167      $bBlog->edit_post($params);
 168  
 169      if ((isset($_POST['send_trackback'])) && ($_POST['send_trackback'] == "TRUE"))
 170      {
 171          // send a trackback
 172          include "./trackback.php";
 173  
 174          if (!isset($_POST['title_text']))   { $_POST['title_text']  = ""; }
 175          if (!isset($_POST['excerpt']))      { $_POST['excerpt']     = ""; }
 176          if (!isset($_POST['tburl']))        { $_POST['tburl']       = ""; }
 177          send_trackback($bBlog->_get_entry_permalink($_POST['postid']), $_POST['title_text'], $_POST['excerpt'], $_POST['tburl']);
 178      }
 179  }
 180  
 181  if ((isset($_POST['filter'])) && ($_POST['filter'] == 'true')) 
 182  {
 183      if ((isset($_POST['shownum'])) && (is_numeric($_POST['shownum'])))
 184      {
 185          $num = $_POST['shownum'];
 186      } 
 187      else 
 188      {
 189          $num=20;
 190      }
 191      
 192      $searchopts['num'] = $num;
 193      $searchopts['wherestart'] = ' WHERE 1 ';    
 194      
 195      if(is_numeric($_POST['showsection'])) 
 196      {
 197          $searchopts['sectionid'] = $_POST['showsection'];
 198      }
 199      
 200      if($_POST['showmonth'] != 'any') 
 201      {
 202          $searchopts['month'] = substr($_POST['showmonth'],0,2);
 203          $searchopts['year']  = substr($_POST['showmonth'],3,4);
 204      }
 205      //print_r($searchopts);
 206      $q = $bBlog->make_post_query($searchopts);
 207      //echo $q;
 208      $archives = $bBlog->get_posts($q);
 209  } 
 210  else 
 211  {
 212      $searchopts['wherestart'] = ' WHERE 1 ';    
 213      $q = $bBlog->make_post_query($searchopts);
 214      $archives = $bBlog->get_posts($q); // ,TRUE);
 215  }
 216  
 217  $bBlog->assign('postmonths',get_post_months());
 218  $bBlog->assign_by_ref('archives',$archives);
 219  $bBlog->display('archives.html');
 220  
 221  function get_post_months() 
 222  {
 223      global $bBlog;
 224      $months_tmp = $bBlog->get_results("SELECT FROM_UNIXTIME(posttime,'%Y%m') yyyymm,  posttime from ".T_POSTS." group by yyyymm order by yyyymm");
 225      $months=array();
 226      foreach($months_tmp as $month) 
 227      {
 228          $nmonth['desc'] = date('F Y',$month->posttime);
 229          $nmonth['numeric'] = date('m-Y',$month->posttime);
 230          $months[]  = $nmonth;
 231      }
 232      return $months;
 233  }
 234  
 235  function timestampform($ts) 
 236  {
 237      $day = date('j',$ts);
 238      $month = date('m',$ts);
 239      $year = date('Y',$ts);
 240      $hour = date('H',$ts);
 241      $minute = date('i',$ts);
 242      $o  = "<span class='ts'>Day</span> / 
 243             <span class='ts'>Month</span> / 
 244             <span class='ts'>Year</span> @ 
 245             <span class='ts'>24hours</span> : 
 246             <span class='ts'>Minutes</span><br />
 247             <input type='text' name='ts_day' value='$day' class='ts' size='5'/> / 
 248             <input type='text' name='ts_month' value='$month' class='ts' size='5'/> / 
 249             <input type='text' name='ts_year' value='$year' class='ts' size='7'/> @ 
 250             <input type='text' name='ts_hour' value='$hour' class='ts' size='5'/> : 
 251             <input type='text' name='ts_minute' value='$minute' class='ts' size='5'/>
 252             ";    
 253      return $o;
 254  }
 255  
 256  function maketimestamp($day,$month,$year,$hour,$minute) 
 257  {
 258      // make timestamp format of YYYYMMDDHHMMSS
 259      $string = $year.$month.$day.$hour.$minute.'00';
 260      $timestamp = mktime(substr($string,8,2),substr($string,10,2),substr($string,12,2), substr($string,4,2),substr($string,6,2),substr($string,0,4));
 261      return $timestamp;
 262  }
 263  
 264  ?>


[ Powered by PHPXref - Served by Debian GNU/Linux ]