Jump to content

robcrozier

Members
  • Posts

    175
  • Joined

  • Last visited

    Never

Everything posted by robcrozier

  1. Hi, thanks for your quick response. I'm accessing the methods like this: $directory->getDirDetails($defaultDirId); and vars like this: $directory->name;
  2. Hi. I have a class called 'directory', defined as follows: <? // Directory Class class directory{ var $id; var $name; var $path; var $parentId; var $accountId; function directory(){ // CONSTRUCTOR $this->id = ""; $this->name = ""; $this->path = ""; $this->parentId = ""; $this->accountId = ""; } function getDirDetails($id){ $query = mysql_query("SELECT * FROM directories WHERE id = '$id'"); while ($row = mysql_fetch_assoc($query)){ $this->name = $row['name']; $this->path = $row['path']; $this->parentId = $row['parent']; $this->accountId = $row['account_id']; } } } ?> The class is included and an instance is made like so: if (!class_exists("directory")) include("classes/class.directory.php"); $directory = new directory; HOWEVER.... When i go to use any var or method of the class, i get the following sorts of error messages: Undefined property: Directory::$name Can anyone help me figure out why it is not working???? Thanks
  3. Hi guys. I'm new'is to OO PHP and i would like to seek some helpful opinions about how to use OOPHP when creating a secure user authentication/login class. My main question is.... i would rather not rely solely on a session variable to keep the user logged in to the site. Is it best practice, and how secure is it to use a 'last activity' value in a database related to each user and use this to determine how long a user has been inactive and then log them out if this is linger than whichever time period i specify in a config file or something similar? Hope this makes sense! Cheers
  4. If i set this at the top of the script to say 3hours or something, and then reset it to 20mins at the bottom of the script, after the file(s) have been uploaded, can anyone foresee any problems? Cheers
  5. Hi. I'm having an issue with my file uploading script. Basically, it uses perl to do the actual uploading which means massive files can be uploaded. This, however causes my PHP session to timeout and log the user out before they have a chance to do anything with their newly uploaded file. Is there any way that i can make sure that the session does not timeout on this one script? I want the session timeout to remain at around 20 mins as default, except when the user uploads a file that may take more than 20 mins depending on the size of it. Any suggestions would be great! Thanks in advance
  6. Awesome mate! Worked a treat! Thanks
  7. Hi guys, just wondering if anyone can help with this? Basically, i have a php file downloader script set up and it works fine for most file types, however it tries to execute and executeable files as it reads their contents. For example with php and html files. Has anyone had this problem before and can anyone suggest how to overcome this? Here's the code: <?php $root = $_SERVER['SERVER_NAME']; $fileID = $_GET['id']; // identify the file and file path from the database $getFile = mysql_query("SELECT name, alias FROM files WHERE files.id = '$fileID'"); while ($row = mysql_fetch_assoc($getFile)) { $fileWithPath = $domain."".$uploadRoot."/".$row['name']; $filePath = $domain."/".$uploadRoot; $baseDir = $domain."/".$uploadRoot."/"; $fileName = $row['name']; $fileAlias = $row['alias']; $relativePath = $relativeDownloadPath.$fileName; //$dirName = $row['dirName']; } if ($fd = fopen ($fileWithPath, "r")) { $fsize = filesize($relativePath); $path_parts = pathinfo($fileWithPath); $ext = strtolower($path_parts["extension"]); switch ($ext) { case "pdf": header("Content-type: application/pdf"); // add here more headers for diff. extensions header("Content-Disposition: attachment; filename=\"".$fileAlias."\""); // use 'attachement' to force a download break; case "doc": header("Content-type: application/msword"); // add here more headers for diff. extensions header("Content-Disposition: attachment; filename=\"".$fileAlias."\""); // use 'attachement' to force a download break; case "xls": header("Content-type: application/vnd.ms-excel"); // add here more headers for diff. extensions header("Content-Disposition: attachment; filename=\"".$fileAlias."\""); // use 'attachement' to force a download break; case "ppt": header("Content-type: application/vnd.ms-powerpoint"); // add here more headers for diff. extensions header("Content-Disposition: attachment; filename=\"".$fileAlias."\""); // use 'attachement' to force a download break; case "txt": header("Content-type: application/txt"); // add here more headers for diff. extensions header("Content-Disposition: attachment; filename=\"".$fileAlias."\""); // use 'attachement' to force a download break; case "gif": header("Content-type: image/gif"); // add here more headers for diff. extensions header("Content-Disposition: attachment; filename=\"".$fileAlias."\""); // use 'attachement' to force a download break; case "png": header("Content-type: image/png"); // add here more headers for diff. extensions header("Content-Disposition: attachment; filename=\"".$fileAlias."\""); // use 'attachement' to force a download break; case "jpg": header("Content-type: image/jpeg"); // add here more headers for diff. extensions header("Content-Disposition: attachment; filename=\"".$fileAlias."\""); // use 'attachement' to force a download break; case "jpeg": header("Content-type: image/jpeg"); // add here more headers for diff. extensions header("Content-Disposition: attachment; filename=\"".$fileAlias."\""); // use 'attachement' to force a download break; case "mp3": header("Content-type: audio/mp3"); // add here more headers for diff. extensions header("Content-Disposition: attachment; filename=\"".$fileAlias."\""); // use 'attachement' to force a download break; case "wav": header("Content-type: audio/x-wav"); // add here more headers for diff. extensions header("Content-Disposition: attachment; filename=\"".$fileAlias."\""); // use 'attachement' to force a download break; case "exe": header("Content-type: application/octet-stream"); // add here more headers for diff. extensions header("Content-Disposition: attachment; filename=\"".$fileAlias."\""); // use 'attachement' to force a download break; case "mpeg": header("Content-type: video/mpeg"); // add here more headers for diff. extensions header("Content-Disposition: attachment; filename=\"".$fileAlias."\""); // use 'attachement' to force a download break; case "mpg": header("Content-type: video/mpeg"); // add here more headers for diff. extensions header("Content-Disposition: attachment; filename=\"".$fileAlias."\""); // use 'attachement' to force a download break; case "mpe": header("Content-type: video/mpeg"); // add here more headers for diff. extensions header("Content-Disposition: attachment; filename=\"".$fileAlias."\""); // use 'attachement' to force a download break; case "mov": header("Content-type: video/quicktime"); // add here more headers for diff. extensions header("Content-Disposition: attachment; filename=\"".$fileAlias."\""); // use 'attachement' to force a download break; case "avi": header("Content-type: video/x-msvideo"); // add here more headers for diff. extensions header("Content-Disposition: attachment; filename=\"".$fileAlias."\""); // use 'attachement' to force a download break; default; header("Content-type: application/octet-stream"); header("Content-Disposition: filename=\"".$fileAlias."\""); } header("Content-length: $fsize"); header("Cache-control: private"); //use this to open files directly while(!feof($fd)) { $buffer = fread($fd, 2048); echo $buffer; } } fclose ($fd); //exit; ?>
  8. Hi corbin, thanks for your reply I'm planning on storing the class as a plain variable. I basically want to create a user class upon system load and then user the various methods of that class to check the users logged-in status and other vars fetched from the database. So if i simply use a check like you suggest that the top of the page: if(!isset($user_class_instance)) { // create instance of user here! } I can create an instance of the user class if there's not one already set. I do just plan to have one instance running at a time as it will basically act as user authentication per session. Cheers
  9. Hi all, i bet this type of thing has been asked before, but i hope you can sympathise with my desire to increase my OOPHP skill and help me with this one.. Basically, i've trawled tutorial after tutorial and now i want to try and create a decent user authentication with OOPHP. What i'm struggling with is probably very basic, but here goes. I want to create an instance of a 'user' class on system startup, which will then obviously be pre-loaded by the class' constructor vars. However, how do i only instantiate the class once, and in fact do this on system startup? If include it in my header file, it will try and instanciate the class on every page for example. Is there any way to check if a user object has been created and if so - do not create another one? Any advice on this would be great, hope it makes sense what i'm trying to do! Cheers
  10. Thanks chester - that link looks great - think i'll go down that road. Thanks also to Crayon Violent - i will look into adopting a framework too!
  11. Do you mean such as a CMS like Joomla? I'd rather create my own code to be hones though.
  12. Hi, i know this has probably been asked, or at least something similar lots of times, but after looking through the forum i can't find what i'm looking for. Basically, i want to create a secure, reliable login script for my website. I'm pretty familiar with PHP and i need something that simply goes beyond setting a session and checking for it at the top of all secure pages. Can anyone suggest something that is perhaps database driven (i don't really want to use IP checks though due to AOL's changing IP's). Any links to tutorials, pointers in a general direction etc would be great! Thanks guys!
  13. I'm using the newest version of php and i know for a fact that it hasn't been compiled to run without it. I'm aware that you need to use: require_once("DB.php"); in order to use the PEAR library, however i just get a file not found error. Any suggestions? Cheers
  14. Hi everyone, i'm new to PHP's PEAR Database object and i'm trying to follow a tutorial aimed at creating a secure php login. The tutorial uses PEAR and i don't seem to be having any joy. Can anyone tell me, is PEAR a pre-installed object within PHP or do i have to install something to use it? Any help getting me off the starting line would be much appreciated. Cheers
  15. That's one of the methods that i've tried actually, however javascript does not recognise it and nor do images. PHP files are OK with this but i need something that i can use for all my JS includes and images too. Cheers
  16. Hi, i was just wondering if anyone could give me any advice on setting up paths within my php scripts. Basically, i have a lot of include() functions going on, from many different locations. Relative paths are starting to give me a headache! How does everyone else set up their paths with their working on a large php project? Do you set up an absolute path in a config file for example? If so how exactly do you do this? I've tried a few ways of setting up an absolute path within my script, however some aren't recognised my javascript (which is also important for me!) and images etc? Any advice would be great.
  17. Hi everyone, just wondering if anyone can point me in the right direction with this one. Basically what i want to do is create a store with multiple (unlimited) subcategories. At the minute i have a DB table that stores all details about each category including it;s ID and parents ID. What i want to do is print the categories out in a nice nested list - subcategories being nested below their parent categories. What's the best way to go about this other than recursively querying the database? Cheers!
  18. Hi everyone, i've been informed that PHP is not ideally suited to uploading very large files (i.e. 1GB + etc...), and that something like perl would work better. I was just wondering if anyone has managed to successfuly upload very large files with PHP? If so how did you go about it and basically... would you recommend using PHP for this? Cheers!
  19. Hi, i'm trying to read the contents of a PHP file from another PHP file and then save only the raw text that would be outputted on the browser. So for example if i have a php file that looks like: <?php echo "Some text"; ?> I want to scan this PHP file and only retreive the "Some text" bit. I will then do some processing with this. I can already scan a HTML file and then strip all HTML tags to retreive the raw site text, however PHP is giving me a headache. Can anyone suggest how i would go about this? Cheers
  20. Hi guys, i wonder if anyone can point me in the right direction with this. What i want to do is generate a number of checkboxes on a form based on the number of rows retrieved from a certain MySQL table. for example if table1 returns 5 rows, i want to generate 5 different checkboxes on the form that the user can select. I then want to pass the value(s) back to the validation script when the form is submitted. I'm having trouble getting my head around whether or not i need to use an array to generate and then pass back the values in the form. If that's the case, how would i go about it? If not... what's the best way to achieve this? Thanks guys!
  21. Here's what's output: ../path/to/file/targetFileName.jpg fileName.JPG Thanks mate
  22. The target is set like this: $target = "../media/siteImgs/store/products/".$file;
  23. Hi everyone, what i'm trying to do is allow a user to upload a file to the server via FTP using PHP. I have chosen to do it this way so that the file permissions are not set to apache when the file is uploaded, instead they will be set to me (the owner) so that they can be remotely opened etc later on. Here's what i have so far: $ftp_server = "******"; $ftp_user_name = "******"; $ftp_user_pass = "******"; $conn_id = ftp_connect($ftp_server); $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); ftp_put($conn_id, $target, $_FILES['file']['tmp_name'], FTP_BINARY); However i keep getting this error message: ftp_put() [function.ftp-put]: path/to/file/name.jpg: No such file or directory in path/to/php/file on line 91 Can anyone help? Cheers
  24. I think a quick and simple way to do this Graham would be to define a <div></div> using CSS with a fixed width and height, with overflow set to auto. I would then hide this until the user has clicked on the preview button using something like: if (isset($_POST['preview'])) { // show div echo "<div class='textBoxPreview></div>"; } else { // do nothing } No all you need to do is add the preview form button to your form. When the form is submitted, collect the data that is posted from the textbox and echo it into the div you defined. The div will act as a sort of viewport where the user will see the html that they have input. Hope that helps Rob
  25. Hi everyone. I've been given the job of developing a PHP driven store on someone's website. Normally this wouldn't cause me too many problems. However this one requires certain products to have additional options (i.e. colour, size etc...) which can be selected/specified before the item is added to the cart by the user. Shopping carts are usually developed along the lines of... product_no->quantity, simple! However, what about adding a product to the cart that could have any number of different specified options etc? It's not just the cart that i'm interested in getting a bit of advice about - it's also how i would go about defining the different options for each product based upon the product itself using PHP (e.g. a pair of shoes may require the user to input size, however a kitchen unit may require:colour, finish, size, etc). I must also bare in mind that additional products and product types may be added by the user through a cms. As i have already mentioned i know how to build an average store and shopping cart - it's the uncertainty of the additional product options that's causing me problems. I'm not expecting anyone to tell me exactly how to go about this in a post - however can anyone point me in the right direction, give me some pointers or point me in the direction of a good tutorial etc? Thanks for your time guys - hope you understand whet i'm looking for
×
×
  • 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.