/** * "Ignites" the post installation process. * * @return void */ public static function ignite() { $autoloadPath = 'realpath(\'vendor\') . \'/autoload.php\''; $configPath = APPPATH . 'config'; $templatePath = __DIR__ . '/../Templates'; // Gets data from application/config/config.php $config = new Config('config', $configPath); $config->set('composer_autoload', 138, $autoloadPath, 'string', true); $config->set('index_page', 37, '', 'string'); $config->set('encryption_key', 316, md5('rougin'), 'string'); $config->save(); // Gets data from application/config/autoload.php $autoload = new Config('autoload', $configPath); // Gets the currently included drivers. $drivers = $autoload->get('drivers', 81, 'array'); // Includes "session" driver. if (!in_array('session', $drivers)) { array_push($drivers, 'session'); } // Gets the currently included helpers $defaultHelpers = ['form', 'url']; $helpers = $autoload->get('helper', 91, 'array'); foreach ($defaultHelpers as $helper) { if (!in_array($helper, $helpers)) { array_push($helpers, $helper); } } $autoload->set('drivers', 81, $drivers, 'array'); $autoload->set('helper', 91, $helpers, 'array'); $autoload->save(); $templates = [['file' => '.htaccess', 'name' => 'Htaccess'], ['file' => APPPATH . 'config/pagination.php', 'name' => 'Pagination']]; foreach ($templates as $template) { $file = new File($template['file']); $path = $templatePath . '/' . $template['name'] . '.tpl'; if ($template['file'] == '.htaccess') { $file->chmod(0777); } $file->putContents(file_get_contents($path)); $file->close(); } }
public function __destruct() { if (self::$change_flag) { File::putContents(self::$fileName, '<?php return ' . var_export(self::$system, true) . ';'); } }
public function update() { $updateFile = Tiny::getPath('data') . 'update.php'; $this->assign('status', '0'); if (file_exists($updateFile)) { $updateInfo = (include $updateFile); if (isset($updateInfo['version'])) { $version = $updateInfo['version']; $versionFile = APP_CODE_ROOT . 'version.php'; $currentVersion = (include $versionFile); if ($currentVersion == $version[0]) { $do = Req::args('do'); if ($do == 'yes') { $dbinfo = DBFactory::getDbInfo(); $this->assign('status', '1'); if (isset($updateInfo['sql'][$dbinfo['type']])) { $sqls = $updateInfo['sql'][$dbinfo['type']]; $db = DBFactory::getInstance(); if (is_array($sqls)) { foreach ($sqls as $sql) { $db->doSql($sql); } } File::putContents($versionFile, "<?php return '{$version[1]}';?>"); unlink($updateFile); $this->assign('info', '升级成功!'); } else { $this->assign('info', '不支持' . $dbinfo['type'] . '数据库类型的升级!'); } } else { $this->assign('info', '系统可从当前版本:' . $currentVersion . '升级到' . $version[1]); } } else { $this->assign('status', '-1'); $this->assign('info', '没有可升级的信息!'); } } else { $this->assign('status', '-1'); $this->assign('info', '没有可升级的信息!'); } } else { $this->assign('status', '-1'); $this->assign('info', '没有可升级的信息!'); } $this->redirect(); }
public function testPutGetContents() { $this->assertEquals(2, File::putContents($this->path, 'Oo')); $this->assertEquals('Oo', File::getContents($this->path)); }
/** * Write the csv file to disk. * * @return static */ public function write($filename) { $data = $this->asString(); File::putContents($filename, $data); }
/** * @covers mychaelstyle\storage\File::putContents */ public function testPutContents() { $expected = $this->getExampleContents(); $this->object->putContents($expected); $this->assertLocalWritten($this->dsn, $expected, $this->uri); }