| Server IP : 195.130.67.5 / Your IP : 216.73.217.154 Web Server : Microsoft-IIS/10.0 System : Windows NT WEBSERVER1 10.0 build 17763 (Windows Server 2016) i586 User : IUSR ( 0) PHP Version : 7.4.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /Old Sites/ees_request/administrator/components/com_printme/helpers/ |
Upload File : |
<?php
/**
* @version 1.5
* @package Printme
* @author Dioscouri Design
* @link http://www.dioscouri.com
* @copyright Copyright (C) 2007 Dioscouri Design. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
*/
/** ensure this file is being included by a parent file */
defined('_JEXEC') or die('Restricted access');
JLoader::import( 'com_printme.helpers._base', JPATH_ADMINISTRATOR.DS.'components' );
class PrintmeHelperDiagnostics extends PrintmeHelperBase
{
/**
* Redirects with message
*
* @param object $message [optional] Message to display
* @param object $type [optional] Message type
*/
function redirect($message = '', $type = '')
{
$mainframe = JFactory::getApplication();
if ($message)
{
$mainframe->enqueueMessage($message, $type);
}
JRequest::setVar('controller', 'dashboard');
JRequest::setVar('view', 'dashboard');
JRequest::setVar('task', '');
return;
}
/**
* Inserts fields into a table
*
* @param string $table
* @param array $fields
* @param array $definitions
* @return boolean
*/
function insertTableFields($table, $fields, $definitions)
{
$database = JFactory::getDBO();
$fields = (array) $fields;
$errors = array();
foreach ($fields as $field)
{
$query = " SHOW COLUMNS FROM {$table} LIKE '{$field}' ";
$database->setQuery( $query );
$rows = $database->loadObjectList();
if (!$rows && !$database->getErrorNum())
{
$query = "ALTER TABLE `{$table}` ADD `{$field}` {$definitions[$field]}; ";
$database->setQuery( $query );
if (!$database->query())
{
$errors[] = $database->getErrorMsg();
}
}
}
if (!empty($errors))
{
$this->setError( implode('<br/>', $errors) );
return false;
}
return true;
}
/**
* Changes fields in a table
*
* @param string $table
* @param array $fields
* @param array $definitions
* @param array $newnames
* @return boolean
*/
function changeTableFields($table, $fields, $definitions, $newnames)
{
$database = JFactory::getDBO();
$fields = (array) $fields;
$errors = array();
foreach ($fields as $field)
{
$query = " SHOW COLUMNS FROM {$table} LIKE '{$field}' ";
$database->setQuery( $query );
$rows = $database->loadObjectList();
if ($rows && !$database->getErrorNum())
{
$query = "ALTER TABLE `{$table}` CHANGE `{$field}` `{$newnames[$field]}` {$definitions[$field]}; ";
$database->setQuery( $query );
if (!$database->query())
{
$errors[] = $database->getErrorMsg();
}
}
}
if (!empty($errors))
{
$this->setError( implode('<br/>', $errors) );
return false;
}
return true;
}
/**
* Drops fields in a table
*
* @param string $table
* @param array $fields
* @return boolean
*/
function dropTableFields($table, $fields)
{
$database = JFactory::getDBO();
$fields = (array) $fields;
$errors = array();
foreach ($fields as $field)
{
$query = " SHOW COLUMNS FROM {$table} LIKE '{$field}' ";
$database->setQuery( $query );
$rows = $database->loadObjectList();
if ($rows && !$database->getErrorNum())
{
$query = "ALTER TABLE `{$table}` DROP `{$field}` ; ";
$database->setQuery( $query );
if (!$database->query())
{
$errors[] = $database->getErrorMsg();
}
}
}
if (!empty($errors))
{
$this->setError( implode('<br/>', $errors) );
return false;
}
return true;
}
/**
* Performs basic checks on your Printme installation to ensure it is configured OK
* @return unknown_type
*/
function checkInstallation()
{
// TODO check all DB tables
// TODO if no articles associated for site::dashboard, create default articles for dashboard
// and update config
}
}