当前位置: 首页>>代码示例>>PHP>>正文


PHP datetime_convert函数代码示例

本文整理汇总了PHP中datetime_convert函数的典型用法代码示例。如果您正苦于以下问题:PHP datetime_convert函数的具体用法?PHP datetime_convert怎么用?PHP datetime_convert使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了datetime_convert函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: removeme_post

function removeme_post(&$a)
{
    if (!local_channel()) {
        return;
    }
    if ($_SESSION['delegate']) {
        return;
    }
    if (!x($_POST, 'qxz_password') || !strlen(trim($_POST['qxz_password']))) {
        return;
    }
    if (!x($_POST, 'verify') || !strlen(trim($_POST['verify']))) {
        return;
    }
    if ($_POST['verify'] !== $_SESSION['remove_account_verify']) {
        return;
    }
    $account = App::get_account();
    if (!account_verify_password($account['account_email'], $_POST['qxz_password'])) {
        return;
    }
    if ($account['account_password_changed'] != NULL_DATE) {
        $d1 = datetime_convert('UTC', 'UTC', 'now - 48 hours');
        if ($account['account_password_changed'] > d1) {
            notice(t('Channel removals are not allowed within 48 hours of changing the account password.') . EOL);
            return;
        }
    }
    require_once 'include/Contact.php';
    $global_remove = intval($_POST['global']);
    channel_remove(local_channel(), 1 - $global_remove, true);
}
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:32,代码来源:removeme.php

示例2: row2array

 private static function row2array($row, $timezone, $hostname, $uid, $namespace_id)
 {
     $v = new vcalendar();
     $v->setConfig('unique_id', $hostname);
     $v->setProperty('method', 'PUBLISH');
     $v->setProperty("x-wr-calname", "AnimexxCal");
     $v->setProperty("X-WR-CALDESC", "Animexx Calendar");
     $v->setProperty("X-WR-TIMEZONE", $timezone);
     if ($row["adjust"]) {
         $start = datetime_convert('UTC', date_default_timezone_get(), $row["start"]);
         $finish = datetime_convert('UTC', date_default_timezone_get(), $row["finish"]);
     } else {
         $start = $row["start"];
         $finish = $row["finish"];
     }
     $allday = strpos($start, "00:00:00") !== false && strpos($finish, "00:00:00") !== false;
     /*
     
     if ($allday) {
     	$dat = Datetime::createFromFormat("Y-m-d H:i:s", $finish_tmp);
     	$dat->sub(new DateInterval("P1D"));
     	$finish = datetime_convert("UTC", date_default_timezone_get(), $dat->format("Y-m-d H:i:s"));
     	var_dump($finish);
     }
     */
     $subject = substr(preg_replace("/\\[[^\\]]*\\]/", "", $row["desc"]), 0, 100);
     $description = preg_replace("/\\[[^\\]]*\\]/", "", $row["desc"]);
     $vevent = dav_create_vevent(wdcal_mySql2icalTime($row["start"]), wdcal_mySql2icalTime($row["finish"]), false);
     $vevent->setLocation(icalendar_sanitize_string($row["location"]));
     $vevent->setSummary(icalendar_sanitize_string($subject));
     $vevent->setDescription(icalendar_sanitize_string($description));
     $v->setComponent($vevent);
     $ical = $v->createCalendar();
     return array("uid" => $uid, "namespace" => CALDAV_NAMESPACE_FRIENDICA_NATIVE, "namespace_id" => $namespace_id, "date" => $row["edited"], "data_uri" => "friendica-" . $namespace_id . "-" . $row["id"] . "@" . $hostname, "data_subject" => $subject, "data_location" => $row["location"], "data_description" => $description, "data_start" => $start, "data_end" => $finish, "data_allday" => $allday, "data_type" => $row["type"], "ical" => $ical, "ical_size" => strlen($ical), "ical_etag" => md5($ical));
 }
开发者ID:robhell,项目名称:friendica-addons,代码行数:35,代码来源:virtual_cal_source_friendica.inc.php

示例3: log_failed_login

