Esempio n. 1
1
 public function checkContentDuration($id)
 {
     $path = "/var/www/html/ediacademy/mediagg/contenuti/{$id}/{$id}.mp4";
     $getID3 = new getID3();
     $file = $getID3->analyze($path);
     FB::log($file);
     return (int) $file['playtime_seconds'];
 }
Esempio n. 2
0
function build(&$query) {
    $segments = array();

    if (isset($query['view'])) {
        $segments[] = $query['view'];
        unset($query['view']);
    }

    if (isset($query['id'])) {
        $segments[] = $query['id'];
        unset($query['id']);
    }

    if (isset($query['type'])) {
        $segments[] = $query['type'];
        unset($query['type']);
    }

    if (isset($query['alias'])) {
        $segments[] = $query['alias'];
        unset($query['alias']);
    }

    if (isset($query['unit'])) {
     //   $segments[] = $query['alias'];
        unset($query['unit']);
    }

    FB::log($segments, "segments" );
    return $segments;
}
Esempio n. 3
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;
}
Esempio n. 4
0
 function display($tpl = null)
 {
     $this->items = $this->get('Items');
     $this->pagination = $this->get('Pagination');
     $this->state = $this->get('State');
     FB::log($this->items);
     $document =& JFactory::getDocument();
     JHtml::_('bootstrap.framework');
     //RS
     JHtml::_('jquery.framework');
     //RS
     JHtml::_('jquery.ui', array('core', 'sortable'));
     //RS
     $document->addStyleSheet('http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css');
     //      Following variables used more than once
     //      $this->sortColumn = $this->state->get('list.ordering');
     //      $this->sortDirection = $this->state->get('list.direction');
     //        $this->searchterms = $this->state->get('filter.search');
     // Set the toolbar
     $this->addToolBar();
     // Set the document
     $this->setDocument();
     // Display the template
     parent::display($tpl);
 }
Esempio n. 5
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!');
    }
}
Esempio n. 6
0
 /**
  * The second last process, should only be getting everything
  * syntaxically correct, rather than doing any heavy processing
  *
  * @author Anthony Short
  * @return $css string
  */
 public static function post_process()
 {
     if ($found = CSS::find_properties_with_value('image-replace', 'url\\([\'\\"]?([^)]+)[\'\\"]?\\)')) {
         foreach ($found[4] as $key => $value) {
             $path = $url = str_replace("\\", "/", unquote($value));
             # If they're getting an absolute file
             if ($path[0] == "/") {
                 $path = DOCROOT . ltrim($path, "/");
             }
             # Check if it exists
             if (!file_exists($path)) {
                 FB::log("ImageReplace - Image doesn't exist " . $path);
             }
             # Make sure it's an image
             if (!is_image($path)) {
                 FB::log("ImageReplace - File is not an image: {$path}");
             }
             // Get the size of the image file
             $size = GetImageSize($path);
             $width = $size[0];
             $height = $size[1];
             // Make sure theres a value so it doesn't break the css
             if (!$width && !$height) {
                 $width = $height = 0;
             }
             // Build the selector
             $properties = "\n\t\t\t\t\tbackground:url({$url}) no-repeat 0 0;\n\t\t\t\t\theight:{$height}px;\n\t\t\t\t\twidth:{$width}px;\n\t\t\t\t\tdisplay:block;\n\t\t\t\t\ttext-indent:-9999px;\n\t\t\t\t\toverflow:hidden;\n\t\t\t\t";
             CSS::replace($found[2][$key], $properties);
         }
         # Remove any left overs
         CSS::replace($found[1], '');
     }
 }
