コード例 #1
2
ファイル: Concat.php プロジェクト: greg-1-anderson/Robo
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     if (is_null($this->dst) || "" === $this->dst) {
         return Result::error($this, 'You must specify a destination file with to() method.');
     }
     if (!$this->checkResources($this->files, 'file')) {
         return Result::error($this, 'Source files are missing!');
     }
     if (file_exists($this->dst) && !is_writable($this->dst)) {
         return Result::error($this, 'Destination already exists and cannot be overwritten.');
     }
     $dump = '';
     foreach ($this->files as $path) {
         foreach (glob($path) as $file) {
             $dump .= file_get_contents($file) . "\n";
         }
     }
     $this->printTaskInfo('Writing {destination}', ['destination' => $this->dst]);
     $dst = $this->dst . '.part';
     $write_result = file_put_contents($dst, $dump);
     if (false === $write_result) {
         @unlink($dst);
         return Result::error($this, 'File write failed.');
     }
     // Cannot be cross-volume; should always succeed.
     @rename($dst, $this->dst);
     return Result::success($this);
 }
コード例 #2
1
ファイル: SelfUpdateCommand.php プロジェクト: ftdysa/insight
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $remoteFilename = 'http://get.insight.sensiolabs.com/insight.phar';
     $localFilename = $_SERVER['argv'][0];
     $tempFilename = basename($localFilename, '.phar') . '-temp.phar';
     try {
         copy($remoteFilename, $tempFilename);
         if (md5_file($localFilename) == md5_file($tempFilename)) {
             $output->writeln('<info>insight is already up to date.</info>');
             unlink($tempFilename);
             return;
         }
         chmod($tempFilename, 0777 & ~umask());
         // test the phar validity
         $phar = new \Phar($tempFilename);
         // free the variable to unlock the file
         unset($phar);
         rename($tempFilename, $localFilename);
         $output->writeln('<info>insight updated.</info>');
     } catch (\Exception $e) {
         if (!$e instanceof \UnexpectedValueException && !$e instanceof \PharException) {
             throw $e;
         }
         unlink($tempFilename);
         $output->writeln('<error>The download is corrupt (' . $e->getMessage() . ').</error>');
         $output->writeln('<error>Please re-run the self-update command to try again.</error>');
     }
 }
コード例 #3
1
ファイル: FdfFile.php プロジェクト: aviddv1/php-pdftk
 /**
  * Constructor
  *
  * @param array $data the form data as name => value
  * @param string|null $suffix the optional suffix for the tmp file
  * @param string|null $suffix the optional prefix for the tmp file. If null 'php_tmpfile_' is used.
  * @param string|null $directory directory where the file should be created. Autodetected if not provided.
  * @param string|null $encoding of the data. Default is 'UTF-8'.
  */
 public function __construct($data, $suffix = null, $prefix = null, $directory = null, $encoding = 'UTF-8')
 {
     if ($directory === null) {
         $directory = self::getTempDir();
     }
     $suffix = '.fdf';
     $prefix = 'php_pdftk_fdf_';
     $this->_fileName = tempnam($directory, $prefix);
     $newName = $this->_fileName . $suffix;
     rename($this->_fileName, $newName);
     $this->_fileName = $newName;
     $fields = '';
     foreach ($data as $key => $value) {
         // Create UTF-16BE string encode as ASCII hex
         // See http://blog.tremily.us/posts/PDF_forms/
         $utf16Value = mb_convert_encoding($value, 'UTF-16BE', $encoding);
         /* Also create UTF-16BE encoded key, this allows field names containing
          * german umlauts and most likely many other "special" characters.
          * See issue #17 (https://github.com/mikehaertl/php-pdftk/issues/17)
          */
         $utf16Key = mb_convert_encoding($key, 'UTF-16BE', $encoding);
         // Escape parenthesis
         $utf16Value = strtr($utf16Value, array('(' => '\\(', ')' => '\\)'));
         $fields .= "<</T(" . chr(0xfe) . chr(0xff) . $utf16Key . ")/V(" . chr(0xfe) . chr(0xff) . $utf16Value . ")>>\n";
     }
     // Use fwrite, since file_put_contents() messes around with character encoding
     $fp = fopen($this->_fileName, 'w');
     fwrite($fp, self::FDF_HEADER);
     fwrite($fp, $fields);
     fwrite($fp, self::FDF_FOOTER);
     fclose($fp);
 }
