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


PHP GUMP::run方法代码示例

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


在下文中一共展示了GUMP::run方法的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: edit

 public function edit()
 {
     $gump = new GUMP();
     $gump->validation_rules(array('id' => 'required|integer|min_len,1', 'user' => 'required|integer', 'enabled' => 'required|integer', 'mins' => 'required', 'hours' => 'required', 'days' => 'required', 'months' => 'required', 'DoW' => 'required'));
     $gump->filter_rules(array('id' => 'trim|whole_number'));
     $valid_data = $gump->run($_POST);
     if ($valid_data === false) {
         return new ActionResult($this, '/admin/core/cron_view', 0, 'Failed to edit cron job!<br />Error: <code>Please check you have completed all fields as instructed.</code>', B_T_FAIL);
     }
     foreach (array('mins', 'hours', 'days', 'months', 'DoW') as $var) {
         if ($valid_data[$var] === '*') {
             $valid_data[$var] = NULL;
         }
     }
     $update_query = $this->mySQL_w->prepare("UPDATE `core_cron` SET `enable`=?, `mins`=?, `hours`=?, `days`=?, `month`=?, `dow`=?, `user_id`=? WHERE `ID`=?");
     if ($update_query === false) {
         return new ActionResult($this, '/admin/core/cron_view', 0, 'Failed to edit cron job.<br/>Error: <code>Update query failed</code>', B_T_FAIL);
     }
     $update_query->bind_param('iiiiiiii', $valid_data['enabled'], $valid_data['mins'], $valid_data['hours'], $valid_data['days'], $valid_data['months'], $valid_data['DoW'], $valid_data['user'], $valid_data['id']);
     $update_query->execute();
     if ($update_query->affected_rows == 1) {
         return new ActionResult($this, '/admin/core/cron_view', 1, 'Succeesfully edited cron job!', B_T_SUCCESS);
     } else {
         return new ActionResult($this, '/admin/core/cron_view', 1, 'Tried to edit cron job, but there was nothing to change!', B_T_INFO);
     }
 }
开发者ID:huwcbjones,项目名称:WebFramework,代码行数:26,代码来源:cron.action.php

示例3: 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

示例4: array

 function _parseParameters($parameters, $validationRules, $filterRules)
 {
     $gump = new \GUMP();
     $parameters = $gump->sanitize($parameters);
     $parameters = $gump->run($parameters);
     if ($parameters === false) {
         global $debugLevel;
         if ($debugLevel >= DEBUG) {
             echo $gump->get_readable_errors(true);
         }
         $parameters = array();
     }
     return $parameters;
 }
开发者ID:nobelprize-org,项目名称:top-laureates,代码行数:14,代码来源:api.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: validate

 public static function validate(\RedBeanPHP\OODBBean $bean)
 {
     $data = $bean->export();
     $model = $bean->box() !== null ? $bean->box() : null;
     if (!$model) {
         throw new ModelValidation_Exception('This bean does not have a model!');
     }
     $rules = isset($model::$rules) ? $model::$rules : null;
     if (!$rules) {
         throw new ModelValidation_Exception('This bean does not have any established rules!');
     }
     $validations = [];
     $filters = [];
     $labels = [];
     $messages = [];
     foreach ($rules as $field => $rule) {
         if (isset($rule['filter'])) {
             $filters[$field] = $rule['filter'];
         }
         if (isset($rule['label'])) {
             $labels[$field] = $rule['label'];
         }
         if (isset($rule['validation'])) {
             $validations[$field] = $rule['validation'];
         }
         if (isset($rule['message'])) {
             $field = isset($rule['label']) ? $rule['label'] : ucwords(str_replace(array('_', '-'), chr(32), $field));
             $messages[$field] = $rule['message'];
         }
     }
     $gump = new \GUMP();
     if (!empty($filters)) {
         $gump->filter_rules($filters);
     }
     if (!empty($validations)) {
         $gump->validation_rules($validations);
     }
     if (!empty($labels)) {
         $gump->set_field_names($labels);
     }
     $validated_data = $gump->run($data);
     if ($validated_data === false) {
         return self::default2custom_errors($gump->get_errors_array(), $messages);
     } else {
         $bean->import($validated_data);
         return true;
     }
 }
开发者ID:filisko,项目名称:redbean-validation-plugin,代码行数:48,代码来源:ModelValidation.php

