本文整理汇总了PHP中Jaws_Utils::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Jaws_Utils::delete方法的具体用法?PHP Jaws_Utils::delete怎么用?PHP Jaws_Utils::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jaws_Utils
的用法示例。
在下文中一共展示了Jaws_Utils::delete方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Upgrade
/**
* Upgrades the gadget
*
* @access public
* @param string $old Current version (in registry)
* @param string $new New version (in the $gadgetInfo file)
* @return mixed true on success, Jaws_Error otherwise
*/
function Upgrade($old, $new)
{
if (version_compare($old, '0.9.0', '<')) {
$result = $this->installSchema('schema.xml', '', '0.8.0.xml');
if (Jaws_Error::IsError($result)) {
return $result;
}
$new_feed_dir = JAWS_DATA . 'feedcache' . DIRECTORY_SEPARATOR;
$old_feed_dir = JAWS_DATA . 'rsscache' . DIRECTORY_SEPARATOR;
if (!Jaws_Utils::mkdir($new_feed_dir)) {
return new Jaws_Error(_t('GLOBAL_ERROR_FAILED_CREATING_DIR', $new_feed_dir));
}
Jaws_Utils::delete($old_feed_dir);
// ACL keys
$this->gadget->acl->delete('ManageRSSSite');
// Update layout actions
$layoutModel = Jaws_Gadget::getInstance('Layout')->model->loadAdmin('Layout');
if (!Jaws_Error::isError($layoutModel)) {
$layoutModel->EditGadgetLayoutAction('FeedReader', 'Display', 'DisplayFeeds', 'Feed');
}
}
return true;
}
示例2: Run
/**
* Does any actions required to finish the stage, such as DB queries.
*
* @access public
* @return bool|Jaws_Error Either true on success, or a Jaws_Error
* containing the reason for failure.
*/
function Run()
{
//config string
$configString = $this->BuildConfig();
$configMD5 = md5($configString);
$existsConfig = @file_get_contents(JAWS_PATH . 'config/JawsConfig.php');
$existsMD5 = md5($existsConfig);
if ($configMD5 !== $existsMD5) {
if (!Jaws_Utils::is_writable(JAWS_PATH . 'config/')) {
return Jaws_Error::raiseError(_t('UPGRADE_CONFIG_RESPONSE_MAKE_CONFIG', 'JawsConfig.php'), __FUNCTION__, JAWS_ERROR_WARNING);
}
// create/overwrite a new one if the dir is writeable
$result = @file_put_contents(JAWS_PATH . 'config/JawsConfig.php', $configString);
if ($result === false) {
return Jaws_Error::raiseError(_t('UPGRADE_CONFIG_RESPONSE_WRITE_FAILED'), __FUNCTION__, JAWS_ERROR_WARNING);
}
}
// Connect to database
require_once JAWS_PATH . 'include/Jaws/DB.php';
$objDatabase = Jaws_DB::getInstance('default', $_SESSION['upgrade']['Database']);
if (Jaws_Error::IsError($objDatabase)) {
_log(JAWS_LOG_DEBUG, "There was a problem connecting to the database, please check the details and try again");
return new Jaws_Error(_t('UPGRADE_DB_RESPONSE_CONNECT_FAILED'), 0, JAWS_ERROR_WARNING);
}
// Create application
include_once JAWS_PATH . 'include/Jaws.php';
$GLOBALS['app'] = jaws();
$GLOBALS['app']->Registry->Init();
_log(JAWS_LOG_DEBUG, "Setting " . JAWS_VERSION . " as the current installed version");
$GLOBALS['app']->Registry->update('version', JAWS_VERSION);
//remove cache directory
$path = JAWS_DATA . 'cache';
if (!Jaws_Utils::delete($path)) {
_log(JAWS_LOG_DEBUG, "Can't delete {$path}");
}
_log(JAWS_LOG_DEBUG, "Configuration file has been created/updated");
return true;
}
示例3: DeleteAlbum
/**
* Delete an album and all its images
*
* @access public
* @param int $id ID of the album
* @return mixed Returns true if album was deleted without problems, Jaws_Error if not.
*/
function DeleteAlbum($id)
{
// Delete files
// We do it this way because we don't want to use subqueries(some versions of mysql don't support it)
$table = Jaws_ORM::getInstance()->table('phoo_image_album');
$table->select('phoo_image_id');
$table->where('phoo_album_id', $id);
$result = $table->fetchAll();
if (Jaws_Error::IsError($result)) {
$GLOBALS['app']->Session->PushLastResponse(_t('PHOO_ERROR_ALBUM_NOT_DELETED'), RESPONSE_ERROR);
return new Jaws_Error(_t('PHOO_ERROR_ALBUM_NOT_DELETED'));
}
if (!empty($result)) {
$imgList = array();
foreach ($result as $i) {
$imgList[] = $i['phoo_image_id'];
}
$table = Jaws_ORM::getInstance()->table('phoo_image');
$table->select('id', 'user_id', 'filename', 'phoo_album_id');
$table->join('phoo_image_album', 'id', 'phoo_image_id');
if (!empty($imgList)) {
$table->where('id', $imgList, 'in');
}
$table->groupBy('id', 'user_id', 'filename', 'phoo_album_id');
$table->having('count(phoo_image_id)', 1);
$result = $table->fetchAll();
if (Jaws_Error::IsError($result)) {
$GLOBALS['app']->Session->PushLastResponse(_t('PHOO_ERROR_ALBUM_NOT_DELETED'), RESPONSE_ERROR);
return new Jaws_Error(_t('PHOO_ERROR_ALBUM_NOT_DELETED'));
}
include_once JAWS_PATH . 'include/Jaws/Image.php';
foreach ($result as $r) {
if (!empty($r['filename'])) {
Jaws_Utils::delete(JAWS_DATA . 'phoo/' . $r['filename']);
Jaws_Utils::delete(JAWS_DATA . 'phoo/' . $this->GetMediumPath($r['filename']));
Jaws_Utils::delete(JAWS_DATA . 'phoo/' . $this->GetThumbPath($r['filename']));
}
}
// Delete images from phoo_image
if (!empty($imgList)) {
$table = Jaws_ORM::getInstance()->table('phoo_image');
$table->delete()->where('id', $imgList, 'in');
$result = $table->exec();
}
if (Jaws_Error::IsError($result)) {
$GLOBALS['app']->Session->PushLastResponse(_t('PHOO_ERROR_ALBUM_NOT_DELETED'), RESPONSE_ERROR);
return new Jaws_Error(_t('PHOO_ERROR_ALBUM_NOT_DELETED'));
}
// Delete images from phoo_image_album
$table = Jaws_ORM::getInstance()->table('phoo_image_album');
$table->delete()->where('phoo_album_id', $id);
$result = $table->exec();
if (Jaws_Error::IsError($result)) {
$GLOBALS['app']->Session->PushLastResponse(_t('PHOO_ERROR_ALBUM_NOT_DELETED'), RESPONSE_ERROR);
return new Jaws_Error(_t('PHOO_ERROR_ALBUM_NOT_DELETED'));
}
}
// Delete album from phoo_album
$table = Jaws_ORM::getInstance()->table('phoo_album');
$table->delete()->where('id', $id);
$result = $table->exec();
if (Jaws_Error::IsError($result)) {
$GLOBALS['app']->Session->PushLastResponse(_t('PHOO_ERROR_ALBUM_NOT_DELETED'), RESPONSE_ERROR);
return new Jaws_Error(_t('PHOO_ERROR_ALBUM_NOT_DELETED'));
}
$GLOBALS['app']->Session->PushLastResponse(_t('PHOO_ALBUM_DELETED'), RESPONSE_NOTICE);
return true;
}
示例4: AddEmblem
/**
* Adds a new emblem
*
* @access public
* @see EmblemsModel->AddEmblem()
*/
function AddEmblem()
{
$post = jaws()->request->fetch(array('title', 'url', 'type', 'published'), 'post');
$post['url'] = Jaws_XSS::defilter($post['url']);
$res = Jaws_Utils::UploadFiles($_FILES, JAWS_DATA . 'emblems/', 'jpg,gif,swf,png,jpeg,bmp,svg');
if (Jaws_Error::IsError($res)) {
$GLOBALS['app']->Session->PushLastResponse($res->getMessage(), RESPONSE_ERROR);
} elseif (empty($res)) {
$GLOBALS['app']->Session->PushLastResponse(_t('EMBLEMS_ERROR_NO_IMAGE_UPLOADED'), RESPONSE_ERROR);
} else {
$post['image'] = $res['image'][0]['host_filename'];
$post['published'] = (bool) $post['published'];
$model = $this->gadget->model->loadAdmin('Emblems');
$res = $model->AddEmblem($post);
if (Jaws_Error::IsError($res)) {
Jaws_Utils::delete(JAWS_DATA . 'emblems/' . $post['image']);
$GLOBALS['app']->Session->PushLastResponse(_t('EMBLEMS_ERROR_NOT_ADDED'), RESPONSE_ERROR);
} else {
$GLOBALS['app']->Session->PushLastResponse(_t('EMBLEMS_ADDED'), RESPONSE_NOTICE);
}
}
Jaws_Header::Location(BASE_SCRIPT . '?gadget=Emblems');
}
示例5: delete
/**
* Delete directories and files
*
* @access public
* @param string $path File/Directory path
* @param bool $dirs_include
* @param bool $self_include
* @return bool Returns TRUE on success or FALSE on failure
* @see http://www.php.net/rmdir & http://www.php.net/unlink
*/
static function delete($path, $dirs_include = true, $self_include = true)
{
if (!file_exists($path)) {
return true;
}
if (is_file($path) || is_link($path)) {
// unlink can't delete read-only files in windows os
if (JAWS_OS_WIN) {
@chmod($path, 0777);
}
return @unlink($path);
}
if (false !== ($files = @scandir($path))) {
foreach ($files as $file) {
if ($file == '.' || $file == '..') {
continue;
}
if (!Jaws_Utils::delete($path . DIRECTORY_SEPARATOR . $file, $dirs_include)) {
return false;
}
}
}
if ($dirs_include && $self_include) {
return @rmdir($path);
}
return true;
}
示例6: Delete
/**
* Deletes file/directory
*
* @access public
* @param int $id File ID
* @return mixed Query result
*/
function Delete($data)
{
if ($data['is_dir']) {
$files = $this->GetFiles(array('parent' => $data['id']));
if (Jaws_Error::IsError($files)) {
return false;
}
foreach ($files as $file) {
$this->Delete($file);
}
}
// Delete file/folder and related shortcuts
$table = Jaws_ORM::getInstance()->table('directory');
$table->delete()->where('id', $data['id']);
$res = $table->exec();
if (Jaws_Error::IsError($res)) {
return false;
}
// Delete from disk
if (!$data['is_dir']) {
$filename = JAWS_DATA . 'directory/' . $data['host_filename'];
if (file_exists($filename)) {
if (!Jaws_Utils::delete($filename)) {
return false;
}
}
}
return true;
}
示例7: DeleteTheme
/**
* Delete the theme
*
* @access public
* @param string $theme
* @returns boolean
*/
function DeleteTheme($theme)
{
$this->gadget->CheckPermission('DeleteTheme');
@(list($theme, $locality) = explode(',', $theme));
$tInfo = Jaws_Utils::GetThemesInfo($locality, $theme);
if (!empty($tInfo) && $locality == 0) {
// get default theme
$defaultTheme = unserialize($GLOBALS['app']->Registry->fetch('theme', 'Settings'));
// Check is default theme?
if ($defaultTheme['locality'] != 0 || $theme != $defaultTheme['name']) {
return Jaws_Utils::delete(JAWS_THEMES . $theme);
}
}
return false;
}
示例8: Uninstall
/**
* Uninstalls the plugin
*
* @access public
* @return bool True
*/
function Uninstall()
{
Jaws_Utils::delete(JAWS_DATA . 'AlbumCover' . DIRECTORY_SEPARATOR);
return true;
}
示例9: SendMessage
//.........这里部分代码省略.........
$data['insert_time'] = time();
$senderMessageId = $mTable->insert($data)->exec();
}
} else {
// update message
$mTable->update($data)->where('id', $messageData['id'])->exec();
$senderMessageId = $messageData['id'];
}
// Insert message for every recipient
if (!empty($recipient_users) && count($recipient_users) > 0) {
$table = $table->table('pm_messages');
$from = $is_notification ? 0 : $user;
$data['folder'] = $messageData['folder'];
foreach ($recipient_users as $recipient_user) {
$data['insert_time'] = time();
$data['from'] = $from;
$data['to'] = $recipient_user;
$data['read'] = false;
$messageId = $table->insert($data)->exec();
if (Jaws_Error::IsError($messageId)) {
//Rollback Transaction
$table->rollback();
return false;
}
$messageIds[] = $messageId;
// send notification on new private message
if (!$is_notification) {
$params = array();
$params['key'] = crc32('PrivateMessage' . $senderMessageId);
$params['title'] = _t('PRIVATEMESSAGE_NEW_MESSAGE_NOTIFICATION_TITLE');
$params['summary'] = _t('PRIVATEMESSAGE_NEW_MESSAGE_NOTIFICATION');
$params['description'] = _t('PRIVATEMESSAGE_NEW_MESSAGE_NOTIFICATION_DESC', $data['subject']);
$params['user'] = (int) $recipient_user;
$this->gadget->event->shout('Notify', $params);
}
}
}
}
// Insert attachments info
if (!empty($messageData['attachments']) && count($messageData['attachments']) > 0) {
$maData = array();
$pm_dir = JAWS_DATA . 'pm' . DIRECTORY_SEPARATOR . 'attachments' . DIRECTORY_SEPARATOR;
foreach ($messageData['attachments'] as $attachment) {
// check new attachments file -- we must copy tmp files to correct location
if (is_array($attachment)) {
$src_filepath = Jaws_Utils::upload_tmp_dir() . '/' . $attachment['filename'];
$dest_filepath = $pm_dir . $attachment['filename'];
if (!file_exists($src_filepath)) {
continue;
}
if (!file_exists($pm_dir)) {
if (!Jaws_Utils::mkdir($pm_dir)) {
return new Jaws_Error(_t('GLOBAL_ERROR_FAILED_CREATING_DIR', JAWS_DATA));
}
}
$cres = Jaws_Utils::rename($src_filepath, $dest_filepath);
Jaws_Utils::delete($src_filepath);
if ($cres) {
$aData = array('title' => $attachment['title'], 'filename' => $attachment['filename'], 'filesize' => $attachment['filesize'], 'filetype' => $attachment['filetype']);
$table = $table->table('pm_attachments');
$attachmentId = $table->insert($aData)->exec();
if (Jaws_Error::IsError($attachmentId)) {
//Rollback Transaction
$table->rollback();
return false;
}
// Add sender message Id to pm_message_attachment table
$maData[] = array('message' => $senderMessageId, 'attachment' => $attachmentId);
// Add recipient message Id to pm_message_attachment table
foreach ($messageIds as $messageId) {
$maData[] = array('message' => $messageId, 'attachment' => $attachmentId);
}
}
} else {
// Add sender message Id to pm_message_attachment table
$maData[] = array('message' => $senderMessageId, 'attachment' => $attachment);
// Add recipient message Id to pm_message_attachment table
foreach ($messageIds as $messageId) {
$maData[] = array('message' => $messageId, 'attachment' => $attachment);
}
}
}
if (!empty($maData) && count($maData) > 0) {
$table = $table->table('pm_message_attachment');
$res = $table->insertAll(array('message', 'attachment'), $maData)->exec();
if (Jaws_Error::IsError($res)) {
//Rollback Transaction
$table->rollback();
return false;
}
} else {
//Rollback Transaction
$table->rollback();
return false;
}
}
//Commit Transaction
$mTable->commit();
return $senderMessageId;
}
示例10: NewEntry
//.........这里部分代码省略.........
$uploaddir = JAWS_DATA . 'phoo/' . date('Y_m_d') . '/';
if (!is_dir($uploaddir)) {
if (!Jaws_Utils::is_writable(JAWS_DATA . 'phoo/')) {
$GLOBALS['app']->Session->PushLastResponse(_t('PHOO_ERROR_CANT_UPLOAD_PHOTO'), RESPONSE_ERROR);
return new Jaws_Error(_t('PHOO_ERROR_CANT_UPLOAD_PHOTO'));
}
$new_dirs = array();
$new_dirs[] = $uploaddir;
$new_dirs[] = $uploaddir . 'thumb';
$new_dirs[] = $uploaddir . 'medium';
foreach ($new_dirs as $new_dir) {
if (!Jaws_Utils::mkdir($new_dir)) {
$GLOBALS['app']->Session->PushLastResponse(_t('PHOO_ERROR_CANT_UPLOAD_PHOTO'), RESPONSE_ERROR);
return new Jaws_Error(_t('PHOO_ERROR_CANT_UPLOAD_PHOTO'));
}
}
}
$filename = $files['name'];
if (file_exists($uploaddir . $files['name'])) {
$filename = time() . '_' . $files['name'];
}
$res = Jaws_Utils::UploadFiles($files, $uploaddir, 'jpg,gif,png,jpeg', false, !$fromControlPanel);
if (Jaws_Error::IsError($res)) {
$GLOBALS['app']->Session->PushLastResponse($res->getMessage(), RESPONSE_ERROR);
return new Jaws_Error($res->getMessage());
} elseif (empty($res)) {
$GLOBALS['app']->Session->PushLastResponse(_t('GLOBAL_ERROR_UPLOAD_4'), RESPONSE_ERROR);
return new Jaws_Error(_t('GLOBAL_ERROR_UPLOAD_4'));
}
$filename = $res[0][0]['host_filename'];
$uploadfile = $uploaddir . $filename;
// Resize Image
include_once JAWS_PATH . 'include/Jaws/Image.php';
$objImage = Jaws_Image::factory();
if (Jaws_Error::IsError($objImage)) {
return Jaws_Error::raiseError($objImage->getMessage());
}
$thumbSize = explode('x', $this->gadget->registry->fetch('thumbsize'));
$mediumSize = explode('x', $this->gadget->registry->fetch('mediumsize'));
$objImage->load($uploadfile);
$objImage->resize($thumbSize[0], $thumbSize[1]);
$res = $objImage->save($this->GetThumbPath($uploadfile));
$objImage->free();
if (Jaws_Error::IsError($res)) {
// Return an error if image can't be resized
$GLOBALS['app']->Session->PushLastResponse(_t('PHOO_ERROR_CANT_RESIZE_TO_THUMB'), RESPONSE_ERROR);
return new Jaws_Error($res->getMessage());
}
$objImage->load($uploadfile);
$objImage->resize($mediumSize[0], $mediumSize[1]);
$res = $objImage->save($this->GetMediumPath($uploadfile));
$objImage->free();
if (Jaws_Error::IsError($res)) {
// Return an error if image can't be resized
$GLOBALS['app']->Session->PushLastResponse($res->getMessage(), RESPONSE_ERROR);
return new Jaws_Error(_t('PHOO_ERROR_CANT_RESIZE_TO_MEDIUM'));
}
$data = array();
$data['user_id'] = $user;
$data['filename'] = date('Y_m_d') . '/' . $filename;
$data['title'] = $title;
$data['description'] = $description;
if ($this->gadget->registry->fetch('allow_comments') === 'true' && $album['allow_comments']) {
$data['allow_comments'] = true;
} else {
$data['allow_comments'] = false;
}
if ($this->gadget->registry->fetch('published') === 'true' && $this->gadget->GetPermission('ManageAlbums')) {
$data['published'] = true;
} else {
$data['published'] = false;
}
$jDate = Jaws_Date::getInstance();
$createtime = Jaws_DB::getInstance()->date();
if (function_exists('exif_read_data') && preg_match("/\\.jpg\$|\\.jpeg\$/i", $files['name']) && ($exifData = @exif_read_data($uploadfile, 1, true)) && !empty($exifData['IFD0']['DateTime']) && $jDate->ValidDBDate($exifData['IFD0']['DateTime'])) {
$aux = explode(' ', $exifData['IFD0']['DateTime']);
$auxdate = str_replace(':', '-', $aux[0]);
$auxtime = $aux[1];
$createtime = $auxdate . ' ' . $auxtime;
}
$data['createtime'] = $createtime;
$table = Jaws_ORM::getInstance()->table('phoo_image');
$result = $table->insert($data)->exec();
if (Jaws_Error::IsError($result)) {
$GLOBALS['app']->Session->PushLastResponse(_t('PHOO_ERROR_CANT_UPLOAD_PHOTO'), RESPONSE_ERROR);
return new Jaws_Error(_t('PHOO_ERROR_CANT_UPLOAD_PHOTO'));
}
// Lets remove the original if keep_original = false
if ($this->gadget->registry->fetch('keep_original') == 'false') {
if (!empty($data['filename'])) {
Jaws_Utils::delete(JAWS_DATA . 'phoo/' . $data['filename']);
}
}
// shout SiteActivity event
$saParams = array();
$saParams['action'] = 'Photo';
$this->gadget->event->shout('SiteActivity', $saParams);
$GLOBALS['app']->Session->PushLastResponse(_t('PHOO_PHOTO_ADDED'), RESPONSE_NOTICE);
return $result;
}
示例11: Delete
/**
* Deletes file/directory
*
* @access public
* @param int $id File ID
* @return mixed Query result
*/
function Delete($data)
{
if ($data['is_dir']) {
$files = $this->GetFiles($data['id'], $data['user']);
if (Jaws_Error::IsError($files)) {
return false;
}
foreach ($files as $file) {
$this->Delete($file);
}
}
// Delete file/folder and related shortcuts
$table = Jaws_ORM::getInstance()->table('directory');
$table->delete()->where('id', $data['id']);
$table->or()->where('reference', $data['id']);
$res = $table->exec();
if (Jaws_Error::IsError($res)) {
return false;
}
// Delete from disk
if (!$data['is_dir']) {
$filename = $GLOBALS['app']->getDataURL('directory/' . $data['user'] . '/' . $data['filename']);
if (file_exists($filename)) {
if (!Jaws_Utils::delete($filename)) {
return false;
}
}
}
return true;
}