Пример #1
6
 /**
  * Compiles a template and writes it to a cache file, which is used for inclusion.
  *
  * @param string $file The full path to the template that will be compiled.
  * @param array $options Options for compilation include:
  *        - `path`: Path where the compiled template should be written.
  *        - `fallback`: Boolean indicating that if the compilation failed for some
  *                      reason (e.g. `path` is not writable), that the compiled template
  *                      should still be returned and no exception be thrown.
  * @return string The compiled template.
  */
 public static function template($file, array $options = array())
 {
     $cachePath = Libraries::get(true, 'resources') . '/tmp/cache/templates';
     $defaults = array('path' => $cachePath, 'fallback' => false);
     $options += $defaults;
     $stats = stat($file);
     $oname = basename(dirname($file)) . '_' . basename($file, '.php');
     $oname .= '_' . ($stats['ino'] ?: hash('md5', $file));
     $template = "template_{$oname}_{$stats['mtime']}_{$stats['size']}.php";
     $template = "{$options['path']}/{$template}";
     if (file_exists($template)) {
         return $template;
     }
     $compiled = static::compile(file_get_contents($file));
     if (is_writable($cachePath) && file_put_contents($template, $compiled) !== false) {
         foreach (glob("{$options['path']}/template_{$oname}_*.php", GLOB_NOSORT) as $expired) {
             if ($expired !== $template) {
                 unlink($expired);
             }
         }
         return $template;
     }
     if ($options['fallback']) {
         return $file;
     }
     throw new TemplateException("Could not write compiled template `{$template}` to cache.");
 }
Пример #2
2
 /**
  * {@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);
 }
Пример #3
1
 protected function rmFile($file)
 {
     if (is_file($file)) {
         chmod(dirname($file), 0777);
         unlink($file);
     }
 }
Пример #4
1
 public function delete()
 {
     $this->load->language('tool/upload');
     $this->document->setTitle($this->language->get('heading_title'));
     $this->load->model('tool/upload');
     if (isset($this->request->post['selected']) && $this->validateDelete()) {
         foreach ($this->request->post['selected'] as $upload_id) {
             // Remove file before deleting DB record.
             $upload_info = $this->model_tool_upload->getUpload($upload_id);
             if ($upload_info && is_file(DIR_DOWNLOAD . $upload_info['filename'])) {
                 unlink(DIR_UPLOAD . $upload_info['filename']);
             }
             $this->model_tool_upload->deleteUpload($upload_id);
         }
         $this->session->data['success'] = $this->language->get('text_success');
         $url = '';
         if (isset($this->request->get['filter_name'])) {
             $url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
         }
         if (isset($this->request->get['filter_date_added'])) {
             $url .= '&filter_date_added=' . $this->request->get['filter_date_added'];
         }
         if (isset($this->request->get['sort'])) {
             $url .= '&sort=' . $this->request->get['sort'];
         }
         if (isset($this->request->get['order'])) {
             $url .= '&order=' . $this->request->get['order'];
         }
         if (isset($this->request->get['page'])) {
             $url .= '&page=' . $this->request->get['page'];
         }
         $this->redirect($this->url->link('tool/upload', 'token=' . $this->session->data['token'] . $url, 'SSL'));
     }
     $this->getList();
 }
Пример #5
1
 /**
  * 图片裁剪
  *
  */
 public function pic_cutOp()
 {
     Uk86Language::uk86_read('admin_common');
     $lang = Uk86Language::uk86_getLangContent();
     uk86_import('function.thumb');
     if (uk86_chksubmit()) {
         $thumb_width = $_POST['x'];
         $x1 = $_POST["x1"];
         $y1 = $_POST["y1"];
         $x2 = $_POST["x2"];
         $y2 = $_POST["y2"];
         $w = $_POST["w"];
         $h = $_POST["h"];
         $scale = $thumb_width / $w;
         $src = str_ireplace(UPLOAD_SITE_URL, BASE_UPLOAD_PATH, $_POST['url']);
         if (strpos($src, '..') !== false || strpos($src, BASE_UPLOAD_PATH) !== 0) {
             exit;
         }
         if (!empty($_POST['filename'])) {
             // 				$save_file2 = BASE_UPLOAD_PATH.'/'.$_POST['filename'];
             $save_file2 = str_ireplace(UPLOAD_SITE_URL, BASE_UPLOAD_PATH, $_POST['filename']);
         } else {
             $save_file2 = str_replace('_small.', '_sm.', $src);
         }
         $cropped = uk86_resize_thumb($save_file2, $src, $w, $h, $x1, $y1, $scale);
         @unlink($src);
         $pathinfo = pathinfo($save_file2);
         exit($pathinfo['basename']);
     }
     $save_file = str_ireplace(UPLOAD_SITE_URL, BASE_UPLOAD_PATH, $_GET['url']);
     $_GET['resize'] = $_GET['resize'] == '0' ? '0' : '1';
     Tpl::output('height', uk86_get_height($save_file));
     Tpl::output('width', uk86_get_width($save_file));
     Tpl::showpage('common.pic_cut', 'null_layout');
 }
 public function tearDown()
 {
     if ($this->tempDirectory) {
         if (file_exists($this->tempDirectory . '/Controller/FooAdminController.php')) {
             unlink($this->tempDirectory . '/Controller/FooAdminController.php');
         }
         if (file_exists($this->tempDirectory . '/Admin/FooAdmin.php')) {
             unlink($this->tempDirectory . '/Admin/FooAdmin.php');
         }
         if (file_exists($this->tempDirectory . '/Resources/config/admin.yml')) {
             unlink($this->tempDirectory . '/Resources/config/admin.yml');
         }
         if (is_dir($this->tempDirectory . '/Controller')) {
             rmdir($this->tempDirectory . '/Controller');
         }
         if (is_dir($this->tempDirectory . '/Admin')) {
             rmdir($this->tempDirectory . '/Admin');
         }
         if (is_dir($this->tempDirectory . '/Resources/config')) {
             rmdir($this->tempDirectory . '/Resources/config');
         }
         if (is_dir($this->tempDirectory . '/Resources')) {
             rmdir($this->tempDirectory . '/Resources');
         }
         if (file_exists($this->tempDirectory) && is_dir($this->tempDirectory)) {
             rmdir($this->tempDirectory);
         }
     }
 }
