PHP Web Host - Quality Web Hosting For All PHP Applications $35/month $250/year (Unlimited) - $25/month - 200,000 impressions - Your Ad Could be Here - Click For Details
  Login or Register
 • Home • Downloads • Your Account • Forums • 

View next topic
View previous topic


Google
 
Web RavenPHPScripts (This Site)
Post new topic   Reply to topic
Author Message
unicornio
Involved
Involved


Joined: Aug 13, 2009
Posts: 432

PostPosted: Wed Jan 13, 2010 9:06 am Reply with quote Back to top

I do know RavenNuke removed that option but I suggest to put it back again based on this example. I worked on this one and it worked properly with the last version.

Code:
<?php



if (!defined('ADMIN_FILE')) { die ("Access Denied"); }

global $prefix, $db, $admin_file;
$aid = substr("$aid", 0,25);
$row = $db->sql_fetchrow($db->sql_query("SELECT radminsuper FROM " . $prefix . "_authors WHERE aid='$aid'"));
if ($row['radminsuper'] == 1) {

   switch($op) {

      case "backup":
      @set_time_limit(600);
      $crlf="\n";

      switch($lang)
      {
         case french :
         // French Text
         $strNoTablesFound   = "Aucune table n'a été trouvée dans cette base.";
         $strHost      = "Serveur";
         $strDatabase      = "Base de données";
         $strTableStructure   = "Structure de la table";
         $strDumpingData      = "Contenu de la table";
         $strError      = "Erreur";
         $strSQLQuery      = "requête SQL";
         $strMySQLSaid      = "MySQL a répondu:";
         $strBack      = "Retour";
         $strFileName      = "Sauvegarde BD";
         $strName      = "Sauvegarde de la base de données";
         $strDone      = "effectuée le";
         $strat         = "à";
         $strby         = "par";
         $date_jour = date ("d-m-Y");
         break;

         default :
         // English Text
         $strNoTablesFound = "No tables found in database.";
         $strHost = "Host";
         $strDatabase = "Database ";
         $strTableStructure = "Table structure for table";
         $strDumpingData = "Dumping data for table";
         $strError = "Error";
         $strSQLQuery = "SQL-query";
         $strMySQLSaid = "MySQL said: ";
         $strBack = "Back";
         $strFileName = "Save Database";
         $strName = "Database saved";
         $strDone = "On";
         $strat = "at";
         $strby = "by";
         $date_jour = date ("m-d-Y");
         break;
      }

      header("Content-disposition: filename=$strFileName $dbname $date_jour.sql");
      header("Content-type: application/octetstream");
      header("Pragma: no-cache");
      header("Expires: 0");


      $client = $_SERVER["HTTP_USER_AGENT"];
      if(ereg('[^(]*\((.*)\)[^)]*',$client,$regs))
      {
         $os = $regs[1];
         if (eregi("Win",$os))
         $crlf="\r\n";
      }


      function my_handler($sql_insert)
      {
         global $crlf;
         echo "$sql_insert;$crlf";
      }

      function get_table_content($db, $table, $handler)
      {
         $result = mysql_db_query($db, "SELECT * FROM $table") or mysql_die();
         $i = 0;
         while($row = mysql_fetch_row($result))
         {
            $table_list = "(";

            for($j=0; $j<mysql_num_fields($result);$j++)
            $table_list .= mysql_field_name($result,$j).", ";

            $table_list = substr($table_list,0,-2);
            $table_list .= ")";

            if(isset($GLOBALS["showcolumns"]))
            $schema_insert = "INSERT INTO $table $table_list VALUES (";
            else
            $schema_insert = "INSERT INTO $table VALUES (";

            for($j=0; $j<mysql_num_fields($result);$j++)
            {
               if(!isset($row[$j]))
               $schema_insert .= " NULL,";
               elseif($row[$j] != "")
               $schema_insert .= " '".addslashes($row[$j])."',";
               else
               $schema_insert .= " '',";
            }
            $schema_insert = ereg_replace(",$", "", $schema_insert);
            $schema_insert .= ")";
            $handler(trim($schema_insert));
            $i++;
         }
         return (true);
      }


      function get_table_def($db, $table, $crlf)
      {
         $schema_create = "";
         $schema_create .= "CREATE TABLE $table ($crlf";

         $result = mysql_db_query($db, "SHOW FIELDS FROM $table") or mysql_die();
         while($row = mysql_fetch_array($result))
         {
            $schema_create .= "   $row[Field] $row[Type]";

            if(isset($row["Default"]) && (!empty($row["Default"]) || $row["Default"] == "0"))
            $schema_create .= " DEFAULT '$row[Default]'";
            if($row["Null"] != "YES")
            $schema_create .= " NOT NULL";
            if($row["Extra"] != "")
            $schema_create .= " $row[Extra]";
            $schema_create .= ",$crlf";
         }
         $schema_create = ereg_replace(",".$crlf."$", "", $schema_create);
         $result = mysql_db_query($db, "SHOW KEYS FROM $table") or mysql_die();
         while($row = mysql_fetch_array($result))
         {
            $kname=$row['Key_name'];
            if(($kname != "PRIMARY") && ($row['Non_unique'] == 0))
            $kname="UNIQUE|$kname";
            if(!isset($index[$kname]))
            $index[$kname] = array();
            $index[$kname][] = $row['Column_name'];
         }

         while(list($x, $columns) = @each($index))
         {
            $schema_create .= ",$crlf";
            if($x == "PRIMARY")
            $schema_create .= "   PRIMARY KEY (" . implode($columns, ", ") . ")";
            elseif (substr($x,0,6) == "UNIQUE")
            $schema_create .= "   UNIQUE ".substr($x,7)." (" . implode($columns, ", ") . ")";
            else
            $schema_create .= "   KEY $x (" . implode($columns, ", ") . ")";
         }

         $schema_create .= "$crlf)";
         return (stripslashes($schema_create));
      }

      function mysql_die($error = "")
      {
         echo "<b> $strError </b><p>";
         if(isset($sql_query) && !empty($sql_query))
         {
            echo "$strSQLQuery: <pre>$sql_query</pre><p>";
         }
         if(empty($error))
         echo $strMySQLSaid.mysql_error();
         else
         echo $strMySQLSaid.$error;
         echo "<br><a href=\"javascript:history.go(-1)\">$strBack</a>";
         exit;
      }

      global $dbhost, $dbuname, $dbpass, $dbname;
      mysql_pconnect($dbhost, $dbuname, $dbpass);
      @mysql_select_db("$dbname") or die ("Unable to select database");

      $tables = mysql_list_tables($dbname);

      $num_tables = @mysql_numrows($tables);
      if($num_tables == 0)
      {
         echo $strNoTablesFound;
      }
      else
      {
         $i = 0;
         $heure_jour = date ("H:i");
         print "# ========================================================$crlf";
         print "#$crlf";
         print "# $strName : $dbname$crlf";
         print "# $strDone $date_jour $strat $heure_jour $strby $name !$crlf";
         print "#$crlf";
         print "# ========================================================$crlf";
         print "$crlf";

         while($i < $num_tables)
         {
            $table = mysql_tablename($tables, $i);

            print $crlf;
            print "# --------------------------------------------------------$crlf";
            print "#$crlf";
            print "# $strTableStructure '$table'$crlf";
            print "#$crlf";
            print $crlf;

            echo get_table_def($dbname, $table, $crlf).";$crlf$crlf";

            print "#$crlf";
            print "# $strDumpingData '$table'$crlf";
            print "#$crlf";
            print $crlf;

            get_table_content($dbname, $table, "my_handler");

            $i++;
         }
      }
      break;
   }

} else {
   echo "Access Denied";
}

