Ejemplo n.º 1
0
 protected function _appendToFile($file_name, $message, $stamp)
 {
     lmbFs::mkdir(dirname($file_name), 0775);
     $file_existed = file_exists($file_name);
     if ($fh = fopen($file_name, 'a')) {
         @flock($fh, LOCK_EX);
         $time = strftime("%b %d %Y %H:%M:%S", $stamp);
         $log_message = PHP_EOL . "=====[" . $time . "]";
         if (isset($_SERVER['REMOTE_ADDR'])) {
             $log_message .= "[" . $_SERVER['REMOTE_ADDR'] . "]";
         }
         if (isset($_SERVER['REQUEST_URI'])) {
             $log_message .= "[";
             if (isset($_SERVER['REQUEST_METHOD'])) {
                 $log_message .= $_SERVER['REQUEST_METHOD'] . " - ";
             }
             $log_message .= $_SERVER['REQUEST_URI'] . "]";
         }
         $log_message .= "=====" . PHP_EOL . $message;
         fwrite($fh, $log_message);
         @flock($fp, LOCK_UN);
         fclose($fh);
         if (!$file_existed) {
             chmod($file_name, 0664);
         }
     } else {
         throw new lmbFsException("Cannot open log file '{$file_name}' for writing" . PHP_EOL . "The web server must be allowed to modify the file." . PHP_EOL . "File logging for '{$file_name}' is disabled.");
     }
 }
Ejemplo n.º 2
0
 function setUp()
 {
     lmbFs::rm(LIMB_VAR_DIR);
     lmbFs::mkdir(LIMB_VAR_DIR);
     $this->logger = new lmbCacheLogFile(LIMB_VAR_DIR . '/cache.log');
     parent::setUp();
 }
 function setUp()
 {
     $this->_cleanUp();
     lmbFs::mkdir(LIMB_VAR_DIR . '/translations');
     lmbFs::mkdir(LIMB_VAR_DIR . '/src');
     lmbFs::mkdir(LIMB_VAR_DIR . '/parse1');
     lmbFs::mkdir(LIMB_VAR_DIR . '/parse2');
 }
 function setUp()
 {
     parent::setUp();
     $this->conn = lmbToolkit::instance()->getDefaultDbConnection();
     $dir_for_tests = lmb_var_dir() . '/constructor/';
     $this->dir_for_test_case = $dir_for_tests . '/' . get_class($this);
     lmbFs::mkdir($this->dir_for_test_case);
 }
Ejemplo n.º 5
0
function lmb_tests_init_var_dir($value)
{
    if (file_exists($value)) {
        lmbFs::rm($value);
    }
    lmbFs::mkdir($value);
    $real = realpath($value) . '/';
    lmb_var_dir($real);
}
 function setUp()
 {
     parent::setUp();
     lmbFs::mkdir($this->tpl_dir . '/_mail');
     $toolkit = lmbToolkit::instance();
     $toolkit->setConf('macro', $this->_createMacroConfig());
     $mail_config = $toolkit->getConf('mail');
     $mail_config->set('mode', 'testing');
     $toolkit->setConf('mail', $mail_config);
 }
Ejemplo n.º 7
0
function lmb_tests_init_var_dir($value)
{
    if (file_exists($value)) {
        lmbFs::rm($value);
    }
    lmbFs::mkdir($value);
    $real = realpath($value) . '/';
    lmb_var_dir($real);
    echo "INFO: Var dir inited in {$real}\n";
}
 function save($cache, $contents)
 {
     $file = $this->_getFilePath($cache);
     $dir = dirname($file);
     //cache conflict
     if (basename($dir) == $this->cache_file) {
         return false;
     }
     lmbFs::mkdir($dir);
     lmbFs::safeWrite($file, $contents);
 }
Ejemplo n.º 9
0
 function setUp()
 {
     lmbToolkit::save();
     $this->toolkit = lmbToolkit::merge(new lmbConfTools());
     $this->application_configs_dir = lmb_var_dir() . '/app/settings';
     lmbFs::mkdir($this->application_configs_dir);
     $this->package_configs_dir = lmb_var_dir() . '/package/settings';
     lmbFs::mkdir($this->package_configs_dir);
     $tests_include_apth = $this->application_configs_dir . ';' . $this->package_configs_dir;
     $this->toolkit->setConfIncludePath($tests_include_apth);
 }
