Jump to content

roopurt18

Staff Alumni
  • Posts

    3,746
  • Joined

  • Last visited

    Never

Everything posted by roopurt18

  1. select min( date ), max( date ) from table group by id
  2. Write the game of life. Prompt the user for the number of generations to run for. Enter the number of generations: 42<enter> Generate a random grid and display to the user: **************************************** *********.****************************** ******************************.********* **************************************** ***.*****.****************************** **************************************** **************************************** **************************************** **************************************** **************************************** ********************.******************* **************************************** **************************************** **************************************** **************************************** *********.**********.******************* **************************************** **************************************** **************************************** **************************************** ******************************.********* **************************************** **************************************** **************************************** An asterisk denotes a dead node and a dot denotes a live node. Now update the grid for the number of generations with the following rules: 1) A live node surrounded by 5 or more other live nodes dies due to over crowding. 2) A dead node surrounded by 3 or less live nodes is reborn into a live node. Each time you update the grid, display it to the user. You can keep the borders dead for the sake of simplicity if you'd like. And you can add arbitrary rules such as: A live node with exactly 4 living neighbors relocates to a random dead spot within 9 units of travel. Have fun!
  3. That's not what I said so either you misread or you mistyped.
  4. http://www.php.net/manual/en/class.httprequest.php I use it all the time.
  5. Do you know what a foreign constraint is?
  6. sleep(0.1) is equivalent to sleep(0) and in either case there is no need to call sleep() during this process.
  7. Every 32-bit OS, from Linux to Windows, I've run on my 4GB machine only picks up ~3.2GB of RAM.
  8. If you're doing money / financial calculations make sure you're using BC or GMP math functions. Do not use floats.
  9. Do as suggested and set it in your CSS and not your JavaScript. Regardless of how you're creating them the CSS rules will be obeyed. If you start putting CSS in your JavaScript you are combining logic and presentation and making it harder to fix things later. The CSS rule you're looking for is: a > img { border: none; } Or if necessary: a > img { border: none !important; }
  10. Clear the screen? No. If the browser is locking up so bad that you're having to close it with task manager then I'm 95% sure the problem is too much output to the browser. Do as suggested and run from a command line: Start -> run -> cmd cd \directory\with\php\file\in\it php scriptname.php If you want you can redirect the output to a file: Start -> run -> cmd cd \directory\with\php\file\in\it php scriptname.php > scriptname.html And then you can see the file size of scriptname.html. If its multiple megabytes then too much output is your problem.
  11. What's the HTML output to the browser? In other words paste the results of View source in your browser.
  12. Looking at his configuration data he is using group www. Now I agree with you in that on the Ubuntu machines I've used Apache2 runs as www-data. However on a CentOs box I administer it runs as user and group apache2 or httpd, I forget which, but it's not www-data. In any case I still stand by my statement: If user and / or group have read and his web server runs as either that user and / or group, then there's no need to grant read access to other.
  13. Since you're using Windows, go get yourself UnixTools from sourceforge and use find and grep: If myVar is the variable you're looking for: find . -type f -name "*.php" -exec grep -il myvar {} \; That will list every file that contains: myvar (case insensitive). If you want to find assignments to myvar, this might get you there: find . -type f -name "*.php" -exec grep -ilE 'myvar[ ]*=' {} \; Best of luck.
  14. I'd say you can just ask your questions in this thread. While I have no direct comparisons, their performance should be comparable and you may be able to find something on this through google. I can tell you that the following affects the performance of all database systems you're considering: 1) Hardware - Fast drives will make a big difference 2) Proper indexes 3) Good table design 4) Optimized queries where necessary 5) Database maintenance (reindexing, packing tables, etc) Regardless of your database software, hardware, whatever, you may reach a point at which you can not achieve the performance you desire. That's when you start looking into calculating and caching results on a schedule rather than in real-time as the user requests things.
  15. Presumably you access the files as jason and apache accesses them as www so I fail to see why you'd want other to have access in the first place.
  16. I recommend rsyslog for keeping an eye on your log files. The routing rules are fantabulous!
  17. I'm probably the one that recommended PostgreSQL. In any case, I think it's the way to go. Both PostgreSQL and MySQL are similar in syntax and support many of the same basic features. However PostgreSQL, as far as I know (remember I've been out of touch with MySQL for 2 1/2 years now), does have more advanced capabilities. You don't have to use them, but they're there if you need them. If you're worried about large data sets, I have tables with more than 10 million records in them and the performance is fine. Certain operations take a long time but that would be the case in either piece of software with that many records.
  18. That's not necessarily what classes and object oriented programming are about. Objects and classes are not primarily intended for grouping similar features into one area, although they can be used in that regard in languages such as PHP that don't (or didn't) support name spaces.
  19. I don't know much about OPC but if the server supports socket connections and you know the protocol you could always establish a read and write sockets and just talk to the server that way.
  20. You could do something like this: <?php /** * Sanitizer exception. */ class Sanitizer_Exception extends Exception { /** * Construct the exception * * @param string $msg * @param mixed $value * @return Sanitizer_Exception */ public function __construct( $msg, $value ) { parent::__construct( $msg . ': ' . var_export( $value, true ) ); } } /** * Sanitizer base class. */ class Sanitizer_Base { /** * The value. * * @access protected * @var mixed */ protected $value = null; /** * Flag if value has been cleaned. * * @access protected * @var bool */ protected $cleaned = false; /** * Construct the class * * @param mixed $value The value to sanitize. * @return Sanitizer_Base */ public function __construct( $value ) { $this->_value = $value; } /** * Return the sanitize value. * * @throws Sanitizer_Exception * @return mixed */ public function clean() { $this->cleaned = true; } } /** * Sanitize as positive integer. */ class PositiveInteger_Sanitizer extends Sanitizer_Base { const EXCEPTION = 'Not a positive integer'; /** * Create object. * * @param mixed $value * @return PositiveInteger_Sanitizer */ public function __construct( $value ) { parent::__construct( $value ); } /** * Clean the value. * * @throws Sanitizer_Exception * @return mixed */ public function clean() { if( $this->cleaned === false ) { do { // // Initially invalid $valid = false; // // Must be all digits if( ctype_digit( $this->value ) === false ) { break; } // // Convert to true int. $this->value = (int)$this->value; // // Must be positive. if( $this->value <= 0 ) { break; } // // Flag as valid $valid = true; } while( false ); // // If valid, cascade to parent. if( $valid === true ) { parent::clean(); } // // If invalid, throw exception else { throw new Sanitizer_Exception( self::EXCEPTION, $this->value ); } } // // Return the value. return $this->value; } } ?> Basically you'd have to make many different sanitation classes suitable for how you intend to use the data.
  21. really?.. Yes, really. As PFMaBiSmAd pointed out HTTP_REFERER can be faked so provides no real security. There are different ways in which someone can perform cross-site attacks and which method you're trying to prevent will guide the solution you use.
  22. What exactly are you trying to accomplish here?
  23. Data should be escaped properly just prior to being used; the escape method depends entirely on the way in which the data is being used. Data, however malicious the user intends it to be, is absolutely harmless while it's just sitting there in your variable. <?php $danger_var = "'; drop table users; --"; ?> $danger_var poses no threat if you echo it to text file, echo it to a PDF, export it to an Excel sheet, or dump it to the user's browser. The only time that variable content is dangerous is if you use it in a database query unescaped. There really is no catch-all sanitation you can perform on POST data that makes it safe for all uses except possibly undoing the effects of magic quotes if they're enabled. On a similar note I've noticed some folks are of the mindset of "I've sanitized before inserting into my database so therefore I do not need to sanitize before sending to the user's browser." Not true! For example before sending data to a user's browser you should always run it through htmlentities() and you should not use htmlentities() before storing data in the database. Drawbacks include: 1) You've altered the data entered by the user. 2) You're operating under the assumption that your database is safe and contains safe data. However if an attacker compromises your database and inserts unescaped and dangerous JavaScript then your users are in big trouble because you'll blindly send that malicious code to them.
  24. I would imagine that most browsers, even if receiving a Location header, would wait until the end of the response from the server to redirect. For example, let's say that an implicit flush and no output buffering was enabled on the server. Then every single echo or header request would immediately be sent to the browser. If the script was intending to first set the location and then add a cookie and the browser immediately redirected after receiving location, the cookie would not be set. I always have my scripts output everything at once at the end and my best practice is to do all my processing and make the following my last two lines of code I want executed: header( 'Location: http://somewhere' );exit();
×
×
  • 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.