Esempio n. 1
0
 public function get_font()
 {
     if (!($captcha_fonts = AWS_APP::cache()->get('captcha_fonts'))) {
         $captcha_fonts = fetch_file_lists(AWS_PATH . 'core/fonts/');
         AWS_APP::cache()->set('captcha_fonts', $captcha_fonts, get_setting('cache_level_normal'));
     }
     return array_random($captcha_fonts);
 }
Esempio n. 2
0
 /**
  * Generate the greeting for everyone!
  *
  * @return string
  */
 private function generateGreeting()
 {
     $currentHour = (int) date('H');
     if ($currentHour < 12) {
         return array_random(['gam', "Mornin'", 'Good morning', 'Morning. :)', 'Morning! :D']);
     }
     return array_random(['gpm', "Afternoon!", 'Good afternoon.', 'Afternoon~', 'Good afternoon. :D']);
 }
Esempio n. 3
0
function run($title, $search_for, $haystack)
{
    echo "<div class='row'>";
    echo "<div class='col-md-12'>";
    echo "<h2>{$title}</h2>";
    $json_str = json_encode($haystack);
    // Visual Output
    echo '<code>';
    echo "<b>Searching: \"{$search_for}\" in..</b>\n";
    var_dump($json_str);
    $result = (bool) strstr($json_str, $search_for) ? 'True' : 'False';
    echo "<strong>Result: {$result}</strong>";
    // Process
    $result = array_random($search_for, $haystack);
    echo "<h2>Result</h2>";
    var_dump($result);
    echo '</code>';
    echo '</div>';
    echo '</div>';
}
Esempio n. 4
0
		</footer>
        <!-- end footer -->

		<!-- begin .copyright -->
		<div class="copyright">

			<?php 
if (of_get_option('footer_copyright') == '') {
    ?>
				<!-- Created by <a href="http://www.s5themes.com/">Site5 WordPress Themes</a>. Experts in <a href="http://gk.site5.com/t/642">WordPress Hosting</a>. -->

				Powered by <a href="http://www.wordpress.org">WordPress</a> | <?php 
    echo array_random(array('Created', 'Coded', 'Built', 'Designed'));
    ?>
 by  <a href="http://gk.site5.com/t/642"><?php 
    echo array_random(array('Site5 WordPress Themes', 'Site5 WordPress Team', 'S5 WordPress Team', 'S5 WordPress Themes', 'S5 Themes', 'S5 WP Themes'));
    ?>
</a><br />
				<a href="http://gk.site5.com/t/642">Expert WordPress Hosting from Site5 - Try us free for 3 months! </a> 
			<?php 
} else {
    ?>
				<?php 
    echo of_get_option('footer_copyright');
    ?>
			<?php 
}
?>

		</div>
		<!-- end .copyright -->
Esempio n. 5
0
 public function index_square_action()
 {
     $per_page = 18;
     // 今日话题
     if ($today_topic = $this->model('topic')->get_topic_by_title(array_random(explode(',', $today_topics)))) {
         $today_topic['best_answer_users'] = $this->model('topic')->get_best_answer_users_by_topic_id($today_topic['topic_id'], 5);
         $today_topic['questions_list'] = $this->model('posts')->get_posts_list('question', 1, 3, 'new', explode(',', $today_topic['topic_id']));
     }
     TPL::assign('today_topic', $today_topic);
     // 专题列表
     switch ($_GET['channel']) {
         case 'focus':
             if ($topics_list = $this->model('topic')->get_focus_topic_list($this->user_id, calc_page_limit($_GET['page'], $per_page))) {
                 $topics_list_total_rows = $this->user_info['topic_focus_count'];
             }
             break;
         default:
         case 'hot':
             switch ($_GET['day']) {
                 case 'month':
                     $order = 'discuss_count_last_month DESC';
                     break;
                 case 'week':
                     $order = 'discuss_count_last_week DESC';
                     break;
                 default:
                     $order = 'discuss_count DESC';
                     break;
             }
             $topics_list = $this->model('topic')->get_child_topic_list(null, $order, $per_page, $_GET['page']);
             $topics_list_total_rows = $this->model('topic')->found_rows();
             break;
         case 'topic':
             $topic_ids[] = intval($_GET['topic_id']);
             if ($child_topic_ids = $this->model('topic')->get_child_topic_ids($_GET['topic_id'])) {
                 $topic_ids = array_merge($child_topic_ids, $topic_ids);
             }
             if ($topics_list = $this->model('topic')->get_child_topic_list('topic_id IN(' . implode(',', $topic_ids) . ') AND merged_id = 0', 'discuss_count DESC', $per_page, $_GET['page'])) {
                 $topics_list_total_rows = $this->model('topic')->found_rows();
             }
             break;
     }
     # get topic foucs info
     foreach ($topics_list as $key => $value) {
         $topics_list[$key]['has_focus'] = $this->model('topic')->has_focus_topic($this->user_id, $value['topic_id']);
     }
     TPL::assign('topics_list', $topics_list);
     TPL::assign('parent_topics', $this->model('topic')->get_parent_topics());
     TPL::assign('pagination', AWS_APP::pagination()->initialize(array('base_url' => get_js_url('/topic/channel-' . $_GET['channel'] . '__topic_id-' . $_GET['topic_id'] . '__day-' . $_GET['day']), 'total_rows' => $topics_list_total_rows, 'per_page' => $per_page))->create_links());
     $this->crumb(AWS_APP::lang()->_t('专题'), '/topic/');
     TPL::output('topic/square');
 }
