예제 #1
0
function passwordExists($dbConn, $username, $password)
{
    $isValid = false;
    $dbQuery = "SELECT Password FROM USERS WHERE Username = '******' LIMIT 1";
    FB::info('passwordExists() query: ' . $dbQuery);
    $dbRows = mysqli_query($dbConn, $dbQuery);
    $dbValues = mysqli_fetch_assoc($dbRows);
    $dbPassword = $dbValues['Password'];
    if (password_verify($password, $dbPassword)) {
        $isValid = true;
        FB::log('Password is valid!');
        // Check if the password needs a rehash.
        if (password_needs_rehash($dbPassword, PASSWORD_DEFAULT)) {
            FB::log('Rehashing password!');
            $dbPassword = password_hash($password, PASSWORD_DEFAULT);
            $dbQuery = "UPDATE USERS SET Password = '******' WHERE Username = '******'";
            FB::info('Password rehash query: ' . $dbQuery);
            $dbRows = mysqli_query($dbConn, $dbQuery);
            if ($dbRows) {
                FB::log('Password rehash successful!');
            } else {
                FB::error('Password rehash failed: ' . mysqli_error($dbConn));
            }
        }
    }
    return $isValid;
}
예제 #2
0
 function index()
 {
     $all = $this->equipment->getAll();
     FB::error($all);
     $this->set('equipment', $all);
     FB::error($this->equipment);
 }
예제 #3
0
function addUser($dbConn, $username, $password, $email)
{
    // Add user to USERS table.
    $dbQuery = "INSERT INTO USERS(Username, First_name, Last_name, Email, Status, About, Date_joined, Password) " . "VALUES('" . $username . "', '', '', '" . $email . "', 'active', '', CURDATE(), '" . $password . "')";
    FB::info('addUser() query:' . $dbQuery);
    if ($dbResults = mysqli_query($dbConn, $dbQuery)) {
        FB::log('USERS insert success! (I think)');
    } else {
        FB::error('USERS insert failed!');
    }
    $userId = mysqli_insert_id($dbConn);
    // ID of the latest created user.
    FB::info('New User ID: ' . $userId);
    // Add user role for newly created user into USER_ROLES table.
    $dbQuery = "INSERT INTO USER_ROLES(User_Id, Role_Id)" . "VALUES(" . $userId . ", 1)";
    if ($dbResults = mysqli_query($dbConn, $dbQuery)) {
        FB::log('USER_ROLES insert success! (I think)');
    } else {
        FB::error('USER_ROLES insert failed!');
    }
    // Add default avatar for newly created user into IMAGES table.
    $avatar = file('images/default_avatar.png');
    // Default avatar for new users.
    $dbQuery = "INSERT INTO IMAGES(Description, Image, User_Id) " . "VALUES('test', '" . $avatar . "', " . $userId . ")";
    if ($dbResults = mysqli_query($dbConn, $dbQuery)) {
        FB::log('IMAGES insert success! (I think)');
    } else {
        FB::error('IMAGES insert failed!');
    }
}
예제 #4
0
 public static function fire($value)
 {
     $dbgs = array_shift(debug_backtrace());
     $msg = date('[ Y-m-d H:i:s ]' . "\n");
     $msg .= 'file: ' . $dbgs['file'] . "\n";
     $msg .= 'line: ' . $dbgs['line'] . "\n\n";
     FB::warn($msg);
     FB::error($value);
 }
예제 #5
0
 public static function logError($m)
 {
     $s = self::toStr($m);
     error_log("KLOUDSPEAKER ERROR: " . $s);
     if (self::$firebug) {
         FB::error($m);
     }
     if (self::isDebug()) {
         self::$trace[] = $s;
     }
 }
예제 #6
0
 function save()
 {
     $this->dbh->TransactionBegin();
     $query = "INSERT INTO room (name, capacity, note, room_type)\n\t\t\t VALUES (\$1, \$2, \$3, \$4)";
     $this->dbh->query($query, array($this->nazov, $this->kapacita, $this->poznamka, $this->id_miestnost_typ));
     $id = $this->dbh->GetLastInsertID();
     FB::error($id);
     foreach ($this->vybavenie as $eq) {
         $query = "INSERT INTO room_equipment (id_room,id_equipment)\n            \t VALUES (\$1, \$2)";
         $this->dbh->query($query, array($id, $eq));
     }
     $this->dbh->TransactionEnd();
 }
