" name="submit"> </p> </form> <br/> <form action="" method="post" id="gde-backup"> <h3><?php _e('Backup and Import', 'google-document-embedder'); ?> </h3> <?php if (!$healthy) { echo "<p>" . gde_show_error(__('Unable to load profile settings. Please re-activate GDE and if the problem persists, request help using the "Support" tab.', 'google-document-embedder')) . "</p>\n"; } else { ?> <p><?php _e('Download a file to your computer containing your profiles, settings, or both, for backup or migration purposes.', 'google-document-embedder'); ?> </p> <p> <input type="radio" value="all" name="type" id="backup-all" checked="checked"><label for="backup-all"> <?php _e('All Profiles and Settings', 'google-document-embedder'); ?> </label> <input type="radio" value="profiles" name="type" id="backup-pro"><label for="backup-pro"> <?php _e('Profiles', 'google-document-embedder');
function gde_profile_form($id = 1) { global $healthy; // get requested profile if (!$healthy) { echo "<p>" . gde_show_error(__('Unable to load profile settings. Please re-activate GDE and if the problem persists, request help using the "Support" tab.', 'google-document-embedder')) . "</p>\n"; } else { $p = gde_get_profiles($id); // minimize FOUC if ($p['viewer'] == "standard") { $hideenh = " hide"; } else { $hideenh = ''; } // setup title & nonce if ($id == 1) { $title = __('Default Settings', 'google-document-embedder'); $desc = __('These settings define the default viewer profile, which is used when no other profile is specified.', 'google-document-embedder'); $naction = "update-default-opts"; $nname = "_general_default"; } else { $title = __('Edit Profile', 'google-document-embedder'); $naction = "update-profile-opts"; $nname = "_profile_edit"; } ?> <div id="profile-form"> <form action="" method="post"> <?php wp_nonce_field($naction, $nname); ?> <input type="hidden" name="profile_id" value="<?php echo esc_attr($id); ?> "> <?php gde_help_link(GDE_STDOPT_URL, 'right'); ?> <h3><?php echo $title; ?> </h3> <?php if (isset($desc)) { echo htmlentities($desc); } ?> <table class="form-table"> <tbody> <tr valign="top"> <th scope="row"><?php _e('Viewer Mode', 'google-document-embedder'); ?> </th> <td> <select name="viewer" id="viewer"> <?php gde_profile_option($p['viewer'], 'standard', __('Standard Viewer', 'google-document-embedder'), __('Embed the basic viewer only', 'google-document-embedder')); //gde_profile_option( $p['viewer'], 'enhanced', __('Enhanced Viewer', 'google-document-embedder'), __('Enable extended viewer options', 'google-document-embedder') ); ?> </select><br/> <span class="gde-fnote" id="viewer-h"></span> <p><b>To find out why Enhanced Mode is no longer available, see the notice on our <a href="https://wordpress.org/plugins/google-document-embedder/" target="_blank">plugin homepage</a>. </b></p> </td> </tr> </tbody> </table> <!-- <fieldset class="gde-inner<?php echo $hideenh; ?> " id="gde-enh-fs"> <legend><?php _e('Enhanced Viewer Settings', 'google-document-embedder'); ?> </legend> <table class="form-table"> <tbody> <tr valign="top"> <th scope="row"><?php _e('Toolbar', 'google-document-embedder'); ?> </th> <td> <?php gde_help_link(GDE_ENHOPT_URL, 'right'); gde_profile_checkbox($p['tb_flags'], 'gdet_h', __('Remove Toolbar', 'google-document-embedder')); ?> </td> </tr> <tr valign="top" id="mobiletb"> <th scope="row"><?php _e('Use Mobile Toolbar', 'google-document-embedder'); ?> </th> <td> <select name="tb_mobile" id="tb_mobile"> <?php gde_profile_option($p['tb_mobile'], 'default', __('Mobile Devices Only (Default)', 'google-document-embedder'), __('Use mobile toolbar when mobile device detected', 'google-document-embedder')); gde_profile_option($p['tb_mobile'], 'always', __('Always', 'google-document-embedder'), __('Use mobile toolbar for all visitors', 'google-document-embedder')); gde_profile_option($p['tb_mobile'], 'never', __('Never', 'google-document-embedder'), __('Never use mobile toolbar', 'google-document-embedder')); ?> </select><br/> <span class="gde-fnote" id="mobile-h"></span> </td> </tr> <tr valign="top" id="toolbuttons"> <th scope="row"><?php _e('Toolbar Items', 'google-document-embedder'); ?> </th> <td> <?php gde_profile_checkbox($p['tb_flags'], 'gdet_p', __('Page Numbers', 'google-document-embedder')); gde_profile_checkbox($p['tb_flags'], 'gdet_r', __('Previous/Next Page', 'google-document-embedder')); gde_profile_checkbox($p['tb_flags'], 'gdet_z', __('Zoom In/Out', 'google-document-embedder')); gde_profile_checkbox($p['tb_flags'], 'gdet_n', __('Full Screen/New Window', 'google-document-embedder'), 'allowNewWin'); ?> <br/> <span class="gde-fnote"><?php _e('Uncheck items to remove from toolbar. Buttons will vary based on file type and device used.', 'google-document-embedder'); ?> </span> </td> </tr> <tr valign="top" id="fullscreen"> <th scope="row"><?php _e('Full Screen Behavior', 'google-document-embedder'); ?> </th> <td> <select name="tb_fullscr" id="tb_fullscr"> <?php gde_profile_option($p['tb_fullscr'], 'default', __('Google-Hosted Page (Default)', 'google-document-embedder')); //gde_profile_option( $p['tb_fullscr'], 'branded', __('Custom-Branded Page', 'google-document-embedder') ); gde_profile_option($p['tb_fullscr'], 'viewer', __('Full Screen Viewer', 'google-document-embedder')); ?> </select><br/> <?php gde_profile_checkbox($p['tb_fullwin'], 'fs_win', __('Open in New Window', 'google-document-embedder')); gde_profile_checkbox($p['tb_fulluser'], 'fs_user', __('Allow Logged-in Users Only', 'google-document-embedder'), 'blockAnon'); //gde_profile_checkbox( $p['tb_print'], 'fs_print', __('Allow Printing', 'google-document-embedder'), 'allowPrint' ); ?> </td> </tr> <tr valign="top" id="bgcolor"> <th scope="row"><?php _e('Page Area Background Color', 'google-document-embedder'); ?> </th> <td> <?php gde_profile_text($p['vw_bgcolor'], 'vw_bgcolor', 'gde-color-field', 10); gde_profile_checkbox($p['vw_flags'], 'gdev_t', __('None (Transparent)', 'google-document-embedder')); ?> </td> </tr> <tr valign="top" id="pbcolor"> <th scope="row"><?php _e('Page Border Color', 'google-document-embedder'); ?> </th> <td> <?php gde_profile_text($p['vw_pbcolor'], 'vw_pbcolor', 'gde-color-field', 10); gde_profile_checkbox($p['vw_flags'], 'gdev_b', __('No Border', 'google-document-embedder')); ?> </td> </tr> <tr valign="top" id="cssfile"> <th scope="row"><?php _e('Custom CSS File', 'google-document-embedder'); ?> </th> <td> <?php @gde_profile_text($p['vw_css'], 'vw_css', '', '65'); ?> <br/> <span class="gde-fnote"><?php _e('URL of custom CSS file (may override some of the above options)', 'google-document-embedder'); ?> </span> </td> </tr> <tr valign="top" id="docsec"> <th scope="row"><?php _e('Security', 'google-document-embedder'); ?> </th> <td> <?php gde_profile_checkbox($p['vw_flags'], 'gdev_x', __('Hide ability to select/copy/paste text', 'google-document-embedder'), 'hideselect', 1); gde_profile_checkbox($p['link_block'], 'block', __('Block all download requests for file', 'google-document-embedder'), 'linkblock', 1); ?> </td> </tr> </tbody> </table> </fieldset> --> <table class="form-table"> <tbody> <tr valign="top"> <th scope="row"><?php _e('Default Language', 'google-document-embedder'); ?> </th> <td> <select name="language" id="language"> <?php require_once GDE_PLUGIN_DIR . 'libs/lib-langs.php'; $langs = gde_supported_langs(); foreach ($langs as $code => $desc) { gde_profile_option($p['language'], $code, $desc); } ?> </select><br/> <span class="gde-fnote"><?php _e('Language of toolbar button tips', 'google-document-embedder'); ?> </span> </td> </tr> <tr valign="top"> <th scope="row"><?php _e('Default Size', 'google-document-embedder'); ?> </th> <td> <?php _e('Width', 'google-document-embedder'); ?> <?php gde_profile_text($p['default_width'], 'default_width', '', '5'); ?> <?php _e('Height', 'google-document-embedder'); ?> <?php gde_profile_text($p['default_height'], 'default_height', '', '5'); ?> <br/> <span class="gde-fnote"><?php _e('Enter as pixels or percentage (example: 500px or 100%)', 'google-document-embedder'); ?> </span> </td> </tr> <tr valign="top"> <th scope="row"><?php _e('File Base URL', 'google-document-embedder'); ?> </th> <td> <?php gde_profile_text($p['base_url'], 'base_url', '', '65'); ?> <br/> <span class="gde-fnote"><?php _e('Any file not starting with <code>http</code> will be prefixed by this value', 'google-document-embedder'); ?> </span> </td> </tr> <tr valign="top"> <th scope="row"><?php _e('Download Link', 'google-document-embedder'); ?> </th> <td> <select name="link_show" id="link_show"> <?php gde_profile_option($p['link_show'], 'all', __('All Users', 'google-document-embedder'), __('Download link visible to everyone by default', 'google-document-embedder')); gde_profile_option($p['link_show'], 'users', __('Logged-in Users', 'google-document-embedder'), __('Download link visible to logged-in users', 'google-document-embedder')); gde_profile_option($p['link_show'], 'none', __('None', 'google-document-embedder'), __('Download link is not visible by default', 'google-document-embedder')); ?> </select><br/> <span class="gde-fnote" id="linkshow-h"></span> </td> </tr> <tr valign="top" id="linktext"> <th scope="row"><?php _e('Link Text', 'google-document-embedder'); ?> </th> <td> <input size="50" name="link_text" value="<?php echo esc_attr($p['link_text']); ?> " type="text"><br/> <span class="gde-fnote"><?php _e('You can further customize text using these dynamic replacements:', 'google-document-embedder'); ?> </span><br> <code>%FILE</code> : <?php _e('filename', 'google-document-embedder'); ?> <code>%TYPE</code> : <?php _e('file type', 'google-document-embedder'); ?> <code>%SIZE</code> : <?php _e('file size', 'google-document-embedder'); ?> </td> </tr> <tr valign="top" id="linkpos"> <th scope="row"><?php _e('Link Position', 'google-document-embedder'); ?> </th> <td> <select name="link_pos"> <?php gde_profile_option($p['link_pos'], 'above', __('Above Viewer', 'google-document-embedder')); gde_profile_option($p['link_pos'], 'below', __('Below Viewer', 'google-document-embedder')); ?> </select> </td> </tr> <tr valign="top" id="linkbehavior"> <th scope="row"><?php _e('Link Behavior', 'google-document-embedder'); ?> </th> <td> <?php gde_profile_checkbox($p['link_force'], 'force', __('Force download (bypass browser plugins)', 'google-document-embedder'), 'linkforce', 1); //gde_profile_checkbox( $p['link_mask'], 'mask', __('Shorten URL', 'google-document-embedder'), 'linkmask', 1 ); ?> </td> </tr> </tbody> </table> <p class="gde-submit"> <input id="pro-submit" class="button-primary" type="submit" value="<?php _e('Save Changes', 'google-document-embedder'); ?> " name="submit"> </p> </form> </div> <?php } }
function gde_do_shortcode($atts) { global $healthy, $gdeoptions; //$gdeglobals // check profile table health if (!$healthy) { delete_option('gde_db_version'); return gde_show_error(__('Unable to load profile settings', 'google-document-embedder')); } // handle global setting overrides - not active in this release /* if ($gdeglobals['enforce_viewer'] == "std") { $gdeoptions['disable_proxy'] = "yes"; } if ($gdeglobals['enforce_lang']) { $gdeoptions['default_lang'] = $gdeglobals['enforce_lang']; } */ extract(shortcode_atts(array('file' => '', 'profile' => 1, 'save' => '', 'width' => '', 'height' => '', 'cache' => ''), $atts)); // get requested profile data (or default if doesn't exist) $term = $profile; if (is_numeric($term)) { // id-based lookup if (!($profile = gde_get_profiles($term))) { gde_dx_log("Loading default profile instead"); if (!($profile = gde_get_profiles(1))) { return gde_show_error(__('Unable to load requested profile.', 'google-document-embedder')); } else { $pid = 1; } } else { $pid = $term; } } else { // name-based lookup if (!($profile = gde_get_profiles(strtolower($term)))) { gde_dx_log("Loading default profile instead"); if (!($profile = gde_get_profiles(1))) { return gde_show_error(__('Unable to load requested profile.', 'google-document-embedder')); } else { $pid = 1; } } else { $pid = $profile['profile_id']; } } // use profile defaults if shortcode override not defined if ($save !== "0") { if (empty($save)) { $save = $profile['link_show']; } } if (empty($width)) { $width = $profile['default_width']; } if (empty($height)) { $height = $profile['default_height']; } if ($cache !== "0") { if (empty($cache)) { $cache = $profile['cache']; } } //if ( $profile['language'] !== "en_US" ) { $lang = $profile['language']; //} // tweak the dimensions if necessary $width = gde_sanitize_dims($width); $height = gde_sanitize_dims($height); // add base url if needed if (!preg_match("/^http/i", $file)) { if (substr($file, 0, 2) == "//") { // append dynamic protocol if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) { $file = "https:" . $file; } else { $file = "http:" . $file; } } elseif (isset($profile['base_url'])) { // not a full link, add base URL if available if (substr($file, 0, 1) == "/") { // remove any preceding slash from doc (base URL adds it) $file = ltrim($file, '/'); } $file = $profile['base_url'] . $file; } } // capture file details $fn = basename($file); $fnp = gde_split_filename($fn); // check for missing required field if (!$file) { return gde_show_error(__('File not specified, check shortcode syntax', 'google-document-embedder')); } // file validation if ($gdeoptions['error_check'] == "no") { $force = true; } else { $force = false; } $status = gde_validate_file(str_replace(" ", "%20", $file), $force); if (!isset($code) && !is_array($status) && $status !== -1) { // validation failed $code = gde_show_error($status); } elseif (!isset($code)) { // validation passed or was skipped // check for max filesize $viewer = true; if ($gdeoptions['file_maxsize'] > 0 && isset($status['fsize'])) { $maxbytes = (int) $gdeoptions['file_maxsize'] * 1024 * 1024; if ($status['fsize'] > $maxbytes) { $viewer = false; } } // generate links (embed, download) $links = array($file, $file); if ($profile['link_block'] == "yes" && gde_is_blockable($profile)) { if ($secure = gde_get_secure_url($file)) { $links[0] = $secure; } else { $links[0] = ''; } $links[1] = ''; } elseif ($profile['link_show'] !== "none") { if ($profile['link_force'] == "yes" && $profile['link_mask'] == "no") { $links[1] = GDE_PLUGIN_URL . "load.php?d=" . urlencode($links[1]); } elseif ($profile['link_force'] == "no" && $profile['link_mask'] == "yes") { $short = gde_get_short_url($links[0]); $links[0] = $short; $links[1] = $short; } elseif ($profile['link_force'] == "yes" && $profile['link_mask'] == "yes") { $short = gde_get_short_url(GDE_PLUGIN_URL . "load.php?d=" . urlencode($links[0])); $links[0] = $short; $links[1] = $short; } } // obfuscate filename if cache disabled (globally or via shortcode) // note that this is ignored if the document is secure to prevent each hit from generating a new db row if (!empty($links[1]) && ($cache == "off" || $cache == "0")) { $links[0] .= "?" . time(); } // check for failed secure doc if (empty($links[0]) && empty($links[1])) { $code = gde_show_error(__('Unable to secure document', 'google-document-embedder')); } else { // which viewer? //if ( $profile['viewer'] == "enhanced" ) { // $lnk = GDE_PLUGIN_URL . "view.php?url=" . urlencode( $links[0] ) . "&hl=" . $lang . "&gpid=" . $pid; // make protocol-agnostic // $lnk = preg_replace( '/^https?:/i', '', $lnk ); //} else { $lnk = "//docs.google.com/viewer?url=" . urlencode($links[0]) . "&hl=" . $lang; //} // what mode? //if ( $profile['tb_mobile'] == "always" ) { // $lnk .= "&mobile=true"; //} else { $lnk .= "&embedded=true"; //} // build viewer if ($viewer == false) { // exceeds max filesize $vwr = ''; } else { $vwr = '<iframe src="%U%" class="gde-frame" style="width:%W%; height:%H%; border: none;"%ATTRS%></iframe>'; $vwr = str_replace("%U%", $lnk, $vwr); $vwr = str_replace("%W%", $width, $vwr); $vwr = str_replace("%H%", $height, $vwr); // frame attributes $vattr[] = ' scrolling="no"'; // iphone scrolling bug //if ( ! empty( $page ) && is_numeric( $page ) ) { // selected starting page // $page = (int) $page - 1; // $vattr[] = ' onload="javascript:this.contentWindow.location.hash=\':0.page.' . $page . '\';"'; //} $vwr = str_replace("%ATTRS%", implode('', $vattr), $vwr); } // show download link? $allow_save = false; if (!empty($links[1])) { // link empty = secure document; ignore any other save attribute if ($save == "all" || $save == "1") { $allow_save = true; } elseif ($save == "users" && is_user_logged_in()) { $allow_save = true; } } if ($allow_save) { // build download link $linkcode = '<p class="gde-text"><a href="%LINK%" class="gde-link"%ATTRS%>%TXT%</a></p>'; $linkcode = str_replace("%LINK%", $links[1], $linkcode); // fix type $ftype = strtoupper($fnp[1]); if ($ftype == "TIF") { $ftype = "TIFF"; } // link attributes if ($profile['link_mask'] == "yes") { $attr[] = ' rel="nofollow"'; } $attr[] = gde_ga_event($file); // GA integration $linkcode = str_replace("%ATTRS%", implode('', $attr), $linkcode); // link text if (empty($profile['link_text'])) { $profile['link_text'] = __('Download', 'google-document-embedder'); } $dltext = str_replace("%FILE", $fn, $profile['link_text']); $dltext = str_replace("%TYPE", $ftype, $dltext); $dltext = str_replace("%SIZE", gde_format_bytes($status['fsize']), $dltext); $linkcode = str_replace("%TXT%", $dltext, $linkcode); } else { $linkcode = ''; } // link position if ($profile['link_pos'] == "above") { $code = $linkcode . "\n" . $vwr; } else { $code = $vwr . "\n" . $linkcode; } } } return $code; }