Пример #1
0
function photoplog_physical_move($source_directory, $source_file_name, $destination_directory, $destination_file_name)
{
    if (photoplog_ensure_directory($destination_directory)) {
        copy($source_directory . "/" . $source_file_name, $destination_directory . "/" . $destination_file_name);
        @unlink($source_directory . "/" . $source_file_name);
    }
}
Пример #2
0
function photoplog_massmove_movefile($fileinfo, $destination_userid)
{
    global $vbulletin, $photoplog_images_directory;
    if (isset($fileinfo) && is_array($fileinfo) && isset($fileinfo['userid']) && isset($fileinfo['filename'])) {
        $source_directory = $photoplog_images_directory . "/" . $fileinfo['userid'];
        $destination_directory = $photoplog_images_directory . "/" . intval($destination_userid);
        $destination_file_name = '';
        if (is_dir($source_directory) && photoplog_ensure_directory($destination_directory)) {
            $source_file_name = $fileinfo['filename'];
            $source_original_name = eregi_replace("^[0-9]+[_]", "", $source_file_name);
            $source_file_location = $source_directory . "/" . $source_file_name;
            $counter = 1;
            $destination_file_name = $counter . "_" . $source_original_name;
            $destination_file_location = $destination_directory . "/" . $destination_file_name;
            while (file_exists($destination_file_location) && $counter <= 500) {
                $counter++;
                $destination_file_name = $counter . "_" . $source_original_name;
                $destination_file_location = $destination_directory . "/" . $destination_file_name;
            }
            if ($counter <= 500) {
                copy($source_file_location, $destination_file_location);
                $destination_file_check = @getimagesize($destination_file_location);
                if ($destination_file_check === false || !is_array($destination_file_check) || empty($destination_file_check) || !in_array($destination_file_check[2], array(1, 2, 3))) {
                    @unlink($destination_file_location);
                } else {
                    @unlink($source_file_location);
                    photoplog_physical_move($source_directory . "/large", $source_file_name, $destination_directory . "/large", $destination_file_name);
                    photoplog_physical_move($source_directory . "/medium", $source_file_name, $destination_directory . "/medium", $destination_file_name);
                    photoplog_physical_move($source_directory . "/small", $source_file_name, $destination_directory . "/small", $destination_file_name);
                    $movefile_sql = "UPDATE " . PHOTOPLOG_PREFIX . "photoplog_fileuploads SET filename = '" . $vbulletin->db->escape_string($destination_file_name) . "' WHERE fileid = " . intval($fileinfo['fileid']);
                    $movefile_query = $vbulletin->db->query_write($movefile_sql);
                }
            }
        }
    }
}