?>
View user's profile Send private message
unicornio
Involved
Involved


Joined: Aug 13, 2009
Posts: 432

PostPosted: Wed Jan 13, 2010 9:08 am Reply with quote Back to top

I suggest to make a powerful secure script to bring this option back again. What do you think about it?
View user's profile Send private message
jakec
Site Admin


Joined: Feb 06, 2006
Posts: 3038
Location: United Kingdom

PostPosted: Wed Jan 13, 2010 9:16 am Reply with quote Back to top

Is there really any need?

It possible to do it by many other methods, such as through cPanel, or using something like BigDump.
View user's profile Send private message
unicornio
Involved
Involved


Joined: Aug 13, 2009
Posts: 432

PostPosted: Wed Jan 13, 2010 3:48 pm Reply with quote Back to top

Yeah! I know what you mean but I dont want to get rid of that option. It could be very easy and if we take care of that file it could be protected and secure.
View user's profile Send private message
Palbin
Site Admin


Joined: Mar 30, 2006
Posts: 2456
Location: Pittsburgh, Pennsylvania

PostPosted: Wed Jan 13, 2010 4:05 pm Reply with quote Back to top

It has been disabled for a while now and with so many other things to do I don't see the dev team picking it up.
View user's profile Send private message
fkelly
Moderator


