php-general Digest 9 Feb 2006 20:36:14 -0000 Issue 3954

Topics (messages 230144 through 230178):

Re: Is my user system bad?
        230144 by: Andrei

XML parsing
        230145 by: Peter Lauri
        230146 by: Kim Christensen
        230151 by: Peter Lauri
        230154 by: Barry
        230177 by: Kim Christensen

Re: SESSION and include
        230147 by: Jochem Maas
        230149 by: Barry

Re: define() or $variable for application settings?
        230148 by: Jochem Maas
        230150 by: Matt Arnilo S. Baluyos (Mailing Lists)
        230159 by: tedd
        230160 by: Barry
        230169 by: Dan Baker
        230178 by: Paul Novitski

Curl With Certificates As Strings
        230152 by: Gustafson, Tim
        230153 by: Oli Howson

http://www.sitepoint.com/forums/showthread.php?t=342801
        230155 by: Jochem Maas

Can't install
        230156 by: Ing. Tomás Liendo
        230157 by: Barry
        230161 by: Ing. Tomás Liendo
        230162 by: Barry
        230163 by: Ing. Tomás Liendo
        230164 by: Jim Moseby

Re: REGEX query
        230158 by: Tom Rogers

Re: image location hiding techniques
        230165 by: Gerry Danen

static variable declaration
        230166 by: suresh kumar

Redirect from /rss.xml to /rss/rss.xml
        230167 by: Murray . PlanetThoughtful

socket_read
        230168 by: Peter Lauri
        230170 by: Oli Howson
        230171 by: Peter Lauri
        230172 by: Weber Sites LTD

PHP_fsockopen_connection refused(111)
        230173 by: Leonidas Safran
        230174 by: Jim Moseby
        230175 by: Weber Sites LTD
        230176 by: Leonidas Safran

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        php-general@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
        Hi Peter,

I use about same system, but instead putting ids of tables into session variable (which is easy to guess) I use a md5( uniqid( rand(), true ) ) string and I create an enreg into online tables (similar to your session table) with this string as primary key. I also add into session a hashed variable with host. When I receive a request I check session variable ($_SESSION['session_id'] in your case) and also the hashed string. For session timeout I delete the enreg from table online (session in your case). For this I have a function which is called at a request of any script at a resonable interval (like once 10 mins) and remove from table online every session that passed a number of seconds (which I defined). When a request comes with a session id, and I don't find it in online table I say that session is expired.

        I'm not saying this is the best, this is what I use.

        Regards,
        Andy

Peter Lauri wrote:
Hi,

I would like to get some comments about my user system.

1. A user logs in, the username and password is checked against the database
2. If correct it adds a row in my database "session" with member_id.
$_SESSION['session_id'] will be set to the mysql_insert_id().
3. To verify if someone is logged on or not, I have a function isLoggedOn()
that checks if there is $_SESSION['session_id'] and it returns the
member_id. If not logged in, the isLoggedOn() returns FALSE.
4. I user the member_id to retrive specific member information
5. To logout, I just unset $_SESSION['session_id']

Is this an ok system to continue to work on? Or is this a very weak system
that is easy to break in to?

I am thinking about setting an new variable $_SESSION['member_id'] so that I
do not need to o a query every time to get the member_id.

Thank you very much!


--- End Message ---
--- Begin Message ---
Hi,

 

When I go thru this documentation the parsing seem to be very complex. With
Java this was not the case.

 

Assume I have XML like this:

 

$xml = '<greeting><from>Peter</from><to>The group</to></greeting>';

 

I would like to get the value of 'from' and 'to'.

 

My dream function would be:

 

$from = xml_function($xml, 'from');

$to = xml_function($xml, 'to');

 

Or maybe an function that create an array from the XML:

 

$arr = xml_to_array($xml);

 

Any one who can give a really SIMPLE example of this?

 

I would LOVE you.

 

 

 

 

 


--- End Message ---
--- Begin Message ---
On 2/9/06, Peter Lauri <[EMAIL PROTECTED]> wrote:
> Or maybe an function that create an array from the XML:
> $arr = xml_to_array($xml);
> Any one who can give a really SIMPLE example of this?

http://php.net/xml

Have you checked the user comments?

--
Kim Christensen
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
Stupid me :) It has all I need!!!

And the opposite way, creating XML, must be even easier. Any function that take 
an array as input, and returns XML? If not, I just need to create a recursive 
function that loops thru the array. If there is a standard function I would be 
very happy.

Right now I am getting killed by the strong Thai woman that is giving me 
massage here in Bangkok.

Tnx

-----Original Message-----
    From: "Kim Christensen"<[EMAIL PROTECTED]>
    Sent: 9/02/06 6:13:48 PM
    To: "Peter Lauri"<[EMAIL PROTECTED]>
    Cc: "PHP General Users"<php-general@lists.php.net>
    Subject: Re: [PHP] XML parsing
      On 2/9/06, Peter Lauri <[EMAIL PROTECTED]> wrote:
    > Or maybe an function that create an array from the XML:
    > $arr = xml_to_array($xml);
    > Any one who can give a really SIMPLE example of this?
    
    http://php.net/xml
    
    Have you checked the user comments?
    
    --
    Kim Christensen
    [EMAIL PROTECTED]
        

[Message truncated. Tap Edit->Mark for Download to get remaining portion.]

--- End Message ---
--- Begin Message ---
Peter Lauri wrote:
Stupid me :) It has all I need!!!

And the opposite way, creating XML, must be even easier. Any function that take 
an array as input, and returns XML? If not, I just need to create a recursive 
function that loops thru the array. If there is a standard function I would be 
very happy.

Right now I am getting killed by the strong Thai woman that is giving me 
massage here in Bangkok.

Foreach works here great.
you can recursively go through arrays.
not with standard foreach but with a small additions.
if you need code let me know.

i think there are also XML functions.

But forgot which one it was ><

greets
        barry

--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

--- End Message ---
--- Begin Message ---
On 2/9/06, Peter Lauri <[EMAIL PROTECTED]> wrote:
> And the opposite way, creating XML, must be even easier. Any function that 
> take an array as input, and returns XML? If not, I just need to create a 
> recursive function that loops thru the array. If there is a standard function 
> I would be very happy.

Once again, check those user comments. There's some excellent examples
there, for two-way parsing XML files!

--
Kim Christensen
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
Fredrik Tillman wrote:
PROBLEM SOLVED!

yeah! :-)

What I actually was including was a variable ($main) and since some my pages are called on from different pages in different folders what I actually did was seting $main to the full URL to the site (http://mysite.com/page.php) to avoid confusion. But when calling on a URL I guess PHP is set to drop $_SESSION variables...

php is capable of opening files on remote systems via http,
when you did:

require 'http://yourdomain.com/yourpage.php';

you actually made a seperate request to youre own webserver
which when it was processed obviously didn't have the session
cookie (as pArt of the request) that would cause the session
array to be initialized with the data you would expect.

go read up on the ini setting 'allow_url_fopen' for more info on this.

--- End Message ---
--- Begin Message ---
Fredrik Tillman wrote:
PROBLEM SOLVED!

What I actually was including was a variable ($main) and since some my pages are called on from different pages in different folders what I actually did was seting $main to the full URL to the site (http://mysite.com/page.php) to avoid confusion. But when calling on a URL I guess PHP is set to drop $_SESSION variables...

$main="../page.php";
require($main);
Works fine.

Thanks for all your time and help!
/Fredrik

That's why it is so important to post the source code.

Not rewriting it, post the code!

Ths problem would have been solved after 2 mins if have known that the given path was a http path >_>

Barry

--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

--- End Message ---
--- Begin Message ---
Chris wrote:
Hi Matt,

I use define's.

me too. mostly because unless you use the runkit extension or
something you can't undefine or change the values of a constant.

bare in mind though that define() is horribly slow (to paraphrase
Rasmus) which may be the reason many projects choose to use variables
instead. see here:

http://php.net/manual/en/function.apc-define-constants.php


With variables it's easy to forget to global'ise it when you go into a function, define's don't have this issue.

also true :-).


Matt Arnilo S. Baluyos (Mailing Lists) wrote:

Hello Everyone,

I have a config.inc.php file which basically contains all the
configuration info that the applications needs (directory/file
locations, database credentials, etc). The information there is set
using the define() function.

However, I've seen some open-source projects which either use
$variables or associative arrays to save the values.

My application works pretty fine but I'd like to solicit opinions from
everyone on what they are using in this case. Also, I have plans of
putting up a sort of coding guidelines for the company so it might
help to have other opinions on this one.

Thanks and best regards,
Matt



--- End Message ---
--- Begin Message ---
On 2/9/06, Jochem Maas <[EMAIL PROTECTED]> wrote:
> bare in mind though that define() is horribly slow (to paraphrase
> Rasmus) which may be the reason many projects choose to use variables
> instead. see here:

Thanks Chris and Jochem!

That should've been my follow up question - which is, if define() is a
lot safer and more elegant to use than variables, why do many projects
use variables?

Would you guys know why this is so? AFAIK, in compiled languages like
C, constants are faster because the preprocessor expands them at
compile-time rather than being allocated memory during run-time - but
then we're talking about PHP here.

--
Stand before it and there is no beginning.
Follow it and there is no end.
Stay with the ancient Tao,
Move with the present.

--- End Message ---
--- Begin Message ---
Matt:

That should've been my follow up question - which is, if define() is a
lot safer and more elegant to use than variables, why do many projects
use variables?

My use of CONSTANCE's and variables depend upon need. If I require a constant throughout the main() portion of my code, then I use define() and if I need something that is subject to change, then I use variables.

However, from my personal programming experience (for all languages), I find it best to write functions that are self contained -- that don't rely on global variables or constants. They simply receive what they need and return, if required, a result. If I place constants in them, then it's harder to reuse the code for other projects.

Some constants are truly constants, like PI -- while other constant elements change depending upon use, like db_name, user_id, and such. The use of constants depends upon your programming style and your ability to remain consistent in defining them.

Would you guys know why this is so? AFAIK, in compiled languages like
C, constants are faster because the preprocessor expands them at
compile-time rather than being allocated memory during run-time - but
then we're talking about PHP here.

It's my understanding that php is written in C.

tedd

--
--------------------------------------------------------------------------------
http://sperling.com/

--- End Message ---
--- Begin Message ---
tedd wrote:
Matt:

That should've been my follow up question - which is, if define() is a
lot safer and more elegant to use than variables, why do many projects
use variables?


My use of CONSTANCE's and variables depend upon need. If I require a constant throughout the main() portion of my code, then I use define() and if I need something that is subject to change, then I use variables.

However, from my personal programming experience (for all languages), I find it best to write functions that are self contained -- that don't rely on global variables or constants. They simply receive what they need and return, if required, a result. If I place constants in them, then it's harder to reuse the code for other projects.

Some constants are truly constants, like PI -- while other constant elements change depending upon use, like db_name, user_id, and such. The use of constants depends upon your programming style and your ability to remain consistent in defining them.

Would you guys know why this is so? AFAIK, in compiled languages like
C, constants are faster because the preprocessor expands them at
compile-time rather than being allocated memory during run-time - but
then we're talking about PHP here.


It's my understanding that php is written in C.

tedd


Consants are very good for multilingual sites.

Well and the name it self says what they are for:
To be constant.

So vars which have the constant same value should be defined as constants.

That's how i see that.

And safe, well. if php is safe, the vars in it are also.

Barry

--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

--- End Message ---
--- Begin Message ---
>"Matt Arnilo S. Baluyos (Mailing Lists)" <[EMAIL PROTECTED]> 
>wrote in message
>
>I have a config.inc.php file which basically contains all the
>configuration info that the applications needs (directory/file
>locations, database credentials, etc). The information there is set
>using the define() function.
>
>However, I've seen some open-source projects which either use
>$variables or associative arrays to save the values.
>
>My application works pretty fine but I'd like to solicit opinions from
>everyone on what they are using in this case. Also, I have plans of
>putting up a sort of coding guidelines for the company so it might
>help to have other opinions on this one.

Another option you can use is to create a "Config" class, and place all your 
configuration state in it. This is probably the slowest, but easy to code 
with.
class Config
{
function Username()
{
    return "Snoopy";
}
function Password()
{
    return "Secret";
}
};
This class is accessible anywhere, and your newer editors assist you -- type 
"Config::" and you get a list of all your available configuration values.
It also makes it easy to have a configuration value that depends on state 
(like "Debug", depends on which machine or folder it is running from).

I also have a class called "Settings" that are user-configurable within the 
website admin page.  All settings are placed inside a table, and the user 
can monkey with them at there will.  Settings::GetValue("Color") returns the 
user-defined value from the table.

Just some thoughts
DanB

--- End Message ---
--- Begin Message ---
At 07:56 PM 2/8/2006, Matt Arnilo S. Baluyos (Mailing Lists) wrote:
I have a config.inc.php file which basically contains all the
configuration info that the applications needs (directory/file
locations, database credentials, etc). The information there is set
using the define() function.

However, I've seen some open-source projects which either use
$variables or associative arrays to save the values.


A small but significant factor in deciding whether to use define()d constants is that constants can't be integrated into expressions as neatly as can variables.

Variables can be embedded in expressions:

        $sUserName = "Froggy";
        echo "Variable: $sUsername.";

        Result:  Variable: Froggy.

Constants can't be embedded in expressions:

        define("sUserName", "Froggy");
        echo "Constant: sUsername.";

        Result:  Constant: sUsername.

In order to use constants in string expressions it's necessary to use concatenation operators:

        echo "Constant: " . sUsername . ".";


Ditto for heredocs:

Variables can be embedded in heredoc expressions:

        $sUserName = "Froggy";
        echo <<< hdExample1
        Variable: $sUserName
hdExample1;

        Result:  Variable: Froggy.

Constants can't be embedded in heredoc expressions:

        define("sUserName", "Froggy");
        echo <<< hdExample2
        Constant: sUserName
hdExample2;

        Result:  Constant: sUsername.

Likewise, functions & classes can't be embedded in expressions without use of concatenation operators, and can't be used in heredocs.

Of course I'm not suggesting that our inability to embed non-variables in string & heredoc expressions removes them from the toolbox, it simply informs our choices within a given application. Personally I love using heredocs, functions, and classes and simply work around the embedding limitation.

Paul
--- End Message ---
--- Begin Message ---
Hello!

Can Curl be configured to use SSL certificates in strings, rather than in 
files?  I am storing my user's certificates in a mySQL database, and I don't 
really want to write those certificates to a file, and then use the file, and 
then delete them when I'm done.  I would much rather just pass the certificate 
to Curl as a string instead.

For example, instead of:

curl_setopt($Curl, CURLOPT_SSLCERT, "/tmp/cert.pem");

I would like to do:

$UserQuery = mysql_query("select * from Users where ID = 1000", $Database);
$UserRow = mysql_fetch_assoc($UserQuery);
curl_setopt($Curl, CURLOPT_SSLCERT, $UserRow["Certificate"]);

Is that possible?  If it isn't using Curl, is there some other library I could 
use to accomplish this?  All I need to do is simple HTTPS posts and gets.

Tim Gustafson
MEI Technology Consulting, Inc
[EMAIL PROTECTED]
(516) 379-0001 Office
(516) 908-4185 Fax
http://www.meitech.com/ 

--- End Message ---
--- Begin Message ---

curl_setopt($Curl, CURLOPT_SSLCERT, "/tmp/cert.pem");

Never used it, but possibly...
curl_setopt($Curl, CURLOPT_SSLCERT, "/some/php/file/to/echo/cert/from/db.php");

just a thought :)

