public function Test_file_put_contents() { $file_name = AkConfig::getDir('tmp') . DS . 'test_file_1.txt'; $content = 'This is the content of file 1'; $this->assertFalse(!AkFileSystem::file_put_contents($file_name, $content)); $file_name = '/cache' . DS . 'test_file_1.txt'; $content = 'This is the NEW content for file 1'; $this->assertFalse(!AkFileSystem::file_put_contents($file_name, $content)); AkFileSystem::file_delete($file_name); $file_name = AkConfig::getDir('tmp') . DS . 'test_file_2.txt'; $content = "\n\rThis is the content of file 2\n"; $this->assertFalse(!AkFileSystem::file_put_contents($file_name, $content)); $file_name = 'cache' . DS . 'test_file_3.txt'; $content = "\rThis is the content of file 3\r\n"; $this->assertFalse(!AkFileSystem::file_put_contents($file_name, $content)); $file_name = 'cache/test_file_4.txt'; $content = "\rThis is the content of file 4\r\n"; $this->assertFalse(!AkFileSystem::file_put_contents($file_name, $content)); $file_name = 'ak_test_folder/test_file.txt'; $content = "\rThis is the content of the test file"; $this->assertFalse(!AkFileSystem::file_put_contents($file_name, $content)); $file_name = 'ak_test_folder/new_folder/test_file.txt'; $content = "\rThis is the content of the test file"; $this->assertFalse(!AkFileSystem::file_put_contents($file_name, $content)); }
static function updateCacheFileAfterExecution($environment = null) { static $called = false, $_environment; if ($called == false && !AkDbSchemaCache::shouldRefresh()) { register_shutdown_function(array('AkDbSchemaCache', 'updateCacheFileAfterExecution')); $called = !empty($environment) ? $environment : AK_ENVIRONMENT; } elseif (empty($environment)) { $config = AkDbSchemaCache::config(null, null, $called); $file_name = AkDbSchemaCache::getCacheFileName($called); /** * @todo On PHP5 var_export requires objects that implement the __set_state magic method. * As see on stangelanda at arrowquick dot benchmarks at comhttp://php.net/var_export * serialize works faster without opcode caches. We should do our benchmarks with * var_export VS serialize using APC once we fix the __set_state magic on phpAdoDB */ if (AK_LOG_EVENTS) { $Logger = Ak::getLogger(); } if (!AK_CLI) { if (AK_LOG_EVENTS) { $Logger->message('Updating database settings on ' . $file_name); } AkFileSystem::file_put_contents($file_name, serialize($config), array('base_path' => AK_TMP_DIR)); //file_put_contents($file_name, serialize($config)); } else { if (AK_LOG_EVENTS) { $Logger->message('Skipping writing of cache file: ' . $file_name); } } } }
public function createTemplate($file_name, $content = 'Dummy') { $file_name = str_replace('/', DS, $file_name); $file_name = AkConfig::getDir('views') . DS . $file_name; $this->assertTrue((bool) AkFileSystem::file_put_contents($file_name, $content)); $this->created_files[] = $file_name; }
public function test_should_generate_controller_and_auxiliary_files() { $files = array(AkConfig::getDir('controllers') . DS . 'credit_card_controller.php', AkConfig::getDir('helpers') . DS . 'credit_card_helper.php', AkConfig::getDir('test') . DS . 'functional' . DS . 'controllers' . DS . 'credit_card_controller_test.php', AkConfig::getDir('test') . DS . 'unit' . DS . 'helpers' . DS . 'credit_card_helper_test.php', AkConfig::getDir('views') . DS . 'credit_card' . DS . 'open.html.tpl', AkConfig::getDir('views') . DS . 'credit_card' . DS . 'debit.html.tpl', AkConfig::getDir('views') . DS . 'credit_card' . DS . 'credit.html.tpl', AkConfig::getDir('views') . DS . 'credit_card' . DS . 'close.html.tpl'); clearstatcache(); foreach ($files as $file) { file_exists($file) && unlink($file); $this->assertFalse(file_exists($file)); } AkFileSystem::file_put_contents(AkConfig::getDir('views') . DS . 'credit_card' . DS . 'credit.html.tpl', 'foo', array('base_path' => AK_FRAMEWORK_DIR)); clearstatcache(); $this->assertPattern('/collisions/', $this->runGeneratorCommand('controller CreditCard open debit credit close')); AkFileSystem::file_delete(AkConfig::getDir('views') . DS . 'credit_card' . DS . 'credit.html.tpl', array('base_path' => AK_FRAMEWORK_DIR)); clearstatcache(); foreach ($files as $file) { $this->assertFalse(file_exists($file)); } $this->assertPattern('/ files have been created/', $this->runGeneratorCommand('controller CreditCard open debit credit close')); clearstatcache(); foreach ($files as $file) { $this->assertTrue(file_exists($file)); if (!file_exists($file)) { AkDebug::trace($file); } @unlink($file); } }
public function test_should_fill_the_table_with_yaml_data() { $unit_tester = new AkUnitTest(); $unit_tester->installAndIncludeModels(array('TheModel' => 'id,name')); $TheModel =& $unit_tester->TheModel; $TheModel->create(array('name' => 'eins')); $TheModel->create(array('name' => 'zwei')); $TheModel->create(array('name' => 'drei')); $TheModel->create(array('name' => 'vier')); $this->assertEqual($TheModel->count(), 4); $this->assertTrue($AllRecords = $TheModel->find()); $yaml = $TheModel->toYaml($AllRecords); $yaml_path = AkConfig::getDir('fixtures') . DS . 'the_models.yml'; $this->assertFalse(file_exists($yaml_path)); AkFileSystem::file_put_contents($yaml_path, $yaml); $unit_tester->installAndIncludeModels(array('TheModel' => 'id,name')); try { $TheModel->find(); } catch (RecordNotFoundException $e) { $this->pass(); } $this->assertEqual($TheModel->count(), 0); $unit_tester->installAndIncludeModels(array('TheModel' => 'id,name'), array('populate' => true)); $this->assertEqual($TheModel->count(), 4); unlink($yaml_path); }
public function saveReport() { if ($this->report == '') { $this->renderReport(); } AkFileSystem::file_put_contents('profiler_results.txt', $this->report); }
public function _get_file_details($key) { $key = preg_replace('/[^A-Z^a-z^0-9]/', '', $key); $file = $this->get_persisted_file($key); if (!empty($file)) { AkFileSystem::file_put_contents($this->_getTempDir() . DS . '_file_uploader_file_' . $key, base64_decode($file['contents']), array('ftp' => false)); return array('tmp_name' => $this->_getTempDir() . DS . '_file_uploader_file_' . $key, 'size' => $file['size'], 'name' => $file['name'], 'type' => $file['type'], 'error' => 0); } else { return false; } }
public function test_should_get_the_right_temp_dir() { $tmp_dir = Ak::get_tmp_dir_name(); $tmp_file = $tmp_dir . DS . 'ak_test_' . __CLASS__; $tmp_file2 = $tmp_dir . DS . 'ak_test_dir' . DS . 'level_one' . DS . 'file.txt'; $this->assertTrue(is_dir($tmp_dir), 'Could not find temporary directory at: ' . $tmp_dir); $this->assertTrue(touch($tmp_dir . DS . 'ak_test_' . __CLASS__), 'Can\'t touch files on the temporary directory ' . $tmp_dir); $this->assertTrue(AkFileSystem::file_put_contents($tmp_file, 'abc'), 'Can\'t write on the temporary file ' . $tmp_file); $this->assertTrue(AkFileSystem::file_get_contents($tmp_file) == 'abc', 'Can\'t write on the temporary file ' . $tmp_file); $this->assertTrue(AkFileSystem::file_put_contents($tmp_file2, 'abce'), 'Can\'t write on the temporary file ' . $tmp_file2); $this->assertTrue(AkFileSystem::file_get_contents($tmp_file2) == 'abce', 'Can\'t write on the temporary file ' . $tmp_file2); $this->assertEqual($tmp_dir, AK_TMP_DIR); }
public function _getMenuOptionsForControllersInModule($type = 'admin') { $controllers = AkFileSystem::dir(AK_CONTROLLERS_DIR . DS . $this->_controller->getModuleName(), array('dirs' => false)); sort($controllers); $menu_options = array(); foreach ($controllers as $controller) { $controller_name = substr($controller, 0, -15); $menu_options[AkInflector::titleize($controller_name)] = array('id' => $controller_name, 'url' => array('controller' => $controller_name)); } $options_file = $this->_getMenuOptionsFile($type); if (!file_exists($options_file)) { AkFileSystem::file_put_contents(AK_CONFIG_DIR . DS . $options_file, Ak::convert('array', 'yaml', array('default' => $menu_options))); } return $menu_options; }
public function init() { $this->ext = empty($this->ext) ? 'xls' : strtolower(trim($this->ext, '.')); $this->tmp_name = Ak::randomString(); if (empty($this->source_file)) { $this->source_file = AK_TMP_DIR . DS . $this->tmp_name . '.' . $this->ext; AkFileSystem::file_put_contents($this->source_file, $this->source); $this->delete_source_file = true; $this->keep_destination_file = empty($this->keep_destination_file) ? empty($this->destination_file) ? false : true : $this->keep_destination_file; } else { $this->delete_source_file = false; $this->keep_destination_file = true; } $this->convert_to = !empty($this->convert_to) && empty($this->_file_type_codes[$this->convert_to]) ? 'csv' : (empty($this->convert_to) ? 'csv' : $this->convert_to); $this->destination_file_name = empty($this->destination_file_name) ? $this->tmp_name . '.' . $this->convert_to : $this->destination_file_name . (strstr($this->destination_file_name, '.') ? '' : '.' . $this->convert_to); $this->destination_file = empty($this->destination_file) ? AK_TMP_DIR . DS . $this->destination_file_name : $this->destination_file; }
public function init() { if (empty($this->handler)) { require_once AK_CONTRIB_DIR . DS . 'Excel' . DS . 'reader.php'; $this->handler = new Spreadsheet_Excel_Reader(); $this->handler->setRowColOffset(empty($this->first_column) ? 0 : $this->first_column); } $this->tmp_name = Ak::randomString(); if (empty($this->source_file)) { $this->source_file = AK_TMP_DIR . DS . $this->tmp_name . '.xls'; AkFileSystem::file_put_contents($this->source_file, $this->source); $this->delete_source_file = true; $this->keep_destination_file = empty($this->keep_destination_file) ? empty($this->destination_file) ? false : true : $this->keep_destination_file; } else { $this->delete_source_file = false; $this->keep_destination_file = true; } }
public function relativizeStylesheetPaths() { $url_suffix = AkConsole::promptUserVar('The admin plugin comes with some fancy CSS background images. Your application might be accessible at /myapp, and your images folder might be at /myapp/public Insert the relative path where your images folder is so you don\'t need to manually edit the CSS files', array('default' => '/')); $url_suffix = trim(preg_replace('/\\/?images\\/admin\\/?$/', '', $url_suffix), '/'); if (!empty($url_suffix)) { $stylesheets = array('admin/admin', 'admin/menu'); foreach ($stylesheets as $stylesheet) { $filename = AK_PUBLIC_DIR . DS . 'stylesheets' . DS . $stylesheet . '.css'; $relativized_css = preg_replace("/url\\((\\'|\")?\\/images/", "url(\$1/{$url_suffix}/images", @AkFileSystem::file_get_contents($filename)); !empty($relativized_css) && @AkFileSystem::file_put_contents($filename, $relativized_css); } } }
public function __construct() { parent::__construct(); $this->fixtures_base = AkConfig::getDir('fixtures') . DS . 'Image_TestCase'; if (!($this->offline_mode = !@file_get_contents('http://www.akelos.org/testing_resources/images/watermark.png'))) { $this->image_path = $this->fixtures_base . DS . 'akelos_framework_logo.png'; $this->photo_path = $this->fixtures_base . DS . 'cristobal.jpg'; $this->watermark = $this->fixtures_base . DS . 'watermark.png'; AkFileSystem::copy(AkConfig::getDir('fixtures') . '/old_logo.png', $this->image_path, array('base_path' => AK_FRAMEWORK_DIR)); $cristobal = @Ak::url_get_contents('http://www.akelos.org/testing_resources/images/cristobal.jpg', array('cache' => 100000)); if (!empty($cristobal)) { AkFileSystem::file_put_contents($this->photo_path, $cristobal, array('base_path' => AK_FRAMEWORK_DIR)); } $watermark = @Ak::url_get_contents('http://www.akelos.org/testing_resources/images/watermark.png', array('cache' => 100000)); if (!empty($watermark)) { AkFileSystem::file_put_contents($this->watermark, $watermark, array('base_path' => AK_FRAMEWORK_DIR)); } $this->_run_extra_tests = file_exists($this->photo_path); } }
static function setDictionary($dictionary, $language, $namespace = false, $comment = null) { $path = AkConfig::getDir('app') . DS . 'locales' . DS . ($namespace ? trim(Ak::sanitize_include($namespace, 'high'), DS) . DS : '') . basename($language) . '.php'; AkLocaleManager::getDictionary($language, $namespace, true, $dictionary); AkFileSystem::file_put_contents($path, "<?php\n/** {$comment} */\n\n\$dictionary=" . var_export((array) $dictionary, true) . ";\n"); return $path; }
protected function _getImagePath($path) { $tmp_dir = AkConfig::getDir('tmp'); if (preg_match('/^http(s)?:\\/\\//', $path)) { $path_info = pathinfo($path); $base_file_name = Ak::sanitize_include($path_info['basename'], 'paranaoid'); if (empty($path_info['extension'])) { // no extension, we don't do magic stuff $path = ''; } else { $local_path = $tmp_dir . DS . 'mailer' . DS . 'remote_images' . DS . md5($path) . DS . $base_file_name . '.' . $path_info['extension']; if (!file_exists($local_path) || time() > filemtime($local_path) + 7200) { if (!AkFileSystem::file_put_contents($local_path, Ak::url_get_contents($path), array('base_path' => $tmp_dir))) { return ''; } } if (!file_exists($local_path) || filesize($local_path) < 1) { return ''; } return $local_path; } } $org_path = $path; $public_dir = AkConfig::getDir('public'); $path = $public_dir . $path; $path = realpath($path); if (substr($path, 0, strlen($public_dir)) != $public_dir || !file_exists($path)) { $path = ''; } return $path; }
public function save($file_path, $content) { $this->log[] = $file_path; AkFileSystem::file_put_contents($file_path, $content, $this->getFileOptions()); }
function makeClassExtensible($class_name_to_extend) { list($checksum, $source) = $this->_getExtensionSourceAndChecksum($class_name_to_extend); $merge_path = AK_TMP_DIR . DS . '.lib'; if ($source) { if (preg_match_all('/[ \\n\\t]*([a-z]+)[ \\n\\t]*extends[ \\n\\t]*(' . $class_name_to_extend . ')[ \\n\\t]*[ \\n\\t]*{/i', $source, $matches)) { $replacements = array(); $extended_by = array(); foreach ($matches[2] as $k => $class_to_extend) { if (empty($last_method) && class_exists($class_to_extend)) { $last_method = $class_to_extend; } if ($class_to_extend == $last_method || !empty($extended_by[$class_to_extend]) && in_array($last_method, $extended_by[$class_to_extend])) { if (!class_exists($matches[1][$k])) { $replacements[trim($matches[0][$k], "\n\t {")] = $matches[1][$k] . ' extends ' . $last_method; $last_method = $matches[1][$k]; $extended_by[$class_to_extend][] = $last_method; } else { trigger_error(Ak::t('The class %class is already defined and can\'t be used for extending %parent_class', array('%class' => $matches[1][$k], '%parent_class' => $class_name_to_extend)), E_NOTICE); } } } $source = str_replace(array_keys($replacements), array_values($replacements), $source); } $source = "{$source}<?php class Extensible{$class_name_to_extend} extends {$last_method}{} ?>"; if (md5($source) != @md5_file($merge_path . DS . 'Extensible' . $class_name_to_extend . '.php')) { AkFileSystem::file_put_contents($merge_path . DS . 'Extensible' . $class_name_to_extend . '.php', $source); AkFileSystem::file_put_contents($merge_path . DS . 'checksums' . DS . 'Extensible' . $class_name_to_extend, $checksum); } } include_once $merge_path . DS . 'Extensible' . $class_name_to_extend . '.php'; }
public function writeCache($config, $namespace, $environment = AK_ENVIRONMENT, $force = false) { if (!$force && !$this->_useWriteCache($environment)) { return false; } $key = $this->_getCacheKey($namespace, $environment); Ak::setStaticVar($key, $config); $var_export = var_export($config, true); $cache = <<<CACHE <?php /** * Auto-generated config cache from {$namespace} in environment {$environment} */ \$config = {$var_export}; return \$config; CACHE; $cache_file_name = $this->getCacheFileName($namespace, $environment); if (!AkFileSystem::file_put_contents($cache_file_name, $cache, array('base_path' => AkConfig::getCacheBasePath()))) { trigger_error(Ak::t('Could not create config cache file %file', array('%file' => $cache_file_name)) . ' ' . AkDebug::getFileAndNumberTextForError(1), E_USER_ERROR); return false; } else { return true; } }
public function test_is_dir() { if (!RUN_FTP_TESTS) { return; } $path = 'invalid path'; $this->assertFalse(AkFtp::is_dir($path)); $path = 'this_is_a_file.txt'; AkFileSystem::file_put_contents('this_is_a_file.txt', ''); $this->assertFalse(AkFtp::is_dir($path)); AkFtp::make_dir('tmp_test_dir'); AkFileSystem::file_put_contents('tmp_test_dir/file_inside.txt', ''); $path = 'tmp_test_dir/file_inside.txt'; $this->assertFalse(AkFtp::is_dir($path)); AkFtp::make_dir('real_dir/another/dir'); $path = 'real_dir'; $this->assertTrue(AkFtp::is_dir($path)); $path = 'real_dir/another/dir'; $this->assertTrue(AkFtp::is_dir($path)); AkFtp::delete('real_dir'); AkFtp::delete('this_is_a_file.txt'); AkFtp::delete('tmp_test_dir'); AkFtp::delete('cache'); }
$dirname = dirname($filtered_file); $base_package_dir = realpath($dirname . DS . '..' . DS); $package_name = trim(str_replace($base_package_dir, '', $dirname), DS . '/'); $packages[$package_name] = $dirname; } } $package_files = array(); foreach ($packages as $package_name => $file_path) { foreach ($filtered_files as $filtered_file) { if (strstr($filtered_file, $file_path)) { $package_files[$package_name][trim(str_replace($file_path, '', $filtered_file), '/')] = $filtered_file; } } } $destination = rtrim($options['destination'], DS) . DS . 'metadata'; foreach ($package_files as $package_name => $files) { AkFileSystem::file_put_contents($destination . DS . 'files' . DS . $package_name . '.php', '<?php $metadata = ' . var_export(array('files' => $files), true) . '; return $metadata;'); } $destination = rtrim($options['destination'], DS) . DS . 'refactored'; foreach ($package_files as $package_name => $files) { foreach ($files as $base_file_path => $file) { AkFileSystem::file_put_contents($destination . DS . $package_name . DS . $base_file_path, file_get_contents($file)); } } $destination = rtrim($options['destination'], DS) . DS . 'textile'; foreach ($package_files as $package_name => $files) { foreach ($files as $base_file_path => $file) { AkFileSystem::file_put_contents($destination . DS . $package_name . DS . str_replace('.php', '.textile', $base_file_path), file_get_contents($file)); } } //print_r($package_files);
public function setErrorFileForNamespace($namespace) { $log_dir = AkConfig::getDir('log'); $file_name = $log_dir . DS . $namespace . '.log'; $this->error_file = $file_name; if (!is_file($file_name)) { if (is_writable($log_dir)) { AkFileSystem::file_put_contents($file_name, '', array('base_path' => AkConfig::getDir('log'))); } else { $this->error_file = false; } } }
public function relativizeStylesheetPaths() { $asset_path = $this->_getAssetBasePath(); if ($this->hasUrlSuffix() || !empty($asset_path)) { $url_suffix = trim($this->getUrlSuffix(), '/'); if (!empty($asset_path)) { $url_suffix = trim($url_suffix . '/' . $asset_path, '/'); } foreach ($this->stylesheets as $stylesheet) { $filename = AK_PUBLIC_DIR . DS . 'stylesheets' . DS . $stylesheet . '.css'; $relativized_css = preg_replace("/url\\((\\'|\")?\\/images/", "url(\$1/{$url_suffix}/images", @AkFileSystem::file_get_contents($filename)); empty($relativized_css) || @AkFileSystem::file_put_contents($filename, $relativized_css); } } }
public function _createJoinClass() { $options = $this->getOptions($this->association_id); $class_file_code = "<?php \n\n//This code was generated automatically by the active record hasAndBelongsToMany Method\n\n"; $class_code = "class {$options['join_class_name']} extends {$options['join_class_extends']} {\n public \$_avoidTableNameValidation = true;\n public function {$options['join_class_name']}() {\n \$this->setModelName(\"{$options['join_class_name']}\");\n \$attributes = (array)func_get_args();\n \$this->setTableName('{$options['join_table']}', true, true);\n \$this->init(\$attributes);\n }\n}"; $class_file_code .= $class_code . "\n\n?>"; $join_file = AkInflector::toModelFilename($options['join_class_name']); if ($this->_automatically_create_join_model_files && !file_exists($join_file) && @AkFileSystem::file_put_contents($join_file, $class_file_code, array('base_path' => AkConfig::getDir('models')))) { require_once $join_file; } else { eval($class_code); } return class_exists($options['join_class_name']); }
public function __construct() { parent::__construct(); $this->doc = new DOMDocument(); $this->doc->loadXML('<testsuite/>'); $this->root = $this->doc->documentElement; $base_path = defined('MAKELOS_BASE_DIR') ? MAKELOS_BASE_DIR : AK_BASE_DIR; $file_path = AkConfig::getOption('report_path', $base_path . DS . 'reports' . DS . 'units.xml'); AkFileSystem::file_put_contents($file_path, "<?xml version=\"1.0\"?>\n", array('base_path' => $base_path)); $this->_fp = @fopen($file_path, 'a'); }
protected function _removeMethodFromClass($path, $name, $pluginName) { return AkFileSystem::file_put_contents($path, preg_replace("|(\n[^\n]*?/\\*\\* AUTOMATED START: {$pluginName}::{$name} \\*/.*?/\\*\\* AUTOMATED END: {$pluginName}::{$name} \\*/\n)|s", "", AkFileSystem::file_get_contents($path)), array('skip_path_restriction' => true)); }
public function persistCookies() { if ($this->_cookie_path) { $cookies_from_response = $this->HttpRequest->getResponseCookies(); if (!empty($this->_persisted_cookie)) { $this->HttpRequest->_cookies = array(); $persisted_cookies = $this->HttpRequest->_response->_parseCookie($this->_persisted_cookie); $this->HttpRequest->_cookies = $cookies_from_response; } if (!empty($cookies_from_response)) { $all_cookies = array_merge(isset($persisted_cookies) ? $persisted_cookies : array(), $cookies_from_response); $cookies = array(); foreach ($all_cookies as $cookie) { if (!empty($cookie['value'])) { $cookies[$cookie['name']] = "{$cookie['name']}={$cookie['value']}"; } } $cookie_string = trim(join($cookies, '; ')); AkFileSystem::file_put_contents($this->_cookie_path, $cookie_string, array('base_path' => AkConfig::getDir('tmp'))); } } }
public function runTaskAsDaemon($task_name, $options = array()) { $this->_ensurePosixAndPcntlAreAvailable(); require_once 'System/Daemon.php'; $app_name = AkInflector::underscore($task_name); $pid_file = AK_BASE_DIR . DS . 'run' . DS . $app_name . DS . $app_name . '.pid'; $log_file = AK_LOG_DIR . DS . 'daemons' . DS . $app_name . '.log'; if (!file_exists($pid_file)) { if (empty($options['attributes']['kill'])) { AkFileSystem::file_put_contents($pid_file, ''); AkFileSystem::file_delete($pid_file); } else { $this->error("Could not kill process for {$task_name}", true); } } else { $pid = (int) file_get_contents($pid_file); if ($pid > 0) { if (!empty($options['attributes']['kill'])) { $this->message("Killing process {$pid}"); `kill {$pid}`; AkFileSystem::file_delete($pid_file); die; } elseif (!empty($options['attributes']['restart'])) { $this->message("Restarting {$task_name}."); $this->message(`kill {$pid}`); } else { $this->error("Daemon for {$task_name} still running ({$pid_file}).\nTask aborted.", true); } } } if (!empty($options['attributes']['kill']) && empty($pid)) { $this->error("No daemon running for task {$task_name}", true); } unset($options['attributes']['restart']); if (!file_exists($log_file)) { AkFileSystem::file_put_contents($log_file, ''); } System_Daemon::setOption('appName', $app_name); System_Daemon::setOption('appDir', AK_BASE_DIR); System_Daemon::setOption('logLocation', $log_file); System_Daemon::setOption('appRunAsUID', posix_geteuid()); System_Daemon::setOption('appRunAsGID', posix_getgid()); System_Daemon::setOption('appPidLocation', $pid_file); $this->message("Staring daemon. ({$log_file})"); System_Daemon::start(); $dsn = Ak::getStaticVar('dsn'); defined('AK_SKIP_DB_CONNECTION') && AK_SKIP_DB_CONNECTION ? null : Ak::db($dsn); $this->runTask($task_name, $options); System_Daemon::stop(); AkFileSystem::file_delete($pid_file); die; }
private function _setExternals($items, $extras = '') { $externals = array(); foreach ($items as $name => $uri) { $externals[] = "{$name} " . rtrim($uri, '/'); } $tmp_file = AK_TMP_DIR . DS . Ak::uuid(); $plugins_dir = AK_PLUGINS_DIR; AkFileSystem::file_put_contents($tmp_file, join("\n", $externals)); `svn propset {$extras} -q svn:externals -F "{$tmp_file}" "{$plugins_dir}"`; AkFileSystem::file_delete($tmp_file); }
public function saveFilterChain($name, $filter_chain = null, $filters_directory = null, $options = array()) { $path = $this->_getFilterChainPath($name, $filters_directory); $filter_chain = empty($filter_chain) ? $this->getFilterChain() : $filter_chain; return AkFileSystem::file_put_contents($path, '<?php $filter_chain = ' . var_export($filter_chain, true) . '; ?>', $options); }
public function _saveCompiledTemplate() { $options = array('base_path' => AK_COMPILED_VIEWS_DIR ? AK_TMP_DIR : AkConfig::getDir('base')); if (defined('AK_UPLOAD_FILES_USING_FTP') && AK_UPLOAD_FILES_USING_FTP && !strstr($options['base_path'], AkConfig::getDir('base'))) { $options['ftp'] = false; } AkFileSystem::file_put_contents($this->_getCompiledTemplatePath(), $this->_options['code'], $options); }