روشن فکری بنیان ماست !

ما هرگز نمی گذاریم حوصله شما سربرود !

اللَّهُ نُورُ السَّمَاوَاتِ وَالْأَرْضِ مَثَلُ نُورِهِ کَمِشْکَاةٍ فِیهَا مِصْبَاحٌ الْمِصْبَاحُ فِی زُجَاجَةٍ الزُّجَاجَةُ کَأَنَّهَا کَوْکَبٌ دُرِّیٌّ یُوقَدُ مِن شَجَرَةٍ مُّبَارَکَةٍ زَیْتُونِةٍ لَّا شَرْقِیَّةٍ وَلَا غَرْبِیَّةٍ یَکَادُ زَیْتُهَا یُضِیءُ وَلَوْ لَمْ تَمْسَسْهُ نَارٌ نُّورٌ عَلَی نُورٍ یَهْدِی اللَّهُ لِنُورِهِ مَن یَشَاءُ وَیَضْرِبُ اللَّهُ الْأَمْثَالَ لِلنَّاسِ وَاللَّهُ بِکُلِّ شَیْءٍ عَلِیمٌ ( برخی از خواص آینه ۳۵ سوره نور از کتاب قرآن کریم )
هرگونه کپی برداری از فایل های اختصاصی پیگرد قانونی دارد لذا در صورت کپی مطالب لینک دریافت آن ها را تغییر ندهید .
روشن فکری بنیان ماست !

به نام او که یادش ترنم عارفانه زندگیست . سلام من سید امیرحسین طــاووســی هستم طــراح و برنامه نویس وب . فـعالیتم را در زمینه کــامپـیوتـر قبل از سـال اول دبـسـتـان شـروع کــردم و تا دوره راهنمایی اطلاعات کاملی از این تکنولوژی بدست آوردم . از ان دوره تا کنون در زمینه های مختلف فعالیت می کنم که مهـم ترین آن برنامه نویسی وب است یکی از عواملی که باعث شد تا به این سمت بیام کـدباز بودن زبان های وب هستش و روز به روز به دانستنیهایم در این زمینه می افزایم. شاد و سرزنده باشید , امیر

جستجو در وبلاگ
آخرین نظرات

درصد پیشرفت پروژه ها

Projects Progress
اسکریپت اشتراک ویدیو + منتظر بزرگترین سوپرایز وبلاگ من در فروردین ۹۵ باشید۷۹ درصد

دریافت جزیات اسکریپت اشتراک ویدیو

به نام او که یادش ترنم عارفانه زندگیست

خوب شاید برای شما هم پیش اومده که نیاز به اجرای دستوری در محیط شل توسط PHP داشته اید اما نمی خواستیم PHP تا زمان تکمیل دستور در حال لود شدن باشد بلکه دستور باید در بکگراند سیستم اجرا شود برای این منظور بهترین کار استفاده از تابع popen && pclose به جای exec یا shell_exec می باشد .

برای این منظور می توانیم از تابع ساده زیر برای اجرای دستورات در بکگراند کمک بگیریم .

function bgExec($cmd) {
 if(substr(php_uname(), 0, 7) == "Windows"){
  pclose(popen("start /B ". $cmd, "r")); 
 }else {
  exec($cmd . " > /dev/null &"); 
 }
}
و به شکل زیر از این تابع در ویندوز و لینوکس استفاده کنیم .
bgExec("php -q server.php");
خوب حالا هر دستوری را میشود در بکگراند اجرا کرد و می توانید از if ... else برای صحت اجرا دستور در شل توسط popen استفاده کنید . ما قصدمون برای استفاده از popen برای run در بکگراند هست در غیر این صورت میشه حتی خروجی popen که مربوط به دستور می باشد را به شکل زیر دریافت کرد .
error_reporting(E_ALL);

