Mensagens - jotix

Páginas: 1 ... 13 14 15 16 17
211
Não sei, não parece de confiança.

212
Gostaria de fazer backups automáticos de uma base de dados, e enviá-la como anexo para o email, de x em x tempo.

Para isso encontrei este script:

Código: [Seleccione]
<?php
  $dbhost        
'localhost';  // Server address of your MySQL Server

  
$dbuser        'usuario';      // Username to access MySQL database
  
$dbpass        'senha';    // Password to access MySQL database

  
$dbname        'nome do banco de dados';      // Database Name

  
$use_gzip      'yes';        // Set to No if you don't want the files sent in .gz format


  
$remove_file   'no';        // Set this to yes if you want to remove the file after sending. Yes is recommended.


  
$use_email     'yes';          // Set to 'yes' if you want the backup to be sent throug email. Fill out next 3 lines.

  
$send_to       'webmaster@site.com.br';   // E-mail to send the mail to

  
$send_from     'webmaster@site.com.br'// E-mail the mail comes from

  
$subject       "Backup do Banco de dados efetuado! - " date("j F Y"); // Subject in the email to be sent.


  
$use_ftp       'no'// Do you want this database backup uploaded to an ftp server? Fill out the next 4 lines
  
$ftp_server    '';   // FTP hostname

  
$ftp_user_name '';   // FTP username
  
$ftp_user_pass '';   // FTP password

  
$ftp_path      "/";  // This is the path to upload on your ftp server!

  
$echo_status 'no';   // Set to 'no' if the script should work silently (no output will be sent to the screen)



# You probably don't need to edit below this line....
#-------------------------------------------------------------------------------

  
$db mysql_connect("$dbhost","$dbuser","$dbpass");

        
mysql_select_db("$dbname",$db);

  
$path make_dir();
  
  if (
$echo_status == 'yes') {

    print 
"Dumpfile will be written to $path<br>";
  }

  
$result mysql_query("show tables from $dbname");

  while (list(
$table) = mysql_fetch_row($result)) {

    
$newfile .= get_def($table);
    
$newfile .= "\n\n";
    
$newfile .= get_content($table);

    
$newfile .= "\n\n";
    
$i++;
    if (
$echo_status == 'yes') {

      print 
"Dumped table $table<br>";
    }
  }

        
$file_name $dbname "-" date("Ymd-Hi") . ".sql";

        
$file_path $path $file_name;

  if (
$use_gzip == "yes") {

    
$file_name .= ".gz";
    
$file_path .= ".gz";
    
$zp gzopen($file_path"wb9");

    
gzwrite($zp,$newfile);
    
gzclose($zp);


    if (
$echo_status == 'yes') {
      print 
"<br>Gzip-file is created...<br>";

    }
  } else {
    
$fp fopen($file_path"w");

    
fwrite($fp$newfile);
    
fclose($fp);

    if (
$echo_status == 'yes') {

      print 
"<br>SQL-file is created...<br>";
    }
  }

  if (
$use_email == 'yes') {

    
$fileatt_type filetype($file_path);
  
    
$headers "From: $send_from";

  
    
// Read the file to be attached ('rb' = read binary)
    
$fp fopen($file_path,'rb');

    
$data fread($fp,filesize($file_path));
    
fclose($fp);

  
    
// Generate a boundary string
    
$semi_rand md5(time());
    
$mime_boundary "==Multipart_Boundary_x{$semi_rand}x";

  
    
// Add the headers for a file attachment
    
$headers .= "\nMIME-Version: 1.0\n" ."Content-Type: multipart/mixed;\n" ." boundary=\"{$mime_boundary}\"";

  
    
// Add a multipart boundary above the plain message
    
$message "This is a multi-part message in MIME format.\n\n" ."--{$mime_boundary}\n" ."Content-Type: text/plain; charset=\"iso-8859-1\"\n" ."Content-Transfer-Encoding: 7bit\n\n" .

    
$message "\n\n";
  
    
// Base64 encode the file data
    
$data chunk_split(base64_encode($data));

  
    
// Add file attachment to the message
    
$message .= "--{$mime_boundary}\n" ."Content-Type: {$fileatt_type};\n" ." name=\"{$file_name}\"\n" ."Content-Disposition: attachment;\n" ." filename=\"{$file_name}\"\n" ."Content-Transfer-Encoding: base64\n\n" .

    
$data "\n\n" ."--{$mime_boundary}--\n";
  
    
// Send the message
    
$ok = @mail($send_to$subject$message$headers);

    
    if (
$echo_status == 'yes') {
      print 
"<br>Mail is sent...<br>";

    }
  }
  
  if (
$use_ftp == 'yes') {

    if (
$use_gzip == 'yes') {
      
$mode FTP_BINARY;

    } else {
      
$mode FTP_ASCII;
    }
    
$ftp_id       ftp_connect($ftp_server);

    
$login_result ftp_login($ftp_id$ftp_user_name$ftp_user_pass);
    
$upload       ftp_put($ftp_id$ftp_path $file_name$file_path$mode);

    
ftp_close($ftp_id);

    if (
$echo_status == 'yes') {

      print 
"<br>Backup is uploaded to $ftp_user_name@$ftp_server...<br>";
    }
  }


  if (
$remove_file == "yes") {
    
unlink($file_name);

    if (
$echo_status == 'yes') {
      print 
"<br>File is deleted...<br>";

    }
  }

  if (
$echo_status == 'yes') {

    print 
"<br>I am done!<br>";
  }


  function 
make_dir() {

    
$page split("/"getenv('SCRIPT_NAME'));
    
$n count($page)-1;

    
$page $page[$n];
    
$page split("\."$page2);

    
$extension $page[1];
    
$page $page[0];
    
$script     "$page.$extension";

    
$base_url   "http://".$_SERVER['SERVER_NAME'];
    
$directory  $_SERVER['PHP_SELF'];

    
$url_base "$base_url$directory";
    
$url_base ereg_replace("$script"''"$_SERVER[PATH_TRANSLATED]");


    
$path $url_base;

    return 
$path;
  }

  function 
get_def($table) {

    
$def "";
    
$def .= "DROP TABLE IF EXISTS $table;\n";
    
$def .= "CREATE TABLE $table (\n";

    
$result mysql_query("SHOW FIELDS FROM $table") or die("Table $table not existing in database");

    while(
$row mysql_fetch_array($result)) {
      
$def .= "    $row[Field] $row[Type]";

      if (
$row["Default"] != ""$def .= " DEFAULT '$row[Default]'";

      if (
$row["Null"] != "YES"$def .= " NOT NULL";

      if (
$row[Extra] != ""$def .= $row[Extra]";

      
$def .= ",\n";
    }
    
$def ereg_replace(",\n$",""$def);

    
$result mysql_query("SHOW KEYS FROM $table");
    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)) {

      
$def .= ",\n";
      if(
$x == "PRIMARY"$def .= "   PRIMARY KEY (" implode($columns", ") . ")";

      else if (
substr($x,0,6) == "UNIQUE"$def .= "   UNIQUE ".substr($x,7)." (" implode($columns", ") . ")";

      else 
$def .= "   KEY $x (" implode($columns", ") . ")";

    }
    
$def .= "\n);";
    return (
stripslashes($def));

  }

  function 
get_content($table) {
    
$content="";

    
$result mysql_query("SELECT * FROM $table");
    while(
$row mysql_fetch_row($result)) {

      
$insert "INSERT INTO $table VALUES (";
      for(
$j=0$j<mysql_num_fields($result);$j++) {

        if(!isset(
$row[$j])) $insert .= "NULL,";

        else if(
$row[$j] != ""$insert .= "'".addslashes($row[$j])."',";

        else 
$insert .= "'',";
      }
      
$insert ereg_replace(",$","",$insert);

      
$insert .= ");\n";
      
$content .= $insert;
    }
    return 
$content;

  }
 
?>


Realmente ele envia um email com anexo, só que esse anexo não é nada.

E ao tentar executar o ficheiro php dá nisto:

Warning: fopen(zubux_bux-20080821-0707.sql) [function.fopen]: failed to open stream: Permission denied in /home/zubux/public_html/backup.php on line 63

Warning: fwrite(): supplied argument is not a valid stream resource in /home/zubux/public_html/backup.php on line 64

Warning: fclose(): supplied argument is not a valid stream resource in /home/zubux/public_html/backup.php on line 65

Warning: filetype() [function.filetype]: Lstat failed for zubux_bux-20080821-0707.sql in /home/zubux/public_html/backup.php on line 73

Warning: fopen(zubux_bux-20080821-0707.sql) [function.fopen]: failed to open stream: No such file or directory in /home/zubux/public_html/backup.php on line 78

Warning: filesize() [function.filesize]: stat failed for zubux_bux-20080821-0707.sql in /home/zubux/public_html/backup.php on line 79

Warning: fread(): supplied argument is not a valid stream resource in /home/zubux/public_html/backup.php on line 79

Warning: fclose(): supplied argument is not a valid stream resource in /home/zubux/public_html/backup.php on line 80

Warning: unlink(zubux_bux-20080821-0707.sql) [function.unlink]: No such file or directory in /home/zubux/public_html/backup.php on line 125

Já alterei as permissões do ficheiro para 777, e a situação permanece.

O que está errado?

213
Websites / Re: [VENDO] Jogodeapostas.com
« em: 21/Ago/2008 13:10 »

214
Websites / Re: [VENDO] Jogodeapostas.com
« em: 21/Ago/2008 13:07 »
Como não estou interessado em continuar com o jogodeapostas, desço o preço para 100€.

Quem quer?

215
Hosting / PTServidor Serviços de Internet
« em: 20/Ago/2008 01:52 »
Esperemos que não volte a acontecer tal ataque. :grin:

216
Projectos / Re: WebLouca.com
« em: 20/Ago/2008 01:46 »
Além do design, o que interessa é o conteúdo. Boa Sorte  :-P

217
Projectos / Re: DR-Clique.Com
« em: 19/Ago/2008 20:55 »
Uhm então esse é o teu ptc.

Boa Sorte  :grin:


Mas penso que esse já existia, ou não?

218
Projectos / Re: Zubux.com ~ Earn with ZuUu ~ by jotix
« em: 18/Ago/2008 18:55 »
Pagamentos de hoje:


219
Projectos / Re: Spot publicitário de acweb.biz
« em: 18/Ago/2008 00:21 »
Assim não fazes uma boa promoção.

Eu por exemplo, não vou estar a fazer o download do vídeo.

Deverias ir directo ao assunto e mostrar o site ou que for.

220
Projectos / Re: WebLouca.com
« em: 18/Ago/2008 00:17 »
Penso que deverias centralizar o site.

221
Projectos / Re: [Fórum] Portugal Online
« em: 18/Ago/2008 00:16 »
E o Zubux como patricionador oficial :-P

222
Projectos / Re: Zubux.com ~ Earn with ZuUu ~ by jotix
« em: 18/Ago/2008 00:15 »
Pagamentos de 14 Agosto


223
Hosting / PTServidor Serviços de Internet
« em: 17/Ago/2008 22:08 »
Que estranho, reclamações de não clientes? Não percebi!

224
Pessoal, na minha opinião, isto devia ser tudo colocado em blogs nacionais... Não perdiam nada, só tinham a ganhar, é menos um burlão na história da sociedade! Nem sei o que dizer... Esse género de pessoas enoja-me!

Eu não me enquadro nesse grupo.

Não foi o que me pareceu visto a história por parte do Nazgulled... E acho vergonhoso tu pagares os 70€ e dizeres que pagaste dando a entender que foi por misercordia... Se ele fez as alterações gráficas, então tem de ser pago, ponto final! E tenho dito... :superlol:

Eu tinha que dizer isto. :ideia:

Eu, pelo menos, dou explicações, ao contrário de outros que oferecem serviços grátis, mas que depois desaparece e não dá qualquer tipo de explicação, nem responde aos seus clientes.

Sirva a carapuça a quem de direito...

Boa Sorte com o v/ projectos.

 :obrigado:

Mas não foste tu que foste roubado em centenas de dolares, foste tu que roubaste uma centena de euros! No meu caso, a empresa que me vendeu os serviços desapareceu e levou com ela mais de 200$ meus... Nem uma dispute me valeu! Enquanto tu tás a engonhar aí e não dizes nada de jeito!

Claro agora és um santo. Mas uma coisa é certa, serviços teus não se pode confiar.

E lembrem-se uma coisa, e já estou pelo cabelos desta situação, e sinceramente já fui tentado a encerrar o zubux, e não o faço pelo membros, que ao contrário de outros, não tem culpa nenhuma e acreditaram no Zubux.


225
Projectos / Re: Web Milionário, o Blog
« em: 14/Ago/2008 03:52 »
Abriu hoje o blog que todos esperavam, o meu!  :grin:

http://www.webmilionario.com vai ser actualizado diariamente com artigos para ajudar qualquer webmaster a ganhar dinheiro online.

Visitem, aprendam, comentem, ensinem e ganhem dinheiro!

Todos esperavam? Nem sabia que tu existias... :superlol:

Páginas: 1 ... 13 14 15 16 17