Re: [PHP] Wiki recommendation?

2009-11-25 Thread TG
Well, if you want to get really extreme, you could use TiddlyWiki:
http://www.tiddlywiki.com/

It's a wiki contained in a single HTML file.  No database.  No server side 
scripting.  No server!  hah

-TG

- Original Message -
From: Skip Evans 
To: TG 
Cc: Jonathan Tapicer , aurfal...@gmail.com, 
"php-general@lists.php.net" 
Date: Wed, 25 Nov 2009 22:33:54 -0600
Subject: Re: [PHP] Wiki recommendation?

> Hey all,
> 
> Thanks much for the recommendations. I'll check them out.
> 
> We don't need fine grained control over access; basically 
> admins that can modify content and the public who cannot.
> 
> But right now DocuWiki is sounding good, and I'd rather, for 
> some strange reason, not use a DB, although I can't justify 
> that in any rational way. I mean, MySQL is already on the machine.
> 
> Thanks again!
> 
> Skip
> 
> TG wrote:
> > A while back I set up a TikiWiki for a client.  I think I liked it 
better 
> > than any of the other wikis I've messed with.  But honestly, I didn't 
get 
> > to use it much and I've only ever used Mediawiki to any real length.
> > 
> > Definitely give it a look, though.
> > 
> > -TG
> > 
> > - Original Message -
> > From: Jonathan Tapicer 
> > To: aurfal...@gmail.com
> > Cc: Skip Evans , "php-general@lists.php.net" 
> > 
> > Date: Wed, 25 Nov 2009 23:54:07 -0300
> > Subject: Re: [PHP] Wiki recommendation?
> > 
> >> On Wed, Nov 25, 2009 at 8:37 PM,   wrote:
> >>> On Nov 25, 2009, at 2:42 PM, Skip Evans wrote:
> >>>
>  Hey all,
> 
>  I'm looking for a good Wiki to maintain documentation on a large
>  commercial web site that is always growing.
> 
>  DokuWiki is the only one I've installed and used at any length, so 
> > before
>  I just use that one again I'd like to hear from the peanut gallery 
what
>  other suggestions you'd have.
> 
>  Remember, this will be for end user documentation for a large 
> > commercial
>  CMS type system, something site admins will go to for information on 
> > site
>  features, updates, etc.
> 
>  Let the shouting begin!
> 
>  Thanks, all, and a very happy eating-charred-dead-bird-flesh day to 
you
>  all!!!
> 
>  Skip
> >>>
> >>> Well, I've used DocuWiki and bit new to MediaWiki which I think 
> > WikiPedia
> >>> uses.
> >>>
> >>> MediaWiki uses a MySQL DB were as DocuWiki is a tree dir structure 
kind 
> > of
> >>> thing.
> >>>
> >>> I actually prefer DocuWiki but maybe thats because I didn't setup 
> > MediaWiki
> >>> correctly.
> >>>
> >>> Cacti uses DocuWiki by the way and I personally avoid DB usage if 
> > possible.
> >>> I think its easier to corrupt a DB then it is to corrupt a filesystem.
> >>>
> >>> However I'm unsure of how scalable a pure file system based Wiki is, 
I 
> > think
> >>> if you put it on a mirrored disk with a decent cache on the Raid 
> > controller,
> >>> you'll be fine performance and DR wise.
> >>>
> >>> If its Linux, then MD based (software raids) works pretty well.
> >>>
> >>> - aurf
> >>>
> >>>
> >>>
> >>> --
> >>> PHP General Mailing List (http://www.php.net/)
> >>> To unsubscribe, visit: http://www.php.net/unsub.php
> >>>
> >>>
> >> I also recommend dokuwiki (with a k, not c :) ): 
http://www.dokuwiki.org/
> >>
> >> Regards,
> >>
> >> Jonathan
> >>
> >> -- 
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >>
> > 
> 
> -- 
> 
> Skip Evans
> PenguinSites.com, LLC
> 503 S Baldwin St, #1
> Madison WI 53703
> 608.250.2720
> http://penguinsites.com
> 
> Those of you who believe in
> telekinesis, raise my hand.
>   -- Kurt Vonnegut
> 
> -- 
> 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] Detecting The Encoding Of A Text File

2009-11-25 Thread Nitsan Bin-Nun
Hi,

I have been trying for the last couple of hours to determine the
encoding of a text file (.txt in windowz).

I have this code:

