function PageArchive(&$title)
 {
     if (is_null($title)) {
         wfDebugDieBacktrace('Archiver() given a null title.');
     }
     $this->title =& $title;
 }
Example #2
0
/**
 * @return string
 */
function oaiDatestamp($timestamp, $granularity = 'YYYY-MM-DDThh:mm:ssZ')
{
    $formats = array('YYYY-MM-DD' => '$1-$2-$3', 'YYYY-MM-DDThh:mm:ssZ' => '$1-$2-$3T$4:$5:$6Z');
    if (!isset($formats[$granularity])) {
        wfDebugDieBacktrace('oaiFormatDate given illegal output format');
    }
    return preg_replace('/^(....)(..)(..)(..)(..)(..)$/', $formats[$granularity], wfTimestamp(TS_MW, $timestamp));
}
Example #3
0
 /**
 * Initialization of ... everything
 @return Article either the object to become $wgArticle, or NULL
 */
 function initialize(&$title, &$output, &$user, $request)
 {
     wfProfileIn('MediaWiki::initialize');
     $this->preliminaryChecks($title, $output, $request);
     $article = NULL;
     if (!$this->initializeSpecialCases($title, $output, $request)) {
         $article = $this->initializeArticle($title, $request);
         if (is_object($article)) {
             $this->performAction($output, $article, $title, $user, $request);
         } elseif (is_string($article)) {
             $output->redirect($article);
         } else {
             wfDebugDieBacktrace("Shouldn't happen: MediaWiki::initializeArticle() returned neither an object nor a URL");
         }
     }
     wfProfileOut('MediaWiki::initialize');
     return $article;
 }
 function processLoginRequest($user, $pass)
 {
     global $wgUser, $wgRequest;
     $userlogin = new LoginForm($wgRequest);
     $userlogin->mName = $user;
     $userlogin->mPassword = $pass;
     //$auth = $userlogin->authenticateUserData();
     //$r= new AjaxResponse($auth);
     //return $r;
     $msg = '';
     switch ($userlogin->authenticateUserData()) {
         case LoginForm::SUCCESS:
             $wgUser->setCookies();
             $msg = wfMsgWikiHtml('loginsuccess', $wgUser->getName());
             break;
         case LoginForm::NO_NAME:
         case LoginForm::ILLEGAL:
             $msg = wfMsgWikiHtml('noname');
             break;
         case LoginForm::WRONG_PLUGIN_PASS:
             $msg = wfMsgWikiHtml('wrongpassword');
             break;
         case LoginForm::NOT_EXISTS:
             $msg = wfMsgWikiHtml('nosuchuser', htmlspecialchars($user));
             break;
         case LoginForm::WRONG_PASS:
             $msg = wfMsgWikiHtml('wrongpassword');
             break;
         case LoginForm::EMPTY_PASS:
             $msg = wfMsgWikiHtml('wrongpasswordempty');
             break;
         case LoginForm::RESET_PASS:
             $msg = wfMsgWikiHtml('resetpass_announce');
             break;
         default:
             wfDebugDieBacktrace("Unhandled case value");
     }
     return new AjaxResponse('<div class="pBody">' . $msg . '</div>');
 }
 /**
  * Equivalent of wfCreateObject
  */
 function extCreateObject($name, $p)
 {
     $p = array_values($p);
     switch (count($p)) {
         case 0:
             return new $name();
         case 1:
             return new $name($p[0]);
         case 2:
             return new $name($p[0], $p[1]);
         case 3:
             return new $name($p[0], $p[1], $p[2]);
         case 4:
             return new $name($p[0], $p[1], $p[2], $p[3]);
         case 5:
             return new $name($p[0], $p[1], $p[2], $p[3], $p[4]);
         case 6:
             return new $name($p[0], $p[1], $p[2], $p[3], $p[4], $p[5]);
         default:
             wfDebugDieBacktrace("Too many arguments to constructor in extCreateObject");
     }
 }
