예제 #1
0
 /**
  * Delete an avatar
  * @param integer $filename Name of file to be deleted
  * @return void Avatar is deleted from filesystem
  */
 static function Delete($filename)
 {
     try {
         Filesystem::Open();
         Filesystem::Delete(UPLOAD_PATH . '/avatars/' . $filename);
         Filesystem::Close();
     } catch (Exception $e) {
         App::Alert('Error During Avatar Removal', "Unable to delete avatar: {$filename}. Error: " . $e->getMessage());
     }
 }
예제 #2
0
        $key = array_search($_GET['delete'], $installed_plugins);
        if ($key !== false) {
            if (method_exists($_GET['delete'], 'Uninstall')) {
                call_user_func(array($_GET['delete'], 'Uninstall'));
            }
            unset($installed_plugins[$key]);
            Settings::Set('installed_plugins', serialize($installed_plugins));
        }
        // Delete plugin files
        $plugin_info = Plugin::GetPluginInfo($_GET['delete']);
        $message = $plugin_info->name . ' plugin has been deleted';
        $message_type = 'success';
        try {
            Filesystem::Open();
            Filesystem::Delete(DOC_ROOT . '/cc-content/plugins/' . $_GET['delete']);
            Filesystem::Close();
        } catch (Exception $e) {
            $message = $e->getMessage();
            $message_type = 'error';
        }
    }
} else {
    if (!empty($_GET['enable']) && !ctype_space($_GET['enable'])) {
        // Validate plugin
        if (Plugin::ValidPlugin($_GET['enable']) && !in_array($_GET['enable'], $enabled_plugins)) {
            // Install plugin if applicable
            if (!in_array($_GET['enable'], $installed_plugins)) {
                if (method_exists($_GET['enable'], 'Install')) {
                    call_user_func(array($_GET['enable'], 'Install'));
                }
                $installed_plugins[] = $_GET['enable'];
예제 #3
0
 /**
  * Delete a video
  * @param integer $video_id ID of video to be deleted
  * @return void Video is deleted from database and all related files and records are also deleted
  */
 static function Delete($video_id)
 {
     App::LoadClass('Rating');
     App::LoadClass('Flag');
     App::LoadClass('Favorite');
     App::LoadClass('Comment');
     $db = Database::GetInstance();
     $video = new self($video_id);
     Plugin::Trigger('video.delete');
     // Delete files
     try {
         Filesystem::Open();
         Filesystem::Delete(UPLOAD_PATH . '/flv/' . $video->filename . '.flv');
         Filesystem::Delete(UPLOAD_PATH . '/thumbs/' . $video->filename . '.jpg');
         Filesystem::Delete(UPLOAD_PATH . '/mobile/' . $video->filename . '.mp4');
         Filesystem::Close();
     } catch (Exception $e) {
         App::Alert('Error During Video Removal', "Unable to delete video files for: {$video->filename}. The video has been removed from the system, but the files still remain. Error: " . $e->getMessage());
     }
     // Delete Comments
     $query = "SELECT comment_id FROM " . DB_PREFIX . "comments WHERE video_id = {$video_id}";
     $result = $db->Query($query);
     while ($row = $db->FetchObj($result)) {
         Comment::Delete($row->comment_id);
     }
     // Delete Ratings
     $query = "SELECT rating_id FROM " . DB_PREFIX . "ratings WHERE video_id = {$video_id}";
     $result = $db->Query($query);
     while ($row = $db->FetchObj($result)) {
         Rating::Delete($row->rating_id);
     }
     // Delete Favorites
     $query = "SELECT fav_id FROM " . DB_PREFIX . "favorites WHERE video_id = {$video_id}";
     $result = $db->Query($query);
     while ($row = $db->FetchObj($result)) {
         Favorite::Delete($row->fav_id);
     }
     // Delete Flags
     $query = "SELECT flag_id FROM " . DB_PREFIX . "flags WHERE id = {$video_id} AND type = 'video'";
     $result = $db->Query($query);
     while ($row = $db->FetchObj($result)) {
         Flag::Delete($row->flag_id);
     }
     // Delete Video
     $query = "DELETE FROM " . DB_PREFIX . "videos WHERE video_id = {$video_id}";
     $db->Query($query);
 }