Esempio n. 7
0
 public function generateJsonResponse($action, $do, $data)
 {
     $response = '';
     if (JDEBUG == 1 && defined('JFIREPHP')) {
         FB::log("Kunena JSON action: " . $action);
     }
     // Sanitize $data variable
     $data = $this->_db->getEscaped($data);
     if ($this->_my->id) {
         // We only entertain json requests for registered and logged in users
         switch ($action) {
             case 'autocomplete':
                 $response = $this->_getAutoComplete($do, $data);
                 break;
             case 'preview':
                 $body = JRequest::getVar('body', '', 'post', 'string', JREQUEST_ALLOWRAW);
                 $response = $this->_getPreview($body);
                 break;
             case 'pollcatsallowed':
                 // TODO: deprecated
                 $response = $this->_getPollsCatsAllowed();
                 break;
             case 'pollvote':
                 $vote = JRequest::getInt('kpollradio', '');
                 $id = JRequest::getInt('kpoll-id', 0);
                 if (!JRequest::checkToken()) {
                     return false;
                 }
                 $response = $this->_addPollVote($vote, $id, $this->_my->id);
                 break;
             case 'pollchangevote':
                 $vote = JRequest::getInt('kpollradio', '');
                 $id = JRequest::getInt('kpoll-id', 0);
                 if (!JRequest::checkToken()) {
                     return false;
                 }
                 $response = $this->_changePollVote($vote, $id, $this->_my->id);
                 break;
             case 'anynomousallowed':
                 // TODO: deprecated
                 $response = $this->_anynomousAllowed();
                 break;
             case 'uploadfile':
                 $response = $this->_uploadFile($do);
                 break;
             case 'modtopiclist':
                 $response = $this->_modTopicList($data);
                 break;
             case 'removeattachment':
                 $response = $this->_removeAttachment($data);
                 break;
             default:
                 break;
         }
     } else {
         $response = array('status' => '-1', 'error' => JText::_('COM_KUNENA_AJAX_PERMISSION_DENIED'));
     }
     // Output the JSON data.
     return json_encode($response);
 }
 public function handle()
 {
     $page = htmlspecialchars(@$_GET['page']);
     FB::log($page);
     $page = $this->getPageIfEmpty($page);
     $view = $this->pageData($page);
     $this->render($view);
 }
Esempio n. 9
0
 /**
  * Loads an XML file and loads it's variables into the object.
  * Returns true if successful
  * @access public
  * @param $file
  * @return boolean
  */
 public function load($file)
 {
     if (!is_file($file)) {
         return false;
     }
     $this->variables = $this->to_array(simplexml_load_file($file));
     FB::log($this->variables, '$this->variables');
     return true;
 }
Esempio n. 10
0
 public function connect()
 {
     $conf = Kohana::config('gmail');
     FB::log($conf, "conf");
     //{server.example.com:143/novalidate-cert}INBOX
     $this->inbox = imap_open($conf['connection']['hostname'], $conf['connection']['username'], $conf['connection']['password']) or die('Cannot connect to Gmail: ' . imap_last_error());
     FB::log($this->inbox);
     return $this;
 }
Esempio n. 11
0
 protected function loadFormData()
 {
     // Check the session for previously entered form data.
     $data = JFactory::getApplication()->getUserState('com_gglms.edit.file.data', array());
     if (empty($data)) {
         $data = $this->getItem();
     }
     FB::log($data, " loadFormData file");
     return $data;
 }
 /**
  * Combina i dati e il template generando la parte una o più pagine PDF.
  * Nel template deve essere usata la variabile {$data} che contine tutti
  * i valori passati.
  * 
  * @param string $template 
  * @param string $cache_id identificatore univoco per la copia di cache e di compilazione (default NULL).
  * @param bool $check se TRUE Easy Smarty guarda se il file template è cambiato e lo ricompila (default TRUE). Una volta che l'applicazione viene messa in produzione (quindi i template non cambieranno più), il passo di check non è più necessario è consigliabile, per massimizzare  le prestazioni, mettere questo parametro a FALSE.
  * @param bool $cache se TRUE l'output è memorizzato nelle cache (default TRUE).
  * @param int $lifetime tempo di validità (in secondi) della copia in cache; per default è 120 (2 minuti). $cache deve essere impostato a TRUE perché $lifetime abbia significato. Un valore di -1 significa cache senza scadenza. Il valore 0 farà sì che la cache venga sempre rigenerata (è utile solo in fase di test, per disabilitare il caching un metodo più efficiente è impostare $cache a FALSE).
  */
 public function fetch_pdf_template($template, $cache_id = null, $check = true, $cache = false, $lifetime = 120)
 {
     $this->AddPage();
     $smarty = new EasySmarty();
     $smarty->assign('data', $this->_data);
     FB::log($this->_data);
     $html = $smarty->fetch_template($template, $cache_id, $check, $cache, $lifetime);
     FB::log($html);
     $this->writeHTML($html, true, true, true, false, '');
     $this->lastPage();
 }
