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,$mypicture_id,$myreference,$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; } //################################################################# // pre convert mygallery-tags (mygalsw etc.) add by norida function pre_conv_tag($mystring) { // mygalsw tag $search = "/\[mygalsw=([A-Za-z0-9\-\_]+),(month|hour|wday),([A-Za-z0-9\-\_\=\,]*)\]/"; 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) { $strgal = $temp_array[1][$key]; $strswkind = $temp_array[2][$key]; $arytmp = explode(',', $temp_array[3][$key]); if (!is_array($arytmp)) $arytmp = array(); $arydata = array(); foreach ($arytmp as $v1) { list($tmp_key, $tmp_data) = explode('=', $v1); $arydata[$tmp_key] = $tmp_data; } $nowsw = -1; $arygetdate = getdate(); switch ($strswkind) { case 'month': $nowsw = $arygetdate['mon']; break; case 'hour': $nowsw = $arygetdate['hours']; break; case 'wday': $nowsw = $arygetdate['wday']; break; } if (!($nowsw < 0)) { if (isset($arydata[$nowsw])) $strgal = $arydata[$nowsw]; } $search = $temp_array[0][$key]; $replace = '[mygal='.$strgal.']'; $mystring = str_replace ($search, $replace, $mystring); } } } return $mystring; } //################################################################# // reads all mygallery-tags an replaces the tags with content function conv_tag($mystring) { // used variables $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); } } } $search = "/\[mygallistgal\]/"; if (preg_match($search, $mystring)){ if (preg_match($search, $mystring)){ $replace=gallistgal(); $search = "/\[mygallistgal\]/"; $mystring= preg_replace ($search, $replace, $mystring); } } $search = "/\[myginpage=(\w+)\]/"; 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); } } } $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); } } } $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',6,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'), 6,dirname(__FILE__).'/myfunctions/mygalleryadmin.php'); add_submenu_page( dirname(__FILE__).'/myfunctions/mygallerymain.php', __('Options', 'myGallery'), __('Options', 'myGallery'), 6,dirname(__FILE__).'/myfunctions/mygalleryoptions.php'); add_submenu_page( dirname(__FILE__).'/myfunctions/mygallerymain.php', __('Gallery Style', 'myGallery'),__('Gallery Style', 'myGallery'), 10,dirname(__FILE__).'/myfunctions/mygallerystyle.php'); add_submenu_page( dirname(__FILE__).'/myfunctions/mygallerymain.php', __('Exif Settings', 'myGallery'), __('Exif Settings', 'myGallery'), 6,dirname(__FILE__).'/myfunctions/mygalleryexif.php'); add_submenu_page( dirname(__FILE__).'/myfunctions/mygallerymain.php', __('Info', 'myGallery'), __('Info', 'myGallery'), 6,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.'