Beispiel #1
0
         echo $filename . "<br />";
     }
 }
 sql("DELETE FROM `pictures` WHERE `user_id`=&1 AND `object_type`=1", $userid);
 // statpic
 if (is_file($dynbasepath . 'images/statpics/statpic' . $userid . '.jpg')) {
     unlink($dynbasepath . 'images/statpics/statpic' . $userid . '.jpg');
 }
 // queries
 sql("DELETE FROM `queries` WHERE `user_id`=&1", $userid);
 // cache_watches
 $rs = sql('SELECT cache_id FROM cache_watches WHERE user_id = &1', $userid);
 if (mysql_num_rows($rs) > 0) {
     for ($i = 0; $i < mysql_num_rows($rs); $i++) {
         $record = sql_fetch_array($rs);
         remove_watch($record['cache_id'], $userid);
     }
 }
 // watches_notified
 sql("DELETE FROM `watches_notified` WHERE `user_id`=&1", $userid);
 // cache_logs
 $rs = sql("SELECT `id`, `cache_id`, `type` FROM `cache_logs` WHERE `user_id`=&1", $userid);
 while ($r = sql_fetch_assoc($rs)) {
     sql("DELETE FROM `cache_logs` WHERE `id`=&1", $r['id']);
     if ($r['type'] == 1) {
         sql("UPDATE `caches` SET `founds`=`founds`-1 WHERE `cache_id`=&1", $r['cache_id']);
     } else {
         if ($r['type'] == 2) {
             sql("UPDATE `caches` SET `notfounds`=`notfounds`-1 WHERE `cache_id`=&1", $r['cache_id']);
         } else {
             if ($r['type'] == 3) {
Beispiel #2
0
$cache_count = $db->multiVariableQueryValue('SELECT COUNT(*) FROM caches WHERE user_id = :1', 0, $user_id);
if ($cache_count > 0) {
    printf("Cannot delete: user %s owns %d cache(s)\n", $user_name, $cache_count);
    exit(3);
}
// Check if user created any logs
$log_count = $db->multiVariableQueryValue('SELECT COUNT(*) FROM cache_logs WHERE user_id = :1', 0, $user_id);
if ($log_count > 0) {
    printf("Cannot delete: user %s created %d log(s)\n", $user_name, $log_count);
    exit(4);
}
// Check if user saved any pictures
// Probably an overkill after checking that there are no caches/no logs.
$pic_count = $db->multiVariableQueryValue('SELECT COUNT(*) FROM pictures WHERE user_id = :1', 0, $user_id);
if ($pic_count > 0) {
    printf("Cannot delete: user %s saved %d picture(s)\n", $user_name, $pic_count);
    exit(5);
}
// Record user removal
$db->multiVariableQuery("INSERT INTO removed_objects (localid, uuid, `type`, removed_date, node)" . " SELECT user_id, uuid, 4, NOW(), :2 FROM user WHERE user_id = :1", $user_id, $oc_nodeid);
// Delete saved queries
$db->multiVariableQuery('DELETE FROM queries WHERE user_id = :1', $user_id);
// Clean all cache_watches
$s = $db->multiVariableQuery('SELECT cache_id FROM cache_watches WHERE user_id = :1', $user_id);
$cache_watches = $db->dbResultFetchAll($s);
foreach ($cache_watches as $watch) {
    remove_watch($watch['cache_id'], $user_id);
}
// Delete user
$db->multiVariableQuery('DELETE FROM user WHERE user_id = :1', $user_id);
printf("User %s deleted\n", $user_name);
            if (mysql_num_rows($rs) > 0) {
                for ($i = 0; $i < mysql_num_rows($rs); $i++) {
                    $record = sql_fetch_array($rs);
                    remove_watch($record['cache_id'], $usr);
                }
            }
        } else {
            // sprawdzenie czy user rzeczywiście obserwuje keszynkę
            // (check if really user is watching specified cache)
            $id_usera = sql_escape($usr['userid']);
            $id_keszynki = sql_escape($cache_id);
            $czy_user_obserwuje_kesz = mysql_num_rows(mysql_query("SELECT `id` FROM `cache_watches` WHERE `cache_id` = {$id_keszynki} AND `user_id` = {$id_usera}"));
            // jeśli tak, usuwamy wpisy z bazy
            // (if so proceed to remove from database)
            if ($czy_user_obserwuje_kesz >= 1) {
                remove_watch($cache_id, $usr);
            }
        }
    }
    tpl_redirect($target);
}
tpl_BuildTemplate();
function remove_watch($cache_id, $usr)
{
    //remove watch
    sql('DELETE FROM cache_watches WHERE cache_id=\'' . sql_escape($cache_id) . '\' AND user_id=\'' . sql_escape($usr['userid']) . '\'');
    //remove from caches
    $rs = sql('SELECT watcher FROM caches WHERE cache_id=\'' . sql_escape($cache_id) . '\'');
    if (mysql_num_rows($rs) > 0) {
        $record = mysql_fetch_array($rs);
        sql('UPDATE caches SET watcher=\'' . ($record['watcher'] - 1) . '\' WHERE cache_id=\'' . sql_escape($cache_id) . '\'');