예제 #7
0
 private function _invalid_data(&$checked)
 {
     // nastavi vsetky veci co zadal korektne
     $this->set('room', $checked);
     // nasledne dve nie su previazane na hodnoty v $this->rooms =>
     // ich pouzitie je korektne
     $room_types = $this->room_type->getAll();
     $this->set('room_types', $room_types);
     $equips = $this->rooms->getEquipment();
     FB::error($equips);
     $this->set('equips', $equips);
     $this->set('equip', $_POST['vybavenie']);
 }
예제 #8
0
 public function findByLogin($login)
 {
     FB::error("robim");
     $query = "SELECT p.id, p.login, p.email, p.notification_on, p.ais_id, " . Users::vyskladajMeno("p", "name", false) . "FROM person p\n        \t WHERE login = \$1";
     $this->dbh->query($query, array($login));
     $user = $this->dbh->fetch_assoc();
     //fb($user);
     if (!empty($user['id'])) {
         $user['groups'] = $this->loadGroups($user['id']);
     }
     //$user['posielat_moje_zmeny'] = ($user['posielat_moje_zmeny'] = 't') ? TRUE : FALSE;
     $user['notification_on'] = $this->convertBoolean($user['notification_on']);
     return $user;
 }
 function close()
 {
     global $phpAnvil;
     //---- Check if Site is Set
     if (isset($phpAnvil->site)) {
         //---- Initialize the Site
         $phpAnvil->site->close();
         $return = true;
     } else {
         FB::error('Site not set in phpAnvil.');
     }
     $phpAnvil->triggerEvent('application.close');
     return $return;
 }
예제 #10
0
 public function offsetGet($offset)
 {
     global $phpAnvil;
     global $firePHP;
     $return = false;
     if (!$this->exists($offset)) {
         $msg = 'Controller (' . $offset . ') not found.';
         $this->_addTraceInfo(__FILE__, __METHOD__, __LINE__, $msg, self::TRACE_TYPE_ERROR);
         FB::error($msg);
     } else {
         $return = parent::offsetGet($offset);
     }
     return $return;
 }
예제 #11
0
 function process()
 {
     global $phpAnvil;
     $return = false;
     $phpAnvil->triggerEvent('application.open');
     //---- Check if Site is Set
     if (isset($phpAnvil->site)) {
         //---- Initialize the Site
         $phpAnvil->site->open();
         $return = true;
     } else {
         FB::error('Site not set in phpAnvil.');
     }
     return $return;
 }
예제 #12
0
function dbConnect()
{
    // Database connection info, which is gained from a file outside the web root directory.
    // Contains, in order: host, username, password, schema.
    $dbInfo = file('/home/jayme/files/dbinfo');
    FB::log('Grabbed DB information');
    $dbConn = mysqli_connect(trim($dbInfo[0]), trim($dbInfo[1]), trim($dbInfo[2]), trim($dbInfo[3]));
    // Schema
    FB::log('Connecting to database');
    if (mysqli_connect_errno($dbConn)) {
        printf("Database connection failed: " . mysqli_connect_error());
        FB::error('Database connection failed: "' . mysqli_connect_error());
    }
    FB::log('DB connection success!');
    return $dbConn;
}
예제 #13
0
 /**
  * Logs an exception
  *
  * @param object $exception_object  The Exception object
  * @param bool $is_fatal            Whether or not to stop execution
  * @return void
  */
 public static function log_exception($exception_object, $is_fatal = TRUE)
 {
     if (class_exists('FB')) {
         FB::error($exception_object);
     }
     // Generates an error message
     $trace = array_pop($exception_object->getTrace());
     $arg_str = implode(',', $trace['args']);
     $method = isset($trace['class']) ? "{$trace['class']}::{$trace['function']}" : $trace['function'];
     $err = "[" . date("Y-m-d h:i:s") . "] " . $exception_object->getFile() . ":" . $exception_object->getLine() . " - Error with message \"" . $exception_object->getMessage() . "\" was thrown from " . "{$method} ({$trace['file']}:{$trace['line']})" . " with arguments: ('" . implode("', '", $trace['args']) . "')\n";
     // Logs the error message
     self::_write_log($err);
     // Stop script execution if the error was fatal
     if ($is_fatal === TRUE) {
         die($exception_object->getMessage());
     }
 }
예제 #14
0
 /**
  * Vlozi informacie o userovi do session
  * @param <array> $user informacie o userovi, vo formate:
  * id - id usera
  * meno - meno usera
  * login - username
  * groups - pole skupin, ktorych je user clenom
  */
 public function writeUser($user)
 {
     // vlozi data noveho usera
     FB::error($user);
     $this->write('uid', $user['id']);
     $this->write('name', $user['name']);
     // to je uz vyskladane z DB
     $this->write('mail', $user["email"]);
     $this->write('username', $user['login']);
     $this->write('groups', $user['groups']);
     $this->write('semester', $user['semester']);
     if ($user['notification_on'] == 't') {
         $this->write('notifyMyActions', TRUE);
     } else {
         $this->write('notifyMyActions', FALSE);
     }
 }
예제 #15
0
 /**
  * (non-PHPdoc)
  * @see debugObject::msg()
  */
 public function msg($msg, $level = DEBUG_LOG)
 {
     if (!empty($msg) && $this->_level & $level) {
         if (DEBUG_INFO & $level) {
             if (is_array($msg)) {
                 FB::group(current($msg), array('Collapsed' => true));
                 FB::info($msg);
                 FB::groupEnd();
             } else {
                 FB::info($msg);
             }
         } elseif (DEBUG_ERROR & $level || DEBUG_STRICT & $level) {
             if (is_array($msg)) {
                 FB::group(current($msg), array('Collapsed' => true, 'Color' => '#FF0000'));
                 FB::error($msg);
                 FB::groupEnd();
             } else {
                 FB::error($msg);
             }
         } elseif (DEBUG_WARNING & $level) {
             if (is_array($msg)) {
                 FB::group(current($msg), array('Collapsed' => true, 'Color' => '#FF0000'));
                 FB::warn($msg);
                 FB::groupEnd();
             } else {
                 FB::warn($msg);
             }
         } else {
             if (is_array($msg)) {
                 FB::group(current($msg), array('Collapsed' => true));
                 FB::log($msg);
                 FB::groupEnd();
             } else {
                 FB::log($msg);
             }
         }
     }
 }
예제 #16
0
파일: Message.php 프로젝트: phpburn/phpburn
 /**
  * Main function of Messaging System. It outputs a message based on the mode defined.
  * 
  * @param String $originalMessage
  * @param String $type
  * @return String
  * @return Boolean
  */
 public static function output($originalMessage, $type = self::NOTICE, $priority = self::NORMAL)
 {
     if (self::$mode == null) {
         self::setMode(self::CONSOLE);
     }
     if ($type == null) {
         $type = self::NOTICE;
     }
     //Searching if Views is loaded
     if (array_search('PhpBURN_Views', get_declared_classes()) == true) {
         $messageClass = 'PhpBURN_Views';
     } else {
         $messageClass = __CLASS__;
     }
     //Now time
     $time = mktime(date('H'), date('i'), date('s'), date('m'), date('d'), date('Y'));
     $time = strftime(SYS_USE_DATEFORMAT, $time);
     //Usage
     $usage = number_format(memory_get_usage() / 1048576, 2, ',', ' ');
     //  		$timing = getrusage();
     //Setup the message
     $message = sprintf("%s: [%s (%s MB)] ", $type, $time, $usage);
     $message .= var_export($originalMessage, true);
     $message .= "\r\n\r\n";
     //The breaklines
     //Sending the message
     switch (self::$mode) {
         case self::BROWSER:
         case self::CONSOLE:
             print $message = call_user_func(array($messageClass, 'lazyTranslate'), $message);
             break;
         case self::FIREBUG:
             $message = call_user_func(array($messageClass, 'lazyTranslate'), $message);
             switch ($type) {
                 case self::LOG:
                     FB::log($message);
                     break;
                 case self::WARNING:
                     FB::warn($message);
                     break;
                 case self::NOTICE:
                     FB::info($message);
                     break;
                 case self::ERROR:
                     FB::error($message);
                     break;
                 default:
                     FB::info($message);
                     break;
             }
             break;
         case self::FILE:
             $fileName = self::$fileName == null || !isset(self::$fileName) ? 'phpburn.log' : $this->fileName;
             $fileName = SYS_BASE_PATH . $fileName;
             $fp = fopen($fileName, 'a+');
             fwrite($fp, call_user_func(array($messageClass, 'lazyTranslate'), $message));
             fclose($fp);
             //@chmod($fileName, 0755);
             break;
         default:
             break;
     }
     if ($type == self::EXCEPTION) {
         throw new Exception($message);
     }
     unset($time, $usage, $message, $translatedType);
 }
