Ejemplo n.º 1
0
 public static function core($drop = false, &$success)
 {
     $db = gdo_db();
     $tables = self::get_core_tables();
     $success = true;
     $ret = '<br/><br/>';
     foreach ($tables as $classname) {
         $ret .= sprintf("Installing %s table ... ", $classname);
         if (false === ($result = GDO::table($classname)->createTable($drop))) {
             #error
             $ret .= '<b class="gwfinstallno">FAILED!<br/>' . PHP_EOL;
             $success = false;
         } else {
             #success
             $ret .= '<b class="gwfinstallyes">OK</b><br/>' . PHP_EOL;
         }
     }
     $ret .= '<br/>';
     /** Try to set a birthdate **/
     if (false === GWF_Settings::getSetting('gwf_site_birthday', false)) {
         $ret .= sprintf("Setting up a birthdate ... %s.", date('Ymd'));
         if (false === GWF_Settings::setSetting('gwf_site_birthday', date('Ymd'))) {
             $ret .= '<b class="gwfinstallno">Cannot set site birthdate.<br/>' . PHP_EOL;
             $success = false;
         }
     }
     return $ret;
 }
Ejemplo n.º 2
0
 public static function getAllDescr()
 {
     $browser_lid = GWF_Language::getCurrentID();
     $sites = GWF_TABLE_PREFIX . 'wc_site';
     $descr = GWF_TABLE_PREFIX . 'wc_site_descr';
     $db = gdo_db();
     $back = array();
     $query = "SELECT site_id, site_desc_txt FROM {$sites} JOIN {$descr} ON site_desc_sid=site_id WHERE site_desc_lid={$browser_lid}";
     if (false === ($result = $db->queryRead($query))) {
         return array();
     }
     while (false !== ($row = $db->fetchRow($result))) {
         $back[(int) $row[0]] = $row[1];
     }
     $db->free($result);
     $query = "SELECT site_id, site_desc_txt FROM {$sites} JOIN {$descr} ON site_desc_sid=site_id WHERE site_desc_lid=site_descr_lid";
     if (false === ($result = $db->queryRead($query))) {
         return array();
     }
     while (false !== ($row = $db->fetchRow($result))) {
         $sid = (int) $row[0];
         if (!isset($back[$sid])) {
             $back[$sid] = $row[1];
         }
     }
     $db->free($result);
     return $back;
 }
Ejemplo n.º 3
0
 /**
  * Select Users For Global Ranking.
  * @param int $count
  * @param int $from
  * @return array
  */
 private function selectUsers($count, $from)
 {
     $db = gdo_db();
     $count = (int) $count;
     $from = (int) $from;
     $regat = GDO::table('WC_RegAt')->getTableName();
     $users = GDO::table('GWF_User')->getTableName();
     $query = "SELECT user_id,user_name,user_level,SUM(regat_score) AS lts, COUNT(regat_score) AS nlinks, regat_langid,user_countryid FROM {$regat} AS B JOIN (SELECT user_id,user_name,user_level,user_countryid FROM {$users} WHERE user_options&0x10000000=0 ORDER BY user_level DESC, user_id ASC LIMIT {$from}, {$count}) AS C ON user_id=regat_uid GROUP by user_id,regat_langid ORDER BY user_level DESC, user_id ASC";
     $back = array();
     if (false === ($result = $db->queryRead($query))) {
         return $back;
     }
     $current = false;
     while (false !== ($row = $db->fetchAssoc($result))) {
         if ($current === false) {
             $current = new GWF_User($row);
             $current->setVar('nlinks', 0);
             $back[] = $current;
         } elseif ($current->getVar('user_id') !== $row['user_id']) {
             if (count($back) === $count) {
                 break;
             }
             $current = new GWF_User($row);
             $current->setVar('nlinks', 0);
             $back[] = $current;
         }
         $current->setVar('grank_' . $row['regat_langid'], $row['lts']);
         $current->setVar('nlinks', $current->getVar('nlinks') + $row['nlinks']);
         //			var_dump($current->getGDOData());
     }
     $db->free($result);
     //		var_dump($back);
     return $back;
 }
