Сам себе режиссер | Ок, вот вся имеющаяся инфа про ошибки на сайте: Ошибка №1 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/p50620/www/redprice-shop.ru/libraries/joomla/database/database/mysql.php on line 344 Ошибка№2 Warning: Invalid argument supplied for foreach() in /home/p50620/www/redprice-shop.ru/modules/mod_virtuemart_product_categories/mod_virtuemart_product_categories.php on line 68 mysql.php
PHP код: <?php
/**
* @version $Id: mysql.php 16385 2010-04-23 10:44:15Z ian $
* @package Joomla.Framework
* @subpackage Database
* @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
// Check to ensure this file is within the rest of the framework
defined('JPATH_BASE') or die();
/**
* MySQL database driver
*
* @package Joomla.Framework
* @subpackage Database
* @since 1.0
*/
class JDatabaseMySQL extends JDatabase
{
/**
* The database driver name
*
* @var string
*/
var $name = 'mysql';
/**
* The null/zero date string
*
* @var string
*/
var $_nullDate = '0000-00-00 00:00:00';
/**
* Quote for named objects
*
* @var string
*/
var $_nameQuote = '`';
/**
* Database object constructor
*
* @access public
* @param array List of options used to configure the connection
* @since 1.5
* @see JDatabase
*/
function __construct( $options )
{
$host = array_key_exists('host', $options) ? $options['host'] : 'localhost';
$user = array_key_exists('user', $options) ? $options['user'] : '';
$password = array_key_exists('password',$options) ? $options['password'] : '';
$database = array_key_exists('database',$options) ? $options['database'] : '';
$prefix = array_key_exists('prefix', $options) ? $options['prefix'] : 'jos_';
$select = array_key_exists('select', $options) ? $options['select'] : true;
// perform a number of fatality checks, then return gracefully
if (!function_exists( 'mysql_connect' )) {
$this->_errorNum = 1;
$this->_errorMsg = 'The MySQL adapter "mysql" is not available.';
return;
}
// connect to the server
if (!($this->_resource = @mysql_connect( $host, $user, $password, true ))) {
$this->_errorNum = 2;
$this->_errorMsg = 'Could not connect to MySQL';
return;
}
// finalize initialization
parent::__construct($options);
// select the database
if ( $select ) {
$this->select($database);
}
}
/**
* Database object destructor
*
* @return boolean
* @since 1.5
*/
function __destruct()
{
$return = false;
if (is_resource($this->_resource)) {
$return = mysql_close($this->_resource);
}
return $return;
}
/**
* Test to see if the MySQL connector is available
*
* @static
* @access public
* @return boolean True on success, false otherwise.
*/
function test()
{
return (function_exists( 'mysql_connect' ));
}
/**
* Determines if the connection to the server is active.
*
* @access public
* @return boolean
* @since 1.5
*/
function connected()
{
if(is_resource($this->_resource)) {
return mysql_ping($this->_resource);
}
return false;
}
/**
* Select a database for use
*
* @access public
* @param string $database
* @return boolean True if the database has been successfully selected
* @since 1.5
*/
function select($database)
{
if ( ! $database )
{
return false;
}
if ( !mysql_select_db( $database, $this->_resource )) {
$this->_errorNum = 3;
$this->_errorMsg = 'Could not connect to database';
return false;
}
// if running mysql 5, set sql-mode to mysql40 - thereby circumventing strict mode problems
if ( strpos( $this->getVersion(), '5' ) === 0 ) {
$this->setQuery( "SET sql_mode = 'MYSQL40'" );
$this->query();
}
return true;
}
/**
* Determines UTF support
*
* @access public
* @return boolean True - UTF is supported
*/
function hasUTF()
{
$verParts = explode( '.', $this->getVersion() );
return ($verParts[0] == 5 || ($verParts[0] == 4 && $verParts[1] == 1 && (int)$verParts[2] >= 2));
}
/**
* Custom settings for UTF support
*
* @access public
*/
function setUTF()
{
mysql_query( "SET NAMES 'utf8'", $this->_resource );
}
/**
* Get a database escaped string
*
* @param string The string to be escaped
* @param boolean Optional parameter to provide extra escaping
* @return string
* @access public
* @abstract
*/
function getEscaped( $text, $extra = false )
{
$result = mysql_real_escape_string( $text, $this->_resource );
if ($extra) {
$result = addcslashes( $result, '%_' );
}
return $result;
}
/**
* Execute the query
*
* @access public
* @return mixed A database resource if successful, FALSE if not.
*/
function query()
{
if (!is_resource($this->_resource)) {
return false;
}
// Take a local copy so that we don't modify the original query and cause issues later
$sql = $this->_sql;
if ($this->_limit > 0 || $this->_offset > 0) {
$sql .= ' LIMIT ' . max($this->_offset, 0) . ', ' . max($this->_limit, 0);
}
if ($this->_debug) {
$this->_ticker++;
$this->_log[] = $sql;
}
$this->_errorNum = 0;
$this->_errorMsg = '';
$this->_cursor = mysql_query( $sql, $this->_resource );
if (!$this->_cursor)
{
$this->_errorNum = mysql_errno( $this->_resource );
$this->_errorMsg = mysql_error( $this->_resource )." SQL=$sql";
if ($this->_debug) {
JError::raiseError(500, 'JDatabaseMySQL::query: '.$this->_errorNum.' - '.$this->_errorMsg );
}
return false;
}
return $this->_cursor;
}
/**
* Description
*
* @access public
* @return int The number of affected rows in the previous operation
* @since 1.0.5
*/
function getAffectedRows()
{
return mysql_affected_rows( $this->_resource );
}
/**
* Execute a batch query
*
* @access public
* @return mixed A database resource if successful, FALSE if not.
*/
function queryBatch( $abort_on_error=true, $p_transaction_safe = false)
{
$this->_errorNum = 0;
$this->_errorMsg = '';
if ($p_transaction_safe) {
$this->_sql = rtrim($this->_sql, "; \t\r\n\0");
$si = $this->getVersion();
preg_match_all( "/(\d+)\.(\d+)\.(\d+)/i", $si, $m );
if ($m[1] >= 4) {
$this->_sql = 'START TRANSACTION;' . $this->_sql . '; COMMIT;';
} else if ($m[2] >= 23 && $m[3] >= 19) {
$this->_sql = 'BEGIN WORK;' . $this->_sql . '; COMMIT;';
} else if ($m[2] >= 23 && $m[3] >= 17) {
$this->_sql = 'BEGIN;' . $this->_sql . '; COMMIT;';
}
}
$query_split = $this->splitSql($this->_sql);
$error = 0;
foreach ($query_split as $command_line) {
$command_line = trim( $command_line );
if ($command_line != '') {
$this->_cursor = mysql_query( $command_line, $this->_resource );
if ($this->_debug) {
$this->_ticker++;
$this->_log[] = $command_line;
}
if (!$this->_cursor) {
$error = 1;
$this->_errorNum .= mysql_errno( $this->_resource ) . ' ';
$this->_errorMsg .= mysql_error( $this->_resource )." SQL=$command_line <br />";
if ($abort_on_error) {
return $this->_cursor;
}
}
}
}
return $error ? false : true;
}
/**
* Diagnostic function
*
* @access public
* @return string
*/
function explain()
{
$temp = $this->_sql;
$this->_sql = "EXPLAIN $this->_sql";
if (!($cur = $this->query())) {
return null;
}
$first = true;
$buffer = '<table id="explain-sql">';
$buffer .= '<thead><tr><td colspan="99">'.$this->getQuery().'</td></tr>';
while ($row = mysql_fetch_assoc( $cur )) {
if ($first) {
$buffer .= '<tr>';
foreach ($row as $k=>$v) {
$buffer .= '<th>'.$k.'</th>';
}
$buffer .= '</tr>';
$first = false;
}
$buffer .= '</thead><tbody><tr>';
foreach ($row as $k=>$v) {
$buffer .= '<td>'.$v.'</td>';
}
$buffer .= '</tr>';
}
$buffer .= '</tbody></table>';
mysql_free_result( $cur );
$this->_sql = $temp;
return $buffer;
}
/**
* Description
*
* @access public
* @return int The number of rows returned from the most recent query.
*/
function getNumRows( $cur=null )
{
return mysql_num_rows( $cur ? $cur : $this->_cursor );
}
/**
* This method loads the first field of the first row returned by the query.
*
* @access public
* @return The value returned in the query or null if the query failed.
*/
function loadResult()
{
if (!($cur = $this->query())) {
return null;
}
$ret = null;
if ($row = mysql_fetch_row( $cur )) {
$ret = $row[0];
}
mysql_free_result( $cur );
return $ret;
}
/**
* Load an array of single field results into an array
*
* @access public
*/
function loadResultArray($numinarray = 0)
{
if (!($cur = $this->query())) {
return null;
}
$array = array();
while ($row = mysql_fetch_row( $cur )) {
$array[] = $row[$numinarray];
}
mysql_free_result( $cur );
return $array;
}
/**
* Fetch a result row as an associative array
*
* @access public
* @return array
*/
function loadAssoc()
{
if (!($cur = $this->query())) {
return null;
}
$ret = null;
if ($array = mysql_fetch_assoc( $cur )) {
$ret = $array;
}
mysql_free_result( $cur );
return $ret;
}
/**
* Load a assoc list of database rows
*
* @access public
* @param string The field name of a primary key
* @return array If <var>key</var> is empty as sequential list of returned records.
*/
function loadAssocList( $key='' )
{
if (!($cur = $this->query())) {
return null;
}
$array = array();
while ($row = mysql_fetch_assoc( $cur )) {
if ($key) {
$array[$row[$key]] = $row;
} else {
$array[] = $row;
}
}
mysql_free_result( $cur );
return $array;
}
/**
* This global function loads the first row of a query into an object
*
* @access public
* @return object
*/
function loadObject( )
{
if (!($cur = $this->query())) {
return null;
}
$ret = null;
if ($object = mysql_fetch_object( $cur )) {
$ret = $object;
}
mysql_free_result( $cur );
return $ret;
}
/**
* Load a list of database objects
*
* If <var>key</var> is not empty then the returned array is indexed by the value
* the database key. Returns <var>null</var> if the query fails.
*
* @access public
* @param string The field name of a primary key
* @return array If <var>key</var> is empty as sequential list of returned records.
*/
function loadObjectList( $key='' )
{
if (!($cur = $this->query())) {
return null;
}
$array = array();
while ($row = mysql_fetch_object( $cur )) {
if ($key) {
$array[$row->$key] = $row;
} else {
$array[] = $row;
}
}
mysql_free_result( $cur );
return $array;
}
/**
* Description
*
* @access public
* @return The first row of the query.
*/
function loadRow()
{
if (!($cur = $this->query())) {
return null;
}
$ret = null;
if ($row = mysql_fetch_row( $cur )) {
$ret = $row;
}
mysql_free_result( $cur );
return $ret;
}
/**
* Load a list of database rows (numeric column indexing)
*
* @access public
* @param string The field name of a primary key
* @return array If <var>key</var> is empty as sequential list of returned records.
* If <var>key</var> is not empty then the returned array is indexed by the value
* the database key. Returns <var>null</var> if the query fails.
*/
function loadRowList( $key=null )
{
if (!($cur = $this->query())) {
return null;
}
$array = array();
while ($row = mysql_fetch_row( $cur )) {
if ($key !== null) {
$array[$row[$key]] = $row;
} else {
$array[] = $row;
}
}
mysql_free_result( $cur );
return $array;
}
/**
* Inserts a row into a table based on an objects properties
*
* @access public
* @param string The name of the table
* @param object An object whose properties match table fields
* @param string The name of the primary key. If provided the object property is updated.
*/
function insertObject( $table, &$object, $keyName = NULL )
{
$fmtsql = 'INSERT INTO '.$this->nameQuote($table).' ( %s ) VALUES ( %s ) ';
$fields = array();
foreach (get_object_vars( $object ) as $k => $v) {
if (is_array($v) or is_object($v) or $v === NULL) {
continue;
}
if ($k[0] == '_') { // internal field
continue;
}
$fields[] = $this->nameQuote( $k );
$values[] = $this->isQuoted( $k ) ? $this->Quote( $v ) : (int) $v;
}
$this->setQuery( sprintf( $fmtsql, implode( ",", $fields ) , implode( ",", $values ) ) );
if (!$this->query()) {
return false;
}
$id = $this->insertid();
if ($keyName && $id) {
$object->$keyName = $id;
}
return true;
}
/**
* Description
*
* @access public
* @param [type] $updateNulls
*/
function updateObject( $table, &$object, $keyName, $updateNulls=true )
{
$fmtsql = 'UPDATE '.$this->nameQuote($table).' SET %s WHERE %s';
$tmp = array();
foreach (get_object_vars( $object ) as $k => $v)
{
if( is_array($v) or is_object($v) or $k[0] == '_' ) { // internal or NA field
continue;
}
if( $k == $keyName ) { // PK not to be updated
$where = $keyName . '=' . $this->Quote( $v );
continue;
}
if ($v === null)
{
if ($updateNulls) {
$val = 'NULL';
} else {
continue;
}
} else {
$val = $this->isQuoted( $k ) ? $this->Quote( $v ) : (int) $v;
}
$tmp[] = $this->nameQuote( $k ) . '=' . $val;
}
$this->setQuery( sprintf( $fmtsql, implode( ",", $tmp ) , $where ) );
return $this->query();
}
/**
* Description
*
* @access public
*/
function insertid()
{
return mysql_insert_id( $this->_resource );
}
/**
* Description
*
* @access public
*/
function getVersion()
{
return mysql_get_server_info( $this->_resource );
}
/**
* Assumes database collation in use by sampling one text field in one table
*
* @access public
* @return string Collation in use
*/
function getCollation ()
{
if ( $this->hasUTF() ) {
$this->setQuery( 'SHOW FULL COLUMNS FROM #__content' );
$array = $this->loadAssocList();
return $array['4']['Collation'];
} else {
return "N/A (mySQL < 4.1.2)";
}
}
/**
* Description
*
* @access public
* @return array A list of all the tables in the database
*/
function getTableList()
{
$this->setQuery( 'SHOW TABLES' );
return $this->loadResultArray();
}
/**
* Shows the CREATE TABLE statement that creates the given tables
*
* @access public
* @param array|string A table name or a list of table names
* @return array A list the create SQL for the tables
*/
function getTableCreate( $tables )
{
settype($tables, 'array'); //force to array
$result = array();
foreach ($tables as $tblval) {
$this->setQuery( 'SHOW CREATE table ' . $this->getEscaped( $tblval ) );
$rows = $this->loadRowList();
foreach ($rows as $row) {
$result[$tblval] = $row[1];
}
}
return $result;
}
/**
* Retrieves information about the given tables
*
* @access public
* @param array|string A table name or a list of table names
* @param boolean Only return field types, default true
* @return array An array of fields by table
*/
function getTableFields( $tables, $typeonly = true )
{
settype($tables, 'array'); //force to array
$result = array();
foreach ($tables as $tblval)
{
$this->setQuery( 'SHOW FIELDS FROM ' . $tblval );
$fields = $this->loadObjectList();
if($typeonly)
{
foreach ($fields as $field) {
$result[$tblval][$field->Field] = preg_replace("/[(0-9)]/",'', $field->Type );
}
}
else
{
foreach ($fields as $field) {
$result[$tblval][$field->Field] = $field;
}
}
}
return $result;
}
}
mod_virtuemart_product_categories.php
PHP код: <?php
if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );
/**
* mambo-phphop Product Categories Module
* NOTE: THIS MODULE REQUIRES AN INSTALLED VirtueMart Component!
*
* @version $Id: mod_virtuemart_product_categories.php
* @package VirtueMart
* @subpackage modules
*
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*
* VirtueMart is Free Software.
* VirtueMart comes with absolute no warranty.
*
* www.virtuemart.net
*/
global $jscook_type, $jscookMenu_style, $jscookTree_style;
// Load the virtuemart main parse code
if( file_exists(dirname(__FILE__).'/../../components/com_virtuemart/virtuemart_parser.php' )) {
require_once( dirname(__FILE__).'/../../components/com_virtuemart/virtuemart_parser.php' );
$mosConfig_absolute_path = realpath( dirname(__FILE__).'/../..' );
} else {
require_once( dirname(__FILE__).'/../components/com_virtuemart/virtuemart_parser.php' );
}
if (!function_exists(getXhtmlList)){
function getXhtmlList($category_id=0, $rankmin, $rankmax, $params, $only_published=true, $keyword = "" ) {
if (empty($category_id)) {
$category_id="0";
}
$db = &JFactory::getDBO();
$parent_id=$category_id;
$menus_table=array();
if ($rows = getKidos($parent_id)) {
$menus_table[]=$rows;
}
if ($category_id>0) {
do {
$child_id=$parent_id;
$parent_id=getDady($parent_id);
$rows = getKidos($parent_id);
for ($n=0; $n<count($rows); $n++) {
if ($rows[$n]['id']==$child_id){
$rows[$n]['active']=1;
}
if ($rows[$n]['id']==$category_id){
$rows[$n]['active']=2;
}
}
$menus_table[] = $rows;
} while ($parent_id>0);
}
$menus_table = array_reverse($menus_table);
// output
return getRowMenu ($menus_table,$rankmin, $rankmax, true, $params);
}
function getRowMenu ($rows,$rankmin, $rankmax, $firstPass=false, $params) {
global $sess ;
$class_sfx = $params->get( 'class_sfx', "" );
$Itemidmod = JRequest::getVar('Itemid', '');
if (!empty($Itemidmod)) {
$Itemidmod='&Itemid='.$Itemidmod;
}
if (isset($rows[$rankmin])) {
$html='<ul'.($firstPass?' class="vmLinkMenu'.$class_sfx.'"':'').'>';
$numLi=0;
foreach ($rows[$rankmin] as $menu_element) {
$texte = shopMakeHtmlSafe ($menu_element['name']);
$link = JFilterOutput::ampReplace(JURI::base()."index.php?option=com_virtuemart&page=shop.browse&category_id=".$menu_element['id'].$Itemidmod);
if ($menu_element['active']==1) {
$class = ' class="active item'.$numLi.'"';
} elseif ($menu_element['active']==2) {
$class = ' class="active item'.$numLi.'" id="active_menu"';
} else {
$class = ' class="item'.$numLi.'"';
}
$html.= '<li'.$class.'><a href="'.$link.'" title="'.$texte.'" ><span>'.$texte.'</span></a>';
if ($menu_element['active']>0 && $rankmin<$rankmax && isset($rows[$rankmin+1])) {
$html.=getRowMenu ($rows,$rankmin+1, $rankmax,false, $params);
}
$html.= '</li>';
$numLi++;
}
$html.="</ul>";
return $html;
}
}
function getDady($catpid, $only_published=true, $keyword = "") {
$db = &JFactory::getDBO();
$query="SELECT category_parent_id FROM #__vm_category_xref WHERE category_child_id=".$catpid;
$db->setQuery($query);
return $db->loadResult();
}
function getKidos ($catpid, $only_published=true, $keyword = "") {
$db = &JFactory::getDBO();
$query = "SELECT category_id AS id, category_parent_id AS parent, category_name AS name, 0 AS active ".
"FROM #__vm_category_xref, #__vm_category ".
"WHERE category_parent_id = ".$catpid.
" AND #__vm_category.category_id=#__vm_category_xref.category_child_id ";
if( $only_published ) {
$query .= " AND #__vm_category.category_publish='Y' ";
}
if( !empty( $keyword )) {
$query .= "AND ( category_name LIKE '%$keyword%' ";
$query .= "OR category_description LIKE '%$keyword%' ";
$query .= ") ";
}
$query .= "ORDER BY #__vm_category.list_order ASC, #__vm_category.category_name ASC";
$db->setQuery($query);
$db->query();
if ($db->getNumRows()>0) {
return $db->loadAssocList();
} else {
return false;
}
}
}
$category_id = vmGet( $_REQUEST, 'category_id');
global $VM_LANG, $sess;
$rankmin = $params->get( 'link_list_min_rank','0');
$rankmax = $params->get( 'link_list_max_rank', '10' );
echo '
<div class="vmlinklist'.$params->get('moduleclass_sfx','').'">'.
getXhtmlList($category_id, $rankmin, $rankmax, $params).
'
</div>';
?>
Еще в самом Virtuemartе присутствует такая ошибка: Warning: Attempt to assign property of non-object in /home/p50620/www/redprice-shop.ru/libraries/joomla/html/editor.php on line 309 |