Example #1
0
         }
         // Initialize GeoIP plugin
         $geoip_Plugin =& $Plugins->get_by_code('evo_GeoIP');
         foreach ($login_attempts as $attempt) {
             $attempt = explode('|', $attempt);
             $attempt_ip = $attempt[1];
             $plugin_country_by_IP = '';
             if (!empty($geoip_Plugin) && ($Country =& $geoip_Plugin->get_country_by_IP($attempt_ip))) {
                 // Get country by IP if plugin is enabled
                 $plugin_country_by_IP = ' (' . $Country->get_name() . ')';
             }
             if ($attempt_ip != $current_ip) {
                 // Get DNS by IP if current IP is different from attempt IP
                 $attempt_ip .= ' ' . gethostbyaddr($attempt_ip);
             }
             $Messages->add(sprintf(T_('Someone tried to log in to your account with a wrong password on %s from %s%s'), date(locale_datefmt() . ' ' . locale_timefmt(), $attempt[0]), $attempt_ip, $plugin_country_by_IP), 'error');
         }
         // Clear the attempts list
         $UserSettings->delete('login_attempts', $current_User->ID);
         $UserSettings->dbupdate();
     }
 } elseif (empty($login_error)) {
     // if the login_error wasn't set yet, add the default one:
     // This will cause the login screen to "popup" (again)
     $login_error = T_('Wrong login/password.');
     if (isset($login_attempts)) {
         // Save new login attempt into DB
         if (count($login_attempts) == 9) {
             // Unset first attempt to clear a space for new attempt
             unset($login_attempts[0]);
         }
Example #2
0
    die('Please, do not access this page directly.');
}
global $blog, $admin_url, $UserSettings;
global $datestartinput, $datestart, $datestopinput, $datestop, $email;
if (param_date('datestartinput', T_('Invalid date'), false, NULL) !== NULL) {
    // We have a user provided localized date:
    memorize_param('datestart', 'string', NULL, trim(form_date($datestartinput)));
    memorize_param('datestartinput', 'string', NULL, empty($datestartinput) ? NULL : date(locale_datefmt(), strtotime($datestartinput)));
} else {
    // We may have an automated param transmission date:
    param('datestart', 'string', '', true);
}
if (param_date('datestopinput', T_('Invalid date'), false, NULL) !== NULL) {
    // We have a user provided localized date:
    memorize_param('datestop', 'string', NULL, trim(form_date($datestopinput)));
    memorize_param('datestopinput', 'string', NULL, empty($datestopinput) ? NULL : date(locale_datefmt(), strtotime($datestopinput)));
} else {
    // We may have an automated param transmission date:
    param('datestop', 'string', '', true);
}
param('email', 'string', '', true);
// Create result set:
$SQL = new SQL();
$SQL->SELECT('SQL_NO_CACHE emlog_ID, emlog_timestamp, emlog_user_ID, emlog_to, emlog_result, emlog_subject');
$SQL->FROM('T_email__log');
$count_SQL = new SQL();
$count_SQL->SELECT('SQL_NO_CACHE COUNT(emlog_ID)');
$count_SQL->FROM('T_email__log');
if (!empty($datestart)) {
    // Filter by start date
    $SQL->WHERE_and('emlog_timestamp >= ' . $DB->quote($datestart . ' 00:00:00'));
Example #3
0
 /**
  * Get last mod date (datetime) of Item
  *
  * @param string date/time format: leave empty to use locale default date format
  * @param boolean true if you want GMT
  */
 function get_mod_date($format = '', $useGM = false)
 {
     if (empty($format)) {
         return mysql2date(locale_datefmt(), $this->datemodified, $useGM);
     }
     return mysql2date($format, $this->datemodified, $useGM);
 }
Example #4
0
function mysql2localedatetime_spans($mysqlstring, $datefmt = NULL, $timefmt = NULL)
{
    if (is_null($datefmt)) {
        $datefmt = locale_datefmt();
    }
    if (is_null($timefmt)) {
        $timefmt = locale_timefmt();
    }
    return '<span class="date">' . mysql2date($datefmt, $mysqlstring) . '</span> <span class="time">' . mysql2date($timefmt, $mysqlstring) . '</span>';
}
Example #5
0
 /**
  * Template function: display date (datetime) of comment
  *
  * @param string date/time format: leave empty to use locale default date format
  * @param boolean true if you want GMT
  */
 function date($format = '', $useGM = false)
 {
     if (empty($format)) {
         echo mysql2date(locale_datefmt(), $this->date, $useGM);
     } else {
         echo mysql2date($format, $this->date, $useGM);
     }
 }
Example #6
0
    default:
        debug_die('unhandled action 1:' . htmlspecialchars($action));
}
$AdminUI->breadcrumbpath_init();
$AdminUI->breadcrumbpath_add(T_('Contents'), '?ctrl=items&amp;blog=$blog$&amp;tab=full&amp;filter=restore');
/**
 * Perform action:
 */
switch ($action) {
    case 'nil':
        // Do nothing
        break;
    case 'new':
    case 'new_mass':
        // $set_issue_date = 'now';
        $item_issue_date = date_i18n(locale_datefmt(), $localtimenow);
        $item_issue_time = date('H:i:s', $localtimenow);
        // pre_dump( $item_issue_date, $item_issue_time );
    // pre_dump( $item_issue_date, $item_issue_time );
    case 'new_switchtab':
        // this gets set as action by JS, when we switch tabs
        // New post form  (can be a bookmarklet form if mode == bookmarklet )
        // We don't check the following earlier, because we want the blog switching buttons to be available:
        if (!blog_has_cats($blog)) {
            break;
        }
        load_class('items/model/_item.class.php', 'Item');
        $edited_Item = new Item();
        $edited_Item->set('main_cat_ID', $Blog->get_default_cat_ID());
        // We use the request variables to fill the edit form, because we need to be able to pass those values
        // from tab to tab via javascript when the editor wants to switch views...
/*
 * Chart
 */
if (count($res_hits)) {
    $last_date = 0;
    $chart['chart_data'][0] = array();
    $chart['chart_data'][1] = array();
    $count = 0;
    foreach ($res_hits as $row_stats) {
        $this_date = mktime(0, 0, 0, $row_stats['month'], $row_stats['day'], $row_stats['year']);
        if ($last_date != $this_date) {
            // We just hit a new day, let's display the previous one:
            $last_date = $this_date;
            // that'll be the next one
            $count++;
            array_unshift($chart['chart_data'][0], date(locale_datefmt(), $last_date));
            array_unshift($chart['chart_data'][1], 0);
        }
        $chart['chart_data'][1][0] = $row_stats['hits'];
    }
    array_unshift($chart['chart_data'][0], '');
    array_unshift($chart['chart_data'][1], 'XML (RSS/Atom) hits');
    // Translations need to be UTF-8
    // Include common chart properties:
    require dirname(__FILE__) . '/inc/_bar_chart.inc.php';
    $chart['series_color'] = array($agent_type_color['rss']);
    echo '<div class="center">';
    load_funcs('_ext/_swfcharts.php');
    DrawChart($chart);
    echo '</div>';
}
Example #8
0
 /**
  * Event handler: SkinTag
  *
  * @param array Associative array of parameters. Valid keys are:
  *                - 'block_start' : (Default: '<div class="bSideItem">')
  *                - 'block_end' : (Default: '</div>')
  *                - 'title' : (Default: T_('Archives'))
  *                - 'mode' : 'monthly'|'daily'|'weekly'|'postbypost' (Default: conf.)
  *                - 'sort_order' : 'date'|'title' (Default: date - used only if the mode is 'postbypost')
  *                - 'link_type' : 'canonic'|'context' (default: canonic)
  *                - 'context_isolation' : what params need override when changing date/range (Default: 'm,w,p,title,unit,dstart' )
  *                - 'form' : true|false (default: false)
  *                - 'limit' : # of archive entries to display or '' (Default: 12)
  *                - 'more_link' : more link text (Default: 'More...')
  *                - 'list_start' : (Default '<ul>')
  *                - 'list_end' : (Default '</ul>')
  *                - 'line_start' : (Default '<li>')
  *                - 'line_end' : (Default '</li>')
  *                - 'day_date_format' : (Default: conf.)
  * @return boolean did we display?
  */
 function SkinTag($params)
 {
     global $month;
     /**
      * @todo get rid of this global:
      */
     global $m;
     /**
      * @var Blog
      */
     global $Blog;
     if (empty($Blog)) {
         return false;
     }
     /**
      * Default params:
      */
     // This is what will enclose the block in the skin:
     if (!isset($params['block_start'])) {
         $params['block_start'] = '<div class="bSideItem">';
     }
     if (!isset($params['block_end'])) {
         $params['block_end'] = "</div>\n";
     }
     // Title:
     if (!isset($params['block_title_start'])) {
         $params['block_title_start'] = '<h3>';
     }
     if (!isset($params['block_title_end'])) {
         $params['block_title_end'] = '</h3>';
     }
     if (!isset($params['title'])) {
         $params['title'] = T_('Archives');
     }
     // Archive mode:
     if (!isset($params['mode'])) {
         $params['mode'] = $Blog->get_setting('archive_mode');
     }
     //Sort order (used only in postbypost mode):
     if ($params['mode'] != 'postbypost') {
         $params['sort_order'] = 'date';
     } elseif (!isset($params['sort_order']) || $params['sort_order'] == '') {
         $params['sort_order'] = 'date';
     }
     // Link type:
     if (!isset($params['link_type'])) {
         $params['link_type'] = 'canonic';
     }
     if (!isset($params['context_isolation'])) {
         $params['context_isolation'] = 'm,w,p,title,unit,dstart';
     }
     // Add form fields?:
     if (!isset($params['form'])) {
         $params['form'] = false;
     }
     // Number of archive entries to display:
     if (!isset($params['limit'])) {
         $params['limit'] = 12;
     }
     // More link text:
     if (!isset($params['more_link'])) {
         $params['more_link'] = T_('More...');
     }
     // This is what will enclose the list:
     if (!isset($params['list_start'])) {
         $params['list_start'] = '<ul>';
     }
     if (!isset($params['list_end'])) {
         $params['list_end'] = "</ul>\n";
     }
     // This is what will separate the archive links:
     if (!isset($params['line_start'])) {
         $params['line_start'] = '<li>';
     }
     if (!isset($params['line_end'])) {
         $params['line_end'] = "</li>\n";
     }
     // Daily archive date format?
     if (!isset($params['day_date_format']) || $params['day_date_format'] == '') {
         $dateformat = locale_datefmt();
         $params['day_date_format'] = $dateformat;
     }
     $ArchiveList =& new ArchiveList($params['mode'], $params['limit'], $params['sort_order'], $params['link_type'] == 'context', $this->dbtable, $this->dbprefix, $this->dbIDname);
     echo $params['block_start'];
     if (!empty($params['title'])) {
         // We want to display a title for the widget block:
         echo $params['block_title_start'];
         echo $params['title'];
         echo $params['block_title_end'];
     }
     echo $params['list_start'];
     while ($ArchiveList->get_item($arc_year, $arc_month, $arc_dayofmonth, $arc_w, $arc_count, $post_ID, $post_title)) {
         echo $params['line_start'];
         switch ($params['mode']) {
             case 'monthly':
                 // --------------------------------- MONTHLY ARCHIVES -------------------------------------
                 $arc_m = $arc_year . zeroise($arc_month, 2);
                 if ($params['form']) {
                     // We want a radio button:
                     echo '<input type="radio" name="m" value="' . $arc_m . '" class="checkbox"';
                     if ($m == $arc_m) {
                         echo ' checked="checked"';
                     }
                     echo ' /> ';
                 }
                 $text = T_($month[zeroise($arc_month, 2)]) . ' ' . $arc_year;
                 if ($params['link_type'] == 'context') {
                     // We want to preserve current browsing context:
                     echo '<a rel="nofollow" href="' . regenerate_url($params['context_isolation'], 'm=' . $arc_m) . '">' . $text . '</a>';
                 } else {
                     // We want to link to the absolute canonical URL for this archive:
                     echo $Blog->gen_archive_link($text, T_('View monthly archive'), $arc_year, $arc_month);
                 }
                 echo ' <span class="dimmed">(' . $arc_count . ')</span>';
                 break;
             case 'daily':
                 // --------------------------------- DAILY ARCHIVES ---------------------------------------
                 $arc_m = $arc_year . zeroise($arc_month, 2) . zeroise($arc_dayofmonth, 2);
                 if ($params['form']) {
                     // We want a radio button:
                     echo '<input type="radio" name="m" value="' . $arc_m . '" class="checkbox"';
                     if ($m == $arc_m) {
                         echo ' checked="checked"';
                     }
                     echo ' /> ';
                 }
                 $text = mysql2date($params['day_date_format'], $arc_year . '-' . zeroise($arc_month, 2) . '-' . zeroise($arc_dayofmonth, 2) . ' 00:00:00');
                 if ($params['link_type'] == 'context') {
                     // We want to preserve current browsing context:
                     echo '<a rel="nofollow" href="' . regenerate_url($params['context_isolation'], 'm=' . $arc_m) . '">' . $text . '</a>';
                 } else {
                     // We want to link to the absolute canonical URL for this archive:
                     echo $Blog->gen_archive_link($text, T_('View daily archive'), $arc_year, $arc_month, $arc_dayofmonth);
                 }
                 echo ' <span class="dimmed">(' . $arc_count . ')</span>';
                 break;
             case 'weekly':
                 // --------------------------------- WEEKLY ARCHIVES --------------------------------------
                 $text = $arc_year . ', ' . T_('week') . ' ' . $arc_w;
                 if ($params['link_type'] == 'context') {
                     // We want to preserve current browsing context:
                     echo '<a rel="nofollow" href="' . regenerate_url($params['context_isolation'], 'm=' . $arc_year . '&amp;w=' . $arc_w) . '">' . $text . '</a>';
                 } else {
                     // We want to link to the absolute canonical URL for this archive:
                     echo $Blog->gen_archive_link($text, T_('View weekly archive'), $arc_year, NULL, NULL, $arc_w);
                 }
                 echo ' <span class="dimmed">(' . $arc_count . ')</span>';
                 break;
             case 'postbypost':
             default:
                 // -------------------------------- POST BY POST ARCHIVES ---------------------------------
                 if ($post_title) {
                     $text = strip_tags($post_title);
                 } else {
                     $text = $post_ID;
                 }
                 if ($params['link_type'] == 'context') {
                     // We want to preserve current browsing context:
                     echo '<a rel="nofollow" href="' . regenerate_url($params['context_isolation'], 'p=' . $post_ID) . '">' . $text . '</a>';
                 } else {
                     // We want to link to the absolute (canonical) URL for this archive:
                     // fp> TODO: This is NOT canonical. To go to the canonical, we'd need a 'light' itemlist (which does not load too much data)
                     // fp> Note: there may be a "redirect to canonical" anyway. Not optimal, but at least this is less broken than it was before.
                     // fp> THIS IS ALL OBSOLETE. There is a better way to have a post list with a specific widget.
                     // TO BE DELETED (waiting for photoblog cleanup)
                     echo '<a href="' . url_add_param($Blog->get('url'), 'p=' . $post_ID . '&amp;more=1&amp;c=1&amp;tb=1&amp;pb=1') . '">' . $text . '</a>';
                 }
         }
         echo $params['line_end'];
     }
     // Display more link:
     if (!empty($params['more_link'])) {
         echo $params['line_start'];
         echo '<a href="';
         $Blog->disp('arcdirurl', 'raw');
         echo '">' . format_to_output($params['more_link']) . '</a>';
         echo $params['line_end'];
     }
     echo $params['list_end'];
     echo $params['block_end'];
     return true;
 }
Example #9
0
/**
 * Check if param is an ISO date.
 *
 * NOTE: for tokens like e.g. "D" (abbr. weekday), T_() gets used and it uses the current locale!
 *
 * @param string param name
 * @param string error message
 * @param boolean Is a non-empty date required?
 * @param string date format (php format)
 * @return boolean|string false if not OK, ISO date if OK
 */
function param_check_date($var, $err_msg, $required = false, $date_format = NULL)
{
    if (empty($GLOBALS[$var])) {
        // empty is OK if not required:
        if ($required) {
            param_error($var, $err_msg);
            return false;
        }
        return '';
    }
    if (empty($date_format)) {
        // Use locale date format:
        $date_format = locale_datefmt();
    }
    // Convert PHP date format to regexp pattern:
    $date_regexp = '~' . preg_replace_callback('~(\\\\)?(\\w)~', create_function('$m', '
		if( $m[1] == "\\\\" ) return $m[2]; // escaped
		switch( $m[2] )
		{
			case "d": return "([0-3]\\d)"; // day, 01-31
			case "j": return "([1-3]?\\d)"; // day, 1-31
			case "l": return "(".str_replace("~", "\\~", implode("|", array_map("trim", array_map("T_", $GLOBALS["weekday"])))).")";
			case "D": return "(".str_replace("~", "\\~", implode("|", array_map("trim", array_map("T_", $GLOBALS["weekday_abbrev"])))).")";
			case "e": // b2evo extension!
				return "(".str_replace("~", "\\~", implode("|", array_map("trim", array_map("T_", $GLOBALS["weekday_letter"])))).")";
				case "S": return "(st|nd|rd|th)"; // english suffix for day

			case "m": return "([0-1]\\d)"; // month, 01-12
			case "n": return "(1?\\d)"; // month, 1-12
			case "F": return "(".str_replace("~", "\\~", implode("|", array_map("trim", array_map("T_", $GLOBALS["month"])))).")"; //  A full textual representation of a month, such as January or March
			case "M": return "(".str_replace("~", "\\~", implode("|", array_map("trim", array_map("T_", $GLOBALS["month_abbrev"])))).")";

			case "y": return "(\\d\\d)"; // year, 00-99
			case "Y": return "(\\d{4})"; // year, XXXX
			default:
				return $m[0];
		}'), $date_format) . '~i';
    // case-insensitive?
    // Allow additional spaces, e.g. "03  May 2007" when format is "d F Y":
    $date_regexp = preg_replace('~ +~', '\\s+', $date_regexp);
    // echo $date_format.'...'.$date_regexp;
    // Check that the numbers match the date pattern:
    if (preg_match($date_regexp, $GLOBALS[$var], $numbers)) {
        // Date does match pattern:
        //pre_dump( $numbers );
        // Get all date pattern parts. We should get 3 parts!:
        preg_match_all('/(?<!\\\\)[A-Za-z]/', $date_format, $parts);
        // "(?<!\\\\)" means that the letter is not escaped with "\"
        //pre_dump( $parts );
        foreach ($parts[0] as $position => $part) {
            switch ($part) {
                case 'd':
                case 'j':
                    $day = $numbers[$position + 1];
                    break;
                case 'm':
                case 'n':
                    $month = $numbers[$position + 1];
                    break;
                case 'F':
                    // full month name
                    $month = array_search(strtolower($numbers[$position + 1]), array_map('strtolower', array_map('trim', array_map('T_', $GLOBALS['month']))));
                    break;
                case 'M':
                    $month = array_search(strtolower($numbers[$position + 1]), array_map('strtolower', array_map('trim', array_map('T_', $GLOBALS['month_abbrev']))));
                    break;
                case 'y':
                case 'Y':
                    $year = $numbers[$position + 1];
                    if ($year < 50) {
                        $year = 2000 + $year;
                    } elseif ($year < 100) {
                        $year = 1900 + $year;
                    }
                    break;
            }
        }
        if (checkdate($month, $day, $year)) {
            // all clean! :)
            // We convert the value to ISO:
            $iso_date = substr('0' . $year, -4) . '-' . substr('0' . $month, -2) . '-' . substr('0' . $day, -2);
            return $iso_date;
        }
    }
    // Date did not pass all tests:
    param_error($var, $err_msg);
    return false;
}
Example #10
0
/**
 * Create author cell for message list table
 *
 * @param integer user ID
 * @param string login
 * @param string first name
 * @param string last name
 * @param integer avatar ID
 * @param string datetime
 */
function author($user_ID, $datetime)
{
    $author = get_user_avatar_styled($user_ID, array('size' => 'crop-top-80x80'));
    return $author . '<div class="note black">' . mysql2date(locale_datefmt() . '<\\b\\r />' . str_replace(':s', '', locale_timefmt()), $datetime) . '</div>';
}
        }
        $hits['session']++;
        $hits_total['session']++;
    }
    if ($last_date != 0) {
        // We had a day pending:
        $this_date = mktime(0, 0, 0, $row_stats['month'], $row_stats['day'], $row_stats['year']);
        $link_text = $admin_url . '?ctrl=stats&tab=hits&datestartinput=' . urlencode(date(locale_datefmt(), $last_date)) . '&datestopinput=' . urlencode(date(locale_datefmt(), $last_date)) . '&blog=' . $blog . '&agent_type=browser';
        $link_text_total_day = $admin_url . '?ctrl=stats&tab=hits&datestartinput=' . urlencode(date(locale_datefmt(), $last_date)) . '&datestopinput=' . urlencode(date(locale_datefmt(), $last_date)) . '&blog=' . $blog . '&agent_type=browser';
        ?>
				<tr class="<?php 
        echo $count % 2 == 1 ? 'odd' : 'even';
        ?>
">
				<td class="firstcol right"><?php 
        echo date('D ' . locale_datefmt(), $this_date);
        if ($current_User->check_perm('stats', 'edit')) {
            echo action_icon(T_('Prune hits for this date!'), 'delete', url_add_param($admin_url, 'ctrl=stats&amp;action=prune&amp;date=' . $last_date . '&amp;show=summary&amp;blog=' . $blog . '&amp;' . url_crumb('stats')));
        }
        ?>
</td>
				<td class="right"><?php 
        echo $hits['session'];
        ?>
</td>
				<td class="right"><a href="<?php 
        echo $link_text . '&referer_type=search';
        ?>
"><?php 
        echo $hits['search'];
        ?>
Example #12
0
            // Required!
            Hitlist::change_type($hit_ID, $new_hit_type);
            $Messages->add(sprintf(T_('Changed hit #%d type to: %s.'), $hit_ID, $new_hit_type), 'success');
            break;
        case 'prune':
            // PRUNE hits for a certain date
            // Check that this action request is not a CSRF hacked request:
            $Session->assert_received_crumb('stats');
            // Check permission:
            $current_User->check_perm('stats', 'edit', true);
            param('date', 'integer', true);
            // Required!
            if ($r = Hitlist::prune($date)) {
                $Messages->add(sprintf(T_('Deleted %d hits for %s.'), $r, date(locale_datefmt(), $date)), 'success');
            } else {
                $Messages->add(sprintf(T_('No hits deleted for %s.'), date(locale_datefmt(), $date)), 'note');
            }
            // Redirect so that a reload doesn't write to the DB twice:
            header_redirect('?ctrl=stats', 303);
            // Will EXIT
            // We have EXITed already at this point!!
            break;
        case 'reset_counters':
            $current_User->check_perm('stats', 'edit', true);
            $sql = 'UPDATE T_track__keyphrase
				SET keyp_count_refered_searches = 0,
					keyp_count_internal_searches = 0';
            $DB->query($sql, ' Reset keyphrases counters');
            break;
    }
}
Example #13
0
 /**
  * Get last touched date (datetime) of Chapter
  *
  * @param string date/time format: leave empty to use locale default date format
  * @param boolean true if you want GMT
  */
 function get_last_touched_date($format = '', $useGM = false)
 {
     if (empty($format)) {
         return mysql2date(locale_datefmt(), $this->last_touched_ts, $useGM);
     }
     return mysql2date($format, $this->last_touched_ts, $useGM);
 }
Example #14
0
    }
    echo '</div>';
}
$facilitate_exploits = '<p>' . T_('When enabled, this feature is known to facilitate hacking exploits in any PHP application.') . "</p>\n<p>" . T_('b2evolution includes additional measures in order not to be affected by this.
	However, for maximum security, we still recommend disabling this PHP feature.') . "</p>\n";
$change_ini = '<p>' . T_('If possible, change this setting to <code>%s</code> in your php.ini or ask your hosting provider about it.') . '</p>';
echo '<h2>' . T_('About this system') . '</h2>';
$block_item_Widget =& new Widget('block_item');
/**
 * b2evolution
 */
$block_item_Widget->title = 'b2evolution';
$block_item_Widget->disp_template_replaced('block_start');
// Version:
$app_timestamp = mysql2timestamp($app_date);
init_system_check('b2evolution version', $app_version . ' released on ' . date_i18n(locale_datefmt(), $app_timestamp));
$app_age = ($localtimenow - $app_timestamp) / 3600 / 24 / 30;
// approx age in months
if ($app_age > 12) {
    disp_system_check('error', sprintf(T_('This version is old. You should check for newer releases on <a %s>b2evolution.net</a>.'), ' href="http://b2evolution.net/downloads/"'));
} elseif ($app_age > 6) {
    disp_system_check('warning', sprintf(T_('This version is aging. You may want to check for newer releases on <a %s>b2evolution.net</a>.'), ' href="http://b2evolution.net/downloads/"'));
} else {
    disp_system_check('ok');
}
// Media folder writable?
list($mediadir_status, $mediadir_msg) = system_check_media_dir();
$mediadir_long = '';
if ($mediadir_status == 'error') {
    $mediadir_long = '<p>' . T_('You will not be able to upload files/images and b2evolution will not be able to generate thumbnails.') . "</p>\n" . '<p>' . T_('Your host requires that you set special file permissions on your media directory.') . get_manual_link('media_file_permission_errors') . "</p>\n";
}
Example #15
0
 /**
  * Template function: display date (datetime) of comment
  *
  * @param string date/time format: leave empty to use locale default date format
  * @param boolean true if you want GMT
  */
 function date($format = '', $useGM = false)
 {
     if (empty($format)) {
         // Get the current locale's default date format
         $format = locale_datefmt();
     }
     echo mysql2date($format, $this->date, $useGM);
 }
Example #16
0
function search_result_block($params = array())
{
    global $Blog, $Session, $debug;
    $search_keywords = param('s', 'string', '', true);
    // Try to load existing search results from Session:
    $search_params = $Session->get('search_params');
    $search_result = $Session->get('search_result');
    $search_result_loaded = false;
    if (empty($search_params) || $search_params['search_keywords'] != $search_keywords || $search_params['search_blog'] != $Blog->ID || $search_result === NULL) {
        // We need to perform a new search:
        if ($debug) {
            echo '<p class="text-muted">Starting a new search...</p>';
        }
        // Flush first part of the page before starting search, which can be long...
        evo_flush();
        $search_params = array('search_keywords' => $search_keywords, 'search_blog' => $Blog->ID);
        // Perform new search:
        $search_result = perform_scored_search($search_keywords);
        // Save results into session:
        $Session->set('search_params', $search_params);
        $Session->set('search_result', $search_result);
        $search_result_loaded = true;
    } else {
        // We found the desired saved search results in the Session:
        if ($debug) {
            // Display counts
            echo '<div class="text-muted">';
            echo '<p>We found the desired saved search results in the Session:</p>';
            echo '<ul><li>' . sprintf('%d posts', $search_result[0]['nr_of_items']) . '</li>';
            echo '<li>' . sprintf('%d comments', $search_result[0]['nr_of_comments']) . '</li>';
            echo '<li>' . sprintf('%d chapters', $search_result[0]['nr_of_cats']) . '</li>';
            echo '<li>' . sprintf('%d tags', $search_result[0]['nr_of_tags']) . '</li></ul>';
            echo '</div>';
        }
        // Flush first part of the page before starting search, which can be long...
        evo_flush();
    }
    // Make sure we are not missing any display params:
    $params = array_merge(array('no_match_message' => '<p class="alert alert-info msg_nothing" style="margin: 2em 0">' . T_('Sorry, we could not find anything matching your request, please try to broaden your search.') . '<p>', 'title_suffix_post' => ' (' . T_('Post') . ')', 'title_suffix_comment' => ' (' . T_('Comment') . ')', 'title_suffix_category' => ' (' . T_('Category') . ')', 'title_suffix_tag' => ' (' . T_('Tag') . ')', 'block_start' => '', 'block_end' => '', 'pagination' => array(), 'use_editor' => false, 'author_format' => 'avatar_name', 'date_format' => locale_datefmt()), $params);
    $search_result = $Session->get('search_result');
    if (empty($search_result)) {
        echo $params['no_match_message'];
        return;
    }
    // Prepare pagination:
    $result_count = count($search_result);
    $result_per_page = $Blog->get_setting('search_per_page');
    if ($result_count > $result_per_page) {
        // We will have multiple search result pages:
        $current_page = param('page', 'integer', 1);
        $total_pages = ceil($result_count / $result_per_page);
        if ($current_page > $total_pages) {
            $current_page = $total_pages;
        }
        $page_params = array_merge(array('total' => $result_count, 'current_page' => $current_page, 'total_pages' => $total_pages, 'list_span' => 11), $params['pagination']);
        search_page_links($page_params);
    } else {
        // Only one page of results:
        $current_page = 1;
        $total_pages = 1;
    }
    // Set current page indexes:
    $from = ($current_page - 1) * $result_per_page;
    $to = $current_page < $total_pages ? $from + $result_per_page : $result_count;
    // Init caches
    $ItemCache =& get_ItemCache();
    $CommentCache =& get_CommentCache();
    $ChapterCache =& get_ChapterCache();
    if (!$search_result_loaded) {
        // Search result objects are not loaded into memory yet, load them
        // Group required object ids by type:
        $required_ids = array();
        for ($index = $from; $index < $to; $index++) {
            $row = $search_result[$index];
            if (isset($required_ids[$row['type']])) {
                $required_ids[$row['type']][] = $row['ID'];
            } else {
                $required_ids[$row['type']] = array($row['ID']);
            }
        }
        // Load each required object into the corresponding cache:
        foreach ($required_ids as $type => $object_ids) {
            switch ($type) {
                case 'item':
                    $ItemCache->load_list($object_ids);
                    break;
                case 'comment':
                    $CommentCache->load_list($object_ids);
                    break;
                case 'category':
                    $ChapterCache->load_list($object_ids);
                    break;
                    // TODO: we'll probably load "tag" objects once we support tag-synonyms.
                // TODO: we'll probably load "tag" objects once we support tag-synonyms.
                default:
                    // Not handled search result type
                    break;
            }
        }
    }
    // ----------- Display ------------
    echo $params['block_start'];
    // Memorize best scores:
    $max_percentage = $search_result[0]['percentage'];
    $max_score = $search_result[0]['score'];
    // Display results for current page:
    for ($index = $from; $index < $to; $index++) {
        $row = $search_result[$index];
        switch ($row['type']) {
            case 'item':
                // Prepare to display an Item:
                $Item = $ItemCache->get_by_ID($row['ID'], false);
                if (empty($Item)) {
                    // This Item was deleted, since the search process was executed
                    continue 2;
                    // skip from switch and skip to the next item in loop
                }
                $display_params = array('title' => $Item->get_title(array('link_type' => 'permalink')) . $params['title_suffix_post'], 'excerpt' => $Item->get_excerpt2(), 'chapter' => sprintf(T_('In %s'), $Item->get_chapter_links()));
                if ($params['use_editor']) {
                    // Get editor info to display:
                    $lastedit_User =& $Item->get_lastedit_User();
                    if (empty($lastedit_User)) {
                        // If editor is not defined yet then use author
                        $lastedit_User =& $Item->get_creator_User();
                    }
                    $display_params = array_merge(array('editor' => $lastedit_User->get_identity_link(array('link_text' => $params['author_format'])), 'lastedit_date' => mysql2date($params['date_format'], empty($Item->datemodified) ? $Item->datecreated : $Item->datemodified)), $display_params);
                } else {
                    // Get author info to display:
                    $creator_User =& $Item->get_creator_User();
                    $display_params = array_merge(array('author' => $creator_User->get_identity_link(array('link_text' => $params['author_format'])), 'creation_date' => mysql2date($params['date_format'], $Item->datecreated), 'lastedit_date' => mysql2date($params['date_format'], $Item->datemodified)), $display_params);
                }
                break;
            case 'comment':
                // Prepare to display a Comment:
                $Comment = $CommentCache->get_by_ID($row['ID'], false);
                if (empty($Comment) || $Comment->status == 'trash') {
                    // This Comment was deleted, since the search process was executed
                    continue 2;
                    // skip from switch and skip to the next item in loop
                }
                $display_params = array('title' => $Comment->get_permanent_link('#item#') . $params['title_suffix_comment'], 'excerpt' => excerpt($Comment->content), 'author' => $Comment->get_author(array('link_text' => $params['author_format'], 'thumb_size' => 'crop-top-15x15', 'thumb_class' => 'avatar_before_login')), 'creation_date' => mysql2date($params['date_format'], $Comment->date));
                break;
            case 'category':
                // Prepare to display a Category:
                $Chapter = $ChapterCache->get_by_ID($row['ID'], false);
                if (empty($Chapter)) {
                    // This Chapter was deleted, since the search process was executed
                    continue 2;
                    // skip from switch and skip to the next item in loop
                }
                $display_params = array('title' => '<a href="' . $Chapter->get_permanent_url() . '">' . $Chapter->get_name() . '</a>' . $params['title_suffix_category'], 'excerpt' => excerpt($Chapter->get('description')));
                break;
            case 'tag':
                // Prepare to display a Tag:
                list($tag_name, $post_count) = explode(':', $row['ID']);
                $display_params = array('title' => '<a href="' . url_add_param($Blog->gen_blogurl(), 'tag=' . $tag_name) . '">' . $tag_name . '</a>' . $params['title_suffix_tag'], 'excerpt' => sprintf(T_('%d posts are tagged with \'%s\''), $post_count, $tag_name));
                break;
            default:
                // Other type of result is not implemented
                // TODO: maybe find collections (especially in case of aggregation)? users? files?
                continue 2;
        }
        // Common display params for all types:
        $display_params['score'] = $row['score'];
        $display_params['percentage'] = isset($row['percentage']) ? $row['percentage'] : round($row['score'] * $max_percentage / $max_score);
        $display_params['scores_map'] = $row['scores_map'];
        $display_params['type'] = $row['type'];
        $display_params['best_result'] = $index == 0;
        $display_params['max_score'] = sprintf(floor($max_score) != $max_score ? '%.2f' : '%d', $max_score);
        $display_params['max_percentage'] = $max_percentage;
        // Display one search result:
        display_search_result(array_merge($params, $display_params));
    }
    echo $params['block_end'];
    // Display pagination:
    if ($result_count > $result_per_page) {
        search_page_links($page_params);
    }
}
Example #17
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>';
    }
}
Example #18
0
        $Table->display_line_start();
        // Checkbox to import
        $Table->display_col_start();
        echo '<input type="radio" name="wp_file" value="' . $import_file['path'] . '"' . (get_param('wp_file') == $import_file['path'] ? ' checked="checked"' : '') . ' />';
        $Table->display_col_end();
        // File
        $Table->display_col_start();
        echo basename($import_file['path']);
        $Table->display_col_end();
        // Type
        $Table->display_col_start();
        echo $import_file['type'];
        $Table->display_col_end();
        // File date
        $Table->display_col_start();
        echo date(locale_datefmt() . ' ' . locale_timefmt(), filemtime($import_file['path']));
        $Table->display_col_end();
        $Table->display_line_end();
        evo_flush();
    }
}
// BODY END / TABLE END:
$Table->display_body_end();
$Table->display_list_end();
if (!empty($import_files)) {
    $Form->begin_fieldset(T_('Select a blog for import'));
    $BlogCache =& get_BlogCache();
    $BlogCache->load_all('shortname,name', 'ASC');
    $BlogCache->none_option_text = '&nbsp;';
    $Form->select_input_object('wp_blog_ID', param('wp_blog_ID', 'integer', 0), $BlogCache, T_('Blog for import'), array('note' => T_('This blog will be used for import.') . ' <a href="' . $admin_url . '?ctrl=collections&action=new">' . T_('Create new blog') . ' &raquo;</a>', 'allow_none' => true, 'required' => true, 'loop_object_method' => 'get_extended_name'));
    $import_type = param('import_type', 'string', 'replace');
 /**
  * Template tag: Display the date if it has changed since last call
  *
  * Optionally also displays empty dates in between.
  *
  * @param array
  */
 function date_if_changed($params = array())
 {
     if ($this->current_Obj->ityp_ID == 1000) {
         // This is not applicable to pages
         return;
     }
     // Make sure we are not missing any param:
     $params = array_merge(array('before' => '<h2>', 'after' => '</h2>', 'empty_day_display' => false, 'empty_day_before' => '<h2>', 'empty_day_after' => '</h2>', 'date_format' => '#'), $params);
     // Get a timestamp for the date WITHOUT the time:
     $current_item_date = mysql2datestamp($this->current_Obj->issue_date);
     if ($current_item_date != $this->last_displayed_date) {
         // Date has changed...
         if ($params['date_format'] == '#') {
             // No format specified, use default locale format:
             $params['date_format'] = locale_datefmt();
         }
         if ($params['empty_day_display'] && !empty($this->last_displayed_date)) {
             // We want to display ALL dates from the previous to the current:
             while ($this->last_displayed_date < $current_item_date - 86400) {
                 $this->last_displayed_date += 86400;
                 // Add one day's worth of seconds
                 echo date_sprintf($params['empty_day_before'], $this->last_displayed_date) . date_i18n($params['date_format'], $this->last_displayed_date) . date_sprintf($params['empty_day_after'], $this->last_displayed_date);
             }
         }
         // Display the new current date:
         echo date_sprintf($params['before'], $this->last_displayed_date) . date_i18n($params['date_format'], $current_item_date) . date_sprintf($params['after'], $this->last_displayed_date);
         $this->last_displayed_date = $current_item_date;
     }
 }
Example #20
0
        $Form->hidden('oldloc_locale', $newlocale);
    }
    $Form->begin_fieldset();
    $Form->text('newloc_locale', $newlocale, 20, T_('Locale'), sprintf(T_('The first two letters should be a <a %s>ISO 639 language code</a>. The last two letters should be a <a %s>ISO 3166 country code</a>.'), 'href="http://www.gnu.org/software/gettext/manual/html_chapter/gettext_15.html#SEC221"', 'href="http://www.gnu.org/software/gettext/manual/html_chapter/gettext_16.html#SEC222"'), 20);
    $Form->checkbox('newloc_enabled', isset($ltemplate['enabled']) && $ltemplate['enabled'], T_('Enabled'), T_('Should this locale be available to users?'));
    $Form->text('newloc_name', isset($ltemplate['name']) ? $ltemplate['name'] : '', 40, T_('Name'), T_('name of the locale'), 40);
    $Form->text('newloc_charset', isset($ltemplate['charset']) ? $ltemplate['charset'] : '', 20, T_('Charset'), T_('Must match the lang file charset.'), 15);
    $Form->text('newloc_datefmt', isset($ltemplate['datefmt']) ? $ltemplate['datefmt'] : '', 20, T_('Date format'), T_('See below.'), 20);
    $Form->text('newloc_timefmt', isset($ltemplate['timefmt']) ? $ltemplate['timefmt'] : '', 20, T_('Time format'), T_('See below.'), 20);
    $Form->dayOfWeek('newloc_startofweek', isset($ltemplate['startofweek']) ? $ltemplate['startofweek'] : 0, T_('Start of week'), T_('Day at the start of the week.'));
    $Form->text('newloc_messages', isset($ltemplate['messages']) ? $ltemplate['messages'] : '', 20, T_('Lang file'), T_('the lang file to use, from the <code>locales</code> subdirectory'), 20);
    $Form->text('newloc_priority', isset($ltemplate['priority']) ? $ltemplate['priority'] : '', 3, T_('Priority'), T_('1 is highest. Priority is important when selecting a locale from a language code and several locales match the same language; this can happen when detecting browser language. Priority also affects the order in which locales are displayed in dropdown boxes, etc.'), 5);
    // TODO: Update this field onchange of datefmt/timefmt through AJAX:
    // fp> It would actually make more sense to have the preview at the exact place that says "see below"
    locale_temp_switch($newlocale);
    $Form->info_field(T_('Date preview:'), date_i18n(locale_datefmt() . ' ' . locale_timefmt(), $localtimenow));
    locale_restore_previous();
    // generate Javascript array of locales to warn in case of overwriting
    $l_warnfor = "'" . implode("', '", array_keys($locales)) . "'";
    if ($edit_locale != '_new_') {
        // remove the locale we want to edit from the generated array
        $l_warnfor = str_replace("'{$newlocale}'", "'thiswillneverevermatch'", $l_warnfor);
    }
    $Form->end_fieldset();
    $Form->end_form(array(array('submit', 'submit', $edit_locale == '_new_' ? T_('Create') : T_('Update'), 'SaveButton'), array('reset', '', T_('Reset'), 'ResetButton')));
    ?>
	<div class="panelinfo">
		<h3><?php 
    echo T_('Flags');
    ?>
