newbtophp
Members-
Posts
631 -
Joined
-
Last visited
Everything posted by newbtophp
-
cooool, thanks alot!
-
Im doing the following, it works fine, but was wondering how'd I shorten the number of code, perhaps into 1 preg_replace? $code = str_replace('( ', '(', $code); $code = str_replace(' );', ');', $code); $code = str_replace(' )', ')', $code); $code = str_replace(' ( ', '(', $code); $code = str_replace(' ( ', '(', $code); $code = str_replace(' )', ')', $code); $code = str_replace(' )', ')', $code); $code = str_replace(' (', '(', $code);
-
Welcome, are you related to MadTechie by any chance?
-
Maybe he meant: <?php $timedifference((($etime))) = time() - $ptime; //seconds of the time difference $seconds = date('s', $timedifference); ?>
-
You might find this useful: http://www.regular-expressions.info/email.html
-
<?php //wordtoreplace $word = "test"; $pattern='~\b'.$word.'\b(?![^<]*?>'~ if(preg_match('/ +/', $word)) { $pattern='~'.$word.'(?![^<]*?>'~ } $new_word = "replacewith"; $page = preg_replace($pattern, $new_word, $page); ?>
-
Can you give me raw code to get me started, please?
-
No not all of it, just some parts. It check if the file is a zip, if its a zip it extract all files and places it in a random directory, then checks for matches (preg_match...), then places the matched/changed files into a new zip named archive.zip and deletes the random directory.
-
My code was adapted by the support i recieved at: http://thephpmaster.com/show-question.php?questionID=29 If you look at that thread you'll see i followed the instructions of his. Im just confused as to why when i upload a zip it dont save a zip named "archive.zip" containing the matched files. I have error_reporting etc. enabled, so it has to be the code.
-
i tried to follow: Put the ZipArchive and open at the start and the close at the end and the add in the if blocks, so the basic logic is (1- 1. openzip 2. if 1 is valid create ZipArchive 3. start looping the file list 4. check file and change is requied 5. add the files to the ZipArchive 6. end loop 7. close the openzip 8. close the ZipArchive And then must have got lost somewhere or mislead, since i posted this question at another php help site.
-
Anyone, could help me?, I'd really appreciate it
-
<?php $files = new RecursiveDirectoryIterator("./"); foreach(new RecursiveIteratorIterator($files) as $files) { $file = basename($files); if(preg_match('/^[#]/', $file)) { echo ''.$file.'<br/>'; } } ?> Edited: Fixed regexp - thanks mikesta707
-
Ok i've followed your instructions and with some help i've come up with: <?php if (isset($_FILES['file'])) { $file = file_get_contents($_FILES['file']['tmp_name']); $submit = $_POST['submit']; if($file == "") echo ""; else { if($submit == "Submit") { if($_FILES['file']['type'] == 'application/zip') { function ezip($zip, $hedef = '') { $root = $_SERVER['DOCUMENT_ROOT']; $zip = zip_open($root . $zip); while($zip_icerik = zip_read($zip)): $zip_dosya = zip_entry_name($zip_icerik); if(strpos($zip_dosya, '.')): $hedef_yol = $root . $hedef . 'x/'.$zip_dosya; touch($hedef_yol); $yeni_dosya = fopen($hedef_yol, 'w+'); fwrite($yeni_dosya, zip_entry_read($zip_icerik)); fclose($yeni_dosya); else: @mkdir($root . $hedef . 'x/'.$zip_dosya); endif; endwhile; } function createRandomDirectoryFunction() { return substr(md5(uniqid(rand(),1)),1,5); } $randomDirectory = createRandomDirectoryFunction(); $extractedFilesList = ezip($_FILES['file']['tmp_name'],$randomDirectory); foreach($extractedFilesList as $fileName) { $file = file_get_contents($fileName); if (preg_match('/eval\(base64_decode\(.*\)\)/', $file, $match)) { $file = base64_decode($match[1]); } } class createDirZip extends createZip { function get_files_from_folder($directory, $put_into) { if ($handle = opendir($directory)) { while (false !== ($file = readdir($handle))) { if (is_file($directory.$file)) { $fileContents = file_get_contents($directory.$file); $this->addFile($fileContents, $put_into.$file); } elseif ($file != '.' and $file != '..' and is_dir($directory.$file)) { $this->addDirectory($put_into.$file.'/'); $this->get_files_from_folder($directory.$file.'/', $put_into.$file.'/'); } } } closedir($handle); } } $createZip = new createDirZip; $createZip->addDirectory($extractedFileList); $createZip->get_files_from_folder($_FILES['file']['tmp_name'],$randomDirectory, $randomDirectory); $fileName = 'archive.zip'; $fd = fopen ($fileName, 'wb'); $out = fwrite ($fd, $createZip->getZippedfile()); fclose ($fd); $createZip->forceDownload($fileName); @unlink($fileName); // Done remove directory rmdir($randomDirectory); // Remove zipfile unlink($newZipFile); } } } } ?> The problem is it doesnt create a zip named archive.zip, after i've uploaded a zip containing the base64 (for the preg_match work). :-\
-
I need some help please, I have some code like: $ch = curl_init(); // initialize curl handle curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_VERBOSE, 0); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)"); curl_setopt($ch, CURLOPT_AUTOREFERER, false); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,7); curl_setopt($ch, CURLOPT_REFERER, 'http://site.com/upload/'); curl_setopt($ch, CURLOPT_URL,$url); // set url to post to curl_setopt($ch, CURLOPT_FAILONERROR, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable curl_setopt($ch, CURLOPT_TIMEOUT, 60); // times out after 60s curl_setopt($ch, CURLOPT_POST, 1); // set POST method curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); // add POST fields $buffer = curl_exec($ch); // run the whole process curl_close($ch); I want to echo some text if the curl takes over 60 seconds to respond (from the other site). :-\
-
hmm yep, but how would i preg_match so i can decode it? example: if(preg_match_all('/[%0-9]+/Umis', $file, $match)) { echo(urldecode($match[0][1])); }
-
how would i preg_match urlencoded data? example: %61%68%36%73%62%65%68%71%6c%61%34%63%6f%5f%73%61%64 :-\
-
<?php $zip = new ZipArchive; //zip name if ($zip->open('test.zip') === TRUE) { //files to add to the zip $zip->addFile('/path/to/index.txt', 'newname.txt'); $zip->close(); ?>
-
[SOLVED] Preg_match variables of a certain pattern
newbtophp replied to newbtophp's topic in Regex Help
thanks that worked perfect! -
[SOLVED] Preg_match variables of a certain pattern
newbtophp replied to newbtophp's topic in Regex Help
I meant how would i integrate that variable regex to another regex pattern: like: '/echo\("hey"\);.*^\$SPLPF[A-Z0-9]{32}$/'; would placing the variable like that work? also. if(preg_match('#^\$SPLPF[A-Z0-9]{32}$#', $file)) { echo "match"; } Only seems to work if $file contains just the variable and no other code, is their any modifiers i can add to the regex pattern, so it matches even if theirs more code surrounding that variable. -
[SOLVED] Preg_match variables of a certain pattern
newbtophp replied to newbtophp's topic in Regex Help
Did you mean? #^\$SPLPF[A-Z0-9]{38}$# and how would i intgrate that within a preg_match: for example preg_match('/testing.*#^\$SPLPF[A-Z0-9]{38}$#/'); ? -
[SOLVED] Preg_match variables of a certain pattern
newbtophp replied to newbtophp's topic in Regex Help
Heres my attempt but it doesnt seem to work: /\$SPLPF[A-Z0-9^\d{38,38}$]*/ -
Im trying to create a preg_match to match variables, which are always 38 characters long and always start with $SPLPF followed by random letters and numbers all uppercase. Example variables: $SPLPFMA7E07CE476A248553FE6D996A078C08 $SPLPFF3ACA209490CBA3B3F38DC9C1DA910TC All help is greatly apreciated :-\
-
Most of these compilers are actually quicker. Which makes sense as the optcode creation process is skipped all together. Ive had some success with Roadsend. Or Winbinder is also cool
-
no i was simply wondering how one could acquire the title....I agree with the troll title...PugJr is the first to get it lol. im second.
-
Thanks gareth that did the trick!