$contents = file_get_contents($config['
txt_dir'] . $file);
$encoding = mb_detect_encoding($contents,
"UTF-8,ISO-8859-1,WINDOWS-1252"); //,Windows-1255

echo "||encoding:".$encoding."||";

if ($encoding == 'UTF-8')
{
$utfcontents = $contents;
}
else if ($encoding == 'ISO-8859-1')
{
$utfcontents = utf8_encode($contents);
}

var_dump($utfcontents);

The $encoding is ISO-8859-1, the text file contains Hebrew characters, then
I'm converting it to utf8.

The above code is outputing gibbrish, it seems that it has converted it in
some way but not in the
proper way that it should have converted it.

My page is UTF-8 encoded, without BOM, I send UTF-8 headers to the browser
and HTML content
encoding meta tag as well.

I have no idea what I am doing wrong.

I would highly appreciate it if someone could point me to the right
direction.

Thanks in Advance,

Nitsan


Re: [PHP] Wiki recommendation?

2009-11-25 Thread Skip Evans

Hey all,

Thanks much for the recommendations. I'll check them out.

We don't need fine grained control over access; basically 
admins that can modify content and the public who cannot.


But right now DocuWiki is sounding good, and I'd rather, for 
some strange reason, not use a DB, although I can't justify 
that in any rational way. I mean, MySQL is already on the machine.


Thanks again!

Skip

TG wrote:
A while back I set up a TikiWiki for a client.  I think I liked it better 
than any of the other wikis I've messed with.  But honestly, I didn't get 
to use it much and I've only ever used Mediawiki to any real length.


Definitely give it a look, though.

-TG

- Original Message -
From: Jonathan Tapicer 
To: aurfal...@gmail.com
Cc: Skip Evans , "php-general@lists.php.net" 


Date: Wed, 25 Nov 2009 23:54:07 -0300
Subject: Re: [PHP] Wiki recommendation?


On Wed, Nov 25, 2009 at 8:37 PM,   wrote:

On Nov 25, 2009, at 2:42 PM, Skip Evans wrote:


Hey all,

I'm looking for a good Wiki to maintain documentation on a large
commercial web site that is always growing.

DokuWiki is the only one I've installed and used at any length, so 

before

I just use that one again I'd like to hear from the peanut gallery what
other suggestions you'd have.

Remember, this will be for end user documentation for a large 

commercial
CMS type system, something site admins will go to for information on 

site

features, updates, etc.

Let the shouting begin!

Thanks, all, and a very happy eating-charred-dead-bird-flesh day to you
all!!!

Skip


Well, I've used DocuWiki and bit new to MediaWiki which I think 

WikiPedia

uses.

MediaWiki uses a MySQL DB were as DocuWiki is a tree dir structure kind 

of

thing.

I actually prefer DocuWiki but maybe thats because I didn't setup 

MediaWiki

correctly.

Cacti uses DocuWiki by the way and I personally avoid DB usage if 

possible.

I think its easier to corrupt a DB then it is to corrupt a filesystem.

However I'm unsure of how scalable a pure file system based Wiki is, I 

think
if you put it on a mirrored disk with a decent cache on the Raid 

controller,

you'll be fine performance and DR wise.

If its Linux, then MD based (software raids) works pretty well.

- aurf



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



I also recommend dokuwiki (with a k, not c :) ): http://www.dokuwiki.org/

Regards,

Jonathan

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






--

Skip Evans
PenguinSites.com, LLC
503 S Baldwin St, #1
Madison WI 53703
608.250.2720
http://penguinsites.com

Those of you who believe in
telekinesis, raise my hand.
 -- Kurt Vonnegut

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



Re: [PHP] Wiki recommendation?

2009-11-25 Thread TG
A while back I set up a TikiWiki for a client.  I think I liked it better 
than any of the other wikis I've messed with.  But honestly, I didn't get 
to use it much and I've only ever used Mediawiki to any real length.

Definitely give it a look, though.

-TG

- Original Message -
From: Jonathan Tapicer 
To: aurfal...@gmail.com
Cc: Skip Evans , "php-general@lists.php.net" 

Date: Wed, 25 Nov 2009 23:54:07 -0300
Subject: Re: [PHP] Wiki recommendation?

> On Wed, Nov 25, 2009 at 8:37 PM,   wrote:
> > On Nov 25, 2009, at 2:42 PM, Skip Evans wrote:
> >
> >> Hey all,
> >>
> >> I'm looking for a good Wiki to maintain documentation on a large
> >> commercial web site that is always growing.
> >>
> >> DokuWiki is the only one I've installed and used at any length, so 
before
> >> I just use that one again I'd like to hear from the peanut gallery what
> >> other suggestions you'd have.
> >>
> >> Remember, this will be for end user documentation for a large 
commercial
> >> CMS type system, something site admins will go to for information on 
site
> >> features, updates, etc.
> >>
> >> Let the shouting begin!
> >>
> >> Thanks, all, and a very happy eating-charred-dead-bird-flesh day to you
> >> all!!!
> >>
> >> Skip
> >
> >
> > Well, I've used DocuWiki and bit new to MediaWiki which I think 
WikiPedia
> > uses.
> >
> > MediaWiki uses a MySQL DB were as DocuWiki is a tree dir structure kind 
of
> > thing.
> >
> > I actually prefer DocuWiki but maybe thats because I didn't setup 
MediaWiki
> > correctly.
> >
> > Cacti uses DocuWiki by the way and I personally avoid DB usage if 
possible.
> >
> > I think its easier to corrupt a DB then it is to corrupt a filesystem.
> >
> > However I'm unsure of how scalable a pure file system based Wiki is, I 
think
> > if you put it on a mirrored disk with a decent cache on the Raid 
controller,
> > you'll be fine performance and DR wise.
> >
> > If its Linux, then MD based (software raids) works pretty well.
> >
> > - aurf
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> 
> I also recommend dokuwiki (with a k, not c :) ): http://www.dokuwiki.org/
> 
> Regards,
> 
> Jonathan
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

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



Re: [PHP] Wiki recommendation?

2009-11-25 Thread Jonathan Tapicer
On Wed, Nov 25, 2009 at 8:37 PM,   wrote:
> On Nov 25, 2009, at 2:42 PM, Skip Evans wrote:
>
>> Hey all,
>>
>> I'm looking for a good Wiki to maintain documentation on a large
>> commercial web site that is always growing.
>>
>> DokuWiki is the only one I've installed and used at any length, so before
>> I just use that one again I'd like to hear from the peanut gallery what
>> other suggestions you'd have.
>>
>> Remember, this will be for end user documentation for a large commercial
>> CMS type system, something site admins will go to for information on site
>> features, updates, etc.
>>
>> Let the shouting begin!
>>
>> Thanks, all, and a very happy eating-charred-dead-bird-flesh day to you
>> all!!!
>>
>> Skip
>
>
> Well, I've used DocuWiki and bit new to MediaWiki which I think WikiPedia
> uses.
>
> MediaWiki uses a MySQL DB were as DocuWiki is a tree dir structure kind of
> thing.
>
> I actually prefer DocuWiki but maybe thats because I didn't setup MediaWiki
> correctly.
>
> Cacti uses DocuWiki by the way and I personally avoid DB usage if possible.
>
> I think its easier to corrupt a DB then it is to corrupt a filesystem.
>
> However I'm unsure of how scalable a pure file system based Wiki is, I think
> if you put it on a mirrored disk with a decent cache on the Raid controller,
> you'll be fine performance and DR wise.
>
> If its Linux, then MD based (software raids) works pretty well.
>
> - aurf
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

I also recommend dokuwiki (with a k, not c :) ): http://www.dokuwiki.org/

Regards,

Jonathan

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



Re: [PHP] PHP Equivalent to Java Jar or Python Eggs

2009-11-25 Thread James McLean
On Thu, Nov 26, 2009 at 11:50 AM,   wrote:
>
> Has anyone done any work towards packaging of PHP in a manner similar to jar 
> or eggs? I was working on a project the other day with a lot of class files 
> and thought this would be a cool, simple way to deploy the app.

Yes; Greg Beaver has done a lot of work with PHAR, which is very
similar. See http://au2.php.net/phar

Cheers

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



[PHP] PHP Equivalent to Java Jar or Python Eggs

2009-11-25 Thread c4632

Has anyone done any work towards packaging of PHP in a manner similar to jar or 
eggs? I was working on a project the other day with a lot of class files and 
thought this would be a cool, simple way to deploy the app. 




Re: [PHP] how to prevent a mild DOSS attack?

2009-11-25 Thread LinuxManMikeC
On Wed, Nov 25, 2009 at 3:57 PM, Ashley Sheridan
 wrote:
