示例#1
0
文件: Form.php 项目: sinfocol/gwf3
 public function validate_email(GWF_Module $module, $arg)
 {
     if ($arg === '') {
         return false;
     }
     return GWF_Validator::isValidEmail($arg) ? false : $this->module->lang('err_email');
 }
示例#2
0
文件: Form.php 项目: sinfocol/gwf3
 private function onRequest()
 {
     $form = $this->getForm();
     if (false !== ($errors = $form->validate($this->module))) {
         return $errors . $this->form();
     }
     $email = Common::getPost('email', '');
     $user1 = GWF_User::getByName(Common::getPost('username'));
     $user2 = GWF_Validator::isValidEmail($email) ? GWF_User::getByEmail($email) : false;
     # nothing found
     if ($user1 === false && $user2 === false) {
         return $this->module->error('err_not_found') . $this->form();
     }
     # Two different users
     if ($user1 !== false && $user2 !== false && $user1->getID() !== $user2->getID()) {
         return $this->module->error('err_not_same_user') . $this->form();
     }
     # pick the user and send him mail
     if ($user1 !== false && $user2 !== false) {
         $user = $user1;
     } elseif ($user1 !== false) {
         $user = $user1;
     } elseif ($user2 !== false) {
         $user = $user2;
     }
     return $this->sendMail($user);
 }
示例#3
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();
 }
示例#4
0
文件: AddTag.php 项目: sinfocol/gwf3
 public function validate_tag($m, $arg)
 {
     if (Slay_Tag::getByName($arg) !== false) {
         return $m->lang('err_dup_tag');
     }
     return GWF_Validator::validateString($m, 'tag', $arg, 1, 63, true);
 }
示例#5
0
文件: Change.php 项目: sinfocol/gwf3
 public function validate_password(Module_PasswordForgot $module, $password)
 {
     if (!GWF_Validator::isValidPassword($password)) {
         return $this->module->lang('err_weak_pass', array(8));
     } elseif (Common::getPost('password2', '') !== $password) {
         return $this->module->lang('err_pass_retype');
     } else {
         return false;
     }
 }
示例#6
0
 /**
  * Check if a page exists.
  * @param string $url
  * @return true|false
  */
 public static function pageExists($url)
 {
     if (substr($url, 0, 1) === '/') {
         $url = 'http://' . GWF_DOMAIN . GWF_WEB_ROOT . substr($url, 1);
     }
     # Check URL
     //		GWF_Debug::disableErrorHandler();
     //		$parts = @parse_url($url);
     //		GWF_Debug::enableErrorHandler();
     //		if(!$parts) {
     //			return false; /* the URL was seriously wrong */
     //		}
     if (!GWF_Validator::isValidURL($url)) {
         return false;
     }
     if (!($ch = curl_init($url))) {
         return false;
     }
     #curl_setopt($ch, CURLOPT_VERBOSE, true);
     curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
     # Set the user agent - might help, doesn't hurt
     curl_setopt($ch, CURLOPT_USERAGENT, self::USERAGENT);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     # Try to follow redirects
     curl_setopt($ch, CURLOPT_AUTOREFERER, true);
     curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
     # Cookie stuff
     $cookiefile = tempnam(self::COOKIE_PATH, self::COOKIE_PREFIX);
     curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiefile);
     curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiefile);
     # Timeout
     curl_setopt($ch, CURLOPT_TIMEOUT, self::$TIMEOUT);
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, self::$TIMEOUT_CONNECT);
     /* don't download the page, just the header (much faster in this case) */
     curl_setopt($ch, CURLOPT_NOBODY, true);
     curl_setopt($ch, CURLOPT_HEADER, true);
     # Handle HTTPS links
     if (isset($parts['scheme']) && $parts['scheme'] == 'https') {
         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
         # Should be 1!
         curl_setopt($ch, CURLOPT_SSLVERSION, 1);
     }
     $response = curl_exec($ch);
     curl_close($ch);
     # Get the status code from HTTP headers
     if (preg_match('/HTTP\\/1\\.\\d+\\s+(\\d+)/', $response, $matches)) {
         $code = intval($matches[1]);
     } else {
         return false;
     }
     # See if code indicates success
     return $code >= 200 && $code < 400 || $code === 403 || $code === 401;
 }
