/**
  * Save an uploaded file to a new location.
  *
  * @param   mixed    name of $_FILE input or array of upload data
  * @param   string   new filename
  * @param   string   new directory
  * @param   integer  chmod mask
  * @return  string   full path to new file
  */
 public static function save($file, $filename = NULL, $directory = NULL, $chmod = 0755)
 {
     // Load file data from FILES if not passed as array
     $file = is_array($file) ? $file : $_FILES[$file];
     if ($filename === NULL) {
         // Use the default filename, with a timestamp pre-pended
         $filename = time() . $file['name'];
     }
     // Remove spaces from the filename
     $filename = preg_replace('/\\s+/', '_', $filename);
     if ($directory === NULL) {
         // Use the pre-configured upload directory
         $directory = WWW_ROOT . 'files/';
     }
     // Make sure the directory ends with a slash
     $directory = rtrim($directory, '/') . '/';
     if (!is_dir($directory)) {
         // Create the upload directory
         mkdir($directory, 0777, TRUE);
     }
     //if ( ! is_writable($directory))
     //throw new exception;
     if (is_uploaded_file($file['tmp_name']) and move_uploaded_file($file['tmp_name'], $filename = $directory . $filename)) {
         if ($chmod !== FALSE) {
             // Set permissions on filename
             chmod($filename, $chmod);
         }
         //$all_file_name = array(FILE_INFO => $filename);
         // Return new file path
         return $filename;
     }
     return FALSE;
 }
    /**
     * {@inheritdoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $class_name = ltrim($input->getArgument('class_name'), '\\');
        $namespace_root = $input->getArgument('namespace_root_path');
        $match = [];
        preg_match('/([a-zA-Z0-9_]+\\\\[a-zA-Z0-9_]+)\\\\(.+)/', $class_name, $match);
        if ($match) {
            $root_namespace = $match[1];
            $rest_fqcn = $match[2];
            $proxy_filename = $namespace_root . '/ProxyClass/' . str_replace('\\', '/', $rest_fqcn) . '.php';
            $proxy_class_name = $root_namespace . '\\ProxyClass\\' . $rest_fqcn;
            $proxy_class_string = $this->proxyBuilder->build($class_name);
            $file_string = <<<EOF
<?php
// @codingStandardsIgnoreFile

/**
 * This file was generated via php core/scripts/generate-proxy-class.php '{$class_name}' "{$namespace_root}".
 */
{{ proxy_class_string }}
EOF;
            $file_string = str_replace(['{{ proxy_class_name }}', '{{ proxy_class_string }}'], [$proxy_class_name, $proxy_class_string], $file_string);
            mkdir(dirname($proxy_filename), 0775, TRUE);
            file_put_contents($proxy_filename, $file_string);
            $output->writeln(sprintf('Proxy of class %s written to %s', $class_name, $proxy_filename));
        }
    }
 function __construct($name)
 {
     $this->folder = TEMP_FOLDER . '/' . $name;
     if (!is_dir($this->folder)) {
         mkdir($this->folder);
     }
 }
 /**
  * Initializes this logger.
  *
  * Available options:
  *
  * - file:        The file path or a php wrapper to log messages
  *                You can use any support php wrapper. To write logs to the Apache error log, use php://stderr
  * - format:      The log line format (default to %time% %type% [%priority%] %message%%EOL%)
  * - time_format: The log time strftime format (default to %b %d %H:%M:%S)
  * - dir_mode:    The mode to use when creating a directory (default to 0777)
  * - file_mode:   The mode to use when creating a file (default to 0666)
  *
  * @param  sfEventDispatcher $dispatcher  A sfEventDispatcher instance
  * @param  array             $options     An array of options.
  *
  * @return Boolean      true, if initialization completes successfully, otherwise false.
  */
 public function initialize(sfEventDispatcher $dispatcher, $options = array())
 {
     if (!isset($options['file'])) {
         throw new sfConfigurationException('You must provide a "file" parameter for this logger.');
     }
     if (isset($options['format'])) {
         $this->format = $options['format'];
     }
     if (isset($options['time_format'])) {
         $this->timeFormat = $options['time_format'];
     }
     if (isset($options['type'])) {
         $this->type = $options['type'];
     }
     $dir = dirname($options['file']);
     if (!is_dir($dir)) {
         mkdir($dir, isset($options['dir_mode']) ? $options['dir_mode'] : 0777, true);
     }
     $fileExists = file_exists($options['file']);
     if (!is_writable($dir) || $fileExists && !is_writable($options['file'])) {
         throw new sfFileException(sprintf('Unable to open the log file "%s" for writing.', $options['file']));
     }
     $this->fp = fopen($options['file'], 'a');
     if (!$fileExists) {
         chmod($options['file'], isset($options['file_mode']) ? $options['file_mode'] : 0666);
     }
     return parent::initialize($dispatcher, $options);
 }
 function check_for_directory()
 {
     if (!file_exists($this->directory_name)) {
         mkdir($this->directory_name, 0777);
     }
     @chmod($this->directory_name, 0777);
 }