Пример #7
1
function task_shutdown()
{
    $pid = posix_getpid();
    if (file_exists(LOCK_DIRECTORY . "/update_daemon-{$pid}.lock")) {
        unlink(LOCK_DIRECTORY . "/update_daemon-{$pid}.lock");
    }
}
Пример #8
1
 /**
  * Performs a batch insert into a specific table using either LOAD DATA INFILE or plain INSERTs,
  * as a fallback. On MySQL, LOAD DATA INFILE is 20x faster than a series of plain INSERTs.
  *
  * @param string $tableName PREFIXED table name! you must call Common::prefixTable() before passing the table name
  * @param array $fields array of unquoted field names
  * @param array $values array of data to be inserted
  * @param bool $throwException Whether to throw an exception that was caught while trying
  *                                LOAD DATA INFILE, or not.
  * @throws Exception
  * @return bool  True if the bulk LOAD was used, false if we fallback to plain INSERTs
  */
 public static function tableInsertBatch($tableName, $fields, $values, $throwException = false)
 {
     $filePath = PIWIK_USER_PATH . '/tmp/assets/' . $tableName . '-' . Common::generateUniqId() . '.csv';
     $filePath = SettingsPiwik::rewriteTmpPathWithInstanceId($filePath);
     $loadDataInfileEnabled = Config::getInstance()->General['enable_load_data_infile'];
     if ($loadDataInfileEnabled && Db::get()->hasBulkLoader()) {
         try {
             $fileSpec = array('delim' => "\t", 'quote' => '"', 'escape' => '\\\\', 'escapespecial_cb' => function ($str) {
                 return str_replace(array(chr(92), chr(34)), array(chr(92) . chr(92), chr(92) . chr(34)), $str);
             }, 'eol' => "\r\n", 'null' => 'NULL');
             // hack for charset mismatch
             if (!DbHelper::isDatabaseConnectionUTF8() && !isset(Config::getInstance()->database['charset'])) {
                 $fileSpec['charset'] = 'latin1';
             }
             self::createCSVFile($filePath, $fileSpec, $values);
             if (!is_readable($filePath)) {
                 throw new Exception("File {$filePath} could not be read.");
             }
             $rc = self::createTableFromCSVFile($tableName, $fields, $filePath, $fileSpec);
             if ($rc) {
                 unlink($filePath);
                 return true;
             }
         } catch (Exception $e) {
             Log::info("LOAD DATA INFILE failed or not supported, falling back to normal INSERTs... Error was: %s", $e->getMessage());
             if ($throwException) {
                 throw $e;
             }
         }
     }
     // if all else fails, fallback to a series of INSERTs
     @unlink($filePath);
     self::tableInsertBatchIterate($tableName, $fields, $values);
     return false;
 }
 public function deleteConfiguration($namespace, $context, $language, $environment, $name)
 {
     $fileName = $this->getFilePath($namespace, $context, $language, $environment, $name);
     if (unlink($fileName) === false) {
         throw new ConfigurationException('[StatementConfigurationProvider::deleteConfiguration()] ' . 'Configuration with name "' . $fileName . '" cannot be deleted! Please check your ' . 'file system configuration, the file name, or your environment configuration.');
     }
 }
