Exemplo n.º 1
0
    /**
     *
     *
     * @todo count?
     */
    function query_init()
    {
        global $current_User;
        if (empty($this->filters)) {
            // Filters have not been set before, we'll use the default filterset:
            // If there is a preset filter, we need to activate its specific defaults:
            $this->filters['filter_preset'] = param($this->param_prefix . 'filter_preset', 'string', $this->default_filters['filter_preset'], true);
            $this->activate_preset_filters();
            // Use the default filters:
            $this->set_filters($this->default_filters);
        }
        // echo '<br />ItemListLight query';
        //pre_dump( $this->filters );
        // GENERATE THE QUERY:
        /*
         * filtering stuff:
         */
        if (!is_null($this->Blog)) {
            // Get the posts only for current Blog
            $this->ItemQuery->where_chapter2($this->Blog, $this->filters['cat_array'], $this->filters['cat_modifier'], $this->filters['cat_focus']);
        } else {
            // If we want to get the posts from all blogs
            // Save for future use (permission checks..)
            $this->ItemQuery->blog = 0;
            $this->ItemQuery->Blog = $this->Blog;
        }
        $this->ItemQuery->where_tags($this->filters['tags']);
        $this->ItemQuery->where_author($this->filters['authors']);
        $this->ItemQuery->where_author_logins($this->filters['authors_login']);
        $this->ItemQuery->where_assignees($this->filters['assignees']);
        $this->ItemQuery->where_assignees_logins($this->filters['assignees_login']);
        $this->ItemQuery->where_author_assignee($this->filters['author_assignee']);
        $this->ItemQuery->where_locale($this->filters['lc']);
        $this->ItemQuery->where_statuses($this->filters['statuses']);
        $this->ItemQuery->where_types($this->filters['types']);
        $this->ItemQuery->where_keywords($this->filters['keywords'], $this->filters['phrase'], $this->filters['exact']);
        $this->ItemQuery->where_ID($this->filters['post_ID'], $this->filters['post_title']);
        $this->ItemQuery->where_ID_list($this->filters['post_ID_list']);
        $this->ItemQuery->where_datestart($this->filters['ymdhms'], $this->filters['week'], $this->filters['ymdhms_min'], $this->filters['ymdhms_max'], $this->filters['ts_min'], $this->filters['ts_max']);
        $this->ItemQuery->where_datecreated($this->filters['ts_created_max']);
        $this->ItemQuery->where_visibility($this->filters['visibility_array']);
        $this->ItemQuery->where_featured($this->filters['featured']);
        /*
         * ORDER BY stuff:
         */
        if ($this->filters['post_ID_list'] && $this->filters['orderby'] == 'ID_list') {
            $order_by = 'FIELD(' . $this->Cache->dbIDname . ', ' . $this->filters['post_ID_list'] . ')';
        } elseif ($this->filters['orderby'] == 'ID_list') {
            // Use blog setting here because 'orderby' might be set to 'ID_list' as default filter
            $this->filters['orderby'] = $this->Blog->get_setting('orderby');
        }
        if (empty($order_by)) {
            $order_by = gen_order_clause($this->filters['orderby'], $this->filters['order'], $this->Cache->dbprefix, $this->Cache->dbIDname);
        }
        $this->ItemQuery->order_by($order_by);
        /*
         * GET TOTAL ROW COUNT:
         */
        if ($this->single_post) {
            // Single post: no paging required!
            $this->total_rows = 1;
            $this->total_pages = 1;
            $this->page = 1;
        } elseif ($this->filters['unit'] == 'days' || $this->filters['unit'] == 'all') {
            $this->total_rows = NULL;
            // unknown!
            $this->total_pages = 1;
            $this->page = 1;
        } elseif ($this->filters['unit'] == 'posts') {
            /*
             * TODO: The result is incorrect when using AND on categories
             * We would need to use a HAVING close and thyen COUNT, which would be a subquery
             * This is nto compatible with mysql 3.23
             * We need fallback code.
             */
            $sql_count = '
				SELECT COUNT( DISTINCT ' . $this->Cache->dbIDname . ') ' . $this->ItemQuery->get_from() . $this->ItemQuery->get_where();
            //echo $DB->format_query( $sql_count );
            parent::count_total_rows($sql_count);
            //echo '<br />'.$this->total_rows;
        } else {
            debug_die('Unhandled LIMITING mode in ItemList:' . $this->filters['unit'] . ' (paged mode is obsolete)');
        }
        /*
         * Paging LIMITs:
         */
        if ($this->single_post) {
            // Single post: no paging required!
        } elseif ($this->filters['unit'] == 'all') {
            // We want ALL results!
        } elseif ($this->filters['unit'] == 'posts') {
            // TODO: dh> check if $limit is NULL!? - though it should not arrive at $page>1 then..
            // echo 'LIMIT POSTS ';
            $pgstrt = '';
            if ($this->page > 1) {
                // We have requested a specific page number
                $pgstrt = (intval($this->page) - 1) * $this->limit . ', ';
            }
            $this->ItemQuery->LIMIT($pgstrt . $this->limit);
        } elseif ($this->filters['unit'] == 'days') {
            // We are going to limit to x days:
            // echo 'LIMIT DAYS ';
            if (empty($this->filters['ymdhms_min'])) {
                // We have no start date, we'll display the last x days:
                if (!empty($this->filters['keywords']) || !empty($this->filters['cat_array']) || !empty($this->filters['authors'])) {
                    // We are in DAYS mode but we can't restrict on these! (TODO: ?)
                    $limits = '';
                } else {
                    // We are going to limit to LAST x days:
                    $lastpostdate = $this->get_lastpostdate();
                    $lastpostdate = mysql2date('Y-m-d 00:00:00', $lastpostdate);
                    $lastpostdate = mysql2date('U', $lastpostdate);
                    // go back x days
                    $otherdate = date('Y-m-d H:i:s', $lastpostdate - ($this->limit - 1) * 86400);
                    $this->ItemQuery->WHERE_and($this->Cache->dbprefix . 'datestart > \'' . $otherdate . '\'');
                }
            } else {
                // We have a start date, we'll display x days starting from that point:
                // $dstart_mysql has been calculated earlier
                // TODO: this is redundant with previous dstart processing:
                // Add trailing 0s: YYYYMMDDHHMMSS
                $dstart0 = $this->filters['ymdhms_min'] . '00000000000000';
                $dstart_mysql = substr($dstart0, 0, 4) . '-' . substr($dstart0, 4, 2) . '-' . substr($dstart0, 6, 2) . ' ' . substr($dstart0, 8, 2) . ':' . substr($dstart0, 10, 2) . ':' . substr($dstart0, 12, 2);
                $dstart_ts = mysql2timestamp($dstart_mysql);
                // go forward x days
                $enddate_ts = date('Y-m-d H:i:s', $dstart_ts + $this->limit * 86400);
                $this->ItemQuery->WHERE_and($this->Cache->dbprefix . 'datestart < \'' . $enddate_ts . '\'');
            }
        } else {
            debug_die('Unhandled LIMITING mode in ItemList:' . $this->filters['unit'] . ' (paged mode is obsolete)');
        }
    }
