本文整理匯總了PHP中is_true函數的典型用法代碼示例。如果您正苦於以下問題:PHP is_true函數的具體用法?PHP is_true怎麽用?PHP is_true使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了is_true函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: execute
public function execute()
{
if (isset($_SERVER["hide_ss"]) == false) {
$_SERVER["hide_ss"] = true;
}
if ($_SERVER["REQUEST_METHOD"] == "POST" && $_POST["submit_button"] == "hidess") {
$_SERVER["hide_ss"] = is_true($_POST["hide_ss"]);
}
$this->output->add_css("banshee/filter.css");
$filter = new filter($this->db, $this->output, $this->user);
$filter->to_output($this->model->table, false);
if (($count = $this->model->count_events($filter->webserver, $_SERVER["hide_ss"])) === false) {
$this->output->add_tag("result", "Database error.");
return;
}
$paging = new pagination($this->output, "events", $this->settings->event_page_size, $count);
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$paging->reset();
}
if (($events = $this->model->get_events($paging->offset, $paging->size, $filter->webserver, $_SERVER["hide_ss"])) === false) {
$this->output->add_tag("result", "Database error.");
return;
}
$this->output->open_tag("events", array("hide_ss" => show_boolean($_SERVER["hide_ss"])));
foreach ($events as $event) {
$event["timestamp"] = date("j F Y, H:i:s", $event["timestamp"]);
$event["event"] = $this->output->secure_string($event["event"], "_");
$this->output->record($event, "event");
}
$paging->show_browse_links();
$this->output->close_tag();
}
示例2: execute
public function execute()
{
header("Status: 401");
$this->output->description = "Login";
$this->output->keywords = "login";
$this->output->title = "Login";
$this->output->add_javascript("banshee/login.js");
$this->output->open_tag("login", array("password" => show_boolean(module_exists("password")), "register" => show_boolean(module_exists("register"))));
$this->output->add_tag("url", $_SERVER["REQUEST_URI"]);
if ($_SERVER["REQUEST_METHOD"] != "POST") {
$this->output->add_tag("bind");
} else {
$this->output->add_tag("username", $_POST["username"]);
if (is_true($_POST["bind_ip"])) {
$this->output->add_tag("bind");
}
}
$this->output->add_tag("remote_addr", $_SERVER["REMOTE_ADDR"]);
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (strpos($_POST["username"], "'") !== false) {
$this->output->add_message("Sorry, this application does not support SQL injection.");
header("X-Hiawatha-Monitor: exploit_attempt");
} else {
$this->output->add_message("Login incorrect");
}
}
$this->output->close_tag();
}
示例3: execute
public function execute()
{
header("Status: 401");
$this->output->description = "Login";
$this->output->keywords = "login";
$this->output->title = "Login";
$this->output->add_javascript("banshee/" . PASSWORD_HASH . ".js");
$this->output->add_javascript("banshee/login.js");
$this->output->run_javascript("set_focus(); hash = window['" . PASSWORD_HASH . "'];");
$this->output->open_tag("login");
$this->output->add_tag("url", $_SERVER["REQUEST_URI"]);
if ($_SERVER["REQUEST_METHOD"] != "POST") {
$this->output->add_tag("bind");
} else {
$this->output->add_tag("username", $_POST["username"]);
if (is_true($_POST["bind_ip"])) {
$this->output->add_tag("bind");
}
}
$this->output->add_tag("remote_addr", $_SERVER["REMOTE_ADDR"]);
$this->output->add_tag("challenge", $_SESSION["challenge"]);
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (strpos($_POST["username"], "'") !== false) {
$this->output->add_message("Sorry, this application does not support SQL injection.");
header("X-Hiawatha-Monitor: exploit_attempt");
} else {
$this->output->add_message("Login incorrect");
}
}
$this->output->close_tag();
}
示例4: execute
public function execute()
{
if (($page = $this->model->get_page($this->page->url)) == false) {
$this->output->add_tag("website_error", 500);
return;
}
/* Page header
*/
if (trim($page["description"]) != "") {
$this->output->description = $page["description"];
}
if (trim($page["keywords"]) != "") {
$this->output->keywords = $page["keywords"];
}
$this->output->title = $page["title"];
if ($page["style"] != null) {
$this->output->inline_css = $page["style"];
}
$this->output->language = $page["language"];
$this->output->set_layout($page["layout"]);
$this->output->allow_hiawatha_cache();
/* Page content
*/
$this->output->open_tag("page");
$this->output->add_tag("title", $page["title"]);
$page["content"] = $this->output->secure_string($page["content"]);
$this->output->add_tag("content", $page["content"]);
if (is_true($page["back"])) {
$parts = explode("/", $this->page->page);
array_pop($parts);
$this->output->add_tag("back", implode("/", $parts));
}
$this->output->close_tag();
}
示例5: fire
public function fire()
{
$options = $this->option();
$this->seed_path = storage_path('seeder');
Asset::setFromSeed(true);
// -------------------------------------
if (is_true($options['reset'])) {
if (Config::getEnvironment() == 'production') {
$really = $this->confirm('This is the *** PRODUCTION *** server are you sure!? [yes|no]');
if (!$really) {
$this->info("**** Exiting ****");
exit;
}
}
if (!File::exists($this->seed_path)) {
File::makeDirectory($this->seed_path);
$n = 50;
for ($i = 1; $i <= $n; $i++) {
$gender_types = ['men', 'women'];
foreach ($gender_types as $gender) {
$user_photo_url = "http://api.randomuser.me/portraits/{$gender}/{$i}.jpg";
File::put($this->seed_path . "/{$gender}_{$i}.jpg", file_get_contents($user_photo_url));
}
$this->info("Cache user seed image - {$i}");
}
}
if ($this->confirm('Do you really want to delete the tables? [yes|no]')) {
// first delete all assets
if (Schema::hasTable('assets')) {
foreach (Asset::all() as $asset) {
$asset->delete();
}
}
$name = $this->call('migrate');
$name = $this->call('migrate:reset');
File::deleteDirectory(public_path('assets/content/users'));
$this->info('--- Halp has been reset ---');
}
Auth::logout();
$this->setupDatabases();
return;
}
// -------------------------------------
if (is_true($options['setup'])) {
$this->setupDatabases();
}
// -------------------------------------
if ($options['seed'] == 'all') {
$this->seed();
}
if ($options['seed'] == 'users') {
$this->seedUsers();
}
if ($options['seed'] == 'tasks') {
$this->seedTasks();
}
if ($options['seed'] == 'projects') {
$this->seedProjects();
}
}
示例6: fire
public function fire()
{
$options = $this->option();
$users = User::all();
$this->repository = new AwardsRepository();
$this->repository->setListener($this);
$this->comment("// -------------------------------------");
$this->comment(" Individual Awards ");
$this->comment("// -------------------------------------");
// user based awards
foreach ($users as $user) {
$this->info("Checking awards for: " . $user->getName());
$this->info($this->repository->checkAwardForUser($user));
}
$this->comment("// -------------------------------------");
$this->comment(" Site Wide Awards ");
$this->comment("// -------------------------------------");
// site wide awards - time based
if (is_true($options['full'])) {
$start = Task::orderBy('created_at')->first()->created_at;
$end = Carbon::now();
$date = clone $start;
for ($i = $start->weekOfYear; $i <= $end->weekOfYear; $i++) {
$this->info("Checking for week of " . $date->toDateString());
$this->info($this->repository->checkForAwards($date));
$date->addWeek();
}
} else {
$this->info($this->repository->checkForAwards());
}
}
示例7: execute
public function execute()
{
if ($this->user->logged_in == false) {
unset($this->sections["mail"]);
}
if (isset($_SESSION["search"]) == false) {
$_SESSION["search"] = array();
foreach ($this->sections as $section => $label) {
$_SESSION["search"][$section] = true;
}
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$this->log_search_query($_POST["query"]);
foreach ($this->sections as $section => $label) {
$_SESSION["search"][$section] = is_true($_POST[$section]);
}
}
$this->output->add_css("banshee/js_pagination.css");
$this->output->add_javascript("banshee/pagination.js");
$this->output->add_javascript("search.js");
$this->output->run_javascript("document.getElementById('query').focus()");
$this->output->add_tag("query", $_POST["query"]);
$this->output->open_tag("sections");
foreach ($this->sections as $section => $label) {
$params = array("label" => $label, "checked" => show_boolean($_SESSION["search"][$section]));
$this->output->add_tag("section", $section, $params);
}
$this->output->close_tag();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (strlen(trim($_POST["query"])) < 3) {
$this->output->add_tag("result", "Search query too short.");
} else {
if (($result = $this->model->search($_POST, $this->sections)) === false) {
/* Error
*/
$this->output->add_tag("result", "Search error.");
} else {
if (count($result) == 0) {
$this->output->add_tag("result", "No matches found.");
} else {
/* Results
*/
foreach ($result as $section => $hits) {
$this->output->open_tag("section", array("section" => $section, "label" => $this->sections[$section]));
foreach ($hits as $hit) {
$hit["text"] = strip_tags($hit["text"]);
$hit["content"] = strip_tags($hit["content"]);
$hit["content"] = preg_replace('/\\[.*?\\]/', "", $hit["content"]);
$hit["content"] = truncate_text($hit["content"], 400);
$this->output->record($hit, "hit");
}
$this->output->close_tag();
}
}
}
}
}
}
示例8: is_boolean
function is_boolean()
{
$params = func_get_args();
$count = func_num_args();
$value = null;
if (_get_value($params, $count, $value)) {
if (!is_true($value) && !is_false($value)) {
return false;
}
return true;
}
return false;
}
示例9: update_profile
public function update_profile($profile)
{
$profile["status"] = USER_STATUS_ACTIVE;
$keys = array("email", "notification_key", "notification_method", "daily_report");
if ($profile["password"] != "") {
array_push($keys, "password");
array_push($keys, "status");
if (is_false($profile["password_hashed"])) {
$profile["password"] = hash(PASSWORD_HASH, $profile["password"] . hash(PASSWORD_HASH, $this->user->username));
}
}
$profile["daily_report"] = is_true($profile["daily_report"]) ? YES : NO;
return $this->db->update("users", $this->user->id, $profile, $keys) !== false;
}
示例10: __construct
public function __construct($db, $settings, $user)
{
$this->db = $db;
$this->settings = $settings;
$this->user = $user;
/* AJAX request
*/
if ($_SERVER["HTTP_X_REQUESTED_WITH"] == "XMLHttpRequest" || $_GET["output"] == "ajax") {
$this->ajax_request = true;
}
/* Select module
*/
if (is_true(ENFORCE_HTTPS) && $_SERVER["HTTPS"] != "on") {
header(sprintf("Location: https://%s%s", $_SERVER["HTTP_HOST"], $_SERVER["REQUEST_URI"]));
header("Strict-Transport-Security: max-age=31536000");
$this->module = ERROR_MODULE;
$this->http_code = 301;
} else {
if (is_false(WEBSITE_ONLINE) && $_SERVER["REMOTE_ADDR"] != WEBSITE_ONLINE) {
$this->module = "banshee/offline";
} else {
if ($this->db->connected == false) {
if (module_exists("setup") && is_true(DEBUG_MODE)) {
$this->module = "setup";
} else {
$this->module = ERROR_MODULE;
$this->http_code = 500;
}
} else {
list($this->url) = explode("?", $_SERVER["REQUEST_URI"], 2);
$path = trim($this->url, "/");
if ($path == "") {
$page = $this->settings->start_page;
} else {
if (valid_input($path, VALIDATE_URL, VALIDATE_NONEMPTY)) {
$page = $path;
} else {
$this->module = ERROR_MODULE;
$this->http_code = 404;
}
}
$this->pathinfo = explode("/", $page);
}
}
}
if ($this->module === null) {
$this->select_module($page);
}
}
示例11: show_item_form
protected function show_item_form($item)
{
if (is_true(DEBUG_MODE) == false && isset($item["id"])) {
if (($current = $this->model->get_item($item["id"])) === false) {
$this->output->add_tag("result", "Database error.");
return false;
}
$this->output->add_javascript("cms/settings.js");
$this->output->open_tag("label");
$this->output->add_tag("key", $current["key"]);
$this->output->add_tag("type", $current["type"]);
$this->output->close_tag();
}
parent::show_item_form($item);
}
示例12: execute
public function execute()
{
$menu = array("Authentication & authorization" => array("Users" => array("cms/user", "users.png"), "Roles" => array("cms/role", "roles.png"), "Organisations" => array("cms/organisation", "organisations.png"), "Access" => array("cms/access", "access.png"), "Flags" => array("cms/flag", "flags.png"), "User switch" => array("cms/switch", "switch.png")), "Content" => array("Agenda" => array("cms/agenda", "agenda.png"), "Dictionary" => array("cms/dictionary", "dictionary.png"), "F.A.Q." => array("cms/faq", "faq.png"), "Files" => array("cms/file", "file.png"), "Forum" => array("cms/forum", "forum.png"), "Guestbook" => array("cms/guestbook", "guestbook.png"), "Languages" => array("cms/language", "language.png"), "Links" => array("cms/links", "links.png"), "Menu" => array("cms/menu", "menu.png"), "News" => array("cms/news", "news.png"), "Pages" => array("cms/page", "page.png"), "Polls" => array("cms/poll", "poll.png"), "Weblog" => array("cms/weblog", "weblog.png")), "Photo album" => array("Albums" => array("cms/album", "album.png"), "Collections" => array("cms/collection", "collection.png"), "Photos" => array("cms/photo", "photo.png")), "Newsletter" => array("Newsletter" => array("cms/newsletter", "newsletter.png"), "Subscriptions" => array("cms/subscriptions", "subscriptions.png")), "System" => array("Logging" => array("cms/logging", "logging.png"), "Action log" => array("cms/action", "action.png"), "Settings" => array("cms/settings", "settings.png"), "API test" => array("cms/apitest", "apitest.png")));
/* Show warnings
*/
if ($this->user->is_admin) {
if (module_exists("setup")) {
$this->output->add_system_warning("The setup module is still available. Remove it from settings/public_modules.conf.");
}
if ($this->user->id == 1 && $this->user->password == "c10b391ff5e75af6ee8469539e6a5428f09eff7e693d6a8c4de0e5525cd9b287") {
$this->output->add_system_warning("Don't forget to change the password of the admin account!");
}
if ($this->settings->secret_website_code == "CHANGE_ME_INTO_A_RANDOM_STRING") {
$this->output->add_system_warning("Don't forget to change the secret_website_code setting.");
}
if (is_true(DEBUG_MODE)) {
$this->output->add_system_warning("Website is running in debug mode. Set DEBUG_MODE in settings/website.conf to 'no'.");
}
}
if ($this->page->pathinfo[1] != null) {
$this->output->add_system_warning("The administration module '%s' does not exist.", $this->page->pathinfo[1]);
}
/* Show icons
*/
if (is_false(MULTILINGUAL)) {
unset($menu["Content"]["Languages"]);
}
$access_list = page_access_list($this->db, $this->user);
$private_modules = config_file("private_modules");
$this->output->open_tag("menu");
foreach ($menu as $text => $section) {
$this->output->open_tag("section", array("text" => $text, "class" => strtr(strtolower($text), " &", "__")));
foreach ($section as $text => $info) {
list($module, $icon) = $info;
if (in_array($module, $private_modules) == false) {
continue;
}
if (isset($access_list[$module])) {
$access = $access_list[$module] > 0;
} else {
$access = true;
}
$this->output->add_tag("entry", $module, array("text" => $text, "access" => show_boolean($access), "icon" => $icon));
}
$this->output->close_tag();
}
$this->output->close_tag();
}
示例13: fire
public function fire()
{
$options = $this->option();
$debug = is_true($options['debug']);
if ($options['job'] == 'expired_tasks') {
$this->info("Looking for expired tasks...");
$tasks = Task::unClaimed()->get()->filter(function ($task) {
if ($task->notifications()->forEvent(Notification::NOTIFICATION_TASK_EXPIRED)->get()->count() == 0 && $task->isExpired()) {
return $task;
}
});
foreach ($tasks as $task) {
$ago = $task->date->diffForHumans();
$this->info("({$task->id}) {$task->title} Expired - {$ago}");
$n = $task->notifications()->forEvent(Notification::NOTIFICATION_TASK_EXPIRED)->get()->count();
if ($n == 0) {
Notification::fire($task, Notification::NOTIFICATION_TASK_EXPIRED);
$this->info("\tNotification Created " . $task->id);
} else {
$this->info("*** Notification not sent");
}
}
if ($tasks->count() == 0) {
$this->info("*** No expired tasks found ***");
}
return;
}
if ($options['job'] == 'notifications') {
// first get all users that want to receive notifications
$users = User::where('notifications', '=', 1)->get();
// get all notifications that have not been sent out
$notifications = Notification::whereNull('sent_at')->get();
if ($notifications->count() == 0) {
$this->info("*** No New Notification ***");
return;
}
$results = [];
foreach ($notifications as $notice) {
$this->info("Notification: " . $notice->getTitle() . " : " . $notice->event);
$status = $notice->send($debug);
$this->info("\t status: " . strbool($status));
}
return $results;
}
}
示例14: execute
public function execute()
{
$menu = array("Authentication, authorization & system" => array("Users" => array("cms/user", "users.png"), "Roles" => array("cms/role", "roles.png"), "Organisations" => array("cms/organisation", "organisations.png"), "Access" => array("cms/access", "access.png"), "User switch" => array("cms/switch", "switch.png"), "Action log" => array("cms/action", "action.png"), "Settings" => array("cms/settings", "settings.png")), "Content" => array("Files" => array("cms/file", "file.png"), "Hostnames" => array("cms/hostname", "hostname.gif"), "Menu" => array("cms/menu", "menu.png"), "Pages" => array("cms/page", "page.png"), "Webservers" => array("cms/webserver", "webserver.png")));
/* Show warnings
*/
if ($this->user->is_admin) {
if ($this->user->id == 1 && $this->user->password == "610706e9a48f85476e04d270bd6dc7492cdcd9ad7e91878007dff629ab11f195") {
$this->output->add_system_warning("Don't forget to change the password of the admin account!");
}
if ($this->settings->secret_website_code == "CHANGE_ME_INTO_A_RANDOM_STRING") {
$this->output->add_system_warning("Don't forget to change the secret_website_code setting.");
}
if (is_true(DEBUG_MODE)) {
$this->output->add_system_warning("Website is running in debug mode. Set DEBUG_MODE in settings/website.conf to 'no'.");
}
}
if ($this->page->pathinfo[1] != null) {
$this->output->add_system_warning("The administration module '%s' does not exist.", $this->page->pathinfo[1]);
}
/* Show icons
*/
if (is_false(MULTILINGUAL)) {
unset($menu["Content"]["Languages"]);
}
$access_list = page_access_list($this->db, $this->user);
$private_pages = config_file("private_pages");
$this->output->open_tag("menu");
foreach ($menu as $text => $section) {
$this->output->open_tag("section", array("text" => $text, "class" => strtr(strtolower($text), " &", "__")));
foreach ($section as $text => $info) {
list($page, $icon) = $info;
if (in_array($page, $private_pages) == false) {
continue;
}
if (isset($access_list[$page])) {
$access = $access_list[$page] > 0;
} else {
$access = true;
}
$this->output->add_tag("entry", $page, array("text" => $text, "access" => show_boolean($access), "icon" => $icon));
}
$this->output->close_tag();
}
$this->output->close_tag();
}
示例15: __get
public function __get($key)
{
if ($this->valid_key($key) == false) {
return null;
}
if (isset($this->cache[$key])) {
return $this->cache[$key];
}
if ($this->db === null) {
return null;
} else {
if ($this->db->connected == false) {
return null;
}
}
$query = "select * from settings where %S=%s";
if (($setting = $this->db->execute($query, "key", $key)) === false) {
return null;
} else {
if (count($setting) == 0) {
printf("Unknown setting: %s\n", $key);
return null;
}
}
$value = $setting[0]["value"];
switch ($setting[0]["type"]) {
case "boolean":
$value = is_true($value);
break;
case "float":
$value = (double) $value;
break;
case "integer":
$value = (int) $value;
break;
}
$this->cache[$key] = $value;
return $value;
}