--- End Message ---
--- Begin Message ---
hi Jason,

you made the following claim on sitepoint (I would have reacted there
but couldn't be bother to crteate another website account) - which
I think is incorrect:

<QUOTE>
Nobody has yet brought up the slightly annoying issue that interfaces are actually implmented as abstract classes "under the hood". This means you can't decare two interfaces with an identical method name

PHP Code:
interface boat {
        public function drive();
        public function float();
}
interface car {
        public function drive();
        public function rotateTires();
}
class amphibious implements boat, car {
        public function float() {}
        public function drive() {}
        public function  rotateTires() {}
}
</QUOTE>

You are correct in that amphibious can't implement both car and boat but you
suggest that this is because of a problem with the engine and that it should be 
fixed.

But there is no problem and there is nothing to fix. (regardless of
interfaces a class can only implement a method once (we don't have C-like
function overloading) and that means you can't implement both interfaces,
besides which it makes no sense because if you we're allowed to implement
one drive() method to satisfy the 2 drive() interface methods then neither
the engine nor your code would know which of the 2 drive() methods
was actually bveing implemented (and if that cannot be determined then the
whole point of the interface becomes moot)

This misconception regarding broken interface functionality seems to seem from
content of your example. 'boat' and 'car' are not interfaces in my mind
 rather I would see them (and 'amphibious') as [abstract] classes and if
they were to implement an interface 'vehicle' springs to mind as a candidate.
(also boats aren't generally 'driven' ;-)

rgds,
Jochem

--- End Message ---
--- Begin Message ---
Hi I can't install PHP on Windows.
The error: "Windows Can't found c:\Windows\System32\issext.vbs"

What Can I do?

Please Help me!

Thnaks, Tom. 

--- End Message ---
--- Begin Message ---
Ing. Tomás Liendo wrote:
Hi I can't install PHP on Windows.
The error: "Windows Can't found c:\Windows\System32\issext.vbs"

What Can I do?

Please Help me!

Thnaks, Tom.
Copy the issext.vbs to your system32 folder.

Don't have it?
Well:

www.google.de

--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

--- End Message ---
--- Begin Message ---
Sorry but I can't find the file issext.vbs!!

Where can I get it???? Can you send me this file?

Thank you!

Tom


"Barry" <[EMAIL PROTECTED]> escribió en el mensaje 
news:[EMAIL PROTECTED]
> Ing. Tomás Liendo wrote:
>> Hi I can't install PHP on Windows.
>> The error: "Windows Can't found c:\Windows\System32\issext.vbs"
>>
>> What Can I do?
>>
>> Please Help me!
>>
>> Thnaks, Tom.
> Copy the issext.vbs to your system32 folder.
>
> Don't have it?
> Well:
>
> www.google.de
>
> -- 
> Smileys rule (cX.x)C --o(^_^o)
> Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o) 

--- End Message ---
--- Begin Message ---
Ing. Tomás Liendo wrote:
Sorry but I can't find the file issext.vbs!!

Where can I get it???? Can you send me this file?

Thank you!

Tom


have you used your pc's search function to search for the file?

I don't have an ISS server so i can't send it to you

--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

--- End Message ---
--- Begin Message ---
Yes, I don't have the file in my PC and I can't find It on Google.
Well... I'll see

Tkank you very much.

Tom.

"Barry" <[EMAIL PROTECTED]> escribió en el mensaje 
news:[EMAIL PROTECTED]
> Ing. Tomás Liendo wrote:
>> Sorry but I can't find the file issext.vbs!!
>>
>> Where can I get it???? Can you send me this file?
>>
>> Thank you!
>>
>> Tom
>>
>>
> have you used your pc's search function to search for the file?
>
> I don't have an ISS server so i can't send it to you
>
> -- 
> Smileys rule (cX.x)C --o(^_^o)
> Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o) 

--- End Message ---
--- Begin Message ---
> 
> Sorry but I can't find the file issext.vbs!!
> 
> Where can I get it???? Can you send me this file?
> 


I don't run IIS, so I can't send you the file.  Maybe you should run Apache
instead, the way <?php echo $deiety; ?> intended PHP to be run  ;-)