Exemplo n.º 2
0
// TODO: dh> add entry for homepage (lastmod of latest item)
// TODO: dh> take comments into consideration for prio
// TODO: dh> use main Blog URL only, since google requires them to be on the same domain/path
// (see sitemap_plugin)
// Note: since URLs are likely to be clean ASCII, $io_charset can probably be faked to UTF-8 here
headers_content_mightcache('application/xml', '#', 'UTF-8');
// In most situations, you do NOT want to cache dynamic content!
echo '<?xml version="1.0" encoding="UTF-8"?' . '>';
?>

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<?php 
while ($Item =& mainlist_get_item()) {
    // For each blog post, do everything below up to the closing curly brace "}"
    // Age in days of the post
    $age = ($localtimenow - mysql2timestamp($Item->datemodified)) / 86400;
    // Prio: Recent posts will get higher priority compared to older posts, in case the SE doesn't want to index all posts!
    // Change frequency: recent posts are more likely to change often than older posts, especially regarding comments.
    // We hint SEs to check back more often (and not to waste indexing credits on old stuff).
    if ($age < 8) {
        $prio = 0.9;
        $changefreq = 'hourly';
    } elseif ($age < 30) {
        $prio = 0.8;
        $changefreq = 'daily';
    } elseif ($age < 90) {
        $prio = 0.7;
        $changefreq = 'daily';
    } elseif ($age < 365) {
        $prio = 0.6;
        $changefreq = 'weekly';
Exemplo n.º 3
0
/**
 * Display user activate info form content
 *
 * @param Object activateinfo Form
 */
function display_activateinfo($params)
{
    global $current_User, $Settings, $UserSettings, $Plugins;
    global $secure_htsrv_url, $rsc_path, $rsc_url, $dummy_fields;
    if (!is_logged_in()) {
        // if this happens, it means the code is not correct somewhere before this
        debug_die("You must log in to see this page.");
    }
    // init force request new email address param
    $force_request = param('force_request', 'boolean', false);
    // get last activation email timestamp from User Settings
    $last_activation_email_date = $UserSettings->get('last_activation_email', $current_User->ID);
    if ($force_request || empty($last_activation_email_date)) {
        // notification email was not sent yet, or user needs another one ( forced request )
        $params = array_merge(array('form_action' => $secure_htsrv_url . 'login.php', 'form_name' => 'form_validatemail', 'form_class' => 'fform', 'form_layout' => 'fieldset', 'inskin' => false), $params);
        $Form = new Form($params['form_action'], $params['form_name'], 'post', $params['form_layout']);
        $Form->begin_form($params['form_class']);
        $Form->add_crumb('validateform');
        $Form->hidden('action', 'req_validatemail');
        $Form->hidden('redirect_to', $params['redirect_to']);
        if ($params['inskin']) {
            $Form->hidden('inskin', $params['inskin']);
            $Form->hidden('blog', $params['blog']);
        }
        $Form->hidden('req_validatemail_submit', 1);
        // to know if the form has been submitted
        $Form->begin_fieldset();
        echo '<ol>';
        echo '<li>' . T_('Please confirm your email address below:') . '</li>';
        echo '</ol>';
        // set email text input content only if this is not a forced request. This way the user may have bigger chance to write a correct email address.
        $user_email = $force_request ? '' : $current_User->email;
        // fp> note: 45 is the max length for evopress skin.
        $Form->text_input($dummy_fields['email'], $user_email, 45, T_('Your email'), '', array('maxlength' => 255, 'class' => 'input_text', 'required' => true));
        $Form->end_fieldset();
        // Submit button:
        $submit_button = array(array('name' => 'submit', 'value' => T_('Send me a new activation email now!'), 'class' => 'submit'));
        $Form->buttons_input($submit_button);
        if (!$params['inskin']) {
            $Plugins->trigger_event('DisplayValidateAccountFormFieldset', array('Form' => &$Form));
        }
        $Form->end_form();
        return;
    }
    // get notification email from general Settings
    $notification_email = $Settings->get('notification_sender_email');
    // convert date to timestamp
    $last_activation_email_ts = mysql2timestamp($last_activation_email_date);
    // get difference between local time and server time
    $time_difference = $Settings->get('time_difference');
    // get last activation email local date and time
    $last_email_date = date(locale_datefmt(), $last_activation_email_ts + $time_difference);
    $last_email_time = date(locale_shorttimefmt(), $last_activation_email_ts + $time_difference);
    $user_email = $current_User->email;
    echo '<ol start="1" class="expanded">';
    $instruction = sprintf(T_('Open your email account for %s and find a message we sent you on %s at %s with the following title:'), $user_email, $last_email_date, $last_email_time);
    echo '<li>' . $instruction . '<br /><b>' . sprintf(T_('Activate your account: %s'), $current_User->login) . '</b>';
    $request_validation_url = 'href="' . regenerate_url('', 'force_request=1&validate_required=true&redirect_to=' . $params['redirect_to']) . '"';
    echo '<p>' . sprintf(T_('NOTE: If you don\'t find it, check your "Junk", "Spam" or "Unsolicited email" folders. If you really can\'t find it, <a %s>request a new activation email</a>.'), $request_validation_url) . '</p></li>';
    echo '<li>' . sprintf(T_('Add us (%s) to your contacts to make sure you receive future email notifications, especially when someone sends you a private message.'), '<b><span class="nowrap">' . $notification_email . '</span></b>') . '</li>';
    echo '<li><b class="red">' . T_('Click on the activation link in the email.') . '</b>';
    echo '<p>' . T_('If this does not work, please copy/paste that link into the address bar of your browser.') . '</p>';
    echo '<p>' . sprintf(T_('If you need assistance, please send an email to %s'), '<b><a href="mailto:"' . $notification_email . '"><span class="nowrap">' . $notification_email . '</span></a></b>') . '</p></li>';
    echo '</ol>';
    if ((strpos($user_email, '@hotmail.') || strpos($user_email, '@live.') || strpos($user_email, '@msn.')) && file_exists($rsc_path . 'img/login_help/hotmail-validation.png')) {
        // The user is on hotmail and we have a help screen to show him: (needs to be localized and include correct site name)
        echo '<div class="center" style="margin: 2em auto"><img src="' . $rsc_url . 'img/login_help/hotmail-validation.png" /></div>';
    }
}
Exemplo n.º 4
0
 // has the form been submitted
 $email = utf8_strtolower(param($dummy_fields['email'], 'string', $current_User->email));
 // the email address is editable
 if ($req_validatemail_submit) {
     // Form has been submitted
     param_check_email($dummy_fields['email'], true);
     // check if user email was changed
     $email_changed = $current_User->get('email') != $email;
     // check if we really needs to send a new validation email
     if (!$email_changed) {
         // the email was not changed
         $last_activation_email_date = $UserSettings->get('last_activation_email', $current_User->ID);
         if (!empty($last_activation_email_date)) {
             // at least one validation email was sent
             // convert date to timestamp
             $last_activation_email_ts = mysql2timestamp($last_activation_email_date);
             $activate_requests_limit = $Settings->get('activate_requests_limit');
             if ($servertimenow - $last_activation_email_ts < $activate_requests_limit) {
                 // a validation email was sent to the same email address less then the x seconds, where x is the "Activation requests limit" value
                 // get difference between local time and server time
                 $time_difference = $Settings->get('time_difference');
                 // get last activation email local date and time
                 $last_email_date = date(locale_datetimefmt(), $last_activation_email_ts + $time_difference);
                 $Messages->add(sprintf(T_("We have already sent you an activation message to %s at %s. Please allow %d minutes for delivery before requesting a new one."), $email, $last_email_date, $activate_requests_limit / 60));
             }
         }
     }
     // Call plugin event to allow catching input in general and validating own things from DisplayRegisterFormFieldset event
     $Plugins->trigger_event('ValidateAccountFormSent');
     if ($Messages->has_errors()) {
         break;
Exemplo n.º 5
0
    /**
     * Constructor
     *
     * If valid session cookie received: pull session from DB
     * Otherwise, INSERT a session into DB
     */
    function Session()
    {
        global $DB, $Debuglog, $current_User, $localtimenow, $Messages, $Settings, $UserSettings;
        global $Hit;
        global $cookie_session, $cookie_expires, $cookie_path, $cookie_domain;
        $Debuglog->add('Session: cookie_domain=' . $cookie_domain, 'request');
        $Debuglog->add('Session: cookie_path=' . $cookie_path, 'request');
        $session_cookie = param_cookie($cookie_session, 'string', '');
        if (empty($session_cookie)) {
            $Debuglog->add('Session: No session cookie received.', 'request');
        } else {
            // session ID sent by cookie
            if (!preg_match('~^(\\d+)_(\\w+)$~', $session_cookie, $match)) {
                $Debuglog->add('Session: Invalid session cookie format!', 'request');
            } else {
                // We have a valid session cookie:
                $session_id_by_cookie = $match[1];
                $session_key_by_cookie = $match[2];
                $Debuglog->add('Session: Session ID received from cookie: ' . $session_id_by_cookie, 'request');
                $timeout_sessions = NULL;
                if ($this->user_ID != NULL) {
                    // User is not anonymous, get custom session timeout (may return NULL):
                    $timeout_sessions = $UserSettings->get('timeout_sessions', $this->user_ID);
                }
                if (empty($timeout_sessions)) {
                    // User is anonymous or has no custom session timeout. So, we use default session timeout:
                    $timeout_sessions = $Settings->get('timeout_sessions');
                }
                $row = $DB->get_row('
					SELECT sess_ID, sess_key, sess_data, sess_user_ID, sess_start_ts, sess_lastseen_ts, sess_device
					  FROM T_sessions
					 WHERE sess_ID  = ' . $DB->quote($session_id_by_cookie) . '
					   AND sess_key = ' . $DB->quote($session_key_by_cookie) . '
					   AND UNIX_TIMESTAMP(sess_lastseen_ts) > ' . ($localtimenow - $timeout_sessions));
                if (empty($row)) {
                    $Debuglog->add('Session: Session ID/key combination is invalid!', 'request');
                } else {
                    // ID + key are valid: load data
                    $Debuglog->add('Session: Session ID is valid.', 'request');
                    $this->ID = $row->sess_ID;
                    $this->key = $row->sess_key;
                    $this->user_ID = $row->sess_user_ID;
                    $this->start_ts = mysql2timestamp($row->sess_start_ts);
                    $this->lastseen_ts = mysql2timestamp($row->sess_lastseen_ts);
                    $this->is_validated = true;
                    $this->sess_device = $row->sess_device;
                    $Debuglog->add('Session: Session user_ID: ' . var_export($this->user_ID, true), 'request');
                    if (empty($row->sess_data)) {
                        $Debuglog->add('Session: No session data available.', 'request');
                        $this->_data = array();
                    } else {
                        // Some session data has been previsouly stored:
                        // Unserialize session data (using an own callback that should provide class definitions):
                        $old_callback = ini_set('unserialize_callback_func', 'session_unserialize_callback');
                        if ($old_callback === false || is_null($old_callback)) {
                            // NULL if ini_set has been disabled for security reasons
                            // Brutally load all classes that we might need:
                            session_unserialize_load_all_classes();
                        }
                        // TODO: dh> This can fail, if there are special chars in sess_data:
                        //       It will be encoded in $evo_charset _after_ "SET NAMES", but
                        //       get retrieved here, _before_ any "SET NAMES" (if $db_config['connection_charset'] is not set (default))!
                        $this->_data = @unserialize($row->sess_data);
                        if ($old_callback !== false) {
                            // Restore the old callback if we changed it:
                            ini_set('unserialize_callback_func', $old_callback);
                        }
                        if (!is_array($this->_data)) {
                            $Debuglog->add('Session: Session data corrupted!<br />
								connection_charset: ' . var_export($DB->connection_charset, true) . '<br />
								Serialized data was: --[' . var_export($row->sess_data, true) . ']--', array('session', 'error'));
                            $this->_data = array();
                        } else {
                            $Debuglog->add('Session: Session data loaded.', 'request');
                            // Load a Messages object from session data, if available:
                            if (($sess_Messages = $this->get('Messages')) && is_a($sess_Messages, 'Messages')) {
                                // dh> TODO: "old" messages should rather get prepended to any existing ones from the current request, rather than appended
                                $Messages->add_messages($sess_Messages);
                                $Debuglog->add('Session: Added Messages from session data.', 'request');
                                $this->delete('Messages');
                            }
                        }
                    }
                }
            }
        }
        if ($this->ID) {
            // there was a valid session before
            if ($this->lastseen_ts < $localtimenow - 60) {
                // lastseen timestamp is older then a minute, it needs to be updated at page exit
                $this->session_needs_save(true);
            }
        } else {
            // create a new session! :
            $this->key = generate_random_key(32);
            // Detect user device
            global $user_devices;
            $this->sess_device = '';
            if (!empty($_SERVER['HTTP_USER_AGENT'])) {
                foreach ($user_devices as $device_name => $device_regexp) {
                    if (preg_match('~' . $device_regexp . '~i', $_SERVER['HTTP_USER_AGENT'])) {
                        $this->sess_device = $device_name;
                        break;
                    }
                }
            }
            // We need to INSERT now because we need an ID now! (for the cookie)
            $DB->query("\n\t\t\t\tINSERT INTO T_sessions( sess_key, sess_start_ts, sess_lastseen_ts, sess_ipaddress, sess_device )\n\t\t\t\tVALUES (\n\t\t\t\t\t'" . $this->key . "',\n\t\t\t\t\t'" . date('Y-m-d H:i:s', $localtimenow) . "',\n\t\t\t\t\t'" . date('Y-m-d H:i:s', $localtimenow) . "',\n\t\t\t\t\t" . $DB->quote($Hit->IP) . ",\n\t\t\t\t\t" . $DB->quote($this->sess_device) . "\n\t\t\t\t)");
            $this->ID = $DB->insert_id;
            // Set a cookie valid for ~ 10 years:
            setcookie($cookie_session, $this->ID . '_' . $this->key, time() + 315360000, $cookie_path, $cookie_domain);
            $Debuglog->add('Session: ID (generated): ' . $this->ID, 'request');
            $Debuglog->add('Session: Cookie sent.', 'request');
        }
    }
Exemplo n.º 6
0
        }
    }
} else {
    $msg = '';
}
$block_item_Widget = new Widget('block_item');
/**
 * b2evolution
 */
$block_item_Widget->title = 'b2evolution' . get_manual_link('system-status-tab');
$block_item_Widget->disp_template_replaced('block_start');
// Instance name:
init_system_check(T_('Instance name'), $instance_name);
disp_system_check('note');
// Version:
$app_timestamp = mysql2timestamp($app_date);
init_system_check(T_('b2evolution version'), sprintf(T_('%s released on %s'), $app_version, date_i18n(locale_datefmt(), $app_timestamp)));
if (!empty($msg)) {
    switch ($global_Cache->get('version_status_color')) {
        case 'green':
            disp_system_check('ok', $msg);
            break;
        case 'yellow':
            disp_system_check('warning', $msg);
            break;
        default:
            disp_system_check('error', $msg);
    }
} else {
    $msg = '<p>Updates from b2evolution.net are disabled!</p>
			<p>You will <b>NOT</b> be alerted if you are running an insecure configuration.</p>';
Exemplo n.º 7
0
/**
 * Format a MYSQL date.
 *
 * @param string enhanced format string
 * @param string MYSQL date YYYY-MM-DD HH:MM:SS
 * @param boolean true to use GM time
 */
function mysql2date($dateformatstring, $mysqlstring, $useGM = false)
{
    $m = $mysqlstring;
    if (empty($m) || $m == '0000-00-00 00:00:00') {
        return false;
    }
    // Get a timestamp:
    $unixtimestamp = mysql2timestamp($m);
    return date_i18n($dateformatstring, $unixtimestamp, $useGM);
}
Exemplo n.º 8
0
    /**
     * Do we want to apply rel="nofollow" tag?
     *
     * @return boolean
     */
    function apply_nofollow(&$data, $Comment)
    {
        global $localtimenow;
        $hours = $this->Settings->get('nofollow_for_hours');
        // 0=never, -1 always, otherwise for x hours
        if ($hours == 0) {
            // "never"
            return;
        }
        if ($hours > 0 && mysql2timestamp($Comment->date) <= $localtimenow - $hours * 3600) {
            return;
        }
        $data = preg_replace_callback('~(<a\\s)([^>]+)>~i', create_function('$m', '
				if( preg_match( \'~\\brel=([\\\'"])(.*?)\\1~\', $m[2], $match ) )
				{ // there is already a rel attrib:
					$rel_values = explode( " ", $match[2] );

					if( ! in_array( \'nofollow\', $rel_values ) )
					{
						$rel_values[] = \'nofollow\';
					}

					return $m[1]
						.preg_replace(
							\'~\\brel=([\\\'"]).*?\\1~\',
							\'rel=$1\'.implode( " ", $rel_values ).\'$1\',
							$m[2] )
						.">";
				}
				else
				{
					return $m[1].$m[2].\' rel="nofollow">\';
				}'), $data);
    }
function my_to_date_sh($in_date)
{
    // short date_time string
    //		$temp = mktime(substr($in_date,11,2),substr($in_date,14,2),substr($in_date,17,2),substr($in_date,5,2),substr($in_date,8,2),substr($in_date,0,4));
    //		$temp = mktime((int)substr($in_date,11,2), (int)substr($in_date,14,2), (int)substr($in_date,17,2), (int)substr($in_date,5,2), (int)substr($in_date,8,2), (int)substr($in_date,0,4));		// 9/29/10
    $temp = mysql2timestamp($in_date);
    // 9/29/10
    return good_date_time($in_date) ? date("H:i", $temp) : "";
    //
}
Exemplo n.º 10
0
/**
 * Deadline
 */
function deadline($date)
{
    $timestamp = mysql2timestamp($date);
    if ($timestamp <= 0) {
        return '&nbsp;';
        // IE needs that crap in order to display cell border :/
    }
    return mysql2localedate($date);
}
function elapsed($in_time)
{
    // 4/26/11
    $mins = (int) round((now() - mysql2timestamp($in_time)) / 60.0);
    return $mins > 99 ? 99 : $mins;
}
Exemplo n.º 12
0
/**
 * Display a comment corresponding the given comment id
 *
 * @param int comment id
 * @param string where to redirect after comment edit
 * @param boolean true to set the new redirect param, false otherwise
 * @param integer Comment index in the current list
 */
function echo_comment($comment_ID, $redirect_to = NULL, $save_context = false, $comment_index = NULL)
{
    global $current_User, $localtimenow;
    $CommentCache =& get_CommentCache();
    /**
     * @var Comment
     */
    $Comment = $CommentCache->get_by_ID($comment_ID);
    $Item =& $Comment->get_Item();
    $Blog =& $Item->get_Blog();
    $is_published = $Comment->get('status') == 'published';
    $expiry_delay = $Item->get_setting('comment_expiry_delay');
    $is_expired = !empty($expiry_delay) && $localtimenow - mysql2timestamp($Comment->get('date')) > $expiry_delay;
    echo '<a name="c' . $comment_ID . '"></a>';
    echo '<div id="comment_' . $comment_ID . '" class="bComment bComment';
    // check if comment is expired
    if ($is_expired) {
        // comment is expired
        echo 'expired';
    } elseif ($Comment->is_meta()) {
        // meta comment
        echo 'meta';
    } else {
        // comment is not expired and not meta
        $Comment->status('raw');
    }
    echo '">';
    if ($current_User->check_perm('comment!CURSTATUS', 'moderate', false, $Comment) || $Comment->is_meta() && $current_User->check_perm('meta_comment', 'view', false, $Item)) {
        // User can moderate this comment OR Comment is meta and current user can view it
        echo '<div class="bSmallHead">';
        echo '<div>';
        if ($Comment->is_meta()) {
            // Display ID for each meta comment
            echo '<span class="badge badge-info">' . $comment_index . '</span> ';
        }
        echo '<div class="bSmallHeadRight">';
        $Comment->permanent_link(array('before' => '', 'text' => $Comment->is_meta() ? T_('Meta link') : '#text#'));
        echo '</div>';
        echo '<span class="bDate">';
        $Comment->date();
        echo '</span>@<span class = "bTime">';
        $Comment->time('#short_time');
        echo '</span>';
        if ($Comment->is_meta()) {
            // Display only author for meta comment
            $Comment->author('', '', ' &middot; ' . T_('Author') . ': ', '');
        } else {
            // Display the detailed info for standard comment
            $Comment->author_email('', ' &middot; Email: <span class="bEmail">', '</span>');
            echo ' &middot; <span class="bKarma">';
            $Comment->spam_karma(T_('Spam Karma') . ': %s%', T_('No Spam Karma'));
            echo '</span>';
            echo '</div>';
            echo '<div style="padding-top:3px">';
            if ($is_expired) {
                echo '<div class="bSmallHeadRight">';
                echo '<span class="bExpired">' . T_('EXPIRED') . '</span>';
                echo '</div>';
            }
            $Comment->author_ip('IP: <span class="bIP">', '</span> &middot; ', true, true);
            $Comment->ip_country('', ' &middot; ');
            $Comment->author_url_with_actions('', true, true);
        }
        echo '</div>';
        echo '</div>';
        echo '<div class="bCommentContent">';
        $Comment->format_status(array('template' => '<div class="floatright"><span class="note status_$status$"><span>$status_title$</span></span></div>'));
        if (!$Comment->is_meta()) {
            // Don't display the titles for meta comments
            echo '<div class="bCommentTitle">';
            echo $Comment->get_title();
            if (get_param('p') == '') {
                // Don't display this title on a post view page
                echo ' ' . T_('in response to') . ' <a href="?ctrl=items&amp;blog=' . $Blog->ID . '&amp;p=' . $Item->ID . '">' . $Item->dget('title') . '</a>';
            }
            echo '</div>';
        }
        echo '<div class="bCommentText">';
        $Comment->rating();
        $Comment->avatar('crop-top-80x80');
        if ($current_User->check_perm('meta_comment', 'edit', false, $Comment)) {
            // Put the comment content into this container to edit by ajax
            echo '<div id="editable_comment_' . $Comment->ID . '" class="editable_comment_content">';
        }
        $Comment->content('htmlbody', 'true');
        if ($current_User->check_perm('meta_comment', 'edit', false, $Comment)) {
            // End of the container that is used to edit meta comment by ajax
            echo '</div>';
        }
        echo '</div>';
        echo '</div>';
        echo '<div class="CommentActionsArea">';
        echo '<div class="floatleft">';
        // Display edit button if current user has the rights:
        $Comment->edit_link(' ', ' ', get_icon('edit_button') . ' ' . T_('Edit'), '#', button_class('text_primary') . ' w80px', '&amp;', $save_context, $redirect_to);
        echo '<span class="' . button_class('group') . '">';
        // Display publish NOW button if current user has the rights:
        $link_params = array('class' => button_class('text'), 'save_context' => $save_context, 'ajax_button' => true, 'redirect_to' => $redirect_to);
        $Comment->raise_link($link_params);
        // Display deprecate button if current user has the rights:
        $Comment->lower_link($link_params);
        $next_status_in_row = $Comment->get_next_status(false);
        if ($next_status_in_row && $next_status_in_row[0] != 'deprecated') {
            // Display deprecate button if current user has the rights:
            $Comment->deprecate_link('', '', get_icon('move_down_grey', 'imgtag', array('title' => '')), '#', button_class(), '&amp;', true, true);
        }
        // Display delete button if current user has the rights:
        $Comment->delete_link('', '', '#', '#', button_class('text'), false, '&amp;', $save_context, true, '#', $redirect_to);
        echo '</span>';
        echo '</div>';
        if (!$Comment->is_meta()) {
            // Display Spam Voting system
            $Comment->vote_spam('', '', '&amp;', $save_context, true);
        }
        echo '<div class="clear"></div>';
        echo '</div>';
    } else {
        // No permissions to moderate of this comment, just preview
        echo '<div class="bSmallHead">';
        echo '<div>';
        echo '<div class="bSmallHeadRight">';
        echo T_('Visibility') . ': ';
        echo '<span class="bStatus">';
        $Comment->status();
        echo '</span>';
        echo '</div>';
        echo '<span class="bDate">';
        $Comment->date();
        echo '</span>@<span class = "bTime">';
        $Comment->time('#short_time');
        echo '</span>';
        echo '</div>';
        echo '</div>';
        if ($is_published) {
            echo '<div class="bCommentContent">';
            echo '<div class="bCommentTitle">';
            echo $Comment->get_title();
            echo '</div>';
            echo '<div class="bCommentText">';
            $Comment->rating();
            $Comment->avatar();
            $Comment->content();
            echo '</div>';
            echo '</div>';
        }
        echo '<div class="clear"></div>';
    }
    echo '</div>';
    // end
}
Exemplo n.º 13
0
function my_to_date_sh($in_date)
{
    // short date_time string
    $temp = mysql2timestamp($in_date);
    return good_date_time($in_date) ? date("H:i", $temp) : "";
    //
}
function do_diff($indx, $row)
{
    // returns diff in seconds from problemstart- 9/29/10
    switch ($indx) {
        case 0:
            $temp = mysql2timestamp($row['dispatched']);
            break;
        case 1:
            $temp = mysql2timestamp($row['responding']);
            break;
        case 2:
            $temp = mysql2timestamp($row['on_scene']);
            break;
        case 3:
            $temp = mysql2timestamp($row['u2fenr']);
            // 10/19/10
            break;
        case 4:
            $temp = mysql2timestamp($row['u2farr']);
            break;
        case 5:
            $temp = mysql2timestamp($row['clear']);
            break;
        case 6:
            $temp = mysql2timestamp($row['problemend']);
            break;
        default:
            dump($indx);
            // error  error  error  error  error
    }
    return $temp - mysql2timestamp($row['problemstart']);
}
function aprs_date_ok($indate)
{
    // checks for date/time within 48 hours
    return abs(time() - mysql2timestamp($indate)) < 2 * 24 * 60 * 60;
}
Exemplo n.º 16
0
 /**
  * Load data from Request form fields.
  *
  * @return boolean true if loaded data seems valid.
  */
 function load_from_Request()
 {
     global $Messages, $localtimenow;
     // Group ID
     param('ivc_grp_ID', 'integer');
     param_check_not_empty('ivc_grp_ID', T_('Please select a group'));
     $this->set_from_Request('grp_ID', 'ivc_grp_ID', true);
     // Code
     param('ivc_code', 'string');
     param_check_not_empty('ivc_code', T_('You must provide an invitation code!'));
     param_check_regexp('ivc_code', '#^[A-Za-z0-9\\-_]{3,32}$#', T_('Invitation code must be from 3 to 32 letters, digits or signs "-", "_".'));
     $this->set_from_Request('code', 'ivc_code');
     // Expire date
     if (param_date('ivc_expire_date', T_('Please enter a valid date.'), true) && param_time('ivc_expire_time')) {
         // If date and time were both correct we may set the 'expire_ts' value
         $this->set('expire_ts', form_date(get_param('ivc_expire_date'), get_param('ivc_expire_time')));
     }
     // Source
     param('ivc_source', 'string');
     $this->set_from_Request('source', 'ivc_source', true);
     if (mysql2timestamp($this->get('expire_ts')) < $localtimenow) {
         // Display a warning if date is expired
         $Messages->add($this->ID == 0 ? T_('Note: The newly created invitation code is already expired') : T_('Note: The updated invitation code is already expired'), 'warning');
     }
     return !param_errors_detected();
 }
Exemplo n.º 17
0
    /**
     * Generate search query based on set filters and obtain count of results
     */
    function query_init()
    {
        global $current_User;
        // Call reset to init the ItemQuery
        // This prevents from adding the same conditions twice if the ItemQuery was already initialized
        $this->reset();
        if (empty($this->filters)) {
            // Filters have not been set before, we'll use the default filterset:
            // If there is a preset filter, we need to activate its specific defaults:
            $this->filters['filter_preset'] = param($this->param_prefix . 'filter_preset', 'string', $this->default_filters['filter_preset'], true);
            $this->activate_preset_filters();
            // Use the default filters:
            $this->set_filters($this->default_filters);
        }
        // echo '<br />ItemListLight query';
        //pre_dump( $this->filters );
        // GENERATE THE QUERY:
        /*
         * Filtering stuff:
         */
        if (!is_null($this->Blog)) {
            // Get the posts only for current Blog
            $this->ItemQuery->where_chapter2($this->Blog, $this->filters['cat_array'], $this->filters['cat_modifier'], $this->filters['cat_focus'], $this->filters['coll_IDs']);
        } else {
            // If we want to get the posts from all blogs
            // Save for future use (permission checks..)
            $this->ItemQuery->blog = 0;
            $this->ItemQuery->Blog = $this->Blog;
        }
        $this->ItemQuery->where_tags($this->filters['tags']);
        $this->ItemQuery->where_author($this->filters['authors']);
        $this->ItemQuery->where_author_logins($this->filters['authors_login']);
        $this->ItemQuery->where_assignees($this->filters['assignees']);
        $this->ItemQuery->where_assignees_logins($this->filters['assignees_login']);
        $this->ItemQuery->where_author_assignee($this->filters['author_assignee']);
        $this->ItemQuery->where_locale($this->filters['lc']);
        $this->ItemQuery->where_statuses($this->filters['statuses']);
        $this->ItemQuery->where_types($this->filters['types']);
        $this->ItemQuery->where_keywords($this->filters['keywords'], $this->filters['phrase'], $this->filters['exact'], $this->filters['keyword_scope']);
        $this->ItemQuery->where_ID($this->filters['post_ID'], $this->filters['post_title']);
        $this->ItemQuery->where_ID_list($this->filters['post_ID_list']);
        $this->ItemQuery->where_datestart($this->filters['ymdhms'], $this->filters['week'], $this->filters['ymdhms_min'], $this->filters['ymdhms_max'], $this->filters['ts_min'], $this->filters['ts_max']);
        $this->ItemQuery->where_datecreated($this->filters['ts_created_max']);
        $this->ItemQuery->where_visibility($this->filters['visibility_array'], $this->filters['coll_IDs']);
        $this->ItemQuery->where_featured($this->filters['featured']);
        /*
         * ORDER BY stuff:
         */
        if ($this->filters['post_ID_list'] && $this->filters['orderby'] == 'ID_list') {
            $order_by = 'FIELD(' . $this->Cache->dbIDname . ', ' . $this->filters['post_ID_list'] . ')';
        } elseif ($this->filters['orderby'] == 'ID_list') {
            // Use blog setting here because 'orderby' might be set to 'ID_list' as default filter
            $this->filters['orderby'] = $this->Blog->get_setting('orderby');
        }
        if (empty($order_by)) {
            $available_fields = array_keys(get_available_sort_options());
            // Extend general list to allow order posts by these fields as well for some special cases
            $available_fields[] = 'creator_user_ID';
            $available_fields[] = 'assigned_user_ID';
            $available_fields[] = 'pst_ID';
            $available_fields[] = 'datedeadline';
            $available_fields[] = 'T_categories.cat_name';
            $available_fields[] = 'T_categories.cat_order';
            $order_by = gen_order_clause($this->filters['orderby'], $this->filters['order'], $this->Cache->dbprefix, $this->Cache->dbIDname, $available_fields);
        }
        $this->ItemQuery->order_by($order_by);
        /*
         * GET TOTAL ROW COUNT:
         */
        if ($this->single_post) {
            // Single post: no paging required!
            $this->total_rows = 1;
            $this->total_pages = 1;
            $this->page = 1;
        } elseif ($this->filters['unit'] == 'days' || $this->filters['unit'] == 'all') {
            $this->total_rows = NULL;
            // unknown!
            $this->total_pages = 1;
            $this->page = 1;
        } elseif ($this->filters['unit'] == 'posts') {
            // Calculate a count of the posts
            if ($this->ItemQuery->get_group_by() == '') {
                // SQL query without GROUP BY clause
                $sql_count = 'SELECT COUNT( DISTINCT ' . $this->Cache->dbIDname . ' )' . $this->ItemQuery->get_from() . $this->ItemQuery->get_where() . $this->ItemQuery->get_limit();
            } else {
                // SQL query with GROUP BY clause, Summarize a count of each grouped result
                $sql_count = 'SELECT SUM( cnt_tbl.cnt ) FROM (
						SELECT COUNT( DISTINCT ' . $this->Cache->dbIDname . ' ) AS cnt ' . $this->ItemQuery->get_from() . $this->ItemQuery->get_where() . $this->ItemQuery->get_group_by() . $this->ItemQuery->get_limit() . '
					) AS cnt_tbl ';
            }
            parent::count_total_rows($sql_count);
        } else {
            debug_die('Unhandled LIMITING mode in ItemList:' . $this->filters['unit'] . ' (paged mode is obsolete)');
        }
        /*
         * Paging LIMITs:
         */
        if ($this->single_post) {
            // Single post: no paging required!
        } elseif ($this->filters['unit'] == 'all') {
            // We want ALL results!
        } elseif ($this->filters['unit'] == 'posts') {
            // TODO: dh> check if $limit is NULL!? - though it should not arrive at $page>1 then..
            // echo 'LIMIT POSTS ';
            $pgstrt = '';
            if ($this->page > 1) {
                // We have requested a specific page number
                $pgstrt = (intval($this->page) - 1) * $this->limit . ', ';
            }
            $this->ItemQuery->LIMIT($pgstrt . $this->limit);
        } elseif ($this->filters['unit'] == 'days') {
            // We are going to limit to x days:
            // echo 'LIMIT DAYS ';
            if (empty($this->filters['ymdhms_min'])) {
                // We have no start date, we'll display the last x days:
                if (!empty($this->filters['keywords']) || !empty($this->filters['cat_array']) || !empty($this->filters['authors'])) {
                    // We are in DAYS mode but we can't restrict on these! (TODO: ?)
                    $limits = '';
                } else {
                    // We are going to limit to LAST x days:
                    $lastpostdate = $this->get_lastpostdate();
                    $lastpostdate = mysql2date('Y-m-d 00:00:00', $lastpostdate);
                    $lastpostdate = mysql2date('U', $lastpostdate);
                    // go back x days
                    $otherdate = date('Y-m-d H:i:s', $lastpostdate - ($this->limit - 1) * 86400);
                    $this->ItemQuery->WHERE_and($this->Cache->dbprefix . 'datestart > \'' . $otherdate . '\'');
                }
            } else {
                // We have a start date, we'll display x days starting from that point:
                // $dstart_mysql has been calculated earlier
                // TODO: this is redundant with previous dstart processing:
                // Add trailing 0s: YYYYMMDDHHMMSS
                $dstart0 = $this->filters['ymdhms_min'] . '00000000000000';
                $dstart_mysql = substr($dstart0, 0, 4) . '-' . substr($dstart0, 4, 2) . '-' . substr($dstart0, 6, 2) . ' ' . substr($dstart0, 8, 2) . ':' . substr($dstart0, 10, 2) . ':' . substr($dstart0, 12, 2);
                $dstart_ts = mysql2timestamp($dstart_mysql);
                // go forward x days
                $enddate_ts = date('Y-m-d H:i:s', $dstart_ts + $this->limit * 86400);
                $this->ItemQuery->WHERE_and($this->Cache->dbprefix . 'datestart < \'' . $enddate_ts . '\'');
            }
        } else {
            debug_die('Unhandled LIMITING mode in ItemList:' . $this->filters['unit'] . ' (paged mode is obsolete)');
        }
    }
Exemplo n.º 18
0
 /**
  * Display the widget!
  *
  * @param array MUST contain at least the basic display params
  */
 function display($params)
 {
     global $DB, $Settings, $UserSettings, $localtimenow;
     if (!$this->get_param('allow_anonymous') && !is_logged_in()) {
         // display only for logged in users
         return;
     }
     // load online Users
     $UserCache =& get_UserCache();
     $online_threshold = $localtimenow - 2 * $Settings->get('timeout_online');
     $UserCache->load_where('user_lastseen_ts > ' . $DB->quote(date2mysql($online_threshold) . ' AND user_status <> ' . $DB->quote('closed')));
     $this->init_display($params);
     // START DISPLAY:
     echo $this->disp_params['block_start'];
     // Display title if requested
     $this->disp_title();
     $r = '';
     while (($iterator_User =& $UserCache->get_next()) != NULL) {
         // Iterate through UserCache
         $user_lastseen_ts = mysql2timestamp($iterator_User->get('lastseen_ts'));
         if ($user_lastseen_ts > $online_threshold && $UserSettings->get('show_online', $iterator_User->ID) && !$iterator_User->check_status('is_closed')) {
             if (empty($r)) {
                 // first user
                 $r .= $params['list_start'];
             }
             $r .= $params['item_start'];
             $r .= $iterator_User->get_identity_link(array('login_mask' => '$login$'));
             $r .= $params['item_end'];
         }
     }
     if (!empty($r)) {
         $r .= $params['list_end'];
         echo $r;
     }
     echo $this->disp_params['block_end'];
     return true;
 }
Exemplo n.º 19
0
/**
 * Decode the dateCreated
 *
 * @param struct
 * @return string MYSQL date
 */
function _mw_decode_date($contentstruct)
{
    global $Settings;
    $postdate = NULL;
    if (!empty($contentstruct['date_created_gmt'])) {
        $postdate = iso8601_to_datetime($contentstruct['date_created_gmt']);
        // Add time difference to GMT date
        $postdate = date('Y-m-d H:i:s', mysql2timestamp($postdate, true) + $Settings->get('time_difference'));
        logIO('Using contentstruct date_created_gmt: ' . $postdate);
    }
    if (empty($postdate) && !empty($contentstruct['dateCreated'])) {
        $postdate = $contentstruct['dateCreated'];
        if (strpos($postdate, 'T') > 0) {
            // Date is in ISO 8601 format
            $postdate = iso8601_to_datetime($postdate);
        }
        logIO('Using contentstruct dateCreated: ' . $postdate);
    }
    return $postdate;
}
Exemplo n.º 20
0
/**
 * Display a comment corresponding the given comment id
 *
 * @param int comment id
 * @param string where to redirect after comment edit
 * @param boolean true to set the new redirect param, false otherwise
 */
function echo_comment($comment_ID, $redirect_to = NULL, $save_context = false)
{
    global $current_User, $localtimenow;
    $CommentCache =& get_CommentCache();
    /**
     * @var Comment
     */
    $Comment = $CommentCache->get_by_ID($comment_ID);
    $Item =& $Comment->get_Item();
    $Blog =& $Item->get_Blog();
    $is_published = $Comment->get('status') == 'published';
    $expiry_delay = $Item->get_setting('post_expiry_delay');
    $is_expired = !empty($expiry_delay) && $localtimenow - mysql2timestamp($Comment->get('date')) > $expiry_delay;
    echo '<div id="c' . $comment_ID . '" class="bComment bComment';
    // check if comment is expired
    if ($is_expired) {
        // comment is expired
        echo 'expired';
    } else {
        // comment is not expired
        $Comment->status('raw');
    }
    echo '">';
    if ($current_User->check_perm('comment!CURSTATUS', 'moderate', false, $Comment)) {
        // User can moderate this comment
        echo '<div class="bSmallHead">';
        echo '<div>';
        echo '<div class="bSmallHeadRight">';
        $Comment->permanent_link(array('before' => '', 'text' => '#text#'));
        echo '</div>';
        echo '<span class="bDate">';
        $Comment->date();
        echo '</span>@<span class = "bTime">';
        $Comment->time('H:i');
        echo '</span>';
        $Comment->author_email('', ' &middot; Email: <span class="bEmail">', '</span>');
        echo ' &middot; <span class="bKarma">';
        $Comment->spam_karma(T_('Spam Karma') . ': %s%', T_('No Spam Karma'));
        echo '</span>';
        echo '</div>';
        echo '<div style="padding-top:3px">';
        if ($is_expired) {
            echo '<div class="bSmallHeadRight">';
            echo '<span class="bExpired">' . T_('EXPIRED') . '</span>';
            echo '</div>';
        }
        $Comment->author_ip('IP: <span class="bIP">', '</span> &middot; ', true);
        $Comment->ip_country('', ' &middot; ');
        $Comment->author_url_with_actions('', true, true);
        echo '</div>';
        echo '</div>';
        echo '<div class="bCommentContent">';
        $Comment->status('styled');
        echo '<div class="bTitle">';
        echo T_('In response to:') . ' <a href="?ctrl=items&amp;blog=' . $Blog->ID . '&amp;p=' . $Item->ID . '">' . $Item->dget('title') . '</a>';
        echo '</div>';
        echo '<div class="bCommentTitle">';
        echo $Comment->get_title();
        echo '</div>';
        echo '<div class="bCommentText">';
        $Comment->rating();
        $Comment->avatar();
        $Comment->content('htmlbody', 'true');
        echo '</div>';
        echo '</div>';
        echo '<div class="CommentActionsArea">';
        echo '<div class="floatleft">';
        // Display edit button if current user has the rights:
        $Comment->edit_link(' ', ' ', get_icon('edit'), '#', 'roundbutton', '&amp;', $save_context, $redirect_to);
        echo '<span class="roundbutton_group">';
        // Display publish NOW button if current user has the rights:
        $link_params = array('class' => 'roundbutton_text', 'save_context' => $save_context, 'ajax_button' => true, 'redirect_to' => $redirect_to);
        $Comment->raise_link($link_params);
        // Display deprecate button if current user has the rights:
        $Comment->lower_link($link_params);
        $next_status_in_row = $Comment->get_next_status(false);
        if ($next_status_in_row && $next_status_in_row[0] != 'deprecated') {
            // Display deprecate button if current user has the rights:
            $Comment->deprecate_link('', '', get_icon('move_down_grey', 'imgtag', array('title' => '')), '#', 'roundbutton', '&amp;', true, true);
        }
        // Display delete button if current user has the rights:
        $Comment->delete_link('', '', '#', '#', 'roundbutton_text', false, '&amp;', $save_context, true, '#', $redirect_to);
        echo '</span>';
        echo '</div>';
        // Display Spam Voting system
        $Comment->vote_spam('', '', '&amp;', $save_context, true);
        echo '<div class="clear"></div>';
        echo '</div>';
    } else {
        // No permissions to moderate of this comment, just preview
        echo '<div class="bSmallHead">';
        echo '<div>';
        echo '<div class="bSmallHeadRight">';
        echo T_('Visibility') . ': ';
        echo '<span class="bStatus">';
        $Comment->status();
        echo '</span>';
        echo '</div>';
        echo '<span class="bDate">';
        $Comment->date();
        echo '</span>@<span class = "bTime">';
        $Comment->time('H:i');
        echo '</span>';
        echo '</div>';
        echo '</div>';
        if ($is_published) {
            echo '<div class="bCommentContent">';
            echo '<div class="bCommentTitle">';
            echo $Comment->get_title();
            echo '</div>';
            echo '<div class="bCommentText">';
            $Comment->rating();
            $Comment->avatar();
            $Comment->content();
            echo '</div>';
            echo '</div>';
        }
        echo '<div class="clear"></div>';
    }
    echo '</div>';
    // end
}
 function my_to_date($in_date)
 {
     // date_time format to user's spec
     //			$temp = mktime(substr($in_date,11,2),substr($in_date,14,2),substr($in_date,17,2),substr($in_date,5,2),substr($in_date,8,2),substr($in_date,0,4));
     $temp = mysql2timestamp($d1);
     // 9/29/10
     return good_date_time($in_date) ? date(get_variable("date_format"), $temp) : "";
     //
 }
Exemplo n.º 22
0
function adj_time($time_stamp)
{
    $temp = mysql2timestamp($time_stamp);
    // MySQL to integer form
    return date("H:i", $temp);
}
Exemplo n.º 23
0
 /**
  * Builds a time select input field
  *
  * @param string field name
  * @param string initial value (ISO datetime or time only)
  * @param string precison xmn or xsec (x:integer) for the options minutes or secondes
  * @param string field label to be display before the field
  * @param string note to be displayed after the field
  * @param string CSS class for select
  * @param string Javascript to add for onchange event (trailing ";").
  */
 function time_select($field_name, $field_value = NULL, $precision = '5mn', $field_label, $field_note = NULL, $field_class = NULL, $field_onchange = NULL)
 {
     preg_match('#([0-9]+)(mn|s)#', $precision, $matches);
     if (!isset($matches[1]) && !isset($matches[2])) {
         // precison has a bad format
         return;
     }
     $field_params = array('note' => $field_note, 'class' => $field_class, 'onchange' => $field_onchange);
     /***  instantiate the precison for the minutes and secondes select options  ****/
     if ($matches[2] == 'mn') {
         $precision_mn = $matches[1];
         $precision_s = 0;
         // convert the precision in sec
         $precision *= 60;
     } else {
         $precision_mn = 1;
         $precision_s = $matches[1];
     }
     // Check if field value is only a time
     if (strlen($field_value) <= 8) {
         // Add date part:
         $field_value = '2000-01-01 ' . $field_value;
     }
     /***  set round time with the precision  ***/
     // Get nb sec since unix...
     $nbsec = mysql2timestamp($field_value);
     $modulo = $nbsec % $precision;
     if ($modulo < $precision / 2) {
         // The round time is before
         $nbsec -= $modulo;
     } else {
         // The round time is after
         $nbsec += $precision - $modulo;
     }
     /******************************************************/
     $this->handle_common_params($field_params, $field_name, $field_label);
     $r = $this->begin_field();
     /**********   select options for the hours *************/
     $field_params['name'] = $field_name . '_h';
     $field_params['id'] = $field_params['name'];
     // Get Hour part of datetime:
     $hour = date('H', $nbsec);
     $r .= $this->_number_select($hour, 23, 1, $field_params);
     /*********  select options for the minutes *************/
     $field_params['name'] = $field_name . '_mn';
     $field_params['id'] = $field_params['name'];
     // Get Minute part of datetime:
     $minute = date('i', $nbsec);
     $r .= ':' . $this->_number_select($minute, 59, $precision_mn, $field_params);
     if ($precision_s) {
         /*********  select options for the minutes  ***********/
         $field_params['name'] = $field_name . '_s';
         $field_params['id'] = $field_params['name'];
         // Get Secondes part of datetime:
         $seconde = substr($field_value, 17, 2);
         $r .= ':' . $this->_number_select($seconde, 59, $precision_s, $field_params);
     }
     $r .= $this->end_field();
     return $this->display_or_return($r);
 }
Exemplo n.º 24
0
            }
        }
        $flightInfo = getFlightInfo($track, $geoServerStatus);
        if ($row->utc) {
            // Convert UTC to local time
            try {
                $timeZone = new DateTimeZone($flightInfo->timezone);
                $timeOffset = timezone_offset_get($timeZone, new DateTime($track['start']['time']));
            } catch (Exception $e) {
                $timeOffset = 0;
            }
            $startTime = mysql2timestamp($track['start']['time']) + $timeOffset;
            $track['start']['time'] = date("Y-m-d H:i:s", $startTime);
            if (!$track['live']) {
                // Live tracks don't have an end time
                $endTime = mysql2timestamp($track['end']['time']) + $timeOffset;
                $track['end']['time'] = date("Y-m-d H:i:s", $endTime);
            }
        }
        $tracks['tracks'][] = $track;
    }
}
if (isset($cb)) {
    echo "{$cb}(" . @json_encode($tracks) . ")";
} else {
    echo @json_encode($tracks);
}
function getFilterCondition($filter)
{
    if (!is_array($filter)) {
        return "";