Quantcast
Channel: phpBB.com
Viewing all articles
Browse latest Browse all 2880

phpBB Custom Coding • PHP script to execute custom MYSQL commands on PHPBB db?

$
0
0
Hello,

i am able to add filename.sh and set it as executable 744 and set crojob: $HOME/filename.sh
and inside the file is:

Code:

mysql --database=dbhere --user=userhere -ppasshere --execute="UPDATE phpbb_privmsgs SET author_ip = '127.0.0.1' where author_ip <> '127.0.0.1';"mysql --database=dbhere --user=userhere -ppasshere --execute="UPDATE phpbb_sessions SET session_ip = '127.0.0.1' where session_ip <> '127.0.0.1';"
and it works, yet it reports
mysql: [Warning] Using a password on the command line interface can be insecure.
filename.sh needs to be outside of the publicly accessible path, for example in account root (to prevent download by unwanted party).

So I would like to use PHP file instead. Please can you mention what should be the content of that php file in order to work?

As a layman I came up with following, but it does not seem to be modifying database, returning no error though.

Code:

<?php/**** @package phpBB3* @version $Id: cron.php 8479 2008-03-29 00:22:48Z naderman $* @copyright (c) 2005 phpBB Group* @license http://opensource.org/licenses/gpl-license.php GNU Public License**/error_reporting("E_ALL");/***/define('IN_PHPBB', true);define('IN_CRON', true);$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';$phpEx = substr(strrchr(__FILE__, '.'), 1);include($phpbb_root_path . 'common.' . $phpEx);{global $db;$sql = 'UPDATE phpbb_privmsgs SET author_ip = '127.0.0.1' where author_ip <> '127.0.0.1';';$sql2 = 'UPDATE phpbb_sessions SET session_ip = '127.0.0.1' where session_ip <> '127.0.0.1';';$db->sql_query($sql);$db->sql_query($sql2);}?>

Statistics: Posted by postcd — Thu Dec 14, 2023 1:24 pm



Viewing all articles
Browse latest Browse all 2880

Trending Articles