</h3>
Example #21
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>';
    $app_age = ($localtimenow - $app_timestamp) / 3600 / 24 / 30;
Example #22
0
<?php

/**
 * This is the template that displays the search form for a blog
 *
 * This file is not meant to be called directly.
 * It is meant to be called by an include in the main.page.php template.
 *
 * b2evolution - {@link http://b2evolution.net/}
 * Released under GNU GPL License - {@link http://b2evolution.net/about/gnu-gpl-license}
 * @copyright (c)2003-2015 by Francois Planque - {@link http://fplanque.com/}
 *
 * @package evoskins
 */
if (!defined('EVO_MAIN_INIT')) {
    die('Please, do not access this page directly.');
}
$params = array_merge(array('pagination' => array(), 'search_class' => 'extended_search_form', 'search_input_before' => '', 'search_input_after' => '', 'search_submit_before' => '', 'search_submit_after' => '', 'search_use_editor' => false, 'search_author_format' => 'avatar_name', 'search_cell_author_start' => '<div class="search_info dimmed">', 'search_cell_author_end' => '</div>', 'search_date_format' => locale_datefmt()), $params);
// ------------------------ START OF SEARCH FORM WIDGET ------------------------
skin_widget(array('widget' => 'coll_search_form', 'block_start' => '', 'block_end' => '', 'block_display_title' => false, 'disp_search_options' => 0, 'search_class' => $params['search_class'], 'search_input_before' => $params['search_input_before'], 'search_input_after' => $params['search_input_after'], 'search_submit_before' => $params['search_submit_before'], 'search_submit_after' => $params['search_submit_after'], 'use_search_disp' => 1));
// ------------------------- END OF SEARCH FORM WIDGET -------------------------
// Perform search (after having displayed the first part of the page) & display results:
search_result_block(array('pagination' => $params['pagination'], 'use_editor' => $params['search_use_editor'], 'author_format' => $params['search_author_format'], 'cell_author_start' => $params['search_cell_author_start'], 'cell_author_end' => $params['search_cell_author_end'], 'date_format' => $params['search_date_format']));
Example #23
0
    /**
     * Builds a date input field.
     *
     * @param string the name of the input field
     * @param string initial value (ISO datetime (YYYY-MM-DD HH:MM:SS)
     *               or erroneous if the field is in error state)
     * @param string label displayed in front of the field
     * @param array Optional params. Additionally to {@link $_common_params} you can use:
     *              - date_format: Format of the date (string, PHP format, default taken from {@link locale_datefmt()})
     *              - add_date_format_note: If true, date format note gets prepended to the field's note
     * @return mixed true (if output) or the generated HTML if not outputting
     */
    function date_input($field_name, $field_value, $field_label, $field_params = array())
    {
        global $month, $weekday_letter;
        if (empty($field_params['date_format'])) {
            // Use locale date format:
            $date_format = locale_datefmt();
        } else {
            $date_format = $field_params['date_format'];
        }
        // Don't keep that attrib in the list:
        unset($field_params['date_format']);
        // Convert PHP date format to JS library date format (date.js):
        // NOTE: when editing/extending this here, you probably also have to adjust param_check_date()!
        $js_date_format = preg_replace_callback('~(\\\\)?(\\w)~', create_function('$m', '
			if( $m[1] == "\\\\" ) return "\\\\".$m[0]; // leave escaped
			switch( $m[2] )
			{
				case "d": return "dd"; // day, 01-31
				case "j": return "d"; // day, 1-31
				case "l": return "EE"; // weekday (name)
				case "D": return "E"; // weekday (abbr)
				case "e": return ""; // weekday letter, not supported

				case "m": return "MM"; // month, 01-12
				case "n": return "M"; // month, 1-12
				case "F": return "MMM"; // full month name; "name or abbr" in date.js
				case "M": return "NNN"; // month name abbr

				case "y": return "yy"; // year, 00-99
				case "Y": return "yyyy"; // year, XXXX
				default:
					return $m[0];
			}'), $date_format);
        #pre_dump( $js_date_format );
        if (param_has_error($field_name)) {
            // There is an error message for this field:
            // We do not try to format the date, we keep the erroneous date.
            //echo 'error on '.$field_name.' keep erroneous entry intact ';
            $field_params['value'] = trim(substr($field_value, 0, 10));
        } else {
            // Make the date value clean for display:
            // The date value may be compact, in this case we have to decompact it
            if (preg_match('/^[0-9]+$/', $field_value)) {
                // The date is compact, so we decompact it
                $field_value = decompact_date($field_value);
            }
            // Get DATE part of datetime and format it to locale format:
            $field_params['value'] = mysql2date($date_format, $field_value);
        }
        if (!empty($field_params['add_date_format_note'])) {
            // Prepend $date_format to note
            $field_params['note'] = empty($field_params['note']) ? '(' . $date_format . ')' : '(' . $date_format . ') ' . $field_params['note'];
        }
        unset($field_params['add_date_format_note']);
        if (!isset($field_params['size'])) {
            // Get size out of $date_format if not explicitly set
            $field_params['size'] = strlen($js_date_format);
        }
        /*
        dh> do not use maxlength by default. Makes no sense IMHO and fails with dateformats like "j \d\e F, Y"
        if( !isset($field_params['maxlength']) )
        {
        	$field_params['maxlength'] = $field_params['size'];
        }
        */
        // Give it a class, so it can be selected for CSS in IE6
        if (empty($field_params['class'])) {
            $field_params['class'] = 'form_date_input';
        } else {
            $field_params['class'] .= ' form_date_input';
        }
        $this->handle_common_params($field_params, $field_name, $field_label);
        $r = $this->begin_field() . '<script type="text/javascript">
						//<![CDATA[
						var cal_' . $field_name . ' = new CalendarPopup();
						cal_' . $field_name . '.showYearNavigation();
						cal_' . $field_name . '.showNavigationDropdowns();
						// cal_' . $field_name . '.showYearNavigationInput();
						// MonthNames get set through MONTH_NAMES
				   cal_' . $field_name . '.setDayHeaders( ' . "'" . T_($weekday_letter[0]) . "'," . "'" . T_($weekday_letter[1]) . "'," . "'" . T_($weekday_letter[2]) . "'," . "'" . T_($weekday_letter[3]) . "'," . "'" . T_($weekday_letter[4]) . "'," . "'" . T_($weekday_letter[5]) . "'," . "'" . T_($weekday_letter[6]) . "' );\n" . ' cal_' . $field_name . '.setWeekStartDay(' . locale_startofweek() . ');
						cal_' . $field_name . ".setTodayText('" . TS_('Today') . "');\r\n\t\t\t\t\t\t//]]>\r\n\t\t\t\t\t</script>\n" . $this->get_input_element($field_params, false) . '<a href="#" onclick="cal_' . $field_name . ".select(document.getElementById('" . $field_name . "'), 'anchor_" . $field_name . "', '" . $js_date_format . "');" . ' return false;" name="anchor_' . $field_name . '" id="anchor_' . $this->get_valid_id($field_name) . '" title="' . T_('Select date') . '">' . get_icon('calendar', 'imgtag', array('title' => T_('Select date'))) . '</a>';
        $r .= $this->end_field();
        return $this->display_or_return($r);
    }
Example #24
0
        // Increment hitcounter:
        $hits[$row_stats['agnt_type']] = $row_stats['hits'];
        $hits_total[$row_stats['agnt_type']] += $row_stats['hits'];
    }
    if ($last_date != 0) {
        // We had a day pending:
        ?>
				<tr class="<?php 
        echo $count % 2 == 1 ? 'odd' : 'even';
        ?>
">
				<td class="firstcol"><?php 
        if ($current_User->check_perm('stats', 'edit')) {
            echo action_icon(T_('Prune hits for this date!'), 'delete', url_add_param($admin_url, 'ctrl=stats&amp;action=prune&amp;date=' . $last_date . '&amp;show=summary&amp;blog=' . $blog));
        }
        echo date(locale_datefmt(), $this_date);
        ?>
				</td>
				<td class="right"><?php 
        echo $hits['rss'];
        ?>
</td>
				<td class="right"><?php 
        echo $hits['robot'];
        ?>
</td>
				<td class="right"><?php 
        echo $hits['browser'];
        ?>
</td>
				<td class="right"><?php 
Example #25
0
function stats_time($format = '')
{
    global $row_stats;
    if ($format == '') {
        $format = locale_datefmt() . ' ' . locale_timefmt();
    }
    echo date_i18n($format, $row_stats['hit_datetime']);
}
Example #26
0
/**
 * Draw the canvas bars chart.
 *
 * @param array Chart bars data
 */
function CanvasBarsChart($chart)
{
    ?>
<div id="canvasbarschart" style="height:<?php 
    echo $chart['canvas_bg']['height'];
    ?>
px;width:<?php 
    echo $chart['canvas_bg']['width'];
    ?>
px;margin:auto auto 35px;"></div>
<script type="text/javascript">
jQuery( window ).load( function()
{
	<?php 
    // Init data for jqPlot format:
    $jqplot_data = array();
    $jqplot_legend = array();
    foreach ($chart['chart_data'] as $i => $data) {
        if ($i > 0) {
            // Legend label
            $jqplot_legend[] = $data[0];
            // Data
            array_shift($data);
            $jqplot_data[] = '[' . implode(',', $data) . ']';
        }
    }
    // Ticks
    $jqplot_ticks = $chart['chart_data'][0];
    array_shift($jqplot_ticks);
    // Weekend bands
    $jqplot_canvas_objects = array();
    foreach ($chart['dates'] as $d => $date) {
        $week_day = date('w', $date);
        if ($week_day == 0 || $week_day == 6) {
            $jqplot_canvas_objects[] = '{rectangle: {
					xmin: ' . ($d + 0.5) . ',
					xmax: ' . ($d + 1.5) . ',
					xminOffset: "0",
					xmaxOffset: "0",
					yminOffset: "0",
					ymaxOffset: "0",
					color: "rgba(0,0,0,0.05)"
				}}';
        }
    }
    ?>
	jQuery.jqplot.postDrawHooks.push( function()
	{
		jQuery( '.jqplot-overlayCanvas-canvas' ).css( 'z-index', '0' ); //send overlay canvas to back
		jQuery( '.jqplot-series-canvas' ).css( 'z-index', '1' ); //send series canvas to front
		jQuery( '.jqplot-highlighter-tooltip' ).css( 'z-index', '2' ); //make sure the tooltip is over the series
		jQuery( '.jqplot-event-canvas' ).css( 'z-index', '5' ); //must be on the very top since it is responsible for event catching and propagation
	} );

	var data = [<?php 
    echo implode(',', $jqplot_data);
    ?>
];
	jQuery.jqplot( 'canvasbarschart', data, {
		seriesColors: [ '#<?php 
    echo implode('\', \'#', $chart['series_color']);
    ?>
' ],
		stackSeries: true,
		animate: !$.jqplot.use_excanvas,
		seriesDefaults:{
			renderer:$.jqplot.BarRenderer,
			rendererOptions: {
				highlightMouseOver: true,
				shadow: false,
				barMargin: 2,
				animation: { speed: 900 },
			}
		},
		<?php 
    if (isset($chart['draw_last_line']) && $chart['draw_last_line']) {
        // Draw a line from last data
        ?>
		series: [<?php 
        echo str_repeat('{},', count($jqplot_data) - 1);
        ?>
		{
			disableStack : true,//otherwise it wil be added to values of previous series
			renderer: $.jqplot.LineRenderer,
			lineWidth: 3,
			pointLabels: { show: true },
			markerOptions: { size: 10 }
		}],
		<?php 
    }
    ?>
		grid: {
			shadow: false,
			borderWidth: 1,
			borderColor: '#e5e5e5',
			gridLineColor: '#e5e5e5',
			background: '#fff'
		},
		axes: {
			xaxis: {
				renderer: $.jqplot.CategoryAxisRenderer,
				rendererOptions: {
					tickRenderer: $.jqplot.CanvasAxisTickRenderer
				},
				ticks: ['<?php 
    echo implode("','", $jqplot_ticks);
    ?>
'],
				tickOptions: {
					showGridline: false,
					angle: -45,
					fontFamily: 'Arial, Helvetica, sans-serif',
					fontSize: '13px',
				},
			},
			yaxis: { min: 0 }
		},
		legend: {
			renderer: $.jqplot.EnhancedLegendRenderer,
			rendererOptions: {
				numberRows: <?php 
    echo isset($chart['legend_numrows']) ? $chart['legend_numrows'] : '1';
    ?>
			},
			labels: ['<?php 
    echo implode("','", $jqplot_legend);
    ?>
'],
			show: true,
			location: 's',
			placement: 'outside',
			yoffset: 80
		},
		highlighter: {
			show: true,
			showMarker: false,
			tooltipAxes: 'y',
		},
		<?php 
    if (!empty($jqplot_canvas_objects)) {
        // Draw overlay boxes for weekends
        ?>
		canvasOverlay: {
			show: true,
			objects: [ <?php 
        echo implode(',', $jqplot_canvas_objects);
        ?>
 ]
		}
		<?php 
    }
    ?>
	} );

	// Highlight legend
	jQuery( '#canvasbarschart' ).bind( 'jqplotDataHighlight', function( ev, seriesIndex, pointIndex, data )
	{
		jQuery( '#canvasbarschart td.jqplot-table-legend' ).removeClass( 'legend-text-highlighted' );
		jQuery( '#canvasbarschart td.jqplot-table-legend' ).eq( seriesIndex * 2 + 1 ).addClass( 'legend-text-highlighted' )
			.prev().addClass( 'legend-text-highlighted' );
		<?php 
    if (isset($chart['link_data'])) {
        ?>
		jQuery( '#canvasbarschart .jqplot-event-canvas' ).css( 'cursor', 'pointer' );
		<?php 
    }
    ?>
	} );
	jQuery( '#canvasbarschart' ).bind( 'jqplotDataUnhighlight', function( ev, seriesIndex, pointIndex, data )
	{
		jQuery( '#canvasbarschart td.jqplot-table-legend' ).removeClass( 'legend-text-highlighted' );
		<?php 
    if (isset($chart['link_data'])) {
        ?>
		jQuery( '#canvasbarschart .jqplot-event-canvas' ).css( 'cursor', 'auto' );
		<?php 
    }
    ?>
		jQuery( '#canvasbarschart .jqplot-highlighter-tooltip' ).hide();
	} );
	var canvas_offset = jQuery( '#canvasbarschart' ).offset();
	jQuery( '#canvasbarschart' ).mousemove( function( ev )
	{
		jQuery( '#canvasbarschart .jqplot-highlighter-tooltip' ).css( {
			top: ev.pageY - canvas_offset.top - 16,
			left: ev.pageX - canvas_offset.left - 16
		} );
	} );

	<?php 
    if (isset($chart['link_data'])) {
        $chart_link_dates = array();
        foreach ($chart['dates'] as $date) {
            $chart_link_dates[] = urlencode(date(locale_datefmt(), $date));
        }
        ?>
	// Open an url on click
	var jqplot_link_url = '<?php 
        echo $chart['link_data']['url'];
        ?>
';
	var jqplot_link_dates = ['<?php 
        echo implode("','", $chart_link_dates);
        ?>
'];
	var jqplot_link_params = [<?php 
        $params = array();
        foreach ($chart['link_data']['params'] as $types) {
            $params[] = "['" . implode("','", $types) . "']";
        }
        echo implode(',', $params);
        ?>
];
	jQuery( '#canvasbarschart' ).bind( 'jqplotDataClick', function ( ev, seriesIndex, pointIndex, data )
	{
		if( typeof( jqplot_link_params[ seriesIndex ] ) == 'undefined' )
		{
			return false;
		}

		var url = jqplot_link_url.replace( /\$date\$/g, jqplot_link_dates[ pointIndex ] );
		url = url.replace( '$param1$', jqplot_link_params[ seriesIndex ][0] );
		url = url.replace( '$param2$', jqplot_link_params[ seriesIndex ][1] );

		//console.log( url );
		location.href = url;
	} );
	<?php 
    }
    ?>
} );
</script>
<?php 
}
Example #27
0
    /**
     * Builds a date input field.
     *
     * @param string the name of the input field
     * @param string initial value (ISO datetime (YYYY-MM-DD HH:MM:SS)
     *               or erroneous if the field is in error state)
     * @param string label displayed in front of the field
     * @param array Optional params. Additionally to {@link $_common_params} you can use:
     *              - date_format: Format of the date (string, PHP format, default taken from {@link locale_datefmt()})
     *              - add_date_format_note: If true, date format note gets prepended to the field's note
     * @return mixed true (if output) or the generated HTML if not outputting
     */
    function date_input($field_name, $field_value, $field_label, $field_params = array())
    {
        global $month, $weekday_letter;
        if (empty($field_params['date_format'])) {
            // Use locale date format:
            $date_format = locale_datefmt();
        } else {
            $date_format = $field_params['date_format'];
        }
        // Don't keep that attrib in the list:
        unset($field_params['date_format']);
        // Convert PHP date format to JS library date format:
        // NOTE: when editing/extending this here, you probably also have to adjust param_check_date()!
        $js_date_format = preg_replace_callback('~(\\\\)?(\\w)~', create_function('$m', '
			if( $m[1] == "\\\\" ) return "\\\\".$m[0]; // leave escaped
			switch( $m[2] )
			{
				case "d": return "dd"; // day, 01-31
				case "j": return "d"; // day, 1-31
				case "l": return "EE"; // weekday (name)
				case "D": return "E"; // weekday (abbr)
				case "e": return ""; // weekday letter, not supported

				case "m": return "MM"; // month, 01-12
				case "n": return "M"; // month, 1-12
				case "F": return "MMM"; // full month name; "name or abbr" in date.js
				case "M": return "NNN"; // month name abbr

				case "y": return "yy"; // year, 00-99
				case "Y": return "yyyy"; // year, XXXX
				default:
					return $m[0];
			}'), $date_format);
        $field_params['type'] = 'text';
        if (param_has_error($field_name) && !preg_match('~^\\d\\d\\d\\d-\\d\\d-\\d\\d(?: \\d\\d:\\d\\d:\\d\\d)?$~', $field_value)) {
            // There is an error message for this field:
            // We do not try to format the date, we keep the erroneous date (if it is not obviously valid).
            // We could have used param_error() ourself (e.g. "date outside of range"), and the erroneous
            // field should have the correct format.
            //echo 'error on '.$field_name.' keep erroneous entry intact ';
            // Keep original value, but strip off the time part (if any).
            $field_params['value'] = preg_replace('~ \\d\\d:\\d\\d:\\d\\d$~', '', $field_value);
        } else {
            // Make the date value clean for display:
            // The date value may be compact, in this case we have to decompact it
            if (preg_match('/^[0-9]+$/', $field_value)) {
                // The date is compact, so we decompact it
                $field_value = decompact_date($field_value);
            }
            // Get DATE part of datetime and format it to locale format:
            $field_params['value'] = mysql2date($date_format, $field_value);
            if (!$field_params['value']) {
                // Conversion failed (e.g. for dates before ~1902 / PHP < 5.1 (Windows) / 32bit / without DateTime support), use the original value (better than 1970-01-01 anyway!).
                $field_params['value'] = $field_value;
            }
        }
        if (!empty($field_params['add_date_format_note'])) {
            // Prepend $date_format to note
            $field_params['note'] = empty($field_params['note']) ? '(' . $date_format . ')' : '(' . $date_format . ') ' . $field_params['note'];
        }
        unset($field_params['add_date_format_note']);
        if (!isset($field_params['size'])) {
            // Get size out of $date_format if not explicitly set
            $field_params['size'] = strlen($js_date_format);
        }
        /*
        dh> do not use maxlength by default. Makes no sense IMHO and fails with dateformats like "j \d\e F, Y"
        if( !isset($field_params['maxlength']) )
        {
        	$field_params['maxlength'] = $field_params['size'];
        }
        */
        /*
        Afwas > In the existing locales only d m y and Y are used. Currently the jQuery Datepicker
        can't handle other dateformats. I will see to some basic check or enable all.
        @TODO ^^ fp> It might make sense to have 2 date formats for locales: 1 for display and 1 for inputs. Input formats could be forced to used numeric data only.
        */
        // Give it a class, so it can be selected for CSS in IE6
        $field_params['class'] = (empty($field_params['class']) ? '' : $field_params['class'] . ' ') . 'form_date_input form-control';
        $this->handle_common_params($field_params, $field_name, $field_label);
        $r = $this->begin_field() . $this->get_input_element($field_params, false);
        $r .= $this->end_field();
        return $this->display_or_return($r);
    }
Example #28
0
/**
 * wp.getOptions
 *
 * @see http://codex.wordpress.org/XML-RPC_wp#wp.getOptions
 *
 * Note: If passing in a struct, search for options listed within it.
 *
 * @param xmlrpcmsg XML-RPC Message
 *					0 blogid (int): Unique identifier of the blog.
 *					1 username (string): User login.
 *					2 password (string): Password for said username.
 *					3 options (struct)
 */
function wp_getoptions($m)
{
    global $Settings;
    // CHECK LOGIN:
    /**
     * @var User
     */
    if (!($current_User =& xmlrpcs_login($m, 1, 2))) {
        // Login failed, return (last) error:
        return xmlrpcs_resperror();
    }
    // GET BLOG:
    /**
     * @var Blog
     */
    if (!($Blog =& xmlrpcs_get_Blog($m, 0))) {
        // Login failed, return (last) error:
        return xmlrpcs_resperror();
    }
    if (isset($m->params[3])) {
        $options = $m->getParam(3);
        $options = xmlrpc_decode_recurse($options);
    }
    $defaults = array('software_name' => array('desc' => 'Software Name', 'value' => 'WordPress'), 'software_version' => array('desc' => 'Software Version', 'value' => '3.3.2'), 'blog_url' => array('desc' => 'Site URL', 'value' => $Blog->gen_blogurl()), 'blog_title' => array('desc' => 'Site TitleL', 'value' => $Blog->get('name')), 'blog_tagline' => array('desc' => 'Site Tagline', 'value' => $Blog->get('tagline')), 'date_format' => array('desc' => 'Date Format', 'value' => locale_datefmt()), 'time_format' => array('desc' => 'Time Format', 'value' => locale_timefmt()), 'users_can_register' => array('desc' => 'Allow new users to sign up', 'value' => $Settings->get('newusers_canregister')), 'thumbnail_crop' => array('desc' => 'Crop thumbnail to exact dimensions', 'value' => false), 'thumbnail_size_w' => array('desc' => 'Thumbnail Width', 'value' => '160'), 'thumbnail_size_h' => array('desc' => 'Thumbnail Height', 'value' => '160'), 'medium_size_w' => array('desc' => 'Medium size image width', 'value' => '320'), 'medium_size_h' => array('desc' => 'Medium size image height', 'value' => '320'), 'large_size_w' => array('desc' => 'Large size image width', 'value' => '720'), 'large_size_h' => array('desc' => 'Large size image height', 'value' => '500'));
    $data = array();
    if (empty($options)) {
        // No specific options where asked for, return all of them
        foreach ($defaults as $k => $opt) {
            $data[$k] = new xmlrpcval(array('desc' => new xmlrpcval($opt['desc']), 'readonly' => new xmlrpcval(true, 'boolean'), 'value' => new xmlrpcval($opt['value'])), 'struct');
        }
        logIO('Retrieving all options');
    } else {
        foreach ($options as $k) {
            if (!isset($defaults[$k])) {
                continue;
            }
            $data[$k] = new xmlrpcval(array('desc' => new xmlrpcval($defaults[$k]['desc']), 'readonly' => new xmlrpcval(true, 'boolean'), 'value' => new xmlrpcval($defaults[$k]['value'])), 'struct');
            logIO('Retrieving option: ' . $k);
        }
    }
    logIO('OK.');
    return new xmlrpcresp(new xmlrpcval($data, 'struct'));
}
echo '</div>';
?>

			<h3 class="evo_post_title linked"><?php 
if (!$Item->is_intro()) {
    $permalink_title = 'permalink';
} else {
    $permalink_title = '';
}
$Item->title(array('link_type' => $permalink_title));
?>
</h3>

			<?php 
if (!$Item->is_intro()) {
    $Item->issue_date(array('before' => '<span class="timestamp">', 'after' => '</span>', 'date_format' => locale_datefmt() . ' H:i'));
}
?>

		</div>

		<?php 
// ---------------------- POST CONTENT INCLUDED HERE ----------------------
// Note: at the top of this file, we set: 'image_size' =>	'', // Do not display images in content block - Image is handled separately
skin_include('_item_content.inc.php', $params);
// Note: You can customize the default item content by copying the generic
// /skins/_item_content.inc.php file into the current skin folder.
// -------------------------- END OF POST CONTENT -------------------------
?>
		
		<?php 
Example #30
0
 /**
 * Get date/time of last modification, formatted.
 *
 $ @param string date format or 'date' or 'time' for default locales.
 * @return string locale formatted date/time
 */
 function get_lastmod_formatted($format = '#')
 {
     global $localtimenow;
     switch ($format) {
         case 'date':
             return date_i18n(locale_datefmt(), $this->_lastmod_ts);
         case 'time':
             return date_i18n(locale_timefmt(), $this->_lastmod_ts);
         case 'compact':
             $age = $localtimenow - $this->_lastmod_ts;
             if ($age < 3600) {
                 // Less than 1 hour: return full time
                 return date_i18n('H:i:s', $this->_lastmod_ts);
             }
             if ($age < 86400) {
                 // Less than 24 hours: return compact time
                 return date_i18n('H:i', $this->_lastmod_ts);
             }
             if ($age < 31536000) {
                 // Less than 365 days: Month and day
                 return date_i18n('M, d', $this->_lastmod_ts);
             }
             // Older: return yeat
             return date_i18n('Y', $this->_lastmod_ts);
             break;
         case '#':
         default:
             $format = locale_datefmt() . ' ' . locale_timefmt();
             return date_i18n($format, $this->_lastmod_ts);
     }
 }