Jnerocorp Posted May 1, 2011 Share Posted May 1, 2011 hello, I have 2 page backlinktool.php and go.php here is the files: <?php session_start(); ?> <!DOCTYPE html> <html> <head> <title>BuildingLinkService.net - Instant Backlink Buiding Tool</title> <script src="http://code.jquery.com/jquery-git.js"></script> <script src="http://code.jquery.com/jquery-1.5.2.js"></script> <script type="text/javascript"> function Ajax(){ var xmlHttp; try{ xmlHttp=new XMLHttpRequest();// Firefox, Opera 8.0+, Safari } catch (e){ try{ xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer } catch (e){ try{ xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ alert("No AJAX!?"); return false; } } } xmlHttp.onreadystatechange=function(){ if(xmlHttp.readyState==4){ document.getElementById('loading').innerHTML=xmlHttp.responseText; setTimeout('Ajax()',10000); } } xmlHttp.open("GET","backlinktool.php",true); xmlHttp.send(null); } window.onload=function(){ setTimeout('Ajax()',10000); } </head> <body> <fieldset> <u><b><center><label for="url">BuildingLinkService.net - Instant Backlink Building Tool</label></center></b></u><br> <form action="go.php" method="post" id="urlForm"> <u><label for="url">URL</u>: </label> <input type="text" name="url" id="url" size="75" placeholder="YourDomain.com" /> Ping results: <input type="checkbox" name="ping" checked="checked"> <br><br><center><input type="submit" name="submit" value="Start Building Backlinks" /></center><br><br> <center>*The software may take up to 20 minutes to complete the link building process. Please leave the page open until the link builder is completely done working.</center> </form> <br /> <br /> <div id="result"></div> <div id="loading"><img src="./loading.gif" border="0" alt="Loading..." /><br> <?php echo "Building ".$_SESSION['total_completed']." out of ".$_SESSION['outof'].""; ?> </div> </fieldset> <script> $( "#loading" ).hide(); // attach a submit handler to the form $("#urlForm").submit(function(event) { // stop form from submitting normally event.preventDefault(); $( "#loading" ).hide(); // get some values from elements on the page: var $form = $( this ), term1 = $form.find( 'input[name="url"]' ).val(), term2 = $form.find( 'input[name="ping"]' ).val(), url = $form.attr( 'action' ); // Send the data using post and put the results in a div $.post( url, { url: term1, ping: term2 } , function( data ) { var content = $( data ).find( '#content' ); $( "#result" ).html( content ); } ); $( "#loading" ).show(); }); </script> </body> </html> go.php <?php session_start(); $completed = 0; $good=0; ini_set("max_execution_time", 0); set_time_limit(0); // no time-outs! $time_start = microtime(true); $url=$_POST[url]; $url = str_replace("http://", "", $url); $fp = @fopen("urls.txt", "rb") or die("Couldn't open file"); while(!feof($fp)) { $data .= fgets($fp, 9999); } fclose($fp); $sites = explode("\n", $data); $sites = array_unique($sites); $lines = count($sites); $_SESSION['outof'] = $lines; /*echo "Array 1 ($lines)...<br><br>"; print_r($sites); $sites = array_unique($sites); $lines = count($sites); echo "Array 2($lines)...<br><br>"; print_r($sites); $lines = count($sites); */ if ($lines>10000){echo "Sorry I can handle only 100 urls per run..."; die; } //print_r($sites); foreach($sites as $site) { // If URL is blank (empty line), then continue to next line. if (!$site) { continue; } else { $curl_url1 = str_replace("yourdomain.com", $url, $site); $ch1 = curl_init(); curl_setopt($ch1, CURLOPT_URL, $curl_url1); // curl_setopt($ch, CURLOPT_PROXY, '203.199.200.44:8090'); curl_setopt($ch1, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3"); curl_setopt($ch1, CURLOPT_REFERER, $curl_url1); curl_setopt($ch1, CURLOPT_HEADER, 1); curl_setopt($ch1, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch1, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch1, CURLOPT_TIMEOUT, 10); $container1 = curl_exec($ch1); // Check if any error occured $completed++; $_SESSION['total_completed'] = $completed; if(!curl_errno($ch1)) { $xurl = str_replace("www.", "", $url); if (strstr($container1, $xurl)){ $good++; $info1 = curl_getinfo($ch1); echo $curl_url1 . ' <b> processed successfully in ' . round($info1['total_time'], 3) . ' seconds<br></b>'; curl_close($ch1); $myFile = "good_sites.txt"; $fh = fopen($myFile, 'a') or die("can't open file"); $stringData = $site . "\n"; fwrite($fh, $stringData); fclose($fh); //print_r($info); //echo "<br><br><br>"; if($_POST['ping']){ $curl_url2 = 'http://pingomatic.com/ping/?title=' . urlencode($xurl) . '&blogurl=' . urlencode($curl_url1) . '&rssurl=http%3A%2F%2F&chk_weblogscom=on&chk_blogs=on&chk_technorati=on&chk_feedburner=on&chk_syndic8=on&chk_newsgator=on&chk_myyahoo=on&chk_pubsubcom=on&chk_blogdigger=on&chk_blogrolling=on&chk_blogstreet=on&chk_moreover=on&chk_weblogalot=on&chk_icerocket=on&chk_newsisfree=on&chk_topicexchange=on&chk_google=on&chk_tailrank=on&chk_bloglines=on&chk_postrank=on&chk_skygrid=on&chk_bitacoras=on&chk_collecta=on'; $ch2 = curl_init(); curl_setopt($ch2, CURLOPT_URL, $curl_url2); // curl_setopt($ch, CURLOPT_PROXY, '203.199.200.44:8090'); curl_setopt($ch2, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3"); curl_setopt($ch2, CURLOPT_REFERER, $curl_url1); curl_setopt($ch2, CURLOPT_HEADER, 1); curl_setopt($ch2, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch2, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch2, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch2, CURLOPT_TIMEOUT, 10); $container2 = curl_exec($ch2); $info2 = curl_getinfo($ch2); $string = 'Pinging complete!'; if (strstr($container2, $string)){ echo $curl_url1 . ' <b> Pinged successfully in ' . round($info2['total_time'], 3) . ' seconds<br></b>'; } else { echo $curl_url1 . ' <b> Pinging failed!</b>'; } // Close handle curl_close($ch2); } // ping } // string check } // error check else { // error reported echo $curl_url1 . ' <b>Returned Error: ' . curl_error($ch1) . '<br><br></b>'; } } // end curl } // end loop $time_end = microtime(true); $seconds = round($time_end - $time_start); $minutes = floor($seconds/60); $secondsleft = $seconds%60; if($minutes<10) $minutes = "0" . $minutes; if($secondsleft<10) $secondsleft = "0" . $secondsleft; echo "<br><br>Finished backlinking $url from <b>$good of $lines </b> websites in <b>$minutes</b> minutes and <b>$secondsleft</b> seconds."; ?> in go.php I have $completed as a variable and at a certain point it adds +1 to that variable then stores it $_SESSION['total_completed'] and on backlinktool.php there is an ajax script that I have running to update a div which displays "$_SESSION['total_completed'] out of $_SESSION['outof']" but I cant get it to work. can anyone help. -John Quote Link to comment https://forums.phpfreaks.com/topic/235282-trying-to-display-number-completed-as-script-runs/ Share on other sites More sharing options...
sunfighter Posted May 8, 2011 Share Posted May 8, 2011 In backlinktool.php your missing the </script> tag. If you remove the two <script src="http://code.jquery.com/jquery-git.js"></script> <script src="http://code.jquery.com/jquery-1.5.2.js"> lines your divs show up... Looks like a conflict.. Oh yeah the name of the div change it. try 'load' but not 'loading'. Quote Link to comment https://forums.phpfreaks.com/topic/235282-trying-to-display-number-completed-as-script-runs/#findComment-1212499 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.