public_html/wp-content/plugins/google-document-embedder/libs/lib-setup.php
/**
 * Create/update database table to store profile data
 *
 * @since   2.5.0.1
 * @return  bool Whether or not table creation/update was successful
 */
Create/update database table to store profile data
@since   2.5.0.1
@return  bool Whether or not table creation/update was successful
Create / update database table to store profile data @since 2 . 5 . 0 . 1 @return bool Whether or not table creation / update was successful
function gde_db_tables( $gde_db_ver ) {
	global $wpdb;
	$fails = 0;
	$table = $wpdb->prefix . 'gde_profiles';
	if ($wpdb->get_var( "SHOW TABLES LIKE '$table'" ) !== $table) {
		delete_site_option( 'gde_db_version' );
	}
	$table = $wpdb->prefix . 'gde_secure';
	if ($wpdb->get_var( "SHOW TABLES LIKE '$table'" ) !== $table) {
		delete_site_option( 'gde_db_version' );
	}
	if ( is_multisite() ) {
		$db_ver_installed = get_site_option( 'gde_db_version', 0 );
	} else {
		$db_ver_installed = get_option( 'gde_db_version', 0 );
	}
	gde_dx_log("Installed DB ver: $db_ver_installed; This DB ver: " . $gde_db_ver );
	if ( version_compare( $gde_db_ver, $db_ver_installed, ">" ) ) {
		$table = $wpdb->prefix . 'gde_profiles';
		$sql = "CREATE TABLE " . $table . " (
		  profile_id mediumint(9) UNSIGNED NOT NULL AUTO_INCREMENT,
		  profile_name varchar(64) NOT NULL,
		  profile_desc varchar(255) NULL,
		  profile_data longtext NOT NULL,
		  UNIQUE KEY (profile_id)
		) ENGINE=MyISAM  DEFAULT CHARSET=utf8; ";
		if ( isset( $sql ) ) {
			require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
			dbDelta($sql);
			if ($wpdb->get_var( "SHOW TABLES LIKE '$table'" ) == $table ) {
				gde_dx_log("Profile table create/update successful");
			} else {
				gde_dx_log("Profile table create/update failed");
				$fails++;
			}
		}
		$table = $wpdb->prefix . 'gde_secure';
		$sql = "CREATE TABLE " . $table . " (
		  code varchar(10) NOT NULL,
		  url varchar(255) NOT NULL,
		  murl varchar(100) NOT NULL,
		  stamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
		  autoexpire enum('Y','N') NOT NULL DEFAULT 'N',
		  UNIQUE KEY code (code)
		) ENGINE=MyISAM DEFAULT CHARSET=utf8; ";
		if ( isset( $sql ) ) {
			require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
			dbDelta( $sql );
			if ( $wpdb->get_var( "SHOW TABLES LIKE '$table'" ) == $table ) {
				gde_dx_log("Secure doc table create/update successful");
			} else {
				gde_dx_log("Secure doc table create/update failed");
				$fails++;
			}
		}
	} else {
		gde_dx_log("Tables OK, nothing to do");
	}
	if ( $fails > 0 ) {
		delete_site_option( 'gde_db_version' );
		return false;
	} else {
		update_site_option( 'gde_db_version', $gde_db_ver );
		return true;
	}
}
function gde_db_tables ( $ gde_db_ver ) { global $ wpdb ; $ fails = 0 ; $ table = $ wpdb -> prefix . 'gde_profiles' ; if ( $ wpdb -> get_var ( " SHOW TABLES LIKE ' $ table ' " ) !== $ table ) { delete_site_option ( 'gde_db_version' ) ; } $ table = $ wpdb -> prefix . 'gde_secure' ; if ( $ wpdb -> get_var ( " SHOW TABLES LIKE ' $ table ' " ) !== $ table ) { delete_site_option ( 'gde_db_version' ) ; } if ( is_multisite ( ) ) { $ db_ver_installed = get_site_option ( 'gde_db_version' , 0 ) ; } else { $ db_ver_installed = get_option ( 'gde_db_version' , 0 ) ; } gde_dx_log ( " Installed DB ver:  $ db_ver_installed ; This DB ver:  " . $ gde_db_ver ) ; if ( version_compare ( $ gde_db_ver , $ db_ver_installed , " > " ) ) { $ table = $ wpdb -> prefix . 'gde_profiles' ; $ sql = " CREATE TABLE  " . $ table . "  (
		  profile_id mediumint(9) UNSIGNED NOT NULL AUTO_INCREMENT,
		  profile_name varchar(64) NOT NULL,
		  profile_desc varchar(255) NULL,
		  profile_data longtext NOT NULL,
		  UNIQUE KEY (profile_id)
		) ENGINE=MyISAM  DEFAULT CHARSET=utf8;  " ; if ( isset ( $ sql ) ) { require_once ( ABSPATH . 'wp-admin/includes/upgrade.php' ) ; dbDelta ( $ sql ) ; if ( $ wpdb -> get_var ( " SHOW TABLES LIKE ' $ table ' " ) == $ table ) { gde_dx_log ( " Profile table create/update successful " ) ; } else { gde_dx_log ( " Profile table create/update failed " ) ; $ fails ++ ; } } $ table = $ wpdb -> prefix . 'gde_secure' ; $ sql = " CREATE TABLE  " . $ table . "  (
		  code varchar(10) NOT NULL,
		  url varchar(255) NOT NULL,
		  murl varchar(100) NOT NULL,
		  stamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
		  autoexpire enum('Y','N') NOT NULL DEFAULT 'N',
		  UNIQUE KEY code (code)
		) ENGINE=MyISAM DEFAULT CHARSET=utf8;  " ; if ( isset ( $ sql ) ) { require_once ( ABSPATH . 'wp-admin/includes/upgrade.php' ) ; dbDelta ( $ sql ) ; if ( $ wpdb -> get_var ( " SHOW TABLES LIKE ' $ table ' " ) == $ table ) { gde_dx_log ( " Secure doc table create/update successful " ) ; } else { gde_dx_log ( " Secure doc table create/update failed " ) ; $ fails ++ ; } } } else { gde_dx_log ( " Tables OK, nothing to do " ) ; } if ( $ fails > 0 ) { delete_site_option ( 'gde_db_version' ) ; return false ; } else { update_site_option ( 'gde_db_version' , $ gde_db_ver ) ; return true ; } }
Create/update database table to store profile data
 @since   2.5.0.1
 @return  bool Whether or not table creation/update was successful
Create / update database table to store profile data @since 2 . 5 . 0 . 1 @return bool Whether or not table creation / update was successful
// attempt to trap table creation failures // check for missing required tables (clear db version) //gde_dx_log("profiles db failed health check"); //gde_dx_log("securedoc db failed health check"); // install or upgrade profile table // write table or update to database // install or upgrade securedoc table // write table or update to database