Пример #10
1
function Proses()
{
    // Buat DBF
    include_once "../{$_SESSION['mnux']}.header.dbf.php";
    include_once "../func/dbf.function.php";
    $NamaFile = "../tmp/TRLSM_{$_SESSION['TahunID']}.DBF";
    $_SESSION['lmhsw_dbf'] = $NamaFile;
    $_SESSION['lmhsw_part'] = 0;
    $_SESSION['lmhsw_counter'] = 0;
    $_SESSION['lmhsw_total'] = HitungData();
    if (file_exists($NamaFile)) {
        unlink($NamaFile);
    }
    DBFCreate($NamaFile, $HeaderKelulusanMhsw);
    // tampilkan
    $ro = "readonly=true";
    echo <<<ESD
  <font size=+1>Proses Data Kelulusan Mahasiswa...</font> (<b>{$_SESSION['lmhsw_total']}</b> data)<br />
  <table class=box cellspacing=1 width=100%>
  <form name='frmMhsw'>
  <tr>
      <td valign=top width=10>
      Counter:<br />
      <input type=text name='Counter' size=4 {$ro} />
      </td>
      
      <td valign=top width=20>
      NIP:<br />
      <input type=text name='MhswID' size=10 {$ro} />
      </td>
      
      <td valign=top>
      Nama Mhsw:<br />
      <input type=text name='NamaMhsw' size=30 {$ro} />
      </td>
      
      <td valign=top align=right width=30>
      <input type=button name='Batal' value='Batal'
        onClick="location='../{$_SESSION['mnux']}.lulusmhsw.php?gos='" />
      </td>
      </tr>
  </form>
  </table>
  <br />
  
  <script>
  function Kembali() {
    window.onLoad=setTimeout("window.location='../{$_SESSION['mnux']}.lulusmhsw.php?gos=Selesai'", 0);
  }
  function Prosesnya(cnt, id, nama) {
    frmMhsw.Counter.value = cnt;
    frmMhsw.MhswID.value = id;
    frmMhsw.NamaMhsw.value = nama;
  }
  </script>
  <iframe src="../{$_SESSION['mnux']}.lulusmhsw.php?gos=ProsesDetails" width=90% height=50 frameborder=0 scrolling=no>
  </iframe>

ESD;
}
Пример #11
1
 protected function setUp()
 {
     $file = sys_get_temp_dir() . '/phinx.yml';
     if (is_file($file)) {
         unlink($file);
     }
 }
