Ejemplo n.º 1
0
 private function onCheckout(array $argv)
 {
     if (count($argv) < 3) {
         return $this->showRepoHelp('checkout');
     }
     $type = strtolower($argv[0]);
     if (!Dog_Repo::isValidType($type)) {
         return $this->error('err_type');
     }
     $url = $argv[1];
     if (!GWF_Validator::isValidURL($url) || !GWF_HTTP::pageExists($url)) {
         // 			return $this->error('err_url');
     }
     $name = $argv[2];
     if (!Dog_Repo::isNameValid($name)) {
         return $this->error('err_name_invalid');
     }
     if (Dog_Repo::repoExists($name, $url)) {
         return $this->error('err_dup');
     }
     $user = NULL;
     $pass = NULL;
     if (isset($argv[3])) {
         $user = $argv[3];
         $pass = isset($argv[4]) ? $argv[4] : '';
     }
     $repo = new Dog_Repo(array('repo_id' => '0', 'repo_type' => $type, 'repo_name' => $name, 'repo_url' => $url, 'repo_user' => $user, 'repo_pass' => $pass, 'repo_options' => '0'));
     if (!$repo->insert()) {
         return $this->error('err_database');
     }
     $this->rply('msg_checking_out', array($name));
     $repo->checkout();
 }
Ejemplo n.º 2
0
 public static function validate_href(Module_Links $module, $arg, $check_dups)
 {
     $arg = trim($arg);
     $_POST['link_href'] = $arg;
     if (strlen($arg) > $module->cfgMaxUrlLen()) {
         return $module->lang('err_url_long', array($module->cfgMaxUrlLen()));
     }
     if (false === GWF_Validator::isValidURL($arg)) {
         return $module->lang('err_url');
     }
     if (false === GWF_HTTP::pageExists($arg)) {
         return $module->lang('err_url_down');
     }
     if ($check_dups === true) {
         if (false !== GWF_Links::getByHREF($arg)) {
             return $module->lang('err_url_dup');
         }
     }
     return false;
 }
Ejemplo n.º 3
0
 private static function checkLinkDown(Module_Links $module, GWF_Links $link)
 {
     # Get HREF
     $href = $link->getVar('link_href');
     if (strpos($href, '/') === 0) {
         $href = 'http://' . GWF_DOMAIN . GWF_WEB_ROOT . substr($href, 1);
     }
     if (GWF_HTTP::pageExists($href)) {
         self::notice("Checking {$href} ... UP");
         $link->saveVar('link_downcount', 0);
         $link->saveOption(GWF_Links::DOWN | GWF_Links::DEAD, false);
     } else {
         self::notice("Checking {$href} ... DOWN");
         $link->increase('link_downcount', 1);
         $bits = GWF_Links::DOWN;
         $count = $link->getVar('link_downcount');
         if ($count > GWF_Links::DOWNCOUNT_DEAD) {
             $bits |= GWF_Links::DEAD;
         }
         $link->saveOption($bits, true);
     }
     $link->saveVar('link_lastcheck', time());
 }
Ejemplo n.º 4
0
 public function on_repo_checkout_Pb()
 {
     GDO::table('Dog_Repo')->createTable(true);
     GDO::table('Dog_RepoSubscribes')->createTable(true);
     GDO::table('Dog_RepoUsers')->createTable(true);
     GWF_File::removeDir(Dog_Repo::baseDir(), false, true, true);
     $argv = $this->argv();
     $argc = count($argv);
     if ($argc !== 3) {
         return $this->showHelp('checkout');
     }
     $type = $argv[1];
     if (!Dog_Repo::isValidType($type)) {
         return $this->rply('err_software');
     }
     $url = @parse_url($argv[2]);
     if (!isset($url['scheme'])) {
         return $this->rply('err_url', $url);
     }
     $url = $argv[2];
     if (!GWF_HTTP::pageExists($url)) {
         return $this->rply('err_connect');
     }
     $name = $argv[0];
     if (!Dog_Repo::isValidName($name)) {
         return $this->rply('err_repo_name');
     }
     if (Dog_Repo::exists($name)) {
         return $this->rply('err_repo_taken');
     }
     if (!GWF_File::createDir(Dog_Repo::repoDir($name))) {
         return $this->rply('err_create_dir');
     }
     if (!($repo = Dog_Repo::create($url, $name, $type))) {
         return Dog::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     call_user_func(array($this, 'checkout_' . $type), $repo);
 }
Ejemplo n.º 5
0
 public static function validateURL($m, $key, $arg, $allow_empty = false, $unset = true)
 {
     $_POST[$key] = $arg = trim($arg);
     if ($arg === '' && $allow_empty === true) {
         return false;
     }
     if (GWF_HTTP::pageExists($arg)) {
         return false;
     }
     # Unset
     if ($unset === true) {
         $_POST[$key] = '';
     } elseif ($unset !== false) {
         $_POST[$key] = $unset;
     }
     # return error msg
     return $m->lang('err_' . $key);
 }
Ejemplo n.º 6
0
 public function validate_url(Module_Guestbook $m, $arg)
 {
     $arg = $_POST['url'] = trim($arg);
     if ($arg === '') {
         return false;
     }
     if (!GWF_Validator::isValidURL($arg)) {
         return $m->lang('err_gbm_url');
     }
     if (!GWF_HTTP::pageExists($arg)) {
         return $m->lang('err_gbm_url');
     }
     return false;
 }