public static function dispatch($logModel = 'Kwf_Util_PayPal_Ipn_LogModel') { $url = Kwf_Setup::getRequestPath(); if ($url != '/wirecard_confirm') { return; } self::process($logModel); echo 'OK'; exit; }
/** * Proxy, der zB für cross-domain ajax requests verwendet werden kann * * @param string|array $hosts Erlaubte Hostnamen (RegExp erlaubt, ^ vorne und $ hinten werden autom. angefügt) */ public static function dispatch($hostnames) { if (Kwf_Setup::getRequestPath() === false) { return; } if (!preg_match('#^/kwf/proxy/?$#i', Kwf_Setup::getRequestPath())) { return; } if (is_string($hostnames)) { $hostnames = array($hostnames); } $proxyUrl = $_REQUEST['proxyUrl']; $proxyPostVars = $_POST; $proxyGetVars = $_GET; if (array_key_exists('proxyUrl', $proxyPostVars)) { unset($proxyPostVars['proxyUrl']); } if (array_key_exists('proxyUrl', $proxyGetVars)) { unset($proxyGetVars['proxyUrl']); } // host checking $proxyHost = parse_url($proxyUrl, PHP_URL_HOST); $matched = false; foreach ($hostnames as $hostname) { if (preg_match('/^' . $hostname . '$/i', $proxyHost)) { $matched = true; break; } } if (!$matched) { return; } // proxying $http = new Zend_Http_Client($proxyUrl); if (count($_POST)) { $http->setMethod(Zend_Http_Client::POST); } else { $http->setMethod(Zend_Http_Client::GET); } if (count($_GET)) { $http->setParameterGet($proxyGetVars); } if (count($_POST)) { $http->setParameterPost($proxyPostVars); } $response = $http->request(); $headers = $response->getHeaders(); if ($headers && !empty($headers['Content-type'])) { header("Content-Type: " . $headers['Content-type']); } echo $response->getBody(); exit; }
public function __call($method, $args) { $log = date('Y-m-d H:i:s') . " (start) {$this->_serverUrl} {$method} " . Kwf_Setup::getRequestPath() . "\n"; file_put_contents('log/srpc-call', $log, FILE_APPEND); $start = microtime(true); $b = Kwf_Benchmark::start('srpc call', $this->_serverUrl . ' ' . $method); $params = array('method' => $method, 'arguments' => array(), 'extraParams' => array()); if (is_array($args) && count($args)) { $params['arguments'] = $args; } if ($this->_extraParams) { $params['extraParams'] = $this->_extraParams; } $params['arguments'] = serialize($params['arguments']); $params['extraParams'] = serialize($params['extraParams']); if (strpos($params['arguments'], 'Kwf_') !== false || strpos($params['extraParams'], 'Kwf_') !== false) { $ex = new Kwf_Exception("a class name with 'Kwf_' must not be sent through srpc client"); $ex->logOrThrow(); } $response = $this->_performRequest($params); $log = date('Y-m-d H:i:s') . ' ' . round(microtime(true) - $start, 2) . "s {$this->_serverUrl} {$method} " . Kwf_Setup::getRequestPath() . "\n"; file_put_contents('log/srpc-call', $log, FILE_APPEND); if ($b) { $b->stop(); } try { $result = unserialize($response); } catch (Exception $e) { throw new Kwf_Exception('Srpc Server Response is not serialized: ' . $response); } if ($result === false) { throw new Kwf_Exception('Srpc Server Response is not serialized: ' . $response); } // result könnte eine Exception sein, wenn ja wird sie weitergeschmissen if ($result instanceof Kwf_Exception_Serializable) { throw $result->getException(); } else { if ($result instanceof Exception) { throw $result; } } return $result; }
public static function output() { self::shutDown(); if (!self::$_enabled) { return; } self::disable(); self::$_logEnabled = false; $execTime = microtime(true) - self::$startTime; if (function_exists('memory_get_peak_usage')) { $memoryUsage = memory_get_peak_usage(); } else { $memoryUsage = memory_get_usage(); } $load = @file_get_contents('/proc/loadavg'); $load = explode(' ', $load); $load = $load[0]; $benchmarkOutput = array(); if ($execTime < 1) { $benchmarkOutput[] = round($execTime * 1000) . " msec"; } else { $benchmarkOutput[] = round($execTime, 3) . " sec"; } if ($load) { $benchmarkOutput[] = "Load: " . $load; } $benchmarkOutput[] = "Memory: " . round($memoryUsage / 1024) . " kb"; if (Zend_Registry::get('dao') && Zend_Registry::get('dao')->hasDb() && Zend_Registry::get('db')) { if (Zend_Registry::get('db')->getProfiler() && method_exists(Zend_Registry::get('db')->getProfiler(), 'getQueryCount')) { $benchmarkOutput[] = "DB-Queries: " . Zend_Registry::get('db')->getProfiler()->getQueryCount(); } else { $benchmarkOutput[] = "DB-Queries: (no profiler used)"; } } else { $benchmarkOutput[] = "DB-Queries: (none)"; } if (PHP_SAPI != 'cli' && (Kwf_Config::getValue('debug.benchmark') || isset($_REQUEST['KWF_BENCHMARK']))) { $up = Kwf_Config::getValue('application.uniquePrefix'); if ($up) { $up .= '-'; } echo '<div class="' . $up . 'benchmarkBox" data-benchmark-type="server">'; echo '<div class="' . $up . 'benchmarkBoxContent">'; foreach ($benchmarkOutput as $line) { echo "{$line}<br />\n"; } } if (Kwf_Config::getValue('debug.benchmarklog')) { $out = date('Y-m-d H:i:s') . "\n"; $out .= Kwf_Setup::getRequestPath() . "\n"; $out .= implode("\n", $benchmarkOutput) . "\n"; file_put_contents('benchmarklog', $out); } if ((Kwf_Config::getValue('debug.benchmark') || isset($_REQUEST['KWF_BENCHMARK'])) && PHP_SAPI != 'cli') { echo self::_getCounterOutput(self::$_counter, true); if (self::$benchmarks) { echo "<br /><b>Benchmarks:</b><br/>"; foreach (self::$benchmarks as $i) { echo "<a style=\"display:block;\" href=\"#\" onclick=\"if(this.nextSibling.nextSibling.style.display=='none') { this.open=true; this.nextSibling.nextSibling.style.display='block'; this.nextSibling.style.display=''; } else { this.open=false; this.nextSibling.nextSibling.style.display='none';this.nextSibling.style.display='none'; } return(false); }\"\n onmouseover=\"if(!this.open) this.nextSibling.style.display=''\"\n onmouseout=\"if(!this.open) this.nextSibling.style.display='none'\">"; echo "{$i->identifier} (" . round($i->duration, 3) . " sec)</a>"; echo "<div style=\"display:none;margin-left:10px\">"; echo $i->addInfo . "<br/>"; echo implode('<br />', $i->getOutput()); echo "</div>"; echo "<div style=\"display:none;margin-left:10px\">"; echo self::_getCounterOutput($i->counter, true); echo "</div>"; } } } if (Kwf_Config::getValue('debug.benchmarklog')) { $out = self::_getCounterOutput(self::$_counter, false); if (self::$benchmarks) { $out .= "\nBenchmarks:\n"; foreach (self::$benchmarks as $i) { $out .= "{$i->identifier} (" . round($i->duration, 3) . " sec)\n"; $out .= " " . $i->addInfo . "\n"; $out .= implode("\n ", $i->getOutput()); $out .= self::_getCounterOutput($i->counter, true); $out .= "\n"; } } file_put_contents('benchmarklog', $out, FILE_APPEND); } if ((Kwf_Config::getValue('debug.benchmark') || isset($_REQUEST['KWF_BENCHMARK'])) && PHP_SAPI != 'cli') { echo "<table style=\"font-size: 10px\">"; echo "<tr><th>ms</th><th>%</th><th>Checkpoint</th></tr>"; $sum = 0; foreach (self::$_checkpoints as $checkpoint) { $sum += $checkpoint[0]; } foreach (self::$_checkpoints as $i => $checkpoint) { echo "<tr>"; echo "<td>" . round($checkpoint[0] * 1000) . "</td>"; echo "<td>" . round($checkpoint[0] / $sum * 100) . "</td>"; echo "<td>" . $checkpoint[1] . "</td>"; echo "</tr>"; if (isset(self::$_subCheckpoints[$i])) { $subCheckpoints = array(); foreach (self::$_subCheckpoints[$i] as $cp) { $subCheckpoints[0][] = $cp[0]; $subCheckpoints[1][] = $cp[1]; } array_multisort($subCheckpoints[0], SORT_DESC, SORT_NUMERIC, $subCheckpoints[1]); foreach (array_keys($subCheckpoints[0]) as $k) { $percent = $subCheckpoints[0][$k] / $sum * 100; if ($percent > 1) { echo "<tr>"; echo "<td>" . round($subCheckpoints[0][$k] * 1000) . "</td>"; echo "<td>" . round($percent) . "</td>"; echo "<td> " . $subCheckpoints[1][$k] . "</td>"; echo "</tr>"; } } } } echo "</table>"; echo "</div>"; echo "</div>"; } if (Kwf_Config::getValue('debug.benchmarklog')) { $out = "\n" . self::getCheckpointOutput(); file_put_contents('benchmarklog', $out, FILE_APPEND); } }
public static function dispatch() { $url = Kwf_Setup::getRequestPath(); self::process(); exit; }