Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/walla3t.corals.io/wp-content/plugins/apper-core/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/walla3t.corals.io/wp-content/plugins/apper-core/update-notifier.php
<?php
/**
* Plugin update notifier
* @package Apper Core
**/

// Constants for the plugin name, folder and remote XML url
define( 'APPER_NOTIFIER_PLUGIN_NAME', 'Apper Core' );
define( 'APPER_NOTIFIER_PLUGIN_FOLDER_NAME', 'apper-core' );
define( 'APPER_NOTIFIER_PLUGIN_FILE_NAME', 'apper-core.php' );
define( 'APPER_NOTIFIER_PLUGIN_XML_FILE', 'https://hostacmee.space/updates/apper/notifier.xml' ); // The remote notifier XML file containing the latest version of the plugin and changelog
define( 'APPER_PLUGIN_NOTIFIER_CACHE_INTERVAL', 25200 ); // The time interval for the remote XML cache in the database (25200 seconds = 7hours)

// Adds an update notification to the WordPress Dashboard menu
function apper_update_plugin_notifier_menu() {
	if ( function_exists( 'simplexml_load_string' ) ) { // Stop if simplexml_load_string funtion isn't available
	    $xml 			= apper_get_latest_plugin_version( APPER_PLUGIN_NOTIFIER_CACHE_INTERVAL ); // Get the latest remote XML file on our server
		$plugin_data 	= get_plugin_data( WP_PLUGIN_DIR . '/' . APPER_NOTIFIER_PLUGIN_FOLDER_NAME . '/' . APPER_NOTIFIER_PLUGIN_FILE_NAME ); // Read plugin current version from the style.css

		if ( (string) $xml->latest > (string) $plugin_data['Version'] ) { // Compare current plugin version with the remote XML version
			if ( defined( 'APPER_NOTIFIER_PLUGIN_SHORT_NAME' ) ) {
				$menu_name = APPER_NOTIFIER_PLUGIN_SHORT_NAME;
			} else {
				$menu_name = APPER_NOTIFIER_PLUGIN_NAME;
			}
			add_dashboard_page( APPER_NOTIFIER_PLUGIN_NAME . ' Plugin Updates', $menu_name . ' <span class="update-plugins count-1"><span class="update-count">New Updates</span></span>', 'administrator', 'apper-plugin-update-notifier', 'apper_update_notifier');
		}
	}
}
add_action('admin_menu', 'apper_update_plugin_notifier_menu');



// Adds an update notification to the WordPress 3.1+ Admin Bar
function apper_update_notifier_bar_menu() {
	if ( function_exists( 'simplexml_load_string' ) ) { // Stop if simplexml_load_string funtion isn't available
		
		global $wp_admin_bar, $wpdb;

		if ( ! is_admin() )
			return;

		if ( ! is_super_admin() || ! is_admin_bar_showing() ) // Don't display notification in admin bar if it's disabled or the current user isn't an administrator
		return;

		$xml 		= apper_get_latest_plugin_version( APPER_PLUGIN_NOTIFIER_CACHE_INTERVAL ); // Get the latest remote XML file on our server
		$plugin_data 	= get_plugin_data( WP_PLUGIN_DIR . '/' . APPER_NOTIFIER_PLUGIN_FOLDER_NAME . '/' .APPER_NOTIFIER_PLUGIN_FILE_NAME ); // Read plugin current version from the main plugin file

		if( (string) $xml->latest > (string) $plugin_data['Version'] ) { // Compare current plugin version with the remote XML version
			$wp_admin_bar->add_menu( array( 'id' => 'plugin_update_notifier', 'title' => '<span>' . APPER_NOTIFIER_PLUGIN_NAME . ' <span id="ab-updates">New Updates</span></span>', 'href' => get_admin_url() . 'index.php?page=apper-plugin-update-notifier' ) );
		}
	}
}
add_action( 'admin_bar_menu', 'apper_update_notifier_bar_menu', 1000 );



// The notifier page
function apper_update_notifier() {
	$xml 			= apper_get_latest_plugin_version( APPER_PLUGIN_NOTIFIER_CACHE_INTERVAL ); // Get the latest remote XML file on our server
	$plugin_data 	= get_plugin_data( WP_PLUGIN_DIR . '/' . APPER_NOTIFIER_PLUGIN_FOLDER_NAME . '/' .APPER_NOTIFIER_PLUGIN_FILE_NAME ); // Read plugin current version from the main plugin file ?>

	<style>
		.update-nag { display: none; }
		#instructions {max-width: 670px;}
		h3.title {margin: 30px 0 0 0; padding: 30px 0 0 0; border-top: 1px solid #ddd;}
	</style>

	<div class="wrap">

		<h2><?php echo APPER_NOTIFIER_PLUGIN_NAME ?> Plugin Updates</h2>
	  <div id="message" class="updated below-h2"><p><strong>There is a new version of the <?php echo APPER_NOTIFIER_PLUGIN_NAME; ?> plugin available.</strong> You have version <?php echo $plugin_data['Version']; ?> installed. Update to version <?php echo $xml->latest; ?>.</p></div>

		<div id="bkc-update-instructions">
		    <h3>Update <?php echo APPER_NOTIFIER_PLUGIN_NAME ?></h3>
		    <p>To update the <?php echo APPER_NOTIFIER_PLUGIN_NAME ?> plugin,</p>
        <ul>
          <li>* Go to Plugins -> Installed plugins.</li>
          <li>* Deactivate the <?php echo APPER_NOTIFIER_PLUGIN_NAME ?> plugin.</li>
          <li>* Delete <?php echo APPER_NOTIFIER_PLUGIN_NAME ?> plugin.</li>
          <li>* Once the <?php echo APPER_NOTIFIER_PLUGIN_NAME ?> plugin is deactivated and deleted, you will see a notification on top of the page to install the
            <?php echo APPER_NOTIFIER_PLUGIN_NAME ?> plugin.
          </li>
          <li>* Click "Install" <?php echo APPER_NOTIFIER_PLUGIN_NAME ?> plugin and follow the instructions in the screen and activate the plugin.</li>
          <li>* That's it. You have just updated the <?php echo APPER_NOTIFIER_PLUGIN_NAME ?> plugin.</li>
        </ul>
		</div>

	    <h3 class="title">Changelog</h3>
	    <?php echo $xml->changelog; ?>

	</div>

<?php }



// Get the remote XML file contents and return its data (Version and Changelog)
// Uses the cached version if available and inside the time interval defined
function apper_get_latest_plugin_version( $interval ) {
	$notifier_file_url = APPER_NOTIFIER_PLUGIN_XML_FILE;
	$db_cache_field = 'notifier-cache';
	$db_cache_field_last_updated = 'notifier-cache-last-updated';
	$last = get_option( $db_cache_field_last_updated );
	$now = time();
	// check the cache
	if ( ! $last || ( ( $now - $last ) > $interval ) ) {
		// cache doesn't exist, or is old, so refresh it
		if( function_exists( 'curl_init' ) ) { // if cURL is available, use it...
			$ch = curl_init( $notifier_file_url );
			curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
			curl_setopt( $ch, CURLOPT_HEADER, 0 );
			curl_setopt( $ch, CURLOPT_TIMEOUT, 10 );
			$cache = curl_exec( $ch );
			curl_close( $ch );
		} else {
			$cache = file_get_contents( $notifier_file_url ); // ...if not, use the common file_get_contents()
		}

		if ( $cache ) {
			// we got good results
			update_option( $db_cache_field, $cache );
			update_option( $db_cache_field_last_updated, time() );
		}
		// read from the cache file
		$notifier_data = get_option( $db_cache_field );
	}
	else {
		// cache file is fresh enough, so read from it
		$notifier_data = get_option( $db_cache_field );
	}

	// Let's see if the $xml data was returned as we expected it to.
	// If it didn't, use the default 1.0 as the latest version so that we don't have problems when the remote server hosting the XML file is down
	if( strpos( (string) $notifier_data, '<notifier>' ) === false ) {
		$notifier_data = '<?xml version="1.0" encoding="UTF-8"?><notifier><latest>1.0</latest><changelog></changelog></notifier>';
	}

	// Load the remote XML data into a variable and return it
	$xml = simplexml_load_string( $notifier_data );

	return $xml;
}

Spamworldpro Mini