本文整理汇总了PHP中Debugger::debug方法的典型用法代码示例。如果您正苦于以下问题:PHP Debugger::debug方法的具体用法?PHP Debugger::debug怎么用?PHP Debugger::debug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Debugger
的用法示例。
在下文中一共展示了Debugger::debug方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Resize
public function Resize($image, $newWidth, $targetName)
{
if (!file_exists(PUBLIC_ROOT . $image)) {
$image = '/assets/images/not-found.gif';
}
$imgInfo = getimagesize(PUBLIC_ROOT . $image);
$oldWidth = $imgInfo[0];
$oldHeight = $imgInfo[1];
$changeRatio = $oldWidth / $newWidth;
$newHeight = round($oldHeight / $changeRatio);
$newImage = imagecreatetruecolor($newWidth, $newHeight);
$source = $this->load(PUBLIC_ROOT . $image);
if ($this->imageType == IMAGETYPE_PNG) {
imagealphablending($newImage, false);
imagesavealpha($newImage, true);
$transparent = imagecolorallocatealpha($newImage, 255, 255, 255, 127);
imagefilledrectangle($newImage, 0, 0, $newWidth, $newHeight, $transparent);
}
imagecopyresampled($newImage, $this->image, 0, 0, 0, 0, $newWidth, $newHeight, $oldWidth, $oldHeight);
header('Content-Type: image/jpeg');
imagejpeg($newImage, $targetName, 100);
Debugger::debug($targetName, 'TARGET');
//$this->save($targetName);
$this->image = $newImage;
imagedestroy($newImage);
}
示例2: processAPI
public function processAPI()
{
Debugger::debug('API_' . ucwords($this->endpoint));
if (class_exists('API_' . ucwords($this->endpoint))) {
return $this->_response($this->getResult());
}
return $this->_response(array('error' => "Invalid Endpoint: {$this->endpoint}"), 404);
}
示例3: connect
private static function connect()
{
try {
self::$db = new \PDO('mysql:host=' . self::$dbHost . ';dbname=' . self::$dbName . ';charset=utf8', self::$dbUser, self::$dbPass);
self::$db->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
Debugger::debug('error');
Errors::handle($e, 'sqlerr');
}
}
示例4: curlCall
public function curlCall($endpoint, $curlPostData = null)
{
$curl = curl_init(REST_URL . $endpoint);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
Debugger::debug($endpoint, '$endpoint');
Debugger::debug($curlPostData, '$curlPostData');
if (!empty($curlPostData)) {
Debugger::debug('adding post');
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $curlPostData);
}
$curlResponse = curl_exec($curl);
curl_close($curl);
Debugger::debug($curlResponse, 'CURL response');
return $curlResponse;
}
示例5: create
public function create($params = null)
{
$result = new API_Response();
if (!empty($_POST)) {
$user = new User();
$userId = $user->create($_POST['username'], $_POST['email'], $_POST['password'], $_POST['gender'], $_POST['postcode']);
//$valid = false;
//echo gettype($userId);
\Debugger::debug($userId, 'user id');
if ($userId) {
$result->addItem('message', 'User id ' . $userId . ' inserted');
$result->addItem('userId', $userId);
$result->addItem('success', true);
} else {
$result->addItem('message', 'User id inserted');
$result->addItem('success', false);
}
} else {
$result->addItem('message', 'POST missing');
$result->addItem('success', false);
}
return $result->getResult();
}
示例6: parse
/**
* Parse a BBCode string and convert it into HTML.
*
* Core parser. This is where all the magic begins and ends.
* Core parsing routine. Call with a BBCode string, and it returns an HTML string.
*
* @param string $string The BBCode string to parse.
* @return string Returns the HTML version of {@link $string}.
*/
public function parse($string)
{
Debugger::debug("<b>Parse Begin:</b> input string is " . strlen($string) . " characters long:<br>\n" . "<b>Parse:</b> input: <tt>" . htmlspecialchars(addcslashes($string, "..\\\"'")) . "</tt><br>\n");
// The lexer is responsible for converting individual characters to tokens,
// and uses preg_split to do most of its magic. Because it uses preg_split
// and not a character-by-character tokenizer, the structure of the input
// must be known in advance, which is why the tag marker cannot be changed
// during the parse.
$this->lexer = new BBCodeLexer($string, $this->tag_marker);
$this->lexer->debug = $this->debug;
// If we're fuzzily limiting the text length, see if we need to actually
// cut it off, or if it's close enough to not be worth the effort.
$old_output_limit = $this->output_limit;
Debugger::debug("weee");
if ($this->output_limit > 0) {
if ($this->debug) {
Debugger::debug("<b>Parse:</b> Limiting text length to {$this->output_limit}.<br>\n");
}
if (strlen($string) < $this->output_limit) {
// Easy case: A short string can't possibly be longer than the output
// limit, so just turn off the output limit.
$this->output_limit = 0;
if ($this->debug) {
Debugger::debug("<b>Parse:</b> Not bothering to limit: Text is too short already.<br>\n");
}
} else {
if ($this->limit_precision > 0) {
// We're using fuzzy precision, so make a guess as to how long the text is,
// and then decide whether we can let this string slide through based on the
// limit precision.
$guess_length = $this->lexer->guessTextLength();
if ($this->debug) {
Debugger::debug("<b>Parse:</b> Maybe not: Fuzzy limiting enabled, and approximate text length is {$guess_length}.<br>\n");
}
if ($guess_length < $this->output_limit * ($this->limit_precision + 1.0)) {
if ($this->debug) {
Debugger::debug("<b>Parse:</b> Not limiting text; it's close enough to the limit to be acceptable.<br>\n");
}
$this->output_limit = 0;
} else {
if ($this->debug) {
Debugger::debug("<b>Parse:</b> Limiting text; it's definitely too long.<br>\n");
}
}
}
}
}
// The token stack is used to perform a document-tree walk without actually
// building the document tree, and is an essential component of our input-
// validation algorithm.
$this->stack = [];
// There are no start tags (yet).
$this->start_tags = [];
// There are no unmatched start tags (yet).
$this->lost_start_tags = [];
// There is no text yet.
$this->text_length = 0;
$this->was_limited = false;
// Remove any initial whitespace in pre-trim mode.
if (strlen($this->pre_trim) > 0) {
$this->cleanupWSByEatingInput($this->pre_trim);
}
// In plain mode, we generate newlines instead of <br> tags.
$newline = $this->plain_mode ? "\n" : "<br>\n";
Debugger::debug("hi");
// This is a fairly straightforward push-down automaton operating in LL(1) mode. For
// clarity's sake, we break the tag-processing code into separate functions, but we
// keep the text/whitespace/newline code here for performance reasons.
while (true) {
if (($token_type = $this->lexer->nextToken()) == self::BBCODE_EOI) {
break;
}
if ($this->debug) {
Debugger::debug("<b>Parse:</b> Stack contents: <tt>" . $this->dumpStack() . "</tt><br>\n");
}
switch ($token_type) {
case self::BBCODE_TEXT:
// Text is like an arithmetic operand, so just push it onto the stack because we
// won't know what to do with it until we reach an operator (e.g., a tag or EOI).
if ($this->debug) {
Debugger::debug("<hr />\n<b>Internal_ParseTextToken:</b> fixup and push text: <tt>" . htmlspecialchars($this->lexer->text) . "</tt><br>\n");
}
// If this token pushes us past the output limit, split it up on a whitespace
// boundary, add as much as we can, and then abort.
if ($this->output_limit > 0 && $this->text_length + strlen($this->lexer->text) >= $this->output_limit) {
$text = $this->limitText($this->lexer->text, $this->output_limit - $this->text_length);
if (strlen($text) > 0) {
$this->text_length += strlen($text);
$this->stack[] = array(self::BBCODE_STACK_TOKEN => self::BBCODE_TEXT, self::BBCODE_STACK_TEXT => $this->fixupOutput($text), self::BBCODE_STACK_TAG => false, self::BBCODE_STACK_CLASS => $this->current_class);
}
$this->doLimit();
//.........这里部分代码省略.........
示例7: load404
public function load404()
{
global $module, $page;
$module = '404';
$page = '404';
$e = new Exception('directing to 404');
Debugger::debug('dump', 'REDIRECT', null, true);
return '404';
//Redirect::handle('/' . ((Site::isAdmin()) ? 'admin/' : '') . '404');
}
示例8: doURL
/**
* Format a [url] tag by producing an <a>...</a> element.
*
* The URL only allows http, https, mailto, and ftp protocols for safety.
*
* @param BBCode $bbcode The {@link BBCode} object doing the parsing.
* @param int $action The current action being performed on the tag.
* @param string $name The name of the tag.
* @param string $default The default value passed to the tag in the form: `[tag=default]`.
* @param array $params All of the parameters passed to the tag.
* @param string $content The content of the tag. Only available when {@link $action} is **BBCODE_OUTPUT**.
* @return string Returns the full HTML url.
*/
public function doURL(BBCode $bbcode, $action, $name, $default, $params, $content)
{
// We can't check this with BBCODE_CHECK because we may have no URL
// before the content has been processed.
if ($action == BBCode::BBCODE_CHECK) {
return true;
}
$url = is_string($default) ? $default : $bbcode->unHTMLEncode(strip_tags($content));
if ($bbcode->isValidURL($url)) {
if ($bbcode->debug) {
Debugger::debug('ISVALIDURL');
}
if ($bbcode->getURLTargetable() !== false && isset($params['target'])) {
$target = ' target="' . htmlspecialchars($params['target']) . '"';
} else {
$target = '';
}
if ($bbcode->getURLTarget() !== false && empty($target)) {
$target = ' target="' . htmlspecialchars($bbcode->getURLTarget()) . '"';
}
// If $detect_urls is on, it's possble the $content is already
// enclosed in an <a href> tag. Remove that if that is the case.
$content = preg_replace('/^\\<a [^\\>]*\\>(.*?)<\\/a>$/', "\\1", $content);
return $bbcode->fillTemplate($bbcode->getURLTemplate(), array("url" => $url, "target" => $target, "content" => $content));
} else {
return htmlspecialchars($params['_tag']) . $content . htmlspecialchars($params['_endtag']);
}
}
示例9: Configurations
require_once "classes/Debugger.php";
require_once "classes/SignupGadget.php";
require_once "classes/CommonTools.php";
/* Implementations of the most critical classes */
$configurations = new Configurations();
$page = new Page(1);
$debugger = new Debugger();
$database = new Database();
/* The code */
$signupGadgets = new SignupGadgets();
// Check if the search was performed
$searchString = CommonTools::GET('search');
$year = CommonTools::GET('year');
// Is the search performed?
if ($searchString != null && $searchString != "") {
$debugger->debug("Searching signup gadgets using search string {$searchString}", "index.php");
$signupGadgets->selectSearchSignupGadget($searchString);
} else {
if ($year != null && $year != "") {
$signupGadgets->selectSignupGadgetsByYear($year);
} else {
$signupGadgets->selectOpenGadgetsOrClosedDuringLastDays(7);
}
}
// Get all selected gadgets to array
$signupGadgets_array = $signupGadgets->getSignupGadgets();
// Print table headers
$page->addContent("<table id=\"signup-gadgets\">");
$page->addContent("<tr id=\"signup-header-row\">");
$page->addContent("<th id=\"signup-name-header\">Ilmo</th><th>Avautuu</th><th>Sulkeutuu</th><th>Tila</th><th>Muokkaa</th><th>Poista</th><th>Muuta tilaa</th>");
$page->addContent("</tr>");
示例10: User
} else {
if ($action == "continueandcancelold") {
$user = new User($signupid);
$user->cancelUnconfirmedSignupAndRefreshSession();
header("Location: " . $configurations->webRoot . "confirm/" . $user->getNewSignupId());
} else {
// Check that signup is open
$newSignupGadget = new SignupGadget($signupid);
$user = null;
if ($newSignupGadget->isOpen()) {
$user = new User($signupid);
} else {
$debugger->error("Ilmoittautuminen ei ole avoinna.", "queue.php");
}
if ($user->getUnconfirmedSignupExists()) {
$debugger->debug("Unconfirmed signup exists", "queue.php");
if ($user->getUnconfirmedSignupIsNotTheSameAsThis()) {
$debugger->debug("Unconfirmed signup exists, but it is not this one", "queue.php");
$signupgadget = new SignupGadget($user->getOldSignupId());
$page->addContent("<p><b>Huom!</b> Olet ilmoittautunut jo ilmomasiinassa <b>" . $signupgadget->getTitle() . "</b>, muttet ole vahvistanut ilmoittautumista. " . "Ennen kuin voit ilmoittautua toiseen ilmomasiinaan sinun pitää vahvistaa tai peruuttaa" . " aikasemmat vahvistamattomat ilmoittautumiset.</p>");
$page->addContent("<p>Valitse mitä haluat tehdä:</p>");
$page->addContent("<p> >> <a href=\"" . $configurations->webRoot . "continueandcancelold/" . $user->getNewSignupId() . "\">Peruuta aiempi vahvistamaton ilmoittautuminen ja " . "siirry eteenpäin</a></p>");
$page->addContent("<p> >> <a href=\"" . $configurations->webRoot . "confirmold/" . $user->getOldSignupId() . "\">Siirry vahvistamaan aiempi ilmoittautuminen</a></p>");
$page->printPage();
} else {
header("Location: " . $configurations->webRoot . "confirm/" . $user->getNewSignupId());
}
} else {
header("Location: " . $configurations->webRoot . "confirm/" . $user->getNewSignupId());
}
}
示例11: decodeTag
/**
* Given a string containing a complete [tag] (including its brackets), break it down into its components and return them as an array.
*
* @param string $tag The tag to decode.
* @return array Returns the array representation of the tag.
*/
protected function decodeTag($tag)
{
Debugger::debug("<b>Lexer::InternalDecodeTag:</b> input: " . htmlspecialchars($tag) . "<br />\n");
// Create the initial result object.
$result = ['_tag' => $tag, '_endtag' => '', '_name' => '', '_hasend' => false, '_end' => false, '_default' => false];
// Strip off the [brackets] around the tag, leaving just its content.
$tag = substr($tag, 1, strlen($tag) - 2);
// The starting bracket *must* be followed by a non-whitespace character.
$ch = ord(substr($tag, 0, 1));
if ($ch >= 0 && $ch <= 32) {
return $result;
}
// Break it apart into words, quoted text, whitespace, and equal signs.
$pieces = preg_split("/(\\\"[^\\\"]+\\\"|\\'[^\\']+\\'|=|[\\x00-\\x20]+)/", $tag, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
$ptr = 0;
// Handle malformed (empty) tags correctly.
if (count($pieces) < 1) {
return $result;
}
// The first piece should be the tag name, whatever it is. If it starts with a /
// we remove the / and mark it as an end tag.
if (!empty($pieces[$ptr]) && substr($pieces[$ptr], 0, 1) === '/') {
$result['_name'] = strtolower(substr($pieces[$ptr++], 1));
$result['_end'] = true;
} else {
$result['_name'] = strtolower($pieces[$ptr++]);
$result['_end'] = false;
}
// Skip whitespace after the tag name.
while (($type = $this->classifyPiece($ptr, $pieces)) == ' ') {
$ptr++;
}
$params = [];
// If the next piece is an equal sign, then the tag's default value follows.
if ($type != '=') {
$result['_default'] = false;
$params[] = ['key' => '', 'value' => ''];
} else {
$ptr++;
// Skip whitespace after the initial equal-sign.
while (($type = $this->classifyPiece($ptr, $pieces)) == ' ') {
$ptr++;
}
// Examine the next (real) piece, and see if it's quoted; if not, we need to
// use heuristics to guess where the default value begins and ends.
if ($type == "\"") {
$value = $this->stripQuotes($pieces[$ptr++]);
} else {
// Collect pieces going forward until we reach an = sign or the end of the
// tag; then rewind before whatever comes before the = sign, and everything
// between here and there becomes the default value. This allows tags like
// [font=Times New Roman size=4] to make sense even though the font name is
// not quoted. Note, however, that there's a special initial case, where
// any equal-signs before whitespace are considered to be part of the parameter
// as well; this allows an ugly tag like [url=http://foo?bar=baz target=my_window]
// to behave in a way that makes (tolerable) sense.
$after_space = false;
$start = $ptr;
while (($type = $this->classifyPiece($ptr, $pieces)) != -1) {
if ($type == ' ') {
$after_space = true;
}
if ($type == '=' && $after_space) {
break;
}
$ptr++;
}
if ($type == -1) {
$ptr--;
}
// We've now found the first (appropriate) equal-sign after the start of the
// default value. (In the example above, that's the "=" after "target".) We
// now have to rewind back to the last whitespace to find where the default
// value ended.
if ($type == '=') {
// Rewind before = sign.
$ptr--;
// Rewind before any whitespace before = sign.
while ($ptr > $start && $this->classifyPiece($ptr, $pieces) == ' ') {
$ptr--;
}
// Rewind before any text elements before that.
while ($ptr > $start && $this->classifyPiece($ptr, $pieces) != ' ') {
$ptr--;
}
}
// The default value is everything from $start to $ptr, inclusive.
$value = "";
for (; $start <= $ptr; $start++) {
if ($this->classifyPiece($start, $pieces) == ' ') {
$value .= " ";
} else {
$value .= $this->stripQuotes($pieces[$start]);
}
//.........这里部分代码省略.........
示例12: User
*
* 11: Mikko Koski
* 12: mikko.koski@tkk.fi
* 13: Normaali ruokavalio
* 14-0: Tykkään kahvista
* 14-1: Tykkään suklaasta
* 14-2: Tykkään pähkinästä
* 15: Punaviini
* ilmo_id: 56
* user_id: 143
* question_ids: 11,12,13,14-0,14-1,14-2,15
*/
$signupId = CommonTools::POST("signupid");
$userId = CommonTools::POST("userid");
$user = new User($signupId);
$debugger->debug("UserID: " + $userId, "save.php");
$signupGadget = new SignupGadget($signupId);
$questions = $signupGadget->getAllQuestions();
$answers = array();
// This is for debugging. It's easy to see from here the variable names that
// the form sends
$debugger->listDefinedPostAndGetVars("save.php");
foreach ($questions as $question) {
$answer = null;
// Checkbox is a bit more complicated
if ($question->getType() == "checkbox") {
$answer = parseCheckboxAnswer($question);
} else {
$answer = parseNormalAnswer($question);
}
array_push($answers, $answer);
示例13: debug
/**
* Debugger Function
*
* To support a debug in any position of the code,
* regardless the possibility of a template engine,
* this must be text-based
*
* @param $mixed
* @param $element
*/
function debug($mixed, $element = '#content')
{
//TODO: Use Termination function
echo Debugger::debug($mixed, $element);
exit;
}