コード例 #4
0
 /**
  * Writes file in a save way to disk
  *
  * @param  string  $_filepath complete filepath
  * @param  string  $_contents file content
  * @return boolean true
  */
 public static function writeFile($_filepath, $_contents, $smarty)
 {
     $old_umask = umask(0);
     $_dirpath = dirname($_filepath);
     // if subdirs, create dir structure
     if ($_dirpath !== '.' && !file_exists($_dirpath)) {
         mkdir($_dirpath, $smarty->_dir_perms, true);
     }
     // write to tmp file, then move to overt file lock race condition
     $_tmp_file = tempnam($_dirpath, 'wrt');
     if (!($fd = @fopen($_tmp_file, 'wb'))) {
         $_tmp_file = $_dirpath . DS . uniqid('wrt');
         if (!($fd = @fopen($_tmp_file, 'wb'))) {
             throw new SmartyException("unable to write file {$_tmp_file}");
             return false;
         }
     }
     fwrite($fd, $_contents);
     fclose($fd);
     // remove original file
     if (file_exists($_filepath)) {
         @unlink($_filepath);
     }
     // rename tmp file
     rename($_tmp_file, $_filepath);
     // set file permissions
     chmod($_filepath, $smarty->_file_perms);
     umask($old_umask);
     return true;
 }
コード例 #5
0
 public function onKernelRequest($event)
 {
     switch (true) {
         case HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType():
         case $this->container->get('kernel')->getEnvironment() == 'dev':
             return;
     }
     $url = $this->container->get('request')->getUri();
     $path = $this->container->getParameter('kernel.cache_dir');
     $old_path = $this->container->getParameter('kernel.cache_dir') . '_old';
     $hash_file = $this->container->getParameter('kernel.cache_dir') . '/config_hash';
     $hash_value = $this->getHash();
     if (!file_exists($hash_file)) {
         $this->writeHashFile($hash_file, $hash_value);
         return;
     } else {
         $old = file_get_contents($hash_file);
         if ($old == $hash_value) {
             return;
         }
         $this->writeHashFile($hash_file, $hash_value);
     }
     if (is_dir($old_path)) {
         $this->container->get('filesystem')->remove($old_path);
     }
     rename($path, $old_path);
     $this->container->get('filesystem')->remove($old_path);
     header('Location: ' . $url);
     exit;
 }
コード例 #6
0
/**
 * write out a file to disk
 *
 * @param string $filename
 * @param string $contents
 * @param boolean $create_dirs
 * @return boolean
 */
function smarty_core_write_file($params, &$smarty)
{
    $_dirname = dirname($params['filename']);
    if ($params['create_dirs']) {
        $_params = array('dir' => $_dirname);
        require_once SMARTY_CORE_DIR . 'core.create_dir_structure.php';
        smarty_core_create_dir_structure($_params, $smarty);
    }
    // write to tmp file, then rename it to avoid file locking race condition
    $_tmp_file = tempnam($_dirname, 'wrt');
    if (!($fd = @fopen($_tmp_file, 'wb'))) {
        $_tmp_file = $_dirname . DIRECTORY_SEPARATOR . uniqid('wrt');
        if (!($fd = @fopen($_tmp_file, 'wb'))) {
            $smarty->trigger_error("problem writing temporary file '{$_tmp_file}'");
            return false;
        }
    }
    fwrite($fd, $params['contents']);
    fclose($fd);
    if (DIRECTORY_SEPARATOR == '\\' || !@rename($_tmp_file, $params['filename'])) {
        // On platforms and filesystems that cannot overwrite with rename()
        // delete the file before renaming it -- because windows always suffers
        // this, it is short-circuited to avoid the initial rename() attempt
        @unlink($params['filename']);
        @rename($_tmp_file, $params['filename']);
    }
    @chmod($params['filename'], $smarty->_file_perms);
    return true;
}
コード例 #7
0
ファイル: Pages_m.php プロジェクト: nurulimamnotes/pusakacms
 function save_page($page)
 {
     $file_content = "";
     // set content
     foreach ($page as $key => $value) {
         if ($value) {
             if ($key == 'slug') {
                 $file_content .= "{: " . $key . " :} " . strtolower(url_title($value)) . "\n";
             } else {
                 $file_content .= "{: " . $key . " :} " . $value . "\n";
             }
         }
     }
     // if it is placed as subpage
     if (!empty($page['parent'])) {
         // if parent still as standalone file (not in folder)
         if (file_exists(PAGE_FOLDER . $page['parent'] . '.md')) {
             // create folder and move the parent inside
             mkdir(PAGE_FOLDER . $page['parent'], 0775);
             rename(PAGE_FOLDER . $page['parent'] . '.md', PAGE_FOLDER . $page['parent'] . '/index.md');
             // create index.html file
             copy(PAGE_FOLDER . 'index.html', PAGE_FOLDER . $page['parent'] . '/index.html');
         }
     }
     if (write_file(PAGE_FOLDER . $page['parent'] . '/' . $page['slug'] . '.md', $file_content)) {
         $this->pusaka->sync_page();
         return true;
     } else {
         return false;
     }
 }
