当前位置: 首页>>代码示例>>PHP>>正文


PHP soft_error函数代码示例

本文整理汇总了PHP中soft_error函数的典型用法代码示例。如果您正苦于以下问题:PHP soft_error函数的具体用法?PHP soft_error怎么用?PHP soft_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了soft_error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: password_submit

function password_submit()
{
    global $vars, $phpcdb, $phpc_user;
    if (!is_user()) {
        return tag('div', __('You must be logged in.'));
    }
    verify_token();
    if (!$phpc_user->is_password_editable()) {
        soft_error(__('You do not have permission to change your password.'));
    }
    if (!isset($vars['old_password'])) {
        return tag('div', __('You must specify your old password.'));
    } else {
        $old_password = $vars['old_password'];
    }
    if ($phpc_user->password != md5($old_password)) {
        return tag('div', __('The password you entered did not match your old password.'));
    }
    if (empty($vars['password1'])) {
        return tag('div', __('You must specify a password'));
    }
    if (empty($vars['password2']) || $vars['password1'] != $vars['password2']) {
        return tag('div', __('Your passwords did not match'));
    }
    $passwd = md5($vars['password1']);
    $phpcdb->set_password($phpc_user->get_uid(), $passwd);
    return tag('div', __('Password updated.'));
}
开发者ID:php-calendar,项目名称:php-calendar,代码行数:28,代码来源:password_submit.php

示例2: process_form

function process_form()
{
    global $vars, $phpcdb, $phpc_script;
    verify_token();
    $cid = $phpcdb->create_calendar();
    foreach (get_config_options() as $item) {
        $name = $item[0];
        $type = $item[2];
        if ($type == PHPC_CHECK) {
            if (isset($vars[$name])) {
                $value = "1";
            } else {
                $value = "0";
            }
        } else {
            if (isset($vars[$name])) {
                $value = $vars[$name];
            } else {
                soft_error(__("{$name} was not set."));
            }
        }
        $phpcdb->create_config($cid, $name, $value);
    }
    message(__('Calendar created.'));
}
开发者ID:php-calendar,项目名称:php-calendar,代码行数:25,代码来源:calendar_form.php

示例3: display_week

function display_week()
{
    global $vars;
    $heading_html = tag('tr');
    $heading_html->add(tag('th', __p('Week', 'W')));
    for ($i = 0; $i < 7; $i++) {
        $d = ($i + day_of_week_start()) % 7;
        $heading_html->add(tag('th', day_name($d)));
    }
    if (!isset($vars['week']) || !isset($vars['year'])) {
        soft_error(__('Invalid date.'));
    }
    $week_of_year = intval($vars['week']);
    $year = intval($vars['year']);
    $day_of_year = 1 + ($week_of_year - 1) * 7 - day_of_week(1, 1, $year);
    $from_stamp = mktime(0, 0, 0, 1, $day_of_year, $year);
    $start_month = date("n", $from_stamp);
    $start_year = date("Y", $from_stamp);
    $last_day = $day_of_year + 6;
    $to_stamp = mktime(23, 59, 59, 1, $last_day, $year);
    $end_month = date("n", $to_stamp);
    $end_year = date("Y", $to_stamp);
    $heading = month_name($start_month) . " {$start_year}";
    if ($end_month != $start_month) {
        $heading .= " - " . month_name($end_month) . " {$end_year}";
    }
    return tag('', tag("div", attributes('id="phpc-summary-view"'), tag("div", attributes('id="phpc-summary-head"'), tag("div", attributes('id="phpc-summary-title"'), ''), tag("div", attributes('id="phpc-summary-author"'), ''), tag("div", attributes('id="phpc-summary-category"'), ''), tag("div", attributes('id="phpc-summary-time"'), '')), tag("div", attributes('id="phpc-summary-body"'), '')), tag('table', attributes('class="phpc-main phpc-calendar"'), tag('caption', $heading), tag('colgroup', tag('col', attributes('class="phpc-week"')), tag('col', attributes('class="phpc-day"')), tag('col', attributes('class="phpc-day"')), tag('col', attributes('class="phpc-day"')), tag('col', attributes('class="phpc-day"')), tag('col', attributes('class="phpc-day"')), tag('col', attributes('class="phpc-day"')), tag('col', attributes('class="phpc-day"'))), tag('thead', $heading_html), create_week($week_of_year, $from_stamp, $to_stamp, $year)));
}
开发者ID:php-calendar,项目名称:php-calendar,代码行数:28,代码来源:display_week.php

示例4: options_form

function options_form()
{
    global $config, $phpc_script, $config_form;
    $tbody = tag('tbody');
    foreach ($config_form as $element) {
        $name = $element[0];
        $text = $element[1];
        $type = $element[2];
        switch ($type) {
            case CHECK:
                $input = create_checkbox($name, '1', $config[$name]);
                break;
            case TEXT:
                $input = create_text($name, $config[$name]);
                break;
            case DROPDOWN:
                $sequence = create_sequence(0, count($element[3]) - 1);
                $input = create_select($name, $element[3], $config[$name], $sequence);
                break;
            default:
                soft_error(_('Unsupported config type') . ": {$type}");
        }
        $tbody->add(tag('tr', tag('th', $text . ':'), tag('td', $input)));
    }
    return tag('form', attributes("action=\"{$phpc_script}\"", 'method="post"'), tag('table', attributes('class="phpc-main"'), tag('caption', _('Options')), tag('tfoot', tag('tr', tag('td', attributes('colspan="2"'), create_hidden('action', 'options_submit'), create_submit(_('Submit'))))), $tbody));
}
开发者ID:noprom,项目名称:cryptdb,代码行数:26,代码来源:admin.php

示例5: user_settings_submit

function user_settings_submit()
{
    global $phpcid, $vars, $phpcdb, $phpc_user_tz, $phpc_user_lang, $phpc_prefix, $phpc_user, $phpc_script;
    verify_token();
    // If we have a timezone, make sure it's valid
    if (!empty($vars["timezone"]) && !in_array($vars['timezone'], timezone_identifiers_list())) {
        soft_error(__("Invalid timezone."));
    }
    // Expire 20 years in the future, give or take.
    $expiration_time = time() + 20 * 365 * 24 * 60 * 60;
    // One hour in the past
    $past_time = time() - 3600;
    if (!empty($vars["timezone"])) {
        setcookie("{$phpc_prefix}tz", $vars['timezone'], $expiration_time);
    } else {
        setcookie("{$phpc_prefix}tz", '', $past_time);
    }
    if (!empty($vars["language"])) {
        setcookie("{$phpc_prefix}lang", $vars['language'], $expiration_time);
    } else {
        setcookie("{$phpc_prefix}lang", '', $past_time);
    }
    if (is_user()) {
        $uid = $phpc_user->get_uid();
        $phpcdb->set_user_default_cid($uid, $vars['default_cid']);
        $phpcdb->set_timezone($uid, $vars['timezone']);
        $phpcdb->set_language($uid, $vars['language']);
        $phpc_user_tz = $vars["timezone"];
        $phpc_user_lang = $vars["language"];
    }
    return message_redirect(__('Settings updated.'), "{$phpc_script}?action=user_settings&phpcid={$phpcid}");
}
开发者ID:hubandbob,项目名称:php-calendar,代码行数:32,代码来源:user_settings_submit.php

示例6: calendar_delete

function calendar_delete()
{
    global $vars, $phpcdb, $phpc_script;
    $html = tag('div', attributes('class="phpc-container"'));
    if (empty($vars["cid"])) {
        $html->add(tag('p', __('No calendar selected.')));
        return $html;
    }
    $id = $vars["cid"];
    $calendar = $phpcdb->get_calendar($id);
    if (empty($calendar)) {
        soft_error(__("Invalid calendar ID."));
    }
    if (empty($vars["confirm"])) {
        $html->add(tag('p', __('Confirm you want to delete calendar:') . $calendar->get_title()));
        $html->add(" [ ", create_action_link(__('Confirm'), "calendar_delete", array("cid" => $id, "confirm" => "1")), " ] ");
        $html->add(" [ ", create_action_link(__('Deny'), "display_month"), " ] ");
        return $html;
    }
    if (!$calendar->can_admin()) {
        $html->add(tag('p', __("You do not have permission to remove calendar") . ": {$id}"));
        return $html;
    }
    if ($phpcdb->delete_calendar($id)) {
        $html->add(tag('p', __("Removed calendar") . ": {$id}"));
    } else {
        $html->add(tag('p', __("Could not remove calendar") . ": {$id}"));
    }
    return message_redirect($html, "{$phpc_script}?action=admin");
}
开发者ID:php-calendar,项目名称:php-calendar,代码行数:30,代码来源:calendar_delete.php

示例7: process_form