예제 #17
0
 /**
  * use of FirePHP::error() if allowed
  *
  * @param mixed $obj
  * @param string $label
  * @return void
  */
 public static function error($obj, $label = '')
 {
     if (PS_USE_FIREPHP) {
         FB::error($obj, $label);
     }
 }
예제 #18
0
 /**
  * Handles Exceptions
  *
  * @param   integer|object  exception object or error code
  * @param   string          error message
  * @param   string          filename
  * @param   integer         line number
  * @return  void
  */
 public static function exception_handler($exception, $message = NULL, $file = NULL, $line = NULL)
 {
     try {
         # PHP errors have 5 args, always
         $PHP_ERROR = func_num_args() === 5;
         # Test to see if errors should be displayed
         if ($PHP_ERROR and error_reporting() === 0) {
             die;
         }
         # Error handling will use exactly 5 args, every time
         if ($PHP_ERROR) {
             $code = $exception;
             $type = 'PHP Error';
         } else {
             $code = $exception->getCode();
             $type = get_class($exception);
             $message = $exception->getMessage();
             $file = $exception->getFile();
             $line = $exception->getLine();
         }
         if (is_numeric($code)) {
             //$codes = self::lang('errors');
             if (!empty($codes[$code])) {
                 list($level, $error, $description) = $codes[$code];
             } else {
                 $level = 1;
                 $error = $PHP_ERROR ? 'Unknown Error' : get_class($exception);
                 $description = '';
             }
         } else {
             // Custom error message, this will never be logged
             $level = 5;
             $error = $code;
             $description = '';
         }
         // Remove the self::config('core.path.docroot') from the path, as a security precaution
         $file = str_replace('\\', '/', realpath($file));
         $file = preg_replace('|^' . preg_quote(self::config('core.path.docroot')) . '|', '', $file);
         if ($PHP_ERROR) {
             $description = 'An error has occurred which has stopped Scaffold';
             if (!headers_sent()) {
                 # Send the 500 header
                 header('HTTP/1.1 500 Internal Server Error');
             }
         } else {
             if (method_exists($exception, 'sendHeaders') and !headers_sent()) {
                 # Send the headers if they have not already been sent
                 $exception->sendHeaders();
             }
         }
         if ($line != FALSE) {
             // Remove the first entry of debug_backtrace(), it is the exception_handler call
             $trace = $PHP_ERROR ? array_slice(debug_backtrace(), 1) : $exception->getTrace();
             // Beautify backtrace
             $trace = self::backtrace($trace);
         }
         # Log to FirePHP
         FB::error($message);
         require SYSPATH . 'views/Scaffold_Exception.php';
         # Turn off error reporting
         error_reporting(0);
         exit;
     } catch (Exception $e) {
         die('Fatal Error: ' . $e->getMessage() . ' File: ' . $e->getFile() . ' Line: ' . $e->getLine());
     }
 }