Esempio n. 6
0
 public function square_action()
 {
     if (!$_GET['id'] and !$this->user_id) {
         $_GET['id'] = 'hot';
     }
     if (!$_GET['per_page']) {
         $_GET['per_page'] = 10;
     }
     switch ($_GET['id']) {
         default:
         case 'focus':
             if ($topics_list = $this->model('topic')->get_focus_topic_list($this->user_id, calc_page_limit($_GET['page'], $_GET['per_page']))) {
                 $topics_list_total_rows = $this->user_info['topic_focus_count'];
                 foreach ($topics_list as $key => $val) {
                     $topics_list[$key]['action_list'] = $this->model('posts')->get_posts_list('question', 1, 3, 'new', explode(',', $val['topic_id']));
                 }
             }
             $topic_key = array('topic_id', 'topic_title', 'topic_description', 'topic_pic');
             if (!empty($topics_list)) {
                 foreach ($topics_list as $k => $v) {
                     foreach ($v as $k_k => $v_v) {
                         if (!in_array($k_k, $topic_key)) {
                             unset($topics_list[$k][$k_k]);
                         }
                         if ($k_k = "topic_pic") {
                             $topics_list[$k][$k_k] = str_replace('_32_32', '_100_100', $topics_list[$k][$k_k]);
                         }
                     }
                 }
             }
             H::ajax_json_output(AWS_APP::RSM(array('total_rows' => $topics_list_total_rows, 'rows' => $topics_list), 1, null));
             break;
         case 'hot':
             if (!($topics_list = AWS_APP::cache()->get('square_hot_topic_list_' . intval($_GET['page'])))) {
                 if ($topics_list = $this->model('topic')->get_topic_list(null, 'discuss_count DESC', $_GET['per_page'], $_GET['page'])) {
                     $topics_list_total_rows = $this->model('topic')->found_rows();
                     AWS_APP::cache()->set('square_hot_topic_list_total_rows', $topics_list_total_rows, get_setting('cache_level_low'));
                     foreach ($topics_list as $key => $val) {
                         $topics_list[$key]['action_list'] = $this->model('posts')->get_posts_list('question', 1, 3, 'new', explode(',', $val['topic_id']));
                     }
                 }
                 AWS_APP::cache()->set('square_hot_topic_list_' . intval($_GET['page']), $topics_list, get_setting('cache_level_low'));
             } else {
                 $topics_list_total_rows = AWS_APP::cache()->get('square_hot_topic_list_total_rows');
             }
             $topic_key = array('topic_id', 'topic_title', 'topic_description', 'topic_pic');
             if (!empty($topics_list)) {
                 foreach ($topics_list as $k => $v) {
                     foreach ($v as $k_k => $v_v) {
                         if (!in_array($k_k, $topic_key)) {
                             unset($topics_list[$k][$k_k]);
                         }
                         if ($k_k = "topic_pic") {
                             $topics_list[$k][$k_k] = str_replace('_32_32', '_100_100', $topics_list[$k][$k_k]);
                         }
                     }
                 }
             }
             H::ajax_json_output(AWS_APP::RSM(array('total_rows' => $topics_list_total_rows, 'rows' => $topics_list), 1, null));
             break;
         case 'today':
             if ($today_topics = rtrim(get_setting('today_topics'), ',')) {
                 if (!($today_topic = AWS_APP::cache()->get('square_today_topic_' . md5($today_topics)))) {
                     if ($today_topic = $this->model('topic')->get_topic_by_title(array_random(explode(',', $today_topics)))) {
                         $today_topic['best_answer_users'] = $this->model('topic')->get_best_answer_users_by_topic_id($today_topic['topic_id'], 5);
                         $today_topic['questions_list'] = $this->model('posts')->get_posts_list('question', 1, 3, 'new', explode(',', $today_topic['topic_id']));
                         AWS_APP::cache()->set('square_today_topic_' . md5($today_topics), $today_topic, strtotime('Tomorrow') - time());
                     }
                 }
             }
             $topic_key = array('topic_id', 'topic_title', 'topic_description', 'topic_pic');
             if (!empty($topics_list)) {
                 foreach ($topics_list as $k => $v) {
                     foreach ($v as $k_k => $v_v) {
                         if (!in_array($k_k, $topic_key)) {
                             unset($topics_list[$k][$k_k]);
                         }
                         if ($k_k = "topic_pic") {
                             $topics_list[$k][$k_k] = str_replace('_32_32', '_100_100', $topics_list[$k][$k_k]);
                         }
                     }
                 }
             }
             H::ajax_json_output(AWS_APP::RSM(array('total_rows' => $topics_list_total_rows, 'rows' => $topics_list), 1, null));
             break;
             break;
     }
 }
 /**
  * Front-end display of widget.
  *
  * @see WP_Widget::widget()
  *
  * @param array $args     Widget arguments.
  * @param array $instance Saved values from database.
  */
 public function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('widget_title', $instance['title']);
     $user = $instance['user'];
     $playertype = $instance['playertype'];
     $autoplay = $instance['autoplay'] ? 'true' : 'false';
     $comments = $instance['comments'] ? 'true' : 'false';
     $artwork = $instance['artwork'] ? 'true' : 'false';
     $classes = $instance['classes'];
     $widthType = $instance['type'];
     $wp = $instance['wp'];
     $custom = $instance['custom'];
     $width = $widthType == 'wp' ? $wp : $custom;
     $behavior = $instance['behavior'];
     $number = $instance['number'];
     $format = $instance['format'];
     //Random User
     if ($user == "randomUser") {
         $options = get_option('soundcloud_is_gold_options');
         $soundcloudIsGoldUsers = isset($options['soundcloud_is_gold_users']) ? array_random($options['soundcloud_is_gold_users'], 1) : '';
         //printl($soundcloudIsGoldUsers[0][0]);
         if (isset($soundcloudIsGoldUsers)) {
             $user = $soundcloudIsGoldUsers[0][0];
         }
     }
     echo $before_widget;
     if (!empty($title)) {
         echo $before_title . $title . $after_title;
     }
     //Random User per Track
     if ($user == "randomUsers") {
         $options = get_option('soundcloud_is_gold_options');
         if (isset($options['soundcloud_is_gold_users'])) {
             //Never select more tracks than there is users.
             $number = count($options['soundcloud_is_gold_users']) <= $number ? count($options['soundcloud_is_gold_users']) : $number;
             $soundcloudIsGoldUsers = array_random($options['soundcloud_is_gold_users'], $number);
         }
         if (isset($soundcloudIsGoldUsers)) {
             foreach ($soundcloudIsGoldUsers as $userKey => $user) {
                 if ($userKey == 1) {
                     $autoplay = false;
                 }
                 foreach (get_soundcloud_is_gold_multiple_tracks_id($user[0], 1, $behavior == "latest" ? FALSE : TRUE, $format) as $key => $ids) {
                     if ($format == "favorites") {
                         $format = "tracks";
                     }
                     //Soundcloud treats Favorites as Tracks for the player.
                     echo soundcloud_is_gold_player($ids, NULL, $autoplay, $comments, $width, $classes, $playertype, NULL, $artwork, $format);
                 }
             }
         }
     } else {
         foreach (get_soundcloud_is_gold_multiple_tracks_id($user, $number, $behavior == "latest" ? FALSE : TRUE, $format) as $key => $ids) {
             if ($key == 1) {
                 $autoplay = false;
             }
             if ($format == "favorites") {
                 $format = "tracks";
             }
             //Soundcloud treats Favorites as Tracks for the player.
             echo soundcloud_is_gold_player($ids, NULL, $autoplay, $comments, $width, $classes, $playertype, NULL, $artwork, $format);
         }
     }
     echo $after_widget;
 }
