OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
php-general Digest 4 Feb 2007 01:26:53 -0000 Issue 4606

php-general-digest-helplists.php.net
Date: Sat Feb 03 2007 - 19:26:53 CST


php-general Digest 4 Feb 2007 01:26:53 -0000 Issue 4606

Topics (messages 248235 through 248262):

Jabber conection manager
        248235 by: chetan rane

Re: Executing scripts from a table
        248236 by: Ken Kixmoeller -- reply to ken.kixmoeller.com
        248238 by: Ken Kixmoeller -- reply to ken.kixmoeller.com

is there socket.so file?
        248237 by: Yeni Setiawan
        248240 by: chetan rane

Help with matching numbers 0-100
        248239 by: Chilling Lounge Admin
        248241 by: frank
        248246 by: Myron Turner

Matching numbers 1-100
        248242 by: Wikus Moller
        248243 by: Wikus Moller
        248244 by: tedd

Regex Mixtake
        248245 by: Manolet Gmail
        248247 by: Steffen Ebermann
        248248 by: Manolet Gmail
        248249 by: Steffen Ebermann
        248250 by: Manolet Gmail
        248251 by: Steffen Ebermann
        248252 by: Robert Cummings

Pop up window in PHP code
        248253 by: Chris Carter
        248254 by: Paul Novitski
        248255 by: wwww.freenet.am
        248256 by: wwww.freenet.am
        248257 by: Myron Turner

Re: Graphs
        248258 by: Peter Lauri

Re: Who uses PHP
        248259 by: Christopher Weldon

include file identifier
        248260 by: Eli
        248261 by: Robert Cummings
        248262 by: Eli

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


HI all

i want to develop a Jabber connection manage its role will be

1. accept HTTp request from the Client
2. establish connection with a jabber server using TCp
3. and later start the instant mechanism between them

has any one worked on this please let me know how to do it

--
Have A plesant Day
Chetan. D. Rane
Location: Pune , India
Contact: +91-9890792762
otherID: chetscoolyahoo.com
             chetranerediffmail.com

attached mail follows:


On Feb 2, 2007, at 6:59 PM, Richard Lynch wrote:

> Putting PHP source into MySQL is the WRONG way to go for security and
> efficiency...

Thank you, Richard -- I appreciate your advice.

Here is a qualifier: I'm not putting any core code into tables, just
code which generates page content. The access rights to that page
content, as well as security code and application objects are not
there. That code is off of the web path, called by functions. No SQL
is in tables. So maybe I shouldn't have said "security."

With that in mind -- I would really appreciate it if would help me
understand your comment or point me to a resource which will. I have
read a bunch of stuff on security, but no resources led me to believe
that I was on a wrong path, though none of them followed the path I
am on. It isn't too late for me to change.

Ken

attached mail follows:


On Feb 3, 2007, at 9:32 AM, Ken Kixmoeller -- reply to
kenkixmoeller.com wrote:

> I'm not putting any core code into tables, just code which
> generates page content. The access rights to that page content, as
> well as security code and application objects are not there. That
> code is off of the web path, called by functions. No SQL is in
> tables. So maybe I shouldn't have said "security."

I should add: All of the PHP in the tables is making calls to UI
objects and data objects (which contain the SQL). Those classes are
also off of the web tree. My goal has been to locate any and all page-
related content (HTML and PHP) in a single location.

I am *not* trying to justify my strategy here. I just want to provide
enough information to anybody willing to help me understand if it is
ill-conceived.

Thank you,

Ken

attached mail follows:


Hi there,
I'm currently writing an IRC bot using php (CLI) and get a little problem.

For windows version, I need to enable socket extension (socket.dll) and
my bot will be able to connect to an IRC server.

But in linux version, it's unable to connect. So I wonder if there's a "
socket.so" or something else
to activate socket extension.

And the question is, do I need socket extension in Linux?

--
regards,

Yeni Setiawan

attached mail follows:


HI Yeni

I had similar problems i recommmend using the following

