/* ******************************************
* movefiles.php
*
* This script will go through the KB dataabse
* find all the records with files and move the files
* to a new directory */
session_start();
require_once('Bootstrap.php');
$bootstrap = Bootstrap::create();
$libdir = $bootstrap->libraryDirectory;
include($bootstrap->libraryDirectory.'util.php');
include($bootstrap->libraryDirectory.'settings.php');
require($bootstrap->libraryDirectory.'proclib.php');
include($bootstrap->libraryDirectory.'datacon.php');
$gUser = (isset($_SESSION['gUser'])) ? $_SESSION['gUser'] : '';
$userID = getUserID($gUser);
if (checkUserAccessRights($gUser, 'ADMIN',1,1) == 0 ){
return;
}
$sql = new MySQL_class;
$sql->Create('nccs_links');
$sql2 = new MySQL_class;
$sql2->Create('nccs_links');
$dir = '/var/www/html/kbfiles/';
$sql->Query("select ID, File, File2 from LINKS where (File != '' OR File IS NOT NULL) or (File2 != '' OR File2 IS NOT NULL) order by ID");
for ($i = 0; $i < $sql->rows; $i ++) {
$sql->fetch($i);
list($linkID, $file1, $file2) = $sql->data;
print "$linkID
";
/* Check to see if the directory exists */
if (!empty($file1) || !empty($file2)) {
if (!is_dir($dir.$linkID)) {
mkdir($dir.$linkID, 0755);
print "Created dir : ".$dir.$linkID."
";
}
}
if (!empty($file1)) {
/* Copy the file */
copy($dir.$file1, $dir.$linkID.'/'.$file1);
$sql2->Insert("insert into LINK_FILES (link_files_id, file_name, link_id, create_date, owner) values(0,'$file1', $linkID, NOW(), 'tpollak')");
print "ADDED: file 1 $file1
";
}
if (!empty($file2)) {
/* Copy the file */
copy($dir.$file2, $dir.$linkID.'/'.$file2);
$sql2->Insert("insert into LINK_FILES (link_files_id, file_name, link_id, create_date, owner) values(0,'$file2', $linkID, NOW(), 'tpollak')");
print "ADDED: file 2 $file2
";
}
print "