Exemple #6
1
 function __construct(array $config = array())
 {
     $this->_config =& $config;
     // Try to locate app folder.
     if (!isset($config['app_dir'])) {
         $cwd = getcwd();
         while (!is_dir("{$cwd}/app")) {
             if ($cwd == dirname($cwd)) {
                 throw new \LogicException('/app folder not found.');
             }
             $cwd = dirname($cwd);
         }
         $config['app_dir'] = "{$cwd}/app";
     }
     $is_web_request = isset($_SERVER['SERVER_NAME']);
     $config += array('debug' => !$is_web_request || $_SERVER['SERVER_NAME'] == 'localhost', 'register_exception_handler' => $is_web_request, 'register_error_handler' => $is_web_request, 'core_dir' => __DIR__ . '/../..', 'data_dir' => "{$config['app_dir']}/../data");
     $this->exception_handler = new ExceptionHandler($this->debug);
     if ($this->register_exception_handler) {
         set_exception_handler(array($this->exception_handler, 'handle'));
     }
     if ($this->register_error_handler) {
         $this->errorHandler = \Symfony\Component\HttpKernel\Debug\ErrorHandler::register();
     }
     foreach (array($config['data_dir'], "{$config['data_dir']}/cache", "{$config['data_dir']}/logs") as $dir) {
         if (!is_dir($dir)) {
             mkdir($dir);
         }
     }
 }
Exemple #7
1
 public static function prepare_dir($prefix)
 {
     $config = midcom_baseclasses_components_configuration::get('midcom.helper.filesync', 'config');
     $path = $config->get('filesync_path');
     if (!file_exists($path)) {
         $parent = dirname($path);
         if (!is_writable($parent)) {
             throw new midcom_error("Directory {$parent} is not writable");
         }
         if (!mkdir($path)) {
             throw new midcom_error("Failed to create directory {$path}. Reason: " . $php_errormsg);
         }
     }
     if (substr($path, -1) != '/') {
         $path .= '/';
     }
     $module_dir = "{$path}{$prefix}";
     if (!file_exists($module_dir)) {
         if (!is_writable($path)) {
             throw new midcom_error("Directory {$path} is not writable");
         }
         if (!mkdir($module_dir)) {
             throw new midcom_error("Failed to create directory {$module_dir}. Reason: " . $php_errormsg);
         }
     }
     return "{$module_dir}/";
 }
