xml_load_file($file); } function simplexml_load_string($string) { $sx = new SimpleXML; return $sx->xml_load_string($string); } } else { define('FGALLERY_PHP4_MODE', 0); require_once('includes/thumbs/ThumbLib.inc.php'); } global $wpdb; $siteurl = get_option('siteurl'); $extra_dir = str_replace($_SERVER['HTTP_HOST'],'',$siteurl); $extra_dir = str_replace('http://www.','',$extra_dir); $extra_dir = str_replace('http://','',$extra_dir); //define table names and constants define('FGALLERY_VERSION','1.6.2'); define('EXTRA_DIR',$extra_dir.'/'); define('ALBUMS_TABLE', $wpdb->prefix . "fgallery_albums"); define('IMAGES_TABLE', $wpdb->prefix . "fgallery_images"); define('IMAGES_TO_ALBUMS_TABLE', $wpdb->prefix . "fgallery_album_images"); define('ALBUMS_SETTINGS_TABLE', $wpdb->prefix . "fgallery_albums_settings"); define('TEMPLATES_TABLE', $wpdb->prefix . "fgallery_templates"); define('FGALLERY_PATH', WP_PLUGIN_URL.'/'.basename(dirname(__FILE__))); define('FGALLERY_ABSPATH', ABSPATH.'/wp-content/plugins/'.basename(dirname(__FILE__))); define('FGALLERY_DIR', ABSPATH . 'wp-content/uploads/fgallery'); if (FGALLERY_PHP4_MODE) { define('COVER_PATH',WP_PLUGIN_URL.'/'.basename(dirname(__FILE__)).'/show_image.php?width=200&filename='.EXTRA_DIR); if (get_option('1_flash_gallery_preview_opt',0) == 1){ define('PREVIEW_PATH',WP_PLUGIN_URL.'/'.basename(dirname(__FILE__)).'/show_image.php?width=300&filename='.EXTRA_DIR); } define('THUMB_PATH',WP_PLUGIN_URL.'/'.basename(dirname(__FILE__)).'/show_image.php?width=600&filename='.EXTRA_DIR); } else { define('COVER_PATH',WP_PLUGIN_URL.'/'.basename(dirname(__FILE__)).'/show_image_5.php?width=200&filename='.EXTRA_DIR); if (get_option('1_flash_gallery_preview_opt',0) == 1){ define('PREVIEW_PATH',WP_PLUGIN_URL.'/'.basename(dirname(__FILE__)).'/show_image_5.php?width=300&filename='.EXTRA_DIR); } define('THUMB_PATH',WP_PLUGIN_URL.'/'.basename(dirname(__FILE__)).'/show_image_5.php?width=600&filename='.EXTRA_DIR); } define('MUSIC_PATH','musicPath'); define('FGALLERY_APP_ID','101920689894773'); define('FGALLERY_FB_PATH','http://test.1plugin.com/facebook/index.php'); //registering install and uninstall hooks register_activation_hook(__FILE__,'fgallery_install'); if (function_exists('register_update_hook')) { register_update_hook(__FILE__,'fgallery_update'); } register_uninstall_hook(__FILE__,'fgallery_uninstall'); //localizations $plugin_dir = basename(dirname(__FILE__)).'/languages/'; load_plugin_textdomain( 'fgallery', null, $plugin_dir ); // installation script function fgallery_install() { global $wpdb; global $wp_filesystem; //add option for screen options (number of elements per page) add_option('1_flash_gallery_page_fgallery_images_per_page', '25', '', 'no'); add_option('toplevel_page_fgallery_per_page', '25', '', 'no'); add_option('1_flash_gallery_watermark_enabled','0','','no'); add_option('1_flash_gallery_watermark_path','','','no'); add_option('1_flash_gallery_watermark_place','','','no'); add_option('fgallery_db_version', '0','',no); if($wpdb->get_var("SHOW TABLES LIKE '" . ALBUMS_TABLE . "'") != ALBUMS_TABLE) { add_option("fgallery_db_version", FGALLERY_VERSION); // create albums table $create_albums = "CREATE TABLE " . ALBUMS_TABLE . " ( `gall_id` int(11) NOT NULL auto_increment, `gall_name` varchar(255) collate utf8_unicode_ci NOT NULL, `gall_description` text collate utf8_unicode_ci NULL default NULL, `gall_cover` int(11) default '0', `gall_createddate` datetime NOT NULL, `gall_createdby` int(11) NOT NULL, `gall_published` tinyint(1) default 1, `gall_width` int(11) default '450', `gall_height` int(11) default '385', `gall_bgcolor` varchar(6) default 'ffffff', `gall_type` smallint(3) default '3', `gall_order` int(11) NOT NULL, PRIMARY KEY (`gall_id`) );" ; require_once(ABSPATH . 'wp-admin/upgrade-functions.php'); dbDelta($create_albums); } if($wpdb->get_var("SHOW TABLES LIKE '" . IMAGES_TABLE . "'") != IMAGES_TABLE) { // create images table $create_images = "CREATE TABLE " . IMAGES_TABLE . " ( `img_id` int(11) NOT NULL auto_increment, `img_caption` varchar(255) collate utf8_unicode_ci NULL, `img_description` text collate utf8_unicode_ci NULL, `img_date` datetime NOT NULL, `img_type` varchar(50) collate utf8_unicode_ci default '', `img_size` int(11) default '0', `img_path` varchar(255) collate utf8_unicode_ci default '', `img_vs_folder` smallint(5) default '0', `img_parent` int(11) default '0', PRIMARY KEY (`img_id`) )"; require_once(ABSPATH . 'wp-admin/upgrade-functions.php'); dbDelta($create_images); } if($wpdb->get_var("SHOW TABLES LIKE '" . IMAGES_TO_ALBUMS_TABLE . "'") != IMAGES_TO_ALBUMS_TABLE) { // create table for relation between images and albums $create_albums_images = "CREATE TABLE " . IMAGES_TO_ALBUMS_TABLE . " ( `img_id` int(11) NOT NULL, `gall_id` int(11) NOT NULL, `gall_folder` int(11) default 0, `img_order` smallint(5) default 0, `img_url` varchar(255) collate utf8_unicode_ci NULL, `img_extra` text collate utf8_unicode_ci NULL, PRIMARY KEY (`img_id`, `gall_id`) )"; require_once(ABSPATH . 'wp-admin/upgrade-functions.php'); dbDelta($create_albums_images); } $version = get_option('fgallery_db_version', 0); if (version_compare($version, '1.0.7', '<')) { $wpdb->query("ALTER TABLE `".IMAGES_TO_ALBUMS_TABLE."` ADD `img_url` VARCHAR( 255 ) collate utf8_unicode_ci NULL AFTER `img_order` ;"); } if (version_compare($version, '1.2.2', '<')) { $array = array('acosta','airion','arai','pax','pazin','postma','pageflip','nilus'); foreach ($array as $key=>$value) { $temp = get_option('1_flash_gallery_'.$value); if ($temp) { $option = substr($temp, 1, 9); update_option('1_flash_gallery_'.$value, $option); } } $wpdb->query("ALTER TABLE `".IMAGES_TO_ALBUMS_TABLE."` CHANGE `gall_folder` `gall_folder` int( 11 ) default 0 ;"); $wpdb->query("ALTER TABLE `".IMAGES_TO_ALBUMS_TABLE."` CHANGE `img_order` `img_order` int( 11 ) default 0 ;"); $wpdb->query("ALTER TABLE `".IMAGES_TABLE."` CHANGE `img_parent` `img_parent` int( 11 ) default 0 ;"); $wpdb->query("ALTER TABLE `".IMAGES_TABLE."` CHANGE `img_vs_folder` `img_vs_folder` int( 11 ) default 0 ;"); $wpdb->query("ALTER TABLE `".IMAGES_TABLE."` CHANGE `img_size` `img_size` int( 11 ) default 0 ;"); $wpdb->query("ALTER TABLE `".IMAGES_TABLE."` CHANGE `img_type` `img_type` varchar(50) collate utf8_unicode_ci default '' ;"); $wpdb->query("ALTER TABLE `".IMAGES_TABLE."` CHANGE `img_path` `img_path` varchar(50) collate utf8_unicode_ci default '' ;"); $wpdb->query("ALTER TABLE `".ALBUMS_TABLE."` CHANGE `gall_cover` `gall_cover` int(11) default 0 ;"); $wpdb->query("ALTER TABLE `".ALBUMS_TABLE."` CHANGE `gall_description` `gall_description` text collate utf8_unicode_ci ;"); } if($wpdb->get_var("SHOW TABLES LIKE '" . ALBUMS_SETTINGS_TABLE . "'") != ALBUMS_SETTINGS_TABLE) { // create table for albums settings $albums_settings = "CREATE TABLE " . ALBUMS_SETTINGS_TABLE . " ( `gall_id` int(11) NOT NULL, `value` text NOT NULL, PRIMARY KEY (`gall_id`) )"; require_once(ABSPATH . 'wp-admin/upgrade-functions.php'); dbDelta($albums_settings); } if (version_compare($version, '1.3.1', '<')) { if($wpdb->get_var("SHOW TABLES LIKE '" . TEMPLATES_TABLE . "'") != TEMPLATES_TABLE) { // create table for albums settings $templates = "CREATE TABLE " . TEMPLATES_TABLE . " ( `id` int(11) NOT NULL AUTO_INCREMENT, `gall_type` smallint(5) NOT NULL, `gall_settings` text NOT NULL, `created` date NOT NULL, `templ_title` varchar(255) collate utf8_unicode_ci NOT NULL, `templ_description` text, PRIMARY KEY (`id`) )"; require_once(ABSPATH . 'wp-admin/upgrade-functions.php'); dbDelta($templates); } } if (version_compare($version, '1.5.1', '<')) { add_option('1_flash_gallery_preview_opt','0','','no'); } if (version_compare($version, '1.5.6', '<')) { $wpdb->query("ALTER TABLE `".IMAGES_TO_ALBUMS_TABLE."` ADD `img_extra` text collate utf8_unicode_ci NULL;"); } update_option("fgallery_db_version", FGALLERY_VERSION); // try to make gallery dir if not exists if (!is_dir(FGALLERY_DIR)) { WP_Filesystem(); @ mkdir(FGALLERY_DIR); @ mkdir(FGALLERY_DIR.'/tmp'); } return true; } function fgallery_update() { $version = get_option('fgallery_db_version', 0); if (version_compare($version, '1.0.7', '<')) { $wpdb->query("ALTER TABLE `".IMAGES_TO_ALBUMS_TABLE."` ADD `img_url` VARCHAR( 255 ) collate utf8_unicode_ci NULL AFTER `img_order` ;"); } if (version_compare($version, '1.2.2', '<')) { $array = array('acosta','airion','arai','pax','pazin','postma','pageflip','nilus'); foreach ($array as $key=>$value) { $temp = get_option('1_flash_gallery_'.$value); if ($temp) { $option = substr($temp, 1, 9); update_option('1_flash_gallery_'.$value, $option); } } $wpdb->query("ALTER TABLE `".IMAGES_TO_ALBUMS_TABLE."` CHANGE `gall_folder` `gall_folder` int( 11 ) default 0 ;"); $wpdb->query("ALTER TABLE `".IMAGES_TO_ALBUMS_TABLE."` CHANGE `img_order` `img_order` int( 11 ) default 0 ;"); $wpdb->query("ALTER TABLE `".IMAGES_TABLE."` CHANGE `img_parent` `img_parent` int( 11 ) default 0 ;"); $wpdb->query("ALTER TABLE `".IMAGES_TABLE."` CHANGE `img_vs_folder` `img_vs_folder` int( 11 ) default 0 ;"); $wpdb->query("ALTER TABLE `".IMAGES_TABLE."` CHANGE `img_size` `img_size` int( 11 ) default 0 ;"); $wpdb->query("ALTER TABLE `".IMAGES_TABLE."` CHANGE `img_type` `img_type` varchar(50) collate utf8_unicode_ci default '' ;"); $wpdb->query("ALTER TABLE `".IMAGES_TABLE."` CHANGE `img_path` `img_path` varchar(50) collate utf8_unicode_ci default '' ;"); $wpdb->query("ALTER TABLE `".ALBUMS_TABLE."` CHANGE `gall_cover` `gall_cover` int(11) default 0 ;"); $wpdb->query("ALTER TABLE `".ALBUMS_TABLE."` CHANGE `gall_description` `gall_description` text collate utf8_unicode_ci ;"); } if (version_compare($version, '1.2.4', '<')) { add_option('1_flash_gallery_watermark_enabled','0','','no'); add_option('1_flash_gallery_watermark_path','','','no'); add_option('1_flash_gallery_watermark_place','','','no'); } if (version_compare($version, '1.3.1', '<')) { if($wpdb->get_var("SHOW TABLES LIKE '" . TEMPLATES_TABLE . "'") != TEMPLATES_TABLE) { // create table for albums settings $templates = "CREATE TABLE " . TEMPLATES_TABLE . " ( `id` int(11) NOT NULL AUTO_INCREMENT, `gall_type` smallint(5) NOT NULL, `gall_settings` text NOT NULL, `created` date NOT NULL, `templ_title` varchar(255) collate utf8_unicode_ci NOT NULL, `templ_description` text, PRIMARY KEY (`id`) )"; require_once(ABSPATH . 'wp-admin/upgrade-functions.php'); dbDelta($templates); } } if (version_compare($version, '1.5.1', '<')) { add_option('1_flash_gallery_preview_opt','0','','no'); } if (version_compare($version, '1.5.6', '<')) { $wpdb->query("ALTER TABLE `".IMAGES_TO_ALBUMS_TABLE."` ADD `img_extra` text collate utf8_unicode_ci NULL;"); } update_option("fgallery_db_version", FGALLERY_VERSION); return true; } // function that recursively removes directory and all files in it function fgallery_delete_dir($path) { $files = glob("$path/*"); foreach($files as $file) { if(is_dir($file) && !is_link($file)) { fgallery_delete_dir($file); } else { unlink($file); } } rmdir($path); } // uninstall script function fgallery_uninstall() { global $wpdb; require_once(ABSPATH . 'wp-admin/upgrade-functions.php'); //drop tables after uninstall dbDelta("DROP TABLE ". ALBUMS_TABLE); dbDelta("DROP TABLE ". PHOTOS_TABLE); dbDelta("DROP TABLE ". IMAGES_TO_ALBUMS_TABLE); dbDelta("DROP TABLE ". ALBUMS_SETTINGS_TABLE); dbDelta("DROP TABLE ". TEMPLATES_TABLE); //remove gallery directory fgallery_delete_dir(FGALLERY_DIR); return true; } function fgallery_get_current_user_role() { global $current_user; $user_roles = $current_user->roles; $user_role = array_shift($user_roles); return $user_role; } // defines the current user access level function fgallery_access_level(){ $role = fgallery_get_current_user_role(); switch ($role) { case 'administrator': return 10; case 'editor': return 7; case 'author': return 2; default: return 2; } } // initialization script function fgallery_init() { global $wp_version; wp_register_script('uploadify', FGALLERY_PATH.'/js/jquery.uploadify.v2.1.4.min.js',array('jquery')); wp_register_script('uploadjs', FGALLERY_PATH.'/js/fgallery_upload.js',array('jquery')); wp_register_script('fgalleryedit', FGALLERY_PATH.'/js/fgallery_edit.js',array('jquery')); wp_register_script('fgalleryjs', FGALLERY_PATH.'/js/fgallery.js',array('jquery')); wp_register_script('fgalleryimages', FGALLERY_PATH.'/js/fgallery_images.js',array('jquery')); wp_register_script('configurator', FGALLERY_PATH.'/js/configurator.js',array('jquery')); if ( version_compare( $wp_version, '3.2', '>=' ) ) { wp_register_script('uislider', FGALLERY_PATH.'/js/ui.slider32.js',array('jquery','jquery-ui-core'));// some code } elseif ( version_compare( $wp_version, '3.1', '>=' ) ) { wp_register_script('uislider', FGALLERY_PATH.'/js/ui.slider31.js',array('jquery','jquery-ui-core')); } else { wp_register_script('uislider', FGALLERY_PATH.'/js/ui.slider.js',array('jquery','jquery-ui-core')); } wp_register_script('copytoclipboard', FGALLERY_PATH.'/js/ZeroClipboard.js',array('jquery')); wp_register_script('copypref', FGALLERY_PATH.'/js/copy.js',array('jquery')); wp_register_script('swfhelper', FGALLERY_PATH. '/js/swfhelper.js',array('jquery')); wp_register_style('uploadifycss', FGALLERY_PATH. '/css/uploadify.css'); wp_register_style('uislidercss', FGALLERY_PATH. '/css/ui.slider.css'); wp_register_style('uithemecss', FGALLERY_PATH. '/css/ui.theme.css'); wp_register_style('uitabscss', FGALLERY_PATH. '/css/ui.tabs.css'); wp_register_style('configuratorcss', FGALLERY_PATH. '/css/configurator.css'); wp_register_style('farbtasticcss', FGALLERY_PATH. '/css/farbtastic.css'); wp_register_style('fgallerycss', FGALLERY_PATH. '/css/fgallery.css'); //needed for flash embeding wp_enqueue_script('swfobject'); wp_enqueue_script('thickbox'); wp_enqueue_script('swfhelper'); wp_enqueue_style('thickbox'); // building menu items add_action('admin_menu', 'fgallery_add_pages'); } add_action('init', 'fgallery_init'); // calls scripts for upload page function fgallery_upload_scripts(){ wp_enqueue_script('jquery-ui-tabs'); wp_enqueue_script('uploadjs'); wp_enqueue_script('uploadify'); wp_enqueue_script('jquery-form'); } // calls scripts for gallery index/add/edit pages function fgallery_admin_scripts() { wp_enqueue_script('jquery-form'); if ($_GET['action'] == 'edit' || $_GET['page'] == 'fgallery_add') { wp_enqueue_script('farbtastic'); wp_enqueue_script('configurator'); wp_enqueue_script('jquery-ui-tabs'); wp_enqueue_script('uislider'); wp_enqueue_script('copytoclipboard'); wp_enqueue_script('copypref'); } if ($_GET['action'] == 'pref') { wp_enqueue_script('copytoclipboard'); wp_enqueue_script('copypref'); } if ($_GET['action'] == 'images') { wp_enqueue_script('jquery-color'); } wp_enqueue_script('fgalleryedit'); wp_enqueue_script('jquery-ui-sortable'); wp_enqueue_script('fgalleryjs'); } // calls scripts for images index/add/edit pages function fgallery_admin_images_scripts(){ wp_enqueue_script('jquery-ui-droppable'); wp_enqueue_script('jquery-ui-draggable'); wp_enqueue_script('fgalleryimages'); } // calls css files for upload page function fgallery_upload_styles() { wp_enqueue_style('uploadifycss'); wp_enqueue_style('fgallerycss'); wp_enqueue_style('uitabscss'); wp_enqueue_style('uithemecss'); } // calls css files for upload page function fgallery_images_styles() { wp_enqueue_style('fgallerycss'); } // calls css files for upload page function fgallery_settings_styles() { wp_enqueue_style('fgallerycss'); } // calls css files for upload page function fgallery_admin_styles() { wp_enqueue_style('fgallerycss'); wp_enqueue_style('uitabscss'); wp_enqueue_style('uithemecss'); wp_enqueue_style('uislidercss'); wp_enqueue_style('farbtasticcss'); wp_enqueue_style('configuratorcss'); } // adding items to menu function fgallery_add_pages() { $pref = add_menu_page(__('1 Flash Gallery','fgallery'), __('1 Flash Gallery', 'fgallery'), 'upload_files', 'fgallery', 'fgallery_admin_albums'); if ( function_exists('add_submenu_page') ) { $main = add_submenu_page('fgallery', __('Galleries List','fgallery'), __('Galleries List','fgallery'), 'upload_files', 'fgallery', 'fgallery_admin_albums'); $add = add_submenu_page('fgallery', __('Create gallery','fgallery'), __('Create Gallery','fgallery'), 'upload_files', 'fgallery_add', 'fgallery_add_gallery'); $images = add_submenu_page('fgallery', __('Images List','fgallery'), __('Images List','fgallery'), 'upload_files', 'fgallery_images', 'fgallery_images_page'); $upload = add_submenu_page('fgallery', __('Upload images','fgallery'), __('Upload Images','fgallery'), 'upload_files', 'fgallery_upload', 'fgallery_upload_page'); $settings = add_submenu_page('fgallery', __('Settings','fgallery'), __('Settings','fgallery'), 'upload_files', 'fgallery_settings', 'fgallery_settings_page'); } add_action('admin_print_scripts-' . $upload, 'fgallery_upload_scripts'); add_action('admin_print_scripts-' . $main, 'fgallery_admin_scripts'); add_action('admin_print_scripts-' . $add, 'fgallery_admin_scripts'); add_action('admin_print_scripts-' . $images, 'fgallery_admin_images_scripts'); add_action('admin_print_styles-' . $upload, 'fgallery_upload_styles' ); add_action('admin_print_styles-' . $images, 'fgallery_images_styles' ); add_action('admin_print_styles-' . $main, 'fgallery_admin_styles' ); add_action('admin_print_styles-' . $add, 'fgallery_admin_styles' ); add_action('admin_print_styles-' . $settings, 'fgallery_settings_styles' ); } /* * Starting admin pages render * */ function fgallery_upload_page() { $nextgen = false; if (plugin_is_active('nextgen-gallery/nggallery.php')) { $nextgen = true; } $folders = fgallery_get_folders(); ?>

