function process_form()
{
    global $phpcid, $vars, $phpcdb, $phpc_script, $phpc_cal;
    verify_token();
    $user = $phpcdb->get_user($vars["uid"]);
    // Remove existing groups for this calendar
    foreach ($user->get_groups() as $group) {
        if ($group["cid"] == $phpcid) {
            $phpcdb->user_remove_group($vars["uid"], $group["gid"]);
        }
    }
    $valid_groups = array();
    foreach ($phpc_cal->get_groups() as $group) {
        $valid_groups[] = $group["gid"];
    }
    if (!empty($vars["groups"])) {
        foreach ($vars["groups"] as $gid) {
            if (!in_array($gid, $valid_groups)) {
                soft_error("Invalid gid");
            }
            $phpcdb->user_add_group($vars["uid"], $gid);
        }
    }
    return message(__('Groups updated.'));
}
开发者ID:Godjqb,项目名称:Php-test,代码行数:25,代码来源:user_groups.php

示例8: event_delete

function event_delete()
{
    global $config;
    if (!is_user() && $config['anon_permission'] < 2) {
        soft_error(_('You do not have permission to delete events.'));
    }
    $del_array = explode('&', $_SERVER['QUERY_STRING']);
    $html = tag('div', attributes('class="box"', 'style="width: 50%"'));
    $ids = 0;
    foreach ($del_array as $del_value) {
        list($drop, $id) = explode("=", $del_value);
        if (preg_match('/^id$/', $drop) == 0) {
            continue;
        }
        $ids++;
        $event = get_event_by_id($id);
        if (!check_user($event['uid']) && $config['anon_permission'] < 2) {
            $html->add(tag('p', _('You do not have permission to remove item') . ": {$id}"));
            continue;
        }
        if (remove_event($id)) {
            $html->add(tag('p', _('Removed item') . ": {$id}"));
        } else {
            $html->add(tag('p', _('Could not remove item') . ": {$id}"));
        }
    }
    if ($ids == 0) {
        $html->add(tag('p', _('No items selected.')));
    }
    return $html;
}
开发者ID:noprom,项目名称:cryptdb,代码行数:31,代码来源:event_delete.php

示例9: translate

function translate()
{
    global $phpc_locale_path;
    if (!is_admin()) {
        permission_error(__('Need to be admin'));
        exit;
    }
    $handle = opendir($phpc_locale_path);
    if (!$handle) {
        return soft_error("Error reading locale directory.");
    }
    $output_tag = tag('div', tag('h2', __('Translate')));
    while (($filename = readdir($handle)) !== false) {
        $pathname = "{$phpc_locale_path}/{$filename}";
        if (strncmp($filename, ".", 1) == 0 || !is_dir($pathname)) {
            continue;
        }
        $msgs_path = "{$pathname}/LC_MESSAGES";
        $hash = parse_po_file("{$msgs_path}/messages.po");
        if ($hash === FALSE) {
            print nl2br("Error reading '{$msgs_path}/messages.po', aborted.\n");
        } else {
            $out = "{$msgs_path}/messages.mo";
            write_mo_file($hash, $out);
        }
        $output_tag->add(tag('div', sprintf(__('Translated "%s"'), $filename)));
    }
    closedir($handle);
    return $output_tag;
}
开发者ID:php-calendar,项目名称:php-calendar,代码行数:30,代码来源:translate.php

示例10: category_submit