Exemple #8
1
 protected function createPath()
 {
     $fullPath = dirname($this->fullFilePath());
     if (!is_dir($fullPath)) {
         mkdir($fullPath, 0755, true);
     }
 }
 protected function makeProjectDir($srcDir = null, $logsDir = null, $cloverXmlPaths = null, $logsDirUnwritable = false, $jsonPathUnwritable = false)
 {
     if ($srcDir !== null && !is_dir($srcDir)) {
         mkdir($srcDir, 0777, true);
     }
     if ($logsDir !== null && !is_dir($logsDir)) {
         mkdir($logsDir, 0777, true);
     }
     if ($cloverXmlPaths !== null) {
         if (is_array($cloverXmlPaths)) {
             foreach ($cloverXmlPaths as $cloverXmlPath) {
                 touch($cloverXmlPath);
             }
         } else {
             touch($cloverXmlPaths);
         }
     }
     if ($logsDirUnwritable) {
         if (file_exists($logsDir)) {
             chmod($logsDir, 0577);
         }
     }
     if ($jsonPathUnwritable) {
         touch($this->jsonPath);
         chmod($this->jsonPath, 0577);
     }
 }
 public static function getUrlUploadMultiImages($obj, $user_id)
 {
     $url_arr = array();
     $min_size = 1024 * 1000 * 700;
     $max_size = 1024 * 1000 * 1000 * 3.5;
     foreach ($obj["tmp_name"] as $key => $tmp_name) {
         $ext_arr = array('png', 'jpg', 'jpeg', 'bmp');
         $name = StringHelper::filterString($obj['name'][$key]);
         $storeFolder = Yii::getPathOfAlias('webroot') . '/images/' . date('Y-m-d', time()) . '/' . $user_id . '/';
         $pathUrl = 'images/' . date('Y-m-d', time()) . '/' . $user_id . '/' . time() . $name;
         if (!file_exists($storeFolder)) {
             mkdir($storeFolder, 0777, true);
         }
         $tempFile = $obj['tmp_name'][$key];
         $targetFile = $storeFolder . time() . $name;
         $ext = strtolower(pathinfo($name, PATHINFO_EXTENSION));
         $size = $obj['name']['size'];
         if (in_array($ext, $ext_arr)) {
             if ($size >= $min_size && $size <= $max_size) {
                 if (move_uploaded_file($tempFile, $targetFile)) {
                     array_push($url_arr, $pathUrl);
                 } else {
                     return NULL;
                 }
             } else {
                 return NULL;
             }
         } else {
             return NULL;
         }
     }
     return $url_arr;
 }
Exemple #11
1
 public static function createSymbolicLink($rootDir = null)
 {
     IS_MULTI_MODULES || exit('please set is_multi_modules => true');
     $deper = Request::isCli() ? PHP_EOL : '<br />';
     echo "{$deper}**************************create link start!*********************{$deper}";
     echo '|' . str_pad('', 64, ' ', STR_PAD_BOTH) . '|';
     is_null($rootDir) && ($rootDir = ROOT_PATH . DIRECTORY_SEPARATOR . 'web');
     is_dir($rootDir) || mkdir($rootDir, true, 0700);
     //modules_static_path_name
     // 递归遍历目录
     $dirIterator = new \DirectoryIterator(APP_MODULES_PATH);
     foreach ($dirIterator as $file) {
         if (!$file->isDot() && $file->isDir()) {
             $resourceDir = $file->getPathName() . DIRECTORY_SEPARATOR . Config::get('modules_static_path_name');
             if (is_dir($resourceDir)) {
                 $distDir = ROOT_PATH . DIRECTORY_SEPARATOR . 'web' . DIRECTORY_SEPARATOR . $file->getFilename();
                 $cmd = Request::operatingSystem() ? "mklink /d {$distDir} {$resourceDir}" : "ln -s {$resourceDir} {$distDir}";
                 exec($cmd, $result);
                 $tip = "create link Application [{$file->getFilename()}] result : [" . (is_dir($distDir) ? 'true' : 'false') . "]";
                 $tip = str_pad($tip, 64, ' ', STR_PAD_BOTH);
                 print_r($deper . '|' . $tip . '|');
             }
         }
     }
     echo $deper . '|' . str_pad('', 64, ' ', STR_PAD_BOTH) . '|';
     echo "{$deper}****************************create link end!**********************{$deper}";
 }
