コード例 #1
0
ファイル: file.php プロジェクト: Jonathan-Law/fhd
 public static function uploadFile($data = NULL, $files = NULL)
 {
     // error_reporting(E_ALL);
     // ini_set('display_errors', '1');
     // echo "<pre>";
     // print_r($files);
     // echo "</pre>";
     // echo "<pre>";
     // print_r($data);
     // echo "</pre>";
     $tags = isset($data['tag']) ? $data['tag'] : array();
     $places = isset($data['place']) ? $data['place'] : array();
     $title = isset($data['title']) ? $data['title'] : "No Title";
     $author = isset($data['author']) ? $data['author'] : "Unknown";
     $comments = $data['file_comments'];
     $newname = $data['newname'];
     $split = explode(".", $files['file']['name']);
     $extension = end($split);
     $savename = $newname . "." . $extension;
     $link = UPLOAD . "{$savename}";
     $temp = File::getByLink($link);
     // return $temp;
     if (!$temp) {
         // return UPLOAD.$savename;
         $file_path = "upload/" . $savename;
         if (file_exists($file_path)) {
             clearstatcache();
             //the file already exists
             return -1;
         }
         if ($files["file"]["error"] > 0) {
             //there was an error uploading the file
             return -2;
         } else {
             $result = array();
             if (move_uploaded_file($files["file"]["tmp_name"], "upload/" . $savename)) {
                 if ($files["file"]["type"] == "image/gif" || $files["file"]["type"] == "image/jpeg" || $files["file"]["type"] == "image/jpg" || $files["file"]["type"] == "image/bmp" || $files["file"]["type"] == "image/png") {
                     $im = self::thumbnail($link, 75);
                     $im2 = self::thumbnail($link, 800);
                     $view_link = "upload/view/" . $newname . " view." . $extension;
                     $temp_thumblink = "upload/thumbs/" . $newname . " thumbnail." . $extension;
                     if ($im && $im2) {
                         $imageMade = self::imageToFile($im, $temp_thumblink);
                         if ($imageMade) {
                             $viewMade = self::imageToFile($im2, $view_link);
                             if (!$viewMade) {
                                 unlink($link);
                                 return -6;
                             }
                         } else {
                             unlink($temp_thumblink);
                             unlink($link);
                             return -6;
                         }
                     } else {
                         unlink($link);
                         return -6;
                     }
                     $type = "image";
                 } else {
                     $view_link = null;
                     $temp_thumblink = "changeMeToDocThumb";
                     $type = "other";
                 }
                 $result[] = "Stored in: " . "upload/" . $savename;
                 $init = new File();
                 $init->id = null;
                 $init->link = $link;
                 $init->thumblink = $temp_thumblink;
                 $init->viewlink = $view_link;
                 $init->title = $title ? $title : "Untitled";
                 $init->author = $author;
                 $init->comments = $comments;
                 $init->date = null;
                 $init_id = $init->save();
                 if ($init_id) {
                     $init->id = $init_id;
                     foreach ($tags as $tag) {
                         $temp_name = explode("||", $tag);
                         if ($temp_name[2] != NULL) {
                             $result[] = saveTags($temp_name[0], "file", intval($init->id), "file_upload", $temp_name[2], $type, URL . $link);
                         } else {
                             $result[] = saveTags($temp_name[0], "file", intval($init->id), "file_upload", -1, $type, URL . $link);
                         }
                     }
                     foreach ($places as $place) {
                         $result[] = savePlaces($place, "file", intval($init->id), "file_upload");
                     }
                     $init->message = $result;
                     return 1;
                 } else {
                     unlink($temp_thumblink);
                     unlink($link);
                     //database connection wasn't saved
                     return -4;
                 }
             } else {
                 //file wasn't moved
                 return -3;
             }
         }
     }
     //the database entry already exists
     return -5;
 }
コード例 #2
0
ファイル: tags.php プロジェクト: laiello/bitcero-modules
        }
    }
    if ($erros != '') {
        redirectMsg('./tags.php?' . $ruta, __('Errors ocurred while trying to delete tags.', 'galleries') . '<br />' . $errors, 1);
        die;
    } else {
        redirectMsg('./tags.php?' . $ruta, __('Tags deleted successfully!', 'galleries'), 0);
        die;
    }
}
$op = rmc_server_var($_REQUEST, 'op', '');
switch ($op) {
    case 'new':
        formTags();
        break;
    case 'edit':
        formTags(1);
        break;
    case 'save':
        saveTags();
        break;
    case 'saveedit':
        saveTags(1);
        break;
    case 'delete':
        deleteTags();
        break;
    default:
        showTags();
        break;
}