Esempio n. 13
0
 /**
  * Generates HTML to display a given array of entries
  *
  * @param array $entries an array of entries to be formatted
  * @return string HTML markup to display the entry
  */
 protected function generate_template_tags()
 {
     FB::log(debug_backtrace());
     parent::generate_template_tags();
     // Add custom tags here
     foreach ($this->entries as $entry) {
         $entry->comment_count = $this->get_comment_count($entry->entry_id);
         $entry->comment_text = $entry->comment_count === 1 ? 'comment' : 'comments';
         $entry->tags = $this->_format_tags($entry->tags);
     }
 }
Esempio n. 14
0
 public static function logInfo($m)
 {
     $s = self::toStr($m);
     error_log("KLOUDSPEAKER INFO: " . $s);
     if (self::$firebug) {
         FB::log($m);
     }
     if (self::isDebug()) {
         self::$trace[] = $s;
     }
 }
Esempio n. 15
0
 public function login($username, $password)
 {
     FB::log($username);
     if (USE_LDAP) {
         try {
             $this->ldap->autentificate($username, $password);
         } catch (LdapException $e) {
             throw new LoginException($e);
         }
     }
 }
Esempio n. 16
0
function sql($query)
{
    if (DEBUG_PLAIN) {
        return FB::log($query);
    }
    if (SCRIPT_IN) {
        return DataEngine::sql($query);
    }
    $sql = str_replace('SQL_PREFIX_', SQL_PREFIX_, $query);
    $result = mysql_query($sql) or sqlerror($query);
}
Esempio n. 17
0
 function __destruct()
 {
     if (!$this->status) {
         if (JDEBUG == 1 && defined('JFIREPHP')) {
             FB::log('Kunena upload failed: ' . $this->error);
         }
     }
     // Delete any left over files in temp
     if (is_file($this->fileTemp)) {
         unlink($this->fileTemp);
     }
 }
Esempio n. 18
0
 public function offsetGet($offset)
 {
     global $phpAnvil;
     $return = false;
     if (!$this->exists($offset)) {
         $msg = 'Database, ' . $offset . ', not found.';
         $this->_addTraceInfo(__FILE__, __METHOD__, __LINE__, $msg, self::TRACE_TYPE_DEBUG);
         FB::log($msg);
     } else {
         $return = parent::offsetGet($offset);
     }
     return $return;
 }
