当前位置: 首页>>代码示例>>PHP>>正文


PHP iaUtil::deleteFile方法代码示例

本文整理汇总了PHP中iaUtil::deleteFile方法的典型用法代码示例。如果您正苦于以下问题:PHP iaUtil::deleteFile方法的具体用法?PHP iaUtil::deleteFile怎么用?PHP iaUtil::deleteFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在iaUtil的用法示例。


在下文中一共展示了iaUtil::deleteFile方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _gridRead

 protected function _gridRead($params)
 {
     switch ($_POST['action']) {
         case 'delete-file':
             return $this->_deleteFile($_POST);
         case 'remove-installer':
             $result = iaUtil::deleteFile(IA_HOME . 'install/modules/module.install.php');
             return array('error' => !$result, 'message' => iaLanguage::get($result ? 'deleted' : 'error'));
         default:
             $result = array();
             $this->_iaCore->startHook('phpAdminActionsJsonHandle', array('action' => $_POST['action'], 'output' => &$result));
             return $result;
     }
 }
开发者ID:TalehFarzaliey,项目名称:subrion,代码行数:14,代码来源:actions.php

示例2: _save

 private function _save(&$iaView)
 {
     $iaAcl = $this->_iaCore->factory('acl');
     if (!$iaAcl->checkAccess($iaView->name() . iaAcl::SEPARATOR . iaCore::ACTION_EDIT)) {
         return iaView::accessDenied();
     }
     $where = "`type` != 'hidden' " . ($this->_type ? 'AND `custom` = 1' : '');
     $params = $this->_iaDb->keyvalue(array('name', 'type'), $where, iaCore::getConfigTable());
     // correct admin dashboard URL generation
     $adminPage = $this->_iaCore->get('admin_page');
     iaUtil::loadUTF8Functions('ascii', 'validation', 'bad', 'utf8_to_ascii');
     $messages = array();
     $error = false;
     if ($_POST['v'] && is_array($_POST['v'])) {
         $values = $_POST['v'];
         $this->_iaCore->startHook('phpConfigurationChange', array('configurationValues' => &$values));
         $this->_iaDb->setTable(iaCore::getConfigTable());
         foreach ($values as $key => $value) {
             $s = strpos($key, '_items_enabled');
             if ($s !== false) {
                 $p = $this->_iaCore->get($key, '', !is_null($this->_type));
                 $array = $p ? explode(',', $p) : array();
                 $data = array();
                 array_shift($value);
                 if ($diff = array_diff($value, $array)) {
                     foreach ($diff as $item) {
                         array_push($data, array('action' => '+', 'item' => $item));
                     }
                 }
                 if ($diff = array_diff($array, $value)) {
                     foreach ($diff as $item) {
                         array_push($data, array('action' => '-', 'item' => $item));
                     }
                 }
                 $extra = substr($key, 0, $s);
                 $this->_iaCore->startHook('phpPackageItemChangedForPlugin', array('data' => $data), $extra);
             }
             if (is_array($value)) {
                 $value = implode(',', $value);
             }
             if (!utf8_is_valid($value)) {
                 $value = utf8_bad_replace($value);
                 trigger_error('Bad UTF-8 detected (replacing with "?") in configuration', E_USER_NOTICE);
             }
             if (self::TYPE_IMAGE == $params[$key]) {
                 if (isset($_POST['delete'][$key])) {
                     $value = '';
                 } elseif (!empty($_FILES[$key]['name'])) {
                     if (!(bool) $_FILES[$key]['error']) {
                         if (@is_uploaded_file($_FILES[$key]['tmp_name'])) {
                             $ext = strtolower(utf8_substr($_FILES[$key]['name'], -3));
                             // if jpeg
                             if ($ext == 'peg') {
                                 $ext = 'jpg';
                             }
                             if (!array_key_exists(strtolower($_FILES[$key]['type']), $this->_imageTypes) || !in_array($ext, $this->_imageTypes, true) || !getimagesize($_FILES[$key]['tmp_name'])) {
                                 $error = true;
                                 $messages[] = iaLanguage::getf('file_type_error', array('extension' => implode(', ', array_unique($this->_imageTypes))));
                             } else {
                                 if ($this->_iaCore->get($key) && file_exists(IA_UPLOADS . $this->_iaCore->get($key))) {
                                     iaUtil::deleteFile(IA_UPLOADS . $this->_iaCore->get($key));
                                 }
                                 $value = $fileName = $key . '.' . $ext;
                                 @move_uploaded_file($_FILES[$key]['tmp_name'], IA_UPLOADS . $fileName);
                                 @chmod(IA_UPLOADS . $fileName, 0777);
                             }
                         }
                     }
                 } else {
                     $value = $this->_iaCore->get($key, '', !is_null($this->_type));
                 }
             }
             if ($this->_type) {
                 $where = sprintf("`name` = '%s' AND `type` = '%s' AND `type_id` = %d", $key, $this->_type, $this->_typeId);
                 $this->_iaDb->setTable(iaCore::getCustomConfigTable());
                 if ($_POST['c'][$key]) {
                     $values = array('name' => $key, 'value' => $value, 'type' => $this->_type, 'type_id' => $this->_typeId);
                     if ($this->_iaDb->exists($where)) {
                         unset($values['value']);
                         $this->_iaDb->bind($where, $values);
                         $this->_iaDb->update(array('value' => $value), $where);
                     } else {
                         $this->_iaDb->insert($values);
                     }
                 } else {
                     $this->_iaDb->delete($where);
                 }
                 $this->_iaDb->resetTable();
             } else {
                 $this->_iaDb->update(array('value' => $value), iaDb::convertIds($key, 'name'));
             }
         }
         $this->_iaDb->resetTable();
         $this->_iaCore->iaCache->clearAll();
     }
     if (!$error) {
         $iaView->setMessages(iaLanguage::get('saved'), iaView::SUCCESS);
         if (isset($_POST['param']['admin_page']) && $_POST['param']['admin_page'] != $adminPage) {
             iaUtil::go_to(IA_URL . $_POST['param']['admin_page'] . '/configuration/general/');
         }
//.........这里部分代码省略.........
开发者ID:kamilklkn,项目名称:subrion,代码行数:101,代码来源:configuration.php

示例3: _processQueries

 protected function _processQueries(array $entries)
 {
     $iaDb =& $this->iaDb;
     $iaDbControl = $this->iaCore->factory('dbcontrol', iaCore::ADMIN);
     require_once IA_INCLUDES . 'utils' . IA_DS . 'pclzip.lib.php';
     $mysqlOptions = 'ENGINE=MyISAM DEFAULT CHARSET=utf8';
     $pathsMap = array(self::TYPE_PLUGIN => IA_PLUGINS, self::TYPE_PACKAGE => IA_PACKAGES);
     $path = isset($pathsMap[$this->itemData['type']]) ? $pathsMap[$this->itemData['type']] : IA_HOME;
     $versionInstalled = $iaDb->one_bind('version', '`name` = :name', array('name' => $this->itemData['name']), self::getTable());
     foreach ($entries as $version => $entry) {
         if ($versionInstalled && version_compare($versionInstalled, $version, '>')) {
             continue;
         }
         foreach ($entry as $data) {
             if ($data['external']) {
                 $filePath = str_replace(array('{DIRECTORY_SEPARATOR}', '{DS}'), IA_DS, $data['query']);
                 $fileFullPath = $path . $this->itemData['name'] . IA_DS . $filePath;
                 if (iaUtil::isZip($fileFullPath)) {
                     $archive = new PclZip($fileFullPath);
                     $files = $archive->extract(PCLZIP_OPT_PATH, IA_TMP);
                     if (0 == $files) {
                         continue;
                     }
                     foreach ($files as $file) {
                         $iaDbControl->splitSQL($file['filename']);
                         iaUtil::deleteFile($file['filename']);
                     }
                 } else {
                     $iaDbControl->splitSQL($fileFullPath);
                 }
             } else {
                 if ($data['query']) {
                     $iaDb->query(str_replace(array('{prefix}', '{mysql_version}'), array($iaDb->prefix, $mysqlOptions), $data['query']));
                 }
             }
         }
     }
 }
开发者ID:TalehFarzaliey,项目名称:subrion,代码行数:38,代码来源:ia.admin.extra.php

示例4: delete

 public function delete($itemId)
 {
     $result = false;
     if ($entryData = $this->iaDb->row(iaDb::ALL_COLUMNS_SELECTION, iaDb::convertIds($itemId), self::getTable())) {
         $result = (bool) $this->iaDb->delete(iaDb::convertIds($itemId), self::getTable());
         if ($result) {
             $iaField = $this->iaCore->factory('field');
             // delete images field values
             if ($imageFields = $iaField->getImageFields($this->getItemName())) {
                 $iaPicture = $this->iaCore->factory('picture');
                 foreach ($imageFields as $imageFieldName) {
                     if (isset($entryData[$imageFieldName]) && $entryData[$imageFieldName]) {
                         $iaPicture->delete($entryData[$imageFieldName]);
                     }
                 }
             }
             // delete storage field values
             if ($storageFields = $iaField->getStorageFields($this->getPackageName())) {
                 foreach ($storageFields as $storageFieldName) {
                     if (isset($entryData[$storageFieldName]) && $entryData[$storageFieldName]) {
                         if (':' == $entryData[$storageFieldName][1]) {
                             $unpackedData = unserialize($entryData[$storageFieldName]);
                             if (is_array($unpackedData) && $unpackedData) {
                                 foreach ($unpackedData as $oneFile) {
                                     iaUtil::deleteFile(IA_UPLOADS . $oneFile['path']);
                                 }
                             }
                         }
                     }
                 }
             }
             $this->_writeLog(iaCore::ACTION_DELETE, $entryData, $itemId);
             $this->updateCounters($itemId, $entryData, iaCore::ACTION_DELETE);
             $this->iaCore->startHook('phpListingRemoved', array('itemId' => $itemId, 'itemName' => $this->getItemName(), 'itemData' => $entryData));
         }
     }
     return $result;
 }
开发者ID:kamilklkn,项目名称:subrion,代码行数:38,代码来源:ia.base.package.admin.php

示例5: _cascadeRemoveFiles

 public function _cascadeRemoveFiles($directory, $removeDirectories = true)
 {
     if (substr($directory, -1) == IA_DS) {
         $directory = substr($directory, 0, -1);
     }
     if (!file_exists($directory) || !is_dir($directory)) {
         return false;
     } elseif (is_readable($directory)) {
         $handle = opendir($directory);
         while ($item = readdir($handle)) {
             if ($item != '.' && $item != '..' && $item != '.htaccess') {
                 $path = $directory . IA_DS . $item;
                 if (is_dir($path)) {
                     $this->_cascadeRemoveFiles($path, true);
                 } else {
                     iaUtil::deleteFile($path);
                 }
             }
         }
         closedir($handle);
         if ($removeDirectories) {
             $objects = scandir($directory);
             foreach ($objects as $object) {
                 if ($object != '.' && $object != '..') {
                     if (filetype($directory . IA_DS . $object) == 'dir') {
                         rmdir($directory . IA_DS . $object);
                     }
                 }
             }
             reset($objects);
         }
     }
     return true;
 }
开发者ID:nicefirework,项目名称:subrion,代码行数:34,代码来源:ia.core.cache.php

示例6: _processQueries

 protected function _processQueries($type, $stage, $ignoreNonVersionedQueries = false)
 {
     if (!isset($this->itemData['sql'][$type][$stage])) {
         return;
     }
     $iaDb =& $this->iaDb;
     $iaDbControl = $this->iaCore->factory('dbcontrol', iaCore::ADMIN);
     require_once IA_INCLUDES . 'utils' . IA_DS . 'pclzip.lib.php';
     $mysqlOptions = 'ENGINE=MyISAM DEFAULT CHARSET=utf8';
     $path = isset($this->_extrasTypePaths[$this->itemData['type']]) ? $this->_extrasTypePaths[$this->itemData['type']] : IA_HOME;
     $extrasVersion = $this->itemData['info']['version'];
     foreach ($this->itemData['sql'][$type][$stage] as $version => $entries) {
         if ($ignoreNonVersionedQueries && self::VERSION_EMPTY == $version) {
             continue;
         }
         if (self::VERSION_EMPTY != $version && version_compare($version, $extrasVersion) > 0) {
             continue;
         }
         foreach ($entries as $entry) {
             if ($entry['external']) {
                 $filePath = str_replace('{DS}', IA_DS, $entry['query']);
                 $fileFullPath = $path . $this->itemData['name'] . IA_DS . $filePath;
                 if (iaUtil::isZip($fileFullPath)) {
                     $archive = new PclZip($fileFullPath);
                     $files = $archive->extract(PCLZIP_OPT_PATH, IA_TMP);
                     if (0 == $files) {
                         continue;
                     }
                     foreach ($files as $file) {
                         $iaDbControl->splitSQL($file['filename']);
                         iaUtil::deleteFile($file['filename']);
                     }
                 } else {
                     $iaDbControl->splitSQL($fileFullPath);
                 }
             } else {
                 if ($entry['query']) {
                     $query = str_replace(array('{prefix}', '{mysql_version}'), array($iaDb->prefix, $mysqlOptions), $entry['query']);
                     $iaDb->query($query);
                 }
             }
         }
     }
 }
开发者ID:kreativmind,项目名称:subrion,代码行数:44,代码来源:ia.admin.extra.php

示例7: _entryDelete

 protected function _entryDelete($entryId)
 {
     $result = false;
     if ($entryData = $this->getById($entryId)) {
         $result = $this->_delete($entryId);
         if ($result) {
             $iaField = $this->_iaCore->factory('field');
             // we have to check for uploaded images of this listing
             if ($imageFields = $iaField->getImageFields($this->getItemName())) {
                 $iaPicture = $this->_iaCore->factory('picture');
                 foreach ($imageFields as $imageFieldName) {
                     if (!empty($entryData[$imageFieldName])) {
                         $iaPicture->delete($entryData[$imageFieldName]);
                     }
                 }
             }
             // delete storage field values
             if ($storageFields = $iaField->getStorageFields($this->getPackageName())) {
                 foreach ($storageFields as $storageFieldName) {
                     if (isset($entryData[$storageFieldName]) && $entryData[$storageFieldName]) {
                         if (':' == $entryData[$storageFieldName][1]) {
                             $unpackedData = unserialize($entryData[$storageFieldName]);
                             if (is_array($unpackedData) && $unpackedData) {
                                 foreach ($unpackedData as $oneFile) {
                                     iaUtil::deleteFile(IA_UPLOADS . $oneFile['path']);
                                 }
                             }
                         }
                     }
                 }
             }
             $this->_writeLog(iaCore::ACTION_DELETE, $entryData, $entryId);
             $this->updateCounters($entryId, $entryData, iaCore::ACTION_DELETE);
             $this->_iaCore->startHook('phpListingRemoved', array('itemId' => $entryId, 'itemName' => $this->getItemName(), 'itemData' => $entryData));
         }
     }
     return $result;
 }
开发者ID:kamilklkn,项目名称:subrion,代码行数:38,代码来源:ia.base.controller.package.admin.php


注:本文中的iaUtil::deleteFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。