How to use check method of superglobals class

Best Atoum code snippet using superglobals.check

superglobals.php

Source:superglobals.php Github

copy

Full Screen

...65 return null;66 }67 unset($GLOBALS['languageLoader']);68 ob_start();69 if (superglobals_check_allowed() === false) {70 return null;71 }72 $superglobals_stylesheet = DIR_FS_CATALOG . 'includes/templates/template_default/css/superglobals.css';73 if (file_exists($superglobals_stylesheet)) {74 echo "\n" . '<style>' . file_get_contents($superglobals_stylesheet) . '</style>';75 }76 echo "\n" . '<div id="superglobals">' . "\n";77 echo '<h4>$GLOBALS:</h4>';78 superglobals_format($GLOBALS);79 if (SHOW_SUPERGLOBALS_GET_DEFINED_CONSTANTS === 'true') {80 echo '<h4>get_defined_constants()</h4>' . "\n";81 $defined_constants = get_defined_constants();82 superglobals_format($defined_constants, false, true);83 unset($defined_constants);84 }85 if (SHOW_SUPERGLOBALS_GET_INCLUDED_FILES === 'true'){86 echo '<h4>get_included_files()</h4>' . "\n";87 $included_files = get_included_files();88 superglobals_format($included_files, false, true);89 unset($included_files);90 }91 echo '<h4>The source of the Superglobals Plus script is subject to version 2.0 of the GPL license. Copyright: Paul Mathot, Haarlem The Netherlands.</h4>';92 echo '</div>' . "\n";93 $superglobals_buffer = ob_get_clean();94 if (SHOW_SUPERGLOBALS_POPUP !== 'false') {95 // add js popup script96 ob_start();97 //-bof-c-v1.4.4-torvista98 // -----99 // Stylesheet location depends on "environment" in which the plugin has been loaded. From the admin, it's in the base /includes100 // directory; from the storefront, it's in the template-specific CSS directory.101 //102 if (defined('SHOW_SUPERGLOBALS_FROM_ADMIN')) {103 $stylesheet_location = DIR_WS_INCLUDES . 'stylesheet_superglobals.css';104 } else {105 $stylesheet_location = $GLOBALS['template']->get_template_dir('.css', DIR_WS_TEMPLATE, $GLOBALS['current_page_base'], 'css') . '/stylesheet_superglobals.css';106 }107?>108<script>109 function superglobalspopup() {110 let newwindow=window.open('','name', 'status=yes, menubar=yes, scrollbars=1, fullscreen=1, resizable=1, toolbar=yes');111 let tmp = newwindow.document;112 tmp.write('<!doctype html>\n');113 tmp.write('<html <?php echo HTML_PARAMS; ?>>\n');114 tmp.write('<head>\n');115 tmp.write('<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>" />\n');116 tmp.write('<title>Superglobals Popup<\/title>\n');117 tmp.write('<link rel="stylesheet" href="<?php echo $stylesheet_location; ?>" />\n');118 tmp.write('<\/head><body>\n');119<?php120 $find = ["\r", "\r\n", "\n"]; //steve how to get carriage returns for better-looking html source?121 $replace = ['', '', '']; 122?>123 tmp.write('<?php echo addslashes(str_replace($find, $replace, $superglobals_buffer)) ; ?>\n');124 tmp.write('<\/body>\n<\/html>');125 tmp.close();126 }127 superglobalspopup();128</script>129<?php130 //-eof-c-v1.4.4-torvista131 $superglobals_buffer = ob_get_clean();132 }133 return $superglobals_buffer;134}135function superglobals_check_allowed()136{137 // -----138 // Indicate, initially, that the output should not be generated.139 //140 $is_enabled = false;141 // -----142 // If we're being called from the admin ...143 //144 if (defined('SHOW_SUPERGLOBALS_FROM_ADMIN')) {145 // -----146 // ... and the admin-display is enabled, indicate that the output should be generated.147 //148 if (SHOW_SUPERGLOBALS_ADMIN === 'true' && superglobals_ip_check()) {149 $is_enabled = true;150 }151 // -----152 // Otherwise, we're being called from the storefront ...153 //154 } else {155 // -----156 // ... if the storefront-display is enabled, indicate that the output should be generated.157 //158 if (SHOW_SUPERGLOBALS === 'true' && superglobals_ip_check()) {159 $is_enabled = true;160 }161 }162 return $is_enabled;163}164// -----165// Function, called from superglobals_check_allowed, that validates whether the plugin's output should166// be generated for the current IP address.167//168// Note: v2.1.0 and later of the plugin operates on Zen Cart notifications, but it's possible that the169// store's files have included an in-line call to generate that output ... and we don't want to double-up170// the output. This function sets a global variable to indicate that it's been run to prevent that171// double output.172//173function superglobals_ip_check()174{175 $ip_valid = false;176 if (!isset($GLOBALS['superglobals_output'])) {177 if (SHOW_SUPERGLOBALS_TO_ALL === 'true' || in_array(superglobals_get_ip_address(), explode(',', str_replace(' ', '', SHOW_SUPERGLOBALS_IP)))) {178 $ip_valid = true;179 }180 $GLOBALS['superglobals_output'] = true;181 }182 return $ip_valid;183}184function superglobals_format($superglobals_var, $recursion = false, $show_customvar = false)185{186 global $showQueryCache;187 // $recursion = FALSE => reset recursion if the function is not called (a second time) from itself188 static $recursionlevel, $toplevel_key, $class;189 if (!isset($recursionlevel) || $recursion === false) {190 $recursionlevel = 0;191 }192 if ($recursionlevel > (int)SHOW_SUPERGLOBALS_MAX_LEVEL && ((int)SHOW_SUPERGLOBALS_MAX_LEVEL) >= 1) {193 die('Superglobals message: Maximum recursion level exceeded! (Current recursion level:' . $recursionlevel . ')'); // basic recursion protection194 }195 $superglobals_var_type = '';196 if (is_array($superglobals_var)) {197 $superglobals_var_type = 'array';198 }199 if (is_object($superglobals_var)) {200 $superglobals_var_type = 'object';201 }202 if (!isset($class)) {203 $class = '';204 }205 if ($superglobals_var_type !== '') {206 $class = ' class="superglobals_' . $superglobals_var_type . '"';207 }208 // $tabs and $tabs_li are used for html source formatting only209 $tabs = "\n";210 $tabs .= str_repeat("\t", $recursionlevel + 1);211 $tabs_li = $tabs . "\t";212 if (is_object($superglobals_var) || (is_countable($superglobals_var) && count($superglobals_var) !== 0)) {213 $sg_exclusions = explode(',', SHOW_SUPERGLOBALS_EXCLUSIONS);214 echo $tabs . '<ul' . $class . '>';215 $numLineItems = 0;216 if (is_array($superglobals_var) || is_object($superglobals_var)) {217 foreach ($superglobals_var as $key => $v) {218 if ( (!$showQueryCache && $key === 'queryCache') || ($key !== 0 && in_array($key, $sg_exclusions)) ) continue;219 // store the top level key into $toplevel_key (used during recursion to determine if the value should be echoed or not)220 if ($recursionlevel === 0) {221 $toplevel_key = $key;222 }223 // check if toplevel_key starts with ....224 if (SHOW_SUPERGLOBALS_FILTER_HTTP === 'false' || !strstr($toplevel_key, 'HTTP_') == $toplevel_key) {225 if (SHOW_SUPERGLOBALS_ALL === 'true' 226 || $show_customvar 227 || ($toplevel_key === '_GET' && SHOW_SUPERGLOBALS_GET === 'true') 228 || ($toplevel_key === '_POST' && SHOW_SUPERGLOBALS_POST === 'true') 229 || ($toplevel_key === '_COOKIE' && SHOW_SUPERGLOBALS_COOKIE === 'true') 230 || ($toplevel_key === '_REQUEST' && SHOW_SUPERGLOBALS_REQUEST === 'true') 231 || ($toplevel_key === '_SESSION' && SHOW_SUPERGLOBALS_SESSION === 'true')232 || ($toplevel_key === '_SERVER' && SHOW_SUPERGLOBALS_SERVER === 'true') 233 || ($toplevel_key === '_ENV' && SHOW_SUPERGLOBALS_ENV === 'true')234 || ($toplevel_key === '_FILES' && SHOW_SUPERGLOBALS_FILES === 'true')) {235 $numLineItems++;236 switch (gettype($v)) {237 case 'array':238 echo $tabs_li;239 echo '<li class="superglobals_array">' . '<strong>' . $key . '</strong> <span class="superglobals_type">(array)</span>';240 if ($key === 'GLOBALS') {241 echo 'Superglobals message: recursion!';242 }243 $recursionlevel++;244 // $GLOBALS is recursive, prevent infinite loop245 if (!($key === 'GLOBALS')) {246 superglobals_format($v, true);247 }248 $recursionlevel--;249 echo '</li>';250 break;251 case 'object':252 echo $tabs_li;253 echo '<li class="superglobals_object">' . '<strong>' . $key . '</strong> <span class="superglobals_type">(object: '. get_class($v) . ')</span>';254 $recursionlevel++;255 superglobals_format($v, true);256 $recursionlevel--;257 echo '</li>';258 break;259 case 'resource':260 echo $tabs_li . '<li class="superglobals_resource"><strong>' . htmlspecialchars((string)$key, ENT_COMPAT, CHARSET) . '</strong> <span class="superglobals_type">(resource: ' . get_resource_type($v) . ')</span> =&gt; ' . htmlspecialchars((string)$v, ENT_COMPAT, CHARSET) . '</li>';261 break;262 case 'string':263 echo $tabs_li . '<li><strong>' . htmlspecialchars((string)$key, ENT_COMPAT, CHARSET) . '</strong> <span class="superglobals_type">(string)</span> =&gt; ' . htmlentities($v, ENT_COMPAT, CHARSET) . '</li>';264 break;265 default:266 echo $tabs_li . '<li><strong>' . $key . '</strong> <span class="superglobals_type">(' . gettype($v) . ')</span> =&gt; ' . htmlspecialchars((string) $v, ENT_COMPAT, CHARSET) . '</li>';267 break;268 } // end switch269 }270 } // end check if toplevel_key starts with ....271 } // end foreach272 }273 if ($numLineItems === 0) {274 echo $tabs_li . '<li>&nbsp;</li>';275 }276 echo $tabs . '</ul>';277 } else {278 echo $tabs . '<ul' . $class . '>';279//-bof-c-v1.4.4-torvista280 echo $tabs_li . '<li class="superglobals_empty">';281 if ($superglobals_var_type) {282 echo '<strong>' . $superglobals_var_type . '</strong> ';283 }284 echo 'Superglobals message: empty!</li>';...

Full Screen

Full Screen

Login.php

Source:Login.php Github

copy

Full Screen

...14 {15 echo $this->getRender()->render('loginView.twig');16 }17 /**18 * Function used to check connection datas and open a session19 *20 */21 public function connexion()22 {23 $superglobalsPost = $this->getSuperglobals()->get_POST();24 if (!empty($superglobalsPost['login']) && !empty($superglobalsPost['password'])) {;25 $user = new UserManager;26 $resultat = $user->checkLogin($superglobalsPost['login']);27 if (isset($resultat['login'], $resultat['password']) && $resultat['login'] == $superglobalsPost['login'] && password_verify($superglobalsPost['password'], $resultat['password'])) {28 session_start();29 $_SESSION['id'] = $resultat['id'];30 $_SESSION['login'] = $resultat['login'];31 $_SESSION['role'] = $resultat['role'];32 if ($_SESSION['role'] == "administrateur") {33 header('Location:/admin');34 } else {35 header('Location:/home');36 }37 } else {38 $failed = "Erreur login et/ou mot de passe";39 echo $this->getRender()->render('loginView.twig', ['failed' => $failed]);40 }41 } else {42 $failed = "Tous les champs sont requis";43 echo $this->getRender()->render('loginView.twig', ['failed' => $failed]);44 }45 }46 /**47 * Function used to create a user account and manage errors (duplicate, empty filed...)48 *49 */50 public function addUser()51 {52 $superglobals = $this->getSuperglobals()->get_POST();53 //errors management: check for validity before asking database54 if (!empty($superglobals)) {55 $errors = [];56 if (empty($superglobals['e_mail']) || !preg_match('/^[a-z0-9._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4}$/', $superglobals['e_mail'])) {57 $errors['e_mail'] = "Votre e-mail n'est pas valide";58 } else {59 $newUser = new UserManager;60 $resultat = $newUser->checkEmail($superglobals['e_mail']);61 if ($resultat) {62 $errors['e_mail'] = "Cet E-mail est déjà utilisé pour un autre compte.";63 }64 }65 if (empty($superglobals['login']) || !preg_match('/^[a-zA-Z0-9_]+$/', $superglobals['login'])) {66 $errors['login'] = "Votre login n'est pas valide. Merci d'utiliser uniquement des caractères alphanumériques.";67 } else {68 $newUser = new UserManager;69 $resultat = $newUser->checkLogin($superglobals['login']);70 if ($resultat) {71 $errors['login'] = "Ce login est déjà utilisé pour un autre compte.";72 }73 }74 if (empty($superglobals['password'])) {75 $errors['password'] = "Votre mot de passe n'est pas valide";76 }77 if (!empty($errors)) {78 echo $this->getRender()->render('loginView.twig', ['errors' => $errors]);79 }80 if (empty($errors)) {81 $superglobals['password'] = password_hash($superglobals['password'], PASSWORD_BCRYPT);82 $superglobals['role'] = "visiteur";83 $newUser->createUser($superglobals);...

Full Screen

Full Screen

check

Using AI Code Generation

copy

Full Screen

1$superglobals = new SuperGlobals();2$superglobals->check();3$superglobals = new SuperGlobals();4$superglobals->check();5$superglobals = new SuperGlobals();6$superglobals->check();7$superglobals = new SuperGlobals();8$superglobals->check();9$superglobals = new SuperGlobals();10$superglobals->check();11$superglobals = new SuperGlobals();12$superglobals->check();13$superglobals = new SuperGlobals();14$superglobals->check();15$superglobals = new SuperGlobals();16$superglobals->check();17$superglobals = new SuperGlobals();18$superglobals->check();19$superglobals = new SuperGlobals();20$superglobals->check();21$superglobals = new SuperGlobals();22$superglobals->check();23$superglobals = new SuperGlobals();24$superglobals->check();25$superglobals = new SuperGlobals();26$superglobals->check();27$superglobals = new SuperGlobals();28$superglobals->check();29$superglobals = new SuperGlobals();30$superglobals->check();

Full Screen

Full Screen

check

Using AI Code Generation

copy

Full Screen

1if (Superglobals::check('get', 'id')) {2 echo 'id is set';3} else {4 echo 'id is not set';5}6if (Superglobals::check('get', 'id')) {7 echo 'id is set';8} else {9 echo 'id is not set';10}11if (Superglobals::request_method('post')) {12 echo 'request method is POST';13} else {14 echo 'request method is not POST';15}16if (Superglobals::request_method('get')) {17 echo 'request method is GET';18} else {19 echo 'request method is not GET';20}21if (Superglobals::request_method('post')) {22 echo 'request method is POST';23} else {24 echo 'request method is not POST';25}26if (Superglobals::request_method('get')) {27 echo 'request method is GET';28} else {29 echo 'request method is not GET';30}31if (Superglobals::request_method('post')) {32 echo 'request method is POST';33} else {34 echo 'request method is not POST';35}36if (Superglobals::request_method('get')) {37 echo 'request method is GET';38} else {39 echo 'request method is not GET';40}41if (Superglobals::request_method('post')) {

Full Screen

Full Screen

check

Using AI Code Generation

copy

Full Screen

1if (Superglobals::check('post', 'submit')) {2 echo 'The form has been submitted';3}4if (Superglobals::check('get', 'id')) {5 echo 'The id has been passed';6}7if (Superglobals::check('cookie', 'username')) {8 echo 'The username has been passed';9}10if (Superglobals::check('session', 'username')) {11 echo 'The username has been passed';12}13if (Superglobals::check('server', 'username')) {14 echo 'The username has been passed';15}

Full Screen

Full Screen

check

Using AI Code Generation

copy

Full Screen

1$superglobals = new Superglobals();2if ($superglobals->check('POST', 'username')) {3 echo 'username is set';4} else {5 echo 'username is not set';6}7$superglobals = new Superglobals();8if ($superglobals->check('GET', 'username')) {9 echo 'username is set';10} else {11 echo 'username is not set';12}13$superglobals = new Superglobals();14if ($superglobals->check('COOKIE', 'username')) {15 echo 'username is set';16} else {17 echo 'username is not set';18}19$superglobals = new Superglobals();20if ($superglobals->check('SESSION', 'username')) {21 echo 'username is set';22} else {23 echo 'username is not set';24}25$superglobals = new Superglobals();26if ($superglobals->check('SERVER', 'username')) {27 echo 'username is set';28} else {29 echo 'username is not set';30}31$superglobals = new Superglobals();32if ($superglobals->check('REQUEST', 'username')) {33 echo 'username is set';34} else {35 echo 'username is not set';36}37$superglobals = new Superglobals();38if ($superglobals->check('FILES', 'username')) {39 echo 'username is set';40} else {41 echo 'username is not set';42}43$superglobals = new Superglobals();44if ($superglobals->check('ENV', 'username')) {45 echo 'username is set';46} else {47 echo 'username is not set';48}49$superglobals = new Superglobals();

Full Screen

Full Screen

check

Using AI Code Generation

copy

Full Screen

1if(Superglobals::check($_POST['name'])) {2 echo 'Value is set';3} else {4 echo 'Value is not set';5}6if(Superglobals::check($_GET['name'])) {7 echo 'Value is set';8} else {9 echo 'Value is not set';10}11if(Superglobals::check($_REQUEST['name'])) {12 echo 'Value is set';13} else {14 echo 'Value is not set';15}16if(Superglobals::check($_COOKIE['name'])) {17 echo 'Value is set';18} else {19 echo 'Value is not set';20}21if(Superglobals::check($_SESSION['name'])) {22 echo 'Value is set';23} else {24 echo 'Value is not set';25}26if(Superglobals::check($_SERVER['name'])) {27 echo 'Value is set';28} else {29 echo 'Value is not set';30}31if(Superglobals::check($_ENV['name'])) {32 echo 'Value is set';33} else {34 echo 'Value is not set';35}36if(Superglobals::check($_FILES['name'])) {37 echo 'Value is set';38} else {39 echo 'Value is not set';40}41if(Superglobals::check($_GLOBALS['name'])) {42 echo 'Value is set';43} else {44 echo 'Value is not set';45}46if(Superglobals::check($_FILES['name']['name'])) {47 echo 'Value is set';48} else {49 echo 'Value is not set';50}

Full Screen

Full Screen

check

Using AI Code Generation

copy

Full Screen

1$superGlobals = new SuperGlobals();2if($superGlobals->check('get', 'name')){3 echo 'Name is set';4}else{5 echo 'Name is not set';6}7$superGlobals = new SuperGlobals();8echo $superGlobals->get('get', 'name');9$superGlobals = new SuperGlobals();10$superGlobals->set('post', 'name', 'John');11$superGlobals = new SuperGlobals();12$superGlobals->delete('post', 'name');13$superGlobals = new SuperGlobals();14echo $superGlobals->all('get');15$superGlobals = new SuperGlobals();16$superGlobals->clear('get');17$superGlobals = new SuperGlobals();18$superGlobals->dump('get');19$superGlobals = new SuperGlobals();20if($superGlobals->has('get', 'name')){21 echo 'Name is set';22}else{23 echo 'Name is not set';24}25$superGlobals = new SuperGlobals();26if($superGlobals->hasAll('get', ['name', 'age'])){27 echo 'Name and age are set';28}else{29 echo 'Name and age are not set';30}31$superGlobals = new SuperGlobals();32if($superGlobals->hasAny('get', ['name', 'age'])){33 echo 'Name or age is set';34}else{35 echo 'Name or age is not set';36}37$superGlobals = new SuperGlobals();38print_r($superGlobals->keys('get'));

Full Screen

Full Screen

check

Using AI Code Generation

copy

Full Screen

1$superglobals = new Superglobals();2if ($superglobals->check('POST', 'submit')) {3} else {4}5$superglobals = new Superglobals();6if ($superglobals->check('GET', 'submit')) {7} else {8}

Full Screen

Full Screen

check

Using AI Code Generation

copy

Full Screen

1require_once('superglobals.class.php');2$s = new superglobals();3if ($s->check('name', 'post')) {4 echo 'name is set';5} else {6 echo 'name is not set';7}8$s->check('name', 'get');9$s->check('name', 'cookie');10$s->check('name', 'session');11$s->check('name', 'server');12$s->check('name', 'files');13$s->check('name', 'env');14$s->check('name', 'request');15$s->check('name', 'globals');16$s->check('name', 'http');17$s->check('name', 'https');

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Atoum automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in superglobals

Trigger check code on LambdaTest Cloud Grid

Execute automation tests with check on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful