Ejemplo n.º 1
0
 public function execute()
 {
     $this->module->includeClass('WC_Warbox');
     $this->module->includeClass('WC_Warflag');
     $this->module->includeClass('WC_Warflags');
     $this->module->includeClass('sites/warbox/WCSite_WARBOX');
     if (false === ($this->box = WC_Warbox::getByID(Common::getGetString('boxid')))) {
         return $this->module->error('err_warbox');
     }
     if (false === ($this->site = $this->box->getSite())) {
         return $this->module->error('err_site');
     }
     if (false === ($this->user = GWF_Session::getUser())) {
         return GWF_HTML::err('ERR_LOGIN_REQUIRED');
     }
     if (false === ($this->flags = WC_Warflag::getForBoxAndUser($this->box, $this->user, 'wf_order ASC'))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (count($this->flags) === 0) {
         return GWF_HTML::err('ERR_GENERAL', array(__FILE__, __LINE__));
     }
     if (isset($_POST['password'])) {
         return $this->onSolve();
     }
     return $this->templateOverview();
 }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
 public function execute()
 {
     if (false === Common::isFile(GWF_GESHI_PATH)) {
         return '';
         // FIXME: {gizmore} log it? GESHI_PATH is may not readable
     }
     require_once GWF_GESHI_PATH;
     $geshi = new GeSHi();
     $langs = $geshi->get_supported_languages(false);
     $key = htmlspecialchars(Common::getGetString('key', ''), ENT_QUOTES);
     sort($langs);
     //		$this->niceArray($langs, false, '-------')
     $this->niceArray($langs, 'python', 'Python');
     $this->niceArray($langs, 'perl', 'Perl');
     $this->niceArray($langs, 'cpp', 'CPP');
     $this->niceArray($langs, 'php', 'PHP');
     $back = $this->module->lang('th_lang') . ':' . PHP_EOL;
     $back .= '<select id="bb_code_lang_sel_' . $key . '">' . PHP_EOL;
     $back .= '<option value="0">' . $this->module->lang('th_lang') . '</option>' . PHP_EOL;
     foreach ($langs as $lang) {
         $back .= sprintf('<option value="%s">%s</option>', $lang, $lang) . PHP_EOL;
     }
     $back .= '</select>' . PHP_EOL;
     $back .= $this->module->lang('th_title') . ': <input type="text" id="bb_code_title_' . $key . '" size="20" value="" />' . PHP_EOL;
     $back .= '<input type="submit" value="' . $this->module->lang('btn_code') . '" onclick="return bbInsertCodeNow(\'' . $key . '\');" />' . PHP_EOL;
     return $back;
 }
Ejemplo n.º 4
0
 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;
 }
Ejemplo n.º 5
0
 public function execute()
 {
     if (false === ($user = GWF_User::getByName(Common::getGetString('username')))) {
         return GWF_HTML::err('ERR_UNKNOWN_USER');
     }
     if (false !== ($error = $this->module->isExcludedFromAPI($user, false))) {
         return $error;
     }
     $this->module->includeClass('WC_RegAt');
     $format = Common::getGetString('format', self::FORMAT);
     $bg = Common::getGetString('bg', self::BGCOLOR);
     $fg = Common::getGetString('fg', self::FGCOLOR);
     $size = Common::clamp(Common::getGetInt('s', self::SIZE), 6, 30);
     $spacingx = Common::clamp(Common::getGetInt('sx', 1), 0, 30);
     $spacingy = Common::clamp(Common::getGetInt('sy', 1), 0, 30);
     $marginx = Common::clamp(Common::getGetInt('mx', 1), 0, 30);
     $marginy = Common::clamp(Common::getGetInt('my', 1), 0, 30);
     $divider = Common::getGetString('div', '  ');
     $font = Common::getGetString('font', self::FONT);
     $_GET['font'] = $font;
     if (!preg_match('/^[a-z_0-9]+$/iD', $font) || !Common::isFile(GWF_EXTRA_PATH . 'font/' . $font . '.ttf')) {
         return "Font not found. Available fonts: " . $this->listFonts();
     }
     die($this->displayBanner($user, $format, $bg, $fg, $size, $spacingx, $spacingy, $marginx, $marginy, $divider));
 }
