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

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!

Related

How to search registered user on ejabberd server from client side using smack library?

I am using smack on the client-side. I tried to search registered users on the client-side because before creating a new user I want to know that the id is registered on server or not if not then create the user either log in the user but ejabberd server crashed with the error. Here are the crash logs of ejabberd server.
Failed to process iq:
#iq{
id = <<"Hh6AJ-28">>,type = set,lang = <<"en">>,
from =
#jid{
user = <<"admin">>,server = <<"faiqkhan-virtualbox">>,
resource = <<"92526029764259513741138">>,luser = <<"admin">>,
lserver = <<"faiqkhan-virtualbox">>,
lresource = <<"92526029764259513741138">>},
to =
#jid{
user = <<>>,server = <<"vjud.faiqkhan-virtualbox">>,resource = <<>>,
luser = <<>>,lserver = <<"vjud.faiqkhan-virtualbox">>,lresource = <<>>},
sub_els =
[#xmlel{
name = <<"query">>,
attrs = [{<<"xmlns">>,<<"jabber:iq:search">>}],
children =
[#xmlel{
name = <<"x">>,
attrs = [{<<"xmlns">>,<<"jabber:x:data">>},{<<"type">>,<<"submit">>}],
children =
[#xmlel{
name = <<"field">>,
attrs = [{<<"var">>,<<"user">>},{<<"type">>,<<"text-single">>}],
children =
[#xmlel{
name = <<"value">>,attrs = [],
children = [{xmlcdata,<<"wasiq#faiqkhan-virtualbox">>}]}]}]}]}],
meta = #{ip => {0,0,0,0,0,65535,49320,11092}}}
exception error: {module_not_loaded,mod_vcard_mnesia,
<<"faiqkhan-virtualbox">>}
in function gen_mod:get_module_opts/2 (src/gen_mod.erl, line 338)
in call from gen_mod:get_module_opt/3 (src/gen_mod.erl, line 318)
in call from mod_vcard_mnesia:filter_fields/3 (src/mod_vcard_mnesia.erl, line 200)
in call from mod_vcard_mnesia:search/4 (src/mod_vcard_mnesia.erl, line 78)
in call from mod_vcard:search_result/4 (src/mod_vcard.erl, line 479)
in call from mod_vcard:process_search/1 (src/mod_vcard.erl, line 264)
in call from gen_iq_handler:process_iq/3 (src/gen_iq_handler.erl, line 131)
in call from gen_iq_handler:process_iq/4 (src/gen_iq_handler.erl, line 109)
I used the following code to get a registered user from the client-side:
InetAddress address = InetAddress.getByName(HOST);
DomainBareJid serviceName = JidCreate.domainBareFrom("faiqkhan-VirtualBox"); XMPPTCPConnectionConfiguration.Builder builder = XMPPTCPConnectionConfiguration.builder();
builder.setPort(PORT);
builder.setSendPresence(true);
builder.setHostAddress(address);
builder.setServiceName(serviceName);
builder.setUsernameAndPassword("admin", "123456");
builder.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
XMPPTCPConnection connection = new XMPPTCPConnection(builder.build());
try {
connection.connect();
connection.login("admin", "123456");
Logger.showError("21560-connection created to: " + connection.getHost());
Roster roster = Roster.getInstanceFor(connection);
Set<RosterEntry> entities = roster.getEntries();
UserSearchManager search = new UserSearchManager(connection);
DomainBareJid s = JidCreate.domainBareFrom("vjud.".concat("faiqkhan-VirtualBox"));
Form searchForm = search.getSearchForm(s);
Form answerForm = searchForm.createAnswerForm();
answerForm.setAnswer("user", "wasiq#faiqkhan-virtualbox");
ReportedData data = search.getSearchResults(answerForm, s);
if (data.getRows() != null) {
for (ReportedData.Row row : data.getRows()) {
for (CharSequence value : row.getValues("jid")) {
Log.i("Iteartor values......", " " + value);
}
}
}
} catch (SmackException | IOException | XMPPException | InterruptedException e) {
Logger.showError("21560-error on account creation: " + e.getMessage());
}
Server crashed on ReportedData data = search.getSearchResults(answerForm, s); line of code.
You found a bug in ejabberd:
It was already fixed in 2018 in
https://github.com/processone/ejabberd/commit/1be21126342d503205798605725ba5ceef9de42b
but the bug got reintroduced in 2019 in
https://github.com/processone/ejabberd/commit/a02cff0e780bb735531594c4ece81e8628f79782#diff-71f613241ed580c3e5dad2b4526503f2R12
and I've now applied a temporary fix in
https://github.com/processone/ejabberd/commit/92913389a51ddc564f11e0712b0d82fca8c9aecb
But even if that bug is fixed, the feature you want to use probably doesn't help: a user must set his vCard in order for his account to be provided in vJud search. In other words, vJUD searches in stored vCards, not in registered accounts. If I register an account but don't set a vCard, then vJUD will not find it.
before creating a new user I want to know that the id is registered on server or not
And why don't you simply attempt to register the account first?
On the other hand, if you would like to check in advance if an account is available for registration or not (like some web registration sites do, to allow the user modify the username until one is available), then I think XMPP doesn't provide that possibility for security reasons: it is not allowed to know if an account exists or not.
A solution for that would be to use the check_account ejabberd command
https://docs.ejabberd.im/developer/ejabberd-api/admin-api/#check-account
executing it with some frontend, like ejabberdctl, ReST or XMLRPC
https://docs.ejabberd.im/admin/guide/managing/#ejabberd-commands
$ ejabberdctl check_account user1 localhost
$ ejabberdctl check_account user6666 localhost
Error: false
~ 1

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 .... :')