Example #6
0
 function error()
 {
     wfDebugDieBacktrace("Attempt to call member function of FakeTitle\n");
 }
 static function HTCPPurge($urlArr)
 {
     global $wgHTCPMulticastAddress, $wgHTCPMulticastTTL, $wgHTCPPort;
     $fname = 'SquidUpdate::HTCPPurge';
     wfProfileIn($fname);
     $htcpOpCLR = 4;
     // HTCP CLR
     // FIXME PHP doesn't support these socket constants (include/linux/in.h)
     if (!defined("IPPROTO_IP")) {
         define("IPPROTO_IP", 0);
         define("IP_MULTICAST_LOOP", 34);
         define("IP_MULTICAST_TTL", 33);
     }
     // pfsockopen doesn't work because we need set_sock_opt
     $conn = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
     if ($conn) {
         // Set socket options
         socket_set_option($conn, IPPROTO_IP, IP_MULTICAST_LOOP, 0);
         if ($wgHTCPMulticastTTL != 1) {
             socket_set_option($conn, IPPROTO_IP, IP_MULTICAST_TTL, $wgHTCPMulticastTTL);
         }
         foreach ($urlArr as $url) {
             if (!is_string($url)) {
                 wfDebugDieBacktrace('Bad purge URL');
             }
             $url = SquidUpdate::expand($url);
             // Construct a minimal HTCP request diagram
             // as per RFC 2756
             // Opcode 'CLR', no response desired, no auth
             $htcpTransID = rand();
             $htcpSpecifier = pack('na4na*na8n', 4, 'HEAD', strlen($url), $url, 8, 'HTTP/1.0', 0);
             $htcpDataLen = 8 + 2 + strlen($htcpSpecifier);
             $htcpLen = 4 + $htcpDataLen + 2;
             // Note! Squid gets the bit order of the first
             // word wrong, wrt the RFC. Apparently no other
             // implementation exists, so adapt to Squid
             $htcpPacket = pack('nxxnCxNxxa*n', $htcpLen, $htcpDataLen, $htcpOpCLR, $htcpTransID, $htcpSpecifier, 2);
             // Send out
             wfDebug("Purging URL {$url} via HTCP\n");
             socket_sendto($conn, $htcpPacket, $htcpLen, 0, $wgHTCPMulticastAddress, $wgHTCPPort);
         }
     } else {
         $errstr = socket_strerror(socket_last_error());
         wfDebug("SquidUpdate::HTCPPurge(): Error opening UDP socket: {$errstr}\n");
     }
     wfProfileOut($fname);
 }
 /**
  * DELETE query wrapper
  *
  * Use $conds == "*" to delete all rows
  */
 function delete($table, $conds, $fname = 'Database::delete')
 {
     if (!$conds) {
         wfDebugDieBacktrace('Database::delete() called with no conditions');
     }
     $table = $this->tableName($table);
     $sql = "DELETE FROM {$table}";
     if ($conds != '*') {
         $sql .= ' WHERE ' . $this->makeList($conds, LIST_AND);
     }
     return $this->query($sql, $fname);
 }
Example #9
0
 /**
  * @param $s string
  * @return string
  */
 function checkTitleEncoding($s)
 {
     if (is_array($s)) {
         wfDebugDieBacktrace('Given array to checkTitleEncoding.');
     }
     # Check for non-UTF-8 URLs
     $ishigh = preg_match('/[\\x80-\\xff]/', $s);
     if (!$ishigh) {
         return $s;
     }
     $isutf8 = preg_match('/^([\\x00-\\x7f]|[\\xc0-\\xdf][\\x80-\\xbf]|' . '[\\xe0-\\xef][\\x80-\\xbf]{2}|[\\xf0-\\xf7][\\x80-\\xbf]{3})+$/', $s);
     if ($isutf8) {
         return $s;
     }
     return $this->iconv($this->fallback8bitEncoding(), 'utf-8', $s);
 }
 /**
  * @param $s string
  * @return string
  */
 function checkTitleEncoding($s)
 {
     if (is_array($s)) {
         wfDebugDieBacktrace('Given array to checkTitleEncoding.');
     }
     if (StringUtils::isUtf8($s)) {
         return $s;
     }
     return $this->iconv($this->fallback8bitEncoding(), 'utf-8', $s);
 }
