Jump to content

myrddinwylt

Members
  • Posts

    84
  • Joined

  • Last visited

    Never

Everything posted by myrddinwylt

  1. Had to modify inside TCPDF libraries as well for some strange reason. After doing that, this magically began working o.0
  2. The following code returns this error: <?php require_once './includes/tcpdf/config/lang/eng.php'; require_once './includes/tcpdf/tcpdf.php'; require_once './includes/tcpdf_invoice_lib.php'; class invoices { private $numbers = array(); private $pdf = null; private $billaddr = null; private $customers = array(); private $customers_currentid = null; public $cdr = array(); private $invoiceid = null; private $invoicedate = array(); private $invoiceperiod = array(); private $clients = array(); private $batch = array(); private $mysql = array(); private $conn = null; private $invoice_output_path = "securefiles"; function __construct($mysql,$files) { $this->mysql = $mysql; $this->files = $files; $date = date('mdy'); // $date = '2009-10-01'; $this->batch = array('lastmonthpayments'=>date('Y-m',strtotime ( '-2 month' , strtotime ( $date ) )) . '-01', 'lastmonth'=>date('Y-m',strtotime ( '-1 month' , strtotime ( $date ) )), 'lastmonthstart'=>date('Y-m',strtotime ( '-1 month' , strtotime ( $date ) )) . '-01', 'lastmonthend' => date('Y-m-j',strtotime('-1 day', strtotime(date('Y-m',strtotime ( $date )) . '-01'))),'thismonth'=>date('Y-m',strtotime($date)) . '-01','thismonthlate'=>date('Y-m',strtotime($date)) . '-20'); $this->invoiceperiod = array($this->batch['lastmonthstart'],$this->batch['lastmonthend']); $this->connect(); } function newInvoice() { if(isset($this->pdf)) { unset($this->pdf); } if(isset($this->cdr)) { unset($this->cdr); } $this->pdf = new Invoice(); $this->cdr = null; } ?> Since setting $this->pdf to NULL doesn't free it's used memory space, and "unset()" is returning an error..... ummm.... what the hell am i supposed to do XD. This is driving me insane. TCPDF has a huge memory leak, but I really don't have a choice in using it, so I need to implement some garbage cleanup freeing it's memory space prior to moving on to the next record. Any suggestions that will work ? Thanks.
  3. Personally I use "DOUBLE" as the field data type which allows for negative numbers as well as positive, and the field length, i set 20, for decimals, i set between 2 and 8 (depending on the precision of the application).
  4. Just use PHP Mailer, and authenticate with your mail server before sending messages. This would eliminate the erronious e-mail account from showing up. Yes, it's more complicated to use PHP Mailer, but it's more accurate, and ensures that every message sent from you is coming from you. I can not believe how many programs are created with this design flaw, and I really wish PHP would either toss the command or update it to allow for: Authentication POP before SMTP SSL / TLS In script configuration CC/BCC/etc HTML/Plain combination body text MIME IMAP Support Rather than monkeying about with headers, and still don't have several of the above features, such as POP before SMTP, or SSL/TLS. Just wish that developers would stop being so lazy with this area if they wish to distribute/sell the application. (not saying thats what you are doing here, but since I have signed up, you are around the 12th person who is using mail() ..... i know it's easier, but it really does create a lot of headaches -- aka... your host e-mail account showing up as originator e-mail in the header, automatically ending up in anyones spam box who uses a server that checks if your account was authenticated with your server frst -- direct mail is 99% of the time spam). Hope this helps you anyway.
  5. <?php function getTimeDiff($time1, $time2) { if($time2 > $time1) $diff = abs($time2 - $time1); } else { $diff = abs($time1 - $time2); } return CEIL($diff / 60); } ?> This should sum it up for you.
  6. If you are looking to simply generate links to PDF's for viewing/etc in the browser, the simplest way IMO: http://docs.google.com/viewer?url= So for example, if you wish to view http://www.statcan.gc.ca/pub/89-599-m/89-599-m2006003-eng.pdf , you would use the following http://docs.google.com/viewer?url=http://www.statcan.gc.ca/pub/89-599-m/89-599-m2006003-eng.pdf The only condition is the file has to be accessible online somewhere.
  7. First MrAdam, What exactly is your point of providing a link to the following information ? It doesn't state that it can not be used to point inside of an IF statement, only can not be pointed inside another loop or file. Second, I wasn't asking for you to define how a GOTO statement would solve a problem. It does resolve a problem by making the code simpler, and more controllable without the use of extending IF statements to encompass the entire body or other similar logic. And NO, PHP does not have the same power of other languages when it comes to use of the GOTO command. For example, in Visual Basic, you CAN use it to go inside another loop (which isn't what was being done here, but whatever). Controlling output buffer is not really my concern. As stated in the original post, this code runs invisible, and does not output ANYTHING until an echo or print statement is made. Notice there is no where any data is to be output inside that block of code until the loop has finished. PHP had no reason to leave that loop, until it's execution was completed, unless you are implying that PHP executes code in a random order, which would pretty much break every language rule out there. The inherant and undocumented flaw in PHP as proven above, is as follows. Breaking out of a foreach Loop using goto to enter into an else portion of an if statement causes PHP to continue execution past two closing }, regardless that the second } is the looping/closing brace for an outer loop. So my not-smart allegation is more than just an "allegation". It is a fact. PHP's GOTO command is not quite as smart as other languages which support GOTO. As for the Wikipedia entry on how GOTO is fail in Fortran, I couldn't give a flying --- . It is still something used and does provide more control over your code without slopping it over using 300 closing braces for a simple IF check. As for further evidence of it's importance, it's inclusion in even the latest version of PHP (albeit limited, but at least they are trying and it does work -- mostly). Perhaps this was a statement you missed in that Wiki entry, , which should help to clarify it's purpose in development --- YOU get to take control of the code, instead of leaving it to the whim of the pairing elseif or else statements, which in large blocks of code tend to get shoveled several hundred lines down... or more. In any case, thank you for your response, even though it was an attempt to insult my work/intelligence/coding techniques. Wow, I don't think you realise how not-smart you just sounded with that allegation. I'm not going to go into what's wrong with GOTO statements, or try to understand how a GOTO statement would solve your problem?? But just to add insult to injury, check out the PHP GOTO statement, available as of PHP5.3. To answer your original question; during long and/or memory intense loads like in your situation, PHP attempts to periodically output whatever is in the buffer. This is normally a positive thing in most situations as it free's up memory and resources. If you want to stop that you need to take control of the output buffer yourself.
  8. Sounds like a job for RegEx. $code = "your html here"; $regex = "~a[^href]*href=\"([^\\"]*)\"~"; preg_match_all('~Select Row</LABEL>.*?>(.*?)</TR>~', $code, $out); foreach($out[1] as $matchedrow) { echo $matchedrow; }
  9. if($time2 > $time1) $diff = $time2 - $time1; } else { $diff = $time1 - $time2; }
  10. Well.. resolved this one again on my own. Turns out that PHP isn't quite as smart as other languages which support "GOTO". case 'merge_cdr': include("includes/ftp.class.php"); include("includes/cdr.class.php"); include("includes/http.class.php"); include("includes/txt2sql.class.php"); include("includes/mysql.class.php"); $startdate = strtotime($download["startdate"]); $month = date("m",$startdate); $day = date("d",$startdate); $year = date("Y",$startdate); $daterange["start"] = mktime(0, 0, 0, $month ,$day,$year); $daterange["end"] = mktime(0,0,0,date("m"),date("d")-2,$year); $daysdownloaded = null; foreach($cdrformats as $cdrformat) { $cdr = new cdr(); $cdr->dateposition = $cdrformat["date"]; switch($cdrformat["type"]) { case "ftp": $ftp = new ftp(); $ftp->connect($cdrformat["server"],$cdrformat["username"],$cdrformat["password"],1); $ftp->nlist($cdrformat["path"]); $cfiles = $ftp->files($cdrformat["filter"]); if($cdrformat["path"] != null && $cdrformat["path"] !="") { $ftp->chdir($cdrformat["path"]); } foreach($cfiles as $file) { $fdate = $cdr->filedate($file,$cdrformat["dateoffset"]); if ($fdate >= $daterange["start"] && $fdate <= $daterange["end"]) { if(file_exists($download['path'] . date("Y-m-d",$fdate) . "." . $cdrformat["name"]) || file_exists("sql\\" . date("Y-m",$fdate) . "\\" . date("Y-m-d",$fdate) . ".sql")) { if($download['overwrite'] != 0) { set_time_limit(500); @unlink($download["path"] . $file); $ftp->get($file, $download['path'] . date("Y-m-d",$fdate) . "." . $cdrformat["name"]); $downloads[$cdrformat["name"]][] = $download['path'] . date("Y-m-d",$fdate) . "." . $cdrformat["name"]; $daysdownloaded[] = date("Y-m-d",$fdate); // echo date("Y-m-d",$fdate) . " - " . $file . "<br>"; } } else { set_time_limit(500); $ftp->get($file, $download['path'] . date("Y-m-d",$fdate) . "." . $cdrformat["name"]); $downloads[$cdrformat["name"]][] = $download['path'] . date("Y-m-d",$fdate) . "." . $cdrformat["name"]; $daysdownloaded[] = date("Y-m-d",$fdate); } } } $ftp->disconnect(); $ftp = null; break; case "http" || "https": $http = new http($cdrformat['server'],$cdrformat['username'],$cdrformat['password'],$cdrformat['type'] ); $http->nlist($cdrformat["path"],$cdrformat["prefixfile"]); $cfiles = $http->files($cdrformat["filter"]); foreach($cfiles as $file) { $fdate = $cdr->filedate($file,$cdrformat["dateoffset"]); if ($fdate >= $daterange["start"] && $fdate <= $daterange["end"]) { if(file_exists($download['path'] . date("Y-m-d",$fdate) . "." . $cdrformat["name"]) || file_exists("sql\\" . date("Y-m",$fdate) . "\\" . date("Y-m-d",$fdate) . ".sql")) { if($download['overwrite'] != 0) { set_time_limit(500); @unlink($download["path"] . $file); $http->get($file, $cdrformat["prefixfile"], $download['path'] . date("Y-m-d",$fdate) . "." . $cdrformat["name"]); $downloads[$cdrformat["name"]][] = $download['path'] . date("Y-m-d",$fdate) . "." . $cdrformat["name"]; $daysdownloaded[] = date("Y-m-d",$fdate); } } else { set_time_limit(500); $http->get($file, $cdrformat["prefixfile"], $download['path'] . date("Y-m-d",$fdate) . "." . $cdrformat["name"]); $downloads[$cdrformat["name"]][] = $download['path'] . date("Y-m-d",$fdate) . "." . $cdrformat["name"]; $daysdownloaded[] = date("Y-m-d",$fdate); } } } break; default: break; } $cdr = null; } $missingfiles = null; if($daysdownloaded != null) { $daysdownloaded = array_unique($daysdownloaded); foreach($daysdownloaded as $daydownloaded) { foreach($cdrformats as $cdrformat) { if(!file_exists("downloads\\" . $daydownloaded . "." . $cdrformat['name'])) { goto skipday; break; } } $mysqldb1 = new mysql($mysql['server'],$mysql['username'],$mysql['password'],$mysql['database'],$mysql['databasetmp'],$cdrformat['name']); $databaseformat = "DROP TABLE IF EXISTS `##DATABASE##`.`##MONTH##`;\nCREATE TABLE `##DATABASE##`.`##MONTH##` ( `uniqueid` int(11) DEFAULT NULL, `Caller` varchar(255) DEFAULT NULL, `Started` datetime DEFAULT NULL, `Dialed` varchar(255) DEFAULT NULL, `DurationSec` int(11) DEFAULT NULL, `DurationMin` int(11) DEFAULT NULL, `Cost` double DEFAULT NULL, `Location` varchar(60) DEFAULT NULL, `Switch` varchar(15) DEFAULT 'Cellular');"; $databaseformat = str_replace("##MONTH##",substr($daydownloaded,0,-3),$databaseformat); $databaseformat = str_replace("##DATABASE##",$mysql['databasetmp'],$databaseformat); $mysqldb1->executesql($databaseformat); $mysqldb1 = null; unset($mysqldb1); $i = 0; foreach($cdrformats as $cdrformat) { if(!file_exists("downloads\\" . $daydownloaded . "." . $cdrformat['name'])) { goto missingfile; } $txt2sql = new txt2sql($cdrformat["name"],$cdrformat["delimiter"],$cdrformat['skiprows'],$mysql['databasetmp']); $vals = $txt2sql->getFile($daydownloaded); $txt2sql = null; unset($txt2sql); $b = ""; $c = ""; $d = ""; $b = str_replace("##DATABASE##",$mysql['databasetmp'],$cdrformat["sql"]["beforerates"]); $d = str_replace("##DATABASE##",$mysql['databasetmp'],$cdrformat["sql"]["migrate"]) . "\n" . "DROP TABLE IF EXISTS `" . $mysql['databasetmp'] . "`.`" . $cdrformat['name'] . "`;\n"; $d = str_replace("##MONTH##",substr($daydownloaded,0,-3),$d); $mysqldb = new mysql($mysql['server'],$mysql['username'],$mysql['password'],$mysql['database'],$mysql['databasetmp'],$cdrformat['name']); if($cdrformat["userates"] == true) { $c = implode("\n",$mysqldb->getrates($cdrformat['useratesfields']['ratefield'],$cdrformat['useratesfields']['locationfield'],$cdrformat['useratesfields']['durationfield'],$cdrformat['useratesfields']['codefield'])); } $vals .= $b . $c . $d; $b = null; $c = null; $d = null; @mkdir("sql\\" . substr($daydownloaded,0,-3) . "\\" . substr($daydownloaded,-2),0777,1); file_put_contents("sql\\" . substr($daydownloaded,0,-3) . "\\" . substr($daydownloaded,-2) . "\\" . $daydownloaded . "." . $cdrformat['name'] . ".sql", $vals); $mysqldb->executesql($vals); $vals = null; $mysqldb = null; unset($vals, $mysqldb, $b, $c, $d); goto nextcdrformat; missingfile: $missingfiles[$cdrformat['name']][] = $daydownloaded; $i++; nextcdrformat: } foreach($cdrformats as $cdrformat) { @unlink("downloads\\" . $daydownloaded . $cdrformat['name']); } if($i == 0) { set_time_limit(3600); $mysqldb1 = new mysql($mysql['server'],$mysql['username'],$mysql['password'],$mysql['database'],$mysql['databasetmp'],$cdrformat['name']); $vals = implode("\n",$mysqldb1->dumpsql($daydownloaded)); @mkdir("sql\\" . substr($daydownloaded,0,-3),0777,1); file_put_contents("sql\\" . substr($daydownloaded,0,-3) . "\\" . $daydownloaded . ".sql", $vals); $mysqldb1->executesql("DROP TABLE IF EXISTS `" . $mysql['databasetmp'] . "`.`" . substr($daydownloaded,0,-3) . "`;"); $mysqldb1->executesql($vals); $vals = null; unset($vals, $mysqldb1); // echo "MERGED: " . $daydownloaded . "<br />"; } else { // echo "MISSING: " . $daydownloaded . "<br />"; } skipday: } } echo "CDR's Downloaded & Merged"; break; Had to move skipday:to just outside the last if statment.
  11. Here is some help with potential flaws that you should look into to see if any apply: First: The all too famous "Include" statement Include Vulnerability - Wikipedia - This topic just touches on the problem with using Include in a brief sensible manner Code Injection Vulnerabilities - This article goes into a bit more detail on how an Include could cause a security issue on your server, and briefly discusses some alternatives. SQL Injections - Article outlining how SQL injections work. If your queries are not sanitized, then, you leave yourself open to problems with your data in your database. If that data also happens to be output to a web page, and/or the web page has exec capabilities on that code, then pretty much anything can happen. Again, as stated in the above posts by other members of this site, without analysing your code (which could be intensive), the server / php / and libraries loaded, ports open, etc, there is no real way to determine 100% how your site got hijacked. The above links should at least point you in the right direction for the type of research you must do if you wish to resolve the problem yourself.
  12. Hello, I am using AJAX to toggle back and forth between "switch/case" by sending a new POST var defining which "case" i wish to execute. At the end of each case, is an echo, which defines progress status, and essentialy is returned to the AJAX html request, and processed client side. So far, it works great for any of the cases I have pushed on it, except this one. case 'merge_cdr': include("includes/ftp.class.php"); include("includes/cdr.class.php"); include("includes/http.class.php"); include("includes/txt2sql.class.php"); include("includes/mysql.class.php"); $startdate = strtotime($download["startdate"]); $month = date("m",$startdate); $day = date("d",$startdate); $year = date("Y",$startdate); $daterange["start"] = mktime(0, 0, 0, $month ,$day,$year); $daterange["end"] = mktime(0,0,0,date("m"),date("d")-2,$year); $daysdownloaded = null; foreach($cdrformats as $cdrformat) { $cdr = new cdr(); $cdr->dateposition = $cdrformat["date"]; switch($cdrformat["type"]) { case "ftp": $ftp = new ftp(); $ftp->connect($cdrformat["server"],$cdrformat["username"],$cdrformat["password"],1); $ftp->nlist($cdrformat["path"]); $cfiles = $ftp->files($cdrformat["filter"]); if($cdrformat["path"] != null && $cdrformat["path"] !="") { $ftp->chdir($cdrformat["path"]); } foreach($cfiles as $file) { $fdate = $cdr->filedate($file,$cdrformat["dateoffset"]); if ($fdate >= $daterange["start"] && $fdate <= $daterange["end"]) { if(file_exists($download['path'] . date("Y-m-d",$fdate) . "." . $cdrformat["name"]) || file_exists("sql\\" . date("Y-m",$fdate) . "\\" . date("Y-m-d",$fdate) . ".sql")) { if($download['overwrite'] != 0) { set_time_limit(500); @unlink($download["path"] . $file); $ftp->get($file, $download['path'] . date("Y-m-d",$fdate) . "." . $cdrformat["name"]); $downloads[$cdrformat["name"]][] = $download['path'] . date("Y-m-d",$fdate) . "." . $cdrformat["name"]; $daysdownloaded[] = date("Y-m-d",$fdate); // echo date("Y-m-d",$fdate) . " - " . $file . "<br>"; } } else { set_time_limit(500); $ftp->get($file, $download['path'] . date("Y-m-d",$fdate) . "." . $cdrformat["name"]); $downloads[$cdrformat["name"]][] = $download['path'] . date("Y-m-d",$fdate) . "." . $cdrformat["name"]; $daysdownloaded[] = date("Y-m-d",$fdate); } } } $ftp->disconnect(); $ftp = null; break; case "http" || "https": $http = new http($cdrformat['server'],$cdrformat['username'],$cdrformat['password'],$cdrformat['type'] ); $http->nlist($cdrformat["path"],$cdrformat["prefixfile"]); $cfiles = $http->files($cdrformat["filter"]); foreach($cfiles as $file) { $fdate = $cdr->filedate($file,$cdrformat["dateoffset"]); if ($fdate >= $daterange["start"] && $fdate <= $daterange["end"]) { if(file_exists($download['path'] . date("Y-m-d",$fdate) . "." . $cdrformat["name"]) || file_exists("sql\\" . date("Y-m",$fdate) . "\\" . date("Y-m-d",$fdate) . ".sql")) { if($download['overwrite'] != 0) { set_time_limit(500); @unlink($download["path"] . $file); $http->get($file, $cdrformat["prefixfile"], $download['path'] . date("Y-m-d",$fdate) . "." . $cdrformat["name"]); $downloads[$cdrformat["name"]][] = $download['path'] . date("Y-m-d",$fdate) . "." . $cdrformat["name"]; $daysdownloaded[] = date("Y-m-d",$fdate); } } else { set_time_limit(500); $http->get($file, $cdrformat["prefixfile"], $download['path'] . date("Y-m-d",$fdate) . "." . $cdrformat["name"]); $downloads[$cdrformat["name"]][] = $download['path'] . date("Y-m-d",$fdate) . "." . $cdrformat["name"]; $daysdownloaded[] = date("Y-m-d",$fdate); } } } break; default: break; } $cdr = null; } $missingfiles = null; if($daysdownloaded != null) { $daysdownloaded = array_unique($daysdownloaded); foreach($daysdownloaded as $daydownloaded) { foreach($cdrformats as $cdrformat) { if(!file_exists("downloads\\" . $daydownloaded . "." . $cdrformat['name'])) { goto skipday; break; } } $mysqldb1 = new mysql($mysql['server'],$mysql['username'],$mysql['password'],$mysql['database'],$mysql['databasetmp'],$cdrformat['name']); $databaseformat = "DROP TABLE IF EXISTS `##DATABASE##`.`##MONTH##`;\nCREATE TABLE `##DATABASE##`.`##MONTH##` ( `uniqueid` int(11) DEFAULT NULL, `Caller` varchar(255) DEFAULT NULL, `Started` datetime DEFAULT NULL, `Dialed` varchar(255) DEFAULT NULL, `DurationSec` int(11) DEFAULT NULL, `DurationMin` int(11) DEFAULT NULL, `Cost` double DEFAULT NULL, `Location` varchar(60) DEFAULT NULL, `Switch` varchar(15) DEFAULT 'Cellular');"; $databaseformat = str_replace("##MONTH##",substr($daydownloaded,0,-3),$databaseformat); $databaseformat = str_replace("##DATABASE##",$mysql['databasetmp'],$databaseformat); $mysqldb1->executesql($databaseformat); $mysqldb1 = null; unset($mysqldb1); $i = 0; foreach($cdrformats as $cdrformat) { if(!file_exists("downloads\\" . $daydownloaded . "." . $cdrformat['name'])) { goto missingfile; } $txt2sql = new txt2sql($cdrformat["name"],$cdrformat["delimiter"],$cdrformat['skiprows'],$mysql['databasetmp']); $vals = $txt2sql->getFile($daydownloaded); $txt2sql = null; unset($txt2sql); $b = ""; $c = ""; $d = ""; $b = str_replace("##DATABASE##",$mysql['databasetmp'],$cdrformat["sql"]["beforerates"]); $d = str_replace("##DATABASE##",$mysql['databasetmp'],$cdrformat["sql"]["migrate"]) . "\n" . "DROP TABLE IF EXISTS `" . $mysql['databasetmp'] . "`.`" . $cdrformat['name'] . "`;\n"; $d = str_replace("##MONTH##",substr($daydownloaded,0,-3),$d); $mysqldb = new mysql($mysql['server'],$mysql['username'],$mysql['password'],$mysql['database'],$mysql['databasetmp'],$cdrformat['name']); if($cdrformat["userates"] == true) { $c = implode("\n",$mysqldb->getrates($cdrformat['useratesfields']['ratefield'],$cdrformat['useratesfields']['locationfield'],$cdrformat['useratesfields']['durationfield'],$cdrformat['useratesfields']['codefield'])); } $vals .= $b . $c . $d; $b = null; $c = null; $d = null; @mkdir("sql\\" . substr($daydownloaded,0,-3) . "\\" . substr($daydownloaded,-2),0777,1); file_put_contents("sql\\" . substr($daydownloaded,0,-3) . "\\" . substr($daydownloaded,-2) . "\\" . $daydownloaded . "." . $cdrformat['name'] . ".sql", $vals); $mysqldb->executesql($vals); $vals = null; $mysqldb = null; unset($vals, $mysqldb, $b, $c, $d); goto nextcdrformat; missingfile: $missingfiles[$cdrformat['name']][] = $daydownloaded; $i++; nextcdrformat: } foreach($cdrformats as $cdrformat) { @unlink("downloads\\" . $daydownloaded . $cdrformat['name']); } if($i == 0) { set_time_limit(3600); $mysqldb1 = new mysql($mysql['server'],$mysql['username'],$mysql['password'],$mysql['database'],$mysql['databasetmp'],$cdrformat['name']); $vals = implode("\n",$mysqldb1->dumpsql($daydownloaded)); @mkdir("sql\\" . substr($daydownloaded,0,-3),0777,1); file_put_contents("sql\\" . substr($daydownloaded,0,-3) . "\\" . $daydownloaded . ".sql", $vals); $mysqldb1->executesql("DROP TABLE IF EXISTS `" . $mysql['databasetmp'] . "`.`" . substr($daydownloaded,0,-3) . "`;"); $mysqldb1->executesql($vals); $vals = null; unset($vals, $mysqldb1); // echo "MERGED: " . $daydownloaded . "<br />"; } else { skipday: // echo "MISSING: " . $daydownloaded . "<br />"; } } } echo "CDR's Downloaded & Merged"; break; This particular case returns the "echo" statement, while it is still processing -- in fact almost immediatly after AJAX makes the call for "merge_cdr". I know that the PHP function is still processing as I can open up Navicat, and watch the tables and structures, and SQL changes occuring live --- After the "CDR's Downloaded & Merged" message has shown in the browser. This entire block of code takes approximatly 1-3 minutes per file, and there could be several files. Any idea as to why the Echo is occuring before the code has completed processing ?
  13. Might seem like adding an extra layer, but here goes. The built in "mail" command doesn't authenticate, and can cause mail (when it does work), to end up in peoples junk folders. You can use the following script PHPMailer which uses raw socket connections for full communication with the mail server. Where mail() has failed, PHPMailer has succeeded with flying colors. It is also 100% free. Not sure why PHP has not updated their mail() function to allow for such things as authentication, CC, BCC, SSL/TLS, etc, etc, but whatever, this script does everything you need for sending mail --- it even has POP before SMTP authentication.
  14. Look up the "datetime" field, or "timestamp", either can be sorted by ASC or DESC. The "datetime" field, follows the format "2010-01-31 13:29:29", where the "timestamp" field stores as a Unix timestamp (looks like a really long number) -- "13992988499" or something like that. Handling different types in php datetime $val = strtotime($row['datetimefieldname']); timestamp $val = $row['timestampfieldname']; Sorting in MySQL .... ORDER BY `datetime_or_timestamp_field_name` ASC ... Both blocks of PHP code above get the Date/Time value in UNIX Timestamp format, which is the easiest to reformat (in my opinion). See date() for more information on formatting date/times.
  15. As for the char at the very beginning, not sure why that is happening outside of the editor, or something funky the "include" command is doing to it. To be safe that it isn't the "html" file you are including, try removing that char using the following free editor: Notepad++ If the character is not in the "html" file when opening with that program, then there is something happening during the "include" process which is adding it. Good luck you guys
  16. For odd characters, you could try switching your header to something like the following <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Your Site Name</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> This also helps with some compatability issues with CSS (W3 Transitional), and the meta http-equiv, tells the browser to display UTF-8 chars properly.
  17. Yes, I am just saying it's bad practice, even though it is something generally used. If the file is 100% pure HTML, the why not use SSI. Include will work, but opens a whole can of potential problems (such as if your html gets 'infected' through an exploit of just this method). Code like ">>" also are interpreted, the list goes on. file_get_contents() / echo combination doesn't allow for interpretation of inserted code. As for PHP_kid's problem in OP, I believe that it does lie within the IE6 style statements as Pikachu2000 pointed out. I am confident you will notice the problem and help the OP resolve this issue though. Was simply pointing out bad practice as "include" does open a whole can of worms best left closed to internal code execution only.
  18. That particular instance, sure, but there are plenty of others. Google is your friend, and the list of blunders is huge. Only if you don't have an understanding of php's list of blunders. That code would be affected by php's short open tag setting.
  19. kenrbnson; I have seen it cause problems in action. "INCLUDE" tries to interpret the syntax of the file. Here is a great example of an opening tag which causes the interpreter to go wonky straight from W3.org. There are a lot of others, but really don't want to waste my time researching and listing them all, just take my word for it, INCLUDE executes code. FILE_GET_CONTENTS / ECHO ... will display the contents as is. Even Smarty has trouble with CSS / Javascript / etc, due to similarities in language syntax's, openings of code, etc. <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Virtual Library</title> </head> <body> <p>Moved to <a href="http://example.org/">example.org</a>.</p> </body> </html> There could also be other problems at play here which could be bypassed by simply spewing out the contents of the file using file_get_contents(), such as SSI support. SSI allows for inclusion of other files using the following format: <!--#include virtual="insertthisfile.html" --> Which PHP may also interpret as an opening statment because of the "<!" ... again server configuration depending. You are also aware that "<%", or pretty much whatever you wanna name the tag can be used as openers, and being able to define settings in php.ini using php commands such as "ini_set_" .... This could be done with any third party control, etc. Essentialy, what I am saying, is there are so many variables on how "include" to include a file containing HTML for display can go wrong, it is simpler just to state, file_get_contents(), or another stdin/stdout of the file such as from a database, other server, etc, is much safer.
  20. Most date/date&time/time strings can be converted into a PHP timestamp using the following command $stamp = strtotime("YOURSTRINGHERE"); You can then use the formatting commands that PHP has to layout the date/time however you see fit. Date & Time formatting Please note that newer versions of PHP require the use of date_default_timezone_set("America/Toronto"); prior to any date/time string manipulation -- replace "America/Toronto" with whichever your server location is at. See here for a complete list of all available zones selectable by region/country.
  21. PHP_Kid, I have seen this problem before. If you are doing what I think you are doing, don't! The "include" command is mean to execute php code, not simply for the display of HTML/CSS content. If the files you wish to include are HTML, consider doing the following instead: $body = file_get_contents("yourfilename.html"); echo $body; If you have some code you wish to execute and have displayed statically, you could consider entering a placeholder tag in the file yourfilename.html such as ##BODY##, and then doing the following: $str = '<p>This is a really cool page</p>'; $body = file_get_contents("yourfilename.html"); $body = str_replace("##BODY##", $str, $body); echo $body; I find this method is much simpler and more flexible in a lot of cases than using template packages such as Smarty, as a lot of times, I don't really need any advanced features that those packages provide for template/php combining. Feel free to modify the amount of "tags" you create and their content in which they are replaced. Some servers do have file_get_contents() disabled, so you could always store the HTML in a database record, and then retrieve it from their instead.
  22. This is the code I use to allow me to get by the problem as stated. /config.inc.php define('BASE_URL','http://' . $_SERVER['HTTP_HOST'] . str_replace('config.inc.php','',str_replace($_SERVER['DOCUMENT_ROOT'],'', str_replace('\\','/',__FILE__)))); define('BASE_REAL_PATH',str_replace('config.inc.php','', str_replace('\\','/',__FILE__))); In subfolders, I do the following. include('/config.inc.php'); echo BASE_REAL_PATH; I think I know why you wish to do this. Some hosts do not allow the use of "../" for includes, as well as the fact that doing a "../" include can be unreliable at times due to different folders, sub-folders, etc, and if you are using the script in SEO, then the current direction could be faked, and thus, the "../" include would fail (see phpBB for plenty of examples of this). The above code has allowed me to do a direct include without ever encountering any of the stated problems. You can name "config.inc.php" whatever you wish, just make sure to replace any instances of it in the code with the new file name. It is also strongly recommended that this is placed in the root / directory to simplify access to it from any sub-folder scripts using the second block of code.
  23. They also have to be from the same distribution. Aka, if you download PHP right now, and then download it say 20 minutes later from official, you will get different compile versions, and as a result, they will not match, and fail to load. In your case, the earlier version was from 2006.
  24. I just encountered this problem myself. Also, no one responded to my post either, but I was able to resolve it. The problem is that the newer versions of PHP went dumb and can't figure out that "localhost" equals "127.0.0.1". Use 127.0.0.1 instead of localhost and you will have no problems (providing the correct credentials, server is started, etc etc.) Cheers. (ps: hope they stop "fixing" shit that ain't broke over at the php dev crew, and maybe release proper instructions on how to compile under windows and provide ALL the libraries included necessary to compile in the source they distro rather than leaving it up to people to randomly figure out (hopelessly) where they go).
×
×
  • 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.