コード例 #8
0
ファイル: picture.php プロジェクト: JiaJia01/homework_09
 private function rename()
 {
     $sql = "select * from t_wz order by id DESC limit 1";
     $info2 = $GLOBALS['dbk']->prepare($sql);
     $info2->execute();
     foreach ($info2 as $value) {
         $this->newname = $value['id'] + 1;
     }
     switch ($this->file['type']) {
         case 'image/jpeg':
             $this->newname = $this->newname . ".jpg";
             break;
         case 'image/png':
             $this->newname = $this->newname . ".png";
             break;
         case 'image/gif':
             $this->newname = $this->newname . ".gif";
             break;
     }
     $oldname = $this->path . "/" . $this->file['name'];
     $newname = $this->path . "/" . $this->newname;
     if (rename($oldname, $newname)) {
     }
     return true;
 }
コード例 #9
0
ファイル: rotate.php プロジェクト: Kevin-ZK/vaneDisk
 protected function rotate($logfile)
 {
     $rotatedLogfile = $logfile . '.1';
     rename($logfile, $rotatedLogfile);
     $msg = 'Log file "' . $logfile . '" was over ' . $this->max_log_size . ' bytes, moved to "' . $rotatedLogfile . '"';
     \OC_Log::write('OC\\Log\\Rotate', $msg, \OC_Log::WARN);
 }
コード例 #10
0
function gridextjs_deprecated()
{
    if (file_exists(dirname(__FILE__) . '/../../modules/gridextjs')) {
        return rename(dirname(__FILE__) . '/../../modules/gridextjs', dirname(__FILE__) . '/../../modules/gridextjs.deprecated');
    }
    return true;
}
コード例 #11
0
/**
 * write out a file to disk
 *
 * @param string $filename
 * @param string $contents
 * @param boolean $create_dirs
 * @return boolean
 */
function smarty_core_write_file($params, &$smarty)
{
    $_dirname = dirname($params['filename']);
    if ($params['create_dirs']) {
        $_params = array('dir' => $_dirname);
        require_once SMARTY_CORE_DIR . 'core.create_dir_structure.php';
        smarty_core_create_dir_structure($_params, $smarty);
    }
    // write to tmp file, then rename it to avoid
    // file locking race condition
    $_tmp_file = tempnam($_dirname, 'wrt');
    if (!($fd = @fopen($_tmp_file, 'wb'))) {
        $_tmp_file = $_dirname . DIRECTORY_SEPARATOR . uniqid('wrt');
        if (!($fd = @fopen($_tmp_file, 'wb'))) {
            $smarty->trigger_error("problem writing temporary file '{$_tmp_file}'");
            return false;
        }
    }
    fwrite($fd, $params['contents']);
    fclose($fd);
    // Delete the file if it allready exists (this is needed on Win,
    // because it cannot overwrite files with rename()
    if (file_exists($params['filename'])) {
        @unlink($params['filename']);
    }
    @rename($_tmp_file, $params['filename']);
    @chmod($params['filename'], $smarty->_file_perms);
    return true;
}
コード例 #12
0
ファイル: ThemeAdmin.php プロジェクト: mcnickbronx/www
 public function fetch()
 {
     if ($this->request->method('post')) {
         $this->dir_delete($this->compiled_dir, false);
         $old_names = $this->request->post('old_name');
         $new_names = $this->request->post('new_name');
         if (is_array($old_names)) {
             foreach ($old_names as $i => $old_name) {
                 $new_name = preg_replace("/[^a-zA-Z0-9\\-\\_]/", "", $new_names[$i]);
                 if (is_writable($this->themes_dir) && is_dir($this->themes_dir . $old_name) && !is_file($this->themes_dir . $new_name) && !is_dir($this->themes_dir . $new_name)) {
                     rename($this->themes_dir . $old_name, $this->themes_dir . $new_name);
                     if ($this->settings->theme == $old_name) {
                         $this->settings->theme = $new_name;
                     }
                 } elseif (is_file($this->themes_dir . $new_name) && $new_name != $old_name) {
                     $message_error = 'name_exists';
                 }
             }
         }
         $action = $this->request->post('action');
         $action_theme = $this->request->post('theme');
         switch ($this->request->post('action')) {
             case 'set_main_theme':
                 $this->settings->theme = $action_theme;
                 break;
             case 'clone_theme':
                 $new_name = $this->settings->theme;
                 while (is_dir($this->themes_dir . $new_name) || is_file($this->themes_dir . $new_name)) {
                     if (preg_match('/(.+)_([0-9]+)$/', $new_name, $parts)) {
                         $new_name = $parts[1] . '_' . ($parts[2] + 1);
                     } else {
                         $new_name = $new_name . '_1';
                     }
                 }
                 $this->dir_copy($this->themes_dir . $this->settings->theme, $this->themes_dir . $new_name);
                 @unlink($this->themes_dir . $new_name . '/locked');
                 $this->settings->theme = $new_name;
                 break;
             case 'delete_theme':
                 $this->dir_delete($this->themes_dir . $action_theme);
                 if ($action_theme == $this->settings->theme) {
                     $t = current($this->get_themes());
                     $this->settings->theme = $t->name;
                 }
                 break;
         }
     }
     $themes = $this->get_themes();
     // Если нет прав на запись - передаем в дизайн предупреждение
     if (!is_writable($this->themes_dir)) {
         $this->design->assign('message_error', 'permissions');
     }
     $current_theme = new stdClass();
     $current_theme->name = $this->settings->theme;
     $current_theme->locked = is_file($this->themes_dir . $current_theme->name . '/locked');
     $this->design->assign('theme', $current_theme);
     $this->design->assign('themes', $themes);
     $this->design->assign('themes_dir', $this->themes_dir);
     return $this->design->fetch('theme.tpl');
 }
