Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update upload-import-orphans.php #1

Merged
merged 1 commit into from
Apr 26, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions upload-import-orphans.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,24 @@
* When a file doesn't correspond to a record, it can
* be safely renamed.
*/
$sql = $database->query("SELECT url, id, public_allow FROM tbl_files WHERE public_allow='0'");
$sql = $database->query("SELECT url, id, public_allow FROM tbl_files");
$db_files = array();
while($row = mysql_fetch_array($sql)) {
$db_files[$row["url"]] = $row["id"];
if ($row['public_allow'] == 1) {$db_files_public[$row["url"]] = $row["id"];}
}

/** Make an array of already assigned files */
$sql = $database->query("SELECT DISTINCT file_id FROM tbl_files_relations");
$sql = $database->query("SELECT DISTINCT file_id FROM tbl_files_relations WHERE client_id IS NOT NULL OR group_id IS NOT NULL OR folder_id IS NOT NULL");
$assigned = array();
while($row = mysql_fetch_array($sql)) {
$assigned[] = $row["file_id"];
}

/** We consider public file as assigned file */
foreach ($db_files_public as $file_id){
$assigned[] = $file_id;
}

/** Read the temp folder and list every allowed file */
if ($handle = opendir($work_folder)) {
Expand Down Expand Up @@ -242,4 +248,4 @@ function search_text($item) {
<?php
$database->Close();
include('footer.php');
?>
?>