예제 #1
0
파일: add.php 프로젝트: ahmatjan/manage
function createFile($title, $type, $content)
{
    //生成文件
    $File = new FileUtil();
    $File->writetofile(BASE_PATH . 'upload/webstyle/public/' . $type . '/' . $title . '.' . $type, $content);
    return $codeFilePath = '/manage/upload/webstyle/public/' . $type . '/' . $title . '.' . $type;
}
예제 #2
0
 /**
  * 获取
  * @Title: getFolderInfo
  * @Description: todo(这里用一句话描述这个方法的作用)
  * 
  * @param unknown $path        	
  * @author quqiang
  *         @date 2015年5月18日 下午4:15:29
  * @throws
  *
  */
 function getFolderInfo($path)
 {
     // 是否直接返回。true:内部调用,false:URL地址访问
     $realyReturn = true;
     if (!$path) {
         $path = $_POST['path'];
         $realyReturn = false;
     }
     // 得到所有能够编辑的文件列表
     // 先读缴存,没有就直接遍历然后存入缓存
     // 处理编辑文件初始目录
     // 所有可以有编辑的文件夹
     $fileData = '';
     // 先找缓存
     $catchdata = F('file_edit_root_dir');
     if (is_array($fileData[$path])) {
         $fileData = $fileData[$path];
     } else {
         import('@.ORG.FileUtil');
         $fileObj = new FileUtil();
         $ret = $fileObj->getOneDir($path);
         if (is_array($ret) && $path) {
             if (is_array($catchdata)) {
                 $catchdataTemp = array_merge($catchdata, array($path => $ret['dir']));
             } else {
                 $catchdataTemp = array($path => $ret['dir']);
             }
             F('file_edit_root_dir', $catchdataTemp);
         }
         $fileData = $ret;
         //['dir'];
     }
     $temp = reset($fileData);
     $dir = '';
     $file = '';
     if ($temp['dir']) {
         $dir = $temp['dir'];
     }
     if ($temp['file']) {
         $file = $temp['file'];
     }
     if (is_array($dir) && is_array($file)) {
         $fileList = array_merge($dir, $file);
     } elseif (!is_array($dir) && is_array($file)) {
         $fileList = $file;
     } elseif (is_array($dir) && !is_array($file)) {
         $fileList = $dir;
     } else {
         $fileList = '';
     }
     // 		print_r($fileList);
     if ($realyReturn) {
         return $fileList;
     } else {
         //echo json_encode (  $fileList  );
         $this->assign('vo', $fileList);
         $this->display('FieldEdit:index');
     }
 }
예제 #3
0
 protected function checkFile()
 {
     import('@.ORG.FileUtil');
     $dir = DConfig_PATH . '/Models';
     $obj = new FileUtil();
     $chekDir = ROOT . '/nbm';
     $obj->checkFileAndCreateAppend($dir, 'listExtend.inc.php', $dir . '/listExtend.inc.php', '');
     var_dump($fileArr);
 }
예제 #4
0
파일: Lock.php 프로젝트: bmdevel/bav
 /**
  * @param string $name lock name
  * @throws LockException
  */
 public function __construct($name)
 {
     $this->name = $name;
     $fileUtil = new FileUtil();
     $lockFile = $fileUtil->getTempDirectory() . DIRECTORY_SEPARATOR . $name;
     $this->handle = fopen($lockFile, "w");
     if (!is_resource($this->handle)) {
         throw new LockException("Could not open lock file {$lockFile}.");
     }
 }
예제 #5
0
 public function actionDelTemplate($template)
 {
     $fileutil = new FileUtil();
     $fileutil->deldir("themes/" . $template);
     $defTheme = $this->connection->createCommand("select content from xm_config where syskey = 'theme'")->queryScalar();
     if ($defTheme == $template) {
         $templates = $fileutil->getFileList('themes');
         $this->actionSetDefault($templates[0]);
     }
     echo 1;
 }
예제 #6
0
 /**
  * @expectedException \PHPUnit_Framework_Error_Notice
  * @medium
  */
 public function testAutomaticUpdatePlan()
 {
     $fileUtil = new FileUtil();
     $file = tempnam($fileUtil->getTempDirectory(), 'bavtest');
     touch($file, strtotime("-1 year"));
     $backend = new FileDataBackend($file);
     $updatePlan = new AutomaticUpdatePlan();
     $this->assertTrue($updatePlan->isOutdated($backend));
     $updatePlan->perform($backend);
     $this->assertFalse($updatePlan->isOutdated($backend));
 }
 /**
  * @Title: setexecutingfile 
  * @Description: todo(生成处理页面)   
  * @author libo 
  * @date 2014-7-7 上午9:49:40 
  * @throws
  */
 public function setexecutingfile()
 {
     import('@.ORG.FileUtil');
     //引入文件
     $obj = new FileUtil();
     //实例化对象
     $chekDir = ROOT . '/Tpl/default/' . $_REQUEST['name'];
     //设置找查目录
     $createDir = ROOT . '/Tpl/default/MisWorkExecuting';
     //返回日志记录位置
     $a = $obj->checkFile($chekDir, $_REQUEST['name'] . '.html', array('auditview.html', 'view.html', 'edit.html'), $createDir, false, true);
 }
예제 #8
0
 /**
  * @Title: step_one 
  * @Description: todo(第一版执行文件检查)   
  * @author laicaixia 
  * @date 2013-6-2 上午10:35:32 
  * @throws 
  */
 public function step_one()
 {
     $fileutil = new FileUtil();
     $filedir = $fileutil->file_list_all(APP_PATH);
     //print_r($a);
     $filedirlist = $this->getResult($filedir);
     foreach ($filedirlist as $key => $val) {
         $arr[] = explode("|", $val);
     }
     $this->assign("filedir", $arr);
     $this->display();
 }
예제 #9
0
 /**
  * Tests automatic installation.
  */
 public function testAutomaticUpdate()
 {
     $updatePlan = new AutomaticUpdatePlan();
     $updatePlan->setNotice(false);
     ConfigurationRegistry::getConfiguration()->setUpdatePlan($updatePlan);
     $fileUtil = new FileUtil();
     $container = new FileDataBackendContainer(tempnam($fileUtil->getTempDirectory(), 'bavtest'));
     $backend = $container->getDataBackend();
     touch($backend->getFile(), strtotime("-1 year"));
     $this->assertTrue($updatePlan->isOutdated($backend));
     $container->applyUpdatePlan($backend);
     $this->assertFalse($updatePlan->isOutdated($backend));
     $backend->uninstall();
     ConfigurationRegistry::getConfiguration()->setUpdatePlan(null);
 }
예제 #10
0
 /**
  * Parses the menu items.
  */
 protected function parseMenuItems()
 {
     foreach ($this->menuItems as $parentMenuItem => $items) {
         foreach ($items as $key => $item) {
             if (!empty($item['menuItemLink']) || !empty($item['menuItemIcon'])) {
                 // get relative path
                 $path = '';
                 if (empty($item['packageDir'])) {
                     $path = RELATIVE_WCF_DIR;
                 } else {
                     $path = FileUtil::getRealPath(RELATIVE_WCF_DIR . $item['packageDir']);
                 }
                 // add package id and session id to link
                 if (!empty($item['menuItemLink'])) {
                     $item['menuItemLink'] = $this->parseMenuItemLink($item['menuItemLink'], $path);
                 }
                 if (!empty($item['menuItemIcon'])) {
                     $item['menuItemIcon'] = $this->parseMenuItemIcon($item['menuItemIcon'], $path);
                 }
                 $this->menuItems[$parentMenuItem][$key] = $item;
             }
             $this->menuItemList[$item['menuItem']] =& $this->menuItems[$parentMenuItem][$key];
         }
     }
 }
예제 #11
0
 /**
  * Loads the taggable objects.
  */
 protected function loadTaggables()
 {
     if ($this->taggables !== null) {
         return;
     }
     // get cache
     WCF::getCache()->addResource('taggables-' . PACKAGE_ID, WCF_DIR . 'cache/cache.taggables-' . PACKAGE_ID . '.php', WCF_DIR . 'lib/system/cache/CacheBuilderTaggable.class.php');
     $this->taggablesData = WCF::getCache()->get('taggables-' . PACKAGE_ID);
     // get objects
     $this->taggables = array();
     foreach ($this->taggablesData as $type) {
         // calculate class path
         $path = '';
         if (empty($type['packageDir'])) {
             $path = WCF_DIR;
         } else {
             $path = FileUtil::getRealPath(WCF_DIR . $type['packageDir']);
         }
         // include class file
         if (!file_exists($path . $type['classPath'])) {
             throw new SystemException("unable to find class file '" . $path . $type['classPath'] . "'", 11000);
         }
         require_once $path . $type['classPath'];
         // create instance
         $className = StringUtil::getClassName($type['classPath']);
         if (!class_exists($className)) {
             throw new SystemException("unable to find class '" . $className . "'", 11001);
         }
         $this->taggables[$type['taggableID']] = new $className($type['taggableID'], $type['name']);
     }
 }
 /**
  * Returns the tree of options.
  * 
  * @return	array
  */
 public function getOptionTree($parentCategoryName = '', User $user)
 {
     $options = array();
     if (isset($this->categoryStructure[$parentCategoryName])) {
         // get super categories
         foreach ($this->categoryStructure[$parentCategoryName] as $superCategoryName) {
             $superCategory = $this->categories[$superCategoryName];
             // add icon path
             if (!empty($superCategory['categoryIconM'])) {
                 // get relative path
                 $path = '';
                 if (empty($superCategory['packageDir'])) {
                     $path = RELATIVE_WCF_DIR;
                 } else {
                     $path = FileUtil::getRealPath(RELATIVE_WCF_DIR . $superCategory['packageDir']);
                 }
                 $superCategory['categoryIconM'] = $path . $superCategory['categoryIconM'];
             }
             $superCategory['options'] = $this->getCategoryOptions($superCategoryName, $user);
             if (count($superCategory['options']) > 0) {
                 $options[$superCategoryName] = $superCategory;
             }
         }
     }
     return $options;
 }
예제 #13
0
function SaveJsonData($category, $start, $end, $file_Path)
{
    $rows = array();
    $query2 = " select pro_id ,title ,img_url ,detail_url ,shop_name ,price ,month_sold ,comm_percent ,seller_ww ,back_BB ,";
    $query2 .= " short_tbk_url ,tbk_url ,commission ,earn ,img_list ,show_order ,P.cat_id ,entrydate ,disabled ";
    $query2 .= " from BS_ProInfo AS P";
    $query2 .= " join BS_Category as C on P.cat_id=C.cat_id";
    $query2 .= " where P.disabled=0 and C.category ='{$category}'";
    $query2 .= " limit {$start}, {$end}";
    // echo $query2;
    // exit();
    $result2 = mysqli_query(connect(), $query2);
    while (@($row = mysqli_fetch_assoc($result2))) {
        $rows[] = $row;
    }
    //random order
    shuffle($rows);
    // echo $filename;
    // echo $query2;
    // echo "<br>";
    if (!file_exists($file_Path)) {
        // 文件所在目录
        // echo dirname($json_path);
        // mkdir($json_path, 0777);
        FileUtil::createFile($file_Path);
    }
    // 修改文件权限为读写可执行
    // Read 4 - 允许读文件
    // Write 2 - 允许写/修改文件
    // eXecute1 - 读/写/删除/修改/目录
    chmod($file_Path, 0777);
    file_put_contents($file_Path, json_encode($rows));
}
예제 #14
0
function mediashare_sourcesapi_scanSources()
{
    // Check access
    if (!SecurityUtil::checkPermission('mediashare::', '::', ACCESS_ADMIN)) {
        return LogUtil::registerPermissionError();
    }
    $dom = ZLanguage::getModuleDomain('mediashare');
    // Clear existing sources table
    if (!DBUtil::truncateTable('mediashare_sources')) {
        return LogUtil::registerError(__f('Error in %1$s: %2$s.', array('sourcesapi.scanSources', __f("Could not clear the '%s' table.", 'sources', $dom)), $dom));
    }
    // Scan for sources APIs
    $files = FileUtil::getFiles('modules/mediashare', false, true, 'php', 'f');
    foreach ($files as $file) {
        if (preg_match('/^pnsource_([-a-zA-Z0-9_]+)api.php$/', $file, $matches)) {
            $sourceName = $matches[1];
            $sourceApi = "source_{$sourceName}";
            // Force load - it is used during pninit
            pnModAPILoad('mediashare', $sourceApi, true);
            if (!($title = pnModAPIFunc('mediashare', $sourceApi, 'getTitle'))) {
                return false;
            }
            if (!pnModAPIFunc('mediashare', 'sources', 'addSource', array('title' => $title, 'name' => $sourceName))) {
                return false;
            }
        }
    }
    return true;
}
예제 #15
0
 public function createCategoryCacheFile()
 {
     $this->dbGetAllCategory();
     $categoryList = $this->categoryList['resultList'];
     $category = $firstCategory = null;
     if ($categoryList) {
         foreach ($categoryList as $val) {
             $category[$val['id']] = $val;
             $childCategory = $this->getChildCategoryById($val['id'], $categoryList);
             if ($childCategory) {
                 $category[$val['id']]['child'] = $childCategory;
             }
             if ($val['parentid'] == 0) {
                 $val['child'] = $childCategory;
                 $firstCategory[$val['id']] = $val;
             }
         }
         $category[0]['child'] = $firstCategory;
     }
     $string_start = "<?php\n \$showcategory=";
     $string_process = var_export($category, TRUE);
     $string_end = ";\n?>";
     $string = $string_start . $string_process . $string_end;
     FileUtil::writeFileContent($this->cacheFile, $string);
 }
예제 #16
0
 /**
  * Reads the disk quota info
  *
  * @param integer $pow
  * @param integer $dec
  * @return array
  */
 public static function readDiskInfo($pow = 2, $dec = 2)
 {
     $diskInformation = array();
     if (function_exists('disk_free_space') && function_exists('disk_total_space')) {
         $root = '';
         if ($tmp = @disk_total_space($_SERVER["DOCUMENT_ROOT"])) {
             $root = $_SERVER["DOCUMENT_ROOT"];
         } else {
             $sql = "SELECT packageDir FROM wcf" . WCF_N . "_package\n            \t\t\tWHERE packageID = " . PACKAGE_ID;
             $row = WCF::getDB()->getFirstRow($sql);
             $root = FileUtil::getRealPath(WCF_DIR . $row['packageDir']);
         }
         if (!empty($root)) {
             $diskInformation['totalSpace'] = round(disk_total_space($root) / pow(1024, $pow), $dec);
             $diskInformation['freeSpace'] = round(disk_free_space($root) / pow(1024, $pow), $dec);
             $diskInformation['usedSpace'] = round($diskInformation['totalSpace'] - $diskInformation['freeSpace'], $dec);
             if ($diskInformation['totalSpace'] > 0) {
                 $diskInformation['freeQuota'] = round($diskInformation['freeSpace'] * 100 / $diskInformation['totalSpace'], $dec);
                 $diskInformation['usedQuota'] = round($diskInformation['usedSpace'] * 100 / $diskInformation['totalSpace'], $dec);
             } else {
                 $diskInformation['freeQuota'] = $diskInformation['usedQuota'] = 0;
             }
         }
     }
     return $diskInformation;
 }
 public function appending()
 {
     with($stream = new FileOutputStream($this->file, true));
     $stream->write('!');
     $this->file->close();
     $this->assertEquals('Created by FileOutputStreamTest!', FileUtil::getContents($this->file));
 }
예제 #18
0
 public function createAdressCacheFile()
 {
     $addressList = $this->dbGetAllAddress();
     $addressList = $addressList['resultList'];
     $address = $firstAddress = null;
     if ($addressList) {
         foreach ($addressList as $val) {
             $address[$val['id']] = $val;
             $childAddress = $this->getChildAddressById($val['id'], $addressList);
             if ($childAddress) {
                 $address[$val['id']]['child'] = $childAddress;
             }
             if ($val['parentid'] == 0) {
                 $val['child'] = $childAddress;
                 $firstAddress[$val['id']] = $val;
             }
         }
         $address[0]['child'] = $firstAddress;
     }
     $string_start = "<?php\n \$mobileaddress=";
     $string_process = var_export($address, TRUE);
     $string_end = ";\n?>";
     $string = $string_start . $string_process . $string_end;
     FileUtil::writeFileContent($this->cacheFile, $string);
 }
예제 #19
0
 /**
  * 新增校友
  */
 public function newAction($col_id)
 {
     //判断是否ajax
     if ($this->request->isAjax()) {
         $validate = new \Validate();
         $data['col_id'] = $validate->getPost('col_id', \Validate::int());
         //学校id
         $data['alu_head'] = $validate->getPost('alu_head', \Validate::base64());
         //校友头像
         $data['alu_name'] = $validate->getPost('alu_name', \Validate::length(15, 2));
         //校友名称
         $data['alu_desc'] = $validate->getPost('alu_desc', \Validate::length(255, 2));
         //校友简介
         $data['alu_src'] = $validate->getPost('alu_src', \Validate::length(255, 2));
         //资料来源
         //验证参数
         if ($validate->getMessage()) {
             $this->end(400);
         }
         //生成校友头像
         $data['alu_head'] = \Func::touchImg($data['alu_head'], 'alu_head');
         //监测图片是否生成成功
         if (!$data['alu_head']) {
             \FileUtil::getInstance()->unlink(UPLOAD_PATH . $data['alu_head']);
             $this->end(400);
         }
         //新增动态
         $this->end((new \CollegeAlumnus())->addAlumnus($this->session->get('id'), $data));
     }
     $this->view->setVars(['col_id' => $col_id]);
 }
예제 #20
0
    /**
     * read editors folder and load names into array
     * 
     * @param array $args
     * @return type 
     */
    public function getEditors($args)
    {
        $path = 'modules/Scribite/plugins';
        $plugins = FileUtil::getFiles($path, false, true, null, 'd');


        $editors = array();

        foreach ($plugins as $pluginName) {
            $className = 'ModulePlugin_Scribite_' . $pluginName . '_Plugin';
            $instance = PluginUtil::loadPlugin($className);
            $pluginstate = PluginUtil::getState($instance->getServiceId(), PluginUtil::getDefaultState());
            if ($pluginstate['state'] == PluginUtil::ENABLED) {
                if (isset($args['format']) && $args['format'] == 'formdropdownlist') {
                    $editors[] = array(
                        'text' => $instance->getMetaDisplayName(),
                        'value' => $pluginName
                    );
                } else {
                    $editors[$pluginName] = $instance->getMetaDisplayName();
                }
            }
        }

        return $editors;
    }
예제 #21
0
파일: Downloader.php 프로젝트: bmdevel/bav
 /**
  * Downloads a file.
  *
  * @param string $uri URI
  * @return string local path to downloaded file.
  * @throws DownloaderException
  */
 public function downloadFile($uri)
 {
     $fileUtil = new FileUtil();
     $file = tempnam($fileUtil->getTempDirectory(), "bavdownload");
     $fp = fopen($file, 'w');
     if (!($file && $fp)) {
         throw new DownloaderException("Failed opening a temporary file");
     }
     curl_setopt($this->handle, CURLOPT_FILE, $fp);
     if (!$this->download($uri)) {
         fclose($fp);
         unlink($file);
         throw new DownloaderException(curl_error($this->handle), curl_errno($this->handle));
     }
     return $file;
 }
예제 #22
0
 public function republicAll()
 {
     if (LOCAL) {
         $except = array("image", "css", "font", "js", ".", "..");
         $basePath = $this->getBasePath();
         $dir = @opendir($basePath);
         while ($entry = @readdir($dir)) {
             $file = $basePath . DIRECTORY_SEPARATOR . $entry;
             if (!in_array($entry, array_merge($this->excludeFiles, $except))) {
                 if (is_dir($file)) {
                     FileUtil::clearDirs($file . "/");
                 }
             }
         }
         closedir($dir);
         $modules = Ibos::app()->getEnabledModule();
         foreach ($modules as $module) {
             $path = Yii::getPathOfAlias("application.modules.{$module["module"]}.static");
             if (is_dir($path)) {
                 $this->publish($path, false, -1, true);
             }
         }
     }
     return true;
 }
예제 #23
0
 public static function water($source, $water, $saveName = null, $pos = 0, $alpha = 80, $quality = 100)
 {
     if (!FileUtil::fileExists($source) || !FileUtil::fileExists($water)) {
         return false;
     }
     $sInfo = self::getImageInfo($source);
     $wInfo = self::getImageInfo($water);
     if ($sInfo["width"] < $wInfo["width"] || $sInfo["height"] < $wInfo["height"]) {
         return false;
     }
     $sCreateFunction = "imagecreatefrom" . $sInfo["type"];
     $sImage = $sCreateFunction($source);
     $wCreateFunction = "imagecreatefrom" . $wInfo["type"];
     $wImage = $wCreateFunction($water);
     imagealphablending($wImage, true);
     list($posX, $posY) = self::getPos($sInfo, $wInfo, $pos);
     if ($wInfo["type"] == "png") {
         imagecopy($sImage, $wImage, $posX, $posY, 0, 0, $wInfo["width"], $wInfo["height"]);
     } else {
         imagealphablending($wImage, true);
         imagecopymerge($sImage, $wImage, $posX, $posY, 0, 0, $wInfo["width"], $wInfo["height"], $alpha);
     }
     $imageFun = "image" . $sInfo["type"];
     if (!$saveName) {
         $saveName = $source;
         @unlink($source);
     }
     if ($sInfo["mime"] == "image/jpeg") {
         $imageFun($sImage, $saveName, $quality);
     } else {
         $imageFun($sImage, $saveName);
     }
     imagedestroy($sImage);
     return true;
 }
예제 #24
0
 /**
  * 回答接口
  */
 public function addAction()
 {
     //取值,参数验证,签名验证
     $vars = ['mem_id', 'mem_mark', 'empty_ans_id', 'mem_relation_id', 'que_id', 'ans_content', 'is_img', 'sign'];
     $this->beforeGetVarExecVerify($vars, 'post');
     //判断是否是图片
     if ($this->data['is_img'] == 1) {
         $this->data['ans_content'] = \Func::touchImg($this->data['ans_content'], 'ans');
         if (!$this->data['ans_content']) {
             $this->throwMessage(ILLEGAL_IMAGE);
         }
     }
     //默认执行回答提问方法
     $func = 'addAnswer';
     //需要的字段
     $field = ['mem_id', 'mem_mark', 'mem_relation_id', 'que_id', 'ans_content'];
     //根据可空回答id,empty_ans_id判断是否执行追问方法
     if ($this->data['empty_ans_id']) {
         array_push($field, $this->data['empty_ans_id']);
         $func = 'addAnswerAsk';
     }
     //转义回答内容
     $this->data['ans_content'] = mb_substr(\Func::escape($this->data['ans_content']), 0, 250, 'utf-8');
     //获取执行状态,执行失败,并且是图片信息,则删除上传的图片
     $add_status = $this->callModelFunc('Answer', $func, $field);
     if ($add_status != OK && $this->data['is_img'] == 1) {
         \FileUtil::getInstance()->unlink(PUBLIC_PATH . $this->data['ans_content']);
     }
     $this->throwMessage($add_status);
 }
 /**
  * Parse a rss feed.
  * 
  * @param	string		$sourceURL
  * @return	array
  */
 public static function parseFeed($sourceURL)
 {
     $newsItems = array();
     $filename = FileUtil::downloadFileFromHttp($sourceURL, 'feed');
     // open & parse file
     $xml = new XML($filename);
     $data = $xml->getElementTree('channel');
     $items = $data['children'][0]['children'];
     foreach ($items as $item) {
         if ($item['name'] != 'item') {
             continue;
         }
         $newsItem = array('title' => '', 'author' => '', 'link' => '', 'guid' => '', 'pubDate' => '', 'description' => '');
         foreach ($item['children'] as $child) {
             if (!isset($child['cdata'])) {
                 continue;
             }
             $newsItem[$child['name']] = $child['cdata'];
         }
         // convert encodings
         if (CHARSET != 'UTF-8') {
             $newsItem['title'] = StringUtil::convertEncoding('UTF-8', CHARSET, $newsItem['title']);
             $newsItem['author'] = StringUtil::convertEncoding('UTF-8', CHARSET, $newsItem['author']);
             $newsItem['link'] = StringUtil::convertEncoding('UTF-8', CHARSET, $newsItem['link']);
             $newsItem['guid'] = StringUtil::convertEncoding('UTF-8', CHARSET, $newsItem['guid']);
             $newsItem['description'] = StringUtil::convertEncoding('UTF-8', CHARSET, $newsItem['description']);
         }
         @($newsItem['pubDate'] = intval(strtotime($newsItem['pubDate'])));
         $newsItems[] = $newsItem;
     }
     // delete tmp file
     @unlink($filename);
     return $newsItems;
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     // validate class path
     if (empty($this->classPath)) {
         throw new UserInputException('classPath');
     }
     try {
         $package = new Package($this->packageID);
         if (!@file_exists(FileUtil::getRealPath(WCF_DIR . $package->getDir() . $this->classPath))) {
             throw new UserInputException('classPath', 'doesNotExist');
         }
     } catch (SystemException $e) {
         throw new UserInputException('classPath', 'doesNotExist');
     }
     try {
         CronjobEditor::validate($this->startMinute, $this->startHour, $this->startDom, $this->startMonth, $this->startDow);
     } catch (SystemException $e) {
         // extract field name
         $fieldName = '';
         if (preg_match("/cronjob attribute '(.*)'/", $e->getMessage(), $match)) {
             $fieldName = $match[1];
         }
         throw new UserInputException($fieldName, 'notValid');
     }
 }
예제 #27
0
파일: FileUtil.php 프로젝트: xw716825/work
 /**
  * 获得FileUtil类的实例
  * 单例模式
  * @return object 返回对象的实例
  */
 public static function getInstance()
 {
     if (!self::$_instance instanceof self) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
예제 #28
0
파일: User.php 프로젝트: robbrandt/Avatar
 /**
  * Avatar_userapi_GetAvatars()
  *
  * returns all possible avatars for the current user.
  *
  * @param integer $args['uid'] the user ID (if missing, the current user is assumed)
  * @param integer $args['startnum'] int the number where to start (for paging)
  * @param integer $args['perpage'] int items per page
  * @return array a list of avatar file names
  **/
 public function getAvatars($args)
 {
     $uid = isset($args['uid']) ? $args['uid'] : UserUtil::getVar('uid');
     $page = isset($args['page']) ? $args['page'] : -1;
     $perpage = isset($args['perpage']) ? $args['perpage'] : -1;
     $realimages = isset($args['realimages']) ? true : false;
     $avatarpath = ModUtil::getVar('Users', 'avatarpath');
     $allavatars = FileUtil::getFiles($avatarpath, true, true, null, false);
     if ($realimages == true) {
         $allavatars = array_diff($allavatars, array('blank.gif', 'gravatar.gif'));
     }
     $avatars = array();
     foreach ($allavatars as $avatar) {
         // imagename is like pers_XXXX.gif (with XXXX = user id)
         if (ModUtil::apiFunc('Avatar', 'user', 'checkAvatar', array('avatar' => $avatar, 'uid' => $uid)) == true) {
             $avatars[] = $avatar;
         }
     }
     sort($avatars);
     $allcount = count($avatars);
     // paging
     if ($page != -1 && $perpage != -1) {
         $start = ($page - 1) * $perpage;
         $stop = $start + $perpage;
         if ($stop > $allcount) {
             $stop = $allcount;
         }
         $pagedavatars = array();
         for ($idx = $start; $idx < $stop; $idx++) {
             $pagedavatars[] = $avatars[$idx];
         }
         return array($pagedavatars, $allcount);
     }
     return array($avatars, $allcount);
 }
 /**
  * Returns a list of available suspension types.
  * 
  * @return	array<SuspensionType>
  */
 public static function getAvailableSuspensionTypes()
 {
     if (self::$availableSuspensionTypes === null) {
         WCF::getCache()->addResource('suspensionTypes-' . PACKAGE_ID, WCF_DIR . 'cache/cache.suspensionTypes-' . PACKAGE_ID . '.php', WCF_DIR . 'lib/system/cache/CacheBuilderSuspensionTypes.class.php');
         $types = WCF::getCache()->get('suspensionTypes-' . PACKAGE_ID);
         foreach ($types as $type) {
             // get path to class file
             if (empty($type['packageDir'])) {
                 $path = WCF_DIR;
             } else {
                 $path = FileUtil::getRealPath(WCF_DIR . $type['packageDir']);
             }
             $path .= $type['classFile'];
             // include class file
             if (!class_exists($type['className'])) {
                 if (!file_exists($path)) {
                     throw new SystemException("Unable to find class file '" . $path . "'", 11000);
                 }
                 require_once $path;
             }
             // instance object
             if (!class_exists($type['className'])) {
                 throw new SystemException("Unable to find class '" . $type['className'] . "'", 11001);
             }
             self::$availableSuspensionTypes[$type['suspensionType']] = new $type['className']();
         }
     }
     return self::$availableSuspensionTypes;
 }
예제 #30
0
 public static function export($idstr)
 {
     $idArr = is_array($idstr) ? $idstr : explode(",", $idstr);
     if (1 < count($idArr)) {
         $zip = new Zip();
         $exportFileName = Ibos::lang("Form export file pack", "workflow.default", array("{date}" => date("Y-m-d")));
         $zipFileName = FileUtil::getTempPath() . "/" . TIMESTAMP . ".zip";
         foreach ($idArr as $id) {
             $form = self::handleExportSingleForm($id);
             $zip->addFile($form["content"], sprintf("%s.html", ConvertUtil::iIconv($form["title"], CHARSET, "gbk")));
         }
         $fp = fopen($zipFileName, "w");
         if (@fwrite($fp, $zip->file()) !== false) {
             header("Cache-control: private");
             header("Content-type: application/octet-stream");
             header("Accept-Ranges: bytes");
             header("Content-Length: " . sprintf("%u", FileUtil::fileSize($zipFileName)));
             header("Content-Disposition: attachment; filename=" . $exportFileName . ".zip");
             readfile($zipFileName);
             exit;
         }
     } else {
         $id = implode(",", $idArr);
         $form = self::handleExportSingleForm($id);
         ob_end_clean();
         header("Cache-control: private");
         header("Content-type: text/plain");
         header("Accept-Ranges: bytes");
         header("Accept-Length: " . strlen($form["content"]));
         header("Content-Disposition: attachment; filename=" . $form["title"] . ".html");
         echo $form["content"];
     }
 }