· 7 years ago · Nov 29, 2018, 10:52 AM
1<?php
2
3
4class Rational_Meta_Box
5{
6 private $screens = array('ads');
7 private $fields = array(
8 array('id' => 'sora_textarea', 'label' => 'Ad Code', 'type' => 'textarea')
9 );
10
11 /**
12 * Class construct method. Adds actions to their respective WordPress hooks.
13 */
14 public function __construct()
15 {
16 add_action('add_meta_boxes', array($this, 'add_meta_boxes'));
17 add_action('save_post', array($this, 'save_post'));
18 }
19
20 /**
21 * Hooks into WordPress' add_meta_boxes function.
22 * Goes through screens (post types) and adds the meta box.
23 */
24 public function add_meta_boxes()
25 {
26 foreach ($this->screens as $screen) {
27 add_meta_box('insert-ad-code', __('Insert Ad Code', 'rational-metabox'), array($this, 'add_meta_box_callback'), $screen, 'advanced', 'default');
28 }
29 }
30
31 /**
32 * Generates the HTML for the meta box
33 *
34 * @param object $post WordPress post object
35 */
36 public function add_meta_box_callback($post)
37 {
38 wp_nonce_field('insert_ad_code_data', 'insert_ad_code_nonce');
39 $this->generate_fields($post);
40 }
41
42 /**
43 * Generates the field's HTML for the meta box.
44 */
45 public function generate_fields($post)
46 {
47 $output = '';
48
49 foreach ($this->fields as $field) {
50 $label = '<label for="' . $field['id'] . '">' . $field['label'] . '</label>';
51 $db_value = get_post_meta($post->ID, 'insert_ad_code_' . $field['id'], true);
52
53 switch ($field['type']) {
54 case 'textarea':
55 $input = sprintf('<textarea class="large-text" id="%s" name="%s" rows="5">%s</textarea>', $field['id'], $field['id'], $db_value);
56 break;
57 }
58
59 $input = (, $field['type'] !== 'color' ? 'class="regular-text"' : '', $field['id'], $field['id'], $field['type'], $db_value);
60 $output .= $this->row_format($label, $input);
61 }
62
63 echo '<table class="form-table"><tbody>' . $output . '</tbody></table>';
64 }
65
66 /**
67 * Generates the HTML for table rows.
68 */
69 public function row_format($label, $input)
70 {
71 return sprintf('<tr><th scope="row">%s</th><td>%s</td></tr>', $label, $input);
72 }
73
74 /**
75 * Hooks into WordPress' save_post function
76 */
77 public function save_post($post_id)
78 {
79 if (!isset($_POST['insert_ad_code_nonce'])) {
80 return $post_id;
81 }
82
83 $nonce = $_POST['insert_ad_code_nonce'];
84
85 if (!wp_verify_nonce($nonce, 'insert_ad_code_data')) {
86 return $post_id;
87 }
88
89 if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
90 return $post_id;
91 }
92
93 foreach ($this->fields as $field) {
94 if (isset($_POST[$field['id']])) {
95 switch ($field['type']) {
96 case 'email':
97 $_POST[$field['id']] = sanitize_email($_POST[$field['id']]);
98 break;
99
100 case 'text':
101 $_POST[$field['id']] = sanitize_text_field($_POST[$field['id']]);
102 break;
103 }
104
105 update_post_meta($post_id, 'insert_ad_code_' . $field['id'], $_POST[$field['id']]);
106 }
107 else if ($field['type'] === 'checkbox') {
108 update_post_meta($post_id, 'insert_ad_code_' . $field['id'], '0');
109 }
110 }
111 }
112}
113
114function sora_ads()
115{
116 $labels = array('name' => _x('Ads', 'Post Type General Name', 'text_domain'), 'singular_name' => _x('Ads', 'Post Type Singular Name', 'text_domain'), 'menu_name' => __('Ads', 'text_domain'), 'name_admin_bar' => __('Ads', 'text_domain'), 'archives' => __('Ads Archives', 'text_domain'), 'parent_item_colon' => __('Parent Ads:', 'text_domain'), 'all_items' => __('All Ads', 'text_domain'), 'add_new_item' => __('Add New Ads', 'text_domain'), 'add_new' => __('Add New', 'text_domain'), 'new_item' => __('New Ads', 'text_domain'), 'edit_item' => __('Edit Ads', 'text_domain'), 'update_item' => __('Update Ads', 'text_domain'), 'view_item' => __('View Ads', 'text_domain'), 'search_items' => __('Search Ads', 'text_domain'), 'not_found' => __('Not found', 'text_domain'), 'not_found_in_trash' => __('Not found in Trash', 'text_domain'), 'featured_image' => __('Featured Image', 'text_domain'), 'set_featured_image' => __('Set featured image', 'text_domain'), 'remove_featured_image' => __('Remove featured image', 'text_domain'), 'use_featured_image' => __('Use as featured image', 'text_domain'), 'insert_into_item' => __('Insert into ads', 'text_domain'), 'uploaded_to_this_item' => __('Uploaded to this ads', 'text_domain'), 'items_list' => __('Adss list', 'text_domain'), 'items_list_navigation' => __('Adss list navigation', 'text_domain'), 'filter_items_list' => __('Filter ads list', 'text_domain'));
117 $args = array(
118 'label' => __('Ads', 'text_domain'),
119 'description' => __('Ads Management', 'text_domain'),
120 'labels' => $labels,
121 'supports' => array('title'),
122 'hierarchical' => false,
123 'public' => true,
124 'show_ui' => true,
125 'show_in_menu' => false,
126 'menu_position' => 5,
127 'show_in_admin_bar' => true,
128 'show_in_nav_menus' => true,
129 'can_export' => true,
130 'has_archive' => true,
131 'exclude_from_search' => false,
132 'publicly_queryable' => true,
133 'rewrite' => false,
134 'capability_type' => 'post'
135 );
136 register_post_type('Ads', $args);
137}
138
139function soralink_settings_link($actions, $file)
140{
141 if (false !== strpos($file, 'soralink')) {
142 $actions['settings'] = '<a href="admin.php?page=soralink_configuration">Configuration</a>';
143 }
144
145 return $actions;
146}
147
148function soralink_menu()
149{
150 add_menu_page('SoraLink Plugin Settings', 'SoraLink', 'administrator', 'soralink_configuration', 'soralink_configuration', 'dashicons-editor-code', 81);
151 add_submenu_page('soralink_configuration', 'SoraLink Configuration', 'Configuration', 'administrator', 'soralink_configuration', 'soralink_configuration');
152 add_submenu_page('soralink_configuration', 'Generate Link', 'Generate Link', 'administrator', 'soralink_generate', 'soralink_generate');
153 add_submenu_page('soralink_configuration', __('Bottom Ads', 'bottom-ads'), __('Bottom Ads', 'bottom-ads'), 'manage_options', 'edit.php?post_type=ads');
154 add_submenu_page('soralink_configuration', 'SoraLink Setup', 'Setup', 'administrator', 'soralink_setup', 'soralink_setup');
155 $submenu['soralink_configuration'][0][0] = 'Dashboard';
156 add_action('admin_init', 'register_soralink_settings');
157}
158
159function register_soralink_settings()
160{
161 register_setting('soralink-settings', 'soralinkkey');
162 register_setting('soralink-settings', 'soralinkkeycache');
163 register_setting('soralink-settings', 'secretkeyserver');
164 register_setting('soralink-settings', 'ads_top');
165 register_setting('soralink-settings', 'ads_content');
166 register_setting('soralink-settings', 'start_date');
167 register_setting('soralink-settings', 'end_date');
168 register_setting('soralink-settings', 'countdown');
169 register_setting('soralink-settings', 'countdowntop');
170 register_setting('soralink-settings', 'singlecountdown');
171}
172
173function soralink_configuration()
174{
175 function askVerifyAndSaveLicenseKey()
176 {
177 if (empty($_POST['soralinkkey'])) {
178 renderLicenseForm('Please enter a license key');
179 exit();
180 }
181 else {
182 $license_key = preg_replace('/[^A-Za-z0-9-_]/', '', trim($_POST['soralinkkey']));
183 }
184
185 $checker = new Am_LicenseChecker($license_key, API_URL);
186
187 if (!$checker->checkLicenseKey()) {
188 renderLicenseForm($checker->getMessage());
189 exit();
190 }
191 else {
192 update_option('soralinkkey', $license_key, '', 'yes');
193 return $license_key;
194 }
195 }
196 function renderLicenseForm($errorMsg = NULL)
197 {
198 echo ' <div class="update-nag notice" style="display: block;">';
199 echo $errorMsg;
200 echo '</div>' . "\n" . ' <form class="form" method="post" action="options.php">' . "\n" . ' ';
201 settings_fields('soralink-settings');
202 echo ' ';
203 do_settings_sections('soralink-settings');
204 echo ' <input type="text" name="soralinkkey" class="regular-text" value="';
205 echo esc_attr(get_option('soralinkkey'));
206 echo '" placeholder="Insert valid license..." />' . "\n" . ' ';
207 submit_button();
208 echo ' </form>' . "\n";
209 }
210 echo '<style>' . "\n" . '.wrap {' . "\n" . ' padding: 10px 20px;' . "\n" . ' order: 1px solid #e5e5e5;' . "\n" . ' -webkit-box-shadow: 0 1px 1px rgba(0,0,0,.04);' . "\n" . ' box-shadow: 0 1px 1px rgba(0,0,0,.04);' . "\n" . ' background: #fff;' . "\n" . '}' . "\n" . '.wrap h1 {' . "\n" . ' margin: -10px -20px;' . "\n" . ' margin-bottom: 10px;' . "\n" . ' padding: 10px 20px;' . "\n" . ' font-size: 17px;' . "\n" . ' font-weight: bold;' . "\n" . ' background: #F7F7F7;' . "\n" . ' border-bottom: 1px solid #EFEFEF;' . "\n" . '}' . "\n" . '</style>' . "\n" . '<div class="wrap">' . "\n" . '<h1>SoraLink Configuration</h1>' . "\n";
211 $license_key = get_option('soralinkkey');
212
213 if (!strlen($license_key)) {
214 $license_key = askVerifyAndSaveLicenseKey();
215 }
216
217 echo "\n" . '<form method="post" action="options.php">' . "\n" . ' ';
218 settings_fields('soralink-settings');
219 echo ' ';
220 do_settings_sections('soralink-settings');
221 echo ' <table class="form-table">' . "\n" . ' <tr valign="top">' . "\n" . ' <th scope="row">License</th>' . "\n" . ' <td><input type="text" name="soralinkkey" class="regular-text" value="';
222 echo esc_attr(get_option('soralinkkey'));
223 echo '" placeholder="Insert valid license..." /></td>' . "\n" . ' </tr>' . "\n" . ' <tr valign="top">' . "\n" . ' <th scope="row">Secret Key</th>' . "\n" . ' <td><input type="text" name="secretkeyserver" class="regular-text" value="';
224 echo esc_attr(get_option('secretkeyserver'));
225 echo '" placeholder="Insert your secret key..." /></td>' . "\n" . ' </tr>' . "\n" . ' <tr valign="top">' . "\n" . ' <th scope="row">Ads Top</th>' . "\n" . ' <td><textarea type="text/javascript" name="ads_top" rows="10" cols="50" value="';
226 echo esc_attr(get_option('ads_top'));
227 echo '" class="large-text code" placeholder="Place your ads code here. Recommended size 728x90">';
228 echo esc_attr(get_option('ads_top'));
229 echo '</textarea></td>' . "\n" . ' </tr>' . "\n" . ' <tr valign="top">' . "\n" . ' <th scope="row">Ads Content</th>' . "\n" . ' <td><textarea type="text/javascript" name="ads_content" rows="10" cols="50" value="';
230 echo esc_attr(get_option('ads_content'));
231 echo '" class="large-text code" placeholder="Place your ads code here. Recommended responsive size or 300x250">';
232 echo esc_attr(get_option('ads_content'));
233 echo '</textarea></td>' . "\n" . ' </tr>' . "\n" . ' <tr valign="top">' . "\n" . ' <th scope="row">Hide Ads by Range Date</th>' . "\n" . ' <td><input type="number" name="start_date" min="0" class="small-text" value="';
234 echo esc_attr(get_option('start_date'));
235 echo '" placeholder="start" />' . "\n\t" . '<label for="range">until</label>' . "\n\t" . '<input type="number" name="end_date" min="0" class="small-text" value="';
236 echo esc_attr(get_option('end_date'));
237 echo '" placeholder="end" />' . "\n\t" . '</td>' . "\n" . ' </tr>' . "\n" . ' <tr valign="top">' . "\n" . ' <th scope="row">Countdown Top</th>' . "\n" . ' <td><input type="number" name="countdowntop" min="1" class="small-text" value="';
238 echo esc_attr(get_option('countdowntop'));
239 echo '" /></td>' . "\n" . ' </tr>' . "\n" . ' <tr valign="top">' . "\n" . ' <th scope="row">Countdown Bottom</th>' . "\n" . ' <td><input type="number" name="countdown" class="small-text" value="';
240 echo esc_attr(get_option('countdown'));
241 echo '" /></td>' . "\n" . ' </tr>' . "\n" . ' <tr valign="top">' . "\n" . ' <th scope="row">Countdown Single</th>' . "\n" . ' <td><input type="number" name="singlecountdown" min="0" class="small-text" value="';
242 echo esc_attr(get_option('singlecountdown'));
243 echo '" /></td>' . "\n" . ' </tr>' . "\n" . ' </table> ' . "\n" . ' ';
244 submit_button();
245 echo "\n" . '</form>' . "\n" . '</div>' . "\n";
246}
247
248function soralink_generate()
249{
250 echo '<script language="javascript">' . "\n" . 'function select_all(obj) {' . "\n" . ' var text_val=eval(obj);' . "\n" . ' text_val.focus();' . "\n" . ' text_val.select();' . "\n" . ' if (!document.all) return; // IE only' . "\n" . ' r = text_val.createTextRange();' . "\n" . ' r.execCommand(\'copy\');' . "\n" . '}' . "\n" . 'function generatelink()' . "\n" . '{' . "\n" . 'var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){var t="";var n,r,i,s,o,u,a;var f=0;e=Base64._utf8_encode(e);while(f<e.length){n=e.charCodeAt(f++);r=e.charCodeAt(f++);i=e.charCodeAt(f++);s=n>>2;o=(n&3)<<4|r>>4;u=(r&15)<<2|i>>6;a=i&63;if(isNaN(r)){u=a=64}else if(isNaN(i)){a=64}t=t+this._keyStr.charAt(s)+this._keyStr.charAt(o)+this._keyStr.charAt(u)+this._keyStr.charAt(a)}return t},decode:function(e){var t="";var n,r,i;var s,o,u,a;var f=0;e=e.replace(/[^A-Za-z0-9\\+\\/\\=]/g,"");while(f<e.length){s=this._keyStr.indexOf(e.charAt(f++));o=this._keyStr.indexOf(e.charAt(f++));u=this._keyStr.indexOf(e.charAt(f++));a=this._keyStr.indexOf(e.charAt(f++));n=s<<2|o>>4;r=(o&15)<<4|u>>2;i=(u&3)<<6|a;t=t+String.fromCharCode(n);if(u!=64){t=t+String.fromCharCode(r)}if(a!=64){t=t+String.fromCharCode(i)}}t=Base64._utf8_decode(t);return t},_utf8_encode:function(e){e=e.replace(/\\r\\n/g,"\\n");var t="";for(var n=0;n<e.length;n++){var r=e.charCodeAt(n);if(r<128){t+=String.fromCharCode(r)}else if(r>127&&r<2048){t+=String.fromCharCode(r>>6|192);t+=String.fromCharCode(r&63|128)}else{t+=String.fromCharCode(r>>12|224);t+=String.fromCharCode(r>>6&63|128);t+=String.fromCharCode(r&63|128)}}return t},_utf8_decode:function(e){var t="";var n=0;var r=c1=c2=0;while(n<e.length){r=e.charCodeAt(n);if(r<128){t+=String.fromCharCode(r);n++}else if(r>191&&r<224){c2=e.charCodeAt(n+1);t+=String.fromCharCode((r&31)<<6|c2&63);n+=2}else{c2=e.charCodeAt(n+1);c3=e.charCodeAt(n+2);t+=String.fromCharCode((r&15)<<12|(c2&63)<<6|c3&63);n+=3}}return t}}' . "\n" . 'generate=document.glink.generate.value;' . "\n" . 'encodedString = Base64.encode(generate);' . "\n" . 'document.glink.result.value=\'';
251 echo get_site_url();
252 echo '/?r=\'+encodedString+\'#landing\';' . "\n" . '}' . "\n" . '</script>' . "\n" . '<div class="wrap">' . "\n" . '<h1>Generate Link</h1>' . "\n" . '<form name="glink">' . "\n" . ' <table class="form-table">' . "\n" . ' <tr valign="top">' . "\n" . ' <th scope="row">Generate</th>' . "\n" . ' <td>' . "\n" . ' ' . "\t" . '<input type="url" name="generate" class="regular-text" size="60" placeholder="Insert url here..." />' . "\n" . ' ' . "\t" . '<input type="button" name="go" id="submit" class="button button-primary" value="Go" onclick="generatelink()">' . "\n" . ' </td>' . "\n" . ' </tr>' . "\n" . ' <tr valign="top">' . "\n" . ' <th scope="row">Result</th>' . "\n" . ' <td>' . "\n" . ' ' . "\t" . '<input type="text" name="result" class="large-text" placeholder="result generate link" onclick="select_all(this)" readonly/>' . "\n" . ' </td>' . "\n" . ' </tr>' . "\n" . ' </table>' . "\n" . ' </form>' . "\n" . '</div>' . "\n";
253}
254
255function soralink_setup()
256{
257 echo '<div class="wrap">' . "\n" . '<script type="text/javascript">' . "\n" . ' function select_all(obj) {' . "\n" . ' var text_val=eval(obj);' . "\n" . ' text_val.focus();' . "\n" . ' text_val.select();' . "\n" . ' if (!document.all) return; // IE only' . "\n" . ' r = text_val.createTextRange();' . "\n" . ' r.execCommand(\'copy\');' . "\n" . ' }' . "\n" . '</script>' . "\n" . '<h1>SoraLink Setup</h1>' . "\n" . '<h2>Installation</h2>' . "\n" . 'Place this code <b>after</b> <?php get_header(); ?> in index.php theme.<br>' . "\n" . '<input type="text" class="large-text code" value="<?php if(function_exists(\'humancheck_sora\')){humancheck_sora(\'Human Verification\',1);} ?>" onclick="select_all(this)" readonly /><br><br>' . "\n" . 'Place this code <b>after</b> <?php get_header(); ?> in single.php theme.<br>' . "\n" . '<input type="text" class="large-text code" value="<?php if(function_exists(\'start_sora\')){start_sora();} ?>" onclick="select_all(this)" readonly /><br><br>' . "\n" . 'Place this code <b>before</b> <?php get_footer(); ?> in single.php theme.<br>' . "\n" . '<input type="text" class="large-text code" value="<?php if(function_exists(\'end_sora\')){end_sora();} ?>" onclick="select_all(this)" readonly /><br><br>' . "\n" . 'Place this code <b>after</b> <?php get_header(); ?> in single.php theme <b>(if using single button)</b>.<br>' . "\n" . '<input type="text" class="large-text code" value="<?php if(function_exists(\'single_sora\')){single_sora();} ?>" onclick="select_all(this)" readonly /><br><br>' . "\n" . '<h2>Autolink Script</h2>' . "\n" . 'use this script if <b>SoraLink Client</b> not working<br><br>' . "\n" . '<textarea type="text/javascript" class="large-text code" rows="7" cols="50" onclick="select_all(this)" readonly>' . "\n" . '<script type="text/javascript" src="';
258 echo get_site_url();
259 echo '/wp-content/plugins/soralink/assets/js/sora.php"></script>' . "\n" . '<script type="text/javascript">' . "\n" . 'protected_links = "";' . "\n" . 'auto_safelink();' . "\n" . '</script></textarea><br/>' . "\n" . '<br/>' . "\n" . '</div>' . "\n";
260}
261
262ini_set('display_errors', false);
263error_reporting(32767);
264new Rational_Meta_Box();
265add_action('init', 'sora_ads', 0);
266add_filter('plugin_action_links', 'soralink_settings_link', 2, 2);
267add_action('admin_menu', 'soralink_menu');
268
269
270
271 function sora_client_encrypt_decrypt_xxxxxxxxx($action, $string)
272 {
273 $output = false;
274 $encrypt_method = 'AES-256-CBC';
275 $secret_key = md5(get_option('secretkeyserver'));
276 $secret_iv = get_option('secretkeyserver');
277 $key = hash('sha256', $secret_key);
278 $iv = substr(hash('sha256', $secret_iv), 0, 16);
279
280 if ($action == 'encrypt') {
281 $output = openssl_encrypt($string, $encrypt_method, $key, 0, $iv);
282 $output = base64_encode($output);
283 }
284 else if ($action == 'decrypt') {
285 $output = openssl_decrypt(base64_decode($string), $encrypt_method, $key, 0, $iv);
286 }
287
288 return $output;
289 }
290 function delayjs()
291 {
292 $cd = get_option('countdown');
293 if (($cd == '0') || ($cd == '')) {
294 $cd = 5;
295 }
296 else {
297 $cd = get_option('countdown');
298 }
299
300 if (isset($_POST['d'])) {
301 echo '<script type=\'text/javascript\'>' . "\n" . 'function generate(){$("#showlink").delay(';
302 echo $cd;
303 echo '000).fadeIn("fast");$("#pleasewaits").fadeIn("fast");var timer=setInterval(function(){$("#pleasewaits").fadeOut("fast")},';
304 echo $cd;
305 echo '000);}function base64_decode(w){var m,b,z,k,x,q,A,y,v="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",s=0,j=0,u="",p=[];if(!w){return w}w+="";do{k=v.indexOf(w.charAt(s++)),x=v.indexOf(w.charAt(s++)),q=v.indexOf(w.charAt(s++)),A=v.indexOf(w.charAt(s++)),y=k<<18|x<<12|q<<6|A,m=y>>16&255,b=y>>8&255,z=255&y,64==q?p[j++]=String.fromCharCode(m):64==A?p[j++]=String.fromCharCode(m,b):p[j++]=String.fromCharCode(m,b,z)}while(s<w.length);return u=p.join(""),decodeURIComponent(escape(u.replace(/\\0+$/,"")))}function changeLink(){var a=base64_decode("';
306 echo $_POST['d'];
307 echo '");window.open(a,"_blank")};' . "\n" . '</script>' . "\n";
308 }
309 else if (isset($_POST['get'])) {
310 echo '<script type=\'text/javascript\'>' . "\n" . 'function generate(){$("#showlink").delay(';
311 echo $cd;
312 echo '000).fadeIn("fast");$("#pleasewaits").fadeIn("fast");var timer=setInterval(function(){$("#pleasewaits").fadeOut("fast")},';
313 echo $cd;
314 echo '000);}function changeLink(){var a=\'';
315 echo sora_client_encrypt_decrypt_xxxxxxxxx('decrypt', $_POST['get']);
316 echo '\';window.open(a,"_blank")};' . "\n" . '</script>' . "\n";
317 }
318 }
319 function humancheck_sora($halo, $status)
320 {
321 if (isset($_GET['r']) || isset($_GET['id'])) {
322 $args = array('post_type' => 'post', 'orderby' => 'rand', 'posts_per_page' => 1, 'no_found_rows' => true, 'update_post_term_cache' => false, 'update_post_meta_cache' => false, 'cache_results' => false);
323 $the_query = new WP_Query($args);
324
325 if ($the_query->have_posts()) {
326 while ($the_query->have_posts()) {
327 $the_query->the_post();
328 echo '<div class="humancheck" id="srl">' . "\n\t" . '<div class="helloworld">';
329 echo $halo;
330 echo '</div>' . "\n\t" . '<form action="';
331 the_permalink();
332 echo '" method="post">' . "\n\t\t";
333
334 if (isset($_GET['r'])) {
335 echo "\t\t\t" . '<input type="hidden" name="d" value="';
336 echo $_GET['r'];
337 echo '">' . "\n\t\t";
338 }
339 else if (isset($_GET['id'])) {
340 echo "\t\t\t" . '<input type="hidden" name="get" value="';
341 echo $_GET['id'];
342 echo '">' . "\n\t\t";
343 }
344
345 echo "\t" . ' <input class="sorasubmit" type="submit" value="Submit">' . "\n\t" . '</form>' . "\n" . '</div>' . "\n";
346 }
347 }
348
349 if ($status == 1) {
350 exit();
351 }
352 }
353 }
354 function start_sora()
355 {
356 if (isset($_POST['d']) || isset($_POST['get'])) {
357 echo "\t\t" . '<div id="landing" class="soractrl">' . "\n";
358 $now = date('d');
359 $start = get_option('start_date');
360 $end = get_option('end_date');
361
362 if (true === in_array($now, range($start, $end))) {
363 }
364 else {
365 echo "\t\t\t" . '<div class="adsora">';
366 $top = get_option('ads_top');
367
368 if ($top) {
369 echo $top;
370 }
371
372 echo '</div>' . "\n";
373 }
374
375 $cdx = get_option('countdowntop');
376 echo '<script>' . "\n" . ' var timeout,interval' . "\n" . ' var threshold = ';
377 echo $cdx;
378 echo '000;' . "\n" . ' var secondsleft=threshold;' . "\n\n" . ' window.onload = function()' . "\n" . ' {' . "\n" . ' startschedule();' . "\n" . ' }' . "\n\n" . ' function startChecking()' . "\n" . ' {' . "\n" . ' secondsleft-=1000;' . "\n" . ' document.querySelector(".wait"); ' . "\n" . ' if(secondsleft == 0)' . "\n" . ' {' . "\n" . ' //document.getElementById("clickme").style.display="";' . "\n" . ' clearInterval(interval);' . "\n" . ' document.querySelector(".wait").style.display="none";' . "\n" . ' document.querySelector(".to").style.display="";' . "\n" . ' }' . "\n" . ' }' . "\n" . ' function startschedule()' . "\n" . ' {' . "\n" . ' clearInterval(interval);' . "\n" . ' secondsleft=threshold;' . "\n" . ' document.querySelector(".wait"); ' . "\n" . ' interval = setInterval(function()' . "\n" . ' {' . "\n" . ' startChecking();' . "\n" . ' },1000) ' . "\n" . ' }' . "\n\n" . ' function resetTimer()' . "\n" . ' {' . "\n" . ' startschedule();' . "\n" . ' }' . "\n" . '</script>' . "\n" . ' <div class="wait">' . "\n" . ' ' . "\t" . '<center><img id="pleasewait" src="';
379 bloginfo('url');
380 echo '/wp-content/plugins/soralink/assets/img/wait.png" /></center>' . "\n" . ' </div>' . "\n\t\t\t" . '<div class="to" style="display: none;">' . "\n\t\t\t\t" . '<a href="#generate" onclick="generate()"><img src="';
381 bloginfo('url');
382 echo '/wp-content/plugins/soralink/assets/img/start.png" /></a>' . "\n\t\t\t" . '</div>' . "\n\t\t" . '</div>' . "\n\t";
383 }
384 }
385 function end_sora()
386 {
387 if (isset($_POST['d']) || isset($_POST['get'])) {
388 echo "\t\t" . '<div class="soractrl">' . "\n\t\t\t" . '<div id="generate"></div>' . "\n" . ' <center><img id="pleasewaits" style="display: none;" src="';
389 bloginfo('url');
390 echo '/wp-content/plugins/soralink/assets/img/wait.png" /></center>' . "\n\t\t\t" . '<img class="spoint" id="showlink" onclick="changeLink()" style="display: none;" src="';
391 bloginfo('url');
392 echo '/wp-content/plugins/soralink/assets/img/end.png" />' . "\n";
393 $now = date('d');
394 $start = get_option('start_date');
395 $end = get_option('end_date');
396
397 if (true === in_array($now, range($start, $end))) {
398 }
399 else {
400 echo "\t\t" . '<div class="adsora">' . "\n\t\t\t";
401 $sorads = new WP_Query('post_type=ads&orderby=rand&showposts=1');
402
403 while ($sorads->have_posts()) {
404 $sorads->the_post();
405 $meta = get_post_meta(get_the_ID(), 'insert_ad_code_sora_textarea', true);
406 echo $meta;
407 }
408
409 echo "\t\t" . '</div>' . "\n";
410 }
411
412 echo "\t\t" . '</div>' . "\n\t";
413 }
414 }
415 function single_sora()
416 {
417 if (isset($_POST['d']) || isset($_POST['get'])) {
418 $now = date('d');
419 $start = get_option('start_date');
420 $end = get_option('end_date');
421
422 if (true === in_array($now, range($start, $end))) {
423 }
424 else {
425 echo ' <div class="adsora">';
426 $top = get_option('ads_top');
427
428 if ($top) {
429 echo $top;
430 }
431
432 echo '</div>' . "\n";
433 }
434
435 echo ' <div class="soractrl">' . "\n" . ' <div id="landing"></div>' . "\n";
436 $cdx = get_option('singlecountdown');
437
438 if ($cdx == '') {
439 $cdx = 0;
440 }
441
442 if ($cdx != '0') {
443 echo '<script>' . "\n" . ' var timeout,interval' . "\n" . ' var threshold = ';
444 echo $cdx;
445 echo '000;' . "\n" . ' var secondsleft=threshold;' . "\n\n" . ' window.onload = function()' . "\n" . ' {' . "\n" . ' startschedule();' . "\n" . ' }' . "\n\n" . ' function startChecking()' . "\n" . ' {' . "\n" . ' secondsleft-=1000;' . "\n" . ' document.querySelector(".wait"); ' . "\n" . ' if(secondsleft == 0)' . "\n" . ' {' . "\n" . ' //document.getElementById("clickme").style.display="";' . "\n" . ' clearInterval(interval);' . "\n" . ' document.querySelector(".wait").style.display="none";' . "\n" . ' document.querySelector(".to").style.display="";' . "\n" . ' }' . "\n" . ' }' . "\n" . ' function startschedule()' . "\n" . ' {' . "\n" . ' clearInterval(interval);' . "\n" . ' secondsleft=threshold;' . "\n" . ' document.querySelector(".wait"); ' . "\n" . ' interval = setInterval(function()' . "\n" . ' {' . "\n" . ' startChecking();' . "\n" . ' },1000) ' . "\n" . ' }' . "\n\n" . ' function resetTimer()' . "\n" . ' {' . "\n" . ' startschedule();' . "\n" . ' }' . "\n" . '</script>' . "\n";
446 }
447
448 echo ' <div class="wait" ';
449 if (($cdx == '0') || ($cdx == '')) {
450 echo 'style="display: none;"';
451 }
452
453 echo ' >' . "\n" . ' <center><img id="pleasewait" src="';
454 bloginfo('url');
455 echo '/wp-content/plugins/soralink/assets/img/wait.png" /></center>' . "\n" . ' </div>' . "\n" . ' <div class="to" ';
456
457 if ($cdx != '0') {
458 echo 'style="display: none;"';
459 }
460
461 echo ' >' . "\n" . ' <img class="spoint" id="showlink" onclick="changeLink()" src="';
462 bloginfo('url');
463 echo '/wp-content/plugins/soralink/assets/img/end.png" />' . "\n" . ' </div>' . "\n" . ' </div>' . "\n" . ' ';
464 }
465 }
466 function prefix_insert_post_ads($content)
467 {
468 $now = date('d');
469 $start = get_option('start_date');
470 $end = get_option('end_date');
471
472 if (true === in_array($now, range($start, $end))) {
473 $ad_code = '';
474 }
475 else {
476 $ad_code = '<div class="soractrl">' . get_option('ads_content') . '</div>';
477 }
478
479 if (is_single() && !is_admin()) {
480 return prefix_insert_after_paragraph($ad_code, 2, $content);
481 }
482
483 return $content;
484 }
485 function prefix_insert_after_paragraph($insertion, $paragraph_id, $content)
486 {
487 $closing_p = '</p>';
488 $paragraphs = explode($closing_p, $content);
489
490 foreach ($paragraphs as $index => $paragraph) {
491 if (trim($paragraph)) {
492 $paragraphs .= $index;
493 }
494
495 if ($paragraph_id == $index + 1) {
496 $paragraphs .= $index;
497 }
498 }
499
500 return implode('', $paragraphs);
501 }
502 add_action('wp_head', 'delayjs');
503 add_filter('the_content', 'prefix_insert_post_ads');
504
505
506?>