/**
 * @brief Log failed logins to a separate auth log.
 *
 * Can be used to reduce overhead for server side intrusion prevention, like
 * parse the authlog file with something like fail2ban, OSSEC, etc.
 *
 * @param string $errormsg
 *  Error message to display for failed login.
 */
function log_failed_login($errormsg)
{
    $authlog = get_config('system', 'authlog');
    if ($authlog) {
        @file_put_contents($authlog, datetime_convert() . ':' . session_id() . ' ' . $errormsg . PHP_EOL, FILE_APPEND);
    }
}
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:16,代码来源:auth.php

示例4: run

 public static function run($argc, $argv)
 {
     logger('cronhooks: start');
     $d = datetime_convert();
     call_hooks('cron', $d);
     return;
 }
开发者ID:BlaBlaNet,项目名称:hubzilla,代码行数:7,代码来源:Cronhooks.php

示例5: privacy_image_cache_init

function privacy_image_cache_init()
{
    $urlhash = 'pic:' . sha1($_REQUEST['url']);
    $r = q("SELECT * FROM `photo` WHERE `resource-id` = '%s' LIMIT 1", $urlhash);
    if (count($r)) {
        $img_str = $r[0]['data'];
        $mime = $r[0]["desc"];
        if ($mime == "") {
            $mime = "image/jpeg";
        }
    } else {
        require_once "Photo.php";
        $img_str = fetch_url($_REQUEST['url'], true);
        if (substr($img_str, 0, 6) == "GIF89a") {
            $mime = "image/gif";
            $image = @imagecreatefromstring($img_str);
            if ($image === FALSE) {
                die;
            }
            q("INSERT INTO `photo`\n\t\t\t( `uid`, `contact-id`, `guid`, `resource-id`, `created`, `edited`, `filename`, `album`, `height`, `width`, `desc`, `data`, `scale`, `profile`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid` )\n\t\t\tVALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', %d, %d, '%s', '%s', '%s', '%s' )", 0, 0, get_guid(), dbesc($urlhash), dbesc(datetime_convert()), dbesc(datetime_convert()), dbesc(basename(dbesc($_REQUEST["url"]))), dbesc(''), intval(imagesy($image)), intval(imagesx($image)), 'image/gif', dbesc($img_str), 100, intval(0), dbesc(''), dbesc(''), dbesc(''), dbesc(''));
        } else {
            $img = new Photo($img_str);
            if ($img->is_valid()) {
                $img->store(0, 0, $urlhash, $_REQUEST['url'], '', 100);
                $img_str = $img->imageString();
            }
            $mime = "image/jpeg";
        }
    }
    header("Content-type: {$mime}");
    header("Expires: " . gmdate("D, d M Y H:i:s", time() + 3600 * 24) . " GMT");
    header("Cache-Control: max-age=" . 3600 * 24);
    echo $img_str;
    killme();
}
开发者ID:robhell,项目名称:friendica-addons,代码行数:35,代码来源:privacy_image_cache.php

示例6: run

 public static function run($argc, $argv)
 {
     /**
      * Cron Weekly
      * 
      * Actions in the following block are executed once per day only on Sunday (once per week).
      *
      */
     call_hooks('cron_weekly', datetime_convert());
     z_check_cert();
     require_once 'include/hubloc.php';
     prune_hub_reinstalls();
     mark_orphan_hubsxchans();
     // get rid of really old poco records
     q("delete from xlink where xlink_updated < %s - INTERVAL %s and xlink_static = 0 ", db_utcnow(), db_quoteinterval('14 DAY'));
     $dirmode = intval(get_config('system', 'directory_mode'));
     if ($dirmode === DIRECTORY_MODE_SECONDARY || $dirmode === DIRECTORY_MODE_PRIMARY) {
         logger('regdir: ' . print_r(z_fetch_url(get_directory_primary() . '/regdir?f=&url=' . urlencode(z_root()) . '&realm=' . urlencode(get_directory_realm())), true));
     }
     // Check for dead sites
     Master::Summon(array('Checksites'));
     // update searchable doc indexes
     Master::Summon(array('Importdoc'));
     /**
      * End Cron Weekly
      */
 }
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:27,代码来源:Cron_weekly.php

