Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision Both sides next revision
u2_progc [2011-01-21 10:36]
Joakim Forsgren
u2_progc [2011-01-21 10:47]
Joakim Forsgren
Line 34: Line 34:
  
 <code php> <code php>
 +
 +// forumController 
 if($_POST['a']=='InsertItem') { if($_POST['a']=='InsertItem') {
- if (!$_POST['Item']) { +  if (!$_POST['Item']) { 
- $session->AddError('You can\'t post empty item...'); +    $session->AddError('You can\'t post empty item...'); 
- header ('location: ' . INDEX . '?c=' . $_GET['c'] . '&a=' . $_GET['a']); +    header ('location: ' . INDEX . '?c=' . $_GET['c'] . '&a=' . $_GET['a']); 
- exit(); +    exit(); 
-+  
- $data = array ( +  $data = array ( 
- 'Item' => $_POST['Item'], +    'Item' => $_POST['Item'], 
- 'UserID' => $session->Get('UserID'), +    'UserID' => $session->Get('UserID'), 
- 'ThreadID' => $_POST['ThreadID'] , +    'ThreadID' => $_POST['ThreadID'] , 
- 'CreateDate' => date('Y-m-j H:i:s'), +    'CreateDate' => date('Y-m-j H:i:s'), 
- 'ChangeDate' => date('Y-m-j H:i:s'+    'ChangeDate' => date('Y-m-j H:i:s'
- ); +  ); 
- $forum->InsertItem($data); +  $forum->InsertItem($data); 
- $session->AddSuccess('Item saved!'); +  $session->AddSuccess('Item saved!'); 
- header ('location: ' . INDEX . '?c=' . $_GET['c'] . '&a=' . $_GET['a'] . '&id=' . $_POST['ThreadID']); +  header ('location: ' . INDEX . '?c=' . $_GET['c'] . '&a=' . $_GET['a'] . '&id=' . $_POST['ThreadID']); 
- exit();+  exit();
 } }
  
 +// forum.php (model_forum)
 public function DeleteThread ($threadid) { public function DeleteThread ($threadid) {
- $query = "DELETE lab5_Threads, lab5_Items FROM `lab5_Threads` LEFT JOIN `lab5_Items` USING(ThreadID)  +  $query = "DELETE lab5_Threads, lab5_Items FROM `lab5_Threads` LEFT JOIN `lab5_Items` USING(ThreadID)  
- WHERE ThreadID = '" . $_POST['ThreadID'] . "' AND (lab5_Threads.UserID = '" . service_session::getInstance()->Get('UserID') . "' OR " . service_session::getInstance()->Get('Admin') . ")"; +            WHERE ThreadID = '" . $_POST['ThreadID'] . "' AND (lab5_Threads.UserID = '" . service_session::getInstance()->Get('UserID') . "'  
- return $this->db->Delete($query); +            OR " . service_session::getInstance()->Get('Admin') . ")"; 
- }+  return $this->db->Delete($query); 
 +} 
 </code> </code>