Update ip of wordpress in ksweb webserver

If you need a wordpress blog locally on phone,
you could install ksweb on android.

But you phone have a different ip each wireless, then wordpress don’t work because he use absolute path.

you need change ip before using the blog.

You could make a php file that change ip.

<?php
define( 'DB_HOST', 'localhost' );
define( 'DB_USER', 'blog_user' );
define( 'DB_PASSWORD', 'blog_pass');
define( 'DB_NAME', 'blog' );

$i=$_GET['i'];
//connessione al db
$conn_id = @mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die ('KO|500|Internal Server Error');
@mysql_select_db(DB_NAME, $conn_id) or die ('KO|500|Internal Server Error');
// @mysql_query("SET NAMES '".DB_CHARSET."'", $conn_id) or die ('KO|500|Internal Server Error');
 
$query = "update wp_options set option_value='".$i."' where option_id = 1;";
 mysql_query($query, $conn_id);
 
$query = "update wp_options set option_value='".$i."' where option_id = 2;";
 mysql_query($query, $conn_id);
?>

run script before launch blog with:

http://localhost/script.php?i=192.168.0.100

see next post for launch it with tasker

Script backup mysql e upload su cloud per cron job

Questo script server per effettuare un backup di diversi database contemporaneamente,

  • crea i backup
  • li comprime
  • li cripta
  • li uploada su dropbox
  • crea un file di log
  • Manda una email per conferma
# Back Up Mysql Database
#!/bin/bash
DB_USER=backup_user # USERNAME dell'utente di backup di mysql
DB_PASS=XXXXXXXXXXX# Password
DB_NAME="db1 db2 ... dbn" # Nomi Database
BK_DIR0=/var/www/backup/mysql # Directory Backup principale
BK_DIR=/var/www/backup/mysql/giornaliero # Directory Backup del backup giornaliero
timestamp=$(date +%Y%m%d%H%M%S) #data
cd /var/www/backup/mysql/giornaliero
for db in $DB_NAME
do 
	mysqldump --quote-names --user=$DB_USER --password=$DB_PASS  $db> $BK_DIR/backup-$db-$timestamp.sql
	nomefile=backup-$db-$timestamp.sql;
	dimensione=$(du -sh $nomefile | awk '{print $1}')
	echo -e $timestamp " Backup giornaliero di "$db" fatto ("$dimensione")" >> $BK_DIR0/backup_mysql.log
	tar cvf - backup-$db-$timestamp.sql | bzip2 -9 | openssl enc -blowfish -salt -out backup-$db-$timestamp.sql.bz2.enc -k PASSWORD
	#tar -zvcf backup-$db-$timestamp.tar.gz backup-$db-$timestamp.sql
	rm backup-$db-$timestamp.sql
	/var/www/dropbox_uploader.sh upload /var/www/backup/mysql/giornaliero/backup-$db-$timestamp.sql.bz2.enc /backup/duck/backup-$db-$timestamp.sql.bz2.enc
done
echo $(date +%H:%M:%S) "(" $timestamp") Backup giornaliero di "$DB_NAME" eseguito e copiato su dropbox" | mail -s "MySql Backup report" -r robot@europclab.com claudio@europclab.com 

questo post deriva da:
Compressione e criptazione file da shell