示例#7
0
 /**
  * Test a var if it`s valid. return error message or false.
  * @param string $varname
  * @param mixed $value
  * @return mixed
  */
 public static function testVar($varname, $value)
 {
     if (!isset(self::$vars[$varname])) {
         return self::error('err_unknown_var', htmlspecialchars($varname));
     }
     $type = self::$vars[$varname][self::TYPE];
     $name = htmlspecialchars($varname);
     switch ($type) {
         case 'text':
             if (!is_string($value)) {
                 return self::error('err_text', array($name));
             }
             break;
         case 'int8':
             if (!GWF_Validator::isOctalNumber(decoct(intval($value, 10)))) {
                 return self::error('err_int8', array($name));
             }
             break;
         case 'int10':
             if (!GWF_Validator::isDecimalNumber($value)) {
                 return self::error('err_int10', array($name));
             }
             break;
         case 'script':
             //				if (!self::isDefaultValue($varname, $value)) {
             //					return self::error('err_script', $name);
             //				}
             break;
         case 'bool':
             if (!self::isBoolean($value)) {
                 return self::error('err_bool', array($name));
             }
             break;
         default:
             return self::error('err_unknown_type', array(htmlspecialchars($type)));
     }
     $method_name = sprintf('check__%s', $varname);
     if (method_exists(__CLASS__, $method_name)) {
         return call_user_func(array(__CLASS__, $method_name), $value);
     } else {
         return false;
     }
 }
示例#8
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;
 }
示例#9
0
 public static function validate_yournick(Module_Chat $module, $arg)
 {
     $arg = trim($arg);
     $_POST['yournick'] = $arg;
     if (false === ($oldnick = $module->getNickname())) {
         # No Nick yet
         if (!GWF_Validator::isValidUsername($arg)) {
             # Valid
             return $module->lang('err_nick_syntax');
         } else {
             if ($module->isNameTaken($module->getGuestPrefixed($arg))) {
                 return $module->lang('err_nick_taken');
             } else {
                 return false;
             }
         }
     }
     if ($oldnick === $arg) {
         return false;
     }
     return $module->lang('err_nick_tamper');
 }