JM

--- End Message ---
--- Begin Message ---
Hi,

Saturday, February 4, 2006, 2:53:32 PM, you wrote:
p> Hi,

p> I'm still trying to get to grips with REGEX and have hit a hurdle with
p> the following:

p> I have this bit of text:
p> (\(EX\) RV-6 )

p> I want to remove the '\(EX\)' part of it
p> so leaving just: ( RV-6 )

p> Any suggestions would be most appreciated.

p> Thanks
p> Alexis


I would use preg_replace_callback() for something like this:
(untested)

<?php

$string = 'some text (\(EX\) RV-6 ) and the end.';

fumction cb($data){
 $r = $data; //just in case not good format
 $parts = split(' ',$data);
 if(count($parts) > 1){
   $r = '( '.$parts[1].' )';
 }
 return $r;
}


$new_string = preg_replace_callback('/\(\\\(\w+\\\)\s[\w-]+\s\)/s','cb', 
$string);

-- 
regards,
Tom

--- End Message ---
--- Begin Message ---
I am attempting to call a script that actually renders the image and
then check for a session variable. However, the session variable does
not seem to be there...

<?php
$fn = $_GET['id']; // filename
$p = $_GET['p']; // path
$img = "/srv/pix/" . $p . "/" . $fn ; // where the photos are + path + filename

if ( $_SESSION['photoid'] != md5("validphoto") ) // set by caller script
 die( "Invalid photo request" ); // or redirect to alternate image
$_SESSION['photoid'] = "";

$render = @imagecreatefromjpeg( $img );
header("Content-type: image/jpeg");
imagejpeg($render,'',100);
imagedestroy ($render);
?>

Does anybody have an idea why the session var is not available?

The script above is called with this:

$_SESSION['photoid'] = md5("validphoto");
echo "<p><img border=0 src='showimage.php?id=$get_pic&p=$from'
alt=\"Photo $get_pic being located...\"></p>";

Gerry


On 2/7/06, hbeaumont hbeaumont <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have a site with images that I want people to download but not have
> the direct path to. ie. I do not want them to be able to just view the
> source, find the dir and then download everything or direct link to
> them.
>
> However I can see no way to do this other than keeping the images on
> disk, having a php script read them and then spit them out. example:
>
> view.php?92348924  where 92348924  is a code that translates to the
> image on disk.
>
> Can anyone think of a better method? If not, what is the most
> efficient way to do this (ie. avoid the most i/o)
>
> Thanks!
>
>
> P.S. I also realize I could use .htaccess to stop direct linking and
> turn off directory indexes. Still I think there might be some other
> problems with .htaccess
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--
Gerry
http://portal.danen.org/

--- End Message ---
--- Begin Message ---
hello everybody,

                 I am having one doubt in static
variable declaration,whether static variable works
only with in the function if that function is  called
more than one times.this is my code facind problem.

 STATIC $m=0;
 if($m==0):
             
             $m=$m+1;
    print "<a
href=\"tradesummary_pg2.php?m=$m\">next</a>";         
  

 elseif($m<($k-1)):
                   
             print "<a
href=\"tradesummary_pg2.php?m=$m-1\">previous</a><a
href=\"tradesummary_pg2.php?m=$m+1\">next</a>";

else:
             print "<a
href=\"tradesummary_pg2.php?ID=$ID&m=$m-1\">previous</span></td><td></td></tr>";

endif;


  u have seen yahoo mail inbox with Next ,previous
links in bottom. i want to implement same
functionality locally.i did my coding and i am facing
a problem, that  when i click the next link $m value
incremented to 1 for first time and when i click next
for second time ,$m value is not incrementing,i
declared $m as STATIC .i am looking forward
suggestions from ur any one.



                         A.suresh

                            


                
__________________________________________________________ 
Yahoo! India Matrimony: Find your partner now. Go to http://yahoo.shaadi.com

--- End Message ---
--- Begin Message ---
Hi All,

