PHPMyAdmin Database connection errors - mysql

I ran query to this effect:
SELECT x.minid FROM (SELECT p.post_title, MIN(p.ID) as minid, m.meta_value
FROM
wp_postmeta m
INNER JOIN wp_posts p
ON p.id = m.post_id
AND p.post_type = 'Product'
WHERE
m.meta_key = '_regular_price'
AND NOT EXISTS (
SELECT 1
FROM
wp_postmeta m1
INNER JOIN wp_posts p1
ON p1.id = m1.post_id
AND p1.post_type = 'Product'
WHERE
m1.meta_key = '_regular_price'
AND p1.post_title = p.post_title
AND m1.meta_value < m.meta_value
And after a long time running the query, it finally threw up this error:
Error
SQL query: DocumentationEdit Edit
SELECT `CHARACTER_SET_NAME` AS `Charset`, `DESCRIPTION` AS `Description` FROM `information_schema`.`CHARACTER_SETS`
Open new phpMyAdmin window
mysqli_connect(): (08004/1040): Too many connections
mysqli_real_connect(): (28000/1045): Access denied for user 'ptrcao'#'localhost' (using password: NO)
mysqli_real_connect(): (28000/1045): Access denied for user 'ptrcao'#'localhost' (using password: NO)
Notice in ./libraries/classes/Config.php#855
Undefined index: collation_connection
Backtrace
./libraries/classes/Config.php#968: PhpMyAdmin\Config->_setConnectionCollation()
./libraries/common.inc.php#453: PhpMyAdmin\Config->loadUserPreferences()
./index.php#26: require_once(./libraries/common.inc.php)
Notice in ./libraries/classes/DatabaseInterface.php#1501
Undefined index: charset_connection
Backtrace
./libraries/classes/Config.php#857: PhpMyAdmin\DatabaseInterface->setCollation(string 'utf8mb4_unicode_ci')
./libraries/classes/Config.php#968: PhpMyAdmin\Config->_setConnectionCollation()
./libraries/common.inc.php#453: PhpMyAdmin\Config->loadUserPreferences()
./index.php#26: require_once(./libraries/common.inc.php)
Failed to set configured collation connection!
Notice in ./index.php#264
Undefined variable: collation_connection
Backtrace
Previously, I was having problems with the queries maxing out my memory resources. I then added on 16G of swap memory as a stopgap measure. It seemed to staved off the #2013 - Lost connection to MySQL server during query error encountered previously, but instead after a long time running, the query produced all the above errors. Please advise.
/usr/local/cpanel/base/3rdparty/phpMyAdmin/libraries/classes/DatabaseInterface.php:
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Main interface for database interactions
*
* #package PhpMyAdmin-DBI
*/
namespace PhpMyAdmin;
use PhpMyAdmin\Core;
use PhpMyAdmin\Database\DatabaseList;
use PhpMyAdmin\Dbi\DbiExtension;
use PhpMyAdmin\Dbi\DbiDummy;
use PhpMyAdmin\Dbi\DbiMysql;
use PhpMyAdmin\Dbi\DbiMysqli;
use PhpMyAdmin\Di\Container;
use PhpMyAdmin\Error;
use PhpMyAdmin\Index;
use PhpMyAdmin\LanguageManager;
use PhpMyAdmin\Relation;
use PhpMyAdmin\SystemDatabase;
use PhpMyAdmin\Table;
use PhpMyAdmin\Types;
"DatabaseInterface.php" 3060L, 104788C
/usr/local/cpanel/base/3rdparty/phpMyAdmin/libraries/classes/Config.php:
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Configuration handling.
*
* #package PhpMyAdmin
*/
namespace PhpMyAdmin;
use DirectoryIterator;
use PhpMyAdmin\Core;
use PhpMyAdmin\Error;
use PhpMyAdmin\LanguageManager;
use PhpMyAdmin\ThemeManager;
use PhpMyAdmin\Url;
use PhpMyAdmin\UserPreferences;
use PhpMyAdmin\Util;
use PhpMyAdmin\Utils\HttpRequest;
/**
* Indication for error handler (see end of this file).
*/
$GLOBALS['pma_config_loading'] = false;
/**
* Configuration class
*
* #package PhpMyAdmin
*/
class Config
{
/**
* #var string default config source
*/
var $default_source = './libraries/config.default.php';
/**
* #var array default configuration settings
*/
var $default = array();
/**
* #var array configuration settings, without user preferences applied
*/
var $base_settings = array();
/**
* #var array configuration settings
*/
var $settings = array();
/**
* #var string config source
*/
var $source = '';
/**
* #var int source modification time
*/
var $source_mtime = 0;
var $default_source_mtime = 0;
"Config.php" 1800L, 57604C
/usr/local/cpanel/base/3rdparty/phpMyAdmin/index.php:
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Main loader script
*
* #package PhpMyAdmin
*/
use PhpMyAdmin\Charsets;
use PhpMyAdmin\Config;
use PhpMyAdmin\Core;
use PhpMyAdmin\Display\GitRevision;
use PhpMyAdmin\LanguageManager;
use PhpMyAdmin\Message;
use PhpMyAdmin\RecentFavoriteTable;
use PhpMyAdmin\Relation;
use PhpMyAdmin\Response;
use PhpMyAdmin\Sanitize;
use PhpMyAdmin\Server\Select;
use PhpMyAdmin\ThemeManager;
use PhpMyAdmin\Url;
use PhpMyAdmin\Util;
/**
* Gets some core libraries and displays a top message if required
*/
require_once 'libraries/common.inc.php';
/**
* pass variables to child pages
*/
$drops = array(
'lang',
'server',
'collation_connection',
'db',
'table'
);
foreach ($drops as $each_drop) {
if (array_key_exists($each_drop, $_GET)) {
unset($_GET[$each_drop]);
}
}
unset($drops, $each_drop);
/*
* Black list of all scripts to which front-end must submit data.
* Such scripts must not be loaded on home page.
*
*/
$target_blacklist = array (
'import.php', 'export.php'
);
// If we have a valid target, let's load that script instead
if (! empty($_REQUEST['target'])
&& is_string($_REQUEST['target'])
&& ! preg_match('/^index/', $_REQUEST['target'])
&& ! in_array($_REQUEST['target'], $target_blacklist)
&& Core::checkPageValidity($_REQUEST['target'], [], true)
) {
include $_REQUEST['target'];
"index.php" 680L, 19899C

Related

My WordPress website and phpMyAdmin are not able to connect to MySQL [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
Here is my problem: my WordPress website and phpMyAdmin cannot access MySQL.
I am using Centos 7 and MySQK 8.0.18 for Linux on x86_64 (MySQL Community Server - GPL).
I tried so much stuff and I don't know what is wrong.
Background of what I've already tried
-I have another website that is made out of pure php and it is able to connect to my database with mysqli.
-I tried re-installing several times MySQL, phpMyAdmin and PHP.
-Disabled password to connect to phpmyadmin
-Gave all rights on all databases for testuser
-I am able to connect to mysql correctly with : mysql -u root -p
-testuser have all the rights to all databases (hes like root)
PHPMYADMIN CONFIG
(/etc/phpMyAdmin/config.inc.php):
<?php
/**
* phpMyAdmin configuration file, you can use it as base for the manual
* configuration. For easier setup you can use "setup/".
*
* All directives are explained in Documentation.html and on phpMyAdmin
* wiki <http://wiki.phpmyadmin.net>.
*/
/*
* This is needed for cookie based authentication to encrypt password in
* cookie
*/
$cfg['blowfish_secret'] = '*********************'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
/**
* Server(s) configuration
*/
$i = 0;
// The $cfg['Servers'] array starts with $cfg['Servers'][1]. Do not use
// $cfg['Servers'][0]. You can disable a server config entry by setting host
// to ''. If you want more than one server, just copy following section
// (including $i incrementation) serveral times. There is no need to define
// full server array, just define values you need to change.
$i++;
$cfg['Servers'][$i]['host'] = '127.0.0.1'; // MySQL hostname or IP address
$cfg['Servers'][$i]['port'] = ''; // MySQL port - leave blank for default port
$cfg['Servers'][$i]['socket'] = ''; // Path to the socket - leave blank for default socket
$cfg['Servers'][$i]['connect_type'] = 'tcp'; // How to connect to MySQL server ('tcp' or 'socket')
$cfg['Servers'][$i]['extension'] = 'mysqli'; // The php MySQL extension to use ('mysql' or 'mysqli')
$cfg['Servers'][$i]['compress'] = FALSE; // Use compressed protocol for the MySQL connection
// (requires PHP >= 4.3.0)
$cfg['Servers'][$i]['controluser'] = ''; // MySQL control user settings
// (this user must have read-only
$cfg['Servers'][$i]['controlpass'] = ''; // access to the "mysql/user"
// and "mysql/db" tables).
// The controluser is also
// used for all relational
// features (pmadb)
$cfg['Servers'][$i]['auth_type'] = 'cookie'; // Authentication method (config, http or cookie based)?
$cfg['Servers'][$i]['user'] = 'testuser'; // MySQL user
$cfg['Servers'][$i]['password'] = 'Password$123'; // MySQL password (only needed
// with 'config' auth_type)
$cfg['Servers'][$i]['only_db'] = ''; // If set to a db-name, only
// this db is displayed in left frame
// It may also be an array of db-names, where sorting order is relevant.
$cfg['Servers'][$i]['hide_db'] = ''; // Database name to be hidden from listings
$cfg['Servers'][$i]['verbose'] = ''; // Verbose name for this host - leave blank to show the hostname
$cfg['Servers'][$i]['pmadb'] = ''; // Database used for Relation, Bookmark and PDF Features
// (see scripts/create_tables.sql)
// - leave blank for no support
// DEFAULT: 'phpmyadmin'
$cfg['Servers'][$i]['bookmarktable'] = ''; // Bookmark table
// - leave blank for no bookmark support
// DEFAULT: 'pma_bookmark'
$cfg['Servers'][$i]['relation'] = ''; // table to describe the relation between links (see doc)
// - leave blank for no relation-links support
// DEFAULT: 'pma_relation'
$cfg['Servers'][$i]['table_info'] = ''; // table to describe the display fields
// - leave blank for no display fields support
// DEFAULT: 'pma_table_info'
$cfg['Servers'][$i]['table_coords'] = ''; // table to describe the tables position for the PDF schema
// - leave blank for no PDF schema support
// DEFAULT: 'pma_table_coords'
$cfg['Servers'][$i]['pdf_pages'] = ''; // table to describe pages of relationpdf
// - leave blank if you don't want to use this
// DEFAULT: 'pma_pdf_pages'
$cfg['Servers'][$i]['column_info'] = ''; // table to store column information
// - leave blank for no column comments/mime types
// DEFAULT: 'pma_column_info'
$cfg['Servers'][$i]['history'] = ''; // table to store SQL history
// - leave blank for no SQL query history
// DEFAULT: 'pma_history'
$cfg['Servers'][$i]['verbose_check'] = TRUE; // set to FALSE if you know that your pma_* tables
// are up to date. This prevents compatibility
// checks and thereby increases performance.
$cfg['Servers'][$i]['AllowRoot'] = TRUE; // whether to allow root login
$cfg['Servers'][$i]['AllowDeny']['order'] // Host authentication order, leave blank to not use
= '';
$cfg['Servers'][$i]['AllowDeny']['rules'] // Host authentication rules, leave blank for defaults
= array();
$cfg['Servers'][$i]['AllowNoPassword'] // Allow logins without a password. Do not change the FALSE
= FALSE; // default unless you're running a passwordless MySQL server
$cfg['Servers'][$i]['designer_coords'] // Leave blank (default) for no Designer support, otherwise
= ''; // set to suggested 'pma_designer_coords' if really needed
$cfg['Servers'][$i]['bs_garbage_threshold'] // Blobstreaming: Recommented default value from upstream
= 50; // DEFAULT: '50'
$cfg['Servers'][$i]['bs_repository_threshold'] // Blobstreaming: Recommented default value from upstream
= '32M'; // DEFAULT: '32M'
$cfg['Servers'][$i]['bs_temp_blob_timeout'] // Blobstreaming: Recommented default value from upstream
= 600; // DEFAULT: '600'
$cfg['Servers'][$i]['bs_temp_log_threshold'] // Blobstreaming: Recommented default value from upstream
= '32M'; // DEFAULT: '32M'
/*
* End of servers configuration
*/
/*
* Directories for saving/loading files from server
*/
$cfg['UploadDir'] = '/var/lib/phpMyAdmin/upload';
$cfg['SaveDir'] = '/var/lib/phpMyAdmin/save';
/*
* Disable the default warning that is displayed on the DB Details Structure
* page if any of the required Tables for the relation features is not found
*/
$cfg['PmaNoRelation_DisableWarning'] = TRUE;
/*
* phpMyAdmin 4.4.x is no longer maintained by upstream, but security fixes
* are still backported by downstream.
*/
$cfg['VersionCheck'] = FALSE;
?>
* WORDPRESS CONFIG *
<?php
/**
* The base configuration for WordPress
*
* The wp-config.php creation script uses this file during the
* installation. You don't have to use the web site, you can
* copy this file to "wp-config.php" and fill in the values.
*
* This file contains the following configurations:
*
* * MySQL settings
* * Secret keys
* * Database table prefix
* * ABSPATH
*
* #link https://codex.wordpress.org/Editing_wp-config.php
*
* #package WordPress
*/
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'testdatabase' );
/** MySQL database username */
define( 'DB_USER', 'testuser' );
/** MySQL database password */
define( 'DB_PASSWORD', 'Password$123' );
/** MySQL hostname */
define( 'DB_HOST', '127.0.0.1' );
/** Database Charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8mb4' );
/** The Database Collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );
/**##+
* Authentication Unique Keys and Salts.
*
* Change these to different unique phrases!
* You can generate these using the {#link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
* You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
*
* #since 2.6.0
*/
define( 'AUTH_KEY', '***************************' );
define( 'SECURE_AUTH_KEY', '**********************' );
define( 'LOGGED_IN_KEY', '******************' );
define( 'NONCE_KEY', '****************' );
define( 'AUTH_SALT', '**************' );
define( 'SECURE_AUTH_SALT', '************' );
define( 'LOGGED_IN_SALT', '******' );
define( 'NONCE_SALT', '*****' );
/**##-*/
/**
* WordPress Database Table prefix.
*
* You can have multiple installations in one database if you give each
* a unique prefix. Only numbers, letters, and underscores please!
*/
$table_prefix = 'wp_';
/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*
* For information on other constants that can be used for debugging,
* visit the Codex.
*
* #link https://codex.wordpress.org/Debugging_in_WordPress
*/
define( 'WP_DEBUG', false );
/* That's all, stop editing! Happy publishing. */
define('WP_ALLOW_REPAIR', true);
/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', dirname( __FILE__ ) . '/' );
}
/** Sets up WordPress vars and included files. */
require_once( ABSPATH . 'wp-settings.php' );
```
The errors I get:
WordPress error : Error establishing a database connection
PhpMyAdmin error: Cannot log in to the MySQL server
I can access phpMyAdmin (mywebsite.com/phpMyadmin/index.php)
I can access my databases with another test website I made out of pure php.
I finally found the answer.
The user testuser password started with : "$"
For example: $Pasword123
I feel stupid .... :')

Customizing user_nicename in wp_users table in wordpress

By default wordpress will santitize the contents written to user_nicename column in wp_users table. It will remove spaces, some special characters and change uppercase to lowercase. Will it be possible to update user_nicename column without sanitizations?
It is possible using the pre_user_nicename filter. You can read on it here https://developer.wordpress.org/reference/hooks/pre_user_nicename/ The filter is applied right after the nicename is sanitized, but we can still access the unsanitized data. This is from wp-includes/user.php
/*
* If a nicename is provided, remove unsafe user characters before using it.
* Otherwise build a nicename from the user_login.
*/
if ( ! empty( $userdata['user_nicename'] ) ) {
$user_nicename = sanitize_user( $userdata['user_nicename'], true );
if ( mb_strlen( $user_nicename ) > 50 ) {
return new WP_Error( 'user_nicename_too_long', __( 'Nicename may not be longer than 50 characters.' ) );
}
} else {
$user_nicename = mb_substr( $user_login, 0, 50 );
}
$user_nicename = sanitize_title( $user_nicename );
// Store values to save in user meta.
$meta = array();
/**
* Filters a user's nicename before the user is created or updated.
*
* #since 2.0.3
*
* #param string $user_nicename The user's nicename.
*/
$user_nicename = apply_filters( 'pre_user_nicename', $user_nicename );
$raw_user_url = empty( $userdata['user_url'] ) ? '' : $userdata['user_url'];
You can still access the unmodified nicename entered by the user with the $userdata['user_nicename'] variable. So an example filter would go like this:
add_filter( 'pre_user_nicename', 'my_nicename_modification');
function my_nicename_modification($userdata) {
/*do anything you want with $userdata['user_nicename'] here
or leave blank if you want it saved just as the user typed it in */
return $userdata['user_nicename'];
}
This will stop $user_nicename = sanitize_title( $user_nicename ); from running, on which you can read more on here https://codex.wordpress.org/Function_Reference/sanitize_title. That is that modifies the nicename as you explained in your question. Hope this helps

When will the database connection be closed in prestashop 1.6.1.3 version?

When will the database connection be closed in prestashop 1.6.1.3 after a db instance is created by $db = Db::getInstance();
Do I need to close the database connection manually by writing any code db close function?
Or the db class in prestashop will handle this?
Actually when will be the PrestaShop db connection will be closed after a db object is created by $db = Db::getInstance();?
See below code which is a simple php file in my root directory of prestashop to update one of my tables and this page is called every one minute by cron job task ,here I am not closing the connection anywhere ,do we need to close it ?
$CheckStatusSql = "select * from ticket_status where item_id='$ItemID' and ticket_series='$TicketSeries' and status='BOOKED' ";
$db = Db::getInstance();
$result = $db->executeS($CheckStatusSql, false);
$ChangeStatus ='';
while ($row = $db->nextRow($result)) {
$status = $row['status'];
$booked_on = $row['booked_on'];
$ticket_no = $row['ticket_no'];
$to_time = strtotime(date("Y-m-d H:i:s"));// Time Now
$from_time = strtotime($booked_on); //Booked Time
$time_diff_minutes=round(abs($to_time - $from_time) / 60,2);
if($time_diff_minutes>$checkMinutes){
$ChangeStatus=$ChangeStatus."Booked ticket no: '".$ticket_no."' exceeds 30 Minutes and its now about ".$time_diff_minutes." minutes, status changed to AVAILABLE<br><br\>";
$updateSql = "UPDATE ticket_status SET status = 'AVAILABLE', booked_on = NULL WHERE item_id='$ItemID' and ticket_series='$TicketSeries' and status='BOOKED' and ticket_no='$ticket_no'";
$bookResult = $db->executeS($updateSql, false);
}
}
That is I am just including the config file (require 'config/config.inc.php';) and creating a db object and then executing my query as shown below :
require 'config/config.inc.php';
$checkMinutes = 30;// In minutes
$checkTimeInSeconds = $checkMinutes*60;
$sql = 'SELECT * FROM ps_ticket WHERE status=5';
$db = Db::getInstance();
$result = $db->executeS($sql, false);
$i=1;
while ($row = $db->nextRow($result)) {
$time = strtotime($row['hold_on']);
$curtime = time();
if(($curtime-$time) > $checkTimeInSeconds) { ///3600 seconds
$sql = 'UPDATE `'._DB_PREFIX_.'lopp_ticket`
SET
`id_customer` = 0,
`hold_on`=0,
`status` = 1
WHERE `ticket_id` = '.$row['ticket_id'];
if(Db::getInstance()->execute($sql)) {
echo $row['ticket_id'].' Updated'.'<br>';
}
}
else {
echo $row['ticket_no'].'No'.'<br>';
}
$i++;
}
So here do I need to close the db connection anywhere in the above code or PrestaShop will handle itself?
Because the server admin is saying too many database sessions are been opened by our code ,
Also Is there anyway to check from where too many db sessions are open/active always ?
As far as i know i never have closed a DB connection in Prestashop.
There documentation also does not explicitly state to close each DB request.
Looking into there source code they also never run a close command after a DB connection.
Looking into the classes\db\DbMySQLi.php class we can find the function below.
/**
* Destroys the database connection link.
*
* #see DbCore::disconnect()
*/
public function disconnect()
{
#$this->link->close();
}
Then we will look into classes\db\Db.php where we find that the function $this->disconnect() is called. So its safe to say they will close all there DB connections automatically.
/**
* Closes connection to database.
*/
public function __destruct()
{
if ($this->link) {
$this->disconnect();
}
}

Trying to make a habbo retro but there's an issue

I did everything that a guy did on YouTube, and it seemed to work perfectly so far but at the end, after I typed in "localhost", I was left with this. MySQL Engine - RevCMS:
MySQL could not connect to database
I don't know what I'm doing wrong, but this is my config (located in xampp/htdogs/app/management/
<?php
if(!defined('IN_INDEX')) { die('Sorry, you cannot access this file.'); }
#Please fill this all out.
#NOTE: To set up TheHabbos.ORG's API go to wwwroot/mysite/thehabbos_api for IIS, OR, htdocs/thehabbos_api for XAMPP and others.
/*
*
* MySQL management
*
*/
$_CONFIG['mysql']['connection_type'] = 'connect'; //Type of connection: It must be connect, or pconnect: if you want a persistent connection.
$_CONFIG['mysql']['hostname'] = 'localhost'; //MySQL host
$_CONFIG['mysql']['username'] = 'root'; //MySQL username
$_CONFIG['mysql']['password'] = 'lol'; //MySQL password
$_CONFIG['mysql']['database'] = 'retro'; //MySQL database
$_CONFIG['mysql']['port'] = '3306'; //MySQL's port
/*
*
* Hotel management - All URLs do not end with an "/"
*
*/
$_CONFIG['hotel']['server_ip'] = 'localhost'; //IP of VPS/DEDI/etc
$_CONFIG['hotel']['url'] = 'http://localhost'; //Does not end with a "/"
$_CONFIG['hotel']['name'] = 'Habbzah'; // Hotel's name
$_CONFIG['hotel']['desc'] = 'Welcome To Habbzah Hotel!'; //Hotel's description
$_CONFIG['hotel']['email'] = 'support#habbzah.co; //Where the help queries from users are emailed to.#Priv skin
$_CONFIG['hotel']['in_maint'] = false; //False if hotel is NOT in maintenance. True if hotel IS in maintenance
$_CONFIG['hotel']['motto'] = 'I <3 ' . $_CONFIG['hotel']['name']; //Default motto users will register with.
$_CONFIG['hotel']['credits'] = 75000; //Default number of credits users will register with.
$_CONFIG['hotel']['pixels'] = 10000; //Default number of pixels users will register with.
$_CONFIG['hotel']['figure'] = 'ch-210-62.hd-180-1.lg-270-64.hr-100-31.sh-290-62'; //Default figure users will register with.
$_CONFIG['hotel']['web_build'] = '63_1dc60c6d6ea6e089c6893ab4e0541ee0/1013'; //Web_Build
$_CONFIG['hotel']['external_vars'] = 'http://localhost/r63/external_variables.txt'; //URL to your external vars
$_CONFIG['hotel']['external_texts'] = 'http://localhost/r63/external_flash_texts.txt'; //URL to your external texts
$_CONFIG['hotel']['product_data'] = 'http://localhost/r63/productdata.txt'; //URL to your productdata
$_CONFIG['hotel']['furni_data'] = 'http://localhost/r63/furnidata.txt'; //URL to your furnidata
$_CONFIG['hotel']['swf_folder'] = 'http://localhost/r63'; //URL to your SWF folder(does not end with a '/')
/*
*
* Templating management - Pick one of our default styles or make yours by following our examples!
*
*/
#RevCMS has 2 default styles, 'Mango' by dannyy94 and 'Priv' by joopie - Others styles are to come, such as RastaLulz's ProCMS style and Nominal's PhoenixCMS 4.0 style.
$_CONFIG['template']['style'] = 'DahT3H';
/*
*
* Other topsites.. thing
*
*/
$_CONFIG['thehabbos']['username'] = 'Jynx';
$_CONFIG['retro_top']['user'] = 'Jynx';
/*
*
* Recaptcha management - Fill the information below if you have one, else leave it like that and don't worry, be happy.
*
*/
$_CONFIG['recaptcha']['priv_key'] = '6LcZ58USAAAAABSV5px9XZlzvIPaBOGA6rQP2G43';
$_CONFIG['recaptcha']['pub_key'] = '6LcZ58USAAAAAAQ6kquItHl4JuTBWs-5cSKzh6DD';
/*
*
* Social Networking stuff
*
*/
$_CONFIG['social']['twitter'] = 'TwitterAccount'; //Hotel's Twitter account
$_CONFIG['social']['facebook'] = 'FacebookAccount'; //Hotel's Facebook account
?>
I don't understand, I even asked for help from them, they told me to change the password, I did that but there was no change!

Using json API pull to store in file or database

I am trying to pull data from the justin.tv API and store the echo I get in the below code in to a database or a file to be included in the sidebar of website. I am not sure on how to do this. The example of what I am trying to achieve is the live streamers list on the sidebar of teamliquid.net. Which I have done but doing it the way I have done it slows the site way down because it does about 50 json requests every time the page loads. I just need to get this in to a cached file that updates every 60 seconds or so. Any ideas?
<?php
$json_file = file_get_contents("http://api.justin.tv/api/stream/list.json?channel=colcatz");
$json_array = json_decode($json_file, true);
if ($json_array[0]['name'] == 'live_user_colcatz') echo 'coL.CatZ Live<br>';
$json_file = file_get_contents("http://api.justin.tv/api/stream/list.json?channel=coldrewbie");
$json_array = json_decode($json_file, true);
if ($json_array[0]['name'] == 'live_user_coldrewbie') echo 'coL.drewbie Live<br>';
?>
I'm not entirely sure how you would imagine this being cached, but the code below is an adaption of a block of code I've used in the past for some Twitter work. There are a few things that could probably be done better from a security perspective. Anyway, this gives you a generic way of grabbing the Feed, parsing through it, and then sending it to the database.
Warning: This assumes that there is a database connection already established within your own system.
(* Make sure you scroll to the bottom of the code window *)
/**
* Class SM
*
* Define a generic wrapper class with some system
* wide functionality. In this case we'll give it
* the ability to fetch a social media feed from
* another server for parsing and possibly caching.
*
*/
class SM {
private $api, $init, $url;
public function fetch_page_contents ($url) {
$init = curl_init();
try {
curl_setopt($init, CURLOPT_URL, $url);
curl_setopt($init, CURLOPT_HEADER, 0);
curl_setopt($init, CURLOPT_RETURNTRANSFER, 1);
} catch (Exception $e) {
error_log($e->getMessage());
}
$output = curl_exec($init);
curl_close($init);
return $output;
}
}
/**
* Class JustinTV
*
* Define a specific site wrapper for getting the
* timeline for a specific user from the JustinTV
* website. Optionally you can return the code as
* a JSON string or as a decoded PHP array with the
* $api_decode argument in the get_timeline function.
*
*/
class JustinTV extends SM {
private $timeline_document,
$api_user,
$api_format,
$api_url;
public function get_timeline ($api_user, $api_decode = 1, $api_format = 'json', $api_url = 'http://api.justin.tv/api/stream/list') {
$timeline_document = $api_url . '.' . $api_format . '?channel=' . $api_user;
$SM_init = new SM();
$decoded_json = json_decode($SM_init->fetch_page_contents($timeline_document));
// Make sure that our JSON is really JSON
if ($decoded_json === null && json_last_error() !== JSON_ERROR_NONE) {
error_log('Badly formed, dangerous, or altered JSON string detected. Exiting program.');
}
if ($api_decode == 1) {
return $decoded_json;
}
return $SM_init->fetch_page_contents($timeline_document);
}
}
/**
* Instantiation of the class
*
* Instantiate our JustinTV class, fetch a user timeline
* from JustinTV for the user colcatz. The loop through
* the results and enter each of the individual results
* into a database table called cache_sm_justintv.
*
*/
$SM_JustinTV = new JustinTV();
$user_timeline = $SM_JustinTV->get_timeline('colcatz');
foreach ($user_timeline AS $entry) {
// Here you could check whether the entry already exists in the system before you cache it, thus reducing duplicate ID's
$date = date('U');
$query = sprintf("INSERT INTO `cache_sm_justintv` (`id`, `cache_content`, `date`) VALUES (%d, '%s', )", $entry->id, $entry, $date);
$result = mysql_query($query);
// Do some other stuff and then close the MySQL Connection when your done
}