> On Wed, 2009-11-25 at 16:38 -0600, LAMP wrote:
>
>> hi guys,
>> this morning I got complains from website owner and tons of visitors -
>> nobody was able to access the website. it will just timeout.
>> I contacted hosting company  for more info but they said the virtual
>> privet server, where the website is, has a lot of traffic and 512MB of
>> RAM is not enough and I have to make an upgrade to at least 1GB etc.
>> it does a make a sense.
>> though, at 4pm I, nor 10 other people I asked for help, was able to
>> access to the website.
>> it was a little bit fishy about BIG traffic whole day long (the website
>> is far from it) and, since I don't have a problem accessing WHM/cPanel
>> of the server, I downloaded apache access file (stupid, I supposed to do
>> it in the morning) and found 20-30 IP addresses, repeatedly were trying
>> to access one (only one) page (something like article.php). and they
>> were requesting the same page so frequently - nobody else was able to
>> access to the website. it looked to me like a little DOSS attack - where
>> attacker wanted just to make the website busy, not to crush the server.
>> I contacted hosting company again. they said there is nothing they can
>> do about this-  even I'm paying them to manage my virtual server (I can
>> manage this way by my self too). of course they can if I pay extra :-(
>>
>> now, my question is: is there anything I can do to stop these attacks
>> using php? something? anything?
>>
>> thanks
>> L
>>
>
>
> There's nothing you could do with PHP to fix this really, as trying to
> block IP addresses from there would be expensive for the processor and
> memory of the server.
>
> You could use the cPanel to block access to the offending IP addresses
> though.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>

Ok... serious answer.  The DoS is either coming from script kiddies
dumb enough to do it from their own IP, or its coming from a bot-net
comprised of computers who's owners are morons and don't keep their
computer secure. Either way, do a WHOIS, reverse DNS query, and
traceroute on the IPs.  You should be able to find the ISPs of the
attacking systems.  Email the ISP tech department with your info and
let them take care of the offending systems.

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



Re: [PHP] how to prevent a mild DOSS attack?

2009-11-25 Thread LinuxManMikeC
Or DoS back at em. :-D

On Wed, Nov 25, 2009 at 3:57 PM, Ashley Sheridan
 wrote:
> On Wed, 2009-11-25 at 16:38 -0600, LAMP wrote:
>
>> hi guys,
>> this morning I got complains from website owner and tons of visitors -
>> nobody was able to access the website. it will just timeout.
>> I contacted hosting company  for more info but they said the virtual
>> privet server, where the website is, has a lot of traffic and 512MB of
>> RAM is not enough and I have to make an upgrade to at least 1GB etc.
>> it does a make a sense.
>> though, at 4pm I, nor 10 other people I asked for help, was able to
>> access to the website.
>> it was a little bit fishy about BIG traffic whole day long (the website
>> is far from it) and, since I don't have a problem accessing WHM/cPanel
>> of the server, I downloaded apache access file (stupid, I supposed to do
>> it in the morning) and found 20-30 IP addresses, repeatedly were trying
>> to access one (only one) page (something like article.php). and they
>> were requesting the same page so frequently - nobody else was able to
>> access to the website. it looked to me like a little DOSS attack - where
>> attacker wanted just to make the website busy, not to crush the server.
>> I contacted hosting company again. they said there is nothing they can
>> do about this-  even I'm paying them to manage my virtual server (I can
>> manage this way by my self too). of course they can if I pay extra :-(
>>
>> now, my question is: is there anything I can do to stop these attacks
>> using php? something? anything?
>>
>> thanks
>> L
>>
>
>
> There's nothing you could do with PHP to fix this really, as trying to
> block IP addresses from there would be expensive for the processor and
> memory of the server.
>
> You could use the cPanel to block access to the offending IP addresses
> though.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>

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



Re: [PHP] Wiki recommendation?

2009-11-25 Thread aurfalien

On Nov 25, 2009, at 2:42 PM, Skip Evans wrote:


Hey all,

I'm looking for a good Wiki to maintain documentation on a large  
commercial web site that is always growing.


DokuWiki is the only one I've installed and used at any length, so  
before I just use that one again I'd like to hear from the peanut  
gallery what other suggestions you'd have.


Remember, this will be for end user documentation for a large  
commercial CMS type system, something site admins will go to for  
information on site features, updates, etc.


Let the shouting begin!

Thanks, all, and a very happy eating-charred-dead-bird-flesh day to  
you all!!!


Skip



Well, I've used DocuWiki and bit new to MediaWiki which I think  
WikiPedia uses.


MediaWiki uses a MySQL DB were as DocuWiki is a tree dir structure  
kind of thing.


I actually prefer DocuWiki but maybe thats because I didn't setup  
MediaWiki correctly.


Cacti uses DocuWiki by the way and I personally avoid DB usage if  
possible.


I think its easier to corrupt a DB then it is to corrupt a filesystem.

However I'm unsure of how scalable a pure file system based Wiki is, I  
think if you put it on a mirrored disk with a decent cache on the Raid  
controller, you'll be fine performance and DR wise.


If its Linux, then MD based (software raids) works pretty well.

- aurf



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



[PHP] Re: Create client certificate with openssl

2009-11-25 Thread Manuel Lemos
Hello,

on 11/25/2009 05:53 AM Tanveer Chowdhury said the following:
> Hi all,
> 
> I have an apache server and for that I created CA as the signing authority
> using openssl.
> 
> Now I created a  php page which will generate client certificates with key
> and will sign by CA. Now the output is in .pem .
> Now how to convert it in .p12 for exporting it in client browser..
> 
> Again, If using exec gives another problem which is it asks for export
> password so how to give this via php.

You may want to take a look at this class:

http://www.phpclasses.org/crypt_openssl

-- 

Regards,
Manuel Lemos

Find and post PHP jobs
http://www.phpclasses.org/jobs/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

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



[PHP] register_globals and sessions

2009-11-25 Thread Allen McCabe
LPAC - Arts for Youth - Seat OrdersI am getting the following error message,
but ONLY on a page where I am querying multiple tables, and I don't see the
correlation:

*
*
*Warning*: Unknown: Your script possibly relies on a session side-effect
which existed until PHP 4.2.3. Please be advised that the session extension
does not consider global variables as a source of data, unless
register_globals is enabled. You can disable this functionality and this
warning by setting session.bug_compat_42 or session.bug_compat_warn to off,
respectively in *Unknown* on line *0*

I have Googled this extensively, and the solutions other people tried
(turning off the warning) don't work for me; I don't have permission to my
PHP settings (currently working on a free-hosted site).

Does ANYONE know what might be causing this?

On my login page, I use this code snippet to instantiate my SESSION
variables for the session:

// Register $myusername, $mypassword and redirect to "default.php?page=211"
$_SESSION['myusername'] = $myusername;
$_SESSION['mypassword'] = $mypassword;

Again, the error only comes up on the page where I am querying multiple.

If you would like to take a look at this, follow this link and sign in as
username: micky  & password: 123456 (
http://lpacmarketing.hostzi.com/afy/orders/)

You will notice on other pages, that error doesn't display, just this one.

Any help would be wonderful, I don't want my users to see this when the
order system is opened for their use.

Thanks!


Re: [PHP] how to prevent a mild DOSS attack?

2009-11-25 Thread Ashley Sheridan
On Wed, 2009-11-25 at 16:38 -0600, LAMP wrote:

> hi guys,
> this morning I got complains from website owner and tons of visitors - 
> nobody was able to access the website. it will just timeout.
> I contacted hosting company  for more info but they said the virtual 
> privet server, where the website is, has a lot of traffic and 512MB of 
> RAM is not enough and I have to make an upgrade to at least 1GB etc.
> it does a make a sense.
> though, at 4pm I, nor 10 other people I asked for help, was able to 
> access to the website.
> it was a little bit fishy about BIG traffic whole day long (the website 
> is far from it) and, since I don't have a problem accessing WHM/cPanel 
> of the server, I downloaded apache access file (stupid, I supposed to do 
> it in the morning) and found 20-30 IP addresses, repeatedly were trying 
> to access one (only one) page (something like article.php). and they 
> were requesting the same page so frequently - nobody else was able to 
> access to the website. it looked to me like a little DOSS attack - where 
> attacker wanted just to make the website busy, not to crush the server.
> I contacted hosting company again. they said there is nothing they can 
> do about this-  even I'm paying them to manage my virtual server (I can 
> manage this way by my self too). of course they can if I pay extra :-(
> 
> now, my question is: is there anything I can do to stop these attacks 
> using php? something? anything?
> 
> thanks
> L
> 


There's nothing you could do with PHP to fix this really, as trying to
block IP addresses from there would be expensive for the processor and
memory of the server.

You could use the cPanel to block access to the offending IP addresses
though.

Thanks,
Ash
http://www.ashleysheridan.co.uk




[PHP] Wiki recommendation?

2009-11-25 Thread Skip Evans

Hey all,

I'm looking for a good Wiki to maintain documentation on a 
large commercial web site that is always growing.


DokuWiki is the only one I've installed and used at any 
length, so before I just use that one again I'd like to hear 
from the peanut gallery what other suggestions you'd have.


Remember, this will be for end user documentation for a large 
commercial CMS type system, something site admins will go to 
for information on site features, updates, etc.


Let the shouting begin!

Thanks, all, and a very happy eating-charred-dead-bird-flesh 
day to you all!!!


Skip

--

Skip Evans
PenguinSites.com, LLC
503 S Baldwin St, #1
Madison WI 53703
608.250.2720
http://penguinsites.com

Those of you who believe in
telekinesis, raise my hand.
 -- Kurt Vonnegut

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



Re: [PHP] function not returning query

2009-11-25 Thread Philip Thompson
On Nov 25, 2009, at 4:32 AM, Ashley Sheridan wrote:

> On Tue, 2009-11-24 at 23:27 -0800, Allen McCabe wrote:
> 
>> If I were to loop through my inputs, I could just exclude any
>> problematic names, eg.:
>> 
>> foreach ($_POST as $var = $val)
>> {
>>   if ($var != filter.x || $var != filter.y)
>>  {
>>$var = $val;
>>  }
>> }
>> 
>> Like that?



> Not really, what if someone else decided they wanted to throw in their
> own form field values in the hope of breaking your system? It's much
> better to be specifically looking for certain form fields and certain
> field values/ranges. For example, if you had some fields that would
> filter something by cost, you might have two form fields named 'max' and
> 'min' which would be ranges for the cost. You should check that these
> fields only contain numbers for example before processing them. Any data
> coming from the client-side is untrustworthy and should be regarded as
> tainted until you can prove otherwise.
> 
> Thanks,
> Ash

The system Ash is referring to is a whitebox approach. You know what you should 
get in, so only accept those values. A simple thing to accomplish what you're 
trying to do, Allen, would be to create an array of required/accepted fields...

 $val) {
if (in_array ($var, $acceptable)) {
// Do whatever here
} else {
// Not acceptable - throw error message or do nothing
}
}
?>

Hope that helps.
~Philip
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] how to prevent a mild DOSS attack?