コード例 #13
0
 /**
  * Resize a file uploaded
  * @param  string   $path   Path of the data, for instance to upload the file in data['Movie']['picture'] path would be Movie.picture
  * @param  string   $dest   Where to save the uploaded file
  * @param  integer  $width
  * @param  integer  $height
  * @return boolean  True if the image is uploaded.
  */
 public function move($path, $dest, $width = 0, $height = 0)
 {
     $file = Hash::get($this->controller->request->data, $path);
     if (empty($file['tmp_name'])) {
         return false;
     }
     $tmp = TMP . $file['name'];
     move_uploaded_file($file['tmp_name'], $tmp);
     $info = pathinfo($file['name']);
     $destinfo = pathinfo($dest);
     $directory = dirname(IMAGES . $dest);
     if (!file_exists($directory)) {
         mkdir($directory, 0777, true);
     }
     if ($info['extension'] == $destinfo['extension'] && $width == 0) {
         rename($tmp, IMAGES . $dest);
         return true;
     }
     if (!file_exists($dest_file)) {
         require_once APP . 'Plugin' . DS . 'Media' . DS . 'Vendor' . DS . 'imagine.phar';
         $imagine = new Imagine\Gd\Imagine();
         $imagine->open($tmp)->thumbnail(new Imagine\Image\Box($width, $height), Imagine\Image\ImageInterface::THUMBNAIL_OUTBOUND)->save(IMAGES . $dest, array('quality' => 90));
     }
     return true;
 }
コード例 #14
0
ファイル: editer_auteur.php プロジェクト: nursit/SPIP
/**
 * Editer ou créer un auteur
 * 
 * @link http://doc.spip.org/@action_editer_auteur_dist
 * @global array $GLOBALS['visiteur_session']
 * @param array $arg 
 * @return array 
 */
function action_editer_auteur_dist($arg = null)
{
    if (is_null($arg)) {
        $securiser_action = charger_fonction('securiser_action', 'inc');
        $arg = $securiser_action();
    }
    // si id_auteur n'est pas un nombre, c'est une creation
    if (!($id_auteur = intval($arg))) {
        if (($id_auteur = auteur_inserer()) > 0) {
            # cf. GROS HACK
            # recuperer l'eventuel logo charge avant la creation
            # ils ont un id = 0-id_auteur de la session
            $id_hack = 0 - $GLOBALS['visiteur_session']['id_auteur'];
            $chercher_logo = charger_fonction('chercher_logo', 'inc');
            if (list($logo) = $chercher_logo($id_hack, 'id_auteur', 'on')) {
                rename($logo, str_replace($id_hack, $id_auteur, $logo));
            }
            if (list($logo) = $chercher_logo($id_hack, 'id_auteur', 'off')) {
                rename($logo, str_replace($id_hack, $id_auteur, $logo));
            }
        }
    }
    // Enregistre l'envoi dans la BD
    $err = "";
    if ($id_auteur > 0) {
        $err = auteur_modifier($id_auteur);
    }
    if ($err) {
        spip_log("echec editeur auteur: {$err}", _LOG_ERREUR);
    }
    return array($id_auteur, $err);
}
コード例 #15
0
ファイル: Download.php プロジェクト: phanan/koel
 /**
  * Generate the downloadable path for a song.
  *
  * @param Song $song
  *
  * @return string
  */
 protected function fromSong(Song $song)
 {
     if ($s3Params = $song->s3_params) {
         // The song is hosted on Amazon S3.
         // We download it back to our local server first.
         $localPath = rtrim(sys_get_temp_dir(), '/') . '/' . basename($s3Params['key']);
         $url = $song->getObjectStoragePublicUrl();
         abort_unless($url, 404);
         // The following function require allow_url_fopen to be ON.
         // We're just assuming that to be the case here.
         copy($url, $localPath);
     } else {
         // The song is hosted locally. Make sure the file exists.
         abort_unless(file_exists($song->path), 404);
         $localPath = $song->path;
     }
     // The BinaryFileResponse factory only accept ASCII-only file names.
     if (ctype_print($localPath)) {
         return $localPath;
     }
     // For those with high-byte characters in names, we copy it into a safe name
     // as a workaround.
     $newPath = rtrim(sys_get_temp_dir(), '/') . '/' . utf8_decode(basename($song->path));
     if ($s3Params) {
         // If the file is downloaded from S3, we rename it directly.
         // This will save us some disk space.
         rename($localPath, $newPath);
     } else {
         // Else we copy it to another file to not mess up the original one.
         copy($localPath, $newPath);
     }
     return $newPath;
 }
 function createFile($imgURL)
 {
     $remImgURL = urldecode($imgURL);
     $urlParced = pathinfo($remImgURL);
     $remImgURLFilename = $urlParced['basename'];
     $imgData = wp_remote_get($remImgURL);
     if (is_wp_error($imgData)) {
         $badOut['Error'] = print_r($imgData, true) . " - ERROR";
         return $badOut;
     }
     $imgData = $imgData['body'];
     $tmp = array_search('uri', @array_flip(stream_get_meta_data($GLOBALS[mt_rand()] = tmpfile())));
     if (!is_writable($tmp)) {
         return "Your temporary folder or file (file - " . $tmp . ") is not witable. Can't upload images to Flickr";
     }
     rename($tmp, $tmp .= '.png');
     register_shutdown_function(create_function('', "unlink('{$tmp}');"));
     file_put_contents($tmp, $imgData);
     if (!$tmp) {
         return 'You must specify a path to a file';
     }
     if (!file_exists($tmp)) {
         return 'File path specified does not exist';
     }
     if (!is_readable($tmp)) {
         return 'File path specified is not readable';
     }
     //  $data['name'] = basename($tmp);
     return "@{$tmp}";
 }
