function delete_collection($del_id) { global $config; $sql = "SELECT c.name AS collection_name, c.path AS collection_path, c.id AS collection_id\r\n\t\tFROM " . TABLE_PREFIX . "collections c\r\n\t\tWHERE c.id = '{$del_id}'"; $result = run_query($sql); $collection = mysql_fetch_assoc($result); if (!$collection) { return array('errors' => plog_tr('No such collection')); } // first delete all albums registered with this album $sql = 'SELECT * FROM ' . TABLE_PREFIX . 'albums WHERE parent_id = ' . $collection['collection_id']; $result = run_query($sql); while ($row = mysql_fetch_assoc($result)) { delete_album($row['id']); } // XXX: un-register collection $query = "DELETE FROM " . TABLE_PREFIX . "collections WHERE `id`= '" . $collection['collection_id'] . "'"; run_query($query); // finally try to delete the directory itself. It will succeed, if there are no files left inside it .. // if there are then .. how did they get there? Probably not through plogger and in this case do we // really want to delete those? $source_collection_name = $collection["collection_path"]; $collection_directory = realpath($config['basedir'] . 'images/' . $source_collection_name); $relative_path = substr($collection_directory, 0, strlen($config['basedir'])); $collection_path = explode('/', substr($collection_directory, strlen($config['basedir']))); // it needs to have 2 parts - images and collection name, if it doesn't, then there is something // wrong with collection name and it's probably not safe to try to delete the directory if ($relative_path == $config['basedir'] && sizeof($collection_path) == 2) { @chmod($collection_directory, 0777); $delete_result = rmdir($collection_directory); if (!$delete_result) { return array('errors' => plog_tr('Collection directory still contains files after all albums have been deleted.')); } } else { return array('errors' => plog_tr('Collection has invalid path, not deleting directory')); } return array(); }
############################################################################################ ## Удаление пользователей ## ############################################################################################ case "del": $uid = check($_GET['uid']); $deldate = abs(intval($_GET['deldate'])); $point = abs(intval($_GET['point'])); if ($uid == $_SESSION['token']) { if ($deldate >= 180) { $deltime = $deldate * 24 * 3600; $queryusers = DB::run()->query("SELECT users_login FROM users WHERE users_timelastlogin<? AND users_point<=?;", array(SITETIME - $deltime, $point)); $users = $queryusers->fetchAll(PDO::FETCH_COLUMN); $total = count($users); if ($total > 0) { foreach ($users as $value) { delete_album($value); delete_users($value); } echo 'Пользователи не посещавшие сайт более <b>' . $deldate . '</b> дней, успешно удалены!<br />'; echo 'Было удалено пользователей: <b>' . $total . '</b><br /><br />'; } else { show_error('Пользователи для удаления отсутсвуют!'); } } else { show_error('Ошибка! Указанно недопустимое время для удаления!'); } } else { show_error('Ошибка! Неверный идентификатор сессии, повторите действие!'); } echo '<img src="/images/img/back.gif" alt="image" /> <a href="delusers.php">Вернуться</a><br />'; break;
function jump($action) { switch ($action) { case "add_album": do_add_album(); break; case "album_action": do_album_action(); break; case "album_update": do_album_update_action(); break; case "track_add": do_track_add(); break; case "track_update": do_track_update(); break; case "album_delete_confirm": delete_album(); break; case "track_delete_confirm": delete_track(); break; default: // default to show main page main_page(); } return; }
pageheader($lang_delete_php['del_user']); starttable("100%", $lang_delete_php['del_user'], 6); foreach ($users_scheduled_for_action as $key) { $result = cpg_db_query("SELECT user_name FROM {$CONFIG['TABLE_USERS']} WHERE user_id = '{$key}'"); print '<tr>'; if (!mysql_num_rows($result)) { print '<td class="tableb">' . $lang_delete_php['err_unknown_user'] . '</td>'; } else { $user_data = mysql_fetch_array($result); print '<td class="tableb">'; // First delete the albums $result2 = cpg_db_query("SELECT aid FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = '" . (FIRST_USER_CAT + $key) . "'"); $user_alb_counter = 0; while ($album = mysql_fetch_array($result2)) { starttable('100%'); delete_album($album['aid']); endtable(); $user_alb_counter++; } // while mysql_free_result($result2); starttable('100%'); print '<tr>'; // Then anonymize comments posted by the user $comment_result = cpg_db_query("SELECT COUNT(*) FROM {$CONFIG['TABLE_COMMENTS']} WHERE author_id = '{$key}'"); $comment_counter = mysql_fetch_array($comment_result); mysql_free_result($comment_result); print '<td class="tableb" width="25%">'; if ($_REQUEST['delete_comments'] == 'yes') { cpg_db_query("DELETE FROM {$CONFIG['TABLE_COMMENTS']} WHERE author_id = '{$key}'"); if ($comment_counter[0] > 0) {
case 'move-delete': // We're either moving or deleting $num_items = 0; $action_result = array(); if (isset($_REQUEST['delete_checked'])) { // Perform the delete function on the selected items if (isset($_REQUEST['selected'])) { foreach ($_REQUEST['selected'] as $del_id) { if ($level == 'pictures') { $rv = delete_picture($del_id); } if ($level == 'collections') { $rv = delete_collection($del_id); } if ($level == 'albums') { $rv = delete_album($del_id); } if (isset($rv['errors'])) { $output .= "\n\t" . '<p class="errors">' . $rv['errors'] . '</p>' . "\n"; } else { $num_items++; } } if ($num_items > 0) { $text = $num_items == 1 ? plog_tr('entry') : plog_tr('entries'); $output .= "\n\t" . '<p class="success">' . sprintf(plog_tr('You have deleted %s successfully'), '<strong>' . $num_items . '</strong> ' . $text) . '.</p>' . "\n"; } } else { $output .= "\n\t" . '<p class="errors">' . plog_tr('Nothing selected to delete') . '!</p>' . "\n"; } } else {
$continueURL = "thumbnails.php?album={$aid}"; $create_update = ''; break; // // Album // // // Album // case 'album': if (!(GALLERY_ADMIN_MODE || USER_ADMIN_MODE)) { redirect_header('index.php', 2, _MD_ACCESS_DENIED); } $aid = (int) $_GET['id']; $out_caption = _MD_DEL_DELALB; delete_album($aid); $data = array(); $data[] = array('del_message' => $del_message, 'pic_del' => $pic_del); $continueURL = 'index.php'; $create_update = ''; break; // // Unknow command // // // Unknow command // default: redirect_header('index.php', 2, _MD_PARAM_MISSING); } if ($out_caption) {
function delete_user($key) { global $CONFIG, $lang_delete_php; $superCage = Inspekt::makeSuperCage(); $result = cpg_db_query("SELECT user_name FROM {$CONFIG['TABLE_USERS']} WHERE user_id = '" . (int) $key . "'"); print '<tr>'; if (!$result->numRows()) { print '<td class="tableb">' . $lang_delete_php['err_unknown_user'] . '</td>'; } else { $user_data = $result->fetchAssoc(); print '<td class="tableb">'; // First delete the albums $result2 = cpg_db_query("SELECT aid FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = '" . (FIRST_USER_CAT + $key) . "'"); $user_alb_counter = 0; while ($album = $result2->fetchAssoc()) { starttable('100%'); print delete_album($album['aid']); endtable(); $user_alb_counter++; } // while $result2->free(); starttable('100%'); print '<tr>'; // Then anonymize comments posted by the user $comment_result = cpg_db_query("SELECT COUNT(*) FROM {$CONFIG['TABLE_COMMENTS']} WHERE author_id = '{$key}'"); $comment_counter = $comment_result->fetchRow(true); print '<td class="tableb" width="25%">'; if ($superCage->get->keyExists('delete_comments')) { $delete_comments_choice = $superCage->get->getAlpha('delete_comments'); } elseif ($superCage->post->keyExists('delete_comments')) { $delete_comments_choice = $superCage->post->getAlpha('delete_comments'); } if ($delete_comments_choice == 'yes') { cpg_db_query("DELETE FROM {$CONFIG['TABLE_COMMENTS']} WHERE author_id = '{$key}'"); if ($comment_counter[0] > 0) { print cpg_fetch_icon('ok', 0) . ' '; } printf($lang_delete_php['deleted_comments'], $comment_counter[0]); } else { cpg_db_query("UPDATE {$CONFIG['TABLE_COMMENTS']} SET author_id = 0, msg_author = '' WHERE author_id = '{$key}'"); if ($comment_counter[0] > 0) { print cpg_fetch_icon('ok', 0) . ' '; } printf($lang_delete_php['anonymized_comments'], $comment_counter[0]); } print '</td>'; // Do the same for pictures uploaded in public albums $publ_upload_result = cpg_db_query("SELECT COUNT(*) FROM {$CONFIG['TABLE_PICTURES']} WHERE owner_id = '{$key}'"); $publ_upload_counter = $publ_upload_result->fetchRow(true); print '<td class="tableb" width="25%">'; if ($superCage->get->keyExists('delete_files')) { $delete_files_choice = $superCage->get->getAlpha('delete_files'); } elseif ($superCage->post->keyExists('delete_files')) { $delete_files_choice = $superCage->post->getAlpha('delete_files'); } if ($delete_files_choice == 'yes') { cpg_db_query("DELETE FROM {$CONFIG['TABLE_PICTURES']} WHERE owner_id = '{$key}'"); if ($publ_upload_counter[0] > 0) { print cpg_fetch_icon('ok', 0) . ' '; } printf($lang_delete_php['deleted_uploads'], $publ_upload_counter[0]); } else { cpg_db_query("UPDATE {$CONFIG['TABLE_PICTURES']} SET owner_id = 0 WHERE owner_id = '{$key}'"); if ($publ_upload_counter[0] > 0) { print cpg_fetch_icon('ok', 0) . ' '; } printf($lang_delete_php['anonymized_uploads'], $publ_upload_counter[0]); } print '</td>'; // Finally delete the user cpg_db_query("DELETE FROM {$CONFIG['TABLE_USERS']} WHERE user_id = '{$key}'"); // Clear any bans cpg_db_query("DELETE FROM {$CONFIG['TABLE_BANNED']} WHERE user_id = '{$key}'"); // Clear any favourites cpg_db_query("DELETE FROM {$CONFIG['TABLE_FAVPICS']} WHERE user_id = '{$key}'"); print '<td class="tableb" width="50%">'; print '<strong>'; print cpg_fetch_icon('ok', 0) . ' '; printf($lang_delete_php['user_deleted'], '«' . $user_data['user_name'] . '»'); print '</strong>'; print '</td>'; print '</tr>'; endtable(); print '</td>'; } $result->free(); print '</tr>'; }
function delete_album($album_id) { global $smcFunc; $album_id = (int) $album_id; $request = $smcFunc['db_query']('', ' SELECT id_album FROM {db_prefix}Maximum_albums WHERE parent_id = {int:id_parent}', array('id_parent' => $album_id)); while ($album = $smcFunc['db_fetch_assoc']($request)) { $request2 = $smcFunc['db_query']('', ' SELECT id_picture FROM {db_prefix}Maximum_pictures WHERE id_album = {int:id_album}', array('id_album' => $album['id_album'])); while ($picture = $smcFunc['db_fetch_assoc']($request2)) { delete_picture($picture['id_picture']); } $smcFunc['db_query']('', ' DELETE FROM {db_prefix}Maximum_albums WHERE id_album = {int:id_album}', array('id_album' => $album['id_album'])); delete_album($album['id_album']); } $request = $smcFunc['db_query']('', ' SELECT id_picture FROM {db_prefix}Maximum_pictures WHERE id_album = {int:id_album}', array('id_album' => $album_id)); while ($picture = $smcFunc['db_fetch_assoc']($request)) { delete_picture($picture['id_picture']); } $smcFunc['db_query']('', ' DELETE FROM {db_prefix}Maximum_albums WHERE id_album = {int:id_album}', array('id_album' => $album_id)); }
if (!empty($mailblack)) { $blackmail = DB::run()->querySingle("SELECT `black_id` FROM `blacklist` WHERE `black_type`=? AND `black_value`=? LIMIT 1;", array(1, $user['users_email'])); if (empty($blackmail) && !empty($user['users_email'])) { DB::run()->query("INSERT INTO `blacklist` (`black_type`, `black_value`, `black_user`, `black_time`) VALUES (?, ?, ?, ?);", array(1, $user['users_email'], $log, SITETIME)); } } // -------------// if (!empty($loginblack)) { $blacklogin = DB::run()->querySingle("SELECT `black_id` FROM `blacklist` WHERE `black_type`=? AND `black_value`=? LIMIT 1;", array(2, strtolower($user['users_login']))); if (empty($blacklogin)) { DB::run()->query("INSERT INTO `blacklist` (`black_type`, `black_value`, `black_user`, `black_time`) VALUES (?, ?, ?, ?);", array(2, $user['users_login'], $log, SITETIME)); } } // ------ Удаление фотографий в галерее -------// if (!empty($delimages)) { delete_album($uz); } // ------ Удаление тем в форуме -------// if (!empty($delpostforum) || !empty($deltopicforum)) { $query = DB::run()->query("SELECT `topics_id` FROM `topics` WHERE `topics_author`=?;", array($uz)); $topics = $query->fetchAll(PDO::FETCH_COLUMN); if (!empty($topics)) { $strtopics = implode(',', $topics); // ------ Удаление загруженных файлов -------// foreach ($topics as $delDir) { removeDir(BASEDIR . '/upload/forum/' . $delDir); } DB::run()->query("DELETE FROM `files_forum` WHERE `file_posts_id` IN (" . $strtopics . ");"); // ------ Удаление загруженных файлов -------// DB::run()->query("DELETE FROM `posts` WHERE `posts_topics_id` IN (" . $strtopics . ");"); DB::run()->query("DELETE FROM `topics` WHERE `topics_id` IN (" . $strtopics . ");");
function delete_collection($del_id) { global $config; $sql = "SELECT c.name AS collection_name, c.path AS collection_path, c.id AS collection_id\n\t\tFROM " . PLOGGER_TABLE_PREFIX . "collections c\n\t\tWHERE c.id = '{$del_id}'"; $result = run_query($sql); $collection = $result->fetch(); if (!$collection) { return array('errors' => plog_tr('No such collection.')); } // First delete all albums registered with this album $sql = 'SELECT * FROM ' . PLOGGER_TABLE_PREFIX . 'albums WHERE parent_id = ' . $collection['collection_id']; $result = run_query($sql); while ($row = $result->fetch()) { delete_album($row['id']); } // XXX: un-register collection $query = "DELETE FROM " . PLOGGER_TABLE_PREFIX . "collections WHERE \"id\"= '" . $collection['collection_id'] . "'"; run_query($query); // Finally try to delete the directory itself. It will succeed, if there are no files left inside it .. // If there are then .. how did they get there? Probably not through Plogger and in this case do we // really want to delete those? $source_collection_name = SmartStripSlashes($collection['collection_path']); // Delete any thumbnails for the collection $collection_thumb_directory = $config['basedir'] . 'plog-content/thumbs/' . $source_collection_name; if (file_exists($collection_thumb_directory)) { kill_dir($collection_thumb_directory); } // Check to see if the collection_directory is a real directory and then try to delete it $collection_directory = $config['basedir'] . 'plog-content/images/' . $source_collection_name; if (is_dir($collection_directory)) { if (!kill_dir($collection_directory)) { return array('errors' => plog_tr('Collection directory still contains files after all albums have been deleted.')); } } else { return array('errors' => plog_tr('Collection has invalid path, not deleting directory.')); } return array(); }