Пример #12
0
 public function co_star_edit()
 {
     if ($_POST['submit'] and $_POST['index'] != "") {
         $Stars = M('Co_stars');
         $index = $_POST['index'];
         $star = $Stars->where('photo_index=' . $index)->find();
         if ($_POST['title'] != "") {
             $data['photo_title'] = $_POST['title'];
         }
         $tmp_name = $_FILES['upfile']['tmp_name'];
         $file = $_FILES["upfile"];
         //上傳文件名稱
         //C('__PUBLIC__')爲 /Quanquan/Public
         move_uploaded_file($tmp_name, 'Public/WebResources/co_star/' . $file['name']);
         //將上傳文件移動到指定目錄待解壓
         if ($file['name']) {
             unlink($star['photo_url']);
             $data['photo_url'] = C('__PUBLIC__') . '/WebResources/co_star/' . $file['name'];
         }
         if ($Stars->where('photo_index=' . $index)->save($data)) {
             echo '修改成功';
         } else {
             echo $star['photo_url'];
         }
     } else {
         echo '未輸入數據';
     }
     $this->display();
 }
Пример #13
0
 /**
  * @inheritdoc
  */
 public function beforeSave($insert)
 {
     if (!parent::beforeSave($insert)) {
         return false;
     }
     if ($this->receiptImg) {
         if ($this->receiptImg->error) {
             return false;
         }
         $fileName = $this->receiptImg->baseName . '.' . $this->receiptImg->extension;
         if ($insert) {
             $this->file_name = $fileName;
             return true;
         }
         $existingFilePath = $this->filePath;
         $this->file_name = $fileName;
         $this->_file_path = null;
         // reset filePath so it is recalculated via magicMethod
         if (!$this->receiptImg->saveAs($this->filePath)) {
             throw new ServerErrorHttpException('Unable to save receipt image.');
         } elseif (!unlink($existingFilePath)) {
             throw new ServerErrorHttpException('Unable to delete existing receipt image.');
         }
     }
     return true;
 }
Пример #14
0
 public function query($domain, $postvars)
 {
     $this->log_proxy('  domain: ' . $domain);
     $this->log_proxy('POSTVARS: ' . $postvars);
     $ch = curl_init($domain);
     curl_setopt($ch, CURLOPT_POST, 0);
     curl_setopt($ch, CURLOPT_VERBOSE, 0);
     //   curl_setopt( $ch, CURLOPT_USERAGENT     , isset( $_SERVER[ 'User-Agent' ]) ? $_SERVER[ 'User-Agent' ] : '' );
     curl_setopt($ch, CURLOPT_POSTFIELDS, $postvars);
     //   curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1 );
     curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
     curl_setopt($ch, CURLOPT_REFERER, $domain);
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
     curl_setopt($ch, CURLOPT_AUTOREFERER, 0);
     curl_setopt($ch, CURLOPT_COOKIEJAR, 'ses_' . session_id());
     curl_setopt($ch, CURLOPT_COOKIEFILE, 'ses_' . session_id());
     //   curl_setopt( $ch, CURLOPT_COOKIE        , $COOKIE );
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_FAILONERROR, 1);
     $content = curl_exec($ch);
     $response = curl_getinfo($ch);
     curl_close($ch);
     unlink('ses_' . session_id());
     return $content;
 }
Пример #15
0
/**
 * Build a secured file with token name
 *
 * @param string $reqkey The reference key
 *
 * @return string The secure key
 */
function buildSecFile($reqkey)
{
    $CI =& get_instance();
    $skey = mt_rand();
    $dir = $CI->config->item('token_dir');
    $file = $skey . '.tok';
    //make the file with the reqkey value in it
    file_put_contents($dir . '/' . $file, $reqkey);
    //do some cleanup - find ones older then the threshold and remove
    $rm = $CI->config->item('token_rm');
    //this is in minutes
    if (is_dir($dir)) {
        if (($h = opendir($dir)) !== false) {
            while (($file = readdir($h)) !== false) {
                if (!in_array($file, array('.', '..'))) {
                    $p = $dir . '/' . $file;
                    if (filemtime($p) < time() - $rm * 60) {
                        unlink($p);
                    }
                }
            }
        }
    }
    return $skey;
}
Пример #16
0
 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();
         }
     }
 }
