本文整理汇总了PHP中Config::current方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::current方法的具体用法?PHP Config::current怎么用?PHP Config::current使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Config
的用法示例。
在下文中一共展示了Config::current方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: thumbnail
public function thumbnail($width = 20, $height = 20)
{
if (!in_array(strtolower($this->info["extension"]), array("png", "jpg", "jpeg", "gif"))) {
return;
}
echo '<img src="' . Config::current()->chyrp_url . '/includes/thumb.php?file=../uploads/' . $this->path . '&max_width=' . $width . '&max_height=' . $height . '" class="thumbnail" alt="attachment" />';
}
示例2: route_submit
/**
* Function: submit
* Submits a post to the blog owner.
*/
public function route_submit()
{
if (!Visitor::current()->group->can("submit_article")) {
show_403(__("Access Denied"), __("You do not have sufficient privileges to submit articles."));
}
if (!empty($_POST)) {
if (!isset($_POST['hash']) or $_POST['hash'] != Config::current()->secure_hashkey) {
show_403(__("Access Denied"), __("Invalid security key."));
}
if (empty($_POST['body'])) {
Flash::notice(__("Post body can't be empty!"), redirect("/"));
}
if (!isset($_POST['draft'])) {
$_POST['draft'] = "true";
}
$_POST['body'] = "{$_POST['body']}\n\n\n{$_POST['name']}\n{$_POST['email']}\n";
$post = Feathers::$instances[$_POST['feather']]->submit();
if (!in_array(false, $post)) {
Flash::notice(__("Thank you for your submission. ", "submission"), "/");
}
}
if (Theme::current()->file_exists("forms/post/submit")) {
MainController::current()->display("forms/post/submit", array("feather" => $feather), __("Submit a Text Post"));
} else {
require "pages/submit.php";
}
}
示例3: getMail
/**
* Gets the mail from the inbox
* Reads all the messages there, and adds posts based on them. Then it deletes the entire mailbox.
*/
function getMail()
{
$config = Config::current();
if (time() - 60 * $config->emailblog_minutes >= $config->emailblog_mail_checked) {
$hostname = '{' . $config->emailblog_server . '}INBOX';
# this isn't working well on localhost
$username = $config->emailblog_address;
$password = $config->emailblog_pass;
$subjpass = $config->emailblog_subjpass;
$inbox = imap_open($hostname, $username, $password) or exit("Cannot connect to Gmail: " . imap_last_error());
$emails = imap_search($inbox, 'SUBJECT "' . $subjpass . '"');
if ($emails) {
rsort($emails);
foreach ($emails as $email_number) {
$message = imap_body($inbox, $email_number);
$overview = imap_headerinfo($inbox, $email_number);
imap_delete($inbox, $email_number);
$title = htmlspecialchars($overview->Subject);
$title = preg_replace($subjpass, "", $title);
$clean = strtolower($title);
$body = htmlspecialchars($message);
# The subject of the email is used as the post title
# the content of the email is used as the body
# not sure about compatibility with images or audio feathers
Post::add(array("title" => $title, "body" => $message), $clean, Post::check_url($clean), "text");
}
}
# close the connection
imap_close($inbox, CL_EXPUNGE);
$config->set("emailblog_mail_checked", time());
}
}
示例4: init
/**
* Initialize the database connection
*
* @param string $type Either mysql, mysqli, oracle. Default is mysql
* @return boolean
*/
public static function init($type = 'mysql')
{
if ($type == 'mysql' || $type == '') {
if (!(self::$DB = new DB_MySQL())) {
self::$error = self::$DB->error;
self::$errno = self::$DB->errno;
return false;
}
self::connect(Config::current()->db_username, Config::current()->db_password, Config::current()->db_name, Config::current()->db_host);
self::set_table_prefix(Config::current()->db_prefix);
} elseif ($type == 'mysqli') {
if (!(self::$DB = new DB_MySQLi())) {
self::$error = self::$DB->error;
self::$errno = self::$DB->errno;
return false;
}
self::connect(Config::current()->db_username, Config::current()->db_password, Config::current()->db_name, Config::current()->db_host);
self::set_table_prefix(Config::current()->db_prefix);
} elseif ($type == 'pdo') {
if (!(self::$DB = new DB_PDO())) {
self::$error = self::$DB->error;
self::$errno = self::$DB->errno;
return false;
}
self::connect('sqlite:' . Config::current()->db_name);
self::set_table_prefix(Config::current()->db_prefix);
} else {
self::$DB = new DB_MySQL();
self::$error = 'Invalid database type';
return false;
}
return true;
}
示例5: scripts
static function scripts($scripts)
{
$route = Route::current()->action;
if ($route == "index" or $route == "archive" or $route == "search") {
$scripts[] = Config::current()->chyrp_url . "/modules/cascade/javascript.php";
return $scripts;
}
}
示例6: indexAction
public function indexAction($uri = array())
{
$this->post = new Post($uri['post']);
// $this->paginator = new Void;
if (!$this->post->success) {
return Error::quit(404, 'So Sorry!', 'The post you are trying to view doesn\'t exist. Please try visiting the <a href="' . Config::current()->url . '">home page</a>.');
}
return $this->output();
}
示例7: group
/**
* Function: group
* Returns the user's <Group> or the "Guest Group".
*
* !! DEPRECATED AFTER 2.0 !!
*/
public function group()
{
if (!isset($this->group_id)) {
return new Group(Config::current()->guest_group);
} elseif (isset($this->group_name)) {
return new Group(null, array("read_from" => array("id" => $this->group_id, "name" => $this->group_name)));
} else {
$group = new Group($this->group_id);
return $group->no_results ? new Group(Config::current()->default_group) : $group;
}
}
示例8: add
/**
* Function: add
* Adds a user to the database with the passed username, password, and e-mail.
*
* Calls the @add_user@ trigger with the inserted user.
*
* Parameters:
* $login - The Login for the new user.
* $password - The Password for the new user. Don't hash this, it's done in the function.
* $email - The E-Mail for the new user.
*
* Returns:
* The newly created <User>.
*
* See Also:
* <update>
*/
static function add($login, $password, $email, $full_name = "", $website = "", $group_id = null, $joined_at = null)
{
$config = Config::current();
$sql = SQL::current();
$trigger = Trigger::current();
$new_values = array("login" => strip_tags($login), "password" => self::hashPassword($password), "email" => strip_tags($email), "full_name" => strip_tags($full_name), "website" => strip_tags($website), "group_id" => fallback($group_id, $config->default_group), "joined_at" => fallback($joined_at, datetime()));
$trigger->filter($new_values, "before_add_user");
$sql->insert("users", $new_values);
$user = new self($sql->latest());
$trigger->call("add_user", $user);
return $user;
}
示例9: remove_expired
public function remove_expired()
{
foreach ((array) glob($this->caches . "/*/*.html") as $file) {
if (time() - filemtime($file) > Config::current()->cache_expire) {
@unlink($file);
}
$dir = dirname($file);
if (!count((array) glob($dir . "/*"))) {
@rmdir($dir);
}
}
}
示例10: __construct
private function __construct()
{
$config = Config::current();
// Setup Default paths:
// Controller paths to Scan:
self::$paths['controller'][] = APPPATH . 'controllers/';
// Class paths to Scan:
self::$paths['class'][] = APPPATH . 'classes/';
// Language paths to Scan:
self::$paths['language'][] = APPPATH . 'languages/';
// Page paths to Scan:
self::$paths['template'][] = CONTENTPATH . 'templates/' . $config->template . '/';
}
示例11: scan
/**
* Scan the plugin registry for custom roles, tasks and commands,
* and register them as existing.
*/
function scan()
{
static $scanned = false;
if ($scanned) {
return;
}
$scanned = true;
$parser = new XMLParser;
$schemapath = Main::getDataPath();
if (!file_exists(Main::getDataPath() . '/channel-1.0.xsd')) {
$schemapath = realpath(__DIR__ . '/../../data');
}
$roleschema = $schemapath . '/customrole-2.0.xsd';
$taskschema = $schemapath . '/customtask-2.0.xsd';
$commandschema = $schemapath . '/customcommand-2.0.xsd';
try {
foreach (Config::current()->channelregistry as $channel) {
foreach ($this->listPackages($channel->name) as $package) {
$chan = $channel->name;
$files = $this->info($package, $chan, 'installedfiles');
// each package may only have 1 role, task or command
foreach ($files as $path => $info) {
switch ($info['role']) {
case 'customrole' :
$roleinfo = $parser->parse($path, $roleschema);
$roleinfo = $roleinfo['role'];
static::makeAutoloader($roleinfo, 'role');
Installer\Role::registerCustomRole($roleinfo);
continue 2;
case 'customtask' :
$taskinfo = $parser->parse($path, $taskschema);
$taskinfo = $taskinfo['task'];
static::makeAutoloader($taskinfo, 'task');
Task\Common::registerCustomTask($taskinfo);
continue 2;
case 'customcommand' :
$commands = $parser->parse($path, $commandschema);
$this->addCommand($commands['commands']['command']);
continue 2;
}
}
}
}
} catch (\Exception $e) {
Logger::log(0, 'Unable to add all custom roles/tasks/commands: ' . $e);
}
}
示例12: admin_context
static function admin_context($context)
{
$theme = Config::current()->theme;
$theme_dir = THEME_DIR . "/";
$file = ltrim(isset($_GET['file']) ? $_GET['file'] : "info.yaml", "/");
$cur_file = $theme_dir . $file;
$ext = array("css", "js", "php", "pot", "twig", "yaml");
$context["editor"]["list_all"] = php_file_tree($theme_dir, "?action=theme_editor&file=[link]", $ext);
if (isset($cur_file) and is_file($cur_file)) {
$context["editor"]["file_name"] = $file;
$context["editor"]["file_path"] = $cur_file;
$context["editor"]["file_content"] = htmlentities(file_get_contents($cur_file));
}
return $context;
}
示例13: check_update
/**
* Function: check_update
* Checks if the a new version of Chyrp is available.
*/
public static function check_update()
{
if (!Config::current()->check_updates) {
return;
}
$xml = self::xml();
$curver = CHYRP_VERSION;
foreach ($xml->channel->item as $item) {
$newver = $item->version;
if (version_compare($curver, $newver, ">=")) {
$return = false;
} else {
$return = _f("<p class='message'>Chyrp v%s is available, you have v%s. <a href='?action=update'>Learn More</a></p>", array($newver, $curver));
break;
}
}
return $return;
}
示例14: __construct
public function __construct($post = null)
{
$this->config =& Config::current();
if (is_object($post)) {
$this->post =& $post;
} else {
$this->post = $this->query($post);
}
if (empty($this->post)) {
return false;
}
foreach ($this->post as $key => &$value) {
if (is_numeric($value)) {
$this->{$key} = (int) $value;
} elseif ($key == 'description') {
$this->{$key} = $value;
} else {
$this->{$key} = Helper::entities($value);
}
}
// Format Dates
$this->date_raw = $this->date;
$this->date_timestamp = strtotime($this->date_raw);
$this->date = date($this->config->date_format, $this->date_timestamp);
$this->author_name = 'Jay Williams';
// Pull from db, on request?
// Format Permalink
if ($this->config->permalink == 'slug') {
$this->url = $this->config->url . 'post/' . $this->slug;
} else {
$this->url = $this->config->url . 'post/' . $this->id;
}
// Add the full url to the image & thumbnail, if it doesn't exist
if (substr($this->photo, 0, 7) != 'http://') {
$this->photo = $this->config->url . 'content/images/' . $this->photo;
}
if (substr($this->photo_t, 0, 7) != 'http://') {
$this->photo_t = $this->config->url . 'content/images/' . $this->photo_t;
}
// Everything worked!
$this->success = true;
}
示例15: create
/**
* Function: create
* Attempts to create a comment using the passed information. If a Defensio API key is present, it will check it.
*
* Parameters:
* $author - The name of the commenter.
* $email - The commenter's email.
* $url - The commenter's website.
* $body - The comment.
* $post - The <Post> they're commenting on.
* $type - The type of comment. Optional, used for trackbacks/pingbacks.
*/
static function create($author, $email, $url, $body, $post, $type = null)
{
if (!self::user_can($post->id) and !in_array($type, array("trackback", "pingback"))) {
return;
}
$config = Config::current();
$route = Route::current();
$visitor = Visitor::current();
if (!$type) {
$status = $post->user_id == $visitor->id ? "approved" : $config->default_comment_status;
$type = "comment";
} else {
$status = $type;
}
if (!empty($config->defensio_api_key)) {
$comment = array("user-ip" => $_SERVER['REMOTE_ADDR'], "article-date" => when("Y/m/d", $post->created_at), "comment-author" => $author, "comment-type" => $type, "comment-content" => $body, "comment-author-email" => $email, "comment-author-url" => $url, "permalink" => $post->url(), "referrer" => $_SERVER['HTTP_REFERER'], "user-logged-in" => logged_in());
$defensio = new Defensio($config->url, $config->defensio_api_key);
list($spam, $spaminess, $signature) = $defensio->auditComment($comment);
if ($spam) {
self::add($body, $author, $url, $email, $_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_USER_AGENT'], "spam", $signature, null, null, $post, $visitor->id);
error(__("Spam Comment"), __("Your comment has been marked as spam. It will have to be approved before it will show up.", "comments"));
} else {
$comment = self::add($body, $author, $url, $email, $_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_USER_AGENT'], $status, $signature, null, null, $post, $visitor->id);
fallback($_SESSION['comments'], array());
$_SESSION['comments'][] = $comment->id;
if (isset($_POST['ajax'])) {
exit("{ comment_id: " . $comment->id . ", comment_timestamp: \"" . $comment->created_at . "\" }");
}
Flash::notice(__("Comment added."), $post->url() . "#comment_" . $comment->id);
}
} else {
$comment = self::add($body, $author, $url, $email, $_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_USER_AGENT'], $status, "", null, null, $post, $visitor->id);
fallback($_SESSION['comments'], array());
$_SESSION['comments'][] = $comment->id;
if (isset($_POST['ajax'])) {
exit("{ comment_id: " . $comment->id . ", comment_timestamp: \"" . $comment->created_at . "\" }");
}
Flash::notice(__("Comment added."), $post->url() . "#comment_" . $comment->id);
}
}