Esempio n. 8
0
/**
 * Main function which will choose random browser
 * @param  array $lang  languages to choose from
 * @return string       user agent
 */
function random_uagent(array $lang = array('en-US'))
{
    list($browser, $os) = chooseRandomBrowserAndOs();
    $proc = array('lin' => array('i686', 'x86_64'), 'mac' => array('Intel', 'PPC', 'U; Intel', 'U; PPC'), 'win' => array('foo'));
    switch ($browser) {
        case 'firefox':
            $ua = "Mozilla/5.0 " . firefox($os);
            break;
        case 'safari':
            $ua = "Mozilla/5.0 " . safari($os);
            break;
        case 'iexplorer':
            $ua = "Mozilla/5.0 " . iexplorer($os);
            break;
        case 'opera':
            $ua = "Opera/" . rand(8, 9) . '.' . rand(10, 99) . ' ' . opera($os);
            break;
        case 'chrome':
            $ua = 'Mozilla/5.0 ' . chrome($os);
            break;
    }
    $ua = str_replace('{proc}', array_random($proc[$os]), $ua);
    $ua = str_replace('{lang}', array_random($lang), $ua);
    return $ua;
}
Esempio n. 9
0
 public function index_square_action()
 {
     if (is_mobile()) {
         HTTP::redirect('/m/topic/');
     }
     if ($today_topics = rtrim(get_setting('today_topics'), ',')) {
         if (!($today_topic = AWS_APP::cache()->get('square_today_topic_' . md5($today_topics)))) {
             if ($today_topic = $this->model('topic')->get_topic_by_title(array_random(explode(',', $today_topics)))) {
                 $today_topic['best_answer_users'] = $this->model('topic')->get_best_answer_users_by_topic_id($today_topic['topic_id'], 5);
                 $today_topic['questions_list'] = $this->model('posts')->get_posts_list('question', 1, 3, 'new', explode(',', $today_topic['topic_id']));
                 AWS_APP::cache()->set('square_today_topic_' . md5($today_topics), $today_topic, strtotime('Tomorrow') - time());
             }
         }
         TPL::assign('today_topic', $today_topic);
     }
     switch ($_GET['channel']) {
         case 'focus':
             if ($topics_list = $this->model('topic')->get_focus_topic_list($this->user_id, calc_page_limit($_GET['page'], 20))) {
                 $topics_list_total_rows = $this->user_info['topic_focus_count'];
             }
             TPL::assign('topics_list', $topics_list);
             break;
         default:
         case 'hot':
             switch ($_GET['day']) {
                 case 'month':
                     $order = 'discuss_count_last_month DESC';
                     break;
                 case 'week':
                     $order = 'discuss_count_last_week DESC';
                     break;
                 default:
                     $order = 'discuss_count DESC';
                     break;
             }
             $cache_key = 'square_hot_topic_list' . md5($order) . '_' . intval($_GET['page']);
             if (!($topics_list = AWS_APP::cache()->get($cache_key))) {
                 if ($topics_list = $this->model('topic')->get_topic_list(null, $order, 20, $_GET['page'])) {
                     $topics_list_total_rows = $this->model('topic')->found_rows();
                     AWS_APP::cache()->set('square_hot_topic_list_total_rows', $topics_list_total_rows, get_setting('cache_level_low'));
                 }
                 AWS_APP::cache()->set($cache_key, $topics_list, get_setting('cache_level_low'));
             } else {
                 $topics_list_total_rows = AWS_APP::cache()->get('square_hot_topic_list_total_rows');
             }
             TPL::assign('topics_list', $topics_list);
             break;
         case 'topic':
             if (!($topics_list = AWS_APP::cache()->get('square_parent_topics_topic_list_' . intval($_GET['topic_id']) . '_' . intval($_GET['page'])))) {
                 $topic_ids[] = intval($_GET['topic_id']);
                 if ($child_topic_ids = $this->model('topic')->get_child_topic_ids($_GET['topic_id'])) {
                     $topic_ids = array_merge($child_topic_ids, $topic_ids);
                 }
                 if ($topics_list = $this->model('topic')->get_topic_list('topic_id IN(' . implode(',', $topic_ids) . ') AND merged_id = 0', 'discuss_count DESC', 20, $_GET['page'])) {
                     $topics_list_total_rows = $this->model('topic')->found_rows();
                     AWS_APP::cache()->set('square_parent_topics_topic_list_' . intval($_GET['topic_id']) . '_total_rows', $topics_list_total_rows, get_setting('cache_level_low'));
                 }
                 AWS_APP::cache()->set('square_parent_topics_topic_list_' . intval($_GET['topic_id']) . '_' . intval($_GET['page']), $topics_list, get_setting('cache_level_low'));
             } else {
                 $topics_list_total_rows = AWS_APP::cache()->get('square_parent_topics_topic_list_' . intval($_GET['topic_id']) . '_total_rows');
             }
             TPL::assign('topics_list', $topics_list);
             break;
     }
     TPL::assign('parent_topics', $this->model('topic')->get_parent_topics());
     TPL::assign('new_topics', $this->model('topic')->get_topic_list(null, 'topic_id DESC', 10));
     TPL::assign('pagination', AWS_APP::pagination()->initialize(array('base_url' => get_js_url('/topic/channel-' . $_GET['channel'] . '__topic_id-' . $_GET['topic_id'] . '__day-' . $_GET['day']), 'total_rows' => $topics_list_total_rows, 'per_page' => 20))->create_links());
     $this->crumb(AWS_APP::lang()->_t('话题广场'), '/topic/');
     TPL::output('topic/square');
 }
Esempio n. 10
0
function randagent()
{
    $arrsch = array_random(array('lin', 'mac', 'lin2'));
    //echo "$arrsch\n";
    return firefox($arrsch);
}