[PHP] Session problem

2007-11-21 Thread Mathieu Dumoulin
I got a strange problem here, here are the setup details first as this seems 
to be a server problem more than a php problem but it is still related to 
php configuration:

Server: Win2003 (latest)
WebServer: IIS6 (latest)
PHP: php5.2.2.1
MySQL: mysql.5

Sites installed in server that may have influence:

www.palliscience.com
dev.palliscience.com
maj.palliscience.com
dev2.palliscience.com

(All sites are installed using php5_ISAPI.dll)

Problem:

When i try to start a session in maj.palliscience.com (Same code as 
everywhere else except the content may differ), the server hangs. I tried 
for two days to find and make sure where this server hang was coming from 
and eventually came to the solid conclusion that my server hang on 
session_start. I tried to add different commands such as session_write_close 
at end of my scripts and checked that my sessions where not already open by 
using session_id.

The only way i was able to make my sessions work in maj.palliscience.com is 
using the CGI version of PHP, but hell this is causing me problems i never 
thought it would. I'm having problems with headers, and also the $_SERVER 
variable is deadly different.

So my question is simple, what could cause this problem. Could it be a clash 
in the filenames for the session files? I tried reading a bit the php.ini 
and saw there is a way to split the session files in different folders but i 
don't have the expertise nor the famous script the php.ini is talking about 
in the session section to fix or alter this info correctly. (I can't start 
tweaking this, there are other sites on the machine that are in production 
mode so i need a final configuration that will work on the first try)

Keep in mind:

1) I got 3 other sites that sport the same code, only slightly different 
content
2) All the sessions in the other sites work marvelously in ISAPI
3) Only maj is affected, i tried copying the code to dev2.palliscience.com, 
problem doesn't show.
4) I can definitely say my sessions are problematic, i comment out any 
session_start, and the problem nevers shows

Thanks

Mathieu Dumoulin 

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



[PHP] Documentation software

2006-06-29 Thread Mathieu Dumoulin
This is not a php specific question but more a programming question. I'd 
like to know names of software that help in creating documentation like 
the microsoft style of documentation when you visit the MSDN library. I 
can also see that often one some sites like the VBCORLIB web site.


I'm sure there is something out there, i'd like mostly a web based one 
and open source or free obviously...


Waiting for your input, thanks

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



[PHP] Re: Update site through email

2006-06-29 Thread Mathieu Dumoulin
How i'd do it is not simple, i'm sure there is an easier method but here 
goes for mine.


First you have to setup an inbox that you can read, it can be POP3 or 
IMAP, as long as your PHP script can read it it's fine.


Second, create a script that can actually connect to that inbox and read 
for a new message periodically. You can use a CRONJOB or a Scheduled 
Task if it's available, else, you'll have to check the mailbox from time 
to time when your page launches from a web browser (Try not to do it all 
the time or your page will suffer from this process if it is launched 
all the time).


That script will have to read the emails in the inbox, finds the 
appropriate email and stores the content the way you want, database or 
file, your choice.


Then, your web page will have to read from that stored source of your 
choice and echo the content at it's right place.


As you can see, it CAN be done, it's just a strange way of doing it.

Furthermore i see problems to that. You can probably get very easily 
hacked using this method. Its easy to read the incoming data in the 
server, find the email address used to update the content and then send 
a mail yourself. There is nothing you can do to stop that except encrypt 
your email using SSL... But thats a bit hardcore and there are much 
simpler ways than using SSL encrypted email to update a page ;)


Math

Rodrigo de Oliveira Costa wrote:

Hy guys I'd like to know if there is a way to update a site through
sending an email. Something like this, you send an email and the body
of the email substitutes a text you use in your site. Igreat apreciate
any help since I couldn't find anything on this topic.

Thanks,
doRodrigo


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



[PHP] Problem with resources and php 5 objects

2006-06-28 Thread Mathieu Dumoulin
I created a php class in charge of doing mysql queries and when this 
query is called it returns an object of the type myddl_result, this 
second object is passed the resource of type mysql_result and if i debug 
the whole thing i seems allright until the __construct is complete, 
after that, the __destruct is called for i don't know which reason and 
the rest is executed normally


At that point my resource is of type unknown and can't be used 
anymore... I really need help on that please... i don't understand whats 
happening even after reading the php website 2x about php 5 objects...


Note: What i understand is that the __destruct is called and thats what 
destroys my resource since i call the mysql_free_result, i tried 
commenting it but obviously thats not what i want, i want to free the 
resource when the object is destroyed which is good pratice, but WHY is 
the __destruct called, it doesn't make sense it's not supposed to be 
destroyed it's just been created...


==
QUERY FUNCTION
==

public function query($sql, $buffered = true){
 if($this-p_mylink){
  //execute the query and look for an exception
  if($buffered == true){
   $res = mysql_query($sql, $this-p_mylink);
  }else{
   $res = mysql_unbuffered_query($sql, $this-p_mylink);
  }
  if(is_resource($res)){//Result returned
   $mddl_result = new myDDLResult($res);
   echo 'Completed creationbrpre';
   var_dump($mddl_result);
   echo '/prebr';
   return $mddl_result;//Create a result object and return it
  }elseif($res === true){//Command executed succesfully
   return new myDDLResult();//Create a result object and return it
  }elseif($res === false){//Can only mean an error occured
   return $this-getError();//Create a result object and return it
  }else{//Impossible case but we'll warn the user
   throw new myDDLException('query failed to compare mysql_query type');
  }
 }
 throw new myDDLInvalidOperationException('Not connected to server');
}

=
RESULT CLASS
=

//Class in charge of interfacing a result
final class myDDLResult {
//Local vars
private $p_myresult;

//Constructor / destructor
public function __construct($result = NULL){
//Store
echo 'Creating';
echo 'br';
var_dump($result);
echo 'br';
$this-p_myresult = $result;
}
public function __destruct(){
echo 'Destroying';
echo 'br';
var_dump($this-p_myresult);
echo 'br';
mysql_free_result($this-p_myresult);
}
}


OUTPUT

Creating
resource(3) of type (mysql result)
Destroying
resource(3) of type (mysql result)
Completed creation

object(myDDLResult)#1 (1) {
  [p_myresult:private]=
  resource(3) of type (Unknown)
}
Destroyingresource(3) of type (Unknown)

Warning:  mysql_free_result(): 3 is not a valid MySQL result resource in 
C:\Source\palliscience\maj.palliscience.com\dev\lib_myddl.php on line 200



Destroying
resource(3) of type (Unknown)

Warning: mysql_free_result(): 3 is not a valid MySQL result resource in 
C:\Source\palliscience\maj.palliscience.com\dev\lib_myddl.php on line 200

Destroying
resource(3) of type (Unknown)

Warning: mysql_free_result(): 3 is not a valid MySQL result resource in 
C:\Source\palliscience\maj.palliscience.com\dev\lib_myddl.php on line 200

Destroying
resource(3) of type (Unknown)

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



[PHP] Question about constructors and destructors

2006-06-28 Thread Mathieu Dumoulin
I posted a bit earlier and did some other tests and now i have a VERY 
simple question... check the following code :


===

class test {
public function __construct(){
echo 'Buildingbr';
}
public function __destruct(){
echo 'Destroyingbr';
}
}

echo 'Will buildbr';
$mytest = new test();
echo 'Finished buildingbr';

echo 'Unsetingbr';
unset($mytest);
echo 'Unset completebr';

===

Althought you may think this will give the following output:

Will build
Building
Finished building
Unseting
Destroying
Unset complete

Instead it outputs the following:

Will build
Building
Destroying
Finished building
Unseting
Destroying
Unset complete

Notice the Destroying right after the building? Is that normal 
behavior, i just updated to PHP 5.1.4 for windows and IMO its not 
normal, can anyone test this on PHP 5 for linux see if it's only a 
windows issue


This is really important thanks

Math

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



[PHP] Re: Question about constructors and destructors

2006-06-28 Thread Mathieu Dumoulin

For all to know

This bug is linux AND windows, the problem is caused when you have the

zend.ze1_compatibility_mode = On

in the php.ini file. This is a bug that was reported before several 
times without having been resolved. I commented and reactiveated the bug 
on the php bug submission engine...


Thanks all for your support

Math

Mathieu Dumoulin wrote:
I posted a bit earlier and did some other tests and now i have a VERY 
simple question... check the following code :


===

class test {
public function __construct(){
echo 'Buildingbr';
}
public function __destruct(){
echo 'Destroyingbr';
}
}

echo 'Will buildbr';
$mytest = new test();
echo 'Finished buildingbr';

echo 'Unsetingbr';
unset($mytest);
echo 'Unset completebr';

===

Althought you may think this will give the following output:

Will build
Building
Finished building
Unseting
Destroying
Unset complete

Instead it outputs the following:

Will build
Building
Destroying
Finished building
Unseting
Destroying
Unset complete

Notice the Destroying right after the building? Is that normal 
behavior, i just updated to PHP 5.1.4 for windows and IMO its not 
normal, can anyone test this on PHP 5 for linux see if it's only a 
windows issue


This is really important thanks

Math


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



Re: [PHP] Avoiding user refresh of pages with forms

2006-05-03 Thread Mathieu Dumoulin

something interesting to note:

header('location: newpage.php');

After processing your POST request, just send them to a new page and in 
that page you can display the result of the process (It can require a 
bit of change in your code) but the result will be that a refresh will 
refresh the result page not the post page...


;)

PS: This doesn't prevent someone to hack your system and repost, but 
someone refreshing or backing up a page should not land on the post 
anymore.


Mathieu

Jochem Maas wrote:

Jeff wrote:


Is there a way to prevent a re-posting of the form data when a user
pushes the refresh button on the browser?

I have a page that has a form to enter credit's or debit's to a user
account.  The top of the page displays the users account history and at
the bottom is a form to add an adjustment. I just had a situation where
a user came in complaining that the database is out of control every
time I REFRESH the page the credit I put in gets added again and
again!!  He also claimed he was getting no warning message about that
which was of course false, he just didn't read it.

In any event, I need to make this more user proof.



a a 'hash' token to the form - and when the form is submitted the first
time log the token to the DB (or somewhere). each time a submission is
made check that the token is not already stored - if it is don't
let the submission through.

you can double up that security by not only blacklisting (as above) but
also whitelisting (the token has to be in your whitelist AND not in your
blacklist before a submission is considered valid)



Thanks,

Jeff



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



[PHP] File database, a href= works, but direct url access in address bar doesn't

2006-02-23 Thread Mathieu Dumoulin

I got a really weird and annoying problem:

I have a file database that people can access, depending of the file 
status (pending, active, deleted) i allow access to it from different 
people. For example, pending is available only to owner and admins, 
active is avail to everyone and delete is not available anymore.


My problem starts here, i did a web page that looks like a file browser, 
every file uploaded by the current user is diplayed there, its nothing 
complicated, just a simple html list of the different folders and files.


If you click on the file's link it loads the content-type, filename, 
reads the file and everything is sent to the user perfectly fine. Now if 
i take the URL of the link leading to the file and copy paste it in the 
same window's address bar, the download fails. For example:


http://dev.palliscience.com/dev_mvg/Palli-Sciences/file_explorer/file.php?element_id=8214
Works perfectly fine if its a link inside of the web site... BUT, if i 
copy paste this URL in my address bar, it fails. This is no special site 
with engines rewritting urls its a simple normal file by file website.


Some other clues:

When i click on the link, IE states the filename, contenttype and source 
perfectly fine. When i copy paste the url, instead of seeing


magistra_recipes.sql
text/plain
dev.palliscience.com

i see

file.php?element_id=8113
text/plain
dev.palliscience.com

Both urls are the same but IE reacts differently...

Here is the code of the page... (Line returns may make the code strange 
dont mind them... there are none in the original file)


/**/
?php
include(../include/authentification.php);
include('../includes/base.php');
include('../includes/db.php');
include('../includes/log.php');
include('../includes/lib/lib_filedb.php');

if(($sql = sql_connect()) === false){
	exit('Erreur de connection à la base de données. Veuillez réesaayer 
plus tard merci.');

}
log_pageaccess($sql);

//Block access if not in V2
if(!isset($_SESSION['sess_usev2']) || $_SESSION['sess_usev2'] != true){
header('location: ../profile/trans.php');
sql_disconnect($sql);
exit();
}

//Catch element_id
if(!isset($_GET['element_id']) || !is_numeric($_GET['element_id'])){
$_GET['element_id'] = 0;
}

//Get the element
$element = mysql_fetch_assoc(sql_query('SELECT * FROM filedb_elements 
WHERE id = '.sql_escape($_GET['element_id']).'', $sql));


ob_start();
/*print_r($element);
echo 'brbr';
print_r($active_account);
echo 'brbr';*/
if($element['sys_status'] == FILEDB_STATUS_ACTIVE){
echo 'public';
	echo 'reading : 
'.'../filedb/'.$element['id'].substr($element['element_name'], 
strrpos($element['element_name'], '.'));

}elseif($element['sys_status'] == FILEDB_STATUS_PENDING){
echo 'pending - ';
if($active_account-id == $element['sys_owner']){
echo 'owner access';
		echo 'reading : 
'.'../filedb/'.$element['id'].substr($element['element_name'], 
strrpos($element['element_name'], '.'));

}else{
echo 'not owner access - ';
		if(($active_account-profile_profileflags  ACCOUNT_ADMIN) == 
ACCOUNT_ADMIN){

echo 'admin access - ';
			echo 'reading : 
'.'../filedb/'.$element['id'].substr($element['element_name'], 
strrpos($element['element_name'], '.'));

}else{
echo 'not admin access';
}
}
}