function kunena_upgrade_160_attachments($parent)
{
    // First check if attachments table has legacy field
    $fields = array_pop($parent->db->getTableFields('#__kunena_attachments'));
    if (!isset($fields['filelocation'])) {
        // Already converted, there is nothing to do
        return;
    }
    //Import filesystem libraries.
    jimport('joomla.filesystem.folder');
    $query = "DROP TABLE IF EXISTS `#__kunena_attachments_bak`";
    $parent->db->setQuery($query);
    $parent->db->query();
    if ($parent->db->getErrorNum()) {
        throw new KunenaInstallerException($parent->db->getErrorMsg(), $parent->db->getErrorNum());
    }
    // Attachments table has filelocation - assume we have to convert attachments
    // hash and size ommited -> NULL
    $query = "RENAME TABLE `#__kunena_attachments` TO `#__kunena_attachments_bak`";
    $parent->db->setQuery($query);
    $parent->db->query();
    if ($parent->db->getErrorNum()) {
        throw new KunenaInstallerException($parent->db->getErrorMsg(), $parent->db->getErrorNum());
    }
    $collation = $parent->db->getCollation();
    if (!strstr($collation, 'utf8')) {
        $collation = 'utf8_general_ci';
    }
    $query = "CREATE TABLE IF NOT EXISTS `#__kunena_attachments` (\n\t\t\t\t`id` int(11) NOT NULL auto_increment,\n\t\t\t\t`mesid` int(11) NOT NULL default '0',\n\t\t\t\t`userid` int(11) NOT NULL default '0',\n\t\t\t\t`hash` char(32) NULL,\n\t\t\t\t`size` int(11) NULL,\n\t\t\t\t`folder` varchar(255) NOT NULL,\n\t\t\t\t`filetype` varchar(20) NOT NULL,\n\t\t\t\t`filename` varchar(255) NOT NULL,\n\t\t\t\t\tPRIMARY KEY (`id`),\n\t\t\t\t\tKEY `mesid` (`mesid`),\n\t\t\t\t\tKEY `userid` (`userid`),\n\t\t\t\t\tKEY `hash` (`hash`),\n\t\t\t\t\tKEY `filename` (`filename`) ) DEFAULT CHARACTER SET utf8 COLLATE {$collation};";
    $parent->db->setQuery($query);
    $parent->db->query();
    if ($parent->db->getErrorNum()) {
        throw new KunenaInstallerException($parent->db->getErrorMsg(), $parent->db->getErrorNum());
    }
    $query = "INSERT INTO #__kunena_attachments (mesid, userid, folder, filetype, filename)\n\t\t\t\tSELECT a.mesid, m.userid,\n\t\t\t\t\tSUBSTRING_INDEX(SUBSTRING_INDEX(a.filelocation, '/', -4), '/', 3) AS folder,\n\t\t\t\t\tSUBSTRING_INDEX(a.filelocation, '.', -1) AS filetype,\n\t\t\t\t\tSUBSTRING_INDEX(a.filelocation, '/', -1) AS filename\n\t\t\t\tFROM #__kunena_attachments_bak AS a\n\t\t\t\tJOIN #__kunena_messages AS m ON a.mesid = m.id";
    $parent->db->setQuery($query);
    $parent->db->query();
    if ($parent->db->getErrorNum()) {
        throw new KunenaInstallerException($parent->db->getErrorMsg(), $parent->db->getErrorNum());
    }
    if (JDEBUG == 1 && defined('JFIREPHP')) {
        FB::log($query, 'Attachment Upgrade');
    }
    // By now the old attachmets table has been converted to the new Kunena 1.6 format
    // with the exception of file size and file hash that cannot be calculated inside
    // the database. Both of these columns are set to null. As we could be dealing with
    // thousands of medium to large size images, we cannot afford to iterate over all
    // of them to calculate this values. A seperate maintenance task will have to be
    // created and executed outside of the upgrade itself.
    return array('action' => '', 'name' => JText::_('COM_KUNENA_INSTALL_160_ATTACHMENTS'), 'success' => true);
}
Esempio n. 20
0
 /**
  * A method to instantiate the database object if one doesn't exist
  * 
  * @return void
  */
 protected function __construct()
 {
     //TODO: Look into a Singleton pattern for this
     if (!isset($this->db)) {
         $dsn = "mysql:host=" . DB_HOST . ";dbname=" . DB_NAME;
         try {
             // Creates a new
             $this->db = new PDO($dsn, DB_USER, DB_PASS);
             return;
         } catch (Exception $e) {
             // Logs the full error stack and die with the message
             FB::log($e);
             die("Database Error: " . $e->getMessage());
         }
     }
 }
