efficacious Posted August 25, 2008 Share Posted August 25, 2008 Hello everyone, I was just wondering if someone would be able to help me setup a "Processing..." pop up for my php script.. I have an automatic update script that checks users version info against our current version info and the decides which files the users need and zips just those files up inside a zip document. The problem I've ran across is that the script execution takes alil long.. like (25sec) or so. But our users are not that computer savvy and would be calling us thinking there is something wrong.. So I'd like to be able to have a "Proccessing.." pop up that does a stupid cheap animation or something.. just to show them .. we are working on it... lol I've never done anything like this so plz do explain as if I knew nothing. thanks, eff Quote Link to comment Share on other sites More sharing options...
DarkWater Posted August 25, 2008 Share Posted August 25, 2008 You could do an Ajax approach for this, which would simply things because you can't really gauge PHP execution time. Quote Link to comment Share on other sites More sharing options...
efficacious Posted August 25, 2008 Author Share Posted August 25, 2008 could you explain kinda the process flow of this tho.. like how am I going to be able to know when the script is done how Do i get the popup to go before the script execution starts... ect... thanks, eff Quote Link to comment Share on other sites More sharing options...
DarkWater Posted August 25, 2008 Share Posted August 25, 2008 Well, first of all, can I see the script? Why does it take so long...? Quote Link to comment Share on other sites More sharing options...
efficacious Posted August 25, 2008 Author Share Posted August 25, 2008 well it takes along time cuz its zipping files.. its a decent size script. 377lines(including display). the files are decent size aswell the biggest one i think is around 50mb Quote Link to comment Share on other sites More sharing options...
DarkWater Posted August 25, 2008 Share Posted August 25, 2008 Oh, okay. You could use Ajax to send the request off the PHP, and then redirect to the ZIP or have it send the download. Quote Link to comment Share on other sites More sharing options...
efficacious Posted August 25, 2008 Author Share Posted August 25, 2008 here is the script: <?php //* COLLECT ALL VERSION INPUT *// $AnnR = (!(isset($_GET['AnnR']))) ? '' : $_GET['AnnR']; //GET Annual Reports $AtchM = (!(isset($_GET['AtchM']))) ? '' : $_GET['AtchM']; //GET Attachment Manager $CapA = (!(isset($_GET['CapA']))) ? '' : $_GET['CapA']; //GET Attachment Manager $Capit = (!(isset($_GET['Capit']))) ? '' : $_GET['Capit']; //GET Capital Assets $Direct = (!(isset($_GET['Direct']))) ? '' : $_GET['Direct']; //GET Direct DP $Humres = (!(isset($_GET['Humres']))) ? '' : $_GET['Humres']; //GET Human Resources $Inven = (!(isset($_GET['Inven']))) ? '' : $_GET['Inven']; //GET Inventory $Inves = (!(isset($_GET['Inves']))) ? '' : $Inves=$_GET['Inves']; //GET Investments $Invoi = (!(isset($_GET['Invoi']))) ? '' : $_GET['Invoi']; //GET Invoice $Payr = (!(isset($_GET['Payr']))) ? '' : $_GET['Payr']; //GET Payroll $POR = (!(isset($_GET['POR']))) ? '' : $_GET['POR']; //GET PO Request $POS = (!(isset($_GET['POS']))) ? '' : $_GET['POS']; //GET POS (Point of Sale) $Purch = (!(isset($_GET['Purch']))) ? '' : $_GET['Purch']; //GET Purchase Orders $Tax = (!(isset($_GET['Tax']))) ? '' : $_GET['Tax']; //GET Tax Reports $Ttrax = (!(isset($_GET['Ttrax']))) ? '' : $_GET['Ttrax']; // GET Time Trax $Utility = (!(isset($_GET['Utility']))) ? '' : $_GET['Utility']; // GET Utility Billing //////////////////////////////////////////////////////////////////////////////////// //* HAS INPUT? *// if(isset($_GET['CapA'])) { //* CREATE MODULE NAME ARRAY *// $Module=array( 'Annual Reports', 'Attachment Manager', 'General Ledger/Accounts Payable', 'Capital Assets', 'Direct Deposit', 'Human Resources', 'Inventory Control', 'Investment Management', 'Invoice', 'Payroll', 'Purchase Order Request', '(POS)Point of Sale', 'Purchase Orders', 'IN Tax Reports', 'Time Trax', 'Utility Billing' ); //* SEARCH DIRECTORY FOR VERSION INFO *// $DIR = scandir("../update/"); $DirCount=count($DIR); for($x=0;$x<$DirCount;$x++) { if(is_dir($DIR[$x])) { if($DIR[$x]=='.' || $DIR[$x]=='..') { echo(''); } else { for($x=0;$x<$DirCount;$x++) { if(is_dir($DIR[$x])) { if($DIR[$x]=='.' || $DIR[$x]=='..') { echo(''); } else { $Folderz[$x]=$DIR[$x]; $IFolderz=array_values($Folderz); } } } } } } $FolderCount=count($IFolderz); for($q=0;$q<$FolderCount;$q++) { //* CREATE MOST RECENT VERSIONS ARRAY *// $NameConvert[$q]=substr($IFolderz[$q],-5); if($NameConvert[$q]=='6.0.0') { $NameConvert[$q]='6.0'; //echo($NameConvert[$q]."<br />"); } $Rversion[$q]=$NameConvert[$q]; } //echo("<br />"); //print_r($IFolderz); //echo("<br /><br />"); for($z=0;$z<$FolderCount;$z++) { //* GET FILES FROM FOLDERS *// if(is_dir($IFolderz[$z])) { if($IFolderz[$z]=='.' || $IFolderz[$z]=='..') { echo(''); } else { $ScanFiles = scandir($IFolderz[$z]); $ScanCount = count($ScanFiles); for($x=0;$x<$ScanCount;$x++) { if($ScanFiles[$x]=='.' || $ScanFiles[$x]=='..') { echo(''); } else { $mod[$x]=$ScanFiles[$x]; } if(isset($mod)) { $TheFile[$x]=$mod[2]; $ZTheFile=array_unique($TheFile); $NFilez=array_values($ZTheFile); } } } } } //echo"<br />"; //print_r($NFilez); //echo"<br />"; //* CREATE USER VERSIONS ARRAY *// $Uversion=array( $AnnR, //Anuual Reports $AtchM, //Attachment Manager $CapA, //Cap Accounting $Capit, //Capital Assets $Direct, //Direct Deposit $Humres, //Human Resources $Inven, //Inventory Control $Inves, //Investment Management $Invoi, //Invoice $Payr, //Payroll $POR, //Purchase Order Request $POS, //(POS)Point of Sale $Purch, //Purchase Orders $Tax, //IN Tax Reports $Ttrax, //Time Trax $Utility //Utility Billing ); $U_Count=count($Uversion); //* START DISPLAY *// echo(" <style> body { background:gray; text-align:center; } table,td { border-bottom:2px solid black; border-right:2px solid black; background:white; } </style> <br /><center><img src='logo2.png' border='0' /></center><br /> <table style='margin:auto;' border='1' cellspacing='5'> <tr> <td colspan='2' style='text-align:center;'> <h2>Available Updates</h2> </td> </tr> <tr> <td colspan='2' style='padding-left:10px;'> <b>Key: </b><br /><br /> <font color='blue'><b>Blue:</b> If Your Version is BLUE it means your module is Up-To-Date.</font><br /><br /> <font color='red'><b>Red:</b> If Your Version is RED it means your module is Out-Of-Date.</font><br /><br /><br /> <font color='green'><b>Green:</b> If Current Versions are GREEN it means that module can be updated.<br /><br /> </td> </tr> <tr> <td style='text-align:center'><h3><b>Your Version</b></h3></td> <td style='text-align:center'><h3><b>Current Version</b></h3></td> </tr> "); ///////////////////////////////////////// //* SETUP INDICATORS FOR FILES TO ZIP *// ///////////////////////////////////////// $Z_AnnR=0; $Z_AtchM=0; $Z_CapA=0; $Z_Capit=0; $Z_Direct=0; $Z_Humres=0; $Z_Inven=0; $Z_Inves=0; $Z_Invoi=0; $Z_Payr=0; $Z_POR=0; $Z_POS=0; $Z_Purch=0; $Z_Tax=0; $Z_Ttrax=0; $Z_Utility=0; $Z_Array= array( $Z_AnnR, $Z_AtchM, $Z_CapA, $Z_Capit, $Z_Direct, $Z_Humres, $Z_Inven, $Z_Inves, $Z_Invoi, $Z_Payr, $Z_POR, $Z_POS, $Z_Purch, $Z_Tax, $Z_Ttrax, $Z_Utility ); $Zcount=count($Z_Array); //* SETUP FILE NAME ARRAY *// $FN_Array= array( 'AnnualReports.accde', 'Attachment Manager.accde', 'CapAccounting.accde', 'CapitalAssets.accde', 'DirectDP.accde', 'Human Resource.accde', 'Inventory.accde', 'Investments.accde', 'Invoice.accde', 'Payroll.accde', 'PORequest.accde', 'POS.accde', 'PurchaseOrders.accde', 'TaxReports.accde', 'TimeTrax.accde', 'UB Billing.accde', ); ///////////////////////////////////// ///* LOOP THROUGH USERS VERSIONS */// //* CHECK AGAINST CURRENT VERSION *// ///////////////////////////////////// for($x=0;$x<16;$x++) { if($Uversion[$x]<$Rversion[$x] && $Uversion[$x]!='') { //VERSION IS OUT OF DATE! echo(" <tr> <td style='color:red'> ".$Module[$x]." v".$Uversion[$x]." </td> <td style='color:green'> ".$Module[$x]." v".$Rversion[$x]." </td> </tr> "); //* MARK MODULE OUT-OF-DATE! *// $Z_Array[$x]++; } elseif($Uversion[$x]==$Rversion[$x]) { //VERSION IS UP-TO-DATE. echo(" <tr> <td style='color:blue'> ".$Module[$x]." v".$Uversion[$x]." </td> <td> ".$Module[$x]." v".$Rversion[$x]." </td> </tr> "); } }//END LOOP //* GET DATE STAMP *// $TheDate = date("m-d-y"); $TheTime = //////////////////////// //* ZIP UP THE FILES *// //////////////////////// $zip = new ZipArchive(); $filename = "CTE_Update".$TheDate.".zip"; //if(!(file_exists($filename))) //{ if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) { exit('cannot open <'.$filename.'>'); } else { for($x=0;$x<16;$x++) { //* GRAB NEW FILES 2 Be Zipped *// if($Z_Array[$x]==0) { echo('');//DON'T GRAB THIS FILE } else { $zip->addFile($IFolderz[$x]."/".$FN_Array[$x],$FN_Array[$x]); } } } $zip->close(); //} //* SERVE UP DOWNLOAD ZIP *// if(file_exists($filename)) { echo(" <tr> <td colspan='2' style='text-align:center;vertical-align:middle;height:75px;'> <a href='".$filename."'>CLICK HERE TO DOWNLOAD UPDATE!</a> </td> </tr> "); } //* DELETE OLD ZIPS *// // UNDERCONSTRUCTION // //* END DISPLAY *// echo("</table>"); }//END CHECK ?> not familiar with ajax 8( Quote Link to comment Share on other sites More sharing options...
DarkWater Posted August 25, 2008 Share Posted August 25, 2008 Ajax is pretty simple. Just look up some examples on the web for basic Ajax requests and you should get the idea from there. And you know, scripts that need to go through every version with big loops like that make me love make even more. xD Quote Link to comment Share on other sites More sharing options...
efficacious Posted August 25, 2008 Author Share Posted August 25, 2008 make? Quote Link to comment Share on other sites More sharing options...
DarkWater Posted August 25, 2008 Share Posted August 25, 2008 It's a UNIX utility that checks the last modified time of files and executes commands to recreate files based on some dependencies and stuff. You see it a lot when compiling programs. Quote Link to comment Share on other sites More sharing options...
efficacious Posted August 25, 2008 Author Share Posted August 25, 2008 ah ic Been wanting to do some stuff on linux/unix systems but havn't been able to for somtime now.. I run my own websites and stuff off my pc aswell as playing games on it.. 8P And I don't have another pc to run it on.. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted August 25, 2008 Share Posted August 25, 2008 ah ic Been wanting to do some stuff on linux/unix systems but havn't been able to for somtime now.. I run my own websites and stuff off my pc aswell as playing games on it.. 8P And I don't have another pc to run it on.. Your hosting companies don't yell at you for hosting your sites on their connection? Surprising. Well, if you get a decent amount of traffic, it's surprising. If it's like, 30 hits a month, then w/e. >_< You should really get some experience with Linux if you can though. Such a great system. Quote Link to comment Share on other sites More sharing options...
efficacious Posted August 25, 2008 Author Share Posted August 25, 2008 well they better not say anything to me... I pay almost 100$ a month for just internet.. 16MB \/ 3M /\ Quote Link to comment Share on other sites More sharing options...
DarkWater Posted August 25, 2008 Share Posted August 25, 2008 well they better not say anything to me... I pay almost 100$ a month for just internet.. 16MB \/ 3M /\ I can get 22MB download and 4MB or 5MB upload. Quote Link to comment Share on other sites More sharing options...
efficacious Posted August 25, 2008 Author Share Posted August 25, 2008 well i'm sure i could get more.. just have to pay more.. But back to the subject.. How can I implement this tho.. Am I gona need multiple pages? Quote Link to comment Share on other sites More sharing options...
DarkWater Posted August 25, 2008 Share Posted August 25, 2008 well i'm sure i could get more.. just have to pay more.. But back to the subject.. How can I implement this tho.. Am I gona need multiple pages? You could do it in one page and one PHP script. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.