2009-11-25 Thread LAMP

hi guys,
this morning I got complains from website owner and tons of visitors - 
nobody was able to access the website. it will just timeout.
I contacted hosting company  for more info but they said the virtual 
privet server, where the website is, has a lot of traffic and 512MB of 
RAM is not enough and I have to make an upgrade to at least 1GB etc.

it does a make a sense.
though, at 4pm I, nor 10 other people I asked for help, was able to 
access to the website.
it was a little bit fishy about BIG traffic whole day long (the website 
is far from it) and, since I don't have a problem accessing WHM/cPanel 
of the server, I downloaded apache access file (stupid, I supposed to do 
it in the morning) and found 20-30 IP addresses, repeatedly were trying 
to access one (only one) page (something like article.php). and they 
were requesting the same page so frequently - nobody else was able to 
access to the website. it looked to me like a little DOSS attack - where 
attacker wanted just to make the website busy, not to crush the server.
I contacted hosting company again. they said there is nothing they can 
do about this-  even I'm paying them to manage my virtual server (I can 
manage this way by my self too). of course they can if I pay extra :-(


now, my question is: is there anything I can do to stop these attacks 
using php? something? anything?


thanks
L

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



[PHP] Detecting The Encoding Of A Text File

2009-11-25 Thread Nitsan Bin-Nun
Hi,

I have been trying for the last couple of hours to determine the
encoding of a text file (.txt in windowz).

I have this code:

$contents = file_get_contents($config['txt_dir'] . $file);
$encoding = mb_detect_encoding($contents,
"UTF-8,ISO-8859-1,WINDOWS-1252"); //,Windows-1255

echo "||encoding:".$encoding."||";

if ($encoding == 'UTF-8')
{
$utfcontents = $contents;
}
else if ($encoding == 'ISO-8859-1')
{
$utfcontents = utf8_encode($contents);
}

var_dump($utfcontents);

The $encoding is ISO-8859-1, the text file contains Hebrew characters, then
I'm converting it to utf8.

The above code is outputing gibbrish, it seems that it has converted it in
some way but not in the
proper way that it should have converted it.

My page is UTF-8 encoded, without BOM, I send UTF-8 headers to the browser
and HTML content
encoding meta tag as well.

I have no idea what I am doing wrong.

I would highly appreciate it if someone could point me to the right
direction.

Thanks in Advance,

Nitsan


Re: [PHP] php mail() function

2009-11-25 Thread James Prentice
It looks like using XAMPP wasn't strictly necessary. I tried running
this example again using my previous versions of mysql and apache and
it worked fine. So the key is to configure Sendmail as described at
the URL I gave.

On Wed, Nov 25, 2009 at 10:58 AM, James Prentice  wrote:
> After a long delay, I've finally got mail working. I had decided to
> move on in the book that I'm working through (Head First PHP & MySQL)
> but doubled back to address the mail issue again. This is how I
> finally got it to work:
>
> 1. Switched to XAMPP for linux rather than using my existing versions
> of mysql, php and apache.
>
> 2. Uninstalled Postfix and reinstalled Sendmail. Then I followed the
> instructions here:
>
> http://dbaron.org/linux/sendmail
>
> I can't vouch that the method described at that link is completely
> safe and secure, but it worked for me and was very easy. I've spent
> many hours and days trying to get this to work so am very relieved.
>
> My only complaint is that there is quite a long delay after submitting
> report.html (from Ch. 1) while it says 'waiting for localhost...'. It
> can take up to 20 seconds or so before sending and giving
> confirmation.
>
> Thanks for all your help.
>
> On Mon, Oct 26, 2009 at 4:37 AM, Bob McConnell  wrote:
>> From: James Prentice
>>
>>> I have tried setting both $to and $email to be the same shaw address
>>> since I assumed it should be recognized by the mail server, but it's
>>> still getting bounced. So why is 'www-d...@homemade' being listed as
>>> the sender? Any ideas?
>>
>> I strongly recommend you call the help desk at Shaw and ask them to
>> explain what is happening. They should know what is going on with their
>> servers. Everyone on this list appears to be guessing at the problem,
>> which is not likely to help you.
>>
>> Bob McConnell
>>
>

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



Re: [PHP] processing html forms and keeping the values

2009-11-25 Thread Kim Madsen

Merlin Morgenstern wrote on 2009-11-24 18:38:

This is not so easy. I am doing some checking with php on the values and 
if one failes php returns via GET to the form with the help of header 
location:


   $parameter =  "&demo=this";
   HEADER("Location:/test.html?error=1".$parameter);
   exit;

I would need to change way to many things in order to simply change to 
post.


Isn't there another way?


This is what I normally do with larger forms:

1. create the form as a function: form()
2. submit the form to the same page
3. test relevant input and if the fail print form()

Example:

function form() {
print '



';
}

if($_POST['submit']) {
  // test email is entered
  if(!$_POST['email']) {
print "error: you must enter an e-mail address";
form();
  }
  else {
// do stuff from here...
  }
}
else
  form();

With a 50 field form this is a nice approach for me :-)

