/** * getImage method * */ public function getImage() { wfProfileIn(__METHOD__); if ($this->wg->User->isLoggedIn()) { # make proper thumb path: c/central/images/thumb/.... $path = sprintf("%s/%s/images", substr($this->wg->DBname, 0, 1), $this->wg->DBname); # take thumb request from request $img = $this->getVal('image'); if (preg_match('/^(\\/?)thumb\\//', $img)) { # build proper thumb url for thumbnailer $thumb_url = sprintf("%s/%s/%s", $this->wg->ThumbnailerService, $path, $img); # call thumbnailer $options = array('method' => 'GET', 'timeout' => 'default', 'noProxy' => 1); $thumb_request = MWHttpRequest::factory($thumb_url, $options); $status = $thumb_request->execute(); $headers = $thumb_request->getResponseHeaders(); if ($status->isOK()) { if (!empty($headers)) { foreach ($headers as $header_name => $header_value) { if (is_array($header_value)) { list($value) = $header_value; } else { $value = $header_value; } header(sprintf("%s: %s", $header_name, $value)); } } echo $thumb_request->getContent(); } else { wfdebug("Cannot generate auth thumb"); $this->_access_forbidden('img-auth-accessdenied', 'img-auth-nofile', $img); } } else { # serve original image $filename = realpath(sprintf("%s/%s", $this->wg->UploadDirectory, $img)); $stat = @stat($filename); if ($stat) { wfResetOutputBuffers(); $fileinfo = finfo_open(FILEINFO_MIME_TYPE); $imageType = finfo_file($fileinfo, $filename); header(sprintf("Content-Disposition: inline;filename*=utf-8'%s'%s", $this->wg->ContLanguageCode, urlencode(basename($filename)))); header(sprintf("Content-Type: %s", $imageType)); header(sprintf("Content-Length: %d" . $stat['size'])); readfile($filename); } else { $this->_access_forbidden('img-auth-accessdenied', 'img-auth-nopathinfo', $img); } } } else { $this->_access_forbidden('img-auth-accessdenied', 'img-auth-public', ''); } wfProfileOut(__METHOD__); exit; }
/** * UPDATE wrapper, takes a condition array and a SET array */ function update($table, $values, $conds, $fname = 'Database::update') { $table = $this->tableName($table); $sql = "UPDATE {$table} SET "; $first = true; foreach ($values as $field => $v) { if ($first) { $first = false; } else { $sql .= ", "; } $sql .= "{$field} = :n{$field} "; } if ($conds != '*') { $sql .= " WHERE " . $this->makeList($conds, LIST_AND); } $stmt = $this->parseStatement($sql); if ($stmt === false) { $this->reportQueryError($this->lastError(), $this->lastErrno(), $stmt); return false; } if ($this->debug()) { wfDebug("SQL: {$sql}\n"); } $s = ''; foreach ($values as $field => $v) { oci_bind_by_name($stmt, ":n{$field}", $values[$field]); if ($this->debug()) { $s .= " [{$field}] = [{$v}]\n"; } } if ($this->debug()) { wfdebug(" PH: {$s}\n"); } $ret = $this->executeStatement($stmt); return $ret; }
/** * Add dismissable notice and prevent submit of the edit form */ public function addEditNotice($text, $id = false) { $this->mEditNotices->add($text, $id); wfdebug(__METHOD__ . ": \"{$text}\"\n"); }