Jump to content

squiggerz

Members
  • Posts

    59
  • Joined

  • Last visited

    Never

Everything posted by squiggerz

  1. I have been fighting with this for hours.. Below is an excerpt of what I'm working with. I have a list of domains in a text file, I upload the text file through a form to my script. All of this is fine and dandy. I have a checkbox set to ask user if they want to stall for 10 minutes after 400 domains are ran through this script before executing 400 more. I can get the script to count the total amount of domains in the file, I just cant wrap my head around what I'm supposed to do if the counted number of domains reaches 400. if ($sleep) { $counted = count($doms); while ($counted < 400) { execute the script on the domain name; } pseudocode from here on: when $counted == 400 { sleep(600) } then continue till $counted == 800 ... } Anybody have any idea how this can be accomplished?
  2. *points up* This is why he has 3 stars, I have 1. lol, I didnt even notice he was fetching his query instead of the resulting variable. Good eye
  3. Have you tried using mysql_fetch_assoc instead of _fetch_object? If all you are fetching is an email addy, I dont see why that wouldnt work.
  4. I have a script that pulls code from a field in a row in mySQL db randomly, is there a way to have several instances of this pulling in the same script, pulling randomly from the remaining rows without repeating? I guess what I'm needing is a function to lock the row once it has been used in the script so that it doesnt use the same row again, then unlock the rows once the script is complete. Is this even possible?
  5. echo '<form name="form1" action="form1.php" method="post">'; echo '<input type="submit" name="submit" value="Form1">'; echo '<form name="form2" action="form1.php" method="post">'; echo '<input type="submit" name="submit" value="Forma2">'; echo '</form name="form2"></form name="form1">'; You have your form2 action set to "form1.php rather than "form2.php should look like this: echo '<form name="form1" action="form1.php" method="post">'; echo '<input type="submit" name="submit" value="Form1">'; echo '<form name="form2" action="form2.php" method="post">'; echo '<input type="submit" name="submit" value="Forma2">'; echo '</form name="form2"></form name="form1">'; might want to close that 1st form before you start the second one as well
  6. So I'm trying to set up a script that grabs webalizer stats from 1 of our 3 servers running cPanel. I have found many, many scripts that will allow you to do this if you put the stats script on the same domain that you are pulling stats for, however I'm trying to pull stats about a domain on one server by a script on another server, nothing I have tried has worked thus far.. auth doesnt seem to work correctly between the two servers (guessing because of the Host: header, not really sure), anyway I've came across another script that works the same way the rest do, if you stick it on the same host, it works. This script actually looks very promising though, hopefully somebody here can help me figure out a way to get it to work cross-server style. Here's the stats script, note the first 3 vars, if you set them to the actual domain/user/pass, the script works, but where I'm trying to use $_POST values from my login.php form, the script fails to pull the images and the links will not work because those vars obviously do not propagate to the links... : <?php $user = $_POST['user']; $pass = $_POST['pass']; $url = $_POST['dom']; //retrieves the webalizer file, either .html or .png function getFile($file) { global $user, $pass, $url; return file_get_contents("http://" . $user . ":" . $pass . "@" . $url . ":2082/tmp/" . $user . "/webalizer/" . $file); } //alters links, either .html or .png function changeLinks($subject, $type) { return preg_replace("/($type=\")(?!http)(.*?)\"/is", "$1$PHP_SELF?$2\"", $subject); } if(!empty($_SERVER['QUERY_STRING'])) { //get file (whether png or html) $page = getFile($_SERVER['QUERY_STRING']); //if png, output appropriate header if(strpos($_SERVER['QUERY_STRING'],'.png') !== false) { header("Content-type: image/png"); } //change the .png src(s) else { $page = changePix($page, 'src'); } } else { //get index $page = getFile('index.html'); //change links $page = changeLinks($page, 'href'); //change the usage.png src $page = changePix($page, 'src'); } //output it echo $page; ?> Now, just for reference, here's my login.php script, keep in mind, this script will reside on a neutral server to the actual servers that the stats script will reside on, which is sort of irrelevant to the actual problem, POST is POST no matter what page it came from: <html> <head> <title>Customer Statistics Login</title> </head> <body> <form name = "cpLoginForm" method="POST" action="stats.php" target="_self"> <p align="center">Please log in. </p> <p align="center">Domain:<br> <input type="text" name="dom"> </p> <p align="center">Username:<br> <input type="text" name="user"> </p> <p align="center">Password: <br> <input type="password" name="pass"> <br> <br> <input type="submit" value="Login"> </p> </form> </body> </html> So, any ideas? I've thought about the session/cookie concept but I'm very ill-versed with that, any help would be greatly appreciated. sq
  7. OK, here's what I have: I'm making up a script that displays awstats or webalizer based on a clients choosing, this goes through cPanel. I have a login.php form that has two fields, domain and password. The login.php file posts to dom.php, this is where the client chooses which stats app to use. In this dom.php file it includes headers.php which has the bulk of the script, all the variables etc. The headers.php takes the $_POST data, does a regex on the cPanel /scripts2/listaccts?viewall=1 page and drops the domains and usernames into an array with domains as keys and usernames as values. I've read about cURL and used it to retreive pages so I understand how that works. I guess the problem I'm really having is being able to go to the stats page having already sent the user/pass instead of passing them in plaintext in the link. I can get the user/pass vars to be set, I think I'm mainly having trouble figuring out if you can take user defined variables from one script and use them in another script?? Anybody with any helpful info, I'd be in your debt. From dom.php: note the link to the stats.php file, SID... this should give you some indication of how much I really understand about sessions: <? include 'header.php'; if (isset($password, $username)) { echo "<table width=\"500\" border=\"0\" align=\"center\" cellpadding=\"1\" cellspacing=\"1\"> <tr> <td height=\"70\" colspan=\"2\"><div align=\"center\">View stats for {$_COOKIE['domain']}<br> Click on one of the Statistical Program images below to access your statistics. </div></td> </tr> <tr> <td height=\"89\"><div align=\"center\"> <p><a href=\"stats.php?SID\"><img src=\"http://www.domain.com/stats/awstats.gif\" width=\"65\" height=\"42\" border=\"0\" /></a><br /> AWStats </p> </div></td> <td><div align=\"center\"><a href=\"webstats.php?SID\"><img src=\"http://www.domain.com/stats/webaliser.gif\" width=\"65\" height=\"42\" border=\"0\" \/></a><br /> Webalizer</div></td> </tr> </table>" ; }else{ echo "<center>Sorry You have either accessed this page directly or endtered a wrong Domain/Password combination. Please check and retry. NOTE: Domain SHOULD NOT CONTAIN 'http://www.'";} ?> From headers.php: <? session_start(); setcookie('domain', $_POST[domain]); $username2 = session_register("username"); $password2 = session_register("password"); $dom2 = session_register("dom"); // Web Host Manager Main Reseller Username, Pass, and URL: $g1user = "*******"; $g1pass = "*******"; $gator1url = "70.87.*.*"; $g2user = "*******"; $g2pass = "*******"; $gator2url = "70.87.*.*"; $g3user = "*******"; $g3pass = "*******"; $gator3url = "74.52.*.*"; // Domain and Password info as passed from form on login.php $dom = $_POST[domain]; $pwd = $_POST[pass]; // Gets the contents of the list all accounts page and puts them in variable $page $g1 = @file_get_contents("http://$g1user:$g1pass@$gator1url:2086/scripts2/listaccts?viewall=1"); $g2 = @file_get_contents("http://$g2user:$g2pass@$gator2url:2086/scripts2/listaccts?viewall=1"); $g3 = @file_get_contents("http://$g3user:$g3pass@$gator3url:2086/scripts2/listaccts?viewall=1"); // Regular Expression (PCRE) for finding the domain name, explaining this would be labor intensive. // In a nutshell, it takes the code from $domain, looks for // <tr class="(tdshade1 or tdshade2)"><td><a href="http://domain.com" target="_blank"> <-- domain.com being what we are wanting. $gator1dn = preg_match_all("/(<tr class=.tdshade)+(1|2)*(.>)+(.........<td>)+(<a href=\"http:\/\/)+([a-zA-Z0-9\-\.]{1,50}.[a-zA-z]{1,4})+(\" )+(target=..blank.>)+/ism", $g1, $gator1d); $gator2dn = preg_match_all("/(<tr class=.tdshade)+(1|2)*(.>)+(.........<td>)+(<a href=\"http:\/\/)+([a-zA-Z0-9\-\.]{1,50}.[a-zA-z]{1,4})+(\" )+(target=..blank.>)+/ism", $g2, $gator2d); $gator3dn = preg_match_all("/(<tr class=.tdshade)+(1|2)*(.>)+(.........<td>)+(<a href=\"http:\/\/)+([a-zA-Z0-9\-\.]{1,50}.[a-zA-z]{1,4})+(\" )+(target=..blank.>)+/ism", $g3, $gator3d); $gator1un = preg_match_all("/(<\/a><\/td>.........<td>)+([a-zA-Z0-9\-\.]{1,15})+(<\/td>)+/ism", $g1, $gator1u); $gator2un = preg_match_all("/(<\/a><\/td>.........<td>)+([a-zA-Z0-9\-\.]{1,15})+(<\/td>)+/ism", $g2, $gator2u); $gator3un = preg_match_all("/(<\/a><\/td>.........<td>)+([a-zA-Z0-9\-\.]{1,15})+(<\/td>)+/ism", $g3, $gator3u); //Combines arrays of domain list and username list $gator1data = array_combine($gator1u[2], $gator1d[6]); $gator2data = array_combine($gator2u[2], $gator2d[6]); $gator3data = array_combine($gator3u[2], $gator3d[6]); $gatorarray = array_merge($gator1data, $gator2data, $gator3data); if (isset($gatorarray)) { asort($gatorarray); } //Searches the $_POST domain value against the domain list values in the array, and returns the username associated if ($arraysearch = array_search($dom, $gatorarray)) { $arraykeys = @array_keys($gatorarray[$dom]); } $username = $arraysearch; $password = $pwd; $_SESSION["username"] = $username; $_SESSION["password"] = $password; ?> and last but not least, from stats.php: <? session_start(); include 'header.php'; $username = $_SESSION["username"]; $password = $_SESSION["password"]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://$dom:2082/awstats.pl?config=$dom&ShowOriginStats=1000'); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_setopt($ch, CURLOPT_USERPWD, '$username:$password'); curl_exec($ch); curl_close($ch); echo $username."<br>".$password; ?> I can get this to work without curl by just making a link to http://$username:$password@$dom:2082/stats... but this displays the user/pass clearly to the client, and the obvious reasoning for this would be that we do not want them to have their either their username or password, the username was easier to hide, and we could use the reseller password as sort of master password for internal use. Another reason is that when we do the user:pass@domain syntax, it asks twice if you would like to log in to this site as username.
  8. <a href="http://www.test.com/" class=l> could try: "/(<a href=.)+(.*?)?(..class=l>)+/ism" easier to read I think, but it stores your url value in $matches[2] let me know if I'm off, I just learned regex over the weekend lol oh, regexlib dot com has a nice regex tester as well if you need it, comes in handy.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.