コード例 #17
0
 protected function uninstall()
 {
     rename(__DIR__ . '/../../../../../config/configuration.yml', __DIR__ . '/../../../../../config/configuration.yml.test');
     $this->tearDownHandlers[] = function () {
         rename(__DIR__ . '/../../../../../config/configuration.yml.test', __DIR__ . '/../../../../../config/configuration.yml');
     };
 }
コード例 #18
0
 static function ResetLog($tag)
 {
     $oldLogName = AliceUtilLogger::$logName;
     AliceUtilLogger::$logName = AliceUtilLogger::logName($tag);
     $defaultLog = self::logName(null);
     // Close the file if it's open
     if ($oldLogName == AliceUtilLogger::$logName) {
         self::WriteLog(null);
     }
     // Remove any old log file
     @unlink(AliceUtilLogger::$logName);
     if (!empty($tag)) {
         // Rename the default log (if it exists) to the new name
         @rename($defaultLog, AliceUtilLogger::$logName);
     }
     // Touch the log file
     $fp = @fopen(AliceUtilLogger::$logName, 'w');
     if ($fp !== false) {
         @fclose($fp);
     }
     // Delete the default log
     if (!empty($tag)) {
         @unlink($defaultLog);
     }
     @chmod(AliceUtilLogger::$logName, 0666);
     self::WriteLog(true, '');
 }
コード例 #19
0
ファイル: Filesystem.php プロジェクト: kayneth/site_enchere
 /**
  * {@inheritdoc}
  */
 public function write($key, $content)
 {
     $dir = dirname($key);
     if (!is_dir($dir)) {
         if (false === @mkdir($dir, 0777, true)) {
             clearstatcache(false, $dir);
             if (!is_dir($dir)) {
                 throw new RuntimeException(sprintf('Unable to create the cache directory (%s).', $dir));
             }
         }
     } elseif (!is_writable($dir)) {
         throw new RuntimeException(sprintf('Unable to write in the cache directory (%s).', $dir));
     }
     $tmpFile = tempnam($dir, basename($key));
     if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $key)) {
         @chmod($key, 0666 & ~umask());
         if (self::FORCE_BYTECODE_INVALIDATION == ($this->options & self::FORCE_BYTECODE_INVALIDATION)) {
             // Compile cached file into bytecode cache
             if (function_exists('opcache_invalidate')) {
                 opcache_invalidate($key, true);
             } elseif (function_exists('apc_compile_file')) {
                 apc_compile_file($key);
             }
         }
         return;
     }
     throw new RuntimeException(sprintf('Failed to write cache file "%s".', $key));
 }