Joined: Aug 30, 2005
Posts: 3186
Location: near Albany NY

PostPosted: Fri Jan 15, 2010 4:09 pm Reply with quote Back to top

I had a hand in disabling it. There is an explanation of the reasoning built right into the ACP where the backup functions used to be. Basically, there is no reliable way to build a backup into PHP code considering the range of servers and capabilities people are running Ravennuke on. And there is just no way that we can duplicate MYSQL dump facilities as well as dump capabilities that are built into programs such as Cpanel.

Plus to me at least it is dangerous and a bad practice to offer a capability that we know won't work in many cases. A new admin could come in and say, "Oh I've got a backup right in RN" and rely on it and when the chips are down their system is screwed up cause it doesn't work.

Even with Cpanel backup capabilities (or similar ones on other hosts) I'd bet that the vast majority of RN systems could not be fully restored in the event of a catastrophic crash. Do you know exactly when the last dump for your system was run? Are the program files and MYSQL databases necessarily in synch? What about updates that took place since the last dump? Do you know exactly how you'd go about restoring the files ... hint if you don't have Bigdump or the equivalent all set up you ain't got a chance. Have you tested your procedures? Has anything major changed since you ran your tests?
View user's profile Send private message Visit poster's website
bigbadjames
New Member
New Member


Joined: Jun 22, 2008
Posts: 24
Location: USA

PostPosted: Fri Jan 29, 2010 8:48 am Reply with quote Back to top

It takes me no more than a minute to log into cPanel and do a database backup. It's easy and secure. The admin version is unnecessary and unreliable.
View user's profile Send private message Visit poster's website
unicornio
Involved
Involved


Joined: Aug 13, 2009
Posts: 432

PostPosted: Fri Jan 29, 2010 12:43 pm Reply with quote Back to top

Ok! I got the point and I agree with all of you. I will remove that addon then.
View user's profile Send private message
bigbadjames
New Member
New Member


Joined: Jun 22, 2008
Posts: 24
Location: USA

PostPosted: Fri Jan 29, 2010 5:59 pm Reply with quote Back to top

unicornio wrote:
Ok! I got the point and I agree with all of you. I will remove that addon then.


ahhh, the sweet sound of peer pressure, lol.
View user's profile Send private message Visit poster's website
Display posts from previous:       
Post new topic   Reply to topic

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Forums ©
 

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2002-2011 by Raven

You can syndicate our news using the file xml

CSE HTML Validator Helped Clean up This Page! [Valid RSS] valid RSS 2.0 Valid robots.txt Stop Spam Harvesters, Join Project Honey Pot

Website engines core code is © copyright by PHP-Nuke but has been heavily patched and modified by myself and others.
PHP-Nuke is a free software released under the GNU/GPL.


:: fisubice phpbb2 style by Daz :: PHP-Nuke theme by www.nukemods.com ::
:: fisubice Theme Modified by the RavenNuke™ Team ::

:: W3C CSS Compliance Validation :: W3C HTML 4.01 Transitional Compliance Validation ::

zerosum