示例7: GUMP

	/**
	 *
	 *	Processes the request from the user
	 *	The main engine of the class
	 *
	 * 	@param object $post WP_Post Object
	 * 	returns nothing
	 *
	 */

	function process_article()
	{
		require_once CPT_PLUGIN_DIR . 'assets/php/gump/gump.class.php';

		$gump = new GUMP();

		$_POST = $gump->sanitize($_POST); // You don't have to sanitize, but it's safest to do so.

		$gump->validation_rules(array(
		    'email'       => 'required|valid_email',
		));

		$gump->filter_rules(array(
		    'email'    => 'trim|sanitize_email',
		));

		$validated_data = $gump->run($_POST);

		if($validated_data === false) {
			$this->message_type = 'error';
		    $this->message = $gump->get_readable_errors(true);
		} else {

			// Get the article data
			$this->post = get_post($validated_data['post_id'], OBJECT, 'edit');

			//build the html
			$email_html = $this->build_html();

			// If article is sent
			if($this->send_email($validated_data['email']))
			{
				$this->message_type = 'success';
			    $this->message = 'The article link has been emailed';
			}
			else
			{
				$this->message_type = 'error';
			    $this->message = 'The article has not been sent. Please try again';
			}
		}

		// Finally send the response to user
		$this->response_message();

	}
开发者ID:acutedeveloper,项目名称:carepoint-development,代码行数:56,代码来源:class-emailarticle.php

示例8: edit

 public function edit()
 {
     $gump = new GUMP();
     $gump->validation_rules(array('id' => 'required|integer|min_len,1', 'name' => 'required', 'value' => 'required'));
     $gump->filter_rules(array('id' => 'trim|whole_number', 'name' => 'trim|sanitize_string', 'value' => 'trim', 'desc' => 'trim|sanitize_string'));
     $valid_data = $gump->run($_POST);
     if ($valid_data === false) {
         return new ActionResult($this, '/admin/core/option_edit', 0, 'Failed to edit option!<br />Error: <code>Please check you have completed all fields as instructed.</code>', B_T_FAIL);
     }
     $update_query = $this->mySQL_w->prepare("UPDATE `core_options` SET `value`=?, `desc`=? WHERE `id`=? AND `name`=?");
     if ($update_query === false) {
         return new ActionResult($this, '/admin/core/option_view', 0, 'Failed to edit option.<br/>Error: <code>Update query failed</code>', B_T_FAIL);
     }
     $update_query->bind_param('ssis', $valid_data['value'], $valid_data['desc'], $valid_data['id'], $valid_data['name']);
     $update_query->execute();
     if ($update_query->affected_rows == 1) {
         return new ActionResult($this, '/admin/core/option_view', 1, 'Succeesfully edited option!', B_T_SUCCESS);
     } else {
         return new ActionResult($this, '/admin/core/option_view', 1, 'Tried to edit option, but there was nothing to change!', B_T_INFO);
     }
 }
开发者ID:huwcbjones,项目名称:WebFramework,代码行数:21,代码来源:option.action.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: edit

 public function edit()
 {
     $gump = new GUMP();
     $gump->validation_rules(array('id' => 'required|integer|min_len,1', 'ip' => 'required|valid_ipv4', 'length' => 'required|integer', 'reason' => 'required'));
     $gump->filter_rules(array('id' => 'trim|whole_number', 'ip' => 'trim', 'length' => 'trim|whole_number', 'reason' => 'trim|sanitize_string'));
     $valid_data = $gump->run($_POST);
     if ($valid_data === false) {
         return new ActionResult($this, '/admin/core/ipblock_view', 0, 'Failed to edit block!<br />Error: <code>Please check you have completed all fields as instructed.</code>', B_T_FAIL);
     }
     $update_query = $this->mySQL_w->prepare("UPDATE `core_ip` SET `length`=?, `reason`=? WHERE `id`=? AND `ip`=INET_ATON(?)");
     if ($update_query === false) {
         return new ActionResult($this, '/admin/core/ipblock_view', 0, 'Failed to edit block.<br/>Error: <code>Update query failed</code>', B_T_FAIL);
     }
     $update_query->bind_param('isis', $valid_data['length'], $valid_data['reason'], $valid_data['id'], $valid_data['ip']);
     $update_query->execute();
     if ($update_query->affected_rows == 1) {
         return new ActionResult($this, '/admin/core/ipblock_view', 1, 'Succeesfully edited block!', B_T_SUCCESS);
     } else {
         return new ActionResult($this, '/admin/core/ipblock_view', 1, 'Tried to edit block, but there was nothing to change!', B_T_INFO);
     }
 }
开发者ID:huwcbjones,项目名称:WebFramework,代码行数:21,代码来源:ipblock.action.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: 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

示例13: 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

示例14: validate

 public function validate($data = null)
 {
     $gump = new \GUMP();
     $gump->validation_rules(['page' => 'required', 'email' => 'required', 'name' => 'required', 'phone' => 'required', 'city_id' => 'required', 'state_id' => 'required', 'message' => 'required', 'destination' => 'required']);
     return $gump->run($data);
 }
开发者ID:rluders,项目名称:crmsocial-php,代码行数:6,代码来源:UpdateLead.php

示例15: stockfiles_form

function stockfiles_form($stock_file_id = 0)
{
    global $user;
    global $backend;
    global $mysqli;
    if ($stock_file_id) {
        $stock_file = new StockFile($stock_file_id);
        $form_type = 'update';
        if (!$user->is_allowed('edit_ashp_stock_files')) {
            echo edgimo_error('Your user role (' . $user->role . ') is not allowed to make edits on this page.');
            return;
        }
    } else {
        $stock_file = new StockFile();
        $form_type = 'insert';
        if (!$user->is_allowed('add_stock_file')) {
            echo edgimo_error('Your user role (' . $user->role . ') is not allowed to make edits on this page.');
            return;
        }
    }
    $html = '';
    $fields = array('display_name' => array('var' => 'display_name', 'label' => 'Display Name', 'desc' => 'This will be displayed publicly as the name of the file.', 'type' => 'text', 'std' => $stock_file->display_name, 'validate' => 'required', 'filter' => 'trim|sanitize_string', 'param' => 's'), 'file_name' => array('var' => 'file_name', 'label' => 'File', 'desc' => 'File will be renamed based on what you enter in Display Name.', 'type' => 'file', 'std' => $stock_file->file_name, 'validate' => 'required', 'filter' => 'trim|sanitize_string', 'param' => 's'), 'hook_name' => array('var' => 'hook_name', 'label' => 'Hook Name', 'desc' => 'Use all lowercase with no space. Make it short but easy to remember.', 'type' => 'text', 'std' => $stock_file->hook_name, 'validate' => 'required|alpha_dash', 'filter' => 'trim|sanitize_string', 'param' => 's'));
    if (isset($_POST['submit'])) {
        $gump = new GUMP();
        foreach ($_POST['form'] as $k => $v) {
            $fields[$k]['std'] = $v;
            $stock_file->{$k} = $v;
            if (!empty($fields[$k]['validate'])) {
                $validate[$k] = $fields[$k]['validate'];
            }
            if (!empty($fields[$k]['filter'])) {
                $filter[$k] = $fields[$k]['filter'];
            }
        }
        $gump->validation_rules($validate);
        $gump->filter_rules($filter);
        $validated_data = $gump->run($_POST['form']);
        if ($validated_data === false) {
            $errors = $gump->get_readable_errors(false);
            $error_text = '';
            foreach ($errors as $error) {
                $error_text .= $error . '<br />';
            }
            echo edgimo_error($error_text);
        } else {
            $validated_data['hook_name'] = strtolower($validated_data['hook_name']);
            if (mysqli_connect_errno()) {
                printf("Connect failed: %s\n", mysqli_connect_error());
                exit;
            }
            if (!isset($validated_data['file_name'])) {
                $validated_data['file_name'] = '';
            }
            if ($_FILES['form']['name']['file_name'] !== '') {
                $uploaded_file = $_FILES['form']['name']['file_name'];
                $ext = pathinfo($uploaded_file, PATHINFO_EXTENSION);
                $validated_data['file_name'] = slugify($validated_data['display_name']) . '.' . $ext;
                if (move_uploaded_file($_FILES['form']['tmp_name']['file_name'], STOCK_FILES_DIR . $validated_data['file_name'])) {
                    echo edgimo_success("File uploaded as " . $validated_data['file_name'] . ".");
                } else {
                    echo edgimo_error("Sorry, there was a problem uploading your file.");
                }
            } else {
                if ($form_type == 'update') {
                    $validated_data['file_name'] = $stock_file->file_name;
                }
            }
            if ($form_type == 'update') {
                $query = $mysqli->prepare("UPDATE ashp_stock_files SET display_name=?, file_name=?, hook_name=? WHERE stock_file_id=?");
                $query->bind_param('sssi', $validated_data['display_name'], $validated_data['file_name'], $validated_data['hook_name'], $stock_file_id);
                $query->execute();
                $query->close();
                echo edgimo_success('Stock File details have been updated.');
                header('refresh: 1; URL=stockfiles.php');
            }
            if ($form_type == 'insert') {
                $query = $mysqli->prepare("INSERT INTO ashp_stock_files (display_name, file_name, hook_name) VALUES (?,?,?)");
                $query->bind_param('sss', $validated_data['display_name'], $validated_data['file_name'], $validated_data['hook_name']);
                $query->execute();
                $query->close();
                echo edgimo_success('New stock file added.');
                header('refresh: 1; URL=stockfiles.php');
            }
        }
    }
    $html .= '<form enctype="multipart/form-data" class="form-horizontal" role="form" method="post">';
    foreach ($fields as $field) {
        isset($errors) && array_key_exists($field['var'], $errors) ? $error = 'has-error' : ($error = '');
        $html .= '<div class="form-group ' . $error . '">';
        switch ($field['type']) {
            case 'text':
                if (!isset($type)) {
                    $type = 'text';
                }
                $html .= '
				<label class="col-lg-2 control-label" for="form[' . $field['var'] . ']">' . $field['label'] . '</label>
				<div class="col-lg-6">
					<input class="form-control" type="' . $type . '" name="form[' . $field['var'] . ']" value="' . $field['std'] . '">
				</div>';
                break;
//.........这里部分代码省略.........
开发者ID:edgimopeter,项目名称:ashp-cms,代码行数:101,代码来源:stockfiles_form.php


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