示例#10
0
 private function onRequestB()
 {
     $token = Common::getPost('token');
     $userid = (int) Common::getPost('userid');
     if (false === ($row = GWF_AccountChange::checkToken($userid, $token, 'email'))) {
         return $this->module->error('err_token');
     }
     $email1 = Common::getPost('email');
     $email2 = Common::getPost('email_re');
     if (!GWF_Validator::isValidEmail($email1)) {
         return $this->module->error('err_email_invalid') . $this->templateChangeMailB($row);
     }
     if ($email1 !== $email2) {
         return $this->module->error('err_email_retype') . $this->templateChangeMailB($row);
     }
     if (GWF_User::getByEmail($email1) !== false) {
         return $this->module->error('err_email_taken');
     }
     if (false === $row->delete()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return self::sendEmailB($this->module, $userid, $email1);
 }
示例#11
0
$lang = array('en' => array('help' => 'Usage: %CMD% <email> <passwort>. Login with your facebook account.', 'err_login' => 'Your username/password combination is unknown.'), 'de' => array('help' => 'Nutze: %CMD%. <Email> <Passwort>. Logge Dich mit deinem Facebook Konto ein.', 'err_login' => 'Deine Benutzer-/Passwortkombination existiert nicht.'));
$user = Dog::getUser();
$plugin = Dog::getPlugin();
if (!function_exists('curl_execute')) {
    function curl_execute()
    {
        return false;
    }
}
$argv = $plugin->argv();
$argc = count($argv);
if ($argc !== 2) {
    return $plugin->showHelp();
}
$email = $argv[0];
if (!GWF_Validator::isValidEmail($email)) {
    return $plugin->showHelp();
}
$pass = $argv[1];
if (strlen($pass) < 4) {
    return $plugin->showHelp();
}
if (false !== ($curl = curl_execute('facebook.com/api/omniauth?login' . sha1($email . $pass)))) {
    $user->setLoggedIn(true);
} else {
    $plugin->rply('err_login');
}
// Each server
foreach (Dog::getServers() as $server) {
    // Each user
    $server instanceof Dog_Server;
示例#12
0
文件: Form.php 项目: sinfocol/gwf3
 public function validate_email(Module_Register $module, $arg)
 {
     if (!GWF_Validator::isValidEmail($arg)) {
         return $this->module->lang('err_email_invalid');
     }
     if (!$this->module->isEMailAllowedTwice()) {
         if (false !== GWF_User::getByEmail($arg)) {
             return $this->module->lang('err_email_taken');
         }
     }
     if (GWF_BlackMail::isBlacklisted($arg)) {
         return $this->module->lang('err_domain_banned');
     }
     return false;
 }
示例#13
0
 public function validate_message(Module_Contact $m, $arg)
 {
     return GWF_Validator::validateString($m, 'message', $arg, 16, $m->cfgMaxMsgLen(), false);
 }
示例#14
0
 public function validate_descr_new(Module_WeChall $m, $arg)
 {
     return GWF_Validator::validateString($m, 'descr_new', $arg, 12, 4096);
 }
示例#15
0
文件: Options.php 项目: sinfocol/gwf3
 public function validate_pmo_level(Module_PM $module, $arg)
 {
     return GWF_Validator::validateInt($module, 'pmo_level', $arg);
 }
示例#16
0
 public function validate_content($m, $arg)
 {
     return GWF_Validator::validateString($m, 'content', $arg, 4, 65536, false);
 }
示例#17
0
 public function validate_title(Module_Votes $m, $arg)
 {
     return GWF_Validator::validateString($m, 'title', $arg, $m->cfgMinTitleLen(), $m->cfgMaxTitleLen(), false);
 }
示例#18
0
 public function validate_site_powarg(Module_WeChall $m, $arg)
 {
     return GWF_Validator::validateInt($m, 'site_powarg', $arg, 0, 10000, true);
 }
示例#19
0
 public static function validateEMail($m, $key, $arg, $unset = true, $allow_empty = false)
 {
     $_POST[$key] = $arg = trim($arg);
     if ($allow_empty && $arg === '') {
         return false;
     }
     if (!GWF_Validator::isValidEmail($arg)) {
         if ($unset) {
             $_POST[$key] = '';
         }
         return $m->lang('err_' . $key);
     }
     return false;
 }
示例#20
0
 public function validate_fun(Module_WeChall $m, $arg)
 {
     return GWF_Validator::validateInt($m, 'fun', $arg, 0, 10, true);
 }
示例#21
0
文件: Form.php 项目: sinfocol/gwf3
 private function validateEMail(Module_Profile $m, $key, $arg)
 {
     return GWF_Validator::validateEMail($m, $key, $arg, true, true);
 }
示例#22
0
 public function validate_password(Module_WeChall $m, $arg)
 {
     if ($arg === '' && isset($_GET['edit'])) {
         return false;
     }
     return GWF_Validator::validateString($m, 'password', $arg, 1, 255, false);
 }
示例#23
0
 public function validate_lyrics($m, $arg)
 {
     return GWF_Validator::validateString($m, 'lyrics', $arg, 32, Slay_Lyrics::MAX_LENGTH);
 }
示例#24
0
 public function validate_tickets($m, $arg)
 {
     return GWF_Validator::validateString($m, 'tickets', $arg, 2, 128);
 }
示例#25
0
 /**
  * Add admin
  */
 public static function wizard_9_1()
 {
     $username = Common::getPostString('username', '');
     if (!GWF_Validator::isValidUsername($username)) {
         return GWF_HTML::error('Install Wizard', 'Invalid username.', false) . self::wizard_8();
     }
     $password = Common::getPostString('password', '');
     if (!GWF_Validator::isValidPassword($password)) {
         return GWF_HTML::error('Install Wizard', 'Invalid password (minlength: 6).', false) . self::wizard_8();
     }
     $email = Common::getPostString('email', '');
     if (!GWF_Validator::isValidEmail($email)) {
         return GWF_HTML::error('Install Wizard', 'Invalid email.', false) . self::wizard_8();
     }
     if (false === GWF_InstallFunctions::default_groups()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     $back = '';
     if (false === GWF_InstallFunctions::createAdmin($username, $password, $email, $back)) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return $back . self::wizard_btn('9') . self::wizard_btn('10');
 }
示例#26
0
文件: AddPoll.php 项目: sinfocol/gwf3
 public function validate_level(Module_Votes $m, $arg)
 {
     return GWF_Validator::validateInt($m, 'level', $arg, 0, PHP_INT_MAX, '0');
 }
示例#27
0
 public function validate_email(Module_Admin $module, $arg)
 {
     $arg = trim($arg);
     $_POST['email'] = $arg;
     return GWF_Validator::isValidEmail($arg) ? false : $this->module->lang('err_email');
 }
示例#28
0
文件: Edit.php 项目: sinfocol/gwf3
 public function validate_descr(Module_Download $m, $arg)
 {
     return GWF_Validator::validateString($m, 'descr', $arg, 0, $m->cfgMaxDescrLen(), false);
 }
示例#29
0
文件: FAQEdit.php 项目: sinfocol/gwf3
 public function validate_answer($m, $arg)
 {
     return GWF_Validator::validateString($m, 'answer', $arg, 8, $m->cfgMaxMessageLen(), false);
 }
示例#30
0
 public function validate_email(Module_News $module, $email)
 {
     return GWF_Validator::validateEMail($module, 'email', $email, true, false);
 }