function query($sql, $is_read = true) { $result = mysql_query($sql, self::$conn[$this->i]); config('log|mysql_sql', 'log') && log::sql($sql, $is_read); if ($result) { return $result; } $info = $sql . ' {' . mysql_error() . '}'; config('exception|sql_error', 'log') && log::exception('mysql', $info); config('param|debug', 'db') && exit($info); }
/** * Renders template using provided data. * * This method is managing exceptions thrown inside to bubble up to current * level of output buffering at least. * * @param string $template template name to render * @param variable_space|array $data data to use on rendering template * @return string rendered template */ public static function render($template = null, $data = null) { $oblevel = ob_get_level(); try { if ($data === null || is_array($data)) { $data = variable_space::fromArray((array) $data); } // @todo consider selecting engine depending on current configuration instead of using current view's one return static::engine()->render($template, $data); } catch (\Exception $e) { while ($oblevel < ob_get_level()) { ob_end_clean(); } static::error(log::exception('[%s:%s in %s@%d]', get_class($e), $e->getMessage(), $e->getFile(), $e->getLine())); return ''; } }
private function act_smtp() { $response = str_replace("\r\n", "", fgets($this->sock, 512)); if (!preg_match("/^[23]/", $response)) { fwrite($this->sock, "QUIT\r\n"); fgets($this->sock, 512); log::exception('mail', 'remote host returned-' . $response); return false; } return true; }
public function execute($_options = null) { $nabaztag = $this->getEqLogic(); $parameters = $this->getConfiguration('parameters'); $type = $this->getConfiguration('request'); switch ($this->subType) { case 'message': $parameters = urlencode(str_replace('#message#', $_options['message'], $parameters)); break; case 'slider': $parameters = str_replace('#slider#', $_options['slider'], $parameters); break; } if ($type == 'urlList') { $parameters = urlencode($parameters); $request = 'http://' . $nabaztag->getConfiguration('addr') . '/ojn/FR/api_stream.jsp?sn=' . $nabaztag->getConfiguration('mac') . '&token=' . $nabaztag->getConfiguration('token') . '&' . $type . '=' . $parameters; } else { $request = 'http://' . $nabaztag->getConfiguration('addr') . '/ojn/FR/api.jsp?sn=' . $nabaztag->getConfiguration('mac') . '&token=' . $nabaztag->getConfiguration('token') . '&' . $type . '=' . $parameters; } log::add('nabaztag', 'debug', $request); try { $request = new com_http($request); $result = $request->exec(0.1, 1); log::add('nabaztag', 'debug', print_r($result, true)); $xml = new SimpleXMLElement($result); $json = json_decode(json_encode($xml), TRUE); } catch (Exception $e) { log::add('nabaztag', 'debug', log::exception($e)); } if (isset($json) && is_array($json) && isset($json['message']) && ($json['message'] == 'PREMIUM_ONLY' || $json['message'] == 'PLUGINNOTAVAILABLE')) { throw new Exception($json['message'] . ' : ' . $json['comment']); } }