Jump to content

kicken

Gurus
  • Posts

    4,704
  • Joined

  • Last visited

  • Days Won

    179

Everything posted by kicken

  1. There are a couple things you can do. You can set document.scrollTop to a value to scroll to a particular point on the screen. Setting it to the same value as document.scrollHeight will take you to the bottom of the page. If you want to show a specific element you can call element.scrollIntoView() which will cause the browser to scroll so that element is visible on the page. So for your member signup form you could do: document.getElementById('membership_signup_form').scrollIntoView();
  2. Sounds to me like the server is probably running mod_security or similar and has a filter setup to deny any requests containing CD followed by a /. Possibly setup to try and prevent attacks involving sending shell commands. You'll have to talk to the hosting company/server admin about it if that is the case.
  3. mysql_fetch_array only returns one row. You need to call it multiple times to get the rest of the rows. This is typically done with a while loop: while ($row=mysql_fetch_array($res)){ //do something }
  4. If it were a case of the host being hacked the only thing really would be to change hosts. However, it is far more likely that the problem is the result of your FTP password being stolen (keylogger, sniffed, virus, etc), or the file being modified via a vulnerability in something of yours (php script, cms, etc). People always want to blame the host when something like this happens, but rarely is it ever actually the hosts fault.
  5. The namespace is included in the parameter passed to your autoload function. So when loading the Template class for instance the variable $class in your autoload function will be 'Cleep\Classes\Cleep' not just 'Cleep' You need to strip off that namespace prefix before you test for the file's existance since you seem to just want the class name for your file test/require statements.
  6. My quick benchmarks seem to indicate the first one is faster, but only just barely. I'm not sure how big your bigstring is, I tested using the contents of a 22MB file which is definitely a big string. With such a big string a single run took a few seconds so I only ran it a few times rather than a few thousand. Results: Begin testing, num tests = 9 //Method 1 Total time: 27.806; tracked 1 points Time track: Point: Method 1 end From start: 27.806 From prev: 27.806 //Method 1(alt) Total time: 3.093; tracked 1 points Time track: Point: Method 1 (alt) end From start: 3.093 From prev: 3.093 //Method 2 Total time: 28.880; tracked 1 points Time track: Point: Method 2 ends From start: 28.880 From prev: 28.880 //Method 2(alt) Total time: 4.881; tracked 1 points Time track: Point: Method 2 (alt) ends From start: 4.881 From prev: 4.881 //Method 3 Total time: 3.474; tracked 1 points Time track: Point: Method 3 ends From start: 3.474 From prev: 3.474 Method 1(alt) and Method 2(alt) are the same as method 1 and 2, but using str_replace+explode rather than preg_split. Method 3 is str_replace+explode and a for loop rather than the while loop. <?php require 'timer.php'; $bigstring = file_get_contents('bigstring'); $runCount=0; $numTests=mt_rand(1,9); echo "Begin testing, num tests = {$numTests}\r\n"; marktime(false, 'Method 1 begin'); for ($runCount=0; $runCount<$numTests; $runCount++){ unset($result); $temp = preg_split("/(\r?\n)/", $bigstring); $temp_size = count($temp); $n = 0; while($n < $temp_size) { $result[$temp[$n]] = $temp[$n + 1]; $n = $n + 2; } } marktime(true, 'Method 1 end'); echo "\r\n"; marktime(false, 'Method 1 (alt) begin'); for ($runCount=0; $runCount<$numTests; $runCount++){ unset($result); $temp = explode("\n", str_replace(array("\r\n","\r"), "\n", $bigstring)); $temp_size = count($temp); $n = 0; while($n < $temp_size) { $result[$temp[$n]] = $temp[$n + 1]; $n = $n + 2; } } marktime(true, 'Method 1 (alt) end'); echo "\r\n"; markTime(false, 'Method 2 begin'); for ($runCount=0; $runCount<$numTests; $runCount++){ // Later method. unset($result); $temp = preg_split("/(\r?\n)/", $bigstring); foreach(array_chunk($temp, 2) as $part){ $result[$part[0]] = $part[1]; } } markTime(true, 'Method 2 ends'); echo "\r\n"; markTime(false, 'Method 2 (alt) begin'); for ($runCount=0; $runCount<$numTests; $runCount++){ // Later method. unset($result); $temp = explode("\n", str_replace(array("\r\n", "\r"), "\n", $bigstring)); foreach(array_chunk($temp, 2) as $part){ $result[$part[0]] = $part[1]; } } markTime(true, 'Method 2 (alt) ends'); echo "\r\n"; marktime(false, 'Method 3 begin'); for ($runCount=0; $runCount<$numTests; $runCount++){ unset($result); $temp = explode("\n", str_replace(array("\r\n","\r"), "\n", $bigstring)); for ($i=0,$len=count($temp); $i<$len; $i+=2){ $result[$temp[$i]] = $temp[$i+1]; } } markTime(true, 'Method 3 ends'); echo "\r\n"; ?>
  7. You should redirect the stderr stream to dev null as well, using a line like this: exec("/usr/bin/php /home/myaccount/public_html/test/script1.php >/dev/null 2>&1 &"); Beyond that, make sure you have the correct path to your script1.php file, and also to the php executable. If you have SSH access to the server you can run the command which php to find out the path to the PHP binary.
  8. Yes, the condition you posted as your example is valid: WHERE field > minimum AND num < maximum You could also use the BETWEEN operator to do a range search. WHERE field BETWEEN minimum AND maximum
  9. Mysql uses CMake to configure it and generate the make files. Make sure you have that installed, then run cmake -L . in the root of the mysql source directory to view the variables. A few how-to's about using cmake might be worth reading.
  10. Add checks to the pages to ensure the parameters you need are present. If they are not, re-direct them somewhere that seems appropriate. For example with your articles: if (!isset($_GET['articleID'])){ //header redirect //to an article listing. }
  11. No, it isn't. There is no requirement that you limit a form field's length. I hardly ever use the maxlength attribute in my HTML. Only for things like a zipcode or when I want a two-letter state abbreviation pretty much. I always just enforce a length in the PHP if it is required, let the user submit whatever they want. In the particular case of passwords, I don't enforce any type of maximum length, only minimum. If a user wants to write out a book for their password, so be it. I will use small phrases for my passwords typically, provided the site lets me. It's quite annoying when a site rejects a password because it's two long or contains an "invalid" character.
  12. Guess I didn't read close enough to notice you used SCRIPT_NAME rather than PHP_SELF. My bad there. A person can always modify your action attribute once they have the page in their browser, it doesn't matter if you fill it in, leave it blank, or leave it out all together. All they have to do is either save the file, change the html, and then open it locally, or use one of the many browser development tools such as firebug or chrome's console to edit the HTML on-the-fly.
  13. Can the user re-produce it on-demand, or is it a random occurrence? If they can re-produce it on demand the easiest thing to do probably would be to try and get them to use something like teamviewer to let you monitor their session remotely and watch what they do. Otherwise what your looking for is basically a keylogger program, most of which are designed to capture everything and not be that easy to remove. Perhaps someone else knows of something out there fitting your requirements though.
  14. The thing with echoing out $_SERVER['PHP_SELF'] is that someone can modify it's value to include data you don't intend to be there, possibly leaving you open to XSS attacks. If your going to echo it out then you should at least run it through htmlentities() like you would other user-defined values. Some people suggest using action="" because in HTML4, when the action is set to an empty URI, that is handled the same as setting it to the current page. In HTML5, this is not allowed however and if you specify an action it has to have a valid URI value. For HTML5 you can achieve the same behavior (submit-to-self) by just not including the action attribute.
  15. I'd say it depends on what the field is. For text fields like names, urls, emails, etc I generally just let it be an empty string and define the field not null. If the field is storing an ID value which is a reference to another table, or a date/time value, I will set it to NULL when left empty, rather than use a value like 0 or something.
  16. Why not? The statement is true, in my experience and observations anyway.
  17. The only fields you generally don't re-populate are sensitive information fields such as a password, cc number, ssn, etc. Most of the time if the field is invalid it is going to be just a small typo the user made, such as missing the . in their email or something. It's somewhat annoying to have to re-type it all when all you really need to do is made a small adjustment.
  18. use COUNT(DISTINCT visitor_id) in your query.
  19. Look at the syntax highlight above. Your heredoc inside the logo function is not being terminated properly, so the definition for your contactInfo function is being treated as part of the string.
  20. You just have to use a foreach loop to find the value. Such as: $found=null; foreach ($penfListData as $v){ if ($addF == $v['userID']){ $found=$v; break; } } if (!$found){ //id does not exist. }
  21. A user's information (their name, bio, whatever) would typically just be in the same table as their username and password, so you would just have three tables: [*] users (storing the login and personal info) [*] guestbook (storing all guestbook entries) [*] photoalbum (storing all photos) In order to link the guestbook and photo's to the proper user, you include a user_id column in those tables which has the same value as the user_id column from the users table. Then you just select from those tables the entries WHERE user_id=$theLoggedInUser
  22. The only option for an unregistered (or unlogged in) visitor is to store a cookie and track them that way. If they are going to be voting on a lot of things, then generate a unique hash value for them and store that value in your database for your votes. Set a cookie with that hash value and whenever they try and vote look to see if that hash has already voted, same as you would for a logged in member and their user_id.
  23. '0' is considered to be empty by the empty function, so you are always hitting that branch. Use isset() to check if it exists instead.
  24. A single equal sign is an assignment. What your doing there is assigning an empty value to $username, rather than checking to see if it is empty. You need to use double-equals to test for a condition: if ($username == ''){
  25. It depends on what you want to happen. If you want to kill the script then use exit. If you just want to leave the current function but keep the script going, use return
×
×
  • 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.