本文整理汇总了PHP中wfTimestamp函数的典型用法代码示例。如果您正苦于以下问题:PHP wfTimestamp函数的具体用法?PHP wfTimestamp怎么用?PHP wfTimestamp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wfTimestamp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: recordUpload2
/**
* Record a file upload in the upload log and the image table
*/
function recordUpload2($oldver, $comment, $pageText, $props = false, $timestamp = false, $user = null)
{
if (is_null($user)) {
global $wgUser;
$user = $wgUser;
}
$dbw = $this->repo->getMasterDB();
$dbw->begin();
if (!$props) {
$props = $this->repo->getFileProps($this->getVirtualUrl());
}
$props['description'] = $comment;
$props['user'] = $user->getId();
$props['user_text'] = $user->getName();
$props['timestamp'] = wfTimestamp(TS_MW);
$this->setProps($props);
// Delete thumbnails and refresh the metadata cache
$this->purgeThumbnails();
$this->saveToCache();
SquidUpdate::purge(array($this->getURL()));
/* Wikia change begin - @author: Marooned, see RT#44185 */
global $wgLogo;
if ($this->url == $wgLogo) {
SquidUpdate::purge(array($this->url));
}
/* Wikia change end */
// Fail now if the file isn't there
if (!$this->fileExists) {
wfDebug(__METHOD__ . ": File " . $this->getPath() . " went missing!\n");
return false;
}
$reupload = false;
if ($timestamp === false) {
$timestamp = $dbw->timestamp();
}
# Test to see if the row exists using INSERT IGNORE
# This avoids race conditions by locking the row until the commit, and also
# doesn't deadlock. SELECT FOR UPDATE causes a deadlock for every race condition.
$dbw->insert('image', array('img_name' => $this->getName(), 'img_size' => $this->size, 'img_width' => intval($this->width), 'img_height' => intval($this->height), 'img_bits' => $this->bits, 'img_media_type' => $this->media_type, 'img_major_mime' => $this->major_mime, 'img_minor_mime' => $this->minor_mime, 'img_timestamp' => $timestamp, 'img_description' => $comment, 'img_user' => $user->getId(), 'img_user_text' => $user->getName(), 'img_metadata' => $this->metadata, 'img_sha1' => $this->sha1), __METHOD__, 'IGNORE');
if ($dbw->affectedRows() == 0) {
$reupload = true;
# Collision, this is an update of a file
# Insert previous contents into oldimage
$dbw->insertSelect('oldimage', 'image', array('oi_name' => 'img_name', 'oi_archive_name' => $dbw->addQuotes($oldver), 'oi_size' => 'img_size', 'oi_width' => 'img_width', 'oi_height' => 'img_height', 'oi_bits' => 'img_bits', 'oi_timestamp' => 'img_timestamp', 'oi_description' => 'img_description', 'oi_user' => 'img_user', 'oi_user_text' => 'img_user_text', 'oi_metadata' => 'img_metadata', 'oi_media_type' => 'img_media_type', 'oi_major_mime' => 'img_major_mime', 'oi_minor_mime' => 'img_minor_mime', 'oi_sha1' => 'img_sha1'), array('img_name' => $this->getName()), __METHOD__);
# Update the current image row
$dbw->update('image', array('img_size' => $this->size, 'img_width' => intval($this->width), 'img_height' => intval($this->height), 'img_bits' => $this->bits, 'img_media_type' => $this->media_type, 'img_major_mime' => $this->major_mime, 'img_minor_mime' => $this->minor_mime, 'img_timestamp' => $timestamp, 'img_description' => $comment, 'img_user' => $user->getId(), 'img_user_text' => $user->getName(), 'img_metadata' => $this->metadata, 'img_sha1' => $this->sha1), array('img_name' => $this->getName()), __METHOD__);
} else {
# This is a new file
# Update the image count
$site_stats = $dbw->tableName('site_stats');
$dbw->query("UPDATE {$site_stats} SET ss_images=ss_images+1", __METHOD__);
}
# Commit the transaction now, in case something goes wrong later
# The most important thing is that files don't get lost, especially archives
$dbw->commit();
# Invalidate cache for all pages using this file
$update = new HTMLCacheUpdate($this->getTitle(), 'imagelinks');
$update->doUpdate();
return true;
}
示例2: parserGetVariable
/**
* Function check if user is blocked, return true
* user blocked status is passed to $ret
* @param $parser Parser
* @param $varCache ??
* @param $index ??
* @param $ret string?
* @return bool
*/
public static function parserGetVariable(&$parser, &$varCache, &$index, &$ret)
{
if ($index != 'USERBLOCKED') {
return true;
}
$title = $parser->getTitle();
if ($title->getNamespace() != NS_USER && $title->getNamespace() != NS_USER_TALK) {
$ret = 'unknown';
return true;
}
$user = User::newFromName($title->getBaseText());
if ($user instanceof User) {
if (!$user->isBlocked()) {
$ret = 'false';
return true;
}
// if user is blocked it's pretty much possible they will be unblocked one day :)
// so we enable cache for shorter time only so that we can recheck later
// if they weren't already unblocked - if there is a better way to do that, fix me
$expiry = $user->getBlock()->mExpiry;
if (is_numeric($expiry)) {
// sometimes this is 'infinityinfinity'. in that case, use the default cache expiry time.
$expiry = wfTimestamp(TS_UNIX, $expiry) - wfTimestamp(TS_UNIX);
if ($expiry > 0) {
// just to make sure
$parser->getOutput()->updateCacheExpiry($expiry);
}
}
$ret = 'true';
return true;
}
$ret = 'unknown';
return true;
}
示例3: addDBData
function addDBData()
{
$user = User::newFromName('UTBlockee');
if ($user->getID() == 0) {
$user->addToDatabase();
$user->setPassword('UTBlockeePassword');
$user->saveSettings();
}
// Delete the last round's block if it's still there
$oldBlock = Block::newFromTarget('UTBlockee');
if ($oldBlock) {
// An old block will prevent our new one from saving.
$oldBlock->delete();
}
$this->block = new Block('UTBlockee', $user->getID(), 0, 'Parce que', 0, false, time() + 100500);
$this->madeAt = wfTimestamp(TS_MW);
$this->block->insert();
// save up ID for use in assertion. Since ID is an autoincrement,
// its value might change depending on the order the tests are run.
// ApiBlockTest insert its own blocks!
$newBlockId = $this->block->getId();
if ($newBlockId) {
$this->blockId = $newBlockId;
} else {
throw new MWException("Failed to insert block for BlockTest; old leftover block remaining?");
}
$this->addXffBlocks();
}
示例4: onArticleViewHeader
public static function onArticleViewHeader(&$article)
{
global $wgOut, $wgLang;
if ($article->mTitle->getNamespace() == NS_DELETION) {
$dqi = DeleteQueueItem::newFromDiscussion($article);
if (!$dqi->isQueued()) {
break;
}
$wgOut->addWikiMsg('deletequeue-deletediscuss-discussionpage', $dqi->getArticle()->mTitle->getPrefixedText(), count($dqi->getEndorsements()), count($dqi->getObjections()));
}
$dqi = DeleteQueueItem::newFromArticle($article);
if (!($queue = $dqi->getQueue())) {
return true;
}
$options = array("deletequeue-page-{$queue}");
$options[] = $dqi->getReason();
$expiry = wfTimestamp(TS_UNIX, $dqi->getExpiry());
$options[] = $wgLang->timeanddate($expiry);
$options[] = $wgLang->date($expiry);
$options[] = $wgLang->time($expiry);
if ($queue == 'deletediscuss') {
$options[] = $dqi->getDiscussionPage()->mTitle->getPrefixedText();
}
call_user_func_array(array($wgOut, 'addWikiMsg'), $options);
return true;
}
示例5: doLogChangeBatch
/**
* @see FileJournal::logChangeBatch()
* @return Status
*/
protected function doLogChangeBatch(array $entries, $batchId)
{
$status = Status::newGood();
try {
$dbw = $this->getMasterDB();
} catch (DBError $e) {
$status->fatal('filejournal-fail-dbconnect', $this->backend);
return $status;
}
$now = wfTimestamp(TS_UNIX);
$data = array();
foreach ($entries as $entry) {
$data[] = array('fj_batch_uuid' => $batchId, 'fj_backend' => $this->backend, 'fj_op' => $entry['op'], 'fj_path' => $entry['path'], 'fj_new_sha1' => $entry['newSha1'], 'fj_timestamp' => $dbw->timestamp($now));
}
try {
$dbw->insert('filejournal', $data, __METHOD__);
if (mt_rand(0, 99) == 0) {
$this->purgeOldLogs();
// occasionally delete old logs
}
} catch (DBError $e) {
$status->fatal('filejournal-fail-dbquery', $this->backend);
return $status;
}
return $status;
}
示例6: execute
public function execute()
{
$params = $this->extractRequestParams();
$strquery = $params['strquery'];
$result = $this->getResult();
if (isset($strquery) && $strquery != NULL) {
$searchString = str_replace('%', '\\%', $strquery);
$searchString = str_replace('_', '\\_', $searchString);
$searchString = str_replace('|', '%', $searchString);
$dbr = $this->getDB();
$suggestStrings = array();
$this->addTables('categorylinks');
$this->addFields('DISTINCT cl_to');
$this->addWhere(" UPPER(CONVERT(cl_to using latin1)) LIKE UPPER(CONVERT('{$searchString}%' using latin1)) ");
$res = $this->select(__METHOD__);
while ($row = $res->fetchObject()) {
array_push($suggestStrings, $row->cl_to);
$fit = $result->addValue(array('query', $this->getModuleName()), null, $row->cl_to);
if (!$fit) {
$this->setContinueEnumParameter('start', wfTimestamp(TS_ISO_8601, $row->afl_timestamp));
break;
}
}
$dbr->freeResult($res);
}
$result->setIndexedTagName_internal(array('query', $this->getModuleName()), 'category');
}
示例7: getArticleRequestTop
function getArticleRequestTop()
{
global $wgTitle, $wgArticle, $wgRequest, $wgUser;
$s = "";
$sk = $wgUser->getSkin();
$action = $wgRequest->getVal("action");
if ($wgTitle->getNamespace() == NS_ARTICLE_REQUEST && $action == "" && $wgTitle->getArticleID() > 0) {
$askedBy = $wgArticle->getUserText();
$authors = $wgArticle->getContributors(1);
//$askedBy = "hi" . $authors[0][0];
//$id = $wgArticle->getUser();
$real_name = User::whoIsReal($authors[0][0]);
if ($real_name != "") {
$askedBy = $real_name;
} else {
if ($authors[0][0] == 0) {
$askedBy = wfMsg('user_anonymous');
} else {
$askedBy = $authors[0][1];
}
}
$dateAsked = date("F d, Y", wfTimestamp(TS_UNIX, $wgArticle->getTimestamp()));
$s .= "<div class=\"article_inner\"><table>\n\t\t\t<tr>\n\t\t\t<td width=\"20%\" valign=\"top\">" . wfMsg('request') . "</td><td><b>" . wfMsg('howto', $wgTitle->getText()) . "</b></td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t<td>" . wfMsg('askedby') . "</td><td>" . $askedBy . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t<td>" . wfMsg('date') . ":</td>\n\t\t\t\t<td>" . $dateAsked . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t<td valign=\"middle\">" . wfMsg('details') . "</td>\n\t\t\t\t<td><b>\t";
}
return $s;
}
示例8: sendConfirmAndMigrateMail
/**
* Generate a new e-mail confirmation token and send a confirmation/invalidation
* mail to the user's given address.
*
* @return Status object
*/
public function sendConfirmAndMigrateMail()
{
global $wgLang;
$tokenLife = 14 * 24 * 60 * 60;
// 14 days
$expiration = null;
// gets passed-by-ref and defined in next line.
$token = $this->confirmationToken($expiration);
// we want this token to last a little bit longer since we are cold-emailing
// users and we really want as many responses as possible
$now = time();
$expires = $now + $tokenLife;
$expiration = wfTimestamp(TS_MW, $expires);
$this->mEmailTokenExpires = $expiration;
if ($this->isEmailConfirmed()) {
// Hack to bypass localization of 'Special:'
// @see User::getTokenUrl
$mergeAccountUrl = Title::makeTitle(NS_MAIN, 'Special:MergeAccount')->getCanonicalURL();
} else {
// create a "token url" for MergeAccount since we have added email
// confirmation there
$mergeAccountUrl = $this->getTokenUrl('MergeAccount', $token);
}
$invalidateURL = $this->invalidationTokenUrl($token);
$this->saveSettings();
return $this->sendMail(wfMessage('centralauth-finishglobaliseemail_subject')->text(), wfMessage("centralauth-finishglobaliseemail_body", $this->getRequest()->getIP(), $this->getName(), $mergeAccountUrl, $wgLang->timeanddate($expiration, false), $invalidateURL, $wgLang->date($expiration, false), $wgLang->time($expiration, false))->text());
}
示例9: getCoordinator
private function getCoordinator()
{
$clientWikis = array('dewiki' => 'dewikidb', 'enwiki' => 'enwikidb', 'nlwiki' => 'nlwikidb', 'ruwiki' => 'ruwikidb', 'zhwiki' => 'zhwikidb');
$coordinator = new SqlChangeDispatchCoordinator(false, $clientWikis);
$coordinator->setBatchSize(3);
$coordinator->setRandomness(3);
$coordinator->setLockGraceInterval(120);
$coordinator->setDispatchInterval(60);
$coordinator->setArrayRandOverride(function ($array) {
$keys = array_keys($array);
$last = end($keys);
return $last;
});
$coordinator->setTimeOverride(function () {
return wfTimestamp(TS_UNIX, '20140303000000');
});
$coordinator->setIsClientLockUsedOverride(function ($wikiDB, $lockName) {
return $wikiDB === 'zhwikidb';
});
$coordinator->setEngageClientLockOverride(function ($wikiDB) {
return $wikiDB !== 'zhwikidb';
});
$coordinator->setReleaseClientLockOverride(function ($wikiDB) {
return true;
});
return $coordinator;
}
示例10: execute
public function execute()
{
global $wgDBname;
if ($this->hasOption('days')) {
$inactivitydays = $this->getOption('days');
} else {
$inactivitydays = 30;
}
if ($this->hasOption('timezone')) {
$timezone = $this->getOption('timezone');
} else {
$timezone = 'UTC';
}
# Generates a timestamp in yearmonthdayhourminutesecond format of the current time
date_default_timezone_set($timezone);
$date = date("YmdHis", strtotime("-{$inactivitydays} days"));
$dbw = wfGetDB(DB_MASTER);
$res = $dbw->select('recentchanges', 'rc_timestamp', 'rc_timestamp >= ' . $dbw->addQuotes($date), __METHOD__, array('ORDER BY' => 'rc_timestamp DESC', 'LIMIT' => 1));
if ($res->numRows() > 0) {
if ($this->hasOption('display-active')) {
foreach ($res as $row) {
$this->output("The wiki \"{$wgDBname}\" does NOT meet the inactivity requirements, date of last RecentChanges log entry: " . wfTimestamp(TS_DB, $row->rc_timestamp) . "\n");
}
}
} else {
$res = $dbw->select('recentchanges', 'rc_timestamp', 'rc_timestamp < ' . $dbw->addQuotes($date), __METHOD__, array('ORDER BY' => 'rc_timestamp DESC', 'LIMIT' => 1));
foreach ($res as $row) {
$this->output("The wiki \"{$wgDBname}\" DOES meet the inactivity requirements, date of last RecentChanges log entry: " . wfTimeStamp(TS_DB, $row->rc_timestamp) . "\n");
}
}
}
示例11: execute
public function execute()
{
$params = $this->extractRequestParams();
$result = $this->getResult();
$userName = $params['user'];
$daysago = $params['daysago'];
$basetimestamp = $params['basetimestamp'];
$user = User::newFromName($userName);
if (!$user) {
$this->dieUsage('Invalid username', 'bad_user');
}
global $wgAuth, $wgUserDailyContributionsApiCheckAuthPlugin;
if ($wgUserDailyContributionsApiCheckAuthPlugin && !$wgAuth->userExists($userName)) {
$this->dieUsage('Specified user does not exist', 'bad_user');
}
// Defaults to 'now' if not given
$totime = wfTimestamp(TS_UNIX, $basetimestamp);
$fromtime = $totime - $daysago * 60 * 60 * 24;
$result->addValue($this->getModuleName(), 'id', $user->getId());
// Returns date of registration in YYYYMMDDHHMMSS format
$result->addValue($this->getModuleName(), 'registration', $user->getRegistration() ? $user->getRegistration() : '0');
// Returns number of edits between daysago date and basetimestamp (or today)
$result->addValue($this->getModuleName(), 'timeFrameEdits', getUserEditCountSince($fromtime, $user, $totime));
// Returns total number of edits
$result->addValue($this->getModuleName(), 'totalEdits', $user->getEditCount() == NULL ? 0 : $user->getEditCount());
}
示例12: displayRecentChanges
static function displayRecentChanges()
{
$html = '';
$html .= '<table width="100%">';
$changes = CustomTitleChangesLog::dbGetRecentChanges(10);
$html .= "<tr><th>When</th><th>User</th><th>Summary</th></tr>\n";
$users = array();
foreach ($changes as $change) {
$html .= '<tr>';
$ts = wfTimestamp(TS_UNIX, $change['tcc_timestamp']);
$html .= "<td>" . date('Y-m-d', $ts) . "</td>";
$userid = $change['tcc_userid'];
if (!isset($users[$userid])) {
$users[$userid] = User::newFromId($userid);
}
$user = $users[$userid];
$usertext = $user ? $user->getName() : '';
$html .= "<td>{$usertext}</td>";
$summary = substr($change['tcc_summary'], 0, 200);
if ($summary != $change['tcc_summary']) {
$summary .= '...';
}
$html .= "<td>{$summary}</td>";
$html .= "</tr>\n";
}
$html .= '</table>';
return $html;
}
示例13: execute
public function execute()
{
global $wgContLang;
$pageSet = $this->getPageSet();
$pageids = array_keys($pageSet->getGoodTitles());
if (!$pageids) {
return true;
}
// Construct SQL Query
$this->addTables('flaggedpages');
$this->addFields(array('fp_page_id', 'fp_stable', 'fp_quality', 'fp_pending_since'));
$this->addWhereFld('fp_page_id', $pageids);
$res = $this->select(__METHOD__);
$result = $this->getResult();
foreach ($res as $row) {
$data = array('stable_revid' => intval($row->fp_stable), 'level' => intval($row->fp_quality), 'level_text' => FlaggedRevs::getQualityLevelText($row->fp_quality));
if ($row->fp_pending_since) {
$data['pending_since'] = wfTimestamp(TS_ISO_8601, $row->fp_pending_since);
}
$result->addValue(array('query', 'pages', $row->fp_page_id), 'flagged', $data);
}
$this->resetQueryParams();
$this->addTables('flaggedpage_config');
$this->addFields(array('fpc_page_id', 'fpc_level', 'fpc_expiry'));
$this->addWhereFld('fpc_page_id', $pageids);
foreach ($this->select(__METHOD__) as $row) {
$result->addValue(array('query', 'pages', $row->fpc_page_id, 'flagged'), 'protection_level', $row->fpc_level);
$result->addValue(array('query', 'pages', $row->fpc_page_id, 'flagged'), 'protection_expiry', $wgContLang->formatExpiry($row->fpc_expiry, TS_ISO_8601));
}
return true;
}
示例14: execute
public function execute()
{
global $wgUser;
$result = $this->getResult();
$params = $this->extractRequestParams();
$token = array();
if ($wgUser->isAnon()) {
if (!isset($params['anontoken'])) {
$this->dieUsageMsg(array('missingparam', 'anontoken'));
} elseif (strlen($params['anontoken']) != 32) {
$this->dieUsage('The anontoken is not 32 characters', 'invalidtoken');
}
$token = $params['anontoken'];
} else {
$token = '';
}
$dbr = wfGetDB(DB_SLAVE);
$dbw = wfGetDB(DB_MASTER);
// Check if the incoming survey is valid
$surveyCount = $dbr->selectRow('research_tools_surveys', 'rts_id', array('rts_id' => $params['survey']), __METHOD__);
if ($surveyCount === false) {
$this->dieUsage('The survey is unknown', 'invalidsurvey');
}
// Find an existing response from this user for this survey
$response = $dbr->selectRow('research_tools_survey_responses', 'rtsr_id', array('rtsr_user_text' => $wgUser->getName(), 'rtsr_user_anon_token' => $token, 'rtsr_survey' => $params['survey']), __METHOD__);
if ($response !== false) {
// Delete any of the previous answers (they questions may have changed)
$dbw->delete('research_tools_survey_answers', array('rtsa_response' => $response->rtsr_id), __METHOD__);
}
// Decode JSON answer data
$answers = FormatJson::decode($params['answers'], true);
if (!is_array($answers)) {
$this->dieUsage('Invalid answer data', 'invalidanswers');
}
// Verify questions exist
foreach ($answers as $question => $answer) {
$question = $dbr->selectRow('research_tools_survey_questions', 'rtsq_id', array('rtsq_survey' => $params['survey'], 'rtsq_id' => $question), __METHOD__);
if ($question === false) {
$this->dieUsage('A question is unknown', 'invalidquestion');
}
}
if ($response === false) {
// Insert a new response row
$dbw->insert('research_tools_survey_responses', array('rtsr_time' => wfTimestamp(TS_MW), 'rtsr_user_text' => $wgUser->getName(), 'rtsr_user_anon_token' => $token, 'rtsr_survey' => $params['survey']), __METHOD__);
$response = $dbw->insertId();
} else {
$response = $response->rtsr_id;
// Update the timestamp of the existing response row
$dbw->update('research_tools_survey_responses', array('rtsr_time' => wfTimestamp(TS_MW)), array('rtsr_id' => $response), __METHOD__);
}
// Insert answers for the response
$answerRows = array();
foreach ($answers as $question => $answer) {
// Build row data
$answerRows[] = array('rtsa_response' => $response, 'rtsa_question' => $question, 'rtsa_value_integer' => is_numeric($answer) ? intval($answer) : null, 'rtsa_value_text' => is_numeric($answer) ? '' : $answer);
}
$dbw->insert('research_tools_survey_answers', $answerRows, __METHOD__);
// Add success to result
$result->addValue(null, $this->getModuleName(), array('result' => 'Success'));
}
示例15: listFilesFlat
private static function listFilesFlat($base_path)
{
#static $count=0;
$results = array();
foreach (new DirectoryIterator($base_path) as $fileinfo) {
#$count++;if ($count>1000) break;
if ($fileinfo->isDot()) {
continue;
} elseif ($fileinfo->isDir()) {
$new_results = self::listFilesFlat($fileinfo->getPathname());
$results = array_merge($results, $new_results);
} else {
$path = $fileinfo->getPathname();
// a hack for filenames that have / in them
$fn = preg_replace('@^/var/www/images_en/./../@', '', $path);
$hash = md5($fn);
if (isset($results[$hash])) {
print "error: dup hash for {$fn}\n";
} else {
$results[$hash] = array('path' => $path, 'file' => $fn, 'size' => $fileinfo->getSize(), 'time' => wfTimestamp(TS_MW, $fileinfo->getMTime()));
}
}
}
return $results;
}