PHPMyAdmin Database connection errors

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

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();
}
}

Facebook login page and cache

I've got a Facebook login in my website
but I need to request permission to post in my user's wall.
I found many many examples on google that use the scope, but they're too different form mine, and I don't understand where to put it
This is the code:
<?php
session_start();
// added in v4.0.0
require_once 'autoload.php';
require 'functions.php';
use Facebook\FacebookSession;
use Facebook\FacebookRedirectLoginHelper;
use Facebook\FacebookRequest;
use Facebook\FacebookResponse;
use Facebook\FacebookSDKException;
use Facebook\FacebookRequestException;
use Facebook\FacebookAuthorizationException;
use Facebook\GraphObject;
use Facebook\Entities\AccessToken;
use Facebook\HttpClients\FacebookCurlHttpClient;
use Facebook\HttpClients\FacebookHttpable;
// init app with app id and secret
FacebookSession::setDefaultApplication( 'APPID','APPSECURE' );
// login helper with redirect_uri
$helper = new FacebookRedirectLoginHelper('http://www.bestparty.altervista.org/APP/facebook/fbconfig.php' );
try {
$session = $helper->getSessionFromRedirect();
} catch( FacebookRequestException $ex ) {
// When Facebook returns an error
} catch( Exception $ex ) {
// When validation fails or other local issues
}
// see if we have a session
if ( isset( $session ) ) {
// graph api request for user data
$request = new FacebookRequest( $session, 'GET', '/me' );
$response = $request->execute();
// get response
$graphObject = $response->getGraphObject();
$fbid = $graphObject->getProperty('id'); // To Get Facebook ID
$fbfullname = $graphObject->getProperty('name'); // To Get Facebook full name
$femail = $graphObject->getProperty('email');
/* ---- Session Variables -----*/
$_SESSION['FBID'] = $fbid;
$_SESSION['FULLNAME'] = $fbfullname;
$_SESSION['EMAIL'] = $femail;
checkuser($fbid,$fbfullname,$femail);
/* ---- header location after session ----*/
$cookie_name = 'FBID';
$cookie_value = $fbid;
setcookie($cookie_name, $cookie_value, time() + (86400 * 30), '/');
$cookie_name2 = 'FULLNAME';
$cookie_value2 = $fbfullname;
setcookie($cookie_name2, $cookie_value2, time() + (86400 * 30), '/');
header("Location: ../gestaccount.php");
} else {
$cookie_name = 'FBID';
$cookie_value = $fbid;
setcookie($cookie_name, $cookie_value, time() + (86400 * 30), '/');
$loginUrl = $helper->getLoginUrl();
header("Location: ".$loginUrl);
}
?>
Also:
May I save the access token in mysql to use it in future?
Why does the datas that I save in cache stays only until I close the browser?
1, You can store the access token however which way you like. As long as it's secure and you are able to update them in case of expired/updated/extended access tokens, it should be fine.
2, This is a bit unclear, are you setting and handling cookies correctly ?