__('Everyone', 'aniga'), 1 => __('Userlevel', 'aniga') . ' >= 1', 2 => __('Userlevel', 'aniga') . ' >= 2', 3 => __('Userlevel', 'aniga') . ' >= 3', 4 => __('Userlevel', 'aniga') . ' >= 4', 5 => __('Userlevel', 'aniga') . ' >= 5', 6 => __('Userlevel', 'aniga') . ' >= 6', 7 => __('Userlevel', 'aniga') . ' >= 7', 8 => __('Userlevel', 'aniga') . ' >= 8', 9 => __('Userlevel', 'aniga') . ' >= 9', 10 => __('Administrator', 'aniga')); // table names $wpdb->aniga_alb = $wpdb->prefix . 'aniga_albums'; $wpdb->aniga_pic = $wpdb->prefix . 'aniga_picture'; $wpdb->aniga_rel = $wpdb->prefix . 'aniga_relations'; //function to create the tables on plugin activation //######################################################################## function aniga_install () { global $wpdb; require_once(ABSPATH . 'wp-admin/upgrade-functions.php'); $table_alb = $wpdb->aniga_alb; if($wpdb->get_var("show tables like '$table_alb'") != $table_alb) { $sql = "CREATE TABLE `".$table_alb."` ( `id` BIGINT( 20 ) NOT NULL DEFAULT '0', `name` TEXT NOT NULL , `desc` TEXT NOT NULL , `level` VARCHAR( 2 ) NOT NULL DEFAULT '0', `order` MEDIUMINT NOT NULL DEFAULT '0', `count` MEDIUMINT NOT NULL , PRIMARY KEY (`id`) );"; dbDelta($sql); } $table_rel = $wpdb->aniga_rel; if($wpdb->get_var("show tables like '$table_rel'") != $table_rel) { $sql = "CREATE TABLE `".$table_rel."` ( `id` BIGINT( 20 ) NOT NULL , `parent_id` BIGINT( 20 ) NOT NULL );"; dbDelta($sql); } $table_pic = $wpdb->aniga_pic; if($wpdb->get_var("show tables like '$table_pic'") != $table_pic) { $sql = "CREATE TABLE `".$table_pic."` ( `pid` BIGINT( 20 ) NOT NULL auto_increment, `parent_id` BIGINT( 20 ) NOT NULL default '0', `path` VARCHAR( 200 ) NOT NULL default '', `filename` VARCHAR( 200 ) NOT NULL default '', `hits` BIGINT( 20 ) NOT NULL default '0', `width` SMALLINT( 6 ) NOT NULL default '0', `height` SMALLINT( 6 ) NOT NULL default '0', `pic_date` DATETIME NOT NULL, `caption` TEXT NOT NULL, `level` VARCHAR( 2 ) NOT NULL default '0', PRIMARY KEY (`pid`) );"; dbDelta($sql); } $column_name = 'comment_pid_ID'; $create_ddl = "ALTER TABLE `".$wpdb->comments."` ADD `".$column_name."` VARCHAR( 20 ) NOT NULL DEFAULT '';"; maybe_add_column($wpdb->comments, $column_name, $create_ddl); if (get_option('aniga_base-id') == '') { $post_author = 1; $post_content = 'Photo gallery'; $post_title = 'photography'; $post_date = gmdate('Y-m-d H:i:s'); $post_date_gmt = gmdate('Y-m-d H:i:s'); $post_category = 1; $post_status = 'publish'; $comment_status = 'closed'; $ping_status = 'closed'; $post_parent = 0; $post_type = 'page'; $page_template = 'gallery-index.php'; $post_data = compact('post_content','post_title','post_date','post_date_gmt','post_author','post_category', 'post_status', 'comment_status', 'ping_status', 'post_status', 'post_parent', 'post_type', 'page_template'); $post_data = add_magic_quotes($post_data); $post_ID = wp_insert_post($post_data); add_option('aniga_base-id', $post_ID, 'base wp ID for ANIga'); } $urlpath = get_bloginfo('url'); add_option('aniga_dirpath', $urlpath.'/wp-content/gallery/', 'dir path'); $abspath = str_replace("\\", "/", ABSPATH); add_option('aniga_abspath', $abspath.'wp-content/gallery/', 'absolute path'); add_option('aniga_thumb_size', '100', 'max Thumbnail size'); add_option('aniga_thumb_csize', '150', 'max Thumbnail size'); add_option('aniga_thumb_square', 'yes', 'Create square thumbnails'); add_option('aniga_caimg_size', '100', 'max Cat/Alb size'); add_option('aniga_norm_size', '400', 'max normal Image size'); add_option('aniga_resize', 'yes', 'resize Images'); add_option('aniga_resize_qual', '100', 'resize Quality'); add_option('aniga_thumb_reflection', 'yes', 'create an Apple like reflection on thumbnails'); add_option('aniga_thumb_reflection_b', 'a4a4a4', 'border for reflection'); add_option('aniga_rolemgr', 'no', 'Use Role Manager Plugin'); add_option('aniga_colums', '3', 'colums in thumbnail page'); add_option('aniga_css', 'yes', 'external CSS style'); add_option('aniga_slds_prefetch', '12', 'ANIga slideshow prefetch'); add_option('aniga_slds_time', '4000', 'ANIga slideshow time'); add_option('aniga_slds_filter', 'no', 'ANIga slideshow filter'); add_option('aniga_delete', 'yes', 'ANIga delete pictures from filesystem'); add_option('aniga_trackback_sent', 'no', 'ANIga trackback sent'); add_option('aniga_img_mode', 'link', 'ANIga Picture link mode'); add_option('aniga_img_sort', 'filename', 'Picture sort mode'); add_option('aniga_img_order', 'ASC', 'Picture order mode'); if (ini_get('safe_mode') || ini_get('safe_mode') == 'on') $zip_mode = "none"; else { if (function_exists('zip_open')) { $zip_mode = "zip"; } else { if (function_exists('exec')) { $zip_mode = "mzip"; } else { $zip_mode = "mzipx"; } } } add_option('aniga_zip_mode', $zip_mode, 'zip mode'); } add_action('activate_aniga_gallery.php','aniga_install'); load_plugin_textdomain('aniga', 'wp-content/plugins/ANIga/language'); // load functions if needed //######################################################################## function aniga_start_gallery() { require_once("ANIga/functions.php"); } //adds the pid to comments for pictures //######################################################################## function aniga_comment_add_pid($comment_ID) { global $wpdb; $ppid = $_GET['pid']; if ($ppid != '') $dopid = $wpdb->query("UPDATE $wpdb->comments SET comment_pid_ID = '$ppid' WHERE comment_ID = '$comment_ID' LIMIT 1"); return $comment_ID; } add_action('comment_post','aniga_comment_add_pid'); add_action('trackback_post','aniga_comment_add_pid'); add_action('pingback_post','aniga_comment_add_pid'); // adds the gallery-css link to the HEAD and the javascript code // to slideshow pages //######################################################################## function aniga_add_css() { ?> ID; $pagestruct = $wp_rewrite->get_page_permastruct(); if ( !$nav ) $do_nav = ''; else $do_nav = '#picture_nav'; if ( '' != $pagestruct ) { $link = get_page_uri($id); $link = str_replace('%pagename%', $link, $pagestruct); $link = get_settings('home') . "/".$link."/?".$do."=".$go_id.$do_nav; } else { $link = get_settings('home') . "/?page_id=".$id."&".$do."=".$go_id.$do_nav; //maybe the '&' will get screwed up? } return apply_filters('page_link', $link, $id); } function aniga_get_userinfo() { global $userdata; get_currentuserinfo(); if ($userdata->user_level == '') $user = 0; else $user = $userdata->user_level; return $user; } //RANDOM IMAGE FUNCTION //######################################################################## function aniga_show_rand_img($before = '
', $after = '
', $limit = 3) { //show random images on the sidebar with one random comment (if there is one for this picture) global $wpdb; $i=1; $level = aniga_get_userinfo(); $rand_img_req = "SELECT pid, path, filename, parent_id FROM $wpdb->aniga_pic WHERE level <= $level ORDER BY RAND() LIMIT $limit"; $rand_img_ret = $wpdb->get_results($rand_img_req); if ($rand_img_ret) { foreach ($rand_img_ret as $rand_img) { $rand_com_req = "SELECT comment_ID, comment_content FROM $wpdb->comments WHERE comment_pid_ID=$rand_img->pid ORDER BY RAND() LIMIT 1"; $rand_com_ret = $wpdb->get_results($rand_com_req); if ($wpdb->num_rows == 1 ) { foreach ($rand_com_ret as $rand_com) { $com_lenth = 7; $com_trans = array("