Changeset 3090225
- Timestamp:
- 05/21/2024 01:37:12 PM (19 months ago)
- Location:
- access-fotoweb-media/trunk
- Files:
-
- 8 edited
-
callback.php (modified) (1 diff)
-
fotoware-auth.php (modified) (1 diff)
-
fotoware-main.php (modified) (3 diffs)
-
fotoware-media-access.php (modified) (4 diffs)
-
fotoware-options.php (modified) (3 diffs)
-
fotoware-selection.php (modified) (4 diffs)
-
index.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
access-fotoweb-media/trunk/callback.php
r2257057 r3090225 1 1 <?php 2 if(!isset($_SESSION)){session_start();} 3 if(isset($_SESSION['fw_url'])){ 4 $_SESSION['fw_url'] = filter_var($_SESSION['fw_url'], FILTER_SANITIZE_URL); 5 $fw_url = $_SESSION['fw_url']; 2 if ( ! isset( $_SESSION ) ) { 3 session_start(); 6 4 } 7 if (isset($_SESSION['client_id'])){8 $_SESSION[' client_id'] = filter_var($_SESSION['client_id'], FILTER_SANITIZE_STRING);9 $client_id = $_SESSION['client_id'];5 if ( isset( $_SESSION['fw_url'] ) ) { 6 $_SESSION['fw_url'] = filter_var( $_SESSION['fw_url'], FILTER_SANITIZE_URL ); 7 $fw_url = $_SESSION['fw_url']; 10 8 } 11 if (isset($_SESSION['client_secret'])){12 $_SESSION['client_id'] = filter_var( $_SESSION['client_secret'], FILTER_SANITIZE_STRING);13 $client_secret = $_SESSION['client_secret'];9 if ( isset( $_SESSION['client_id'] ) ) { 10 $_SESSION['client_id'] = filter_var( $_SESSION['client_id'], FILTER_SANITIZE_SPECIAL_CHARS ); 11 $client_id = $_SESSION['client_id']; 14 12 } 15 if (isset($_SESSION['redirect_uri'])){16 $_SESSION[' redirect_uri'] = filter_var($_SESSION['redirect_uri'], FILTER_SANITIZE_URL);17 $redirect_uri = $_SESSION['redirect_uri'];13 if ( isset( $_SESSION['client_secret'] ) ) { 14 $_SESSION['client_secret'] = filter_var( $_SESSION['client_secret'], FILTER_SANITIZE_SPECIAL_CHARS ); 15 $client_secret = $_SESSION['client_secret']; 18 16 } 19 if (isset($_GET['code'])){20 $_ GET['code'] = filter_var($_GET['code'], FILTER_SANITIZE_STRING);21 $authorization_code = $_GET['code'];17 if ( isset( $_SESSION['redirect_uri'] ) ) { 18 $_SESSION['redirect_uri'] = filter_var( $_SESSION['redirect_uri'], FILTER_SANITIZE_URL ); 19 $redirect_uri = $_SESSION['redirect_uri']; 22 20 } 23 if (isset($_SESSION['state'])){24 $_ SESSION['state'] = filter_var($_SESSION['state'], FILTER_SANITIZE_URL);25 $session_state = $_SESSION['state'];21 if ( isset( $_GET['code'] ) ) { 22 $_GET['code'] = filter_var( $_GET['code'], FILTER_SANITIZE_SPECIAL_CHARS ); 23 $authorization_code = $_GET['code']; 26 24 } 27 if (isset($_GET['state'])){28 $_ GET['state'] = filter_var($_GET['state'], FILTER_SANITIZE_STRING);29 $state = $_GET['state'];25 if ( isset( $_SESSION['state'] ) ) { 26 $_SESSION['state'] = filter_var( $_SESSION['state'], FILTER_SANITIZE_URL ); 27 $session_state = $_SESSION['state']; 30 28 } 31 if(!isset($_SESSION['access_token'])){ 32 fw_media_get_access_token(); 29 if ( isset( $_GET['state'] ) ) { 30 $_GET['state'] = filter_var( $_GET['state'], FILTER_SANITIZE_SPECIAL_CHARS ); 31 $state = $_GET['state']; 32 } 33 if ( ! isset( $_SESSION['access_token'] ) ) { 34 fw_media_get_access_token(); 33 35 } 34 36 35 function fw_media_get_access_token(){ 36 global $client_id; 37 global $client_secret; 38 global $redirect_uri; 39 global $authorization_code; 40 global $fw_url; 41 global $session_state; 42 global $state; 43 44 if(!$authorization_code or ($state == null)){ 45 return; 46 } 47 48 $url = "$fw_url/fotoweb/oauth2/token"; 49 50 $data = array( 51 'grant_type' => 'authorization_code', 52 'client_id' => $client_id, 53 'client_secret' => $client_secret, 54 'code' => $authorization_code, 55 'redirect_uri' => $redirect_uri 56 ); 57 $options = array( 58 'http' => array( 59 'header' => "Content-type: application/x-www-form-urlencoded\r\n", 60 'method' => 'POST', 61 'content' => http_build_query($data) 62 ) 63 ); 64 $context = stream_context_create($options); 65 $result = file_get_contents($url, false, $context); 37 function fw_media_get_access_token() { 38 global $client_id; 39 global $client_secret; 40 global $redirect_uri; 41 global $authorization_code; 42 global $fw_url; 43 global $session_state; 44 global $state; 66 45 67 $access_token = json_decode($result)->access_token; 68 $_SESSION['access_token'] = $access_token; 46 if ( ! $authorization_code || ( null === $state ) ) { 47 return; 48 } 69 49 70 $refresh_token = json_decode($result)->refresh_token; 71 $_SESSION['refresh_token'] = $refresh_token; 50 $url = "$fw_url/fotoweb/oauth2/token"; 72 51 73 if ($_SESSION['access_token']){ 74 echo 'You have now been successfully logged in. Please close this tab and return to your WordPress site.'; 75 ?> 76 <script> window.localStorage.setItem('isLoggedIn', 'true');</script> 77 <?php 78 } 52 $data = array( 53 'grant_type' => 'authorization_code', 54 'client_id' => $client_id, 55 'client_secret' => $client_secret, 56 'code' => $authorization_code, 57 'redirect_uri' => $redirect_uri, 58 ); 59 $options = array( 60 'http' => array( 61 'header' => "Content-type: application/x-www-form-urlencoded\r\n", 62 'method' => 'POST', 63 'content' => http_build_query( $data ), 64 ), 65 ); 66 $context = stream_context_create( $options ); 67 $result = file_get_contents( $url, false, $context ); 68 69 $access_token = json_decode( $result )->access_token; 70 $_SESSION['access_token'] = $access_token; 71 72 $refresh_token = json_decode( $result )->refresh_token; 73 $_SESSION['refresh_token'] = $refresh_token; 74 75 if ( $_SESSION['access_token'] ) { 76 echo 'You have now been successfully logged in. Please close this tab and return to your WordPress site.'; 77 ?> 78 <script> window.localStorage.setItem('isLoggedIn', 'true');</script> 79 <?php 80 } 79 81 } 80 82 ?> -
access-fotoweb-media/trunk/fotoware-auth.php
r2257057 r3090225 1 1 <?php 2 if(!isset($_SESSION)){session_start();} 3 if(isset($_SESSION['fw_url'])){ 4 $_SESSION['fw_url'] = filter_var($_SESSION['fw_url'], FILTER_SANITIZE_URL); 5 $fotoweb_url = $_SESSION['fw_url']; 2 if ( ! isset( $_SESSION ) ) { 3 session_start(); 6 4 } 7 if (isset($_SESSION['access_token'])){8 $_SESSION[' access_token'] = filter_var($_SESSION['access_token'], FILTER_SANITIZE_STRING);9 $access_token = $_SESSION['access_token'];5 if ( isset( $_SESSION['fw_url'] ) ) { 6 $_SESSION['fw_url'] = filter_var( $_SESSION['fw_url'], FILTER_SANITIZE_URL ); 7 $fotoweb_url = $_SESSION['fw_url']; 10 8 } 11 if (isset($_SESSION['client_id'])){12 $_SESSION[' client_id'] = filter_var($_SESSION['client_id'], FILTER_SANITIZE_STRING);13 $client_id = $_SESSION['client_id'];9 if ( isset( $_SESSION['access_token'] ) ) { 10 $_SESSION['access_token'] = filter_var( $_SESSION['access_token'], FILTER_SANITIZE_SPECIAL_CHARS ); 11 $access_token = $_SESSION['access_token']; 14 12 } 15 if (isset($_SESSION['client_secret'])){16 $_SESSION['client_id'] = filter_var( $_SESSION['client_secret'], FILTER_SANITIZE_STRING);17 $client_secret = $_SESSION['client_secret'];13 if ( isset( $_SESSION['client_id'] ) ) { 14 $_SESSION['client_id'] = filter_var( $_SESSION['client_id'], FILTER_SANITIZE_SPECIAL_CHARS ); 15 $client_id = $_SESSION['client_id']; 18 16 } 19 if (isset($_SESSION['redirect_uri'])){20 $_SESSION[' redirect_uri'] = filter_var($_SESSION['redirect_uri'], FILTER_SANITIZE_URL);21 $redirect_uri = $_SESSION['redirect_uri'];17 if ( isset( $_SESSION['client_secret'] ) ) { 18 $_SESSION['client_id'] = filter_var( $_SESSION['client_secret'], FILTER_SANITIZE_SPECIAL_CHARS ); 19 $client_secret = $_SESSION['client_secret']; 22 20 } 23 if (isset($_GET['code'])){24 $_ GET['code'] = filter_var($_GET['code'], FILTER_SANITIZE_STRING);25 $authorization_code = $_GET['code'];21 if ( isset( $_SESSION['redirect_uri'] ) ) { 22 $_SESSION['redirect_uri'] = filter_var( $_SESSION['redirect_uri'], FILTER_SANITIZE_URL ); 23 $redirect_uri = $_SESSION['redirect_uri']; 26 24 } 27 if (isset($_SESSION['state'])){28 $_ SESSION['state'] = filter_var($_SESSION['state'], FILTER_SANITIZE_URL);29 $session_state = $_SESSION['state'];25 if ( isset( $_GET['code'] ) ) { 26 $_GET['code'] = filter_var( $_GET['code'], FILTER_SANITIZE_SPECIAL_CHARS ); 27 $authorization_code = $_GET['code']; 30 28 } 31 if (isset($_GET['state'])){32 $_ GET['state'] = filter_var($_GET['state'], FILTER_SANITIZE_STRING);33 $state = $_GET['state'];29 if ( isset( $_SESSION['state'] ) ) { 30 $_SESSION['state'] = filter_var( $_SESSION['state'], FILTER_SANITIZE_URL ); 31 $session_state = $_SESSION['state']; 34 32 } 35 function fw_media_get_access_token_from_refresh_token(){ 36 $refresh_token = $_SESSION['refresh_token']; 37 global $access_token; 38 global $client_id; 39 global $client_secret; 40 global $fw_url; 33 if ( isset( $_GET['state'] ) ) { 34 $_GET['state'] = filter_var( $_GET['state'], FILTER_SANITIZE_SPECIAL_CHARS ); 35 $state = $_GET['state']; 36 } 37 function fw_media_get_access_token_from_refresh_token() { 38 $refresh_token = $_SESSION['refresh_token']; 39 global $access_token; 40 global $client_id; 41 global $client_secret; 42 global $fw_url; 41 43 42 $url = "$fw_url/fotoweb/oauth2/token";44 $url = "$fw_url/fotoweb/oauth2/token"; 43 45 44 //Refresh the token 45 $data = array( 46 'grant_type' => 'refresh_token', 47 'refresh_token' => $refresh_token, 48 'client_id' => $client_id, 49 'client_secret' => $client_secret, 50 ); 51 52 $options = array( 53 'http' => array( 54 'header' => "Content-type: application/x-www-form-urlencoded\r\n", 55 'method' => 'POST', 56 'content' => http_build_query($data) 57 ) 58 ); 59 $context = stream_context_create($options); 60 $refresh_result = file_get_contents($url, false, $context); 46 // Refresh the token. 47 $data = array( 48 'grant_type' => 'refresh_token', 49 'refresh_token' => $refresh_token, 50 'client_id' => $client_id, 51 'client_secret' => $client_secret, 52 ); 61 53 62 if($refresh_result){ 63 $_SESSION['access_token'] = json_decode($refresh_result)->access_token; 64 $_SESSION['refresh_token'] = json_decode($refresh_result)->refresh_token; 65 } 54 $options = array( 55 'http' => array( 56 'header' => "Content-type: application/x-www-form-urlencoded\r\n", 57 'method' => 'POST', 58 'content' => http_build_query( $data ), 59 ), 60 ); 61 $context = stream_context_create( $options ); 62 $refresh_result = file_get_contents( $url, false, $context ); 66 63 67 return json_decode($refresh_result)->access_token; 64 if ( $refresh_result ) { 65 $_SESSION['access_token'] = json_decode( $refresh_result )->access_token; 66 $_SESSION['refresh_token'] = json_decode( $refresh_result )->refresh_token; 67 } 68 69 return json_decode( $refresh_result )->access_token; 68 70 } -
access-fotoweb-media/trunk/fotoware-main.php
r2257057 r3090225 1 <?php 2 // Exit if accessed directly 3 if ( !defined( 'ABSPATH' ) ) exit; 4 if( !class_exists('FotoWeb')){ 1 <?php 2 // Exit if accessed directly. 3 if ( ! defined( 'ABSPATH' ) ) { 4 exit; 5 } 6 if ( ! class_exists( 'FotoWeb' ) ) { 5 7 6 function fw_media_generateState($length = 10) {7 $characters= '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';8 $charactersLength = strlen($characters);9 $state= '';10 for ($i = 0; $i < $length; $i++) {11 $state .= $characters[rand(0, $charactersLength - 1)];12 }13 return $state;14 }8 function fw_media_generateState( $length = 10 ) { 9 $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; 10 $charactersLength = strlen( $characters ); 11 $state = ''; 12 for ( $i = 0; $i < $length; $i++ ) { 13 $state .= $characters[ rand( 0, $charactersLength - 1 ) ]; 14 } 15 return $state; 16 } 15 17 16 $_SESSION['state'] = fw_media_generateState();18 $_SESSION['state'] = fw_media_generateState(); 17 19 18 class FotoWeb { 19 20 public $plugin; 21 public $fw_options; 22 public $logged_in; 20 class FotoWeb { 23 21 24 function __construct () { 25 $this->fw_options = new FotoWeb_Options(); 26 $this->plugin = plugin_basename(__FILE__); 27 28 global $fotoweb_url; 29 $fotoweb_url = $this->fw_options->options['fw_url']; 30 $_SESSION['fw_url'] = $this->fw_options->options['fw_url']; 31 $_SESSION['client_id'] = $this->fw_options->options['client_id']; 32 $_SESSION['client_secret'] = $this->fw_options->options['client_secret']; 33 $_SESSION['redirect_uri'] = FW_MEDIA_AC_URL.'callback.php'; 34 $_SESSION['afterlog_url'] = FW_MEDIA_AC_URL; 35 } 22 public $plugin; 23 public $fw_options; 24 public $logged_in; 36 25 37 function fw_media_register_script(){ 38 add_filter("plugin_action_links_$this->plugin" , array($this, 'settings_link')); 26 function __construct() { 27 $this->fw_options = new FotoWeb_Options(); 28 $this->plugin = plugin_basename( __FILE__ ); 39 29 40 if($this->fw_options->options['fw_url']) { 41 add_action('media_buttons', array($this,'login_fotoweb_button'), 15); 42 } 43 } 44 45 public function settings_link( $links){ 46 $settings_link = '<a href=admin.php?page=fotoweb_plugin>Settings</a>'; 47 array_push($links, $settings_link); 48 return $links; 49 } 30 global $fotoweb_url; 31 $fotoweb_url = $this->fw_options->options['fw_url']; 32 $_SESSION['fw_url'] = $this->fw_options->options['fw_url']; 33 $_SESSION['client_id'] = $this->fw_options->options['client_id']; 34 $_SESSION['client_secret'] = $this->fw_options->options['client_secret']; 35 $_SESSION['redirect_uri'] = FW_MEDIA_AC_URL . 'callback.php'; 36 $_SESSION['afterlog_url'] = FW_MEDIA_AC_URL; 37 } 50 38 51 public function login_fotoweb_button(){ 52 echo '<a onclick="handleOpenWindow 39 function fw_media_register_script() { 40 add_filter( "plugin_action_links_$this->plugin", array( $this, 'settings_link' ) ); 41 42 if ( $this->fw_options->options['fw_url'] ) { 43 add_action( 'media_buttons', array( $this, 'login_fotoweb_button' ), 15 ); 44 } 45 } 46 47 public function settings_link( $links ) { 48 $settings_link = '<a href=admin.php?page=fotoweb_plugin>Settings</a>'; 49 array_push( $links, $settings_link ); 50 return $links; 51 } 52 53 public function login_fotoweb_button() { 54 echo '<a onclick="handleOpenWindow 53 55 54 ()" target="_blank" id="fotoweb_button" class="button"><img src="' . FW_MEDIA_AC_IMG_URL.'/fotoweb_icon.png" style="vertical-align:sub; padding-right: 4px; padding-left: 0px;" height="16px" width="16px"/>Add Media from FotoWare</a>';55 ?>56 ()" target="_blank" id="fotoweb_button" class="button"><img src="' . FW_MEDIA_AC_IMG_URL . '/fotoweb_icon.png" style="vertical-align:sub; padding-right: 4px; padding-left: 0px;" height="16px" width="16px"/>Add Media from FotoWare</a>'; 57 ?> 56 58 <script> 57 const fw_url = '<?php echo $_SESSION['fw_url'];?>';58 const afterlog_url = '<?php echo $_SESSION['afterlog_url'];?>';59 function handleOpenWindow(){60 const access_token = '<?php echo $_SESSION['access_token'] ?>';61 const client_id = '<?php echo $_SESSION['client_id'] ?>';62 const redirect_uri = '<?php echo $_SESSION['redirect_uri'] ?>';63 const state = '<?php echo $_SESSION['state'] ?>';59 const fw_url = '<?php echo $_SESSION['fw_url']; ?>'; 60 const afterlog_url = '<?php echo $_SESSION['afterlog_url']; ?>'; 61 function handleOpenWindow(){ 62 const access_token = '<?php echo $_SESSION['access_token']; ?>'; 63 const client_id = '<?php echo $_SESSION['client_id']; ?>'; 64 const redirect_uri = '<?php echo $_SESSION['redirect_uri']; ?>'; 65 const state = '<?php echo $_SESSION['state']; ?>'; 64 66 65 67 const isLoggedIn = window.localStorage.getItem('isLoggedIn'); 66 68 if(isLoggedIn === 'true'){ 67 const token = '<?php echo fw_media_get_access_token_from_refresh_token() ?>';69 const token = '<?php echo fw_media_get_access_token_from_refresh_token(); ?>'; 68 70 showcontactusform(); 69 71 }else{ … … 72 74 } 73 75 function showcontactusform() { 74 //set the width and height of the75 //pop up window in pixels76 var width = 655;77 var height = 555;76 //set the width and height of the 77 //pop up window in pixels 78 var width = 655; 79 var height = 555; 78 80 79 //Get the TOP coordinate by80 //getting the 50% of the screen height minus81 //the 50% of the pop up window height82 var top = parseInt((screen.availHeight/2) - (height/2));81 //Get the TOP coordinate by 82 //getting the 50% of the screen height minus 83 //the 50% of the pop up window height 84 var top = parseInt((screen.availHeight/2) - (height/2)); 83 85 84 //Get the LEFT coordinate by85 //getting the 50% of the screen width minus86 //the 50% of the pop up window width87 var left = parseInt((screen.availWidth/2) - (width/2));86 //Get the LEFT coordinate by 87 //getting the 50% of the screen width minus 88 //the 50% of the pop up window width 89 var left = parseInt((screen.availWidth/2) - (width/2)); 88 90 89 //Open the window with the90 //file to show on the pop up window91 //title of the pop up92 //and other parameter where we will use the93 //values of the variables above94 window.open(afterlog_url +"fotoware-selection.php",91 //Open the window with the 92 //file to show on the pop up window 93 //title of the pop up 94 //and other parameter where we will use the 95 //values of the variables above 96 window.open(afterlog_url +"fotoware-selection.php", 95 97 "", 96 "menubar=no,resizable=no,width=655,height=555,scrollbars=0,left=" 97 + left + ",top=" + top + ",screenX=" + left + ",screenY=" + top); 98 }98 "menubar=no,resizable=no,width=655,height=555,scrollbars=0,left=" 99 + left + ",top=" + top + ",screenX=" + left + ",screenY=" + top); 100 } 99 101 100 102 const popup = () => { … … 107 109 wp.media.editor.insert(exported_url); 108 110 window.localStorage.removeItem('exported_url'); 109 } 111 } 110 112 }, false); 111 113 112 window.addEventListener('storage', function(e) { 113 if(e.newValue === 'true'){114 popup();115 }114 window.addEventListener('storage', function(e) { 115 if(e.newValue === 'true'){ 116 popup(); 117 } 116 118 });</script> 117 <?php } 119 <?php } 118 120 119 public function fw_media_registrer_my_scripts(){120 wp_localize_script( 'fw-javascript', 'fwParams', $this->fw_options->options );121 }122 }123 $fotoweb = new FotoWeb();124 $fotoweb ->fw_media_register_script();121 public function fw_media_registrer_my_scripts() { 122 wp_localize_script( 'fw-javascript', 'fwParams', $this->fw_options->options ); 123 } 124 } 125 $fotoweb = new FotoWeb(); 126 $fotoweb->fw_media_register_script(); 125 127 } ?> -
access-fotoweb-media/trunk/fotoware-media-access.php
r2610724 r3090225 1 1 <?php 2 2 /** 3 * Plugin Name: FotoWare Word press Lite3 * Plugin Name: FotoWare WordPress Lite 4 4 * Plugin URI: https://viitorcloud.com/ 5 5 * Description: The Plugin's WordPress editor button connector for Fotoware allows to include images directly from the Fotoweb DAM, into WordPress. 6 * Version: 1.0.06 * Version:2.0.0 7 7 * Author: VIITORCLOUD 8 8 * Author URI: https://viitorcloud.com/ 9 9 * License: GPL2 10 */ 10 * 11 * @package Fotoware_wordpress_plugin 12 */ 11 13 12 13 // Exit if accessed directly 14 if ( !defined( 'ABSPATH' ) ) exit; 14 // Exit if accessed directly. 15 if ( ! defined( 'ABSPATH' ) ) { 16 exit; 17 } 15 18 16 19 global $wpdb; 17 20 18 if ( !defined( 'FW_MEDIA_AC_DIR' ) ) {19 define( 'FW_MEDIA_AC_DIR', dirname( __FILE__ ) ); // plugin dir21 if ( ! defined( 'FW_MEDIA_AC_DIR' ) ) { 22 define( 'FW_MEDIA_AC_DIR', __DIR__ ); // plugin dir. 20 23 } 21 24 22 if ( !defined( 'FW_MEDIA_AC_URL' ) ) {23 define( 'FW_MEDIA_AC_URL', plugin_dir_url( __FILE__ ) ); // plugin url 25 if ( ! defined( 'FW_MEDIA_AC_URL' ) ) { 26 define( 'FW_MEDIA_AC_URL', plugin_dir_url( __FILE__ ) ); // plugin url. 24 27 } 25 if ( !defined( 'FW_MEDIA_AC_IMG_URL' ) ) {26 define( 'FW_MEDIA_AC_IMG_URL', FW_MEDIA_AC_URL . '/images' ); // plugin images url 28 if ( ! defined( 'FW_MEDIA_AC_IMG_URL' ) ) { 29 define( 'FW_MEDIA_AC_IMG_URL', FW_MEDIA_AC_URL . '/images' ); // plugin images url. 27 30 } 28 if ( !defined( 'FW_MEDIA_AC_TEXT_DOMAIN' ) ) {29 define( 'FW_MEDIA_AC_TEXT_DOMAIN', 'fotoware_media_access' ); // text domain for doing language translation 31 if ( ! defined( 'FW_MEDIA_AC_TEXT_DOMAIN' ) ) { 32 define( 'FW_MEDIA_AC_TEXT_DOMAIN', 'fotoware_media_access' ); // text domain for doing language translation. 30 33 } 31 34 32 35 /** 33 36 * Load Text Domain 34 * 37 * 35 38 * This gets the plugin ready for translation. 36 * 39 * 37 40 * @package FotoWare Media Access 38 * @since 1.0.041 * @since 2.0.0 39 42 */ 40 43 load_plugin_textdomain( 'fotoware_media_access', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); 41 44 /** 42 45 * Activation hook 43 * 46 * 44 47 * Register plugin activation hook. 45 * 48 * 46 49 * @package FotoWare Media Access 47 *@since 1.0.050 *@since 2.0.0 48 51 */ 49 52 register_activation_hook( __FILE__, 'fotoware_media_access_install' ); … … 53 56 * 54 57 * Register plugin deactivation hook. 55 * 58 * 56 59 * @package FotoWare Media Access 57 * @since 1.0.060 * @since 2.0.0 58 61 */ 59 62 register_deactivation_hook( __FILE__, 'fotoware_media_access_uninstall' ); 60 63 61 64 /** 62 * Plugin Setup Activation hook call back 65 * Plugin Setup Activation hook call back 63 66 * 64 * Initial setup of the plugin setting default options 67 * Initial setup of the plugin setting default options 65 68 * and database tables creations. 66 * 69 * 67 70 * @package FotoWare Media Access 68 * @since 1.0.071 * @since 2.0.0 69 72 */ 70 73 function fotoware_media_access_install() { 71 72 global $wpdb; 73 74 75 global $wpdb; 74 76 } 75 77 /** … … 80 82 * 81 83 * @package FotoWare Media Access 82 * @since 1.0.084 * @since 2.0.0 83 85 */ 84 86 function fotoware_media_access_uninstall() { 85 87 86 88 global $wpdb; 87 88 89 } 89 90 … … 94 95 * 95 96 * @package FotoWare Media Access 96 * @since 1.0.097 * @since 2.0.0 97 98 */ 98 99 99 // require_once options file100 require_once ( FW_MEDIA_AC_DIR . '/fotoware-options.php');100 // require_once options file. 101 require_once FW_MEDIA_AC_DIR . '/fotoware-options.php'; 101 102 102 // require_once callback file103 require_once ( FW_MEDIA_AC_DIR . '/callback.php');103 // require_once callback file. 104 require_once FW_MEDIA_AC_DIR . '/callback.php'; 104 105 105 // require_once auth file106 require_once ( FW_MEDIA_AC_DIR . '/fotoware-auth.php');106 // require_once auth file. 107 require_once FW_MEDIA_AC_DIR . '/fotoware-auth.php'; 107 108 108 // require_once options file109 require_once( FW_MEDIA_AC_DIR . '/fotoware-main.php');109 // require_once options file. 110 require_once FW_MEDIA_AC_DIR . '/fotoware-main.php'; -
access-fotoweb-media/trunk/fotoware-options.php
r2289189 r3090225 1 <?php 2 // Exit if accessed directly 3 if ( !defined( 'ABSPATH' ) ) exit; 1 <?php 2 // Exit if accessed directly. 3 if ( ! defined( 'ABSPATH' ) ) { 4 exit; 5 } 4 6 class FotoWeb_Options { 5 7 6 8 public $options; 7 public $options_name = 'fotoweb_plugin_options';8 public $state;9 public $options_name = 'fotoweb_plugin_options'; 10 public $state; 9 11 10 public function __construct () {11 $this->fw_media_setup_globals();12 $this->setup_hooks();13 add_action( 'admin_init', array($this, 'register_settings_and_fields'));14 add_action('admin_menu', array($this, 'add_menu_page'));15 $this->options = get_option( $this->options_name );12 public function __construct() { 13 $this->fw_media_setup_globals(); 14 $this->setup_hooks(); 15 add_action( 'admin_init', array( $this, 'register_settings_and_fields' ) ); 16 add_action( 'admin_menu', array( $this, 'add_menu_page' ) ); 17 $this->options = get_option( $this->options_name ); 16 18 } 17 19 18 public function fw_media_generateState($length = 10) { 19 $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; 20 $charactersLength = strlen($characters); 21 $state = ''; 22 for ($i = 0; $i < $length; $i++) { 23 $state .= $characters[rand(0, $charactersLength - 1)]; 24 } 25 return $state; 26 } 27 28 public function add_menu_page() { 29 add_menu_page('FotoWare Plugin', 'FotoWare Settings', 'manage_options', 'fotoweb_plugin', array($this, 'fw_media_display_options_page'), ' 30 dashicons-admin-generic', 110); 20 public function fw_media_generateState( $length = 10 ) { 21 $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; 22 $charactersLength = strlen( $characters ); 23 $state = ''; 24 for ( $i = 0; $i < $length; $i++ ) { 25 $state .= $characters[ rand( 0, $charactersLength - 1 ) ]; 26 } 27 return $state; 31 28 } 32 29 33 public function fw_media_display_options_page () { 30 public function add_menu_page() { 31 add_menu_page( 32 'FotoWare Plugin', 33 'FotoWare Settings', 34 'manage_options', 35 'fotoweb_plugin', 36 array( $this, 'fw_media_display_options_page' ), 37 ' 38 dashicons-admin-generic', 39 110 40 ); 41 } 42 43 public function fw_media_display_options_page() { 34 44 ?> 35 45 <div class="wrap fotoware-setting"> 36 46 <div class="fotoware-setting-form"> 37 47 <form method="post" action="options.php"> 38 <?php 39 settings_fields( $this->options_name);40 do_settings_sections( __FILE__);48 <?php 49 settings_fields( $this->options_name ); 50 do_settings_sections( __FILE__ ); 41 51 submit_button(); 42 52 ?> … … 46 56 <?php 47 57 } 48 49 public function register_settings_and_fields () {50 register_setting($this->options_name, $this->options_name, array($this, 'fotoweb_validate_settings'));51 add_settings_section( 'fw_main_section', 'FotoWare Settings', array($this, 'fw_main_section_cb'), __FILE__ );52 add_settings_field( 'fw_url', 'FotoWare URL', array($this, 'fw_url_setting'), __FILE__, 'fw_main_section');53 add_settings_field( 'client_id', 'Client ID', array($this, 'client_id_setting'), __FILE__, 'fw_main_section');54 add_settings_field( 'client_secret', 'Client Secret', array($this, 'client_secret_setting'), __FILE__, 'fw_main_section');55 add_settings_field( 'redirect_uri', 'Redirect URI', array($this, 'redirect_uri_setting'), __FILE__, 'fw_main_section');56 add_settings_field( 'logout', '', array($this, 'fotoweb_logout_settings'), __FILE__, 'fw_main_section');57 58 59 public function register_settings_and_fields() { 60 register_setting( $this->options_name, $this->options_name, array( $this, 'fotoweb_validate_settings' ) ); 61 add_settings_section( 'fw_main_section', 'FotoWare Settings', array( $this, 'fw_main_section_cb' ), __FILE__ ); 62 add_settings_field( 'fw_url', 'FotoWare URL', array( $this, 'fw_url_setting' ), __FILE__, 'fw_main_section' ); 63 add_settings_field( 'client_id', 'Client ID', array( $this, 'client_id_setting' ), __FILE__, 'fw_main_section' ); 64 add_settings_field( 'client_secret', 'Client Secret', array( $this, 'client_secret_setting' ), __FILE__, 'fw_main_section' ); 65 add_settings_field( 'redirect_uri', 'Redirect URI', array( $this, 'redirect_uri_setting' ), __FILE__, 'fw_main_section' ); 66 add_settings_field( 'logout', '', array( $this, 'fotoweb_logout_settings' ), __FILE__, 'fw_main_section' ); 58 67 } 59 68 60 69 61 public function fotoweb_validate_settings ($plugin_options) {70 public function fotoweb_validate_settings( $plugin_options ) { 62 71 return $plugin_options; 63 72 } … … 69 78 * 70 79 */ 71 public function fw_main_section_cb () {72 echo "Add below details and save settings";80 public function fw_main_section_cb() { 81 echo 'Add below details and save settings'; 73 82 } 74 public function fw_url_setting () {83 public function fw_url_setting() { 75 84 echo "<input name='$this->options_name[fw_url]' type='text' value='{$this->options['fw_url']}' />"; 76 85 } 77 public function client_id_setting () {86 public function client_id_setting() { 78 87 echo "<input name='$this->options_name[client_id]' type='text' value='{$this->options['client_id']}' />"; 79 88 } 80 public function client_secret_setting () {89 public function client_secret_setting() { 81 90 echo "<input name='$this->options_name[client_secret]' type='text' value='{$this->options['client_secret']}' />"; 82 91 } 83 public function wordpress_url_setting () {92 public function wordpress_url_setting() { 84 93 echo "<input name='$this->options_name[wordpress_url]' type='text' value='{$this->options['wordpress_url']}' />"; 85 94 } 86 95 87 public function redirect_uri_setting () {96 public function redirect_uri_setting() { 88 97 $fotoware_base_uri = get_site_url(); 89 echo '<div> ' .FW_MEDIA_AC_URL.'callback.php</div>';98 echo '<div> ' . FW_MEDIA_AC_URL . 'callback.php</div>'; 90 99 } 91 public function fotoweb_logout_settings() {92 echo '<a href="' .FW_MEDIA_AC_URL.'fotoware-logout.php" class="button">Log out From FotoWare</a>';100 public function fotoweb_logout_settings() { 101 echo '<a href="' . FW_MEDIA_AC_URL . 'fotoware-logout.php" class="button">Log out From FotoWare</a>'; 93 102 } 94 103 private function fw_media_setup_globals() { 95 // let's define some globals to easily build the url to your scripts 96 $this->version= '1.0.0';97 $this->file= __FILE__;98 99 // url to your plugin dir : site.url/wp-content/wp-fotoweb-api/ 100 $this->plugin_url= plugin_dir_url( $this->file );101 102 // url to your plugin's includes dir : site.url/wp-content/plugins/wp-fotoweb-api/includes/ 103 $this->includes_url = trailingslashit( $this->plugin_url . 'includes' );104 105 // url to your plugin's js dir : site.url/wp-content/plugins/wp-fotoweb-api/includes/js/ 106 $this->plugin_js= trailingslashit( $this->includes_url . 'js' );107 108 // url to your plugin's css dir : site.url/wp-content/plugins/wp-fotoweb-api/includes/css/ 109 $this->plugin_css= trailingslashit( $this->includes_url . 'css' );110 111 $this->component_id = 'wp-fotoweb-api';112 $this->component_slug = 'wp-fotoweb-api';113 }114 115 private function setup_hooks() {116 // As soon as WordPress meets this hook, your cssjs function will be called 117 add_action( 'admin_enqueue_scripts', array( $this, 'fw_media_include' ) ); 118 }119 120 public function fw_media_include() {121 // Your css file is reachable at site.url/wp-content/plugins/buddyplug/includes/css/buddyplug.css 122 wp_enqueue_style( 'fotoware-media', FW_MEDIA_AC_URL . 'css/fotoware-media.css', false, $this->version );123 }104 // let's define some globals to easily build the url to your scripts. 105 $this->version = '1.0.0'; 106 $this->file = __FILE__; 107 108 // url to your plugin dir : site.url/wp-content/wp-fotoweb-api/. 109 $this->plugin_url = plugin_dir_url( $this->file ); 110 111 // url to your plugin's includes dir : site.url/wp-content/plugins/wp-fotoweb-api/includes/. 112 $this->includes_url = trailingslashit( $this->plugin_url . 'includes' ); 113 114 // url to your plugin's js dir : site.url/wp-content/plugins/wp-fotoweb-api/includes/js/. 115 $this->plugin_js = trailingslashit( $this->includes_url . 'js' ); 116 117 // url to your plugin's css dir : site.url/wp-content/plugins/wp-fotoweb-api/includes/css/. 118 $this->plugin_css = trailingslashit( $this->includes_url . 'css' ); 119 120 $this->component_id = 'wp-fotoweb-api'; 121 $this->component_slug = 'wp-fotoweb-api'; 122 } 123 124 private function setup_hooks() { 125 // As soon as WordPress meets this hook, your cssjs function will be called. 126 add_action( 'admin_enqueue_scripts', array( $this, 'fw_media_include' ) ); 127 } 128 129 public function fw_media_include() { 130 // Your css file is reachable at site.url/wp-content/plugins/buddyplug/includes/css/buddyplug.css. 131 wp_enqueue_style( 'fotoware-media', FW_MEDIA_AC_URL . 'css/fotoware-media.css', false, $this->version ); 132 } 124 133 } 125 134 ?> -
access-fotoweb-media/trunk/fotoware-selection.php
r2257057 r3090225 1 1 <?php 2 include_once 'fotoware-auth.php';3 if (isset($_SESSION['fw_url'])){4 $_SESSION['fw_url'] = filter_var( $_SESSION['fw_url'], FILTER_SANITIZE_URL);5 $fotoweb_url= $_SESSION['fw_url'];2 require_once 'fotoware-auth.php'; 3 if ( isset( $_SESSION['fw_url'] ) ) { 4 $_SESSION['fw_url'] = filter_var( $_SESSION['fw_url'], FILTER_SANITIZE_URL ); 5 $fotoweb_url = $_SESSION['fw_url']; 6 6 } 7 if (isset($_SESSION['access_token'])){8 $_SESSION['access_token'] = filter_var( $_SESSION['access_token'], FILTER_SANITIZE_STRING);9 $access_token= $_SESSION['access_token'];7 if ( isset( $_SESSION['access_token'] ) ) { 8 $_SESSION['access_token'] = filter_var( $_SESSION['access_token'], FILTER_SANITIZE_STRING ); 9 $access_token = $_SESSION['access_token']; 10 10 } 11 if (isset($_SESSION['client_id'])){12 $_SESSION['client_id'] = filter_var( $_SESSION['client_id'], FILTER_SANITIZE_STRING);13 $client_id= $_SESSION['client_id'];11 if ( isset( $_SESSION['client_id'] ) ) { 12 $_SESSION['client_id'] = filter_var( $_SESSION['client_id'], FILTER_SANITIZE_STRING ); 13 $client_id = $_SESSION['client_id']; 14 14 } 15 if (isset($_SESSION['redirect_uri'])){16 $_SESSION['redirect_uri'] = filter_var( $_SESSION['redirect_uri'], FILTER_SANITIZE_URL);17 $redirect_uri= $_SESSION['redirect_uri'];15 if ( isset( $_SESSION['redirect_uri'] ) ) { 16 $_SESSION['redirect_uri'] = filter_var( $_SESSION['redirect_uri'], FILTER_SANITIZE_URL ); 17 $redirect_uri = $_SESSION['redirect_uri']; 18 18 } 19 if (isset($_SESSION['state'])){20 $_SESSION['state'] = filter_var( $_SESSION['state'], FILTER_SANITIZE_STRING);21 $state= $_SESSION['state'];22 } 19 if ( isset( $_SESSION['state'] ) ) { 20 $_SESSION['state'] = filter_var( $_SESSION['state'], FILTER_SANITIZE_STRING ); 21 $state = $_SESSION['state']; 22 } 23 23 24 if(isset($_SESSION['access_token'])){ 25 echo '<iframe src="'.$fotoweb_url.'/fotoweb/widgets/selection?access_token='.$access_token.'" width="100%" height="100%" frameBorder="0" id="iframe"></iframe>'; 26 } 27 else{ 28 echo 'Something went wrong! Please <a href="'.$fotoweb_url.'/fotoweb/oauth2/authorize?response_type=code&client_id='.$client_id.'&redirect_uri='.$redirect_uri.'&state='.$state.'"> log in </a> again!'; 24 if ( isset( $_SESSION['access_token'] ) ) { 25 echo '<iframe src="' . $fotoweb_url . '/fotoweb/widgets/selection?access_token=' . $access_token . '" width="100%" height="100%" frameBorder="0" id="iframe"></iframe>'; 26 } else { 27 echo 'Something went wrong! Please <a href="' . $fotoweb_url . '/fotoweb/oauth2/authorize?response_type=code&client_id=' . $client_id . '&redirect_uri=' . $redirect_uri . '&state=' . $state . '"> log in </a> again!'; 29 28 } 30 29 ?> 31 30 <script> 32 const fw_url = '<?php echo $_SESSION['fw_url']; ?>';31 const fw_url = '<?php echo $_SESSION['fw_url']; ?>'; 33 32 document.title = "Add Media from FotoWare"; 34 document.documentElement.style.overflow = 'hidden'; // firefox, chrome 33 document.documentElement.style.overflow = 'hidden'; // firefox, chrome. 35 34 document.getElementsByTagName("body")[0].style.margin = "0"; 36 35 document.getElementsByTagName("body")[0].style.padding = "0"; 37 36 38 37 function listener (event) { 39 if (event.data === 'authenticated') {38 if (event.data === 'authenticated') { 40 39 const iframes = document.getElementById('iframe'); 41 40 const FW_iframe = ''; … … 51 50 handleExported(event.data); 52 51 }else if (event.data.event === 'selectionWidgetCancel') { 53 window.close();54 }52 window.close(); 53 } 55 54 } 56 55 function handleSelected(data) { … … 63 62 '" width="' + data.export.export.size.w + 64 63 '" height="' + data.export.export.size.h + 65 '" />';64 '" />'; 66 65 window.localStorage.setItem('exported_url',exported_url); 67 66 window.close(); … … 69 68 70 69 function getFrameURL (data, url) { 71 const token = '<?php echo $_SESSION['access_token']?>';70 const token = '<?php echo $_SESSION['access_token']; ?>'; 72 71 const frameURL = url + '/fotoweb/widgets/publish?access_token=' + token + '&i=' + encodeURIComponent(data.asset.href); 73 72 return frameURL; -
access-fotoweb-media/trunk/index.php
r2257057 r3090225 1 1 <?php 2 2 // Silence is golden. 3 ?> -
access-fotoweb-media/trunk/readme.txt
r2894187 r3090225 4 4 Tags:DAM, FOTOWARE, upload image from FotoWare, 5 5 Requires at least: 3.8 6 Tested up to: 6. 27 Requires PHP: 5.2.46 Tested up to: 6.5.3 7 Requires PHP: 7.4 or higher 8 8 Stable tag: 3.2.0 9 9 License: GPLv3
Note: See TracChangeset
for help on using the changeset viewer.