Author Topic: Amazing PHP scripts!  (Read 2212 times)

reactosguy

  • Member
  • **
  • Posts: 269
  • Kudos: 2
    • Microsoft Sucks !!!
Amazing PHP scripts!
« on: 10 October 2010, 22:57 »
Here's a PHP script to create a really big CSV file! It's really impressive!


Code: [Select]

<?php
// Filename: spamtable_csv.php
$content '"'.rand().'","'.date("Y-m-d").'","'.date("H:i:s").'"\n';
$fh fopen("spamtable.csv","a");
while(
file_exists("spamtable.csv"))
{
fwrite($fh,$content);
}
?>



I used it 4 times to create a 154 MB CSV file that took like 8 minutes to open on my PC.


Here's a MySQL version:


Code: [Select]

<?php
// Filename: spamtable_sql.php
$rand rand();
$date date("Y-m-d");
$time date("H:i:s");
$cxn mysqli_connect("localhost","username","password","database");
$sql "INSERT INTO spamtable (rand,date,time) VALUES ('$rand','$date','$time')";
$result mysqli_query($cxn,$sql);
include(
"spamtable_sql.php");
?>



The CSV edition is prone to unnecessary duplicates, and on Windows, no \n turning into the press of an enter/return button. I attempt to use this to prevent duplicates, but it won't fix Windows's dislike of the \n. I haven't tried this, it was a last minute addition.



Code: [Select]

<?php
// Filename: spamtable_csv.php
$content '"'.rand().'","'.date("Y-m-d").'","'.date("H:i:s").'"\n';
$fh fopen("spamtable.csv","a");
fwrite($fh,$content);
include(
"spamtable_csv.php");
?>



Please be aware that MySQL server may get corrupted with a 20,000+ row table, requiring a drop of the junk table and probably a restart of the computer.


Have fun with this!

Aloone_Jonez

  • Administrator
  • Member
  • ***
  • Posts: 4,090
  • Kudos: 954
Re: Amazing PHP scripts!
« Reply #1 on: 10 October 2010, 23:20 »
If it's Windows, I think a batch file is the easiest way to do this.

Code: [Select]
@echo off
echo Really big file>> bigfile.txt
:larger
 type bigfile.txt>> bigfile.txt
goto larger
This is not a Windows help forum, however please do feel free to sign up and agree or disagree with our views on Microsoft.

Oh and FUCKMicrosoft! :fu: