Jump to content

Ninjakreborn

Members
  • Posts

    3,922
  • Joined

  • Last visited

Everything posted by Ninjakreborn

  1. Yes far less powerful, and far less secure. It's only real purpose (based on what I read about it), is if you are working on a server that you don't have access to and need to run server side code.
  2. No you can't but there is a work around. You can set the PHP engine to parse ASP pages as well (anything in <% %> is parsed by the ASP engine, and anything in <?php ?> is parsed by the PHP engine). Once you have this set, then all asp pages are also ran through php's parser to look for any php code. Just have php then set a session (IN PHP) as well so you will have access to it. You can even set the PHP parser to parse asp file's using htaccess like this AddType application/x-httpd-php .asp Give that a try, in your htaccess file. Then where the session in ASP is being created, right below that just register the session variables with PHP too, so php can then work it's magic wherever you need on other PHP pages.
  3. Well technically nobody really will say one language is better than the other, but some languages have more "popularity" than others. For example, after doing research on languages right before I decided to pick my primary. I found out some were far more popular than others. I found this out by seeing how many projects would be available for each language, how many site's used each one, adn more importantly graphs and grids of peoples opinions. It seemed to fall in pretty much the following order of popularity. This is only taking in server side languages, it's not even mentioning higher level languages like java, perl, or python. When I was looking I was only interested in picking up a server side at the time, but this list is generally the way I categorized it based on popularity. The main reason I noticed that php gained more popularity than ASP overall was because PHP is free. It's also easier to use (That part is pretty much based on opinion). PHP ASP JSP/Coldfusion // about the same Server Side Javascript
  4. If you are wanting to run the entire class at start up (like it's a system or something and everything need's to be run at system startup everytime. Here is a quick idea. 1. Instantiate the class 2. After the instance is created, get an array together of all the function names within your class (all the ones you need to run) 3. Run a foreach on the loop running each function one at a time. like $class = new class(); $functions = array("start", "afterstart", "middle", "aftermiddle", "end", "afterend"); // just some examples foreach ($functions as $k => $v) { $k . "()"; } Yeah, that probably won't work without some thought. However you get the idea of what I meant anyway.
  5. Yes, I realized that awhile after reading it. In the end I found out it's because of the class I was trying to take had functions that were dependent on other files, so it didn't work even after changing that. Thanks.
  6. I got it, I found a contribution in the forums, that was specifically for downloads. Works perfectly, thanks.
  7. No problems with it, I am 100% sure of that. I have looked all over his forums, and it seems the class is pretty populater because it's number 1 in google for a bunch of search queries. http://www.ros.co.nz/pdf/ I know it's something I am doing, I just have to figure out what it is.
  8. I didn't have the variables because I wasn't using output buffering. I know there are 2 functions with this class I am using the ez_Streaming and ez_Output The output shoots out the raw pdf code, the streaming streams it. I really don't understand why nothing is working, and at time's when it does prompt for download it's always corrupted. Ok, that is a true statement, the definitions (based on what the class say's are Ok based on that I just ran a test, same code except with the output instead of the stream. It ALWAYS prompts for download like this, however after I download it to my computer I try to open it and I get the following message. That is always the error message I get from adobe when trying to get it to open on my computer. In the end I am stuck with the same problem.
  9. Ok. I went through and reformatted all of my code, and re-commented everything to make sure everything was very readable. Then using your example I recreated my headers again carefully trying to make sure everything was in order. In the end it didn't work. Again it's still streaming straight into the browser without any prompts for uploading or anything. Here is the new code, with the headers changes based off your example. <?php session_start(); // session for verifying login // headers to force download header("Content-disposition: attachment; filename=download.pdf"); header("Cache-Control: cache, must-revalidate"); header("Content-type: application/pdf"); // end headers to force download // check that they are logged in if(!$_SESSION['cymember']) { header('Location: index.php'); exit; } // require config file, functions file, and pdf class (config/functions has db info) require_once('../common/config.php'); require_once('../common/functions.php'); require_once('../common/class.ezpdf.php'); $pdf =& new Cezpdf(); // start pdf class $pdf->selectFont('../common/fonts/Helvetica.afm'); // get font $monthvar = mysql_real_escape_string($_POST['month']); // get post $month = date("m", $monthvar); // get month itself $year = date("Y", $monthvar); // get year itself // first day of the month $first = "1/" . date("m/Y", $monthvar); // get first day<br /> $first = strtotime($first); // convert first day to timestamp // last day of the month $last = getlastday($month, $year); $last = $last . date("/m/Y", $monthvar); $last = strtotime($last); // run query here (fully tested, this part works) $select = "SELECT * FROM transactions WHERE submitted >= '$first' and submitted <= '$last'"; $query = mysql_query($select); // while it's going through rows while ($row = mysql_fetch_array($query)) { // put information into the pdf processor $pdf->ezText(" -- Start Transaction -- User Id: " . $row['userid'] . " Biller/Account: " . $row['biller_or_account'] . " Type: " . $row['type'] . " Amount: " . $row['amount'] . " Date: " . date("d/m/Y", $row['date']) . " Date Submitted: " . date("d/m/Y", $row['submitted']) . " Status: " . $row['status'] . " -- Stop Transaction -- "); } // this is where we throw out the pdf file information. $pdf->ezStream(); ?> Any Advice?
  10. I tried that, it's not working with what I am trying to do. I have the headers on there, I tried them in multiple way's. When the thingcomes to the browser, all it's doing is outputting it, one time I got it to force the download, and then all of a sudden the file was corrupt. I am going in circles with this one, and a deadline looming over my head, I didn't know he was going to ask for it to be uploadable.
  11. Anybody, because I am fresh out of ideas. I spent almost a full day getting the pdf creation class up and running, and getting use to it. Finally got the query working and all those date calculations done, and now he's telling me he wants it to be a download instead (like when they click on the submit button to the form, I need to do all the calculations, get it to do what it's doing now). however instead of streaming through the browser it's needs to prompt as a download, any advice.
  12. The current problem is when I show the current pdf file (as shown above) it streams through the browser. I need it to prompt to download to teh person's computer but nothing is working, any advice?
  13. Ok, I modified my view page to this. <?php session_start(); // We'll be outputting a PDF header('Content-type: application/pdf'); // It will be called downloaded.pdf header('Content-Disposition: attachment; filename="downloaded.pdf"'); // The PDF source is in original.pdf readfile('transpdf.php'); if(!$_SESSION['cymember']) { header('Location: index.php'); exit; } require_once('../common/config.php'); require_once('../common/functions.php'); require_once('../common/class.ezpdf.php'); function getlastday($month, $year) { for ($day = 28; $day < 32; $day++) { if (!checkdate($month, $day, $year)) return $day-1; } } ?> <?php $pdf =& new Cezpdf(); $pdf->selectFont('../common/fonts/Helvetica.afm'); $monthvar = mysql_real_escape_string($_POST['month']); // get post //echo "<br />Month var: " . $monthvar; $month = date("m", $monthvar); // get month itself //echo "<br />Month: " . $month; $year = date("Y", $monthvar); // get year itself //echo "<br />Year: " . $year; $first = "1/" . date("m/Y", $monthvar); // get first day<br /> //echo "<br />first 1: " . $first; $first = strtotime($first); // convert first day to timestamp //echo "<br />first 2: " . $first; $last = getlastday($month, $year); //echo "<br />last 1: " . $last; $last = $last . date("/m/Y", $monthvar); //echo "<br />last 2: " . $last; $last = strtotime($last); //echo "<br />last 3: " . $last; //exit; $select = "SELECT * FROM transactions WHERE submitted >= '$first' and submitted <= '$last'"; $query = mysql_query($select); while ($row = mysql_fetch_array($query)) { $pdf->ezText(" -- Start Transaction -- User Id: " . $row['userid'] . " Biller/Account: " . $row['biller_or_account'] . " Type: " . $row['type'] . " Amount: " . $row['amount'] . " Date: " . date("d/m/Y", $row['date']) . " Date Submitted: " . date("d/m/Y", $row['submitted']) . " Status: " . $row['status'] . " -- Stop Transaction -- "); } $pdf->ezStream(); ?> It's coming back with an error saying it was corrupted or something (AFTER) it's downloaded. So basically this prompts for downlaod but it's corrupted, and before when it was just showing it as a page, it created it properly and showed the data from it.
  14. Ok, I have a form leading to a page where a pdf file is outputted (created). Form <p class="memWel memGrn">View Statements</p> <p class="memDate"> <br /><br /> <p class="memDate"> To view and/or print a specific monthly statement, select a statement period from the drop-down list below and click <strong>Go</strong>. </p> <form name="statement" id="statement" action="transpdf.php" method="post"> <select name="month"> <option>Select A Billing Cycle</option> <option>----------------------</option> <?php // something quick here, it simply outputs a drop down menu of the last 3 months. // It also accounts for leap year, and special days, and all of that other good // stuff. list($m, $y) = explode('-', date('m-Y')); for ($i = -3; $i < 1; $i++) { $ts = mktime(0,0,0,$m+$i,1,$y); $n = date('F', $ts); $days = date('t', $ts); echo "<option value=\"$ts\">$n 1 - $days</option>\n"; } ?> </select> <input name="go" type="image" src="../common/images/button_go.jpg" /> </form> <p class="memDate"> The statement you select will open up as an Adobe PDF file. You will need Adobe Reader to view the file.<br /> <a href="http://www.adobe.com/products/reader"><img border="0" src="<?php echo $wwwpath; ?>common/images/button_getadobereader.gif" align="left" /></a> </p> PDF OUTPUT FILE <?php session_start(); header("application/pdf object"); //IE 6 Fix if(!$_SESSION['cymember']) { header('Location: index.php'); exit; } require_once('../common/config.php'); require_once('../common/functions.php'); require_once('../common/class.ezpdf.php'); function getlastday($month, $year) { for ($day = 28; $day < 32; $day++) { if (!checkdate($month, $day, $year)) return $day-1; } } ?> <?php $pdf =& new Cezpdf(); $pdf->selectFont('../common/fonts/Helvetica.afm'); $monthvar = mysql_real_escape_string($_POST['month']); // get post //echo "<br />Month var: " . $monthvar; $month = date("m", $monthvar); // get month itself //echo "<br />Month: " . $month; $year = date("Y", $monthvar); // get year itself //echo "<br />Year: " . $year; $first = "1/" . date("m/Y", $monthvar); // get first day<br /> //echo "<br />first 1: " . $first; $first = strtotime($first); // convert first day to timestamp //echo "<br />first 2: " . $first; $last = getlastday($month, $year); //echo "<br />last 1: " . $last; $last = $last . date("/m/Y", $monthvar); //echo "<br />last 2: " . $last; $last = strtotime($last); //echo "<br />last 3: " . $last; //exit; $select = "SELECT * FROM transactions WHERE submitted >= '$first' and submitted <= '$last'"; $query = mysql_query($select); while ($row = mysql_fetch_array($query)) { $pdf->ezText(" -- Start Transaction -- User Id: " . $row['userid'] . " Biller/Account: " . $row['biller_or_account'] . " Type: " . $row['type'] . " Amount: " . $row['amount'] . " Date: " . date("d/m/Y", $row['date']) . " Date Submitted: " . date("d/m/Y", $row['submitted']) . " Status: " . $row['status'] . " -- Stop Transaction -- "); } $pdf->ezStream(); ?> This works completely, it brings them to the page, and it outputs a PDF with the data. Is there a way to "instead" make it when they click the button for the form, it prompts that same pdf file as a download instead.
  15. <?php session_start(); header("Cache-control: private"); //IE 6 Fix if(!$_SESSION['cymember']) { header('Location: index.php'); exit; } include('../common/config.php'); require_once('../common/class.ezpdf.php'); function getlastday($month, $year) { for ($day = 28; $day < 32; $day++) { if (!checkdate($month, $day, $year)) return $day-1; } } ?> <?php $pdf =& new Cezpdf(); $pdf->selectFont('../common/fonts/Helvetica.afm'); $monthvar = mysql_real_escape_string($_POST['month']); // get post //echo "<br />Month var: " . $monthvar; $month = date("m", $monthvar); // get month itself //echo "<br />Month var: " . $month; $year = date("Y", $monthvar); // get year itself //echo "<br />Year var: " . $year; $first = "1/" . date("m/Y", $monthvar); // get first day<br /> //echo "<br />first 1 var: " . $first; $first = strtotime($first); // convert first day to timestamp //echo "<br />first 2 var: " . $first; $last = getlastday($month, $year); //echo "<br />last 1 var: " . $last; $last = $last . date("/m/Y", $monthvar); //echo "<br />last 2 var: " . $last; $last = strtotime($last); //echo "<br />last 3 var: " . $last; //exit; $select = "SELECT * FROM transactions WHERE submitted >= '$first' and submitted <= '$last'"; $query = mysql_query($select); while ($row = mysql_fetch_array($query)) { $pdf->ezText(" -- Start Transaction -- User Id: " . $row['userid'] . " Biller/Account: " . $row['biller_or_account'] . " Type: " . $row['type'] . " Amount: " . $row['amount'] . " Date: " . date("d/m/Y", $row['userid']) . " Date Submitted: " . date("d/m/Y", $row['userid']) . " Status: " . $row['status'] . " -- Stop Transaction -- "); } $pdf->ezStream(); ?> Ok I knew I had to get the first month and the last month on this page, so I went through all the calculations and tested it. When it come's up the query isn't returning the fields. I put in some commented codes to help with debugging if I ran into this problem. It's full output is. Based on this output I know that all of the stuff is happening correctly. The only problem is it's not returning the date ranges I am trying to return.
  16. Well I have that script you originally helped me setup passing the month over to this page. <?php session_start(); header("Cache-control: private"); //IE 6 Fix if(!$_SESSION['member']) { header('Location: index.php'); exit; } include('../common/config.php'); require_once('../common/class.ezpdf.php'); ?> <?php $pdf =& new Cezpdf(); $pdf->selectFont('../common/fonts/Helvetica.afm'); $month = mysql_real_escape_string($_POST['month']); $select = "SELECT * FROM transactions WHERE submitted >= '$month' and submitted <= '$month'"; $query = mysql_query($select); while ($row = mysql_fetch_array($query)) { $pdf->ezText(" -- Start Transaction -- User Id: " . $row['userid'] . " Biller/Account: " . $row['biller_or_account'] . " Type: " . $row['type'] . " Amount: " . $row['amount'] . " Date: " . date("d/m/Y", $row['userid']) . " Date Submitted: " . date("d/m/Y", $row['userid']) . " Status: " . $row['status'] . " -- Stop Transaction -- "); } $pdf->ezStream(); ?> The month being the month that is getting passed from the other script in a timestamp. I need to narrow it down even more and only let them see one's that they have authorization to see, but first I need this to work. I know how to add on the other part, what I am trying here isn't working. I looked and what is getting past fromt hat script you help me setup. <form name="statement" id="statement" action="transpdf.php" method="post"> <select name="month"> <option>Select A Billing Cycle</option> <option>----------------------</option> <?php // something quick here, it simply outputs a drop down menu of the last 3 months. // It also accounts for leap year, and special days, and all of that other good // stuff. list($m, $y) = explode('-', date('m-Y')); for ($i = -3; $i < 1; $i++) { $ts = mktime(0,0,0,$m+$i,1,$y); $n = date('F', $ts); $days = date('t', $ts); echo "<option value=\"$ts\">$n 1 - $days</option>\n"; } ?> </select> <input name="go" type="image" src="../common/images/button_go.jpg" /> </form> It's passing the time stamp, which is how I did calculations before on another system I had to get date ranges on. Any advice on why this isn't working is appreciated, I set it to show this month too, because all the test ones are in there, and I wanted to test it, then change it back when I am done.
  17. What is the easiest way to search by date ranges when you have it saved in the db as a unix time stamp. I don't want to change the time stamp on this because it's programmed liked that throughout the rest of the system, and the deadline is drawing near, is there a way to search date ranges? I need to just use the form I created earlier (drop down menu of the month and hte 1st day last day of that month. I need to be able to get all all reports from February, or march, or whatever. Any advice?
  18. Ah perfect, after looking that your explanation then reviewing the for statement over at w3schools I have a better understanding of it. uh, well I understand what your script is doing, but I am still lost as to what the for loop does. THe reason being, I see people using for, and I alway use while/foreach. Which is better, what are the best situations in which the for loop is needed.
  19. hehe, well it's technically done I just asked him and he's ok with it. last 3 months it is.
  20. Well having to do both, I am starting to think I should use the format like obsidian suggests from the database by default. Then I can do the sorting or whatever else from there. Then I can change what I need to timestamps as the time comes. That is assuming that the date format in mysql will also contain the second, minute, hour, and day.
  21. Ah, ok that's the reason it didn't work, I didn't specify enough. I meant last 3 months (including this one.) So it would be February, March, April basically that's what I meant. Sorry about that, I can modify it myself, but could you break down the code so I understand it better, this looks like a much simpler solution to get the same results, with less code.
  22. Well it outputted Jan/feb/march, and it had the proper "dates" with it, but it needs to output this months, last months, and the months' before. That's why I was trying to do it this other way, I am not very familiar with this syntax <?php list($m, $y) = explode('-', date('m-Y')); for ($i = -3; $i < 0; $i++) { $ts = mktime(0,0,0,$m+$i,1,$y); $n = date('F', $ts); $days = date('t', $ts); echo "<option value=\"$ts\">$n 1 - $days</option>\n"; } ?> That's why a lot of times I come up with something else based on the general "suggestions" that are sometimes offered. See above, I know what list does, it takes those 2 variables and fills them with 2 variables from an array you specify (can't really explain it's functionality but I know what it does). Then when you get with all this for ($i = -3; $i < 0; $i++) { to me this is just saying i = minus 3 then i also is less than 0, and you increment i I am not sure about all this syntax, and when I look up the stuff for the for loop I don't fully get it, that's why I never took the time to use a for loop, it confused me more than helped me. That is why I looked at the suggestions and created something different so I could fully understand everything I was looking for, because I also have to make sure my back end script knows the current year (which I can do in that script), but I may have alterations I have to make based on requests from the client. Like how the 3 months are going to display and other stuff. SO far I tried what you said directly, and it worked, but it only outputted the first 3 months in the drop down menu. The only other problem is, if I had to make alterations I have <?php list($m, $y) = explode('-', date('m-Y')); for ($i = -3; $i < 0; $i++) { $ts = mktime(0,0,0,$m+$i,1,$y); $n = date('F', $ts); $days = date('t', $ts); echo "<option value=\"$ts\">$n 1 - $days</option>\n"; } ?> I don't understand how a for loop works, I don't understand what that means where you outputted the option lists, I don't understand what F, t are in the formats, and I really have no standing experience with mktime (where I have used strtotime, strftime, and date quite a bit.)
  23. Ok it's because I had '$variable' in the array I forgot to remove the single quotes. Ok just wanted to make sure, based on the output you get from date("M");// uppercase M is the following list correct $months = array("Jan" => "01-31", "Feb" => "01-28", "Mar" => "01-31", "Apr" => "01-30", "May" => "01-31", "Jun" => "01-30", "Jul" => "01-31", "Aug" => "01-31", "Sep" => "01-30", "Oct" => "01-31", "Nov" => "01-30", "Dec" => "01-31"); I know some of the abbreviates are correct like Dec, and NOV adn OCT but I am not sure what it sends out for june or july, and some of the others. Also I know all of these ranges are correct, but there was something on wikipedia, http://en.wikipedia.org/wiki/Months On the one for febuary, this is a little disturbing. I hope it's fine I just don't want to launch this a few years from now a major error that's going to cause problems (multiple) throughout the entire system.I also have a few more features to build into this, I just want to get this part right first.
  24. <?php // get array of months information $months = array("Jan" => "01-31", "Feb" => "01-28", "Mar" => "01-31", "Apr" => "01-30", "May" => "01-31", "Jun" => "01-30", "Jul" => "01-31", "Aug" => "01-31", "Sep" => "01-30", "Oct" => "01-31", "Nov" => "01-30", "Dec" => "01-31"); // get months $thismonth = date(); $thismonth = strtotime($thismonth); $lastmonth = strtotime("-1 month", $thismonth); $monthbeforelast = strtotime("-2 month", $thismonth); // turn them into the proper format $thismonth = date("M"); $lastmonth = date("M", $lastmonth); $monthbeforelast = date("M", $monthbeforelast); echo $thismonth; echo "<br />"; echo $lastmonth; echo "<br />"; echo $monthbeforelast; echo "<br />"; ?> <form name="dates" id="dates" action="" method="post"> <select name="months"> <option value="<?php echo $monthbeforelast; ?>"><?php echo $monthbeforelast . $months['$monthbeforelast']; ?></option> <option value="<?php echo $lastmonth; ?>"><?php echo $lastmonth . $months['$lastmonth']; ?></option> <option value="<?php echo $thismonth; ?>"><?php echo $thismonth . $months['$thismonth']; ?></option> </select> </form> <?php print_r($months); ?> I want to be able to get this to work. I created something now, that works perfectly except for 1 thing. It's not reading my array right, here is the full output of what is above. However where you see echo $thismonth . $months['$thismonth']; it's ignoring me trying to call that month from the array to get the numbers. Ok, that is the outputs the drop down menu (properly), I just need to check 2 things. 1. WHy isn't it outputting those number ranges and 2. Are those number ranges/dates correct, (I got them from wikipedia) 3. Using the M format is it going to match those months listed in the array or some of those abbreviations wrong, thanks.
  25. I had nothing yet, I was brain storming. My only idea was to save them all in an "array" get the current month and throw out the last 3. However, I wasn't expecting all the working examples, this give's me something great to build off of, greatly appreciated. I can definitely get something work now, I was originally just wanting a little direction, perfect. Thanks.
×
×
  • 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.