Exemplo n.º 1
0
 private function onHardlink()
 {
     $form = $this->formHardlink();
     if (false !== ($error = $form->validate($this->module))) {
         return $error;
     }
     $onsitename = Common::getPost('onsitename');
     $site = $this->site;
     $user = $this->user;
     require_once GWF_CORE_PATH . 'module/WeChall/WC_RegAt.php';
     require_once GWF_CORE_PATH . 'module/WeChall/WC_Freeze.php';
     if (false !== WC_RegAt::getRegatRow($user->getID(), $site->getID())) {
         return $this->module->error('err_already_linked', array($site->displayName()));
     }
     if (WC_Freeze::isUserFrozenOnSite($user->getID(), $site->getID())) {
         return $this->module->error('err_site_ban', array($site->displayName()));
     }
     if (false !== ($regat = WC_RegAt::getByOnsitename($site->getID(), $onsitename))) {
         if (false === ($user = $regat->getUser())) {
             return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
         } else {
             return $this->module->error('err_onsitename_taken', array(htmlspecialchars($onsitename), $site->displayName(), $user->displayUsername()));
         }
     }
     $entry = new WC_RegAt(array('regat_uid' => $user->getID(), 'regat_sid' => $site->getID(), 'regat_onsitename' => $onsitename, 'regat_onsitescore' => 0, 'regat_challcount' => 0, 'regat_options' => 0, 'regat_lastdate' => '', 'regat_linkdate' => GWF_Time::getDate(GWF_Date::LEN_DAY), 'regat_solved' => 0.0, 'regat_score' => 0, 'regat_langid' => 0, 'regat_tagbits' => 0, 'regat_onsiterank' => 0, 'regat_challsolved' => 0));
     if (false === $entry->insert()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (0 < ($percent = $form->getVar('percent'))) {
         $new_score = round($site->getOnsiteScore() * $percent / 100);
         $site->onUpdateUserB($user, $entry, $new_score, true, true);
     }
     return $this->module->message('msg_hardlinked', array($user->displayUsername(), $site->displayName(), GWF_HTML::display($onsitename)));
 }
Exemplo n.º 2
0
 /**
  * Link a site.
  * First we check if username/email exists on that site.
  * If so, we check if emails are the same.
  * If not, we send some email, else we just link.
  * @return unknown_type
  */
 private function onLinkSite()
 {
     $form = $this->getFormLink();
     if (false !== ($errors = $form->validate($this->module))) {
         return $errors;
     }
     $user = GWF_Session::getUser();
     $onsitename = Common::getPostString('onsitename', '');
     $onsitemail = Common::getPostString('password_email', '');
     if (false === ($site = WC_Site::getByID_Class(Common::getPost('siteid')))) {
         return $this->module->error('err_site');
     }
     if (false !== WC_RegAt::getRegatRow(GWF_Session::getUserID(), $site->getID())) {
         return $this->module->error('err_already_linked', array($site->displayName()));
     }
     if (!$site->isScored()) {
         return $this->module->error('err_site');
     }
     if (WC_Freeze::isUserFrozenOnSite(GWF_Session::getUserID(), $site->getID())) {
         return $this->module->error('err_site_ban', array($site->displayName()));
     }
     if ($site->isNoV1()) {
         if (!$site->isValidWarboxLink($user, $onsitename)) {
             return $this->module->error('err_warbox_nick');
         }
     }
     if (false === $site->isAccountValid($onsitename, $onsitemail)) {
         $key = $site->getVar('site_classname') === 'HTS' ? 'err_link_account_hts' : 'err_link_account';
         return $this->module->error($key, array($site->displayName()));
     }
     if (false !== ($regat = WC_RegAt::getByOnsitename($site->getID(), $onsitename))) {
         if (false === ($user = $regat->getUser())) {
             return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
         } else {
             return $this->module->error('err_onsitename_taken', array(htmlspecialchars($onsitename), $site->displayName(), $user->displayUsername()));
         }
     }
     if ($onsitemail !== $user->getValidMail()) {
         return $this->onLinkSiteMail($site, $user, $onsitename, $onsitemail);
     } else {
         return $this->onLinkSiteAfterMail($site, $user, $onsitename);
     }
 }