Пример #1
0
function renewlog($arrline)
{
    //ログ更新	入力:配列
    global $gzlog;
    if (LOCKEY == 1) {
        lock_dir(LOCK) or lock_error();
    }
    if (LOCKEY == 3) {
        m_lock(LOGFILE, true);
        m_lock(LOGFILE) or lock_error();
    }
    if (filesize(LOGFILE)) {
        copy(LOGFILE, LOGFILE . '.bak');
    } else {
        if (file_exists(LOGFILE . '.bak')) {
            rename(LOGFILE . '.bak', LOGFILE . '.bak2');
        }
    }
    $rp = $gzlog ? gzopen(LOGFILE, "w") : fopen(LOGFILE, "w");
    if (LOCKEY >= 2) {
        @flock($rp, 2);
    }
    set_file_buffer($rp, 0);
    fputs($rp, implode("", $arrline));
    @ftruncate($rp, ftell($rp));
    if (!$gzlog) {
        fclose($rp);
    } else {
        gzclose($rp);
    }
    if (LOCKEY == 1) {
        unlock_dir(LOCK);
    }
    if (LOCKEY == 3) {
        m_lock(LOGFILE, false);
    }
}
Пример #2
0
function old_category_load($id, $param=array()) {
  global $lists_dir;

  if($state=category_check_state()!==true) {
    return array('status'=>$state);
  }

  lock_dir($lists_dir);

  if($param[branch]) {
    chdir($lists_dir);
    system("git checkout $param[branch]");
    system("git rebase $param[version]");

    $content=file_get_contents("$lists_dir/$id.xml");

    $version=category_version();
    return $content;
  }
  elseif($param[version]) {
    chdir($lists_dir);
    $p=popen("git show $param[version]:$id.xml", "r");
    while($r=fgets($p)) {
      $content.=$r;
    }
    pclose($p);
    $version=$param[version];
  }
  else {
    if(!file_exists("$lists_dir/$id.xml")) {
      unlock_dir($lists_dir);
      print "File $id not found!\n";
      exit;
    }

    $content=file_get_contents("$lists_dir/$id.xml");
    $version=category_version();
  }

  $file=new DOMDocument();
  $file->loadXML($content);

  $l=$file->getElementsByTagName("category");
  for($i=0; $i<$l->length; $i++) {
    $l->item($i)->setAttribute("version", $version);
  }

  unlock_dir($lists_dir);
  return $file->saveXML();
}
Пример #3
0
  function unlock() {
    if(!$this->is_sane) {
      return array("status"=>"Git directory is not in sane state");
    }

    unlock_dir("{$this->path}");
  }