コード例 #20
0
 function new_pic()
 {
     $inpId = $this->input->post('inpId');
     $inpVal = $this->input->post('inpValue');
     $cid = $this->session->userdata['profile_data'][0]['custID'];
     $filepath = $_SERVER['DOCUMENT_ROOT'] . "/uploads/";
     $name = $this->session->userdata['profile_data'][0]['custID'] . '_' . $_FILES['profile_pic']['name'];
     $size = $_FILES['profile_pic']['size'];
     $photo_type = $_FILES['profile_pic']['type'];
     $tmp = $_FILES['profile_pic']['tmp_name'];
     $upload_image = $filepath . basename($_FILES['profile_pic']['name']);
     $thumbnail = $filepath . 'small_' . $name;
     $actual = $filepath . $name;
     $newwidth = "200";
     $newheight = "200";
     if (move_uploaded_file($_FILES['profile_pic']['tmp_name'], $upload_image)) {
         exec('convert ' . $upload_image . ' -resize ' . $newwidth . 'x' . $newheight . '^ ' . $thumbnail);
         rename($upload_image, $actual);
         /*   unlink("uploads/".$this->session->userdata['profile_data'][0]['photo']);
               unlink("uploads/small_".$this->session->userdata['profile_data'][0]['photo']);
               $data=array(
               'photo' => $name
               );
              $this->session->set_userdata("profile_data[0]['photo']",$name); */
         echo "uploaded" . $_SERVER['DOCUMENT_ROOT'];
     } else {
         echo "not_uploaded";
     }
     $sql_11 = "UPDATE `personaldata` SET `PerdataProfPict`='{$name}' WHERE  `custID`='{$cid}'";
     $this->db->query($sql_11);
     $sql_22 = "UPDATE `personalphoto` SET `photo`='{$name}' WHERE `custID`='{$cid}'";
     $this->db->query($sql_22);
     $this->update_joomla('avatar', $name);
     echo $this->db->affected_rows();
 }
コード例 #21
0
 /**
  * Generates classes and templates in cache.
  *
  * @param array $params The parameters
  *
  * @return string The data to put in configuration cache
  */
 public function generate($params = array())
 {
     $this->validateParameters($params);
     $this->modelClass = $this->params['model_class'];
     // generated module name
     $this->setModuleName($this->params['moduleName']);
     $this->setGeneratedModuleName('auto' . ucfirst($this->params['moduleName']));
     // theme exists?
     $theme = isset($this->params['theme']) ? $this->params['theme'] : 'default';
     $this->setTheme($theme);
     $themeDir = $this->generatorManager->getConfiguration()->getGeneratorTemplate($this->getGeneratorClass(), $theme, '');
     if (!is_dir($themeDir)) {
         throw new sfConfigurationException(sprintf('The theme "%s" does not exist.', $theme));
     }
     // configure the model
     $this->configure();
     $this->configuration = $this->loadConfiguration();
     // generate files
     $this->generatePhpFiles($this->generatedModuleName, sfFinder::type('file')->relative()->in($themeDir));
     // move helper file
     if (file_exists($file = $this->generatorManager->getBasePath() . '/' . $this->getGeneratedModuleName() . '/lib/helper.php')) {
         @rename($file, $this->generatorManager->getBasePath() . '/' . $this->getGeneratedModuleName() . '/lib/Base' . ucfirst($this->moduleName) . 'GeneratorHelper.class.php');
     }
     return "require_once(sfConfig::get('sf_module_cache_dir').'/" . $this->generatedModuleName . "/actions/actions.class.php');";
 }
コード例 #22
0
    public function loadFile()
    {
        if (!$_FILES) {
            ?>
<form method="POST" enctype="multipart/form-data">
File to upload: <input type="file" name="io_file"/> <input type="submit" value="Upload"/>
</form>
<?php 
            exit;
        }
        if (!empty($_FILES['io_file']['tmp_name'])) {
            $uploader = new Mage_Core_Model_File_Uploader('io_file');
            $uploader->setAllowedExtensions(array('csv', 'xml'));
            $path = Mage::app()->getConfig()->getTempVarDir() . '/import/';
            $uploader->save($path);
            if ($uploadFile = $uploader->getUploadedFileName()) {
                $session = Mage::getModel('dataflow/session');
                $session->setCreatedDate(date('Y-m-d H:i:s'));
                $session->setDirection('import');
                $session->setUserId(Mage::getSingleton('admin/session')->getUser()->getId());
                $session->save();
                $sessionId = $session->getId();
                $newFilename = 'import_' . $sessionId . '_' . $uploadFile;
                rename($path . $uploadFile, $path . $newFilename);
                $session->setFile($newFilename);
                $session->save();
                $this->setData(file_get_contents($path . $newFilename));
                Mage::register('current_dataflow_session_id', $sessionId);
            }
        }
        return $this;
    }
コード例 #23
0
 public function updatePerfilAction($id)
 {
     $em = $this->getDoctrine()->getManager();
     $estudiante = $em->getRepository('EstudianteBundle:Estudiante')->find($id);
     $cedula = $estudiante->getCedula();
     $password = $estudiante->getPassword();
     if (!$estudiante) {
         throw $this->createNotFoundException('No se ha encontrado el estudiante solicitado');
     }
     $editForm = $this->createForm(new EstudianteRegistroType(), $estudiante);
     $request = $this->getRequest();
     $editForm->handleRequest($request);
     if ($editForm->isValid()) {
         if (!($cedula === $estudiante->getCedula())) {
             rename(__DIR__ . '/../../../../web/uploads/estudiantes/' . $cedula, __DIR__ . '/../../../../web/uploads/estudiantes/' . $estudiante->getCedula());
         }
         $estudiante->setPassword($password);
         $estudiante->upload();
         $em->persist($estudiante);
         $em->flush();
         $this->getRequest()->getSession()->getFlashBag()->add('notice', '¡Perfil Modificado!');
         return $this->redirect($this->generateUrl('estudiante_edit', array('id' => $id)));
     }
     //var_dump($editForm->getErrors());
     return $this->render('EstudianteBundle:Default:modalEditEstudiante.html.twig', array('estudiante' => $estudiante, 'edit_form' => $editForm->createView()));
 }
