Jump to content

Simon Lloyd

Members
  • Posts

    26
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Simon Lloyd's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks guys, i used closedir($handle) and now no error, now it just shows me a list of directory contents, thanks again
  2. Hi all, firstly let me say im not a coder but can just about get by, i have the code below in a file (delfile.php) it's function is to delete files in the designated directory if they are over a month old, i'm running it via a cron job in cpanel and the line to run it is: php /home/xxxxxx/public_html/delfile.php When the cron runs i get this error returned in the cpanel email telling me the contents of the file and then this error underneath, what have i missed or done wron in the code below? Fatal error: Call to undefined function close() in /home/xxxxxx/public_html/delfile.php on line 33 <?php // if you not running this script in the directory // then you must add directory to the file you are // reading. $directory = '/home/xxxxxx/public_html/expupload'; $latesttime = time (); $handle = opendir ( $directory ); while ( false !== ( $file = readdir ( $handle ) ) ) { if ( $file != '.' && $file != '..' ) { $path = $directory . '/' . $file; echo $file . "<br>"; $filetime = filemtime ( $path ); echo $filetime . "<br>"; $dtime = ( $latesttime - $filetime ); if( ! is_dir ( $path ) && $dtime >= 604800 ) { unlink ( $path ); } } } close ($handle); ?> Regards, Simon
  3. I dont know what i can show you, vbulletin has a plugin system where you choose a hook (a pre programmed location or execution point) plop in your php code but without <? at either end and your away! (providing the code works)
  4. Ok, well i think that i've come to the end of what i can do without really annoying you, the code i posted a couple of posts ago works great (with the negative assertions) apart from working with FUNCTION so i guess i'll remove that and live with it. I have to say hats off to you for sticking with me this far, i appreciate what you've been trying to do and am sorry that there are just some things that i can't convey very well due to lack of knowledge,but again thanks Regards, Simon
  5. I simply copied it verbatim, however i removed what seemed to be an erroneous ' just before IF and the error i now get is: so i guess it needed the '
  6. I implemented it by replacing all the code for that supplied, running it last time and with the revised code gave this error i know you were expecting an error and for it to give you some clue but other than a delimiter issue i cant help you understand my issue
  7. I tried that and it gave an error relating to preg_replace, didnt catch it because it was up briefly, it didnt echo the $data!
  8. Im on php 5.2.17, a lot of my add-ons..etc wont function in php5.3.x unfortunately, thanks for that i'll give it a try
  9. Ok, this works perfect but only if i remove the: Function MyTest() blah End Function The word Function makes it nuts!, any ideas? $post['message'] = preg_replace('/\\[code\\](.*)(?<!\[\/KODE\])\\[\/code\\]/siU', '[KODE]\\1[/KODE]', $post['message']); $post['message'] = preg_replace("/(?<!\[KODE\]|End\s)Sub(?<!\s\[\/KODE\])(.*)End Sub/siU", '[KODE]Sub \\1 End Sub[/KODE]', $post['message']); $post['message'] = preg_replace("/(?<!\[KODE\]|End\s)Function(?<!\s\[\/KODE\])(.*)End Function/siU", '[KODE]Function \\1 End Function[/KODE]', $post['message']); So how can we change the last preg_replace to ignore the word FUNCTION as a command word? Regards, Simon
  10. Hi would it help to have test forum access (although you'd have to replace [ code ] tags there) or would it help to have the bbcode.php?, to be honest with you all that needs checking is, is there already a [KODE] tag there before SUB or FUNCTION if yes skip END SUB or END FUNCTION and look for next SUB or FUNCTION do the check again if no [KODE] tag is present then add [KODE]just before it, find the next END SUB or END FUNCTION and after it add [/KODE]. Like i said above the one where i do each seperately works but too well as it doubles or tripples up depending on how many instances of code there are in the post being made, thats why i tried adding the negative assertion code to one of them to try it but couldn't get the syntax correct. I appreciate this is probably frustrating to you and really appreciate you sticking with it. Regards, Simon
  11. Sorry $MyString should read differently $pattern1 = "/(?<![KODE])Sub\s/"; $pattern2 = "/(?![/KODE])End Sub/"; $pattern3 = "/Function\s/"; $pattern4 = "/End Function/"; $replace1 = "[KODE]Sub "; $replace2 = "End Sub[/KODE]"; $replace3 = "[KODE]Function "; $replace4 = "End Function[/KODE]"; $post['message']= preg_replace($pattern1, $replace1, $post['message']); $post['message']= preg_replace($pattern2, $replace2, $post['message']); $post['message']= preg_replace($pattern3, $replace3, $post['message']); $post['message']= preg_replace($pattern4, $replace4, $post['message']); $post['message']= preg_replace('/\\[code\\](.*)\\[\/code\\]/siU', '[KODE]\\1[/KODE]', $post['message']); I tried adding the negative assertion to check the beginnig and end, i got an error back "..Unknown qualifier "K"...", so i tried to escape it like this \\[KODE\\]..etc but still an error, im just shooting in the dark as i don't have the foggiest what im doing. Regards, Simon
  12. Would it be easier to go back to pattern1 = "/Sub\s/"; $pattern2 = "/End Sub/"; $pattern3 = "/Function\s/"; $pattern4 = "/End Function/"; $replace1 = "[KODE]Sub "; $replace2 = "End Sub[/KODE]"; $replace3 = "[KODE]Function "; $replace4 = "End Function[/KODE]"; $MyString= preg_replace($pattern1, $replace1, $post['message']); $MyString= preg_replace($pattern2, $replace2, $post['message']); $MyString= preg_replace($pattern3, $replace3, $post['message']); $MyString= preg_replace($pattern4, $replace4, $post['message']); $MyString= preg_replace('/\\[code\\](.*)\\[\/code\\]/siU', '[KODE]\\1[/KODE]', $post['message']); and maybe add /(?<![KODE])Sub/ will only match "Sub" if it is not preceded by "[KODE]". I found that on the net but i don't know how to implement it for each of the expressions and i especially have no idea how to implement it for following "End Sub"...etc Regards, Simon
  13. Ok changed the entire for each like this //foreach( $matches as $match ) { //if( !empty($match[1]) ) // check if [kode] was found //continue; //$parsed[] = array( //'name' => $match[3], //'arguments' => $match[4], //'body' => trim($match[5]) //); //} foreach( $matches as $match ) { if( !empty($match[1]) ) // check if [kode] was found continue; echo "[KODE]$match[2] $match[3]($match[4]) $match[5] End $match[2][/KODE]\n"; } There wasn't a replacement if no tags existed and no echo and there wasn't the echo if tags existed, i even replaced echo with print but nothing appeared?
  14. It didnt make any replacements at all, why would that be do you think? in the previous preg_replace it worked too well and doubled sometimes tripled up so im wondering why your latest solution didnt replace anything? even if i tested with only one section of data to look at Sub Test() If This = "" Then Msgbox "This is that" End If End Sub it didnt replace anything in that string, did i need the print command uncommented? i thought that may have just been to show the results on screen? Regards, Simon P.S When i said i'm no young pup i meant you cant teach an old dog new tricks well not quickly anyway!
  15. Lol, i understand you we're trying to teach me (and im no young pup!) and vbulletin has a plugin area designed specifically for php where you just add the php code without the start and end <?. I dont understand REGEX or the scenarios of where we'd use look forward, look back, look around...etc, so i have to admit i was looking for a solution which i could then later try and decipher as to why it works and what it's doing. Still, ido appreciate everything you've done so far, thanks Regards, Simon
×
×
  • 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.