示例7: post

 function post()
 {
     if (!local_channel()) {
         return;
     }
     if ($_SESSION['delegate']) {
         return;
     }
     if (!x($_POST, 'qxz_password') || !strlen(trim($_POST['qxz_password']))) {
         return;
     }
     if (!x($_POST, 'verify') || !strlen(trim($_POST['verify']))) {
         return;
     }
     if ($_POST['verify'] !== $_SESSION['remove_account_verify']) {
         return;
     }
     $account = \App::get_account();
     $account_id = get_account_id();
     if (!account_verify_password($account['account_email'], $_POST['qxz_password'])) {
         return;
     }
     if ($account['account_password_changed'] != NULL_DATE) {
         $d1 = datetime_convert('UTC', 'UTC', 'now - 48 hours');
         if ($account['account_password_changed'] > d1) {
             notice(t('Account removals are not allowed within 48 hours of changing the account password.') . EOL);
             return;
         }
     }
     $global_remove = intval($_POST['global']);
     account_remove($account_id, 1 - $global_remove);
 }
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:32,代码来源:Removeaccount.php

示例8: find_diaspora_person_by_handle

function find_diaspora_person_by_handle($handle)
{
    $person = false;
    $refresh = false;
    if (diaspora_is_blacklisted($handle)) {
        return false;
    }
    $r = q("select * from xchan where xchan_addr = '%s' limit 1", dbesc($handle));
    if ($r) {
        $person = $r[0];
        logger('find_diaspora_person_by handle: in cache ' . print_r($r, true), LOGGER_DATA, LOG_DEBUG);
        if ($person['xchan_name_date'] < datetime_convert('UTC', 'UTC', 'now - 1 month')) {
            logger('Updating Diaspora cached record for ' . $handle);
            $refresh = true;
        }
    }
    if (!$person || $refresh) {
        // try webfinger. Make sure to distinguish between diaspora,
        // hubzilla w/diaspora protocol and friendica w/diaspora protocol.
        $result = discover_by_webbie($handle);
        if ($result) {
            $r = q("select * from xchan where xchan_addr = '%s' limit 1", dbesc(str_replace('acct:', '', $handle)));
            if ($r) {
                $person = $r[0];
                logger('find_diaspora_person_by handle: discovered ' . print_r($r, true), LOGGER_DATA, LOG_DEBUG);
            }
        }
    }
    return $person;
}
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:30,代码来源:util.php

示例9: testdrive_cron

function testdrive_cron($a, $b)
{
    $r = q("select * from account where account_expires_on < %s + INTERVAL %s and\n\t\taccount_expire_notified = '%s' ", db_utcnow(), db_quoteinterval('5 DAY'), dbesc(NULL_DATE));
    if ($r) {
        foreach ($r as $rr) {
            $uid = $rr['account_default_channel'];
            if (!$uid) {
                continue;
            }
            $x = q("select * from channel where channel_id = %d limit 1", intval($uid));
            if (!$x) {
                continue;
            }
            \Zotlabs\Lib\Enotify::submit(array('type' => NOTIFY_SYSTEM, 'system_type' => 'testdrive_expire', 'from_xchan' => $x[0]['channel_hash'], 'to_xchan' => $x[0]['channel_hash']));
            q("update account set account_expire_notified = '%s' where account_id = %d", dbesc(datetime_convert()), intval($rr['account_id']));
        }
    }
    // give them a 5 day grace period. Then nuke the account.
    $r = q("select * from account where account_expired = 1 and account_expires < %s - INTERVAL %s", db_utcnow(), db_quoteinterval('5 DAY'));
    if ($r) {
        foreach ($r as $rr) {
            account_remove($rr['account_id']);
        }
    }
}
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:25,代码来源:testdrive.php