Esempio n. 21
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;
}
Esempio n. 22
0
 public function getUserKeywords()
 {
     //#FB::info(Site::$user, 'User');
     if (Site::$user) {
         $sql = "SELECT `keywords`.`keyword`, `keywords`.`id`, `keytypes`.`type`,`keytypes`.`code`,`key_relations`.`task`\n\t\t\t\t\tFROM `keywords` \n\t\t\t\t\tINNER JOIN `key_relations`\n \t\t\t\t\tON `key_relations`.`keyword` = `keywords`.`id`\n\t\t\t\t\tINNER JOIN `keytypes`\n\t\t\t\t\tON `keywords`.`type` = `keytypes`.`id`\n\t\t\t\t\tWHERE `key_relations`.`user` = " . Site::$user . "\n\t\t\t\t\tORDER BY `keywords`.`id`;";
         $result = Site::$db->query($sql);
         $name = array();
         while ($obj = $result->fetch_assoc()) {
             if (!in_array($obj['keyword'] . '-' . $obj['type'], $name)) {
                 $name[] = $obj['keyword'] . '-' . $obj['type'];
                 self::$keys[$obj['type']][] = $obj;
             }
         }
         FB::info(self::$keys, 'User Keywords');
         FB::log(debug_backtrace(), 'User Keywords');
     }
 }
Esempio n. 23
0
 protected function generate_contact_form()
 {
     FB::log("Wrong class.");
     try {
         // Create a new form object and set submission properties
         $form = new Form();
         $form->page = $this->url0;
         $form->action = 'contact-form';
         $form->form_id = 'contact-form';
         $form->legend = 'Contact ' . SITE_NAME;
         // Set up input information
         $form->input_arr = array(array('name' => 'cf_n', 'class' => 'input-text', 'label' => 'Name'), array('name' => 'cf_e', 'class' => 'input-text', 'label' => 'Email'), array('name' => 'cf_p', 'class' => 'input-text', 'label' => 'Phone'), array('type' => 'textarea', 'name' => 'cf_m', 'class' => 'input-textarea', 'label' => 'Message'), array('type' => 'submit', 'class' => 'input-submit', 'name' => 'cf_s', 'value' => 'Send Message'));
         return $form;
     } catch (Exception $e) {
         Error::logException($e);
     }
 }
Esempio n. 24
0
 /**
  * onAfterInitialise handler
  *
  * Register FirePHP libraries and set options according to paramters
  *
  * @access	public
  * @return null
  */
 public function onAfterInitialise()
 {
     require_once 'jfirephp' . DS . 'firephpcore' . DS . 'fb.php';
     // JFirePHP is installed and loaed
     define('JFIREPHP', 1);
     // Before doing any checks lets disable logging
     FB::setEnabled(false);
     // Check if the integration is set to enabled
     $enable = (bool) $this->params->get('enable', 0);
     // Only turn on if enabled
     if ($enable) {
         // if limited to debug mode, check JDEBUG
         $limittodebug = (bool) $this->params->get('limittodebug', 1);
         if ($limittodebug == false || JDEBUG) {
             // We are enabled and either in Debug mode, or it does not matter
             FB::setEnabled(true);
             $verbose = (bool) $this->params->get('verbose', 0);
             if ($verbose) {
                 FB::group('JFirePHP Startup', array('Collapsed' => true, 'Color' => '#FF4000'));
                 FB::log('JFirePHP enabled! - Verbose Output Mode: ON');
             }
             $options = array('maxObjectDepth' => intval($this->params->get('maxObjectDepth', 10)), 'maxArrayDepth' => intval($this->params->get('maxArrayDepth', 20)), 'useNativeJsonEncode' => intval($this->params->get('useNativeJsonEncode', 1)), 'includeLineNumbers' => intval($this->params->get('includeLineNumbers', 1)));
             FB::setOptions($options);
             if ($verbose) {
                 FB::log('JFirePHP: Options Set - maxObjectDepth:' . $options['maxObjectDepth'] . ' maxArrayDepth:' . $options['maxArrayDepth'] . ' useNativeJsonEncode:' . $options['useNativeJsonEncode'] . ' includeLineNumbers:' . $options['includeLineNumbers']);
             }
             $redirectphp = (bool) $this->params->get('redirectphp', 0);
             if ($redirectphp) {
                 // Convert E_WARNING, E_NOTICE, E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE and
                 // E_RECOVERABLE_ERROR errors to ErrorExceptions and send all Exceptions to Firebug automatically
                 FB::registerErrorHandler(true);
                 FB::registerExceptionHandler();
                 FB::registerAssertionHandler(true, false);
                 if ($verbose) {
                     FB::log('JFirePHP: E_WARNING, E_NOTICE, E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE and E_RECOVERABLE_ERROR redirected.');
                 }
             }
             if ($verbose) {
                 FB::groupEnd();
             }
         }
     }
 }