function category_submit()
{
    global $vars, $phpcdb, $phpc_script, $phpc_cal;
    if (empty($vars["text-color"]) || empty($vars["bg-color"])) {
        $page = "{$phpc_script}?action=category_form";
        if (!empty($vars["cid"])) {
            $page .= "&cid={$vars["cid"]}";
        }
        if (!empty($vars["catid"])) {
            $page .= "&catid={$vars["catid"]}";
        }
        return message_redirect(__("Color not specified."), $page);
    }
    // The current widget produces hex values without the "#".
    //   We may in the future want to allow different input, so store the
    //   values with the "#"
    $text_color = '#' . $vars["text-color"];
    $bg_color = '#' . $vars["bg-color"];
    if (empty($vars['gid']) || strlen($vars['gid']) == 0) {
        $gid = 0;
    } else {
        $gid = $vars['gid'];
    }
    if (!check_color($text_color) || !check_color($bg_color)) {
        soft_error(__("Invalid color."));
    }
    if (!isset($vars['catid'])) {
        $modify = false;
        if (!isset($vars['cid'])) {
            $cid = null;
            if (!is_admin()) {
                permission_error(__('You do not have permission to add categories to all calendars.'));
            }
        } else {
            $cid = $vars['cid'];
            $calendar = $phpcdb->get_calendar($cid);
            if (!$calendar->can_admin()) {
                permission_error(__('You do not have permission to add categories to this calendar.'));
            }
        }
        $catid = $phpcdb->create_category($cid, $vars["name"], $text_color, $bg_color, $gid);
    } else {
        $modify = true;
        $catid = $vars['catid'];
        $category = $phpcdb->get_category($catid);
        if (!(empty($category['cid']) && is_admin() || $phpcdb->get_calendar($category["cid"])->can_admin())) {
            soft_error(__("You do not have permission to modify this category."));
        }
        $phpcdb->modify_category($catid, $vars['name'], $text_color, $bg_color, $gid);
    }
    $page = "{$phpc_script}?action=cadmin&phpcid=" . $vars['phpcid'];
    if ($modify) {
        return message_redirect(__("Modified category: ") . $catid, $page);
    }
    if ($catid > 0) {
        return message_redirect(__("Created category: ") . $catid, $page);
    }
    return tag('div', attributes('class="phpc-error"'), __('Error submitting category.'));
}
开发者ID:php-calendar,项目名称:php-calendar,代码行数:59,代码来源:category_submit.php

示例11: search_results

function search_results()
{
    global $vars, $phpcdb, $phpcid, $sort_options, $order_options;
    $searchstring = $vars['searchstring'];
    if (!empty($vars['search-from-date']) && strlen($vars['search-from-date']) > 0) {
        $start = get_timestamp('search-from');
    } else {
        $start = false;
    }
    if (!empty($vars['search-to-date']) && strlen($vars['search-to-date']) > 0) {
        $end = get_timestamp('search-to');
    } else {
        $end = false;
    }
    // make sure sort is valid
    $sort = htmlentities($vars['sort']);
    if (array_search($sort, array_keys($sort_options)) === false) {
        soft_error(__('Invalid sort option') . ": {$sort}");
    }
    // make sure order is valid
    $order = htmlentities($vars['order']);
    if (array_search($order, array_keys($order_options)) === false) {
        soft_error(__('Invalid order option') . ": {$order}");
    }
    $keywords = explode(" ", $searchstring);
    $results = $phpcdb->search($phpcid, $keywords, $start, $end, $sort, $order);
    $tags = array();
    foreach ($results as $event) {
        if (!$event->can_read()) {
            continue;
        }
        $name = $event->get_author();
        $subject = $event->get_subject();
        $desc = $event->get_desc();
        $date = $event->get_date_string();
        $time = $event->get_time_string();
        $eid = $event->get_eid();
        $tags[] = tag('tr', tag('td', tag('strong', create_event_link($subject, 'display_event', $eid))), tag('td', "{$date} {$time}"), tag('td', $desc));
    }
    if (sizeof($tags) == 0) {
        $html = tag('div', tag('strong', __('No events matched your search criteria.')));
    } else {
        $html = tag('table', attributes('class="phpc-main"'), tag('caption', __('Search Results')), tag('thead', tag('tr', tag('th', __('Subject')), tag('th', __('Date Time')), tag('th', __('Description')))));
        foreach ($tags as $tag) {
            $html->add($tag);
        }
    }
    return $html;
}
开发者ID:Godjqb,项目名称:Php-test,代码行数:49,代码来源:search.php

示例12: display_event

function display_event()
{
    global $vars;
    if (!empty($vars['contentType']) && $vars['contentType'] == 'json') {
        return display_event_json();
    }
    if (isset($vars['oid'])) {
        return display_event_by_oid($vars['oid']);
    }
    if (isset($vars['eid'])) {
        return display_event_by_eid($vars['eid']);
    }
    // If we get here, we did something wrong
    soft_error(__("Invalid arguments."));
}
开发者ID:bluewarest,项目名称:gameboard,代码行数:15,代码来源:display_event.php

示例13: display

function display()
{
    global $vars, $day, $month, $year;
    if (isset($vars['id'])) {
        return display_id($vars['id']);
    }
    if (isset($vars['day'])) {
        return display_day($day, $month, $year);
    }
    if (isset($vars['month'])) {
        return display_month($month, $year);
    }
    if (isset($vars['year'])) {
        soft_error('year view not yet implemented');
    }
    return display_month($month, $year);
}
开发者ID:noprom,项目名称:cryptdb,代码行数:17,代码来源:display.php

