[PHP] Re: Basic Auth

2013-08-27 Thread B. Aerts

On 27/08/13 15:37, Jim Giner wrote:

Im using basic auth for a few of my pages that I want to limit access
to - nothing of a sensitive nature, but simply want to limit access to.
  Want to implement a signoff process, but can't figure it out.

 From the comments in the manual I take it one can't do this by simply
unsetting the PHP_AUTH_USER and _PW vars.  Can someone explain to me why
this doesn't suffice?  The signon process expects them to be there, so
when they are not (after the 'unset'), how come my signon process still
detects them and their values?


Hello Jim,

at the risk of under-estimating your knowledge (and over-estimating 
mine) of HTTP-requests in PHP - but here it goes.


I see two options of bypassing the JavaScript option.

The first one is to use the default authorization, and error pages of 
your HTTP server.
(For example, in Apache: 
http://httpd.apache.org/docs/2.2/custom-error.html)

This is for a login with invalid credentials.
For some-one to leave the protected site, a HTTP-request without 
credentials, and to a URI outside the protected domain, should do (as 
every HTTP request into the protected domain should repeat the 
Authorisation header).



The second one is to leave header(), and go down one level, to the likes 
of fsockopen() or stream_socket_server() - though personally, I've only 
limited knowledge of a bit of client-side programming.


Unless I've completely misunderstood your question,
Hope this helps,

Bert

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Premature end of script

2013-07-17 Thread R B
Hello,

5 years ago, y developed a php system and was working fine. But 20 days
ago, when y try to access to some pages (not all the pages), in the log
appears this message and the page is not displayed:

== /usr/local/apache/logs/error_log ==
[Wed Jul 3 02:36:58 2013] [error] [client 10.30.6.161] Premature end of
script
headers: /home/capitale/public_html/miembros/myscript.php

Can you help me please with this error?

Thank you.


Re: [PHP] webDAV/CalDAV client class experience ?

2013-02-18 Thread B. Aerts

- Adding the HTTP header Accept: */* made sure all read actions ( e.g.
GET, PROPFIND, REPORT) worked perfectly


This is interesting. The Accept header has to do with what media types
the browser will accept in return. I didn't think it had anything to
do with what operations the server/application accepts. Must go read
further


I'll have to revoke this statement, as I can't reproduce it anymore.
I noticed the DaviCal didn't use it, bu the CURL call did - and yielded 
more ( = meaningfull) results.

But, as I said, can't reproduce it.

The thing I could reproduce was that, if the request was sent to the 
default port, AND this port was included in the Host header, both GET 
and PUT yielded HTTP 404.





Only problem remaining was that PUT still isn't possible - at least not with
one of the providers. Since I used a verbatim copy of a PUT action from the
RFC, I strongly suspect the problem to be with the provider.


You've no doubt considered this already, but it might be intentional
on the provider's part. I'm not up on all the webDAV/calDAV providers;
I imagine some of them might add in additional layers of auth
(including the NOWAI layer)  just to consider themselves more secure.


Yes I did, but the following arguments should negate that consideration:
- when running OPTIONS, PUT is included in the allowed HTTP methods
- the HTTP return code from the PUT command is 301, where a security 
issue would have yielded a code in the 400 range
- I think the CalDAV spec does mention Basic auhentication, so it can't 
be anything more sophisticated
- the other provider does respond as expected (though I agree, that is 
the weakest argument: expectations != specifications )
- the provider does allow sync'ing Sunbird, iCal, ... over CalDAV, and 
that works, even entering a new event (which is a PUT action). The 
Charles debugging proxy too shows that it's only Basic authentication 
that's going up - and succeeding



I'll add the code I used for the tests.
When looking for the configuration ( Calendar URL, ...), the search term 
CalDAV provider Calendar Sunbird always did the trick for me.
( I also had to modify the Davical client class a bit - make some 
protected members public for this test code to work)



if (1)
{
   $url  = 
https://caldav.calendar.provider1.com/dav/ba_aerts/Calendar/tstCalDAV/ 
; // make sure it ends in a '/' !

   $user = usrname1@provider1.com ;
   $pwd  = *1 ;
}
else
{
   $url  = 
https://www.provider2.com/calendar/dav/usrname2@provider2.com/events/ 
;

   $user = usrname2@provider2.com ;
   $pwd = **2 ;
}

/
 * run OPTIONS test *
 /

$method = OPTIONS ;

$requestHeaders = Array(content-type = text/xml,
Depth = 1) ;

echo UL\n ;

echo LI$method request:\n ;
doCurlRequest($method, $url, $user, $pwd, , $requestHeaders) ;
doCalDAVClientRequest($method, $url, $user, $pwd, , $requestHeaders ) ;
echo /LI \n ;

echo 
\r\nLI=/LI 
\n ;


/
 * run PROPFIND test*
 /

$method = PROPFIND ;
$body = XML
D:propfind xmlns:D=DAV: xmlns:CS=http://calendarserver.org/ns/; 
xmlns:C=urn:ietf:params:xml:ns:caldav

D:prop
D:resourcetype /
D:owner /
D:current-user-principal /
D:supported-report-set /
C:supported-calendar-component-set /
CS:getctag /
/D:prop
/D:propfind
XML;

echo LI$method request:\n ;
doCurlRequest($method, $url, $user, $pwd, $body, $requestHeaders) ;
doCalDAVClientRequest($method, $url, $user, $pwd, $body, $requestHeaders ) ;

echo /LI \n ;

echo 
\r\nLI=/LI 
\n ;


/
 * run REPORT test  *
 /

$method = REPORT ;
$body = XML
?xml version=1.0 encoding=utf-8 ?
C:calendar-query xmlns:D=DAV: xmlns:C=urn:ietf:params:xml:ns:caldav
 D:prop
   C:calendar-data/
   D:getetag/
 /D:prop
 C:filter
   C:comp-filter name=VCALENDAR
 C:comp-filter name=VEVENT
   C:time-range start=20130201T01Z end=20130228T01Z/
 /C:comp-filter
   /C:comp-filter
 /C:filter
/C:calendar-query
XML;

echo LI$method request:\n ;
doCurlRequest($method, $url, $user, $pwd, $body, $requestHeaders) ;
doCalDAVClientRequest($method, $url, $user, $pwd, $body, $requestHeaders ) ;
echo /LI \n ;

echo 
\r\nLI=/LI 
\n ;


/
 * run GET test *
 /

$method   = GET ;
$icsFile  = e26443db-02d4-4bf0-a97c-c1ddbd3126df.ics ;

echo LI$method request:\n ;

// some cheating 

Re: [PHP] webDAV/CalDAV client class experience ?

2013-02-16 Thread B. Aerts

On 13/02/13 14:27, Daniel Brown wrote:

On Tue, Feb 12, 2013 at 3:40 PM, B. Aerts ba_ae...@yahoo.com wrote:

Hello,

I'm working on this one for more than a year (personal project) - but I'm
turning pretty desperate here.

I'm trying to connect to 2 Calendars through the CalDAV protocol.
The calendars are hosted by 2 webmail providers.
If I try to sync through a dedicated calendar, like iCal or Thunderbird
Lightning add-on, this works fine.

However, once I try to do it through native PHP, I fail miserably - even
if I mimick HTTP requests as recorded by Charles (HTTP debugging proxy).

Up until now, I used the inc_caldav-client-v2.php, which worked for a while
and then stopped all of a sudden. The PUT requests failed, and then any HTTP
request got caught in what appears to be a socket timeout.

My question: is anyone using some webDAV/CalDAV class that actually works ?
If not, any tutorial on the subject is also deeply appreciated ( all I can
rely on is the IETF spec rfc4791, which is far from accesible reading
material)


 I haven't tried them myself, but there are PEAR packages for
client-server implementations for WebDAV:

 http://pear.php.net/search.php?q=webdavin=packagesx=0y=0

 They're not actively maintained by anyone right now (feel free to
apply to change that if you'd like the responsibility), but the most
recent server version was released just this past October (the client
version is about a year older).  At the very least, it may be enough
to get you started.



Hello,

I did try to download the PEAR package, but got stuck in some missing 
header problem.
In the mean time however, I did manage to solve a few problems - listed 
for archiving's sake :
- the biggest mistake: apparently I commented the fwrite() call to the 
stream, which explains why he went in time-out ... (in this case, please 
DO shoot the pianist)


- CalDAVClient class from inc_caldav-client-v2.php always adds the port 
to the Host HTTP header, even if it is the default port; by removing 
it from the header, I got less problems
- Adding the HTTP header Accept: */* made sure all read actions ( e.g. 
GET, PROPFIND, REPORT) worked perfectly


Only problem remaining was that PUT still isn't possible - at least not 
with one of the providers. Since I used a verbatim copy of a PUT action 
from the RFC, I strongly suspect the problem to be with the provider.


Thanks for the help !

Bert


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] webDAV/CalDAV client class experience ?

2013-02-12 Thread B. Aerts

Hello,

I'm working on this one for more than a year (personal project) - but 
I'm turning pretty desperate here.


I'm trying to connect to 2 Calendars through the CalDAV protocol.
The calendars are hosted by 2 webmail providers.
If I try to sync through a dedicated calendar, like iCal or Thunderbird 
Lightning add-on, this works fine.


However, once I try to do it through native PHP, I fail miserably - 
even if I mimick HTTP requests as recorded by Charles (HTTP debugging 
proxy).


Up until now, I used the inc_caldav-client-v2.php, which worked for a 
while and then stopped all of a sudden. The PUT requests failed, and 
then any HTTP request got caught in what appears to be a socket timeout.


My question: is anyone using some webDAV/CalDAV class that actually works ?
If not, any tutorial on the subject is also deeply appreciated ( all I 
can rely on is the IETF spec rfc4791, which is far from accesible 
reading material)





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] error_handler : unique caller ID ?

2012-11-14 Thread B. Aerts

On 13/11/12 20:04, Robert Williams wrote:

On 11/13/12 11:20, B. Aerts ba_ae...@yahoo.com wrote:



Having read access to a variable's address (like a C-pointer) would be
perfect - but Google tells me you can't in PHP.


If you can restrict yourself to objects for the passed variables, you can
use spl_object_hash(). It does exactly what you need, but it only works
with objects. AFAIK, there's no equivalent for scalars or arrays.

http://php.net/manual/en/function.spl-object-hash.php


Regards,
Bob

--
Robert E. Williams, Jr.
Associate Vice President of Software Development
Newtek Businesss Services, Inc. -- The Small Business Authority
https://www.newtekreferrals.com/rewjr
http://www.thesba.com/



Hello Bob,

thanks for the tip - indeed it does exactly what I need.
Unfortunately, I need to keep scalars/arrays in the frame too.

But thinking along your line, do you know of a function that does a 
similar thing to the function call itsself ?


( as functions get stacked, called recursive or through callback 
mechanisms, there must be a similar allocation table/mechanism as for 
variables/objects)


Regards,

Bert


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] error_handler : unique caller ID ?

2012-11-13 Thread B. Aerts

Dear list,

a penny for your thoughts on the following problem.

Does anyone have an idea how to find a unique caller ID for a 
user-defined error handler ?


The goal is to get a cached error messages tree where the following 
snippet would yield an array as below it:


// start-of-snippet

function Outer($a)
{
   trigger_error('entering Outer');
   $a=Inner($a) ;
   trigger_error('leaving Outer') ;
}

function Inner($x)
{
   trigger_error('entering Inner');
   return(2*$x) ;
}

trigger_error('Here we go ');
$b = 1 ;
$b = Outer($b) ;
trigger_error('End result is $b');


// end-of-snippet

Output:

Array(
[0] = 'Here we go'
['Outer(unique_ID_01)'] = Array(
   [0] = 'entering Outer' ;
   ['Inner(unique_ID_02)'] = Array(
  [0] = 'entering Inner' ;
   )
   [1] = 'leaving Outer' ;
   )
[1] = 'End result is 2'
)

I've considered the 'args' option in debug_backtrace(), but that fails 
for referenced arguments.


Having read access to a variable's address (like a C-pointer) would be 
perfect - but Google tells me you can't in PHP.


Any other idea's ?

Regards,

Bert

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Character encoding

2009-08-05 Thread b

On 08/05/2009 07:05 AM, Sándor Tamás (HostWare Kft.) wrote:

Hi,

I have a mysql database, which the users can insert comments. As the users can 
be from different countries, with different character encoding, the mysql table 
can contain various special characters.

How can I be sure to display these comments properly? I've found the 
mb_convert_encoding, and for some characters it works okay, but there are some 
really special characters which displayed as a '?'.

Does anybody know some workarounds?

Thanks,
SanTa


Use UTF-8. Create your database and its tables with UTF-8 char encoding. eg.

ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci

Note there's no hyphen.

Also, make sure the *data* is converted. You can use iconv for that.

Next, ensure that the browser knows how to display the text. Use either 
a header or a meta tag (or both):


meta http-equiv=Content-Type content=text/html; charset=utf-8 /

This is especially important for the page with the comments form.

Any SQL file with your data (for import) should have the following at 
the top:


SET NAMES 'utf8';

If you export a dump make sure that line is present before trying to import.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fileinfo returning wrong mime type for Excel files

2009-07-30 Thread b

On 07/30/2009 08:53 AM, Peter Ford wrote:


Have you tried using 'file -i' from the command line: after all you are looking
for a MIME type with your fileinfo...

Having said that, with file -i on my system, Word documents are
'application/msword' and Excel files are 'application/octet-stream'



Fedora11 (2.6.29.6-213.fc11.i586)

$ file excel.xls
excel.xls: CDF V2 Document, Little Endian, Os: Windows, Version 5.1, 
Code page: 1252, Author: ??, Last Saved By: 
ELAN, Name of Creating Application: Microsoft Excel, Last Printed: Sun 
Nov  6 18:04:20 2005, Create Time/Date: Tue Nov  1 02:56:47 2005, 
Security: 0


$ file -i excel.xls
excel.xls: application/vnd.ms-excel; charset=binary

Using 5.2.9, the OP's script prints:
application/vnd.ms-excel; charset=binary

I wonder if the problem lies with the documents themselves. Last May, I 
posted a msg here about how FileInfo was reporting back 
application/msword application/msword for some (but not all) Word 
docs. I never received a reply about it but came up with a hack to split 
on the space, if present.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting plain text file

2009-07-30 Thread b

On 07/30/2009 06:29 PM, Skip Evans wrote:

Jim Lucas wrote:

Skip Evans wrote:

Hey all,

Am I brain fading or what? I'm so used to formatting text in tables for
HTML display I can't think of how to do it for a plain text file.

I just need to create a columned table of names and addresses type
stuff... sprintf?


or a little str_pad on each variable...



Sure, that will do it. But isn't there some way to construct formatted
tables similar to HTML?




Are you thinking of a CSV file that you can open in a spreadsheet prog? 
Or, do you literally mean a plaintext file with columns? For the latter, 
you'd need to measure the max char length of each column for every 
line in the file, then go back and print each line using str_pad().



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fileinfo returning wrong mime type for Excel files

2009-07-30 Thread b

On 07/30/2009 10:15 AM, Ashley Sheridan wrote:

On Thu, 2009-07-30 at 07:12 -0700, Christoph Boget wrote:



You could email it to me, which I presume is better if you replied
back just to me and not the list?


Just copying the list back on in this one now. I don't know of any
places that you could upload a file to off the top of my head. Anyone
have any links?



Just google upload file; there are a bunch of sites that do this to 
choose from.


(I've never used any so I can't recommend one over the others)


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] preg_match too greedy

2009-07-29 Thread b
I'm trying to figure out how to test if a string matches *exactly* 
another string, using a regexp pattern. The manual says that ereg() is 
deprecated (in favour of what?) and preg_match() is giving me trouble. 
The problem is that I'm passing the end-of-line delimiter ($) but it 
seems to be ignored. An example:


-- snip --
header('Content-type: text/plain');
$url = '/foo(/)?';
$test = 'foo/bar';
$pattern = '%^'.$url.'$%U';

echo ${url} :: ${test}\n;

echo (preg_match($pattern, $test) != false)
? 'match'
: 'no match';
-- snip --

I expected 'no match' but get 'match'.

The reason for the (/)? is to allow for a trailing slash. I've added a 
'$' to specify that I want to test for the exact string. However, 
preg_match() tests for the existence of a string and appears to ignore 
the '$'.


How do I do this?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] preg_match too greedy

2009-07-29 Thread b

On 07/29/2009 02:07 PM, Jim Lucas wrote:

b wrote:

I'm trying to figure out how to test if a string matches *exactly*
another string, using a regexp pattern. The manual says that ereg() is
deprecated (in favour of what?) and preg_match() is giving me trouble.
The problem is that I'm passing the end-of-line delimiter ($) but it
seems to be ignored. An example:

-- snip --
header('Content-type: text/plain');
$url = '/foo(/)?';
$test = 'foo/bar';
$pattern = '%^'.$url.'$%U';

echo ${url} :: ${test}\n;

echo (preg_match($pattern, $test) != false)
 ? 'match'
 : 'no match';
-- snip --

I expected 'no match' but get 'match'.

The reason for the (/)? is to allow for a trailing slash. I've added a
'$' to specify that I want to test for the exact string. However,
preg_match() tests for the existence of a string and appears to ignore
the '$'.

How do I do this?



cut/paste your code and it works for me.

Jim Lucas



Works, meaning you get 'match', or 'no match'? It should be the latter, 
but I'm seeing the former.


I'm using 5.2.9, btw.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] preg_match too greedy

2009-07-29 Thread b

On 07/29/2009 03:03 PM, Ben Dunlap wrote:

Jim Lucas wrote:

I expected 'no match' but get 'match'.

[8]

cut/paste your code and it works for me.


Works for me as well. I get 'no match' from PHP 5.1.2, 5.2.6, and 5.2.8. What
version do you have?


5.2.9


If I might suggest a couple of simplifications that would make it easier to
follow/troubleshoot:


$url = '/foo(/)?';


I don't think you need parentheses around your second forward-slash. If you had
multiple characters that were optional you'd want to group them in parentheses,
but here I think it just makes the regex harder to read.


Really? I think it makes it crystal clear that it's the '/' that is 
optional. In any case, it makes no difference.





echo (preg_match($pattern, $test) != false)


The  != false  here is redundant.


Understood. But what you think is redundancy is, to me, clarity in 
programming. I happen to think that boolean tests shouldn't ride on 
whether or not an array returned from a function is empty or not (or a 
freaking boolean). If what I'm looking for is a false then that's what 
I'll test for.



Combined with the ternary operator, the logical switchbacks make me a

 little dizzy (especially this close to lunchtime).




Oh, you're one of those people who can't stand the sight of a ternary 
operator. Buck up, son, it's good for ya ;-)


(Seriously: I don't understand why ternaries freak some people out. It's 
plain as day!)



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] preg_match too greedy

2009-07-29 Thread b

On 07/29/2009 07:48 PM, Daniel Kolbo wrote:


code works (no match) for me too on php 5.2.6 build date May 2 2008
18:01:20 with dumbdows NT.

preg_match fails but for a reason other than what I think you may be
expecting.  It fails b/c of the first forwards slash in $url.  The regex
engine doesn't even get past the second character let alone reaching the
end of line anchor.


The forward slash shouldn't be an issue as the delimiter is '%'. The 
full pattern is:


%^/foo/?$%U



Also, your code works (no match) with this first forward slash removed:
$url = 'foo(/)?'


But the string happens to start with a forward slash.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] preg_match too greedy

2009-07-29 Thread b

On 07/29/2009 11:18 PM, Daniel Kolbo wrote:

b wrote:

On 07/29/2009 07:48 PM, Daniel Kolbo wrote:

code works (no match) for me too on php 5.2.6 build date May 2 2008
18:01:20 with dumbdows NT.

preg_match fails but for a reason other than what I think you may be
expecting.  It fails b/c of the first forwards slash in $url.  The regex
engine doesn't even get past the second character let alone reaching the
end of line anchor.

The forward slash shouldn't be an issue as the delimiter is '%'. The
full pattern is:

%^/foo/?$%U



Also, your code works (no match) with this first forward slash removed:
$url = 'foo(/)?'

But the string happens to start with a forward slash.



i am not talking about the delimiter
your pattern is:
%^/foo/?$%U
your test string is:
'foo/bar'


AAARRRGG! Sorry, that's a typo! It should be:

$test = '/foo/bar';

I guess that explains a lot. For the record, I had to type that in 
because this latest version of Thunderbird crashes whenever I paste into 
it. (note to self: downgrade that, stat!)






--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP as Language

2009-07-24 Thread b

On 07/24/2009 02:06 PM, Kyle Smith wrote:

Martin Scotta wrote:

Hi all

Is there a formal definition for the php language?
Where I can found it?

I've STW with no results.


Not sure if this is what you mean, but PHP stands for PHP: Hypertext
Processor

- Kyle



I think Martin is looking for the formal definition of the language, not 
the name. Wikipedia has a bunch of links worth checking:


http://en.wikipedia.org/wiki/PHP#Notes

Nothing jumps out at me, though.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Amazon s3 and PHP

2009-06-03 Thread R B
Hi,

Do you know if amazon s3 hosting support php files?

Thanks.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Amazon s3 and PHP

2009-06-03 Thread R B
To configure a AMI have some extra fee?

Do you have a link to read how to run php files in amazon s3?

Thanks.


On Wed, Jun 3, 2009 at 11:13 AM, Bastien Koert phps...@gmail.com wrote:

 On Wed, Jun 3, 2009 at 12:27 PM, R B rbp...@gmail.com wrote:
  Hi,
 
  Do you know if amazon s3 hosting support php files?
 
  Thanks.
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 

 yep, depending on the AMI you use to set up the server. There are many
 supporting php5, but not many supporting mysql5


 --

 Bastien

 Cat, the other other white meat



Re: [PHP] Re: PHP Security

2009-06-02 Thread b

Grant Peel wrote:

???


I think you can safely assume that was a joke.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Why does PHP have such a pain in the a$$ configuration file?

2009-05-27 Thread b

hessi...@hessiess.com wrote:

Something that seriously annoys me about PHP is the fact that it has
a configuration file which can *completely* change the behaviour of
the language.


Perhaps you're not at all clear on the purpose of a configuration file.

 I am seriously considering moving to a different language because of 
this.


I guess you could look for a language that has a parser with 0 
configuration options. Sounds like a bundle of fun.


Meanwhile, why don't you consider a) moving to a new host; or, b) 
setting up your own server so you can ~shudder~ *configure* it however 
you like.



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Fileinfo and MSWord bug

2009-05-16 Thread b

PHP 5.2.6
file-4.17-15.el5_3.1
Fileinfo installed through PECL

Checking certain MSWord files, I'm getting back (sans quotes) 
application/msword application/msword. Someone reported (in the manual 
comments) this same thing back in 2007:

http://ca2.php.net/manual/en/ref.fileinfo.php#79063

Can anyone shed any light on how/why this is happening? Specifically, is 
this a bug in Fileinfo, file (the app), the Word doc, or the magic file 
itself? I'd love to investigate this further but am having some trouble 
searching online. Narrowing it down to a specific target would be most 
helpful. I don't see anything about it at bugs.php.net and I'd rather 
try to figure out if the problem is PHP-related before filing a bug.


For now, I'm doing the following:

$fi = new finfo(FILEINFO_MIME, FINFO_PATH);
$type = $fi-file($file['tmp_name']);

$split = explode(' ', $type);
$type = $split[0];

Pretty hackish. If anyone has a better solution in the meantime, I'd be 
most appreciative.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Execute flash files with PHP

2009-02-19 Thread R B
Hello.

I have two scripts in php that reads a .swf or .flv movie file, like this:

SCRIPT # 1

?php

$movie = movie.swf;

readfile($movie);
?

SCRIPT # 2

?php

$movie = movie.flv;

readfile($movie);
?

The script # 1 with the .swf file works fine: the video is executed with
streaming.
The script # 2 with the .flv file  is executed but without streaming.

If i execute the movie.flv directly (without the php script), then it´s
executed with streaming.

Do you know how can i do to execute the .flv file with php and with
straming?
I tried with fopen, readfile, but don´t works.

Thank you


[PHP] mysql_query - CREATE DATABASE

2009-02-09 Thread R B
Hello,

When i create a mysql database with the next command:

mysql_query(CREATE DATABASE my_db,$con)

In the server is created the database, but usually the name is created with
a prefix.

In this case: someuser_my_db

How can i detect with PHP the complete name of the new database created?

Thanks


Re: [PHP] Re: mysql_query - CREATE DATABASE

2009-02-09 Thread R B
I´m creating a software that use a database, and i want to include a
install.php file to install the database
of the software.

I can create the database in the install.php file with

mysql_query(CREATE DATABASE my_db,$con)
But when is created, i don´t know the complete name of the database, because
a prefix is added.




On Mon, Feb 9, 2009 at 12:17 PM, Shawn McKenzie nos...@mckenzies.netwrote:

  R B wrote:
  Hello,
 
  When i create a mysql database with the next command:
 
  mysql_query(CREATE DATABASE my_db,$con)
 
  In the server is created the database, but usually the name is created
 with
  a prefix.
 
  In this case: someuser_my_db
 
  How can i detect with PHP the complete name of the new database created?
 
  Thanks
 

 There may be a better way, but off the top of my head, translate this to
 PHP:

 use information_schema;
 select SCHEMA_NAME from SCHEMATA where SCHEMA_NAME like '%_my_db';

 Now of course you could have multiples there, like user_my_db and
 user2_my_db.  Not sure about that, maybe it would be the last one in the
 returned records?

 --
 Thanks!
 -Shawn
 http://www.spidean.com

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Re: mysql_query - CREATE DATABASE

2009-02-09 Thread R B
I´m looking that i have another problem:

I´m making a software to install in any server.

The software needs a database, so i want to create a script install.php
to create the database when this script is executed.

At this point of the instalation, i don´t know none of the users that are
defined in mysql.

If i use this command:

mysql_query(CREATE DATABASE my_db,$con)

first i need to connect to mysql with the command

mysql_connect

But at this point, i don´t know none of the users that are defined in mysql.

So, what i do in this case?

Thanks


On Mon, Feb 9, 2009 at 12:31 PM, Shawn McKenzie nos...@mckenzies.netwrote:

 Shawn McKenzie wrote:
  R B wrote:
  Hello,
 
  When i create a mysql database with the next command:
 
  mysql_query(CREATE DATABASE my_db,$con)
 
  In the server is created the database, but usually the name is created
 with
  a prefix.
 
  In this case: someuser_my_db
 
  How can i detect with PHP the complete name of the new database created?
 
  Thanks
 
 
  There may be a better way, but off the top of my head, translate this to
  PHP:
 
  use information_schema;
  select SCHEMA_NAME from SCHEMATA where SCHEMA_NAME like '%_my_db';
 
  Now of course you could have multiples there, like user_my_db and
  user2_my_db.  Not sure about that, maybe it would be the last one in the
  returned records?
 

 Using mysql_list_dbs() and mysql_db_name()  would acheive the same,
 however from the man page of mysql_db_name() there is a neat contib:

 $result = mysql_query(SELECT DATABASE());
 $dbname = mysql_result($result, 0);

 --
 Thanks!
 -Shawn
 http://www.spidean.com

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Re: mysql_query - CREATE DATABASE

2009-02-09 Thread R B
thank you.



On Mon, Feb 9, 2009 at 1:14 PM, Shawn McKenzie nos...@mckenzies.net wrote:

 R B wrote:
  I´m looking that i have another problem:
 
  I´m making a software to install in any server.
 
  The software needs a database, so i want to create a script install.php
  to create the database when this script is executed.
 
  At this point of the instalation, i don´t know none of the users that are
  defined in mysql.
 
  If i use this command:
 
  mysql_query(CREATE DATABASE my_db,$con)
 
  first i need to connect to mysql with the command
 
  mysql_connect
 
  But at this point, i don´t know none of the users that are defined in
 mysql.
 
  So, what i do in this case?
 
  Thanks
 
 

 Well, obviously the user will have to supply the username and password.
  There's no way around that.  So after you know the username you can
 create the db and then check if the db exists as you have named it
 (my_db), and if not check for ($username_my_db), if not that then one of
 the examples I gave you, or just skip right to listing the databases.


 --
  Thanks!
 -Shawn
 http://www.spidean.com

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Include PHP library file in the .htaccess

2009-01-30 Thread R B
Hello.

Supose that i have this script:

?php

require_once(lib.php);


lib_function();
?

I want to know if there is a way to call the lib.php library from the
.htaccess instead of the PHP script?
Thanks.


[PHP] Non-traditional software accessing my website

2009-01-26 Thread R B
Hello,

Is there a way to be sure that a website is going to be accessed only by
traditional browsers and not from another
software that send to the server the same headers of any of the traditional
browsers?
For example, supose that i only want to give access to my site users from
firefox, ie, chrome and safari, because
i know that the users can´t download the copyright information of the
website to the temporary files with anyone
of this browsers.

How can i be sure that someone that develop a mini-browser or a software
can´t access my site sending the same
header information of traditional browsers?

In this case, the validation of HTTP_USER_AGENT isn´t a solution.

Thanks.


[PHP] PHP and Apache configuration

2009-01-19 Thread R B
Hello,

I need that every time someone access one image file in my server, then
redirect to a php file.

I make this well with:

Redirect 301 imagefile.jpg scriptfile.php

But i need that the file scriptfile.php can only be accessed by this
redirect command.

If someone try to access directly from the url
http://www.mydomain.com/xyz/scriptfile.php, i want to send an error access.

I tried with:

Files scriptfile.php
Order allow,deny
Deny from all
/Files
But with this configuration, the redirect command cant access the
scriptfile.php

Do you have the solution for this?

thanks.


Re: [PHP] PHP and Apache configuration

2009-01-19 Thread R B
I like this apache solution, but if i put

SetEnvIf Referer ^http://www.yourdomain.com; local_referal

Then i can access the file putting this path in the URL:

 http://www.yourdomain.com/xyz/scriptfile.php
And i don´t want the script to be access by the url. That is the main
problem.

Thanks


On Mon, Jan 19, 2009 at 1:38 PM, Richard Heyes rich...@php.net wrote:

  ...

 This may be of some help. It's from the Apache website and only allows
 access if the Referer header is sent by the browser and is
 www.yourdomain.com, ie. Direct access is not permitted:

 ###
 SetEnvIf Referer ^http://www.yourdomain.com; local_referal

 Order Deny,Allow
 Deny from all
 Allow from env=local_referal
 ###

 --
 Richard Heyes

 HTML5 Graphing for Firefox, Chrome, Opera and Safari:
 http://www.rgraph.org (Updated January 17th)



[PHP] Create PHP form from MySQL table structure

2008-12-21 Thread R B MacGregor
Hi folks

Anybody got any recommendations for a utility which would create a quick head 
start by creating the php/html code for a basic form using the field structure 
of a MySQL table ?

Thanks for any suggestions.

-- 
Ronnie MacGregor
Scotland

Ronnie at
dBASEdeveloper
dot co dot uk

www.dBASEdeveloper.co.uk




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Sepating MySQL result set into html tables

2008-09-26 Thread b

Thodoris wrote:

Hello everybody,
   I have a mysql result set that I want to print out in an html table. 
But some times it gets so big that I will probably need to separate it 
in to multiple ones. I wrote a function that separates the result set 
into three ones like this:


...

But I really need to tell the function in how many tables I need the 
result set to be separated. How can I do this?


What can I put instead of this for 3 tables: (($j == $limit-1) || ($j == 
(2*$limit)-1))


I can't find the algorithm although I think I have done this before but 
I can't remember how.




Why not just use LIMIT in your query and make several?

Why do you need to split the data into multiple tables, anyway?


   $table = table class='inner';

   $table .= tabletrtdtable class='inner';


That's going to give you badly-formatted HTML.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] calling functions from one or multiple files

2008-09-24 Thread b

Lamp Lists wrote:

Hi,
Right now I use one file, usually called functions.php, with all functions I'm 
going to use most likely on every page.
Then, I create each function I'm going to use once in a while as separate file.
Pro: I would include a function when I'm going to use.
Con: I have to write extra include line to call function. And have bunch of 
files (functions) in function folder.

I was talking to co-workers few days ago and they said I complicate my
life to much and putting ALL functions in one file is just fine and
I'll not be able to see difference in real situations.



When not using a framework (eg. Cake) i also usually keep a single file 
and include it. I think it depends on how many functions you have. If 
you've got a really huge functions.php and most of them are used only in 
one or two scripts, then you probably shouldn't be loading it into every 
script. Otherwise, i wouldn't be too concerned about it.


Of course, you should also think about using classes if that makes sense 
for what you're doing.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] calling functions from one or multiple files

2008-09-24 Thread b

Ashley Sheridan wrote:

On Wed, 2008-09-24 at 12:37 -0400, b wrote:

Lamp Lists wrote:

Hi, Right now I use one file, usually called functions.php, with
all functions I'm going to use most likely on every page. Then, I
create each function I'm going to use once in a while as separate
file. Pro: I would include a function when I'm going to use. Con:
I have to write extra include line to call function. And have
bunch of files (functions) in function folder.

I was talking to co-workers few days ago and they said I
complicate my life to much and putting ALL functions in one file
is just fine and I'll not be able to see difference in real
situations.


When not using a framework (eg. Cake) i also usually keep a single
file and include it. I think it depends on how many functions you
have. If you've got a really huge functions.php and most of them
are used only in one or two scripts, then you probably shouldn't be
loading it into every script. Otherwise, i wouldn't be too
concerned about it.

Of course, you should also think about using classes if that makes
sense for what you're doing.

I tend to try and group functions I use on a site, with common ones 
going into a generic functions.php file. This avoid the problems of 
overly large function files included on every page, as chances are

you won't need every function.



Done that, but not so much anymore. It depends on how specialised the 
functions (and sections) are. Usually an administration section can do 
with a separate file (while also including the general one). But, for 
other areas, it'll work fine until you find that you need a function 
that's in another file.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] br was [PHP] Re: render html

2008-09-21 Thread b

tedd wrote:

At 8:17 AM +0200 9/21/08, Lupus Michaelis wrote:

Michelle Konzack a écrit :

$body = hellobr/ulier/ulhellohello;

^
Should be br /


  Definitely no :

http://www.w3.org/TR/2006/REC-xml-20060816/#dt-empty
http://www.w3.org/TR/2006/REC-xml-20060816/#NT-S

  Or maybe for buggy browsers ?



   Definitely no ???  

I've always found this confusing.



I think this page explains the roots of the confusion very well:

Empty elements in SGML, HTML, XML, and XHTML
http://www.cs.tut.fi/~jkorpela/html/empty.html


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Associative array issues with loading values after initialization

2008-09-19 Thread b

Thomas Bolioli wrote:
I should add, it is not working with this funciton, which could be the 
source of the issue.


function dropbox_from_list($list, $selected_index){
   while ($nex = next($list)) {


I'd use foreach() here and avoid next(). At least, reset the array 
first. And maybe pass the array by reference:


function dropbox_from_list($list, $selected_index)
{
  foreach($list as $k = $v)
  {


   $k = key($nex);
   if (strcmp($selected_index, $k) == 0) {
   $select = ' SELECTED';
   }
   else {
   $select = '';
   }
   print(option value='.$k.'.$select..$nex[$k]./option);
   }
}


Maybe you should also add what it is that's not working.




Thomas Bolioli wrote:

The below function is not working.
function crm_get_country_list(){
global $dbh;
   $result = mysql_query(SELECT * FROM countries ORDER BY 
pk_country_id ASC, $dbh) or die(mysql_error());

   $country_list = array(' ' =' ');


Are you starting with an empty key  value so that you'll have an empty 
option in your select list? Why not just print an empty one?



   while ($row = mysql_fetch_assoc($result)){
   $country_list[$row['pk_countryID']] = $row['country_name'];
   }
return $country_list;
}


Start with the obvious: what does $country_list contain when it's returned?

Again, some details about what you're getting would go a long way toward 
getting some advice.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Paypal Integration

2008-09-16 Thread b

Ashley Sheridan wrote:


I don't recommend HSBC at all. They make you jump your code through so
many hoops and their documentation was awful. I don't know why large
companies think it's acceptable to produce bad/out-of-date documentation
and expect it all to be OK.



Thanks for the heads-up. I also did have a look at 2Checkout some time 
ago but found it pretty sketchy, as someone else pointed out.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] tedd's back from vacation

2008-09-10 Thread b

tedd wrote:

hi gang:

For those who wondered where I went -- I was on vacation.

I would have announced it before I left, but I was afraid that someone 
would have broken into my collection of stuff.


I'll post pictures of my vacation soon.

Oh, I had lot's of fun -- so much so, I broke my big toe on my left foot 
-- that's having serious fun! That was a dance someone should have 
recorded.


Cheers,

tedd


OK, this is getting ridiculous. I think we need a new PHP list. 
Something like [EMAIL PROTECTED] sounds about right.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] New Server Install

2008-09-10 Thread b

Robbert van Andel wrote:

I am working on a new webserver running Fedora 9.  I installed php-mysql and
php-mssql via yum.  When I try to connect to our mysql server using php, I
get the following error: Can't connect to MySQL server on 'mysqlservername'
(13)

Here's the weird part, I can connect to the mysql database server just fine
from the web server's command line so I'm pretty confident that it's not a
firewall issue.  While trying to connect using PHP, I see no packets leaving
the webserver. 

 


I'd guess it's SELinux blocking it. This will allow apache to connect to 
a remote server:



/usr/sbin/setsebool -P httpd_can_network_connect=1

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] php image and javascript include

2008-09-07 Thread b

javasac wrote:

[lots of stuff ...]



I'm guessing that was the *output* of the PHP file, not the script itself.

You've got a couple different errors here. The first is that you're not 
creating img tags. All you have here is the path to the image. A browser 
isn't going to do anything with that.


 td width=10 height=7
 images/box_bottom_lft.jpg /td

Second, at least one of the image paths is relative to your own desktop 
computer's drive (why is it that this always happens on a Windows box?)


 td width=11
 C:/wamp/www/yojoe-web/html/site/images/box_top_rht.jpg /td


Also, in the future, it'd be better to trim out the completely 
unnecessary bits. That's an awful lot of (bloated) HTML and javascript 
to wade through.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Sending POST variables without html code

2008-09-05 Thread R B
Hi,

I need to create a cron job PHP script to access every day the information
of a webpage that is out of my server. This webpage needs POST variables to
display the information.

How can i send this POST variables from my PHP script without having a html
form, and receive the required information?

Thanks,

RB


Re: [PHP] Negative Look Ahead Regex - Code Mistake or Bug?

2008-08-18 Thread Cameron B. Prince
Hi Simcha,

I tried your suggestion and it does prevent the SID from being inserted
inside the extension, but causes double ?'s and SID's in some cases.

Thanks,
Cameron


On 8/18/08 2:25 AM, Simcha Younger [EMAIL PROTECTED] wrote:

 
 Hi
 
 
 You did not put a question mark in your character class  ([\/\w\.-] and
 instead you put it together with the session id.
 The expression looks for a sequence without which is not followed by the
 next expression --- ?PHPSESSID\=2u0cca.
 If it would count the last `p` of `.php` then the next expression would
 violate the negative lookahead.
 Instead it stops just before it, after the `.ph` which is the longest
 expression it could find that fulfills your negative lookahead, and then it
 inserts the new sessionid over there.
 
 Try instead 
 $buffer =
 preg_replace('/http\:\/\/www\.domain\.com([\/\w\.\-]*\??)(?!PHPSESSID\=2u0c
 caffoh6jaeapkke35qpp87;?)/',
 'http://www.domain.com$1?PHPSESSID=t9gksvpdcuobsnqt98qloe6lg4;', $buffer);
 
 (not tested)
 
 
 
 Simcha Younger
 
 -Original Message-
 From: Cameron B. Prince [mailto:[EMAIL PROTECTED]
 Sent: Monday, August 18, 2008 12:56 AM
 To: php-general@lists.php.net
 Subject: [PHP] Negative Look Ahead Regex - Code Mistake or Bug?
 
 Hello,
 
 I¹ve run into a problem with a regex and need help determining if this is my
 mistake or a bug. The regex is for inserting a SID into every link in the
 buffer before it¹s flushed, but only when each link doesn¹t already have a
 SID.
 
 An example of the code is here:
 
 $buffer = 
 preg_replace('/http\:\/\/www\.domain\.com([\/\w\.-]*)(?!\?PHPSESSID\=2u0cca
 ffoh6jaeapkke35qpp87;?)/',
 'http://www.domain.com$1?PHPSESSID=t9gksvpdcuobsnqt98qloe6lg4;', $buffer);
 
 The code works correctly in most cases except when a SID already exists and
 there is a path after the .com such as:
 
 http://www.domain.com/path1/path2.php?PHPSESSID=2u0ccaffoh6jaeapkke35qpp87;
 
 When this URL is processed by the regex, it becomes:
 
 http://www.domain.com/path1/path2.ph?PHPSESSID=t9gksvpdcuobsnqt98qloe6lg4;p?
 PHPSESSID=2u0ccaffoh6jaeapkke35qpp87;
 
 
 So the problem is the regex not only falsely matches, it's inserting the SID
 in between 2nd and 3rd letters of the extension.
 
 You can see the code in action here:
 
 http://kottmann.com/test.php
 
 The full source for the test code is also available when viewing the source
 of this page.
 
 I've tested this on PHP v5.1.6 and PHP v5.2.6.
 
 TIA,
 Cameron
 
 
 
 
 
 
 



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Negative Look Ahead Regex - Code Mistake or Bug?

2008-08-18 Thread Cameron B. Prince
Hi Al,

I am using preg_quote in the live code. I omitted it from the example code
to simplify the example.

Thanks,
Cameron


On 8/18/08 8:31 AM, Al [EMAIL PROTECTED] wrote:

 Run your pattern thru preg_quote() prior to using it in your preg_replace().
 Don't backslash 
 anything yourself, let preg_quote() do it.
 
 Cameron B. Prince wrote:
 Hello,
 
 I¹ve run into a problem with a regex and need help determining if this is my
 mistake or a bug. The regex is for inserting a SID into every link in the
 buffer before it¹s flushed, but only when each link doesn¹t already have a
 SID.
 
 An example of the code is here:
 
 $buffer = 
 preg_replace('/http\:\/\/www\.domain\.com([\/\w\.-]*)(?!\?PHPSESSID\=2u0cca
 ffoh6jaeapkke35qpp87;?)/',
 'http://www.domain.com$1?PHPSESSID=t9gksvpdcuobsnqt98qloe6lg4;', $buffer);
 
 The code works correctly in most cases except when a SID already exists and
 there is a path after the .com such as:
 
 http://www.domain.com/path1/path2.php?PHPSESSID=2u0ccaffoh6jaeapkke35qpp87;
 
 When this URL is processed by the regex, it becomes:
 
 http://www.domain.com/path1/path2.ph?PHPSESSID=t9gksvpdcuobsnqt98qloe6lg4;p?
 PHPSESSID=2u0ccaffoh6jaeapkke35qpp87;
 
 
 So the problem is the regex not only falsely matches, it's inserting the SID
 in between 2nd and 3rd letters of the extension.
 
 You can see the code in action here:
 
 http://kottmann.com/test.php
 
 The full source for the test code is also available when viewing the source
 of this page.
 
 I've tested this on PHP v5.1.6 and PHP v5.2.6.
 
 TIA,
 Cameron
 
 
 
 
 
 
 



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Negative Look Ahead Regex - Code Mistake or Bug?

2008-08-17 Thread Cameron B. Prince
Hello,

I¹ve run into a problem with a regex and need help determining if this is my
mistake or a bug. The regex is for inserting a SID into every link in the
buffer before it¹s flushed, but only when each link doesn¹t already have a
SID.

An example of the code is here:

$buffer = 
preg_replace('/http\:\/\/www\.domain\.com([\/\w\.-]*)(?!\?PHPSESSID\=2u0cca
ffoh6jaeapkke35qpp87;?)/',
'http://www.domain.com$1?PHPSESSID=t9gksvpdcuobsnqt98qloe6lg4;', $buffer);

The code works correctly in most cases except when a SID already exists and
there is a path after the .com such as:

http://www.domain.com/path1/path2.php?PHPSESSID=2u0ccaffoh6jaeapkke35qpp87;

When this URL is processed by the regex, it becomes:

http://www.domain.com/path1/path2.ph?PHPSESSID=t9gksvpdcuobsnqt98qloe6lg4;p?
PHPSESSID=2u0ccaffoh6jaeapkke35qpp87;


So the problem is the regex not only falsely matches, it's inserting the SID
in between 2nd and 3rd letters of the extension.

You can see the code in action here:

http://kottmann.com/test.php

The full source for the test code is also available when viewing the source
of this page.

I've tested this on PHP v5.1.6 and PHP v5.2.6.

TIA,
Cameron








--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Negative Look Ahead Regex - Code Mistake or Bug?

2008-08-17 Thread Cameron B. Prince
Hi Ash,

 As far as I can tell, you have an error in your syntax. You're using a -
 (hyphen) character in the first match, but Regex uses this to define a
 range of characters. It seems that if you don't escape it, the whole
 thing behaves a little strangely. For example, using your URL as the
 source string:
 
 http://www.domain.com/path1/path2.php?PHPSESSID=2u0ccaffoh6jaeapkke35qpp87;
 
 This regular expression
 /^(http:\/\/www\.domain\.com([\/\.\-\_\w]*))/
 matches
 [!MATCH!]?PHPSESSID=2u0ccaffoh6jaeapkke35qpp87;

Thanks for your reply. I updated the code at the URL below adding your
suggestion, but it doesn't seem to make a difference.

http://www.kottmann.com/test.php

Even if there is a problem with the meta characters, I don't understand how
or why the SID would be added in between the .ph and the p in the extension.
It's just totally bizarre to me and is why I'm wondering if it's a bug. (See
links 1  8 by viewing source at the link above)

You or anyone have other ideas to try?

Thanks,
Cameron



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] PHP and Apache

2008-06-23 Thread R B
Hello,

I´m developing a PHP system that needs one of these lines in the .htaccess,
depending of the server configuration:

AddHandler application/x-httpd-php .xyz
or

AddHandler application/x-httpd-php4 .xyz

or

AddHandler application/x-httpd-php5 .xyz

How can i detect on the fly which line i have to use?


Re: [PHP] PHP and Apache

2008-06-23 Thread R B
The people that will install this system, don´t have programming knowledge.
They have a website, buy don´t have knowledge of configurations.

If i add all the lines, it don´t works, unless the last line is the correct
for that particular server.






 Why not just read the manual and add the appropriate line for your version
 of PHP ?

 Makes the most sense.

 Or add all the lines.

 Pretty much an Apache list question though.

 Wolf



[PHP] Another way to send variables

2008-06-13 Thread R B
Hello.

I have this script (script1.php):

?php
 $a = Hello;
 header(Location: script2.php);
?

I need to send the $a variable to script2.php, but i don´t want to send it
in the url.

Is there another method?

Maybe with another header instruction without putting in the url?

Thank you.


[PHP] Memory cache problem

2008-06-13 Thread R B
Hello,

I´m making a video manual, but i don´t want to be cached in the client
machine.

I make a script like this:

?php
 header(Expires: Mon, 26 Jul 1997 05:00:00 GMT);
 header(Last-Modified:  . gmdate(D, d M Y H:i:s) .  GMT);
 header(Cache-Control: no-store, no-cache, must-revalidate);
 header(Cache-Control: post-check=0, pre-check=0, false);
 header(Pragma: no-cache);

 readfile($video_name);
?

With Internet explorer the script works fine. But Firefox have two types of
cache: Memory cache and disk cache.
With firefox disk cache, the script works fine, because don´t appears in the
disk cache, but i have problems with the Memory cache.

How can i avoid to appears in the firefox memory cache?


Re: [PHP] Memory cache problem

2008-06-13 Thread R B
The video manual it´s not for me, it´s for a customer and he don´t want to
be cached in the client machine...

If you put in firefoxin the url area:   about:cache , firefox display the
Memory cache and the Disk cache...

I search in both caches, and the video appears in the memory cache.

On Fri, Jun 13, 2008 at 4:17 PM, Stut [EMAIL PROTECTED] wrote:

  On 13 Jun 2008, at 23:12, R B wrote:

 I´m making a video manual, but i don´t want to be cached in the client
 machine.

 I make a script like this:

 ?php
 header(Expires: Mon, 26 Jul 1997 05:00:00 GMT);
 header(Last-Modified:  . gmdate(D, d M Y H:i:s) .  GMT);
 header(Cache-Control: no-store, no-cache, must-revalidate);
 header(Cache-Control: post-check=0, pre-check=0, false);
 header(Pragma: no-cache);

 readfile($video_name);
 ?

 With Internet explorer the script works fine. But Firefox have two types
 of
 cache: Memory cache and disk cache.
 With firefox disk cache, the script works fine, because don´t appears in
 the
 disk cache, but i have problems with the Memory cache.

 How can i avoid to appears in the firefox memory cache?


 Why don't you want it cached?

 What makes you think it's cached in memory on FF?

 -Stut

 --
 http://stut.net/


[PHP] PHP with C++

2008-06-09 Thread R B
Hi,
I have a C++ script containing the function hello(x, y, z)

I want to access this C++ function from PHP, and output with PHP the return
information.

How can i do this?

Thank you.


Re: [PHP] Developing existing java portal in php

2008-04-14 Thread Sangamesh B
Hi,

  I know that php is an interpreter, like shell. It won't produce any
object or executable file.

  Now the portal has to be developed such that the php source shouldn't
be visible in the product. Means the product should be able to produced in
binary format.

Is it possible to embed php code in any other programming language such
as C?

Or there any other tool which can store/embed the php script in binary
format?

Has anybody has implemented this kind of stuff?

   Is it possible? Please let me know at the earliest..

Thanks for your guidance,

Sangamesh

On Sat, Mar 29, 2008 at 12:10 PM, Sangamesh B [EMAIL PROTECTED] wrote:

 Thanks for the reply.

 Can it be done by just using php + html or perl + html.

 Also, May I know a beginners document to start working on html, php and
 perl.

 Thanks,
 Sangamesh



 On Fri, Mar 28, 2008 at 1:50 AM, ganu [EMAIL PROTECTED] wrote:

 
 
  On Thu, Mar 27, 2008 at 7:52 AM, Sangamesh B [EMAIL PROTECTED]
  wrote:
 
   Hi all,
  
   Here is one web portal product which is already developed using java
   tools.
   I don't know java, php or perl. But I can learn php quickly compared
   to
   java.
 
 
  Learning PHP,Perl is very easy as compare to Java.
 
  
  
   My question is: Is it possible to develop such web portal using php 
   html?
 
 
  Yea, is possible.
 
  
  
   Let me explain how the java portal/product works:
  
   The user logs in to the portal with his user name and password thru
   web
   browser by using a public ip or for example say xyz-portal.com
  
   The user name and password are the user names of the  Linux OS. So
   username
   authentication is required.
  
   In the next page, the user accesses  the preinstalled applications (
   these
   are C or Fortran apps) and submits the job.
   While submitting the job, he is allowed to give the command line
   options and
   input file. The input files are present in his home directory. These
   files
   should be listed in combo box.
  
   It doesn't mean that, all installed apps in linux must be listed in
   the
   portal. There should be a mechanism to add a particular application to
   the
   portal ( part of administrator's work). And all apps which are to be
   displayed in portal are in a different dir, say /usr/local/bin.
  
   This portal is totally based on the server. i.e. The user accesses the
   portal and submits his application job from client system to run the
   job in
   the server. The client system uses only web browser. So other software
   can
   not be used to do this.
  
   Regarding php, I know that linux commands can be bypassed thru php.
  
   So can any one tell me whether this can be done using php with the
   above
   mentioned conditions/facilities?
  
  
   Thanks  Regards,
   Sangamesh
 
 
  I think you can do all front end things in PHP and html and you can do
  all system calls with Perl.
  Perl will be fast and easy for all linux things.
 
  you can refer this for calling Perl from PHP page -
  http://devzone.zend.com/node/view/id/1712
 
 
  ---





[PHP] pecl/PAM

2008-04-02 Thread Kyle B

Hi,

I've recently installed the pecl/PAM module, however, it appears that it 
is not functioning as it should. It's returning a value of 1, even if 
the username and password are completely incorrect.


This is the file I'm using to test:
development# cat test.php
?php
if(pam_auth('sfdfgfdu', '0blah0') == 1) {
echo YAY!;
} else {
echo BOO!;
}
?

I've created the /etc/pam.d/php file using pam_unix.so as the library, 
and added pam.servicename = php; to the top of my php.ini file. I'm on 
FreeBSD 7.0-RELEASE, PHP 5.2.5, and Apache 2.2.


Any assistance would be appreciated.

Thanks!

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Developing existing java portal in php

2008-03-29 Thread Sangamesh B
Thanks for the reply.

Can it be done by just using php + html or perl + html.

Also, May I know a beginners document to start working on html, php and
perl.

Thanks,
Sangamesh


On Fri, Mar 28, 2008 at 1:50 AM, ganu [EMAIL PROTECTED] wrote:



 On Thu, Mar 27, 2008 at 7:52 AM, Sangamesh B [EMAIL PROTECTED] wrote:

  Hi all,
 
  Here is one web portal product which is already developed using java
  tools.
  I don't know java, php or perl. But I can learn php quickly compared to
  java.


 Learning PHP,Perl is very easy as compare to Java.

 
 
  My question is: Is it possible to develop such web portal using php 
  html?


 Yea, is possible.

 
 
  Let me explain how the java portal/product works:
 
  The user logs in to the portal with his user name and password thru web
  browser by using a public ip or for example say xyz-portal.com
 
  The user name and password are the user names of the  Linux OS. So
  username
  authentication is required.
 
  In the next page, the user accesses  the preinstalled applications (
  these
  are C or Fortran apps) and submits the job.
  While submitting the job, he is allowed to give the command line options
  and
  input file. The input files are present in his home directory. These
  files
  should be listed in combo box.
 
  It doesn't mean that, all installed apps in linux must be listed in the
  portal. There should be a mechanism to add a particular application to
  the
  portal ( part of administrator's work). And all apps which are to be
  displayed in portal are in a different dir, say /usr/local/bin.
 
  This portal is totally based on the server. i.e. The user accesses the
  portal and submits his application job from client system to run the job
  in
  the server. The client system uses only web browser. So other software
  can
  not be used to do this.
 
  Regarding php, I know that linux commands can be bypassed thru php.
 
  So can any one tell me whether this can be done using php with the above
  mentioned conditions/facilities?
 
 
  Thanks  Regards,
  Sangamesh


 I think you can do all front end things in PHP and html and you can do all
 system calls with Perl.
 Perl will be fast and easy for all linux things.

 you can refer this for calling Perl from PHP page -
 http://devzone.zend.com/node/view/id/1712


 ---


[PHP] Developing existing java portal in php

2008-03-27 Thread Sangamesh B
Hi all,

Here is one web portal product which is already developed using java tools.
I don't know java, php or perl. But I can learn php quickly compared to
java.

My question is: Is it possible to develop such web portal using php  html?

Let me explain how the java portal/product works:

The user logs in to the portal with his user name and password thru web
browser by using a public ip or for example say xyz-portal.com

The user name and password are the user names of the  Linux OS. So username
authentication is required.

In the next page, the user accesses  the preinstalled applications ( these
are C or Fortran apps) and submits the job.
While submitting the job, he is allowed to give the command line options and
input file. The input files are present in his home directory. These files
should be listed in combo box.

It doesn't mean that, all installed apps in linux must be listed in the
portal. There should be a mechanism to add a particular application to the
portal ( part of administrator's work). And all apps which are to be
displayed in portal are in a different dir, say /usr/local/bin.

This portal is totally based on the server. i.e. The user accesses the
portal and submits his application job from client system to run the job in
the server. The client system uses only web browser. So other software can
not be used to do this.

Regarding php, I know that linux commands can be bypassed thru php.

So can any one tell me whether this can be done using php with the above
mentioned conditions/facilities?


Thanks  Regards,
Sangamesh


[PHP] query not working properly

2007-07-26 Thread Joey B

Hi everyone,
I'mt trying to do the below query which itself works correctly, but when I
add a order by statement just bombs.

   $query = select * from articles where ( {$now} BETWEEN startdate
AND enddate) and categoryid = 1 limit 0,3;



$query = select * from articles order by startdate asc where (
{$now} BETWEEN startdate AND enddate) and categoryid = 1 limit 0,3;

This one just doesn't work, can you tell me what I have done wrong??



Thanks


RE: [PHP] Currency Exchange Database?

2007-06-28 Thread Andy B.
You could have a look at the Euro foreign exchange reference rates rom the
European Central Bank.

They also provide a regularly updated XML file:

http://www.ecb.int/stats/exchange/eurofxref/html/index.en.html

Hope it helps...


Andy

-Original Message-
From: Tom Ray [Lists] [mailto:[EMAIL PROTECTED] 
Sent: Friday, June 29, 2007 02:45
To: php-general@lists.php.net
Subject: [PHP] Currency Exchange Database?

I have a client that's looking to do auto conversions of currency on 
their reservation payment form. No big deal, I can that part down. 
However, exchange rates change on a minute to minute basis and they want 
the program to automatically know the current rates. Is there an online 
database or a way I can tap into a database that has that information?

Any help would be appreciated.

Thanks.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] mail() only working with php-cli

2007-05-07 Thread Andy B.
Thanks a lot for helping.

I found the problem while trying so su to the www-user, where I was
immediately told /bin/bash: permission denied. Rather unusual...

The owner of the server has mistakenly changed many permissions in the
/(s)bin, /usr/(s)bin directories, so that most of the files were chmod 700
instead of 755. The suid flags were also gone.

It took me a while to rebuild the permissions, but after that mail() worked
as it should.

That being said, it really would have saved me a lot of time and anger if
mail() were a little bit more verbose in situations like that. A simple
error message like /usr/sbin/sendmail: permission denied would have made
it.

Regards,


Andy

-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 08, 2007 01:01
To: Andy B.
Cc: php-general@lists.php.net
Subject: Re: [PHP] mail() only working with php-cli

On Sat, May 5, 2007 3:53 pm, Andy B. wrote:
 Is there any way to debug the mail() function within PHP4 or PHP5?

Check Apache error logs.
Check sendmail (or whatever) error logs.

 The following code is not working when called from a browser, but it
 does
 work from the command line:

Often points to a paths/permissions problem...

Can you 'su' to the Apache/PHP User and *then* run sendmail on command
line?

 php and php-cli use the same php.ini file. Php via Apache is launched
 as a
 module, NOT as CGI!

 sendmail_path is correctly set to /usr/sbin/sendmail -t -i

You put quotes around that in  php.ini, right?...

Cuz it needs the quotes, last I checked:

sendmail_path = /usr/sbin/sendmail -t -i

 the /var/log/mail.log only shows activity when I try my code via
 command
 line, so my best guess is that sendmail is never reached when run from
 the
 browser.

 I went a little deeper and modified the sendmail_path to /tmp/test.sh,
 which
 contains:

 #!/bin/bash
 echo I was used!!  /tmp/test.log

 (chmod 777 /tmp/test.sh)

 Again I tried my script from the web and from the command line. Same
 result... command line is fine and generates the test.log file. In the
 browser no log file is created.

Hmmm.  That blows away the quotes as an issue, at least until you got
back to using multi-word path...

Was sendmail installed when you compiled PHP, so PHP knows that it
should be able to use it?
Or, the short version of that question:
Does ?php phpinfo();? show you 'mail' as an installed extension?

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] mail() only working with php-cli

2007-05-06 Thread Andy B.
Oliver,

Yes I also analyzed the log files from apache, but all they are telling me
is that I am accesing the file mail.php with my browser. Error.log stays
empty.

I wish that it were possible to reproduce an error when accessing mail()
that would somewhat look like this:

cannot access /usr/sbin/sendmail: permission denied, then at least I know
what needs to be done. However I doubt that my php configuration is
forbidden to access this file.


Andy


-Original Message-
From: Oliver Block [mailto:[EMAIL PROTECTED] 
Sent: Saturday, May 05, 2007 23:58
To: php-general@lists.php.net
Cc: Andy B.
Subject: Re: [PHP] mail() only working with php-cli

Hello Andy,

did you take a look into the apache log files?

Regards,

Oliver


Am Samstag, 5. Mai 2007 22:53 schrieb Andy B.:
 Is there any way to debug the mail() function within PHP4 or PHP5?

 The following code is not working when called from a browser, but it does
 work from the command line:

 ?php
 $to  = '[EMAIL PROTECTED]';
 $subject = 'the subject';
 $message = 'hello...';
 $headers = 'From: [EMAIL PROTECTED]' . \r\n .
 'Reply-To: [EMAIL PROTECTED]' . \r\n .
 'X-Mailer: PHP/' . phpversion();

 if(mail($to, $subject, $message, $headers))
 echo IT WORKED;
 else
 echo DAMN!!!;
 ?


 php and php-cli use the same php.ini file. Php via Apache is launched as a
 module, NOT as CGI!

 sendmail_path is correctly set to /usr/sbin/sendmail -t -i

 the /var/log/mail.log only shows activity when I try my code via command
 line, so my best guess is that sendmail is never reached when run from the
 browser.

 I went a little deeper and modified the sendmail_path to /tmp/test.sh,
 which contains:

 #!/bin/bash
 echo I was used!!  /tmp/test.log

 (chmod 777 /tmp/test.sh)

 Again I tried my script from the web and from the command line. Same
 result... command line is fine and generates the test.log file. In the
 browser no log file is created.

 I have already made numerous LAMP installations, but I never had this kind
 of mail() issue. This installation is quite simple: standard Apache 2.0
 with php5, php5-mysql, php5-gd, ... This makes it even more frustrating
:-(

 What am I missing?

 Thanks a lot!!

 
 Andy

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] mail() only working with php-cli

2007-05-05 Thread Andy B.
Is there any way to debug the mail() function within PHP4 or PHP5?

The following code is not working when called from a browser, but it does
work from the command line:

?php
$to  = '[EMAIL PROTECTED]';
$subject = 'the subject';
$message = 'hello...';
$headers = 'From: [EMAIL PROTECTED]' . \r\n .
'Reply-To: [EMAIL PROTECTED]' . \r\n .
'X-Mailer: PHP/' . phpversion();

if(mail($to, $subject, $message, $headers))
echo IT WORKED;
else
echo DAMN!!!;
?


php and php-cli use the same php.ini file. Php via Apache is launched as a
module, NOT as CGI!

sendmail_path is correctly set to /usr/sbin/sendmail -t -i

the /var/log/mail.log only shows activity when I try my code via command
line, so my best guess is that sendmail is never reached when run from the
browser.

I went a little deeper and modified the sendmail_path to /tmp/test.sh, which
contains:

#!/bin/bash
echo I was used!!  /tmp/test.log

(chmod 777 /tmp/test.sh)

Again I tried my script from the web and from the command line. Same
result... command line is fine and generates the test.log file. In the
browser no log file is created.

I have already made numerous LAMP installations, but I never had this kind
of mail() issue. This installation is quite simple: standard Apache 2.0 with
php5, php5-mysql, php5-gd, ... This makes it even more frustrating :-(

What am I missing?

Thanks a lot!!


Andy

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] mail() only working with php-cli

2007-05-05 Thread Andy B.
Yes, it's the same build.

I am running php5 on a debian distribution that has been installed via
apt-get.

Details:

--
CLI php.ini = /etc/php5/cli/php.ini

PHP 5.2.0-8+etch3 (cli) (built: Apr 29 2007 10:42:07) 
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2006 Zend Technologies
--

--
APACHE php.ini = = /etc/php5/apache2/php.ini

PHP Version 5.2.0-8+etch3 

System  Linux A011 2.6.21 #1 SMP Fri Apr 27 22:50:50 CEST 2007 i686  
Build Date  Apr 29 2007 10:24:27  
Server API  Apache 2.0 Handler  
Virtual Directory Support  disabled  
Configuration File (php.ini) Path  /etc/php5/apache2/php.ini  
--


Both are exactly the same, as I copied the CLI version into the Apache
Version. Of course I first tested with the original Apache php.ini before
overwriting it with the CLI version.

Unfortunately error Reporting does not help. I've already tested with E_ALL
and also dumping errors/warnings into log files...



Andy

-Original Message-
From: Tijnema ! [mailto:[EMAIL PROTECTED] 
Sent: Saturday, May 05, 2007 23:58
To: Andy B.
Cc: php-general@lists.php.net
Subject: Re: [PHP] mail() only working with php-cli


Are you sure that the PHP CLI and PHP-module are exactly the same build?
And you could try to set error reporting level to E_ALL, maybe there's
a warning generated that's hidden now because of a lower reporting
level.

Tijnema

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Text Editor for Windows?

2007-02-08 Thread Alexandre B.

u can try PSPad, a freeware code editor (kind of ultraedit but free)
http://www.pspad.com/
ALexandre B

On 2/8/07, Andrei [EMAIL PROTECTED] wrote:



Lots of ppl would tell u lots of different php editors. I personally
use editplus2 bcuz it's very light and has syntax hightlighting on php
code and html code in same time and other bla bla features. And I use it
on linux too with wine.
But anyway you will have to try them yourself to tell this is the
one for u.

Andy

Stephen wrote:
 I am finding that notepad is lacking when correcting syntax errors in my
php code. No line numbers.

 What can people recommend for use under Windows?

 Thanks
 Stephen

 .



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Problem with copy() function

2007-01-05 Thread R B

Hi,

I'm trying to copy a file like this:

copy(home/xxx/public_html/yyy/zzz/index.php,
home/xxx/public_html/yyy/www/index.php)

and have this error:

*Warning*: Wrong parameter count for copy() in */home/.*

Someone can help me please?

Thanks,


[PHP] Recomended host

2006-12-18 Thread R B

Hello.
I'm looking for a host to put my website.
I was looking godaddy.com, but i read in phplist forum that godaddy have
limitations in the number of mail to send per day.

Someone can recomend me a good host provider, with good stability, good
support, good features, and no limitation in the use of a list of
members...?

Thanks


Re: [PHP] how to build env to develop php extension

2006-09-18 Thread Michael B Allen
On Mon, 18 Sep 2006 15:53:21 +0800
junhui bai [EMAIL PROTECTED] wrote:

 
 There are a lot of documentation to tell you how to create php extension on
 unix platform . For example, using tool phpize to create skeleton and son.
 But I can't find information on how to create php extension on window
 platform. 
 
 I installed php on window xp flatform from both source code and binary
 package, but I can't find the tool phpize on window hosts. 
 
 So could you please tell me how to create php extension on window platform?
 Thank you very much.

I don't have a definitive answer for you but there's not much to the
bare skeleton of an extension. Just copy one of the existing ones and
start from that. That's what I did (although I didn't use Windows).

Mike

-- 
Michael B Allen
PHP Active Directory SSO
http://www.ioplex.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Odd PHP memory issue

2006-09-15 Thread Michael B Allen
On Fri, 15 Sep 2006 08:42:26 -0700
Matthew H. North [EMAIL PROTECTED] wrote:

 6) Resources (think database resources) are automatically freed by
 garbage collection when there are no more references to them

Resources can be persistent. Try traversing a small tree and print
memory usage after each of several executions. If the memory is increasing
each time there is a memory leak in the extension. I doubt that is the
problem but it's a good test because it will show you with certainty
that data is in fact being released when the script exits. Then I would
scale down your test. Create a db connection and close it printing
memory usage along the way to make sure all memory is restored within
the script execution. If that doesn't work there are memory references
hanging around *somewhere*.

Mike

-- 
Michael B Allen
PHP Active Directory SSO
http://www.ioplex.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] copy, open, or manipulate an image hosted in a https server

2006-09-12 Thread R B

Hello,

I need to copy, open or manipulate a gif images that is hosted in a https
server.

But when i try to do this, i recive a warning like this:

*Warning*: imagecreatefromgif(https:///aaa.gif): failed to open stream:
Invalid argument in .

I recive a similar message if i use:

copy(https:///aaa.gif,' bla bla bla ');

fopen (https:///aaa.gif, );

How can i resolve this problem and use this image?

Thanks,

RB


Re: [PHP] copy, open, or manipulate an image hosted in a https server

2006-09-12 Thread R B

It's not a syntaxis problem.

On 9/12/06, Robert Cummings [EMAIL PROTECTED] wrote:


On Tue, 2006-09-12 at 12:27 -0600, R B wrote:
 Hello,

 I need to copy, open or manipulate a gif images that is hosted in a
https
 server.

 But when i try to do this, i recive a warning like this:

 *Warning*: imagecreatefromgif(https:///aaa.gif): failed to open
stream:
 Invalid argument in .

 I recive a similar message if i use:

 copy(https:///aaa.gif,' bla bla bla ');

 fopen (https:///aaa.gif, );

 How can i resolve this problem and use this image?

Ummm, you're missing quotes around the URL portion of the argument.

Cheers,
Rob.
--
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'




Re: [PHP] copy, open, or manipulate an image hosted in a https server

2006-09-12 Thread R B

I think it's a security https problem.

I was reading that with IIS, you can't use fopen in a https server... I
think i have this problem also with copy...

Some ideas?




On 9/12/06, R B [EMAIL PROTECTED] wrote:


It's not a syntaxis problem.


On 9/12/06, Robert Cummings [EMAIL PROTECTED] wrote:

 On Tue, 2006-09-12 at 12:27 -0600, R B wrote:
  Hello,
 
  I need to copy, open or manipulate a gif images that is hosted in a
 https
  server.
 
  But when i try to do this, i recive a warning like this:
 
  *Warning*: imagecreatefromgif(https:///aaa.gif): failed to open
 stream:
  Invalid argument in .
 
  I recive a similar message if i use:
 
  copy(https:///aaa.gif,' bla bla bla ');
 
  fopen (https:///aaa.gif, );
 
  How can i resolve this problem and use this image?

 Ummm, you're missing quotes around the URL portion of the argument.

 Cheers,
 Rob.
 --
 ..
 | InterJinn Application Framework - http://www.interjinn.com |
 ::
 | An application and templating framework for PHP. Boasting  |
 | a powerful, scalable system for accessing system services  |
 | such as forms, properties, sessions, and caches. InterJinn |
 | also provides an extremely flexible architecture for   |
 | creating re-usable components quickly and easily.  |
 `'





Re: [PHP] Filter MS Word Garbage

2006-09-12 Thread Michael B Allen
On Tue, 12 Sep 2006 15:02:08 -0700
Kevin Murphy [EMAIL PROTECTED] wrote:

 I have a web form where trusted people will be inputing information  
 that they usually copy/paste out of MS Word. While the people are  
 trusted... MS Word isn't. I keep getting garbage characters in there,  
 usually associated with Smart Quotes. If I take the content out of  
 the DB, throw it into BBEdit and use the convert to ASCII command  
 that solves the problem.

Iterate of each character (byte) and use chr(b) to get the numeric
value. If that value is less than 128 the character is ASCII. Otherwise
it is not. Based on that, it would be very easy to write a function to
strip all non-ASCII characters.

However, you might consider giving people back exactly what they
submitted. Meaning when storing the fragment use mysql_escape_string()
or equivalent and then when the HTML field use htmlentities() to escape
any special HTML character. That might preserve formatting information
embedded in the clipboard fragment (if that's something you want).

Mike

-- 
Michael B Allen
PHP Active Directory SSO
http://www.ioplex.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] substr and UTF-8

2006-08-30 Thread Michael B Allen
On Wed, 30 Aug 2006 18:34:20 +0700
Peter Lauri [EMAIL PROTECTED] wrote:

 Hi group,
 
 I want to limit the number of characters that are shown in a script. The
 characters happen to be Thai, and the page is encoded in UTF-8. Everything
 works, except when I want to cut the text (just take start of string).
 
 I do:
 
 echo substr($thaistring, 0, 30);
 
 The beginning of the string works fine, but the last character does mostly
 break. How can I determine the start and end of a character.

The last byte of a UTF-8 character does not have bit 8 set whereas all
preceeding bytes do.

Mike

-- 
Michael B Allen
PHP Active Directory SSO
http://www.ioplex.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] substr and UTF-8

2006-08-30 Thread Michael B Allen
On Wed, 30 Aug 2006 10:08:36 -0400
Michael B Allen [EMAIL PROTECTED] wrote:

 On Wed, 30 Aug 2006 18:34:20 +0700
 Peter Lauri [EMAIL PROTECTED] wrote:
 
  Hi group,
  
  I want to limit the number of characters that are shown in a script. The
  characters happen to be Thai, and the page is encoded in UTF-8. Everything
  works, except when I want to cut the text (just take start of string).
  
  I do:
  
  echo substr($thaistring, 0, 30);
  
  The beginning of the string works fine, but the last character does mostly
  break. How can I determine the start and end of a character.
 
 The last byte of a UTF-8 character does not have bit 8 set whereas all
 preceeding bytes do.

Actually this is false. I don't know what I was thinking. The high bit
will be set in all bytes of a UTF-8 byte sequence. If it's not it's an
ASCII character.

The bytes are actually layed out as follows [1]:

U- ___ U-007F:  0xxx
U-0080 ___ U-07FF:  110x 10xx
U-0800 ___ U-:  1110 10xx 10xx
U-0001 ___ U-001F:  0xxx 10xx 10xx 10xx

So there's no way to tell the last byte of a UTF-8 byte sequence but you
can tell if it's the first byt looking at bits 7 and 8. Specifically,
if bit 8 is not on, the character is ASCII and thus the start of a
new character. Otherwise, if bit 7 is on it's the start of a new UTF-8
byte sequence.

  function is_utf8_start($b) {
  return (($b  0x80) == 0) || ($b  0x40);
  }

Mike

[1] http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8

-- 
Michael B Allen
PHP Active Directory SSO
http://www.ioplex.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] substr and UTF-8

2006-08-30 Thread Michael B Allen
On Wed, 30 Aug 2006 21:46:18 +0700
Peter Lauri [EMAIL PROTECTED] wrote:

   function is_utf8_start($b) {
   return (($b  0x80) == 0) || ($b  0x40);
   }
 [/snip]
 
 :) I think I will go with the mb_substr function, it works for me :)

Yeah, I guess that's the right thing to do. Otherwise, in a year you
won't remember what the cryptic masking is all about.

Mike

-- 
Michael B Allen
PHP Active Directory SSO
http://www.ioplex.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Problems with UTF

2006-08-28 Thread Michael B Allen
On Mon, 28 Aug 2006 15:57:17 -0400
mbneto [EMAIL PROTECTED] wrote:

 Hi,
 
 I have a php based script that is called from a html page via ajax.
 Everything runs fine except when I use characters such as á that ends up
 like A!

A browser will display text according the the charset specified in the
HTTP response Content-Type header. That is usually set by the HTTP server
(e.g. Apache AddDefaultCharset and AddCharset). So I suspect that in
your case, your HTTP server is sending charset=ISO-8859-1 whereas the
content is in fact UTF-8 (when one non-ascii character is rendered as
two or three usually garbled characters it's an indication that UTF-8
is being rendered as some 8 bit codepage like ISO-8859-1).

Note that the charset specified in the META tag within an HTML document
is ignored when served over a network. I'm not certain what the charset
in the META tag is for. I suspect it's for caching or when you open an
HTML file from disk perhaps.

Mike

-- 
Michael B Allen
PHP Active Directory SSO
http://www.ioplex.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Email with pregmatch

2006-08-27 Thread Michael B Allen
On Sun, 27 Aug 2006 20:35:47 +0700
Peter Lauri [EMAIL PROTECTED] wrote:

 Hi,
 
 I am trying to check if an email is an email or not, so I used this that I
 found on the internet:
 
 preg_match(/^([a-zA-Z0-9])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+/,
 $_POST['email']);

This is what I use:

eregi([EMAIL PROTECTED],6}$, $email)

Mike

-- 
Michael B Allen
PHP Active Directory SSO
http://www.ioplex.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHPSESSID used sporatically

2006-08-17 Thread Michael B Allen
On Thu, 17 Aug 2006 14:26:17 +1000
Chris [EMAIL PROTECTED] wrote:

 Michael B Allen wrote:
  On Thu, 17 Aug 2006 12:06:08 +1000
  Chris [EMAIL PROTECTED] wrote:
  
  Michael B Allen wrote:
  Searching through the logs and browsing my site (see sig) I sometimes see
  PHPSESSID is used as opposed to cookies. I know it's not simply that the
  client doesn't support cookies because I can see the same IP transition
  to and from using PHPSESSID. Can someone explain why this is happening?
  Is session.use_trans_sid switched on?
  
  Yes. It is. After reading about it I can't quite see what benifit it
  provides. Should I just turn it off?
 
 It depends on your site.
 
 If you do something like this for a search:
 
snip
 
 I could send someone a url with the sessionid on the end of it, and it 
 won't have to do the bit in the middle, it will be able to jump right to 
 the end (the foreach loop).

I'm not doing anything like that. Sessions are only used to prevent
duplicate form invokations. But my boilerplate code calls session_start
for all .php pages. I suppose I should be more selective to make things
a little more efficient.

But I'm still confuse.

Why aren't cookies alone sufficient to satisfy the session code?

Is PHPSESSID used because of some kind of transition from a PHP page
that calls session_start to a page that does not?

Does session.use_trans_sid simply enable the PHPSESSID in URLs or does
it have a deeper semantic?

The URLs for the tabs my site are not dynamically generated and yet
they're being rewritten. Is that PHP or Apache doing that?

Mike

-- 
Michael B Allen
PHP Active Directory SSO
http://www.ioplex.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHPSESSID used sporatically

2006-08-17 Thread Michael B Allen
On Thu, 17 Aug 2006 12:06:08 +1000
Chris [EMAIL PROTECTED] wrote:

 Michael B Allen wrote:
  Searching through the logs and browsing my site (see sig) I sometimes see
  PHPSESSID is used as opposed to cookies. I know it's not simply that the
  client doesn't support cookies because I can see the same IP transition
  to and from using PHPSESSID. Can someone explain why this is happening?
 
 Is session.use_trans_sid switched on?

Yes. It is. After reading about it I can't quite see what benifit it
provides. Should I just turn it off?

Mike

-- 
Michael B Allen
PHP Active Directory SSO
http://www.ioplex.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] active directory and PHP

2006-08-17 Thread Michael B Allen
Hi Alain,

PlexSSO is by far the best and easiest solution available for PHP SSO
with Active Directory. We provide:

  o Windows Integerated Authentication (WIA)
  o Script level access to user info like username, home drive, etc.
  o Script level access control using windows group names

Someone else mentioned LDAP but I don't know why because it doesn't
provide authentication [1]. For authorization LDAP doesn't automatically
perform proper group expansion and is redundant to start with since the
Kerberos ticket has the fully expanded groups in it already.

Our authorization code very easy to use. An access check looks like:

  ?php
  if (plexsso_is_memberof(FOONET\\Managers)) {
  echo You're a manager.;
  }
  ?

None of the mod_authz_* Apache modules can do this. These checks are
also very fast. Once the SIDs for the groups used in your scripts are
cached they're instantaneous.

Check us out. It's very affordable (free for 25 users and 25 groups),
we're adding major features in our next release, and we bring serious
SSO experience to the table.

   http://www.ioplex.com/

Mike

[1] You could proxy the user's username and password to ldap_sasl_bind but
aside from being a hack it's not SSO and doesn't scale because it requires
communication with the DC whereas Kerberos does not. And it's insecure
because you have to cache the users credentials in the user's session.

-- 
Michael B Allen
PHP Active Directory SSO
http://www.ioplex.com/

On Thu, 17 Aug 2006 12:14:18 +0200
Alain Roger [EMAIL PROTECTED] wrote:

 Hi,
 
 I'm new to PHP, so sorry if my question looks like stupid.
 
 I have a web application which use authorization and authentication process
 to log-in.
 I would like to know if it exists a way to synchronize the authentication
 with our Active Directory domain ?
 Something like a single side-on.
 
 In fact, i want from my web application users to make them remember only
 their login/pwd from Active directory to use my application.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] active directory and PHP

2006-08-17 Thread Michael B Allen
On Thu, 17 Aug 2006 11:54:53 -0500
Ray Hauge [EMAIL PROTECTED] wrote:

  [1] You could proxy the user's username and password to ldap_sasl_bind but
  aside from being a hack it's not SSO and doesn't scale because it requires
  communication with the DC whereas Kerberos does not. And it's insecure
  because you have to cache the users credentials in the user's session.
 
 LDAP can authenticate with Active Directory just fine:
 The question is how secure is it.  You can set up LDAP to use SSL, so that 
 would make it more secure.  Kerberos is more secure than LDAP, and you 
 _could_ set it up so that the browser forwards the ticket on to mod_kerb for 
 authentication, thus not needing a sign-on other than to the domain.  From my 
 experiences that isn't exactly easy to set up though.

I didn't say it wouldn't work but people should understand there
are numerous problems with using LDAP bind functions as some kind of
make-shift authentication serivce.

1) It's insecure. To make it remotely fast enough you would need to store
something in the user's session to prevent excessive communication with AD
in which case if someone were able to get the user's PHPSESSID, a cookie,
or sniff the session id they could gain access to the site (possibly with
the user's credentials if those are stored in the session). And whatever
you do don't use ldap_bind because those credentials are passed in clear
text so a sniffer could collect passwords. At least use ldap_sasl_bind
or do a TLS connection.

2) It's slow. Kerberos does not require communication between the web
server and AD. With LDAP you would need to communicate with AD at least
once for every new session.

Otherwise, yeah it would work.

Mike

-- 
Michael B Allen
PHP Active Directory SSO
http://www.ioplex.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] PHPSESSID used sporatically

2006-08-16 Thread Michael B Allen
Searching through the logs and browsing my site (see sig) I sometimes see
PHPSESSID is used as opposed to cookies. I know it's not simply that the
client doesn't support cookies because I can see the same IP transition
to and from using PHPSESSID. Can someone explain why this is happening?

I'm using PHP 4.

Thanks,
Mike
-- 
Michael B Allen
PHP Active Directory SSO
http://www.ioplex.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Codigo de Captcha en PHP

2006-08-15 Thread Julio B.
Hi Richard, my example is not safe, but already I wrote in the last part of 
my message to Ricardo that, by security, would be necessary to make use of 
session variables, for example, to pass the value of catpcha generated and 
to be able to compare it.

The modification would be like this:

?php
session_start();
$key = strtolower(substr(md5(rand()), 0, 4));
$_SESSION['captcha'] = $key;

 $im = imagecreatetruecolor(40, 20);

 $bg = imagecolorallocate($im, 0, 0, 0);
 $col_text = imagecolorallocate($im, 255, 255, 255);

 imagestring($im, 4, 4, 1, $key, $col_text);

 header('Content-type: image/png');
 imagepng($im);
 imagedestroy($im);

?

And the comparison would be between the value introduced by the user and the 
stored one in the session variable.

Saludos,

Julio Barroso 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Codigo de Captcha en PHP

2006-08-14 Thread Julio B.
Hay muchos y muy variados en Internet. En alguna ocasión he usado el que 
viene en sBlog. Es muy sencillo de implementar y para la mayoría de los 
casos suficiente para evitarnos problemas de spam.

En código es:

?php

 $key = (array_key_exists('k', $_GET)  strlen($_GET['k']) == 4) ? 
$_GET['k'] : strtolower(substr(md5(rand()), 0, 4));

 $im = imagecreatetruecolor(40, 20);

 $bg = imagecolorallocate($im, 0, 0, 0);
 $col_text = imagecolorallocate($im, 255, 255, 255);

 imagestring($im, 4, 4, 1, $key, $col_text);

 header('Content-type: image/png');
 imagepng($im);
 imagedestroy($im);

?

Luego llamas a este archivo desde el que lo necesites.

Te generas el código (en este caso de 4 numeros y letras):

?php   $k = strtolower(substr(md5(mt_rand()), 0, 4)); ?

En el formulario donde lo uses poner un campo oculto como éste:

input type=hidden name=h id=h value=?php echo $k; ? /

Y llamas a la imagen como:

img src=as_img.php?k=?php echo $k; ?  /

Por último, una vez se a enviado el formulario, compruebas que el valor del 
campo oculto h es igual que el escrito por el usuario en el formulario.

Para más seguridad se podrían haber usado variables de sesión para guardar y 
pasar los valores de h, pero eso ya te lo dejo a ti.

Saludos,

Julio Barroso

Ricardo Ríos [EMAIL PROTECTED] escribió en el mensaje 
news:[EMAIL PROTECTED]
| Hola amigos listeros alguien conoce algun codigo libre de un captcha en 
php
| , gracias por sus comentarios.
| 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Problem Loading Extension

2006-08-11 Thread Michael B Allen
On Fri, 11 Aug 2006 17:50:12 -0500
Ray Hauge [EMAIL PROTECTED] wrote:

 Hello everyone,
 
 I successfully compiled PHP 4.4.3 and PHP 5.1.4 today.  I'm having a problem 
 with loading the PDFLib extension (pdflib_php.so).  It works fine in PHP 4, 
 but PHP5 is not loading it.  I do know that I have the file in the correct 
 location (same as the mysql.so file), and when I take out mysql.so, then 
 mysql functions are not available.  I am not sure why this module is not 
 loading.
 
 I checked the error_log, and I didn't get any error messages at all.  STFW 
 didn't give me a whole lot of information.  Anyone have any ideas of where to 
 look to find out why it's not loading?

Was the module compiled for 5? Check the apache error.log. If the .so
can't resolve a symbol or similar, usually that type of error appears in
the apache error log. Also, of course the .so needs to be in the right
location and the php.ini needs the appropriate extension directive.

Mike

-- 
Michael B Allen
PHP Active Directory SSO
http://www.ioplex.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Greek Characters from MySQL to PHP to the Browser: ??????

2006-08-08 Thread Michael B Allen
On Tue, 08 Aug 2006 18:00:29 +0100
Colin Guthrie [EMAIL PROTECTED] wrote:

  - If I copy and paste greek characters from the db table into a string
  in my PHP script, and output that, it works just FINE, without any
  htmlentities() or other functions.
  
  I'm at a loss.  What am I doing wrong?
 
 That I don't know :)
 
 I'm guessing that there may be some setting inbetween the PHP and mysql 
 layer that is mangling things.

Or maybe MySQL needs to be running in the UTF-8 locale. Try mysqldump
to get some text in a file and make sure it's really UTF-8. There are
a number of ways to tell if something is UTF-8. One is to create an
ASCII string with one non-ascii character like 'hêllo' in the db and
then hexdump some mysqldump output. You should see single bytes for the
ASCII characters and then two or more bytes for the non-ascii character.

In general I would say a conversion is taking place somewhere. To fix,
verify what encoding is being used by mysql, the mysql client, PHP,
Apache, and the browser. If any one of those does not clearly output
UTF-8 the chain is broken. Start with MySQL and work your way down.

Mike

BTW: htmlentities has nothing to do with character conversions.

-- 
Michael B Allen
PHP Active Directory SSO
http://www.ioplex.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP Frameworks - Opinion

2006-08-01 Thread Michael B Allen
On Tue, 1 Aug 2006 19:44:28 +0200
Satyam [EMAIL PROTECTED] wrote:

 There is no 'common consensus'  but I am sure you'll be getting lots and 
 lots, I would even say LOTS, of sugestions.

I would be very skeptical of any suggestions because only someone
who tried multiple frameworks would be in a position to say with any
authority that one is better than another. And even then I would still
be skeptical. Compounded by the fact that most fall into the almost
what I need but not quite category (don't they all?) I see no other
option but to try each. Also, reasoning that you will eventually need to
modify it you might as well pick something that is relatively simple and
extensible. Meaning, it doesn't need to be mature. It just needs to be
clearly organized and well thought out. After looking at the source for
a few it should become apparent what techniques are superior to others.

Mike

-- 
Michael B Allen
PHP Extension for SSO w/ Windows Group Authorization
http://www.ioplex.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Return Values Copied? Copied if By Reference?

2006-07-26 Thread Michael B Allen
Is a function return value copied? If the value is an integer I suppose
it is but what about a string or an array? If you pass by reference is
the return value still copied?

For example, is this:

  function foo($arr) {
  $arr[] = bar;
  }

faster than this?

  function foo($arr) {
  $arr[] = bar;
  return $arr; // is this copied?
  }

I'm working on some code that would be called to generate a cell in a
possibly large table and therefore a small difference in performance
may have a significant impact.

Thanks,
Mike

-- 
Michael B Allen
PHP Extension for SSO w/ Windows Group Authorization
http://www.ioplex.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] SQL Result Set - HTML Table Fragment (but Simple)

2006-07-24 Thread Michael B Allen
Anyone have a PHP fragment that just prints a very simple html table
from the contents of a db result set? I don't want phpmyadmin or anything
remotely that complex. I want something that simply extracts the header
info and prints a basic HTML table. It should be about 10 lines of code
I suspect. If so, can you post it?

Mike

-- 
Michael B Allen
PHP Extension for SSO w/ Windows Group Authorization
http://www.ioplex.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] SQL Result Set - HTML Table Fragment (but Simple)

2006-07-24 Thread Michael B Allen
Ok, I've been tinkering a little. This isn't simple but it's not a
lot of code either.

Basically the user supplies an array of cell renderers associated
with column names. Each renderer is a function name that will be called
to modify an array() representing an HTML TD element. The result is
printed to yield an HTML table. I think this is pretty extensible. You
can render columns or individual cells differently depending on the text
or position of the coloumn or cell. You can format numbers and dates,
render buttons, ... whatever you want.

The first column renderer below renders every odd column a light shade
of grey. The second renderer demonstrates formmating a timestamp. The
third renderer colors the background of an individual cell green if the
numeric value is greater than 1000.

I'm a C person myself. Can someone clean this up / improve on it (e.g. how
can I pass parameters to renderers?).

Mike

function db_cr_shade_odd($td, $i) {
if (($i % 2) == 0) { 
$td['style'] = background-color: #c0c0c0;;
} 
return $td;
} 
function db_cr_unix_ts_mdty($td, $i) {
if (isset($td['#text'])) {
$td['#text'] = date(M j, Y g:i a, $td['#text']);
}
return $td;
}
function db_result_print($result, $names, $renderers, $default_renderer) {
echo tr\n;
$i = 0; 
while ($i  mysql_num_fields($result)) {
$meta = mysql_fetch_field($result, $i);
$name = $meta-name;
if (isset($renderers[$name])) {
$renderers[$i] = $renderers[$name];
}
if (isset($names[$name])) {
$name = $names[$name];
}
echo th$name/td\n;
$i++;
}
echo /tr\n;
 
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo tr; 
$i = 0; 
foreach ($row as $str) { 
$td = array('#text' = $str);
if ($default_renderer) {
$td = call_user_func($default_renderer, $td, $i);
}   
if (isset($renderers[$i])) {
$td = call_user_func($renderers[$i], $td, $i);
}
echo td;
foreach ($td as $attr = $value) {
if (substr($attr, 0, 1) != '#') {
echo  $attr=\$value\;
}   
}
echo  . $td['#text'] . /td;
$i++;
}
echo /tr\n;
}
}

// EXAMPLE USAGE

// custom renderer specific to invoice report
function db_cr_gt_1000($td, $i) {
$amount = $td['#text'];
if ($amount  1000.00) {
$td['style'] = background-color: #00ff00;;
}
return $td;
}

// pretty column names
$names = array(
invoice_id = ID,
invoice_date = Date, 
invoice_amount = Amount,
invoice_transaction_id = Txn. ID,
invoice_approval_code = App. Code,
invoice_name = Name, 
invoice_email = Email,
invoice_company = Company);
// renderers
$renderers = array(
invoice_date = db_cr_mysql_ts_mdyt,
invoice_amount = db_cr_gt_1000);

echo table class=\d\ border='0' cellpadding=\3\\n;
db_result_print($result, $names, $renderers, db_cr_shade_odd);
echo /table\n;

-- 
Michael B Allen
PHP Extension for SSO w/ Windows Group Authorization
http://www.ioplex.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Different php.ini files for different apache processes on one server

2006-07-18 Thread Michael B Allen
On Tue, 18 Jul 2006 20:44:35 +0200
[EMAIL PROTECTED](Karl Pflästerer) wrote:

 Hi,
 suppose you had several directories a, b and c where in each directory
 you had an Apache http.conf file.  For each directory Apache gets started
 with the http.conf (and other conf files) in that directory.
 
 PHP is used a an Apache module.  How can I have a different php.ini file
 for each different Apache process (a, b and c)? (Apache is 1.3.33 IIRC)

You could chroot each apache instance but I would probably try to modify
the apache module to accept a parameter (and in the process verify that
one does not already exist).

Mike

-- 
Michael B Allen
PHP Extension for SSO w/ Windows Group Authorization
http://www.ioplex.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Separation between View and State (The Back Button)

2006-07-13 Thread Michael B Allen
Let's say you have a Buy button that posts a form to a script that
inserts or increments the quantity of a record in a shopping cart
table. So you click Buy and then Checkout. Now if you hit the Back
button it asks the user if they would like to repost the form. If you
click Ok the db script runs again and now they have two items in the
cart. Not good.

It seems to me this is a fundamental model view controller kind of
problem. There's no seperation between the view and the controller.

What I'm thinking is that I need to give each form a unique token. When
the form is submitted a new token is generate. So if at any time a form
is reposted the token will be invalid and action regarding the form
contents can be igored.

Specifically I'm thinking of somthing like:

?php 
function token_generate() {
return $_SESSION['state_token'] = rand(1,9);
}
function token_matches() {
return isset($_POST['t'])  $_SESSION['state_token'] == $_POST['t'];
}
if (token_matches()) {
// insert or update cart contents
}
?   

h1Shopping Cart/h1
 
form action=cart.php method=post
?php
echo input name=\t\ type=\hidden\ value=\ . token_generate() . 
\/\n;
?

// display cart contents

I don't get to do much web programming so I'm wondering what the PHP
crowd thinks of this method. Can anyone improve on this? Is it fatally
flawed? How would you solve this problem in general?

Thanks,
Mike

-- 
Michael B Allen
PHP Extension for SSO w/ Windows Group Authorization
http://www.ioplex.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Separation between View and State (The Back Button)

2006-07-13 Thread Michael B Allen
On Thu, 13 Jul 2006 14:41:21 -0400
Jim Moseby [EMAIL PROTECTED] wrote:

  
  Let's say you have a Buy button that posts a form to a script that
  inserts or increments the quantity of a record in a shopping cart
  table. So you click Buy and then Checkout. Now if you hit the Back
  button it asks the user if they would like to repost the form. If you
  click Ok the db script runs again and now they have two items in the
  cart. Not good.
  
 ::snip::
 
 Someone posted here an elegant way of handling that, but I can't remember
 who or the specifics of how.  But, IIRC, it involved a header you can send
 that keeps the page from being included in the browser history.  So when the
 user hits 'Back', it skips the processing page and takes them back to the
 form page.

Actually what would be even better is if there were a header that
indicated the form data should NOT be reposted on back or reload. Anyone
heard of such a thing?

Mike

-- 
Michael B Allen
PHP Extension for SSO w/ Windows Group Authorization
http://www.ioplex.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Debugging Log

2006-07-12 Thread Michael B Allen
What is the standard method of logging debug info? Should I just fopen
a file for append and write the message or is there a facility provided?

Mike

-- 
Michael B Allen
PHP Extension for SSO w/ Windows Group Authorization
http://www.ioplex.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Debugging Log

2006-07-12 Thread Michael B Allen
On Wed, 12 Jul 2006 19:13:53 +0100
Stut [EMAIL PROTECTED] wrote:

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1
 
 Michael B Allen wrote:
  What is the standard method of logging debug info? Should I just fopen
  a file for append and write the message or is there a facility provided?
 
 http://php.net/syslog or use a file. There are also various JS-based
 solutions floating around.

I don't think I want to write boring CC failures to syslog. And error_log
doesn't write a timestamp. But I guess this isn't rocket surgery. I
think I can figure out how to maybe prefix error_log entries with a TS.

Thanks,
Mike

-- 
Michael B Allen
PHP Extension for SSO w/ Windows Group Authorization
http://www.ioplex.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Debugging Log

2006-07-12 Thread Michael B Allen
On Wed, 12 Jul 2006 21:13:31 +0100
Stut [EMAIL PROTECTED] wrote:

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1
 
 Michael B Allen wrote:
  On Wed, 12 Jul 2006 19:13:53 +0100
  Stut [EMAIL PROTECTED] wrote:
  Michael B Allen wrote:
  What is the standard method of logging debug info? Should I just fopen
  a file for append and write the message or is there a facility provided?
  http://php.net/syslog or use a file. There are also various JS-based
  solutions floating around.
  
  I don't think I want to write boring CC failures to syslog. And error_log
  doesn't write a timestamp. But I guess this isn't rocket surgery. I
  think I can figure out how to maybe prefix error_log entries with a TS.
 
 So polluting the PHP error log is better than directing it to a log file
 via the syslog facility? Your choice, but remember that syslog is much
 more than just one log. If that's a revelation to you I suggest some
 RTFM is needed before dismissing the option.

Thanks for the tip dipshit.

-- 
Michael B Allen
PHP Extension for SSO w/ Windows Group Authorization
http://www.ioplex.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Debugging Log

2006-07-12 Thread Michael B Allen
On Wed, 12 Jul 2006 22:44:23 +0100
Stut [EMAIL PROTECTED] wrote:

 Michael B Allen wrote:
  Thanks for the tip dipshit.
 
 Maybe I'm in a sensitive mood, but that was uncalled for. Michael, meet
 /dev/null, I hope you live happily ever after.

Oh, no. What am I going to do now? You're like The Man on this
list. I'll never figure out how to write to a logfile now. I might as
well just give up and use VB or something.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] List of Restricted Countries to Leave Out of Credit Card Form?

2006-07-11 Thread Michael B Allen
For my credit card form I provide the user with a list of countries. I
suppose these are ISO country codes? For the US is there an official
list of countries with which I'm not supposed to do business with? Will
Authorize.Net catch those transactions?

Thanks,
Mike

-- 
Michael B Allen
PHP Extension for SSO w/ Windows Group Authorization
http://www.ioplex.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Shopping Carts

2006-07-08 Thread Michael B Allen
I need a (free) shopping cart. The simpler the better. This one is what
I'm looking for:

  http://www.zend.com/codex.php?id=112single=1

but it doesn't use current session handling, needs validation, etc.

Any ideas?

Thanks,
Mike

-- 
Michael B Allen
PHP Extension for SSO w/ Windows Group Authorization
http://www.ioplex.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Get recursive array

2006-02-06 Thread Bruno B B Magalhães

Hi guys..

well I have a little problem, I succeeded on retrieving a value by  
it's key, but I want a clean and faster method... Let me explain:


I have the following function which I use to set variables in my  
framework like (configs, requests, etc)...



/***
* @function_name set_vars
* @function_type Method
* @function_input None
* @function_description None
***/
function set_var($key = '', $value = null)
{
if(is_array($key))
{
if(count($key))
{
foreach($key as $key_key = $key_value)
{
$this-vars[$key_key] = $key_value;
}
}
}
elseif(is_array($value))
{
if(count($value))
{
foreach($value as $value_key = $value_value)
{
$this-vars[$key][$value_key] = $value_value;
}
}
}
else
{
$this-vars[$key] = $value;
}
}

For example I have:

$this-vars['config']['database_type'] = 'mysql'; or...
$this-vars['http']['get'] = 'b';

But now I want a function that gets those values and subvalues, but  
there is one small catch, I need to dynamically get parsed arguments  
and check if key exists and returns it... I tried func_num_args, and  
func_get_args, without success.


Any ideas?

Regards,
Bruno B B Magalhaes

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Get recursive array

2006-02-06 Thread Bruno B B Magalhães

Hi guys..

well I have a little problem, I succeeded on retrieving a value by  
it's key, but I want a clean and faster method... Let me explain:


I have the following function which I use to set variables in my  
framework like (configs, requests, etc)...



/***
* @function_name set_vars
* @function_type Method
* @function_input None
* @function_description None
***/
function set_var($key = '', $value = null)
{
if(is_array($key))
{
if(count($key))
{
foreach($key as $key_key = $key_value)
{
$this-vars[$key_key] = $key_value;
}
}
}
elseif(is_array($value))
{
if(count($value))
{
foreach($value as $value_key = $value_value)
{
$this-vars[$key][$value_key] = $value_value;
}
}
}
else
{
$this-vars[$key] = $value;
}
}

For example I have:

$this-vars['config']['database_type'] = 'mysql'; or...
$this-vars['http']['get'] = 'b';

But now I want a function that gets those values and subvalues, but  
there is one small catch, I need to dynamically get parsed arguments  
and check if key exists and returns it... I tried func_num_args, and  
func_get_args, without success.


Any ideas?

Regards,
Bruno B B Magalhaes

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



  1   2   3   4   5   6   7   8   9   >