Jump to content

.josh

Staff Alumni
  • Posts

    14,780
  • Joined

  • Last visited

  • Days Won

    43

Everything posted by .josh

  1. is there a reason you can't include them both? <script type="text/javascript" src="B.js"></script> <script type="text/javascript" src="A.js"></script> But anyways, if you want to "include" a javascript file within another javascript file you can do this: document.write(unescape('%3Cscript src="B.js" type="text/javascript"%3E%3C/script%3E')); or this: var obj = document.createElement("SCRIPT"); obj.type = "text/javascript"; obj.src = "B.js"; document.body.appendChild(obj);
  2. c/ping that code and example content works fine for me, are you using the right variable for the subject? I see you have $data...is that the right variable? If so, then your problem is still somewhere else, that regex is fine, based on the example content you listed.
  3. It has a Magical Trevor feel to it
  4. there are literally hundreds of posts here asking this exact question. Please use the search function.
  5. Sounds like if you move it to Zend, it will be additional work, which the client might not be too keen on paying for, unless you can make a really good case for why it would be better in the long run. But even then, the client and her resources may not even know how to work with Zend, so it will be harder on them to use Zend (more time/resources spent on them learning Zend).
  6. hmm...maybe your server isn't setup to recognize short tags... okay try also changing this line var servertimestring=(servermode=="server-php")? '<? print date("F d, Y H:i:s", time())?>' : (servermode=="server-ssi")? '<!--#config timefmt="%B %d, %Y %H:%M:%S"--><!--#echo var="DATE_LOCAL" -->' : '<%= Now() %>' to this: var servertimestring=(servermode=="server-php")? '<?php print date("F d, Y H:i:s", time()); ?> ' : (servermode=="server-ssi")? '<!--#config timefmt="%B %d, %Y %H:%M:%S"--><!--#echo var="DATE_LOCAL" -->' : '<%= Now() %>'
  7. Super cheap to distribute (which gets passed on to the customers) and saving lots of trees in the process is a mad obsession? Don't get me wrong, I too like to read printed newspapers, magazines or books. And up until relatively recently, it hasn't really been all that practical to use the electronic versions unless you happened to be sitting in front of a computer. But as technology progresses, access to them is becoming easier. That's why products like the Kindle are so popular. Yeah...still "not the same" and no argument there, but the benefits far outweigh the cost to the point that the "but I like printed..." is little different than a "I am old and set in my ways" argument.
  8. and you are sure that your "WAMSERVER" is setup correctly and correctly running php? Make a page with the following code <?php echo "test"; ?> does that show a page with "test"?
  9. okay well then where are you trying to run that script? That script expects to be run from either a php or ssi server. Are you trying to run it locally on your computer with no server setup?
  10. .josh

    Help with Regex

    okay maybe it might help if you explain what you are actually trying to do with the matched stuff and what you are trying to replace it with. For example, if I have this: <?php function someFunction ($matches) { // $matches[0] is the full current match // $matches[1] is whatever the value of your s param is // $matches[2] is whatever the value of your a param is echo "<pre>";print_r($matches); echo "</pre>"; // do whatever calculations, assumed resulting, final string you want to replace the pattern with is put into $replacement return $replacement; } $message = "hen an unknown printer took a galley of type and localhost/view.php?s=324&a=2433 scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic localhost/view.php?s=33&a=222 typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing"; $regexExpr = "~localhost/view.php\?s=([0-9]+)&a=([0-9]+)~" ; $message = preg_replace_callback($regexExpr, "someFunction", $message); ?> I get the following output: Array ( [0] => localhost/view.php?s=324&a=2433 [1] => 324 [2] => 2433 ) Array ( [0] => localhost/view.php?s=33&a=222 [1] => 33 [2] => 222 ) Each time there is a match, the function is called and I dump out the contents of $match. As you can see, $matches[0] is the full current match, $matches[1] is the first captured group (the value of s param in the string) and $matches[2] is the value of the 2nd captured group in your string (the a param)
  11. .josh

    Help with Regex

    need to see the actual pattern, what $regexExpr2 is
  12. .josh

    Help with Regex

    no...preg_replace_callback() will effectively allow you to do string>array for pattern>replacement, though it actually lets you do a lot more than that. You make a call to a specified function for each match found, as it is found, and replace the found item with whatever you return from the function. 1. Match 2. Call function, passing match 3. replace match with whatever is returned from function 4. repeat 1-3 until no more matches So for instance: function someFunction($matches) { $m = $matches[0]+1; return $m; } $content = "123"; echo $content . "<br/>"; $content = preg_replace_callback("~\d~","someFunction",$content); echo $content; output: 123 234 So you would basically do function someFunction ($matches) { // $matches[0] is the full current match // $matches[1] is whatever the value of your s param is // $matches[2] is whatever the value of your a param is // do whatever calculations, assumed resulting, final string you want to replace the pattern with is put into $replacement return $replacement } $regexExpr = "~localhost/view.php\?s=([0-9]+)&a=([0-9]+)~" ; $message = preg_replace_callback($regexExpr, "someFunction", $message); edit: I edited it to use captured groups in the regex so you can skip having to do that foreach loop you had...
  13. .josh

    Help with Regex

    I'm guessing you don't have error reporting turned on... ...looks like based on comment in your code, with that last preg_replace() you are trying to use a single pattern but an array of replacements (string>array). With preg_replace, the pattern>replace can be string>string, array>string or array>array, but not string>array. So you basically have three choices. First choice would be to put that last preg_replace() in a loop (you can put it in your current foreach loop or use another loop) and then limit the preg_replace() to one replacement at a time (you do this with optional 4th argument of preg_replace()). This will only really work if your replacement is changed to the point that the pattern will not match it again after the replacement (I have no idea whether or not your replacement does this because you didn't post that part of your script). 2nd choice would be to basically make an array for your pattern argument that has same amount of elements as your replacement and each element of the array just has the same pattern. You will need to use 4th argument for this way too, and it also would depend on same thing as option 1 as far as whether or not the pattern will rematch the replacement. 3rd choice is to move forward with the preg_replace_callback() option, which is what I vote you should do, as it is cleaner and built for this exact type of scenario.
  14. You cannot get a user's IP address with javascript so the answer is no.
  15. Try changing new showLocalTime("timecontainer", "server-ssi", 0, "short") to new showLocalTime("timecontainer", "server-php", 0, "short")
  16. Not possible. This is cross-site scripting (XSS) and not allowed for what should be obvious security reasons.
  17. You had a problem with your script's logic and making a call to an arbitrary function at a certain time, which is not relevant to the point of the stickie. p.s. - but I'm glad you sorted your problem out
  18. .josh

    Help with Regex

    You need to escape the ? as it has special meaning in regex. \? instead of ? Also, your patterns need to have a delimiter. $regexExpr = "~localhost/view.php\?s=[0-9]+&a=[0-9]+~" need to apply that to your other patterns too Also you can probably make your code more efficient overall by combining those 3 preg functions and loop by using preg_replace_callback instead
  19. When there is a match, the first element in the matched array (element 0) is always the full pattern match. Everything between your /.../ forward slashes is the full pattern. Each element after that represents the matches for each captured group you have in the pattern. Captured groups are the parts of the pattern between the parenthesis.
  20. Are you seriously asking how to register and login to facebook, twitter, etc...? Is that what you are really asking? Perhaps you need to clarify...
  21. Well if you happen to find what you're looking for then post it, as I am always interested in playing with words
  22. you do what I showed you in my post... assign the noconflict to a variable and use $yourvariable instead of $ and I gave an example using your first line of code...
  23. .josh

    PHP Regur

    urlencode
  24. Lookin' to shake your willy in front of a web cam for $2.99 per minute?
  25. for good measure, you could do: $pattern = '~((ht|f)tps?|irc)://[^\s]*~i'; This will also match https, ftp and irc protocols.
×
×
  • 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.