Пример #17
0
 public function purge_step($old_state)
 {
     switch ($old_state) {
         case '':
             // Empty means nothing has run yet
             global $phpbb_root_path;
             $phpbb_store_path = $phpbb_root_path . 'store/';
             $this->del_content_dir('d120de/banner/default/');
             $this->del_content_dir('d120de/banner/event/');
             $this->del_content_dir('d120de/banner/');
             unlink($phpbb_store_path . 'd120de/index.htm');
             //this fails if there are other folders than banner
             $del_res = rmdir($phpbb_store_path . 'd120de/');
             if ($del_res === false) {
                 //we faild create index.htm again
                 touch($phpbb_store_path . 'd120de/index.htm');
             }
             return 'del_content_dir';
             break;
         default:
             // Run parent purge step method
             return parent::purge_step($old_state);
             break;
     }
 }
 public static function setUpBeforeClass()
 {
     $reflect = new \ReflectionClass(__CLASS__);
     self::$directory = @tempnam(sys_get_temp_dir(), $reflect->getShortName() . '-');
     @unlink(self::$directory);
     @mkdir(self::$directory);
 }
Пример #19
0
 /**
  * Delete files in the deleted directory if they are not referenced in the
  * filearchive table. This needs to be done in the repo because it needs to
  * interleave database locks with file operations, which is potentially a
  * remote operation.
  * @return FileRepoStatus
  */
 function cleanupDeletedBatch($storageKeys)
 {
     $root = $this->getZonePath('deleted');
     $dbw = $this->getMasterDB();
     $status = $this->newGood();
     $storageKeys = array_unique($storageKeys);
     foreach ($storageKeys as $key) {
         $hashPath = $this->getDeletedHashPath($key);
         $path = "{$root}/{$hashPath}{$key}";
         $dbw->begin();
         $inuse = $dbw->selectField('filearchive', '1', array('fa_storage_group' => 'deleted', 'fa_storage_key' => $key), __METHOD__, array('FOR UPDATE'));
         if (!$inuse) {
             $sha1 = substr($key, 0, strcspn($key, '.'));
             $ext = substr($key, strcspn($key, '.') + 1);
             $ext = File::normalizeExtension($ext);
             $inuse = $dbw->selectField('oldimage', '1', array('oi_sha1' => $sha1, 'oi_archive_name ' . $dbw->buildLike($dbw->anyString(), ".{$ext}"), $dbw->bitAnd('oi_deleted', File::DELETED_FILE) => File::DELETED_FILE), __METHOD__, array('FOR UPDATE'));
         }
         if (!$inuse) {
             wfDebug(__METHOD__ . ": deleting {$key}\n");
             if (!@unlink($path)) {
                 $status->error('undelete-cleanup-error', $path);
                 $status->failCount++;
             }
         } else {
             wfDebug(__METHOD__ . ": {$key} still in use\n");
             $status->successCount++;
         }
         $dbw->commit();
     }
     return $status;
 }
function sup_repertoire($chemin)
{
    // vérifie si le nom du repertoire contient "/" à la fin
    if ($chemin[strlen($chemin) - 1] != '/') {
        $chemin .= '/';
        // rajoute '/'
    }
    if (is_dir($chemin)) {
        $sq = opendir($chemin);
        // lecture
        while ($f = readdir($sq)) {
            if ($f != '.' && $f != '..') {
                $fichier = $chemin . $f;
                // chemin fichier
                if (is_dir($fichier)) {
                    sup_repertoire($fichier);
                    // rapel la fonction de manière récursive
                } else {
                    unlink($fichier);
                    // sup le fichier
                }
            }
        }
        closedir($sq);
        rmdir($chemin);
        // sup le répertoire
    } else {
        unlink($chemin);
        // sup le fichier
    }
}
Пример #21
0
 public function delete($key)
 {
     $file = $this->getCacheFile($key);
     if (file_exists($file) && !unlink($file)) {
         throw new Google_Cache_Exception("Cache file could not be deleted");
     }
 }
