本文整理汇总了PHP中waFiles::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP waFiles::delete方法的具体用法?PHP waFiles::delete怎么用?PHP waFiles::delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类waFiles
的用法示例。
在下文中一共展示了waFiles::delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
function execute()
{
try {
$message = array();
$settings = waRequest::get('setting');
if ($settings) {
$model = new waAppSettingsModel();
$changed = false;
foreach ((array) $settings as $setting) {
if (in_array($setting, array('auth_form_background'))) {
if ($value = $model->get('webasyst', $setting)) {
waFiles::delete(wa()->getDataPath($value, true, 'webasyst'));
$message[] = _w('Image deleted');
}
} else {
$changed = true;
}
$model->set('webasyst', $setting, false);
}
if ($changed) {
$message[] = _w('Settings saved');
}
}
$params = array('module' => 'settings', 'msg' => installerMessage::getInstance()->raiseMessage(implode(', ', $message)));
$this->redirect($params);
} catch (waException $ex) {
$msg = installerMessage::getInstance()->raiseMessage($ex->getMessage(), installerMessage::R_FAIL);
$params = array('module' => 'settings', 'msg' => $msg);
$this->redirect($params);
}
}
示例2: execute
public function execute()
{
$p = $path = rtrim(waRequest::post('path'), ' /');
$file = waRequest::post('file');
try {
if ($file) {
if (!is_array($file)) {
$file = array($file);
}
foreach ($file as $f) {
$f = $path . '/' . $f;
waFiles::delete(wa()->getDataPath($f, true, null, false));
}
$this->log('file_delete', count($file));
} else {
$path = wa()->getDataPath($path, true, null, false);
if (!is_writable($path)) {
$this->errors = sprintf(_w("Folder could not bet deleted due to the insufficient permissions."), $p);
} else {
waFiles::delete($path);
$this->log('file_delete', 1);
}
}
} catch (Exception $e) {
$this->errors = $e->getMessage();
}
}
示例3: step
protected function step()
{
$image_model = new shopProductImagesModel();
$create_thumbnails = waRequest::post('create_thumbnails');
$chunk_size = 50;
if ($create_thumbnails) {
$chunk_size = 10;
}
$sizes = wa('shop')->getConfig()->getImageSizes();
$images = $image_model->getAvailableImages($this->data['offset'], $chunk_size);
foreach ($images as $i) {
if ($this->data['product_id'] != $i['product_id']) {
sleep(0.2);
$this->data['product_id'] = $i['product_id'];
$this->data['product_count'] += 1;
}
try {
$path = shopImage::getThumbsPath($i);
if (!waFiles::delete($path)) {
throw new waException(sprintf(_w('Error when delete thumbnails for image %d'), $i['id']));
}
if ($create_thumbnails) {
shopImage::generateThumbs($i, $sizes);
}
$this->data['image_count'] += 1;
// image count - count of successful progessed images
} catch (Exception $e) {
$this->error($e->getMessage());
}
$this->data['offset'] += 1;
}
}
示例4: flushCache
protected function flushCache()
{
$config = wa()->getConfig();
$path_cache = $config->getPath('cache');
waFiles::protect($path_cache);
$caches = array();
$paths = waFiles::listdir($path_cache);
foreach ($paths as $path) {
#skip long action & data path
if ($path != 'temp') {
$path = $path_cache . '/' . $path;
if (is_dir($path)) {
$caches[] = $path;
}
}
}
$root_path = $config->getRootPath();
$errors = array();
foreach ($caches as $path) {
try {
waFiles::delete($path);
} catch (Exception $ex) {
$errors[] = str_replace($root_path . DIRECTORY_SEPARATOR, '', $ex->getMessage());
waFiles::delete($path, true);
}
}
waFiles::protect($path_cache);
return $errors;
}
示例5: removeExtras
protected function removeExtras($app_id, $extras_id, $info)
{
try {
$paths = array();
$plugin_instance = waSystem::getInstance($app_id)->getPlugin($extras_id);
if (!$plugin_instance) {
return false;
}
$plugin_instance->uninstall();
$this->installer->updateAppPluginsConfig($app_id, $extras_id, null);
//wa-apps/$app_id/plugins/$slug
$paths[] = wa()->getAppPath("{$this->extras_type}/{$extras_id}", $app_id);
$paths[] = wa()->getTempPath(null, $app_id);
//wa-cache/temp/$app_id/
$paths[] = wa()->getAppCachePath(null, $app_id);
//wa-cache/apps/$app_id/
foreach ($paths as $path) {
waFiles::delete($path, true);
}
return true;
} catch (Exception $ex) {
//TODO check config
$this->installer->updateAppPluginsConfig($app_id, $extras_id, true);
throw $ex;
}
}
示例6: delete
public static function delete($file)
{
self::loadPath();
$file = preg_replace('!\\.\\.[/\\\\]!', '', $file);
$file = self::$path . $file;
if (file_exists($file)) {
waFiles::delete($file);
}
}
示例7: execute
public function execute()
{
$contact = wa()->getUser();
$contact['photo'] = 0;
$contact->save();
$oldDir = wa()->getDataPath(waContact::getPhotoDir($contact->getId()), true, 'contacts', false);
if (file_exists($oldDir)) {
waFiles::delete($oldDir);
}
$this->response = array('done' => 1);
}
示例8: execute
public function execute()
{
$id = waRequest::post('id');
if (is_numeric($id)) {
$modelNotifierTemplate = new shopNotifierTemplateModel();
$path = shopNotifierPlugin::path($id);
waFiles::delete($path);
$modelNotifierTemplate->deleteById($id);
$this->response['message'] = 'ok';
} else {
$this->response['message'] = 'fail';
}
}
开发者ID:quadrodesign,项目名称:notifier,代码行数:13,代码来源:shopNotifierPluginSettingsDeletetemplate.controller.php
示例9: removeExtras
protected function removeExtras($app_id, $extras_id, $info)
{
$paths = array();
$paths[] = wa()->getTempPath(null, $app_id);
//wa-cache/temp/$app_id/
//wa-apps/$app_id/extrass/$slug
$paths[] = wa()->getAppPath("{$this->extras_type}/{$extras_id}", $app_id);
$paths[] = wa()->getAppCachePath(null, $app_id);
//wa-cache/apps/$app_id/
foreach ($paths as $path) {
waFiles::delete($path, true);
}
return true;
}
示例10: execute
public function execute()
{
$id = $this->getId();
// Delete the old photos if they exist
$oldDir = wa()->getDataPath(waContact::getPhotoDir($id), TRUE);
if (file_exists($oldDir)) {
waFiles::delete($oldDir);
}
// Update record in DB for this user
$contact = new waContact($id);
$contact['photo'] = 0;
$contact->save();
// Update recent history to reload thumbnail correctly (if not called from personal account)
if (wa()->getUser()->get('is_user')) {
$history = new contactsHistoryModel();
$history->save('/contact/' . $id, null, null, '--');
}
$this->response = array('done' => 1, 'url' => $contact->getPhoto());
}
示例11: removeExtras
protected function removeExtras($app_id, $extras_id)
{
try {
$paths = array();
if (strpos($app_id, 'wa-plugins/') !== 0) {
try {
$plugin_instance = waSystem::getInstance($app_id)->getPlugin($extras_id);
if (!$plugin_instance) {
return false;
}
$plugin_instance->uninstall();
} catch (Exception $ex) {
waLog::log($ex->getMessage(), 'installer.log');
}
$this->installer->updateAppPluginsConfig($app_id, $extras_id, null);
//wa-apps/$app_id/plugins/$slug
$paths[] = wa()->getAppPath("{$this->extras_type}/{$extras_id}", $app_id);
$paths[] = wa()->getTempPath(null, $app_id);
//wa-cache/temp/$app_id/
$paths[] = wa()->getAppCachePath(null, $app_id);
//wa-cache/apps/$app_id/
} else {
$type = str_replace('wa-plugins/', '', $app_id);
$paths[] = wa()->getConfig()->getPath('plugins') . '/' . $type . '/' . $extras_id;
//wa-plugins/$type/$extras_id
$paths[] = wa()->getAppCachePath(null, $type . '_' . $extras_id);
//wa-cache/apps/$app_id/
}
foreach ($paths as $path) {
waFiles::delete($path, true);
}
return true;
} catch (Exception $ex) {
//TODO check config
if (strpos($app_id, 'wa-plugins/') !== 0) {
if (file_exists(reset($paths) . '/lib/plugin.php')) {
$this->installer->updateAppPluginsConfig($app_id, $extras_id, true);
}
}
throw $ex;
}
}
示例12: delete
public function delete(array $product_ids)
{
if (wa()->getEnv() !== 'cli') {
$delete_ids = $this->filterAllowedProductIds($product_ids);
} else {
$delete_ids = $product_ids;
}
// remove files
foreach ($delete_ids as $product_id) {
try {
waFiles::delete(shopProduct::getPath($product_id, null, false));
waFiles::delete(shopProduct::getPath($product_id, null, true));
} catch (waException $e) {
}
}
if (empty($delete_ids)) {
return false;
}
$params = array('ids' => $delete_ids);
/**
* @event product_delete
* @param array [string]mixed $params
* @param array [string]array $params['ids'] Array of IDs of deleted product entries
* @return void
*/
wa()->event('product_delete', $params);
// remove from related models
foreach (array(new shopProductFeaturesModel(), new shopProductImagesModel(), new shopProductReviewsModel(), new shopProductServicesModel(), new shopProductSkusModel(), new shopProductStocksModel(), new shopProductStocksLogModel(), new shopProductTagsModel(), new shopCategoryProductsModel(), new shopSetProductsModel(), new shopSearchIndexModel(), new shopProductFeaturesSelectableModel(), new shopProductParamsModel(), new shopCartItemsModel()) as $model) {
$model->deleteByProducts($delete_ids);
}
$type_ids = $this->select('DISTINCT `type_id`')->where($this->getWhereByField($this->id, $delete_ids))->fetchAll('type_id');
// remove records
if ($this->deleteById($delete_ids)) {
$type_model = new shopTypeModel();
$type_model->recount(array_keys($type_ids));
if ($cache = wa('shop')->getCache()) {
$cache->deleteGroup('sets');
}
return $delete_ids;
}
return false;
}
示例13: execute
public function execute()
{
try {
$path_cache = waConfig::get('wa_path_cache');
waFiles::delete($path_cache, true);
waFiles::protect($path_cache);
$app_path = waConfig::get('wa_path_apps');
$apps = new waInstallerApps();
$app_list = $apps->getApplicationsList(true);
foreach ($app_list as $app) {
if (isset($app['enabled']) && $app['enabled']) {
$path_cache = $app_path . '/' . $app['slug'] . '/js/compiled';
waFiles::delete($path_cache, true);
}
}
$this->response['message'] = _w('Cache cleared');
} catch (Exception $ex) {
$this->setError($ex->getMessage());
}
}
示例14: execute
public function execute()
{
$deleted = false;
if ($this->getRights('delete_files')) {
$path = waRequest::post('path');
if ($path) {
$full_path = logsHelper::getAbsolutePath($path);
if (!is_dir($full_path)) {
$available = logsHelper::checkPath($full_path, false);
if ($available) {
$deleted = waFiles::delete($full_path);
}
}
}
}
if ($deleted) {
$update_total_size = waRequest::get('update_size', 0, waRequest::TYPE_INT) == 1;
$this->response['total_size'] = $update_total_size ? logsHelper::getTotalLogsSize() : '';
} else {
$this->errors[] = _wp('File cannot be deleted');
}
}
示例15: execute
public function execute()
{
$id = waRequest::post('id', null, waRequest::TYPE_INT);
$filter = waRequest::post('filter', 'grayscale', waRequest::TYPE_STRING_TRIM);
if (!$id) {
throw new waException(_w("Can't apply a filter to photo: unknown photo id"));
}
if (!isset($this->filters[$filter])) {
throw new waException(_w("Can't apply a filter to photo: unknown filter"));
}
$plugin = wa('photos')->getPlugin('imageeffects');
$filter_params = $plugin->getSettings($filter);
$filter_params = $filter_params ? $filter_params : array();
$filter = $this->filters[$filter];
$photo_model = new photosPhotoModel();
$photo_rights_model = new photosPhotoRightsModel();
$photo = $photo_model->getById($id);
$photo_rights_model = new photosPhotoRightsModel();
if (!$photo_rights_model->checkRights($photo, true)) {
throw new waException(_w("You don't have sufficient access rights"));
}
$photo_path = photosPhoto::getPhotoPath($photo);
$image = new photosImage($photo_path);
if ($image->filter($filter, $filter_params)->save()) {
waFiles::delete(photosPhoto::getPhotoThumbDir($photo));
$edit_datetime = date('Y-m-d H:i:s');
$photo_model->updateById($id, array('edit_datetime' => $edit_datetime));
$photo['edit_datetime'] = $edit_datetime;
$original_photo_path = photosPhoto::getOriginalPhotoPath($photo);
if (wa('photos')->getConfig()->getOption('save_original') && file_exists($original_photo_path)) {
$photo['original_exists'] = true;
} else {
$photo['original_exists'] = false;
}
$this->response['photo'] = $photo;
$this->log('photo_edit', 1);
}
}