php-general Digest 13 Jan 2009 14:33:10 -0000 Issue 5899

Topics (messages 286193 through 286208):

Re: RewriteRules
        286193 by: Jason Pruim
        286195 by: Nathan Rixham
        286197 by: Jason Pruim
        286206 by: tedd
        286207 by: Ashley Sheridan

ecommerce related question
        286194 by: Travis Moore
        286203 by: tedd

Re: upgrade php 5.2.6 -> 5.2.8 mysql problems!
        286196 by: Merlin Morgenstern

Re: Php and CSS where to put it
        286198 by: Al

Re: HowTo use Eclipse PDT and existing mounted directory tree?
        286199 by: Thodoris
        286204 by: Eric Butera

iconv is messing up a spreadsheet generated by the Spreadsheet Excel Writer
        286200 by: Thodoris
        286201 by: Ashley Sheridan
        286202 by: Thodoris
        286205 by: Ashley Sheridan
        286208 by: Thodoris

Administrivia:

To subscribe to the digest, e-mail:
        [email protected]

To unsubscribe from the digest, e-mail:
        [email protected]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---

On Jan 12, 2009, at 2:16 PM, Nathan Rixham wrote:

Jason Pruim wrote:
Hi Everyone,
I know it's not a php question... But I know alot of you use rewrite rules and regular expressions and so I thought maybe you would be able to help me.
The site: HTTP://purl.raoset.com/test112
test112 doesn't exist.. It's driven by the database using this rewrite rule:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /p.php [L]
Now, on that site I have a few links... right now the likes are in the format of:
HTTP://purl.raoset.com/design.php?purl=test112
What I would like is to have it read:
HTTP://purl.raoset.com/test112/design
completing the total look of the site :)

technically the same code as above should work even if you change you're links.. you see it's just redirecting everything not found to p.php

so in p.php simply add in a
print_r($_SERVER);
exit();
at the top, upload to server then visit /test112/design in you're browser.. check the print_r output and you'll see the request in there, (variables sometimes differ, hence why I'm suggesting you check; you can skip this bit and jump right on to the next paragraph though)

you can then simply:
$request_page_parts = explode('/', $_SERVER['REQUEST_URI');
print_r($request_page_parts);

then use whatever code you want to display the correct page based on the uri requested (as you want)

I know this isn't the approach you expected but it basically hands off all page selection and processing to php, rather than a load of rewrite rules and lots of updating of .htaccess

if you really want the rewrite rules then I'm sure you've had many other accurate replies with examples :)

Nathan,

You get any drink you want as long as you come to me! Once I looked at it and read your e-mail it made total sense... I understand PHP programming better than rewrite rules :)




--- End Message ---
--- Begin Message ---
Jason Pruim wrote:

On Jan 12, 2009, at 2:16 PM, Nathan Rixham wrote:

Jason Pruim wrote:
Hi Everyone,
I know it's not a php question... But I know alot of you use rewrite rules and regular expressions and so I thought maybe you would be able to help me.
The site: HTTP://purl.raoset.com/test112
test112 doesn't exist.. It's driven by the database using this rewrite rule:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /p.php [L]
Now, on that site I have a few links... right now the likes are in the format of:
HTTP://purl.raoset.com/design.php?purl=test112
What I would like is to have it read:
HTTP://purl.raoset.com/test112/design
completing the total look of the site :)

technically the same code as above should work even if you change you're links.. you see it's just redirecting everything not found to p.php

so in p.php simply add in a
print_r($_SERVER);
exit();
at the top, upload to server then visit /test112/design in you're browser.. check the print_r output and you'll see the request in there, (variables sometimes differ, hence why I'm suggesting you check; you can skip this bit and jump right on to the next paragraph though)

you can then simply:
$request_page_parts = explode('/', $_SERVER['REQUEST_URI');
print_r($request_page_parts);

then use whatever code you want to display the correct page based on the uri requested (as you want)

I know this isn't the approach you expected but it basically hands off all page selection and processing to php, rather than a load of rewrite rules and lots of updating of .htaccess

if you really want the rewrite rules then I'm sure you've had many other accurate replies with examples :)

Nathan,

You get any drink you want as long as you come to me! Once I looked at it and read your e-mail it made total sense... I understand PHP programming better than rewrite rules :)




cool; couple of little notes to help you on you're way..

first thing you'll want to do is explode/split on "?" so that you have any get params stripped off and stored seperately for good measure next up it makes sense to check for and seperate file extensions, and likewise trim off trailing /'s

also experiment with this, you can do some nifty things; the last time I implemented it I had the following set up on my urls
domain.com/.wrapper/section/the_page_name.ext
in short, .wrapper was optional, and could be one of .ajax, .default, .print (output template differed dependant on the wrapper specified)
section and page name are both self explanatory
.ext was again optional, in one implementation I completely ignored it, meaning I could disguise the site as being all .html, or all .asp or .jsp or whatever (just for the novelty and to throw hackers) - in another implementation I used it wth extensions of .json .xml .php and .html (much like twitter) which turned the site into a kind of api.

I would recommend trying the above and making a system like this at some point, it's simpler than you think; but the benefits are immense, not becuase of the things you can do.. but because of the way it makes you program, it get's you to seperate the functional code from the presentation and really think about things - you learn lessons that never leave you :)

best wishes, nath

--- End Message ---
--- Begin Message ---

On Jan 13, 2009, at 5:37 AM, Nathan Rixham wrote:

Jason Pruim wrote:

On Jan 12, 2009, at 2:16 PM, Nathan Rixham wrote:

Jason Pruim wrote:
Hi Everyone,
I know it's not a php question... But I know alot of you use rewrite rules and regular expressions and so I thought maybe you would be able to help me.
The site: HTTP://purl.raoset.com/test112
test112 doesn't exist.. It's driven by the database using this rewrite rule:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /p.php [L]
Now, on that site I have a few links... right now the likes are in the format of:
HTTP://purl.raoset.com/design.php?purl=test112
What I would like is to have it read:
HTTP://purl.raoset.com/test112/design
completing the total look of the site :)

technically the same code as above should work even if you change you're links.. you see it's just redirecting everything not found to p.php

so in p.php simply add in a
print_r($_SERVER);
exit();
at the top, upload to server then visit /test112/design in you're browser.. check the print_r output and you'll see the request in there, (variables sometimes differ, hence why I'm suggesting you check; you can skip this bit and jump right on to the next paragraph though)

you can then simply:
$request_page_parts = explode('/', $_SERVER['REQUEST_URI');
print_r($request_page_parts);

then use whatever code you want to display the correct page based on the uri requested (as you want)

I know this isn't the approach you expected but it basically hands off all page selection and processing to php, rather than a load of rewrite rules and lots of updating of .htaccess

if you really want the rewrite rules then I'm sure you've had many other accurate replies with examples :)

Nathan,

You get any drink you want as long as you come to me! Once I looked at it and read your e-mail it made total sense... I understand PHP programming better than rewrite rules :)




cool; couple of little notes to help you on you're way..

first thing you'll want to do is explode/split on "?" so that you have any get params stripped off and stored seperately for good measure next up it makes sense to check for and seperate file extensions, and likewise trim off trailing /'s

also experiment with this, you can do some nifty things; the last time I implemented it I had the following set up on my urls
domain.com/.wrapper/section/the_page_name.ext
in short, .wrapper was optional, and could be one of .ajax, .default, .print (output template differed dependant on the wrapper specified)
section and page name are both self explanatory
.ext was again optional, in one implementation I completely ignored it, meaning I could disguise the site as being all .html, or all .asp or .jsp or whatever (just for the novelty and to throw hackers) - in another implementation I used it wth extensions of .json .xml .php and .html (much like twitter) which turned the site into a kind of api.