示例10: q

 function q($sql)
 {
     if (!$this->db || !$this->connected) {
         return false;
     }
     $this->error = '';
     $result = @mysql_query($sql, $this->db);
     if (mysql_errno($this->db)) {
         $this->error = mysql_error($this->db);
     }
     if ($result === false || $this->error) {
         logger('dba_mysql: ' . printable($sql) . ' returned false.' . "\n" . $this->error);
         if (file_exists('dbfail.out')) {
             file_put_contents('dbfail.out', datetime_convert() . "\n" . printable($sql) . ' returned false' . "\n" . $this->error . "\n", FILE_APPEND);
         }
     }
     if ($result === true || $result === false) {
         return $result;
     }
     $r = array();
     if (mysql_num_rows($result)) {
         while ($x = mysql_fetch_array($result, MYSQL_ASSOC)) {
             $r[] = $x;
         }
         mysql_free_result($result);
         if ($this->debug) {
             logger('dba_mysql: ' . printable(print_r($r, true)));
         }
     }
     return $r;
 }
开发者ID:msooon,项目名称:hubzilla,代码行数:31,代码来源:dba_mysql.php

示例11: checksites_run

function checksites_run($argv, $argc)
{
    cli_startup();
    $a = get_app();
    logger('checksites: start');
    if ($argc > 1 && $argv[1]) {
        $site_id = $argv[1];
    }
    if ($site_id) {
        $sql_options = " and site_url = '" . dbesc($argv[1]) . "' ";
    }
    $days = intval(get_config('system', 'sitecheckdays'));
    if ($days < 1) {
        $days = 30;
    }
    $r = q("select * from site where site_dead = 0 and site_update < %s - INTERVAL %s and site_type = %d {$sql_options} ", db_utcnow(), db_quoteinterval($days . ' DAY'), intval(SITE_TYPE_ZOT));
    if (!$r) {
        return;
    }
    foreach ($r as $rr) {
        if (!strcasecmp($rr['site_url'], z_root())) {
            continue;
        }
        $x = ping_site($rr['site_url']);
        if ($x['success']) {
            logger('checksites: ' . $rr['site_url']);
            q("update site set site_update = '%s' where site_url = '%s' ", dbesc(datetime_convert()), dbesc($rr['site_url']));
        } else {
            logger('marking dead site: ' . $x['message']);
            q("update site set site_dead = 1 where site_url = '%s' ", dbesc($rr['site_url']));
        }
    }
    return;
}
开发者ID:TamirAl,项目名称:hubzilla,代码行数:34,代码来源:checksites.php

示例12: lock_function

 function lock_function($fn_name, $block = true, $wait_sec = 2, $timeout = 30)
 {
     if ($wait_sec == 0) {
         $wait_sec = 2;
     }
     // don't let the user pick a value that's likely to crash the system
     $got_lock = false;
     $start = time();
     do {
         q("LOCK TABLE `locks` WRITE");
         $r = q("SELECT `locked`, `created` FROM `locks` WHERE `name` = '%s' LIMIT 1", dbesc($fn_name));
         if (count($r) and (!$r[0]['locked'] or strtotime($r[0]['created']) < time() - 3600)) {
             q("UPDATE `locks` SET `locked` = 1, `created` = '%s' WHERE `name` = '%s'", dbesc(datetime_convert()), dbesc($fn_name));
             $got_lock = true;
         } elseif (!$r) {
             // the Boolean value for count($r) should be equivalent to the Boolean value of $r
             q("INSERT INTO `locks` (`name`, `created`, `locked`) VALUES ('%s', '%s', 1)", dbesc($fn_name), dbesc(datetime_convert()));
             $got_lock = true;
         }
         q("UNLOCK TABLES");
         if ($block && !$got_lock) {
             sleep($wait_sec);
         }
     } while ($block && !$got_lock && time() - $start < $timeout);
     logger('lock_function: function ' . $fn_name . ' with blocking = ' . $block . ' got_lock = ' . $got_lock . ' time = ' . (time() - $start), LOGGER_DEBUG);
     return $got_lock;
 }
开发者ID:ZerGabriel,项目名称:friendica,代码行数:27,代码来源:lock.php

示例13: p_init

