예제 #1
0
파일: Pay2.php 프로젝트: sinfocol/gwf3
 private function templatePay(Module_PaymentBank $module, GWF_Order $order)
 {
     if (false === $order->saveVar('order_status', GWF_Order::ORDERED)) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     $tVars = array('lang' => $module->loadLangGWF(), 'order_c' => $order);
     return $module->templatePHP('pay2.php', $tVars);
     //
     //		$module2 = $order->getOrderModule();
     //		$module2->onLoadLanguage();
     //		$gdo = $order->getOrderData();
     //		$user = $order->getUser();
     //		$sitename = $module->getSiteName();
     //
     //		$action = GWF_WEB_ROOT.'index.php?mo=PaymentBank&me=Pay2';
     //		$hidden = GWF_Form::hidden('gwf_token', $order->getOrderToken());
     //		$buttons = Module_Payment::tinyform('Bank Transfer', 'img/'.GWF_ICON_SET.'buy_bank.png', $action, $hidden);
     //
     //		$lang = $module->loadLangGWF();
     //
     //		$tVars = array(
     //			'lang' => $lang,
     //			'user' => $user,
     //			'order_c' => $order,
     //			'order' => Module_Payment::displayOrder3S($module2, $order, $gdo, $user, $sitename, $buttons),
     //		);
     //		return $module->templatePHP('pay.php', $tVars);
 }
예제 #2
0
파일: WCSite_VH.php 프로젝트: sinfocol/gwf3
 public function parseStats($url)
 {
     if (false === ($result = GWF_HTTP::getFromURL($url, false))) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     $stats = explode(':', $result);
     if (count($stats) !== 7) {
         //			if ($result === '0') {
         //				return array(0, 0);
         //			}
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     # username:rank:score:maxscore:challssolved:challcount:usercount
     $uname = $stats[0];
     $rank = intval($stats[1]);
     $onsitescore = intval($stats[2]);
     $maxscore = intval($stats[3]);
     $challssolved = intval($stats[4]);
     $challcount = intval($stats[5]);
     $usercount = intval($stats[6]);
     if ($maxscore === 0 || $challcount === 0 || $usercount === 0) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     return array($onsitescore, $rank, $challssolved, $maxscore, $usercount, $challcount);
 }
예제 #3
0
 public function onMarkSolved(GWF_HelpdeskTicket $ticket, GWF_HelpdeskMsg $message)
 {
     if (false === $ticket->saveVars(array('hdt_status' => 'solved'))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return $this->module->message('msg_solve_solved');
 }
예제 #4
0
 public static function write($image, $fontfile, $x, $y, $text, $color, $maxwidth, $size = 11, $spacingx = 2, $spacingy = 2, $mx = 1, $my = 1, $angle = 0)
 {
     if (!Common::isFile($fontfile)) {
         echo GWF_HTML::err('ERR_FILE_NOT_FOUND', array(htmlspecialchars($fontfile)));
         return false;
     }
     $dim = GWF_GDText::getFontSize($fontfile, $size, $angle);
     $fontwidth = $dim->w;
     $fontheight = $dim->h;
     if ($maxwidth != NULL) {
         // 			die(''.$maxwidth);
         $maxcharsperline = floor($maxwidth / $fontwidth);
         $text = wordwrap($text, $maxcharsperline, "\n", 1);
         // 			die($text);
     }
     // 		die(var_dump($color));
     $lines = explode("\n", $text);
     $x += $mx;
     $y += $my;
     foreach ($lines as $line) {
         $y += $fontheight + $spacingy;
         imagettftext($image, $size, $angle, $x, $y, $color, $fontfile, $line);
     }
     return true;
 }
예제 #5
0
파일: ShowError.php 프로젝트: sinfocol/gwf3
 private function templateError()
 {
     $module = $this->module;
     $module instanceof Module_GWF;
     $codes = $module->lang('ERR_HTTP');
     # Get the error page
     $code = Common::getGetString('code', '0');
     if (false === isset($codes[$code])) {
         return GWF_HTML::err('ERR_NO_PERMISSION');
     }
     @header($_SERVER['SERVER_PROTOCOL'] . ' ' . $code . ' ' . $codes[$code]);
     # Generate template
     $tVars = array('code' => $code, 'file' => GWF_HTML::error(GWF_SITENAME, $module->getLang()->langA('ERR_HTTP', $code, array(htmlspecialchars($_SERVER['REQUEST_URI']))), false));
     $template = $module->template($this->_tpl, $tVars);
     # Is the request blacklisted?
     foreach (preg_split('/[,;]/', $module->cfgBlacklist()) as $pattern) {
         if (false !== strpos($_SERVER['REQUEST_URI'], $pattern)) {
             # Do not log and email the request
             return $template;
         }
     }
     $message = self::getMessage($code);
     # Mail it?
     if (1 === preg_match("/(?:^|[,;]){$code}(?:\$|[,;])/", $module->cfgMail())) {
         self::errorMail($code, $message);
     }
     # Log it?
     if (1 === preg_match("/(?:^|[,;]){$code}(?:\$|[,;])/", $module->cfgLog())) {
         GWF_Log::logHTTP($message);
     }
     return $template;
 }
예제 #6
0
파일: VotePoll.php 프로젝트: sinfocol/gwf3
 private function onVote(GWF_VoteMulti $poll, $user)
 {
     $opts = Common::getPostArray('opt', array());
     $taken = array();
     $max = $poll->getNumChoices();
     foreach ($opts as $i => $stub) {
         $i = (int) $i;
         if ($i < 1 || $i > $max) {
             continue;
         }
         if (!in_array($i, $taken, true)) {
             $taken[] = $i;
         }
     }
     $count = count($taken);
     //		if ($count === 0) {
     //			return $this->module->error('err_no_options');
     //		}
     if (!$poll->isMultipleChoice() && $count !== 1) {
         return $this->module->error('err_no_multi');
     }
     if (false === $poll->onVote($user, $taken)) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return $this->module->message('msg_voted', array(htmlspecialchars(GWF_Session::getLastURL())));
 }
예제 #7
0
 public function parseStats($url)
 {
     if (false === ($result = GWF_HTTP::getFromURL($url, false))) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     $result = str_replace("", '', $result);
     # BOM
     $result = trim($result);
     $stats = explode(":", $result);
     if (count($stats) !== 7) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     $i = 0;
     $username = $stats[$i++];
     $rank = intval($stats[$i++]);
     $onsitescore = intval($stats[$i++]);
     $onsitescore = Common::clamp($onsitescore, 0);
     $maxscore = intval($stats[$i++]);
     $challssolved = intval($stats[$i++]);
     $challcount = intval($stats[$i++]);
     $usercount = intval($stats[$i++]);
     if ($maxscore === 0 || $challcount === 0 || $usercount === 0) {
         return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName())));
     }
     return array($onsitescore, $rank, $challssolved, $maxscore, $usercount, $challcount);
 }