Ejemplo n.º 4
0
function smarty_resource_db_timestamp($tpl_name, &$tpl_timestamp, $smarty)
{
    $query = 'SELECT page_time t FROM ' . GWF_TABLE_PREFIX . 'page WHERE page_id=' . (int) $tpl_name;
    if (false === ($result = gdo_db()->queryFirst($query))) {
        $tpl_timestamp = time();
        return false;
    }
    $tpl_timestamp = time();
    //	$tpl_timestamp = $result['t'];
    return true;
}
Ejemplo n.º 5
0
function Upgrade_Profile_1_02(Module_Profile $module)
{
    $db = gdo_db();
    $profile = GWF_TABLE_PREFIX . 'profile';
    $query = "ALTER TABLE {$profile} ADD COLUMN prof_poi_score INT(11) DEFAULT 0";
    if (false === $db->queryWrite($query)) {
        return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    echo GWF_HTML::message('Profile', '[+] Profile POI Score', false);
    return '';
}
Ejemplo n.º 6
0
function Upgrade_PageBuilder_1_01(Module_PageBuilder $module)
{
    $db = gdo_db();
    $page = GWF_TABLE_PREFIX . 'page';
    $query = "ALTER TABLE {$page} DROP COLUMN `page_menu_pos`";
    $addcol = "ALTER TABLE {$page} ADD COLUMN `page_inline_css` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL";
    if (false === $db->queryWrite($query) || false === $db->queryWrite($addcol)) {
        return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    return '';
}
Ejemplo n.º 7
0
function warscore_function($socket, $pid)
{
    # Init GWF
    $gwf = new GWF3(getcwd(), array('website_init' => false, 'autoload_modules' => false, 'load_module' => false, 'start_debug' => true, 'get_user' => false, 'log_request' => false, 'no_session' => true, 'store_last_url' => false, 'ignore_user_abort' => false));
    gdo_db();
    GWF_Debug::setDieOnError(false);
    GWF_HTML::init();
    if (false === ($wechall = GWF_Module::loadModuleDB('WeChall', true, true, true))) {
        warscore_error($socket, 'Cannot load WeChall!');
    }
    $wechall->includeClass('WC_Warbox');
    $wechall->includeClass('WC_WarToken');
    $wechall->includeClass('WC_Warflag');
    $wechall->includeClass('WC_Warflags');
    $wechall->includeClass('sites/warbox/WCSite_WARBOX');
    if (false === ($input = socket_read($socket, 2048))) {
        warscore_error($socket, 'Read Error 1!');
    }
    warscore_debug("GOT INPUT: {$input}");
    if (false === ($username = Common::substrUntil($input, "\n", false))) {
        warscore_error($socket, 'No username sent!');
    }
    if (false === ($user = GWF_User::getByName($username))) {
        warscore_error($socket, 'Unknown user!');
    }
    warscore_debug("GOT USER: {$username}");
    if ('' === ($token = Common::substrFrom($input, "\n", ''))) {
        warscore_error($socket, 'No token sent!');
    }
    $token = trim(Common::substrUntil($token, "\n", $token));
    if (!WC_WarToken::isValidWarToken($user, $token)) {
        warscore_error($socket, 'Invalid Token!');
    }
    if (!socket_getpeername($socket, $client_ip, $client_port)) {
        warscore_error($socket, 'Socket Error 2!');
    }
    echo "{$client_ip}\n";
    $boxes = WC_Warbox::getByIP($client_ip);
    if (count($boxes) === 0) {
        warscore_error($socket, 'Unknown Warbox!');
    }
    warscore_debug("GOT N BOXES: " . count($boxes));
    $curr_port = 0;
    foreach ($boxes as $box) {
        $box instanceof WC_Warbox;
        if ($curr_port !== $box->getVar('wb_port')) {
            $curr_port = $box->getVar('wb_port');
            warscore_identd($socket, $box, $user, $client_ip, $client_port);
        }
    }
    socket_write($socket, 'Bailing out! You should not see me.');
    socket_close($socket);
    die(0);
}
Ejemplo n.º 8
0
function Upgrade_GWF_1_04(Module_GWF $module)
{
    $db = gdo_db();
    $country = GWF_TABLE_PREFIX . 'country';
    $query = "ALTER TABLE {$country} ADD COLUMN country_pop INT(11) UNSIGNED NOT NULL DEFAULT 0";
    if (false === $db->queryWrite($query)) {
        return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    GWF_HTML::message('GWF', '[+] GWF 1.04 (country population)', true, true);
    return '';
}
Ejemplo n.º 9
0
function Upgrade_Profile_1_01(Module_Profile $module)
{
    $db = gdo_db();
    $profile = GWF_TABLE_PREFIX . 'profile';
    $query = "ALTER TABLE {$profile} ADD COLUMN prof_irc VARCHAR(255) CHARACTER SET ascii COLLATE ascii_bin";
    if (false === $db->queryWrite($query)) {
        return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    echo GWF_HTML::message('Profile', '[+] Profile IRC', false);
    return '';
}
Ejemplo n.º 10
0
function Upgrade_WeChall_1_06(Module_WeChall $module)
{
    GWF_Website::addDefaultOutput(GWF_HTML::message('WC5', "Regat table now stores challs_solved. (thx Jinx)"));
    $db = gdo_db();
    $regat = GWF_TABLE_PREFIX . 'wc_regat';
    $query = "ALTER TABLE {$regat} ADD COLUMN regat_challsolved INT(11) NOT NULL DEFAULT -1";
    if (false === $db->queryWrite($query)) {
        return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    return '';
}
Ejemplo n.º 11
0
function Upgrade_Account_1_03(Module_Account $module)
{
    var_dump('TRIGGERED Upgrade_Account_1_03');
    var_dump('The token entropy has been raised from 8 chars to 24.');
    $db = gdo_db();
    $accc = GWF_TABLE_PREFIX . 'accchange';
    $query = "ALTER TABLE {$accc} MODIFY COLUMN token VARCHAR(24) CHARACTER SET ascii COLLATE ascii_bin";
    if (false === $db->queryWrite($query)) {
        return GWF_HTML::err('ERR_DATABASE', __FILE__, __LINE__);
    }
    return '';
}
Ejemplo n.º 12
0
function Upgrade_GWF_1_02(Module_GWF $module)
{
    var_dump('TRIGGERED Upgrade GWF1.02 (Supported Language Flag)');
    $db = gdo_db();
    # NEW: Module options
    $lang = GWF_TABLE_PREFIX . 'language';
    $query = "ALTER TABLE {$lang} ADD COLUMN lang_options INT(11) UNSIGNED NOT NULL DEFAULT 0";
    if (false === $db->queryWrite($query)) {
        return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    return '';
}
Ejemplo n.º 13
0
function Upgrade_PM_1_05(Module_PM $module)
{
    echo GWF_HTML::message('PM', 'Triggering Upgrade_PM_1_05');
    echo GWF_HTML::message('PM', 'PMO_user_level');
    $db = gdo_db();
    $pmo = GWF_TABLE_PREFIX . 'pm_options';
    $query = "ALTER TABLE {$pmo} ADD COLUMN pmo_level INT(11) UNSIGNED DEFAULT 0";
    if (false === $db->queryWrite($query)) {
        return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    return '';
}
Ejemplo n.º 14
0
function Upgrade_PM_1_04(Module_PM $module)
{
    echo GWF_HTML::message('PM', 'Triggering Upgrade_PM_1_04');
    echo GWF_HTML::message('PM', 'PM ignore reasons');
    $db = gdo_db();
    $pmi = GWF_TABLE_PREFIX . 'pm_ignore';
    $query = "ALTER TABLE {$pmi} ADD COLUMN pmi_reason TEXT CHARACTER SET utf8 COLLATE utf8_general_ci";
    if (false === $db->queryWrite($query)) {
        return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    return '';
}
Ejemplo n.º 15
0
function module_PageBuilder_monthly()
{
    require_once GWF_CORE_PATH . 'module/PageBuilder/GWF_Page.php';
    $enabled = GWF_Page::ENABLED;
    $langid = GWF_Language::getCurrentID();
    $db = gdo_db();
    $t = GWF_TABLE_PREFIX . 'page';
    $query = "SELECT IFNULL(p2.page_otherid,p1.page_otherid), IFNULL(p2.page_title,p1.page_title), IFNULL(p2.page_url,p1.page_url), IFNULL(p2.page_date,p1.page_date) FROM {$t} p1 LEFT JOIN {$t} p2 ON p1.page_otherid=p2.page_otherid AND p2.page_lang={$langid} WHERE p1.page_lang=0 ORDER BY 4 DESC";
    if (false === ($result = $db->queryRead($query))) {
        return '';
    }
    $first = NULL;
    $tree = array();
    while (false !== ($page = $db->fetchRow($result))) {
        if ($first === NULL) {
            $first = $page;
        }
        monthlyAddTree($tree, $page);
    }
    $db->free($result);
    if (count($tree) === 0) {
        return '';
    }
    //	$first = $pages[key($pages)];
    $currdate = $first[3];
    list($y, $m, $d) = monthlySplit($currdate);
    $cy = $y;
    $cm = $m;
    $cd = $d;
    //	$tree = monthlyGetTree($pages);
    $back = '<div class="gwf_pb_monthly fr">' . PHP_EOL;
    foreach ($tree as $year => $y2) {
        $c = count($y2);
        $back .= "<ol id=\"_pby{$year}\"><li>{$year}({$c})</li>\n";
        foreach ($y2 as $m1 => $m2) {
            $c = count($m2);
            $month = GWF_HTML::lang('M' . ($m1 + 0));
            $back .= "<li>{$year} {$month} ({$c})<ol>\n";
            foreach ($m2 as $page) {
                $url = htmlspecialchars(GWF_WEB_ROOT . $page[2]);
                $title = htmlspecialchars($page[1]);
                $back .= "<li><a href=\"{$url}\" title=\"{$title}\">{$title}</a></li>\n";
            }
            $back .= "</ol></li>\n";
        }
        $back .= "</ol>\n";
    }
    $back .= '</div>' . PHP_EOL;
    return $back;
    echo $back;
    return;
}
Ejemplo n.º 16
0
function Upgrade_News_1_01(Module_News $module)
{
    if (false === gdo_db()->query('ALTER TABLE ' . GWF_TABLE_PREFIX . 'newstrans' . ' ADD COLUMN newst_threadid INT(11) UNSIGNED NOT NULL DEFAULT 0')) {
        return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    $msg = GWF_HTML::message('News', 'It is now possible to have news in forums.');
    if (GWF_OUTPUT_BUFFERING) {
        echo $msg;
    } else {
        GWF_Website::addDefaultOutput($msg);
    }
    return '';
}
Ejemplo n.º 17
0
 private function onMarkRead()
 {
     $user = GWF_Session::getUser();
     $userid = $user->getID();
     $sites = GWF_TABLE_PREFIX . 'wc_site';
     $regat = GWF_TABLE_PREFIX . 'wc_regat';
     $query = "UPDATE {$regat} JOIN {$sites} ON regat_sid=site_id SET regat_challcount=site_challcount WHERE regat_uid={$userid}";
     $db = gdo_db();
     if (false === $db->queryWrite($query)) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return $this->module->message('msg_challs_marked');
 }
Ejemplo n.º 18
0
function Upgrade_GWF_3_04(Module_GWF $module)
{
    echo GWF_HTML::message('GWF', 'Triggering Upgrade_GWF_3_04');
    echo GWF_HTML::message('GWF', 'The email field in user database is now UTF8.');
    $db = gdo_db();
    $users = GWF_TABLE_PREFIX . 'user';
    $query = "ALTER TABLE `{$users}` CHANGE `user_email` `user_email` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
    if (false === $db->queryWrite($query)) {
        return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    $modules = GWF_TABLE_PREFIX . 'module';
    $query = "ALTER TABLE `{$modules}` ADD UNIQUE `module_name` ( `module_name` )";
    return '';
}
Ejemplo n.º 19
0
 public static function single($name = 'country', $selected = '0')
 {
     $db = gdo_db();
     $table = GDO::table('GWF_Country');
     if (false === ($result = $table->select('country_id,country_name', '', 'country_name ASC'))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     $data = array(array('0', GWF_HTML::lang('sel_country')));
     while (false !== ($row = $db->fetchRow($result))) {
         $data[] = $row;
     }
     $db->free($result);
     return GWF_Select::display($name, $data, $selected);
 }
Ejemplo n.º 20
0
function Upgrade_WeChall_1_03(Module_WeChall $module)
{
    $db = gdo_db();
    $sites = GWF_TABLE_PREFIX . 'wc_site';
    $query = "ALTER TABLE {$sites} ADD COLUMN site_spc INT(11) UNSIGNED NOT NULL DEFAULT 25";
    if (false === $db->queryWrite($query)) {
        return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    $query = "ALTER TABLE {$sites} ADD COLUMN site_powarg INT(11) UNSIGNED NOT NULL DEFAULT 100";
    if (false === $db->queryWrite($query)) {
        return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    GWF_HTML::message('WC', '[+] Advanced Scoring by Caesum', true, true);
    return '';
}
Ejemplo n.º 21
0
function Upgrade_Links_1_03(Module_Links $module)
{
    echo GWF_HTML::message('Links', 'Langauge filter');
    $db = gdo_db();
    $table = GWF_TABLE_PREFIX . 'links';
    $query = "ALTER TABLE {$table} ADD COLUMN link_lang INT(11) UNSIGNED NOT NULL DEFAULT 1";
    if (false === $db->queryWrite($query)) {
        return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    $query = "ALTER TABLE {$table} ADD INDEX(link_lang)";
    if (false === $db->queryWrite($query)) {
        return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    return '';
}
Ejemplo n.º 22
0
function Upgrade_Links_1_02(Module_Links $module)
{
    echo GWF_HTML::message('Links', 'Link Up/Down Checker');
    $db = gdo_db();
    $table = GWF_TABLE_PREFIX . 'links';
    $query = "ALTER TABLE {$table} ADD COLUMN link_lastcheck INT(11) UNSIGNED NOT NULL DEFAULT 0";
    if (false === $db->queryWrite($query)) {
        return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    $query = "ALTER TABLE {$table} ADD COLUMN link_downcount INT(11) UNSIGNED NOT NULL DEFAULT 0";
    if (false === $db->queryWrite($query)) {
        return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    return '';
}
Ejemplo n.º 23
0
 public function connect(Dog_Server $server, $blocking = 0)
 {
     if ($this->connecting) {
         return $this->socket_try;
     }
     $this->connecting = true;
     // Disconnect, so the child process has no db that it could kill.
     global $SINGLE_GDO_DB;
     $SINGLE_GDO_DB->disconnect();
     $SINGLE_GDO_DB = null;
     $pid = pcntl_fork();
     if ($pid == -1) {
     } else {
         if ($pid) {
             $this->server = $server;
             self::$PARENT_PID = $pid;
             if (!$this->initQueues()) {
                 die('Cannot get message queue :(');
             }
             $this->connected = true;
             gdo_db();
             return true;
         } else {
             $this->server = $server;
             // we are the child
             declare (ticks=1);
             if (false === pcntl_signal(SIGINT, array($this, 'SIGINT'))) {
                 die('Cannot install SIGINT handler in ' . __FILE__ . PHP_EOL);
             }
             if (false === pcntl_signal(SIGCHLD, array($this, 'SIGINT'))) {
                 die('Cannot install SIGCHLD handler in ' . __FILE__ . PHP_EOL);
             }
             if (!$this->initQueues()) {
                 die('Cannot get message queue :(');
             }
             $this->socket = new WebSocketServer('tcp://0.0.0.0:' . $server->getPort(), 'rob_hubbard_fanclub!');
             $this->socket->addObserver($this);
             $this->socket->initQueue((int) $server->getID());
             // 			sleep(10);
             // 			die('oops');
             if (false === $this->socket->run($this)) {
                 $this->socket_try = false;
                 return false;
             }
             return true;
         }
     }
 }
Ejemplo n.º 24
0
function Upgrade_Forum_1_03(Module_Forum $module)
{
    var_dump('TRIGGERED Upgrade_Forum_1_03');
    var_dump('New threads are forced beeing unread, when added to group.');
    $db = gdo_db();
    $threads = GWF_TABLE_PREFIX . 'forumthread';
    $query = "ALTER TABLE {$threads} ADD COLUMN thread_force_unread TEXT CHARACTER SET ascii COLLATE ascii_bin";
    if (false === $db->queryWrite($query)) {
        return GWF_HTML::err('ERR_DATABASE', __FILE__, __LINE__);
    }
    $query = "UPDATE {$threads} SET thread_force_unread=':'";
    if (false === $db->queryWrite($query)) {
        return GWF_HTML::err('ERR_DATABASE', __FILE__, __LINE__);
    }
    return '';
}
Ejemplo n.º 25
0
 public function templateChalls(GWF_User $user)
 {
     $whitelist = array('chall_score', 'chall_title', 'chall_creator_name', 'chall_solvecount', 'chall_date', 'chall_dif', 'chall_edu', 'chall_fun', 'csolve_date', 'csolve_time_taken');
     require_once GWF_CORE_PATH . 'module/WeChall/WC_ChallSolved.php';
     $challs = GDO::table('WC_Challenge');
     $db = gdo_db();
     $uid = $user->getVar('user_id');
     $challs = GWF_TABLE_PREFIX . 'wc_chall';
     $solved = GWF_TABLE_PREFIX . 'wc_chall_solved';
     $by = GDO::getWhitelistedByS(Common::getGet('pcby'), $whitelist, self::DEFAULT_BY);
     $dir = GDO::getWhitelistedDirS(Common::getGet('pcdir'), self::DEFAULT_DIR);
     $orderby = "ORDER BY {$by} {$dir}";
     $query = "SELECT c.*, s.* FROM {$challs} c LEFT JOIN {$solved} s ON c.chall_id=s.csolve_cid AND s.csolve_uid={$uid} {$orderby}";
     $tVars = array('data' => $db->queryAll($query), 'sort_url' => GWF_WEB_ROOT . 'index.php?mo=Profile&me=Profile&username='******'user_name') . '&pcby=%BY%&pcdir=%DIR%#wc_profile_challenges', 'table_title' => $this->module->lang('tt_challs_for', array('', $user->display('user_name'))));
     return $this->module->templatePHP('challs_profile.php', $tVars);
 }
Ejemplo n.º 26
0
function Upgrade_PM_1_01(Module_PM $module)
{
    echo GWF_HTML::message('PM', 'TRIGGERED Upgrade_PM_1_01');
    echo GWF_HTML::message('PM', 'It is now possible to navigate prev/next for pms');
    $db = gdo_db();
    $pms = GWF_TABLE_PREFIX . 'pm';
    $query = "ALTER TABLE {$pms} ADD COLUMN pm_in_reply INT(11) UNSIGNED NOT NULL DEFAULT 0";
    if (false === $db->queryWrite($query)) {
        return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    $query = "ALTER TABLE {$pms} ADD INDEX pm_in_reply(pm_in_reply)";
    if (false === $db->queryWrite($query)) {
        return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    return '';
}
Ejemplo n.º 27
0
 public static function getTimings($with_diskspace = true)
 {
     $t_sql = $queries = 0;
     if (false !== ($db = gdo_db())) {
         $t_sql = $db->getQueryTime();
         $queries = $db->getQueryCount();
     }
     $t_total = microtime(true) - GWF_DEBUG_TIME_START;
     $mem_total = memory_get_peak_usage(true);
     $mem_user = memory_get_peak_usage(false);
     $disk_total = $disk_free = 0;
     if ($with_diskspace) {
         $disk_free = disk_free_space(dirname(__FILE__));
         $disk_total = disk_total_space(dirname(__FILE__));
     }
     return array('queries' => $queries, 't_sql' => $t_sql, 't_php' => $t_total - $t_sql, 't_total' => $t_total, 'mem_php' => $mem_total - $mem_user, 'mem_user' => $mem_user, 'mem_total' => $mem_total, 'space_free' => $disk_free, 'space_total' => $disk_total, 'space_used' => $disk_total - $disk_free);
 }
Ejemplo n.º 28
0
function Upgrade_GWF_3_05(Module_GWF $module)
{
    echo GWF_HTML::message('GWF', 'Triggering Upgrade_GWF_3_05');
    echo GWF_HTML::message('GWF', 'The module_name column got a unique index.');
    $db = gdo_db();
    $modules = GWF_TABLE_PREFIX . 'module';
    //	$query = "ALTER TABLE `$modules` DROP INDEX `module_name` ";
    //	if (false === ($db->queryWrite($query)))
    //	{
    //		return GWF_HTML::err('ERR_DATABASE', array( __FILE__, __LINE__));
    //	}
    $query = "ALTER TABLE `{$modules}` ADD UNIQUE INDEX `module_name` ( `module_name` )";
    if (false === $db->queryWrite($query)) {
        return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    return '';
}
Ejemplo n.º 29
0
 private function getAdminProfiles()
 {
     $admin = GWF_Group::getByName('admin')->getID();
     $u = GWF_TABLE_PREFIX . 'user';
     $ug = GWF_TABLE_PREFIX . 'usergroup';
     $db = gdo_db();
     $query = "SELECT user_name FROM {$ug} AS ug INNER JOIN {$u} AS u ON u.user_id=ug_userid WHERE ug_groupid={$admin}";
     if (false === ($result = $db->queryRead($query))) {
         return '';
     }
     $back = '';
     while (false !== ($row = $db->fetchRow($result))) {
         $name = $row[0];
         $back .= sprintf(', <a href="%s">%s</a>', GWF_WEB_ROOT . 'profile/' . urlencode($name), GWF_HTML::display($name));
     }
     $db->free($result);
     return substr($back, 2);
 }
Ejemplo n.º 30
0
 public function execute()
 {
     $letter = strtolower(Common::getGetString('letter'));
     if (!preg_match('/^[a-z]{1}$/D', $letter)) {
         return '';
     }
     $db = gdo_db();
     $users = GWF_TABLE_PREFIX . 'user';
     $query = "SELECT user_name FROM {$users} WHERE user_name LIKE '{$letter}%' ORDER BY user_name ASC";
     if (false === ($result = $db->queryRead($query))) {
         return '';
     }
     $back = array();
     while (false !== ($row = $db->fetchRow($result))) {
         $back[] = $row[0];
     }
     $db->free($result);
     return '(' . json_encode($back) . ');';
 }