本文整理汇总了PHP中log::success方法的典型用法代码示例。如果您正苦于以下问题:PHP log::success方法的具体用法?PHP log::success怎么用?PHP log::success使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类log
的用法示例。
在下文中一共展示了log::success方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _send_reset
private function _send_reset($form)
{
$user_name = $form->reset->inputs["name"]->value;
$user = user::lookup_by_name($user_name);
if ($user && !empty($user->email)) {
$user->hash = random::hash();
$user->save();
$message = new View("reset_password.html");
$message->confirm_url = url::abs_site("password/do_reset?key={$user->hash}");
$message->user = $user;
Sendmail::factory()->to($user->email)->subject(t("Password Reset Request"))->header("Mime-Version", "1.0")->header("Content-type", "text/html; charset=UTF-8")->message($message->render())->send();
log::success("user", t("Password reset email sent for user %name", array("name" => $user->name)));
} else {
if (!$user) {
// Don't include the username here until you're sure that it's XSS safe
log::warning("user", t("Password reset email requested for user %user_name, which does not exist.", array("user_name" => $user_name)));
} else {
log::warning("user", t("Password reset failed for %user_name (has no email address on record).", array("user_name" => $user->name)));
}
}
// Always pretend that an email has been sent to avoid leaking
// information on what user names are actually real.
message::success(t("Password reset email sent"));
json::reply(array("result" => "success"));
}
示例2: _update
/**
* @see REST_Controller::_update($resource)
*/
public function _update($photo)
{
access::verify_csrf();
access::required("view", $photo);
access::required("edit", $photo);
$form = photo::get_edit_form($photo);
$valid = $form->validate();
if ($valid = $form->validate()) {
if ($form->edit_item->filename->value != $photo->name || $form->edit_item->slug->value != $photo->slug) {
// Make sure that there's not a name or slug conflict
if ($row = Database::instance()->select(array("name", "slug"))->from("items")->where("parent_id", $photo->parent_id)->where("id <>", $photo->id)->open_paren()->where("name", $form->edit_item->filename->value)->orwhere("slug", $form->edit_item->slug->value)->close_paren()->get()->current()) {
if ($row->name == $form->edit_item->filename->value) {
$form->edit_item->filename->add_error("name_conflict", 1);
}
if ($row->slug == $form->edit_item->slug->value) {
$form->edit_item->slug->add_error("slug_conflict", 1);
}
$valid = false;
}
}
}
if ($valid) {
$photo->title = $form->edit_item->title->value;
$photo->description = $form->edit_item->description->value;
$photo->slug = $form->edit_item->slug->value;
$photo->rename($form->edit_item->filename->value);
$photo->save();
module::event("item_edit_form_completed", $photo, $form);
log::success("content", "Updated photo", "<a href=\"{$photo->url()}\">view</a>");
message::success(t("Saved photo %photo_title", array("photo_title" => html::purify($photo->title))));
print json_encode(array("result" => "success"));
} else {
print json_encode(array("result" => "error", "form" => $form->__toString()));
}
}
示例3: _send_reset
private function _send_reset()
{
$form = $this->_reset_form();
$valid = $form->validate();
if ($valid) {
$user = user::lookup_by_name($form->reset->inputs["name"]->value);
if (!$user->loaded || empty($user->email)) {
$form->reset->inputs["name"]->add_error("no_email", 1);
$valid = false;
}
}
if ($valid) {
$user->hash = md5(rand());
$user->save();
$message = new View("reset_password.html");
$message->confirm_url = url::abs_site("password/do_reset?key={$user->hash}");
$message->user = $user;
Sendmail::factory()->to($user->email)->subject(t("Password Reset Request"))->header("Mime-Version", "1.0")->header("Content-type", "text/html; charset=iso-8859-1")->message($message->render())->send();
log::success("user", t("Password reset email sent for user %name", array("name" => $user->name)));
} else {
// Don't include the username here until you're sure that it's XSS safe
log::warning("user", "Password reset email requested for bogus user");
}
message::success(t("Password reset email sent"));
print json_encode(array("result" => "success"));
}
示例4: add_photo
public function add_photo($id)
{
$album = ORM::factory("item", $id);
access::required("view", $album);
access::required("add", $album);
access::verify_csrf();
$file_validation = new Validation($_FILES);
$file_validation->add_rules("Filedata", "upload::valid", "upload::type[gif,jpg,png,flv,mp4]");
if ($file_validation->validate()) {
// SimpleUploader.swf does not yet call /start directly, so simulate it here for now.
if (!batch::in_progress()) {
batch::start();
}
$temp_filename = upload::save("Filedata");
try {
$name = substr(basename($temp_filename), 10);
// Skip unique identifier Kohana adds
$title = item::convert_filename_to_title($name);
$path_info = pathinfo($temp_filename);
if (array_key_exists("extension", $path_info) && in_array(strtolower($path_info["extension"]), array("flv", "mp4"))) {
$movie = movie::create($album, $temp_filename, $name, $title);
log::success("content", t("Added a movie"), html::anchor("movies/{$movie->id}", t("view movie")));
} else {
$photo = photo::create($album, $temp_filename, $name, $title);
log::success("content", t("Added a photo"), html::anchor("photos/{$photo->id}", t("view photo")));
}
} catch (Exception $e) {
unlink($temp_filename);
throw $e;
}
unlink($temp_filename);
}
print "File Received";
}
示例5: _update
/**
* @see REST_Controller::_update($resource)
*/
public function _update($photo)
{
access::verify_csrf();
access::required("view", $photo);
access::required("edit", $photo);
$form = photo::get_edit_form($photo);
if ($valid = $form->validate()) {
if ($form->edit_photo->filename->value != $photo->name) {
// Make sure that there's not a conflict
if (Database::instance()->from("items")->where("parent_id", $photo->parent_id)->where("id <>", $photo->id)->where("name", $form->edit_photo->filename->value)->count_records()) {
$form->edit_photo->filename->add_error("conflict", 1);
$valid = false;
}
}
}
if ($valid) {
$photo->title = $form->edit_photo->title->value;
$photo->description = $form->edit_photo->description->value;
$photo->rename($form->edit_photo->filename->value);
$photo->save();
module::event("photo_edit_form_completed", $photo, $form);
log::success("content", "Updated photo", "<a href=\"photos/{$photo->id}\">view</a>");
message::success(t("Saved photo %photo_title", array("photo_title" => p::clean($photo->title))));
print json_encode(array("result" => "success", "location" => url::site("photos/{$photo->id}")));
} else {
print json_encode(array("result" => "error", "form" => $form->__toString()));
}
}
示例6: _save_api_key
private function _save_api_key($form)
{
$new_key = $form->sharing->api_key->value;
if ($new_key && !l10n_client::validate_api_key($new_key)) {
$form->sharing->api_key->add_error("invalid", 1);
$valid = false;
} else {
$valid = true;
}
if ($valid) {
$old_key = l10n_client::api_key();
l10n_client::api_key($new_key);
if ($old_key && !$new_key) {
message::success(t("Your API key has been cleared."));
} else {
if ($old_key && $new_key && $old_key != $new_key) {
message::success(t("Your API key has been changed."));
} else {
if (!$old_key && $new_key) {
message::success(t("Your API key has been saved."));
}
}
}
log::success(t("gallery"), t("l10n_client API key changed."));
url::redirect("admin/languages");
} else {
// Show the page with form errors
$this->index($form);
}
}
示例7: add_photo
public function add_photo($id)
{
$album = ORM::factory("item", $id);
access::required("view", $album);
access::required("add", $album);
access::verify_csrf();
// The Flash uploader not call /start directly, so simulate it here for now.
if (!batch::in_progress()) {
batch::start();
}
$form = $this->_get_add_form($album);
// Uploadify adds its own field to the form, so validate that separately.
$file_validation = new Validation($_FILES);
$file_validation->add_rules("Filedata", "upload::valid", "upload::required", "upload::type[" . implode(",", legal_file::get_extensions()) . "]");
if ($form->validate() && $file_validation->validate()) {
$temp_filename = upload::save("Filedata");
Event::add("system.shutdown", create_function("", "unlink(\"{$temp_filename}\");"));
try {
$item = ORM::factory("item");
$item->name = substr(basename($temp_filename), 10);
// Skip unique identifier Kohana adds
$item->title = item::convert_filename_to_title($item->name);
$item->parent_id = $album->id;
$item->set_data_file($temp_filename);
// Remove double extensions from the filename - they'll be disallowed in the model but if
// we don't do it here then it'll result in a failed upload.
$item->name = legal_file::smash_extensions($item->name);
$path_info = @pathinfo($temp_filename);
if (array_key_exists("extension", $path_info) && in_array(strtolower($path_info["extension"]), legal_file::get_movie_extensions())) {
$item->type = "movie";
$item->save();
log::success("content", t("Added a movie"), html::anchor("movies/{$item->id}", t("view movie")));
} else {
$item->type = "photo";
$item->save();
log::success("content", t("Added a photo"), html::anchor("photos/{$item->id}", t("view photo")));
}
module::event("add_photos_form_completed", $item, $form);
} catch (Exception $e) {
// The Flash uploader has no good way of reporting complex errors, so just keep it simple.
Kohana_Log::add("error", $e->getMessage() . "\n" . $e->getTraceAsString());
// Ugh. I hate to use instanceof, But this beats catching the exception separately since
// we mostly want to treat it the same way as all other exceptions
if ($e instanceof ORM_Validation_Exception) {
Kohana_Log::add("error", "Validation errors: " . print_r($e->validation->errors(), 1));
}
header("HTTP/1.1 500 Internal Server Error");
print "ERROR: " . $e->getMessage();
return;
}
print "FILEID: {$item->id}";
} else {
header("HTTP/1.1 400 Bad Request");
print "ERROR: " . t("Invalid upload");
}
}
示例8: install
static function install()
{
$db = Database::instance();
$db->query("CREATE TABLE IF NOT EXISTS {emboss_overlays} (\n `id` int(9) NOT NULL auto_increment,\n `active` tinyint(4) NOT NULL DEFAULT 1,\n `name` varchar(64) NOT NULL,\n `width` int(9) NOT NULL,\n `height` int(9) NOT NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY(`name`))");
$db->query("CREATE TABLE IF NOT EXISTS {emboss_mappings} (\n `id` int(9) NOT NULL auto_increment,\n `image_id` int(9) NOT NULL,\n `best_overlay_id` int(9) NOT NULL,\n `cur_overlay_id` int(9),\n `cur_gravity` varchar(16),\n `cur_transparency` tinyint(4),\n PRIMARY KEY (`id`),\n UNIQUE KEY(`image_id`))");
@mkdir(VARPATH . 'originals');
@mkdir(VARPATH . 'modules');
@mkdir(VARPATH . 'modules/emboss');
module::set_version('emboss', 1);
log::success('emboss', 'Emboss Installed');
}
示例9: choose
public function choose($toolkit_id)
{
access::verify_csrf();
if ($toolkit_id != module::get_var("gallery", "graphics_toolkit")) {
$tk = graphics::detect_toolkits();
module::set_var("gallery", "graphics_toolkit", $toolkit_id);
module::set_var("gallery", "graphics_toolkit_path", $tk->{$toolkit_id}->dir);
site_status::clear("missing_graphics_toolkit");
$msg = t("Changed graphics toolkit to: %toolkit", array("toolkit" => $tk->{$toolkit_id}->name));
message::success($msg);
log::success("graphics", $msg);
}
url::redirect("admin/graphics");
}
示例10: choose
public function choose($toolkit)
{
access::verify_csrf();
if ($toolkit != module::get_var("gallery", "graphics_toolkit")) {
module::set_var("gallery", "graphics_toolkit", $toolkit);
$toolkit_info = graphics::detect_toolkits();
if ($toolkit == "graphicsmagick" || $toolkit == "imagemagick") {
module::set_var("gallery", "graphics_toolkit_path", $toolkit_info[$toolkit]);
}
site_status::clear("missing_graphics_toolkit");
message::success(t("Updated Graphics Toolkit"));
log::success("graphics", t("Changed graphics toolkit to: %toolkit", array("toolkit" => $toolkit)));
}
url::redirect("admin/graphics");
}
示例11: add_photo
public function add_photo($id)
{
$album = ORM::factory("item", $id);
access::required("view", $album);
access::required("add", $album);
access::verify_csrf();
$file_validation = new Validation($_FILES);
$file_validation->add_rules("Filedata", "upload::valid", "upload::required", "upload::type[gif,jpg,jpeg,png,flv,mp4]");
if ($file_validation->validate()) {
// SimpleUploader.swf does not yet call /start directly, so simulate it here for now.
if (!batch::in_progress()) {
batch::start();
}
$temp_filename = upload::save("Filedata");
try {
$name = substr(basename($temp_filename), 10);
// Skip unique identifier Kohana adds
$title = item::convert_filename_to_title($name);
$path_info = @pathinfo($temp_filename);
if (array_key_exists("extension", $path_info) && in_array(strtolower($path_info["extension"]), array("flv", "mp4"))) {
$item = movie::create($album, $temp_filename, $name, $title);
log::success("content", t("Added a movie"), html::anchor("movies/{$item->id}", t("view movie")));
} else {
$item = photo::create($album, $temp_filename, $name, $title);
log::success("content", t("Added a photo"), html::anchor("photos/{$item->id}", t("view photo")));
}
// We currently have no way of showing errors if validation fails, so only call our event
// handlers if validation passes.
$form = $this->_get_add_form($album);
if ($form->validate()) {
module::event("add_photos_form_completed", $item, $form);
}
} catch (Exception $e) {
Kohana_Log::add("alert", $e->__toString());
if (file_exists($temp_filename)) {
unlink($temp_filename);
}
header("HTTP/1.1 500 Internal Server Error");
print "ERROR: " . $e->getMessage();
return;
}
unlink($temp_filename);
print "FILEID: {$item->id}";
} else {
header("HTTP/1.1 400 Bad Request");
print "ERROR: " . t("Invalid Upload");
}
}
示例12: index
public function index()
{
$form = akismet::get_configure_form();
if (request::method() == "post") {
// @todo move the "post" handler part of this code into a separate function
access::verify_csrf();
$valid = $form->validate();
if ($valid) {
$new_key = $form->configure_akismet->api_key->value;
if ($new_key && !akismet::validate_key($new_key)) {
$form->configure_akismet->api_key->add_error("invalid", 1);
$valid = false;
}
}
if ($valid) {
$old_key = module::get_var("akismet", "api_key");
if ($old_key && !$new_key) {
message::success(t("Your Akismet key has been cleared."));
} else {
if ($old_key && $new_key && $old_key != $new_key) {
message::success(t("Your Akismet key has been changed."));
} else {
if (!$old_key && $new_key) {
message::success(t("Your Akismet key has been saved."));
}
}
}
log::success("akismet", t("Akismet key changed to {$new_key}"));
module::set_var("akismet", "api_key", $new_key);
akismet::check_config();
url::redirect("admin/akismet");
} else {
$valid_key = false;
}
} else {
$valid_key = module::get_var("akismet", "api_key") ? 1 : 0;
}
akismet::check_config();
$view = new Admin_View("admin.html");
$view->content = new View("admin_akismet.html");
$view->content->valid_key = $valid_key;
$view->content->form = $form;
print $view;
}
示例13: delete_product
public function delete_product($id)
{
access::verify_csrf();
$product = ORM::factory("bp_product", $id);
if (!$product->loaded()) {
kohana::show_404();
}
$form = bp_product::get_delete_form_admin($product);
if ($form->validate()) {
$name = $product->name;
$product->delete();
} else {
print $form;
}
$message = t("Deleted user %product_name", array("product_name" => html::clean($name)));
log::success("user", $message);
message::success($message);
print json::reply(array("result" => "success"));
}
示例14: delete_email_template
public function delete_email_template($id)
{
access::verify_csrf();
$email_template = ORM::factory("bp_email_template", $id);
if (!$email_template->loaded()) {
kohana::show_404();
}
$form = bp_email_template::get_delete_form_admin($email_template);
if ($form->validate()) {
$name = $email_template->name;
$email_template->delete();
} else {
print $form;
}
$message = t("Deleted Email template %email_template_name", array("email_template_name" => html::clean($name)));
log::success("email_template", $message);
message::success($message);
print json::reply(array("result" => "success"));
}
示例15: index
public function index()
{
$form = recaptcha::get_configure_form();
if (request::method() == "post") {
// @todo move the "save" part of this into a separate controller function
access::verify_csrf();
$old_public_key = module::get_var("recaptcha", "public_key");
$old_private_key = module::get_var("recaptcha", "private_key");
if ($form->validate()) {
$public_key = $form->configure_recaptcha->public_key->value;
$private_key = $form->configure_recaptcha->private_key->value;
if ($public_key && $private_key) {
module::set_var("recaptcha", "public_key", $public_key);
module::set_var("recaptcha", "private_key", $private_key);
message::success(t("reCAPTCHA configured!"));
log::success("recaptcha", t("reCAPTCHA public and private keys set"));
url::redirect("admin/recaptcha");
} else {
if ($public_key && !$private_key) {
$form->configure_recaptcha->private_key->add_error("invalid");
} else {
if ($private_key && !$public_key) {
$form->configure_recaptcha->public_key->add_error("invalid");
} else {
module::set_var("recaptcha", "public_key", "");
module::set_var("recaptcha", "private_key", "");
message::success(t("No keys provided. reCAPTCHA is disabled!"));
log::success("recaptcha", t("reCAPTCHA public and private keys cleared"));
url::redirect("admin/recaptcha");
}
}
}
}
}
recaptcha::check_config();
$view = new Admin_View("admin.html");
$view->page_title = t("reCAPTCHA");
$view->content = new View("admin_recaptcha.html");
$view->content->public_key = module::get_var("recaptcha", "public_key");
$view->content->private_key = module::get_var("recaptcha", "private_key");
$view->content->form = $form;
print $view;
}