コード例 #1
0
function check_push_events_bitbucket($repo)
{
    $data = get_api_data("/api/1.0/repositories/{$repo}/events", "bitbucket");
    $changesets = get_api_data("/api/1.0/repositories/{$repo}/changesets?limit=10", "bitbucket");
    for ($i = 0; $i < count($data["events"]); $i++) {
        if (isset($data["events"][$i]["utc_created_on"]) == False) {
            continue;
        }
        $timestamp = $data["events"][$i]["utc_created_on"];
        $t = convert_timestamp($timestamp, "Y-m-d H:i:s      ");
        $dt = microtime(True) - $t;
        if ($dt <= TIME_LIMIT_SEC) {
            if ($data["events"][$i]["event"] == "pushed") {
                pm(FEED_CHAN, chr(3) . "13" . "push to https://bitbucket.org/{$repo} @ " . date("H:i:s", $t) . " by " . $data["events"][$i]["user"]["username"]);
                $commits = $data["events"][$i]["description"]["commits"];
                for ($j = 0; $j < count($commits); $j++) {
                    $changeset = bitbucket_get_changeset($changesets, $commits[$j]["hash"]);
                    if ($changeset === False) {
                        pm(FEED_CHAN, "changeset not found");
                        continue;
                    }
                    $desc = $commits[$j]["description"];
                    if ($desc != $changeset["message"]) {
                        continue;
                    }
                    pm(FEED_CHAN, chr(3) . "11" . "  " . $changeset["author"] . ": " . $changeset["message"]);
                    $url = "https://bitbucket.org/{$repo}/commits/" . $commits[$j]["hash"];
                    pm(FEED_CHAN, chr(3) . "11" . "  " . $url);
                }
            }
        }
    }
}
コード例 #2
0
ファイル: time_lib.php プロジェクト: cmn32480/exec-irc-bot
function convert_google_location_time($time)
{
    # 6:00 PM Friday, August 29, 2014 (GMT+10) Time in Traralgon VIC, Australia
    $result = array();
    $parts = explode(" ", $time);
    if (count($parts) < 10) {
        return False;
    }
    $timestamp = $parts[0];
    for ($i = 1; $i <= 6; $i++) {
        $timestamp = $timestamp . " " . $parts[$i];
    }
    $result["timezone"] = substr($parts[6], 1, strlen($parts[6]) - 2);
    for ($i = 0; $i <= 8; $i++) {
        array_shift($parts);
    }
    $result["location"] = implode(" ", $parts);
    $result["timestamp"] = convert_timestamp($timestamp, "g:i A l, F j, Y (TO)");
    return $result;
}
コード例 #3
0
ファイル: functions.php プロジェクト: vicpril/rep_bidqa
function projectTheme_get_post_outstanding_project_function()
{
    $pid = get_the_ID();
    global $post, $current_user;
    get_currentuserinfo();
    $ending = get_post_meta(get_the_ID(), 'ending', true);
    $sec = $ending - current_time('timestamp', 0);
    $location = get_post_meta(get_the_ID(), 'Location', true);
    $closed = get_post_meta(get_the_ID(), 'closed', true);
    $featured = get_post_meta(get_the_ID(), 'featured', true);
    $private_bids = get_post_meta(get_the_ID(), 'private_bids', true);
    $paid = get_post_meta(get_the_ID(), 'paid', true);
    $budget = ProjectTheme_get_budget_name_string_fromID(get_post_meta($pid, 'budgets', true));
    $proposals = sprintf(__('%s proposals', 'ProjectTheme'), projectTheme_number_of_bid($pid));
    //$proposals 			= sprintf(__('%s proposals','ProjectTheme'), projectTheme_number_of_bid($pid));
    $posted = get_the_time("jS F Y");
    $auth = get_userdata($post->post_author);
    $hide_project_p = get_post_meta($post->ID, 'private_bids', true);
    $tm_d = get_post_meta(get_the_ID(), 'expected_delivery', true);
    $tm_bid = Bid::get_by_pid_uid($pid, $current_user->ID)->expected_delivery;
    $due_date = sprintf(__('Due Date: %s', 'ProjectTheme'), date_i18n('d-M-Y g:iA', $tm_bid));
    //----------------------
    //		$bid = projectTheme_get_bid_by_uid($pid, $current_user->ID);
    $bid = Bid::get_by_pid_uid($pid, $current_user->ID, true);
    $mark_coder_delivered = Bid::get_field_by_id($bid->id, 'mark_coder_delivered', $single = true);
    $my_bid = projecttheme_get_show_price($bid->bid);
    //		$mark_coder_delivered 	= get_post_meta(get_the_ID(), 'mark_coder_delivered', true);
    ?>

    	

        <div class="post" id="post-<?php 
    the_ID();
    ?>
"><div class="padd10">

    		<div class="post-title"><a href="<?php 
    the_permalink();
    ?>
"><?php 
    the_title();
    ?>
</a>

            

             <?php 
    if ($featured == "1") {
        echo '<span class="featured_thing_project2">' . __('Featured Project', 'ProjectTheme') . '</span>';
    }
    if ($hide_project_p == "1" or $hide_project_p == "yes") {
        echo '<span class="private_thing_project2">' . __('Sealed Bidding', 'ProjectTheme') . '</span>';
    }
    ?>

            

            </div>

    		<div class="post-main-details">

            	<ul>

                	<li>

                    	<p><img src="<?php 
    bloginfo('template_url');
    ?>
/images/wallet_icon2.png" alt="project budget" width="16" height="16" /></p>

                        <h4><?php 
    echo sprintf(__('My Bid: %s', 'ProjectTheme'), $my_bid);
    ?>
</h4>

                    </li>

                    

                    <li>

                    	<p><img src="<?php 
    bloginfo('template_url');
    ?>
/images/prop_icon.png" alt="project proposals" width="16" height="16" /></p>

                        <h4><?php 
    echo $proposals;
    ?>
</h4>

                    </li>

                    

                    <li>

                    	<p><img src="<?php 
    bloginfo('template_url');
    ?>
/images/cal_icon.png" alt="project calendar" width="16" height="16" /></p>

                        <h4><?php 
    echo $posted;
    ?>
</h4>

                    </li>

                    

                    <li class="last">

                    	<p><img src="<?php 
    bloginfo('template_url');
    ?>
/images/clock_icon.png" alt="project clock" width="16" height="16" /></p>

                        <h4><?php 
    echo $due_date;
    ?>
</h4>

                    </li>

                    

                </ul>

            </div> <!-- end post-main-details -->

          

            <div class="excerpt-thing">

                <?php 
    if ($mark_coder_delivered != "1") {
        $time_spent = get_post_meta($pid, 'time_spent', true);
        if ($time_spent) {
            $time_spent = unserialize($time_spent);
        } else {
            $button_timer = '<button class="work_timer" act="start" pid="' . $pid . '">Start work timer</button>';
        }
        if ($time_spent[$current_user->ID]) {
            $curent_time_spent = $time_spent[$current_user->ID]['count_time'];
            if ($time_spent[$current_user->ID]['start'] == 0) {
                $button_timer = '<button class="work_timer" act="start" pid="' . $pid . '">Start work timer</button>';
                $timer_class = 'not_active_timer';
            }
            if ($time_spent[$current_user->ID]['end'] == 0) {
                $tm = current_time('timestamp', 0);
                $curent_time_spent = $time_spent[$current_user->ID]['count_time'] + $tm - $time_spent[$current_user->ID]['start'];
                //$curent_time_spent = $time_spent[$uid]['count_time'];
                $button_timer = '<button class="work_timer" act="stop" pid="' . $pid . '">Stop work timer</button>';
                $timer_class = 'active_timer';
            }
        } else {
            $curent_time_spent = 0;
            $button_timer = '<button class="work_timer" act="start" pid="' . $pid . '">Start work timer</button>';
        }
    } elseif ($mark_coder_delivered == 1) {
        $time_spent = get_post_meta($pid, 'time_spent', true);
        if ($time_spent) {
            $time_spent = unserialize($time_spent);
            $curent_time_spent = $time_spent[$current_user->ID]['count_time'];
        } else {
            $curent_time_spent = 0;
        }
    }
    ?>
     

                              	

                <div class="my-deliv_2 work_timer_line">

                <?php 
    /*$hours = floor($curent_time_spent/3600);                 	
    
                     	$minutes = floor(($curent_time_spent/3600 - $hours)*60);                 	
    
                     	if($minutes<10){$minutes='0'.$minutes;}
    
    					$seconds = round(((($curent_time_spent/3600 - $hours)*60)-$minutes)*60);
    
    					if($seconds<10){$seconds='0'.$seconds;}
    
    					if($hours<10){$hours='0'.$hours;}
    
                     	$str_time = $hours.':'.$minutes.':'.$seconds;*/
    $str_time = convert_timestamp($curent_time_spent);
    ?>

                	<?php 
    echo $button_timer . '<strong> Time spent: <span  class="' . $timer_class . '" id="stopwatch' . $pid . '" cur_time="' . $curent_time_spent . '">' . $str_time . '</span></strong>';
    ?>

                </div> 

                <div class="work_timer_terms">  

                	<div class="work_timer_terms_inner">

	                	By clicking in, you acknowledge that the project owner has the right to terminate your participation in this project due to any of the following:<br>

	                	1. Inadequate performance<br>

	                	2. Unmet deadlines<br>

	                	3. Lack of communication<br>

	                	etc. (more to be added)<br>

	                	<label><input type="checkbox" class="timer_accept"> accept</label><br>

	                	<input type="button" value="cancel" class="cansel_timer"><input type="button" value="ok" class="accept_timer">

	                </div>

                </div> 

                	<?php 
    if ($mark_coder_delivered != "1") {
        ?>

            	<div class="my-deliv_1"><?php 
        _e('After finishing the work on the project, you can mark it as <em><strong>delivered</strong></em>', 'ProjectTheme');
        ?>
</div>

                	<?php 
    }
    ?>

                <div class="my-deliv_2">

					 	<?php 
    do_action('ProjectTheme_outstanding_proj_buttons');
    ?>
    

		

						<?php 
    if ($mark_coder_delivered != "1") {
        $cannot_mark_delivered = 0;
        $projectTheme_enable_paypal_ad = get_option('projectTheme_enable_paypal_ad');
        if ($projectTheme_enable_paypal_ad == "yes") {
            $adaptive_done = get_post_meta(get_the_ID(), 'adaptive_done', true);
            if (empty($adaptive_done)) {
                $cannot_mark_delivered = 1;
            }
        }
        if (!$cannot_mark_delivered) {
            ?>

           

                            <a href="<?php 
            echo get_bloginfo('siteurl');
            ?>
/?p_action=mark_delivered&pid=<?php 
            echo get_the_ID();
            ?>
&bid=<?php 
            echo $bid->id;
            ?>
" 

                            class="green_btn"><?php 
            echo __("Mark Delivered", "ProjectTheme");
            ?>
</a>

                            

                            

                            <?php 
        } else {
            echo '<div class="cpts_n1">';
            _e('The Project Owner must deposit the money escrow through PayPal before the project starts.', 'ProjectTheme');
            echo '</div>';
        }
        $projectTheme_enable_paypal_ad = get_option('projectTheme_enable_paypal_ad');
        if ($projectTheme_enable_paypal_ad == "yes") {
            $adaptive_done = get_post_meta(get_the_ID(), 'adaptive_done', true);
            if ($adaptive_done == 'started') {
                echo '<br/>';
                echo '<div style="margin-top:20px;" class="ep_ep2">' . __('The project owner has put the money into escrow for you. Once you mark the project as delivered the owner will release the money. ', 'ProjectTheme') . '</div>';
            }
        }
        ?>

                            

                       

                       <?php 
    } else {
        //                            $dv = get_post_meta(get_the_ID(), 'mark_coder_delivered_date', true);
        $dv = Bid::get_field_by_id($bid->id, 'mark_coder_delivered_date', true);
        $dv = date_i18n('d-M-Y H:i:s', $dv);
        ?>

                       

                       <span class="zbk_zbk">

                       <?php 
        printf(__("Awaiting buyer response.<br/>Marked as delivered on: %s", "ProjectTheme"), $dv);
        ?>

                       </span>

                       

                       <?php 
    }
    ?>



                

                </div>

            </div> <!-- end excerpt-thing -->

            

            

            <div class="user-poster-thing">

            	<div class="user-avatar-me">

                	<img src="<?php 
    echo ProjectTheme_get_avatar($post->post_author, 25, 25);
    ?>
" alt="avatar-user" class="acc_m1" width="25" height="25" />

                </div>

                

                <div class="user-avatar-me fun-time">

                <div class="post-main-details">

            	<ul>

                	<li><a class="avatar-posted-by-username" href="<?php 
    bloginfo('siteurl');
    ?>
/?p_action=user_profile&post_author=<?php 
    echo $post->post_author;
    ?>
"><?php 
    echo $auth->user_login;
    ?>
</a></li>

                	<li><?php 
    echo ProjectTheme_project_get_star_rating($post->post_author);
    ?>
</li>

                    <li class="last"><a href="<?php 
    echo ProjectTheme_get_user_feedback_link($post->post_author);
    ?>
"><?php 
    _e('View User Feedback', 'ProjectTheme');
    ?>
</a></li>

                </ul>

                

                </div>

                </div>

                

            </div> <!-- end user-poster-thing -->

        

        </div></div>

        

        <?php 
}
コード例 #4
0
function search_to_sql($link, $search, $match_on)
{
    $search_query_part = "";
    $keywords = explode(" ", $search);
    $query_keywords = array();
    foreach ($keywords as $k) {
        if (strpos($k, "-") === 0) {
            $k = substr($k, 1);
            $not = "NOT";
        } else {
            $not = "";
        }
        $commandpair = explode(":", mb_strtolower($k), 2);
        if ($commandpair[0] == "note" && $commandpair[1]) {
            if ($commandpair[1] == "true") {
                array_push($query_keywords, "({$not} (note IS NOT NULL AND note != ''))");
            } else {
                array_push($query_keywords, "({$not} (note IS NULL OR note = ''))");
            }
        } else {
            if ($commandpair[0] == "star" && $commandpair[1]) {
                if ($commandpair[1] == "true") {
                    array_push($query_keywords, "({$not} (marked = true))");
                } else {
                    array_push($query_keywords, "({$not} (marked = false))");
                }
            } else {
                if ($commandpair[0] == "pub" && $commandpair[1]) {
                    if ($commandpair[1] == "true") {
                        array_push($query_keywords, "({$not} (published = true))");
                    } else {
                        array_push($query_keywords, "({$not} (published = false))");
                    }
                } else {
                    if (strpos($k, "@") === 0) {
                        $user_tz_string = get_pref($link, 'USER_TIMEZONE', $_SESSION['uid']);
                        $orig_ts = strtotime(substr($k, 1));
                        $k = date("Y-m-d", convert_timestamp($orig_ts, $user_tz_string, 'UTC'));
                        //$k = date("Y-m-d", strtotime(substr($k, 1)));
                        array_push($query_keywords, "(" . SUBSTRING_FOR_DATE . "(updated,1,LENGTH('{$k}')) {$not} = '{$k}')");
                    } else {
                        if ($match_on == "both") {
                            array_push($query_keywords, "(UPPER(ttrss_entries.title) {$not} LIKE UPPER('%{$k}%')\n\t\t\t\t\t\tOR UPPER(ttrss_entries.content) {$not} LIKE UPPER('%{$k}%'))");
                        } else {
                            if ($match_on == "title") {
                                array_push($query_keywords, "(UPPER(ttrss_entries.title) {$not} LIKE UPPER('%{$k}%'))");
                            } else {
                                if ($match_on == "content") {
                                    array_push($query_keywords, "(UPPER(ttrss_entries.content) {$not} LIKE UPPER('%{$k}%'))");
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    $search_query_part = implode("AND", $query_keywords);
    return $search_query_part;
}
コード例 #5
0
ファイル: functions2.php プロジェクト: zamentur/ttrss_ynh
function search_to_sql($search)
{
    $search_query_part = "";
    $keywords = str_getcsv($search, " ");
    $query_keywords = array();
    $search_words = array();
    foreach ($keywords as $k) {
        if (strpos($k, "-") === 0) {
            $k = substr($k, 1);
            $not = "NOT";
        } else {
            $not = "";
        }
        $commandpair = explode(":", mb_strtolower($k), 2);
        switch ($commandpair[0]) {
            case "title":
                if ($commandpair[1]) {
                    array_push($query_keywords, "({$not} (LOWER(ttrss_entries.title) LIKE '%" . db_escape_string(mb_strtolower($commandpair[1])) . "%'))");
                } else {
                    array_push($query_keywords, "(UPPER(ttrss_entries.title) {$not} LIKE UPPER('%{$k}%')\n\t\t\t\t\t\t\tOR UPPER(ttrss_entries.content) {$not} LIKE UPPER('%{$k}%'))");
                    array_push($search_words, $k);
                }
                break;
            case "author":
                if ($commandpair[1]) {
                    array_push($query_keywords, "({$not} (LOWER(author) LIKE '%" . db_escape_string(mb_strtolower($commandpair[1])) . "%'))");
                } else {
                    array_push($query_keywords, "(UPPER(ttrss_entries.title) {$not} LIKE UPPER('%{$k}%')\n\t\t\t\t\t\t\tOR UPPER(ttrss_entries.content) {$not} LIKE UPPER('%{$k}%'))");
                    array_push($search_words, $k);
                }
                break;
            case "note":
                if ($commandpair[1]) {
                    if ($commandpair[1] == "true") {
                        array_push($query_keywords, "({$not} (note IS NOT NULL AND note != ''))");
                    } else {
                        if ($commandpair[1] == "false") {
                            array_push($query_keywords, "({$not} (note IS NULL OR note = ''))");
                        } else {
                            array_push($query_keywords, "({$not} (LOWER(note) LIKE '%" . db_escape_string(mb_strtolower($commandpair[1])) . "%'))");
                        }
                    }
                } else {
                    array_push($query_keywords, "(UPPER(ttrss_entries.title) {$not} LIKE UPPER('%{$k}%')\n\t\t\t\t\t\t\tOR UPPER(ttrss_entries.content) {$not} LIKE UPPER('%{$k}%'))");
                    if (!$not) {
                        array_push($search_words, $k);
                    }
                }
                break;
            case "star":
                if ($commandpair[1]) {
                    if ($commandpair[1] == "true") {
                        array_push($query_keywords, "({$not} (marked = true))");
                    } else {
                        array_push($query_keywords, "({$not} (marked = false))");
                    }
                } else {
                    array_push($query_keywords, "(UPPER(ttrss_entries.title) {$not} LIKE UPPER('%{$k}%')\n\t\t\t\t\t\t\tOR UPPER(ttrss_entries.content) {$not} LIKE UPPER('%{$k}%'))");
                    if (!$not) {
                        array_push($search_words, $k);
                    }
                }
                break;
            case "pub":
                if ($commandpair[1]) {
                    if ($commandpair[1] == "true") {
                        array_push($query_keywords, "({$not} (published = true))");
                    } else {
                        array_push($query_keywords, "({$not} (published = false))");
                    }
                } else {
                    array_push($query_keywords, "(UPPER(ttrss_entries.title) {$not} LIKE UPPER('%{$k}%')\n\t\t\t\t\t\t\tOR UPPER(ttrss_entries.content) {$not} LIKE UPPER('%{$k}%'))");
                    if (!$not) {
                        array_push($search_words, $k);
                    }
                }
                break;
            default:
                if (strpos($k, "@") === 0) {
                    $user_tz_string = get_pref('USER_TIMEZONE', $_SESSION['uid']);
                    $orig_ts = strtotime(substr($k, 1));
                    $k = date("Y-m-d", convert_timestamp($orig_ts, $user_tz_string, 'UTC'));
                    //$k = date("Y-m-d", strtotime(substr($k, 1)));
                    array_push($query_keywords, "(" . SUBSTRING_FOR_DATE . "(updated,1,LENGTH('{$k}')) {$not} = '{$k}')");
                } else {
                    array_push($query_keywords, "(UPPER(ttrss_entries.title) {$not} LIKE UPPER('%{$k}%')\n\t\t\t\t\t\t\tOR UPPER(ttrss_entries.content) {$not} LIKE UPPER('%{$k}%'))");
                    if (!$not) {
                        array_push($search_words, $k);
                    }
                }
        }
    }
    $search_query_part = implode("AND", $query_keywords);
    return array($search_query_part, $search_words);
}
コード例 #6
0
ファイル: work_timer.php プロジェクト: vicpril/ProjectTheme
    if ($_POST['act'] == 'start') {
        $time_spent[$uid]['start'] = $tm;
        $time_spent[$uid]['end'] = 0;
        $time_spent = serialize($time_spent);
        update_post_meta($pid, 'time_spent', $time_spent);
        echo '<button class="work_timer" act="stop" pid="' . $pid . '">Stop work timer</button>';
        echo '<strong> Time spent: <span  class="active_timer" id="stopwatch' . $pid . '" cur_time="' . $curent_time_spent . '">' . $str_time . '</span></strong>';
    } elseif ($_POST['act'] == 'stop') {
        $time_spent[$uid]['end'] = $tm;
        if ($time_spent[$uid]['start'] > 0) {
            $time_spent[$uid]['count_time'] += round($time_spent[$uid]['end'] - $time_spent[$uid]['start']);
        } else {
            $time_spent[$uid]['count_time'] += 0;
        }
        $curent_time_spent = $time_spent[$uid]['count_time'];
        $str_time = convert_timestamp($curent_time_spent);
        $time_spent[$uid]['start'] = 0;
        $time_spent = serialize($time_spent);
        update_post_meta($pid, 'time_spent', $time_spent);
        echo '<button class="work_timer" act="start" pid="' . $pid . '">Start work timer</button>';
        echo '<strong> Time spent: <span  class="not_active_timer" id="stopwatch' . $pid . '" cur_time="' . $curent_time_spent . '">' . $str_time . '</span></strong>';
    }
} else {
    $curent_time_spent = 0;
    $str_time = '00:00:00';
    if ($_POST['act'] == 'start') {
        $time_spent[$uid]['start'] = $tm;
        $time_spent[$uid]['end'] = 0;
        $time_spent[$uid]['count_time'] = 0;
        $time_spent = serialize($time_spent);
        update_post_meta($pid, 'time_spent', $time_spent);
コード例 #7
0
ファイル: show.php プロジェクト: staydecent/wp-sourdough
    /**
     * How to display the widget on the screen.
     */
    function widget($args, $instance)
    {
        extract($args);
        /* Our variables from the widget settings. */
        $title = apply_filters('widget_title', $instance['title']);
        $number = $instance['number'];
        /* Before widget (defined by themes). */
        echo $before_widget;
        /* Display the widget title if one was input (before and after defined by themes). */
        if ($title) {
            echo $before_title . $title . $after_title;
        }
        rewind_posts();
        wp_reset_query();
        $count;
        $args = array('post_type' => 'show', 'orderby' => 'datetime', 'meta_key' => 'datetime', 'order' => 'ASC');
        query_posts($args);
        ?>
		
		<?php 
        if (have_posts()) {
            ?>

            <ul id="gigs">

			<?php 
            while (have_posts() && $count < $number) {
                the_post();
                ?>
            
            <?php 
                $location = get_the_term_list(get_the_ID(), 'location', '', ', ', '');
                $venue = get_the_term_list(get_the_ID(), 'venue', '', ', ', '');
                $tour = get_the_term_list(get_the_ID(), 'tour', '', ', ', '');
                $date = get_post_meta(get_the_ID(), "timedate", true);
                ?>
            	<li class="gig">
                    <span class="tour"><?php 
                echo $tour;
                ?>
</span>
                	<h4>
	                	<a href="<?php 
                the_permalink();
                ?>
"><?php 
                the_title();
                ?>
</a>
	                    <?php 
                $ticketlink = get_post_meta(get_the_ID(), 'ticketlink', true);
                ?>
	                    <?php 
                if ($ticketlink) {
                    ?>
	                     <a class="ticketlink" href="<?php 
                    echo $ticketlink;
                    ?>
">(<span><?php 
                    _e("tickets", "garageband");
                    ?>
</span>)</a>
	                    <?php 
                }
                ?>
                	</h4>
                	<span class="date">
                    	<?php 
                $timestamp = get_post_meta(get_the_ID(), 'datetime', true);
                echo convert_timestamp($timestamp, "g:s A, F d, Y") . " ";
                ?>
                    </span>
                    <span class="location"><?php 
                echo $venue;
                ?>
 <?php 
                if ($location) {
                    echo " in " . $location;
                }
                ?>
</span>
                </li>
                
			<?php 
                $count++;
            }
            ?>
            
            </ul>
                        
        <?php 
        }
        ?>

		<?php 
        /* After widget (defined by themes). */
        echo $after_widget;
    }
コード例 #8
0
ファイル: functions.php プロジェクト: rolfkleef/Tiny-Tiny-RSS
function prepare_headlines_digest($link, $user_id, $days = 1, $limit = 1000)
{
    require_once "lib/MiniTemplator.class.php";
    $tpl = new MiniTemplator();
    $tpl_t = new MiniTemplator();
    $tpl->readTemplateFromFile("templates/digest_template_html.txt");
    $tpl_t->readTemplateFromFile("templates/digest_template.txt");
    $user_tz_string = get_pref($link, 'USER_TIMEZONE', $user_id);
    $local_ts = convert_timestamp(time(), 'UTC', $user_tz_string);
    $tpl->setVariable('CUR_DATE', date('Y/m/d', $local_ts));
    $tpl->setVariable('CUR_TIME', date('G:i', $local_ts));
    $tpl_t->setVariable('CUR_DATE', date('Y/m/d', $local_ts));
    $tpl_t->setVariable('CUR_TIME', date('G:i', $local_ts));
    $affected_ids = array();
    if (DB_TYPE == "pgsql") {
        $interval_query = "ttrss_entries.date_updated > NOW() - INTERVAL '{$days} days'";
    } else {
        if (DB_TYPE == "mysql") {
            $interval_query = "ttrss_entries.date_updated > DATE_SUB(NOW(), INTERVAL {$days} DAY)";
        }
    }
    $result = db_query($link, "SELECT ttrss_entries.title,\n\t\t\t\tttrss_feeds.title AS feed_title,\n\t\t\t\tCOALESCE(ttrss_feed_categories.title, '" . __('Uncategorized') . "') AS cat_title,\n\t\t\t\tdate_updated,\n\t\t\t\tttrss_user_entries.ref_id,\n\t\t\t\tlink,\n\t\t\t\tscore,\n\t\t\t\tcontent,\n\t\t\t\t" . SUBSTRING_FOR_DATE . "(last_updated,1,19) AS last_updated\n\t\t\tFROM\n\t\t\t\tttrss_user_entries,ttrss_entries,ttrss_feeds\n\t\t\tLEFT JOIN\n\t\t\t\tttrss_feed_categories ON (cat_id = ttrss_feed_categories.id)\n\t\t\tWHERE\n\t\t\t\tref_id = ttrss_entries.id AND feed_id = ttrss_feeds.id\n\t\t\t\tAND include_in_digest = true\n\t\t\t\tAND {$interval_query}\n\t\t\t\tAND ttrss_user_entries.owner_uid = {$user_id}\n\t\t\t\tAND unread = true\n\t\t\t\tAND score >= 0\n\t\t\tORDER BY ttrss_feed_categories.title, ttrss_feeds.title, score DESC, date_updated DESC\n\t\t\tLIMIT {$limit}");
    $cur_feed_title = "";
    $headlines_count = db_num_rows($result);
    $headlines = array();
    while ($line = db_fetch_assoc($result)) {
        array_push($headlines, $line);
    }
    for ($i = 0; $i < sizeof($headlines); $i++) {
        $line = $headlines[$i];
        array_push($affected_ids, $line["ref_id"]);
        $updated = make_local_datetime($link, $line['last_updated'], false, $user_id);
        /*			if ($line["score"] != 0) {
        				if ($line["score"] > 0) $line["score"] = '+' . $line["score"];
        
        				$line["title"] .= " (".$line['score'].")";
        			} */
        if (get_pref($link, 'ENABLE_FEED_CATS', $user_id)) {
            $line['feed_title'] = $line['cat_title'] . " / " . $line['feed_title'];
        }
        $tpl->setVariable('FEED_TITLE', $line["feed_title"]);
        $tpl->setVariable('ARTICLE_TITLE', $line["title"]);
        $tpl->setVariable('ARTICLE_LINK', $line["link"]);
        $tpl->setVariable('ARTICLE_UPDATED', $updated);
        $tpl->setVariable('ARTICLE_EXCERPT', truncate_string(strip_tags($line["content"]), 300));
        //			$tpl->setVariable('ARTICLE_CONTENT',
        //				strip_tags($article_content));
        $tpl->addBlock('article');
        $tpl_t->setVariable('FEED_TITLE', $line["feed_title"]);
        $tpl_t->setVariable('ARTICLE_TITLE', $line["title"]);
        $tpl_t->setVariable('ARTICLE_LINK', $line["link"]);
        $tpl_t->setVariable('ARTICLE_UPDATED', $updated);
        //			$tpl_t->setVariable('ARTICLE_EXCERPT',
        //				truncate_string(strip_tags($line["excerpt"]), 100));
        $tpl_t->addBlock('article');
        if ($headlines[$i]['feed_title'] != $headlines[$i + 1]['feed_title']) {
            $tpl->addBlock('feed');
            $tpl_t->addBlock('feed');
        }
    }
    $tpl->addBlock('digest');
    $tpl->generateOutputToString($tmp);
    $tpl_t->addBlock('digest');
    $tpl_t->generateOutputToString($tmp_t);
    return array($tmp, $headlines_count, $affected_ids, $tmp_t);
}
コード例 #9
0
ファイル: github_feed.php プロジェクト: cmn32480/exec-irc-bot
function check_issue_events($repo)
{
    $data = get_api_data("/repos/{$repo}/issues/events");
    $n = count($data) - 1;
    for ($i = $n; $i >= 0; $i--) {
        if (isset($data[$i]["created_at"]) == False) {
            continue;
        }
        $timestamp = $data[$i]["created_at"];
        $t = convert_timestamp($timestamp, CREATE_TIME_FORMAT);
        $dt = microtime(True) - $t;
        if ($dt <= TIME_LIMIT_SEC) {
            github_msg($repo, chr(3) . "13" . "issue " . $data[$i]["event"] . " by " . $data[$i]["actor"]["login"] . " @ " . date("H:i:s", $t) . " - " . $data[$i]["issue"]["html_url"]);
        }
    }
}
コード例 #10
0
ファイル: weather_lib.php プロジェクト: cmn32480/exec-irc-bot
function process_weather_old(&$location, $nick)
{
    $loc = get_location($location, $nick);
    if ($loc === False) {
        if ($location == "") {
            return 0;
        }
        $loc = $location;
    }
    $location = $loc;
    $loc_query = filter($loc, VALID_UPPERCASE . VALID_LOWERCASE . VALID_NUMERIC . ",");
    # http://weather.gladstonefamily.net/site/search?site=melbourne&search=Search
    $search = wget("weather.gladstonefamily.net", "/site/search?site=" . urlencode($loc_query) . "&search=Search", 80, ICEWEASEL_UA, "", 300);
    if (strpos($search, "Pick one of the following") === False) {
        return 1;
    }
    $parts = explode("<li>", $search);
    $delim1 = "/site/";
    $delim2 = "\">";
    $delim3 = "</a>";
    for ($i = 0; $i < count($parts); $i++) {
        if (strpos($parts[$i], "/site/") !== False and strpos($parts[$i], "[no data]") === False and strpos($parts[$i], "[inactive]") === False) {
            term_echo($parts[$i]);
            $j1 = strpos($parts[$i], $delim1);
            $j2 = strpos($parts[$i], $delim2);
            $j3 = strpos($parts[$i], $delim3);
            if ($j1 !== False and $j2 !== False and $j3 !== False) {
                $name = substr($parts[$i], $j2 + strlen($delim2), $j3 - $j2 - strlen($delim2));
                $station = substr($parts[$i], $j1 + strlen($delim1), $j2 - $j1 - strlen($delim1));
                # http://weather.gladstonefamily.net/cgi-bin/wxobservations.pl?site=94868&days=7
                $csv = trim(wget("weather.gladstonefamily.net", "/cgi-bin/wxobservations.pl?site=" . urlencode($station) . "&days=3", 80, ICEWEASEL_UA, "", 300));
                $lines = explode("\n", $csv);
                # UTC baro-mb temp°F dewpoint°F rel-humidity-% wind-mph wind-deg
                # 2014-04-07 17:00:00,1020.01,54.1,53.6,98,0,0,,,,,,
                $first = $lines[count($lines) - 2];
                $last = $lines[count($lines) - 1];
                term_echo($last);
                $data_first = explode(",", $first);
                $data_last = explode(",", $last);
                if ($data_last[1] == "" or $data_last[2] == "" or count($data_first) < 7 or count($data_last) < 7) {
                    continue;
                }
                $results = array();
                $dt = 0;
                $age = -1;
                if ($data_first[0] != "" and $data_last[0] != "") {
                    # 2014-04-12 23:00:00
                    $ts1 = convert_timestamp($data_first[0], "Y-m-d H:i:s");
                    $ts2 = convert_timestamp($data_last[0], "Y-m-d H:i:s");
                    $dt = round(($ts2 - $ts1) / 60 / 60, 1);
                    $utc_str = gmdate("M d Y H:i:s", time());
                    $utc = strtotime($utc_str);
                    $age = round(($utc - $ts2) / 60 / 60, 1);
                } else {
                    continue;
                }
                $results["temp_C"] = False;
                $results["temp_F"] = False;
                if ($data_last[2] == "") {
                    $temp = "(no data)";
                } else {
                    $tempF = round($data_last[2], 1);
                    $tempC = round(($tempF - 32) * 5 / 9, 1);
                    $results["temp_C"] = $tempC;
                    $results["temp_F"] = $tempF;
                    $temp = $tempC . "°C (" . $tempF . "°F)";
                }
                if ($data_last[1] == "") {
                    $press = "(no data)";
                    $delta_str = "";
                    $pressmb = False;
                } else {
                    $delta_str = "";
                    if ($dt > 0 and $data_first[1] != "") {
                        $d = round($data_last[1] - $data_first[1], 1);
                        #$delta_str=" ($d mb over ".round($dt*60,0)." mins)";
                        $dt = $dt * 60;
                        if ($d > 0) {
                            $delta_str = " (+{$d} mb/{$dt} mins)";
                        } else {
                            $delta_str = " ({$d} mb/{$dt} mins)";
                        }
                    }
                    $pressmb = round($data_last[1], 1);
                    $press = $pressmb . " mb" . $delta_str;
                }
                if ($data_last[3] == "") {
                    $dewpoint = "(no data)";
                } else {
                    $tempF = round($data_last[3], 1);
                    $tempC = round(($data_last[3] - 32) * 5 / 9, 1);
                    $dewpoint = $tempC . "°C (" . $tempF . "°F)";
                }
                if ($data_last[4] == "") {
                    $relhumidity = "(no data)";
                } else {
                    $relhumidity = round($data_last[4], 1) . "%";
                }
                if ($data_last[5] == "") {
                    $wind_speed = "(no data)";
                } else {
                    $wind_speed_mph = round($data_last[5], 1);
                    $wind_speed_kph = round($data_last[5] * 8 / 5, 1);
                    $wind_speed = $wind_speed_kph . " km/h (" . $wind_speed_mph . " mph)";
                }
                if ($data_last[6] == "") {
                    $wind_direction = "(no data)";
                } else {
                    $wind_direction = round($data_last[6], 1) . "°";
                    # include N/S/E/W/NE/SE/NW/SW/NNE/ENE/SSE/ESE/etc
                }
                $agestr = ":";
                if ($age >= 0) {
                    $age = round($age * 60, 0);
                    $agestr = " ~ {$age} mins ago:";
                }
                $results["name"] = $name;
                $results["utc"] = $data_last[0];
                $results["utc_num"] = $ts2;
                $results["age"] = $agestr;
                $results["age_num"] = $age;
                $results["temp"] = $temp;
                $results["dewpoint"] = $dewpoint;
                $results["press"] = $press;
                $results["delta_str"] = $delta_str;
                $results["pressmb"] = $pressmb;
                $results["humidity"] = $relhumidity;
                $results["wind_speed"] = $wind_speed;
                $results["wind_direction"] = $wind_direction;
                return $results;
            }
        }
    }
    return 2;
}