Changeset 191 for branches

Show
Ignore:
Timestamp:
07/16/06 16:56:50 (2 years ago)
Author:
michiel
Message:

the admin class is now fully working too.
Time to start cleaning up and rearrange stuff

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/class-rewrite/common/admin.php

    r190 r191  
    4343                        $this->show_login(); 
    4444                } 
     45        } 
     46        /* }}} */ 
     47        /* _strip_tags {{{ */ 
     48        /** 
     49         * strip all html tags cept for some tags we like. 
     50         * The tags we leave will be stripped from attributes we dont like. 
     51         * 
     52         * @param string The text to process 
     53         * @return string The text with only allowed tags. 
     54         */ 
     55        private function _strip_tags($text) { 
     56                $allowed_tags  = "<h1><h2><p><font><ul><li><ol><blockquote><u><strike><sub><br>"; 
     57                $allowed_tags .= "<sup><img><a><table><tbody><tr><td><tt><pre><div><span>"; 
     58                $text = strip_tags($text, $allowed_tags); 
     59                return preg_replace('/<(.*?)>/ie', "'<'.$this->_strip_attributes('\\1').'>'", $text); 
     60        } 
     61        /* }}} */ 
     62        /* _strip_attributes {{{ */ 
     63        /** 
     64         * strip evil attributes from tags 
     65         * 
     66         * @param string The text to process 
     67         * @return string The processed text 
     68         */ 
     69        private function _strip_attributes($text) { 
     70                $attr_to_strip = array( 
     71                        "javascript:", 
     72                        "onclick", 
     73                        "ondblclick", 
     74                        "onmousedown", 
     75                        "onmouseup", 
     76                        "onmouseover" 
     77                ); 
     78                foreach ($attr_to_strip as $attribute) { 
     79                        $text = stripslashes(preg_replace("/$attribute/i", "forbidden", $text)); 
     80                } 
     81                return $text; 
    4582        } 
    4683        /* }}} */ 
     
    9791016        } 
    9801017        /* }}} */ 
    981  
    982  
    983  
    984  
    985  
    986  
    987  
    988  
    989  
    990  
    991  
    992  
    993 //{{{ show_acro: show a list of all acros 
    994 //--------------------------------------- 
    995 function show_acro() { 
    996         global $db; 
    997         $res =& $db->query("SELECT * FROM acronyms ORDER BY upper(acronym)"); 
    998         if (PEAR::isError($res)) { 
    999                 die($res->getMessage()); 
    1000         } 
    1001  
    1002         ?><a href="./index.php?action=edit_acro&amp;id=0">create new</a><? 
    1003         while ($res->fetchInto($row, DB_FETCHMODE_ASSOC)) { 
    1004                 ?> 
    1005                 <div class="log_post"> 
    1006                         <div class="log_post_head"> 
    1007                                 <h1 class="log_post_h1"><a href="?action=edit_acro&amp;id=<?=$row["id"]?>"><?=stripslashes($row["acronym"])?></a></h1> 
    1008                         </div> 
    1009                         <div class="log_post_body"> 
    1010                                 <div class="log_post_normal"> 
    1011                                         <?=stripslashes($row["description"])?> 
    1012                                 </div> 
    1013                         </div> 
    1014                         <div class="log_post_foot"> 
    1015                         </div> 
    1016                 </div> 
    1017                 <? 
    1018         } 
    1019 } 
    1020  
    1021 //}}}-------------------------------------------------- 
    1022 //{{{ edit_acro($id): show user a form to edit the acro 
    1023 //----------------------------------------------------- 
    1024 function edit_acro($id) { 
    1025         global $db; 
    1026         if ($id==0) { 
    1027                 $cat["id"]          = 0; 
    1028                 $cat["acronym"]     = "acronym name"; 
    1029                 $cat["description"] = "Category description"; 
    1030         } else { 
    1031                 $res =& $db->query(sprintf("SELECT * FROM acronyms WHERE id = %d", $id)); 
     1018        /* show_comments {{{ */ 
     1019        /** 
     1020         * show comment items 
     1021         * 
     1022         * @param array top => where to start for pages, limit => the pagesize 
     1023         */ 
     1024        public function show_comments($options) { 
     1025                if (!$options["top"])   { $options["top"]   = 0; }  else { $options["top"]   = (int)$options["top"]; } 
     1026                if (!$options["limit"]) { $options["limit"] = 15; } else { $options["limit"] = (int)$options["limit"]; } 
     1027                /* create an array with the article titles */ 
     1028                $sql = "SELECT id,title FROM articles"; 
     1029                $res = $this->db->query($sql); 
     1030                $articles[0] = "no article"; 
     1031                while ($res->fetchInto($row, DB_FETCHMODE_ASSOC)) { 
     1032                        $articles[$row["id"]] = stripslashes($row["title"]); 
     1033                } 
     1034                /* loop through the comments */ 
     1035                $res_count =& $this->db->query("SELECT COUNT(*) FROM comments"); 
     1036                $res_count->fetchInto($counter_r, DB_FETCHMODE_NUM); 
     1037                $counter = $counter_r[0]; 
     1038                $res =& $this->db->limitQuery("SELECT * FROM comments ORDER BY date DESC", $options["top"], $options["limit"]); 
    10321039                if (PEAR::isError($res)) { 
    10331040                        die($res->getMessage()); 
    10341041                } 
    1035                 $res->fetchInto($acro, DB_FETCHMODE_ASSOC); 
    1036         } 
    1037         ?> 
    1038         <form name="acronym" method="post" action="index.php"> 
    1039         <input type="hidden" name="action" value="save_acro" /> 
    1040         <input type="hidden" name="acro[id]" value="<?=$acro["id"]?>" /> 
    1041         <div class="log_post"> 
    1042                 <div class="log_post_head"> 
    1043                         <h1 class="log_post_h1"><input type="text" name="acro[acronym]" value="<?=stripslashes($acro["acronym"])?>" /></h1> 
    1044                 </div> 
    1045                 <div class="log_post_body"> 
    1046                         <input type="text" name="acro[description]" value="<?=stripslashes($acro["description"])?>" style="width: 500px;" /><br /> 
    1047                         <input type="submit" value="save" /> 
    1048                         <? if ($id) { ?> 
    1049                                 <input type="button" value="delete" onClick="document.forms.acronym.action.value='delete_acro';document.forms.acronym.submit();" /> 
    1050                         <? } else { ?> 
    1051                                 <input type="button" value="cancel" onClick="document.forms.acronym.action.value='show_acro';document.forms.acronym.submit();" /> 
    1052                         <? } ?> 
    1053                 </div> 
    1054                 <div class="log_postfoot"> 
    1055                 </div> 
    1056         </div> 
    1057         </form> 
    1058         <? 
    1059 } 
    1060  
    1061 //}}}------------------------------------ 
    1062 //{{{ save_acro($acro): store in database 
    1063 //--------------------------------------- 
    1064 function save_acro($acro) { 
    1065         global $db; 
    1066         if ($acro["id"]) { 
    1067                 $query = sprintf("UPDATE acronyms SET %s = '%s', %s = '%s' WHERE id = %d", 
    1068                         $this->db_quote("acronym"), preg_quote(strip_tags($acro["acronym"]), "'"), 
    1069                         $this->db_quote("description"), preg_quote(_strip_tags($acro["description"]), "'"), 
    1070                         $acro["id"] 
    1071                 ); 
    1072         } else { 
    1073                 $query = sprintf("INSERT INTO acronyms (%s, %s) VALUES ('%s', '%s')", 
    1074                         $this->db_quote("acronym"), $this->db_quote("description"), 
    1075                         preg_quote(strip_tags($acro["acronym"]), "'"), 
    1076                         preg_quote(_strip_tags($acro["description"]), "'") 
    1077                 ); 
    1078         } 
    1079         $res =& $db->query($query); 
    1080         if (PEAR::isError($res)) { 
    1081                 die($res->getUserInfo()); 
    1082         } 
    1083         header("Location: index.php?action=show_acro"); 
    1084 } 
    1085  
    1086 //}}}----------------------------------------- 
    1087 //{{{ delete_acro($id): remove acronym from db 
    1088 //-------------------------------------------- 
    1089 function delete_acro($id) { 
    1090         global $db; 
    1091         $query = sprintf("DELETE FROM acronyms WHERE id = %d", $id); 
    1092         $res =& $db->query($query); 
    1093         if (PEAR::isError($res)) { 
    1094                 die($res->getUserInfo()); 
    1095         } 
    1096         header("Location: index.php?action=show_acro"); 
    1097 } 
    1098  
    1099 //}}}------------------------------------ 
    1100 //{{{ show_settings(); show the blogsettings 
    1101 //------------------------------------------ 
    1102 function show_settings() { 
    1103         global $db; 
    1104         /* get settings from db */ 
    1105         $settings = array(); 
    1106         $sql = "SELECT * FROM settings"; 
    1107         $res =& $db->query($sql); 
    1108         while ($res->fetchInto($row, DB_FETCHMODE_ASSOC)) { 
    1109                 $settings[$row["settingname"]] = $row["settingvalue"]; 
    1110         } 
    1111         ?> 
    1112         <div class="log_post"> 
    1113                 <div class="log_post_head"> 
    1114                         <h1 class="log_post_h1"> 
    1115                         Blogsettings 
    1116                         </h1> 
    1117                 </div> 
    1118                 <div class="log_post_body"> 
    1119                         <div class="log_post_normal"> 
    1120                                 <form name="settings" method="post" action="index.php"> 
    1121                                 <input type="hidden" name="action" value="save_settings" /> 
    1122                                 <table border="0" cellspacing="0" cellpadding="0"><tr> 
    1123                                         <td style="vertical-align: top;">blog title</td> 
    1124                                         <td><input type="text" style="width: 200px;" name="settings[blogtitle]" value="<?=stripslashes($settings["blogtitle"])?>" /></td> 
    1125                                 </tr><tr> 
    1126                                         <td style="vertical-align: top;">blog/meta description:</td> 
    1127                                         <td><textarea name="settings[blogdescription]" style="width: 200px; height: 100px;"><?=stripslashes($settings["blogdescription"])?></textarea></td> 
    1128                                 </tr><tr> 
    1129                                         <td style="vertical-align: top;">meta keywords</td> 
    1130                                         <td> 
    1131                                                 <textarea name="settings[blogkeywords]" style="width: 200px; height: 100px;"><?=stripslashes($settings["blogkeywords"])?></textarea> 
    1132                                         </td> 
    1133                                 </tr><tr> 
    1134                                         <td style="vertical-align: top;">posts per page</td> 
    1135                                         <td> 
    1136                                                 <select name="settings[postsperpage]"> 
    1137                                                         <option value="10"<? if ($settings["postsperpage"] == 10) { echo " SELECTED"; } ?>>10</option> 
    1138                                                         <option value="20"<? if ($settings["postsperpage"] == 20) { echo " SELECTED"; } ?>>20</option> 
    1139                                                         <option value="50"<? if ($settings["postsperpage"] == 50) { echo " SELECTED"; } ?>>50</option> 
    1140                                                         <option value="75"<? if ($settings["postsperpage"] == 75) { echo " SELECTED"; } ?>>75</option> 
    1141                                                         <option value="100"<? if ($settings["postsperpage"] == 100) { echo " SELECTED"; } ?>>100</option> 
    1142                                                 </select> 
    1143                                         </td> 
    1144                                 </tr><tr> 
    1145                                         <td>enable anonymous comments</td> 
    1146                                         <td> 
    1147                                                 <select name="settings[allowanoncomments]"> 
    1148                                                         <option value="0">no</option> 
    1149                                                         <option value="1"<? if ($settings["allowanoncomments"] == 1) { echo " SELECTED"; } ?>>yes</option> 
    1150                                                 </select> 
    1151                                         </td> 
    1152                                 </tr><tr> 
    1153                                         <td colspan="2">&nbsp;</td> 
    1154                                 </tr><tr> 
    1155                                         <td>&nbsp;</td> 
    1156                                         <td><input type="submit" value="save" /></td> 
    1157                                 </tr></table> 
    1158                                 </form> 
    1159                         </div> 
    1160                 </div> 
    1161                 <div class="log_post_foot"> 
    1162                 </div> 
    1163         </div> 
    1164         <? 
    1165 } 
    1166  
    1167 //}}}----------------------------------- 
    1168 //{{{ save_settings: save settings to db 
    1169 //-------------------------------------- 
    1170 function save_settings($settings) { 
    1171         global $db; 
    1172         $queries = array(); 
    1173         /* get current settings */ 
    1174         $sql = "SELECT * FROM settings"; 
    1175         $res =& $db->query($sql); 
    1176         while ($res->fetchInto($row, DB_FETCHMODE_ASSOC)) { 
    1177                 $settings_db[$row["settingname"]]["id"]  = $row["id"]; 
    1178                 $settings_db[$row["settingname"]]["val"] = $row["settingvalue"]; 
    1179         } 
    1180         /* construct queries to sync database with userinput */ 
    1181         foreach ($settings as $key=>$val) { 
    1182                 if (array_key_exists(preg_quote(_strip_tags($key), "'"), $settings_db)) { 
    1183                         //setting was there, we need to UPDATE it 
    1184                         $queries[] = sprintf("UPDATE settings SET settingvalue = '%s' WHERE settingname = '%s'", preg_quote(_strip_tags($val), "'"), preg_quote(strip_tags($key), "'")); 
    1185                 } else { 
    1186                         //setting was not there, we need to INSERT it 
    1187                         $queries[] = sprintf("INSERT INTO settings (settingname, settingvalue) VALUES ('%s','%s')", preg_quote(strip_tags($key), "'"), preg_quote(_strip_tags($val), "'")); 
    1188                 } 
    1189         } 
    1190         /* run queries against db */ 
    1191         foreach ($queries as $q) { 
    1192                 $res =& $db->query($q); 
    1193                 if (PEAR::isError($res)) { 
    1194                         die($res->getUserInfo()); 
    1195                 } 
    1196         } 
    1197         /* return to blogsettings view */ 
    1198         header("Location: index.php?action=show_settings"); 
    1199 } 
    1200  
    1201 //}}}----------------------------------------- 
    1202 //{{{ show_menuitems(): show custom menu items 
    1203 //-------------------------------------------- 
    1204 function show_menuitems() { 
    1205         global $db; 
    1206         /* get max pos from db and add 1 for the default pos in new item */ 
    1207         $sql = "SELECT MAX(sortorder) FROM menulinks"; 
    1208         $res =& $db->query($sql); 
    1209         $res->fetchInto($row); 
    1210         $nextsort = (int)$row[0]+1; 
    1211         $sql = "SELECT * FROM menulinks ORDER BY sortorder,linktitle"; 
    1212         $res =& $db->query($sql); 
    1213         ?> 
    1214         <div class="log_post"> 
    1215                 <div class="log_post_head"> 
    1216                         <h1 class="log_post_h1"> 
    1217                                 Menu items 
    1218                         </h1> 
    1219                 </div> 
    1220                 <div class="log_post_body"> 
    1221                         <div class="log_post_normal"> 
    1222                                 <form name="settings" id="settingsform" method="post" action="index.php"> 
    1223                                 <input type="hidden" name="action" value="save_menuitems" /> 
    1224                                 <? 
    1225                                 while ($res->fetchInto($row, DB_FETCHMODE_ASSOC)) { 
    1226                                         ?> 
    1227                                         <table border="0" cellspacing="1" cellpadding="0"><tr> 
    1228                                                 <td>name</td> 
    1229                                                 <td><input style="width: 300px;" type="text" name="link[<?=$row["id"]?>][linktitle]" value="<?=stripslashes($row["linktitle"])?>" /></td> 
    1230                                         </tr><tr> 
    1231                                                 <td>link</td> 
    1232                                                 <td><input style="width: 300px;" type="text" name="link[<?=$row["id"]?>][url]" value="<?=stripslashes($row["url"])?>" /></td> 
    1233                                         </tr><tr> 
    1234                                                 <td>image</td> 
    1235                                                 <td><input style="width: 300px;" type="text" name="link[<?=$row["id"]?>][image]" value="<?=stripslashes($row["image"])?>" /></td> 
    1236                                         </tr><tr> 
    1237                                                 <td>pos</td> 
    1238                                                 <td> 
    1239                                                         <input style="width: 30px;" type="text" name="link[<?=$row["id"]?>][sortorder]" value="<?=(int)$row["sortorder"]?>" /><br /> 
    1240                                                         <input type="button" name="del" value="del" onclick="document.getElementById('state_<?=$row["id"]?>').value='delete'; document.getElementById('settingsform').submit();"> 
    1241                                                 </td> 
    1242                                         </tr></table> 
    1243                                         <input type="hidden" id="state_<?=$row["id"]?>" name="link[<?=$row["id"]?>][state]" value="save" /> 
    1244                                         <hr> 
    1245                                         <? 
    1246                                 } 
    1247                                 ?> 
    1248                                 <table border="0" cellspacing="1" cellpadding="0"><tr> 
    1249                                         <td>name</td> 
    1250                                         <td><input style="width: 300px;" type="text" name="link[0][linktitle]" value="" /></td> 
    1251                                 </tr><tr> 
    1252                                         <td>link</td> 
    1253                                         <td><input style="width: 300px;" type="text" name="link[0][url]" value="" /></td> 
    1254                                 </tr><tr> 
    1255                                         <td>image</td> 
    1256                                         <td><input style="width: 300px;" type="text" name="link[0][image]" value="" /></td> 
    1257                                 </tr><tr> 
    1258                                         <td>pos</td> 
    1259                                         <td> 
    1260                                                 <input style="width: 30px;" type="text" name="link[0][sortorder]" value="<?=$nextsort?>" /> 
    1261                                         </td> 
    1262                                 </tr></table> 
    1263                                 <input type="hidden" id="state_<?=$row["id"]?>" name="link[0][state]" value="save" /> 
    1264                                 <hr> 
    1265                                 <input type="submit" value="save all" /> 
    1266                                 </form> 
    1267                         </div> 
    1268                 </div> 
    1269         </div> 
    1270         <? 
    1271 } 
    1272  
    1273 //}}}----------------------------------------------------- 
    1274 //{{{ save_menuitems(links): store/remove database entries 
    1275 //-------------------------------------------------------- 
    1276 function save_menuitems($links) { 
    1277         global $db; 
    1278         /* walk through all the links */ 
    1279         if (is_array($links)) { 
    1280                 foreach ($links as $k=>$v) { 
    1281                         /* new item always has $k == 0 */ 
    1282                         if ($k == 0) { 
    1283                                 if (strlen(trim($v["linktitle"])) && strlen(trim($v["url"]))) { 
    1284                                         $sql  = "INSERT INTO menulinks (url, linktitle, image, sortorder) VALUES "; 
    1285                                         $sql .= sprintf("('%s', '%s', '%s', %d)", 
    1286                                                 preg_quote(strip_tags($v["url"]), "'"), 
    1287                                                 preg_quote(strip_tags($v["linktitle"]), "'"), 
    1288                                                 preg_quote(strip_tags($v["image"]), "'"), 
    1289                                                 $v["sortorder"] 
    1290                                         ); 
    1291                                         $res = $db->query($sql); 
    1292                                 } 
    1293                         } else { 
    1294                                 /* from db. this can be either be marked as delete or save */ 
    1295                                 if ($v["state"] == "delete") { 
    1296                                         $sql = sprintf("DELETE FROM menulinks WHERE id = %d", $k); 
    1297                                         $res = $db->query($sql); 
    1298                                 } elseif ($v["state"] == "save") { 
    1299                                         $sql  = "UPDATE menulinks SET "; 
    1300                                         $sql .= sprintf("url = '%s'", preg_quote(strip_tags($v["url"]), "'")); 
    1301                                         $sql .= sprintf(", linktitle = '%s'", preg_quote(strip_tags($v["linktitle"]), "'")); 
    1302                                         $sql .= sprintf(", image = '%s'", preg_quote(strip_tags($v["image"]), "'")); 
    1303                                         $sql .= sprintf(", sortorder = %d", $v["sortorder"]); 
    1304                                         $sql .= sprintf(" WHERE id = %d", $k); 
    1305                                         $res = $db->query($sql); 
    1306                                 } 
    1307                         } 
    1308                 } 
    1309         } 
    1310         header("Location: index.php?action=show_menuitems"); 
    1311 } 
    1312  
    1313 //}}}------------------------------------ 
    1314 //{{{ show_comments(): show comment items 
    1315 //--------------------------------------- 
    1316 function show_comments($options) { 
    1317         global $db; 
    1318         if (!$options["top"])   { $options["top"]   = 0; }  else { $options["top"]   = (int)$options["top"]; } 
    1319         if (!$options["limit"]) { $options["limit"] = 15; } else { $options["limit"] = (int)$options["limit"]; } 
    1320         /* create an array with the article titles */ 
    1321         $sql = "SELECT id,title FROM articles"; 
    1322         $res = $db->query($sql); 
    1323         $articles[0] = "no article"; 
    1324         while ($res->fetchInto($row, DB_FETCHMODE_ASSOC)) { 
    1325                 $articles[$row["id"]] = stripslashes($row["title"]); 
    1326         } 
    1327         /* loop through the comments */ 
    1328         $res_count =& $db->query("SELECT COUNT(*) FROM comments"); 
    1329         $res_count->fetchInto($counter_r, DB_FETCHMODE_NUM); 
    1330         $counter = $counter_r[0]; 
    1331         $res =& $db->limitQuery("SELECT * FROM comments ORDER BY date DESC", $options["top"], $options["limit"]); 
    1332         if (PEAR::isError($res)) { 
    1333                 die($res->getMessage()); 
    1334         } 
    1335         while ($res->fetchInto($row, DB_FETCHMODE_ASSOC)) { 
    1336                 if (!trim($row["title"])) { $row["title"] = "no title"; } 
     1042                echo "<div class=\"log_post\"></div>"; 
     1043                while ($res->fetchInto($row, DB_FETCHMODE_ASSOC)) { 
     1044                        if (!trim($row["title"])) { $row["title"] = "no title"; } 
     1045                        ?> 
     1046                        <div class="log_post"> 
     1047                                <div class="log_post_head"> 
     1048                                        <h1 class="log_post_h1"> 
     1049                                                <?=htmlspecialchars(stripslashes($row["title"]))?> (<?=$articles[$row["articles_id"]]?>) 
     1050                                        </h1><br /> 
     1051                                        <h2 class="log_post_h2">name: <?=stripslashes(htmlspecialchars($row["name"]))?>&nbsp;ip: <?=$row["ip"]?></h2> 
     1052                                        <h2 class="log_post_h2">website: <?=stripslashes(htmlspecialchars($row["website"]))?>&nbsp;email: <?=stripslashes(htmlspecialchars($row["email"]))?></h2> 
     1053                                </div> 
     1054                                <div class="log_post_body"> 
     1055                                        <div class="log_post_normal"><?=stripslashes(htmlspecialchars($row["comment"]))?></div> 
     1056                                </div> 
     1057                                <div class="log_post_foot"> 
     1058                                        <!-- not yet implemented 
     1059                                        <? if (trim($row["ip"])) { ?><a href="index.php?action=blacklist_ip&commentid=<?=$row["id"]?>">blacklist ip</a><? } ?>&nbsp;&nbsp; 
     1060                                        --> 
     1061                                        <? if (!$row["deleted"]) { ?> 
     1062                                                <a href="index.php?action=delete_comment&id=<?=$row["id"]?>">delete</a> 
     1063                                        <? } else { ?> 
     1064                                                <a href="index.php?action=recover_comment&id=<?=$row["id"]?>">recover</a> 
     1065                                        <? } ?> 
     1066                                </div> 
     1067                        </div> 
     1068                        <? 
     1069                } 
     1070                if ($options["top"]) { 
     1071                        echo "<a class=\"link_prev\" href=\"index.php?action=show_comments&amp;options[top]=".($options["top"]-$options["limit"])."\">previous</a> "; 
     1072                } 
     1073                if (($options["top"] + $options["limit"]) > $counter) { 
     1074                        $end = $counter; 
     1075                } else { 
     1076                        $end = ($options["top"]+$options["limit"]); 
     1077                } 
     1078                if ($counter == 0) { 
     1079                        echo "<span class=\"log_cat\">no comments"; 
     1080                } else { 
     1081                        echo "<span class=\"log_cat\">showing ".($options["top"]+1)." to ".$end." of ".$counter." total comments"; 
     1082                } 
     1083                if (($options["top"]+$options["limit"]) < $counter) { 
     1084                        echo " <a class=\"link_next\" href=\"index.php?action=show_comments&amp;options[top]=".($options["top"]+$options["limit"])."\">next</a>"; 
     1085                } 
     1086                echo "</span>"; 
     1087        } 
     1088        /* }}} */ 
     1089        /* delete_comment {{{ */ 
     1090        /** 
     1091         * Delete a comment from the database 
     1092         * 
     1093         * @param int The comment id to remove 
     1094         */ 
     1095        public function delete_comment($id) { 
     1096                $sql = sprintf("DELETE FROM comments WHERE id = %d", $id); 
     1097                $res = $this->db->query($sql); 
     1098                header("Location: index.php?action=show_comments"); 
     1099        } 
     1100        /* }}} */ 
     1101        /* show_settings {{{ */ 
     1102        /** 
     1103         * show the blogsettings with edit boxen 
     1104         */ 
     1105        public function show_settings() { 
     1106                /* get settings from db */ 
     1107                $settings = array(); 
     1108                $sql = "SELECT * FROM settings"; 
     1109                $res =& $this->db->query($sql); 
     1110                while ($res->fetchInto($row, DB_FETCHMODE_ASSOC)) { 
     1111                        $settings[$row["settingname"]] = $row["settingvalue"]; 
     1112                } 
    13371113                ?> 
    13381114                <div class="log_post"> 
    13391115                        <div class="log_post_head"> 
    13401116                                <h1 class="log_post_h1"> 
    1341                                         <?=htmlspecialchars(stripslashes($row["title"]))?> (<?=$articles[$row["articles_id"]]?>) 
    1342                                 </h1><br /> 
    1343                                 <h2 class="log_post_h2">name: <?=stripslashes(htmlspecialchars($row["name"]))?>&nbsp;ip: <?=$row["ip"]?></h2> 
    1344                                 <h2 class="log_post_h2">website: <?=stripslashes(htmlspecialchars($row["website"]))?>&nbsp;email: <?=stripslashes(htmlspecialchars($row["email"]))?></h2> 
     1117                                Blogsettings 
     1118                                </h1> 
    13451119                        </div> 
    13461120                        <div class="log_post_body"> 
    1347                                 <div class="log_post_normal"><?=stripslashes(htmlspecialchars($row["comment"]))?></div> 
     1121                                <div class="log_post_normal"> 
     1122                                        <form name="settings" method="post" action="index.php"> 
     1123                                        <input type="hidden" name="action" value="save_settings" /> 
     1124                                        <table border="0" cellspacing="0" cellpadding="0"><tr> 
     1125                                                <td style="vertical-align: top;">blog title</td> 
     1126                                                <td><input type="text" style="width: 200px;" name="settings[blogtitle]" value="<?=stripslashes($settings["blogtitle"])?>" /></td> 
     1127                                        </tr><tr> 
     1128                                                <td style="vertical-align: top;">blog/meta description:</td> 
     1129                                                <td><textarea name="settings[blogdescription]" style="width: 200px; height: 100px;"><?=stripslashes($settings["blogdescription"])?></textarea></td> 
     1130                                        </tr><tr> 
     1131                                                <td style="vertical-align: top;">meta keywords</td> 
     1132                                                <td> 
     1133                                                        <textarea name="settings[blogkeywords]" style="width: 200px; height: 100px;"><?=stripslashes($settings["blogkeywords"])?></textarea> 
     1134                                                </td> 
     1135                                        </tr><tr> 
     1136                                                <td style="vertical-align: top;">posts per page</td> 
     1137                                                <td> 
     1138                                                        <select name="settings[postsperpage]"> 
     1139                                                                <option value="10"<? if ($settings["postsperpage"] == 10) { echo " SELECTED"; } ?>>10</option> 
     1140                                                                <option value="20"<? if ($settings["postsperpage"] == 20) { echo " SELECTED"; } ?>>20</option> 
     1141                                                                <option value="50"<? if ($settings["postsperpage"] == 50) { echo " SELECTED"; } ?>>50</option> 
     1142                                                                <option value="75"<? if ($settings["postsperpage"] == 75) { echo " SELECTED"; } ?>>75</option> 
     1143                                                                <option value="100"<? if ($settings["postsperpage"] == 100) { echo " SELECTED"; } ?>>100</option> 
     1144                                                        </select> 
     1145                                                </td> 
     1146                                        </tr><tr> 
     1147                                                <td>enable anonymous comments</td> 
     1148                                                <td> 
     1149                                                        <select name="settings[allowanoncomments]"> 
     1150                                                                <option value="0">no</option>