Example #11
0
 function checkDBSchema(&$db)
 {
     # img_name must be unique
     if (!$db->indexUnique('image', 'img_name') && !$db->indexExists('image', 'PRIMARY')) {
         wfDebugDieBacktrace('Database schema not up to date, please run maintenance/archives/patch-image_name_unique.sql');
     }
     #new fields must exist
     if (!$db->fieldExists('image', 'img_media_type') || !$db->fieldExists('image', 'img_metadata') || !$db->fieldExists('image', 'img_width')) {
         wfDebugDieBacktrace('Database schema not up to date, please run maintenance/update.php');
     }
 }
Example #12
0
 function processLogin()
 {
     global $wgUser, $wgAuth;
     switch ($this->authenticateUserData()) {
         case self::SUCCESS:
             # We've verified now, update the real record
             if ((bool) $this->mRemember != (bool) $wgUser->getOption('rememberpassword')) {
                 $wgUser->setOption('rememberpassword', $this->mRemember ? 1 : 0);
                 $wgUser->saveSettings();
             } else {
                 $wgUser->invalidateCache();
             }
             $wgUser->setCookies();
             if ($this->hasSessionCookie()) {
                 if ($this->mAutoRedirect != "") {
                     $title = Title::newFromText(urldecode($this->mAutoRedirect));
                     if ($title && is_object($title) && ($this->mFromSite || $this->shouldFollow($title))) {
                         return $this->successfulLogin($title->getLocalURL(), true, true);
                     }
                 }
                 return $this->successfulLogin(wfMsg('loginsuccess_owl', $wgUser->getName()));
             } else {
                 return $this->cookieRedirectCheck('login');
             }
             break;
         case self::NO_NAME:
         case self::ILLEGAL:
             $this->mainLoginForm(wfMsg('noname'), 'error_username');
             break;
         case self::WRONG_PLUGIN_PASS:
             $this->mainLoginForm(wfMsg('wrongpassword'), 'error_password');
             break;
         case self::NOT_EXISTS:
             if ($wgUser->isAllowed('createaccount')) {
                 $this->mainLoginForm(wfMsg('nosuchuser', htmlspecialchars($this->mName)), 'error_username');
             } else {
                 $this->mainLoginForm(wfMsg('nosuchusershort', htmlspecialchars($this->mName)), 'error_username');
             }
             break;
             // XXADDED
         // XXADDED
         case self::NO_EMAIL:
             $this->mainLoginForm(wfMsg('noemail_login'), 'error_username');
             break;
         case self::MULTIPLE_EMAILS:
             $this->mainLoginForm(wfMsg('multipleemails_login'), 'error_username');
             break;
         case self::WRONG_PASS:
             $this->mainLoginForm(wfMsg('wrongpassword'), 'error_password');
             break;
         case self::EMPTY_PASS:
             $this->mainLoginForm(wfMsg('wrongpasswordempty'), 'error_password');
             break;
         case self::RESET_PASS:
             $this->resetLoginForm(wfMsg('resetpass_announce'), 'error_password');
             break;
         default:
             wfDebugDieBacktrace("Unhandled case value");
     }
 }
Example #13
0
 /**
  * Pick the appropriate attribute value from a match set from the
  * MW_ATTRIBS_REGEX matches.
  *
  * @param array $set
  * @return string
  * @access private
  */
 function getTagAttributeCallback($set)
 {
     if (isset($set[6])) {
         # Illegal #XXXXXX color with no quotes.
         return $set[6];
     } elseif (isset($set[5])) {
         # No quotes.
         return $set[5];
     } elseif (isset($set[4])) {
         # Single-quoted
         return $set[4];
     } elseif (isset($set[3])) {
         # Double-quoted
         return $set[3];
     } elseif (!isset($set[2])) {
         # In XHTML, attributes must have a value.
         # For 'reduced' form, return explicitly the attribute name here.
         return $set[1];
     } else {
         wfDebugDieBacktrace("Tag conditions not met. This should never happen and is a bug.");
     }
 }