fsockopen() instead open_socket()

it wprks fine on both

On 2/3/7, Yeni Setiawan <yenisetiawangmail.com> wrote:
>
> Hi there,
> I'm currently writing an IRC bot using php (CLI) and get a little problem.
>
> For windows version, I need to enable socket extension (socket.dll) and
> my bot will be able to connect to an IRC server.
>
> But in linux version, it's unable to connect. So I wonder if there's a "
> socket.so" or something else
> to activate socket extension.
>
> And the question is, do I need socket extension in Linux?
>
> --
> regards,
>
> Yeni Setiawan
>
>

--
Have A plesant Day
Chetan. D. Rane
Location: Pune , India
Contact: +91-9890792762
otherID: chetscoolyahoo.com
             chetranerediffmail.com

attached mail follows:


Hi.

I need help with matching a variable. The variable would be e.g. 0-15
, 16-30 etc. and when the variable is equal to a certain range, it
would echo an image.

Does anyone know what function I should use? preg_match?

The code would be something like

if(preg_match("[16-30]",$variable))
{
echo "image";
}

but the above code doesn't work. How do I fix it?

Thanx

attached mail follows:


better make a switch statement: with case such as
switch($x):
case ($x >= 16 && $x <= 30):

    break;
case ....

set*

""Chilling Lounge Admin"" <adminchillinglounge.net> schrieb im Newsbeitrag
news:a927b2380702030855w1d730547wcb35d813c8b09a4bmail.gmail.com...
> Hi.
>
> I need help with matching a variable. The variable would be e.g. 0-15
> , 16-30 etc. and when the variable is equal to a certain range, it
> would echo an image.
>
> Does anyone know what function I should use? preg_match?
>
> The code would be something like
>
> if(preg_match("[16-30]",$variable))
> {
> echo "image";
> }
>
> but the above code doesn't work. How do I fix it?
>
> Thanx

attached mail follows:


Chilling Lounge Admin wrote:
> Hi.
>
> I need help with matching a variable. The variable would be e.g. 0-15
> , 16-30 etc. and when the variable is equal to a certain range, it
> would echo an image.
>
> Does anyone know what function I should use? preg_match?
>
> The code would be something like
>
> if(preg_match("[16-30]",$variable))
> {
> echo "image";
> }
>
> but the above code doesn't work. How do I fix it?
>
> Thanx
>

