Jump to content

TripleDES

Members
  • Posts

    64
  • Joined

  • Last visited

Everything posted by TripleDES

  1. Please help with with this regex. I need to match the first string as Z followed by 3-5 numbers. Z1 - Match Z12 - Match Z1234 - Match zZ123 - No Match This expression seems to work well except for the last example. How do I filter out characters before Z? Or...how do I enforce Z as the first character? /\b[Z][0-9]{3,5}/ Thanks!
  2. And if you haven't already visited: http://hudzilla.org/phpwiki/index.php?title=Introduction_to_Curl
  3. Try not using CURLOPT_POST and also try CURLOPT_URL, "$url". I'm looking at your example and the one I have working and there's not much of a difference. Here's mine: $curl = curl_init(); curl_setopt ($curl, CURLOPT_URL, "$url"); curl_setopt($curl, CURLOPT_USERPWD, "user:pass"); curl_setopt($curl, CURLOPT_USERAGENT, $useragent); //Spoofs Firefox curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec ($curl); curl_close ($curl);
  4. Thanks! It works with the following. <?php header("Cache-control: private"); $uploadfile = "{$_FILES['userfile']['name']}"; $uploadfpath = "{$_FILES['userfile']['tmp_name']}"; $handle = fopen($uploadfpath, "rwb"); $contents = fread($handle, filesize($uploadfpath)); fclose($handle); $hubarray = explode("\n", $contents); $template = $_POST['Template']; print "<pre>"; foreach ($hubarray as $line) { $line = trim($line); $parts = explode(",",$line); printf($template . "\r",$parts[0],$parts[1],$parts[2],$parts[3],$parts[4],$parts[5],$parts[6],$parts[7]); print "\r\r"; } ?> I just need to figure out a clever way to code $parts[0], $parts[1], etc.
  5. That doesn't seem to work as expected. I don't get any output and the $output returns boolean with a false value. $uploadfpath = "{$_FILES['userfile']['tmp_name']}"; $handle = fopen($uploadfpath, "rwb"); $template = $_POST['Template']; $hubarray = explode("\n", $contents $output = sprintf($template, $hubarray); var_dump($output);
  6. Heredoc will be basically a template that includes numerous whitespaces and variables. Here's an example: $output = <<<EOT set route $hostarray[0] gateway $hostarray[3] set route $hostarray[1] gateway $hostarray[3] set route $hostarray[2] gateway $hostarray[3] EOT; The uploaded fill will contain those variables: ipinfo.csv 1.1.1.0,1.1.1.1,1.1.1.2,1.1.1.3 2.2.2.0,2.2.2.1,2.2.2.2,2.2.2.3 3.3.3.0,3.3.3.1,3.3.3.2,3.3.3.3 I would like heredoc to be a variable. This way, I can input a different "template" into the text area. ie. set policy $hostarray[0] allow $hostarray[3] set policy $hostarray[1] allow $hostarray[3] set policy $hostarray[2] allow $hostarray[3]
  7. I can't seem to get heredoc to populate correctly with variables through a form. <textarea name="Template" rows="10" cols="80">Template Here</textarea> Contents could be something like: I want to replace $myarray[0] and another variable $myarray[1] I call heredoc this way: $hubarray = explode("\n", $contents); $template = $_POST['Template']; foreach ($hubarray as $val) { $hostarray = explode(",", $val); $output = <<<EOT $template EOT; I'm feeding it a file that has multiple rows separated by \n as array 1 and within those rows are fields separated by "," for array 2. I'm trying to iterate through the arrays and populate heredoc($template) accordingly.
  8. Silly me....I think so. So once you fclose(), the file goes bye bye unless you purposely write it??
  9. Is it possible to append to a temporary file? I'm iterating through a file and when a condition becomes true, I want to append the content to a temporary file. I want to display the contents once the loop completes. If there's a better suggestion on how to go about this, please let me know.
  10. I was able to get output buffering working as expected with other scripts. However, it seems when I try to run an external program such as ping, PHP waits until the command completes before releasing any output. $ping = "ping -i .25 -c $ping_count -s $ping_size $ping_ip_addr"; I've tried exec(), passthru() and plan 'ping x.x.x.x' to no avail. Any other suggestions?
  11. Apologies, I posted before seeing your response. See my partial script below. The location of the output buffering essentially has an artificial effect of what I'm trying to do. The script actually completes, but then has a 1 second delay before displaying each line. if (preg_match("$regex", $ping_ip_addr) OR preg_match("$regex2", $ping_ip_addr)) { exec($ping, $result); ob_start(); foreach($result as $val) { print "$val<br>"; sleep(1); ob_flush(); flush(); }
  12. hmm...no workaround? that's unfortunate.
  13. Thanks for the quick response. So how do I defer from this default behavior? Here's what I'm going with this script. I want to form a ping script that will ping x host x times. Let's say I want to ping 4.2.2.2 20 times. I would like a running output: PING 4.2.2.2 (4.2.2.2) 56(84) bytes of data. 64 bytes from 4.2.2.2: icmp_seq=1 ttl=247 time=139 ms 64 bytes from 4.2.2.2: icmp_seq=2 ttl=247 time=147 ms 64 bytes from 4.2.2.2: icmp_seq=3 ttl=247 time=168 ms 64 bytes from 4.2.2.2: icmp_seq=4 ttl=247 time=143 ms ...etc. Currently, the user must wait until the script is complete to see the entire output.
  14. Very simple script. When executed from CLI, I get desired response. Each character is displayed while it iterates. ie. 1..2..3 However, when running this script through a browser, it waits before the script completes before displaying 123. Any ideas why? Someone in a PHP newsgroup mentioned possible output buffering enabled. I since disabled this, but still seem to get the same issue. <?php while($i++<3) { print($i); sleep(2); } ?>
×
×
  • 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.