Example #14
0
 /** Delete a group */
 function delete()
 {
     global $wgMemc;
     if (Group::getStaticGroups()) {
         wfDebugDieBacktrace("Can't modify groups in static mode");
     }
     if ($this->id == 0) {
         return;
     }
     $fname = 'Group::delete';
     $dbw =& wfGetDB(DB_MASTER);
     // First remove all users from the group
     $dbw->delete('user_group', array('ug_group' => $this->id), $fname);
     // Now delete the group
     $dbw->delete('groups', array('gr_id' => $this->id), $fname);
     $wgMemc->delete(Group::getCacheKey($this->id));
 }
Example #15
0
 function MwRdfGetModel($article, $modelnames = null)
 {
     global $wgRdfModelFunctions, $wgRdfDefaultModels;
     if ($modelnames == null) {
         $modelnames = $wgRdfDefaultModels;
     }
     $fullModel = ModelFactory::getDefaultModel();
     $title = $article->mTitle;
     $uri = $title->getFullURL();
     $fullModel->setBaseURI($uri);
     foreach ($modelnames as $modelname) {
         $modelfunc = $wgRdfModelFunctions[$modelname];
         if (!$modelfunc) {
             wfDebugDieBacktrace("MwRdf: No RDF model named '{$modelname}'.");
         } elseif (!function_exists($modelfunc)) {
             wfDebugDieBacktrace("MwRdf: No function named '{$modelfunc}' " . " for model '{$modelname}'.");
         }
         # Check the cache...
         $model = MwRdfGetCache($title, $modelname);
         # If it's not there, regenerate.
         if (!isset($model) || !$model) {
             $model = $modelfunc($article);
             MwRdfSetCache($title, $modelname, $model);
         }
         if (isset($model)) {
             $fullModel->addModel($model);
         }
     }
     return $fullModel;
 }
 protected static function load()
 {
     global $wgFlaggedRevsTags, $wgFlaggedRevTags;
     if (self::$loaded) {
         return true;
     }
     if (!FlaggedRevsSetup::isReady()) {
         // sanity
         wfDebugDieBacktrace('FlaggedRevs config loaded too soon! Possibly before LocalSettings.php!');
     }
     self::$loaded = true;
     $flaggedRevsTags = null;
     if (isset($wgFlaggedRevTags)) {
         $flaggedRevsTags = $wgFlaggedRevTags;
         // b/c
         wfWarn('Please use $wgFlaggedRevsTags instead of $wgFlaggedRevTags in config.');
     } elseif (isset($wgFlaggedRevsTags)) {
         $flaggedRevsTags = $wgFlaggedRevsTags;
     }
     # Assume true, then set to false if needed
     if (!empty($flaggedRevsTags)) {
         self::$qualityVersions = true;
         self::$pristineVersions = true;
         self::$binaryFlagging = count($flaggedRevsTags) <= 1;
     }
     foreach ($flaggedRevsTags as $tag => $levels) {
         # Sanity checks
         $safeTag = htmlspecialchars($tag);
         if (!preg_match('/^[a-zA-Z]{1,20}$/', $tag) || $safeTag !== $tag) {
             die('FlaggedRevs given invalid tag name!');
         }
         # Define "quality" and "pristine" reqs
         if (is_array($levels)) {
             $minQL = $levels['quality'];
             $minPL = $levels['pristine'];
             $ratingLevels = $levels['levels'];
             # B/C, $levels is just an integer (minQL)
         } else {
             global $wgFlaggedRevPristine, $wgFlaggedRevValues;
             $ratingLevels = isset($wgFlaggedRevValues) ? $wgFlaggedRevValues : 1;
             $minQL = $levels;
             // an integer
             $minPL = isset($wgFlaggedRevPristine) ? $wgFlaggedRevPristine : $ratingLevels + 1;
             wfWarn('Please update the format of $wgFlaggedRevsTags in config.');
         }
         # Set FlaggedRevs tags
         self::$dimensions[$tag] = array();
         for ($i = 0; $i <= $ratingLevels; $i++) {
             self::$dimensions[$tag][$i] = "{$tag}-{$i}";
         }
         if ($ratingLevels > 1) {
             self::$binaryFlagging = false;
             // more than one level
         }
         # Sanity checks
         if (!is_integer($minQL) || !is_integer($minPL)) {
             die('FlaggedRevs given invalid tag value!');
         }
         if ($minQL > $ratingLevels) {
             self::$qualityVersions = false;
             self::$pristineVersions = false;
         }
         if ($minPL > $ratingLevels) {
             self::$pristineVersions = false;
         }
         self::$minQL[$tag] = max($minQL, 1);
         self::$minPL[$tag] = max($minPL, 1);
         self::$minSL[$tag] = 1;
     }
     global $wgFlaggedRevsTagsRestrictions, $wgFlagRestrictions;
     if (isset($wgFlagRestrictions)) {
         self::$tagRestrictions = $wgFlagRestrictions;
         // b/c
         wfWarn('Please use $wgFlaggedRevsTagsRestrictions instead of $wgFlagRestrictions in config.');
     } else {
         self::$tagRestrictions = $wgFlaggedRevsTagsRestrictions;
     }
     # Make sure that the restriction levels are unique
     global $wgFlaggedRevsRestrictionLevels;
     self::$restrictionLevels = array_unique($wgFlaggedRevsRestrictionLevels);
     self::$restrictionLevels = array_filter(self::$restrictionLevels, 'strlen');
     # Make sure no talk namespaces are in review namespace
     global $wgFlaggedRevsNamespaces;
     foreach ($wgFlaggedRevsNamespaces as $ns) {
         if (MWNamespace::isTalk($ns)) {
             die('FlaggedRevs given talk namespace in $wgFlaggedRevsNamespaces!');
         } elseif ($ns == NS_MEDIAWIKI) {
             die('FlaggedRevs given NS_MEDIAWIKI in $wgFlaggedRevsNamespaces!');
         }
     }
     self::$reviewNamespaces = $wgFlaggedRevsNamespaces;
     # Handle $wgFlaggedRevsAutoReview settings
     global $wgFlaggedRevsAutoReview, $wgFlaggedRevsAutoReviewNew;
     if (is_int($wgFlaggedRevsAutoReview)) {
         self::$autoReviewConfig = $wgFlaggedRevsAutoReview;
     } else {
         // b/c
         if ($wgFlaggedRevsAutoReview) {
             self::$autoReviewConfig = FR_AUTOREVIEW_CHANGES;
         }
         wfWarn('$wgFlaggedRevsAutoReview is now a bitfield instead of a boolean.');
     }
     if (isset($wgFlaggedRevsAutoReviewNew)) {
         // b/c
         self::$autoReviewConfig = $wgFlaggedRevsAutoReviewNew ? self::$autoReviewConfig |= FR_AUTOREVIEW_CREATION : self::$autoReviewConfig & ~FR_AUTOREVIEW_CREATION;
         wfWarn('$wgFlaggedRevsAutoReviewNew is deprecated; use $wgFlaggedRevsAutoReview.');
     }
 }
