php-general Digest 22 Nov 2010 06:45:05 -0000 Issue 7048

Topics (messages 309595 through 309605):

E-mail injection question
        309595 by: Gary
        309596 by: Adam Richardson

Re: MySQL Query Help
        309597 by: Ben Miller

Re: Problem with functions and arrays...
        309598 by: Tamara Temple

How to install ext/intl on Mac OSX (NumberFormatter and so on)
        309599 by: cimodev

range header in curl?
        309600 by: Tontonq Tontonq
        309601 by: Michael Shadle
        309602 by: shiplu

Wordpress Page: How to add pagination?
        309603 by: vince samoy

Re: PHP Sockets, problem with remote execution (exec/system)
        309604 by: 惠新宸
        309605 by: Ronny Tiebel

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

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


----------------------------------------------------------------------
--- Begin Message ---
I have been testing various scripts to kill email injection attacks.  I 
adapted this script and it seems to work well.  Does anyone see any issues 
with this?

<?php
$newlinecounter = 0;
foreach($_POST as $key => $val_newline){
if(stristr($val_newline, '\r')){$newlinecounter++;}
if(stristr($val_newline, '\n')){$newlinecounter++;}
if(stristr($val_newline, '\\r')){$newlinecounter++;}
if(stristr($val_newline, '\\n')){$newlinecounter++;}
if(stristr($val_newline, '\r\n')){$newlinecounter++;}
if(stristr($val_newline, '\\r\\n')){$newlinecounter++;}
if(stristr($val_newline, 'Bcc')){$newlinecounter++;}
}
if ($newlinecounter >= 1){ die('die scum die');
}

?>

Thank you,
Gary 



__________ Information from ESET Smart Security, version of virus signature 
database 5636 (20101121) __________

The message was checked by ESET Smart Security.

http://www.eset.com





--- End Message ---
--- Begin Message ---
On Sun, Nov 21, 2010 at 12:02 PM, Gary <gp...@paulgdesigns.com> wrote:

> I have been testing various scripts to kill email injection attacks.  I
> adapted this script and it seems to work well.  Does anyone see any issues
> with this?
>
> <?php
> $newlinecounter = 0;
> foreach($_POST as $key => $val_newline){
> if(stristr($val_newline, '\r')){$newlinecounter++;}
> if(stristr($val_newline, '\n')){$newlinecounter++;}
> if(stristr($val_newline, '\\r')){$newlinecounter++;}
> if(stristr($val_newline, '\\n')){$newlinecounter++;}
> if(stristr($val_newline, '\r\n')){$newlinecounter++;}
> if(stristr($val_newline, '\\r\\n')){$newlinecounter++;}
> if(stristr($val_newline, 'Bcc')){$newlinecounter++;}
> }
> if ($newlinecounter >= 1){ die('die scum die');
> }
>
> ?>
>
> Thank you,
> Gary
>

Hi Gary,

There are issues with this approach (one being that checking all POST fields
non-discriminately will lead to false positives, as the body/message of an
email can contain new line characters without issue.)

I'd suggest using Zend's Email capabilities.  You just upload the framework
to your site, add it to your include path, and then you can even use SMTP
email capabilities through an account such as gmail or another email
provider, which is much better than using the general mail() function,
anyway.  And, you have all the security benefits.

Here's a link to Zend's Mail class documentation:
http://framework.zend.com/manual/en/zend.mail.html

Adam

-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com

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

SELECT * FROM products p LEFT JOIN criteria_values cv ON p.key=cv.key LEFT
JOIN criteria c ON cv.key=c.key WHERE c.value IS NOT NULL

Hard to answer without more detail, but I am guessing the answer will be
something like the above. Your question makes it hard to understand whether
c or cv is joined to p. So swap em around if I misunderstood. 

iPhone 4. It rocks!

On Nov 21, 2010, at 1:37 AM, Simcha Younger <sim...@syounger.com> wrote:

> On Sat, 20 Nov 2010 13:54:29 -0700
> "Ben Miller" <biprel...@gmail.com> wrote:
> 
>> Hi,
>> 
>> I'm building a website for a client in which I need to compare their 
>> products, side-by-side, but only include criteria for which all 
>> selected products have a value for that criteria.
>> 
>> In my database (MySQL), I have a tables named "products","criteria" 
>> and "criteria_values"
>> 
>> If I have something like
>> 
>> $selected_product = array("1"=>"Product 1","2"=>"Product 2"...)  //  
>> All products selected for comparison by the user
>> 
>> I need to get only rows from "criteria" where there is a row in 
>> "criteria_values" matching "criteria.criteria_id" for each 
>> $selected_product
>> - in other words, if any of the $selected_product does not have a row 
>> in "criteria_values" that matches "criteria.criteria_id", that 
>> criteria would not be returned.  I hope that makes sense.
> 
> It would be a lot easier to think about this if you could provide the
table structure or create table statements.
> 
> If I understood correctly, you have products which reference a criteria ID
which has no matching value. If this is the problem you have a to first take
care of the integrity of your data, as this should never happen. 
> 

To help clarify - the 3 tables look something like the following (tableName
=> column,column,column...):

Products => product_id,product_name,product_description...  (key =
product_id)
Criteria => criteria_id,criteria_title,criteria_text,...  (key =
criteria_id)
Criteria_values => product_id,criteria_id,criteria_value,... (key =
product_id & criteria_id)

The user selects up to X product_id's to compare, stored in
$selected_products.

I then need to get each criteria_title and criteria_text from
table(criteria) where there is a matching criteria_id in
table(criteria_values) for each/all $selected_products, also returning the
criteria_value for each $selected_products, ultimately ending up with an
array or object that looks something like:

