本文整理汇总了PHP中Input::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Input::instance方法的具体用法?PHP Input::instance怎么用?PHP Input::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Input
的用法示例。
在下文中一共展示了Input::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDispositionForm
public function getDispositionForm()
{
$faxprof = Input::instance()->post('faxprofile');
$faxdisp = Doctrine::getTable('FaxDisposition')->find($faxprof['fxp_fxd_id']);
if ($faxdisp) {
$packageobj = Doctrine::getTable('package')->find($faxdisp['fxd_package_id']);
if ($packageobj) {
try {
if (!($package = Package_Catalog::getInstalledPackage($packageobj->name))) {
echo 'Package not ' . $packageobj->name . ' found.';
exit;
}
$formfile = $package['directory'] . '/views/' . $packageobj->name . '/' . $faxdisp['fxd_name'] . '.php';
kohana::Log('debug', 'Looking for view ' . $formfile);
if (file_exists($formfile)) {
$featureFormView = new View($packageobj->name . '/' . $faxdisp['fxd_name']);
kohana::Log('debug', 'View file found.');
if (isset($faxprof['fxp_id']) && !empty($faxprof['fxp_id']) && $faxprof['fxp_id'] != '') {
$faxprofobj = Doctrine::getTable('FaxProfile')->find($faxprof['fxp_id']);
} else {
$faxprofobj = new FaxProfile();
}
$featureFormView->set_global('faxprofile', $faxprofobj);
echo $featureFormView->render(TRUE);
} else {
kohana::Log('debug', 'View file not found.');
}
} catch (Package_Catalog_Exception $e) {
echo 'Package not ' . $packageobj->name . ' found.';
}
}
}
exit;
}
示例2: create
/**
* Create a new comment.
* @param Item_MOdel $item the parent item
* @param User_Model $author the author User_Model
* @param string $text comment body
* @param string $guest_name guest's name (if the author is a guest user, default empty)
* @param string $guest_email guest's email (if the author is a guest user, default empty)
* @param string $guest_url guest's url (if the author is a guest user, default empty)
* @return Comment_Model
*/
static function create($item, $author, $text, $guest_name = null, $guest_email = null, $guest_url = null)
{
$comment = ORM::factory("comment");
$comment->author_id = $author->id;
$comment->guest_email = $guest_email;
$comment->guest_name = $guest_name;
$comment->guest_url = $guest_url;
$comment->item_id = $item->id;
$comment->text = $text;
$comment->state = "published";
// These values are useful for spam fighting, so save them with the comment.
$input = Input::instance();
$comment->server_http_accept = substr($input->server("HTTP_ACCEPT"), 0, 128);
$comment->server_http_accept_charset = substr($input->server("HTTP_ACCEPT_CHARSET"), 0, 64);
$comment->server_http_accept_encoding = substr($input->server("HTTP_ACCEPT_ENCODING"), 0, 64);
$comment->server_http_accept_language = substr($input->server("HTTP_ACCEPT_LANGUAGE"), 0, 64);
$comment->server_http_connection = substr($input->server("HTTP_CONNECTION"), 0, 64);
$comment->server_http_host = substr($input->server("HTTP_HOST"), 0, 64);
$comment->server_http_referer = substr($input->server("HTTP_REFERER"), 0, 255);
$comment->server_http_user_agent = substr($input->server("HTTP_USER_AGENT"), 0, 128);
$comment->server_query_string = substr($input->server("QUERY_STRING"), 0, 64);
$comment->server_remote_addr = substr($input->server("REMOTE_ADDR"), 0, 32);
$comment->server_remote_host = substr($input->server("REMOTE_HOST"), 0, 64);
$comment->server_remote_port = substr($input->server("REMOTE_PORT"), 0, 16);
$comment->save();
return $comment;
}
示例3: saveprefs
public function saveprefs()
{
// Process the admin form.
// Prevent Cross Site Request Forgery
access::verify_csrf();
// Save user specified settings to the database.
$str_slideshow_url = Input::instance()->post("slideshow_url");
module::set_var("minislideshow", "slideshow_url", $str_slideshow_url);
$str_slideshow_shuffle = Input::instance()->post("shuffle");
module::set_var("minislideshow", "shuffle", $str_slideshow_shuffle);
$str_slideshow_dropshadow = Input::instance()->post("dropshadow");
module::set_var("minislideshow", "dropshadow", $str_slideshow_dropshadow);
$str_slideshow_show_title = Input::instance()->post("show_title");
module::set_var("minislideshow", "show_title", $str_slideshow_show_title);
$str_slideshow_trans_in_type = Input::instance()->post("trans_in_type");
module::set_var("minislideshow", "trans_in_type", $str_slideshow_trans_in_type);
$str_slideshow_trans_out_type = Input::instance()->post("trans_out_type");
module::set_var("minislideshow", "trans_out_type", $str_slideshow_trans_out_type);
$str_slideshow_mask = Input::instance()->post("mask");
module::set_var("minislideshow", "mask", $str_slideshow_mask);
$str_slideshow_use_full_image = Input::instance()->post("use_full_image");
module::set_var("minislideshow", "use_full_image", $str_slideshow_use_full_image);
$str_slideshow_delay = Input::instance()->post("delay");
module::set_var("minislideshow", "delay", $str_slideshow_delay);
// Display a success message and load the admin screen.
message::success(t("Your Settings Have Been Saved."));
$view = new Admin_View("admin.html");
$view->content = new View("admin_minislideshow.html");
$view->content->minislideshow_form = $this->_get_admin_form();
print $view;
}
示例4: __construct
/**
* On first session instance creation, sets up the driver and creates session.
*/
public function __construct()
{
$this->input = Input::instance();
// This part only needs to be run once
if (self::$instance === NULL) {
// Load config
self::$config = Kohana::config('session');
// Makes a mirrored array, eg: foo=foo
self::$protect = array_combine(self::$protect, self::$protect);
// Configure garbage collection
ini_set('session.gc_probability', (int) self::$config['gc_probability']);
ini_set('session.gc_divisor', 100);
ini_set('session.gc_maxlifetime', self::$config['expiration'] == 0 ? 86400 : self::$config['expiration']);
// Create a new session
$this->create();
if (self::$config['regenerate'] > 0 and $_SESSION['total_hits'] % self::$config['regenerate'] === 0) {
// Regenerate session id and update session cookie
$this->regenerate();
} else {
// Always update session cookie to keep the session alive
cookie::set(self::$config['name'], $_SESSION['session_id'], self::$config['expiration']);
}
// Close the session just before sending the headers, so that
// the session cookie(s) can be written.
Event::add('system.send_headers', array($this, 'write_close'));
// Make sure that sessions are closed before exiting
register_shutdown_function(array($this, 'write_close'));
// Singleton instance
self::$instance = $this;
}
Kohana::log('debug', 'Session Library initialized');
}
示例5: sendmail_wrapped_message_test
public function sendmail_wrapped_message_test()
{
$domain = Input::instance()->server("HTTP_HOST");
$expected = "To: receiver@someemail.com\r\n" . "From: from@gallery3.com\n" . "Reply-To: reply_to@gallery3.com\r\n" . "Subject: Test Email Unit test\r\n\r\n" . "This is a long message that needs to go\n" . "over forty characters If we get lucky we\n" . "might make it long enought to wrap a\n" . "couple of times.";
$result = Sendmail_For_Test::factory()->to("receiver@someemail.com")->subject("Test Email Unit test")->line_length(40)->message("This is a long message that needs to go over forty characters " . "If we get lucky we might make it long enought to wrap a couple " . "of times.")->send()->send_text;
$this->assert_equal($expected, $result);
}
示例6: get
/**
* Fetch a cookie value, using the Input library.
*
* @param string cookie name
* @param mixed default value
* @param boolean use XSS cleaning on the value
* @return string
*/
public static function get($name = NULL, $default = NULL, $xss_clean = FALSE)
{
// Return an array of all the cookies if we don't have a name
if ($name === NULL) {
$cookies = array();
foreach ($_COOKIE as $key => $value) {
$cookies[$key] = cookie::get($key, $default, $xss_clean);
}
return $cookies;
}
if (!isset($_COOKIE[$name])) {
return $default;
}
// Get the cookie value
$cookie = $_COOKIE[$name];
// Find the position of the split between salt and contents
$split = strlen(cookie::salt($name, NULL));
if (isset($cookie[$split]) and $cookie[$split] === '~') {
// Separate the salt and the value
list($hash, $value) = explode('~', $cookie, 2);
if (cookie::salt($name, $value) === $hash) {
if ($xss_clean === TRUE and Kohana::config('core.global_xss_filtering') === FALSE) {
return Input::instance()->xss_clean($value);
}
// Cookie signature is valid
return $value;
}
// The cookie signature is invalid, delete it
cookie::delete($name);
}
return $default;
}
示例7: _show
private function _show($album)
{
$page_size = module::get_var("gallery", "page_size", 9);
$page = Input::instance()->get("page", "1");
$album_defn = unserialize(module::get_var("dynamic", $album));
$children_count = $album_defn->limit;
if (empty($children_count)) {
$children_count = ORM::factory("item")->viewable()->where("type", "!=", "album")->count_all();
}
$offset = ($page - 1) * $page_size;
$max_pages = ceil($children_count / $page_size);
// Make sure that the page references a valid offset
if ($page < 1 || $children_count && $page > ceil($children_count / $page_size)) {
throw new Kohana_404_Exception();
}
$template = new Theme_View("page.html", "collection", "dynamic");
$template->set_global("page", $page);
$template->set_global("page_size", $page_size);
$template->set_global("max_pages", $max_pages);
$template->set_global("children", ORM::factory("item")->viewable()->where("type", "!=", "album")->order_by($album_defn->key_field, "DESC")->find_all($page_size, $offset));
$template->set_global("children_count", $children_count);
$template->content = new View("dynamic.html");
$template->content->title = t($album_defn->title);
print $template;
}
示例8: save
public function save($u = false)
{
if ($u) {
return parent::save($u);
}
if ($this->loaded) {
$p = parent::save($u);
$model = ORM::factory($this->object_plural . '_position')->where($this->object_name . '_id', $this->id)->find();
$model->{$this->object_name . '_id'} = $p->id;
$model->save(true);
return $p;
} else {
$p = parent::save($u);
$type = Input::instance()->post('form_type');
$types = array('insert_as_last_child', 'insert_as_first_child', 'insert_as_next_sibling', 'insert_as_prev_sibling');
if (!in_array($type, $types)) {
throw new Exception("Insert type not set", 1);
}
$parent = Input::instance()->post('form_parent');
if (!is_numeric($parent)) {
throw new Exception("Parent id not set", 1);
}
$model = ORM::factory($this->object_plural . '_position');
$model->{$this->object_name . '_id'} = $this->id;
$model->{$this->object_name . '_pid'} = $this->pid;
$model->version = $this->version;
$model->{$type}($parent);
return $p;
}
}
示例9: __construct
protected function __construct()
{
$this->input = Input::instance();
$this->config = CodeIgniter_Config::instance();
$this->db = CodeIgniter_Database::instance();
$this->load = CodeIgniter_Loader::instance();
}
示例10: index
public function index()
{
$session = Session::instance();
// Make sure we have an upgrade token
if (!($upgrade_token = $session->get("upgrade_token", null))) {
$session->set("upgrade_token", $upgrade_token = random::hash());
}
// If the upgrade token exists, then bless this session
if (file_exists(TMPPATH . $upgrade_token)) {
$session->set("can_upgrade", true);
@unlink(TMPPATH . $upgrade_token);
}
$available_upgrades = 0;
foreach (module::available() as $module) {
if ($module->version && $module->version != $module->code_version) {
$available_upgrades++;
}
}
$failed = Input::instance()->get("failed");
$view = new View("upgrader.html");
$view->can_upgrade = identity::active_user()->admin || $session->get("can_upgrade");
$view->upgrade_token = $upgrade_token;
$view->available = module::available();
$view->failed = $failed ? explode(",", $failed) : array();
$view->done = $available_upgrades == 0;
print $view;
}
示例11: saveprefs
public function saveprefs()
{
// Prevent Cross Site Request Forgery
access::verify_csrf();
// Figure out which boxes where checked
$linkOptions_array = Input::instance()->post("ContactOwnerLinkTypes");
$ownerLink = false;
$userLink = false;
for ($i = 0; $i < count($linkOptions_array); $i++) {
if ($linkOptions_array[$i] == "ContactOwner") {
$ownerLink = true;
}
if ($linkOptions_array[$i] == "ContactUser") {
$userLink = true;
}
}
// Figure out the values of the text boxes
$str_contactbutton = Input::instance()->post("owner_button_text");
$str_contactemail = Input::instance()->post("owner_email");
$str_contactname = Input::instance()->post("owner_name");
$str_messageheader = Input::instance()->post("message_header");
// Save Settings.
module::set_var("contactowner", "contact_owner_link", $ownerLink);
module::set_var("contactowner", "contact_user_link", $userLink);
module::set_var("contactowner", "contact_button_text", $str_contactbutton);
module::set_var("contactowner", "contact_owner_email", $str_contactemail);
module::set_var("contactowner", "contact_owner_name", $str_contactname);
module::set_var("contactowner", "contact_owner_header", $str_messageheader);
message::success(t("Your Settings Have Been Saved."));
// Load Admin page.
$view = new Admin_View("admin.html");
$view->content = new View("admin_contactowner.html");
$view->content->contactowner_form = $this->_get_admin_form();
print $view;
}
示例12: getInstance
public static function getInstance()
{
if (self::$instance === NULL) {
self::$instance = new self();
}
return self::$instance;
}
示例13: saveprefs
public function saveprefs()
{
// Prevent Cross Site Request Forgery
access::verify_csrf();
// Save Settings.
module::set_var("ratings", "showunderphoto", Input::instance()->post("showunderphoto"));
module::set_var("ratings", "showinsidebar", Input::instance()->post("showinsidebar"));
module::set_var("ratings", "imageword", Input::instance()->post("imageword"));
module::set_var("ratings", "votestring", Input::instance()->post("votestring"));
module::set_var("ratings", "castyourvotestring", Input::instance()->post("castyourvotestring"));
# module::set_var("ratings", "bgcolor", Input::instance()->post("bgcolor"));
module::set_var("ratings", "fillcolor", Input::instance()->post("fillcolor"));
module::set_var("ratings", "votedcolor", Input::instance()->post("votedcolor"));
module::set_var("ratings", "hovercolor", Input::instance()->post("hovercolor"));
module::set_var("ratings", "textcolor", Input::instance()->post("textcolor"));
module::set_var("ratings", "regonly", Input::instance()->post("regonly"));
$iconset = Input::instance()->post("iconset");
$iconset = preg_replace("/\\/index\\.php/", "", $iconset);
module::set_var("ratings", "iconset", $iconset);
message::success(t("Your Settings Have Been Saved."));
site_status::clear("ratings_configuration");
// Load Admin page.
$view = new Admin_View("admin.html");
$view->content = new View("admin_ratings.html");
$view->content->ratings_form = $this->_get_admin_form();
print $view;
}
示例14: load_themes
/**
* Load the active theme. This is called at bootstrap time. We will only ever have one theme
* active for any given request.
*/
static function load_themes()
{
$input = Input::instance();
$path = $input->server("PATH_INFO");
if (empty($path)) {
$path = "/" . $input->get("kohana_uri");
}
$config = Kohana_Config::instance();
$modules = $config->get("core.modules");
self::$is_admin = $path == "/admin" || !strncmp($path, "/admin/", 7);
self::$site_theme_name = module::get_var("gallery", "active_site_theme");
if (self::$is_admin) {
// Load the admin theme
self::$admin_theme_name = module::get_var("gallery", "active_admin_theme");
array_unshift($modules, THEMEPATH . self::$admin_theme_name);
// If the site theme has an admin subdir, load that as a module so that
// themes can provide their own code.
if (file_exists(THEMEPATH . self::$site_theme_name . "/admin")) {
array_unshift($modules, THEMEPATH . self::$site_theme_name . "/admin");
}
} else {
// Admins can override the site theme, temporarily. This lets us preview themes.
if (identity::active_user()->admin && ($override = $input->get("theme"))) {
if (file_exists(THEMEPATH . $override)) {
self::$site_theme_name = $override;
} else {
Kohana_Log::add("error", "Missing override theme: '{$override}'");
}
}
array_unshift($modules, THEMEPATH . self::$site_theme_name);
}
$config->set("core.modules", $modules);
}
示例15: session
public function session($key)
{
access::verify_csrf();
$input = Input::instance();
Session::instance()->set($key, $input->get("value"));
url::redirect($input->server("HTTP_REFERER"));
}