Exemple #12
1
 public function __construct($moduleDir, $template, $cache = 2)
 {
     global $app;
     $theme = self::$theme;
     $this->_css = array();
     $this->_js = array('/includes/jquery/jquery.js');
     #~ Setup Debug mode & Template Caching
     $this->debugging = !Live;
     $this->caching = Live ? $cache : false;
     #~ Set the tpl file to display
     $this->_template = $template;
     #~ Set Theme directories
     $this->config_dir = DocRoot . $app->ConfPath;
     $this->template_dir = array(DocRoot . "/themes/{$theme}/templates/{$moduleDir}", DocRoot . "/modules/{$moduleDir}/templates");
     $this->plugins_dir[] = DocRoot . "/themes/{$theme}/plugins";
     #~ Set Writable Theme directories / Create if necessory
     $this->compile_dir = DocRoot . $app->ConfPath . "/tmp/{$theme}_c";
     $this->cache_dir = DocRoot . $app->ConfPath . "/tmp/{$theme}_cache";
     if (!is_dir($this->compile_dir)) {
         mkdir($this->compile_dir);
     }
     if (!is_dir($this->cache_dir)) {
         mkdir($this->cache_dir);
     }
     #~ Every Assignments, if any.
     $this->assign('BaseURL', BaseURL);
     $this->assign('BasePath', BasePath);
     $this->assign('Theme', BasePath . '/themes/' . $theme);
 }
 public function indexAction()
 {
     $container = $this->container;
     $conn = $this->get('doctrine')->getConnection();
     $dir = $container->getParameter('doctrine_migrations.dir_name');
     if (!file_exists($dir)) {
         mkdir($dir, 0777, true);
     }
     $configuration = new Configuration($conn);
     $configuration->setMigrationsNamespace($container->getParameter('doctrine_migrations.namespace'));
     $configuration->setMigrationsDirectory($dir);
     $configuration->registerMigrationsFromDirectory($dir);
     $configuration->setName($container->getParameter('doctrine_migrations.name'));
     $configuration->setMigrationsTableName($container->getParameter('doctrine_migrations.table_name'));
     $versions = $configuration->getMigrations();
     foreach ($versions as $version) {
         $migration = $version->getMigration();
         if ($migration instanceof ContainerAwareInterface) {
             $migration->setContainer($container);
         }
     }
     $migration = new Migration($configuration);
     $migrated = $migration->migrate();
     // ...
 }
 /**
  * @param  EntityMapping $modelMapping
  * @param  string        $namespace
  * @param  string        $path
  * @param  bool          $override
  * @return void
  */
 public function generate(EntityMapping $modelMapping, $namespace, $path, $override = false)
 {
     $abstractNamespace = $namespace . '\\Base';
     if (!is_dir($path)) {
         mkdir($path, 0777, true);
     }
     $abstractPath = $path . DIRECTORY_SEPARATOR . 'Base';
     if (!is_dir($abstractPath)) {
         mkdir($abstractPath, 0777, true);
     }
     $abstracClassName = 'Abstract' . $modelMapping->getName();
     $classPath = $path . DIRECTORY_SEPARATOR . $modelMapping->getName() . '.php';
     $abstractClassPath = $abstractPath . DIRECTORY_SEPARATOR . $abstracClassName . '.php';
     $nodes = array();
     $nodes = array_merge($nodes, $this->generatePropertyNodes($modelMapping));
     $nodes = array_merge($nodes, $this->generateConstructNodes($modelMapping));
     $nodes = array_merge($nodes, $this->generateMethodNodes($modelMapping));
     $nodes = array_merge($nodes, $this->generateMetadataNodes($modelMapping));
     $nodes = array(new Node\Stmt\Namespace_(new Name($abstractNamespace), array(new Class_('Abstract' . $modelMapping->getName(), array('type' => 16, 'stmts' => $nodes)))));
     $abstractClassCode = $this->phpGenerator->prettyPrint($nodes);
     file_put_contents($abstractClassPath, '<?php' . PHP_EOL . PHP_EOL . $abstractClassCode);
     if (file_exists($classPath) && !$override) {
         return;
     }
     $nodes = array(new Node\Stmt\Namespace_(new Name($namespace), array(new Class_($modelMapping->getName(), array('extends' => new FullyQualified($abstractNamespace . '\\' . $abstracClassName))))));
     $classCode = $this->phpGenerator->prettyPrint($nodes);
     file_put_contents($classPath, '<?php' . PHP_EOL . PHP_EOL . $classCode);
 }
 /**
  * Create a directory
  *
  * @param string $path
  * @param integer $permission
  * @throws \Application\Exception\ApplicationException
  * @return void
  */
 public static function createDir($path, $permission = self::DEFAULT_FOLDER_PERMISSIONS)
 {
     if (true !== ($result = mkdir($path, $permission, true))) {
         throw new ApplicationException('Failed to create directory - ' . $path);
     }
     @chmod($path, self::DEFAULT_FOLDER_PERMISSIONS);
 }