'attachment','post_mime_type'=>'image','numberposts'=>999999999); $images = get_posts($args); ?>


'.__("Folder", 'fagllery').' wp-content/uploads/fgallery '.__("doesn't exist", 'fagllery').'

'; } elseif (!is_writeable(FGALLERY_DIR)) { echo '

'.__("Folder", 'fagllery').' wp-content/uploads/fgallery '.__("is not writable", 'fagllery').'

'; } _e('Note: Important! If single image is more then 1Mb galleries may work slower', 'fgallery');?>
guid).'" alt="'.$image->post_title.'" />'; ?>
post_title?>
path.'/thumbs/thumbs_'.$image->filename.'" alt="'.$image->alttext.'" />'; ?>
alttext?>
description?>

'.__('Server Name:', 'fgallery').''.$_SERVER['SERVER_NAME']."

"; echo '

'.__('Document Root:', 'fgallery').''.$_SERVER['DOCUMENT_ROOT']."

"; echo '

'.__('Web server:', 'fgallery').''.$_SERVER['SERVER_SOFTWARE']."

"; echo '

'.__('Host:', 'fagallery').''.$_SERVER['HTTP_HOST']."

"; echo '

'.__('Client Agent:', 'fgallery').''.$_SERVER['HTTP_USER_AGENT']."

