public function CreatePoiImageAction() { //只接受文件流 $img = uploads('temp/poi/'); logDebug(json_encode($img)); if (is_array($img) && !isset($img[0]['error']) && FALSE != $img) { $this->di['wechat']->createPoiLogo($img); foreach ($img as $val) { unlink(ROOT_DIR . DIRECTORY_SEPARATOR . 'Public' . DIRECTORY_SEPARATOR . $val); } returnJSON(array('err' => '1', 'wechat_url' => $this->di['wechat']->url)); return; } returnJSON(array('err' => '0', 'errmsg' => $img[0]['error'])); return; }
public function __construct($cacheHandler) { $this->cache = $cacheHandler; // try to connect to the cache $cacheIsAlive = false; try { $cacheIsAlive = $this->cache->save('test', 'test', array(), 100); } catch (Exception $e) { } if (!$cacheIsAlive) { logDebug('session', 'No memcache available...'); $this->cacheType = 'database'; } else { $this->cacheType = 'memcache'; } logDebug('session', 'Session store in use: ' . $this->cacheType . '...'); }
public function __construct() { $config = Zend_Registry::getInstance()->get('CONFIG'); $solrServers = $config->solr->toArray(); $this->solrBalancer = new Apache_Solr_Service_Balancer(); foreach ($solrServers as $serverName => $params) { if (substr_compare($serverName, 'master', 0, 6) == 0) { logDebug('SolrServer', 'Adding new Solr master: ' . $params['host'] . ':' . $params['port'] . '<br>'); $this->solrBalancer->addWriteService(new Apache_Solr_Service($params['host'], $params['port'])); } else { if (substr_compare($serverName, 'slave', 0, 5) == 0) { logDebug('SolrServer', 'Adding new Solr slave: ' . $params['host'] . ':' . $params['port'] . '<br>'); $this->solrBalancer->addReadService(new Apache_Solr_Service($params['host'], $params['port'], 'solr/listings')); } } } $this->solrBalancer->setReadPingTimeout(1); }
function zapi_call($key, $auth, $function, $request_data) { global $zapi_hostname; global $zapi_port; global $zapi_location; $signature = array($key, $auth); foreach ($request_data as $foo) { array_push($signature, $foo); } $return_data = xmlrpc_request($zapi_hostname, $zapi_port, $zapi_location, $function, $signature); if (is_array($return_data)) { if ($return_data['faultString']) { logDebug("failure in zapi_call"); logDebug($return_data['faultString']); header("HTTP/1.0 500 Internal Server Error"); print $return_data['faultString']; stop_debugging(); die; } } return $return_data; }
function getFormatter() { logDebug("getFormatter called on ldaresponse"); if ($format = $this->Request->getParam('_format')) { if ($this->ConfigGraph->getApiContentNegotiation() == API . 'parameterBased') { if ($this->ConfigGraph->apiSupportsFormat($format)) { return $format; } else { logError("Bad Request when selecting formatter: {$format}"); $this->errorMessages[] = "Sorry. This API does not support {$format}"; $this->setStatusCode(HTTP_Bad_Request); $this->serve(); } } else { logError("This API does not support parameter based format selection."); $this->errorMessages[] = "This API does not support parameter based format selection. Try content-negotiation."; $this->setStatusCode(HTTP_Bad_Request); $this->serve(); } } else { if ($this->Request->hasFormatExtension()) { $extension = $this->Request->getFormatExtension(); if ($this->extensionIsSupported($extension)) { return $extension; } else { $this->errorMessages[] = "Sorry, the '{$extension}' extension is not supported here."; $this->setStatusCode(HTTP_Unsupported_Media_Type); return false; } } else { if ($this->Request->hasAcceptTypes()) { logDebug("Doing content-negotiation"); $configFormatters = $this->ConfigGraph->getFormatters(); foreach ($this->Request->getAcceptTypes($this->ConfigGraph->getDefaultMimeTypes()) as $acceptType) { logDebug("request accept type: '{$acceptType}'"); foreach ($configFormatters as $formatName => $formatterUri) { $formatterMimetypes = $this->ConfigGraph->getMimetypesOfFormatterByName($formatName); if (in_array($acceptType, $formatterMimetypes)) { logDebug("{$acceptType} matches {$formatterUri}"); return $formatName; } } } } } } if ($formatUri = $this->ConfigGraph->getEndpointDefaultFormatter()) { return $this->ConfigGraph->get_first_literal($formatUri, API . 'name'); } else { if ($formatUri = $this->ConfigGraph->getApiDefaultFormatter()) { return $this->ConfigGraph->get_first_literal($formatUri, API . 'name'); } } return 'json'; }
function getGroupGraphPattern() { $whereRequestParam = $this->_request->getParam('_where'); $selectorConfigWhereProperty = $this->getConfigGraph()->getSelectWhere(); $bindings = $this->getConfigGraph()->getAllProcessedVariableBindings(); $selectorConfigWhereProperty = $this->fillQueryTemplate($selectorConfigWhereProperty, $bindings); if (!empty($whereRequestParam)) { $whereRequestParam = '{' . $whereRequestParam . '}'; } if (!empty($selectorConfigWhereProperty)) { $selectorConfigWhereProperty = '{' . $selectorConfigWhereProperty . '}'; } $GGP = "{$whereRequestParam}\n{$selectorConfigWhereProperty}\n "; $filter = implode('&', $this->getConfigGraph()->getAllFilters()); foreach ($this->_request->getUnreservedParams() as $k => $v) { list($k, $v) = array(urlencode($k), urlencode($v)); $filter .= "&{$k}={$v}"; } logDebug("Filter is: {$filter}"); $params = queryStringToParams($filter); $langs = array(); foreach ($params as $k => $v) { if (strpos($k, 'lang-') === 0) { $langs[substr($k, 5)] = $v; unset($params[$k]); } } $GGP .= $this->paramsToSparql($params, $langs); $GGP = trim($GGP); if (empty($GGP)) { $GGP = "\n ?item ?property ?value ."; } return $GGP; }
function serve() { $Request = $this->Request; header($this->statusCode); if ($this->statusCode != HTTP_OK) { header("Content-Type: text/html"); switch ($this->statusCode) { case HTTP_Unsupported_Media_Type: case HTTP_Bad_Request: require 'views/errors/400.php'; break; default: case HTTP_Internal_Server_Error: require 'views/errors/500.php'; break; case HTTP_Not_Found: require 'views/errors/404.php'; break; case HTTP_Gateway_Timeout: require 'views/errors/504.php'; break; } exit; } //statusCode is HTTP_OK try { $outputFormat = $this->getFormatter(); if (!$outputFormat) { throw new Exception("No output format provided"); } if (!($mimetype = $this->ConfigGraph->getMimetypesOfFormatterByName($outputFormat))) { if (isset($this->outputFormats[$outputFormat])) { $mimetype = $this->outputFormats[$outputFormat]['mimetypes']; } else { $mimetype = array('text/html'); } } $mimetype = $mimetype[0]; $this->mimetype = $mimetype; $endpointType = $this->ConfigGraph->getEndpointType(); switch ($endpointType) { case API . 'ListEndpoint': #Antonis botch #Antonis botch case API . 'OPSListEndpoint': case PUELIA . 'SearchEndpoint': $pageUri = $this->Request->getUriWithPageParam(); break; case API . 'ItemEndpoint': case API . 'ExternalHTTPService': $pageUri = $this->Request->getUri(); break; default: throw new ConfigGraphException("<{$endpointType}> is not an implemented Endpoint type"); } if ($this->overrideUserConfig and isset($this->outputFormats[$outputFormat])) { logDebug('Override User Config is set to :' . $this->overrideUserConfig); $viewFile = $this->outputFormats[$outputFormat]['view']; $mimetype = $this->outputFormats[$outputFormat]['mimetypes'][0]; $this->mimetype = $mimetype; } else { if ($this->ConfigGraph->getFormatterTypeByName($outputFormat) == API . 'XsltFormatter') { logDebug("XSLT Formatter chosen"); $viewFile = 'views/xslt.php'; $styleSheetFile = $this->ConfigGraph->getXsltStylesheetOfFormatterByName($outputFormat); require $viewFile; die; } else { if ($this->ConfigGraph->getFormatterTypeByName($outputFormat) == PUELIA . 'PhpFormatter') { logDebug("PhpFormatter chosen"); $formatterUri = $this->ConfigGraph->getFormatterUriByName($outputFormat); //not used $innerTemplate = $this->ConfigGraph->get_first_literal($formatterUri, PUELIA.'innerTemplate'); $outerTemplate = $this->ConfigGraph->get_first_literal($formatterUri, PUELIA . 'outerTemplate'); require $outerTemplate; die; } else { if (isset($this->outputFormats[$outputFormat])) { $viewFile = $this->outputFormats[$outputFormat]['view']; } else { throw new Exception("{$outputFormat} is not an accepted output format"); } } } } } catch (Exception $e) { logError("Error when serving response: " . $e->getMessage()); $this->setStatusCode(HTTP_Internal_Server_Error); $this->serve(); } $this->serveHTTPSuccessPage($mimetype, $viewFile, $Request); }
function enviarMail($mensaje, $aQuien, $motivo) { logDebug("ENVIO EMAIL: " . $aQuien . " " . $motivo . " " . $mensaje . " From: " . htmlchars(Parametro::obtV(Parametro::FROM))); // mail($aQuien, $motivo, $mensaje, "From: " . Parametro::obtV(Parametro::FROM)); }
public static function hasCachedConfig($filepath) { logDebug("Looking in memcache for {$filepath}"); if (!function_exists("memcache_connect")) { return false; } $key = LinkedDataApiCache::configCacheKey($filepath); $mc = memcache_connect(PUELIA_MEMCACHE_HOST, PUELIA_MEMCACHE_PORT); $cachedObject = $mc->get($key); if ($cachedObject) { return $cachedObject; } logDebug("No cached version of ConfigGraph from {$filepath}"); return false; }
public function logSQL($result, $sql, $costTime) { $costTime = round($costTime, 3); $this->logNum++; if ($result === false) { logError("Num: " . $this->logNum . ", CostTime: {$costTime}, SQL:\n\t{$sql}"); throw new SQLException($this->func("error") . "\n\t" . "SQL=" . $sql); } else { logDebug("Num: " . $this->logNum . ", CostTime: {$costTime}, SQL:\n\t{$sql}"); } }
function connect($dsn = null) { if (strlen($dsn) > 0) { $this->dsn = $dsn; } if (is_array($dsn)) { $dsn = array_rand($dsn); } $arrDsnInfo = $this->explodeDsn($dsn); require_once __ROOT_PATH . 'libs/Drivers/' . $arrDsnInfo['driver'] . '.php'; $startTime = getMicrotime(); $this->conn = new $arrDsnInfo['driver']($arrDsnInfo); if (__Debug) { logDebug("connect use time: " . (getMicrotime() - $startTime)); } return $this->conn; }
/** * save file or image to upaiyun.com then update db * 先保存数据到又拍云存储,然后在更新数据库 * @param string $model * @param string $filename 保存文件名 * @param mixed $streamFile 流文件或者是图片路径 * @param bigint $id ID * @param bigint $user_id userid */ public function save($account_id, $filename = '', $streamFile = '', $id = '') { $result = $this->put('image', $filename, $streamFile); logDebug('UPLOAD FILE TO UPAI ' . json_encode($result)); $id = empty($id) ? objid() : $id; $filename = empty($filename) ? $id . '.jpg' : $filename; if ($result['code'] == 200) { return ImageLogic::setImage($id, $account_id, $filename, 'web'); } logNotice(__CLASS__ . '/' . __FUNCTION__ . ':UPLOAD IMAGE ERROR PATH:%s', $filename); return false; }
function arrayDump($array) { logDebug(print_a($array, 1)); }
public function mostrarOpciones(Usuario $usuario, BDCon $BD) { global $menu; global $system; ?> <div class="navbar navbar-default navbar-static-top" role="navigation"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#">Logo</a> </div> <div class="navbar-collapse collapse"> <ul class="nav navbar-nav"> <?php logDebug($usuario); foreach ($this->opciones as $opcion) { if ($usuario && $usuario->tieneAcceso($opcion->getNivel())) { ?> <li <?php echo $menu == $opcion->getClave() ? 'class="active"' : ''; ?> > <?php if (count($opcion->getHijos()) == 0) { ?> <a href="<?php echo $opcion->getUrl(); ?> "><?php echo $opcion->getTexto(); ?> </a> <?php } else { ?> <a href="<?php echo $opcion->getUrl(); ?> " data-toggle="dropdown"> <?php echo $opcion->getTexto(); ?> <b class="caret"></b></a> <ul class="dropdown-menu"> <?php foreach ($opcion->getHijos() as $hijo) { ?> <li> <a href="<?php echo $hijo->getUrl(); ?> "><?php echo $hijo->getTexto(); ?> </a> </li> <?php } ?> </ul> <?php } ?> </li> <?php } } ?> </ul> <div class="navbar-form navbar-right"> <?php if ($usuario && $usuario->logueado()) { ?> <div class="userbox"> <span><?php echo $usuario->getUsername(); ?> </span> <div class="logout"> <button class="btn btn-default" onclick="logout()"> <i class="glyphicon glyphicon-log-out"></i> Salir </button> </div> </div> <?php } else { ?> <a type="button" href="<?php echo $system["URL_LOGIN"]; ?> " class="btn btn-default">Acceder</a> <?php } ?> </div> </div> </div> </div> <?php }
private static function parseActionKey() { global $_FASTPHP_REWRITE_RULE; // 解析 Path & Query $path = $_SERVER['REQUEST_URI']; $query = ""; $pos = strpos($path, "?"); if ($pos !== false) { $query = substr($path, $pos); $path = substr($path, 0, $pos); } // 解析 Home Path $homePath = __HOME_URL; if ($homePath == "" || substr($homePath, -1) != "/") { logFatal("__HOME_URL must end with '/'."); } else { if (substr($homePath, 0, 7) == "http://" || substr($homePath, 0, 8) == "https://") { $pos = strpos($homePath, "/", 10); if ($pos !== false) { $homePath = substr($homePath, $pos); } else { $homePath = "/"; } } } if (defined("__REWRITE_RULE_MODE") == false || __REWRITE_RULE_MODE == "CLOSE") { return self::getDefaultActionKey($homePath, $path); } $homePathLen = strlen($homePath); $pathLen = strlen($path); if ($pathLen < $homePathLen || $homePath != substr($path, 0, $homePathLen)) { return self::getDefaultActionKey($homePath, $path); } $path = substr($path, $homePathLen - 1); //提取URL中的静态化参数部分 $parsedParams = array(); $staticParamStr = ""; if ($pathLen > 5 && substr($path, -4) == ".htm") { //静态化参数必须以 .htm 结尾 $pos = strrpos($path, '/'); $staticParamStr = substr($path, $pos + 1, -4); //最后一个 "/" 与 ".htm" 之间的内容 $path = substr($path, 0, $pos); //不包含结尾的“/” $pathLen = $pos; } else { if (substr($path, -1) == '/') { $path = substr($path, 0, -1); //移除结尾的“/” $pathLen--; } } //URL规则匹配 $find_actionkey = null; foreach ($_FASTPHP_REWRITE_RULE as $key => &$config) { if (empty($config['rule'])) { continue; } if ($pathLen == 0) { //特殊情形 - 首页地址 if ($config['rule'] == "/") { $find_actionkey = $key; break; } continue; } $preRule = ""; foreach (explode("|", $config['rule']) as $str) { if ($str == "") { continue; } $preRule .= $str; $rule = $preRule; if (substr($rule, -1) == "/") { $rule = substr($rule, 0, -1); } $ruleLen = strlen($rule); $pos = strpos($rule, '{'); if ($pos === false) { if ($rule == $path) { //没有表达式,结尾没有 “/” $find_actionkey = $key; break; } continue; } if ($pos >= $pathLen || substr($rule, 0, $pos) != substr($path, 0, $pos)) { continue; } //正则匹配 $regex = ""; $varNames = array(); for ($i = 0; $i < $ruleLen; $i++) { if ($rule[$i] == '/') { $regex .= "\\/"; } else { if ($rule[$i] == '{') { //do check //if($rule[$i+1] != '$') { //} $i += 2; //跳过 “{$” //$rule[$i] = ""; $varName = ""; for (; $i < $ruleLen; $i++) { if ($rule[$i] == '}') { $i++; //跳过 } break; } $varName .= $rule[$i]; } if (!empty($config['type'][$varName])) { $regex .= "(" . $config['type'][$varName] . ")"; $varNames[] = $varName; } else { logDebug("[RewriteRule] ActionKey: {$key}, Rule={$rule}, IgnoreVariable={$varName}."); } } else { $regex .= $rule[$i]; } } } $matches = array(); if (@preg_match("/^{$regex}/", $path, $matches)) { //找到了 //提取变量 foreach ($varNames as $index => $varName) { $parsedParams[$varName] = FastPHP_Request::decode($matches[$index + 1]); } $find_actionkey = $key; break; } } if ($find_actionkey !== null) { break; } } if ($find_actionkey !== null) { //解析自动静态化变量 if ($staticParamStr != "") { $arr = explode("--", $staticParamStr); foreach ($arr as $str) { $arr2 = explode("-", $str, 2); $parsedParams[$arr2[0]] = FastPHP_Request::decode($arr2[1]); } } //已有变量的优先级高 $_GET = array_merge($parsedParams, $_GET); $_REQUEST = array_merge($parsedParams, $_REQUEST); return $find_actionkey; } else { return self::getDefaultActionKey($homePath, $path); } }
function get_short_name_for_uri($propertyUri) { if ($name = $this->get_first_literal($propertyUri, API . 'label') or $name = $this->_config->get_first_literal($propertyUri, API . 'label')) { $this->_usedProperties[$name] = $propertyUri; return $name; } else { if ($name = $this->get_label($propertyUri) and $this->is_legal_short_name($name)) { $this->_usedProperties[$name] = $propertyUri; return $name; } } $mappings = $this->getConfigGraph()->getVocabPropertyLabels(); $mappings = array_flip($mappings); if (isset($mappings[$propertyUri]) and $this->is_legal_short_name($mappings[$propertyUri])) { $this->_usedProperties[$mappings[$propertyUri]] = $propertyUri; return $mappings[$propertyUri]; } else { preg_match('@^(.+[#/])([^#/]+)$@', $propertyUri, $m); $ns = $m[1]; $localName = $m[2]; if (!in_array($localName, array_values($mappings)) and $this->is_legal_short_name($localName)) { $this->_usedProperties[$localName] = $propertyUri; return $localName; } else { $prefix = $this->get_prefix($ns); $name = $prefix . '_' . $localName; if ($this->is_legal_short_name($name)) { $this->_usedProperties[$name] = $propertyUri; return $name; } else { logDebug("{$propertyUri} has no legal short name"); $name = preg_replace('/[^a-zA-Z0-9_]/', '_', $name); $this->_usedProperties[$name] = $propertyUri; return $name; } } } }
static function sendAlert() { global $DB, $CFG_GLPI; if (!$CFG_GLPI["use_mailing"]) { return 0; } $message = array(); $items_infos = array(); $query = "SELECT `glpi_plugin_ocsinventoryng_notimportedcomputers`.*\n FROM `glpi_plugin_ocsinventoryng_notimportedcomputers`\n LEFT JOIN `glpi_alerts`\n ON (`glpi_plugin_ocsinventoryng_notimportedcomputers`.`id` = `glpi_alerts`.`items_id`\n AND `glpi_alerts`.`itemtype` = 'PluginOcsinventoryngNotimportedcomputer'\n AND `glpi_alerts`.`type` = '" . Alert::END . "')\n WHERE `glpi_alerts`.`date` IS NULL"; foreach ($DB->request($query) as $notimported) { $items_infos[$notimported['entities_id']][$notimported['id']] = $notimported; } foreach ($items_infos as $entity => $items) { if (NotificationEvent::raiseEvent('not_imported', new PluginOcsinventoryngNotimportedcomputer(), array('entities_id' => $entity, 'notimported' => $items))) { $alert = new Alert(); $input["itemtype"] = 'PluginOcsinventoryngNotimportedcomputer'; $input["type"] = Alert::END; foreach ($items as $id => $item) { $input["items_id"] = $id; $alert->add($input); unset($alert->fields['id']); } } else { logDebug(__('%1$s: %2$s') . "\n", Dropdown::getDropdownName("glpi_entities", $entity), __('Send OCSNG not imported computers alert failed', 'ocsinventoryng')); } } }
public function insert($insert) { global $_ejecValida; logDebug($insert); if ($_ejecValida) { $this->obtCon(); try { $this->getCon()->query($insert); } catch (PDOException $e) { logError("Problemas en insert (" . $insert . "): " . mysql_error()); } } }
$ConfigGraph->init(); if ($selectedEndpointUri = $ConfigGraph->getEndpointUri()) { logDebug("Endpoint Uri Selected: {$selectedEndpointUri}"); unset($CompleteConfigGraph); $Response = new LinkedDataApiResponse($Request, $ConfigGraph, $HttpRequestFactory); $Response->process(); break; } else { if ($docPath = $ConfigGraph->dataUriToEndpointItem($Request->getUri())) { logDebug("Redirecting " . $Request->getUri() . " to {$docPath}"); header("Location: {$docPath}", 303); exit; } } } if (!isset($selectedEndpointUri)) { logDebug("No Endpoint Selected"); $Response = new LinkedDataApiResponse($Request, $CompleteConfigGraph); if ($Request->getPathWithoutExtension() == $Request->getInstallSubDir() . CONFIG_PATH) { logDebug("Serving ConfigGraph"); $Response->serveConfigGraph(); } else { logDebug("URI Requested:" . $Request->getPathWithoutExtension()); $Response->process(); } } } $Response->serve(); if (defined("PUELIA_SERVE_FROM_CACHE") and $Response->cacheable) { LinkedDataApiCache::cacheResponse($Request, $Response); }
public function afterExecute() { if ($this->displayDisabled == false && $this->isAjaxFlag == false) { logDebug("<center>Page Execution Time: <font color='red'>" . round(microtime(true) - $this->startTime, 3) . "</font>s</center>"); } }