/* Add redirection so we can get stderr. */
$handle = popen('/path/to/spooge 2>&1', 'r');
echo "'$handle'; " . gettype($handle) . "\n";
$read = fread($handle, 2096);
echo $read;
pclose($handle);
من در مرحله اول که تست کردم تابع معرفی شده در بکگراند Run شد و حتی زمانی که دستورات زیاد بود به خوبی اجرا شد ، اما برخی دستورات مثلا تبدیل ویدیو با ffmpeg را که تست کردم دیگر خبری از اجرا در بکگراند نبود بلکه PHP اینقدر صبر میکرد تا این پروسه تموم بشه به همین دلیل تصمیم گرفتم از راه بهتری در بکگراند دستورات را اجرا کنم که برای هر نوع دستوری پاسخگو باشد به همین دلیل با جستجو به کد زیر رسیدم .
$bat_filename = "C:\\my_bat_file.bat";
$bat_log_filename = "C:\\my_bat_file_bat.log";
$bat_file = fopen($bat_filename, "w");
if($bat_file) {
    fwrite($bat_file, "@echo off"."\n");
    fwrite($bat_file, "echo Starting proces >> ".$bat_log_filename."\n");
    fwrite($bat_file, "php c:\\my_php_process.php >> ".$bat_log_filename."\n");
    fwrite($bat_file, "echo End proces >> ".$bat_log_filename."\n");
    fwrite($bat_file, "EXIT"."\n");
    fclose($bat_file);
}
            
//
// Start the process in the background
//
$exe = "start /b ".$bat_filename;
if( pclose(popen($exe, 'r')) ) {
    return true;
}
return false;
آره اگه شما هم مثل من فکر می کنید ، حتما ذوق زده شده اید اره ابتکار خیلی جالبی هست ، در این تابع دستور مورد نظر به صورت فایل bat. که قابل اجرا در ویندوز است ساخته می شود بعد در popen اجرا می شود . اما باز هم من بعد تست به دلیل وجود چندین تابع fwrite در این کد نتیجه نگرفتم بلکه با کمی تغییرات در این کد و اولین تابع که معرفی کردم به که زیر رسیدم این تابع با bat. در ویندوز به بهترین نحو اجرا می شود ، اگر در لینوکس مشکلی وجود داشت به دنبال همین راه باشید اما در فایل اجرایی خود لینوکس دستورات را ایجاد کنید و بعد اجرا .
    protected function __bgExec($cmd, $action)
    {
        if (substr(php_uname(), 0, 7) == "Windows") {
            $bat_filename     = $this->__filedir . '/' . $this->__filename . '_' . $action . '.bat';
            $bat_log_filename = $this->__filedir . '/' . $this->__filename . '_' . $action . '.log';
            $bat_file         = fopen($bat_filename, 'w');
            if ($bat_file) {
                $text = '@echo off
for /f "tokens=2 delims==" %%a in (\'wmic OS Get localdatetime /value\') do set "dt=%%a"
set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%"
set "fullstamp=%YYYY%-%MM%-%DD%_%HH%-%Min%-%Sec%"
echo In the name of Allah Starting proces At "%fullstamp%" >> ' . $bat_log_filename . '
' . $cmd . ' >> ' . $bat_log_filename . '
for /f "tokens=2 delims==" %%a in (\'wmic OS Get localdatetime /value\') do set "dt=%%a"
set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%"
set "fullstamp=%YYYY%-%MM%-%DD%_%HH%-%Min%-%Sec%"
echo Thanks to God        End proces      At "%fullstamp%" >> ' . $bat_log_filename . '
EXIT';
                fwrite($bat_file, $text);
                fclose($bat_file);
            }
            // Start the process in the background
            if (pclose(popen('start /b ' . $bat_filename, 'r'))) {
                return true;
            }
            return false;
        } else {
            exec($cmd . " > /dev/null &");
        }
    }
چون من این کد را از داخل کلاسی که نوشتم برداشتم برای استفاده ازش نیاز به حذف برخی کدهای اضافه دارید ولی بهترین جواب رو از این کد گرفتم . در مرحله اول دستور را در فایل bat. میسازد به این صورت که ابتدا فایل log. ساخته شود که بنویسد این پروسه در چه تاریخ و زمانی اجرا شد و سپس دستور را اجرا می کند و وقتی دستور به صورت کامل تمام شد سپس ذکر می کند پروسه در چه تاریخ و زمانی به پایان رسید . به این راحتی توانستیم هرگونه دستوری را در ویندوز به صورت بکگراند اجرا کنیم حالا به چندین مثال از تابع popen و کاربردهایش می پردازیم .
مثالها : (در اولین فرصت توضیحات کامل در هر مورد را ذکر می کنم هرچند کامنت انگلیسی بالای اکثر کدها هست)
//Note that you *have* to do a read on the handle before you can feof(), even if the command outputs nothing! So..
$f=popen("sleep 2","r");
while (!feof($f)) {}
pclose($f);
print "done";
//will never finish.
-
/* 
To run a php script and not wait for it I use this on windows 
$commandString = "start /b c:\\php\\php.EXE c:\\image\\cleanup.php --passaccount=$account --passcount=$count"; 
pclose(popen($commandString, 'r')); 

Note to pass my script vars you need dashdash. 
to read the var use --this is in cleanup.php 
*/
 
function arguments($argv) { 
    $_ARG = array(); 
    foreach ($argv as $arg) { 
        if (ereg('--[a-zA-Z0-9]*=.*',$arg)) { 
            $str = split("=",$arg); $arg = ''; 
            $key = ereg_replace("--",'',$str[0]); 
            for ( $i = 1; $i < count($str); $i++ ) { 
                $arg .= $str[$i]; 
            } 
                        $_ARG[$key] = $arg; 
        } elseif(ereg('-[a-zA-Z0-9]',$arg)) { 
            $arg = ereg_replace("-",'',$arg); 
            $_ARG[$arg] = 'true'; 
        } 
    
    } 
return $_ARG; 
} 
sleep(5); 
$var_array= arguments($argv); 
extract($var_array, EXTR_PREFIX_SAME, "wddx");//$user comes from here 
//echo "hello new $user"; 
$account=$passaccount; 
$count=$passcount; 
-
/*
If you try to execute a command under Windows the PHP script normally waits until the process has been terminated. Executing long-term processes pauses a PHP script even if you don't want to wait for the end of the process. 
It wasn't easy to find this beautiful example how to start a process under Windows without waiting for its termination: 
*/

$commandString = 'start /b c:\\programToRun.exe -attachment "c:\\temp\file1.txt"'; 
pclose(popen($commandString, 'r')); 
-
//If you want to download files from a linux server with a filesize bigger than 2GB you can use the following: 
 
function serveFile( $file , $as ){ 
    header( 'Expires: Mon, 1 Apr 1974 05:00:00 GMT' ); 
    header( 'Pragma: no-cache' ); 
    header( 'Cache-Control: must-revalidate, post-check=0, pre-check=0' ); 
    header( 'Content-Description: File Download' ); 
    header( 'Content-Type: application/octet-stream' ); 
    header( 'Content-Length: '.trim(`stat -c%s "$file"`) ); 
    header( 'Content-Disposition: attachment; filename="'. $as .'"' ); 
    header( 'Content-Transfer-Encoding: binary' ); 
    //@readfile( $file ); 

    flush(); 
    $fp = popen("tail -c ".trim(`stat -c%s "$file"`)." ".$file.' 2>&1', "r"); 
    while(!feof($fp)) 
    { 
        // send the current file part to the browser 
        print fread($fp, 1024); 
        // flush the content to the browser 
        flush(); 
    } 
    fclose($fp); 
} 
-
Note, when using this with a batch file in windows, you must put an "exit" at the end of your batch file or you will get a new cmd.exe stuck in your process list every time you execute the page.
-
/*
Care needs to be taken in the case of long running child processes. Say you want to run tail -f /var/log/messages or in my case burn dvds. If you have a busy wait, Apache2 can sit towards 100%cpu and steadily grow memory. In my case I crashed the server after about an hour and 90% of the dvd burned. During that time apache had consumed a gig of swap. 
Offending code - don't copy: 
*/

        $ThisCommand = sprintf("%s %s",COMMAND,$ThisFile); 
        $fp=popen($ThisCommand,"r"); 
        while (!feof($fp)) { 
                set_time_limit (20); 
                $results = fgets($fp, 4096); 
                if (strlen($results) == 0) { 
                   // stop the browser timing out 
                   echo " "; 
                   flush(); 
                } else { 
                   $tok = strtok($results, "\n"); 
                   while ($tok !== false) { 
                        echo htmlentities(sprintf("%s\n",$tok))."<br/>"; 
                        flush(); 
                        $tok = strtok("\n"); 
                   } 
                } 
        } 
        pclose($fp); 

//to go from zero memory and 100% cpu  to negligible memory and negligible cpu add a sleep. 

        while (!feof($fp)) { 
                set_time_limit (20); 
                $results = fgets($fp, 256); 
                if (strlen($results) == 0) { 
                   // stop the browser timing out 
                   echo " "; 
                   flush(); 
                } else { 
                   $tok = strtok($results, "\n"); 
                   while ($tok !== false) { 
                        echo htmlentities(sprintf("%s\n",$tok))."<br/>"; 
                        flush(); 
                        $tok = strtok("\n"); 
                   } 
                } 
                // avoid a busy wait 
                sleep(1); 

        } 

//I think the continued banging of the space to keep the browser awake triggered some issues in apache.
-
//Note that under Windows, if you are trying to write data to be available to your pipe's STDIN, you may need to execute php directly, rather than depending on file associations. 
 
    // with $cmd set to 'foo.php', STDIN comes up blank. 
    // with $cmd set to 'php foo.php', STDIN gets filled 
    //     (assuming php.exe is in your path) 
    $cmd = 'foo.php'; 

    if ( ($fh = popen($cmd, 'w')) === false ) 
        die("Open failed: ${php_errormsg}\n"); 

    fwrite($fh, "Line one\nLine two\n"); 

    pclose($fh); 
-
popen() seems to have problems dealing with binary data (piping audio data to the standard input of an encoding application). I changed to proc_open() instead and now everything is working fine.
-
Thanks a lot to tr4nc3 at msn dot com..
when using apache on Windows XP, on 'console mode' commands work fine, but as a system service, commands like 'popen' stop functioning, to resolve this:

Start>Run>services.msc
Right click "Apache...", select properties.
Click on the "LOG ON" tab
Check the box "Allow this service to interact with desktop"
Click OK
Restart Apache
-
// The above import function can be easily extended using 
// /usr/local/bin/xls2csv (part of catdoc ) and popen 
// to read excell files directly. 
// In our particular application the first line was the file heading. 
function importxls($file,$head=true,$throwfirst=true,$delim=",",$len=1000) { 
   $return = false; 
   $handle = popen("/usr/local/bin/xls2csv $file", "r"); 
// or die if not there. 
   if ($throwfirst) { 
       $throw = fgetcsv($handle, $len, $delim); 
   } 
   if ($head) { 
       $header = fgetcsv($handle, $len, $delim); 
   } 
   while (($data = fgetcsv($handle, $len, $delim)) !== FALSE) { 
       if ($head AND isset($header)) { 
           foreach ($header as $key=>$heading) { 
               $row[$heading]=(isset($data[$key])) ? $data[$key] : ''; 
               print "<li>". $heading ."=>" . $row[$heading]."</li>"; 
           } 
           $return[]=$row; 
       } else { 
           $return[]=$data; 
       } 
   } 
   fclose($handle); 
   return $return; 
} 
-
/*
Truncated output from ps command? 

The solution lies in the way ps displays it's info 
specifically the -w option which: 
'uses 132 columns to display information, 
instead of the default which is your window size.'.... 
somehow with fgets in php that results in 74 characters 
regardless off the init length parameter 

a bit of code: 
*/

echo '<table width="99%"><tr><td>cron</td></tr>' . "\n"; 
$fp=popen("/bin/ps -waux","r"); 
while (!feof($fp)) { 
    $buffer = fgets($fp, 4096); 
    $croninf .= '<tr><td>' . $buffer . '</td></tr>' . "\n"; 
} 
pclose($fp); 
echo $croninf; 
echo '</table><br><br>' . "\n";  

//Ciao, 

//Rene =<>=
-
//Writing and executing a bash script is as simple as that: 

$f = popen ("/bin/bash","w"); 
fwrite($f, "export KRB5CCNAME=`tempfile`\n"); 
fwrite($f, "export KRBTKFILE=`tempfile`\n"); 
fwrite($f, "$KINIT --keytab=$GLOBALS["KADMIN_KEYFILE"] --use-keytab --afslog $GLOBALS["KADMIN_PRINC"]\n"); 
fwrite($f, "pts delete $uid\n"); 
fwrite($f, "fs rmmount $rwhome\n"); 
fwrite($f, "vos remove sanjo b user.$uid\n"); 
fwrite($f, "$KDESTROY\n"); 
pclose($f); 
-
//Here is a nice little script for monitoring your http access log.

$handle = popen("tail -f /etc/httpd/logs/access.log 2>&1", 'r');
while(!feof($handle)) {
    $buffer = fgets($handle);
    echo "$buffer<br/>\n";
    ob_flush();
    flush();
}
pclose($handle);
-
/*
If you want to fork a process under windows, this is the function to use.  I created a batch file called runcmd.bat with the following line 

start %1 %2 %3 %4 

then I have the folowing function 
*/

define('RUNCMDPATH', 'c:\\htdocs\\nonwebspace\\runcmd.bat'); 

function runCmd($cmd) { 
    $externalProcess=popen(RUNCMDPATH.' '.$cmd, 'r'); 
    pclose($externalProcess); 
}    

//with this, doing something like 

runCmd('php.exe printWorkOrder.php 3498');

/*
will launch php.exe outside of apache and allow the script calling the runCmd() function to continue without waiting for the command line process to return.  The process will run under the same user account that Apache (or whatever webserver you're running) is running under, so make sure it has permissions to do whatever you need to do.  Also, make sure that the batch file has enough %n s in order to pass all the command line variables that you might need to pass. 

Special thanks to kicken from the devshed forums for coming up with the idea.
*/
-
/*
I should say, my host uses a modified form of safe mode, so I don't know if that might have caused a problem with "popen" as opposed to "proc_open".  With safe mode enabled, all words following the initial command string are treated as a single argument. Thus, echo y | echo x becomes echo "y | echo x".  [Because of this,] LinixDude010's srcipt did not work for me.  Seems wrong to read and write with popen, according to the manual. 

The script produced pgp text, but there was something wrong with the text and I could not decode it. 

This replacement script, using proc_open, which can read and write, DOES work: 
*/

function pgp_encrypt($keyring_location, $public_key_id, $plain_text) { 
  $encrypted_text=''; 
  $key_id = EscapeShellArg($public_key_id); 
  putenv("PGPPATH=$keyring_location"); 

  // encrypt the message 
  $descriptorspec = array( 
    0 => array("pipe", "r"),  // stdin 
    1 => array("pipe", "w"),  // stdout 
    2 => array("pipe", "w")   // stderr ?? instead of a file 
  ); 
  $process = proc_open("pgpe -r $key_id -af", $descriptorspec, $pipes); 
  if (is_resource($process)) { 
    fwrite($pipes[0], $plain_text); 
    fclose($pipes[0]); 
    while($s= fgets($pipes[1], 1024)) { 
          // read from the pipe 
          $encrypted_text .= $s; 
    } 
    fclose($pipes[1]); 
    // optional: 
    while($s= fgets($pipes[2], 1024)) { 
      $encrypted_text.= "\n<p>Error: $s</p>\n"; 
    } 
    fclose($pipes[2]); 
  } 
  return $encrypted_text; 
} 

$message = pgp_encrypt("/home/username/.pgp", "to@domain.com", "dummy text to be encrypted"); 
print nl2br($message); 
-
/*
Note that there appears to be a limit to the amount of data that fread() will return from a handle opened with popen(). A call to fread() may not return as much as you ask for.

For example, suppose I have a file "myfile.txt" which is more than 10KB in size. The following code works as expected:
*/

$fp = fopen('myfile.txt', 'r');
$data = fread($fp, 10240);
echo strlen($data);

//The output is '10240.' However, popen() behaves differently:

$fp = popen('/bin/cat myfile.txt', 'r');
$data = fread($fp, 10240);
echo strlen($data);

//On my system, this code prints out '8192' instead of the expected '10240.'
-
If you're having trouble with the server (Apache) hanging when issuing system commands consider the following bug report:

http://bugs.php.net/bug.php?id=22526

basically, if you're using sessions issue a 

session_write_close();

command before you execute your system command to keep the server from hanging.

This may also correct the problem when using other system command executing functions like exec.
-
//Yet another workaround for not having bidirectional pipes in php. 

$Cmd = 
"bc 2>&1 << END\n" . 
"100+221\n" . 
"1+3*3\n" . 
"quit\n" . 
"END\n"; 

$fp = popen($Cmd, 'r'); 
$read = fread($fp, 1024); 
echo $read; 
pclose($fp); 
-
From the popen linux programmers manual: 

"The  command  argument  is  a pointer to a null-terminated string containing a shell command line.  This  command  is passed  to  /bin/sh  using the -c flag." 

Since php uses this popen function, you need to be sure /bin/sh exists. This file may not exist in chroot()ed environments.
-
/*
I noticed that some of the examples above seem to advocate passing unencrypted data to gpg via the pipe shell escape, in the absence of a bi-directional popen (on some OSes). 

The approach I've taken is similar to: 
*/

  $prefix = 'example'; 
  $command = '/usr/local/bin/gpg --encrypt --armor --no-tty --batch --no-secmem-warning --recipient "joe.soap@example.com"'; 
  $tmpfile = tempnam('/tmp', $prefix); 
  $pipe = popen("$command 2>&1 >$tmpfile", 'w'); 
  if (!$pipe) { 
    unlink($tmpfile); 
  } else { 
    fwrite($pipe, $plaintxt, strlen($plaintxt)); 
    pclose($pipe); 
    $fd = fopen($tmpfile, "rb"); 
    $output = fread($fd, filesize($tmpfile)); 
    fclose($fd); 
    unlink($tmpfile); 
  } 
  return $output; 

//This means that unencrypted information is not passed via a (potentially readable) shell command, and only encrypted information gets stored on disc.
-
/*
Here is a workaround for not having bidirectional pipes in php. 

If you have bidirectional pipe support, don't bother with this. 

The trick here is to send the input on the command line to the target application.  In particular I wanted to use openssl without using temp files or named pipes.  This solution should also be thread/process safe. 

This does work on Linux (RedHat 7). 
*/

function filterThroughCmd($input, $commandLine) { 
  $pipe = popen("echo \"$input\"|$commandLine" , 'r'); 
  if (!$pipe) { 
    print "pipe failed."; 
    return ""; 
  } 
  $output = ''; 
  while(!feof($pipe)) { 
    $output .= fread($pipe, 1024); 
  } 
  pclose($pipe); 
  return $output; 
} 

/*
# example: 
print filterThroughCmd("hello", "cat"); 
# Piping to cat has the effect of echoing your input. 
*/
-
//The below code works for both way processing ;) Have fun folks 

   system("mkfifo pipeout"); 
   $pipe = popen("./nwserver -module Chapter1E > pipeout","w"); 
   $pipeout = fopen("pipeout", "r"); 
   while ($s = fgets($pipeout,1024)) { 
    echo $s; 
   } 

-
/*
I had all kinds of trouble encrypting a message with PGP, but I finanlly got it to work.  The trick was to 'chmod o+r pubring.pkr' so that the apache server could read the public keys!!!  Then, this function worked fine:
*/

function pgp_encrypt($keyring_location, $public_key_id, $plain_text) {

        $key_id = EscapeShellArg($public_key_id);
        putenv("PGPPATH=$keyring_location");

        // encrypt the message
        $pipe = popen("pgpe -r $key_id -af", "r");               
        fwrite($pipe, $plain_text);
        $encrypted_text = '';
        while($s = fgets($pipe, 1024)) {
                // read from the pipe
                $encrypted_text .= $s;
        }
        pclose($pipe);

        return $encrypted_text;
}

$message = pgp_encrypt("/home/username/.pgp", "to@domain.com", "dummy text to be encrypted");
print nl2br($message);
-
/*ive tried using popen using bidirectional pipes without working for obvious reasons, but i managed to create a simple script that managed to take care of the problem.  This example is for gpg encryption.*/

   $message = "this is the text to encrypt with gpg"; 
   $sendto = 'Dummy Key <another@fake.email>'; 

   system("mkfifo pipein"); 
   system("mkfifo pipeout"); 
   system("gpg --encrypt -a -r '$sendto' > pipeout < pipein &"); 
   $fo = fopen("pipeout", "r"); 
   $fi = fopen("pipein", "w"); 
   fwrite($fi, $message, strlen($message)); 
   fclose($fi); 
   while (!feof($fo)) { 
      $buf .= fread($fo, 1024); 
   } 
   echo $buf; 
   unlink("pipein"); 
   unlink("pipeout"); 

//If anyone has a better way of doing this I would love to see it.
-
Just a quick note about your environment. None of the apache specific environment variables are available to the called program.
-
Just make sure that you check the user information being passed into the command (if any) before it executes.
-
Note that your OS must support bi-direction pipes for popen to be bi-directional.  

FreeBSD and BSDI are known to support bi-pipes.  

Not sure about Linux.
تا روزهای آینده که فرداهای امروز است ، خدانگهدار

من سید امیرحسین طــاووســی هستم طــراح و برنامه نویس وب . فـعالیتم را در زمینه کــامپـیوتـر قبل از سـال اول دبـسـتـان شـروع کــردم و تا دوره راهنمایی اطلاعات کاملی از این تکنولوژی بدست آوردم . از ان دوره تا کنون در زمینه های مختلف فعالیت می کنم که مهـم ترین آن برنامه نویسی وب است یکی از عواملی که باعث شد تا به این سمت بیام کـدباز بودن زبان های وب هستش و روز به روز به دانستنیهایم در این زمینه می افزایم. شاد و سرزنده باشید .

رمز فایل ها در بیان باکس : tavousi.name

در صورت مشکل در دانلود فایل ها و یا حذف شدن آن ها ما را مطلع نمایید .

نظرات  (۰)

هیچ نظری هنوز ثبت نشده است

ارسال نظر

ارسال نظر آزاد است، اما اگر قبلا در بیان ثبت نام کرده اید می توانید ابتدا وارد شوید.
شما میتوانید از این تگهای html استفاده کنید:
<b> یا <strong>، <em> یا <i>، <u>، <strike> یا <s>، <sup>، <sub>، <blockquote>، <code>، <pre>، <hr>، <br>، <p>، <a href="" title="">، <span style="">، <div align="">
تجدید کد امنیتی