"; echo '

'.__('Word Press version:', 'fagallery').''.$wp_version; echo '

'.__('Plugin version:', 'fgallery').''.FGALLERY_VERSION; echo '

'.__('Max size of uploaded file:', 'fgallery').''.ini_get('upload_max_filesize').'

'; if (!is_dir(FGALLERY_DIR)) { echo '

'.__("Folder", 'fgallery').' wp-content/uploads/fgallery '.__("doesn't exist", 'fgallery').'

'; } elseif (!is_writeable(FGALLERY_DIR)) { echo '

'.__("Folder", 'fgallery').' wp-content/uploads/fgallery '.__("is not writable", 'fgallery').'

'; } if (!is_dir(FGALLERY_DIR.'/tmp')) { echo '

'.__("Folder", 'fgallery').' wp-content/uploads/fgallery/tmp '.__("doesn't exist", 'fgallery').'

'; } elseif (!is_writeable(FGALLERY_DIR.'/tmp')) { echo '

'.__("Folder", 'fgallery').' wp-content/uploads/fgallery/tmp '.__("is not writable", 'fgallery').'

'; } if (FGALLERY_PHP4_MODE) { echo '

'.__("Your server runs PHP 4", 'fgallery').'

'; } ?>
'.__('Copy settings to clipboard', 'fagllery').'';?>

'; $updated = true; } if (get_option('1_flash_gallery_airion') != '') { echo '1 Flash Gallery Update Airion
'; $updated = true; } if (get_option('1_flash_gallery_arai') != '') { echo '1 Flash Gallery Update Arai
'; $updated = true; } if (get_option('1_flash_gallery_pax') != '') { echo '1 Flash Gallery Update Pax
'; $updated = true; } if (get_option('1_flash_gallery_pazin') != '') { echo '1 Flash Gallery Update Pazin
'; $updated = true; } if (get_option('1_flash_gallery_postma') != '') { echo '1 Flash Gallery Update Postma
'; $updated = true; } if (get_option('1_flash_gallery_pageflip') != '') { echo '1 Flash Gallery Update PageFlip
'; $updated = true; } if (get_option('1_flash_gallery_nilus') != '') { echo '1 Flash Gallery Update Nilus
'; $updated = true; } if (get_option('1_flash_gallery_nusl') != '') { echo '1 Flash Gallery Update Nusl
'; $updated = true; } if (get_option('1_flash_gallery_kranjk') != '') { echo '1 Flash Gallery Update Kranjk
'; $updated = true; } if (!$updated) { _e('There are no updates yet. You can get them at 1 Flash Gallery Wordpress Plugin Site', 'fgallery'); } ?>
'); } update_option('1_flash_gallery_watermark_path',$file_name); } update_option('1_flash_gallery_watermark_place',$_POST['wm_placement']); } $wm_enabled = get_option('1_flash_gallery_watermark_enabled'); $wm_path = get_option('1_flash_gallery_watermark_path'); $wm_place = get_option('1_flash_gallery_watermark_place'); ?>

name="wm_placement"> name="wm_placement"> name="wm_placement">
name="wm_placement"> name="wm_placement"> name="wm_placement">
name="wm_placement"> name="wm_placement"> name="wm_placement">
id="watermark_enabled" />

Current Watermark

watermark'; }?>

/>


query("DELETE FROM ". IMAGES_TO_ALBUMS_TABLE. " WHERE img_id IN (".$ids_string.") AND gall_id = ".$_POST['gall_id']); break; default : $wpdb->query("UPDATE ".IMAGES_TO_ALBUMS_TABLE." SET `gall_folder` =".$_POST['album_id']." WHERE `img_id` IN (".$ids_string.") AND `gall_id` = ".$_POST['gall_id']); break; } } } } if (isset($_GET['id']) && is_numeric($_GET['id'])) { $id = $_GET['id']; fgallery_edit_album_images_page($id); } break; default: // -- pagination ------------ if (!empty($_POST) && wp_verify_nonce($_POST['screenoptionnonce'], 'screen-options-nonce')) { update_option( $_POST['wp_screen_options']['option'], $_POST['wp_screen_options']['value']); } $pagenum = isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 0; $sort_by = isset($_GET['sort']) ? absint($_GET['sort']) : 4; if ( empty($pagenum) ) $pagenum = 1; if ( empty( $per_page ) || $per_page < 1 ) $per_page = get_option('toplevel_page_fgallery_per_page',25); apply_filters('toplevel_page_fgallery_per_page', $per_page); $num_pages = ceil(fgallery_albums_count() / $per_page); $page_links = paginate_links( array( 'base' => add_query_arg( 'paged', '%#%' ), 'format' => '', 'prev_text' => __('«'), 'next_text' => __('»'), 'total' => $num_pages, 'current' => $pagenum )); // --------------------------- $items = fgallery_get_albums($pagenum,$per_page, $sort_by); ?>