Example #17
0
 /**
  * @param object $row
  * @access private
  */
 function Revision($row)
 {
     if (is_object($row)) {
         $this->mId = IntVal($row->rev_id);
         $this->mPage = IntVal($row->rev_page);
         $this->mTextId = IntVal($row->rev_text_id);
         $this->mComment = $row->rev_comment;
         $this->mUserText = $row->rev_user_text;
         $this->mUser = IntVal($row->rev_user);
         $this->mMinorEdit = IntVal($row->rev_minor_edit);
         $this->mTimestamp = $row->rev_timestamp;
         $this->mDeleted = IntVal($row->rev_deleted);
         $this->mCurrent = $row->rev_id == $row->page_latest;
         $this->mTitle = Title::makeTitle($row->page_namespace, $row->page_title);
         if (isset($row->old_text)) {
             $this->mText = $this->getRevisionText($row);
         } else {
             $this->mText = null;
         }
     } elseif (is_array($row)) {
         // Build a new revision to be saved...
         global $wgUser;
         $this->mId = isset($row['id']) ? IntVal($row['id']) : null;
         $this->mPage = isset($row['page']) ? IntVal($row['page']) : null;
         $this->mTextId = isset($row['text_id']) ? IntVal($row['text_id']) : null;
         $this->mUserText = isset($row['user_text']) ? StrVal($row['user_text']) : $wgUser->getName();
         $this->mUser = isset($row['user']) ? IntVal($row['user']) : $wgUser->getId();
         $this->mMinorEdit = isset($row['minor_edit']) ? IntVal($row['minor_edit']) : 0;
         $this->mTimestamp = isset($row['timestamp']) ? StrVal($row['timestamp']) : wfTimestamp(TS_MW);
         $this->mDeleted = isset($row['deleted']) ? IntVal($row['deleted']) : 0;
         // Enforce spacing trimming on supplied text
         $this->mComment = isset($row['comment']) ? trim(StrVal($row['comment'])) : null;
         $this->mText = isset($row['text']) ? rtrim(StrVal($row['text'])) : null;
         $this->mTitle = null;
         # Load on demand if needed
         $this->mCurrent = false;
     } else {
         wfDebugDieBacktrace('Revision constructor passed invalid row format.');
     }
 }
 function reportQueryError($error, $errno, $sql, $fname, $tempIgnore = false)
 {
     $message = "A database error has occurred\n" . "Query: {$sql}\n" . "Function: {$fname}\n" . "Error: {$errno} {$error}\n";
     wfDebugDieBacktrace($message);
 }
 /**
  * Factory: creates an object representing an ID
  * @static
  */
 function &get($id)
 {
     global $wgMagicWords;
     if (!is_array($wgMagicWords)) {
         wfDebugDieBacktrace("Incorrect initialisation order, \$wgMagicWords does not exist\n");
     }
     if (!array_key_exists($id, $wgMagicWords)) {
         $mw = new MagicWord();
         $mw->load($id);
         $wgMagicWords[$id] = $mw;
     }
     return $wgMagicWords[$id];
 }
 /**
  * gzwrite() / fwrite() wrapper
  */
 function write(&$handle, $str)
 {
     if ($handle === true || $handle === false) {
         wfDebugDieBacktrace(__METHOD__ . " was passed a boolean as a file handle.\n");
     }
     if ($this->compress) {
         gzwrite($handle, $str);
     } else {
         fwrite($handle, $str);
     }
 }
