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


PHP GUMP::filter_rules方法代码示例

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


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

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

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

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

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

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

示例9: user_form

function user_form($user_id = 0)
{
    global $mysqli;
    global $user;
    if ($user_id) {
        $form_user = new User(get_user_email_by_id($user_id));
        $form_type = 'update';
        if ($form_user->email != $_SESSION['email'] && !$user->is_allowed('edit_ashp_users')) {
            echo edgimo_error('Your user role (' . $user->role . ') is not allowed to make edits on this page.');
            return;
        }
    } else {
        if (!$user->is_allowed('add_user')) {
            echo edgimo_error('Your user role (' . $user->role . ') is not allowed to add users.');
            return;
        }
        $form_user = new User();
        $form_type = 'insert';
    }
    $html = '';
    $fields = array('first_name' => array('var' => 'first_name', 'label' => 'First Name', 'type' => 'text', 'std' => $form_user->first_name, 'validate' => 'required|valid_name', 'filter' => 'trim|sanitize_string', 'param' => 's', 'desc' => ''), 'last_name' => array('var' => 'last_name', 'label' => 'Last Name', 'type' => 'text', 'std' => $form_user->last_name, 'validate' => 'required|valid_name', 'filter' => 'trim|sanitize_string', 'param' => 's', 'desc' => ''), 'email' => array('var' => 'email', 'label' => 'Email', 'type' => 'text', 'std' => $form_user->email, 'validate' => 'required|valid_email', 'filter' => 'trim|sanitize_string', 'param' => 's', 'desc' => ''), 'password' => array('var' => 'password', 'label' => 'Password', 'type' => 'password', 'std' => '', 'validate' => 'required', 'filter' => '', 'param' => 's', 'desc' => ''));
    if ($user->is_allowed('change_roles')) {
        $fields['role'] = array('var' => 'role', 'label' => 'Role', 'type' => 'select', 'options' => unserialize(ROLES), 'std' => $form_user->role, 'validate' => 'required', 'filter' => 'trim|sanitize_string', 'param' => 's', 'desc' => '');
    }
    //special instructions for updating password
    if ($form_type == 'update') {
        $fields['password']['desc'] = 'Only enter a new password here if you wish to update the existing password';
    }
    if (isset($_POST['submit'])) {
        $gump = new GUMP();
        //password can be left blank when updating account. If it is, just plug in the saved value
        if ($form_type == 'update') {
            if ($_POST['form']['password'] === '') {
                $_POST['form']['password'] = $form_user->password;
            }
        }
        //add values to the validate and filter gump arrays
        foreach ($_POST['form'] as $k => $v) {
            //update the std value for form output below
            $fields[$k]['std'] = $v;
            if (!empty($fields[$k]['validate'])) {
                $validate[$k] = $fields[$k]['validate'];
            }
            if (!empty($fields[$k]['filter'])) {
                $filter[$k] = $fields[$k]['filter'];
            }
        }
        //run gump
        $gump->validation_rules($validate);
        $gump->filter_rules($filter);
        //get validated data
        $validated_data = $gump->run($_POST['form']);
        if (empty($validated_data['role'])) {
            $validated_data['role'] = $form_user->role;
        }
        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 {
            if (mysqli_connect_errno()) {
                printf("Connect failed: %s\n", mysqli_connect_error());
                exit;
            }
            if ($form_type == 'update') {
                $query = $mysqli->prepare("UPDATE ashp_users SET first_name=?, last_name=?, email=?, role=?, password=? WHERE user_id=?");
                $password = sha1($validated_data['password']);
                $query->bind_param('sssssi', $validated_data['first_name'], $validated_data['last_name'], $validated_data['email'], $validated_data['role'], $password, $form_user->user_id);
                echo edgimo_success('Account details have been updated.');
            }
            if ($form_type == 'insert') {
                $query = $mysqli->prepare("INSERT INTO ashp_users (email, first_name, last_name, password, role, status) VALUES (?,?,?,?,?,?)");
                $password = sha1($validated_data['password']);
                $status = 'active';
                $query->bind_param('ssssss', $validated_data['email'], $validated_data['first_name'], $validated_data['last_name'], $password, $validated_data['role'], $status);
                echo edgimo_success('New user created.');
            }
            $query->execute();
            $query->close();
            $new_user = new User($validated_data['email']);
            $user_vars = get_object_vars($new_user);
            echo '<script>table_insert(' . json_encode($user_vars) . ');</script>';
        }
    }
    $html .= '<form 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 'password':
                $type = 'password';
                $field['std'] = '';
            case 'text':
                if (!isset($type)) {
                    $type = 'text';
                }
                $html .= '
//.........这里部分代码省略.........
开发者ID:edgimopeter,项目名称:ashp-cms,代码行数:101,代码来源:user_form.php

示例10: diy_addorg

function diy_addorg($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();
    $up = json_decode(base64_decode($payload));
    $client_id = $up->client_id;
    $org = OAuth2\Request::createFromGlobals()->request["org"];
    $org_desc = OAuth2\Request::createFromGlobals()->request["org_desc"];
    $diy_error["post"]["org"] = $org;
    $diy_error["post"]["org_desc"] = $org_desc;
    $post["org"] = $org;
    //organisation					oauth_devices
    $post["org_desc"] = $org_desc;
    //mia perigrafi oti thelei o christis		oauth_devices
    $gump = new GUMP();
    $gump->validation_rules(array('org' => 'required|alpha_numeric', 'org_desc' => 'required|max_len,100'));
    $gump->filter_rules(array('org' => 'trim|sanitize_string', 'org_desc' => '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 {
        //check if device name exists
        $stmt = $storage->prepare('SELECT * FROM oauth_organisations WHERE organisation = :org');
        $stmt->execute(array('org' => trim($org)));
        $row = $stmt->fetch(PDO::FETCH_ASSOC);
        if ($row) {
            $result["result"]["error"] = ExceptionMessages::OrgExist . " , " . ExceptionCodes::OrgExist;
        } else {
            try {
                // oauth_organisation table
                $stmt2 = $storage->prepare('INSERT INTO oauth_organisations (organisation, client_id, desc) VALUES (:org, :client_id, :desc)');
                $stmt2->execute(array('client_id' => $client_id, 'org' => $org, 'desc' => $org_desc));
                // scopes gia devices
                $scope = $org;
                $is_default = 0;
                $stmt3 = $storage->prepare('INSERT INTO oauth_scopes (scope, is_default) VALUES (:scope, :is_default)');
                $stmt3->execute(array('scope' => $scope, 'is_default' => $is_default));
                $scope = $org . "_dev";
                $is_default = 0;
                $stmt3 = $storage->prepare('INSERT INTO oauth_scopes (scope, is_default) VALUES (:scope, :is_default)');
                $stmt3->execute(array('scope' => $scope, 'is_default' => $is_default));
                $scope = $org . "_dpri";
                $is_default = 0;
                $stmt3 = $storage->prepare('INSERT INTO oauth_scopes (scope, is_default) VALUES (:scope, :is_default)');
                $stmt3->execute(array('scope' => $scope, 'is_default' => $is_default));
                $scope = $org . "_org";
                $is_default = 0;
                $stmt3 = $storage->prepare('INSERT INTO oauth_scopes (scope, is_default) VALUES (:scope, :is_default)');
                $stmt3->execute(array('scope' => $scope, 'is_default' => $is_default));
                $scope = $org . "_dpub";
                $is_default = 0;
                $stmt3 = $storage->prepare('INSERT INTO oauth_scopes (scope, is_default) VALUES (:scope, :is_default)');
                $stmt3->execute(array('scope' => $scope, 'is_default' => $is_default));
                // scopes gia users
                $scope = $org . "_view";
                $is_default = 0;
                $stmt3 = $storage->prepare('INSERT INTO oauth_scopes (scope, is_default) VALUES (:scope, :is_default)');
                $stmt3->execute(array('scope' => $scope, 'is_default' => $is_default));
                $scope = $org . "_devel";
                $is_default = 0;
                $stmt3 = $storage->prepare('INSERT INTO oauth_scopes (scope, is_default) VALUES (:scope, :is_default)');
                $stmt3->execute(array('scope' => $scope, 'is_default' => $is_default));
                $scope = $org . "_admin";
                $is_default = 0;
                $stmt3 = $storage->prepare('INSERT INTO oauth_scopes (scope, is_default) VALUES (:scope, :is_default)');
                $stmt3->execute(array('scope' => $scope, 'is_default' => $is_default));
                $stmt6 = $storage->prepare('SELECT * FROM oauth_clients WHERE client_id = :client_id');
                $stmt6->execute(array('client_id' => trim($client_id)));
                $row6 = $stmt6->fetch(PDO::FETCH_ASSOC);
                if ($row6) {
                    $scope6 = $row6["scope"];
                    $scope6 .= " " . $org . "_admin";
                    $scope6 .= " " . $org . "_view";
                    $stmt5 = $storage->prepare('UPDATE oauth_clients  set scope = :scope6 where client_id = :client_id');
                    $stmt5->execute(array('scope6' => $scope6, 'client_id' => $client_id));
                }
                //result_messages===============================================================
                $result["result"]["result"] = $post;
                $result["result"]["session"] = $session;
                $result["error"] = $error;
                $result["status"] = "200";
                $result["message"] = "[" . $result["method"] . "][" . $result["function"] . "]: NoErrors";
            } catch (Exception $e) {
                $result["status"] = $e->getCode();
                $result["message"] = "[" . $result["method"] . "][" . $result["function"] . "]:" . $e->getMessage();
            }
        }
    }
    if (diyConfig::read('debug') == 1) {
        $result["debug"] = $diy_error;
    }
    return $result;
}
开发者ID:pantnik,项目名称:DIYiotServer,代码行数:100,代码来源:diy_Addorg.php

示例11: GUMP

$form_saved = false;
if (isset($_POST['submit'])) {
    $gump = new GUMP();
    foreach ($_POST['form'] as $k => $v) {
        //update the std value for form output below
        $fields[$k]['std'] = $v;
        $saved->{$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']);
    $error_text = '';
    $privatekey = "6Lepf-gSAAAAAEE3oZNbZJE0FvuD4gtkQ04gZkAL";
    $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
    if (!$resp->is_valid) {
        $validated_data = false;
        $error_text .= $resp->error . '<br />';
    }
    if ($validated_data === false) {
        $errors = $gump->get_readable_errors(false);
        foreach ($errors as $error) {
            $error_text .= $error . '<br />';
        }
        $html .= '<div class="alert alert-danger"><p>' . $error_text . '</p></div>';
    } else {
开发者ID:edgimopeter,项目名称:ashp-cms,代码行数:31,代码来源:index.php

示例12: diy_register

function diy_register()
{
    global $app, $diy_storage;
    $result["controller"] = __FUNCTION__;
    $result["function"] = substr($app->request()->getPathInfo(), 1);
    $result["method"] = $app->request()->getMethod();
    $params = loadParameters();
    $client_id = $params["client_id"];
    $client_secret = $params["client_secret"];
    $firstname = $params["first_name"];
    $lastname = $params["last_name"];
    $email = $params["email"];
    $post["client_id"] = $client_id;
    $post["client_secret"] = $client_secret;
    $post["firstname"] = $firstname;
    $post["lastname"] = $lastname;
    $post["email"] = $email;
    foreach ($post as $curKey => $curValue) {
        $diy_error["post"][$curKey] = $curValue;
    }
    $gump = new GUMP();
    $gump->validation_rules(array('client_id' => 'required|alpha_numeric', 'client_secret' => 'required|alpha_numeric', 'firstname' => 'required|alpha_numeric', 'lastname' => 'required|alpha_numeric', 'email' => 'required|valid_email'));
    $gump->filter_rules(array('client_id' => 'trim|sanitize_string', 'client_secret' => 'trim|sanitize_string', 'firstname' => 'trim|sanitize_string', 'lastname' => 'trim|sanitize_string', 'email' => '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);
    }
    try {
        if (count($result["parse_errors"]) <= 0) {
            $storage = $diy_storage();
            $lastkey = $storage->query('SELECT user_id FROM oauth_users ORDER BY user_id DESC LIMIT 1');
            foreach ($lastkey as $curRow) {
                $lastkey = intval($curRow[0]);
            }
            $code = md5($post["firstname"] . $post["lastname"] . $post["email"]);
            // Create user
            $storage->query('INSERT INTO oauth_users (user_id, first_name, last_name, email, email_verified, email_ver_code)
        VALUES (' . ($lastkey + 1) . ', "' . $post["firstname"] . '", "' . $post["lastname"] . '", "' . $post["email"] . '", 0, "' . $code . '")');
            $user_id = $storage->lastInsertId();
            // Create client
            $publicKey = file_get_contents('../../ssh/CLIENT_ID1_pubkey.pem');
            $privateKey = file_get_contents('../../ssh/CLIENT_ID1_privkey.pem');
            $storage->query('INSERT INTO oauth_clients (client_id, client_secret, scope, user_id) VALUES ("' . $post["client_id"] . '", "' . $post["client_secret"] . '", "main", ' . $user_id . ')');
            $client_id = $storage->lastInsertId();
            $storage->query('INSERT INTO oauth_public_keys (client_id, public_key, private_key, encryption_algorithm) VALUES ("' . $post["client_id"] . '", "' . $publicKey . '", "' . $privateKey . '", "RS256")');
            // Send email
            $mailserver = diyConfig::read('mail.smtpserver');
            $mailserverport = diyConfig::read('mail.smtpport');
            $mailfrom = diyConfig::read('mail.fromuser');
            $link = 'https://' . $_SERVER['HTTP_HOST'] . '/api/activate/' . $code;
            $transport = Swift_SmtpTransport::newInstance($mailserver, $mailserverport);
            $mailer = Swift_Mailer::newInstance($transport);
            $message = Swift_Message::newInstance('Wonderful Subject')->setFrom(array($mailfrom => 'Diyiot'))->setTo(array($post["email"]))->setSubject('Welcome to diyiot')->setBody('Hi ' . $post["firstname"] . ',<BR /><BR />To active your account please click the following link <a href="' . $link . '">' . $link . '</a>.', 'text/html', 'UTF-8');
            $mailer->send($message);
        }
        //result_messages===============================================================
        $result["result"]["user_id"] = $user_id;
        $result["error"] = $error;
        $result["status"] = "200";
        $result["message"] = "[" . $result["method"] . "][" . $result["function"] . "]: NoErrors";
    } catch (Exception $e) {
        $result["status"] = $e->getCode();
        $result["message"] = "[" . $result["method"] . "][" . $result["function"] . "]:" . $e->getMessage();
        if (isset($user_id)) {
            $storage->query('DELETE FROM oauth_users WHERE user_id = ' . $user_id);
        }
    }
    if (diyConfig::read('debug') == 1) {
        $result["debug"] = $diy_error;
    }
    return $result;
}
开发者ID:pantnik,项目名称:DIYiotServer,代码行数:73,代码来源:diy_register.php

示例13: diy_adddevice

function diy_adddevice($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();
    $up = json_decode(base64_decode($payload));
    $client_id = $up->client_id;
    $userscope = $up->scope;
    $org = OAuth2\Request::createFromGlobals()->request["org"];
    $device = OAuth2\Request::createFromGlobals()->request["device"];
    $client_secret = OAuth2\Request::createFromGlobals()->request["passwd"];
    $device_desc = OAuth2\Request::createFromGlobals()->request["device_desc"];
    $diy_error["post"]["org"] = $org;
    $diy_error["post"]["device"] = $device;
    $diy_error["post"]["client_secret"] = $client_secret;
    $diy_error["post"]["device_desc"] = $device_desc;
    $post["org"] = $org;
    //organisation					oauth_devices
    $post["device"] = $device;
    // to client_id tou device			oauth_devices	oauth_clients	oauth_public_keys
    $post["client_secret"] = $client_secret;
    //mia perigrafi oti thelei o christis		oauth_devices
    $post["device_desc"] = $device_desc;
    //mia perigrafi oti thelei o christis		oauth_devices
    //$result["result"]["up"] =  $up;
    $gump = new GUMP();
    $gump->validation_rules(array('org' => 'required|alpha_numeric', 'device' => 'required|alpha_numeric', 'client_secret' => 'required|max_len,100|min_len,6', 'device_desc' => 'required|max_len,100'));
    $gump->filter_rules(array('org' => 'trim|sanitize_string', 'device' => 'trim|sanitize_string', 'client_secret' => 'trim', 'device_desc' => '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 {
        //check if org name exists
        $orgexists = "no";
        $stmtorg = $storage->prepare('SELECT * FROM oauth_organisations WHERE organisation = :org');
        $stmtorg->execute(array('org' => trim($org)));
        $roworg = $stmtorg->fetch(PDO::FETCH_ASSOC);
        if ($roworg) {
            $orgexists = "yes";
            //$result["result"]["error"] =  ExceptionMessages::OrgExist." , ". ExceptionCodes::OrgExist;
            $orgadmin = "no";
            $orgowner = "no";
            $userscopes = explode(' ', trim($userscope));
            $orgscope = $org . "_admin";
            for ($i = 0; $i <= count($userscopes); $i++) {
                if (trim($userscopes[$i]) == $orgscope) {
                    $orgadmin = "yes";
                }
            }
            if ($orgadmin == "no") {
                //check if org name exists and client_id
                $stmtorg1 = $storage->prepare('SELECT * FROM oauth_organisations WHERE organisation = :org and client_id = :client_id');
                $stmtorg1->execute(array('org' => trim($org), 'client_id' => $client_id));
                $roworg1 = $stmtorg1->fetch(PDO::FETCH_ASSOC);
                if (!$roworg1) {
                    $result["result"]["error"] = ExceptionMessages::OrgOwner . " , " . ExceptionCodes::OrgOwner;
                } else {
                    $orgowner = "yes";
                }
            }
        } else {
            $result["result"]["error"] = ExceptionMessages::OrgNotExist . " , " . ExceptionCodes::OrgNotExist;
        }
        //check if device name exists
        $orgdeviceexists = "no";
        $stmt = $storage->prepare('SELECT client_id  FROM oauth_clients WHERE client_id = :device');
        $stmt->execute(array('device' => trim($device)));
        $row = $stmt->fetch(PDO::FETCH_ASSOC);
        if ($row) {
            $result["result"]["error"] = ExceptionMessages::DeviceExist . " , " . ExceptionCodes::DeviceExist;
            $orgdeviceexists = "yes";
        }
        if ($orgexists == "yes" && ($orgowner == "yes" || $orgadmin == "yes") && $orgdeviceexists == "no") {
            //}else{
            try {
                $tempfile = tempnam('tmp/', '');
                if (file_exists($tempfile)) {
                    unlink($tempfile);
                }
                mkdir($tempfile);
                if (is_dir($tempfile)) {
                    exec("openssl genrsa -out {$tempfile}/{$client_id}-privkey.pem 2048");
                    exec("openssl rsa -in {$tempfile}/{$client_id}-privkey.pem -pubout -out {$tempfile}/{$client_id}-pubkey.pem");
                    $publicKey = file_get_contents("{$tempfile}/{$client_id}-pubkey.pem");
                    $privateKey = file_get_contents("{$tempfile}/{$client_id}-privkey.pem");
                    // oauth_public_keys table
                    $encryption_algorithm = "RS256";
                    $stmt5 = $storage->prepare('INSERT INTO oauth_public_keys (client_id, public_key, private_key, encryption_algorithm) VALUES (:client_id, :public_key, :private_key, :encryption_algorithm)');
                    $stmt5->execute(array('client_id' => $device, 'public_key' => $publicKey, 'private_key' => $privateKey, ':encryption_algorithm' => $encryption_algorithm));
                    unlink("{$tempfile}/{$client_id}-pubkey.pem");
                    unlink("{$tempfile}/{$client_id}-privkey.pem");
                    // na ftiaxo to key me tis portes na einai etoimo
                    // tha to kano messo cron
                    // o pinakas ta echei ola oauth_clients
//.........这里部分代码省略.........
开发者ID:pantnik,项目名称:DIYiotServer,代码行数:101,代码来源:diy_Adddevice.php

示例14: process_submission

 public static function process_submission()
 {
     require_once 'gump.class.php';
     $gump = new GUMP();
     $_POST = $gump->sanitize($_POST);
     global $a;
     $a = AC::load_current_activity();
     if (isset($_POST['waitlist-submit'])) {
         AC::generate_waitlist_fields();
         require_once 'wp-content/themes/vetri-master/lib/ReCaptcha/autoload.php';
         $recaptcha = new \ReCaptcha\ReCaptcha('6LendQoTAAAAABQzKPl_3sLPQQkTKMW4DBnIP37R', new \ReCaptcha\RequestMethod\Curl());
         $resp = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
         if (!$resp->isSuccess()) {
             AC::$errors['recaptcha'] = 'Please verify using the ReCaptcha widget';
             return false;
         }
     } else {
         if (AC::is_active_timer_expired()) {
             AC::$errors[] = 'Your timer has expired. Please start over.';
             AC::reset_all();
             return false;
         }
         AC::generate_fields();
         $step = $_POST['step'];
         foreach ($_POST['form'] as $k => $v) {
             $_SESSION['edgimo-reservation-form']['step-' . $step][$k] = $v;
         }
     }
     if (isset($_POST['activity-center-back'])) {
         $_SESSION['edgimo-reservation-form']['current-step']--;
         if (AC::get_current_step() === 1) {
             AC::reset_timer();
         }
         return true;
     }
     $validation = array();
     $filter = array();
     foreach ($_POST['form'] as $field_name => $field_value) {
         if (isset(AC::$fields[$field_name]['validate'])) {
             $validation[$field_name] = AC::$fields[$field_name]['validate'];
         }
         if (isset(AC::$fields[$field_name]['filter'])) {
             $filter[$field_name] = AC::$fields[$field_name]['filter'];
         }
     }
     $gump->validation_rules($validation);
     $gump->filter_rules($filter);
     $validated_data = $gump->run($_POST['form']);
     if (isset($step) && $step == 1 && !isset($validated_data['terms'])) {
         AC::$errors['terms'] = 'You must agree to the terms of registration in order to register for an event.  If you have questions about the terms, please feel free to contact us at <a href="mailto:' . $a->service_email . '">' . $a->service_email . '</a>';
         return false;
     }
     if ($validated_data === false) {
         $temp = $gump->get_readable_errors();
         $i = 0;
         foreach ($gump->validate($_POST['form'], $validation) as $error) {
             AC::$errors[$error['field']] = $temp[$i];
             $i++;
         }
         return false;
     }
     if (isset($_POST['waitlist-submit'])) {
         $new_waitlist = wp_insert_post(array('post_name' => $validated_data['name'], 'post_title' => $validated_data['name'], 'post_type' => 'waitlist', 'post_status' => 'publish'));
         $meta = array('_waitlist_activity' => $validated_data['activity_id'], '_waitlist_created' => time(), '_waitlist_name' => $validated_data['name'], '_waitlist_desired_seats' => $validated_data['desired_seats'], '_waitlist_phone' => $validated_data['phone_1'] . $validated_data['phone_2'] . $validated_data['phone_3'], '_waitlist_email' => $validated_data['email'], '_waitlist_code' => md5(time() . rand() . $validated_data['name']), '_waitlist_redeemed' => 'false');
         foreach ($meta as $k => $v) {
             add_post_meta($new_waitlist, $k, $v, true);
         }
         require_once 'wp-content/themes/vetri-master/lib/phpmailer/PHPMailerAutoload.php';
         AC::send_admin_waitlist_email($new_waitlist);
         AC::send_waitlist_confirmation_email($new_waitlist);
         $_SESSION['edgimo-reservation-form']['waitlist-success'] = $new_waitlist;
         wp_redirect(AC::get_redirect_url());
         exit;
     }
     switch ($step) {
         case 1:
             //check to see if the capacity went down after submitting registrant count
             if ($a->seats_available < AC::load_saved_data('number_of_registrants') && !AC::current_user_has_pending_reservation() && !AC::valid_waitlist_code()) {
                 AC::$errors['number_of_registrants'] = 'The number of registrants you selected is no longer available. Please select again.';
                 return false;
             }
             $_SESSION['edgimo-reservation-form']['current-step'] = 2;
             //in case user clicked back using browser and not button, pending data will still exist. delete it
             if (AC::current_user_has_pending_reservation()) {
                 AC::reset_timer();
             }
             //by now any old pending data should be gone
             //always initiate a new timer when step 1 is submitted
             AC::init_timer();
             break;
         case 2:
             $_SESSION['edgimo-reservation-form']['current-step'] = 3;
             break;
         case 3:
             $values = AC::get_all_final_values();
             $result = AC::process_transaction($values);
             if ($result['success']) {
                 $new_reservation = wp_insert_post(array('post_name' => $values['registrant_1_last_name'] . ', ' . $values['registrant_1_first_name'], 'post_title' => $values['registrant_1_last_name'] . ', ' . $values['registrant_1_first_name'], 'post_type' => 'reservation', 'post_status' => 'publish'));
                 isset($values['donation']) ? $values['donation'] = $values['donation'] : ($values['donation'] = 0);
                 $meta = array('_reservation_activity' => $a->ID, '_reservation_created' => time(), '_reservation_total' => AC::get_total(), '_reservation_fee' => $a->fee * $values['number_of_registrants'], '_reservation_gratuity' => AC::calculate_gratuity(), '_reservation_tax' => AC::calculate_tax(), '_reservation_donation' => $values['donation'], '_reservation_registrant_count' => $values['number_of_registrants'], '_reservation_optin' => $values['optin'], '_reservation_billing_first_name' => $values['billing_first_name'], '_reservation_billing_last_name' => $values['billing_last_name'], '_reservation_billing_address' => $values['billing_address'], '_reservation_billing_phone' => $values['billing_phone'], '_reservation_billing_city' => $values['billing_city'], '_reservation_billing_state' => $values['billing_state'], '_reservation_billing_zip' => $values['billing_zip'], '_reservation_transaction_id' => $result['RefNum'], '_reservation_auth_code' => $result['AuthCode'], '_reservation_card_type' => AC::card_type($values['cc_number']), '_reservation_last4' => $result['Last4']);
//.........这里部分代码省略.........
开发者ID:edgimopeter,项目名称:ActivityCenter,代码行数:101,代码来源:Activity_Center.class.php

示例15: diy_movedevice

function diy_movedevice($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();
    $up = json_decode(base64_decode($payload));
    $client_id = $up->client_id;
    $userscope = $up->scope;
    $device = OAuth2\Request::createFromGlobals()->query["device"];
    $orgto = OAuth2\Request::createFromGlobals()->query["orgto"];
    $diy_error["post"]["device"] = $device;
    $diy_error["post"]["orgto"] = $orgto;
    $post["device"] = $device;
    // to client_id tou device			oauth_devices	oauth_clients	oauth_public_keys
    $post["orgto"] = $orgto;
    // to client_id tou device			oauth_devices	oauth_clients	oauth_public_keys
    //$result["result"]["up"] =  $up;
    $gump = new GUMP();
    $gump->validation_rules(array('device' => 'required|alpha_numeric', 'orgto' => 'required|alpha_numeric'));
    $gump->filter_rules(array('device' => 'trim|sanitize_string', 'orgto' => '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 {
        $movedevice = "no";
        $dev = $storage->prepare('SELECT * FROM oauth_devices WHERE device  = :device');
        $dev->execute(array('device' => trim($device)));
        $rowdev = $dev->fetch(PDO::FETCH_ASSOC);
        if ($rowdev) {
            $org = $rowdev["organisation"];
        } else {
            $result["result"]["error"] = ExceptionMessages::DeviceNotExist . " , " . ExceptionCodes::DeviceNotExist;
        }
        function check($storage, $userscopes, $org, $client_id, $device)
        {
            //check if org name exists
            $orgexists = "no";
            $stmtorg = $storage->prepare('SELECT * FROM oauth_organisations WHERE organisation = :org');
            $stmtorg->execute(array('org' => trim($org)));
            $roworg = $stmtorg->fetch(PDO::FETCH_ASSOC);
            if ($roworg) {
                $orgexists = "yes";
                //$result["result"]["error"] =  ExceptionMessages::OrgExist." , ". ExceptionCodes::OrgExist;
                $orgadmin = "no";
                $orgowner = "no";
                $userscopes = explode(' ', trim($userscope));
                $orgscope = $org . "_admin";
                for ($i = 0; $i <= count($userscopes); $i++) {
                    if (trim($userscopes[$i]) == $orgscope) {
                        $orgadmin = "yes";
                    }
                }
                if ($orgadmin == "no") {
                    //check if org name exists and client_id
                    $stmtorg1 = $storage->prepare('SELECT * FROM oauth_organisations WHERE organisation = :org and client_id = :client_id');
                    $stmtorg1->execute(array('org' => trim($org), 'client_id' => $client_id));
                    $roworg1 = $stmtorg1->fetch(PDO::FETCH_ASSOC);
                    if (!$roworg1) {
                        $result["result"]["error"] = ExceptionMessages::OrgOwner . " , " . ExceptionCodes::OrgOwner;
                    } else {
                        $orgowner = "yes";
                    }
                }
            } else {
                $result["result"]["error"] = ExceptionMessages::OrgNotExist . " , " . ExceptionCodes::OrgNotExist;
            }
            //check if device name exists
            $orgdeviceexists = "no";
            $stmt = $storage->prepare('SELECT client_id  FROM oauth_clients WHERE client_id = :device');
            $stmt->execute(array('device' => trim($device)));
            $row = $stmt->fetch(PDO::FETCH_ASSOC);
            if ($row) {
                //$result["result"]["error"] =  ExceptionMessages::DeviceExist." , ". ExceptionCodes::DeviceExist;
                $orgdeviceexists = "yes";
            } else {
                $result["result"]["error"] = ExceptionMessages::DeviceNotExist . " , " . ExceptionCodes::DeviceNotExist;
                $orgdeviceexists = "no";
            }
            if ($orgexists == "yes" && ($orgowner == "yes" || $orgadmin == "yes") && $orgdeviceexists == "yes") {
                $result["result"]["check"] = "ok";
                return $result;
            } else {
                $result["result"]["check"] = "no";
                return $result;
            }
        }
        $diy_error["error"]["check"] = check($storage, $userscopes, $org, $client_id, $device);
        // check if user owned the devices or have admin scope in orgfrom
        $checkr = check($storage, $userscopes, $org, $client_id, $device);
        if ($checkr["result"]["check"] == "ok") {
            $diy_error["error"]["orgfrom"] = "ok";
            // check if user owned the devices or have admin scope in orgto
            $checkr1 = check($storage, $userscopes, $orgto, $client_id, $device);
            if ($checkr1["result"]["check"] == "ok") {
//.........这里部分代码省略.........
开发者ID:pantnik,项目名称:DIYiotServer,代码行数:101,代码来源:diy_movedevice.php


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