' . __( 'Displaying %s–%s of %s' ) . '%s', number_format_i18n( ( $pagenum - 1 ) * $per_page + 1 ), number_format_i18n( min( $pagenum * $per_page, $count_posts ) ), number_format_i18n( $count_posts ), $page_links ); echo $page_links_text; ?>
$page_links_text
"; } ?>
'; echo '

'.__('Images in', 'fgallery').' '.$album['gall_name'].' '.__('gallery','fgallery').'

'; $title = __('Add images', 'fgallery'); echo ''.$title.''; $title = __('Create album', 'fgallery'); echo ''.$title.'
'; if (!empty($images)){ echo fgallery_render_album_images($images, $id); } else { _e('There are no images in this gallery', 'fgallery'); } echo '
'; } // render edit gallery page function fgallery_edit_album_page($id){ echo '
'; $album = fgallery_get_album($id); if (empty($album)) { $album['gall_id'] = 0; $album['gall_width'] = 450; $album['gall_height'] = 385; $album['gall_bgcolor'] = "ffffff"; $album['gall_type'] = 3; } if ($id != 0) { echo '

'.__('Edit gallery', 'fgallery').' "'.$album['gall_name'].'"

'; } else { echo '

'.__('Add new gallery', 'fgallery').'

'; } echo '
'; if ($album['gall_published'] && $id != 0) { echo '

'.__('Embed code', 'fgallery').'

'; echo '
'.fgallery_do_shortcode($album['gall_id']).'
'; echo ''; } echo '
'; echo sc_params_pane($album); echo '
'; if ($id != 0): echo ''; $path = fgallery_search_flash_path($album); echo ' '; echo '
You need to upgrade your Flash Player

'; endif; echo '
'; echo '
'; } // renders image edit page function fgallery_edit_image_page($id){ echo '
'; if ( !empty($_POST) && check_admin_referer('fgallery_edit','fgallery_edit_image_field') ) { $save = fgallery_edit_image($_POST, $id); if ($save) { echo '

'.__('Image has been saved', 'fgallery').'

'; } else { echo '

'.__('Image name cannot be empty', 'fgallery').'

'; } } $image = fgallery_get_image($id); if ($image['img_vs_folder'] == 1) { echo '

'.__('Edit folder', 'fgallery').' "'.$image['img_caption'].'"

'; } elseif ($image['img_vs_folder'] == 0) { echo '

'.__('Edit image', 'fgallery').' "#'.$image['img_id'].' '.$image['img_caption'].'"

'; } echo fgallery_render_edit_image_form($image); if ($image['img_vs_folder'] == 0) { echo ' '.$image['img_caption'].' '; } echo '
'; } // renders images index page function fgallery_images_page() { global $wpdb; if (isset($_GET['action'])) { $action = $_GET['action']; } switch ($action) { case 'edit': if (isset($_GET['id']) && is_numeric($_GET['id'])) { $id = $_GET['id']; fgallery_edit_image_page($id); } break; case 'rotate': if (isset($_GET['id']) && is_numeric($_GET['id'])) { $id = $_GET['id']; if (isset($_GET['dir']) && is_numeric($_GET['dir'])) { $dir = $_GET['dir']; if ($dir) { fgallery_rotate_by_id($id, 'CW'); } else { fgallery_rotate_by_id($id, 'CC'); } } fgallery_edit_image_page($id); } break; case 'watermark': if (isset($_GET['id']) && is_numeric($_GET['id'])) { $id = $_GET['id']; fgallery_watermark_by_id($id); } fgallery_edit_image_page($id); break; default: // -- pagination ------------ if (!empty($_POST) && wp_verify_nonce($_POST['screenoptionnonce'], 'screen-options-nonce')) { update_option( $_POST['wp_screen_options']['option'], $_POST['wp_screen_options']['value']); } $pagenum = isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 0; $sort_by = isset($_GET['sort']) ? absint($_GET['sort']) : 3; $folder = isset($_GET['folder']) ? absint($_GET['folder']) : 0; if ($folder) { $folder_name = fgallery_get_folder_name($folder); } if ( empty($pagenum) ) $pagenum = 1; if ( empty( $per_page ) || $per_page < 1 ) $per_page = get_option('1_flash_gallery_page_fgallery_images_per_page',25); apply_filters('1_flash_gallery_page_fgallery_images_per_page', $per_page); $num_pages = ceil(fgallery_images_count($folder) / $per_page); $page_links = paginate_links( array( 'base' => add_query_arg( 'paged', '%#%' ), 'format' => '', 'prev_text' => __('«'), 'next_text' => __('»'), 'total' => $num_pages, 'current' => $pagenum )); // --------------------------- $items = fgallery_get_images($pagenum,$per_page, $folder, $sort_by); ?>

' . __( 'Displaying %s–%s of %s' ) . '%s', number_format_i18n( ( $pagenum - 1 ) * $per_page + 1 ), number_format_i18n( min( $pagenum * $per_page, $count_posts ) ), number_format_i18n( $count_posts ), $page_links ); echo $page_links_text; ?>
=5) :?>
$page_links_text
"; } ?>
get_var("SELECT value FROM ".ALBUMS_SETTINGS_TABLE." WHERE gall_id = ".$gall_id); if (empty($settings)) { return fgallery_default_album_settings(); } else { return unserialize($settings); } } // saves the albums settings to db function fgallery_save_album_settings($gall_id, $data) { global $wpdb; $res = $wpdb->get_row("SELECT * FROM ".ALBUMS_SETTINGS_TABLE." WHERE gall_id = ".$gall_id, ARRAY_A); if (empty($res)) { $wpdb->insert(ALBUMS_SETTINGS_TABLE, array('gall_id'=>$gall_id, 'value'=>serialize($data))); } else { $wpdb->update(ALBUMS_SETTINGS_TABLE, array('value'=>serialize($data)), array('gall_id'=>$gall_id)); } return true; } // save changes to gallery into db function fgallery_edit_album($data,$id) { global $wpdb; global $current_user; $name = htmlentities($data['fgallery_name'], ENT_NOQUOTES, "UTF-8"); $desc = htmlentities($data['fgallery_description'], ENT_NOQUOTES, "UTF-8"); $published = $data['fgallery_status']; $width = (int)$data['gall_width']; if ($width == 0) $width = 450; $height = (int)$data['gall_height']; if ($height == 0) $height = 385; $bgcolor = str_replace('#','',$data['gall_bgcolor']); $type = $data['gall_type']; if ($id == 0) { $user_id = $current_user->ID;//get_current_user_id(); $max = $wpdb->get_var("SELECT MAX(`gall_order`) FROM ".ALBUMS_TABLE); $wpdb->insert(ALBUMS_TABLE, array('gall_name' => $name, 'gall_description' => $desc, 'gall_createddate' => date("Y-m-d H:i:s"), 'gall_createdby' => $user_id, 'gall_published' => $published, 'gall_width'=>$width, 'gall_height'=> $height, 'gall_bgcolor'=> $bgcolor, 'gall_type'=> $type, 'gall_order' => $max + 1)); return $wpdb->insert_id; } if ($name != '') { $wpdb->update(ALBUMS_TABLE, array('gall_name' => $name, 'gall_description' => $desc, 'gall_published' => $published, 'gall_width'=>$width, 'gall_height'=> $height, 'gall_bgcolor'=> $bgcolor, 'gall_type'=> $type), array('gall_id' => $id)); return $id; } else { return 0; } } // save changes to image into db function fgallery_edit_image($data,$id) { global $wpdb; $name = htmlentities($data['fgallery_image_caption'], ENT_NOQUOTES, "UTF-8"); $desc = htmlentities($data['fgallery_image_description'], ENT_NOQUOTES, "UTF-8"); if ($name != '') { $wpdb->update(IMAGES_TABLE, array('img_caption' => $name, 'img_description' => $desc), array('img_id' => $id)); return 1; } else { return 0; } } function fgallery_edit_album_image($data) { global $wpdb; if (isset($data['img_id']) && is_numeric($data['img_id'])) { $id = $data['img_id']; } else { die('0'); } if (isset($data['gall_id']) && is_numeric($data['gall_id'])) { $gall_id = $data['gall_id']; } else { die('0'); } $action = 'fgallery_edit_image_field_'.$id; if (!wp_verify_nonce($_POST['nonce'], 'fgallery_edit')) { die('0'); } $name = htmlentities(urldecode($data['img_caption']), ENT_NOQUOTES, "UTF-8"); $desc = htmlentities(urldecode($data['img_description']), ENT_NOQUOTES, "UTF-8"); $url = urldecode($data['img_url']); $img_extra = array('img_type'=>$data['img_type']); $extra = serialize($img_extra); if ($name != '') { $wpdb->update(IMAGES_TABLE, array('img_caption' => $name, 'img_description' => $desc), array('img_id' => $id)); $wpdb->update(IMAGES_TO_ALBUMS_TABLE, array('img_url' => $url, 'img_extra' => $extra), array('img_id' => $id, 'gall_id' => $gall_id)); die('1'); } else { die('0'); } } // deletes image from db and deletes file function fgallery_delete_image($id) { global $wpdb; if (fgallery_access_level()>=5) { $wpdb->query("DELETE FROM ".IMAGES_TO_ALBUMS_TABLE." WHERE `img_id` = ".$id); $image = fgallery_get_image($id); if ($image['img_vs_folder'] == 1){ $wpdb->query("UPDATE ".IMAGES_TABLE." SET `img_parent` = 0 WHERE `img_parent` =".$id); $wpdb->query("DELETE FROM ".IMAGES_TABLE." WHERE `img_id` = ".$id); } elseif ($image['img_vs_folder'] == 0) { // we shouldn't delete wp media files so ..... if (strpos($image['img_path'],'fgallery') === false) { $wpdb->query("DELETE FROM ".IMAGES_TABLE." WHERE `img_id` = ".$id); } else { unlink(ABSPATH.$image['img_path']); $wpdb->query("DELETE FROM ".IMAGES_TABLE." WHERE `img_id` = ".$id); } } return true; } else { return false; } } // deletes gallery from db (does not delete files) function fgallery_delete_album($id) { global $wpdb; if (fgallery_access_level()>=8) { $wpdb->query("DELETE FROM ".IMAGES_TO_ALBUMS_TABLE." WHERE `gall_id` = ".$id); $wpdb->query("DELETE FROM ".ALBUMS_SETTINGS_TABLE." WHERE `gall_id` = ".$id); $wpdb->query("DELETE FROM ".ALBUMS_TABLE." WHERE `gall_id` = ".$id); return true; } else { return false; } } // returns the way of gallery sorting function fgallery_sort_albums_condition($sort) { switch ($sort){ case 0: return 'gall_name ASC'; break; case 1: return 'gall_name DESC'; break; case 2: return 'gall_createddate ASC'; break; case 3: return 'gall_createddate DESC'; break; case 4: return 'gall_order ASC'; break; default: return 'gall_order ASC'; break; } } // returns the way of image sorting function fgallery_sort_images_condition($sort) { switch ($sort){ case 0: return 'img_caption ASC'; break; case 1: return 'img_caption DESC'; break; case 2: return 'img_date ASC'; break; case 3: return 'img_date DESC'; break; case 4: return 'img_size ASC'; break; case 5: return 'img_size DESC'; break; } } function fgallery_get_nextgen_images() { global $wpdb; $images = $wpdb->get_results("SELECT a.pid, a.description, a.alttext, a.filename, b.path FROM ".$wpdb->prefix."ngg_pictures as a LEFT JOIN ".$wpdb->prefix."ngg_gallery as b ON (a.galleryid = b.gid)"); return $images; } // returns all folders function fgallery_get_folders(){ global $wpdb; $folders = $wpdb->get_results("SELECT * FROM " . IMAGES_TABLE." WHERE `img_vs_folder` = 1 ORDER BY `img_caption`", 'ARRAY_A'); return $folders; } // Returns all albums function fgallery_get_albums($pagenum, $per_page, $sort) { global $wpdb; $cond = fgallery_sort_albums_condition($sort); $albums = $wpdb->get_results("SELECT * FROM " . ALBUMS_TABLE." ORDER BY ".$cond." LIMIT ".($pagenum-1)*$per_page.",".$pagenum*$per_page, 'ARRAY_A'); return $albums; } // counts the number of galleries function fgallery_albums_count() { global $wpdb; $count = $wpdb->get_var("SELECT COUNT(*) FROM " .ALBUMS_TABLE); return $count; } function fgallery_count_gallery_album_images($folder) { global $wpdb; $count = $wpdb->get_var("SELECT COUNT(*) FROM ".IMAGES_TO_ALBUMS_TABLE." WHERE `gall_folder` = ".$folder); return $count; } // returns all the images function fgallery_get_images($pagenum, $per_page, $parent = 0, $sort = 3) { global $wpdb; $cond = fgallery_sort_images_condition($sort); $images = $wpdb->get_results("SELECT * FROM ". IMAGES_TABLE. " WHERE `img_parent` = ".$parent." AND `img_vs_folder` IN (0,1) ORDER BY `img_vs_folder` DESC, ".$cond." LIMIT ".($pagenum-1)*$per_page.",".$pagenum*$per_page, 'ARRAY_A'); return $images; } // counts the number of images in the folder (0 - root folder or not in any folder) function fgallery_images_count($folder) { global $wpdb; $count = $wpdb->get_var("SELECT COUNT(*) FROM " .IMAGES_TABLE." WHERE `img_parent` = ".$folder." AND `img_vs_folder` IN (0,1)"); return $count; } // returns defined gallery function fgallery_get_album($id) { global $wpdb; $album = $wpdb->get_row("SELECT * FROM ".ALBUMS_TABLE." WHERE gall_id = ".$id, ARRAY_A); return $album; } // returns defined image function fgallery_get_image($id) { global $wpdb; $image = $wpdb->get_row("SELECT * FROM ".IMAGES_TABLE." WHERE img_id = ".$id, ARRAY_A); return $image; } // returns the images from defined gallery function fgallery_get_album_images($gall_id, $folder = 0) { global $wpdb; $items = $wpdb->get_results("SELECT a.*, b.* FROM " . IMAGES_TABLE . " as a LEFT JOIN ". IMAGES_TO_ALBUMS_TABLE." as b ON (a.img_id = b.img_id) WHERE b.gall_id = " .$gall_id." AND b.gall_folder = ".$folder." ORDER BY a.img_vs_folder DESC, b.img_order ASC", 'ARRAY_A'); return $items; } // returns the galleries that have the defined image in them function fgallery_image_get_albums($id) { global $wpdb; $albums = $wpdb->get_results("SELECT a.gall_name, a.gall_id FROM ". ALBUMS_TABLE ." as a LEFT JOIN ". IMAGES_TO_ALBUMS_TABLE. " as b ON (a.gall_id = b.gall_id) WHERE b.img_id =".$id, ARRAY_A); return $albums; } // returns the folder name function fgallery_get_folder_name($id) { global $wpdb; $name = $wpdb->get_var("SELECT `img_caption` FROM ".IMAGES_TABLE." WHERE `img_id` =".$id); return $name; } function fgallery_get_settings_param($param, $settings) { $name = (string)$param['element_name']; if ($param['values'] == 'true') { return $settings[$name] ? 'true' : 'false'; } else { return $settings[$name]; } } function fgallery_prepare_settings($data) { unset($data['gallery']); $new = fgallery_default_album_settings(); foreach ($new as $key=>$value) { if ($data[$key] != '') { $new[$key] = $data[$key]; } } return $new; } /* * Starting the configurator rendering */ function sc_params_pane($album) { $gall_id = $album['gall_id']; $type = $album['gall_type']; $form = '
'; $params_xml = simplexml_load_file(FGALLERY_ABSPATH . '/xml/params_'.$type.'.xml'); $settings = fgallery_get_album_settings($gall_id); // Preparing jQuery UI tabs $tab_controls = ""; $form .= $tab_controls; $form .= fgallery_render_edit_album_form($album, $settings_xml->gallery->source); // Form the list of parameters in groups // if php 4 is running if (FGALLERY_PHP4_MODE) { foreach ($params_xml->params->group as $g) { $temp = $g->attributes(); $form .= '
'; $zebra = 'even'; foreach ($g->p as $p) { $p_temp = $p->attributes(); if (function_exists($fn = 'sc_controls_' . $p_temp['control'])) { $p_temp['element_name'] = 'sc_' . $temp['name'] . '__' . $p_temp['name']; $p_temp['default'] = fgallery_get_settings_param($p_temp, $settings); $p_temp['zebra'] = $zebra; $form .= $fn($p_temp); $zebra = $zebra == 'even' ? 'odd' : 'even'; } } $form .= '
'; } //end php 4 clause } else { // if php 5 is running foreach ($params_xml->params->group as $g) { $form .= '
'; $zebra = 'even'; foreach ($g->p as $p) { if (function_exists($fn = 'sc_controls_' . $p['control'])) { $p['element_name'] = 'sc_' . $g['name'] . '__' . $p['name']; $p['default'] = fgallery_get_settings_param($p, $settings); $p['zebra'] = $zebra; $form .= $fn($p); $zebra = $zebra == 'even' ? 'odd' : 'even'; } } $form .= '
'; } // end php condition } // "Save" button $form .= ''; $form .= wp_nonce_field('fgallery_settings','fgallery_settings_field'); $form .= '
'; return $form; } /** * Element text */ function sc_controls_text($p) { return '
' . '' . '' . '
'; } /** * Element - checkbox. */ function sc_controls_checkbox($p) { $checked = (int)$p['default'] ? 'checked="checked"' : ''; if ($checked == '' && (string)$p['default'] == 'true') $checked = 'checked = "checked"'; return '
' . '' . '' . '
'; } /** * Element - select. */ function sc_controls_select($p) { $options_raw = explode(',', $p['values']); $options = ''; foreach ($options_raw as $o) { $selected = (string) $p['default'] == $o ? 'selected="selected"' : ''; $options .= ''; } return '
' . '' . '' . '
'; } /** * Element - slider (jQuery UI slider). */ function sc_controls_slider($p) { $values = explode(':', $p['values']); // format "1..5:1" $range = $values[0]; $range = explode('..', $range); $min = $range[0]; $max = $range[1]; $step = $values[1]; // Validate values if (!is_numeric($step) || !is_numeric($min) || !is_numeric($max)) { return '
Parse error
'; } return '
' . '' . '' . '
'; } /** * Form element - color picker (Farbtastic). */ function sc_controls_color($p) { return '
' . '' . '' . '
'; } // Renders the list of all albums function fgallery_render_albums_table($albums){ $output .= ''; $output .= ''; if (!empty($albums)) { foreach ($albums as $album) { $output .= fgallery_render_album_item_row($album); } } else { $output .= ''; } $output .= '
'.__('ID').' '.__('Name','fgallery').' '.__('Cover','fgallery').' '.__('Description','fgallery').' '.__('Attributes','fgallery').' '.__('Actions','fgallery').'
'.__('ID').' '.__('Name','fgallery').' '.__('Cover','fgallery').' '.__('Description','fgallery').' '.__('Attributes','fgallery').' '.__('Actions','fgallery').'
'.__('There are no galleries yet. You can create new one using Add gallery menu','fgallery'). '
'; return $output; } // renders the row in the albums list function fgallery_render_album_item_row($album) { $id = $album['gall_id']; $output = ''; $output .= ''; $output .= ''.$id.''; $output .= ''.$album['gall_name'].''; $output .= ''.fgallery_get_album_cover($album).''; $output .= ''.$album['gall_description'].''; $output .= ''.fgallery_get_album_attributes($album).''; $output .= ''.fgallery_get_album_actions($id).''; $output .= ''; return $output; } function fgallery_render_album_image_form($item, $gall_id, $type) { if ($gall_id == '') { return ''; } $output .= '

'; $output .= '

'; $output .= '

'; if ($type == 7) { $item_img_type = unserialize($item['img_extra']); if ($item_img_type['img_type'] == 'page') { $selected_page = ' selected="selected"'; $selected_spread = ''; } else { $selected_spread = ' selected="selected"'; $selected_page = ''; } $output .= '

'; } $output .= wp_nonce_field('fgallery_edit','fgallery_edit_image_field_'.$item['img_id']); $output .= ''; $output .= ''.__('Save').''; return $output; } // renders the list of album images on gallery edit page function fgallery_render_album_images($items, $gall_id) { $title = __('Remove', 'fgallery'); $title_2 = __('Set as cover', 'fgallery'); $title_3 = __('Edit','fgallery'); $title_4 = __('Add images','fgallery'); $album = fgallery_get_album($gall_id); $output = ''; return $output; } // renders the list of images function fgallery_render_images_table($images){ $output .= ''; $output .= ''; if (isset($_GET['folder'])) { $output .= ''; } if (!empty($images)) { foreach ($images as $image) { $output .= fgallery_render_image_item_row($image); } } else { $output .= ''; } $output .= '
'.__('ID').' '.__('Caption', 'fgallery').' '.__('Preview', 'fgallery').' '.__('Description', 'fgallery').' '.__('Attributes', 'fgallery').' '.__('Actions', 'fgallery').'
'.__('ID').' '.__('Caption', 'fgallery').' '.__('Preview', 'fgallery').' '.__('Description', 'fgallery').' '.__('Attributes', 'fgallery').' '.__('Actions', 'fgallery').'
'.__('Go up', 'fgallery').'...
'.__('There are no images yet. You can upload new ones using Upload images menu', 'fgallery'). '
'; return $output; } // renders the row in the albums list function fgallery_render_image_item_row($image) { $id = $image['img_id']; if ($image['img_vs_folder']){ $output = ''; } else { $output = ''; } $output .= ''; $output .= ''.$id.''; if ($image['img_vs_folder']) { $output .= ''.$image['img_caption'].''; $output .= ''.$image['img_caption'].''; $output .= ''.$image['img_description'].''; $output .= ''.fgallery_get_folder_attributes($image).''; $output .= ''.fgallery_get_folder_actions($id).''; } else { $output .= ''.$image['img_caption'].''; $output .= ''.$image['img_caption'].''; $output .= ''.$image['img_description'].''; $output .= ''.fgallery_get_image_attributes($image).''; $output .= ''.fgallery_get_image_actions($id).''; } $output .= ''; return $output; } function fgallery_get_listof_gallery_albums($id) { global $wpdb; $albums =$wpdb->get_results("SELECT a.img_caption, a.img_id FROM ".IMAGES_TABLE." as a LEFT JOIN ".IMAGES_TO_ALBUMS_TABLE." as b ON (a.img_id = b.img_id) WHERE a.img_vs_folder = 2 AND b.gall_id = ".$id, ARRAY_A); if (count($albums) > 0) { $output = ''; $output .= ''; $output .= ''; } $output .= '
'; return $output; } function fgallery_create_thumb_url($width) { if (is_numeric($width)) { if (FGALLERY_PHP4_MODE) { return WP_PLUGIN_URL.'/'.basename(dirname(__FILE__)).'/show_image.php?width='.$width.'&filename='.EXTRA_DIR; } else { return WP_PLUGIN_URL.'/'.basename(dirname(__FILE__)).'/show_image_5.php?width='.$width.'&filename='.EXTRA_DIR; } } else { return COVER_PATH; } } // returns the wrapped in img tag album cover function fgallery_get_album_cover($album, $width ='') { global $wpdb; $gall_id = $album['gall_id']; if ($album['gall_cover'] != 0){ $cover_id = $album['gall_cover']; $cover = $wpdb->get_row("SELECT `img_path`, `img_caption` FROM " . IMAGES_TABLE . " WHERE `img_id` = " .$cover_id." LIMIT 1", 'ARRAY_A'); } else { $cover = $wpdb->get_row("SELECT a.`img_path`, a.`img_caption` FROM " . IMAGES_TABLE . " as a LEFT JOIN ". IMAGES_TO_ALBUMS_TABLE ." as b ON (a.img_id = b.img_id) WHERE b.gall_id = " .$gall_id." ORDER BY b.img_order ASC LIMIT 1", 'ARRAY_A'); } if ($cover['img_path']!=''){ $gall_cover = ''.$cover['img_caption'].''; } return $gall_cover; } //returns rendered album attributes (image quantity, total size, publish date and etc.) function fgallery_get_album_attributes($album, $extra = true) { global $wpdb; $id = $album['gall_id']; $attr = $wpdb->get_row("SELECT COUNT(a.img_id) as 'quantity', SUM(a.img_size) as 'total_size' FROM " . IMAGES_TABLE . " as a LEFT JOIN ". IMAGES_TO_ALBUMS_TABLE ." as b ON (a.img_id = b.img_id) WHERE b.gall_id = " .$id." AND a.img_vs_folder <> 2", 'ARRAY_A'); $output = __('Number of photos:', 'fgallery').$attr['quantity']. '
'; $output .= __('Total size:','fgallery').formatBytes($attr['total_size']). '
'; if ($extra) { if ($album['gall_published']) { $status = __('Published'); } else { $status = __('Draft'); } $output .= __('Gallery status:','fgallery').$status. '
'; $output .= date("d F Y",strtotime($album['gall_createddate'])). '
'; } return $output; } //returns rendered album attributes function fgallery_get_image_attributes($image){ $id = $image['img_id']; $albums = fgallery_image_get_albums($id); $albums_name = ''; if (count($albums)>0){ foreach ($albums as $album) { $albums_name .= $album['gall_name'].','; } $albums_name = substr($albums_name, 0, -1); } else { $albums_name = __('Image is not in any gallery', 'fgallery'); } $output = __('Galleries:', 'fgallery').$albums_name.'
'; $output.= __('Image type:', 'fgallery').$image['img_type'].'
'; $output.= __('Image size:', 'fgallery').formatBytes($image['img_size']).'
'; $output.= __('Upload date:', 'fgallery').date("d F Y",strtotime($image['img_date'])); return $output; } //returns rendered folder attributes function fgallery_get_folder_attributes($image){ global $wpdb; if ($image['img_vs_folder']) { $id = $image['img_id']; $attr = $wpdb->get_row("SELECT COUNT(a.img_id) as 'quantity', SUM(a.img_size) as 'total_size' FROM " . IMAGES_TABLE . " as a WHERE a.img_parent = " .$id, 'ARRAY_A'); $output = __('Images:', 'fgallery').$attr['quantity'].'
'; $output.= __('Images size:', 'fgallery').formatBytes($attr['total_size']).'
'; $output.= __('Create date:', 'fgallery').date("d F Y",strtotime($image['img_date'])); } return $output; } //renders the album actions function fgallery_get_album_actions($id) { $title_1 = __('Add images','fgallery'); $title_2 = __('Edit gallery','fgallery'); $title_3 = __('Delete gallery','fgallery'); $title_4 = __('Edit images', 'fgallery'); $output = ''.$title_1.''; $output .= ''.$title_2.''; $output .= ''.$title_4.''; if (fgallery_access_level()>= 8){ $output .= ''.$title_3.''; } return $output; } //renders the folder actions function fgallery_get_folder_actions($id) { $title_2 = __('Change name', 'fgallery'); $title_3 = __('Delete folder', 'fgallery'); $output .= ''.$title_2.''; $output .= ''.__('Create gallery', 'fgallery').''; if (fgallery_access_level()>= 5){ $output .= ''.$title_3.''; } return $output; } //renders the image actions function fgallery_get_image_actions($id) { $title_2 = __('Edit image', 'fgallery'); $title_3 = __('Delete image', 'fgallery'); $output = ''.$title_2.''; if (fgallery_access_level()>= 5){ $output .= ''.$title_3.''; } return $output; } // renders the shortcode for inserting the gallery into the content function fgallery_do_shortcode($id, $type = 0) { $album = fgallery_get_album($id); return sprintf('[fgallery id=%d w=%d h=%d t=%d title="%s"]',$id, $album['gall_width'], $album['gall_height'], $type, trim($album['gall_name'])); } // renders the gaellery edit form function fgallery_render_edit_album_form($album, $source) { $id = $album['gall_id']; $output .= '
'; $output .= '
'; $output .= '
'; $output .= ''; $output .= ''; $output .= '
'; $output .= '
'; $output .= ''; $opt = array(); $opt[$album['gall_type']] = 'selected ="selected"'; $output .= '
'; $output .= '
'; return $output; } function fgallery_get_flash_type($album) { switch ($album['gall_type']) { case 1: return 'acosta'; case 2: return 'airion'; case 3: return 'arai'; case 4: return 'pax'; case 5: return 'pazin'; case 6: return 'postma'; case 7: return 'pageflip'; case 8: return 'nilus'; case 9: return 'nusl'; case 10: return 'kranjk'; default: return 'arai'; } } // renders the image edit form function fgallery_render_edit_image_form($image) { $id = $image['img_id']; $output = '
'; $output .= '


