/** * Var dump that shows paths for arrays * @param $data object to dump * @param $methods show methods from objects * @param $level maximum nesting level (to prevent infinite loops) */ function var_dump_path($data, $methods = false, $maxdepth = 20, $path = '', $level = 0, $aRecursives = array()) { echo '<span style="10px; font-family: Verdana; font-size: 10px; color: black">'; if (is_array($data) || is_object($data)) { if ($level < $maxdepth) { $bObject = is_object($data); if ($bObject) { echo '<span style=""><b>' . $path . '</b>: <i>' . get_class($data) . ' object</i></span><br />'; $aRecursives[] = $data; if ($methods) { $methods = get_class_methods($data); $data = get_object_vars($data); foreach ($methods as $method) { $data[$method . '()'] = 'method'; } } else { $data = get_object_vars($data); } } else { $aRecursives[] = print_r($data, true); echo '<b>' . $path . '</b>: <i>Array</i><br />'; } foreach ($data as $key => $value) { $sArray = '[<span style="color:green;">' . "'" . $key . "'</span>]"; $sObj = '-><span style="color:blue;">' . $key . '</span>'; if ($bObject && in_array($value, $aRecursives, true) || !$bObject && in_array(print_r($value, true), $aRecursives)) { if ($bObject) { echo '<span style="background-color: #FFEEEE"><b>' . $path . $sObj . '</b>: <i>Recursive</i></span><br />'; } else { echo '<span style="background-color: #FFEEEE"><b>' . $path . $sArray . '</b>: <i>Recursive</i></span><br />'; } } else { if (is_int($key)) { var_dump_path($value, $methods, $maxdepth, $path . '[<span style="color:red; font-size:9px;">' . $key . '</span>]', $level + 1, $aRecursives); } else { if ($bObject) { var_dump_path($value, $methods, $maxdepth, $path . $sObj, $level + 1, $aRecursives); } else { var_dump_path($value, $methods, $maxdepth, $path . $sArray, $level + 1, $aRecursives); } } } } } else { if (is_object($data)) { echo '<span style="background-color: #FFEEEE"><b>' . $path . '</b>: <i>' . get_class($data) . ' object (too deep)</i></span><br />'; } else { echo '<span style="background-color: #FFEEEE"><b>' . $path . '</b>: <i>Array (too deep)</i><br />'; } echo '<div style="width: 100%; height: 10px; background-color: #FFEEEE; margin-top: -10px"> </div>'; } } else { if (!$data) { echo '<b>' . $path . '</b>: <i>null</i><br />'; } else { echo '<b>' . $path . '</b>: ' . htmlspecialchars((string) $data) . '<br />'; } } echo '</span>'; }
/** * @param string $url */ public function getNefubContents($url, $maxAge, array $postData = null) { if (is_null($maxAge)) { self::put('Max age mag geen null zijn'); throw new Exception('Max age mag geen null zijn'); } $oCache = RequestCache::getRequest($url, $postData); // Request te oud bevonden if (!$oCache || $oCache->getAgeInDays() >= $maxAge) { $urls = array(); if ($this->retrieveLog->urls) { $urls = json_decode($this->retrieveLog->urls); } if (in_array($url, $urls)) { echo $url . ' is al eerder opgehaald<br />'; var_dump_path(debug_backtrace()); exit; } $urls[] = $url; $this->retrieveLog->urls = json_encode($urls); $this->retrieveLog->save(); if (self::$totalRequests < LIMIT_API_REQUESTS) { $this->countRequests++; self::$totalRequests++; // alleen nieuw object nodig als url niet eerder is opgehaald, anders vernieuwen we de rij alleen if (!$oCache) { $oCache = new RequestCache(); $oCache->url = $url; $oCache->save(); } $this->retrieveLog->requests = self::$totalRequests; $this->retrieveLog->save(); $context = null; if (is_array($postData)) { $httpQuery = http_build_query($postData); $streamOptions = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $httpQuery)); $context = stream_context_create($streamOptions); } $oCache->postData = is_array($postData) ? json_encode($postData) : null; $oCache->response = file_get_contents($url, false, $context); $oCache->success = is_string($oCache->response); $oCache->update_time = date("Y-m-d H:i:s"); $oCache->save(); } else { $text = 'Limiet van ' . LIMIT_API_REQUESTS . ' bereikt bij het ophalen van ' . $url; self::put($text); echo $text; $this->retrieveLog->requests = self::$totalRequests; $this->retrieveLog->finished = true; $this->retrieveLog->successfully = false; $this->retrieveLog->save(); exit; } } return $oCache->response; }
<?php require_once 'config.php'; setlocale(LC_ALL, 'nl_NL'); if (isset($_GET['tree']) && $_GET['tree'] == 1) { $oSeason = Season::getInstance(); var_dump_path($oSeason->getTree()); exit; } else { $oFrontRenderer = new FrontRenderer(); $arguments = explode('?', $_SERVER['REQUEST_URI']); $arguments = strtolower($arguments[0]); $arguments = explode('/', $arguments); array_shift($arguments); $c = count($arguments); $subject = $arguments[0]; if ($c >= 2) { $nefubId = $arguments[1]; } // Handle requests switch ($subject) { case 'ajax': if ($nefubId == 'search') { $search = urldecode($arguments[2]); $results = doSearch($search); echo json_encode($results); exit; } break; case 'retrieve.php': if (isset($_GET['retrieve'])) {