Пример #22
0
/**
 * mime_image_update update file information in the database if there were changes.
 *
 * @param array $pStoreRow File data needed to update details in the database
 * @access public
 * @return TRUE on success, FALSE on failure - $pStoreRow[errors] will contain reason
 */
function mime_image_update(&$pStoreRow, $pParams = NULL)
{
    global $gThumbSizes, $gBitSystem;
    $ret = TRUE;
    // this will set the correct pluign guid, even if we let default handle the store process
    $pStoreRow['attachment_plugin_guid'] = PLUGIN_MIME_GUID_IMAGE;
    // if storing works, we process the image
    if (!empty($pStoreRow['upload']) && ($ret = mime_default_update($pStoreRow))) {
        if (!mime_image_store_exif_data($pStoreRow)) {
            // if it all goes t**s up, we'll know why
            $pStoreRow['errors'] = $pStoreRow['log'];
            $ret = FALSE;
        }
    } elseif ($gBitSystem->isFeatureActive('mime_image_panoramas') && !empty($pParams['preference']['is_panorama']) && empty($pStoreRow['thumbnail_url']['panorama'])) {
        if (!mime_image_create_panorama($pStoreRow)) {
            $ret = FALSE;
        }
    } elseif (empty($pParams['preference']['is_panorama']) && !empty($pStoreRow['thumbnail_url']['panorama'])) {
        // we remove the panorama setting in the database and the panorama thumb
        if (LibertyAttachable::validateStoragePath(STORAGE_PKG_PATH . $pStoreRow['thumbnail_url']['panorama'])) {
            @unlink(STORAGE_PKG_PATH . $pStoreRow['thumbnail_url']['panorama']);
        }
    }
    return $ret;
}
Пример #23
0
 /**
  * Deactivate plugin action
  */
 function deactivate()
 {
     $this->unschedule();
     if (!$this->locked()) {
         @unlink(W3TC_ADDIN_FILE_OBJECT_CACHE);
     }
 }
Пример #24
0
 /**
  * @group internet
  * @group slow
  */
 public function test_recache()
 {
     global $conf;
     $conf['fetchsize'] = 500 * 1024;
     //500kb
     $local = media_get_from_URL('http://www.google.com/images/srpr/logo3w.png', 'png', 5);
     $this->assertTrue($local !== false);
     $this->assertFileExists($local);
     // remember time stamp
     $time = filemtime($local);
     clearstatcache(false, $local);
     sleep(1);
     // fetch again and make sure we got a cache file
     $local = media_get_from_URL('http://www.google.com/images/srpr/logo3w.png', 'png', 5);
     clearstatcache(false, $local);
     $this->assertTrue($local !== false);
     $this->assertFileExists($local);
     $this->assertEquals($time, filemtime($local));
     clearstatcache(false, $local);
     sleep(6);
     // fetch again and make sure we got a new file
     $local = media_get_from_URL('http://www.google.com/images/srpr/logo3w.png', 'png', 5);
     clearstatcache(false, $local);
     $this->assertTrue($local !== false);
     $this->assertFileExists($local);
     $this->assertNotEquals($time, filemtime($local));
     unlink($local);
 }
Пример #25
0
 public function __construct(EngineInterface $engine, $proxyPath = null)
 {
     $this->engine = $engine;
     if (file_exists($proxyPath)) {
         unlink($this->proxyPath);
     }
 }
Пример #26
0
/**
 * Recursively delete an entire directory.
 *
 * @since 4.6
 * @package all
 * @param string $directory The dir you want to remove.
 * @param bool $empty Should the dir remain empty?
 * @return bool
 */
function recursive_remove_directory($directory, $empty = false)
{
    if (substr($directory, -1) == '/') {
        $directory = substr($directory, 0, -1);
    }
    if (!file_exists($directory) || !is_dir($directory)) {
        return false;
    } elseif (is_readable($directory)) {
        $handle = opendir($directory);
        while (false !== ($item = readdir($handle))) {
            if ($item != '.' && $item != '..') {
                $path = $directory . '/' . $item;
                if (is_dir($path)) {
                    recursive_remove_directory($path);
                } else {
                    unlink($path);
                }
            }
        }
        closedir($handle);
        if (!$empty) {
            if (!rmdir($directory)) {
                return false;
            }
        }
    }
    return true;
}
Пример #27
0
 /**
  * {@inheritDoc}
  */
 public function evictClassMetadataFromCache(\ReflectionClass $class)
 {
     $path = $this->dir . '/' . strtr($class->name, '\\', '-') . '.cache.php';
     if (file_exists($path)) {
         unlink($path);
     }
 }
Пример #28
0
 public static function clearCache()
 {
     if (!is_dir(CACHE_PATH)) {
         return;
     }
     try {
         $dirIterator = new RecursiveDirectoryIterator(CACHE_PATH);
         $iterator = new RecursiveIteratorIterator($dirIterator, RecursiveIteratorIterator::CHILD_FIRST);
         foreach ($iterator as $path) {
             switch (true) {
                 case '.' == basename($path->__toString()):
                 case '..' == basename($path->__toString()):
                 case '...' == basename($path->__toString()):
                     break;
                 case $path->isDir():
                     rmdir($path->__toString());
                     break;
                 default:
                     unlink($path->__toString());
                     break;
             }
         }
         rmdir(CACHE_PATH);
     } catch (Exception $e) {
         throw $e;
     }
 }
	/**
	 * @see	wcf\system\package\plugin\IPackageInstallationPlugin::install()
	 */
	public function install() {
		parent::install();
		
		// extract files.tar to temp folder
		$sourceFile = $this->installation->getArchive()->extractTar($this->instruction['value'], 'acptemplates_');
		
		// create file handler
		$fileHandler = new ACPTemplatesFileHandler($this->installation);
		
		// extract content of files.tar
		$packageDir = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR.$this->installation->getPackage()->packageDir));
		
		try {
			$fileInstaller = $this->installation->extractFiles($packageDir.'acp/templates/', $sourceFile, $fileHandler);
		}
		catch (SystemException $e) {
			WCF::getTPL()->assign(array(
				'exception' => $e
			));
			WCF::getTPL()->display('packageInstallationFileInstallationFailed');
			exit;
		}
		
		// delete temporary sourceArchive
		@unlink($sourceFile);
	}
Пример #30
0
 public static function GetPHPFilesMark()
 {
     $res = array();
     $file_name = $_SERVER["DOCUMENT_ROOT"] . "/" . COption::GetOptionString("main", "upload_dir", "/upload/") . "/perfmon#i#.php";
     $content = "<?\$s='" . str_repeat("x", 1024) . "';?><?/*" . str_repeat("y", 1024) . "*/?><?\$r='" . str_repeat("z", 1024) . "';?>";
     for ($j = 0; $j < 4; $j++) {
         $s1 = getmicrotime();
         for ($i = 0; $i < 100; $i++) {
             $fn = str_replace("#i#", $i, $file_name);
         }
         $e1 = getmicrotime();
         $N1 = $e1 - $s1;
         $s2 = getmicrotime();
         for ($i = 0; $i < 100; $i++) {
             //This is one op
             $fn = str_replace("#i#", $i, $file_name);
             $fh = fopen($fn, "wb");
             fwrite($fh, $content);
             fclose($fh);
             include $fn;
             unlink($fn);
         }
         $e2 = getmicrotime();
         $N2 = $e2 - $s2;
         if ($N2 > $N1) {
             $res[] = 100 / ($N2 - $N1);
         }
     }
     if (count($res)) {
         return array_sum($res) / doubleval(count($res));
     } else {
         return 0;
     }
 }