本文整理汇总了PHP中Filesystem::Open方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::Open方法的具体用法?PHP Filesystem::Open怎么用?PHP Filesystem::Open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Filesystem
的用法示例。
在下文中一共展示了Filesystem::Open方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Delete
/**
* 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: array_search
}
// Uninstall plugin
$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'));
示例3: Delete
/**
* 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);
}