function p_init(&$a)
{
    if (argc() < 2) {
        http_status_exit(401);
    }
    $mid = str_replace('.xml', '', argv(1));
    $r = q("select * from item where mid = '%s' and item_wall = 1 and item_private = 0 limit 1", dbesc($mid));
    if (!$r || !perm_is_allowed($r[0]['uid'], '', 'view_stream')) {
        http_status_exit(404);
    }
    $c = q("select * from channel where channel_id = %d limit 1", intval($r[0]['uid']));
    if (!$c) {
        http_status_exit(404);
    }
    $myaddr = $c[0]['channel_address'] . '@' . App::get_hostname();
    $item = $r[0];
    $title = $item['title'];
    $body = bb2diaspora_itembody($item);
    $created = datetime_convert('UTC', 'UTC', $item['created'], 'Y-m-d H:i:s \\U\\T\\C');
    $tpl = get_markup_template('diaspora_post.tpl', 'addon/diaspora');
    $msg = replace_macros($tpl, array('$body' => xmlify($body), '$guid' => $item['mid'], '$handle' => xmlify($myaddr), '$public' => 'true', '$created' => $created, '$provider' => $item['app'] ? $item['app'] : t('$projectname')));
    header('Content-type: text/xml');
    echo $msg;
    killme();
}
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:25,代码来源:p.php

示例14: clear

 public static function clear()
 {
     q("DELETE FROM `cache` WHERE `updated` < '%s' AND `expire_mode` = %d", dbesc(datetime_convert('UTC', 'UTC', "now - 30 days")), intval(CACHE_MONTH));
     q("DELETE FROM `cache` WHERE `updated` < '%s' AND `expire_mode` = %d", dbesc(datetime_convert('UTC', 'UTC', "now - 7 days")), intval(CACHE_WEEK));
     q("DELETE FROM `cache` WHERE `updated` < '%s' AND `expire_mode` = %d", dbesc(datetime_convert('UTC', 'UTC', "now - 1 days")), intval(CACHE_DAY));
     q("DELETE FROM `cache` WHERE `updated` < '%s' AND `expire_mode` = %d", dbesc(datetime_convert('UTC', 'UTC', "now - 1 hours")), intval(CACHE_HOUR));
 }
开发者ID:ZerGabriel,项目名称:friendica,代码行数:7,代码来源:cache.php

示例15: handle_pubsubhubbub

function handle_pubsubhubbub()
{
    global $a, $db;
    logger('start');
    // We'll push to each subscriber that has push > 0,
    // i.e. there has been an update (set in notifier.php).
    $r = q("SELECT * FROM `push_subscriber` WHERE `push` > 0");
    foreach ($r as $rr) {
        $params = get_feed_for($a, '', $rr['nickname'], $rr['last_update'], 0, true);
        $hmac_sig = hash_hmac("sha1", $params, $rr['secret']);
        $headers = array("Content-type: application/atom+xml", sprintf("Link: <%s>;rel=hub," . "<%s>;rel=self", $a->get_baseurl() . '/pubsubhubbub', $rr['topic']), "X-Hub-Signature: sha1=" . $hmac_sig);
        logger('POST ' . print_r($headers, true) . "\n" . $params, LOGGER_DEBUG);
        post_url($rr['callback_url'], $params, $headers);
        $ret = $a->get_curl_code();
        if ($ret >= 200 && $ret <= 299) {
            logger('successfully pushed to ' . $rr['callback_url']);
            // set last_update to "now", and reset push=0
            $date_now = datetime_convert('UTC', 'UTC', 'now', 'Y-m-d H:i:s');
            q("UPDATE `push_subscriber` SET `push` = 0, last_update = '%s' WHERE id = %d", dbesc($date_now), intval($rr['id']));
        } else {
            logger('error when pushing to ' . $rr['callback_url'] . ' HTTP: ' . $ret);
            // we use the push variable also as a counter, if we failed we
            // increment this until some upper limit where we give up
            $new_push = intval($rr['push']) + 1;
            if ($new_push > 30) {
                // OK, let's give up
                $new_push = 0;
            }
            q("UPDATE `push_subscriber` SET `push` = %d WHERE id = %d", $new_push, intval($rr['id']));
        }
    }
    logger('done');
}
开发者ID:ZerGabriel,项目名称:friendica,代码行数:33,代码来源:pubsubpublish.php


注:本文中的datetime_convert函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。