I would recommend trying the above and making a system like this at some point, it's simpler than you think; but the benefits are immense, not becuase of the things you can do.. but because of the way it makes you program, it get's you to seperate the functional code from the presentation and really think about things - you learn lessons that never leave you :)

best wishes, nath

Hmm... I like the idea of that... I'll play with that when I get home... Unfortunately the boss doesn't pay me to write programs anymore... Even though I've written stuff to make him money! :)

so if anyone knows of a junior to mid level programming job that pays $50,000+ in the US let me know! :)



--
Jason Pruim
[email protected]
616.399.2355




--- End Message ---
--- Begin Message ---
Jason:

In addition to what everyone else has said, try this:

$self = basename($_SERVER['SCRIPT_NAME'])

I use it for forms -- you might find it useful.

Cheers,

tedd
--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
On Tue, 2009-01-13 at 09:20 -0500, tedd wrote:
> Jason:
> 
> In addition to what everyone else has said, try this:
> 
> $self = basename($_SERVER['SCRIPT_NAME'])
> 
> I use it for forms -- you might find it useful.
> 
> Cheers,
> 
> tedd
> -- 
> -------
> http://sperling.com  http://ancientstones.com  http://earthstones.com
> 
No need to use it on forms, as leaving the action attribute empty means
the form sends to itself anyway.


Ash
www.ashleysheridan.co.uk


--- End Message ---
--- Begin Message --- Firstly, not really a php question, but generic web stuff, but I feel it's still better answered here.

Recently a friend came to me asking to create an ecommerce website. In the past my php work has been primarily a hobby, and as such haven't really taken much interest or effort into security aspects of it.

Given the nature of the project, I realise security is a must. My question is: what recommended reading for security or ecommerce can any of you suggest?

--
Thanks,
Travis Moore
[email protected] OR [email protected]
--- End Message ---
--- Begin Message ---
At 3:58 PM +1030 1/13/09, Travis Moore wrote:
Firstly, not really a php question, but generic web stuff, but I feel it's still better answered here.

Recently a friend came to me asking to create an ecommerce website. In the past my php work has been primarily a hobby, and as such haven't really taken much interest or effort into security aspects of it.

Given the nature of the project, I realise security is a must. My question is: what recommended reading for security or ecommerce can any of you suggest?

--
Thanks,
Travis Moore
[email protected] OR [email protected]


Travis:

I could write a treaties on ecommerce security problems and not cover everything.

My recommendation for a hobbyist php developer is to contact PayPal; establish an account with them; and have them do all the collections.

You prepare the site to sell items and do what PayPal says needs to be done. That will work well enough for a successful operation.

If you are thinking about collecting credit card information and processing transactions yourself, you had better have the business as a corporation to protect your personal assets (if you are in the USA), because things could get out of hand very quickly. That's a dangerous road to travel.

Cheers,

tedd
--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
Hi there,

has somebody an idea how to fix this? I do appreciate any help.

Thank you in advance, Merlin

Merlin Morgenstern wrote:
No. The with-pdo-mysql command secures compatibility with oder databases . That workes fine. The yes in the error msg. seams to be normal in this case. I found loads of such via google. e.g:
http://www.rootforum.de/forum/viewtopic.php?f=158&t=35941&start=0

All point to the fact that there needs to be mysql-dev installed. But why? I am already running 5.2.6. And mysql-dev does not come with suse 11. I doubt that this is the cause.

Any other ideas?

Thanx, merlin

Chris schrieb:

Here is the configure command that is pretty much the same as in 5.2.6:

So look at the differences ;)

'./configure' '--enable-fastcgi' '--with-mysql' '--prefix=/usr/local/php' '--with-apxs2=/usr/local/apache2/bin/apxs' '--enable-mbstring' '--with-pdo-mysql=/usr/local/mysql/' '--with-mysql-sock=/tmp' '--enable-soap' '--with-zlib' '--with-freetype-dir=/usr/local/lib' '--with-gd' '--with-jpeg-dir=/usr' '--with-png-dir=/usr/lib' '--enable-exif' '--enable-cli'

