Copy Source | Copy HTML #!/usr/bin/php <?php $in = fopen( 'php://stdin' , 'r' ); // $db = NULL; while ( $in_str = fgets( $in )) { // if (@mysql_ping( $db ) !== true ) { // - @mysql_close( $db ); $db = mysql_connect(); } mysql_query( ' $in_str ' ); // echo '1' ; // , } mysql_close( $db ); fclose( $in ); ?>
Copy Source | Copy HTML #!/usr/bin/php <?php $in = fopen( 'php://stdin' , 'r' ); // $db = NULL; while ( $in_str = fgets( $in )) { // if (@mysql_ping( $db ) !== true ) { // - @mysql_close( $db ); $db = mysql_connect(); } mysql_query( ' $in_str ' ); // echo '1' ; // , } mysql_close( $db ); fclose( $in ); ?>
Copy Source | Copy HTML #!/usr/bin/php <?php $in = fopen( 'php://stdin' , 'r' ); // $db = NULL; while ( $in_str = fgets( $in )) { // if (@mysql_ping( $db ) !== true ) { // - @mysql_close( $db ); $db = mysql_connect(); } mysql_query( ' $in_str ' ); // echo '1' ; // , } mysql_close( $db ); fclose( $in ); ?>
Copy Source | Copy HTML #!/usr/bin/php <?php $in = fopen( 'php://stdin' , 'r' ); // $db = NULL; while ( $in_str = fgets( $in )) { // if (@mysql_ping( $db ) !== true ) { // - @mysql_close( $db ); $db = mysql_connect(); } mysql_query( ' $in_str ' ); // echo '1' ; // , } mysql_close( $db ); fclose( $in ); ?>
Copy Source | Copy HTML #!/usr/bin/php <?php $in = fopen( 'php://stdin' , 'r' ); // $db = NULL; while ( $in_str = fgets( $in )) { // if (@mysql_ping( $db ) !== true ) { // - @mysql_close( $db ); $db = mysql_connect(); } mysql_query( ' $in_str ' ); // echo '1' ; // , } mysql_close( $db ); fclose( $in ); ?>
Copy Source | Copy HTML #!/usr/bin/php <?php $in = fopen( 'php://stdin' , 'r' ); // $db = NULL; while ( $in_str = fgets( $in )) { // if (@mysql_ping( $db ) !== true ) { // - @mysql_close( $db ); $db = mysql_connect(); } mysql_query( ' $in_str ' ); // echo '1' ; // , } mysql_close( $db ); fclose( $in ); ?>
Copy Source | Copy HTML #!/usr/bin/php <?php $in = fopen( 'php://stdin' , 'r' ); // $db = NULL; while ( $in_str = fgets( $in )) { // if (@mysql_ping( $db ) !== true ) { // - @mysql_close( $db ); $db = mysql_connect(); } mysql_query( ' $in_str ' ); // echo '1' ; // , } mysql_close( $db ); fclose( $in ); ?>
Copy Source | Copy HTML #!/usr/bin/php <?php $in = fopen( 'php://stdin' , 'r' ); // $db = NULL; while ( $in_str = fgets( $in )) { // if (@mysql_ping( $db ) !== true ) { // - @mysql_close( $db ); $db = mysql_connect(); } mysql_query( ' $in_str ' ); // echo '1' ; // , } mysql_close( $db ); fclose( $in ); ?>
Copy Source | Copy HTML #!/usr/bin/php <?php $in = fopen( 'php://stdin' , 'r' ); // $db = NULL; while ( $in_str = fgets( $in )) { // if (@mysql_ping( $db ) !== true ) { // - @mysql_close( $db ); $db = mysql_connect(); } mysql_query( ' $in_str ' ); // echo '1' ; // , } mysql_close( $db ); fclose( $in ); ?>
Copy Source | Copy HTML #!/usr/bin/php <?php $in = fopen( 'php://stdin' , 'r' ); // $db = NULL; while ( $in_str = fgets( $in )) { // if (@mysql_ping( $db ) !== true ) { // - @mysql_close( $db ); $db = mysql_connect(); } mysql_query( ' $in_str ' ); // echo '1' ; // , } mysql_close( $db ); fclose( $in ); ?>
Copy Source | Copy HTML #!/usr/bin/php <?php $in = fopen( 'php://stdin' , 'r' ); // $db = NULL; while ( $in_str = fgets( $in )) { // if (@mysql_ping( $db ) !== true ) { // - @mysql_close( $db ); $db = mysql_connect(); } mysql_query( ' $in_str ' ); // echo '1' ; // , } mysql_close( $db ); fclose( $in ); ?>
Copy Source | Copy HTML #!/usr/bin/php <?php $in = fopen( 'php://stdin' , 'r' ); // $db = NULL; while ( $in_str = fgets( $in )) { // if (@mysql_ping( $db ) !== true ) { // - @mysql_close( $db ); $db = mysql_connect(); } mysql_query( ' $in_str ' ); // echo '1' ; // , } mysql_close( $db ); fclose( $in ); ?>
Copy Source | Copy HTML #!/usr/bin/php <?php $in = fopen( 'php://stdin' , 'r' ); // $db = NULL; while ( $in_str = fgets( $in )) { // if (@mysql_ping( $db ) !== true ) { // - @mysql_close( $db ); $db = mysql_connect(); } mysql_query( ' $in_str ' ); // echo '1' ; // , } mysql_close( $db ); fclose( $in ); ?>
Copy Source | Copy HTML #!/usr/bin/php <?php $in = fopen( 'php://stdin' , 'r' ); // $db = NULL; while ( $in_str = fgets( $in )) { // if (@mysql_ping( $db ) !== true ) { // - @mysql_close( $db ); $db = mysql_connect(); } mysql_query( ' $in_str ' ); // echo '1' ; // , } mysql_close( $db ); fclose( $in ); ?>
Copy Source | Copy HTML #!/usr/bin/php <?php $in = fopen( 'php://stdin' , 'r' ); // $db = NULL; while ( $in_str = fgets( $in )) { // if (@mysql_ping( $db ) !== true ) { // - @mysql_close( $db ); $db = mysql_connect(); } mysql_query( ' $in_str ' ); // echo '1' ; // , } mysql_close( $db ); fclose( $in ); ?>
Copy Source | Copy HTML #!/usr/bin/php <?php $in = fopen( 'php://stdin' , 'r' ); // $db = NULL; while ( $in_str = fgets( $in )) { // if (@mysql_ping( $db ) !== true ) { // - @mysql_close( $db ); $db = mysql_connect(); } mysql_query( ' $in_str ' ); // echo '1' ; // , } mysql_close( $db ); fclose( $in ); ?>
Copy Source | Copy HTML
- #! / usr / bin / php
- <? php
- // number of handlers
- define ( 'PROCESSORS_TO_SPAWN' , 5 );
- // full path to the handler
- define ( 'PROCESSOR_PATH' , '/path/to/processor.php' );
- $ in = fopen ( "php: // stdin" , 'r' );
- // transfer the standard input to non-blocking mode
- stream_set_blocking ( $ in , 0);
- // list of handler readiness flags
- $ processors_states = array_fill (0, PROCESSORS_TO_SPAWN, true );
- $ processors = array ();
- $ proc_signal_pipes = array ();
- $ proc_data_pipes = array ();
- $ descriptorspec = array (
- 0 => array ( "pipe" , "r" ),
- 1 => array ( "pipe" , "w" ),
- 2 => array ( "file" , "/ dev / null" , "a" )
- );
- $ buffer = array ();
- // run the handlers and translate the reading channel into non-blocking mode
- while (count ( $ processors ) <PROCESSORS_TO_SPAWN) {
- $ processors [] = proc_open (PROCESSOR_PATH, $ descriptorspec , $ pipes , NULL, NULL);
- stream_set_blocking ( $ pipes [ 1 ], 0 );
- $ proc_data_pipes [] = $ pipes [0];
- $ proc_signal_pipes [] = $ pipes [ 1 ];
- }
- while ( true ) {
- $ in_str = fgets ( $ in );
- if ( $ in_str ! == false ) {
- // here you can check the validity of the log line
- if ( true ) {
- $ buffer [] = $ in_str ;
- }
- }
- foreach ( $ processors_states as $ proc_num => $ processor_state ) {
- // in non-blocking mode, check the handler readiness
- if (fgets ( $ proc_signal_pipes [ $ proc_num ]) == '1' ) {
- $ processors_states [ $ proc_num ] = true ;
- }
- }
- // while there are free handlers and the queue is not empty - we feed them data
- while (count ( $ buffer )> 0 and
- ( $ selected_proc = array_search ( true , $ processors_states ))! == false ) {
- $ item = array_shift ( $ buffer );
- fwrite ( $ proc_data_pipes [ $ selected_proc ], $ item );
- $ processors_states [ $ selected_proc ] = false ;
- }
- // if the standard input is closed and the queue is empty - finish the work
- if (feof ( $ in ) and count ( $ buffer ) == 0 ) {
- break ;
- }
- $ check_list = $ proc_signal_pipes ;
- $ check_list [] = $ in ;
- // wait for data to be read on the standard input or from one of the handlers
- stream_select ( $ check_list , $ w = NULL, $ e = NULL, 1 );
- }
- // close handlers and tidy up
- foreach ( $ processors as $ proc_num => $ proc ) {
- fclose ( $ proc_data_pipes [ $ proc_num ]);
- fclose ( $ proc_signal_pipes [ $ proc_num ]);
- proc_close ( $ proc );
- }
- fclose ( $ in );
- ?>
Source: https://habr.com/ru/post/54140/
All Articles