/**
  * @return void
  */
 public function execute()
 {
     if (is_null($this->file)) {
         throw new \Exception('ファイルを指定してください');
     }
     $this->file->create();
 }
	/**
	 * Constructs a new Debug-Object.
	 *
	 * The first parameter has to be the file name with extension, but without directory. The second
	 * parameter has to be a valid and existing directory path with trainling directory separator
	 * (make sure the directory is writable). Standard value for this paramteer is null. If the
	 * directory is null or invalid  "data/logs/" will be used. If the specified file doesn't exist
	 * it will created. If it is not possible to create a file a NonFatalException will be thrown.
	 *
	 * @param string File for saving the logdata
	 * @param string Valid Directory for saving the logfile or null (directory will be "data/logs/")
	 * @throws NonFatalException
	 */
	public function __construct($file, $dir = null) {
		if ($dir === null || is_dir($dir) === false) {
			$dir = 'data/logs/';
		}
		$this->file = new File($dir.basename($file));
		if ($this->file->create() === false) {
			throw new NonFatalException('Could not create log file "'.$this->file->relPath().'".');
		}
		if ($this->file->readable() === false || $this->file->writable() === false) {
			$this->file->setPermissions(666);
		}
		$this->logs = array();
		$this->benchmarks = array();
		$this->temp = array();
	}
Example #3
0
 function step2($data)
 {
     //eseguo lo script MySQL
     if (!$this->mySqlInstall()) {
         $this->validationErrors['script_db'] = 'Errore nella compilazione del database';
         return false;
     }
     //inserisco i dati di configurazione dell'utente admin
     App::import('model', 'User');
     $User = new User();
     $User->create(array('User' => array('first_name' => $data['admin_first_name'], 'last_name' => $data['admin_last_name'], 'username' => $data['admin_username'], 'password' => Security::hash($data['admin_pwd'], null, true), 'email' => $data['admin_email'], 'role' => 0, 'active' => 1)));
     if (!$User->save()) {
         return false;
     }
     //scrivo il file installed.txt nella directory config
     App::import('core', 'File');
     $installedFile = new File(APP . 'config' . DS . 'installed.txt');
     $installedFile->create();
     //imposto correttamente i permessi sulle directories per la produzione
     if (!$this->setFolderPermissions($this->writableDirsForInstall, '0755')) {
         return false;
     }
     if (!$this->setFolderPermissions($this->writableDirsForProduction, '0755')) {
         return false;
     }
     //tutto ok
     return true;
 }
 public function action_zip($articulo_id = null)
 {
     is_null($articulo_id) and Response::redirect('diagramador');
     $articulos = Model_Articulo::find('all', array('related' => array('fotos', 'seccion'), 'where' => array(array('id', '=', $articulo_id))));
     $files_to_zip = array();
     $archivo_informacion = '';
     foreach ($articulos as $articulo) {
         $archivo_informacion .= "Nombre del Articulo: " . $articulo->nombre . "\n";
         $archivo_informacion .= "Seccion del Articulo: " . $articulo->seccion->descripcion . "\n";
         $archivo_informacion .= "Fecha del Articulo: " . date('Y-m-d H:i:s', $articulo->fecha_publicacion) . "\n";
         $archivo_informacion .= "\n ==========================\n";
         foreach ($articulo->fotos as $foto) {
             if ($foto->estado == 1) {
                 array_push($files_to_zip, $foto->imagen);
                 $nombre_archivo = str_ireplace(".jpg", "-" . $articulo->pagina->descripcion . ".jpg", $foto->imagen);
                 $pieces = explode("/", $nombre_archivo);
                 $count_foto = count($pieces);
                 $nombre_archivo = $pieces[$count_foto - 1];
                 $archivo_informacion .= $nombre_archivo . "\n" . "Medida: " . $foto->dimension->descipcion . "\n" . "Pagina: " . $articulo->pagina->descripcion . "\n ==========================\n";
             }
         }
     }
     $time = time();
     File::create(DOCROOT . "zip/", "info_{$articulo_id}_{$time}.txt", $archivo_informacion);
     array_push($files_to_zip, "/gr/public/zip/info_{$articulo_id}_{$time}.txt");
     Zip::create_zip($files_to_zip, $articulo_id, true, $time, $articulo->pagina->descripcion);
 }
Example #5
0
 /**
  * Create method for this handler
  *
  * @return array of assets created
  **/
 public function create()
 {
     // Set the asset type to video
     $this->asset['type'] = 'file';
     $this->asset['subtype'] = 'swf';
     // Call the primary create method on the file asset handler
     return parent::create();
 }
 /**
  * Finish install, set .installed file on
  * module path
  * 
  * @param string $module
  * @return boolean
  */
 public function finishInstall($module)
 {
     $modulePath = CLOGGY_PATH_MODULE . $module . DS;
     $modulePathInstalled = $modulePath . '.installed';
     $folder = new Folder();
     $folder->chmod($modulePath, 0755, true);
     $file = new File($modulePathInstalled);
     return $file->create();
 }
 /**
  * @return void
  */
 public function execute()
 {
     if (is_null($this->file)) {
         throw new \Exception('ファイルを指定してください');
     }
     $file = new File();
     $file->setPath('copy_of_' . $this->file->getPath());
     $file->create();
 }
 /**
  * Constructs a new Debug-Object.
  *
  * The first parameter has to be the file name with extension, but without directory.
  * Standard value is null, then the filename will be "internal.log".
  * The second parameter has to be a valid and existing directory with trailing slash.
  * Standard value is also null, then the directory will be "data/logs/" (make sure that it is writable).
  * If the specified file doesn't exist, it will created.
  * If it is not possible to create a file nn Exception will be thrown.
  *
  * @param string File for saving the logdata or null (filename is internal.log then)
  * @param string Directory for saving the logfile or null (directory is data/logs/ then)
  * @throws Exception
  */
 public function __construct($file = null, $dir = null)
 {
     if ($dir == null || is_dir($dir) == false) {
         $dir = 'data/logs/';
     }
     if ($file == null) {
         $file = 'internal.log';
     }
     $this->file = new File($dir . basename($file));
     if ($this->file->create() == false) {
         throw new Exception('Could not create log file in method Debug::__construct().');
     }
     if ($this->file->readable() == false || $this->file->writable() == false) {
         $writable = new CHMOD(666);
         $this->file->setChmod($writable);
     }
     $this->logs = array();
     $this->benchmarks = array();
     $this->temp = array();
 }
 public function downloadModule($fileUrl, $savePath, $unzip = 'no')
 {
     // self::uploadFromUrl($fileUrl,$savePath);
     $imgData = Http::getDataUrl($fileUrl);
     $fileName = basename($fileUrl);
     $fullPath = ROOT_PATH . $savePath . $fileName;
     File::create($fullPath, $imgData);
     if ($unzip != 'no') {
         self::unzipModule($fullPath, 'yes');
     }
 }
Example #10
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     if (!Auth::user()->can('create-audio')) {
         return view('errors.denied');
     }
     $file_hash = md5(Input::file('audio')->getClientOriginalName() . time());
     $file_details = ['name' => Input::file('audio')->getClientOriginalName(), 'title' => Input::get('title'), 'description' => Input::get('description'), 'file_hash' => $file_hash, 'extension' => Input::file('audio')->getClientOriginalExtension(), 'type' => 2];
     File::create($file_details);
     Input::file('audio')->move(base_path() . '/files/audio/', $file_hash . '.' . Input::file('audio')->getClientOriginalExtension());
     return view('audio.index');
 }
 public function edit()
 {
     if (!($match = Uri::match('\\/edit\\/(\\w+)'))) {
         Redirect::to(ADMINCP_URL);
     }
     $themeName = $match[1];
     $thePath = THEMES_PATH . $themeName . '/';
     if (!is_dir($thePath)) {
         Redirect::to(ADMINCP_URL);
     }
     $subPath = Request::get('path', '');
     if (preg_match('/\\.\\./i', $subPath)) {
         // Alert::make('You can not do this action.');
         $subPath = dirname($subPath);
     }
     $thePath .= $subPath;
     $queryPath = $thePath;
     $pageData = array();
     if (preg_match('/.*?\\.\\w+/i', $subPath)) {
         if (!preg_match('/(\\w+)\\/\\w+\\.\\w+/i', $subPath, $match)) {
             $subPath = dirname($subPath);
         } else {
             $subPath = $match[1];
         }
         $pageData['file']['name'] = basename($queryPath);
         $pageData['file']['data'] = file_get_contents($queryPath);
         $queryPath = dirname($queryPath);
         if (Request::has('btnSave')) {
             $savePath = $queryPath . '/' . $pageData['file']['name'];
             $saveData = trim(Request::get('send.file_content', ''));
             File::create($savePath, $saveData);
             $pageData['file']['data'] = file_get_contents($savePath);
         }
     }
     $listFiles = Dir::all($queryPath);
     if (isset($listFiles[0]) == '.') {
         unset($listFiles[0]);
     }
     if (isset($listFiles[1]) == '..') {
         unset($listFiles[1]);
     }
     sort($listFiles);
     $pageData['listFiles'] = $listFiles;
     $pageData['themeName'] = $themeName;
     $pageData['themePath'] = THEMES_PATH . $themeName . '/';
     $pageData['thisPath'] = $queryPath;
     $pageData['subPath'] = $subPath . '/';
     // print_r($pageData['listFiles']);die();
     System::setTitle('Edit theme ' . $themeName . ' - ' . ADMINCP_TITLE);
     View::make('admincp/head', array());
     self::makeContents('themeEdit', $pageData);
     View::make('admincp/footer');
 }
Example #12
0
function settingProcess()
{
    $alert = '<div class="alert alert-warning">Error. Check information again, pls!</div>';
    $valid = Validator::make(array('send.email' => 'email|slashes', 'send.secret' => 'slashes', 'send.order_status' => 'slashes', 'send.pending_status' => 'slashes', 'send.cancelled_status' => 'slashes', 'send.failed_status' => 'slashes', 'send.chargeback_status' => 'slashes'));
    if (!$valid) {
        return $alert;
    }
    $saveData = json_encode(Request::get('send'));
    File::create(PAYMENTMETHOD_PATH . 'setting.json', $saveData);
    $alert = '<div class="alert alert-success">Completed. Save changes success!</div>';
    return $alert;
}
Example #13
0
File: Log.php Project: schpill/thin
 /**
  * Write a message to the log file.
  *
  * <code>
  *      // Write an "error" message to the log file
  *      Log::write('error', 'Something went horribly wrong!');
  *
  *      // Write an "error" message using the class' magic method
  *      Log::error('Something went horribly wrong!');
  *
  *      // Log an arrays data
  *      Log::write('info', array('name' => 'Sawny', 'passwd' => '1234', array(1337, 21, 0)), true);
  *      //Result: Array ( [name] => Sawny [passwd] => 1234 [0] => Array ( [0] => 1337 [1] => 21 [2] => 0 ) )
  *      //If we had omit the third parameter the result had been: Array
  * </code>
  *
  * @param  string  $type
  * @param  string  $message
  * @return void
  */
 public static function write($type, $message, $prettyPrint = false)
 {
     if (!isset(static::$_logFile)) {
         static::$_logFile = LOGS_PATH . DS . date('Y-m-d') . '.log';
     }
     if (!File::exists(static::$_logFile)) {
         File::create(static::$_logFile);
     }
     $message = false !== $prettyPrint ? print_r($message, true) : $message;
     $message = static::format($type, $message);
     File::append(static::$_logFile, $message);
 }
