Esempio n. 1
0
 /**
  * @ORM\PostPersist
  */
 public function uploadFile2()
 {
     if (null === $this->file2) {
         return;
     } else {
         $this->file2->move(__DIR__ . '/../../../app/uploads' . $this->getUploadDir(), $this->second_fichier);
         unset($this->file2);
     }
 }
function createAndWrite($file, $string)
{
    $file_ins = new file();
    if ($file_ins->createFile($file)) {
        $file_ins->writeToFile($string);
        return True;
    } else {
        return False;
    }
}
Esempio n. 3
0
 /**
  * @ORM\PostPersist
  */
 public function upload()
 {
     if (null === $this->file) {
         return;
     }
     // if there is an error when moving the file, an exception will
     // be automatically thrown by move(). This will properly prevent
     // the entity from being persisted to the database on error
     $this->file->move($this->getUploadRootDir(), $this->photo);
     unset($this->file);
 }
Esempio n. 4
0
function file_upload($files)
{
    global $upload_path;
    $objects = array();
    foreach ($files as $file) {
        if (!empty($file['name'])) {
            $obj = new file();
            $obj->upload($file);
            $objects[] = $obj;
        }
    }
    return $objects;
}
Esempio n. 5
0
 public function __destruct()
 {
     flush();
     if (!is_dir(ROOT . 'task')) {
         return false;
     }
     if (AJAX) {
         return false;
     }
     //ajax操作的时候不做计划任务
     if (defined('CLOSETASK')) {
         return false;
     }
     extract($this->info);
     /** 分时计划任务 **/
     $file = new file();
     $db = new db();
     $str = new str();
     $time = time();
     $today = $str->formatDate($time, 'Ymd');
     for ($i_task = 1; $i_task <= 6; $i_task++) {
         if ($time - intval(kc_config('task.update' . $i_task)) > 3600 * $i_task) {
             $tasks = $file->getDir('task/' . $i_task . '/', 'php');
             if (!empty($tasks)) {
                 foreach ($tasks as $k => $v) {
                     require ROOT . $k;
                 }
             }
             unset($tasks);
             $db->update('%s_config', array('value' => $time), "class='task' and name='update{$i_task}'");
         }
     }
     //开始执行每日计划任务
     if (kc_config('task.day') != $today) {
         $tasks = $file->getDir('task/day/', 'php');
         if (!empty($tasks)) {
             foreach ($tasks as $k => $v) {
                 require ROOT . $k;
             }
         }
         unset($tasks);
         $db->update('%s_config', array('value' => $today), "class='task' and name='day'");
     }
     //刷新即可执行
     $tasks = $file->getDir('task/0/', 'php');
     if (!empty($tasks)) {
         foreach ($tasks as $k => $v) {
             require ROOT . $k;
         }
     }
 }
Esempio n. 6
0
 /**
  * Adding new files from Request in begin of uploading
  *
  * @param file $files   
  */
 public function addNewFromFiles($files)
 {
     $file = $files->get('file');
     $fileFullName = $file->getClientOriginalName();
     $this->status = self::STATUS_NEW;
     $this->fullname = $fileFullName;
     $fileParts = explode(".", $fileFullName);
     $this->ext = end($fileParts);
     $this->name = str_replace('.' . $this->ext, '', $fileFullName);
     $this->created = time();
     $this->mime = $file->getMimeType();
     $this->size = $file->getSize();
     $this->save();
     return $this;
 }
Esempio n. 7
0
 public static function getSampleCode($assignment_id, $code_id = null)
 {
     $path = dirname(dirname(dirname(__FILE__))) . "/files/sample_code/" . $assignment_id . "/";
     if (is_null($code_id)) {
         $files = file::dirContent();
     }
 }
Esempio n. 8
0
 public static function get_instance()
 {
     if (self::$instance == null) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Esempio n. 9
0
 public function getUnInstalled()
 {
     $installed = (array) $this->getInstalled();
     $folders = dir::folders(ZPATH_MODULES, '.', false);
     $folders = array_diff($folders, array_keys($installed));
     $modules = array();
     foreach ($folders as $folder) {
         $modulePath = ZPATH_MODULES . DS . $folder;
         $moduleUrl = url::modules() . '/' . $folder;
         $moduleFile = $modulePath . DS . 'module.php';
         if (file::exists($moduleFile)) {
             $m = (include $moduleFile);
             $m['path'] = '$modules/' . $folder;
             $m['url'] = '$modules/' . $folder;
             if (!isset($m['icon'])) {
                 if (!file::exists($modulePath . '/icon.png')) {
                     $m['icon'] = url::theme() . '/image/skin/none.png';
                 } else {
                     $m['icon'] = $moduleUrl . '/icon.png';
                 }
             }
             $modules[$m['id']] = $m;
         }
     }
     return $modules;
 }
Esempio n. 10
0
function eqphp_autoload($class)
{
    if (isset($_SERVER['REQUEST_URI'])) {
        $root = current(explode('/', trim($_SERVER['REQUEST_URI'], '/')));
    }
    //optimize: $config save memcache or redis
    $group = config('group.list');
    $path = isset($root) && is_array($group) && in_array($root, $group) ? $root . '/' : '';
    $module = array('a' => $path . 'action', 'm' => $path . 'model', 'p' => $path . 'plugin', 's' => 'server');
    $prefix = substr($class, 0, strpos($class, '_'));
    $dir_name = in_array($prefix, array('a', 'm', 's', 'p')) ? $module[$prefix] : 'class';
    $execute_file = $dir_name . '/' . $class . '.php';
    if (file_exists($execute_file)) {
        return include PATH_ROOT . $execute_file;
    }
    //通用加载
    if (config('state.common_load') && in_array($prefix, array('a', 'm'), true)) {
        $common_option = array('a' => 'action/', 'm' => 'model/');
        $execute_file = PATH_ROOT . $common_option[$prefix] . $class . '.php';
        if (file_exists($execute_file)) {
            return include $execute_file;
        }
    }
    //贪婪加载
    if (config('state.greedy_load')) {
        $execute_file = file::search(PATH_ROOT . $dir_name, $class, $file_list, true);
        if ($execute_file) {
            return include $execute_file;
        }
    }
    if ($prefix === 'a') {
        logger::notice('class [' . $class . '] not found');
        http::send(404);
    }
}
 /**
  *
  * @static
  * @param string $filename
  * @return bool
  */
 public static function CheckTemplate($filename = "")
 {
     try {
         if (empty($filename)) {
             $objTemplate = new file(THEME_PREFIX . Settings::$page_templates_path . self::$template);
             return $objTemplate->Exists();
         } else {
             $objTemplate = new file(THEME_PREFIX . Settings::$page_templates_path . $filename);
             return $objTemplate->Exists();
         }
     } catch (Exception $e) {
         Debug::Log($e, ERROR);
         return false;
     }
     return true;
 }
Esempio n. 12
0
	protected function execTinyMce($prm=null) {
		$search = 'js/tiny_mce/';
		$request = request::get('request');
		$pos = strpos($request, $search);
		if ($pos === false)
			exit;
		$tmp = substr($request, $pos+strlen($search));
		$file = file::nyroExists(array(
			'name'=>'lib'.DS.'tinyMce'.DS.$tmp,
			'realName'=>true,
			'type'=>'other'
		));
		if (strpos($file, '.php') !== false) {
			array_walk($_GET, create_function('&$v', '$v = urldecode($v);'));
			$path = str_replace($tmp, '', $file);
			ini_set('include_path', $path);
			define('TINYMCEPATH', substr($path, 0, -1));
			define('TINYMCECACHEPATH', substr(TMPROOT, 0, -1));
			if (ob_get_length())
				ob_clean();
			include($file);
			exit;
		} else
			response::getInstance()->showFile($file);
	}
Esempio n. 13
0
 function get_file_list($dir, $attimg)
 {
     $imgname['size'] = 0;
     foreach ($dir as $filedirs) {
         $filedir = HDWIKI_ROOT . '/' . $filedirs;
         file::forcemkdir($filedir);
         $handle = opendir($filedir);
         $i = 0;
         while ($filename = readdir($handle)) {
             if (!is_dir($filedir . '/' . $filename) && '.' != $filename && '..' != $filename && '.svn' != $filename && 'index.htm' != $filename) {
                 $fstr = explode(".", $filename);
                 $flast = substr(strrchr($fstr[0], '_'), 1);
                 if (!in_array($filedirs . '/' . $filename, $attimg)) {
                     //if !in_array($filedirs.'/'.$filename,$attimg) && $flast!='140' && $flast!="s"
                     $i++;
                     $imgname[] = $filedirs . '/' . $filename;
                     $imgname['size'] += filesize($filedir . '/' . $filename);
                 }
             }
         }
         $imgname['num'] = $i;
         closedir($handle);
     }
     return $imgname;
 }
 /**
  * get full information for an upload
  *
  * @param string $file 
  * @param array $file_data 
  * @return array
  * @author Andy Bennett
  */
 function get_upload_data($file, $file_data)
 {
     $filename = self::save($file);
     if (APPENV == 'frontend') {
         $upl_dir = str_replace('frontend', 'backend', Kohana::config('upload.directory'));
         if (!copy($filename, $upl_dir . basename($filename))) {
             Kohana::log('error', "COPY FAILED: copy({$filename}, {$upl_dir}.basename({$filename}))");
         }
     }
     $pp = pathinfo($filename);
     $ext = $pp['extension'];
     $file_type = self::check_filetype($file_data['type'], $filename);
     $d = Kohana::config('upload.directory');
     $upload_data['file_name'] = $pp['basename'];
     $upload_data['file_type'] = $file_type;
     $upload_data['file_path'] = $d;
     $upload_data['full_path'] = $filename;
     $upload_data['raw_name'] = $pp['filename'];
     $upload_data['orig_name'] = $file_data['name'];
     $upload_data['file_ext'] = '.' . strtolower($ext);
     $upload_data['file_size'] = $file_data['size'];
     $upload_data['is_image'] = file::is_image($file_type);
     $upload_data['date_added'] = date('Y-m-d H:i:s');
     if ($upload_data['is_image']) {
         $properties = file::get_image_properties($filename);
         if (!empty($properties)) {
             $upload_data = array_merge($upload_data, $properties);
         }
     }
     return $upload_data;
 }
Esempio n. 15
0
 public function install($path)
 {
     $module = @(include path::decode($path . DS . 'module.php'));
     if (is_array($module)) {
         $module['path'] = $path;
         $module['url'] = $path;
         if (!isset($module['icon'])) {
             if (file::exists($path . '/icon.png')) {
                 $module['icon'] = $module['url'] . '/icon.png';
             }
         }
         $module['type'] = empty($module['type']) ? 'plugin' : $module['type'];
         $module['status'] = 0;
         $module['order'] = $this->max('order') + 1;
         $module['installtime'] = TIME;
         $module['updatetime'] = TIME;
         $insert = $this->insert($module);
     }
     if ($insert) {
         $driver = $this->db()->config('driver');
         $sqls = file::read($path . DS . 'install' . DS . $driver . '.sql');
         if ($sqls) {
             $this->db()->run($sqls);
         }
     }
     return true;
 }
Esempio n. 16
0
 /**
 * start upload
 +-----------------------------------------
 * @access public
 * @param string $path
 * @return void
 */
 public function save($path = '/', $web_path = '')
 {
     // check dir
     if (!is_dir($path)) {
         $this->error = 2404;
         return false;
     } else {
         if (!file::_is_writable($path)) {
             $this->error = 2655;
             return false;
         }
     }
     $files_rs = array();
     $this->save_path = $path;
     $this->web_path = $web_path;
     $this->file_upload_count = 0;
     foreach ($_FILES as $name => $file) {
         $files_rs[$name] = array();
         if (is_array($file['name'])) {
             $this->multiple($file['name'], $file['type'], $file['tmp_name'], $file['error'], $file['size'], $files_rs[$name]);
         } else {
             $files_rs[$name] = $this->_save($file);
         }
     }
     return $files_rs;
 }
Esempio n. 17
0
 /**
  * Imports Series from Opus3 to Opus4 in alphabetical order
  *
  * @param DOMDocument $data XML-Document to be imported
  * @return void
  */
 protected function importSeries($data)
 {
     $mf = $this->config->migration->mapping->series;
     $fp = null;
     $fp = @fopen($mf, 'w');
     if (!$fp) {
         $this->logger->log("Could not create '" . $mf . "' for Series", Zend_Log::ERR);
         return;
     }
     $series = $this->transferOpusSeries($data);
     $sort_order = 1;
     foreach ($series as $s) {
         if (array_key_exists('name', $s) === false) {
             continue;
         }
         if (array_key_exists('sr_id', $s) === false) {
             continue;
         }
         $sr = new Opus_Series();
         $sr->setTitle($s['name']);
         $sr->setVisible(1);
         $sr->setSortOrder($sort_order++);
         $sr->store();
         $this->logger->log("Series imported: " . $s['name'], Zend_Log::DEBUG);
         fputs($fp, $s['sr_id'] . ' ' . $sr->getId() . "\n");
     }
     fclose($fp);
 }
 public function test_restful_can_be_any_argument()
 {
     $this->generate->controller(array('admin', 'restful', 'index:post'));
     $contents = file::get(self::$controller);
     $this->assertContains('public $restful = true', $contents);
     $this->assertContains('post_index', $contents);
 }
Esempio n. 19
0
 static function get_version()
 {
     if (file::get_folder_path('framework') === false) {
         return;
     }
     return @file_get_contents(get_file('framework', 'VERSION')->get_path());
 }
Esempio n. 20
0
 function __construct($array)
 {
     parent::__construct($array);
     $vars = self::fetch($this->root);
     foreach ($vars as $key => $var) {
         $this->_['variables'][$key] = $var;
     }
 }
Esempio n. 21
0
 public function response($call, $data, $c)
 {
     $data = $this->cleanData($data);
     $filename = time() . '-' . $call . '-response-' . $c . '.xml';
     $path = $this->path . $filename;
     parent::fopen($path, 'a');
     parent::fwrite($data);
 }
Esempio n. 22
0
 function writecache($cachename, $arraydata)
 {
     $this->getfile($cachename);
     $data = is_array($arraydata) ? var_export($arraydata, true) : "'" . $arraydata . "'";
     $strdata = "<?php\nreturn " . $data . ";\n?>";
     $bytes = file::writetofile($this->cachefile, $strdata);
     return $bytes;
 }
Esempio n. 23
0
 public function get_write_path()
 {
     $folder_path = file::get_folder_path($this->folder);
     if ($folder_path === false) {
         common::error("Unknown folder ID: " . $this->folder);
     }
     $relative = $path[0] != '/' && strpos($path, ':') === false;
     return ($relative ? PATH_TO_ROOT_WRITE : '') . $folder_path . $this->name;
 }
Esempio n. 24
0
 function __construct()
 {
     $this->session = session::getInstance();
     $this->post = post::getInstance();
     $this->get = get::getInstance();
     $this->http = http::getInstance();
     $this->file = file::getInstance();
     $this->cookie = cookie::getInstance();
 }
 public function test_controllers_can_be_restful()
 {
     $this->generate->controller(array('admin', 'index', 'index:post', 'update:put', 'restful'));
     $contents = file::get(self::$controller);
     $this->assertContains('public $restful = true', $contents);
     $this->assertContains('get_index', $contents);
     $this->assertContains('post_index', $contents);
     $this->assertContains('put_update', $contents);
 }
Esempio n. 26
0
	/**
	 * Find the init file for a library
	 * ie: nyro/lib/$name/init.lib.php
	 *
	 * @param string $name The library name
	 * @return false|string The file path or false if not found
	 */
	public static function initFile($name) {
		if (!array_key_exists($name, self::$libFiles)) {
			self::$libFiles[$name] = file::nyroExists(array(
				'name'=>'lib_'.$name.'_init',
				'type'=>'lib'
			));
		}
		return self::$libFiles[$name];
	}
Esempio n. 27
0
 /**
  * Recursive version of php's native glob() method
  * 
  * @param int		the pattern passed to glob()
  * @param int		the flags passed to glob()
  * @param string	the path to scan
  * @return mixed	an array of files in the given path matching the pattern.
  */
 public static function rglob($pattern = '*', $flags = 0, $path = '')
 {
     $paths = glob($path . '*', GLOB_MARK | GLOB_ONLYDIR | GLOB_NOSORT);
     $files = glob($path . $pattern, $flags);
     foreach ($paths as $path) {
         $files = array_merge($files, file::rglob($pattern, $flags, $path));
     }
     return $files;
 }
Esempio n. 28
0
 public static function compile($files)
 {
     $content = "<?php\n";
     foreach ($files as $file) {
         $content .= file::compile($file);
     }
     $content .= "\n?>";
     return $content;
 }
Esempio n. 29
0
 /**
  * Override base method.
  */
 public function save()
 {
     if (isset($this->file)) {
         $fileName = $this->entityId . '_' . $this->fieldId . '.' . $this->file->getClientOriginalExtension();
         $this->value = $fileName;
         $this->file->move(public_path() . config('asgard.dynamicfield.config.files-path'), $fileName);
     }
     parent::save();
 }
Esempio n. 30
0
 protected function uploadFile($value)
 {
     $uploadPressed = http_request::getString('upload');
     $fileExists = false;
     if ($value == "4d988458b51093c7ee3a4e1582b5fd9b" && $uploadPressed == 'Ladda upp') {
         $value = $imgStr = randomString();
         file::tempName($imgStr);
         $fileExists = true;
     }
     $uploadState = file::append($this->name, $this->mimes, $this->max, $this->dir, $value);
     if ($uploadPressed !== false && $uploadPressed == 'Ladda upp' && $uploadState === false) {
         $this->error = 'Filuppladdningen misslyckades: för stor fil eller bild av ej tillåtet format.';
         $this->value = sprintf('%s/%d.%s', $this->dir, 0, 'png');
         return false;
     }
     $removePressed = http_request::getString('remove');
     $doRemove = $removePressed !== false && in_array($removePressed, array('Ta bort Avatar', 'Ta bort Bild'));
     if ($uploadState !== false) {
         $bajs = fe($uploadState);
         $fileExists = true;
         $this->value = str_replace(ROOT . '/public/', '/', $uploadState);
         $this->uploaded = true;
         if (isset($_SESSION['fileTempName'])) {
             $_SESSION['fileTempName'] = basename($this->value);
         }
         foreach ($this->mimes as $fe) {
             $f = sprintf('%s/%s.%s', $this->dir, $value, $fe);
             if (file_exists($f) && $fe != $bajs) {
                 file::remove($f);
             }
         }
         if ($doRemove === true) {
             file::remove($uploadState);
         }
     } else {
         foreach ($this->mimes as $fe) {
             $f = sprintf('%s/%s.%s', $this->dir, $value, $fe);
             if (file_exists($f)) {
                 if ($doRemove === true) {
                     file::remove($f);
                 }
                 $fileExists = true;
                 $this->value = str_replace(ROOT . '/public/', '/', $f);
                 if (isset($_SESSION['fileTempName'])) {
                     $_SESSION['fileTempName'] = $this->value;
                 }
                 $this->uploaded = true;
                 break;
             }
         }
     }
     if ($fileExists === false) {
         $this->value = sprintf('%s/%d.%s', $this->dir, 0, 'png');
     }
     return $fileExists ? true : false;
 }