Example #21
0
 /** 
  * Because programmers assign to $wgHooks, we need to be very
  * careful about its contents. So, there's a lot more error-checking
  * in here than would normally be necessary.
  */
 function wfRunHooks($event, $args = null)
 {
     global $wgHooks;
     if (!is_array($wgHooks)) {
         wfDebugDieBacktrace("Global hooks array is not an array!\n");
         return false;
     }
     if (!array_key_exists($event, $wgHooks)) {
         return true;
     }
     if (!is_array($wgHooks[$event])) {
         wfDebugDieBacktrace("Hooks array for event '{$event}' is not an array!\n");
         return false;
     }
     foreach ($wgHooks[$event] as $hook) {
         $object = NULL;
         $method = NULL;
         $func = NULL;
         $data = NULL;
         $have_data = false;
         /* $hook can be: a function, an object, an array of $function and $data,
          * an array of just a function, an array of object and method, or an
          * array of object, method, and data.
          */
         if (is_array($hook)) {
             if (count($hook) < 1) {
                 wfDebugDieBacktrace("Empty array in hooks for " . $event . "\n");
             } else {
                 if (is_object($hook[0])) {
                     $object = $hook[0];
                     if (count($hook) < 2) {
                         $method = "on" . $event;
                     } else {
                         $method = $hook[1];
                         if (count($hook) > 2) {
                             $data = $hook[2];
                             $have_data = true;
                         }
                     }
                 } else {
                     if (is_string($hook[0])) {
                         $func = $hook[0];
                         if (count($hook) > 1) {
                             $data = $hook[1];
                             $have_data = true;
                         }
                     } else {
                         wfDebugDieBacktrace("Unknown datatype in hooks for " . $event . "\n");
                     }
                 }
             }
         } else {
             if (is_string($hook)) {
                 # functions look like strings, too
                 $func = $hook;
             } else {
                 if (is_object($hook)) {
                     $object = $hook;
                     $method = "on" . $event;
                 } else {
                     wfDebugDieBacktrace("Unknown datatype in hooks for " . $event . "\n");
                 }
             }
         }
         /* We put the first data element on, if needed. */
         if ($have_data) {
             $hook_args = array_merge(array($data), $args);
         } else {
             $hook_args = $args;
         }
         /* Call the hook. */
         if ($object) {
             $retval = call_user_func_array(array($object, $method), $hook_args);
         } else {
             $retval = call_user_func_array($func, $hook_args);
         }
         /* String return is an error; false return means stop processing. */
         if (is_string($retval)) {
             global $wgOut;
             $wgOut->fatalError($retval);
             return false;
         } else {
             if (!$retval) {
                 return false;
             }
         }
     }
     return true;
 }
