Advertisement
jargon

Puzzlum.NET TRK_BulkLink()

Jun 13th, 2021
1,157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.25 KB | None | 0 0
  1. <?php
  2.  
  3. function trk_bulklink( $in = '' )
  4. {
  5.     $pattern = '/{{(.*\|.*)}}/';
  6.     preg_match_all( $pattern, $in, $matches_full );
  7.     if ( count( $matches_full ) > 0 )
  8.     {
  9.         foreach($matches_full as $matches )
  10.         {
  11.             if ( isset( $matches[ 1 ] ) )
  12.             {
  13.                 $params = explode( '|', $matches[ 1 ] );
  14.                
  15.                 trk_echo3('params', array( $params ) );
  16.    
  17.                 if ( isset( $params[ 1 ] ) && isset( $params[ 2 ] ) )
  18.                 {
  19.                     for($offset=0;$offset<=3;$offset++)
  20.                     {
  21.                         $set[$offset]=true;
  22.                         if($set[$offset]) { $set[$offset] = isset( $params[ $offset ] ); }
  23.                         if($set[$offset]) { $set[$offset] = is_string( $params[ $offset ] ); }
  24.                         if($set[$offset]) { $set[$offset] = strlen( $params[ $offset ] ) > 0; }
  25.                     }
  26.                     trk_echo3('params', array( $params ) );
  27.                
  28.                     $replace = 
  29.                     '<a href="?' . urlencode( $set[ 0 ] ? $params[ 0 ] : '' ).
  30.                     '=' . urlencode( $set[ 1 ] ? $params[ 1 ] : '' ) .
  31.                     '">' .
  32.                     ( $set[ 2 ]  ? ( '<img src="' . urlencode( $params[ 2 ] ) . '">' ) : '' ) .
  33.                     ( $set[ 2 ] && $set[ 3 ] ? '<br>' : '' ) .
  34.                     ( $set[ 3 ] ? $params[ 3 ] :( $set[ 1 ] ? $params[ 1 ] : '' ) ) .
  35.                     '</a>';
  36.                    
  37.                     $in = str_replace( '{{' . $matches[ 1 ] . '}}', $replace, $in );
  38.                 }
  39.             }
  40.         }
  41.     }
  42.     return $in;
  43. }
  44.  
  45. ?>
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement