Jump to content

Daniel0

Staff Alumni
  • Posts

    11,885
  • Joined

  • Last visited

Everything posted by Daniel0

  1. Take the first line. Start with the number 0. Each time you encounter a (, add 1, when you encounter ) subtract 1. If you don't end up with 0 again you are missing some
  2. They work on the HTTP protocol only so if you run the cron job via HTTP, cookies will work.
  3. Do you know what the preprocessor is? The lines starting with hash marks are what's called preprocessor directives. The preprocessor is run before the compiler. The #define directive defines a constant, so when the preprocessor runs it will, in this case, go through the source code and everywhere it finds IDR_MYMENU it will replace it with 101. Then the compiler will run.
  4. You must include or require the file that contains the captcha class.
  5. I think Mr. Jobs is just talking out of his ass here.
  6. So you want to check if it contains any of the words in the array? Then like this perhaps: $results = "I am testing this right now"; $options = array("am", "yes", "check"); $results = explode(' ', preg_replace('#[^a-z ]#', '', strtolower($results))); if (count(array_intersect($results, $options))) { echo 'Successful'; } Or like this: $results = "I am testing this right now"; $options = array("am", "yes", "check"); foreach ($options as $option) { if (preg_match('#\b' . preg_quote($option, '#') . '\b#i', $results)) { echo 'Successful'; break; } }
  7. Looks like something like this: #!/bin/bash find /home/***/conv/processed -mtime +1 -exec rm {} \; find /home/***/conv/uploaded -mtime +1 -exec rm {} \; find /home/***/conv/tmp -mtime +1 -exec rm {} \; find /home/***/public_html/tmpvidstore -mtime +1 -exec rm {} \; find /***/fetchmp3/public_html/convlog -mtime +1 -exec rm {} \; for DIR in `echo /home/***/public_html/vidcache/*` do find $DIR -mtime +7 -exec rm -rf {} \; done Would do the same.
  8. AKA cloaking, a technique the big search engines would ban you for. It's explicitly prohibited in Google's webmaster guidelines.
  9. Any reason why you don't just write it in bash?
  10. Then you can use reflection. This should work: <?php function callFunction($callback, array $arguments = array()) { if (is_array($callback)) { if (count($callback) == 2 && (is_string($callback[0]) || is_object($callback[0]) && is_string($callback[1]))) { $class = is_object($callback[0]) ? get_class($callback[0]) : $callback[0]; $function = $callback[1]; $reflection = new ReflectionMethod($class, $function); } else { throw new InvalidArgumentException('Invalid callback'); } } else { $reflection = new ReflectionFunction($callback); } $params = $reflection->getParameters(); foreach ($params as $i => $param) { if (!$param->isOptional() && !isset($arguments[$i])) { throw new RuntimeException('Missing required argument ' . ($i + 1)); } } if (is_array($callback)) { if (!is_object($callback[0]) && !$reflection->isStatic()) { throw new RuntimeException('Cannot statically call a non-static method'); } else if (!is_object($callback[0])) { return call_user_func_array($callback, $arguments); } else { $return = $reflection->invokeArgs($callback[0], $arguments); } } else { $return = $reflection->invokeArgs($arguments); } return $return; } The $callback supports the regular callback format except the Class::method() notation. Exceptions are good because they can be caught. Errors cannot easily be caught.
  11. Well yeah, but I just consolidated it into a single statement.
  12. And that requires the error message from MySQL which you can get using mysql_error().
  13. if (!mysql_num_rows(mysql_query("SELECT * FROM users WHERE username='admin' LIMIT 1"))) { // insert user }
  14. I didn't mean you should scrap error handling. You could do one of the alternative I proposed: or trigger_error('Query failed: ' . mysql_error($db), E_USER_ERROR); (assuming $db is your MySQL connection handle)
  15. Well, yeah just run a query selecting users with that username. If the result set is empty the user doesn't exist and you can run your insertion query.
  16. That is why you according to this blog post, which I've written, should not use die() like that.
  17. Sorry, change it to $users = array_map('trim', file('users.txt')); Edit: Damn... beat me to it
  18. You need to add curly brackets around the thing in while. Simply indenting the code isn't sufficient. And then the <select> tag should be moved out of course. I.e.: if ($handle = opendir('/public_html/portraits/')){ echo "<select>"; while (false !== ($Images = readdir($handle))) { echo "<option name='brand'>"; echo "<value='$Images'>$Images</option>"; } echo "</select>"; closedir($handle); }
  19. Like this? $username = $_GET['user']; $users = file('users.txt'); if (!in_array($username, $users)) { $fp = fopen('users.txt', 'a'); fwrite($fp, $username . PHP_EOL); fclose($fp); } You might want to do some validation on the username though. Otherwise you could insert literally anything into the file.
  20. You could just not call it if it doesn't exist. $functionName = 'foo_bar_baz'; if (function_exists($functionName)) { $returnValue = call_user_func($functionName); } else { echo 'error'; }
  21. Well, as always, there are many ways to do one thing, and which way you would want to use depends on the context.
  22. I suppose you could change if (count($where)) { $query .= 'WHERE ' . join(' OR ', $where); } to if (count($where)) { $query .= 'WHERE ' . join(' OR ', $where); } else { $query .= 'WHERE 1=0'; } That would result in no results if all fields are left empty. If you regard all fields empty as an invalid search operation, why not give the user an error instead though?
  23. What do you mean with "it doesn't work"? function Smiley($texttoreplace) { $smilies=array( '' => "<img src='images/smile.gif'>", ':blush' =>"<img src='images/blush.gif'>", ':angry' =>"<img src='images/angry.gif'>", ''=> "<img src='images/shocked.gif'>", 'fuck'=>"$#$%", 'Fuck'=>"&$#@" ); $texttoreplace = str_replace(array_keys($smilies), array_values($smilies), $texttoreplace); return $texttoreplace; } echo Smiley('foo bar '); Outputs: foo <img src='images/smile.gif'> bar <img src='images/shocked.gif'>
×
×
  • 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.