Changeset 112

Show
Ignore:
Timestamp:
31/05/05 21:54:02 (4 years ago)
Author:
dez
Message:

Entry deletion written as per #1
Check to prevent passwords containing numbers removed - there's nothing wrong with numbers in passwords!

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • admin.lib.php

    r111 r112  
    289289                } 
    290290        } 
     291 
    291292        //update form 
    292293        function updateForm($id) 
     
    304305        } 
    305306 
     307        //delete an entry 
     308        function deleteEntry($id) 
     309        { 
     310                $id = $this->blog->makeCleanString($id); 
     311                if (!$id) { 
     312                        error(4,"If you dont give me a post how do you expect me to delete it"); 
     313                } 
     314                //no errors, so continue.. 
     315                if (!$this->inputError) { 
     316                        //check to see this post exists 
     317                        $sql = db_query("SELECT id from entries where shortsubject = '".$id."' AND user_id='".$this->id."';"); 
     318                        $sqlNum = db_num_rows($sql); 
     319                        //yes?, we can delete it then.. 
     320                        if ($sqlNum == 1) {  
     321                                $sql = db_query("DELETE FROM entries WHERE shortsubject = '{$id}' AND user_id = '".$this->id."';");                      
     322                                if (!$sql) { 
     323                                        error(2,"Entry deletion failed - ".db_error()); 
     324                                }  
     325                                else { 
     326                                        $this->inputError = _("Entry deleted."); 
     327                                        $this->updateForm($id); 
     328                                } 
     329                        } 
     330                        //cant update non-existant entrys 
     331                        else { 
     332                                 error(2,_("Cannot delete entry, as it does not exist.".db_error())); 
     333                        } 
     334                } 
     335                //redisplay entry form if there are errors 
     336                else { 
     337                        $this->updateForm($id); 
     338                } 
     339        } 
     340 
    306341        //update settings 
    307342        function updateSettings() 
     
    348383                //sanitise password and encrypt 
    349384                if ($_POST['pass1'] != "") { 
    350                         if ((isset($_POST['pass1']) && trim($_POST['pass1']) != "" && (int)$_POST['pass1'] == 0) && ($_POST['pass1']==$_POST['pass2'])) { 
     385                        if ((isset($_POST['pass1']) && trim($_POST['pass1']) != "") && ($_POST['pass1']==$_POST['pass2'])) { 
    351386                                $password = crypt($_POST['pass1']); 
    352387                                $setpass = true; 
  • admin.php

    r106 r112  
    5858                                                break; 
    5959                                        case "showentries": 
    60                                                 $admin->printEntries(); 
     60                                                $admin->printEntries() ; 
     61                                                break; 
     62                                        case "deleteentry": 
     63                                                $admin->deleteEntry(array_shift($request)) ; 
    6164                                                break; 
    6265                                        default: