Re: [PHP] how call a variable in a text
I don't think it is about readability: $arr[3] = 'test'; $test = 3; //This prints "$test" echo "This doesn't work: $$arr[3]"; //This prints 3 echo "This works: ${$arr[3]}"; Using the same type way as before in this thread. Above example is a classic one where readability and maintainability deal well together. First of all everything works as expected but obviously you need to know what you need. It is ambiguous to write $$arr[3] ... what do you expect?] No I don't think it is. It produces "$test" and if this is what you need echo it works nice :-) . Did you mean the variable derived by $arr[3]? echo "This works: {$$arr[3]}"; since curly brackets make the meaning of the expression explicit, it will be 3 indeed. What is the less ambiguous, readable, easy to maintain, way to obtain that result? echo "This works: {${$arr[3]}}"; If our aim is to get the variable with name equal to the value of $arr[3] Can you see now why I am talking about good practice? Zero ambiguity, and that's how I like to code Regards Although I totally agree with the way of thinking and it is my style as well. But I though that the point of the thread was to present ways of putting vars inside strings... -- Thodoris
Re: [PHP] how call a variable in a text
Using the same type way as before in this thread. This was supposed to come out as "using the same way of thinking". But the English->Nerdish dictionary came out... -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how call a variable in a text
> So no they are not meant to go around. You can use them this way as well. that has almost the same meaning of $_ = '_POST'; echo count($$_); which again, for readability brackets are suggested to improve maintainability $_ = '_POST'; echo count(${$_}); Regards <http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_2:092009> I don't think it is about readability: $arr[3] = 'test'; $test = 3; //This prints "$test" echo "This doesn't work: $$arr[3]"; //This prints 3 echo "This works: ${$arr[3]}"; Using the same type way as before in this thread. My point is that in the curly braces you protect the way the evaluation is going to be made into the string. So you can put them anywhere as long as it is meaningful. See some examples: http://php.net/manual/en/language.types.string.php in the complex (curly) syntax section. -- Thodoris
Re: [PHP] how call a variable in a text
Erm, the braces are meant to go *around* the variable, not around a bit of it: print "Test: {$var[0][0]}"; Thanks, Ash http://www.ashleysheridan.co.uk In many cases braces can go around the variable name not the necessarily around the whole variable (like the bash scripts). Those are coming from the manual: function test() { // NULL -- not what initially expected $string = '_POST'; var_dump(${$string}); // Works as expected var_dump(${'_POST'}); // Works as expected global ${$string}; var_dump(${$string}); } So no they are not meant to go around. You can use them this way as well. -- Thodoris
Re: [PHP] how call a variable in a text
On Wed, 2009-10-21 at 23:11 +0200, Kim Madsen wrote: Ashley Sheridan wrote on 2009-10-21 22:56: Try this though: Print "This is different from your previous example :-)"; -- Kind regards Kim Emax - masterminds.dk Yeah, I just forgot that PHP will correctly work with an array to a depth of 1 inside of a string. Much like the above advice, I'd taken to always using {} for arrays inside of strings, although not for strings inside of strings unless I needed non-white-space text to immediately follow said string. Would make more sense if I used the braces for everything, but nobody has ever accused me of making too much sense before! Thanks, Ash http://www.ashleysheridan.co.uk This will also work (shell like style): print "Test: ${var[0]}"; but this won't based on the same principle you mention above: print "Test: ${var[0][0]}"; -- Thodoris
Re: [PHP] Get rid of warning massage
http://php.net/manual/en/language.operators.errorcontrol.php ? A better idea would be suppressing the error messages in a production site: ini_set('display_errors',0); -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Get rid of warning massage
How do you mean an invalid URL? A URL that is not valid as in $url = "poo" or a valid formed URL that doesn't exist? Thanks, Ash http://www.ashleysheridan.co.uk Does it really matter? In both cases the file_get_contents() wont be able to open the URL and it will produce a warning or an error. -- Thodoris
Re: [PHP] Please don't kick me!
Hi all. I know this question has been asked a thousand times on the list, but my searches in the archives are not being nice to me. So... please don't kick me. Currently, we use DOMPDF to generate PDFs from HTML. However, it's no longer maintained and it has a few bugs that we just can no longer live with. What PDF generating software do you use? It does not have to be free, but it must run on linux and may be command line or run through code. Some of the ones I have researched are... html2pdf html2ps html2fpdf xhtml2pdf fpdf tcpdf You're thoughts would be appreciated. Oh, my preference would be to send HTML/CSS to a script and it just automagically convert to PS/PDF. Thanks, ~Philip I find tcpdf very useful although ezpdf seems faster after a first look. I am using tcpdf though because it has a native utf-8 support that most pdf classes don't and that is vital to me. I wasn't able to print greek for example with some other classes I 've tried. I am not sure if ezpdf does that. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PEAR segfaulting
/Registry.php on line 1183 warning: pear/PEAR requires package "pear/Archive_Tar" (recommended version 1.3.3) PHP Deprecated: Function set_magic_quotes_runtime() is deprecated in /usr/bin/temp/PEAR/Registry.php on line 1179 PHP Deprecated: Function set_magic_quotes_runtime() is deprecated in /usr/bin/temp/PEAR/Registry.php on line 1183 PHP Deprecated: Function set_magic_quotes_runtime() is deprecated in /usr/bin/temp/PEAR/Registry.php on line 1179 PHP Deprecated: Function set_magic_quotes_runtime() is deprecated in /usr/bin/temp/PEAR/Registry.php on line 1183 warning: pear/PEAR requires package "pear/Structures_Graph" (recommended version 1.0.2) PHP Deprecated: Function set_magic_quotes_runtime() is deprecated in /usr/bin/temp/PEAR/Registry.php on line 1179 PHP Deprecated: Function set_magic_quotes_runtime() is deprecated in /usr/bin/temp/PEAR/Registry.php on line 1183 PHP Deprecated: Function set_magic_quotes_runtime() is deprecated in /usr/bin/temp/PEAR/Registry.php on line 1179 PHP Deprecated: Function set_magic_quotes_runtime() is deprecated in /usr/bin/temp/PEAR/Registry.php on line 1183 warning: pear/PEAR requires package "pear/Console_Getopt" (recommended version 1.2.3) PHP Deprecated: Function set_magic_quotes_runtime() is deprecated in /usr/bin/temp/PEAR/Registry.php on line 1179 PHP Deprecated: Function set_magic_quotes_runtime() is deprecated in /usr/bin/temp/PEAR/Registry.php on line 1183 PHP Deprecated: Function set_magic_quotes_runtime() is deprecated in /usr/bin/temp/PEAR/Registry.php on line 1179 PHP Deprecated: Function set_magic_quotes_runtime() is deprecated in /usr/bin/temp/PEAR/Registry.php on line 1183 warning: pear/PEAR requires package "pear/XML_Util" (recommended version 1.2.1) PHP Deprecated: Function set_magic_quotes_runtime() is deprecated in /usr/bin/temp/PEAR/Registry.php on line 1179 PHP Deprecated: Function set_magic_quotes_runtime() is deprecated in /usr/bin/temp/PEAR/Registry.php on line 1183 PHP Deprecated: Function set_magic_quotes_runtime() is deprecated in /usr/bin/temp/PEAR/Registry.php on line 1179 PHP Deprecated: Function set_magic_quotes_runtime() is deprecated in /usr/bin/temp/PEAR/Registry.php on line 1183 PHP Deprecated: Function set_magic_quotes_runtime() is deprecated in /usr/bin/temp/PEAR/Registry.php on line 1179 PHP Deprecated: Function set_magic_quotes_runtime() is deprecated in /usr/bin/temp/PEAR/Registry.php on line 1183 downloading PEAR-1.9.0.tgz ... Starting to download PEAR-1.9.0.tgz (291,634 bytes) ..done: 291,634 bytes Segmentation fault Manually is the best solution as far as I can tell: http://pear.php.net/manual/en/installation.getting.php Eddie is right. Give it a try. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PEAR segfaulting
Thodoris wrote: Is there a good reason for needing this pear package? http://pear.php.net/package/DB It is old and it has been replaced with MDB2 some time ago. Why don't you use it instead of trying to install DB. The issue here isn't what package is being installed. The issue is that PEAR segfaults no matter what I try to install. PECL works just fine (at least I was able to install something with it.) Obviously something went wrong while installing PHP and you will have to find this because this probably the reason pear segfaults. Did you run make test before installing? (makes sure everything went well) You know you don't need pear binary to use a pear's package right? (it's pure PHP after all) -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How do YOU set default function/method params?
Here is a problem that I have had for years now. I have been trying to come up with the perfect solution for this problem. But, I have come down to two different methods for solving it. Here is the problem... date('c'), 'Message-ID' => md5($to.$subject), ); $headers += $defaults; END of examples... Now, IMO, the last one is the simplest one and for me, I think it will be the new way that I solve this type of problem. But, my question that I put out to all of you is... How would you solve this problem? TIA Jim Lucas You could always check these functions: http://www.php.net/manual/en/function.func-get-arg.php http://www.php.net/manual/en/function.func-get-args.php http://www.php.net/manual/en/function.func-num-args.php They come with PHP 5.3. You can use them like Perl's shift if you like. PS Didn't bother to read the whole thread as you will all understand. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PEAR segfaulting
Thodoris wrote: Was, by any chance, PHP installed as binary before you install it from source? If this is the case try uninstalling the binary and then configure and compile the source again running 'make clean' before. PHP was not installed at all on this machine. I grabbed the source from php.net and installed that. Is there a good reason for needing this pear package? http://pear.php.net/package/DB It is old and it has been replaced with MDB2 some time ago. Why don't you use it instead of trying to install DB. http://pear.php.net/package/MDB2 Just a thought :-) -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PEAR segfaulting
Typing 'pear segmentation fault' in Google produces tons of responses so I know I'm not the only one with this issue, but I'll be damned if I can figure out what the problem is and how to fix it. I rolled my own PHP 5.3.0 from source. Compilation went fine, no errors. Installation went without any errors. I can run 'pecl' and install some packages, but when I try to run 'pear', it segfaults after it downloads a package: $ pear install DB WARNING: "pear/DB" is deprecated in favor of "pear/MDB2" downloading DB-1.7.13.tgz ... Starting to download DB-1.7.13.tgz (132,246 bytes) .done: 132,246 bytes Segmentation fault Was, by any chance, PHP installed as binary before you install it from source? If this is the case try uninstalling the binary and then configure and compile the source again running 'make clean' before. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Wrong Date
Hello, My currently timezone is set to : America/Sao_Paulo My currently date/time is ok: Fri Oct 16 13:04:45 BRT 2009 But when I execute "echo date("d/m/Y H:i:s");" the output presented have +1 hour Bellow [date] of php.ini: date date/time support => enabled "Olson" Timezone Database Version => 2008.2 Timezone Database => internal Default timezone => America/Sao_Paulo Directive => Local Value => Master Value date.default_latitude => 31.7667 => 31.7667 date.default_longitude => 35.2333 => 35.2333 date.sunrise_zenith => 90.58 => 90.58 date.sunset_zenith => 90.58 => 90.58 date.timezone => no value => no value Thanks Assuming you have a unix-like OS and the timezone you mention is set to the system clock I will have to guess that PHP uses different zone from the system. Try setting the date.timezone setting in your php.ini and see what happens (don't forget to restart the web server to make changes take effect) or use the ini_set(). -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] preg_match doesn't match Greek
Hi gang, I am trying to make a form validation using preg_match and it fails. I think it is because the input is in Greek. I have made this script: $str = "ΕΕΝ 5196"; $pattern = "/^[[:alnum:]\s\-\,]*$/u"; echo ''; print preg_match($pattern,$str,$matches)."\n"; print_r($matches); to test preg_match's behavior and when the above string has Latin characters the pattern matches when it's in greek. Can someone explain this? Is there a workaround? PS all are in UTF-8. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] str_to_date equivalent in PHP
Well it does make sense if you leave in UK :-) . But I was asking about how to change a day/month/year formated date (or a date in any format I like) to mysql format. The basic problem is that I need to define the format that the date is in. Sorry if I didn't make that clear before. Why not use mktime() and date() along with a few substrings? Thanks Ash www.ashleysheridan.co.uk I know that this works (as a workaround) which gets me back to my initial question: Can I use date_create_from_format()?? Does this works the way I need (because I don't have PHP 5.3.0 to test it)? http://www.php.net/manual/en/function.date-create-from-format.php -- Thodoris
Re: [PHP] str_to_date equivalent in PHP
Thodoris wrote: 2009/7/28 Thodoris : Hi gang, I've been looking for a str_to_date (mysql) equivalent in PHP. I've noticed that these are matching the description: http://www.php.net/manual/en/datetime.createfromformat.php http://www.php.net/manual/en/function.date-create-from-format.php but I don't have PHP 5.3.0 installed in any of my systems to test it and the function/method is not well documented yet. So I will have to write a workaround this. Has anybody tried this? Does strtotime() not work for you? Well actually it doesn't basically because I need to define the date's format. This is because strtotime will use for this date: 7/8/2009 the *month/day/year* format but in Greece we usually write dates in *day/**month/year* so this is causing me trouble. I have written this in case there is an active database handler around: function db_date2mysql($date_str,$date_format="%d/%m/%Y",$dbh=null) { if (isset($dbh)) { $sql = "SELECT STR_TO_DATE('$date_str','$date_format') AS `date`"; $ar = $dbh->query($sql)->fetch(PDO::FETCH_ASSOC); return $ar['date']; } else { return null; } } but I will need something more solid. Just a side question about your function. Is there a PDO::FETCH_OBJECT that could be used in place of the PDO::FETCH_ASSOC that you show. If so, could you shorten that by one line by doing this return $dbh->query($sql)->fetch(PDO::FETCH_OBJECT)->date; Thanks Jim !! That is a very good suggestion. How did I miss that :-) -- Thodoris
Re: [PHP] str_to_date equivalent in PHP
On Tue, 2009-07-28 at 20:10 +0300, Thodoris wrote: > 2009/7/28 Thodoris mailto:t...@kinetix.gr>>: > >> Hi gang, >> I've been looking for a str_to_date (mysql) equivalent in PHP. I've >> noticed that these are matching the description: >> >> http://www.php.net/manual/en/datetime.createfromformat.php >> http://www.php.net/manual/en/function.date-create-from-format.php >> >> but I don't have PHP 5.3.0 installed in any of my systems to test it and the >> function/method is not well documented yet. So I will have to write a >> workaround this. >> >> Has anybody tried this? >> > > Does strtotime() not work for you? > > Well actually it doesn't basically because I need to define the date's format. This is because strtotime will use for this date: 7/8/2009 the *month/day/year* format but in Greece we usually write dates in *day/**month/year* so this is causing me trouble. I have written this in case there is an active database handler around: function db_date2mysql($date_str,$date_format="%d/%m/%Y",$dbh=null) { if (isset($dbh)) { $sql = "SELECT STR_TO_DATE('$date_str','$date_format') AS `date`"; $ar = $dbh->query($sql)->fetch(PDO::FETCH_ASSOC); return $ar['date']; } else { return null; } } but I will need something more solid. I've always used strtotime from the output I get from the database, and it's always worked for me, and before you ask, I live in the UK where the date formats make sense :p Thanks Ash www.ashleysheridan.co.uk Well it does make sense if you leave in UK :-) . But I was asking about how to change a day/month/year formated date (or a date in any format I like) to mysql format. The basic problem is that I need to define the format that the date is in. Sorry if I didn't make that clear before. -- Thodoris
Re: [PHP] str_to_date equivalent in PHP
2009/7/28 Thodoris : Hi gang, I've been looking for a str_to_date (mysql) equivalent in PHP. I've noticed that these are matching the description: http://www.php.net/manual/en/datetime.createfromformat.php http://www.php.net/manual/en/function.date-create-from-format.php but I don't have PHP 5.3.0 installed in any of my systems to test it and the function/method is not well documented yet. So I will have to write a workaround this. Has anybody tried this? Does strtotime() not work for you? Well actually it doesn't basically because I need to define the date's format. This is because strtotime will use for this date: 7/8/2009 the *month/day/year* format but in Greece we usually write dates in *day/**month/year* so this is causing me trouble. I have written this in case there is an active database handler around: function db_date2mysql($date_str,$date_format="%d/%m/%Y",$dbh=null) { if (isset($dbh)) { $sql = "SELECT STR_TO_DATE('$date_str','$date_format') AS `date`"; $ar = $dbh->query($sql)->fetch(PDO::FETCH_ASSOC); return $ar['date']; } else { return null; } } but I will need something more solid. -- Thodoris
[PHP] str_to_date equivalent in PHP
Hi gang, I've been looking for a str_to_date (mysql) equivalent in PHP. I've noticed that these are matching the description: http://www.php.net/manual/en/datetime.createfromformat.php http://www.php.net/manual/en/function.date-create-from-format.php but I don't have PHP 5.3.0 installed in any of my systems to test it and the function/method is not well documented yet. So I will have to write a workaround this. Has anybody tried this? -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PEAR Spreadsheet_Excel_Writer setLocked method
Thodoris wrote: I've used it for some time but never needed to lock a cell. Here is a piece of code that shows how to apply a format to a cell: > Hope it helps. I think that by doing something like this: $format_bold->setLocked(); while creating the format could do the trick but it is not tested. No, this didn't do it. I already have some formats I've created for dollar amounts, right align, etc, and applying the setLocked() method to them had no affect. Skip I have noticed that when you use setLocked to the cell formatting the cell has the protected flag set. My openoffice tells me that the cell protection is meaningful only if the data sheet is protected. I think that the following code does what you need as long as you save the xls before opening it. // Stop displaying the errors so that the warnings don't get in your spreadsheet // ini_set('display_errors',0); // Instantiate a workbook $workbook = new Spreadsheet_Excel_Writer(); // Send it directly to the browser $workbook->send("test.xls"); // Set the version (very useful for compatibility) $workbook->setVersion(8); // Create a worksheet in the workbook $worksheet =& $workbook->addWorksheet('Test'); // Set input encoding $worksheet->setInputEncoding('UTF-8'); // Set protection for the worksheet $worksheet->protect(""); // Create the formats format $format_locked =& $workbook->addFormat(); $format_locked->setBold(); $format_locked->setHAlign('center'); $format_locked->setFgColor('yellow'); $format_locked->setLocked(); // Create a format $format_unlocked =& $workbook->addFormat(); $format_unlocked->setBold(); $format_unlocked->setHAlign('center'); $format_unlocked->setFgColor('yellow'); // Apply the format to a cell $worksheet->writeString(0, 0, "Locked", $format_locked); $worksheet->writeString(0, 1, "Unocked", $format_unlocked); // Close the workbook $workbook->close(); ?> This protects the file with a blank password. I don't know if this is the proper way to do this but it has been tested and works. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 500 Internal Error
Greetings Gurus! I am attempting to use PHP+MYSQL+APACHE and I have downloaded all the latest verions and installed them on a fresh windows XP install. Got the Apache server up and running, got MySQL up and running and installed PHP. Tested PHP with a script containing phpinfo(). Everything works great. Wrote a small script to connect to the MySql database. Tried to run the script (http://localhost/dbscript.php) and I get a 500 Internal Server error. I have been up and down the web for two days looking for a solution and I am completely frustrated. I HAVE to be missing something. PLEASE PLEASE PLEASE help. Thanks. MySql is enabled in php.ini. Paths are set to the php folder. I have NOT moved or copied any files whatsoever. Apache version is 2.2. Thanks. Since you are a windows user and you need to begin coding in PHP etc why don't you try WAMP for starters? http://www.wampserver.com/en/ It gives you all you need in one package. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Help: PHP version not up to date after "apt-get install php5-dev"
Why not just compile it yourself? Why not let the ports system compile it for you and then have the choice to remove it as package whenever you like... You get it compiled and packaged the same time... :-) I guess BSD is the way to make your life easier... -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sessions tutorial
Top of the list is for real dummies at tizag.com. So I don't have to search 282,000 entries for php sessions tutorial (doesn't this say something about the stupidity on the internet - just how many of those entries could possibly be real and worth looking at? Since you "gurus" (I kowtow) have been there, done that, I would appreciate hearing of a tutorial that will give something more than "you can use sessions in to store information"; like what kind of information, just how is it used e.g. whatis this, where did it come from, what does it mean? -- if (isset($_REQUEST["ReturnToBooksList"])) and if (!isset($_SESSION["addNewBooks"])) - in these examples it come from inputs. They were not specifically declared or is this a declaration by itself... how can I find this information so I can understand how to use it? I really don't want to bother you guys but do you see the futility here? My little programs are advancing little by little, but boy is it a struggle to get any information. I eventually dig it out but, frankly, it might be more productive digging salt mines in the Urals. :-( PJ "the bitcher" You could always read the manual for starters: http://www.php.net/manual/en/book.session.php It gives you a pretty good picture on sessions. Google could also help as usual: http://www.google.gr/search?q=php+how+to+use+sessions&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:el:official&client=firefox-a besides the first hit which is tizag there others you could look into for info. I know I've stated the *obvious* but I think you should try it nonetheless. -- Thodoris
Re: [PHP] PEAR Spreadsheet_Excel_Writer setLocked method
Hey all, Any one use the PEAR Spreadsheet_Excel_Writer package? I need to know how to implement the setLocked method to lock out a cell, but can't figure out how this would be done. Do you add it as a format? But then how is it applied to a cell. It's not documented on the PEAR pages. Any help as always is greatly appreciated. Also, what about making a cell span more than one cell below and above it? I can't find a way to do this either. Thanks, Skip I've used it for some time but never needed to lock a cell. Here is a piece of code that shows how to apply a format to a cell: // Stop displaying the errors so that the warnings don't get in your spreadsheet // ini_set('display_errors',0); // Instantiate a workbook $workbook = new Spreadsheet_Excel_Writer(); // Send it directly to the browser $workbook->send("test.xls"); // Set the version (very useful for compatibility) $workbook->setVersion(8); // Create a worksheet in the workbook $worksheet =& $workbook->addWorksheet('Test'); // Set input encoding $worksheet->setInputEncoding('UTF-8'); // Create a format $format_bold =& $workbook->addFormat(); $format_bold->setBold(); $format_bold->setHAlign('center'); $format_bold->setFgColor('yellow'); // Apply the format to a cell $worksheet->writeString(0, 0, "Test content", $format_bold); // Close the workbook $workbook->close(); ?> Hope it helps. I think that by doing something like this: $format_bold->setLocked(); while creating the format could do the trick but it is not tested. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Parse ini file problem
I am trying to parse an ini conf file using parse_ini_file but fails without returning something. I found this which is probably the reason: http://bugs.php.net/bug.php?id=44544 (the $ in the values) The problem is that this file has more than 7500 lines so it's kind of difficult to use quotes in all fields and there are several other reasons that I want to avoid quoting the values. In addition to that PHP 5.3 (which fixes this) is not stable yet and thus I can't install it in a production machine. So does anybody know any workarounds?? -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fileinfo on RHEL5
fileinfo.so is, indeed, in /usr/lib/php/modules. But I know it's enabled, in any case. So, anyone know if this extension doesn't work well with 5.1.6? Well you could enable the error messages to see what is going wrong. The $type var is probably empty because the instantiation of the $fi object fails for some reason. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fileinfo on RHEL5
Thodoris wrote: Is fileinfo pecl extension installed as a package or with pecl? In case it is installed as an rpm try to remove it and install it as an extension in case the package is broken for some reason. I installed it with PECL: /usr/share/pear/bin/pecl install fileinfo Other question: where does PECL install this? It's not under /usr/share/pear AFAIK. This is the same as with the dev box, so I don't think it's an issue; I'm just curious. Pear and pecl are different. Pear is used to install pure PHP-coded extensions that you can include in your projects. You can use this piece of code that pear provides by just copying it somewhere and including it though not recommended IMHO. Pecl on the other hand provides C-coded extensions that you need to compile and may provide for eg APIs for known libraries that must exist in your system. That is what pecl command does downloads, compiles and installs the extension. A wild guess is that your modules probably live under the /usr/lib/php/modules directory or in a directory under the /usr/lib/php. Anyway, as I said, phpinfo() tells me it's installed & enabled. Have in mind that you will need the magic_open library for this to work. You mean libmagic? I have file-4.17-15.el5_3.1, which provides libmagic, installed. Strangely, for Fedora, it comes in the file-libs package. But I know that, for the dev box, I had to install file-devel to get this all working. Neither of these appear to be available for RHEL, which I'm discovering is a bit "interesting" to deal with, package-wise. The file package also provides /usr/share/file/magic*, which I have. I'd created a link to /etc/magic.mime but decided in the end to just pass the correct path to finfo(). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sending SMS through website
Hi All, Does anyone know how to send sms through a php website. I am completely new to the requirement and don't know even the pre-requisite of doing it. You can also drop in link to a good tutorial. Any help will be highly appreciated. Thanks and Regards, Dheeraj Bansal Never implemented something similar but I will share what I know. If you manage to set up an SMS gateway it will probably provide you some means (like an API, a spool-like directory, database etc) to pass messages to it. You can probably use PHP 's capabilities to pass the sms to the gateway and use it this way to send the message to the subscriber. Generally speaking this is the plan. But you will need to have a working SMS gateway and walk through its aspects and details. I am not sure but I think there might be someone selling the service that you may pay to use it in your site. I am sure that someone more experienced than me will reply when the time is right. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fileinfo on RHEL5
RHEL5/PHP 5.1.6 I'm having some trouble getting the Fileinfo package working. It installed fine, and phpinfo() says it's enabled. But it consistently returns an empty string when getting the MIME of a file. /usr/share/pear/bin/pecl install fileinfo vi /etc/php.d/fileinfo.ini extension=fileinfo.so ln -s /usr/share/file/magic /etc/magic.mime The code: define('FINFO_PATH', '/usr/share/file/magic'); ... $fi = new finfo(FILEINFO_MIME, FINFO_PATH); $type = $fi->file($file_path); $type is always empty. And, yes, the path to the file is good. This works fine on the dev box (PHP 5.2.6). Unfortunately, the decision to use RHEL5 for production was out of my hands and I'm stuck with this older version. At least, I'm thinking it might be due to that. I didn't see anything in the manual about it, though. I did come across a post[1] online about doing file conversions where the guy mentions rolling an upgrade to 5.2.4 for RHEL5 but wasn't specific as to whether it was necessary to get Fileinfo to work at all. I might try using that upgrade but thought I'd do a sanity check here first. Any other reason it'd be returning nothing? [1] http://bhuga.net/2008/07/setting-your-system-file-conversions-with-file-framework Is fileinfo pecl extension installed as a package or with pecl? In case it is installed as an rpm try to remove it and install it as an extension in case the package is broken for some reason. Have in mind that you will need the magic_open library for this to work. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Trying to create a colortable - what am I missing here?
On Tue, 2009-05-12 at 18:05 +0300, Thodoris wrote: Still curious about the right script though (if this is possible of course). Of course it's possible... but you're probably not going to get the results you want since you're taking 3 dimensions and trying to push them into 2. You'll notice most colour pickers have a square for a given colour, and a bar to pick the colour. The following will produce a colour picker, but it won't look like what you expect: if( ++$x >= $width ) { $x = 0; $y++; } } } } header( "Content-Type: image/png" ); imagepng( $im ); imagedestroy( $im ); ?> Cheers, Rob. Thanks for pointing to the right direction Rob. I should really consider some reading on image manipulation theory. My curiosity still beats my reading though. -- Thodoris
Re: [PHP] irrational behavior
Could somebody please explain this? When the line - sort($category) is commented out, the output returns Notice: Undefined offset: in the line "36" for all the repeats (29 in this case) The code below: ", $cat, ""; $ii++; } $ii = $lastIndex; //echo $category[$ii]['category']; while ($ii <= $count -1) { $cat = $category[$ii]['name']; $catn = preg_replace("/[^a-zA-Z0-9]/", "", $cat); echo "", $cat, "" ; $ii++; } echo "" ; } ?> The same phenomenon happens in another application using the identical code. I don't want to sort the category; that has been taken care of in the query. It just doesn't make sense that sorting would affect the count. :-( Well a wild guess is this: This function assigns new keys to the elements in /array/ . It will remove any existing keys that may have been assigned, rather than just reordering the keys http://www.php.net/manual/en/function.sort.php Forgot to mention this of course which was my point on the first place: Be careful when sorting arrays with mixed types values because *sort()* can produce unpredictable results. -- Thodoris
Re: [PHP] irrational behavior
Could somebody please explain this? When the line - sort($category) is commented out, the output returns Notice: Undefined offset: in the line "36" for all the repeats (29 in this case) The code below: ", $cat, ""; $ii++; } $ii = $lastIndex; //echo $category[$ii]['category']; while ($ii <= $count -1) { $cat = $category[$ii]['name']; $catn = preg_replace("/[^a-zA-Z0-9]/", "", $cat); echo "", $cat, "" ; $ii++; } echo "" ; } ?> The same phenomenon happens in another application using the identical code. I don't want to sort the category; that has been taken care of in the query. It just doesn't make sense that sorting would affect the count. :-( Well a wild guess is this: This function assigns new keys to the elements in /array/ . It will remove any existing keys that may have been assigned, rather than just reordering the keys http://www.php.net/manual/en/function.sort.php -- Thodoris
Re: [PHP] Re: Trying to create a colortable - what am I missing here?
Thodoris wrote: דניאל דנון wrote: I've tried to make a color table, but I am missing something. not in the color-table-code itself, but in somewhere else... I just can't find... untested but try.. // 4096*4096 = 16777216 = FF+1 $im = imagecreate(4096, 4096); $white = imagecolorallocate($im, 0, 0, 0); $r = $g = $b = $x = $y = 0; $max = 255; while ($r <= $max) { while ($g <= $max) { while ($b <= $max) { $n = imagecolorallocate($im, $r, $g, $b); imagesetpixel($im, $x, $y, $n); $x = $x == 4096 ? 0 : $x+1; $y = $y == 4096 ? 0 : $y+1; $b++; } $b = 0; $g++; } $g = 0; $r++; } header("Content-Type: image/png"); imagepng($im); imagedestroy($im); Never used image manipulation with PHP but this is giving me a black image. You probably need $im = imagecreatetruecolor(4096,4096); Still doesn't work... Now the result is an almost black image with a yellow-white line in the middle. Also be aware that creating a truecolor image 4096 pixels square is going to take a LOT of memory, and it will take a while to download to the client, AND it is 4096 pixels square! That's a fair bit bigger than most screens... It was necessary to increase max execution time to something big above 4 minutes. I suspect the OP is going to have to rethink this... Still curious about the right script though (if this is possible of course). -- Thodoris
Re: [PHP] Can not read write file from Desktop
Thodoris wrote: hi I was trying to read a file from Desktop (Centos), Simply saying (php code file is in /var/www/html/ ) if (file_exists("/root/Desktop/conf_files_linux")) echo "yes file is there"; else echo "no none"; It gives me none. If i place conf_files_linux file in /var/www/html. i get yes... After checking log file i got [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec) What i need to do, so tht i can access files from outside? help pls thanx I assume that this running by the web server (/var/www/html) so a wild guess is that the user that your web server uses to run (usually apache or www) cannot access the Desktop directory. In order to use the suexec feature you need to configure it or else the web server user needs to have read/write rights to the directory you need to access like the Desktop. Though this not recommended. You could always run this script from command line being root or whatever user is the owner of the Desktop directory. Read this if you are not aware of how this can be done: http://www.php.net/features.commandline If the OP's system is set up properly, then nobody but root should be able to read ANY of root's home directory, so the files will not be found. For a start, one doesn't want config files in anyone's home directory if they are for a system-wide server. There is always suexec so this is partly true. And one doesn't EVER want to have anything in /root that anyone but root needs to access. Couldn't agree more. And one shouldn't be logged in as root unless one is doing a short-lived system maintenance task: certainly one should not doing development work there... This is the principle but handling files at root directory might be a maintenance task and since PHP is a scripting language it can be used for this kind of tasks mainly running from command line. I know it sounds dictatorial, but it's (part-way to) best practice... Those config files should be in something like /etc/apache/extra, perhaps, if they are not safe in the web root (which they probably are not, unless the web server is configured to keep them safe) The OP could always use one of the already developed file browsers in PHP. Never tried one besides webmin but a little googling could end up very resourceful. -- Thodoris
Re: [PHP] Re: Trying to create a colortable - what am I missing here?
דניאל דנון wrote: I've tried to make a color table, but I am missing something. not in the color-table-code itself, but in somewhere else... I just can't find... untested but try.. // 4096*4096 = 16777216 = FF+1 $im = imagecreate(4096, 4096); $white = imagecolorallocate($im, 0, 0, 0); $r = $g = $b = $x = $y = 0; $max = 255; while ($r <= $max) { while ($g <= $max) { while ($b <= $max) { $n = imagecolorallocate($im, $r, $g, $b); imagesetpixel($im, $x, $y, $n); $x = $x == 4096 ? 0 : $x+1; $y = $y == 4096 ? 0 : $y+1; $b++; } $b = 0; $g++; } $g = 0; $r++; } header("Content-Type: image/png"); imagepng($im); imagedestroy($im); Never used image manipulation with PHP but this is giving me a black image. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can not read write file from Desktop
hi I was trying to read a file from Desktop (Centos), Simply saying (php code file is in /var/www/html/ ) if (file_exists("/root/Desktop/conf_files_linux")) echo "yes file is there"; else echo "no none"; It gives me none. If i place conf_files_linux file in /var/www/html. i get yes... After checking log file i got [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec) What i need to do, so tht i can access files from outside? help pls thanx I assume that this running by the web server (/var/www/html) so a wild guess is that the user that your web server uses to run (usually apache or www) cannot access the Desktop directory. In order to use the suexec feature you need to configure it or else the web server user needs to have read/write rights to the directory you need to access like the Desktop. Though this not recommended. You could always run this script from command line being root or whatever user is the owner of the Desktop directory. Read this if you are not aware of how this can be done: http://www.php.net/features.commandline -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Mail subject encoding breaks
Hello, on 05/11/2009 12:25 PM Thodoris said the following: This script seems to work ok in a freebsd development server I have but a linux production machine breaks the subject's encoding for some unexpected reason. The subject has a mix of English and Greek characters that FreeBSD seems to handle like a charm. Both machines have the same php version (5.2.9) and the scripts encoding is UTF-8. Iconv and mbstring are configured the same way in php.ini (although I am not aware whether phpmailer uses iconv or mbstring). Has anyone had a similar experience? Is it possible that sendmail (which is the underlying tool) breaks the mail encoding? I am not sure what you mean by breaking the mail encoding. I use the MIME message class and it works perfectly with any encoding, even multibyte character sets. Take a look at the examples test_email_message and test_multibyte_message.php . http://www.phpclasses.org/mimemessage I am not sure what is happening exactly but I think that for some reason the subject of the e-mail includes more than one encoding while using linux. The English part is encoded in ISO-8859-1 and the Greek part into something that I can't detect (probably because thunderbird doesn't support all encodings). The body of the message is UTF-8 as expected. I didn't try the suggested solution since I have solved this, but the original question was about phpmailer. I will give it a try however because it seems like a better solution and more robust than mail_utf8. -- Thodoris
Re: [PHP] Mail subject encoding breaks
On 11 May 2009 at 18:25, Thodoris wrote: Hi gang, I am using phpmailer to send some mail notifications in an intranet I've made. This is a sample code: $e->Subject = "This is δφκξγκδφη garbidge κηδφκξγσ"; Hi, I have had success with this in the past: $subject= "This is δφκξγκδφη garbidge κηδφκξγσ"; $e->Subject = mb_encode_mimeheader($subject, "UTF-8", "Q") ; Regards Ian Thanks Ian this works in most cases but there are times that still breaks the subject. I have experimented with: mb_encode_mimeheader($subject, "UTF-8", "B") as well but nothing seems to be working without problems. I think that this solved my problems since I noticed that it works fine until this moment. function mail_utf8($to, $subject = '(No subject)', $message = '', $header = '') { $header_ = 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/plain; charset=UTF-8' . "\r\n"; mail($to, "=?UTF-8?B?".base64_encode($subject).'?=', $message, $header_ . $header); } -- Thodoris
[PHP] Mail subject encoding breaks
Hi gang, I am using phpmailer to send some mail notifications in an intranet I've made. This is a sample code: From = "aco...@host.gr"; $e->FromName = "Test"; $e->Mailer = "mail"; $e->Subject = "This is δφκξγκδφη garbidge κηδφκξγσ"; $e->CharSet = "UTF-8"; $e->Body = "H εργασία id: 122 έκλεισε με σχόλια."; $e->AddReplyTo("supp...@kinetix.gr"); $e->AddAddress("t...@kinetix.gr"); // $e->to = array("t...@kinetix.gr"); if ($e->Send()) { print "Mail has been sent successfully."; } else { print "Failed to send mail.".$e->ErrorInfo; } ?> Where mailer class is: This script seems to work ok in a freebsd development server I have but a linux production machine breaks the subject's encoding for some unexpected reason. The subject has a mix of English and Greek characters that FreeBSD seems to handle like a charm. Both machines have the same php version (5.2.9) and the scripts encoding is UTF-8. Iconv and mbstring are configured the same way in php.ini (although I am not aware whether phpmailer uses iconv or mbstring). Has anyone had a similar experience? Is it possible that sendmail (which is the underlying tool) breaks the mail encoding? Please any help would be appreciated because this is really driving me crazy. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] bug or expected, mbstring.func_overload not changeable by .htaccess 5.2.8/5.2.9
Hello, Besides the .htaccess which might be an apache configuration problem if you use ini_set("mbstring.func_overload",2) in a script of this directory does it work? no, also the ini_set does not work for this Directive. Sorry for the late reply. The ini_set is meant to be used inside a php script not in an .htaccess file. So perhaps you could test this in a script specific manner. In addition to this heck your apache configuration to see if you allow .htaccess to be parsed. apache and .htaccess are ok i added a scond line which changes mbstring.encoding_translation from off to on without problems: Directive Local Value Master Value mbstring.encoding_translation On Off mbstring.func_overload 0 0 .htaccess: php_value mbstring.func_overload 2 php_flag mbstring.encoding_translation On IMHO this is not a good practice using .htaccess to alter php's behavior. Perhaps you should consider ini_set after all. Can you confirm or rebut this behavior? Should we go to internals list? Thanks, Andre Unfortunately I can confirm that. This is a list with all the initial values you are allowed to change: http://www.php.net/manual/en/ini.list.php This is a script that shows all the mbstring extension values in an array: "; print_r(ini_get_all('mbstring')); ?> This array contains the default,local values and access level for each one. Note that according to the manual: http://www.php.net/ini_get_all The access levels for every value are:| Constant Value Meaning PHP_INI_USER 1 Entry can be set in user scripts PHP_INI_PERDIR2 Entry can be set in php.ini, .htaccess or httpd.conf PHP_INI_SYSTEM4 Entry can be set in php.ini or httpd.conf PHP_INI_ALL 7 Entry can be set anywhere |Although in the ini list the mbstring is supposed to have access level 2 I've noticed that I have access level 4 for mbstring.func_overload. Perhaps *this is the problem*. You have access level 4 so that is why you can't change the value using .htaccess. I don't know if this is an expected behavior though. Can anyone else confirm this?? -- Thodoris
Re: [PHP] bug or expected, mbstring.func_overload not changeable by .htaccess 5.2.8/5.2.9
Hello, following in my .htaccess works with php 5.2.6 (mod_php) php_value mbstring.func_overload 2 Seems that since (5.2.7?) 5.2.8/5.2.9 this value is not any more accepted by php in .htaccess. mbstring.func_overload should be changeable by PHP_INI_PERDIR which includes .htaccess Other values are changeable by .htaccess so it should not be a general problem on my side. Please someone could check this? Thanks, Andre Besides the .htaccess which might be an apache configuration problem if you use ini_set("mbstring.func_overload",2) in a script of this directory does it work? In addition to this heck your apache configuration to see if you allow .htaccess to be parsed. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDO fetch_obj - question
Hi there, I’ve made a fetch_obj and, as stated on some sites, it returns a anonymous object where the properties will have the name of our columns database. However, when I do this, I notice that instead of giving me the column names as they are typed on the DB I get them uppercase. So, when my database field is “id_dog” to retrieve the property properly I have to search for “ID_DOG” Why is this? Is this a normal behavior? Thanks a lot, Márcio I have just dumped an object using var_dump retrieved with pdo fetch object method: object(stdClass)#3 (4) { ["id"]=> string(1) "1" ["cat"]=> string(1) "1" ["cod_sin"]=> string(6) "120014" ["cod_uis"]=> string(2) "26" } and it seems quite normal to me. Try to see your table info using: describe `tablename`; To see what are your table's fields . Try to include more info about your system, php version etc in case you reply. It will help us to help you. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] alt() - unknown function?
This is someplace where NetBeans really benefits me. You can hit CTRL-B, or right-click, to take you to a definition. Holding CTRL turns darned-near everything into a hyperlink, doing the same thing. Lastly, CTRL-SHIFT-F lets you search through every file in the project for your string. Finding nothing with those, I'd grep the whole stinkin' drive and go grab a coffee. :) On Wed, Apr 15, 2009 at 10:39 AM, Thodoris wrote: Hi all, I've just started looking at the code of an e-commerce site we are taking over the development of, that another company has previously developed . Coupled with the difficulty of taking over development of someone else's code (also poorly commented), I've been stumped by a fatal error on a function call alt() which is dotted everywhere in the main templating script (sample below): // Get/Set a specific property of a page function getPageProp($prop,$id="") { return $this->PAGES[alt($id,$this->getPageID())][$prop]; } function setPageProp($prop,$val,$id="") { $this->PAGES[alt($id,$this->getPageID())][$prop]=$val; } It looks to be defining properties for a list of pages, with each page providing its own PageID. I've never seen this function before, nor can I find any definition of it in the site code, I was wondering if anyone recognises this, is it from a thirdparty templating tool at all? Thanks -Tom I think that you should check the included files (require, require_once, include, include_once) in case it is defined somewhere in there. Another possibility I can think of is to be defined in a framework that you use. You can check the user and internal functions using the get_defined_fumctions(): http://us.php.net/manual/en/function.get-defined-functions.php -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php What if it is not defined in your project but somewhere in your include path? You could I suppose grep the whole drive if you have time to waste :) -- Thodoris
Re: [PHP] alt() - unknown function?
Hi all, I've just started looking at the code of an e-commerce site we are taking over the development of, that another company has previously developed . Coupled with the difficulty of taking over development of someone else's code (also poorly commented), I've been stumped by a fatal error on a function call alt() which is dotted everywhere in the main templating script (sample below): // Get/Set a specific property of a page function getPageProp($prop,$id="") { return $this->PAGES[alt($id,$this->getPageID())][$prop]; } function setPageProp($prop,$val,$id="") { $this->PAGES[alt($id,$this->getPageID())][$prop]=$val; } It looks to be defining properties for a list of pages, with each page providing its own PageID. I've never seen this function before, nor can I find any definition of it in the site code, I was wondering if anyone recognises this, is it from a thirdparty templating tool at all? Thanks -Tom I think that you should check the included files (require, require_once, include, include_once) in case it is defined somewhere in there. Another possibility I can think of is to be defined in a framework that you use. You can check the user and internal functions using the get_defined_fumctions(): http://us.php.net/manual/en/function.get-defined-functions.php -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: fpdf adding font error
If you want to use UTF-8 fonts with FPDF then switch to TCPDF (www.tcpdf.org) Thanks Tony I think that it will do what I really need. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] pdflib greek problem
Hi, I am trying the following code to generate a pdf: try { // Create a new pdf handler $pdf = new PDFlib(); // open new PDF file if ($pdf->begin_document("", "") == 0) { die("Error: " . $p->get_errmsg()); } // Set some info to the new pdf $pdf->set_info("Creator", "Test"); $pdf->set_info("Author", "Test"); $pdf->set_info("Title", "Test"); // Start the page $pdf->begin_page_ext(595, 842, ""); // Load the documents font and set the details $font = $pdf->load_font("Times-Roman", "iso8859-7", ""); $pdf->setfont($font,24.0); $pdf->set_parameter('autospace',TRUE); // Set the position inside the document $pdf->set_text_pos(50, 700); // Now start to show the data $str = 'Αυτό είναι ένα τεστ.'; mb_convert_variables('ISO-8859-7','UTF-8',$str); $pdf->show($str); // End the page and the document $pdf->end_page_ext(""); $pdf->end_document(""); // Get the document from the buffer find it's length $buf = $pdf->get_buffer(); $len = strlen($buf); // And finally print it out to the browser header("Content-type: application/pdf"); header("Content-Length: $len"); header("Content-Disposition: inline; filename=hello.pdf"); print $buf; } catch (PDFlibException $e) { die("PDFlib exception occurred in hello sample:\n" . "[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " . $e->get_errmsg() . "\n"); } catch (Exception $e) { die($e); } Although greek are printed normally the characters are overlapping on each other. The script in encoded in UTF-8. Does anybody have any suggestions on this? Please any help would be appreciated. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] fpdf adding font error
Hello gang, I know this is not an fpdf mailing list but if anyone has experience on the matter please help. I am working on a pdf generation part of a project and I am using fpdf to generate them. The content of the pdf needs to be in greek. But I am having difficulties to get the pdf generated properly. This means that I can't see the greek in the pdf file that is generated. I have tried to set the encoding to non-UTF since fpdf doesn't support UTF-8 but the problem still remains. As a second solution I am trying to add new fonts with the ISO-8859-7 encoding but it doesn't work as expected. The font is not being although I am following the fpdf's directions step-by-step. Does anybody know another way to generate pdf files with greek properly or can help me with the fpdf?? Thanks in advance. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Smarty Tips and Techniques
From: Bastien Koert On Thu, Mar 19, 2009 at 11:06 AM, Bob McConnell wrote: From: Virgilio Quilario >> That looks nice, but how do I get to the point where I can understand >> how to use it? >> >> I have also looked at the Smarty site <http://www.smarty.net/>, but >> their documents assume significant experience in building and using >> templates. >> >> Where can I find guidance or tutorials on how to do all of this, >> starting with only a rudimentary knowledge of HTML and PHP. It would be >> best if they also focused on procedural rather than object oriented >> code. > > > When I started learning smarty, I spent most of my time doing research > and that's really tiresome and it is so hard to find examples. > Experimented a lot and listed those what's possible, then applied them > to my projects. > > Now to make them handy I posted them to my site so i can have a look > whenever and wherever. > http://www.jampmark.com/php-programming/16-very-useful-smarty-scripting- tips-and-techniques-to-make-templates-smarter.html <http://www.jampmark.com/php-programming/16-very-useful-smarty-scripting -tips-and-techniques-to-make-templates-smarter.html> > > As a first step, maybe you should see the crash course at smarty > http://www.smarty.net/crashcourse.php Hi Virgil, After your last post here, I looked at your site, then the Smarty site. That was what triggered this question. Templates are a black art to me. I don't even know where to begin to understand them. Every reference I have looked at so far assumes that I already understand the MVC pattern, which is also one of the dark arts. Let me put it simply. I can't grok OO. I tried to do OOP for several years, but it simply does not make any sense to me. As a direct result, I don't understand the concept nor application of patterns. So how do I figure out how to use templates without having to absorb those first? Can I learn enough this way to determine if a site can be converted from the current state (PHP and XHTML spaghetti) into templates and begin that transformation? Bob, You really would need to learn those concepts first OOP / MVC. There is a learning curve, but you really don't need OOP to be able to do an MVC style application, but it does make the code neater. One of the books that really helped me grok OOP is Head First OOP...another is Martin Fowlers Patterns of Enterprise Architecture. The MVC pattern is explained well in a number of places, but worth checking out are both the cakephp framework site and the codeingniter site. You'll find that there are people from both camps here, pure OOP and other just as happy with procedural coding styles. Many use both, using objects to handle common tasks like DB interaction or filesystem processes. Yes, I have to deal with both camps here as well. Of five developers doing PHP at the moment, two are primarily using OOP. But I spent 3.5 years as part of a team developing MS-Windows services in C++. After all that time, I was only able to write basic functions for others to convert into methods or classes. I could eventually find my way around in some of those classes, but it seemed that every time I figured out what was where, somebody "refactored" a major component and I had to start all over again. All I saw was a lot of unnecessary overhead and obfuscation which made little sense in the long run and slowed down both the development and the application. The result was a handful of DLLs that are shared between several products, and each time anything is changed in one of them, every product needs to be retested to make sure nothing got broke and some have to be recertified for PCI-DSS as well. So you are telling me that I can forget about trying to use templates. Since I can not understand OOP, there is no chance I will be able to use them. Just knowing that will probably save me several weeks of frustration. Thank you, Bob McConnell Well think of the positive side that you don't need to write in OOP in order to use Smarty. Think it just like a class used for displaying the output (simply put). At least I've been doing this for some time now (the non-OOP part). I have a feeling that someone coming from the procedural way of programming would have problems probably with the templates instead of the development part. -- Thodoris
Re: [PHP] Smarty Tips and Techniques
That looks nice, but how do I get to the point where I can understand how to use it? I have also looked at the Smarty site <http://www.smarty.net/>, but their documents assume significant experience in building and using templates. Where can I find guidance or tutorials on how to do all of this, starting with only a rudimentary knowledge of HTML and PHP. It would be best if they also focused on procedural rather than object oriented code. Bob McConnell -Original Message- From: Virgilio Quilario [mailto:virgilio.quila...@gmail.com] Sent: Wednesday, March 18, 2009 10:36 AM To: php-general@lists.php.net Subject: [PHP] Smarty Tips and Techniques Hi list, Just wanna share my collection of Smarty scripting tips and techniques. Smarty is a template engine for PHP that you can use to separate data and logic from web design. This way programmers can work on the php scripts and designers can work on the templates for the same web site. Here is the link: http://www.jampmark.com/php-programming/16-very-useful-smarty-scripting- tips-and-techniques-to-make-templates-smarter.html Hope you find it useful. Virgil I have stared using smarty myself in a recent project I am still making and I'll have to say that it has its virtues. Look at a simple example in the smarty's site and use the manual for any questions. You will probably find some stuff by googling. The templates (simply put) are actually html-like that has some php variables inside you may assign before displaying the actual template. This way you customize the template to output what you need. Above that you may start using the statements to automatically build forms, tables etc I like the fact that there is a cache and that the templates get "compiled" which make them faster to process. Nevertheless you need time to get familiar with the smarty way of thinking as with all frameworks and template engines you need to use. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] assign associative array values to variables?
I have been tearing out my hair to figure out a way to place array values into $variables with not much luck. I can echo the array to the screen but I can not manipulate the results. I have searched wide and far all day on the web and I find nothing that points the way how to extract values from an associative array and assign them to a variable. I expected to find some elegant way to do it. Here's the code that outputs the values: if ( isset( $book_categories[$bookID] ) ) { foreach ( $book_categories[$bookID] AS $categoryID ) { if ( isset( $category[$categoryID] ) ) { echo($category[$categoryID]['category']); } } } this will echo something like "CivilizationGods And GoddessesHistorical PeriodsSociology & Anthropology" (I have not added breaks beween the categories as there is more manipulation needed on them) This works for as many categories as needed. Manipulating each value should not be a problem once it is in a string variable using switch and preg_replace() as each category needs to be stripped of spaces, commas and &s. Perhaps extract() ?? http://www.php.net/manual/en/function.extract.php -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] bad interpreter error from CLI
Thodoris wrote: Hi gang, I am trying to run a script from cli which goes like this: #!/usr/bin/php The error I get is this: /usr/bin/php^M: bad interpreter: Permission denied the php binary is indeed in this location and when I run the same script like this: php -f test.php it works properly. I will have to mention that the executable flag is set in the file's permissions. Any ideas why is this happening? php -v gives me: PHP 5.1.6 (cli) (built: Nov 12 2008 11:22:34) Copyright (c) 1997-2006 The PHP Group Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies Does the filesystem the scripts are on by any chance has 'noexec' set? $ mount (rw,noexec,nosuid,nodev) Yes this is the problem !! How did I miss that? Thanks for the help. -- Thodoris
Re: [PHP] bad interpreter error from CLI
On Fri, Mar 13, 2009 at 10:23, Thodoris wrote: [snip!] Both commands return the same path. and that path, I'll presume, is the same you have set in the script, right? Please offer as much information as you can with each email to speed up the troubleshooting process. ;-P What's the output you get from the following (copied exactly)? ls -l /usr/bin/php ls -l `which php` [r...@foo tmp]# ls -l /usr/bin/php -rwxr-xr-x 1 root root 2702972 Nov 12 16:24 /usr/bin/php [r...@foo tmp]# ls -l `which php` -rwxr-xr-x 1 root root 2702972 Nov 12 16:24 /usr/bin/php I did mention that it works using php -f didn't I? So it actually finds the binary because it is in the path :-) . -- Thodoris
Re: [PHP] bad interpreter error from CLI
Note the ^M --- then use dos2unix from the command line on the Linux box to fix the line endings on that file. The ^M character is a sure-fire sign of a Windows-saved file. Already tried that but I still get the same error (without the ^M of course) so I think it's not the line termination. the php binary is indeed in this location and when I run the same script like this: php -f test.php it works properly. I will have to mention that the executable flag is set in the file's permissions. Any ideas why is this happening? php -v gives me: PHP 5.1.6 (cli) (built: Nov 12 2008 11:22:34) Copyright (c) 1997-2006 The PHP Group Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies The above should no doubt fix it, but in the event that it does not, check the output from the following command line commands on your Linux box: which php whereis php The first will tell you which PHP CLI binary is preferred by the current $PATH settings, while the second will tell you where in $PATH 'php' is located. Both commands return the same path. -- Thodoris
[PHP] bad interpreter error from CLI
Hi gang, I am trying to run a script from cli which goes like this: #!/usr/bin/php The error I get is this: /usr/bin/php^M: bad interpreter: Permission denied the php binary is indeed in this location and when I run the same script like this: php -f test.php it works properly. I will have to mention that the executable flag is set in the file's permissions. Any ideas why is this happening? php -v gives me: PHP 5.1.6 (cli) (built: Nov 12 2008 11:22:34) Copyright (c) 1997-2006 The PHP Group Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] whoami explanation
Thodoris wrote: Didn't have the time to read the whole thread. Sorry for being so lame. Obviously, or you would have known that this thread has very little if anything to do with whoami! :-) Indeed nonetheless it will be something useful for the archives (at least I think that). After that I had to read the whole thing!! Blast I though I could get away with it :-) -- Thodoris
Re: [PHP] whoami explanation
This really needs some explanation I found this on the web: with it there was the comment "the direction of those single-quotes matters" (WHY ?) and it works But this (_*FROM THE PHP MANUAL***_ * - exec()* executes the given /command/ ) does not, COPIED AND PASTED: | | What is going on here? And I often find such discrepancies in examples - and some wonder why I seem to be so stupid... and don't know the fundamentals... :-\ Didn't have the time to read the whole thread. Sorry for being so lame. I will have to mention that whoami is actually "id -un" and probably if you need to get user information from the shell IMHO you should better use the id command or a better solution could be the posix_getuid() function. If you need to find the owner of the current script you could use something like get_current_user(). Current proccess id from the shell: "; echo `id`; echo "Current proccess id from the posix getuid: "; echo posix_getuid(); ?> btw I think it would be nice to have a function that can give you the user that actually runs the script (apache ,www) instead of using the command line. The posix functions AFAIK can give you only the ids (uid,gid etc) about a process. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDO buffered query problem
Stewart Duncan wrote: Hi there, I'm having some serious problems with the PHP Data Object functions. I'm trying to loop through a sizeable result set (~60k rows, ~1gig) using a buffered query to avoid fetching the whole set. No matter what I do, the script just hangs on the PDO::query() - it seems the query is running unbuffered (why else would the change in result set size 'fix' the issue?). Here is my code to reproduce the problem: PDO::ERRMODE_EXCEPTION, PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true ) ); Don't you want it the other way around? You want it unbuffered so it doesn't get retrieved in mysql, send the whole result set to php then you can use it. You want to start using it immediately - so make it unbuffered. Either way if the result set is going to be large your MySQL's memory or PHP's memory may exceed. So if you use either you may need to fine-tune PHP by increasing the per process memory (memory_limit in php.ini) or MySQL. In case you use unbuffered queries you cannot use transactions as far as I can recall. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Securing web services
Yanick, I'm hoping to save you some time here; Web Services are very poorly implemented in PHP (and that sentence is the reason I'm emailing you off-list). You actually didn't :-) . Everything you need is catered for in SOAP and by using the WS-xxx extensions which are common place in the Java and .net world (infact most languages) - thankfully those who are fortunate enough to know can do this in PHP as well and consume all manner of web services, as well as generate them. You need WSO2 (oxygen) - specifically WSO2 WSF/PHP; it's the finest web service library for all languages and has a massive community behind it. http://wso2.org/projects/wsf/php docs: http://wso2.org/project/wsf/php/2.0.0/docs/api.html Honestly my friend, everything you need - I've been through the same thing as you for moths over many projects and this framework saved my life. it also has very nice scripts for working with wsdl including an automatic wsdl2php and a full WSDL generation API :) Many Regards, Nathan ps: I'm no affiliation :) -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Accessors
Also, i know php is an interpreted language. But wouldn't it be possible to write a virtual machine for php and compile byte code... I know, php is not Java or Actionscript :-P but it could be an add on feature. i guess the eval wouldn't work then would it? Although eval could still be interpreted... This would be nice in case you need to protect your intellectual property. I haven't tried it, but I might soon for an appliance I'm building. http://www.roadsend.com/ Actually might not have "virtual machine" as java does but it has an engine and it is possible to produce something similar to byte-code. You can some solutions to this and here is one of them (open source): http://www.php.net/manual/en/ref.bcompiler.php http://pecl.php.net/package/bcompiler and there is a script to make "byte-code": http://bencoder.urdada.net/ I have used and it works. -- Thodoris
Re: [PHP] function array problem
I've had a bit of a problem with a function I'm using for a form. Essentially, the function looks like this: function addEvent($values = Array('name' => '', 'venue' => '', 'description' => '', 'errors' => Array())) { // code here displays the form } The function is used to both display an empty form, and the form populated with values again should there be any validation errors. Now this works fine when the form has been filled out and there are errors present, as I can call the function with the correct array values. However, when I call the function with no arguments (intending the function to populate the $values array itself) all it does is present me with an empty array. A print_r($values) just returns Array( ), no key values defined. I altered the function to this: function addEvent($values = Array()) { if(count($values) == 0) { $values = Array('name' => '', 'venue' => '', 'description' => '', 'errors' => Array()); } // code here displays the form } then all works as intended. Question is, am I being dense, or is there a reason why this shouldn't work? Ash www.ashleysheridan.co.uk While reading this thread I've noticed that you all use "venue" in the index of the parameter array. Is this intended or you actually mean "value"? You may want to consider these functions: |func_get_args ||func_get_arg| |func_num_args| to make the functions input more loose and have it accept multiple formats as needed like one dimensional, two dimensional or simple parameters the same time. -- Thodoris
Re: [PHP] PHP AS an FTP server
On Tue, 2009-02-17 at 18:54 +0200, Thodoris wrote: Hi, This is probably a bit stupid, but I've been having issues getting any of the good FTP servers running on my Ubuntu 6.06 (LTS) box. I've tried Pro-FTP, Pure-FTP, and briefly installed some others, but the versions available for my distro don't seem to support MySQL (or I'm simply doing something wrong). AFAIK in most distros the ftp servers come without mysql (or database) authentication support. If this is what is happening in your case you need to compile the ftp server from source adding a configuration time option to enable the database support. Anyway, I had the thought that the FTP server won't be used much, as I mainly use SSH, however I need to be able to give other people access, which is why I'm wondering if there are any PHP scripts that can be used AS an FTP server. That is, I'd setup Apache to accept on the standard FTP port(s), and get it to point everything to a PHP script, which I could then use to pull user/pass details each of which would have their own directories, allowing each user to access a sym-link to their domain(s) log file, website directory, and anything else. In case you have ssh enabled you may use the sftp subsystem that openssh supports if it fits your needs. It's more secure than plain ftp but you still have to add local user accounts which is a bad idea imo. You may use PHP to upload files using the http (and not the ftp) protocol by making a project that authenticates the user provides him the ability to upload, delete and download files using forms. There has to be something already written that implements such a procedure in case you don't want to code this by yourself. You may google to find whatever fits your needs. Has someone already got a script that does this (at least accepting FTP connections), or is this a crazy idea that's just not possible? Should I just compile the latest version of some FTP server, and try and configure that to do what I want instead? I suggest that since you need ftp access it would be much better if you could configure an ftp server instead of writing something on your own. The vsftp daemon is a good solution to your problem written including advanced security features but I don't know if it supports mysql authentication. On the other hand pro-ftpd does support modular authentication (mysql, ldap etc) if you compile the proper module. Thanks. -- Thodoris I used vsftp for several FTP systems at work, and bar a few problems (errors on my part!) they work just fine. I've even got PHP talking to various Bash scripts to manage users and permissions for the FTP, and, touch wood, everything works well. I wouldn't really agree that allowing local users to FTP in is a bad idea. I'm using just that method for my systems. The users, etc are only ever created through a web interface, which forces certain rules on usernames, which as far as I see it, is the only problem. As long as the vsftpd.conf file is configured correctly and securely, the whole thing will remain pretty tight. Ash www.ashleysheridan.co.uk The local users part was about ssh-sftp access Ash not ftp. IMO when you add local users you add extra risks to your system than simple ftp (non-local) users may not cause. Of course if you secure your system carefully everything will work fine but I would avoid that and there are many security issues that here is not the place to discuss. Of course if this fits your needs I have no objections. -- Thodoris
Re: [PHP] Opinions Please, Describing PHP as Web Framework of C and C++
What's so funny? Assembly is just a framework for microcode. Cheers, Rob. So, what is the level that actually polarizes the sectors on the hard drive? Anything more abstract then that is then an API right? I guess it abstracts a level but I can hardly say that microcode is actually a programming language and assembly as well. Since API is a Programming Interface it was to do with a programming language. So I have the feeling that the discretion is made on what it actually is a programming language. On the other hand the framework is usually use to describe an abstraction of the same language. That is why I don't feel right saying that PHP is actually a C framework. But probably I feel right saying Zend is a PHP framework. My problem I guess is not the abstraction itself which happens to exist in all software and hardware technology but what you abstract each time and what term you choose to use. An example that comes in mind is about networks. You can say that the http protocol is a framework of underlying tcp protocol although it is comes as an abstraction. -- Thodoris
Re: [PHP] php cli memory leak error
seems to work fine here. What are your php.ini (memory related) settings? run: /usr/local/bin/php --ini and get the location of the php.ini file that is getting used. Check our the memory settings in that file. Some general options: max_input_time = 60 max_execution_time = 120 memory_limit = 128M and the last one I have just noticed (that is why it reports the leak): report_memleaks = On In case I set this to Off it just stops bugging me. But is there a memory leak? And if yes should I report this as a bug ? -- Thodoris
Re: [PHP] Opinions Please, Describing PHP as Web Framework of C and C++
Virgilio Quilario wrote: Recently we had some serious discussion on local boards. I prefer calling PHP as Web Framework of C and C++ if you had a time for this fruitless discussion. Please send your opinions. PHP is a server side scripting language for the Web using a C like language structure and conventions. The engine is built with C that is true but it is the engine that interprets the scripts not C. C has nothing to do with the operations of PHP engine. It is merely a code which is used to generate machine codes for the PHP engine. Good luck with your "fruitless" discussion as you like to call it. Virgil http://www.jampmark.com I prefer calling C and C++ as Framework of Assembly language. Hahaha that was a good one Shawn. I almost fall of the chair :-) . -- Thodoris
Re: [PHP] php cli memory leak error
Thodoris wrote: Hi gang, I am trying to run a simple PHP script using the cli and I get a weird memory leak error. The script goes like this: #! /usr/local/bin/php The problem is that when I run the script I get this error: Script: './bcom.php' /usr/ports/lang/php5/work/php-5.2.8/main/main.c(2015) : Freeing 0x2871F2A8 (43 bytes), script=./bcom.php === Total 1 memory leaks detected === This is hosted on a FreeBSD 7 machine with: PHP 5.2.8 with Suhosin-Patch 0.9.6.3 (cli) Anyone knows what is happening ?? I have to mention that the array is printed as expected. how are you call it? What arguments are you passing? etc... Show us your command line params... I am calling it from the command line like this: ./bcom.php -f test -d test -o test :-) But it really doesn't matter because it seems to leak even when calling it without passing options. -- Thodoris
Re: [PHP] display_errors and error_reporting not enough?
Thodoris wrote: When I make something wrong like syntax error; I get blank pages. Because the PHP code is not running (because of the syntax error), and thus not setting the error reporting as desired. You'll need to aither use a .htaccess file (if you're running Apache) or make the changes in your php.ini file (and restart your web server). Either way you won't be able to use the constants (which you use only in a PHP script. IIRC the correct directive would be: error_reporting 2047 In other words try to set: display_errors=On error_reporting = E_ALL in your php.ini which is: /etc/php5/apache2/php.ini As far as I can see from you phpinfo page. So that you don't need to set it in every script during runtime as you mentioned. I would look at doing this only for a testing area, but not for a production area. If they are one in the same, then you could setup to different sub domains, one for testing and one for production. They can point to the same DOCUMENT_ROOT for that matter, just have different running configurations. Totally agree on that since Jim has a very good point. You shouldn't leave error reporting active in a production domain because it reveals a great deal of information about your code making you site vulnerable to attacks. I suggested that assuming it is a testing-development domain. The less someone knows about how things work the more secure your site becomes. -- Thodoris
Re: [PHP] Full versus relative URLs
for that matter, you could use variables to specify the relative path to make it absolute within each of the production and dev environments. Another possible solution I can think is building configuration files that could include the paths and parse them to find the path every time you need it. This conf files would be different between the two machines and you will only need to upload the source files without consideration since the directories will actually inside the conf files. A database table that would store the paths could always be an alternative that you could perhaps load into the session to avoid overhead. -- Thodoris
Re: [PHP] Full versus relative URLs
I know it's been said before, but beware of relying on this value just for the sole purpose of deciding where things are located, as without a bit of error checking on it, it can be used for injection attacks and what-not, although, sadly, I forget the exact post recently that had the link that explained this issue on PHP_SELF. Alternatively, $_SERVER['PHP_SELF']) could be switch()ed for known values, and $path be set accordingly with hardcoded values. Didn't notice this thread passing from the list. I will look into it. But sometimes you need to detect where something is located and that's the point of the whole conversation. If you hardcode the values then you need to change them while renaming or moving files and directories So what someone should do to accomplish such a behavior? Without being vulnerable to injection attacks of course. -- Thodoris
[PHP] php cli memory leak error
Hi gang, I am trying to run a simple PHP script using the cli and I get a weird memory leak error. The script goes like this: #! /usr/local/bin/php The problem is that when I run the script I get this error: Script: './bcom.php' /usr/ports/lang/php5/work/php-5.2.8/main/main.c(2015) : Freeing 0x2871F2A8 (43 bytes), script=./bcom.php === Total 1 memory leaks detected === This is hosted on a FreeBSD 7 machine with: PHP 5.2.8 with Suhosin-Patch 0.9.6.3 (cli) Anyone knows what is happening ?? I have to mention that the array is printed as expected. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] display_errors and error_reporting not enough?
When I make something wrong like syntax error; I get blank pages. Because the PHP code is not running (because of the syntax error), and thus not setting the error reporting as desired. You'll need to aither use a .htaccess file (if you're running Apache) or make the changes in your php.ini file (and restart your web server). Either way you won't be able to use the constants (which you use only in a PHP script. IIRC the correct directive would be: error_reporting 2047 In other words try to set: display_errors=On error_reporting = E_ALL in your php.ini which is: /etc/php5/apache2/php.ini As far as I can see from you phpinfo page. So that you don't need to set it in every script during runtime as you mentioned. -- Thodoris
Re: [PHP] PHP AS an FTP server
Hi, This is probably a bit stupid, but I've been having issues getting any of the good FTP servers running on my Ubuntu 6.06 (LTS) box. I've tried Pro-FTP, Pure-FTP, and briefly installed some others, but the versions available for my distro don't seem to support MySQL (or I'm simply doing something wrong). AFAIK in most distros the ftp servers come without mysql (or database) authentication support. If this is what is happening in your case you need to compile the ftp server from source adding a configuration time option to enable the database support. Anyway, I had the thought that the FTP server won't be used much, as I mainly use SSH, however I need to be able to give other people access, which is why I'm wondering if there are any PHP scripts that can be used AS an FTP server. That is, I'd setup Apache to accept on the standard FTP port(s), and get it to point everything to a PHP script, which I could then use to pull user/pass details each of which would have their own directories, allowing each user to access a sym-link to their domain(s) log file, website directory, and anything else. In case you have ssh enabled you may use the sftp subsystem that openssh supports if it fits your needs. It's more secure than plain ftp but you still have to add local user accounts which is a bad idea imo. You may use PHP to upload files using the http (and not the ftp) protocol by making a project that authenticates the user provides him the ability to upload, delete and download files using forms. There has to be something already written that implements such a procedure in case you don't want to code this by yourself. You may google to find whatever fits your needs. Has someone already got a script that does this (at least accepting FTP connections), or is this a crazy idea that's just not possible? Should I just compile the latest version of some FTP server, and try and configure that to do what I want instead? I suggest that since you need ftp access it would be much better if you could configure an ftp server instead of writing something on your own. The vsftp daemon is a good solution to your problem written including advanced security features but I don't know if it supports mysql authentication. On the other hand pro-ftpd does support modular authentication (mysql, ldap etc) if you compile the proper module. Thanks. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Opinions Please, Describing PHP as Web Framework of C and C++
I didn't mention that it was a C specific framework, I just said IMO it was similar to a framework for the web. It's an opinion so I can't be "wrong". In my opinion earlier versions of PHP *could* (not should but could) be described as a framework in essence, however I wouldn't say that anymore since it has evolved so much. In your opinion I may be completely wrong but that's the idea of an opinion. I think that this is what you said: I prefer calling PHP as Web Framework of C and C++ Btw opinions and personal styles are always welcome. Besides, if you cross reference your description of a framework: "basically because when you use a framework (or API or whatever label you choose to use for describing it) in a language it just abstracts some aspects of the language making it "easier" to code". That's my point meaning that PHP is not exactly abstracting C as other frameworks happen to abstract PHP. With the description of the original PHP: "It had Perl-like variables, automatic interpretation of form variables and HTML embedded syntax. The syntax itself was similar to that of Perl, albeit much more limited, simple, and somewhat inconsistent." That of course was PHP and you probably have a point. Then surely what is described is just a way of abstracting parts of the language to make it "easier" to code. This was mentioned about a framework not PHP of course since PHP is abstracting parts of any other language. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Opinions Please, Describing PHP as Web Framework of C and C++
I didn't mention that it was a C specific framework, I just said IMO it was similar to a framework for the web. It's an opinion so I can't be "wrong". In my opinion earlier versions of PHP *could* (not should but could) be described as a framework in essence, however I wouldn't say that anymore since it has evolved so much. In your opinion I may be completely wrong but that's the idea of an opinion. Besides, if you cross reference your description of a framework: "basically because when you use a framework (or API or whatever label you choose to use for describing it) in a language it just abstracts some aspects of the language making it "easier" to code". With the description of the original PHP: "It had Perl-like variables, automatic interpretation of form variables and HTML embedded syntax. The syntax itself was similar to that of Perl, albeit much more limited, simple, and somewhat inconsistent." Then surely what is described is just a way of abstracting parts of the language to make it "easier" to code. 2009/2/16 Thodoris : I'd personally say that PHP was originally intended to essentially be a framework for the web, but has since evolved in to its own language. It's just my opinion though... Well you can see that some basic facts from PHP history can prove you wrong: http://www.php.net/manual/en/history.php.php Actually PHP started as a set of perl scripts and then was rewritten in C as a form interpreter. Of course you could always think what you want even if it is not a fact and the fact is that it's purpose was never to become a C or C++ API for web applications. Not to mention that there is a difference between a framework and an API. -- Thodoris Keep this on the list please -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Opinions Please, Describing PHP as Web Framework of C and C++
2009/2/16 Thodoris : In addition to this there is an API for C that can be used to code web applications and it is known as CGI (it is provided by many languages) CGI is a protocol not an API and has no specific connection to C. -Stuart I stand corrected on this. But what I meant is that it actually is a protocol that many languages are providing APIs to use it and one of them is C. Thanks for the observation Stuart. -- Thodoris
Re: [PHP] Opinions Please, Describing PHP as Web Framework of C and C++
I'd personally say that PHP was originally intended to essentially be a framework for the web, but has since evolved in to its own language. It's just my opinion though... Well you can see that some basic facts from PHP history can prove you wrong: http://www.php.net/manual/en/history.php.php Actually PHP started as a set of perl scripts and then was rewritten in C as a form interpreter. Of course you could always think what you want even if it is not a fact and the fact is that it's purpose was never to become a C or C++ API for web applications. Not to mention that there is a difference between a framework and an API. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Full versus relative URLs
On Mon, Feb 16, 2009 at 07:39:29PM +0200, Thodoris wrote: Here's a question related to my last post. When specifying a link in a HTML file (like to the css or an image file), there are two ways of doing it. One is to simply include the relative path to the file (relative to the doc root), like: /graphics/my_portrait.gif Or you can include the full URL, like: http://example.com/graphics/my_portrait.gif My casual observation seems to indicate that the former will load faster than the latter. But has anyone done any benchmarking on it? Paul I am not aware if absolute URLs are faster or not (in case they are there will be such a small difference you cannot probably notice) but IMHO it is a bad practice to use full URLs. Basically because renaming directories or scripts will cause great pain in the ass. Of course resources that are coming outside your own site are needed to use absolute URLs and nobody is assuming that are useless. Agreed. But here's the real reason, in my case. We develop the pages on an internal server, which has the URL http://pokey/mysite.com. When we move the pages to the live server at mysite.com, all the URLs would have to be rewritten. Ugh. Paul I sometimes use something like this in my scripts for every script to determine itself: // Find what is the name of this script $self = basename($_SERVER['PHP_SELF']); You can probably take advantage of the $_SERVER information so that you don't need to rewrite every url you use. Hope that helps. -- Thodoris
Re: [PHP] Zend Guard/Optimizer alternatives?
I should mention that I did try the ionCube online encoder, which I think is a great idea... but its runtimes failed to load on both of my test systems, requiring editing of php.ini. That's over the top for my users. I need something that's rock-solid and that will never require my users to have to know anything or do anything special (they are business people, not developers or server admins). On Feb 16, 2009, at 9:10 AM, Brian Dunning wrote: Is there a cheaper alternative to Guard/Optimizer? I have a single small PHP file that is part of a larger solution I sell, and I want it to be protected - and it has to be a runtime so it will run on anyone's standard PHP server. Zend's $600 was a little bit of sticker shock. Any alternatives? There is this pecl extension that I tested once and it works: http://pecl.php.net/package/bcompiler Your users won't need to do anything special if you encode the PHP projects that you host (in case I am getting this right). But there are no magical solutions to anything. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Full versus relative URLs
Here's a question related to my last post. When specifying a link in a HTML file (like to the css or an image file), there are two ways of doing it. One is to simply include the relative path to the file (relative to the doc root), like: /graphics/my_portrait.gif Or you can include the full URL, like: http://example.com/graphics/my_portrait.gif My casual observation seems to indicate that the former will load faster than the latter. But has anyone done any benchmarking on it? Paul I am not aware if absolute URLs are faster or not (in case they are there will be such a small difference you cannot probably notice) but IMHO it is a bad practice to use full URLs. Basically because renaming directories or scripts will cause great pain in the ass. Of course resources that are coming outside your own site are needed to use absolute URLs and nobody is assuming that are useless. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Apache odd behavior
I'm submitting a url like this: http://mysite.com/index.php/alfa/bravo/charlie/delta The index.php calls has code to decode the url segments (alfa/bravo/charlie/delta). It determines that the controller is alfa, the method is bravo, and converts charlie and delta to $_GET['charlie'] = 'delta'. It verifies that the controller and method exist, and calls the controller and method. This works fine. The right controller gets called and the right method, and the GET parameter looks like it should. The method sets some variables and then calls a render() function to render the page, which is in the doc root of the site. The page does get rendered, but without the stylesheet, and none of the graphics show up. Why? Because, according to the logs, Apache appears to be looking for the images and everything else in the directory index.php/alfa/bravo/charlie/delta, which of course doesn't exist. No, I don't have an .htaccess file with RewriteEngine on. Apache figures out that index.php is the file to look for in the original URL, but can't figure out that everything else is relative to that file, not the entire URL. This method is in use in at least one other MVC framework. What am I doing wrong? Paul I assume that in order for this to work you will have to use mod_rewrite for apache to work properly. Check the framework's installation instructions to see if you configured mod_rewrite correctly for this to work properly. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Opinions Please, Describing PHP as Web Framework of C and C++
Hello list. Recently we had some serious discussion on local boards. I prefer calling PHP as Web Framework of C and C++ if you had a time for this fruitless discussion. Please send your opinions. Regards Sancar I think that you can't assume that PHP is a C framework for the web, basically because when you use a framework (or API or whatever label you choose to use for describing it) in a language it just abstracts some aspects of the language making it "easier" to code. Since you can't compile PHP (as you would probably need to do with a C API) and since you don't even need C to write something in PHP you can't call it a C or C++ framework. In addition to this there is an API for C that can be used to code web applications and it is known as CGI (it is provided by many languages) PHP is coded in C and some things are similar in syntax and style but this is the only relation I can find between the two. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Reverse IP lookup
Hello, Is there anyway to get a list of sitess that are on a specific IP? I looked, But I couldn't find anything. I tried to make some with dns_get_record and gethostbyaddr, but couldn't make anything Thank Daniel Well actually you can't basically because of the way the Name Service reverse resolution works. AFAIK you may assign many domain names to a single IP as A records (main resolution option) or as CNAME (aliases) but you can't assign multiple IP's on the same domain name (meaning you can't make many PTR records for the same IP). So perhaps there are solutions to this using search engines but you can't know for sure. This is the way it works. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP OOP
Hi gang: At the college where I teach, they are considering teaching OOP, but they don't want to settle on a specific language. My thoughts are it's difficult to teach OOP without a language -- while the general concepts of OOP are interesting, people need to see how concepts are applied to understand how they work -- thus I think a specific language is required I lean toward C++ because I wrote in it for a few years AND C++ appears to be the most common, widespread, and popular OOP language. However, while I don't know PHP OOP, I am open to considering it because of the proliferation of web based applications. My personal opinion is that's where all programming is headed anyway, but that's just my opinion. With that said, what's the differences and advantages/disadvantages between C++ and PHP OOP? Cheers, tedd IMHO I think that you are right about using a specific language and you should strongly insist on that. Someone needs to see how objects are taking flesh and bones in real life and not just theoretically. You could consider Java as well before taking your final decision. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] xls to pdf conversion in unix
Hi gang, I did a little research to find out how can someone convert an xls file into pdf and I found that you can use openoffice to do that (already done that in perl). My problem is that I need to find a way for doing this without openoffice by using just PHP. I know that I could probably parse the xls using a reader and then write the data in a pdf with a module (like fpdf or pdflib) but I will get into complications I cannot resolve. So is there another way to do such a transformation. Give me your light... -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Email configuration
2009/2/6 Thodoris : 2009/2/5 Thodoris : I think that the OP mentioned the word fedora somewhere above... Oh sorry, I'm so stupid... Anyways, if you want to send mail to large providers you'll need to use a relay. I found a nice tutorial about how to set it up with google apps. It was for Ubuntu but you just have to install msmtp and follow the other steps. Here it is: http://nanotux.com/blog/the-ultimate-server/4/#l-mail I did it on my little gentoo server here at home and it works great. Well if I am not getting what you say in the wrong way I should say that you don't need to use a relay because you don't need a mail server at all. The point is that PHP can send mail with the mail() function using a local mail client like sendmail's client part or something coded in pure PHP. Keep in mind that you don't need to have a mail server in your PC in order to send mail. Similarly PHP doesn't need to have a local mail server in order to send mail. So you don't need extra mail configuration assuming of course that you don't need to do something extreme. You just use mail() and the mail gets sent. -- Thodoris Of course he can send mails this way, but they won't be accepted by many mail providers because of their anti-spam measurments. They bounce mails that come from dynamic ip ranges like his home server. I just wanted to help him avoid this because you won't see the reason until you look at the syslog. I am sorry didn't get right what you meant after all. In that case a simple mail() won't do. -- Thodoris
Re: [PHP] Boolean Assignment Operator
2009/2/2 Gavin Hodge Hi, I'm fairly new to PHP, having migrated from the Java / C# world. I wrote some code similar to the following: $success = true; $success &= operation1(); $success &= operation2(); if ($success === true) { operation3(); // depends on 1 and 2 being successful } This didn't work as expected. After a bit of digging I found: * The &= operation isn't mentioned anywhere in the PHP documentation * The &= function seems to work as expected, however the following is observed... $success = true; $success &= true; print $success == true; // outputs 1 print $sucesss === true; // no output * The 'or' assignment operator |= causes no errors but doesn't work. Can any PHP gurus explain why the &= operator works at all, and why === seems to fail afterwards? Cheers, Gavin. Hey, never heard of the "|=" operator. So I think php does not support it. Not true. This works just fine: And gives 1 as expected. I cannot say how "&=" works in Java or C# but as of php it works like that (IMO) (reference instead of copy): $var1 = "test1"; $var2 = $var1; $var3 &= $var1; $var1 = "test2"; echo var1; // "test2" echo var2; // "test1" echo var3; // "test2" The manual does describe these as "combined operators" in the assignment operators section. See the last example: http://www.php.net/manual/en/language.operators.assignment.php -- Thodoris
Re: [PHP] cgi vs php
Thodoris napsal(a): Y In cgi i can use perl ,c etc suppose i use perl now how efficiency differs? How cgi written in perl and php is differ in working in context of web service? other difference?. but their differ. On Thu, Feb 5, 2009 at 6:45 PM, Jay Blanchard wrote: [snip] can anybody tell me the benefits of php over cgi or vice versa? i need to compare both? [/snip] CGI is a gateway to be used by languages PHP is a language First of all try not to top post this is what we usually do here. Well CGI is a standard protocol implemented by many programming languages. You may start googling to find about it but this is a start: http://en.wikipedia.org/wiki/Common_Gateway_Interface Both Perl and PHP can work with CGI but working with Perl-CGI is not something that we should discuss in this list since this is a *PHP* list. IMHO you should start reading some aspects of web development to make some things clear before start asking questions in the lsit. This will improve your understanding and it help us to make suggestions. I admire your calmness. Such a descriptive reply for someone who doesn't think before asking. After smashing a ton of keyboards and yell at my screen when people started looking me with a weird expression in their faces I understood that: 1) I am paying a lot of money for keyboards 2) My screen will never answer my threats 3) People will start to think that I come from outer space 4) Everybody needs help :-) -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Email configuration
2009/2/5 Thodoris : I think that the OP mentioned the word fedora somewhere above... Oh sorry, I'm so stupid... Anyways, if you want to send mail to large providers you'll need to use a relay. I found a nice tutorial about how to set it up with google apps. It was for Ubuntu but you just have to install msmtp and follow the other steps. Here it is: http://nanotux.com/blog/the-ultimate-server/4/#l-mail I did it on my little gentoo server here at home and it works great. Well if I am not getting what you say in the wrong way I should say that you don't need to use a relay because you don't need a mail server at all. The point is that PHP can send mail with the mail() function using a local mail client like sendmail's client part or something coded in pure PHP. Keep in mind that you don't need to have a mail server in your PC in order to send mail. Similarly PHP doesn't need to have a local mail server in order to send mail. So you don't need extra mail configuration assuming of course that you don't need to do something extreme. You just use mail() and the mail gets sent. -- Thodoris
Re: [PHP] Clarity needed
Hi gang: I need some fog removed. I have a problem where I have an unlimited number of tutors teaching an unlimited number of courses. When I call upon a tutor, I want to see all the courses they teach. In my old days, I would just set up a linked list of courses and attach it to the tutor (another linked list). As a tutor adds courses, I would just add the course to the end of the linked list. If the tutor deletes a course, then I would remove it from the list by changing a single pointer. If I needed a list of all the courses the tutor taught, I would just run down the linked list pulling them out as needed. But now I have to think in terms of records in a database. I'll eventually figure it out, but what are your suggestions/solutions? I understand that I can have one record set up for each tutor, and another record set up for each course, and then tie the two together by another record like an assignment. That way I can have as many assignments as I want tying courses to tutors. It that the way you guys would do it? Thanks, tedd There is a very good schema for doing thing like that in this pdf. Its main purpose is to explain join temporary, tables and transactions but you will find it useful because I think it is relevant with your case. http://dev.mysql.com/tech-resources/articles/mysql-db-design-ch5.pdf Why don't you give it a try. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php rpm
On Wed, Feb 4, 2009 at 12:59 PM, Daniel Brown wrote: On Wed, Feb 4, 2009 at 09:46, wrote: Okay here is my question. Does anyone know of an RPM of php that is pre-compiled with all the extras like soap, mssql, freetds, etc... Afternoon, Rich, et al; On an RHEL 5.3 system, you should already have 'yum' installed with the repos ready to go by default, so just drop to a command line and, as root, type: yum install php-soap yum install php-mssql yum install php-pdo etc. If your 'yum' isn't working from the get-go, check http://rpmfind.net/ or http://pbone.net/ for the individual RPM's. -- daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ Unadvertised dedicated server deals, too low to print - email me to find out! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I might be wrong, but I think the packages have the php version appended to the it. so php5-soap, for example. At least it's like that in Fedora. Well I think this is a practice that FreeBSD uses in its ports and IMHO it is a good one. I don't remember if fedora is truly doing that but if it does that is cool I will check with my laptop (the only piece of hardware that has fedora installed). -- Thodoris
Re: [PHP] kadm5 Library
Sorry, I could have been a little clearer: I can't recompile PHP. It's against our general policy to use custom compiled software on the grounds that there are too many sysadmins managing a lot of these machines and if some software is custom compiled and others not, it gets too confusing when it comes to keeping the machines updated and patched. We're talking a dozen sysadmins and hundreds of machines here. :) That is understandable. No harm is done and sorry for the late reply. I did try to compile the PECL library by specifying the path to the Kerberos libraries as you suggested, but it turns out that the normal version of Kerberos seems to have, among other things, a "krb5/admin.h" header file, and the one that comes with CentOS has "krb5/krb5.h" instead, and even when I change the source code to use "krb5/krb5.h", it still throws about 50 errors talking about missing functions and re-defined functions and so on. Did you try to install krb5-devel. Try "yum search krb5" to see all the available packages that CentOS includes. In case your yum doesn't find something you may add more repos like Dag's: http://dag.wieers.com/ It is just an rpm that updates the systems repositories that I find very useful. I'm thinking that the problem is that the PECL module was designed to work with one version of the Kerberos library and CentOS provides a different version. I guess I was really asking if anyone had any diffs or anything I could apply to the PECL module to make it compile on a CentOS machine. Or perhaps is there a Yum repository somewhere that I could use to get a version of the PECL module precompiled for CentOS? I am not aware if there is a pre-compiled package for kerberos but Dag's repo doesn't provide it AFAIK. It does provide some other pecl extensions like php-pecl-fileinfo etc but not this one. What you need is to find a kerberos rpm to include development header in order to compile it your self. I should point out that the Perl Kerberos module did install and compile successfully on this machine, so I'm fairly sure that Kerberos is itself working. Tim Gustafson BSOE Webmaster UC Santa Cruz t...@soe.ucsc.edu 831-459-5354 Well let me tell what I did: I have installed this that is needed for the package to work: http://dag.wieers.com/rpm/packages/re2c/re2c-0.12.0-1.el5.rf.i386.rpm I have downloaded the source and tried to compile it with: ./configure --with-kadm5=/usr/include/krb5 But the compilation failed. My installed packages are: krb5-server-1.6.1-25.el5_2.2 krb5-libs-1.6.1-25.el5_2.2 krb5-workstation-1.6.1-25.el5_2.2 pam_krb5-2.2.14-1.el5_2.1 krb5-devel-1.6.1-25.el5_2.2 And then I run into this: http://pecl.php.net/bugs/bug.php?id=15196&thanks=3 I have already reported the bug and lets hope it will get fixed. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Blank page of hell..what to look for
Is there a certain thing that should be suspected and looked at first when getting the php blank page of hell I have errors on and nothing is being output anywhere to lead me in the right direction, I have a VariableReveal script (one of you provide and THANK YOU IT HAS BEEN A LIFESAVER) But it is doing nothing today, yesterday the page worked today I get the blank page with not a clue in sight ARGH... Terion First of all check if you are displaying error in your php.ini display_errors = On but don't use this in a normal site. You are probably already doing this because you mentioned that errors get displayed. You may use die to verify the how variables are changing values through the script and see if everything they store is what you want. die(print $var); die(print_r($array); die(var_dump($var)); You use it as you need to track down what is messing your script. Another way I can think you may use is exceptions especially if you are a PHP5 user. This could be useful: http://www.php.net/manual/en/language.exceptions.php I suspect that you would get a better answer if you were willing to send us some more details in what you are trying to do. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] cgi vs php
Y In cgi i can use perl ,c etc suppose i use perl now how efficiency differs? How cgi written in perl and php is differ in working in context of web service? other difference?. but their differ. On Thu, Feb 5, 2009 at 6:45 PM, Jay Blanchard wrote: [snip] can anybody tell me the benefits of php over cgi or vice versa? i need to compare both? [/snip] CGI is a gateway to be used by languages PHP is a language First of all try not to top post this is what we usually do here. Well CGI is a standard protocol implemented by many programming languages. You may start googling to find about it but this is a start: http://en.wikipedia.org/wiki/Common_Gateway_Interface Both Perl and PHP can work with CGI but working with Perl-CGI is not something that we should discuss in this list since this is a *PHP* list. IMHO you should start reading some aspects of web development to make some things clear before start asking questions in the lsit. This will improve your understanding and it help us to make suggestions. -- Thodoris
Re: [PHP] Email configuration
2009/2/5 It flance : Hi all, I've installed php and mysql in fedora. Now i am able to create php programs. But when I am unable to use email in my programs. I am wondering what is the easiest way to use email in my php programs. Can i send email from my personal computer. I am a regular person connected to internet through an internet provider. Is there any preconfigured software or I have to go through the configuration of sendmail for example? Thank you Sorry... But I need a _little_ bit more information. What operating system do you use? Linux/Windows/Mac/other? The main problem is that most of the big email providers don't accept mails from dialup connections, but there are solutions to work around this. For now start by telling me which operating system you have. I think that the OP mentioned the word fedora somewhere above... To the point: Your linux probably has already installed the sendmail suite. If that is the case (run rpm -qa | grep sendmail to check) you may safely use the PHP's mail function for simple things. In case you don't have sendmail installed use: # yum install sendmail http://www.php.net/manual/en/function.mail.php If you need more advanced features like for e.g. adding attachments to your e-mails you may consider other options like phpmailer. I have never used it myself but many people that belong in this gang are very fond of it. http://phpmailer.codeworxtech.com/ Keep in mind that in case you have compiled PHP from source without having the sendmail installed you may need to recompile it. You can find this by making a phpinfo somewhere. In case you have installed from package no harm is done. Put this in a script: You will find "sendmail_path" somethere in the resulting page or something like that "Path to sendmail". If this is set then everything will work like a charm. -- Thodoris
Re: [PHP] function_exists question
Is there a way to check not only if a function exists, but also to check that the number and types of parameters desired match a function definition? The reason being that additional options have been added in php 4 and 5 to various standard function calls, but I'm still running a php3 and php4 server in addition to a php5 server. I would like to make sure that certain "extended" function calls still work in all versions (or I'll perform the tasks "manually", albeit less efficiently). One example I can think of is the round() function. The $precision parameter was added in php4, so will not work in php3. However, function_exists would return TRUE for both 3 and 4, but round itself would fail if I tried to send a precision level to the php3 server. Thanks much, Matt P.S. Of course the modified "function_exists" would unfortunately have to be a recognized function/method in php3 in order for me to call it to check parameter counts on a php3 server :( I am sure you have some good reasons for keeping php3 right? Why don't you consider updating to at least php4 ?? PHPv3 is not even maintained and PHPv4 is not being developed any more. So by the end of this year (I hope) we will start using a stable PHPv6. IMHO you should consider changing your code (if this is possible) to a more mainstream version. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sometime the code works and sometimes doesn't
Hi, Here is a code for PHP password sending. There is some strange thing happening. This code DOES WORK but not always. So I might be able to get the password in my mailbox once but not always. What could be wrong. $host = 'xxx'; $user = 'xxx'; $password = 'xxx'; $dbName = 'xxx'; // connect and select the database $conn = mysql_connect($host, $user, $password) or die(mysql_error()); $db = mysql_select_db($dbName, $conn) or die(mysql_error()); // value sent from form $emailAddress=$_POST['emailAddress']; $sql="SELECT password FROM mytable WHERE emailAddress='$emailAddress'"; $result=mysql_query($sql); BTW I think that this vulnerable to SQL injection. So don't put this piece of code in a real as is. Instead escape before making the query with mysql_escape_string: http://www.php.net/manual/en/function.mysql-escape-string.php // keep value in variable name "$count" $count=mysql_num_rows($result); // compare if $count =1 row if($count==1){ $rows=mysql_fetch_array($result); // keep password in $your_password $your_password=$rows['password']; $subject="Your password is retrieved"; $header="from: Great Site"; $messages= "Hi \n\n Your password for login to our website is retrieved.\n\n"; $messages.="Your password is '$your_password' \n\n"; $messages.="You can use this password"; // send email $sentmail = mail($emailAddress, $subject, $messages, $header); } // else if $count not equal 1 else { echo "Not found your email in our database"; } // if your email succesfully sent if($sentmail){ echo "Your Password Has Been Sent To Your Email Address."; } else { echo "Cannot send password to your e-mail address"; } ?> There must be something that I am doing wrong. Otherwise I could have always gotten the password in my mailbox. Please help. Thanks in advance, Chris -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP webhosting - USA - conclusion
I should have said in the beginning it's a small website and I am not looking for a dedicated server. Howewer, I decided to move to Lypha.com Thanks for all your fruitful* comments :) Martin PS: PHP mailgroup rulz *) that was in dictionary You could check ICDsoft http://www.icdsoft.com/ -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php rpm
Daniel Brown wrote: On Wed, Feb 4, 2009 at 09:46, wrote: Okay here is my question. Does anyone know of an RPM of php that is pre-compiled with all the extras like soap, mssql, freetds, etc... Afternoon, Rich, et al; On an RHEL 5.3 system, you should already have 'yum' installed with the repos ready to go by default, so just drop to a command line and, as root, type: yum install php-soap yum install php-mssql yum install php-pdo etc. If your 'yum' isn't working from the get-go, check http://rpmfind.net/ or http://pbone.net/ for the individual RPM's. This probably more then one rpm :-) . You can do most of things using your distro's repos but usually PHP doesn't come in a single rpm. The truth is IMHO that pre-compiled packages are responsible for some failures in certain circumstances but generally are very good if you don't want to get your hands dirty. A good way to see how is your distro giving you a prepackaged PHP set of rpms is using yum: # yum search php This is to get the list of all the available packages. You can then go and install what you need. Using: # yum install php (and whatever you need) It is not a good practice making an rpm with all the features included because it could become huge and it will probably need many dependencies in order to get installed properly. IMHO that is why the best OS to use as on a web server is FreeBSD because of the flexibility provided by the ports system and the way that PHP is divided into small parts that can be added or removed easily. Not to mention that you are compiling PHP (as a port) and you can update it or remove it like a package the same time. Again this is my point of view that I wanted to share. --- Thodoris
Re: [PHP] calculate the time that day ends
Shawn McKenzie wrote: Thodoris wrote: 2009/2/3 Thodoris : I was wondering if there is way to find out what is the time that every day ends? I am planning to add this to the first page on an interface I am developing. Most days end at midnight, but there may be some exceptions ;-) Seriously though, not really sure what you're asking. -Stuart :-) Sorry Stuart I should have made it more clear. I meant the time that the sun goes down and the dark night finally comes. The time that a vampire can safely go for a pizza without burning himself. Of course Blade is an exception thrown out of the blue. STFW http://www.google.com/search?q=calculate+sunset+formula Wow, also: http://www.google.com/search?q=php+calculate+sunset Yields this gem: http://www.w3schools.com/php/func_date_sunset.asp Thanks Shawn this could make a good start: http://www.phpclasses.org/browse/package/2642.html -- Thodoris
Re: RES: [PHP] calculate the time that day ends
Try: echo date("H:i:s", mktime(23-date("H"), 59-date("i"), 59-date("s")); This is I guess how much time we have to reach midnight. But the question is how to calculate the time that sun stops showing its refreshing light. BTW try not to top post -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php