/** * function for checking if your are denying people * from e.g. admin areas of your module. */ function dev_test_access($options = null) { $files = file::getFileListRecursive(conf::pathModules(), "*module.php"); foreach ($files as $val) { $class_path = "modules" . str_replace(conf::pathModules(), '', $val); $class_path = str_replace('.php', '', $class_path); $class = str_replace('/', "\\", $class_path); $ary = get_class_methods($class); if (!is_array($ary)) { continue; } $call_paths = dev_get_actions($ary, $class_path); foreach ($call_paths as $path) { $url = conf::getSchemeWithServerName() . "{$path}"; $curl = new mycurl($url); $curl->createCurl(); echo $curl->getHttpStatus(); common::echoMessage(" Status code recieved on: {$url}"); } } }
<?php include_once "vendor/autoload.php"; use diversen\mycurl; use diversen\conf; conf::setMainIni('base_path', realpath('.')); $c = new mycurl('http://coscms/account/login/index'); $fields = array('email' => 'test', 'password' => 'test', 'submit_account_login' => 'Send'); $c->setPost($fields); $c->createCurl(); echo $c->getWebPage();
/** * Make an API call. For all * * @see http://developer.github.com/v3/ * * @param string $command e.g "/users" * @param string $request e.g "POST" or PATCH, DELETE - if empty it is a GET * @param array $post vaiables $_POST variables to send * @param boolean $json should we return output as json. Default is false * @return boolean|array false if failure. Else: $ary response from github server */ public function apiCall($command, $request = null, $post = null, $json = false) { if (!isset($_SESSION['access_token']) || empty($_SESSION['access_token'])) { $this->errors[] = 'No valid token'; return false; } $end_point = 'https://api.github.com'; $command = $end_point . "{$command}"; $command .= "?access_token={$_SESSION['access_token']}"; $c = new mycurl($command); if (isset($request)) { $c->setRequest($request); } if (isset($post)) { $json = json_encode($post); $c->setPost($json); } $c->createCurl(); $resp = $c->getWebPage(); $this->returnCode = $c->getHttpStatus(); if ($json) { return $resp; } else { $ary = json_decode($resp, true); return $ary; } }