예제 #8
0
 public function onAssign(GWF_HelpdeskTicket $ticket, GWF_User $user)
 {
     if (false === $ticket->saveVars(array('hdt_worker' => $user->getID(), 'hdt_status' => 'working'))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return $this->module->message('msg_assigned', array($ticket->getID(), $user->displayUsername()));
 }
예제 #9
0
파일: Welcome.php 프로젝트: sinfocol/gwf3
 private function welcome($first_time)
 {
     if (false === ($user = GWF_Session::getUser())) {
         return GWF_HTML::err('ERR_LOGIN_REQUIRED');
     }
     require_once GWF_CORE_PATH . 'module/Login/GWF_LoginHistory.php';
     GWF_Hook::call(GWF_Hook::LOGIN_AFTER, $user, array(GWF_Session::getOrDefault('GWF_LOGIN_BACK', GWF_WEB_ROOT)));
     $fails = GWF_Session::getOrDefault('GWF_LOGIN_FAILS', 0);
     GWF_Session::remove('GWF_LOGIN_FAILS');
     if ($fails > 0) {
         $fails = $this->module->lang('err_failures', array($fails));
     } else {
         $fails = '';
     }
     $href_hist = $this->module->getMethodURL('History');
     $username = $user->display('user_name');
     if (false !== ($ll = GWF_LoginHistory::getLastLogin($user->getID()))) {
         $last_login = $this->module->lang('msg_last_login', array($ll->displayDate(), $ll->displayIP(), $ll->displayHostname(), $href_hist));
         $welcome = $this->module->lang('welcome_back', array($username, $ll->displayDate(), $ll->displayIP()));
     } else {
         $last_login = '';
         $welcome = $this->module->lang('welcome', array($username));
     }
     $tVars = array('welcome' => $welcome, 'fails' => $fails, 'last_login' => $last_login, 'href_history' => $href_hist);
     return $this->module->template('welcome.tpl', $tVars);
 }
예제 #10
0
파일: Button.php 프로젝트: sinfocol/gwf3
 private function imageButton()
 {
     $cs = $this->size;
     $cx = $cy = round($this->size / 2);
     if (false === ($image = imagecreatetruecolor($cs, $cs))) {
         # FIXME: {gizmore} define in bootstrap? check if function exists?
         return GWF_HTML::err('ERR_GENERAL');
     }
     imagealphablending($image, true);
     $background = imagecolorallocatealpha($image, 0x0, 0x0, 0x0, 0x0);
     imagecolortransparent($image, $background);
     $color = $this->getColor($image);
     $white = imagecolorallocate($image, 0xff, 0xff, 0xff);
     imagefilledellipse($image, $cx, $cy, $cs, $cs, $white);
     imagefilledellipse($image, $cx, $cy, $cs - 1, $cs - 1, $color);
     header('Content-Type: image/' . $this->ext);
     switch ($this->ext) {
         case 'png':
             imagepng($image);
             break;
         case 'gif':
             imagegif($image);
             break;
         case 'jpg':
             imagejpeg($image);
             break;
         default:
             return GWF_HTML::err('ERR_GENERAL', array(__FILE__, __LINE__));
     }
     imagedestroy($image);
     die(0);
 }
예제 #11
0
파일: Warbox.php 프로젝트: sinfocol/gwf3
 public function execute()
 {
     $this->module->includeClass('WC_Warbox');
     $this->module->includeClass('WC_Warflag');
     $this->module->includeClass('WC_WarToken');
     $this->module->includeClass('sites/warbox/WCSite_WARBOX');
     # CHECK TOKEN
     if (isset($_GET['CHECK'])) {
         $_GET['ajax'] = 1;
         if (false === ($username = Common::getGetString('username', false))) {
             return GWF_HTML::err('ERR_PARAMETER', array('username'));
         }
         if (false === ($token = Common::getGetString('token', false))) {
             return GWF_HTML::err('ERR_PARAMETER', array('token'));
         }
         return WC_WarToken::isValidWarToken($username, $token) ? '1' : '0';
     }
     # GET CONFIG
     if (isset($_GET['CONFIG'])) {
         return $this->genConfig();
     }
     if (!GWF_Session::isLoggedIn()) {
         return GWF_HTML::err('ERR_LOGIN_REQUIRED');
     }
     # GEN AND SHOW
     return $this->templateToken();
 }
예제 #12
0
파일: Ajax.php 프로젝트: sinfocol/gwf3
 private function onPost($nickname, $target, $message)
 {
     # Validate the crap!
     if (false !== ($error = GWF_ChatValidator::validate_yournick($this->module, $nickname))) {
         return $error;
     }
     if (false !== ($error = GWF_ChatValidator::validate_target($this->module, $target))) {
         $error;
     }
     if (false !== ($error = GWF_ChatValidator::validate_message($this->module, $message))) {
         return $error;
     }
     # Post it!
     $oldnick = $this->module->getNickname();
     $sender = Common::getPost('yournick', $oldnick);
     $target = trim($target);
     $message = str_replace("\n", '<br/>', Common::getPost('message'));
     if ($oldnick === false) {
         $sender = $this->module->getGuestPrefixed($sender);
         $this->module->setGuestNick($sender);
     } else {
         $sender = $oldnick;
     }
     if (false === GWF_ChatMsg::newMessage($sender, $target, $message)) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return '1';
 }
예제 #13
0
 protected static function err($key, $args = null)
 {
     $message = GWF_HTML::langISO('en', $key, $args);
     GWF_Log::logError($message);
     self::reply($message);
     return false;
 }
예제 #14
0
파일: ShowUsers.php 프로젝트: sinfocol/gwf3
 public function execute()
 {
     if (false === ($group = GWF_Group::getByID(Common::getGet('gid')))) {
         return $this->module->error('err_unk_group');
     }
     if ($group->isOptionEnabled(GWF_Group::VISIBLE_MEMBERS)) {
     } else {
         switch ($group->getVisibleMode()) {
             case GWF_Group::VISIBLE:
                 break;
             case GWF_Group::COMUNITY:
                 if (!GWF_Session::isLoggedIn()) {
                     return GWF_HTML::err('ERR_NO_PERMISSION');
                 }
                 break;
             case GWF_Group::HIDDEN:
             case GWF_Group::SCRIPT:
                 if (!GWF_User::isInGroupS($group->getVar('group_name'))) {
                     return $this->module->error('err_not_invited');
                 }
                 break;
             default:
                 return GWF_HTML::err('ERR_GENERAL', array(__FILE__, __LINE__));
         }
     }
     return $this->templateUsers($group);
 }
예제 #15
0
 private function onAdd(Dog_User $user, $url)
 {
     if (false !== ($link = Dog_Link::getByURL($url))) {
         return true;
     }
     if (false === ($description = $this->getDescription($url))) {
         Dog_Log::error('Mod_Link::onAdd() failed. URL: ' . $url);
         return false;
     }
     $type = $description[0];
     $description = $description[1];
     switch ($type) {
         case 'image':
             if (false === ($link = Dog_Link::insertImage($user->getID(), $url, $description))) {
                 GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
                 return;
             }
             break;
         case 'html':
             if (false === ($link = Dog_Link::insertLink($user->getID(), $url, $description))) {
                 GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
                 return;
             }
             break;
         default:
             echo "UNKNOWN TYPE: {$type}\n";
             return;
     }
     Dog_Log::user($user, sprintf('Inserted Link %s (ID:%d)', $url, $link->getID()));
 }
예제 #16
0
function Upgrade_Slaytags_1_01(Module_Slaytags $module)
{
    GWF_Website::addDefaultOutput(GWF_HTML::message('Slaytags', "BPM and Key"));
    $songs = GDO::table('Slay_Song');
    $songs->createColumn('ss_bpm');
    $songs->createColumn('ss_key');
}
예제 #17
0
파일: SiteAdd.php 프로젝트: sinfocol/gwf3
 public function onAddSite()
 {
     $form = $this->getForm();
     if (false !== ($error = $form->validate($this->module))) {
         return $error . $this->templateSiteAdd();
     }
     $site = new WC_Site(array('site_status' => 'wanted', 'site_name' => $form->getVar('site_name'), 'site_classname' => $form->getVar('site_classname'), 'site_country' => 0, 'site_language' => 0, 'site_joindate' => GWF_Time::getDate(GWF_Date::LEN_SECOND), 'site_launchdate' => '', 'site_authkey' => GWF_Random::randomKey(32), 'site_xauthkey' => GWF_Random::randomKey(32), 'site_irc' => '', 'site_url' => '', 'site_url_mail' => '', 'site_url_score' => '', 'site_url_profile' => '', 'site_score' => 0, 'site_basescore' => 0, 'site_avg' => 0, 'site_vote_dif' => 0, 'site_vote_fun' => 0, 'site_challcount' => 0, 'site_usercount' => 0, 'site_visit_in' => 0, 'site_visit_out' => 0, 'site_options' => 0, 'site_boardid' => 0, 'site_threadid' => 0, 'site_tags' => ''));
     if (false === $site->insert()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     Module_WeChall::includeVotes();
     if (false === $site->onCreateVotes()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     Module_WeChall::includeForums();
     if (false === $site->onCreateBoard()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === $site->onCreateThread($this->module)) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     require_once GWF_CORE_PATH . 'module/WeChall/WC_SiteDescr.php';
     if (false === WC_SiteDescr::insertDescr($site->getID(), 1, 'Please edit me :)')) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return $this->module->message('msg_site_added');
 }
예제 #18
0
 public static function validate_tags(Module_Links $module, $arg)
 {
     $errors = array();
     $new = 0;
     $arg = explode(',', trim($arg));
     $taken = array();
     $minlen = 3;
     $maxlen = $module->cfgMaxTagLen();
     foreach ($arg as $tag) {
         $tag = trim($tag);
         if (strlen($tag) === 0) {
             continue;
         }
         if (false === GWF_LinksTag::getByName($tag)) {
             if (self::isValidTagName($tag, $minlen, $maxlen)) {
                 $taken[] = $tag;
                 $new++;
             } else {
                 $errors[] = $module->lang('err_tag', array(GWF_HTML::display($tag), $minlen, $maxlen));
             }
         } else {
             $taken[] = $tag;
         }
     }
     if (count($taken) === 0) {
         $errors[] = $module->lang('err_no_tag');
     }
     $_POST['link_tags'] = implode(',', $taken);
     if (count($errors) === 0) {
         return false;
     }
     return implode('<br/>', $errors);
 }
예제 #19
0
 public static function getDescription($siteid)
 {
     $siteid = (int) $siteid;
     $browser_lid = GWF_Language::getCurrentID();
     if (false === ($result = GDO::table('WC_Site')->selectAll('site_desc_lid, site_desc_txt', "site_desc_sid={$siteid} AND (site_desc_lid= {$browser_lid} OR site_desc_lid=site_descr_lid)", '', array('description'), 2, 0, GDO::ARRAY_N))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     //		$sites = GWF_TABLE_PREFIX.'wc_site';
     //		$descr = GWF_TABLE_PREFIX.'wc_site_descr';
     //		$db = gdo_db();
     //
     //		$query = "SELECT site_desc_lid, site_desc_txt FROM $sites JOIN $descr ON site_desc_sid=site_id WHERE site_desc_sid=$siteid AND (site_desc_lid=$browser_lid OR site_desc_lid=site_descr_lid)";
     //
     //		if (false === ($result = $db->queryAll($query, false))) {
     //			return '';
     //		}
     //
     if (count($result) === 2) {
         if ($result[0][0] === $browser_lid) {
             return $result[0][1];
         } else {
             return $result[1][1];
         }
     } else {
         return $result[0][1];
     }
 }
예제 #20
0
 public static function display(GWF_Module $module, GDO $gdo, $user, $sortURL, $conditions = '', $ipp = 25, $pageURL = false, $joins = NULL)
 {
     $fields = $gdo->getSortableFields($user);
     $headers = self::getGDOHeaders2($module, $gdo, $user, $sortURL);
     $nItems = $gdo->countRows($conditions);
     $nPages = GWF_PageMenu::getPagecount($ipp, $nItems);
     $page = Common::clamp(intval(Common::getGet('page', 1)), 1, $nPages);
     $orderby = self::getMultiOrderBy($gdo, $user);
     $from = GWF_PageMenu::getFrom($page, $ipp);
     $i = 0;
     $data = array();
     if (false === ($result = $gdo->select('*', $conditions, $orderby, $joins, $ipp, $from))) {
         echo GWF_HTML::err(ERR_DATABASE, __FILE__, __LINE__);
         return false;
     }
     while (false !== ($row = $gdo->fetch($result, GDO::ARRAY_O))) {
         $row instanceof GWF_Sortable;
         $data[$i] = array();
         foreach ($fields as $field) {
             $data[$i][] = $row->displayColumn($module, $user, $field);
         }
         $i++;
     }
     $gdo->free($result);
     if ($pageURL === false) {
         $pageURL = '';
     } elseif ($pageURL === true) {
         $pageURL = str_replace(array('%BY%', '%DIR%'), array(urlencode(Common::getGet('by')), urlencode(Common::getGet('dir'))), $sortURL);
         $pageURL .= '&page=%PAGE%';
     }
     $pagemenu = $pageURL === '' ? '' : GWF_PageMenu::display($page, $nPages, $pageURL);
     return $pagemenu . self::display2($headers, $data) . $pagemenu;
 }
예제 #21
0
파일: index.php 프로젝트: sinfocol/gwf3
function wccgpg_doit(WC_Challenge $chall, $user)
{
    if ($user === false) {
        echo GWF_HTML::error('GPG', $chall->lang('err_login'), false);
        return;
    }
    if (!$user->hasValidMail()) {
        echo GWF_HTML::error('GPG', $chall->lang('err_no_mail'));
        return;
    }
    $receiver = $user->getValidMail();
    if (!function_exists('gnupg_init')) {
        echo GWF_HTML::error('GPG', $chall->lang('err_server'));
        return;
    }
    if (false === ($fingerprint = GWF_PublicKey::getFingerprintForUser($user))) {
        $url = GWF_WEB_ROOT . 'account';
        echo GWF_HTML::error('GPG', $chall->lang('err_no_gpg', $url), false);
        return;
    }
    $solution = WC_CryptoChall::generateSolution('OHOYOUGOTGPG!', true, false);
    $mail = new GWF_Mail();
    $mail->setSubject($chall->lang('mail_s'));
    $mail->setSender(GWF_BOT_EMAIL);
    $mail->setReceiver($receiver);
    $mail->setBody($chall->lang('mail_b', array($user->displayUsername(), $solution)));
    if (false === $mail->sendToUser($user)) {
        echo GWF_HTML::err('ERR_MAIL_SENT');
    } else {
        echo GWF_HTML::message('GPG', $chall->lang('msg_mail_sent', array(htmlspecialchars($receiver))));
    }
}
예제 #22
0
 public static function deliver(Module_PM $module, GWF_PM $pm)
 {
     if (false === ($pmo = GWF_PMOptions::getPMOptions($pm->getReceiver()))) {
         return 0;
     }
     if (!$pmo->isOptionEnabled(GWF_PMOptions::EMAIL_ON_PM)) {
         return 0;
     }
     $sender = $pm->getSender();
     $receiver = $pm->getReceiver();
     if ('' === ($rec = $receiver->getValidMail())) {
         return 0;
     }
     $sendername = $sender->getID() !== '0' ? $sender->display('user_name') : GWF_HTML::langUser($receiver, 'guest');
     $email = new GWF_Mail();
     $email->setSender($module->cfgEmailSender());
     $email->setReceiver($rec);
     $email->setSubject($module->langUser($receiver, 'mail_subj', array($sendername)));
     $autofolder = sprintf('index.php?mo=PM&me=AutoFolder&pmid=%s&uid=%s&token=%s', $pm->getID(), $receiver->getID(), $pm->getHashcode());
     $autofolder = Common::getAbsoluteURL($autofolder);
     $autofolder = GWF_HTML::anchor($autofolder, $autofolder);
     $delete = sprintf('index.php?mo=PM&me=Delete&pmid=%s&uid=%s&token=%s', $pm->getID(), $receiver->getID(), $pm->getHashcode());
     $delete = Common::getAbsoluteURL($delete);
     $delete = GWF_HTML::anchor($delete, $delete);
     $email->setBody($module->langUser($receiver, 'mail_body', array($receiver->displayUsername(), $sendername, $pm->display('pm_title'), $pm->display('pm_message'), $autofolder, $delete)));
     if (false === $email->sendToUser($receiver)) {
         return -4;
     }
     return 1;
 }
예제 #23
0
 public function execute()
 {
     if (false === ($user = GWF_User::getByName(Common::getGet('username')))) {
         return GWF_HTML::err('ERR_UNKNOWN_USER');
     }
     return $this->templateHistory($user);
 }
예제 #24
0
파일: SendMail.php 프로젝트: sinfocol/gwf3
 private function send(GWF_User $user)
 {
     $form = $this->form($user);
     if (false !== ($errors = $form->validate($this->module))) {
         return $errors . $this->template($user);
     }
     $u = GWF_User::getStaticOrGuest();
     $sendermail = $u->getValidMail();
     if ($sendermail === '') {
         $sendermail = Common::getPost('email');
     }
     if ($sendermail === '') {
         $sendermail = GWF_HTML::lang('unknown');
     }
     $sendermail = GWF_HTML::display($sendermail);
     $mail = new GWF_Mail();
     $mail->setSender(GWF_BOT_EMAIL);
     $mail->setReceiver($user->getValidMail());
     $mail->setReply($sendermail);
     $mail->setSubject($this->module->langUser($user, 'mail_subj_mail', $sendermail));
     $mail->setBody($this->module->langUser($user, 'mail_subj_body', array($user->displayUsername(), $sendermail, GWF_Message::display($_POST['message']))));
     if (false === $mail->sendToUser($user)) {
         return GWF_HTML::err('ERR_MAIL_SENT');
     }
     return $this->module->message('msg_mailed', array($user->displayUsername()));
 }
예제 #25
0
파일: Ranking.php 프로젝트: sinfocol/gwf3
 private function templateRankingU($username)
 {
     if (false === ($user = GWF_User::getByName($username))) {
         return GWF_HTML::err('ERR_UNKNOWN_USER');
     }
     return $this->templateRanking($user);
 }
예제 #26
0
파일: Staff.php 프로젝트: sinfocol/gwf3
 private function onApprove($lid, $approve)
 {
     if (false === ($link = GWF_Links::getByID($lid))) {
         return $this->module->error('err_link');
     }
     if (!$link->isInModeration()) {
         return $this->module->error('err_approved');
     }
     if ($link->getToken() !== Common::getGet('token')) {
         return $this->module->error('err_token');
     }
     if ($approve) {
         if (false !== ($error = $link->insertTags($this->module))) {
             return $error;
         }
         if (false === $link->saveOption(GWF_Links::IN_MODERATION, false)) {
             return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
         }
         if (false === $link->setVotesEnabled(true)) {
             return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
         }
     } else {
         if (false !== ($error = $link->deleteLink($this->module))) {
             return $error;
         }
     }
     return $this->module->message($approve ? 'msg_approved' : 'msg_deleted');
 }
예제 #27
0
 public function execute()
 {
     if (false === ($user = GWF_User::getByID(Common::getGet('userid')))) {
         return GWF_HTML::err('ERR_UNKNOWN_USER');
     }
     $tmpfile = GWF_PATH . 'extra/temp/gpg/' . $user->getVar('user_id');
     if (!is_file($tmpfile) || !is_readable($tmpfile)) {
         return GWF_HTML::err('ERR_FILE_NOT_FOUND', array($tmpfile));
     }
     if (false === ($file_content = file_get_contents($tmpfile))) {
         return GWF_HTML::err('ERR_FILE_NOT_FOUND', array($tmpfile));
     }
     if (false === unlink($tmpfile)) {
         return GWF_HTML::err('ERR_WRITE_FILE', array($tmpfile));
     }
     if (false === ($fingerprint = GWF_PublicKey::grabFingerprint($file_content))) {
         return $this->module->error('err_gpg_key');
     }
     if (Common::getGet('token') !== $fingerprint) {
         return $this->module->error('err_gpg_token');
     }
     if (false === GWF_PublicKey::updateKey($user->getID(), $file_content)) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === $user->saveOption(GWF_User::EMAIL_GPG, true)) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return $this->module->message('msg_setup_gpg');
 }
예제 #28
0
파일: AddAttach.php 프로젝트: sinfocol/gwf3
 private function onAdd()
 {
     $form = $this->formAdd();
     if (false !== ($error = $form->validate($this->module))) {
         return $error . $this->templateAdd();
     }
     $file = $form->getVar('file');
     $tmp = $file['tmp_name'];
     $postid = $this->post->getID();
     $userid = GWF_Session::getUserID();
     $options = 0;
     $options |= isset($_POST['guest_view']) ? GWF_ForumAttachment::GUEST_VISIBLE : 0;
     $options |= isset($_POST['guest_down']) ? GWF_ForumAttachment::GUEST_DOWNLOAD : 0;
     # Put in db
     $attach = new GWF_ForumAttachment(array('fatt_aid' => 0, 'fatt_uid' => $userid, 'fatt_pid' => $postid, 'fatt_mime' => GWF_Upload::getMimeType($tmp), 'fatt_size' => filesize($tmp), 'fatt_downloads' => 0, 'fatt_filename' => $file['name'], 'fatt_options' => $options, 'fatt_date' => GWF_Time::getDate(GWF_Date::LEN_SECOND)));
     if (false === $attach->insert()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     $aid = $attach->getID();
     # Copy file
     $path = $attach->dbimgPath();
     if (false === GWF_Upload::moveTo($file, $path)) {
         @unlink($tmp);
         return GWF_HTML::err('ERR_WRITE_FILE', $path);
     }
     @unlink($tmp);
     $this->post->increase('post_attachments', 1);
     return $this->module->message('msg_attach_added', array($this->post->getShowHREF()));
 }
예제 #29
0
파일: Show.php 프로젝트: sinfocol/gwf3
 public function execute()
 {
     # Page exists?
     if (false === ($page = GWF_Page::getByID(Common::getGetString('pageid')))) {
         header($_SERVER['SERVER_PROTOCOL'] . " 404 Not Found");
         return $this->module->error('err_404');
     }
     # Have permission to see?
     if (!$this->checkPermission($page)) {
         header($_SERVER['SERVER_PROTOCOL'] . " 403 Forbidden");
         return GWF_HTML::err('ERR_NO_PERMISSION');
     }
     # Load comments?
     if ($page->isOptionEnabled(GWF_Page::COMMENTS)) {
         $this->mod_c = GWF_Module::loadModuleDB('Comments', true, true);
         if (false === ($this->comments = $page->getComments())) {
             return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
         }
         $_REQUEST['cmts_id'] = $this->comments->getID();
     }
     # Exec ...
     $back = '';
     if (isset($_POST['reply'])) {
         $back = $this->onReply($page);
     }
     return $this->showPage($page) . $back;
 }
예제 #30
0
파일: Thanks.php 프로젝트: sinfocol/gwf3
 private function onThanks()
 {
     if (false === ($post = $this->module->getCurrentPost())) {
         return $this->module->error('err_post');
     }
     if (false === $this->module->cfgThanksEnabled()) {
         return $this->module->error('err_thanks_off');
     }
     if (false === ($user = GWF_Session::getUser())) {
         return GWF_HTML::err('ERR_GENERAL', __FILE__, __LINE__);
     }
     if ($post->hasThanked($user)) {
         return $this->module->error('err_thank_twice');
     }
     if ($post->getUserID() === $user->getID()) {
         return $this->module->error('err_thank_self');
     }
     if (false === $post->onThanks($this->module, $user)) {
         return GWF_HTML::err('ERR_DATABASE', __FILE__, __LINE__);
     }
     if ($this->module->isAjax()) {
         return '1:' . $post->getThanksCount();
     } else {
         return $this->module->message('msg_thanked', $post->getShowHREF());
     }
 }