This may turn out to be more of an apache question (but I'm hoping there are some apache experts on the list as well), but I'm wondering how I would go about automatically redirecting requests for /rss.xml to read the contents of /rss/rss.xml instead?

Any help appreciated!

Much warmth,

Murray
---
"Lost in thought"
http://www.planetthoughtful.org

"Urban legends, superstitions, ghost
stories and folklore"
http://www.ulblog.org

--- End Message ---
--- Begin Message ---
Best group member,

 

I want to read the content from a socket that is sending XML.

 

The socket_read(socket, length) takes the two parameters. But what I am
concerned about it, I do not actually know the 'length' of what is being
sent. How do I protect myself from that?

 

Right now I just use a value of 'length' that with margin is larger then the
size I will receive. Is it possible to get the size of what is ready to be
read from the socket?

 

Best regards,
Peter Lauri

 

 

 


--- End Message ---
--- Begin Message ---

I want to read the content from a socket that is sending XML.

IIRC, you just read in a loop while there's still stuff to read.

--- End Message ---
--- Begin Message ---
Ok, any standard value for the size to read per time? Will the total time be
faster if a larger maximum size is choosed?


-----Original Message-----
From: Oli Howson [mailto:[EMAIL PROTECTED] 
Sent: Friday, February 10, 2006 12:10 AM
To: php-general@lists.php.net
Subject: Re: [PHP] socket_read


> I want to read the content from a socket that is sending XML.

IIRC, you just read in a loop while there's still stuff to read.

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

--- End Message ---
--- Begin Message ---
Check out some XML examples, maybe you can find more there :

http://www.weberdev.com/AdvancedSearch.php?example=&searchtype=category&sort
=title&search=&category=XML&date=&secondary=&SearchIn=All+Categories&IsSub=&
PHPFunctions=&Articles=on

Sincerely 
 
berber 
 
Visit the Weber Sites Today, 
To see where PHP might take you tomorrow. 
SEO Data Monitor : http://seo.weberdev.com 
PHP & MySQL Forums : http://www.weberforums.com
 

-----Original Message-----
From: Peter Lauri [mailto:[EMAIL PROTECTED] 
Sent: Thursday, February 09, 2006 7:05 PM
To: 'PHP General Users'
Subject: [PHP] socket_read

Best group member,

 

I want to read the content from a socket that is sending XML.

 

The socket_read(socket, length) takes the two parameters. But what I am
concerned about it, I do not actually know the 'length' of what is being
sent. How do I protect myself from that?

 

Right now I just use a value of 'length' that with margin is larger then the
size I will receive. Is it possible to get the size of what is ready to be
read from the socket?

 

Best regards,
Peter Lauri

 

 

 

--- End Message ---
--- Begin Message ---
Hello,

I'm writting a domain checker and for that, I want to use fsockopen to send
data to the registry's whois database.
Unfortunately I have always "Connection refused", Error 111 when try to
create a socket...

Even the example shown on php.net website doesn't work, so I believe it's
not a code problem from my side...
http://www.php.net/manual/de/function.fsockopen.php

PHP has been compiled with -enable-socket option, so I also think it's not
the problem neither. On top of that, I tried the same code on two different
machines (Ubuntu, FC4): same result...

I first thought it could be a DNS problem, but as I can use my browser
normally on the same PC, I wonder...

Any help would be highly appreciated ;-)


Thx:

BB

-- 
10 GB Mailbox, 100 FreeSMS/Monat http://www.gmx.net/de/go/topmail
+++ GMX - die erste Adresse für Mail, Message, More +++

--- End Message ---
--- Begin Message ---
> 
> I'm writting a domain checker and for that, I want to use 
> fsockopen to send
> data to the registry's whois database.
> Unfortunately I have always "Connection refused", Error 111 
> when try to
> create a socket...

Are you just doing whois lookups?  If so, there's an easier way on a linux
box:

$whois=`whois gmx.net`;//look up gmx.net in the whois database
print"$whois\r\n";//echo it to the screen

JM

--- End Message ---
--- Begin Message ---
This may help :

http://www.weberdev.com/get_example-4335.html

Sincerely 
 
berber 
 
Visit the Weber Sites Today, 
To see where PHP might take you tomorrow. 
SEO Data Monitor : http://seo.weberdev.com 
PHP & MySQL Forums : http://www.weberforums.com
Free Uptime Monitor : http://uptime.weberdev.com
 

-----Original Message-----
From: Leonidas Safran [mailto:[EMAIL PROTECTED] 
Sent: Thursday, February 09, 2006 7:49 PM
To: php-general@lists.php.net
Subject: [PHP] PHP_fsockopen_connection refused(111)

Hello,

I'm writting a domain checker and for that, I want to use fsockopen to send
data to the registry's whois database.
Unfortunately I have always "Connection refused", Error 111 when try to
create a socket...

Even the example shown on php.net website doesn't work, so I believe it's
not a code problem from my side...
http://www.php.net/manual/de/function.fsockopen.php

PHP has been compiled with -enable-socket option, so I also think it's not
the problem neither. On top of that, I tried the same code on two different
machines (Ubuntu, FC4): same result...

I first thought it could be a DNS problem, but as I can use my browser
normally on the same PC, I wonder...

Any help would be highly appreciated ;-)


Thx:

BB

--
10 GB Mailbox, 100 FreeSMS/Monat http://www.gmx.net/de/go/topmail
+++ GMX - die erste Adresse f|r Mail, Message, More +++

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

--- End Message ---
--- Begin Message ---
Hello,

>I am also creating the same thing...
>I use socket_create(), and it works fine. Who is the registrar?

Well I try querying denic which is the german registry.

I finally got it to work, but it seems it is a name<->ip resolving issue.
Instead of using the whois.denic.de as a name, I used the corresponding IP
address. And now it works.

What I really don't now, is why name resolution works when I use the command
line or the browser... ???

One error reported was (in combination with leaving out the "@" in front of
the fsockopen() function):

Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed:
Temporary failure in name resolution in /path/php/class/Request.php on line
22

...

Adding "@" in front of fsockopen and using Address instead of domainname
solves the problem (superficially)...


Thx for your help

BB

-- 
Telefonieren Sie schon oder sparen Sie noch?
NEU: GMX Phone_Flat http://www.gmx.net/de/go/telefonie

--- End Message ---

Reply via email to