Jump to content
Larry Ullman's Book Forums

HartleySan

Members
  • Posts

    3047
  • Joined

  • Last visited

  • Days Won

    243

Posts posted by HartleySan

  1. Note that the proxy script you write to retrieve the images will run on a separate process thread, thus the header issue is not a problem.

     

    For example, all the images you want to load via the proxy script will require markup like the following:

    <img src="image_proxy_script.php?img=image1.png">

    You can have as many of those image tags as you want on the page, as they will all invoke separate processes, thus not causing any issues.

     

    To answer your second question, I imagine that you'd want to construct a data model that allows you to loop through an array where each element is a post and all the data surrounding that post, including the URL to the avatar image.

    As such, one SQL call to get all the avatar images makes the most sense to me. In fact, I imagine that with the proper joins, you could get all the post info you need in one query.

     

    With all that said though, please note that for each img tag you have in your markup, a separate HTTP request will be made for those images. That is how the protocol works and is unavoidable.

  2. Okay, I think I understand what you're asking now.

    Like I said before though, this is not a trivial task, and will require the use of at least one very complicated regex.

    To get you started, please look at the following:

    http://stackoverflow.com/questions/161738/what-is-the-best-regular-expression-to-check-if-a-string-is-a-valid-url

     

    If you're still up for the challenge, give it a go and report back with any problems you find.

  3. I still don't really understand your question, but it sounds like you are turning all HTML special characters into HTML entities before inserting the data into the database, and you then want to (sometimes) turn the a links back into actual links. Is that correct?

     

    Operating on that assumption, I have a few comments:

    1. I would not recommend altering the user input before it's put in the DB. I would alter it as need be every time you retrieve it for view purposes. Keeping the input in its raw form in the DB will give you maximum flexibility.
    2. To do a mass string replace across disparate values, you're going to have to use regexes. This is not a trivial task if you're not used to it. I warn against attempting this because of #3 below.
    3. Allowing for clickable links from user input is one of the biggest security risks you can imagine. I would be very careful about how you handle this.

     

    With all that said though, I'm still not sure I understand your question, so please clarify. Thank you.

  4. I will admit that the CKEditor interface is a bit annoying to get used to, but basically, you need to first get the container element of the text through some sort of DOM selector (or by looping through the CKEditor interfaces from the CKEditor object).

    From there, you have to either use the value property or textContent/innerText to get the text within the container, and then reference the length property of that string.

     

    It's hard to give a more specific answer than that without some code to reference, but that's the basic premise.

  5. I've only used MariaDB briefly, but it seemed totally fine to me.

     

    Also, to be honest, I've never really been one to utilize all the latest-and-greatest most products have to offer, so I'm probably not the best one to comment on the feature sets of MySQL and MariaDB.

    I generally stick with MySQL only because it's what everyone uses and it has the established history and support.

     

    For the most part though, I always stick with basic CRUD queries using prepared statements, which all RDBMSs support anyway, so I'm pretty much RDBMS-agnostic.

     

    Anyway, please let us know what your experience is if you use it.

    Thanks.

  6. It won't "automatically" execute, per se, but it will execute because you have the parentheses after the function name.

    Any time you put parentheses after a function name, the function will be called. The only difference from my code and yours is that the return value of the regularExpressionMatchFunction function is then sent as an argument to the push method of the returnVals array (in one line of code).

    You could, of course, pull the code out across a couple of lines for clarity's sake, but I really don't think it necessary in this case.

     

    Also, I'm more than happy to help, but I would recommend a couple of things in the future:

    1. Try not to rely on me and this forum too much. Really, really try to do things yourself before coming here. It's not that we don't want you here; it's more that I think you'll grow more as a programmer if you try more to solve problems you encounter yourself. Sure, it can certainly be frustrating (believe me, I know), but I think maybe giving problems you face a little more time yourself before coming on here will help you grow.
    2. Please make more of a concerted effort to clearly explain any problems you're having and provide legible code snippets in your posts. Whenever I make a post asking for help here or on Stack Overflow, etc., I always re-read my post many times and edit it accordingly before actually posting it to make it as simple and straightforward as possible for anyone that may potentially help me. Doing so will make it much more likely that people will in fact try to help you.

     

    Anyway, I'm glad you solved your problem!

    • Upvote 1
  7. angels, please use the <> button in the site editor to mark your code. Your code is still hard to read.

     

    Anyway, as a general solution, I would first always return flagVariableNoError from the regularExpressionMatchFunction function, regardless of whether it is true or false.

    I would then have that return value stored in an array of return values. For example, at the top of the validateFormOnSubmit function, define a new variable as such:

    var returnVals = [];

    Then, store each of the values returned by the regularExpressionMatchFunction function calls in the array like so:

    returnVals.push(regularExpressionMatchFunction("firstName", /^[A-Za-z'\.]+\s*[A-Za-z'\.\s]*$/, "The name must include alphabetical letters \(and can include apostrophes, periods, and spaces\)"));

    Then, after all the regularExpressionMatchFunction function calls are complete, do something like the following:

    for (var i = 0, len = returnVals.length; i < len; i += 1) {
      if (!returnVals[i]) {
        return false;
      }
    }
     
    That answer your question?
    • Upvote 1
×
×
  • Create New...