Esempio n. 25
0
 /**
  * アプリケーションログを記録
  *
  * <pre>
  * アプリケーションログを記録します。
  * このログは画面上で確認できる一時的なスクリーンログです。
  * </pre>
  *
  * @param string $logKey   ログキー
  * @param mixed  $logValue 値
  *
  * @return void
  */
 public function log($logKey, $logValue = null)
 {
     if ($this->_config['debug'] !== true) {
         return;
     }
     $this->_logs[][$logKey] = $logValue;
     $showFirePHP = isset($_GET['_firelog']) || array_search($logKey, $this->_fbKeys) !== false;
     if (class_exists('FB', false) && $showFirePHP) {
         $color = $logValue ? 'black' : 'grey';
         FB::group($logKey, array('Collapsed' => true, 'Color' => $color));
         FB::log($logValue);
         FB::groupEnd();
     }
     if (!is_scalar($logValue)) {
         $logValue = print_r($logValue, true);
         $logValue = str_replace("\n", '', $logValue);
         $logValue = preg_replace("/\\s+/s", " ", $logValue);
     }
 }
Esempio n. 26
0
 public function getOptions()
 {
     // Initialize variables.
     $options = array();
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('id As value, titolo As text');
     $query->from('#__gg_unit AS a');
     $query->order('a.titolo');
     FB::log("Recupero le categorie");
     // Get the options.
     $db->setQuery($query);
     $options = $db->loadObjectList();
     // Check for a database error.
     if ($db->getErrorNum()) {
         JError::raiseWarning(500, $db->getErrorMsg());
     }
     return $options;
 }
