Jump to content

GreenSmurf

Members
  • Posts

    108
  • Joined

  • Last visited

About GreenSmurf

  • Birthday 11/30/1985

Profile Information

  • Gender
    Male

GreenSmurf's Achievements

Member

Member (2/5)

0

Reputation

  1. You are right about PHP doing the calculation in UNIX_TIMESTAMP but at least it is not in the DB for now and I just need to find a better solution to avoid the UNIX_TIMESTAMP.
  2. Got it. Its messy but the functionality is there: if ($reQuest!=""){ $timeSub = date("h:i A", strtotime('+1 day +1 minute '.$reQuest)); $timeNow = date("Y-m-d H:i:s", time()); $timeNow = strtotime($timeNow); //echo $timeNow."<br />"; //echo $reQuest."<br />"; $timeComp = date("Y-m-d H:i:s", strtotime('+1 day '.$reQuest)); $timeComp = strtotime($timeComp); //echo $timeComp."<br />"; if ($timeNow <= $timeComp){ $timePass=false; }else{$timePass=true;} Hope this helps anyone else who might need this sort of calc. -GS
  3. Thank you. You beat me to it. The issue is more that I just want to compare the dates. I thought I was on to something with this little bit of code but I have again hit a wall. $mysqldate = date($reQuest, $phpdate); $phpdate = strtotime($mysqldate); Any more ideas or code snippets would be appreciated. -GS
  4. I was trying to avoid the UNIX_TIMESTAMP because of the date limitations placed upon it. Plus, I am not trying to limit the query anyway because I am accessing other information in the table from the database. I need to compare the m in PHP.
  5. What I need the code to check is that $reQuest is 24 hours in the past then return a time based on how long ago that was in the past if 24 hours has not passed. if ($reQuest!=""){ if (is_on_interval($phpdate,$getdate,24)==false){ //24 hours has not passed. $timePass=false; //echo $reQuest."<br />"; //debug lines of code //echo phpversion(); // Installed 5.3.1 but still registered as 5.2.2 --odd $start = new DateTime($reQuest); //First or start date to be check as pulled from the database. $time = $start->diff(new DateTime(date("Y-m-d H:i:s", $phptime))); //Check the difference in date with diff() available in 5.3.1 }else{$timePass=true;} } The problem is that 5.3.1 did not install properly and being such I am trying to figure out a new way to get the difference in time from the DateTime in the database and the current time obtained by PHP. The $reQuest variable has a value of 2010-02-18 12:47:15 Any help would be appreciated. Thank you. -GS
  6. In the gen.php I forgot this little important line of code and thought I should include it just in case anyone ever decides to use this as a learning tool. Just before the headers there needs to be a line of code that converts the $filename variable back into URL format. Hence this line of code: $filename = urlencode($filename); -GS
  7. I found this which has the functionality that I am looking for built-in but I am having trouble figuring out how it achieves my goal. I hope that someone may find this useful or can enlighten me should I not find what I am looking for soon. -GS [attachment deleted by admin]
  8. This URL pointed me in the right direction. http://www.boutell.com/newfaq/creating/forcedownload.html I hope it helps someone else. So, what I did based on this was I changed this: if($_REQUEST['download'] && $forcedownloads) { $filename = urldecode($_REQUEST['download']); header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); header("Content-Disposition: attachment; filename=".basename($filename).";"); header("Content-Transfer-Encoding: binary"); header("Content-Length: ".filesize($filename)); @readfile($filename); exit(0); } to this: $fname = $_REQUEST['download']; echo "<script type=\"text/javascript\">"; echo "window.open(\"gen.php?download=$fname\",\"$fname\", \"resizable,toolbar,scrollbars,menubar,\");"; echo "</script>"; And made gen.php look like this: <?php $allowed_ext = array ( 'zip' => 'application/zip', 'pdf' => 'application/pdf', 'doc' => 'application/msword', 'docx' => 'application/msword', 'docm' => 'application/msword', 'doct' => 'application/msword', 'dotm' => 'application/msword', 'dotx' => 'application/msword', 'dot' => 'application/msword', 'odt' => 'application/msword', 'wpd' => 'application/msword', 'wps' => 'application/msword', 'prn' => 'application/msword', 'xls' => 'application/vnd.ms-excel', 'xl' => 'application/vnd.ms-excel', 'xlsx' => 'application/vnd.ms-excel', 'xlsm' => 'application/vnd.ms-excel', 'xlsb' => 'application/vnd.ms-excel', 'xlam' => 'application/vnd.ms-excel', 'xltx' => 'application/vnd.ms-excel', 'xltm' => 'application/vnd.ms-excel', 'xlt' => 'application/vnd.ms-excel', 'xla' => 'application/vnd.ms-excel', 'xlm' => 'application/vnd.ms-excel', 'xlw' => 'application/vnd.ms-excel', 'qba' => 'application/x-qbmsxml', 'qbb' => 'application/x-qbmsxml', 'qbm' => 'application/x-qbmsxml', 'qbw' => 'application/x-qbmsxml', 'qbx' => 'application/x-qbmsxml', 'gif' => 'image/gif', 'png' => 'image/png', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg' ); $filename = urldecode($_REQUEST['download']); $fext = strtolower(substr(strrchr($filename,"."),1)); if (!array_key_exists($fext, $allowed_ext)) { die("Not allowed file type."); } if ($allowed_ext[$fext] == '') { $mtype = ''; if (function_exists('mime_content_type')) { $mtype = mime_content_type($file_path);} else if (function_exists('finfo_file')) { $finfo = finfo_open(FILEINFO_MIME); $mtype = finfo_file($finfo, $file_path); finfo_close($finfo); } if ($mtype == '') { $mtype = "application/force-download"; } }else{ $mtype = $allowed_ext[$fext];} header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/force-download"); header("Content-Type: application/$mtype"); header("Content-Type: application/download"); header("Content-Disposition: attachment; filename=".basename($filename).";"); header("Content-Transfer-Encoding: binary"); header("Content-Length: ".filesize($filename)); @readfile($filename); exit(0); ?> And like magic the script works! I knew I was not crazy but eventually we all have our tipping point. Thanks to anyone who PM'd me or even considered my problem. -GS
  9. Trying to get my force downloads script to work. The example below was actually taken from another script and modified but its similar to the one I originally wrote. if($_REQUEST['download'] && $forcedownloads) { $filename = urldecode($_REQUEST['download']); header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); header("Content-Disposition: attachment; filename=".basename($filename).";"); header("Content-Transfer-Encoding: binary"); header("Content-Length: ".filesize($filename)); @readfile($filename); exit(0); } It is pretty basic but the problem occurs when the script outputs this: Any help would be appreciated. Thank you. -GS
  10. I am not exactly sure how to word this because I know it is possible but I will try my best. I am attempting to find information on how to limit the file extensions in the file browser before a user submits an upload. I have attached an image of what I am talking about. It by default comes up with All Files (*.*) as the option but I would like to limit it to valid types. I have seen an example script on how to do this before but I forget for the life of me what its called or else I might just Google it. If anyone has any information I would appreciate it. Thank you. -GS [attachment deleted by admin]
  11. Found the error. It was a check just above the code I provided. Thank you RussellReal for your tip. It made me think about what information was being passed. So, I echoed the information being passed and saw that its was doubling up on the variable $leadon and that made me think what could be causing it. Turns out that this code: if($dirok) { $leadon = $leadon.$_REQUEST['dir']; } Was supposed to be this: if($dirok) { $leadon = $_REQUEST['dir']; } Thank you for your help. Simple fix for a simple problem. -GS
  12. Allow uploads is true and I have been able to verify that the logic is working properly but the uploading process itself is not. A possible culprit is the variable $leadon which is the directory value for the person logged into their account. The directory is correct and is based on their name and unique member id. For example, my test account has the directory set to User_Name43. if($allowuploads && $_FILES['file']) { $upload = true; if(!$overwrite) { if(file_exists($leadon.$_FILES['file']['name'])) { $upload = false; } } if($upload) { move_uploaded_file($_FILES['file']['tmp_name'], $leadon . $_FILES['file']['name']); } } Any hints at what appears to be wrong would be most appreciated. If you need to see more code I can throw it up but I did not want to burden anyone person's eyes with all the code. -Smurf
  13. I believe it has to do with the browser you are using. I am not certain but this problem seems to have vanished now that I am on Firefox 3.5.6 and not an older version or using Internet Explorer. If anyone has experienced similar problems I would like to know how it was resolved within the code or if it is just a lost cause. Thank you. -GS
  14. Still have not exactly figured out the error due to the fact that one application of rawurlencode() works and in a very similar (copy-paste) use of the code it does not. The first one does not work. echo "Users added. See on <a href='index.php?group_name=".rawurlencode($group_name)."'>\"$group_name\"</a> or <a href='javascript:history.go(-1)'>Go Back.</a>";[\php] While this one does. [code=php:0]echo "Users removed. See on <a href='index.php?group_name=".rawurlencode($group_name)."'>group page \"$group_name\"</a>."; Any suggestions? I would consider making a URL for each group in the database but then I would have to change quite a bit in the database and in the code due to the fact that it has been left open-ended and generates requests on the fly rather than pulling the info from a database. The other reason is that I wanted to cut down on a need to run queries. I would like to thank you in advanced for any replies and your time. -GS
  15. No real reason for choosing one over the other. I just learned rawurlencode first and it works in my other code with similar applications.
×
×
  • 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.