Jump to content

Irate

Members
  • Posts

    354
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Irate

  1. You could do something like preg_match("/$findthis/i",$text_to_search) && preg_match("/$this/i",$text_to_search) ? /* code here will be executed if $text_to_search includes both $findthis and $this */ : /* code here will be executed if either only $findthis, only $this or none of both was found in $text_to_search */; Of course, you can refine the conditions to work with the boolean OR operator (||) or something like that.
  2. Your Regular Expression is a bit off... preg_ functions take for each Regular Expression a string which starts with one sign and ends with the same sign, optionally followed by g, i or m (or a combination of those). I noticed that I myself didn't put them in strings, but since I was on my phone, I did not feel like editing it. Anyway. preg_match("~yoursite.co.za/filename.php~i",$_SERVER['HTTP_REFERER']) should do the trick.
  3. You can set up spoof links that show a href attribute of something else and then use header("Location: /new_address.php"), but as user, I'd be highly displeased if a site would try to link me somewhere else than it specified... Example below. <!-- yoursite.php --> <a href="redirect.php">Click to redirect</a> <!-- end of yoursite.php --> <?php // redirect.php if(isser($_SERVER['HTTP_REFERER']) && preg_match(~yoursite\.php~i,$_SERVER['HTTP_REFERER'])){ header("Location: newsite.php"); } else { header("Location: othersite.php"); } // end of redirect.php ?>
  4. I'll give it a try, didn't include any of that in my lecture about Perl, so, eh. Still going to try it out, thanks a bunch.
  5. So, yeah, another of these IIS topics (I would use XAMPP, but I managed to corrupt all of my data (don't ask how hahah)), this time, I added, as the title might suggest, a Script Map for all *.pl files to be handled by C:\Perl64\bin\perl.exe, seeing as I recently downloaded Perl and want to gather some experience working with it. I primarily am interested in using it with the CGI, but I will also use Perl for CLI scripts (and that's working fine), although the CGI tells me that the Perl scripts throw no HTTP headers at me, causing 502 errors. Anyone know if it's a failing Script Map or if there is an .exe file for the CGI I do not know about?
  6. Congratz, hope you do well.
  7. Support button not functioning on mobile browser, tested with Sony Ericsson Xperia Arc S on default browser. Edit: more important, the whole upload function does not work on a mobile browser.
  8. If I'm not mistaken, Android browsers handles click events with propagating up to a higher hierachy. Add, within the click function, the line event.stopPropagation();, which will prevent any event from bubbling up to a higher hierachy element. So, for example, $('#popup').click(function(e){ e.stopPropagation(); /* rest of your code here */});
  9. Some browsers do not always correctly set the charset HTTP header, so I think you could try adding a header("Content-Type: text/html; charset=utf-8"); in your PHP file if you are using one. Otherwise, try getting the Unicode-formatted character encodings for the characters you need.
  10. Try $datasortarray[] = "new value";, that'd add a new element to the end of the array.
  11. <input type="password"> That'll hide the user input from views, if it's that what you need. Otherwise, trq provided a solution.
  12. Your showHide function is captured within a closure - variables, functions, objects and basically everything defined within a closure is unique to the closure. You don't need jQuery for that function, so define it before you start the closure. function showHide() { var head1 = document.getElementById("head1"); var showform = document.form1.head1.checked; head1.style.visibility = (showform) ? "visible" : "hidden"; } (function($){ ... })(jQuery);
  13. If you want the position to stay fixed... did you try adding the CSS { position: fixed; }?
  14. What gristoi said, you can generally pass your data via GET or POST requests (I do recommend using POST requests if the data is confidential - even if POST is only minimally more secure than GET in terms of detectability, GET requests pass the direct variables in the URL and are easily seen even by not-so-tech-savvy members). Example below. jQuery(document).ready(function(){ // lots of code and variable declarations omitted here... I will just assume you have yourvar and yourvalue declared already and that they are strings jQuery.ajax({ url: 'some/dir/some/path.php', data: yourvar + "=" + yourvalue }, function(data){ // do something with the result now console.log(data); // I decided to log it here, even though you would not want to do that in productive scripts }); }); Just a rough draft, that is, but it should do fine as long as you are using jQuery on your server/machine.
  15. If you **want**, you can use JavaScript's DOM methods for that. document.links and window.frames respectively do just that. If you are looking for the PHP version, look up non-greedy repititions. <a href="some/path/link.php">A link here.</a><a href="another/path/link.php">Another link here.</a> The above line would be matched by your RegExp
  16. If you want to use jQuery and have the image on your page, try using jQuery('input[type=button][value^=Reload]').click(function(){...}); To fetch the image, use jQuery().load() or any Ajax-method (GET, POST, whatever you like).
  17. JavaScript has its own specification for XML, fittingly called E4X (EMCAScript for XML) which provides everything you need. Check it on Google or on the ECMAScript specification, you'll find loads of helpful tools. Otherwise, standard DOM methods should work... Like, document.getElementsByTagName("MediaFiles"), do a for loop and then get the MediaFile tags. Simple enough, though relying solely on JS for your script to work is risky if you can do it with PHP.
  18. Do you have jQuery installed on your machine?
  19. Nice to see, nice to see. My programming skills are still developing, such a badge would be, like, the highest achievement I could gain right now. lol.
  20. Custom Constructors can be created with functions as mentioned above (actually, functions returning this or a property of this can also be used neatly for imitating classes as you know them in Java). For example, assuming that I want to create a global constructor "TypedArray", I'd write something like this... window.TypedArray = function(typeToUse /*, args (as array or array elts) */) {this.type = typeToUse;this.new_array = [];if(arguments.length > 1) {for(var i = 0; i < arguments.length; i++) {if("array" !== typeof arguments[i]) {if(this.type !== typeof arguments[i]) continue;this.new_array[this.new_array.length] = arguments[i];} else {for(var n = 0; n < arguments[i].length; n++) {if(this.type !== typeof arguments[i][n]) continue;this.new_array[this.new_array.length] = arguments[i][n];}}}}return this;}; var x = new TypedArray("string"); // define a new typed array var a = x.new_array; // a is now the array var t = x.type; // t now holds the value of typeHope that helped you a little bit. Edit: Fixed code formatting... made a mistake with closing a comment... code=auto:0 also messed up spacing... Oh, whatever.
  21. Use alert() and set document.cookie for those purposes.
  22. You could save them in your database as name without accents and when a user searches for them, you output the name with accented characters using possibly a switch statement and str_replace. Though that'd imply that the correctly spelled name wouldn't be found either.
  23. return terminates a function block, echo just echoes it and continues function execution, so it will eventually return undefined. Which is mostly not what you want. If you want functions to hold a variable throughout your program, always use return.
  24. You are comparing a string to another string, h1w1 will never equal t. If you want to compare to a global variable, declare the variable as property of the window object and compare again.
  25. Use document.querySelectorAll() or jQuery, then it's possible, yes.
×
×
  • 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.