if(preg_match('/(\d+)/', $variable, $matches) {
       if($matches[1] > N && $matches[1] < N2) {
           / do your thing
      }
}

<?php
$variable = "image-number 16. jpg";
if(preg_match('/(\d+)/', $variable, $matches)) {
       if($matches[1] > 4 && $matches[1] < 20) {
           echo $matches[1] . " is in range\n";
      }
      else echo $matches[1] . " out of range\n";
}
?>

--

_____________________
Myron Turner
http://www.room535.org
http://www.bstatzero.org
http://www.mturner.org/XML_PullParser/

attached mail follows:


Hi.

I want to know if anyone can help me with my code which matches a
number to a range e.g. 1-15 and echoes an image if the number is in
the range.

The code would use the if statement and check if a variable for
example 5 matches the range like 4-10 and if it does it echoes a
certain image.

Anyone know which function I should use and what regex I should use?

Thanks

attached mail follows:


Hi.

I want to know if anyone can help me with my code which matches a
number to a range e.g. 1-15 and echoes an image if the number is in
the range.

The code would use the if statement and check if a variable for
example 5 matches the range like 4-10 and if it does it echoes a
certain image.

Anyone know which function I should use and what regex I should use?

Thanks

attached mail follows:


At 5:09 PM +0000 2/3/07, Wikus Moller wrote:
>Hi.
>
>I want to know if anyone can help me with my code which matches a
>number to a range e.g. 1-15 and echoes an image if the number is in
>the range.
>
>The code would use the if statement and check if a variable for
>example 5 matches the range like 4-10 and if it does it echoes a
>certain image.
>
>Anyone know which function I should use and what regex I should use?
>
>Thanks

Hi:

Wasn't this same question just asked by Chilling Lounge Admin?

It does seem that similar questions rise at similar times, must be sun spots.

In any event, its the same answer -- use a switch.

http://us2.php.net/switch

hth's

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

attached mail follows:


Hi, i have a problem using regex, i want to get all the text between " "

so i try this...

$subject = 'menu "Archer?",-,"Chief?",L_Menu2,"Big Mouth?",L_Menu3;';
if (ereg('"([^"]*)"', $subject, $regs)) {
        print_r($regs);
}

but just return me:

Array
(
    [0] => "Archer?"
    [1] => Archer?
)

not return me Chief and Big Mounth

what is the problem?

attached mail follows:


You have to use preg_match_all()

  if (preg_match_all("!\"(.+)\"!sU", $var, $match))

On Sat, Feb 03, 2007 at 12:36:59PM -0500, Manolet Gmail wrote:
> Hi, i have a problem using regex, i want to get all the text between " "
>
> so i try this...
>
> $subject = 'menu "Archer?",-,"Chief?",L_Menu2,"Big Mouth?",L_Menu3;';
> if (ereg('"([^"]*)"', $subject, $regs)) {
> print_r($regs);
> }

attached mail follows:


2007/2/3, Steffen Ebermann <esehnognu.de>:
> You have to use preg_match_all()
>
> if (preg_match_all("!\"(.+)\"!sU", $var, $match))
>
>

oh wow! works very well... but... i take 2 days reading about ereg ='(
 there is no way to do this using ereg an not preg (PCRE)...

anyway, PCRE is better that ereg?

> On Sat, Feb 03, 2007 at 12:36:59PM -0500, Manolet Gmail wrote:
> > Hi, i have a problem using regex, i want to get all the text between " "
> >
> > so i try this...
> >
> > $subject = 'menu "Archer?",-,"Chief?",L_Menu2,"Big Mouth?",L_Menu3;';
> > if (ereg('"([^"]*)"', $subject, $regs)) {
> > print_r($regs);
> > }
>

attached mail follows:


I don't know, but http://php.net/manual/en/function.ereg.php says

  "Note: preg_match(), which uses a Perl-compatible regular expression
         syntax, is often a faster alternative to ereg()."

On Sat, Feb 03, 2007 at 01:58:50PM -0500, Manolet Gmail wrote:
> anyway, PCRE is better that ereg?

attached mail follows:


well thanks you too much, i will learn the preg sintax.

2007/2/3, Steffen Ebermann <esehnognu.de>:
> I don't know, but http://php.net/manual/en/function.ereg.php says
>
> "Note: preg_match(), which uses a Perl-compatible regular expression
> syntax, is often a faster alternative to ereg()."
>
>
> On Sat, Feb 03, 2007 at 01:58:50PM -0500, Manolet Gmail wrote:
> > anyway, PCRE is better that ereg?
>

attached mail follows:


Side note:

  $exp = explode('"', $var);
  foreach ($exp as $key => $val) if ($key%2!=0) $arr[] = $val;
  var_dump($arr);

works without regular expressions.

--
Steffen

On Sat, Feb 03, 2007 at 12:36:59PM -0500, Manolet Gmail wrote:
> Hi, i have a problem using regex, i want to get all the text between " "
>
> so i try this...
>
> $subject = 'menu "Archer?",-,"Chief?",L_Menu2,"Big Mouth?",L_Menu3;';
> if (ereg('"([^"]*)"', $subject, $regs)) {
> print_r($regs);
> }

attached mail follows:


On Sat, 2007-02-03 at 13:58 -0500, Manolet Gmail wrote:
> 2007/2/3, Steffen Ebermann <esehnognu.de>:
> > You have to use preg_match_all()
> >
> > if (preg_match_all("!\"(.+)\"!sU", $var, $match))
> >
> >
>
> oh wow! works very well... but... i take 2 days reading about ereg ='(
> there is no way to do this using ereg an not preg (PCRE)...
>
> anyway, PCRE is better that ereg?

PCRE is much more powerful than ereg(). It is considerably faster too.
However ereg() is POSIX compliant if that matters at all.

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

attached mail follows:


I am trying to open a Java script pop up widow from within the php code. Not
able to get it done, the error I think is in the use of "" '' .. I mean
double and/or single quote. Do not know how to place those. Please advice.
The code is below:

echo "
<tr>
<td>$shopname </td>
<td>$category </td>
<td>$subcategory </td>
<td>$level </td>
<td> javascript:poptastic( Details </td>
</tr>";
$i++;

The Javascript code is:

<script language="javascript">
var newwindow;
function poptastic(url)
{
        newwindow=window.open(url,'name','height=490,width=900,left=150,top=175');
        if (window.focus) {newwindow.focus()}
}
</script>

The javascript code works perfect with other pages and within HTML, its just
that the PHP is not supporting the quotes and double quotes. I have even
tried &rsquo &rdquo and all.

Thanks in advance
--
View this message in context: http://www.nabble.com/Pop-up-window-in-PHP-code-tf3167481.html#a8786668
Sent from the PHP - General mailing list archive at Nabble.com.

attached mail follows:


At 2/3/2007 12:44 PM, Chris Carter wrote:
>I am trying to open a Java script pop up widow from within the php code. Not
>able to get it done, the error I think is in the use of "" '' .. I mean
>double and/or single quote. Do not know how to place those. Please advice.
>The code is below:
>
>echo "
><tr>
><td>$shopname </td>
><td>$category </td>
><td>$subcategory </td>
><td>$level </td>
><td> javascript:poptastic( Details </td>
></tr>";

That last table cell is deeply troubled. First, you're missing a
close-parenthesis and semi-colon, should be:
         javascript:poptastic( Details );
Second, this is going to output to HTML as plain text, not as
executable script. Perhaps you meant to embed the function call in an anchor?

         <a href="javascript:poptastic( Details );">link text</a>

Third, when do you expect this pop-up window to pop up? Are you
aware that PHP executes on the server, then downloads the page to the
client, then the client processes any embedded javascript and
executes it? Perhaps this sequence of events would be more clear if
you used the window.onload event to trigger the pop-up.

Fourth, are you aware that many browsers are set to suppress
pop-ups? If your page depends on pop-ups, it will break or be
rendered non-functional by pop-up suppression.

>The javascript code works perfect with other pages and within HTML, its just
>that the PHP is not supporting the quotes and double quotes. I have even
>tried &rsquo &rdquo and all.

Don't use curly quotes in scripting; that's just for text display.

I don't see that quotation marks are a problem in the script you've
posted, but maybe you haven't given us an accurate copy of the whole thing.

If quotes are a problem, try using heredoc:
http://php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc

echo <<<_
This text doesn't "care" about quotes.
_;

Regards,

Paul
__________________________

Paul Novitski
Juniper Webcraft Ltd.
http://juniperwebcraft.com

attached mail follows:


Try this:

<script>
function poptastic(url)
{
        newwindow=window.open(url,'name','height=490,width=900,left=150,top=175');
        if (window.focus) {newwindow.focus()}
}
</script>
<?
$URL="index.php";
print "<a href=\"javascript:poptastic('".$URL."')\">click here</a>";
?>

Ed

> I am trying to open a Java script pop up widow from within the php code. Not
> able to get it done, the error I think is in the use of "" '' .. I mean
> double and/or single quote. Do not know how to place those. Please advice.
> The code is below:

> echo "
> <tr>
> <td>$shopname </td>
> <td>$category </td>
> <td>$subcategory </td>
> <td>$level </td>
> <td> javascript:poptastic( Details </td>
> </tr>";
> $i++;

> The Javascript code is:

> <script language="javascript">
> var newwindow;
> function poptastic(url)
> {
>
> newwindow=window.open(url,'name','height=490,width=900,left=150,top=175');
> if (window.focus) {newwindow.focus()}
> }
> </script>

> The javascript code works perfect with other pages and within HTML, its just
> that the PHP is not supporting the quotes and double quotes. I have even
> tried &rsquo &rdquo and all.

> Thanks in advance
> --
> View this message in context:
> http://www.nabble.com/Pop-up-window-in-PHP-code-tf3167481.html#a8786668
> Sent from the PHP - General mailing list archive at Nabble.com.

--
Best regards,
 wwww mailto:wwwwfreenet.am

attached mail follows:


Sorry, if already posted, just did not get any confirmation, wanted to
make sure the e-mail has been sent.

Try this:

<script>
function poptastic(url)
{
        newwindow=window.open(url,'name','height=490,width=900,left=150,top=175');
        if (window.focus) {newwindow.focus()}
}
</script>
<?
$URL="index.php";
print "<a href=\"javascript:poptastic('".$URL."')\">click here</a>";
?>

Ed

> I am trying to open a Java script pop up widow from within the php code. Not
> able to get it done, the error I think is in the use of "" '' .. I mean
> double and/or single quote. Do not know how to place those. Please advice.
> The code is below:

> echo "
> <tr>
> <td>$shopname </td>
> <td>$category </td>
> <td>$subcategory </td>
> <td>$level </td>
> <td> javascript:poptastic( Details </td>
> </tr>";
> $i++;

> The Javascript code is:

> <script language="javascript">
> var newwindow;
> function poptastic(url)
> {
>
> newwindow=window.open(url,'name','height=490,width=900,left=150,top=175');
> if (window.focus) {newwindow.focus()}
> }
> </script>

> The javascript code works perfect with other pages and within HTML, its just
> that the PHP is not supporting the quotes and double quotes. I have even
> tried &rsquo &rdquo and all.

> Thanks in advance
> --
> View this message in context:
> http://www.nabble.com/Pop-up-window-in-PHP-code-tf3167481.html#a8786668
> Sent from the PHP - General mailing list archive at Nabble.com.

--
Best regards,
 wwww mailto:wwwwfreenet.am

attached mail follows:


Chris Carter wrote:
> I am trying to open a Java script pop up widow from within the php code. Not
> able to get it done, the error I think is in the use of "" '' .. I mean
> double and/or single quote. Do not know how to place those. Please advice.
> The code is below:
>
> echo "
> <tr>
> <td>$shopname </td>
> <td>$category </td>
> <td>$subcategory </td>
> <td>$level </td>
> <td> javascript:poptastic( Details </td>
> </tr>";
> $i++;
>
> The javascript code works perfect with other pages and within HTML, its just
> that the PHP is not supporting the quotes and double quotes. I have even
> tried &rsquo &rdquo and all.
>

Where are the problem quotation marks? And Is this in fact the actual
html that you are outputting?

        <td> javascript:poptastic( Details </td>

Shouldn't it be:
<td><a href="javascript:portastic();">hello</a></table>

Without the a tag, it just prints the javascript pseudo-url to the
screen as text.

--

_____________________
Myron Turner
http://www.room535.org
http://www.bstatzero.org
http://www.mturner.org/XML_PullParser/

attached mail follows:


Gnuplot can do it for you as well...

Best regards,
Peter Lauri

www.dwsasia.com - company web site
www.lauri.se - personal web site
www.carbonfree.org.uk - become Carbon Free

-----Original Message-----
From: ffredrixsoncomcast.net [mailto:ffredrixsoncomcast.net]
Sent: Friday, February 02, 2007 12:56 PM
To: php-generallists.php.net
Subject: [PHP] Graphs

I would like to add some graphing capability to an app of mine. What package
is recommended? I don't need anything too fancy, just some bar graphs, pie
charts, etc.

Thank you in advance.

attached mail follows:


>> Well, if you do not know the answer to my particular question, I'm
>> curious how might you respond to someone who says:
>>
>> PHP has to many security issues and should not be used with a
>> user authentication system.
>> We should use XXX.
>
> I think security mainly depends on the programmer and not on the
> language he uses...
>
> greets
> Zoltán Németh

I totally agree.

>
>>
>> You are not allowed to say 'Well, you're wrong. PHP is as secure as
>> anything else.' without explaining why.
>> Or, would you agree with the statement? Is there an 'XXX' that should
>> be used instead of PHP?
>>

Of course not. As Zoltan stated above, security is dependent upon the
programmer and not the language. But, if you aren't familiar with why
PHP is considered so "insecure" its a result of people who can't/
don't know how to properly program PHP applications. PHP is an easy
programming language to learn quickly and hit the ground running.
These people (typically) don't care to check to make sure writing
something like:

mysql_query('SELECT * FROM admins WHERE username = "'.$_GET
['username'].'" and password = "'.$_GET['password'].'"');

is safe and secure. This is one of the bigger issues I've seen on
some PHP applications. As you will (or perhaps already have read) on
Chris S.'s site that a big thing to do in PHP apps is FIEO (Filter
Input Escape Output). Applications written in this manner are
insecure; PHP isn't what's insecure.

However, with my limited Computer Science training, FIEO is something
that should be done in any application under any programming language
- for security's sake.

So, rather than consider the difference in security of a programming
language versus another, you should be asking the question "What does
PHP offer me that XXX doesn't?". Alternatively, if the person on the
other end is still too concerned about security, then you should be
considering "How much easier is it for me to program secure
applications in PHP than XXX?" If you do it right from the start,
you'll find that PHP does not make it difficult to write secure apps.

>> Given the limited number of options for maintaining state
>> information, I would be hard pressed to see how any language could be
>> inherently more security or why one could not write PHP code which
>> implemented the same techniques as 'XXX'.
>>
>> (No, I do not know what 'XXX' might be.)
>>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
Christopher Weldon
President & CEO
Cerberus Interactive, Inc.
cweldoncerberusonline.com
(866) 813-4603 x605

attached mail follows:


Hello,

Does any included file in PHP have a unique identifier? (like a stack of
includes identifier).

If the files names are different, then __FILE__ can be used as an
identifier. But if a file was included by itself, then __FILE__ is the
same, tho there are 2 different includes of the same file.

Example:
=== a.php
<?php
echo "\nRunning ".__FILE__." (id=X)!\t";
if (!$visited) {
        echo "You are visiting here!";
        $visited = true;
        include(__FILE__);
}
else {
        echo "You have been already visiting here! (Bye)";
}
?>

-thanks, Eli

attached mail follows:


On Sun, 2007-02-04 at 03:05 +0200, Eli wrote:
> Hello,
>
> Does any included file in PHP have a unique identifier? (like a stack of
> includes identifier).
>
> If the files names are different, then __FILE__ can be used as an
> identifier. But if a file was included by itself, then __FILE__ is the
> same, tho there are 2 different includes of the same file.
>
> Example:
> === a.php
> <?php
> echo "\nRunning ".__FILE__." (id=X)!\t";
> if (!$visited) {
> echo "You are visiting here!";
> $visited = true;
> include(__FILE__);
> }
> else {
> echo "You have been already visiting here! (Bye)";
> }
> ?>

Looking at the code above... it would seem you want:

    include_once()

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

attached mail follows:


Robert Cummings wrote:
> Looking at the code above... it would seem you want:
>
> include_once()
It's not the idea..

I'm not trying to make that code work, I want to know which exact
include (of the same file) does what..

Say you got a loop of self-include:
e.g:
=== a.php
<?php
echo "\nRunning ".__FILE__." (id=X)!\t";
if ($visited<5) {
        echo "You are visiting here!";
        $visited++;
        include(__FILE__);
}
else {
        echo "That's enough! Bye!";
}
?>

In "(id=X)!".. what's the X? You may say you can use $visited as an
identifier, but it's not the point I mean.. I want a global include file
identifier, that is not dependent on other variables.