Ejemplo n.º 10
0
 protected function _loadCache()
 {
     $cache_dir = $this->_cache_dir;
     lmbFs::mkdir($cache_dir);
     $cache_file = $this->getCacheFile();
     if (!$this->_isCacheValid($cache_file)) {
         return false;
     }
     $this->import(unserialize(file_get_contents($cache_file)));
     return true;
 }
 function testSimpleIterate()
 {
     lmbFs::rm($this->dir);
     lmbFs::mkdir($this->dir);
     $it = new lmbFsRecursiveIterator($this->dir);
     $it->rewind();
     $this->_assertDotDir($it, __LINE__);
     $it->next();
     $this->_assertDotDir($it, __LINE__);
     $it->next();
     $this->assertFalse($it->valid());
     lmbFs::rm($this->dir);
 }
Ejemplo n.º 12
0
 function setUp()
 {
     $this->base_dir = lmb_var_dir() . '/tpl';
     $this->tpl_dir = $this->base_dir;
     $this->cache_dir = $this->base_dir . '/compiled';
     $this->tags_dir = dirname(__FILE__) . '/../../src/tags';
     $this->filters_dir = dirname(__FILE__) . '/../../src/filters';
     lmbFs::rm(lmb_var_dir());
     lmbFs::mkdir(lmb_var_dir());
     lmbFs::mkdir($this->base_dir);
     lmbFs::mkdir($this->tpl_dir);
     lmbFs::mkdir($this->cache_dir);
 }
 protected function _appendToFile($file_name, $title, $message, $stamp)
 {
     lmbFs::mkdir(dirname($file_name), 0775);
     $file_existed = file_exists($file_name);
     if ($fh = fopen($file_name, 'a')) {
         @flock($fh, LOCK_EX);
         $time = strftime("%b %d %Y %H:%M:%S", $stamp);
         $log_message = "========================= {$title} [{$time}]";
         $log_message .= "=========================\n" . $message;
         fwrite($fh, $log_message);
         @flock($fh, LOCK_UN);
         fclose($fh);
         if (!$file_existed) {
             chmod($file_name, 0664);
         }
     } else {
         throw new lmbFsException("Cannot open log file '{$file_name}' for writing" . PHP_EOL . "The web server must be allowed to modify the file." . PHP_EOL . "File logging for '{$file_name}' is disabled.");
     }
 }
 function setUp()
 {
     parent::setUp();
     lmbFs::mkdir(LIMB_VAR_DIR . '/tpl/tags/');
     lmbFs::mkdir(LIMB_VAR_DIR . '/tpl/tags/subfolder/');
 }
Ejemplo n.º 15
0
 function setUp()
 {
     $this->tmp_dir = LIMB_VAR_DIR . '/tmp_cmd/';
     lmbFs::mkdir($this->tmp_dir);
 }
 /**
  * @param lmbUri $dsn
  */
 function __construct($dsn)
 {
     parent::__construct($dsn);
     $this->_cache_dir = $this->dsn->getPath();
     lmbFs::mkdir($this->_cache_dir);
 }