/**
 * Appends to second array if $value differs from that in $default
 */
function wfAppendToArrayIfNotDefault($key, $value, $default, &$changed)
{
    if (is_null($changed)) {
        wfDebugDieBacktrace('GlobalFunctions::wfAppendToArrayIfNotDefault got null');
    }
    if ($default[$key] !== $value) {
        $changed[$key] = $value;
    }
}
Example #23
0
 /**
  * Die with a backtrace if something happens in the code which
  * shouldn't have
  *
  * @param int $error  ID for the error
  * @param string $data Serialized error data
  */
 function croak($error, $data)
 {
     wfDebugDieBacktrace(wfMsgForContent('cite_croak', $this->error($error), $data));
 }
	protected static function syckDump( $data ) {
		# Make temporary file
		$td = wfTempDir();
		$tf = tempnam( $td, 'yaml-load-' );

		# Write to file
		$sdata = serialize( $data );
		file_put_contents( $tf, $sdata );

		$cmd = "perl -MYAML::Syck=DumpFile -MPHP::Serialization=unserialize -MFile::Slurp=slurp -we '" .
			   '$YAML::Syck::Headless = 1;' .
			   '$YAML::Syck::SortKeys = 1;' .
			   'my $tf = q[' . $tf . '];' .
		       'my $serialized = slurp($tf);' .
		       'my $unserialized = unserialize($serialized);' .
			   'my $unserialized_utf8 = deutf8($unserialized);' .
			   'DumpFile(qq[$tf.yaml], $unserialized_utf8);' .
			   'sub deutf8 {' .
			       'if(ref($_[0]) eq "HASH") {' .
			           'return { map { deutf8($_) } %{$_[0]} };' .
			       '} elsif(ref($_[0]) eq "ARRAY") {' .
			           'return [ map { deutf8($_) } @{$_[0]} ];' .
			       '} else {' .
			           'my $s = $_[0];' .
			           'utf8::decode($s);' .
			           'return $s;' .
			       '}' .
			   '}' .
			   "' 2>&1";
		$out = wfShellExec( $cmd, $ret );
		if ( $ret != 0 ) {
			wfDebugDieBacktrace( "The command '$cmd' died in execution with exit code '$ret': $out" );
		}

		$yaml = file_get_contents( "$tf.yaml" );

		unlink( $tf );
		unlink( "$tf.yaml" );

		return $yaml;
	}
Example #25
0
 function processLogin()
 {
     global $wgUser, $wgAuth;
     switch ($this->authenticateUserData()) {
         case self::SUCCESS:
             # We've verified now, update the real record
             if ((bool) $this->mRemember != (bool) $wgUser->getOption('rememberpassword')) {
                 $wgUser->setOption('rememberpassword', $this->mRemember ? 1 : 0);
                 $wgUser->saveSettings();
             } else {
                 $wgUser->invalidateCache();
             }
             $wgUser->setCookies();
             if ($this->hasSessionCookie()) {
                 return $this->successfulLogin(wfMsg('loginsuccess', $wgUser->getName()));
             } else {
                 return $this->cookieRedirectCheck('login');
             }
             break;
         case self::NO_NAME:
         case self::ILLEGAL:
             $this->mainLoginForm(wfMsg('noname'));
             break;
         case self::WRONG_PLUGIN_PASS:
             $this->mainLoginForm(wfMsg('wrongpassword'));
             break;
         case self::NOT_EXISTS:
             $this->mainLoginForm(wfMsg('nosuchuser', htmlspecialchars($this->mName)));
             break;
         case self::WRONG_PASS:
             $this->mainLoginForm(wfMsg('wrongpassword'));
             break;
         case self::EMPTY_PASS:
             $this->mainLoginForm(wfMsg('wrongpasswordempty'));
             break;
         case self::RESET_PASS:
             $this->resetLoginForm(wfMsg('resetpass_announce'));
             break;
         default:
             wfDebugDieBacktrace("Unhandled case value");
     }
 }
