Version Description
[05/06/2013] =
- Improvement - Ability to setup custom text for LinkedIn attachments.
- Improvement - Ability to skip User Security Settings.
- Improvement - New User privilege - autopost without seeing options.
- Bug Fix - Google+ Community Pages category retrieval problems.
Download this release
Release Info
Developer | NextScripts |
Plugin | NextScripts: Social Networks Auto-Poster |
Version | 2.7.14 |
Comparing to | |
See all releases |
Code changes from version 2.6.3 to 2.7.14
- NextScripts_SNAP.php +388 -207
- img/ff-bg.png +0 -0
- img/ff16.png +0 -0
- img/rd-bg.png +0 -0
- img/rd16.png +0 -0
- img/tpz-bg.png +0 -0
- img/tpz16.png +0 -0
- img/vkPostTypesDiff6.png +0 -0
- img/wl-bg.png +0 -0
- img/wl16.png +0 -0
- img/yt-bg.png +0 -0
- img/yt16.png +0 -0
- inc-cl/apis/base_facebook.php +1 -0
- inc-cl/apis/facebook.php +1 -1
- inc-cl/apis/liOAuth.php +4 -3
- inc-cl/apis/xmlrpc-client.php +80 -1
- inc-cl/bg.php +39 -24
- inc-cl/di.php +30 -20
- inc-cl/dl.php +31 -20
- inc-cl/fb.api.php +61 -0
- inc-cl/fb.php +77 -83
- inc-cl/ff.php +202 -0
- inc-cl/gp.api.php +43 -0
- inc-cl/gp.php +84 -48
- inc-cl/ip.php +28 -18
- inc-cl/li.php +67 -32
- inc-cl/lj.php +42 -26
- inc-cl/pk.php +27 -18
- inc-cl/pn.php +24 -13
- inc-cl/su.php +35 -24
- inc-cl/tr.php +43 -30
- inc-cl/tw.api.php +53 -0
- inc-cl/tw.php +138 -61
- inc-cl/vb.php +30 -21
- inc-cl/vk.php +52 -26
- inc-cl/wp.php +36 -17
- inc-cl/yt.php +186 -0
- js/js.js +10 -2
- nxs_functions.php +278 -47
- readme.txt +152 -67
NextScripts_SNAP.php
CHANGED
@@ -4,14 +4,15 @@ Plugin Name: NextScripts: Social Networks Auto-Poster
|
|
4 |
Plugin URI: http://www.nextscripts.com/social-networks-auto-poster-for-wordpress
|
5 |
Description: This plugin automatically publishes posts from your blog to multiple accounts on Facebook, Twitter, and Google+ profiles and/or pages.
|
6 |
Author: Next Scripts
|
7 |
-
Version: 2.
|
8 |
Author URI: http://www.nextscripts.com
|
9 |
Copyright 2012 Next Scripts, Inc
|
10 |
*/
|
11 |
-
define( 'NextScripts_SNAP_Version' , '2.
|
12 |
//## Include All Available Networks
|
13 |
global $nxs_snapAvNts, $nxs_snapThisPageUrl, $nxs_plurl, $nxs_isWPMU, $nxs_tpWMPU;
|
14 |
-
$nxs_snapAvNts = array();
|
|
|
15 |
|
16 |
$nxs_snapThisPageUrl = admin_url().'options-general.php?page=NextScripts_SNAP.php';
|
17 |
$nxs_plurl = plugin_dir_url(__FILE__);
|
@@ -112,7 +113,7 @@ define('WP_ALLOW_MULTISITE', true);<br/>to<br/>define('WP_ALLOW_MULTISITE', fals
|
|
112 |
}
|
113 |
function showSNAutoPosterOptionsPage() { global $nxs_snapAvNts, $nxs_snapThisPageUrl, $nxsOne, $nxs_plurl, $nxs_isWPMU, $nxs_tpWMPU; $nxsOne = ''; $options = $this->nxs_options; //prr($options);
|
114 |
//if($acid==1) $options = $this->nxs_options; else { switch_to_blog($acid); $options = $this->getAPOptions(); }
|
115 |
-
if (isset($_POST['upload_NS_SNAutoPoster_settings'])) { if (get_magic_quotes_gpc()) {array_walk_recursive($_POST, 'nsx_stripSlashes');} array_walk_recursive($_POST, 'nsx_fixSlashes');
|
116 |
//## Import Settings
|
117 |
$secCheck = wp_verify_nonce($_POST['nxsChkUpl_wpnonce'], 'nxsChkUpl');
|
118 |
if ($secCheck!==false && isset($_FILES['impFileSettings_button']) && is_uploaded_file($_FILES['impFileSettings_button']['tmp_name'])) { $fileData = trim(file_get_contents($_FILES['impFileSettings_button']['tmp_name']));
|
@@ -121,9 +122,7 @@ define('WP_ALLOW_MULTISITE', true);<br/>to<br/>define('WP_ALLOW_MULTISITE', fals
|
|
121 |
}
|
122 |
}
|
123 |
|
124 |
-
|
125 |
-
|
126 |
-
if (isset($_POST['update_NS_SNAutoPoster_settings'])) { if (get_magic_quotes_gpc()) {array_walk_recursive($_POST, 'nsx_stripSlashes');} array_walk_recursive($_POST, 'nsx_fixSlashes');
|
127 |
//## Load Networks Settings
|
128 |
foreach ($nxs_snapAvNts as $avNt) if (isset($_POST[$avNt['lcode']])) { $clName = 'nxs_snapClass'.$avNt['code']; if (!isset($options[$avNt['lcode']])) $options[$avNt['lcode']] = array();
|
129 |
$ntClInst = new $clName(); $ntOpt = $ntClInst->setNTSettings($_POST[$avNt['lcode']], $options[$avNt['lcode']]); $options[$avNt['lcode']] = $ntOpt;
|
@@ -132,12 +131,22 @@ define('WP_ALLOW_MULTISITE', true);<br/>to<br/>define('WP_ALLOW_MULTISITE', fals
|
|
132 |
if (isset($_POST['nxsHTDP'])) $options['nxsHTDP'] = $_POST['nxsHTDP'];
|
133 |
if (isset($_POST['ogImgDef'])) $options['ogImgDef'] = $_POST['ogImgDef'];
|
134 |
if (isset($_POST['featImgLoc'])) $options['featImgLoc'] = $_POST['featImgLoc'];
|
135 |
-
if (isset($_POST['
|
|
|
|
|
|
|
136 |
|
137 |
if (isset($_POST['nxsURLShrtnr']))$options['nxsURLShrtnr'] = $_POST['nxsURLShrtnr'];
|
138 |
if (isset($_POST['bitlyUname'])) $options['bitlyUname'] = $_POST['bitlyUname'];
|
139 |
if (isset($_POST['bitlyAPIKey'])) $options['bitlyAPIKey'] = $_POST['bitlyAPIKey'];
|
140 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
|
142 |
if (isset($_POST['nsOpenGraph'])) $options['nsOpenGraph'] = $_POST['nsOpenGraph']; else $options['nsOpenGraph'] = 0;
|
143 |
if (isset($_POST['imgNoCheck'])) $options['imgNoCheck'] = 0; else $options['imgNoCheck'] = 1;
|
@@ -158,10 +167,17 @@ define('WP_ALLOW_MULTISITE', true);<br/>to<br/>define('WP_ALLOW_MULTISITE', fals
|
|
158 |
$cIds = get_all_category_ids(); if(is_array($pk) && $cIds) $options['exclCats'] = serialize(array_diff($cIds, $pk)); else $options['exclCats'] = '';
|
159 |
} //prr($options['exclCats']);
|
160 |
if (!isset($_POST['whoCanSeeSNAPBox'])) $_POST['whoCanSeeSNAPBox'] = array(); $_POST['whoCanSeeSNAPBox'][] = 'administrator';
|
161 |
-
if (isset($_POST['whoCanSeeSNAPBox'])) $options['whoCanSeeSNAPBox'] = $_POST['whoCanSeeSNAPBox'];
|
162 |
-
if (
|
163 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
foreach ($options['whoCanSeeSNAPBox'] as $uRole) { $role = get_role($uRole); $role->add_cap('see_snap_box'); }
|
|
|
165 |
|
166 |
update_option($this->dbOptionsName, $options); // prr($options);
|
167 |
?><div class="updated"><p><strong><?php _e("Settings Updated.", 'nxs_snap');?></strong></p></div><?php
|
@@ -170,7 +186,7 @@ define('WP_ALLOW_MULTISITE', true);<br/>to<br/>define('WP_ALLOW_MULTISITE', fals
|
|
170 |
|
171 |
$category_ids = get_all_category_ids(); if(isset($options['exclCats'])) $pk = maybe_unserialize($options['exclCats']); else $pk = '';
|
172 |
if ( is_array($category_ids) && is_array($pk) && count($category_ids) == count($pk)) { ?>
|
173 |
-
<div class="error" id="message"><p><strong>All your categories are excluded from auto-posting.</strong> Nothing will be auto-posted. Please Click "
|
174 |
<?php }
|
175 |
|
176 |
if(!$nxs_isWPMU) $this->NS_SNAP_ShowPageTop(); ?>
|
@@ -183,7 +199,7 @@ if ( is_array($category_ids) && is_array($pk) && count($category_ids) == count($
|
|
183 |
|
184 |
<ul class="nsx_tabs">
|
185 |
<li><a href="#nsx_tab1">Your Social Networks Accounts</a></li>
|
186 |
-
<li><a href="#nsx_tab2"
|
187 |
<?php if ((function_exists("nxs_showPRXTab")) && (int)$options['showPrxTab'] == 1) { ?> <li><a href="#nsx_tab5">Proxies</a></li> <?php } ?>
|
188 |
<li><a href="#nsx_tab3">Log/History</a></li>
|
189 |
<li><a href="#nsx_tab4">Help/Support</a></li>
|
@@ -205,6 +221,7 @@ if ( is_array($category_ids) && is_array($pk) && count($category_ids) == count($
|
|
205 |
|
206 |
</div>
|
207 |
|
|
|
208 |
<div id="showCatSel" style="display: none;background-color: #fff; width: 300px; padding: 25px;"><span class="nxspButton bClose"><span>X</span></span>Select Categories:
|
209 |
<div id="fbSelCats<?php echo $ii; ?>" class="categorydivInd" style="padding-left: 15px; background-color: #fff;">
|
210 |
<a href="#" onclick="nxs_chAllCatsL(1, 'fbSelCats<?php echo $ii; ?>'); return false;">Check all</a> | <a href="#" onclick="nxs_chAllCatsL(0, 'fbSelCats<?php echo $ii; ?>'); return false;">UnCheck all</a>
|
@@ -220,34 +237,66 @@ if ( is_array($category_ids) && is_array($pk) && count($category_ids) == count($
|
|
220 |
foreach ($nxs_snapAvNts as $avNt) { $clName = 'nxs_snapClass'.$avNt['code']; $ntClInst = new $clName();
|
221 |
if ( isset($options[$avNt['lcode']]) && count($options[$avNt['lcode']])>0) { $ntClInst->showGenNTSettings($options[$avNt['lcode']]); } // else $ntClInst->showNewNTSettings(0);
|
222 |
}
|
223 |
-
if ($isNoNts) { ?><br/><br/><br/>You don't have any configured social networks yet. Please click "Add new account" button
|
|
|
|
|
224 |
|
225 |
<div style="float: right; padding: 1.5em;">
|
226 |
|
227 |
<input onclick="nxs_expSettings(); return false;" type="button" class="button" name="expSettings_repostButton" id="expSettings_button" value="<?php _e('Export Settings', 'nxs_snap') ?>" />
|
228 |
<input onclick="jQuery('#impFileSettings_button').click(); return false;" type="button" class="button" name="impSettings_repostButton" id="impSettings_button" value="<?php _e('Import Settings', 'nxs_snap') ?>" />
|
229 |
</div>
|
230 |
-
|
231 |
<div class="submit"><input type="submit" id="nxs-button-primary-submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div>
|
232 |
|
233 |
<?php } ?>
|
234 |
</div> <!-- END TAB -->
|
235 |
<div id="nsx_tab2" class="nsx_tab_content">
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
<
|
243 |
-
<b>"
|
244 |
-
<b>"Scheduled"</b> - Releases the page immediately back to you, so you can proceed with something else and it schedules all auto-posting jobs to your WP-Cron. This is much faster and much more efficient, but it could not work if your WP-Cron is disabled or broken.
|
245 |
</div>
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
251 |
|
252 |
foreach ( $editable_roles as $role => $details ) { $name = translate_user_role($details['name'] ); echo '<input type="checkbox" ';
|
253 |
if (in_array($role, $options['whoCanSeeSNAPBox']) || $role=='administrator') echo ' checked="checked" '; if ($role=='administrator' || $role=='subscriber') echo ' disabled="disabled" ';
|
@@ -260,49 +309,43 @@ if ( is_array($category_ids) && is_array($pk) && count($category_ids) == count($
|
|
260 |
echo '<br/>';
|
261 |
} ?>
|
262 |
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
|
|
|
|
|
|
|
|
|
|
274 |
$args=array('public'=>true, '_builtin'=>false); $output = 'names'; $operator = 'and'; $post_types = array(); if (function_exists('get_post_types')) $post_types=get_post_types($args, $output, $operator);
|
275 |
if ($options['nxsCPTSeld']!='') $nxsCPTSeld = unserialize($options['nxsCPTSeld']); else $nxsCPTSeld = array_keys($post_types);
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
<
|
293 |
-
|
294 |
-
|
295 |
-
}
|
296 |
-
(function($) {
|
297 |
-
$(function() {
|
298 |
-
$('.button-primary[name="update_NS_SNAutoPoster_settings"]').bind('click', function(e) { var str = $('input[name="post_category[]"]').serialize(); $('div.categorydivInd').replaceWith('<input type="hidden" name="pcInd" value="" />');
|
299 |
-
str = str.replace(/post_category/g, "pk"); $('div.categorydiv').replaceWith('<input type="hidden" name="post_category" value="'+str+'" />');
|
300 |
-
});
|
301 |
-
});
|
302 |
-
})(jQuery);
|
303 |
-
</script>
|
304 |
-
|
305 |
-
<a href="#" onclick="nxs_chAllCats(1); return false;">Check all</a> | <a href="#" onclick="nxs_chAllCats(0); return false;">UnCheck all</a>
|
306 |
|
307 |
<div id="taxonomy-category" class="categorydiv">
|
308 |
<div id="category-all" class="tabs-panel"><input type='hidden' name='post_category[]' value='0' />
|
@@ -315,86 +358,129 @@ function nxs_chAllCats(ch){
|
|
315 |
</ul>
|
316 |
</div>
|
317 |
</div>
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
<br/>
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
327 |
bit.ly Username: <input name="bitlyUname" style="width: 20%;" value="<?php if (isset($options['bitlyUname'])) _e(apply_filters('format_to_edit',$options['bitlyUname']), 'nxs_snap') ?>" /><br/>
|
328 |
-
bit.ly API Key: <input name="bitlyAPIKey" style="width: 20%;" value="<?php if (isset($options['bitlyAPIKey'])) _e(apply_filters('format_to_edit',$options['bitlyAPIKey']), 'nxs_snap') ?>"
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
<
|
333 |
-
|
334 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
335 |
<input name="riHowManyPostsToTrack" style="width: 50px;" value="<?php if (isset($options['riHowManyPostsToTrack'])) _e(apply_filters('format_to_edit', $options['riHowManyPostsToTrack']), 'nxs_snap'); else echo "10"; ?>" /> <br/>
|
336 |
|
337 |
-
<span style="font-size: 11px; margin-left: 1px;">Setting two many will degrade your website's
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
<h3 style="font-size: 14px; margin-bottom: 2px;">Additional URL Parameters<span style="font-size: 11px; color:red; padding-left: 5px; padding-right: 5px;">[<?php _e('New', 'nxs_snap') ?>]</span></h3> <span style="font-size: 11px; margin-left: 1px;">Will be added to backlinks. </span>
|
342 |
-
|
343 |
-
<p style="margin: 0px;margin-left: 5px;"><input name="addURLParams" style="width: 800px;" value="<?php if (isset($options['addURLParams'])) _e(apply_filters('format_to_edit', $options['addURLParams']), 'nxs_snap'); ?>" /> <br/>
|
344 |
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
|
|
|
|
|
|
|
|
|
|
366 |
<input name="ogImgDef" style="width: 30%;" value="<?php if (isset($options['ogImgDef'])) _e(apply_filters('format_to_edit',$options['ogImgDef']), 'nxs_snap') ?>" />
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
384 |
|
385 |
-
<?php if (function_exists("nxs_showPRXTab")) { ?>
|
386 |
-
|
387 |
-
<h3 style="font-size: 14px; margin-bottom: 2px;">Show "Proxies" Tab</h3>
|
388 |
-
|
389 |
<p style="margin: 0px;margin-left: 5px;"><input value="set" id="showPrxTab" name="showPrxTab" type="checkbox" <?php if ((int)$options['showPrxTab'] == 1) echo "checked"; ?> />
|
390 |
-
|
391 |
-
<span style="font-size: 11px; margin-left: 1px;">Advanced Setting. Check to enable "Proxies" tab where you can setup autoposting proxies.</span>
|
392 |
</p>
|
393 |
<?php } ?>
|
394 |
|
395 |
-
<div class="submit"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div>
|
396 |
-
|
397 |
</div>
|
|
|
398 |
<?php if ((function_exists("nxs_showPRXTab")) && (int)$options['showPrxTab'] == 1) { nxs_showPRXTab($options); } ?>
|
399 |
<div id="nsx_tab3" class="nsx_tab_content">
|
400 |
<div style="width:760px;">
|
@@ -402,12 +488,19 @@ Example: utm_source=%NTCODE%&utm_medium=%ACCNAME%&utm_campaign=SNAP%2Bfrom%2B%SI
|
|
402 |
|
403 |
Showing last 150 records <a href="#" onclick="nxs_clLog();return false;" class="NXSButton" id="nxs_clearLog">Clear Log</a><br/><br/>
|
404 |
<div style="overflow: auto; border: 1px solid #999; width: 750px; height: 600px; font-size: 11px;" class="logDiv" id="nxslogDiv">
|
405 |
-
<?php
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
411 |
</div>
|
412 |
|
413 |
<div id="nsx_tab4" class="nsx_tab_content">
|
@@ -519,12 +612,13 @@ Please see #4 and #5 for Twitter:<br/>
|
|
519 |
|
520 |
<form method="post" enctype="multipart/form-data" id="nsStFormUpl" action="<?php echo $nxs_snapThisPageUrl?>">
|
521 |
<input type="file" accept="text/plain" onchange="jQuery('#nsStFormUpl').submit();" id="impFileSettings_button" name="impFileSettings_button" style="display: block; visibility: hidden; width: 0; height: 0;" size="chars">
|
522 |
-
<input type="hidden" value="1" name="upload_NS_SNAutoPoster_settings" /> <?php wp_nonce_field( 'nxsChkUpl', 'nxsChkUpl_wpnonce' ); ?>
|
523 |
</form>
|
524 |
|
525 |
<br/> <br/> <?php
|
526 |
}
|
527 |
-
function showSNAutoPosterOptionsPagex() {
|
|
|
528 |
|
529 |
function NS_SNAP_ShowPageTop(){ global $nxs_snapAvNts, $nxs_snapThisPageUrl, $nxsOne, $nxs_plurl, $nxs_isWPMU; $nxsOne = ''; $options = $this->nxs_options;
|
530 |
$nxsOne = NextScripts_SNAP_Version; if (defined('NXSAPIVER')) $nxsOne .= " (<span id='nxsAPIUpd'>API</span> Version: ".NXSAPIVER.")"; ?>
|
@@ -553,9 +647,12 @@ Please see #4 and #5 for Twitter:<br/>
|
|
553 |
- <a target="_blank" href="http://www.nextscripts.com/social-networks-auto-poster-for-wp-multiple-accounts"><?php _e('Get', 'nxs_snap'); ?> PRO - Multiple Accounts Edition</a><br/><br/>
|
554 |
|
555 |
<?php _e('Here you can setup "Social Networks Auto Poster".', 'nxs_snap'); ?><br/> <?php _e('You can start by clicking "Add new account" button and choosing the Social Network you would like to add.', 'nxs_snap'); ?><?php }} ?><br/>
|
556 |
-
<?php
|
557 |
if (!function_exists('curl_init')) {
|
558 |
-
echo ("<br/><b style='font-size:16px; color:red;'>Error: No CURL Found</b> <
|
|
|
|
|
|
|
559 |
}
|
560 |
/*
|
561 |
if ((defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE==true) || (defined('MULTISITE') && MULTISITE==true) ) {
|
@@ -570,15 +667,17 @@ Please see #4 and #5 for Twitter:<br/>
|
|
570 |
<?php }
|
571 |
}
|
572 |
|
573 |
-
function NS_SNAP_SavePostMetaTags($id) { global $nxs_snapAvNts, $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
|
574 |
-
$post = get_post($id);
|
575 |
-
if (
|
576 |
-
if (
|
|
|
|
|
577 |
foreach ($nxs_snapAvNts as $avNt) {
|
578 |
if (count($options[$avNt['lcode']])>0 && isset($_POST[$avNt['lcode']]) && count($_POST[$avNt['lcode']])>0) { $savedMeta = maybe_unserialize(get_post_meta($id, 'snap'.$avNt['code'], true));
|
579 |
if(is_array($_POST[$avNt['lcode']])) { $ii=0;
|
580 |
-
foreach ($_POST[$avNt['lcode']] as $pst ) {
|
581 |
-
if (is_array($pst) && $pst['do'.$avNt['code']]=='') $_POST[$avNt['lcode']][$ii]['do'.$avNt['code']]= 0; $ii++;
|
582 |
}
|
583 |
} $newMeta = $_POST[$avNt['lcode']];
|
584 |
if (is_array($savedMeta) && is_array($newMeta)) $newMeta = nxsMergeArraysOV($savedMeta, $newMeta); // echo "##### ".$id."| snap".$avNt['code']; prr($savedMeta); echo "||"; prr($newMeta);// $newMeta = 'AAA';
|
@@ -597,7 +696,7 @@ Please see #4 and #5 for Twitter:<br/>
|
|
597 |
.underdash a:hover {border-bottom: 1px #21759B dashed}
|
598 |
</style>
|
599 |
|
600 |
-
<input value="
|
601 |
<div class="popShAtt" style="width: 200px;" id="popShAttSV"><?php _e('If you made any changes to the format, please "Update" the post before reposting', 'nxs_snap'); ?></div>
|
602 |
<?php if($post->post_status != "publish" ) { ?>
|
603 |
<div style="float: right;"> <input type="hidden" id="nxsLockIt" value="0" />
|
@@ -625,7 +724,7 @@ Please see #4 and #5 for Twitter:<br/>
|
|
625 |
}
|
626 |
}
|
627 |
|
628 |
-
if (class_exists("NS_SNAutoPoster")) { $plgn_NS_SNAutoPoster = new NS_SNAutoPoster();
|
629 |
//## Delete Account
|
630 |
if (!function_exists("ns_delNT_ajax")) { function ns_delNT_ajax(){ check_ajax_referer('nsDN'); $indx = (int)$_POST['id'];
|
631 |
global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
|
@@ -637,28 +736,46 @@ if (!function_exists("nsAuthFBSv_ajax")) { function nsAuthFBSv_ajax() { check_aj
|
|
637 |
}}
|
638 |
if (!function_exists("nsGetBoards_ajax")) {
|
639 |
function nsGetBoards_ajax() { global $nxs_gCookiesArr; check_ajax_referer('getBoards'); global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
|
640 |
-
if (get_magic_quotes_gpc()) { $_POST['u'] = stripslashes($_POST['u']); $_POST['p'] = stripslashes($_POST['p']);} $_POST['p'] = trim($_POST['p']); $u = trim($_POST['u']);
|
641 |
$loginError = doConnectToPinterest($_POST['u'], substr($_POST['p'], 0, 5)=='g9c1a'?nsx_doDecode(substr($_POST['p'], 5)):$_POST['p'] ); if ($loginError!==false) {echo $loginError; return "BAD USER/PASS";}
|
642 |
$gPNBoards = doGetBoardsFromPinterest(); $options['pn'][$_POST['ii']]['pnBoardsList'] = base64_encode($gPNBoards);
|
643 |
$options['pn'][$_POST['ii']]['pnSvC'] = serialize($nxs_gCookiesArr); if (is_array($options)) update_option('NS_SNAutoPoster', $options); echo $gPNBoards; die();
|
644 |
}
|
645 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
646 |
if (!function_exists("nsGetWLBoards_ajax")) {
|
647 |
function nsGetWLBoards_ajax() { global $nxs_gCookiesArr; check_ajax_referer('getWLBoards'); global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
|
648 |
-
if (get_magic_quotes_gpc()) { $_POST['u'] = stripslashes($_POST['u']); $_POST['p'] = stripslashes($_POST['p']);} $_POST['p'] = trim($_POST['p']); $u = trim($_POST['u']);
|
649 |
$loginError = doConnectToWaNeLo($_POST['u'], substr($_POST['p'], 0, 5)=='g9c1a'?nsx_doDecode(substr($_POST['p'], 5)):$_POST['p'] ); if ($loginError!==false) {echo $loginError; return "BAD USER/PASS";}
|
650 |
$gWLBoards = doGetBoardsFromWaNeLo(); $options['wl'][$_POST['ii']]['wlBoardsList'] = base64_encode($gWLBoards);
|
651 |
$options['wl'][$_POST['ii']]['wlSvC'] = serialize($nxs_gCookiesArr); if (is_array($options)) update_option('NS_SNAutoPoster', $options); echo $gWLBoards; die();
|
652 |
}
|
653 |
}
|
654 |
|
655 |
-
if (!function_exists("nxs_clLgo_ajax")) { function nxs_clLgo_ajax() { check_ajax_referer('nxsSsPageWPN');
|
656 |
-
update_option('NS_SNAutoPosterLog', '');
|
|
|
657 |
}}
|
658 |
|
659 |
if (!function_exists("nxs_rfLgo_ajax")) { function nxs_rfLgo_ajax() { check_ajax_referer('nxsSsPageWPN'); echo "Y:";
|
660 |
-
|
661 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
662 |
}}
|
663 |
|
664 |
//## Initialize the admin panel if the plugin has been activated
|
@@ -675,39 +792,51 @@ if (!function_exists("NS_SNAutoPoster_apx")) { function NS_SNAutoPoster_apx() {
|
|
675 |
}}}
|
676 |
|
677 |
//## Main Function to Post
|
678 |
-
if (!function_exists("nxs_snapPublishTo")) { function nxs_snapPublishTo($postArr, $type='', $aj=false) {
|
679 |
-
if (
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
|
|
|
|
|
|
|
|
686 |
$post = get_post($postID); $args=array( 'public' => true, '_builtin' => false); $output = 'names'; $operator = 'and'; $post_types = array(); if (function_exists('get_post_types')) $post_types=get_post_types($args, $output, $operator);
|
687 |
-
$
|
688 |
-
|
689 |
-
|
|
|
|
|
690 |
if ($options['nxsCPTSeld']!='') $nxsCPTSeld = unserialize($options['nxsCPTSeld']); else $nxsCPTSeld = array_keys($post_types); //prr($nxsCPTSeld);
|
691 |
-
$snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted=='1') return;
|
692 |
|
693 |
-
if ($post->post_type == 'post'
|
694 |
if (count($options[$avNt['lcode']])>0) { $clName = 'nxs_snapClass'.$avNt['code'];
|
695 |
-
if ($isPost) $po = $_POST[$avNt['lcode']]; else { $po = get_post_meta($postID, 'snap'.$avNt['code'], true); $po = maybe_unserialize($po);}
|
696 |
-
|
697 |
-
$
|
698 |
-
|
699 |
-
|
700 |
-
}
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
}
|
706 |
-
|
707 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
708 |
}
|
709 |
-
}
|
710 |
-
}}
|
711 |
|
712 |
//## AJAX to Post to Google+
|
713 |
|
@@ -736,31 +865,74 @@ if (!function_exists("ns_custom_types_setup")) { function ns_custom_types_setup(
|
|
736 |
}
|
737 |
}}
|
738 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
739 |
//## Format Message
|
740 |
-
if (!function_exists("nsFormatMessage")) { function nsFormatMessage($msg, $postID, $addURLParams=''){ global $ShownAds, $plgn_NS_SNAutoPoster; $post = get_post($postID); $options = $plgn_NS_SNAutoPoster->nxs_options;
|
|
|
741 |
$msg = stripcslashes($msg); if (isset($ShownAds)) $ShownAdsL = $ShownAds; // $msg = htmlspecialchars(stripcslashes($msg));
|
742 |
-
|
743 |
-
if (preg_match('%
|
|
|
|
|
|
|
744 |
if (preg_match('%IMG%', $msg)) { $imgURL = nxs_getPostImage($postID); $msg = str_ireplace("%IMG%", $imgURL, $msg); }
|
745 |
if (preg_match('%TITLE%', $msg)) { $title = nxs_doQTrans($post->post_title, $lng); $msg = str_ireplace("%TITLE%", $title, $msg); }
|
746 |
if (preg_match('%STITLE%', $msg)) { $title = nxs_doQTrans($post->post_title, $lng); $title = substr($title, 0, 115); $msg = str_ireplace("%STITLE%", $title, $msg); }
|
747 |
if (preg_match('%AUTHORNAME%', $msg)) { $aun = $post->post_author; $aun = get_the_author_meta('display_name', $aun ); $msg = str_ireplace("%AUTHORNAME%", $aun, $msg);}
|
|
|
|
|
|
|
|
|
|
|
748 |
if (preg_match('%TEXT%', $msg)) {
|
749 |
if ($post->post_excerpt!="") $excerpt = apply_filters('the_content', nxs_doQTrans($post->post_excerpt, $lng)); else $excerpt= apply_filters('the_content', nxs_doQTrans($post->post_content, $lng));
|
750 |
$excerpt = nsTrnc(strip_tags(strip_shortcodes($excerpt)), 300, " ", "..."); $msg = str_ireplace("%TEXT%", $excerpt, $msg);
|
751 |
}
|
|
|
|
|
|
|
|
|
752 |
if (preg_match('%RAWEXTEXT%', $msg)) {
|
753 |
if ($post->post_excerpt!="") $excerpt = nxs_doQTrans($post->post_excerpt, $lng); else $excerpt= nxs_doQTrans($post->post_content, $lng);
|
754 |
$excerpt = nsTrnc(strip_tags(strip_shortcodes($excerpt)), 300, " ", "..."); $msg = str_ireplace("%RAWEXTEXT%", $excerpt, $msg);
|
755 |
}
|
756 |
-
if (preg_match('%
|
|
|
|
|
|
|
|
|
|
|
|
|
757 |
if (preg_match('%CATS%', $msg)) { $t = wp_get_post_categories($postID); $cats = array(); foreach($t as $c){ $cat = get_category($c); $cats[] = str_ireplace('&','&',$cat->name); }
|
758 |
$ctts = implode(', ',$cats); $msg = str_ireplace("%CATS%", $ctts, $msg);
|
759 |
}
|
760 |
-
if (preg_match('%
|
761 |
-
|
762 |
-
|
763 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
764 |
if (preg_match('%FULLTEXT%', $msg)) { $postContent = apply_filters('the_content', nxs_doQTrans($post->post_content, $lng)); $msg = str_ireplace("%FULLTEXT%", $postContent, $msg);}
|
765 |
if (preg_match('%RAWTEXT%', $msg)) { $postContent = nxs_doQTrans($post->post_content, $lng); $msg = str_ireplace("%RAWTEXT%", $postContent, $msg);}
|
766 |
if (preg_match('%SITENAME%', $msg)) { $siteTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); $msg = str_ireplace("%SITENAME%", $siteTitle, $msg);}
|
@@ -771,7 +943,7 @@ if (!function_exists("nsFormatMessage")) { function nsFormatMessage($msg, $postI
|
|
771 |
if (!function_exists("nxs_adminInitFunc")) { function nxs_adminInitFunc(){ global $plgn_NS_SNAutoPoster, $nxs_snapThisPageUrl, $pagenow, $nxs_isWPMU;
|
772 |
$nxs_snapThisPageUrl = admin_url().($pagenow=='admin.php'?'network/':'').$pagenow.'?page=NextScripts_SNAP.php';
|
773 |
//## Javascript to Admin Panel
|
774 |
-
if (( ($pagenow=='options-general.php'||$pagenow=='admin.php')&& $_GET['page']=='NextScripts_SNAP.php') ||$pagenow=='post.php'||$pagenow=='post-new.php'){add_action('admin_head', 'jsPostToSNAP'); add_action('admin_head', 'nxs_jsPostToSNAP2');}
|
775 |
if (function_exists('nxsDoLic_ajax')) { add_action('wp_ajax_nxsDoLic', 'nxsDoLic_ajax'); }
|
776 |
if (function_exists('nxs_getInitUCheck') && (isset($plgn_NS_SNAutoPoster))) { $options = $plgn_NS_SNAutoPoster->nxs_options; if (is_array($options) && count($options)>1) nxs_getInitUCheck($options); }
|
777 |
|
@@ -866,6 +1038,8 @@ if (isset($plgn_NS_SNAutoPoster)) { //## Actions
|
|
866 |
add_action('admin_init', 'nxs_adminInitFunc');
|
867 |
add_action( 'admin_enqueue_scripts', 'nxssnap_enqueue_scripts' );
|
868 |
|
|
|
|
|
869 |
add_action('wp_ajax_nxs_clLgo', 'nxs_clLgo_ajax');
|
870 |
add_action('wp_ajax_nxs_rfLgo', 'nxs_rfLgo_ajax');
|
871 |
add_action('wp_ajax_nxs_prxTest', 'nxs_prxTest_ajax');
|
@@ -875,6 +1049,8 @@ if (isset($plgn_NS_SNAutoPoster)) { //## Actions
|
|
875 |
|
876 |
add_action('nxs_hourly_event', 'nxs_do_this_hourly');
|
877 |
add_action('wp', 'nxs_activation');
|
|
|
|
|
878 |
|
879 |
if ($isO || $isS) {
|
880 |
//## Whenever you publish a post, post to Social Networks
|
@@ -887,8 +1063,15 @@ if (isset($plgn_NS_SNAutoPoster)) { //## Actions
|
|
887 |
//## Add nxs_snapPublishTo to custom post types
|
888 |
add_action('wp_loaded', 'ns_custom_types_setup' );
|
889 |
foreach ($nxs_snapAvNts as $avNt) { add_action('ns_doPublishTo'.$avNt['code'], 'nxs_doPublishTo'.$avNt['code'], 1, 2); }
|
|
|
890 |
|
891 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
892 |
if ($isO) {
|
893 |
add_action('admin_menu', 'NS_SNAutoPoster_ap');
|
894 |
add_action('admin_init', 'nxs_adminInitFunc2');
|
@@ -902,15 +1085,13 @@ if (isset($plgn_NS_SNAutoPoster)) { //## Actions
|
|
902 |
add_action('save_post', array($plgn_NS_SNAutoPoster, 'NS_SNAP_SavePostMetaTags'));
|
903 |
add_action('edit_page_form', array($plgn_NS_SNAutoPoster, 'NS_SNAP_SavePostMetaTags'));
|
904 |
|
905 |
-
|
906 |
-
foreach ($nxs_snapAvNts as $avNt) { add_action('wp_ajax_rePostTo'.$avNt['code'], 'nxs_rePostTo'.$avNt['code'].'_ajax'); }
|
907 |
-
add_action('wp_ajax_getBoards' , 'nsGetBoards_ajax');
|
908 |
-
add_action('wp_ajax_getWLBoards' , 'nsGetWLBoards_ajax');
|
909 |
-
add_action('wp_ajax_nsDN', 'ns_delNT_ajax');
|
910 |
|
911 |
add_action('wp_ajax_nsAuthFBSv', 'nsAuthFBSv_ajax');
|
912 |
//## Custom Post Types and OG tags
|
913 |
add_filter('plugin_action_links','ns_add_settings_link', 10, 2 );
|
|
|
|
|
914 |
|
915 |
//## Scedulled Publish Calls
|
916 |
if ((int)$suOptions['nsOpenGraph'] == 1) {
|
4 |
Plugin URI: http://www.nextscripts.com/social-networks-auto-poster-for-wordpress
|
5 |
Description: This plugin automatically publishes posts from your blog to multiple accounts on Facebook, Twitter, and Google+ profiles and/or pages.
|
6 |
Author: Next Scripts
|
7 |
+
Version: 2.7.14
|
8 |
Author URI: http://www.nextscripts.com
|
9 |
Copyright 2012 Next Scripts, Inc
|
10 |
*/
|
11 |
+
define( 'NextScripts_SNAP_Version' , '2.7.14' ); require_once "nxs_functions.php";
|
12 |
//## Include All Available Networks
|
13 |
global $nxs_snapAvNts, $nxs_snapThisPageUrl, $nxs_plurl, $nxs_isWPMU, $nxs_tpWMPU;
|
14 |
+
if (!isset($nxs_snapAvNts) || !is_array($nxs_snapAvNts)) $nxs_snapAvNts = array(); $nxs_snapAPINts = array(); foreach (glob(plugin_dir_path( __FILE__ ).'inc-cl/*.php') as $filename){ require_once $filename; }
|
15 |
+
do_action('nxs_doSomeMore');
|
16 |
|
17 |
$nxs_snapThisPageUrl = admin_url().'options-general.php?page=NextScripts_SNAP.php';
|
18 |
$nxs_plurl = plugin_dir_url(__FILE__);
|
113 |
}
|
114 |
function showSNAutoPosterOptionsPage() { global $nxs_snapAvNts, $nxs_snapThisPageUrl, $nxsOne, $nxs_plurl, $nxs_isWPMU, $nxs_tpWMPU; $nxsOne = ''; $options = $this->nxs_options; //prr($options);
|
115 |
//if($acid==1) $options = $this->nxs_options; else { switch_to_blog($acid); $options = $this->getAPOptions(); }
|
116 |
+
if (isset($_POST['upload_NS_SNAutoPoster_settings'])) { if (get_magic_quotes_gpc() || $_POST['nxs_mqTest']=="\'") {array_walk_recursive($_POST, 'nsx_stripSlashes');} array_walk_recursive($_POST, 'nsx_fixSlashes');
|
117 |
//## Import Settings
|
118 |
$secCheck = wp_verify_nonce($_POST['nxsChkUpl_wpnonce'], 'nxsChkUpl');
|
119 |
if ($secCheck!==false && isset($_FILES['impFileSettings_button']) && is_uploaded_file($_FILES['impFileSettings_button']['tmp_name'])) { $fileData = trim(file_get_contents($_FILES['impFileSettings_button']['tmp_name']));
|
122 |
}
|
123 |
}
|
124 |
|
125 |
+
if (isset($_POST['update_NS_SNAutoPoster_settings'])) { if (get_magic_quotes_gpc() || $_POST['nxs_mqTest']=="\'") {array_walk_recursive($_POST, 'nsx_stripSlashes');} array_walk_recursive($_POST, 'nsx_fixSlashes');
|
|
|
|
|
126 |
//## Load Networks Settings
|
127 |
foreach ($nxs_snapAvNts as $avNt) if (isset($_POST[$avNt['lcode']])) { $clName = 'nxs_snapClass'.$avNt['code']; if (!isset($options[$avNt['lcode']])) $options[$avNt['lcode']] = array();
|
128 |
$ntClInst = new $clName(); $ntOpt = $ntClInst->setNTSettings($_POST[$avNt['lcode']], $options[$avNt['lcode']]); $options[$avNt['lcode']] = $ntOpt;
|
131 |
if (isset($_POST['nxsHTDP'])) $options['nxsHTDP'] = $_POST['nxsHTDP'];
|
132 |
if (isset($_POST['ogImgDef'])) $options['ogImgDef'] = $_POST['ogImgDef'];
|
133 |
if (isset($_POST['featImgLoc'])) $options['featImgLoc'] = $_POST['featImgLoc'];
|
134 |
+
if (isset($_POST['anounTagLimit'])) $options['anounTagLimit'] = $_POST['anounTagLimit'];
|
135 |
+
if (isset($_POST['featImgLocPrefix'])) $options['featImgLocPrefix'] = $_POST['featImgLocPrefix'];
|
136 |
+
if (isset($_POST['featImgLocArrPath'])) $options['featImgLocArrPath'] = $_POST['featImgLocArrPath'];
|
137 |
+
|
138 |
|
139 |
if (isset($_POST['nxsURLShrtnr']))$options['nxsURLShrtnr'] = $_POST['nxsURLShrtnr'];
|
140 |
if (isset($_POST['bitlyUname'])) $options['bitlyUname'] = $_POST['bitlyUname'];
|
141 |
if (isset($_POST['bitlyAPIKey'])) $options['bitlyAPIKey'] = $_POST['bitlyAPIKey'];
|
142 |
+
|
143 |
+
if (isset($_POST['YOURLSKey'])) $options['YOURLSKey'] = $_POST['YOURLSKey'];
|
144 |
+
if (isset($_POST['YOURLSURL'])) $options['YOURLSURL'] = $_POST['YOURLSURL'];
|
145 |
+
|
146 |
+
if (isset($_POST['gglAPIKey'])) $options['gglAPIKey'] = $_POST['gglAPIKey'];
|
147 |
+
|
148 |
+
if ($options['nxsURLShrtnr']=='B' && (trim($_POST['bitlyAPIKey'])=='' || trim($_POST['bitlyAPIKey'])=='')) $options['nxsURLShrtnr'] = 'G';
|
149 |
+
if ($options['nxsURLShrtnr']=='Y' && (trim($_POST['YOURLSKey'])=='' || trim($_POST['YOURLSURL'])=='')) $options['nxsURLShrtnr'] = 'G';
|
150 |
|
151 |
if (isset($_POST['nsOpenGraph'])) $options['nsOpenGraph'] = $_POST['nsOpenGraph']; else $options['nsOpenGraph'] = 0;
|
152 |
if (isset($_POST['imgNoCheck'])) $options['imgNoCheck'] = 0; else $options['imgNoCheck'] = 1;
|
167 |
$cIds = get_all_category_ids(); if(is_array($pk) && $cIds) $options['exclCats'] = serialize(array_diff($cIds, $pk)); else $options['exclCats'] = '';
|
168 |
} //prr($options['exclCats']);
|
169 |
if (!isset($_POST['whoCanSeeSNAPBox'])) $_POST['whoCanSeeSNAPBox'] = array(); $_POST['whoCanSeeSNAPBox'][] = 'administrator';
|
170 |
+
if (isset($_POST['whoCanSeeSNAPBox'])) $options['whoCanSeeSNAPBox'] = $_POST['whoCanSeeSNAPBox'];
|
171 |
+
if (!isset($_POST['whoCanMakePosts'])) $_POST['whoCanMakePosts'] = array(); $_POST['whoCanMakePosts'][] = 'administrator';
|
172 |
+
if (isset($_POST['whoCanMakePosts'])) $options['whoCanMakePosts'] = $_POST['whoCanMakePosts'];
|
173 |
+
|
174 |
+
if (isset($_POST['skipSecurity'])) $options['skipSecurity'] = 1; else $options['skipSecurity'] = 0;
|
175 |
+
|
176 |
+
if ($nxs_isWPMU && (!isset($options['suaMode'])||$options['suaMode'] == '')) $options['suaMode'] = $nxs_tpWMPU;
|
177 |
+
$editable_roles = get_editable_roles(); foreach ( $editable_roles as $roleX => $details ) {$role = get_role($roleX); $role->remove_cap('see_snap_box'); $role->remove_cap('make_snap_posts'); }
|
178 |
+
|
179 |
foreach ($options['whoCanSeeSNAPBox'] as $uRole) { $role = get_role($uRole); $role->add_cap('see_snap_box'); }
|
180 |
+
foreach ($options['whoCanMakePosts'] as $uRole) { $role = get_role($uRole); $role->add_cap('make_snap_posts'); }
|
181 |
|
182 |
update_option($this->dbOptionsName, $options); // prr($options);
|
183 |
?><div class="updated"><p><strong><?php _e("Settings Updated.", 'nxs_snap');?></strong></p></div><?php
|
186 |
|
187 |
$category_ids = get_all_category_ids(); if(isset($options['exclCats'])) $pk = maybe_unserialize($options['exclCats']); else $pk = '';
|
188 |
if ( is_array($category_ids) && is_array($pk) && count($category_ids) == count($pk)) { ?>
|
189 |
+
<div class="error" id="message"><p><strong>All your categories are excluded from auto-posting.</strong> Nothing will be auto-posted. Please Click "Settings Tab" and select some categories.</div>
|
190 |
<?php }
|
191 |
|
192 |
if(!$nxs_isWPMU) $this->NS_SNAP_ShowPageTop(); ?>
|
199 |
|
200 |
<ul class="nsx_tabs">
|
201 |
<li><a href="#nsx_tab1">Your Social Networks Accounts</a></li>
|
202 |
+
<li><a href="#nsx_tab2"><?php _e('Settings', 'nxs_snap') ?></a></li>
|
203 |
<?php if ((function_exists("nxs_showPRXTab")) && (int)$options['showPrxTab'] == 1) { ?> <li><a href="#nsx_tab5">Proxies</a></li> <?php } ?>
|
204 |
<li><a href="#nsx_tab3">Log/History</a></li>
|
205 |
<li><a href="#nsx_tab4">Help/Support</a></li>
|
221 |
|
222 |
</div>
|
223 |
|
224 |
+
<div class="popShAtt" id="popOnlyCat"><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></div>
|
225 |
<div id="showCatSel" style="display: none;background-color: #fff; width: 300px; padding: 25px;"><span class="nxspButton bClose"><span>X</span></span>Select Categories:
|
226 |
<div id="fbSelCats<?php echo $ii; ?>" class="categorydivInd" style="padding-left: 15px; background-color: #fff;">
|
227 |
<a href="#" onclick="nxs_chAllCatsL(1, 'fbSelCats<?php echo $ii; ?>'); return false;">Check all</a> | <a href="#" onclick="nxs_chAllCatsL(0, 'fbSelCats<?php echo $ii; ?>'); return false;">UnCheck all</a>
|
237 |
foreach ($nxs_snapAvNts as $avNt) { $clName = 'nxs_snapClass'.$avNt['code']; $ntClInst = new $clName();
|
238 |
if ( isset($options[$avNt['lcode']]) && count($options[$avNt['lcode']])>0) { $ntClInst->showGenNTSettings($options[$avNt['lcode']]); } // else $ntClInst->showNewNTSettings(0);
|
239 |
}
|
240 |
+
if ($isNoNts) { ?><br/><br/><br/>You don't have any configured social networks yet. Please click "Add new account" button.<br/><br/>
|
241 |
+
<input onclick="jQuery('#impFileSettings_button').click(); return false;" type="button" class="button" name="impSettings_repostButton" id="impSettings_button" value="<?php _e('Import Settings', 'nxs_snap') ?>" />
|
242 |
+
<?php } else {?>
|
243 |
|
244 |
<div style="float: right; padding: 1.5em;">
|
245 |
|
246 |
<input onclick="nxs_expSettings(); return false;" type="button" class="button" name="expSettings_repostButton" id="expSettings_button" value="<?php _e('Export Settings', 'nxs_snap') ?>" />
|
247 |
<input onclick="jQuery('#impFileSettings_button').click(); return false;" type="button" class="button" name="impSettings_repostButton" id="impSettings_button" value="<?php _e('Import Settings', 'nxs_snap') ?>" />
|
248 |
</div>
|
249 |
+
<input value="'" type="hidden" name="nxs_mqTest" />
|
250 |
<div class="submit"><input type="submit" id="nxs-button-primary-submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div>
|
251 |
|
252 |
<?php } ?>
|
253 |
</div> <!-- END TAB -->
|
254 |
<div id="nsx_tab2" class="nsx_tab_content">
|
255 |
+
<!-- ##################### OTHER #####################-->
|
256 |
+
<?php wp_nonce_field( 'nxsSsPageWPN', 'nxsSsPageWPN_wpnonce' ); ?>
|
257 |
+
<!-- How to make auto-posts? -->
|
258 |
+
<div class="nxs_box"> <div class="nxs_box_header"><h3><?php _e('How to make auto-posts?', 'nxs_snap') ?> <-- (<a id="showShAttIS" onmouseover="showPopShAtt('IS', event);" onmouseout="hidePopShAtt('IS');" onclick="return false;" class="underdash" href="#"><?php _e('What\'s the difference?', 'nxs_snap') ?></a>)</h3></div>
|
259 |
+
<div class="popShAtt" id="popShAttIS">
|
260 |
+
<h3><?php _e('The difference between "Immediately" and "Scheduled"', 'nxs_snap') ?></h3>
|
261 |
+
<?php _e('<b>"Immediately"</b> - Once you click "Publish" button plugin starts pushing your update to configured social networks. At this time you need to wait and look at the turning circle. Some APIs are pretty slow, so you have to wait and wait and wait until all updates are posted and page released back to you.', 'nxs_snap') ?><br/><br/>
|
262 |
+
<?php _e('<b>"Scheduled"</b> - Releases the page immediately back to you, so you can proceed with something else and it schedules all auto-posting jobs to your WP-Cron. This is much faster and much more efficient, but it could not work if your WP-Cron is disabled or broken.', 'nxs_snap') ?>
|
|
|
263 |
</div>
|
264 |
+
<div class="nxs_box_inside">
|
265 |
+
<div class="itemDiv">
|
266 |
+
<input type="radio" name="nxsHTDP" value="I" <?php if (isset($options['nxsHTDP']) && $options['nxsHTDP']=='I') echo 'checked="checked"'; ?> /> <b><?php _e('Publish Immediately', 'nxs_snap') ?></b> - <i><?php _e('Use if WP Cron is disabled or broken on your website', 'nxs_snap') ?></i><br/>
|
267 |
+
</div>
|
268 |
+
|
269 |
+
<div class="itemDiv">
|
270 |
+
<input type="radio" name="nxsHTDP" value="S" <?php if (!isset($options['nxsHTDP']) || $options['nxsHTDP']=='S') echo 'checked="checked"'; ?> /> <b><?php _e('Schedule (Recommended)', 'nxs_snap') ?></b> - <i><?php _e('Faster Performance - requires working WP Cron', 'nxs_snap') ?></i><br/> <?php /* ?>
|
271 |
+
<input type="checkbox" name="runNXSCron" value="1"> <b><?php _e('Try to process missed "Scheduled" posts.', 'nxs_snap') ?></b> <i><?php _e('Usefull when WP Cron is disabled or broken, but can cause some short perfomance issues and duplicates. It is <b>highly</b> recomended to setup a proper cron job of fix WP Cron instead', 'nxs_snap') ?></i>. <?php */ ?>
|
272 |
+
</div>
|
273 |
+
</div></div>
|
274 |
+
<!-- #### Who can see auto-posting options on the "New Post" pages? ##### -->
|
275 |
+
<div class="nxs_box"> <div class="nxs_box_header"><h3><?php _e('User Privileges/Security', 'nxs_snap') ?></h3></div>
|
276 |
+
<div class="nxs_box_inside">
|
277 |
+
<div class="itemDiv">
|
278 |
+
|
279 |
+
<input value="set" id="skipSecurity" name="skipSecurity" type="checkbox" <?php if ((int)$options['skipSecurity'] == 1) echo "checked"; ?> /> <b><?php _e('Skip User Security Check', 'nxs_snap') ?></b>
|
280 |
+
<span style="font-size: 11px; margin-left: 1px;"><?php _e('NOT Recommended, but usefull in some situations. This will allow autoposting for everyone even for the non-existent users.', 'nxs_snap') ?></span>
|
281 |
+
|
282 |
+
<h4><?php _e('Who can make autoposts without seeing any auto-posting options?', 'nxs_snap') ?></h4>
|
283 |
+
|
284 |
+
<?php $editable_roles = get_editable_roles(); if (!isset($options['whoCanMakePosts']) || !is_array($options['whoCanMakePosts'])) $options['whoCanMakePosts'] = array();
|
285 |
+
|
286 |
+
foreach ( $editable_roles as $role => $details ) { $name = translate_user_role($details['name'] ); echo '<input type="checkbox" ';
|
287 |
+
if (in_array($role, $options['whoCanMakePosts']) || $role=='administrator') echo ' checked="checked" '; if ($role=='administrator') echo ' disabled="disabled" ';
|
288 |
+
echo 'name="whoCanMakePosts[]" value="'.esc_attr($role).'"> '.$name;
|
289 |
+
if ($role=='administrator') echo ' - Somebody who has access to all the administration features';
|
290 |
+
if ($role=='editor') echo " - Somebody who can publish and manage posts and pages as well as manage other users' posts, etc. ";
|
291 |
+
if ($role=='author') echo ' - Somebody who can publish and manage their own posts ';
|
292 |
+
if ($role=='contributor') echo ' - Somebody who can write and manage their posts but not publish them';
|
293 |
+
if ($role=='subscriber') echo ' - Somebody who can only manage their profile';
|
294 |
+
echo '<br/>';
|
295 |
+
} ?>
|
296 |
+
|
297 |
+
<h4><?php _e('Who can see auto-posting options on the "New Post" and "Edit Post" pages and make autoposts?', 'nxs_snap') ?></h4>
|
298 |
+
|
299 |
+
<?php $editable_roles = get_editable_roles(); if (!isset($options['whoCanSeeSNAPBox']) || !is_array($options['whoCanSeeSNAPBox'])) $options['whoCanSeeSNAPBox'] = array();
|
300 |
|
301 |
foreach ( $editable_roles as $role => $details ) { $name = translate_user_role($details['name'] ); echo '<input type="checkbox" ';
|
302 |
if (in_array($role, $options['whoCanSeeSNAPBox']) || $role=='administrator') echo ' checked="checked" '; if ($role=='administrator' || $role=='subscriber') echo ' disabled="disabled" ';
|
309 |
echo '<br/>';
|
310 |
} ?>
|
311 |
|
312 |
+
|
313 |
+
|
314 |
+
|
315 |
+
</div>
|
316 |
+
|
317 |
+
</div></div>
|
318 |
+
<!-- #### Include/Exclude Wordpress Pages and Custom Post Types ##### -->
|
319 |
+
<div class="nxs_box"> <div class="nxs_box_header"><h3><?php _e('Include/Exclude Wordpress Pages and Custom Post Types', 'nxs_snap') ?></h3></div>
|
320 |
+
<div class="nxs_box_inside">
|
321 |
+
<div class="itemDiv">
|
322 |
+
<input value="set" id="useForPages" name="useForPages" type="checkbox" <?php if ((int)$options['useForPages'] == 1) echo "checked"; ?> /> <b><?php _e('Use for Wordpress Pages', 'nxs_snap') ?></b>
|
323 |
+
<span style="font-size: 11px; margin-left: 1px;"><?php _e('Show the SNAP metabox and auto-post for pages, not just posts.', 'nxs_snap') ?></span>
|
324 |
+
</div>
|
325 |
+
<div class="itemDiv"><b><br/><?php _e('Custom Post Types:', 'nxs_snap') ?></b>
|
326 |
+
<span style="font-size: 11px; margin-left: 1px;"><?php _e('Please select "Custom Post Types" that you would like to be autoposted to your social networks', 'nxs_snap') ?> </span> <br/>
|
327 |
+
<?php $nxsOne = base64_encode("v=".$nxsOne);
|
328 |
$args=array('public'=>true, '_builtin'=>false); $output = 'names'; $operator = 'and'; $post_types = array(); if (function_exists('get_post_types')) $post_types=get_post_types($args, $output, $operator);
|
329 |
if ($options['nxsCPTSeld']!='') $nxsCPTSeld = unserialize($options['nxsCPTSeld']); else $nxsCPTSeld = array_keys($post_types);
|
330 |
+
|
331 |
+
?> <div class="taxonomydiv"><div class="tabs-panel" style="padding: 10px;"><input type="hidden" name="nxsCPTSeld[]" value="0" /> <?php //prr($nxsCPTSeld); prr($post_types); prr($_POST['nxsCPTSeld']);
|
332 |
+
foreach ($post_types as $cptID=>$cptName){ if (in_array($cptID, $nxsCPTSeld)) $dCh = ' checked="checked" '; else $dCh = "";
|
333 |
+
?><input type="checkbox" name="nxsCPTSeld[]" value="<?php echo esc_attr($cptID); ?>"<?php echo $dCh ?>> <?php echo $cptName ?><br/> <?php
|
334 |
+
}
|
335 |
+
?></div></div>
|
336 |
+
</div>
|
337 |
+
</div></div>
|
338 |
+
<!-- #### Categories to Include/Exclude: ##### -->
|
339 |
+
<script type="text/javascript"> function nxs_chAllCats(ch){ jQuery("form input:checkbox[name='post_category[]']").attr('checked', ch==1);}
|
340 |
+
(function($) { $(function() {
|
341 |
+
$('.button-primary[name="update_NS_SNAutoPoster_settings"]').bind('click', function(e) { var str = $('input[name="post_category[]"]').serialize(); $('div.categorydivInd').replaceWith('<input type="hidden" name="pcInd" value="" />');
|
342 |
+
str = str.replace(/post_category/g, "pk"); $('div.categorydiv').replaceWith('<input type="hidden" name="post_category" value="'+str+'" />');
|
343 |
+
}); }); })(jQuery); </script>
|
344 |
+
<div class="nxs_box"> <div class="nxs_box_header"><h3><?php _e('Categories to Include/Exclude:', 'nxs_snap') ?></h3></div>
|
345 |
+
<div class="nxs_box_inside"> <span style="font-size: 11px; margin-left: 1px;"><?php _e('Each blogpost will be autoposted to all categories selected below. All categories are selected by default.
|
346 |
+
<b>Uncheck</b> categories that you would like <b>NOT</b> to auto-post by default. Assigning the uncheked category to the new blogpost will turn off auto-posting to all configured networks.', 'nxs_snap') ?> </span> <br/>
|
347 |
+
<div class="itemDiv">
|
348 |
+
<a href="#" onclick="nxs_chAllCats(1); return false;">Check all</a> | <a href="#" onclick="nxs_chAllCats(0); return false;">UnCheck all</a>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
349 |
|
350 |
<div id="taxonomy-category" class="categorydiv">
|
351 |
<div id="category-all" class="tabs-panel"><input type='hidden' name='post_category[]' value='0' />
|
358 |
</ul>
|
359 |
</div>
|
360 |
</div>
|
361 |
+
</div>
|
362 |
+
</div></div>
|
363 |
+
<!-- ##################### URL Shortener #####################-->
|
364 |
+
<div class="nxs_box"> <div class="nxs_box_header"><h3><?php _e('URL Shortener', 'nxs_snap') ?></h3></div>
|
365 |
+
<div class="nxs_box_inside"> <span style="font-size: 11px; margin-left: 1px;">Please use %SURL% in "Message Format" to get shortened urls. </span> <br/>
|
366 |
+
<!-- <div class="itemDiv">
|
367 |
+
<input type="radio" name="nxsURLShrtnr" value="G" <?php if (!isset($options['nxsURLShrtnr']) || $options['nxsURLShrtnr']=='' || $options['nxsURLShrtnr']=='G') echo 'checked="checked"'; ?> /> <b>gd.is</b> (Default) - fast, simple, free, no configuration nessesary.
|
368 |
+
</div> -->
|
369 |
+
<div class="itemDiv">
|
370 |
+
<input type="radio" name="nxsURLShrtnr" value="O" <?php if (isset($options['nxsURLShrtnr']) && $options['nxsURLShrtnr']=='O' || $options['nxsURLShrtnr']=='' || $options['nxsURLShrtnr']=='G') echo 'checked="checked"'; ?> /> <b>goo.gl</b> - <i> Enter goo.gl <a target="_blank" href="https://developers.google.com/url-shortener/v1/getting_started#APIKey">API Key</a> below [Optional]</i><br/>
|
371 |
+
goo.gl API Key: <input name="gglAPIKey" style="width: 20%;" value="<?php if (isset($options['gglAPIKey'])) _e(apply_filters('format_to_edit',$options['gglAPIKey']), 'nxs_snap') ?>" />
|
372 |
+
</div>
|
373 |
+
|
374 |
+
<?php if (function_exists('wp_get_shortlink')) { ?><div class="itemDiv">
|
375 |
+
<input type="radio" name="nxsURLShrtnr" value="W" <?php if (isset($options['nxsURLShrtnr']) && $options['nxsURLShrtnr']=='W') echo 'checked="checked"'; ?> /> <b>Wordpress Built-in Shortener</b> (wp.me if you use Jetpack)<br/>
|
376 |
+
</div><?php } ?>
|
377 |
+
|
378 |
+
<div class="itemDiv">
|
379 |
+
<input type="radio" name="nxsURLShrtnr" value="B" <?php if (isset($options['nxsURLShrtnr']) && $options['nxsURLShrtnr']=='B') echo 'checked="checked"'; ?> /> <b>bit.ly</b> - <i>Enter bit.ly username and <a target="_blank" href="http://bitly.com/a/your_api_key">API Key</a> below</i><br/>
|
380 |
bit.ly Username: <input name="bitlyUname" style="width: 20%;" value="<?php if (isset($options['bitlyUname'])) _e(apply_filters('format_to_edit',$options['bitlyUname']), 'nxs_snap') ?>" /><br/>
|
381 |
+
bit.ly API Key: <input name="bitlyAPIKey" style="width: 20%;" value="<?php if (isset($options['bitlyAPIKey'])) _e(apply_filters('format_to_edit',$options['bitlyAPIKey']), 'nxs_snap') ?>" />
|
382 |
+
</div>
|
383 |
+
|
384 |
+
<div class="itemDiv">
|
385 |
+
<input type="radio" name="nxsURLShrtnr" value="Y" <?php if (isset($options['nxsURLShrtnr']) && $options['nxsURLShrtnr']=='Y') echo 'checked="checked"'; ?> /> <b>YOURLS (Your Own URL Shortener)</b> -
|
386 |
+
<i>YOURLS API URL - usually sonething like http://yourdomain.cc/yourls-api.php; YOURLS API Secret Signature Token can be found in your YOURLS Admin Panel->Tools</i><br/>
|
387 |
+
YOURLS API URL: <input name="YOURLSURL" style="width: 19.4%;" value="<?php if (isset($options['YOURLSURL'])) _e(apply_filters('format_to_edit',$options['YOURLSURL']), 'nxs_snap') ?>" /><br/>
|
388 |
+
YOURLS API Secret Signature Token: <input name="YOURLSKey" style="width: 13%;" value="<?php if (isset($options['YOURLSKey'])) _e(apply_filters('format_to_edit',$options['YOURLSKey']), 'nxs_snap') ?>" />
|
389 |
+
</div>
|
390 |
+
|
391 |
+
</div></div>
|
392 |
+
<!-- ##################### Auto-Import comments from Social Networks #####################-->
|
393 |
+
<div class="nxs_box"> <div class="nxs_box_header"><h3><?php _e('Auto-Import comments from Social Networks', 'nxs_snap') ?><span class="nxs_newLabel">[<?php _e('New', 'nxs_snap') ?>]</span></h3></div>
|
394 |
+
<div class="nxs_box_inside"> <span style="font-size: 11px; margin-left: 1px;">Plugin will automatically grab the comments posted on Social Networks and insert them as "Comments to your post". Plugin will check for the new comments every hour. </span> <br/>
|
395 |
+
<div class="itemDiv">
|
396 |
+
<input value="set" id="riActive" name="riActive" type="checkbox" <?php if ((int)$options['riActive'] == 1) echo "checked"; ?> />
|
397 |
+
<strong>Enable "Comments Import"</strong>
|
398 |
+
</div>
|
399 |
+
<div class="itemDiv">
|
400 |
+
<strong style="font-size: 12px; margin: 10px; margin-left: 1px;">How many posts should be tracked:</strong>
|
401 |
<input name="riHowManyPostsToTrack" style="width: 50px;" value="<?php if (isset($options['riHowManyPostsToTrack'])) _e(apply_filters('format_to_edit', $options['riHowManyPostsToTrack']), 'nxs_snap'); else echo "10"; ?>" /> <br/>
|
402 |
|
403 |
+
<span style="font-size: 11px; margin-left: 1px;">Setting two many will degrade your website's performance. 10-20 posts are recommended</span>
|
404 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
405 |
|
406 |
+
</div></div>
|
407 |
+
<!-- ##################### Additional URL Parameters #####################-->
|
408 |
+
<div class="nxs_box"> <div class="nxs_box_header"><h3><?php _e('Additional URL Parameters', 'nxs_snap') ?> <span class="nxs_newLabel">[<?php _e('New', 'nxs_snap') ?>]</span></h3></div>
|
409 |
+
<div class="nxs_box_inside"> <span style="font-size: 11px; margin-left: 1px;"><?php _e('Will be added to backlinks.', 'nxs_snap') ?> </span> <br/>
|
410 |
+
<div class="itemDiv">
|
411 |
+
<b><?php _e('Additional URL Parameters:', 'nxs_snap') ?></b> <input name="addURLParams" style="width: 800px;" value="<?php if (isset($options['addURLParams'])) _e(apply_filters('format_to_edit', $options['addURLParams']), 'nxs_snap'); ?>" />
|
412 |
+
</div>
|
413 |
+
<span style="font-size: 11px; margin-left: 1px;"> <?php _e('You can use %NTNAME% for social network name, %NTCODE% for social network two-letter code, %ACCNAME% for account name, %POSTID% for post ID, %POSTTITLE% for post title, %SITENAME% for website name. <b>Any text must be URL Encoded</b><br/>Example: utm_source=%NTCODE%&utm_medium=%ACCNAME%&utm_campaign=SNAP%2Bfrom%2B%SITENAME%', 'nxs_snap') ?></span>
|
414 |
+
</div></div>
|
415 |
+
|
416 |
+
<!-- ##### ANOUNCE TAG ##### -->
|
417 |
+
<div class="nxs_box"> <div class="nxs_box_header"><h3><?php _e('%ANNOUNCE% tag settings', 'nxs_snap') ?></h3></div>
|
418 |
+
<div class="nxs_box_inside"> <span style="font-size: 11px; margin-left: 1px;"><?php _e('Plugin will take text untill the <!--more--> tag. Please specify how many characters should it get if <!--more--> tag is not found', 'nxs_snap') ?> </span> <br/>
|
419 |
+
<div class="itemDiv">
|
420 |
+
<b><?php _e('How many characters:', 'nxs_snap') ?></b> <input name="anounTagLimit" style="width: 100px;" value="<?php if (isset($options['anounTagLimit'])) _e(apply_filters('format_to_edit',$options['anounTagLimit']), 'nxs_snap'); else echo "300"; ?>" />
|
421 |
+
</div>
|
422 |
+
</div></div>
|
423 |
+
|
424 |
+
<!-- ##################### Open Graph #####################-->
|
425 |
+
<div class="nxs_box"> <div class="nxs_box_header"><h3><?php _e('"Open Graph" Tags', 'nxs_snap') ?></h3></div>
|
426 |
+
<div class="nxs_box_inside"> <span style="font-size: 11px; margin-left: 1px;"><?php _e('"Open Graph" tags are used for generating title, description and preview image for your Facebook and Google+ posts. This is quite simple implementation of "Open Graph" Tags. This option will only add tags needed for "Auto Posting". If you need something more serious uncheck this and use other specialized plugins.', 'nxs_snap') ?> </span> <br/>
|
427 |
+
<div class="itemDiv">
|
428 |
+
<input value="1" id="nsOpenGraph" name="nsOpenGraph" type="checkbox" <?php if ((int)$options['nsOpenGraph'] == 1) echo "checked"; ?> /> <b><?php _e('Add Open Graph Tags', 'nxs_snap') ?></b>
|
429 |
+
</div>
|
430 |
+
<div class="itemDiv">
|
431 |
+
<b><?php _e('Default Image URL for og:image tag:', 'nxs_snap') ?></b>
|
432 |
<input name="ogImgDef" style="width: 30%;" value="<?php if (isset($options['ogImgDef'])) _e(apply_filters('format_to_edit',$options['ogImgDef']), 'nxs_snap') ?>" />
|
433 |
+
</div>
|
434 |
+
</div></div>
|
435 |
+
<!-- #### "Featured" Image ##### -->
|
436 |
+
<div class="nxs_box"> <div class="nxs_box_header"><h3><?php _e('Advanced "Featured" Image Settings', 'nxs_snap') ?></h3></div>
|
437 |
+
<div class="nxs_box_inside">
|
438 |
+
<div class="itemDiv">
|
439 |
+
<input value="set" id="imgNoCheck" name="imgNoCheck" type="checkbox" <?php if ((int)$options['imgNoCheck'] != 1) echo "checked"; ?> /> <strong>Verify "Featured" Image</strong>
|
440 |
+
<br/><span style="font-size: 11px; margin-left: 1px;"><?php _e('Advanced Setting. Uncheck only if you are 100% sure that your images are valid or if you have troubles with image verification.', 'nxs_snap') ?> </span> <br/>
|
441 |
+
</div>
|
442 |
+
|
443 |
+
<div class="itemDiv">
|
444 |
+
<input value="1" id="useUnProc" name="useUnProc" type="checkbox" <?php if (isset($options['useUnProc']) && (int)$options['useUnProc'] == 1) echo "checked"; ?> />
|
445 |
+
<b><?php _e('Use advanced image finder', 'nxs_snap') ?></b>
|
446 |
+
<br/>
|
447 |
+
<span style="font-size: 11px; margin-left: 1px;"> <?php _e('Check this if your images could be found only in the fully processed posts. <br/>This feature could interfere with some plugins using post processing functions incorrectly. Your site could become messed up, have troubles displaying content or start giving you "ob_start() [ref.outcontrol]: Cannot use output buffering in output buffering display handlers" errors.', 'nxs_snap') ?></span>
|
448 |
+
</div>
|
449 |
+
|
450 |
+
</div></div>
|
451 |
+
|
452 |
+
<!-- ##### Alternative "Featured Image" location ##### -->
|
453 |
+
<div class="nxs_box"> <div class="nxs_box_header"><h3><?php _e('Alternative "Featured Image" location', 'nxs_snap') ?></h3></div>
|
454 |
+
<div class="nxs_box_inside"> <span style="font-size: 11px; margin-left: 1px;"><?php _e('Plugin uses standard Wordpress "Featured Image" by default. If your theme stores "Featured Image" in the custom field, please enter the name of it. Use prefix if your custom field has only partial location.', 'nxs_snap') ?> </span> <br/>
|
455 |
+
<div class="itemDiv">
|
456 |
+
<b><?php _e('Custom field name:', 'nxs_snap') ?></b> <input name="featImgLoc" style="width: 200px;" value="<?php if (isset($options['featImgLoc'])) _e(apply_filters('format_to_edit',$options['featImgLoc']), 'nxs_snap') ?>" />
|
457 |
+
<br/>
|
458 |
+
<span style="font-size: 11px; margin-left: 1px;"><?php _e('Set the name of the custom field that contains image info', 'nxs_snap') ?></span>
|
459 |
+
</div>
|
460 |
+
<div class="itemDiv">
|
461 |
+
<b><?php _e('Custom field Array Path:', 'nxs_snap') ?></b> <input name="featImgLocArrPath" style="width: 200px;" value="<?php if (isset($options['featImgLocArrPath'])) _e(apply_filters('format_to_edit',$options['featImgLocArrPath']), 'nxs_snap') ?>" />
|
462 |
+
<br/>
|
463 |
+
<span style="font-size: 11px; margin-left: 1px;">[<?php _e('Optional', 'nxs_snap') ?>] <?php _e('If your custom field contain an array, please enter the path to the image field. For example: [\'images\'][\'image\']', 'nxs_snap') ?></span>
|
464 |
+
</div>
|
465 |
+
<div class="itemDiv">
|
466 |
+
<b><?php _e('Custom field Image Prefix:', 'nxs_snap') ?></b> <input name="featImgLocPrefix" style="width: 200px;" value="<?php if (isset($options['featImgLocPrefix'])) _e(apply_filters('format_to_edit',$options['featImgLocPrefix']), 'nxs_snap') ?>" />
|
467 |
+
<br/>
|
468 |
+
<span style="font-size: 11px; margin-left: 1px;">[<?php _e('Optional', 'nxs_snap') ?>] <?php _e('If your custom field contain only the last part of the image path, please enter the prefix', 'nxs_snap') ?></span>
|
469 |
+
</div>
|
470 |
+
</div></div>
|
471 |
+
|
472 |
+
|
473 |
|
474 |
+
<?php if (function_exists("nxs_showPRXTab")) { ?>
|
475 |
+
<h3 style="font-size: 14px; margin-bottom: 2px;">Show "Proxies" Tab</h3>
|
|
|
|
|
476 |
<p style="margin: 0px;margin-left: 5px;"><input value="set" id="showPrxTab" name="showPrxTab" type="checkbox" <?php if ((int)$options['showPrxTab'] == 1) echo "checked"; ?> />
|
477 |
+
<strong>Show "Proxies" Tab</strong> <span style="font-size: 11px; margin-left: 1px;">Advanced Setting. Check to enable "Proxies" tab where you can setup autoposting proxies.</span>
|
|
|
478 |
</p>
|
479 |
<?php } ?>
|
480 |
|
481 |
+
<div class="submit"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div>
|
|
|
482 |
</div>
|
483 |
+
|
484 |
<?php if ((function_exists("nxs_showPRXTab")) && (int)$options['showPrxTab'] == 1) { nxs_showPRXTab($options); } ?>
|
485 |
<div id="nsx_tab3" class="nsx_tab_content">
|
486 |
<div style="width:760px;">
|
488 |
|
489 |
Showing last 150 records <a href="#" onclick="nxs_clLog();return false;" class="NXSButton" id="nxs_clearLog">Clear Log</a><br/><br/>
|
490 |
<div style="overflow: auto; border: 1px solid #999; width: 750px; height: 600px; font-size: 11px;" class="logDiv" id="nxslogDiv">
|
491 |
+
<?php //$logInfo = maybe_unserialize(get_option('NS_SNAutoPosterLog'));
|
492 |
+
$logInfo = nxs_getnxsLog();
|
493 |
+
if (is_array($logInfo))
|
494 |
+
foreach (array_reverse($logInfo) as $logline) {
|
495 |
+
if ($logline['type']=='E') $actSt = "color:#FF0000;"; elseif ($logline['type']=='M') $actSt = "color:#585858;"; elseif ($logline['type']=='BG') $actSt = "color:#008000; font-weight:bold;";
|
496 |
+
elseif ($logline['type']=='I') $actSt = "color:#0000FF;"; elseif ($logline['type']=='W') $actSt = "color:#DB7224;"; elseif ($logline['type']=='BI') $actSt = "color:#0000FF; font-weight:bold;";
|
497 |
+
elseif ($logline['type']=='GR') $actSt = "color:#008080;"; elseif ($logline['type']=='S') $actSt = "color:#005800; font-weight:bold;"; else $actSt = "color:#585858;";
|
498 |
+
if ($logline['type']=='E') $msgSt = "color:#FF0000;"; elseif ($logline['type']=='BG') $msgSt = "color:#008000; font-weight:bold;"; else $msgSt = "color:#585858;";
|
499 |
+
if ($logline['nt']!='') $ntInfo = ' ['.$logline['nt'].'] '; else $ntInfo = '';
|
500 |
+
echo '<snap style="color:#008000">['.$logline['date'].']</snap> - <snap style="'.$actSt.'">['.$logline['act'].']</snap>'.$ntInfo.'- <snap style="'.$msgSt.'">'.$logline['msg'].'</snap> '.$logline['extInfo'].'<br/>';
|
501 |
+
} ?>
|
502 |
+
</div>
|
503 |
+
</div>
|
504 |
</div>
|
505 |
|
506 |
<div id="nsx_tab4" class="nsx_tab_content">
|
612 |
|
613 |
<form method="post" enctype="multipart/form-data" id="nsStFormUpl" action="<?php echo $nxs_snapThisPageUrl?>">
|
614 |
<input type="file" accept="text/plain" onchange="jQuery('#nsStFormUpl').submit();" id="impFileSettings_button" name="impFileSettings_button" style="display: block; visibility: hidden; width: 0; height: 0;" size="chars">
|
615 |
+
<input type="hidden" value="1" name="upload_NS_SNAutoPoster_settings" /> <input value="'" type="hidden" name="nxs_mqTest" /> <?php wp_nonce_field( 'nxsChkUpl', 'nxsChkUpl_wpnonce' ); ?>
|
616 |
</form>
|
617 |
|
618 |
<br/> <br/> <?php
|
619 |
}
|
620 |
+
function showSNAutoPosterOptionsPagex() { global $nxs_snapAvNts, $nxs_snapThisPageUrl, $nxsOne, $nxs_plurl, $nxs_isWPMU; $nxsOne = ''; $options = $this->nxs_options; ?>
|
621 |
+
<br/><br/><br/>This version of the plugin is not compatible with <b>Wordpress Multisite Edition</b>. Please contact your Network Admin for the upgrade. <?php }
|
622 |
|
623 |
function NS_SNAP_ShowPageTop(){ global $nxs_snapAvNts, $nxs_snapThisPageUrl, $nxsOne, $nxs_plurl, $nxs_isWPMU; $nxsOne = ''; $options = $this->nxs_options;
|
624 |
$nxsOne = NextScripts_SNAP_Version; if (defined('NXSAPIVER')) $nxsOne .= " (<span id='nxsAPIUpd'>API</span> Version: ".NXSAPIVER.")"; ?>
|
647 |
- <a target="_blank" href="http://www.nextscripts.com/social-networks-auto-poster-for-wp-multiple-accounts"><?php _e('Get', 'nxs_snap'); ?> PRO - Multiple Accounts Edition</a><br/><br/>
|
648 |
|
649 |
<?php _e('Here you can setup "Social Networks Auto Poster".', 'nxs_snap'); ?><br/> <?php _e('You can start by clicking "Add new account" button and choosing the Social Network you would like to add.', 'nxs_snap'); ?><?php }} ?><br/>
|
650 |
+
<?php $disabled_functions = @ini_get('disable_functions');
|
651 |
if (!function_exists('curl_init')) {
|
652 |
+
echo ("<br/><b style='font-size:16px; color:red;'>Error: No CURL Found</b> - <i style='font-size:12px; color:red;'>Social Networks AutoPoster needs the CURL PHP extension. Please install it or contact your hosting company to install it.</i><br/><br/>");
|
653 |
+
}
|
654 |
+
if (stripos($disabled_functions, 'curl_exec')!==false) {
|
655 |
+
echo ("<br/><b style='font-size:16px; color:red;'>curl_exec function is disabled in php.ini</b> - <i style='font-size:12px; color:red;'>Social Networks AutoPoster needs the CURL PHP extension. Please enable it or contact your hosting company to enable it.</i><br/><br/>");
|
656 |
}
|
657 |
/*
|
658 |
if ((defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE==true) || (defined('MULTISITE') && MULTISITE==true) ) {
|
667 |
<?php }
|
668 |
}
|
669 |
|
670 |
+
function NS_SNAP_SavePostMetaTags($id) { global $nxs_snapAvNts, $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options; // echo "| NS_SNAP_SavePostMetaTags - ".$id." |";
|
671 |
+
$post = get_post($id); if ($post->post_type=='revision' && $post->post_status=='inherit' && $post->post_parent!='0') return;
|
672 |
+
if (isset($_POST["snapEdIT"])) $nspost_edit = $_POST["snapEdIT"]; //echo "| snapEdIT |"; // prr($nspost_edit);
|
673 |
+
if (get_magic_quotes_gpc() || $_POST['nxs_mqTest']=="\'"){ array_walk_recursive($_POST, 'nsx_stripSlashes'); }
|
674 |
+
$snap_isAutoPosted = get_post_meta($id, 'snap_isAutoPosted', true); if ($snap_isAutoPosted=='1' && $post->post_status=='future') { delete_post_meta($id, 'snap_isAutoPosted'); add_post_meta($id, 'snap_isAutoPosted', '2'); }
|
675 |
+
if (isset($nspost_edit) && !empty($nspost_edit)) { delete_post_meta($id, 'snapEdIT'); add_post_meta($id, 'snapEdIT', '1' );
|
676 |
foreach ($nxs_snapAvNts as $avNt) {
|
677 |
if (count($options[$avNt['lcode']])>0 && isset($_POST[$avNt['lcode']]) && count($_POST[$avNt['lcode']])>0) { $savedMeta = maybe_unserialize(get_post_meta($id, 'snap'.$avNt['code'], true));
|
678 |
if(is_array($_POST[$avNt['lcode']])) { $ii=0;
|
679 |
+
foreach ($_POST[$avNt['lcode']] as $pst ) { // echo "#############################################################################"; prr($pst);
|
680 |
+
if (is_array($pst) && $pst['do'.$avNt['code']]=='' && $_POST[$avNt['lcode']][$ii]['do'.$avNt['code']]=='') $_POST[$avNt['lcode']][$ii]['do'.$avNt['code']]= 0; $ii++;
|
681 |
}
|
682 |
} $newMeta = $_POST[$avNt['lcode']];
|
683 |
if (is_array($savedMeta) && is_array($newMeta)) $newMeta = nxsMergeArraysOV($savedMeta, $newMeta); // echo "##### ".$id."| snap".$avNt['code']; prr($savedMeta); echo "||"; prr($newMeta);// $newMeta = 'AAA';
|
696 |
.underdash a:hover {border-bottom: 1px #21759B dashed}
|
697 |
</style>
|
698 |
|
699 |
+
<input value="1" type="hidden" name="snapEdIT" /> <input value="'" type="hidden" name="nxs_mqTest" />
|
700 |
<div class="popShAtt" style="width: 200px;" id="popShAttSV"><?php _e('If you made any changes to the format, please "Update" the post before reposting', 'nxs_snap'); ?></div>
|
701 |
<?php if($post->post_status != "publish" ) { ?>
|
702 |
<div style="float: right;"> <input type="hidden" id="nxsLockIt" value="0" />
|
724 |
}
|
725 |
}
|
726 |
|
727 |
+
if (class_exists("NS_SNAutoPoster")) { nxs_checkAddLogTable(); $plgn_NS_SNAutoPoster = new NS_SNAutoPoster(); }
|
728 |
//## Delete Account
|
729 |
if (!function_exists("ns_delNT_ajax")) { function ns_delNT_ajax(){ check_ajax_referer('nsDN'); $indx = (int)$_POST['id'];
|
730 |
global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
|
736 |
}}
|
737 |
if (!function_exists("nsGetBoards_ajax")) {
|
738 |
function nsGetBoards_ajax() { global $nxs_gCookiesArr; check_ajax_referer('getBoards'); global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
|
739 |
+
if (get_magic_quotes_gpc() || $_POST['nxs_mqTest']=="\'") { $_POST['u'] = stripslashes($_POST['u']); $_POST['p'] = stripslashes($_POST['p']);} $_POST['p'] = trim($_POST['p']); $u = trim($_POST['u']);
|
740 |
$loginError = doConnectToPinterest($_POST['u'], substr($_POST['p'], 0, 5)=='g9c1a'?nsx_doDecode(substr($_POST['p'], 5)):$_POST['p'] ); if ($loginError!==false) {echo $loginError; return "BAD USER/PASS";}
|
741 |
$gPNBoards = doGetBoardsFromPinterest(); $options['pn'][$_POST['ii']]['pnBoardsList'] = base64_encode($gPNBoards);
|
742 |
$options['pn'][$_POST['ii']]['pnSvC'] = serialize($nxs_gCookiesArr); if (is_array($options)) update_option('NS_SNAutoPoster', $options); echo $gPNBoards; die();
|
743 |
}
|
744 |
}
|
745 |
+
|
746 |
+
if (!function_exists("nsGetGPCats_ajax")) {
|
747 |
+
function nsGetGPCats_ajax() { global $nxs_gCookiesArr; check_ajax_referer('getGPCats'); global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
|
748 |
+
if (get_magic_quotes_gpc() || $_POST['nxs_mqTest']=="\'") { $_POST['u'] = stripslashes($_POST['u']); $_POST['p'] = stripslashes($_POST['p']);} $_POST['p'] = trim($_POST['p']); $u = trim($_POST['u']);
|
749 |
+
$loginError = doConnectToGooglePlus2($_POST['u'], substr($_POST['p'], 0, 5)=='g9c1a'?nsx_doDecode(substr($_POST['p'], 5)):$_POST['p'] ); if ($loginError!==false) {echo $loginError; return "BAD USER/PASS";}
|
750 |
+
$gGPCCats = doGetCCatsFromGooglePlus($_POST['c']); $options['gp'][$_POST['ii']]['gpCCatsList'] = base64_encode($gGPCCats);
|
751 |
+
if (is_array($options)) update_option('NS_SNAutoPoster', $options); echo $gGPCCats; die();
|
752 |
+
}
|
753 |
+
}
|
754 |
if (!function_exists("nsGetWLBoards_ajax")) {
|
755 |
function nsGetWLBoards_ajax() { global $nxs_gCookiesArr; check_ajax_referer('getWLBoards'); global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
|
756 |
+
if (get_magic_quotes_gpc() || $_POST['nxs_mqTest']=="\'") { $_POST['u'] = stripslashes($_POST['u']); $_POST['p'] = stripslashes($_POST['p']);} $_POST['p'] = trim($_POST['p']); $u = trim($_POST['u']);
|
757 |
$loginError = doConnectToWaNeLo($_POST['u'], substr($_POST['p'], 0, 5)=='g9c1a'?nsx_doDecode(substr($_POST['p'], 5)):$_POST['p'] ); if ($loginError!==false) {echo $loginError; return "BAD USER/PASS";}
|
758 |
$gWLBoards = doGetBoardsFromWaNeLo(); $options['wl'][$_POST['ii']]['wlBoardsList'] = base64_encode($gWLBoards);
|
759 |
$options['wl'][$_POST['ii']]['wlSvC'] = serialize($nxs_gCookiesArr); if (is_array($options)) update_option('NS_SNAutoPoster', $options); echo $gWLBoards; die();
|
760 |
}
|
761 |
}
|
762 |
|
763 |
+
if (!function_exists("nxs_clLgo_ajax")) { function nxs_clLgo_ajax() { check_ajax_referer('nxsSsPageWPN'); global $wpdb;
|
764 |
+
//update_option('NS_SNAutoPosterLog', '');
|
765 |
+
$wpdb->query( 'DELETE FROM '.$wpdb->prefix . 'nxs_log' ); echo "OK";
|
766 |
}}
|
767 |
|
768 |
if (!function_exists("nxs_rfLgo_ajax")) { function nxs_rfLgo_ajax() { check_ajax_referer('nxsSsPageWPN'); echo "Y:";
|
769 |
+
//$log = get_option('NS_SNAutoPosterLog'); $logInfo = maybe_unserialize(get_option('NS_SNAutoPosterLog'));
|
770 |
+
$logInfo = nxs_getnxsLog();
|
771 |
+
if (is_array($logInfo))foreach (array_reverse($logInfo) as $logline) {
|
772 |
+
if ($logline['type']=='E') $actSt = "color:#FF0000;"; elseif ($logline['type']=='M') $actSt = "color:#585858;"; elseif ($logline['type']=='BG') $actSt = "color:#008000; font-weight:bold;";
|
773 |
+
elseif ($logline['type']=='I') $actSt = "color:#0000FF;"; elseif ($logline['type']=='W') $actSt = "color:#DB7224;"; elseif ($logline['type']=='BI') $actSt = "color:#0000FF; font-weight:bold;";
|
774 |
+
elseif ($logline['type']=='GR') $actSt = "color:#008080;"; elseif ($logline['type']=='S') $actSt = "color:#005800; font-weight:bold;"; else $actSt = "color:#585858;";
|
775 |
+
if ($logline['type']=='E') $msgSt = "color:#FF0000;"; elseif ($logline['type']=='BG') $msgSt = "color:#008000; font-weight:bold;"; else $msgSt = "color:#585858;";
|
776 |
+
if ($logline['nt']!='') $ntInfo = ' ['.$logline['nt'].'] '; else $ntInfo = '';
|
777 |
+
echo '<snap style="color:#008000">['.$logline['date'].']</snap> - <snap style="'.$actSt.'">['.$logline['act'].']</snap>'.$ntInfo.'- <snap style="'.$msgSt.'">'.$logline['msg'].'</snap> '.$logline['extInfo'].'<br/>';
|
778 |
+
}
|
779 |
}}
|
780 |
|
781 |
//## Initialize the admin panel if the plugin has been activated
|
792 |
}}}
|
793 |
|
794 |
//## Main Function to Post
|
795 |
+
if (!function_exists("nxs_snapPublishTo")) { function nxs_snapPublishTo($postArr, $type='', $aj=false) { global $plgn_NS_SNAutoPoster, $nxs_snapAvNts, $blog_id, $nxs_tpWMPU; // echo " | nxs_doSMAS2 | "; prr($postArr);
|
796 |
+
if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
|
797 |
+
if(is_object($postArr)) $postID = $postArr->ID; else { $postID = $postArr; $postArr = get_post($postID); } $isPost = isset($_POST["snapEdIT"]);
|
798 |
+
if ($isPost && $options['skipSecurity']!='1' && !current_user_can("make_snap_posts") && !current_user_can("manage_options")) { nxs_addToLogN('I', 'Skipped', '', 'Current user can\'t autopost - Post ID:('.$postID.')' ); return; }
|
799 |
+
$postUser = $postArr->post_author;
|
800 |
+
if ($options['skipSecurity']!='1' && !user_can( $postUser, "make_snap_posts" ) && !user_can( $postUser, "manage_options")){ nxs_addToLogN('I', 'Skipped', '', 'User ID '.$postUser.' can\'t autopost - Post ID:('.$postID.')' ); return; }
|
801 |
+
if ($isPost) $plgn_NS_SNAutoPoster->NS_SNAP_SavePostMetaTags($postID);
|
802 |
+
if (function_exists('nxs_doSMAS2')) { nxs_doSMAS2($postArr, $type, $aj); return; } else {
|
803 |
+
$options = $plgn_NS_SNAutoPoster->nxs_options; $ltype=strtolower($type);
|
804 |
+
if ($nxs_tpWMPU=='S') { switch_to_blog(1); $plgn_NS_SNAutoPoster = new NS_SNAutoPoster(); $options = $plgn_NS_SNAutoPoster->nxs_options; restore_current_blog(); }
|
805 |
+
if (!isset($options['nxsHTDP']) || $options['nxsHTDP']=='S') { if(isset($_POST["snapEdIT"]) && $_POST["snapEdIT"]=='1') { $publtype='S'; $delay = rand(2,10); } else $publtype='A'; } else $publtype = 'I';
|
806 |
+
nxs_addToLogN('BG', 'Start =- ', '', '------=========#### NEW AUTO-POST REQUEST '.($blog_id>1?'BlogID:'.$blog_id:'').' PostID:('.$postID.') '.($publtype=='S'?'Scheduled +'.$delay:($publtype=='A'?'Non Human':'Immediate')).' ####=========------');
|
807 |
$post = get_post($postID); $args=array( 'public' => true, '_builtin' => false); $output = 'names'; $operator = 'and'; $post_types = array(); if (function_exists('get_post_types')) $post_types=get_post_types($args, $output, $operator);
|
808 |
+
$snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted=='1') { nxs_addToLogN('W', 'Skipped', '', 'Already Autoposted - Post ID:('.$postID.')' ); return; }
|
809 |
+
$snap_isEdIT = get_post_meta($postID, 'snapEdIT', true); if ($snap_isEdIT!='1') { $doPost = true; $exclCats = maybe_unserialize($options['exclCats']); $postCats = wp_get_post_categories($postID);
|
810 |
+
foreach ($postCats as $pCat) { if ( (is_array($exclCats)) && in_array($pCat, $exclCats)) $doPost = false; else {$doPost = true; break;}}
|
811 |
+
if (!$doPost) { nxs_addToLogN('I', 'Skipped', '', 'Non-Human Post - Category Excluded - Post ID:('.$postID.')' ); return; }
|
812 |
+
}
|
813 |
if ($options['nxsCPTSeld']!='') $nxsCPTSeld = unserialize($options['nxsCPTSeld']); else $nxsCPTSeld = array_keys($post_types); //prr($nxsCPTSeld);
|
|
|
814 |
|
815 |
+
if ($post->post_type == 'post'|| ($options['useForPages']=='1' && $post->post_type == 'page') || in_array($post->post_type, $post_types) && in_array($post->post_type, $nxsCPTSeld)) foreach ($nxs_snapAvNts as $avNt) {
|
816 |
if (count($options[$avNt['lcode']])>0) { $clName = 'nxs_snapClass'.$avNt['code'];
|
817 |
+
if ($isPost && isset($_POST[$avNt['lcode']])) $po = $_POST[$avNt['lcode']]; else { $po = get_post_meta($postID, 'snap'.$avNt['code'], true); $po = maybe_unserialize($po);}
|
818 |
+
|
819 |
+
if (isset($po) && is_array($po)) $isPostMeta = true; else { $isPostMeta = false; $po = $options[$avNt['lcode']]; }
|
820 |
+
delete_post_meta($postID, 'snap_isAutoPosted'); add_post_meta($postID, 'snap_isAutoPosted', '1');
|
821 |
+
|
822 |
+
$optMt = $options[$avNt['lcode']][0]; if ($isPostMeta) { $ntClInst = new $clName(); $optMt = $ntClInst->adjMetaOpt($optMt, $po[0]); }
|
823 |
+
if ($snap_isEdIT!='1') { $doPost = true;
|
824 |
+
if ( $optMt['catSel']=='1' && trim($optMt['catSelEd'])!='' ) { $inclCats = explode(',',$optMt['catSelEd']); foreach ($postCats as $pCat) { if (!in_array($pCat, $inclCats)) $doPost = false; else {$doPost = true; break;}}
|
825 |
+
if (!$doPost) { nxs_addToLogN('I', 'Skipped', $avNt['name'].' ('.$optMt['nName'].')', '[Non-Human Post] - Individual Category Excluded - Post ID:('.$postID.')' ); return; }
|
826 |
+
}
|
827 |
+
}
|
828 |
+
if ($optMt['do'.$avNt['code']]=='1') { $optMt['ii'] = 0;
|
829 |
+
if ($publtype=='A' && ($optMt['nMin']>0 || $optMt['nHrs']>0 || $optMt['nTime']!='')) $publtype='S';
|
830 |
+
if ($publtype=='S') { if (isset($optMt['nHrs']) && isset($optMt['nMin']) && ($optMt['nHrs']>0 || $optMt['nMin']>0) ) { $delay = $optMt['nMin']*60+$optMt['nHrs']*3600;
|
831 |
+
nxs_addToLogN('I', 'Delayed', $avNt['name'].' ('.$optMt['nName'].')', 'Post has been delayed for '.$delay.' Seconds ('.($optMt['nHrs']>0?$optMt['nHrs'].' Hours':'')." ".($optMt['nMin']>0?$optMt['nMin'].' Minutes':'').')' );
|
832 |
+
} else $delay = rand(2,10); $optMt['timeToRun'] = time()+$delay; $args = array($postID, $optMt); wp_schedule_single_event($optMt['timeToRun'],'ns_doPublishTo'.$avNt['code'], $args);
|
833 |
+
nxs_addToLogN('BI', 'Scheduled', $avNt['name'].' ('.$optMt['nName'].')', ' PostID:('.$postID.')' );
|
834 |
+
} else { $fname = 'nxs_doPublishTo'.$avNt['code']; $fname($postID, $optMt); }
|
835 |
+
} else { nxs_addToLogN('GR', 'Skipped', $avNt['name'].' ('.$optMt['nName'].')', '-=[Unchecked Account]=- - PostID:'.$postID.'' ); }
|
836 |
+
}
|
837 |
}
|
838 |
+
} if ($isS) restore_current_blog();
|
839 |
+
}}
|
840 |
|
841 |
//## AJAX to Post to Google+
|
842 |
|
865 |
}
|
866 |
}}
|
867 |
|
868 |
+
//## Process Spin
|
869 |
+
if (!function_exists("nxs_spinRecursion")) { function nxs_spinRecursion(&$txt, $startCh) { global $nxs_spin_lCh, $nxs_spin_rCh, $nxs_spin_splCh; $startPos = $startCh;
|
870 |
+
while ($startCh++ < strlen($txt)) {
|
871 |
+
if (substr($txt, $startCh, strlen($nxs_spin_lCh)) == $nxs_spin_lCh) $txt = nxs_spinRecursion($txt, $startCh);
|
872 |
+
elseif (substr($txt, $startCh, strlen($nxs_spin_rCh)) == $nxs_spin_rCh) {
|
873 |
+
$tmpTxt = substr($txt, $startPos+strlen($nxs_spin_lCh), ($startCh - $startPos)-strlen($nxs_spin_rCh));
|
874 |
+
$toRepl = nxs_spinReplace($tmpTxt); $txt = str_replace($nxs_spin_lCh.$tmpTxt.$nxs_spin_rCh, $toRepl, $txt);
|
875 |
+
}
|
876 |
+
} return $txt;
|
877 |
+
}}
|
878 |
+
if (!function_exists("nxs_spinReplace")) { function nxs_spinReplace($txt) { global $nxs_spin_splCh; $txt = explode($nxs_spin_splCh, $txt); $out = $txt[mt_rand(0,count($txt)-1)]; return $out; }}
|
879 |
+
if (!function_exists("nxs_doSpin")) { function nxs_doSpin($msg){ global $nxs_spin_lCh, $nxs_spin_rCh, $nxs_spin_splCh;
|
880 |
+
$nxs_spin_lCh = '{'; $nxs_spin_rCh='}'; $nxs_spin_splCh='|'; $msg = nxs_spinRecursion($msg, -1); return $msg;
|
881 |
+
}}
|
882 |
+
|
883 |
//## Format Message
|
884 |
+
if (!function_exists("nsFormatMessage")) { function nsFormatMessage($msg, $postID, $addURLParams=''){ global $ShownAds, $plgn_NS_SNAutoPoster, $nxs_urlLen; $post = get_post($postID); $options = $plgn_NS_SNAutoPoster->nxs_options;
|
885 |
+
// if ($addURLParams=='' && $options['addURLParams']!='') $addURLParams = $options['addURLParams'];
|
886 |
$msg = stripcslashes($msg); if (isset($ShownAds)) $ShownAdsL = $ShownAds; // $msg = htmlspecialchars(stripcslashes($msg));
|
887 |
+
$msg = nxs_doSpin($msg);
|
888 |
+
if (preg_match('%URL%', $msg)) { $url = get_permalink($postID); if($addURLParams!='') $url .= (strpos($url,'?')!==false?'&':'?').$addURLParams; $nxs_urlLen = nxs_strLen($url); $msg = str_ireplace("%URL%", $url, $msg);}
|
889 |
+
if (preg_match('%SURL%', $msg)) { $url = get_permalink($postID); if($addURLParams!='') $url .= (strpos($url,'?')!==false?'&':'?').$addURLParams;
|
890 |
+
$url = nxs_mkShortURL($url, $postID); $nxs_urlLen = nxs_strLen($url); $msg = str_ireplace("%SURL%", $url, $msg);
|
891 |
+
}
|
892 |
if (preg_match('%IMG%', $msg)) { $imgURL = nxs_getPostImage($postID); $msg = str_ireplace("%IMG%", $imgURL, $msg); }
|
893 |
if (preg_match('%TITLE%', $msg)) { $title = nxs_doQTrans($post->post_title, $lng); $msg = str_ireplace("%TITLE%", $title, $msg); }
|
894 |
if (preg_match('%STITLE%', $msg)) { $title = nxs_doQTrans($post->post_title, $lng); $title = substr($title, 0, 115); $msg = str_ireplace("%STITLE%", $title, $msg); }
|
895 |
if (preg_match('%AUTHORNAME%', $msg)) { $aun = $post->post_author; $aun = get_the_author_meta('display_name', $aun ); $msg = str_ireplace("%AUTHORNAME%", $aun, $msg);}
|
896 |
+
if (preg_match('%ANNOUNCE%', $msg)) { $postContent = nxs_doQTrans($post->post_content, $lng);
|
897 |
+
if (stripos($postContent, '<!--more-->')!==false) { $postContentEx = explode('<!--more-->',$postContent); $postContent = $postContentEx[0]; }
|
898 |
+
elseif (stripos($postContent, '<!--more-->')!==false) { $postContentEx = explode('<!--more-->',$postContent); $postContent = $postContentEx[0]; }
|
899 |
+
else $postContent = nsTrnc($postContent, $options['anounTagLimit']); $msg = str_ireplace("%ANNOUNCE%", $postContent, $msg);
|
900 |
+
}
|
901 |
if (preg_match('%TEXT%', $msg)) {
|
902 |
if ($post->post_excerpt!="") $excerpt = apply_filters('the_content', nxs_doQTrans($post->post_excerpt, $lng)); else $excerpt= apply_filters('the_content', nxs_doQTrans($post->post_content, $lng));
|
903 |
$excerpt = nsTrnc(strip_tags(strip_shortcodes($excerpt)), 300, " ", "..."); $msg = str_ireplace("%TEXT%", $excerpt, $msg);
|
904 |
}
|
905 |
+
if (preg_match('%EXCERPT%', $msg)) {
|
906 |
+
if ($post->post_excerpt!="") $excerpt = apply_filters('the_content', nxs_doQTrans($post->post_excerpt, $lng)); else $excerpt= apply_filters('the_content', nxs_doQTrans($post->post_content, $lng));
|
907 |
+
$excerpt = nsTrnc(strip_tags(strip_shortcodes($excerpt)), 300, " ", "..."); $msg = str_ireplace("%EXCERPT%", $excerpt, $msg);
|
908 |
+
}
|
909 |
if (preg_match('%RAWEXTEXT%', $msg)) {
|
910 |
if ($post->post_excerpt!="") $excerpt = nxs_doQTrans($post->post_excerpt, $lng); else $excerpt= nxs_doQTrans($post->post_content, $lng);
|
911 |
$excerpt = nsTrnc(strip_tags(strip_shortcodes($excerpt)), 300, " ", "..."); $msg = str_ireplace("%RAWEXTEXT%", $excerpt, $msg);
|
912 |
}
|
913 |
+
if (preg_match('%RAWEXCERPT%', $msg)) {
|
914 |
+
if ($post->post_excerpt!="") $excerpt = nxs_doQTrans($post->post_excerpt, $lng); else $excerpt= nxs_doQTrans($post->post_content, $lng);
|
915 |
+
$excerpt = nsTrnc(strip_tags(strip_shortcodes($excerpt)), 300, " ", "..."); $msg = str_ireplace("%RAWEXCERPT%", $excerpt, $msg);
|
916 |
+
}
|
917 |
+
if (preg_match('%TAGS%', $msg)) { $t = wp_get_object_terms($postID, 'product_tag'); if ( empty($t) || is_wp_error($pt) || !is_array($t) ) $t = wp_get_post_tags($postID);
|
918 |
+
$tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = implode(', ',$tggs); $msg = str_ireplace("%TAGS%", $tags, $msg);
|
919 |
+
}
|
920 |
if (preg_match('%CATS%', $msg)) { $t = wp_get_post_categories($postID); $cats = array(); foreach($t as $c){ $cat = get_category($c); $cats[] = str_ireplace('&','&',$cat->name); }
|
921 |
$ctts = implode(', ',$cats); $msg = str_ireplace("%CATS%", $ctts, $msg);
|
922 |
}
|
923 |
+
if (preg_match('%HCATS%', $msg)) { $t = wp_get_post_categories($postID); $cats = array();
|
924 |
+
foreach($t as $c){ $cat = get_category($c); $cats[] = "#".trim(str_replace(' ','', str_replace(' ', '', trim(str_ireplace('&','',str_ireplace('&','',$cat->name)))))); }
|
925 |
+
$ctts = implode(', ',$cats); $msg = str_ireplace("%HCATS%", $ctts, $msg);
|
926 |
+
}
|
927 |
+
if (preg_match('%HTAGS%', $msg)) { $t = wp_get_object_terms($postID, 'product_tag'); if ( empty($t) || is_wp_error($pt) || !is_array($t) ) $t = wp_get_post_tags($postID);
|
928 |
+
$tggs = array(); foreach ($t as $tagA) {$tggs[] = "#".trim(str_replace(' ','',preg_replace('/[^a-zA-Z0-9\p{L}\p{N}\s]/u', '', trim(ucwords(str_ireplace('&','',str_ireplace('&','',$tagA->name))))))); }
|
929 |
+
$tags = implode(', ',$tggs); $msg = str_ireplace("%HTAGS%", $tags, $msg);
|
930 |
+
}
|
931 |
+
if (preg_match('%CF-[a-zA-Z0-9]%', $msg)) { $msgA = explode('%CF', $msg); $mout = '';
|
932 |
+
foreach ($msgA as $mms) {
|
933 |
+
if (substr($mms, 0, 1)=='-' && stripos($mms, '%')!==false) { $mGr = CutFromTo($mms, '-', '%'); $cfItem = get_post_meta($postID, $mGr, true); $mms = str_ireplace("-".$mGr."%", $cfItem, $mms); } $mout .= $mms;
|
934 |
+
} $msg = $mout;
|
935 |
+
}
|
936 |
if (preg_match('%FULLTEXT%', $msg)) { $postContent = apply_filters('the_content', nxs_doQTrans($post->post_content, $lng)); $msg = str_ireplace("%FULLTEXT%", $postContent, $msg);}
|
937 |
if (preg_match('%RAWTEXT%', $msg)) { $postContent = nxs_doQTrans($post->post_content, $lng); $msg = str_ireplace("%RAWTEXT%", $postContent, $msg);}
|
938 |
if (preg_match('%SITENAME%', $msg)) { $siteTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); $msg = str_ireplace("%SITENAME%", $siteTitle, $msg);}
|
943 |
if (!function_exists("nxs_adminInitFunc")) { function nxs_adminInitFunc(){ global $plgn_NS_SNAutoPoster, $nxs_snapThisPageUrl, $pagenow, $nxs_isWPMU;
|
944 |
$nxs_snapThisPageUrl = admin_url().($pagenow=='admin.php'?'network/':'').$pagenow.'?page=NextScripts_SNAP.php';
|
945 |
//## Javascript to Admin Panel
|
946 |
+
if (( ($pagenow=='options-general.php'||$pagenow=='admin.php') && isset($_GET['page']) && $_GET['page']=='NextScripts_SNAP.php') ||$pagenow=='post.php'||$pagenow=='post-new.php'){add_action('admin_head', 'jsPostToSNAP'); add_action('admin_head', 'nxs_jsPostToSNAP2');}
|
947 |
if (function_exists('nxsDoLic_ajax')) { add_action('wp_ajax_nxsDoLic', 'nxsDoLic_ajax'); }
|
948 |
if (function_exists('nxs_getInitUCheck') && (isset($plgn_NS_SNAutoPoster))) { $options = $plgn_NS_SNAutoPoster->nxs_options; if (is_array($options) && count($options)>1) nxs_getInitUCheck($options); }
|
949 |
|
1038 |
add_action('admin_init', 'nxs_adminInitFunc');
|
1039 |
add_action( 'admin_enqueue_scripts', 'nxssnap_enqueue_scripts' );
|
1040 |
|
1041 |
+
add_action('wp_ajax_nxscr', 'nxscr_ajax');
|
1042 |
+
|
1043 |
add_action('wp_ajax_nxs_clLgo', 'nxs_clLgo_ajax');
|
1044 |
add_action('wp_ajax_nxs_rfLgo', 'nxs_rfLgo_ajax');
|
1045 |
add_action('wp_ajax_nxs_prxTest', 'nxs_prxTest_ajax');
|
1049 |
|
1050 |
add_action('nxs_hourly_event', 'nxs_do_this_hourly');
|
1051 |
add_action('wp', 'nxs_activation');
|
1052 |
+
add_action('shutdown', 'nxs_psCron');
|
1053 |
+
|
1054 |
|
1055 |
if ($isO || $isS) {
|
1056 |
//## Whenever you publish a post, post to Social Networks
|
1063 |
//## Add nxs_snapPublishTo to custom post types
|
1064 |
add_action('wp_loaded', 'ns_custom_types_setup' );
|
1065 |
foreach ($nxs_snapAvNts as $avNt) { add_action('ns_doPublishTo'.$avNt['code'], 'nxs_doPublishTo'.$avNt['code'], 1, 2); }
|
1066 |
+
foreach ($nxs_snapAvNts as $avNt) { add_action('wp_ajax_rePostTo'.$avNt['code'], 'nxs_rePostTo'.$avNt['code'].'_ajax'); }
|
1067 |
|
1068 |
+
//## Add AJAX Calls for Test and Repost
|
1069 |
+
add_action('wp_ajax_getBoards' , 'nsGetBoards_ajax');
|
1070 |
+
add_action('wp_ajax_getGPCats' , 'nsGetGPCats_ajax');
|
1071 |
+
add_action('wp_ajax_getWLBoards' , 'nsGetWLBoards_ajax');
|
1072 |
+
add_action('wp_ajax_nsDN', 'ns_delNT_ajax');
|
1073 |
+
}
|
1074 |
+
|
1075 |
if ($isO) {
|
1076 |
add_action('admin_menu', 'NS_SNAutoPoster_ap');
|
1077 |
add_action('admin_init', 'nxs_adminInitFunc2');
|
1085 |
add_action('save_post', array($plgn_NS_SNAutoPoster, 'NS_SNAP_SavePostMetaTags'));
|
1086 |
add_action('edit_page_form', array($plgn_NS_SNAutoPoster, 'NS_SNAP_SavePostMetaTags'));
|
1087 |
|
1088 |
+
|
|
|
|
|
|
|
|
|
1089 |
|
1090 |
add_action('wp_ajax_nsAuthFBSv', 'nsAuthFBSv_ajax');
|
1091 |
//## Custom Post Types and OG tags
|
1092 |
add_filter('plugin_action_links','ns_add_settings_link', 10, 2 );
|
1093 |
+
|
1094 |
+
add_filter('get_avatar','ns_get_avatar', 10, 5 );
|
1095 |
|
1096 |
//## Scedulled Publish Calls
|
1097 |
if ((int)$suOptions['nsOpenGraph'] == 1) {
|
img/ff-bg.png
ADDED
Binary file
|
img/ff16.png
ADDED
Binary file
|
img/rd-bg.png
ADDED
Binary file
|
img/rd16.png
ADDED
Binary file
|
img/tpz-bg.png
ADDED
Binary file
|
img/tpz16.png
ADDED
Binary file
|
img/vkPostTypesDiff6.png
ADDED
Binary file
|
img/wl-bg.png
ADDED
Binary file
|
img/wl16.png
ADDED
Binary file
|
img/yt-bg.png
ADDED
Binary file
|
img/yt16.png
ADDED
Binary file
|
inc-cl/apis/base_facebook.php
CHANGED
@@ -50,6 +50,7 @@ class NXS_FacebookApiException extends Exception
|
|
50 |
} else if (isset($result['error']) && is_array($result['error'])) {
|
51 |
// OAuth 2.0 Draft 00 style
|
52 |
$msg = $result['error']['message'];
|
|
|
53 |
} else if (isset($result['error_msg'])) {
|
54 |
// Rest server style
|
55 |
$msg = $result['error_msg'];
|
50 |
} else if (isset($result['error']) && is_array($result['error'])) {
|
51 |
// OAuth 2.0 Draft 00 style
|
52 |
$msg = $result['error']['message'];
|
53 |
+
if ($code==0 && isset($result['error']['code'])) $code = $result['error']['code'];
|
54 |
} else if (isset($result['error_msg'])) {
|
55 |
// Rest server style
|
56 |
$msg = $result['error_msg'];
|
inc-cl/apis/facebook.php
CHANGED
@@ -45,7 +45,7 @@ class NXS_Facebook extends NXS_BaseFacebook
|
|
45 |
* @see BaseFacebook::__construct in facebook.php
|
46 |
*/
|
47 |
public function __construct($config) {
|
48 |
-
if (!session_id()) {
|
49 |
session_start();
|
50 |
}
|
51 |
parent::__construct($config);
|
45 |
* @see BaseFacebook::__construct in facebook.php
|
46 |
*/
|
47 |
public function __construct($config) {
|
48 |
+
if (!session_id() && !headers_sent() ) {
|
49 |
session_start();
|
50 |
}
|
51 |
parent::__construct($config);
|
inc-cl/apis/liOAuth.php
CHANGED
@@ -97,9 +97,10 @@ class nsx_LinkedIn {
|
|
97 |
return $response;
|
98 |
}
|
99 |
|
100 |
-
function postToGroup($msg, $title, $groupID) { $status_url = $this->base_url . "/v1/groups/".$groupID."/posts"; //$debug = true;
|
101 |
$dsc = nxs_decodeEntitiesFull(strip_tags($dsc)); $msg = strip_tags(nxs_decodeEntitiesFull($msg)); $title = nxs_decodeEntitiesFull(strip_tags($title));
|
102 |
-
$xml = '<?xml version="1.0" encoding="UTF-8"?><post><title>'.htmlspecialchars($title, ENT_NOQUOTES, "UTF-8").'</title><summary>'.htmlspecialchars($msg, ENT_NOQUOTES, "UTF-8").'</summary
|
|
|
103 |
|
104 |
$request = nsx_trOAuthRequest::from_consumer_and_token($this->consumer, $this->access_token, "POST", $status_url);
|
105 |
$request->sign_request($this->signature_method, $this->consumer, $this->access_token);
|
@@ -177,7 +178,7 @@ class nsx_LinkedIn {
|
|
177 |
$header = curl_getinfo($curl); curl_close($curl);// prr($header);
|
178 |
|
179 |
if ($this->debug) echo $data . "\n";
|
180 |
-
|
181 |
return $data;
|
182 |
}
|
183 |
|
97 |
return $response;
|
98 |
}
|
99 |
|
100 |
+
function postToGroup($msg, $title, $groupID, $url='', $imgURL='', $dsc='') { $status_url = $this->base_url . "/v1/groups/".$groupID."/posts"; //$debug = true;
|
101 |
$dsc = nxs_decodeEntitiesFull(strip_tags($dsc)); $msg = strip_tags(nxs_decodeEntitiesFull($msg)); $title = nxs_decodeEntitiesFull(strip_tags($title));
|
102 |
+
$xml = '<?xml version="1.0" encoding="UTF-8"?><post><title>'.htmlspecialchars($title, ENT_NOQUOTES, "UTF-8").'</title><summary>'.htmlspecialchars($msg, ENT_NOQUOTES, "UTF-8").'</summary>
|
103 |
+
'.($url!=''?'<content><title>'.htmlspecialchars($title, ENT_NOQUOTES, "UTF-8").'</title><submitted-url>'.$url.'</submitted-url><submitted-image-url>'.$imgURL.'</submitted-image-url><description>'.htmlspecialchars($dsc, ENT_NOQUOTES, "UTF-8").'</description></content>':'').'</post>';
|
104 |
|
105 |
$request = nsx_trOAuthRequest::from_consumer_and_token($this->consumer, $this->access_token, "POST", $status_url);
|
106 |
$request->sign_request($this->signature_method, $this->consumer, $this->access_token);
|
178 |
$header = curl_getinfo($curl); curl_close($curl);// prr($header);
|
179 |
|
180 |
if ($this->debug) echo $data . "\n";
|
181 |
+
if (trim($data)=='' && ($header['http_code']=='201' || $header['http_code']=='200' || $header['http_code']=='202')) $data = '201';
|
182 |
return $data;
|
183 |
}
|
184 |
|
inc-cl/apis/xmlrpc-client.php
CHANGED
@@ -623,7 +623,7 @@ class NXS_XMLRPC_Client
|
|
623 |
$this->timeout = $timeout;
|
624 |
}
|
625 |
|
626 |
-
function
|
627 |
{
|
628 |
$args = func_get_args();
|
629 |
$method = array_shift($args);
|
@@ -708,6 +708,85 @@ class NXS_XMLRPC_Client
|
|
708 |
return true;
|
709 |
}
|
710 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
711 |
function getResponse()
|
712 |
{
|
713 |
// methodResponses can only have one param - return that
|
623 |
$this->timeout = $timeout;
|
624 |
}
|
625 |
|
626 |
+
function queryFS()
|
627 |
{
|
628 |
$args = func_get_args();
|
629 |
$method = array_shift($args);
|
708 |
return true;
|
709 |
}
|
710 |
|
711 |
+
/**
|
712 |
+
* Set the query to send to the XML-RPC Server
|
713 |
+
* @since 0.1.0
|
714 |
+
*/
|
715 |
+
function query()
|
716 |
+
{
|
717 |
+
$args = func_get_args();
|
718 |
+
$method = array_shift($args);
|
719 |
+
$request = new NXS_XMLRPC_Request($method, $args);
|
720 |
+
$length = $request->getLength();
|
721 |
+
$xml = $request->getXml();
|
722 |
+
|
723 |
+
if ($this->debug) {
|
724 |
+
echo '<pre>'.htmlspecialchars($xml)."\n</pre>\n\n";
|
725 |
+
}
|
726 |
+
|
727 |
+
//This is where we deviate from the normal query()
|
728 |
+
//Rather than open a normal sock, we will actually use the cURL
|
729 |
+
//extensions to make the calls, and handle the SSL stuff.
|
730 |
+
|
731 |
+
//Since 04Aug2004 (0.1.3) - Need to include the port (duh...)
|
732 |
+
//Since 06Oct2004 (0.1.4) - Need to include the colon!!!
|
733 |
+
// (I swear I've fixed this before... ESP in live... But anyhu...)
|
734 |
+
$curl=curl_init('http://' . $this->server . ':' . $this->port . $this->path);
|
735 |
+
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
736 |
+
|
737 |
+
//Since 23Jun2004 (0.1.2) - Made timeout a class field
|
738 |
+
curl_setopt($curl, CURLOPT_TIMEOUT, $this->timeout);
|
739 |
+
|
740 |
+
if ($this->debug) {
|
741 |
+
curl_setopt($curl, CURLOPT_VERBOSE, 1);
|
742 |
+
}
|
743 |
+
|
744 |
+
curl_setopt($curl, CURLOPT_HEADER, 1);
|
745 |
+
curl_setopt($curl, CURLOPT_POST, 1);
|
746 |
+
curl_setopt($curl, CURLOPT_POSTFIELDS, $xml);
|
747 |
+
curl_setopt($curl, CURLOPT_PORT, $this->port);
|
748 |
+
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
|
749 |
+
"Content-Type: text/xml",
|
750 |
+
"Content-length: {$length}"));
|
751 |
+
|
752 |
+
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
|
753 |
+
|
754 |
+
// Call cURL to do it's stuff and return us the content
|
755 |
+
$contents = curl_exec($curl);
|
756 |
+
curl_close($curl);
|
757 |
+
|
758 |
+
// Check for 200 Code in $contents
|
759 |
+
if (!strstr($contents, '200 OK')) {
|
760 |
+
//There was no "200 OK" returned - we failed
|
761 |
+
$this->error = new NXS_XMLRPC_Error(-32300, 'transport error - HTTP status code was not 200');
|
762 |
+
return false;
|
763 |
+
}
|
764 |
+
|
765 |
+
if ($this->debug) {
|
766 |
+
echo '<pre>'.htmlspecialchars($contents)."\n</pre>\n\n";
|
767 |
+
}
|
768 |
+
// Now parse what we've got back
|
769 |
+
// Since 20Jun2004 (0.1.1) - We need to remove the headers first
|
770 |
+
// Why I have only just found this, I will never know...
|
771 |
+
// So, remove everything before the first <
|
772 |
+
$contents = substr($contents,strpos($contents, '<'));
|
773 |
+
|
774 |
+
$this->message = new NXS_XMLRPC_Message($contents);
|
775 |
+
if (!$this->message->parse()) {
|
776 |
+
// XML error
|
777 |
+
$this->error = new NXS_XMLRPC_Error(-32700, 'parse error. not well formed');
|
778 |
+
return false;
|
779 |
+
}
|
780 |
+
// Is the message a fault?
|
781 |
+
if ($this->message->messageType == 'fault') {
|
782 |
+
$this->error = new NXS_XMLRPC_Error($this->message->faultCode, $this->message->faultString);
|
783 |
+
return false;
|
784 |
+
}
|
785 |
+
|
786 |
+
// Message must be OK
|
787 |
+
return true;
|
788 |
+
}
|
789 |
+
|
790 |
function getResponse()
|
791 |
{
|
792 |
// methodResponses can only have one param - return that
|
inc-cl/bg.php
CHANGED
@@ -15,7 +15,7 @@ if (!class_exists("nxs_snapClassBG")) { class nxs_snapClassBG {
|
|
15 |
<div class="nxs_box_inside">
|
16 |
<?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
|
17 |
<p style="margin:0px;margin-left:5px;">
|
18 |
-
<input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> />
|
19 |
<strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
|
20 |
<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'nxs_snap'); ?> ==></b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>
|
21 |
<a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
|
@@ -63,9 +63,13 @@ if (!class_exists("nxs_snapClassBG")) { class nxs_snapClassBG {
|
|
63 |
<div id="altFormat" style="">
|
64 |
<div style="width:100%;"><strong id="altFormatText"><?php _e('Post Text Format', 'nxs_snap'); ?>:</strong> (<a href="#" id="apBGMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apBGMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)
|
65 |
|
66 |
-
|
67 |
-
</
|
68 |
-
|
|
|
|
|
|
|
|
|
69 |
</div>
|
70 |
|
71 |
<p style="margin-bottom: 20px;margin-top: 5px;"><input value="1" id="bgInclTags" type="checkbox" name="bg[<?php echo $ii; ?>][bgInclTags]" <?php if ((int)$options['bgInclTags'] == 1) echo "checked"; ?> />
|
@@ -116,8 +120,8 @@ if (!class_exists("nxs_snapClassBG")) { class nxs_snapClassBG {
|
|
116 |
?>
|
117 |
|
118 |
<tr><th style="text-align:left;" colspan="2"><?php if ( $options['catSel']=='1' && trim($options['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_BG<?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" /> <?php } ?>
|
119 |
-
<?php if ($isAvailBG) { ?><input class="nxsGrpDoChb" value="1" id="doBG<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="bg[<?php echo $ii; ?>][doBG]" <?php if (($
|
120 |
-
<div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/bg16.png);">Blogger - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $options['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
|
121 |
if ($post->post_status == "publish" && $isAvailBG) { ?>
|
122 |
<input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToBG_repostButton" id="rePostToBG_button" value="<?php _e('Repost to Blogger', 'nxs_snap') ?>" />
|
123 |
<?php wp_nonce_field( 'rePostToBG', 'rePostToBG_wpnonce' ); } ?>
|
@@ -130,10 +134,12 @@ if (!class_exists("nxs_snapClassBG")) { class nxs_snapClassBG {
|
|
130 |
</td></tr>
|
131 |
<?php if (!$isAvailBG) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b><?php _e('Setup your Blogger Account to AutoPost to Blogger', 'nxs_snap') ?></b>
|
132 |
<?php } elseif ($post->post_status != "puZblish") { ?>
|
133 |
-
<tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;"><?php _e('Title Format:', 'NS_SPAP') ?></th>
|
134 |
-
<td><input value="<?php echo $bgMsgTFormat ?>" type="text" name="bg[<?php echo $ii; ?>][SNAPTformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apBGTMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apBGTMsgFrmt".$ii); ?></td></tr>
|
135 |
-
<tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;"><?php _e('Message Format:', 'NS_SPAP') ?></th>
|
136 |
-
<td
|
|
|
|
|
137 |
<?php }
|
138 |
}
|
139 |
}
|
@@ -170,7 +176,7 @@ if (!function_exists('nsBloggerGetAuth')){ function nsBloggerGetAuth($email, $pa
|
|
170 |
curl_close($ch); $arr = explode("=",$result); $token = $arr[3]; if (trim($token)=='') return false; else return $token;
|
171 |
}}
|
172 |
if (!function_exists('nsBloggerNewPost')){ function nsBloggerNewPost($auth, $blogID, $title, $text) {$text = str_ireplace('allowfullscreen','', $text); $title = utf8_decode(strip_tags($title));
|
173 |
-
$text = preg_replace('/<object\b[^>]*>(.*?)<\/object>/is', "", $text); $text = preg_replace('/<iframe\b[^>]*>(.*?)<\/iframe>/is', "", $text);
|
174 |
|
175 |
$postText = '<entry xmlns="http://www.w3.org/2005/Atom"><title type="text">'.$title.'</title><content type="xhtml">'.$text.'</content></entry>'; //prr($postText);
|
176 |
$len = strlen($entry); $ch = curl_init("https://www.blogger.com/feeds/$blogID/posts/default");
|
@@ -182,40 +188,49 @@ if (!function_exists('nsBloggerNewPost')){ function nsBloggerNewPost($auth, $blo
|
|
182 |
if (stripos($result,'tag:blogger.com')!==false) { $postID = CutFromTo($result, " rel='alternate' type='text/html' href='", "'"); return array("code"=>"OK", "post_id"=>$postID); } else { prr($result); return false;}
|
183 |
}}
|
184 |
if (!function_exists("nxs_doPublishToBG")) { //## Second Function to Post to BG
|
185 |
-
function nxs_doPublishToBG($postID, $options){ $ntCd = 'BG'; $ntCdL = 'bg'; $ntNm = 'Blogger';
|
|
|
|
|
186 |
$blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url();
|
187 |
$addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'ACCNAME'=>$options['nName'], 'POSTID'=>$postID));
|
188 |
-
$ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
|
|
|
|
|
189 |
if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
|
190 |
-
|
|
|
|
|
191 |
}
|
|
|
192 |
if ($postID=='0') { echo "Testing ... <br/><br/>"; $msgT = 'Test Post from '.htmlentities($blogTitle); $link = home_url(); $msg = 'Test Post from '.$blogTitle. " ".$link; }
|
193 |
-
|
194 |
$link = get_permalink($postID); $msgTFormat = $options['bgMsgTFormat']; $msgT = nsFormatMessage($msgTFormat, $postID, $addParams); nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
|
195 |
}
|
|
|
196 |
//## Actual POST Code
|
197 |
$email = $options['bgUName']; $pass = substr($options['bgPass'], 0, 5)=='b4d7s'?nsx_doDecode(substr($options['bgPass'], 5)):$options['bgPass']; $blogID = $options['bgBlogID'];
|
198 |
//echo "###".$auth."|".$blogID."|".$msgT."|".$msg;
|
199 |
if ($options['bgInclTags']=='1'){$t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = implode('","',$tggs); $tags = nsTrnc($tags, 195, ',', ''); }
|
200 |
-
if (substr($tags, -1)=='"') $tags = substr($tags, 0, -1);
|
201 |
-
$extInfo = ' | PostID: '.$postID; $logNT = '<span style="color:#F87907">'.$ntNm.'</span> - '.$options['nName'];
|
202 |
|
203 |
if (class_exists('DOMDocument')) {$doc = new DOMDocument(); @$doc->loadHTML('<?xml encoding="UTF-8">' .$msg); $doc->encoding = 'UTF-8'; $msg = $doc->saveHTML(); $msg = CutFromTo($msg, '<body>', '</body>');
|
204 |
$msg = preg_replace('/<br(.*?)\/?>/','<br$1/>',$msg); $msg = preg_replace('/<img(.*?)\/?>/','<img$1/>',$msg);
|
205 |
-
require_once ('apis/htmlNumTable.php'); $msg = strtr($msg, $HTML401NamedToNumeric);
|
206 |
} // prr($text);
|
207 |
// prr($msg); echo " =HT= ";
|
208 |
-
$msg = preg_replace('/<script\b[^>]*>(.*?)<\/script>/is', "", $msg); $msg = preg_replace('/<!--(.*)-->/Uis', "", $msg); $nxshf = new NXS_HtmlFixer(); $nxshf->debug = false; $msg = $nxshf->getFixedHtml($msg);
|
209 |
-
//
|
210 |
-
|
211 |
if (function_exists("doConnectToBlogger")) {$auth = doConnectToBlogger($email, $pass); if ($auth!==false) $ret = $auth; else $ret = doPostToBlogger($blogID, $msgT, $msg, $tags);}
|
212 |
else {$auth = nsBloggerGetAuth($email, $pass); if ($auth===false) $ret = 'Incorrect Username/Password'; else { $msgT = str_ireplace('&', '&', $msgT);
|
213 |
$msgT = utf8_encode(str_ireplace('&', '&', $msgT)); $msg = utf8_encode($msg); $ret = nsBloggerNewPost($auth, $blogID, $msgT, $msg);
|
214 |
}}
|
215 |
//## /Actual POST Code
|
216 |
-
if ( (!is_array($ret)) && $ret!='OK') { if ($postID=='0') prr($ret);
|
217 |
-
else { if ($postID=='0') { echo 'OK - Message Posted, please see your '.$ntNm.' Page ';
|
218 |
-
else { nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPosted'=>'1', 'pgID'=>$ret['post_id'], 'pDate'=>date('Y-m-d H:i:s')));
|
|
|
|
|
|
|
219 |
}
|
220 |
}
|
221 |
|
15 |
<div class="nxs_box_inside">
|
16 |
<?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
|
17 |
<p style="margin:0px;margin-left:5px;">
|
18 |
+
<input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> /> <?php if ((int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
|
19 |
<strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
|
20 |
<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'nxs_snap'); ?> ==></b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>
|
21 |
<a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
|
63 |
<div id="altFormat" style="">
|
64 |
<div style="width:100%;"><strong id="altFormatText"><?php _e('Post Text Format', 'nxs_snap'); ?>:</strong> (<a href="#" id="apBGMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apBGMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)
|
65 |
|
66 |
+
<!--
|
67 |
+
HTML is <?php if(!function_exists('doPostToGooglePlus')) {?> <b>NOT</b> <?php } ?> allowed. <?php if(!function_exists('doPostToGooglePlus')) {?> <i>- Blogger "Free API" limitation. Please get <a href="http://www.nextscripts.com/google-plus-automated-posting/#blogger">NextScripts API</a> to allow HTML</i> <?php } ?> -->
|
68 |
+
</div>
|
69 |
+
|
70 |
+
<textarea cols="150" rows="3" id="bg<?php echo $ii; ?>SNAPformat" name="bg[<?php echo $ii; ?>][apBGMsgFrmt]" style="width:51%;max-width: 650px;" onfocus="jQuery('#bg<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('apBGMsgFrmt<?php echo $ii; ?>');"><?php if ($options['bgMsgFormat']!='') _e(apply_filters('format_to_edit',htmlentities($options['bgMsgFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap'); else echo "%FULLTEXT% <br/><a href='%URL%'>%TITLE%</a>"; ?></textarea>
|
71 |
+
|
72 |
+
<?php nxs_doShowHint("apBGMsgFrmt".$ii, __('HTML is allowed', 'nxs_snap')); ?>
|
73 |
</div>
|
74 |
|
75 |
<p style="margin-bottom: 20px;margin-top: 5px;"><input value="1" id="bgInclTags" type="checkbox" name="bg[<?php echo $ii; ?>][bgInclTags]" <?php if ((int)$options['bgInclTags'] == 1) echo "checked"; ?> />
|
120 |
?>
|
121 |
|
122 |
<tr><th style="text-align:left;" colspan="2"><?php if ( $options['catSel']=='1' && trim($options['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_BG<?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" /> <?php } ?>
|
123 |
+
<?php if ($isAvailBG) { ?><input class="nxsGrpDoChb" value="1" id="doBG<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="bg[<?php echo $ii; ?>][doBG]" <?php if ((int)$doBG == 1) echo 'checked="checked" title="def"'; ?> /> <?php if ($post->post_status == "publish") { ?> <input type="hidden" name="bg[<?php echo $ii; ?>][doBG]" value="<?php echo $doBG;?>"> <?php } ?> <?php } ?>
|
124 |
+
<div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/bg16.png);">Blogger - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $options['nName']; ?></i>)</div></th> <td style="min-width: 180px; width: 350px;" ><?php //## Only show RePost button if the post is "published"
|
125 |
if ($post->post_status == "publish" && $isAvailBG) { ?>
|
126 |
<input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToBG_repostButton" id="rePostToBG_button" value="<?php _e('Repost to Blogger', 'nxs_snap') ?>" />
|
127 |
<?php wp_nonce_field( 'rePostToBG', 'rePostToBG_wpnonce' ); } ?>
|
134 |
</td></tr>
|
135 |
<?php if (!$isAvailBG) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b><?php _e('Setup your Blogger Account to AutoPost to Blogger', 'nxs_snap') ?></b>
|
136 |
<?php } elseif ($post->post_status != "puZblish") { ?>
|
137 |
+
<tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Title Format:', 'NS_SPAP') ?></th>
|
138 |
+
<td><input value="<?php echo $bgMsgTFormat ?>" type="text" name="bg[<?php echo $ii; ?>][SNAPTformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apBGTMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apBGTMsgFrmt".$ii, '', '58'); ?></td></tr>
|
139 |
+
<tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Message Format:', 'NS_SPAP') ?></th>
|
140 |
+
<td>
|
141 |
+
<textarea cols="150" rows="1" id="bg<?php echo $ii; ?>SNAPformat" name="bg[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('#bg<?php echo $ii; ?>SNAPformat').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apBGMsgFrmt<?php echo $ii; ?>');"><?php echo $bgMsgFormat; ?></textarea>
|
142 |
+
<?php nxs_doShowHint("apBGMsgFrmt".$ii, '', '58'); ?></td></tr>
|
143 |
<?php }
|
144 |
}
|
145 |
}
|
176 |
curl_close($ch); $arr = explode("=",$result); $token = $arr[3]; if (trim($token)=='') return false; else return $token;
|
177 |
}}
|
178 |
if (!function_exists('nsBloggerNewPost')){ function nsBloggerNewPost($auth, $blogID, $title, $text) {$text = str_ireplace('allowfullscreen','', $text); $title = utf8_decode(strip_tags($title));
|
179 |
+
$text = preg_replace('/<object\b[^>]*>(.*?)<\/object>/is', "", $text); $text = preg_replace('/<iframe\b[^>]*>(.*?)<\/iframe>/is', "", $text); $text = utf8_decode($text);
|
180 |
|
181 |
$postText = '<entry xmlns="http://www.w3.org/2005/Atom"><title type="text">'.$title.'</title><content type="xhtml">'.$text.'</content></entry>'; //prr($postText);
|
182 |
$len = strlen($entry); $ch = curl_init("https://www.blogger.com/feeds/$blogID/posts/default");
|
188 |
if (stripos($result,'tag:blogger.com')!==false) { $postID = CutFromTo($result, " rel='alternate' type='text/html' href='", "'"); return array("code"=>"OK", "post_id"=>$postID); } else { prr($result); return false;}
|
189 |
}}
|
190 |
if (!function_exists("nxs_doPublishToBG")) { //## Second Function to Post to BG
|
191 |
+
function nxs_doPublishToBG($postID, $options){ $ntCd = 'BG'; $ntCdL = 'bg'; $ntNm = 'Blogger'; // $uqID = uniqid('BG_');
|
192 |
+
//$backtrace = debug_backtrace(); nxs_addToLogN('W', 'Enter', $ntCd, 'I am here - '.$ntCd."|".print_r($backtrace, true), '');
|
193 |
+
// if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToBG', array($postID, $options));
|
194 |
$blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url();
|
195 |
$addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'ACCNAME'=>$options['nName'], 'POSTID'=>$postID));
|
196 |
+
$ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
|
197 |
+
$logNT = '<span style="color:#F87907">'.$ntNm.'</span> - '.$options['nName'];
|
198 |
+
$snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
|
199 |
if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
|
200 |
+
$snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') {
|
201 |
+
nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'); return;
|
202 |
+
}
|
203 |
}
|
204 |
+
|
205 |
if ($postID=='0') { echo "Testing ... <br/><br/>"; $msgT = 'Test Post from '.htmlentities($blogTitle); $link = home_url(); $msg = 'Test Post from '.$blogTitle. " ".$link; }
|
206 |
+
else { $post = get_post($postID); if(!$post) return; $msgFormat = $options['bgMsgFormat']; $msg = nsFormatMessage($msgFormat, $postID, $addParams);
|
207 |
$link = get_permalink($postID); $msgTFormat = $options['bgMsgTFormat']; $msgT = nsFormatMessage($msgTFormat, $postID, $addParams); nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
|
208 |
}
|
209 |
+
$extInfo = ' | PostID: '.$postID." - ".nxs_doQTrans($post->post_title, $lng);
|
210 |
//## Actual POST Code
|
211 |
$email = $options['bgUName']; $pass = substr($options['bgPass'], 0, 5)=='b4d7s'?nsx_doDecode(substr($options['bgPass'], 5)):$options['bgPass']; $blogID = $options['bgBlogID'];
|
212 |
//echo "###".$auth."|".$blogID."|".$msgT."|".$msg;
|
213 |
if ($options['bgInclTags']=='1'){$t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = implode('","',$tggs); $tags = nsTrnc($tags, 195, ',', ''); }
|
214 |
+
if (substr($tags, -1)=='"') $tags = substr($tags, 0, -1);
|
|
|
215 |
|
216 |
if (class_exists('DOMDocument')) {$doc = new DOMDocument(); @$doc->loadHTML('<?xml encoding="UTF-8">' .$msg); $doc->encoding = 'UTF-8'; $msg = $doc->saveHTML(); $msg = CutFromTo($msg, '<body>', '</body>');
|
217 |
$msg = preg_replace('/<br(.*?)\/?>/','<br$1/>',$msg); $msg = preg_replace('/<img(.*?)\/?>/','<img$1/>',$msg);
|
218 |
+
require_once ('apis/htmlNumTable.php'); if (is_array($HTML401NamedToNumeric)) { $msg = strtr($msg, $HTML401NamedToNumeric); $msgT = strtr($msgT, $HTML401NamedToNumeric); }
|
219 |
} // prr($text);
|
220 |
// prr($msg); echo " =HT= ";
|
221 |
+
$msg = preg_replace('/<script\b[^>]*>(.*?)<\/script>/is', "", $msg); $msg = preg_replace('/<!--(.*)-->/Uis', "", $msg); $nxshf = new NXS_HtmlFixer(); $nxshf->debug = false; $msg = $nxshf->getFixedHtml($msg);
|
222 |
+
$msg = str_replace("\r\n","\n", $msg); $msg = str_replace("\n\r","\n", $msg); $msg = str_replace("\r","\n", $msg); $msg = str_replace("\n","<br/>", $msg); // prr($msg); die();
|
|
|
223 |
if (function_exists("doConnectToBlogger")) {$auth = doConnectToBlogger($email, $pass); if ($auth!==false) $ret = $auth; else $ret = doPostToBlogger($blogID, $msgT, $msg, $tags);}
|
224 |
else {$auth = nsBloggerGetAuth($email, $pass); if ($auth===false) $ret = 'Incorrect Username/Password'; else { $msgT = str_ireplace('&', '&', $msgT);
|
225 |
$msgT = utf8_encode(str_ireplace('&', '&', $msgT)); $msg = utf8_encode($msg); $ret = nsBloggerNewPost($auth, $blogID, $msgT, $msg);
|
226 |
}}
|
227 |
//## /Actual POST Code
|
228 |
+
if ( (!is_array($ret)) && $ret!='OK') { if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '. strip_tags(print_r($ret, true)), $extInfo); return $ret; }
|
229 |
+
else { if ($postID=='0') { echo 'OK - Message Posted, please see your '.$ntNm.' Page '; nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); return 201;}
|
230 |
+
else { nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPosted'=>'1', 'pgID'=>$ret['post_id'], 'pDate'=>date('Y-m-d H:i:s')));
|
231 |
+
do_action('nxs_actOnBG', array('postID'=>$postID, 'pgID'=>$ret['post_id'], 'ii'=>$ii)); nxs_addToLogN( 'S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo);
|
232 |
+
} return 200;
|
233 |
+
}
|
234 |
}
|
235 |
}
|
236 |
|
inc-cl/di.php
CHANGED
@@ -16,7 +16,7 @@ if (!class_exists("nxs_snapClassDI")) { class nxs_snapClassDI {
|
|
16 |
<div class="nxs_box_inside">
|
17 |
<?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
|
18 |
<p style="margin:0px;margin-left:5px;">
|
19 |
-
<input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> />
|
20 |
<strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
|
21 |
<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'nxs_snap'); ?> ==></b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>
|
22 |
<a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
|
@@ -67,7 +67,11 @@ if (!class_exists("nxs_snapClassDI")) { class nxs_snapClassDI {
|
|
67 |
|
68 |
<div id="altFormat" style="">
|
69 |
<div style="width:100%;"><strong id="altFormatText"><?php _e('Post Text Format', 'nxs_snap'); ?></strong> (<a href="#" id="apDIMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apDIMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)</div>
|
70 |
-
|
|
|
|
|
|
|
|
|
71 |
</div><br/>
|
72 |
|
73 |
<?php if ($options['diPass']!='') { ?>
|
@@ -103,7 +107,8 @@ if (!class_exists("nxs_snapClassDI")) { class nxs_snapClassDI {
|
|
103 |
$isAvailDI = $ntOpt['diUName']!='' && $ntOpt['diPass']!=''; $diMsgFormat = htmlentities($ntOpt['diMsgFormat'], ENT_COMPAT, "UTF-8"); $diMsgTFormat = htmlentities($ntOpt['diMsgTFormat'], ENT_COMPAT, "UTF-8");
|
104 |
?>
|
105 |
<tr><th style="text-align:left;" colspan="2"><?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_DI<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
|
106 |
-
<?php if ($isAvailDI) { ?><input class="nxsGrpDoChb" value="1" id="doDI<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="di[<?php echo $ii; ?>][doDI]" <?php if ((
|
|
|
107 |
|
108 |
<div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/di16.png);">Diigo - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
|
109 |
if ($post->post_status == "publish" && $isAvailDI) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToDI_repostButton" id="rePostToDI_button" value="<?php _e('Repost to Diigo', 'nxs_snap') ?>" />
|
@@ -115,10 +120,12 @@ if (!class_exists("nxs_snapClassDI")) { class nxs_snapClassDI {
|
|
115 |
</td></tr>
|
116 |
<?php if (!$isAvailDI) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your Diigo Account to AutoPost to Diigo</b>
|
117 |
<?php } elseif ($post->post_status != "pubZlish") { ?>
|
118 |
-
<tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;"><?php _e('Title Format:', 'nxs_snap') ?></th>
|
119 |
-
<td><input value="<?php echo $diMsgTFormat ?>" type="text" name="di[<?php echo $ii; ?>][SNAPformatT]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apDIMsgTFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apDIMsgTFrmt".$ii); ?></td></tr>
|
120 |
-
<tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;"><?php _e('Text Format:', 'nxs_snap') ?></th>
|
121 |
-
<td
|
|
|
|
|
122 |
<?php }
|
123 |
}
|
124 |
}
|
@@ -219,23 +226,26 @@ if (!function_exists("nxs_doPostToDI")) { function nxs_doPostToDI($url, $subj,
|
|
219 |
}}
|
220 |
|
221 |
if (!function_exists("nxs_doPublishToDI")) { //## Second Function to Post to DI
|
222 |
-
function nxs_doPublishToDI($postID, $options){ global $nxs_diCkArray; $ntCd = 'DI'; $ntCdL = 'di'; $ntNm = 'Diigo';
|
223 |
-
|
224 |
-
$ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
|
|
|
|
|
225 |
if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
|
226 |
-
|
227 |
-
|
228 |
-
|
|
|
229 |
if ($postID=='0') { echo "Testing ... <br/><br/>"; $link = home_url(); $msg = 'Test Message from '.$link; $msgT = 'Test Link from '.$link; } else {
|
230 |
$post = get_post($postID); if(!$post) return; $link = get_permalink($postID);
|
231 |
$msgFormat = $options['diMsgFormat']; $diCat = $options['diCat']; $msg = nsFormatMessage($msgFormat, $postID); $msgFormatT = $options['diMsgTFormat']; $msgT = nsFormatMessage($msgFormatT, $postID);
|
232 |
nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
|
233 |
-
}
|
234 |
-
|
235 |
//## Actual POST Code
|
236 |
$email = $options['diUName']; $pass = (substr($options['diPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['diPass'], 5)):$options['diPass']);
|
237 |
$dusername = $options['diUName']; //$link = urlencode($link); $desc = urlencode(substr($msg, 0, 500));
|
238 |
-
|
239 |
$t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = (implode(',',$tggs)); $tags = str_replace(' ','+',$tags);
|
240 |
|
241 |
$flds = array(); $flds['key']=$options['diAPIKey']; $flds['url']=$link; $flds['title']=nsTrnc($msgT, 250); $flds['desc']=nsTrnc($msg, 250); $flds['tags']=$tags; $flds['shared']='yes';
|
@@ -243,14 +253,14 @@ if (!function_exists("nxs_doPublishToDI")) { //## Second Function to Post to DI
|
|
243 |
$cnt = wp_remote_post( 'https://secure.diigo.com/api/v2/bookmarks', array( 'method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds));
|
244 |
|
245 |
if( is_wp_error( $cnt ) ) {
|
246 |
-
$ret = 'Something went wrong - ';
|
247 |
} else {
|
248 |
if (is_array($cnt) && stripos($cnt['body'],'"code":1')!==false)
|
249 |
-
{ $ret = 'OK'; nxs_metaMarkAsPosted($postID, 'DI', $options['ii'], array('isPosted'=>'1', 'pgID'=>'DI', 'pDate'=>date('Y-m-d H:i:s')));
|
250 |
-
else { if ($cnt['response']['code']=='401') $ret = " Incorrect Username/Password "; else $ret = 'Something went wrong - ';
|
251 |
}
|
252 |
}
|
253 |
-
if ($ret!='OK') { if ($postID=='0') echo $ret; } else if ($postID=='0') { echo 'OK - Message Posted, please see your Diigo Page';
|
254 |
if ($ret == 'OK') return 200; else return $ret;
|
255 |
|
256 |
}
|
16 |
<div class="nxs_box_inside">
|
17 |
<?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
|
18 |
<p style="margin:0px;margin-left:5px;">
|
19 |
+
<input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> /> <?php if ((int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
|
20 |
<strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
|
21 |
<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'nxs_snap'); ?> ==></b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>
|
22 |
<a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
|
67 |
|
68 |
<div id="altFormat" style="">
|
69 |
<div style="width:100%;"><strong id="altFormatText"><?php _e('Post Text Format', 'nxs_snap'); ?></strong> (<a href="#" id="apDIMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apDIMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)</div>
|
70 |
+
|
71 |
+
|
72 |
+
<textarea cols="150" rows="3" id="di<?php echo $ii; ?>SNAPformat" name="di[<?php echo $ii; ?>][apDIMsgFrmt]" style="width:51%;max-width: 650px;" onfocus="jQuery('#di<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('apDIMsgFrmt<?php echo $ii; ?>');"><?php if ($isNew) echo "%EXCERPT%"; else _e(apply_filters('format_to_edit', htmlentities($options['diMsgFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap'); ?></textarea>
|
73 |
+
|
74 |
+
<?php nxs_doShowHint("apDIMsgFrmt".$ii); ?>
|
75 |
</div><br/>
|
76 |
|
77 |
<?php if ($options['diPass']!='') { ?>
|
107 |
$isAvailDI = $ntOpt['diUName']!='' && $ntOpt['diPass']!=''; $diMsgFormat = htmlentities($ntOpt['diMsgFormat'], ENT_COMPAT, "UTF-8"); $diMsgTFormat = htmlentities($ntOpt['diMsgTFormat'], ENT_COMPAT, "UTF-8");
|
108 |
?>
|
109 |
<tr><th style="text-align:left;" colspan="2"><?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_DI<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
|
110 |
+
<?php if ($isAvailDI) { ?><input class="nxsGrpDoChb" value="1" id="doDI<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="di[<?php echo $ii; ?>][doDI]" <?php if ((int)$doDI == 1) echo 'checked="checked" title="def"'; ?> />
|
111 |
+
<?php if ($post->post_status == "publish") { ?> <input type="hidden" name="di[<?php echo $ii; ?>][doDI]" value="<?php echo $doDI;?>"> <?php } ?> <?php } ?>
|
112 |
|
113 |
<div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/di16.png);">Diigo - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
|
114 |
if ($post->post_status == "publish" && $isAvailDI) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToDI_repostButton" id="rePostToDI_button" value="<?php _e('Repost to Diigo', 'nxs_snap') ?>" />
|
120 |
</td></tr>
|
121 |
<?php if (!$isAvailDI) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your Diigo Account to AutoPost to Diigo</b>
|
122 |
<?php } elseif ($post->post_status != "pubZlish") { ?>
|
123 |
+
<tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Title Format:', 'nxs_snap') ?></th>
|
124 |
+
<td><input value="<?php echo $diMsgTFormat ?>" type="text" name="di[<?php echo $ii; ?>][SNAPformatT]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apDIMsgTFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apDIMsgTFrmt".$ii, '', '58'); ?></td></tr>
|
125 |
+
<tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Text Format:', 'nxs_snap') ?></th>
|
126 |
+
<td>
|
127 |
+
<textarea cols="150" rows="1" id="di<?php echo $ii; ?>SNAPformat" name="di[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('#di<?php echo $ii; ?>SNAPformat').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apDIMsgFrmt<?php echo $ii; ?>');"><?php echo $diMsgFormat; ?></textarea>
|
128 |
+
<?php nxs_doShowHint("apDIMsgFrmt".$ii, '', '58'); ?></td></tr>
|
129 |
<?php }
|
130 |
}
|
131 |
}
|
226 |
}}
|
227 |
|
228 |
if (!function_exists("nxs_doPublishToDI")) { //## Second Function to Post to DI
|
229 |
+
function nxs_doPublishToDI($postID, $options){ global $nxs_diCkArray; $ntCd = 'DI'; $ntCdL = 'di'; $ntNm = 'Diigo';
|
230 |
+
// if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToDI', array($postID, $options));
|
231 |
+
$ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
|
232 |
+
$logNT = '<span style="color:#000080">Diigo</span> - '.$options['nName'];
|
233 |
+
$snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
|
234 |
if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
|
235 |
+
$snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') { sleep(5);
|
236 |
+
nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'); return;
|
237 |
+
}
|
238 |
+
}
|
239 |
if ($postID=='0') { echo "Testing ... <br/><br/>"; $link = home_url(); $msg = 'Test Message from '.$link; $msgT = 'Test Link from '.$link; } else {
|
240 |
$post = get_post($postID); if(!$post) return; $link = get_permalink($postID);
|
241 |
$msgFormat = $options['diMsgFormat']; $diCat = $options['diCat']; $msg = nsFormatMessage($msgFormat, $postID); $msgFormatT = $options['diMsgTFormat']; $msgT = nsFormatMessage($msgFormatT, $postID);
|
242 |
nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
|
243 |
+
}
|
244 |
+
$extInfo = ' | PostID: '.$postID." - ".$post->post_title;
|
245 |
//## Actual POST Code
|
246 |
$email = $options['diUName']; $pass = (substr($options['diPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['diPass'], 5)):$options['diPass']);
|
247 |
$dusername = $options['diUName']; //$link = urlencode($link); $desc = urlencode(substr($msg, 0, 500));
|
248 |
+
|
249 |
$t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = (implode(',',$tggs)); $tags = str_replace(' ','+',$tags);
|
250 |
|
251 |
$flds = array(); $flds['key']=$options['diAPIKey']; $flds['url']=$link; $flds['title']=nsTrnc($msgT, 250); $flds['desc']=nsTrnc($msg, 250); $flds['tags']=$tags; $flds['shared']='yes';
|
253 |
$cnt = wp_remote_post( 'https://secure.diigo.com/api/v2/bookmarks', array( 'method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds));
|
254 |
|
255 |
if( is_wp_error( $cnt ) ) {
|
256 |
+
$ret = 'Something went wrong - '; nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.$ret. "ERR: ".print_r($cnt, true), $extInfo);
|
257 |
} else {
|
258 |
if (is_array($cnt) && stripos($cnt['body'],'"code":1')!==false)
|
259 |
+
{ $ret = 'OK'; nxs_metaMarkAsPosted($postID, 'DI', $options['ii'], array('isPosted'=>'1', 'pgID'=>'DI', 'pDate'=>date('Y-m-d H:i:s'))); nxs_addToLogN( 'S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); }
|
260 |
+
else { if ($cnt['response']['code']=='401') $ret = " Incorrect Username/Password "; else $ret = 'Something went wrong - '; nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.$ret. "ERR: ".print_r($cnt, true), $extInfo);
|
261 |
}
|
262 |
}
|
263 |
+
if ($ret!='OK') { if ($postID=='0') echo $ret; } else if ($postID=='0') { echo 'OK - Message Posted, please see your Diigo Page'; nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); }
|
264 |
if ($ret == 'OK') return 200; else return $ret;
|
265 |
|
266 |
}
|
inc-cl/dl.php
CHANGED
@@ -15,7 +15,7 @@ if (!class_exists("nxs_snapClassDL")) { class nxs_snapClassDL {
|
|
15 |
<div class="nxs_box_inside">
|
16 |
<?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
|
17 |
<p style="margin:0px;margin-left:5px;">
|
18 |
-
<input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> />
|
19 |
<strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
|
20 |
<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'nxs_snap'); ?> ==></b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>
|
21 |
<a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
|
@@ -58,7 +58,10 @@ if (!class_exists("nxs_snapClassDL")) { class nxs_snapClassDL {
|
|
58 |
|
59 |
<div id="altFormat" style="">
|
60 |
<div style="width:100%;"><strong id="altFormatText"><?php _e('Post Text Format', 'nxs_snap'); ?></strong> (<a href="#" id="apDLMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apDLMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)</div>
|
61 |
-
|
|
|
|
|
|
|
62 |
</div><br/>
|
63 |
|
64 |
<?php if ($gpo['dlPass']!='') { ?>
|
@@ -95,7 +98,8 @@ if (!class_exists("nxs_snapClassDL")) { class nxs_snapClassDL {
|
|
95 |
$isAvailDL = $ntOpt['dlUName']!='' && $ntOpt['dlPass']!=''; $dlMsgFormat = htmlentities($ntOpt['dlMsgFormat'], ENT_COMPAT, "UTF-8"); $dlMsgTFormat = htmlentities($ntOpt['dlMsgTFormat'], ENT_COMPAT, "UTF-8");
|
96 |
?>
|
97 |
<tr><th style="text-align:left;" colspan="2"><?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_DL<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
|
98 |
-
<?php if ($isAvailDL) { ?><input class="nxsGrpDoChb" value="1" id="doDL<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="dl[<?php echo $ii; ?>][doDL]" <?php if ((
|
|
|
99 |
|
100 |
<div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/dl16.png);">Delicious - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
|
101 |
if ($post->post_status == "publish" && $isAvailDL) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToDL_repostButton" id="rePostToDL_button" value="<?php _e('Repost to Delicious', 'nxs_snap') ?>" />
|
@@ -111,11 +115,13 @@ if (!class_exists("nxs_snapClassDL")) { class nxs_snapClassDL {
|
|
111 |
<?php if (!$isAvailDL) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your Delicious Account to AutoPost to Delicious</b>
|
112 |
<?php } elseif ($post->post_status != "pubZlish") { ?>
|
113 |
|
114 |
-
<tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;"><?php _e('Title Format:', 'nxs_snap') ?></th>
|
115 |
-
<td><input value="<?php echo $dlMsgTFormat ?>" type="text" name="dl[<?php echo $ii; ?>][SNAPformatT]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apDLTMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apDLTMsgFrmt".$ii); ?></td></tr>
|
116 |
|
117 |
-
<tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;"><?php _e('Text Format:', 'nxs_snap') ?></th>
|
118 |
-
<td
|
|
|
|
|
119 |
<?php }
|
120 |
}
|
121 |
}
|
@@ -154,20 +160,24 @@ if (!function_exists("nxs_getDLHeaders")) { function nxs_getDLHeaders($up){ $hd
|
|
154 |
}}
|
155 |
|
156 |
if (!function_exists("nxs_doPublishToDL")) { //## Second Function to Post to DL
|
157 |
-
function nxs_doPublishToDL($postID, $options){ $ntCd = 'DL'; $ntCdL = 'dl'; $ntNm = 'Delicious';
|
158 |
-
|
159 |
-
$ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
|
|
|
|
|
160 |
if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
|
161 |
-
|
162 |
-
|
|
|
|
|
163 |
|
164 |
if ($postID=='0') { echo "Testing ... <br/><br/>"; $link = home_url(); $msgT = 'Test Link from '.$link; } else { $post = get_post($postID); if(!$post) return; $link = get_permalink($postID);
|
165 |
$msgFormat = $options['dlMsgFormat']; $msgTFormat = $options['dlMsgTFormat']; $msgT = nsFormatMessage($msgTFormat, $postID); $msg = nsFormatMessage($msgFormat, $postID);
|
166 |
nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
|
167 |
}
|
|
|
168 |
$dusername = $options['dlUName']; $pass = (substr($options['dlPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['dlPass'], 5)):$options['dlPass']);
|
169 |
-
$api = "api.del.icio.us/v1"; $link = urlencode($link); $desc = urlencode(substr($msgT, 0, 250)); $ext = urlencode(substr($msg, 0, 1000));
|
170 |
-
$extInfo = ' | PostID: '.$postID." - ".$post->post_title; $logNT = '<span style="color:#000080">Delicious</span> - '.$options['nName'];
|
171 |
$t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = urlencode(implode(',',$tggs)); $tags = str_replace(' ','+',$tags);
|
172 |
$apicall = "https://$api/posts/add?red=api&url=$link&description=$desc&extended=$ext&tags=$tags";
|
173 |
$hdrsArr = nxs_getDLHeaders($dusername.':'.$pass); $cnt = wp_remote_get( $apicall, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr) ); // prr($cnt);
|
@@ -176,16 +186,17 @@ if (!function_exists("nxs_doPublishToDL")) { //## Second Function to Post to DL
|
|
176 |
$cnt = wp_remote_get( $apicall, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr) );}
|
177 |
}
|
178 |
if(is_wp_error($cnt)) {
|
179 |
-
$ret = 'Something went wrong - '."http://$dusername:*********@$api/posts/add?&url=$link&description=$desc&extended=$ext&tags=$tags";
|
180 |
} else {
|
181 |
if (is_array($cnt) && stripos($cnt['body'],'code="done"')!==false)
|
182 |
-
{ $ret = 'OK'; nxs_metaMarkAsPosted($postID, 'DL', $options['ii'], array('isPosted'=>'1', 'pgID'=>'DL', 'pDate'=>date('Y-m-d H:i:s')));
|
183 |
-
elseif (is_array($cnt) && $cnt['body']=='<?xml version="1.0" encoding="UTF-8"?>') { $ret = 'It looks like Delicious API is Down';
|
184 |
-
elseif (is_array($cnt) && stripos($cnt['body'],'item already exists')!==false) { $ret = '..All good, but this link has already been bookmarked..';
|
185 |
-
else { if ($cnt['response']['code']=='401') $ret = " Incorrect Username/Password "; else $ret = 'Something went wrong - '."https://$dusername:*********@$api/posts/add?&url=$link&description=$desc&extended=$ext&tags=$tags";
|
|
|
186 |
}
|
187 |
}
|
188 |
-
if ($ret!='OK') { if ($postID=='0') echo $ret; } else if ($postID=='0') { echo 'OK - Message Posted, please see your Delicious Page';
|
189 |
if ($ret == 'OK') return 200; else return $ret;
|
190 |
|
191 |
}
|
15 |
<div class="nxs_box_inside">
|
16 |
<?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
|
17 |
<p style="margin:0px;margin-left:5px;">
|
18 |
+
<input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> /> <?php if ((int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
|
19 |
<strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
|
20 |
<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'nxs_snap'); ?> ==></b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>
|
21 |
<a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
|
58 |
|
59 |
<div id="altFormat" style="">
|
60 |
<div style="width:100%;"><strong id="altFormatText"><?php _e('Post Text Format', 'nxs_snap'); ?></strong> (<a href="#" id="apDLMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apDLMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)</div>
|
61 |
+
|
62 |
+
<textarea cols="150" rows="3" id="di<?php echo $ii; ?>SNAPformat" name="dl[<?php echo $ii; ?>][apDLMsgFrmt]" style="width:51%;max-width: 650px;" onfocus="jQuery('#dl<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('apDLMsgFrmt<?php echo $ii; ?>');"><?php if ($isNew) echo "%EXCERPT%"; else _e(apply_filters('format_to_edit', htmlentities($gpo['dlMsgFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap'); ?></textarea>
|
63 |
+
|
64 |
+
<?php nxs_doShowHint("apDLMsgFrmt".$ii); ?>
|
65 |
</div><br/>
|
66 |
|
67 |
<?php if ($gpo['dlPass']!='') { ?>
|
98 |
$isAvailDL = $ntOpt['dlUName']!='' && $ntOpt['dlPass']!=''; $dlMsgFormat = htmlentities($ntOpt['dlMsgFormat'], ENT_COMPAT, "UTF-8"); $dlMsgTFormat = htmlentities($ntOpt['dlMsgTFormat'], ENT_COMPAT, "UTF-8");
|
99 |
?>
|
100 |
<tr><th style="text-align:left;" colspan="2"><?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_DL<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
|
101 |
+
<?php if ($isAvailDL) { ?><input class="nxsGrpDoChb" value="1" id="doDL<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="dl[<?php echo $ii; ?>][doDL]" <?php if ((int)$doDL == 1) echo 'checked="checked" title="def"'; ?> />
|
102 |
+
<?php if ($post->post_status == "publish") { ?> <input type="hidden" name="dl[<?php echo $ii; ?>][doDL]" value="<?php echo $doDL;?>"> <?php } ?> <?php } ?>
|
103 |
|
104 |
<div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/dl16.png);">Delicious - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
|
105 |
if ($post->post_status == "publish" && $isAvailDL) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToDL_repostButton" id="rePostToDL_button" value="<?php _e('Repost to Delicious', 'nxs_snap') ?>" />
|
115 |
<?php if (!$isAvailDL) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your Delicious Account to AutoPost to Delicious</b>
|
116 |
<?php } elseif ($post->post_status != "pubZlish") { ?>
|
117 |
|
118 |
+
<tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Title Format:', 'nxs_snap') ?></th>
|
119 |
+
<td><input value="<?php echo $dlMsgTFormat ?>" type="text" name="dl[<?php echo $ii; ?>][SNAPformatT]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apDLTMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apDLTMsgFrmt".$ii, '', '58'); ?></td></tr>
|
120 |
|
121 |
+
<tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Text Format:', 'nxs_snap') ?></th>
|
122 |
+
<td>
|
123 |
+
<textarea cols="150" rows="1" id="dl<?php echo $ii; ?>SNAPformat" name="dl[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('#dl<?php echo $ii; ?>SNAPformat').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apDLMsgFrmt<?php echo $ii; ?>');"><?php echo $dlMsgFormat; ?></textarea>
|
124 |
+
<?php nxs_doShowHint("apDLMsgFrmt".$ii, '', '58'); ?></td></tr>
|
125 |
<?php }
|
126 |
}
|
127 |
}
|
160 |
}}
|
161 |
|
162 |
if (!function_exists("nxs_doPublishToDL")) { //## Second Function to Post to DL
|
163 |
+
function nxs_doPublishToDL($postID, $options){ $ntCd = 'DL'; $ntCdL = 'dl'; $ntNm = 'Delicious';
|
164 |
+
// if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToDL', array($postID, $options));
|
165 |
+
$ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
|
166 |
+
$logNT = '<span style="color:#000080">Delicious</span> - '.$options['nName'];
|
167 |
+
$snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
|
168 |
if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
|
169 |
+
$snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') { sleep(5);
|
170 |
+
nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'); return;
|
171 |
+
}
|
172 |
+
}
|
173 |
|
174 |
if ($postID=='0') { echo "Testing ... <br/><br/>"; $link = home_url(); $msgT = 'Test Link from '.$link; } else { $post = get_post($postID); if(!$post) return; $link = get_permalink($postID);
|
175 |
$msgFormat = $options['dlMsgFormat']; $msgTFormat = $options['dlMsgTFormat']; $msgT = nsFormatMessage($msgTFormat, $postID); $msg = nsFormatMessage($msgFormat, $postID);
|
176 |
nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
|
177 |
}
|
178 |
+
$extInfo = ' | PostID: '.$postID." - ".$post->post_title;
|
179 |
$dusername = $options['dlUName']; $pass = (substr($options['dlPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['dlPass'], 5)):$options['dlPass']);
|
180 |
+
$api = "api.del.icio.us/v1"; $link = urlencode($link); $desc = urlencode(substr($msgT, 0, 250)); $ext = urlencode(substr($msg, 0, 1000));
|
|
|
181 |
$t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = urlencode(implode(',',$tggs)); $tags = str_replace(' ','+',$tags);
|
182 |
$apicall = "https://$api/posts/add?red=api&url=$link&description=$desc&extended=$ext&tags=$tags";
|
183 |
$hdrsArr = nxs_getDLHeaders($dusername.':'.$pass); $cnt = wp_remote_get( $apicall, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr) ); // prr($cnt);
|
186 |
$cnt = wp_remote_get( $apicall, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr) );}
|
187 |
}
|
188 |
if(is_wp_error($cnt)) {
|
189 |
+
$ret = 'Something went wrong - '."http://$dusername:*********@$api/posts/add?&url=$link&description=$desc&extended=$ext&tags=$tags"; nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.$ret. "ERR: ".print_r($cnt, true), $extInfo);
|
190 |
} else {
|
191 |
if (is_array($cnt) && stripos($cnt['body'],'code="done"')!==false)
|
192 |
+
{ $ret = 'OK'; nxs_metaMarkAsPosted($postID, 'DL', $options['ii'], array('isPosted'=>'1', 'pgID'=>'DL', 'pDate'=>date('Y-m-d H:i:s'))); nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); }
|
193 |
+
elseif (is_array($cnt) && $cnt['body']=='<?xml version="1.0" encoding="UTF-8"?>') { $ret = 'It looks like Delicious API is Down'; nxs_addToLogN('E', 'Error', $logNT, 'It looks like Delicious API is Down', $extInfo); }
|
194 |
+
elseif (is_array($cnt) && stripos($cnt['body'],'item already exists')!==false) { $ret = '..All good, but this link has already been bookmarked..'; nxs_addToLogN('S', 'Skipped', $logNT, 'All good, but this link has already been bookmarked', $extInfo); }
|
195 |
+
else { if ($cnt['response']['code']=='401') $ret = " Incorrect Username/Password "; else $ret = 'Something went wrong - '."https://$dusername:*********@$api/posts/add?&url=$link&description=$desc&extended=$ext&tags=$tags";
|
196 |
+
nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.$ret. "ERR: ".print_r($cnt, true), $extInfo);
|
197 |
}
|
198 |
}
|
199 |
+
if ($ret!='OK') { if ($postID=='0') echo $ret; } else if ($postID=='0') { echo 'OK - Message Posted, please see your Delicious Page'; nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); }
|
200 |
if ($ret == 'OK') return 200; else return $ret;
|
201 |
|
202 |
}
|
inc-cl/fb.api.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
//## NextScripts Facebook Connection Class
|
3 |
+
$nxs_snapAPINts[] = array('code'=>'FB', 'lcode'=>'fb', 'name'=>'Facebook');
|
4 |
+
|
5 |
+
if (!class_exists("nxs_class_SNAP_FB")) { class nxs_class_SNAP_FB {
|
6 |
+
|
7 |
+
var $ntCode = 'FB';
|
8 |
+
var $ntLCode = 'fb';
|
9 |
+
|
10 |
+
function doPost($options, $message){ if (!is_array($options)) return false; $out = array(); //return false;
|
11 |
+
foreach ($options as $ii=>$ntOpts) $out[$ii] = $this->doPostToNT($ntOpts, $message);
|
12 |
+
return $out;
|
13 |
+
}
|
14 |
+
function doPostToNT($options, $message){ require_once ('apis/facebook.php'); $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>''); // prr($message); prr($options);
|
15 |
+
//## Check settings
|
16 |
+
if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
|
17 |
+
if (!isset($options['fbAppAuthToken']) || trim($options['fbAppAuthToken'])=='') { $badOut['Error'] = 'No Auth Token Found'; return $badOut; }
|
18 |
+
//## Make Post
|
19 |
+
$facebook = new NXS_Facebook(array( 'appId' => $options['fbAppID'], 'secret' => $options['fbAppSec'], 'cookie' => true ));
|
20 |
+
if (!isset($options['fbAppPageAuthToken']) || trim($options['fbAppPageAuthToken'])=='') $options['fbAppPageAuthToken'] = $options['fbAppAuthToken'];
|
21 |
+
|
22 |
+
//## Some OLD Format Conversion
|
23 |
+
if (!isset($options['attachType']) && isset($options['fbAttch'])) $options['attachType'] = $options['fbAttch'];
|
24 |
+
if (!isset($options['postType']) && isset($options['fbPostType'])) $options['postType'] = $options['fbPostType'];
|
25 |
+
if (!isset($options['pgID']) && isset($options['fbPgID'])) $options['pgID'] = $options['fbPgID'];
|
26 |
+
|
27 |
+
$msg = $message['message']; $imgURL = $message['imageURL']; $fbPostType = $options['postType']; $fbWhere = 'feed';
|
28 |
+
$attachType = $options['attachType']; if ($attachType=='1') $attachType = 'A'; else $attachType = 'S';
|
29 |
+
if ($options['imgUpl']!='2') $options['imgUpl'] = 'T'; else $options['imgUpl'] = 'A'; $page_id = $options['pgID'];
|
30 |
+
|
31 |
+
$mssg = array('access_token' => $options['fbAppPageAuthToken'], 'message' => $msg);
|
32 |
+
|
33 |
+
if ($fbPostType=='I' && trim($imgURL)=='') $fbPostType='T';
|
34 |
+
if ($fbPostType=='A' || $fbPostType=='') {
|
35 |
+
if (($attachType=='A' || $attachType=='S')) { $attArr = array('name' => $message['title'], 'caption' => $message['siteName'], 'link' =>$message['link'], 'description' => $message['description']); $mssg = array_merge($mssg, $attArr); ; }
|
36 |
+
if ($attachType=='A') $mssg['actions'] = array(array('name' => $message['siteName'], 'link' =>$message['link']));
|
37 |
+
if (trim($imgURL)!='') $mssg['picture'] = $imgURL; if (trim($message['videoURL'])!='') $mssg['source'] = $message['videoURL'];
|
38 |
+
} elseif ($fbPostType=='I') { $facebook->setFileUploadSupport(true); $fbWhere = 'photos'; $mssg['url'] = $imgURL;
|
39 |
+
if ($options['imgUpl']=='T') { //## Try to Post to TImeline
|
40 |
+
$aacct = array('access_token' => $options['fbAppPageAuthToken']);
|
41 |
+
try { $albums = $facebook->api("/$page_id/albums", "get", $aacct); } catch (NXS_FacebookApiException $e) { $badOut['Error'] = ' [ERROR] '.$e->getMessage()."<br/>\n"; }
|
42 |
+
|
43 |
+
if (isset($albums) && isset($albums["data"]) && is_array($albums["data"])) foreach ($albums["data"] as $album) { if ($album["type"] == "wall") { $chosen_album = $album; break;}}
|
44 |
+
if (isset($chosen_album) && isset($chosen_album["id"])) $page_id = $chosen_album["id"];
|
45 |
+
}
|
46 |
+
}
|
47 |
+
//prr($message); prr($mssg); prr($options); //die();
|
48 |
+
try { $ret = $facebook->api("/$page_id/".$fbWhere, "post", $mssg);} catch (NXS_FacebookApiException $e) { $badOut['Error'] = ' [ERROR] '.$e->getMessage()."<br/>\n";
|
49 |
+
if (stripos($e->getMessage(),'This API call requires a valid app_id')!==false) {
|
50 |
+
if ( !is_numeric($page_id) && stripos($options['fbURL'], '/groups/')!=false) $badOut['Error'] .= ' [ERROR] Unrecognized Facebook Group ID. Please use numeric ID.';
|
51 |
+
else $badOut['Error'] .= " [ERROR] (invalid app_id) Authorization Error. <br/>\r\n<br/>\r\n Possible Reasons: <br/>\r\n 1. Your app is not authorized. Please go to the Plugin Settings - Facebook and authorize it.<br/>\r\n 2. The current authorized user have no rights to post to the specified page. Please login to Facebook as the correct user and Re-Authorize the Plugin.<br/>\r\n 3. You clicked 'Skip' or unchecked the 'Manage Pages' or 'Post on your behalf' permissions when Authorization wizard asked you. Please Re-Authorize the Plugin<br/>\r\n";
|
52 |
+
}
|
53 |
+
}
|
54 |
+
if (isset($ret['id']) && $ret['id']!='') {
|
55 |
+
$pgID = (isset($ret['post_id']) && strpos($ret['post_id'],'_')!==false)?$ret['post_id']:$ret['id']; $pgg = explode('_', $pgID); $postID = $pgg[1];
|
56 |
+
$pgURL = 'http://www.facebook.com/'.$options['pgID'].'/posts/'.$postID;
|
57 |
+
return array('isPosted'=>'1', 'postID'=>$pgID, 'postURL'=>$pgURL, 'pDate'=>date('Y-m-d H:i:s'));
|
58 |
+
} else return $badOut;
|
59 |
+
}
|
60 |
+
}}
|
61 |
+
?>
|
inc-cl/fb.php
CHANGED
@@ -51,7 +51,7 @@ if (!class_exists("nxs_snapClassFB")) { class nxs_snapClassFB {
|
|
51 |
<?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = str_ireplace('https://www.facebook.com','', str_ireplace('http://www.facebook.com','', $pbo['fbURL']));
|
52 |
if (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='') $pbo[$ntInfo['lcode'].'OK'] = (isset($pbo['fbAppAuthUser']) && $pbo['fbAppAuthUser']>1)?'1':''; ?>
|
53 |
<p style="margin:0px;margin-left:5px;">
|
54 |
-
<input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> />
|
55 |
<strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
|
56 |
<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'nxs_snap'); ?> ==></b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>
|
57 |
<a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
|
@@ -63,7 +63,7 @@ if (!class_exists("nxs_snapClassFB")) { class nxs_snapClassFB {
|
|
63 |
|
64 |
}
|
65 |
//#### Show NEW Settings Page
|
66 |
-
function showNewNTSettings($mfbo){ $fbo = array('nName'=>'', 'doFB'=>'1', 'fbURL'=>'', 'fbAppID'=>'', 'imgUpl'=>'1', 'fbPostType'=>'A', 'fbMsgAFormat'=>'', 'fbAppSec'=>'', 'fbAttch'=>'1', 'fbPgID'=>'', 'fbAppAuthUser'=>'', 'fbMsgFormat'=>'New post has been published on %SITENAME%' ); $this->showNTSettings($mfbo, $fbo, true);}
|
67 |
//#### Show Unit Settings
|
68 |
function showNTSettings($ii, $fbo, $isNew=false){ global $nxs_plurl, $nxs_snapThisPageUrl, $plgn_NS_SNAutoPoster; if ((int)$fbo['fbAttch']==0 && (!isset($fbo['trPostType']) || $fbo['trPostType']=='')) $fbo['trPostType'] = 'T';
|
69 |
if (!isset($plgn_NS_SNAutoPoster)) return; $gOptions = $plgn_NS_SNAutoPoster->nxs_options;
|
@@ -71,8 +71,8 @@ if (!class_exists("nxs_snapClassFB")) { class nxs_snapClassFB {
|
|
71 |
<div id="doFB<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>" style="background-image: url(<?php echo $nxs_plurl; ?>img/fb-bg.png); background-position:90% 10%;"> <input type="hidden" name="apDoSFB<?php echo $ii; ?>" value="0" id="apDoSFB<?php echo $ii; ?>" />
|
72 |
<?php if ($isNew) { ?> <input type="hidden" name="fb[<?php echo $ii; ?>][apDoFB]" value="1" id="apDoNewFB<?php echo $ii; ?>" /> <?php } ?>
|
73 |
|
74 |
-
<div class="nsx_iconedTitle" style="float: right; max-width:
|
75 |
-
<span style="font-size: 10px;"
|
76 |
|
77 |
</div>
|
78 |
|
@@ -98,7 +98,8 @@ if (!class_exists("nxs_snapClassFB")) { class nxs_snapClassFB {
|
|
98 |
<div id="altFormat">
|
99 |
<div style="width:100%;"><strong id="altFormatText"><?php _e('Message text Format', 'nxs_snap'); ?>:</strong> (<a href="#" id="apFBMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apFBMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)</div>
|
100 |
|
101 |
-
<
|
|
|
102 |
</div><br/>
|
103 |
<div style="width:100%;"><strong style="font-size: 16px;" id="altFormatText">Post Type:</strong><-- (<a id="showShAtt" onmouseout="hidePopShAtt('<?php echo $ii; ?>X');" onmouseover="showPopShAtt('<?php echo $ii; ?>X', event);" onclick="return false;" class="underdash" href="http://www.nextscripts.com/blog/"><?php _e('What\'s the difference?', 'nxs_snap'); ?></a>) </div>
|
104 |
<div style="margin-left: 10px;">
|
@@ -156,7 +157,7 @@ if (!class_exists("nxs_snapClassFB")) { class nxs_snapClassFB {
|
|
156 |
<?php } else { if(isset($fbo['fbAppAuthUser']) && $fbo['fbAppAuthUser']>0) { ?>
|
157 |
<?php _e('Your Facebook Account has been authorized.', 'nxs_snap'); ?> User ID: <?php _e(apply_filters('format_to_edit', htmlentities($fbo['fbAppAuthUser'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>.
|
158 |
<?php _e('You can', 'nxs_snap'); ?> Re- <?php } ?>
|
159 |
-
<a href="https://www.facebook.com/dialog/oauth?client_id=<?php echo trim($fbo['fbAppID']);?>&client_secret=<?php echo trim($fbo['fbAppSec']);?>&scope=publish_stream,user_photos,offline_access,read_stream,manage_pages&redirect_uri=<?php echo trim(urlencode($nxs_snapThisPageUrl.'&auth=fb&acc='.$ii));?>">Authorize Your Facebook Account</a>
|
160 |
<?php if (!isset($fbo['fbAppAuthUser']) || $fbo['fbAppAuthUser']<1) { ?> <div class="blnkg"><=== <?php _e('Authorize your account', 'nxs_snap'); ?> ===</div>
|
161 |
<br/><br/><i> <?php _e('If you get Facebook message:', 'nxs_snap'); ?> <b>"Error. An error occurred. Please try again later."</b> or <b>"Error 191"</b> <?php _e('please make sure that domain name in your Facebook App matches your website domain exactly. Please note that www. and non www. versions are different domains.', 'nxs_snap'); ?></i> <?php }?>
|
162 |
<?php } ?>
|
@@ -217,7 +218,8 @@ if (!class_exists("nxs_snapClassFB")) { class nxs_snapClassFB {
|
|
217 |
|
218 |
<tr><th style="text-align:left;" colspan="2"> <?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_FB<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
|
219 |
|
220 |
-
<?php if ($isAvailFB) { ?><input class="nxsGrpDoChb" value="1" id="doFB<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="fb[<?php echo $ii; ?>][doFB]" <?php if ((
|
|
|
221 |
|
222 |
<div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/fb16.png);">Facebook - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th><td><?php //## Only show RePost button if the post is "published"
|
223 |
if ($post->post_status == "publish" && $isAvailFB) { ?>
|
@@ -261,15 +263,20 @@ if (!class_exists("nxs_snapClassFB")) { class nxs_snapClassFB {
|
|
261 |
<div class="popShAtt" id="popShAtt<?php echo $ii; ?>"><h3><?php _e('Two ways of attaching post on Facebook', 'nxs_snap'); ?></h3> <img src="<?php echo $nxs_plurl; ?>img/fb2wops.jpg" width="600" height="271" alt="<?php _e('Two ways of attaching post on Facebook', 'nxs_snap'); ?>"/></div>
|
262 |
<div class="popShAtt" id="popShAtt<?php echo $ii; ?>X"><h3><?php _e('Facebook Post Types', 'nxs_snap'); ?></h3><img src="<?php echo $nxs_plurl; ?>img/fbPostTypesDiff6.png" width="600" height="398" alt="<?php _e('Facebook Post Types', 'nxs_snap'); ?>"/></div>
|
263 |
</td></tr>
|
264 |
-
|
265 |
-
<tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;"><?php _e('
|
|
|
|
|
|
|
|
|
266 |
<td>
|
267 |
<?php if (1==1) { ?>
|
268 |
-
<textarea cols="150" rows="
|
269 |
<?php } else { ?>
|
270 |
-
<input value="<?php echo $fbMsgFormat ?>" type="text" name="fb[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apFBTMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apFBTMsgFrmt".$ii); ?>
|
271 |
<?php } ?>
|
272 |
</td></tr>
|
|
|
273 |
<?php }
|
274 |
}
|
275 |
|
@@ -287,11 +294,11 @@ if (!class_exists("nxs_snapClassFB")) { class nxs_snapClassFB {
|
|
287 |
|
288 |
if (!function_exists("nxs_getBackFBComments")) { function nxs_getBackFBComments($postID, $options, $po) { require_once ('apis/facebook.php'); $opts = array('access_token' => $options['fbAppPageAuthToken']);
|
289 |
$facebook = new NXS_Facebook(array( 'appId' => $options['fbAppID'], 'secret' => $options['fbAppSec'], 'cookie' => true )); $ci = 0;
|
290 |
-
$ret = $facebook->api($po['pgID']."/comments", "GET", $opts); $impCmnts = get_post_meta($postID, 'snapImportedComments', true);
|
291 |
if (is_array($ret) && is_array($ret['data'])) foreach ($ret['data'] as $comment){ $cid = $comment['id']; if (trim($cid)=='' || in_array('fbxcw'.$cid, $impCmnts)) continue; else $impCmnts[] = 'fbxcw'.$cid; // prr($impCmnts);
|
292 |
$authData = $facebook->api($comment['from']['id'], "GET", $opts);
|
293 |
$commentdata = array( 'comment_post_ID' => $postID, 'comment_author' => $comment['from']['name'], 'comment_author_email' => $comment['from']['id'].'@facebook.com',
|
294 |
-
'comment_author_url' => $authData['link'], 'comment_content' => $comment['message'], 'comment_date_gmt' => date('Y-m-d H:i:s', strtotime( $comment['created_time'] ) ), 'comment_type' => '
|
295 |
// prr($commentdata);
|
296 |
nxs_postNewComment($commentdata, $options['riCommentsAA']=='1'); $ci++;
|
297 |
}
|
@@ -304,90 +311,77 @@ if (!function_exists("nxs_rePostToFB_ajax")) { function nxs_rePostToFB_ajax() {
|
|
304 |
$fbpo = get_post_meta($postID, 'snapFB', true); /* echo $postID."|"; echo $fbpo; */ $fbpo = maybe_unserialize($fbpo); // prr($fbpo);
|
305 |
if (is_array($fbpo) && isset($fbpo[$ii]) && is_array($fbpo[$ii]) ){ $ntClInst = new nxs_snapClassFB(); $fbo = $ntClInst->adjMetaOpt($fbo, $fbpo[$ii]); } //prr($fbo);
|
306 |
if ($_POST['ri']=='1') { nxs_getBackFBComments($postID, $fbo, $fbpo[$ii]); die(); } else {
|
307 |
-
$result = nxs_doPublishToFB($postID, $fbo); if ($result == 200) die("
|
308 |
}
|
309 |
}
|
310 |
}
|
311 |
}
|
312 |
|
313 |
if (!function_exists("nxs_doPublishToFB")) { //## Second Function to Post to FB
|
314 |
-
function nxs_doPublishToFB($postID, $options){ global $ShownAds; $ntCd = 'FB'; $ntCdL = 'fb'; $ntNm = 'Facebook'; $dsc = '';
|
315 |
-
|
316 |
-
|
317 |
-
$
|
|
|
|
|
|
|
|
|
318 |
if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
if ($
|
326 |
-
|
327 |
-
|
328 |
-
|
|
|
|
|
|
|
329 |
$isAttachFB = $options['fbAttch']; $fbPostType = $options['fbPostType']; $isAttachVidFB = $options['fbAttchAsVid'];
|
330 |
-
nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
|
331 |
-
if (($isAttachFB=='1' || $isAttachFB=='2' || $fbPostType=='A')) $imgURL = nxs_getPostImage($postID, '
|
332 |
-
if ($fbPostType=='I') $imgURL = nxs_getPostImage($postID, 'full'); // prr($options); echo "PP - ".$postID; prr($src);
|
333 |
-
|
334 |
-
|
335 |
-
if (function_exists('
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
|
|
|
|
|
|
340 |
}
|
341 |
|
342 |
-
$dsc = strip_tags($dsc); $dsc = nxs_decodeEntitiesFull($dsc); $dsc = nsTrnc($dsc, 900, ' ');
|
343 |
$postSubtitle = home_url(); $msg = str_replace('<br>', "\n", $msg); $msg = str_replace('<br/>', "\n", $msg); $msg = str_replace('<br />', "\n", $msg);
|
344 |
-
$msg = strip_tags($msg); $msg = nxs_decodeEntitiesFull($msg);
|
345 |
-
|
346 |
-
if ($
|
347 |
-
|
348 |
-
|
349 |
-
if (trim($imgURL)!='') $mssg['picture'] = $imgURL;
|
350 |
-
if ($isAttachVidFB=='1') {$vids = nsFindVidsInPost($post); if (count($vids)>0) {
|
351 |
-
if (strlen($vids[0])==11) { $mssg['source'] = 'http://www.youtube.com/v/'.$vids[0]; $mssg['picture'] = 'http://img.youtube.com/vi/'.$vids[0].'/0.jpg'; }
|
352 |
-
if (strlen($vids[0])==8) { $mssg['source'] = 'https://secure.vimeo.com/moogaloop.swf?clip_id='.$vids[0].'&autoplay=1';
|
353 |
-
//$mssg['source'] = 'http://player.vimeo.com/video/'.$vids[0];
|
354 |
$apiURL = "http://vimeo.com/api/v2/video/".$vids[0].".json?callback=showThumb"; $json = wp_remote_get($apiURL);
|
355 |
-
if (!is_wp_error($json)) { $json = $json['body']; $json = str_replace('showThumb(','',$json); $json = str_replace('])',']',$json); $json = json_decode($json, true); $
|
356 |
}
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
$aacct = array('access_token' => $options['fbAppPageAuthToken']); $albums = $facebook->api("/$page_id/albums", "get", $aacct);
|
361 |
-
foreach ($albums["data"] as $album) { if ($album["type"] == "wall") { $chosen_album = $album; break;}}
|
362 |
-
if (isset($chosen_album) && isset($chosen_album["id"])) $page_id = $chosen_album["id"];
|
363 |
-
}
|
364 |
-
}
|
365 |
-
} // prr($mssg); // prr($options); // prr($facebook); echo "/$page_id/feed";
|
366 |
if (isset($ShownAds)) $ShownAds = $ShownAdsL; // FIX for the quick-adsense plugin
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
}
|
381 |
-
if ($postID=='0') echo 'Error:', $e->getMessage(), "\n"; return "Valid app_id ERROR:".$e->getMessage();
|
382 |
-
} // prr($ret);
|
383 |
-
if ($postID=='0') { prr($ret); if (isset($ret['id']) && $ret['id']!='') { _e('OK - Message Posted, please see your Facebook Page', 'nxs_snap'); nxs_addToLog($logNT, 'M', 'Test Message Posted, please see your Facebook Page'); }}
|
384 |
-
else { if (isset($ret['id']) && $ret['id']!='') { $pgID = (strpos($ret['post_id'],'_')!==false)?$ret['post_id']:$ret['id'];
|
385 |
-
nxs_metaMarkAsPosted($postID, 'FB', $options['ii'], array('isPosted'=>'1', 'pgID'=>$pgID, 'pDate'=>date('Y-m-d H:i:s')) );
|
386 |
-
nxs_addToLog($logNT, 'M', 'OK - Message Posted'.print_r($ret, true), $extInfo);
|
387 |
-
nxs_addToRI($postID);
|
388 |
-
} else nxs_addToLog($logNT, 'E', '-=ERROR=- '.print_r($ret, true), $extInfo);
|
389 |
-
}
|
390 |
-
}
|
391 |
}
|
392 |
|
393 |
?>
|
51 |
<?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = str_ireplace('https://www.facebook.com','', str_ireplace('http://www.facebook.com','', $pbo['fbURL']));
|
52 |
if (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='') $pbo[$ntInfo['lcode'].'OK'] = (isset($pbo['fbAppAuthUser']) && $pbo['fbAppAuthUser']>1)?'1':''; ?>
|
53 |
<p style="margin:0px;margin-left:5px;">
|
54 |
+
<input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> /> <?php if ((int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
|
55 |
<strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
|
56 |
<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'nxs_snap'); ?> ==></b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>
|
57 |
<a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
|
63 |
|
64 |
}
|
65 |
//#### Show NEW Settings Page
|
66 |
+
function showNewNTSettings($mfbo){ $fbo = array('nName'=>'', 'doFB'=>'1', 'fbURL'=>'', 'fbAppID'=>'', 'imgUpl'=>'1', 'fbPostType'=>'A', 'fbMsgAFormat'=>'', 'fbAppSec'=>'', 'fbAttch'=>'1', 'fbPgID'=>'', 'fbAppAuthUser'=>'', 'fbMsgFormat'=>__('New post (%TITLE%) has been published on %SITENAME%', 'nxs_snap') ); $this->showNTSettings($mfbo, $fbo, true);}
|
67 |
//#### Show Unit Settings
|
68 |
function showNTSettings($ii, $fbo, $isNew=false){ global $nxs_plurl, $nxs_snapThisPageUrl, $plgn_NS_SNAutoPoster; if ((int)$fbo['fbAttch']==0 && (!isset($fbo['trPostType']) || $fbo['trPostType']=='')) $fbo['trPostType'] = 'T';
|
69 |
if (!isset($plgn_NS_SNAutoPoster)) return; $gOptions = $plgn_NS_SNAutoPoster->nxs_options;
|
71 |
<div id="doFB<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>" style="background-image: url(<?php echo $nxs_plurl; ?>img/fb-bg.png); background-position:90% 10%;"> <input type="hidden" name="apDoSFB<?php echo $ii; ?>" value="0" id="apDoSFB<?php echo $ii; ?>" />
|
72 |
<?php if ($isNew) { ?> <input type="hidden" name="fb[<?php echo $ii; ?>][apDoFB]" value="1" id="apDoNewFB<?php echo $ii; ?>" /> <?php } ?>
|
73 |
|
74 |
+
<div class="nsx_iconedTitle" style="float: right; max-width: 322px; text-align: right; background-image: url(<?php echo $nxs_plurl; ?>img/fb16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-facebook-social-networks-auto-poster-wordpress/"><?php $nType="Facebook"; printf( __( 'Detailed %s Installation/Configuration Instructions', 'nxs_snap' ), $nType); ?></a><br/>
|
75 |
+
<span style="font-size: 10px;"><?php _e('Please use in your Facebook App:', 'nxs_snap'); ?> <br/> URL: <em style="font-size: 10px; color:#CB4B16;">http://<?php echo $_SERVER["SERVER_NAME"] ?></em> <br/>Domain: <em style="font-size: 10px; color:#CB4B16;"><?php echo $_SERVER["SERVER_NAME"] ?></em> </span>
|
76 |
|
77 |
</div>
|
78 |
|
98 |
<div id="altFormat">
|
99 |
<div style="width:100%;"><strong id="altFormatText"><?php _e('Message text Format', 'nxs_snap'); ?>:</strong> (<a href="#" id="apFBMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apFBMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)</div>
|
100 |
|
101 |
+
<textarea cols="150" rows="3" id="fb<?php echo $ii; ?>SNAPformat" name="fb[<?php echo $ii; ?>][apFBMsgFrmt]" style="width:51%;max-width: 610px;" onfocus="jQuery('#fb<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('apFBMsgFrmt<?php echo $ii; ?>');"><?php _e(apply_filters('format_to_edit', htmlentities($fbo['fbMsgFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?></textarea> <?php nxs_doShowHint("apFBMsgFrmt".$ii); ?>
|
102 |
+
<br/>
|
103 |
</div><br/>
|
104 |
<div style="width:100%;"><strong style="font-size: 16px;" id="altFormatText">Post Type:</strong><-- (<a id="showShAtt" onmouseout="hidePopShAtt('<?php echo $ii; ?>X');" onmouseover="showPopShAtt('<?php echo $ii; ?>X', event);" onclick="return false;" class="underdash" href="http://www.nextscripts.com/blog/"><?php _e('What\'s the difference?', 'nxs_snap'); ?></a>) </div>
|
105 |
<div style="margin-left: 10px;">
|
157 |
<?php } else { if(isset($fbo['fbAppAuthUser']) && $fbo['fbAppAuthUser']>0) { ?>
|
158 |
<?php _e('Your Facebook Account has been authorized.', 'nxs_snap'); ?> User ID: <?php _e(apply_filters('format_to_edit', htmlentities($fbo['fbAppAuthUser'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>.
|
159 |
<?php _e('You can', 'nxs_snap'); ?> Re- <?php } ?>
|
160 |
+
<a href="https://www.facebook.com/dialog/oauth?client_id=<?php echo trim($fbo['fbAppID']);?>&client_secret=<?php echo trim($fbo['fbAppSec']);?>&scope=publish_stream,user_photos,photo_upload,friends_photos,offline_access,read_stream,manage_pages,user_groups,friends_groups&redirect_uri=<?php echo trim(urlencode($nxs_snapThisPageUrl.'&auth=fb&acc='.$ii));?>">Authorize Your Facebook Account</a>
|
161 |
<?php if (!isset($fbo['fbAppAuthUser']) || $fbo['fbAppAuthUser']<1) { ?> <div class="blnkg"><=== <?php _e('Authorize your account', 'nxs_snap'); ?> ===</div>
|
162 |
<br/><br/><i> <?php _e('If you get Facebook message:', 'nxs_snap'); ?> <b>"Error. An error occurred. Please try again later."</b> or <b>"Error 191"</b> <?php _e('please make sure that domain name in your Facebook App matches your website domain exactly. Please note that www. and non www. versions are different domains.', 'nxs_snap'); ?></i> <?php }?>
|
163 |
<?php } ?>
|
218 |
|
219 |
<tr><th style="text-align:left;" colspan="2"> <?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_FB<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
|
220 |
|
221 |
+
<?php if ($isAvailFB) { ?><input class="nxsGrpDoChb" value="1" id="doFB<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="fb[<?php echo $ii; ?>][doFB]" <?php if ((int)$doFB == 1) echo 'checked="checked" title="def"'; ?> />
|
222 |
+
<?php if ($post->post_status == "publish") { ?> <input type="hidden" name="fb[<?php echo $ii; ?>][doFB]" value="<?php echo $doFB;?>"> <?php } ?> <?php } ?>
|
223 |
|
224 |
<div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/fb16.png);">Facebook - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th><td><?php //## Only show RePost button if the post is "published"
|
225 |
if ($post->post_status == "publish" && $isAvailFB) { ?>
|
263 |
<div class="popShAtt" id="popShAtt<?php echo $ii; ?>"><h3><?php _e('Two ways of attaching post on Facebook', 'nxs_snap'); ?></h3> <img src="<?php echo $nxs_plurl; ?>img/fb2wops.jpg" width="600" height="271" alt="<?php _e('Two ways of attaching post on Facebook', 'nxs_snap'); ?>"/></div>
|
264 |
<div class="popShAtt" id="popShAtt<?php echo $ii; ?>X"><h3><?php _e('Facebook Post Types', 'nxs_snap'); ?></h3><img src="<?php echo $nxs_plurl; ?>img/fbPostTypesDiff6.png" width="600" height="398" alt="<?php _e('Facebook Post Types', 'nxs_snap'); ?>"/></div>
|
265 |
</td></tr>
|
266 |
+
<!--
|
267 |
+
<tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Image(s) to use:', 'nxs_snap') ?></th>
|
268 |
+
<td><input type="checkbox" class="isAutoImg" checked="checked" id="isAutoImg-fb<?php echo $ii; ?>" name="fb[<?php echo $ii; ?>][isAutoImg]" value="A"/> <?php _e('Auto', 'nxs_snap'); ?><br/>
|
269 |
+
<div id="imgPrevList-fb<?php echo $ii; ?>" class="nxs_imgPrevList"></div></td></tr>
|
270 |
+
-->
|
271 |
+
<tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Message Format:', 'nxs_snap') ?></th>
|
272 |
<td>
|
273 |
<?php if (1==1) { ?>
|
274 |
+
<textarea cols="150" rows="2" id="fb<?php echo $ii; ?>SNAPformat" name="fb[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('#fb<?php echo $ii; ?>SNAPformat').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apFBTMsgFrmt<?php echo $ii; ?>');"><?php echo $fbMsgFormat ?></textarea>
|
275 |
<?php } else { ?>
|
276 |
+
<input value="<?php echo $fbMsgFormat ?>" type="text" name="fb[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apFBTMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apFBTMsgFrmt".$ii, '', '58'); ?>
|
277 |
<?php } ?>
|
278 |
</td></tr>
|
279 |
+
|
280 |
<?php }
|
281 |
}
|
282 |
|
294 |
|
295 |
if (!function_exists("nxs_getBackFBComments")) { function nxs_getBackFBComments($postID, $options, $po) { require_once ('apis/facebook.php'); $opts = array('access_token' => $options['fbAppPageAuthToken']);
|
296 |
$facebook = new NXS_Facebook(array( 'appId' => $options['fbAppID'], 'secret' => $options['fbAppSec'], 'cookie' => true )); $ci = 0;
|
297 |
+
$ret = $facebook->api($po['pgID']."/comments", "GET", $opts); $impCmnts = get_post_meta($postID, 'snapImportedComments', true); if (!is_array($impCmnts)) $impCmnts = array();
|
298 |
if (is_array($ret) && is_array($ret['data'])) foreach ($ret['data'] as $comment){ $cid = $comment['id']; if (trim($cid)=='' || in_array('fbxcw'.$cid, $impCmnts)) continue; else $impCmnts[] = 'fbxcw'.$cid; // prr($impCmnts);
|
299 |
$authData = $facebook->api($comment['from']['id'], "GET", $opts);
|
300 |
$commentdata = array( 'comment_post_ID' => $postID, 'comment_author' => $comment['from']['name'], 'comment_author_email' => $comment['from']['id'].'@facebook.com',
|
301 |
+
'comment_author_url' => $authData['link'], 'comment_content' => $comment['message'], 'comment_date_gmt' => date('Y-m-d H:i:s', strtotime( $comment['created_time'] ) ), 'comment_type' => '');
|
302 |
// prr($commentdata);
|
303 |
nxs_postNewComment($commentdata, $options['riCommentsAA']=='1'); $ci++;
|
304 |
}
|
311 |
$fbpo = get_post_meta($postID, 'snapFB', true); /* echo $postID."|"; echo $fbpo; */ $fbpo = maybe_unserialize($fbpo); // prr($fbpo);
|
312 |
if (is_array($fbpo) && isset($fbpo[$ii]) && is_array($fbpo[$ii]) ){ $ntClInst = new nxs_snapClassFB(); $fbo = $ntClInst->adjMetaOpt($fbo, $fbpo[$ii]); } //prr($fbo);
|
313 |
if ($_POST['ri']=='1') { nxs_getBackFBComments($postID, $fbo, $fbpo[$ii]); die(); } else {
|
314 |
+
$result = nxs_doPublishToFB($postID, $fbo); if ($result == '200') die("Your post has been successfully sent to FaceBook."); else die($result);
|
315 |
}
|
316 |
}
|
317 |
}
|
318 |
}
|
319 |
|
320 |
if (!function_exists("nxs_doPublishToFB")) { //## Second Function to Post to FB
|
321 |
+
function nxs_doPublishToFB($postID, $options){ global $ShownAds; $ntCd = 'FB'; $ntCdL = 'fb'; $ntNm = 'Facebook'; $dsc = '';
|
322 |
+
if (!class_exists('nxs_class_SNAP_FB')) { nxs_addToLogN('E', 'Error', $ntCd, '-=ERROR=- No Facebook API Lib Detected', ''); return "No Facebook API Lib Detected";}
|
323 |
+
|
324 |
+
$fbWhere = 'feed'; $page_id = $options['fbPgID']; if (isset($ShownAds)) $ShownAdsL = $ShownAds; $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'POSTID'=>$postID, 'ACCNAME'=>$options['nName']));
|
325 |
+
//## Some Common stuff
|
326 |
+
$ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
|
327 |
+
$logNT = '<span style="color:#0000FF">Facebook</span> - '.$options['nName'];
|
328 |
+
$snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
|
329 |
if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
|
330 |
+
$snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') {
|
331 |
+
nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$options['pType']); return;
|
332 |
+
}
|
333 |
+
}
|
334 |
+
//## Make the post
|
335 |
+
if (isset($options['qTLng'])) $lng = $options['qTLng']; else $lng = ''; if (!isset($options['fbAppPageAuthToken'])) $options['fbAppPageAuthToken'] = '';
|
336 |
+
$blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url();
|
337 |
+
//## Initiate Posting Array
|
338 |
+
$message = array('message'=>'', 'link'=>'', 'title'=>'', 'description'=>'', 'imageURL'=>'', 'videoURL'=>'', 'siteName'=>$blogTitle);
|
339 |
+
|
340 |
+
if ($postID=='0') { $message['message'] = 'Test Post, Please Ignore';
|
341 |
+
$message['description'] = 'Test Post, Description'; $message['title'] = 'Test Post - Title'; $message['link'] = home_url();
|
342 |
+
} else { $post = get_post($postID); if(!$post) return; $msg = nsFormatMessage($options['fbMsgFormat'], $postID, $addParams);
|
343 |
$isAttachFB = $options['fbAttch']; $fbPostType = $options['fbPostType']; $isAttachVidFB = $options['fbAttchAsVid'];
|
344 |
+
nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1')); $extInfo = ' | PostID: '.$postID." - ".nxs_doQTrans($post->post_title, $lng).' |'.$options['pType'];
|
345 |
+
if (($isAttachFB=='1' || $isAttachFB=='2' || $fbPostType=='A')) $imgURL = nxs_getPostImage($postID, 'medium'); // prr($options); echo "PP - ".$postID; prr($src);
|
346 |
+
if ($fbPostType=='I') $imgURL = nxs_getPostImage($postID, 'full'); // prr($options); echo "PP - ".$postID; prr($src);
|
347 |
+
if (($isAttachFB=='1' || $fbPostType=='A' || $fbPostType=='S')){
|
348 |
+
//## AUTO - Get Post Descr from SEO Plugins or make it.
|
349 |
+
if (trim($options['fbMsgAFrmt'])!='') {$dsc = nsFormatMessage($options['fbMsgAFrmt'], $postID, $addParams);} else { if (function_exists('aioseop_mrt_fix_meta') && $dsc=='') $dsc = trim(get_post_meta($postID, '_aioseop_description', true));
|
350 |
+
if (function_exists('wpseo_admin_init') && $dsc=='') $dsc = trim(get_post_meta($postID, '_yoast_wpseo_opengraph-description', true));
|
351 |
+
if (function_exists('wpseo_admin_init') && $dsc=='') $dsc = trim(get_post_meta($postID, '_yoast_wpseo_metadesc', true));
|
352 |
+
if ($dsc=='') $dsc = trim(apply_filters('the_content', nxs_doQTrans($post->post_excerpt, $lng))); if ($dsc=='') $dsc = trim(nxs_doQTrans($post->post_excerpt, $lng));
|
353 |
+
if ($dsc=='') $dsc = trim(apply_filters('the_content', nxs_doQTrans($post->post_content, $lng))); if ($dsc=='') $dsc = trim(nxs_doQTrans($post->post_content, $lng));
|
354 |
+
if ($dsc=='') $dsc = get_bloginfo('description');
|
355 |
+
}
|
356 |
+
$dsc = strip_tags($dsc); $dsc = nxs_decodeEntitiesFull($dsc); $dsc = nsTrnc($dsc, 900, ' ');
|
357 |
}
|
358 |
|
|
|
359 |
$postSubtitle = home_url(); $msg = str_replace('<br>', "\n", $msg); $msg = str_replace('<br/>', "\n", $msg); $msg = str_replace('<br />', "\n", $msg);
|
360 |
+
$msg = strip_tags($msg); $msg = nxs_decodeEntitiesFull($msg);
|
361 |
+
|
362 |
+
if ($isAttachVidFB=='1') {$vids = nsFindVidsInPost($post, false); if (count($vids)>0) {
|
363 |
+
if (strlen($vids[0])==11) { $vidURL = 'http://www.youtube.com/v/'.$vids[0]; $imgURL = nsGetYTThumb($vids[0]); }
|
364 |
+
if (strlen($vids[0])==8) { $vidURL = 'https://secure.vimeo.com/moogaloop.swf?clip_id='.$vids[0].'&autoplay=1';
|
|
|
|
|
|
|
|
|
|
|
365 |
$apiURL = "http://vimeo.com/api/v2/video/".$vids[0].".json?callback=showThumb"; $json = wp_remote_get($apiURL);
|
366 |
+
if (!is_wp_error($json)) { $json = $json['body']; $json = str_replace('showThumb(','',$json); $json = str_replace('])',']',$json); $json = json_decode($json, true); $imgURL = $json[0]['thumbnail_large']; }
|
367 |
}
|
368 |
+
}}
|
369 |
+
$message = array('message'=>$msg, 'link'=>get_permalink($postID), 'title'=>nxs_doQTrans($post->post_title, $lng), 'description'=>$dsc, 'imageURL'=>$imgURL, 'videoURL'=>$vidURL, 'siteName'=>$blogTitle);
|
370 |
+
} // prr($mssg); // prr($options); // prr($facebook); echo "/$page_id/feed";
|
|
|
|
|
|
|
|
|
|
|
|
|
371 |
if (isset($ShownAds)) $ShownAds = $ShownAdsL; // FIX for the quick-adsense plugin
|
372 |
+
|
373 |
+
//## Actual Post
|
374 |
+
$ntToPost = new nxs_class_SNAP_FB(); $ret = $ntToPost->doPostToNT($options, $message);
|
375 |
+
//## Process Results
|
376 |
+
if (!is_array($ret) || $ret['isPosted']!='1') { //## Error
|
377 |
+
if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);
|
378 |
+
} else { // ## All Good - log it.
|
379 |
+
if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo _e('OK - Message Posted, please see your '.$logNT.' Page. ', 'nxs_snap'); }
|
380 |
+
else { nxs_addToRI($postID); nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPosted'=>'1', 'pgID'=>$ret['postID'], 'pDate'=>date('Y-m-d H:i:s'))); nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); }
|
381 |
+
}
|
382 |
+
//## Return Result
|
383 |
+
if ($ret['isPosted']=='1') return 200; else return print_r($ret, true);
|
384 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
385 |
}
|
386 |
|
387 |
?>
|
inc-cl/ff.php
ADDED
@@ -0,0 +1,202 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
//## NextScripts Facebook Connection Class
|
3 |
+
$nxs_snapAvNts[] = array('code'=>'FF', 'lcode'=>'ff', 'name'=>'FriendFeed');
|
4 |
+
|
5 |
+
if (!class_exists("nxs_snapClassFF")) { class nxs_snapClassFF {
|
6 |
+
//#### Show Common Settings
|
7 |
+
function showGenNTSettings($ntOpts){ global $nxs_plurl; $ntInfo = array('code'=>'FF', 'lcode'=>'ff', 'name'=>'FriendFeed', 'defNName'=>'ffUName', 'tstReq' => false); ?>
|
8 |
+
<div class="nxs_box">
|
9 |
+
<div class="nxs_box_header">
|
10 |
+
<div class="nsx_iconedTitle" style="margin-bottom:1px;background-image:url(<?php echo $nxs_plurl;?>img/<?php echo $ntInfo['lcode']; ?>16.png);"><?php echo $ntInfo['name']; ?>
|
11 |
+
<?php $cbo = count($ntOpts); ?> <?php wp_nonce_field( 'ns'.$ntInfo['code'], 'ns'.$ntInfo['code'].'_wpnonce' ); ?>
|
12 |
+
<?php if ($cbo>1){ ?><div class="nsBigText"><?php echo "(".($cbo=='0'?'No':$cbo)." "; _e('accounts', 'nxs_snap'); echo ")"; ?></div><?php } ?>
|
13 |
+
</div>
|
14 |
+
</div>
|
15 |
+
<div class="nxs_box_inside">
|
16 |
+
<?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
|
17 |
+
<p style="margin:0px;margin-left:5px;">
|
18 |
+
<input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> /> <?php if ((int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
|
19 |
+
<strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
|
20 |
+
<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'nxs_snap'); ?> ==></b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>
|
21 |
+
<a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
|
22 |
+
</p><?php $this->showNTSettings($indx, $pbo);
|
23 |
+
}?>
|
24 |
+
</div>
|
25 |
+
</div> <?php
|
26 |
+
}
|
27 |
+
//#### Show NEW Settings Page
|
28 |
+
function showNewNTSettings($mgpo){ $gpo = array('nName'=>'', 'doFF'=>'1', 'ffUName'=>'', 'ffPageID'=>'', 'ffAttch'=>'', 'ffPass'=>''); $this->showNTSettings($mgpo, $gpo, true);}
|
29 |
+
//#### Show Unit Settings
|
30 |
+
function showNTSettings($ii, $gpo, $isNew=false){ global $nxs_plurl; ?>
|
31 |
+
<div id="doFF<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>" style="max-width: 1000px; background-color: #EBF4FB; background-image: url(<?php echo $nxs_plurl; ?>img/ff-bg.png); background-position:90% 10%; background-repeat: no-repeat; margin: 10px; border: 1px solid #808080; padding: 10px; display:none;"> <input type="hidden" name="apDoSFF<?php echo $ii; ?>" value="0" id="apDoSFF<?php echo $ii; ?>" />
|
32 |
+
|
33 |
+
<div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/ff16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-FriendFeed-social-networks-auto-poster-wordpress/"><?php $nType="FriendFeed"; printf( __( 'Detailed %s Installation/Configuration Instructions', 'nxs_snap' ), $nType); ?></a></div>
|
34 |
+
|
35 |
+
<div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easely identify it', 'nxs_snap'); ?></i> </div><input name="ff[<?php echo $ii; ?>][nName]" id="ffnName<?php echo $ii; ?>" style="font-weight: bold; color: #005800; border: 1px solid #ACACAC; width: 40%;" value="<?php _e(apply_filters('format_to_edit',htmlentities($gpo['nName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /><br/>
|
36 |
+
<?php echo nxs_addQTranslSel('ff', $ii, $gpo['qTLng']); ?><?php echo nxs_addPostingDelaySel('ff', $ii, $gpo['nHrs'], $gpo['nMin']); ?>
|
37 |
+
|
38 |
+
<?php if (!$isNew) { ?>
|
39 |
+
<div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
|
40 |
+
<input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="ff[<?php echo $ii; ?>][catSel]" <?php if ((int)$gpo['catSel'] != 1) echo "checked"; ?> /> All
|
41 |
+
<input value="1" id="catSelSFF<?php echo $ii; ?>" type="radio" name="ff[<?php echo $ii; ?>][catSel]" <?php if ((int)$gpo['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_FF<?php echo $ii; ?>" onclick="jQuery('#catSelSFF<?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('FF<?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_FF<?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($gpo['catSelEd']!='') echo "[".(substr_count($gpo['catSelEd'], ",")+1)."]"; ?></a>
|
42 |
+
<input type="hidden" name="ff[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_FF<?php echo $ii; ?>" value="<?php echo $gpo['catSelEd']; ?>" />
|
43 |
+
<br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
|
44 |
+
<br/>
|
45 |
+
<?php } ?>
|
46 |
+
|
47 |
+
<div style="width:100%;"><strong>FriendFeed nickname:</strong> <span style="font-size: 11px; margin: 0px;">Get it from <a target="_blank" href="https://friendfeed.com/account/api">https://friendfeed.com/account/api</a>.</span></div><input name="ff[<?php echo $ii; ?>][apFFUName]" id="apFFUName" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit',htmlentities($gpo['ffUName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
|
48 |
+
<div style="width:100%;"><strong>FriendFeed remote key:</strong> <span style="font-size: 11px; margin: 0px;">Get it from <a target="_blank" href="https://friendfeed.com/account/api">https://friendfeed.com/account/api</a>.</span>
|
49 |
+
|
50 |
+
</div><input name="ff[<?php echo $ii; ?>][apFFPass]" id="apFFPass" type="password" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities(substr($gpo['ffPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($gpo['ffPass'], 5)):$gpo['ffPass'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /> <br/>
|
51 |
+
|
52 |
+
<div style="width:100%;"><br/><strong>Group ID:</strong> [Optional] Please specify Group ID. <i>Use this <b>only</b> if you are posting NOT to your own feed. </i></div>
|
53 |
+
<input name="ff[<?php echo $ii; ?>][grpID]" id="grpID" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($gpo['grpID'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
|
54 |
+
|
55 |
+
<?php if ($isNew) { ?> <input type="hidden" name="ff[<?php echo $ii; ?>][apDoFF]" value="1" id="apDoNewFF<?php echo $ii; ?>" /> <?php } ?>
|
56 |
+
<br/> <br/>
|
57 |
+
|
58 |
+
<div id="altFormat" style="">
|
59 |
+
<div style="width:100%;"><strong id="altFormatText"><?php _e('Post Text Format', 'nxs_snap'); ?></strong> (<a href="#" id="apFFMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apFFMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)</div>
|
60 |
+
<input name="ff[<?php echo $ii; ?>][apFFMsgFrmt]" id="apFFMsgFrmt" style="width: 50%;" value="<?php if ($isNew) echo "%TITLE% - %URL% %EXCERPT%"; else _e(apply_filters('format_to_edit',htmlentities($gpo['ffMsgFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap'); ?>" onfocus="mxs_showFrmtInfo('apFFMsgFrmt<?php echo $ii; ?>');" /><?php nxs_doShowHint("apFFMsgFrmt".$ii); ?>
|
61 |
+
</div>
|
62 |
+
<p style="margin: 0px;"><input value="1" id="apLIAttch" type="checkbox" name="ff[<?php echo $ii; ?>][attchImg]" <?php if ((int)$gpo['attchImg'] == 1) echo "checked"; ?> /> <strong><?php _e('Attach Image to FriendFeed Post', 'nxs_snap'); ?></strong></p>
|
63 |
+
<br/>
|
64 |
+
|
65 |
+
<?php if ($gpo['ffPass']!='') { ?>
|
66 |
+
<?php wp_nonce_field( 'rePostToFF', 'rePostToFF_wpnonce' ); ?>
|
67 |
+
<b><?php _e('Test your settings', 'nxs_snap'); ?>:</b> <a href="#" class="NXSButton" onclick="testPost('FF', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'nxs_snap' ), $nType); ?></a>
|
68 |
+
|
69 |
+
<?php }
|
70 |
+
|
71 |
+
?><div class="submit"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div></div><?php
|
72 |
+
}
|
73 |
+
//#### Set Unit Settings from POST
|
74 |
+
function setNTSettings($post, $options){ global $nxs_snapThisPageUrl; $code = 'FF'; $lcode = 'ff';
|
75 |
+
foreach ($post as $ii => $pval){
|
76 |
+
if (isset($pval['apFFUName']) && $pval['apFFUName']!=''){ if (!isset($options[$ii])) $options[$ii] = array();
|
77 |
+
if (isset($pval['apFFUName'])) $options[$ii]['ffUName'] = trim($pval['apFFUName']);
|
78 |
+
if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']);
|
79 |
+
if (isset($pval['apFFPass'])) $options[$ii]['ffPass'] = 'n5g9a'.nsx_doEncode($pval['apFFPass']); else $options[$ii]['ffPass'] = '';
|
80 |
+
|
81 |
+
if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']);
|
82 |
+
if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
|
83 |
+
|
84 |
+
if (isset($pval['apFFMsgFrmt'])) $options[$ii]['ffMsgFormat'] = trim($pval['apFFMsgFrmt']);
|
85 |
+
if (isset($pval['grpID'])) $options[$ii]['grpID'] = trim($pval['grpID']);
|
86 |
+
if (isset($pval['attchImg'])) $options[$ii]['attchImg'] = $pval['attchImg']; else $options[$ii]['attchImg'] = 0;
|
87 |
+
if (isset($pval['apDoFF'])) $options[$ii]['doFF'] = $pval['apDoFF']; else $options[$ii]['doFF'] = 0;
|
88 |
+
if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
|
89 |
+
if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
|
90 |
+
}
|
91 |
+
} return $options;
|
92 |
+
}
|
93 |
+
//#### Show Post->Edit Meta Box Settings
|
94 |
+
function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
|
95 |
+
foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapFF', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
|
96 |
+
$doFF = $ntOpt['doFF'] && (is_array($pMeta) || $ntOpt['catSel']!='1');
|
97 |
+
$isAvailFF = $ntOpt['ffUName']!='' && $ntOpt['ffPass']!=''; $ffMsgFormat = htmlentities($ntOpt['ffMsgFormat'], ENT_COMPAT, "UTF-8"); $ffMsgTFormat = htmlentities($ntOpt['ffMsgTFormat'], ENT_COMPAT, "UTF-8");
|
98 |
+
$isAttchImg = $ntOpt['attchImg'];
|
99 |
+
?>
|
100 |
+
<tr><th style="text-align:left;" colspan="2"><?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_FF<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
|
101 |
+
<?php if ($isAvailFF) { ?><input class="nxsGrpDoChb" value="1" id="doFF<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="ff[<?php echo $ii; ?>][doFF]" <?php if ((int)$doFF == 1) echo 'checked="checked" title="def"'; ?> />
|
102 |
+
<?php if ($post->post_status == "publish") { ?> <input type="hidden" name="ff[<?php echo $ii; ?>][doFF]" value="<?php echo $doFF;?>"> <?php } ?> <?php } ?>
|
103 |
+
|
104 |
+
<div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/ff16.png);">FriendFeed - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
|
105 |
+
if ($post->post_status == "publish" && $isAvailFF) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToFF_repostButton" id="rePostToFF_button" value="<?php _e('Repost to FriendFeed', 'nxs_snap') ?>" />
|
106 |
+
<?php wp_nonce_field( 'rePostToFF', 'rePostToFF_wpnonce' ); } ?>
|
107 |
+
|
108 |
+
<?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
|
109 |
+
?> <span id="pstdFF<?php echo $ii; ?>" style="float: right; padding-top: 4px; padding-right: 10px;">
|
110 |
+
<a style="font-size: 10px;" href="http://www.FriendFeed.com/e/<?php echo $pMeta[$ii]['pgID']; ?>" target="_blank"><?php $nType="FriendFeed"; printf( __( 'Posted on', 'nxs_snap' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
|
111 |
+
</span><?php } ?>
|
112 |
+
|
113 |
+
</td></tr>
|
114 |
+
|
115 |
+
<tr><th scope="row" style="text-align:right; width:150px; vertical-align:top; padding-top: 5px; padding-right:10px;">
|
116 |
+
<input value="0" type="hidden" name="ff[<?php echo $ii; ?>][attchImg]"/>
|
117 |
+
<input value="1" type="checkbox" name="ff[<?php echo $ii; ?>][attchImg]" <?php if ((int)$isAttchImg == 1) echo "checked"; ?> /> </th><td><strong>Attach Image to FriendFeed Post</strong></td> </tr>
|
118 |
+
|
119 |
+
<?php if (!$isAvailFF) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your FriendFeed Account to AutoPost to FriendFeed</b>
|
120 |
+
<?php } elseif ($post->post_status != "pubZlish") { ?>
|
121 |
+
|
122 |
+
<tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Title Format:', 'nxs_snap') ?></th>
|
123 |
+
<td><input value="<?php echo $ffMsgFormat ?>" type="text" name="ff[<?php echo $ii; ?>][SNAPformatT]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apFFMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apFFMsgFrmt".$ii, '', '58'); ?></td></tr>
|
124 |
+
|
125 |
+
<?php }
|
126 |
+
}
|
127 |
+
}
|
128 |
+
//#### Save Meta Tags to the Post
|
129 |
+
function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
|
130 |
+
if (isset($pMeta['SNAPformat'])) $optMt['ffMsgFormat'] = $pMeta['SNAPformat'];
|
131 |
+
if (isset($pMeta['attchImg'])) $optMt['attchImg'] = $pMeta['attchImg'] == 1?1:0; else { if (isset($pMeta['attchImg'])) $optMt['attchImg'] = 0; }
|
132 |
+
|
133 |
+
if (isset($pMeta['doFF'])) $optMt['doFF'] = $pMeta['doFF'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doFF'] = 0; }
|
134 |
+
if (isset($pMeta['SNAPincludeFF']) && $pMeta['SNAPincludeFF'] == '1' ) $optMt['doFF'] = 1;
|
135 |
+
return $optMt;
|
136 |
+
}
|
137 |
+
}}
|
138 |
+
if (!function_exists("nxs_rePostToFF_ajax")) {
|
139 |
+
function nxs_rePostToFF_ajax() { check_ajax_referer('rePostToFF'); $postID = $_POST['id']; $options = get_option('NS_SNAutoPoster');
|
140 |
+
foreach ($options['ff'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj'; //if ($two['gpPageID'].$two['gpUName']==$_POST['nid']) {
|
141 |
+
$gppo = get_post_meta($postID, 'snapFF', true); $gppo = maybe_unserialize($gppo);// prr($gppo);
|
142 |
+
if (is_array($gppo) && isset($gppo[$ii]) && is_array($gppo[$ii])){ $ntClInst = new nxs_snapClassFF(); $two = $ntClInst->adjMetaOpt($two, $gppo[$ii]);}
|
143 |
+
$result = nxs_doPublishToFF($postID, $two); if ($result == 200) die("Successfully sent your post to FriendFeed."); else die($result);
|
144 |
+
}
|
145 |
+
}
|
146 |
+
}
|
147 |
+
|
148 |
+
if (!function_exists("nxs_getFFHeaders")) { function nxs_getFFHeaders($up){ $hdrsArr = array();
|
149 |
+
$hdrsArr['Cache-Control']='no-cache'; $hdrsArr['Connection']='keep-alive';
|
150 |
+
$hdrsArr['User-Agent']='SNAP for Wordpress; Ver '.NextScripts_SNAP_Version;
|
151 |
+
$hdrsArr['Accept']='text/html, application/xhtml+xml, */*'; $hdrsArr['DNT']='1';
|
152 |
+
$hdrsArr['Content-Type']='application/x-www-form-urlencoded';
|
153 |
+
$hdrsArr['Authorization'] = 'Basic ' . base64_encode("$up");
|
154 |
+
//$hdrsArr['Authorization'] = $up;
|
155 |
+
$hdrsArr['Accept-Encoding']='gzip,deflate'; $hdrsArr['Accept-Language']='en-US,en;q=0.8'; $hdrsArr['Accept-Charset']='ISO-8859-1,utf-8;q=0.7,*;q=0.3'; return $hdrsArr;
|
156 |
+
}}
|
157 |
+
|
158 |
+
if (!function_exists("nxs_doPublishToFF")) { //## Second Function to Post to FF
|
159 |
+
function nxs_doPublishToFF($postID, $options){ $ntCd = 'FF'; $ntCdL = 'ff'; $ntNm = 'FriendFeed';
|
160 |
+
//if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToFF', array($postID, $options));
|
161 |
+
|
162 |
+
$ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
|
163 |
+
$logNT = '<span style="color:#000080">FriendFeed</span> - '.$options['nName'];
|
164 |
+
$snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
|
165 |
+
if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
|
166 |
+
$snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') { sleep(5);
|
167 |
+
nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$uqID); return;
|
168 |
+
}
|
169 |
+
}
|
170 |
+
|
171 |
+
if ($postID=='0') { echo "Testing ... <br/><br/>"; $link = home_url(); $msg = 'Test Link from '.$link; } else { $post = get_post($postID); if(!$post) return; $link = get_permalink($postID);
|
172 |
+
$msgFormat = $options['ffMsgFormat']; $msgTFormat = $options['ffMsgTFormat']; $msgT = nsFormatMessage($msgTFormat, $postID); $msg = nsFormatMessage($msgFormat, $postID);
|
173 |
+
nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
|
174 |
+
}
|
175 |
+
$extInfo = ' | PostID: '.$postID." - ".$post->post_title;
|
176 |
+
$dusername = $options['ffUName']; $pass = (substr($options['ffPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['ffPass'], 5)):$options['ffPass']);
|
177 |
+
$link = urlencode($link); $ext = urlencode(substr($msg, 0, 1000));
|
178 |
+
// API/V2 if we ever switch - $postArr = array('body'=>$msg, 'link'=>'', 'to'=>($options['grpID']!=''?$options['grpID']:'me'), 'image_url'=>($imgURL!=''?$imgURL:'me'), 'short'=>0); prr($postArr);
|
179 |
+
|
180 |
+
if ($options['attchImg']=='1') $imgURL = nxs_getPostImage($postID, 'full'); else $imgURL = '';
|
181 |
+
$postArr = array('title'=>$msg, 'image0_link'=>'', 'room'=>($options['grpID']!=''?$options['grpID']:''), 'image0_url'=>($imgURL!=''?$imgURL:''));
|
182 |
+
$apicall = "http://friendfeed.com/api/share"; $hdrsArr = nxs_getFFHeaders($dusername.':'.$pass);
|
183 |
+
$paramcall = array( 'method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'body'=> $postArr, 'headers' => $hdrsArr);
|
184 |
+
|
185 |
+
$cnt = wp_remote_post( $apicall, $paramcall ); // prr(json_decode($cnt['body'], true));
|
186 |
+
|
187 |
+
if(is_wp_error($cnt)) {
|
188 |
+
$ret = 'Something went wrong - '.""; nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.$ret. "ERR: ".print_r($cnt, true), $extInfo);
|
189 |
+
} else {
|
190 |
+
if (is_array($cnt) && $cnt['response']['code']=='200' && is_array(json_decode($cnt['body'], true)))
|
191 |
+
{ $ret = 'OK'; $retInfo = json_decode($cnt['body'], true);
|
192 |
+
nxs_metaMarkAsPosted($postID, 'FF', $options['ii'], array('isPosted'=>'1', 'pgID'=>$retInfo['entries'][0]['id'], 'pDate'=>date('Y-m-d H:i:s'))); nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); }
|
193 |
+
else { $ret = "Error: ";
|
194 |
+
if ($cnt['response']['code']=='401') $ret .= " Incorrect Username/Password ";
|
195 |
+
$ret .= $cnt['response']['message']; nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.$ret. " | ERR: ".print_r($cnt, true), $extInfo);
|
196 |
+
}
|
197 |
+
}
|
198 |
+
if ($ret!='OK') { if ($postID=='0') echo $ret; } else if ($postID=='0') { echo 'OK - Message Posted, please see your FriendFeed Page. '; nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); }
|
199 |
+
if ($ret == 'OK') return 200; else return $ret;
|
200 |
+
}
|
201 |
+
}
|
202 |
+
?>
|
inc-cl/gp.api.php
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
//## NextScripts Facebook Connection Class
|
3 |
+
$nxs_snapAPINts[] = array('code'=>'GP', 'lcode'=>'gp', 'name'=>'Google+');
|
4 |
+
|
5 |
+
if (!class_exists("nxs_class_SNAP_GP")) { class nxs_class_SNAP_GP {
|
6 |
+
|
7 |
+
var $ntCode = 'GP';
|
8 |
+
var $ntLCode = 'gp';
|
9 |
+
|
10 |
+
function doPost($options, $message){ if (!is_array($options)) return false;
|
11 |
+
foreach ($options as $ntOpts) $out[] = $this->doPostToNT($ntOpts, $message);
|
12 |
+
return $out;
|
13 |
+
}
|
14 |
+
function doPostToNT($options, $message){ $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>'');
|
15 |
+
//## Check API Lib
|
16 |
+
if (!function_exists('doPostToGooglePlus')) if (file_exists('apis/postToGooglePlus.php')) require_once ('apis/postToGooglePlus.php'); elseif (file_exists('/home/_shared/deSrc.php')) require_once ('/home/_shared/deSrc.php');
|
17 |
+
if (!function_exists('doPostToGooglePlus')) { $badOut['Error'] = 'Google+ API Library not found'; return $badOut; }
|
18 |
+
//## Check settings
|
19 |
+
if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
|
20 |
+
if (!isset($options['gpUName']) || trim($options['gpPass'])=='') { $badOut['Error'] = 'Not Configured'; return $badOut; }
|
21 |
+
//## Make Post
|
22 |
+
$gpPostType = $options['postType'];
|
23 |
+
|
24 |
+
$msg = nxs_doFormatMsg($options['gpMsgFormat'], $message); // Make "message default"
|
25 |
+
if ($gpPostType=='I' || $gpPostType=='A') {
|
26 |
+
if (is_array($message['imageURL'])) { $imgURL = trim($message['imageURL'][$options['attchImg']]);
|
27 |
+
if ($imgURL=='') $imgURL = trim($message['imageURL']['large']); if ($imgURL=='') $imgURL = trim($message['imageURL']['medium']);
|
28 |
+
if ($imgURL=='') $imgURL = trim($message['imageURL']['original']); if ($imgURL=='') $imgURL = trim($message['imageURL']['thumb']);
|
29 |
+
} else $imgURL = $message['imageURL'];
|
30 |
+
}
|
31 |
+
|
32 |
+
$email = $options['gpUName']; $pass = substr($options['gpPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['gpPass'], 5)):$options['gpPass'];
|
33 |
+
$loginError = doConnectToGooglePlus2($email, $pass); if ($loginError!==false) { $badOut['Error'] = print_r($loginError, true)." - BAD USER/PASS"; return $badOut; }
|
34 |
+
if ($gpPostType=='I') $lnk = array(); if ($gpPostType=='A') $lnk = doGetGoogleUrlInfo2($message['url']); if (is_array($lnk) && $imgURL!='') $lnk['img'] = $imgURL;
|
35 |
+
if ($gpPostType=='I' && trim($message['videoURL'])!='') { $lnk['video'] = $message['videoURL']; }
|
36 |
+
if (!empty($options['gpPageID'])) { $to = $options['gpPageID']; $ret = doPostToGooglePlus2($msg, $lnk, $to);}
|
37 |
+
elseif (!empty($options['gpCommID'])) $ret = doPostToGooglePlus2($msg, $lnk, '', $options['gpCommID'], $options['gpCCat']); else $ret = doPostToGooglePlus2($msg, $lnk);
|
38 |
+
if ( (!is_array($ret)) && $ret!='OK') { $badOut['Error'] = print_r($ret, true); } else { return array('isPosted'=>'1', 'postID'=>$ret['post_id'], 'postURL'=>'https://plus.google.com/'.$ret['post_id'], 'pDate'=>date('Y-m-d H:i:s')); }
|
39 |
+
return $badOut;
|
40 |
+
}
|
41 |
+
|
42 |
+
}}
|
43 |
+
?>
|
inc-cl/gp.php
CHANGED
@@ -16,7 +16,7 @@ if (!class_exists("nxs_snapClassGP")) { class nxs_snapClassGP {
|
|
16 |
<?php if(!function_exists('doPostToGooglePlus')) {?> Google+ doesn't have a built-in API for automated posts yet. The current <a href="http://developers.google.com/+/api/">Google+ API</a> is "Read Only" and can't be used for posting. <br/>You need to get a special <a target="_blank" href="http://www.nextscripts.com/google-plus-automated-posting">library module</a> to be able to publish your content to Google+.
|
17 |
<?php } else foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
|
18 |
<p style="margin:0px;margin-left:5px;">
|
19 |
-
<input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> />
|
20 |
<strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
|
21 |
<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'nxs_snap'); ?> ==></b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>
|
22 |
<a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
|
@@ -26,9 +26,9 @@ if (!class_exists("nxs_snapClassGP")) { class nxs_snapClassGP {
|
|
26 |
</div> <?php
|
27 |
}
|
28 |
//#### Show NEW Settings Page
|
29 |
-
function showNewNTSettings($mgpo){ $
|
30 |
//#### Show Unit Settings
|
31 |
-
function showNTSettings($ii, $
|
32 |
<div id="doGP<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>" style="background-image: url(<?php echo $nxs_plurl; ?>img/gp-bg.png); background-position:90% 10%;"> <input type="hidden" name="apDoSGP<?php echo $ii; ?>" value="0" id="apDoSGP<?php echo $ii; ?>" />
|
33 |
<?php if(!function_exists('doPostToGooglePlus')) {?><span style="color:#580000; font-size: 16px;"><br/><br/>
|
34 |
<b><?php _e('Google+ API Library not found', 'nxs_snap'); ?></b>
|
@@ -36,47 +36,63 @@ if (!class_exists("nxs_snapClassGP")) { class nxs_snapClassGP {
|
|
36 |
<?php return; }; ?>
|
37 |
<div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/gp16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-google-plus-social-networks-auto-poster-wordpress/"><?php $nType="Google+"; printf( __( 'Detailed %s Installation/Configuration Instructions', 'nxs_snap' ), $nType); ?></a></div>
|
38 |
|
39 |
-
<div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easely identify it', 'nxs_snap'); ?></i> </div><input name="gp[<?php echo $ii; ?>][nName]" id="gpnName<?php echo $ii; ?>" style="font-weight: bold; color: #005800; border: 1px solid #ACACAC; width: 40%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($
|
40 |
-
<?php echo nxs_addQTranslSel('gp', $ii, $
|
41 |
|
42 |
<?php if (!$isNew) { ?>
|
43 |
<div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
|
44 |
-
<input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="gp[<?php echo $ii; ?>][catSel]" <?php if ((int)$
|
45 |
-
<input value="1" id="catSelSGP<?php echo $ii; ?>" type="radio" name="gp[<?php echo $ii; ?>][catSel]" <?php if ((int)$
|
46 |
-
<input type="hidden" name="gp[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_GP<?php echo $ii; ?>" value="<?php echo $
|
47 |
<br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
|
48 |
<br/>
|
49 |
<?php } ?>
|
50 |
|
51 |
-
<div style="width:100%;"><strong>Google+ Username:</strong> </div><input name="gp[<?php echo $ii; ?>][apGPUName]" id="apGPUName" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($
|
52 |
-
<div style="width:100%;"><strong>Google+ Password:</strong> </div><input name="gp[<?php echo $ii; ?>][apGPPass]" id="apGPPass" type="password" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities(substr($
|
53 |
<p><div style="width:100%;"><strong>Google+ Page ID (Optional - for Google+ Pages Only. <b style="color: #580000;"> <?php _e('Leave Empty to publish to your profile or community', 'nxs_snap'); ?></b>):</strong>
|
54 |
<p style="font-size: 11px; margin: 0px;">For example if URL of your page is https://plus.google.com/u/0/b/117008619877691455570/ your Page ID is: 117008619877691455570. <b><?php _e('Leave Empty to publish to your profile or community.', 'nxs_snap'); ?></b></p>
|
55 |
-
</div><input name="gp[<?php echo $ii; ?>][apGPPage]" id="apGPPage" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($
|
56 |
<br/>
|
57 |
<p><div style="width:100%;"><strong>Google+ Community ID (Optional - for Google+ Communities Only. <b style="color: #580000;"> <?php _e('Leave Empty to publish to your profile or page', 'nxs_snap'); ?></b>):</strong>
|
58 |
<p style="font-size: 11px; margin: 0px;">For example if URL of your Community is https://plus.google.com/communities/100396001601096060160 your Page ID is: 100396001601096060160. <b><?php _e('Leave Empty to publish to your profile or page', 'nxs_snap'); ?>.</b></p>
|
59 |
-
</div><input name="gp[<?php echo $ii; ?>][gpCommID]" id="gpCommID" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
<br/><br/>
|
61 |
|
62 |
<div id="altFormat" style="">
|
63 |
<div style="width:100%;"><strong id="altFormatText"><?php _e('Message text Format', 'nxs_snap'); ?>:</strong> (<a href="#" id="apGPMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apGPMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)
|
64 |
-
</div
|
|
|
|
|
|
|
|
|
65 |
</div><br/>
|
66 |
|
67 |
<div style="width:100%;"><strong id="altFormatText">Post Type:</strong><-- (<a id="showShAtt" onmouseout="hidePopShAtt('<?php echo $ii; ?>XG');" onmouseover="showPopShAtt('<?php echo $ii; ?>XG', event);" onclick="return false;" class="underdash" href="http://www.nextscripts.com/blog/"><?php _e('What\'s the difference?', 'nxs_snap'); ?></a>) </div>
|
68 |
<div style="margin-left: 10px;">
|
69 |
-
<?php if(!isset($
|
70 |
-
if ((int)$
|
71 |
-
if ((int)$
|
72 |
} ?>
|
73 |
-
<input type="radio" name="gp[<?php echo $ii; ?>][postType]" value="T" <?php if ($
|
74 |
-
<input type="radio" name="gp[<?php echo $ii; ?>][postType]" value="I" <?php if ($
|
75 |
-
<input type="radio" name="gp[<?php echo $ii; ?>][postType]" value="A" <?php if ( !isset($
|
76 |
<div class="popShAtt" id="popShAtt<?php echo $ii; ?>XG"><h3><?php _e('Google+ Post Types', 'nxs_snap'); ?></h3><img src="<?php echo $nxs_plurl; ?>img/gpPostTypesDiff6.png" width="600" height="285" alt="<?php _e('Google+ Post Types', 'nxs_snap'); ?>"/></div>
|
77 |
</div><br/>
|
78 |
<?php if ($isNew) { ?> <input type="hidden" name="gp[<?php echo $ii; ?>][apDoGP]" value="1" id="apDoNewGP<?php echo $ii; ?>" /> <?php } ?>
|
79 |
-
<?php if ($
|
80 |
<?php wp_nonce_field( 'rePostToGP', 'rePostToGP_wpnonce' ); ?>
|
81 |
<b><?php _e('Test your settings', 'nxs_snap'); ?>:</b> <a href="#" class="NXSButton" onclick="testPost('GP', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'nxs_snap' ), $nType); ?></a> <?php }
|
82 |
?><div class="submit"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div></div><?php
|
@@ -92,7 +108,8 @@ if (!class_exists("nxs_snapClassGP")) { class nxs_snapClassGP {
|
|
92 |
if (isset($pval['gpCommID'])) $options[$ii]['gpCommID'] = trim($pval['gpCommID']);
|
93 |
|
94 |
if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']);
|
95 |
-
if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
|
|
|
96 |
|
97 |
if (isset($pval['postType'])) $options[$ii]['postType'] = $pval['postType'];
|
98 |
if (isset($pval['apGPMsgFrmt'])) $options[$ii]['gpMsgFormat'] = trim($pval['apGPMsgFrmt']);
|
@@ -113,7 +130,8 @@ if (!class_exists("nxs_snapClassGP")) { class nxs_snapClassGP {
|
|
113 |
} $gpPostType = $ntOpt['postType'];
|
114 |
?>
|
115 |
<tr><th style="text-align:left;" colspan="2"><?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_GP<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
|
116 |
-
<?php if ($isAvailGP) { ?><input class="nxsGrpDoChb" value="1" id="doGP<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="gp[<?php echo $ii; ?>][doGP]" <?php if ((
|
|
|
117 |
|
118 |
<div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/gp16.png);">Google+ - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
|
119 |
if ($post->post_status == "publish" && $isAvailGP) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToGP_repostButton" id="rePostToGP_button" value="<?php _e('Repost to Google+', 'nxs_snap') ?>" />
|
@@ -130,16 +148,26 @@ if (!class_exists("nxs_snapClassGP")) { class nxs_snapClassGP {
|
|
130 |
<?php if (!$isAvailGP) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your Google+ Account to AutoPost to Google+</b>
|
131 |
<?php } elseif ($post->post_status != "puZblish") { ?>
|
132 |
|
133 |
-
<tr><th scope="row" style="text-align:right; width:150px; vertical-align:top; padding-top: 0px; padding-right:10px;"> <?php _e('
|
134 |
(<a id="showShAtt" style="font-weight: normal" onmouseout="hidePopShAtt('<?php echo $ii; ?>XG');" onmouseover="showPopShAtt('<?php echo $ii; ?>XG', event);" onclick="return false;" class="underdash" href="http://www.nextscripts.com/blog/"><?php _e('What\'s the difference?', 'nxs_snap'); ?></a>)
|
135 |
</th><td>
|
136 |
|
137 |
-
<input type="radio" name="gp[<?php echo $ii; ?>][postType]" value="T" <?php if ($gpPostType == 'T') echo 'checked="checked"'; ?> /> <?php _e('
|
138 |
<input type="radio" name="gp[<?php echo $ii; ?>][postType]" value="I" <?php if ($gpPostType == 'I') echo 'checked="checked"'; ?> /> <?php _e('Post to Google+ as "Image post"', 'nxs_snap') ?> - <i><?php _e('big image with text message', 'nxs_snap') ?></i><br/>
|
139 |
<input type="radio" name="gp[<?php echo $ii; ?>][postType]" value="A" <?php if ( !isset($gpPostType) || $gpPostType == '' || $gpPostType == 'A') echo 'checked="checked"'; ?> /><?php _e('Text Post with "attached" blogpost', 'nxs_snap') ?>
|
140 |
<div class="popShAtt" id="popShAtt<?php echo $ii; ?>XG"><h3><?php _e('Google+ Post Types', 'nxs_snap') ?></h3><img src="<?php echo $nxs_plurl; ?>img/gpPostTypesDiff6.png" width="600" height="285" alt="<?php _e('Google+ Post Types', 'nxs_snap') ?>"/></div>
|
141 |
</td></tr>
|
142 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
143 |
<td>
|
144 |
|
145 |
<?php if (1==1) { ?>
|
@@ -157,6 +185,7 @@ if (!class_exists("nxs_snapClassGP")) { class nxs_snapClassGP {
|
|
157 |
function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
|
158 |
if (isset($pMeta['SNAPformat'])) $optMt['gpMsgFormat'] = $pMeta['SNAPformat'];
|
159 |
if (isset($pMeta['postType'])) $optMt['postType'] = $pMeta['postType'];
|
|
|
160 |
if (isset($pMeta['doGP'])) $optMt['doGP'] = $pMeta['doGP'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doGP'] = 0; }
|
161 |
if (isset($pMeta['SNAPincludeGP']) && $pMeta['SNAPincludeGP'] == '1' ) $optMt['doGP'] = 1;
|
162 |
return $optMt;
|
@@ -172,32 +201,39 @@ if (!function_exists("nxs_rePostToGP_ajax")) {
|
|
172 |
}
|
173 |
}
|
174 |
if (!function_exists("nxs_doPublishToGP")) { //## Second Function to Post to G+
|
175 |
-
function nxs_doPublishToGP($postID, $options){ $ntCd = 'GP'; $ntCdL = 'gp'; $ntNm = 'Google+';
|
176 |
-
if(!function_exists('doConnectToGooglePlus2') || !function_exists('doPostToGooglePlus2')) {
|
177 |
-
$ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
|
|
|
|
|
178 |
if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
|
|
184 |
|
185 |
-
if($
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
|
187 |
-
if ($gpPostType=='A') $imgURL = nxs_getPostImage($postID, 'thumbnail'); if ($gpPostType=='I') $imgURL = nxs_getPostImage($postID, 'full');
|
188 |
-
$email = $options['gpUName']; $pass = substr($options['gpPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['gpPass'], 5)):$options['gpPass'];
|
189 |
-
$extInfo = ' | PostID: '.$postID; $logNT = '<span style="color:#800000">Google+</span> - '.$options['nName'];
|
190 |
-
$loginError = doConnectToGooglePlus2($email, $pass); if ($loginError!==false) {if ($postID=='0') echo $loginError; nxs_addToLog($logNT, 'E', '-=ERROR=- '.print_r($loginError, true)." - BAD USER/PASS", $extInfo); return "BAD USER/PASS";}
|
191 |
-
$url = get_permalink($postID); if(trim($url)=='') $url = home_url();
|
192 |
-
if ($gpPostType=='I') $lnk = array(); if ($gpPostType=='A') $lnk = doGetGoogleUrlInfo2($url); if (is_array($lnk) && $imgURL!='') $lnk['img'] = $imgURL; //prr($lnk);
|
193 |
-
if ($gpPostType=='I' && trim($ytUrl)!='') { $lnk['video'] = $ytUrl; }
|
194 |
-
if (!empty($options['gpPageID'])) { $to = $options['gpPageID']; $ret = doPostToGooglePlus2($msg, $lnk, $to);}
|
195 |
-
elseif (!empty($options['gpCommID'])) $ret = doPostToGooglePlus2($msg, $lnk, '', $options['gpCommID']); else $ret = doPostToGooglePlus2($msg, $lnk); //prr($ret);
|
196 |
-
if ($ret=='OK') $ret = array("code"=>"OK", "post_id"=>'');
|
197 |
-
if ( (!is_array($ret)) && $ret!='OK') { if ($postID=='0') prr($ret); nxs_addToLog($logNT, 'E', '-=ERROR=- '.print_r($ret, true), $extInfo);}
|
198 |
-
else if ($postID=='0') { nxs_addToLog($logNT, 'M', 'OK - TEST Message Posted '); echo _e('OK - Message Posted, please see your Google+ Page', 'nxs_snap'); } else
|
199 |
-
{ nxs_metaMarkAsPosted($postID, 'GP', $options['ii'], array('isPosted'=>'1', 'pgID'=>$ret['post_id'], 'pDate'=>date('Y-m-d H:i:s'))); nxs_addToLog($logNT, 'M', 'OK - Message Posted ', $extInfo); }
|
200 |
-
if ($ret['code']=='OK') return 200; else return $ret;
|
201 |
}
|
202 |
}
|
203 |
?>
|
16 |
<?php if(!function_exists('doPostToGooglePlus')) {?> Google+ doesn't have a built-in API for automated posts yet. The current <a href="http://developers.google.com/+/api/">Google+ API</a> is "Read Only" and can't be used for posting. <br/>You need to get a special <a target="_blank" href="http://www.nextscripts.com/google-plus-automated-posting">library module</a> to be able to publish your content to Google+.
|
17 |
<?php } else foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
|
18 |
<p style="margin:0px;margin-left:5px;">
|
19 |
+
<input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> /> <?php if ((int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
|
20 |
<strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
|
21 |
<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'nxs_snap'); ?> ==></b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>
|
22 |
<a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
|
26 |
</div> <?php
|
27 |
}
|
28 |
//#### Show NEW Settings Page
|
29 |
+
function showNewNTSettings($mgpo){ $options = array('nName'=>'', 'doGP'=>'1', 'gpUName'=>'', 'gpPageID'=>'', 'gpCommID'=>'', 'postType'=>'A', 'gpPass'=>''); $this->showNTSettings($mgpo, $options, true);}
|
30 |
//#### Show Unit Settings
|
31 |
+
function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl; ?>
|
32 |
<div id="doGP<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>" style="background-image: url(<?php echo $nxs_plurl; ?>img/gp-bg.png); background-position:90% 10%;"> <input type="hidden" name="apDoSGP<?php echo $ii; ?>" value="0" id="apDoSGP<?php echo $ii; ?>" />
|
33 |
<?php if(!function_exists('doPostToGooglePlus')) {?><span style="color:#580000; font-size: 16px;"><br/><br/>
|
34 |
<b><?php _e('Google+ API Library not found', 'nxs_snap'); ?></b>
|
36 |
<?php return; }; ?>
|
37 |
<div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/gp16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-google-plus-social-networks-auto-poster-wordpress/"><?php $nType="Google+"; printf( __( 'Detailed %s Installation/Configuration Instructions', 'nxs_snap' ), $nType); ?></a></div>
|
38 |
|
39 |
+
<div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easely identify it', 'nxs_snap'); ?></i> </div><input name="gp[<?php echo $ii; ?>][nName]" id="gpnName<?php echo $ii; ?>" style="font-weight: bold; color: #005800; border: 1px solid #ACACAC; width: 40%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['nName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /><br/>
|
40 |
+
<?php echo nxs_addQTranslSel('gp', $ii, $options['qTLng']); ?><?php echo nxs_addPostingDelaySel('gp', $ii, $options['nHrs'], $options['nMin']); ?>
|
41 |
|
42 |
<?php if (!$isNew) { ?>
|
43 |
<div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
|
44 |
+
<input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="gp[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
|
45 |
+
<input value="1" id="catSelSGP<?php echo $ii; ?>" type="radio" name="gp[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_GP<?php echo $ii; ?>" onclick="jQuery('#catSelSGP<?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('GP<?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_GP<?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($options['catSelEd']!='') echo "[".(substr_count($options['catSelEd'], ",")+1)."]"; ?></a>
|
46 |
+
<input type="hidden" name="gp[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_GP<?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
|
47 |
<br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
|
48 |
<br/>
|
49 |
<?php } ?>
|
50 |
|
51 |
+
<div style="width:100%;"><strong>Google+ Username:</strong> </div><input name="gp[<?php echo $ii; ?>][apGPUName]" id="apGPUName<?php echo $ii; ?>" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['gpUName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
|
52 |
+
<div style="width:100%;"><strong>Google+ Password:</strong> </div><input name="gp[<?php echo $ii; ?>][apGPPass]" id="apGPPass<?php echo $ii; ?>" type="password" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities(substr($options['gpPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['gpPass'], 5)):$options['gpPass'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /> <br/>
|
53 |
<p><div style="width:100%;"><strong>Google+ Page ID (Optional - for Google+ Pages Only. <b style="color: #580000;"> <?php _e('Leave Empty to publish to your profile or community', 'nxs_snap'); ?></b>):</strong>
|
54 |
<p style="font-size: 11px; margin: 0px;">For example if URL of your page is https://plus.google.com/u/0/b/117008619877691455570/ your Page ID is: 117008619877691455570. <b><?php _e('Leave Empty to publish to your profile or community.', 'nxs_snap'); ?></b></p>
|
55 |
+
</div><input name="gp[<?php echo $ii; ?>][apGPPage]" id="apGPPage" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['gpPageID'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
|
56 |
<br/>
|
57 |
<p><div style="width:100%;"><strong>Google+ Community ID (Optional - for Google+ Communities Only. <b style="color: #580000;"> <?php _e('Leave Empty to publish to your profile or page', 'nxs_snap'); ?></b>):</strong>
|
58 |
<p style="font-size: 11px; margin: 0px;">For example if URL of your Community is https://plus.google.com/communities/100396001601096060160 your Page ID is: 100396001601096060160. <b><?php _e('Leave Empty to publish to your profile or page', 'nxs_snap'); ?>.</b></p>
|
59 |
+
</div><input name="gp[<?php echo $ii; ?>][gpCommID]" id="gpCommID<?php echo $ii; ?>" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['gpCommID'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
|
60 |
+
<a href="#" onclick="getGPCats(jQuery('<?php if ($isNew) echo "#nsx_addNT "; ?>#apGPUName<?php echo $ii; ?>').val(), jQuery('<?php if ($isNew) echo "#nsx_addNT "; ?>#apGPPass<?php echo $ii; ?>').val(), '<?php echo $ii; ?>', jQuery('<?php if ($isNew) echo "#nsx_addNT "; ?>#gpCommID<?php echo $ii; ?>').val()); return false;">
|
61 |
+
<?php _e('Retreive Categories', 'nxs_snap'); ?>
|
62 |
+
</a>
|
63 |
+
<div style="padding-left: 15px; width:100%;"><strong>Community Category:</strong>
|
64 |
+
<?php wp_nonce_field( 'getGPCats', 'getGPCats_wpnonce' ); ?><img id="gpLoadingImg<?php echo $ii; ?>" style="display: none;" src='<?php echo $nxs_plurl; ?>img/ajax-loader-sm.gif' />
|
65 |
+
<select name="gp[<?php echo $ii; ?>][apGPCCats]" id="apGPCCats<?php echo $ii; ?>">
|
66 |
+
<?php if ($options['gpCCatsList']!=''){ $gGPCats = $options['gpCCatsList']; if ( base64_encode(base64_decode($gGPCats)) === $gGPCats) $gGPCats = base64_decode($gGPCats);
|
67 |
+
if ($options['gpCCat']!='') $gGPCats = str_replace($options['gpCCat'].'"', $options['gpCCat'].'" selected="selected"', $gGPCats); echo $gGPCats;} else { ?>
|
68 |
+
<option value="0">None(Click above to retrieve your categories)</option>
|
69 |
+
<?php } ?>
|
70 |
+
</select> </div>
|
71 |
+
|
72 |
<br/><br/>
|
73 |
|
74 |
<div id="altFormat" style="">
|
75 |
<div style="width:100%;"><strong id="altFormatText"><?php _e('Message text Format', 'nxs_snap'); ?>:</strong> (<a href="#" id="apGPMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apGPMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)
|
76 |
+
</div>
|
77 |
+
|
78 |
+
<textarea cols="150" rows="3" id="gp<?php echo $ii; ?>SNAPformat" name="gp[<?php echo $ii; ?>][apGPMsgFrmt]" style="width:51%;max-width: 650px;" onfocus="jQuery('#gp<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('apGPMsgFrmt<?php echo $ii; ?>');"><?php if ($isNew) _e("New post (%TITLE%) has been published on %SITENAME%", 'nxs_snap'); else _e(apply_filters('format_to_edit', htmlentities($options['gpMsgFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap'); ?></textarea>
|
79 |
+
|
80 |
+
<?php nxs_doShowHint("apGPMsgFrmt".$ii); ?>
|
81 |
</div><br/>
|
82 |
|
83 |
<div style="width:100%;"><strong id="altFormatText">Post Type:</strong><-- (<a id="showShAtt" onmouseout="hidePopShAtt('<?php echo $ii; ?>XG');" onmouseover="showPopShAtt('<?php echo $ii; ?>XG', event);" onclick="return false;" class="underdash" href="http://www.nextscripts.com/blog/"><?php _e('What\'s the difference?', 'nxs_snap'); ?></a>) </div>
|
84 |
<div style="margin-left: 10px;">
|
85 |
+
<?php if(!isset($options['postType']) || $options['postType']=='') {
|
86 |
+
if ((int)$options['imgPost'] == 1) $options['postType'] = 'I';
|
87 |
+
if ((int)$options['gpAttch'] == 1 || $isNew) $options['postType'] = 'A';
|
88 |
} ?>
|
89 |
+
<input type="radio" name="gp[<?php echo $ii; ?>][postType]" value="T" <?php if ($options['postType'] == 'T') echo 'checked="checked"'; ?> /> <?php _e('Text Post', 'nxs_snap'); ?> - <i><?php _e('just text message', 'nxs_snap'); ?></i><br/>
|
90 |
+
<input type="radio" name="gp[<?php echo $ii; ?>][postType]" value="I" <?php if ($options['postType'] == 'I') echo 'checked="checked"'; ?> /> <?php _e('Google+ Image Post', 'nxs_snap'); ?> - <i><?php _e('big image with text message', 'nxs_snap'); ?></i><br/>
|
91 |
+
<input type="radio" name="gp[<?php echo $ii; ?>][postType]" value="A" <?php if ( !isset($options['postType']) || $options['postType'] == '' || $options['postType'] == 'A') echo 'checked="checked"'; ?> /> <?php _e('Add blogpost to Google+ message as an attachment', 'nxs_snap'); ?><br/>
|
92 |
<div class="popShAtt" id="popShAtt<?php echo $ii; ?>XG"><h3><?php _e('Google+ Post Types', 'nxs_snap'); ?></h3><img src="<?php echo $nxs_plurl; ?>img/gpPostTypesDiff6.png" width="600" height="285" alt="<?php _e('Google+ Post Types', 'nxs_snap'); ?>"/></div>
|
93 |
</div><br/>
|
94 |
<?php if ($isNew) { ?> <input type="hidden" name="gp[<?php echo $ii; ?>][apDoGP]" value="1" id="apDoNewGP<?php echo $ii; ?>" /> <?php } ?>
|
95 |
+
<?php if ($options['gpPass']!='') { ?>
|
96 |
<?php wp_nonce_field( 'rePostToGP', 'rePostToGP_wpnonce' ); ?>
|
97 |
<b><?php _e('Test your settings', 'nxs_snap'); ?>:</b> <a href="#" class="NXSButton" onclick="testPost('GP', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'nxs_snap' ), $nType); ?></a> <?php }
|
98 |
?><div class="submit"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div></div><?php
|
108 |
if (isset($pval['gpCommID'])) $options[$ii]['gpCommID'] = trim($pval['gpCommID']);
|
109 |
|
110 |
if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']);
|
111 |
+
if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
|
112 |
+
if (isset($pval['apGPCCats'])) $options[$ii]['gpCCat'] = trim($pval['apGPCCats']);
|
113 |
|
114 |
if (isset($pval['postType'])) $options[$ii]['postType'] = $pval['postType'];
|
115 |
if (isset($pval['apGPMsgFrmt'])) $options[$ii]['gpMsgFormat'] = trim($pval['apGPMsgFrmt']);
|
130 |
} $gpPostType = $ntOpt['postType'];
|
131 |
?>
|
132 |
<tr><th style="text-align:left;" colspan="2"><?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_GP<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
|
133 |
+
<?php if ($isAvailGP) { ?><input class="nxsGrpDoChb" value="1" id="doGP<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="gp[<?php echo $ii; ?>][doGP]" <?php if ((int)$doGP == 1) echo 'checked="checked" title="def"'; ?> />
|
134 |
+
<?php if ($post->post_status == "publish") { ?> <input type="hidden" name="gp[<?php echo $ii; ?>][doGP]" value="<?php echo $doGP;?>"> <?php } ?> <?php } ?>
|
135 |
|
136 |
<div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/gp16.png);">Google+ - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
|
137 |
if ($post->post_status == "publish" && $isAvailGP) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToGP_repostButton" id="rePostToGP_button" value="<?php _e('Repost to Google+', 'nxs_snap') ?>" />
|
148 |
<?php if (!$isAvailGP) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your Google+ Account to AutoPost to Google+</b>
|
149 |
<?php } elseif ($post->post_status != "puZblish") { ?>
|
150 |
|
151 |
+
<tr><th scope="row" style="text-align:right; width:150px; vertical-align:top; padding-top: 0px; padding-right:10px;"> <?php _e('Post Type:', 'nxs_snap') ?> <br/>
|
152 |
(<a id="showShAtt" style="font-weight: normal" onmouseout="hidePopShAtt('<?php echo $ii; ?>XG');" onmouseover="showPopShAtt('<?php echo $ii; ?>XG', event);" onclick="return false;" class="underdash" href="http://www.nextscripts.com/blog/"><?php _e('What\'s the difference?', 'nxs_snap'); ?></a>)
|
153 |
</th><td>
|
154 |
|
155 |
+
<input type="radio" name="gp[<?php echo $ii; ?>][postType]" value="T" <?php if ($gpPostType == 'T') echo 'checked="checked"'; ?> /> <?php _e('Text Post', 'nxs_snap') ?> - <i><?php _e('just text message', 'nxs_snap') ?></i><br/>
|
156 |
<input type="radio" name="gp[<?php echo $ii; ?>][postType]" value="I" <?php if ($gpPostType == 'I') echo 'checked="checked"'; ?> /> <?php _e('Post to Google+ as "Image post"', 'nxs_snap') ?> - <i><?php _e('big image with text message', 'nxs_snap') ?></i><br/>
|
157 |
<input type="radio" name="gp[<?php echo $ii; ?>][postType]" value="A" <?php if ( !isset($gpPostType) || $gpPostType == '' || $gpPostType == 'A') echo 'checked="checked"'; ?> /><?php _e('Text Post with "attached" blogpost', 'nxs_snap') ?>
|
158 |
<div class="popShAtt" id="popShAtt<?php echo $ii; ?>XG"><h3><?php _e('Google+ Post Types', 'nxs_snap') ?></h3><img src="<?php echo $nxs_plurl; ?>img/gpPostTypesDiff6.png" width="600" height="285" alt="<?php _e('Google+ Post Types', 'nxs_snap') ?>"/></div>
|
159 |
</td></tr>
|
160 |
+
<?php if ($ntOpt['gpCommID']!='') { ?>
|
161 |
+
<tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;">Community Category</th>
|
162 |
+
<td><select name="gp[<?php echo $ii; ?>][apGPCCat]" id="apGPCCat">
|
163 |
+
<?php if ($ntOpt['gpCCatsList']!=''){ $gCats = $ntOpt['gpCCatsList']; if ( base64_encode(base64_decode($gCats)) === $gCats) $gCats = base64_decode($gCats);
|
164 |
+
if ($ntOpt['gpCCat']!='') $gCats = str_replace($ntOpt['gpCCat'].'"', $ntOpt['gpCCat'].'" selected="selected"', $gCats); echo $gCats;} else { ?>
|
165 |
+
<option value="0">None(Please go to settings and retreive)</option>
|
166 |
+
<?php } ?>
|
167 |
+
</select></td>
|
168 |
+
</tr>
|
169 |
+
<?php } ?>
|
170 |
+
<tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Message Format:', 'nxs_snap') ?></th>
|
171 |
<td>
|
172 |
|
173 |
<?php if (1==1) { ?>
|
185 |
function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
|
186 |
if (isset($pMeta['SNAPformat'])) $optMt['gpMsgFormat'] = $pMeta['SNAPformat'];
|
187 |
if (isset($pMeta['postType'])) $optMt['postType'] = $pMeta['postType'];
|
188 |
+
if (isset($pMeta['apGPCCat']) && $pMeta['apGPCCat']!='' && $pMeta['apGPCCat']!='0') $optMt['gpCCat'] = $pMeta['apGPCCat'];
|
189 |
if (isset($pMeta['doGP'])) $optMt['doGP'] = $pMeta['doGP'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doGP'] = 0; }
|
190 |
if (isset($pMeta['SNAPincludeGP']) && $pMeta['SNAPincludeGP'] == '1' ) $optMt['doGP'] = 1;
|
191 |
return $optMt;
|
201 |
}
|
202 |
}
|
203 |
if (!function_exists("nxs_doPublishToGP")) { //## Second Function to Post to G+
|
204 |
+
function nxs_doPublishToGP($postID, $options){ $ntCd = 'GP'; $ntCdL = 'gp'; $ntNm = 'Google+';
|
205 |
+
if(!function_exists('doConnectToGooglePlus2') || !function_exists('doPostToGooglePlus2')) { nxs_addToLogN('E', 'Error', $ntCd, '-=ERROR=- No G+ API Lib Detected', ''); return "No G+ API Lib Detected";}
|
206 |
+
$ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
|
207 |
+
$logNT = '<span style="color:#800000">Google+</span> - '.$options['nName'];
|
208 |
+
$snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
|
209 |
if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
|
210 |
+
$snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') {
|
211 |
+
nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$uqID); return;
|
212 |
+
}
|
213 |
+
}
|
214 |
+
|
215 |
+
$message = array('message'=>'', 'link'=>'', 'imageURL'=>'', 'videoURL'=>'');
|
216 |
|
217 |
+
if ($postID=='0') { echo "Testing ... <br/><br/>"; $options['gpMsgFormat'] = "Test Post from ". htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES)." - ".home_url(); $message['url'] = home_url();
|
218 |
+
} else { nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1')); $post = get_post($postID); if(!$post) return;
|
219 |
+
$gpMsgFormat = $options['gpMsgFormat']; $gpPostType = $options['postType']; $msg = nsFormatMessage($gpMsgFormat, $postID); $options['gpMsgFormat'] = $msg;
|
220 |
+
$extInfo = ' | PostID: '.$postID." - ".$post->post_title;
|
221 |
+
if($gpPostType=='I') { $vids = nsFindVidsInPost($post, false); if (count($vids)>0) $ytCode = $vids[0]; if (trim($ytCode)=='') $options['trPostType']='T'; }
|
222 |
+
if ($gpPostType=='A') $imgURL = nxs_getPostImage($postID, 'medium'); if ($gpPostType=='I') $imgURL = nxs_getPostImage($postID, 'full');
|
223 |
+
$message = array('message'=>$msg, 'url'=>get_permalink($postID), 'imageURL'=>$imgURL, 'videoCode'=>$ytCode);
|
224 |
+
}
|
225 |
+
//## Actual Post
|
226 |
+
$ntToPost = new nxs_class_SNAP_GP(); $ret = $ntToPost->doPostToNT($options, $message);
|
227 |
+
//## Process Results
|
228 |
+
if (!is_array($ret) || $ret['isPosted']!='1') { //## Error
|
229 |
+
if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);
|
230 |
+
} else { // ## All Good - log it.
|
231 |
+
if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo _e('OK - Message Posted, please see your '.$logNT.' Page. ', 'nxs_snap'); }
|
232 |
+
else { nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPosted'=>'1', 'pgID'=>$ret['postID'], 'pDate'=>date('Y-m-d H:i:s'))); nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); }
|
233 |
+
}
|
234 |
+
//## Return Result
|
235 |
+
if ($ret['isPosted']=='1') return 200; else return print_r($ret, true);
|
236 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
237 |
}
|
238 |
}
|
239 |
?>
|
inc-cl/ip.php
CHANGED
@@ -15,7 +15,7 @@ if (!class_exists("nxs_snapClassIP")) { class nxs_snapClassIP {
|
|
15 |
<div class="nxs_box_inside">
|
16 |
<?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
|
17 |
<p style="margin:0px;margin-left:5px;">
|
18 |
-
<input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> />
|
19 |
<strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
|
20 |
<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'nxs_snap'); ?> ==></b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>
|
21 |
<a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
|
@@ -58,7 +58,10 @@ if (!class_exists("nxs_snapClassIP")) { class nxs_snapClassIP {
|
|
58 |
|
59 |
<div id="altFormat" style="">
|
60 |
<div style="width:100%;"><strong id="altFormatText"><?php _e('Post Text Format', 'nxs_snap'); ?></strong> (<a href="#" id="apIPMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apIPMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)</div>
|
61 |
-
|
|
|
|
|
|
|
62 |
</div><br/>
|
63 |
|
64 |
<?php if ($gpo['ipPass']!='') { ?>
|
@@ -95,7 +98,8 @@ if (!class_exists("nxs_snapClassIP")) { class nxs_snapClassIP {
|
|
95 |
$isAvailIP = $ntOpt['ipUName']!='' && $ntOpt['ipPass']!=''; $ipMsgFormat = htmlentities($ntOpt['ipMsgFormat'], ENT_COMPAT, "UTF-8"); $ipMsgTFormat = htmlentities($ntOpt['ipMsgTFormat'], ENT_COMPAT, "UTF-8");
|
96 |
?>
|
97 |
<tr><th style="text-align:left;" colspan="2"><?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_IP<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
|
98 |
-
<?php if ($isAvailIP) { ?><input class="nxsGrpDoChb" value="1" id="doIP<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="ip[<?php echo $ii; ?>][doIP]" <?php if ((
|
|
|
99 |
|
100 |
<div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/ip16.png);">Instapaper - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
|
101 |
if ($post->post_status == "publish" && $isAvailIP) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToIP_repostButton" id="rePostToIP_button" value="<?php _e('Repost to Instapaper', 'nxs_snap') ?>" />
|
@@ -111,11 +115,13 @@ if (!class_exists("nxs_snapClassIP")) { class nxs_snapClassIP {
|
|
111 |
<?php if (!$isAvailIP) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your Instapaper Account to AutoPost to Instapaper</b>
|
112 |
<?php } elseif ($post->post_status != "pubZlish") { ?>
|
113 |
|
114 |
-
<tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;"><?php _e('Title Format:', 'nxs_snap') ?></th>
|
115 |
<td><input value="<?php echo $ipMsgTFormat ?>" type="text" name="ip[<?php echo $ii; ?>][SNAPformatT]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apIPTMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apIPTMsgFrmt".$ii); ?></td></tr>
|
116 |
|
117 |
-
<tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;"><?php _e('Text Format:', 'nxs_snap') ?></th>
|
118 |
-
<td
|
|
|
|
|
119 |
<?php }
|
120 |
}
|
121 |
}
|
@@ -147,20 +153,25 @@ if (!function_exists("nxs_getIPHeaders")) { function nxs_getIPHeaders($up){ $hd
|
|
147 |
}}
|
148 |
|
149 |
if (!function_exists("nxs_doPublishToIP")) { //## Second Function to Post to IP
|
150 |
-
function nxs_doPublishToIP($postID, $options){ $ntCd = 'IP'; $ntCdL = 'ip'; $ntNm = 'Instapaper';
|
|
|
151 |
|
152 |
-
$ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
|
|
|
|
|
153 |
if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
|
154 |
-
|
155 |
-
|
|
|
|
|
156 |
|
157 |
if ($postID=='0') { echo "Testing ... <br/><br/>"; $link = home_url(); $msgT = 'Test Link from '.$link; } else { $post = get_post($postID); if(!$post) return; $link = get_permalink($postID);
|
158 |
$msgFormat = $options['ipMsgFormat']; $msgTFormat = $options['ipMsgTFormat']; $msgT = nsFormatMessage($msgTFormat, $postID); $msg = nsFormatMessage($msgFormat, $postID);
|
159 |
nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
|
160 |
}
|
|
|
161 |
$dusername = $options['ipUName']; $pass = (substr($options['ipPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['ipPass'], 5)):$options['ipPass']);
|
162 |
-
$link = urlencode($link); $desc = urlencode(substr($msgT, 0, 250)); $ext = urlencode(substr($msg, 0, 1000));
|
163 |
-
$extInfo = ' | PostID: '.$postID." - ".$post->post_title; $logNT = '<span style="color:#000080">Instapaper</span> - '.$options['nName'];
|
164 |
$t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = urlencode(implode(',',$tggs)); $tags = str_replace(' ','+',$tags);
|
165 |
$apicall = "https://www.instapaper.com/api/add?red=api&url=$link&title=$desc&selection=$ext";
|
166 |
$hdrsArr = nxs_getIPHeaders($dusername.':'.$pass); $cnt = wp_remote_get( $apicall, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr) );// prr($cnt);
|
@@ -169,16 +180,15 @@ if (!function_exists("nxs_doPublishToIP")) { //## Second Function to Post to IP
|
|
169 |
$cnt = wp_remote_get( $apicall, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr) );}
|
170 |
}
|
171 |
if(is_wp_error($cnt)) {
|
172 |
-
$ret = 'Something went wrong - '."";
|
173 |
} else {
|
174 |
if (is_array($cnt) && stripos($cnt['body'],'201')!==false)
|
175 |
-
{ $ret = 'OK'; nxs_metaMarkAsPosted($postID, 'IP', $options['ii'], array('isPosted'=>'1', 'pgID'=>'IP', 'pDate'=>date('Y-m-d H:i:s')));
|
176 |
-
|
177 |
-
|
178 |
-
else { if ($cnt['response']['code']=='401') $ret = " Incorrect Username/Password "; else $ret = 'Something went wrong - '."https://$dusername:*********@$api/posts/add?&url=$link&description=$desc&extended=$ext&tags=$tags"; nxs_addToLog($logNT, 'E', '-=ERROR=- '.$ret. "ERR: ".print_r($cnt, true), $extInfo);
|
179 |
}
|
180 |
}
|
181 |
-
if ($ret!='OK') { if ($postID=='0') echo $ret; } else if ($postID=='0') { echo 'OK - Message Posted, please see your Instapaper Page. ';
|
182 |
if ($ret == 'OK') return 200; else return $ret;
|
183 |
|
184 |
}
|
15 |
<div class="nxs_box_inside">
|
16 |
<?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
|
17 |
<p style="margin:0px;margin-left:5px;">
|
18 |
+
<input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> /> <?php if ((int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
|
19 |
<strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
|
20 |
<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'nxs_snap'); ?> ==></b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>
|
21 |
<a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
|
58 |
|
59 |
<div id="altFormat" style="">
|
60 |
<div style="width:100%;"><strong id="altFormatText"><?php _e('Post Text Format', 'nxs_snap'); ?></strong> (<a href="#" id="apIPMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apIPMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)</div>
|
61 |
+
|
62 |
+
<textarea cols="150" rows="3" id="ip<?php echo $ii; ?>SNAPformat" name="ip[<?php echo $ii; ?>][apIPMsgFrmt]" style="width:51%;max-width: 650px;" onfocus="jQuery('#ip<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('apIPMsgFrmt<?php echo $ii; ?>');"><?php if ($isNew) echo "%EXCERPT%"; else _e(apply_filters('format_to_edit', htmlentities($gpo['ipMsgFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap'); ?></textarea>
|
63 |
+
|
64 |
+
<?php nxs_doShowHint("apIPMsgFrmt".$ii); ?>
|
65 |
</div><br/>
|
66 |
|
67 |
<?php if ($gpo['ipPass']!='') { ?>
|
98 |
$isAvailIP = $ntOpt['ipUName']!='' && $ntOpt['ipPass']!=''; $ipMsgFormat = htmlentities($ntOpt['ipMsgFormat'], ENT_COMPAT, "UTF-8"); $ipMsgTFormat = htmlentities($ntOpt['ipMsgTFormat'], ENT_COMPAT, "UTF-8");
|
99 |
?>
|
100 |
<tr><th style="text-align:left;" colspan="2"><?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_IP<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
|
101 |
+
<?php if ($isAvailIP) { ?><input class="nxsGrpDoChb" value="1" id="doIP<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="ip[<?php echo $ii; ?>][doIP]" <?php if ((int)$doIP == 1) echo 'checked="checked" title="def"'; ?> />
|
102 |
+
<?php if ($post->post_status == "publish") { ?> <input type="hidden" name="ip[<?php echo $ii; ?>][doIP]" value="<?php echo $doIP;?>"> <?php } ?> <?php } ?>
|
103 |
|
104 |
<div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/ip16.png);">Instapaper - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
|
105 |
if ($post->post_status == "publish" && $isAvailIP) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToIP_repostButton" id="rePostToIP_button" value="<?php _e('Repost to Instapaper', 'nxs_snap') ?>" />
|
115 |
<?php if (!$isAvailIP) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your Instapaper Account to AutoPost to Instapaper</b>
|
116 |
<?php } elseif ($post->post_status != "pubZlish") { ?>
|
117 |
|
118 |
+
<tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Title Format:', 'nxs_snap') ?></th>
|
119 |
<td><input value="<?php echo $ipMsgTFormat ?>" type="text" name="ip[<?php echo $ii; ?>][SNAPformatT]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apIPTMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apIPTMsgFrmt".$ii); ?></td></tr>
|
120 |
|
121 |
+
<tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Text Format:', 'nxs_snap') ?></th>
|
122 |
+
<td>
|
123 |
+
<textarea cols="150" rows="1" id="ip<?php echo $ii; ?>SNAPformat" name="ip[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('#ip<?php echo $ii; ?>SNAPformat').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apIPMsgFrmt<?php echo $ii; ?>');"><?php echo $ipMsgFormat; ?></textarea>
|
124 |
+
<?php nxs_doShowHint("apIPMsgFrmt".$ii); ?></td></tr>
|
125 |
<?php }
|
126 |
}
|
127 |
}
|
153 |
}}
|
154 |
|
155 |
if (!function_exists("nxs_doPublishToIP")) { //## Second Function to Post to IP
|
156 |
+
function nxs_doPublishToIP($postID, $options){ $ntCd = 'IP'; $ntCdL = 'ip'; $ntNm = 'Instapaper';
|
157 |
+
//if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToIP', array($postID, $options));
|
158 |
|
159 |
+
$ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
|
160 |
+
$logNT = '<span style="color:#000080">Instapaper</span> - '.$options['nName'];
|
161 |
+
$snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
|
162 |
if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
|
163 |
+
$snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') { sleep(5);
|
164 |
+
nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$uqID); return;
|
165 |
+
}
|
166 |
+
}
|
167 |
|
168 |
if ($postID=='0') { echo "Testing ... <br/><br/>"; $link = home_url(); $msgT = 'Test Link from '.$link; } else { $post = get_post($postID); if(!$post) return; $link = get_permalink($postID);
|
169 |
$msgFormat = $options['ipMsgFormat']; $msgTFormat = $options['ipMsgTFormat']; $msgT = nsFormatMessage($msgTFormat, $postID); $msg = nsFormatMessage($msgFormat, $postID);
|
170 |
nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
|
171 |
}
|
172 |
+
$extInfo = ' | PostID: '.$postID." - ".$post->post_title;
|
173 |
$dusername = $options['ipUName']; $pass = (substr($options['ipPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['ipPass'], 5)):$options['ipPass']);
|
174 |
+
$link = urlencode($link); $desc = urlencode(substr($msgT, 0, 250)); $ext = urlencode(substr($msg, 0, 1000));
|
|
|
175 |
$t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = urlencode(implode(',',$tggs)); $tags = str_replace(' ','+',$tags);
|
176 |
$apicall = "https://www.instapaper.com/api/add?red=api&url=$link&title=$desc&selection=$ext";
|
177 |
$hdrsArr = nxs_getIPHeaders($dusername.':'.$pass); $cnt = wp_remote_get( $apicall, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr) );// prr($cnt);
|
180 |
$cnt = wp_remote_get( $apicall, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr) );}
|
181 |
}
|
182 |
if(is_wp_error($cnt)) {
|
183 |
+
$ret = 'Something went wrong - '.""; nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.$ret. "ERR: ".print_r($cnt, true), $extInfo);
|
184 |
} else {
|
185 |
if (is_array($cnt) && stripos($cnt['body'],'201')!==false)
|
186 |
+
{ $ret = 'OK'; nxs_metaMarkAsPosted($postID, 'IP', $options['ii'], array('isPosted'=>'1', 'pgID'=>'IP', 'pDate'=>date('Y-m-d H:i:s'))); nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); }
|
187 |
+
else { if ($cnt['response']['code']=='401') $ret = " Incorrect Username/Password "; else $ret = 'Something went wrong - '."https://$dusername:*********@$api/posts/add?&url=$link&description=$desc&extended=$ext&tags=$tags";
|
188 |
+
nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.$ret. "ERR: ".print_r($cnt, true), $extInfo);
|
|
|
189 |
}
|
190 |
}
|
191 |
+
if ($ret!='OK') { if ($postID=='0') echo $ret; } else if ($postID=='0') { echo 'OK - Message Posted, please see your Instapaper Page. '; nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); }
|
192 |
if ($ret == 'OK') return 200; else return $ret;
|
193 |
|
194 |
}
|
inc-cl/li.php
CHANGED
@@ -27,7 +27,7 @@ $nxs_snapAvNts[] = array('code'=>'LI', 'lcode'=>'li', 'name'=>'LinkedIn');
|
|
27 |
|
28 |
if (!class_exists("nxs_snapClassLI")) { class nxs_snapClassLI {
|
29 |
//#### Show Common Settings
|
30 |
-
function showGenNTSettings($ntOpts){ global $nxs_snapThisPageUrl, $nxs_plurl; $ntInfo = array('code'=>'LI', 'lcode'=>'li', 'name'=>'LinkedIn
|
31 |
|
32 |
if ( isset($_GET['auth']) && $_GET['auth']=='li'){ require_once('apis/liOAuth.php'); $options = $ntOpts[$_GET['acc']];
|
33 |
|
@@ -66,7 +66,7 @@ if (!class_exists("nxs_snapClassLI")) { class nxs_snapClassLI {
|
|
66 |
if (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='') $pbo[$ntInfo['lcode'].'OK'] = (isset($pbo['liAccessToken']) && $pbo['liAccessTokenSecret']!='')?'1':'';
|
67 |
?>
|
68 |
<p style="margin:0px;margin-left:5px;">
|
69 |
-
<input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> />
|
70 |
<strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
|
71 |
<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'nxs_snap'); ?> ==></b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>
|
72 |
<a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
|
@@ -76,7 +76,7 @@ if (!class_exists("nxs_snapClassLI")) { class nxs_snapClassLI {
|
|
76 |
</div> <?php
|
77 |
}
|
78 |
//#### Show NEW Settings Page
|
79 |
-
function showNewNTSettings($bo){ $po = array('nName'=>'', 'ulName'=>'', 'uPass'=>'', 'grpID'=>'', 'uPage'=>'', 'doLI'=>'1', 'liAPIKey'=>'', 'liAPISec'=>'', 'liUserInfo'=>'', 'liAttch'=>'1', 'liOAuthToken'=>'', 'liMsgFormat'=>'New post has been published on %SITENAME%' ); $this->showNTSettings($bo, $po, true);}
|
80 |
//#### Show Unit Settings
|
81 |
function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl,$nxs_snapThisPageUrl; if (!isset($options['liOK'])) $options['liOK'] = ''; ?>
|
82 |
<div id="doLI<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>" style="background-image: url(<?php echo $nxs_plurl; ?>img/li-bg.png); background-position:90% 10%;"> <input type="hidden" name="apDoSLI<?php echo $ii; ?>" value="0" id="apDoSLI<?php echo $ii; ?>" />
|
@@ -150,18 +150,34 @@ if (!class_exists("nxs_snapClassLI")) { class nxs_snapClassLI {
|
|
150 |
|
151 |
<br/><br/>
|
152 |
|
153 |
-
|
|
|
|
|
|
|
|
|
154 |
|
155 |
<p style="margin: 0px;"><input value="1" id="apLIAttch" onchange="doShowHideAltFormat();" type="checkbox" name="li[<?php echo $ii; ?>][apLIAttch]" <?php if ((int)$options['liAttch'] == 1) echo "checked"; ?> />
|
156 |
<strong>Publish Posts to LinkedIn as an Attachment</strong>
|
157 |
-
</p>
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
|
166 |
<?php if($options['liAPIKey']!='' || (isset($options['uPass']) && $options['uPass']!='')) { ?>
|
167 |
<?php wp_nonce_field( 'rePostToLI', 'rePostToLI_wpnonce' ); ?>
|
@@ -195,6 +211,9 @@ if (!class_exists("nxs_snapClassLI")) { class nxs_snapClassLI {
|
|
195 |
if (isset($pval['grpID'])) $options[$ii]['grpID'] = trim($pval['grpID']);
|
196 |
if (isset($pval['uPage'])) $options[$ii]['uPage'] = trim($pval['uPage']);
|
197 |
if (isset($pval['apLIMsgFrmt'])) $options[$ii]['liMsgFormat'] = trim($pval['apLIMsgFrmt']);
|
|
|
|
|
|
|
198 |
if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
|
199 |
if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
|
200 |
} //prr($options);
|
@@ -205,11 +224,12 @@ if (!class_exists("nxs_snapClassLI")) { class nxs_snapClassLI {
|
|
205 |
foreach($ntOpts as $ii=>$options) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapLI', true)); if (is_array($pMeta)) $options = $this->adjMetaOpt($options, $pMeta[$ii]);
|
206 |
$doLI = $options['doLI'] && (is_array($pMeta) || $options['catSel']!='1');
|
207 |
$isAvailLI = (isset($options['liOAuthVerifier']) && $options['liOAuthVerifier']!='' && $options['liAccessTokenSecret']!='' && $options['liAccessToken']!='' && $options['liAPIKey']!='') || ($options['ulName']!=='' && $options['uPass']!=='');
|
208 |
-
$isAttachLI = $options['liAttch']; $liMsgFormat = htmlentities($options['liMsgFormat'], ENT_COMPAT, "UTF-8");
|
209 |
?>
|
210 |
|
211 |
<tr><th style="text-align:left;" colspan="2"><?php if ( $options['catSel']=='1' && trim($options['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_LI<?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" /> <?php } ?>
|
212 |
-
<?php if ($isAvailLI) { ?><input class="nxsGrpDoChb" value="1" id="doLI<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="li[<?php echo $ii; ?>][doLI]" <?php if ((
|
|
|
213 |
<div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/li16.png);">LinkedIn - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $options['nName']; ?></i>)</div></th><td><?php //## Only show RePost button if the post is "published"
|
214 |
if ($post->post_status == "publish" && $isAvailLI) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToLI_repostButton" id="rePostToLI_button" value="<?php _e('Repost to LinkedIn', 'nxs_snap') ?>" />
|
215 |
<?php wp_nonce_field( 'rePostToLI', 'rePostToLI_wpnonce' ); } ?>
|
@@ -227,8 +247,13 @@ if (!class_exists("nxs_snapClassLI")) { class nxs_snapClassLI {
|
|
227 |
<input value="0" type="hidden" name="li[<?php echo $ii; ?>][AttachPost]"/>
|
228 |
<input value="1" id="SNAP_AttachLI" onchange="doShowHideAltFormatX();" type="checkbox" name="li[<?php echo $ii; ?>][AttachPost]" <?php if ((int)$isAttachLI == 1) echo "checked"; ?> /> </th><td><strong>Publish Post to LinkedIn as Attachment</strong></td> </tr>
|
229 |
|
230 |
-
<tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;"><?php _e('Message Format:', 'nxs_snap') ?></th>
|
231 |
-
<td
|
|
|
|
|
|
|
|
|
|
|
232 |
|
233 |
<?php }
|
234 |
}
|
@@ -236,6 +261,7 @@ if (!class_exists("nxs_snapClassLI")) { class nxs_snapClassLI {
|
|
236 |
|
237 |
function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
|
238 |
if (isset($pMeta['SNAPformat'])) $optMt['liMsgFormat'] = $pMeta['SNAPformat']; if (trim($optMt['liMsgFormat'])=='') $optMt['liMsgFormat'] = ' ';
|
|
|
239 |
if (isset($pMeta['AttachPost'])) $optMt['liAttch'] = $pMeta['AttachPost'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['liAttch'] = 0; }
|
240 |
if (isset($pMeta['doLI'])) $optMt['doLI'] = $pMeta['doLI'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doLI'] = 0; }
|
241 |
if (isset($pMeta['SNAPincludeLI']) && $pMeta['SNAPincludeLI'] == '1' ) $optMt['doLI'] = 1;
|
@@ -255,45 +281,54 @@ if (!function_exists("nxs_rePostToLI_ajax")) { function nxs_rePostToLI_ajax() {
|
|
255 |
}
|
256 |
|
257 |
if (!function_exists("nxs_doPublishToLI")) { //## Second Function to Post to LI
|
258 |
-
function nxs_doPublishToLI($postID, $options){ global $nxs_gCookiesArr; $ntCd = 'LI'; $ntCdL = 'li'; $ntNm = 'LinkedIn';
|
259 |
-
|
260 |
-
$ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
|
|
|
|
|
261 |
if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
|
262 |
-
|
|
|
|
|
263 |
}
|
264 |
|
265 |
$blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url(); // prr($options);
|
266 |
if ($postID=='0') { echo "Testing ... <br/><br/>"; $msgT = 'Test Post from '.$blogTitle; $link = home_url(); $msg = 'Test Post from '.$blogTitle. " ".$link; $isAttachLI = ''; $title = $blogTitle; }
|
267 |
-
else { $post = get_post($postID); if(!$post) return; $liMsgFormat = $options['liMsgFormat']; $msg = nsFormatMessage($liMsgFormat, $postID);
|
268 |
$link = get_permalink($postID); $isAttachLI = $options['liAttch']; $title = nsTrnc($post->post_title, 200); nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
|
269 |
}
|
270 |
-
|
271 |
-
if ($isAttachLI=='1') {
|
272 |
-
|
|
|
|
|
273 |
}
|
274 |
-
$
|
275 |
if (function_exists("doConnectToLinkedIn") && $options['ulName']!='' && $options['uPass']!='') {
|
276 |
$auth = doConnectToLinkedIn($options['ulName'], $options['uPass'], $options['ii']); if ($auth!==false) die($auth);
|
277 |
$to = $options['uPage']!=''?$options['uPage']:'http://www.linkedin.com/home'; $lnk = array(); $msg = str_ireplace(' ',' ',$msg); $msg = nsTrnc(strip_tags($msg), 700);
|
278 |
if ($postID=='0') { $lnk['title'] = get_bloginfo('name'); $lnk['desc'] = get_bloginfo('description'); $lnk['url'] = home_url();
|
279 |
-
} else { if ($isAttachLI=='1') { $lnk['title'] = nsTrnc( strip_tags($post->post_title), 200); $lnk['desc'] = $dsc; $lnk['url'] = get_permalink($postID); $lnk['img'] = $src; }} //prr($msg);
|
280 |
$ret = doPostToLinkedIn($msg, $lnk, $to); $liPostID = $options['uPage'];
|
281 |
} else { require_once ('apis/liOAuth.php'); $linkedin = new nsx_LinkedIn($options['liAPIKey'], $options['liAPISec']); $linkedin->oauth_verifier = $options['liOAuthVerifier'];
|
282 |
$linkedin->request_token = new nsx_trOAuthConsumer($options['liOAuthToken'], $options['liOAuthTokenSecret'], 1);
|
283 |
$linkedin->access_token = new nsx_trOAuthConsumer($options['liAccessToken'], $options['liAccessTokenSecret'], 1); $msg = nsTrnc($msg, 700);
|
284 |
if ($options['grpID']!=''){
|
285 |
-
try{ $
|
|
|
|
|
|
|
286 |
} else {
|
287 |
try{ if($isAttachLI=='1') $ret = $linkedin->postShare($msg, nsTrnc($post->post_title, 200), get_permalink($postID), $src, $dsc); else $ret = $linkedin->postShare($msg); }
|
288 |
-
catch (Exception $o){
|
289 |
}
|
290 |
//$liPostID = $linkedin->getCurrentShare(); prr($liPostID);
|
291 |
-
$liPostID = $options['liUserInfo'];
|
292 |
}
|
293 |
if (stripos($ret, 'update-url')!==false) { $liPostID = CutFromTo($ret, '<update-url>','</update-url>'); $ret = '201'; }
|
294 |
-
if ($ret!='201') { if ($postID=='0') prr($ret);
|
295 |
-
else if ($postID=='0') { echo 'OK - Linkedin status updated successfully';
|
296 |
-
{ nxs_metaMarkAsPosted($postID, 'LI', $options['ii'], array('isPosted'=>'1', 'pgID'=>$liPostID, 'pDate'=>date('Y-m-d H:i:s')));
|
297 |
if ($ret=='201') return true; else return 'Something Wrong';
|
298 |
}
|
299 |
}
|
27 |
|
28 |
if (!class_exists("nxs_snapClassLI")) { class nxs_snapClassLI {
|
29 |
//#### Show Common Settings
|
30 |
+
function showGenNTSettings($ntOpts){ global $nxs_snapThisPageUrl, $nxs_plurl; $ntInfo = array('code'=>'LI', 'lcode'=>'li', 'name'=>'LinkedIn', 'defNName'=>'ulName', 'tstReq' => true);
|
31 |
|
32 |
if ( isset($_GET['auth']) && $_GET['auth']=='li'){ require_once('apis/liOAuth.php'); $options = $ntOpts[$_GET['acc']];
|
33 |
|
66 |
if (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='') $pbo[$ntInfo['lcode'].'OK'] = (isset($pbo['liAccessToken']) && $pbo['liAccessTokenSecret']!='')?'1':'';
|
67 |
?>
|
68 |
<p style="margin:0px;margin-left:5px;">
|
69 |
+
<input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> /> <?php if ((int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
|
70 |
<strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
|
71 |
<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'nxs_snap'); ?> ==></b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>
|
72 |
<a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
|
76 |
</div> <?php
|
77 |
}
|
78 |
//#### Show NEW Settings Page
|
79 |
+
function showNewNTSettings($bo){ $po = array('nName'=>'', 'ulName'=>'', 'uPass'=>'', 'grpID'=>'', 'uPage'=>'', 'doLI'=>'1', 'liAPIKey'=>'', 'liAPISec'=>'', 'liUserInfo'=>'', 'liAttch'=>'1', 'liOAuthToken'=>'', 'liMsgFormat'=>'New post has been published on %SITENAME%', 'liMsgFormatT'=>'New post - %TITLE%' ); $this->showNTSettings($bo, $po, true);}
|
80 |
//#### Show Unit Settings
|
81 |
function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl,$nxs_snapThisPageUrl; if (!isset($options['liOK'])) $options['liOK'] = ''; ?>
|
82 |
<div id="doLI<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>" style="background-image: url(<?php echo $nxs_plurl; ?>img/li-bg.png); background-position:90% 10%;"> <input type="hidden" name="apDoSLI<?php echo $ii; ?>" value="0" id="apDoSLI<?php echo $ii; ?>" />
|
150 |
|
151 |
<br/><br/>
|
152 |
|
153 |
+
<div id="altFormat">
|
154 |
+
<div style="width:100%;"><strong id="altFormatText"><?php _e('Message text Format', 'nxs_snap'); ?>:</strong> </div>
|
155 |
+
<textarea cols="150" rows="3" id="li<?php echo $ii; ?>SNAPformat" name="li[<?php echo $ii; ?>][apLIMsgFrmt]" style="width:51%;max-width: 650px;" onfocus="jQuery('#li<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('apLIMsgFrmt<?php echo $ii; ?>');"><?php _e(apply_filters('format_to_edit',htmlentities($options['liMsgFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?></textarea>
|
156 |
+
<?php nxs_doShowHint("apIPMsgFrmt".$ii); ?>
|
157 |
+
</div>
|
158 |
|
159 |
<p style="margin: 0px;"><input value="1" id="apLIAttch" onchange="doShowHideAltFormat();" type="checkbox" name="li[<?php echo $ii; ?>][apLIAttch]" <?php if ((int)$options['liAttch'] == 1) echo "checked"; ?> />
|
160 |
<strong>Publish Posts to LinkedIn as an Attachment</strong>
|
161 |
+
</p>
|
162 |
+
|
163 |
+
<div style="margin-left: 10px;">
|
164 |
+
|
165 |
+
<strong><?php _e('Attachment Text Format', 'nxs_snap'); ?>:</strong><br/>
|
166 |
+
<input value="1" id="apLIMsgAFrmtA<?php echo $ii; ?>" <?php if (trim($options['liMsgAFrmt'])=='') echo "checked"; ?> onchange="if (jQuery(this).is(':checked')) { jQuery('#apLIMsgAFrmtDiv<?php echo $ii; ?>').hide(); jQuery('#apLIMsgAFrmt<?php echo $ii; ?>').val(''); }else jQuery('#apLIMsgAFrmtDiv<?php echo $ii; ?>').show();" type="checkbox" name="li[<?php echo $ii; ?>][apLIMsgAFrmtA]"/> <strong><?php _e('Auto', 'nxs_snap'); ?></strong>
|
167 |
+
<i> - <?php _e('Recommended. Info from SEO Plugins will be used, then post excerpt, then post text', 'nxs_snap'); ?> </i><br/>
|
168 |
+
<div id="apLIMsgAFrmtDiv<?php echo $ii; ?>" style="<?php if ($options['liMsgAFrmt']=='') echo "display:none;"; ?>" > <?php _e('Set your own format', 'nxs_snap'); ?>:<input name="li[<?php echo $ii; ?>][apLIMsgAFrmt]" id="apLIMsgAFrmt<?php echo $ii; ?>" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['liMsgAFrmt'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /><br/></div>
|
169 |
+
|
170 |
+
</div>
|
171 |
+
|
172 |
+
<br/>
|
173 |
+
<div id="altFormat">
|
174 |
+
<div style="width:100%;"><strong id="altFormatText"><?php _e('Message title Format (Groups Only)', 'nxs_snap'); ?>:</strong> </div>
|
175 |
+
|
176 |
+
<input name="li[<?php echo $ii; ?>][apLIMsgFrmtT]" id="li<?php echo $ii; ?>SNAPformatT" style="width: 50%;" value="<?php if ($isNew) echo "New Post - %TITLE%"; else _e(apply_filters('format_to_edit',htmlentities($options['liMsgFormatT'], ENT_COMPAT, "UTF-8")), 'nxs_snap'); ?>" onfocus="mxs_showFrmtInfo('apLIMsgFrmtT<?php echo $ii; ?>');" /><?php nxs_doShowHint("apIPMsgFrmt".$ii); ?>
|
177 |
+
|
178 |
+
</div>
|
179 |
+
|
180 |
+
<br/>
|
181 |
|
182 |
<?php if($options['liAPIKey']!='' || (isset($options['uPass']) && $options['uPass']!='')) { ?>
|
183 |
<?php wp_nonce_field( 'rePostToLI', 'rePostToLI_wpnonce' ); ?>
|
211 |
if (isset($pval['grpID'])) $options[$ii]['grpID'] = trim($pval['grpID']);
|
212 |
if (isset($pval['uPage'])) $options[$ii]['uPage'] = trim($pval['uPage']);
|
213 |
if (isset($pval['apLIMsgFrmt'])) $options[$ii]['liMsgFormat'] = trim($pval['apLIMsgFrmt']);
|
214 |
+
if (isset($pval['apLIMsgFrmtT'])) $options[$ii]['liMsgFormatT'] = trim($pval['apLIMsgFrmtT']);
|
215 |
+
if (isset($pval['apLIMsgAFrmt'])) $options[$ii]['liMsgAFrmt'] = trim($pval['apLIMsgAFrmt']);
|
216 |
+
|
217 |
if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
|
218 |
if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
|
219 |
} //prr($options);
|
224 |
foreach($ntOpts as $ii=>$options) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapLI', true)); if (is_array($pMeta)) $options = $this->adjMetaOpt($options, $pMeta[$ii]);
|
225 |
$doLI = $options['doLI'] && (is_array($pMeta) || $options['catSel']!='1');
|
226 |
$isAvailLI = (isset($options['liOAuthVerifier']) && $options['liOAuthVerifier']!='' && $options['liAccessTokenSecret']!='' && $options['liAccessToken']!='' && $options['liAPIKey']!='') || ($options['ulName']!=='' && $options['uPass']!=='');
|
227 |
+
$isAttachLI = $options['liAttch']; $liMsgFormat = htmlentities($options['liMsgFormat'], ENT_COMPAT, "UTF-8"); $liMsgFormatT = htmlentities($options['liMsgFormatT'], ENT_COMPAT, "UTF-8");
|
228 |
?>
|
229 |
|
230 |
<tr><th style="text-align:left;" colspan="2"><?php if ( $options['catSel']=='1' && trim($options['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_LI<?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" /> <?php } ?>
|
231 |
+
<?php if ($isAvailLI) { ?><input class="nxsGrpDoChb" value="1" id="doLI<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="li[<?php echo $ii; ?>][doLI]" <?php if ((int)$doLI == 1) echo 'checked="checked" title="def"'; ?> />
|
232 |
+
<?php if ($post->post_status == "publish") { ?> <input type="hidden" name="li[<?php echo $ii; ?>][doLI]" value="<?php echo $doLI;?>"> <?php } ?> <?php } ?>
|
233 |
<div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/li16.png);">LinkedIn - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $options['nName']; ?></i>)</div></th><td><?php //## Only show RePost button if the post is "published"
|
234 |
if ($post->post_status == "publish" && $isAvailLI) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToLI_repostButton" id="rePostToLI_button" value="<?php _e('Repost to LinkedIn', 'nxs_snap') ?>" />
|
235 |
<?php wp_nonce_field( 'rePostToLI', 'rePostToLI_wpnonce' ); } ?>
|
247 |
<input value="0" type="hidden" name="li[<?php echo $ii; ?>][AttachPost]"/>
|
248 |
<input value="1" id="SNAP_AttachLI" onchange="doShowHideAltFormatX();" type="checkbox" name="li[<?php echo $ii; ?>][AttachPost]" <?php if ((int)$isAttachLI == 1) echo "checked"; ?> /> </th><td><strong>Publish Post to LinkedIn as Attachment</strong></td> </tr>
|
249 |
|
250 |
+
<tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Message Format:', 'nxs_snap') ?></th>
|
251 |
+
<td>
|
252 |
+
<textarea cols="150" rows="1" id="li<?php echo $ii; ?>SNAPformat" name="li[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('#li<?php echo $ii; ?>SNAPformat').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apLIMsgFrmt<?php echo $ii; ?>');"><?php echo $liMsgFormat; ?></textarea>
|
253 |
+
<?php nxs_doShowHint("apLIMsgFrmt".$ii); ?></td></tr>
|
254 |
+
|
255 |
+
<tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Title Format (Groups Only):', 'nxs_snap') ?></th>
|
256 |
+
<td><input value="<?php echo $liMsgFormatT ?>" type="text" name="li[<?php echo $ii; ?>][SNAPformatT]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apLIMsgFrmtT<?php echo $ii; ?>');"/><?php nxs_doShowHint("apLIMsgFrmtT".$ii, '', '58'); ?></td></tr>
|
257 |
|
258 |
<?php }
|
259 |
}
|
261 |
|
262 |
function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
|
263 |
if (isset($pMeta['SNAPformat'])) $optMt['liMsgFormat'] = $pMeta['SNAPformat']; if (trim($optMt['liMsgFormat'])=='') $optMt['liMsgFormat'] = ' ';
|
264 |
+
if (isset($pMeta['SNAPformatT'])) $optMt['liMsgFormatT'] = $pMeta['SNAPformatT']; if (trim($optMt['liMsgFormatT'])=='') $optMt['liMsgFormatT'] = ' ';
|
265 |
if (isset($pMeta['AttachPost'])) $optMt['liAttch'] = $pMeta['AttachPost'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['liAttch'] = 0; }
|
266 |
if (isset($pMeta['doLI'])) $optMt['doLI'] = $pMeta['doLI'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doLI'] = 0; }
|
267 |
if (isset($pMeta['SNAPincludeLI']) && $pMeta['SNAPincludeLI'] == '1' ) $optMt['doLI'] = 1;
|
281 |
}
|
282 |
|
283 |
if (!function_exists("nxs_doPublishToLI")) { //## Second Function to Post to LI
|
284 |
+
function nxs_doPublishToLI($postID, $options){ global $nxs_gCookiesArr; $ntCd = 'LI'; $ntCdL = 'li'; $ntNm = 'LinkedIn';
|
285 |
+
//if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToLI', array($postID, $options));
|
286 |
+
$ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
|
287 |
+
$logNT = '<span style="color:#000058">LinkedIn</span> - '.$options['nName'];
|
288 |
+
$snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
|
289 |
if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
|
290 |
+
$snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') { sleep(5);
|
291 |
+
nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$uqID); return;
|
292 |
+
}
|
293 |
}
|
294 |
|
295 |
$blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url(); // prr($options);
|
296 |
if ($postID=='0') { echo "Testing ... <br/><br/>"; $msgT = 'Test Post from '.$blogTitle; $link = home_url(); $msg = 'Test Post from '.$blogTitle. " ".$link; $isAttachLI = ''; $title = $blogTitle; }
|
297 |
+
else { $post = get_post($postID); if(!$post) return; $liMsgFormat = $options['liMsgFormat']; $msg = nsFormatMessage($liMsgFormat, $postID); $msgT = nsFormatMessage($options['liMsgFormatT'], $postID);
|
298 |
$link = get_permalink($postID); $isAttachLI = $options['liAttch']; $title = nsTrnc($post->post_title, 200); nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
|
299 |
}
|
300 |
+
$extInfo = ' | PostID: '.$postID." - ".$post->post_title; $msgT = nsTrnc($msgT, 200);
|
301 |
+
if ($isAttachLI=='1') {
|
302 |
+
if (trim($options['liMsgAFrmt'])!='') {$dsc = nsFormatMessage($options['liMsgAFrmt'], $postID, $addParams);} else {
|
303 |
+
$src = nxs_getPostImage($postID); $dsc = trim(apply_filters('the_content', $post->post_excerpt)); if ($dsc=='') $dsc = apply_filters('the_content', $post->post_content);
|
304 |
+
} $dsc = strip_tags($dsc); $dsc = nxs_decodeEntitiesFull($dsc); $dsc = nxs_html_to_utf8($dsc); $dsc = nsTrnc($dsc, 300);
|
305 |
}
|
306 |
+
$msg = nxs_html_to_utf8($msg); $msgT = nxs_html_to_utf8($msgT);
|
307 |
if (function_exists("doConnectToLinkedIn") && $options['ulName']!='' && $options['uPass']!='') {
|
308 |
$auth = doConnectToLinkedIn($options['ulName'], $options['uPass'], $options['ii']); if ($auth!==false) die($auth);
|
309 |
$to = $options['uPage']!=''?$options['uPage']:'http://www.linkedin.com/home'; $lnk = array(); $msg = str_ireplace(' ',' ',$msg); $msg = nsTrnc(strip_tags($msg), 700);
|
310 |
if ($postID=='0') { $lnk['title'] = get_bloginfo('name'); $lnk['desc'] = get_bloginfo('description'); $lnk['url'] = home_url();
|
311 |
+
} else { if ($isAttachLI=='1') { $lnk['title'] = nsTrnc( strip_tags($post->post_title), 200); $lnk['postTitle'] = $msgT; $lnk['desc'] = $dsc; $lnk['url'] = get_permalink($postID); $lnk['img'] = $src; }} //prr($msg);
|
312 |
$ret = doPostToLinkedIn($msg, $lnk, $to); $liPostID = $options['uPage'];
|
313 |
} else { require_once ('apis/liOAuth.php'); $linkedin = new nsx_LinkedIn($options['liAPIKey'], $options['liAPISec']); $linkedin->oauth_verifier = $options['liOAuthVerifier'];
|
314 |
$linkedin->request_token = new nsx_trOAuthConsumer($options['liOAuthToken'], $options['liOAuthTokenSecret'], 1);
|
315 |
$linkedin->access_token = new nsx_trOAuthConsumer($options['liAccessToken'], $options['liAccessTokenSecret'], 1); $msg = nsTrnc($msg, 700);
|
316 |
if ($options['grpID']!=''){
|
317 |
+
try{ // prr($msgT); prr($msg); prr($options['grpID']); prr($src); prr($dsc); $purl = get_permalink($postID); prr($purl);
|
318 |
+
if($isAttachLI=='1') $ret = $linkedin->postToGroup($msg, $msgT, $options['grpID'], get_permalink($postID), $src, $dsc); else $ret = $linkedin->postToGroup($msg, $msgT, $options['grpID']);
|
319 |
+
$liPostID= 'http://www.linkedin.com/groups?gid='.$options['grpID'];
|
320 |
+
} catch (Exception $o){ nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '."Linkedin Status couldn't be updated! - ".print_r($o, true)); $ret="ERROR:".print_r($o, true); }
|
321 |
} else {
|
322 |
try{ if($isAttachLI=='1') $ret = $linkedin->postShare($msg, nsTrnc($post->post_title, 200), get_permalink($postID), $src, $dsc); else $ret = $linkedin->postShare($msg); }
|
323 |
+
catch (Exception $o){ nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '."<br/>Linkedin Status couldn't be updated! - ".print_r($o, true)); $ret="ERROR:".print_r($o, true); }
|
324 |
}
|
325 |
//$liPostID = $linkedin->getCurrentShare(); prr($liPostID);
|
326 |
+
if ($liPostID=='') $liPostID = $options['liUserInfo'];
|
327 |
}
|
328 |
if (stripos($ret, 'update-url')!==false) { $liPostID = CutFromTo($ret, '<update-url>','</update-url>'); $ret = '201'; }
|
329 |
+
if ($ret!='201') { if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo); }
|
330 |
+
else if ($postID=='0') { echo 'OK - Linkedin status updated successfully'; nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); } else
|
331 |
+
{ nxs_metaMarkAsPosted($postID, 'LI', $options['ii'], array('isPosted'=>'1', 'pgID'=>$liPostID, 'pDate'=>date('Y-m-d H:i:s'))); nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); }
|
332 |
if ($ret=='201') return true; else return 'Something Wrong';
|
333 |
}
|
334 |
}
|
inc-cl/lj.php
CHANGED
@@ -15,7 +15,7 @@ if (!class_exists("nxs_snapClassLJ")) { class nxs_snapClassLJ {
|
|
15 |
<div class="nxs_box_inside">
|
16 |
<?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = str_ireplace('/xmlrpc.php','', str_ireplace('http://','', str_ireplace('https://','', $pbo['ljURL']))); ?>
|
17 |
<p style="margin:0px;margin-left:5px;">
|
18 |
-
<input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> />
|
19 |
<strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
|
20 |
<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'nxs_snap'); ?> ==></b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>
|
21 |
<a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
|
@@ -25,7 +25,7 @@ if (!class_exists("nxs_snapClassLJ")) { class nxs_snapClassLJ {
|
|
25 |
</div> <?php
|
26 |
}
|
27 |
//#### Show NEW Settings Page
|
28 |
-
function showNewNTSettings($mgpo){ $gpo = array('nName'=>'', 'doLJ'=>'1', 'ljUName'=>'', 'ljPageID'=>'', 'ljAttch'=>'', 'ljPass'=>'', 'ljURL'=>''); $this->showNTSettings($mgpo, $gpo, true);}
|
29 |
//#### Show Unit Settings
|
30 |
function showNTSettings($ii, $gpo, $isNew=false){ global $nxs_plurl; ?>
|
31 |
<div id="doLJ<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>" style="background-image: url(<?php echo $nxs_plurl; ?>img/lj-bg.png); background-position:90% 10%;"> <input type="hidden" name="apDoSLJ<?php echo $ii; ?>" value="0" id="apDoSLJ<?php echo $ii; ?>" />
|
@@ -66,16 +66,19 @@ if (!class_exists("nxs_snapClassLJ")) { class nxs_snapClassLJ {
|
|
66 |
</div>
|
67 |
<div id="altFormat" style="">
|
68 |
<div style="width:100%;"><strong id="altFormatText"><?php _e('Post Text Format', 'nxs_snap'); ?></strong> (<a href="#" id="apLJMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apLJMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)
|
69 |
-
</div
|
70 |
-
|
71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
<?php if ($gpo['ljPass']!='') { ?>
|
73 |
<?php wp_nonce_field( 'rePostToLJ', 'rePostToLJ_wpnonce' ); ?>
|
74 |
-
<b><?php _e('Test your settings', 'nxs_snap'); ?>:</b> <a href="#" class="NXSButton" onclick="testPost('LJ', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'nxs_snap' ), $nType); ?></a>
|
75 |
-
|
76 |
-
<?php }
|
77 |
-
|
78 |
-
?><div class="submit"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div></div><?php
|
79 |
}
|
80 |
//#### Set Unit Settings from POST
|
81 |
function setNTSettings($post, $options){ global $nxs_snapThisPageUrl; $code = 'LJ'; $lcode = 'lj';
|
@@ -88,6 +91,8 @@ if (!class_exists("nxs_snapClassLJ")) { class nxs_snapClassLJ {
|
|
88 |
if (isset($pval['apLJMsgFrmt'])) $options[$ii]['ljMsgFormat'] = trim($pval['apLJMsgFrmt']);
|
89 |
if (isset($pval['apLJMsgTFrmt'])) $options[$ii]['ljMsgTFormat'] = trim($pval['apLJMsgTFrmt']);
|
90 |
if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']);
|
|
|
|
|
91 |
if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
|
92 |
|
93 |
if (isset($pval['commID'])) {
|
@@ -107,7 +112,8 @@ if (!class_exists("nxs_snapClassLJ")) { class nxs_snapClassLJ {
|
|
107 |
$isAvailLJ = $ntOpt['ljUName']!='' && $ntOpt['ljPass']!=''; $ljMsgFormat = htmlentities($ntOpt['ljMsgFormat'], ENT_COMPAT, "UTF-8"); $ljMsgTFormat = htmlentities($ntOpt['ljMsgTFormat'], ENT_COMPAT, "UTF-8");
|
108 |
?>
|
109 |
<tr><th style="text-align:left;" colspan="2"><?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_LJ<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
|
110 |
-
<?php if ($isAvailLJ) { ?><input class="nxsGrpDoChb" value="1" id="doLJ<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="lj[<?php echo $ii; ?>][doLJ]" <?php if ((
|
|
|
111 |
<div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/lj16.png);">LiveJournal - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
|
112 |
if ($post->post_status == "publish" && $isAvailLJ) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="shoLJopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToLJ_repostButton" id="rePostToLJ_button" value="<?php _e('Repost to LiveJournal', 'nxs_snap') ?>" />
|
113 |
<?php wp_nonce_field( 'rePostToLJ', 'rePostToLJ_wpnonce' ); } ?>
|
@@ -122,11 +128,13 @@ if (!class_exists("nxs_snapClassLJ")) { class nxs_snapClassLJ {
|
|
122 |
<?php if (!$isAvailLJ) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your LiveJournal Account to AutoPost to LiveJournal</b>
|
123 |
<?php } elseif ($post->post_status != "puZblish") { ?>
|
124 |
|
125 |
-
<tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;"><?php _e('Title Format:', 'nxs_snap') ?></th>
|
126 |
<td><input value="<?php echo $ljMsgTFormat ?>" type="text" name="lj[<?php echo $ii; ?>][SNAPformatT]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apLJTMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apLJTMsgFrmt".$ii); ?></td></tr>
|
127 |
|
128 |
-
<tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;"><?php _e('Text Format:', 'nxs_snap') ?></th>
|
129 |
-
<td
|
|
|
|
|
130 |
|
131 |
<?php }
|
132 |
}
|
@@ -151,33 +159,41 @@ if (!function_exists("nxs_rePostToLJ_ajax")) {
|
|
151 |
}
|
152 |
|
153 |
if (!function_exists("nxs_doPublishToLJ")) { //## Second Function to Post to LJ
|
154 |
-
function nxs_doPublishToLJ($postID, $options){ $ntCd = 'LJ'; $ntCdL = 'lj'; $ntNm = 'LJ Based Blog';
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
|
|
|
|
|
|
|
|
160 |
$imgURL = nxs_getPostImage($postID);
|
161 |
$email = $options['ljUName']; $pass = substr($options['ljPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['ljPass'], 5)):$options['ljPass'];
|
162 |
if ($postID=='0') { echo "Testing ... <br/><br/>"; $link = home_url(); $msgT = 'Test Link from '.$link; $msg = 'Test post please ignore'; } else { $post = get_post($postID); if(!$post) return; $link = get_permalink($postID);
|
163 |
$msgFormat = $options['ljMsgFormat']; $msg = nsFormatMessage($msgFormat, $postID); $msgTFormat = $options['ljMsgTFormat']; $msgT = nsFormatMessage($msgTFormat, $postID);
|
164 |
nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
|
165 |
} //prr($msg); prr($msgFormat);
|
|
|
166 |
//## Post
|
167 |
require_once ('apis/xmlrpc-client.php'); if ($options['ljSrv']=='DW') $server = 'dreamwidth.org'; else $server = 'livejournal.com';
|
168 |
-
$nxsToLJclient = new NXS_XMLRPC_Client('http://www.'.$server.'/interface/xmlrpc'); $nxsToLJclient->debug = false;
|
169 |
-
$extInfo = ' | PostID: '.$postID." - ".$post->post_title; $logNT = '<span style="color:#2097EE">LJ</span> - '.$options['nName'];
|
170 |
|
171 |
$date = time(); $year = date("Y", $date); $mon = date("m", $date); $day = date("d", $date); $hour = date("G", $date); $min = date("i", $date);
|
172 |
$nxsToLJContent = array( "username" => $options['ljUName'], "password" => $pass, "event" => $msg, "subject" => $msgT, "lineendings" => "unix", "year" => $year, "mon" => $mon, "day" => $day, "hour" => $hour, "min" => $min, "ver" => 2);
|
173 |
-
if ($options['commID']!='') $nxsToLJContent["usejournal"] = $options['commID'];
|
|
|
|
|
|
|
|
|
174 |
if (!$nxsToLJclient->query('LJ.XMLRPC.postevent', $nxsToLJContent)) { $ret = 'Something went wrong - '.$nxsToLJclient->getErrorCode().' : '.$nxsToLJclient->getErrorMessage();} else $ret = 'OK';
|
175 |
$pid = $nxsToLJclient->getResponse(); if (is_array($pid)) $pid = $pid['url']; else { $ret = 'Something went wrong - NO PID '.print_r($pid, true);}
|
176 |
|
177 |
if ($ret!='OK') { if ($postID=='0') echo $ret;
|
178 |
-
|
179 |
-
} else { if ($postID=='0') { echo 'OK - Message Posted, please see your LiveJournal';
|
180 |
-
{ nxs_metaMarkAsPosted($postID, 'LJ', $options['ii'], array('isPosted'=>'1', 'pgID'=>$pid, 'pDate'=>date('Y-m-d H:i:s')));
|
181 |
if ($ret == 'OK') return 200; else return $ret;
|
182 |
}
|
183 |
}
|
15 |
<div class="nxs_box_inside">
|
16 |
<?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = str_ireplace('/xmlrpc.php','', str_ireplace('http://','', str_ireplace('https://','', $pbo['ljURL']))); ?>
|
17 |
<p style="margin:0px;margin-left:5px;">
|
18 |
+
<input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> /> <?php if ((int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
|
19 |
<strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
|
20 |
<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'nxs_snap'); ?> ==></b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>
|
21 |
<a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
|
25 |
</div> <?php
|
26 |
}
|
27 |
//#### Show NEW Settings Page
|
28 |
+
function showNewNTSettings($mgpo){ $gpo = array('nName'=>'', 'doLJ'=>'1', 'ljUName'=>'', 'ljPageID'=>'', 'inclTags'=>'1', 'ljAttch'=>'', 'ljPass'=>'', 'ljURL'=>''); $this->showNTSettings($mgpo, $gpo, true);}
|
29 |
//#### Show Unit Settings
|
30 |
function showNTSettings($ii, $gpo, $isNew=false){ global $nxs_plurl; ?>
|
31 |
<div id="doLJ<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>" style="background-image: url(<?php echo $nxs_plurl; ?>img/lj-bg.png); background-position:90% 10%;"> <input type="hidden" name="apDoSLJ<?php echo $ii; ?>" value="0" id="apDoSLJ<?php echo $ii; ?>" />
|
66 |
</div>
|
67 |
<div id="altFormat" style="">
|
68 |
<div style="width:100%;"><strong id="altFormatText"><?php _e('Post Text Format', 'nxs_snap'); ?></strong> (<a href="#" id="apLJMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apLJMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)
|
69 |
+
</div>
|
70 |
+
|
71 |
+
<textarea cols="150" rows="3" id="lj<?php echo $ii; ?>SNAPformat" name="lj[<?php echo $ii; ?>][apLJMsgFrmt]" style="width:51%;max-width: 650px;" onfocus="jQuery('#lj<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('apLJMsgFrmt<?php echo $ii; ?>');"><?php if ($isNew) echo "%FULLTEXT%"; else _e(apply_filters('format_to_edit', htmlentities($gpo['ljMsgFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap'); ?></textarea>
|
72 |
+
|
73 |
+
<?php nxs_doShowHint("apLJMsgFrmt".$ii); ?>
|
74 |
+
</div>
|
75 |
+
<p style="margin-bottom: 20px;margin-top: 5px;"><input value="1" id="ljInclTags<?php echo $ii; ?>" type="checkbox" name="lj[<?php echo $ii; ?>][inclTags]" <?php if ((int)$gpo['inclTags'] == 1) echo "checked"; ?> />
|
76 |
+
<strong><?php _e('Post with tags.', 'nxs_snap') ?></strong> <?php _e('Tags from the blogpost will be auto posted to LiveJournal', 'nxs_snap') ?>
|
77 |
+
</p><br/>
|
78 |
<?php if ($gpo['ljPass']!='') { ?>
|
79 |
<?php wp_nonce_field( 'rePostToLJ', 'rePostToLJ_wpnonce' ); ?>
|
80 |
+
<b><?php _e('Test your settings', 'nxs_snap'); ?>:</b> <a href="#" class="NXSButton" onclick="testPost('LJ', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'nxs_snap' ), $nType); ?></a> <?php } ?>
|
81 |
+
<div class="submit"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div></div><?php
|
|
|
|
|
|
|
82 |
}
|
83 |
//#### Set Unit Settings from POST
|
84 |
function setNTSettings($post, $options){ global $nxs_snapThisPageUrl; $code = 'LJ'; $lcode = 'lj';
|
91 |
if (isset($pval['apLJMsgFrmt'])) $options[$ii]['ljMsgFormat'] = trim($pval['apLJMsgFrmt']);
|
92 |
if (isset($pval['apLJMsgTFrmt'])) $options[$ii]['ljMsgTFormat'] = trim($pval['apLJMsgTFrmt']);
|
93 |
if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']);
|
94 |
+
if (isset($pval['inclTags'])) $options[$ii]['inclTags'] = $pval['inclTags']; else $options[$ii]['inclTags'] = 0;
|
95 |
+
|
96 |
if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
|
97 |
|
98 |
if (isset($pval['commID'])) {
|
112 |
$isAvailLJ = $ntOpt['ljUName']!='' && $ntOpt['ljPass']!=''; $ljMsgFormat = htmlentities($ntOpt['ljMsgFormat'], ENT_COMPAT, "UTF-8"); $ljMsgTFormat = htmlentities($ntOpt['ljMsgTFormat'], ENT_COMPAT, "UTF-8");
|
113 |
?>
|
114 |
<tr><th style="text-align:left;" colspan="2"><?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_LJ<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
|
115 |
+
<?php if ($isAvailLJ) { ?><input class="nxsGrpDoChb" value="1" id="doLJ<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="lj[<?php echo $ii; ?>][doLJ]" <?php if ((int)$doLJ == 1) echo 'checked="checked" title="def"'; ?> />
|
116 |
+
<?php if ($post->post_status == "publish") { ?> <input type="hidden" name="lj[<?php echo $ii; ?>][doLJ]" value="<?php echo $doLJ;?>"> <?php } ?> <?php } ?>
|
117 |
<div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/lj16.png);">LiveJournal - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
|
118 |
if ($post->post_status == "publish" && $isAvailLJ) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="shoLJopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToLJ_repostButton" id="rePostToLJ_button" value="<?php _e('Repost to LiveJournal', 'nxs_snap') ?>" />
|
119 |
<?php wp_nonce_field( 'rePostToLJ', 'rePostToLJ_wpnonce' ); } ?>
|
128 |
<?php if (!$isAvailLJ) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your LiveJournal Account to AutoPost to LiveJournal</b>
|
129 |
<?php } elseif ($post->post_status != "puZblish") { ?>
|
130 |
|
131 |
+
<tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Title Format:', 'nxs_snap') ?></th>
|
132 |
<td><input value="<?php echo $ljMsgTFormat ?>" type="text" name="lj[<?php echo $ii; ?>][SNAPformatT]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apLJTMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apLJTMsgFrmt".$ii); ?></td></tr>
|
133 |
|
134 |
+
<tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Text Format:', 'nxs_snap') ?></th>
|
135 |
+
<td>
|
136 |
+
<textarea cols="150" rows="1" id="lj<?php echo $ii; ?>SNAPformat" name="lj[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('#lj<?php echo $ii; ?>SNAPformat').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apLJMsgFrmt<?php echo $ii; ?>');"><?php echo $ljMsgFormat; ?></textarea>
|
137 |
+
<?php nxs_doShowHint("apLJMsgFrmt".$ii); ?></td></tr>
|
138 |
|
139 |
<?php }
|
140 |
}
|
159 |
}
|
160 |
|
161 |
if (!function_exists("nxs_doPublishToLJ")) { //## Second Function to Post to LJ
|
162 |
+
function nxs_doPublishToLJ($postID, $options){ $ntCd = 'LJ'; $ntCdL = 'lj'; $ntNm = 'LJ Based Blog';
|
163 |
+
//if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToLJ', array($postID, $options));
|
164 |
+
$ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
|
165 |
+
$logNT = '<span style="color:#2097EE">LJ</span> - '.$options['nName'];
|
166 |
+
$snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
|
167 |
+
if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
|
168 |
+
$snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') {
|
169 |
+
nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$uqID); return;
|
170 |
+
}
|
171 |
+
}
|
172 |
$imgURL = nxs_getPostImage($postID);
|
173 |
$email = $options['ljUName']; $pass = substr($options['ljPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['ljPass'], 5)):$options['ljPass'];
|
174 |
if ($postID=='0') { echo "Testing ... <br/><br/>"; $link = home_url(); $msgT = 'Test Link from '.$link; $msg = 'Test post please ignore'; } else { $post = get_post($postID); if(!$post) return; $link = get_permalink($postID);
|
175 |
$msgFormat = $options['ljMsgFormat']; $msg = nsFormatMessage($msgFormat, $postID); $msgTFormat = $options['ljMsgTFormat']; $msgT = nsFormatMessage($msgTFormat, $postID);
|
176 |
nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
|
177 |
} //prr($msg); prr($msgFormat);
|
178 |
+
$extInfo = ' | PostID: '.$postID." - ".$post->post_title;
|
179 |
//## Post
|
180 |
require_once ('apis/xmlrpc-client.php'); if ($options['ljSrv']=='DW') $server = 'dreamwidth.org'; else $server = 'livejournal.com';
|
181 |
+
$nxsToLJclient = new NXS_XMLRPC_Client('http://www.'.$server.'/interface/xmlrpc'); $nxsToLJclient->debug = false;
|
|
|
182 |
|
183 |
$date = time(); $year = date("Y", $date); $mon = date("m", $date); $day = date("d", $date); $hour = date("G", $date); $min = date("i", $date);
|
184 |
$nxsToLJContent = array( "username" => $options['ljUName'], "password" => $pass, "event" => $msg, "subject" => $msgT, "lineendings" => "unix", "year" => $year, "mon" => $mon, "day" => $day, "hour" => $hour, "min" => $min, "ver" => 2);
|
185 |
+
if ($options['commID']!='') $nxsToLJContent["usejournal"] = $options['commID'];
|
186 |
+
|
187 |
+
if ($options['inclTags']=='1'){ $t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = implode(',', $tggs); $nxsToLJContent['props'] = array('taglist' => $tags); }
|
188 |
+
|
189 |
+
|
190 |
if (!$nxsToLJclient->query('LJ.XMLRPC.postevent', $nxsToLJContent)) { $ret = 'Something went wrong - '.$nxsToLJclient->getErrorCode().' : '.$nxsToLJclient->getErrorMessage();} else $ret = 'OK';
|
191 |
$pid = $nxsToLJclient->getResponse(); if (is_array($pid)) $pid = $pid['url']; else { $ret = 'Something went wrong - NO PID '.print_r($pid, true);}
|
192 |
|
193 |
if ($ret!='OK') { if ($postID=='0') echo $ret;
|
194 |
+
nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);
|
195 |
+
} else { if ($postID=='0') { echo 'OK - Message Posted, please see your LiveJournal'; nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); } else
|
196 |
+
{ nxs_metaMarkAsPosted($postID, 'LJ', $options['ii'], array('isPosted'=>'1', 'pgID'=>$pid, 'pDate'=>date('Y-m-d H:i:s'))); nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo);} }
|
197 |
if ($ret == 'OK') return 200; else return $ret;
|
198 |
}
|
199 |
}
|
inc-cl/pk.php
CHANGED
@@ -54,7 +54,7 @@ if (!class_exists("nxs_snapClassPK")) { class nxs_snapClassPK {
|
|
54 |
<?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = str_ireplace('https://','', str_ireplace('http://','', $pbo['pkURL']));
|
55 |
if (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='') $pbo[$ntInfo['lcode'].'OK'] = (isset($pbo['pkOAuthTokenSecret']) && $pbo['pkOAuthTokenSecret']!='')?'1':''; ?>
|
56 |
<p style="margin:0px;margin-left:5px;">
|
57 |
-
<input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> />
|
58 |
<strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
|
59 |
<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'nxs_snap'); ?> ==></b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>
|
60 |
<a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
|
@@ -104,7 +104,9 @@ if (!class_exists("nxs_snapClassPK")) { class nxs_snapClassPK {
|
|
104 |
|
105 |
<div style="width:100%;"><strong id="altFormatText"><?php _e('Post Text Format', 'nxs_snap'); ?>:</strong> (<a href="#" id="apPKMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apPKMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>) </div>
|
106 |
|
107 |
-
|
|
|
|
|
108 |
<?php nxs_doShowHint("apPKMsgFrmt".$ii); ?>
|
109 |
<br/>
|
110 |
<?php
|
@@ -163,7 +165,8 @@ if (!class_exists("nxs_snapClassPK")) { class nxs_snapClassPK {
|
|
163 |
?>
|
164 |
|
165 |
<tr><th style="text-align:left;" colspan="2"><?php if ( $options['catSel']=='1' && trim($options['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_PK<?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" /> <?php } ?>
|
166 |
-
<?php if ($isAvailPK) { ?><input class="nxsGrpDoChb" value="1" id="doPK<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="pk[<?php echo $ii; ?>][doPK]" <?php if ((
|
|
|
167 |
<div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/pk16.png);">Plurk - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $options['nName']; ?></i>) </div></th><td><?php //## Only show RePost button if the post is "published"
|
168 |
if ($post->post_status == "publish" && $isAvailPK) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToPK_repostButton" id="rePostToPK_button" value="<?php _e('Repost to Plurk', 'nxs_snap') ?>" />
|
169 |
<?php wp_nonce_field( 'rePostToPK', 'rePostToPK_wpnonce' ); } ?>
|
@@ -188,8 +191,10 @@ if (!class_exists("nxs_snapClassPK")) { class nxs_snapClassPK {
|
|
188 |
?>
|
189 |
</select></td></tr>
|
190 |
|
191 |
-
<tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;"><?php _e('Text Format:', 'nxs_snap') ?></th>
|
192 |
-
<td
|
|
|
|
|
193 |
|
194 |
<?php }
|
195 |
}
|
@@ -216,23 +221,27 @@ if (!function_exists("nxs_rePostToPK_ajax")) { function nxs_rePostToPK_ajax() {
|
|
216 |
|
217 |
if (!function_exists("nxs_doPublishToPK")) { //## Second Function to Post to TR
|
218 |
function nxs_doPublishToPK($postID, $options){ $ntCd = 'PK'; $ntCdL = 'pk'; $ntNm = 'Plurk';
|
219 |
-
|
220 |
$blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url();
|
221 |
|
222 |
-
$ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
|
|
|
|
|
223 |
if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
|
224 |
-
|
|
|
|
|
225 |
}
|
226 |
//## Format
|
227 |
if ($postID=='0') { echo "Testing ... <br/><br/>"; $msg = 'Test Post from '.$blogTitle; $msgT = 'Test Post from '.$blogTitle;}
|
228 |
else{ $post = get_post($postID); if(!$post) return; $twMsgFormat = $options['pkMsgFormat']; nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1')); $twLim = 180;
|
229 |
-
|
230 |
if (stripos($twMsgFormat, '%URL%')!==false || stripos($twMsgFormat, '%SURL%')!==false) $twLim = $twLim - 5;
|
231 |
if (stripos($twMsgFormat, '%AUTHORNAME%')!==false) { $aun = $post->post_author; $aun = get_the_author_meta('display_name', $aun ); $twLim = $twLim - strlen($aun); }
|
232 |
|
233 |
-
$noRepl = str_ireplace("%TITLE%", "", $twMsgFormat); $noRepl = str_ireplace("%SITENAME%", "", $noRepl); $noRepl = str_ireplace("%URL%", "", $noRepl);
|
234 |
-
$noRepl = str_ireplace("%SURL%", "", $noRepl);$noRepl = str_ireplace("%TEXT%", "", $noRepl);$noRepl = str_ireplace("%FULLTEXT%", "", $noRepl);
|
235 |
-
$noRepl = str_ireplace("%AUTHORNAME%", "", $noRepl); $twLim = $twLim - strlen($noRepl);
|
236 |
|
237 |
$pTitle = $title = $post->post_title;
|
238 |
if ($post->post_excerpt!="") $pText = apply_filters('the_content', $post->post_excerpt); else $pText= apply_filters('the_content', $post->post_content);
|
@@ -246,9 +255,9 @@ if (!function_exists("nxs_doPublishToPK")) { //## Second Function to Post to TR
|
|
246 |
if (stripos($twMsgFormat, '%SITENAME%')!==false) {
|
247 |
$siteTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); $siteTitle = nsTrnc($siteTitle, $twLim); $twMsgFormat = str_ireplace("%SITENAME%", $siteTitle, $twMsgFormat); $twLim = $twLim - strlen($siteTitle);
|
248 |
}
|
249 |
-
if (stripos($twMsgFormat, '%
|
250 |
$pText = nsTrnc(strip_tags(strip_shortcodes($pText)), 300, " ", "...");
|
251 |
-
$pText = nsTrnc($pText, $twLim); $twMsgFormat = str_ireplace("%
|
252 |
}
|
253 |
if (stripos($twMsgFormat, '%FULLTEXT%')!==false) {
|
254 |
$pFullText = nsTrnc(strip_tags($pFullText), $twLim); $twMsgFormat = str_ireplace("%FULLTEXT%", $pFullText, $twMsgFormat); $twLim = $twLim - strlen($pFullText);
|
@@ -269,15 +278,15 @@ if (!function_exists("nxs_doPublishToPK")) { //## Second Function to Post to TR
|
|
269 |
if ($options['attchImg']=='1') { $imgURL = nxs_getPostImage($postID); $msg .= " ".$imgURL; }
|
270 |
|
271 |
$postDate = ($post->post_date_gmt!='0000-00-00 00:00:00'?$post->post_date_gmt:gmdate("Y-m-d H:i:s", strtotime($post->post_date)))." GMT"; //## Adds date to Tumblr post. Thanks to Kenneth Lecky
|
272 |
-
|
273 |
$postArr = array('content'=>$msg, 'qualifier'=>$options['pkCat']);
|
274 |
$postinfo = $tum_oauth->makeReq('http://www.plurk.com/APP/Timeline/plurkAdd', $postArr); // prr($postinfo);
|
275 |
if (is_array($postinfo) && isset($postinfo['plurk_id'])) $pkID = $postinfo['plurk_id'];
|
276 |
|
277 |
$code = $tum_oauth->http_code;// echo "XX".print_r($code); prr($postinfo); // prr($msg); prr($postinfo); echo $code."VVVV"; die("|====");
|
278 |
-
if ($code == 200) { if ($postID=='0') {
|
279 |
-
else {
|
280 |
-
else {
|
281 |
|
282 |
return $code;
|
283 |
}
|
54 |
<?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = str_ireplace('https://','', str_ireplace('http://','', $pbo['pkURL']));
|
55 |
if (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='') $pbo[$ntInfo['lcode'].'OK'] = (isset($pbo['pkOAuthTokenSecret']) && $pbo['pkOAuthTokenSecret']!='')?'1':''; ?>
|
56 |
<p style="margin:0px;margin-left:5px;">
|
57 |
+
<input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> /> <?php if ((int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
|
58 |
<strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
|
59 |
<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'nxs_snap'); ?> ==></b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>
|
60 |
<a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
|
104 |
|
105 |
<div style="width:100%;"><strong id="altFormatText"><?php _e('Post Text Format', 'nxs_snap'); ?>:</strong> (<a href="#" id="apPKMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apPKMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>) </div>
|
106 |
|
107 |
+
<textarea cols="150" rows="3" id="pk<?php echo $ii; ?>SNAPformat" name="pk[<?php echo $ii; ?>][apPKMsgFrmt]" style="width:51%;max-width: 650px;" onfocus="jQuery('#pk<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('apPKMsgFrmt<?php echo $ii; ?>');"><?php if ($options['pkMsgFormat']!='') _e(apply_filters('format_to_edit', htmlentities($options['pkMsgFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap'); else echo htmlentities("%TITLE% - %URL%"); ?></textarea>
|
108 |
+
|
109 |
+
<br/>
|
110 |
<?php nxs_doShowHint("apPKMsgFrmt".$ii); ?>
|
111 |
<br/>
|
112 |
<?php
|
165 |
?>
|
166 |
|
167 |
<tr><th style="text-align:left;" colspan="2"><?php if ( $options['catSel']=='1' && trim($options['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_PK<?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" /> <?php } ?>
|
168 |
+
<?php if ($isAvailPK) { ?><input class="nxsGrpDoChb" value="1" id="doPK<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="pk[<?php echo $ii; ?>][doPK]" <?php if ((int)$doPK == 1) echo 'checked="checked" title="def"'; ?> />
|
169 |
+
<?php if ($post->post_status == "publish") { ?> <input type="hidden" name="pk[<?php echo $ii; ?>][doPK]" value="<?php echo $doPK;?>"> <?php } ?> <?php } ?>
|
170 |
<div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/pk16.png);">Plurk - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $options['nName']; ?></i>) </div></th><td><?php //## Only show RePost button if the post is "published"
|
171 |
if ($post->post_status == "publish" && $isAvailPK) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToPK_repostButton" id="rePostToPK_button" value="<?php _e('Repost to Plurk', 'nxs_snap') ?>" />
|
172 |
<?php wp_nonce_field( 'rePostToPK', 'rePostToPK_wpnonce' ); } ?>
|
191 |
?>
|
192 |
</select></td></tr>
|
193 |
|
194 |
+
<tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top:6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Text Format:', 'nxs_snap') ?></th>
|
195 |
+
<td>
|
196 |
+
<textarea cols="150" rows="1" id="pk<?php echo $ii; ?>SNAPformat" name="pk[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('#pk<?php echo $ii; ?>SNAPformat').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apPKMsgFrmt<?php echo $ii; ?>');"><?php echo $pkMsgFormat; ?></textarea>
|
197 |
+
<?php nxs_doShowHint("apPKMsgFrmt".$ii); ?></td></tr>
|
198 |
|
199 |
<?php }
|
200 |
}
|
221 |
|
222 |
if (!function_exists("nxs_doPublishToPK")) { //## Second Function to Post to TR
|
223 |
function nxs_doPublishToPK($postID, $options){ $ntCd = 'PK'; $ntCdL = 'pk'; $ntNm = 'Plurk';
|
224 |
+
//if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToPK', array($postID, $options));
|
225 |
$blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url();
|
226 |
|
227 |
+
$ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
|
228 |
+
$logNT = '<span style="color:#014A76">Plurk</span> - '.$options['nName'];
|
229 |
+
$snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
|
230 |
if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
|
231 |
+
$snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') { sleep(5);
|
232 |
+
nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$uqID); return;
|
233 |
+
}
|
234 |
}
|
235 |
//## Format
|
236 |
if ($postID=='0') { echo "Testing ... <br/><br/>"; $msg = 'Test Post from '.$blogTitle; $msgT = 'Test Post from '.$blogTitle;}
|
237 |
else{ $post = get_post($postID); if(!$post) return; $twMsgFormat = $options['pkMsgFormat']; nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1')); $twLim = 180;
|
238 |
+
$extInfo = ' | PostID: '.$postID." - ".$post->post_title;
|
239 |
if (stripos($twMsgFormat, '%URL%')!==false || stripos($twMsgFormat, '%SURL%')!==false) $twLim = $twLim - 5;
|
240 |
if (stripos($twMsgFormat, '%AUTHORNAME%')!==false) { $aun = $post->post_author; $aun = get_the_author_meta('display_name', $aun ); $twLim = $twLim - strlen($aun); }
|
241 |
|
242 |
+
$noRepl = str_ireplace("%TITLE%", "", $twMsgFormat); $noRepl = str_ireplace("%SITENAME%", "", $noRepl); $noRepl = str_ireplace("%URL%", "", $noRepl);$noRepl = str_ireplace("%RAWEXCERPT%", "", $noRepl);
|
243 |
+
$noRepl = str_ireplace("%SURL%", "", $noRepl);$noRepl = str_ireplace("%TEXT%", "", $noRepl);$noRepl = str_ireplace("%FULLTEXT%", "", $noRepl);$noRepl = str_ireplace("%EXCERPT%", "", $noRepl);
|
244 |
+
$noRepl = str_ireplace("%ANNOUNCE%", "", $noRepl); $noRepl = str_ireplace("%AUTHORNAME%", "", $noRepl); $twLim = $twLim - strlen($noRepl);
|
245 |
|
246 |
$pTitle = $title = $post->post_title;
|
247 |
if ($post->post_excerpt!="") $pText = apply_filters('the_content', $post->post_excerpt); else $pText= apply_filters('the_content', $post->post_content);
|
255 |
if (stripos($twMsgFormat, '%SITENAME%')!==false) {
|
256 |
$siteTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); $siteTitle = nsTrnc($siteTitle, $twLim); $twMsgFormat = str_ireplace("%SITENAME%", $siteTitle, $twMsgFormat); $twLim = $twLim - strlen($siteTitle);
|
257 |
}
|
258 |
+
if (stripos($twMsgFormat, '%EXCERPT%')!==false) {
|
259 |
$pText = nsTrnc(strip_tags(strip_shortcodes($pText)), 300, " ", "...");
|
260 |
+
$pText = nsTrnc($pText, $twLim); $twMsgFormat = str_ireplace("%EXCERPT%", $pText, $twMsgFormat); $twLim = $twLim - strlen($pText);
|
261 |
}
|
262 |
if (stripos($twMsgFormat, '%FULLTEXT%')!==false) {
|
263 |
$pFullText = nsTrnc(strip_tags($pFullText), $twLim); $twMsgFormat = str_ireplace("%FULLTEXT%", $pFullText, $twMsgFormat); $twLim = $twLim - strlen($pFullText);
|
278 |
if ($options['attchImg']=='1') { $imgURL = nxs_getPostImage($postID); $msg .= " ".$imgURL; }
|
279 |
|
280 |
$postDate = ($post->post_date_gmt!='0000-00-00 00:00:00'?$post->post_date_gmt:gmdate("Y-m-d H:i:s", strtotime($post->post_date)))." GMT"; //## Adds date to Tumblr post. Thanks to Kenneth Lecky
|
281 |
+
|
282 |
$postArr = array('content'=>$msg, 'qualifier'=>$options['pkCat']);
|
283 |
$postinfo = $tum_oauth->makeReq('http://www.plurk.com/APP/Timeline/plurkAdd', $postArr); // prr($postinfo);
|
284 |
if (is_array($postinfo) && isset($postinfo['plurk_id'])) $pkID = $postinfo['plurk_id'];
|
285 |
|
286 |
$code = $tum_oauth->http_code;// echo "XX".print_r($code); prr($postinfo); // prr($msg); prr($postinfo); echo $code."VVVV"; die("|====");
|
287 |
+
if ($code == 200) { if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo 'OK - Message Posted, please see your Plurk Page. <br/> Result:'; }
|
288 |
+
else { nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); nxs_metaMarkAsPosted($postID, 'PK', $options['ii'], array('isPosted'=>'1', 'pgID'=>$pkID, 'pDate'=>date('Y-m-d H:i:s'))); } }
|
289 |
+
else { nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($postinfo, true), $extInfo); if ($postID=='0') prr($postinfo); $code .= " ERROR: - ".$postinfo['error_text']; }
|
290 |
|
291 |
return $code;
|
292 |
}
|
inc-cl/pn.php
CHANGED
@@ -16,7 +16,7 @@ if (!class_exists("nxs_snapClassPN")) { class nxs_snapClassPN {
|
|
16 |
<?php if(!function_exists('doPostToPinterest')) {?> Pinterest doesn't have a built-in API for automated posts yet. <br/>You need to get a special <a target="_blank" href="http://www.nextscripts.com/pinterest-automated-posting">library module</a> to be able to publish your content to Pinterest.
|
17 |
<?php } else foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
|
18 |
<p style="margin:0px;margin-left:5px;">
|
19 |
-
<input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> />
|
20 |
<strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
|
21 |
<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'nxs_snap'); ?> ==></b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>
|
22 |
<a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
|
@@ -74,7 +74,9 @@ if (!class_exists("nxs_snapClassPN")) { class nxs_snapClassPN {
|
|
74 |
|
75 |
<div id="altFormat" style="">
|
76 |
<div style="width:100%;"><strong id="altFormatText"><?php _e('Message text Format', 'nxs_snap'); ?>:</strong> <a href="#" id="apPNMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apPNMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>
|
77 |
-
</div
|
|
|
|
|
78 |
|
79 |
<?php nxs_doShowHint("apPNMsgFrmt".$ii); ?>
|
80 |
</div><br/>
|
@@ -116,7 +118,8 @@ if (!class_exists("nxs_snapClassPN")) { class nxs_snapClassPN {
|
|
116 |
$isAvailPN = $ntOpt['pnUName']!='' && $ntOpt['pnPass']!=''; $pnMsgFormat = htmlentities($ntOpt['pnMsgFormat'], ENT_COMPAT, "UTF-8");
|
117 |
?>
|
118 |
<tr><th style="text-align:left;" colspan="2"><?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_PN<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
|
119 |
-
<?php if ($isAvailPN) { ?><input class="nxsGrpDoChb" value="1" id="doPN<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="pn[<?php echo $ii; ?>][doPN]" <?php if ((
|
|
|
120 |
<div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/pn16.png);">Pinterest - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
|
121 |
if ($post->post_status == "publish" && $isAvailPN) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToPN_repostButton" id="rePostToPN_button" value="<?php _e('Repost to Pinterest', 'nxs_snap') ?>" />
|
122 |
<?php wp_nonce_field( 'rePostToPN', 'rePostToPN_wpnonce' ); } ?>
|
@@ -140,8 +143,10 @@ if (!class_exists("nxs_snapClassPN")) { class nxs_snapClassPN {
|
|
140 |
</select></td>
|
141 |
</tr>
|
142 |
|
143 |
-
<tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;"><?php _e('Text Message Format:', 'nxs_snap') ?></th>
|
144 |
-
<td
|
|
|
|
|
145 |
|
146 |
<?php }
|
147 |
}
|
@@ -166,12 +171,17 @@ if (!function_exists("nxs_rePostToPN_ajax")) {
|
|
166 |
}
|
167 |
|
168 |
if (!function_exists("nxs_doPublishToPN")) { //## Second Function to Post to G+
|
169 |
-
function nxs_doPublishToPN($postID, $options){ global $nxs_gCookiesArr; $ntCd = 'PN'; $ntCdL = 'pn'; $ntNm = 'Pinterest';
|
170 |
-
|
171 |
-
|
|
|
|
|
|
|
172 |
$isAttachVid = $options['isAttachVid']; $isAttachVid = '1';
|
173 |
if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
|
174 |
-
|
|
|
|
|
175 |
}
|
176 |
$blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url();
|
177 |
|
@@ -185,16 +195,17 @@ if (!function_exists("nxs_doPublishToPN")) { //## Second Function to Post to G+
|
|
185 |
$email = $options['pnUName']; $boardID = $options['pnBoard']; $pass = substr($options['pnPass'], 0, 5)=='g9c1a'?nsx_doDecode(substr($options['pnPass'], 5)):$options['pnPass'];// prr($boardID); prr($_POST); die();
|
186 |
if (isset($options['pnSvC'])) $nxs_gCookiesArr = maybe_unserialize( $options['pnSvC']); $loginError = true;
|
187 |
if (is_array($nxs_gCookiesArr)) $loginError = doCheckPinterest();
|
188 |
-
$extInfo = ' | PostID: '.$postID." - ".$post->post_title;
|
189 |
-
if ($loginError!==false) $loginError = doConnectToPinterest($email, $pass); if ($loginError!==false) {echo $loginError;
|
190 |
if (serialize($nxs_gCookiesArr)!=$options['pnSvC']) { global $plgn_NS_SNAutoPoster; $gOptions = $plgn_NS_SNAutoPoster->nxs_options; // prr($gOptions['pn']);
|
191 |
if (isset($options['ii']) && $options['ii']!=='') { $gOptions['pn'][$options['ii']]['pnSvC'] = serialize($nxs_gCookiesArr); update_option('NS_SNAutoPoster', $gOptions); }
|
192 |
else foreach ($gOptions['pn'] as $ii=>$gpn) { $result = array_diff($options, $gpn);
|
193 |
if (!is_array($result) || count($result)<1) { $gOptions['pn'][$ii]['pnSvC'] = serialize($nxs_gCookiesArr); update_option('NS_SNAutoPoster', $gOptions); break; }
|
194 |
}
|
195 |
} // echo "PN SET:".$msg."|".$imgURL."|".$link."|".$boardID;
|
196 |
-
|
197 |
-
|
|
|
198 |
if ($ret['code']=='OK') return 200; else return $ret;
|
199 |
}
|
200 |
}
|
16 |
<?php if(!function_exists('doPostToPinterest')) {?> Pinterest doesn't have a built-in API for automated posts yet. <br/>You need to get a special <a target="_blank" href="http://www.nextscripts.com/pinterest-automated-posting">library module</a> to be able to publish your content to Pinterest.
|
17 |
<?php } else foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
|
18 |
<p style="margin:0px;margin-left:5px;">
|
19 |
+
<input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> /> <?php if ((int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
|
20 |
<strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
|
21 |
<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'nxs_snap'); ?> ==></b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>
|
22 |
<a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
|
74 |
|
75 |
<div id="altFormat" style="">
|
76 |
<div style="width:100%;"><strong id="altFormatText"><?php _e('Message text Format', 'nxs_snap'); ?>:</strong> <a href="#" id="apPNMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apPNMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>
|
77 |
+
</div>
|
78 |
+
|
79 |
+
<textarea cols="150" rows="3" id="pn<?php echo $ii; ?>SNAPformat" name="pn[<?php echo $ii; ?>][apPNMsgFrmt]" style="width:51%;max-width: 650px;" onfocus="jQuery('#pn<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('apPNMsgFrmt<?php echo $ii; ?>');"><?php if ($options['pnMsgFormat']!='') _e(apply_filters('format_to_edit', htmlentities($options['pnMsgFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap'); else echo "%TITLE% - %URL%"; ?></textarea>
|
80 |
|
81 |
<?php nxs_doShowHint("apPNMsgFrmt".$ii); ?>
|
82 |
</div><br/>
|
118 |
$isAvailPN = $ntOpt['pnUName']!='' && $ntOpt['pnPass']!=''; $pnMsgFormat = htmlentities($ntOpt['pnMsgFormat'], ENT_COMPAT, "UTF-8");
|
119 |
?>
|
120 |
<tr><th style="text-align:left;" colspan="2"><?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_PN<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
|
121 |
+
<?php if ($isAvailPN) { ?><input class="nxsGrpDoChb" value="1" id="doPN<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="pn[<?php echo $ii; ?>][doPN]" <?php if ((int)$doPN == 1) echo 'checked="checked" title="def"'; ?> />
|
122 |
+
<?php if ($post->post_status == "publish") { ?> <input type="hidden" name="pn[<?php echo $ii; ?>][doPN]" value="<?php echo $doPN;?>"> <?php } ?> <?php } ?>
|
123 |
<div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/pn16.png);">Pinterest - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
|
124 |
if ($post->post_status == "publish" && $isAvailPN) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToPN_repostButton" id="rePostToPN_button" value="<?php _e('Repost to Pinterest', 'nxs_snap') ?>" />
|
125 |
<?php wp_nonce_field( 'rePostToPN', 'rePostToPN_wpnonce' ); } ?>
|
143 |
</select></td>
|
144 |
</tr>
|
145 |
|
146 |
+
<tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top:6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Text Message Format:', 'nxs_snap') ?></th>
|
147 |
+
<td>
|
148 |
+
<textarea cols="150" rows="1" id="pn<?php echo $ii; ?>SNAPformat" name="pn[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('#pn<?php echo $ii; ?>SNAPformat').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apPNMsgFrmt<?php echo $ii; ?>');"><?php echo $pnMsgFormat; ?></textarea>
|
149 |
+
<?php nxs_doShowHint("apPNMsgFrmt".$ii); ?></td></tr>
|
150 |
|
151 |
<?php }
|
152 |
}
|
171 |
}
|
172 |
|
173 |
if (!function_exists("nxs_doPublishToPN")) { //## Second Function to Post to G+
|
174 |
+
function nxs_doPublishToPN($postID, $options){ global $nxs_gCookiesArr; $ntCd = 'PN'; $ntCdL = 'pn'; $ntNm = 'Pinterest';
|
175 |
+
// $backtrace = debug_backtrace(); nxs_addToLogN('W', 'Enter', $ntCd, 'I am here - '.$ntCd."|".print_r($backtrace, true), '');
|
176 |
+
//if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToPN', array($postID, $options));
|
177 |
+
$ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
|
178 |
+
$logNT = '<span style="color:#FA5069">Pinterest</span> - '.$options['nName'];
|
179 |
+
$snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
|
180 |
$isAttachVid = $options['isAttachVid']; $isAttachVid = '1';
|
181 |
if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
|
182 |
+
$snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') { sleep(5);
|
183 |
+
nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$uqID); return;
|
184 |
+
}
|
185 |
}
|
186 |
$blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url();
|
187 |
|
195 |
$email = $options['pnUName']; $boardID = $options['pnBoard']; $pass = substr($options['pnPass'], 0, 5)=='g9c1a'?nsx_doDecode(substr($options['pnPass'], 5)):$options['pnPass'];// prr($boardID); prr($_POST); die();
|
196 |
if (isset($options['pnSvC'])) $nxs_gCookiesArr = maybe_unserialize( $options['pnSvC']); $loginError = true;
|
197 |
if (is_array($nxs_gCookiesArr)) $loginError = doCheckPinterest();
|
198 |
+
$extInfo = ' | PostID: '.$postID." - ".$post->post_title;
|
199 |
+
if ($loginError!==false) $loginError = doConnectToPinterest($email, $pass); if ($loginError!==false) {echo $loginError; nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($loginError, true), $extInfo); return "BAD USER/PASS";}
|
200 |
if (serialize($nxs_gCookiesArr)!=$options['pnSvC']) { global $plgn_NS_SNAutoPoster; $gOptions = $plgn_NS_SNAutoPoster->nxs_options; // prr($gOptions['pn']);
|
201 |
if (isset($options['ii']) && $options['ii']!=='') { $gOptions['pn'][$options['ii']]['pnSvC'] = serialize($nxs_gCookiesArr); update_option('NS_SNAutoPoster', $gOptions); }
|
202 |
else foreach ($gOptions['pn'] as $ii=>$gpn) { $result = array_diff($options, $gpn);
|
203 |
if (!is_array($result) || count($result)<1) { $gOptions['pn'][$ii]['pnSvC'] = serialize($nxs_gCookiesArr); update_option('NS_SNAutoPoster', $gOptions); break; }
|
204 |
}
|
205 |
} // echo "PN SET:".$msg."|".$imgURL."|".$link."|".$boardID;
|
206 |
+
if (preg_match ( '/\$(\d+\.\d+)/', $msg, $matches )) $price = $matches[0];
|
207 |
+
$ret = doPostToPinterest($msg, $imgURL, $link, $boardID, 'TITLE WHERE IS IT?', $price, $link."/GTH/" ); if ($ret=='OK') $ret = array("code"=>"OK", "post_id"=>'');
|
208 |
+
if ( (!is_array($ret)) && $ret!='OK') { if ($postID=='0') echo $ret; nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo); } else { if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo 'OK - Message Posted, please see your Pinterest Page'; } else { nxs_metaMarkAsPosted($postID, 'PN', $options['ii'], array('isPosted'=>'1', 'pgID'=>$ret['post_id'], 'pDate'=>date('Y-m-d H:i:s'))); nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo);} }
|
209 |
if ($ret['code']=='OK') return 200; else return $ret;
|
210 |
}
|
211 |
}
|
inc-cl/su.php
CHANGED
@@ -15,7 +15,7 @@ if (!class_exists("nxs_snapClassSU")) { class nxs_snapClassSU {
|
|
15 |
<div class="nxs_box_inside">
|
16 |
<?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
|
17 |
<p style="margin:0px;margin-left:5px;">
|
18 |
-
<input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> />
|
19 |
<strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
|
20 |
<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'nxs_snap'); ?> ==></b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>
|
21 |
<a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
|
@@ -70,7 +70,11 @@ if (!class_exists("nxs_snapClassSU")) { class nxs_snapClassSU {
|
|
70 |
|
71 |
<div id="altFormat" style="">
|
72 |
<div style="width:100%;"><strong id="altFormatText"><?php _e('Post Text Format', 'nxs_snap'); ?></strong> (<a href="#" id="apSUMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apSUMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)</div>
|
73 |
-
|
|
|
|
|
|
|
|
|
74 |
</div><br/>
|
75 |
|
76 |
<?php if ($options['suPass']!='') { ?>
|
@@ -109,7 +113,8 @@ if (!class_exists("nxs_snapClassSU")) { class nxs_snapClassSU {
|
|
109 |
$isAvailSU = $ntOpt['suUName']!='' && $ntOpt['suPass']!=''; $suMsgFormat = htmlentities($ntOpt['suMsgFormat'], ENT_COMPAT, "UTF-8"); $suMsgTFormat = htmlentities($ntOpt['suMsgTFormat'], ENT_COMPAT, "UTF-8");
|
110 |
?>
|
111 |
<tr><th style="text-align:left;" colspan="2"><?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_SU<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
|
112 |
-
<?php if ($isAvailSU) { ?><input class="nxsGrpDoChb" value="1" id="doSU<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="su[<?php echo $ii; ?>][doSU]" <?php if ((
|
|
|
113 |
|
114 |
<div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/su16.png);">StumbleUpon - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
|
115 |
if ($post->post_status == "publish" && $isAvailSU) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToSU_repostButton" id="rePostToSU_button" value="<?php _e('Repost to StumbleUpon', 'nxs_snap') ?>" />
|
@@ -128,16 +133,17 @@ if (!class_exists("nxs_snapClassSU")) { class nxs_snapClassSU {
|
|
128 |
<tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;">Category:</th>
|
129 |
<td><div id="altFormat" style="">
|
130 |
<select name="su[<?php echo $ii; ?>][apSUCat]" id="apSUCat<?php echo $ii; ?>"><option value="error" selected="selected" disabled="">Select default StumbleUpon Category</option>
|
131 |
-
<?php $suCats = $this->suCats();
|
132 |
-
if ($ntOpt['suCat']!='') $suCats = str_replace(
|
133 |
-
|
134 |
?>
|
135 |
</select> <input value="1" id="sunsfw<?php echo $ii; ?>" type="checkbox" name="su[<?php echo $ii; ?>][nsfw]" <?php if ((int)$options['nsfw'] == 1) echo "checked"; ?> /> <strong>NSFW</strong>
|
136 |
|
137 |
</div> </td></tr>
|
138 |
|
139 |
-
<tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;"><?php _e('Text Format:', 'nxs_snap') ?></th>
|
140 |
-
<td
|
|
|
|
|
141 |
<?php }
|
142 |
}
|
143 |
}
|
@@ -182,7 +188,7 @@ if (!function_exists("nxs_doCheckSU")) {function nxs_doCheckSU(){ global $nxs_su
|
|
182 |
return false;
|
183 |
}}
|
184 |
if (!function_exists("nxs_doConnectToSU")) { function nxs_doConnectToSU($u, $p){ global $nxs_suCkArray; $hdrsArr = nxs_getSUHeaders('https://www.stumbleupon.com/login', true); // echo "LOGGIN";
|
185 |
-
$response = wp_remote_get('https://www.stumbleupon.com/login'); if (is_wp_error($response)) {
|
186 |
$contents = $response['body']; //$response['body'] = htmlentities($response['body']); prr($response); die();
|
187 |
$ckArr = $response['cookies'];
|
188 |
$frmTxt = CutFromTo($contents, '<form id="login-form"','</form>'); $md = array(); $flds = array();// prr($frmTxt);
|
@@ -211,20 +217,20 @@ if (!function_exists("nxs_doPostToSU")) { function nxs_doPostToSU($msg, $lnk, $
|
|
211 |
} $flds['url'] = $lnk; $flds['review'] = $msg; $flds['tags'] = $cat; $flds['nsfw'] = $nsfw?'true':'false'; $flds['user-tags'] = $tags; $flds['_output'] = 'Json'; $flds['_method'] = 'create'; $flds['language'] = 'EN';
|
212 |
|
213 |
$r2 = wp_remote_post('https://www.stumbleupon.com/submit', array('method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds, 'cookies' => $ckArr));
|
214 |
-
$resp = json_decode($r2['body'], true);
|
215 |
|
216 |
if (stripos($resp['_reason'][0]['message'], 'Failed to add URL')!==false) { sleep(5);
|
217 |
$r2 = wp_remote_post('https://www.stumbleupon.com/submit', array('method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds, 'cookies' => $ckArr));
|
218 |
-
$resp = json_decode($r2['body'], true);
|
219 |
}
|
220 |
|
221 |
if (stripos($resp['_error'], 'Invalid token')!==false) { // In case we got the Wrong Cookies
|
222 |
$r2 = wp_remote_post('https://www.stumbleupon.com/submit', array('method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds, 'cookies' => $ckArr2));
|
223 |
-
$resp = json_decode($r2['body'], true);
|
224 |
|
225 |
if (stripos($resp['_reason'][0]['message'], 'Failed to add URL')!==false) { sleep(5);
|
226 |
$r2 = wp_remote_post('https://www.stumbleupon.com/submit', array('method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds, 'cookies' => $ckArr2));
|
227 |
-
$resp = json_decode($r2['body'], true); // prr($flds); prr($resp); //
|
228 |
}
|
229 |
}
|
230 |
|
@@ -234,11 +240,16 @@ if (!function_exists("nxs_doPostToSU")) { function nxs_doPostToSU($msg, $lnk, $
|
|
234 |
}}
|
235 |
|
236 |
if (!function_exists("nxs_doPublishToSU")) { //## Second Function to Post to SU
|
237 |
-
function nxs_doPublishToSU($postID, $options){ global $nxs_suCkArray; $ntCd = 'SU'; $ntCdL = 'su'; $ntNm = 'StumbleUpon';
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
|
|
|
|
|
|
|
|
|
|
242 |
}
|
243 |
$suCat = $options['suCat'];
|
244 |
// if (function_exists("get_post_thumbnail_id") ){ $src = wp_get_attachment_image_src(get_post_thumbnail_id($postID), 'thumbnail'); $src = $src[0];}
|
@@ -247,7 +258,7 @@ if (!function_exists("nxs_doPublishToSU")) { //## Second Function to Post to SU
|
|
247 |
$msgFormat = $options['suMsgFormat']; $msg = nsFormatMessage($msgFormat, $postID); $link = get_permalink($postID); nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
|
248 |
}
|
249 |
$dusername = $options['suUName']; //$link = urlencode($link); $desc = urlencode(substr($msg, 0, 500));
|
250 |
-
$extInfo = ' | PostID: '.$postID." - ".$post->post_title;
|
251 |
if ($options['suInclTags']=='1') { $t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = urlencode(implode(',',$tggs)); $tags = str_replace(' ','+',$tags); } else $tags = '';
|
252 |
if (isset($options['suSvC'])) $nxs_suCkArray = maybe_unserialize( $options['suSvC']); $loginError = true;
|
253 |
if (is_array($nxs_suCkArray)) $loginError = nxs_doCheckSU(); if ($loginError!=false) $loginError = nxs_doConnectToSU($email, $pass);
|
@@ -257,15 +268,15 @@ if (!function_exists("nxs_doPublishToSU")) { //## Second Function to Post to SU
|
|
257 |
if (!is_array($result) || count($result)<1) { $gOptions['su'][$ii]['suSvC'] = serialize($nxs_suCkArray); update_option('NS_SNAutoPoster', $gOptions); break; }
|
258 |
}
|
259 |
}
|
260 |
-
if ($loginError!==false) {if ($postID=='0') prr($loginError);
|
261 |
|
262 |
$ret = nxs_doPostToSU($msg, $link, $options['suCat'], $tags, $options['nsfw']=='1'); // $extInfo .= "++".$msg."|".$link."|".$options['suCat']."|".$tags."|".$options['nsfw'];
|
263 |
if ($ret=='OK') $ret = array("code"=>"OK", "post_id"=>'');
|
264 |
-
if ( (!is_array($ret)) && $ret!='OK') { if ($postID=='0') prr($ret);
|
265 |
-
elseif ($ret['code']=='OK') if ($postID=='0') {
|
266 |
-
{ nxs_metaMarkAsPosted($postID, 'SU', $options['ii'], array('isPosted'=>'1', 'pgID'=>$ret['post_id'], 'pDate'=>date('Y-m-d H:i:s')));
|
267 |
else { if ($options['reset'] == '1') {
|
268 |
-
|
269 |
return "ERROR = ".print_r($ret, true);
|
270 |
} else { $options['reset'] = '1'; $options['suSvC'] = ''; return nxs_doPublishToSU($postID, $options); }
|
271 |
}
|
15 |
<div class="nxs_box_inside">
|
16 |
<?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
|
17 |
<p style="margin:0px;margin-left:5px;">
|
18 |
+
<input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> /> <?php if ((int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
|
19 |
<strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
|
20 |
<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'nxs_snap'); ?> ==></b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>
|
21 |
<a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
|
70 |
|
71 |
<div id="altFormat" style="">
|
72 |
<div style="width:100%;"><strong id="altFormatText"><?php _e('Post Text Format', 'nxs_snap'); ?></strong> (<a href="#" id="apSUMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apSUMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)</div>
|
73 |
+
|
74 |
+
<textarea cols="150" rows="3" id="su<?php echo $ii; ?>SNAPformat" name="su[<?php echo $ii; ?>][apSUMsgFrmt]" style="width:51%;max-width: 650px;" onfocus="jQuery('#su<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('apSUMsgFrmt<?php echo $ii; ?>');"><?php if ($isNew) echo "%TITLE% - %EXCERPT%"; else _e(apply_filters('format_to_edit', htmlentities($options['suMsgFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap'); ?></textarea>
|
75 |
+
|
76 |
+
|
77 |
+
<?php nxs_doShowHint("apSUMsgFrmt".$ii); ?>
|
78 |
</div><br/>
|
79 |
|
80 |
<?php if ($options['suPass']!='') { ?>
|
113 |
$isAvailSU = $ntOpt['suUName']!='' && $ntOpt['suPass']!=''; $suMsgFormat = htmlentities($ntOpt['suMsgFormat'], ENT_COMPAT, "UTF-8"); $suMsgTFormat = htmlentities($ntOpt['suMsgTFormat'], ENT_COMPAT, "UTF-8");
|
114 |
?>
|
115 |
<tr><th style="text-align:left;" colspan="2"><?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_SU<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
|
116 |
+
<?php if ($isAvailSU) { ?><input class="nxsGrpDoChb" value="1" id="doSU<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="su[<?php echo $ii; ?>][doSU]" <?php if ((int)$doSU == 1) echo 'checked="checked" title="def"'; ?> />
|
117 |
+
<?php if ($post->post_status == "publish") { ?> <input type="hidden" name="su[<?php echo $ii; ?>][doSU]" value="<?php echo $doSU;?>"> <?php } ?> <?php } ?>
|
118 |
|
119 |
<div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/su16.png);">StumbleUpon - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
|
120 |
if ($post->post_status == "publish" && $isAvailSU) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToSU_repostButton" id="rePostToSU_button" value="<?php _e('Repost to StumbleUpon', 'nxs_snap') ?>" />
|
133 |
<tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;">Category:</th>
|
134 |
<td><div id="altFormat" style="">
|
135 |
<select name="su[<?php echo $ii; ?>][apSUCat]" id="apSUCat<?php echo $ii; ?>"><option value="error" selected="selected" disabled="">Select default StumbleUpon Category</option>
|
136 |
+
<?php $suCats = $this->suCats();
|
137 |
+
if (isset($ntOpt['suCat']) && $ntOpt['suCat']!='') $suCats = str_replace('"'.$ntOpt['suCat'].'"', '"'.$ntOpt['suCat'].'" selected="selected"', $suCats); echo $suCats;
|
|
|
138 |
?>
|
139 |
</select> <input value="1" id="sunsfw<?php echo $ii; ?>" type="checkbox" name="su[<?php echo $ii; ?>][nsfw]" <?php if ((int)$options['nsfw'] == 1) echo "checked"; ?> /> <strong>NSFW</strong>
|
140 |
|
141 |
</div> </td></tr>
|
142 |
|
143 |
+
<tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top:6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Text Format:', 'nxs_snap') ?></th>
|
144 |
+
<td>
|
145 |
+
<textarea cols="150" rows="1" id="su<?php echo $ii; ?>SNAPformat" name="su[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('#su<?php echo $ii; ?>SNAPformat').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apSUMsgFrmt<?php echo $ii; ?>');"><?php echo $suMsgFormat; ?></textarea>
|
146 |
+
<?php nxs_doShowHint("apSUMsgFrmt".$ii); ?></td></tr>
|
147 |
<?php }
|
148 |
}
|
149 |
}
|
188 |
return false;
|
189 |
}}
|
190 |
if (!function_exists("nxs_doConnectToSU")) { function nxs_doConnectToSU($u, $p){ global $nxs_suCkArray; $hdrsArr = nxs_getSUHeaders('https://www.stumbleupon.com/login', true); // echo "LOGGIN";
|
191 |
+
$response = wp_remote_get('https://www.stumbleupon.com/login'); if (is_wp_error($response)) { nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($response, true), ''); return "Connection ERROR. Please see log";}
|
192 |
$contents = $response['body']; //$response['body'] = htmlentities($response['body']); prr($response); die();
|
193 |
$ckArr = $response['cookies'];
|
194 |
$frmTxt = CutFromTo($contents, '<form id="login-form"','</form>'); $md = array(); $flds = array();// prr($frmTxt);
|
217 |
} $flds['url'] = $lnk; $flds['review'] = $msg; $flds['tags'] = $cat; $flds['nsfw'] = $nsfw?'true':'false'; $flds['user-tags'] = $tags; $flds['_output'] = 'Json'; $flds['_method'] = 'create'; $flds['language'] = 'EN';
|
218 |
|
219 |
$r2 = wp_remote_post('https://www.stumbleupon.com/submit', array('method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds, 'cookies' => $ckArr));
|
220 |
+
$resp = json_decode($r2['body'], true);
|
221 |
|
222 |
if (stripos($resp['_reason'][0]['message'], 'Failed to add URL')!==false) { sleep(5);
|
223 |
$r2 = wp_remote_post('https://www.stumbleupon.com/submit', array('method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds, 'cookies' => $ckArr));
|
224 |
+
$resp = json_decode($r2['body'], true);
|
225 |
}
|
226 |
|
227 |
if (stripos($resp['_error'], 'Invalid token')!==false) { // In case we got the Wrong Cookies
|
228 |
$r2 = wp_remote_post('https://www.stumbleupon.com/submit', array('method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds, 'cookies' => $ckArr2));
|
229 |
+
$resp = json_decode($r2['body'], true);
|
230 |
|
231 |
if (stripos($resp['_reason'][0]['message'], 'Failed to add URL')!==false) { sleep(5);
|
232 |
$r2 = wp_remote_post('https://www.stumbleupon.com/submit', array('method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds, 'cookies' => $ckArr2));
|
233 |
+
$resp = json_decode($r2['body'], true); // prr($flds); prr($resp); //nxs_addToLogN('SU', 'E', '-=DBG=- '.print_r($resp, true)." - #####", $extInfo);
|
234 |
}
|
235 |
}
|
236 |
|
240 |
}}
|
241 |
|
242 |
if (!function_exists("nxs_doPublishToSU")) { //## Second Function to Post to SU
|
243 |
+
function nxs_doPublishToSU($postID, $options){ global $nxs_suCkArray; $ntCd = 'SU'; $ntCdL = 'su'; $ntNm = 'StumbleUpon';
|
244 |
+
//$backtrace = debug_backtrace(); nxs_addToLogN('W', 'Enter', $ntCd, 'I am here - '.$ntCd."|".print_r($backtrace, true), '');
|
245 |
+
//if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToSU', array($postID, $options));
|
246 |
+
$ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
|
247 |
+
$logNT = '<span style="color:#000080">StumbleUpon</span> - '.$options['nName'];
|
248 |
+
$snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
|
249 |
+
if ($options['reset'] != '1' && $options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
|
250 |
+
$snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') { sleep(5);
|
251 |
+
nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$uqID); return;
|
252 |
+
}
|
253 |
}
|
254 |
$suCat = $options['suCat'];
|
255 |
// if (function_exists("get_post_thumbnail_id") ){ $src = wp_get_attachment_image_src(get_post_thumbnail_id($postID), 'thumbnail'); $src = $src[0];}
|
258 |
$msgFormat = $options['suMsgFormat']; $msg = nsFormatMessage($msgFormat, $postID); $link = get_permalink($postID); nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
|
259 |
}
|
260 |
$dusername = $options['suUName']; //$link = urlencode($link); $desc = urlencode(substr($msg, 0, 500));
|
261 |
+
$extInfo = ' | PostID: '.$postID." - ".$post->post_title;
|
262 |
if ($options['suInclTags']=='1') { $t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = urlencode(implode(',',$tggs)); $tags = str_replace(' ','+',$tags); } else $tags = '';
|
263 |
if (isset($options['suSvC'])) $nxs_suCkArray = maybe_unserialize( $options['suSvC']); $loginError = true;
|
264 |
if (is_array($nxs_suCkArray)) $loginError = nxs_doCheckSU(); if ($loginError!=false) $loginError = nxs_doConnectToSU($email, $pass);
|
268 |
if (!is_array($result) || count($result)<1) { $gOptions['su'][$ii]['suSvC'] = serialize($nxs_suCkArray); update_option('NS_SNAutoPoster', $gOptions); break; }
|
269 |
}
|
270 |
}
|
271 |
+
if ($loginError!==false) {if ($postID=='0') prr($loginError); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($loginError, true)." - BAD USER/PASS", $extInfo); return " -= BAD USER/PASS =- ";}
|
272 |
|
273 |
$ret = nxs_doPostToSU($msg, $link, $options['suCat'], $tags, $options['nsfw']=='1'); // $extInfo .= "++".$msg."|".$link."|".$options['suCat']."|".$tags."|".$options['nsfw'];
|
274 |
if ($ret=='OK') $ret = array("code"=>"OK", "post_id"=>'');
|
275 |
+
if ( (!is_array($ret)) && $ret!='OK') { if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);}
|
276 |
+
elseif ($ret['code']=='OK') if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo ' OK - Message Posted, please see your StumbleUpon Page '; } else
|
277 |
+
{ nxs_metaMarkAsPosted($postID, 'SU', $options['ii'], array('isPosted'=>'1', 'pgID'=>$ret['post_id'], 'pDate'=>date('Y-m-d H:i:s'))); nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); return 200; }
|
278 |
else { if ($options['reset'] == '1') {
|
279 |
+
nxs_addToLogN('E', 'Error', $logNT, '-=ERROR TRY #2=- '.print_r($ret, true), $extInfo.$options['reset']);
|
280 |
return "ERROR = ".print_r($ret, true);
|
281 |
} else { $options['reset'] = '1'; $options['suSvC'] = ''; return nxs_doPublishToSU($postID, $options); }
|
282 |
}
|
inc-cl/tr.php
CHANGED
@@ -44,7 +44,7 @@ if (!class_exists("nxs_snapClassTR")) { class nxs_snapClassTR {
|
|
44 |
<?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = str_ireplace('https://','', str_ireplace('http://','', $pbo['trURL']));
|
45 |
if (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='') $pbo[$ntInfo['lcode'].'OK'] = (isset($pbo['trOAuthTokenSecret']) && $pbo['trOAuthTokenSecret']!='')?'1':''; ?>
|
46 |
<p style="margin:0px;margin-left:5px;">
|
47 |
-
<input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> />
|
48 |
<strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
|
49 |
<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'nxs_snap'); ?> ==></b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>
|
50 |
<a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
|
@@ -54,7 +54,7 @@ if (!class_exists("nxs_snapClassTR")) { class nxs_snapClassTR {
|
|
54 |
</div> <?php
|
55 |
}
|
56 |
//#### Show NEW Settings Page
|
57 |
-
function showNewNTSettings($bo){ $po = array('nName'=>'', 'doTR'=>'1', 'trURL'=>'', 'trPgID'=>'', 'trConsKey'=>'', 'trInclTags'=>'1', 'cImgURL'=>'R', 'trConsSec'=>'', 'trPostType'=>'T', 'trDefImg'=>'', 'trOAuthTokenSecret'=>'', 'trAccessTocken'=>'', 'trMsgFormat'=>'<p>New Post has been published on %URL%</p><blockquote><p><strong>%TITLE%</strong></p><p><img src=\'%IMG%\'/></p><p>%FULLTEXT%</p></blockquote>', 'trMsgTFormat'=>'New Post has been published on %SITENAME%' ); $this->showNTSettings($bo, $po, true);}
|
58 |
//#### Show Unit Settings
|
59 |
function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl,$nxs_snapThisPageUrl; ?>
|
60 |
<div id="doTR<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>" style="background-image: url(<?php echo $nxs_plurl; ?>img/tr-bg.png); background-position:90% 10%;"> <input type="hidden" name="apDoSTR<?php echo $ii; ?>" value="0" id="apDoSTR<?php echo $ii; ?>" />
|
@@ -74,9 +74,9 @@ if (!class_exists("nxs_snapClassTR")) { class nxs_snapClassTR {
|
|
74 |
<br/>
|
75 |
<?php } ?>
|
76 |
|
77 |
-
<div style="width:100%;"><strong>
|
78 |
-
<div style="width:100%;"><strong>
|
79 |
-
<div style="width:100%;"><strong>
|
80 |
<br/>
|
81 |
|
82 |
<div style="width:100%;"><strong id="altFormatText">Default Post Type:</strong></div>
|
@@ -84,12 +84,13 @@ if (!class_exists("nxs_snapClassTR")) { class nxs_snapClassTR {
|
|
84 |
|
85 |
<input type="radio" name="tr[<?php echo $ii; ?>][apTRPostType]" value="T" <?php if ($options['trPostType'] != 'I') echo 'checked="checked"'; ?> onchange="nxs_TRSetEnable('T','<?php echo $ii; ?>');" /> Text Post<br/>
|
86 |
|
87 |
-
<div style="width:100%; margin-left: 15px;"><strong id="altFormatText"
|
88 |
<input name="tr[<?php echo $ii; ?>][apTRMsgTFrmt]" id="apTRMsgTFrmt<?php echo $ii; ?>" style="margin-left: 15px; width: 50%;" value="<?php if ($options['trMsgTFormat']!='') _e(apply_filters('format_to_edit', htmlentities($options['trMsgTFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap'); else echo "New Post has been published on %SITENAME%"; ?>" onfocus="jQuery('#apTRTMsgFrmt<?php echo $ii; ?>Hint').show();" <?php if ($options['trPostType'] == 'I') echo 'disabled="disabled"'; ?> /><br/>
|
89 |
<?php nxs_doShowHint("apTRTMsgFrmt".$ii); ?>
|
90 |
</div>
|
91 |
|
92 |
-
<input type="radio" name="tr[<?php echo $ii; ?>][apTRPostType]" value="I" <?php if ($options['trPostType'] == 'I') echo 'checked="checked"'; ?> onchange="nxs_TRSetEnable('I','<?php echo $ii; ?>');"/> Image Post
|
|
|
93 |
|
94 |
<div style="width:100%; margin-left: 15px;">
|
95 |
|
@@ -98,10 +99,7 @@ if (!class_exists("nxs_snapClassTR")) { class nxs_snapClassTR {
|
|
98 |
<input type="radio" name="tr[<?php echo $ii; ?>][cImgURL]" value="R" <?php if ( !isset($options['cImgURL']) || $options['cImgURL'] == '' || $options['cImgURL'] == 'R') echo 'checked="checked"'; ?> /> Regular Post URL
|
99 |
<input type="radio" name="tr[<?php echo $ii; ?>][cImgURL]" value="S" <?php if ($options['cImgURL'] == 'S') echo 'checked="checked"'; ?> /> Shortened Post URL
|
100 |
<input type="radio" name="tr[<?php echo $ii; ?>][cImgURL]" value="N" <?php if ($options['cImgURL'] == 'N') echo 'checked="checked"'; ?> /> No Clickthrough URL
|
101 |
-
</p>
|
102 |
-
|
103 |
-
|
104 |
-
<strong>Defailt Image to Post:</strong>
|
105 |
<p style="font-size: 11px; margin: 0px;">If your post is missing "Featured Image" and doesn't have any images in the text body this will be used instead.</p>
|
106 |
</div><input name="tr[<?php echo $ii; ?>][apTRDefImg]" id="apTRDefImg<?php echo $ii; ?>" style=" margin-left: 15px; width: 30%;" <?php if ($options['trPostType'] != 'I') echo 'disabled="disabled"'; ?> value="<?php _e(apply_filters('format_to_edit', htmlentities($options['trDefImg'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
|
107 |
<br/>
|
@@ -114,12 +112,17 @@ if (!class_exists("nxs_snapClassTR")) { class nxs_snapClassTR {
|
|
114 |
|
115 |
<div style="width:100%;"><strong id="altFormatText"><?php _e('Post Text Format', 'nxs_snap'); ?>:</strong> (<a href="#" id="apTRMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apTRMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>) </div>
|
116 |
|
117 |
-
|
|
|
|
|
|
|
118 |
<?php nxs_doShowHint("apTRMsgFrmt".$ii); ?>
|
119 |
|
120 |
|
121 |
<p style="margin-bottom: 20px;margin-top: 5px;"><input value="1" id="trInclTags" type="checkbox" name="tr[<?php echo $ii; ?>][trInclTags]" <?php if ((int)$options['trInclTags'] == 1) echo "checked"; ?> />
|
122 |
-
<strong>Post with tags
|
|
|
|
|
123 |
</p>
|
124 |
|
125 |
<?php
|
@@ -153,6 +156,7 @@ if (!class_exists("nxs_snapClassTR")) { class nxs_snapClassTR {
|
|
153 |
$trPgID = $options[$ii]['trURL']; if (substr($trPgID, -1)=='/') $trPgID = substr($trPgID, 0, -1); $trPgID = substr(strrchr($trPgID, "/"), 1);
|
154 |
$options[$ii]['trPgID'] = $trPgID; //echo $fbPgID;
|
155 |
}
|
|
|
156 |
if (isset($pval['apDoTR'])) $options[$ii]['doTR'] = $pval['apDoTR']; else $options[$ii]['doTR'] = 0;
|
157 |
if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']);
|
158 |
if (isset($pval['apTRConsKey'])) $options[$ii]['trConsKey'] = trim($pval['apTRConsKey']);
|
@@ -160,6 +164,7 @@ if (!class_exists("nxs_snapClassTR")) { class nxs_snapClassTR {
|
|
160 |
if (isset($pval['apTRMsgFrmt'])) $options[$ii]['trMsgFormat'] = trim($pval['apTRMsgFrmt']);
|
161 |
if (isset($pval['apTRMsgTFrmt'])) $options[$ii]['trMsgTFormat'] = trim($pval['apTRMsgTFrmt']);
|
162 |
if (isset($pval['trInclTags'])) $options[$ii]['trInclTags'] = $pval['trInclTags']; else $options[$ii]['trInclTags'] = 0;
|
|
|
163 |
if (isset($pval['apTRPostType'])) $options[$ii]['trPostType'] = trim($pval['apTRPostType']);
|
164 |
if (isset($pval['cImgURL'])) $options[$ii]['cImgURL'] = trim($pval['cImgURL']);
|
165 |
|
@@ -181,7 +186,8 @@ if (!class_exists("nxs_snapClassTR")) { class nxs_snapClassTR {
|
|
181 |
?>
|
182 |
|
183 |
<tr><th style="text-align:left;" colspan="2"><?php if ( $options['catSel']=='1' && trim($options['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_TR<?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" /> <?php } ?>
|
184 |
-
<?php if ($isAvailTR) { ?><input class="nxsGrpDoChb" value="1" id="doTR<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="tr[<?php echo $ii; ?>][doTR]" <?php if ((
|
|
|
185 |
<div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/tr16.png);">Tumblr - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $options['nName']; ?></i>) </div></th><td><?php //## Only show RePost button if the post is "published"
|
186 |
if ($post->post_status == "publish" && $isAvailTR) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;"Z type="button" class="button" name="rePostToTR_repostButton" id="rePostToTR_button" value="<?php _e('Repost to Tumblr', 'nxs_snap') ?>" />
|
187 |
<?php wp_nonce_field( 'rePostToTR', 'rePostToTR_wpnonce' ); } ?>
|
@@ -209,8 +215,10 @@ if (!class_exists("nxs_snapClassTR")) { class nxs_snapClassTR {
|
|
209 |
<input type="radio" name="tr[<?php echo $ii; ?>][apTRPostType]" value="U" <?php if ($options['trPostType'] == 'U') echo 'checked="checked"'; ?> /> <b>Audio Post</b> <?php nxs_doShowHint("apTRTMsgFrmt".$ii); ?>
|
210 |
</td></tr>
|
211 |
|
212 |
-
<tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;"><?php _e('Text Format:', 'nxs_snap') ?></th>
|
213 |
-
<td
|
|
|
|
|
214 |
|
215 |
<?php }
|
216 |
}
|
@@ -228,7 +236,7 @@ if (!class_exists("nxs_snapClassTR")) { class nxs_snapClassTR {
|
|
228 |
}
|
229 |
}}
|
230 |
|
231 |
-
if (!function_exists("nxs_rePostToTR_ajax")) { function nxs_rePostToTR_ajax() { check_ajax_referer('rePostToTR'); $postID = $_POST['id'];
|
232 |
$options = get_option('NS_SNAutoPoster'); foreach ($options['tr'] as $ii=>$po) if ($ii==$_POST['nid']) { $po['ii'] = $ii; $po['pType'] = 'aj';
|
233 |
$mpo = get_post_meta($postID, 'snapTR', true); $mpo = maybe_unserialize($mpo);
|
234 |
if (is_array($mpo) && isset($mpo[$ii]) && is_array($mpo[$ii]) ){ $ntClInst = new nxs_snapClassTR(); $po = $ntClInst->adjMetaOpt($po, $mpo[$ii]); }
|
@@ -238,13 +246,16 @@ if (!function_exists("nxs_rePostToTR_ajax")) { function nxs_rePostToTR_ajax() {
|
|
238 |
}
|
239 |
|
240 |
if (!function_exists("nxs_doPublishToTR")) { //## Second Function to Post to TR
|
241 |
-
function nxs_doPublishToTR($postID, $options){ $ntCd = 'TR'; $ntCdL = 'tr'; $ntNm = 'Tumblr';
|
242 |
-
|
243 |
-
$blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url();
|
244 |
-
|
245 |
-
$
|
|
|
246 |
if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
|
247 |
-
|
|
|
|
|
248 |
}
|
249 |
//## Format
|
250 |
if ($postID=='0') { echo "Testing ... <br/><br/>"; $msg = 'Test Post from '.$blogTitle; $msgT = 'Test Post from '.$blogTitle; $options['trPostType']=='T';}
|
@@ -254,14 +265,16 @@ if (!function_exists("nxs_doPublishToTR")) { //## Second Function to Post to TR
|
|
254 |
//## Post
|
255 |
require_once('apis/trOAuth.php'); $consumer_key = $options['trConsKey']; $consumer_secret = $options['trConsSec'];
|
256 |
$tum_oauth = new TumblrOAuth($consumer_key, $consumer_secret, $options['trAccessTocken']['oauth_token'], $options['trAccessTocken']['oauth_token_secret']); //prr($options);
|
257 |
-
$trURL = trim(str_ireplace('http://', '', $options['trURL'])); if (substr($trURL,-1)=='/') $trURL = substr($trURL,0,-1);
|
258 |
-
if ($options['trInclTags']=='1'){$t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = implode(','
|
|
|
259 |
$postDate = ($post->post_date_gmt!='0000-00-00 00:00:00'?$post->post_date_gmt:gmdate("Y-m-d H:i:s", strtotime($post->post_date)))." GMT"; //## Adds date to Tumblr post. Thanks to Kenneth Lecky
|
260 |
-
$extInfo = ' | PostID: '.$postID." - ".$post->post_title
|
261 |
$postArr = array('tags'=>$tags, 'date'=>$postDate);
|
262 |
if($options['trPostType']=='V') { $vids = nsFindVidsInPost($post); if (count($vids)>0) $ytUrl = $vids[0]; if (trim($ytUrl)=='') $options['trPostType']='T'; }
|
263 |
if($options['trPostType']=='U') { $aud = nsFindAudioInPost($post); if (count($aud)>0) $aUrl = $aud[0]; if (trim($aUrl)=='') $options['trPostType']='T'; }
|
264 |
-
if
|
|
|
265 |
if (!isset($options['cImgURL']) || $options['cImgURL']=='' || $options['cImgURL']=='R' ) $postArr['link'] = get_permalink($postID);
|
266 |
elseif ($options['cImgURL']=='S' ) {$postArr['link'] = get_permalink($postID); $postArr['link'] = nxs_mkShortURL($postArr['link']);}
|
267 |
} elseif($options['trPostType']=='U') { $postArr['type'] = 'audio'; $postArr['caption'] = $msg; $postArr['external_url'] = $aUrl;
|
@@ -273,9 +286,9 @@ if (!function_exists("nxs_doPublishToTR")) { //## Second Function to Post to TR
|
|
273 |
$postinfo = $tum_oauth->post("http://api.tumblr.com/v2/blog/".$trURL."/post", $postArr); // prr($postinfo); prr($postArr);
|
274 |
|
275 |
$code = $postinfo->meta->status;// echo "XX".print_r($code); prr($postinfo); // prr($msg); prr($postinfo); echo $code."VVVV"; die("|====");
|
276 |
-
if ($code == 201) { if ($postID=='0') {
|
277 |
-
else {
|
278 |
-
else {
|
279 |
|
280 |
return $code;
|
281 |
}
|
44 |
<?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = str_ireplace('https://','', str_ireplace('http://','', $pbo['trURL']));
|
45 |
if (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='') $pbo[$ntInfo['lcode'].'OK'] = (isset($pbo['trOAuthTokenSecret']) && $pbo['trOAuthTokenSecret']!='')?'1':''; ?>
|
46 |
<p style="margin:0px;margin-left:5px;">
|
47 |
+
<input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> /> <?php if ((int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
|
48 |
<strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
|
49 |
<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'nxs_snap'); ?> ==></b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>
|
50 |
<a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
|
54 |
</div> <?php
|
55 |
}
|
56 |
//#### Show NEW Settings Page
|
57 |
+
function showNewNTSettings($bo){ $po = array('nName'=>'', 'doTR'=>'1', 'trURL'=>'', 'trPgID'=>'', 'trConsKey'=>'', 'trInclTags'=>'1', 'trInclCats'=>'0', 'cImgURL'=>'R', 'trConsSec'=>'', 'trPostType'=>'T', 'trDefImg'=>'', 'trOAuthTokenSecret'=>'', 'trAccessTocken'=>'', 'trMsgFormat'=>'<p>New Post has been published on %URL%</p><blockquote><p><strong>%TITLE%</strong></p><p><img src=\'%IMG%\'/></p><p>%FULLTEXT%</p></blockquote>', 'trMsgTFormat'=>'New Post has been published on %SITENAME%' ); $this->showNTSettings($bo, $po, true);}
|
58 |
//#### Show Unit Settings
|
59 |
function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl,$nxs_snapThisPageUrl; ?>
|
60 |
<div id="doTR<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>" style="background-image: url(<?php echo $nxs_plurl; ?>img/tr-bg.png); background-position:90% 10%;"> <input type="hidden" name="apDoSTR<?php echo $ii; ?>" value="0" id="apDoSTR<?php echo $ii; ?>" />
|
74 |
<br/>
|
75 |
<?php } ?>
|
76 |
|
77 |
+
<div style="width:100%;"><strong>Tumblr URL:</strong> <i>It should be your public URL. (i.e. like <b>http://nextscripts.tumblr.com/</b>, not http://www.tumblr.com/blog/nextscripts</i> </div><input onchange="nxsTRURLVal(<?php echo $ii; ?>);" name="tr[<?php echo $ii; ?>][apTRURL]" id="apTRURL<?php echo $ii; ?>" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['trURL'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /><span style="color: #F00000;" id="apTRURLerr<?php echo $ii; ?>"></span>
|
78 |
+
<div style="width:100%;"><strong>Tumblr OAuth Consumer Key:</strong> </div><input name="tr[<?php echo $ii; ?>][apTRConsKey]" id="apTRConsKey" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['trConsKey'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
|
79 |
+
<div style="width:100%;"><strong>Tumblr Secret Key:</strong> </div><input name="tr[<?php echo $ii; ?>][apTRConsSec]" id="apTRConsSec" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['trConsSec'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
|
80 |
<br/>
|
81 |
|
82 |
<div style="width:100%;"><strong id="altFormatText">Default Post Type:</strong></div>
|
84 |
|
85 |
<input type="radio" name="tr[<?php echo $ii; ?>][apTRPostType]" value="T" <?php if ($options['trPostType'] != 'I') echo 'checked="checked"'; ?> onchange="nxs_TRSetEnable('T','<?php echo $ii; ?>');" /> Text Post<br/>
|
86 |
|
87 |
+
<div style="width:100%; margin-left: 15px;"><strong id="altFormatText"><?php _e('Post Title Format', 'nxs_snap'); ?>:</strong> (<a href="#" id="apTRTMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apTRTMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>) </div><div onblur="jQuery('#apTRMsgFrmt<?php echo $ii; ?>Hint').hide();">
|
88 |
<input name="tr[<?php echo $ii; ?>][apTRMsgTFrmt]" id="apTRMsgTFrmt<?php echo $ii; ?>" style="margin-left: 15px; width: 50%;" value="<?php if ($options['trMsgTFormat']!='') _e(apply_filters('format_to_edit', htmlentities($options['trMsgTFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap'); else echo "New Post has been published on %SITENAME%"; ?>" onfocus="jQuery('#apTRTMsgFrmt<?php echo $ii; ?>Hint').show();" <?php if ($options['trPostType'] == 'I') echo 'disabled="disabled"'; ?> /><br/>
|
89 |
<?php nxs_doShowHint("apTRTMsgFrmt".$ii); ?>
|
90 |
</div>
|
91 |
|
92 |
+
<input type="radio" name="tr[<?php echo $ii; ?>][apTRPostType]" value="I" <?php if ($options['trPostType'] == 'I') echo 'checked="checked"'; ?> onchange="nxs_TRSetEnable('I','<?php echo $ii; ?>');"/> Image Post
|
93 |
+
<i>Don't forget to change default "Post Text Format" to prevent duplicate images.</i><br/>
|
94 |
|
95 |
<div style="width:100%; margin-left: 15px;">
|
96 |
|
99 |
<input type="radio" name="tr[<?php echo $ii; ?>][cImgURL]" value="R" <?php if ( !isset($options['cImgURL']) || $options['cImgURL'] == '' || $options['cImgURL'] == 'R') echo 'checked="checked"'; ?> /> Regular Post URL
|
100 |
<input type="radio" name="tr[<?php echo $ii; ?>][cImgURL]" value="S" <?php if ($options['cImgURL'] == 'S') echo 'checked="checked"'; ?> /> Shortened Post URL
|
101 |
<input type="radio" name="tr[<?php echo $ii; ?>][cImgURL]" value="N" <?php if ($options['cImgURL'] == 'N') echo 'checked="checked"'; ?> /> No Clickthrough URL
|
102 |
+
</p><strong>Defailt Image to Post:</strong>
|
|
|
|
|
|
|
103 |
<p style="font-size: 11px; margin: 0px;">If your post is missing "Featured Image" and doesn't have any images in the text body this will be used instead.</p>
|
104 |
</div><input name="tr[<?php echo $ii; ?>][apTRDefImg]" id="apTRDefImg<?php echo $ii; ?>" style=" margin-left: 15px; width: 30%;" <?php if ($options['trPostType'] != 'I') echo 'disabled="disabled"'; ?> value="<?php _e(apply_filters('format_to_edit', htmlentities($options['trDefImg'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
|
105 |
<br/>
|
112 |
|
113 |
<div style="width:100%;"><strong id="altFormatText"><?php _e('Post Text Format', 'nxs_snap'); ?>:</strong> (<a href="#" id="apTRMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apTRMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>) </div>
|
114 |
|
115 |
+
|
116 |
+
<textarea cols="150" rows="3" id="tr<?php echo $ii; ?>SNAPformat" name="tr[<?php echo $ii; ?>][apTRMsgFrmt]" style="width:51%;max-width: 650px;" onfocus="jQuery('#tr<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('apTRMsgFrmt<?php echo $ii; ?>');"><?php if ($options['trMsgFormat']!='') _e(apply_filters('format_to_edit', htmlentities($options['trMsgFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap'); else echo htmlentities("<p>New Post has been published on %URL%</p>\r\n<blockquote><p><strong>%TITLE%</strong></p>\r\n<p><img src=\"%IMG%\"/></p><p>%FULLTEXT%</p></blockquote>"); ?></textarea>
|
117 |
+
|
118 |
+
<br/>
|
119 |
<?php nxs_doShowHint("apTRMsgFrmt".$ii); ?>
|
120 |
|
121 |
|
122 |
<p style="margin-bottom: 20px;margin-top: 5px;"><input value="1" id="trInclTags" type="checkbox" name="tr[<?php echo $ii; ?>][trInclTags]" <?php if ((int)$options['trInclTags'] == 1) echo "checked"; ?> />
|
123 |
+
<strong>Post with tags.</strong> Tags from the blogpost will be auto posted to Tumblr
|
124 |
+
<br/><input value="1" id="trInclCats" type="checkbox" name="tr[<?php echo $ii; ?>][trInclCats]" <?php if ((int)$options['trInclCats'] == 1) echo "checked"; ?> />
|
125 |
+
<strong>Post categories as tags.</strong> Categories from the blogpost will be auto posted to Tumblr as tags
|
126 |
</p>
|
127 |
|
128 |
<?php
|
156 |
$trPgID = $options[$ii]['trURL']; if (substr($trPgID, -1)=='/') $trPgID = substr($trPgID, 0, -1); $trPgID = substr(strrchr($trPgID, "/"), 1);
|
157 |
$options[$ii]['trPgID'] = $trPgID; //echo $fbPgID;
|
158 |
}
|
159 |
+
if (substr($options[$ii]['trURL'], -1)!='/') $options[$ii]['trURL'] .= '/';;
|
160 |
if (isset($pval['apDoTR'])) $options[$ii]['doTR'] = $pval['apDoTR']; else $options[$ii]['doTR'] = 0;
|
161 |
if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']);
|
162 |
if (isset($pval['apTRConsKey'])) $options[$ii]['trConsKey'] = trim($pval['apTRConsKey']);
|
164 |
if (isset($pval['apTRMsgFrmt'])) $options[$ii]['trMsgFormat'] = trim($pval['apTRMsgFrmt']);
|
165 |
if (isset($pval['apTRMsgTFrmt'])) $options[$ii]['trMsgTFormat'] = trim($pval['apTRMsgTFrmt']);
|
166 |
if (isset($pval['trInclTags'])) $options[$ii]['trInclTags'] = $pval['trInclTags']; else $options[$ii]['trInclTags'] = 0;
|
167 |
+
if (isset($pval['trInclCats'])) $options[$ii]['trInclCats'] = $pval['trInclCats']; else $options[$ii]['trInclCats'] = 0;
|
168 |
if (isset($pval['apTRPostType'])) $options[$ii]['trPostType'] = trim($pval['apTRPostType']);
|
169 |
if (isset($pval['cImgURL'])) $options[$ii]['cImgURL'] = trim($pval['cImgURL']);
|
170 |
|
186 |
?>
|
187 |
|
188 |
<tr><th style="text-align:left;" colspan="2"><?php if ( $options['catSel']=='1' && trim($options['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_TR<?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" /> <?php } ?>
|
189 |
+
<?php if ($isAvailTR) { ?><input class="nxsGrpDoChb" value="1" id="doTR<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="tr[<?php echo $ii; ?>][doTR]" <?php if ((int)$doTR == 1) echo 'checked="checked" title="def"'; ?> />
|
190 |
+
<?php if ($post->post_status == "publish") { ?> <input type="hidden" name="tr[<?php echo $ii; ?>][doTR]" value="<?php echo $doTR;?>"> <?php } ?> <?php } ?>
|
191 |
<div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/tr16.png);">Tumblr - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $options['nName']; ?></i>) </div></th><td><?php //## Only show RePost button if the post is "published"
|
192 |
if ($post->post_status == "publish" && $isAvailTR) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;"Z type="button" class="button" name="rePostToTR_repostButton" id="rePostToTR_button" value="<?php _e('Repost to Tumblr', 'nxs_snap') ?>" />
|
193 |
<?php wp_nonce_field( 'rePostToTR', 'rePostToTR_wpnonce' ); } ?>
|
215 |
<input type="radio" name="tr[<?php echo $ii; ?>][apTRPostType]" value="U" <?php if ($options['trPostType'] == 'U') echo 'checked="checked"'; ?> /> <b>Audio Post</b> <?php nxs_doShowHint("apTRTMsgFrmt".$ii); ?>
|
216 |
</td></tr>
|
217 |
|
218 |
+
<tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top:6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Text Format:', 'nxs_snap') ?></th>
|
219 |
+
<td>
|
220 |
+
<textarea cols="150" rows="1" id="tr<?php echo $ii; ?>SNAPformat" name="tr[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('#tr<?php echo $ii; ?>SNAPformat').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apTRMsgFrmt<?php echo $ii; ?>');"><?php echo $trMsgFormat; ?></textarea>
|
221 |
+
<?php nxs_doShowHint("apTRMsgFrmt".$ii); ?></td></tr>
|
222 |
|
223 |
<?php }
|
224 |
}
|
236 |
}
|
237 |
}}
|
238 |
|
239 |
+
if (!function_exists("nxs_rePostToTR_ajax")) { function nxs_rePostToTR_ajax() { check_ajax_referer('rePostToTR'); $postID = $_POST['id'];
|
240 |
$options = get_option('NS_SNAutoPoster'); foreach ($options['tr'] as $ii=>$po) if ($ii==$_POST['nid']) { $po['ii'] = $ii; $po['pType'] = 'aj';
|
241 |
$mpo = get_post_meta($postID, 'snapTR', true); $mpo = maybe_unserialize($mpo);
|
242 |
if (is_array($mpo) && isset($mpo[$ii]) && is_array($mpo[$ii]) ){ $ntClInst = new nxs_snapClassTR(); $po = $ntClInst->adjMetaOpt($po, $mpo[$ii]); }
|
246 |
}
|
247 |
|
248 |
if (!function_exists("nxs_doPublishToTR")) { //## Second Function to Post to TR
|
249 |
+
function nxs_doPublishToTR($postID, $options){ $ntCd = 'TR'; $ntCdL = 'tr'; $ntNm = 'Tumblr';
|
250 |
+
//if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToTR', array($postID, $options));
|
251 |
+
$blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url();
|
252 |
+
$ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
|
253 |
+
$logNT = '<span style="color:#014A76">Tumblr</span> - '.$options['nName'];
|
254 |
+
$snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
|
255 |
if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
|
256 |
+
$snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') {
|
257 |
+
nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$options['pType']); return;
|
258 |
+
}
|
259 |
}
|
260 |
//## Format
|
261 |
if ($postID=='0') { echo "Testing ... <br/><br/>"; $msg = 'Test Post from '.$blogTitle; $msgT = 'Test Post from '.$blogTitle; $options['trPostType']=='T';}
|
265 |
//## Post
|
266 |
require_once('apis/trOAuth.php'); $consumer_key = $options['trConsKey']; $consumer_secret = $options['trConsSec'];
|
267 |
$tum_oauth = new TumblrOAuth($consumer_key, $consumer_secret, $options['trAccessTocken']['oauth_token'], $options['trAccessTocken']['oauth_token_secret']); //prr($options);
|
268 |
+
$trURL = trim(str_ireplace('http://', '', $options['trURL'])); if (substr($trURL,-1)=='/') $trURL = substr($trURL,0,-1); $tggs = array();
|
269 |
+
if ($options['trInclTags']=='1'){ $t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = implode(',', $tggs); }
|
270 |
+
if ($options['trInclCats']=='1'){ $t = wp_get_post_categories($postID); foreach($t as $c){ $cat = get_category($c); $tggs[] = $cat->name; } $tags = implode(',', $tggs); }
|
271 |
$postDate = ($post->post_date_gmt!='0000-00-00 00:00:00'?$post->post_date_gmt:gmdate("Y-m-d H:i:s", strtotime($post->post_date)))." GMT"; //## Adds date to Tumblr post. Thanks to Kenneth Lecky
|
272 |
+
$extInfo = ' | PostID: '.$postID." - ".$post->post_title.' |'.$options['pType'];
|
273 |
$postArr = array('tags'=>$tags, 'date'=>$postDate);
|
274 |
if($options['trPostType']=='V') { $vids = nsFindVidsInPost($post); if (count($vids)>0) $ytUrl = $vids[0]; if (trim($ytUrl)=='') $options['trPostType']='T'; }
|
275 |
if($options['trPostType']=='U') { $aud = nsFindAudioInPost($post); if (count($aud)>0) $aUrl = $aud[0]; if (trim($aUrl)=='') $options['trPostType']='T'; }
|
276 |
+
if($options['trPostType']=='I') { $imgURL = nxs_getPostImage($postID, 'large', $options['trDefImg']); if (trim($imgURL)=='') $options['trPostType']='T'; }
|
277 |
+
if ($options['trPostType']=='I') { $postArr['type'] = 'photo'; $postArr['caption'] = $msg; $postArr['source'] = $imgURL;
|
278 |
if (!isset($options['cImgURL']) || $options['cImgURL']=='' || $options['cImgURL']=='R' ) $postArr['link'] = get_permalink($postID);
|
279 |
elseif ($options['cImgURL']=='S' ) {$postArr['link'] = get_permalink($postID); $postArr['link'] = nxs_mkShortURL($postArr['link']);}
|
280 |
} elseif($options['trPostType']=='U') { $postArr['type'] = 'audio'; $postArr['caption'] = $msg; $postArr['external_url'] = $aUrl;
|
286 |
$postinfo = $tum_oauth->post("http://api.tumblr.com/v2/blog/".$trURL."/post", $postArr); // prr($postinfo); prr($postArr);
|
287 |
|
288 |
$code = $postinfo->meta->status;// echo "XX".print_r($code); prr($postinfo); // prr($msg); prr($postinfo); echo $code."VVVV"; die("|====");
|
289 |
+
if ($code == 201) { if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo 'OK - Message Posted, please see your Tumblr Page. <br/> Result:'; prr($postinfo->meta); }
|
290 |
+
else { nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); nxs_metaMarkAsPosted($postID, 'TR', $options['ii'], array('isPosted'=>'1', 'pgID'=>$postinfo->response->id, 'pDate'=>date('Y-m-d H:i:s'))); } }
|
291 |
+
else { nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($postinfo, true), $extInfo); if ($postID=='0') prr($postinfo); $code .= " - ".$postinfo->meta->msg.$postinfo->errmsg; }
|
292 |
|
293 |
return $code;
|
294 |
}
|
inc-cl/tw.api.php
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
//## NextScripts Twitter Connection Class
|
3 |
+
$nxs_snapAPINts[] = array('code'=>'TW', 'lcode'=>'tw', 'name'=>'Twitter');
|
4 |
+
|
5 |
+
if (!class_exists("nxs_class_SNAP_TW")) { class nxs_class_SNAP_TW {
|
6 |
+
|
7 |
+
var $ntCode = 'TW';
|
8 |
+
var $ntLCode = 'tw';
|
9 |
+
|
10 |
+
function doPost($options, $message){ if (!is_array($options)) return false; $out = array(); // return false;
|
11 |
+
foreach ($options as $ii=>$ntOpts) $out[$ii] = $this->doPostToNT($ntOpts, $message);
|
12 |
+
return $out;
|
13 |
+
}
|
14 |
+
function doPostToNT($options, $message){ global $nxs_urlLen; $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>'');
|
15 |
+
//## Check settings
|
16 |
+
if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
|
17 |
+
if (!isset($options['twAccToken']) || trim($options['twAccToken'])=='') { $badOut['Error'] = 'No Auth Token Found'; return $badOut; }
|
18 |
+
//## Old Settings Fix
|
19 |
+
if ($options['attchImg']=='1') $options['attchImg'] = 'large'; if ($options['attchImg']=='0') $options['attchImg'] = false;
|
20 |
+
if (isset($message['img'])) $img = trim($message['img']); else $img = ''; // prr($message);
|
21 |
+
//## Format Post
|
22 |
+
$msg = nxs_doFormatMsg($options['twMsgFormat'], $message); if ($options['attchImg']!=false) { $imgURL = trim($message['imgURL'][$options['attchImg']]);
|
23 |
+
if ($imgURL=='') $imgURL = trim($message['imgURL']['large']); if ($imgURL=='') $imgURL = trim($message['imgURL']['medium']);
|
24 |
+
if ($imgURL=='') $imgURL = trim($message['imgURL']['original']); if ($imgURL=='') $imgURL = trim($message['imgURL']['thumb']);
|
25 |
+
}
|
26 |
+
if ($imgURL=='' && $img=='') $options['attchImg'] = false;
|
27 |
+
//## Make Post
|
28 |
+
//$msg = $message['message']; $imgURL = trim($message['imageURL']); $img = trim($message['img']); $nxs_urlLen = $message['urlLength'];
|
29 |
+
if ($options['attchImg']!=false && $img=='' && $imgURL!='' ) {
|
30 |
+
if( ini_get('allow_url_fopen') ) { if (getimagesize($imgURL)!==false) { $img = nxs_remote_get($imgURL); if(is_nxs_error($img)) $options['attchImg'] = false; else $img = $img['body']; } else $options['attchImg'] = false; }
|
31 |
+
else { $img = nxs_remote_get($imgURL); if(is_nxs_error($img)) $options['attchImg'] = false; elseif (isset($img['body'])&& trim($img['body'])!='') $img = $img['body']; else $options['attchImg'] = false; }
|
32 |
+
}
|
33 |
+
if ($options['attchImg']!=false && $img!='') $twLim = 118; else $twLim = 140;
|
34 |
+
|
35 |
+
require_once ('apis/tmhOAuth.php'); if ($nxs_urlLen>0) { $msg = nsTrnc($msg, $twLim-22+$nxs_urlLen); } else $msg = nsTrnc($msg, $twLim);
|
36 |
+
$tmhOAuth = new NXS_tmhOAuth(array( 'consumer_key' => $options['twConsKey'], 'consumer_secret' => $options['twConsSec'], 'user_token' => $options['twAccToken'], 'user_secret' => $options['twAccTokenSec']));
|
37 |
+
if ($options['attchImg']!=false && $img!='') $code = $tmhOAuth -> request('POST', 'http://upload.twitter.com/1/statuses/update_with_media.json', array( 'media[]' => $img, 'status' => $msg), true, true);
|
38 |
+
else $code = $tmhOAuth->request('POST', $tmhOAuth->url('1.1/statuses/update'), array('status' =>$msg));
|
39 |
+
if ( $code=='403' && stripos($tmhOAuth->response['response'], 'User is over daily photo limit')!==false && $options['attchImg']!=false && $img!='') {
|
40 |
+
$badOut['Error'] .= "User is over daily photo limit. Will post without image\r\n"; $code = $tmhOAuth->request('POST', $tmhOAuth->url('1.1/statuses/update'), array('status' =>$msg));
|
41 |
+
}
|
42 |
+
if ($code == 200){
|
43 |
+
$twResp = json_decode($tmhOAuth->response['response'], true); if (is_array($twResp) && isset($twResp['id_str'])) $twNewPostID = $twResp['id_str'];
|
44 |
+
if (is_array($twResp) && isset($twResp['user'])) $twPageID = $twResp['user']['screen_name'];
|
45 |
+
return array('postID'=>$twNewPostID, 'isPosted'=>1, 'postURL'=>'https://twitter.com/'.$twPageID.'/status/'.$twNewPostID, 'pDate'=>date('Y-m-d H:i:s'));
|
46 |
+
} else { $badOut['Error'] .= print_r($tmhOAuth->response['response'], true)." MSG:".print_r($msg, true);
|
47 |
+
return $badOut;
|
48 |
+
}
|
49 |
+
return $badOut;
|
50 |
+
}
|
51 |
+
|
52 |
+
}}
|
53 |
+
?>
|
inc-cl/tw.php
CHANGED
@@ -15,9 +15,9 @@ if (!class_exists("nxs_snapClassTW")) { class nxs_snapClassTW {
|
|
15 |
<div class="nxs_box_inside">
|
16 |
<?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = str_ireplace('https://','', str_ireplace('http://','', $pbo['twURL'])); ?>
|
17 |
<p style="margin:0px;margin-left:5px;">
|
18 |
-
<input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> />
|
19 |
<strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
|
20 |
-
<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention
|
21 |
<a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
|
22 |
</p><?php $this->showNTSettings($indx, $pbo);
|
23 |
}?>
|
@@ -27,7 +27,9 @@ if (!class_exists("nxs_snapClassTW")) { class nxs_snapClassTW {
|
|
27 |
//#### Show NEW Settings Page
|
28 |
function showNewNTSettings($mtwo){ $two = array('nName'=>'', 'doTW'=>'1', 'twURL'=>'', 'twConsKey'=>'', 'twConsSec'=>'', 'twAccToken'=>'', 'twAccTokenSec'=>'', 'attchImg'=>0, 'twAttch'=>'', 'twAccTokenSec'=>''); $this->showNTSettings($mtwo, $two, true);}
|
29 |
//#### Show Unit Settings
|
30 |
-
function showNTSettings($ii, $two, $isNew=false){ global $nxs_plurl;
|
|
|
|
|
31 |
<div id="doTW<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>" style="background-image: url(<?php echo $nxs_plurl; ?>img/tw-bg.png); background-position:90% 10%;"> <input type="hidden" name="apDoSTW<?php echo $ii; ?>" value="0" id="apDoSTW<?php echo $ii; ?>" />
|
32 |
|
33 |
<div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/tw16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-twitter-social-networks-auto-poster-wordpress/"><?php $nType="Twitter"; printf( __( 'Detailed %s Installation/Configuration Instructions', 'nxs_snap' ), $nType); ?></a></div>
|
@@ -51,13 +53,29 @@ if (!class_exists("nxs_snapClassTW")) { class nxs_snapClassTW {
|
|
51 |
<div style="width:100%;"><strong>Your Access Token Secret:</strong> </div><input name="tw[<?php echo $ii; ?>][apTWAccTokenSec]" id="apTWAccTokenSec" style="width: 40%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($two['twAccTokenSec'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
|
52 |
<?php if ($isNew) { ?> <input type="hidden" name="tw[<?php echo $ii; ?>][apDoTW]" value="1" id="apDoNewTW<?php echo $ii; ?>" /> <?php } ?>
|
53 |
<br/><br/>
|
54 |
-
<p style="margin: 0px;"><input value="1" id="apLIAttch" type="checkbox" name="tw[<?php echo $ii; ?>][attchImg]" <?php if ((int)$two['attchImg'] == 1) echo "checked"; ?> /> <strong
|
55 |
<br/>
|
56 |
<strong id="altFormatText"><?php _e('Message text Format', 'nxs_snap'); ?>:</strong>
|
57 |
-
<
|
58 |
-
|
59 |
-
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
|
62 |
<?php if($two['twAccTokenSec']!='') { ?> <?php wp_nonce_field( 'rePostToTW', 'rePostToTW_wpnonce' ); ?>
|
63 |
<br/><br/><b><?php _e('Test your settings', 'nxs_snap'); ?>:</b> <?php if (!isset($two['twOK']) || $two['twOK']!='1') { ?> <div class="blnkg">=== Submit Test Post to Complete ===></div> <?php } ?> <a href="#" class="NXSButton" onclick="testPost('TW', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s' , 'nxs_snap'), $nType); ?></a> <br/>
|
@@ -80,6 +98,10 @@ if (!class_exists("nxs_snapClassTW")) { class nxs_snapClassTW {
|
|
80 |
if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']);
|
81 |
if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
|
82 |
|
|
|
|
|
|
|
|
|
83 |
if (isset($pval['apTWAccTokenSec']))$options[$ii]['twAccTokenSec'] = trim($pval['apTWAccTokenSec']);
|
84 |
if (isset($pval['apTWMsgFrmt'])) $options[$ii]['twMsgFormat'] = trim($pval['apTWMsgFrmt']);
|
85 |
if (isset($pval['attchImg'])) $options[$ii]['attchImg'] = $pval['attchImg']; else $options[$ii]['attchImg'] = 0;
|
@@ -95,10 +117,16 @@ if (!class_exists("nxs_snapClassTW")) { class nxs_snapClassTW {
|
|
95 |
$isAvailTW = $ntOpt['twURL']!='' && $ntOpt['twConsKey']!='' && $ntOpt['twConsSec']!='' && $ntOpt['twAccToken']!=''; $twMsgFormat = htmlentities($ntOpt['twMsgFormat'], ENT_COMPAT, "UTF-8"); $isAttchImg = $ntOpt['attchImg'];
|
96 |
?>
|
97 |
<tr><th style="text-align:left;" colspan="2"><?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_TW<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
|
98 |
-
<?php if ($isAvailTW) { ?><input class="nxsGrpDoChb" value="1" id="doTW<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="tw[<?php echo $ii; ?>][doTW]" <?php if ((
|
|
|
99 |
<div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/tw16.png);">Twitter - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th><td><?php //## Only show RePost button if the post is "published"
|
100 |
if ($post->post_status == "publish" && $isAvailTW) { ?>
|
101 |
<input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToTW_repostButton" id="rePostToTW_button" value="<?php _e('Repost to Twitter', 'nxs_snap') ?>" />
|
|
|
|
|
|
|
|
|
|
|
102 |
<?php wp_nonce_field( 'rePostToTW', 'rePostToTW_wpnonce' ); } ?>
|
103 |
<?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID'])) { ?> <span style="float: right;padding-top: 4px; padding-right: 10px;">
|
104 |
<a id="pstdTW<?php echo $ii; ?>" style="font-size: 10px;" href="<?php echo $ntOpt['twURL'].'/status/'.$pMeta[$ii]['pgID']; ?>" target="_blank"><?php $nType="Twitter"; printf( __( 'Posted on', 'nxs_snap' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
|
@@ -107,7 +135,7 @@ if (!class_exists("nxs_snapClassTW")) { class nxs_snapClassTW {
|
|
107 |
<?php if (!$isAvailTW) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your Twitter Account to AutoPost to Twitter</b>
|
108 |
<?php }elseif ($post->post_status != "puZblish") { ?>
|
109 |
|
110 |
-
<tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;"><?php _e('Message Format:', 'nxs_snap') ?></th>
|
111 |
<td><input value="<?php echo $twMsgFormat ?>" type="text" name="tw[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apTWMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apTWMsgFrmt".$ii); ?></td></tr>
|
112 |
|
113 |
<tr><th scope="row" style="text-align:right; width:150px; vertical-align:top; padding-top: 5px; padding-right:10px;">
|
@@ -126,105 +154,154 @@ if (!class_exists("nxs_snapClassTW")) { class nxs_snapClassTW {
|
|
126 |
}
|
127 |
}}
|
128 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
if (!function_exists("nxs_rePostToTW_ajax")) {
|
130 |
function nxs_rePostToTW_ajax() { check_ajax_referer('rePostToTW'); $postID = $_POST['id']; $options = get_option('NS_SNAutoPoster');
|
131 |
foreach ($options['tw'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj';
|
132 |
$twpo = get_post_meta($postID, 'snapTW', true); $twpo = maybe_unserialize($twpo);
|
133 |
-
if (is_array($twpo) && isset($twpo[$ii]) && is_array($twpo[$ii]) && isset($twpo[$ii]['SNAPformat']) ) { $ntClInst = new nxs_snapClassTW(); $two = $ntClInst->adjMetaOpt($two, $twpo[$ii]);}
|
134 |
-
|
|
|
|
|
135 |
}
|
136 |
}
|
137 |
}
|
138 |
|
139 |
if (!function_exists("nxs_doPublishToTW")) { //## Second Function to Post to TW
|
140 |
-
function nxs_doPublishToTW($postID, $options){ $ntCd = 'TW'; $ntCdL = 'tw'; $ntNm = 'Twitter'; $img = ''; $imgURL = '';
|
|
|
|
|
141 |
|
142 |
-
$ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
|
|
|
|
|
143 |
if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
|
144 |
-
|
|
|
|
|
145 |
}
|
146 |
$blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url(); $uln = 0;
|
147 |
|
148 |
if ($options['attchImg']=='1') { $imgURL = nxs_getPostImage($postID); if(trim($imgURL)=='') $options['attchImg'] = 0; else {
|
149 |
-
if( ini_get('allow_url_fopen') ) { if (@getimagesize($imgURL)!==false) { $img = wp_remote_get($imgURL);
|
150 |
-
|
151 |
-
|
152 |
-
|
|
|
|
|
|
|
153 |
|
154 |
-
if ($postID=='0') { echo "Testing ... <br/><br/>"; $msg = 'Test Post from '.nsTrnc($blogTitle, $twLim - 24)." - ".rand(1, 155); $uln =
|
155 |
else{ $post = get_post($postID); if(!$post) return; $twMsgFormat = $options['twMsgFormat']; nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
|
156 |
-
if (stripos($twMsgFormat, '%URL%')!==false || stripos($twMsgFormat, '%SURL%')!==false) $twLim = $twLim -
|
157 |
-
if (stripos($twMsgFormat, '%AUTHORNAME%')!==false) { $aun = $post->post_author; $aun = get_the_author_meta('display_name', $aun ); $twLim = $twLim -
|
158 |
|
159 |
-
$noRepl = str_ireplace("%TITLE%", "", $twMsgFormat); $noRepl = str_ireplace("%SITENAME%", "", $noRepl); $noRepl = str_ireplace("%URL%", "", $noRepl);
|
160 |
-
$noRepl = str_ireplace("%SURL%", "", $noRepl);$noRepl = str_ireplace("%TEXT%", "", $noRepl);$noRepl = str_ireplace("%FULLTEXT%", "", $noRepl);
|
161 |
-
$noRepl = str_ireplace("%
|
162 |
|
163 |
$pTitle = $title = $post->post_title;
|
164 |
-
if ($post->post_excerpt!="") $
|
165 |
-
$pFullText = apply_filters('the_content', $
|
166 |
-
$pRawText = $post->post_content;
|
167 |
-
|
168 |
if (stripos($twMsgFormat, '%TAGS%')!==false || stripos($twMsgFormat, '%HTAGS%')!==false) {
|
169 |
-
$t =
|
|
|
170 |
if (preg_match('/\b'.$frmTag.'\b/iu', $pTitle)) $pTitle = trim(preg_replace('/\b'.$frmTag.'\b/iu', '#'.$frmTag, $pTitle));
|
171 |
if (preg_match('/\b'.$frmTag.'\b/iu', $pFullText)) $pFullText = trim(preg_replace('/\b'.$frmTag.'\b/iu', '#'.$frmTag, $pFullText));
|
172 |
if (preg_match('/\b'.$frmTag.'\b/iu', $pText)) $pText = trim(preg_replace('/\b'.$frmTag.'\b/iu', '#'.$frmTag, $pText));
|
173 |
if (preg_match('/\b'.$frmTag.'\b/iu', $pRawText)) $pRawText = trim(preg_replace('/\b'.$frmTag.'\b/iu', '#'.$frmTag, $pRawText));
|
174 |
if ( ((stripos($twMsgFormat, '%TITLE%')!==false) && preg_match('/\b'.$frmTag.'\b/i', $pTitle)) ||
|
175 |
((stripos($twMsgFormat, '%TEXT%')!==false) && preg_match('/\b'.$frmTag.'\b/i', $pText)) ||
|
|
|
|
|
|
|
176 |
((stripos($twMsgFormat, '%FULLTEXT%')!==false) && preg_match('/\b'.$frmTag.'\b/i', $pFullText)) ||
|
177 |
((stripos($twMsgFormat, '%RAWTEXT%')!==false) && preg_match('/\b'.$frmTag.'\b/i', $pRawText)) ) {} else $tggs[] = '#'.$frmTag;
|
178 |
-
} $tags = implode(' ',$tggs); while(
|
179 |
-
$twLim = $twLim -
|
180 |
-
}
|
181 |
if (stripos($twMsgFormat, '%CATS%')!==false || stripos($twMsgFormat, '%HCATS%')!==false) {
|
182 |
-
$t = wp_get_post_categories($postID); $
|
183 |
if (stripos($pTitle, $cat->name)!==false) $pTitle = str_ireplace($cat->name, '#'.$frmTag, $pTitle); elseif (stripos($pTitle, $frmTag)!==false) $pTitle = str_ireplace($frmTag, '#'.$frmTag, $pTitle);
|
184 |
if (stripos($pText, $cat->name)!==false) $pText = str_ireplace($cat->name, '#'.$frmTag, $pText); elseif (stripos($pText, $frmTag)!==false) $pText = str_ireplace($frmTag, '#'.$frmTag, $pText);
|
185 |
if (stripos($pFullText, $cat->name)!==false) $pFullText = str_ireplace($cat->name, '#'.$frmTag, $pFullText); elseif (stripos($pFullText, $frmTag)!==false) $pFullText = str_ireplace($frmTag, '#'.$frmTag, $pFullText);
|
186 |
if (stripos($pRawText, $cat->name)!==false) $pRawText = str_ireplace($cat->name, '#'.$frmTag, $pRawText); elseif (stripos($pRawText, $frmTag)!==false) $pRawText = str_ireplace($frmTag, '#'.$frmTag, $pRawText);
|
187 |
if ( ((stripos($twMsgFormat, '%TITLE%')!==false) && (stripos($pTitle, $cat->name)!==false || stripos($pTitle, $frmTag)!==false)) ||
|
188 |
((stripos($twMsgFormat, '%TEXT%')!==false) && (stripos($pText, $cat->name)!==false || stripos($pText, $frmTag)!==false)) ||
|
|
|
|
|
|
|
189 |
((stripos($twMsgFormat, '%FULLTEXT%')!==false) && (stripos($pFullText, $cat->name)!==false || stripos($pFullText, $frmTag)!==false)) ||
|
190 |
-
((stripos($twMsgFormat, '%RAWTEXT%')!==false) && (stripos($pRawText, $cat->name)!==false || stripos($pRawText, $frmTag)!==false)) ) {} else $
|
191 |
-
} $
|
192 |
-
$twLim = $twLim -
|
193 |
-
}
|
194 |
if (stripos($twMsgFormat, '%TITLE%')!==false) { if (stripos($pTitle, '.co.uk')!==false) $twLim = $twLim - 14;
|
195 |
if (stripos($pTitle, '.com')!==false) $twLim = $twLim - 16; if (stripos($pTitle, '.net')!==false) $twLim = $twLim - 16; if (stripos($pTitle, '.org')!==false) $twLim = $twLim - 16;
|
196 |
$pTitle = html_entity_decode(strip_tags($pTitle), ENT_NOQUOTES, 'UTF-8');
|
197 |
-
$pTitle = nsTrnc($pTitle, $twLim); $twMsgFormat = str_ireplace("%TITLE%", $pTitle, $twMsgFormat); $twLim = $twLim -
|
198 |
}
|
199 |
if (stripos($twMsgFormat, '%SITENAME%')!==false) {
|
200 |
-
$siteTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); $siteTitle = nsTrnc($siteTitle, $twLim); $twMsgFormat = str_ireplace("%SITENAME%", $siteTitle, $twMsgFormat); $twLim = $twLim -
|
201 |
-
}
|
202 |
if (stripos($twMsgFormat, '%TEXT%')!==false) {
|
203 |
-
$pText = nsTrnc(strip_tags(strip_shortcodes($pText)), 300, " ", "...");
|
204 |
-
$pText = nsTrnc($pText, $twLim); $twMsgFormat = str_ireplace("%TEXT%", $pText, $twMsgFormat); $twLim = $twLim -
|
205 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
if (stripos($twMsgFormat, '%FULLTEXT%')!==false) {
|
207 |
-
$pFullText = nsTrnc(strip_tags($pFullText), $twLim); $twMsgFormat = str_ireplace("%FULLTEXT%", $pFullText, $twMsgFormat); $twLim = $twLim -
|
208 |
}
|
209 |
if (stripos($twMsgFormat, '%RAWTEXT%')!==false) {
|
210 |
-
$pRawText = nsTrnc(strip_tags($pRawText), $twLim); $twMsgFormat = str_ireplace("%RAWTEXT%", $pRawText, $twMsgFormat); $twLim = $twLim -
|
211 |
-
}
|
212 |
-
$msg = nsFormatMessage($twMsgFormat, $postID);
|
213 |
-
}
|
|
|
|
|
|
|
|
|
|
|
214 |
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
if ($
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
$
|
223 |
-
}
|
224 |
-
} else{ if ($postID=='0') {NXS_tmhUtilities::pr($tmhOAuth->response['response']); prr($msg); } nxs_addToLog($logNT, 'E', '-=ERROR=- '.print_r($tmhOAuth->response['response'], true)." MSG:".print_r($msg, true), $extInfo);
|
225 |
-
$code .= " | ".$tmhOAuth->response['response']." | ".print_r($msg, true);
|
226 |
}
|
227 |
-
|
|
|
|
|
228 |
}
|
229 |
}
|
230 |
|
15 |
<div class="nxs_box_inside">
|
16 |
<?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = str_ireplace('https://','', str_ireplace('http://','', $pbo['twURL'])); ?>
|
17 |
<p style="margin:0px;margin-left:5px;">
|
18 |
+
<input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> /> <?php if ((int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
|
19 |
<strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
|
20 |
+
<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention required. Unfinished setup', 'nxs_snap'); ?> ==></b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>
|
21 |
<a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
|
22 |
</p><?php $this->showNTSettings($indx, $pbo);
|
23 |
}?>
|
27 |
//#### Show NEW Settings Page
|
28 |
function showNewNTSettings($mtwo){ $two = array('nName'=>'', 'doTW'=>'1', 'twURL'=>'', 'twConsKey'=>'', 'twConsSec'=>'', 'twAccToken'=>'', 'twAccTokenSec'=>'', 'attchImg'=>0, 'twAttch'=>'', 'twAccTokenSec'=>''); $this->showNTSettings($mtwo, $two, true);}
|
29 |
//#### Show Unit Settings
|
30 |
+
function showNTSettings($ii, $two, $isNew=false){ global $nxs_plurl, $plgn_NS_SNAutoPoster;
|
31 |
+
if (!isset($plgn_NS_SNAutoPoster)) return; $gOptions = $plgn_NS_SNAutoPoster->nxs_options;
|
32 |
+
?>
|
33 |
<div id="doTW<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>" style="background-image: url(<?php echo $nxs_plurl; ?>img/tw-bg.png); background-position:90% 10%;"> <input type="hidden" name="apDoSTW<?php echo $ii; ?>" value="0" id="apDoSTW<?php echo $ii; ?>" />
|
34 |
|
35 |
<div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/tw16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-twitter-social-networks-auto-poster-wordpress/"><?php $nType="Twitter"; printf( __( 'Detailed %s Installation/Configuration Instructions', 'nxs_snap' ), $nType); ?></a></div>
|
53 |
<div style="width:100%;"><strong>Your Access Token Secret:</strong> </div><input name="tw[<?php echo $ii; ?>][apTWAccTokenSec]" id="apTWAccTokenSec" style="width: 40%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($two['twAccTokenSec'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
|
54 |
<?php if ($isNew) { ?> <input type="hidden" name="tw[<?php echo $ii; ?>][apDoTW]" value="1" id="apDoNewTW<?php echo $ii; ?>" /> <?php } ?>
|
55 |
<br/><br/>
|
56 |
+
<p style="margin: 0px;"><input value="1" id="apLIAttch" type="checkbox" name="tw[<?php echo $ii; ?>][attchImg]" <?php if ((int)$two['attchImg'] == 1) echo "checked"; ?> /> <strong><?php _e('Attach Image to Twitter Post', 'nxs_snap'); ?></strong></p>
|
57 |
<br/>
|
58 |
<strong id="altFormatText"><?php _e('Message text Format', 'nxs_snap'); ?>:</strong>
|
59 |
+
<input name="tw[<?php echo $ii; ?>][apTWMsgFrmt]" id="apTWMsgFrmt" style="width: 50%;" value="<?php if (!$isNew) _e(apply_filters('format_to_edit', htmlentities($two['twMsgFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap'); else echo "%TITLE% - %URL%"; ?>" onfocus="mxs_showFrmtInfo('apTWMsgFrmt<?php echo $ii; ?>');" />
|
60 |
+
|
61 |
+
<?php nxs_doShowHint("apTWMsgFrmt".$ii, '<br/><br/><b>%TAGS% and %CATS% will be posted as hashtags. <br/>Please remember that Twitter takes only 140 characters.</b>'); ?>
|
62 |
+
|
63 |
+
<br/><br/>
|
64 |
+
<div style="width:100%;"><strong style="font-size: 16px;"><?php _e('Twitter Replies and Mentions:', 'nxs_snap'); ?></strong> </div>
|
65 |
+
<div style="margin-bottom: 5px; margin-left: 10px; ">
|
66 |
+
<p style="font-size: 11px; margin: 0px;"><?php _e('Plugin could grab Replies and Mentions from Twitter and import them as Wordpress Comments', 'nxs_snap'); ?></p>
|
67 |
+
|
68 |
+
<?php if ( $gOptions['riActive'] == '1' ) { ?>
|
69 |
+
<input value="1" id="riC<?php echo $ii; ?>" <?php if (trim($two['riComments'])=='1') echo "checked"; ?> type="checkbox" name="tw[<?php echo $ii; ?>][riComments]"/> <strong><?php _e('Import Twitter Replies', 'nxs_snap'); ?></strong>
|
70 |
+
|
71 |
+
<input value="1" id="riCM<?php echo $ii; ?>" <?php if (trim($two['riCommentsM'])=='1') echo "checked"; ?> type="checkbox" name="tw[<?php echo $ii; ?>][riCommentsM]"/> <strong><?php _e('Import Twitter Mentions', 'nxs_snap'); ?></strong>
|
72 |
+
<br/>
|
73 |
+
<div style="margin-bottom: 5px; margin-left: 10px; ">
|
74 |
+
<input value="1" id="riCA<?php echo $ii; ?>" <?php if (trim($two['riCommentsAA'])=='1') echo "checked"; ?> type="checkbox" name="tw[<?php echo $ii; ?>][riCommentsAA]"/> <strong><?php _e('Auto-approve imported comments', 'nxs_snap'); ?></strong></div>
|
75 |
+
|
76 |
+
<?php } else { echo "<br/>"; _e('Please activate the "Comments Import" from SNAP Settings - Other Settings', 'nxs_snap'); } ?>
|
77 |
+
|
78 |
+
</div>
|
79 |
|
80 |
<?php if($two['twAccTokenSec']!='') { ?> <?php wp_nonce_field( 'rePostToTW', 'rePostToTW_wpnonce' ); ?>
|
81 |
<br/><br/><b><?php _e('Test your settings', 'nxs_snap'); ?>:</b> <?php if (!isset($two['twOK']) || $two['twOK']!='1') { ?> <div class="blnkg">=== Submit Test Post to Complete ===></div> <?php } ?> <a href="#" class="NXSButton" onclick="testPost('TW', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s' , 'nxs_snap'), $nType); ?></a> <br/>
|
98 |
if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']);
|
99 |
if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
|
100 |
|
101 |
+
if (isset($pval['riComments'])) $options[$ii]['riComments'] = $pval['riComments']; else $options[$ii]['riComments'] = 0;
|
102 |
+
if (isset($pval['riCommentsM'])) $options[$ii]['riCommentsM'] = $pval['riCommentsM']; else $options[$ii]['riCommentsM'] = 0;
|
103 |
+
if (isset($pval['riCommentsAA'])) $options[$ii]['riCommentsAA'] = $pval['riCommentsAA']; else $options[$ii]['riCommentsAA'] = 0;
|
104 |
+
|
105 |
if (isset($pval['apTWAccTokenSec']))$options[$ii]['twAccTokenSec'] = trim($pval['apTWAccTokenSec']);
|
106 |
if (isset($pval['apTWMsgFrmt'])) $options[$ii]['twMsgFormat'] = trim($pval['apTWMsgFrmt']);
|
107 |
if (isset($pval['attchImg'])) $options[$ii]['attchImg'] = $pval['attchImg']; else $options[$ii]['attchImg'] = 0;
|
117 |
$isAvailTW = $ntOpt['twURL']!='' && $ntOpt['twConsKey']!='' && $ntOpt['twConsSec']!='' && $ntOpt['twAccToken']!=''; $twMsgFormat = htmlentities($ntOpt['twMsgFormat'], ENT_COMPAT, "UTF-8"); $isAttchImg = $ntOpt['attchImg'];
|
118 |
?>
|
119 |
<tr><th style="text-align:left;" colspan="2"><?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_TW<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
|
120 |
+
<?php if ($isAvailTW) { ?><input class="nxsGrpDoChb" value="1" id="doTW<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="tw[<?php echo $ii; ?>][doTW]" <?php if ((int)$doTW == 1) echo 'checked="checked" title="def"'; ?> />
|
121 |
+
<?php if ($post->post_status == "publish") { ?> <input type="hidden" name="tw[<?php echo $ii; ?>][doTW]" value="<?php echo $doTW;?>"> <?php } ?> <?php } ?>
|
122 |
<div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/tw16.png);">Twitter - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th><td><?php //## Only show RePost button if the post is "published"
|
123 |
if ($post->post_status == "publish" && $isAvailTW) { ?>
|
124 |
<input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToTW_repostButton" id="rePostToTW_button" value="<?php _e('Repost to Twitter', 'nxs_snap') ?>" />
|
125 |
+
|
126 |
+
<?php if ($ntOpt['riComments']=='1' && (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) && $pMeta[$ii]['pgID']!='' ) ) { ?>
|
127 |
+
<input alt="<?php echo $ii; ?>" style="float: right; " onclick="return false;" type="button" class="button" name="riToTW_repostButton" id="riToTW_button" value="<?php _e('Import Replies/Mentions from Twitter', 'nxs_snap') ?>" />
|
128 |
+
<?php } ?>
|
129 |
+
|
130 |
<?php wp_nonce_field( 'rePostToTW', 'rePostToTW_wpnonce' ); } ?>
|
131 |
<?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID'])) { ?> <span style="float: right;padding-top: 4px; padding-right: 10px;">
|
132 |
<a id="pstdTW<?php echo $ii; ?>" style="font-size: 10px;" href="<?php echo $ntOpt['twURL'].'/status/'.$pMeta[$ii]['pgID']; ?>" target="_blank"><?php $nType="Twitter"; printf( __( 'Posted on', 'nxs_snap' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
|
135 |
<?php if (!$isAvailTW) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your Twitter Account to AutoPost to Twitter</b>
|
136 |
<?php }elseif ($post->post_status != "puZblish") { ?>
|
137 |
|
138 |
+
<tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top:6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Message Format:', 'nxs_snap') ?></th>
|
139 |
<td><input value="<?php echo $twMsgFormat ?>" type="text" name="tw[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apTWMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apTWMsgFrmt".$ii); ?></td></tr>
|
140 |
|
141 |
<tr><th scope="row" style="text-align:right; width:150px; vertical-align:top; padding-top: 5px; padding-right:10px;">
|
154 |
}
|
155 |
}}
|
156 |
|
157 |
+
if (!function_exists("nxs_getBackTWComments")) { function nxs_getBackTWComments($postID, $options, $po) { $impCmnts = get_post_meta($postID, 'snapImportedComments', true); if(!is_array($impCmnts)) $impCmnts = array();
|
158 |
+
$url = 'https://api.twitter.com/1/related_results/show/'.$po['pgID'].'.json?include_entities=1'; //echo $url;
|
159 |
+
$data = json_decode( $response = wp_remote_retrieve_body( wp_remote_get( $url ) ), true ); // prr($data[0]['results']);
|
160 |
+
if (is_array($data) && is_array($data[0]) && is_array($data[0]['results']))
|
161 |
+
foreach ($data[0]['results'] as $comment){ $comment = $comment['value']; $cid = $comment['id_str']; if (trim($cid)=='' || in_array('twxcw'.$cid, $impCmnts)) continue; else $impCmnts[] = 'twxcw'.$cid; // prr($impCmnts);
|
162 |
+
$commentdata = array( 'comment_post_ID' => $postID, 'comment_author' => $comment['user']['name'], 'comment_author_email' => $comment['user']['screen_name'].'@twitter.com',
|
163 |
+
'comment_author_url' => 'http://twitter.com/'.$comment['user']['screen_name'], 'comment_content' => $comment['text'], 'comment_date_gmt' => date('Y-m-d H:i:s', strtotime( $comment['created_at'] ) ), 'comment_type' => '');
|
164 |
+
nxs_postNewComment($commentdata, $options['riCommentsAA']=='1'); $ci++;
|
165 |
+
}
|
166 |
+
$url = 'http://search.twitter.com/search.json?rpp=100&since_id=' . $lastID . '&q=' . urlencode( get_permalink( $postID ) );
|
167 |
+
$data = json_decode( $response = wp_remote_retrieve_body( wp_remote_get( $url ) ), true );
|
168 |
+
if (is_array($data) && is_array($data['results']))
|
169 |
+
foreach ($data['results'] as $comment){ $cid = $comment['id_str']; if (trim($cid)=='' || in_array('twxcw'.$cid, $impCmnts) || $cid==$po['pgID']) continue; else $impCmnts[] = 'twxcw'.$cid; // prr($impCmnts);
|
170 |
+
$commentdata = array( 'comment_post_ID' => $postID, 'comment_author' => $comment['from_user_name'], 'comment_author_email' => $comment['from_user'].'@twitter.com',
|
171 |
+
'comment_author_url' => 'http://twitter.com/'.$comment['from_user'], 'comment_content' => $comment['text'], 'comment_date_gmt' => date('Y-m-d H:i:s', strtotime( $comment['created_at'] ) ), 'comment_type' => '');
|
172 |
+
nxs_postNewComment($commentdata, $options['riCommentsAA']=='1'); $ci++;
|
173 |
+
}
|
174 |
+
delete_post_meta($postID, 'snapImportedComments'); add_post_meta($postID, 'snapImportedComments', $impCmnts );
|
175 |
+
if ($_POST['id']!='') printf( _n( '%d comment has been imported.', '%d comments has been imported.', $ci, 'nxs_snap'), $ci );
|
176 |
+
}}
|
177 |
+
|
178 |
if (!function_exists("nxs_rePostToTW_ajax")) {
|
179 |
function nxs_rePostToTW_ajax() { check_ajax_referer('rePostToTW'); $postID = $_POST['id']; $options = get_option('NS_SNAutoPoster');
|
180 |
foreach ($options['tw'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj';
|
181 |
$twpo = get_post_meta($postID, 'snapTW', true); $twpo = maybe_unserialize($twpo);
|
182 |
+
if (is_array($twpo) && isset($twpo[$ii]) && is_array($twpo[$ii]) && isset($twpo[$ii]['SNAPformat']) ) { $ntClInst = new nxs_snapClassTW(); $two = $ntClInst->adjMetaOpt($two, $twpo[$ii]);}
|
183 |
+
if ($_POST['ri']=='1') { nxs_getBackTWComments($postID, $two, $twpo[$ii]); die(); } else {
|
184 |
+
$result = nxs_doPublishToTW($postID, $two); if ($result == 200) {$options['tw'][$ii]['twOK']=1; update_option('NS_SNAutoPoster', $options); } if ($result == 200) die("Successfully sent your post to Twitter."); else die($result);
|
185 |
+
}
|
186 |
}
|
187 |
}
|
188 |
}
|
189 |
|
190 |
if (!function_exists("nxs_doPublishToTW")) { //## Second Function to Post to TW
|
191 |
+
function nxs_doPublishToTW($postID, $options){ $ntCd = 'TW'; $ntCdL = 'tw'; $ntNm = 'Twitter'; $img = ''; $imgURL = ''; global $nxs_urlLen; $nxs_urlLen = 0;
|
192 |
+
//$backtrace = debug_backtrace(); nxs_addToLogN('W', 'Error', $logNT, 'I am here - '.$ntCd."|".print_r($backtrace, true), '');
|
193 |
+
//if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToTW', array($postID, $options));
|
194 |
|
195 |
+
$ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
|
196 |
+
$logNT = '<span style="color:#00FFFF">Twitter</span> - '.$options['nName'];
|
197 |
+
$snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
|
198 |
if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
|
199 |
+
$snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') {
|
200 |
+
nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$options['pType']); return;
|
201 |
+
}
|
202 |
}
|
203 |
$blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url(); $uln = 0;
|
204 |
|
205 |
if ($options['attchImg']=='1') { $imgURL = nxs_getPostImage($postID); if(trim($imgURL)=='') $options['attchImg'] = 0; else {
|
206 |
+
if( ini_get('allow_url_fopen') ) { if (@getimagesize($imgURL)!==false) { $img = wp_remote_get($imgURL);
|
207 |
+
if ($img['headers']['content-length']<200) { $options['attchImg'] = 0; } else if(is_wp_error($img)) $options['attchImg'] = 0; else $img = $img['body']; } else $options['attchImg'] = 0;
|
208 |
+
} else { $img = wp_remote_get($imgURL); if(is_wp_error($img)) $options['attchImg'] = 0; elseif (isset($img['body'])&& trim($img['body'])!='') $img = $img['body']; else $options['attchImg'] = 0; }
|
209 |
+
}
|
210 |
+
if ($options['attchImg'] == 0) nxs_addToLogN('E', 'Error', $logNT, 'Could not get image, will post without it - Error:'.print_r($img), $extInfo);
|
211 |
+
}
|
212 |
+
if ($options['attchImg']=='1' && $img!='') $twLim = 117; else $twLim = 140;
|
213 |
|
214 |
+
if ($postID=='0') { echo "Testing ... <br/><br/>"; $msg = 'Test Post from '.nsTrnc($blogTitle, $twLim - 24)." - ".rand(1, 155); $uln = nxs_strLen($msg);}
|
215 |
else{ $post = get_post($postID); if(!$post) return; $twMsgFormat = $options['twMsgFormat']; nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
|
216 |
+
if (stripos($twMsgFormat, '%URL%')!==false || stripos($twMsgFormat, '%SURL%')!==false) $twLim = $twLim - 22;
|
217 |
+
if (stripos($twMsgFormat, '%AUTHORNAME%')!==false) { $aun = $post->post_author; $aun = get_the_author_meta('display_name', $aun ); $twLim = $twLim - nxs_strLen($aun); }
|
218 |
|
219 |
+
$noRepl = str_ireplace("%TITLE%", "", $twMsgFormat); $noRepl = str_ireplace("%SITENAME%", "", $noRepl); $noRepl = str_ireplace("%URL%", "", $noRepl);$noRepl = str_ireplace("%RAWEXCERPT%", "", $noRepl);
|
220 |
+
$noRepl = str_ireplace("%SURL%", "", $noRepl);$noRepl = str_ireplace("%TEXT%", "", $noRepl);$noRepl = str_ireplace("%FULLTEXT%", "", $noRepl);$noRepl = str_ireplace("%EXCERPT%", "", $noRepl);
|
221 |
+
$noRepl = str_ireplace("%ANNOUNCE%", "", $noRepl); $noRepl = str_ireplace("%AUTHORNAME%", "", $noRepl); $twLim = $twLim - nxs_strLen($noRepl);
|
222 |
|
223 |
$pTitle = $title = $post->post_title;
|
224 |
+
if ($post->post_excerpt!="") $exrText = $post->post_excerpt; else $exrText= $post->post_content; $pText = apply_filters('the_content', $exrText);
|
225 |
+
$pRawText = $post->post_content; $pFullText = apply_filters('the_content', $pRawText);
|
|
|
|
|
226 |
if (stripos($twMsgFormat, '%TAGS%')!==false || stripos($twMsgFormat, '%HTAGS%')!==false) {
|
227 |
+
$t = wp_get_object_terms($postID, 'product_tag'); if ( empty($t) || is_wp_error($pt) || !is_array($t) ) $t = wp_get_post_tags($postID);
|
228 |
+
$tggs = array(); foreach ($t as $tagA) { $frmTag = trim(str_replace(' ','',preg_replace('/[^a-zA-Z0-9\p{L}\p{N}\s]/u', '', trim(ucwords(str_ireplace('&','',str_ireplace('&','',$tagA->name)))))));
|
229 |
if (preg_match('/\b'.$frmTag.'\b/iu', $pTitle)) $pTitle = trim(preg_replace('/\b'.$frmTag.'\b/iu', '#'.$frmTag, $pTitle));
|
230 |
if (preg_match('/\b'.$frmTag.'\b/iu', $pFullText)) $pFullText = trim(preg_replace('/\b'.$frmTag.'\b/iu', '#'.$frmTag, $pFullText));
|
231 |
if (preg_match('/\b'.$frmTag.'\b/iu', $pText)) $pText = trim(preg_replace('/\b'.$frmTag.'\b/iu', '#'.$frmTag, $pText));
|
232 |
if (preg_match('/\b'.$frmTag.'\b/iu', $pRawText)) $pRawText = trim(preg_replace('/\b'.$frmTag.'\b/iu', '#'.$frmTag, $pRawText));
|
233 |
if ( ((stripos($twMsgFormat, '%TITLE%')!==false) && preg_match('/\b'.$frmTag.'\b/i', $pTitle)) ||
|
234 |
((stripos($twMsgFormat, '%TEXT%')!==false) && preg_match('/\b'.$frmTag.'\b/i', $pText)) ||
|
235 |
+
((stripos($twMsgFormat, '%EXCERPT%')!==false) && preg_match('/\b'.$frmTag.'\b/i', $pText)) ||
|
236 |
+
((stripos($twMsgFormat, '%RAWEXCERPT%')!==false) && preg_match('/\b'.$frmTag.'\b/i', $pText)) ||
|
237 |
+
((stripos($twMsgFormat, '%ANNOUNCE%')!==false) && preg_match('/\b'.$frmTag.'\b/i', $pText)) ||
|
238 |
((stripos($twMsgFormat, '%FULLTEXT%')!==false) && preg_match('/\b'.$frmTag.'\b/i', $pFullText)) ||
|
239 |
((stripos($twMsgFormat, '%RAWTEXT%')!==false) && preg_match('/\b'.$frmTag.'\b/i', $pRawText)) ) {} else $tggs[] = '#'.$frmTag;
|
240 |
+
} $tags = implode(' ',$tggs); while(count($tags)>($twLim-10)) {array_pop($tggs); $tags = implode(' ',$tggs);} $twMsgFormat = str_ireplace("%TAGS%", $tags, $twMsgFormat); $twMsgFormat = str_ireplace("%HTAGS%", $tags, $twMsgFormat);
|
241 |
+
$twLim = $twLim - nxs_strLen($tags);
|
242 |
+
}
|
243 |
if (stripos($twMsgFormat, '%CATS%')!==false || stripos($twMsgFormat, '%HCATS%')!==false) {
|
244 |
+
$t = wp_get_post_categories($postID); $ctts = array(); foreach($t as $c){ $cat = get_category($c); $frmTag = trim(str_replace(' ','', str_replace(' ',' ',str_ireplace('&','&',trim(ucwords($cat->name))))));
|
245 |
if (stripos($pTitle, $cat->name)!==false) $pTitle = str_ireplace($cat->name, '#'.$frmTag, $pTitle); elseif (stripos($pTitle, $frmTag)!==false) $pTitle = str_ireplace($frmTag, '#'.$frmTag, $pTitle);
|
246 |
if (stripos($pText, $cat->name)!==false) $pText = str_ireplace($cat->name, '#'.$frmTag, $pText); elseif (stripos($pText, $frmTag)!==false) $pText = str_ireplace($frmTag, '#'.$frmTag, $pText);
|
247 |
if (stripos($pFullText, $cat->name)!==false) $pFullText = str_ireplace($cat->name, '#'.$frmTag, $pFullText); elseif (stripos($pFullText, $frmTag)!==false) $pFullText = str_ireplace($frmTag, '#'.$frmTag, $pFullText);
|
248 |
if (stripos($pRawText, $cat->name)!==false) $pRawText = str_ireplace($cat->name, '#'.$frmTag, $pRawText); elseif (stripos($pRawText, $frmTag)!==false) $pRawText = str_ireplace($frmTag, '#'.$frmTag, $pRawText);
|
249 |
if ( ((stripos($twMsgFormat, '%TITLE%')!==false) && (stripos($pTitle, $cat->name)!==false || stripos($pTitle, $frmTag)!==false)) ||
|
250 |
((stripos($twMsgFormat, '%TEXT%')!==false) && (stripos($pText, $cat->name)!==false || stripos($pText, $frmTag)!==false)) ||
|
251 |
+
((stripos($twMsgFormat, '%EXCERPT%')!==false) && (stripos($pText, $cat->name)!==false || stripos($pText, $frmTag)!==false)) ||
|
252 |
+
((stripos($twMsgFormat, '%RAWEXCERPT%')!==false) && (stripos($exrText, $cat->name)!==false || stripos($exrText, $frmTag)!==false)) ||
|
253 |
+
((stripos($twMsgFormat, '%ANNOUNCE%')!==false) && (stripos($pText, $cat->name)!==false || stripos($pText, $frmTag)!==false)) ||
|
254 |
((stripos($twMsgFormat, '%FULLTEXT%')!==false) && (stripos($pFullText, $cat->name)!==false || stripos($pFullText, $frmTag)!==false)) ||
|
255 |
+
((stripos($twMsgFormat, '%RAWTEXT%')!==false) && (stripos($pRawText, $cat->name)!==false || stripos($pRawText, $frmTag)!==false)) ) {} else $ctts[] = '#'.$frmTag;
|
256 |
+
} $cats = implode(' ',$ctts); while(count($cats)>($twLim-10)) {array_pop($ctts); $cats = implode(' ',$ctts);} $twMsgFormat = str_ireplace("%CATS%", $cats, $twMsgFormat); $twMsgFormat = str_ireplace("%HCATS%", $cats, $twMsgFormat);
|
257 |
+
$twLim = $twLim - nxs_strLen($cats);
|
258 |
+
}
|
259 |
if (stripos($twMsgFormat, '%TITLE%')!==false) { if (stripos($pTitle, '.co.uk')!==false) $twLim = $twLim - 14;
|
260 |
if (stripos($pTitle, '.com')!==false) $twLim = $twLim - 16; if (stripos($pTitle, '.net')!==false) $twLim = $twLim - 16; if (stripos($pTitle, '.org')!==false) $twLim = $twLim - 16;
|
261 |
$pTitle = html_entity_decode(strip_tags($pTitle), ENT_NOQUOTES, 'UTF-8');
|
262 |
+
$pTitle = nsTrnc($pTitle, $twLim); $twMsgFormat = str_ireplace("%TITLE%", $pTitle, $twMsgFormat); $twLim = $twLim - nxs_strLen($pTitle);
|
263 |
}
|
264 |
if (stripos($twMsgFormat, '%SITENAME%')!==false) {
|
265 |
+
$siteTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); $siteTitle = nsTrnc($siteTitle, $twLim); $twMsgFormat = str_ireplace("%SITENAME%", $siteTitle, $twMsgFormat); $twLim = $twLim - nxs_strLen($siteTitle);
|
266 |
+
}
|
267 |
if (stripos($twMsgFormat, '%TEXT%')!==false) {
|
268 |
+
$pText = nsTrnc(strip_tags(strip_shortcodes($pText)), 300, " ", "...");
|
269 |
+
$pText = nsTrnc($pText, $twLim); $twMsgFormat = str_ireplace("%TEXT%", $pText, $twMsgFormat); $twLim = $twLim - nxs_strLen($pText);
|
270 |
+
}
|
271 |
+
if (stripos($twMsgFormat, '%EXCERPT%')!==false) {
|
272 |
+
$pText = nsTrnc(strip_tags(strip_shortcodes($pText)), 300, " ", "...");
|
273 |
+
$pText = nsTrnc($pText, $twLim); $twMsgFormat = str_ireplace("%EXCERPT%", $pText, $twMsgFormat); $twLim = $twLim - nxs_strLen($pText);
|
274 |
+
}
|
275 |
+
if (stripos($twMsgFormat, '%RAWEXCERPT%')!==false) {
|
276 |
+
$exrText = nsTrnc(strip_tags(strip_shortcodes($exrText)), 300, " ", "...");
|
277 |
+
$exrText = nsTrnc($exrText, $twLim); $twMsgFormat = str_ireplace("%RAWEXCERPT%", $exrText, $twMsgFormat); $twLim = $twLim - nxs_strLen($exrText);
|
278 |
+
}
|
279 |
if (stripos($twMsgFormat, '%FULLTEXT%')!==false) {
|
280 |
+
$pFullText = nsTrnc(strip_tags($pFullText), $twLim); $twMsgFormat = str_ireplace("%FULLTEXT%", $pFullText, $twMsgFormat); $twLim = $twLim - nxs_strLen($pFullText);
|
281 |
}
|
282 |
if (stripos($twMsgFormat, '%RAWTEXT%')!==false) {
|
283 |
+
$pRawText = nsTrnc(strip_tags($pRawText), $twLim); $twMsgFormat = str_ireplace("%RAWTEXT%", $pRawText, $twMsgFormat); $twLim = $twLim - nxs_strLen($pRawText);
|
284 |
+
}
|
285 |
+
$msg = nsFormatMessage($twMsgFormat, $postID);
|
286 |
+
}
|
287 |
+
$msg = str_replace('&#039;', "'", $msg); $msg = str_replace(''', "'", $msg); $msg = str_replace('#039;', "'", $msg); $msg = str_replace('#039', "'", $msg);
|
288 |
+
$msg = str_replace('&#8217;', "'", $msg); $msg = str_replace('’', "'", $msg); $msg = str_replace('#8217;', "'", $msg); $msg = str_replace('#8217', "'", $msg);
|
289 |
+
$msg = str_replace('&#8220;', '"', $msg); $msg = str_replace('“', '"', $msg); $msg = str_replace('#8220;', '"', $msg); $msg = str_replace('#8220', "'", $msg);
|
290 |
+
$msg = str_replace('&#8221;', '"', $msg); $msg = str_replace('”', '"', $msg); $msg = str_replace('#8221;', '"', $msg); $msg = str_replace('#8221', "'", $msg);
|
291 |
+
$message = array('message'=>$msg, 'img'=>$img, 'urlLength'=>$nxs_urlLen); $options['twMsgFormat'] = $msg;
|
292 |
|
293 |
+
//## Actual Post
|
294 |
+
$ntToPost = new nxs_class_SNAP_TW(); $ret = $ntToPost->doPostToNT($options, $message);
|
295 |
+
//## Process Results
|
296 |
+
if (!is_array($ret) || $ret['isPosted']!='1') { //## Error
|
297 |
+
if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);
|
298 |
+
} else { // ## All Good - log it.
|
299 |
+
if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo _e('OK - Message Posted, please see your '.$logNT.' Page. ', 'nxs_snap'); }
|
300 |
+
else { nxs_addToRI($postID); nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPosted'=>'1', 'pgID'=>$ret['postID'], 'pDate'=>date('Y-m-d H:i:s'))); nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); }
|
|
|
|
|
|
|
301 |
}
|
302 |
+
//## Return Result
|
303 |
+
if ($ret['isPosted']=='1') return 200; else return print_r($ret, true);
|
304 |
+
|
305 |
}
|
306 |
}
|
307 |
|
inc-cl/vb.php
CHANGED
@@ -15,7 +15,7 @@ if (!class_exists("nxs_snapClassVB")) { class nxs_snapClassVB {
|
|
15 |
<div class="nxs_box_inside">
|
16 |
<?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
|
17 |
<p style="margin:0px;margin-left:5px;">
|
18 |
-
<input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> />
|
19 |
<strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
|
20 |
<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'nxs_snap'); ?> ==></b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>
|
21 |
<a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
|
@@ -66,12 +66,15 @@ if (!class_exists("nxs_snapClassVB")) { class nxs_snapClassVB {
|
|
66 |
|
67 |
<div id="altFormat" style="">
|
68 |
<div style="width:100%;"><strong id="altFormatText"><?php _e('Post Title Format', 'nxs_snap'); ?></strong> (<a href="#" id="apVBMsgTFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apVBMsgTFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)</div>
|
69 |
-
|
70 |
-
|
|
|
|
|
|
|
71 |
|
72 |
<div id="altFormat" style="">
|
73 |
<div style="width:100%;"><strong id="altFormatText"><?php _e('Post Text Format', 'nxs_snap'); ?></strong> (<a href="#" id="apVBMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apVBMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)</div>
|
74 |
-
<input name="vb[<?php echo $ii; ?>][apVBMsgFrmt]" id="apVBMsgFrmt" style="width: 50%;" value="<?php if ($isNew) echo "%
|
75 |
</div><br/>
|
76 |
|
77 |
<?php if ($options['vbPass']!='') { ?>
|
@@ -111,7 +114,8 @@ if (!class_exists("nxs_snapClassVB")) { class nxs_snapClassVB {
|
|
111 |
$isAvailVB = $ntOpt['vbUName']!='' && $ntOpt['vbPass']!=''; $vbMsgFormat = htmlentities($ntOpt['vbMsgFormat'], ENT_COMPAT, "UTF-8"); $vbMsgTFormat = htmlentities($ntOpt['vbMsgTFormat'], ENT_COMPAT, "UTF-8");
|
112 |
?>
|
113 |
<tr><th style="text-align:left;" colspan="2"><?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_VB<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
|
114 |
-
<?php if ($isAvailVB) { ?><input class="nxsGrpDoChb" value="1" id="doVB<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="vb[<?php echo $ii; ?>][doVB]" <?php if ((
|
|
|
115 |
|
116 |
<div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/vb16.png);">vBulletin - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
|
117 |
if ($post->post_status == "publish" && $isAvailVB) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToVB_repostButton" id="rePostToVB_button" value="<?php _e('Repost to vBulletin', 'nxs_snap') ?>" />
|
@@ -128,11 +132,13 @@ if (!class_exists("nxs_snapClassVB")) { class nxs_snapClassVB {
|
|
128 |
<?php if (!$isAvailVB) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your vBulletin Account to AutoPost to vBulletin</b>
|
129 |
<?php } elseif ($post->post_status != "puZblish") { ?>
|
130 |
|
131 |
-
<tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;"><?php _e('Text Format:', 'nxs_snap') ?></th>
|
132 |
<td><input value="<?php echo $vbMsgTFormat ?>" type="text" name="vb[<?php echo $ii; ?>][SNAPformatT]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apVBMsgTFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apVBMsgTFrmt".$ii); ?></td></tr>
|
133 |
|
134 |
-
<tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;"><?php _e('Text Format:', 'nxs_snap') ?></th>
|
135 |
-
<td
|
|
|
|
|
136 |
<?php }
|
137 |
}
|
138 |
}
|
@@ -170,7 +176,7 @@ if (!function_exists("nxs_doCheckVB")) {function nxs_doCheckVB($url){ global $nx
|
|
170 |
return false;
|
171 |
}}
|
172 |
if (!function_exists("nxs_doConnectToVB")) { function nxs_doConnectToVB($u, $p, $url){ global $nxs_vbCkArray; $hdrsArr = nxs_getVBHeaders($url, true); // echo "LOGGIN";
|
173 |
-
$response = wp_remote_get($url); if(is_wp_error($response)) {
|
174 |
$contents = $response['body']; //$response['body'] = htmlentities($response['body']); prr($response); die();
|
175 |
$ckArr = $response['cookies']; $mdhashLoc = stripos($contents, 'md5hash(vb_login_password');
|
176 |
if ($mdhashLoc===false) return "No VB found";
|
@@ -192,7 +198,7 @@ if (!function_exists("nxs_doConnectToVB")) { function nxs_doConnectToVB($u, $p,
|
|
192 |
}}
|
193 |
if (!function_exists("nxs_doPostToVB")) { function nxs_doPostToVB($url, $subj, $msg, $lnk, $tags){ global $nxs_vbCkArray; $hdrsArr = nxs_getVBHeaders($url); $ckArr = $nxs_vbCkArray;
|
194 |
$response = wp_remote_get($url, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr));
|
195 |
-
if(is_wp_error($response)) {
|
196 |
$contents = $response['body']; //$response['body'] = htmlentities($response['body']); prr($response); die();
|
197 |
if (stripos($contents, 'base href="')!==false) $baseURL = trim(CutFromTo($contents,'base href="', '"')); else { $uarr = explode('/',$url); $dd = $uarr[count($uarr)-1]; $baseURL = str_replace($dd, '', $url);}
|
198 |
if (stripos($contents, 'newthread.php?do=newthread')!==false) $mdd='t'; elseif (stripos($contents, 'newreply.php?')!==false) $mdd='p'; else return "No Thread/Post Controls found";
|
@@ -205,8 +211,7 @@ if (!function_exists("nxs_doPostToVB")) { function nxs_doPostToVB($url, $subj,
|
|
205 |
$frmTxt = substr($frmTxt, stripos($frmTxt, '<input')+8);
|
206 |
} $flds['subject'] = $subj; $flds['message'] = $msg; $flds['message_backup'] = $msg; $flds['wysiwyg'] = '1'; $flds['do'] = 'postthread'; $flds['taglist'] = $tags; $flds['parseurl'] = '1'; $flds['sbutton'] = 'Submit+New+Thread';
|
207 |
$smURL = $baseURL.'newthread.php?do=postthread'.str_replace('&','&',$fid);
|
208 |
-
}
|
209 |
-
|
210 |
if ($mdd=='p'){ $fid = CutFromTo($contents, 'newreply.php?do=newreply','"');
|
211 |
$response = wp_remote_get( $baseURL.'newreply.php?do=newreply'.str_replace('&','&',$fid), array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr)); $contents = $response['body'];
|
212 |
|
@@ -234,10 +239,14 @@ if (!function_exists("nxs_doPostToVB")) { function nxs_doPostToVB($url, $subj,
|
|
234 |
|
235 |
if (!function_exists("nxs_doPublishToVB")) { //## Second Function to Post to VB
|
236 |
function nxs_doPublishToVB($postID, $options){ global $nxs_vbCkArray; $ntCd = 'VB'; $ntCdL = 'vb'; $ntNm = 'vBulletin';
|
237 |
-
|
238 |
-
$ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
|
|
|
|
|
239 |
if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
|
240 |
-
|
|
|
|
|
241 |
}
|
242 |
|
243 |
$vbCat = $options['vbCat']; $email = $options['vbUName']; $pass = (substr($options['vbPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['vbPass'], 5)):$options['vbPass']);
|
@@ -246,8 +255,8 @@ if (!function_exists("nxs_doPublishToVB")) { //## Second Function to Post to VB
|
|
246 |
$msgFormat = $options['vbMsgFormat']; $msg = nsFormatMessage($msgFormat, $postID); $msgFormatT = $options['vbMsgTFormat']; $msgT = nsFormatMessage($msgFormatT, $postID);
|
247 |
}
|
248 |
$dusername = $options['vbUName']; //$link = urlencode($link); $desc = urlencode(substr($msg, 0, 500));
|
249 |
-
$extInfo = ' | PostID: '.$postID." - ".$post->post_title;
|
250 |
-
if ($options['vbInclTags']=='1') { $t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = urlencode(implode(',',$tggs)); $tags = str_replace(' ','+',$tags); } else $tags = '';
|
251 |
if (isset($options['vbSvC'])) $nxs_vbCkArray = maybe_unserialize( $options['vbSvC']); $loginError = true;
|
252 |
if (is_array($nxs_vbCkArray)) $loginError = nxs_doCheckVB( $options['vbURL']); if ($loginError!==false) $loginError = nxs_doConnectToVB($email, $pass, $options['vbURL']);
|
253 |
if (serialize($nxs_vbCkArray)!=$options['vbSvC']) { global $plgn_NS_SNAutoPoster; $gOptions = $plgn_NS_SNAutoPoster->nxs_options;
|
@@ -256,11 +265,11 @@ if (!function_exists("nxs_doPublishToVB")) { //## Second Function to Post to VB
|
|
256 |
if (!is_array($result) || count($result)<1) { $gOptions['vb'][$ii]['vbSvC'] = serialize($nxs_vbCkArray); update_option('NS_SNAutoPoster', $gOptions); break; }
|
257 |
}
|
258 |
} //var_dump($loginError);
|
259 |
-
if ($loginError!==false) {if ($postID=='0') prr($loginError);
|
260 |
$ret = nxs_doPostToVB($options['vbURL'], $msgT, $msg, $link, $tags);
|
261 |
-
if ( (!is_array($ret)) && $ret!='OK'){ if ($postID=='0') prr($ret);
|
262 |
-
else if ($postID=='0') {
|
263 |
-
{ nxs_metaMarkAsPosted($postID, 'VB', $options['ii'], array('isPosted'=>'1', 'pgID'=>$ret['post_id'], 'pDate'=>date('Y-m-d H:i:s')));
|
264 |
if ($ret['code']=='OK') return 200; else return $ret;
|
265 |
|
266 |
}
|
15 |
<div class="nxs_box_inside">
|
16 |
<?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
|
17 |
<p style="margin:0px;margin-left:5px;">
|
18 |
+
<input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> /> <?php if ((int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
|
19 |
<strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
|
20 |
<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'nxs_snap'); ?> ==></b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>
|
21 |
<a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
|
66 |
|
67 |
<div id="altFormat" style="">
|
68 |
<div style="width:100%;"><strong id="altFormatText"><?php _e('Post Title Format', 'nxs_snap'); ?></strong> (<a href="#" id="apVBMsgTFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apVBMsgTFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)</div>
|
69 |
+
|
70 |
+
<textarea cols="150" rows="3" id="vb<?php echo $ii; ?>SNAPformat" name="vb[<?php echo $ii; ?>][apVBMsgTFrmt]" style="width:51%;max-width: 650px;" onfocus="jQuery('#vb<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('apVBMsgTFrmt<?php echo $ii; ?>');"><?php if ($isNew) echo "%TITLE%"; else _e(apply_filters('format_to_edit', htmlentities($options['vbMsgTFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap'); ?></textarea>
|
71 |
+
|
72 |
+
<?php nxs_doShowHint("apVBMsgTFrmt".$ii); ?>
|
73 |
+
</div><br/>
|
74 |
|
75 |
<div id="altFormat" style="">
|
76 |
<div style="width:100%;"><strong id="altFormatText"><?php _e('Post Text Format', 'nxs_snap'); ?></strong> (<a href="#" id="apVBMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apVBMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)</div>
|
77 |
+
<input name="vb[<?php echo $ii; ?>][apVBMsgFrmt]" id="apVBMsgFrmt" style="width: 50%;" value="<?php if ($isNew) echo "%EXCERPT%"; else _e(apply_filters('format_to_edit', htmlentities($options['vbMsgFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap'); ?>" onfocus="mxs_showFrmtInfo('apVBMsgFrmt<?php echo $ii; ?>');" /><?php nxs_doShowHint("apVBMsgFrmt".$ii); ?>
|
78 |
</div><br/>
|
79 |
|
80 |
<?php if ($options['vbPass']!='') { ?>
|
114 |
$isAvailVB = $ntOpt['vbUName']!='' && $ntOpt['vbPass']!=''; $vbMsgFormat = htmlentities($ntOpt['vbMsgFormat'], ENT_COMPAT, "UTF-8"); $vbMsgTFormat = htmlentities($ntOpt['vbMsgTFormat'], ENT_COMPAT, "UTF-8");
|
115 |
?>
|
116 |
<tr><th style="text-align:left;" colspan="2"><?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_VB<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
|
117 |
+
<?php if ($isAvailVB) { ?><input class="nxsGrpDoChb" value="1" id="doVB<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="vb[<?php echo $ii; ?>][doVB]" <?php if ((int)$doVB == 1) echo 'checked="checked" title="def"'; ?> />
|
118 |
+
<?php if ($post->post_status == "publish") { ?> <input type="hidden" name="vb[<?php echo $ii; ?>][doVB]" value="<?php echo $doVB;?>"> <?php } ?> <?php } ?>
|
119 |
|
120 |
<div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/vb16.png);">vBulletin - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
|
121 |
if ($post->post_status == "publish" && $isAvailVB) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToVB_repostButton" id="rePostToVB_button" value="<?php _e('Repost to vBulletin', 'nxs_snap') ?>" />
|
132 |
<?php if (!$isAvailVB) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your vBulletin Account to AutoPost to vBulletin</b>
|
133 |
<?php } elseif ($post->post_status != "puZblish") { ?>
|
134 |
|
135 |
+
<tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top:6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Text Format:', 'nxs_snap') ?></th>
|
136 |
<td><input value="<?php echo $vbMsgTFormat ?>" type="text" name="vb[<?php echo $ii; ?>][SNAPformatT]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apVBMsgTFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apVBMsgTFrmt".$ii); ?></td></tr>
|
137 |
|
138 |
+
<tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top:6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Text Format:', 'nxs_snap') ?></th>
|
139 |
+
<td>
|
140 |
+
<textarea cols="150" rows="1" id="vb<?php echo $ii; ?>SNAPformat" name="vb[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('#vb<?php echo $ii; ?>SNAPformat').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apVBMsgFrmt<?php echo $ii; ?>');"><?php echo $vbMsgFormat; ?></textarea>
|
141 |
+
<?php nxs_doShowHint("apVBMsgFrmt".$ii); ?></td></tr>
|
142 |
<?php }
|
143 |
}
|
144 |
}
|
176 |
return false;
|
177 |
}}
|
178 |
if (!function_exists("nxs_doConnectToVB")) { function nxs_doConnectToVB($u, $p, $url){ global $nxs_vbCkArray; $hdrsArr = nxs_getVBHeaders($url, true); // echo "LOGGIN";
|
179 |
+
$response = wp_remote_get($url); if(is_wp_error($response)) { nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($response, true), ''); return "Invalid Connection. Please see log."; }
|
180 |
$contents = $response['body']; //$response['body'] = htmlentities($response['body']); prr($response); die();
|
181 |
$ckArr = $response['cookies']; $mdhashLoc = stripos($contents, 'md5hash(vb_login_password');
|
182 |
if ($mdhashLoc===false) return "No VB found";
|
198 |
}}
|
199 |
if (!function_exists("nxs_doPostToVB")) { function nxs_doPostToVB($url, $subj, $msg, $lnk, $tags){ global $nxs_vbCkArray; $hdrsArr = nxs_getVBHeaders($url); $ckArr = $nxs_vbCkArray;
|
200 |
$response = wp_remote_get($url, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr));
|
201 |
+
if(is_wp_error($response)) { nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($response, true), ''); return "Invalid Connection. Please see log."; }
|
202 |
$contents = $response['body']; //$response['body'] = htmlentities($response['body']); prr($response); die();
|
203 |
if (stripos($contents, 'base href="')!==false) $baseURL = trim(CutFromTo($contents,'base href="', '"')); else { $uarr = explode('/',$url); $dd = $uarr[count($uarr)-1]; $baseURL = str_replace($dd, '', $url);}
|
204 |
if (stripos($contents, 'newthread.php?do=newthread')!==false) $mdd='t'; elseif (stripos($contents, 'newreply.php?')!==false) $mdd='p'; else return "No Thread/Post Controls found";
|
211 |
$frmTxt = substr($frmTxt, stripos($frmTxt, '<input')+8);
|
212 |
} $flds['subject'] = $subj; $flds['message'] = $msg; $flds['message_backup'] = $msg; $flds['wysiwyg'] = '1'; $flds['do'] = 'postthread'; $flds['taglist'] = $tags; $flds['parseurl'] = '1'; $flds['sbutton'] = 'Submit+New+Thread';
|
213 |
$smURL = $baseURL.'newthread.php?do=postthread'.str_replace('&','&',$fid);
|
214 |
+
} //prr($flds);
|
|
|
215 |
if ($mdd=='p'){ $fid = CutFromTo($contents, 'newreply.php?do=newreply','"');
|
216 |
$response = wp_remote_get( $baseURL.'newreply.php?do=newreply'.str_replace('&','&',$fid), array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr)); $contents = $response['body'];
|
217 |
|
239 |
|
240 |
if (!function_exists("nxs_doPublishToVB")) { //## Second Function to Post to VB
|
241 |
function nxs_doPublishToVB($postID, $options){ global $nxs_vbCkArray; $ntCd = 'VB'; $ntCdL = 'vb'; $ntNm = 'vBulletin';
|
242 |
+
//if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToVB', array($postID, $options));
|
243 |
+
$ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
|
244 |
+
$logNT = '<span style="color:#000080">vBulletin</span> - '.$options['nName'];
|
245 |
+
$snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
|
246 |
if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
|
247 |
+
$snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') { sleep(5);
|
248 |
+
nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$uqID); return;
|
249 |
+
}
|
250 |
}
|
251 |
|
252 |
$vbCat = $options['vbCat']; $email = $options['vbUName']; $pass = (substr($options['vbPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['vbPass'], 5)):$options['vbPass']);
|
255 |
$msgFormat = $options['vbMsgFormat']; $msg = nsFormatMessage($msgFormat, $postID); $msgFormatT = $options['vbMsgTFormat']; $msgT = nsFormatMessage($msgFormatT, $postID);
|
256 |
}
|
257 |
$dusername = $options['vbUName']; //$link = urlencode($link); $desc = urlencode(substr($msg, 0, 500));
|
258 |
+
$extInfo = ' | PostID: '.$postID." - ".$post->post_title;
|
259 |
+
if ($options['vbInclTags']=='1') { $t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = urlencode(implode(', ',$tggs)); $tags = str_replace(' ','+',$tags); } else $tags = '';
|
260 |
if (isset($options['vbSvC'])) $nxs_vbCkArray = maybe_unserialize( $options['vbSvC']); $loginError = true;
|
261 |
if (is_array($nxs_vbCkArray)) $loginError = nxs_doCheckVB( $options['vbURL']); if ($loginError!==false) $loginError = nxs_doConnectToVB($email, $pass, $options['vbURL']);
|
262 |
if (serialize($nxs_vbCkArray)!=$options['vbSvC']) { global $plgn_NS_SNAutoPoster; $gOptions = $plgn_NS_SNAutoPoster->nxs_options;
|
265 |
if (!is_array($result) || count($result)<1) { $gOptions['vb'][$ii]['vbSvC'] = serialize($nxs_vbCkArray); update_option('NS_SNAutoPoster', $gOptions); break; }
|
266 |
}
|
267 |
} //var_dump($loginError);
|
268 |
+
if ($loginError!==false) {if ($postID=='0') prr($loginError); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($loginError, true)." - BAD USER/PASS", $extInfo); return " -= BAD USER/PASS =- ";}
|
269 |
$ret = nxs_doPostToVB($options['vbURL'], $msgT, $msg, $link, $tags);
|
270 |
+
if ( (!is_array($ret)) && $ret!='OK'){ if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);}
|
271 |
+
else if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo ' OK - Message Posted, please see your vBulletin Page '; } else
|
272 |
+
{ nxs_metaMarkAsPosted($postID, 'VB', $options['ii'], array('isPosted'=>'1', 'pgID'=>$ret['post_id'], 'pDate'=>date('Y-m-d H:i:s'))); nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); }
|
273 |
if ($ret['code']=='OK') return 200; else return $ret;
|
274 |
|
275 |
}
|
inc-cl/vk.php
CHANGED
@@ -15,7 +15,7 @@ if (!class_exists("nxs_snapClassVK")) { class nxs_snapClassVK {
|
|
15 |
<div class="nxs_box_inside">
|
16 |
<?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = str_ireplace('https://vk.com','', str_ireplace('http://vk.com','', $pbo['url'])); ?>
|
17 |
<p style="margin:0px;margin-left:5px;">
|
18 |
-
<input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> />
|
19 |
<strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
|
20 |
<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'nxs_snap'); ?> ==></b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>
|
21 |
<a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
|
@@ -87,7 +87,10 @@ if (!class_exists("nxs_snapClassVK")) { class nxs_snapClassVK {
|
|
87 |
<br/>
|
88 |
<div id="altFormat">
|
89 |
<div style="width:100%;"><strong id="altFormatText"><?php _e('Message text Format', 'nxs_snap'); ?>:</strong> (<a href="#" id="msgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('msgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)</div>
|
90 |
-
|
|
|
|
|
|
|
91 |
</div>
|
92 |
<div >
|
93 |
<input value="1" type="checkbox" name="vk[<?php echo $ii; ?>][addBackLink]" <?php if (isset($options['addBackLink']) && (int)$options['addBackLink'] == 1) echo "checked"; ?> /> <?php _e('Add backlink to the post', 'nxs_snap') ?>
|
@@ -144,7 +147,8 @@ if (!class_exists("nxs_snapClassVK")) { class nxs_snapClassVK {
|
|
144 |
$options[$ii]['vkAppAuthToken'] = trim( CutFromTo($pval['apVKAuthResp'].'&', 'access_token=','&'));
|
145 |
$options[$ii]['vkAppAuthUser'] = trim( CutFromTo($pval['apVKAuthResp']."&", 'user_id=','&'));
|
146 |
$hdrsArr = nxs_getVKHeaders($pval['url']);
|
147 |
-
$response = wp_remote_get($pval['url'], array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr));
|
|
|
148 |
if (stripos($contents, '"group_id":')!==false) { $options[$ii]['pgIntID'] = '-'.CutFromTo($contents, '"group_id":', ','); $type='all'; }
|
149 |
if (stripos($contents, '"public_id":')!==false) { $options[$ii]['pgIntID'] = '-'.CutFromTo($contents, '"public_id":', ','); $type='all'; }
|
150 |
if (stripos($contents, '"user_id":')!==false) { $options[$ii]['pgIntID'] = CutFromTo($contents, '"user_id":', ','); $type='own'; }
|
@@ -183,7 +187,8 @@ if (!class_exists("nxs_snapClassVK")) { class nxs_snapClassVK {
|
|
183 |
$isAvailVK = $ntOpt['url']!='' && $ntOpt['vkAppID']!='' || $ntOpt['uPass']!=''; $isAttachVK = $ntOpt['attch']; $msgFrmt = htmlentities($ntOpt['msgFrmt'], ENT_COMPAT, "UTF-8"); $postType = $ntOpt['postType'];
|
184 |
?>
|
185 |
<tr><th style="text-align:left;" colspan="2"> <?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_VK<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
|
186 |
-
<?php if ($isAvailVK) { ?><input class="nxsGrpDoChb" value="1" id="doVK<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="vk[<?php echo $ii; ?>][doVK]" <?php if ((
|
|
|
187 |
<div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/vk16.png);">vKontakte(VK) - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th>
|
188 |
<td><?php //## Only show RePost button if the post is "published"
|
189 |
if ($post->post_status == "publish" && $isAvailVK) { ?>
|
@@ -196,8 +201,11 @@ if (!class_exists("nxs_snapClassVK")) { class nxs_snapClassVK {
|
|
196 |
</td></tr>
|
197 |
<?php if (!$isAvailVK) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup and Authorize your vKontakte(VK) Account to AutoPost to vKontakte(VK)</b>
|
198 |
<?php } elseif ($post->post_status != "puZblish") {?>
|
199 |
-
<tr id="altFormat1" style=""><th scope="row" valign="top" style="text-align:right; width:60px; padding-right:10px;"><?php _e('Message Format:', 'nxs_snap') ?></th>
|
200 |
-
<td
|
|
|
|
|
|
|
201 |
<br/><div ><input value="0" type="hidden" name="vk[<?php echo $ii; ?>][addBackLink]" />
|
202 |
<input value="1" type="checkbox" name="vk[<?php echo $ii; ?>][addBackLink]" <?php if (isset($ntOpt['addBackLink']) && (int)$ntOpt['addBackLink'] == 1) echo "checked"; ?> /> <?php _e('Add backlink to the post', 'nxs_snap') ?>
|
203 |
</div>
|
@@ -244,24 +252,25 @@ if (!function_exists("nxs_getVKHeaders")) { function nxs_getVKHeaders($ref, $po
|
|
244 |
}}
|
245 |
|
246 |
if (!function_exists("nxs_uplImgtoVK")) { function nxs_uplImgtoVK($imgURL, $options){
|
247 |
-
$postUrl = 'https://api.vkontakte.ru/method/photos.getWallUploadServer?gid='
|
248 |
$response = wp_remote_get($postUrl); $thumbUploadUrl = $response['body'];
|
249 |
if (!empty($thumbUploadUrl)) { $thumbUploadUrlObj = json_decode($thumbUploadUrl); $VKuploadUrl = $thumbUploadUrlObj->response->upload_url; }
|
250 |
if (!empty($VKuploadUrl)) {
|
251 |
$remImgURL = urldecode($imgURL); $urlParced = pathinfo($remImgURL); $remImgURLFilename = $urlParced['basename']; $imgData = wp_remote_get($remImgURL); $imgData = $imgData['body'];
|
252 |
$tmp=array_search('uri', @array_flip(stream_get_meta_data($GLOBALS[mt_rand()]=tmpfile())));
|
|
|
253 |
rename($tmp, $tmp.='.png'); register_shutdown_function(create_function('', "unlink('{$tmp}');"));
|
254 |
file_put_contents($tmp, $imgData);
|
255 |
|
256 |
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $VKuploadUrl); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
257 |
-
curl_setopt($ch, CURLOPT_POSTFIELDS, array('photo' => '@' . $tmp)); $response = curl_exec($ch); $errmsg = curl_error($ch); curl_close($ch);
|
258 |
|
259 |
-
$uploadResultObj = json_decode($response);
|
260 |
|
261 |
if (!empty($uploadResultObj->server) && !empty($uploadResultObj->photo) && !empty($uploadResultObj->hash)) {
|
262 |
-
$postUrl = 'https://api.vkontakte.ru/method/photos.saveWallPhoto?server='.$uploadResultObj->server.'&photo='.$uploadResultObj->photo.'&hash='.$uploadResultObj->hash.'&gid='
|
263 |
$response = wp_remote_get($postUrl);
|
264 |
-
$resultObject = json_decode($response['body'])
|
265 |
if (isset($resultObject) && isset($resultObject->response[0]->id)) { return $resultObject->response[0]; } else { return false; }
|
266 |
}
|
267 |
}
|
@@ -269,19 +278,33 @@ if (!function_exists("nxs_uplImgtoVK")) { function nxs_uplImgtoVK($imgURL, $opt
|
|
269 |
|
270 |
if (!function_exists("nxs_doPublishToVK")) { //## Second Function to Post to VK
|
271 |
function nxs_doPublishToVK($postID, $options){ global $ShownAds, $nxs_vkCkArray; $ntCd = 'VK'; $ntCdL = 'vk'; $ntNm = 'vKontakte(VK)';
|
272 |
-
|
|
|
|
|
|
|
273 |
if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
|
274 |
-
|
|
|
|
|
275 |
}
|
276 |
$email = $options['uName']; $pass = (substr($options['uPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['uPass'], 5)):$options['uPass']);
|
277 |
if ($postID=='0') { echo "Testing ... <br/><br/>"; $link = home_url(); $msg = 'Test Link from '.$link; } else { $post = get_post($postID); if(!$post) return;
|
278 |
-
$msgFormat = $options['msgFrmt']; $msg = nsFormatMessage($msgFormat, $postID); $link = get_permalink($postID); nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
|
279 |
}
|
280 |
$dusername = $options['uName']; $postType = $options['postType']; //$link = urlencode($link); $desc = urlencode(substr($msg, 0, 500));
|
281 |
-
$extInfo = ' | PostID: '.$postID." - ".$post->post_title
|
282 |
|
283 |
-
$
|
284 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
285 |
if ($postType=='A' && $link!='') {
|
286 |
//## Login
|
287 |
if (isset($options['vkSvC'])) $nxs_vkCkArray = maybe_unserialize( $options['vkSvC']); $loginError = true;
|
@@ -292,7 +315,7 @@ if (!function_exists("nxs_doPublishToVK")) { //## Second Function to Post to VK
|
|
292 |
if (!is_array($result) || count($result)<1) { $gOptions['vk'][$ii]['vkSvC'] = serialize($nxs_vkCkArray); update_option('NS_SNAutoPoster', $gOptions); break; }
|
293 |
}
|
294 |
}
|
295 |
-
if ($loginError!==false) {if ($postID=='0') prr($loginError);
|
296 |
//## Post
|
297 |
if (trim($fbMsgAFormat)!='') {$dsc = nsFormatMessage($fbMsgAFormat, $postID);} else { if (function_exists('aioseop_mrt_fix_meta') && $dsc=='') $dsc = trim(get_post_meta($postID, '_aioseop_description', true));
|
298 |
if (function_exists('wpseo_admin_init') && $dsc=='') $dsc = trim(get_post_meta($postID, '_yoast_wpseo_opengraph-description', true));
|
@@ -301,22 +324,25 @@ if (!function_exists("nxs_doPublishToVK")) { //## Second Function to Post to VK
|
|
301 |
if ($dsc=='') $dsc = trim(apply_filters('the_content', nxs_doQTrans($post->post_content, $lng))); if ($dsc=='') $dsc = trim(nxs_doQTrans($post->post_content, $lng));
|
302 |
if ($dsc=='') $dsc = get_bloginfo('description');
|
303 |
} $dsc = strip_tags($dsc); $dsc = nxs_decodeEntitiesFull($dsc); $dsc = nsTrnc($dsc, 900, ' ');
|
304 |
-
$msgOpts['url'] = $link; $msgOpts['urlTitle'] = nxs_doQTrans($post->post_title, $lng); $msgOpts['urlDesc'] = $dsc; $msgOpts['imgURL'] = $imgURL;
|
305 |
$ret = nxs_doPostToVK($msg, $options['url'], $msgOpts); // prr($ret);
|
306 |
-
}
|
307 |
-
|
|
|
308 |
if ($postType!='A') { if( $options['addBackLink']=='1') $atts[] = $link;
|
309 |
if (is_array($atts)) $atts = implode(',', $atts);
|
310 |
-
|
311 |
-
$
|
|
|
|
|
312 |
if ( is_wp_error($response) || (is_object($response) && (isset($response->errors))) || (is_array($response) && stripos($response['body'],'"error":')!==false )) {
|
313 |
$ret = $response['body'];
|
314 |
} else { $respJ = json_decode($response['body'], true); $ret = array("code"=>"OK", "post_id"=>$options['pgIntID'].'_'.$respJ['response']['post_id']); }
|
315 |
|
316 |
}
|
317 |
-
if (is_array($ret) && $ret['code']=='OK') { if ($postID=='0') {
|
318 |
-
{ nxs_metaMarkAsPosted($postID, 'VK', $options['ii'], array('isPosted'=>'1', 'pgID'=>$ret['post_id'], 'pDate'=>date('Y-m-d H:i:s')));
|
319 |
-
} else {if ($postID=='0') prr($ret);
|
320 |
}
|
321 |
}
|
322 |
?>
|
15 |
<div class="nxs_box_inside">
|
16 |
<?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = str_ireplace('https://vk.com','', str_ireplace('http://vk.com','', $pbo['url'])); ?>
|
17 |
<p style="margin:0px;margin-left:5px;">
|
18 |
+
<input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> /> <?php if ((int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
|
19 |
<strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
|
20 |
<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'nxs_snap'); ?> ==></b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>
|
21 |
<a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
|
87 |
<br/>
|
88 |
<div id="altFormat">
|
89 |
<div style="width:100%;"><strong id="altFormatText"><?php _e('Message text Format', 'nxs_snap'); ?>:</strong> (<a href="#" id="msgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('msgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)</div>
|
90 |
+
|
91 |
+
<textarea cols="150" rows="3" id="vkmsgFrmt<?php echo $ii; ?>" name="vk[<?php echo $ii; ?>][msgFrmt]" style="width:51%;max-width: 650px;" onfocus="jQuery('#vk<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('msgFrmt<?php echo $ii; ?>');"><?php _e(apply_filters('format_to_edit', htmlentities($options['msgFrmt'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?></textarea>
|
92 |
+
|
93 |
+
<?php nxs_doShowHint("msgFrmt".$ii); ?><br/>
|
94 |
</div>
|
95 |
<div >
|
96 |
<input value="1" type="checkbox" name="vk[<?php echo $ii; ?>][addBackLink]" <?php if (isset($options['addBackLink']) && (int)$options['addBackLink'] == 1) echo "checked"; ?> /> <?php _e('Add backlink to the post', 'nxs_snap') ?>
|
147 |
$options[$ii]['vkAppAuthToken'] = trim( CutFromTo($pval['apVKAuthResp'].'&', 'access_token=','&'));
|
148 |
$options[$ii]['vkAppAuthUser'] = trim( CutFromTo($pval['apVKAuthResp']."&", 'user_id=','&'));
|
149 |
$hdrsArr = nxs_getVKHeaders($pval['url']);
|
150 |
+
$response = wp_remote_get($pval['url'], array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr));
|
151 |
+
if (is_wp_error($response)) { echo "ERROR: <br/>"; prr($response); return;} $contents = $response['body'];
|
152 |
if (stripos($contents, '"group_id":')!==false) { $options[$ii]['pgIntID'] = '-'.CutFromTo($contents, '"group_id":', ','); $type='all'; }
|
153 |
if (stripos($contents, '"public_id":')!==false) { $options[$ii]['pgIntID'] = '-'.CutFromTo($contents, '"public_id":', ','); $type='all'; }
|
154 |
if (stripos($contents, '"user_id":')!==false) { $options[$ii]['pgIntID'] = CutFromTo($contents, '"user_id":', ','); $type='own'; }
|
187 |
$isAvailVK = $ntOpt['url']!='' && $ntOpt['vkAppID']!='' || $ntOpt['uPass']!=''; $isAttachVK = $ntOpt['attch']; $msgFrmt = htmlentities($ntOpt['msgFrmt'], ENT_COMPAT, "UTF-8"); $postType = $ntOpt['postType'];
|
188 |
?>
|
189 |
<tr><th style="text-align:left;" colspan="2"> <?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_VK<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
|
190 |
+
<?php if ($isAvailVK) { ?><input class="nxsGrpDoChb" value="1" id="doVK<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="vk[<?php echo $ii; ?>][doVK]" <?php if ((int)$doVK == 1) echo 'checked="checked" title="def"'; ?> />
|
191 |
+
<?php if ($post->post_status == "publish") { ?> <input type="hidden" name="vk[<?php echo $ii; ?>][doVK]" value="<?php echo $doVK;?>"> <?php } ?> <?php } ?>
|
192 |
<div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/vk16.png);">vKontakte(VK) - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th>
|
193 |
<td><?php //## Only show RePost button if the post is "published"
|
194 |
if ($post->post_status == "publish" && $isAvailVK) { ?>
|
201 |
</td></tr>
|
202 |
<?php if (!$isAvailVK) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup and Authorize your vKontakte(VK) Account to AutoPost to vKontakte(VK)</b>
|
203 |
<?php } elseif ($post->post_status != "puZblish") {?>
|
204 |
+
<tr id="altFormat1" style=""><th scope="row" valign="top" style="vertical-align:top; padding-top:6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Message Format:', 'nxs_snap') ?></th>
|
205 |
+
<td>
|
206 |
+
<textarea cols="150" rows="1" id="vk<?php echo $ii; ?>SNAPformat" name="vk[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('#vk<?php echo $ii; ?>SNAPformat').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apVKTMsgFrmt<?php echo $ii; ?>');"><?php echo $msgFrmt; ?></textarea>
|
207 |
+
|
208 |
+
<?php nxs_doShowHint("apVKTMsgFrmt".$ii); ?>
|
209 |
<br/><div ><input value="0" type="hidden" name="vk[<?php echo $ii; ?>][addBackLink]" />
|
210 |
<input value="1" type="checkbox" name="vk[<?php echo $ii; ?>][addBackLink]" <?php if (isset($ntOpt['addBackLink']) && (int)$ntOpt['addBackLink'] == 1) echo "checked"; ?> /> <?php _e('Add backlink to the post', 'nxs_snap') ?>
|
211 |
</div>
|
252 |
}}
|
253 |
|
254 |
if (!function_exists("nxs_uplImgtoVK")) { function nxs_uplImgtoVK($imgURL, $options){
|
255 |
+
$postUrl = 'https://api.vkontakte.ru/method/photos.getWallUploadServer?gid='.(str_replace('-','',$options['pgIntID'])).'&access_token='.$options['vkAppAuthToken'];
|
256 |
$response = wp_remote_get($postUrl); $thumbUploadUrl = $response['body'];
|
257 |
if (!empty($thumbUploadUrl)) { $thumbUploadUrlObj = json_decode($thumbUploadUrl); $VKuploadUrl = $thumbUploadUrlObj->response->upload_url; }
|
258 |
if (!empty($VKuploadUrl)) {
|
259 |
$remImgURL = urldecode($imgURL); $urlParced = pathinfo($remImgURL); $remImgURLFilename = $urlParced['basename']; $imgData = wp_remote_get($remImgURL); $imgData = $imgData['body'];
|
260 |
$tmp=array_search('uri', @array_flip(stream_get_meta_data($GLOBALS[mt_rand()]=tmpfile())));
|
261 |
+
if (!is_writable($tmp)) return "Your temporary folder or file (file - ".$tmp.") is not witable. Can't upload image to VK";
|
262 |
rename($tmp, $tmp.='.png'); register_shutdown_function(create_function('', "unlink('{$tmp}');"));
|
263 |
file_put_contents($tmp, $imgData);
|
264 |
|
265 |
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $VKuploadUrl); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
266 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, array('photo' => '@' . $tmp)); $response = curl_exec($ch); $errmsg = curl_error($ch); curl_close($ch); //prr($response);
|
267 |
|
268 |
+
$uploadResultObj = json_decode($response); // prr($response); //prr($uploadResultObj);
|
269 |
|
270 |
if (!empty($uploadResultObj->server) && !empty($uploadResultObj->photo) && !empty($uploadResultObj->hash)) {
|
271 |
+
$postUrl = 'https://api.vkontakte.ru/method/photos.saveWallPhoto?server='.$uploadResultObj->server.'&photo='.$uploadResultObj->photo.'&hash='.$uploadResultObj->hash.'&gid='.(str_replace('-','',$options['pgIntID'])).'&access_token='.$options['vkAppAuthToken'];
|
272 |
$response = wp_remote_get($postUrl);
|
273 |
+
$resultObject = json_decode($response['body']); //prr($resultObject);
|
274 |
if (isset($resultObject) && isset($resultObject->response[0]->id)) { return $resultObject->response[0]; } else { return false; }
|
275 |
}
|
276 |
}
|
278 |
|
279 |
if (!function_exists("nxs_doPublishToVK")) { //## Second Function to Post to VK
|
280 |
function nxs_doPublishToVK($postID, $options){ global $ShownAds, $nxs_vkCkArray; $ntCd = 'VK'; $ntCdL = 'vk'; $ntNm = 'vKontakte(VK)';
|
281 |
+
//if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToVK', array($postID, $options));
|
282 |
+
$ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
|
283 |
+
$logNT = '<span style="color:#000080">vKontakte</span> - '.$options['nName'];
|
284 |
+
$snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
|
285 |
if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
|
286 |
+
$snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') {
|
287 |
+
nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$options['pType']); return;
|
288 |
+
}
|
289 |
}
|
290 |
$email = $options['uName']; $pass = (substr($options['uPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['uPass'], 5)):$options['uPass']);
|
291 |
if ($postID=='0') { echo "Testing ... <br/><br/>"; $link = home_url(); $msg = 'Test Link from '.$link; } else { $post = get_post($postID); if(!$post) return;
|
292 |
+
$msgFormat = $options['msgFrmt']; $msg = strip_tags(nsFormatMessage($msgFormat, $postID)); $link = get_permalink($postID); nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
|
293 |
}
|
294 |
$dusername = $options['uName']; $postType = $options['postType']; //$link = urlencode($link); $desc = urlencode(substr($msg, 0, 500));
|
295 |
+
$extInfo = ' | PostID: '.$postID." - ".$post->post_title.' |'.$options['pType']; $imgURL = nxs_getPostImage($postID);
|
296 |
|
297 |
+
$vids = nsFindVidsInPost($post); if (count($vids)>0) {
|
298 |
+
if (strlen($vids[0])==11) { $vidURL = 'http://www.youtube.com/watch?v='.$vids[0]; $imgURL = 'http://img.youtube.com/vi/'.$vids[0].'/maxresdefault.jpg'; }
|
299 |
+
if (strlen($vids[0])==8) { $vidURL = 'https://secure.vimeo.com/moogaloop.swf?clip_id='.$vids[0].'&autoplay=1';
|
300 |
+
//$mssg['source'] = 'http://player.vimeo.com/video/'.$vids[0];
|
301 |
+
$apiURL = "http://vimeo.com/api/v2/video/".$vids[0].".json?callback=showThumb"; $json = wp_remote_get($apiURL);
|
302 |
+
if (!is_wp_error($json)) { $json = $json['body']; $json = str_replace('showThumb(','',$json); $json = str_replace('])',']',$json); $json = json_decode($json, true); $imgURL = $json[0]['thumbnail_large']; }
|
303 |
+
}
|
304 |
+
}
|
305 |
+
$msgOpts = array(); $msgOpts['uid'] = $options['vkPgID']; // if ($link!='') $msgOpts['link'] = $link;
|
306 |
+
if ($vidURL!='' && $postType=="I") { $postType='A'; $link=$vidURL; $msgOpts['vID'] = $vids[0]; }
|
307 |
+
if ($postType=='I' && trim($imgURL)=='') $postType='T'; $msgOpts['type'] = $postType;
|
308 |
if ($postType=='A' && $link!='') {
|
309 |
//## Login
|
310 |
if (isset($options['vkSvC'])) $nxs_vkCkArray = maybe_unserialize( $options['vkSvC']); $loginError = true;
|
315 |
if (!is_array($result) || count($result)<1) { $gOptions['vk'][$ii]['vkSvC'] = serialize($nxs_vkCkArray); update_option('NS_SNAutoPoster', $gOptions); break; }
|
316 |
}
|
317 |
}
|
318 |
+
if ($loginError!==false) {if ($postID=='0') prr($loginError); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($loginError, true)." - BAD USER/PASS", $extInfo); return " -= BAD USER/PASS =- ";}
|
319 |
//## Post
|
320 |
if (trim($fbMsgAFormat)!='') {$dsc = nsFormatMessage($fbMsgAFormat, $postID);} else { if (function_exists('aioseop_mrt_fix_meta') && $dsc=='') $dsc = trim(get_post_meta($postID, '_aioseop_description', true));
|
321 |
if (function_exists('wpseo_admin_init') && $dsc=='') $dsc = trim(get_post_meta($postID, '_yoast_wpseo_opengraph-description', true));
|
324 |
if ($dsc=='') $dsc = trim(apply_filters('the_content', nxs_doQTrans($post->post_content, $lng))); if ($dsc=='') $dsc = trim(nxs_doQTrans($post->post_content, $lng));
|
325 |
if ($dsc=='') $dsc = get_bloginfo('description');
|
326 |
} $dsc = strip_tags($dsc); $dsc = nxs_decodeEntitiesFull($dsc); $dsc = nsTrnc($dsc, 900, ' ');
|
327 |
+
$msgOpts['url'] = $link; $msgOpts['urlTitle'] = nxs_doQTrans($post->post_title, $lng); $msgOpts['urlDesc'] = $dsc; $msgOpts['imgURL'] = $imgURL;
|
328 |
$ret = nxs_doPostToVK($msg, $options['url'], $msgOpts); // prr($ret);
|
329 |
+
} //prr($postType);
|
330 |
+
|
331 |
+
if ($postType=='I') { $imgUpld = nxs_uplImgtoVK($imgURL, $options); if (is_object($imgUpld)) { $imgID = $imgUpld->id; $atts[] = $imgID; } else nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($imgUpld, true), $extInfo); }
|
332 |
if ($postType!='A') { if( $options['addBackLink']=='1') $atts[] = $link;
|
333 |
if (is_array($atts)) $atts = implode(',', $atts);
|
334 |
+
|
335 |
+
$postUrl = 'https://api.vkontakte.ru/method/wall.post';
|
336 |
+
$postArr = array('owner_id'=>$options['pgIntID'], 'access_token'=>$options['vkAppAuthToken'], 'from_group'=>'1', 'message'=>$msg, 'attachment'=>$atts);
|
337 |
+
$response = wp_remote_post($postUrl, array('body' => $postArr));
|
338 |
if ( is_wp_error($response) || (is_object($response) && (isset($response->errors))) || (is_array($response) && stripos($response['body'],'"error":')!==false )) {
|
339 |
$ret = $response['body'];
|
340 |
} else { $respJ = json_decode($response['body'], true); $ret = array("code"=>"OK", "post_id"=>$options['pgIntID'].'_'.$respJ['response']['post_id']); }
|
341 |
|
342 |
}
|
343 |
+
if (is_array($ret) && $ret['code']=='OK') { if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo ' OK - Message Posted, please see your VK Page '; } else
|
344 |
+
{ nxs_metaMarkAsPosted($postID, 'VK', $options['ii'], array('isPosted'=>'1', 'pgID'=>$ret['post_id'], 'pDate'=>date('Y-m-d H:i:s'))); nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); return 200; }
|
345 |
+
} else {if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);}
|
346 |
}
|
347 |
}
|
348 |
?>
|
inc-cl/wp.php
CHANGED
@@ -15,7 +15,7 @@ if (!class_exists("nxs_snapClassWP")) { class nxs_snapClassWP {
|
|
15 |
<div class="nxs_box_inside">
|
16 |
<?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = str_ireplace('/xmlrpc.php','', str_ireplace('http://','', str_ireplace('https://','', $pbo['wpURL']))); ?>
|
17 |
<p style="margin:0px;margin-left:5px;">
|
18 |
-
<input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> />
|
19 |
<strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
|
20 |
<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'nxs_snap'); ?> ==></b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>
|
21 |
<a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
|
@@ -54,15 +54,24 @@ if (!class_exists("nxs_snapClassWP")) { class nxs_snapClassWP {
|
|
54 |
|
55 |
<?php if ($isNew) { ?> <input type="hidden" name="wp[<?php echo $ii; ?>][apDoWP]" value="1" id="apDoNewWP<?php echo $ii; ?>" /> <?php } ?>
|
56 |
|
57 |
-
<br
|
58 |
-
|
59 |
<div id="altFormat" style="">
|
60 |
<div style="width:100%;"><strong id="altFormatText"><?php _e('Post Title Format', 'nxs_snap'); ?></strong>
|
61 |
-
|
|
|
|
|
|
|
62 |
</div>
|
63 |
<div id="altFormat" style="">
|
64 |
<div style="width:100%;"><strong id="altFormatText"><?php _e('Post Text Format', 'nxs_snap'); ?></strong>
|
65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
</div><br/>
|
67 |
|
68 |
<?php if ($gpo['wpPass']!='') { ?>
|
@@ -100,7 +109,8 @@ if (!class_exists("nxs_snapClassWP")) { class nxs_snapClassWP {
|
|
100 |
$isAvailWP = $ntOpt['wpUName']!='' && $ntOpt['wpPass']!=''; $wpMsgFormat = htmlentities($ntOpt['wpMsgFormat'], ENT_COMPAT, "UTF-8"); $wpMsgTFormat = htmlentities($ntOpt['wpMsgTFormat'], ENT_COMPAT, "UTF-8");
|
101 |
?>
|
102 |
<tr><th style="text-align:left;" colspan="2"><?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_WP<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
|
103 |
-
<?php if ($isAvailWP) { ?><input class="nxsGrpDoChb" value="1" id="doWP<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="wp[<?php echo $ii; ?>][doWP]" <?php if ((
|
|
|
104 |
<div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/wp16.png);">WP Blog - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
|
105 |
if ($post->post_status == "publish" && $isAvailWP) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToWP_repostButton" id="rePostToWP_button" value="<?php _e('Repost to WP Blog', 'nxs_snap') ?>" />
|
106 |
<?php wp_nonce_field( 'rePostToWP', 'rePostToWP_wpnonce' ); } ?>
|
@@ -116,11 +126,13 @@ if (!class_exists("nxs_snapClassWP")) { class nxs_snapClassWP {
|
|
116 |
<?php if (!$isAvailWP) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your WP Blog Account to AutoPost to WP Blogs</b>
|
117 |
<?php } elseif ($post->post_status != "puZblish") { ?>
|
118 |
|
119 |
-
<tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;"><?php _e('Title Format:', 'nxs_snap') ?></th>
|
120 |
<td><input value="<?php echo $wpMsgTFormat ?>" type="text" name="wp[<?php echo $ii; ?>][SNAPformatT]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apWPTMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apWPTMsgFrmt".$ii); ?></td></tr>
|
121 |
|
122 |
-
<tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;"><?php _e('Text Format:', 'nxs_snap') ?></th>
|
123 |
-
<td
|
|
|
|
|
124 |
|
125 |
<?php }
|
126 |
}
|
@@ -146,10 +158,14 @@ if (!function_exists("nxs_rePostToWP_ajax")) {
|
|
146 |
|
147 |
if (!function_exists("nxs_doPublishToWP")) { //## Second Function to Post to WP
|
148 |
function nxs_doPublishToWP($postID, $options){ $ntCd = 'WP'; $ntCdL = 'wp'; $ntNm = 'WP Based Blog';
|
149 |
-
|
150 |
-
$ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
|
|
|
|
|
151 |
if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
|
152 |
-
|
|
|
|
|
153 |
}
|
154 |
$imgURL = nxs_getPostImage($postID);
|
155 |
$email = $options['wpUName']; $pass = substr($options['wpPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['wpPass'], 5)):$options['wpPass'];
|
@@ -174,14 +190,14 @@ if (!function_exists("nxs_doPublishToWP")) { //## Second Function to Post to WP
|
|
174 |
if (!$nxsToWPclient->query('wp.getOptions', $params)) { $ret = 'Something went wrong - '.$nxsToWPclient->getErrorCode().' : '.$nxsToWPclient->getErrorMessage();} else $ret = 'OK';
|
175 |
$rwpOpt = $nxsToWPclient->getResponse(); $rwpOpt = $rwpOpt['software_version']['value']; $rwpOpt = floatval($rwpOpt); //prr($rwpOpt);prr($nxsToWPclient);
|
176 |
|
177 |
-
$extInfo = ' | PostID: '.$postID." - ".$post->post_title;
|
178 |
|
179 |
if ($rwpOpt==0) {
|
180 |
$errMsg = $nxsToWPclient->getErrorMessage(); if ($errMsg!='') $ret = $errMsg; else $ret = 'XMLRPC is not found or not active. WP admin - Settings - Writing - Enable XML-RPC';
|
181 |
} else if ($rwpOpt<3.0) $ret = 'XMLRPC is too OLD - '.$rwpOpt.' You need at least 3.0'; else {
|
182 |
|
183 |
if ($rwpOpt>3.3){
|
184 |
-
$nxsToWPContent = array('title'=>$msgT, 'description'=>$msg, 'post_status'=>'draft', 'mt_allow_comments'=>1, 'mt_allow_pings'=>1, 'post_type'=>'post', 'mt_keywords'=>$tags, 'categories'=>($cats), 'custom_fields' => $customfields);
|
185 |
$params = array(0, $options['wpUName'], $pass, $nxsToWPContent, true);
|
186 |
if (!$nxsToWPclient->query('metaWeblog.newPost', $params)) { $ret = 'Something went wrong - '.$nxsToWPclient->getErrorCode().' : '.$nxsToWPclient->getErrorMessage();} else $ret = 'OK';
|
187 |
$pid = $nxsToWPclient->getResponse();
|
@@ -199,9 +215,12 @@ if (!function_exists("nxs_doPublishToWP")) { //## Second Function to Post to WP
|
|
199 |
$pid = $nxsToWPclient->getResponse();
|
200 |
}
|
201 |
} if ($ret!='OK') { if ($postID=='0') echo $ret;
|
202 |
-
|
203 |
-
} else { if ($postID=='0') { echo 'OK - Message Posted, please see your WP Blog';
|
204 |
-
{ nxs_metaMarkAsPosted($postID, 'WP', $options['ii'], array('isPosted'=>'1', 'pgID'=>$pid, 'pDate'=>date('Y-m-d H:i:s')));
|
|
|
|
|
|
|
205 |
if ($ret == 'OK') return 200; else return $ret;
|
206 |
}
|
207 |
}
|
15 |
<div class="nxs_box_inside">
|
16 |
<?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = str_ireplace('/xmlrpc.php','', str_ireplace('http://','', str_ireplace('https://','', $pbo['wpURL']))); ?>
|
17 |
<p style="margin:0px;margin-left:5px;">
|
18 |
+
<input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> /> <?php if ((int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
|
19 |
<strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
|
20 |
<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'nxs_snap'); ?> ==></b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>
|
21 |
<a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
|
54 |
|
55 |
<?php if ($isNew) { ?> <input type="hidden" name="wp[<?php echo $ii; ?>][apDoWP]" value="1" id="apDoNewWP<?php echo $ii; ?>" /> <?php } ?>
|
56 |
|
57 |
+
<br/>
|
58 |
+
|
59 |
<div id="altFormat" style="">
|
60 |
<div style="width:100%;"><strong id="altFormatText"><?php _e('Post Title Format', 'nxs_snap'); ?></strong>
|
61 |
+
(<a href="#" id="apWPMsgTFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apWPMsgTFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)
|
62 |
+
</div>
|
63 |
+
<input name="wp[<?php echo $ii; ?>][apWPMsgTFrmt]" id="apWPMsgTFrmt" style="width: 50%;" onfocus="mxs_showFrmtInfo('apWPMsgTFrmt<?php echo $ii; ?>');" value="<?php if ($isNew) echo "%TITLE%"; else _e(apply_filters('format_to_edit', htmlentities($gpo['wpMsgTFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap'); ?>" /> <?php nxs_doShowHint("apWPMsgTFrmt".$ii); ?>
|
64 |
+
|
65 |
</div>
|
66 |
<div id="altFormat" style="">
|
67 |
<div style="width:100%;"><strong id="altFormatText"><?php _e('Post Text Format', 'nxs_snap'); ?></strong>
|
68 |
+
(<a href="#" id="apWPMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apWPMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)
|
69 |
+
</div>
|
70 |
+
|
71 |
+
|
72 |
+
<textarea cols="150" rows="3" id="wp<?php echo $ii; ?>SNAPformat" name="wp[<?php echo $ii; ?>][apWPMsgFrmt]" style="width:51%;max-width: 650px;" onfocus="jQuery('#wp<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('apWPMsgFrmt<?php echo $ii; ?>');"><?php if ($isNew) echo "%EXCERPT%"; else _e(apply_filters('format_to_edit', htmlentities($gpo['wpMsgFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap'); ?></textarea>
|
73 |
+
<?php nxs_doShowHint("apWPMsgFrmt".$ii); ?>
|
74 |
+
|
75 |
</div><br/>
|
76 |
|
77 |
<?php if ($gpo['wpPass']!='') { ?>
|
109 |
$isAvailWP = $ntOpt['wpUName']!='' && $ntOpt['wpPass']!=''; $wpMsgFormat = htmlentities($ntOpt['wpMsgFormat'], ENT_COMPAT, "UTF-8"); $wpMsgTFormat = htmlentities($ntOpt['wpMsgTFormat'], ENT_COMPAT, "UTF-8");
|
110 |
?>
|
111 |
<tr><th style="text-align:left;" colspan="2"><?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_WP<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
|
112 |
+
<?php if ($isAvailWP) { ?><input class="nxsGrpDoChb" value="1" id="doWP<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="wp[<?php echo $ii; ?>][doWP]" <?php if ((int)$doWP == 1 ) echo 'checked="checked" title="def"'; ?> />
|
113 |
+
<?php if ($post->post_status == "publish") { ?> <input type="hidden" name="wp[<?php echo $ii; ?>][doWP]" value="<?php echo $doWP;?>"> <?php } ?> <?php } ?>
|
114 |
<div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/wp16.png);">WP Blog - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
|
115 |
if ($post->post_status == "publish" && $isAvailWP) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToWP_repostButton" id="rePostToWP_button" value="<?php _e('Repost to WP Blog', 'nxs_snap') ?>" />
|
116 |
<?php wp_nonce_field( 'rePostToWP', 'rePostToWP_wpnonce' ); } ?>
|
126 |
<?php if (!$isAvailWP) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your WP Blog Account to AutoPost to WP Blogs</b>
|
127 |
<?php } elseif ($post->post_status != "puZblish") { ?>
|
128 |
|
129 |
+
<tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top:6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Title Format:', 'nxs_snap') ?></th>
|
130 |
<td><input value="<?php echo $wpMsgTFormat ?>" type="text" name="wp[<?php echo $ii; ?>][SNAPformatT]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apWPTMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apWPTMsgFrmt".$ii); ?></td></tr>
|
131 |
|
132 |
+
<tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top:6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Text Format:', 'nxs_snap') ?></th>
|
133 |
+
<td>
|
134 |
+
<textarea cols="150" rows="1" id="wp<?php echo $ii; ?>SNAPformat" name="wp[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('#wp<?php echo $ii; ?>SNAPformat').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apWPMsgFrmt<?php echo $ii; ?>');"><?php echo $wpMsgFormat; ?></textarea>
|
135 |
+
<?php nxs_doShowHint("apWPMsgFrmt".$ii); ?></td></tr>
|
136 |
|
137 |
<?php }
|
138 |
}
|
158 |
|
159 |
if (!function_exists("nxs_doPublishToWP")) { //## Second Function to Post to WP
|
160 |
function nxs_doPublishToWP($postID, $options){ $ntCd = 'WP'; $ntCdL = 'wp'; $ntNm = 'WP Based Blog';
|
161 |
+
//if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToWP', array($postID, $options));
|
162 |
+
$ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
|
163 |
+
$logNT = '<span style="color:#1A9EE6">WP</span> - '.$options['nName'];
|
164 |
+
$snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
|
165 |
if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
|
166 |
+
$snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') { sleep(5);
|
167 |
+
nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$uqID); return;
|
168 |
+
}
|
169 |
}
|
170 |
$imgURL = nxs_getPostImage($postID);
|
171 |
$email = $options['wpUName']; $pass = substr($options['wpPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['wpPass'], 5)):$options['wpPass'];
|
190 |
if (!$nxsToWPclient->query('wp.getOptions', $params)) { $ret = 'Something went wrong - '.$nxsToWPclient->getErrorCode().' : '.$nxsToWPclient->getErrorMessage();} else $ret = 'OK';
|
191 |
$rwpOpt = $nxsToWPclient->getResponse(); $rwpOpt = $rwpOpt['software_version']['value']; $rwpOpt = floatval($rwpOpt); //prr($rwpOpt);prr($nxsToWPclient);
|
192 |
|
193 |
+
$extInfo = ' | PostID: '.$postID." - ".$post->post_title;
|
194 |
|
195 |
if ($rwpOpt==0) {
|
196 |
$errMsg = $nxsToWPclient->getErrorMessage(); if ($errMsg!='') $ret = $errMsg; else $ret = 'XMLRPC is not found or not active. WP admin - Settings - Writing - Enable XML-RPC';
|
197 |
} else if ($rwpOpt<3.0) $ret = 'XMLRPC is too OLD - '.$rwpOpt.' You need at least 3.0'; else {
|
198 |
|
199 |
if ($rwpOpt>3.3){
|
200 |
+
$nxsToWPContent = array('title'=>$msgT, 'description'=>$msg, 'post_status'=>'draft', 'mt_excerpt'=>$post->post_excerpt, 'mt_allow_comments'=>1, 'mt_allow_pings'=>1, 'post_type'=>'post', 'mt_keywords'=>$tags, 'categories'=>($cats), 'custom_fields' => $customfields);
|
201 |
$params = array(0, $options['wpUName'], $pass, $nxsToWPContent, true);
|
202 |
if (!$nxsToWPclient->query('metaWeblog.newPost', $params)) { $ret = 'Something went wrong - '.$nxsToWPclient->getErrorCode().' : '.$nxsToWPclient->getErrorMessage();} else $ret = 'OK';
|
203 |
$pid = $nxsToWPclient->getResponse();
|
215 |
$pid = $nxsToWPclient->getResponse();
|
216 |
}
|
217 |
} if ($ret!='OK') { if ($postID=='0') echo $ret;
|
218 |
+
nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);
|
219 |
+
} else { if ($postID=='0') { echo 'OK - Message Posted, please see your WP Blog'; nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); } else
|
220 |
+
{ nxs_metaMarkAsPosted($postID, 'WP', $options['ii'], array('isPosted'=>'1', 'pgID'=>$pid, 'pDate'=>date('Y-m-d H:i:s')));
|
221 |
+
do_action('nxs_actOnWP', array('postID'=>$postID, 'pgID'=>$pid, 'wpURL'=>$options['wpURL'], 'ii'=>$ii)); nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo);
|
222 |
+
}
|
223 |
+
}
|
224 |
if ($ret == 'OK') return 200; else return $ret;
|
225 |
}
|
226 |
}
|
inc-cl/yt.php
ADDED
@@ -0,0 +1,186 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
//## NextScripts Facebook Connection Class
|
3 |
+
$nxs_snapAvNts[] = array('code'=>'YT', 'lcode'=>'yt', 'name'=>'YouTube');
|
4 |
+
|
5 |
+
if (!class_exists("nxs_snapClassYT")) { class nxs_snapClassYT {
|
6 |
+
//#### Show Common Settings
|
7 |
+
function showGenNTSettings($ntOpts){ global $nxs_plurl; $ntInfo = array('code'=>'YT', 'lcode'=>'yt', 'name'=>'YouTube', 'defNName'=>'ytUName', 'tstReq' => false); ?>
|
8 |
+
<div class="nxs_box">
|
9 |
+
<div class="nxs_box_header">
|
10 |
+
<div class="nsx_iconedTitle" style="margin-bottom:1px;background-image:url(<?php echo $nxs_plurl;?>img/<?php echo $ntInfo['lcode']; ?>16.png);"><?php echo $ntInfo['name']; ?>
|
11 |
+
<?php $cbo = count($ntOpts); ?> <?php wp_nonce_field( 'ns'.$ntInfo['code'], 'ns'.$ntInfo['code'].'_wpnonce' ); ?>
|
12 |
+
<?php if ($cbo>1){ ?><div class="nsBigText"><?php echo "(".($cbo=='0'?'No':$cbo)." "; _e('accounts', 'nxs_snap'); echo ")"; ?></div><?php } ?>
|
13 |
+
</div>
|
14 |
+
</div>
|
15 |
+
<div class="nxs_box_inside">
|
16 |
+
<?php if(!function_exists('doPostToGooglePlus')) {?> YouTube doesn't have a built-in API for automated posts yet. The current <a href="http://developers.google.com/+/api/">YouTube API</a> is "Read Only" and can't be used for posting. <br/>You need to get a special <a target="_blank" href="http://www.nextscripts.com/google-plus-automated-posting">library module</a> to be able to publish your content to YouTube.
|
17 |
+
<?php } else foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
|
18 |
+
<p style="margin:0px;margin-left:5px;">
|
19 |
+
<input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> /> <?php if ((int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
|
20 |
+
<strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
|
21 |
+
<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'nxs_snap'); ?> ==></b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>
|
22 |
+
<a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
|
23 |
+
</p><?php $this->showNTSettings($indx, $pbo);
|
24 |
+
}?>
|
25 |
+
</div>
|
26 |
+
</div> <?php
|
27 |
+
}
|
28 |
+
//#### Show NEW Settings Page
|
29 |
+
function showNewNTSettings($myto){ $yto = array('nName'=>'', 'doYT'=>'1', 'ytUName'=>'', 'ytPageID'=>'', 'ytCommID'=>'', 'postType'=>'A', 'ytPass'=>''); $this->showNTSettings($myto, $yto, true);}
|
30 |
+
//#### Show Unit Settings
|
31 |
+
function showNTSettings($ii, $yto, $isNew=false){ global $nxs_plurl; ?>
|
32 |
+
<div id="doYT<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>" style="background-image: url(<?php echo $nxs_plurl; ?>img/yt-bg.png); background-position:90% 10%;"> <input type="hidden" name="apDoSYT<?php echo $ii; ?>" value="0" id="apDoSYT<?php echo $ii; ?>" />
|
33 |
+
<?php if(!function_exists('doPostToGooglePlus')) {?><span style="color:#580000; font-size: 16px;"><br/><br/>
|
34 |
+
<b><?php _e('YouTube API Library not found', 'nxs_snap'); ?></b>
|
35 |
+
<br/><br/> <?php _e('YouTube doesn\'t have a built-in API for automated posts yet.', 'nxs_snap'); ?> <br/><?php _e('The current <a target="_blank" href="http://developers.google.com/+/api/">YouTube API</a> is "Read Only" and can\'t be used for posting. <br/><br/>You need to get a special <a target="_blank" href="http://www.nextscripts.com/google-plus-automated-posting"><b>API Library Module</b></a> to be able to publish your content to YouTube.', 'nxs_snap'); ?></span></div>
|
36 |
+
<?php return; }; ?>
|
37 |
+
<div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/yt16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-google-plus-social-networks-auto-poster-wordpress/"><?php $nType="YouTube"; printf( __( 'Detailed %s Installation/Configuration Instructions', 'nxs_snap' ), $nType); ?></a></div>
|
38 |
+
|
39 |
+
<div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easely identify it', 'nxs_snap'); ?></i> </div><input name="yt[<?php echo $ii; ?>][nName]" id="ytnName<?php echo $ii; ?>" style="font-weight: bold; color: #005800; border: 1px solid #ACACAC; width: 40%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($yto['nName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /><br/>
|
40 |
+
<?php echo nxs_addQTranslSel('yt', $ii, $yto['qTLng']); ?><?php echo nxs_addPostingDelaySel('yt', $ii, $yto['nHrs'], $yto['nMin']); ?>
|
41 |
+
|
42 |
+
<?php if (!$isNew) { ?>
|
43 |
+
<div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
|
44 |
+
<input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="yt[<?php echo $ii; ?>][catSel]" <?php if ((int)$yto['catSel'] != 1) echo "checked"; ?> /> All
|
45 |
+
<input value="1" id="catSelSYT<?php echo $ii; ?>" type="radio" name="yt[<?php echo $ii; ?>][catSel]" <?php if ((int)$yto['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_YT<?php echo $ii; ?>" onclick="jQuery('#catSelSYT<?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('YT<?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_YT<?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($yto['catSelEd']!='') echo "[".(substr_count($yto['catSelEd'], ",")+1)."]"; ?></a>
|
46 |
+
<input type="hidden" name="yt[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_YT<?php echo $ii; ?>" value="<?php echo $yto['catSelEd']; ?>" />
|
47 |
+
<br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
|
48 |
+
<br/>
|
49 |
+
<?php } ?>
|
50 |
+
|
51 |
+
<div style="width:100%;"><strong>YouTube(Google) Username:</strong> </div><input name="yt[<?php echo $ii; ?>][apYTUName]" id="apYTUName" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($yto['ytUName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
|
52 |
+
<div style="width:100%;"><strong>YouTube(Google) Password:</strong> </div><input name="yt[<?php echo $ii; ?>][apYTPass]" id="apYTPass" type="password" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities(substr($yto['ytPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($yto['ytPass'], 5)):$yto['ytPass'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /> <br/>
|
53 |
+
<p><div style="width:100%;"><strong>YouTube Channel Page URL:</strong>
|
54 |
+
|
55 |
+
</div><input name="yt[<?php echo $ii; ?>][apYTPage]" id="apYTPage" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($yto['ytPageID'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
|
56 |
+
<br/><br/>
|
57 |
+
|
58 |
+
<div id="altFormat" style="">
|
59 |
+
<div style="width:100%;"><strong id="altFormatText"><?php _e('Message text Format', 'nxs_snap'); ?>:</strong> (<a href="#" id="apYTMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apYTMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)
|
60 |
+
</div>
|
61 |
+
|
62 |
+
<textarea cols="150" rows="3" id="yt<?php echo $ii; ?>SNAPformat" name="yt[<?php echo $ii; ?>][apYTMsgFrmt]" style="width:51%;max-width: 650px;" onfocus="jQuery('#yt<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('apYTMsgFrmt<?php echo $ii; ?>');"><?php if ($isNew) _e("New post: %TITLE% - %URL%", 'nxs_snap'); else _e(apply_filters('format_to_edit', htmlentities($yto['ytMsgFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap'); ?></textarea>
|
63 |
+
|
64 |
+
<?php nxs_doShowHint("apYTMsgFrmt".$ii); ?>
|
65 |
+
</div><br/>
|
66 |
+
|
67 |
+
<?php if ($isNew) { ?> <input type="hidden" name="yt[<?php echo $ii; ?>][apDoYT]" value="1" id="apDoNewYT<?php echo $ii; ?>" /> <?php } ?>
|
68 |
+
<?php if ($yto['ytPass']!='') { ?>
|
69 |
+
<?php wp_nonce_field( 'rePostToYT', 'rePostToYT_wpnonce' ); ?>
|
70 |
+
<b><?php _e('Test your settings', 'nxs_snap'); ?>:</b> <a href="#" class="NXSButton" onclick="testPost('YT', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'nxs_snap' ), $nType); ?></a> <?php }
|
71 |
+
?><div class="submit"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div></div><?php
|
72 |
+
}
|
73 |
+
//#### Set Unit Settings from POST
|
74 |
+
function setNTSettings($post, $options){ global $nxs_snapThisPageUrl; $code = 'YT'; $lcode = 'yt';
|
75 |
+
foreach ($post as $ii => $pval){
|
76 |
+
if (isset($pval['apYTUName']) && $pval['apYTUName']!=''){ if (!isset($options[$ii])) $options[$ii] = array();
|
77 |
+
if (isset($pval['apYTUName'])) $options[$ii]['ytUName'] = trim($pval['apYTUName']);
|
78 |
+
if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']);
|
79 |
+
if (isset($pval['apYTPass'])) $options[$ii]['ytPass'] = 'n5g9a'.nsx_doEncode($pval['apYTPass']); else $options[$ii]['ytPass'] = '';
|
80 |
+
if (isset($pval['apYTPage'])) $options[$ii]['ytPageID'] = trim($pval['apYTPage']);
|
81 |
+
if (isset($pval['ytCommID'])) $options[$ii]['ytCommID'] = trim($pval['ytCommID']);
|
82 |
+
|
83 |
+
if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']);
|
84 |
+
if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
|
85 |
+
|
86 |
+
if (isset($pval['postType'])) $options[$ii]['postType'] = $pval['postType'];
|
87 |
+
if (isset($pval['apYTMsgFrmt'])) $options[$ii]['ytMsgFormat'] = trim($pval['apYTMsgFrmt']);
|
88 |
+
if (isset($pval['apDoYT'])) $options[$ii]['doYT'] = $pval['apDoYT']; else $options[$ii]['doYT'] = 0;
|
89 |
+
if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
|
90 |
+
if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
|
91 |
+
}
|
92 |
+
} return $options;
|
93 |
+
}
|
94 |
+
//#### Show Post->Edit Meta Box Settings
|
95 |
+
function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
|
96 |
+
foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapYT', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
|
97 |
+
$doYT = $ntOpt['doYT'] && (is_array($pMeta) || $ntOpt['catSel']!='1');
|
98 |
+
$isAvailYT = $ntOpt['ytUName']!='' && $ntOpt['ytPass']!=''; $ytMsgFormat = htmlentities($ntOpt['ytMsgFormat'], ENT_COMPAT, "UTF-8");
|
99 |
+
if(!isset($ntOpt['postType']) || $ntOpt['postType']=='') {
|
100 |
+
if ((int)$ntOpt['imgPost'] == 1) $ntOpt['postType'] = 'I';
|
101 |
+
if ((int)$ntOpt['ytAttch'] == 1 || $isNew) $ntOpt['postType'] = 'A';
|
102 |
+
} $ytPostType = $ntOpt['postType'];
|
103 |
+
?>
|
104 |
+
<tr><th style="text-align:left;" colspan="2"><?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_YT<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
|
105 |
+
<?php if ($isAvailYT) { ?><input class="nxsGrpDoChb" value="1" id="doYT<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="yt[<?php echo $ii; ?>][doYT]" <?php if ((int)$doYT == 1) echo 'checked="checked" title="def"'; ?> />
|
106 |
+
<?php if ($post->post_status == "publish") { ?> <input type="hidden" name="yt[<?php echo $ii; ?>][doYT]" value="<?php echo $doYT;?>"> <?php } ?> <?php } ?>
|
107 |
+
|
108 |
+
<div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/yt16.png);">YouTube - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
|
109 |
+
if ($post->post_status == "publish" && $isAvailYT) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToYT_repostButton" id="rePostToYT_button" value="<?php _e('Repost to YouTube', 'nxs_snap') ?>" />
|
110 |
+
<?php wp_nonce_field( 'rePostToYT', 'rePostToYT_wpnonce' ); } ?>
|
111 |
+
|
112 |
+
<?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
|
113 |
+
|
114 |
+
?> <span id="pstdYT<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
|
115 |
+
<a style="font-size: 10px;" href="<?php echo $ntOpt['ytPageID']; ?>" target="_blank"><?php $nType="YouTube"; printf( __( 'Posted on', 'nxs_snap' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
|
116 |
+
</span><?php } ?>
|
117 |
+
|
118 |
+
</td></tr>
|
119 |
+
|
120 |
+
<?php if (!$isAvailYT) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your YouTube Account to AutoPost to YouTube</b>
|
121 |
+
<?php } elseif ($post->post_status != "puZblish") { ?>
|
122 |
+
|
123 |
+
|
124 |
+
<tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Message Format:', 'nxs_snap') ?></th>
|
125 |
+
<td>
|
126 |
+
|
127 |
+
<?php if (1==1) { ?>
|
128 |
+
<textarea cols="150" rows="1" id="yt<?php echo $ii; ?>SNAPformat" name="yt[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('#yt<?php echo $ii; ?>SNAPformat').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apYTMsgFrmt<?php echo $ii; ?>');"><?php echo $ytMsgFormat ?></textarea>
|
129 |
+
<?php } else { ?>
|
130 |
+
<input value="<?php echo $ytMsgFormat ?>" type="text" name="yt[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apYTMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apYTMsgFrmt".$ii); ?>
|
131 |
+
<?php } ?>
|
132 |
+
|
133 |
+
|
134 |
+
</td></tr>
|
135 |
+
<?php }
|
136 |
+
}
|
137 |
+
}
|
138 |
+
//#### Save Meta Tags to the Post
|
139 |
+
function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
|
140 |
+
if (isset($pMeta['SNAPformat'])) $optMt['ytMsgFormat'] = $pMeta['SNAPformat'];
|
141 |
+
if (isset($pMeta['postType'])) $optMt['postType'] = $pMeta['postType'];
|
142 |
+
if (isset($pMeta['doYT'])) $optMt['doYT'] = $pMeta['doYT'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doYT'] = 0; }
|
143 |
+
if (isset($pMeta['SNAPincludeYT']) && $pMeta['SNAPincludeYT'] == '1' ) $optMt['doYT'] = 1;
|
144 |
+
return $optMt;
|
145 |
+
}
|
146 |
+
}}
|
147 |
+
if (!function_exists("nxs_rePostToYT_ajax")) {
|
148 |
+
function nxs_rePostToYT_ajax() { check_ajax_referer('rePostToYT'); $postID = $_POST['id']; global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
|
149 |
+
foreach ($options['yt'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj'; //if ($two['ytPageID'].$two['ytUName']==$_POST['nid']) {
|
150 |
+
$ytpo = get_post_meta($postID, 'snapYT', true); $ytpo = maybe_unserialize($ytpo);// prr($ytpo);
|
151 |
+
if (is_array($ytpo) && isset($ytpo[$ii]) && is_array($ytpo[$ii])){ $ntClInst = new nxs_snapClassYT(); $two = $ntClInst->adjMetaOpt($two, $ytpo[$ii]); }
|
152 |
+
$result = nxs_doPublishToYT($postID, $two); if ($result == 200) die("Successfully sent your post to YouTube."); else die($result);
|
153 |
+
}
|
154 |
+
}
|
155 |
+
}
|
156 |
+
|
157 |
+
if (!function_exists("nxs_doPublishToYT")) { //## Second Function to Post to G+
|
158 |
+
function nxs_doPublishToYT($postID, $options){ $ntCd = 'YT'; $ntCdL = 'yt'; $ntNm = 'YouTube'; global $nxs_gCookiesArr;
|
159 |
+
// $backtrace = debug_backtrace(); nxs_addToLogN('W', 'Enter', $ntCd, 'I am here - '.$ntCd."|".print_r($backtrace, true), '');
|
160 |
+
//if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToYT', array($postID, $options));
|
161 |
+
if(!function_exists('doConnectToGooglePlus2') || !function_exists('doPostToGooglePlus2')) { nxs_addToLogN('E', 'Error', $ntCd, '-=ERROR=- No G+ API Lib Detected', ''); return "No G+ API Lib Detected";}
|
162 |
+
$ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
|
163 |
+
$logNT = '<span style="color:#800000">YouTube</span> - '.$options['nName'];
|
164 |
+
$snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
|
165 |
+
if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
|
166 |
+
$snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') { sleep(5);
|
167 |
+
nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$uqID); return;
|
168 |
+
}
|
169 |
+
}
|
170 |
+
if ($postID=='0') echo "Testing ... <br/><br/>"; else { nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1')); $post = get_post($postID); if(!$post) return;}
|
171 |
+
$ytMsgFormat = $options['ytMsgFormat']; $msg = nsFormatMessage($ytMsgFormat, $postID);// prr($msg); echo $postID;
|
172 |
+
$extInfo = ' | PostID: '.$postID." - ".$post->post_title;
|
173 |
+
$email = $options['ytUName']; $pass = substr($options['ytPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['ytPass'], 5)):$options['ytPass'];
|
174 |
+
|
175 |
+
$loginError = doConnectToGooglePlus2($email, $pass, 'YT');
|
176 |
+
if ($loginError!==false) {if ($postID=='0') echo $loginError; nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($loginError, true)." - BAD USER/PASS", $extInfo); return "BAD USER/PASS";}
|
177 |
+
$url = get_permalink($postID); if(trim($url)=='') $url = home_url(); $vids = nsFindVidsInPost($post); if (count($vids)>0) $vUrl = $vids[0];
|
178 |
+
$ret = doPostToYouTube($msg, $options['ytPageID'], $vUrl); //prr($ret);
|
179 |
+
if ($ret=='OK') $ret = array("code"=>"OK", "post_id"=>'');
|
180 |
+
if ( (!is_array($ret)) && $ret!='OK') { if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);}
|
181 |
+
else if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo _e('OK - Message Posted, please see your YouTube Page', 'nxs_snap'); } else
|
182 |
+
{ nxs_metaMarkAsPosted($postID, 'YT', $options['ii'], array('isPosted'=>'1', 'pgID'=>$ret['post_id'], 'pDate'=>date('Y-m-d H:i:s'))); nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); }
|
183 |
+
if ($ret['code']=='OK') return 200; else return $ret;
|
184 |
+
}
|
185 |
+
}
|
186 |
+
?>
|
js/js.js
CHANGED
@@ -20,12 +20,17 @@ function nxs_expSettings(){
|
|
20 |
}
|
21 |
// AJAX Functions
|
22 |
function getBoards(u,p,ii){ jQuery("#pnLoadingImg"+ii).show();
|
23 |
-
jQuery.post(ajaxurl,{u:u,p:p,ii:ii, action: 'getBoards', id: 0, _wpnonce: jQuery('input#getBoards_wpnonce').val(), ajax: 'true'}, function(j){ var options = '';
|
24 |
jQuery("select#apPNBoard"+ii).html(j); jQuery("#pnLoadingImg"+ii).hide();
|
25 |
}, "html")
|
26 |
}
|
|
|
|
|
|
|
|
|
|
|
27 |
function getWLBoards(u,p,ii){ jQuery("#wlLoadingImg"+ii).show();
|
28 |
-
jQuery.post(ajaxurl,{u:u,p:p,ii:ii, action: 'getWLBoards', id: 0, _wpnonce: jQuery('input#getWLBoards_wpnonce').val(), ajax: 'true'}, function(j){ var options = '';
|
29 |
jQuery("select#apWLBoard"+ii).html(j); jQuery("#wlLoadingImg"+ii).hide();
|
30 |
}, "html")
|
31 |
}
|
@@ -40,6 +45,9 @@ function nxs_doSetSelCats(nt, idNum){ var scc = ''; var sccA = [];
|
|
40 |
var sccL = sccA.length; if (sccL>0) scc = sccA.join(","); jQuery('#nxs_SC_'+nt).val(scc); jQuery('#nxs_SCA_'+nt).html('Selected ['+sccL+']');
|
41 |
}
|
42 |
|
|
|
|
|
|
|
43 |
function showPopShAtt(imid, e){ if (!jQuery('div#popShAtt'+imid).is(":visible")) jQuery('div#popShAtt'+imid).show().css('top', e.pageY+5).css('left', e.pageX+25).appendTo('body'); }
|
44 |
function hidePopShAtt(imid){ jQuery('div#popShAtt'+imid).hide(); }
|
45 |
function doSwitchShAtt(att, idNum){
|
20 |
}
|
21 |
// AJAX Functions
|
22 |
function getBoards(u,p,ii){ jQuery("#pnLoadingImg"+ii).show();
|
23 |
+
jQuery.post(ajaxurl,{u:u,p:p,ii:ii, nxs_mqTest:"'", action: 'getBoards', id: 0, _wpnonce: jQuery('input#getBoards_wpnonce').val(), ajax: 'true'}, function(j){ var options = '';
|
24 |
jQuery("select#apPNBoard"+ii).html(j); jQuery("#pnLoadingImg"+ii).hide();
|
25 |
}, "html")
|
26 |
}
|
27 |
+
function getGPCats(u,p,ii,c){ jQuery("#gpLoadingImg"+ii).show();
|
28 |
+
jQuery.post(ajaxurl,{u:u,p:p,c:c,ii:ii, nxs_mqTest:"'", action: 'getGPCats', id: 0, _wpnonce: jQuery('input#getGPCats_wpnonce').val(), ajax: 'true'}, function(j){ var options = '';
|
29 |
+
jQuery("select#apGPCCats"+ii).html(j); jQuery("#gpLoadingImg"+ii).hide();
|
30 |
+
}, "html")
|
31 |
+
}
|
32 |
function getWLBoards(u,p,ii){ jQuery("#wlLoadingImg"+ii).show();
|
33 |
+
jQuery.post(ajaxurl,{u:u,p:p,ii:ii, nxs_mqTest:"'", action: 'getWLBoards', id: 0, _wpnonce: jQuery('input#getWLBoards_wpnonce').val(), ajax: 'true'}, function(j){ var options = '';
|
34 |
jQuery("select#apWLBoard"+ii).html(j); jQuery("#wlLoadingImg"+ii).hide();
|
35 |
}, "html")
|
36 |
}
|
45 |
var sccL = sccA.length; if (sccL>0) scc = sccA.join(","); jQuery('#nxs_SC_'+nt).val(scc); jQuery('#nxs_SCA_'+nt).html('Selected ['+sccL+']');
|
46 |
}
|
47 |
|
48 |
+
function nxs_showPopUpInfo(pid, e){ if (!jQuery('div#'+pid).is(":visible")) jQuery('div#'+pid).show().css('top', e.pageY+5).css('left', e.pageX+25).appendTo('body'); }
|
49 |
+
function nxs_hidePopUpInfo(pid){ jQuery('div#'+pid).hide(); }
|
50 |
+
|
51 |
function showPopShAtt(imid, e){ if (!jQuery('div#popShAtt'+imid).is(":visible")) jQuery('div#popShAtt'+imid).show().css('top', e.pageY+5).css('left', e.pageX+25).appendTo('body'); }
|
52 |
function hidePopShAtt(imid){ jQuery('div#popShAtt'+imid).hide(); }
|
53 |
function doSwitchShAtt(att, idNum){
|
nxs_functions.php
CHANGED
@@ -14,6 +14,7 @@ if (!function_exists('nsx_doDecode')){ function nsx_doDecode($string,$key='NSX')
|
|
14 |
if (!function_exists('nxs_decodeEntitiesFull')){ function nxs_decodeEntitiesFull($string, $quotes = ENT_COMPAT, $charset = 'utf-8') {
|
15 |
return html_entity_decode(preg_replace_callback('/&([a-zA-Z][a-zA-Z0-9]+);/', 'nxs_convertEntity', $string), $quotes, $charset);
|
16 |
}}
|
|
|
17 |
if (!function_exists('nxs_convertEntity')){ function nxs_convertEntity($matches, $destroy = true) {
|
18 |
static $table = array('quot' => '"','amp' => '&','lt' => '<','gt' => '>','OElig' => 'Œ','oelig' => 'œ','Scaron' => 'Š','scaron' => 'š','Yuml' => 'Ÿ','circ' => 'ˆ','tilde' => '˜','ensp' => ' ','emsp' => ' ','thinsp' => ' ','zwnj' => '‌','zwj' => '‍','lrm' => '‎','rlm' => '‏','ndash' => '–','mdash' => '—','lsquo' => '‘','rsquo' => '’','sbquo' => '‚','ldquo' => '“','rdquo' => '”','bdquo' => '„','dagger' => '†','Dagger' => '‡','permil' => '‰','lsaquo' => '‹','rsaquo' => '›','euro' => '€','fnof' => 'ƒ','Alpha' => 'Α','Beta' => 'Β','Gamma' => 'Γ','Delta' => 'Δ','Epsilon' => 'Ε','Zeta' => 'Ζ','Eta' => 'Η','Theta' => 'Θ','Iota' => 'Ι','Kappa' => 'Κ','Lambda' => 'Λ','Mu' => 'Μ','Nu' => 'Ν','Xi' => 'Ξ','Omicron' => 'Ο','Pi' => 'Π','Rho' => 'Ρ','Sigma' => 'Σ','Tau' => 'Τ','Upsilon' => 'Υ','Phi' => 'Φ','Chi' => 'Χ','Psi' => 'Ψ','Omega' => 'Ω','alpha' => 'α','beta' => 'β','gamma' => 'γ','delta' => 'δ','epsilon' => 'ε','zeta' => 'ζ','eta' => 'η','theta' => 'θ','iota' => 'ι','kappa' => 'κ','lambda' => 'λ','mu' => 'μ','nu' => 'ν','xi' => 'ξ','omicron' => 'ο','pi' => 'π','rho' => 'ρ','sigmaf' => 'ς','sigma' => 'σ','tau' => 'τ','upsilon' => 'υ','phi' => 'φ','chi' => 'χ','psi' => 'ψ','omega' => 'ω','thetasym' => 'ϑ','upsih' => 'ϒ','piv' => 'ϖ','bull' => '•','hellip' => '…','prime' => '′','Prime' => '″','oline' => '‾','frasl' => '⁄','weierp' => '℘','image' => 'ℑ','real' => 'ℜ','trade' => '™','alefsym' => 'ℵ','larr' => '←','uarr' => '↑','rarr' => '→','darr' => '↓','harr' => '↔','crarr' => '↵','lArr' => '⇐','uArr' => '⇑','rArr' => '⇒','dArr' => '⇓','hArr' => '⇔','forall' => '∀','part' => '∂','exist' => '∃','empty' => '∅','nabla' => '∇','isin' => '∈','notin' => '∉','ni' => '∋','prod' => '∏','sum' => '∑','minus' => '−','lowast' => '∗','radic' => '√','prop' => '∝','infin' => '∞','ang' => '∠','and' => '∧','or' => '∨','cap' => '∩','cup' => '∪','int' => '∫','there4' => '∴','sim' => '∼','cong' => '≅','asymp' => '≈','ne' => '≠','equiv' => '≡','le' => '≤','ge' => '≥','sub' => '⊂','sup' => '⊃','nsub' => '⊄','sube' => '⊆','supe' => '⊇','oplus' => '⊕','otimes' => '⊗','perp' => '⊥','sdot' => '⋅','lceil' => '⌈','rceil' => '⌉','lfloor' => '⌊','rfloor' => '⌋','lang' => '〈','rang' => '〉','loz' => '◊','spades' => '♠','clubs' => '♣','hearts' => '♥','diams' => '♦','nbsp' => ' ','iexcl' => '¡','cent' => '¢','pound' => '£','curren' => '¤','yen' => '¥','brvbar' => '¦','sect' => '§','uml' => '¨','copy' => '©','ordf' => 'ª','laquo' => '«','not' => '¬','shy' => '­','reg' => '®','macr' => '¯','deg' => '°','plusmn' => '±','sup2' => '²','sup3' => '³','acute' => '´','micro' => 'µ','para' => '¶','middot' => '·','cedil' => '¸','sup1' => '¹','ordm' => 'º','raquo' => '»','frac14' => '¼','frac12' => '½','frac34' => '¾','iquest' => '¿','Agrave' => 'À','Aacute' => 'Á','Acirc' => 'Â','Atilde' => 'Ã','Auml' => 'Ä','Aring' => 'Å','AElig' => 'Æ','Ccedil' => 'Ç','Egrave' => 'È','Eacute' => 'É','Ecirc' => 'Ê','Euml' => 'Ë','Igrave' => 'Ì','Iacute' => 'Í','Icirc' => 'Î','Iuml' => 'Ï','ETH' => 'Ð','Ntilde' => 'Ñ','Ograve' => 'Ò','Oacute' => 'Ó','Ocirc' => 'Ô','Otilde' => 'Õ','Ouml' => 'Ö','times' => '×','Oslash' => 'Ø','Ugrave' => 'Ù','Uacute' => 'Ú','Ucirc' => 'Û','Uuml' => 'Ü','Yacute' => 'Ý','THORN' => 'Þ','szlig' => 'ß','agrave' => 'à','aacute' => 'á','acirc' => 'â','atilde' => 'ã','auml' => 'ä','aring' => 'å','aelig' => 'æ','ccedil' => 'ç','egrave' => 'è','eacute' => 'é','ecirc' => 'ê','euml' => 'ë','igrave' => 'ì','iacute' => 'í','icirc' => 'î','iuml' => 'ï','eth' => 'ð','ntilde' => 'ñ','ograve' => 'ò','oacute' => 'ó','ocirc' => 'ô','otilde' => 'õ','ouml' => 'ö','divide' => '÷','oslash' => 'ø','ugrave' => 'ù','uacute' => 'ú','ucirc' => 'û','uuml' => 'ü','yacute' => 'ý','thorn' => 'þ','yuml' => 'ÿ');
|
19 |
if (isset($table[$matches[1]])) return $table[$matches[1]];
|
@@ -25,33 +26,38 @@ if (!function_exists('nsFindImgsInPost')){function nsFindImgsInPost($post, $advI
|
|
25 |
//$output = preg_match_all( '/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $postCnt, $matches ); if ($output === false){return false;}
|
26 |
//$postCnt = str_replace("'",'"',$postCnt); $output = preg_match_all( '/src="([^"]*)"/', $postCnt, $matches ); if ($output === false){return false;}
|
27 |
$postCnt = str_replace("'",'"',$postCnt); $output = preg_match_all( '/< *img[^>]*src *= *["\']?([^"\']*)/i', $postCnt, $matches ); // prr($matches);
|
28 |
-
if ($output === false || $output == 0){ $vids = nsFindVidsInPost($post); if (count($vids)>0) $postImgs[] = 'http://img.youtube.com/vi/'.$vids[0].'/0.jpg'; else return false;}
|
29 |
else { foreach ($matches[1] as $match) { if (!preg_match('/^https?:\/\//', $match ) ) $match = site_url( '/' ) . ltrim( $match, '/' ); $postImgs[] = $match;} if (isset($ShownAds)) $ShownAds = $ShownAdsL; }
|
30 |
return $postImgs;
|
31 |
}}
|
32 |
|
33 |
|
34 |
-
if (!function_exists('nsFindAudioInPost')){function nsFindAudioInPost($post, $raw=true) {
|
35 |
global $ShownAds; if (isset($ShownAds)) $ShownAdsL = $ShownAds; $postVids = array();
|
36 |
if (is_object($post)) { if ($raw) $postCnt = $post->post_content; else $postCnt = apply_filters('the_content', $post->post_content); } else $postCnt = $post;
|
37 |
$regex_pattern = "((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*\.(mp3|aac|m4a))";
|
38 |
$output = preg_match_all( $regex_pattern, $postCnt, $matches ); if ($output === false){return false;}
|
39 |
-
foreach ($matches[0] as $match) { $postAu[] = $match;
|
40 |
-
|
41 |
-
} $postAu = array_unique($postAu); if (isset($ShownAds)) $ShownAds = $ShownAdsL; return $postAu;
|
42 |
}}
|
43 |
-
if (!function_exists('
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
global $ShownAds; if (isset($ShownAds)) $ShownAdsL = $ShownAds; $postVids = array();
|
45 |
-
if (is_object($post)) { if ($raw) $postCnt = $post->post_content; else $postCnt = apply_filters('the_content', $post->post_content); } else $postCnt = $post;
|
46 |
-
$
|
|
|
47 |
foreach ($matches[0] as $match) {
|
48 |
-
$output2 = preg_match_all( '%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"<>&?/ ]{11})%i', $match, $matches2 );
|
49 |
foreach ($matches2[1] as $match2) { $match2 = trim($match2); if (strlen($match2)==11) $postVids[] = $match2;}
|
50 |
$output3 = preg_match_all( '/^http:\/\/(www\.)?vimeo\.com\/(clip\:)?(\d+).*$/', $match, $matches3 ); if ($output3 === false){return false;}
|
51 |
foreach ($matches3[3] as $match3) { $match3 = trim($match3); if (strlen($match3)==8) $postVids[] = $match3;}
|
52 |
} $postVids = array_unique($postVids); if (isset($ShownAds)) $ShownAds = $ShownAdsL; return $postVids;
|
53 |
}}
|
54 |
-
if (!function_exists('nsTrnc')){ function nsTrnc($string, $limit, $break=" ", $pad=" ...") { if(strlen($string) <= $limit) return $string; $string = substr($string, 0, $limit-strlen($pad));
|
55 |
$brLoc = strripos($string, $break); if ($brLoc===false) return $string.$pad; else return substr($string, 0, $brLoc).$pad;
|
56 |
}}
|
57 |
if (!function_exists('nsSubStrEl')){ function nsSubStrEl($string, $length, $end='...'){ if (strlen($string) > $length){ $length -= strlen($end); $string = substr($string, 0, $length); $string .= $end; } return $string;}}
|
@@ -68,28 +74,40 @@ if (!function_exists("nxs_getNXSHeaders")) { function nxs_getNXSHeaders($ref=''
|
|
68 |
}}
|
69 |
if (!function_exists('nxs_chckRmImage')){function nxs_chckRmImage($url, $chType='head'){ if( ini_get('allow_url_fopen')=='1' && @getimagesize($url)!==false) return true;
|
70 |
$hdrsArr = nxs_getNXSHeaders(); $nxsWPRemWhat = 'wp_remote_'.$chType; $rsp = $nxsWPRemWhat($url, array('headers' => $hdrsArr));
|
71 |
-
if(is_wp_error($rsp)) {
|
72 |
if (is_array($rsp) && ($rsp['response']['code']=='200' || ( $rsp['response']['code']=='403' && $rsp['headers']['server']=='cloudflare-nginx') )) return true;
|
73 |
-
else { if ($chType=='head') { return nxs_chckRmImage($url, 'get'); } else {
|
74 |
}
|
75 |
}}
|
76 |
if (!function_exists('nxs_getPostImage')){ function nxs_getPostImage($postID, $size='large', $def='') { $imgURL = ''; global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
|
77 |
$imgURL = "https://www.google.com/images/srpr/logo3w.png"; $res = nxs_chckRmImage($imgURL); $imgURL = ''; if (!$res) $options['imgNoCheck'] = '1';
|
78 |
-
|
79 |
-
|
80 |
-
|
|
|
|
|
|
|
81 |
if ($imgURL!='' && $options['imgNoCheck']!='1' && nxs_chckRmImage($imgURL)==false) $imgURL = ''; if ($imgURL!='') return $imgURL;
|
82 |
-
|
|
|
83 |
if ($imgURL!='' && $options['imgNoCheck']!='1' && nxs_chckRmImage($imgURL)==false) $imgURL = ''; if ($imgURL!='') return $imgURL;
|
84 |
-
|
85 |
-
|
|
|
86 |
}
|
87 |
-
if ($imgURL!='' && $options['imgNoCheck']!='1' && nxs_chckRmImage($imgURL)==false) $imgURL = ''; if ($imgURL!='') return $imgURL;
|
88 |
-
if ($imgURL=='') {$post = get_post($postID); $imgsFromPost = nsFindImgsInPost($post); if (is_array($imgsFromPost) && count($imgsFromPost)>0) $imgURL = $imgsFromPost[0]; } //echo "##".count($imgsFromPost); prr($imgsFromPost);
|
89 |
if ($imgURL!='' && $options['imgNoCheck']!='1' && nxs_chckRmImage($imgURL)==false) $imgURL = ''; if ($imgURL!='') return $imgURL;
|
90 |
-
|
91 |
-
if ($imgURL==''
|
92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
return $imgURL;
|
94 |
}}
|
95 |
if (!function_exists('nxs_makeURLParams')){ function nxs_makeURLParams($params) { global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
|
@@ -103,9 +121,80 @@ if (!function_exists('nxs_makeURLParams')){ function nxs_makeURLParams($params)
|
|
103 |
return $templ;
|
104 |
}}
|
105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
//## CSS && JS
|
107 |
if (!function_exists("jsPostToSNAP")) { function jsPostToSNAP() { global $nxs_snapAvNts, $nxs_plurl; ?>
|
108 |
-
<script type="text/javascript" >
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
jQuery(document).ready(function($) {
|
110 |
<?php
|
111 |
foreach ($nxs_snapAvNts as $avNt) {?>
|
@@ -186,7 +275,7 @@ if (!function_exists("nxs_jsPostToSNAP2")){ function nxs_jsPostToSNAP2() { glob
|
|
186 |
});
|
187 |
</script>
|
188 |
|
189 |
-
<link href='
|
190 |
<style type="text/css">
|
191 |
.NXSButton { background-color:#89c403;
|
192 |
background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #89c403), color-stop(1, #77a809) );
|
@@ -238,13 +327,25 @@ background:#f1f1f1;background-image:-webkit-gradient(linear,left bottom,left top
|
|
238 |
.nxs_box_inside{line-height: 1.4em; padding: 10px;}
|
239 |
.nxs_box_inside input{ padding: 5px; border: 1px solid #ACACAC;}
|
240 |
.nxs_box_inside .insOneDiv, #nsx_addNT .insOneDiv{max-width: 1020px; background-color: #f8f9f9; background-repeat: no-repeat; margin: 10px; border: 1px solid #808080; padding: 10px; display:none;}
|
|
|
|
|
|
|
241 |
|
|
|
|
|
|
|
|
|
|
|
242 |
|
|
|
|
|
|
|
|
|
243 |
</style>
|
244 |
<?php }}
|
245 |
|
246 |
-
if (!function_exists('nxs_doShowHint')){ function nxs_doShowHint($t){ ?>
|
247 |
-
<div id="<?php echo $t; ?>Hint" class="nxs_FRMTHint" style="font-size: 11px; margin: 2px; margin-top: 0px; padding:7px; border: 1px solid #C0C0C0; width:
|
248 |
<?php }}
|
249 |
|
250 |
if (!function_exists('nxs_doSMAS')){ function nxs_doSMAS($nType, $typeii) { ?><div id="do<?php echo $typeii; ?>Div" class="clNewNTSets" style="margin-left: 10px; display:none; "><div style="font-size: 15px; text-align: center;"><br/><br/>
|
@@ -272,17 +373,48 @@ if (!function_exists("nxs_chArrVar")) { function nxs_chArrVar($arr, $varN, $varV
|
|
272 |
|
273 |
if (!function_exists("nxs_metaMarkAsPosted")) { function nxs_metaMarkAsPosted($postID, $nt, $did, $args=''){ $mpo = get_post_meta($postID, 'snap'.$nt, true); $mpo = maybe_unserialize($mpo);
|
274 |
if (!is_array($mpo)) $mpo = array(); if (!is_array($mpo[$did])) $mpo[$did] = array();
|
275 |
-
if ($args=='' || $args['isPosted']==1) $mpo[$did]['isPosted'] = '1';
|
276 |
if (is_array($args) && isset($args['isPrePosted']) && $args['isPrePosted']==1) $mpo[$did]['isPrePosted'] = '1';
|
277 |
if (is_array($args) && isset($args['pgID'])) $mpo[$did]['pgID'] = $args['pgID'];
|
|
|
278 |
if (is_array($args) && isset($args['pDate'])) $mpo[$did]['pDate'] = $args['pDate'];
|
279 |
-
/*$mpo = mysql_real_escape_string(serialize($mpo)); */ delete_post_meta($postID, 'snap'.$nt); add_post_meta($postID, 'snap'.$nt, $mpo);
|
280 |
}}
|
281 |
-
if (!function_exists('
|
282 |
-
$
|
283 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
284 |
}}
|
285 |
|
|
|
|
|
286 |
if (!function_exists('nxsMergeArraysOV')){function nxsMergeArraysOV($Arr1, $Arr2){
|
287 |
foreach($Arr2 as $key => $value) { if(array_key_exists($key, $Arr1) && is_array($value)) $Arr1[$key] = nxsMergeArraysOV($Arr1[$key], $Arr2[$key]); else $Arr1[$key] = $value;} return $Arr1;
|
288 |
}}
|
@@ -318,29 +450,118 @@ if (!function_exists("nxs_mkShortURL")) { function nxs_mkShortURL($url, $postID=
|
|
318 |
if ($rtr['status_code']=='200') $rurl = $rtr['data']['url'];
|
319 |
} //echo "###".$rurl;
|
320 |
if ($options['nxsURLShrtnr']=='W' && function_exists('wp_get_shortlink')) { global $post; $post = get_post($postID); $rurl = wp_get_shortlink($postID, 'post'); }
|
321 |
-
if ($
|
322 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
323 |
}}
|
324 |
//## Comments
|
325 |
if (!function_exists("nxs_postNewComment")) { function nxs_postNewComment($cmnt, $aa = false) { $cmnt['comment_post_ID'] = (int) $cmnt['comment_post_ID'];
|
326 |
$cmnt['comment_parent'] = isset($cmnt['comment_parent']) ? absint($cmnt['comment_parent']) : 0;
|
327 |
$parent_status = ( 0 < $cmnt['comment_parent'] ) ? wp_get_comment_status($cmnt['comment_parent']) : '';
|
328 |
$cmnt['comment_parent'] = ( 'approved' == $parent_status || 'unapproved' == $parent_status ) ? $cmnt['comment_parent'] : 0;
|
329 |
-
$cmnt['comment_author_IP'] = ''; $cmnt['comment_agent'] = 'SNAP'; $cmnt['comment_date'] = get_date_from_gmt( $cmnt['comment_date_gmt'] );
|
|
|
330 |
$cmnt = wp_filter_comment($cmnt); if ($aa) $cmnt['comment_approved'] = 1; else $cmnt['comment_approved'] = wp_allow_comment($cmnt); $cmntID = wp_insert_comment($cmnt);
|
331 |
if ( 'spam' !== $cmnt['comment_approved'] ) { if ( '0' == $cmnt['comment_approved'] ) wp_notify_moderator($cmntID); $post = &get_post($cmnt['comment_post_ID']);
|
332 |
-
if ( get_option('comments_notify') && $cmnt['comment_approved'] && ( ! isset( $cmnt['user_id'] ) || $post->post_author != $cmnt['user_id'] ) ) wp_notify_postauthor($cmntID, isset( $cmnt['comment_type'] ) ? $cmnt['comment_type'] : '' );
|
333 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
334 |
}}
|
335 |
|
336 |
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
344 |
}}
|
345 |
|
346 |
if (!function_exists("nxs_addToRI")) { function nxs_addToRI($postID) { global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
|
@@ -350,15 +571,25 @@ if (!function_exists("nxs_addToRI")) { function nxs_addToRI($postID) { global $p
|
|
350 |
|
351 |
function nxs_activation(){ if (!wp_next_scheduled('nxs_hourly_event')){wp_schedule_event(time(), 'hourly', 'nxs_hourly_event');} }
|
352 |
function nxs_do_this_hourly() { $options = get_option('NS_SNAutoPoster'); $riPosts = get_option('NS_SNriPosts'); if (!is_array($riPosts)) $riPosts = array(); //## Check for Incoming Comments if nessesary.
|
353 |
-
|
|
|
|
|
354 |
//## Facebook
|
355 |
-
foreach ($options['fb'] as $ii=>$fbo) if ($fbo['riComments']=='1') { $fbo['ii'] = $ii; $fbo['pType'] = 'aj';
|
356 |
foreach ($riPosts as $postID) {
|
357 |
$fbpo = get_post_meta($postID, 'snapFB', true); $fbpo = maybe_unserialize($fbpo);
|
358 |
if (is_array($fbpo) && isset($fbpo[$ii]) && is_array($fbpo[$ii]) ){ $ntClInst = new nxs_snapClassFB(); $fbo = $ntClInst->adjMetaOpt($fbo, $fbpo[$ii]); }
|
359 |
nxs_getBackFBComments($postID, $fbo, $fbpo[$ii]);
|
360 |
}
|
361 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
362 |
}
|
363 |
|
364 |
class NXS_HtmlFixer { public $dirtyhtml; public $fixedhtml; public $allowed_styles; private $matrix; public $debug; private $fixedhtmlDisplayCode;
|
@@ -429,7 +660,7 @@ class NXS_HtmlFixer { public $dirtyhtml; public $fixedhtml; public $allowed_styl
|
|
429 |
}
|
430 |
private function removeSpacesAndBadTags($s) { $i=0;
|
431 |
while ($i<10) { $i++; $s = preg_replace (
|
432 |
-
array( '/
|
433 |
'/<font([^>])*>( )*\s*<\/font>/i', '/<small([^>])*>( )*\s*<\/small>/i', '/<\?xml:namespace([^>])*><\/\?xml:namespace>/i', '/<\?xml:namespace([^>])*\/>/i', '/class=\"MsoNormal\"/i',
|
434 |
'/<o:p><\/o:p>/i', '/<!DOCTYPE([^>])*>/i', '/<!--(.|\s)*?-->/', '/<\?(.|\s)*?\?>/'),
|
435 |
array(' ', ' ', '', '', '', '', '', '', '', '', '', ' ', '', '' ) , trim($s));
|
14 |
if (!function_exists('nxs_decodeEntitiesFull')){ function nxs_decodeEntitiesFull($string, $quotes = ENT_COMPAT, $charset = 'utf-8') {
|
15 |
return html_entity_decode(preg_replace_callback('/&([a-zA-Z][a-zA-Z0-9]+);/', 'nxs_convertEntity', $string), $quotes, $charset);
|
16 |
}}
|
17 |
+
if (!function_exists('nxs_strLen')){ function nxs_strLen($str) { return count(str_split(utf8_decode($str))); }}
|
18 |
if (!function_exists('nxs_convertEntity')){ function nxs_convertEntity($matches, $destroy = true) {
|
19 |
static $table = array('quot' => '"','amp' => '&','lt' => '<','gt' => '>','OElig' => 'Œ','oelig' => 'œ','Scaron' => 'Š','scaron' => 'š','Yuml' => 'Ÿ','circ' => 'ˆ','tilde' => '˜','ensp' => ' ','emsp' => ' ','thinsp' => ' ','zwnj' => '‌','zwj' => '‍','lrm' => '‎','rlm' => '‏','ndash' => '–','mdash' => '—','lsquo' => '‘','rsquo' => '’','sbquo' => '‚','ldquo' => '“','rdquo' => '”','bdquo' => '„','dagger' => '†','Dagger' => '‡','permil' => '‰','lsaquo' => '‹','rsaquo' => '›','euro' => '€','fnof' => 'ƒ','Alpha' => 'Α','Beta' => 'Β','Gamma' => 'Γ','Delta' => 'Δ','Epsilon' => 'Ε','Zeta' => 'Ζ','Eta' => 'Η','Theta' => 'Θ','Iota' => 'Ι','Kappa' => 'Κ','Lambda' => 'Λ','Mu' => 'Μ','Nu' => 'Ν','Xi' => 'Ξ','Omicron' => 'Ο','Pi' => 'Π','Rho' => 'Ρ','Sigma' => 'Σ','Tau' => 'Τ','Upsilon' => 'Υ','Phi' => 'Φ','Chi' => 'Χ','Psi' => 'Ψ','Omega' => 'Ω','alpha' => 'α','beta' => 'β','gamma' => 'γ','delta' => 'δ','epsilon' => 'ε','zeta' => 'ζ','eta' => 'η','theta' => 'θ','iota' => 'ι','kappa' => 'κ','lambda' => 'λ','mu' => 'μ','nu' => 'ν','xi' => 'ξ','omicron' => 'ο','pi' => 'π','rho' => 'ρ','sigmaf' => 'ς','sigma' => 'σ','tau' => 'τ','upsilon' => 'υ','phi' => 'φ','chi' => 'χ','psi' => 'ψ','omega' => 'ω','thetasym' => 'ϑ','upsih' => 'ϒ','piv' => 'ϖ','bull' => '•','hellip' => '…','prime' => '′','Prime' => '″','oline' => '‾','frasl' => '⁄','weierp' => '℘','image' => 'ℑ','real' => 'ℜ','trade' => '™','alefsym' => 'ℵ','larr' => '←','uarr' => '↑','rarr' => '→','darr' => '↓','harr' => '↔','crarr' => '↵','lArr' => '⇐','uArr' => '⇑','rArr' => '⇒','dArr' => '⇓','hArr' => '⇔','forall' => '∀','part' => '∂','exist' => '∃','empty' => '∅','nabla' => '∇','isin' => '∈','notin' => '∉','ni' => '∋','prod' => '∏','sum' => '∑','minus' => '−','lowast' => '∗','radic' => '√','prop' => '∝','infin' => '∞','ang' => '∠','and' => '∧','or' => '∨','cap' => '∩','cup' => '∪','int' => '∫','there4' => '∴','sim' => '∼','cong' => '≅','asymp' => '≈','ne' => '≠','equiv' => '≡','le' => '≤','ge' => '≥','sub' => '⊂','sup' => '⊃','nsub' => '⊄','sube' => '⊆','supe' => '⊇','oplus' => '⊕','otimes' => '⊗','perp' => '⊥','sdot' => '⋅','lceil' => '⌈','rceil' => '⌉','lfloor' => '⌊','rfloor' => '⌋','lang' => '〈','rang' => '〉','loz' => '◊','spades' => '♠','clubs' => '♣','hearts' => '♥','diams' => '♦','nbsp' => ' ','iexcl' => '¡','cent' => '¢','pound' => '£','curren' => '¤','yen' => '¥','brvbar' => '¦','sect' => '§','uml' => '¨','copy' => '©','ordf' => 'ª','laquo' => '«','not' => '¬','shy' => '­','reg' => '®','macr' => '¯','deg' => '°','plusmn' => '±','sup2' => '²','sup3' => '³','acute' => '´','micro' => 'µ','para' => '¶','middot' => '·','cedil' => '¸','sup1' => '¹','ordm' => 'º','raquo' => '»','frac14' => '¼','frac12' => '½','frac34' => '¾','iquest' => '¿','Agrave' => 'À','Aacute' => 'Á','Acirc' => 'Â','Atilde' => 'Ã','Auml' => 'Ä','Aring' => 'Å','AElig' => 'Æ','Ccedil' => 'Ç','Egrave' => 'È','Eacute' => 'É','Ecirc' => 'Ê','Euml' => 'Ë','Igrave' => 'Ì','Iacute' => 'Í','Icirc' => 'Î','Iuml' => 'Ï','ETH' => 'Ð','Ntilde' => 'Ñ','Ograve' => 'Ò','Oacute' => 'Ó','Ocirc' => 'Ô','Otilde' => 'Õ','Ouml' => 'Ö','times' => '×','Oslash' => 'Ø','Ugrave' => 'Ù','Uacute' => 'Ú','Ucirc' => 'Û','Uuml' => 'Ü','Yacute' => 'Ý','THORN' => 'Þ','szlig' => 'ß','agrave' => 'à','aacute' => 'á','acirc' => 'â','atilde' => 'ã','auml' => 'ä','aring' => 'å','aelig' => 'æ','ccedil' => 'ç','egrave' => 'è','eacute' => 'é','ecirc' => 'ê','euml' => 'ë','igrave' => 'ì','iacute' => 'í','icirc' => 'î','iuml' => 'ï','eth' => 'ð','ntilde' => 'ñ','ograve' => 'ò','oacute' => 'ó','ocirc' => 'ô','otilde' => 'õ','ouml' => 'ö','divide' => '÷','oslash' => 'ø','ugrave' => 'ù','uacute' => 'ú','ucirc' => 'û','uuml' => 'ü','yacute' => 'ý','thorn' => 'þ','yuml' => 'ÿ');
|
20 |
if (isset($table[$matches[1]])) return $table[$matches[1]];
|
26 |
//$output = preg_match_all( '/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $postCnt, $matches ); if ($output === false){return false;}
|
27 |
//$postCnt = str_replace("'",'"',$postCnt); $output = preg_match_all( '/src="([^"]*)"/', $postCnt, $matches ); if ($output === false){return false;}
|
28 |
$postCnt = str_replace("'",'"',$postCnt); $output = preg_match_all( '/< *img[^>]*src *= *["\']?([^"\']*)/i', $postCnt, $matches ); // prr($matches);
|
29 |
+
if ($output === false || $output == 0){ $vids = nsFindVidsInPost($post, $advImgFnd==false); if (count($vids)>0) $postImgs[] = 'http://img.youtube.com/vi/'.$vids[0].'/0.jpg'; else return false;}
|
30 |
else { foreach ($matches[1] as $match) { if (!preg_match('/^https?:\/\//', $match ) ) $match = site_url( '/' ) . ltrim( $match, '/' ); $postImgs[] = $match;} if (isset($ShownAds)) $ShownAds = $ShownAdsL; }
|
31 |
return $postImgs;
|
32 |
}}
|
33 |
|
34 |
|
35 |
+
if (!function_exists('nsFindAudioInPost')){function nsFindAudioInPost($post, $raw=true) { //### !!! $raw=false Breaks ob_start() [ref.outcontrol]: Cannot use output buffering in output buffering display handlers - Investigate
|
36 |
global $ShownAds; if (isset($ShownAds)) $ShownAdsL = $ShownAds; $postVids = array();
|
37 |
if (is_object($post)) { if ($raw) $postCnt = $post->post_content; else $postCnt = apply_filters('the_content', $post->post_content); } else $postCnt = $post;
|
38 |
$regex_pattern = "((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*\.(mp3|aac|m4a))";
|
39 |
$output = preg_match_all( $regex_pattern, $postCnt, $matches ); if ($output === false){return false;}
|
40 |
+
foreach ($matches[0] as $match) { $postAu[] = $match; } $postAu = array_unique($postAu); if (isset($ShownAds)) $ShownAds = $ShownAdsL; return $postAu;
|
|
|
|
|
41 |
}}
|
42 |
+
if (!function_exists('nsGetYTThumb')){function nsGetYTThumb($yt) {
|
43 |
+
$out = 'http://img.youtube.com/vi/'.$yt.'/maxresdefault.jpg'; $response = wp_remote_get($out);
|
44 |
+
if (is_wp_error($response) || $response['response']['code']!='200' ) { $out = 'http://img.youtube.com/vi/'.$yt.'/sddefault.jpg';
|
45 |
+
$response = wp_remote_get($out); if (is_wp_error($response) || $response['response']['code']!='200' ) $out = 'http://img.youtube.com/vi/'.$yt.'/0.jpg';
|
46 |
+
} return $out;
|
47 |
+
}}
|
48 |
+
if (!function_exists('nsFindVidsInPost')){function nsFindVidsInPost($post, $raw=true) { //### !!! $raw=false ## Breaks ob_start() [ref.outcontrol]: Cannot use output buffering in output buffering display handlers - Investigate
|
49 |
global $ShownAds; if (isset($ShownAds)) $ShownAdsL = $ShownAds; $postVids = array();
|
50 |
+
if (is_object($post)) { if ($raw) $postCnt = $post->post_content; else $postCnt = apply_filters('the_content', $post->post_content); } else $postCnt = $post; //prr($postCnt);
|
51 |
+
$postCnt = preg_replace('/youtube.com\/vi\/(.*)\/(.*).jpg/isU', "youtube.com/v/$1/", $postCnt);
|
52 |
+
$output = preg_match_all( '@((https?://)?([-\w]+\.[-\w\.]+)+\w(:\d+)?(/([-\w/_\.]*(\?\S+)?)?(#[a-z_.-][a-z0-9+\$_.-]*)?)*)@', $postCnt, $matches ); if ($output === false){return false;}
|
53 |
foreach ($matches[0] as $match) {
|
54 |
+
$output2 = preg_match_all( '%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"<>&?/ ]{11})%i', $match, $matches2 ); if ($output2 === false){return false;}
|
55 |
foreach ($matches2[1] as $match2) { $match2 = trim($match2); if (strlen($match2)==11) $postVids[] = $match2;}
|
56 |
$output3 = preg_match_all( '/^http:\/\/(www\.)?vimeo\.com\/(clip\:)?(\d+).*$/', $match, $matches3 ); if ($output3 === false){return false;}
|
57 |
foreach ($matches3[3] as $match3) { $match3 = trim($match3); if (strlen($match3)==8) $postVids[] = $match3;}
|
58 |
} $postVids = array_unique($postVids); if (isset($ShownAds)) $ShownAds = $ShownAdsL; return $postVids;
|
59 |
}}
|
60 |
+
if (!function_exists('nsTrnc')){ function nsTrnc($string, $limit, $break=" ", $pad=" ...") { if(strlen($string) <= $limit) return $string; if(strlen($pad) >= $limit) return ''; $string = substr($string, 0, $limit-strlen($pad));
|
61 |
$brLoc = strripos($string, $break); if ($brLoc===false) return $string.$pad; else return substr($string, 0, $brLoc).$pad;
|
62 |
}}
|
63 |
if (!function_exists('nsSubStrEl')){ function nsSubStrEl($string, $length, $end='...'){ if (strlen($string) > $length){ $length -= strlen($end); $string = substr($string, 0, $length); $string .= $end; } return $string;}}
|
74 |
}}
|
75 |
if (!function_exists('nxs_chckRmImage')){function nxs_chckRmImage($url, $chType='head'){ if( ini_get('allow_url_fopen')=='1' && @getimagesize($url)!==false) return true;
|
76 |
$hdrsArr = nxs_getNXSHeaders(); $nxsWPRemWhat = 'wp_remote_'.$chType; $rsp = $nxsWPRemWhat($url, array('headers' => $hdrsArr));
|
77 |
+
if(is_wp_error($rsp)) { nxs_addToLogN('E', 'Error', 'IMAGE', '-=ERROR=- Server can\'t access it\'s own images. Most probably it\'s a DNS problem. Please contact your hosting provider. '.print_r($rsp, true), ''); return false; }
|
78 |
if (is_array($rsp) && ($rsp['response']['code']=='200' || ( $rsp['response']['code']=='403' && $rsp['headers']['server']=='cloudflare-nginx') )) return true;
|
79 |
+
else { if ($chType=='head') { return nxs_chckRmImage($url, 'get'); } else { nxs_addToLogN('E', 'Error', 'IMAGE', '-=ERROR=- Server can\'t access it\'s own images. Most probably it\'s a DNS problem. Please contact your hosting provider. '.print_r($rsp, true), $url); return false; }
|
80 |
}
|
81 |
}}
|
82 |
if (!function_exists('nxs_getPostImage')){ function nxs_getPostImage($postID, $size='large', $def='') { $imgURL = ''; global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
|
83 |
$imgURL = "https://www.google.com/images/srpr/logo3w.png"; $res = nxs_chckRmImage($imgURL); $imgURL = ''; if (!$res) $options['imgNoCheck'] = '1';
|
84 |
+
//## Featured Image from Specified Location
|
85 |
+
if ((int)$postID>0 && isset($options['featImgLoc']) && $options['featImgLoc']!=='') { $afiLoc= get_post_meta($postID, $options['featImgLoc'], true);
|
86 |
+
if (is_array($afiLoc) && $options['featImgLocArrPath']!='') { $cPath = $options['featImgLocArrPath'];
|
87 |
+
while (strpos($cPath, '[')!==false){ $arrIt = CutFromTo($cPath, '[', ']'); $arrIt = str_replace("'", "", str_replace('"', '', $arrIt)); $afiLoc = $afiLoc[$arrIt]; $cPath = substr($cPath, strpos($cPath, ']'));}
|
88 |
+
} $imgURL = trim($options['featImgLocPrefix']).trim($afiLoc); if ($imgURL!='' && stripos($imgURL, 'http')===false) $imgURL = home_url().$imgURL;
|
89 |
+
}
|
90 |
if ($imgURL!='' && $options['imgNoCheck']!='1' && nxs_chckRmImage($imgURL)==false) $imgURL = ''; if ($imgURL!='') return $imgURL;
|
91 |
+
//## Featured Image
|
92 |
+
if ($imgURL=='') { if ((int)$postID>0 && function_exists("get_post_thumbnail_id") ){ $imgURL = wp_get_attachment_image_src(get_post_thumbnail_id($postID), $size); $imgURL = $imgURL[0]; } }
|
93 |
if ($imgURL!='' && $options['imgNoCheck']!='1' && nxs_chckRmImage($imgURL)==false) $imgURL = ''; if ($imgURL!='') return $imgURL;
|
94 |
+
//## YAPB
|
95 |
+
if ((int)$postID>0 && class_exists("YapbImage")) { $imgURLObj = YapbImage::getInstanceFromDb($postID); if (is_object($imgURLObj)) $imgURL = $imgURLObj->uri;
|
96 |
+
$stURL = site_url(); if (substr($stURL, -1)=='/') $stURL = substr($stURL, 0, -1); if ($imgURL!='') $imgURL = $stURL.$imgURL;
|
97 |
}
|
|
|
|
|
98 |
if ($imgURL!='' && $options['imgNoCheck']!='1' && nxs_chckRmImage($imgURL)==false) $imgURL = ''; if ($imgURL!='') return $imgURL;
|
99 |
+
//## Find Images in Post
|
100 |
+
if ((int)$postID>0 && $imgURL=='') {$post = get_post($postID); $imgsFromPost = nsFindImgsInPost($post, $options['useUnProc'] == '1'); if (is_array($imgsFromPost) && count($imgsFromPost)>0) $imgURL = $imgsFromPost[0]; } //echo "##".count($imgsFromPost); prr($imgsFromPost);
|
101 |
+
if ($imgURL!='' && $options['imgNoCheck']!='1' && nxs_chckRmImage($imgURL)==false) $imgURL = ''; if ($imgURL!='') return $imgURL;
|
102 |
+
//## Attachements
|
103 |
+
if ((int)$postID>0 && $imgURL=='') { $attachments = get_posts(array('post_type' => 'attachment', 'posts_per_page' => -1, 'post_parent' => $postID));
|
104 |
+
if (is_array($attachments) && is_object($attachments[0])) $imgURL = wp_get_attachment_image_src($attachments[0]->ID, $size); $imgURL = $imgURL[0];
|
105 |
+
}
|
106 |
+
if ($imgURL!='' && $options['imgNoCheck']!='1' && nxs_chckRmImage($imgURL)==false) $imgURL = ''; if ($imgURL!='') return $imgURL;
|
107 |
+
//## Default
|
108 |
+
if (trim($imgURL)=='' && trim($def)=='') $imgURL = $options['ogImgDef'];
|
109 |
+
if (trim($imgURL)=='' && trim($def)!='') $imgURL = $def;
|
110 |
+
|
111 |
return $imgURL;
|
112 |
}}
|
113 |
if (!function_exists('nxs_makeURLParams')){ function nxs_makeURLParams($params) { global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
|
121 |
return $templ;
|
122 |
}}
|
123 |
|
124 |
+
function nxs_tiny_mce_before_init( $init ) {
|
125 |
+
$init['setup'] = "function( ed ) { ed.onChange.add( function( ed, e ) {
|
126 |
+
nxs_updateGetImgsX( e );
|
127 |
+
}); }";
|
128 |
+
return $init;
|
129 |
+
}
|
130 |
+
add_filter( 'tiny_mce_before_init', 'nxs_tiny_mce_before_init' );
|
131 |
+
|
132 |
//## CSS && JS
|
133 |
if (!function_exists("jsPostToSNAP")) { function jsPostToSNAP() { global $nxs_snapAvNts, $nxs_plurl; ?>
|
134 |
+
<script type="text/javascript" >
|
135 |
+
function nxs_updateGetImgsX(e){ }
|
136 |
+
jQuery(document).on('change', '#content', function( e ) {
|
137 |
+
nxs_updateGetImgsX( e );
|
138 |
+
});
|
139 |
+
function nxs_updateGetImgsXX(e){
|
140 |
+
var targetId = e.target.id;
|
141 |
+
var text = 'Kortinko';
|
142 |
+
|
143 |
+
switch ( targetId ) {
|
144 |
+
|
145 |
+
case 'content':
|
146 |
+
text = jQuery('#content').val();
|
147 |
+
break;
|
148 |
+
|
149 |
+
case 'tinymce':
|
150 |
+
if ( tinymce.activeEditor )
|
151 |
+
text = tinymce.activeEditor.getContent();
|
152 |
+
break;
|
153 |
+
}
|
154 |
+
|
155 |
+
jQuery('.nxs_imgPrevList').html( text );
|
156 |
+
}
|
157 |
+
|
158 |
+
function nxs_clPrvImgShow(tIdN){ jQuery("#isAutoImg-"+tIdN).trigger('click'); jQuery("#isAutoImg-"+tIdN).trigger('click'); }
|
159 |
+
|
160 |
+
function nxs_clPrvImg(id, ii){ jQuery("#imgToUse-"+ii).val(jQuery("#"+id+" img").attr('src')); jQuery(".nxs_prevIDiv"+ii+" .nxs_checkIcon").hide();
|
161 |
+
jQuery(".nxs_prevIDiv"+ii).removeClass("nxs_chImg_selDiv"); jQuery(".nxs_prevIDiv"+ii+" img").removeClass("nxs_chImg_selImg");
|
162 |
+
jQuery("#"+id+" img").addClass("nxs_chImg_selImg"); jQuery("#"+id).addClass("nxs_chImg_selDiv"); jQuery("#"+id+" .nxs_checkIcon").show();
|
163 |
+
}
|
164 |
+
|
165 |
+
function nxs_getOriginalWidthOfImg(img_element) { var t = new Image(); t.src = (img_element.getAttribute ? img_element.getAttribute("src") : false) || img_element.src; /* alert(t.src+" | "+t.width); */ return t.width; }
|
166 |
+
|
167 |
+
function nxs_updateGetImgs(e){
|
168 |
+
var textOut='';
|
169 |
+
var tId = e.target.id;
|
170 |
+
var tIdN = tId.replace("isAutoImg-", "");
|
171 |
+
if ( tinymce.activeEditor ) text = tinymce.activeEditor.getContent(); else text = jQuery('#content').val();
|
172 |
+
jQuery('#NS_SNAP_AddPostMetaTags').append('<div id="nxs_tempDivImgs" style="display: none;"></div>'); jQuery('#nxs_tempDivImgs').append(text);
|
173 |
+
var textOutA = new Array(); var currSelImg = jQuery("#imgToUse-"+tIdN).val();
|
174 |
+
|
175 |
+
textOutA.push('http://cdn.gtln.us/img/nxs/noImgC.png');
|
176 |
+
var fImg = jQuery('.attachment-post-thumbnail').attr('src'); if (fImg!='' && fImg!=undefined) { textOutA.push(fImg); if (currSelImg=='') currSelImg = fImg; }
|
177 |
+
var fImg = jQuery('#yapbdiv img').attr('src'); if (fImg!='' && fImg!=undefined) { textOutA.push(fImg); if (currSelImg=='') currSelImg = fImg; }
|
178 |
+
|
179 |
+
jQuery('#nxs_tempDivImgs img').each(function(){ var prWidth; prWidth = nxs_getOriginalWidthOfImg(this); if (prWidth!=1) textOutA.push(jQuery(this).attr('src')); });
|
180 |
+
jQuery('#nxs_tempDivImgs').remove();
|
181 |
+
var index; for (index = 0; index < textOutA.length; ++index) { var isSel = currSelImg == textOutA[index] ? 'nxs_chImg_selImg' : ''; var isSelDisp = currSelImg == textOutA[index] ? 'style="display:block;"' : '';
|
182 |
+
textOut = textOut + '<div class="nxs_prevIDiv'+tIdN+' nxs_prevImagesDiv" id="nxs_idiv'+tIdN+index+'" onclick="nxs_clPrvImg(\'nxs_idiv'+tIdN+index+'\', \''+tIdN+'\');"><img class="nxs_prevImages '+isSel+'" src="'+textOutA[index]+'"><div '+isSelDisp+' class="nxs_checkIcon"><div class="media-modal-icon"></div></div></div>';
|
183 |
+
}
|
184 |
+
jQuery('#imgPrevList-'+tIdN).html( textOut );
|
185 |
+
if (jQuery('#'+tId).is(":checked")) jQuery('#imgPrevList-'+tIdN).hide(); else { jQuery('#nxs_'+tIdN+'_idivD').hide(); jQuery('#imgPrevList-'+tIdN).show(); }
|
186 |
+
|
187 |
+
}
|
188 |
+
|
189 |
+
jQuery(document).on('change', '.isAutoImg', function( e ) {
|
190 |
+
nxs_updateGetImgs( e );
|
191 |
+
});
|
192 |
+
jQuery(document).on('change', '#wp-content-editor-container #conXXtent', function() {
|
193 |
+
nxs_updateGetImgs();
|
194 |
+
});
|
195 |
+
jQuery(document).on('change', '#tinXXymce', function() {
|
196 |
+
nxs_updateGetImgs();
|
197 |
+
});
|
198 |
jQuery(document).ready(function($) {
|
199 |
<?php
|
200 |
foreach ($nxs_snapAvNts as $avNt) {?>
|
275 |
});
|
276 |
</script>
|
277 |
|
278 |
+
<link href='https://fonts.googleapis.com/css?family=News+Cycle' rel='stylesheet' type='text/css'>
|
279 |
<style type="text/css">
|
280 |
.NXSButton { background-color:#89c403;
|
281 |
background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #89c403), color-stop(1, #77a809) );
|
327 |
.nxs_box_inside{line-height: 1.4em; padding: 10px;}
|
328 |
.nxs_box_inside input{ padding: 5px; border: 1px solid #ACACAC;}
|
329 |
.nxs_box_inside .insOneDiv, #nsx_addNT .insOneDiv{max-width: 1020px; background-color: #f8f9f9; background-repeat: no-repeat; margin: 10px; border: 1px solid #808080; padding: 10px; display:none;}
|
330 |
+
.nxs_box_inside .itemDiv {margin:5px;margin-left:10px;}
|
331 |
+
.nxs_box_header h3 {font-size: 14px; margin-bottom: 2px; margin-top: 2px;}
|
332 |
+
.nxs_newLabel {font-size: 11px; color:red; padding-left: 5px; padding-right: 5px;}
|
333 |
|
334 |
+
.nxs_prevImagesDiv {border:1px solid #0f3c6d; width:110px; height:110px; margin:3px; padding:3px; text-align:center; float:left; position: relative;}
|
335 |
+
.nxs_prevImages {padding:1px; max-height:100px; max-width:100px;}
|
336 |
+
.nxs_chImg_selDiv {border:1px solid #800000;}
|
337 |
+
.nxs_chImg_selImg {border:4px solid #800000;}
|
338 |
+
.nxs_checkIcon{position: absolute;}
|
339 |
|
340 |
+
.nxs_checkIcon{display:none; height:24px;width:24px;position:absolute;top:-7px;right:-7px;outline:0;border:1px solid #fff;border-radius:3px;box-shadow:0 0 0 1px rgba(0,0,0,0.4);background:#800000;background-image:-webkit-gradient(linear,left top,left bottom,from(#800000),to(#570000));background-image:-webkit-linear-gradient(top,#800000,#570000);background-image:-moz-linear-gradient(top,#800000,#570000);background-image:-o-linear-gradient(top,#800000,#570000);background-image:linear-gradient(to bottom,#800000,#570000)}
|
341 |
+
.nxs_checkIcon{ top:-5px; right: -3px; width: 15px; height: 15px; box-shadow:0 0 0 1px #800000;background:#800000;background-image:-webkit-gradient(linear,left top,left bottom,from(#800000),to(#570000));background-image:-webkit-linear-gradient(top,#800000,#570000);background-image:-moz-linear-gradient(top,#800000,#570000);background-image:-o-linear-gradient(top,#800000,#570000);background-image:linear-gradient(to bottom,#800000,#570000)}
|
342 |
+
.nxs_checkIcon div{background-position:-21px 0; width: 15px; height: 15px;}
|
343 |
+
|
344 |
</style>
|
345 |
<?php }}
|
346 |
|
347 |
+
if (!function_exists('nxs_doShowHint')){ function nxs_doShowHint($t, $ex='', $wdth='79'){ ?>
|
348 |
+
<div id="<?php echo $t; ?>Hint" class="nxs_FRMTHint" style="font-size: 11px; margin: 2px; margin-top: 0px; padding:7px; border: 1px solid #C0C0C0; width: <?php echo $wdth; ?>%; background: #fff; display: none;"><span class="nxs_hili">%TITLE%</span> - <?php _e('Inserts the Title of the post', 'nxs_snap'); ?>, <span class="nxs_hili">%URL%</span> - <?php _e('Inserts the URL of the post', 'nxs_snap'); ?>, <span class="nxs_hili">%SURL%</span> - <?php _e('Inserts the <b>shortened URL</b> of your post', 'nxs_snap'); ?>, <span class="nxs_hili">%IMG%</span> - <?php _e('Inserts the featured image URL', 'nxs_snap'); ?>, <span class="nxs_hili">%EXCERPT%</span> - <?php _e('Inserts the excerpt of the post (processed)', 'nxs_snap'); ?>, <span class="nxs_hili">%RAWEXCERPT%</span> - <?php _e('Inserts the excerpt of the post (as typed)', 'nxs_snap'); ?>, <span class="nxs_hili">%ANNOUNCE%</span> - <?php _e('Inserts the text till the <!--more--> tag or first N words of the post', 'nxs_snap'); ?>, <span class="nxs_hili">%FULLTEXT%</span> - <?php _e('Inserts the processed body(text) of the post', 'nxs_snap'); ?>, <span class="nxs_hili">%RAWTEXT%</span> - <?php _e('Inserts the body(text) of the post as typed', 'nxs_snap'); ?>, <span class="nxs_hili">%TAGS%</span> - <?php _e('Inserts post tags', 'nxs_snap'); ?>, <span class="nxs_hili">%CATS%</span> - <?php _e('Inserts post categories', 'nxs_snap'); ?>, <span class="nxs_hili">%HTAGS%</span> - <?php _e('Inserts post tags as hashtags', 'nxs_snap'); ?>, <span class="nxs_hili">%HCATS%</span> - <?php _e('Inserts post categories as hashtags', 'nxs_snap'); ?>, <span class="nxs_hili">%AUTHORNAME%</span> - <?php _e('Inserts the author\'s name', 'nxs_snap'); ?>, <span class="nxs_hili">%SITENAME%</span> - <?php _e('Inserts the the Blog/Site name', 'nxs_snap'); ?>. <?php echo $ex; ?></div>
|
349 |
<?php }}
|
350 |
|
351 |
if (!function_exists('nxs_doSMAS')){ function nxs_doSMAS($nType, $typeii) { ?><div id="do<?php echo $typeii; ?>Div" class="clNewNTSets" style="margin-left: 10px; display:none; "><div style="font-size: 15px; text-align: center;"><br/><br/>
|
373 |
|
374 |
if (!function_exists("nxs_metaMarkAsPosted")) { function nxs_metaMarkAsPosted($postID, $nt, $did, $args=''){ $mpo = get_post_meta($postID, 'snap'.$nt, true); $mpo = maybe_unserialize($mpo);
|
375 |
if (!is_array($mpo)) $mpo = array(); if (!is_array($mpo[$did])) $mpo[$did] = array();
|
376 |
+
if ($args=='' || $args['isPosted']=='1') $mpo[$did]['isPosted'] = '1';
|
377 |
if (is_array($args) && isset($args['isPrePosted']) && $args['isPrePosted']==1) $mpo[$did]['isPrePosted'] = '1';
|
378 |
if (is_array($args) && isset($args['pgID'])) $mpo[$did]['pgID'] = $args['pgID'];
|
379 |
+
if (is_array($args) && isset($args['postURL'])) $mpo[$did]['postURL'] = $args['postURL'];
|
380 |
if (is_array($args) && isset($args['pDate'])) $mpo[$did]['pDate'] = $args['pDate'];
|
381 |
+
/*$mpo = mysql_real_escape_string(serialize($mpo)); */ delete_post_meta($postID, 'snap'.$nt); add_post_meta($postID, 'snap'.$nt, serialize($mpo));
|
382 |
}}
|
383 |
+
if (!function_exists('nxs_checkAddLogTable')){ function nxs_checkAddLogTable(){ global $nxs_tpWMPU, $wpdb; if($nxs_tpWMPU=='S') switch_to_blog(1);
|
384 |
+
$installed_ver = get_option( "nxs_log_db_table_version" ); if ($installed_ver=='1.1') return true;
|
385 |
+
$table_name = $wpdb->prefix . "nxs_log";
|
386 |
+
$sql = "CREATE TABLE $table_name (
|
387 |
+
id mediumint(9) NOT NULL AUTO_INCREMENT,
|
388 |
+
date datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
|
389 |
+
act VARCHAR(255) DEFAULT '' NOT NULL,
|
390 |
+
nt VARCHAR(255) DEFAULT '' NOT NULL,
|
391 |
+
type VARCHAR(255) DEFAULT '' NOT NULL,
|
392 |
+
msg text NOT NULL,
|
393 |
+
extInfo text NOT NULL,
|
394 |
+
UNIQUE KEY id (id)
|
395 |
+
) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;";
|
396 |
+
require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($sql);
|
397 |
+
delete_option("nxs_log_db_table_version"); add_option("nxs_log_db_table_version", '1.1');
|
398 |
+
if($nxs_tpWMPU=='S') restore_current_blog();
|
399 |
+
}}
|
400 |
+
if (!function_exists('nxs_getnxsLog')){ function nxs_getnxsLog(){ global $nxs_tpWMPU, $wpdb; if($nxs_tpWMPU=='S') switch_to_blog(1);
|
401 |
+
$log = $wpdb->get_results( "SELECT * FROM ". $wpdb->prefix . "nxs_log ORDER BY id", ARRAY_A ); if (!is_array($log)) return array(); else return $log;
|
402 |
+
}}
|
403 |
+
|
404 |
+
if (!function_exists('nxs_addToLog')){ function nxs_addToLog ($type, $action, $nt, $msg=''){ nxs_addToLogN ($type, $action, $nt, $msg); }}
|
405 |
+
if (!function_exists('nxs_addToLogN')){ function nxs_addToLogN ($type, $action, $nt, $msg, $extInfo=''){ global $nxs_tpWMPU, $wpdb; if($nxs_tpWMPU=='S') switch_to_blog(1);
|
406 |
+
$logItem = array('date'=>date('Y-m-d H:i:s'), 'act'=>$action, 'msg'=> strip_tags($msg), 'extInfo'=>$extInfo, 'type'=>$type, 'nt'=>$nt);
|
407 |
+
$nxDB = $wpdb->insert( $wpdb->prefix . "nxs_log", $logItem ); $lid = $wpdb->insert_id; $lid = $lid-150;
|
408 |
+
if ($lid>0) $wpdb->query( 'DELETE FROM '.$wpdb->prefix . 'nxs_log WHERE id<'.$lid );
|
409 |
+
|
410 |
+
// $nxsDBLog = get_option('NS_SNAutoPosterLog'); $nxsDBLog = maybe_unserialize($nxsDBLog); if(!is_array($nxsDBLog)) $nxsDBLog = array(); $nxsDBLog[] = $logItem; $nxsDBLog = array_slice($nxsDBLog, -150);
|
411 |
+
// $res = update_option('NS_SNAutoPosterLog', ($nxsDBLog));
|
412 |
+
//delete_option('NS_SNAutoPosterLog'); add_option('NS_SNAutoPosterLog', ($nxsDBLog));
|
413 |
+
if($nxs_tpWMPU=='S') restore_current_blog();
|
414 |
}}
|
415 |
|
416 |
+
|
417 |
+
|
418 |
if (!function_exists('nxsMergeArraysOV')){function nxsMergeArraysOV($Arr1, $Arr2){
|
419 |
foreach($Arr2 as $key => $value) { if(array_key_exists($key, $Arr1) && is_array($value)) $Arr1[$key] = nxsMergeArraysOV($Arr1[$key], $Arr2[$key]); else $Arr1[$key] = $value;} return $Arr1;
|
420 |
}}
|
450 |
if ($rtr['status_code']=='200') $rurl = $rtr['data']['url'];
|
451 |
} //echo "###".$rurl;
|
452 |
if ($options['nxsURLShrtnr']=='W' && function_exists('wp_get_shortlink')) { global $post; $post = get_post($postID); $rurl = wp_get_shortlink($postID, 'post'); }
|
453 |
+
if ($options['nxsURLShrtnr']=='Y' && trim($options['YOURLSKey']!='') && trim($options['YOURLSURL']!='')) { $timestamp = time(); $signature = md5( $timestamp . $options['YOURLSKey'] );
|
454 |
+
$flds = array('signature'=>$signature, 'action' => 'shorturl', 'url'=>$url, 'format'=>'json', 'timestamp'=>$timestamp);
|
455 |
+
$response = wp_remote_post(($options['YOURLSURL']), array('body' => $flds));
|
456 |
+
if (is_wp_error($response)) { nxs_addToLog('goo.gl', 'E', '-=ERROR=- '.print_r($response, true), ''); return false; }
|
457 |
+
$rtr = json_decode($response['body'],true); if (!is_array($rtr) || !isset($rtr['shorturl']) ) { nxs_addToLog('goo.gl', 'E', '-=ERROR=- '.print_r($response, true), ''); return false; }
|
458 |
+
$rurl = $rtr['shorturl'];
|
459 |
+
|
460 |
+
}
|
461 |
+
if ($options['nxsURLShrtnr']=='O' || $options['nxsURLShrtnr']=='' || $options['nxsURLShrtnr']=='G') {
|
462 |
+
$response = wp_remote_post('https://www.googleapis.com/urlshortener/v1/url'.($options['gglAPIKey']!=''?'?key='.$options['gglAPIKey']:''), array('headers' => array('Content-Type'=>'application/json'), 'body' => '{"longUrl": "'.$url.'"}'));
|
463 |
+
if (is_wp_error($response)) { nxs_addToLog('goo.gl', 'E', '-=ERROR=- '.print_r($response, true), ''); return false; }
|
464 |
+
$rtr = json_decode($response['body'],true); if (!is_array($rtr) || isset($rtr['error']) || !isset($rtr['id']) ) { nxs_addToLog('goo.gl', 'E', '-=ERROR=- '.print_r($response, true), ''); return false; }
|
465 |
+
$rurl = $rtr['id'];
|
466 |
+
}
|
467 |
+
//if ($rurl=='') { $response = wp_remote_get('http://gd.is/gtq/'.$url); if ((is_array($response) && ($response['response']['code']=='200'))) $rurl = $response['body']; }
|
468 |
+
if ($rurl!='') $url = $rurl; return $url;
|
469 |
}}
|
470 |
//## Comments
|
471 |
if (!function_exists("nxs_postNewComment")) { function nxs_postNewComment($cmnt, $aa = false) { $cmnt['comment_post_ID'] = (int) $cmnt['comment_post_ID'];
|
472 |
$cmnt['comment_parent'] = isset($cmnt['comment_parent']) ? absint($cmnt['comment_parent']) : 0;
|
473 |
$parent_status = ( 0 < $cmnt['comment_parent'] ) ? wp_get_comment_status($cmnt['comment_parent']) : '';
|
474 |
$cmnt['comment_parent'] = ( 'approved' == $parent_status || 'unapproved' == $parent_status ) ? $cmnt['comment_parent'] : 0;
|
475 |
+
$cmnt['comment_author_IP'] = ''; $cmnt['comment_agent'] = 'SNAP'; $cmnt['comment_date'] = get_date_from_gmt( $cmnt['comment_date_gmt'] );
|
476 |
+
|
477 |
$cmnt = wp_filter_comment($cmnt); if ($aa) $cmnt['comment_approved'] = 1; else $cmnt['comment_approved'] = wp_allow_comment($cmnt); $cmntID = wp_insert_comment($cmnt);
|
478 |
if ( 'spam' !== $cmnt['comment_approved'] ) { if ( '0' == $cmnt['comment_approved'] ) wp_notify_moderator($cmntID); $post = &get_post($cmnt['comment_post_ID']);
|
479 |
+
if ( get_option('comments_notify') && $cmnt['comment_approved'] && ( ! isset( $cmnt['user_id'] ) || $post->post_author != $cmnt['user_id'] ) ) wp_notify_postauthor($cmntID, isset( $cmnt['comment_type'] ) ? $cmnt['comment_type'] : '' );
|
480 |
+
global $wpdb, $dsq_api;
|
481 |
+
if (isset($dsq_api)) { $plugins_url = str_replace( 'social-networks-auto-poster-facebook-twitter-g/', '', plugin_dir_path( __FILE__ )); require_once( $plugins_url.'disqus-comment-system/export.php'); if (function_exists('dsq_export_wp')) {
|
482 |
+
$comments = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_ID = ".$cmntID) ); // prr($comments);
|
483 |
+
$wxr = dsq_export_wp($post, $comments); $response = $dsq_api->import_wordpress_comments($wxr, time()); // prr($response);
|
484 |
+
}}
|
485 |
+
}
|
486 |
+
return $cmntID;
|
487 |
+
}}
|
488 |
+
|
489 |
+
if (!function_exists("ns_get_avatar")) { function ns_get_avatar($avatar, $id_or_email, $size=96, $default='', $alt='') {
|
490 |
+
if ( is_object($id_or_email) ) {
|
491 |
+
if ($id_or_email->comment_agent=='SNAP' && stripos($id_or_email->comment_author_url, 'facebook.com')!==false) { $fbuID = str_ireplace('@facebook.com','',$id_or_email->comment_author_email);
|
492 |
+
$avatar = "<img alt='{$id_or_email->comment_author}' src='https://graph.facebook.com/$fbuID/picture' class='avatar avatar-{$size} photo avatar-default' height='{$size}' width='{$size}' />";
|
493 |
+
}
|
494 |
+
if ($id_or_email->comment_agent=='SNAP' && stripos($id_or_email->comment_author_url, 'twitter.com')!==false) { $fbuID = str_ireplace('@twitter.com','',$id_or_email->comment_author_email);
|
495 |
+
$avatar = "<img alt='{$id_or_email->comment_author}' src='http://api.twitter.com/1/users/profile_image?screen_name=$fbuID&size=bigger' class='avatar avatar-{$size} photo avatar-default' height='{$size}' width='{$size}' />";
|
496 |
+
}
|
497 |
+
|
498 |
+
}
|
499 |
+
return $avatar;
|
500 |
+
}}
|
501 |
+
|
502 |
+
if (!function_exists('nxs_doProcessTags')){ function nxs_doProcessTags($tags){ $tagsA = array(); if (!is_array($tags)) { $tags = explode(',', $tags);
|
503 |
+
foreach ($tags as $tg) $tagsA[] = trim($tg); } else $tagsA = $tags; $tagsA = array_unique($tagsA); $tags = array();
|
504 |
+
foreach ($tagsA as $tg) { $tags['tagsA'][] = $tg; $tags['htagsA'][] = "#".trim(str_replace(' ', '', preg_replace('/[^a-zA-Z0-9\p{L}\p{N}\s]/u', '', trim(ucwords(str_ireplace('&', '', str_ireplace('&','',$tg))))))); }
|
505 |
+
$tags['tags'] = implode(', ', $tags['tagsA']); $tags['htags'] = implode(', ', $tags['htagsA']);
|
506 |
+
return $tags;
|
507 |
+
}}
|
508 |
+
if (!function_exists('nxs_doFormatMsg')){ function nxs_doFormatMsg($format, $message, $addURLParams=''){ global $nxs_urlLen; $msg = nxs_doSpin($format);// prr($msg); prr($message);// Make "message default"
|
509 |
+
if (preg_match('%URL%', $msg)) { $url = $message['url']; if($addURLParams!='') $url .= (strpos($url,'?')!==false?'&':'?').$addURLParams; $nxs_urlLen = nxs_strLen($url); $msg = str_ireplace("%URL%", $url, $msg);}
|
510 |
+
if (preg_match('%SURL%', $msg)) {
|
511 |
+
if (isset($message['surl']) && $message['surl']!='') $url = $message['surl']; else { $url = $message['url']; if($addURLParams!='') $url .= (strpos($url,'?')!==false?'&':'?').$addURLParams; $url = nxs_mkShortURL($url); }
|
512 |
+
$nxs_urlLen = nxs_strLen($url); $msg = str_ireplace("%SURL%", $url, $msg);
|
513 |
+
}
|
514 |
+
if (preg_match('%IMG%', $imgURL)) { $imgURL = trim($message['imgURL']['large']); if ($imgURL=='') $imgURL = trim($message['imgURL']['medium']);
|
515 |
+
if ($imgURL=='') $imgURL = trim($message['imgURL']['original']); if ($imgURL=='') $imgURL = trim($message['imgURL']['thumb']); $msg = str_ireplace("%IMG%", $imgURL, $msg);
|
516 |
+
}
|
517 |
+
if (preg_match('%IMGLARGE%', $imgURL)) $msg = str_ireplace("%IMG%", trim($message['imgURL']['large'], $msg));
|
518 |
+
if (preg_match('%IMGMEDIUM%', $imgURL)) $msg = str_ireplace("%IMGMEDIUM%", trim($message['imgURL']['medium'], $msg));
|
519 |
+
if (preg_match('%IMGTHUMB%', $imgURL)) $msg = str_ireplace("%IMGTHUMB%", trim($message['imgURL']['thumb'], $msg));
|
520 |
+
if (preg_match('%IMGORIGINAL%', $imgURL)) $msg = str_ireplace("%IMGORIGINAL%", trim($message['imgURL']['original'], $msg));
|
521 |
+
|
522 |
+
if (preg_match('%TITLE%', $msg)) $msg = str_ireplace("%TITLE%", $message['title'], $msg);
|
523 |
+
if (preg_match('%STITLE%', $msg)) { $title = substr($message['title'], 0, 115); $msg = str_ireplace("%STITLE%", $title, $msg); }
|
524 |
+
if (preg_match('%AUTHORNAME%', $msg)) $msg = str_ireplace("%AUTHORNAME%", $message['authorName'], $msg);
|
525 |
+
if (preg_match('%SITENAME%', $msg)) $msg = str_ireplace("%SITENAME%", $message['siteName'], $msg);
|
526 |
+
|
527 |
+
if (preg_match('%ANNOUNCE%', $msg)) { $sText = trim($message['announce'])!=''?$message['announce']:nsTrnc($message['description'], 300, " ", "..."); $msg = str_ireplace("%ANNOUNCE%", $sText, $msg); }
|
528 |
+
if (preg_match('%EXCERPT%', $msg)) { $sText = trim($message['announce'])!=''?$message['announce']:nsTrnc($message['description'], 300, " ", "..."); $msg = str_ireplace("%EXCERPT%", $sText, $msg); }
|
529 |
+
if (preg_match('%RAWEXCERPT%', $msg)) { $sText = trim($message['announce'])!=''?$message['announce']:nsTrnc($message['description'], 300, " ", "..."); $msg = str_ireplace("%RAWEXCERPT%", $sText, $msg); }
|
530 |
+
|
531 |
+
if (preg_match('%TEXT%', $msg)) $msg = str_ireplace("%TEXT%", $message['description'], $msg);
|
532 |
+
if (preg_match('%FULLTEXT%', $msg)) $msg = str_ireplace("%FULLTEXT%", $message['description'], $msg);
|
533 |
+
if (preg_match('%RAWTEXT%', $msg)) $msg = str_ireplace("%RAWTEXT%", $message['description'], $msg);
|
534 |
+
|
535 |
+
|
536 |
+
if (preg_match('%TAGS%', $msg)) { $tags = nxs_doProcessTags($message['tags']); $msg = str_ireplace("%TAGS%", $tags['tags'], $msg); }
|
537 |
+
if (preg_match('%HTAGS%', $msg)) { $tags = nxs_doProcessTags($message['tags']); $msg = str_ireplace("%HTAGS%", $tags['htags'], $msg); }
|
538 |
+
if (preg_match('%CATS%', $msg)) { $tags = nxs_doProcessTags($message['cats']); $msg = str_ireplace("%CATS%", $tags['cats'], $msg); }
|
539 |
+
if (preg_match('%HCATS%', $msg)) { $tags = nxs_doProcessTags($message['hcats']); $msg = str_ireplace("%HCATS%", $tags['hcats'], $msg); }
|
540 |
+
|
541 |
+
if (preg_match('%CF-[a-zA-Z0-9]%', $msg)) { $msgA = explode('%CF', $msg); $mout = '';
|
542 |
+
foreach ($msgA as $mms) {
|
543 |
+
if (substr($mms, 0, 1)=='-' && stripos($mms, '%')!==false) { $mGr = CutFromTo($mms, '-', '%'); $cfItem = $message[$mGr]; $mms = str_ireplace("-".$mGr."%", $cfItem, $mms); } $mout .= $mms;
|
544 |
+
} $msg = $mout;
|
545 |
+
}
|
546 |
+
return trim($msg);
|
547 |
}}
|
548 |
|
549 |
|
550 |
+
|
551 |
+
//## NXS Cron
|
552 |
+
if (!function_exists("nxs_psCron")) { function nxs_psCron() {
|
553 |
+
if (stripos($_SERVER["REQUEST_URI"], 'admin-ajax.php')!==false || stripos($_SERVER["REQUEST_URI"], 'cf_action')!==false || stripos($_SERVER["REQUEST_URI"], 'wp-cron.php')!==false) return;
|
554 |
+
$sh =_get_cron_array(); $itmsToPush = array();
|
555 |
+
if (is_array($sh)) foreach ($sh as $evTime => $evDataX) foreach ($evDataX as $evFunc=>$evData) if (strpos($evFunc, 'ns_doPublishTo')!==false) { $chkTime = rand(360, 600); //$chkTime = rand(5, 7);
|
556 |
+
if ($evTime>'1359495839' && $evTime<time()-$chkTime) $itmsToPush[] = array('time'=>$evTime);
|
557 |
+
} if (count($itmsToPush)<1) return;
|
558 |
+
/*
|
559 |
+
$snapIP = get_post_meta($toPush['args'][0], 'snap_mp_'.$toPush['func'], true);
|
560 |
+
nxs_addToLogN('S', 'Missed Scheduled Autoposts Found', '', ' - ('.$evTime."<".(time()-$chkTime).') - Trying to Post', '');
|
561 |
+
delete_post_meta(); add_post_meta($toPush['args'][0], 'snap_mp_'.$toPush['func'], (time()+300));
|
562 |
+
*/
|
563 |
+
$cron_url = site_url( 'wp-cron.php?doing_wp_cron=0'); ?><script type="text/javascript" > jQuery(document).ready(function($) { jQuery.get('<?php echo $cron_url; ?>'); }); </script><?php die();
|
564 |
+
return true;
|
565 |
}}
|
566 |
|
567 |
if (!function_exists("nxs_addToRI")) { function nxs_addToRI($postID) { global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
|
571 |
|
572 |
function nxs_activation(){ if (!wp_next_scheduled('nxs_hourly_event')){wp_schedule_event(time(), 'hourly', 'nxs_hourly_event');} }
|
573 |
function nxs_do_this_hourly() { $options = get_option('NS_SNAutoPoster'); $riPosts = get_option('NS_SNriPosts'); if (!is_array($riPosts)) $riPosts = array(); //## Check for Incoming Comments if nessesary.
|
574 |
+
if ($options['riActive'] != 1 || count($riPosts)<1 ) return;
|
575 |
+
|
576 |
+
nxs_addToLogN( 'S', 'Comments Import', 'ALL', 'Checking for new comments now...', print_r($riPosts, true));
|
577 |
//## Facebook
|
578 |
+
if (is_array($options['fb'])) foreach ($options['fb'] as $ii=>$fbo) if ($fbo['riComments']=='1') { $fbo['ii'] = $ii; $fbo['pType'] = 'aj';
|
579 |
foreach ($riPosts as $postID) {
|
580 |
$fbpo = get_post_meta($postID, 'snapFB', true); $fbpo = maybe_unserialize($fbpo);
|
581 |
if (is_array($fbpo) && isset($fbpo[$ii]) && is_array($fbpo[$ii]) ){ $ntClInst = new nxs_snapClassFB(); $fbo = $ntClInst->adjMetaOpt($fbo, $fbpo[$ii]); }
|
582 |
nxs_getBackFBComments($postID, $fbo, $fbpo[$ii]);
|
583 |
}
|
584 |
}
|
585 |
+
//## Twitter
|
586 |
+
if (is_array($options['tw'])) foreach ($options['tw'] as $ii=>$fbo) if ($fbo['riComments']=='1') { $fbo['ii'] = $ii; $fbo['pType'] = 'aj';
|
587 |
+
foreach ($riPosts as $postID) {
|
588 |
+
$fbpo = get_post_meta($postID, 'snapTW', true); $fbpo = maybe_unserialize($fbpo);
|
589 |
+
if (is_array($fbpo) && isset($fbpo[$ii]) && is_array($fbpo[$ii]) ){ $ntClInst = new nxs_snapClassTW(); $fbo = $ntClInst->adjMetaOpt($fbo, $fbpo[$ii]); }
|
590 |
+
nxs_getBackTWComments($postID, $fbo, $fbpo[$ii]);
|
591 |
+
}
|
592 |
+
}
|
593 |
}
|
594 |
|
595 |
class NXS_HtmlFixer { public $dirtyhtml; public $fixedhtml; public $allowed_styles; private $matrix; public $debug; private $fixedhtmlDisplayCode;
|
660 |
}
|
661 |
private function removeSpacesAndBadTags($s) { $i=0;
|
662 |
while ($i<10) { $i++; $s = preg_replace (
|
663 |
+
array( '/ /i', '/<p([^>])*>( )*\s*<\/p>/i', '/<span([^>])*>( )*\s*<\/span>/i', '/<strong([^>])*>( )*\s*<\/strong>/i', '/<em([^>])*>( )*\s*<\/em>/i',
|
664 |
'/<font([^>])*>( )*\s*<\/font>/i', '/<small([^>])*>( )*\s*<\/small>/i', '/<\?xml:namespace([^>])*><\/\?xml:namespace>/i', '/<\?xml:namespace([^>])*\/>/i', '/class=\"MsoNormal\"/i',
|
665 |
'/<o:p><\/o:p>/i', '/<!DOCTYPE([^>])*>/i', '/<!--(.|\s)*?-->/', '/<\?(.|\s)*?\?>/'),
|
666 |
array(' ', ' ', '', '', '', '', '', '', '', '', '', ' ', '', '' ) , trim($s));
|
readme.txt
CHANGED
@@ -2,19 +2,22 @@
|
|
2 |
|
3 |
Contributors: NextScripts
|
4 |
Donate link: http://www.nextscripts.com/social-networks-auto-poster-for-wordpress
|
5 |
-
Tags: automation, autopost, auto-post, auto post, socialnetworks, socialnetwork, social networks, social network, facebook, google, google+, twitter, google plus, pinterest, tumblr, blogger, blogspot, blogpost, linkedin, delicious, delicious.com, plugin, links, Post, posts, api, automatic, seo, integration, bookmark,
|
6 |
Requires at least: 3.0
|
7 |
Tested up to: 3.5.1
|
8 |
-
Stable tag: 2.
|
9 |
License: GPLv2 or later
|
10 |
|
11 |
Automatically re-publishes blogposts to Facebook, Twitter, Google+, Pinterest, LinkedIn, Blogger, Tumblr, Delicious, Plurk, etc profiles and/or pages
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
-
**This plugin automatically publishes posts from your blog to your Social Network accounts** such as Facebook, Twitter, Google+(Google Plus), Blogger, Tumblr, LiveJournal, DreamWidth, Delicious, Diigo, Instapaper, Stumbleupon, LinkedIn, Pinterest, Plurk, VKontakte(VK.com), Wordpress, etc. The whole process is completely automated. Just write a new post and either entire post or it's nicely formatted announcement with backlink will be published to all your configured social networks. You can reach the most audience and tell all your friends, readers and followers about your new post. Plugin works with profiles, business pages, community pages, groups, etc.
|
16 |
|
17 |
-
|
|
|
|
|
|
|
18 |
* *Version 2.5* - Export/Import Plugin settings, direct links to the published posts from the "Edit" page, ability to assign categories to each Social Network. LiveJournal Support.
|
19 |
* *Version 2.4* - "Image" posts for Facebook and Twitter, bit.ly support, Plurk Support
|
20 |
* *Version 2.3* - Google+ image posts, delayed postings (Pro Only), new networks - Stumbleupon, vBulletin, Diigo
|
@@ -25,6 +28,7 @@ Automatically re-publishes blogposts to Facebook, Twitter, Google+, Pinterest, L
|
|
25 |
* **Delicious** - Auto-submit bookmark to your account.
|
26 |
* **Diigo** - Auto-submit bookmark to your account.
|
27 |
* **Facebook** - Autopost to your profile, business page, community page, or Facebook group page. Ability to attach your blogpost to Facebook post. Ability to make "Image" posts.
|
|
|
28 |
* **Instapaper** - Auto-submit bookmark to your account.
|
29 |
* **Google+** (*with third party API library*) - Autopost to your profile or business page. Ability to attach your blogpost to Google+ post. Ability to make "Image" posts.
|
30 |
* **LinkedIn** - Autopost to your account. Ability to attach your blogpost to LinkedIn post. Autopost to LinkedIn Company pages and/or Groups (*with third party API library*)
|
@@ -37,6 +41,7 @@ Automatically re-publishes blogposts to Facebook, Twitter, Google+, Pinterest, L
|
|
37 |
* **vBulletin** - Auto-submit your blogpost to vBulletin forums. Could create new threads or new posts.
|
38 |
* **vKontakte(VK.com)** - Autopost to your profile or group page. Ability to attach your blogpost to Facebook post. Ability to make "Image" posts.
|
39 |
* **Wordpress** - Auto-submit your blogpost to another blog based on Wordpress. This options includes Wordpress.com, Blog.com, etc..
|
|
|
40 |
|
41 |
... more networks are coming soon ...
|
42 |
|
@@ -50,70 +55,25 @@ Please see <a href="http://www.nextscripts.com/installation-of-social-networks-a
|
|
50 |
|
51 |
You need to have account with either Facebook, Tumblr, Google+, LinkedIn, Pinterest, Blogger, Twitter, Delicious, Diigo, Plurk, LiveJournal, Stumbleupon, DreamWidth or all of them.
|
52 |
|
53 |
-
**
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
6. [Optional - you can skip this step and use existing page] Click "Advanced" from the left side menu "Settings.". Scroll all the way down and click "Create Facebook Page" button. Facebook will create Community page for your App. Click on it and see the URL. It will be something like http://www.facebook.com/pages/Your-Site-Community/304945439569358
|
72 |
-
|
73 |
-
2. Connect Facebook to your Wordpress.
|
74 |
-
1. Login to your Wordpress Admin Panel, Go to the Settings->Social Networks AutoPoster Options.
|
75 |
-
2. Click green "Add new account" button, select "Facebook" from the list.
|
76 |
-
3. Fill URL of your Community page from step 6 above.
|
77 |
-
4. Fill "App ID" and "App Secret" from step 3 above.
|
78 |
-
3. Authorize Facebook for your Wordpress.
|
79 |
-
1. Click "Update Settings". Notice new link "Authorize Your FaceBook Account".
|
80 |
-
2. Click "Authorize Your FaceBook Account" and follow the Facebook authorization wizard. If you get any errors at this step, please make sure that domain for your Wordpress site is entered to your App as "App Domain".
|
81 |
-
4. Your facebook is ready to use.
|
82 |
-
|
83 |
-
Twitter.
|
84 |
-
|
85 |
-
1. Create a Twitter App for your website.
|
86 |
-
1. Login to your Twitter account.
|
87 |
-
2. Go to the Twitter Developers website: https://dev.twitter.com/ Sign in again if asked.
|
88 |
-
3. Click "Create an app" link from the right panel. Fill details, click "Create your Twitter application".
|
89 |
-
***Notice Consumer key and Consumer secret on this page.
|
90 |
-
4. Click "Settings" tab. Scroll to the "Application type", change Access level from "Read Only" to "Read and Write". Click "Update this Twitter application settings".
|
91 |
-
5. Come back to "Details" tab. Scroll to the "Your access token" and click "Create my access token" button. Refresh page and notice "Access token" and "Access token secret". Make sure you have "Read and Write" access level.
|
92 |
-
|
93 |
-
2. Connect Twitter to your Wordpress.
|
94 |
-
1. Login to your Wordpress Admin Panel, Go to the Settings->Social Networks AutoPoster Options.
|
95 |
-
2. Click green "Add new account" button, select "Twitter" from the list.
|
96 |
-
3. Fill your Twitter URL.
|
97 |
-
4. Fill "Consumer key" and "Consumer secret" from step 3 above.
|
98 |
-
5. Fill "Access token" and "Access token secret" from step 5 above.
|
99 |
-
3. Your Twitter is ready to use.
|
100 |
-
|
101 |
-
Google+.
|
102 |
-
|
103 |
-
Google+ don't yet have API for automated posts. You need to get special library module to be able to publish Google+ posts.
|
104 |
-
|
105 |
-
1. Create Google+ page for your website.
|
106 |
-
1. Login to your Google+ account.
|
107 |
-
2. Click "Create a Google+ page" link from the right panel. Choose category, fill details, click "Create".
|
108 |
-
***Notice the URL of your page.
|
109 |
-
2. Connect Google+ to your Wordpress.
|
110 |
-
1. Login to your Wordpress Admin Panel, Go to the Settings->Social Networks AutoPoster Options.
|
111 |
-
2. Click green "Add new account" button, select "Google+" from the list.
|
112 |
-
3. Fill Google+ Login and Password. Please note that Wordpress is not storing your Google+ password in very secure manner, so you better create a separate G+ account for your website.
|
113 |
-
4. Fill the ID of your page. You can get this ID from your URL (Step 2 above). If your URL is https://plus.google.com/u/0/b/117008619877691455570/ - your ID is 117008619877691455570
|
114 |
-
3. Your Google+ is ready to use.
|
115 |
|
116 |
-
Please see <a href="http://www.nextscripts.com/installation-of-social-networks-auto-poster-for-wordpress/">complete installation instructions with screenshots</a>
|
117 |
|
118 |
== Frequently Asked Questions ==
|
119 |
|
@@ -159,6 +119,131 @@ Please see more <a href="http://www.nextscripts.com/faq/">Frequently asked quest
|
|
159 |
|
160 |
== Changelog ==
|
161 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
= 2.6.3 [02/07/2013] =
|
163 |
|
164 |
* Improvement/Bug fix - Twitter - Better hashtags support.
|
2 |
|
3 |
Contributors: NextScripts
|
4 |
Donate link: http://www.nextscripts.com/social-networks-auto-poster-for-wordpress
|
5 |
+
Tags: automation, autopost, auto-post, auto post, socialnetworks, socialnetwork, social networks, social network, facebook, google, google+, twitter, google plus, pinterest, tumblr, blogger, blogspot, blogpost, linkedin, delicious, delicious.com, reddit, reddit.com, plugin, links, Post, posts, api, automatic, seo, integration, bookmark, FriendFeed, bookmarks, admin, images, image, social, sharing, share, repost, re-post, wordpress.com, StumbleUpon, Diigo, vBulletin, Plurk, forums, vKontakte, open graph, LiveJournal, YouTube
|
6 |
Requires at least: 3.0
|
7 |
Tested up to: 3.5.1
|
8 |
+
Stable tag: 2.7.14
|
9 |
License: GPLv2 or later
|
10 |
|
11 |
Automatically re-publishes blogposts to Facebook, Twitter, Google+, Pinterest, LinkedIn, Blogger, Tumblr, Delicious, Plurk, etc profiles and/or pages
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
+
**This plugin automatically publishes posts from your blog to your Social Network accounts** such as Facebook, Twitter, Google+(Google Plus), Blogger, Tumblr, LiveJournal, FriendFeed, DreamWidth, Delicious, Diigo, Instapaper, Stumbleupon, LinkedIn, Pinterest, Plurk, VKontakte(VK.com), YouTube, Wordpress, etc. The whole process is completely automated. Just write a new post and either entire post or it's nicely formatted announcement with backlink will be published to all your configured social networks. You can reach the most audience and tell all your friends, readers and followers about your new post. Plugin works with profiles, business pages, community pages, groups, etc.
|
16 |
|
17 |
+
Version 3 is coming soon, you can request to become an early beta-tester here: http://www.nextscripts.com/version-3-beta/
|
18 |
+
|
19 |
+
* **Latest version 2.7** - YouTube Support, FriendFeed support, Auto-import comments from Facebook and Twitter as Wordpress Commnets, goo.gl and YOURLS support, ability to spin message text.
|
20 |
+
* *Version 2.6* - Better Interface, DreamWidth support, Instapaper support, ability to auto-import comments from social networks
|
21 |
* *Version 2.5* - Export/Import Plugin settings, direct links to the published posts from the "Edit" page, ability to assign categories to each Social Network. LiveJournal Support.
|
22 |
* *Version 2.4* - "Image" posts for Facebook and Twitter, bit.ly support, Plurk Support
|
23 |
* *Version 2.3* - Google+ image posts, delayed postings (Pro Only), new networks - Stumbleupon, vBulletin, Diigo
|
28 |
* **Delicious** - Auto-submit bookmark to your account.
|
29 |
* **Diigo** - Auto-submit bookmark to your account.
|
30 |
* **Facebook** - Autopost to your profile, business page, community page, or Facebook group page. Ability to attach your blogpost to Facebook post. Ability to make "Image" posts.
|
31 |
+
* **FriendFeed** - Autopost to your account. Ability to attach Image to posts.
|
32 |
* **Instapaper** - Auto-submit bookmark to your account.
|
33 |
* **Google+** (*with third party API library*) - Autopost to your profile or business page. Ability to attach your blogpost to Google+ post. Ability to make "Image" posts.
|
34 |
* **LinkedIn** - Autopost to your account. Ability to attach your blogpost to LinkedIn post. Autopost to LinkedIn Company pages and/or Groups (*with third party API library*)
|
41 |
* **vBulletin** - Auto-submit your blogpost to vBulletin forums. Could create new threads or new posts.
|
42 |
* **vKontakte(VK.com)** - Autopost to your profile or group page. Ability to attach your blogpost to Facebook post. Ability to make "Image" posts.
|
43 |
* **Wordpress** - Auto-submit your blogpost to another blog based on Wordpress. This options includes Wordpress.com, Blog.com, etc..
|
44 |
+
* **YouTube** (*with third party API library*) - Post messages to your YouTube channel feed. If blogpost has youtube reference it will be attached.
|
45 |
|
46 |
... more networks are coming soon ...
|
47 |
|
55 |
|
56 |
You need to have account with either Facebook, Tumblr, Google+, LinkedIn, Pinterest, Blogger, Twitter, Delicious, Diigo, Plurk, LiveJournal, Stumbleupon, DreamWidth or all of them.
|
57 |
|
58 |
+
**Very detailed installation instructions with screenshots are located here:** http://www.nextscripts.com/installation-of-social-networks-auto-poster-for-wordpress
|
59 |
+
|
60 |
+
How to setup each type of Social Network
|
61 |
+
|
62 |
+
<a href="http://www.nextscripts.com/setup-installation-facebook-social-networks-auto-poster-wordpress/">Facebook Configuration</a>
|
63 |
+
<a href="http://www.nextscripts.com/setup-installation-twitter-social-networks-auto-poster-wordpress/">Twitter Configuration</a>
|
64 |
+
<a href="http://www.nextscripts.com/setup-installation-google-plus-social-networks-auto-poster-wordpress/">Google+ Configuration</a>
|
65 |
+
<a href="http://www.nextscripts.com/setup-installation-pinterest-social-networks-auto-poster-wordpress/">Pinterest Configuration</a>
|
66 |
+
<a href="http://www.nextscripts.com/setup-installation-tumblr-social-networks-auto-poster-wordpress/">Tumblr Configuration</a>
|
67 |
+
<a href="http://www.nextscripts.com/setup-installation-linkedin-social-networks-auto-poster-wordpress/">LinkedIn Configuration</a>
|
68 |
+
<a href="http://www.nextscripts.com/setup-installation-blogger-social-networks-auto-poster-wordpress/">Blogger Configuration</a>
|
69 |
+
<a href="http://www.nextscripts.com/setup-installation-delicious-social-networks-auto-poster-wordpress/">Delicious Configuration</a>
|
70 |
+
<a href="http://www.nextscripts.com/setup-installation-wp-based-social-networks-auto-poster-wordpress/">Blog.com/Wordpress.com Configuration</a>
|
71 |
+
<a href="http://www.nextscripts.com/setup-installation-diigo-social-networks-auto-poster-wordpress/">Diigo Configuration</a>
|
72 |
+
<a href="http://www.nextscripts.com/setup-installation-plurk-social-networks-auto-poster-wordpress/">Plurk Configuration</a>
|
73 |
+
|
74 |
+
|
75 |
+
Have problems? Please check out the <a href="http://www.nextscripts.com/troubleshooting-social-networks-auto-poster">Troubleshooting FAQ</a> page.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
|
|
|
77 |
|
78 |
== Frequently Asked Questions ==
|
79 |
|
119 |
|
120 |
== Changelog ==
|
121 |
|
122 |
+
= 2.7.14 [05/06/2013] =
|
123 |
+
|
124 |
+
* Improvement - Ability to setup custom text for LinkedIn attachments.
|
125 |
+
* Improvement - Ability to skip User Security Settings.
|
126 |
+
* Improvement - New User privilege - autopost without seeing options.
|
127 |
+
* Bug Fix - Google+ Community Pages category retrieval problems.
|
128 |
+
|
129 |
+
= 2.7.13 [04/30/2013] =
|
130 |
+
|
131 |
+
* New - Google+ Community Pages - now you can select which category to post.
|
132 |
+
* Improvement - Compatibility with Facebook's "July 2013 Breaking Changes". It's now safe to enable them for your apps.
|
133 |
+
* Bug Fix - Incorrect "User ID XXXXX can't autopost" error.
|
134 |
+
|
135 |
+
= 2.7.12 [04/29/2013] =
|
136 |
+
|
137 |
+
* Bug Fix - [Critical] Broken scheduled and automated posts
|
138 |
+
|
139 |
+
= 2.7.11 [04/26/2013] =
|
140 |
+
|
141 |
+
* Bug Fix - [Critical] Twitter lost formatting for posts
|
142 |
+
|
143 |
+
= 2.7.10 [04/25/2013] =
|
144 |
+
|
145 |
+
* New - Support for Facebook Secret Groups
|
146 |
+
* Improvement - Import Button is available even if no networks configured.
|
147 |
+
* Improvement - "Include/Exclude Wordpress Pages and Custom Post Types" is now a list of checkboxes.
|
148 |
+
* Bug Fix - Google+ Community Postings
|
149 |
+
* Bug Fix - Unselected user types were still be able to autopost from front end.
|
150 |
+
* Bug Fix - Facebook "Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by ...".
|
151 |
+
* Bug Fix - Facebook sometimes dies silently without reporting an error.
|
152 |
+
|
153 |
+
= 2.7.9 [04/11/2013] =
|
154 |
+
|
155 |
+
* Bug Fix - Auto-Importing Facebook comments was broken in some cases
|
156 |
+
* Bug Fix - Twitter "Attention required. Unfinished setup" message even if setup is finished
|
157 |
+
* Bug Fix - Twitter error "The text of your tweet is too long" - Thanks to Twitter's "minus another character from image post" update
|
158 |
+
* Bug Fix - Several small/cosmetic bug fixes
|
159 |
+
|
160 |
+
= 2.7.8 [03/27/2013] =
|
161 |
+
|
162 |
+
* Bug Fix - [Critical] URLS and images were missing from the Twitter posts
|
163 |
+
* Bug Fix - Disqus comments import - missing thread ID.
|
164 |
+
|
165 |
+
= 2.7.6 [03/25/2013] =
|
166 |
+
|
167 |
+
* Bug Fix - ob_start() [ref.outcontrol]: Cannot use output buffering in output buffering display handlers.
|
168 |
+
* Bug Fix - Plugin were breaking AJAX Calls sometimes.
|
169 |
+
* Bug Fix - Twitter - %TAGS% broken for non unicode environments
|
170 |
+
* Bug Fix - Incorrect "Skipped Category" for non-human posts.
|
171 |
+
|
172 |
+
= 2.7.5 [03/23/2013] =
|
173 |
+
|
174 |
+
* Change. - gd.is is blocked by Twitter, goog.gl is a new default.
|
175 |
+
* New - Comments imported from Facebook and Twitter will come with applicabale Facebook and Twitter userpics.
|
176 |
+
* New - Comments imported from Facebook and Twitter will be imported to Disqus as well.(if Disqus is installed and activated)
|
177 |
+
* Improvement - Videos will be found even if coming from shortcodes.
|
178 |
+
* Bug Fix - Twitter - Incorrect character count not non-english messages.
|
179 |
+
|
180 |
+
= 2.7.4 [03/12/2013] =
|
181 |
+
|
182 |
+
* New - Support for images from Yet Another Photoblog(YAPB) Plugin.
|
183 |
+
* Improvement - Pinterest will recognize entered price.
|
184 |
+
* Improvement - VK - video attachments. (Pro Only)
|
185 |
+
* Improvement/Bug Fix - Changed/Improved the way of finding images in posts
|
186 |
+
* Improvement/Bug Fix - Title template for LinkedIn Groups
|
187 |
+
* Improvement/Bug Fix - Perfomance and Duplicate handling improvements
|
188 |
+
* Bug Fix - Duplicate posts issue.
|
189 |
+
* Bug Fix - Sometimes "Individual Category Selection" checkboxes were ignored
|
190 |
+
* Bug Fix - Broken VK Image posts.
|
191 |
+
* Bug Fix - Twitter Error - in_array() expects parameter 2 to be array
|
192 |
+
|
193 |
+
= 2.7.3 [03/06/2013] =
|
194 |
+
|
195 |
+
* New - New network "YouTube" (Comes with Google+ API Only)
|
196 |
+
* Improvement/Bug Fix - Better Duplicate handling.
|
197 |
+
* Bug Fix - vk.com "Access Denied" errors
|
198 |
+
* Bug Fix - Blogger removing some letters from the posts
|
199 |
+
* Bug Fix - %HTAGS% tag was not working for some networks
|
200 |
+
|
201 |
+
= 2.7.2 [02/28/2013] =
|
202 |
+
|
203 |
+
* Improvement/Bug Fix - New Pinterest interface suppport.
|
204 |
+
* Improvement - Post with tags for LiveJournal/Dreamwidth
|
205 |
+
* Improvement - Wordpress to Wordpress posts will include "Excerpt" as well.
|
206 |
+
* Bug fix - WPMU - Accounts loosing selected mode.
|
207 |
+
* Bug fix - Twitter - "Your Message is too long" problem caused by Twitter increasing URL length from 20 to 22 characters.
|
208 |
+
* Bug fix - LinkedIn - Posts were not attaching when posting to LinkedIn Groups.
|
209 |
+
* Bug fix - Incorrect skipping of individual categories selection for automated (non-human) posts
|
210 |
+
|
211 |
+
= 2.7.1 [02/26/2013] =
|
212 |
+
|
213 |
+
* New - New network "FriendFeed"
|
214 |
+
* Improvement - Indicators that some networks have excluded categories.
|
215 |
+
* Improvement - Woocommerce product tags supported for %TAGS% and %HTAGS%.
|
216 |
+
* Bug fix - Broken checkboxes in "Post Edit"
|
217 |
+
* Bug fix - Tumblr Post URLs
|
218 |
+
* Bug fix - Broken %ANNOUNCE% tag
|
219 |
+
* Bug fix - Blogger line breaks.
|
220 |
+
* Bug fix - Some issues potentialy causing duplicates.
|
221 |
+
* Bug fix - Blogger line breaks.
|
222 |
+
* Bug fix - Warning: _() expects exactly 1 fixed
|
223 |
+
* Bug fix - vk.com connection error
|
224 |
+
|
225 |
+
|
226 |
+
= 2.7.0 [02/23/2013] =
|
227 |
+
|
228 |
+
* New - Ability to auto-import "Replies" and "Mentions" from Twitter and post them as WP Comments
|
229 |
+
* New - Ability to use "Custom Fields" %CF-CustomFieldName% in autoposter message templates.
|
230 |
+
* New - New template tag %ANNOUNCE% Inserts the text till the <!--more--> tag or first N words of the post.
|
231 |
+
* New - Ability to "Spin" message post templates.
|
232 |
+
* New - Support for YOURLS URL Shortener.
|
233 |
+
* New - Support for goo.gl URL Shortener.
|
234 |
+
* Improvement - Better interface for "Settings" tab
|
235 |
+
* Improvement - Tumblr include categories as tags
|
236 |
+
* Improvement - More clear and understandable log
|
237 |
+
* Improvement - All "Message Format" fields are now multirow fields.
|
238 |
+
* Improvement - no _ in hashtags anymore
|
239 |
+
* Improvement - Featured image custom field could be an array
|
240 |
+
* Improvement/Bug Fix - additional protection against magic quotes.
|
241 |
+
* Bug fix - Stumbleupon category selection.
|
242 |
+
* Bug fix - Twitter characters limit when %TEXT% is used.
|
243 |
+
* Bug fix - Autoposting stability improvements.
|
244 |
+
* Bug fix - Featured image location in custom field.
|
245 |
+
* Bug fix - International characters for Blogger (Free API).
|
246 |
+
|
247 |
= 2.6.3 [02/07/2013] =
|
248 |
|
249 |
* Improvement/Bug fix - Twitter - Better hashtags support.
|