yum --enablerepo=remi install php-mbstring
Wednesday, 20 April 2016
Monday, 11 April 2016
Monday, 4 April 2016
Install uTorrent Server 3.3
Step 1: Download latest uTorrent Server from here
Note: (You need to download uTorrent Server for 13.04, also works for Ubuntu 14.04)
Step 2: Extract uTorrent Files
- Launch terminal (with Ctrl+Alt+T or search Terminal in dash and click to open it)Change directory to Downloads folder
cd ~/Downloads/
- Extract uTorrent files to the /opt directory
sudo tar -xvzf utserver.tar.gz -C /opt/
Step 3: Set Permission
- Set permission on uTorrent-server folder
sudo chmod -R 755 /opt/utorrent-server-alpha-v3_3/
Step 4: Set Symbolic link
- Run the command to link uTorrent server to the /user/bin directory.
sudo ln -s /opt/utorrent-server-alpha-v3_3/utserver /usr/bin/utserver
Step 5: Start uTorrent
- Run the following command in the Terminal
utserver -settingspath /opt/utorrent-server-alpha-v3_3/
Note: If you get an error about
libssl.so
package missing, then- Run the command below to install it:
sudo apt-get install libssl0.9.8:i386
then try starting it again.
Step 6: Log into uTorrent
- Open Firefox/Chrome and browse to the URL
localhost:8080/gui
- The username is admin and leave the password field empty
Friday, 1 April 2016
Database Backup PHP Script
<?php
backup_tables('localhost','username','password', 'database-name','*');
/* backup the db OR just a table */
function backup_tables($host,$user,$pass,$name,$tables = '*')
{
$link = mysql_connect($host, $user, $pass);
mysql_select_db($name,$link);
//get all of the tables
if($tables == '*')
{
$tables = array();
$result = mysql_query('SHOW TABLES');
while($row = mysql_fetch_row($result))
{
$tables[] = $row[0];
}
}
else
{
$tables = is_array($tables) ? $tables : explode(',',$tables);
}
//cycle through
foreach($tables as $table)
{
$result = mysql_query('SELECT * FROM '.$table);
$num_fields = mysql_num_fields($result);
$return.= 'DROP TABLE IF EXISTS '.$table.';';
$row2 = mysql_fetch_row(mysql_query('SHOW CREATE TABLE '.$table));
$return.= "\n\n".$row2[1].";\n\n";
for ($i = 0; $i < $num_fields; $i++)
{
while($row = mysql_fetch_row($result))
{
$return.= 'INSERT INTO '.$table.' VALUES(';
for($j=0; $j<$num_fields; $j++)
{
$row[$j] = addslashes($row[$j]);
$row[$j] = ereg_replace("\n","\\n",$row[$j]);
if (isset($row[$j])) { $return.= '"'.$row[$j].'"' ; } else { $return.= '""'; }
if ($j<($num_fields-1)) { $return.= ','; }
}
$return.= ");\n";
}
}
$return.="\n\n\n";
}
//save file
$filename = 'db-backup-'.date('Y-m-d-H-i-s').'.sql';
$handle = fopen('../public/backup/'.$filename,'w+');
fwrite($handle,$return);
fclose($handle);
}
?>
backup_tables('localhost','username','password', 'database-name','*');
/* backup the db OR just a table */
function backup_tables($host,$user,$pass,$name,$tables = '*')
{
$link = mysql_connect($host, $user, $pass);
mysql_select_db($name,$link);
//get all of the tables
if($tables == '*')
{
$tables = array();
$result = mysql_query('SHOW TABLES');
while($row = mysql_fetch_row($result))
{
$tables[] = $row[0];
}
}
else
{
$tables = is_array($tables) ? $tables : explode(',',$tables);
}
//cycle through
foreach($tables as $table)
{
$result = mysql_query('SELECT * FROM '.$table);
$num_fields = mysql_num_fields($result);
$return.= 'DROP TABLE IF EXISTS '.$table.';';
$row2 = mysql_fetch_row(mysql_query('SHOW CREATE TABLE '.$table));
$return.= "\n\n".$row2[1].";\n\n";
for ($i = 0; $i < $num_fields; $i++)
{
while($row = mysql_fetch_row($result))
{
$return.= 'INSERT INTO '.$table.' VALUES(';
for($j=0; $j<$num_fields; $j++)
{
$row[$j] = addslashes($row[$j]);
$row[$j] = ereg_replace("\n","\\n",$row[$j]);
if (isset($row[$j])) { $return.= '"'.$row[$j].'"' ; } else { $return.= '""'; }
if ($j<($num_fields-1)) { $return.= ','; }
}
$return.= ");\n";
}
}
$return.="\n\n\n";
}
//save file
$filename = 'db-backup-'.date('Y-m-d-H-i-s').'.sql';
$handle = fopen('../public/backup/'.$filename,'w+');
fwrite($handle,$return);
fclose($handle);
}
?>
Subscribe to:
Posts (Atom)