/**
* @param mixed $outputtype A timestamp in one of the supported formats, the
*                          function will autodetect which format is supplied
                           and act accordingly.
* @return string Time in the format specified in $outputtype
*/
function wfTimestamp($outputtype = TS_UNIX, $ts = 0)
{
    if ($ts == 0) {
        $uts = time();
    } elseif (preg_match("/^(\\d{4})\\-(\\d\\d)\\-(\\d\\d) (\\d\\d):(\\d\\d):(\\d\\d)\$/", $ts, $da)) {
        # TS_DB
        $uts = gmmktime((int) $da[4], (int) $da[5], (int) $da[6], (int) $da[2], (int) $da[3], (int) $da[1]);
    } elseif (preg_match("/^(\\d{4}):(\\d\\d):(\\d\\d) (\\d\\d):(\\d\\d):(\\d\\d)\$/", $ts, $da)) {
        # TS_EXIF
        $uts = gmmktime((int) $da[4], (int) $da[5], (int) $da[6], (int) $da[2], (int) $da[3], (int) $da[1]);
    } elseif (preg_match("/^(\\d{4})(\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)\$/", $ts, $da)) {
        # TS_MW
        $uts = gmmktime((int) $da[4], (int) $da[5], (int) $da[6], (int) $da[2], (int) $da[3], (int) $da[1]);
    } elseif (preg_match("/^(\\d{1,13})\$/", $ts, $datearray)) {
        # TS_UNIX
        $uts = $ts;
    } else {
        # Bogus value; fall back to the epoch...
        wfDebug("wfTimestamp() fed bogus time value: {$outputtype}; {$ts}\n");
        $uts = 0;
    }
    switch ($outputtype) {
        case TS_UNIX:
            return $uts;
        case TS_MW:
            return gmdate('YmdHis', $uts);
        case TS_DB:
            return gmdate('Y-m-d H:i:s', $uts);
            // This shouldn't ever be used, but is included for completeness
        // This shouldn't ever be used, but is included for completeness
        case TS_EXIF:
            return gmdate('Y:m:d H:i:s', $uts);
        case TS_RFC2822:
            return gmdate('D, d M Y H:i:s', $uts) . ' GMT';
        default:
            wfDebugDieBacktrace('wfTimestamp() called with illegal output type.');
    }
}
Example #27
0
 /**
  * Die with a backtrace if something happens in the code which
  * shouldn't have
  *
  * @param int $error  ID for the error
  * @param string $data Serialized error data
  */
 function croak($error, $data)
 {
     wfDebugDieBacktrace(wfMessage('cite_croak', $this->error($error), $data)->inContentLanguage()->text());
 }
Example #28
0
 /**
  * Really opens a connection
  * @private
  */
 function reallyOpenConnection(&$server)
 {
     if (!is_array($server)) {
         wfDebugDieBacktrace('You must update your load-balancing configuration. See DefaultSettings.php entry for $wgDBservers.');
     }
     extract($server);
     # Get class for this database type
     $class = 'Database' . ucfirst($type);
     if (!class_exists($class)) {
         require_once "{$class}.php";
     }
     # Create object
     return new $class($host, $user, $password, $dbname, 1, $flags);
 }
Example #29
0
 /**
  * Internal code errors should be reported with this method
  * @param $method string Method or function name
  * @param $message string Error message
  */
 protected static function dieDebug($method, $message)
 {
     wfDebugDieBacktrace("Internal error in {$method}: {$message}");
 }
Example #30
0
 function renderMetadata($format)
 {
     switch ($format) {
         case 'oai_dc':
             $data = $this->renderDublinCore();
             break;
         case 'mediawiki':
             $data = $this->renderMediaWiki();
             break;
         case 'lsearch':
             $data = $this->renderLSearch();
             break;
         default:
             wfDebugDieBacktrace('Unsupported metadata format.');
     }
     return "<metadata>\n{$data}</metadata>\n";
 }