Make WordPress Core

Changeset 81


Ignore:
Timestamp:
05/24/2003 09:30:13 PM (23 years ago)
Author:
mikelittle
Message:

minor layout change

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/b2edit.php

    r44 r81  
    44
    55function add_magic_quotes($array) {
    6         foreach ($array as $k => $v) {
    7                 if (is_array($v)) {
    8                         $array[$k] = add_magic_quotes($v);
    9                 } else {
    10                         $array[$k] = addslashes($v);
    11                 }
    12         }
    13         return $array;
     6    foreach ($array as $k => $v) {
     7        if (is_array($v)) {
     8            $array[$k] = add_magic_quotes($v);
     9        } else {
     10            $array[$k] = addslashes($v);
     11        }
     12    }
     13    return $array;
    1414}
    1515
    1616if (!get_magic_quotes_gpc()) {
    17         $HTTP_GET_VARS    = add_magic_quotes($HTTP_GET_VARS);
    18         $HTTP_POST_VARS   = add_magic_quotes($HTTP_POST_VARS);
    19         $HTTP_COOKIE_VARS = add_magic_quotes($HTTP_COOKIE_VARS);
     17    $HTTP_GET_VARS    = add_magic_quotes($HTTP_GET_VARS);
     18    $HTTP_POST_VARS   = add_magic_quotes($HTTP_POST_VARS);
     19    $HTTP_COOKIE_VARS = add_magic_quotes($HTTP_COOKIE_VARS);
    2020}
    2121
    2222$b2varstoreset = array('action','safe_mode','withcomments','c','posts','poststart','postend','content','edited_post_title','comment_error','profile', 'trackback_url', 'excerpt');
    2323for ($i=0; $i<count($b2varstoreset); $i += 1) {
    24         $b2var = $b2varstoreset[$i];
    25         if (!isset($$b2var)) {
    26                 if (empty($HTTP_POST_VARS["$b2var"])) {
    27                         if (empty($HTTP_GET_VARS["$b2var"])) {
    28                                 $$b2var = '';
    29                         } else {
    30                                 $$b2var = $HTTP_GET_VARS["$b2var"];
    31                         }
    32                 } else {
    33                         $$b2var = $HTTP_POST_VARS["$b2var"];
    34                 }
    35         }
     24    $b2var = $b2varstoreset[$i];
     25    if (!isset($$b2var)) {
     26        if (empty($HTTP_POST_VARS["$b2var"])) {
     27            if (empty($HTTP_GET_VARS["$b2var"])) {
     28                $$b2var = '';
     29            } else {
     30                $$b2var = $HTTP_GET_VARS["$b2var"];
     31            }
     32        } else {
     33            $$b2var = $HTTP_POST_VARS["$b2var"];
     34        }
     35    }
    3636}
    3737
    3838switch($action) {
    39        
    40 case 'post':
    41 
    42         $standalone = 1;
    43         require_once('b2header.php');
    44 
    45         $post_autobr = intval($HTTP_POST_VARS["post_autobr"]);
    46         $post_pingback = intval($HTTP_POST_VARS["post_pingback"]);
    47         $content = balanceTags($HTTP_POST_VARS["content"]);
    48         $content = format_to_post($content);
    49         $excerpt = balanceTags($HTTP_POST_VARS["excerpt"]);
    50         $excerpt = format_to_post($excerpt);
    51         $post_title = addslashes($HTTP_POST_VARS["post_title"]);
    52         $post_category = intval($HTTP_POST_VARS["post_category"]);
    53 
    54         if ($user_level == 0)
    55                 die ("Cheatin' uh ?");
    56 
    57         if (($user_level > 4) && (!empty($HTTP_POST_VARS["edit_date"]))) {
    58                 $aa = $HTTP_POST_VARS["aa"];
    59                 $mm = $HTTP_POST_VARS["mm"];
    60                 $jj = $HTTP_POST_VARS["jj"];
    61                 $hh = $HTTP_POST_VARS["hh"];
    62                 $mn = $HTTP_POST_VARS["mn"];
    63                 $ss = $HTTP_POST_VARS["ss"];
    64                 $jj = ($jj > 31) ? 31 : $jj;
    65                 $hh = ($hh > 23) ? $hh - 24 : $hh;
    66                 $mn = ($mn > 59) ? $mn - 60 : $mn;
    67                 $ss = ($ss > 59) ? $ss - 60 : $ss;
    68                 $now = "$aa-$mm-$jj $hh:$mn:$ss";
    69         } else {
    70                 $now = date("Y-m-d H:i:s", (time() + ($time_difference * 3600)));
    71         }
    72 
    73         $query = "INSERT INTO $tableposts (ID, post_author, post_date, post_content, post_title, post_category, post_excerpt) VALUES ('0','$user_ID','$now','$content','$post_title','$post_category','$excerpt')";
    74         $result = mysql_query($query) or mysql_oops($query);
    75 
    76         $post_ID = mysql_insert_id();
    77 
    78         if (isset($sleep_after_edit) && $sleep_after_edit > 0) {
    79                 sleep($sleep_after_edit);
    80         }
    81 
    82         pingWeblogs($blog_ID);
    83         pingCafelog($cafelogID, $post_title, $post_ID);
    84         pingBlogs($blog_ID);
    85         if ($post_pingback) {
    86                 pingback($content, $post_ID);
    87         }
    88 
    89         if (!empty($HTTP_POST_VARS['trackback_url'])) {
    90                 $excerpt = (strlen(strip_tags($content)) > 255) ? substr(strip_tags($content), 0, 252).'...' : strip_tags($content);
    91                 $excerpt = stripslashes($excerpt);
    92                 $trackback_urls = explode(',', $HTTP_POST_VARS['trackback_url']);
    93                 foreach($trackback_urls as $tb_url) {
    94                         $tb_url = trim($tb_url);
    95                         trackback($tb_url, stripslashes($post_title), $excerpt, $post_ID);
    96                 }
    97         }
    98 
    99         if (!empty($HTTP_POST_VARS["mode"])) {
    100                 switch($HTTP_POST_VARS["mode"]) {
    101                         case "bookmarklet":
    102                                 $location="b2bookmarklet.php?a=b";
    103                                 break;
    104                         case "sidebar":
    105                                 $location="b2sidebar.php?a=b";
    106                                 break;
    107                         default:
    108                                 $location="b2edit.php";
    109                                 break;
    110                 }
    111         } else {
    112                 $location="b2edit.php";
    113         }
    114         header("Location: $location");
    115         exit();
    116 
    117 break;
    118 
    119 case 'edit':
    120 
    121         $standalone = 0;
    122         require_once('b2header.php');
    123         $post = $HTTP_GET_VARS['post'];
    124         if ($user_level > 0) {
    125                 $postdata=get_postdata($post) or die('Oops, no post with this ID. <a href="b2edit.php">Go back</a>!');
    126                 $authordata = get_userdata($postdata["Author_ID"]);
    127         if ($user_level < $authordata[13])
    128         die ('You don&#8217;t have the right to edit <strong>'.$authordata[1].'</strong>&#8217;s posts.');
    129 
    130         $content = $postdata['Content'];
    131         $content = format_to_edit($content);
    132         $excerpt = $postdata['Excerpt'];
    133         $excerpt = format_to_edit($excerpt);
    134         $edited_post_title = format_to_edit($postdata['Title']);
    135 
    136         include('b2edit.form.php');
    137 
    138         } else {
    139         ?>
    140 
    141         <p>Since you're a newcomer, you'll have to wait for an admin to raise your level to 1, in order to be authorized to post.<br />You can also <a href="mailto:<?php echo $admin_email ?>?subject=b2-promotion">e-mail the admin</a> to ask for a promotion.<br />When you're promoted, just reload this page and you'll be able to blog. :)</p>
    142 
    143         <?php
    144         }
    145 
    146 break;
    147 
    148 case "editpost":
    149 
    150         $standalone = 1;
    151         require_once("./b2header.php");
    152        
    153         if ($user_level == 0)
    154         die ("Cheatin' uh ?");
    155 
    156         if (!isset($blog_ID)) {
    157                 $blog_ID = 1;
    158         }
    159         $post_ID = $HTTP_POST_VARS["post_ID"];
    160         $post_category = intval($HTTP_POST_VARS["post_category"]);
    161         $post_autobr = intval($HTTP_POST_VARS["post_autobr"]);
    162         $content = balanceTags($HTTP_POST_VARS["content"]);
    163         $content = format_to_post($content);
    164         $excerpt = balanceTags($HTTP_POST_VARS["excerpt"]);
    165         $excerpt = format_to_post($excerpt);
    166         $post_title = addslashes($HTTP_POST_VARS["post_title"]);
    167 
    168         if (($user_level > 4) && (!empty($HTTP_POST_VARS["edit_date"]))) {
    169                 $aa = $HTTP_POST_VARS["aa"];
    170                 $mm = $HTTP_POST_VARS["mm"];
    171                 $jj = $HTTP_POST_VARS["jj"];
    172                 $hh = $HTTP_POST_VARS["hh"];
    173                 $mn = $HTTP_POST_VARS["mn"];
    174                 $ss = $HTTP_POST_VARS["ss"];
    175                 $jj = ($jj > 31) ? 31 : $jj;
    176                 $hh = ($hh > 23) ? $hh - 24 : $hh;
    177                 $mn = ($mn > 59) ? $mn - 60 : $mn;
    178                 $ss = ($ss > 59) ? $ss - 60 : $ss;
    179                 $datemodif = ", post_date=\"$aa-$mm-$jj $hh:$mn:$ss\"";
    180         } else {
    181                 $datemodif = "";
    182         }
    183 
    184         $query = "UPDATE $tableposts SET post_content=\"$content\", post_excerpt=\"$excerpt\", post_title=\"$post_title\", post_category=\"$post_category\"".$datemodif." WHERE ID=$post_ID";
    185         $result = mysql_query($query) or mysql_oops($query);
    186 
    187         if (isset($sleep_after_edit) && $sleep_after_edit > 0) {
    188                 sleep($sleep_after_edit);
    189         }
    190 
    191 //      pingWeblogs($blog_ID);
    192 
    193         $location = "Location: b2edit.php";
    194         header ($location);
    195 
    196 break;
    197 
    198 case "delete":
    199 
    200         $standalone = 1;
    201         require_once("./b2header.php");
    202 
    203         if ($user_level == 0)
    204         die ("Cheatin' uh ?");
    205 
    206         $post = $HTTP_GET_VARS['post'];
    207         $postdata=get_postdata($post) or die("Oops, no post with this ID. <a href=\"b2edit.php\">Go back</a> !");
    208         $authordata = get_userdata($postdata["Author_ID"]);
    209 
    210         if ($user_level < $authordata[13])
    211         die ("You don't have the right to delete <b>".$authordata[1]."</b>'s posts.");
    212 
    213         $query = "DELETE FROM $tableposts WHERE ID=$post";
    214         $result = mysql_query($query) or die("Oops, no post with this ID. <a href=\"b2edit.php\">Go back</a> !");
    215         if (!$result)
    216         die("Error in deleting... contact the <a href=\"mailto:$admin_email\">webmaster</a>...");
    217 
    218         $query = "DELETE FROM $tablecomments WHERE comment_post_ID=$post";
    219         $result = mysql_query($query) or die("Oops, no comment associated to that post. <a href=\"b2edit.php\">Go back</a> !");
    220 
    221         if (isset($sleep_after_edit) && $sleep_after_edit > 0) {
    222                 sleep($sleep_after_edit);
    223         }
    224 
    225 //      pingWeblogs($blog_ID);
    226 
    227         header ('Location: b2edit.php');
    228 
    229 break;
    230 
    231 case 'editcomment':
    232 
    233         $standalone = 0;
    234         require_once ('b2header.php');
    235 
    236         get_currentuserinfo();
    237 
    238         if ($user_level == 0) {
    239                 die ('Cheatin&#8217; uh?');
    240         }
    241 
    242         $comment = $HTTP_GET_VARS['comment'];
    243         $commentdata = get_commentdata($comment, 1) or die('Oops, no comment with this ID. <a href="javascript:history.go(-1)">Go back</a>!');
    244         $content = $commentdata['comment_content'];
    245         $content = format_to_edit($content);
    246 
    247         include('b2edit.form.php');
    248 
    249 break;
    250 
    251 case "deletecomment":
    252 
    253         $standalone = 1;
    254         require_once("./b2header.php");
    255 
    256         if ($user_level == 0)
    257                 die ("Cheatin' uh ?");
    258 
    259         $comment = $HTTP_GET_VARS['comment'];
    260         $p = $HTTP_GET_VARS['p'];
    261         $commentdata=get_commentdata($comment) or die("Oops, no comment with this ID. <a href=\"b2edit.php\">Go back</a> !");
    262 
    263         $query = "DELETE FROM $tablecomments WHERE comment_ID=$comment";
    264         $result = mysql_query($query) or die("Oops, no comment with this ID. <a href=\"b2edit.php\">Go back</a> !");
    265 
    266         header ("Location: b2edit.php?p=$p&c=1#comments"); //?a=dc");
    267 
    268 break;
    269 
    270 case "editedcomment":
    271 
    272         $standalone = 1;
    273         require_once("./b2header.php");
    274 
    275         if ($user_level == 0)
    276                 die ("Cheatin' uh ?");
    277 
    278         $comment_ID = $HTTP_POST_VARS['comment_ID'];
    279         $comment_post_ID = $HTTP_POST_VARS['comment_post_ID'];
    280         $newcomment_author = $HTTP_POST_VARS['newcomment_author'];
    281         $newcomment_author_email = $HTTP_POST_VARS['newcomment_author_email'];
    282         $newcomment_author_url = $HTTP_POST_VARS['newcomment_author_url'];
    283         $newcomment_author = addslashes($newcomment_author);
    284         $newcomment_author_email = addslashes($newcomment_author_email);
    285         $newcomment_author_url = addslashes($newcomment_author_url);
    286         $post_autobr = $HTTP_POST_VARS["post_autobr"];
    287 
    288         if (($user_level > 4) && (!empty($HTTP_POST_VARS["edit_date"]))) {
    289                 $aa = $HTTP_POST_VARS["aa"];
    290                 $mm = $HTTP_POST_VARS["mm"];
    291                 $jj = $HTTP_POST_VARS["jj"];
    292                 $hh = $HTTP_POST_VARS["hh"];
    293                 $mn = $HTTP_POST_VARS["mn"];
    294                 $ss = $HTTP_POST_VARS["ss"];
    295                 $jj = ($jj > 31) ? 31 : $jj;
    296                 $hh = ($hh > 23) ? $hh - 24 : $hh;
    297                 $mn = ($mn > 59) ? $mn - 60 : $mn;
    298                 $ss = ($ss > 59) ? $ss - 60 : $ss;
    299                 $datemodif = ", comment_date=\"$aa-$mm-$jj $hh:$mn:$ss\"";
    300         } else {
    301                 $datemodif = "";
    302         }
    303         $content = balanceTags($content);
    304         $content = format_to_post($content);
    305 
    306         $query = "UPDATE $tablecomments SET comment_content=\"$content\", comment_author=\"$newcomment_author\", comment_author_email=\"$newcomment_author_email\", comment_author_url=\"$newcomment_author_url\"".$datemodif." WHERE comment_ID=$comment_ID";
    307         $result = mysql_query($query) or mysql_oops($query);
    308 
    309         header ("Location: b2edit.php?p=$comment_post_ID&c=1#comments"); //?a=ec");
    310 
    311 break;
    312 
    313 default:
    314 
    315         $standalone=0;
    316         require_once ("./b2header.php");
    317        
    318         if ($user_level > 0) {
    319                 if ((!$withcomments) && (!$c)) {
    320 
    321                         $action="post";
    322                         include("b2edit.form.php");
    323                         echo "<br /><br />";
    324 
    325                 }       
    326 
    327         } else {
    328 
    329                 echo $tabletop; ?>
    330                 <p>Since you're a newcomer, you'll have to wait for an admin to raise your level to 1, in order to be authorized to post.<br />You can also <a href="mailto:<?php echo $admin_email ?>?subject=b2-promotion">e-mail the admin</a> to ask for a promotion.<br />When you're promoted, just reload this page and you'll be able to blog. :)</p>
    331                 <?php
    332                 echo $tablebottom;
    333                 echo "<br /><br />";
    334 
    335         }
    336 
    337         include("b2edit.showposts.php");
    338 
    339 }
    340 
    341 
     39
     40    case 'post':
     41
     42        $standalone = 1;
     43        require_once('b2header.php');
     44
     45        $post_autobr = intval($HTTP_POST_VARS["post_autobr"]);
     46        $post_pingback = intval($HTTP_POST_VARS["post_pingback"]);
     47        $content = balanceTags($HTTP_POST_VARS["content"]);
     48        $content = format_to_post($content);
     49        $excerpt = balanceTags($HTTP_POST_VARS["excerpt"]);
     50        $excerpt = format_to_post($excerpt);
     51        $post_title = addslashes($HTTP_POST_VARS["post_title"]);
     52        $post_category = intval($HTTP_POST_VARS["post_category"]);
     53
     54        if ($user_level == 0)
     55            die ("Cheatin' uh ?");
     56
     57        if (($user_level > 4) && (!empty($HTTP_POST_VARS["edit_date"]))) {
     58            $aa = $HTTP_POST_VARS["aa"];
     59            $mm = $HTTP_POST_VARS["mm"];
     60            $jj = $HTTP_POST_VARS["jj"];
     61            $hh = $HTTP_POST_VARS["hh"];
     62            $mn = $HTTP_POST_VARS["mn"];
     63            $ss = $HTTP_POST_VARS["ss"];
     64            $jj = ($jj > 31) ? 31 : $jj;
     65            $hh = ($hh > 23) ? $hh - 24 : $hh;
     66            $mn = ($mn > 59) ? $mn - 60 : $mn;
     67            $ss = ($ss > 59) ? $ss - 60 : $ss;
     68            $now = "$aa-$mm-$jj $hh:$mn:$ss";
     69        } else {
     70            $now = date("Y-m-d H:i:s", (time() + ($time_difference * 3600)));
     71        }
     72
     73        $query = "INSERT INTO $tableposts (ID, post_author, post_date, post_content, post_title, post_category, post_excerpt) VALUES ('0','$user_ID','$now','$content','$post_title','$post_category','$excerpt')";
     74        $result = mysql_query($query) or mysql_oops($query);
     75
     76        $post_ID = mysql_insert_id();
     77
     78        if (isset($sleep_after_edit) && $sleep_after_edit > 0) {
     79                sleep($sleep_after_edit);
     80        }
     81
     82        pingWeblogs($blog_ID);
     83        pingCafelog($cafelogID, $post_title, $post_ID);
     84        pingBlogs($blog_ID);
     85        if ($post_pingback) {
     86            pingback($content, $post_ID);
     87        }
     88
     89        if (!empty($HTTP_POST_VARS['trackback_url'])) {
     90            $excerpt = (strlen(strip_tags($content)) > 255) ? substr(strip_tags($content), 0, 252).'...' : strip_tags($content);
     91            $excerpt = stripslashes($excerpt);
     92            $trackback_urls = explode(',', $HTTP_POST_VARS['trackback_url']);
     93            foreach($trackback_urls as $tb_url) {
     94                $tb_url = trim($tb_url);
     95                trackback($tb_url, stripslashes($post_title), $excerpt, $post_ID);
     96            }
     97        }
     98
     99        if (!empty($HTTP_POST_VARS["mode"])) {
     100            switch($HTTP_POST_VARS["mode"]) {
     101                case "bookmarklet":
     102                    $location="b2bookmarklet.php?a=b";
     103                    break;
     104                case "sidebar":
     105                    $location="b2sidebar.php?a=b";
     106                    break;
     107                default:
     108                    $location="b2edit.php";
     109                    break;
     110            }
     111        } else {
     112            $location="b2edit.php";
     113        }
     114        header("Location: $location");
     115        exit();
     116        break;
     117
     118    case 'edit':
     119
     120        $standalone = 0;
     121        require_once('b2header.php');
     122        $post = $HTTP_GET_VARS['post'];
     123        if ($user_level > 0) {
     124            $postdata=get_postdata($post) or die('Oops, no post with this ID. <a href="b2edit.php">Go back</a>!');
     125            $authordata = get_userdata($postdata["Author_ID"]);
     126            if ($user_level < $authordata[13])
     127                die ('You don&#8217;t have the right to edit <strong>'.$authordata[1].'</strong>&#8217;s posts.');
     128
     129            $content = $postdata['Content'];
     130            $content = format_to_edit($content);
     131            $excerpt = $postdata['Excerpt'];
     132            $excerpt = format_to_edit($excerpt);
     133            $edited_post_title = format_to_edit($postdata['Title']);
     134
     135            include('b2edit.form.php');
     136
     137        } else {
     138?>
     139            <p>Since you're a newcomer, you'll have to wait for an admin to raise your level to 1,
     140            in order to be authorized to post.<br />
     141            You can also <a href="mailto:<?php echo $admin_email ?>?subject=b2-promotion">e-mail the admin</a>
     142            to ask for a promotion.<br />
     143            When you're promoted, just reload this page and you'll be able to blog. :)
     144            </p>
     145<?php
     146        }
     147        break;
     148
     149    case "editpost":
     150
     151        $standalone = 1;
     152        require_once("./b2header.php");
     153       
     154        if ($user_level == 0)
     155            die ("Cheatin' uh ?");
     156
     157        if (!isset($blog_ID)) {
     158            $blog_ID = 1;
     159        }
     160        $post_ID = $HTTP_POST_VARS["post_ID"];
     161        $post_category = intval($HTTP_POST_VARS["post_category"]);
     162        $post_autobr = intval($HTTP_POST_VARS["post_autobr"]);
     163        $content = balanceTags($HTTP_POST_VARS["content"]);
     164        $content = format_to_post($content);
     165        $excerpt = balanceTags($HTTP_POST_VARS["excerpt"]);
     166        $excerpt = format_to_post($excerpt);
     167        $post_title = addslashes($HTTP_POST_VARS["post_title"]);
     168
     169        if (($user_level > 4) && (!empty($HTTP_POST_VARS["edit_date"]))) {
     170            $aa = $HTTP_POST_VARS["aa"];
     171            $mm = $HTTP_POST_VARS["mm"];
     172            $jj = $HTTP_POST_VARS["jj"];
     173            $hh = $HTTP_POST_VARS["hh"];
     174            $mn = $HTTP_POST_VARS["mn"];
     175            $ss = $HTTP_POST_VARS["ss"];
     176            $jj = ($jj > 31) ? 31 : $jj;
     177            $hh = ($hh > 23) ? $hh - 24 : $hh;
     178            $mn = ($mn > 59) ? $mn - 60 : $mn;
     179            $ss = ($ss > 59) ? $ss - 60 : $ss;
     180            $datemodif = ", post_date=\"$aa-$mm-$jj $hh:$mn:$ss\"";
     181        } else {
     182            $datemodif = "";
     183        }
     184
     185        $query = "UPDATE $tableposts SET post_content=\"$content\", post_excerpt=\"$excerpt\", post_title=\"$post_title\", post_category=\"$post_category\"".$datemodif." WHERE ID=$post_ID";
     186        $result = mysql_query($query) or mysql_oops($query);
     187
     188        if (isset($sleep_after_edit) && $sleep_after_edit > 0) {
     189            sleep($sleep_after_edit);
     190        }
     191
     192        //pingWeblogs($blog_ID);
     193
     194        $location = "Location: b2edit.php";
     195        header ($location);
     196        break;
     197
     198    case "delete":
     199
     200        $standalone = 1;
     201        require_once("./b2header.php");
     202
     203        if ($user_level == 0)
     204            die ("Cheatin' uh ?");
     205
     206        $post = $HTTP_GET_VARS['post'];
     207        $postdata=get_postdata($post) or die("Oops, no post with this ID. <a href=\"b2edit.php\">Go back</a> !");
     208        $authordata = get_userdata($postdata["Author_ID"]);
     209
     210        if ($user_level < $authordata[13])
     211            die ("You don't have the right to delete <b>".$authordata[1]."</b>'s posts.");
     212
     213        $query = "DELETE FROM $tableposts WHERE ID=$post";
     214        $result = mysql_query($query) or die("Oops, no post with this ID. <a href=\"b2edit.php\">Go back</a> !");
     215        if (!$result)
     216            die("Error in deleting... contact the <a href=\"mailto:$admin_email\">webmaster</a>...");
     217
     218        $query = "DELETE FROM $tablecomments WHERE comment_post_ID=$post";
     219        $result = mysql_query($query) or die("Oops, no comment associated to that post. <a href=\"b2edit.php\">Go back</a> !");
     220
     221        if (isset($sleep_after_edit) && $sleep_after_edit > 0) {
     222            sleep($sleep_after_edit);
     223        }
     224
     225        //      pingWeblogs($blog_ID);
     226
     227        header ('Location: b2edit.php');
     228
     229        break;
     230
     231    case 'editcomment':
     232
     233        $standalone = 0;
     234        require_once ('b2header.php');
     235
     236        get_currentuserinfo();
     237
     238        if ($user_level == 0) {
     239            die ('Cheatin&#8217; uh?');
     240        }
     241
     242        $comment = $HTTP_GET_VARS['comment'];
     243        $commentdata = get_commentdata($comment, 1) or die('Oops, no comment with this ID. <a href="javascript:history.go(-1)">Go back</a>!');
     244        $content = $commentdata['comment_content'];
     245        $content = format_to_edit($content);
     246
     247        include('b2edit.form.php');
     248
     249        break;
     250
     251    case "deletecomment":
     252
     253        $standalone = 1;
     254        require_once("./b2header.php");
     255
     256        if ($user_level == 0)
     257            die ("Cheatin' uh ?");
     258
     259        $comment = $HTTP_GET_VARS['comment'];
     260        $p = $HTTP_GET_VARS['p'];
     261        $commentdata=get_commentdata($comment) or die("Oops, no comment with this ID. <a href=\"b2edit.php\">Go back</a> !");
     262
     263        $query = "DELETE FROM $tablecomments WHERE comment_ID=$comment";
     264        $result = mysql_query($query) or die("Oops, no comment with this ID. <a href=\"b2edit.php\">Go back</a> !");
     265
     266        header ("Location: b2edit.php?p=$p&c=1#comments"); //?a=dc");
     267
     268        break;
     269
     270    case "editedcomment":
     271
     272        $standalone = 1;
     273        require_once("./b2header.php");
     274
     275        if ($user_level == 0)
     276            die ("Cheatin' uh ?");
     277
     278        $comment_ID = $HTTP_POST_VARS['comment_ID'];
     279        $comment_post_ID = $HTTP_POST_VARS['comment_post_ID'];
     280        $newcomment_author = $HTTP_POST_VARS['newcomment_author'];
     281        $newcomment_author_email = $HTTP_POST_VARS['newcomment_author_email'];
     282        $newcomment_author_url = $HTTP_POST_VARS['newcomment_author_url'];
     283        $newcomment_author = addslashes($newcomment_author);
     284        $newcomment_author_email = addslashes($newcomment_author_email);
     285        $newcomment_author_url = addslashes($newcomment_author_url);
     286        $post_autobr = $HTTP_POST_VARS["post_autobr"];
     287
     288        if (($user_level > 4) && (!empty($HTTP_POST_VARS["edit_date"]))) {
     289            $aa = $HTTP_POST_VARS["aa"];
     290            $mm = $HTTP_POST_VARS["mm"];
     291            $jj = $HTTP_POST_VARS["jj"];
     292            $hh = $HTTP_POST_VARS["hh"];
     293            $mn = $HTTP_POST_VARS["mn"];
     294            $ss = $HTTP_POST_VARS["ss"];
     295            $jj = ($jj > 31) ? 31 : $jj;
     296            $hh = ($hh > 23) ? $hh - 24 : $hh;
     297            $mn = ($mn > 59) ? $mn - 60 : $mn;
     298            $ss = ($ss > 59) ? $ss - 60 : $ss;
     299            $datemodif = ", comment_date=\"$aa-$mm-$jj $hh:$mn:$ss\"";
     300        } else {
     301            $datemodif = "";
     302        }
     303        $content = balanceTags($content);
     304        $content = format_to_post($content);
     305
     306        $query = "UPDATE $tablecomments SET comment_content=\"$content\", comment_author=\"$newcomment_author\", comment_author_email=\"$newcomment_author_email\", comment_author_url=\"$newcomment_author_url\"".$datemodif." WHERE comment_ID=$comment_ID";
     307        $result = mysql_query($query) or mysql_oops($query);
     308
     309        header ("Location: b2edit.php?p=$comment_post_ID&c=1#comments"); //?a=ec");
     310
     311        break;
     312
     313    default:
     314
     315        $standalone=0;
     316        require_once ("./b2header.php");
     317
     318        if ($user_level > 0) {
     319            if ((!$withcomments) && (!$c)) {
     320
     321                $action="post";
     322                include("b2edit.form.php");
     323                echo "<br /><br />";
     324
     325            }
     326
     327        } else {
     328
     329            echo $tabletop;
     330?>
     331            <p>Since you're a newcomer, you'll have to wait for an admin to raise your level to 1, in order to be authorized to post.<br />You can also <a href="mailto:<?php echo $admin_email ?>?subject=b2-promotion">e-mail the admin</a> to ask for a promotion.<br />When you're promoted, just reload this page and you'll be able to blog. :)</p>
     332<?php
     333            echo $tablebottom;
     334            echo "<br /><br />";
     335        }
     336
     337        include("b2edit.showposts.php");
     338        break;
     339} // end switch
    342340/* </Edit> */
    343341include("b2footer.php");
Note: See TracChangeset for help on using the changeset viewer.