本文整理汇总了PHP中db_helper_compare_days函数的典型用法代码示例。如果您正苦于以下问题:PHP db_helper_compare_days函数的具体用法?PHP db_helper_compare_days怎么用?PHP db_helper_compare_days使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了db_helper_compare_days函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: require_api
require_api( 'user_api.php' );
form_security_validate( 'manage_user_prune' );
auth_reauthenticate();
access_ensure_global_level( config_get( 'manage_user_threshold' ) );
$t_user_table = db_get_table( 'user' );
# Delete the users who have never logged in and are older than 1 week
$days_old = (int)7 * SECONDS_PER_DAY;
$query = "SELECT id, access_level
FROM $t_user_table
WHERE ( login_count = 0 ) AND ( date_created = last_visit ) AND " . db_helper_compare_days( 0, "date_created", "> $days_old" );
$result = db_query_bound($query, Array( db_now() ) );
if ( !$result ) {
trigger_error( ERROR_GENERIC, ERROR );
}
$count = db_num_rows( $result );
if ( $count > 0 ) {
helper_ensure_confirmed( lang_get( 'confirm_account_pruning' ),
lang_get( 'prune_accounts_button' ) );
}
for ($i=0; $i < $count; $i++) {
$row = db_fetch_array( $result );
示例2: news_get_limited_rows
function news_get_limited_rows($p_offset, $p_project_id = null)
{
if ($p_project_id === null) {
$p_project_id = helper_get_current_project();
}
$c_offset = db_prepare_int($p_offset);
$t_projects = current_user_get_all_accessible_subprojects($p_project_id);
$t_projects[] = (int) $p_project_id;
if (ALL_PROJECTS != $p_project_id) {
$t_projects[] = ALL_PROJECTS;
}
$t_news_table = db_get_table('mantis_news_table');
$t_news_view_limit = config_get('news_view_limit');
$t_news_view_limit_days = config_get('news_view_limit_days') * SECONDS_PER_DAY;
switch (config_get('news_limit_method')) {
case 0:
# BY_LIMIT - Select the news posts
$query = "SELECT *\n\t\t\t\t\t\tFROM {$t_news_table}";
if (1 == count($t_projects)) {
$c_project_id = $t_projects[0];
$query .= " WHERE project_id='{$c_project_id}'";
} else {
$query .= ' WHERE project_id IN (' . join($t_projects, ',') . ')';
}
$query .= ' ORDER BY announcement DESC, id DESC';
$result = db_query($query, $t_news_view_limit, $c_offset);
break;
case 1:
# BY_DATE - Select the news posts
$query = "SELECT *\n\t\t\t\t\t\tFROM {$t_news_table} WHERE\n\t\t\t\t\t\t( " . db_helper_compare_days(0, 'date_posted', "< {$t_news_view_limit_days}") . "\n\t\t\t\t\t\t OR announcement = " . db_param() . " ) ";
$t_params = array(db_now(), 1);
if (1 == count($t_projects)) {
$c_project_id = $t_projects[0];
$query .= " AND project_id=" . db_param();
$t_params[] = $c_project_id;
} else {
$query .= ' AND project_id IN (' . join($t_projects, ',') . ')';
}
$query .= " ORDER BY announcement DESC, id DESC";
$result = db_query_bound($query, $t_params, $t_news_view_limit, $c_offset);
break;
}
# end switch
$t_row_count = db_num_rows($result);
$t_rows = array();
for ($i = 0; $i < $t_row_count; $i++) {
$row = db_fetch_array($result);
array_push($t_rows, $row);
}
return $t_rows;
}
示例3: form_security_validate
* @package MantisBT
* @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
* @copyright Copyright (C) 2002 - 2014 MantisBT Team - mantisbt-dev@lists.sourceforge.net
* @link http://www.mantisbt.org
*/
/**
* MantisBT Core API's
*/
require_once 'core.php';
form_security_validate('manage_user_prune');
auth_reauthenticate();
access_ensure_global_level(config_get('manage_user_threshold'));
$t_user_table = db_get_table('mantis_user_table');
# Delete the users who have never logged in and are older than 1 week
$days_old = (int) 7 * SECONDS_PER_DAY;
$query = "SELECT id, access_level\n\t\t\tFROM {$t_user_table}\n\t\t\tWHERE ( login_count = 0 ) AND ( date_created = last_visit ) AND " . db_helper_compare_days(0, "date_created", "> {$days_old}");
$result = db_query_bound($query, array(db_now()));
if (!$result) {
trigger_error(ERROR_GENERIC, ERROR);
}
$count = db_num_rows($result);
if ($count > 0) {
helper_ensure_confirmed(lang_get('confirm_account_pruning'), lang_get('prune_accounts_button'));
}
for ($i = 0; $i < $count; $i++) {
$row = db_fetch_array($result);
# Don't prune accounts with a higher global access level than the current user
if (access_has_global_level($row['access_level'])) {
user_delete($row['id']);
}
}
示例4: db_prepare_string
}
$t_index_links .= '<td>' . $t_link . '</td>';
}
$t_index_links .= '</tr></table></center>';
echo $t_index_links;
if ($f_prefix === 'ALL') {
$t_where = '(1 = 1)';
} else {
$c_prefix = db_prepare_string($f_prefix);
$t_where = "(username like '{$c_prefix}%')";
}
# Get the user data in $c_sort order
if (0 == $c_hide) {
$query = "SELECT *\n\t\t\t\tFROM {$t_user_table}\n\t\t\t\tWHERE {$t_where}\n\t\t\t\tORDER BY {$c_sort} {$c_dir}";
} else {
$query = "SELECT *\n\t\t\t\tFROM {$t_user_table}\n\t\t\t\tWHERE (" . db_helper_compare_days(db_now(), "last_visit", "< '{$days_old}'") . ") AND {$t_where}\n\t\t\t\tORDER BY {$c_sort} {$c_dir}";
}
$result = db_query($query);
$user_count = db_num_rows($result);
?>
<br />
<table class="width100" cellspacing="1">
<tr>
<td class="form-title" colspan="5">
<?php
echo lang_get('manage_accounts_title');
?>
[<?php
echo $user_count;
?>
]
示例5: helper_ensure_post
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Mantis. If not, see <http://www.gnu.org/licenses/>.
# --------------------------------------------------------
# $Id: manage_user_prune.php,v 1.11.2.1 2007-10-13 22:33:57 giallu Exp $
# --------------------------------------------------------
require_once 'core.php';
# helper_ensure_post();
auth_reauthenticate();
access_ensure_global_level(config_get('manage_user_threshold'));
$t_user_table = config_get('mantis_user_table');
# Delete the users who have never logged in and are older than 1 week
$days_old = 7;
$days_old = (int) $days_old;
$date_calc = db_helper_compare_days(db_now(), "date_created", "> {$days_old}");
$query = "SELECT id\n\t\t\tFROM {$t_user_table}\n\t\t\tWHERE ( login_count = 0 ) AND ( date_created = last_visit ) AND {$date_calc}";
$result = db_query($query);
if (!$result) {
trigger_error(ERROR_GENERIC, ERROR);
}
$count = db_num_rows($result);
if ($count > 0) {
helper_ensure_confirmed(lang_get('confirm_account_pruning'), lang_get('prune_accounts_button'));
}
for ($i = 0; $i < $count; $i++) {
$row = db_fetch_array($result);
user_delete($row['id']);
}
$t_redirect_url = 'manage_user_page.php';
print_header_redirect($t_redirect_url);
示例6: summary_resolved_bug_count_by_date
function summary_resolved_bug_count_by_date($p_time_length = 1)
{
$t_bug_table = db_get_table('mantis_bug_table');
$t_bug_history_table = db_get_table('mantis_bug_history_table');
$t_resolved = config_get('bug_resolved_status_threshold');
$c_time_length = (int) $p_time_length * SECONDS_PER_DAY;
$t_project_id = helper_get_current_project();
$t_user_id = auth_get_current_user_id();
$specific_where = helper_project_specific_where($t_project_id);
if (' 1<>1' == $specific_where) {
return;
}
$query = "SELECT COUNT(DISTINCT(b.id))\n\t\t\t\tFROM {$t_bug_table} b\n\t\t\t\tLEFT JOIN {$t_bug_history_table} h\n\t\t\t\tON b.id = h.bug_id\n\t\t\t\tAND h.type = " . NORMAL_TYPE . "\n\t\t\t\tAND h.field_name = 'status'\n\t\t\t\tWHERE b.status >= " . db_param() . "\n\t\t\t\tAND h.old_value < " . db_param() . "\n\t\t\t\tAND h.new_value >= " . db_param() . "\n\t\t\t\tAND " . db_helper_compare_days("" . db_now() . "", "date_modified", "<= {$c_time_length}") . "\n\t\t\t\tAND {$specific_where}";
$result = db_query_bound($query, array($t_resolved, $t_resolved, $t_resolved));
return db_result($result, 0);
}
示例7: db_query_bound
if ($t_page_count < 1) {
$t_page_count = 1;
}
# Make sure $p_page_number isn't past the last page.
if ($f_page_number > $t_page_count) {
$f_page_number = $t_page_count;
}
# Make sure $p_page_number isn't before the first page
if ($f_page_number < 1) {
$f_page_number = 1;
}
if (0 == $c_hide_inactive) {
$query = "SELECT *\n\t\t\t\tFROM {$t_user_table}\n\t\t\t\tWHERE {$t_where}\n\t\t\t\t{$t_show_disabled_cond}\n\t\t\t\tORDER BY {$c_sort} {$c_dir}";
$result = db_query_bound($query, $t_where_params, $p_per_page, $t_offset);
} else {
$query = "SELECT *\n\t\t\t\tFROM {$t_user_table}\n\t\t\t\tWHERE {$t_where} AND " . db_helper_compare_days("" . db_now() . "", "last_visit", "< {$days_old}") . "\n\t\t\t\t{$t_show_disabled_cond}\n\t\t\t\tORDER BY {$c_sort} {$c_dir}";
$result = db_query_bound($query, $t_where_params, $p_per_page, $t_offset);
}
$user_count = db_num_rows($result);
?>
<br />
<table class="width100" cellspacing="1">
<tr>
<td class="form-title" colspan="5">
<?php
echo lang_get('manage_accounts_title');
?>
[<?php
echo $total_user_count;
?>
]
示例8: summary_resolved_bug_count_by_date
/**
* returns the number of bugs resolved in the last X days (default is 1 day) for the current project
*
* @param integer $p_num_days Anumber of days.
* @return integer
*/
function summary_resolved_bug_count_by_date($p_num_days = 1)
{
$t_resolved = config_get('bug_resolved_status_threshold');
$c_time_length = (int) $p_num_days * SECONDS_PER_DAY;
$t_project_id = helper_get_current_project();
$t_specific_where = helper_project_specific_where($t_project_id);
if (' 1<>1' == $t_specific_where) {
return 0;
}
$t_query = 'SELECT COUNT(DISTINCT(b.id))
FROM {bug} b
LEFT JOIN {bug_history} h
ON b.id = h.bug_id
AND h.type = ' . NORMAL_TYPE . '
AND h.field_name = \'status\'
WHERE b.status >= ' . db_param() . '
AND h.old_value < ' . db_param() . '
AND h.new_value >= ' . db_param() . '
AND ' . db_helper_compare_days('' . db_now() . '', 'date_modified', '<= ' . $c_time_length) . '
AND ' . $t_specific_where;
$t_result = db_query($t_query, array($t_resolved, $t_resolved, $t_resolved));
return db_result($t_result, 0);
}
示例9: summary_bug_count_by_date
function summary_bug_count_by_date($p_time_length = 1)
{
$t_mantis_bug_table = config_get('mantis_bug_table');
$c_time_length = (int) $p_time_length;
$t_project_id = helper_get_current_project();
$t_user_id = auth_get_current_user_id();
$specific_where = helper_project_specific_where($t_project_id);
if (' 1<>1' == $specific_where) {
return;
}
$query = "SELECT COUNT(*)\n\t\t\t\tFROM {$t_mantis_bug_table}\n\t\t\t\tWHERE " . db_helper_compare_days(db_now(), "date_submitted", "<= '{$c_time_length}'") . " AND {$specific_where}";
$result = db_query($query);
return db_result($result, 0);
}
示例10: db_query
if( $f_page_number > $t_page_count ) {
$f_page_number = $t_page_count;
}
# Make sure $p_page_number isn't before the first page
if( $f_page_number < 1 ) {
$f_page_number = 1;
}
if( 0 == $c_hide_inactive ) {
$t_query = 'SELECT * FROM {user} WHERE ' . $t_where . ' ' . $t_show_disabled_cond . ' ORDER BY ' . $c_sort . ' ' . $c_dir;
$t_result = db_query( $t_query, $t_where_params, $p_per_page, $t_offset );
} else {
$t_query = 'SELECT * FROM {user}
WHERE ' . $t_where . ' AND ' . db_helper_compare_days( '' . db_now() . '', 'last_visit', '< ' . $t_days_old ) . '
' . $t_show_disabled_cond . ' ORDER BY ' . $c_sort . ' ' . $c_dir;
$t_result = db_query( $t_query, $t_where_params, $p_per_page, $t_offset );
}
$t_users = array();
while( $t_row = db_fetch_array( $t_result ) ) {
$t_users[] = $t_row;
}
$t_user_count = count( $t_users );
?>
<div id="manage-user-div" class="form-container">
<h2><?php echo lang_get( 'manage_accounts_title' ) ?></h2> [<?php echo $t_total_user_count ?>]
<?php
print_button( 'manage_user_create_page.php', lang_get( 'create_new_account_link' ) );
示例11: news_get_limited_rows
/**
* Gets a limited set of news rows to be viewed on one page based on the criteria
* defined in the configuration file.
*
* @param integer $p_offset Offset.
* @param integer $p_project_id A project identifier.
* @return array
*/
function news_get_limited_rows($p_offset, $p_project_id = null)
{
if ($p_project_id === null) {
$p_project_id = helper_get_current_project();
}
$c_offset = (int) $p_offset;
$t_projects = current_user_get_all_accessible_subprojects($p_project_id);
$t_projects[] = (int) $p_project_id;
if (ALL_PROJECTS != $p_project_id) {
$t_projects[] = ALL_PROJECTS;
}
$t_news_view_limit = config_get('news_view_limit');
$t_news_view_limit_days = config_get('news_view_limit_days') * SECONDS_PER_DAY;
switch (config_get('news_limit_method')) {
case 0:
# BY_LIMIT - Select the news posts
$t_query = 'SELECT * FROM {news}';
if (1 == count($t_projects)) {
$c_project_id = $t_projects[0];
$t_query .= ' WHERE project_id=' . db_param();
$t_params = array($c_project_id);
} else {
$t_query .= ' WHERE project_id IN (' . join($t_projects, ',') . ')';
$t_params = null;
}
$t_query .= ' ORDER BY announcement DESC, id DESC';
$t_result = db_query($t_query, $t_params, $t_news_view_limit, $c_offset);
break;
case 1:
# BY_DATE - Select the news posts
$t_query = 'SELECT * FROM {news} WHERE
( ' . db_helper_compare_days(0, 'date_posted', '< ' . $t_news_view_limit_days) . '
OR announcement = ' . db_param() . ' ) ';
$t_params = array(db_now(), 1);
if (1 == count($t_projects)) {
$c_project_id = $t_projects[0];
$t_query .= ' AND project_id=' . db_param();
$t_params[] = $c_project_id;
} else {
$t_query .= ' AND project_id IN (' . join($t_projects, ',') . ')';
}
$t_query .= ' ORDER BY announcement DESC, id DESC';
$t_result = db_query($t_query, $t_params, $t_news_view_limit, $c_offset);
break;
}
$t_rows = array();
while ($t_row = db_fetch_array($t_result)) {
array_push($t_rows, $t_row);
}
return $t_rows;
}
示例12: db_query_bound
if ( $f_page_number < 1 ) {
$f_page_number = 1;
}
if ( 0 == $c_hide ) {
$query = "SELECT *
FROM $t_user_table
WHERE $t_where
ORDER BY $c_sort $c_dir";
$result = db_query_bound($query, $t_where_params, $p_per_page, $t_offset);
} else {
$query = "SELECT *
FROM $t_user_table
WHERE $t_where AND " . db_helper_compare_days( "" . db_now() . "", "last_visit", "< $days_old" ) . "
ORDER BY $c_sort $c_dir";
$result = db_query_bound($query, $t_where_params, $p_per_page, $t_offset );
}
$user_count = db_num_rows( $result );
?>
<div id="manage-user-div" class="form-container">
<h2><?php echo lang_get( 'manage_accounts_title' ) ?></h2> [<?php echo $total_user_count ?>]
<?php print_button( 'manage_user_create_page.php', lang_get( 'create_new_account_link' ) ) ?>
<?php if ( $f_filter === 'UNUSED' ) echo print_button( 'manage_user_prune.php', lang_get( 'prune_accounts' ) ); ?>
<form id="manage-user-filter" method="post" action="manage_user_page.php">
<fieldset>
<?php # CSRF protection not required here - form does not result in modifications ?>
<input type="hidden" name="sort" value="<?php echo $c_sort ?>" />
<input type="hidden" name="dir" value="<?php echo $c_dir ?>" />
<input type="hidden" name="save" value="1" />
示例13: require_api
require_api('authentication_api.php');
require_api('config_api.php');
require_api('constant_inc.php');
require_api('database_api.php');
require_api('form_api.php');
require_api('helper_api.php');
require_api('lang_api.php');
require_api('print_api.php');
require_api('user_api.php');
form_security_validate('manage_user_prune');
auth_reauthenticate();
access_ensure_global_level(config_get('manage_user_threshold'));
# Delete the users who have never logged in and are older than 1 week
$t_days_old = (int) 7 * SECONDS_PER_DAY;
$t_query = 'SELECT id, access_level FROM {user}
WHERE ( login_count = 0 ) AND ( date_created = last_visit ) AND ' . db_helper_compare_days(0, 'date_created', '> ' . $t_days_old);
$t_result = db_query($t_query, array(db_now()));
if (!$t_result) {
trigger_error(ERROR_GENERIC, ERROR);
}
$t_count = db_num_rows($t_result);
if ($t_count > 0) {
helper_ensure_confirmed(lang_get('confirm_account_pruning'), lang_get('prune_accounts_button'));
}
for ($i = 0; $i < $t_count; $i++) {
$t_row = db_fetch_array($t_result);
# Don't prune accounts with a higher global access level than the current user
if (access_has_global_level($t_row['access_level'])) {
user_delete($t_row['id']);
}
}
示例14: token_purge_expired
function token_purge_expired($p_token_type = NULL)
{
$t_tokens_table = config_get('mantis_tokens_table');
# Remove
$query = "DELETE FROM {$t_tokens_table} WHERE ";
if (!is_null($p_token_type)) {
$c_token_type = db_prepare_int($p_token_type);
$query .= " type='{$c_token_type}' AND ";
}
$query .= db_helper_compare_days(db_now(), 'timestamp', ">= '1'");
db_query($query);
return true;
}