public function test_install()
 {
     $db_tools = new \phpbb\db\tools($this->db);
     $this->assertTrue($db_tools->sql_table_exists('phpbb_gallery_albums'));
     $this->assertTrue($db_tools->sql_table_exists('phpbb_gallery_albums_track'));
     $this->assertTrue($db_tools->sql_table_exists('phpbb_gallery_comments'));
     $this->assertTrue($db_tools->sql_table_exists('phpbb_gallery_contests'));
     $this->assertTrue($db_tools->sql_table_exists('phpbb_gallery_favorites'));
     $this->assertTrue($db_tools->sql_table_exists('phpbb_gallery_images'));
     $this->assertTrue($db_tools->sql_table_exists('phpbb_gallery_modscache'));
     $this->assertTrue($db_tools->sql_table_exists('phpbb_gallery_permissions'));
     $this->assertTrue($db_tools->sql_table_exists('phpbb_gallery_rates'));
     $this->assertTrue($db_tools->sql_table_exists('phpbb_gallery_reports'));
     $this->assertTrue($db_tools->sql_table_exists('phpbb_gallery_roles'));
     $this->assertTrue($db_tools->sql_table_exists('phpbb_gallery_users'));
     $this->assertTrue($db_tools->sql_table_exists('phpbb_gallery_watch'));
     $this->assertTrue($db_tools->sql_table_exists('phpbb_gallery_log'));
 }
 public function test_install()
 {
     $db_tools = new \phpbb\db\tools($this->db);
     $this->assertTrue($db_tools->sql_table_exists('phpbb_posts_likes'));
 }
示例#3
0
 /**
  *  API function - set up shop
  */
 function install()
 {
     global $db;
     $db_tool = new \phpbb\db\tools($db);
     $schemas = array($this->table_captcha_questions => array('COLUMNS' => array('question_id' => array('UINT', null, 'auto_increment'), 'strict' => array('BOOL', 0), 'lang_id' => array('UINT', 0), 'lang_iso' => array('VCHAR:30', ''), 'question_text' => array('TEXT_UNI', '')), 'PRIMARY_KEY' => 'question_id', 'KEYS' => array('lang' => array('INDEX', 'lang_iso'))), $this->table_captcha_answers => array('COLUMNS' => array('question_id' => array('UINT', 0), 'answer_text' => array('STEXT_UNI', '')), 'KEYS' => array('qid' => array('INDEX', 'question_id'))), $this->table_qa_confirm => array('COLUMNS' => array('session_id' => array('CHAR:32', ''), 'confirm_id' => array('CHAR:32', ''), 'lang_iso' => array('VCHAR:30', ''), 'question_id' => array('UINT', 0), 'attempts' => array('UINT', 0), 'confirm_type' => array('USINT', 0)), 'KEYS' => array('session_id' => array('INDEX', 'session_id'), 'lookup' => array('INDEX', array('confirm_id', 'session_id', 'lang_iso'))), 'PRIMARY_KEY' => 'confirm_id'));
     foreach ($schemas as $table => $schema) {
         if (!$db_tool->sql_table_exists($table)) {
             $db_tool->sql_create_table($table, $schema);
         }
     }
 }
示例#4
0
    public static function top10($start = 0, $uaction = '')
    {
        global $db, $config, $sconfig, $user, $table_prefix, $tables, $request, $template, $phpbb_container;
        $module_aray = array(0 => 'COUNTRIES', 1 => 'REFERRALS', 2 => 'SEARCHENG', 3 => 'SEARCHTERMS', 4 => 'BROWSERS', 5 => 'CRAWLERS', 6 => 'SYSTEMS', 7 => 'MODULES', 8 => 'RESOLUTIONS', 9 => 'USERS', 10 => 'FL_DATE', 11 => 'POSTS', 12 => 'UNIQUE');
        $modules = self::get_modules();
        $db_tools = new \phpbb\db\tools($db);
        $searchresulttabel = $db_tools->sql_table_exists($table_prefix . 'searchresults');
        $sql_aray[] = 'SELECT d.description AS name, o.hits FROM ' . $tables['archive'] . ' o LEFT JOIN ' . $tables['domain'] . ' d ON (d.domain = o.name) 
						WHERE cat = 4 GROUP BY o.name ORDER BY hits DESC';
        $sql_aray[] = 'SELECT name, hits FROM ' . $tables['archive'] . ' WHERE cat = 7 ORDER BY hits DESC';
        $sql_aray[] = 'SELECT name, hits FROM ' . $tables['archive'] . ' WHERE cat = 7 ORDER BY hits DESC';
        $sql_aray[] = 'SELECT name, hits FROM ' . $tables['archive'] . ' WHERE cat = 8 ORDER BY hits DESC';
        $sql_aray[] = 'SELECT name, hits FROM ' . $tables['archive'] . ' WHERE cat = 2 ORDER BY hits DESC';
        $sql_aray[] = 'SELECT a.name, a.hits FROM ' . $tables['archive'] . ' a LEFT JOIN ' . BOTS_TABLE . ' b ON a.name = b.bot_name 
					   WHERE  a.cat = 5 AND b.bot_name IS NOT NULL ORDER BY hits DESC';
        $sql_aray[] = 'SELECT name, hits FROM ' . $tables['archive'] . ' WHERE cat = 3 ORDER BY hits DESC';
        $sql_aray[] = 'SELECT name, hits FROM ' . $tables['archive'] . ' WHERE cat = 1 ORDER BY hits DESC';
        $sql_aray[] = 'SELECT name, hits FROM ' . $tables['archive'] . ' WHERE cat = 6 ORDER BY hits DESC';
        $sql_aray[] = 'SELECT a.name, a.hits FROM ' . $tables['archive'] . ' a LEFT JOIN ' . USERS_TABLE . ' b ON a.name = b.username 
					   WHERE  a.cat = 5 AND b.username IS NOT NULL ORDER BY hits DESC';
        $sql_aray[] = 'SELECT "First startdate" AS name, MIN(first) AS hits FROM ' . $tables['archive'] . ' UNION 
					   SELECT "Last startdate" AS name, MAX(last) AS hits FROM ' . $tables['archive'] . ' 
					   UNION SELECT "Rows" AS name, ROUND(COUNT(id), 0) AS hits FROM ' . $tables['archive'] . ' 
					   UNION SELECT "Table size" AS name, CASE WHEN data_length + index_length < 1024 THEN CONCAT(ROUND(((data_length + index_length)), 1), " B")
					   WHEN data_length + index_length BETWEEN 1024 AND 1048576 THEN CONCAT(ROUND(((data_length + index_length) / 1024), 1), " Kb")
					   WHEN data_length + index_length > 1048576 THEN CONCAT(ROUND(((data_length + index_length) / 1024 / 1024), 1), " Mb")
					   END AS hits FROM information_schema.TABLES 
					   WHERE table_schema = "' . $db->get_db_name() . '" AND table_name = "' . $tables['archive'] . '"' . ($searchresulttabel ? ' UNION SELECT "Searchwords" AS name, COUNT(search_key) AS hits FROM ' . $table_prefix . 'searchresults' : '');
        $sql_aray[] = '';
        $sql_aray[] = 'SELECT name, hits FROM ' . $tables['archive'] . ' WHERE cat = 9 ORDER BY hits DESC';
        $pagination = $phpbb_container->get('pagination');
        $base_url = $uaction . '&amp;screen=top10';
        $pagination->generate_template_pagination($base_url, 'pagination', 'start', 13, 6, $start);
        for ($i = $start; $i < min($start + 6, sizeof($module_aray)); $i++) {
            $template->assign_block_vars('blocks', array('KEY' => $i, 'TITLE' => $user->lang[$module_aray[$i]]));
            if ($i < 12) {
                $result = $db->sql_query_limit($sql_aray[$i], 10, 0);
                $counter = 0;
                while ($row = $db->sql_fetchrow($result)) {
                    $counter += 1;
                    $template->assign_block_vars('blocks.block', array('COUNTER' => $counter, 'NAME' => $i == 7 ? isset($modules[$row['name']]) ? $modules[$row['name']] : 'Not found' : $row['name'], 'HITS' => $i == 10 && isset($row['hits']) && $counter < 3 ? $user->format_date($row['hits'], 'd m \'y') : self::roundk($row['hits']), 'THITS' => $i == 10 && isset($row['hits']) && $counter < 3 ? $user->format_date($row['hits']) : $row['hits']));
                }
                if ($counter < 10) {
                    for ($counter + 1; $counter + 1 <= 10; $counter++) {
                        if ($i == 11) {
                            $aray[0] = array('name' => 'Posts per day', 'hits' => round($config['num_posts'] / ((time() - $config['board_startdate']) / 86400), 1));
                            $aray[1] = array('name' => 'Posts per month', 'hits' => round($config['num_posts'] / ((time() - $config['board_startdate']) / 2440800), 1));
                            $aray[2] = array('name' => 'Topics per day', 'hits' => round($config['num_topics'] / ((time() - $config['board_startdate']) / 86400), 1));
                            $aray[3] = array('name' => 'Topics per month', 'hits' => round($config['num_topics'] / ((time() - $config['board_startdate']) / 2440800), 1));
                            $aray[4] = array('name' => 'Forumdays', 'hits' => floor((time() - $config['board_startdate']) / 86400));
                            $aray[5] = array('name' => 'Average posts per topic', 'hits' => floor($config['num_posts'] / $config['num_topics']));
                            $aray[6] = array('name' => 'Average posts per user', 'hits' => floor($config['num_posts'] / $config['num_users']));
                        }
                        $template->assign_block_vars('blocks.block', array('COUNTER' => $counter + 1, 'NAME' => $i == 11 && isset($aray[$counter]) ? $aray[$counter]['name'] : '', 'HITS' => $i == 11 && isset($aray[$counter]) ? $aray[$counter]['hits'] : ''));
                    }
                }
            } else {
                $result = $db->sql_query_limit($sql_aray[$i], 10, 0);
                $counter = 0;
                while ($row = $db->sql_fetchrow($result)) {
                    $counter += 1;
                    $template->assign_block_vars('blocks.block', array('COUNTER' => $counter, 'NAME' => $user->format_date($row['name'], 'd F \'y'), 'HITS' => self::roundk($row['hits']), 'THITS' => $row['hits']));
                }
            }
        }
        $template->assign_vars(array('U_ACTION' => $uaction, 'SUB_DISPLAY' => 'top10'));
    }