Esempio n. 27
0
 /**
  * Method to get a list of categories that respects access controls and can be used for
  * either category assignment or parent category assignment in edit screens.
  * Use the parent element to indicate that the field will be used for assigning parent categories.
  *
  * @return	array	The field option objects.
  * @since	1.6
  */
 protected function getOptions()
 {
     // Initialise variables.
     $options = array();
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('a.id AS value, a.parametro AS text');
     $query->from('#__gg_param AS a');
     $query->order("a.id, a.ordinamento");
     $db->setQuery($query);
     $options = $db->loadObjectList();
     FB::log($options, "Parametri");
     // Check for a database error.
     if ($db->getErrorNum()) {
         JError::raiseWarning(500, $db->getErrorMsg());
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
Esempio n. 28
0
 public static function OutputDatabaseProfile(QDatabaseBase $objDb = null)
 {
     if ($objDb == null) {
         $objDb = QApplication::$Database[1];
     }
     if ($objDb->EnableProfiling) {
         $objProfileArray = $objDb->Profile;
         $intCount = count($objProfileArray) / 2;
         if ($intCount == 0) {
             parent::log(QApplication::Translate('No queries were performed.'));
         } else {
             if ($intCount == 1) {
                 parent::log(QApplication::Translate('1 query was performed.'));
             } else {
                 $log = sprintf(QApplication::Translate('%s queries were performed.'), $intCount);
                 parent::log($log);
             }
         }
         for ($intIndex = 0; $intIndex < count($objProfileArray); $intIndex++) {
             $objDebugBacktrace = $objProfileArray[$intIndex]['objBacktrace'];
             $strQuery = $objProfileArray[$intIndex]['strQuery'];
             $dblTimeInfo = $objProfileArray[$intIndex]['dblTimeInfo'];
             $objArgs = array_key_exists('args', $objDebugBacktrace) ? $objDebugBacktrace['args'] : array();
             $strClass = array_key_exists('class', $objDebugBacktrace) ? $objDebugBacktrace['class'] : null;
             $strType = array_key_exists('type', $objDebugBacktrace) ? $objDebugBacktrace['type'] : null;
             $strFunction = array_key_exists('function', $objDebugBacktrace) ? $objDebugBacktrace['function'] : null;
             $strFile = array_key_exists('file', $objDebugBacktrace) ? $objDebugBacktrace['file'] : null;
             $strLine = array_key_exists('line', $objDebugBacktrace) ? $objDebugBacktrace['line'] : null;
             $called = QApplication::Translate('Called by') . ' ' . $strClass . $strType . $strFunction . '(' . implode(', ', $objArgs) . ')';
             parent::group($called);
             $file = $strFile . ' ' . QApplication::Translate('Line') . ': ' . $strLine;
             parent::log($file, QApplication::Translate('File'));
             parent::log($strQuery, QApplication::Translate('Query'));
             parent::log($dblTimeInfo, QApplication::Translate('Time Info'));
             parent::groupEnd();
         }
     } else {
         parent::log(QApplication::Translate('Profiling was not enabled for this database connection. To enable, ensure that ENABLE_PROFILING is set to TRUE.'));
     }
 }
Esempio n. 29
0
 /**
  * Method to get a list of categories that respects access controls and can be used for
  * either category assignment or parent category assignment in edit screens.
  * Use the parent element to indicate that the field will be used for assigning parent categories.
  *
  * @return	array	The field option objects.
  * @since	1.6
  */
 protected function getOptions()
 {
     // Initialise variables.
     $options = array();
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('a.id AS value, CONCAT(u.titolo," - ",a.titolo) AS text');
     $query->from('#__gg_contenuti AS a');
     $query->join('left', '#__gg_unit_map AS m ON m.idcontenuto= a.id');
     $query->join('left', '#__gg_unit AS u ON u.id= m.idunita');
     $query->order("u.id, m.ordinamento");
     $db->setQuery($query);
     $options = $db->loadObjectList();
     FB::log($options, "Prerequisiti");
     // Check for a database error.
     if ($db->getErrorNum()) {
         JError::raiseWarning(500, $db->getErrorMsg());
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
Esempio n. 30
0
function sendError($error, $msg = '')
{
    global $ERRORS_TO;
    $details = var_export($error, true);
    $ip = $_SERVER['REMOTE_ADDR'];
    $log = fopen('work/sforce.log', 'a');
    if ($log) {
        fwrite($log, '----ERROR-------------- ' . date('c') . "\n");
        fwrite($log, $ip . "\n");
        if ($msg) {
            fwrite($log, $msg);
        }
        fwrite($log, $details);
        fwrite($log, "\n");
        fclose($log);
    }
    FB::log($obj, $msg = '');
    $to = ERRORS_TO;
    $subject = 'Top Company Form Error';
    $headers = 'From: webmaster@anitaborg.org' . "\r\n" . "Reply-To: " . ERRORS_TO . " \r\n" . 'X-Mailer: PHP/' . phpversion() . "\r\n" . "Return-Path:<" . ERRORS_TO . "\r\n";
    mail($to, $subject, $msg . "\n" . $details, $headers);
}