Jump to content

steviez

Members
  • Posts

    382
  • Joined

  • Last visited

    Never

Everything posted by steviez

  1. Hi, I am trying to use the exec function to zip up some files on my server because i dont want to use a third party class to do such a simple function. The problem ima facing is that it is zipping up the file with all the directorys too.... for example: /home/gggg/uploads/myfile.txt and all i want is the file in the zip not the folders and file. my code is like this: <?php exec("zip -r /home/gggg/myfile.txt /home/gggg/myfile.zip"); ?> any ideas?
  2. Hi, I am integrating some api code for my site and am getting stuck on this curl upload script. The actual upload function works perfect on ,y site so i have come to the conclusion that its the following code: <?php // Example Upload API (PHP with cURL) class Uploader { var $file; var $uploadURL; var $api_key; var $postParams = array (); /* Constructor for Uploader */ function Uploader($file, $uploadURL, $api_key) { $this->uploadURL = $uploadURL; $this->postParams = array("api_key" => $api_key, "file" => "@" . $file); } /* function to upload file */ function UploadFile() { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->uploadURL); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_VERBOSE, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)"); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $this->postParams); $postResult = curl_exec($ch); if(curl_errno($ch)) { print curl_error($ch); print "<p>Unable to upload file.</p>"; exit(); } curl_close($ch); return $postResult; } } // set upload server $upload_server = "http://mysite.com/api/upload.php"; $upload = new Uploader('file.rar', $upload_server, '546474a6ge5dfe958575857'); $result = $upload->UploadFile(); // error print if(preg_match("/upload_failed/", $result)){ echo "<p>Upload failed.</p>"; } if(preg_match("/invalid_api/", $result)){ echo "<p>Invalid API Code.</p>"; } // success print if(preg_match("/upload_success/", $result)){ echo "<p>" .$result. "</p>"; } ?> does this look ok to you to perform a file upload? all i keep getting is upload_failed Thanks
  3. Hi, I am making a simple file hosting site and want to check if users premium subscriptions have ended or not. In the database i have premium_start ( time() ) and premium_end ( time() ) that represents the start and end date. Would the following code work to check if an account has expired? <?php // check premium expire if((time() - $member['premium_end']) >= time()) { // do actions here } ?> thanks
  4. Hi, I am developing a image upload system for my site where users will be able to upload images in to their photo albums. My problem is this: When uploading the images the script has to create a few different sized thumbnails for each image and so far the system fails. I keep getting an error saying "failed to allocate xxxx bytes ....." I know that when an images is to be resized first it is uncompressed and it takes up a lot of memory but surly there is a way to do it even on shared hosting where you cant change your memory allocation? I will have quite a few users uploading at the same time so it has to work, can anyone shed some light on a good way to resize? Thanks
  5. cookies are enables because if I set the expire time to 0 instead of say time()+3600 then it works like a charm.
  6. Hi, I have a strange one here for you (well its strange to me). When I am setting cookies in my script they work 100% fine for me in firefox but any other browser (ie, chrome etc) they simply wont register for me. My code: <?php setcookie("TestCookie", $value, time()+3600); ?> Any ideas?
  7. steviez

    search help

    dont matter now, I got it fixed... thanks for all your help guys.
  8. steviez

    search help

    My query is not working for the search criteria.. after my initial query I have extra statments like: AND username = 'me' The following query wont work: " AND (YEAR(CURDATE())-YEAR(user_birthday)) - (RIGHT(CURDATE(),5)<RIGHT(user_birthday,5)) between '%{$_GET['age_from']}%' and '%{$_GET['age_to']}%'" Any help?
  9. steviez

    search help

    Computers don't really care about that. Formats like dd-mm-yyyy or mm/dd/yyyy are human conventions and have no significance to a computer. Computers care about things like speed and storage requirements. The YYYY-MM-DD format exists for a couple of reasons - 1) When the fields (y, m, d) are in that specific order, the values can be directly sorted and compared using less-than/greater-than comparisons, 2) By using a consistent, fixed format, the amount of storage has been minimized and the code has been optimized to result in the fastest queries. There are also a couple dozen built in data/time functions that can be used once your dates are in the expected DATE data type. To output a DATE data type in any format you want, simply use the mysql DATE_FORMAT() function in your query when you SELECT the data. Thank you so so much for your help
  10. steviez

    search help

    I have just found my mistake there, it needs to be date format, why does it only allow yyyy-mm-dd though? I am UK based and wanted dd-mm-yyyy
  11. steviez

    search help

    Yes, but what DOES it return? And as previously mentioned in the thread, what data type is mm_users.user_birthday? I get no result its blank, I am not sure what you mean by data type... If you mean the database row type then its varchar(20)
  12. steviez

    search help

    That would result in duplicate/derived data. It would also create a data management problem because a person's age is not fixed (unless they are dead.) You would need to recalculate the age every time you used it in case their birthday date went past. The link I posted above to the mysql manual section shows a query that calculates the age. You can then use the age value in that same query any way you want. I have done what is says on that page but it does not return there age, my query is here: "SELECT mm_users.user_id, mm_users.user_username, mm_users.user_photo, mm_users.user_signupdate, mm_users.user_lastlogindate, mm_users.user_dateupdated, mm_users.user_birthday, CURDATE(), (YEAR(CURDATE())-YEAR(mm_users.user_birthday)) - (RIGHT(CURDATE(),5)<RIGHT(mm_users.user_birthday,5)) AS age FROM mm_profiles LEFT JOIN mm_users ON mm_profiles.profile_id = mm_users.user_id WHERE mm_users.user_privacy_search = '1' $bquery"
  13. steviez

    search help

    there should be no problem in grabbing the date of birth and working out the age with php then adding it to a row in ther users database should there? I can then do a simple search query
  14. steviez

    search help

    I have no idea how to do any of that im afraid... Im a complete noob, so I think I will have to alter my script some how.
  15. steviez

    search help

    I am a complete SQL nOOob, would you be able to show me sample syntax?
  16. steviez

    search help

    Sorry I should have said, the birthdays are stored as: 2-02-1984.. I am starting to think that it may not be do-able
  17. steviez

    search help

    Hi, I am writing a php script to search through my database of users, I need one of the search criteria to be age (eg: between 30 and 70) but the only problem is that their age is not stored in the database only there date of birth. Without rewriting my script or adding extra functions on search (not sure if its even possible) is there any way of doing this search? Thanks
  18. I have managed to do this my self after much trial and error, thanks anyway.
  19. Anyone? been trying to do this all night
  20. Hi, I am a complete PHP noob and am asking for help please I am working through a site to learn how to code in php and at every step learning how to do the work. The next step is a site search and I am stuck! My search function needs to take extra search criteria like height, weight, location, name etc and these will be text boxes and so on. I have my initial code and search functions set up but dont know how to pass these extra criteria to the search string if they exists. Here is my code so far: <?php /** set page name **/ $page = "search"; /** set page title **/ $page_title = "Search"; /** include header **/ include "header.php"; /** get task **/ $task = $misc->get_task(); /** get page **/ $p = $misc->get_page(); /** set empty vars **/ $browse_query = ""; /** set sorting variable **/ $sort = $misc->get_sort(); /** construct main query **/ $browse_query = "SELECT mm_users.user_id, mm_users.user_username, mm_users.user_photo, mm_users.user_signupdate, mm_users.user_lastlogindate, mm_users.user_dateupdated FROM mm_profiles LEFT JOIN mm_users ON mm_profiles.profile_id = mm_users.user_id WHERE mm_users.user_privacy_search = '1'"; /** get total users **/ $total_users = sql_num_rows($browse_query); /** make browse pages **/ $results_per_page = 20; if(($total_users % $results_per_page) != 0){ $maxpage = ($total_users) / $users_per_page + 1; }else{ $maxpage = ($total_users) / $users_per_page; } $maxpage = (int) $maxpage; if($p > $maxpage){ $p = $maxpage; } if($p < 1){ $p = 1; } $start = ($p - 1) * $results_per_page; /** add order and limit to query **/ $browse_query .= " ORDER BY $sort LIMIT $start, $results_per_page"; /** display users **/ $users = sql_query($browse_query); $user_array = array(); $user_count = 0; while($user_info = mysql_fetch_assoc($users)) { /** set new user **/ $search_user = new user(array($user_info['user_id'], $user_info['user_username'])); /** get users photo and see if it exists **/ $user_photo = $search_user->user_photo_crop("./assets/images/nophoto.gif"); /** set array of user info **/ $user_array[$user_count] = array('user_username' => $search_user->user_info['user_username'], 'user_photo' => $user_photo); $user_count++; } /** assign smarty variables **/ $smarty->assign('users', $user_array); $smarty->assign('total_users', $total_users); $smarty->assign('sort', $sort); $smarty->assign('maxpage', $maxpage); $smarty->assign('p', $p); $smarty->assign('p_start', $start+1); $smarty->assign('p_end', $start+$user_count); $smarty->assign('task', $task); /** include footer **/ include("footer.php"); ?> Please could anyone help me as i really want to learn and for me the best way is to be shown and to then do the work my self Thanks!
  21. Thanks, Its nice to learn new things
  22. How can you remove the first / off this url ( /home/members ) so it looks like home/members Thanks
  23. I know now that it is a memory issue because of shared hosting and it taking a lot of memory to do... So my question is this: is there a better way to do it on shared hosting?
  24. No i ment it was there when i bought the script, no idea why
  25. It was in the code for my script
×
×
  • 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.