$content = ob_get_contents();
ob_end_clean();
$fp = fopen('../filedb/log.txt', 'a');
fwrite($fp, str_replace('br', \r\n, $content));
fclose($fp);

//Check element type and owner
if($element['contenttype'] != 'system/folder'){
	//Check for status, if public, anyone can access it, if private, allow 
access only to admins or owner
	if(($element['sys_status'] == FILEDB_STATUS_ACTIVE) || 
(($element['sys_status'] == FILEDB_STATUS_PENDING)  
(($active_account-id == $element['sys_owner']) || 
(($active_account-profile_profileflags  ACCOUNT_ADMIN) == 
ACCOUNT_ADMIN{

//Authorize download// We'll be outputting a PDF
header('Content-type: '.$element['contenttype']);
// It will be called downloaded.pdf
		header('Content-Disposition: inline; 
filename='.$element['element_name'].'');

// The PDF source is in original.pdf
		readfile('../filedb/'.$element['id'].substr($element['element_name'], 
strrpos($element['element_name'], '.')));

}else{
//Bad file, can't access it
header('HTTP/1.0 404 Not Found');
		echo 'File not found 0x55498a3ff22 ('.$element['sys_owner'].' / 
'.$active_account-id.')';

}
}else{
//Bad file, can't access it
header('HTTP/1.0 404 Not Found');
echo 'File not found 0x6ef445a22d1';
}

//Disconnect the database
sql_disconnect($sql);
?
/**/
log.txt:

[PHP] Re: File database, a href= works, but direct url access in addressbar doesn't

2006-02-23 Thread Mathieu Dumoulin

Update update update


I tried with mozilla firefox and it worked fine, i just need to find out 
now what IE does that makes this process fail. If any of you have an 
idea that could help me solve my problem don't hesitate cause i need to 
find a solution.


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



[PHP] Re: auto download

2006-02-23 Thread Mathieu Dumoulin
If your page is already displayed and you want to auto start a link, its 
not done via PHP, its done via javascript to open a new window towards 
one of those links. Nothing prevents you from outputting javascript 
yourself from PHP, give it a try its really fun to build dynamic 
javascript applications.


Jens Kleikamp wrote:

Benjamin Adams wrote:


I have three links. The code already auto selects one.
I'm trying to take that one link and automaticly start the download.
I tryed with header('location:$link');
but it tells me Warning: Cannot modify header information
what would I use to start downloading?
one of the link is another page so I need it to pop up in a new window.

Thanks for any help


Moin,

You can´t start the browsers download dialog if you already sent any 
data. No header(), echo(), print() etc.


Have a look at http://pear.php.net/package/HTTP_Download.

cheers,
Jens


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



[PHP] Performance question

2006-02-01 Thread Mathieu Dumoulin

This is more a How would you do it than a How can i do it question.

Didn't have time to try it, but i want to know how mysql_seek_row acts 
with large result sets.


For example im thinking of building a node tree application that can 
have dual direction links to nodes attached to different places.


I was wondering if i could actually have two result sets that query 
everything sorted by ID (Links and Nodes) then just seek the rows i need 
instead of dumping everything in php memory. When i mean large i mean 
really large, more than the standard possible 2 mbs of data allowed by 
most php servers.


That's where the how you'd do it comes into play. I think i'd just 
query my tables, loop them but keep only the line (to do a data_seek 
later on) and ID in some kind of an hash table or simply an array. This 
would make it relatively fast without taking too much memory.


This is my solution, how do you people see it without dumping everything 
to memory or by making recursive SQL calls (which will obviously slow 
everything down i'm pretty sure)


Mathieu Dumoulin
Programmer analyst in web solutions
[EMAIL PROTECTED]

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



[PHP] Re: Performance question

2006-02-01 Thread Mathieu Dumoulin
Thx, but that wouldn't work since i can have dual direction nodes and 
further something i didnt say is that a node may be used infinite number 
of times in the tree... so it isn't really valid to use joins in that 
case :(


thx anyway

Barry wrote:

Mathieu Dumoulin wrote:


This is more a How would you do it than a How can i do it question.

Didn't have time to try it, but i want to know how mysql_seek_row acts 
with large result sets.


For example im thinking of building a node tree application that can 
have dual direction links to nodes attached to different places.


I was wondering if i could actually have two result sets that query 
everything sorted by ID (Links and Nodes) then just seek the rows i 
need instead of dumping everything in php memory. When i mean large i 
mean really large, more than the standard possible 2 mbs of data 
allowed by most php servers.


That's where the how you'd do it comes into play. I think i'd just 
query my tables, loop them but keep only the line (to do a data_seek 
later on) and ID in some kind of an hash table or simply an array. 
This would make it relatively fast without taking too much memory.


This is my solution, how do you people see it without dumping 
everything to memory or by making recursive SQL calls (which will 
obviously slow everything down i'm pretty sure)


Mathieu Dumoulin
Programmer analyst in web solutions
[EMAIL PROTECTED]



With JOINS probably if i am understanding you right.

Simple queries would still be dumped on PHP.

Uhm, my db is kinda 70MB big and JOINS work just fine.

Just theory, hope that helps.



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



Re: [PHP] Performance question

2006-02-01 Thread Mathieu Dumoulin
B trees or binary trees or hash tables or wathever sort algo or memory 
organisation could be just great if i'd put all my data in the page and 
tried or needed to sort it, but i can't do that and don't really need to.


I'm actually searching for a way to load a ton of data from mysql but 
avoiding to transfer everything in php memory to work it out.


I think the b tree would be nice if i had a ton of data to sort but i 
technically don't have lots of element in my node tree on the same 
levels, i could just sort that data in a simple php sort before showing 
it :)


Jochem Maas wrote:

I think this might interest you:

http://www.bluerwhite.org/btree/

then again it may make your ears bleed (because of the Maths :-).

Mathieu Dumoulin wrote:


This is more a How would you do it than a How can i do it question.

Didn't have time to try it, but i want to know how mysql_seek_row acts 
with large result sets.


For example im thinking of building a node tree application that can 
have dual direction links to nodes attached to different places.


I was wondering if i could actually have two result sets that query 
everything sorted by ID (Links and Nodes) then just seek the rows i 
need instead of dumping everything in php memory. When i mean large i 
mean really large, more than the standard possible 2 mbs of data 
allowed by most php servers.


That's where the how you'd do it comes into play. I think i'd just 
query my tables, loop them but keep only the line (to do a data_seek 
later on) and ID in some kind of an hash table or simply an array. 
This would make it relatively fast without taking too much memory.


This is my solution, how do you people see it without dumping 
everything to memory or by making recursive SQL calls (which will 
obviously slow everything down i'm pretty sure)


Mathieu Dumoulin
Programmer analyst in web solutions
[EMAIL PROTECTED]



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



Re: [PHP] Hide email addresses from spam bots

2006-02-01 Thread Mathieu Dumoulin
Indeed, the problem is that the HTTP-USER_AGENT is actually set by the 
software reading the page, a bot could actually say its IE6 and then 
bypass your protection.


The best protection you can do is encoding your addresses in a two way 
encoding like Base64 wich is plenty enough and using a little script on 
your email links, you call a javascript that decodes the links and does 
a window.location = mailto:+decoded_email


This will the browser act like a mailto: link had been clicked and still 
protect your email adresses.


For example: [EMAIL PROTECTED] looks like this in base64 : 
bWR1bW91bGluQGdyb3VwZS1jZGdpLmNvbQ==


Now i dunno how to do a base64 decode and encode in javascript but there 
is bound to be someone that did it somewhere on the net, just look for a 
function already coded...


tedd wrote:

Regulars:

I doubt if this can be done, but it there a way to detect a spambot as 
compared to a SE indexing your site? They are both basically the same, 
right?


tedd



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



Re: [PHP] Performance question

2006-02-01 Thread Mathieu Dumoulin

Miles Thompson wrote:

At 12:02 PM 2/1/2006, Mathieu Dumoulin wrote:


This is more a How would you do it than a How can i do it question.

Didn't have time to try it, but i want to know how mysql_seek_row acts 
with large result sets.


For example im thinking of building a node tree application that can 
have dual direction links to nodes attached to different places.


I was wondering if i could actually have two result sets that query 
everything sorted by ID (Links and Nodes) then just seek the rows i 
need instead of dumping everything in php memory. When i mean large i 
mean really large, more than the standard possible 2 mbs of data 
allowed by most php servers.


That's where the how you'd do it comes into play. I think i'd just 
query my tables, loop them but keep only the line (to do a data_seek 
later on) and ID in some kind of an hash table or simply an array. 
This would make it relatively fast without taking too much memory.


This is my solution, how do you people see it without dumping 
everything to memory or by making recursive SQL calls (which will 
obviously slow everything down i'm pretty sure)


Mathieu Dumoulin
Programmer analyst in web solutions
[EMAIL PROTECTED]



I don't get it - what are you trying to do? Why? What is being 
visualized in the tree structure?


Building trees is expensive, you're essentially duplicating the index of 
the database, and if you fetch the data it's in memory regardless of how 
you present it.


The mysql_data_seek needs the row number - but by  then you're on the 
client side, if this is to respond to a link.


Maybe I just don't see it - or maybe you're confusing server side and 
client side.


Regards - Miles Thompson



I'll try to explain my post better since people dont seem to understand 
it. I'm trying to illustrate a node tree client side, everything is 
considered a node in a tree. Now these nodes can appear more than once 
since i allow a node to be linked to different elements (Not just one 
parent, i may need to refer to a node several times.


Considering that a node may be there twice or more, that the number of 
nodes to work with may be quite high, i dont want to start copying into 
a php memory structure everything from the database that i might need... 
Nor do i want to recursively call SQL queries getting childrens of every 
parent. (That would cost a lot to the database server)


So i was wondering what would be the best idea to actually implement 
this... dilema of keeping it fast and not using too much memory.


As  i understand your reply Miles, the query im doing resides in the php 
memory even if i don't fetch the data? If you do confirm that i WILL 
have to resort to recursive SQL calls. :(


To finish my post i'd re-explain rapidly my vision of doing this, but 
obviously i may be mistaken, maybe i can't do this. Taking two sql 
queries, one for the nodes, one for the links between nodes, i'd first 
read the results sorted by id, and do a mapping table for each result. 
When i need to use some info, i'd map the id of this info to the mapping 
table and retrieve the row from the result residing in mysql memory. (Up 
to now, this seemed logical until Miles told me that results are kept in 
PHP memory.) If this is still a valid way of doing it great. What would 
be the impact on the sQL server. Would this be a good way? I'd like to 
know from other pros how they'd implement it.


Mathieu Dumoulin

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



[PHP] Sorting in PHP

2005-08-02 Thread Mathieu Dumoulin
Hi, i need to sort data using ksort. Its complex data out from a 
database (and no i can't sort it using the database sadly). I can change 
my code to reflect a new way of sorting but only to some extent, im limited.


Now from the data i build an array of the things i need to display, 
using the names of the hockey players i create a list that is supposed 
to be sorted, look at the result, you'll see that accents are not sorted 
althought my var_dump(setlocale(...)) returns that the french locale 
(string(5) fr_CA) has been chosen. Is there anything wrong? can i 
change my code to fix this problem and how, cause all my tries point to 
nothing.


(Btw i tried all the installed locales to no avail.)

Balodis  Devon1985-06-11Baie-Comeau AF *Joueur
Balogh  Sébastien1987-01-17Baie-Comeau AF   Joueur
Blais  Alexandre1986-06-23Baie-Comeau AFJoueur
Blouin  Sébastien1987-03-04Baie-Comeau MAJ  Joueur
Bossé  Simon1900-01-01Baie-Comeau AF *Joueur
Bouchard  François1988-04-26Baie-Comeau MAJ   Joueur
Boudreault  Stéphane1986-01-16Baie-Comeau AF  Joueur
Boulianne  Yannick1987-10-19Baie-Comeau AF   Joueur
Bradley  Adam1985-09-18Baie-Comeau AF *Joueur
Breault  Benjamin1988-02-21Baie-Comeau MAJ Joueur
Brodeur  Benoît1987-03-07Baie-Comeau AF Joueur
Bédard  Mikaël1987-12-13Baie-Comeau AF Joueur
Bélanger  Maxime1986-03-03Baie-Comeau MAJ Joueur
Bérubé  Mathieu1986-10-01Baie-Comeau AF Joueur

(In case you didn't notice, the last 3 lines are the problem, they 
should be right after the 3 first lines (after the a's))




//$teamdata gathered higher up in the code
$tmp_players = list_get_players($mysql_link, $_SESSION['team_list'],
$_GET['sys_date'],
$_SESSION['histo_directdata']);

//Sort it alpha cause its not done right now
foreach($tmp_players as $player){
	$players[0][$player['register_file']['info_lname'].'-'.$player['register_file']['info_fname'].'-'.$player['register_file']['info_mname'].'-'.$player['register_file']['info_datenais']] 
= $player;

}

unset($tmpplayers, $player);
var_dump(setlocale(LC_ALL, array('fr_CA', 'fr_CA.iso88591',
'fr_CA.utf8')));
ksort($players[0], SORT_LOCALE_STRING);

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



[PHP] Re: Sorting in PHP

2005-08-02 Thread Mathieu Dumoulin
Found my problem, i'm runnig php 4.3.11, will update first then i will 
try again.


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



Re: [PHP] Loading dynamic extension

2005-07-22 Thread Mathieu Dumoulin

Richard Lynch wrote:

On Thu, July 21, 2005 12:17 pm, Mathieu Dumoulin said:


2. Further more, i can't seem to find a way to know from which path or
drive my usbkey is operating. There is maybe something i missed
somewhere that's why im asking. Anyone ever found something about the
CLI current run path in $_ENV or $_SERVER var?



If your PHP script is on the same drive as the GTK lib, then you can use
phpinfo() to find out the variable name that has your drive letter.

Something like $script_filename or somesuch.

Insert the USB device, note the drive letter, run php -i | grep X:

Course, on a Mac or Linux box, your USB device won't have a drive letter
per se -- You'll have the correct PATH though, for the OS it's on, which
is far far more portable.



Sorry that doesn't work, just in case i tried erasing anything related 
to Apache, PHP and Perl on my home system. It seems by default, if PHP 
can't find a php.ini it sets all defaults to c:\windows instead of 
setting them to the current application run path.


I think my next step will be to check if i can recompile PHP manually 
for windows and change the code in it to reflect what i need in terms of 
defaults... Like using the application start path and stuff like that to 
load extensions and more.


Does that look like a good idea?

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



[PHP] Loading dynamic extension

2005-07-21 Thread Mathieu Dumoulin

Hi, ive got two hard questions for you guys.

1. I'm trying to load an extension dynamically using DL():

if(!extension_loaded('gtk')){ dl('php_gtk.'.PHP_SHLIB_SUFFIX); }

The problem with this is that i can't load the extension correctly since 
the software is running from a USBKEY. These removable medias do not 
necessarely always have the same drive letter and i can't ask people to 
copy the software on their machine since the software will write back on 
the key at a specific location.


2. Further more, i can't seem to find a way to know from which path or 
drive my usbkey is operating. There is maybe something i missed 
somewhere that's why im asking. Anyone ever found something about the 
CLI current run path in $_ENV or $_SERVER var?


Mathieu Dumoulin

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



[PHP] Sorting with french characters

2005-06-23 Thread Mathieu Dumoulin
I've got a little problem with the ksort and sort functions. When i fill 
 this array's keys or the array's data and i sort it, i can't seem to 
get a correct sort order concerning accented french characters.


For example:

Emiss, Erick
Morrison, Phillip
Tatey, Peter
Zachary, Martin
Élement, Marc-André

This is the kind of result i get from Ksort when i put these as keys. 
Notice the Élement, Marc-André at the end? Its supossed to be in the 
Es not at the end.


So i'm wondering how i can make this work now. I can't afford to make a 
STR_REPLACE on all possible accents, i got over a thousand records from 
the database to parse in a fast way and there are at the very least 60 
different accents to replace from the A, E, I, O and U without 
forgetting we have acute, grave, trema, circonflex accents for each 
letter. :S


My guess is there is something in the configuration of my dev server 
that must do this. Can anyone help me?


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



Re: [PHP] Uploading and verifying word and excel files

2005-06-23 Thread Mathieu Dumoulin

John Nichel wrote:

Jack Jackson wrote:
snip

Also, it seems that directories must be blown wide open (777) to allow 
the script to copy the file over from /tmp. My ISP won't allow 
directories to be set to 777 under public_html/ -- but we need to 
access the files via web browser which is the whole point.



It shouldn't have to be this way.  The webserver should be configured to 
run as your virtual user, or belong to a group which has write 
permission to that directory, or.I'm getting a bit off track with 
that.  This is something you'll have to take up with your ISP.



So my questions:
1. How do you validate Word and Excel files before upload?



Before?  JavaScript...if JavaScript can even do it (I haven't touched 
the stuff in ages).  After upload, you can check the mime type, but 
that's not foolproof.


2. How can I make a passthrough from a file above public_html to one 
below it so that people can surf in with a browser and download files 
which have been uploaded by the script?



http://us4.php.net/move_uploaded_file



Indeed file types are not fool proof, for example windows provide 
mime-type based on the file type in your system. Whatever browser the 
user has, if you don't have for example acrobat reader installed, all 
PDF files will be uploaded as application/octet-stream files.


So in no way should you ever validate a file based on its extension or 
on its mime type since 93% of the machines out there use extension to 
determine the mime type.


The only virtually failproof way to test for a certain file is using the 
header of the file. For example, getimagesize uses the header of the 
file to find what type of file it is. I wouln't recommend parsing the 
file, imagine someone uploaded a imposing 10 or even 100 mb file. The 
only way would be to read the first few characters and compare them with 
standard headers in those particular files. This will be an almost 
failproof way to see if an uploaded file is of the correct type.


The only 2 drawbacks to this method is:

- 1) Someone with malicious intentions CAN change the header of a file 
to force it to look like another type of file. What is the end result i 
dare not think about it. It could be used for any kind of hacking or 
damaging effect.


- 2) With ever changing versions of WORD and EXCEL, you need to 
implement a series of different headers for PC, MAC and even possibly 
LINUX if there is a version of these with slightly different headers. So 
i makes your code get heavier each year or so.


Mathieu Dumoulin

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



Re: [PHP] How to submit a form that has a file included ?

2005-06-06 Thread Mathieu Dumoulin

Jay Blanchard wrote:

[snip]
I want to have a form with text fields and a browse field for
uploading a file.
...
  Now, i want here a browse button, so users when clicking on it trigers
the os File Open box to choose the file to upload.
...
My question is: what is the code i need in the form ?
And the form tag, is it allright like it is ?
[/snip]

Read this section, http://us4.php.net/manual/en/features.file-upload.php it has 
examples.


Never tried this?

input type=file name=wathever size=100

;)

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



[PHP] need help on .htaccess

2005-05-05 Thread Mathieu Dumoulin
We have here at work a simple .htaccess that redirects all requests to 
an index page which works fine so far. I'll show you the code of the 
.htaccess you can use it if you can't to, it works perfectly fine.

AddType application/x-httpd-php .html
RewriteEngine on
RewriteBase /
RewriteRule ^$ - [QSA,L]
RewriteRule ^.*\.gif$ - [L]
RewriteRule ^.*\.jpg$ - [L]
RewriteRule ^.*\.css$ - [L]
RewriteRule ^.*\.png$ - [L]
RewriteRule ^.*\.exe$ - [L]
RewriteRule ^(.*)/$ index.html?virtual_path=$1 [QSA,L]
RewriteRule ^(.*)$ index.html?virtual_path=$1 [QSA,L]
RewriteRule ^(.*)/index.html$ index.html?virtual_path=$1 [QSA,L]
The major problem i have with this, is that we have a folder called 
/media and i want everything inside this folder to be [L] left alone. 
Right you can see we managed to do this using different extension but i 
got a dynamic module that allows people to upload/download pretty much 
anything from the media folder, so eventually some files are not of 
correcte extension and i get problems regarding a page that doesn't 
really exist in my engine or i just open the DB connection for nothing 
for instance.

I really suck a Regexp so i was wondering if people could help me find 
the exact regexp that will make everything in the /media dir completly 
[L] appart. I tried several things but doesn't work.

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


[PHP] Re: is this the correct syntax

2005-05-05 Thread Mathieu Dumoulin
Ross wrote:
Am trying to do an update of a record...
Is this the correct syntax..
 $query= UPDATE $table_name SET fname='$fname', sname='$sname' WHERE id= 
$id;

R. 
Technically this is right as long as your variables are giving out the 
real intented values.

For extra knowledge, your $query should look something like this to make 
it secure:

$query = 'Update `'.mysql_escape_string($table_name).'` SET fname = 
'.mysql_escape_string($fname).', sname = 
'.mysql_escape_string($sname).' WHERE id = 
'.mysql_escape_string($id).'';

Now the mysql_escape_string is used to escape ' and  characters in your 
string in case they are not already escape which may cause a security 
hole in your code. Also note that you should place  around all values 
in your SQL string even for numeric values in case your data was sent an 
incorrect text value (Which you should filter beforehand but that's up 
to you)

Finally, for even more security, you should use $_POST[] or $_GET[] 
arrays if the above values come from a form, if they are calculated or 
extracted from something else don't mind this.

PS: i forgot about the `` around table and field names, this prevents 
mysql of interpreting a word in your SQL as a keyword, for example, 
using `` you can easily use `date` as a table or field name (not 
recommended) but it will allow to bypass the keyword DATE.

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


[PHP] Re: Linking to the Root Dir - LAMP

2005-05-05 Thread Mathieu Dumoulin
Shaun wrote:
Hi,
I have a file called application.php and this file I define all of the 
directories in my site:

class object {};
$CFG = new object;
$CFG-wwwroot = http://www.mydomain.com;
$CFG-dirroot  = /usr/home/myaccount/public_html;
$CFG-admindir = $CFG-wwwroot/admin;
$CFG-claimsdir_adm = $CFG-admindir/claims;
$CFG-clientsdir   = $CFG-admindir/clients;
$CFG-cssdir = $CFG-wwwroot/css;
$CFG-expense_categoriesdir = $CFG-admindir/expense_categories;
$CFG-projectsdir   = $CFG-admindir/projects;
$CFG-shoppingdir  = $CFG-wwwroot/shopping;
...
This works very well and means if I change a directory name or move a 
directory I only have to update this file. application.php is included on 
every page so all I have to do to link to another directory would be 
something like:

pClick a href=?php echo $CFG-expense_categoriesdir; 
??action=add_expense_categoryhere/a to add a category/p

The problem with this is that the URL's include the http://www.mydomain.com/ 
and are therefore not relative links. Is there a way to link to the root 
directory from wherever I am within the directory structure?

Thanks for your advice 
Just put a / in front of your folders. Instead of putting the whole 
domain name the slash in front of anything will refer to the root of the 
site while not statically putting the domain name.

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


Re: [PHP] is this the correct syntax

2005-05-05 Thread Mathieu Dumoulin
Prathaban look carefully, we are here to give acurate info and you are 
giving mistaken information. The $id thing is wrong, you'll actually 
create a parse error X|

...
Prathaban Mookiah wrote:
It should be $id.
Note that missing 
Prathap
-- Original Message ---
From: Ross [EMAIL PROTECTED]
To: php-general@lists.php.net
Sent: Thu, 5 May 2005 12:09:18 +0100
Subject: [PHP] is this the correct syntax

Am trying to do an update of a record...
Is this the correct syntax..
$query= UPDATE $table_name SET fname='$fname', sname='$sname' 
WHERE id= $id;

R.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End of Original Message ---
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: PHP mail

2005-05-05 Thread Mathieu Dumoulin
Eustace wrote:
I am relatively new to PHP and could use some help. I have a form, which is
basically in an email format, from, subject, and message. How do I then send
this to an email? I know a bit about the mail function, somebody show me the
ropes please!
Eustace
I'll show you how we do it here at work, its quite simple:
//Target message setup
$target_receptemail = 'insert email here';
$target_receptname = 'insert the targets name here';
$target_senderemail = 'insert your email here';
$target_sendername = 'insert your name here';
//Message body setup
//Target setup
$target_bodymsg = 'Insert content here';
$target_subjectmsg = 'Insert subject here';
//Build the headers
$headers = array(
'From: '.$target_sendername.' '.$target_senderemail.'',
'Content-Type: text/html'
);
//Send the mail
mail(
$target_receptemail,
$target_subjectmsg,
$target_bodymsg,
implode(\r\n, $headers)
);
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Objects in Arrays (without the READ prompt)

2005-05-05 Thread Mathieu Dumoulin
Stuart Nielson wrote:
Sorry to everyone about the stupid READ notification on the posting.  I
completely forgot that it was enabled.  This one shouldn't have that
problem.
I am using PHP version 4.3.4.
I'm creating an authorization module that uses a users object, that
includes the username, usertype, etc.  I want to store this in a session
variable (i.e. $_SESSION['objects']['auth'] = new Authorization();) so
that I can keep the information from page to page.  However, I get an
error that it is an incomplete class everytime I try to access a
function from the object like this:
$_SESSION['objects']['auth']-Login();.  It works fine when it's not
stored in the array.  Is this a PHP 4 issue?  Or is there something I'm
doing wrong?
Any pointers would be helpful.  If this doesn't work, I'll have to
rework 
things to just store in arrays.

Stuart
Objects can't be stored in sessions, what you could do is register a 
shutdown function using register_shutdown_function(functionname) and 
create a custom function that would use serialize() to serialize your 
object.

When the system starts a new you could unserialize() this session 
variable back into an array.

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


[PHP] problems setting up php5 on apache2 (WinXP Pro)

2004-09-10 Thread Mathieu Dumoulin
(Don't write to me telling me to use linux, i dont want to, this is my home
machine not a production server, thank you, now if you really want to help
keep on reading)

I got a most recent copy of PHP 5.01 extracted into C:\php and everything
seems to be working fine as long as i dont ask to load extensions. Any
extension that i try to add will fail to load and i'm clueless.

At first in the PHP.ini file this was the original directive:

; Directory in which the loadable extensions (modules) reside.
extension_dir = ./

And it would not work so i changed it to a hardcoded path

; Directory in which the loadable extensions (modules) reside.
extension_dir = C:\php\ext

Still no extensions wont load. Whats the weirdest, all the DLLs are at the
correct location, apache reports: PHP startup: Unable to load dynamic
library 'C:\php\ext\php_mysql.dll' - The specified module could not be
found.

but it IS there, at the exact location, i even looked and compared both
paths manually letter by letter. Another weird thing to note is that some
extensions DO load while some don't, here is a list of the extensions that
i'm loading and which one fails (Note ALL extensions DLL are indeed in the
folder intended, they just dont load)

extension=php_bz2.dll
extension=php_gd2.dll
extension=php_imap.dll
extension=php_mysql.dll  fails but it's vital to me

these extensions are activated, only mysql fails, but there are other i
wanted earlier lemme see which ones: (These would be nice to have, i'll tell
you which one fails too)

;extension=php_exif.dll  fails
;extension=php_ldap.dll  fails (The file really isnt there so it's not a
real problem)
;extension=php_openssl.dll  fails
;extension=php_pdf.dll
;extension=php_pgsql.dll
;extension=php_snmp.dll
;extension=php_sockets.dll
;extension=php_tidy.dll
;extension=php_zip.dll

All of these will load... S I'm stuck there, i need help, tell me if you
need to know anything else. i'll be glad to give you info, i want to set
this up to further my PHP developement at home. We intensively use PHP4 at
work but i wanted to start working on PHP5 to see how good it is.

Till then
See ya'll
TheInsaneCoder

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



[PHP] Dynamic Class Methods

2004-09-07 Thread Mathieu Dumoulin
I'm trying to setup a function from user code inside a defined object or a
class definition but it doesnt seem to work. Am i doing it right? Is there
something i need to know... is it even possible?

I know create_function can be used to create a function and it returns the
ident to run the function later on, lookup create_function on php.net and it
seems possible. Now i wonder if you can actually assign this function inside
a class. My final goal is to create a set of functions or objects that will
be able to implement interfaces to object classes, which is something
missing to the PHP language.

--
RESULT
--
allo
Fatal error: Call to undefined function: b() in
/home/tech/web/testboard/implements.php on line 21

-
CODE
-
?php
class cls_a {
 function a(){
  echo 'allo';
 }
}

class impl_a {
 function get_impl_b(){
  return array('', 'echo Hello world;');
 }
}

$a = new cls_a();
$b_code = impl_a::get_impl_b();
$a-b = create_function($b_code[0], $b_code[1]);
$a-a();
$a-b();
?

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



[PHP] XML Cdata problem

2004-06-30 Thread Mathieu Dumoulin
PHP 4.3.7 on Linux Red Hat 7.3 full patch and updates, Expat expat_1.95.2

Problem:

I am reading the XML file below and at path:

advantage/route/origin/status/

The CDATA inside the STATUS node cannot be read (Current value 1900), there
isnt much information on how to use the EXPAT library on PHP.Net apart from
the extensive definition of all functions so i'm not sure im using EXPAT the
correct way. Please tell me if im doing something wrong, here is my code and
the XML file is further below:


*  PHP CODE  *


//Load the XML like it was a XML reponse
$xml = implode('', file('xml.xml'));
echo 'PRE'.str_replace(array('', ''), array('lt;', 'gt;'),
$xml).'/PRE';

/*For now all objects are empty shells without data in them, the XML parser
will link everything together nicely
and will add the CDATA for objects if there is some. Later we will add the
standard options to each class
and create functions for output.*/

//Contains an advantage server response, very basic object with only one
thing below
class advantage_node {
   function advantage_response() {}
}

//Contains an advantage server data representing a route
class route_node {
   function route_node() {}
}

//Contains an advantage server data representing a parsed input data from
the server
class origin_node {
   function origin_node() {}
}

//Contains an advantage server data representing a status
class status_node {
   function status_node() {}
}

//Contains an advantage server data representing a location
class location_node {
   function location_node() {}
}

//Contains an advantage server data representing a number
class number_node {
   function number_node() {}
}

//In charge of making the object tree and handling first level objects
function xml_to_class_tag_start($parser, $element, $attributes){
 $element_class = $element.'_node';
 if(class_exists($element_class) 
isset($GLOBALS['element_levels'][$GLOBALS['element_level']-1])){
  $new_element = new $element_class;
  if(is_array($attributes)){ foreach($attributes as $attribute = $value){
   $new_element-$attribute = $value;
  }}
  if($GLOBALS['element_level']-1 = 0){
   $GLOBALS['element_levels'][$GLOBALS['element_level']-1]-$element =
$new_element;
  }
  $GLOBALS['element_levels'][$GLOBALS['element_level']] = $new_element;
 }
 ++$GLOBALS['element_level'];
}

//In charge of closing the current object and rolling back to the previous
one
function xml_to_class_tag_end($parser, $element){
 if($GLOBALS['element_level']  1){
  unset($GLOBALS['element_levels'][$GLOBALS['element_level']]);
 }
 $GLOBALS['element_level']--;
}

function xml_to_class_tag_data($parser, $data){
 if(trim($data) != ''){
  $GLOBALS['element_levels'][$GLOBALS['element_level']]-cdata = $data;
 }
}

//Setup the objects
$element_level = 0;
$element_levels = array(-1 = '');

//Start the XML parsing
$parser = xml_parser_create();
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 1);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 0);
xml_set_element_handler($parser, 'xml_to_class_tag_start',
'xml_to_class_tag_end');
xml_set_character_data_handler($parser, 'xml_to_class_tag_data');
xml_parse($parser, $xml);
xml_parser_free($parser);

//Output
echo 'pre'.print_r($element_levels[0], true).'/pre';
*  RESULT
*advantage_node Object
(
[ROUTE] = route_node Object
(
[STATUS] = 0
[ORIGIN] = origin_node Object
(
[COUNT] = 1
[STATUS] = status_node Object
(
)

[LOCATION] = location_node Object
(
[NUMBER] = number_node Object
(
)

)

)

)

)
*  XML DATA  *


advantage
-
 route status=0
-
 parameters
clientId[protected]/clientId
destcountryca/destcountry
destpostalcodeh1p 2w8/destpostalcode
origcountryca/origcountry
origpostalcodeh1z 2l2/origpostalcode
transactionroute/transaction
/parameters
-
 input
-
 origin count=1
-
 location
postalCodeh1z 2l2/postalCode
countryca/country
/location
/origin
-
 destination count=1
-
 location
postalCodeh1p 2w8/postalCode
countryca/country
/location
/destination
/input
-
 origin count=1
status1900/status
-
 location
number1/number
cityMONTREAL/city
stateProvinceQC/stateProvince
postalCodeH1Z 2L2/postalCode
countryCA/country
latitude45.569129/latitude
longitude-73.601440/longitude
geocodeQualityZIP/geocodeQuality
iconId9191/iconId
-
 map
height119/height
width198/width
type8/type
mapStyledefault/mapStyle
-
 request
[useless junk]
/request
/map
/location
/origin
-
 destination count=1
status1900/status
-
 location
number1/number
citySAINT-LEONARD/city
stateProvinceQC/stateProvince
postalCodeH1P 

[PHP] Re: XML Cdata problem

2004-06-30 Thread Mathieu Dumoulin
Forget myt post, its a stupid error from my part because of object
references and stuff like that. I'll fix it myself.

Mathieu Dumoulin [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 PHP 4.3.7 on Linux Red Hat 7.3 full patch and updates, Expat expat_1.95.2

 Problem:

 I am reading the XML file below and at path:

 advantage/route/origin/status/

 The CDATA inside the STATUS node cannot be read (Current value 1900),
there
 isnt much information on how to use the EXPAT library on PHP.Net apart
from
 the extensive definition of all functions so i'm not sure im using EXPAT
the
 correct way. Please tell me if im doing something wrong, here is my code
and
 the XML file is further below:

 
 *  PHP CODE  *
 

 //Load the XML like it was a XML reponse
 $xml = implode('', file('xml.xml'));
 echo 'PRE'.str_replace(array('', ''), array('lt;', 'gt;'),
 $xml).'/PRE';

 /*For now all objects are empty shells without data in them, the XML
parser
 will link everything together nicely
 and will add the CDATA for objects if there is some. Later we will add the
 standard options to each class
 and create functions for output.*/

 //Contains an advantage server response, very basic object with only one
 thing below
 class advantage_node {
function advantage_response() {}
 }

 //Contains an advantage server data representing a route
 class route_node {
function route_node() {}
 }

 //Contains an advantage server data representing a parsed input data from
 the server
 class origin_node {
function origin_node() {}
 }

 //Contains an advantage server data representing a status
 class status_node {
function status_node() {}
 }

 //Contains an advantage server data representing a location
 class location_node {
function location_node() {}
 }

 //Contains an advantage server data representing a number
 class number_node {
function number_node() {}
 }

 //In charge of making the object tree and handling first level objects
 function xml_to_class_tag_start($parser, $element, $attributes){
  $element_class = $element.'_node';
  if(class_exists($element_class) 
 isset($GLOBALS['element_levels'][$GLOBALS['element_level']-1])){
   $new_element = new $element_class;
   if(is_array($attributes)){ foreach($attributes as $attribute = $value){
$new_element-$attribute = $value;
   }}
   if($GLOBALS['element_level']-1 = 0){
$GLOBALS['element_levels'][$GLOBALS['element_level']-1]-$element =
 $new_element;
   }
   $GLOBALS['element_levels'][$GLOBALS['element_level']] = $new_element;
  }
  ++$GLOBALS['element_level'];
 }

 //In charge of closing the current object and rolling back to the previous
 one
 function xml_to_class_tag_end($parser, $element){
  if($GLOBALS['element_level']  1){
   unset($GLOBALS['element_levels'][$GLOBALS['element_level']]);
  }
  $GLOBALS['element_level']--;
 }

 function xml_to_class_tag_data($parser, $data){
  if(trim($data) != ''){
   $GLOBALS['element_levels'][$GLOBALS['element_level']]-cdata = $data;
  }
 }

 //Setup the objects
 $element_level = 0;
 $element_levels = array(-1 = '');

 //Start the XML parsing
 $parser = xml_parser_create();
 xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 1);
 xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 0);
 xml_set_element_handler($parser, 'xml_to_class_tag_start',
 'xml_to_class_tag_end');
 xml_set_character_data_handler($parser, 'xml_to_class_tag_data');
 xml_parse($parser, $xml);
 xml_parser_free($parser);

 //Output
 echo 'pre'.print_r($element_levels[0], true).'/pre';
 *  RESULT
 *advantage_node Object
 (
 [ROUTE] = route_node Object
 (
 [STATUS] = 0
 [ORIGIN] = origin_node Object
 (
 [COUNT] = 1
 [STATUS] = status_node Object
 (
 )

 [LOCATION] = location_node Object
 (
 [NUMBER] = number_node Object
 (
 )

 )

 )

 )

 )
 *  XML DATA  *
 

 advantage
 -
  route status=0
 -
  parameters
 clientId[protected]/clientId
 destcountryca/destcountry
 destpostalcodeh1p 2w8/destpostalcode
 origcountryca/origcountry
 origpostalcodeh1z 2l2/origpostalcode
 transactionroute/transaction
 /parameters
 -
  input
 -
  origin count=1
 -
  location
 postalCodeh1z 2l2/postalCode
 countryca/country
 /location
 /origin
 -
  destination count=1
 -
  location
 postalCodeh1p 2w8/postalCode
 countryca/country
 /location
 /destination
 /input
 -
  origin count=1
 status1900/status
 -
  location
 number1/number
 cityMONTREAL/city
 stateProvinceQC/stateProvince
 postalCodeH1Z 2L2/postalCode
 countryCA/country
 latitude45.569129

[PHP] Session start problem

2003-07-07 Thread Mathieu Dumoulin
We are using php 4.0.6 here on a dev server and we are getting a weird
session_start() problem.

After setting up the login on another page, if we register any of our three
required varaibles to go on, the session_start() will simply crash and loop
endlessly. We have tested everything:

- setting values after registering, before registering, not registering at
all and as soon as we register a variable it loops endlessly when we start
the session. Needless to say that we NEED to fix that or else we have a
wonderfull system with no login nor sessions...

here is the code:

[[[LOGIN.PHP]]]

?
session_start();
include('../includes/open.php');

function verifypass($login, $password)
{
 global $sql, $result;
 $req=SELECT  *  FROM giuser WHERE login= ' .  $login  . ' AND password
=' .  md5($password) .';
 $result=mysql_query($req, $sql);

 if(mysql_num_rows($result)  1) // le resultat est unique
 {
  return 'Erreur: mot de passe invalide';
 }
 return '';
}

if($submit == '' || $login == '' || $password == '' || ($moo =
verifypass($login, $password))!='')
{

 echo 'htmlheadtitleGestion des projets/titlemeta
http-equiv=Content-Type content=text/html; charset=iso-8859-1
link href=../css/giprojects.css rel=stylesheet
type=text/css/head
body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0
class=giprojects';
 echo 'FORM name=loginform method=post action=login.php?submit=1
table width=100% height=100% border=0 cellpadding=5
cellspacing=0 class=txt11px
tr tdp align=centerimg
src=../images/logo.gifbrbrbrbrNom d\'usager :
INPUT name=login type=text id=projet25 size=18 maxlength=15
';
 if($submit!=''  $login=='') echo 'nbsp; *';
 echo 'brMot de passe : INPUT name=password type=password id=login
size=20 maxlength=15';
 if($submit!=''  $password=='') echo 'nbsp; *';
 echo 'brbra href=# onClick=document.loginform.submit(); return
true;Entrer/a/p/td
/tr/tablediv align=center/div/body/html';
}
else
{
 $req=SELECT  *  FROM giuser WHERE login= ' .  $login  . ' AND password
=' .  md5($password) .';
 $result=mysql_query($req, $sql);

 if(mysql_num_rows($result)  1) // le resultat est unique
 {
  include( 'login.php?e=1');
 }
 else
 {
  $row = mysql_fetch_array($result);

  session_register(session_user);
  session_register(session_niveauusager);
  session_register(session_nomusager);
  $session_user = $login;
  $session_nomusager = $row[nom];
  $session_niveauusager=$row[level];

  echo 'HTMLHEADTITLEGI Projects/TITLEMETA http-equiv=refresh
content=5; URL=todo.php?user=' . $login .'/HEADBODY';
  $req=SELECT  nom FROM  person WHERE id = .  $row[personid] ;
  $result = mysql_query($req, $sql);
  $row = mysql_fetch_array($result);
  echo 'centerh3Bienvenu '.  $row[nom] . '!/h3/center';
  echo 'center[niveau d\'access: '. $session_niveauusager . ']'; }
}

include('../includes/close.php');
?

[[TODO.PHP (File that we get
redirected to after loging in that loops edlessly)

?php
session_start();//--- JAMS HERE
exit(A);
//include('secur.php'); ?
?php include('../includes/open.php'); ?

HTML
HEAD
?php //include('../includes/helpers.php');
/HEAD
/HTML



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



[PHP] Re: Session start problem

2003-07-07 Thread Mathieu Dumoulin
Problem was that the TMP dir was full and we couldn'T write down the session
file... Seems this jams the server completly. Be aware that if anything like
that happen to you that you have to check fro the TMP files that might be
overflooding your partition.

Mathieu Dumoulin [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 We are using php 4.0.6 here on a dev server and we are getting a weird
 session_start() problem.

 After setting up the login on another page, if we register any of our
three
 required varaibles to go on, the session_start() will simply crash and
loop
 endlessly. We have tested everything:

 - setting values after registering, before registering, not registering at
 all and as soon as we register a variable it loops endlessly when we start
 the session. Needless to say that we NEED to fix that or else we have a
 wonderfull system with no login nor sessions...

 here is the code:

 [[[LOGIN.PHP]]]

 ?
 session_start();
 include('../includes/open.php');

 function verifypass($login, $password)
 {
  global $sql, $result;
  $req=SELECT  *  FROM giuser WHERE login= ' .  $login  . ' AND password
 =' .  md5($password) .';
  $result=mysql_query($req, $sql);

  if(mysql_num_rows($result)  1) // le resultat est unique
  {
   return 'Erreur: mot de passe invalide';
  }
  return '';
 }

 if($submit == '' || $login == '' || $password == '' || ($moo =
 verifypass($login, $password))!='')
 {

  echo 'htmlheadtitleGestion des projets/titlemeta
 http-equiv=Content-Type content=text/html; charset=iso-8859-1
 link href=../css/giprojects.css rel=stylesheet
 type=text/css/head
 body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0
 class=giprojects';
  echo 'FORM name=loginform method=post action=login.php?submit=1
 table width=100% height=100% border=0 cellpadding=5
 cellspacing=0 class=txt11px
 tr tdp align=centerimg
 src=../images/logo.gifbrbrbrbrNom d\'usager :
 INPUT name=login type=text id=projet25 size=18 maxlength=15
 ';
  if($submit!=''  $login=='') echo 'nbsp; *';
  echo 'brMot de passe : INPUT name=password type=password
id=login
 size=20 maxlength=15';
  if($submit!=''  $password=='') echo 'nbsp; *';
  echo 'brbra href=# onClick=document.loginform.submit(); return
 true;Entrer/a/p/td
 /tr/tablediv align=center/div/body/html';
 }
 else
 {
  $req=SELECT  *  FROM giuser WHERE login= ' .  $login  . ' AND password
 =' .  md5($password) .';
  $result=mysql_query($req, $sql);

  if(mysql_num_rows($result)  1) // le resultat est unique
  {
   include( 'login.php?e=1');
  }
  else
  {
   $row = mysql_fetch_array($result);

   session_register(session_user);
   session_register(session_niveauusager);
   session_register(session_nomusager);
   $session_user = $login;
   $session_nomusager = $row[nom];
   $session_niveauusager=$row[level];

   echo 'HTMLHEADTITLEGI Projects/TITLEMETA http-equiv=refresh
 content=5; URL=todo.php?user=' . $login .'/HEADBODY';
   $req=SELECT  nom FROM  person WHERE id = .  $row[personid] ;
   $result = mysql_query($req, $sql);
   $row = mysql_fetch_array($result);
   echo 'centerh3Bienvenu '.  $row[nom] . '!/h3/center';
   echo 'center[niveau d\'access: '. $session_niveauusager . ']'; }
 }

 include('../includes/close.php');
 ?

 [[TODO.PHP (File that we get
 redirected to after loging in that loops edlessly)

 ?php
 session_start();//--- JAMS HERE
 exit(A);
 //include('secur.php'); ?
 ?php include('../includes/open.php'); ?

 HTML
 HEAD
 ?php //include('../includes/helpers.php');
 /HEAD
 /HTML





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



[PHP] Can't seem to be able to do a get request

2003-03-13 Thread Mathieu Dumoulin
I got this script i wish to run like it was a seperate thread on the server
cause i can't run anything with a crontab but i can't seem to do a valid GET
request thru fsockopen. If anyone can help me please.


$fp = fsockopen (sandbox.lhjmq.xl5.net, 80);
if ($fp) {

fputs ($fp, GET /lang_fr/index.php HTTP/1.1);
while (!feof($fp)) echo fgets ($fp,128);
fclose ($fp);
}

I run the script from the web but nothing happens. If i run it also with the
real URL i want to get (I cannot show this url for security reasons) my
processor and mysql process should go up to 80% each for like 40 seconds and
my top command in shell would show it, but it's not happenning. Now i
tried index.php and still nothing!

Please help me out

Mathieu Dumoulin



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



[PHP] Does comments slow down processing a lot

2003-03-12 Thread Mathieu Dumoulin
I'm programming large web solutions here and a new programmer has given me a
warning about how much comments i put in  my code and said that it could
probably lower effiency when parsing and executing the php code in my
documents.

So my questions are:
Does putting huge amount of comments in a file really lower the parsing,
compilation and execution time?
Using Zend Optimizer, which is the case right now, would it be better if it
did slow down the code?

Thank you in advance

Mathieu Dumoulin
www.groupimage.com
Web solution Programmer/Analyst



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



[PHP] session id generation

2003-03-12 Thread Mathieu Dumoulin
Hi, i'd like to know how PHP determines what session_id to hand out to
users.

Is it based on some real value like the browser and the ip address? an
incremental number? I want to make sure that it doesnt provide two same
session id for the different users at the same time.

thanks

MAthieu Dumoulin
Programmer analyst for web solutions
www.groupimage.com




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



[PHP] mysql.so

2003-03-12 Thread Mathieu Dumoulin
Got this problem here.

I have a script i wish to run from a crontab every 2 minutes (Compiles live
stats for a hockey site). This script doesn't run at all in shell mode as an
application but works perfectly fine when called from the web.

Problem is i can't integrate it in the web site like when someone adds an
event or they have to wait like 30 seconds before being able to enter
something else. Talk about live stats if you can only enter 1
shot/hit/faceoff/etc each 30 seconds..

So i HAVE, unless there is a way to do it another way, to run it as a
crontab. My question now is:

- Can i, from a php script from the web start running another script
directly and ignoring the reply...just make it run, thats all and then
redirect the user to some other page while it runs
- Or, can you help me solve my problem about unloadable libraries:

Here is what i can tell from the error i got:
===
[EMAIL PROTECTED] cron_compile_sys]# ./compileMatches.php
Zend Optimizer requires Zend Engine API version 20020429
The installed Zend Engine API version is 20001224

Content-type: text/html

PHP Warning:  Unable to load dynamic library '/usr/lib/php4/mysql.so' -
libmysqlclient.so.10: cannot open shared object file: No such file or
directory in Unknown on line 0
X-Powered-By: PHP/4.0.6
Content-type: text/html

br
bFatal error/b:  Call to undefined function:  mysql_connect() in
b/var/www/sandbox.lhjmq.xl5.net/web/classes/class.mysql.connection.php/b
on line b53/bbr
===
I check my /usr/lib/php4/ folder and it DOES contain the mysql.so file
Second, i looked all over the machine to find other PHP interpretors, i
found several ones all saying version 4.0.6 although when i run phpinfo.php
it says php4.2.2 in the phpinfo response.

http://www.lhjmq.qc.ca/phpinfo.php

Finaly, since it's a production web server, i cannot take the risk to
recompile apache, php or install a new module unless i get an approval from
the website owner, so please, if possible try not to give me that as a
solution. ohh, another thing. When i directly run the interpreter it says
this:
===
[EMAIL PROTECTED] /]# cd /usr
[EMAIL PROTECTED] usr]# cd bin
[EMAIL PROTECTED] bin]# php
Content-type: text/html

PHP Warning:  imap: Unable to initialize module
Module compiled with module API=20001222, debug=0, thread-safety=0
PHPcompiled with module API=20020429, debug=0, thread-safety=0
These options need to match
 in Unknown on line 0
PHP Warning:  ldap: Unable to initialize module
Module compiled with module API=20001222, debug=0, thread-safety=0
PHPcompiled with module API=20020429, debug=0, thread-safety=0
These options need to match
 in Unknown on line 0
PHP Warning:  Unable to load dynamic library '/usr/lib/php4/mysql.so' -
libmysqlclient.so.10: cannot open shared object file: No such file or
directory in Unknown on line 0
===
Please oh please, help me out on this

Mathieu Dumoulin
Programmer analyst for web solutions
www.groupimage.com




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



[PHP] Cannot execute php applications. Problems with required library mysql.so

2003-03-12 Thread Mathieu Dumoulin
Got this problem here.

I have a script i wish to run from a crontab every 2 minutes (Compiles live
stats for a hockey site). This script doesn't run at all in shell mode as an
application but works perfectly fine when called from the web.

Problem is i can't integrate it in the web site like when someone adds an
event or they have to wait like 30 seconds before being able to enter
something else. Talk about live stats if you can only enter 1
shot/hit/faceoff/etc each 30 seconds..

So i HAVE, unless there is a way to do it another way, to run it as a
crontab. My question now is:

- Can i, from a php script from the web start running another script
directly and ignoring the reply...just make it run, thats all and then
redirect the user to some other page while it runs
- Or, can you help me solve my problem about unloadable libraries:

Here is what i can tell from the error i got:
===
[EMAIL PROTECTED] cron_compile_sys]# ./compileMatches.php
Zend Optimizer requires Zend Engine API version 20020429
The installed Zend Engine API version is 20001224

Content-type: text/html

PHP Warning:  Unable to load dynamic library '/usr/lib/php4/mysql.so' -
libmysqlclient.so.10: cannot open shared object file: No such file or
directory in Unknown on line 0
X-Powered-By: PHP/4.0.6
Content-type: text/html

br
bFatal error/b:  Call to undefined function:  mysql_connect() in
b/var/www/sandbox.lhjmq.xl5.net/web/classes/class.mysql.connection.php/b
on line b53/bbr
===
I check my /usr/lib/php4/ folder and it DOES contain the mysql.so file
Second, i looked all over the machine to find other PHP interpretors, i
found several ones all saying version 4.0.6 although when i run phpinfo.php
it says php4.2.2 in the phpinfo response.

http://www.lhjmq.qc.ca/phpinfo.php

Finaly, since it's a production web server, i cannot take the risk to
recompile apache, php or install a new module unless i get an approval from
the website owner, so please, if possible try not to give me that as a
solution. ohh, another thing. When i directly run the interpreter it says
this:
===
[EMAIL PROTECTED] /]# cd /usr
[EMAIL PROTECTED] usr]# cd bin
[EMAIL PROTECTED] bin]# php
Content-type: text/html

PHP Warning:  imap: Unable to initialize module
Module compiled with module API=20001222, debug=0, thread-safety=0
PHPcompiled with module API=20020429, debug=0, thread-safety=0
These options need to match
 in Unknown on line 0
PHP Warning:  ldap: Unable to initialize module
Module compiled with module API=20001222, debug=0, thread-safety=0
PHPcompiled with module API=20020429, debug=0, thread-safety=0
These options need to match
 in Unknown on line 0
PHP Warning:  Unable to load dynamic library '/usr/lib/php4/mysql.so' -
libmysqlclient.so.10: cannot open shared object file: No such file or
directory in Unknown on line 0
===
Please oh please, help me out on this

Mathieu Dumoulin
Programmer analyst for web solutions
www.groupimage.com




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



[PHP] Mailling question

2003-02-28 Thread Mathieu Dumoulin
Allright, we managed to get to send emails thru an SMTP, but now we need to
know which email DID get to the recipient and which didn't. Our smtp class
supports basic error message but as soon as the message is outbound from
this server, which is most oftenly the case, the class always returns
success. Allright we can live with that. But our mass mailing software using
this class needs to keep track of which client of our numerous members gets
the email.

The only solution we though of which is very risky, is to:

Setup a mass mailing account for each client and send emails as if they
where the mass mailer
Then a robot is in charge of scanning the inbox for returned postmaster
messages and parse it to find the error such as unknown user.

The problem is, all pop servers from the recipients anwser with different
email formats and error numbers. Does anyone know how i could fix this
problem. Keep in mind that this is one statistic we have to compile:

Who received and who didn't receive (Not who looked at email or Not, this is
another stats for which we already have the solution)

Mathieu Dumoulin
Web solution Programmer Analyst



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



[PHP] Maximum execution time explanation needed

2003-02-24 Thread Mathieu Dumoulin
Ok, i got this script i run on my server, this script runs exactly 47 secs
or so (45 to 49) each time i run it. I run it from the command line cause
it's going to be a CRON job i'll run every month.

My question is, why after 47 seconds or so does my script end saying:

bFatal error/b:  Maximum execution time of 30 seconds exceeded in
b/var/www/autoexpert/includes/db.php/b on line b69/bbr

This sucks, i did another script that imports data, it takes something like
5 minutes to execute, and it's pretty much the same code, why does this one
end like that with a fatal error while the other goes trough its very long
task of import a whole set of data in 5 minutes.

I'd like to know exactly how PHP calculates that my script ran too much
time. Here is the code in case you need to see it. Please do not fix my code
for me, if there are bugs i will find them, i just want to know how PHP says
it's been 30 seconds.

Mathieu Dumoulin
Web Solutions Programmer Analyst

Code:

#! /usr/bin/php
?php
/*This file is used each month on the 1st day to compile the whole
previous month data for the cars and for the person to which this
post pertains to.*/

//Definition
define('IN_INDEX', 1);

//Connect to the database
include(../includes/config.php);
include(../includes/db.php);

//Open the connection
$db-connect();

//Get the current date
//$curDate = date(Y-m-d);
$curDate = 2003-03-01;

//Get the previous month's complete date
$cur_expl = explode(-, $curDate);
$cur_month = $cur_expl[1];
if($cur_month == 1){
 $prev_month = 12;
 $prev_year = $cur_expl[0] - 1;
}else{
 $prev_month = $cur_month - 1;
 $prev_year = $cur_expl[0];
}
$prev_day = 01;
$prevDate = (string)$prev_year . - . @str_repeat(0, 2 -
strlen($prev_month)) . $prev_month . - . $prev_day;
$prevDateYearOnly = (string)$prev_year . - . 01 . - . $prev_day;

//Echo
echo Running... please wait\n;

//Get all this month's stats
$db-query(SELECT * FROM stats_vehicules_days WHERE day = '$prevDate' AND
day  '$curDate' ORDER BY vehiculeid, stats_vehicules_days);

//Loop and add all lines as needed
while($row = $db-fetch_array(stats_vehicules_days)){
 //Update the line in the stats_vehicules_month
 $db-query(UPDATE stats_vehicules_months SET clicks = clicks +  .
$row[clicks] . , views = views +  . $row[views] .  WHERE vehiculeid =  .
$row[vehiculeid] .  AND month = '$prevDate', updateStats);
 //Get the Info ID for this vehicule
 $db-query(SELECT i.id AS info_id FROM info AS i, annonces AS a, vehicules
AS v WHERE i.id = a.infoid AND a.id = v.annonceid AND v.id =  .
(string)$row[vehiculeid], infoId);
 $infoid_row = $db-fetch_array(infoId);
 //Write the stats for this user
 $db-query(UPDATE stats_info_months SET clicks = clicks +  . $row[clicks]
. , views = views +  . $row[views] .  WHERE infoid =  .
$infoid_row[info_id] .  AND month = '$prevDate', updateStats);
 $db-query(UPDATE stats_info_years SET clicks = clicks +  . $row[clicks]
. , views = views +  . $row[views] .  WHERE infoid =  .
$infoid_row[info_id] .  AND year = '$prevDateYearOnly', updateStats);
}

//Close the connection
$db-close();
?



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



[PHP] Re: Maximum execution time explanation needed

2003-02-24 Thread Mathieu Dumoulin
Thank you, but it doesn'T explain why i can run the other script for 5
minutes without any set_time_limit

i'd like to get a precise explanation on why it's doing it, for the time
being i will use set_time_limit for this script.

Mathieu Dumoulin

Joel Colombo [EMAIL PROTECTED] a écrit dans le message de news:
[EMAIL PROTECTED]
 stick a.

 set_time_limit(XXX);

 at the top of the page
 where XXX is the maximum time u would like it to run. ex... 180 for say 3
 minutes.

 Joel Colombo


 Mathieu Dumoulin [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  Ok, i got this script i run on my server, this script runs exactly 47
secs
  or so (45 to 49) each time i run it. I run it from the command line
cause
  it's going to be a CRON job i'll run every month.
 
  My question is, why after 47 seconds or so does my script end saying:
 
  bFatal error/b:  Maximum execution time of 30 seconds exceeded in
  b/var/www/autoexpert/includes/db.php/b on line b69/bbr
 
  This sucks, i did another script that imports data, it takes something
 like
  5 minutes to execute, and it's pretty much the same code, why does this
 one
  end like that with a fatal error while the other goes trough its very
long
  task of import a whole set of data in 5 minutes.
 
  I'd like to know exactly how PHP calculates that my script ran too much
  time. Here is the code in case you need to see it. Please do not fix my
 code
  for me, if there are bugs i will find them, i just want to know how PHP
 says
  it's been 30 seconds.
 
  Mathieu Dumoulin
  Web Solutions Programmer Analyst
 
  Code:
 
  #! /usr/bin/php
  ?php
  /*This file is used each month on the 1st day to compile the whole
  previous month data for the cars and for the person to which this
  post pertains to.*/
 
  //Definition
  define('IN_INDEX', 1);
 
  //Connect to the database
  include(../includes/config.php);
  include(../includes/db.php);
 
  //Open the connection
  $db-connect();
 
  //Get the current date
  //$curDate = date(Y-m-d);
  $curDate = 2003-03-01;
 
  //Get the previous month's complete date
  $cur_expl = explode(-, $curDate);
  $cur_month = $cur_expl[1];
  if($cur_month == 1){
   $prev_month = 12;
   $prev_year = $cur_expl[0] - 1;
  }else{
   $prev_month = $cur_month - 1;
   $prev_year = $cur_expl[0];
  }
  $prev_day = 01;
  $prevDate = (string)$prev_year . - . @str_repeat(0, 2 -
  strlen($prev_month)) . $prev_month . - . $prev_day;
  $prevDateYearOnly = (string)$prev_year . - . 01 . - . $prev_day;
 
  //Echo
  echo Running... please wait\n;
 
  //Get all this month's stats
  $db-query(SELECT * FROM stats_vehicules_days WHERE day = '$prevDate'
 AND
  day  '$curDate' ORDER BY vehiculeid, stats_vehicules_days);
 
  //Loop and add all lines as needed
  while($row = $db-fetch_array(stats_vehicules_days)){
   //Update the line in the stats_vehicules_month
   $db-query(UPDATE stats_vehicules_months SET clicks = clicks +  .
  $row[clicks] . , views = views +  . $row[views] .  WHERE vehiculeid =

 .
  $row[vehiculeid] .  AND month = '$prevDate', updateStats);
   //Get the Info ID for this vehicule
   $db-query(SELECT i.id AS info_id FROM info AS i, annonces AS a,
 vehicules
  AS v WHERE i.id = a.infoid AND a.id = v.annonceid AND v.id =  .
  (string)$row[vehiculeid], infoId);
   $infoid_row = $db-fetch_array(infoId);
   //Write the stats for this user
   $db-query(UPDATE stats_info_months SET clicks = clicks +  .
 $row[clicks]
  . , views = views +  . $row[views] .  WHERE infoid =  .
  $infoid_row[info_id] .  AND month = '$prevDate', updateStats);
   $db-query(UPDATE stats_info_years SET clicks = clicks +  .
 $row[clicks]
  . , views = views +  . $row[views] .  WHERE infoid =  .
  $infoid_row[info_id] .  AND year = '$prevDateYearOnly',
updateStats);
  }
 
  //Close the connection
  $db-close();
  ?
 
 





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



[PHP] Re: Maximum execution time explanation needed

2003-02-24 Thread Mathieu Dumoulin
Could it be because i fopen the php://stdin stream that i can execute my
script for 5 minutes?

Mathieu Dumoulin

Mathieu Dumoulin [EMAIL PROTECTED] a écrit dans le message de
news: [EMAIL PROTECTED]
 Ok, i got this script i run on my server, this script runs exactly 47 secs
 or so (45 to 49) each time i run it. I run it from the command line cause
 it's going to be a CRON job i'll run every month.

 My question is, why after 47 seconds or so does my script end saying:

 bFatal error/b:  Maximum execution time of 30 seconds exceeded in
 b/var/www/autoexpert/includes/db.php/b on line b69/bbr

 This sucks, i did another script that imports data, it takes something
like
 5 minutes to execute, and it's pretty much the same code, why does this
one
 end like that with a fatal error while the other goes trough its very long
 task of import a whole set of data in 5 minutes.

 I'd like to know exactly how PHP calculates that my script ran too much
 time. Here is the code in case you need to see it. Please do not fix my
code
 for me, if there are bugs i will find them, i just want to know how PHP
says
 it's been 30 seconds.

 Mathieu Dumoulin
 Web Solutions Programmer Analyst

 Code:

 #! /usr/bin/php
 ?php
 /*This file is used each month on the 1st day to compile the whole
 previous month data for the cars and for the person to which this
 post pertains to.*/

 //Definition
 define('IN_INDEX', 1);

 //Connect to the database
 include(../includes/config.php);
 include(../includes/db.php);

 //Open the connection
 $db-connect();

 //Get the current date
 //$curDate = date(Y-m-d);
 $curDate = 2003-03-01;

 //Get the previous month's complete date
 $cur_expl = explode(-, $curDate);
 $cur_month = $cur_expl[1];
 if($cur_month == 1){
  $prev_month = 12;
  $prev_year = $cur_expl[0] - 1;
 }else{
  $prev_month = $cur_month - 1;
  $prev_year = $cur_expl[0];
 }
 $prev_day = 01;
 $prevDate = (string)$prev_year . - . @str_repeat(0, 2 -
 strlen($prev_month)) . $prev_month . - . $prev_day;
 $prevDateYearOnly = (string)$prev_year . - . 01 . - . $prev_day;

 //Echo
 echo Running... please wait\n;

 //Get all this month's stats
 $db-query(SELECT * FROM stats_vehicules_days WHERE day = '$prevDate'
AND
 day  '$curDate' ORDER BY vehiculeid, stats_vehicules_days);

 //Loop and add all lines as needed
 while($row = $db-fetch_array(stats_vehicules_days)){
  //Update the line in the stats_vehicules_month
  $db-query(UPDATE stats_vehicules_months SET clicks = clicks +  .
 $row[clicks] . , views = views +  . $row[views] .  WHERE vehiculeid = 
.
 $row[vehiculeid] .  AND month = '$prevDate', updateStats);
  //Get the Info ID for this vehicule
  $db-query(SELECT i.id AS info_id FROM info AS i, annonces AS a,
vehicules
 AS v WHERE i.id = a.infoid AND a.id = v.annonceid AND v.id =  .
 (string)$row[vehiculeid], infoId);
  $infoid_row = $db-fetch_array(infoId);
  //Write the stats for this user
  $db-query(UPDATE stats_info_months SET clicks = clicks +  .
$row[clicks]
 . , views = views +  . $row[views] .  WHERE infoid =  .
 $infoid_row[info_id] .  AND month = '$prevDate', updateStats);
  $db-query(UPDATE stats_info_years SET clicks = clicks +  .
$row[clicks]
 . , views = views +  . $row[views] .  WHERE infoid =  .
 $infoid_row[info_id] .  AND year = '$prevDateYearOnly', updateStats);
 }

 //Close the connection
 $db-close();
 ?





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



[PHP] Re: emailing a web-page

2003-02-24 Thread Mathieu Dumoulin
What i would actually do is this:

Generate simple HTML code that creates a FRAMESET with only one FRAME point
the source directly on the page you wish to show to the user in the mail.
Here are the good reasons:

1) Updated content cause it stays on the web
2) Small email, no image, not even the real web page is attached
3) No super hard coding to get the links from RELATIVE to COMPLETE
4) Easy to do for anyone, even for you, it's simple.

Mathieu Dumoulin

Neko [EMAIL PROTECTED] a écrit dans le message de news:
[EMAIL PROTECTED]
 Question : When people send you junk e-mails they often have image refs
and
 so forth - does that mean they are using absolute links in the img refs?

 I need to find a way to allow a non-technical user to quickly and easily
 send off a web-page (generated on the fly) in email format, but so far I'm
 still working out the particulars of sending as HTML with additional
 resources (images, stylesheets).

 neko_





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



[PHP] Re: Reading Text file by line

2003-02-24 Thread Mathieu Dumoulin
Depends on what OS you are:

Windows: Search for \n\r (or chr(13) . chr(10))
Unix/linux: Search only for \n (or chr(13))
MAC: Search for only \r (or chr(10))

If you want to READ line by line instead of Exploding your complete content,
use this:

$myLine = fgets($myFilePointer, 1048576)

The 2 problem are that if your line is longer than 1 meg (That means a line
of 1048576 characters long without a EOL) then it will not read everything.
And the 2nd problem is the EOL (\n\r, \n or \r) is kept with the line, so
you have to also implement the code to strip out the \n and/or \r from the
end of line.

Mathieu Dumoulin

Anthony [EMAIL PROTECTED] a écrit dans le message de news:
[EMAIL PROTECTED]
 I need to read a text file by line, if I open the file and use fgets()