Exemple #16
0
 /**
  * Initialize the provider
  *
  * @return void
  */
 public function initialize()
 {
     $this->options = array_merge($this->defaultConfig, $this->options);
     date_default_timezone_set($this->options['log.timezone']);
     // Finally, create a formatter
     $formatter = new LineFormatter($this->options['log.outputformat'], $this->options['log.dateformat'], false);
     // Create a new directory
     $logPath = realpath($this->app->config('bono.base.path')) . '/' . $this->options['log.path'];
     if (!is_dir($logPath)) {
         mkdir($logPath, 0755);
     }
     // Create a handler
     $stream = new StreamHandler($logPath . '/' . date($this->options['log.fileformat']) . '.log');
     // Set our formatter
     $stream->setFormatter($formatter);
     // Create LogWriter
     $logger = new LogWriter(array('name' => $this->options['log.name'], 'handlers' => array($stream), 'processors' => array(new WebProcessor())));
     // Bind our logger to Bono Container
     $this->app->container->singleton('log', function ($c) {
         $log = new Log($c['logWriter']);
         $log->setEnabled($c['settings']['log.enabled']);
         $log->setLevel($c['settings']['log.level']);
         $env = $c['environment'];
         $env['slim.log'] = $log;
         return $log;
     });
     // Set the writer
     $this->app->config('log.writer', $logger);
 }
Exemple #17
0
 public function onEnable()
 {
     $this->getServer()->getPluginManager()->registerEvents($this, $this);
     if (!is_dir($this->getDataFolder())) {
         mkdir($this->getDataFolder());
     }
     if (!file_exists($this->getDataFolder() . "areas.json")) {
         file_put_contents($this->getDataFolder() . "areas.json", "[]");
     }
     if (!file_exists($this->getDataFolder() . "config.yml")) {
         $c = $this->getResource("config.yml");
         $o = stream_get_contents($c);
         fclose($c);
         file_put_contents($this->getDataFolder() . "config.yml", str_replace("DEFAULT", $this->getServer()->getDefaultLevel()->getName(), $o));
     }
     $this->areas = array();
     $data = json_decode(file_get_contents($this->getDataFolder() . "areas.json"), true);
     foreach ($data as $datum) {
         $area = new Area($datum["name"], $datum["flags"], $datum["pos1"], $datum["pos2"], $datum["level"], $datum["whitelist"], $this);
     }
     $c = yaml_parse(file_get_contents($this->getDataFolder() . "config.yml"));
     $this->god = $c["Default"]["God"];
     $this->edit = $c["Default"]["Edit"];
     $this->touch = $c["Default"]["Touch"];
     $this->levels = array();
     foreach ($c["Worlds"] as $level => $flags) {
         $this->levels[$level] = $flags;
     }
 }
 public function testPreDispatchNonWritableSkin()
 {
     mkdir(self::$_tmpMediaDir, 0777);
     $this->_runOptions['media_dir'] = self::$_tmpMediaDir;
     mkdir(self::$_tmpSkinDir, 0444);
     $this->_testInstallProhibitedWhenNonWritable(self::$_tmpSkinDir);
 }
 function __construct()
 {
     if (CREATE_LOG_FOLDER) {
         if (file_exists('/D') && is_dir('/D')) {
             if (!file_exists('/D/dune_plugin_logs/')) {
                 mkdir('/D/dune_plugin_logs/');
                 hd_print('log_dir created');
             }
         }
     }
     $this->vod = new EmplexerVod();
     $this->add_screen(new EmplexerSetupScreen());
     $this->add_screen(new EmplexerSectionScreen());
     $this->add_screen(new EmplexerRootList());
     $this->add_screen(new EmplexerSeasonList());
     $this->add_screen(new EmplexerVideoList());
     $this->add_screen(new EmplexerMovieList());
     // $this->add_screen(new EmplexerMovieDescriptionScreen());
     $this->add_screen(new VodMovieScreen($this->vod));
     $this->add_screen(new EmplexerBaseChannel());
     $this->add_screen(new EmplexerListVideo());
     $this->add_screen(new EmplexerSecondarySection());
     $this->add_screen(new EmplexerMusicList());
     //        $this->add_screen(new EmplexerSMBSetup());
     EmplexerFifoController::getInstance();
     // inicia o fifo
 }
