protected function _execute($queries) { $result = true; foreach ($queries as $query) { if ($response = $this->_db->query($query)) { Debug::info("Applied: " . get_class($this)); } else { Debug::error("Error: " . get_class($this)); $result = false; } } return $result; }
/** * previewSave: * Sometimes during development we need to see the exact query that is generated. * This function uses debugging messages to show the query that would be generated * and executed by save(), but without actually executing it against the database. */ function previewSave() { $keyName = static::$_keyField; $keyValue = addslashes($this->getKeyValue()); if (!$this->recordExists()) { $fields = $this->getInsertFieldList(); $values = $this->getInsertValueList(); if (!empty(static::$_insertTimestampField)) { $fields .= ', `' . static::$_insertTimestampField . '`'; $values .= ", NOW()"; } Debug::info('[DB-PREVIEW] INSERT INTO `%s` (%s) VALUES (%s)', static::$_tableName, $fields, $values); } else { $fields = $this->getUpdateFieldList(); if (!empty(static::$_updateTimestampField)) { if (!empty($fields)) { $fields .= ', '; } $fields .= '`' . static::$_updateTimestampField . '` = NOW()'; } Debug::info("[DB-PREVIEW] UPDATE `%s` SET %s WHERE `%s` = '%s'", static::$_tableName, $fields, $keyName, $keyValue); } }
<?php session_start(); # Start benchmark $benchmark_start = microtime(TRUE); # We need the File library for autoloader require_once CORE_PATH . '/libraries/File.php'; # Register class autoloader spl_autoload_register(array('File', 'autoloader')); # Load core configs require CORE_PATH . "/config/config.php"; # Stop benchmark, get execution time define('EXECUTION_TIME', number_format(microtime(TRUE) - $benchmark_start, 4)); # Optionally show debugging info if not in production. to enable add ?debug to URI Debug::info();
public function debug() { Debug::info($this->_mysql); }
$previous[] = $post['autor_link']; $blog_list .= "<li><a href='" . $post['autor_link'] . "'><img src='/gfx/feed-icon-10x10.png' " . "alt='RSS feed' /></a>" . "<a href='" . $post['blog_url'] . "'>" . $post['blog_title'] . "</a></li>\n"; $fOutput->writeOpml(File::ReadAndParse('xml/opml_item.xml', $post)); } } $fOutput->writeOpml(File::ReadAndParse('xml/opml_foot.xml')); $blog_list .= "</ul>\n"; define('BLOG_LIST', $blog_list); unset($blog_list); # Other similar planets: $planets = $Config->getPlanetas(); $planet_list = "<ul>\n"; foreach ($planets as $planet) { $planet_list .= "<li><a href='" . $planet['rss'] . "'><img src='/gfx/feed-icon-10x10.png' alt='Feed RSS' /></a>" . "<a href='" . $planet['url'] . "'>" . $planet['name'] . "</a></li>\n"; } $planet_list .= "</ul>\n"; define('PLANET_LIST', $planet_list); unset($planet_list); # Sidebar generation: $fOutput->write(File::ReadAndParse('html/sidebar.html')); # Extended content initially hidden: $fOutput->write('<script type="text/javascript">$(".content").hide();</script>'); # Statistics: Debug::info("HTML: Statistics code"); $fOutput->write(File::ReadAndParse('html/stats.html')); # Closure: Debug::info("Closures"); $fOutput->write(File::ReadAndParse('html/footer.html')); $fOutput->writeRss(File::Read('xml/rss20_foot.xml')); Debug::info("EOF");
public function getFolders($token) { $url = "https://docs.google.com/feeds/documents/private/full/-/folder?showfolders=true"; $results = self::fetchXML($url, $token); Debug::info($results); if (!$results) { return array(); } $return = array(); foreach ($results as $result) { $data = array(); $data['id'] = $result->{'id'}; $data['title'] = $result->{'title'}; //$data['due-date'] = $result->{'due-date'}; //$data['space-id'] = $result->{'space-id'}; Debug::info($data['title']); $return[] = $data; } return $return; }
function __construct() { Debug::info("OBJECT: " . get_class($this)); $this->_init(); }
/** * Throws a redirection * * @param string $url URL to be redirected * @param integer $time The time before being redirected * @param integer $code Status code to be sent * @throws Exception if the URL is empty * * @return void */ public function redirect($url, $time = 0, $code = self::FOUND) { if (empty($url)) { throw new Exception('Can\'t redirect to an empty url'); } if (!$this->isRedirect($code)) { throw new Exception(sprintf('Bad HTTP status response (%1$s given)', $code)); } if ($time === 0) { $header = 'Location'; $value = $url; } else { $header = 'Refresh'; $value = $time . ';url=' . $url; } Debug::info('Redirecting...'); $this->_redirect = true; $this->status($code); $this->header($header, $value, true, $code); $this->sendHeaders(); }
} else { if ($collection = getParam("views")) { if (!strcmp($collection, "dbupdate")) { require_once ROOT_PATH . 'lib/core/dbupdate.php'; require_once ROOT_PATH . 'lib/core/dbchange.php'; $dbupdate = new Dbupdate(); $dbupdate->run(); } else { Debug::warning("Route: [views] : No Element"); } } else { if ($collection = getParam("assembla")) { if (!strcmp($collection, "query")) { require_once ROOT_PATH . 'lib/core/curl.php'; require_once ROOT_PATH . 'lib/rest/assembla.php'; Debug::info(print_r($_POST, true)); $status = getParam('status', 'open'); $timeframe = getParam('timeframe', 'this-week'); $group = getParam('group', 'both'); $assembla = new Assembla(); $result = $assembla->loadAllData($status, $timeframe, $group); $html = $assembla->view($result, $group); $response->setData($html); } else { Debug::warning("Route: [assembla] : No Element"); } } else { Debug::warning("Route: No Collection"); } } }
public function loadAllData($status, $timeframe, $group) { Debug::info($status . ":" . $timeframe . ":" . $group); // Debug::info($timeframe); $spaces = $this->getSpaces(); $projects = array(); $users = array(); $tickets = array(); $milestones = array(); $validMilestones = array(); $spaceholder = ""; $projectTickets = array(); foreach ($spaces as $space) { if ($status == "all") { $projectTickets = $this->getAllTickets($space['id']); } else { if ($status == "open") { $projectTickets = $this->getOpenTickets($space['id']); } else { if ($status == "closed") { $projectTickets = $this->getClosedTickets($space['id']); } } } $milestones = array_merge($milestones, $this->getMilestones($space['id'])); $users = array_merge($users, $this->getUsers($space['id'])); $tickets = array_merge($tickets, $projectTickets); $project['name'] = str_replace('"', "'", $space['name']); $project['space'] = $space['space']; $project['tickets'] = array(); $project['users'] = $users; $projects[(string) $space['id']] = $project; $spaceholder = (string) $space['id']; } // Timeframe if ($timeframe != "all-time") { $adjust = $timeframe == "next-week" ? "+1 week" : ""; foreach ($milestones as $milestone) { //$dt = new DateTime($milestone['due-date']); //$ts = $dt->getTimestamp(); $ts = strtotime($milestone['due-date']); if (strtotime("last sunday {$adjust}") < $ts && strtotime("next sunday {$adjust}") > $ts) { $validMilestones[] = (int) $milestone['id']; } } } else { foreach ($milestones as $milestone) { $validMilestones[] = (int) $milestone['id']; } //Debug::info($validMilestones); } foreach ($projects as &$project) { foreach ($users as $user) { $project['tickets'][(string) $user['id']] = array(); } $project['tickets']['unassigned'] = array(); } foreach ($tickets as $ticket) { $tid = $group != 'user' ? (string) $ticket['space-id'] : $spaceholder; if ($timeframe != "all-time") { if ($ticket['milestone-id'] == "") { continue; } if (!in_array($ticket['milestone-id'], $validMilestones)) { continue; } } $id = $ticket['assigned-to-id']; $claimed = false; foreach ($users as $user) { if (!strcmp($id, $user['id'])) { $claimed = true; $projects[$tid]['tickets'][(string) $user['id']][] = $ticket; break; } } if (!$claimed) { $projects[$tid]['tickets']['unassigned'][] = $ticket; } } // Project // User // User Tickets // Title // Priority //Debug::info($projects); return $projects; }
private function schemaTableExists() { global $config; $query = "SELECT table_name\n FROM information_schema.tables\n WHERE table_schema = '" . $config['database.name'] . "'\n AND table_name = 'schema_versions_applied'"; $result = $this->_db->query($query); if ($result) { Debug::info("Schema_Versions_Applied table found."); return true; } Debug::error("Schema_Versions_Applied table not found."); $query = "\n\t\t\tCREATE TABLE `schema_versions_applied` (\n `change_id` int(11) NOT NULL AUTO_INCREMENT,\n `change_filename` varchar(255) NOT NULL,\n `applied` int(11) NOT NULL,\n PRIMARY KEY (`change_id`),\n UNIQUE KEY (`change_filename`)\n ) ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;"; $result = $this->_db->query($query); if ($result) { Debug::info("Schema_Versions_Applied table created."); return true; } return false; }
/** * * Get posts from feeds: * @param array $feeds Array with the feeds. * @return array Array with the posts. */ public function getPosts($feeds) { $posts = array(); foreach ($feeds as $name => $feed) { Debug::info("Getting posts from " . $feed['url']); $rss = new SimplePie($feed['url']); $rss->handle_content_type(); $rss->force_feed(true); $counter = 1; foreach ($rss->get_items() as $item) { Debug::info(" post {$counter} of " . MAXPOSTS . "."); if (!is_object($item)) { Debug::error("Parsing item (" . $item . ")."); } else { if (strstr($item->get_title(), "[minipost]")) { Debug::say("Minipost...passing."); } else { $counter++; $timestamp = strtotime($item->get_date()); # Post: $posts[$timestamp]['id'] = "p" . $timestamp . "-" . $counter; $posts[$timestamp]['pubdate'] = $item->get_date('r'); $posts[$timestamp]['date'] = $item->get_local_date(); $posts[$timestamp]['time'] = $item->get_local_date("%T"); $posts[$timestamp]['permalink'] = $item->get_permalink(); $posts[$timestamp]['title'] = $item->get_title(); $posts[$timestamp]['description'] = $item->get_description(); $posts[$timestamp]['content'] = $item->get_content(); if ($posts[$timestamp]['description'] == $posts[$timestamp]['content'] and strlen($posts[$timestamp]['content']) < 400) { $posts[$timestamp]['description'] = Html::Cut(Html::BurnerClean($item->get_description())); $posts[$timestamp]['content'] = ""; $posts[$timestamp]['toggle'] = ""; } else { $posts[$timestamp]['description'] = Html::Cut(Html::BurnerClean($item->get_description())); $posts[$timestamp]['content'] = Html::Clean($item->get_content()); $posts[$timestamp]['toggle'] = "<a onclick='ToggleContent(\"" . $posts[$timestamp]['id'] . "\"); return false;' href=\"#\">⇓ Read more</a>"; } // Microblogging posts have same description as title if (FALSE !== strpos($posts[$timestamp]['title'], $posts[$timestamp]['description'])) { $posts[$timestamp]['description'] = ""; $posts[$timestamp]['content'] = ""; $posts[$timestamp]['toggle'] = ""; } # Rss: $posts[$timestamp]['description_rss'] = $posts[$timestamp]['description']; $posts[$timestamp]['content_rss'] = $posts[$timestamp]['content']; # author: if (method_exists($item, 'get_author') and is_object($item->get_author())) { # The feed ones: $posts[$timestamp]['author'] = $item->get_author()->get_name(); $posts[$timestamp]['author_link'] = $item->get_author()->get_link(); } else { Debug::say("No author data feed " . $name); $posts[$timestamp]['author'] = $name; $posts[$timestamp]['author_link'] = $rss->get_permalink(); } # Si han quedado vacíos pese a todo: if (empty($posts[$timestamp]['author'])) { $posts[$timestamp]['author'] = $name; } if (empty($posts[$timestamp]['author_link'])) { $posts[$timestamp]['author_link'] = $feed['url']; } $posts[$timestamp]['author_email'] = $feed['email']; # Gravatar: if (strlen($feed['avatar'])) { $posts[$timestamp]['author_avatar'] = "http://www.gravatar.com/avatar.php?gravatar_id=" . md5($feed['avatar']) . "&size=40&default=" . urlencode(DEFAULT_AVATAR); } else { if (strlen($feed['avatar_url'])) { $posts[$timestamp]['author_avatar'] = $feed['avatar_url']; } } # Blog: $posts[$timestamp]['blog_title'] = $rss->get_title(); $posts[$timestamp]['blog_url'] = $rss->get_permalink(); $posts[$timestamp]['blog_desc'] = $rss->get_description(); # Logo: $posts[$timestamp]['logo_url'] = $rss->get_image_url(); $posts[$timestamp]['logo_link'] = $rss->get_image_link(); $posts[$timestamp]['logo_title'] = $rss->get_image_title(); } } if ($counter > MAXPOSTS) { break; } } } krsort($posts); #Debug::dump($posts); return $posts; }