function deleteCertUserRecords($recid) { $result = false; $record = get_record('certificate_records', 'id', $recid); if (!empty($record->filename)) { if (fileDelete("../../../verifycert/", $record->filename)) { //echo "File deleted. - ".$record->filename; $result = true; } else { //echo "Cannot delete file. - ".$record->filename; $result = false; } } //if($result) if (!file_exists("../../../verifycert/" . $record->filename)) { delete_records('certificate_records', 'id', $recid); $result = true; } return $result; }
function fileMove($path, $filename, $id, $where) { global $database, $thumbnailPrefix; if (!permForPath($path, 'write')) { jsonStart(); error('You do not have permission for this action.'); return false; } $path = str_replace("//", "/", $path); $path = str_replace("..", "", $path); $where = str_replace("//", "/", $where); $where = str_replace("//", "/", $where); $filename = str_replace("//", "/", $filename); $filename = str_replace("//", "/", $filename); $filePath = $path . '/' . $filename; $newPath = $where . '/' . $filename; if (file_exists($filePath)) { if (is_dir($where)) { //Remove original if it exists if (file_exists($newPath)) { $id = $newPath; $id = str_replace("/", "_", $id); $id = str_replace(".", "_", $id); fileDelete($where, $filename, $id); } // Handle any DB records $query = "select * from {$GLOBALS['tablePrefix']}filesystem where rpath=\"{$path}\" and filename=\"{$id}\""; $result = mysql_query($query, $database); if (mysql_num_rows($result) > 0) { $newId = str_replace("/", "_", $newPath); $newId = str_replace(".", "_", $newId); $query = "update {$GLOBALS['tablePrefix']}filesystem set rpath=\"{$where}\", filename=\"{$newId}\" where rpath=\"{$path}\" and filename=\"{$id}\" "; mysql_query($query, $database); logAction('fileMove', 'Updating metadata'); } // Rename file rename($filePath, $newPath); logAction('fileMove', $filePath . ' to ' . $newPath); // Thumbnail $tmp = explode('.', $filename); $oldImageExtension = array_pop($tmp); $oldImageBasename = implode('.', $tmp); $tmp = explode('.', $newName); $newImageExtension = array_pop($tmp); $newImageBasename = implode('.', $tmp); $oldThumbPath = $path . '/' . $thumbnailPrefix . $oldImageBasename . '.' . $oldImageExtension . '.jpg'; $newThumbPath = $path . '/' . $thumbnailPrefix . $newImageBasename . '.' . $oldImageExtension . '.jpg'; if (file_exists($oldThumbPath)) { // Remove any exising thumbnail by the same name if (file_exists($newThumbPath)) { fileDelete($newThumbPath); } rename($oldThumbPath, $newThumbPath); } } else { error('New directory doesn\'t exist'); } } }
} else { $mysqli = $system->get_mysqli(); if ($system->get_user_id() < 1) { $response = $system->addError(HEURIST_REQUEST_DENIED); } else { $action = @$_REQUEST['a']; // || @$_REQUEST['action']; // call function from db_record library // these function returns standard response: status and data // data is recordset (in case success) or message $res = false; if ($action == "add" || $action == "save") { $res = fileSave($system, $_REQUEST); } else { if ($action == "delete" && @$_REQUEST['ids']) { $res = fileDelete($system, $_REQUEST['ids'], @$_REQUEST['UGrpID']); } else { if ($action == "search") { $res = fileSearch($system, true, @$_REQUEST['recIDs'], @$_REQUEST['mediaType'], @$_REQUEST['UGrpID']); if (is_array($res)) { $res['recIDs'] = @$_REQUEST['recIDs']; } } else { if ($action == "viewer") { //find all files for given set of records $res = fileSearch($system, true, @$_REQUEST['recIDs']); if (@$_REQUEST['mode'] == "yox") { //generate html output for yoxviewer in frame ???? or on client side ???? exit; } else { if (is_array($res)) {