Jump to content

trq

Staff Alumni
  • Posts

    30,999
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by trq

  1. It t is terror supressor and should be avoided. Use proper error trapping instead.
  2. The files always need to be publicly available in order for them to be served to a browser. What you can do however is write a php script which can serve the files, this php file (as well as hiding the actual file location) can then also be used to check your users are logged in or whatever before allowing the files to be served. A simple script might look like.... serve.php if (isset($_GET['movie'])) { $$movie = $_GET['movie']; $expires = 60 * 60 * 24 * 3; $exp_gmt = gmdate("D, d M Y H:i:s", time() + $expires )." GMT"; $mod_gmt = gmdate("D, d M Y H:i:s", time() + (3600 * -5 * 24 * 365) )." GMT"; @header("Content-type: $type"); @header("Expires: {$exp_gmt}"); @header("Last-Modified: {$mod_gmt}"); @header("Cache-Control: public, max-age={$expires}"); @header("Content-Length: {$size}"); @readfile('/fule/path/to/movies/' . $movie); }
  3. I should mention that for stuff like this (objects being populated from data within a database), you should likely be using an ORM instead. I understand your only in the learning process, but just though I should point them out. Doctrine is one of the more popular.
  4. Keep in mid that this is a VERY simple example of ONE way to do it. if you want multiple address books per User you would need to make the private $_addressBook variable an array and populate that with AddressBook objects but I'll leave that for you to play with. <?php class AddressBook { private $_street; public function __construct($id) { // some code that populates the AddressBook object from a database. } public function getStreet() { return $this->_street; } } class User { private $_addressBook = null; private $_id; private $_name; public function __construct($id) { // some code that populates the User object from a database. } public function getName() { return $this->_name; } public function getAddressBook() { if (is_null($this->_addressBook)) { $this->_addressBook = new AddressBook($this->_id); } return $this->_addressBook; } } $user = new User(22); echo $user->getAddressBook()->getStreet();
  5. You would have a method within the User object that creates (and returns) an AddressBook object.
  6. Well, that must suck. I'll have another look around this afternoon.
  7. Auto load (include) files containing classes as you need them. Stops you having to use include every time you need to use a class.
  8. With what? Are you offering? All that advertising $$$ you guys rake in... It happens regularly when I go to: 1.) http://www.phpfreaks.com 2.) Click on a thread in the forums 3.) Try to check messages in my profile 4.) Making a post 5.) Anywhere I usually have to re-submit a page 5, 6, 7, 8 times and then it will usually work, but often I have to come back 30 minutes later. To the untrained eye, it looks like your entire website is down... TomTees Like I said. We have been having some ongoing issue with database load. I'm on here 70% of my day and its never as bad for me as you have described. I haven't seen any error message since Saturday for instance. On Saturday I restarted a few services and another Admin cleared some logs. We are keeping an eye on things. Thanks for the heads-up though.
  9. Output buffering doesn't really help you unless you plan on using what's in the buffer. It has nothing to do with the issue you posted above, I was suggesting it as another possible solution to your overall problem though.
  10. Your code needs to be accessed via a url in order for the server to execute it. The other thing you could do would be to use output buffering to trap all output in a buffer, then write that output to a file. This will likely require modification of your code however unless you setup auto_prepend_file to enable the buffer and auto_append_file to write the file. Take a look at ob_start.
  11. Yeah, I thought it might be. Seems for whatever reason though, its timing out. Shouldn't really take too long to execute. You can access the page easily enough through a browser?
  12. This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=311225.0
  13. It looks like you do, but make sure you have 'allow_url_fopen' enabled in your php.ini. Don't forget to restart the server if you make any changes.
  14. This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=311235.0
  15. With what? Are you offering? What url are you attempting to access, a 404 indicates file not found. We have been having some issues with our DB, but you will get an appropriate error message.
  16. Functions except arguments, these arguments then show up within your function as the variables you declared within your argument list. eg; function foo($bar) { echo $bar; } foo('hello');
  17. This topic has been moved to Apache HTTP Server. http://www.phpfreaks.com/forums/index.php?topic=311239.0
  18. window.setInterval(function() { // ajax call in here. }, 2000);
  19. Ajax is simple using a library like jQuery. http://api.jquery.com/jQuery.ajax
  20. This is a server setting, nothing to do with php.
  21. What you are describing is entirely feasible. Are you stuck somewhere in particular? I'm not a Drupal user mind you so couldn't really help with specifics, but your post seems pretty broad anyway.
  22. I said several posts ago that if you make your __construct private you will not be able to instantiate the class into an object.
×
×
  • 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.