예제 #19
0
 public function verify_user()
 {
     // Store and clean the POST data
     $this->_store_post_data();
     // Make sure the username is valid
     if (!SIV::validate($_POST['username'], SIV::USERNAME)) {
         // Set error message
         $this->_sdata->error = '0001';
     } else {
         if (!SIV::validate($_POST['display'], SIV::STRING)) {
             // Set error message
             $this->_sdata->error = '0002';
         } else {
             if (strlen($_POST['password']) < 8) {
                 // Set error message
                 $this->_sdata->error = '0003';
             } else {
                 if ($_POST['password'] !== $_POST['verify-password']) {
                     // Set error message
                     $this->_sdata->error = '0004';
                 } else {
                     // Reset the error code
                     $this->_sdata->error = '0000';
                     // Grab cleaned data out of the temporary session data
                     $username = $this->_sdata->temp->username;
                     $display = $this->_sdata->temp->display;
                     $vcode = $this->_sdata->temp->vcode;
                     // Create a salted hash of the password
                     $password = AdminUtilities::createSaltedHash($_POST['password']);
                 }
             }
         }
     }
     // Check for errors
     if ($this->_sdata->error !== '0000') {
         // Bounce back to the verification form
         header('Location: /admin/verify/' . $vcode);
         exit;
     }
     // Define the update query
     $sql = "UPDATE `" . DB_NAME . "`.`" . DB_PREFIX . "users`\n                SET\n                    `username`=:username,\n                    `display`=:display,\n                    `password`=:password,\n                    `active`=1\n                WHERE `vcode`=:vcode\n                AND `active`=0\n                LIMIT 1";
     try {
         $stmt = $this->db->prepare($sql);
         $stmt->bindParam(':username', $username, PDO::PARAM_STR);
         $stmt->bindParam(':display', $display, PDO::PARAM_STR);
         $stmt->bindParam(':password', $password, PDO::PARAM_STR);
         $stmt->bindParam(':vcode', $vcode, PDO::PARAM_STR);
         $stmt->execute();
         if ($stmt->errorCode() !== '00000') {
             FB::error($e);
             $err = $stmt->errorInfo();
             ECMS_Error::log_exception(new Exception($err[2]));
         }
         $stmt->closeCursor();
         $this->_sdata = NULL;
         return TRUE;
     } catch (Exception $e) {
         ECMS_Error::log_exception($e);
     }
 }
예제 #20
0
파일: kunena.php 프로젝트: kaantunc/MYK-BOR
        // Credits
        echo '<div class="fb_credits"> ' . CKunenaLink::GetTeamCreditsLink($catid, _KUNENA_POWEREDBY) . ' ' . CKunenaLink::GetCreditsLink();
        if ($fbConfig->enablerss) {
            $document->addCustomTag('<link rel="alternate" type="application/rss+xml" title="' . _LISTCAT_RSS . '" href="' . JRoute::_(KUNENA_LIVEURLREL . '&amp;func=fb_rss&amp;no_html=1') . '" />');
            echo CKunenaLink::GetRSSLink('<img class="rsslink" src="' . KUNENA_URLEMOTIONSPATH . 'rss.gif" border="0" alt="' . _LISTCAT_RSS . '" title="' . _LISTCAT_RSS . '" />');
        }
        echo '</div>';
        // display footer
        $KunenaTemplate->displayParsedTemplate('kunena-footer');
    }
}
//else
if (is_object($kunenaProfile)) {
    $kunenaProfile->close();
}
if (JDEBUG == 1) {
    $__profiler->mark('Done');
    $__queries = $__profiler->getQueryCount();
    if (defined('JFIREPHP')) {
        FB::log($__profiler->getBuffer(), 'Kunena Profiler');
        if ($__queries > 50) {
            FB::error($__queries, 'Kunena Queries');
        } else {
            if ($__queries > 35) {
                FB::warn($__queries, 'Kunena Queries');
            } else {
                FB::log($__queries, 'Kunena Queries');
            }
        }
    }
}
예제 #21
0
파일: Panda.php 프로젝트: sssAlchemy/Panda
 /**
  * Fatal Error Handler
  *
  * @param string $buffer PHP output buffer
  *
  * @return string
  * @ignore
  *
  * <code>
  * ob_start(array('Panda_Errpr', 'fatalErrorHandler'); // set handler
  * </code>
  */
 public static function onFatalError($buffer)
 {
     $error = error_get_last();
     // return "FATAL" . $buffer . "FATAL" . var_export($error, true);
     if ($error['type'] !== 1) {
         return $buffer;
     }
     // Web
     header("HTTP/1.x 503 Service Temporarily Unavailable.");
     $id = substr(md5(serialize($error)), 0, 6);
     // FB
     if (self::$_config[self::CONFIG_DEBUG] === true && self::$_config[self::CONFIG_ENABLE_FIREPHP]) {
         FB::error("Fatal Error - {$error['message']} - ref# {$id}");
     }
     // write fatal error in file
     if (self::$_config[self::CONFIG_LOG_PATH]) {
         $path = self::$_config[self::CONFIG_LOG_PATH];
         $msg = "{$error['message']} in {$error['line']} on {$error['line']}";
         error_log("[PHP Fatal][{$id}]:{$msg}");
         if (!is_writable($path)) {
             trigger_error('File write error' . $path, E_USER_ERROR);
         }
         $file = $path . 'fatal-' . $id . '.log';
         if (!file_exists($file)) {
             file_put_contents($file, $buffer);
         } else {
         }
     }
     // show Fatal error page
     $fatalHtml = (include self::$_config[self::CONFIG_FATAL_HTML]);
     if (is_string($fatalHtml)) {
         return $fatalHtml;
     }
     return $buffer;
 }
