Jump to content

newbtophp

Members
  • Posts

    631
  • Joined

  • Last visited

Everything posted by newbtophp

  1. Uploaded file needs to be .php, i already have an if statement to validate the file extension. Im matching a variety of of code, and the regex is quite long theirfore i renamed to pattern1 ...pattern2 etc, to post just the relevant code. Im looking for something abit like this , some sort of else with echos if none of the preg_matches are true (match). <?php if (isset($_FILES['file'])) { $file = file_get_contents($_FILES['file']['tmp_name']); $submit = $_POST['submit']; if($file == "") echo "error"; else { if($submit == "Submit") { if(preg_match('/pattern1/', $file)) { include "somepage1.php"; } if(preg_match('/pattern2/', $file)) { include "somepage2.php"; } if(preg_match('/pattern3/', $file)) { include "somepage3.php"; } if(preg_match('/pattern4/', $file)) { include "somepage4.php"; } else { echo "none of the above matches were found!"; } } } ?>
  2. Ok, I have the following code, but i want to echo a message if no matches were found on any of the if statements. <?php if (isset($_FILES['file'])) { $file = file_get_contents($_FILES['file']['tmp_name']); $submit = $_POST['submit']; if($file == "") echo "error"; else { if($submit == "Submit") { //pattern is actually a regex pattern if(preg_match('/pattern1/', $file)) { include "somepage1.php"; } if(preg_match('/pattern2/', $file)) { include "somepage2.php"; } if(preg_match('/pattern3/', $file)) { include "somepage3.php"; } if(preg_match('/pattern4/', $file)) { include "somepage4.php"; } } } } ?> All help is greatly apreciated.
  3. If you just want a popup to display upon submit, place this within the if statement (untested): print "<script>alert('Replace with the text you want to show here!');</script>";
  4. Yep, thats what i thought, but i cant modify code.php since its on a remote server (long story). So is their a work around, to some how bypass the eval?, and do the replace. Because code.php will remain the same.
  5. content of code.php: <?php eval(base64_decode('ZWNobyAidW5zZXQiOw==')); ?>
  6. $file = file_get_contents('code.php');
  7. I have the following code, everything works fine, but i can't get the str_replace to work, I think its because $file doesnt contain unset, but once executed (after the eval), it then prints unset. So theirfore im unsure on where to place that line? $file = file_get_contents('code.php'); $file = str_replace('<?php', '', $file); $file = str_replace('<?', '', $file); $file = str_replace('?>', '', $file); $file = str_replace('unset', 'hello', $file); eval($file);
  8. google winbinder, and php.exe
  9. Ok sure, lol. Are you available to help?
  10. http://www.onlinecronjobs.com/
  11. Thanks for clearing things up!, i was going mad, but 1 thing can you give me some example code 1-8 so i can then modify that, and add in the ifs etc. I've never worked with zips or loops before, always stuck to sql.
  12. <?php if (isset($_FILES['file'])) { $file = $_FILES['file']['tmp_name']; $submit = $_POST['submit']; if($file == "") echo "Error"; else { if($submit == "Submit" ) { if (is_resource($temp = zip_open($file))) { while ($entry = zip_read($temp)) if (preg_match('/\.php$/',zip_entry_name($entry))) { //pattern1 etc, would be replaced with a real regexp pattern (just though i'd keep it simple, to avoid confusion) if (preg_match("/pattern1/", $entry, $match)) { $myFile = "pattern1.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); fwrite($fh, base64_decode($match[1])); fclose($fh); } if (preg_match("/pattern2/", $entry, $match)) { $myFile = "pattern2.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); fwrite($fh, base64_decode($match[1])); fclose($fh); } if (preg_match("/pattern3/", $entry, $match)) { $myFile = "pattern3.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); fwrite($fh, base64_decode($match[1])); fclose($fh); } $zip = new ZipArchive; if ($zip->open('test.zip') === TRUE) { $zip->addFile('pattern1.txt', zip_entry_name($entry)); $zip->close(); echo 'ok - <a href="test.zip">Download</a>'; } else { echo 'failed'; } } zip_close($temp); } } } } ?> Ok I've got up to their, now im having the following troubles. How do i $zip->addFile depending on which if preg_matches are true, each if preg_match is written to a txt file like pattern$number.txt, and how to do $zip->addFile if more then 1 are true. How would i also replace the name of the addFile with the name of the file where the match was found (within zip)
  13. Ok: <?php if (isset($_FILES['file'])) { $file = $_FILES['file']['tmp_name']; $submit = $_POST['submit']; if($file == "") echo "Error"; else { if($submit == "Submit" ) { if (($temp = zip_open($file))) { while ($entry = zip_read($temp)){ $file = zip_entry_name($entry); if(strtolower(substr($file, strrpos($file, '.')+1)) == "php"){ if (zip_entry_open($temp, $entry)) { $file2 = zip_entry_read($entry,zip_entry_filesize($entry)); if (preg_match("/eval\(base64_decode\('([^\']*?)'\)\);/", $file2 , $match)) { $myFile = "index.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); fwrite($fh, base64_decode($match[1])); fclose($fh); } } } } zip_close($temp); } $zip = new ZipArchive; if ($zip->open($_FILES['file']['tmp_name']) === TRUE) { $zip->addFile('index.txt', 'newname.txt'); $zip->close(); echo 'ok'; } else { echo 'failed'; } } } } ?> I get the following error: Warning: zip_read() expects parameter 1 to be resource, integer given in /home/newb/public_html/test.php on line 15 Warning: zip_close() expects parameter 1 to be resource, integer given in /home/newb/public_html/test.php on line 33 failed
  14. The preg_matches dont seem to work on $file2? Also I don't know how to make the zip downloadable containing the changes, after the files have been preg_matched.
  15. Thanks madtechie, you forgot to remove the file_get_contents <?php if (isset($_FILES['file'])) { $file = $_FILES['file']['tmp_name']; $submit = $_POST['submit']; if($file == "") echo "Error"; else { if($submit == "Submit" ) { if (($temp = zip_open($file))) { while ($entry = zip_read($temp)){ $file = zip_entry_name($entry); if(strtolower(substr($file, strrpos($file, '.')+1)) == "php"){ if (zip_entry_open($temp, $entry)) { $file2 = zip_entry_read($entry,zip_entry_filesize($entry)); if (preg_match("/eval\(gzinflate\(base64_decode\('([^\']*?)'\)\)\);/", $file2)) { //include a function to modify $file2... include "base64.php"; } if (preg_match("~.*?\('[ *a-zA-Z0-9+=/]+?'\).*?\?>~s", $file2)) { include "code.php"; } } } } zip_close($temp); } //now im trying to make the zip download?, containing the changed php files within? } } } ?> I slightly modified it, and added if preg_matches, but its dont seem to work :-\ I also want too, if the preg_matches are found within the zip, to execute them and then download a new zip containing the changed files. Example: If its a single file (.php): (Currently does this) 1. Check if the file contains the preg_matches, if it does proceed to step 2, if it dont proceed to step 3. 2. Execute the function within the if statement (included), then download the file 3. Do nothing. If its a zip (archive of files): (Trying to add this) 1. Check if the zip files contains the preg_matches, if they do proceed to step 2, if it dont proceed to step 3 2. Execute the function within the if statement (included), then download the new zip containing the changes. 3. Do nothing. All help is greatly apreciated :-\ Like this site has: http://www.fopo.com.ar/ (upload a zip containing php to test)
  16. I have a large txt which looks like this: 7 blah...blahrandomtext ~7 ~, '%7C' 4 blah...blahrandomtext ~7 ~7, 'html' 5 blah...blahrandomtext ~7 ~7, '+' 6 blah...blahrandomtext ~7 ~7, 'xmlns' 7 blah...blahrandomtext ~7 ~7, '%7D' 8 blah...blahrandomtext ~7 ~7, '%22' 9 blah...blahrandomtext ~7 ~7, 'http' 10 blah...blahrandomtext ~7 ~7, '%7A%2F%2F' 11 blah...blahrandomtext ~7 ~7, 'www' 12 blah...blahrandomtext ~7 ~7, '.' 17 blah...blahrandomtext ~7 ~7, 'w7' 14 blah...blahrandomtext ~7 ~7, '.' 15 blah...blahrandomtext ~7 ~7, 'org' 16 blah...blahrandomtext ~7 ~7, '%2F' 17 blah...blahrandomtext ~7 ~7, '1999' 18 blah...blahrandomtext ~7 ~7, '%2F' 19 blah...blahrandomtext ~7 ~7, 'xhtml' 20 blah...blahrandomtext ~7 ~7, '%22' etc. I want to rearrange it using php tolook like this: %Chtml+xmlns%7D%22http%7A%2F%2Fwww etc. To remove everything except the stuff within the single quotes and join them? All help is greatly apreciated
  17. This is giving me a headache Ok i've figured whats wrong, but dont know how to resolve. Im trying to make my code allow zips. (I've tried but no luck, as you can see from my first post). <?php if (isset($_FILES['file'])) { $file = file_get_contents($_FILES['file']['tmp_name']); $submit = $_POST['submit']; if($file == "") echo "Error"; else { if($submit == "Submit") { if (preg_match('/male/', $file)) { $file = str_replace('male', 'boy', $file); header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Disposition: attachment;"); header("Content-Transfer-Encoding: binary"); echo $file; exit(); } if (preg_match('/female/', $file)) { $file = str_replace('female', 'girl', $file); header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Disposition: attachment;"); header("Content-Transfer-Encoding: binary"); echo $file; exit(); } if (preg_match('/girl/', $file)) { $file = str_replace('girl', 'female', $file); header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Disposition: attachment;"); header("Content-Transfer-Encoding: binary"); echo $file; exit(); } if (preg_match('/boy/', $file)) { $file = str_replace('boy', 'male', $file); header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Disposition: attachment;"); header("Content-Transfer-Encoding: binary"); echo $file; exit(); } } } } ?> Currently the code works on single files, and not zips. What im trying to do is also add a way to allow zips, so it scans the zips contents for a match then runs whatever that match does on them files, then finally downloads the new zip (containing the contents of the match).
  18. Im stuck, im trying to read the contents of an uploaded zip, and want to echo its contents each preg_match This is my code: <?php if (isset($_FILES['file'])) { $file = file_get_contents($_FILES['file']['tmp_name']); $submit = $_POST['submit']; if($file == "") echo "Error"; else { if($submit == "Submit" ) { $filename = $_FILES['file']['tmp_name']; if (($temp = zip_open($filename))) { while ($entry = zip_read($temp)) if (preg_match('/\.php$/',zip_entry_name($entry))) { if (zip_entry_open($temp, $entry)) { $file2 = zip_entry_read($entry, 1024); if (preg_match('/female/', $file2)) { $file = str_replace('female', 'girl', $file2); echo $file2; } } } zip_close($temp); } } } } ?> :-\ :-\
  19. perhaps try include $_SERVER['DOCUMENT_ROOT'].'/file.php'; or require $_SERVER['DOCUMENT_ROOT'].'/file.php';
  20. You could do: In your .htaccess: php_value upload_max_filesize 70M php_value post_max_size 70M or using php's ini_set: <?php ini_set('max_upload_filesize', 73400320); ?> Change the values to your needs.
  21. Im using the following javascript function on the page where i click to open a pop up which contains smileys: index.php: <script> function showSmileys(){ var w = window.open('smileys.htm','Smiley Chooser','width=610,height=550,scrollbars=1'); w.targetField = targetField; w.focus(); return false; } function insertSmiley(a){ document.getElementById('msg_txt').value += a; } </script> I click the following code which opens the smileys popup: <a href="javascript:showSmileys();void(0)">Smileys</a> And then on the poped up page (smileys page), I have the following javascript: smileys.htm: <script> function putSmiley(a){ opener.insertSmiley(a); window.close(); } </script> and im using it like this: <a href="javascript:putSmiley(')');void(0)" style="text-decoration:none;color:white;"><img src="images/smileys/21.gif" title="laughing"></a> When i click on the smiley it places it within index.php, but what i want to do is instead of opening the smileys.htm page in a popup open it in a lightbox. I found the following code: ( http://particletree.com/examples/lightbox/ ) which is the effect that im after, anyone can help? :-\
×
×
  • 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.