Ejemplo n.º 6
0
 private function templateSongs()
 {
     //		$user = GWF_Session::getUser();
     //		$uid = $user->getID();
     $table = GDO::table('Slay_Song');
     $joins = NULL;
     $headers = array();
     $headers[] = array($this->module->lang('th_artist'), 'ss_artist');
     $headers[] = array($this->module->lang('th_title'), 'ss_title');
     $headers[] = array($this->module->lang('th_duration'), 'ss_duration');
     $headers[] = array($this->module->lang('th_bpm'), 'ss_bpm');
     $headers[] = array($this->module->lang('th_key'), 'ss_key');
     $headers[] = array($this->module->lang('D'));
     $headers[] = array($this->module->lang('L'));
     $headers[] = array($this->module->lang('T'));
     $headers[] = array($this->module->lang('th_tags'));
     $where = "";
     $nItems = $table->selectVar('COUNT(ss_id)', $where, '', $joins);
     $nPages = GWF_PageMenu::getPagecount(self::IPP, $nItems);
     $page = Common::clamp(Common::getGetInt('page'), 1, $nPages);
     $by = Common::getGetString('by', self::BY);
     $dir = Common::getGetString('dir', self::DIR);
     $orderby = $table->getMultiOrderby($by, $dir, false);
     $songs = $table->selectAll('*', $where, $orderby, $joins, self::IPP, GWF_PageMenu::getFrom($page, self::IPP), GDO::ARRAY_O);
     $tVars = array('is_dj' => GWF_User::isInGroupS('dj'), 'sort_url' => GWF_WEB_ROOT . 'index.php?mo=Slaytags&me=Songs&by=%BY%&dir=%DIR%&page=1', 'pagemenu' => GWF_PageMenu::display($page, $nPages, GWF_WEB_ROOT . sprintf('index.php?mo=Slaytags&me=Songs&by=%s&dir=%s&page=%%PAGE%%', urlencode($by), urlencode($dir))), 'songs' => $songs, 'headers' => $headers);
     return $this->module->template('songs.tpl', $tVars);
 }
Ejemplo n.º 7
0
 private function sanitize()
 {
     if (false === ($this->group = GWF_Group::getByID(Common::getGetString('gid')))) {
         return $this->module->error('err_group');
     }
     return false;
 }
Ejemplo n.º 8
0
 public function execute()
 {
     return $_SERVER['REMOTE_ADDR'];
     $ip = Common::getGetString('ip', false);
     $type = Common::getGetString('type', GWF_IP6::INT_32);
     return GWF_IP6::getIP($type, $ip);
 }
Ejemplo n.º 9
0
 public function execute()
 {
     $nav = $this->module->templateNav();
     if ('true' === Common::getGetString('all')) {
         return $nav . $this->onInstallAll();
     }
     if (false !== Common::getPost('install')) {
         return $nav . $this->onInstallModuleSafe(false);
     }
     if (false !== Common::getPost('reinstall')) {
         return $nav . $this->onTemplateReinstall(true);
     }
     if (false !== Common::getPost('reinstall2')) {
         return $nav . $this->onInstallModuleSafe(true);
     }
     if (false !== Common::getPost('resetvars2')) {
         return $nav . $this->onResetModule();
     }
     if (false !== Common::getPost('delete')) {
         return $nav . $this->onTemplateReinstall(false);
     }
     if (false !== Common::getPost('delete2')) {
         return $nav . $this->onDeleteModule();
     }
     if (false !== ($modulename = Common::getGetString('module'))) {
         return $nav . $this->onInstall($modulename, false);
     }
     return GWF_HTML::err('ERR_GENERAL', array(__FILE__, __LINE__));
 }
Ejemplo n.º 10
0
 public function execute()
 {
     if (false === ($this->song = Slay_Song::getByID(Common::getGetString('song')))) {
         return $this->module->error('err_song');
     }
     return $this->templateSong();
 }
Ejemplo n.º 11
0
 public function templateChalls($for_userid = false, $from_userid = false, $tag = '', $by = '', $dir = '', $show_cloud = true, $show_empty = true)
 {
     require_once GWF_CORE_PATH . 'module/WeChall/WC_ChallSolved.php';
     $challs = GDO::table('WC_Challenge');
     $for_userid = (int) $for_userid;
     $from_userid = (int) $from_userid;
     $solved_bits = $for_userid > 0 ? WC_ChallSolved::getSolvedForUser($for_userid, true) : array();
     if (count($solved_bits) === 0 && !$show_empty && $from_userid === 0) {
         return '';
     }
     $solve_filter = Common::getGetString('filter', '');
     if ($solve_filter === 'solved' or $solve_filter == 'open') {
         $filter_prefix = $solve_filter . '_';
     } else {
         $filter_prefix = '';
     }
     $from_query = $from_userid === 0 ? '1' : "chall_creator LIKE '%,{$from_userid},%'";
     $conditions = "({$from_query})";
     if (0 === ($count = $challs->countRows($conditions))) {
         return '';
     }
     $orderby = $challs->getMultiOrderby($by, $dir);
     $tag_2 = $tag == '' ? '' : $tag . '/';
     $this->setPageDescr($for_userid, $from_userid, $tag, $count);
     $sort_url = 'challs/' . $tag_2 . 'by/' . $by . '/' . $dir . '/page-1';
     $tVars = array('filter_prefix' => $filter_prefix, 'sort_url' => GWF_WEB_ROOT . $filter_prefix . 'challs/' . $tag_2 . 'by/%BY%/%DIR%/page-1', 'challs' => $challs->selectObjects('*', $conditions, $orderby), 'tags' => $show_cloud ? $this->getTags() : '', 'solved_bits' => $solved_bits, 'table_title' => $this->getTableTitle($for_userid, $from_userid, $tag, $count), 'tag' => $tag, 'by' => $by, 'dir' => $dir, 'href_all' => GWF_WEB_ROOT . $sort_url, 'href_solved' => GWF_WEB_ROOT . 'solved_' . $sort_url, 'href_unsolved' => GWF_WEB_ROOT . 'open_' . $sort_url, 'sel_all' => $solve_filter === '', 'sel_solved' => $solve_filter === 'solved', 'sel_unsolved' => $solve_filter === 'open');
     return $this->module->templatePHP('challs.php', $tVars);
 }
Ejemplo n.º 12
0
 public function execute()
 {
     GWF_Website::plaintext();
     $input = trim(Common::getGetString('username', ''));
     if (false !== ($onsitename = Common::getGet('onsitename')) && false !== ($sitename = Common::getGet('sitename'))) {
         die($this->rawOnSiteStats($sitename, $onsitename));
     }
     require_once GWF_CORE_PATH . 'module/WeChall/WC_RegAt.php';
     if (Common::getGet('wechall') === 'yes') {
         die($this->wechallChalls($input));
     }
     if ($input === '') {
         $message = sprintf('Try %s?username=name/rank. New: ?username=!sitename username/rank. Or: ?username=!sites usernname', 'wechall.php');
         die($message);
     }
     if (strpos($input, '!sites') === 0) {
         $this->showSites($input);
     } elseif (strpos($input, '!site') === 0) {
         $this->showSiteDetail($input);
     } elseif (strpos($input, '!') === 0) {
         $this->showSite($input);
     } else {
         die($this->showGlobal($input));
     }
 }
