PATH:
var
/
www
/
clients
/
client1
/
web1
/
web
/
wp-content
/
plugins
/
vxcash
/
includes
<?php /** * The file that defines the core plugin class * * A class definition that includes attributes and functions used across both the * public-facing side of the site and the admin area. * * @link https://www.vxcash.net * @since 1.0.0 * * @package Vxcash * @subpackage Vxcash/includes */ /** * The core plugin class. * * This is used to define internationalization, admin-specific hooks, and * public-facing site hooks. * * Also maintains the unique identifier of this plugin as well as the current * version of the plugin. * * @since 1.0.0 * @package Vxcash * @subpackage Vxcash/includes * @author Support <support@vxcash.net> */ class Vxcash { /** * @var Vxcash_Config */ private $config; /** * The loader that's responsible for maintaining and registering all hooks that power * the plugin. * * @since 1.0.0 * @access protected * @var Vxcash_Loader $loader Maintains and registers all hooks for the plugin. */ protected $loader; /** * The unique identifier of this plugin. * * @since 1.0.0 * @access protected * @var string $plugin_name The string used to uniquely identify this plugin. */ protected $plugin_name; /** * The current version of the plugin. * * @since 1.0.0 * @access protected * @var string $version The current version of the plugin. */ protected $version; /** * @var wpdb */ private $wpdb; /** * @var Vxcash_Visitx_Host_Admin */ private $vxhostPage; /** * Define the core functionality of the plugin. * * Set the plugin name and the plugin version that can be used throughout the plugin. * Load the dependencies, define the locale, and set the hooks for the admin area and * the public-facing side of the site. * * @since 1.0.0 */ public function __construct() { global $wpdb; $this->plugin_name = 'vxcash'; $this->version = '2.4.3'; $this->load_dependencies(); $this->set_locale(); $this->config = Vxcash_Config::getInstance(); $notifier = Vxcash_Notifier::getInstance(); $this->wpdb = $wpdb; if (is_admin()) { $this->loader->add_action('init', $this, 'runVersionUpdate'); $this->define_admin_hooks(); $notifier->handleNotifications(); } $hasPornme = $this->hasPornme(); $this->define_public_hooks(); $this->defineShortcodes(); $importDP = new Vxcash_Auto_Import_Dataprovider($wpdb); $dataprovider = new Vxcash_Vx_Dataprovider($this->config, $this->wpdb, new Vxcash_Visitx_Graphql_Client($this->config), $this->version); $categoryHandler = new Vxcash_Host_Category_Handler(); $this->vxhostPage = new Vxcash_Visitx_Host_Admin( $this->plugin_name, $this->version, $this->loader, $this->config, $categoryHandler, $dataprovider, $importDP ); $this->vxvideoPage = new Vxcash_Visitx_Video_Admin( $this->plugin_name, $this->version, $this->loader, $this->config, $dataprovider, $importDP ); $this->vxhostCustomPostType = new Vxcash_Vxhost_Custom_Posttype($this->loader); $this->vxvideoCustomPostType = new Vxcash_Vxvideo_Custom_Posttype($this->loader); $this->taxonomies = new Vxcash_Taxonomies($this->loader); if ($hasPornme) { $this->pornMePage = new Vxcash_Pornme_Video_Admin( $this->loader ); $this->pornMeCustomPostType = new Vxcash_Pornme_Custom_Posttype($this->loader); } $this->debugPage = new Vxcash_Debug_Admin( $this->plugin_name, $this->version, $this->loader, $this->config ); } /** * Load the required dependencies for this plugin. * * Include the following files that make up the plugin: * * - Vxcash_Loader. Orchestrates the hooks of the plugin. * - Vxcash_i18n. Defines internationalization functionality. * - Vxcash_Admin. Defines all hooks for the admin area. * - Vxcash_Public. Defines all hooks for the public side of the site. * * Create an instance of the loader which will be used to register the hooks * with WordPress. * * @since 1.0.0 * @access private */ private function load_dependencies() { $this->loader = new Vxcash_Loader(); } /** * Define the locale for this plugin for internationalization. * * Uses the Vxcash_i18n class in order to set the domain and to register the hook * with WordPress. * * @since 1.0.0 * @access private */ private function set_locale() { $plugin_i18n = new Vxcash_i18n(); $this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain'); } /** * Register all the hooks related to the admin area functionality * of the plugin. * * @since 1.0.0 * @access private */ private function define_admin_hooks() { $plugin_admin = new Vxcash_Admin($this->get_plugin_name(), $this->get_version(), $this->wpdb); $plugin_basename = plugin_basename(plugin_dir_path(__DIR__) . $this->plugin_name . '.php'); $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles'); $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts'); $this->loader->add_action('admin_menu', $plugin_admin, 'add_main_menu_entry'); // Add transitioning states $this->loader->add_action('publish_livecams', $plugin_admin, 'on_livecam_publishing', 10, 2); $this->loader->add_action('draft_livecams', $plugin_admin, 'on_livecam_drafting', 10, 2); $this->loader->add_action('future_livecams', $plugin_admin, 'on_livecam_drafting', 10, 2); $this->loader->add_action('private_livecams', $plugin_admin, 'on_livecam_drafting', 10, 2); $this->loader->add_action('trash_livecams', $plugin_admin, 'on_livecam_drafting', 10, 2); // Add Options update function $this->loader->add_action('admin_init', $plugin_admin, 'options_update'); // Add Settings link to the plugin $this->loader->add_filter('plugin_action_links_' . $plugin_basename, $plugin_admin, 'add_action_links'); // Add extra handling of external URL Preview in Admin panel $this->loader->add_filter('admin_post_thumbnail_html', $plugin_admin, 'add_thumbnail_url_field'); $this->loader->add_action('save_post', $plugin_admin, 'thumbnail_url_field_save', 10, 2); // Add Warning in the edit screen of turned off livecams $this->loader->add_action('current_screen', $plugin_admin, 'showWarningForTurnedOfLivecams'); $this->loader->add_action('current_screen', $plugin_admin, 'showWarningForTurnedOffVideos'); } /** * Register all the hooks related to the public-facing functionality * of the plugin. * * @since 1.0.0 * @access private */ private function define_public_hooks() { $vxcashBasDataprovider = new Vxcash_Bas_Dataprovider($this->config, $this->wpdb); $plugin_public = new Vxcash_Public( $this->get_plugin_name(), $this->get_version(), new Vxcash_Vx_Dataprovider( Vxcash_Config::getInstance(), $this->wpdb, new Vxcash_Visitx_Graphql_Client(Vxcash_Config::getInstance()), $this->version ), $vxcashBasDataprovider ); $plugin_bas = new Vxcash_Bas($vxcashBasDataprovider, $this->loader, $this->config); new VXCash_Crosselling($this->config); $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles'); $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts'); $this->loader->add_filter('link_host_name', $plugin_public, 'linkHostName'); $this->loader->add_filter('cron_schedules', $plugin_public, 'check_livecams_monthly_recurrence'); $this->loader->add_action('wp', $plugin_public, 'check_livecams_monthly_hook_setup'); $this->loader->add_action('check_livecams_availability', $plugin_public, 'check_livecams'); $this->loader->add_filter('post_thumbnail_html', $plugin_public, 'show_external_thumbnail'); $this->loader->add_action('show_bas_button', $plugin_bas, 'showBasButton'); $this->loader->add_action('get_bas_list', $plugin_bas, 'showBasList'); $this->loader->add_action('wp_ajax_get_bas_chat_page', $plugin_bas, 'getChatPage'); $this->loader->add_action('wp_ajax_nopriv_get_bas_chat_page', $plugin_bas, 'getChatPage'); $this->loader->add_action('wp_ajax_nopriv_turn_off_host', $plugin_public, 'ajaxTurnOffHost'); } /** * Run the loader to execute all the hooks with WordPress. * * @since 1.0.0 */ public function run() { $this->loader->run(); } /** * The name of the plugin used to uniquely identify it within the context of * WordPress and to define internationalization functionality. * * @since 1.0.0 * @return string The name of the plugin. */ public function get_plugin_name() { return $this->plugin_name; } /** * The reference to the class that orchestrates the hooks with the plugin. * * @since 1.0.0 * @return Vxcash_Loader Orchestrates the hooks of the plugin. */ public function get_loader() { return $this->loader; } /** * Retrieve the version number of the plugin. * * @since 1.0.0 * @return string The version number of the plugin. */ public function get_version() { return $this->version; } /** * Updates Databases and stuff between different versions of this plugin * * @since 1.1.0 */ public function runVersionUpdate() { $lastVersion = get_option('vxcash_plugin_version', '1.0.0'); if ($lastVersion !== $this->version) { if (version_compare($lastVersion, '1.0.0', '<=')) { $this->changeAllVXLinks(); } if (version_compare($lastVersion, '1.1.2', '<=')) { $this->addBasTables(); } if (version_compare($lastVersion, '1.3.5', '<')) { $this->extendLivecams(); } if (version_compare($lastVersion, '1.5.2', '<')) { $this->changeHardVXLinks(); } if (version_compare($lastVersion, '1.6.0', '<')) { $this->addPorndoeTable(); $this->updateAutoImporterTable(); $this->changePornmeLinks(); } if (version_compare($lastVersion, '1.8.0', '<')) { $this->removePorndoeTablesAndInfos(); $this->updateAutoImporterTable(); $notifier = Vxcash_Notifier::getInstance(); $notifier->addNotification( 'PorndoeRemoved', '<b>Hinweis:</b> Wie bereits mitgeteilt ist der Merchant PornDoe nicht mehr bei VX-CASH verfügbar.<br>Die entsprechenden Seiten wurden bereits automatisch entfernt. Bitte prüfe, dass deine Wordpress Seite weiterhin funktioniert.', Vxcash_Notifier::LEVEL_WARNING); } if (version_compare($lastVersion, '2.0.0', '<')) { $this->removePornmeTables(); $this->addVxVideoTable(); $this->updateAutoImporterTable(); } if (version_compare($lastVersion, '2.1.0', '<')) { $notifier = Vxcash_Notifier::getInstance(); $this->updateAutoImporterTable(); $notifier->addNotification( 'VXGraphQL', '<b>Bitte beachten:</b> Bitte beachten: Für den Import und das Anzeigen der VISIT-X Daten benötigen sie ab sofort einen GraphQL-API-Key der von ihrem VX-CASH-Supporter freigeschaltet werden muss. Bitte wenden Sie sich hierzu direkt an ihren Kontakt bei VX-CASH oder an support@vxcash.net. Nach der Freischaltung des Keys können Sie ihr Theme nutzen.', Vxcash_Notifier::LEVEL_INFO); } if (version_compare($lastVersion, '2.3.1', '<')) { $this->updateAutoImporterTable(); } if (version_compare($lastVersion, '2.4.1', '<')) { $this->simplifyAutoloader(); } update_option('vxcash_plugin_version', $this->version); } } /** * Change existing Links to VISIT-X inside posts and meta data to more valid link types */ private function changeAllVXLinks() { global $wpdb; $data = $wpdb->get_results("SELECT p.meta_id, p.post_id, p2.meta_value as hostid, p.meta_value as link FROM {$wpdb->postmeta} p LEFT JOIN {$wpdb->postmeta} p2 ON p.post_id = p2.post_id AND p2.meta_key = 'hostid' WHERE p.meta_key = 'link' AND p.meta_value LIKE '%visit-x.net/CAMS%'"); /** @var stdClass[] $data */ foreach ($data as $obj) { $name = '?s=' . $obj->hostid . '&'; $id = $obj->hostid; $post = $obj->post_id; $meta = $obj->meta_id; $link = $obj->link; $newLink = str_replace('CAMS/DE/Darsteller/' . $id . '?', $name, $link); $wpdb->update($wpdb->postmeta, array('meta_value' => $newLink), array('meta_id' => $meta)); $wpdb->query($wpdb->prepare('UPDATE ' . $wpdb->posts . " SET post_content = REPLACE(post_content,'CAMS/DE/Darsteller/%d?', %s) WHERE ID = %d", $id, $name, $post)); } } /** * Change hard links inside posts to new shorttag for automatic creation */ private function changeHardVXLinks() { global $wpdb; $ids = $wpdb->get_col('SELECT ID from ' . $wpdb->posts . ' WHERE post_content LIKE \'%visit-x.net%\''); foreach ($ids as $id) { $content = $wpdb->get_var('SELECT post_content FROM ' . $wpdb->posts . ' WHERE ID = ' . $id); $newContent = preg_replace('!https?://(www\.)?visit-x\.net/\?s=(\d+)[^\'"]*!', '[vxlinking id=$2]', $content); if ($content !== $newContent) { $wpdb->update($wpdb->posts, array('post_content' => $newContent), array('ID' => $id)); } } } /** * Change porme links to shortcodes */ private function changePornmeLinks() { global $wpdb; $ids = $wpdb->get_col('SELECT ID from ' . $wpdb->posts . ' WHERE post_content LIKE \'%www.pornme.pm%\' AND post_type = \'videos\''); foreach ($ids as $id) { $content = $wpdb->get_var('SELECT post_content FROM ' . $wpdb->posts . ' WHERE ID = ' . $id); $newContent = preg_replace('!https?://(www\.)?pornme.pm/([^\?"\']+)[^"\']*!', '[pmlinking]$2[/pmlinking]', $content); $customfields = get_post_custom($id); $link = $customfields['link'][0]; $newLink = preg_replace('!https?://(www\.)?pornme.pm/([^\?"\']+)[^"\']*!', '[pmlinking]$2[/pmlinking]', $link); if ($content !== $newContent) { $wpdb->update($wpdb->posts, array('post_content' => $newContent), array('ID' => $id)); update_post_meta($id, 'link', $newLink); } } } /** * Creates the BeiAnrufSexTables */ private function addBasTables() { global $wpdb; require_once ABSPATH . 'wp-admin' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'upgrade.php'; $numbersTable = $wpdb->prefix . Vxcash_Tablename_Enum::BAS_NUMBERS; $hostsTable = $wpdb->prefix . Vxcash_Tablename_Enum::BAS_HOSTS; $charset_collate = $wpdb->get_charset_collate(); $sql = "CREATE TABLE $numbersTable ( lang varchar(4) NOT NULL, content text NOT NULL, UNIQUE KEY lang (lang) ) $charset_collate"; dbDelta($sql); $sql2 = "CREATE TABLE $hostsTable ( hostid varchar(20) NOT NULL, content text NOT NULL, UNIQUE KEY hostid (hostid) ) $charset_collate"; dbDelta($sql2); } /** * */ private function removePorndoeTablesAndInfos() { global $wpdb; $videosTable = $wpdb->prefix . Vxcash_Tablename_Enum::PORNDOE_IMPORTED_VIDEOS; $importTable = $wpdb->prefix . Vxcash_Tablename_Enum::CRON_AUTOLOAD; $ids = $wpdb->get_col('SELECT postId FROM ' . $videosTable); foreach ($ids as $id) { // We force the time limit to reset, because this might take quite a while set_time_limit(30); wp_delete_post($id, true); } $wpdb->query("DROP TABLE IF EXISTS $videosTable"); $wpdb->query("DELETE FROM $importTable WHERE type = 'PORNDOEVIDEO'"); } /** * Adds the porndoe video protokoll */ private function addPorndoeTable() { // No longer } private function updateAutoImporterTable() { global $wpdb; require_once ABSPATH . 'wp-admin' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'upgrade.php'; $tableName = $wpdb->prefix . Vxcash_Tablename_Enum::CRON_AUTOLOAD; $charset_collate = $wpdb->get_charset_collate(); $sql = "CREATE TABLE $tableName ( id int(10) UNSIGNED NOT NULL AUTO_INCREMENT, type enum('HOST','VIDEO', 'VXVIDEO') NOT NULL, settings varchar(30000) NOT NULL, lastupdate timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, imported int(10) UNSIGNED NOT NULL DEFAULT '0', aktiv int(2) UNSIGNED NOT NULL DEFAULT '1', PRIMARY KEY (id), KEY type (type) ) $charset_collate"; dbDelta($sql); } /** * Extends the Livecams table with two additional columns for host removing */ private function extendLivecams() { global $wpdb; require_once ABSPATH . 'wp-admin' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'upgrade.php'; $tableName = $wpdb->prefix . Vxcash_Tablename_Enum::LIVECAMS; $charset_collate = $wpdb->get_charset_collate(); $sql = "CREATE TABLE $tableName ( id bigint(20) UNSIGNED NOT NULL, name varchar(50) NOT NULL, last_action int(10) UNSIGNED NOT NULL DEFAULT '1', action_time timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, page bigint(20) UNSIGNED NOT NULL, PRIMARY KEY (id), UNIQUE KEY name (name) ) $charset_collate"; dbDelta($sql); } private function addVxVideoTable() { global $wpdb; require_once ABSPATH . 'wp-admin' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'upgrade.php'; $tableName = $wpdb->prefix . Vxcash_Tablename_Enum::VX_VIDEOS; $charset_collate = $wpdb->get_charset_collate(); $sql = "CREATE TABLE $tableName ( id bigint(20) UNSIGNED NOT NULL, title varchar(150) NOT NULL, last_action int(10) UNSIGNED NOT NULL DEFAULT '1', action_time timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, page bigint(20) UNSIGNED NOT NULL, PRIMARY KEY (id) ) $charset_collate"; dbDelta($sql); } /** * Define Shortcodes to be used in all themes */ private function defineShortcodes() { add_shortcode('vxlinking', array(__CLASS__, 'doVxLinking')); add_shortcode('pmlinking', array(__CLASS__, 'doPmLinking')); add_shortcode('pdlinking', array(__CLASS__, 'doPdLinking')); add_shortcode('vxcashwmdata', array(__CLASS__, 'doAddWebmasterData')); } /** * Creates a VISIT-X Link * * @param array $atts * * @return string */ public static function doVxLinking( $atts ) { $attributes = shortcode_atts(array('id' => 0), $atts); $config = Vxcash_Config::getInstance(); if ($config->getVxDirectLink() !== '') { $url = $config->getVxDirectLink(); } else { $url = sprintf('https://www.visit-x.net?w=%s&ws=%s', $config->getWmid(), $config->getVxCampaignId() . '.wp'); } if (strpos($url, '?') === false) { $url .= '?'; } else { $url .= '&'; } if ($attributes['id'] !== 0) { $url .= 's=' . $attributes['id'] . '&'; } $url .= 'adtv=' . self::createAdtv() . '&'; if (strpos($url, 'visit-x.net') !== false) { $url .= 'pfm=1502'; } else { $url .= 'pfm=2107&successUrl=' . urlencode($config->getVxDirectLink()); } return $url; } /** * Creates a PornMe Link * * @param array $atts * @param string $content * * @return string */ public static function doPmLinking( $atts, $content = '' ) { $config = Vxcash_Config::getInstance(); $domain = $config->getPornmeDomain(); $url = sprintf('https://%s/%s?w=%s&ws=%s&adtv=%s', $domain, $content, $config->getWmid(), $config->getVxCampaignId() . '.wp', self::createAdtv()); return $url; } /** * Creates a PornDoe Link * * @param array $atts * @param string $content * * @return string */ public static function doPdLinking( $atts, $content = '' ) { $config = Vxcash_Config::getInstance(); $w = $config->getWmid(); $campaignId = $config->getPornDoeCampaignId(); $bind = strpos($content, '?') === false ? '?' : '&'; $url = $content . $bind . sprintf('w=%s&ws=%s&adtv=%s', $w, $campaignId . '.wp', self::createAdtv()); $iframe = sprintf('<iframe src="%s" frameborder="0" width="850" height="506" allowfullscreen="yes" scrolling="no"></iframe>', $url); return $iframe; } /** * @param array $atts * @param string $content * * @return string */ public static function doAddWebmasterData( $atts, $content = '' ) { $attributes = shortcode_atts(array('product' => ''), $atts); $config = Vxcash_Config::getInstance(); $w = $config->getWmid(); $ws = $config->getCampaignId(); switch ($attributes['product']) { case 'vx': $ws = $config->getVxCampaignId(); break; case 'pm': $ws = $config->getPmCampaignId(); break; case 'rs': $ws = $config->getResellerCampaignId(); break; case 'bas': $ws = $config->getBasCampaignId(); break; } $bind = strpos($content, '?') === false ? '?' : '&'; return $content . $bind . sprintf('w=%s&ws=%s&adtv=%s', $w, $ws . '.wp', self::createAdtv()); } /** * @return string */ public static function createAdtv() { $id = 8330; $random = mt_rand(hexdec('100000'), hexdec('ffffff')); $concat = $id . '_' . dechex($random); $hash = substr(md5($concat . 'wordpress'), 0 , 5); return $concat . '_' . $hash; } /** * @return bool */ private function hasPornme() { $hasPornme = get_option('vxcash.hasPornme', null); if ($hasPornme === null) { $tableName = $this->wpdb->prefix . Vxcash_Tablename_Enum::PORNME_IMPORTED_VIDEOS; $count = (int) $this->wpdb->get_var("SELECT COUNT(*) FROM $tableName WHERE 1"); $hasPornme = $count > 0; add_option('vxcash.hasPornme', $hasPornme); } return (bool) $hasPornme; } private function removePornmeTables() { global $wpdb; $hostTable = $wpdb->prefix . Vxcash_Tablename_Enum::PORNME_HOST_INFO; $keywordsTable = $wpdb->prefix . Vxcash_Tablename_Enum::PORNME_KEYWORDS; $importTable = $wpdb->prefix . Vxcash_Tablename_Enum::CRON_AUTOLOAD; $wpdb->query("DROP TABLE IF EXISTS $hostTable"); $wpdb->query("DROP TABLE IF EXISTS $keywordsTable"); $wpdb->query("DELETE FROM $importTable WHERE type = 'VIDEO'"); } private function simplifyAutoloader() { global $wpdb; require_once ABSPATH . 'wp-admin' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'upgrade.php'; $tableName = $wpdb->prefix . Vxcash_Tablename_Enum::CRON_AUTOLOAD; $charset_collate = $wpdb->get_charset_collate(); $sql = "CREATE TABLE $tableName ( id int(10) UNSIGNED NOT NULL AUTO_INCREMENT, type varchar(30) NOT NULL, settings varchar(30000) NOT NULL, lastupdate timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, imported int(10) UNSIGNED NOT NULL DEFAULT '0', aktiv int(2) UNSIGNED NOT NULL DEFAULT '1', PRIMARY KEY (id), KEY type (type) ) $charset_collate"; dbDelta($sql); } }
[-] class-vxcash-deactivator.php
[edit]
[-] index.php
[edit]
[-] class-vxcash-posttypes-enum.php
[edit]
[-] class-vxcash-tablename-enum.php
[edit]
[-] class-vxcash-vxhost-custom-posttype.php
[edit]
[-] class-vxcash-vxvideo-custom-posttype.php
[edit]
[-] class-vxcash-taxonomies.php
[edit]
[-] class-vxcash-activator.php
[edit]
[+]
..
[-] class-vxcash-pornme-custom-posttype.php
[edit]
[-] class-vxcash.php
[edit]
[-] class-vxcash-loader.php
[edit]
[-] class-vxcash-vxhost-state-enum.php
[edit]
[-] class-vxcash-i18n.php
[edit]