<snip>

configure: error: Cannot find MySQL header files under yes.

This gives you the clue - it's not "--with-mysql=yes" or something (no idea where "yes" is actually coming from).

Try --with-mysql=/usr/local/mysql


--- End Message ---
--- Begin Message ---


Terion Miller wrote:
I have this code and the css seems to not work in IE at all, do I need to
put it somewhere different on the page maybe?

<link rel="stylesheet" type="text/css" href="inc/styles.css">
<?php  include 'inc/dbconnOpen.php' ;

ini_set('error_reporting', E_ALL);
ini_set('display_errors', true);

 $sql = "SELECT * FROM `textads` WHERE `expos` > xCount ORDER BY RAND()
LIMIT 3";
$result = mysql_query($sql);

echo "
<table class=jobfont width=728 height=90 border=0 align=center
cellpadding=10 bordercolor=#000066 background= 'inc/bg.gif' bgcolor=#CCCCCC>
<tr>
<td>
<table width=690 height=50 border=0 align=center cellpadding=5>
<tr>";

while ($row = mysql_fetch_array($result)) {
    echo "
    <td  class=col align=center
width=33%>{$row['title']}<br>{$row['blurb']}<br>
    <A HREF='{$row['href']}'>{$row['href']}</a></td>";
    //Add to exposure count
    $views = $row['xCount'] + 1;
    mysql_query("UPDATE `textads` SET `xCount` = '{$views}' WHERE `ID` =
'{$row['ID']}'");
}

echo " </tr>
</table></td></tr></table>";

?>


Terion: Install Firefox and the "HTML Validator" extension. It is a perfect tool for you. It will clearly identify all the HTML errors and warnings, AND point you to how to fix them. It uses Tidy, which classifies many errors as warnings.

However, you should fix them. Your page has 21 serious warnings many of which are errors that will affect rendering. After you've fixed the warnings and errors it finds, run the W3C HTML Validator.

Also, install the Firefox extension "Validate CSS". Run it on your page. It has 8 bad errors.

These tools are great learning aids.

Incidentally, I'm not a fan of frames, often causes problems.

Al.....

--- End Message ---
--- Begin Message ---

On Mon, Jan 12, 2009 at 8:13 PM, Daevid Vincent <[email protected]> wrote:
I must be retarded or something because I can't figure out in Eclipse
PDT (Linux) how in the heck do I start a new project and have it "point"
to an existing directory tree.

I DO NOT want Eclipse to pull in a copy of the files or do anything
wacky like that. I simply want it to look at a mount point (sshfs)
directory and use the files that exist there already. These are served
up via apache on a dedicated development server, so obviously I want to
change them and not a 'local copy'.

The files are physically in /var/www/vincentd/ on the dev box but are
in /home/vincentd/mydev/ on my local Ubuntu as a share. Or in other
words... localhost:/home/vincentd/pse02 ->
development:/var/www/vincentd/

I've Googled around and can't seem to find the right words to get an
answer to what would seem an obvious task.

D.Vin
http://daevid.com



There's a checkbox near the project name.  Can't remember what it's
called, but it lets you use a different workspace location.  Try that.


Try to set the workspace in the mounted directory. If the project already exists try to import the project (I think this is the proper way) by right clicking in PHP explorer and choosing Import menu. Then you should choose "Existing project into Workspace" under the "General" tree.

I don't if there is a better way but I usually open the existing projects this way.

--
Thodoris


--- End Message ---
--- Begin Message ---
On Mon, Jan 12, 2009 at 8:51 PM, Eric Butera <[email protected]> wrote:
> On Mon, Jan 12, 2009 at 8:13 PM, Daevid Vincent <[email protected]> wrote:
>> I must be retarded or something because I can't figure out in Eclipse
>> PDT (Linux) how in the heck do I start a new project and have it "point"
>> to an existing directory tree.
>>
>> I DO NOT want Eclipse to pull in a copy of the files or do anything
>> wacky like that. I simply want it to look at a mount point (sshfs)
>> directory and use the files that exist there already. These are served
>> up via apache on a dedicated development server, so obviously I want to
>> change them and not a 'local copy'.
>>
>> The files are physically in /var/www/vincentd/ on the dev box but are
>> in /home/vincentd/mydev/ on my local Ubuntu as a share. Or in other
>> words... localhost:/home/vincentd/pse02 ->
>> development:/var/www/vincentd/
>>
>> I've Googled around and can't seem to find the right words to get an
>> answer to what would seem an obvious task.
>>
>> D.Vin
>> http://daevid.com
>>
>>
>
> There's a checkbox near the project name.  Can't remember what it's
> called, but it lets you use a different workspace location.  Try that.
>

The checkbox is labeled "Use Default" under the "Project Contents" group.

If all of your sites are in this share and you'll use it each time, I
would recommend changing your default workspace location.  On my local
ubuntu I change it to /home/eric/Sites.

--- End Message ---
--- Begin Message ---

Hi gang,
I am generating a spreadsheet using the contents of a mysql table. I guess that there is something in the data that causes iconv used in the module's script to generate this error:

*Notice*: iconv() [function.iconv <file:///C:/Documents%20and%20Settings/tgol/Local%20Settings/Temp/function.iconv>]: Detected an incomplete multibyte character in input string in */usr/local/share/pear/Spreadsheet/Excel/Writer/Worksheet.php* on line *1547*

This causes the production of weird characters in a cell in the spreadsheet and after that cell everything is printed out of order.

The data in the mysql table are filtered for non-printable character before the data import.

I have tried to filter the data before writing them into the sheet but this behavior persists.

Any ideas in what might be wrong?

--
Thodoris


--- End Message ---
--- Begin Message ---
On Tue, 2009-01-13 at 15:51 +0200, Thodoris wrote:
> Hi gang,
>     I am generating a spreadsheet using the contents of a mysql table. I 
> guess that there is something in the data that causes iconv used in the 
> module's script to generate this error:
> 
> *Notice*: iconv() [function.iconv 
> <file:///C:/Documents%20and%20Settings/tgol/Local%20Settings/Temp/function.iconv>]:
>  
> Detected an incomplete multibyte character in input string in 
> */usr/local/share/pear/Spreadsheet/Excel/Writer/Worksheet.php* on line 
> *1547*
> 
> This causes the production of weird characters in a cell in the 
> spreadsheet and after that cell everything is printed out of order.
> 
> The data in the mysql table are filtered for non-printable character 
> before the data import.
> 
> I have tried to filter the data before writing them into the sheet but 
> this behavior persists.
> 
> Any ideas in what might be wrong?
> 
Well a multibyte character is something like a character from utf-8 or
unicode, where more than one byte is used to represent the character.
Does the Excel writer you use support utf or unicode?


Ash
www.ashleysheridan.co.uk


--- End Message ---
--- Begin Message ---

On Tue, 2009-01-13 at 15:51 +0200, Thodoris wrote:
Hi gang,
I am generating a spreadsheet using the contents of a mysql table. I guess that there is something in the data that causes iconv used in the module's script to generate this error:

*Notice*: iconv() [function.iconv <file:///C:/Documents%20and%20Settings/tgol/Local%20Settings/Temp/function.iconv>]: Detected an incomplete multibyte character in input string in */usr/local/share/pear/Spreadsheet/Excel/Writer/Worksheet.php* on line *1547*

This causes the production of weird characters in a cell in the spreadsheet and after that cell everything is printed out of order.

The data in the mysql table are filtered for non-printable character before the data import.

I have tried to filter the data before writing them into the sheet but this behavior persists.

Any ideas in what might be wrong?

Well a multibyte character is something like a character from utf-8 or
unicode, where more than one byte is used to represent the character.
Does the Excel writer you use support utf or unicode?


Ash
www.ashleysheridan.co.uk


Actually it does and AFAIK it changes everything into UTF-16LE. The Excel writer is the pecl module Spreadsheet_Excel_Writer.

BTW do you have any suggestions for a better open source writer I could use?

--
Thodoris


--- End Message ---
--- Begin Message ---
On Tue, 2009-01-13 at 16:07 +0200, Thodoris wrote:
> > On Tue, 2009-01-13 at 15:51 +0200, Thodoris wrote:
> >   
> >> Hi gang,
> >>     I am generating a spreadsheet using the contents of a mysql table. I 
> >> guess that there is something in the data that causes iconv used in the 
> >> module's script to generate this error:
> >>
> >> *Notice*: iconv() [function.iconv 
> >> <file:///C:/Documents%20and%20Settings/tgol/Local%20Settings/Temp/function.iconv>]:
> >>  
> >> Detected an incomplete multibyte character in input string in 
> >> */usr/local/share/pear/Spreadsheet/Excel/Writer/Worksheet.php* on line 
> >> *1547*
> >>
> >> This causes the production of weird characters in a cell in the 
> >> spreadsheet and after that cell everything is printed out of order.
> >>
> >> The data in the mysql table are filtered for non-printable character 
> >> before the data import.
> >>
> >> I have tried to filter the data before writing them into the sheet but 
> >> this behavior persists.
> >>
> >> Any ideas in what might be wrong?
> >>
> >>     
> > Well a multibyte character is something like a character from utf-8 or
> > unicode, where more than one byte is used to represent the character.
> > Does the Excel writer you use support utf or unicode?
> >
> >
> > Ash
> > www.ashleysheridan.co.uk
> >
> >   
> 
> Actually it does and AFAIK it changes everything into UTF-16LE. The 
> Excel writer is the pecl module Spreadsheet_Excel_Writer.
> 
> BTW do you have any suggestions for a better open source writer I could use?
> 
> -- 
> Thodoris
> 
> 
Unfortunately I don't know of any other Excel writers, but I never
really use that format anymore if I can help it. Would a CSV not work?


Ash
www.ashleysheridan.co.uk


--- End Message ---
--- Begin Message ---

On Tue, 2009-01-13 at 16:07 +0200, Thodoris wrote:
On Tue, 2009-01-13 at 15:51 +0200, Thodoris wrote:
Hi gang,
I am generating a spreadsheet using the contents of a mysql table. I guess that there is something in the data that causes iconv used in the module's script to generate this error:

*Notice*: iconv() [function.iconv <file:///C:/Documents%20and%20Settings/tgol/Local%20Settings/Temp/function.iconv>]: Detected an incomplete multibyte character in input string in */usr/local/share/pear/Spreadsheet/Excel/Writer/Worksheet.php* on line *1547*

This causes the production of weird characters in a cell in the spreadsheet and after that cell everything is printed out of order.

The data in the mysql table are filtered for non-printable character before the data import.

I have tried to filter the data before writing them into the sheet but this behavior persists.

Any ideas in what might be wrong?

Well a multibyte character is something like a character from utf-8 or
unicode, where more than one byte is used to represent the character.
Does the Excel writer you use support utf or unicode?


Ash
www.ashleysheridan.co.uk

Actually it does and AFAIK it changes everything into UTF-16LE. The Excel writer is the pecl module Spreadsheet_Excel_Writer.

BTW do you have any suggestions for a better open source writer I could use?

--
Thodoris


Unfortunately I don't know of any other Excel writers, but I never
really use that format anymore if I can help it. Would a CSV not work?


Ash
www.ashleysheridan.co.uk


Well it does work but unfortunately both need to be supported.

I should say that it actually is the pear module Spreadsheet_Excel_Writer and not pecl.

I could probably try to debug the module itself but this is usually a very bad idea. I came to this point because I have stripped all non-printable characters, tabs, CRs and LFs before writing into the speadsheet but nothing seems to work.

--
Thodoris


--- End Message ---

Reply via email to