Ejemplo n.º 17
0
    global $logger;
    $back_trace = new lmbBacktrace(10, 10);
    $error_str = " error: {$errstr}\nfile: {$errfile}\nline: {$errline}\nbacktrace:" . $back_trace->toString();
    $logger->log($error_str, "ERROR", $errno);
}
set_error_handler('write_error_in_log');
error_reporting(E_ALL);
ini_set('display_errors', true);
if ($argc < 2) {
    die('Usage: php cron_runner.php cron_job_file_path(starting from include_file_path)' . PHP_EOL);
}
$cron_job_file_path = $argv[1];
$logger = YaLogger::instance();
$lock_dir = LIMB_VAR_DIR . '/cron_job_lock/';
if (!file_exists($lock_dir)) {
    lmbFs::mkdir($lock_dir, 0777);
}
$name = array_shift(explode('.', basename($cron_job_file_path)));
$lock_file = $lock_dir . $name;
if (!file_exists($lock_file)) {
    file_put_contents($lock_file, '');
    chmod($lock_file, 0777);
}
$fp = fopen($lock_file, 'w');
if (!flock($fp, LOCK_EX + LOCK_NB)) {
    $logger->logConflict();
    return;
}
flock($fp, LOCK_EX + LOCK_NB);
try {
    lmb_require($cron_job_file_path);
Ejemplo n.º 18
0
 function getWc()
 {
     lmbFs::mkdir(LIMB_VAR_DIR . '/wc/');
     $shared_wc = $this->getSharedWc();
     if ($shared_wc) {
         return LIMB_VAR_DIR . '/wc/' . $shared_wc;
     } else {
         return LIMB_VAR_DIR . '/wc/' . $this->getName();
     }
 }
Ejemplo n.º 19
0
 protected function _makeDump()
 {
     $host = $this->db['host'];
     $user = $this->db['user'];
     $password = $this->db['password'];
     $database = $this->db['database'];
     $charset = $this->db['charset'];
     lmbFs::mkdir($this->getProjectDir() . '/base');
     $sql_schema = $this->getProjectDir() . '/base/schema.mysql';
     $sql_data = $this->getProjectDir() . '/base/data.mysql';
     //создаем дамп
     $this->mysql_dump_schema($host, $user, $password, $database, $charset, $sql_schema);
     $this->mysql_dump_data($host, $user, $password, $database, $charset, $sql_data);
 }
Ejemplo n.º 20
0
/**
 * @desc Create var folder
 */
function task_project_var_dir()
{
    $var_path = taskman_prop('PROJECT_DIR') . '/var';
    if (file_exists($var_path)) {
        taskman_msg("Var dir ({$var_path}) exists...\n");
        return;
    }
    lmb_require('limb/fs/src/lmbFs.class.php');
    lmbFs::mkdir($var_path);
    taskman_msg("Created var dir ({$var_path})...\n");
}
Ejemplo n.º 21
0
 function setUp()
 {
     $this->toolkit = lmbToolkit::save();
     lmbFs::rm(LIMB_VAR_DIR . '/tpl');
     lmbFs::mkdir(LIMB_VAR_DIR . '/tpl/compiled');
 }
Ejemplo n.º 22
0
 function setUp()
 {
     $this->tmp_dir = lmb_var_dir() . '/tmp_cmd/';
     lmbFs::mkdir($this->tmp_dir);
 }
 function _writeFile($file, $content = '')
 {
     lmbFs::mkdir(dirname($file));
     $fh = fopen($file, 'w');
     fwrite($fh, $content);
     fclose($fh);
 }
 protected function _saveToCache($dictionary, $file)
 {
     if (!$this->_isFileCachingOn()) {
         return;
     }
     $cache = $this->_getCacheFile($file);
     if (!is_dir($dir = dirname($cache))) {
         lmbFs::mkdir($dir);
     }
     file_put_contents($this->_getCacheFile($file), serialize($dictionary->getTranslations()), LOCK_EX);
 }
 function setUp()
 {
     lmbFs::mkdir(LIMB_VAR_DIR . '/translations');
 }
 function getCacheFile()
 {
     lmbFs::mkdir($this->_cache_dir);
     $cache_file = $this->_cache_dir . '/' . $this->_cache_name . '_locator.cache';
     return $cache_file;
 }
 function setUp()
 {
     lmbFs::rm(LIMB_VAR_DIR . '/tags/');
     lmbFs::mkdir(LIMB_VAR_DIR . '/tags/');
 }
Ejemplo n.º 28
0
 function testMkdirWithoutDirValue()
 {
     try {
         lmbFs::mkdir('');
         $this->fail();
     } catch (lmbFsException $e) {
     }
 }
Ejemplo n.º 29
0
 function setUp()
 {
     lmbFs::mkdir(lmb_var_dir() . '/tmp_ini');
 }
Ejemplo n.º 30
0
 static function writeFile($file, $data)
 {
     $dirname = dirname($file);
     lmbFs::mkdir($dirname);
     file_put_contents($file, $data);
 }