Browse Month: April 2014

Roles and permissions of user in wordpress

WordPress is a free and open source blogging tool and a content management system (CMS) based on PHP and MySQL, which runs on a web hosting service.

WordPress is the most popular blogging system in use on the Web, at more than 60 million websites. WordPress having a set of User groups roles and permission. They are

  1. Super Admin – somebody with access to the site network administration features and all other features. See the Create a Network article.
  2. Administrator – somebody who has access to all the administration features within a single site.
  3. Editor – somebody who can publish and manage posts including the posts of other users.
  4. Author – somebody who can publish and manage their own posts.
  5. Contributor – somebody who can write and manage their own posts but cannot publish them.
  6. Subscriber – somebody who can only manage their profile.

A Business Tryst With Australia

Since the advent of Nanostuffs in October 2010, we had been already working with many SME & Enterprise customers from Australia. We have realised it definitely helps when a face is put to a name & thats why we finally planned out a much awaiting & looking forward trip to a promising land of opportunities, Australia.

After a planning of 2 months, we spent entire April 2014 at Sydney & Melbourne meeting almost 50+ companies & individuals sharing our experiences so far & discussing any new opportunities we can work on together. Some of the most notable meetings included:

  • Buzz Products, an existing customer of Nanostuffs for whom we have already created 10+ mobile apps & provided other services in web & cloud space.
  • McCorkell.com.au, one of the best Event Management company in Australia for whom again we have worked on several apps, Salesforce & Eloqua related projects. This was a new customer & we are really grateful for their trust & believe on our capabilities based on a meetings of just few hours.
  • OurDeal.com.au, they call it the GroupOn of Australia. We assist them on Salesforce.com developments & support.
  • AMEX, Having already worked with AMEX USA it was great to start a relationship with their Australian base as well.
  • Universal Music Australia, one of the best benefits of the trip had been to become a Salesforce solution vendor for this amazing worldwide known organization.

MySQL Database Backup Using PHP

If your site is live and using Database then it is very important to take backup of you Database in regular time interval. But it is not possible to take the backup manually every time. So lets create a simple PHP function to do this job for us and we can call that function using Cron Job in regular time interval.

Here is the sample of php code

<?php
include("config.php");
function backup_db(){
/* Store All Table name in an Array */
$allTables = array();
$result = mysql_query('SHOW TABLES');
while($row = mysql_fetch_row($result)){
     $allTables[] = $row[0];
}

foreach($allTables 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.= "nn".$row2[1].";nn";

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] = str_replace("n","\n",$row[$j]);
       if (isset($row[$j])) { $return.= '"'.$row[$j].'"' ; }
       else { $return.= '""'; }
       if ($j<($num_fields-1)) { $return.= ','; }
     }
   $return.= ");n";
}
}
$return.="nn";
}

//Generate Backup Folder
$folder = 'DB_Backup/';
if (!is_dir($folder))
mkdir($folder, 0777, true);
chmod($folder, 0777);

$date = date('m-d-Y-H-i-s', time());
$filename = $folder."db-backup-".$date; 

$handle = fopen($filename.'.sql','w+');
fwrite($handle,$return);
fclose($handle);
}

// Call the function
backup_db();
?>

config.php file
<?php
  $host="hostname";
  $uname="uname";
  $pass="password";
  $database = "databasename";
$connection=mysql_connect($host,$uname,$pass);
or die("Database Connection Failed");
$selectdb=mysql_select_db($database) or die("Database could not be selected");
$result=mysql_select_db($database)
or die("database cannot be selected <br>");
?>

Save the above code in a PHP file and upload the file to your web server
then run the file. And check if it create a folder called DB_Backup  and
create the backup .sql  file  inside DB_Backup folder. If the file  works
fine then  you can assign the file to your Cron Job.