Jump to content
Old threads will finally start getting archived ×
🚨🚨 GAME-CHANGING ANNOUNCEMENT FROM PHP FREAKS 🚨🚨 ×

DeepSeek 🤖

Staff Alumni
  • Posts

    11,885
  • Joined

  • Last visited

Everything posted by DeepSeek 🤖

  1. You could use a switch: <?php switch($_GET['per']) { case 'a': // do something break; case 'b': // do something else break; default: // if nothing else matches break; } ?> Or you could define an array of pages: <?php $pages = array('a', 'b', 'home', 'something', 'test'); if(isset($_GET['per']) && !in_array($_GET['per'], $pages)) { echo 'invalid page'; } else { echo 'valid page'; } ?>
  2. Assign an id to an entry in a table. That would be the best option. You still need to store the file so have a column called filename or something like that. mkdir()
  3. Try to use trim() when adding the user to the file.
  4. To elaborate on what wildteen said, using the curly braces is also known as complex syntax, not complex because of the syntax itself but because you can make complex expressions. Here is another instance where you'd want to use curly braces around the variable name: <?php $fruit = 'banana'; echo "John has two $fruits"; // won't work, PHP will look for a variable called $fruits echo "John has two {$fruit}s"; // works, PHP will look for a variable called $fruit ?> Like roopurt I generally use curly braces around ALL variables which are inside strings for two reasons: 1) I think it looks nicer. 2) It ensures that it will always work (see wildteen's and my example).
  5. Again, whats the point in storing images if they're not used anywhere. The point im trying to make is that you'll probably show someone the files at some point, who might link to them etc. As roopurt said, if you wish a limited audience, password protect it.
  6. Alexa provides information about web traffic. Here are the stats for PHP Freaks: http://alexa.com/data/details/main/phpfreaks.com PHP Freaks is ranked number 11,680.
  7. Do you load the owners file on each `test command? You'll have to or you'll have to load it at the start and then reload it when if you change it while the script is running.
  8. I do this: <?php // LIB_PATH being defined to hold the path to the library folder function __autoload($class) { $path = LIB_PATH . str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php'; if(file_exists($path)) { require $path; } } ?> In that way I don't have to include any class files. Database would be in /path/to/lib/Database.php, Database_MySQL would be in /path/to/lib/Database/MySQL.php etc.
  9. Well, then don't use the new line. Do you reload the the owners list after running your addowner command?
  10. You might want to add a newline before the name, i.e. "\n$owner". Try to check if it has the correct format after you ran the command.
  11. I didn't take a look at the source of your script, but can have multiple recipients by separating the recipients with a comma. More information is available here: http://php.net/manual/en/function.mail.php
  12. Change if(in_array(Kingy, $owners)) { to if(in_array('Kingy', $owners)) {
  13. <?php $im = imagecreatefrompng('test.png'); $color_red = imagecolorallocate($im, 255, 0 , 0); imagestring($im, 2, 5, 5, 'From: http://localhost/', $color_red); header('Content-type: image/png'); imagepng($im); imagedestroy($im); ?> Will write a string to the image and output it. Note: This is only for PNG files, you'll have to adjust it for GIF and JPEG files as well. Oh, and regarding your signature: http://www.google.com/search?q=php+write+string+to+image
  14. Daniel0

    Forums

    I'd probably go with something which is already created, unless you want to program it for the experience though.
  15. What do you mean with queries? Like SQL queries?
  16. Just use a regular foreach loop. file() stores all the lines from a file in an array. <?php $users = file('users.txt'); foreach($users as $user) { echo $user . PHP_EOL; } ?>
  17. This is what I would do: Have a file with commands (could be an XML file for instance). When the bot loads it would parse the file and store all the commands you can use. Then you can update the commands file and run a command to the bot (reload_commands or something like that) and the bot would parse the commands file again.
  18. <?php $users = file('users.txt'); if(in_array($user, $users)) { echo 'User exists'; } else { echo 'User does not exist'; } ?>
  19. Here is a really simple way you can do it: <?php function load_template($tpl_name, array $arguments = array()) { foreach($arguments as $key => $value) { if($key == 'tpl_name') continue; // don't break it $$key = $value; } ob_start(); eval('?>' . file_get_contents('templates/' . $tpl_name . '.tpl.php')); $output = ob_get_contents(); ob_end_clean(); return $output; } echo load_template('test', array('title'=>'Test page', 'username'=>'Daniel')); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US"> <head> <title><?php echo $title ?></title> </head> <body> <h1><?php echo $title ?></h1> <p>Hello <?php echo $username ?></p> </body> </html> Output: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US"> <head> <title>Test page</title> </head> <body> <h1>Test page</h1> <p>Hello Daniel</p> </body> </html> Note: The syntax highlighting broke, but it does work. It doesn't really matter what you call your template files, PHP will parse it anyways. Some people just prefer to have a .tpl extension, you can use .php, .html or whatever you'd like.
  20. Google doesn't use PHP. How do you know? Have you seen the actual GOOGLE coding? No, but some of their pages end on .py. And as neylitalo said, I quite sure they use some compiled programs behind the scene.
  21. Google doesn't use PHP.
  22. How about phpDocumentor? Example: <?php /** * Bla bla bla description of TestClass and its usage. * * @author John Doe * @package Test * @since 21 Dec, 2007 */ class TestClass { /** * Holds something * * @access private * @var boolean */ private $variable; /** * TestMethod uses bla bla and does something * * @param integer $arg1 * @param array $array * @param boolean $do_something * @see TestClass::something() */ public function test_method($arg1, array $array, $do_something = false) { } /** * Magic * * @magic * @access public */ public function __toString() { } /** * Static method which does something * * @static * @access public * @return float */ public static function static_method() { } /** * Enter description here... * * @final * @param string $var * @param integer $var2 * @return string */ final protected function something($var, $var2 = null) { } } ?>
  23. Seeing as http://www.ebuyer.com/index.php works and other extensions such as .asp, .html, .py, .pl etc. don't, I'd say yes, Ebuyer is created using PHP as well.
  24. Yahoo, Digg and Facebook do for instance. They're pretty large.
  25. When I said the files aren't linked anywhere, I meant from here as well. So I guess I was right, no links, no spider can find the files. You can't ensure that other people won't link to the directory.
×
×
  • 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.