Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function trk_bulklink( $in = '' )
- {
- $pattern = '/{{(.*\|.*)}}/';
- preg_match_all( $pattern, $in, $matches_full );
- if ( count( $matches_full ) > 0 )
- {
- foreach($matches_full as $matches )
- {
- if ( isset( $matches[ 1 ] ) )
- {
- $params = explode( '|', $matches[ 1 ] );
- trk_echo3('params', array( $params ) );
- if ( isset( $params[ 1 ] ) && isset( $params[ 2 ] ) )
- {
- for($offset=0;$offset<=3;$offset++)
- {
- $set[$offset]=true;
- if($set[$offset]) { $set[$offset] = isset( $params[ $offset ] ); }
- if($set[$offset]) { $set[$offset] = is_string( $params[ $offset ] ); }
- if($set[$offset]) { $set[$offset] = strlen( $params[ $offset ] ) > 0; }
- }
- trk_echo3('params', array( $params ) );
- $replace =
- '<a href="?' . urlencode( $set[ 0 ] ? $params[ 0 ] : '' ).
- '=' . urlencode( $set[ 1 ] ? $params[ 1 ] : '' ) .
- '">' .
- ( $set[ 2 ] ? ( '<img src="' . urlencode( $params[ 2 ] ) . '">' ) : '' ) .
- ( $set[ 2 ] && $set[ 3 ] ? '<br>' : '' ) .
- ( $set[ 3 ] ? $params[ 3 ] :( $set[ 1 ] ? $params[ 1 ] : '' ) ) .
- '</a>';
- $in = str_replace( '{{' . $matches[ 1 ] . '}}', $replace, $in );
- }
- }
- }
- }
- return $in;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement