예제 #1
0
 protected function git_revision()
 {
     $rev = "";
     if (!($rev = Config::get('GIT_HEAD'))) {
         if (is_readable(WAX_ROOT . ".git/HEAD")) {
             $rev_ref = trim(substr(file_get_contents(WAX_ROOT . ".git/HEAD"), 5));
         }
         if (is_readable(WAX_ROOT . ".git/info/refs")) {
             $gresource = fopen(WAX_ROOT . ".git/info/refs", "r");
             while (($buffer = fgets($gresource, 4096)) !== false) {
                 if (strpos($buffer, $rev_ref)) {
                     $rev = substr($buffer, 0, 6);
                 }
             }
         } elseif (is_readable(WAX_ROOT . ".git/" . $rev_ref)) {
             $rev = substr(file_get_contents(WAX_ROOT . ".git/" . $rev_ref), 0, 6);
         }
         $rev = "?r={$rev}";
         Config::set('GIT_HEAD', $rev);
     }
     return $rev;
 }
예제 #2
0
파일: Config.php 프로젝트: phpwax/config
 /**
  * Loads a file from the config directory.
  * If path is absolute then load it in directly.
  * Detects readability and uses YAML or php where appropriate.
  *
  * @return void
  **/
 public static function load($config_file, $as = false)
 {
     if (strpos($config_file, "/") === FALSE) {
         $config_file = CONFIG_DIR . $config_file;
     }
     if (substr($config_file, -3) == "yml") {
         return self::load_yaml($config_file);
     }
     if (substr($config_file, -3) == "php") {
         return self::set(include $config_file);
     }
     if (substr($config_file, -3) == "ini") {
         $res = ConfigINI::parse($config_file, true);
         if ($as) {
             Config::set($as, $res);
         } else {
             Config::set($res);
         }
     }
 }