Ejemplo n.º 13
0
 public function execute()
 {
     if (false === ($page = GWF_Page::getByID(Common::getGetString('pageid')))) {
         return $this->module->error('err_page');
     }
     $user = GWF_User::getStaticOrGuest();
     $this->is_author = $this->module->isAuthor($user);
     $this->is_owner = $this->is_author || $page->isOwner($user);
     if (!$this->is_owner && !$this->is_author) {
         return GWF_HTML::err('ERR_NO_PERMISSION');
     }
     $this->page = $page;
     $this->user = $user;
     $this->is_oowner = $this->is_author ? true : $page->getOtherPage()->isOwner($user);
     $back = '';
     if (isset($_POST['edit'])) {
         $back .= $this->onEdit();
     } elseif (isset($_POST['unlock'])) {
         return $this->onUnlock() . $this->templateEdit();
     } elseif (isset($_POST['delete'])) {
         return $this->onDelete() . $this->templateEdit();
     } elseif (isset($_POST['translate'])) {
         GWF_Website::redirect($this->module->getMethodURL('Translate', '&pageid=' . $page->getID()));
         die;
     } elseif (isset($_POST['upload'])) {
         require_once GWF_CORE_PATH . 'module/PageBuilder/PB_Uploader.php';
         $back .= PB_Uploader::onUpload($this->module) . $this->templateEdit();
     }
     return $back . $this->templateEdit();
 }
Ejemplo n.º 14
0
 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();
 }
Ejemplo n.º 15
0
 public function execute()
 {
     GWF_Website::plaintext();
     GWF3::setConfig('store_last_url', false);
     $lat = $this->module->lat();
     $lon = $this->module->lon();
     $descr = trim(Common::getGetString('pp_descr'));
     $descr = $descr === '' ? null : $descr;
     $id = Common::getGetInt('pp_id', 0);
     $user = GWF_User::getStaticOrGuest();
     $uid = $user->getID();
     if (!GWF_ProfilePOI::changeAllowed($id, $uid)) {
         $this->module->ajaxError('Permission error!');
     }
     $count = $id === 0 ? GWF_ProfilePOI::getPOICount($uid) : 0;
     $max_pois = $this->module->cfgAllowedPOIs();
     if ($count >= $max_pois) {
         $this->module->ajaxErr('err_poi_exceed');
     }
     $poi = new GWF_ProfilePOI(array('pp_id' => $id, 'pp_uid' => $uid, 'pp_lat' => $lat, 'pp_lon' => $lon, 'pp_descr' => $descr));
     $poi->replace();
     $data = $poi->getGDOData();
     $data['user_name'] = $user->getVar('user_name');
     die(json_encode($data));
 }
Ejemplo n.º 16
0
 public function execute()
 {
     if (false === ($lyrics = Slay_Lyrics::getByIDs(Common::getGetString(''), Common::getGetString('')))) {
         return $this->module->error('err_lyrics_unk');
     }
     return $this->templateEditLyrics($lyrics);
 }
Ejemplo n.º 17
0
function salesman_on_submit_answer(WC_Challenge $chall)
{
    if ('' !== ($answer = Common::getGetString('answer', ''))) {
        return salesman_check_answer($chall, $answer);
    } else {
        return salesman_fail($chall);
    }
}
Ejemplo n.º 18
0
 private function getData()
 {
     $table = GDO::table('WC_Warflags');
     $by = Common::getGetString('by', 'wf_order');
     $dir = Common::getGetString('dir', 'ASC');
     $orderby = $table->getMultiOrderby($by, $dir);
     return WC_Warflag::getForBoxAndUser($this->box, GWF_User::getStaticOrGuest(), $orderby);
 }
Ejemplo n.º 19
0
 /**
  * Get a langid from possible get parameters. default is browser.
  * @return string
  */
 private function getSelectedLangID()
 {
     if ('' !== ($iso = Common::getGetString('to_iso'))) {
         if (false !== ($id = GWF_Language::getIDByISO($iso))) {
             return $id;
         }
     }
     return Common::getGetString('to_lang_id', true);
 }
Ejemplo n.º 20
0
 public function execute()
 {
     if (false !== ($filename = Common::getGetString('filename', false))) {
         return $this->templateFile($filename);
     }
     if (false !== Common::getPost('save_file')) {
         return $this->onSaveFile();
     }
     return $this->templateFiles();
 }