예제 #22
0
 /**
  * Intefacet to FirePHP error, just to make things easier
  *
  * @param       $data
  * @param		$label
  */
 public static function error($data, $label)
 {
     FB::error($data, $label);
 }
예제 #23
0
define('FIREPHP_INFO', false);
define('FIREPHP_WARN', false);
define('FIREPHP_ERROR', false);
define('FIREPHP_TRACE', true);
require_once '../../Grace/FirePHPCore/fb.php';
FB::log('Hello World !');
// 常规记录
\FB::group('Test Group A', ['Collapsed' => true]);
// 记录分组
// 以下为按照不同类别或者类型进行信息记录
FB::log('Plain Message');
FB::info('Info Message');
FB::warn('Warn Message');
FB::error('Error Message');
FB::log('Message', 'Optional Label');
FB::info([1, 2, 3, 5, 56], "All Turtles");
FB::groupEnd();
FB::group('Test Group B');
FB::log('Hello World B');
FB::log('Plain Message');
FB::info('Info Message');
FB::warn('Warn Message');
FB::error('Error Message');
FB::log('Message', 'Optional Label');
FB::groupEnd();
$table[] = array('Col 1 Heading', 'Col 2 Heading', 'Col 2 Heading');
$table[] = array('Row 1 Col 1', 'Row 1 Col 2', 'Row 1 Col 2');
$table[] = array('Row 2 Col 1', 'Row 2 Col 2');
$table[] = array('Row 3 Col 1', 'Row 3 Col 2');
FB::table('Table Label', $table);
FB::trace('123', [1, 23, 4]);
예제 #24
0
파일: index.php 프로젝트: sudhir9026/demo
<?php

header("Content-type: text/html; charset=utf-8");
require_once 'fb.php';
FB::log('Log message');
FB::info('info message');
FB::warn('warn message');
FB::error('error message');
$var = array('abc');
fb($var, FirePHP::TRACE);
//End_php
예제 #25
0
 static function displayPosts($num = 8, $page = 'blog', $filter = "recent", $id = "latest-blogs")
 {
     // Determine which posts to retreive
     if ($filter == "recent") {
         $filter_sql = "WHERE page='{$page}'";
     } elseif ($filter == "featured") {
         $filter_sql = "WHERE page='{$page}' AND data5='1'";
     }
     //TODO: Convert to PDO
     $db = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
     $sql = "SELECT title,data6\n                FROM `" . DB_NAME . "`.`" . DB_PREFIX . "entryMgr`\n                {$filter_sql}\n                ORDER BY created DESC\n                LIMIT {$num}";
     try {
         $stmt = $db->prepare($sql);
         $list = NULL;
         $stmt->execute();
         $stmt->bind_result($title, $data6);
         while ($stmt->fetch()) {
             $url = isset($data6) ? $data6 : urlencode($title);
             $link = SITE_URL . $page . "/" . $url;
             $title = stripslashes($title);
             $list .= "\n                        <li><a href=\"{$link}\">{$title}</a></li>";
         }
         $stmt->close();
     } catch (Exception $e) {
         FB::error($e);
         throw new Exception("Could not load entries.");
     }
     return "\n                    <ul id=\"{$id}\">{$list}\n                    </ul>";
 }
예제 #26
0
 public function OnError($msg,$label=null)
 {
     \FB::error($msg, $label);
 }
예제 #27
0
 public static function display_posts($num = 8, $page = 'blog', $filter = "recent", $id = "latest-blogs")
 {
     // Load the page ID
     $page = Menu::get_page_data_by_slug($page);
     // Determine which posts to retreive
     if ($filter == "recent") {
         $sql = "SELECT `title`, `slug`\n                    FROM `" . DB_NAME . "`.`" . DB_PREFIX . "entries`\n                    WHERE `page_id`='{$page->page_id}'\n                    ORDER BY `created` DESC\n                    LIMIT 0, {$num}";
     } elseif ($filter == "featured") {
         $sql = "SELECT `entry_id`, `title`, `slug`\n                    FROM `" . DB_NAME . "`.`" . DB_PREFIX . "featured`\n                    LEFT JOIN `" . DB_NAME . "`.`" . DB_PREFIX . "entries`\n                    USING( `entry_id` )\n                    LIMIT 0, {$num}";
     }
     //TODO: Convert to PDO
     $dbo = new DB_Connect();
     try {
         $stmt = $dbo->db->prepare($sql);
         $stmt->execute();
         $list = NULL;
         $lb = "\n" . str_repeat(' ', 24);
         while ($entry = $stmt->fetch(PDO::FETCH_OBJ)) {
             $url = isset($entry->slug) ? $entry->slug : urlencode($entry->title);
             $link = SITE_URL . $page->page_slug . "/" . $url;
             $title = stripslashes($entry->title);
             $list .= "{$lb}<li><a href=\"{$link}\">{$title}</a></li>";
         }
         $stmt->closeCursor();
     } catch (Exception $e) {
         FB::error($e);
         throw new Exception("Could not load entries.");
     }
     $lb = "\n" . str_repeat(' ', 20);
     return "{$lb}<ul id=\"{$id}\">{$list}{$lb}</ul><!-- end #{$id} -->";
 }
예제 #28
0
 public function attestato()
 {
     //JRequest::setVar('view', 'attestato');
     $japp =& JFactory::getApplication();
     $model =& $this->getModel('attestato');
     FB::error("ATTENZIONE!!!! indici statici sull'attestato");
     $model->certificate(678, 155);
     $japp->close();
     parent::display();
 }
예제 #29
0
파일: Debug.php 프로젝트: sssAlchemy/Panda
 /**
  * Debug output
  *
  * <code>
  * Panda_Debug::p
  * 出力モードを指定して変数を出力します
  * </code>
  *
  * @param mixed  $values    any values
  * @param string $ouputMode 'var' | 'export' | 'syslog' | 'fire' dafult is 'print_a'
  * @param array  $options   options
  *
  * @return void
  */
 public static function p($values = '', $ouputMode = null, array $options = array())
 {
     if (!self::$enable) {
         return;
     }
     if (isset($options['return']) && $options['return'] === true) {
         ob_start();
     }
     // Roならarrayに
     if (class_exists('BEAR_Ro', false) && $values instanceof BEAR_Ro) {
         $values = array('code' => $values->getCode(), 'headers' => $values->header, 'body' => $values->body, 'links' => $values->links);
     }
     if ($ouputMode === null && is_scalar($values)) {
         $ouputMode = 'dump';
     }
     $trace = isset($options['trace']) ? $options['trace'] : debug_backtrace();
     $file = $trace[0]['file'];
     $line = $trace[0]['line'];
     $includePath = explode(":", get_include_path());
     $method = isset($trace[1]['class']) ? " ({$trace[1]['class']}" . '::' . "{$trace[1]['function']})" : '';
     $fileArray = file($file, FILE_USE_INCLUDE_PATH);
     $p = trim($fileArray[$line - 1]);
     unset($fileArray);
     preg_match("/p\\((.+)[\\s,\\)]/is", $p, $matches);
     $varName = isset($matches[1]) ? $matches[1] : '';
     $label = isset($options['label']) ? $options['label'] : "{$varName} in {$file} on line {$line}{$method}";
     if (strlen(serialize($values)) > 1000000) {
         $ouputMode = 'dump';
     }
     $label = is_object($values) ? ucwords(get_class($values)) . " {$label}" : $label;
     // if CLI
     if (PHP_SAPI === 'cli') {
         $colorOpenReverse = "";
         $colorOpenBold = "";
         $colorOpenPlain = "";
         $colorClose = "";
         echo $colorOpenReverse . "{$varName}" . $colorClose . " = ";
         var_dump($values);
         echo $colorOpenPlain . "in {$colorOpenBold}{$file}{$colorClose}{$colorOpenPlain} on line {$line}{$method}" . $colorClose . "\n";
         return;
     }
     if (Panda::isCliOutput()) {
         if (class_exists('FB', false)) {
             $ouputMode = 'fire';
         } else {
             $ouputMode = 'syslog';
         }
     }
     $labelField = '<fieldset style="color:#4F5155; border:1px solid black;padding:2px;width:10px;">';
     $labelField .= '<legend style="color:black;font-size:9pt;font-weight:bold;font-family:Verdana,';
     $labelField .= 'Arial,,SunSans-Regular,sans-serif;">' . $label . '</legend>';
     switch ($ouputMode) {
         case 'v':
         case 'var':
             if (class_exists('Var_Dump', false)) {
                 Var_Dump::displayInit(array('display_mode' => 'HTML4_Text'));
                 print $labelField;
                 Var_Dump::display($values);
             } else {
                 ob_start();
                 var_export($values);
                 $var = ob_get_clean();
                 print $labelField;
                 echo "<pre>" . $var . '</pre>';
             }
             print "</fieldset>";
             break;
         case 'd':
         case 'dump':
             $file = "<a style=\"color:gray; text-decoration:none;\" target=\"_blank\" href=/__panda/edit/?file={$file}&line={$line}>{$file}</a>";
             $dumpLabel = isset($options['label']) ? $options['label'] : "in <span style=\"color:gray\">{$file}</span> on line {$line}{$method}";
             echo self::dump($values, null, array('label' => $dumpLabel, 'var_name' => $varName));
             break;
         case 'e':
         case 'export':
             echo "{$labelField}<pre>" . var_export($values, true);
             echo '</fieldset></pre>';
             break;
         case 'h':
         case 'header':
             header("x-panda-{$label}", print_r($values, true));
             break;
         case 's':
         case 'syslog':
             syslog(LOG_DEBUG, "label:{$label}" . print_r($values, true));
             break;
         case 'f':
         case 'fire':
             if (class_exists('FB', false)) {
                 $label = isset($options['label']) ? $options['label'] : 'p() in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'];
                 FB::group($label);
                 FB::error($values);
                 FB::groupEnd();
             }
             break;
         case null:
         case 'printa':
         case 'print_a':
         default:
             $options = "max_y:100;pickle:1;label:{$label}";
             print_a($values, $options);
     }
     if (isset($options['return']) && $options['return'] === true) {
         return ob_get_clean();
     }
 }
예제 #30
0
 /**
     * Ritorna le informazioni per l'unita richiesto. 
     * L'id dell'unita viene letto da URL e deve essere un intero valido.
     * 
     * @return array
     */
 public function getUnita($where = null, $limit = null) {
 	try {

 		if (!empty($this->_content)) {
 			return $this->_content;
 		}

 		

 		$query = 'SELECT *
        FROM #__gg_unit as u ';

        if(!$where)
            $query .=  'WHERE id = '. $this->_id ;
        else
            $query .= $where;

        FB::log($query, "getUnita -- Principale");

        $this->_db->setQuery($query);
        if (false === ($unita = $this->_db->loadAssoc()))   
        	throw new RuntimeException($this->_db->getErrorMsg(), E_USER_ERROR);
        if (empty($unita))
        	throw new DomainException('Nessun contenuto trovato', E_USER_NOTICE);

//         $unita['unitaFiglio'] = array();
// >        $query = 'SELECT *  FROM #__gg_unit WHERE categoriapadre = '.$this->_id .' order by ordinamento ';

//         FB::log($query, "getUnita - unitaFiglio");
//         $this->_db->setQuery($query);
//         if (false === ($results = $this->_db->loadAssocList()))
//         	throw new RuntimeException($this->_db->getErrorMsg(), E_USER_ERROR);
//         $unita['unitaFiglio'] = $results;

//         $unita['unitaPadre'] = array();
//         $query = 'SELECT * FROM #__gg_unit WHERE id = '.$unita['categoriapadre'] .' order by ordinamento ';

        // echo $query;

        // FB::log($query, "getUnita - unitaPadre");
        // $this->_db->setQuery($query);
        // if (false === ($results = $this->_db->loadAssocList()))
        // 	throw new RuntimeException($this->_db->getErrorMsg(), E_USER_ERROR);
        // $unita['unitaPadre'] = $results;


        // if($unita['tipologia']==2){

        	// $unita['contenutiUnita'] = array();

        	// $unita['contenutiUnita'] = $this->getContenuti($this->_id);
        // }

        // foreach ($unita['unitaFiglio'] as &$item) {

        //     // FB::log($item, "item - unita figlio");

        //     $item['contenutiUnita'] = array();

        //     $item['contenutiUnita'] = $this->getContenuti($item['id']);
        // }




        FB::info($unita, "Unita");
    } catch (Exception $e) {
    	FB::error($e);
    }
    return $unita;
}