--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] php mail() function

2009-11-25 Thread James Prentice
After a long delay, I've finally got mail working. I had decided to
move on in the book that I'm working through (Head First PHP & MySQL)
but doubled back to address the mail issue again. This is how I
finally got it to work:

1. Switched to XAMPP for linux rather than using my existing versions
of mysql, php and apache.

2. Uninstalled Postfix and reinstalled Sendmail. Then I followed the
instructions here:

http://dbaron.org/linux/sendmail

I can't vouch that the method described at that link is completely
safe and secure, but it worked for me and was very easy. I've spent
many hours and days trying to get this to work so am very relieved.

My only complaint is that there is quite a long delay after submitting
report.html (from Ch. 1) while it says 'waiting for localhost...'. It
can take up to 20 seconds or so before sending and giving
confirmation.

Thanks for all your help.

On Mon, Oct 26, 2009 at 4:37 AM, Bob McConnell  wrote:
> From: James Prentice
>
>> I have tried setting both $to and $email to be the same shaw address
>> since I assumed it should be recognized by the mail server, but it's
>> still getting bounced. So why is 'www-d...@homemade' being listed as
>> the sender? Any ideas?
>
> I strongly recommend you call the help desk at Shaw and ask them to
> explain what is happening. They should know what is going on with their
> servers. Everyone on this list appears to be guessing at the problem,
> which is not likely to help you.
>
> Bob McConnell
>

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



Re: [PHP] Create client certificate with openssl

2009-11-25 Thread Ryan Sun
check these options
*-pass arg, -passin arg*

the PKCS#12 file (i.e. input file) password source. For more information
about the format of *arg* see the *PASS PHRASE ARGUMENTS* section in *
openssl*(1) .
*-passout arg*

pass phrase source to encrypt any outputed private keys with. For more
information about the format of *arg* see the *PASS PHRASE ARGUMENTS*section in
*openssl*(1) .
I believe you can ask user their password on previous page and utilize the
'pass' option and it won't ask for a password again

HTH


On Wed, Nov 25, 2009 at 2:53 AM, Tanveer Chowdhury <
tanveer.chowdh...@gmail.com> wrote:

> Hi all,
>
> I have an apache server and for that I created CA as the signing authority
> using openssl.
>
> Now I created a  php page which will generate client certificates with key
> and will sign by CA. Now the output is in .pem .
> Now how to convert it in .p12 for exporting it in client browser..
>
> Again, If using exec gives another problem which is it asks for export
> password so how to give this via php.
>
> Thanks in advance.
> Below is the code:
>
>   Header("Content-Type: text/plain");
> $CA_CERT = "/usr/local/openssl/misc/demoCA/cacert.pem";
> $CA_KEY  = "/usr/local/openssl/misc/demoCA/private/cakey.pem";
> $req_key = openssl_pkey_new();
> if(openssl_pkey_export ($req_key, $out_key)) {
>$dn = array(
>"countryName"=> "AU",
>"stateOrProvinceName"=> "AR",
>"organizationName"   => "Widget Ltd",
>"organizationalUnitName" => "Test",
>"commonName" => "John Smith"
>);
>$req_csr  = openssl_csr_new ($dn, $req_key);
>$req_cert = openssl_csr_sign($req_csr, "file://$CA_CERT",
> "file://$CA_KEY", 365);
>if(openssl_x509_export ($req_cert, $out_cert)) {
>echo "$out_key\n";
>echo "$out_cert\n";
>$myFile2 = "/tmp/testFile.pem";
>   // $myFile1 = "/tmp/testKey.pem";
>
> $fh2 = fopen($myFile2, 'w') or die("can't open file");
> fwrite($fh2, $out_key);
> $fh1 = fopen($myFile2, 'a') or die("can't open file");
> fwrite($fh1, $out_cert);
> fclose($fh1);
> fclose($fh2);
>
> $command = `openssl pkcs12 -export test -in /tmp/testFile.pem -out
> client-cert.p12`;
> exec( $command );
>
>}
> elseecho "Failed Cert\n";
>}
> else
>echo "FailedKey\n";
> ?>
>


Re: [PHP] processing html forms and keeping the values

2009-11-25 Thread Merlin Morgenstern

Hello Raymond,

thank you for your hint. I will go with sessions. Thanx for the note 
regarding XSS.


Kind regards, merlin

Raymond Irving wrote:

There are a couple of ways that you can do this:

1. Store the post values in the $_SESSION variable then echo them back 
to the screen. Be careful with this as it can lead to XSS. Strip html, etc
2. Send the post values back to the form as part of the query sting. 
This solution is limited to the size of the query string (2k). Be 
careful with XSS


Another solution is to use a framework to handle the post back values. 
One such framework is called Raxan. Here's an example of what it can do:


http://raxanpdi.com/form-state-example.html

__
Raymond Irving

*From:* Merlin Morgenstern 
*To:* php-general@lists.php.net
*Sent:* Tue, November 24, 2009 12:14:01 PM
*Subject:* [PHP] processing html forms and keeping the values

Hi there,

I am trying to redirect a user back to a html form if a validation 
failes. The form shoult then hold all entered values. So far I did 
this over $_GET, but there is a 100 Character limitation. How could I 
do this while keeping all characters?


Thank you for any hint,

Merlin

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



Re: [PHP] processing html forms and keeping the values

2009-11-25 Thread Raymond Irving
There are a couple of ways that you can do this:

1. Store the post values in the $_SESSION variable then echo them back to the 
screen. Be careful with this as it can lead to XSS. Strip html, etc
2. Send the post values back to the form as part of the query sting. This 
solution is limited to the size of the query string (2k). Be careful with XSS


