picture_id) { if (preg_match($search, $content,$matches)) { $tmp_result=getfirstgallerypicture($matches[1],$matches[2]); $mynavigation_obj->picture_id=$tmp_result->id; } } if ($mynavigation_obj->picture_id) { if (preg_match($search, $content,$matches)){ $result=getpicture($mynavigation_obj->picture_id); // exit if there is no pictures with this id if (!$result) { return; } $search = "/\[mygal=".$result->name."(|\([0-9\,]+\))]/"; $replace = "[mybigpic][mygal=".$result->name."$1]"; $content = preg_replace ($search, $replace, $content); // show thumbs under bgc picture if ($mg_options[bigpicshowthumbs]) { $content=conv_tag($content); } else { $search = "/\[mygal=([A-Za-z0-9\-\_]+)(|\([0-9\,]+\))\]/"; $replace=''; $content = preg_replace ($search, $replace, $content); } // create HTML for big picture $search = "/\[mybigpic\]/"; $replace=createhtmlforbigpicture($result,$mynavigation_obj->picture_id,$matches[2]); $content = preg_replace ($search, $replace, $content); } } else { // if there is no gallery_id match, function returns a empty page $content=conv_tag($content); } return $content; } //################################################################# // reads all mygallery-tags an replaces the tags with content function conv_tag($mystring) { // single gallery $search = "/\[mygal=([A-Za-z0-9\-\_]+)(|\([0-9\,]+\))\]/"; $mg_options=get_option('mygalleryoptions'); global $myurl; if (preg_match($search, $mystring)){ preg_match_all($search, $mystring, $temp_array); if (is_array ($temp_array[1])) { foreach ($temp_array[1] as $key=>$v0) { $search = "/\[mygal=".$v0.addcslashes ($temp_array[2][$key],'\(\)')."\]/"; $replace= showtumbs($v0,0,$temp_array[2][$key]); $mystring= preg_replace ($search, $replace, $mystring); } } } // gallery overview $search = "/\[mygallistgal\]/"; if (preg_match($search, $mystring)){ if (preg_match($search, $mystring)){ $replace=gallistgal(); $search = "/\[mygallistgal\]/"; $mystring= preg_replace ($search, $replace, $mystring); } } // inline gallery $search = "/\[myginpage=([A-Za-z0-9\-\_]+)(|\([0-9\,]+\))\]/"; if (preg_match($search, $mystring)){ preg_match_all($search, $mystring, $temp_array); if (is_array($temp_array[1])) { foreach ($temp_array[1] as $v0) { $search = "/\[myginpage=".$v0."\]/"; $replace=showtumbs($v0,1); $mystring= preg_replace ($search, $replace, $mystring); } } } // single picture $search = "/\[inspic=(\d+)(|,\w+|,)(|,http:\/\/[^,]+|,fullscreen|,gal|,)(|,thumb|,\d+|,)(|,:\w+)\]/"; if (preg_match($search, $mystring,$sresult)){ preg_match_all($search, $mystring, $temp_array); if (is_array($temp_array)) { foreach ($temp_array[1] as $key =>$v0) { $search = "/\[inspic=".$v0.$temp_array[2][$key].addcslashes($temp_array[3][$key],'\/').$temp_array[4][$key].$temp_array[5][$key]."\]/"; $replace=myinlinepicture($v0,$temp_array[2][$key],$temp_array[3][$key],$temp_array[4][$key],$temp_array[5][$key]); $mystring= preg_replace ($search, $replace, $mystring); } } } // picture link $search = "/\[mypicref=(\d+)\](.*)\[\/mypicref\]/U"; if (preg_match($search, $mystring)){ preg_match_all($search, $mystring, $temp_array); if (is_array($temp_array[1])) { foreach ($temp_array[1] as $key => $v0) { $search = "/\[mypicref=".$v0."\](.*)\[\/mypicref\]/U"; $replace=mytextpiclink($v0,$temp_array[2][$key]); $mystring= preg_replace ($search, $replace, $mystring); } } } $mystring=" \t".$mystring; return $mystring; } //################################################################# // adminpanel functions function mygallery_menu() { if (function_exists('add_menu_page')) { add_menu_page('mygallery Generator', 'myGallery','use myGallery',dirname(__FILE__).'/myfunctions/mygallerymain.php'); } if (function_exists('add_submenu_page')) { $mg_options=get_option('mygalleryoptions'); if ($mg_options[language]) load_textdomain('myGallery', myGalleryPath.'/languages/'.$mg_options[language].'.mo'); add_submenu_page( dirname(__FILE__).'/myfunctions/mygallerymain.php', __('Gallery Management', 'myGallery'), __('Gallery Management', 'myGallery'), 'use myGallery',dirname(__FILE__).'/myfunctions/mygalleryadmin.php'); add_submenu_page( dirname(__FILE__).'/myfunctions/mygallerymain.php', __('Options', 'myGallery'), __('Options', 'myGallery'), 'myGallery Settings',dirname(__FILE__).'/myfunctions/mygalleryoptions.php'); add_submenu_page( dirname(__FILE__).'/myfunctions/mygallerymain.php', __('Gallery Style', 'myGallery'),__('Gallery Style', 'myGallery'), 'myGallery Settings',dirname(__FILE__).'/myfunctions/mygallerystyle.php'); add_submenu_page( dirname(__FILE__).'/myfunctions/mygallerymain.php', __('Exif Settings', 'myGallery'), __('Exif Settings', 'myGallery'), 'myGallery Settings',dirname(__FILE__).'/myfunctions/mygalleryexif.php'); add_submenu_page( dirname(__FILE__).'/myfunctions/mygallerymain.php', __('Info', 'myGallery'), __('Info', 'myGallery'), 'use myGallery',dirname(__FILE__).'/myfunctions/mygallinfo.php'); } } //################################################################# function myrandompic($myamount=1) { global $table_prefix, $wpdb,$wp_rewrite,$mg_options; // used variables $mybaseurl=get_bloginfo('wpurl'); $mg_options=get_option('mygalleryoptions'); $myurl=$mybaseurl.'/'.$mg_options[gallerybasepath]; // read pictures table into array $mg_options=get_option('mygalleryoptions'); if ($mg_options[excludeoverview]) { $mypicturesarray = $wpdb->get_results('SELECT '.$table_prefix.'mypictures.id FROM '.$table_prefix.'mypictures, '.$table_prefix.'mygallery, '.$table_prefix.'mygprelation WHERE ' .$table_prefix.'mypictures.id = '.$table_prefix. 'mygprelation.pid AND '.$table_prefix.'mygprelation.gid = '.$table_prefix.'mygallery.id AND ('.$table_prefix.'mygallery.excludegal IS NULL OR '.$table_prefix.'mygallery.excludegal=0 ) AND ('.$table_prefix.'mypictures.picexclude IS NULL OR '.$table_prefix.'mypictures.picexclude=0)'); } else { $mypicturesarray = $wpdb->get_results('SELECT id FROM '.$table_prefix.'mypictures WHERE '.$table_prefix.'mypictures.picexclude IS NULL OR '.$table_prefix.'mypictures.picexclude=0'); } // exit if no gallery pictures are found if (!$mypicturesarray) { return; } // get random element(s) for ($i =1; $i<=$myamount; $i++){ srand(); $myrandomid=$mypicturesarray[ array_rand ($mypicturesarray)]->id; // read element infos $result=$wpdb->get_row('SELECT * FROM '.$table_prefix.'mypictures,'.$table_prefix.'mygprelation,'.$table_prefix.'mygallery WHERE '.$table_prefix.'mypictures.id = '.$myrandomid.' AND '.$table_prefix.'mygprelation.pid = '.$myrandomid.' AND '.$table_prefix.'mygallery.id ='.$table_prefix.'mygprelation.gid' ); $mypage_id=$wpdb->get_var('SELECT pageid FROM '.$table_prefix.'mygallery WHERE id ='.$result->gid); // return picture if ($mg_options[templatemode] AND (!$mypage_id)) $mypage_id=$mg_options[templatemodeid]; if ($mg_options[randombox]) { $myhyperlink_open=''; $myhyperlink_close=''; } else if ($mypage_id) { $myreference=get_permalink($mypage_id); if ( $wp_rewrite->using_permalinks() ) { $myreference=$myreference.'?picture_id='; } else { $myreference=$myreference.'&picture_id='; } $myhyperlink_open=''; $myhyperlink_close=''; } $thumb_size=getimagesize(ABSPATH.$mg_options[gallerybasepath].$result->name.'/tumbs/tmb_'.$result->picturepath); $mypicstring=$mypicstring.'