'; if (!$image['img_vs_folder']){ $output .= '


'; } $output .= wp_nonce_field('fgallery_edit','fgallery_edit_image_field'); $output .= '

'; $output .='
'; return $output; } // formats the image/folder/gallery size function formatBytes($b,$p = null) { /** * * @author Martin Sweeny * @version 2010.0617 * * returns formatted number of bytes. * two parameters: the bytes and the precision (optional). * if no precision is set, function will determine clean * result automatically. * **/ $units = array("B","kB","MB","GB","TB","PB","EB","ZB","YB"); $c=0; if(!$p && $p !== 0) { foreach($units as $k => $u) { if(($b / pow(1024,$k)) >= 1) { $r["bytes"] = $b / pow(1024,$k); $r["units"] = $u; $c++; } } return number_format($r["bytes"],2) . " " . $r["units"]; } else { return number_format($b / pow(1024,$p)) . " " . $units[$p]; } } function mixed_to_utf8($data) { $search = array(' ','¡','¢','£','¤','¥','¦', '§','¨','©','ª','«','¬','­','®', '¯','°','±','²','³','´','µ', '¶','·','¸','¹','º','»','¼', '½','¾','¿','À','Á','Â', 'Ã','Ä','Å','Æ','Ç','È','É', 'Ê','Ë','Ì','Í','Î','Ï','Ð', 'Ñ','Ò','Ó','Ô','Õ','Ö','×', 'Ø','Ù','Ú','Û','Ü','Ý','Þ', 'ß','à','á','â','ã','ä','å', 'æ','ç','è','é','ê','ë','ì', 'í','î','ï','ð','ñ','ò','ó', 'ô','õ','ö','÷','ø','ù','ú', 'û','ü','ý','þ','ÿ'); $replace = array(' ','¡','¢','£','¤','¥','¦','§', '¨','©','ª','«','¬','­','®','¯', '°','±','²','³','´','µ','¶','·', '¸','¹','º','»','¼','½','¾','¿', 'À','Á','Â','Ã','Ä','Å','Æ','Ç', 'È','É','Ê','Ë','Ì','Í','Î','Ï', 'Ð','Ñ','Ò','Ó','Ô','Õ','Ö','×', 'Ø','Ù','Ú','Û','Ü','Ý','Þ','ß', 'à','á','â','ã','ä','å','æ','ç', 'è','é','ê','ë','ì','í','î','ï', 'ð','ñ','ò','ó','ô','õ','ö','÷', 'ø','ù','ú','û','ü','ý','þ','ÿ'); return str_replace($search,$replace,$data); } /* * Ajax callbacks */ add_action('wp_ajax_fgallery_save_album_image', 'fgallery_save_album_image'); add_action('wp_ajax_fgallery_sort_album_images', 'fgallery_sort_album_images'); add_action('wp_ajax_fgallery_remove_album_image', 'fgallery_remove_album_image'); add_action('wp_ajax_fgallery_set_album_cover', 'fgallery_set_album_cover'); add_action('wp_ajax_fgallery_delete_image', 'fgallery_delete_image_ajax'); add_action('wp_ajax_fgallery_folder_addimage', 'fgallery_folder_addimage'); add_action('wp_ajax_fgallery_delete_gallery', 'fgallery_delete_gallery'); add_action('wp_ajax_fgallery_sort_galleries', 'fgallery_sort_galleries'); add_action('wp_ajax_fgallery_rotate_image', 'fgallery_rotate_image'); function fgallery_rotate_image(){ if (isset($_POST['id']) && is_numeric($_POST['id'])) { $id = $_POST['id']; if (isset($_POST['dir']) && is_numeric($_POST['dir'])) { $dir = $_POST['dir']; } if ($dir){ fgallery_rotate_by_id($id, 'CW'); die('1'); } else { fgallery_rotate_by_id($id, 'CC'); die('1'); } } die(); } function fgallery_save_album_image() { fgallery_edit_album_image($_POST); die(); // this is required to return a proper result } function fgallery_sort_album_images(){ global $wpdb; if (isset($_POST['img_id']) && isset($_POST['gall_id']) && is_numeric($_POST['img_id']) && is_numeric($_POST['gall_id'])) { $id = $_POST['img_id']; $gall_id = $_POST['gall_id']; $order = $_POST['order']; $wpdb->update(IMAGES_TO_ALBUMS_TABLE, array('img_order' => $order), array('img_id' => $id, 'gall_id' => $gall_id)); } else { die('0'); } die(); } function fgallery_remove_album_image(){ global $wpdb; if (isset($_POST['img_id']) && isset($_POST['gall_id']) && is_numeric($_POST['img_id']) && is_numeric($_POST['gall_id'])) { $id = $_POST['img_id']; $gall_id = $_POST['gall_id']; $wpdb->query("UPDATE ".IMAGES_TO_ALBUMS_TABLE." SET `gall_folder` = 0 WHERE `gall_folder` =".$id); $wpdb->query("DELETE FROM ". IMAGES_TO_ALBUMS_TABLE. " WHERE img_id =".$id." AND gall_id = ".$gall_id); } die(); } function fgallery_set_album_cover(){ global $wpdb; if (isset($_POST['img_id']) && isset($_POST['gall_id']) && is_numeric($_POST['img_id']) && is_numeric($_POST['gall_id'])) { $id = $_POST['img_id']; $gall_id = $_POST['gall_id']; $wpdb->update(ALBUMS_TABLE, array('gall_cover'=>$id), array('gall_id' => $gall_id)); } die('1'); } function fgallery_delete_image_ajax() { if (isset($_POST['id']) && is_numeric($_POST['id'])) { $id = $_POST['id']; fgallery_delete_image($id); } die('1'); } function fgallery_folder_addimage(){ global $wpdb; if (!empty($_POST)) { $wpdb->update(IMAGES_TABLE, array('img_parent' => $_POST['folder_id']), array('img_id' => $_POST['img_id'])); $folder = fgallery_get_image($_POST['folder_id']); echo fgallery_get_folder_attributes($folder); } else { die('Not saved'); } die(); } function fgallery_delete_gallery(){ if (isset($_POST['id']) && is_numeric($_POST['id'])) { $id = $_POST['id']; fgallery_delete_album($id); } die(); } function fgallery_sort_galleries(){ global $wpdb; if (isset($_POST['id']) && is_numeric($_POST['id']) && isset($_POST['order']) && is_numeric($_POST['order'])) { $id = $_POST['id']; $order = $_POST['order']; $wpdb->update(ALBUMS_TABLE, array('gall_order' => $order), array('gall_id' => $id)); } die(); } /* * Starting URLs() * */ function fgallery_images_url() { return admin_url('admin.php?page=fgallery_images'); } function fgallery_get_upload_url() { return admin_url('admin.php?page=fgallery_upload'); } function fgallery_createalbum_url() { return admin_url('admin.php?page=fgallery_add'); } function fgallery_get_addimages_url($id, $folder_id = 0) { return FGALLERY_PATH.'/addimage.php?id='.$id.'&fid='.$folder_id.'TB_iframe=1'; } function fgallery_get_addimages_url_clean($id) { return FGALLERY_PATH.'/addimage.php?id='.$id; } function fgallery_get_album_images_url($id) { return admin_url('admin.php?page=fgallery&action=images&id='.$id); } function fgallery_create_folder_url($type,$id) { return FGALLERY_PATH.'/folder.php?&action=create&type='.$type.'&gall_id='.$id.'&TB_iframe=1'; } function fgallery_get_save_settings_url($id, $clean = false) { if ($clean) { return FGALLERY_PATH.'/templates.php?gall_id='.$id.'&action=save'; } else { return FGALLERY_PATH.'/templates.php?gall_id='.$id.'&action=save&TB_iframe=1'; } } function fgallery_get_export_settings_url($id) { return FGALLERY_PATH.'/config.php?gall_id='.$id.'&view=1'; } function fgallery_get_load_settings_url($id, $clean = false) { if ($clean) { return FGALLERY_PATH.'/templates.php?gall_id='.$id.'&action=load'; } else { return FGALLERY_PATH.'/templates.php?gall_id='.$id.'&action=load&TB_iframe=1'; } } function fgallery_get_template_delete_url($id, $templ_id) { return FGALLERY_PATH.'/templates.php?gall_id='.$id.'&templ_id='.$templ_id.'&action=delete'; } function fgallery_get_edit_url($id) { return admin_url('admin.php?page=fgallery&action=edit&id='.$id); } function fgallery_get_edit_url_clean($id) { return admin_url('admin.php?page=fgallery&action=edit&id='.$id); } function fgallery_get_image_edit_url($id) { return admin_url('admin.php?page=fgallery_images&action=edit&id='.$id); } function fgallery_get_rotate_image_url($id,$direction) { return admin_url('admin.php?page=fgallery_images&action=rotate&dir='.$direction.'&id='.$id); } function fgallery_get_watermark_image_url($id) { return admin_url('admin.php?page=fgallery_images&action=watermark&id='.$id); } function fgallery_get_folder_url($id) { return admin_url('admin.php?page=fgallery_images&folder='.$id); } function fgallery_upload_uploadify_get_url() { return FGALLERY_PATH.'/upload.php?action=uploadify'; } function fgallery_upload_zip_get_url() { return FGALLERY_PATH.'/upload.php?action=unzip'; } function fgallery_upload_ftp_get_url() { return FGALLERY_PATH.'/upload.php?action=ftp'; } function fgallery_upload_url_get_url() { return FGALLERY_PATH.'/upload.php?action=upload_url'; } function fgallery_upload_media_get_url() { return FGALLERY_PATH.'/upload.php?action=media'; } function fgallery_upload_facebook_get_url() { return FGALLERY_PATH.'/upload.php?action=facebook'; } function fgallery_upload_nextgen_get_url() { return FGALLERY_PATH.'/upload.php?action=nextgen'; } function fgallery_upload_scandir_get_url() { return FGALLERY_PATH.'/upload.php?action=scandir'; } function fgallery_get_massedit_url() { return FGALLERY_PATH.'/massedit.php'; } function fgallery_get_add_album_url(){ return FGALLERY_PATH.'/insert_gallery.php?TB_iframe=1'; } function fgallery_get_insert_button_url(){ return FGALLERY_PATH.'/images/icon_gallery.gif'; } function fgallery_get_pref_url() { return admin_url('admin.php?page=fgallery&action=pref'); } function fgallery_view_gallery_url($id, $width, $height, $bgcolor) { $height = $height+30; return FGALLERY_PATH.'/view.php?gall_id='.$id.'&width='.$width.'&height='.$height.'&bg='.$bgcolor.'&TB_iframe=1'; } /* * Filters * */ add_filter('screen_settings', 'fgallery_screen_settings', 10, 2); add_filter('contextual_help', 'fgallery_plugin_help', 10, 3); add_filter('media_buttons_context','fgallery_add_button',9); add_shortcode( 'fgallery', 'fgallery_shortcode_handler' ); function fgallery_plugin_help($contextual_help, $screen_id, $screen) { if ($screen_id == 'toplevel_page_fgallery' || $screen_id == '1-flash-gallery_page_fgallery_add' || $screen_id == '1-flash-gallery_page_fgallery_add' || $screen_id == '1-flash-gallery_page_fgallery_images' || $screen_id == '1-flash-gallery_page_fgallery_upload') { $contextual_help = '

