function dump($var, $echo = true, $label = null, $strict = true) { $label = $label === null ? '' : rtrim($label) . ' '; if (!$strict) { if (ini_get('html_errors')) { $output = print_r($var, true); $output = "<pre>" . $label . htmlspecialchars($output, ENT_QUOTES) . "</pre>"; } else { $output = $label . " : " . print_r($var, true); } } else { ob_start(); var_dump($var); $output = ob_get_clean(); if (!extension_loaded('xdebug')) { $output = preg_replace("/\\]\\=\\>\n(\\s+)/m", "] => ", $output); $output = '<pre>' . $label . htmlspecialchars($output, ENT_QUOTES, "GB2312") . '</pre>'; } } if ($echo) { echo $output; return null; } else { return $output; } }
function _testXPath($xpath_expression) { if (!class_exists('DOMDocument') || !class_exists('DOMXPath')) { if (function_exists('domxml_open_mem')) { $dom = domxml_open_mem($this->_response); if (!$dom) { $this->fail('Error parsing doc'); return false; } var_dump($dom); $xpath = $dom->xpath_init(); var_dump($xpath); $ctx = $dom->xpath_new_context(); var_dump($xpath_expression); $result = $ctx->xpath_eval($xpath_expression); var_dump($result); $return = new stdClass(); $return->length = count($result->nodeset); return $return; } $this->fail('No xpath support built in'); return false; } else { if (extension_loaded('domxml')) { $this->fail('Please disable the domxml extension. Only php5 builtin domxml is supported'); return false; } } $dom = new DOMDocument(); $dom->loadHtml($this->_response); $xpath = new DOMXPath($dom); $node = $xpath->query($xpath_expression); return $node; }
public static function save() { try { $series = $_POST['series']; $SerieDocumentoFiscalTO = new SerieDocumentoFiscalTO(); $SerieDocumentoFiscalDao = new SerieDocumentoFiscalDao(); $conn = Conexao::getInstance(); $conn->beginTransaction(); foreach ($series as $key => $value) { if (isset($value['flg_excluido']) && (int) $value['flg_excluido'] == 1) { $SerieDocumentoFiscalDao->delete($value['id']); } else { $SerieDocumentoFiscalTO->cod_empreendimento = $value['cod_empreendimento']; $SerieDocumentoFiscalTO->serie_documento_fiscal = $value['serie_documento_fiscal']; $SerieDocumentoFiscalTO->num_modelo_documento_fiscal = $value['num_modelo_documento_fiscal']; $SerieDocumentoFiscalTO->num_ultimo_documento_fiscal = $value['num_ultimo_documento_fiscal']; if (isset($value['id']) && is_numeric($value['id'])) { $SerieDocumentoFiscalTO->id = $value['id']; $SerieDocumentoFiscalDao->update($SerieDocumentoFiscalTO); } else { $SerieDocumentoFiscalDao->save($SerieDocumentoFiscalTO); } } } $conn->commit(); Flight::halt(201); } catch (Exception $e) { //$conn->rollback() ; var_dump($e); } }
public static function api_method($type, $code, $msg = '', $data = array()) { if (!is_numeric($code)) { return "system error"; } $result = array('code' => $code, 'msg' => $msg, 'data' => $data); if ($type == "json") { self::json($code, $msg, $data); //exit; } else { if ($type == "xml") { self::xml_encode($code, $msg, $data); exit; } else { if ($type == "array") { var_dump($result); } else { if ($type == "") { $code = "408"; $msg = "error:Invalid ask_method value!"; $data = "null"; self::json($code, $msg, $data); exit; } } } } }
public function full_Record($page) { $settings = array('oauth_access_token' => "1654747094-39QyDkE8pCO4u1g3DOJ6Y9cWTIab1AM5yCaqjI1", 'oauth_access_token_secret' => "GVFbktmNzIOyjGQi0LpgUv7BR7TPq782YYF5IWalVKAQv", 'consumer_key' => "NYpbHzhdUUQGERNE1AiOUy1vS", 'consumer_secret' => "il0grNd5ZxsI7GoaQ10MVvQPyjv7NKLx5cneSj0djcyX1Ci4bG"); $url = 'https://api.twitter.com/1.1/users/search.json'; $getfield = '?q=john&page=' . $page; $requestMethod = 'GET'; $twitter = new TwitterAPIExchange($settings); $users = $twitter->setGetfield($getfield)->buildOauth($url, $requestMethod)->performRequest(); //echo '<pre>';print_r($users);die; $users = json_decode($users, true); var_dump($users); die; if (empty($users)) { echo "Data saved less data available"; } else { //var_dump($users);die(); for ($i = 0; $i <= 19; $i++) { $twitter = new twitter_user(); $twitter->user_id = $users[$i]['id']; $twitter->name = $users[$i]['name']; $twitter->sname = $users[$i]['screen_name']; $twitter->location = $users[$i]['location']; $twitter->save(); } if ($page <= 3) { $page++; $this->full_Record($page); } else { echo "Data Saved ok"; } } }
public function getSelectData($sql_select) { $data = array(); try { $pdo = new \PDO('mysql:host=' . \fbx\Config::getInstance()->getHost() . ';port=' . \fbx\Config::getInstance()->getPort() . ';dbname=' . \fbx\Config::getInstance()->getDbName(), \fbx\Config::getInstance()->getUser(), \fbx\Config::getInstance()->getPwd()); $query = $pdo->prepare($sql_select); $query->execute(); } catch (\PDOException $e) { var_dump(\fbx\Config::getInstance()); var_dump($e->getMessage()); echo "l'erreur " . $e->getMessage() . "<br />"; echo "le numero de l'erreur est " . $e->getCode() . "<br />"; echo "l'erreur est à la ligne " . $e->getLine() . "<br />"; echo "l'erreur est à la ligne " . $e->getTrace() . "<br />"; die; } $ind = 0; while ($row = $query->fetchObject()) { $data[$ind] = $row; $ind++; } unset($pdo); unset($query); return $data; }
/** * Dump & Die * * @codeCoverageIgnore */ function dd() { array_map(function ($x) { var_dump($x); }, func_get_args()); die; }
public function actionUpdate($fid = 0, $gid = 0, $sort = '') { $timer = new CountTimer(); $cacheToken = 'cache-update'; Yii::beginProfile($cacheToken); ob_start(); // 生成版块列表缓存 $this->forward('forum/forumlist', false); // 生成帖子列表缓存 $sortArr = array('', 'new', 'marrow', 'top'); $fids = $this->_getFids($fid); $uids = $this->_getUidsByGid($gid); foreach ($sortArr as $sort) { foreach ($fids as $fid) { foreach ($uids as $uid) { $_GET = array_merge($_GET, array('hacker_uid' => $uid, 'boardId' => $fid, 'page' => 1, 'pageSize' => 10, 'sortby' => $sort)); $res = $this->forward('forum/topiclist', false); ob_clean(); } } } ob_end_clean(); var_dump($timer->stop()); Yii::endProfile($cacheToken); }
public function execute() { global $CFG, $DB; require_once $CFG->libdir . '/accesslib.php'; //some variables you may want to use //$this->cwd - the directory where moosh command was executed //$this->mooshDir - moosh installation directory //$this->expandedOptions - commandline provided options, merged with defaults //$this->topDir - top Moodle directory //$this->arguments[0] - first argument passed //$this->pluginInfo - array with information about the current plugin (based on cwd), keys:'type','name','dir' $options = $this->expandedOptions; $contextid = $this->arguments[0]; //$contextpath = $this->arguments[0]; // Get all contexts under given one $context = \context::instance_by_id($contextid, MUST_EXIST); var_dump($context); echo $context->get_context_name(); return; $sql = "SELECT * FROM {context} WHERE path LIKE '{$contextpath}/%'"; $contexts = $DB->get_records_sql($sql); foreach ($contexts as $context) { /** @var \context $context */ echo $this->context_info($context->id) . "\n"; // What is in mdl_role_capabilities for this context $capabilities = $DB->get_records('role_capabilities', array('contextid' => $context->id)); foreach ($capabilities as $cap) { echo $cap->roleid . ' ' . $cap->capability . ' ' . $cap->permission . " | "; } echo "\n"; } }
public function execute(Request $request, $count, OutputInterface $out) { $client = new \Elasticsearch\Client(['hosts' => [$request->getHost()]]); $response = new Response(); if ($this->clearCache) { $this->clearCache($client, $out); } $helper = new ProgressHelper(); $helper->start($out, $count); $start = microtime(true); for ($i = 0; $i < $count; $i++) { try { $response->addSuccess($client->search($request->getParameters())); } catch (\Exception $ex) { $response->addFailure(); var_dump($ex->getMessage()); exit; } $helper->advance(); } $helper->finish(); $response->setExternalTime(microtime(true) - $start); try { $response->setStats($client->indices()->stats([['index' => $request->getIndex()], 'groups' => [$request->getStatId()]])); } catch (\Exception $ex) { // nothing to do here } return $response; }
public function __get($strPropertyName) { var_dump($strPropertyName); $method = 'get' . ucfirst($strPropertyName); var_dump($method); return $this->{$method}(); }
protected function runCommand($queue, $interval, $verbose, $count, $script) { $return = 1; $yiiPath = 'yiipath'; //Yii::getAlias('system'); $appPath = Yii::getAlias('@app'); $resquePath = Yii::getAlias('@vendor') . '/rolies106/yii2resque'; $redis = Yii::$app->get('redis', false); if (empty($redis)) { echo "\n"; echo "resque component cannot be found in your configuration.\n"; echo "please check your console.php configuration for resque components.\n\n"; echo "ERROR.\n\n"; return $return; } $server = $redis->hostname ?: 'localhost'; $port = $redis->port ?: 6379; $host = $server . ':' . $port; $db = $redis->database ?: 0; $auth = $redis->password ?: ''; $prefix = isset($redis->prefix) ? $redis->prefix : ''; $includeFiles = isset($redis->includeFiles) ? $redis->includeFiles : null; if (is_array($includeFiles)) { $includeFiles = implode(',', $includeFiles); } $command = 'nohup sh -c "PREFIX=' . $prefix . ' QUEUE=' . $queue . ' COUNT=' . $count . ' REDIS_BACKEND=' . $host . ' REDIS_BACKEND_DB=' . $db . ' REDIS_AUTH=' . $auth . ' INTERVAL=' . $interval . ' VERBOSE=' . $verbose . ' INCLUDE_FILES=' . $includeFiles . ' YII_PATH=' . $yiiPath . ' APP_PATH=' . $appPath . ' php ' . $resquePath . '/bin/' . $script . '" >> ' . $appPath . '/runtime/yii_resque_log.log 2>&1 &'; die(var_dump($command)); exec($command, $return); return $return; }
function fetchAndUpdateFacultyInfo($query, $conn, $nextPage) { $stid = oci_parse($conn, $query); var_dump($query); oci_execute($stid); echo "<form action=\"{$nextPage}?user=FACULTY\">"; echo "<table border='1'>\n"; while ($row = oci_fetch_array($stid, OCI_ASSOC + OCI_RETURN_NULLS)) { $i = 1; foreach ($row as $item) { echo "<tr>\n"; $column_name = oci_field_name($stid, $i); echo "<td> {$column_name} </td>\n"; if ($column_name == "UnityId" || $column_name == "FacultyNo" || $column_name == "Balance" || $column_name == "Type" || $column_name == "Category" || $column_name == "isHeld" || $column_name == "Department") { echo " <td>" . "<input type=\"text\" name=\"{$column_name}\" value=\"{$item}\" readonly>" . "</td>\n"; } else { echo " <td>" . "<input type=\"text\" name=\"{$column_name}\" value=\"{$item}\" >" . "</td>\n"; } $i++; echo "</tr>\n"; } } echo "</table>\n"; echo "<input type=\"submit\" value=\"Update\">"; echo "</form>"; }
function postToIDS($url, $data) { $agent = $_SERVER["HTTP_USER_AGENT"]; $curlData = http_build_query($data); $curlData = str_replace(" ", '%20', $curlData); $curlData = str_replace("+", '%20', $curlData); $curl = curl_init(); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); //curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); //curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($curl, CURLOPT_USERAGENT, $agent); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $curlData); $response = curl_exec($curl); echo '<!-- CURLINFO_EFFECTIVE_URL' . PHP_EOL; var_dump(curl_getinfo($curl, CURLINFO_EFFECTIVE_URL)); echo PHP_EOL . '/-->' . PHP_EOL; if ($response === false) { echo "curl error: " . curl_error($curl); } else { $http_status = curl_getinfo($curl, CURLINFO_HTTP_CODE); } curl_close($curl); return $http_status; }
function d($v, $t) { echo '<pre>'; echo '<h1>' . $t . '</h1>'; var_dump($v); echo '</pre>'; }
private function _debugDump($obj) { if ($this->debugMode) { print_r("\n"); var_dump($obj); } }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { //validate this var_dump($request->all()); $input = $request->all(); $params = []; $quantities = $input['quantities'] = explode(',', $input['quantities']); $items = $this->item->getIn('id', explode(',', $input['ids'])); $ctr = 0; $recipe = Recipe::create($request->all()); foreach ($items as $key => $value) { $ing = ['name' => $value['name'] . " for " . $recipe->name, 'recipe_id' => $recipe->id, 'item_id' => $value['id'], 'quantity' => (int) $quantities[$ctr]]; array_push($params, $ing); $ctr++; } $ingredients = Ingredient::insert($params); if ($recipe && $ingredients) { return redirect()->back()->with('flash_message', 'Recipe has been successfully saved.'); } $this->recipe->fdelete($recipe); foreach ($ingredients as $key) { $key->forceDelete(); } return redirect()->back()->withErrors('Could not save recipe'); }
public function list(Request $request) { $offset = $request->get('offset'); $limit = $request->get('limit'); $data = $this->model->list($offset, $limit); var_dump($data); }
function index() { var_dump($_GET); $data['ss'] = 2222; $data['qqq'] = 2222; return $data; }
function readUrl($url) { var_dump($url); die; $urldata = parse_url($url); if (isset($urldata['host'])) { if ($this->host and $this->host != $urldata['host']) { return false; } $this->protocol = $urldata['scheme']; $this->host = $urldata['host']; $this->path = $urldata['path']; return $url; } if (preg_match('#^/#', $url)) { $this->path = $urldata['path']; return $this->protocol . '://' . $this->host . $url; } else { if (preg_match('#/$#', $this->path)) { return $this->protocol . '://' . $this->host . $this->path . $url; } else { if (strrpos($this->path, '/') !== false) { return $this->protocol . '://' . $this->host . substr($this->path, 0, strrpos($this->path, '/') + 1) . $url; } else { return $this->protocol . '://' . $this->host . '/' . $url; } } } }
function updateIndex($lang, $file) { $fileData = readFileData($file); $filename = $file->getPathName(); list($filename) = explode('.', $filename); $path = $filename . '.html'; $id = str_replace($lang . '/', '', $filename); $id = str_replace('/', '-', $id); $id = trim($id, '-'); $url = implode('/', array(ES_URL, ES_INDEX, $lang, $id)); $data = array('contents' => $fileData['contents'], 'title' => $fileData['title'], 'url' => $path); $data = json_encode($data); $size = strlen($data); $fh = fopen('php://memory', 'rw'); fwrite($fh, $data); rewind($fh); echo "Sending request:\n\tfile: {$file}\n\turl: {$url}\n"; $ch = curl_init($url); curl_setopt($ch, CURLOPT_PUT, true); curl_setopt($ch, CURLOPT_INFILE, $fh); curl_setopt($ch, CURLOPT_INFILESIZE, $size); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $metadata = curl_getinfo($ch); if ($metadata['http_code'] > 400) { echo "[ERROR] Failed to complete request.\n"; var_dump($response); exit(2); } curl_close($ch); fclose($fh); echo "Sent {$file}\n"; }
/** * @param $data */ public static function var_dump($data) { echo "<pre>"; var_dump($data); echo "</pre>"; return; }
/** * Dump the given value and kill the script. * * @param mixed $value * @return void */ function dd($value) { echo "<pre>"; var_dump($value); echo "</pre>"; die; }
public static function dumpVarsToFileAndDie($vars) { ob_start(); var_dump($vars); file_put_contents('/tmp/log.txt', file_get_contents('/tmp/log.txt') . "\n" . ob_get_contents()); ob_end_clean(); }
public function match($uri) { foreach ($this->routers as $route) { preg_match('~\\{(?:([^{}]+):)*([a-zA-Z][a-zA-Z0-9_]*)\\}~', $uri, $params); var_dump($params); } }
/** * Call path (with optional parameters) on base url using the given method. * * @throws Zend_Http_Client_Exception * @param $path URL path * @param string $method POST|GET|PUT|DELETE * @param bool|array $args Optional parameters for PUT/POST requests * @return mixed */ public function call($path, $method = 'GET', $args = false, $verbose = false) { $client = $this->getClient(); $client->setUri($this->_getClientUrl() . $path); if ($verbose) { echo "### URL: " . $this->_getClientUrl() . $path . "\n"; } if ($args && ($method == 'POST' || $method == 'PUT')) { foreach ($args as $k => $v) { $client->setParameterPost($k, $v); } } else { if ($args && $method == 'GET') { foreach ($args as $k => $v) { $client->setParameterGet($k, $v); } } } try { $result = $client->request($method); if ($verbose) { echo "###Result:\n"; var_dump($result->getBody()); echo "###\n\n"; } if (!$result->isSuccessful()) { throw new Exception('API request failed miserably', $result->getStatus()); } return Zend_Json_Decoder::decode($result->getBody()); } catch (Zend_Http_Client_Exception $e) { throw $e; } }
protected function _init() { $app = App::i(); $config = array_merge(['timeout' => '24 hours', 'salt' => 'LT_SECURITY_SALT_SECURITY_SALT_SECURITY_SALT_SECURITY_SALT_SECU', 'login_url' => 'https://www.google.com/accounts/o8/id', 'path' => preg_replace('#^https?\\:\\/\\/[^\\/]*(/.*)#', '$1', $app->createUrl('auth'))], $this->_config); $opauth_config = ['Strategy' => ['OpenID' => ['identifier_form' => THEMES_PATH . 'active/views/auth-form.php', 'url' => $config['login_url']]], 'security_salt' => $config['salt'], 'security_timeout' => $config['timeout'], 'path' => $config['path'], 'callback_url' => $app->createUrl('auth', 'response')]; $opauth = new \Opauth($opauth_config, false); $this->opauth = $opauth; if ($config['logout_url']) { $app->hook('auth.logout:after', function () use($app, $config) { $app->redirect($config['logout_url'] . '?next=' . $app->baseUrl); }); } // add actions to auth controller $app->hook('GET(auth.index)', function () use($app) { $app->redirect($this->createUrl('openid')); }); $app->hook('<<GET|POST>>(auth.openid)', function () use($opauth, $config) { $_POST['openid_url'] = $config['login_url']; $opauth->run(); }); $app->hook('GET(auth.response)', function () use($app) { $app->auth->processResponse(); if ($app->auth->isUserAuthenticated()) { $app->redirect($app->auth->getRedirectPath()); } else { if ($app->config['app.mode'] === 'production') { $app->redirect($this->createUrl('error')); } else { echo '<pre>'; var_dump($this->data, $_POST, $_GET, $_REQUEST, $_SESSION); die; } } }); }
public function __invoke($input) { var_dump($input); $user = $this->domain->currentUser(); $payload = $this->domain->edit($input['todoId'], $user->userId(), $input['description']); return $payload; }
function getform() { // $db = new Model; //Initialisation de deux variablesq $titre = "Index du forum"; $totaldesmessages = 0; $categorie = NULL; var_dump($titre); //Cette requête permet d'obtenir tout sur le forum $db = DB::select('SELECT cat_id, cat_nom, forum_forum.forum_id, forum_name, forum_desc, forum_post, forum_topic, auth_view, forum_topic.topic_id, forum_topic.topic_post, post_id, post_time, post_createur, membre_pseudo, membre_id FROM forum_categorie LEFT JOIN forum_forum ON forum_categorie.cat_id = forum_forum.forum_cat_id LEFT JOIN forum_post ON forum_post.post_id = forum_forum.forum_last_post_id LEFT JOIN forum_topic ON forum_topic.topic_id = forum_post.topic_id LEFT JOIN forum_membres ON forum_membres.membre_id = forum_post.post_createur WHERE auth_view <= :lvl ORDER BY cat_ordre, forum_ordre DESC'); return $db; // $query->bindValue(':lvl',$lvl,PDO::PARAM_INT); // $query->execute(); // //On compte les membres // $TotalDesMembres = $db->query('SELECT COUNT(*) FROM forum_membres')->fetchColumn(); // $query->CloseCursor(); // $query = $db->query('SELECT membre_pseudo, membre_id FROM forum_membres ORDER BY membre_id DESC LIMIT 0, 1'); // $data = $query->fetch(); // $derniermembre = stripslashes(htmlspecialchars($data['membre_pseudo'])); // $query->CloseCursor(); }
/** * Remove the record IF there are no records referencing this user. */ function updateDatabase($form, $myvalues) { //Perform some data quality checks now. if (!isset($myvalues['protocol_shortname'])) { die("Cannot delete record because missing protocol_shortname in array!\n" . var_dump($myvalues)); } $updated_dt = date("Y-m-d H:i", time()); $protocol_shortname = $myvalues['protocol_shortname']; //Backup all the existing records. $this->m_oPageHelper->copyProtocolLibToReplacedTable($protocol_shortname); $this->m_oPageHelper->copyKeywordsToReplacedTable($protocol_shortname); $this->m_oPageHelper->copyTemplateValuesToReplacedTable($protocol_shortname); //Delete all the records. $num_deleted = db_delete('raptor_protocol_lib')->condition('protocol_shortname', $protocol_shortname)->execute(); $num_deleted = db_delete('raptor_protocol_keywords')->condition('protocol_shortname', $protocol_shortname)->execute(); $num_deleted = db_delete('raptor_protocol_template')->condition('protocol_shortname', $protocol_shortname)->execute(); //Success? if ($num_deleted == 1) { $feedback = 'The ' . $protocol_shortname . ' protocol has been succesfully deleted.'; drupal_set_message($feedback); return 1; } //We are here because we failed. $feedback = 'Trouble deleting ' . $protocol_shortname . ' protocol!'; error_log($feedback . ' delete reported ' . $num_deleted); drupal_set_message($feedback, 'warning'); return 0; }