コード例 #24
0
ファイル: util.php プロジェクト: alopix/aoxPages
 public static function write_file($filename, $content)
 {
     /*
     Atomically writes, or overwrites, the given content to a file.
     
     Atomic file writes are required for cache updates, and when
     writing compiled templates, to avoid race conditions.
     */
     $temp = tempnam(OUTLINE_CACHE_PATH, 'temp');
     if (!($f = @fopen($temp, 'wb'))) {
         $temp = OUTLINE_CACHE_PATH . DIRECTORY_SEPARATOR . uniqid('temp');
         if (!($f = @fopen($temp, 'wb'))) {
             trigger_error("OutlineUtil::write_file() : error writing temporary file '{$temp}'", E_USER_WARNING);
             return false;
         }
     }
     fwrite($f, $content);
     fclose($f);
     if (!@rename($temp, $filename)) {
         @unlink($filename);
         @rename($temp, $filename);
     }
     @chmod($filename, OUTLINE_FILE_MODE);
     return true;
 }
コード例 #25
0
ファイル: NoticiesForm.class.php プロジェクト: nagiro/intra
 public function save($conn = null)
 {
     parent::save();
     $BASE = $this->URL_IMAGE;
     $ON = $this->getObject();
     if ($ON instanceof Noticies) {
         $I = $ON->getImatge();
         if (!empty($I) && file_exists($BASE . $I)) {
             $img = new sfImage($BASE . $I, 'image/jpg');
             $img->resize(100, 100);
             $nom = $ON->getIdnoticia() . '.jpg';
             $img->saveAs($BASE . $nom);
             if ($I != $nom) {
                 unlink($BASE . $I);
             }
             $ON->setImatge($nom)->save();
         }
         $P = $ON->getAdjunt();
         if (!empty($P) && file_exists($BASE . $P)) {
             $nom = $ON->getIdnoticia() . '.pdf';
             rename($BASE . $P, $BASE . $nom);
             if ($I != $nom) {
                 unlink($BASE . $P);
             }
             $ON->setAdjunt($nom)->save();
         }
     }
 }
コード例 #26
0
ファイル: RenameFolder.php プロジェクト: Mursyidn/TES-UAS
    function run()
    {
        $result1 = false;
        if ($this->newname != '') {
            $result1 = rename($this->real_cwd . '/' . $this->foldername, $this->real_cwd . '/' . $this->newname);
        }
        header("content-type: text/xml");
        echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n";
        ?>
<Connector command="RenameFolder" resourceType="<?php 
        echo $this->type;
        ?>
">
	<CurrentFolder path="<?php 
        echo $this->raw_cwd;
        ?>
" url="<?php 
        echo $this->actual_cwd;
        ?>
" />
	<?php 
        if ($result1) {
            $err_no = 0;
        } else {
            $err_no = 602;
        }
        ?>
	<Error number="<?php 
        echo "" . $err_no;
        ?>
" />
</Connector>
		<?php 
    }
