Jump to content

Adam

Moderators
  • Posts

    5,717
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by Adam

  1. This is an extremely inefficient way of doing this. For example this page right now will have several hundred elements on it, and you're looping through every single one of them trying to set the colour property to the name of the element. The JS engine must also validate the colour, because when I did a quick test, a paragraph tag's (<p>) colour wasn't set to "p". Also I don't really understand how you're trying to use this. Are you just running it on pages where the custom mark-up is output? Like for example when viewing the posts on this page, you'd run that script to set the colours of the custom elements? If so, that's a really bad way of doing it. Not sure where the entities come into that either. Personally I'd reconsider your approach to this. Rather than depending on JS - which not every user has enabled - I'd format the custom mark-up using PHP - server-side - before outputting in the HTML. For example: <?php $input = '<pink>my pink text</pink>'; $custom_markup_regexps = array( '/<pink>(.*?)<\/pink>/' => '<span class="pink">$1</span>', '/<red>(.*?)<\/pink>/' => '<span class="red">$1</span>', '/<blue>(.*?)<\/pink>/' => '<span class="blue">$1</span>', // add more here for other replacements ); $output = preg_replace(array_keys($custom_markup_regexps), array_values($custom_markup_regexps), $input); echo $output; ?> The output from that is: Less resource heavy, removes the JS dependency and adheres to standards.
  2. Could you provide a demo URL? Much easier to fix something when you can reproduce the error.
  3. This is normally due to the file using *Nix format line breaks ("\n") and the editor is expecting Windows ("\r\n"). I don't use FileZilla, but it may check the remote server's OS and convert the file to that type - I'm not sure to be honest. What are you using to edit the files? If you're using standard Notepad you should definitely consider upgrading to a more capable editor, that is able to differentiate/convert between the two.
  4. Whatever makes the request, it uses the browser to do it. It's easy to track what requests are being made behind the scenes - even for Flash.
  5. Then all the user has to do is go that URL instead? At the end of the day it's impossible to prevent the user from downloading them. In-fact the user (the browser) has to download it just to play it. All you can do is obfuscate the process, but anyone who wants it will get it. That's why no sites will allow you to listen to a track before you purchase it.
  6. What do you want us to do?
  7. Registered, entered activation code, and got redirected to "/user_center/undefined" with "NO PERMISSION" message.
  8. Perfect, that's exactly the kind of little nuance I was hoping to find out about. Thanks for your response.
  9. I didn't look far away from that one statement before, but you seem to have a series of problems with this code. Where do you define slot (or slots)? What's it supposed to be? .concat() is a method of an array object, so slot should be an array. From what I can tell it will be undefined. var slotNum = $(this).attr('id').substring((slotIdPrefix.length)); The .substring() start parameter starts from 0, so settings it to the length of the prefix will actually be 1 character ahead than you're expecting. slot.concat(slotNum) .concst() expects one or more arrays passed as parameter(s), where as you're passing the string (as mentioned above) so I imagine it's throwing an error. Can you explain what you're trying to do with this code, and what logic should be (in English)?
  10. Okay. You need to use the .length property then: if (slot.concat(slotNum).length > 0) By the way you also had the expression placed within a jQuery selector? Removed it.
  11. That expression will never evaluate to true because .contact() returns a copy of the merged arrays. Are you wanting to check against a successful merge, or that the size / "length" of the merged arrays is more than 0?
  12. Try: print_r($row); Within the loop.
  13. You can't with PHP, only JavaScript. Frames are handled by the browser - the client-side - not by the PHP.
  14. Adam

    PHPBB spider

    I wouldn't use a recursive function. A forum typically has many links, and doing it that way you're going to exhaust the memory limit in no time. Build up a list of URLs, like Google's "index", and process one at a time. You need to differentiate between internal and external and index them accordingly. You should also be considerate and limit the number of requests you make to their servers; one every 10 second or so at most. If not they're likely to block you anyway.
  15. Hey up everyone, This is a bit of an odd question, and kind of hard to explain. Does anybody know whether there's European languages where the text "Step 1" (as an example) should formally be written "Step One" (obviously translated though)? I.e. in a written context it's grammatically correct to write the word, instead of the number..? Thanks Adam
  16. Assuming I'm following what you're asking, an object would probably be the best way. Using an object you can have a separate instance of the gallery pointing to the correct set of images, or wrapper depending on how you do it.
  17. That's because "IndexOf" isn't a function, "indexOf" is though. JS is case-sensitive.
  18. There's a 10px top margin on the DIV surrounding the ads which is causing the problem: <div style="width: 728px; margin: 10px auto 0pt;">
  19. Eh..?
  20. Generally that indicates a MySQL error. mysql_error returns the last error from your session, so trigger an error if mysql_query returns false: $result = mysql_query($sql) or trigger_error('MySQL error: ' . mysql_error(), E_USER_ERROR); That should help you debug the problem.
  21. I wouldn't recommend strip_tags for preventing XSS, but htmlentities as you output the string. Also regex isn't needed for checking string length (unless you wish to go by whole words), strlen should be fine. As for your website vins, it's too much. I have no idea what the site is for or what all those links are. You're just chucking a load of information on a page and expecting people to get it.
  22. Have you tried removing the @s that are possibly suppressing useful errors?
  23. However you store the files internally will have (next to) no noticeable difference to the end-user; they still receive the same HTML content back from the server. If you had a lot of users accessing the website though there may be a slight bottle neck in reading the file, but the main problem you'll have would be in maintaining it. Trying to find a specific point or line or something could be a nightmare, but could be avoided by using a proper file structure.
  24. Or... learn to use Vim. Typing with one hand would never be as fast as two, and I do as it happens type long runs of text start to finish.
  25. If you're searching with regex enabled, you should be able escape the dollar with a backslash.
×
×
  • 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.