'.__('FAQ').'

'; } return $contextual_help; } // filter for setting the number of elements on the screen function fgallery_screen_options($screen) { if ( is_string($screen) ) $screen = convert_to_screen($screen); $option = str_replace( '-', '_', "{$screen->id}_per_page" ); $per_page = (int) get_option( $option , 25); if ( $screen->id == '1-flash-gallery_page_fgallery_images') { $per_page_label = _x( 'Images', 'images per page (screen options)' ); } else { $per_page_label = _x( 'Galleries', 'galleries per page (screen options)' ); } $return = "
\n"; if ( !empty($per_page_label) ) $return .= " \n"; $return .= ""; $return .= ""; $return .= "
\n"; return $return; } function fgallery_screen_settings($current, $screen){ if ( $screen->id == '1-flash-gallery_page_fgallery_images' && !isset($_GET['action'])){ $current = '
'._x('Show on screen', 'Screen Options').'
'; $current .= fgallery_screen_options($screen); $current .= '
'. wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', true ).'
'; } elseif ($screen->id == 'toplevel_page_fgallery' && !isset($_GET['action'])){ $current = '
'._x('Show on screen', 'Screen Options').'
'; $current .= fgallery_screen_options($screen); $current .= '
'. wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', true ).'
'; } return $current; } function plugin_is_active($plugin_path) { $return_var = in_array( $plugin_path, apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ); return $return_var; } function fgallery_resemple($fullpath) { if (FGALLERY_PHP4_MODE){ $thumb = new Thumbnail($fullpath, 0); } else { $thumb = PhpThumbFactory::create($fullpath, array(), false, 0); } $thumb->resize(1200, 1200); $thumb->save($fullpath); } function fgallery_watermark($fullpath) { $wm_file = get_option('1_flash_gallery_watermark_path',''); if ($wm_file == '') return false; $wm_place = get_option('1_flash_gallery_watermark_place','C'); if (FGALLERY_PHP4_MODE){ $thumb = new Thumbnail($fullpath, 0); } else { $thumb = PhpThumbFactory::create($fullpath, array(), false, 0); } return $thumb->watermarkImageGD($fullpath,$fullpath,$wm_file,$wm_place); } function fgallery_watermark_by_id($id) { $path = $_SERVER['DOCUMENT_ROOT']. EXTRA_DIR; $image = fgallery_get_image($id); $img_path = $path.$image['img_path']; fgallery_watermark($img_path); } function fgallery_rotate_by_id($id, $direction) { $path = $_SERVER['DOCUMENT_ROOT']. EXTRA_DIR; $image = fgallery_get_image($id); $img_path = $path.$image['img_path']; if (FGALLERY_PHP4_MODE){ $thumb = new Thumbnail($img_path, 0); } else { $thumb = PhpThumbFactory::create($img_path, array(), false, 0); } $thumb->rotateImage($direction); $thumb->save($img_path); } function fgallery_search_flash_path($album) { $type = fgallery_get_flash_type($album); if (get_option('1_flash_gallery_'.fgallery_get_flash_type($album)) !='') { if (plugin_is_active('1-flash-gallery-update/update_fgallery.php')) { return WP_PLUGIN_URL .'/1-flash-gallery-update/swf/'.fgallery_get_flash_type($album).'.swf'; } elseif (plugin_is_active('1-flash-gallery-update-'.fgallery_get_flash_type($album).'/update_'.fgallery_get_flash_type($album).'.php')) { return WP_PLUGIN_URL .'/1-flash-gallery-update-'.fgallery_get_flash_type($album).'/swf/'.fgallery_get_flash_type($album).'.swf'; } else { return FGALLERY_PATH.'/swf/'.fgallery_get_flash_type($album).'.swf'; } } else { return FGALLERY_PATH.'/swf/'.fgallery_get_flash_type($album).'.swf'; } } // filter for replacing gallery shortcode with flash movie itself function fgallery_shortcode_handler($atts, $content = null){ // set default params if not present extract(shortcode_atts( array( 'id' => 0, 'w' => 450, 'h' => 385, 'bg' => 'ffffff', 't' => 0, 'align' => '', 'thumb' => '', 'title' => '', 'margin' => '0px', ), $atts )); if ($t < 0 || $t > 2) { $t = 0; } // check if the gallery exist if ($id > 0) { $album = fgallery_get_album($id); if (empty($album)) { return '[fgallery 404 Not found]'; } } else { return '[fgallery 404 Not found]'; } // different output for different insert type switch ($t) { case '0' : $rand = rand(0, 150); $path = fgallery_search_flash_path($album); if (isset($align)) { switch ($align) { case 'left' : case 'right' : $align_text = 'float:'.$align; break; case 'center' : $margin = $margin.' auto'; default: $align_text = ''; break; } } $gallery_snippet = '
'.fgallery_get_album_cover($album, $w).'
You need to upgrade your Flash Player
'; if (get_option('1_flash_gallery_'.fgallery_get_flash_type($album)) =='') { $gallery_snippet .= '
'; } $gallery_snippet .= '
'; break; case '1' : if ($title == '') { $insert_text = $album['gall_name']; } else { $insert_text = $title; } $gallery_snippet = ''.$insert_text.'

'.fgallery_get_album_attributes($album, false).'

'; break; case '2' : $gallery_snippet = ''.fgallery_get_album_cover($album, $thumb).'

'.$album['gall_name'].'

'.fgallery_get_album_attributes($album, false).'

'; break; } return $gallery_snippet; } // filter to add the button (for inserting the gallery into post) to post edit page function fgallery_add_button($buttons) { $fgallery_button = " ".__("; $buttons .= $fgallery_button; return $buttons; } class FgalleryWidget extends WP_Widget { /** constructor */ function FgalleryWidget() { parent::WP_Widget(false, $name = '1 Flash Gallery Widget', array('description'=>__('Use this widget to place any gallery from 1 Flash Gallery plugin anywhere on your page'))); } /** @see WP_Widget::widget */ function widget($args, $instance) { extract( $args ); $title = apply_filters('widget_title', $instance['title']); $gall_id = esc_attr($instance['gall_id']); $type = esc_attr($instance['type']); $album = fgallery_get_album($gall_id); ?>

>
>
>