Example #1
0
 public static function removeInactive($maxIdleTime)
 {
     global $db;
     $fromWhen = time() - $maxIdleTime * 86400;
     $fromWhen = strftime('%Y-%m-%d %H:%M:%S', $fromWhen);
     $usersResult = $db->query('select id from users where (lastVisit<"' . $fromWhen . '" or level=0) and level<2');
     $pendingCount = $removedCount = 0;
     while ($userRow = db::fetch($usersResult)) {
         $pendingCount++;
         $result = $db->query('select id from nodes where user="******"');
         while ($row = db::fetch($result)) {
             node::remove($row['id']);
         }
         $ok = 1;
         $db->query('delete from activations where user="******"');
         $messagesResult = $db->query('select id from messages where recipient="' . $userRow['id'] . '" or sender="' . $userRow['id'] . '"');
         while ($row = db::fetch($messagesResult)) {
             $db->query('insert into free_ids (id, type) values ("' . $row['id'] . '", "messages")');
             if ($db->affected_rows() == -1) {
                 $ok = 0;
             }
             $db->query('delete from messages where id="' . $row['id'] . '"');
             if ($db->affected_rows() == -1) {
                 $ok = 0;
             }
         }
         $db->query('insert into free_ids (id, type) values ("' . $userRow['id'] . '", "users")');
         if ($db->affected_rows() == -1) {
             $ok = 0;
         }
         $db->query('delete from users where id="' . $userRow['id'] . '"');
         if ($db->affected_rows() == -1) {
             $ok = 0;
         }
         if ($ok) {
             $status = 'done';
         } else {
             $status = 'error';
         }
         if ($ok) {
             $removedCount++;
         }
     }
     return array('found' => $pendingCount, 'removed' => $removedCount);
 }
Example #2
0
             $node->location['x'] = $_POST['x'];
             $node->location['y'] = $_POST['y'];
             $message = $ui[$node->add($_SESSION[$shortTitle . 'User']['id'])];
         } else {
             $message = $ui['insufficientData'];
         }
     }
     break;
 case 'remove':
     if (isset($_GET['nodeId'])) {
         $node = new node();
         $status = $node->get('id', $_GET['nodeId']);
         if ($status == 'done') {
             if (isset($_GET['go']) && $_GET['go']) {
                 if ($node->data['user'] == $_SESSION[$shortTitle . 'User']['id']) {
                     $status = node::remove($_GET['nodeId']);
                     if ($status == 'done') {
                         header('location: node.php?action=list');
                     } else {
                         $message = $ui[$status];
                     }
                 } else {
                     $message = $ui['accessDenied'];
                 }
             }
         } else {
             $message = $ui[$status];
         }
     } else {
         $message = $ui['insufficientData'];
     }