示例14: search_results

function search_results()
{
    global $vars, $db, $calendar_name, $sort_options, $order_options;
    $searchstring = $vars['searchstring'];
    $start = "{$vars['syear']}-{$vars['smonth']}-{$vars['sday']}";
    $end = "{$vars['eyear']}-{$vars['emonth']}-{$vars['eday']}";
    // make sure sort is valid
    $sort = $vars['sort'];
    if (array_search($sort, array_keys($sort_options)) === false) {
        soft_error(_('Invalid sort option') . ": {$sort}");
    }
    // make sure order is valid
    $order = $vars['order'];
    if (array_search($order, array_keys($order_options)) === false) {
        soft_error(_('Invalid order option') . ": {$order}");
    }
    $keywords = explode(" ", $searchstring);
    $words = array();
    foreach ($keywords as $keyword) {
        $words[] = "(subject LIKE '%{$keyword}%' " . "OR description LIKE '%{$keyword}%')\n";
    }
    $where = implode(' AND ', $words);
    $query = 'SELECT * FROM ' . SQL_PREFIX . "events " . "WHERE ({$where}) " . "AND calendar = '{$calendar_name}' " . "AND enddate >= DATE '{$start}' " . "AND startdate <= DATE '{$end}' " . "ORDER BY {$sort} {$order}";
    $result = $db->Execute($query) or db_error(_('Encountered an error while searching.'), $query);
    $tags = array();
    while ($row = $result->FetchRow()) {
        $name = stripslashes($row['uid']);
        $subject = stripslashes($row['subject']);
        $desc = nl2br(stripslashes($row['description']));
        $desc = parse_desc($desc);
        $tags[] = tag('tr', tag('td', attributes('class="phpc-list"'), tag('strong', create_id_link($subject, 'display', $row['id']))), tag('td', attributes('class="phpc-list"'), $row['startdate'] . ' ' . formatted_time_string($row['starttime'], $row['eventtype'])), tag('td', attributes('class="phpc-list"'), $desc));
    }
    if (sizeof($tags) == 0) {
        $html = tag('div', tag('strong', _('No events matched your search criteria.')));
    } else {
        $html = tag('table', attributes('class="phpc-main"'), tag('caption', _('Search Results')), tag('thead', tag('tr', tag('th', _('Subject')), tag('th', _('Date Time')), tag('th', _('Description')))));
        foreach ($tags as $tag) {
            $html->add($tag);
        }
    }
    return $html;
}
开发者ID:noprom,项目名称:cryptdb,代码行数:42,代码来源:search.php

示例15: __construct

 function __construct($event)
 {
     parent::__construct($event);
     $this->oid = $event['oid'];
     if (!empty($event['start_ts'])) {
         $start_ts = $event['start_ts'];
         $this->start_year = date('Y', $start_ts);
         $this->start_month = date('n', $start_ts);
         $this->start_day = date('j', $start_ts);
         $this->start_hour = date('H', $start_ts);
         $this->start_minute = date('i', $start_ts);
     }
     if (!empty($event['start_date'])) {
         if (preg_match('/^(\\d{4})(\\d{2})(\\d{2})$/', $event['start_date'], $start_matches) < 1) {
             soft_error(__('DB returned an invalid date.') . "({$event['start_date']})");
         }
         $this->start_year = $start_matches[1];
         $this->start_month = $start_matches[2];
         $this->start_day = $start_matches[3];
     }
     if (!empty($event['end_ts'])) {
         $end_ts = $event['end_ts'];
         $this->end_year = date('Y', $end_ts);
         $this->end_month = date('n', $end_ts);
         $this->end_day = date('j', $end_ts);
         $this->end_hour = date('H', $end_ts);
         $this->end_minute = date('i', $end_ts);
     }
     if (!empty($event['end_date'])) {
         if (preg_match('/^(\\d{4})(\\d{2})(\\d{2})$/', $event['end_date'], $end_matches) < 1) {
             soft_error(__('DB returned an invalid date.') . "({$event['start_date']})");
         }
         $this->end_year = $end_matches[1];
         $this->end_month = $end_matches[2];
         $this->end_day = $end_matches[3];
     }
     $this->time_type = $event['time_type'];
     if (!empty($event['end_ts'])) {
         $this->duration = $event['end_ts'] - $event['start_ts'];
     }
 }
开发者ID:php-calendar,项目名称:php-calendar,代码行数:41,代码来源:phpcoccurrence.class.php


注:本文中的soft_error函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。