then
 it doesn't pick up the EOL corretly.  So I was planning on reading the
whole
 file in with fread() and then breaking it up by EOL characters.  My
question
 is, how do I do it?  What character do I search for in the string?  Anyone
 have a simple example on how to do this?  Thanks.





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



[PHP] read input in console mode

2003-02-06 Thread Mathieu Dumoulin
Hi there,

I found a way to read input from a console mode in linux, very simple open
php://stdin to read from the standard input system. THE PROBLEM is i can't
just read one character it always waits for the user to press enter which is
not what i intended to do.

When i write Please press a key to continue if the user presses anything
else than enter it appears on the screen. and the input ends only when he
presses enter. If you are a C/C++ programmer you can compare that to the cin
 command.

I need something to read only one char at a time if needed!

thank you

Mathieu Dumoulin
Programmer analyste for web solutions



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




Re: [PHP] read input in console mode

2003-02-06 Thread Mathieu Dumoulin
Nope, it returns 1 character from the input buffer after the user presses
enter

sadly, i did try that already!

=P

-

Adam Voigt [EMAIL PROTECTED] a écrit dans le message de news:
[EMAIL PROTECTED]
$f = fopen(php://stdin,r);
$command = fread($f,1);
fclose($f);

Would that not read a single character?

On Thu, 2003-02-06 at 09:41, Mathieu Dumoulin wrote:
Hi there,

I found a way to read input from a console mode in linux, very simple open
php://stdin to read from the standard input system. THE PROBLEM is i can't
just read one character it always waits for the user to press enter which is
not what i intended to do.

When i write Please press a key to continue if the user presses anything
else than enter it appears on the screen. and the input ends only when he
presses enter. If you are a C/C++ programmer you can compare that to the cin
 command.

I need something to read only one char at a time if needed!

thank you

Mathieu Dumoulin
Programmer analyste for web solutions-
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
--
Adam Voigt ([EMAIL PROTECTED])
The Cryptocomm Group
My GPG Key: http://64.238.252.49:8080/adam_at_cryptocomm.asc



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




[PHP] Re: Stupid question, sorry...

2003-02-06 Thread Mathieu Dumoulin
All single quotes around variables or escape characters are written out man!

it's as simple as that.

example you have a variable named $hey and you want to output $hey, you
can't it's gonna replace the content of that string with the value of $hey.

When you put stuff inside ' ' they are not escaped by the system

Mathiue Dumoulin

Chris Boget [EMAIL PROTECTED] a écrit dans le message de news:
021901c2cdf4$4a806d00$[EMAIL PROTECTED]
 Why is it that \n gets translated to a _new line_ when in
 double quotes whereas it's displayed as the literal when
 in single quotes?  I checked out the docs but couldn't
 come up with a definitive answer.  If someone could point
 me to the right page in the docs that explains this, I'd be
 ever so appreciative!

 thnx,
 Chris




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




[PHP] Global variables question

2002-11-10 Thread Mathieu Dumoulin
Hi, i got this project i'm building right now. It basically a core system to
do adminsitrative modules for web sites.

I got tons of classes that get created on call of a function like
sql_setup(), frm_setup(). These functions create the objects from the
classes so they can be used later in other objects...yada yada yada...

Now my thing is, instead of always starting my method of an object with
global sql_server; and global frm_builder, is there a way that these
variables are declared as global automatically, just like i would get
$_GET[], $_POST[] and so on, they are already global. I want to do this to
simplify development since this project is going to be HUGE. And also it
will facilitate debugging as i've been using global at a lot of places and
when you forget one, PHP assumes the creation of a dummy variable messing up
everything.

I'm waiting for an anwser,
thank you

Mathieu Dumoulin
Programmer / Analayst in web solutions
Groupimage Comunications



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




[PHP] mysql_field_flags() problems

2002-08-01 Thread Mathieu Dumoulin

This is a part of my code for my data interfacer class which takes an SQL
RESULT RESOURCE and gets the field from it. Problem is, i can't get the
primary key out nor the auto-increment flag out. Before, the same script (or
so, it was modified but not that part) was working fine. I tried it on
several tables and on several database servers and i still can't get the
PRIMARY or AUTO_INCREMENT flag out. In fact the only flag that is returned
is: NOT_NULL. (When i ECHO the mysql_field_flags(...) i get only notnull).

Furthermore, i can't seem to get the data, that i will check more in detail,
my most important part IS the primary and auto-increment flags.

Thanks in advance if you can find something.

Here is the complete code that you need:

//Execute the query twice to get the fields and a result for the values
$result =
$this-mysql_server-send_result_sql($this-query_builder-generate_select()
, 1);
$fieldlist =
$this-mysql_server-send_result_sql($this-query_builder-generate_select()
, 1);

//get the first row to insert values in the interface
$data = mysql_fetch_array($result);

//Used for the field flag fetching
$curfield = -1;
$fieldcount = mysql_num_fields($fieldlist);

//Loop the data field definition and add the field in the end
for($curfield = 0; $curfield  $fieldcount; $curfield++){
   //Get the current field
   $datadef = mysql_fetch_field($fieldlist, $curfield);

   //Reset the data
   $primary_key = 0;
   $auto_increment = 0;

   //Get all the other params from the field definition
   $fieldname = $datadef-name;
   $sourcetable  = $datadef-table;
   $datatype = constant(MYSQL_NDT_ . strtoupper($datadef-type));
   $fieldvalue = $data[$datadef-name];
   $datasize = $datadef-max_length;

   //Get the field flags and explode them immediatly
   $fieldflags = explode( , mysql_field_flags($fieldlist, $curfield));

   //Check all the field flags
   foreach($fieldflags as $key = $value){
if($value == primary_key){
 $primary_key = 1;
}elseif($value == auto_increment){
 $auto_increment = 1;
}
   }

   //Add the field to the data_interface
   $newint-add_field($fieldname, $fieldvalue, $datatype, $datasize,
$primary, $autoinc, $sourcetable);
}



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




[PHP] Re: How to check if a field is auto increment

2002-07-26 Thread Mathieu Dumoulin

Oh, and also, i need to know how to get the default value...

Btw, i CAN be done, or else, how does phpMyAdmin does it =P

InsaneCoder


 How can i check if a field has auto-increment extra activated on it?

 Thanks





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




[PHP] Calling a function without variable params

2002-07-26 Thread Mathieu Dumoulin

Ok, here i made a function that can accept an unknown number of params.

In fact, it's a data interface for a mysql database, when i call the
object's constructor it is in possibility to pass any number of table names
from 1 to x. Now i got this other class called a data interfacer which sends
a certain number of tables to the data interface constructor. I tried doing:

$interface = new data_interface($table1, eval($table2, $table3, $table4));
$interface = eval(new data_interface($table1, $table2, $table3, $table4));

and various other tries. The thing is i can't know how many tables can be
transfered from the data interfacer to the data_interface. So i could make a
if..elseif...elseif until i reach something like 10 tables but still, it's
not a good practice, i'm sure there is a way to emulate real parameters when
they are needed and skip them in the call if you don't have them.

Can anybody help me out?

InsaneCoder



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




[PHP] Call func with variable num params (Dont confuse with making func variable params)

2002-07-26 Thread Mathieu Dumoulin

Ok, here i made a function that can accept an unknown number of params.

In fact, it's a data interface for a mysql database, when i call the
object's constructor it is in possibility to pass any number of table names
from 1 to x. Now i got this other class called a data interfacer which sends
a certain number of tables to the data interface constructor. I tried doing:

$interface = new data_interface($table1, eval($table2, $table3, $table4));
$interface = eval(new data_interface($table1, $table2, $table3, $table4));

and various other tries. The thing is i can't know how many tables can be
transfered from the data interfacer to the data_interface. So i could make a
if..elseif...elseif until i reach something like 10 tables but still, it's
not a good practice, i'm sure there is a way to emulate real parameters when
they are needed and skip them in the call if you don't have them.

Can anybody help me out?

InsaneCoder



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




Re: [PHP] calling user-defined php functions from a href tag

2002-07-26 Thread Mathieu Dumoulin

Easy

Your form when pressed the button submit will send the data from the form
via post (Which is the best method) to the functions.php with all the
functions. What you need to modify now is that all the input type=radio
need to be modified to FuncToExec name.

When you receive the input of the form, you just verify what $FuncToExec is
and execute the correct function.

?php

if($FuncToExec == joe){
joe();
}elseif(...){
}

... (All functions in your file goes there)...

?

Now what you also want to add is that if your JOE function is to return
something, the IF ELSE calling that thing should intercept the value
returned and this part of the script should either do something with that
value or just redirect the value to another script by GET mode:

header(location: myresultpage.php?result=$result);

There, sorted that out right?

have fun
insanecoder!

Michael [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...


 Hi, Justin.

 Thanks very much for the reponse.
 Yeah, this is a SUPER simplified form of my question, so please don't
 expect it to make sense. Heh.

 Basically, I have a php file with dozens of functions in it. I want ONE of
 them to get called when a link is clicked.

 Currently, I achieve this with the use of HTML forms. My form generates a
 list of options. And the user has to select an option, then click the
 SUBMIT button.

 But I want to make it a one-step process, whereby the user only needs to
 click on the option.

 Of course, you can't achieve this in a form with JavaScript, but the
 JavaScript code won't let me execute a server-side php function
 (obviously).

 And I don't want to just shoot the link off to another page (even though
 that's what it was designed to do). I want to call a very specific
 function.

 Tricky, I know.   :(

 -- Michael

 On Sat, 27 Jul 2002, Justin French wrote:

  Date: Sat, 27 Jul 2002 11:35:23 +1000
  From: Justin French [EMAIL PROTECTED]
  To: Michael [EMAIL PROTECTED], [EMAIL PROTECTED]
  Subject: Re: [PHP] calling user-defined php functions from a href tag
 
  on 27/07/02 12:09 PM, Michael ([EMAIL PROTECTED]) wrote:
 
   ?php
   function joe() {
   $temp1=10;
   $temp2=20;
   $result=$temp1+$temp2;
   echo The result of this function is:  . $result;
   }
   ?
 
  wouldn't that be
 
  return The result of this function is:  . $result;
 
  rather than echo?
 
 
  Anyhoo, you haven't specified HOW you want to communicate the result of
the
  function to the browser.
 
  A HREF is supposed to take you off to another page (amongst other
things),
  which might be what you're after.
 
  JavaScript (*shudder*) is designed to provide client-side actions, so
maybe
  a javascript alert is what you want, or a pop-up window, or who knows
what.
 
  You need to decide what happens, in a story board fashion.
 
 
  Remember, everything in PHP code takes place on the server, BEFORE the
  browser gets it.
 
 
  Example of using JS alert:
 
  HTML
  ?
  function joe() {
  $temp1=10;
  $temp2=20;
  $result=$temp1+$temp2;
  return The result of this function is:  . $result;
  }
  ?
  A HREF=# onclick=javascript:alert('?=joe()?')calculate foo/a
  /HTML
 
  but really, I can't understand why you wouldn't just do:
 
  HTML
  ?
  $result=$temp1+$temp2;
  echo Total: {$result};
  ?
  /HTML
 
  Why do they have to click?
 
 
  You'll have to check all the javascript stuff and maybe massage it,
because
  I haven't tested this, and haven't written much JS in the past coupla
years.
 
 
  Beware of the limitations of relying on javascript for anything though
:)
 
 
  Justin French
 
 
  --
  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] calling user-defined php functions from a href tag

2002-07-26 Thread Mathieu Dumoulin

Then simple,

In your hrefs do:
a href=myfunctions.php?FuncToExec=JoeExecute Joe() function/a

thats all there is to it

InsaneCoder

Michael [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...


 Hmm.

 Hey, Mathieu. Many thanks for the reply. However, I currently AM using a
 form. What I'm trying to get away from, is the two step process:

 1.  pick your option
 2.  click submit

 I'm trying to get a one-step process, where the user can click on a link,
 and that calls the function.

 JavaScript won't work, because it's client side, and can't be used to call
 a server-side php function (unless you tell me some neat trick I don't
 know about yet). See my struggle now?




 On Fri, 26 Jul 2002, Mathieu Dumoulin wrote:

  Date: Fri, 26 Jul 2002 21:46:00 -0400
  From: Mathieu Dumoulin [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Subject: Re: [PHP] calling user-defined php functions from a href tag
 
  Easy
 
  Your form when pressed the button submit will send the data from the
form
  via post (Which is the best method) to the functions.php with all the
  functions. What you need to modify now is that all the input
type=radio
  need to be modified to FuncToExec name.
 
  When you receive the input of the form, you just verify what $FuncToExec
is
  and execute the correct function.
 
  ?php
 
  if($FuncToExec == joe){
  joe();
  }elseif(...){
  }
 
  ... (All functions in your file goes there)...
 
  ?
 
  Now what you also want to add is that if your JOE function is to return
  something, the IF ELSE calling that thing should intercept the value
  returned and this part of the script should either do something with
that
  value or just redirect the value to another script by GET mode:
 
  header(location: myresultpage.php?result=$result);
 
  There, sorted that out right?
 
  have fun
  insanecoder!
 
  Michael [EMAIL PROTECTED] wrote in message
  [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  
  
   Hi, Justin.
  
   Thanks very much for the reponse.
   Yeah, this is a SUPER simplified form of my question, so please don't
   expect it to make sense. Heh.
  
   Basically, I have a php file with dozens of functions in it. I want
ONE of
   them to get called when a link is clicked.
  
   Currently, I achieve this with the use of HTML forms. My form
generates a
   list of options. And the user has to select an option, then click the
   SUBMIT button.
  
   But I want to make it a one-step process, whereby the user only needs
to
   click on the option.
  
   Of course, you can't achieve this in a form with JavaScript, but the
   JavaScript code won't let me execute a server-side php function
   (obviously).
  
   And I don't want to just shoot the link off to another page (even
though
   that's what it was designed to do). I want to call a very specific
   function.
  
   Tricky, I know.   :(
  
   -- Michael
  
   On Sat, 27 Jul 2002, Justin French wrote:
  
Date: Sat, 27 Jul 2002 11:35:23 +1000
From: Justin French [EMAIL PROTECTED]
To: Michael [EMAIL PROTECTED], [EMAIL PROTECTED]
Subject: Re: [PHP] calling user-defined php functions from a href
tag
   
on 27/07/02 12:09 PM, Michael ([EMAIL PROTECTED]) wrote:
   
 ?php
 function joe() {
 $temp1=10;
 $temp2=20;
 $result=$temp1+$temp2;
 echo The result of this function is:  . $result;
 }
 ?
   
wouldn't that be
   
return The result of this function is:  . $result;
   
rather than echo?
   
   
Anyhoo, you haven't specified HOW you want to communicate the result
of
  the
function to the browser.
   
A HREF is supposed to take you off to another page (amongst other
  things),
which might be what you're after.
   
JavaScript (*shudder*) is designed to provide client-side actions,
so
  maybe
a javascript alert is what you want, or a pop-up window, or who
knows
  what.
   
You need to decide what happens, in a story board fashion.
   
   
Remember, everything in PHP code takes place on the server, BEFORE
the
browser gets it.
   
   
Example of using JS alert:
   
HTML
?
function joe() {
$temp1=10;
$temp2=20;
$result=$temp1+$temp2;
return The result of this function is:  . $result;
}
?
A HREF=# onclick=javascript:alert('?=joe()?')calculate
foo/a
/HTML
   
but really, I can't understand why you wouldn't just do:
   
HTML
?
$result=$temp1+$temp2;
echo Total: {$result};
?
/HTML
   
Why do they have to click?
   
   
You'll have to check all the javascript stuff and maybe massage it,
  because
I haven't tested this, and haven't written much JS in the past
coupla
  years.
   
   
Beware of the limitations of relying on javascript for anything
though
  :)
   
   
Justin French
   
   
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
   
   
  
 
 
 
  

[PHP] How to check if a field is auto increment

2002-07-26 Thread Mathieu Dumoulin

I'm doing a class that actually interfaces with a mysql database, so far i
can easily get the type out the values, the names of fields, everything i
need is there except one thing..

How can i check if a field has auto-increment extra activated on it?

Thanks



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




[PHP] Re: OO Programming - get practical

2002-07-23 Thread Mathieu Dumoulin

If i can suggest...

I'm working on a project for the Quebec Junior Major Hockey league and i
found out that objects can be quite usefull in a large scale web application
like this one.

What i am doing is an object that connects to the database and stores
pertinent information into it. Also, i have other objects called collections
which read from the database in an uniform way. My junior programmers here
don't understand the basics of OOP but they do like it, because it
simplifies their work. They just need to know the object methods and
properties, how to use it and they do. They don't even have to do complex
request to the database anymore, all my objects do it for them.

My point is, OOP is great and it INDEED should be pushed much much more into
our common day programming of anything, should it be webapps or normal
executables.

If anyone is interested in developping a package of classes that could
greatly benefit SQL Reading/Writting and Data manipulation i'd be ready to
invest some time into it with other people so we can create a completly
standalone reader/writter class for any situation, table and fields. That
would be great.

(BTW, i'm on php4 and mysql, but welcome to new technologies like
Orable-php and ODBC-php)

Insane Coder
(Or almost insane =P)



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




[PHP] PHP OOP list

2002-07-23 Thread Mathieu Dumoulin

Is there a newsgroup list for PHP and OOP?
It would be great to split up this large topic and create an OOP specific
list.

InsaneCoder



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




[PHP] Re: Filename is nothing

2002-07-23 Thread Mathieu Dumoulin

Check to make sure that your FORM tag has: enc-type=multpart-formdata

i had SO much trouble finding this out. hope it helps ya

InsaneCoder

Liam Gibbs [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Basic scenario. There's really nothing else to tell
 except for that.

 I'm trying to upload a file via a TYPE=FILE control in
 a form. When I press submit, my $uploadedfile is what
 it should be, but my $uploadedfile_name is blank. So
 is my $uploadedfile_size. Any reason?

 __
 Do You Yahoo!?
 Yahoo! Health - Feel better, live better
 http://health.yahoo.com



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




Re: [PHP] Credit card checks?

2002-07-23 Thread Mathieu Dumoulin

Visa starts with 45
Mastercard starts with 51

=P

InsaneCoder

Kristopher Yates [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 You should contact Visa International Service Association to determine
 what constitues a valid credit card number.  Just FYI, a valid format
 is 16 digits; ---.  I believe VISA normally begins with
 41 as the first two digits, however, I am not a Visa Int. agent but I
 am a client. Ultimately, you would need a merchant account to verify its
 validity, AFTER you have verified its format for accuracy.  HTH Kris

 Jas wrote:

 Yeah, I have looked at that class file and I don't want someone elses
 example to use, I want to build my own but have no way of knowing what
makes
 up a valid visa number etc
 Jas
 
 Richard Baskett [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 
 
 Try this:
 
 http://www.AnalysisAndSolutions.com/code/ccvs-ph.htm
 
 Rick
 
 A sense of humor can help you over look the unattractive, tolerate the
 unpleasant, cope with the unexpected, and smile through the
unbearable. -
 Moshe Waldoks
 
 
 
 From: Jas [EMAIL PROTECTED]
 Date: Tue, 23 Jul 2002 12:09:48 -0600
 To: [EMAIL PROTECTED]
 Subject: [PHP] Credit card checks?
 
 Just wondering if anyone has come across the need to develop a class to
 
 
 test
 
 
 a string of numbers based on a credit card type.  If you have where
 
 
 would I
 
 
 be able to get information on what string of numbers is consistent with
 
 
 each
 
 
 of the different credit cards?  Any help would be appreciated!
 Jas
 
 
 
 --
 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




[PHP] Object problem

2002-07-23 Thread Mathieu Dumoulin

I just wrote this message in the wrong list so i'll be short...

I have two classes:
 - mysql_connection
 - data_collection

data_collection REQUIRES a mysql_connection object to work. So i decided to
pass this object in the constructor for the  data_collection, but when i do
so it seems it creates a copy of this object and doesn't use the object i
had previously created...

I tried to do function data_collection($mysql_server){
...
}

But even the  sign like they say to use on the php.net web site doesn't
work, it creates a copy of the object. The only way i found to bypass this
problem is to do:

my_collection-mysql_server = $mysql_server;

which will assign a reference of the mysql_collection object to my
collection, but this means i need to modify something like 45 files of my
web site and also i have to add some init settings because they where done
in the constructor where you needed the connection...

please help me out!!!

InsaneCoder



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




[PHP] What is a mysql link ressource

2002-07-23 Thread Mathieu Dumoulin

Ok guys i got this problem here:

I got a class i made that creates a link ressource for a mysql database.
Stores it inside of itself with different login and password and other
params. Other functions are also available for usage.

When i start this class it connects fine, i can also use it no problem.
BUT...At one point i start referencing this object to other objects so they
can use one and only one connection.

If one of these alternate objects using the connection does an error, i can
NO PROBLEM get the mysql_error() using the link ressource from inside the
alternate object. If i try to get the error from outside that object in my
top level script lets say, i use the one and only mysql_connection object
and it still fails. it's like it doesn't see the error. (I think it's
because the object is being copied, but i looked at my script several times
and i never see any copy.) My only guess is that a mysql_link resssource is
also an object and gets copied or lost somewhere in the middle.

Can anybody tell me what i could do???

(PS i didn't post all the source and the real login info...tehre is too much
to paste and also, it's too improtant to reveal anything)

SOURCE:
class mysql_connection{
 //Variables
 var $mysql_link;
 var $mysql_username;
 var $mysql_password;
 var $mysql_database;

 //Constructor(Establishes the connection)
 function mysql_connection($hostname, $username, $password, $database){
  //Connection to database
  $this-mysql_link = mysql_connect($hostname, $username, $password);
  if(!$this-mysql_link){
   //Display an error message
   exit(Error connecting to mysql server, contact web administrator or try
again later!);
  }
  //Select the database
  if(!mysql_select_db($database, $this-mysql_link)){
   //Display an error message
   exit(Error selecting database on mysql server, contact web administrator
or try again later!);
  }
 }
}

class arenas{

 //System objects
 var $mysql_server;
 var $item;

 //Variables/Arrays
 var $indexes = array();
 var $curindex = 0;

 //Constructor
 function arenas($mysql_server){
  //Store the server
  $this-mysql_server = $mysql_server;
  //Build the index
  $this-refresh();
 }
}

$mysql_server = new mysql_connection(localhost, username, password,
database);

//Get the arenas and the current item
$arenas = new arenas($mysql_server);

//At this point i would do a sql query from inside my arenas class that
would raise an error
//If i echo the error from inside the class using
//echo mysql_error($this-mysql_server-mysql_link);
//it works

//if i echo from the script itself like here it doesn't work
echo mysql_error($mysql_server-mysql_link);

//The first one will show something, the second will never show the error,
any clue why?



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