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


PHP GUMP类代码示例

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


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

示例1: diy_compile

function diy_compile($payload, $storage)
{
    global $app;
    $result["controller"] = __FUNCTION__;
    $result["function"] = substr($app->request()->getPathInfo(), 1);
    $result["method"] = $app->request()->getMethod();
    $params = loadParameters();
    $result->function = substr($app->request()->getPathInfo(), 1);
    $result->method = $app->request()->getMethod();
    $params = loadParameters();
    $srcfile = OAuth2\Request::createFromGlobals()->request["srcfile"];
    $srclib = OAuth2\Request::createFromGlobals()->request["srclib"];
    $device = OAuth2\Request::createFromGlobals()->request["device"];
    $comp = OAuth2\Request::createFromGlobals()->request["comp"];
    $filename = OAuth2\Request::createFromGlobals()->request["filename"];
    $writedevice = OAuth2\Request::createFromGlobals()->request["writedevice"];
    $up = json_decode(base64_decode($payload));
    $client_id = $up->client_id;
    $diy_error["post"]["device"] = $device;
    $post["srcfile"] = $srcfile;
    //organisation                                  oauth_devices
    $post["device"] = $device;
    //organisation                                  oauth_devices
    $post["comp"] = $comp;
    //organisation                                  oauth_devices
    $post["filename"] = $filename;
    //organisation                                  oauth_devices
    $post["writedevice"] = $writedevice;
    //organisation                                  oauth_devices
    $gump = new GUMP();
    $gump->validation_rules(array('device' => 'required|alpha_numeric', 'filename' => 'required|alpha_numeric', 'comp' => 'required|alpha_numeric', 'writedevice' => 'required|alpha_numeric'));
    $gump->filter_rules(array('device' => 'trim|sanitize_string', 'filename' => 'trim|sanitize_string', 'comp' => 'trim|sanitize_string', 'writedevice' => 'trim|sanitize_string'));
    $validated = $gump->run($post);
    if ($validated === false) {
        $result["parse_errors"] = $gump->get_readable_errors(true);
        $result["message"] = "[" . $result["method"] . "][" . $result["function"] . "]:" . $gump->get_readable_errors(true);
    } else {
        try {
            $sourceWriteDir = __DIR__ . '/../../../data/sketches/' . $client_id . '/' . $device . '/' . $filename;
            if (file_exists($sourceWriteDir)) {
                throw new \Exception('Filename ' . $filename . ' for user ' . $client_id . ' and device ' . $device . ' already exists');
            }
            $stmt2 = $storage->prepare('SELECT * FROM oauth_devices WHERE device = :device');
            $stmt2->execute(array('device' => trim($device)));
            $row2 = $stmt2->fetch(PDO::FETCH_ASSOC);
            if ($row2["organisation"]) {
                $org = trim($row2["organisation"]);
            }
            if ($row2["mode"]) {
                $mode = trim($row2["mode"]);
            }
            if ($row2["status"]) {
                $status = trim($row2["status"]);
            }
            if ($row2["client_id"]) {
                $devclient_id = trim($row2["client_id"]);
            }
            $orgscopeadmin = "no";
            $orgscopedevel = "no";
            if ($mode == "devel" && $status == "org") {
                $userscopes = explode(' ', trim($userscope));
                $adminscope = $org . "_admin";
                $develscope = $org . "_admin";
                // o user aniki sto scope
                for ($i = 0; $i <= count($userscopes); $i++) {
                    if (trim($userscopes[$i]) == $adminscope) {
                        $orgscopeadmin = "yes";
                    }
                    if (trim($userscopes[$i]) == $develscope) {
                        $orgscopedevel = "yes";
                    }
                }
                // einai o owner
                if ($devclient_id == $client_id) {
                    $orgscopeadmin = "yes";
                }
            }
            // einmai o owner
            if ($mode == "devel" && $status == "private" && $devclient_id == $client_id) {
                $orgscopeadmin = "yes";
            }
            $result["result"]["sketch1"] = $orgscopeadmin;
            if ($orgscopeadmin == "yes" || $orgscopedevel == "yes") {
                try {
                    $stmt2 = $storage->prepare('SELECT * FROM oauth_clients WHERE client_id = :device');
                    $stmt2->execute(array('device' => trim($device)));
                    $row2 = $stmt2->fetch(PDO::FETCH_ASSOC);
                    if ($row2["apiport"]) {
                        // *************************************** compiler *********************************
                        // srcfile echeis se base64 ton kodika
                        // compiler echeis ton compiler pou thelei o user   mechri stigmis echoume   gcc, ino
                        // filename to filename pou edosse o user
                        // o poros compilesketch
                        // afou kanei compile
                        // epistrefei
                        // error   ta lathi  h noerrors
                        // binfile    to hex file
                        $compilerserver = diyConfig::read("compiler.host");
                        $compilerserver .= ":" . diyConfig::read("compiler.port");
                        $data1 = 'filename=' . $filename;
//.........这里部分代码省略.........
开发者ID:pantnik,项目名称:DIYiotServer,代码行数:101,代码来源:diy_compiledevices.php

示例2: insert_update_group

/**
 * Insert/Update Group
 *
 * Controller for the Group module.
 *
 * @param \Slim\Route $route The route data array
 * @return void
 */
function insert_update_group(\Slim\Route $route)
{
    $app = \Slim\Slim::getInstance();
    $final_global_template_vars = $app->config('final_global_template_vars');
    require_once $final_global_template_vars["absolute_path_to_this_module"] . "/models/group.class.php";
    require_once $_SERVER["PATH_TO_VENDOR"] . "wixel/gump/gump.class.php";
    // URL parameters matched in the route.
    $params = $route->getParams();
    $group_id = isset($params["group_id"]) ? $params["group_id"] : false;
    $db_conn = new \PHPSkeleton\models\db($final_global_template_vars["db_connection"]);
    $db_resource = $db_conn->get_resource();
    $group = new \PHPSkeleton\Group($db_resource, $final_global_template_vars["session_key"]);
    $gump = new GUMP();
    $rules = array("name" => "required", "abbreviation" => "required|alpha_numeric", "state" => "alpha_numeric", "zip" => "numeric|exact_len,5", "group_parent" => "numeric");
    $validated = $gump->validate($app->request()->post(), $rules);
    $errors = array();
    if ($validated !== true) {
        $errors = \phpskeleton\models\utility::gump_parse_errors($validated);
    }
    if (!$errors) {
        $group->insert_update_group($app->request()->post(), $group_id);
        // If group_id is true, then the group was modified. Otherwise, it was created.
        if ($group_id) {
            $app->flash('message', 'The group has been successfully modified.');
        } else {
            $app->flash('message', 'New group has been successfully created.');
        }
        $app->redirect($final_global_template_vars["path_to_this_module"]);
    } else {
        $env = $app->environment();
        $env["default_validation_errors"] = $errors;
    }
}
开发者ID:ghalusa,项目名称:php-skeleton-app,代码行数:41,代码来源:insert_update_group.php

示例3: submit_registration

/**
 * Submit Registration
 *
 * Controller for the Authenticate module.
 *
 * @author      Goran Halusa <gor@webcraftr.com>
 * @since       0.1.0
 * @param       array  $route  The route data array
 */
function submit_registration(\Slim\Route $route)
{
    $app = \Slim\Slim::getInstance();
    $final_global_template_vars = $app->config('final_global_template_vars');
    require_once $final_global_template_vars["default_module_list"]["user_account"]["absolute_path_to_this_module"] . "/models/user_account.class.php";
    require_once $final_global_template_vars["default_module_list"]["group"]["absolute_path_to_this_module"] . "/models/group.class.php";
    require_once $_SERVER["PATH_TO_VENDOR"] . "wixel/gump/gump.class.php";
    $env = $app->environment();
    $db_conn = new \PHPSkeleton\models\db($final_global_template_vars["db_connection"]);
    $db_resource = $db_conn->get_resource();
    $user_account = new \PHPSkeleton\UserAccount($db_resource, $final_global_template_vars["session_key"]);
    $gump = new GUMP();
    $errors = array();
    $user_account_id = $_SESSION[$final_global_template_vars["session_key"]]["user_account_id"];
    // Check to see if this user is already assigned to a group - they may have been added by another administrator.
    $current_groups = $user_account->get_user_account_groups($user_account_id);
    if (!$current_groups) {
        // Validate the group that they submitted.
        $rules = array("group" => "required|integer");
        $validated = $gump->validate($app->request()->post(), $rules);
        if ($validated !== true) {
            $errors = \phpskeleton\models\utility::gump_parse_errors($validated);
        }
    }
    // Validate the acceptable use policy.
    $rules = array("acceptable_use_policy" => "required|integer");
    $validated = $gump->validate($app->request()->post(), $rules);
    if ($validated !== true) {
        $errors = array_merge($errors, \phpskeleton\models\utility::gump_parse_errors($validated));
    }
    if (!$errors) {
        // Create the actual user account.
        $user_data = array("group_data" => '{"0":{"group_id":"' . $app->request()->post("group") . '","roles":["' . $final_global_template_vars["default_role_id"] . '"]}}');
        $update_groups = !empty($current_groups) ? false : true;
        // Get the existing user account info.
        $existing_user_data = $user_account->get_user_account_info($user_account_id);
        // Merge the data.
        $user_data = array_merge($user_data, $existing_user_data);
        // Insert/update
        $user_account->insert_update_user_account($user_data, $user_account_id, $update_groups);
        // Update acceptable use policy.
        $user_account->update_acceptable_use_policy($user_account_id, 1);
        $landing_page = $final_global_template_vars['landing_page'];
        if (isset($_COOKIE[$final_global_template_vars["redirect_cookie_key"]]) && $_COOKIE[$final_global_template_vars["redirect_cookie_key"]]) {
            $landing_page = $_COOKIE[$final_global_template_vars["redirect_cookie_key"]];
            setcookie($final_global_template_vars["redirect_cookie_key"], "", time() - 3600, "/");
            unset($_COOKIE[$final_global_template_vars["redirect_cookie_key"]]);
        }
        // Add role list to session.
        $_SESSION[$final_global_template_vars["session_key"]][$final_global_template_vars["current_user_roles_session_key"]] = \phpskeleton\models\utility::array_flatten($user_account->get_user_roles_list($user_account_id));
        // Add group to session.
        $_SESSION[$final_global_template_vars["session_key"]]["associated_groups"] = array((int) $app->request()->post("group"));
        $app->redirect($landing_page);
    } else {
        $env["default_validation_errors"] = $errors;
    }
}
开发者ID:ghalusa,项目名称:php-skeleton-app,代码行数:66,代码来源:submit_registration.php

示例4: gradeInputPreprocess

 /**
  * Checks, sanitizes and Escapes the Userinput
  *
  * Dies if User submitted incorrect data
  */
 protected function gradeInputPreprocess()
 {
     require_once PATH_INCLUDE . '/gump.php';
     $gump = new GUMP();
     $rules = array('gradelabel' => array('required|min_len,1|max_len,255', 'sql_escape', _g('Gradelabel')), 'gradelevel' => array('required|numeric|min_len,1|max_len,3', 'sql_escape', _g('Gradelevel')), 'schooltype' => array('numeric|min_len,1|max_len,11', 'sql_escape', _g('Schooltype')));
     $gump->rules($rules);
     if (!$gump->run($_POST)) {
         $this->_interface->dieError($gump->get_readable_string_errors(true));
     }
 }
开发者ID:Auwibana,项目名称:babesk,代码行数:15,代码来源:Grade.php

示例5: gump

 protected function gump()
 {
     require_once PATH_INCLUDE . '/gump.php';
     try {
         $gump = new GUMP($_POST);
         $gump->rules(array('userInput' => array($_POST['regex'], '', $_POST['elementName'])));
         if (!$gump->run($_POST)) {
             die('wrongInput');
         } else {
             die('correctInput');
         }
     } catch (Exception $e) {
         die('somethingWentWrong' . $e->getMessage());
     }
 }
开发者ID:Auwibana,项目名称:babesk,代码行数:15,代码来源:InputdataCheck.php

示例6: get_instance

 /**
  * Function to create and return previously created instance
  *
  * @return GUMP
  */
 public static function get_instance()
 {
     if (self::$instance === null) {
         self::$instance = new self();
     }
     return self::$instance;
 }
开发者ID:acutedeveloper,项目名称:havering-intranet-development,代码行数:12,代码来源:gump.class.php

示例7: delete

 public function delete()
 {
     $options = WebApp::post('options') === NULL ? array() : strgetcsv(WebApp::post('options'));
     if (count($options) == 0) {
         return new ActionResult($this, '/admin/core/option_view', 0, 'No option(s) were selected!', B_T_FAIL);
     }
     foreach ($options as $option) {
         $validated = GUMP::is_valid(array('opt' => $option), array('opt' => 'integer'));
         if ($validated !== true) {
             return new ActionResult($this, '/admin/core/option_view', 0, 'No option(s) were selected!', B_T_FAIL);
         }
     }
     $delete = $this->mySQL_w->prepare("DELETE FROM `core_options` WHERE `id`=?");
     $affected_rows = 0;
     foreach ($options as $id) {
         $delete->bind_param('i', $id);
         $delete->execute();
         $delete->store_result();
         $affected_rows += $delete->affected_rows;
     }
     if ($affected_rows == count($options)) {
         $this->parent->parent->logEvent($this::name_space, 'Deleted options: ' . csvgetstr($options));
         return new ActionResult($this, '/admin/core/option_view', 1, 'Successfully deleted selected option(s)!', B_T_SUCCESS);
     } else {
         $this->parent->parent->logEvent($this::name_space, 'Deleted some options: ' . csvgetstr($options));
         return new ActionResult($this, '/admin/core/option_view', 1, 'Successfully deleted ' . $affected_rows . '/' . count($options) . ' selected option(s)!<br /><small>Possible cause: <code>Unknown</code></small>', B_T_WARNING);
     }
 }
开发者ID:huwcbjones,项目名称:WebFramework,代码行数:28,代码来源:option.action.php

示例8: save

 public function save()
 {
     GUMP::add_validator("unique", function ($field, $input, $param = NULL) {
         $checkExistingUser = R::findOne('user', 'user=?', array($input));
         if ($checkExistingUser == NULL) {
             return FALSE;
         } else {
             return TRUE;
         }
     });
     GUMP::add_validator("strong", function ($field, $input, $param = NULL) {
         return checkPasswordStrength($input);
     });
     $rules = array('reseller_username' => 'required|alpha_numeric|max_len,10|min_len,6|unique', 'reseller_password' => 'required|max_len,10|min_len,7|strong');
     $filters = array('reseller_username' => 'trim|sanitize_string', 'reseller_password' => 'trim|sanitize_string|md5');
     $app = Slim::getInstance();
     $post = $app->request()->post();
     // $app - Slim main app instance
     $postValues = $gump->filter($post, $filters);
     $validated = $gump->validate($gump->filter($postValues, $filters), $rules);
     if ($validated === TRUE) {
         $createUser = R::dispense('user');
         $createUser->user = $postValues['reseller_username'];
         $createUser->user = $postValues['reseller_password'];
     } else {
         $this->setError($gump->get_readable_errors(true));
     }
     if ($this->getError() == "") {
         $this->fails = FALSE;
     } else {
         $this->fails = TRUE;
     }
 }
开发者ID:bogiesoft,项目名称:Slim_PHP_Project,代码行数:33,代码来源:reseller_library.php

示例9: register_post

 public function register_post()
 {
     $gump = new GUMP();
     $form = $gump->sanitize($_POST);
     $gump->validation_rules(array("firstname" => "required|valid_name", "lastname" => "required|valid_name", "street" => "required|street_address", "zip" => "required|numeric,min_len=4", "city" => "required", "country" => "required", "email" => "required|valid_email", "password" => "required", "password_verify" => "required"));
     $validation = $gump->run($form);
     if ($validation === false) {
         $errors = $gump->errors();
         for ($i = 0; $i < count($errors); $i++) {
             $this->form[$errors[$i]["field"]]["error"] = true;
         }
     } else {
         if ($user = (new Login())->createLogin($form["email"], $form["password"], $form["company"], $form["firstname"], $form["lastname"], $form["street"], $form["zip"], $form["city"], $form["country"])) {
             $session = new \Base\Session();
             $session->set("user_id", $user->getId());
             (new Request())->redirect("dashboard");
         }
     }
     $this->assign("error_message", "E-Mail oder Passwort falsch.");
     $this->register();
 }
开发者ID:xama5,项目名称:uver-erp,代码行数:21,代码来源:Router.php

示例10: authenticate_user

/**
 * Authenticate User
 *
 * Controller for the Authenticate module.
 *
 * @author      Goran Halusa <gor@webcraftr.com>
 * @since       0.1.0
 */
function authenticate_user()
{
    $app = \Slim\Slim::getInstance();
    $final_global_template_vars = $app->config('final_global_template_vars');
    require_once $_SERVER["PATH_TO_VENDOR"] . "wixel/gump/gump.class.php";
    require_once $final_global_template_vars["absolute_path_to_this_module"] . "/models/authenticate.class.php";
    $db_conn = new \PHPSkeleton\models\db($final_global_template_vars["db_connection"]);
    $db_resource = $db_conn->get_resource();
    $authenticate = new \PHPSkeleton\Authenticate($db_resource, $final_global_template_vars["session_key"]);
    $gump = new GUMP();
    $rules = array("user_account_email" => "valid_email", "password" => "min_len,6");
    $validated = $gump->validate($app->request()->post(), $rules);
    if ($validated === true) {
        $validated = array(array("field" => "user_account_email", "value" => "", "rule" => ""));
        // Query the database for the user_account_email and password.
        try {
            $local_validated = $authenticate->authenticate_local($app->request()->post('user_account_email'), $app->request()->post('password'));
        } catch (Exception $e) {
            $local_validated = false;
        }
        if ($local_validated) {
            $validated = true;
            session_regenerate_id();
            foreach ($final_global_template_vars["auth_session_keys"] as $single_key) {
                $_SESSION[$final_global_template_vars["session_key"]][$single_key] = $local_validated[$single_key];
            }
            // Log the successful login attempt.
            $authenticate->log_login_attempt($local_validated["user_account_email"], "succeeded");
        }
    }
    if ($validated === true) {
        // The show_login_form.php redirects to the redirect cookie key instead of doing it here.
    } else {
        // Log the failed login attempt.
        $authenticate->log_login_attempt($app->request()->post("user_account_email"), "failed");
        $env = $app->environment();
        $env["default_validation_errors"] = $validated;
    }
}
开发者ID:ghalusa,项目名称:php-skeleton-app,代码行数:47,代码来源:authenticate_user.php

示例11: inputCheck

 /**
  * Validates the input of the admin
  */
 protected function inputCheck()
 {
     require_once PATH_INCLUDE . '/gump.php';
     $gump = new \GUMP();
     try {
         $gump->rules($this->_changeRules);
         //Set none-filled-out formelements to be at least a void string,
         //for easier processing
         // $_POST = $gump->voidVarsToStringByRuleset(
         // 	$_POST, self::$registerRules);
         //validate the elements
         if (!$gump->run($_POST)) {
             die(json_encode(array('value' => 'error', 'message' => $gump->get_readable_string_errors(false))));
         }
     } catch (\Exception $e) {
         $this->_logger->log('error checking input', 'error', Null, json_encode(array('message' => $e->getMessage())));
         die(json_encode(array('value' => 'error', 'message' => array('Konnte die Eingaben nicht überprüfen!'))));
     }
     if (!empty($_POST['cardnumber'])) {
         $this->cardnumberDuplicatedCheck($_POST['cardnumber']);
     }
 }
开发者ID:Auwibana,项目名称:babesk,代码行数:25,代码来源:Change.php

示例12: get_menu_level

 function get_menu_level()
 {
     // Do we need to check the wp_nonce??
     require_once CPT_PLUGIN_DIR . 'assets/php/gump/gump.class.php';
     // Let clean the data
     $gump = new GUMP();
     $sanitized_data = $gump->sanitize($_REQUEST);
     // printme($_GET);
     // Get the post_type
     $menu_slug = $sanitized_data['menu'];
     $menu_item_id = $sanitized_data['menu_item_id'];
     $menu_level = $sanitized_data['menu_level'];
     $taxonomy = 'hi_' . str_replace("-", "_", $menu_slug) . '_tax';
     // Because cpts cannot be more than 20 characters we need to filter for
     // these custom post types that have truncated names
     if ($menu_slug == "health-and-safety") {
         $cpt = new stdClass();
         $cpt->label = 'Health and Safety';
         $taxonomy = 'hi_health_safety_tax';
     } else {
         if ($menu_slug == "committee-services") {
             $cpt = new stdClass();
             $cpt->label = 'Committee Services';
             $taxonomy = 'hi_committee_service_tax';
         } else {
             $cpt = get_post_type_object('hi_' . str_replace("-", "_", $menu_slug));
         }
     }
     // depending on the value
     if ($menu_level == 'level_two') {
         wp_nav_menu(array('theme_location' => $menu_slug, 'depth' => 1, 'walker' => new Content_menu_walker(2, $menu_slug), 'container' => false, 'items_wrap' => '<h3>' . $cpt->label . '</h3><ul>%3$s</ul>'));
     } elseif ($menu_level == 'level_three') {
         $tax_slug = $sanitized_data['tax'];
         $term = get_term_by('slug', $tax_slug, $taxonomy);
         wp_nav_menu(array('theme_location' => $menu_slug, 'depth' => 1, 'level' => 2, 'child_of' => (int) $menu_item_id, 'walker' => new Content_menu_walker(3, $menu_slug), 'container' => false, 'items_wrap' => '<h3>' . $term->name . '</h3><ul>%3$s</ul>'));
     }
     die;
 }
开发者ID:acutedeveloper,项目名称:havering-intranet-development,代码行数:38,代码来源:class-main-content-menu.php

示例13: addSub

 public function addSub()
 {
     $gump = new GUMP();
     $gump->validation_rules(array('module' => 'required|integer|min_len,1', 'PID' => 'required|integer', 'parent' => 'required|integer'));
     $gump->filter_rules(array('module' => 'trim|whole_number', 'PID' => 'trim|whole_number', 'parent' => 'trim|whole_number'));
     $valid_data = $gump->run($_POST);
     if ($valid_data === false) {
         return new ActionResult($this, '/admin/core/menu_add', 0, 'Failed to add menu sub menu item.<br />Error: <code>Please check you have completed all fields as instructed.</code>', B_T_FAIL);
     }
     $max_query = $this->mySQL_r->query("SELECT MAX(`position`) FROM `core_menu`");
     $parent_query = $this->mySQL_r->prepare("SELECT `MID` FROM `core_menu` WHERE `MID`=?");
     if (!$parent_query) {
         return new ActionResult($this, '/admin/core/menu_add', 0, 'Failed to add sub menu item.<br/>Error: <code>Query to check parent item exists failed</code>', B_T_FAIL);
     }
     if (!$max_query) {
         return new ActionResult($this, '/admin/core/menu_add', 0, 'Failed to add sub menu item.<br/>Error: <code>Failed to get next free position</code>', B_T_FAIL);
     }
     $parent_query->bind_param('i', $valid_data['parent']);
     $parent_query->execute();
     $parent_query->store_result();
     if ($parent_query->num_rows != 1) {
         return new ActionResult($this, '/admin/core/menu_add', 0, 'Failed to add sub menu item.<br/>Error: <code>Failed to check parent exists</code>', B_T_FAIL);
     }
     $max = $max_query->fetch_row();
     $max = $max[0] + 1;
     $add_query = $this->mySQL_w->prepare("INSERT INTO `core_menu` (`position`, `parent`, `PID`, `dropdown`, `divider` ) VALUES (?, ?, ?, 0, 0)");
     if (!$add_query) {
         return new ActionResult($this, '/admin/core/menu_add', 0, 'Failed to add menu.<br/>Error: <code>Insert query failed</code>', B_T_FAIL);
     }
     $add_query->bind_param('iii', $max, $valid_data['parent'], $valid_data['PID']);
     $add_query->execute();
     if ($add_query->affected_rows == 1) {
         return new ActionResult($this, '/admin/core/menu_edit/' . $valid_data['parent'] . '/?tp=dropdown', 1, 'Succeesfully add sub menu item!', B_T_SUCCESS);
     } else {
         return new ActionResult($this, '/admin/core/menu_addsub/' . $valid_data['parent'], 0, 'Tried to add sub menu item, but failed!', B_T_FAIL);
     }
 }
开发者ID:huwcbjones,项目名称:WebFramework,代码行数:37,代码来源:menu.action.php

示例14: save

 public function save()
 {
     if (WebApp::post('mysql_r_pass') === '') {
         WebApp::post('mysql_r_pass', $this->parent->parent->config->config['mysql']['r']['pass']);
     }
     if (WebApp::post('mysql_w_pass') === '') {
         WebApp::post('mysql_r_pass', $this->parent->parent->config->config['mysql']['w']['pass']);
     }
     $gump = new GUMP();
     $gump->validation_rules(array('core_errors' => 'required|boolean', 'core_maintenance' => 'required|boolean', 'core_debug' => 'required|boolean', 'core_https_a' => 'required|boolean', 'core_https_f' => 'required|boolean', 'core_cdn' => 'required', 'mysql_db' => 'required', 'mysql_r_user' => 'required', 'mysql_r_host' => 'required', 'mysql_r_port' => 'required|integer', 'mysql_w_user' => 'required', 'mysql_w_host' => 'required', 'mysql_w_port' => 'required|integer', 'reCAPTCHA_pub' => 'required|alpha_dash', 'reCAPTCHA_priv' => 'required|alpha_dash'));
     $gump->filter_rules(array('core_cdn' => 'trim|urlencode'));
     $valid_data = $gump->run($_POST);
     if ($valid_data === false) {
         return new ActionResult($this, '/admin/core/config_edit', 0, 'Failed to save config!<br />Error: <code>Please check you have completed all fields as instructed.</code>', B_T_FAIL);
     }
     $configFile = fopen(__LIBDIR__ . '/config.inc.php', 'w');
     if (fwrite($configFile, $this->getFile($valid_data))) {
         fclose($configFile);
         return new ActionResult($this, '/admin/core/config_view', 1, 'Succeesfully saved config!', B_T_SUCCESS);
     } else {
         fclose($configFile);
         return new ActionResult($this, '/admin/core/config_edit', 0, 'Failed to save config!', B_T_SFAIL);
     }
 }
开发者ID:huwcbjones,项目名称:WebFramework,代码行数:24,代码来源:config.action.php

示例15: validate

 public static function validate($validation, $value, $type)
 {
     $rules = array('required');
     if (array_key_exists('email', $validation)) {
         array_push($rules, 'valid_email');
     }
     if (array_key_exists('starts', $validation)) {
         array_push($rules, 'starts,' . $validation['starts']);
     }
     if (array_key_exists('regex', $validation)) {
         $regex = is_array($validation['regex']) ? implode(',', $validation['regex']) : $validation['regex'];
         error_log($regex);
         error_log($value);
         if (!preg_match($regex, $value)) {
             return false;
         }
     }
     if ($type == 'string') {
         if (array_key_exists('maxLength', $validation)) {
             array_push($rules, 'max_len,' . $validation['maxLength']);
         }
         if (array_key_exists('minLength', $validation)) {
             if ($validation['minLength'] === 0 && strlen($value) == 0) {
                 return true;
             }
             array_push($rules, 'min_len,' . $validation['minLength']);
         }
     } else {
         if ($type == 'integer' || $type == 'timestamp') {
             if ($type == 'integer') {
                 array_push($rules, 'integer');
             }
             if (array_key_exists('min', $validation)) {
                 array_push($rules, 'min_numeric,' . $validation['min']);
             }
             if (array_key_exists('max', $validation)) {
                 array_push($rules, 'max_numeric,' . $validation['max']);
             }
         }
     }
     if (count($rules) == 1) {
         return true;
     }
     $valid = \GUMP::is_valid(array('temp' => $value), array('temp' => implode('|', $rules)));
     return $valid === true;
 }
开发者ID:stenvala,项目名称:deco-essentials,代码行数:46,代码来源:Validation.php


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