Another solution is to use a framework to handle the post back values. One such 
framework is called Raxan. Here's an example of what it can do: 

http://raxanpdi.com/form-state-example.html

__
Raymond Irving



From: Merlin Morgenstern 
To: php-general@lists.php.net
Sent: Tue, November 24, 2009 12:14:01 PM
Subject: [PHP] processing html forms and keeping the values

Hi there,

I am trying to redirect a user back to a html form if a validation failes. The 
form shoult then hold all entered values. So far I did this over $_GET, but 
there is a 100 Character limitation. How could I do this while keeping all 
characters?

Thank you for any hint,

Merlin

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

Re: [PHP] function not returning query

2009-11-25 Thread Ashley Sheridan
On Tue, 2009-11-24 at 23:27 -0800, Allen McCabe wrote:

> If I were to loop through my inputs, I could just exclude any
> problematic names, eg.:
> 
> foreach ($_POST as $var = $val)
> {
>if ($var != filter.x || $var != filter.y)
>   {
> $var = $val;
>   }
> }
> 
> Like that?
> 
> 
> On Tue, Nov 24, 2009 at 2:34 AM, Ashley Sheridan
>  wrote:
> 
> 
> On Tue, 2009-11-24 at 02:11 -0800, Allen McCabe wrote:
> 
> > I am! Will these extra query variables cause any problems or
> > should I use standard submit inputs?
> > 
> > Thanks Ashley!
> > 
> > On Tue, Nov 24, 2009 at 1:10 AM, Ashley Sheridan
> >  wrote:
> > 
> > 
> > On Mon, 2009-11-23 at 21:53 -0800, Allen McCabe
> > wrote: 
> > 
> > > Okay, suddenly I got it to filter the results, but I 
> still can't figure out
> > > where this part of the query is coming from, at the end 
> of the query string
> > > in the URL, I have this "filter.x=0&filter.y=0".
> > > 
> > > No where in my form do I have a field named filter.x or 
> filter.y. I DO
> > > however, have 3 forms (I don't want to mess with AJAX), 
> my set up looks like
> > > this:
> > > 
> > > Filter by:
> > > User - [username dropdown  v] Order by [database fields  
> v] Asc/Desc
> > > [Ascend  v] - Go
> > > School - [school dropdown  v] Order by [database fields  
> v] Asc/Desc
> > > [Ascend  v] - Go
> > > Show - [show dropdown  v] Order by [database fields  v] 
> Asc/Desc [Ascend  v]
> > > - Go
> > > 
> > > There are actually two order by fields, but this gives 
> you the idea. Each of
> > > the three lines is a separate form, each with a unique 
> name all with a "get"
> > > method, but all three Go buttons are named "filter", I 
> didn't think to try
> > > changing it until now, but is this perhaps where the 
> filter.x and filter.y
> > > are coming from? I have never seen this before in a query.
> > > 
> > > Oh, now the filter that was working spontaneously gives 
> me the error I have
> > > been getting all along, this is so frustrating.
> > > 
> > > To those who asked, yes I am connected to the database; I 
> forgot to mention
> > > that the else part of my if statement works, as long as I 
> don't try to
> > > filter my results it works.
> > > 
> > > Here is an example of the URL that my filter function 
> (via one of the 3
> > > forms) outputs:
> > > 
> http://lpacmarketing.hostzi.com/afy/orders/default.php?filterby=school&schoolid=36&orderby1=order_id&asc_desc_order1=Descend&orderby2=pmt_recd_date&asc_desc_order2=Descend&filter.x=13&filter.y=8&filter=Go
> > > 
> > > On Mon, Nov 23, 2009 at 8:03 PM, Philip Thompson 
> wrote:
> > > 
> > > > On Nov 23, 2009, at 6:22 PM, Allen McCabe wrote:
> > > >
> > > > > Hi, thanks for reading, I hope you can help:
> > > > >
> > > > > In my main file for an orders page I have the 
> following code:
> > > > >
> > > > >
> > > > > if (isset($_GET['filterby']))
> > > > > {
> > > > >  $resultOrders = adminFilterQuery();
> > > > >  $numberOfOrders = mysql_num_rows($resultOrders);
> > > > > }
> > > > > else
> > > > > {
> > > > >  $resultOrders = mysql_query("SELECT * FROM 
> afy_order;") or
> > > > > die(mysql_error("Could not query the database!"));
> > > > >  $numberOfOrders = mysql_num_rows($resultOrders);
> > > > > }
> > > >
> > > > You reduce this part by one line by putting the 
> following after the else
> > > > statement and removing the other 2:
> > > >
> > > > $numberOfOrders = mysql_num_rows ($resultOrders);
> > > >
> > > > Also, these queries don't need a semi-colon (;) to end 
> the query. PHP
> > > > handles this part. Remove them.
> > > >
> > > >
> > > > > adminFilterQuery() is a custom function that is 
> supposed to return a
> > > > > mysql_query, here are the last few lines of this 
> function:
> > > > >
> > > > >
> > > > > $q

[PHP] Re: Class not returning value

2009-11-25 Thread Pieter du Toit
Thanks for th reply Peter

i call this method on success
$this->sendSMS();

But i sorted the problem with this:
 public function getResult()
{
$this->processRequest();
 return $this->responseArray;

}

"Peter Ford"  wrote in message 
news:cf.a1.5.d5cfc...@pb1.pair.com...
> Pieter du Toit wrote:
>> Hi
>>
>> This is my first class and it does not work, i do a return
>> $this->responseArray; with the public function getResult() method, but 
>> get
>> nothing. Can someone please help me.
>>
>> Thsi is how i create the object
>> $number = new Smsgate($cell_numbers, $message, "27823361602", "27");
>> $result = $number->getResult();
>>
>> Here is the code:
>> >
>> /**
>>  *
>>  * @version 1.0
>>  * @copyright 2009
>>  */
>>
>> /**
>>  */
>> class Smsgate {
>>
>> protected $number;
>> protected $message;
>> protected $sender_id;
>> protected $tofind;
>> private $result;
>> /**
>>  * Constructor
>>  */
>> function __construct($number = "", $message = "", $sender_id = "",
>> $tofind = "")
>> {
>>
>> $this->message = $message;
>> $this->number = $number;
>> $this->sender_id = $sender_id;
>> $this->tofind = $tofind;
>> }
>>
>> protected function display ($result)
>> {
>> return $result;
>> }
>>
>> public function getResult()
>> {
>> return $this->processRequest();
>>
>> }
>> public function numberErrors()
>> {
>> return $this->errorResult;
>> }
>>
>> /**
>>  * Smsgate::checknumbers()
>>  *
>>  * @return array of correct and incorrect formatted numbers
>>  */
>> private function processRequest()
>> {
>> echo "nou by numers";
>> print_r($this->number);
>> // check if the property is an array and add to new array for
>> sending
>> if (is_array($this->number)) {
>> // check for starting digits
>> $this->result = "";
>> // loop through numbers and check for errors
>> foreach ($this->number as $this->val) {
>>
>> $this->position = strpos($this->val , $this->tofind);
>>
>> // number correct
>> if ($this->position === 0) {
>> echo "is integer ";
>> if ($this->result != "") {
>> $this->result .= ",";
>> }
>> // create comma seperated numbers to send as bulk in
>> sendSMS method
>> $this->result .= $this->val; //infobip multiple
>> recipients must be seperated by comma
>> // create an array to use with responseStringExplode 
>> in
>> sendSMS method
>> $this->cellarray[] = $this->val;
>> echo "Result is " . $this->result . "";
>> } else {
>> // numbers not in correct format
>> $this->errorResult[] = $this->val;
>> }
>>
>> } //end foreach
>>$this->sendSMS();
>>
>> } else {
>> $this->result = "Not ok";
>>  return $this->result;
>> }
>>
>> }
>>
>> private function sendSMS()
>> {
>>
>> $this->smsUrl =
>> 'http://www.infobip.com/Addon/SMSService/SendSMS.aspx?user=&password=';
>> $this->post_data = '&sender=' . $this->sender_id . '&SMSText=' .
>> urlencode($this->message) . '&IsFlash=0&GSM=' . $this->result;
>> $this->sendData = $this->sendWithCurl($this->smsUrl,
>> $this->post_data);
>> $this->responseStringExplode = explode("\n", $this->sendData);
>>
>>  $count=0;
>> foreach ($this->responseStringExplode as $this->rvalue) {
>>   $this->responseArray[$this->rvalue] = 
>> ($this->cellarray[$count]);
>>   $count = ++$count;
>> }
>>  return $this->responseArray;
>> }
>>  private function sendWithCurl($url, $postData) {
>>   if (!is_resource($this->connection_handle)) {
>>// Try to create one
>>if (!$this->connection_handle = curl_init()) {
>> trigger_error('Could not start new CURL instance');
>> $this->error = true;
>> return;
>>}
>>   }
>>   curl_setopt($this->connection_handle, CURLOPT_URL, $url);
>>   curl_setopt ($this->connection_handle, CURLOPT_POST, 1);
>>   $post_fields = $postData;
>>   curl_setopt ($this->connection_handle, CURLOPT_POSTFIELDS, 
>> $post_fields);
>>   curl_setopt($this->connection_handle, CURLOPT_RETURNTRANSFER, 1);
>>   $this->response_string = curl_exec($this->connection_handle);
>>   curl_close($this->connection_handle);
>>   return $this->response_string;
>>  }
>> }
>>
>> ?>
>>
>>
>
>
> Based on a first scan of your code, it looks like the only return in
> processRequest() is inside the else block, so nothing is returned unless 
> the
> processing fails.
>
> -- 
> Peter Ford  phone: 01580 89
> Developer   fax:   01580

[PHP] Re: Class not returning value

2009-11-25 Thread Pieter du Toit
Sorry i found the problem, need to do this:
public function getResult()
{
$this->processRequest();
 return $this->responseArray;

}

""Pieter du Toit""  wrote in message 
news:57.90.5.88fec...@pb1.pair.com...
> Hi
>
> This is my first class and it does not work, i do a return 
> $this->responseArray; with the public function getResult() method, but get 
> nothing. Can someone please help me.
>
> Thsi is how i create the object
> $number = new Smsgate($cell_numbers, $message, "27823361602", "27");
> $result = $number->getResult();
>
> Here is the code:
> 
> /**
> *
> * @version 1.0
> * @copyright 2009
> */
>
> /**
> */
> class Smsgate {
>
>protected $number;
>protected $message;
>protected $sender_id;
>protected $tofind;
>private $result;
>/**
> * Constructor
> */
>function __construct($number = "", $message = "", $sender_id = "", 
> $tofind = "")
>{
>
>$this->message = $message;
>$this->number = $number;
>$this->sender_id = $sender_id;
>$this->tofind = $tofind;
>}
>
>protected function display ($result)
>{
>return $result;
>}
>
>public function getResult()
>{
>return $this->processRequest();
>
>}
>public function numberErrors()
>{
>return $this->errorResult;
>}
>
>/**
> * Smsgate::checknumbers()
> *
> * @return array of correct and incorrect formatted numbers
> */
>private function processRequest()
>{
>echo "nou by numers";
>print_r($this->number);
>// check if the property is an array and add to new array for 
> sending
>if (is_array($this->number)) {
>// check for starting digits
>$this->result = "";
>// loop through numbers and check for errors
>foreach ($this->number as $this->val) {
>
>$this->position = strpos($this->val , $this->tofind);
>
>// number correct
>if ($this->position === 0) {
>echo "is integer ";
>if ($this->result != "") {
>$this->result .= ",";
>}
>// create comma seperated numbers to send as bulk in 
> sendSMS method
>$this->result .= $this->val; //infobip multiple 
> recipients must be seperated by comma
>// create an array to use with responseStringExplode in 
> sendSMS method
>$this->cellarray[] = $this->val;
>echo "Result is " . $this->result . "";
>} else {
>// numbers not in correct format
>$this->errorResult[] = $this->val;
>}
>
>} //end foreach
>   $this->sendSMS();
>
>} else {
>$this->result = "Not ok";
> return $this->result;
>}
>
>}
>
>private function sendSMS()
>{
>
>$this->smsUrl = 
> 'http://www.infobip.com/Addon/SMSService/SendSMS.aspx?user=&password=';
>$this->post_data = '&sender=' . $this->sender_id . '&SMSText=' . 
> urlencode($this->message) . '&IsFlash=0&GSM=' . $this->result;
>$this->sendData = $this->sendWithCurl($this->smsUrl, 
> $this->post_data);
>$this->responseStringExplode = explode("\n", $this->sendData);
>
> $count=0;
>foreach ($this->responseStringExplode as $this->rvalue) {
>  $this->responseArray[$this->rvalue] = ($this->cellarray[$count]);
>  $count = ++$count;
>}
> return $this->responseArray;
>}
> private function sendWithCurl($url, $postData) {
>  if (!is_resource($this->connection_handle)) {
>   // Try to create one
>   if (!$this->connection_handle = curl_init()) {
>trigger_error('Could not start new CURL instance');
>$this->error = true;
>return;
>   }
>  }
>  curl_setopt($this->connection_handle, CURLOPT_URL, $url);
>  curl_setopt ($this->connection_handle, CURLOPT_POST, 1);
>  $post_fields = $postData;
>  curl_setopt ($this->connection_handle, CURLOPT_POSTFIELDS, $post_fields);
>  curl_setopt($this->connection_handle, CURLOPT_RETURNTRANSFER, 1);
>  $this->response_string = curl_exec($this->connection_handle);
>  curl_close($this->connection_handle);
>  return $this->response_string;
> }
> }
>
> ?>
> 



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



[PHP] Re: Class not returning value

2009-11-25 Thread Peter Ford
Pieter du Toit wrote:
> Hi
> 
> This is my first class and it does not work, i do a return 
> $this->responseArray; with the public function getResult() method, but get 
> nothing. Can someone please help me.
> 
> Thsi is how i create the object
> $number = new Smsgate($cell_numbers, $message, "27823361602", "27");
> $result = $number->getResult();
> 
> Here is the code:
>  
> /**
>  *
>  * @version 1.0
>  * @copyright 2009
>  */
> 
> /**
>  */
> class Smsgate {
> 
> protected $number;
> protected $message;
> protected $sender_id;
> protected $tofind;
> private $result;
> /**
>  * Constructor
>  */
> function __construct($number = "", $message = "", $sender_id = "", 
> $tofind = "")
> {
> 
> $this->message = $message;
> $this->number = $number;
> $this->sender_id = $sender_id;
> $this->tofind = $tofind;
> }
> 
> protected function display ($result)
> {
> return $result;
> }
> 
> public function getResult()
> {
> return $this->processRequest();
> 
> }
> public function numberErrors()
> {
> return $this->errorResult;
> }
> 
> /**
>  * Smsgate::checknumbers()
>  *
>  * @return array of correct and incorrect formatted numbers
>  */
> private function processRequest()
> {
> echo "nou by numers";
> print_r($this->number);
> // check if the property is an array and add to new array for 
> sending
> if (is_array($this->number)) {
> // check for starting digits
> $this->result = "";
> // loop through numbers and check for errors
> foreach ($this->number as $this->val) {
> 
> $this->position = strpos($this->val , $this->tofind);
> 
> // number correct
> if ($this->position === 0) {
> echo "is integer ";
> if ($this->result != "") {
> $this->result .= ",";
> }
> // create comma seperated numbers to send as bulk in 
> sendSMS method
> $this->result .= $this->val; //infobip multiple 
> recipients must be seperated by comma
> // create an array to use with responseStringExplode in 
> sendSMS method
> $this->cellarray[] = $this->val;
> echo "Result is " . $this->result . "";
> } else {
> // numbers not in correct format
> $this->errorResult[] = $this->val;
> }
> 
> } //end foreach
>$this->sendSMS();
> 
> } else {
> $this->result = "Not ok";
>  return $this->result;
> }
> 
> }
> 
> private function sendSMS()
> {
> 
> $this->smsUrl = 
> 'http://www.infobip.com/Addon/SMSService/SendSMS.aspx?user=&password=';
> $this->post_data = '&sender=' . $this->sender_id . '&SMSText=' . 
> urlencode($this->message) . '&IsFlash=0&GSM=' . $this->result;
> $this->sendData = $this->sendWithCurl($this->smsUrl, 
> $this->post_data);
> $this->responseStringExplode = explode("\n", $this->sendData);
> 
>  $count=0;
> foreach ($this->responseStringExplode as $this->rvalue) {
>   $this->responseArray[$this->rvalue] = ($this->cellarray[$count]);
>   $count = ++$count;
> }
>  return $this->responseArray;
> }
>  private function sendWithCurl($url, $postData) {
>   if (!is_resource($this->connection_handle)) {
>// Try to create one
>if (!$this->connection_handle = curl_init()) {
> trigger_error('Could not start new CURL instance');
> $this->error = true;
> return;
>}
>   }
>   curl_setopt($this->connection_handle, CURLOPT_URL, $url);
>   curl_setopt ($this->connection_handle, CURLOPT_POST, 1);
>   $post_fields = $postData;
>   curl_setopt ($this->connection_handle, CURLOPT_POSTFIELDS, $post_fields);
>   curl_setopt($this->connection_handle, CURLOPT_RETURNTRANSFER, 1);
>   $this->response_string = curl_exec($this->connection_handle);
>   curl_close($this->connection_handle);
>   return $this->response_string;
>  }
> }
> 
> ?> 
> 
> 


Based on a first scan of your code, it looks like the only return in
processRequest() is inside the else block, so nothing is returned unless the
processing fails.

-- 
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



[PHP] Class not returning value

2009-11-25 Thread Pieter du Toit
Hi

This is my first class and it does not work, i do a return 
$this->responseArray; with the public function getResult() method, but get 
nothing. Can someone please help me.

Thsi is how i create the object
$number = new Smsgate($cell_numbers, $message, "27823361602", "27");
$result = $number->getResult();

Here is the code:
message = $message;
$this->number = $number;
$this->sender_id = $sender_id;
$this->tofind = $tofind;
}

protected function display ($result)
{
return $result;
}

public function getResult()
{
return $this->processRequest();

}
public function numberErrors()
{
return $this->errorResult;
}

/**
 * Smsgate::checknumbers()
 *
 * @return array of correct and incorrect formatted numbers
 */
private function processRequest()
{
echo "nou by numers";
print_r($this->number);
// check if the property is an array and add to new array for 
sending
if (is_array($this->number)) {
// check for starting digits
$this->result = "";
// loop through numbers and check for errors
foreach ($this->number as $this->val) {

$this->position = strpos($this->val , $this->tofind);

// number correct
if ($this->position === 0) {
echo "is integer ";
if ($this->result != "") {
$this->result .= ",";
}
// create comma seperated numbers to send as bulk in 
sendSMS method
$this->result .= $this->val; //infobip multiple 
recipients must be seperated by comma
// create an array to use with responseStringExplode in 
sendSMS method
$this->cellarray[] = $this->val;
echo "Result is " . $this->result . "";
} else {
// numbers not in correct format
$this->errorResult[] = $this->val;
}

} //end foreach
   $this->sendSMS();

} else {
$this->result = "Not ok";
 return $this->result;
}

}

private function sendSMS()
{

$this->smsUrl = 
'http://www.infobip.com/Addon/SMSService/SendSMS.aspx?user=&password=';
$this->post_data = '&sender=' . $this->sender_id . '&SMSText=' . 
urlencode($this->message) . '&IsFlash=0&GSM=' . $this->result;
$this->sendData = $this->sendWithCurl($this->smsUrl, 
$this->post_data);
$this->responseStringExplode = explode("\n", $this->sendData);

 $count=0;
foreach ($this->responseStringExplode as $this->rvalue) {
  $this->responseArray[$this->rvalue] = ($this->cellarray[$count]);
  $count = ++$count;
}
 return $this->responseArray;
}
 private function sendWithCurl($url, $postData) {
  if (!is_resource($this->connection_handle)) {
   // Try to create one
   if (!$this->connection_handle = curl_init()) {
trigger_error('Could not start new CURL instance');
$this->error = true;
return;
   }
  }
  curl_setopt($this->connection_handle, CURLOPT_URL, $url);
  curl_setopt ($this->connection_handle, CURLOPT_POST, 1);
  $post_fields = $postData;
  curl_setopt ($this->connection_handle, CURLOPT_POSTFIELDS, $post_fields);
  curl_setopt($this->connection_handle, CURLOPT_RETURNTRANSFER, 1);
  $this->response_string = curl_exec($this->connection_handle);
  curl_close($this->connection_handle);
  return $this->response_string;
 }
}

?> 



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