Exemple #20
0
 function display($tpl = null)
 {
     $prod =& $this->get('Data');
     $isNew = $prod->id < 1;
     $text = $isNew ? JText::_("NEW") : JText::_("EDIT");
     JToolBarHelper::title(JText::_("PRODUCT") . ': <small><small>[ ' . $text . ' ]</small></small>', 'fst_prods');
     if (FST_Helper::Is16()) {
         JToolBarHelper::custom('translate', 'translate', 'translate', 'Translate', false);
         JToolBarHelper::spacer();
     }
     JToolBarHelper::save();
     if ($isNew) {
         JToolBarHelper::cancel();
     } else {
         // for existing items the button is renamed `close`
         JToolBarHelper::cancel('cancel', 'Close');
     }
     FSTAdminHelper::DoSubToolbar();
     $this->assignRef('prod', $prod);
     $path = JPATH_SITE . DS . 'images' . DS . 'fst' . DS . 'products';
     if (!file_exists($path)) {
         mkdir($path, 0777, true);
     }
     $files = JFolder::files($path, '(.png$|.jpg$|.jpeg$|.gif$)');
     $sections[] = JHTML::_('select.option', '', JText::_("NO_IMAGE"), 'id', 'title');
     foreach ($files as $file) {
         $sections[] = JHTML::_('select.option', $file, $file, 'id', 'title');
     }
     $lists['images'] = JHTML::_('select.genericlist', $sections, 'image', 'class="inputbox" size="1" ', 'id', 'title', $prod->image);
     $this->assignRef('lists', $lists);
     parent::display($tpl);
 }
function cuttingimg($zoom, $fn, $sz)
{
    @mkdir(WUO_ROOT . '/photos/maps');
    $img = imagecreatefrompng(WUO_ROOT . '/photos/maps/0-0-0-' . $fn);
    // получаем идентификатор загруженного изрбражения которое будем резать
    $info = getimagesize(WUO_ROOT . '/photos/maps/0-0-0-' . $fn);
    // получаем в массив информацию об изображении
    $w = $info[0];
    $h = $info[1];
    // ширина и высота исходного изображения
    $sx = round($w / $sz, 0);
    // длинна куска изображения
    $sy = round($h / $sz, 0);
    // высота куска изображения
    $px = 0;
    $py = 0;
    // координаты шага "реза"
    for ($y = 0; $y <= $sz; $y++) {
        for ($x = 0; $x <= $sz; $x++) {
            $imgcropped = imagecreatetruecolor($sx, $sy);
            imagecopy($imgcropped, $img, 0, 0, $px, $py, $sx, $sy);
            imagepng($imgcropped, WUO_ROOT . '/photos/maps/' . $zoom . '-' . $y . '-' . $x . '-' . $fn);
            $px = $px + $sx;
        }
        $px = 0;
        $py = $py + $sy;
    }
}
Exemple #22
0
public function __construct ($configs)
{
	parent::__construct($configs);

	if (!coren::depend('_path_normalizer_0'))
		throw new exception("Tool '_path_normalizer_0' missed.");

	if(isset($configs['lock_relax'])) $this->lock_relax = $configs['lock_relax'];
	if(isset($configs['lock_count'])) $this->lock_count = $configs['lock_count'];
	if(isset($configs['lock_sleep'])) $this->lock_sleep = $configs['lock_sleep'];

	if(isset($configs['chunk_size'])) $this->chunk_size = $configs['chunk_size'];
	$this->chink_size = (integer) $this->chunk_size;
	if ($this->chunk_size <= 0) $this->chunk_size = 1024;

	if(isset($configs['dir_path'    ])) $this->dir_path     = $configs['dir_path'    ];
	if(isset($configs['dir_absolute'])) $this->dir_absolute = $configs['dir_absolute'];
	if(isset($configs['dir_required'])) $this->dir_required = $configs['dir_required'];
	if(isset($configs['dir_automake'])) $this->dir_automake = $configs['dir_automake'];
	if(isset($configs['dir_umask'   ])) $this->dir_umask    = $configs['dir_umask'   ];
	$this->dir = _path_normalizer_0::normalize_dir($this->dir_path, $this->dir_absolute ? null : SITEPATH);
	if ($this->dir_automake && !file_exists($this->dir))
	{
		$old_umask = umask(octdec($this->dir_umask));
		mkdir($this->dir, 0777, true);
		umask($old_umask);
	}
	if ($this->dir_required && !is_dir($this->dir))
	{
		throw new exception("Required directory '{$this->dir}' does not exist.");
	}
}
 public function makeDefDir($field)
 {
     $folder = $this->getFolderPath($field);
     if (is_dir($folder) == false) {
         mkdir($folder, 0755, true);
     }
 }