Example #14
0
function w_serverlog($server, $log)
{
    $logfile = TMP . "server/" . $server . ".log";
    $file = new File($logfile);
    if ($file->exists()) {
        $file->append('
[' . date('Y-m-d H:i:s') . '] ' . $log);
    } else {
        $file->create();
        $file->append('[' . date('Y-m-d H:i:s') . '] ' . $log);
    }
}
Example #15
0
function detect_update_system()
{
    $loadData = Update::get();
    $encodeData = serialize($loadData);
    $md5Data = md5($encodeData);
    $path = CACHES_PATH . 'dbcache/plugin/autoupdate/';
    $filePath = $path . $md5Data . '.cache';
    if (!file_exists($filePath)) {
        Update::make();
        File::create($filePath, 'ok');
    }
}
Example #16
0
 function create($name, $iso, $flag = '')
 {
     if (empty($name) || empty($iso)) {
         return false;
     }
     $iso = strtolower($iso);
     $dir = APP_DIR . DS . App::getAppName() . DS . APP_LOCALE . DS . $iso . DS;
     File::mkdir($dir);
     $file = new File($dir . $iso . '.locale.php', true);
     $file->write('<?php' . PHP_EOL . 'return array();');
     $file->create($dir . 'config.php');
     self::setConfig($iso, array('name' => $name, 'iso' => $iso, 'flag' => str_replace('.png', '', $flag), 'default' => false));
 }
Example #17
0
 public function actionAccountMemberEditAccount($account_id = '', $args = '')
 {
     $testmod_path = \Module::exists('testmod');
     $log_file_name = 'member-edit-account.txt';
     $log_file_path = $testmod_path . $log_file_name;
     // delete if exists.
     if (\File::exists($log_file_path) && !is_writable($log_file_path)) {
         return false;
     } elseif (\File::exists($log_file_path) && is_writable($log_file_path)) {
         \File::delete($log_file_path);
     }
     \File::create($testmod_path, $log_file_name, 'Member has edit to made changed their account. Account id = ' . $account_id . '. Arguments = ' . json_encode($args));
     return true;
 }
Example #18
0
 /**
  * manage and execute queues
  *
  */
 public function run()
 {
     // check pids
     if (\Config::get('queue.queue_parallel_number') <= count(glob(\APPPATH . 'tmp/' . \Config::get('queue.queue_pid_prefix') . '_*.pid'))) {
         \Log::debug('queue limit over.');
         return;
     }
     $this->__process_file_name = \Config::get('queue.queue_pid_prefix') . '_' . getmypid() . '.pid';
     // create pid file
     \File::create(\APPPATH . 'tmp', $this->__process_file_name);
     try {
         // check dead queues
         $recover = \Model_TaskQueue::recover_zombie_queues();
         if (!empty($recover)) {
             \Model_TaskQueue::notify('zombie task recovered. ids = ' . implode(',', $recover));
         }
         // check queues
         $queue = \Model_TaskQueue::pickup();
         if (empty($queue)) {
             return;
         }
         // exec queue
         call_user_func_array('\\' . $queue['method'], \Format::forge($queue['options'], 'json')->to_array());
         // finish (update to success) queue
         \Model_TaskQueue::finish($queue['id'], \Model_TaskQueue::STATUS_SUCCESS);
     } catch (\Exception $e) {
         if (\DB::in_transaction()) {
             \DB::rollback_transaction();
         }
         if (isset($queue) and !empty($queue)) {
             // finish (update to error) queue
             \Model_TaskQueue::finish($queue['id'], \Model_TaskQueue::STATUS_ERROR);
             // send to notify method
             $body = array();
             $body[] = 'task queue error occured.';
             $body[] = '--------------------------------';
             $body[] = 'id: ' . $queue['id'];
             $body[] = 'method: ' . $queue['method'];
             $body[] = 'options: ' . $queue['options'];
             if (is_array($e->getMessage())) {
                 $body[] = 'reason: ' . implode(' ', $e->getMessage());
             } elseif (!empty($e->getMessage())) {
                 $body[] = 'reason: ' . $e->getMessage();
             }
             \Model_TaskQueue::notify($body);
         }
     } finally {
         \File::delete(\APPPATH . 'tmp/' . $this->__process_file_name);
     }
 }
Example #19
0
 public function __construct($db, $table)
 {
     $dir = Config::get('mlite.dir.' . $db, STORAGE_PATH . DS . $db . '.db');
     $new = !is_file($dir);
     if (!is_file($dir)) {
         File::create($dir);
     }
     $this->db = new SQLite3($dir);
     if ($new) {
         $q = "CREATE TABLE infosdb (data_key VARCHAR PRIMARY KEY, data_value);";
         $this->db->exec($q);
     }
     $this->table = $table;
     $this->database = $db;
 }
Example #20
0
 public function action_upload_image()
 {
     try {
         //throw new Exception("");
         $id = Input::post("id");
         $image = Input::post("image");
         $fileName = $id . "_" . System::ymdhism() . ".png";
         $res = File::create(APPPATH . "../../report/tmp/", $fileName, base64_decode(str_replace(' ', '+', $image)));
         if (!$res) {
             throw new FileException("画像の保存に失敗しました");
         }
         $this->response($fileName);
     } catch (Exception $e) {
         $this->error($e);
     }
 }
Example #21
0
 public function add()
 {
     $path = $_POST['path'];
     $folder = $_POST['folder'];
     include_once ROOT . DS . 'includes' . DS . 'file.php';
     $file = new File();
     $this->root = dirname(ROOT);
     $path = $this->root . DS . $path . DS . $folder;
     $path = str_replace('/', DS, $path);
     $check = $file->create($path, 0755);
     if ($check == false) {
         echo lang('media_exists');
     } else {
         echo 1;
     }
     exit;
 }
 /**
  * Main
  *
  * @return void
  * @access public
  */
 public function main()
 {
     $contents = $this->Content->find('all', array('conditions' => array('Content.status' => array('archived', 'published')), 'contain' => array('Sitemap'), 'fields' => array('Content.canonical', 'Content.modified', 'Sitemap.changefreq', 'Sitemap.priority')));
     $xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
     $xml .= "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">";
     foreach ($contents as $content) {
         $xml .= "<url>";
         $xml .= "<loc>" . htmlspecialchars($content['Content']['canonical'], ENT_QUOTES) . "</loc>";
         $xml .= "<lastmod>" . htmlspecialchars(date('Y-m-d', strtotime($content['Content']['modified'])), ENT_QUOTES) . "</lastmod>";
         $xml .= "<changefreq>" . htmlspecialchars($content['Sitemap']['changefreq'], ENT_QUOTES) . "</changefreq>";
         $xml .= "<priority>" . htmlspecialchars($content['Sitemap']['priority'], ENT_QUOTES) . "</priority>";
         $xml .= "</url>";
     }
     $xml .= "</urlset>";
     $file = new File(ROOT . DS . APP_DIR . DS . 'webroot' . DS . 'sitemap.xml', true, 0644);
     $file->create();
     $file->write($xml, $mode = 'w', false);
     $file->close();
 }
 /**
  * Test, if we can create a file.
  */
 function testCreateAndDelete()
 {
     // create a temporary file and just delete it again:
     $temp_path = $this->createUserFile();
     if (!$temp_path) {
         return;
     }
     unlink($temp_path);
     $temp_name = basename($temp_path);
     $File = new File('user', 1, $temp_name);
     $this->assertFalse($File->exists(), 'File does not exist.');
     $File->create();
     $this->assertTrue($File->exists(), 'File exists after create().');
     $this->assertTrue(file_exists($temp_path), 'File really exists.');
     if (file_exists($temp_path)) {
         $File->unlink();
         $this->assertFalse($File->exists(), 'File thinks it is unlinked.');
         $this->assertFalse(file_exists($temp_path), 'File is really unlinked.');
     }
 }
Example #24
0
 /**
  * Checks that directories are writeable
  *
  * Checks the 'plugin' prefix class variable
  * to ensure that the plugin path, and all
  * subpaths, are writeable by the system.
  *
  * Also ensures that templates are available for
  * all actions, plugins, etc
  *
  * @param CakeAdmin $admin
  * @return mixed boolean true if successful, string error message otherwise
  * @todo test me
  */
 function checkBuild($admin)
 {
     $this->handler();
     $this->handler->cd(APP);
     $contents = $this->handler->read();
     if (!in_array('plugins', $contents[0])) {
         return __("Missing Plugin directory", true);
     }
     $this->handler->cd(APP . 'plugins');
     $contents = $this->handler->read();
     $path = APP . 'plugins' . DS . $admin->plugin;
     // Recover if the required plugin directory is missing
     if (!in_array($admin->plugin, $contents[0])) {
         $this->handler->create($path);
     }
     $contents = $this->handler->read();
     if (!in_array($admin->plugin, $contents[0])) {
         return sprintf(__("Unable to create path: %s", true), $path);
     }
     // Check all the required MVC directories
     $required = array('controllers', 'models', 'views');
     $this->handler->cd($path);
     $content = $this->handler->read();
     foreach ($required as $directory) {
         if (!in_array($directory, $content[0])) {
             $this->handler->create($path . DS . $directory);
         }
         $content = $this->handler->read();
         if (!in_array($directory, $content[0])) {
             return sprintf(__('Missing directory: %s', true), $directory);
         }
     }
     // Check that the directories and files are writeable by shell
     foreach ($required as $directory) {
         if (!$this->handler->chmod($path . DS . $directory)) {
             return sprintf(__('Directory not writeable: %s', true), $directory);
         }
     }
     return true;
 }
Example #25
0
 public function __construct($viewFile = null)
 {
     if (null !== $viewFile) {
         $this->_module = 'www';
         if (strstr($viewFile, DS)) {
             $this->_viewFile = $viewFile;
         } else {
             $file = CACHE_PATH . DS . md5($this->_viewFile . time() . Utils::UUID()) . '.fake';
             File::create($file);
             $fp = fopen($file, 'a');
             fwrite($fp, '<?php echo $this->content; ?>');
             $this->_viewFile = $file;
         }
     } else {
         $route = Utils::get('appDispatch');
         /* polymorphism */
         $route = !$route instanceof Container ? container()->getRoute() : $route;
         $module = $route->getModule();
         $controller = $route->getController();
         $action = $route->getAction();
         $this->_module = $module;
         $isTranslate = Utils::get('isTranslate');
         if (true === $isTranslate) {
             $lng = getLanguage();
             if (true === container()->getMultiSite()) {
                 $this->_viewFile = APPLICATION_PATH . DS . SITE_NAME . DS . 'modules' . DS . $module . DS . 'views' . DS . 'scripts' . DS . Inflector::lower($controller) . DS . Inflector::lower($lng) . DS . Inflector::lower($action) . '.phtml';
             } else {
                 $this->_viewFile = APPLICATION_PATH . DS . 'modules' . DS . $module . DS . 'views' . DS . 'scripts' . DS . Inflector::lower($controller) . DS . Inflector::lower($lng) . DS . Inflector::lower($action) . '.phtml';
             }
         } else {
             if (true === container()->getMultiSite()) {
                 $this->_viewFile = APPLICATION_PATH . DS . SITE_NAME . DS . 'modules' . DS . $module . DS . 'views' . DS . 'scripts' . DS . Inflector::lower($controller) . DS . Inflector::lower($action) . '.phtml';
             } else {
                 $this->_viewFile = APPLICATION_PATH . DS . 'modules' . DS . $module . DS . 'views' . DS . 'scripts' . DS . Inflector::lower($controller) . DS . Inflector::lower($action) . '.phtml';
             }
         }
     }
     Utils::set('appView', $this);
     Utils::set('showStats', true);
 }
Example #26
0
 /**
  * Checks that directories are writeable
  *
  * Checks the 'plugin' prefix class variable
  * to ensure that the plugin path, and all
  * subpaths, are writeable by the system.
  *
  * Also ensures that templates are available for
  * all actions, plugins, etc
  *
  * @param CakeAdmin $admin
  * @return mixed boolean true if successful, string error message otherwise
  * @todo test me
  */
 public function _checkBuild($admin)
 {
     $this->_handler();
     $this->handler->cd(APP);
     $contents = $this->handler->read();
     if (!in_array('Plugin', $contents[0])) {
         return __("Missing Plugin directory");
     }
     $this->handler->cd(APP . 'Plugin');
     $contents = $this->handler->read();
     $path = APP . 'Plugin' . DS . Inflector::camelize($admin->plugin);
     // Recover if the required plugin directory is missing
     if (!in_array($admin->plugin, $contents[0])) {
         $this->handler->create($path);
     }
     $contents = $this->handler->read();
     if (!in_array(Inflector::camelize($admin->plugin), $contents[0])) {
         return __("Unable to create path: %s", $path);
     }
     // Check all the required MVC directories
     $required = array('Controller', 'Model', 'View');
     $this->handler->cd($path);
     $content = $this->handler->read();
     foreach ($required as $directory) {
         if (!in_array($directory, $content[0])) {
             $this->handler->create($path . DS . $directory);
         }
         $content = $this->handler->read();
         if (!in_array($directory, $content[0])) {
             return __('Missing directory: %s', $directory);
         }
     }
     // Check that the directories and files are writeable by shell
     foreach ($required as $directory) {
         if (!$this->handler->chmod($path . DS . $directory)) {
             return __('Directory not writeable: %s', $directory);
         }
     }
     return true;
 }
function addFile()
{
    $promo = params("promo");
    $rang = params("rang");
    $libelle = params("libelle");
    if (!(isset($_FILES["document"]) && $_FILES["document"]["error"] == 0)) {
        set("status", false);
        set("file", $_FILES["document"]["name"]);
        return render("files/statusUploadFile.html.php");
    }
    if ($promo == "-1") {
        $promo = "";
    }
    $file = new File();
    $file->setPromo($promo);
    $file->setRang($rang);
    $file->setLibelle($libelle);
    $file->setFichier($_FILES["document"]["tmp_name"]);
    $file->setFichierOK($_FILES["document"]["name"]);
    $status = $file->create();
    set("status", $status);
    set("file", $_FILES["document"]["name"]);
    return render("files/statusUploadFile.html.php");
}
Example #28
0
 /**
  * testDirSize method
  *
  * @return void
  */
 public function testDirSize()
 {
     $Folder = new Folder(TMP . 'config_non_existent', true);
     $this->assertEquals(0, $Folder->dirSize());
     $File = new File($Folder->pwd() . DS . 'my.php', true, 0777);
     $File->create();
     $File->write('something here');
     $File->close();
     $this->assertEquals(14, $Folder->dirSize());
     $Folder->cd(TMP);
     $Folder->delete($Folder->pwd() . 'config_non_existent');
 }
 /**
  * Utility method to create a {@link FileSecured} object and save to the test DB.
  * 
  * @param string $can
  * @param string $type
  * @param array $props
  * @return File
  */
 private function createSecuredFile($can = null, $type = null, $props = array())
 {
     $file = File::create();
     $file->Secured = true;
     if ($can && $type) {
         $file->{$can} = $type;
     }
     foreach ($props as $prop => $val) {
         $file->{$prop} = $val;
     }
     $file->write();
     return $file;
 }
Example #30
0
 public static function saveCache()
 {
     $themePath = System::getThemePath();
     $filePath = $themePath . 'widgets.php';
     $fileHash = md5_file($filePath);
     if (!file_exists($themePath . $fileHash . '.cache')) {
         File::create($themePath . $fileHash . '.cache', serialize(self::$widgetData));
     }
 }