(Assuming the user selected Product A (product_id=1), Product B
(product_id=2) and Product C (product_id=3)

criteria => Array  (
        [$criteria_id] => Array (
                [title] => query_row[criteria_title]
                [text] => query_row[criteria_text]
                [values] => Array (
                        [1] => Product A's value for this criteria
                        [2] => Product B's value for this criteria
                        [3] => Product C's value for this criteria
                )
        )
        [$criteria_id] => Array (
                .....
        )
)

Again, displaying only/all criteria where there is a matching value for
each/all $selected_products

Thanks again,
Ben



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

On Nov 20, 2010, at 5:31 PM, Jason Pruim wrote:

<?PHP

function ddbYear($name, $message, $_POST, $option){


Maybe it's just me, but using the name of a global as a function parameter just seems like a bad idea. Yes, you can do it. Should you? I think not. Especially, as, you are passing it a scalar below and treating it here like the global array.

   //Make sure to post form start/stop OUTSIDE of this function...
   //It's not meant to be a one size fits all function!
echo "NAME: " . $name . "<BR>";
echo "MESSAGE: " . $message . "<BR>";

echo "POST: " . $_POST . "<BR>";
echo "OPTION: " . $option . "<BR>";


$sticky = '';
if(isset($_POST['submit'])) {

Check the error messages -- since you're passing in $startYear as a scalar below, you shouldn't be able to access $_POST as an associative array.

$sticky = $_POST["{$name}"];
echo "STICKY: " . $sticky;
}
//echo "OPTION: ";
//print_r($option);

   echo <<<HTML
<select name="{$name}">
<option value="0">{$message}</option>

HTML;

foreach ($option as $key => $value){

if($key == $sticky) {
echo '<option value="' . $key .'" selected>' . $value . '</option>';
}else{
echo '<option value="' . $key .'">' . $value . '</option>';
}

}

echo <<<HTML

</select>
HTML;
unset($value);
return;
}

?>

One for Month, Day & Year... All the same exact code... When I get brave I'll combine it into 1 functions :)

Now... What it's trying to do.. It's on a "update" form on my website. Basically pulls the info from the database and displays it in the form again so it can be edited and resubmitted...

As I'm sure you can tell from the function it checks to see if the a value has been selected in the drop down box and if it has then set the drop down box to that value.

I call the function like this:
<?PHP
$startYear = date("Y", $row['startdate']); //Actual DBValue: 1265000400

You're setting $startYear as a scalar value here.

$optionYear = array("2010" => "2010", "2011" => "2011", "2012" => "2012", "2013" => "2013", "2014" => "2014");

ddbYear("startYear", "Select Year", $startYear, $optionYear);

And passing it in to the $_POST variable in your function. Then you treat the $_POST variable as an associative array (seemingly much like the global $_POST array).



?>

The output I'm getting is:
THESE ARE THE ACTUAL UNPROCESSED (OTHER THEN SEPARATING) VALUES FROM THE DATABASE
startmonth: 2
startday: 1
startYear: 2010
endmonth: 11
endDay: 30
endYear: 1999

THESE ARE THE VALUES INSIDE THE FUNCTION
NAME: startYear
MESSAGE: Select Year
POST: 2010
OPTION: Array
STICKY: 2

Now... The problem is that $sticky get set to "2" instead of "2010"... But I can't figure out why...

Anyone have any ideas?

And just incase I didn't provide enough info here's a link that shows it happening:

HTTP://jason.pruimphotography.com/dev/cms2/events/update_form.php? id=62

Again, I will reiterate that taking the name of a global variable and using it as a parameter in a function is a bad idea. It can be done, and my in some cases have some uses, but I don't think the way you're using it is a good idea, and looks wrong to me as well.


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

Apple is shipping PHP 5.3.3 on Mac OSX Darwin without the PECL-Extension
"ext/intl".

So i tried to install ext/intl with "pecl install intl".

The Error Message is:
/private/var/tmp/apache_mod_php/apache_mod_php-53~1/Build/tmp/pear/temp/intl/collator/collator_class.c:92:
error: duplicate ‘static’
/private/var/tmp/apache_mod_php/apache_mod_php-53~1/Build/tmp/pear/temp/intl/collator/collator_class.c:96:
error: duplicate ‘static’
/private/var/tmp/apache_mod_php/apache_mod_php-53~1/Build/tmp/pear/temp/intl/collator/collator_class.c:101:
error: duplicate ‘static’
/private/var/tmp/apache_mod_php/apache_mod_php-53~1/Build/tmp/pear/temp/intl/collator/collator_class.c:107:
error: duplicate ‘static’
make: *** [collator/collator_class.lo] Error 1
ERROR: `make' failed


phpize output is:

Configuring for:
PHP Api Version:         20090626
Zend Module Api No:      20090626
Zend Extension Api No:   220090626

gcc -v:

gcc -v
Using built-in specs.
Target: i686-apple-darwin10
Configured with: /var/tmp/gcc/gcc-5664~105/src/configure --disable-checking
--enable-werror --prefix=/usr --mandir=/share/man
--enable-languages=c,objc,c++,obj-c++
--program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib
--build=i686-apple-darwin10 --program-prefix=i686-apple-darwin10-
--host=x86_64-apple-darwin10 --target=i686-apple-darwin10
--with-gxx-include-dir=/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Apple Inc. build 5664)

Has anyone good tips for solving this?

--- End Message ---
--- Begin Message ---
hi im downloading files from h0tf1le as a premium user by curl i want to do
something like streaming i want it resend to user what it got from server
i couldnt find any resource about curl and streaming the executed source
so i did by the Range header but sometimes i see files are corrupted i check
the logs

GET
http://s137.hotfile.com/get/7006d266367d7975861e5f7200b604ad478674fc/4ce9a4ff/1/f37a0969e2e26077/332dfdf/2137758/pimp.rarHTTP/1.1
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; tr; rv:1.9.2)
Gecko/20100115 Firefox/3.6
Host: s137.hotfile.com
Pragma: no-cache
Accept: */*
Connection: Keep-Alive
Range: bytes=1-2

i only get 1 byte for learn length


Content-Disposition: attachment; filename="pimp.rar"
Content-Transfer-Encoding: binary
Content-Range: bytes 1-2/5781810

i see the range

request:Range: bytes=0-2097152
response:
Content-Disposition: attachment; filename="pimp.rar"
Content-Transfer-Encoding: binary
Content-Range: bytes 0-2097152/5781810
Connection: close

request:Range: bytes=2097152-4194304
response:
Content-Disposition: attachment; filename="pimp.rar"
Content-Transfer-Encoding: binary
Content-Range: bytes 2097152-4194304/5781810
Connection: close

request:Range: bytes=4194304-5781810

Content-Disposition: attachment; filename="pimp.rar"
Content-Transfer-Encoding: binary
Content-Range: bytes 4194304-5781810/5781810
Connection: close


i can not see any error do you?

and this is a part of it



$kackb=arasi('Content-Range: bytes 1-2/','
',$cikti);
$bytes=(int)$kackb;
$infocuk=curl_getinfo($ch);
$sabiturl=$infocuk["url"];
curl_close($ch);
$sinir*=1024;
$kackez=$bytes/$sinir;


for($i=0;$i<=$kackez;$i++)
{
$bsinir=$i*$sinir;
$ssinir+=$sinir;
if($bytes<$ssinir) { $ssinir=$bytes; }
$header = array("Range: bytes=$bsinir-$ssinir");
$ch = curl_init();
curl_setopt($ch , CURLOPT_URL, $sabiturl);
curl_setopt($ch , CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT
5.1; tr; rv:1.9.2) Gecko/20100115 Firefox/3.6');
curl_setopt($ch , CURLOPT_COOKIEJAR, dirname(__FILE__).'/cookies.txt');
curl_setopt($ch , CURLOPT_COOKIEFILE, dirname(__FILE__).'/cookies.txt');
curl_setopt($ch , CURLOPT_COOKIEFILE, dirname(__FILE__).'/cookies.txt');
if($proxy) { curl_setopt($ch , CURLOPT_PROXY, $proxy); }
curl_setopt ( $ch , CURLOPT_HTTPHEADER, $header );
curl_setopt($ch , CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch , CURLOPT_RETURNTRANSFER , 1);
$cikti = curl_exec($ch);
echo $cikti;

}

--- End Message ---
--- Begin Message ---
Is range the right header to be sending? I thought it was something else.

Also I believe there is a curl_setopt option for range... Look at php.net's 
predefined constants for the curl modul

On Nov 21, 2010, at 3:05 PM, Tontonq Tontonq <root...@gmail.com> wrote:

> hi im downloading files from h0tf1le as a premium user by curl i want to do
> something like streaming i want it resend to user what it got from server
> i couldnt find any resource about curl and streaming the executed source
> so i did by the Range header but sometimes i see files are corrupted i check
> the logs
> 
> GET
> http://s137.hotfile.com/get/7006d266367d7975861e5f7200b604ad478674fc/4ce9a4ff/1/f37a0969e2e26077/332dfdf/2137758/pimp.rarHTTP/1.1
> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; tr; rv:1.9.2)
> Gecko/20100115 Firefox/3.6
> Host: s137.hotfile.com
> Pragma: no-cache
> Accept: */*
> Connection: Keep-Alive
> Range: bytes=1-2
> 
> i only get 1 byte for learn length
> 
> 
> Content-Disposition: attachment; filename="pimp.rar"
> Content-Transfer-Encoding: binary
> Content-Range: bytes 1-2/5781810
> 
> i see the range
> 
> request:Range: bytes=0-2097152
> response:
> Content-Disposition: attachment; filename="pimp.rar"
> Content-Transfer-Encoding: binary
> Content-Range: bytes 0-2097152/5781810
> Connection: close
> 
> request:Range: bytes=2097152-4194304
> response:
> Content-Disposition: attachment; filename="pimp.rar"
> Content-Transfer-Encoding: binary
> Content-Range: bytes 2097152-4194304/5781810
> Connection: close
> 
> request:Range: bytes=4194304-5781810
> 
> Content-Disposition: attachment; filename="pimp.rar"
> Content-Transfer-Encoding: binary
> Content-Range: bytes 4194304-5781810/5781810
> Connection: close
> 
> 
> i can not see any error do you?
> 
> and this is a part of it
> 
> 
> 
> $kackb=arasi('Content-Range: bytes 1-2/','
> ',$cikti);
> $bytes=(int)$kackb;
> $infocuk=curl_getinfo($ch);
> $sabiturl=$infocuk["url"];
> curl_close($ch);
> $sinir*=1024;
> $kackez=$bytes/$sinir;
> 
> 
> for($i=0;$i<=$kackez;$i++)
> {
> $bsinir=$i*$sinir;
> $ssinir+=$sinir;
> if($bytes<$ssinir) { $ssinir=$bytes; }
> $header = array("Range: bytes=$bsinir-$ssinir");
> $ch = curl_init();
> curl_setopt($ch , CURLOPT_URL, $sabiturl);
> curl_setopt($ch , CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT
> 5.1; tr; rv:1.9.2) Gecko/20100115 Firefox/3.6');
> curl_setopt($ch , CURLOPT_COOKIEJAR, dirname(__FILE__).'/cookies.txt');
> curl_setopt($ch , CURLOPT_COOKIEFILE, dirname(__FILE__).'/cookies.txt');
> curl_setopt($ch , CURLOPT_COOKIEFILE, dirname(__FILE__).'/cookies.txt');
> if($proxy) { curl_setopt($ch , CURLOPT_PROXY, $proxy); }
> curl_setopt ( $ch , CURLOPT_HTTPHEADER, $header );
> curl_setopt($ch , CURLOPT_FOLLOWLOCATION, 1);
> curl_setopt($ch , CURLOPT_RETURNTRANSFER , 1);
> $cikti = curl_exec($ch);
> echo $cikti;
> 
> }

--- End Message ---
--- Begin Message ---
On Mon, Nov 22, 2010 at 5:05 AM, Tontonq Tontonq <root...@gmail.com> wrote:

> hi im downloading files from h0tf1le as a premium user by curl i want to do
> something like streaming i want it resend to user what it got from server
> i couldnt find any resource about curl and streaming the executed source
> so i did by the Range header but sometimes i see files are corrupted i
> check
> the logs
>
> GET
>
> http://s137.hotfile.com/get/7006d266367d7975861e5f7200b604ad478674fc/4ce9a4ff/1/f37a0969e2e26077/332dfdf/2137758/pimp.rarHTTP/1.1
> User-Agent<http://s137.hotfile.com/get/7006d266367d7975861e5f7200b604ad478674fc/4ce9a4ff/1/f37a0969e2e26077/332dfdf/2137758/pimp.rarHTTP/1.1%0AUser-Agent>:
> Mozilla/5.0 (Windows; U; Windows NT 5.1; tr; rv:1.9.2)
> Gecko/20100115 Firefox/3.6
> Host: s137.hotfile.com
> Pragma: no-cache
> Accept: */*
> Connection: Keep-Alive
> Range: bytes=1-2
>
> i only get 1 byte for learn length
>

Not sure why your are getting 1 byte. You should get 2 bytes. Is the size of
pimp.rar 2 bytes? In that case first 2 byte will returned by bytes=0-1 range
specifier instead of bytes=1-2

Check this spec out
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35

May be this will help you.


-- 
Shiplu Mokaddim
http://talk.cmyweb.net

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

I was wondering if this is the right place that this question of mine might get 
an answer. I'm currently working on a website project and I'm trying to add a 
pagination on a "Wordpress Page" as I might call it.

I was able to make it work on the archive.php page. Please take note that this 
page is calling out 3 "Posts" on each page and that the pagination is working.

Link: http://lgrathletics.com/lgr/category/basketball

Code:

<?php get_header();?>

<?php get_sidebar();?>

<div class="main-contents">this is the archive
<div id="gridContainer">

<div class="category_title"><h2><?php single_cat_title(); ?> </h2></div>

<?php
$c = 1; //init counter
$bpr = 3; //boxes per row

if(have_posts()) :
    while(have_posts()) :
        the_post();
?>
            <div class="post <?php
global $wp_query;
$postid = $wp_query->post->ID;

echo get_post_meta($postid, 'third_post', true);
wp_reset_query();
?>" id="post-<?php the_ID(); ?>">
                <h1 class="title"><a href="<?php the_permalink(); ?>" 
title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1>
                <div class="postImage">
                    <a href="<?php the_permalink(); ?>" title="<?php 
the_title_attribute(); ?>"><?php the_post_thumbnail('grid-post-image'); ?></a>
                </div>
                <div class="postExcerpt">
                    <?php the_excerpt(); ?>
                </div>
            </div>
<?php
if($c == $bpr) :
?>
<div class="clr"></div>
<?php
$c = 0;
endif;
?>
<?php
        $c++;
    endwhile;
endif;
?>
<?php wp_pagenavi(); ?>
<div class="clr"></div>
</div>
</div>

<?php get_footer(); ?>

Now, I'm trying to make this work on a template page. With 3 "Pages" instead of 
posts on each page. You'll notice that the pagination is not appearing.

Link: http://lgrathletics.com/lgr/basketball

Code:

<?php
/*
Template Name: Product Grid
*/
?>

<?php get_header(); ?>

<?php get_sidebar(); ?>

<div class="main-contents">this is the product grid
<div id="gridContainer">

<div class="category_title"><h2><?php
$parent_title = get_the_title($post->post_parent);
echo $parent_title;
?>
 </h2></div>

<?php if ( (is_page('Products')) or (is_page('Basketball')) ) {

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;    
    
query_posts(array('showposts' => 3, 'post_parent' => 173, 'post_type' => 
'page'));

    while (have_posts()) {
        
        the_post(); // vital
        
        $thumbPath = get_post_meta($post->ID, 'thumbnail', true);
        
        if ($thumbPath == "") {
            $thumbPath = "/images/comingsoon.png";
        
        }
        
        ?>
        <div class="post <?php echo get_post_meta($post->ID, 'third_post', 
true); ?>">
        
        <h1 class="title"><a href="<?php the_permalink() ?>" 
class="grid-product">
        <?php the_title(); ?></a></h1>
        <div class="postImage">
            <a href="<?php the_permalink() ?>" class="grid-product"><img 
src="<?php echo $thumbPath ?>" alt="" /></a>
        </div>
        <div class="postExcerpt">
                    $<?php echo get_post_meta($post->ID, 'price', true); ?>
                </div>
                
        </div>
        
    <?php }
    
    wp_reset_query(); // Restore global post data
    
}
?>

<?php if(function_exists('wp_pagenavi')) { // if PageNavi is activated ?>

<?php wp_pagenavi(); // Use PageNavi ?>

<?php } else { // Otherwise, use traditional Navigation ?>

<div class="nav-previous">
<!-- next_post_link -->
</div>

<div class="nav-next">
<!-- previous_post_link -->
</div>

<?php } // End if-else statement ?>
 
<div class="clr"></div>
</div>
</div>

<?php get_footer(); ?>


I really don't what I'm currently missing or this is something that is 
impossible. Hope you guys can help me out.

Thanks in advance and good day!

Vince




      

--- End Message ---
--- Begin Message ---
Hi:
is there a chance that there is a "Listen 8133" in your apache2 configure file? always no as "httpd.conf" or *.conf in the apache2/conf/extra folder.

thanks

Best regards

惠新宸     Xinchen Hui
http://www.laruence.com/

On 2010/11/19 15:18, Ronny Tiebel wrote:
Good Morning List ;)

ive allready postet my question on the german phpbar mailinglist, but no
responses from anyone yet. i hope someone on that list could give me an
advice or hint.

i'm writing a php-daemon which will run on a debian lenny/squeeze.
this daemon should listen to a specific port of a
vpn-interface/ip-address (it creates a socket)

if the daemon script recieves a string from my management webinterface
(other server) it should run some code e.g. exec('/etc/init.d/apache2
restart'); or system('something'); or whatever.

i got it working, but there is a (for me) strange behavior. After the
daemon has restarted the apache2 service for example and the php daemon
is stoped, the apache2 process takes over the socket. that means, in
`netstat -tulpen` or `netstat -anp` i first can see something like that:

tcp        0      0 10.0.0.1:8133   0.0.0.0:*    LISTEN      29168/php
tcp6       0      0 :::80         :::*       LISTEN      29155/apache2

after the daemon has restarted apache2 and stops itself (or i have to
kill him), netstat shows up the following:

tcp        0      0 10.0.0.1:8133   0.0.0.0:*  LISTEN      31490/apache2
tcp6       0      0 :::80         :::*         LISTEN      31490/apache2

so i cant restart the daemon because apache uses that port/ip (or socket?)

after invoking "/etc/init.d/apache2 restart" on the shell, everything is
fine again and im able to start the daemon. btw, the same with the
openvpn service. (mysql doesnt act like apache or openvpn).

Am i missing something? Or is that the default behavior of
linux/apache/php/sockets ???

Additional Information about OS etc.

Server/Client   Debian Lenny    Apache 2.2.9    PHP 5.2.6-1+lenny9 with
Suhosin-Patch 0.9.6.2 (cli) (built: Aug  4 2010 06:06:53)

Client/Server   Ubuntu Lucid    Apache 2.2.14   PHP 5.3.2-1ubuntu4.5 with
Suhosin-Patch (cli) (built: Sep 17 2010 13:49:46)


Ive tested it both way: Ubuntu as Server, Debian as Client and vice versa.

The Ubuntu System (my workstation) is in our Office and the Debian
System is in the datacentre@ our provider...


Any help would be great!

Thanks in advance,

kind regards
Ronny

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

.


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

thank you for your reply.

Nope, Apache runs in its standard configuration and is listening on
"*:80" and "*:443", quiet as normal.

But after some tests yesterday and after checking the init scripts of
apache2 and openvpn (where that problem occours) ive testet to invoke
the "apache2ctl" script. if i use "exec('apache2ctl restart');"
everything works fine and as i expected it. that means imho, that the
behavior described below is caused by the standard apache initscript...

i think its possible that the initscript is setting some vars which will
cause that "bug"?

i'll have a look at that, but maybe thats the solution for my problem.

thanks

kind regards

Ronny


> Hi:
>  is there a chance that there is a "Listen 8133" in your apache2
> configure file? always no as "httpd.conf" or *.conf in the
> apache2/conf/extra folder.
> 
> thanks
> 
> Best regards
> 
> 惠新宸    Xinchen Hui
> http://www.laruence.com/
> 
> On 2010/11/19 15:18, Ronny Tiebel wrote:
>> Good Morning List ;)
>>
>> ive allready postet my question on the german phpbar mailinglist, but no
>> responses from anyone yet. i hope someone on that list could give me an
>> advice or hint.
>>
>> i'm writing a php-daemon which will run on a debian lenny/squeeze.
>> this daemon should listen to a specific port of a
>> vpn-interface/ip-address (it creates a socket)
>>
>> if the daemon script recieves a string from my management webinterface
>> (other server) it should run some code e.g. exec('/etc/init.d/apache2
>> restart'); or system('something'); or whatever.
>>
>> i got it working, but there is a (for me) strange behavior. After the
>> daemon has restarted the apache2 service for example and the php daemon
>> is stoped, the apache2 process takes over the socket. that means, in
>> `netstat -tulpen` or `netstat -anp` i first can see something like that:
>>
>> tcp        0      0 10.0.0.1:8133   0.0.0.0:*    LISTEN      29168/php
>> tcp6       0      0 :::80         :::*       LISTEN      29155/apache2
>>
>> after the daemon has restarted apache2 and stops itself (or i have to
>> kill him), netstat shows up the following:
>>
>> tcp        0      0 10.0.0.1:8133   0.0.0.0:*  LISTEN      31490/apache2
>> tcp6       0      0 :::80         :::*         LISTEN      31490/apache2
>>
>> so i cant restart the daemon because apache uses that port/ip (or
>> socket?)
>>
>> after invoking "/etc/init.d/apache2 restart" on the shell, everything is
>> fine again and im able to start the daemon. btw, the same with the
>> openvpn service. (mysql doesnt act like apache or openvpn).
>>
>> Am i missing something? Or is that the default behavior of
>> linux/apache/php/sockets ???
>>
>> Additional Information about OS etc.
>>
>> Server/Client   Debian Lenny    Apache 2.2.9    PHP 5.2.6-1+lenny9 with
>> Suhosin-Patch 0.9.6.2 (cli) (built: Aug  4 2010 06:06:53)
>>
>> Client/Server   Ubuntu Lucid    Apache 2.2.14   PHP 5.3.2-1ubuntu4.5 with
>> Suhosin-Patch (cli) (built: Sep 17 2010 13:49:46)
>>
>>
>> Ive tested it both way: Ubuntu as Server, Debian as Client and vice
>> versa.
>>
>> The Ubuntu System (my workstation) is in our Office and the Debian
>> System is in the datacentre@ our provider...
>>
>>
>> Any help would be great!
>>
>> Thanks in advance,
>>
>> kind regards
>> Ronny
>>
>> -- 
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>> .
>>


-- 
Cloud IT Services GmbH   Telefon: +49 351 47940230
Altplauen 19             Telefax: +49 351 47940239
01187 Dresden            E-Mail:  i...@cloud-it-services.com
                         Web:     www.cloud-it-services.com

Geschäftsführung:        Wolfram Gürlich
Sitz der Gesellschaft:   Blankenburg
Amtsgericht Stendal:     HRB 12528


Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte
Informationen. Wenn Sie nicht der richtige Adressat sind oder diese
E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den
Absender und vernichten Sie diese E-Mail. Das unerlaubte Kopieren sowie
die unbefugte Weitergabe dieser E-Mail ist nicht gestattet.
Internetkommunikationen sind nicht sicher. Daher übernimmt die
Cloud IT Services GmbH keinerlei Haftung für den Inhalt dieser
Nachricht. Jegliche Ansichten oder dargestellte Meinungen
sind ausschließlich solche des Autors und repräsentieren nicht
notwendigerweise die der Cloud IT Services GmbH.

This e-mail may contain confidential and/or privileged information. If
you are not the intended recipient (or have received this e-mail in
error) please notify the sender immediately and destroy this e-mail. Any
unauthorized copying, disclosure or distribution of the material in this
e-mail is strictly forbidden. Internet communications are not secure and
therefore Cloud IT Services GmbH does not accept legal responsibility
for the contents of this message. Any views or opinions presented are
solely those of the author and do not necessarily represent those of
Cloud IT Services GmbH.

--- End Message ---

Reply via email to