Exemple #24
0
 /**
  * {@inheritdoc}
  */
 protected function ensureDirectory($root)
 {
     if (is_dir($root) === false) {
         mkdir($root, 0755, true);
     }
     return gae_realpath($root);
 }
Exemple #25
0
 public function __construct()
 {
     $logPath = CoreHelper::loadConfig("log_path", "config");
     $logFileExtension = CoreHelper::loadConfig("log_file_extension", "config");
     $logThreshold = CoreHelper::loadConfig("log_threshold", "config");
     $logDateFormat = CoreHelper::loadConfig("log_date_format", "config");
     $logFilePermissions = CoreHelper::loadConfig("log_file_permissions", "config");
     $this->_log_path = $logPath !== '' ? $logPath : APPPATH . 'logs/';
     $this->_file_ext = isset($logFileExtension) && $logFileExtension !== '' ? ltrim($logFileExtension, '.') : 'php';
     file_exists($this->_log_path) || mkdir($this->_log_path, 0755, true);
     if (!is_dir($this->_log_path) || !CoreHelper::isWriteable($this->_log_path)) {
         $this->_enabled = false;
     }
     if (is_numeric($logThreshold)) {
         $this->_threshold = (int) $logThreshold;
     } elseif (is_array($logThreshold)) {
         $this->_threshold = 0;
         $this->_threshold_array = array_flip($logThreshold);
     }
     if (!empty($logDateFormat)) {
         $this->_date_fmt = $logDateFormat;
     }
     if (!empty($logFilePermissions) && is_int($logFilePermissions)) {
         $this->_file_permissions = $logFilePermissions;
     }
 }
 public static function setUpBeforeClass()
 {
     $reflect = new \ReflectionClass(__CLASS__);
     self::$directory = @tempnam(sys_get_temp_dir(), $reflect->getShortName() . '-');
     @unlink(self::$directory);
     @mkdir(self::$directory);
 }
 public function index_post()
 {
     if (IS_POST || isset($_GET['dosubmit'])) {
         //print_r($_REQUEST);exit();
         if (isset($_GET['type']) && $_GET['type'] == 'url') {
             $sizelimit = isset($_GET['sizelimit']) && abs(intval($_GET['sizelimit'])) ? abs(intval($_GET['sizelimit'])) : $this->error('请输入每个分卷文件大小');
             $this->backup_name = isset($_GET['backup_name']) && trim($_GET['backup_name']) ? trim($_GET['backup_name']) : $this->error('请输入备份名称');
             $vol = $this->_get_vol();
             $vol++;
         } else {
             $sizelimit = isset($_POST['sizelimit']) && abs(intval($_POST['sizelimit'])) ? abs(intval($_POST['sizelimit'])) : $this->error('请输入每个分卷文件大小');
             $this->backup_name = isset($_POST['backup_name']) && trim($_POST['backup_name']) ? trim($_POST['backup_name']) : $this->error('请输入备份名称');
             $backup_tables = isset($_POST['backup_tables']) && $_POST['backup_tables'] ? $_POST['backup_tables'] : $this->error('请选择备份数据表');
             if (is_dir(SITE_PATH . $this->backup_path . $this->backup_name)) {
                 $this->error('备份名称已经存在');
             }
             mkdir(SITE_PATH . $this->backup_path . $this->backup_name);
             if (!is_file(SITE_PATH . $this->backup_path . $this->backup_name . '/tbl_queue.log')) {
                 //写入队列
                 $this->_put_tbl_queue($backup_tables);
             }
             $vol = 1;
         }
         $tables = $this->_dump_queue($vol, $sizelimit * 1024);
         if ($tables === false) {
             $this->error('加载队列文件错误');
         }
         $this->_deal_result($tables, $vol, $sizelimit);
         exit;
     }
 }