Ejemplo n.º 21
0
 public function execute()
 {
     $back = '';
     GWF_Website::addJavascript(GWF_WEB_ROOT . 'js/module/Helpdesk/helpdesk.js');
     GWF_Website::addJavascriptOnload('helpdeskInit();');
     if (Common::getGetString('generate') === 'now') {
         $back .= $this->onGenerate();
     }
     return $back . $this->templateFAQ();
 }
Ejemplo n.º 22
0
 public function execute()
 {
     if (false === ($song = Slay_Song::getByID(Common::getGetString('stid')))) {
         return $this->module->error('err_song');
     }
     if (isset($_POST['add'])) {
         return $this->onAddLyrics($song) . $this->templateAddLyrics($song);
     }
     return $this->templateAddLyrics($song);
 }
Ejemplo n.º 23
0
 public function execute()
 {
     if (false === ($termin = Konzert_Termin::getByID(Common::getGetString('ktid')))) {
         return $this->module->error('err_termin');
     }
     if (isset($_POST['edit'])) {
         return $this->onEdit($termin) . $this->templateEdit($termin);
     }
     return $this->templateEdit($termin);
 }
Ejemplo n.º 24
0
 private function sanitize()
 {
     $this->table = new GWF_UserActivation(false);
     $this->ipp = $this->module->getActivationsPerPage();
     $this->nItems = $this->table->countRows();
     $this->nPages = GWF_PageMenu::getPagecount($this->ipp, $this->nItems);
     $this->page = Common::clamp((int) Common::getGet('page', 1), 1, $this->nPages);
     $this->by = $this->table->getWhitelistedBy(Common::getGetString('by'), 'timestamp');
     $this->dir = GDO::getWhitelistedDirS(Common::getGetString('dir'), 'DESC');
     $this->orderby = "{$this->by} {$this->dir}";
 }
Ejemplo n.º 25
0
 public function execute()
 {
     if (false !== Common::getPost('quickjump')) {
         return $this->onQuickjump();
     }
     if (false === ($site = WC_Site::getByName(Common::getGetString('site', NULL)))) {
         return $this->module->error('err_unknown_site');
     }
     $_GET['sid'] = $site->getID();
     return $this->templateHistory($site);
 }
Ejemplo n.º 26
0
 public function execute()
 {
     $this->module->includeClass('WC_Warbox');
     $this->module->includeClass('WC_Warflag');
     $this->module->includeClass('WC_Warflags');
     $this->module->includeClass('sites/warbox/WCSite_WARBOX');
     if (false === ($this->flag = WC_Warflag::getByID(Common::getGetString('flag')))) {
         return $this->module->error('err_warflag');
     }
     return $this->templateSolvers();
 }
Ejemplo n.º 27
0
 private function sanitize($cmt_id)
 {
     if (false === ($c = GWF_Comment::getByID($cmt_id))) {
         return $this->module->error('err_comment');
     }
     if (Common::getGetString('ctoken', '') !== $c->getHashcode()) {
         return $this->module->error('err_hashcode');
     }
     $this->comment = $c;
     return false;
 }
Ejemplo n.º 28
0
 private function getWhere()
 {
     switch (Common::getGetString('mode')) {
         case 'disabled':
             return '';
         case 'deleted':
             return '';
         default:
             return '';
     }
 }
Ejemplo n.º 29
0
 public function execute()
 {
     if (false === ($news = GWF_News::getByID(Common::getGetString('newsid', '0')))) {
         return $this->module->error('err_news');
     }
     #		$oldhidden = $news->isHidden();
     $newhidden = Common::getGetString('hidden') === '1';
     if (false === $news->saveOption(GWF_News::HIDDEN, $newhidden)) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return $this->module->message('msg_hidden_' . ($newhidden ? 1 : 0));
 }
Ejemplo n.º 30
0
 public function execute()
 {
     if ('' === ($filename = Common::getGetString('filename'))) {
         return GWF_Error::err('ERR_NO_PERMISSION');
     }
     $path = $this->module->getContentPath();
     $filename = $path . '/' . $filename;
     if (!Common::isFile($filename)) {
         return GWF_Error::err404($filename);
     }
     GWF_Upload::outputFile($filename);
 }