コード例 #27
0
ファイル: rtmessageadd.php プロジェクト: Akheon23/lms
function MessageAdd($msg, $headers, $files = NULL)
{
    global $DB, $LMS;
    $time = time();
    $head = '';
    if ($headers) {
        foreach ($headers as $idx => $header) {
            $head .= $idx . ": " . $header . "\n";
        }
    }
    $DB->Execute('INSERT INTO rtmessages (ticketid, createtime, subject, body, userid, customerid, mailfrom, inreplyto, messageid, replyto, headers)
			VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', array($msg['ticketid'], $time, $msg['subject'], preg_replace("/\r/", "", $msg['body']), $msg['userid'], $msg['customerid'], $msg['mailfrom'], $msg['inreplyto'], $msg['messageid'], isset($msg['replyto']) ? $msg['replyto'] : $headers['Reply-To'], $head));
    $mail_dir = ConfigHelper::getConfig('rt.mail_dir');
    if (!empty($files) && !empty($mail_dir)) {
        $id = $DB->GetLastInsertId('rtmessages');
        $dir = $mail_dir . sprintf('/%06d/%06d', $msg['ticketid'], $id);
        @mkdir($mail_dir . sprintf('/%06d', $msg['ticketid']), 0700);
        @mkdir($dir, 0700);
        foreach ($files as $file) {
            $newfile = $dir . '/' . $file['name'];
            if (@rename($file['tmp_name'], $newfile)) {
                $DB->Execute('INSERT INTO rtattachments (messageid, filename, contenttype) 
						VALUES (?,?,?)', array($id, $file['name'], $file['type']));
            }
        }
    }
}
コード例 #28
0
ファイル: filesDriver.php プロジェクト: xiaoliwang/phpCache
 public function driverSet(string $keyword, $value, int $time = 0, bool $not_exist = false) : bool
 {
     $file_path = $this->getFilePath($keyword);
     $temp_path = $file_path . ".tmp";
     $now = time();
     $expiring_time = $time ? $now + $time : 0;
     $object = ['value' => $value, 'expiring_time' => $expiring_time];
     $data = $this->encode($object);
     $to_write = true;
     if ($not_exist && @file_exists($file_path)) {
         $content = file_get_contents($file_path);
         $old = $this->decode($content);
         $to_write = false;
         if ($this->isExpired($old)) {
             $to_write = true;
         }
     }
     $written = false;
     if ($to_write) {
         try {
             $written = @file_put_contents($temp_path, $data, LOCK_EX | LOCK_NB) && @rename($temp_path, $file_path);
         } catch (\Exception $e) {
             $written = false;
         }
     }
     return $written;
 }
コード例 #29
0
ファイル: Users.php プロジェクト: ankuradhey/dealtrip
 public function UpdateUser($dataForm, $SignUpfor)
 {
     global $mySession;
     $db = new Db();
     $chkQry = $db->runQuery("select * from " . USERS . " where user_id = '" . $mySession->LoggedUserId . "'");
     if ($dataForm['photo'] != "") {
         unlink(SITE_ROOT . 'images/' . $chkQry[0]['image']);
         $profileImage = time() . "_" . $dataForm['photo'];
         @rename(SITE_ROOT . 'images/' . $dataForm['photo'], SITE_ROOT . 'images/' . $profileImage);
         $dataInsert['image'] = $profileImage;
         $mySession->LoggedUser['image'] = $profileImage;
     }
     $dataInsert['first_name'] = $dataForm['first_name'];
     $dataInsert['last_name'] = $dataForm['last_name'];
     $dataInsert['country_id'] = $dataForm['country_id'];
     $dataInsert['state_id'] = $dataForm['state_id'];
     $dataInsert['city_id'] = $dataForm['city_id'];
     $dataInsert['zipcode'] = $dataForm['zipcode'];
     $dataInsert['home_number'] = $dataForm['home_number'];
     $dataInsert['work_number'] = $dataForm['work_number'];
     $dataInsert['mobile_number'] = $dataForm['mobile_number'];
     //$dataInsert['address'] = $dataForm['address'];
     $dataInsert['web'] = $dataForm['webaddress'];
     $conditionUpdate = " user_id ='" . $mySession->LoggedUserId . "'";
     $db->modify(USERS, $dataInsert, $conditionUpdate);
     return 1;
 }
コード例 #30
-1
ファイル: manage_common.php プロジェクト: andregirol/uxpanel
function installConfig()
{
    require_once "../include/pbkdf2.php";
    $fout = fopen("../config_local.php_", 'w') or die("Could not write to local configuration file!");
    fwrite($fout, "<?php\n");
    fwrite($fout, '$config["site_name"] = "' . readline("Site name? ") . '";' . "\n");
    fwrite($fout, '$config["root_path"] = "' . readline("Root path (ex: /uxpanel/)? ") . '";' . "\n");
    fwrite($fout, '$config["mail_from"] = "' . readline("E-mail address to send as? ") . '";' . "\n");
    fwrite($fout, '$config["admin_username"] = "******"Admin username? ") . '";' . "\n");
    fwrite($fout, '$config["admin_password"] = "******"Admin password? ")) . '";' . "\n");
    fwrite($fout, '$config["admin_passwordtype"] = "pbkdf2";' . "\n");
    fwrite($fout, '$config["db_hostname"] = "' . readline("Database hostname? ") . '";' . "\n");
    fwrite($fout, '$config["db_name"] = "' . readline("Database name? ") . '";' . "\n");
    fwrite($fout, '$config["db_username"] = "******"Database username? ") . '";' . "\n");
    fwrite($fout, '$config["db_password"] = "******"Database password? ") . '";' . "\n");
    do {
        $slave = readline("Install as slave (y/n)? ");
    } while ($slave != "y" && $slave != "n");
    $slave = $slave == "y";
    fwrite($fout, '$config["slave"] = ' . ($slave ? "true" : "false") . ';' . "\n");
    if ($slave) {
        fwrite($fout, '$config["slave_master"] = "' . readline("Master URL (ex: http://master.yourdomain.com/uxpanel/)? ") . '";' . "\n");
        fwrite($fout, '$config["slave_id"] = ' . readline("Slave ID number? ") . ';' . "\n");
    }
    fwrite($fout, "?>\n");
    fclose($fout);
    rename("../config_local.php_", "../config_local.php");
}