Exemple #28
0
 public function prepare($statement, $driver_options = array())
 {
     if (isset($this->dsn) and stristr($this->dsn, 'anjuke_db') and preg_match('/\\sajk_propertys\\s/i', $statement)) {
         if (stristr($statement, 'select CITYID') or stristr($statement, 'insert') or stristr($statement, 'update ')) {
         } else {
             $dir = '/home/www/logs/propsql';
             if (!is_dir($dir)) {
                 mkdir($dir, 0755, true);
             }
             $content = '-=-=-=-=-=-=-=-=-=-=' . PHP_EOL;
             $content .= 'DSN: ' . $this->dsn . PHP_EOL;
             $content .= 'URI: ' . $_SERVER['REQUEST_URI'] . PHP_EOL;
             $content .= 'JOB: ' . var_export($_SERVER['argv'], true) . PHP_EOL;
             $content .= 'SQL: ' . $statement . PHP_EOL;
             file_put_contents($dir . '/' . date('Ymd'), $content, FILE_APPEND);
         }
     }
     //add by jackie for record SQL
     APF::get_instance()->pf_benchmark("sql", array($this->i => $statement));
     $stmt = parent::prepare($statement, $driver_options);
     if ($stmt instanceof PDOStatement) {
         $stmt->setFetchMode($this->default_fetch_mode);
     }
     //add by hexin for record SQL execute time
     $stmt->set_i($this->i);
     $this->i++;
     $stmt->_sql = $statement;
     return $stmt;
 }
Exemple #29
0
function doAction($action)
{
    $id = $_POST['id'];
    $mapFile = "map/" . $id . ".map";
    $offlineFile = "map/offline/" . $id . ".js";
    switch ($action) {
        case "save":
            if (!is_dir("map")) {
                mkdir("map");
                mkdir("map/offline");
            }
            file_put_contents($mapFile, $_POST['data']);
            file_put_contents($offlineFile, "Map.level[" . $id . "]  = " . $_POST['data']);
            return $_POST['data'];
            break;
        case "load":
            if (!empty($_POST['offlineMode'])) {
                return file_get_contents($offlineFile);
            }
            if (file_exists($mapFile)) {
                return file_get_contents($mapFile);
            }
            echo "Echo file not found: " . $mapFile;
            ThrowNotFound();
            break;
    }
}
 /**
  * @throws \CHttpException
  */
 public function run()
 {
     if (!Yii::app()->getRequest()->getIsPostRequest()) {
         throw new \CHttpException(404);
     }
     if (empty($_FILES['file']['name'])) {
         Yii::app()->ajax->raw(['error' => Yii::t('YupeModule.yupe', 'There is an error when downloading!')]);
     }
     $this->webPath = '/' . $this->getController()->yupe->uploadPath . '/files/' . date('Y/m/d') . '/';
     $this->uploadPath = Yii::getPathOfAlias('webroot') . $this->webPath;
     if (!is_dir($this->uploadPath)) {
         if (!@mkdir($this->uploadPath, 0755, true)) {
             Yii::app()->ajax->raw(['error' => Yii::t('YupeModule.yupe', 'Can\'t create catalog "{dir}" for files!', ['{dir}' => $this->uploadPath])]);
         }
     }
     $this->getController()->disableProfilers();
     $this->uploadedFile = CUploadedFile::getInstanceByName('file');
     $form = new UploadForm();
     $form->maxSize = $this->maxSize ?: null;
     $form->mimeTypes = $this->mimeTypes ?: null;
     $form->types = $this->types ?: null;
     $form->file = $this->uploadedFile;
     if ($form->validate() && $this->uploadFile() && ($this->fileLink !== null && $this->fileName !== null)) {
         Yii::app()->ajax->raw(['filelink' => $this->fileLink, 'filename' => $this->fileName]);
     } else {
         Yii::app()->ajax->raw(['error' => join("\n", $form->getErrors("file"))]);
     }
 }