[PHP] Re: Why the difference in email transit times?

2013-08-13 Thread Ian
On 13/08/2013 16:20, Tedd Sperling wrote:
> Hi gang:
> 
> I'm using the class.phpmailer.php code to send email -- it works neat -- very 
> classy (no pun intended).
> 
> I can send an email from my sperling.com domain and it arrives almost 
> immediately.
> 
> However, when I use the exact same code (except for the FROM address) from 
> kvyv.com (another domain I own), the email literally takes hours (up to 12) 
> to arrive.
> 
> Any idea of why there is a difference of email transit times between the two 
> domains?
> 
> Cheers,
> 
> tedd
> 
> PS: Note, my receiving email addresses are handled by gmail.com.

Hi,

Have a look at the "Received:" headers of each email.  They are in
reverse order.  I.e. the one at the top is the most recently added.

Take into account timezone differences too.


12 hours seems like a very long time for a delay.  I suspect one of the
receiving hosts in the chain employs greylisting, and the sending
network employs many different sending servers (ie like Google) in a
round-robin fashion.  The greylisting server may not be configured to
recognise the many different servers as one 'set'.

All speculation of course ;)

Feel free to send the headers off list and I'll take a look.

Regards

Ian
-- 







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



[PHP] Re: cURL issues posting to an end point

2012-10-11 Thread Ian
On 04/10/2012 15:54, Bastien Koert wrote:
> Hi All,
> 
> I have a page that receives third party data into my app, xml data via
> https post. This works fine and I receive the data as expected. The
> issue I am facing is around posting XML data back as a synchronous
> response to the post I receive. I am using the following code:
> 



> 
>   $result = curl_exec($ch);
>   
>   curl_close($ch);
>   // Print CURL result.
>   echo $ch_result;
> }
> 
> 
> The endpoint recipient says they are not receiving the data and I am
> at a loss to figure out why. Any insight would be appreciated.
> 
> Thanks,
> 
Hi,

Try adding some error checking before and after the curl_exec() call:

// Check for an error
if(curl_errno($ch)>0){
print "Error creating curl object: Err Number:".
curl_errno($ch). " ,Description:" . curl_error($ch);
}

// Execute request
$result = curl_exec($ch);

// Check for an error again
if(curl_errno($ch)>0){
print "Error executing query: Err Number:". curl_errno($ch).
", Description:" . curl_error($ch));
}

It may also be wise to increase your time out whilst testing, just in case.


Regards

Ian
-- 



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



[PHP] Re: How to limit source IP in PHP

2012-09-18 Thread Ian
On 14/09/2012 20:08, Curtis Maurand wrote:
> On 9/14/2012 7:20 AM, Ian wrote:
>> On 12/09/2012 14:53, Tonix (Antonio Nati) wrote:
>>> Is there a way to force a PHP script to bind to a prefixed IP?
>>>
>>> Actually, while you can assign more IPs to Apache for listening,
>>> assigning domains to specific IPs, it looks like any PHP script can
>>> freely choose which IP to bind. Instead I'd love some domains are
>>> permitted to open connections only from the domain IP.
>>>
>>> In FreeBSD I do it easily, setting up dedicated jails for domains. But
>>> how to do it simply using PHP on Linux?
>>>
>>> Regards,
>>>
>>> Tonino
>> Hi,
>>
>> I think its been established now that this cannot be done by any php
>> configuration so you will have to use other methods.
>>
>>
>> You could configure iptables to only allow outgoing packets from
>> specific IPs using the 'owner' module:
>>
>> http://www.netfilter.org/documentation/HOWTO/packet-filtering-HOWTO-7.html
>>
>>   (search for 'owner').
>>
>>
>> There is also SELINUX.
>>
>>
>> Or you could look at container based virtualisation like OpenVZ.
>>
>>
>> Regards
>>
>> Ian
> 
> 1. |if (function_exists('stream_context_create') &&
>function_exists('stream_socket_client')) {|
> 2. |$socket_options = array('socket' => array('bindto' => '192.0.2.1:0'));|
> 3. |$socket_context = stream_context_create($socket_options);|
> 4. |$socket = stream_socket_client('ssl://xmlapi.example.org:9090',
>$errno,|
> 5. |$errstr, 30, STREAM_CLIENT_CONNECT, $socket_context);|
> 6. |} else {|
> 7. |$socket = @fsockopen( "ssl://xmlapi.example.org" , 9090 , $errno ,
>$errstr , 30 );|
> 8. |}|
> 
> Google is your friend.
> 
> 
Hi Curtis,

I am suffering from sleep deprivation due to a new family addition and I
fail to see how your code will prevent a malicious user from binding to
an IP that I do not want him to.  It appears to be an example of how to
bind to an IP, not how to prevent it.

Could you please explain?

Regards

Ian
-- 





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



[PHP] Re: How to limit source IP in PHP

2012-09-14 Thread Ian
On 12/09/2012 14:53, Tonix (Antonio Nati) wrote:
> 
> Is there a way to force a PHP script to bind to a prefixed IP?
> 
> Actually, while you can assign more IPs to Apache for listening,
> assigning domains to specific IPs, it looks like any PHP script can
> freely choose which IP to bind. Instead I'd love some domains are
> permitted to open connections only from the domain IP.
> 
> In FreeBSD I do it easily, setting up dedicated jails for domains. But
> how to do it simply using PHP on Linux?
> 
> Regards,
> 
> Tonino

Hi,

I think its been established now that this cannot be done by any php
configuration so you will have to use other methods.


You could configure iptables to only allow outgoing packets from
specific IPs using the 'owner' module:

http://www.netfilter.org/documentation/HOWTO/packet-filtering-HOWTO-7.html
 (search for 'owner').


There is also SELINUX.


Or you could look at container based virtualisation like OpenVZ.


Regards

Ian
-- 




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



[PHP] Re: How to best set per-site PHP session storage under suPHP/WordPress?

2012-08-13 Thread Ian
On 13/08/2012 06:01, Philip Amadeo Saeli wrote:
> I'm administering WordPress sites under suPHP on a CentOS LAMP server
> and would like to know how I can set PHP to keep the session files under
> the WP user's dir without having do duplicate the entire php.ini file
> for each WP site while still maintaining adequate security.  The
> problems I'm encountering are that, AFAICT, I have basically two
> choices:
> 
>  1. Use the suPHP "suPHP_ConfigPath" to set the path to a
> per-site php.ini file containing a "session.save_path"
> directive.
> 
>  2. Put php.ini files with the "session.save_path" directive
> within the WP dir hier.
> 
> The problems with the above two options (I have found no other options
> so far) are that, for the former, the system php.ini file is not read so
> the per-site php.ini file(s) have to duplicate most if not all of what's
> in the system php.ini file; this is for each WP site (if not a WP Net
> (AKA WPMU) install); and for the latter, -any-and-every- subdir in the
> WP dir hier that has code that may reference the PHP session must have
> its own php.ini file in it.  Either way it becomes a significant
> maintenance problem, especially once there are more than one or two
> such sites.
> 
> I have not been able to find much documentation on this, either in the
> PHP site or in the various help forums.  I've searched quite extensively
> and have run some tests of my own using phpinfo.php to see how things
> are set.
> 
> I do not desire to open up file permissions to bypass this PHP settings
> issue altogether due to security concerns (though I do wish an answer
> could be so simple).
> 
> What's canonical in such a case?  If nothing, are there any other
> alternatives?  My desired solution would be to be able to put one
> php.ini (or equivalent) file per site that would contain the needed
> directive which would be merged with the settings from the system
> php.ini, overriding only the session.save_path, but, AFAICT, PHP does
> not seem to allow this.  Any other ideas?
> 
> Thanks!
> 
> --Phil
> 
> 

Hi,

You can add php.ini variables to the Apache Virtual Host section for
each site, for example:


php_admin_value session.save_path "/path/to/new/session/folder"

[http://php.net/manual/en/configuration.changes.php]


This will override the save path for each site you add it to, but all
other values will be picked up from the system default.


You must make sure the Apache user has write access to the new folder.

Regards

Ian
-- 



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



[PHP] Re: How to write and read serial or parallel port

2012-07-27 Thread Ian
On 26/07/2012 13:37, Alex Nikitin wrote:



> Real question is
> why in the world would you want to use PHP for this to begin with.



Hi,

I cannot speak for the OP, but personally I am doing this so I can hook
up to a web application and re-use existing code.

Regards

Ian
-- 


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



[PHP] Re: How to write and read serial or parallel port

2012-07-26 Thread Ian
On 26/07/2012 11:12, viper wrote:
> hi all!
> 
> is it possible to write and read data on a COM or LPT port?
> is there any function or class in PHP?
> 
> anyone has already done something similar?
> 
> thanks,
> viper
> 

Hi,

There is a class here:

php-serial
http://code.google.com/p/php-serial/source/browse/trunk/

I will be trying this myself tonight as I need to hook up to an arduino
and retrieve some sensor readings.

Regards

Ian
-- 



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



[PHP] Re: slicing and dicing strings

2012-06-28 Thread Ian


> RTFM is not sage words; if you don't want to help me please don't waste
> the bandwidth.


Hi,

Seeing as you are using Windows, why not download the manual as a handy
Windows Help File (CHM), that way you wont waste bandwidth online every
time you get stumped.

http://www.php.net/download-docs.php

I recommend the version with user notes as there are also lots of great
examples / comments included too.


There are also CHM readers for other operating systems (including
mobiles), so no excuse for not Reading The Fine Manual any more.

Regards

Ian
-- 

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



[PHP] Re: make error

2012-03-23 Thread Ian
On 23/03/2012 16:58, Asher Wong wrote:
> I use php-5.4.0.tar.bz2 and MySQL-5.5.21-1.el6.src.rpm in CentOS 6.2. But I
> can find the MySQL headers in the MySQL source I used. Is there anything
> wrong with my installing MySQL?

Hi,

You can just install the mysql headers via the devel package if you
don't need the server:

#   yum install mysql-devel


If you want to find where they were installed use:

#   find / -name mysql.h

Regards

Ian
-- 



> 
> 
> 
>> 2012/3/23 Daniel Brown 
>>
>>> 2012/3/23 黄昭源 :
>>>> Hello, I have a problem.
>>>> When I configure php with the parameter --with-mysql=/usr/local/mysql
>>> and
>>>> make, some errors happen. Below is the errors:
>>>> ext/mysql/php_mysql.c:995: undefined reference to `_mysqlnd_init'
>>>> ext/mysql/php_mysql.c:1012: undefined reference to `mysqlnd_connect'
>>>> ext/mysql/php_mysql.c:876: undefined reference to `_mysqlnd_init'
>>>> ...
>>>> and so on.
>>>> Is there someone also come across this? Can anyone help me? Thanks!
>>>
>>> Sounds like you're missing the MySQL headers from the source
>>> library.  You can either download the full source or install just the
>>> headers via your system's package manager.  If you need more help, let
>>> us know what distribution you're using.
>>>
>>> --
>>> 
>>> Network Infrastructure Manager
>>> http://www.php.net/
>>>
>>
>>
>>
>> --
>> 黄昭源(Asher Wong)
>> *Best Wishes To You!*
>>
>>
> 
> 



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



[PHP] Re: Time zone in date function

2012-01-31 Thread Ian
On 31/01/2012 01:55, Ron Piggott wrote:
> 
> On my clients account when I use “echo date(‘D, d M Y H:i:s');” the output is 
> 5 hours ahead of us.  How do I change it to my local time?  Is there a way to 
> specify “Eastern” time zone?
> 
> I expect this would work:
> 
> echo date(‘D, d M Y H:i:s' , ( strtotime( date(‘D, d M Y H:i:s') – 21600  ) ) 
> );
> 
> I would prefer to specify Eastern time, so if the web host changes a server 
> setting it will remain in Eastern time zone.  Ron

Hi Ron,

I use this function to get the current time in a particular timezone:

format("Y-m-d H:i:s")));
}
?>

Example:



Regards

Ian


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



[PHP] Re: PHP 5.3.6 Dates

2011-12-12 Thread Ian
On 12/12/2011 16:56, Floyd Resler wrote:
> If this was already discussed I apologize for the duplicate question.  For 
> some reason dates of -00-00 get converted to 11/30/-0001 with the date 
> function.  Is this be design or a bug?
> 
> Thanks!
> Floyd
> 
> 

Hi,

In the past I have noticed that zero used in date functions causes a
subtraction.  In this case it is probably working like this (all
speculation!)

Start with 1 Jan 

Take away 1 Month gives:

31 Nov -0001 (not valid though)

Take away 1 day

30 Nov -0001

I'm sure someone with more knowledge of the internals can explain this
better.

Regards

Ian
-- 





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



[PHP] Re: Compile PHP with MySQLi (With MySQL on a remote server)

2011-10-13 Thread Ian
On 13/10/2011 13:29, Nick Khamis wrote:
> Hello Everyone,
> 
> I am trying to compile php from source using the following config:
> 
> ./configure --prefix=/usr/local/php
> --with-apxs2=/usr/local/
> apache/bin/apxs
> --with-config-file-path=/usr/local/php
> --with-mcrypt=/usr/local/bin/mcrypt --with-mysqli
> --with-gettext=./ext/gettext --with-pear
> --with-libxml-dir=/usr/include/libxml2 --with-zlib --with-gd
> --enable-pcntl
> 
> Note the mysqli without pointing to /usr/local/mysql/bin/mysql_config.
> The problem is MySQL is not installed on the machine, it is actually
> installed on another server.
> 
> MySQLi Suport:
> 
> mysqli
> MysqlI Support  enabled
> Client API library version  5.1.49
> Active Persistent Links 0
> Inactive Persistent Links   0
> Active Links0
> Client API header version   5.1.49
> MYSQLI_SOCKET   /var/run/mysqld/mysqld.sock
> 
> Directive   Local Value Master Value
> mysqli.allow_local_infile   On  On
> mysqli.allow_persistent On  On
> mysqli.default_host no valueno value
> mysqli.default_port 33063306
> mysqli.default_pw   no valueno value
> mysqli.default_socket   no valueno value
> mysqli.default_user no valueno value
> mysqli.max_linksUnlimited   Unlimited
> mysqli.max_persistent   Unlimited   Unlimited
> mysqli.reconnectOff Off
> 
> The machine I compiled PHP on does not have mysqli.so, and so I am
> recieving the "fatal call to undefined function mysql_connect()"
> error. Can someone tell me how to compile php from source with mysql
> support, but actually mysql is installed on a different server?
> 
> Can I download a precompile mysqli anywhere? The PHP version is 5.1.49
> as noted earlier.
> 
> Thanks in Advance,
> 
> Nick
> 

Hi Nick,

You only need the mysql development libraries to compile mysql/mysqli
support into php.

If you are on an rpm based system use (Red Hat / CentOS / SuSE etc):

yum install mysql-devel

There may be other dependencies required to install this, but yum should
tell you what they are.


If you are using a different package manager then google will be able to
help.


Regards

Ian
-- 






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



[PHP] Re: Secure data management

2011-10-07 Thread Ian

On 07/10/2011 05:46, Govinda wrote:

Hi everyone


I have read many many articles and blog posts in the last few days to bolster my (still mostly 
newbie) understanding of the factors that play in to preventing various methods of SQL injection 
prevention.. and by now I am well aware that most everyone (expert) here says prepared statements 
are the most secure method of (string hacking) SQL-injection prevention.. even to the point of 
saying that one common (and at least previously-popular) alternative 
"mysql-real-escape-string" is "..silly and technically insecure..".

I am learning and using the CodeIgniter (CI) framework for my current project and, not 
wanting to leave myself vulnerable, I read posts on the CI forum on this topic, to find 
out if I could (or needed) to use prepared statements in CI.. and I read one forum thread 
where one dev shows how to hack the core system of CI so that it can use PDO (for 
prepared statements) instead of the built-in ActiveRecord (or "Query Bindings") 
which apparently rely on mysql-real-escape-string.  In that thread, the debate goes back 
and forth, as it does in other threads.. and while the sentiment that prepared statements 
are better because they remove the need to keep being ahead of the char-escaping chase... 
 I never did see any example of *how* mysql-real-escape-string fails.  The only thing I 
ever read that does show mysql-real-escape-string possibly failing is in the example in 
this article:

http://shiflett.org/blog/2006/jan/addslashes-versus-mysql-real-escape-string

or rather an article referred to there, here:
http://ilia.ws/archives/103-mysql_real_escape_string-versus-Prepared-Statements.html


Hi,

Please bare in mind that the above example uses the mysql object, not 
mysqli (the improved mysql extenstion).  The above attack doesn't work 
in mysqli (at least not in my setup!).  There is also the issue of which 
character set is used by mysqli_real_escape_string.  To be sure issue 
the mysqli_set_charset() call after connecting to the db.




With regards to procedure in MySQL, there is one gotcha that caught me 
out.  There is no way to ALTER a procedure, you must DROP and reCREATE 
it again.  This is fine in most GUIs such as Heidi SQL, as all the work 
is done for you, but you must realize that when you issue the DROP 
command it also DROPS any permissions you have on that procedure.


So to alter a procedure you must DROP, CREATE and then re-create the 
permissions.  If you have a replicated setup with multiple servers and 
multiple web sites accessing them, this can be allot of permissions to 
re-apply.




In web programming (or any other sort) you must ALWAYS assume that any 
input is malicious. Using this principle you can then build secure 
applications.


For example, the above article takes the $_POST input without any 
validation.  In this case it is a username.  On my sites I tell users 
when registering that their username can only contain certain 
characters.  If any other characters are supplied I strip them out.


I can then pass data to mysqli_real_escape_string knowing that there 
will be no multi-byte characters in there to trip it up.


The same goes for other input, validate it all. There are built in 
functions to do this for you [1], or you can build your own.


It is not just input to watch out for, you must also Escape your output 
to mitigate Cross Site Scripting (XSS)[2] and other attacks.



There are many automated tools out there to help you test your 
applications.  You wont know its breakable unless you try to break it! 
And if you don't, others will.



I suggest you go to the OWASP site [3] (The Open Web Application 
Security Project) and have a look around.


Regards

Ian
--

[1] http://php.net/manual/en/ref.filter.php
[2] http://en.wikipedia.org/wiki/Cross-site_scripting
[3] https://www.owasp.org/index.php/Main_Page

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



[PHP] Re: Stop PHP execution on client connection closed

2011-09-13 Thread Ian
On 13/09/2011 09:01, Marco Lanzotti wrote:
> Il 13/09/2011 09:39, vikash.i...@gmail.com ha scritto:
>>
>> You can use ob_start() to start output buffering and ob_end_flush() to send
>> some data in the middle of script  - that way  your php script will send
>> some data to the client earlier than finishing execution and hence detect
>> the aborted connection.
> 
> The question is: how can I send data to client until I'm waiting for
> query execution? PHP thread support is not available in Apache enviroment.
> 
> Bye,
> Marco
> 

Hi Marco,

You may have to think of this problem a different way.


How about about creating a job queuing system to handle the long running
database queries.  You will have to break it down into steps:



User initiatives Query via AJAX call.

System receives query and adds it to queue, return status of 'Added to
queue'

System daemon monitors job queue and runs / records status / stores
results of jobs.

Background process on web page monitors job status via AJAX calls and
alerts user when complete.



On linux systems, The pear module 'System Daemon' is very good for job
queues and easy to install:

[http://pear.php.net/package/System_Daemon]



Hope this helps.

Ian
-- 




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



[PHP] Re: DateTime using DateTimeZone Timestamp problem

2011-04-05 Thread Ian
On 05/04/2011 10:11, Simon J Welsh wrote:
> On 5/04/2011, at 3:35 AM, Ian wrote:
> 
>> Hi,
>>
>> I have a problem using the php built in classes DateTime and DateTimeZone.
>>
>> The idea behind the following code is to return the timestamp for the
>> current time in Singapore (or other places).  What it actually returns
>> is the timestamp for the local system. Other formatted dates appear to
>> return correctly, which is why I am puzzled.
>>
>> I am using the latest php 5.3.6 compiled from source on a OpenVZ CentOS
>> container. All packages are up to date.
>>
>> Am I doing something wrong or is this a bug?
>>
>> I can workaround this problem my parsing the correctly formatted date
>> using strtotime() but I would like to know what's going on.
>>
>>
>>
>> This is the output of the script:
>>
>>  Current time in Asia/Singapore is 2011-04-04 23:32:36
>>  Timestamp for Asia/Singapore is 1301931156
>>  Date created from previous timestamp is 2011-04-04 16:32:36
>>
>> The code is :
>>
>> >
>> $timezone="Asia/Singapore";
>>
>> # Create Timezone object
>> $remote_timezone = new DateTimeZone($timezone);
>>
>> # Create datetime object
>> $remote_time = new DateTime("now" , $remote_timezone);
>>
>> # Print the date
>> print "Current time in {$timezone} ";
>> print "is {$remote_time->format("Y-m-d H:i:s")}";
>>
>> # Print the timestamp
>> print "Timestamp for {$timezone} ";
>> print "is {$remote_time->format("U")}";
>>
>> # Get the timestamp and create a date from it
>> $timestamp = (int)$remote_time->format("U");
>>
>> # Show the formatted date created from timestamp
>> print "Date created from previous timestamp is ";
>> print date("Y-m-d H:i:s",$timestamp)."";
>>
>> ?>
> 
> May I suggest including the timezone in your date format (O or e)? It may 
> show the two date strings to be equivalent.
> 

Hi,

Found the problem:


Unix timestamps are a moment in time and so timezones have no influences
on them. They count the number of seconds since 1970-01-01 00:00 *UTC*

See: http://en.wikipedia.org/wiki/Unix_time


So the timestamp will always be the same no matter which timezone.
I will use by workaround to get the expected timestamp for use in
comparisons.

Regards

Ian
-- 




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



[PHP] Re: DateTime using DateTimeZone Timestamp problem

2011-04-05 Thread Ian
On 04/04/2011 18:02, Ashley Sheridan wrote:


> 
> What do you mean it only returns the timestamp for the local system? Did
> you want PHP to know what time the visitors are on? PHP won't know about
> that, all you can do is set the timezone for the script based on some
> information you're receiving from a clients machine, otherwise PHP won't
> know, because it's only run on the server and doesn't know about the
> client machines? Is this what you're trying to do, or did I
> misunderstand?
> 
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk

Hi,

I want the code to return the timestamp for the current time in
Singapore.  The format command returns different result if the 'U' for
timestamp is specified.  It also returns the same (wrong) result for
DateTime::getTimestamp() as well.

The clients are booking entry into a place at a specific time, for
example 7am in Singapore on the 12 April. Clients can book right up to
the entry time (if there is space available).  I want to make sure they
are not trying to book in the past.

The booking system is in the UK but clients can book from anywhere.  I
cannot rely on them having the right time on their systems (or being in
the right place). Plus this would mean relying on client supplied data,
which is a no-no ;)

I have previously used a gmt offset, which was good enough as there are
not that many people who book close to the entry time.  But now its time
to improve this and use proper time zone info which can change without
my input.


If no-one can find a problem with my code I will submit it as a bug.

Thanks

Ian
-- 





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



[PHP] DateTime using DateTimeZone Timestamp problem

2011-04-04 Thread Ian
Hi,

I have a problem using the php built in classes DateTime and DateTimeZone.

The idea behind the following code is to return the timestamp for the
current time in Singapore (or other places).  What it actually returns
is the timestamp for the local system. Other formatted dates appear to
return correctly, which is why I am puzzled.

I am using the latest php 5.3.6 compiled from source on a OpenVZ CentOS
container. All packages are up to date.

Am I doing something wrong or is this a bug?

I can workaround this problem my parsing the correctly formatted date
using strtotime() but I would like to know what's going on.



This is the output of the script:

Current time in Asia/Singapore is 2011-04-04 23:32:36
Timestamp for Asia/Singapore is 1301931156
Date created from previous timestamp is 2011-04-04 16:32:36

The code is :

format("Y-m-d H:i:s")}";

# Print the timestamp
print "Timestamp for {$timezone} ";
print "is {$remote_time->format("U")}";

# Get the timestamp and create a date from it
$timestamp = (int)$remote_time->format("U");

# Show the formatted date created from timestamp
print "Date created from previous timestamp is ";
print date("Y-m-d H:i:s",$timestamp)."";

?>



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



[PHP] Re: Acentos en tpl

2011-03-18 Thread Ian
On 18/03/2011 10:34, Richard Quadling wrote:
> 2011/3/17 Lorena Monroy O. :
>> Hola a todos
>> Tengo un formulario que tiene dos paneles (.tpl), el cual maneja variables 
>> que vienen de php con la funcion setVariable, pero en el panel del menu me 
>> carga las tildes correctamente y a la derecha me las carga como un rombo con 
>> interrogación. Manejo Firefox y probe cambiando la configuración de 
>> caracteres de UTF-8 a Occidental, pero a la izquierda se ve mal y a la 
>> derecha se ve bien.
>> Si modifico en el codigo por ó ahi se ve bien, pero en otros combos no... 
>> como puedo hacer que en ese tpl se vea bien sin modificarlo desde el codigo.
>> Gracias
>>
>>  Lorenita   Ing. Electrónica U. Bosque Ing. de Sistemas U. Bosque   
>> Especialista en Telecomunicaciones Móviles U.Distrital
>>
>>
>>
> 
> Please use English.
> 
> But translated by GMail ...
> 
> "Hi all
> I have a form that has two panels (. Tpl) which handles variables that
> come setVariable php function, but I panel menu loads correctly and
> the right accents to me like a diamond loaded with question marks.
> Firefox and probe handling changing the charset of UTF-8 to Western,
> but the left is wrong and right is right.
> If I edit in the code or there is fine, but in other combos do not ...
> as I can do that in the tpl look good without modification from the
> code.
> Thanks
> 
> Electronics Engineer Lorenita U. Systems Engineer Forest U. Mobile
> Specialist Forest U. District
> "
> 
> Are both TPL files encoded to use UTF-8? PHP will not convert the
> encoding of a file automatically.
> 
Hi,

Also make sure the web server is sending out the correct character encoding.

With Apache this can be done by adding the following line to the
httpd.conf file and restarting the service:

AddDefaultCharset UTF-8


Regards

Ian
-- 




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



[PHP] Re: PHPmailer.. best way to send to many recipients?

2010-12-21 Thread Ian
On 20/12/2010 21:33, Govinda wrote:
> followup question, please see below the OP:
> 
>> I just started using PHPmailer for one project that requires SMTP
>> authentication (if I said that right).. and all is well.. but I want
>> to ask now before it might get outta hand later:
>>
>> How many comma-delim'ed addresses can I stuff in $BCC_recipients
>> before I have problems (need to restructure the design)?
>>
>> --
>> require("php_inc/class.phpmailer.php");
>> $mail = new PHPMailer();
>> $BCC_recipients = "x...@host.com,y...@server.com"; // <---just an example
>> $arrBCC_recipients = explode(",", $BCC_recipients);
>> foreach ($arrBCC_recipients as $email2stuffInBCC) {
>> $mail->AddBcc($email2stuffInBCC);
>> }
>> if(!$mail->Send()) { // problem 
>> --
>>
>> For now there will be less than 100 Bcc recipients.. but later, more. 
>> I don't know if/when it will ever grow past 1,000.
> 
> I see from reading on a PHPmailer list that the main concern people
> expressed from this (above) approach is to not go over limits set by the
> host/server as to how many emails can go out before being marked as
> spam.  OK, understood.

> Here I am just asking about the code.  I mean does it make any
> difference in terms of code reliability whether I loop on $mail->Send()
> -versus- looping on/concatenating the Bcc addresses?

Hi,

I regularly use PHPMailer to send out a mailshot to two batches of 5
and had no problems at all.

I would not use BCC.  Just set the recipient, send the email, then use
the ClearAllRecipients() function and start again.

We do other things like set a custom MessageID for tracking bounces and
auto unsubscribing during this process as well.

I also do this from the command line so I don't have to worry about
timeouts / apache memory issues etc.  But as long as you're aware of
these problems then you can set the values appropriately.

Regards

Ian
-- 

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



[PHP] Re: read smb drive

2010-11-05 Thread Ian
On 05/11/2010 16:18, Steve Staples wrote:
> On Fri, 2010-11-05 at 10:06 -0600, Nathan Nobbe wrote:
>> On Fri, Nov 5, 2010 at 9:48 AM, Steve Staples  wrote:
>>
>>> Hey guys (and gals)
>>>
>>> I am writing something that needs to connect to a SMB server... can this
>>> be done easliy?
>>>
>>> I copied a sample code from php.net that used the system() command and
>>> mounted the SMB to a /mnt/tmp partion, and technically, it works the
>>> problem is, is that mount has to be run as root...
>>>
>>> is there a way to put the "mount/unmount" commands into an allowed
>>> command?   i supposed, the other problem is, is waht if this is on a
>>> windows machine?
>>>
>>> i dont really want to mess with permissions too much, since this will
>>> have to be portable from linux to windows...   any help would be
>>> appreciated...
>>>
>>
>> is there any reason the php application code has to be responsible for
>> mounting the network drive?
>>
>> typically this is an os-level responsibility.
>>
>> -nathan
> 
> this is true, but i am looking at mounting it, reading the contents,
> maybe moving a file to it, or renaming a file... and then closing the
> smb share.
> 
> i have thought abotu making it a requirement on the users end to have
> the directory ready for the application... but thought also about maybe
> giving them the option to connect to it and do what it has to do, then
> close it... 
> 
> i've been doing it the second way, but was wondering if the first was a
> viable option or not.
> 
> Steve
> 
> 
Hi,

To do this without giving your web site root permissions you will have
to split out the required actions.

You could have a php daemon running as root which periodically checks if
the share needs mounting. The trigger could be many things, like the
existence of a file or database record.

You can then have the web site create the file or database record when
it needs the share mounting and then wait for the mount to appear.


I have used the Pear module System_Daemon[1] to do this in the past,
very easy to use.

[1] http://pear.php.net/package/System_Daemon

Regards

Ian

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



[PHP] Re: handing over data between two PHP connections

2010-07-19 Thread Ian
On 19/07/2010 12:21, Tobias Mueller wrote:


> My question is: can this be done without a database? Can one PHP instance 
> (thread, process, ...) hand over data to another PHP instance? 
> 
> 
> (Actually there is an Apache Server that executes PHP scripts. Typical LAMP 
> configuration.)

Hi,

You will have to store the data somewhere that both php processes can
read.  You are currently using a database but you could also use:

The File System
Shared Memory Functions [http://php.net/manual/en/ref.shmop.php]
Memcache [http://php.net/manual/en/book.memcache.php]

I'm sure there are other ways as well but it depends on how portable you
want the system to be.

Regards

Ian
-- 




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



[PHP] Re: protecting email addresses on a web site

2010-06-15 Thread Ian
On 14/06/2010 22:51, Ashley Sheridan wrote:



> It's not my requirement, it's been a legal requirement in the UK for 3
> years now.
> 
> http://www.calmdesign.co.uk/articles/Website_legal_requirements/?id=16 
> 
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk

Hi,

Further to this the actual regulation is here:

http://www.opsi.gov.uk/si/si2002/20022013.htm

The relevant line from this:

6(c) the details of the service provider, including his electronic mail
address, which make it possible to contact him rapidly and communicate
with him in a direct and effective manner;



It must be stressed that these laws were written before spam became 90%+
of all email communication (2002). So I suspect it could be argued that
a contact form can be allowed to bypass your normal email spam checking
and is therefore a quicker way to communicate effectively.

IANAL ;)

Regards

Ian
-- 

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



[PHP] Doing dynamic routing for an office

2010-03-11 Thread Ian
Hi,

I have had a weird request as a project and that is to build a system where
the clients can put down their office plans into a system and based on where
you are in the buliding (either via defined kiosks or mobile dropdown
filters) it will print out directions on how to get somewhere within that
building. Now, to do it from a fixed location is okay - that could just be a
manual input for each building, but for the variable start point I have no
idea how to do it.

To explain in another way:
* You enter one of the clients offices - you walk up to the touch screen
kiosk and say you are looking to go to Mr Awesomes office. The system then
says, okay - head to the elevators on your right, go to the eighth floor,
turn right walk to the end of the passage and the office is on your left.
This part is easy - the following isnt.
* You are new to the company. You are having a smoke break in a smoking room
and remember you have a meeting. You logon to a mobile site from your phone
(or from your workstation) and you are presented with some filtering options
to pin point where you are (since we cant use GPS here), you then again say
you need to go to Mr Awesomes offices and the system works out that you need
to exit the smoking room left, second passage way right, first left, into
the elevators, up 2 floors, right out the elevators and walk to the end of
the passage and office is on your left.

Any ideas how I could do this easily? The front end isnt a problem, its the
processing behind it actually working out the route. Hope my description is
clear enough and sorry if this has been discussed before - I have no idea
what to search for :)

Thanks
Ian


[PHP] Re: Help with exec.

2010-03-03 Thread Ian
On 03/03/2010 13:01, Paul Halliday wrote:
> I need to pipe some data to an external application.
> 
> I have this:
> 
> while ($row = mysql_fetch_array($theData[0])) {
> $src_ip[] = $row[0];
> $dst_ip[] = $row[1];
> $sig_desc[] = $row[2];
> 
> $rec ++;
> if ( $rec == $recCount ) {
> break;
> }
> }
> 
> for ($i = 0; $i < sizeof($src_ip); $i++) {
> $tmpResult[] = "$sig_desc[$i],$src_ip[$i],$dst_ip[$i]\n";
> }
> 
> 
> The external program is called like:
> 
> cat results.csv | theprogram outputfilename
> 
> Is there a way mimic this w/o outputting $tmpResult to a file first?
> 
> Thanks.
> 

Hi,

I have used this code to feed data to gpg and read back the encrypted
result, Im sure you can adapt it to your needs.

function Encrypt($data){

# http://www.theoslogic.com/scripts/php-gpg/

$gpg_command="/usr/bin/gpg $parameters";

$errLog = "/tmp/errors.log";

$dspecs = array(
0=>array("pipe", "r"),
1=>array("pipe", "w"),
2=>array("file", $errLog, "a")
);

$encrypted="";
$procdata="";

$gpgproc = proc_open($gpg_command, $dspecs, $pipes);

if (is_resource($gpgproc)) {
fwrite($pipes[0], $data);
fclose($pipes[0]);

while($procdata = fgets($pipes[1], 1024)) {
$encrypted .= $procdata;
}
fclose($pipes[1]);
}

return $encrypted;
}

It works really well.

Regards

Ian
-- 


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



RE: [PHP] Excel Spreadsheets and PHP

2010-02-26 Thread Ian Robertson
Thank you all very much for your replies.

I learned about a few new approaches.

I didn't see it come up yet, so I'll post the URL of what I have been using.

php_writeexcel - 
http://www.bettina-attack.de/jonny/view.php/projects/php_writeexcel/

I've been able to pull off quite a bit with this class and actually have 
referenced this Perl page for documentation since this PHP class was ported 
from a Perl class - 
http://cpansearch.perl.org/src/JMCNAMARA/Spreadsheet-WriteExcel-0.37/WriteExcel/doc/WriteExcel.html

So, many thanks for your replies and also thanks to Johann and his 3 Bettinas, 
wherever you are, haha.

-Original Message-
From: Jay Blanchard [mailto:jblanch...@pocket.com] 
Sent: Sunday, February 21, 2010 9:44 PM
To: Ian Robertson; php-general@lists.php.net
Subject: RE: [PHP] Excel Spreadsheets and PHP

[snip]
What are you using, if anything, to create Excel spreadsheets with PHP?
[/snip]

PHP

http://www.evolt.org/node/26896



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



[PHP] Re: PHP or SQL to do this?

2010-02-24 Thread Ian
On 24/02/2010 05:46, Rob Gould wrote:
> I'm not sure if I need to write a PHP for-loop to do this, or if it can all 
> be done in one SQL statement?
> 
> Basically, I want to copy all the barcodes from one table and put them into 
> another table, but only if the barcode in the first table > 0, and only if 
> the wineid's match from table to table.
> 
> 
> Steps individually are something like this:
> 
> 1)  First, I get all the records from the "wine" table that have barcodes, 
> like this:
> 
>   SELECT *  FROM `wine` WHERE barcode2 > 0
> 
> The fields I need are "barcode2", and "wineid"
> 
> 
> 2)  Next, I need to match all the wineid's from this "wine" table with the 
> wine id's from the "usersdata" table.  Both fields in both tables are called 
> "wineid".
> 
> 3)  Then, if the wineid's match, I need to copy the "barcode2" value from the 
> wine table and put it into the field "custombarcode" in the "usersdata" table.
> 
> 
> I'm tempted to write a PHP script which does a while-loop through all the 
> records returned from the wine table and do the matching with the usersdata 
> table, but I wouldn't be surprised if there's some sort of table-join-type 
> query that can do all this in one step.
> 
Hi,

If your using MySQL (Other DBs may support this as well) you can insert
multiple rows like this.

INSERT INTO destination_table ( barcode2, wineID)
SELECT barcode2, wineID
FROM wine
WHERE barcode2 > 0;

(adjust to your spec)

Check out the manual page here (MySQL 5.1):

http://dev.mysql.com/doc/refman/5.1/en/insert-select.html

You can jump to the manual for other versions from this page too.


Build up your SELECT statement first and then add the INSERT line when
you're happy its getting the right values.  If you want to be really
careful, insert into a temporary table first.


Regards

Ian
-- 




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



[PHP] Excel Spreadsheets and PHP

2010-02-19 Thread Ian Robertson
Hello, everyone.

Just a quick question.

What are you using, if anything, to create Excel spreadsheets with PHP?

Thank you in advance.




Re: [PHP] Making several variables into 1 variable

2009-07-28 Thread Ian
> On Tue, 2009-07-28 at 09:42 -0400, Miller, Terion wrote:
> > 
> > 
> > On 7/28/09 8:35 AM, "Ashley Sheridan"  wrote:
> > 
> > $pastDays = strtotime("-30 days");
> > $date = date("d/m/y", $pastDays);
> > 
> > Well I tried and got no results from my query and I know there results with 
> > date ranges in the last 30 days, I basically need to count backward from 
> > now() 30 days I thought strtotime() would work well..but the fields in the 
> > db are varchar not date fields they are all formatted the same though 
> > 00/00/00:
> > 
> >   $sql = "  SELECT DISTINCT restaurants.ID, name, address, inDate 
>>  FROM restaurants, inspections 
>>  WHERE restaurants.name != '' AND inspections.inDate <= $date 
>>  GROUP BY restaurants.ID ORDER BY 'name' ";
> > 
> 
> I believe the query is suspect. From memory, don't you need to enclose
> dates in single quotes in MySQL statements? Also, I believe it uses
> American data format, so you might have to put the month before the day
> like was in Richards example.

Hi,

Instead of using php to work out the 30 days part you could just let the 
database do it:

$sql = "SELECT DISTINCT restaurants.ID, name, address, inDate 
FROM restaurants, inspections 
WHERE restaurants.name != '' AND 

CAST(inspections.inDate AS DATE)<=  

DATE_SUB(NOW(),INTERVAL 30 DAYS)

GROUP BY restaurants.ID ORDER BY 'name' ";

You will have to check that the CAST function is working properly on your 
varchar'ed date 
fields before testing this query.  It should point you in the right direction 
though.

Regards

Ian
-- 



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



[PHP] require/include fails with APC enabled

2009-07-20 Thread Ian Maddox
I have one server that is acting up whenever I try to enable APC.  PHP
scripts execute normally as long as there are no calls to include(),
include_once(), require(), or require_once().
Any file (no matter the size) that can be included while APC is disabled
will cause the script to silently fail at the point of include when APC is
enabled.  There is no output in the PHP error_log, even when logging all
message types.

This feels like it's probably a really simple fix, but we're stumped.  Any
help you can provide would be greatly appreciated.

Server software combinations:
PHP 5.2.9 with APC 3.0.18 and ZTS
PHP 5.2.6+lenny3  with APC 3.1.2
PHP 5.2.6+lenny3  with APC 3.0.18

Apache 2.2.9 in all cases
APC is configured for pthread mutex locks.  mmap disabled.


[PHP] Mastercard Securecode

2009-06-19 Thread Ian
Hi,

A search of google has been unsuccessfull so I am posting here in the hope 
someone 
can help.

We have recently been told that we must implement the Mastercard Securecode 
'feature' 
for all our Maesto transactions or face fines of up $25000 per month. Our 
merchant has 
provided a SDK which has APIs in C, COM or Java (specifically the "Arcot 
Transfort 
Merchant Software").

We previously moved away from a Java API into our merchant in favour of a pure 
PHP 
implementation using XML and would rather not take a step back again.


Is anyone aware of a pure PHP implementation of the Mastercard Securecode 
'feature'?


I am aware I can link into COM & Java from PHP, and even take the C API and 
make my 
own extension but I would rather not pursue these options unless I really have 
to!

Regards

Ian
-- 


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



Re: [PHP] difference between two times? Date_diff and DateTime::diff

2009-06-16 Thread Ian
On 16 Jun 2009 at 14:05, Matthew Croud wrote:

> Hi Dajve and Tom,
> 
> Thanks again, I totally didn't realise that this function is yet to be  
> implemented in the mainstream PHP,
> 
> So is there no function that exists in vanilla PHP that can take two  
> dates/times and supply the difference ?
> If there isn't I do apologise, i've been talking to my friend who does  
> ASP.net and he said he was sure there is for PHP.

Hi,

This is a quick function that works using unix time stamps.  Its a bit quick 
and messy but 
works ok.  Take a look at the manual page for the strtotime() function to get a 
better idea 
of what it can handle.

  0,
"Hours" =>  0,
"Minutes"   =>  0,
"Seconds"   =>  0
);

$amounts= Array(
"Days"  =>  60*60*24,
"Hours" =>  60*60,
"Minutes"   =>  60
);

$difference = $Date2_UnixTimeStamp - $Date1_UnixTimeStamp;

if($difference >= $amounts["Days"]){
$return_difference["Days"] = floor($difference / 
$amounts["Days"]);
$difference -=  $return_difference["Days"] * $amounts["Days"];
}

if($difference >= $amounts["Hours"]){
$return_difference["Hours"] = floor($difference / 
$amounts["Hours"]);
$difference -=   $return_difference["Hours"] * 
$amounts["Hours"];
}
if($difference >= $amounts["Minutes"]){
$return_difference["Minutes"] = floor($difference / 
$amounts["Minutes"]);
$difference -=  $return_difference["Minutes"] * 
$amounts["Minutes"];
}

$return_difference["Seconds"] = $difference;

return $return_difference;
}

?>

Regards

Ian
-- 



> On 16 Jun 2009, at 13:11, Dajve Green wrote:
> 
> >
> > Hi Matthew,
> >
> > A quick note on the DateTime::diff() method - it's only available as  
> > from
> > PHP 5.3, which is currently in release candidate stage, meaning  
> > unless you
> > have your own server running PHP, it won't be available to use  
> > (hopefully -
> > I would be sceptical of any webhost which rolls out RCs on production
> > servers).
> >
> > If you need to know what version of PHP you're running, use:
> > phpversion() or phpinfo()
> >
> >> -Original Message-
> >> From: Matthew Croud [mailto:m...@obviousdigital.com]
> >> Sent: 16 June 2009 12:42
> >> To: Tom Chubb
> >> Cc: PHP General list
> >> Subject: Re: [PHP] difference between two times? Date_diff and
> >> DateTime::diff
> >>
> >> Hi Tom,
> >>
> >> Thanks for the reply,  I believe I have a fair understanding of
> >> functions, and I have followed the example on the PHP manual page (
> >> http://uk3.php.net/manual/en/function.date-diff.php
> >>  ), ideally I want to know how to use the class DateTime::diff, how
> >> can I use the DateTime::diff to get the difference between two times/
> >> dates ? I suppose then I'm after the syntax
> >>
> >> would it be like this for example:
> >> $DIfferenceInTime  = DateTime::diff(10:00,12:32);
> >>
> >> Thanks again for helping me out.
> >>
> >>
> >>
> >> On 16 Jun 2009, at 12:33, Tom Chubb wrote:
> >>
> >>> Matt,
> >>> Do you understand how to use functions?
> >>> A function is defined like this:
> >>>
> >>> function () {
> >>> //code goes here
> >>> }
> >>>
> >>> You can pass arguments to be used in a function like this:
> >>>
> >>> function($arg1, $arg2) {
> >>> //code goes here
> >>> }
> >>>
> >>> In the first example on the following page:
> >> http://uk3.php.net/manual/en/function.date-diff.php
> >>> To call the function you need to provide two arguments: $dtTime1 &
> >>> $dtTime2
> >>>
> >>> To use in a script, you need to first define the function, as per
> >>> the example:
> >>>
> >>>  >>>
> >>> function GetDeltaTime($dtTime1, $dtTime2)
> >>> {
> >>>  $nUXDate1 = strtotime($dtTime1->format("Y-m-d H:i:s"

Re: [PHP] Mail subject encoding breaks

2009-05-11 Thread Ian
On 11 May 2009 at 18:25, Thodoris wrote:

> Hi gang,
> I am using phpmailer to send some mail notifications in an intranet
> I've made. This is a sample code:

> $e->Subject = "This is δφκξγκδφη garbidge κηδφκξγσ";

Hi,

I have had success with this in the past:

$subject= "This is δφκξγκδφη garbidge κηδφκξγσ";
$e->Subject = mb_encode_mimeheader($subject, "UTF-8", "Q") ;

Regards

Ian
--



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



Re: [PHP] problems with gnupg extension.

2009-04-21 Thread Ian
On 20 Apr 2009 at 11:37, Ray wrote:



> Any suggestions, Anyone?
> Ray

Hi,

I adapted these scripts for my own user and have not had any problems:

http://www.theoslogic.com/scripts/php-gpg/

It does not use the gnupg extension at all but popen() or proc_open().

Regards

Ian
-- 




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



Re: [PHP] Upload large < 100MB of PDFS to MySQL using PHP, Is my settings ok?

2009-04-02 Thread Ian
On 2 Apr 2009 at 15:33, Louie Miranda wrote:

> Guys,
> 
> I need help on the php and mysql configurations.
> 
> I want to be able to upload < 100MB to MySQL using PHP.
> 


> > max_allowed_packet = 5M

Hi,

This may be the one that's stopping it.  

max_allowed_packet:
http://dev.mysql.com/doc/refman/5.0/en/server-system-
variables.html#sysvar_max_allowed_packet

If the SQL statement you are using goes over 5Mb, MySQL will cut the connection 
with an 
error.  It is strange that you are not seeing an error in your code thought.

Regards

Ian
-- 

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



Re: [PHP] formulate nested select

2009-04-02 Thread Ian
On 31 Mar 2009 at 18:15, PJ wrote:



> >> But I see that I may be trying to do too much - I thought of showing how
> >> many books were listed under each letter of the alphabet but I don't see
> >> how it can be done in any simiple way as it would mean that I would have
> >> to do the select once with the ORDER BY and a second time without it
> >> just to get the number of listing. If there are a lot of books, like
> >> thousands, it might slow down things.
> >> I suppose I could live with ORDER BY "title" as that does not require
> >> another effort.
> >> Any thoughts or suggestions?

Hi,

Sounds like you need to use the GROUP BY functions of MySQL

This SQL is probably wrong because I don't remember seeing your schema (and am 
too 
busy here to go looking!)

SELECT 
LEFT(last_name, 1 ) as Letter, Count(bookID) as NumberOfBooks
FROM 
books INNER JOIN 
GROUP BY Letter
ORDER BY Letter ASC


You will have to play around with that to get the right results.  But it should 
give you 
something like:

Letter,NumberOfBooks
A,47
B,21
C,8
...

The MySQL manual has more info:
http://dev.mysql.com/doc/refman/5.0/en/group-by-functions-and-modifiers.html

Regards

Ian
-- 


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



Re: [PHP] formulate nested select

2009-03-31 Thread Ian
On 31 Mar 2009 at 9:08, PJ wrote:

> I must be doing something wrong. Can't figure it out even though I've
> been searching the manuals & tutorials, it still does not work. Here is
> the exact code that I have tried; the first version is commented out and
> obviously does not work either (the spelling, the table names and column
> names are correct):
> 
> $books = array();
> /*$SQL = "SELECT * FROM book b
> JOIN book_author c
> ON b.id = c.bookID
> JOIN author a ON a.id = c.authID
> WHERE LEFT(a.last_name,1) = $Auth
> ORDER BY $sort $dir
> LIMIT $offset, $records_per_page"; */
> 
> $SQL = "SELECT * FROM book b
> INNER JOIN book_author c
> ON b.id = c.bookID
> WHERE c.authID = (SELECT id FROM author a WHERE LEFT(a.last_name, 1
> ) = $Auth )

Hi,

I think this should be '$Auth' as MySQL will be expecting a string.


> ORDER BY $sort $dir
> LIMIT $offset, $records_per_page";
> if ( ( $results = mysql_query($SQL, $db) ) !== false ) {
> while ( $row = mysql_fetch_assoc($results) ) {
> $books[$row['id']] = $row;
> }
> }
> echo "auth = :", $Auth ; ---> returns "auth = :A" (my quotes)
> var_dump($results);  ---> returns "boolean false" (my quotes)
> 
> Now, this:
> $SQL = "select *
> from book b
> inner join book_author c
> on (b.id = c.bookID)
> inner join author a on (a.id = c.authID)
> where left(a.last_name, 1 ) = $Auth;
> if ( ( $results = mysql_query($SQL, $db) ) !== false ) {
> while ( $row = mysql_fetch_assoc($results) ) {
> $books[$row['id']] = $row;  ---> returns "Parse error:
> syntax error, unexpected '[', expecting ']' in this line
> There seems to be something odd in the query... and yet, it all three
> look right to me... could there be some inconsistency in the tables,
> like skipped records or a record in a column that is non-existent in a
> corresponding column?

Looks like there is a double quote ( " ) missing from the end of the $SQL 
variable.

When building complex SQL queries for use in PHP I usually test them in the 
mysql 
command line client or a gui such as HeidiSQL first to make sure I am getting 
the 
expected results.  

Also you could try printing the SQL statement to the web page to make sure it 
looks as 
expected.

You can try checking for a MySQL error within PHP by using these functions:

mysql_errno()
mysql_error()

Regards

Ian
-- 



> 
> 
> Jim Lucas wrote:
> > Chris wrote:
> >> PJ wrote:
> >>> I cannot find anything on google or the manuals/tutorials that gives
> >>> some kin of clear explanation of how to so nested selects with where or
> >>> whatever.
> >>> I have three tables: books, authors and book-authors.
> >>> I need to retrieve only those books whose author's names begin with A.
> >>> I have tried several maniipulations of where and select with select
> >>> subqueries and I cannot get results from the queries.
> >>> For example
> >>> "SELECT * FROM book b, book_authors c (SELECT id FROM author WHERE
> >>> LEFT(author.last_name = $Auth )) as a WHERE a.id = c.authID && b.id =
> >>> c.bookID 
> >>
> >> Not really a php question :P
> >>
> >> You don't need a subquery for this. You can join all of the tables
> >> together and just use the where clause to cut down your results, but
> >> I'll give an example of both.
> >>
> >> select *
> >> from
> >>   books b inner join book_authors c on (b.id=c.bookId)
> >>   inner join authors a on (a.id=c.authorId)
> >> where
> >>   left(a.last_name = 'A');
> >
> > correct me if I'm wrong, but did you use the left() function
> > in-correctly?
> >
> > The documentation shows a different way to use it then you describe.
> >
> > Something more like the following:
> >
> > WHERE
> >LEFT(a.last_name, 1) = 'A';
> >
> > But that would be case-sensitive...
> >
> > So, something like this would work better IMHO
> >
> > WHERE
> >UPPER(LEFT(a.last_name, 1)) = 'A';
> >
> > or
> >
> > WHERE
> >a.last_name ILIKE 'A%';
> >
> > would do the trick
> >>
> >> or
> >>
> >> select *
> >> from
> >>   books b inner join book_authors c on 

Fwd: [PHP] Re: Unique User Hashes

2009-02-18 Thread Ian
Forgot to send to list.

-- Forwarded message --
From: Ian 
Date: Wed, Feb 18, 2009 at 11:12 AM
Subject: Re: [PHP] Re: Unique User Hashes
To: Colin Guthrie 



'Twas brillig, and Ian at 18/02/09 07:09 did gyre and gimble:
>
>> We dont have registration - its a once off vote anonymously using the hash
>> in the original email. We dont want registration otherwise it would be
>> much
>> easier - but this was the best way I could think of without user
>> registration :/
>>
>
> Do you have to invite people to vote or can anyone come along and cast?
>
> If the former you could email a UUID token to them or similar as part of
> the link. Once that UUID was "spent" it wouldn't allow voting again.
>
> I say UUID as a regular auto-incrementing id would be fairly easy to guess
> ;)
>
> Of course this may not be appropriate in this circumstance.
>
> Col
>
> Unfortunately its anyone can come along and vote - no email inviting :/


If you've already sent them an email with a hash in it, can you do something
> like:
>
> - require the hash be pasted into a field in your voting form
> - save the hash to a cookie
> - if the cookie doesn't exist, prompt for the hash again along with a link
> to resend the hash
>
> It's sort of 'login lite' in a way, but might be less oppressive than a
> full login process.

Same as above - wouldnt work because we arent recording that info...


Re: [PHP] Unique User Hashes

2009-02-17 Thread Ian
We dont have registration - its a once off vote anonymously using the hash
in the original email. We dont want registration otherwise it would be much
easier - but this was the best way I could think of without user
registration :/

On Wed, Feb 18, 2009 at 9:05 AM, Chris  wrote:

> Ian wrote:
>
>> Hi,
>>
>> Yep it is backed by DB and i do record when they vote - but its still
>> flawed in how to track unique users :) Thanks though - will continue to look
>> further.
>>
>
> Do you have to log in to vote?
>
> How are you stopping people from signing up multiple times?
>
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
>


Re: [PHP] Unique User Hashes

2009-02-17 Thread Ian
Hi,

Yep it is backed by DB and i do record when they vote - but its still flawed
in how to track unique users :) Thanks though - will continue to look
further.

Cheers

On Wed, Feb 18, 2009 at 5:56 AM, Chris  wrote:

> Ian wrote:
>
>> Hi,
>> I am busy building an application that requires one time voting and to get
>> around the user deleting a cookie that I set im keeping a hash on my side
>> which I then try match before allowing anything.
>>
>
> I assume this is backed by a db of some sort.
>
>
> $query = "update user set has_voted=NOW() where userid='x'";
>
> so you can also see when the user voted. Maybe record the ip etc as a
> record to back up your assertion they have voted but as you say, ip is not a
> very reliable indicator.
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
>


[PHP] Unique User Hashes

2009-02-17 Thread Ian
Hi,
I am busy building an application that requires one time voting and to get
around the user deleting a cookie that I set im keeping a hash on my side
which I then try match before allowing anything.

This is how I currently generate my hash:
/* Get vars */
$browser = $_SERVER['HTTP_USER_AGENT'];
$ip = $_SERVER['REMOTE_ADDR'];
$real_client_ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
if(!empty($real_client_ip))
$name = gethostbyaddr($real_client_ip);
else
$name = gethostbyaddr($ip);

/* Return generated hash */
return md5($browser.$ip.$real_client_ip.$name);

Now thats not ideal because you can just change your user agent and vote
again - but IP isnt good enough either because in South Africa due to the
poor internet we all connect to international sites via a series of
Transparent proxies which makes everyone seem to come from one IP.

Anyone had to deal with this in the past and does anyone have any
suggestions/ideas as to how I could better this setup?

Many thanks in advance,
Ian


Re: [PHP] Global Changes With Loop To Allow Nulls In A Table...

2009-01-27 Thread Ian
On 27 Jan 2009 at 8:53, revDAVE wrote:

> Hi Folks,
>
> Newbie question
>
> I have a mysql table with 100 fields, currently all do not allow nulls.
> Rather than hand typing in phpMyAdmin, I would like a way to loop through
> all fields and update them to allow nulls
>
> My Beginning attempt needs help...
>
>
> $i = 1;
> while ($i <= 100):
>
> // how do I word this to just change whatever field we are on to allow
> nulls?
>
> $sql = 'ALTER TABLE `mytable` ?*update*? `'.$???WhatEverField??[$i].'`
> ?ALLOWNULL?;';
>
> //mysql_query($sql);
>
> $result = mysql_query($sql) or die(" Could not renumber dB $sql
> " . mysql_error());
>
>
> $i++;
> endwhile;
>
>
> Thanks in advance

Hi,

The MySQL syntax to alter a column is:

ALTER TABLE `table` MODIFY `column` BIGINT NOT NULL;

[ http://dev.mysql.com/doc/refman/5.1/en/alter-table.html ]

The sql statement

SHOW COLUMNSFROM `table`;

[ http://dev.mysql.com/doc/refman/5.1/en/show-columns.html ]

will give you a list of all the fields with there type, default values, null 
etc...
You can then use this in the loop to find all the fields where null=NO.

Warning from the manual:

When you change a data type using CHANGE or MODIFY, MySQL tries to
convert existing column values to the new type as well as possible.

Warning
This conversion may result in alteration of data. For example, if you 
shorten a
string column, values may be truncated. To prevent the operation from
succeeding if conversions to the new data type would result in loss of 
data, enable
strict SQL mode before using ALTER TABLE (see Section 5.1.6, “SQL Modes”).

I don't think this will affect you but bare it in mind.

Regards

Ian
--



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



Re: [PHP] Seg Faulting PHP

2009-01-19 Thread Ian
On Mon, Jan 19, 2009 at 10:51 PM, Daniel Brown  wrote:

> On Mon, Jan 19, 2009 at 15:12, Ian  wrote:
> > Hi all,
> >
> > Appologies if this is the wrong list - please direct me in the right
> > direction should this be the case.
> >
> > I am running PHP 5.2.8 on freebsd 7.0 and am getting a Seg fault when
> > running one of my new programs. We run a couple of other sites of this
> > server (only one upgraded to 5.2.8) and they are running fine - its just
> > this script. This script uses:
>
> If you can run it from the command line, Ian, check the tail of
> strace by running:
>
> strace php -e /path/to/offending/script.php
>
>Otherwise, there may be a problem with that particular port with
> your system.  If all else fails, compile from source.
>
> --
> 
> daniel.br...@parasane.net || danbr...@php.net
> http://www.parasane.net/ || http://www.pilotpig.net/
> Unadvertised dedicated server deals, too low to print - email me to find
> out!


Hi Daniel,

Here are the last couple lines from the strace:
unlink("/some/dir/sqlite.sq3-journal") = 0
fcntl(3, F_SETLK, {type=0 /* F_??? */, whence=SEEK_SET, start=0, len=0}) = 0
fcntl(3, F_SETLK, {type=0 /* F_??? */, whence=SEEK_SET, start=0, len=0}) = 0
fcntl(3, F_SETLK, {type=0 /* F_??? */, whence=SEEK_SET, start=0, len=0}) = 0
sigprocmask(SIG_BLOCK, NULL, [])= 0
sigprocmask(SIG_BLOCK, NULL, [])= 0
sigprocmask(SIG_BLOCK, NULL, [])= 0
sigprocmask(SIG_BLOCK, NULL, [])= 0
fcntl(3, F_SETLK, {type=0 /* F_??? */, whence=SEEK_SET, start=0, len=0}) = 0
fcntl(3, F_SETLK, {type=0 /* F_??? */, whence=SEEK_SET, start=0, len=0}) = 0
fcntl(3, F_SETLK, {type=0 /* F_??? */, whence=SEEK_SET, start=0, len=0}) = 0
access("/some/dir/sqlite.sq3-journal", F_OK) = -1 ENOENT (No such file or
directory)
fstat(3, {st_mode=0, st_size=0, ...})   = 0
syscall_478(0x3, 0x18, 0, 0)= 0x18
read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16) = 16
fcntl(3, F_SETLK, {type=0 /* F_??? */, whence=SEEK_SET, start=0, len=0}) = 0
open("/some/dir/sqlite.sq3-journal", O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW, 0644)
= 4
fstat(4, {st_mode=0, st_size=0, ...})   = 0
open(/some/dir", O_RDONLY) = 5
syscall_478(0x4, 0, 0, 0)   = 0
write(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 24) = 24
syscall_478(0x4, 0x1ff, 0, 0)   = 0x1ff
write(4, "\0"..., 1)= 1
syscall_478(0x3, 0x800, 0, 0)   = 0x800
read(3,
"\n\0\0\0\t\3\312\0\3\372\3\364\3\356\3\350\3\342\3\334\3\326\3\320\3\312\0\0\0\0\0\0\0"...,
1024) = 1024
syscall_478(0x4, 0x200, 0, 0)   = 0x200
write(4,
"\0\0\0\3\n\0\0\0\t\3\312\0\3\372\3\364\3\356\3\350\3\342\3\334\3\326\3\320\3\312\0\0\0"...,
1032) = 1032
syscall_478(0x4, 0x608, 0, 0)   = 0x608
write(4,
"\0\0\0\2\r\0\0\0\t\0C\0\3\226\3,\2\302\2W\1\354\1\202\1\30\0\256\0C\0\0\0"...,
1032) = 1032
syscall_478(0x4, 0xa10, 0, 0)   = 0xa10
write(4,
"\0\0\0\4\r\0\0\0\2\3\345\0\3\362\3\345\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,
1032) = 1032
syscall_478(0x4, 0xe18, 0, 0)   = 0xe18
write(4, "\0\0\0\1SQLite format 3\0\4\0\1\1\0@  \0\0\0.\0"..., 1032) = 1032
fsync(4)= 0
fsync(5)= 0
close(5)= 0
syscall_478(0x4, 0x8, 0, 0) = 0x8
write(4, "\0\0\0\0"..., 4)  = 4
fsync(4)= 0
fcntl(3, F_SETLK, {type=0 /* F_??? */, whence=SEEK_SET, start=0,
len=281474976841728}) = 0
fcntl(3, F_SETLK, {type=0 /* F_??? */, whence=SEEK_SET, start=65536, len=0})
= 0
syscall_478(0x3, 0, 0, 0)   = 0
write(3, "SQLite format 3\0\4\0\1\1\0@  \0\0\0/\0\0\0\0\0"..., 1024) = 1024
syscall_478(0x3, 0x400, 0, 0)   = 0x400
write(3,
"\5\0\0\0\1\3\373\0\0\0\0\33\3\373\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,
1024) = 1024
syscall_478(0x3, 0x800, 0, 0)   = 0x800
write(3,
"\n\0\0\0\n\3\304\0\3\372\3\364\3\356\3\350\3\342\3\334\3\326\3\320\3\312\3\304\0\0\0\0\0"...,
1024) = 1024
syscall_478(0x3, 0xc00, 0, 0)   = 0xc00
write(3,
"\r\0\0\0\2\3\345\0\3\362\3\345\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,
1024) = 1024
syscall_478(0x3, 0x6400, 0, 0)  = 0x6400
write(3,
"\r\0\0\0\t\0C\0\3\226\3,\2\302\2W\1\354\1\202\1\30\0\256\0C\0\0\0\0\0\0\0"...,
1024) = 1024
syscall_478(0x3, 0x6800, 0, 0)  = 0x6800
write(3,
"\r\0\0\0\1\3\226\0\3\226\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,
1024) = 1024
fsync(3)= 0
close(4)= 0
unlink("/some/dir/sqlite.sq3-journal") = 0
fcntl(3, F_SETLK, {type=0 /* F_??? */, whence=SEEK_SET, start=0, len=0}) = 0
fcntl(3, F_SETLK, {type=0 /* F_??? */, whence=SEEK_

[PHP] Seg Faulting PHP

2009-01-19 Thread Ian
rl.so
extension=simplexml.so
extension=spl.so
extension=dom.so
extension=exif.so
extension=fileinfo.so
extension=filter.so
extension=gd.so
extension=gettext.so
extension=hash.so
extension=iconv.so
extension=json.so
extension=mbstring.so
extension=mcrypt.so
extension=mhash.so
extension=mysql.so
extension=mysqli.so
extension=odbc.so
extension=openssl.so
extension=pdf.so
extension=pdo.so
extension=pdo_sqlite.so
extension=posix.so
extension=session.so
extension=pspell.so
extension=snmp.so
extension=soap.so
extension=sockets.so
extension=sqlite.so
extension=sysvmsg.so
extension=sysvshm.so
extension=tokenizer.so
extension=xml.so
extension=xmlreader.so
extension=xmlrpc.so
extension=xmlwriter.so
extension=zip.so
extension=zlib.so

Any ideas as to why this is happening?

Thanks in advance
Ian


[PHP] new xampp server problem w/mail

2008-12-15 Thread Ian Lin
hi I have been searching for a way to get the php mail function to work and 
have had no luck. I was hoping you could address my situation:
 
I have a fairly new xampp install and I need to know how to get mail() to work. 
I would like to know tha simplest way possible to get the mail function to 
work. I guess the major problem is that my xampp install doesn't have an email 
server. please advise my what I need to do to get one for a linux box.
 
Please keep in mind that I am a newbie and need detailed instructions for 
installing any software and configuring any files that may need altered in the 
server's configuration files such as php.ini etc...
 
email me at linia...@yahoo.com if you can help.
 
Thanks,
Ian

Re: [PHP] Problem changing file encoding

2008-10-22 Thread Ian
On 22 Oct 2008 at 14:39, Thodoris wrote:

> Hi guys,
> I am developing a project and I wrote an interface to import contracts 
> in it. The problem is that when the user uploads the file I don't know 
> what is the encoding it has. So I decided that a good idea is to make 
> the user tell me the encoding from a drop down before I parse the file.
> 
> Then I could probably change the encoding with iconv and use it to 
> validate the data and make the inserts in mysql. Although in the unix 
> world I have available the iconv command and I can change the file to 
> the new encoding like this:
> 
> iconv -f  CP737 -t UTF-8 -o newfile.csv original_file.csv
> 
> I can't find a way to do this from within php. Iconv support gives me 
> some options but only to convert strings and there is not a way AFAIK to 
> get all the supported encodings from the system as I can do in command 
> line with this:
> 
> iconv --list
> 
> Is this the best way to do this ? Can I use mbstring as an alternative ?
> 
> Please make any suggestions you might think because I am stuck.

Hi,

I assume there is a reason why can't just run the command above from php? 

Regards

Ian
-- 


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



Re: [PHP] Half way

2008-10-22 Thread Ian
On 22 Oct 2008 at 6:34, Ron Piggott wrote:

> I am tweaking a blog application I have programmed.  I am trying to
> display a Google ad half through the blog entry, at the first available
> .
> 
> The code I use so far is:
> 
> $half_way = strlen( nl2br(stripslashes($entry))) /2 ;
> $ad_position = strpos  ( nl2br(stripslashes($entry))  , "" ,
> $half_way );
> echo substr( nl2br(stripslashes($entry)) , 0, $ad_position);
> 
> Is there a way to modify my strpos syntax to check and see if the
> nearest  is before the half way mark?  
> 
> What is tending to happen is the ad is being placed 5/7ths of the way
> through the blog entry because of the length of the paragraph the half
> way character falls in.  Visually it doesn't look balanced.  I would
> prefer the ad display 4/7th of the way through the blog entry in those
> situations.
> 
> Thanks for helping me.

Hi,

Disclaimer: Without seeing the actual blog entry this is all guess work!

Your code above seems to find the half way point in the raw text.  This is all 
very well if 
you do not have paragraphs or other formatting code that can move text around 
once 
displayed.

To overcome this you will have to try and detect the number of paragraphs (or 
formatting 
code) before the half way point and after it and try and move the Google Ad 
entry to 
accommodate this.

This will involve trial and error to determine an algorithm that best matches 
your blog 
entries.

Or you could go down the easy route and add some sort of marker (database entry 
or a 
tag of some sort) to each blog which indicates were the Google ads should go.

Personally I prefer the later options as its probably easier ;)

Regards

Ian
-- 


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



RE: [PHP] How to Execute Exe File from PHP

2008-10-22 Thread Ian
On 22 Oct 2008 at 2:14, Alice Wei wrote:  

> 
> HI, 
> 
>   To answer your questions, I run this on Windows. What is so weird is
> that when I do 
> 
> $a= shell_exec("C:\Inetpub\wwwroot\/test.exe -m$market -d$length"); echo
> $a; 
> 
> It works, and echoes everything as it is supposed to, and the file is also
> generated like I expected. However, the PHP file where I execute this from
> is in the same folder (which is why I thought using a . would work) 
> 
> Could anyone please tell me if this is only way Ito do this on a Windows
> machine? 
> 
> Thanks in advance, I think I am getting a little confused. 

Hi,

It may help to run the command 'dir' to see where the web server considers its 
path to be:



The response will include the current path as well as a directory listing.

Regards

Ian
-- 




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



Re: [PHP] Information on Cookies

2008-10-15 Thread Ian
On 15 Oct 2008 at 16:04, Ben Stones wrote:

> Can you explain to me the benefits of hashing/encrypting/md5'ing cookie
> values? I don't see how it'd stop hackers from changing cookie values?

Hi,

You would keep a copy of the hash on the server and check that against the 
submitted 
value.  If they are different then the cookie has been modified.

Regards

Ian
-- 

> 
> 2008/10/15 Stut <[EMAIL PROTECTED]>
> 
> >  On 15 Oct 2008, at 15:23, Ben Stones wrote:
> >
> >> I've read a few videos on cookie security and it makes sense that people
> >> can
> >> modify cookie values which is a problem I'm trying to figure out to *try*
> >> and prevent. What I'll first do is at the top of the page that validates
> >> if
> >> the cookie values is in the database, but what my next problem is they'd
> >> use
> >> usernames in the database as the vaues. Are there any preventable measures
> >> to prevent cookie forging or what not.
> >>
> >
> > You can encrypt or hash the cookies to prevent tampering...
> >
> >  http://stut.net/blog/2008/07/26/sessionless-sessions-2/
> >
> > -Stut
> >
> > --
> > http://stut.net/
> >
> 



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



Re: [PHP] returning array from commandline

2008-10-14 Thread Ian
This is resolved - I used serialize and unserialize which worked a treat.

Thanks for the suggestion :)

On Fri, Oct 10, 2008 at 8:17 PM, Richard Lynch <[EMAIL PROTECTED]> wrote:
> Convert it to XML or JSON.
>
> Those port quite nicely to anything.
>
> For all-PHP, you can use serialize to make it a string.
>
>> -Original Message-
>> From: Ian [mailto:[EMAIL PROTECTED]
>> Sent: Friday, October 10, 2008 8:38 AM
>> To: php-general@lists.php.net
>> Subject: [PHP] returning array from commandline
>>
>> Hi,
>>
>> I am busy developing a commandline tool that will, in certain
>> cirumstances, return an array of information when called and im having
>> a problem with this.
>>
>> The last part of my code looks like this:
>>
>> if(is_array($rslt)) return $rslt;
>> else echo $rslt;
>>
>> I.e. if its an array dont echo it, return it rather and im have huge
>> problems even using that $rslt variable. I have tried various exec
>> queries including exec() (with var before function call and as a
>> parameter), passthru, backtick operators and none of them allow me to
>> use the array after the commandline tool has been run.
>>
>> I also dont know how many levels the array may have as im referencing
>> other functions that change them based on the query given to the
>> commandline tool so I cant even put it into a string before returning
>> it as i dont know how many levels are involved and are returned from
>> the function call inside the commandline app. Does anyone have any
>> suggestions as to how I could achieve this or any better ways of doing
>> it?
>>
>> Quick summary: Im accessing a web interface that calls a php file to
>> parse some info. That php file may get an array back that I need to
>> use in the web interface - but I cant pass it back to the web
>> interface from the commandline tool.
>>
>> Thanks
>> Ian
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> ___
>
> The  information in this email or in any file attached
> hereto is intended only for the personal and confiden-
> tial  use  of  the individual or entity to which it is
> addressed and may contain information that is  propri-
> etary  and  confidential.  If you are not the intended
> recipient of this message you are hereby notified that
> any  review, dissemination, distribution or copying of
> this message is strictly prohibited.  This  communica-
> tion  is  for information purposes only and should not
> be regarded as an offer to sell or as  a  solicitation
> of an offer to buy any financial product. Email trans-
> mission cannot be guaranteed to be  secure  or  error-
> free. P6070214
>

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



Re: [PHP] returning array from commandline

2008-10-10 Thread Ian
On Fri, Oct 10, 2008 at 3:47 PM, Per Jessen <[EMAIL PROTECTED]> wrote:
> Ian wrote:
>
>> I am busy developing a commandline tool that will, in certain
>> cirumstances, return an array of information when called and im having
>> a problem with this.
>
> Ian, that's a bit of a contradiction - a command line tool returns a
> return code.
>

Yep, my bad - thats bad english - it was talking about the output that
the commandline tool spews out - i was hoping to return the entire
array for use within the web interface.

>> The last part of my code looks like this:
>>
>> if(is_array($rslt)) return $rslt;
>> else echo $rslt;
>>
>> I.e. if its an array dont echo it, return it rather and im have huge
>> problems even using that $rslt variable. I have tried various exec
>> queries including exec() (with var before function call and as a
>> parameter), passthru, backtick operators and none of them allow me to
>> use the array after the commandline tool has been run.
>
> Exactly - the array is a PHP construct, once you've called the command
> script, you've moved into your basic OS environment - which doesn't
> understand about PHP arrays.

Thats what i suspected - was just taking a gamble that someone would
have an ideal solution and make my life much easier :) ill have to
manually add some switch cases for different result sets and then a
decompile function on the other end.

>
>> Quick summary: Im accessing a web interface that calls a php file to
>> parse some info. That php file may get an array back that I need to
>> use in the web interface - but I cant pass it back to the web
>> interface from the commandline tool.
>
> Why does it have to be called as a command line tool?  Why not just call
> it as a plain PHP function?

I have to use it as I cant include some required files into my web ui
as they interfere with the base system (not one i wrote) and it causes
all sorts of havoc so I have resorted to creating a "bridge" to
combine the two systems which is where this problem comes in.

Many thanks :)

>
>
> /Per Jessen, Zürich
>
>
> --
> 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] returning array from commandline

2008-10-10 Thread Ian
Hi,

I am busy developing a commandline tool that will, in certain
cirumstances, return an array of information when called and im having
a problem with this.

The last part of my code looks like this:

if(is_array($rslt)) return $rslt;
else echo $rslt;

I.e. if its an array dont echo it, return it rather and im have huge
problems even using that $rslt variable. I have tried various exec
queries including exec() (with var before function call and as a
parameter), passthru, backtick operators and none of them allow me to
use the array after the commandline tool has been run.

I also dont know how many levels the array may have as im referencing
other functions that change them based on the query given to the
commandline tool so I cant even put it into a string before returning
it as i dont know how many levels are involved and are returned from
the function call inside the commandline app. Does anyone have any
suggestions as to how I could achieve this or any better ways of doing
it?

Quick summary: Im accessing a web interface that calls a php file to
parse some info. That php file may get an array back that I need to
use in the web interface - but I cant pass it back to the web
interface from the commandline tool.

Thanks
Ian

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



[PHP] Google Auth Scripts

2008-09-04 Thread Ian
Hi,

I am looking for a script that can authenticate a user against the
gmail database - except what I need back is the name of the person
thats doing it automagically, as well as if they have an avatar set
etc. Does anyone know of any scripts that do this?

I have done some googling for this and only really come up with
scripts that import your contacts - which is great - but not really
what I need.

Thanks in advance,
Ian

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



[PHP] localconv() monetary grouping

2008-06-27 Thread Ian Carter
Looking through the PHP 5 docs regarding the information returned by
localconv(), I am not sure what the 'grouping' and 'mon_grouping' elements
refer to.

Can someone explain to me why in the example shown ('[EMAIL PROTECTED]'), the
grouping array is empty and the mon_grouping array has two elements of '3'
each.

Thanks, Ian.



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



[PHP] Using Googles SSO for GApps

2008-04-08 Thread Ian
Hi,

I was wondering if anyone has set up SSO using googles api for apps.
http://code.google.com/apis/apps/sso/saml_reference_implementation.html
is their implementation guide but I was wondering if anyone has done
it, and if I could have a peak at the code you used, mainly for the
encrypting of the information being sent, also for the generation of
the xml.

I have done some googling and can find a few java implementaions, but
no php ones - maybe I cant search so if there are some examples around
please excuse my ignorance.

Thanks in advance,
Ian

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



[PHP] path_info in fastcgi setting

2008-03-09 Thread Ian M. Evans

Greetings all.

Making the transition to PHP 5.2.5 operating as FastCGI through Nginx.

Seem to be having a bit o' weirdness with path_info.

Under Apache and the PHP module:
a) test.php path_info is blank
b) test.php/ppp path_info=/ppp

Under PHP FastCGI:
c) test.php path_info is test.php
d) test.php/ppp path_info=/ppp

Not sure why it's not blank in 'c' and instead equals the filename.

I need coffee. :-)

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



[PHP] Deprecated configure options

2008-03-07 Thread Ian M. Evans
Was just upgrading to 5.2.5 and used the same configure line as I used 
for 5.2.0. Got the following notice:


"Notice: Following unknown configure options were used:

--enable-pic
--with-dom
--with-png
--with-xml
--enable-track-vars
--enable-trans-sid
--enable-yp
--enable-mbstr-enc-trans
--enable-dio
--enable-mcal
--with-jpeg"

Safe to assume those were deprecated?

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



Re: [PHP] Parse error help.., thanks..

2007-03-30 Thread Ian
Thanks very much for the help, Davi,, no more such errors.. :)

Ian
"Davi" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
Em Sexta 30 Março 2007 18:55, Ian escreveu:
> Parse error: syntax error, unexpected ';' in
> /hxxx/x/domains/x.com/public_html/blog/labels.php on line 15
>
> 
 http://.x.com/labels');
2
define('SEARCH_DIR','//x/domains/x.com/public_html/blog/labels');
3 define('THIS_FILE', 'cloud.php');
4 if(file_exists(SEARCH_DIR.'_cloud_include_cache.html') &&
5 filemtime(SEARCH_DIR.'_cloud_include_cache.html')>(time()-(60*60)))
6 echo file_get_contents(SEARCH_DIR.'_cloud_include_cache.html');
7 else
8 {
9 $output = '';
10 $files = array();
11 $dir = opendir(SEARCH_DIR);
12 while($file = readdir($dir))
13 if($file != '.' && $file != '..' && $file != THIS_FILE
14 
&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;am
15 p;amp;amp;& $file != CACHE_FILE)
16 {
17 $files[] = $file;
18 }

Try remove the "&"s...

[]s


-- 
Davi Vidal
[EMAIL PROTECTED]
[EMAIL PROTECTED]
--

Agora com fortune:
"Toothpaste never hurts the taste of good scotch." 

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



Re: [PHP] Parse error help.., thanks..

2007-03-30 Thread Ian
Hehe.., didn't i told i am poor in this, actually, never learn PHP before.. 
:)

No more such errors anymore thank you Tijnema! =)

Ian
""Tijnema !"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On 3/30/07, Ian <[EMAIL PROTECTED]> wrote:
>> Hi everyone, i am new to PHP, but not a programmer..,
>> i got this php code to workout on something on my blog, but it seems that 
>> it
>> gives me the following error:
>>
>> Parse error: syntax error, unexpected ';' in
>> /hxxx/x/domains/x.com/public_html/blog/labels.php on line 15
>>
>> 
>> > define('PREFIX', 'http://.x.com/labels');
>> define('SEARCH_DIR','//x/domains/x.com/public_html/blog/labels');
>> define('THIS_FILE', 'cloud.php');
>> if(file_exists(SEARCH_DIR.'_cloud_include_cache.html') &&
>> filemtime(SEARCH_DIR.'_cloud_include_cache.html')>(time()-(60*60)))
>> echo file_get_contents(SEARCH_DIR.'_cloud_include_cache.html');
>> else
>> {
>> $output = '';
>> $files = array();
>> $dir = opendir(SEARCH_DIR);
>> while($file = readdir($dir))
>> if($file != '.' && $file != '..' && $file != THIS_FILE
>> &amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;&
>
> How can above string be ever correct
>> $file != CACHE_FILE)
>> {
>> $files[] = $file;
>> }
>>
>> 
>> Anyhelp on this will ve be very much appreciated, thanks..
>>
>> Ian
> Try this code:
> 
>  define('PREFIX', 'http://.x.com/labels');
> define('SEARCH_DIR','//x/domains/x.com/public_html/blog/labels');
> define('THIS_FILE', 'cloud.php');
> if(file_exists(SEARCH_DIR.'_cloud_include_cache.html') &&
> filemtime(SEARCH_DIR.'_cloud_include_cache.html')>(time()-(60*60)))
> echo file_get_contents(SEARCH_DIR.'_cloud_include_cache.html');
> else
> {
> $output = '';
> $files = array();
> $dir = opendir(SEARCH_DIR);
> while($file = readdir($dir))
> if($file != '.' && $file != '..' && $file != THIS_FILE && $file != 
> CACHE_FILE)
> {
> $files[] = $file;
> }
>
> It should work, if not, come back here :)
>
> Tijnema
>>
>> --
>> 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] Parse error help.., thanks..

2007-03-30 Thread Ian
Hi everyone, i am new to PHP, but not a programmer..,
i got this php code to workout on something on my blog, but it seems that it 
gives me the following error:

Parse error: syntax error, unexpected ';' in 
/hxxx/x/domains/x.com/public_html/blog/labels.php on line 15


http://.x.com/labels');
define('SEARCH_DIR','//x/domains/x.com/public_html/blog/labels');
define('THIS_FILE', 'cloud.php');
if(file_exists(SEARCH_DIR.'_cloud_include_cache.html') &&
filemtime(SEARCH_DIR.'_cloud_include_cache.html')>(time()-(60*60)))
echo file_get_contents(SEARCH_DIR.'_cloud_include_cache.html');
else
{
$output = '';
$files = array();
$dir = opendir(SEARCH_DIR);
while($file = readdir($dir))
if($file != '.' && $file != '..' && $file != THIS_FILE 
&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;&
 
$file != CACHE_FILE)
{
$files[] = $file;
}


Anyhelp on this will ve be very much appreciated, thanks..

Ian 

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



[PHP] Excluding apostrophe's

2006-12-22 Thread RAFMTD \(Ian\)
Dear Sir/madam,

I have a problem which I don't seem to be able to resolve, so I hope you
can.

I have a simple html form which 'posts' variables to the following
script...
---

--

This in turn sends the data to my database, everything works fine until
someone enters an apostrophe, then it fails to send the data.
I have searched for the answer and it appears to be to use
mysql_real_escape_string  but when I apply that like this
--

--
the script fails with the following report Warning:
mysql_real_escape_string(): Can't connect to local MySQL server through
socket '/var/run/mysqld/mysqld.sock' (2)

Any help would be appreciated.

Regards

Ian Scales


Re: [PHP] Odd error after upgrading from Php4 to Php5

2006-11-28 Thread Ian Barnes

Hi,

$sql1 = "UPDATE members SET $pass WHERE id = '$editid'";

Thats whats on 199. ON line 198 i have: $pass = $_POST['pass'];

Thanks,
Ian



On 11/29/06, Jochem Maas <[EMAIL PROTECTED]> wrote:


Ian Barnes wrote:
> Hi,
>
> We recently upgraded our primary webserver to php 5 from php4 and we are
> now
> getting the following errors on the site:
>
> *Catchable fatal error*: Object of class stdClass could not be converted
to
> string in /home/www/somesite/somfile.php on line *199
>
> *Around that area in the code is some code something like:

so what is line 199?

>
> if(!$db->query("SQL $HaveYouGoTAVarInHere HERE"))

 ??

> {
>   echo 'Fail';
> }
>
> Any ideas what it means or how I can fix it ?
>
> Thanks
> Ian
>
> P.S. Please copy me, i dont know if my list membership is working.
>




[PHP] Odd error after upgrading from Php4 to Php5

2006-11-28 Thread Ian Barnes

Hi,

We recently upgraded our primary webserver to php 5 from php4 and we are now
getting the following errors on the site:

*Catchable fatal error*: Object of class stdClass could not be converted to
string in /home/www/somesite/somfile.php on line *199

*Around that area in the code is some code something like:

if(!$db->query("SQL QUERY HERE"))
{
  echo 'Fail';
}

Any ideas what it means or how I can fix it ?

Thanks
Ian

P.S. Please copy me, i dont know if my list membership is working.


[PHP] Database Class Help

2005-11-30 Thread Ian Barnes
Hi,

We have a database class that we want to use to connect to multiple
databases at the same time using different variables.

Here is part of the db class:

class db {
  var $dbh = "";
  var $q   = "";

  function db($db_host, $db_user, $db_pass, $db_name) {
$this->dbh = @mysql_pconnect($db_host, $db_user, $db_pass);
$this->select_db($db_name);
  }

  function select_db($db) {
if ([EMAIL PROTECTED]($db, $this->dbh)) {
  die("Cannot select database because:\n" .
mysql_error() . "");
}
  }

  function num_rows($_q) {
if (!$this->q = mysql_query($_q, $this->dbh)) {
  die("Invalid query \"" . $_q . "\"\n" .
mysql_error() . "");
} else {
  return mysql_num_rows($this->q);
}
@mysql_free_result($this->q);
  }
}

In my php file I say something like

num_rows('select * from table1');
Echo $db_2->num_rows('select * from table2');

?>


Now that happens is when I try and do the query for db1, I get told that
db2.table1 doesn't exist. I can swop anything around and it doesn't seem to
work for one of the classes.

Does anyone have any idea as to why this is happening?

Thanks a lot,
Ian

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



RE: [PHP] Help with Class

2005-09-08 Thread Ian Barnes
Hi Ryan,

I am including a different class.inc.php file each time the foreach loops.
Each one sits in a different dir. Yes, I do get that error. 

My understanding of OOP is that I could null the $sdk variable and re-init
it when the loop starts again..

Cheers

-Original Message-
From: Ryan Creaser [mailto:[EMAIL PROTECTED] 
Sent: 09 September 2005 12:34 AM
To: Ian Barnes
Cc: PHP General
Subject: Re: [PHP] Help with Class

Ian Barnes wrote:

>require_once (
>$fetchd['path'].'sdk/ipbsdk_class.inc.php' );
>  
>

What is the above line doing? It looks like you are trying to redeclare 
the ipbsdk class each time around the loop which is illegal in php. You 
can't do :

class ipbsdk {
 ...
}

and then (in the same request)

class ipbsdk {
...
}

because the names will clash. This should  cause a "Fatal error: Cannot 
redeclare class ipbsdk ..." message though. Are you seeing any errors?

- Ryan

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



RE: [PHP] Help with Class

2005-09-08 Thread Ian Barnes
Hi Thomas,

Thanks for the help. That didn't work though ...

Its now set to be $SDK = new sdk;

Nothing :(

-Original Message-
From: Thomas [mailto:[EMAIL PROTECTED] 
Sent: 08 September 2005 09:08 AM
To: 'Ian Barnes'
Subject: RE: [PHP] Help with Class


Sorry for not explaining ... [code]$SDK =& new ipbsdk;[/code] initializes
the $SDK variable as a reference of the class ipbsdk. The '&' operator is
called the reference operator. So by leaving it out you copy (the default
initialization) the resulting class object.

Maybe that does the trick.

T

-----Original Message-
From: Ian Barnes [mailto:[EMAIL PROTECTED] 
Sent: 08 September 2005 08:52 AM
To: 'Thomas'
Subject: RE: [PHP] Help with Class

Sorry for the stupid question. How do I init the class as a copy not a
reference ?

-Original Message-
From: Thomas [mailto:[EMAIL PROTECTED] 
Sent: 08 September 2005 08:25 AM
To: 'Ian Barnes'
Subject: RE: [PHP] Help with Class

Hmm, that is strange because OO tells us that by nulling an object you
destroy it. I don't see what the other person could have done to avoid the
destruction of his class ... (that would be above my head)

One more thing I would try (which you have not done yet) is to initialize
the class as a copy and not a reference. That should not impair your code
much because you are creating a new one ever time anyway.

> think it cant be done
That would somehow go against my understanding of OO programming ;-) ...

Good luck.

Thomas

-Original Message-
From: Ian Barnes [mailto:[EMAIL PROTECTED] 
Sent: 08 September 2005 08:07 AM
To: 'Thomas'
Subject: RE: [PHP] Help with Class

Hi,

I put the db object in there temporarily because the SDK class resets it and
I haven't gotten round to changing it yet. 

I tried initing $SDK to null at the start but that hasn't worked either.

The class that I initing isn't mine, it was written by someone else and they
don't allow for multiple directories. The first run in the foreach loop runs
perfectly, I get all the info back I need, so its just when the loop runs
again. 

Here is my current code with all options I have tried:
foreach ( $forums as $num=>$val )
{
$SDK=null;
$sdk = null;
$db = new db ( 'localhost' , 'user' , 'pass' , 'db' );
$sql = 'SELECT * FROM vaults WHERE id = "'.$val.'"';
$result = $db->get($sql);
$fetchd = mysql_fetch_array ( $result );
$forumid = $fetchd['forumid'];
$posterid = $fetchd['posterid'];
$title = $_POST['title'];
$desc = $_POST['desc'];
$post = $_POST['post'];
require_once ( $fetchd['path'].'sdk/ipbsdk_class.inc.php' );
$SDK =& new ipbsdk;
$info = $SDK -> get_info ( $posterid );
$postername = $info['name'];
echo "Forum ID:".$forumid;
echo "Title:".$title;
echo "Desc:".$desc;
echo "Post:".$post;
echo "PosterID:".$posterid;
echo "PosterName:".$postername;
echo "";
//  if ($SDK -> new_topic($forumid, $title, $desc, $post, $posterid,
$postername)) {
//  echo 'Topic Created!';
//  } else {
//  echo $SDK->sdk_error();
//  }
unset ( $sdk );
$SDK = null;
unset ( $SDK );
$sdk = null;
unset ( $GLOBALS['SDK']);
unset ( $GLOBALS['sdk'] ) ;
$GLOBALS['SDK'] = null;
$GLOBALS['sdk'] = null;
$_SESSION['sdk'] = null;
$_SESSION['SDK'] = null;
unset ( $_SESSION['SDK'] );
unset ( $_SESSION['sdk'] );
register_shutdown_function($SDK);
register_shutdown_function($sdk);
}

So as you can see, I have tried a lot of things and im starting to think it
cant be done, in which case ill just have to take the other persons class
and either modify it (which is against his terms) or take what he does and
do it manually myself.

Thanks for the help.

Ian



-Original Message-
From: Thomas [mailto:[EMAIL PROTECTED] 
Sent: 08 September 2005 07:54 AM
To: 'Ian Barnes'
Subject: RE: [PHP] Help with Class

First up, I am not sure if you need to create a new db object every single
loop, as far as I can see you can easily leave that outside the loop (unless
you connect to a different db on each loop).

Maybe you could initialize the $SDK variable on top of your loop with null
($SDK=null;) that way ever loop will serve you up with a 'nulled' $SDK
variable.

Does your current code not initialize the correct classes?

T

-Original Message-
From: Ian Barnes [mailto:[EMAIL PROTECTED] 
Sent: 08

RE: [PHP] Help with Class

2005-09-07 Thread Ian Barnes
Hi,

 

Thanks for the help, but none of those worked. 

 

Anyone else got any suggestions? Or possibly another way of achieving this ?

 

Cheers

Ian

 

  _  

From: Jason Davidson [mailto:[EMAIL PROTECTED] 
Sent: 07 September 2005 05:47 PM
To: Ian Barnes
Cc: PHP General
Subject: Re: [PHP] Help with Class

 

I would have guessed unset($sqk); to work, but also try $sdk = null;

Jason

On 9/7/05, Ian Barnes <[EMAIL PROTECTED]> wrote:

Hi,



I am writing a site where I need to access multiple classes of the same name
located under certain directories. The reason for each directory is because
the class under that directory talks only to the files in that directory and

cant do multiple (its not my software)



I have it so that I choose which ones I want to "post" to via checkboxes. I
then do a foreach loop and here it is:



foreach ( $forums as $num=>$val )

{

$db = new db ( 'localhost' , 'user' ,
'pass' , 'db' );

$sql = 'SELECT * FROM table WHERE id =
"'.$val.'"';

$result = $db->get($sql);

$fetchd = mysql_fetch_array ( $result );

$forumid = $fetchd['forumid'];

$posterid = $fetchd['posterid'];

$title = $_POST['title'];

$desc = $_POST['desc'];

$post = $_POST['post'];

require_once (
$fetchd['path'].'sdk/ipbsdk_class.inc.php' );

$SDK =& new ipbsdk;

$info = $SDK -> get_info ( $posterid );

$postername = $info['name'];

echo "Forum ID:".$forumid;

echo "Title:".$title;

echo "Desc:".$desc;

echo "Post:".$post;

echo "PosterID:".$posterid;

echo "PosterName:".$postername;

echo "";

}



See at the end of that foreach loop I need to unset the class $SDK so I can
re-init it from another dir. How can I do this? I have tried some of the 
following:

Unset ( $SDK);

Unset ($GLOBALS['SDK'] );





Can anyone shed any light on my predicament ?



Thanks in advance

Cheers

Ian

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

 



RE: [PHP] Help with Class

2005-09-07 Thread Ian Barnes
Hi,

 

Thanks for the help, but none of those worked. 

 

Anyone else got any suggestions? Or possibly another way of achieving this ?

 

Cheers

Ian

 

  _  

From: Jason Davidson [mailto:[EMAIL PROTECTED] 
Sent: 07 September 2005 05:47 PM
To: Ian Barnes
Cc: PHP General
Subject: Re: [PHP] Help with Class

 

I would have guessed unset($sqk); to work, but also try $sdk = null;

Jason

On 9/7/05, Ian Barnes <[EMAIL PROTECTED]> wrote:

Hi,



I am writing a site where I need to access multiple classes of the same name
located under certain directories. The reason for each directory is because
the class under that directory talks only to the files in that directory and

cant do multiple (its not my software)



I have it so that I choose which ones I want to "post" to via checkboxes. I
then do a foreach loop and here it is:



foreach ( $forums as $num=>$val )

{

$db = new db ( 'localhost' , 'user' ,
'pass' , 'db' );

$sql = 'SELECT * FROM table WHERE id =
"'.$val.'"';

$result = $db->get($sql);

$fetchd = mysql_fetch_array ( $result );

$forumid = $fetchd['forumid'];

$posterid = $fetchd['posterid'];

$title = $_POST['title'];

$desc = $_POST['desc'];

$post = $_POST['post'];

require_once (
$fetchd['path'].'sdk/ipbsdk_class.inc.php' );

$SDK =& new ipbsdk;

$info = $SDK -> get_info ( $posterid );

$postername = $info['name'];

echo "Forum ID:".$forumid;

echo "Title:".$title;

echo "Desc:".$desc;

echo "Post:".$post;

echo "PosterID:".$posterid;

echo "PosterName:".$postername;

echo "";

}



See at the end of that foreach loop I need to unset the class $SDK so I can
re-init it from another dir. How can I do this? I have tried some of the 
following:

Unset ( $SDK);

Unset ($GLOBALS['SDK'] );





Can anyone shed any light on my predicament ?



Thanks in advance

Cheers

Ian

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

 



[PHP] Help with Class

2005-09-07 Thread Ian Barnes
Hi,

 

I am writing a site where I need to access multiple classes of the same name
located under certain directories. The reason for each directory is because
the class under that directory talks only to the files in that directory and
cant do multiple (its not my software)

 

I have it so that I choose which ones I want to "post" to via checkboxes. I
then do a foreach loop and here it is:

 

foreach ( $forums as $num=>$val )

{

$db = new db ( 'localhost' , 'user' ,
'pass' , 'db' );

$sql = 'SELECT * FROM table WHERE id =
"'.$val.'"';

$result = $db->get($sql);

$fetchd = mysql_fetch_array ( $result );

$forumid = $fetchd['forumid'];

$posterid = $fetchd['posterid'];

$title = $_POST['title'];

$desc = $_POST['desc'];

$post = $_POST['post'];

require_once (
$fetchd['path'].'sdk/ipbsdk_class.inc.php' );

$SDK =& new ipbsdk;

$info = $SDK -> get_info ( $posterid );

$postername = $info['name'];

echo "Forum ID:".$forumid;

echo "Title:".$title;

echo "Desc:".$desc;

echo "Post:".$post;

echo "PosterID:".$posterid;

echo "PosterName:".$postername;

echo "";

}

 

See at the end of that foreach loop I need to unset the class $SDK so I can
re-init it from another dir. How can I do this? I have tried some of the
following:

Unset ( $SDK);

Unset ($GLOBALS['SDK'] );

 

 

Can anyone shed any light on my predicament ?

 

Thanks in advance

Cheers

Ian

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



[PHP] PHP Security

2005-08-25 Thread Ian C . McGarvey
I have been studying PHP all summer because I wanted to put some PHP 
code on my schools web site. I got to school and went to the web design 
teacher. I asked him if they had installed PHP on their server. He said 
that the district thinks that it would be a HUGE security risk and that 
people at my school would try to hack into the server (what bull). 
Anyway, can you give me some tips to make the server secure? Any help 
would be appreciated!


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



Re: [PHP] Re: Apache Webserver User Survey

2005-06-21 Thread Ian Holsman

wow you php bunch are a vocal lot.. ;-)
no other mailing list had a peep.

ok. let me try to answer the questions.. and apologies if I offend, it 
isn't the intention.



the answers your have given me are great (I wish u stuck them in the 
survey form, but no matter)


you've just given me 2 different reasons on 'why apache' then the 
previous poster.


you said:
stability & 'leanness'

he said:
performance & price.

Others have also mentioned other reasons like ease of configuration, 
modularity and so on.


The point is each of you are unique individuals with different reasons 
and experiences. If no one asks, we wouldn't know, we could just make a

gut choice .. which would most likely be wrong.

now..

why demographics..

have a look at http://www.biznix.org/surveys/ for a different picture
of apache's server usage stats. people in america in fortune 500 
companies use IIS more than people in 'the world' in global 500 
companies... so where you live does make a difference.


who knew?

as for how we could use this information.

I put the demographic in there to see what kind of person you are, and 
to see if there was any correlation between where you live and how you 
answered. ie.. people in Europe think documentation is a big issue, 
while the people in the USA are more concerned about performance. (this 
might be because the French documentation is really bad.. which would be 
interesting in itself no?).


BTW.. your IP# would have given me a whole lot of this information as 
well. I was just being polite (and lazy.. I didn't want to implement the 
same thing the php website does for it's download mirroring)


and to address your other concern.. why 'PHP'..
easy.. you guys use apache and IIS. PHP is so great it can run on both..
you guys have a *choice*..
If we didn't listen to what you guys say.. you wouldn't choose us next time.


mod_perl or .NET users don't have that choice.

if you do know a IIS mailing list, please feel free to mail me..
I really couldn't find any.



Kind regards
Ian Holsman.

Rene Brehmer wrote:

Documented research indicate that on Wed, 22 Jun 2005 10:58:12 +1000, Ian
Holsman wrote:



Greg Donald wrote:


On 6/21/05, Al <[EMAIL PROTECTED]> wrote:



Why bother.

http://news.netcraft.com/archives/web_server_survey.html


http://www.securityspace.com/s_survey/data/200504/index.html

http://www.securityspace.com/s_survey/data/man.200504/apachemods.html



These show that apache has 70% usage, but not why.



Because it's free and can do just about any HTTP need you might have on any
platform ever made ?

I tried using IIS, both the small one that comes with Windows 2000 Pro and
XP Pro, and the full version that comes with Windows 2000/2003 server, and
it is by far nowhere as lean or stable as Apache. ... And because IIS comes
with windows, and an awful lot of companies, for gawd knows what reason,
choose windows for their servers, it remains the only real alternative to
Apache.

But at any rate: Your survey might be better aimed at the Apache and IIS
user groups, rather than the PHP groups.

And personally, I don't like the demographical info in your survey. Unless
you're doing a localization project, I don't see the relevance in it. What
people use a webserver for in Timbuktu is generally the same as in Alaska,
the different local languages aside: Serving porn sites, news and reviews,
technical and not so technical references, and community sites (those four
things happen to be what about 70% of the web consists of).




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



Re: [PHP] Re: Apache Webserver User Survey

2005-06-21 Thread Ian Holsman

Greg Donald wrote:

On 6/21/05, Al <[EMAIL PROTECTED]> wrote:


Why bother.

http://news.netcraft.com/archives/web_server_survey.html



http://www.securityspace.com/s_survey/data/200504/index.html

http://www.securityspace.com/s_survey/data/man.200504/apachemods.html




These show that apache has 70% usage, but not why.

The survey is aimed to find out:
- what people actually use (and how)
- what kind of things they would like to see
- and what they want improved


and just because apache has a 70% market share today doesn't mean that 
it will have it in a year from now. just look at the netscape browser 
for an example on how fast you can fall from being the #1 to #0.


Regards
Ian.

ps.
I honestly do want some feedback good or bad. If you could spend the 10 
minutes it would be appreciated.


The link again
http://survey.zilbo.com/php.survey

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



[PHP] Apache Webserver User Survey

2005-06-21 Thread Ian Holsman

Hi.

I am conducting a survey about what users want out of a webserver
and how the Apache webserver ranks as far as fulfilling those needs.

In order to get a better understanding of it, I thought I would ask
you guys what was important to you.

The survey should take about 10-15 minutes to complete.

http://survey.zilbo.com/php.survey

I wish I could say there was a prize being given away if you fill it 
out, but there isn't..


This is 'opensource' research.. I don't have a marketing budget ;-)



Thanks
Ian Holsman
[EMAIL PROTECTED]

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



[PHP] Bug in look-behind assertions in PCRE patterns ?

2005-03-23 Thread Ian Thurlbeck
Dear All
Is this a bug ?
I'm using look-behind assertions within preg_match()
to ignore certain combinations of patterns. E.g. from
ref. manual is: (?
Here's my test script:

$line = '$res = foobar("ddd", "dfdf");';
if (preg_match("/(?
$line = '$res = $bar("ddd", "dfdf");';
if (preg_match("/(?
In the first preg_match() is correctly ignores the foobar
function name. However the second preg_match() does NOT
ignore the $bar as I expected.
I converted this to Perl and it correctly ignores both!
Is this a bug, or am I missing something ?
using PHP-4.3.10 + apache 1.3.33 + fc 1
Many thanks
Ian
--
Ian Thurlbeckhttp://www.stams.strath.ac.uk/
Statistics and Modelling Science, University of Strathclyde
Livingstone Tower, 26 Richmond Street, Glasgow, UK,  G1 1XH
Tel: +44 (0)141 548 3667   Fax: +44 (0)141 552 2079
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] php-not-executing-in-html-file-help

2005-03-20 Thread Ian Firla

You need to tell apache to run html files through the php interpreter:

ie. AddType application/x-httpd-php .php .php3 .html

then restart apache

Ian

On Sun, 2005-03-20 at 14:12 -0800, vijayaraj nagarajan wrote:
> hi friends
> i am struggling to solve this problem for the past one
> week...kindly help me..
> 
> my apache runs perfectly...
> this code gives a perfect output in the browser...
> 
> file name: hi.html
> 
> 
> hihihi
> 
> 
> but this code doesnot give any output in the
> browser...
> 
> file name: hi.html
> 
> 
> 
> 
> 
> but, the same file with the php code in it...could be
> executed in the command line, using php... where i am
> getting the expected output...
> 
> i tested to c if my apache doesnt recognise php ...
> 
> this code runs perfectly...in the browser...
> 
> 
> 
> if saved as hi.php file...
> the same code saved as .html, is not giving any output
> in the browser...
> 
> kindly help me to figure out this problem...
> 
> thanks
> 
> vijayaraj nagarajan
> graduate student
> the university of southern mississippi
> MS - USA
> 
> 
> 
> ______
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> 
-- 
Ian Firla Consulting
http://ianfirla.com

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



Re: [PHP] unexplainable - page generation time class

2005-03-06 Thread Ian Firla

I think the problem is how, when and where you're calling things.

Basically, your code is fine. I modified it slightly and get the correct
output. This could still be cleaned up and optimised significantly;
however, I think you can take it from here:

Your Class:

cls_start_time = $microstart[0] + $microstart[1];
return $this->cls_start_time;
}

//
// FIGURE OUT THE TIME AT THE END OF THE PAGE
//
function stop() {
$microstop = explode(' ',microtime());
$this->cls_stop_time = $microstop[0] + $microstop[1];
return $this->cls_stop_time;
}

//
// CALCULATE THE DIFFERENCE BETWEEN THE BEGINNNG AND THE END AND
COLOR CODE THE RESULT
//
function gen($start, $stop) {
$this->cls_gen_time = $stop - $start;
return $this->cls_gen_time;
}
}
?>

index php that calls it:

start();
sleep(2);
$stop=$page_gen->stop();

echo("start/stop: $start $stop");

$gentime=$page_gen->gen($start, $stop);

echo "generation time: ". $gentime;

?>

Output:

start/stop: 1110096261.12 1110096263.13

generation time: 2.00168681145

All the best,

Ian

---
Ian Firla Consulting
http://ianfirla.com

On Sat, 2005-03-05 at 22:04 -0700, James Williams wrote:
> Howdy!  I've made a class which simply determines the page generation 
> time of a php script... After pretty much an hour of straight examining 
> the code and trying tons of different things, no good has come of it, 
> however I can't find an error... anywhere.
> 
>  class page_gen {
> //
> // PRIVATE - DO NOT MODIFY
> //
> var $cls_start_time;
> var $cls_stop_time;
> var $cls_gen_time;
> 
> //
> // FIGURE OUT THE TIME AT THE BEGINNING OF THE PAGE
> //
> function start() {
> $microstart = explode(' ',microtime());
> $this->cls_start_time = $microstart[0] + $microstart[1];
> }
> 
> //
> // FIGURE OUT THE TIME AT THE END OF THE PAGE
> //
> function stop() {
> $microstop = explode(' ',microtime());
> $this->cls_stop_time = $microstop[0] + $microstop[1];
> }
> 
> //
> // CALCULATE THE DIFFERENCE BETWEEN THE BEGINNNG AND THE END AND 
> COLOR CODE THE RESULT
> //
> function gen() {
> $this->cls_gen_time = $this->cls_stop_time - 
> $this->cls_start_time;
> return $this->cls_gen_time;
> }
> }
> ?>
> 
> What happens is it simply returns the $this->cls_start_time variable.  
> 
> Both the start() and stop() functions work fine because to test them I 
> put print commands at the end and they both returned proper results, the 
> error appears to be in the line where I minus the start time from the 
> end time.  It simply returns a negative start time instead of minusing 
> the two.
> 
> I tried changing the minus to a plus for testing sake and it just took 
> out the negative.  Does anybody have any idea what is going on here?  
> Thanks-you
> 

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



Re: [PHP] Bypassing php.ini setting for file uploads?

2005-03-02 Thread Ian Firla

There're all kinds of threads on this if you google around for a bit but
one good on in my bookmarks is:

http://www.webdevforums.com/showthread.php?t=7231

Ian

On Wed, 2005-03-02 at 09:39 -0800, Matt Cassarino wrote:
>Hi,
>
>I am trying to modify the php.ini settings for post_max_size and 
>upload_max_filesize to allow for a custom script to upload files larger than 
>8MB, the default size limit set in php.ini.  This is on a shared server, and 
>my hosting company won't modify the limitation, although they will charge me 
>$50/hr to code a custom script.  Whatever!  I'll just do it myself... but I 
>don't know how.
>
>Also, http://docs.php.net/en/function.ini-set.html tells me that for 
>post_max_size and upload_max_filesize: "Entry can be set in php.ini, .htaccess 
>or httpd.conf."
>
>Any help would be greatly appreciated!!
>
>Thanks,
>
>Matt Cassarino
>Cell: (206) 484-4626
>Web: www.mattcass.com
>Email: [EMAIL PROTECTED]

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



[PHP] Getting floats from 8 byte IEEE binary representations

2005-02-16 Thread Ian Johnson
I am trying to write a function which will read a string of bytes from a
binary file and convert 8 byte sequences to Float type data.  I've been
through the manual and can find nothing but think I must be missing
something.  It can't be that hard.  Can someone help me out.


Thanks


Ian 

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



Re: [PHP] PHP/5.0.3 & MySQL 5.0.2 Stored procedure (OUT)

2005-02-08 Thread Ian Porter
Curt Zirzow wrote:

> * Thus wrote Ian Porter:
>> Hi,
>> 
>> I am just wondering how to obtain the result from a mysql procedure OUT
>> parameter within PHP e.g.
>> 
>> MYSQL
>> create procedure test_out(OUT testvar int)
>> BEGIN
>>  select max_connections into testvar from mysql.user limit 1;
>> END
>> 
>> PHP
>> 
>> $query = 'call test_out('.$test_val.')';
>> $query_handle = mysql_query($query);
> 
> You should really be using the mysqli* interface to mysql. It
> provides better ways to execute things like that.
> 
> http://php.net/mysqli

Thanks very much, that did the trick.

Cheers
Ian
> 
> 
> Curt

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



[PHP] PHP/5.0.3 & MySQL 5.0.2 Stored procedure (OUT)

2005-02-07 Thread Ian Porter
Hi,

I am just wondering how to obtain the result from a mysql procedure OUT 
parameter within PHP e.g.

MYSQL
create procedure test_out(OUT testvar int)
BEGIN
 select max_connections into testvar from mysql.user limit 1;
END

PHP

$query = 'call test_out('.$test_val.')';
$query_handle = mysql_query($query);

but there is nothing within the $test.val, after searching the web there 
appears to be something like this for oracle connection with the bind, but I 
cannot find the mysql version ?

Any advice ?

Cheers
Ian

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



Re: [PHP] PHP displaying images

2005-01-28 Thread Ian Johnson
Jason Wong wrote:
On Saturday 29 January 2005 10:13, Ian Johnson wrote:

There is no error message in the ../httpd/error_log file.

That looks like the Apache error log file, which is most likely not what you 
want to be looking at. You want the PHP error log, see settings in php.ini, 
and check phpinfo().

My php is configured to write error messages to the http error_log and 
not to display errors.

In this case the error is displayed and not logged.
Note that there is no problem with the code from phpfreaks.  It seems to 
run for  everyone else on their computers.

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


Re: [PHP] PHP displaying images

2005-01-28 Thread Ian Johnson
This does the same for png as well.  No errors are generated when header
() is commented out or other content-types are specified

Ian Johnson



On Fri, 2005-01-28 at 20:45 -0800, Richard Lynch wrote:
> Ian Johnson wrote:
> > I am trying to use GD to create and manipulate images but the statement:
> >
> > header ("Content-type: image/jpg");
> >
> > generates the error message:
> >
> > The image "http://localhost/gdtst2.php"; cannot be displayed,
> > because
> > it contains errors.
> 
> "contains errors" here means "It's not a valid JPEG"
> 
> So comment out the header() and see if you see any error messages then.
> 
> After it looks like it's a JPEG (starts with yoya) put the header() line
> back in.
> 

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



[PHP] Problems displaying images with PHP-GD

2005-01-28 Thread Ian Johnson
Hello 

I am trying to use GD to create and manipulate images but the
statement: 

header ("Content-type: image/jpg"); 

generates the error message: 

The image "http://localhost/gdtst2.php"; cannot be displayed, because
it contains errors. 

There is no error message in the ../httpd/error_log file. 
I am using PHP 5.0.3 with GD 2.0.28.  The report from phpinfo()
indicates gd present and enabled. Other nongraphics content-types do not
gererate errors. 

Code used was "First Program" from tutorial at
http://www.phpfreaks.com/tutorials/105/1.php.  Similar code from php
manual generates the same error. 

I suspect the solution is simple but I'm just not seeing it! 

Help 

Ian Johnson 

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



[PHP] PHP displaying images

2005-01-28 Thread Ian Johnson
Hello
I am trying to use GD to create and manipulate images but the statement:
header ("Content-type: image/jpg");
generates the error message:
	The image "http://localhost/gdtst2.php"; cannot be displayed, 		because 
it contains errors.

There is no error message in the ../httpd/error_log file.
I am using PHP 5.0.3 with GD 2.0.28.  The report from phpinfo() 
indicates gd present and enabled. Other nongraphics content-types do not 
gererate errors.

Code used was "First Program" from tutorial at 
http://www.phpfreaks.com/tutorials/105/1.php.  Similar code from php 
manual generates the same error.

I suspect the solution is simple but I'm just not seeing it!
Help
Ian Johnson
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Writing new code vs. re-writing someone else's code

2004-12-21 Thread Ian Firla

Good question.

Personally, I think I tend to write more new code than reworking old
code. However, I have taken on numerous projects where I've been
required to port ASP to PHP and MSSQL dbs to Postgre or MySQL... but
these projects also require a fair bit of new code.

There are *so* many legacy COBOL applications though that, yeah, I think
a COBOL programmer will very rarely get to write anything new. The
people who I know who work with COBOL generally either patch problems
or, if there's new functionality required, will code in Java or C.

Ian

On Tue, 2004-12-21 at 11:41 +0100, Eakin, W wrote:
> Hello,
> This question could be seen as a general programming question, but 
> because PHP is what I know best, I'll ask it here.
> 
> A good friend of mine is the person who got me more interested in 
> programming as a career. She's a professional COBOL programmer, and 
> works for a large bank. She once told me that 75% of her time was spent 
> going over and rewriting/repairing old code that she didn't write, and 
> only 25% writing new code. From what I know about COBOL, it seems that 
> it might need more rewriting than other languages, because of all the 
> built up old code. But as I look forward to the day when I can work as a 
> full-time PHP coder, I wonder. The question is, how much of your time 
> (you, the professional PHP coder reading this), is spent 
> rewriting/repairing old code vs. writing new code. Although this is a 
> PHP list, and my question is in regards to PHP, if you want to give me 
> your opinion on this same question in regards to other languages you've 
> programmed in, I wouldn't mind.
> 
> thanks,
> William
> 

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



Re: [PHP] Uncompressing files on server

2004-12-20 Thread Ian Firla

Which platform?

How are the files compressed?

Do you have access to the commandline on your server?

Ian

On Sun, 2004-12-19 at 23:00 -0500, Josh wrote:
> I have some PHP files from a content management system.  I uploaded the
> compressed files to the server, but how do I un-compress them now?  I am
> using Filezilla.  Can it be done, or do I have to uncompress the file on my
> computer and then upload?
> 
> thanks
> 

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



[PHP] mixed strings

2004-12-18 Thread Ian Firla

Hi All,

I'm wondering if anyone knows if there's a way of sending strings of
mixed type to a UDP socket.

I'm storing the data I need to send in an array. Parsing the array with
a foreach, I'm sending out the various pieces to the socket with fwrite.

Unfortunately, it seems that UDP terminates each message and the client
is expecting everything in one chunk with each byte of a specific type
(ie. ASCII, INTEGER, BCD)

Is there any way I can write a string of mixed types to an open UDP
socket as a single message?

Ian

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



Re: [PHP] File-handling

2004-12-17 Thread Ian Firla

fgets uses the resource created by fopen.

Read the manual:

http://it.php.net/fopen

http://it.php.net/fgets

look at the example:



Ian

On Fri, 2004-12-17 at 11:24 +0100, [EMAIL PROTECTED] wrote:
> Hi there!
> 
> Can someone explain the major difference between fgets and fopen? Which is
> the best together with plain textfiles? and why?
> 
> eof and feof. What's the difF? *don't get it*
> 
> When using fget. Is it something special you should think when taking care
> of line-breaks? (/n, /r/n ...)
> 
> /G
> 

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



php-general@lists.php.net

2004-12-16 Thread Ian Firla
Ciao Tomas,

I'm not sure if I followed your question completely but do you mean to
test a variable or an array element and unset it if it matches a certain
type?

If so, then maybe:

http://it.php.net/is_int

is_bool(), is_float(), is_numeric(), is_string(), is_array(), and
is_object()

will be of help?

Ian

On Wed, 2004-12-15 at 22:36 +0100, Tomas Tintera wrote:
> Hi all.
> 
> Is there some construct, which evaluates any type of its parameter (like 
> t_echo, t_unset) and returns some value with normal type (like 0)? What?
> 
> I would like to unset a variable in an operation like ()?unset():() and 
> I can not use "if" because "if" does not return normal type of value 
> (like 0 or 'a') and can not be used in operations like () && ().
> 
> Tomas Tintera
> 

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



Re: [PHP] cURL FTP

2004-12-15 Thread Ian Firla
On Wed, 2004-12-15 at 08:27 -0500, Lowell Allen wrote:

 
> $fh = fopen("test.txt", "r") or die($php_errormsg);


Try opening the file "rw". At the moment, you're opening it read only.

Ian

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



Re: [PHP] "Byte Array"

2004-12-14 Thread Ian Firla
On Tue, 2004-12-14 at 08:40 -0800, Richard Lynch wrote:
> Ian Firla wrote:
> >
> > Just a follow-up to myself... I decided to try packet sniffing to see
> > what was going on and ettercap confirms that I'm sending out strings
> > rather than data of the type stored in my array:
> >
> > 16:12:26  192.168.0.101:32779 --> 192.168.0.88:32896 | UDP |
> >
> >  : 3331 31
> >
> > That "31" should be an integer of only one byte, not two.
> 
> I suspect that PHP is converting your integers into strings at some point,
> as you build the array...
> 
> *WHERE* it is doing that is difficult to say, without seeing more code.
> 
> > The function that's doing the sending looks like this:
> >
> > function send_back($sock, $msg, $ip, $port) {
> > $fp = fsockopen("udp://$ip", $port, $errno, $errstr);
> > foreach ($msg as $msg_to_send) {
> 
> //To confirm my suspicion that you have a string here:
> error_log("The type of $msg_to_send is " . gettype($msg_to_send));
> //Now go check your PHP error log (default: Apache error_log)

Thanks Richard.

I thought of that too and have since expanded my debugging. The types
are correct when passed to fwrite. They come out the other end as
strings:

16:39:54 SENT 'K' of type string
16:39:54 SENT '0' of type integer
16:39:54 SENT '0' of type integer
16:39:54 SENT '65' of type integer
16:39:54 SENT '31' of type integer

15:46:10  192.168.0.101:32778 --> 192.168.0.84:32896 | UDP |

 : 4b   K


15:46:10  192.168.0.101:32778 --> 192.168.0.84:32896 | UDP |


 : 30   0


15:46:10  192.168.0.101:32778 --> 192.168.0.84:32896 | UDP |

 : 30   0


15:46:10  192.168.0.101:32778 --> 192.168.0.84:32896 | UDP |

 : 3635 65


15:46:10  192.168.0.101:32778 --> 192.168.0.84:32896 | UDP |

 : 3331 31

As you can see, the last two elements "65" and "31" have arrived as
strings of two bytes rather than integers of one.

Ian


> > fwrite($fp, $msg_to_send);
> > echo date("H:i:s")." SENT '$msg_to_send'\n"; //seen server 
> > side
> > }
> > fclose($fp);
> > }
> >
> > Can anyone see where I might be going wrong? Why am I not sending the
> > integers as integers and the binary bits as binary bits?
> 
> -- 
> Like Music?
> http://l-i-e.com/artists.htm
> 

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


Re: [PHP] "Byte Array"

2004-12-13 Thread Ian Firla

Just a follow-up to myself... I decided to try packet sniffing to see
what was going on and ettercap confirms that I'm sending out strings
rather than data of the type stored in my array:

16:12:26  192.168.0.101:32779 --> 192.168.0.88:32896 | UDP |

 : 3331 31

That "31" should be an integer of only one byte, not two.

The function that's doing the sending looks like this:

function send_back($sock, $msg, $ip, $port) {
$fp = fsockopen("udp://$ip", $port, $errno, $errstr);
foreach ($msg as $msg_to_send) {
fwrite($fp, $msg_to_send);
echo date("H:i:s")." SENT '$msg_to_send'\n"; //seen server 
side
}
fclose($fp);
}

Can anyone see where I might be going wrong? Why am I not sending the
integers as integers and the binary bits as binary bits?

Ian

On Tue, 2004-12-14 at 12:12 +0100, Ian Firla wrote:
> You're right. I think it will. Thanks.
> 
> I've got another issue now though which may indeed be a show-stopper.
> 
> It seems that while socket_recvfrom is binary safe, there's no way to
> send data in any way other than a string... Is that right? Can I not
> send data of other types?
> 
> Ian
> 
> On Mon, 2004-12-13 at 07:57 -0800, Chris wrote:
> > Try the unpack function, it should do quite nicely.
> > 
> > Chris
> > 
> > Ian Firla wrote:
> > 
> > >Hello All,
> > >
> > >I've hit a bit of a show stopper in a project I'm working on.
> > >
> > >I'm getting a 65 byte stream of data. 32 of those bytes are of the type
> > >"Byte Array". Is there a way that I can covert that data into something
> > >useful?
> > >
> > >For the record, the data stream that I'm getting is in the format:
> > >
> > >|ascii|ascii|asciiX10|integerX4|byte arrayX32|
> > >
> > >The byte array looks like this: 
> > >gÃ.ÃÃ.ÃÆÃÃÂÃUâÃAÃÂ9xÅÂÃ|%ÃrÂÃ9â.
> > >
> > >Any ideas?
> > >
> > >Ian
> > >
> > >  
> > >
> > 
> 

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



Re: [PHP] "Byte Array"

2004-12-13 Thread Ian Firla

You're right. I think it will. Thanks.

I've got another issue now though which may indeed be a show-stopper.

It seems that while socket_recvfrom is binary safe, there's no way to
send data in any way other than a string... Is that right? Can I not
send data of other types?

Ian

On Mon, 2004-12-13 at 07:57 -0800, Chris wrote:
> Try the unpack function, it should do quite nicely.
> 
> Chris
> 
> Ian Firla wrote:
> 
> >Hello All,
> >
> >I've hit a bit of a show stopper in a project I'm working on.
> >
> >I'm getting a 65 byte stream of data. 32 of those bytes are of the type
> >"Byte Array". Is there a way that I can covert that data into something
> >useful?
> >
> >For the record, the data stream that I'm getting is in the format:
> >
> >|ascii|ascii|asciiX10|integerX4|byte arrayX32|
> >
> >The byte array looks like this: 
> >gÃ.ÃÃ.ÃÆÃÃÂÃUâÃAÃÂ9xÅÂÃ|%ÃrÂÃ9â.
> >
> >Any ideas?
> >
> >Ian
> >
> >  
> >
> 

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



[PHP] "Byte Array"

2004-12-13 Thread Ian Firla

Hello All,

I've hit a bit of a show stopper in a project I'm working on.

I'm getting a 65 byte stream of data. 32 of those bytes are of the type
"Byte Array". Is there a way that I can covert that data into something
useful?

For the record, the data stream that I'm getting is in the format:

|ascii|ascii|asciiX10|integerX4|byte arrayX32|

The byte array looks like this: 
gÃ.ÃÃ.ÃÆÃÃÂÃUâÃAÃÂ9xÅÂÃ|%ÃrÂÃ9â.

Any ideas?

Ian

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



[PHP] Security Question with my password protected login script...

2004-12-08 Thread Ian Gray
Hello all,

I have the following script called login.inc which I include at the
beginning of each page on my customer control panel.  Basically it checks to
see if a session has been created with user details and if it has it carries
on with the rest of the page and if not the login screen is printed.

My question is, how secure is this?  I have the password, username etc in a
MYSQL database but I haven't encrypted it (don't know how)

Should I have login.inc in a folder below my public_html directory?

I have removed some details such as passwords and swapped that with question
marks.

Many thanks,

Ian Gray

Here is the code?




http://www.w3.org/1999/xhtml";>


Customer Login



Re: [PHP] How do I su to another account??

2004-11-11 Thread Ian Firla

Do you really need to switch users or do you need to run something as
another user?

Try looking into setting up and using sudo.

Ian

On Thu, 2004-11-11 at 09:20 -0500, Scott Fletcher wrote:
> How do I su (switch user) to another account from the nobody in php?  I
> haven't got it to work, so I get the impression that it is either I'm doing
> it all wrong in PHP script or that the nobody doesn't have the authority to
> do so.
> 
> Have anyone who ever successfully do it please post a sample script?
> 
> Thanks,
>  Scott
> 

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



Re: [PHP] passing resources from one script to another

2004-11-11 Thread Ian Firla

Thanks Greg.

That is what I'm doing.

The problem remains passing a resource to the script executed by exec.

Ian

On Thu, 2004-11-11 at 08:45 -0600, Greg Donald wrote:
> On Thu, 11 Nov 2004 15:15:56 +0100, Ian Firla <[EMAIL PROTECTED]> wrote:
> > The problem is the dialogue with the client. If I enter into a while
> > loop then the whole script remains occupied and cannot accept new
> > connections.
> 
> PHP doesn't have threads.. and that's what you would need to accept
> more than a single connection at once.  You can simulate thread
> functionality to a degree using the PHP execution functions here:
> 
> http://www.php.net/manual/en/ref.exec.php
> 
> 
> -- 
> Greg Donald
> Zend Certified Engineer
> http://gdconsultants.com/
> http://destiney.com/
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> F

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



Re: [PHP] passing resources from one script to another

2004-11-11 Thread Ian Firla

I should have specified that this is a shell script, not a web
application.

I have a listening process running. The listening process calls another
script once a connection is established. This is done via exec.

It works; however, I can't pass a resource directly to the other script.
Therefore, I've passed the resource to "serialize()" and pass the
resulting string to the other script as an argument. My idea was to
"unserialize" the string in that script. I expected to get a resource
back; unfortunately, I get an integer.

My question is: is there any way to pass a Resource between scripts?

Ian

On Thu, 2004-11-11 at 15:36 +0100, Sebastiano Cascione wrote:
> I'm not shure to understand what you are looking for...
> 
> You can build a message queue into a text file, every message in the queue 
> will contain the pid as identifier of every socket connetion (the client) and 
> the target pid. 
> This is not a fast solution, but it models a messages system that is 
> indipendent from the server. For example, this queue colud be readed from the 
> client every time it launchs an avent, ect..
> 
> A question, why don't use session vars? (or an array of them?)
> 
> Sebastiano
> 
> 
> Alle 15:15, giovedì 11 novembre 2004, Ian Firla ha scritto:
> > Hi All,
> >
> > I'm developing a small server application that accepts connections on a
> > socket and then launches an interactive session with the client.
> >
> > The server needs to be able to accept N connections. This part is
> > working famously thanks to code I've borrowed and modified from:
> >
> > http://www.zend.com/lists/php-dev/200205/msg00286.html
> >
> > The problem is the dialogue with the client. If I enter into a while
> > loop then the whole script remains occupied and cannot accept new
> > connections.
> >
> > If I try to open a new background process with exec, then I need to pass
> > a resource from the listening script to the dialogue script. However, it
> > seems that I cannot pass a resource between scripts.
> >
> > If I serialize the resource, passing it as a string to the dialogue
> > shell script, then unserialize it in the dialogue script, it's no longer
> > a resource but an integer...
> >
> > Any ideas on how to get around this problem? Can it be done with PHP?
> >
> > Ian

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



[PHP] passing resources from one script to another

2004-11-11 Thread Ian Firla

Hi All,

I'm developing a small server application that accepts connections on a
socket and then launches an interactive session with the client.

The server needs to be able to accept N connections. This part is
working famously thanks to code I've borrowed and modified from:

http://www.zend.com/lists/php-dev/200205/msg00286.html

The problem is the dialogue with the client. If I enter into a while
loop then the whole script remains occupied and cannot accept new
connections.

If I try to open a new background process with exec, then I need to pass
a resource from the listening script to the dialogue script. However, it
seems that I cannot pass a resource between scripts.

If I serialize the resource, passing it as a string to the dialogue
shell script, then unserialize it in the dialogue script, it's no longer
a resource but an integer...

Any ideas on how to get around this problem? Can it be done with PHP?

Ian

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



Re: [PHP] Most efficient way of fetching 1,000 records from MySQL ?

2004-10-25 Thread Ian Firla

I think you'll find that your first approach is not only more correct,
it's the only manageable one.

Ian

On Mon, 2004-10-25 at 10:15 +0200, Steve McGill wrote:
> Hello,
> 
> In my script I have generated an array of 1,000 userIDs for example. Now for
> I need to fetch each user's record and I am wondering what is the best way
> to go about it:
> 
> 1) 1000 sql queries
> 
> // code is sort of pseudo for clarity
> 
> foreach($users as $userID) {
>   $user = sql("select * from users where userID = '$userID'");
>   // bla bla
> }
> 
> 2) 1 query
> 
> $users = sql("select * from users where userID='1' or userID='2' or
> userID='5' or userID='10'");
> 
> I imagine the 2nd one would be a bit of a nightmare for MySQL to parse, if
> it gets too long?
> 
> Or am I missing a more efficient 3rd / 4th option?
> 
> Many thanks in advance for your help.
> 
> Steve McGill
> 

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



Re: [PHP] PHP App User Permissions Tecnique

2004-10-15 Thread Ian Firla

Definitely store them in a session. A db lookup will mean a much heavier
and process intensive procedure.

Ian

On Fri, 2004-10-15 at 09:41, Brendon wrote:
> I am building a web based community forum type software using PHP. I am 
> currently working on how different user privelages are handled. Each 
> user is part of a group and each group has varying degrees of privelages.
> 
> I need to add in functionality which at the begginning of every script 
> check the permission level of the user accessing the page. There are 
> about 15 different permissions.
> 
> I am debating whether i should store all the permission abilities into 
> session variables and they can quickly be checked throughout the script, 
> or whether i should query the database to check to see if the user has 
> adequate group permissions to perform a certain function.
> 
> Could someone give me some advice as to which would be more advisable?

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



  1   2   3   >