NextScripts: Social Networks Auto-Poster - Version 2.5.5

Version Description

[01/18/2013] =

  • New/Improvement - Tumblr - Audio and Video Post types
  • New/Improvement - %HTAGS% and %HCATS% for insert tags and categories as hashtags
  • Bug fix - Critical Facebook Authorization Problem
Download this release

Release Info

Developer NextScripts
Plugin Icon 128x128 NextScripts: Social Networks Auto-Poster
Version 2.5.5
Comparing to
See all releases

Code changes from version 2.4.8 to 2.5.5

Files changed (24) hide show
  1. NextScripts_SNAP.php +136 -32
  2. img/lj-bg.png +0 -0
  3. img/lj16.png +0 -0
  4. img/vk-bg.png +0 -0
  5. img/vk16.png +0 -0
  6. inc-cl/apis/liOAuth.php +15 -2
  7. inc-cl/bg.php +31 -14
  8. inc-cl/di.php +24 -4
  9. inc-cl/dl.php +29 -7
  10. inc-cl/fb.php +84 -36
  11. inc-cl/gp.php +42 -13
  12. inc-cl/li.php +33 -11
  13. inc-cl/lj.php +162 -0
  14. inc-cl/pk.php +28 -8
  15. inc-cl/pn.php +33 -15
  16. inc-cl/su.php +70 -20
  17. inc-cl/tr.php +47 -12
  18. inc-cl/tw.php +29 -10
  19. inc-cl/vb.php +33 -10
  20. inc-cl/vk.php +311 -0
  21. inc-cl/wp.php +31 -10
  22. js/js.js +128 -0
  23. nxs_functions.php +95 -175
  24. readme.txt +123 -62
NextScripts_SNAP.php CHANGED
@@ -4,18 +4,18 @@ 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.4.8
8
  Author URI: http://www.nextscripts.com
9
  Copyright 2012 Next Scripts, Inc
10
  */
11
- define( 'NextScripts_SNAP_Version' , '2.4.8' ); require_once "nxs_functions.php";
12
  //## Include All Available Networks
13
  global $nxs_snapAvNts, $nxs_snapThisPageUrl, $nxs_plurl, $nxs_isWPMU, $nxs_tpWMPU;
14
  $nxs_snapAvNts = array(); foreach (glob(plugin_dir_path( __FILE__ ).'inc-cl/*.php') as $filename){ require_once $filename; }
15
 
16
  $nxs_snapThisPageUrl = admin_url().'options-general.php?page=NextScripts_SNAP.php';
17
  $nxs_plurl = plugin_dir_url(__FILE__);
18
- $nxs_isWPMU = (defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE==true && defined('MULTISITE') && MULTISITE==true);
19
 
20
  //## Define SNAutoPoster class
21
  if (!class_exists("NS_SNAutoPoster")) {
@@ -35,12 +35,14 @@ if (!class_exists("NS_SNAutoPoster")) {
35
  //$options = array('nsOpenGraph'=>1);
36
  $dbOptions = get_option($this->dbOptionsName);
37
  $this->nxs_ntoptions = get_site_option($this->dbOptionsName);
38
- if ($nxs_isWPMU && $blog_id>1) { switch_to_blog(1); $dbMUOptions = get_option($this->dbOptionsName); restore_current_blog();
 
39
  $dbOptions['lk'] = $dbMUOptions['lk']; $dbOptions['ukver'] = $dbMUOptions['ukver']; $dbOptions['uklch'] = $dbMUOptions['uklch']; $dbOptions['uk'] = $dbMUOptions['uk'];
40
  }
41
  if (!empty($dbOptions) && is_array($dbOptions)) foreach ($dbOptions as $key => $option) if (trim($key)!='') $options[$key] = $option;
42
- if (function_exists('nxs_getInitAdd')) nxs_getInitAdd($options); //$ttt = function_exists('nxs_getInitAdd'); var_dump($ttt);
43
-
 
44
  if (defined('NXSAPIVER') && $options['ukver']!=NXSAPIVER){$options['ukver']=NXSAPIVER; update_option($this->dbOptionsName, $options);}
45
  $options['isMA'] = function_exists('nxs_doSMAS1') && isset($options['lk']) && isset($options['uk']) && $options['uk']!='';
46
  $options['isMU'] = function_exists('showSNAP_WPMU_OptionsPageExt') && isset($options['lk']) && isset($options['uk']) && $options['uk']!='';
@@ -69,8 +71,8 @@ if (!class_exists("NS_SNAutoPoster")) {
69
  }
70
  //## Update the options for the panel
71
  $options = $optPro; update_option($this->dbOptionsName, $options);
72
- }
73
- if(!$options['isMA']) $options = nxs_snapCleanup($options);
74
  return $options;
75
  }
76
 
@@ -108,10 +110,19 @@ define('WP_ALLOW_MULTISITE', true);<br/>to<br/>define('WP_ALLOW_MULTISITE', fals
108
  <?php return;
109
  }
110
  }
111
- function showSNAutoPosterOptionsPage() { global $nxs_snapAvNts, $nxs_snapThisPageUrl, $nxsOne, $nxs_plurl, $nxs_isWPMU, $nxs_tpWMPU; $nxsOne = ''; $options = $this->nxs_options;
112
  //if($acid==1) $options = $this->nxs_options; else { switch_to_blog($acid); $options = $this->getAPOptions(); }
 
 
 
 
 
 
 
 
113
 
114
- if (isset($_POST['update_NS_SNAutoPoster_settings'])) { if (get_magic_quotes_gpc()) {array_walk_recursive($_POST, 'nsx_stripSlashes');} array_walk_recursive($_POST, 'nsx_fixSlashes');
 
115
  foreach ($nxs_snapAvNts as $avNt) if (isset($_POST[$avNt['lcode']])) { $clName = 'nxs_snapClass'.$avNt['code']; if (!isset($options[$avNt['lcode']])) $options[$avNt['lcode']] = array();
116
  $ntClInst = new $clName(); $ntOpt = $ntClInst->setNTSettings($_POST[$avNt['lcode']], $options[$avNt['lcode']]); $options[$avNt['lcode']] = $ntOpt;
117
  }
@@ -128,10 +139,20 @@ define('WP_ALLOW_MULTISITE', true);<br/>to<br/>define('WP_ALLOW_MULTISITE', fals
128
 
129
  if (isset($_POST['nsOpenGraph'])) $options['nsOpenGraph'] = $_POST['nsOpenGraph']; else $options['nsOpenGraph'] = 0;
130
  if (isset($_POST['imgNoCheck'])) $options['imgNoCheck'] = 0; else $options['imgNoCheck'] = 1;
 
 
 
 
 
 
 
 
131
 
132
  if (isset($_POST['useUnProc'])) $options['useUnProc'] = $_POST['useUnProc']; else $options['useUnProc'] = 0;
133
  if (isset($_POST['nxsCPTSeld'])) $options['nxsCPTSeld'] = serialize($_POST['nxsCPTSeld']);
134
- if (isset($_POST['post_category'])) { $pk = $_POST['post_category']; $cIds = get_all_category_ids(); $options['exclCats'] = serialize(array_diff($cIds, $pk)); } // prr($options['exclCats']);
 
 
135
  if (!isset($_POST['whoCanSeeSNAPBox'])) $_POST['whoCanSeeSNAPBox'] = array(); $_POST['whoCanSeeSNAPBox'][] = 'administrator';
136
  if (isset($_POST['whoCanSeeSNAPBox'])) $options['whoCanSeeSNAPBox'] = $_POST['whoCanSeeSNAPBox'];
137
  if ($nxs_isWPMU && (!isset($options['suaMode'])||$options['suaMode'] = '')) $options['suaMode'] = $nxs_tpWMPU;
@@ -155,12 +176,13 @@ if ( is_array($category_ids) && is_array($pk) && count($category_ids) == count($
155
  <ul class="nsx_tabs">
156
  <li><a href="#nsx_tab1">Your Social Networks Accounts</a></li>
157
  <li><a href="#nsx_tab2">Other Settings</a></li>
 
158
  <li><a href="#nsx_tab3">Log/History</a></li>
159
  <li><a href="#nsx_tab4">Help/Support</a></li>
160
  </ul>
161
  <form method="post" id="nsStForm" action="<?php echo $nxs_snapThisPageUrl?>">
162
  <div class="nsx_tab_container">
163
- <div id="nsx_tab1" class="nsx_tab_content"><a href="#" class="NXSButton" id="nxs_snapAddNew">Add new account</a> <div class="nxsInfoMsg"><img style="position: relative; top: 8px;" alt="Arrow" src="<?php echo $nxs_plurl; ?>img/arrow_l_green_c1.png"/> You can add Facebook, Twitter, Google+, Pinterest, LinkedIn, Tumblr, Blogger/Blogspot, Delicious accounts</div><br/><br/>
164
  <div id="nxs_spPopup"><span class="nxspButton bClose"><span>X</span></span>Add New Network: <select onchange="doShowFillBlockX(this.value);" id="nxs_ntType"><option value =""></option>
165
  <?php foreach ($nxs_snapAvNts as $avNt) { if (!isset($options[$avNt['lcode']]) || count($options[$avNt['lcode']])==0) $mt=0; else $mt = 1+max(array_keys($options[$avNt['lcode']]));
166
  echo '<option value ="'.$avNt['code'].$mt.'">'.$avNt['name'].'</option>';
@@ -174,12 +196,32 @@ if ( is_array($category_ids) && is_array($pk) && count($category_ids) == count($
174
  </div>
175
 
176
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
177
  <?php wp_nonce_field( 'nsDN', 'nsDN_wpnonce' );
178
  foreach ($nxs_snapAvNts as $avNt) { $clName = 'nxs_snapClass'.$avNt['code']; $ntClInst = new $clName();
179
  if ( isset($options[$avNt['lcode']]) && count($options[$avNt['lcode']])>0) { $ntClInst->showGenNTSettings($options[$avNt['lcode']]); } // else $ntClInst->showNewNTSettings(0);
180
  }
181
  if ($isNoNts) { ?><br/><br/><br/>You don't have any configured social networks yet. Please click "Add new account" button.<?php } else {?>
182
- <div class="submit"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'NS_SNAutoPoster') ?>" /></div>
 
 
 
 
 
 
 
 
183
  <?php } ?>
184
  </div> <!-- END TAB -->
185
  <div id="nsx_tab2" class="nsx_tab_content">
@@ -203,7 +245,7 @@ if ( is_array($category_ids) && is_array($pk) && count($category_ids) == count($
203
  if (in_array($role, $options['whoCanSeeSNAPBox']) || $role=='administrator') echo ' checked="checked" '; if ($role=='administrator' || $role=='subscriber') echo ' disabled="disabled" ';
204
  echo 'name="whoCanSeeSNAPBox[]" value="'.esc_attr($role).'"> '.$name;
205
  if ($role=='administrator') echo ' - Somebody who has access to all the administration features';
206
- if ($role=='editor') echo ' - Somebody who can publish and manage posts and pages as well as manage other users\' posts, etc. ';
207
  if ($role=='author') echo ' - Somebody who can publish and manage their own posts ';
208
  if ($role=='contributor') echo ' - Somebody who can write and manage their posts but not publish them';
209
  if ($role=='subscriber') echo ' - Somebody who can only manage their profile';
@@ -223,7 +265,14 @@ if ( is_array($category_ids) && is_array($pk) && count($category_ids) == count($
223
  ?><option <?php if (in_array($cptID,$nxsCPTSeld)) echo 'selected="selected"'; ?> value="<?php echo $cptID; ?>"><?php echo $cptName; ?></option><?php
224
  }
225
  ?>
226
- </select>
 
 
 
 
 
 
 
227
 
228
  <div style="width:500px;"><strong style="font-size: 14px;"><br/>Categories to Include/Exclude:</strong>
229
  <p style="font-size: 11px; margin: 0px;">Each blogpost will be autoposted to all categories selected below. All categories are selected by default.
@@ -233,6 +282,13 @@ if ( is_array($category_ids) && is_array($pk) && count($category_ids) == count($
233
  function nxs_chAllCats(ch){
234
  jQuery("form input:checkbox[name='post_category[]']").attr('checked', ch==1);
235
  }
 
 
 
 
 
 
 
236
  </script>
237
 
238
  <a href="#" onclick="nxs_chAllCats(1); return false;">Check all</a> &nbsp;|&nbsp; <a href="#" onclick="nxs_chAllCats(0); return false;">UnCheck all</a>
@@ -240,7 +296,7 @@ function nxs_chAllCats(ch){
240
  <div id="taxonomy-category" class="categorydiv">
241
  <div id="category-all" class="tabs-panel"><input type='hidden' name='post_category[]' value='0' />
242
  <ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
243
- <?php $category_ids = get_all_category_ids(); if(isset($options['exclCats'])) $pk = maybe_unserialize($options['exclCats']); else $pk = '';
244
  if (is_array($pk) && count($pk)>0 ) $selCats = array_diff($category_ids, $pk); else $selCats = $category_ids;
245
  $args = array( 'descendants_and_self' => 0, 'selected_cats' => $selCats, 'taxonomy' => 'category', 'checked_ontop' => false);
246
  if (function_exists('wp_terms_checklist')) wp_terms_checklist(0, $args );
@@ -286,16 +342,27 @@ function nxs_chAllCats(ch){
286
  Custom field Image Prefix: <input name="featImgLocPrefix" style="width: 200px;" value="<?php if (isset($options['featImgLocPrefix'])) _e(apply_filters('format_to_edit',$options['featImgLocPrefix']), 'NS_SNAutoPoster') ?>" />
287
 
288
 
289
- <h3 style="font-size: 14px; margin-bottom: 2px;">Verify "Featured" Image</h3>
290
 
291
- <p style="margin: 0px;margin-left: 5px;"><input value="set" id="imgNoCheck" name="imgNoCheck" type="checkbox" <?php if ((int)$options['imgNoCheck'] != 1) echo "checked"; ?> />
292
  <strong>Verify "Featured" Image</strong>
293
  <span style="font-size: 11px; margin-left: 1px;">Advanced Setting. Uncheck only if you are 100% sure that your images are valid or if you have troubles with image verification.</span>
294
- </p>
 
 
 
 
 
 
 
 
 
 
295
 
296
- <div class="submit"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'NS_SNAutoPoster') ?>" /></div>
297
 
298
  </div>
 
299
  <div id="nsx_tab3" class="nsx_tab_content">
300
  <div style="width:760px;">
301
  <a href="#" style="float: right" onclick="nxs_rfLog();return false;" class="NXSButton" id="nxs_clearLog">Refresh</a>
@@ -303,7 +370,7 @@ function nxs_chAllCats(ch){
303
  Showing last 150 records <a href="#" onclick="nxs_clLog();return false;" class="NXSButton" id="nxs_clearLog">Clear Log</a><br/><br/>
304
  <div style="overflow: auto; border: 1px solid #999; width: 750px; height: 600px; font-size: 11px;" class="logDiv" id="nxslogDiv">
305
  <?php $logInfo = maybe_unserialize(get_option('NS_SNAutoPosterLog')); if (is_array($logInfo))
306
- foreach (array_reverse($logInfo) as $logline) echo '<snap style="color:#008000">['.$logline['date'].']</snap> - ['.$logline['nt'].'] - <snap style="color:#'.($logline['type']=='E'?'FF0000':'585858').'">'.$logline['msg'].'</snap> '.$logline['extInfo'].'<br/>'; ?>
307
  </div>
308
 
309
  </div>
@@ -416,6 +483,12 @@ Please see #4 and #5 for Twitter:<br/>
416
  </div>
417
 
418
  </form>
 
 
 
 
 
 
419
  <br/>&nbsp;<br/> <?php
420
  }
421
 
@@ -448,7 +521,7 @@ Please see #4 and #5 for Twitter:<br/>
448
  Here you can setup "Social Networks Auto Poster".<br/> You can start by clicking "Add new account" button and choosing the Social Network you would like to add.<?php }} ?><br/>
449
  <?php
450
  if (!function_exists('curl_init')) {
451
- echo ('<br/><b style=\'font-size:16px; color:red;\'>Error: No CURL Found</b> <br/><i>Social Networks AutoPoster needs the CURL PHP extension. Please install it or contact your hosting company to install it.</i><br/>');
452
  }
453
  /*
454
  if ((defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE==true) || (defined('MULTISITE') && MULTISITE==true) ) {
@@ -466,9 +539,14 @@ Please see #4 and #5 for Twitter:<br/>
466
  $post = get_post($id); if ($post->post_type=='revision') return; if (isset($_POST["SNAPEdit"])) $nspost_edit = $_POST["SNAPEdit"];
467
  if (isset($nspost_edit) && !empty($nspost_edit)) { delete_post_meta($id, 'snapEdIT'); add_post_meta($id, 'snapEdIT', '1' );
468
  foreach ($nxs_snapAvNts as $avNt) {
469
- 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)); $newMeta = $_POST[$avNt['lcode']];
470
- if (is_array($savedMeta) && is_array($newMeta)) $newMeta = nxsMergeArraysOV($savedMeta, $newMeta);
471
- delete_post_meta($id, 'snap'.$avNt['code']); add_post_meta($id, 'snap'.$avNt['code'], (serialize($newMeta)));
 
 
 
 
 
472
  }
473
  }
474
  } // prr($_POST);
@@ -483,6 +561,7 @@ Please see #4 and #5 for Twitter:<br/>
483
  .underdash {border-bottom: 1px #21759B dashed; text-decoration:none;}
484
  .underdash a:hover {border-bottom: 1px #21759B dashed}
485
  </style>
 
486
  <input value="SNAPEdit" type="hidden" name="SNAPEdit" />
487
  <div class="popShAtt" style="width: 200px;" id="popShAttSV">Please "Update" the post before reposting, if you made any changes to the format</div>
488
  <?php if($post->post_status != "publish" ) { ?>
@@ -500,8 +579,11 @@ Please see #4 and #5 for Twitter:<br/>
500
  ?></table></div></div></div> <?php
501
  }
502
  //## Add MetaBox to Post->Edit
503
- function NS_SNAP_addCustomBoxes() { add_meta_box( 'NS_SNAP_AddPostMetaTags', __( 'NextScripts: Social Networks Auto Poster - Post Options', 'NS_SNAutoPoster' ), array($this, 'NS_SNAP_AddPostMetaTags'), 'post' );
504
  global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
 
 
 
505
  $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);
506
  if ((isset($options['nxsCPTSeld'])) && $options['nxsCPTSeld']!='') $nxsCPTSeld = unserialize($options['nxsCPTSeld']); else $nxsCPTSeld = array_keys($post_types); //prr($nxsCPTSeld);
507
  foreach ($post_types as $cptID=>$cptName) if (in_array($cptID, $nxsCPTSeld)){
@@ -534,12 +616,10 @@ if (!function_exists("nxs_clLgo_ajax")) { function nxs_clLgo_ajax() { check_ajax
534
  update_option('NS_SNAutoPosterLog', ''); echo "OK";
535
  }}
536
 
537
- if (!function_exists("nxs_rfLgo_ajax")) { function nxs_rfLgo_ajax() { echo "W"; check_ajax_referer('nxsSsPageWPN'); echo "Y";
538
  $log = get_option('NS_SNAutoPosterLog');
539
  $logInfo = maybe_unserialize(get_option('NS_SNAutoPosterLog')); if (is_array($logInfo))
540
  foreach (array_reverse($logInfo) as $logline) echo '<snap style="color:#008000">['.$logline['date'].']</snap> - ['.$logline['nt'].'] - <snap style="color:#'.($logline['type']=='E'?'FF0000':'585858').'">'.$logline['msg'].'</snap> '.$logline['extInfo'].'<br/>';
541
-
542
-
543
  }}
544
 
545
  //## Initialize the admin panel if the plugin has been activated
@@ -568,11 +648,14 @@ if (!function_exists("nxs_snapPublishTo")) { function nxs_snapPublishTo($postArr
568
  if ($options['nxsCPTSeld']!='') $nxsCPTSeld = unserialize($options['nxsCPTSeld']); else $nxsCPTSeld = array_keys($post_types); //prr($nxsCPTSeld);
569
  $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted=='1') return;
570
 
571
- if ($post->post_type == 'post' || in_array($post->post_type, $post_types) && in_array($post->post_type, $nxsCPTSeld)) foreach ($nxs_snapAvNts as $avNt) {
572
  if (count($options[$avNt['lcode']])>0) { $clName = 'nxs_snapClass'.$avNt['code'];
573
  if ($isPost) $po = $_POST[$avNt['lcode']]; else { $po = get_post_meta($postID, 'snap'.$avNt['code'], true); $po = maybe_unserialize($po);}
574
  $optMt = $options[$avNt['lcode']][0]; if (isset($po) && is_array($po)) { $ntClInst = new $clName(); $optMt = $ntClInst->adjMetaOpt($optMt, $po[0]); }
575
  $isCustBoxMeta = get_post_meta($postID, 'nxs_snapPostTo_'.$avNt['code'], true);
 
 
 
576
  if ($optMt['do'.$avNt['code']]=='1' || $isCustBoxMeta=='1') { delete_post_meta($postID, 'snap_isAutoPosted'); add_post_meta($postID, 'snap_isAutoPosted', '1'); $optMt['ii'] = 0;
577
  if ($publtype=='S') { // nxs_addToLog($logNT, 'M', $avNt['code'].' autopost scheduled');
578
  $args = array($postID, $optMt); wp_schedule_single_event(time()+$delay, 'ns_doPublishTo'.$avNt['code'], $args);
@@ -632,6 +715,10 @@ if (!function_exists("nsFormatMessage")) { function nsFormatMessage($msg, $postI
632
  if (preg_match('%CATS%', $msg)) { $t = wp_get_post_categories($postID); $cats = array(); foreach($t as $c){ $cat = get_category($c); $cats[] = str_ireplace('&','&amp;',$cat->name); }
633
  $ctts = implode(', ',$cats); $msg = str_ireplace("%CATS%", $ctts, $msg);
634
  }
 
 
 
 
635
  if (preg_match('%FULLTEXT%', $msg)) { $postContent = apply_filters('the_content', nxs_doQTrans($post->post_content, $lng)); $msg = str_ireplace("%FULLTEXT%", $postContent, $msg);}
636
  if (preg_match('%RAWTEXT%', $msg)) { $postContent = nxs_doQTrans($post->post_content, $lng); $msg = str_ireplace("%RAWTEXT%", $postContent, $msg);}
637
  if (preg_match('%SITENAME%', $msg)) { $siteTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); $msg = str_ireplace("%SITENAME%", $siteTitle, $msg);}
@@ -679,7 +766,8 @@ function nxs_ogtgCallback($content){ global $post, $plgn_NS_SNAutoPoster; if (!
679
  $ogD = '<meta property="og:description" content="'.esc_attr( apply_filters( 'nxsog_desc', $ogD ) ).'" />'."\r\n";
680
  }
681
  $ogSN = '<meta property="og:site_name" content="'.get_bloginfo('name').'" />'."\r\n";
682
- $ogLoc = '<meta property="og:locale" content="'.strtolower(esc_attr(get_locale())).'" />'."\r\n"; $iss = is_home();
 
683
  $ogType = is_singular()?'article':'website'; if($vidsFromPost == false) $ogType = '<meta property="og:type" content="'.esc_attr(apply_filters('nxsog_type', $ogType)).'" />'."\r\n";
684
 
685
  if (is_home() || is_front_page()) $ogUrl = get_bloginfo( 'url' ); else $ogUrl = 'http' . (is_ssl() ? 's' : '') . "://".$_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
@@ -708,6 +796,18 @@ function nxs_ogtgCallback($content){ global $post, $plgn_NS_SNAutoPoster; if (!
708
  }
709
 
710
  function nxs_addOGTagsPreHolder() { echo "<!-- ## NXS/OG ## --><!-- ## NXSOGTAGS ## --><!-- ## NXS/OG ## -->\n\r";}
 
 
 
 
 
 
 
 
 
 
 
 
711
 
712
  //## Actions and filters
713
  if (isset($plgn_NS_SNAutoPoster)) { //## Actions
@@ -722,10 +822,13 @@ if (isset($plgn_NS_SNAutoPoster)) { //## Actions
722
  if (function_exists('nxs_doSMAS3')) nxs_doSMAS3($isS, $isO);
723
 
724
  add_action('admin_init', 'nxs_adminInitFunc');
725
-
726
 
727
  add_action('wp_ajax_nxs_clLgo', 'nxs_clLgo_ajax');
728
  add_action('wp_ajax_nxs_rfLgo', 'nxs_rfLgo_ajax');
 
 
 
729
 
730
  if ($isO || $isS) {
731
  //## Whenever you publish a post, post to Social Networks
@@ -758,6 +861,7 @@ if (isset($plgn_NS_SNAutoPoster)) { //## Actions
758
  add_action('wp_ajax_getBoards' , 'nsGetBoards_ajax');
759
  add_action('wp_ajax_nsDN', 'ns_delNT_ajax');
760
 
 
761
  add_action('wp_ajax_nsAuthFBSv', 'nsAuthFBSv_ajax');
762
  //## Custom Post Types and OG tags
763
  add_filter('plugin_action_links','ns_add_settings_link', 10, 2 );
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.5.5
8
  Author URI: http://www.nextscripts.com
9
  Copyright 2012 Next Scripts, Inc
10
  */
11
+ define( 'NextScripts_SNAP_Version' , '2.5.5' ); require_once "nxs_functions.php";
12
  //## Include All Available Networks
13
  global $nxs_snapAvNts, $nxs_snapThisPageUrl, $nxs_plurl, $nxs_isWPMU, $nxs_tpWMPU;
14
  $nxs_snapAvNts = array(); foreach (glob(plugin_dir_path( __FILE__ ).'inc-cl/*.php') as $filename){ require_once $filename; }
15
 
16
  $nxs_snapThisPageUrl = admin_url().'options-general.php?page=NextScripts_SNAP.php';
17
  $nxs_plurl = plugin_dir_url(__FILE__);
18
+ $nxs_isWPMU = defined('MULTISITE') && MULTISITE==true;
19
 
20
  //## Define SNAutoPoster class
21
  if (!class_exists("NS_SNAutoPoster")) {
35
  //$options = array('nsOpenGraph'=>1);
36
  $dbOptions = get_option($this->dbOptionsName);
37
  $this->nxs_ntoptions = get_site_option($this->dbOptionsName);
38
+ if ($nxs_isWPMU && $blog_id>1) { switch_to_blog(1); $dbMUOptions = get_option($this->dbOptionsName);
39
+ if (function_exists('nxs_getInitAdd')) nxs_getInitAdd($dbMUOptions); restore_current_blog();
40
  $dbOptions['lk'] = $dbMUOptions['lk']; $dbOptions['ukver'] = $dbMUOptions['ukver']; $dbOptions['uklch'] = $dbMUOptions['uklch']; $dbOptions['uk'] = $dbMUOptions['uk'];
41
  }
42
  if (!empty($dbOptions) && is_array($dbOptions)) foreach ($dbOptions as $key => $option) if (trim($key)!='') $options[$key] = $option;
43
+ if ( (!$nxs_isWPMU || $blog_id==1) && function_exists('nxs_getInitAdd')) nxs_getInitAdd($options); //$ttt = function_exists('nxs_getInitAdd'); var_dump($ttt);
44
+ if (isset($options['uk']) && $options['uk']!='') $options['uk']='API';
45
+
46
  if (defined('NXSAPIVER') && $options['ukver']!=NXSAPIVER){$options['ukver']=NXSAPIVER; update_option($this->dbOptionsName, $options);}
47
  $options['isMA'] = function_exists('nxs_doSMAS1') && isset($options['lk']) && isset($options['uk']) && $options['uk']!='';
48
  $options['isMU'] = function_exists('showSNAP_WPMU_OptionsPageExt') && isset($options['lk']) && isset($options['uk']) && $options['uk']!='';
71
  }
72
  //## Update the options for the panel
73
  $options = $optPro; update_option($this->dbOptionsName, $options);
74
+ }
75
+ // if(!$options['isMA']) $options = nxs_snapCleanup($options);
76
  return $options;
77
  }
78
 
110
  <?php return;
111
  }
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']));
119
+ while (substr($fileData, 0,1)!=='a') $fileData = substr($fileData, 1);
120
+ $uplOpt = maybe_unserialize($fileData); if (is_array($uplOpt) && isset($uplOpt['imgNoCheck'])) { $options = $uplOpt; update_option($this->dbOptionsName, $options); } else { ?><div class="error" id="message"><p><strong>Incorrect Import file.</div><?php }
121
+ }
122
+ }
123
 
124
+ if (isset($_POST['update_NS_SNAutoPoster_settings'])) { if (get_magic_quotes_gpc()) {array_walk_recursive($_POST, 'nsx_stripSlashes');} array_walk_recursive($_POST, 'nsx_fixSlashes');
125
+ //## Load Networks Settings
126
  foreach ($nxs_snapAvNts as $avNt) if (isset($_POST[$avNt['lcode']])) { $clName = 'nxs_snapClass'.$avNt['code']; if (!isset($options[$avNt['lcode']])) $options[$avNt['lcode']] = array();
127
  $ntClInst = new $clName(); $ntOpt = $ntClInst->setNTSettings($_POST[$avNt['lcode']], $options[$avNt['lcode']]); $options[$avNt['lcode']] = $ntOpt;
128
  }
139
 
140
  if (isset($_POST['nsOpenGraph'])) $options['nsOpenGraph'] = $_POST['nsOpenGraph']; else $options['nsOpenGraph'] = 0;
141
  if (isset($_POST['imgNoCheck'])) $options['imgNoCheck'] = 0; else $options['imgNoCheck'] = 1;
142
+ if (isset($_POST['useForPages'])) $options['useForPages'] = 1; else $options['useForPages'] = 0;
143
+
144
+
145
+ if (isset($_POST['showPrxTab'])) $options['showPrxTab'] = 1; else $options['showPrxTab'] = 0;
146
+ if (isset($_POST['useRndProxy'])) $options['useRndProxy'] = 1; else $options['useRndProxy'] = 0;
147
+
148
+ if (isset($_POST['prxList'])) $options['prxList'] = $_POST['prxList'];
149
+
150
 
151
  if (isset($_POST['useUnProc'])) $options['useUnProc'] = $_POST['useUnProc']; else $options['useUnProc'] = 0;
152
  if (isset($_POST['nxsCPTSeld'])) $options['nxsCPTSeld'] = serialize($_POST['nxsCPTSeld']);
153
+ if (isset($_POST['post_category'])) { $pk = $_POST['post_category']; if (!is_array($pk)) { $pk = urldecode($pk); parse_str($pk); }
154
+ $cIds = get_all_category_ids(); if(is_array($pk) && $cIds) $options['exclCats'] = serialize(array_diff($cIds, $pk)); else $options['exclCats'] = '';
155
+ } //prr($options['exclCats']);
156
  if (!isset($_POST['whoCanSeeSNAPBox'])) $_POST['whoCanSeeSNAPBox'] = array(); $_POST['whoCanSeeSNAPBox'][] = 'administrator';
157
  if (isset($_POST['whoCanSeeSNAPBox'])) $options['whoCanSeeSNAPBox'] = $_POST['whoCanSeeSNAPBox'];
158
  if ($nxs_isWPMU && (!isset($options['suaMode'])||$options['suaMode'] = '')) $options['suaMode'] = $nxs_tpWMPU;
176
  <ul class="nsx_tabs">
177
  <li><a href="#nsx_tab1">Your Social Networks Accounts</a></li>
178
  <li><a href="#nsx_tab2">Other Settings</a></li>
179
+ <?php if ((function_exists("nxs_showPRXTab")) && (int)$options['showPrxTab'] == 1) { ?> <li><a href="#nsx_tab5">Proxies</a></li> <?php } ?>
180
  <li><a href="#nsx_tab3">Log/History</a></li>
181
  <li><a href="#nsx_tab4">Help/Support</a></li>
182
  </ul>
183
  <form method="post" id="nsStForm" action="<?php echo $nxs_snapThisPageUrl?>">
184
  <div class="nsx_tab_container">
185
+ <div id="nsx_tab1" class="nsx_tab_content"><a href="#" class="NXSButton" id="nxs_snapAddNew">Add new account</a> <div class="nxsInfoMsg"><img style="position: relative; top: 8px;" alt="Arrow" src="<?php echo $nxs_plurl; ?>img/arrow_l_green_c1.png"/> You can add Facebook, Twitter, Google+, Pinterest, LinkedIn, Tumblr, Blogger/Blogspot, Delicious, etc accounts</div><br/><br/>
186
  <div id="nxs_spPopup"><span class="nxspButton bClose"><span>X</span></span>Add New Network: <select onchange="doShowFillBlockX(this.value);" id="nxs_ntType"><option value =""></option>
187
  <?php foreach ($nxs_snapAvNts as $avNt) { if (!isset($options[$avNt['lcode']]) || count($options[$avNt['lcode']])==0) $mt=0; else $mt = 1+max(array_keys($options[$avNt['lcode']]));
188
  echo '<option value ="'.$avNt['code'].$mt.'">'.$avNt['name'].'</option>';
196
  </div>
197
 
198
  </div>
199
+
200
+ <div id="showCatSel" style="display: none;background-color: #fff; width: 300px; padding: 25px;"><span class="nxspButton bClose"><span>X</span></span>Select Categories:
201
+ <div id="fbSelCats<?php echo $ii; ?>" class="categorydivInd" style="padding-left: 15px; background-color: #fff;">
202
+ <a href="#" onclick="nxs_chAllCatsL(1, 'fbSelCats<?php echo $ii; ?>'); return false;">Check all</a> &nbsp;|&nbsp; <a href="#" onclick="nxs_chAllCatsL(0, 'fbSelCats<?php echo $ii; ?>'); return false;">UnCheck all</a>
203
+ <div id="category-all" class="tabs-panel"> <input type="hidden" id="tmpCatSelNT" name="tmpCatSelNT" value="" />
204
+ <ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
205
+ <?php if (function_exists('wp_terms_checklist')) wp_terms_checklist(0, $args ); ?>
206
+ </ul>
207
+ </div>
208
+ </div> <div class="submit"><input type="button" id="" class="button-primary" name="btnSelCats" onclick="nxs_doSetSelCats( jQuery('#tmpCatSelNT').val() ); $('#showCatSel').bPopup().close();" value="Select Categories" /></div>
209
+ </div>
210
+
211
  <?php wp_nonce_field( 'nsDN', 'nsDN_wpnonce' );
212
  foreach ($nxs_snapAvNts as $avNt) { $clName = 'nxs_snapClass'.$avNt['code']; $ntClInst = new $clName();
213
  if ( isset($options[$avNt['lcode']]) && count($options[$avNt['lcode']])>0) { $ntClInst->showGenNTSettings($options[$avNt['lcode']]); } // else $ntClInst->showNewNTSettings(0);
214
  }
215
  if ($isNoNts) { ?><br/><br/><br/>You don't have any configured social networks yet. Please click "Add new account" button.<?php } else {?>
216
+
217
+ <div style="float: right; padding: 1.5em;">
218
+
219
+ <input onclick="nxs_expSettings(); return false;" type="button" class="button" name="expSettings_repostButton" id="expSettings_button" value="<?php _e('Export Settings', 'expSettings') ?>" />
220
+ <input onclick="jQuery('#impFileSettings_button').click(); return false;" type="button" class="button" name="impSettings_repostButton" id="impSettings_button" value="<?php _e('Import Settings', 'impSettings') ?>" />
221
+ </div>
222
+
223
+ <div class="submit"><input type="submit" id="nxs-button-primary-submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'NS_SNAutoPoster') ?>" /></div>
224
+
225
  <?php } ?>
226
  </div> <!-- END TAB -->
227
  <div id="nsx_tab2" class="nsx_tab_content">
245
  if (in_array($role, $options['whoCanSeeSNAPBox']) || $role=='administrator') echo ' checked="checked" '; if ($role=='administrator' || $role=='subscriber') echo ' disabled="disabled" ';
246
  echo 'name="whoCanSeeSNAPBox[]" value="'.esc_attr($role).'"> '.$name;
247
  if ($role=='administrator') echo ' - Somebody who has access to all the administration features';
248
+ if ($role=='editor') echo " - Somebody who can publish and manage posts and pages as well as manage other users' posts, etc. ";
249
  if ($role=='author') echo ' - Somebody who can publish and manage their own posts ';
250
  if ($role=='contributor') echo ' - Somebody who can write and manage their posts but not publish them';
251
  if ($role=='subscriber') echo ' - Somebody who can only manage their profile';
265
  ?><option <?php if (in_array($cptID,$nxsCPTSeld)) echo 'selected="selected"'; ?> value="<?php echo $cptID; ?>"><?php echo $cptName; ?></option><?php
266
  }
267
  ?>
268
+ </select>
269
+
270
+ <h3 style="font-size: 14px; margin-bottom: 2px;">Use for pages</h3>
271
+
272
+ <p style="margin: 0px;margin-left: 5px;"><input value="set" id="useForPages" name="useForPages" type="checkbox" <?php if ((int)$options['useForPages'] != 1) echo "checked"; ?> />
273
+ <strong>Use for pages</strong>
274
+ <span style="font-size: 11px; margin-left: 1px;">Show the metabox and autopost for pages.</span>
275
+ </p>
276
 
277
  <div style="width:500px;"><strong style="font-size: 14px;"><br/>Categories to Include/Exclude:</strong>
278
  <p style="font-size: 11px; margin: 0px;">Each blogpost will be autoposted to all categories selected below. All categories are selected by default.
282
  function nxs_chAllCats(ch){
283
  jQuery("form input:checkbox[name='post_category[]']").attr('checked', ch==1);
284
  }
285
+ (function($) {
286
+ $(function() {
287
+ $('.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="" />');
288
+ str = str.replace(/post_category/g, "pk"); $('div.categorydiv').replaceWith('<input type="hidden" name="post_category" value="'+str+'" />');
289
+ });
290
+ });
291
+ })(jQuery);
292
  </script>
293
 
294
  <a href="#" onclick="nxs_chAllCats(1); return false;">Check all</a> &nbsp;|&nbsp; <a href="#" onclick="nxs_chAllCats(0); return false;">UnCheck all</a>
296
  <div id="taxonomy-category" class="categorydiv">
297
  <div id="category-all" class="tabs-panel"><input type='hidden' name='post_category[]' value='0' />
298
  <ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
299
+ <?php if(isset($options['exclCats'])) $pk = maybe_unserialize($options['exclCats']); else $pk = '';
300
  if (is_array($pk) && count($pk)>0 ) $selCats = array_diff($category_ids, $pk); else $selCats = $category_ids;
301
  $args = array( 'descendants_and_self' => 0, 'selected_cats' => $selCats, 'taxonomy' => 'category', 'checked_ontop' => false);
302
  if (function_exists('wp_terms_checklist')) wp_terms_checklist(0, $args );
342
  Custom field Image Prefix: <input name="featImgLocPrefix" style="width: 200px;" value="<?php if (isset($options['featImgLocPrefix'])) _e(apply_filters('format_to_edit',$options['featImgLocPrefix']), 'NS_SNAutoPoster') ?>" />
343
 
344
 
345
+ <h3 style="font-size: 14px; margin-bottom: 2px;">Verify "Featured" Image</h3>
346
 
347
+ <p style="margin: 0px;margin-left: 5px;"><input value="set" id="imgNoCheck" name="imgNoCheck" type="checkbox" <?php if ((int)$options['imgNoCheck'] != 1) echo "checked"; ?> />
348
  <strong>Verify "Featured" Image</strong>
349
  <span style="font-size: 11px; margin-left: 1px;">Advanced Setting. Uncheck only if you are 100% sure that your images are valid or if you have troubles with image verification.</span>
350
+ </p>
351
+
352
+ <?php if (function_exists("nxs_showPRXTab")) { ?>
353
+
354
+ <h3 style="font-size: 14px; margin-bottom: 2px;">Show "Proxies" Tab</h3>
355
+
356
+ <p style="margin: 0px;margin-left: 5px;"><input value="set" id="showPrxTab" name="showPrxTab" type="checkbox" <?php if ((int)$options['showPrxTab'] == 1) echo "checked"; ?> />
357
+ <strong>Show "Proxies" Tab</strong>
358
+ <span style="font-size: 11px; margin-left: 1px;">Advanced Setting. Check to enable "Proxies" tab where you can setup autoposting proxies.</span>
359
+ </p>
360
+ <?php } ?>
361
 
362
+ <div class="submit"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'NS_SNAutoPoster') ?>" /></div>
363
 
364
  </div>
365
+ <?php if ((function_exists("nxs_showPRXTab")) && (int)$options['showPrxTab'] == 1) { nxs_showPRXTab($options); } ?>
366
  <div id="nsx_tab3" class="nsx_tab_content">
367
  <div style="width:760px;">
368
  <a href="#" style="float: right" onclick="nxs_rfLog();return false;" class="NXSButton" id="nxs_clearLog">Refresh</a>
370
  Showing last 150 records <a href="#" onclick="nxs_clLog();return false;" class="NXSButton" id="nxs_clearLog">Clear Log</a><br/><br/>
371
  <div style="overflow: auto; border: 1px solid #999; width: 750px; height: 600px; font-size: 11px;" class="logDiv" id="nxslogDiv">
372
  <?php $logInfo = maybe_unserialize(get_option('NS_SNAutoPosterLog')); if (is_array($logInfo))
373
+ foreach (array_reverse($logInfo) as $logline) echo '<snap style="color:#008000">['.$logline['date'].']</snap> - ['.$logline['nt'].'] - <snap style="color:#'.($logline['type']=='E'?'FF0000':'585858').'">'.((stripos($logline['msg'], '<body')!==false)?CutFromTo($logline['msg'], '<body ', '</body>'):$logline['msg']).'</snap> '.$logline['extInfo'].'<br/>'; ?>
374
  </div>
375
 
376
  </div>
483
  </div>
484
 
485
  </form>
486
+
487
+ <form method="post" enctype="multipart/form-data" id="nsStFormUpl" action="<?php echo $nxs_snapThisPageUrl?>">
488
+ <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">
489
+ <input type="hidden" value="1" name="upload_NS_SNAutoPoster_settings" /> <?php wp_nonce_field( 'nxsChkUpl', 'nxsChkUpl_wpnonce' ); ?>
490
+ </form>
491
+
492
  <br/>&nbsp;<br/> <?php
493
  }
494
 
521
  Here you can setup "Social Networks Auto Poster".<br/> You can start by clicking "Add new account" button and choosing the Social Network you would like to add.<?php }} ?><br/>
522
  <?php
523
  if (!function_exists('curl_init')) {
524
+ echo ("<br/><b style='font-size:16px; color:red;'>Error: No CURL Found</b> <br/><i>Social Networks AutoPoster needs the CURL PHP extension. Please install it or contact your hosting company to install it.</i><br/>");
525
  }
526
  /*
527
  if ((defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE==true) || (defined('MULTISITE') && MULTISITE==true) ) {
539
  $post = get_post($id); if ($post->post_type=='revision') return; if (isset($_POST["SNAPEdit"])) $nspost_edit = $_POST["SNAPEdit"];
540
  if (isset($nspost_edit) && !empty($nspost_edit)) { delete_post_meta($id, 'snapEdIT'); add_post_meta($id, 'snapEdIT', '1' );
541
  foreach ($nxs_snapAvNts as $avNt) {
542
+ 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));
543
+ if(is_array($_POST[$avNt['lcode']])) { $ii=0;
544
+ foreach ($_POST[$avNt['lcode']] as $pst ) {
545
+ if (is_array($pst) && $pst['SNAPinclude'.$avNt['code']]=='') $_POST[$avNt['lcode']][$ii]['SNAPinclude'.$avNt['code']]= 0; $ii++;
546
+ }
547
+ } $newMeta = $_POST[$avNt['lcode']]; // prr($newMeta); echo "~~~~~";
548
+ if (is_array($savedMeta) && is_array($newMeta)) $newMeta = nxsMergeArraysOV($savedMeta, $newMeta); // echo "## snap".$avNt['code']; prr($savedMeta); echo "||"; prr($newMeta);
549
+ delete_post_meta($id, 'snap'.$avNt['code']); add_post_meta($id, 'snap'.$avNt['code'], $newMeta);
550
  }
551
  }
552
  } // prr($_POST);
561
  .underdash {border-bottom: 1px #21759B dashed; text-decoration:none;}
562
  .underdash a:hover {border-bottom: 1px #21759B dashed}
563
  </style>
564
+
565
  <input value="SNAPEdit" type="hidden" name="SNAPEdit" />
566
  <div class="popShAtt" style="width: 200px;" id="popShAttSV">Please "Update" the post before reposting, if you made any changes to the format</div>
567
  <?php if($post->post_status != "publish" ) { ?>
579
  ?></table></div></div></div> <?php
580
  }
581
  //## Add MetaBox to Post->Edit
582
+ function NS_SNAP_addCustomBoxes() { add_meta_box( 'NS_SNAP_AddPostMetaTags', __( 'NextScripts: Social Networks Auto Poster - Post Options', 'NS_SNAutoPoster' ), array($this, 'NS_SNAP_AddPostMetaTags'), 'post' );
583
  global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
584
+
585
+ if ($options['useForPages']=='1') add_meta_box( 'NS_SNAP_AddPostMetaTags', __( 'NextScripts: Social Networks Auto Poster - Post Options', 'NS_SNAutoPoster' ), array($this, 'NS_SNAP_AddPostMetaTags'), 'page' );
586
+
587
  $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);
588
  if ((isset($options['nxsCPTSeld'])) && $options['nxsCPTSeld']!='') $nxsCPTSeld = unserialize($options['nxsCPTSeld']); else $nxsCPTSeld = array_keys($post_types); //prr($nxsCPTSeld);
589
  foreach ($post_types as $cptID=>$cptName) if (in_array($cptID, $nxsCPTSeld)){
616
  update_option('NS_SNAutoPosterLog', ''); echo "OK";
617
  }}
618
 
619
+ if (!function_exists("nxs_rfLgo_ajax")) { function nxs_rfLgo_ajax() { check_ajax_referer('nxsSsPageWPN'); echo "Y:";
620
  $log = get_option('NS_SNAutoPosterLog');
621
  $logInfo = maybe_unserialize(get_option('NS_SNAutoPosterLog')); if (is_array($logInfo))
622
  foreach (array_reverse($logInfo) as $logline) echo '<snap style="color:#008000">['.$logline['date'].']</snap> - ['.$logline['nt'].'] - <snap style="color:#'.($logline['type']=='E'?'FF0000':'585858').'">'.$logline['msg'].'</snap> '.$logline['extInfo'].'<br/>';
 
 
623
  }}
624
 
625
  //## Initialize the admin panel if the plugin has been activated
648
  if ($options['nxsCPTSeld']!='') $nxsCPTSeld = unserialize($options['nxsCPTSeld']); else $nxsCPTSeld = array_keys($post_types); //prr($nxsCPTSeld);
649
  $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted=='1') return;
650
 
651
+ 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) {
652
  if (count($options[$avNt['lcode']])>0) { $clName = 'nxs_snapClass'.$avNt['code'];
653
  if ($isPost) $po = $_POST[$avNt['lcode']]; else { $po = get_post_meta($postID, 'snap'.$avNt['code'], true); $po = maybe_unserialize($po);}
654
  $optMt = $options[$avNt['lcode']][0]; if (isset($po) && is_array($po)) { $ntClInst = new $clName(); $optMt = $ntClInst->adjMetaOpt($optMt, $po[0]); }
655
  $isCustBoxMeta = get_post_meta($postID, 'nxs_snapPostTo_'.$avNt['code'], true);
656
+ if ($snap_isEdIT!='1') { $doPost = true;
657
+ if ( $optMt['catSel']=='1' && trim($optMt['catSelEd'])!='' ) { $exclCats = explode(',',$optMt['catSelEd']); foreach ($postCats as $pCat) { if (in_array($pCat, $exclCats)) $doPost = false; else {$doPost = true; break;}} if (!$doPost) break; }
658
+ }
659
  if ($optMt['do'.$avNt['code']]=='1' || $isCustBoxMeta=='1') { delete_post_meta($postID, 'snap_isAutoPosted'); add_post_meta($postID, 'snap_isAutoPosted', '1'); $optMt['ii'] = 0;
660
  if ($publtype=='S') { // nxs_addToLog($logNT, 'M', $avNt['code'].' autopost scheduled');
661
  $args = array($postID, $optMt); wp_schedule_single_event(time()+$delay, 'ns_doPublishTo'.$avNt['code'], $args);
715
  if (preg_match('%CATS%', $msg)) { $t = wp_get_post_categories($postID); $cats = array(); foreach($t as $c){ $cat = get_category($c); $cats[] = str_ireplace('&','&amp;',$cat->name); }
716
  $ctts = implode(', ',$cats); $msg = str_ireplace("%CATS%", $ctts, $msg);
717
  }
718
+ if (preg_match('%HTAGS%', $msg)) { $t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = "#".trim(str_replace(' ','_', str_replace(' ', ' ', trim($tagA->name))));} $tags = implode(', ',$tggs); $msg = str_ireplace("%HTAGS%", $tags, $msg);}
719
+ if (preg_match('%HCATS%', $msg)) { $t = wp_get_post_categories($postID); $cats = array(); foreach($t as $c){ $cat = get_category($c); $cats[] = "#".trim(str_replace(' ','_', str_replace(' ', ' ', trim(str_ireplace('&','&amp;',$cat->name))))); }
720
+ $ctts = implode(', ',$cats); $msg = str_ireplace("%HCATS%", $ctts, $msg);
721
+ }
722
  if (preg_match('%FULLTEXT%', $msg)) { $postContent = apply_filters('the_content', nxs_doQTrans($post->post_content, $lng)); $msg = str_ireplace("%FULLTEXT%", $postContent, $msg);}
723
  if (preg_match('%RAWTEXT%', $msg)) { $postContent = nxs_doQTrans($post->post_content, $lng); $msg = str_ireplace("%RAWTEXT%", $postContent, $msg);}
724
  if (preg_match('%SITENAME%', $msg)) { $siteTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); $msg = str_ireplace("%SITENAME%", $siteTitle, $msg);}
766
  $ogD = '<meta property="og:description" content="'.esc_attr( apply_filters( 'nxsog_desc', $ogD ) ).'" />'."\r\n";
767
  }
768
  $ogSN = '<meta property="og:site_name" content="'.get_bloginfo('name').'" />'."\r\n";
769
+ $ogLoc = strtolower(esc_attr(get_locale())); if (strlen($ogLoc)==2) $ogLoc .= "_".strtoupper($ogLoc);
770
+ $ogLoc = '<meta property="og:locale" content="'.$ogLoc.'" />'."\r\n"; $iss = is_home();
771
  $ogType = is_singular()?'article':'website'; if($vidsFromPost == false) $ogType = '<meta property="og:type" content="'.esc_attr(apply_filters('nxsog_type', $ogType)).'" />'."\r\n";
772
 
773
  if (is_home() || is_front_page()) $ogUrl = get_bloginfo( 'url' ); else $ogUrl = 'http' . (is_ssl() ? 's' : '') . "://".$_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
796
  }
797
 
798
  function nxs_addOGTagsPreHolder() { echo "<!-- ## NXS/OG ## --><!-- ## NXSOGTAGS ## --><!-- ## NXS/OG ## -->\n\r";}
799
+
800
+ if (!function_exists("nxssnap_enqueue_scripts")) { function nxssnap_enqueue_scripts(){
801
+ wp_enqueue_script( 'nxssnap-scripts', plugin_dir_url( __FILE__ ) . 'js/js.js', array( 'jquery' ) );
802
+ wp_localize_script( 'nxssnap-scripts', 'MyAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'nxsnapWPnonce' => wp_create_nonce( 'nxsnapWPnonce' ),));
803
+ }}
804
+
805
+
806
+ if (!function_exists("nxs_getExpSettings_ajax")) { function nxs_getExpSettings_ajax() { check_ajax_referer('nsDN'); $filename = preg_replace('/[^a-z0-9\-\_\.]/i','',$_POST['filename']);
807
+ header("Cache-Control: "); header("Content-type: text/plain"); header('Content-Disposition: attachment; filename="'.$filename.'"');
808
+ global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
809
+ echo serialize($options); die();
810
+ }}
811
 
812
  //## Actions and filters
813
  if (isset($plgn_NS_SNAutoPoster)) { //## Actions
822
  if (function_exists('nxs_doSMAS3')) nxs_doSMAS3($isS, $isO);
823
 
824
  add_action('admin_init', 'nxs_adminInitFunc');
825
+ add_action( 'admin_enqueue_scripts', 'nxssnap_enqueue_scripts' );
826
 
827
  add_action('wp_ajax_nxs_clLgo', 'nxs_clLgo_ajax');
828
  add_action('wp_ajax_nxs_rfLgo', 'nxs_rfLgo_ajax');
829
+ add_action('wp_ajax_nxs_prxTest', 'nxs_prxTest_ajax');
830
+ add_action('wp_ajax_nxs_prxGet', 'nxs_prxGet_ajax');
831
+ add_action('wp_ajax_nxs_getExpSettings', 'nxs_getExpSettings_ajax');
832
 
833
  if ($isO || $isS) {
834
  //## Whenever you publish a post, post to Social Networks
861
  add_action('wp_ajax_getBoards' , 'nsGetBoards_ajax');
862
  add_action('wp_ajax_nsDN', 'ns_delNT_ajax');
863
 
864
+
865
  add_action('wp_ajax_nsAuthFBSv', 'nsAuthFBSv_ajax');
866
  //## Custom Post Types and OG tags
867
  add_filter('plugin_action_links','ns_add_settings_link', 10, 2 );
img/lj-bg.png ADDED
Binary file
img/lj16.png ADDED
Binary file
img/vk-bg.png ADDED
Binary file
img/vk16.png ADDED
Binary file
inc-cl/apis/liOAuth.php CHANGED
@@ -138,6 +138,19 @@ class nsx_LinkedIn {
138
  $response = $this->httpRequest($search_url, $auth_header, "GET");
139
  return $response;
140
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
141
 
142
  function httpRequest($url, $auth_header, $method, $body = NULL) { // $this->debug = true; //if (!is_array($auth_header)) $auth_header = array($auth_header);
143
  if (!is_array($auth_header)) $auth_header = array($auth_header);
@@ -154,13 +167,13 @@ class nsx_LinkedIn {
154
  curl_setopt($curl, CURLOPT_HTTPHEADER, $auth_header);
155
  }
156
 
157
- $data = curl_exec($curl); $errmsg = curl_error($curl);
158
 
159
  //## NextScripts Fix
160
  if (curl_errno($curl) == 60 || stripos($errmsg, 'SSL')!==false) { curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); $data = curl_exec($curl);}
161
  if (curl_errno($curl) > 0) { $err = curl_errno($curl); $errmsg = curl_error($curl); prr($errmsg); prr($err);}
162
  //## /NextScripts Fix
163
- $header = curl_getinfo($curl); curl_close($curl);
164
 
165
  if ($this->debug) echo $data . "\n";
166
  if (trim($data)=='' && $header['http_code']=='201') $data = '201';
138
  $response = $this->httpRequest($search_url, $auth_header, "GET");
139
  return $response;
140
  }
141
+
142
+ function getCurrentShare($parameters='') {
143
+ $search_url = $this->base_url . "/v1/people/~/current-share";
144
+ $request = nsx_trOAuthRequest::from_consumer_and_token($this->consumer, $this->access_token, "GET", $search_url);
145
+ $request->sign_request($this->signature_method, $this->consumer, $this->access_token);
146
+ $auth_header = $request->to_header("https://api.linkedin.com");
147
+ if ($debug) {
148
+ echo $request->get_signature_base_string() . "\n";
149
+ echo $auth_header . "\n";
150
+ }
151
+ $response = $this->httpRequest($search_url, $auth_header, "GET");
152
+ return $response;
153
+ }
154
 
155
  function httpRequest($url, $auth_header, $method, $body = NULL) { // $this->debug = true; //if (!is_array($auth_header)) $auth_header = array($auth_header);
156
  if (!is_array($auth_header)) $auth_header = array($auth_header);
167
  curl_setopt($curl, CURLOPT_HTTPHEADER, $auth_header);
168
  }
169
 
170
+ $data = curl_exec($curl); $errmsg = curl_error($curl); //prr($data);// die();
171
 
172
  //## NextScripts Fix
173
  if (curl_errno($curl) == 60 || stripos($errmsg, 'SSL')!==false) { curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); $data = curl_exec($curl);}
174
  if (curl_errno($curl) > 0) { $err = curl_errno($curl); $errmsg = curl_error($curl); prr($errmsg); prr($err);}
175
  //## /NextScripts Fix
176
+ $header = curl_getinfo($curl); curl_close($curl);// prr($header);
177
 
178
  if ($this->debug) echo $data . "\n";
179
  if (trim($data)=='' && $header['http_code']=='201') $data = '201';
inc-cl/bg.php CHANGED
@@ -4,8 +4,7 @@ $nxs_snapAvNts[] = array('code'=>'BG', 'lcode'=>'bg', 'name'=>'Blogger');
4
 
5
  if (!class_exists("nxs_snapClassBG")) { class nxs_snapClassBG {
6
  //#### Show Common Settings
7
- function showGenNTSettings($ntOpts){ global $nxs_snapThisPageUrl, $nxs_plurl; $code = 'BG'; $lcode = 'bg'; wp_nonce_field( 'ns'.$code, 'ns'.$code.'_wpnonce' );
8
-
9
  ?>
10
  <hr/><div class="nsx_iconedTitle" style="background-image: url(<?php echo $nxs_plurl; ?>img/<?php echo $lcode; ?>16.png);">Blogger Settings: <?php $cfbo = count($ntOpts); $mfbo = 1+max(array_keys($ntOpts)); ?> <?php wp_nonce_field( 'nsFB', 'nsFB_wpnonce' ); ?>
11
  <div class="nsBigText">You have <?php echo $cfbo=='0'?'No':$cfbo; ?> Blogger account<?php if ($cfbo!=1){ ?>s<?php } ?> <!-- - <a href="#" class="NXSButton" onclick="doShowHideBlocks2('FB<?php echo $mfbo; ?>');return false;">Add new Facebook Account</a> --> </div></div>
@@ -33,6 +32,15 @@ if (!class_exists("nxs_snapClassBG")) { class nxs_snapClassBG {
33
  <?php echo nxs_addQTranslSel('bg', $ii, $options['qTLng']); ?>
34
  <?php echo nxs_addPostingDelaySel('bg', $ii, $options['nHrs'], $options['nMin']); ?>
35
 
 
 
 
 
 
 
 
 
 
36
  <div style="width:100%;"><strong>Blogger Username/Email:</strong> </div><input name="bg[<?php echo $ii; ?>][apBGUName]" id="apBGUName" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit',htmlentities($options['bgUName'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" />
37
  <div style="width:100%;"><strong>Blogger Password:</strong> </div><input name="bg[<?php echo $ii; ?>][apBGPass]" id="apBGPass" autocomplete="off" type="password" style="width: 30%;" value="<?php if (trim($options['bgPass'])!='') _e(apply_filters('format_to_edit', htmlentities(substr($options['bgPass'], 0, 5)=='b4d7s'?nsx_doDecode(substr($options['bgPass'], 5)):$options['bgPass'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" /> <br/>
38
  <div style="width:100%;"><strong>Blogger Blog ID:</strong>
@@ -75,6 +83,9 @@ if (!class_exists("nxs_snapClassBG")) { class nxs_snapClassBG {
75
 
76
  if (isset($pval['apDoBG'])) $options[$ii]['doBG'] = $pval['apDoBG']; else $options[$ii]['doBG'] = 0;
77
 
 
 
 
78
  if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']);
79
  if (isset($pval['apBGUName'])) $options[$ii]['bgUName'] = trim($pval['apBGUName']);
80
  if (isset($pval['apBGPass'])) $options[$ii]['bgPass'] = 'b4d7s'.nsx_doEncode($pval['apBGPass']); else $options[$ii]['bgPass'] = '';
@@ -91,17 +102,22 @@ if (!class_exists("nxs_snapClassBG")) { class nxs_snapClassBG {
91
  }
92
  //#### Show Post->Edit Meta Box Settings
93
  function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
94
- foreach($ntOpts as $ii=>$options){ $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapBG', true)); if (is_array($pMeta)) $options = $this->adjMetaOpt($options, $pMeta[$ii]); $doBG = $options['doBG'];
95
  $isAvailBG = $options['bgUName']!='' && $options['bgPass']!=''; $bgMsgFormat = htmlentities($options['bgMsgFormat'], ENT_COMPAT, "UTF-8"); $bgMsgTFormat = htmlentities($options['bgMsgTFormat'], ENT_COMPAT, "UTF-8");
96
  ?>
97
 
98
- <tr><th style="text-align:left;" colspan="2">
99
- <?php if ($isAvailBG) { ?><input class="nxsGrpDoChb" value="1" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="bg[<?php echo $ii; ?>][SNAPincludeBG]" <?php if (($post->post_status == "publish" && $options['isPosted'] == '1') || ($post->post_status != "publish" && ((int)$doBG == 1)) ) echo 'checked="checked" title="def"'; ?> /> <?php } ?>
100
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/bg16.png);">Blogger - publish to (<i style="color: #005800;"><?php echo $options['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
101
  if ($post->post_status == "publish" && $isAvailBG) { ?>
102
- <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', 're-post') ?>" />
103
-
104
  <?php wp_nonce_field( 'rePostToBG', 'rePostToBG_wpnonce' ); } ?>
 
 
 
 
 
 
105
  </td></tr>
106
  <?php if (!$isAvailBG) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your Blogger Account to AutoPost to Blogger</b>
107
  <?php } elseif ($post->post_status != "puZblish") { ?>
@@ -143,8 +159,8 @@ if (!function_exists('nsBloggerGetAuth')){ function nsBloggerGetAuth($email, $pa
143
  $result = curl_exec($ch); $resultArray = curl_getinfo($ch);
144
  curl_close($ch); $arr = explode("=",$result); $token = $arr[3]; if (trim($token)=='') die('Incorrect Username/Password'); return $token;
145
  }}
146
- if (!function_exists('nsBloggerNewPost')){ function nsBloggerNewPost($auth, $blogID, $title, $text) {$text = str_ireplace('allowfullscreen','', $text);
147
- $text = preg_replace('/<object\b[^>]*>(.*?)<\/object>/is', "", $text);
148
 
149
  $postText = '<entry xmlns="http://www.w3.org/2005/Atom"><title type="text">'.$title.'</title><content type="xhtml">'.$text.'</content></entry>'; //prr($postText);
150
  $len = strlen($entry); $ch = curl_init("https://www.blogger.com/feeds/$blogID/posts/default");
@@ -152,7 +168,8 @@ if (!function_exists('nsBloggerNewPost')){ function nsBloggerNewPost($auth, $blo
152
  curl_setopt($ch, CURLOPT_UNRESTRICTED_AUTH, 1); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
153
  curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0)");
154
  curl_setopt($ch, CURLOPT_HEADER,0); curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1); curl_setopt($ch, CURLINFO_HEADER_OUT, true);
155
- $result = curl_exec($ch); curl_close($ch); if (stripos($result,'tag:blogger.com')!==false) return 'OK'; else { prr($result); return false;}
 
156
  }}
157
  if (!function_exists("nxs_doPublishToBG")) { //## Second Function to Post to BG
158
  function nxs_doPublishToBG($postID, $options){ $ntCd = 'BG'; $ntCdL = 'bg'; $ntNm = 'Blogger';
@@ -179,13 +196,13 @@ if (!function_exists("nxs_doPublishToBG")) { //## Second Function to Post to BG
179
  // prr($msg); echo " =HT= ";
180
  $msg = preg_replace('/<script\b[^>]*>(.*?)<\/script>/is', "", $msg); $msg = preg_replace('/<!--(.*)-->/Uis', "", $msg); $nxshf = new NXS_HtmlFixer(); $nxshf->debug = false; $msg = $nxshf->getFixedHtml($msg);
181
  // prr($msg); die();
 
182
  if (function_exists("doConnectToBlogger")) {$auth = doConnectToBlogger($email, $pass); if ($auth!==false) die($auth); $ret = doPostToBlogger($blogID, $msgT, $msg, $tags);}
183
  else {$auth = nsBloggerGetAuth($email, $pass); $msgT = str_ireplace('&amp;', '&', $msgT); $msgT = utf8_encode(str_ireplace('&', '&amp;', $msgT)); $msg = utf8_encode($msg); $ret = nsBloggerNewPost($auth, $blogID, $msgT, $msg);}
184
- //## /Actual POST Code
185
-
186
- if ($ret!='OK') { if ($postID=='0') echo $ret; nxs_addToLog($logNT, 'E', '-=ERROR=- '. strip_tags(print_r($ret, true)), $extInfo); return $ret; }
187
  else { if ($postID=='0') { echo 'OK - Message Posted, please see your '.$ntNm.' Page '; nxs_addToLog($logNT, 'M', 'OK - TEST Message Posted '); return 201;}
188
- else { nxs_metaMarkAsPosted($postID, $ntCd, $options['ii']); nxs_addToLog($logNT, 'M', 'OK - Message Posted ', $extInfo);} return 200; }
189
  }
190
  }
191
 
4
 
5
  if (!class_exists("nxs_snapClassBG")) { class nxs_snapClassBG {
6
  //#### Show Common Settings
7
+ function showGenNTSettings($ntOpts){ global $nxs_snapThisPageUrl, $nxs_plurl; $code = 'BG'; $lcode = 'bg'; wp_nonce_field( 'ns'.$code, 'ns'.$code.'_wpnonce' );
 
8
  ?>
9
  <hr/><div class="nsx_iconedTitle" style="background-image: url(<?php echo $nxs_plurl; ?>img/<?php echo $lcode; ?>16.png);">Blogger Settings: <?php $cfbo = count($ntOpts); $mfbo = 1+max(array_keys($ntOpts)); ?> <?php wp_nonce_field( 'nsFB', 'nsFB_wpnonce' ); ?>
10
  <div class="nsBigText">You have <?php echo $cfbo=='0'?'No':$cfbo; ?> Blogger account<?php if ($cfbo!=1){ ?>s<?php } ?> <!-- - <a href="#" class="NXSButton" onclick="doShowHideBlocks2('FB<?php echo $mfbo; ?>');return false;">Add new Facebook Account</a> --> </div></div>
32
  <?php echo nxs_addQTranslSel('bg', $ii, $options['qTLng']); ?>
33
  <?php echo nxs_addPostingDelaySel('bg', $ii, $options['nHrs'], $options['nMin']); ?>
34
 
35
+ <?php if (!$isNew) { ?>
36
+ <div style="width:100%;"><strong>Auto-Post Categories:</strong>
37
+ <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="bg[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
38
+ <input value="1" id="catSelSBG<?php echo $ii; ?>" type="radio" name="bg[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_BG<?php echo $ii; ?>" onclick="jQuery('#catSelSBG<?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('BG<?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_BG<?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>
39
+ <input type="hidden" name="bg[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_BG<?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
40
+ </div>
41
+ <br/>
42
+ <?php } ?>
43
+
44
  <div style="width:100%;"><strong>Blogger Username/Email:</strong> </div><input name="bg[<?php echo $ii; ?>][apBGUName]" id="apBGUName" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit',htmlentities($options['bgUName'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" />
45
  <div style="width:100%;"><strong>Blogger Password:</strong> </div><input name="bg[<?php echo $ii; ?>][apBGPass]" id="apBGPass" autocomplete="off" type="password" style="width: 30%;" value="<?php if (trim($options['bgPass'])!='') _e(apply_filters('format_to_edit', htmlentities(substr($options['bgPass'], 0, 5)=='b4d7s'?nsx_doDecode(substr($options['bgPass'], 5)):$options['bgPass'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" /> <br/>
46
  <div style="width:100%;"><strong>Blogger Blog ID:</strong>
83
 
84
  if (isset($pval['apDoBG'])) $options[$ii]['doBG'] = $pval['apDoBG']; else $options[$ii]['doBG'] = 0;
85
 
86
+ if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']);
87
+ if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
88
+
89
  if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']);
90
  if (isset($pval['apBGUName'])) $options[$ii]['bgUName'] = trim($pval['apBGUName']);
91
  if (isset($pval['apBGPass'])) $options[$ii]['bgPass'] = 'b4d7s'.nsx_doEncode($pval['apBGPass']); else $options[$ii]['bgPass'] = '';
102
  }
103
  //#### Show Post->Edit Meta Box Settings
104
  function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
105
+ foreach($ntOpts as $ii=>$options){ $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapBG', true)); if (is_array($pMeta)) $options = $this->adjMetaOpt($options, $pMeta[$ii]); $doBG = $options['doBG'] && $options['catSel']!='1';
106
  $isAvailBG = $options['bgUName']!='' && $options['bgPass']!=''; $bgMsgFormat = htmlentities($options['bgMsgFormat'], ENT_COMPAT, "UTF-8"); $bgMsgTFormat = htmlentities($options['bgMsgTFormat'], ENT_COMPAT, "UTF-8");
107
  ?>
108
 
109
+ <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 } ?>
110
+ <?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; ?>][SNAPincludeBG]" <?php if (($post->post_status == "publish" && $options['isPosted'] == '1') || ($post->post_status != "publish" && ((int)$doBG == 1)) ) echo 'checked="checked" title="def"'; ?> /> <?php } ?>
111
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/bg16.png);">Blogger - publish to (<i style="color: #005800;"><?php echo $options['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
112
  if ($post->post_status == "publish" && $isAvailBG) { ?>
113
+ <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', 're-post') ?>" />
 
114
  <?php wp_nonce_field( 'rePostToBG', 'rePostToBG_wpnonce' ); } ?>
115
+
116
+ <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
117
+ ?> <span id="pstdBG<?php echo $ii; ?>" style="float: right; padding-top: 4px; padding-right: 10px;">
118
+ <a style="font-size: 10px;" href="<?php echo $pMeta[$ii]['pgID']; ?>" target="_blank">Posted on Blogger <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
119
+ </span><?php } ?>
120
+
121
  </td></tr>
122
  <?php if (!$isAvailBG) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your Blogger Account to AutoPost to Blogger</b>
123
  <?php } elseif ($post->post_status != "puZblish") { ?>
159
  $result = curl_exec($ch); $resultArray = curl_getinfo($ch);
160
  curl_close($ch); $arr = explode("=",$result); $token = $arr[3]; if (trim($token)=='') die('Incorrect Username/Password'); return $token;
161
  }}
162
+ if (!function_exists('nsBloggerNewPost')){ function nsBloggerNewPost($auth, $blogID, $title, $text) {$text = str_ireplace('allowfullscreen','', $text); $title = utf8_decode(strip_tags($title));
163
+ $text = preg_replace('/<object\b[^>]*>(.*?)<\/object>/is', "", $text); $text = preg_replace('/<iframe\b[^>]*>(.*?)<\/iframe>/is', "", $text);
164
 
165
  $postText = '<entry xmlns="http://www.w3.org/2005/Atom"><title type="text">'.$title.'</title><content type="xhtml">'.$text.'</content></entry>'; //prr($postText);
166
  $len = strlen($entry); $ch = curl_init("https://www.blogger.com/feeds/$blogID/posts/default");
168
  curl_setopt($ch, CURLOPT_UNRESTRICTED_AUTH, 1); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
169
  curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0)");
170
  curl_setopt($ch, CURLOPT_HEADER,0); curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1); curl_setopt($ch, CURLINFO_HEADER_OUT, true);
171
+ $result = curl_exec($ch); curl_close($ch);
172
+ 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;}
173
  }}
174
  if (!function_exists("nxs_doPublishToBG")) { //## Second Function to Post to BG
175
  function nxs_doPublishToBG($postID, $options){ $ntCd = 'BG'; $ntCdL = 'bg'; $ntNm = 'Blogger';
196
  // prr($msg); echo " =HT= ";
197
  $msg = preg_replace('/<script\b[^>]*>(.*?)<\/script>/is', "", $msg); $msg = preg_replace('/<!--(.*)-->/Uis', "", $msg); $nxshf = new NXS_HtmlFixer(); $nxshf->debug = false; $msg = $nxshf->getFixedHtml($msg);
198
  // prr($msg); die();
199
+
200
  if (function_exists("doConnectToBlogger")) {$auth = doConnectToBlogger($email, $pass); if ($auth!==false) die($auth); $ret = doPostToBlogger($blogID, $msgT, $msg, $tags);}
201
  else {$auth = nsBloggerGetAuth($email, $pass); $msgT = str_ireplace('&amp;', '&', $msgT); $msgT = utf8_encode(str_ireplace('&', '&amp;', $msgT)); $msg = utf8_encode($msg); $ret = nsBloggerNewPost($auth, $blogID, $msgT, $msg);}
202
+ //## /Actual POST Code
203
+ if ( (!is_array($ret)) && $ret!='OK') { if ($postID=='0') prr($ret); nxs_addToLog($logNT, 'E', '-=ERROR=- '. strip_tags(print_r($ret, true)), $extInfo); return $ret; }
 
204
  else { if ($postID=='0') { echo 'OK - Message Posted, please see your '.$ntNm.' Page '; nxs_addToLog($logNT, 'M', 'OK - TEST Message Posted '); return 201;}
205
+ else { nxs_metaMarkAsPosted($postID, $ntCd, $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);} return 200; }
206
  }
207
  }
208
 
inc-cl/di.php CHANGED
@@ -33,6 +33,16 @@ if (!class_exists("nxs_snapClassDI")) { class nxs_snapClassDI {
33
  <div style="width:100%;"><strong>Account Nickname:</strong> <i>Just so you can easely identify it</i> </div><input name="di[<?php echo $ii; ?>][nName]" id="dinName<?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")), 'NS_SNAutoPoster') ?>" /><br/>
34
  <?php echo nxs_addQTranslSel('di', $ii, $options['qTLng']); ?>
35
  <?php echo nxs_addPostingDelaySel('di', $ii, $options['nHrs'], $options['nMin']); ?>
 
 
 
 
 
 
 
 
 
 
36
  <div id="altFormat" style="">
37
  <div style="width:100%;"><strong id="altFormatText">Diigo API Key:</strong> <span style="font-size: 11px; margin: 0px;">Get it from <a target="_blank" href="http://www.diigo.com/api_keys/">http://www.diigo.com/api_keys</a>.</span></div>
38
  <input name="di[<?php echo $ii; ?>][apDIAPIKey]" id="apDIAPIKey" style="width: 60%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['diAPIKey'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" /> <br/>
@@ -74,6 +84,9 @@ if (!class_exists("nxs_snapClassDI")) { class nxs_snapClassDI {
74
  if (isset($pval['apDIPass'])) $options[$ii]['diPass'] = 'n5g9a'.nsx_doEncode($pval['apDIPass']); else $options[$ii]['diPass'] = '';
75
  if (isset($pval['apDIAPIKey'])) $options[$ii]['diAPIKey'] = trim($pval['apDIAPIKey']);
76
 
 
 
 
77
  if (isset($pval['diInclTags'])) $options[$ii]['diInclTags'] = $pval['diInclTags']; else $options[$ii]['diInclTags'] = 0;
78
  if (isset($pval['apDIMsgTFrmt'])) $options[$ii]['diMsgTFormat'] = trim($pval['apDIMsgTFrmt']);
79
  if (isset($pval['apDIMsgFrmt'])) $options[$ii]['diMsgFormat'] = trim($pval['apDIMsgFrmt']);
@@ -85,15 +98,21 @@ if (!class_exists("nxs_snapClassDI")) { class nxs_snapClassDI {
85
  }
86
  //#### Show Post->Edit Meta Box Settings
87
  function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
88
- foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapDI', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]); $doDI = $ntOpt['doDI'];
89
  $isAvailDI = $ntOpt['diUName']!='' && $ntOpt['diPass']!=''; $diMsgFormat = htmlentities($ntOpt['diMsgFormat'], ENT_COMPAT, "UTF-8"); $diMsgTFormat = htmlentities($ntOpt['diMsgTFormat'], ENT_COMPAT, "UTF-8");
90
  ?>
91
- <tr><th style="text-align:left;" colspan="2">
92
- <?php if ($isAvailDI) { ?><input class="nxsGrpDoChb" value="1" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="di[<?php echo $ii; ?>][SNAPincludeDI]" <?php if (($post->post_status == "publish" && $ntOpt['isPosted'] == '1') || ($post->post_status != "publish" && ((int)$doDI == 1)) ) echo 'checked="checked" title="def"'; ?> /> <?php } ?>
93
 
94
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/di16.png);">Diigo - publish to (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
95
  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', 're-post') ?>" />
96
  <?php wp_nonce_field( 'rePostToDI', 'rePostToDI_wpnonce' ); } ?>
 
 
 
 
 
 
97
  </td></tr>
98
 
99
  <?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>
@@ -228,7 +247,8 @@ if (!function_exists("nxs_doPublishToDI")) { //## Second Function to Post to DI
228
  if( is_wp_error( $cnt ) ) {
229
  $ret = 'Something went wrong - '; nxs_addToLog($logNT, 'E', '-=ERROR=- '.$ret. "ERR: ".print_r($cnt, true), $extInfo);
230
  } else {
231
- if (is_array($cnt) && stripos($cnt['body'],'"code":1')!==false) { $ret = 'OK'; nxs_metaMarkAsPosted($postID, 'DI', $options['ii']); nxs_addToLog($logNT, 'M', 'OK - Message Posted ', $extInfo); }
 
232
  else { if ($cnt['response']['code']=='401') $ret = " Incorrect Username/Password "; else $ret = 'Something went wrong - '; nxs_addToLog($logNT, 'E', '-=ERROR=- '.$ret. "ERR: ".print_r($cnt, true), $extInfo);
233
  }
234
  }
33
  <div style="width:100%;"><strong>Account Nickname:</strong> <i>Just so you can easely identify it</i> </div><input name="di[<?php echo $ii; ?>][nName]" id="dinName<?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")), 'NS_SNAutoPoster') ?>" /><br/>
34
  <?php echo nxs_addQTranslSel('di', $ii, $options['qTLng']); ?>
35
  <?php echo nxs_addPostingDelaySel('di', $ii, $options['nHrs'], $options['nMin']); ?>
36
+
37
+ <?php if (!$isNew) { ?>
38
+ <div style="width:100%;"><strong>Auto-Post Categories:</strong>
39
+ <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="di[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
40
+ <input value="1" id="catSelSDI<?php echo $ii; ?>" type="radio" name="di[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_DI<?php echo $ii; ?>" onclick="jQuery('#catSelSDI<?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('DI<?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_DI<?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>
41
+ <input type="hidden" name="di[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_DI<?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
42
+ </div>
43
+ <br/>
44
+ <?php } ?>
45
+
46
  <div id="altFormat" style="">
47
  <div style="width:100%;"><strong id="altFormatText">Diigo API Key:</strong> <span style="font-size: 11px; margin: 0px;">Get it from <a target="_blank" href="http://www.diigo.com/api_keys/">http://www.diigo.com/api_keys</a>.</span></div>
48
  <input name="di[<?php echo $ii; ?>][apDIAPIKey]" id="apDIAPIKey" style="width: 60%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['diAPIKey'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" /> <br/>
84
  if (isset($pval['apDIPass'])) $options[$ii]['diPass'] = 'n5g9a'.nsx_doEncode($pval['apDIPass']); else $options[$ii]['diPass'] = '';
85
  if (isset($pval['apDIAPIKey'])) $options[$ii]['diAPIKey'] = trim($pval['apDIAPIKey']);
86
 
87
+ if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']);
88
+ if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
89
+
90
  if (isset($pval['diInclTags'])) $options[$ii]['diInclTags'] = $pval['diInclTags']; else $options[$ii]['diInclTags'] = 0;
91
  if (isset($pval['apDIMsgTFrmt'])) $options[$ii]['diMsgTFormat'] = trim($pval['apDIMsgTFrmt']);
92
  if (isset($pval['apDIMsgFrmt'])) $options[$ii]['diMsgFormat'] = trim($pval['apDIMsgFrmt']);
98
  }
99
  //#### Show Post->Edit Meta Box Settings
100
  function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
101
+ foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapDI', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]); $doDI = $ntOpt['doDI'] && $ntOpt['catSel']!='1';
102
  $isAvailDI = $ntOpt['diUName']!='' && $ntOpt['diPass']!=''; $diMsgFormat = htmlentities($ntOpt['diMsgFormat'], ENT_COMPAT, "UTF-8"); $diMsgTFormat = htmlentities($ntOpt['diMsgTFormat'], ENT_COMPAT, "UTF-8");
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_DI<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
105
+ <?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; ?>][SNAPincludeDI]" <?php if (($post->post_status == "publish" && $ntOpt['isPosted'] == '1') || ($post->post_status != "publish" && ((int)$doDI == 1)) ) echo 'checked="checked" title="def"'; ?> /> <?php } ?>
106
 
107
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/di16.png);">Diigo - publish to (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
108
  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', 're-post') ?>" />
109
  <?php wp_nonce_field( 'rePostToDI', 'rePostToDI_wpnonce' ); } ?>
110
+
111
+ <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
112
+ ?> <span id="pstdDI<?php echo $ii; ?>" style="float: right; padding-top: 4px; padding-right: 10px;">
113
+ <a style="font-size: 10px;" href="http://www.diigo.com/user/<?php echo $ntOpt['diUName']; ?>" target="_blank">Posted on Diigo <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
114
+ </span><?php } ?>
115
+
116
  </td></tr>
117
 
118
  <?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>
247
  if( is_wp_error( $cnt ) ) {
248
  $ret = 'Something went wrong - '; nxs_addToLog($logNT, 'E', '-=ERROR=- '.$ret. "ERR: ".print_r($cnt, true), $extInfo);
249
  } else {
250
+ if (is_array($cnt) && stripos($cnt['body'],'"code":1')!==false)
251
+ { $ret = 'OK'; nxs_metaMarkAsPosted($postID, 'DI', $options['ii'], array('isPosted'=>'1', 'pgID'=>'DI', 'pDate'=>date('Y-m-d H:i:s'))); nxs_addToLog($logNT, 'M', 'OK - Message Posted ', $extInfo); }
252
  else { if ($cnt['response']['code']=='401') $ret = " Incorrect Username/Password "; else $ret = 'Something went wrong - '; nxs_addToLog($logNT, 'E', '-=ERROR=- '.$ret. "ERR: ".print_r($cnt, true), $extInfo);
253
  }
254
  }
inc-cl/dl.php CHANGED
@@ -29,7 +29,16 @@ if (!class_exists("nxs_snapClassDL")) { class nxs_snapClassDL {
29
  <div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/dl16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-delicious-social-networks-auto-poster-wordpress/">Detailed Delicious Installation/Configuration Instructions</a></div>
30
 
31
  <div style="width:100%;"><strong>Account Nickname:</strong> <i>Just so you can easely identify it</i> </div><input name="dl[<?php echo $ii; ?>][nName]" id="dlnName<?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")), 'NS_SNAutoPoster') ?>" /><br/>
32
- <?php echo nxs_addQTranslSel('dl', $ii, $options['qTLng']); ?><?php echo nxs_addPostingDelaySel('dl', $ii, $gpo['nHrs'], $gpo['nMin']); ?>
 
 
 
 
 
 
 
 
 
33
 
34
  <div style="width:100%;"><strong>Delicious Username:</strong> </div><input name="dl[<?php echo $ii; ?>][apDLUName]" id="apDLUName" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit',htmlentities($gpo['dlUName'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" />
35
  <div style="width:100%;"><strong>Delicious Password:</strong> </div><input name="dl[<?php echo $ii; ?>][apDLPass]" id="apDLPass" type="password" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities(substr($gpo['dlPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($gpo['dlPass'], 5)):$gpo['dlPass'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" /> <br/>
@@ -63,6 +72,10 @@ if (!class_exists("nxs_snapClassDL")) { class nxs_snapClassDL {
63
  if (isset($pval['apDLUName'])) $options[$ii]['dlUName'] = trim($pval['apDLUName']);
64
  if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']);
65
  if (isset($pval['apDLPass'])) $options[$ii]['dlPass'] = 'n5g9a'.nsx_doEncode($pval['apDLPass']); else $options[$ii]['dlPass'] = '';
 
 
 
 
66
  if (isset($pval['apDLMsgFrmt'])) $options[$ii]['dlMsgFormat'] = trim($pval['apDLMsgFrmt']);
67
  if (isset($pval['apDLMsgTFrmt'])) $options[$ii]['dlMsgTFormat'] = trim($pval['apDLMsgTFrmt']);
68
  if (isset($pval['apDoDL'])) $options[$ii]['doDL'] = $pval['apDoDL']; else $options[$ii]['doDL'] = 0;
@@ -73,15 +86,21 @@ if (!class_exists("nxs_snapClassDL")) { class nxs_snapClassDL {
73
  }
74
  //#### Show Post->Edit Meta Box Settings
75
  function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
76
- foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapDL', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]); $doDL = $ntOpt['doDL'];
77
  $isAvailDL = $ntOpt['dlUName']!='' && $ntOpt['dlPass']!=''; $dlMsgFormat = htmlentities($ntOpt['dlMsgFormat'], ENT_COMPAT, "UTF-8"); $dlMsgTFormat = htmlentities($ntOpt['dlMsgTFormat'], ENT_COMPAT, "UTF-8");
78
  ?>
79
- <tr><th style="text-align:left;" colspan="2">
80
- <?php if ($isAvailDL) { ?><input class="nxsGrpDoChb" value="1" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="dl[<?php echo $ii; ?>][SNAPincludeDL]" <?php if (($post->post_status == "publish" && $ntOpt['isPosted'] == '1') || ($post->post_status != "publish" && ((int)$doDL == 1)) ) echo 'checked="checked" title="def"'; ?> /> <?php } ?>
81
 
82
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/dl16.png);">Delicious - publish to (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
83
  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', 're-post') ?>" />
84
  <?php wp_nonce_field( 'rePostToDL', 'rePostToDL_wpnonce' ); } ?>
 
 
 
 
 
 
85
  </td></tr>
86
 
87
  <?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>
@@ -137,14 +156,17 @@ if (!function_exists("nxs_doPublishToDL")) { //## Second Function to Post to DL
137
  $extInfo = ' | PostID: '.$postID." - ".$post->post_title; $logNT = '<span style="color:#000080">Delicious</span> - '.$options['nName'];
138
 
139
  $t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = urlencode(implode(',',$tggs)); $tags = str_replace(' ','+',$tags);
140
- $apicall = "http://$dusername:$pass@$api/posts/add?&url=$link&description=$desc&extended=$ext&tags=$tags";
141
- $cnt = wp_remote_get( $apicall, '' );// prr($cnt);
 
 
142
 
143
  if(is_wp_error($cnt)) { $error_string = $cnt->get_error_message(); if (stripos($error_string, ' timed out')!==false) { sleep(10); $cnt = wp_remote_get( $apicall, '' );}}
144
  if(is_wp_error($cnt)) {
145
  $ret = 'Something went wrong - '."http://$dusername:*********@$api/posts/add?&url=$link&description=$desc&extended=$ext&tags=$tags"; nxs_addToLog($logNT, 'E', '-=ERROR=- '.$ret. "ERR: ".print_r($cnt, true), $extInfo);
146
  } else {
147
- if (is_array($cnt) && stripos($cnt['body'],'code="done"')!==false) { $ret = 'OK'; nxs_metaMarkAsPosted($postID, 'DL', $options['ii']); nxs_addToLog($logNT, 'M', 'OK - Message Posted ', $extInfo); }
 
148
  elseif (is_array($cnt) && stripos($cnt['body'],'item already exists')!==false) { $ret = '..All good, but this link has already been bookmarked..'; nxs_addToLog($logNT, 'M', 'All good, but this link has already been bookmarked', $extInfo); }
149
  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);
150
  }
29
  <div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/dl16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-delicious-social-networks-auto-poster-wordpress/">Detailed Delicious Installation/Configuration Instructions</a></div>
30
 
31
  <div style="width:100%;"><strong>Account Nickname:</strong> <i>Just so you can easely identify it</i> </div><input name="dl[<?php echo $ii; ?>][nName]" id="dlnName<?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")), 'NS_SNAutoPoster') ?>" /><br/>
32
+ <?php echo nxs_addQTranslSel('dl', $ii, $gpo['qTLng']); ?><?php echo nxs_addPostingDelaySel('dl', $ii, $gpo['nHrs'], $gpo['nMin']); ?>
33
+
34
+ <?php if (!$isNew) { ?>
35
+ <div style="width:100%;"><strong>Auto-Post Categories:</strong>
36
+ <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="dl[<?php echo $ii; ?>][catSel]" <?php if ((int)$gpo['catSel'] != 1) echo "checked"; ?> /> All
37
+ <input value="1" id="catSelSDL<?php echo $ii; ?>" type="radio" name="dl[<?php echo $ii; ?>][catSel]" <?php if ((int)$gpo['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_DL<?php echo $ii; ?>" onclick="jQuery('#catSelSDL<?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('DL<?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_DL<?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>
38
+ <input type="hidden" name="dl[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_DL<?php echo $ii; ?>" value="<?php echo $gpo['catSelEd']; ?>" />
39
+ </div>
40
+ <br/>
41
+ <?php } ?>
42
 
43
  <div style="width:100%;"><strong>Delicious Username:</strong> </div><input name="dl[<?php echo $ii; ?>][apDLUName]" id="apDLUName" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit',htmlentities($gpo['dlUName'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" />
44
  <div style="width:100%;"><strong>Delicious Password:</strong> </div><input name="dl[<?php echo $ii; ?>][apDLPass]" id="apDLPass" type="password" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities(substr($gpo['dlPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($gpo['dlPass'], 5)):$gpo['dlPass'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" /> <br/>
72
  if (isset($pval['apDLUName'])) $options[$ii]['dlUName'] = trim($pval['apDLUName']);
73
  if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']);
74
  if (isset($pval['apDLPass'])) $options[$ii]['dlPass'] = 'n5g9a'.nsx_doEncode($pval['apDLPass']); else $options[$ii]['dlPass'] = '';
75
+
76
+ if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']);
77
+ if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
78
+
79
  if (isset($pval['apDLMsgFrmt'])) $options[$ii]['dlMsgFormat'] = trim($pval['apDLMsgFrmt']);
80
  if (isset($pval['apDLMsgTFrmt'])) $options[$ii]['dlMsgTFormat'] = trim($pval['apDLMsgTFrmt']);
81
  if (isset($pval['apDoDL'])) $options[$ii]['doDL'] = $pval['apDoDL']; else $options[$ii]['doDL'] = 0;
86
  }
87
  //#### Show Post->Edit Meta Box Settings
88
  function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
89
+ foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapDL', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]); $doDL = $ntOpt['doDL'] && $ntOpt['catSel']!='1';
90
  $isAvailDL = $ntOpt['dlUName']!='' && $ntOpt['dlPass']!=''; $dlMsgFormat = htmlentities($ntOpt['dlMsgFormat'], ENT_COMPAT, "UTF-8"); $dlMsgTFormat = htmlentities($ntOpt['dlMsgTFormat'], ENT_COMPAT, "UTF-8");
91
  ?>
92
+ <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 } ?>
93
+ <?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; ?>][SNAPincludeDL]" <?php if (($post->post_status == "publish" && $ntOpt['isPosted'] == '1') || ($post->post_status != "publish" && ((int)$doDL == 1)) ) echo 'checked="checked" title="def"'; ?> /> <?php } ?>
94
 
95
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/dl16.png);">Delicious - publish to (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
96
  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', 're-post') ?>" />
97
  <?php wp_nonce_field( 'rePostToDL', 'rePostToDL_wpnonce' ); } ?>
98
+
99
+ <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
100
+ ?> <span id="pstdDL<?php echo $ii; ?>" style="float: right; padding-top: 4px; padding-right: 10px;">
101
+ <a style="font-size: 10px;" href="http://delicious.com/<?php echo $ntOpt['dlUName']; ?>" target="_blank">Posted on Delicious <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
102
+ </span><?php } ?>
103
+
104
  </td></tr>
105
 
106
  <?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>
156
  $extInfo = ' | PostID: '.$postID." - ".$post->post_title; $logNT = '<span style="color:#000080">Delicious</span> - '.$options['nName'];
157
 
158
  $t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = urlencode(implode(',',$tggs)); $tags = str_replace(' ','+',$tags);
159
+ $apicall = "http://$dusername:$pass@$api/posts/add?&url=$link&description=$desc&extended=$ext&tags=$tags"; // prr($apicall);
160
+ $cnt = wp_remote_get( $apicall, '' ); // prr($cnt);
161
+
162
+ // nxs_addToLog($logNT, 'E', '-=ER!!ROR=- '.$ret. "ERR: ".print_r($cnt, true), $extInfo);
163
 
164
  if(is_wp_error($cnt)) { $error_string = $cnt->get_error_message(); if (stripos($error_string, ' timed out')!==false) { sleep(10); $cnt = wp_remote_get( $apicall, '' );}}
165
  if(is_wp_error($cnt)) {
166
  $ret = 'Something went wrong - '."http://$dusername:*********@$api/posts/add?&url=$link&description=$desc&extended=$ext&tags=$tags"; nxs_addToLog($logNT, 'E', '-=ERROR=- '.$ret. "ERR: ".print_r($cnt, true), $extInfo);
167
  } else {
168
+ if (is_array($cnt) && stripos($cnt['body'],'code="done"')!==false)
169
+ { $ret = 'OK'; nxs_metaMarkAsPosted($postID, 'DL', $options['ii'], array('isPosted'=>'1', 'pgID'=>'DL', 'pDate'=>date('Y-m-d H:i:s'))); nxs_addToLog($logNT, 'M', 'OK - Message Posted ', $extInfo); }
170
  elseif (is_array($cnt) && stripos($cnt['body'],'item already exists')!==false) { $ret = '..All good, but this link has already been bookmarked..'; nxs_addToLog($logNT, 'M', 'All good, but this link has already been bookmarked', $extInfo); }
171
  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);
172
  }
inc-cl/fb.php CHANGED
@@ -5,15 +5,15 @@ $nxs_snapAvNts[] = array('code'=>'FB', 'lcode'=>'fb', 'name'=>'Facebook');
5
  if (!class_exists("nxs_snapClassFB")) { class nxs_snapClassFB {
6
  //#### Show Common Settings
7
  function showGenNTSettings($ntOpts){ global $nxs_snapThisPageUrl, $nxs_plurl; $code = 'FB'; $lcode = 'fb'; wp_nonce_field( 'ns'.$code, 'ns'.$code.'_wpnonce' );
8
- if ( isset($_GET['code']) && $_GET['code']!='' && ((!isset($_GET['action'])) || $_GET['action']!='gPlusAuth')){ $at = $_GET['code']; echo "-= This is normal technical authorization info that will dissapear (Unless you get some errors) =- <br/><br/><br/>-= Code:".$at;
9
  //$fbo = array('wfa'=> 1339160000); //foreach ($ntOpts as $two) { if (isset($two['wfa']) && $two['wfa']>$fbo['wfa']) $fbo = $two; }
10
  $fbo = $ntOpts[$_GET['acc']]; $wprg = array(); $response = wp_remote_get('https://graph.facebook.com/nextscripts', $wprg);
11
  if( is_wp_error( $response) && isset($response->errors['http_request_failed']) && stripos($response->errors['http_request_failed'][0], 'SSL')!==false ) { prr($response->errors); $wprg['sslverify'] = false; }
12
  if (isset($fbo['fbPgID'])){ echo "-="; prr($fbo);// die();
13
- $response = wp_remote_get('https://graph.facebook.com/oauth/access_token?client_id='.$fbo['fbAppID'].'&redirect_uri='.urlencode($nxs_snapThisPageUrl.'&acc='.$_GET['acc']).'&client_secret='.$fbo['fbAppSec'].'&code='.$at, $wprg);
14
  //prr('https://graph.facebook.com/oauth/access_token?client_id='.$fbo['fbAppID'].'&redirect_uri='.urlencode($nxs_snapThisPageUrl).'&client_secret='.$fbo['fbAppSec'].'&code='.$at);
15
  if ( (is_object($response) && (isset($response->errors))) || (is_array($response) && stripos($response['body'],'"error":')!==false )) { prr($response); die(); }
16
- parse_str($response['body'], $params); $at = $params['access_token']; // prr($response); prr($params);
17
  $response = wp_remote_get('https://graph.facebook.com/oauth/access_token?client_secret='.$fbo['fbAppSec'].'&client_id='.$fbo['fbAppID'].'&grant_type=fb_exchange_token&fb_exchange_token='.$at, $wprg);
18
  if ((is_object($response) && isset($response->errors))) { prr($response); die();}
19
  parse_str($response['body'], $params); $at = $params['access_token']; $fbo['fbAppAuthToken'] = $at;
@@ -24,16 +24,15 @@ if (!class_exists("nxs_snapClassFB")) { class nxs_snapClassFB {
24
  try { $page_id = $fbo['fbPgID']; echo "-= Authorizing Page =-";
25
  if ( !is_numeric($page_id) && stripos($fbo['fbURL'], '/groups/')!=false) { //$fbPgIDR = wp_remote_get('nxs.php?g='.$fbo['fbURL']); // TODO - how to replace
26
  $fbPgIDR = trim($fbPgIDR['body']); $page_id = $fbPgIDR!=''?$fbPgIDR:$page_id;
27
- } $page_info = $facebook->api("/$page_id?fields=access_token"); prr($page_info);
28
  if( !empty($page_info['access_token']) ) { $fbo['fbAppPageAuthToken'] = $page_info['access_token']; }
29
  } catch (NXS_FacebookApiException $e) { $errMsg = $e->getMessage(); prr($errMsg);
30
- if ( stripos($errMsg, 'Unknown fields: access_token')!==false) $fbo['fbAppPageAuthToken'] = $fbo['fbAppAuthToken']; else { echo 'Error:', $errMsg, "\n"; die(); }
31
  }
32
  } else echo "Can't get Facebook User. Please login to Facebook.";
33
 
34
- if ($user>0) { $fbo['fbAppAuthUser'] = $user; $options = get_option('NS_SNAutoPoster');
35
- foreach ($options['fb'] as $two) { if ($two['fbPgID']==$fbo['fbPgID']) $fbs[] = $fbo; else $fbs[] = $two; } $options['fb'] = $fbs; // prr($options); die();
36
- update_option('NS_SNAutoPoster', $options);
37
  ?><script type="text/javascript">window.location = "<?php echo $nxs_snapThisPageUrl; ?>"</script>
38
  <?php } die(); }
39
  } ?>
@@ -51,9 +50,10 @@ if (!class_exists("nxs_snapClassFB")) { class nxs_snapClassFB {
51
  } //## END FB Settings
52
  }
53
  //#### Show NEW Settings Page
54
- function showNewNTSettings($mfbo){ $fbo = array('nName'=>'', 'doFB'=>'1', 'fbURL'=>'', 'fbAppID'=>'','fbPostType'=>'A', 'fbMsgAFormat'=>'', 'fbAppSec'=>'', 'fbAttch'=>'1', 'fbPgID'=>'', 'fbAppAuthUser'=>'', 'fbMsgFormat'=>'New post has been published on %SITENAME%' ); $this->showNTSettings($mfbo, $fbo, true);}
55
  //#### Show Unit Settings
56
- function showNTSettings($ii, $fbo, $isNew=false){ global $nxs_plurl, $nxs_snapThisPageUrl; if ((int)$fbo['fbAttch']==0 && (!isset($fbo['trPostType']) || $fbo['trPostType']=='')) $fbo['trPostType'] = 'T'; ?>
 
57
  <div id="doFB<?php echo $ii; ?>Div" <?php if ($isNew){ ?>class="clNewNTSets"<?php } ?> style="max-width: 1000px; background-color: #EBF4FB; background-image: url(<?php echo $nxs_plurl; ?>img/fb-bg.png); background-position:90% 10%; background-repeat: no-repeat; margin: 10px; border: 1px solid #808080; padding: 10px; <?php if ((isset($fbo['fbAppAuthUser']) && $fbo['fbAppAuthUser']>1)||$isNew) { ?>display:none;<?php } ?>"> <input type="hidden" name="apDoSFB<?php echo $ii; ?>" value="0" id="apDoSFB<?php echo $ii; ?>" />
58
  <?php if ($isNew) { ?> <input type="hidden" name="fb[<?php echo $ii; ?>][apDoFB]" value="1" id="apDoNewFB<?php echo $ii; ?>" /> <?php } ?>
59
 
@@ -66,6 +66,15 @@ if (!class_exists("nxs_snapClassFB")) { class nxs_snapClassFB {
66
  <?php echo nxs_addQTranslSel('fb', $ii, $fbo['qTLng']); ?>
67
  <?php echo nxs_addPostingDelaySel('fb', $ii, $fbo['nHrs'], $fbo['nMin']); ?>
68
 
 
 
 
 
 
 
 
 
 
69
  <div style="width:100%;"><strong>Your Facebook URL:</strong> </div>
70
  <p style="font-size: 11px; margin: 0px;">Could be your Facebook Profile, Facebook Page, Facebook Group</p>
71
  <input name="fb[<?php echo $ii; ?>][apFBURL]" id="apFBURL" style="width: 50%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($fbo['fbURL'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" />
@@ -73,15 +82,21 @@ if (!class_exists("nxs_snapClassFB")) { class nxs_snapClassFB {
73
  <div style="width:100%;"><strong>Your Facebook App Secret:</strong> </div><input name="fb[<?php echo $ii; ?>][apFBAppSec]" id="apFBAppSec" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($fbo['fbAppSec'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" /><br/><br/>
74
  <div id="altFormat">
75
  <div style="width:100%;"><strong id="altFormatText">Message text Format:</strong> (<a href="#" id="apFBMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apFBMsgFrmt<?php echo $ii; ?>'); return false;">Show format info</a>)</div>
 
76
  <input name="fb[<?php echo $ii; ?>][apFBMsgFrmt]" id="apFBMsgFrmt" style="width: 50%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($fbo['fbMsgFormat'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" onfocus="mxs_showFrmtInfo('apFBMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apFBMsgFrmt".$ii); ?><br/>
77
  </div><br/>
78
-
79
-
80
  <div style="width:100%;"><strong id="altFormatText">Post Type:</strong>&lt;-- (<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/">What's the difference?</a>) </div>
81
  <div style="margin-left: 10px;">
82
 
83
  <input type="radio" name="fb[<?php echo $ii; ?>][fbPostType]" value="T" <?php if ($fbo['fbPostType'] == 'T') echo 'checked="checked"'; ?> /> Text Post - <i>just text message</i><br/>
 
84
  <input type="radio" name="fb[<?php echo $ii; ?>][fbPostType]" value="I" <?php if ($fbo['fbPostType'] == 'I') echo 'checked="checked"'; ?> /> Image Post - <i>big image with text message</i><br/>
 
 
 
 
 
 
85
  <input type="radio" name="fb[<?php echo $ii; ?>][fbPostType]" value="A" <?php if ( !isset($fbo['fbPostType']) || $fbo['fbPostType'] == '' || $fbo['fbPostType'] == 'A') echo 'checked="checked"'; ?> /> Text Post with "attached" link<br/>
86
 
87
  <div style="width:100%; margin-left: 15px;"><strong>Link attachment type:&nbsp;</strong> <input value="2" id="apFBAttchShare<?php echo $ii; ?>" type="radio" name="fb[<?php echo $ii; ?>][apFBAttch]" <?php if ((int)$fbo['fbAttch'] == 2) echo "checked"; ?> />
@@ -99,8 +114,9 @@ if (!class_exists("nxs_snapClassFB")) { class nxs_snapClassFB {
99
  </div><br/>
100
  </div><br/>
101
 
102
- <div class="popShAtt" id="popShAtt<?php echo $ii; ?>"><h3>Two ways of attaching post on Facebook</h3><img src="<?php echo $nxs_plurl; ?>img/fb2wops.jpg" width="600" height="271" alt="Two ways of attaching post on Facebook"/></div>
103
- <div class="popShAtt" id="popShAtt<?php echo $ii; ?>X"><h3>Facebook Post Types</h3><img src="<?php echo $nxs_plurl; ?>img/fbPostTypesDiff6.png" width="600" height="398" alt="Facebook Post Types"/></div>
 
104
 
105
 
106
  <?php if ($fbo['fbPgID']!='') {?><div style="width:100%;"><strong>Your Facebook Page ID:</strong> <?php _e(apply_filters('format_to_edit', htmlentities($fbo['fbPgID'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?> </div><?php } ?>
@@ -110,7 +126,7 @@ if (!class_exists("nxs_snapClassFB")) { class nxs_snapClassFB {
110
  <?php } else { if(isset($fbo['fbAppAuthUser']) && $fbo['fbAppAuthUser']>0) { ?>
111
  Your Facebook Account has been authorized. User ID: <?php _e(apply_filters('format_to_edit', htmlentities($fbo['fbAppAuthUser'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>.
112
  You can Re- <?php } ?>
113
- <a href="https://www.facebook.com/dialog/oauth?client_id=<?php echo $fbo['fbAppID'];?>&client_secret='<?php echo $fbo['fbAppSec'];?>&scope=publish_stream,offline_access,read_stream,manage_pages&redirect_uri=<?php echo urlencode($nxs_snapThisPageUrl.'&acc='.$fbo['ii']);?>">Authorize Your Facebook Account</a>
114
  <?php if (!isset($fbo['fbAppAuthUser']) || $fbo['fbAppAuthUser']<1) { ?> <div class="blnkg">&lt;=== Authorize your account ===</div> <?php } ?>
115
 
116
  <?php if (!isset($fbo['fbAppAuthUser']) || $fbo['fbAppAuthUser']<1) { ?>
@@ -136,9 +152,15 @@ if (!class_exists("nxs_snapClassFB")) { class nxs_snapClassFB {
136
  if (isset($pval['apFBAppID'])) $options[$ii]['fbAppID'] = trim($pval['apFBAppID']);
137
  if (isset($pval['apFBAppSec'])) $options[$ii]['fbAppSec'] = trim($pval['apFBAppSec']);
138
 
139
- if (isset($pval['fbPostType'])) $options[$ii]['fbPostType'] = trim($pval['fbPostType']);
140
- if (isset($pval['apFBAttch'])) $options[$ii]['fbAttch'] = $pval['apFBAttch']; else $options[$ii]['fbAttch'] = 0;
 
 
 
141
  if (isset($pval['apFBAttchAsVid'])) $options[$ii]['fbAttchAsVid'] = $pval['apFBAttchAsVid']; else $options[$ii]['fbAttchAsVid'] = 0;
 
 
 
142
  if (isset($pval['apFBMsgFrmt'])) $options[$ii]['fbMsgFormat'] = trim($pval['apFBMsgFrmt']);
143
  if (isset($pval['apFBMsgAFrmt'])) $options[$ii]['fbMsgAFrmt'] = trim($pval['apFBMsgAFrmt']);
144
 
@@ -156,17 +178,24 @@ if (!class_exists("nxs_snapClassFB")) { class nxs_snapClassFB {
156
  }
157
  //#### Show Post->Edit Meta Box Settings
158
  function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
159
- foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapFB', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]); $doFB = $ntOpt['doFB'];
160
- $isAvailFB = $ntOpt['fbURL']!='' && $ntOpt['fbAppID']!='' && $ntOpt['fbAppSec']!=''; $isAttachFB = $ntOpt['fbAttch']; $fbMsgFormat = htmlentities($ntOpt['fbMsgFormat'], ENT_COMPAT, "UTF-8"); $fbPostType = $ntOpt['fbPostType'];
161
  ?>
162
 
163
- <tr><th style="text-align:left;" colspan="2">
164
 
165
- <?php if ($isAvailFB) { ?><input class="nxsGrpDoChb" value="1" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="fb[<?php echo $ii; ?>][SNAPincludeFB]" <?php if (($post->post_status == "publish" && $ntOpt['isPosted'] == '1') || ($post->post_status != "publish" && ((int)$doFB == 1)) ) echo 'checked="checked" title="def"'; ?> /> <?php } ?>
166
 
167
  <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 ', 'NS_SPAP'); ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th><td><?php //## Only show RePost button if the post is "published"
168
  if ($post->post_status == "publish" && $isAvailFB) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToFB_repostButton" id="rePostToFB_button" value="<?php _e('Repost to Facebook', 're-post') ?>" />
169
  <?php wp_nonce_field( 'rePostToFB', 'rePostToFB_wpnonce' ); } ?>
 
 
 
 
 
 
 
170
  </td></tr>
171
  <?php if (!$isAvailFB) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup and Authorize your Facebook Account to AutoPost to Facebook</b>
172
  <?php } elseif ($post->post_status != "puZblish") {?>
@@ -237,7 +266,8 @@ if (!function_exists("nxs_doPublishToFB")) { //## Second Function to Post to FB
237
  } else { $post = get_post($postID); if(!$post) return; $fbMsgFormat = $options['fbMsgFormat']; $msg = nsFormatMessage($fbMsgFormat, $postID); $fbMsgAFormat = $options['fbMsgAFrmt'];
238
  $isAttachFB = $options['fbAttch']; $fbPostType = $options['fbPostType']; $isAttachVidFB = $options['fbAttchAsVid'];
239
  nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
240
- if (($isAttachFB=='1' || $isAttachFB=='2' || $fbPostType=='A' || $fbPostType=='I')) $imgURL = nxs_getPostImage($postID); // prr($options); echo "PP - ".$postID; prr($src);
 
241
 
242
  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));
243
  if (function_exists('wpseo_admin_init') && $dsc=='') $dsc = trim(get_post_meta($postID, '_yoast_wpseo_opengraph-description', true));
@@ -249,32 +279,50 @@ if (!function_exists("nxs_doPublishToFB")) { //## Second Function to Post to FB
249
 
250
  $dsc = strip_tags($dsc); $dsc = nxs_decodeEntitiesFull($dsc); $dsc = nsTrnc($dsc, 900, ' ');
251
  $postSubtitle = home_url(); $msg = str_replace('<br>', "\n", $msg); $msg = str_replace('<br/>', "\n", $msg); $msg = str_replace('<br />', "\n", $msg);
252
- $msg = strip_tags($msg); $msg = nxs_decodeEntitiesFull($msg); $mssg = array('access_token' => $options['fbAppPageAuthToken'], 'message' => $msg);
253
  if ($fbPostType=='I' && trim($imgURL)=='') $fbPostType='T';
254
  if ($fbPostType=='A' || $fbPostType=='') {
255
  if (($isAttachFB=='1' || $isAttachFB=='2')) { $attArr = array('name' => nxs_doQTrans($post->post_title, $lng), 'caption' => $postSubtitle, 'link' => get_permalink($postID), 'description' => $dsc); $mssg = array_merge($mssg, $attArr); }
256
  if ($isAttachFB=='1') $mssg['actions'] = array(array('name' => $blogTitle, 'link' => home_url()));
257
  if (trim($imgURL)!='') $mssg['picture'] = $imgURL;
258
- if ($isAttachVidFB=='1') {$vids = nsFindVidsInPost($post); if (count($vids)>0) { $mssg['source'] = 'http://www.youtube.com/v/'.$vids[0]; $mssg['picture'] = 'http://img.youtube.com/vi/'.$vids[0].'/0.jpg'; }}
259
- } elseif ($fbPostType=='I') { $facebook->setFileUploadSupport(true); $fbWhere = 'photos'; $mssg['url'] = $imgURL; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
260
  } // prr($mssg); // prr($options); // prr($facebook); echo "/$page_id/feed";
261
  if (isset($ShownAds)) $ShownAds = $ShownAdsL; // FIX for the quick-adsense plugin
262
- $extInfo = ' | PostID: '.$postID." - ".nxs_doQTrans($post->post_title, $lng); $logNT = '<span style="color:#0000FF">Facebook</span> - '.$options['nName']; //prr($mssg);
263
-
264
- try { $ret = $facebook->api("/$page_id/".$fbWhere,"post", $mssg);} catch (NXS_FacebookApiException $e) { nxs_addToLog($logNT, 'E', '-=ERROR=- '.$e->getMessage(), $extInfo);
265
  if (stripos($e->getMessage(),'This API call requires a valid app_id')!==false) { $page_id = $options['fbPgID'];
266
- if ( !is_numeric($page_id) && stripos($options['fbURL'], '/groups/')!=false) { $fbPgIDR = wp_remote_get('http://www.nextscripts.com/nxs.php?g='.$fbo['fbURL']);
267
  $fbPgIDR = trim($fbPgIDR['body']); $page_id = $fbPgIDR!=''?$fbPgIDR:$page_id;
268
- } $page_info = $facebook->api("/$page_id?fields=access_token");
269
  if( !empty($page_info['access_token']) ) { $options['fbAppPageAuthToken'] = $page_info['access_token'];
270
- nxs_addToLog($logNT, 'M', 'Personal Auth used instead of Page. Please re-authorize Facebook.'); $ret = $facebook->api("/$page_id/".$fbWhere,"post", $mssg);
271
- } else { nxs_addToLog($logNT, 'E', '-=ERROR=- '.$e->getMessage(), $extInfo); return "ERROR:".$e->getMessage();}
 
 
 
272
  }
273
- if ($postID=='0') echo 'Error:', $e->getMessage(), "\n"; return "ERROR:".$e->getMessage();
274
- }
275
  if ($postID=='0') { prr($ret); if (isset($ret['id']) && $ret['id']!='') { echo 'OK - Message Posted, please see your Facebook Page '; nxs_addToLog($logNT, 'M', 'Test Message Posted, please see your Facebook Page'); }}
276
- else { if (isset($ret['id']) && $ret['id']!='') { nxs_metaMarkAsPosted($postID, 'FB', $options['ii'], array('isPosted'=>'1', 'pgID'=>$ret['id']) ); nxs_addToLog($logNT, 'M', 'OK - Message Posted'.print_r($ret, true), $extInfo); }
277
- else nxs_addToLog($logNT, 'E', '-=ERROR=- '.print_r($ret, true), $extInfo);
 
278
  }
279
  }
280
  }
5
  if (!class_exists("nxs_snapClassFB")) { class nxs_snapClassFB {
6
  //#### Show Common Settings
7
  function showGenNTSettings($ntOpts){ global $nxs_snapThisPageUrl, $nxs_plurl; $code = 'FB'; $lcode = 'fb'; wp_nonce_field( 'ns'.$code, 'ns'.$code.'_wpnonce' );
8
+ if ( isset($_GET['code']) && $_GET['code']!='' && (isset($_GET['auth']) && $_GET['auth']=='fb') && ((!isset($_GET['action'])) || $_GET['action']!='gPlusAuth')){ $at = $_GET['code']; echo "-= This is normal technical authorization info that will dissapear (Unless you get some errors) =- <br/><br/><br/>-= Code:".$at;
9
  //$fbo = array('wfa'=> 1339160000); //foreach ($ntOpts as $two) { if (isset($two['wfa']) && $two['wfa']>$fbo['wfa']) $fbo = $two; }
10
  $fbo = $ntOpts[$_GET['acc']]; $wprg = array(); $response = wp_remote_get('https://graph.facebook.com/nextscripts', $wprg);
11
  if( is_wp_error( $response) && isset($response->errors['http_request_failed']) && stripos($response->errors['http_request_failed'][0], 'SSL')!==false ) { prr($response->errors); $wprg['sslverify'] = false; }
12
  if (isset($fbo['fbPgID'])){ echo "-="; prr($fbo);// die();
13
+ $response = wp_remote_get('https://graph.facebook.com/oauth/access_token?client_id='.$fbo['fbAppID'].'&redirect_uri='.urlencode($nxs_snapThisPageUrl.'&auth=fb&acc='.$_GET['acc']).'&client_secret='.$fbo['fbAppSec'].'&code='.$at, $wprg);
14
  //prr('https://graph.facebook.com/oauth/access_token?client_id='.$fbo['fbAppID'].'&redirect_uri='.urlencode($nxs_snapThisPageUrl).'&client_secret='.$fbo['fbAppSec'].'&code='.$at);
15
  if ( (is_object($response) && (isset($response->errors))) || (is_array($response) && stripos($response['body'],'"error":')!==false )) { prr($response); die(); }
16
+ parse_str($response['body'], $params); $at = $params['access_token']; prr($response); prr($params);
17
  $response = wp_remote_get('https://graph.facebook.com/oauth/access_token?client_secret='.$fbo['fbAppSec'].'&client_id='.$fbo['fbAppID'].'&grant_type=fb_exchange_token&fb_exchange_token='.$at, $wprg);
18
  if ((is_object($response) && isset($response->errors))) { prr($response); die();}
19
  parse_str($response['body'], $params); $at = $params['access_token']; $fbo['fbAppAuthToken'] = $at;
24
  try { $page_id = $fbo['fbPgID']; echo "-= Authorizing Page =-";
25
  if ( !is_numeric($page_id) && stripos($fbo['fbURL'], '/groups/')!=false) { //$fbPgIDR = wp_remote_get('nxs.php?g='.$fbo['fbURL']); // TODO - how to replace
26
  $fbPgIDR = trim($fbPgIDR['body']); $page_id = $fbPgIDR!=''?$fbPgIDR:$page_id;
27
+ } $page_info = $facebook->api("/$page_id?fields=access_token");
28
  if( !empty($page_info['access_token']) ) { $fbo['fbAppPageAuthToken'] = $page_info['access_token']; }
29
  } catch (NXS_FacebookApiException $e) { $errMsg = $e->getMessage(); prr($errMsg);
30
+ if ( stripos($errMsg, 'Unknown fields: access_token')!==false) { $fbo['fbAppPageAuthToken'] = $fbo['fbAppAuthToken']; } else { echo 'Error:', $errMsg, "\n"; die(); }
31
  }
32
  } else echo "Can't get Facebook User. Please login to Facebook.";
33
 
34
+ if ($user>0) { $fbo['fbAppAuthUser'] = $user;
35
+ $optionsG = get_option('NS_SNAutoPoster'); $optionsG['fb'][$_GET['acc']] = $fbo; update_option('NS_SNAutoPoster', $optionsG);
 
36
  ?><script type="text/javascript">window.location = "<?php echo $nxs_snapThisPageUrl; ?>"</script>
37
  <?php } die(); }
38
  } ?>
50
  } //## END FB Settings
51
  }
52
  //#### Show NEW Settings Page
53
+ 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);}
54
  //#### Show Unit Settings
55
+ function showNTSettings($ii, $fbo, $isNew=false){ global $nxs_plurl, $nxs_snapThisPageUrl; if ((int)$fbo['fbAttch']==0 && (!isset($fbo['trPostType']) || $fbo['trPostType']=='')) $fbo['trPostType'] = 'T';
56
+ if (!isset($fbo['nHrs'])) $fbo['nHrs'] = 0; if (!isset($fbo['nMin'])) $fbo['nMin'] = 0; if (!isset($fbo['catSel'])) $fbo['catSel'] = 0; if (!isset($fbo['catSelEd'])) $fbo['catSelEd'] = ''; ?>
57
  <div id="doFB<?php echo $ii; ?>Div" <?php if ($isNew){ ?>class="clNewNTSets"<?php } ?> style="max-width: 1000px; background-color: #EBF4FB; background-image: url(<?php echo $nxs_plurl; ?>img/fb-bg.png); background-position:90% 10%; background-repeat: no-repeat; margin: 10px; border: 1px solid #808080; padding: 10px; <?php if ((isset($fbo['fbAppAuthUser']) && $fbo['fbAppAuthUser']>1)||$isNew) { ?>display:none;<?php } ?>"> <input type="hidden" name="apDoSFB<?php echo $ii; ?>" value="0" id="apDoSFB<?php echo $ii; ?>" />
58
  <?php if ($isNew) { ?> <input type="hidden" name="fb[<?php echo $ii; ?>][apDoFB]" value="1" id="apDoNewFB<?php echo $ii; ?>" /> <?php } ?>
59
 
66
  <?php echo nxs_addQTranslSel('fb', $ii, $fbo['qTLng']); ?>
67
  <?php echo nxs_addPostingDelaySel('fb', $ii, $fbo['nHrs'], $fbo['nMin']); ?>
68
 
69
+ <?php if (!$isNew) { ?>
70
+ <div style="width:100%;"><strong>Auto-Post Categories:</strong>
71
+ <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="fb[<?php echo $ii; ?>][catSel]" <?php if ((int)$fbo['catSel'] != 1) echo "checked"; ?> /> All
72
+ <input value="1" id="catSelSFB<?php echo $ii; ?>" type="radio" name="fb[<?php echo $ii; ?>][catSel]" <?php if ((int)$fbo['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_FB<?php echo $ii; ?>" onclick="jQuery('#catSelSFB<?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('FB<?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_FB<?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 ($fbo['catSelEd']!='') echo "[".(substr_count($fbo['catSelEd'], ",")+1)."]"; ?></a>
73
+ <input type="hidden" name="fb[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_FB<?php echo $ii; ?>" value="<?php echo $fbo['catSelEd']; ?>" />
74
+ </div>
75
+ <br/>
76
+ <?php } ?>
77
+
78
  <div style="width:100%;"><strong>Your Facebook URL:</strong> </div>
79
  <p style="font-size: 11px; margin: 0px;">Could be your Facebook Profile, Facebook Page, Facebook Group</p>
80
  <input name="fb[<?php echo $ii; ?>][apFBURL]" id="apFBURL" style="width: 50%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($fbo['fbURL'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" />
82
  <div style="width:100%;"><strong>Your Facebook App Secret:</strong> </div><input name="fb[<?php echo $ii; ?>][apFBAppSec]" id="apFBAppSec" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($fbo['fbAppSec'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" /><br/><br/>
83
  <div id="altFormat">
84
  <div style="width:100%;"><strong id="altFormatText">Message text Format:</strong> (<a href="#" id="apFBMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apFBMsgFrmt<?php echo $ii; ?>'); return false;">Show format info</a>)</div>
85
+
86
  <input name="fb[<?php echo $ii; ?>][apFBMsgFrmt]" id="apFBMsgFrmt" style="width: 50%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($fbo['fbMsgFormat'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" onfocus="mxs_showFrmtInfo('apFBMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apFBMsgFrmt".$ii); ?><br/>
87
  </div><br/>
 
 
88
  <div style="width:100%;"><strong id="altFormatText">Post Type:</strong>&lt;-- (<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/">What's the difference?</a>) </div>
89
  <div style="margin-left: 10px;">
90
 
91
  <input type="radio" name="fb[<?php echo $ii; ?>][fbPostType]" value="T" <?php if ($fbo['fbPostType'] == 'T') echo 'checked="checked"'; ?> /> Text Post - <i>just text message</i><br/>
92
+
93
  <input type="radio" name="fb[<?php echo $ii; ?>][fbPostType]" value="I" <?php if ($fbo['fbPostType'] == 'I') echo 'checked="checked"'; ?> /> Image Post - <i>big image with text message</i><br/>
94
+ <div style="width:100%; margin-left: 15px;"><strong>Upload Images to:&nbsp;</strong>
95
+ <input value="2" id="apFBImgUplAPP<?php echo $ii; ?>" type="radio" name="fb[<?php echo $ii; ?>][apFBImgUpl]" <?php if ((int)$fbo['imgUpl'] == 2) echo "checked"; ?> /> App Album .. or ..
96
+ <input value="1" id="apFBImgUplTML<?php echo $ii; ?>" type="radio" name="fb[<?php echo $ii; ?>][apFBImgUpl]" <?php if ((int)$fbo['imgUpl'] != 2) echo "checked"; ?> />
97
+ Timeline &lt;-- (<a id="showShAtt" onmouseout="hidePopShAtt('<?php echo $ii; ?>I');" onmouseover="showPopShAtt('<?php echo $ii; ?>I', event);" onclick="return false;" class="underdash" href="http://www.nextscripts.com/blog/">What's the difference?</a>)
98
+ </div>
99
+
100
  <input type="radio" name="fb[<?php echo $ii; ?>][fbPostType]" value="A" <?php if ( !isset($fbo['fbPostType']) || $fbo['fbPostType'] == '' || $fbo['fbPostType'] == 'A') echo 'checked="checked"'; ?> /> Text Post with "attached" link<br/>
101
 
102
  <div style="width:100%; margin-left: 15px;"><strong>Link attachment type:&nbsp;</strong> <input value="2" id="apFBAttchShare<?php echo $ii; ?>" type="radio" name="fb[<?php echo $ii; ?>][apFBAttch]" <?php if ((int)$fbo['fbAttch'] == 2) echo "checked"; ?> />
114
  </div><br/>
115
  </div><br/>
116
 
117
+ <div class="popShAtt" style="z-index: 9999; width: 350px;" id="popShAtt<?php echo $ii; ?>I"><h3>Where to upload Images</h3> <b>(App Album)</b> Facebook automatically creates an album for your app. Images will be grouped there as in any regular album. <br/><br/><b>(Timeline)</b> Images will be posted to the special "Wall/Timeline" album and won't be grouped. "Wall/Timeline" album must exist. It's created when first image posted to timeline manually.</div>
118
+ <div class="popShAtt" style="z-index: 9999" id="popShAtt<?php echo $ii; ?>"><h3>Two ways of attaching post on Facebook</h3><img src="<?php echo $nxs_plurl; ?>img/fb2wops.jpg" width="600" height="271" alt="Two ways of attaching post on Facebook"/></div>
119
+ <div class="popShAtt" style="z-index: 9999" id="popShAtt<?php echo $ii; ?>X"><h3>Facebook Post Types</h3><img src="<?php echo $nxs_plurl; ?>img/fbPostTypesDiff6.png" width="600" height="398" alt="Facebook Post Types"/></div>
120
 
121
 
122
  <?php if ($fbo['fbPgID']!='') {?><div style="width:100%;"><strong>Your Facebook Page ID:</strong> <?php _e(apply_filters('format_to_edit', htmlentities($fbo['fbPgID'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?> </div><?php } ?>
126
  <?php } else { if(isset($fbo['fbAppAuthUser']) && $fbo['fbAppAuthUser']>0) { ?>
127
  Your Facebook Account has been authorized. User ID: <?php _e(apply_filters('format_to_edit', htmlentities($fbo['fbAppAuthUser'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>.
128
  You can Re- <?php } ?>
129
+ <a href="https://www.facebook.com/dialog/oauth?client_id=<?php echo $fbo['fbAppID'];?>&client_secret='<?php echo $fbo['fbAppSec'];?>&scope=publish_stream,user_photos,offline_access,read_stream,manage_pages&redirect_uri=<?php echo urlencode($nxs_snapThisPageUrl.'&auth=fb&acc='.$fbo['ii']);?>">Authorize Your Facebook Account</a>
130
  <?php if (!isset($fbo['fbAppAuthUser']) || $fbo['fbAppAuthUser']<1) { ?> <div class="blnkg">&lt;=== Authorize your account ===</div> <?php } ?>
131
 
132
  <?php if (!isset($fbo['fbAppAuthUser']) || $fbo['fbAppAuthUser']<1) { ?>
152
  if (isset($pval['apFBAppID'])) $options[$ii]['fbAppID'] = trim($pval['apFBAppID']);
153
  if (isset($pval['apFBAppSec'])) $options[$ii]['fbAppSec'] = trim($pval['apFBAppSec']);
154
 
155
+ if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']);
156
+ if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
157
+
158
+ if (isset($pval['fbPostType'])) $options[$ii]['fbPostType'] = trim($pval['fbPostType']);
159
+ if (isset($pval['apFBAttch'])) $options[$ii]['fbAttch'] = $pval['apFBAttch']; else $options[$ii]['fbAttch'] = 0;
160
  if (isset($pval['apFBAttchAsVid'])) $options[$ii]['fbAttchAsVid'] = $pval['apFBAttchAsVid']; else $options[$ii]['fbAttchAsVid'] = 0;
161
+
162
+ if (isset($pval['apFBImgUpl'])) $options[$ii]['imgUpl'] = $pval['apFBImgUpl']; else $options[$ii]['imgUpl'] = 0;
163
+
164
  if (isset($pval['apFBMsgFrmt'])) $options[$ii]['fbMsgFormat'] = trim($pval['apFBMsgFrmt']);
165
  if (isset($pval['apFBMsgAFrmt'])) $options[$ii]['fbMsgAFrmt'] = trim($pval['apFBMsgAFrmt']);
166
 
178
  }
179
  //#### Show Post->Edit Meta Box Settings
180
  function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
181
+ foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapFB', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]); $doFB = $ntOpt['doFB'] && $ntOpt['catSel']!='1';
182
+ $isAvailFB = $ntOpt['fbURL']!='' && $ntOpt['fbAppID']!='' && $ntOpt['fbAppSec']!=''; $isAttachFB = $ntOpt['fbAttch']; $fbMsgFormat = htmlentities($ntOpt['fbMsgFormat'], ENT_COMPAT, "UTF-8"); $fbPostType = $ntOpt['fbPostType'];
183
  ?>
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_FB<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
186
 
187
+ <?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; ?>][SNAPincludeFB]" <?php if (($post->post_status == "publish" && $ntOpt['isPosted'] == '1') || ($post->post_status != "publish" && ((int)$doFB == 1)) ) echo 'checked="checked" title="def"'; ?> /> <?php } ?>
188
 
189
  <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 ', 'NS_SPAP'); ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th><td><?php //## Only show RePost button if the post is "published"
190
  if ($post->post_status == "publish" && $isAvailFB) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToFB_repostButton" id="rePostToFB_button" value="<?php _e('Repost to Facebook', 're-post') ?>" />
191
  <?php wp_nonce_field( 'rePostToFB', 'rePostToFB_wpnonce' ); } ?>
192
+
193
+ <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) && strpos($pMeta[$ii]['pgID'],'_')!==false ) { $pid = explode('_', $pMeta[$ii]['pgID']);
194
+
195
+ ?> <span id="pstdFB<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
196
+ <a style="font-size: 10px;" href="http://www.facebook.com/permalink.php?story_fbid=<?php echo $pid[1].'&id='.$pid[0]; ?>" target="_blank">Posted on Facebook <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
197
+ </span><?php } ?>
198
+
199
  </td></tr>
200
  <?php if (!$isAvailFB) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup and Authorize your Facebook Account to AutoPost to Facebook</b>
201
  <?php } elseif ($post->post_status != "puZblish") {?>
266
  } else { $post = get_post($postID); if(!$post) return; $fbMsgFormat = $options['fbMsgFormat']; $msg = nsFormatMessage($fbMsgFormat, $postID); $fbMsgAFormat = $options['fbMsgAFrmt'];
267
  $isAttachFB = $options['fbAttch']; $fbPostType = $options['fbPostType']; $isAttachVidFB = $options['fbAttchAsVid'];
268
  nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
269
+ if (($isAttachFB=='1' || $isAttachFB=='2' || $fbPostType=='A')) $imgURL = nxs_getPostImage($postID); // prr($options); echo "PP - ".$postID; prr($src);
270
+ if ($fbPostType=='I') $imgURL = nxs_getPostImage($postID, 'full'); // prr($options); echo "PP - ".$postID; prr($src);
271
 
272
  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));
273
  if (function_exists('wpseo_admin_init') && $dsc=='') $dsc = trim(get_post_meta($postID, '_yoast_wpseo_opengraph-description', true));
279
 
280
  $dsc = strip_tags($dsc); $dsc = nxs_decodeEntitiesFull($dsc); $dsc = nsTrnc($dsc, 900, ' ');
281
  $postSubtitle = home_url(); $msg = str_replace('<br>', "\n", $msg); $msg = str_replace('<br/>', "\n", $msg); $msg = str_replace('<br />', "\n", $msg);
282
+ $msg = strip_tags($msg); $msg = nxs_decodeEntitiesFull($msg); $mssg = array('access_token' => $options['fbAppPageAuthToken'], 'message' => $msg); //prr($imgURL);
283
  if ($fbPostType=='I' && trim($imgURL)=='') $fbPostType='T';
284
  if ($fbPostType=='A' || $fbPostType=='') {
285
  if (($isAttachFB=='1' || $isAttachFB=='2')) { $attArr = array('name' => nxs_doQTrans($post->post_title, $lng), 'caption' => $postSubtitle, 'link' => get_permalink($postID), 'description' => $dsc); $mssg = array_merge($mssg, $attArr); }
286
  if ($isAttachFB=='1') $mssg['actions'] = array(array('name' => $blogTitle, 'link' => home_url()));
287
  if (trim($imgURL)!='') $mssg['picture'] = $imgURL;
288
+ if ($isAttachVidFB=='1') {$vids = nsFindVidsInPost($post); if (count($vids)>0) {
289
+ 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'; }
290
+ if (strlen($vids[0])==8) { $mssg['source'] = 'https://secure.vimeo.com/moogaloop.swf?clip_id='.$vids[0].'&autoplay=1';
291
+ //$mssg['source'] = 'http://player.vimeo.com/video/'.$vids[0];
292
+ $apiURL = "http://vimeo.com/api/v2/video/".$vids[0].".json?callback=showThumb"; $json = wp_remote_get($apiURL);
293
+ if (!is_wp_error($json)) { $json = $json['body']; $json = str_replace('showThumb(','',$json); $json = str_replace('])',']',$json); $json = json_decode($json, true); $mssg['picture'] = $json[0]['thumbnail_large']; }
294
+ }
295
+ }}
296
+ } elseif ($fbPostType=='I') { $facebook->setFileUploadSupport(true); $fbWhere = 'photos'; $mssg['url'] = $imgURL;
297
+ if ($options['imgUpl']!='2') {
298
+ $aacct = array('access_token' => $options['fbAppPageAuthToken']); $albums = $facebook->api("/$page_id/albums", "get", $aacct);
299
+ foreach ($albums["data"] as $album) { if ($album["type"] == "wall") { $chosen_album = $album; break;}}
300
+ if (isset($chosen_album) && isset($chosen_album["id"])) $page_id = $chosen_album["id"];
301
+ }
302
+
303
+ }
304
  } // prr($mssg); // prr($options); // prr($facebook); echo "/$page_id/feed";
305
  if (isset($ShownAds)) $ShownAds = $ShownAdsL; // FIX for the quick-adsense plugin
306
+ $extInfo = ' | PostID: '.$postID." - ".nxs_doQTrans($post->post_title, $lng); $logNT = '<span style="color:#0000FF">Facebook</span> - '.$options['nName']; // prr($mssg);
307
+
308
+ try { $ret = $facebook->api("/$page_id/".$fbWhere, "post", $mssg);} catch (NXS_FacebookApiException $e) { nxs_addToLog($logNT, 'E', '-=ERROR=- '.$e->getMessage(), $extInfo);
309
  if (stripos($e->getMessage(),'This API call requires a valid app_id')!==false) { $page_id = $options['fbPgID'];
310
+ if ( !is_numeric($page_id) && stripos($options['fbURL'], '/groups/')!=false) { $fbPgIDR = wp_remote_get('http://www.nextscripts.com/nxs.php?g='.$options['fbURL']);
311
  $fbPgIDR = trim($fbPgIDR['body']); $page_id = $fbPgIDR!=''?$fbPgIDR:$page_id;
312
+ } try { $page_info = $facebook->api("/$page_id?fields=access_token"); } catch (NXS_FacebookApiException $er2) { }
313
  if( !empty($page_info['access_token']) ) { $options['fbAppPageAuthToken'] = $page_info['access_token'];
314
+ nxs_addToLog($logNT, 'M', 'Personal Auth used instead of Page. Please re-authorize Facebook.');
315
+ try { $ret = $facebook->api("/$page_id/".$fbWhere,"post", $mssg); } catch (NXS_FacebookApiException $e) { nxs_addToLog($logNT, 'E', '-=ERROR 2=- '.$e->getMessage(), $extInfo);}
316
+ } else { $rMsg = '-= ERROR =- (invalid app_id) Authorization Error. Your app is not authorized. Please go to the Plugin Settings - Facebook and authorize it.<br/>';
317
+ nxs_addToLog($logNT, 'E', $rMsg, $extInfo); return $rMsg.$e->getMessage();
318
+ }
319
  }
320
+ if ($postID=='0') echo 'Error:', $e->getMessage(), "\n"; return "Valid app_id ERROR:".$e->getMessage();
321
+ } // prr($ret);
322
  if ($postID=='0') { prr($ret); if (isset($ret['id']) && $ret['id']!='') { echo 'OK - Message Posted, please see your Facebook Page '; nxs_addToLog($logNT, 'M', 'Test Message Posted, please see your Facebook Page'); }}
323
+ else { if (isset($ret['id']) && $ret['id']!='') {
324
+ nxs_metaMarkAsPosted($postID, 'FB', $options['ii'], array('isPosted'=>'1', 'pgID'=>$ret['id'], 'pDate'=>date('Y-m-d H:i:s')) ); nxs_addToLog($logNT, 'M', 'OK - Message Posted'.print_r($ret, true), $extInfo);
325
+ } else nxs_addToLog($logNT, 'E', '-=ERROR=- '.print_r($ret, true), $extInfo);
326
  }
327
  }
328
  }
inc-cl/gp.php CHANGED
@@ -11,7 +11,8 @@ if (!class_exists("nxs_snapClassGP")) { class nxs_snapClassGP {
11
  <?php } else { $cgpo = count($ntOpts); $mgpo = 1+max(array_keys($ntOpts)); $nxsOne .= "&g=1"; ?>
12
  <div class="nsBigText">You have <?php echo $cgpo=='0'?'No':$cgpo; ?> Google+ account<?php if ($cgpo!=1){ ?>s<?php } ?> <!--- <a href="#" class="NXSButton" onclick="doShowHideBlocks2('GP<?php echo $mgpo; ?>');return false;">Add new Google+ Account</a> --> </div></div>
13
  <?php //if (function_exists('nxs_doSMAS1')) nxs_doSMAS1($this, $mgpo); else nxs_doSMAS('Google+', 'GP'.$mgpo); ?>
14
- <?php foreach ($ntOpts as $indx=>$gpo){ if (trim($gpo['nName']=='')) { $gpo['nName'] = $gpo['gpUName']; if($gpo['gpPageID']!='') $gpo['nName'] .= "Page: ".$gpo['gpPageID']; else $gpo['nName'] .= " Profile"; } ?>
 
15
  <p style="margin: 0px;margin-left: 5px;">
16
  <input value="1" id="apDoGP" name="gp[<?php echo $indx; ?>][apDoGP]" type="checkbox" <?php if ((int)$gpo['doGP'] == 1) echo "checked"; ?> />
17
  <strong>Auto-publish your Posts to your Google+ <i style="color: #005800;"><?php if($gpo['nName']!='') echo "(".$gpo['nName'].")"; ?></i> </strong>
@@ -23,7 +24,7 @@ if (!class_exists("nxs_snapClassGP")) { class nxs_snapClassGP {
23
  <?php }
24
  }
25
  //#### Show NEW Settings Page
26
- function showNewNTSettings($mgpo){ $gpo = array('nName'=>'', 'doGP'=>'1', 'gpUName'=>'', 'gpPageID'=>'', 'postType'=>'A', 'gpPass'=>''); $this->showNTSettings($mgpo, $gpo, true);}
27
  //#### Show Unit Settings
28
  function showNTSettings($ii, $gpo, $isNew=false){ global $nxs_plurl; ?>
29
  <div id="doGP<?php echo $ii; ?>Div" <?php if ($isNew){ ?>class="clNewNTSets"<?php } ?> style="max-width: 1000px; background-color: #EBF4FB; background-image: url(<?php echo $nxs_plurl; ?>img/gp-bg.png); background-position:90% 10%; background-repeat: no-repeat; margin: 10px; border: 1px solid #808080; padding: 10px; display:none;"> <input type="hidden" name="apDoSGP<?php echo $ii; ?>" value="0" id="apDoSGP<?php echo $ii; ?>" />
@@ -36,13 +37,26 @@ if (!class_exists("nxs_snapClassGP")) { class nxs_snapClassGP {
36
  <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/">Detailed Google+ Installation/Configuration Instructions</a></div>
37
 
38
  <div style="width:100%;"><strong>Account Nickname:</strong> <i>Just so you can easely identify it</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($gpo['nName'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" /><br/>
39
- <?php echo nxs_addQTranslSel('gp', $ii, $options['qTLng']); ?><?php echo nxs_addPostingDelaySel('gp', $ii, $gpo['nHrs'], $gpo['nMin']); ?>
 
 
 
 
 
 
 
 
 
40
 
41
  <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($gpo['gpUName'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" />
42
  <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($gpo['gpPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($gpo['gpPass'], 5)):$gpo['gpPass'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" /> <br/>
43
- <p><div style="width:100%;"><strong>Google+ Page ID (Optional - for Google+ Pages Only. <b style="color: #580000;"> Leave Empty to publish to your profile</b>):</strong>
44
- <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>Leave Empty to publish to your profile.</b></p>
45
  </div><input name="gp[<?php echo $ii; ?>][apGPPage]" id="apGPPage" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($gpo['gpPageID'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" />
 
 
 
 
46
  <br/><br/>
47
 
48
  <div id="altFormat" style="">
@@ -81,7 +95,12 @@ if (!class_exists("nxs_snapClassGP")) { class nxs_snapClassGP {
81
  if (isset($pval['apGPUName'])) $options[$ii]['gpUName'] = trim($pval['apGPUName']);
82
  if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']);
83
  if (isset($pval['apGPPass'])) $options[$ii]['gpPass'] = 'n5g9a'.nsx_doEncode($pval['apGPPass']); else $options[$ii]['gpPass'] = '';
84
- if (isset($pval['apGPPage'])) $options[$ii]['gpPageID'] = trim($pval['apGPPage']);
 
 
 
 
 
85
  if (isset($pval['postType'])) $options[$ii]['postType'] = $pval['postType'];
86
  if (isset($pval['apGPMsgFrmt'])) $options[$ii]['gpMsgFormat'] = trim($pval['apGPMsgFrmt']);
87
  if (isset($pval['apDoGP'])) $options[$ii]['doGP'] = $pval['apDoGP']; else $options[$ii]['doGP'] = 0;
@@ -92,19 +111,26 @@ if (!class_exists("nxs_snapClassGP")) { class nxs_snapClassGP {
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, 'snapGP', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]); $doGP = $ntOpt['doGP'];
96
  $isAvailGP = $ntOpt['gpUName']!='' && $ntOpt['gpPass']!=''; $gpMsgFormat = htmlentities($ntOpt['gpMsgFormat'], ENT_COMPAT, "UTF-8");
97
  if(!isset($ntOpt['postType']) || $ntOpt['postType']=='') {
98
  if ((int)$ntOpt['imgPost'] == 1) $ntOpt['postType'] = 'I';
99
  if ((int)$ntOpt['gpAttch'] == 1 || $isNew) $ntOpt['postType'] = 'A';
100
  } $gpPostType = $ntOpt['postType'];
101
  ?>
102
- <tr><th style="text-align:left;" colspan="2">
103
- <?php if ($isAvailGP) { ?><input class="nxsGrpDoChb" value="1" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="gp[<?php echo $ii; ?>][SNAPincludeGP]" <?php if (($post->post_status == "publish" && $ntOpt['isPosted'] == '1') || ($post->post_status != "publish" && ((int)$doGP == 1)) ) echo 'checked="checked" title="def"'; ?> /> <?php } ?>
104
 
105
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/gp16.png);">Google+ - publish to (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
106
  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+', 're-post') ?>" />
107
  <?php wp_nonce_field( 'rePostToGP', 'rePostToGP_wpnonce' ); } ?>
 
 
 
 
 
 
 
108
  </td></tr>
109
 
110
  <?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>
@@ -156,10 +182,13 @@ if (!function_exists("nxs_doPublishToGP")) { //## Second Function to Post to G+
156
  $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";}
157
  $url = get_permalink($postID); if(trim($url)=='') $url = home_url();
158
  if ($gpPostType=='I') $lnk = array(); if ($gpPostType=='A') $lnk = doGetGoogleUrlInfo2($url); if (is_array($lnk) && $imgURL!='') $lnk['img'] = $imgURL; //prr($lnk);
159
- if (!empty($options['gpPageID'])) { $to = $options['gpPageID']; $ret = doPostToGooglePlus2($msg, $lnk, $to);} else $ret = doPostToGooglePlus2($msg, $lnk);
160
- if ($ret!='OK') { if ($postID=='0') echo $ret; nxs_addToLog($logNT, 'E', '-=ERROR=- '.print_r($ret, true), $extInfo);}
161
- else if ($postID=='0') { nxs_addToLog($logNT, 'M', 'OK - TEST Message Posted '); echo 'OK - Message Posted, please see your Google+ Page'; } else { nxs_metaMarkAsPosted($postID, 'GP', $options['ii']); nxs_addToLog($logNT, 'M', 'OK - Message Posted ', $extInfo); }
162
- if ($ret == 'OK') return 200; else return $ret;
 
 
 
163
  }
164
  }
165
  ?>
11
  <?php } else { $cgpo = count($ntOpts); $mgpo = 1+max(array_keys($ntOpts)); $nxsOne .= "&g=1"; ?>
12
  <div class="nsBigText">You have <?php echo $cgpo=='0'?'No':$cgpo; ?> Google+ account<?php if ($cgpo!=1){ ?>s<?php } ?> <!--- <a href="#" class="NXSButton" onclick="doShowHideBlocks2('GP<?php echo $mgpo; ?>');return false;">Add new Google+ Account</a> --> </div></div>
13
  <?php //if (function_exists('nxs_doSMAS1')) nxs_doSMAS1($this, $mgpo); else nxs_doSMAS('Google+', 'GP'.$mgpo); ?>
14
+ <?php foreach ($ntOpts as $indx=>$gpo){ if (trim($gpo['nName']=='')) { $gpo['nName'] = $gpo['gpUName'];
15
+ if($gpo['gpPageID']!='') $gpo['nName'] .= "Page: ".$gpo['gpPageID']; elseif ($gpo['gpCommID']!='') $gpo['nName'] .= "Community: ".$gpo['gpCommID']; else $gpo['nName'] .= " Profile"; } ?>
16
  <p style="margin: 0px;margin-left: 5px;">
17
  <input value="1" id="apDoGP" name="gp[<?php echo $indx; ?>][apDoGP]" type="checkbox" <?php if ((int)$gpo['doGP'] == 1) echo "checked"; ?> />
18
  <strong>Auto-publish your Posts to your Google+ <i style="color: #005800;"><?php if($gpo['nName']!='') echo "(".$gpo['nName'].")"; ?></i> </strong>
24
  <?php }
25
  }
26
  //#### Show NEW Settings Page
27
+ function showNewNTSettings($mgpo){ $gpo = array('nName'=>'', 'doGP'=>'1', 'gpUName'=>'', 'gpPageID'=>'', 'gpCommID'=>'', 'postType'=>'A', 'gpPass'=>''); $this->showNTSettings($mgpo, $gpo, true);}
28
  //#### Show Unit Settings
29
  function showNTSettings($ii, $gpo, $isNew=false){ global $nxs_plurl; ?>
30
  <div id="doGP<?php echo $ii; ?>Div" <?php if ($isNew){ ?>class="clNewNTSets"<?php } ?> style="max-width: 1000px; background-color: #EBF4FB; background-image: url(<?php echo $nxs_plurl; ?>img/gp-bg.png); background-position:90% 10%; background-repeat: no-repeat; margin: 10px; border: 1px solid #808080; padding: 10px; display:none;"> <input type="hidden" name="apDoSGP<?php echo $ii; ?>" value="0" id="apDoSGP<?php echo $ii; ?>" />
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/">Detailed Google+ Installation/Configuration Instructions</a></div>
38
 
39
  <div style="width:100%;"><strong>Account Nickname:</strong> <i>Just so you can easely identify it</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($gpo['nName'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" /><br/>
40
+ <?php echo nxs_addQTranslSel('gp', $ii, $gpo['qTLng']); ?><?php echo nxs_addPostingDelaySel('gp', $ii, $gpo['nHrs'], $gpo['nMin']); ?>
41
+
42
+ <?php if (!$isNew) { ?>
43
+ <div style="width:100%;"><strong>Auto-Post Categories:</strong>
44
+ <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="gp[<?php echo $ii; ?>][catSel]" <?php if ((int)$gpo['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)$gpo['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 ($gpo['catSelEd']!='') echo "[".(substr_count($gpo['catSelEd'], ",")+1)."]"; ?></a>
46
+ <input type="hidden" name="gp[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_GP<?php echo $ii; ?>" value="<?php echo $gpo['catSelEd']; ?>" />
47
+ </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($gpo['gpUName'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" />
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($gpo['gpPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($gpo['gpPass'], 5)):$gpo['gpPass'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" /> <br/>
53
+ <p><div style="width:100%;"><strong>Google+ Page ID (Optional - for Google+ Pages Only. <b style="color: #580000;"> Leave Empty to publish to your profile or community</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>Leave Empty to publish to your profile or community.</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($gpo['gpPageID'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" />
56
+ <br/>
57
+ <p><div style="width:100%;"><strong>Google+ Community ID (Optional - for Google+ Communities Only. <b style="color: #580000;"> Leave Empty to publish to your profile or page</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>Leave Empty to publish to your profile or page.</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($gpo['gpCommID'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" />
60
  <br/><br/>
61
 
62
  <div id="altFormat" style="">
95
  if (isset($pval['apGPUName'])) $options[$ii]['gpUName'] = trim($pval['apGPUName']);
96
  if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']);
97
  if (isset($pval['apGPPass'])) $options[$ii]['gpPass'] = 'n5g9a'.nsx_doEncode($pval['apGPPass']); else $options[$ii]['gpPass'] = '';
98
+ if (isset($pval['apGPPage'])) $options[$ii]['gpPageID'] = trim($pval['apGPPage']);
99
+ if (isset($pval['gpCommID'])) $options[$ii]['gpCommID'] = trim($pval['gpCommID']);
100
+
101
+ if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']);
102
+ if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
103
+
104
  if (isset($pval['postType'])) $options[$ii]['postType'] = $pval['postType'];
105
  if (isset($pval['apGPMsgFrmt'])) $options[$ii]['gpMsgFormat'] = trim($pval['apGPMsgFrmt']);
106
  if (isset($pval['apDoGP'])) $options[$ii]['doGP'] = $pval['apDoGP']; else $options[$ii]['doGP'] = 0;
111
  }
112
  //#### Show Post->Edit Meta Box Settings
113
  function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
114
+ foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapGP', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]); $doGP = $ntOpt['doGP'] && $ntOpt['catSel']!='1';
115
  $isAvailGP = $ntOpt['gpUName']!='' && $ntOpt['gpPass']!=''; $gpMsgFormat = htmlentities($ntOpt['gpMsgFormat'], ENT_COMPAT, "UTF-8");
116
  if(!isset($ntOpt['postType']) || $ntOpt['postType']=='') {
117
  if ((int)$ntOpt['imgPost'] == 1) $ntOpt['postType'] = 'I';
118
  if ((int)$ntOpt['gpAttch'] == 1 || $isNew) $ntOpt['postType'] = 'A';
119
  } $gpPostType = $ntOpt['postType'];
120
  ?>
121
+ <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 } ?>
122
+ <?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; ?>][SNAPincludeGP]" <?php if (($post->post_status == "publish" && $ntOpt['isPosted'] == '1') || ($post->post_status != "publish" && ((int)$doGP == 1)) ) echo 'checked="checked" title="def"'; ?> /> <?php } ?>
123
 
124
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/gp16.png);">Google+ - publish to (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
125
  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+', 're-post') ?>" />
126
  <?php wp_nonce_field( 'rePostToGP', 'rePostToGP_wpnonce' ); } ?>
127
+
128
+ <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
129
+
130
+ ?> <span id="pstdGP<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
131
+ <a style="font-size: 10px;" href="https://plus.google.com/<?php echo $pMeta[$ii]['pgID']; ?>" target="_blank">Posted on Google+ <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
132
+ </span><?php } ?>
133
+
134
  </td></tr>
135
 
136
  <?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>
182
  $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";}
183
  $url = get_permalink($postID); if(trim($url)=='') $url = home_url();
184
  if ($gpPostType=='I') $lnk = array(); if ($gpPostType=='A') $lnk = doGetGoogleUrlInfo2($url); if (is_array($lnk) && $imgURL!='') $lnk['img'] = $imgURL; //prr($lnk);
185
+ if (!empty($options['gpPageID'])) { $to = $options['gpPageID']; $ret = doPostToGooglePlus2($msg, $lnk, $to);}
186
+ elseif (!empty($options['gpCommID'])) $ret = doPostToGooglePlus2($msg, $lnk, '', $options['gpCommID']); else $ret = doPostToGooglePlus2($msg, $lnk); //prr($ret);
187
+ if ($ret=='OK') $ret = array("code"=>"OK", "post_id"=>'');
188
+ if ( (!is_array($ret)) && $ret!='OK') { if ($postID=='0') prr($ret); nxs_addToLog($logNT, 'E', '-=ERROR=- '.print_r($ret, true), $extInfo);}
189
+ else if ($postID=='0') { nxs_addToLog($logNT, 'M', 'OK - TEST Message Posted '); echo 'OK - Message Posted, please see your Google+ Page'; } else
190
+ { 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); }
191
+ if ($ret['code']=='OK') return 200; else return $ret;
192
  }
193
  }
194
  ?>
inc-cl/li.php CHANGED
@@ -78,6 +78,15 @@ if (!class_exists("nxs_snapClassLI")) { class nxs_snapClassLI {
78
  <div style="width:100%;"><strong>Account Nickname:</strong> <i>Just so you can easely identify it</i> </div><input name="li[<?php echo $ii; ?>][nName]" id="linName<?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")), 'NS_SNAutoPoster') ?>" /><br/>
79
  <?php echo nxs_addQTranslSel('li', $ii, $options['qTLng']); ?><?php echo nxs_addPostingDelaySel('li', $ii, $options['nHrs'], $options['nMin']); ?>
80
 
 
 
 
 
 
 
 
 
 
81
  <table width="800" border="0" cellpadding="10">
82
  <tr><td colspan="2">
83
  <div style="width:100%; text-align: center; color:#005800; font-weight: bold; font-size: 14px;">You can choose what API you would like to use. </div>
@@ -164,6 +173,10 @@ if (!class_exists("nxs_snapClassLI")) { class nxs_snapClassLI {
164
  if (isset($pval['apLIAPIKey']))$options[$ii]['liAPIKey'] = trim($pval['apLIAPIKey']);
165
  if (isset($pval['apLIAPISec']))$options[$ii]['liAPISec'] = trim($pval['apLIAPISec']);
166
  if (isset($pval['apLIAttch'])) $options[$ii]['liAttch'] = $pval['apLIAttch']; else $options[$ii]['liAttch'] = 0;
 
 
 
 
167
  if (isset($pval['ulName'])) $options[$ii]['ulName'] = trim($pval['ulName']);
168
  if (isset($pval['uPass'])) $options[$ii]['uPass'] = trim($pval['uPass']);
169
  if (isset($pval['grpID'])) $options[$ii]['grpID'] = trim($pval['grpID']);
@@ -176,27 +189,34 @@ if (!class_exists("nxs_snapClassLI")) { class nxs_snapClassLI {
176
  }
177
  //#### Show Post->Edit Meta Box Settings
178
  function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID; //prr($ntOpts);
179
- 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]); $doLI = $options['doLI'];
180
  $isAvailLI = (isset($options['liOAuthVerifier']) && $options['liOAuthVerifier']!='' && $options['liAccessTokenSecret']!='' && $options['liAccessToken']!='' && $options['liAPIKey']!='') || ($options['ulName']!=='' && $options['uPass']!=='');
181
  $isAttachLI = $options['liAttch']; $liMsgFormat = htmlentities($options['liMsgFormat'], ENT_COMPAT, "UTF-8");
182
  ?>
183
 
184
- <tr><th style="text-align:left;" colspan="2">
185
- <?php if ($isAvailLI) { ?><input class="nxsGrpDoChb" value="1" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="li[<?php echo $ii; ?>][SNAPincludeLI]" <?php if (($post->post_status == "publish" && $options['isPosted'] == '1') || ($post->post_status != "publish" && ((int)$doLI == 1)) ) echo 'checked="checked" title="def"'; ?> /> <?php } ?>
186
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/li16.png);">LinkedIn - publish to (<i style="color: #005800;"><?php echo $options['nName']; ?></i>)</div></th><td><?php //## Only show RePost button if the post is "published"
187
  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', 're-post') ?>" />
188
  <?php wp_nonce_field( 'rePostToLI', 'rePostToLI_wpnonce' ); } ?>
 
 
 
 
 
 
189
  </td></tr>
190
  <?php if (!$isAvailLI) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your LinkedIn Account to AutoPost to LinkedIn</b>
191
- <?php }elseif ($post->post_status != "puZblish") { ?>
192
 
193
  <tr><th scope="row" style="text-align:right; width:150px; vertical-align:top; padding-top: 5px; padding-right:10px;">
 
194
  <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>
195
 
196
  <tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;"><?php _e('Message Format:', 'NS_SPAP') ?></th>
197
  <td><input value="<?php echo ($liMsgFormat); ?>" type="text" name="li[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apLIMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apLIMsgFrmt".$ii); ?></td></tr>
198
 
199
- <?php }
200
  }
201
  }
202
 
@@ -231,9 +251,8 @@ if (!function_exists("nxs_doPublishToLI")) { //## Second Function to Post to LI
231
  else { $post = get_post($postID); if(!$post) return; $liMsgFormat = $options['liMsgFormat']; $msg = nsFormatMessage($liMsgFormat, $postID);
232
  $link = get_permalink($postID); $isAttachLI = $options['liAttch']; $title = nsTrnc($post->post_title, 200); nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
233
  }
234
-
235
- if ($isAttachLI=='1' && function_exists("get_post_thumbnail_id") ){ $src = nxs_getPostImage($postID); }
236
- if ($isAttachLI=='1') { $dsc = trim(apply_filters('the_content', $post->post_excerpt)); if ($dsc=='') $dsc = apply_filters('the_content', $post->post_content);
237
  $dsc = strip_tags($dsc); $dsc = nxs_decodeEntitiesFull($dsc); $dsc = nxs_html_to_utf8($dsc); $dsc = nsTrnc($dsc, 300);
238
  }
239
  $extInfo = ' | PostID: '.$postID." - ".$post->post_title; $logNT = '<span style="color:#000058">LinkedIn</span> - '.$options['nName'];
@@ -242,7 +261,7 @@ if (!function_exists("nxs_doPublishToLI")) { //## Second Function to Post to LI
242
  $to = $options['uPage']!=''?$options['uPage']:'http://www.linkedin.com/home'; $lnk = array(); $msg = str_ireplace('&nbsp;',' ',$msg); $msg = nsTrnc(strip_tags($msg), 700);
243
  if ($postID=='0') { $lnk['title'] = get_bloginfo('name'); $lnk['desc'] = get_bloginfo('description'); $lnk['url'] = home_url();
244
  } 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);
245
- $ret = doPostToLinkedIn($msg, $lnk, $to);
246
  } else { require_once ('apis/liOAuth.php'); $linkedin = new nsx_LinkedIn($options['liAPIKey'], $options['liAPISec']); $linkedin->oauth_verifier = $options['liOAuthVerifier'];
247
  $linkedin->request_token = new nsx_trOAuthConsumer($options['liOAuthToken'], $options['liOAuthTokenSecret'], 1);
248
  $linkedin->access_token = new nsx_trOAuthConsumer($options['liAccessToken'], $options['liAccessTokenSecret'], 1); $msg = nsTrnc($msg, 700);
@@ -252,9 +271,12 @@ if (!function_exists("nxs_doPublishToLI")) { //## Second Function to Post to LI
252
  try{ if($isAttachLI=='1') $ret = $linkedin->postShare($msg, nsTrnc($post->post_title, 200), get_permalink($postID), $src, $dsc); else $ret = $linkedin->postShare($msg); }
253
  catch (Exception $o){ echo "<br/>Linkedin Status couldn't be updated!</br>"; prr($o); echo '<br/>'; $ret="ERROR:".print_r($o, true); }
254
  }
 
 
255
  }
256
- if ($ret!='201') { if ($postID=='0') echo $ret; nxs_addToLog($logNT, 'E', '-=ERROR=- '.print_r($ret, true), $extInfo); }
257
- else if ($postID=='0') { echo 'OK - Linkedin status updated successfully'; nxs_addToLog($logNT, 'M', 'OK - TEST Message Posted '); } else {nxs_metaMarkAsPosted($postID, 'LI', $options['ii']); nxs_addToLog($logNT, 'M', 'OK - Message Posted ', $extInfo); }
 
258
  if ($ret=='201') return true; else return 'Something Wrong';
259
  }
260
  }
78
  <div style="width:100%;"><strong>Account Nickname:</strong> <i>Just so you can easely identify it</i> </div><input name="li[<?php echo $ii; ?>][nName]" id="linName<?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")), 'NS_SNAutoPoster') ?>" /><br/>
79
  <?php echo nxs_addQTranslSel('li', $ii, $options['qTLng']); ?><?php echo nxs_addPostingDelaySel('li', $ii, $options['nHrs'], $options['nMin']); ?>
80
 
81
+ <?php if (!$isNew) { ?>
82
+ <div style="width:100%;"><strong>Auto-Post Categories:</strong>
83
+ <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="li[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
84
+ <input value="1" id="catSelSLI<?php echo $ii; ?>" type="radio" name="li[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_LI<?php echo $ii; ?>" onclick="jQuery('#catSelSLI<?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('LI<?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_LI<?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>
85
+ <input type="hidden" name="li[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_LI<?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
86
+ </div>
87
+ <br/>
88
+ <?php } ?>
89
+
90
  <table width="800" border="0" cellpadding="10">
91
  <tr><td colspan="2">
92
  <div style="width:100%; text-align: center; color:#005800; font-weight: bold; font-size: 14px;">You can choose what API you would like to use. </div>
173
  if (isset($pval['apLIAPIKey']))$options[$ii]['liAPIKey'] = trim($pval['apLIAPIKey']);
174
  if (isset($pval['apLIAPISec']))$options[$ii]['liAPISec'] = trim($pval['apLIAPISec']);
175
  if (isset($pval['apLIAttch'])) $options[$ii]['liAttch'] = $pval['apLIAttch']; else $options[$ii]['liAttch'] = 0;
176
+
177
+ if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']);
178
+ if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
179
+
180
  if (isset($pval['ulName'])) $options[$ii]['ulName'] = trim($pval['ulName']);
181
  if (isset($pval['uPass'])) $options[$ii]['uPass'] = trim($pval['uPass']);
182
  if (isset($pval['grpID'])) $options[$ii]['grpID'] = trim($pval['grpID']);
189
  }
190
  //#### Show Post->Edit Meta Box Settings
191
  function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID; //prr($ntOpts);
192
+ 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]); $doLI = $options['doLI'] && $options['catSel']!='1';
193
  $isAvailLI = (isset($options['liOAuthVerifier']) && $options['liOAuthVerifier']!='' && $options['liAccessTokenSecret']!='' && $options['liAccessToken']!='' && $options['liAPIKey']!='') || ($options['ulName']!=='' && $options['uPass']!=='');
194
  $isAttachLI = $options['liAttch']; $liMsgFormat = htmlentities($options['liMsgFormat'], ENT_COMPAT, "UTF-8");
195
  ?>
196
 
197
+ <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 } ?>
198
+ <?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; ?>][SNAPincludeLI]" <?php if (($post->post_status == "publish" && $options['isPosted'] == '1') || ($post->post_status != "publish" && ((int)$doLI == 1)) ) echo 'checked="checked" title="def"'; ?> /> <?php } ?>
199
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/li16.png);">LinkedIn - publish to (<i style="color: #005800;"><?php echo $options['nName']; ?></i>)</div></th><td><?php //## Only show RePost button if the post is "published"
200
  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', 're-post') ?>" />
201
  <?php wp_nonce_field( 'rePostToLI', 'rePostToLI_wpnonce' ); } ?>
202
+
203
+ <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
204
+ ?> <span id="pstdLI<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
205
+ <a style="font-size: 10px;" href="<?php if ($options['uPage']!='') echo $options['uPage']; else { echo "http://www.linkedin.com/profile/view?id=".CutFromTo("XWEXW".$pMeta[$ii]['pgID'], "XWEXW", ' - '); } ?>" target="_blank">Posted on LinkedIn <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
206
+ </span><?php } ?>
207
+
208
  </td></tr>
209
  <?php if (!$isAvailLI) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your LinkedIn Account to AutoPost to LinkedIn</b>
210
+ <?php } elseif ($post->post_status != "puZblish") { ?>
211
 
212
  <tr><th scope="row" style="text-align:right; width:150px; vertical-align:top; padding-top: 5px; padding-right:10px;">
213
+ <input value="0" type="hidden" name="li[<?php echo $ii; ?>][AttachPost]"/>
214
  <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>
215
 
216
  <tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;"><?php _e('Message Format:', 'NS_SPAP') ?></th>
217
  <td><input value="<?php echo ($liMsgFormat); ?>" type="text" name="li[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apLIMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apLIMsgFrmt".$ii); ?></td></tr>
218
 
219
+ <?php }
220
  }
221
  }
222
 
251
  else { $post = get_post($postID); if(!$post) return; $liMsgFormat = $options['liMsgFormat']; $msg = nsFormatMessage($liMsgFormat, $postID);
252
  $link = get_permalink($postID); $isAttachLI = $options['liAttch']; $title = nsTrnc($post->post_title, 200); nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
253
  }
254
+
255
+ if ($isAttachLI=='1') { $src = nxs_getPostImage($postID); $dsc = trim(apply_filters('the_content', $post->post_excerpt)); if ($dsc=='') $dsc = apply_filters('the_content', $post->post_content);
 
256
  $dsc = strip_tags($dsc); $dsc = nxs_decodeEntitiesFull($dsc); $dsc = nxs_html_to_utf8($dsc); $dsc = nsTrnc($dsc, 300);
257
  }
258
  $extInfo = ' | PostID: '.$postID." - ".$post->post_title; $logNT = '<span style="color:#000058">LinkedIn</span> - '.$options['nName'];
261
  $to = $options['uPage']!=''?$options['uPage']:'http://www.linkedin.com/home'; $lnk = array(); $msg = str_ireplace('&nbsp;',' ',$msg); $msg = nsTrnc(strip_tags($msg), 700);
262
  if ($postID=='0') { $lnk['title'] = get_bloginfo('name'); $lnk['desc'] = get_bloginfo('description'); $lnk['url'] = home_url();
263
  } 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);
264
+ $ret = doPostToLinkedIn($msg, $lnk, $to); $liPostID = $options['uPage'];
265
  } else { require_once ('apis/liOAuth.php'); $linkedin = new nsx_LinkedIn($options['liAPIKey'], $options['liAPISec']); $linkedin->oauth_verifier = $options['liOAuthVerifier'];
266
  $linkedin->request_token = new nsx_trOAuthConsumer($options['liOAuthToken'], $options['liOAuthTokenSecret'], 1);
267
  $linkedin->access_token = new nsx_trOAuthConsumer($options['liAccessToken'], $options['liAccessTokenSecret'], 1); $msg = nsTrnc($msg, 700);
271
  try{ if($isAttachLI=='1') $ret = $linkedin->postShare($msg, nsTrnc($post->post_title, 200), get_permalink($postID), $src, $dsc); else $ret = $linkedin->postShare($msg); }
272
  catch (Exception $o){ echo "<br/>Linkedin Status couldn't be updated!</br>"; prr($o); echo '<br/>'; $ret="ERROR:".print_r($o, true); }
273
  }
274
+ //$liPostID = $linkedin->getCurrentShare(); prr($liPostID);
275
+ $liPostID = $options['liUserInfo'];
276
  }
277
+ if ($ret!='201') { if ($postID=='0') prr($ret); nxs_addToLog($logNT, 'E', '-=ERROR=- '.print_r($ret, true), $extInfo); }
278
+ else if ($postID=='0') { echo 'OK - Linkedin status updated successfully'; nxs_addToLog($logNT, 'M', 'OK - TEST Message Posted '); } else
279
+ { nxs_metaMarkAsPosted($postID, 'LI', $options['ii'], array('isPosted'=>'1', 'pgID'=>$liPostID, 'pDate'=>date('Y-m-d H:i:s'))); nxs_addToLog($logNT, 'M', 'OK - Message Posted ', $extInfo); }
280
  if ($ret=='201') return true; else return 'Something Wrong';
281
  }
282
  }
inc-cl/lj.php ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //## NextScripts Facebook Connection Class
3
+ $nxs_snapAvNts[] = array('code'=>'LJ', 'lcode'=>'lj', 'name'=>'LiveJournal');
4
+
5
+ if (!class_exists("nxs_snapClassLJ")) { class nxs_snapClassLJ {
6
+ //#### Show Common Settings
7
+ function showGenNTSettings($ntOpts){ global $nxs_snapThisPageUrl, $nxs_plurl, $nxsOne; $code = 'LJ'; $lcode = 'lj'; wp_nonce_field( 'ns'.$code, 'ns'.$code.'_wpnonce' ); ?>
8
+ <hr/><div class="nsx_iconedTitle" style="background-image: url(<?php echo $nxs_plurl; ?>img/<?php echo $lcode; ?>16.png);">LiveJournal Blog Settings:
9
+ <?php $cgpo = count($ntOpts); $mgpo = 1+max(array_keys($ntOpts)); $nxsOne .= "&g=1"; ?>
10
+ <div class="nsBigText">You have <?php echo $cgpo=='0'?'No':$cgpo; ?> Blog account<?php if ($cgpo!=1){ ?>s<?php } ?> </div></div>
11
+ <?php //if (function_exists('nxs_doSMAS1')) nxs_doSMAS1($this, $mgpo); else nxs_doSMAS('Google+', 'GP'.$mgpo); ?>
12
+ <?php foreach ($ntOpts as $indx=>$gpo){ if (trim($gpo['nName']=='')) $gpo['nName'] = str_ireplace('/xmlrpc.php','', str_ireplace('http://','', str_ireplace('https://','', $gpo['ljURL']))); ?>
13
+ <p style="margin: 0px; margin-left: 5px;">
14
+ <input value="1" id="apDoLJ" name="lj[<?php echo $indx; ?>][apDoLJ]"type="checkbox" <?php if ((int)$gpo['doLJ'] == 1) echo "checked"; ?> />
15
+ <strong>Auto-publish your Posts to your Blog <i style="color: #005800;"><?php if($gpo['nName']!='') echo "(".$gpo['nName'].")"; ?></i></strong>
16
+ &nbsp;&nbsp;<a id="doLJ<?php echo $indx; ?>A" href="#" onclick="doShowHideBlocks2('LJ<?php echo $indx; ?>');return false;">[Show Settings]</a> &nbsp;&nbsp;
17
+ <a href="#" onclick="doDelAcct('lj','<?php echo $indx; ?>', '<?php echo $gpo['ljUName']; ?>');return false;">[Remove Account]</a>
18
+ </p>
19
+ <?php $this->showNTSettings($indx, $gpo);
20
+ } ?>
21
+ <?php
22
+ }
23
+ //#### Show NEW Settings Page
24
+ function showNewNTSettings($mgpo){ $gpo = array('nName'=>'', 'doLJ'=>'1', 'ljUName'=>'', 'ljPageID'=>'', 'ljAttch'=>'', 'ljPass'=>'', 'ljURL'=>''); $this->showNTSettings($mgpo, $gpo, true);}
25
+ //#### Show Unit Settings
26
+ function showNTSettings($ii, $gpo, $isNew=false){ global $nxs_plurl; ?>
27
+ <div id="doLJ<?php echo $ii; ?>Div" <?php if ($isNew){ ?>class="clNewNTSets"<?php } ?> style="max-width: 1000px; background-color: #EBF4FB; background-image: url(<?php echo $nxs_plurl; ?>img/lj-bg.png); background-position:90% 10%; background-repeat: no-repeat; margin: 10px; border: 1px solid #808080; padding: 10px; display:none;"> <input type="hidden" name="apDoSLJ<?php echo $ii; ?>" value="0" id="apDoSLJ<?php echo $ii; ?>" />
28
+
29
+ <div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/lj16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-livejournal-social-networks-auto-poster-for-wordpress/">Detailed LiveJournal Installation/Configuration Instructions</a></div>
30
+ <?php if ($isNew){ ?> <br/>You can setup LiveJournal blog.<br/><br/> <?php } ?>
31
+
32
+ <div style="width:100%;"><strong>Account Nickname:</strong> <i>Just so you can easely identify it</i> </div><input name="lj[<?php echo $ii; ?>][nName]" id="ljnName<?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")), 'NS_SNAutoPoster') ?>" /><br/>
33
+ <?php echo nxs_addQTranslSel('lj', $ii, $gpo['qTLng']); ?><?php echo nxs_addPostingDelaySel('lj', $ii, $gpo['nHrs'], $gpo['nMin']); ?>
34
+
35
+ <?php if (!$isNew) { ?>
36
+ <div style="width:100%;"><strong>Auto-Post Categories:</strong>
37
+ <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="lj[<?php echo $ii; ?>][catSel]" <?php if ((int)$gpo['catSel'] != 1) echo "checked"; ?> /> All
38
+ <input value="1" id="catSelSLJ<?php echo $ii; ?>" type="radio" name="lj[<?php echo $ii; ?>][catSel]" <?php if ((int)$gpo['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_LJ<?php echo $ii; ?>" onclick="jQuery('#catSelSLJ<?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('LJ<?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_LJ<?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>
39
+ <input type="hidden" name="lj[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_LJ<?php echo $ii; ?>" value="<?php echo $gpo['catSelEd']; ?>" />
40
+ </div>
41
+ <?php } ?>
42
+ <div style="width:100%;"><br/><strong>LiveJournal Username:</strong> </div><input name="lj[<?php echo $ii; ?>][apLJUName]" id="apLJUName" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($gpo['ljUName'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" />
43
+ <div style="width:100%;"><strong>LiveJournal Password:</strong> </div><input name="lj[<?php echo $ii; ?>][apLJPass]" id="apLJPass" type="password" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities(substr($gpo['ljPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($gpo['ljPass'], 5)):$gpo['ljPass'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" /> <br/>
44
+
45
+ <?php if ($isNew) { ?> <input type="hidden" name="lj[<?php echo $ii; ?>][apDoLJ]" value="1" id="apDoNewLJ<?php echo $ii; ?>" /> <?php } ?>
46
+
47
+ <br/><strong id="altFormatText">Post Title and Post Text Formats</strong>
48
+ <p style="font-size: 11px; margin: 0px;">%SITENAME% - Inserts the Your Blog/Site Name. &nbsp; %TITLE% - Inserts the Title of your post. &nbsp; %URL% - Inserts the URL of your post. &nbsp; %TEXT% - Inserts the excerpt of your post. &nbsp; %FULLTEXT% - Inserts the body(text) of your post, %AUTHORNAME% - Inserts the author's name.</p>
49
+ <div id="altFormat" style="">
50
+ <div style="width:100%;"><strong id="altFormatText">Post Title Format</strong>
51
+ </div><input name="lj[<?php echo $ii; ?>][apLJMsgTFrmt]" id="apLJMsgTFrmt" style="width: 50%;" value="<?php if ($isNew) echo "%TITLE%"; else _e(apply_filters('format_to_edit', htmlentities($gpo['ljMsgTFormat'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster'); ?>" />
52
+ </div>
53
+ <div id="altFormat" style="">
54
+ <div style="width:100%;"><strong id="altFormatText">Post Text Format</strong>
55
+ </div><input name="lj[<?php echo $ii; ?>][apLJMsgFrmt]" id="apLJMsgFrmt" style="width: 50%;" value="<?php if ($isNew) echo "%FULLTEXT%"; else _e(apply_filters('format_to_edit', htmlentities($gpo['ljMsgFormat'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster'); ?>" />
56
+ </div><br/>
57
+
58
+ <?php if ($gpo['ljPass']!='') { ?>
59
+ <?php wp_nonce_field( 'rePostToLJ', 'rePostToLJ_wpnonce' ); ?>
60
+ <b>Test your settings:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('LJ', '<?php echo $ii; ?>'); return false;">Submit Test Post to LiveJournal</a>
61
+
62
+ <?php }
63
+
64
+ ?><div class="submit"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'NS_SNAutoPoster') ?>" /></div></div><?php
65
+ }
66
+ //#### Set Unit Settings from POST
67
+ function setNTSettings($post, $options){ global $nxs_snapThisPageUrl; $code = 'LJ'; $lcode = 'lj';
68
+ foreach ($post as $ii => $pval){
69
+ if (isset($pval['apLJUName']) && $pval['apLJUName']!=''){ if (!isset($options[$ii])) $options[$ii] = array();
70
+ if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']);
71
+ if (isset($pval['apLJUName'])) $options[$ii]['ljUName'] = trim($pval['apLJUName']); $options[$ii]['ljURL'] = 'http://'.$options[$ii]['ljUName'].'.livejournal.com';
72
+ if (isset($pval['apLJPass'])) $options[$ii]['ljPass'] = 'n5g9a'.nsx_doEncode($pval['apLJPass']); else $options[$ii]['ljPass'] = '';
73
+ if (isset($pval['apLJMsgFrmt'])) $options[$ii]['ljMsgFormat'] = trim($pval['apLJMsgFrmt']);
74
+ if (isset($pval['apLJMsgTFrmt'])) $options[$ii]['ljMsgTFormat'] = trim($pval['apLJMsgTFrmt']);
75
+
76
+ if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']);
77
+ if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
78
+
79
+ if (isset($pval['apDoLJ'])) $options[$ii]['doLJ'] = $pval['apDoLJ']; else $options[$ii]['doLJ'] = 0;
80
+ if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
81
+ if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
82
+ }
83
+ } return $options;
84
+ }
85
+ //#### Show Post->Edit Meta Box Settings
86
+ function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
87
+ foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapLJ', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]); $doLJ = $ntOpt['doLJ'] && $ntOpt['catSel']!='1';
88
+ $isAvailLJ = $ntOpt['ljUName']!='' && $ntOpt['ljPass']!=''; $ljMsgFormat = htmlentities($ntOpt['ljMsgFormat'], ENT_COMPAT, "UTF-8"); $ljMsgTFormat = htmlentities($ntOpt['ljMsgTFormat'], ENT_COMPAT, "UTF-8");
89
+ ?>
90
+ <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 } ?>
91
+ <?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; ?>][SNAPincludeLJ]" <?php if (($post->post_status == "publish" && $ntOpt['isPosted'] == '1') || ($post->post_status != "publish" && ((int)$doLJ == 1)) ) echo 'checked="checked" title="def"'; ?> /> <?php } ?>
92
+ <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/lj16.png);">LiveJournal - publish to (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
93
+ 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', 're-post') ?>" />
94
+ <?php wp_nonce_field( 'rePostToLJ', 'rePostToLJ_wpnonce' ); } ?>
95
+
96
+ <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
97
+ ?> <span id="pstdLJ<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
98
+ <a style="font-size: 10px;" href="<?php echo $pMeta[$ii]['pgID']; ?>" target="_blank">Posted on LiveJournal <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
99
+ </span><?php } ?>
100
+
101
+ </td></tr>
102
+
103
+ <?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>
104
+ <?php } elseif ($post->post_status != "puZblish") { ?>
105
+
106
+ <tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;"><?php _e('Title Format:', 'NS_SPAP') ?></th>
107
+ <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>
108
+
109
+ <tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;"><?php _e('Text Format:', 'NS_SPAP') ?></th>
110
+ <td><input value="<?php echo $ljMsgFormat ?>" type="text" name="lj[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apLJMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apLJMsgFrmt".$ii); ?></td></tr>
111
+
112
+ <?php }
113
+ }
114
+ }
115
+ //#### Save Meta Tags to the Post
116
+ function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
117
+ if (isset($pMeta['SNAPformat'])) $optMt['ljMsgFormat'] = $pMeta['SNAPformat'];
118
+ if (isset($pMeta['SNAPformatT'])) $optMt['ljMsgTFormat'] = $pMeta['SNAPformatT'];
119
+ if (isset($pMeta['SNAPincludeLJ'])) $optMt['doLJ'] = $pMeta['SNAPincludeLJ'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doLJ'] = 0; } return $optMt;
120
+ }
121
+ }}
122
+ if (!function_exists("nxs_rePostToLJ_ajax")) {
123
+ function nxs_rePostToLJ_ajax() { check_ajax_referer('rePostToLJ'); $postID = $_POST['id']; $options = get_option('NS_SNAutoPoster');
124
+ foreach ($options['lj'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj';//if ($two['gpPageID'].$two['gpUName']==$_POST['nid']) {
125
+ $gppo = get_post_meta($postID, 'snapLJ', true); $gppo = maybe_unserialize($gppo);// prr($gppo);
126
+ if (is_array($gppo) && isset($gppo[$ii]) && is_array($gppo[$ii])){ $ntClInst = new nxs_snapClassLJ(); $two = $ntClInst->adjMetaOpt($two, $gppo[$ii]); }
127
+ $result = nxs_doPublishToLJ($postID, $two); if ($result == 200) die("Successfully sent your post to LiveJournal."); else die($result);
128
+ }
129
+ }
130
+ }
131
+
132
+ if (!function_exists("nxs_doPublishToLJ")) { //## Second Function to Post to LJ
133
+ function nxs_doPublishToLJ($postID, $options){ $ntCd = 'LJ'; $ntCdL = 'lj'; $ntNm = 'LJ Based Blog';
134
+
135
+ $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10)); $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
136
+ if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
137
+ nxs_addToLog($ntCd.' - '.$options['nName'], 'E', '-=Duplicate=- Post ID:'.$postID, 'Not posted. No reason for posting duplicate'); return;
138
+ }
139
+ $imgURL = nxs_getPostImage($postID);
140
+ $email = $options['ljUName']; $pass = substr($options['ljPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['ljPass'], 5)):$options['ljPass'];
141
+ 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);
142
+ $msgFormat = $options['ljMsgFormat']; $msg = nsFormatMessage($msgFormat, $postID); $msgTFormat = $options['ljMsgTFormat']; $msgT = nsFormatMessage($msgTFormat, $postID);
143
+ nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
144
+ } //prr($msg); prr($msgFormat);
145
+ //## Post
146
+ require_once ('apis/xmlrpc-client.php'); $nxsToLJclient = new NXS_XMLRPC_Client('http://www.livejournal.com/interface/xmlrpc'); $nxsToLJclient->debug = false;
147
+
148
+ $extInfo = ' | PostID: '.$postID." - ".$post->post_title; $logNT = '<span style="color:#2097EE">LJ</span> - '.$options['nName'];
149
+
150
+ $date = time(); $year = date("Y", $date); $mon = date("m", $date); $day = date("d", $date); $hour = date("G", $date); $min = date("i", $date);
151
+ $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);
152
+ if (!$nxsToLJclient->query('LJ.XMLRPC.postevent', $nxsToLJContent)) { $ret = 'Something went wrong - '.$nxsToLJclient->getErrorCode().' : '.$nxsToLJclient->getErrorMessage();} else $ret = 'OK';
153
+ $pid = $nxsToLJclient->getResponse(); if (is_array($pid)) $pid = $pid['url']; else { $ret = 'Something went wrong - '.print_r($pid, true);}
154
+
155
+ if ($ret!='OK') { if ($postID=='0') echo $ret;
156
+ nxs_addToLog($logNT, 'E', '-=ERROR=- '.print_r($ret, true), $extInfo);
157
+ } else { if ($postID=='0') { echo 'OK - Message Posted, please see your LiveJournal'; nxs_addToLog($logNT, 'M', 'OK - TEST Message Posted '); } else
158
+ { nxs_metaMarkAsPosted($postID, 'LJ', $options['ii'], array('isPosted'=>'1', 'pgID'=>$pid, 'pDate'=>date('Y-m-d H:i:s'))); nxs_addToLog($logNT, 'M', 'OK - Message Posted ', $extInfo);} }
159
+ if ($ret == 'OK') return 200; else return $ret;
160
+ }
161
+ }
162
+ ?>
inc-cl/pk.php CHANGED
@@ -67,6 +67,15 @@ if (!class_exists("nxs_snapClassPK")) { class nxs_snapClassPK {
67
  <div style="width:100%;"><strong>Account Nickname:</strong> <i>Just so you can easely identify it</i> </div><input name="pk[<?php echo $ii; ?>][nName]" id="pknName<?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")), 'NS_SNAutoPoster') ?>" /><br/>
68
  <?php echo nxs_addQTranslSel('pk', $ii, $options['qTLng']); ?><?php echo nxs_addPostingDelaySel('pk', $ii, $options['nHrs'], $options['nMin']); ?>
69
 
 
 
 
 
 
 
 
 
 
70
  <div style="width:100%;"><strong>Your Plurk URL:</strong> </div><input onchange="nxsPKURLVal(<?php echo $ii; ?>);" name="pk[<?php echo $ii; ?>][apPKURL]" id="apPKURL<?php echo $ii; ?>" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['pkURL'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" /><span style="color: #F00000;" id="apPKURLerr<?php echo $ii; ?>"></span>
71
  <div style="width:100%;"><strong>Your Plurk App Key:</strong> </div><input name="pk[<?php echo $ii; ?>][apPKConsKey]" id="apPKConsKey" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['pkConsKey'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" />
72
  <div style="width:100%;"><strong>Your Plurk App Secret:</strong> </div><input name="pk[<?php echo $ii; ?>][apPKConsSec]" id="apPKConsSec" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['pkConsSec'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" />
@@ -124,7 +133,11 @@ if (!class_exists("nxs_snapClassPK")) { class nxs_snapClassPK {
124
  if (isset($pval['apDoPK'])) $options[$ii]['doPK'] = $pval['apDoPK']; else $options[$ii]['doPK'] = 0;
125
  if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']);
126
  if (isset($pval['apPKConsKey'])) $options[$ii]['pkConsKey'] = trim($pval['apPKConsKey']);
127
- if (isset($pval['apPKConsSec'])) $options[$ii]['pkConsSec'] = trim($pval['apPKConsSec']);
 
 
 
 
128
  if (isset($pval['apPKMsgFrmt'])) $options[$ii]['pkMsgFormat'] = trim($pval['apPKMsgFrmt']);
129
  if (isset($pval['Cat'])) $options[$ii]['pkCat'] = $pval['Cat']; else $options[$ii]['pkCat'] = "";
130
  if (isset($pval['attchImg'])) $options[$ii]['attchImg'] = $pval['attchImg']; else $options[$ii]['attchImg'] = 0;
@@ -135,16 +148,22 @@ if (!class_exists("nxs_snapClassPK")) { class nxs_snapClassPK {
135
  }
136
  //#### Show Post->Edit Meta Box Settings
137
  function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
138
- foreach($ntOpts as $ii=>$options) {$pMeta = maybe_unserialize(get_post_meta($post_id, 'snapPK', true)); if (is_array($pMeta)) $options = $this->adjMetaOpt($options, $pMeta[$ii]); $doPK = $options['doPK'];
139
  $isAvailPK = isset($options['pkAccessTocken']) && isset($options['pkAccessTocken']['oauth_token_secret']) && $options['pkAccessTocken']['oauth_token_secret']!=='';
140
  $pkMsgFormat = htmlentities($options['pkMsgFormat'], ENT_COMPAT, "UTF-8"); $pkMsgTFormat = htmlentities($options['pkMsgTFormat'], ENT_COMPAT, "UTF-8");
141
  ?>
142
 
143
- <tr><th style="text-align:left;" colspan="2">
144
- <?php if ($isAvailPK) { ?><input class="nxsGrpDoChb" value="1" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="pk[<?php echo $ii; ?>][SNAPincludePK]" <?php if (($post->post_status == "publish" && $options['isPosted'] == '1') || ($post->post_status != "publish" && ((int)$doPK == 1)) ) echo 'checked="checked" title="def"'; ?> /> <?php } ?>
145
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/pk16.png);">Plurk - publish to (<i style="color: #005800;"><?php echo $options['nName']; ?></i>) </div></th><td><?php //## Only show RePost button if the post is "published"
146
  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', 're-post') ?>" />
147
  <?php wp_nonce_field( 'rePostToPK', 'rePostToPK_wpnonce' ); } ?>
 
 
 
 
 
 
148
  </td></tr>
149
  <?php if (!$isAvailPK) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup and authorize your Plurk Account to AutoPost to Plurk</b>
150
  <?php }elseif ($post->post_status != "puZblish") { ?>
@@ -178,14 +197,14 @@ if (!class_exists("nxs_snapClassPK")) { class nxs_snapClassPK {
178
  if (!function_exists("nxs_rePostToPK_ajax")) { function nxs_rePostToPK_ajax() { check_ajax_referer('rePostToPK'); $postID = $_POST['id']; // $result = nsPublishTo($id, 'FB', true);
179
  $options = get_option('NS_SNAutoPoster'); foreach ($options['pk'] as $ii=>$po) if ($ii==$_POST['nid']) { $po['ii'] = $ii; $po['pType'] = 'aj';
180
  $mpo = get_post_meta($postID, 'snapPK', true); $mpo = maybe_unserialize($mpo);
181
- if (is_array($mpo) && isset($mpo[$ii]) && is_array($mpo[$ii]) ){ $ntClInst = new nxs_snapClassPN(); $po = $ntClInst->adjMetaOpt($po, $mpo[$ii]); }
182
  $result = nxs_doPublishToPK($postID, $po); if ($result == 200 || $result == 201) die("Your post has been successfully sent to Plurk."); else { echo $result; die(); }
183
  }
184
  }
185
  }
186
 
187
  if (!function_exists("nxs_doPublishToPK")) { //## Second Function to Post to TR
188
- function nxs_doPublishToPK($postID, $options){ $ntCd = 'PK'; $ntCdL = 'pk'; $ntNm = 'Plurk';
189
 
190
  $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url();
191
 
@@ -241,11 +260,12 @@ if (!function_exists("nxs_doPublishToPK")) { //## Second Function to Post to TR
241
  $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
242
  $extInfo = ' | PostID: '.$postID." - ".$post->post_title; $logNT = '<span style="color:#014A76">Plurk</span> - '.$options['nName'];
243
  $postArr = array('content'=>$msg, 'qualifier'=>$options['pkCat']);
244
- $postinfo = $tum_oauth->makeReq('http://www.plurk.com/APP/Timeline/plurkAdd', $postArr);
 
245
 
246
  $code = $tum_oauth->http_code;// echo "XX".print_r($code); prr($postinfo); // prr($msg); prr($postinfo); echo $code."VVVV"; die("|====");
247
  if ($code == 200) { if ($postID=='0') { nxs_addToLog($logNT, 'M', 'OK - TEST Message Posted '); echo 'OK - Message Posted, please see your Plurk Page. <br/> Result:'; prr($postinfo); }
248
- else { nxs_addToLog($logNT, 'M', 'OK - Message Posted ', $extInfo); nxs_metaMarkAsPosted($postID, 'PK', $options['ii']); } }
249
  else { nxs_addToLog($logNT, 'E', '-=ERROR=- '.print_r($postinfo, true), $extInfo); if ($postID=='0') prr($postinfo); $code .= " ERROR: - ".$postinfo['error_text']; }
250
 
251
  return $code;
67
  <div style="width:100%;"><strong>Account Nickname:</strong> <i>Just so you can easely identify it</i> </div><input name="pk[<?php echo $ii; ?>][nName]" id="pknName<?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")), 'NS_SNAutoPoster') ?>" /><br/>
68
  <?php echo nxs_addQTranslSel('pk', $ii, $options['qTLng']); ?><?php echo nxs_addPostingDelaySel('pk', $ii, $options['nHrs'], $options['nMin']); ?>
69
 
70
+ <?php if (!$isNew) { ?>
71
+ <div style="width:100%;"><strong>Auto-Post Categories:</strong>
72
+ <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="pk[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
73
+ <input value="1" id="catSelSPK<?php echo $ii; ?>" type="radio" name="pk[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_PK<?php echo $ii; ?>" onclick="jQuery('#catSelSPK<?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('PK<?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_PK<?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>
74
+ <input type="hidden" name="pk[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_PK<?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
75
+ </div>
76
+ <br/>
77
+ <?php } ?>
78
+
79
  <div style="width:100%;"><strong>Your Plurk URL:</strong> </div><input onchange="nxsPKURLVal(<?php echo $ii; ?>);" name="pk[<?php echo $ii; ?>][apPKURL]" id="apPKURL<?php echo $ii; ?>" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['pkURL'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" /><span style="color: #F00000;" id="apPKURLerr<?php echo $ii; ?>"></span>
80
  <div style="width:100%;"><strong>Your Plurk App Key:</strong> </div><input name="pk[<?php echo $ii; ?>][apPKConsKey]" id="apPKConsKey" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['pkConsKey'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" />
81
  <div style="width:100%;"><strong>Your Plurk App Secret:</strong> </div><input name="pk[<?php echo $ii; ?>][apPKConsSec]" id="apPKConsSec" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['pkConsSec'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" />
133
  if (isset($pval['apDoPK'])) $options[$ii]['doPK'] = $pval['apDoPK']; else $options[$ii]['doPK'] = 0;
134
  if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']);
135
  if (isset($pval['apPKConsKey'])) $options[$ii]['pkConsKey'] = trim($pval['apPKConsKey']);
136
+ if (isset($pval['apPKConsSec'])) $options[$ii]['pkConsSec'] = trim($pval['apPKConsSec']);
137
+
138
+ if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']);
139
+ if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
140
+
141
  if (isset($pval['apPKMsgFrmt'])) $options[$ii]['pkMsgFormat'] = trim($pval['apPKMsgFrmt']);
142
  if (isset($pval['Cat'])) $options[$ii]['pkCat'] = $pval['Cat']; else $options[$ii]['pkCat'] = "";
143
  if (isset($pval['attchImg'])) $options[$ii]['attchImg'] = $pval['attchImg']; else $options[$ii]['attchImg'] = 0;
148
  }
149
  //#### Show Post->Edit Meta Box Settings
150
  function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
151
+ foreach($ntOpts as $ii=>$options) {$pMeta = maybe_unserialize(get_post_meta($post_id, 'snapPK', true)); if (is_array($pMeta)) $options = $this->adjMetaOpt($options, $pMeta[$ii]); $doPK = $options['doPK'] && $options['catSel']!='1';
152
  $isAvailPK = isset($options['pkAccessTocken']) && isset($options['pkAccessTocken']['oauth_token_secret']) && $options['pkAccessTocken']['oauth_token_secret']!=='';
153
  $pkMsgFormat = htmlentities($options['pkMsgFormat'], ENT_COMPAT, "UTF-8"); $pkMsgTFormat = htmlentities($options['pkMsgTFormat'], ENT_COMPAT, "UTF-8");
154
  ?>
155
 
156
+ <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 } ?>
157
+ <?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; ?>][SNAPincludePK]" <?php if (($post->post_status == "publish" && $options['isPosted'] == '1') || ($post->post_status != "publish" && ((int)$doPK == 1)) ) echo 'checked="checked" title="def"'; ?> /> <?php } ?>
158
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/pk16.png);">Plurk - publish to (<i style="color: #005800;"><?php echo $options['nName']; ?></i>) </div></th><td><?php //## Only show RePost button if the post is "published"
159
  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', 're-post') ?>" />
160
  <?php wp_nonce_field( 'rePostToPK', 'rePostToPK_wpnonce' ); } ?>
161
+
162
+ <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
163
+ ?> <span id="pstdPK<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
164
+ <a style="font-size: 10px;" href="http://www.plurk.com/p/<?php echo base_convert($pMeta[$ii]['pgID'], 10, 36); ?>" target="_blank">Posted on Plurk <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
165
+ </span><?php } ?>
166
+
167
  </td></tr>
168
  <?php if (!$isAvailPK) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup and authorize your Plurk Account to AutoPost to Plurk</b>
169
  <?php }elseif ($post->post_status != "puZblish") { ?>
197
  if (!function_exists("nxs_rePostToPK_ajax")) { function nxs_rePostToPK_ajax() { check_ajax_referer('rePostToPK'); $postID = $_POST['id']; // $result = nsPublishTo($id, 'FB', true);
198
  $options = get_option('NS_SNAutoPoster'); foreach ($options['pk'] as $ii=>$po) if ($ii==$_POST['nid']) { $po['ii'] = $ii; $po['pType'] = 'aj';
199
  $mpo = get_post_meta($postID, 'snapPK', true); $mpo = maybe_unserialize($mpo);
200
+ if (is_array($mpo) && isset($mpo[$ii]) && is_array($mpo[$ii]) ){ $ntClInst = new nxs_snapClassPK(); $po = $ntClInst->adjMetaOpt($po, $mpo[$ii]); }
201
  $result = nxs_doPublishToPK($postID, $po); if ($result == 200 || $result == 201) die("Your post has been successfully sent to Plurk."); else { echo $result; die(); }
202
  }
203
  }
204
  }
205
 
206
  if (!function_exists("nxs_doPublishToPK")) { //## Second Function to Post to TR
207
+ function nxs_doPublishToPK($postID, $options){ $ntCd = 'PK'; $ntCdL = 'pk'; $ntNm = 'Plurk';
208
 
209
  $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url();
210
 
260
  $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
261
  $extInfo = ' | PostID: '.$postID." - ".$post->post_title; $logNT = '<span style="color:#014A76">Plurk</span> - '.$options['nName'];
262
  $postArr = array('content'=>$msg, 'qualifier'=>$options['pkCat']);
263
+ $postinfo = $tum_oauth->makeReq('http://www.plurk.com/APP/Timeline/plurkAdd', $postArr); // prr($postinfo);
264
+ if (is_array($postinfo) && isset($postinfo['plurk_id'])) $pkID = $postinfo['plurk_id'];
265
 
266
  $code = $tum_oauth->http_code;// echo "XX".print_r($code); prr($postinfo); // prr($msg); prr($postinfo); echo $code."VVVV"; die("|====");
267
  if ($code == 200) { if ($postID=='0') { nxs_addToLog($logNT, 'M', 'OK - TEST Message Posted '); echo 'OK - Message Posted, please see your Plurk Page. <br/> Result:'; prr($postinfo); }
268
+ else { nxs_addToLog($logNT, 'M', 'OK - Message Posted ', $extInfo); nxs_metaMarkAsPosted($postID, 'PK', $options['ii'], array('isPosted'=>'1', 'pgID'=>$pkID, 'pDate'=>date('Y-m-d H:i:s'))); } }
269
  else { nxs_addToLog($logNT, 'E', '-=ERROR=- '.print_r($postinfo, true), $extInfo); if ($postID=='0') prr($postinfo); $code .= " ERROR: - ".$postinfo['error_text']; }
270
 
271
  return $code;
inc-cl/pn.php CHANGED
@@ -41,6 +41,15 @@ if (!class_exists("nxs_snapClassPN")) { class nxs_snapClassPN {
41
  <div id="doPN<?php echo $ii; ?>Div" style="margin-left: 10px;"> <div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/pn16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-pinterest-social-networks-auto-poster-wordpress/">Detailed Pinterest Installation/Configuration Instructions</a></div>
42
  <div style="width:100%;"><strong>Account Nickname:</strong> <i>Just so you can easely identify it</i> </div><input name="pn[<?php echo $ii; ?>][nName]" id="pnnName<?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")), 'NS_SNAutoPoster') ?>" /><br/>
43
  <?php echo nxs_addQTranslSel('pn', $ii, $options['qTLng']); ?><?php echo nxs_addPostingDelaySel('pn', $ii, $options['nHrs'], $options['nMin']); ?>
 
 
 
 
 
 
 
 
 
44
 
45
  <div style="width:100%;"><strong>Pinterest Email:</strong> </div><input name="pn[<?php echo $ii; ?>][apPNUName]" id="apPNUName<?php echo $ii; ?>" class="apPNUName<?php echo $ii; ?>" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['pnUName'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" />
46
  <div style="width:100%;"><strong>Pinterest Password:</strong> </div><input name="pn[<?php echo $ii; ?>][apPNPass]" id="apPNPass<?php echo $ii; ?>" type="password" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities(substr($options['pnPass'], 0, 5)=='g9c1a'?nsx_doDecode(substr($options['pnPass'], 5)):$options['pnPass'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" /> <br/>
@@ -89,6 +98,10 @@ if (!class_exists("nxs_snapClassPN")) { class nxs_snapClassPN {
89
  if (isset($pval['apPNPass'])) $options[$ii]['pnPass'] = 'g9c1a'.nsx_doEncode($pval['apPNPass']); else $options[$ii]['pnPass'] = '';
90
  if (isset($pval['apPNBoard'])) $options[$ii]['pnBoard'] = trim($pval['apPNBoard']);
91
  if (isset($pval['apPNDefImg'])) $options[$ii]['pnDefImg'] = trim($pval['apPNDefImg']);
 
 
 
 
92
  if (isset($pval['apPNMsgFrmt'])) $options[$ii]['pnMsgFormat'] = trim($pval['apPNMsgFrmt']);
93
  if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
94
  if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
@@ -97,14 +110,20 @@ if (!class_exists("nxs_snapClassPN")) { class nxs_snapClassPN {
97
  }
98
  //#### Show Post->Edit Meta Box Settings
99
  function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
100
- foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapPN', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]); $doPN = $ntOpt['doPN'];
101
  $isAvailPN = $ntOpt['pnUName']!='' && $ntOpt['pnPass']!=''; $pnMsgFormat = htmlentities($ntOpt['pnMsgFormat'], ENT_COMPAT, "UTF-8");
102
  ?>
103
- <tr><th style="text-align:left;" colspan="2">
104
- <?php if ($isAvailPN) { ?><input class="nxsGrpDoChb" value="1" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="pn[<?php echo $ii; ?>][SNAPincludePN]" <?php if (($post->post_status == "publish" && $ntOpt['isPosted'] == '1') || ($post->post_status != "publish" && ((int)$doPN == 1)) ) echo 'checked="checked" title="def"'; ?> /> <?php } ?>
105
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/pn16.png);">Pinterest - publish to (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
106
  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', 're-post') ?>" />
107
  <?php wp_nonce_field( 'rePostToPN', 'rePostToPN_wpnonce' ); } ?>
 
 
 
 
 
 
108
  </td></tr>
109
 
110
  <?php if (!$isAvailPN) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your Pinterest Account to AutoPost to Pinterest</b>
@@ -145,34 +164,33 @@ if (!function_exists("nxs_doPublishToPN")) { //## Second Function to Post to G+
145
  function nxs_doPublishToPN($postID, $options){ global $nxs_gCookiesArr; $ntCd = 'PN'; $ntCdL = 'pn'; $ntNm = 'Pinterest';
146
 
147
  $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10)); $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
 
148
  if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
149
  nxs_addToLog($ntCd.' - '.$options['nName'], 'E', '-=Duplicate=- Post ID:'.$postID, 'Not posted. No reason for posting duplicate'); return;
150
- }
151
-
152
  $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url();
 
153
  if ($postID=='0') { echo "Testing ... <br/><br/>"; $msg = 'Test Post from '.$blogTitle; $link = home_url();
154
  if ($options['pnDefImg']!='') $imgURL = $options['pnDefImg']; else $imgURL ="http://direct.gtln.us/img/nxs/NextScriptsLogoT.png";
155
  }
156
  else { $post = get_post($postID); if(!$post) return; $pnMsgFormat = $options['pnMsgFormat']; $msg = nsFormatMessage($pnMsgFormat, $postID); $link = get_permalink($postID);
157
- nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1')); $imgURL = nxs_getPostImage($postID, 'large', $options['ogImgDef']); // echo "WW".$postID."|";
158
- }
159
-
160
- $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();
161
-
162
  if (isset($options['pnSvC'])) $nxs_gCookiesArr = maybe_unserialize( $options['pnSvC']); $loginError = true;
163
  if (is_array($nxs_gCookiesArr)) $loginError = doCheckPinterest();
164
  $extInfo = ' | PostID: '.$postID." - ".$post->post_title; $logNT = '<span style="color:#FA5069">Pinterest</span> - '.$options['nName'];
165
- if ($loginError!==false) $loginError = doConnectToPinterest($email, $pass); if ($loginError!==false) {echo $loginError; nxs_addToLog($logNT, 'E', '-=ERROR=- '.print_r($loginError, true), $extInfo); return "BAD USER/PASS";}
166
-
167
  if (serialize($nxs_gCookiesArr)!=$options['pnSvC']) { global $plgn_NS_SNAutoPoster; $gOptions = $plgn_NS_SNAutoPoster->nxs_options; // prr($gOptions['pn']);
168
  if (isset($options['ii']) && $options['ii']!=='') { $gOptions['pn'][$options['ii']]['pnSvC'] = serialize($nxs_gCookiesArr); update_option('NS_SNAutoPoster', $gOptions); }
169
  else foreach ($gOptions['pn'] as $ii=>$gpn) { $result = array_diff($options, $gpn);
170
  if (!is_array($result) || count($result)<1) { $gOptions['pn'][$ii]['pnSvC'] = serialize($nxs_gCookiesArr); update_option('NS_SNAutoPoster', $gOptions); break; }
171
  }
172
  } // echo "PN SET:".$msg."|".$imgURL."|".$link."|".$boardID;
173
- $ret = doPostToPinterest($msg, $imgURL, $link, $boardID);
174
- if ($ret!='OK') { if ($postID=='0') echo $ret; nxs_addToLog($logNT, 'E', '-=ERROR=- '.print_r($ret, true), $extInfo); } else { if ($postID=='0') { nxs_addToLog($logNT, 'M', 'OK - TEST Message Posted '); echo 'OK - Message Posted, please see your Pinterest Page'; } else { nxs_metaMarkAsPosted($postID, 'PN', $options['ii']); nxs_addToLog($logNT, 'M', 'OK - Message Posted ', $extInfo);} }
175
- if ($ret == 'OK') return 200; else return $ret;
176
  }
177
  }
178
  ?>
41
  <div id="doPN<?php echo $ii; ?>Div" style="margin-left: 10px;"> <div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/pn16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-pinterest-social-networks-auto-poster-wordpress/">Detailed Pinterest Installation/Configuration Instructions</a></div>
42
  <div style="width:100%;"><strong>Account Nickname:</strong> <i>Just so you can easely identify it</i> </div><input name="pn[<?php echo $ii; ?>][nName]" id="pnnName<?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")), 'NS_SNAutoPoster') ?>" /><br/>
43
  <?php echo nxs_addQTranslSel('pn', $ii, $options['qTLng']); ?><?php echo nxs_addPostingDelaySel('pn', $ii, $options['nHrs'], $options['nMin']); ?>
44
+
45
+ <?php if (!$isNew) { ?>
46
+ <div style="width:100%;"><strong>Auto-Post Categories:</strong>
47
+ <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="pn[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
48
+ <input value="1" id="catSelSPN<?php echo $ii; ?>" type="radio" name="pn[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_PN<?php echo $ii; ?>" onclick="jQuery('#catSelSPN<?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('PN<?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_PN<?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>
49
+ <input type="hidden" name="pn[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_PN<?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
50
+ </div>
51
+ <br/>
52
+ <?php } ?>
53
 
54
  <div style="width:100%;"><strong>Pinterest Email:</strong> </div><input name="pn[<?php echo $ii; ?>][apPNUName]" id="apPNUName<?php echo $ii; ?>" class="apPNUName<?php echo $ii; ?>" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['pnUName'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" />
55
  <div style="width:100%;"><strong>Pinterest Password:</strong> </div><input name="pn[<?php echo $ii; ?>][apPNPass]" id="apPNPass<?php echo $ii; ?>" type="password" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities(substr($options['pnPass'], 0, 5)=='g9c1a'?nsx_doDecode(substr($options['pnPass'], 5)):$options['pnPass'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" /> <br/>
98
  if (isset($pval['apPNPass'])) $options[$ii]['pnPass'] = 'g9c1a'.nsx_doEncode($pval['apPNPass']); else $options[$ii]['pnPass'] = '';
99
  if (isset($pval['apPNBoard'])) $options[$ii]['pnBoard'] = trim($pval['apPNBoard']);
100
  if (isset($pval['apPNDefImg'])) $options[$ii]['pnDefImg'] = trim($pval['apPNDefImg']);
101
+
102
+ if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']);
103
+ if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
104
+
105
  if (isset($pval['apPNMsgFrmt'])) $options[$ii]['pnMsgFormat'] = trim($pval['apPNMsgFrmt']);
106
  if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
107
  if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
110
  }
111
  //#### Show Post->Edit Meta Box Settings
112
  function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
113
+ foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapPN', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]); $doPN = $ntOpt['doPN'] && $ntOpt['catSel']!='1';
114
  $isAvailPN = $ntOpt['pnUName']!='' && $ntOpt['pnPass']!=''; $pnMsgFormat = htmlentities($ntOpt['pnMsgFormat'], 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_PN<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
117
+ <?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; ?>][SNAPincludePN]" <?php if (($post->post_status == "publish" && $ntOpt['isPosted'] == '1') || ($post->post_status != "publish" && ((int)$doPN == 1)) ) echo 'checked="checked" title="def"'; ?> /> <?php } ?>
118
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/pn16.png);">Pinterest - publish to (<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" && $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', 're-post') ?>" />
120
  <?php wp_nonce_field( 'rePostToPN', 'rePostToPN_wpnonce' ); } ?>
121
+
122
+ <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
123
+ ?> <span id="pstdPN<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
124
+ <a style="font-size: 10px;" href="http://pinterest.com<?php echo $pMeta[$ii]['pgID']; ?>" target="_blank">Posted on Pinterest <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
125
+ </span><?php } ?>
126
+
127
  </td></tr>
128
 
129
  <?php if (!$isAvailPN) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your Pinterest Account to AutoPost to Pinterest</b>
164
  function nxs_doPublishToPN($postID, $options){ global $nxs_gCookiesArr; $ntCd = 'PN'; $ntCdL = 'pn'; $ntNm = 'Pinterest';
165
 
166
  $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10)); $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
167
+ $isAttachVid = $options['isAttachVid']; $isAttachVid = '1';
168
  if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
169
  nxs_addToLog($ntCd.' - '.$options['nName'], 'E', '-=Duplicate=- Post ID:'.$postID, 'Not posted. No reason for posting duplicate'); return;
170
+ }
 
171
  $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url();
172
+
173
  if ($postID=='0') { echo "Testing ... <br/><br/>"; $msg = 'Test Post from '.$blogTitle; $link = home_url();
174
  if ($options['pnDefImg']!='') $imgURL = $options['pnDefImg']; else $imgURL ="http://direct.gtln.us/img/nxs/NextScriptsLogoT.png";
175
  }
176
  else { $post = get_post($postID); if(!$post) return; $pnMsgFormat = $options['pnMsgFormat']; $msg = nsFormatMessage($pnMsgFormat, $postID); $link = get_permalink($postID);
177
+ nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1')); $imgURL = nxs_getPostImage($postID, 'large', $options['ogImgDef']); //echo $imgURL."######"; // echo "WW".$postID."|";
178
+ if ($isAttachVid=='1') { $vids = nsFindVidsInPost($post); if (count($vids)>0) { $vidURL = 'http://www.youtube.com/v/'.$vids[0]; $imgURL = 'http://img.youtube.com/vi/'.$vids[0].'/0.jpg'; }}
179
+ }
180
+ $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();
 
181
  if (isset($options['pnSvC'])) $nxs_gCookiesArr = maybe_unserialize( $options['pnSvC']); $loginError = true;
182
  if (is_array($nxs_gCookiesArr)) $loginError = doCheckPinterest();
183
  $extInfo = ' | PostID: '.$postID." - ".$post->post_title; $logNT = '<span style="color:#FA5069">Pinterest</span> - '.$options['nName'];
184
+ if ($loginError!==false) $loginError = doConnectToPinterest($email, $pass); if ($loginError!==false) {echo $loginError; nxs_addToLog($logNT, 'E', '-=ERROR=- '.print_r($loginError, true), $extInfo); return "BAD USER/PASS";}
 
185
  if (serialize($nxs_gCookiesArr)!=$options['pnSvC']) { global $plgn_NS_SNAutoPoster; $gOptions = $plgn_NS_SNAutoPoster->nxs_options; // prr($gOptions['pn']);
186
  if (isset($options['ii']) && $options['ii']!=='') { $gOptions['pn'][$options['ii']]['pnSvC'] = serialize($nxs_gCookiesArr); update_option('NS_SNAutoPoster', $gOptions); }
187
  else foreach ($gOptions['pn'] as $ii=>$gpn) { $result = array_diff($options, $gpn);
188
  if (!is_array($result) || count($result)<1) { $gOptions['pn'][$ii]['pnSvC'] = serialize($nxs_gCookiesArr); update_option('NS_SNAutoPoster', $gOptions); break; }
189
  }
190
  } // echo "PN SET:".$msg."|".$imgURL."|".$link."|".$boardID;
191
+ $ret = doPostToPinterest($msg, $imgURL, $link, $boardID); if ($ret=='OK') $ret = array("code"=>"OK", "post_id"=>'');
192
+ if ( (!is_array($ret)) && $ret!='OK') { if ($postID=='0') echo $ret; nxs_addToLog($logNT, 'E', '-=ERROR=- '.print_r($ret, true), $extInfo); } else { if ($postID=='0') { nxs_addToLog($logNT, 'M', '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_addToLog($logNT, 'M', 'OK - Message Posted ', $extInfo);} }
193
+ if ($ret['code']=='OK') return 200; else return $ret;
194
  }
195
  }
196
  ?>
inc-cl/su.php CHANGED
@@ -33,6 +33,15 @@ if (!class_exists("nxs_snapClassSU")) { class nxs_snapClassSU {
33
  <div style="width:100%;"><strong>Account Nickname:</strong> <i>Just so you can easely identify it</i> </div><input name="su[<?php echo $ii; ?>][nName]" id="sunName<?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")), 'NS_SNAutoPoster') ?>" /><br/>
34
  <?php echo nxs_addQTranslSel('su', $ii, $options['qTLng']); ?><?php echo nxs_addPostingDelaySel('su', $ii, $options['nHrs'], $options['nMin']); ?>
35
 
 
 
 
 
 
 
 
 
 
36
  <div style="width:100%;"><strong>StumbleUpon Username:</strong> </div><input name="su[<?php echo $ii; ?>][apSUUName]" id="apSUUName" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['suUName'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" />
37
  <div style="width:100%;"><strong>StumbleUpon Password:</strong> </div><input name="su[<?php echo $ii; ?>][apSUPass]" id="apSUPass" type="password" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities(substr($options['suPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['suPass'], 5)):$options['suPass'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" /> <br/>
38
 
@@ -77,7 +86,11 @@ if (!class_exists("nxs_snapClassSU")) { class nxs_snapClassSU {
77
  if (isset($pval['apSUPass'])) $options[$ii]['suPass'] = 'n5g9a'.nsx_doEncode($pval['apSUPass']); else $options[$ii]['suPass'] = '';
78
  if (isset($pval['apSUCat'])) $options[$ii]['suCat'] = trim($pval['apSUCat']);
79
  if (isset($pval['suInclTags'])) $options[$ii]['suInclTags'] = $pval['suInclTags']; else $options[$ii]['suInclTags'] = 0;
80
- if (isset($pval['apSUMsgFrmt'])) $options[$ii]['suMsgFormat'] = trim($pval['apSUMsgFrmt']);
 
 
 
 
81
  if (isset($pval['apDoSU'])) $options[$ii]['doSU'] = $pval['apDoSU']; else $options[$ii]['doSU'] = 0;
82
  if (isset($pval['nsfw'])) $options[$ii]['nsfw'] = $pval['nsfw']; else $options[$ii]['nsfw'] = 0;
83
  if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
@@ -87,15 +100,21 @@ if (!class_exists("nxs_snapClassSU")) { class nxs_snapClassSU {
87
  }
88
  //#### Show Post->Edit Meta Box Settings
89
  function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
90
- foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapSU', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]); $doSU = $ntOpt['doSU'];
91
  $isAvailSU = $ntOpt['suUName']!='' && $ntOpt['suPass']!=''; $suMsgFormat = htmlentities($ntOpt['suMsgFormat'], ENT_COMPAT, "UTF-8"); $suMsgTFormat = htmlentities($ntOpt['suMsgTFormat'], ENT_COMPAT, "UTF-8");
92
  ?>
93
- <tr><th style="text-align:left;" colspan="2">
94
- <?php if ($isAvailSU) { ?><input class="nxsGrpDoChb" value="1" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="su[<?php echo $ii; ?>][SNAPincludeSU]" <?php if (($post->post_status == "publish" && $ntOpt['isPosted'] == '1') || ($post->post_status != "publish" && ((int)$doSU == 1)) ) echo 'checked="checked" title="def"'; ?> /> <?php } ?>
95
 
96
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/su16.png);">StumbleUpon - publish to (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
97
  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', 're-post') ?>" />
98
  <?php wp_nonce_field( 'rePostToSU', 'rePostToSU_wpnonce' ); } ?>
 
 
 
 
 
 
99
  </td></tr>
100
 
101
  <?php if (!$isAvailSU) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your StumbleUpon Account to AutoPost to StumbleUpon</b>
@@ -129,7 +148,7 @@ if (!function_exists("nxs_rePostToSU_ajax")) {
129
  function nxs_rePostToSU_ajax() { check_ajax_referer('rePostToSU'); $postID = $_POST['id']; $options = get_option('NS_SNAutoPoster');
130
  foreach ($options['su'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj'; //if ($two['gpPageID'].$two['gpUName']==$_POST['nid']) {
131
  $gppo = get_post_meta($postID, 'snapSU', true); $gppo = maybe_unserialize($gppo);// prr($gppo);
132
- if (is_array($gppo) && isset($gppo[$ii]) && is_array($gppo[$ii])){ $ntClInst = new nxs_snapClassPN(); $two = $ntClInst->adjMetaOpt($two, $gppo[$ii]); }
133
  $result = nxs_doPublishToSU($postID, $two); if ($result == 200) die("Successfully sent your post to StumbleUpon."); else die($result);
134
  }
135
  }
@@ -137,24 +156,26 @@ if (!function_exists("nxs_rePostToSU_ajax")) {
137
 
138
  if (!function_exists("nxs_getSUHeaders")) { function nxs_getSUHeaders($ref, $post=false){ $hdrsArr = array();
139
  $hdrsArr['X-Requested-With']='XMLHttpRequest'; $hdrsArr['Connection']='keep-alive'; $hdrsArr['Referer']=$ref;
140
- $hdrsArr['User-Agent']='Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.22 Safari/537.11';
141
  if($post) $hdrsArr['Content-Type']='application/x-www-form-urlencoded';
142
  $hdrsArr['Accept']='application/json, text/javascript, */*; q=0.01'; $hdrsArr['Origin']='http://www.stumbleupon.com';
143
-
144
  $hdrsArr['Accept-Encoding']='gzip,deflate,sdch'; $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;
145
  }}
146
  if (!function_exists("nxs_doCheckSU")) {function nxs_doCheckSU(){ global $nxs_suCkArray; $hdrsArr = nxs_getSUHeaders('https://www.stumbleupon.com/submit'); $ckArr = $nxs_suCkArray;
147
  $response = wp_remote_get('http://www.stumbleupon.com/submit', array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr));
148
  $response['body'] = htmlentities($response['body'], ENT_COMPAT, "UTF-8"); // $response['body'] = htmlentities($response['body']); prr($response); die();
149
  if (isset($response['headers']['location']) && $response['headers']['location']=='/submit/visitor') return 'Bad Saved Login';
150
- if ( $response['response']['code']=='200' && stripos($response['body'], 'Add a New Page')!==false){ /*echo "You are IN"; */ return false;
 
 
 
151
  } else return 'No Saved Login';
152
  return false;
153
  }}
154
- if (!function_exists("nxs_doConnectToSU")) { function nxs_doConnectToSU($u, $p){ global $nxs_suCkArray; $hdrsArr = nxs_getSUHeaders('https://www.stumbleupon.com/login', true); echo "LOGGIN";
155
  $response = wp_remote_get('https://www.stumbleupon.com/login'); $contents = $response['body']; //$response['body'] = htmlentities($response['body']); prr($response); die();
156
  $ckArr = $response['cookies'];
157
- $frmTxt = CutFromTo($contents, '<form id="login-form"','</form>'); $md = array(); $flds = array(); prr($frmTxt);
158
  while (stripos($frmTxt, '<input')!==false){ $inpField = trim(CutFromTo($frmTxt,'<input', '>')); $name = trim(CutFromTo($inpField,'name="', '"'));
159
  if ( stripos($inpField, '"hidden"')!==false && $name!='' && !in_array($name, $md)) { $md[] = $name; $val = trim(CutFromTo($inpField,'value="', '"')); $flds[$name]= $val; $mids .= "&".$name."=".$val;}
160
  $frmTxt = substr($frmTxt, stripos($frmTxt, '<input')+8);
@@ -165,19 +186,40 @@ if (!function_exists("nxs_doConnectToSU")) { function nxs_doConnectToSU($u, $p)
165
  $resp = json_decode($r2['body'], true);
166
  if ($resp['_success']=='1') { $ckArr = nxsMergeArraysOV($ckArr, $r2['cookies']); $nxs_suCkArray = $ckArr; return false; } elseif (isset($resp['_reason'])) { return $resp['_reason']; } else return "ERROR";
167
  }}
168
- if (!function_exists("nxs_doPostToSU")) { function nxs_doPostToSU($msg, $lnk, $cat, $tags, $nsfw=false){ global $nxs_suCkArray; $hdrsArr = nxs_getSUHeaders('https://www.stumbleupon.com/submit'); $ckArr = $nxs_suCkArray;
 
169
  $response = wp_remote_get('http://www.stumbleupon.com/submit', array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr));
 
 
170
  $contents = $response['body']; //$response['body'] = htmlentities($response['body']); prr($response);
171
  //$ckArr = nxsMergeArraysOV($ckArr, $response['cookies']);
172
- $hdrsArr = nxs_getSUHeaders('https://www.stumbleupon.com/submit', true);
173
- $frmTxt = CutFromTo($contents, '<form method="post" id="submit-form"','</form>'); $md = array(); $flds = array();
174
  while (stripos($frmTxt, '<input')!==false){ $inpField = trim(CutFromTo($frmTxt,'<input', '>')); $name = trim(CutFromTo($inpField,'name="', '"'));
175
  if ( stripos($inpField, '"hidden"')!==false && $name!='' && !in_array($name, $md)) { $md[] = $name; $val = trim(CutFromTo($inpField,'value="', '"')); $flds[$name]= $val; $mids .= "&".$name."=".$val;}
176
  $frmTxt = substr($frmTxt, stripos($frmTxt, '<input')+8);
177
  } $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';
178
- $r2 = wp_remote_get($lnk); $r2 = wp_remote_post( 'http://www.stumbleupon.com/submit', array( 'method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds, 'cookies' => $ckArr));
179
- $resp = json_decode($r2['body'], true); // prr($flds); prr($resp); nxs_addToLog('SU', 'E', '-=DBG=- '.print_r($resp, true)." - #####", $extInfo);
180
- if ($resp['_success']=='1') { $ckArr = nxsMergeArraysOV($ckArr, $r2['cookies']); $nxs_suCkArray = $ckArr; return 'OK'; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  elseif (isset($resp['_reason'])) { $resp['_reason']['NXS_FIELDS'] = $flds; $resp['_reason']['NXS_RESP'] = $resp; return $resp['_reason']; } else return "ERROR".print_r($resp, true);
182
  }}
183
 
@@ -193,7 +235,7 @@ if (!function_exists("nxs_doPublishToSU")) { //## Second Function to Post to SU
193
  $email = $options['suUName']; $pass = (substr($options['suPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['suPass'], 5)):$options['suPass']);
194
  if ($postID=='0') { echo "Testing ... <br/><br/>"; $link = home_url(); $msg = 'Test Link from '.$link; } else { $post = get_post($postID); if(!$post) return;
195
  $msgFormat = $options['suMsgFormat']; $msg = nsFormatMessage($msgFormat, $postID); $link = get_permalink($postID); nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
196
- }
197
  $dusername = $options['suUName']; //$link = urlencode($link); $desc = urlencode(substr($msg, 0, 500));
198
  $extInfo = ' | PostID: '.$postID." - ".$post->post_title; $logNT = '<span style="color:#000080">StumbleUpon</span> - '.$options['nName'];
199
  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 = '';
@@ -206,10 +248,18 @@ if (!function_exists("nxs_doPublishToSU")) { //## Second Function to Post to SU
206
  }
207
  }
208
  if ($loginError!==false) {if ($postID=='0') prr($loginError); nxs_addToLog($logNT, 'E', '-=ERROR=- '.print_r($loginError, true)." - BAD USER/PASS", $extInfo); return " -= BAD USER/PASS =- ";}
 
209
  $ret = nxs_doPostToSU($msg, $link, $options['suCat'], $tags, $options['nsfw']=='1'); // $extInfo .= "++".$msg."|".$link."|".$options['suCat']."|".$tags."|".$options['nsfw'];
210
- if ($ret!='OK') { if ($postID=='0') prr($ret); nxs_addToLog($logNT, 'E', '-=ERROR=- '.print_r($ret, true), $extInfo);}
211
- else if ($postID=='0') { nxs_addToLog($logNT, 'M', 'OK - TEST Message Posted '); echo ' OK - Message Posted, please see your StumbleUpon Page '; } else { nxs_metaMarkAsPosted($postID, 'SU', $options['ii']); nxs_addToLog($logNT, 'M', 'OK - Message Posted ', $extInfo); }
212
- if ($ret == 'OK') return 200; else return print_r($ret, true);
 
 
 
 
 
 
 
213
 
214
  }
215
  }
33
  <div style="width:100%;"><strong>Account Nickname:</strong> <i>Just so you can easely identify it</i> </div><input name="su[<?php echo $ii; ?>][nName]" id="sunName<?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")), 'NS_SNAutoPoster') ?>" /><br/>
34
  <?php echo nxs_addQTranslSel('su', $ii, $options['qTLng']); ?><?php echo nxs_addPostingDelaySel('su', $ii, $options['nHrs'], $options['nMin']); ?>
35
 
36
+ <?php if (!$isNew) { ?>
37
+ <div style="width:100%;"><strong>Auto-Post Categories:</strong>
38
+ <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="su[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
39
+ <input value="1" id="catSelSSU<?php echo $ii; ?>" type="radio" name="su[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_SU<?php echo $ii; ?>" onclick="jQuery('#catSelSSU<?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('SU<?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_SU<?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>
40
+ <input type="hidden" name="su[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_SU<?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
41
+ </div>
42
+ <br/>
43
+ <?php } ?>
44
+
45
  <div style="width:100%;"><strong>StumbleUpon Username:</strong> </div><input name="su[<?php echo $ii; ?>][apSUUName]" id="apSUUName" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['suUName'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" />
46
  <div style="width:100%;"><strong>StumbleUpon Password:</strong> </div><input name="su[<?php echo $ii; ?>][apSUPass]" id="apSUPass" type="password" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities(substr($options['suPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['suPass'], 5)):$options['suPass'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" /> <br/>
47
 
86
  if (isset($pval['apSUPass'])) $options[$ii]['suPass'] = 'n5g9a'.nsx_doEncode($pval['apSUPass']); else $options[$ii]['suPass'] = '';
87
  if (isset($pval['apSUCat'])) $options[$ii]['suCat'] = trim($pval['apSUCat']);
88
  if (isset($pval['suInclTags'])) $options[$ii]['suInclTags'] = $pval['suInclTags']; else $options[$ii]['suInclTags'] = 0;
89
+ if (isset($pval['apSUMsgFrmt'])) $options[$ii]['suMsgFormat'] = trim($pval['apSUMsgFrmt']);
90
+
91
+ if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']);
92
+ if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
93
+
94
  if (isset($pval['apDoSU'])) $options[$ii]['doSU'] = $pval['apDoSU']; else $options[$ii]['doSU'] = 0;
95
  if (isset($pval['nsfw'])) $options[$ii]['nsfw'] = $pval['nsfw']; else $options[$ii]['nsfw'] = 0;
96
  if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
100
  }
101
  //#### Show Post->Edit Meta Box Settings
102
  function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
103
+ foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapSU', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]); $doSU = $ntOpt['doSU'] && $ntOpt['catSel']!='1';
104
  $isAvailSU = $ntOpt['suUName']!='' && $ntOpt['suPass']!=''; $suMsgFormat = htmlentities($ntOpt['suMsgFormat'], ENT_COMPAT, "UTF-8"); $suMsgTFormat = htmlentities($ntOpt['suMsgTFormat'], ENT_COMPAT, "UTF-8");
105
  ?>
106
+ <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 } ?>
107
+ <?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; ?>][SNAPincludeSU]" <?php if (($post->post_status == "publish" && $ntOpt['isPosted'] == '1') || ($post->post_status != "publish" && ((int)$doSU == 1)) ) echo 'checked="checked" title="def"'; ?> /> <?php } ?>
108
 
109
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/su16.png);">StumbleUpon - publish to (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
110
  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', 're-post') ?>" />
111
  <?php wp_nonce_field( 'rePostToSU', 'rePostToSU_wpnonce' ); } ?>
112
+
113
+ <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
114
+
115
+ ?> <span id="pstdSU<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
116
+ <a style="font-size: 10px;" href="http://www.stumbleupon.com/content/<?php echo $pMeta[$ii]['pgID']; ?>" target="_blank">Posted on Stumbleupon <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
117
+ </span><?php } ?>
118
  </td></tr>
119
 
120
  <?php if (!$isAvailSU) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your StumbleUpon Account to AutoPost to StumbleUpon</b>
148
  function nxs_rePostToSU_ajax() { check_ajax_referer('rePostToSU'); $postID = $_POST['id']; $options = get_option('NS_SNAutoPoster');
149
  foreach ($options['su'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj'; //if ($two['gpPageID'].$two['gpUName']==$_POST['nid']) {
150
  $gppo = get_post_meta($postID, 'snapSU', true); $gppo = maybe_unserialize($gppo);// prr($gppo);
151
+ if (is_array($gppo) && isset($gppo[$ii]) && is_array($gppo[$ii])){ $ntClInst = new nxs_snapClassSU(); $two = $ntClInst->adjMetaOpt($two, $gppo[$ii]); }
152
  $result = nxs_doPublishToSU($postID, $two); if ($result == 200) die("Successfully sent your post to StumbleUpon."); else die($result);
153
  }
154
  }
156
 
157
  if (!function_exists("nxs_getSUHeaders")) { function nxs_getSUHeaders($ref, $post=false){ $hdrsArr = array();
158
  $hdrsArr['X-Requested-With']='XMLHttpRequest'; $hdrsArr['Connection']='keep-alive'; $hdrsArr['Referer']=$ref;
159
+ $hdrsArr['User-Agent']='Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.45 Safari/537.17';
160
  if($post) $hdrsArr['Content-Type']='application/x-www-form-urlencoded';
161
  $hdrsArr['Accept']='application/json, text/javascript, */*; q=0.01'; $hdrsArr['Origin']='http://www.stumbleupon.com';
 
162
  $hdrsArr['Accept-Encoding']='gzip,deflate,sdch'; $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;
163
  }}
164
  if (!function_exists("nxs_doCheckSU")) {function nxs_doCheckSU(){ global $nxs_suCkArray; $hdrsArr = nxs_getSUHeaders('https://www.stumbleupon.com/submit'); $ckArr = $nxs_suCkArray;
165
  $response = wp_remote_get('http://www.stumbleupon.com/submit', array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr));
166
  $response['body'] = htmlentities($response['body'], ENT_COMPAT, "UTF-8"); // $response['body'] = htmlentities($response['body']); prr($response); die();
167
  if (isset($response['headers']['location']) && $response['headers']['location']=='/submit/visitor') return 'Bad Saved Login';
168
+ if ( $response['response']['code']=='200' && stripos($response['body'], 'Add a New Page')!==false){
169
+
170
+
171
+ /*echo "You are IN"; */ return false;
172
  } else return 'No Saved Login';
173
  return false;
174
  }}
175
+ if (!function_exists("nxs_doConnectToSU")) { function nxs_doConnectToSU($u, $p){ global $nxs_suCkArray; $hdrsArr = nxs_getSUHeaders('https://www.stumbleupon.com/login', true); // echo "LOGGIN";
176
  $response = wp_remote_get('https://www.stumbleupon.com/login'); $contents = $response['body']; //$response['body'] = htmlentities($response['body']); prr($response); die();
177
  $ckArr = $response['cookies'];
178
+ $frmTxt = CutFromTo($contents, '<form id="login-form"','</form>'); $md = array(); $flds = array();// prr($frmTxt);
179
  while (stripos($frmTxt, '<input')!==false){ $inpField = trim(CutFromTo($frmTxt,'<input', '>')); $name = trim(CutFromTo($inpField,'name="', '"'));
180
  if ( stripos($inpField, '"hidden"')!==false && $name!='' && !in_array($name, $md)) { $md[] = $name; $val = trim(CutFromTo($inpField,'value="', '"')); $flds[$name]= $val; $mids .= "&".$name."=".$val;}
181
  $frmTxt = substr($frmTxt, stripos($frmTxt, '<input')+8);
186
  $resp = json_decode($r2['body'], true);
187
  if ($resp['_success']=='1') { $ckArr = nxsMergeArraysOV($ckArr, $r2['cookies']); $nxs_suCkArray = $ckArr; return false; } elseif (isset($resp['_reason'])) { return $resp['_reason']; } else return "ERROR";
188
  }}
189
+ if (!function_exists("nxs_doPostToSU")) { function nxs_doPostToSU($msg, $lnk, $cat, $tags, $nsfw=false){ global $nxs_suCkArray; $r2 = wp_remote_get($lnk);
190
+ $hdrsArr = nxs_getSUHeaders('http://www.stumbleupon.com/submit'); $ckArr = $nxs_suCkArray;
191
  $response = wp_remote_get('http://www.stumbleupon.com/submit', array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr));
192
+ $ckArr2 = nxsMergeArraysOV($ckArr, $response['cookies']); //$nxs_suCkArray = $ckArr;
193
+
194
  $contents = $response['body']; //$response['body'] = htmlentities($response['body']); prr($response);
195
  //$ckArr = nxsMergeArraysOV($ckArr, $response['cookies']);
196
+ $hdrsArr = nxs_getSUHeaders('http://www.stumbleupon.com/submit', true);
197
+ $frmTxt = CutFromTo($contents, '<form method="post" id="submit-form"','</form>'); $md = array(); $flds = array(); // prr($contents);
198
  while (stripos($frmTxt, '<input')!==false){ $inpField = trim(CutFromTo($frmTxt,'<input', '>')); $name = trim(CutFromTo($inpField,'name="', '"'));
199
  if ( stripos($inpField, '"hidden"')!==false && $name!='' && !in_array($name, $md)) { $md[] = $name; $val = trim(CutFromTo($inpField,'value="', '"')); $flds[$name]= $val; $mids .= "&".$name."=".$val;}
200
  $frmTxt = substr($frmTxt, stripos($frmTxt, '<input')+8);
201
  } $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';
202
+
203
+ $r2 = wp_remote_post('http://www.stumbleupon.com/submit', array('method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds, 'cookies' => $ckArr));
204
+ $resp = json_decode($r2['body'], true); // prr($flds); prr($resp); //nxs_addToLog('SU', 'E', '-=DBG=- '.print_r($resp, true)." - #####", $extInfo);
205
+
206
+ if (stripos($resp['_reason'][0]['message'], 'Failed to add URL')!==false) { sleep(5);
207
+ $r2 = wp_remote_post('http://www.stumbleupon.com/submit', array('method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds, 'cookies' => $ckArr));
208
+ $resp = json_decode($r2['body'], true); // prr($flds); prr($resp); //nxs_addToLog('SU', 'E', '-=DBG=- '.print_r($resp, true)." - #####", $extInfo);
209
+ }
210
+
211
+ if (stripos($resp['_error'], 'Invalid token')!==false) { // In case we got the Wrong Cookies
212
+ $r2 = wp_remote_post('http://www.stumbleupon.com/submit', array('method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds, 'cookies' => $ckArr2));
213
+ $resp = json_decode($r2['body'], true); // prr($flds); prr($resp); //nxs_addToLog('SU', 'E', '-=DBG=- '.print_r($resp, true)." - #####", $extInfo);
214
+
215
+ if (stripos($resp['_reason'][0]['message'], 'Failed to add URL')!==false) { sleep(5);
216
+ $r2 = wp_remote_post('http://www.stumbleupon.com/submit', array('method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds, 'cookies' => $ckArr2));
217
+ $resp = json_decode($r2['body'], true); // prr($flds); prr($resp); //nxs_addToLog('SU', 'E', '-=DBG=- '.print_r($resp, true)." - #####", $extInfo);
218
+ }
219
+ }
220
+
221
+ if (isset($resp['discovery']['publicid'])) $pageID = $resp['discovery']['publicid']; elseif (isset($resp['discovery']['url']['publicid']))$pageID = $resp['discovery']['url']['publicid'];
222
+ if ($resp['_success']=='1') { $ckArr = nxsMergeArraysOV($ckArr, $r2['cookies']); $nxs_suCkArray = $ckArr; return array("code"=>"OK", "post_id"=>$pageID); }
223
  elseif (isset($resp['_reason'])) { $resp['_reason']['NXS_FIELDS'] = $flds; $resp['_reason']['NXS_RESP'] = $resp; return $resp['_reason']; } else return "ERROR".print_r($resp, true);
224
  }}
225
 
235
  $email = $options['suUName']; $pass = (substr($options['suPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['suPass'], 5)):$options['suPass']);
236
  if ($postID=='0') { echo "Testing ... <br/><br/>"; $link = home_url(); $msg = 'Test Link from '.$link; } else { $post = get_post($postID); if(!$post) return;
237
  $msgFormat = $options['suMsgFormat']; $msg = nsFormatMessage($msgFormat, $postID); $link = get_permalink($postID); nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
238
+ }
239
  $dusername = $options['suUName']; //$link = urlencode($link); $desc = urlencode(substr($msg, 0, 500));
240
  $extInfo = ' | PostID: '.$postID." - ".$post->post_title; $logNT = '<span style="color:#000080">StumbleUpon</span> - '.$options['nName'];
241
  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 = '';
248
  }
249
  }
250
  if ($loginError!==false) {if ($postID=='0') prr($loginError); nxs_addToLog($logNT, 'E', '-=ERROR=- '.print_r($loginError, true)." - BAD USER/PASS", $extInfo); return " -= BAD USER/PASS =- ";}
251
+
252
  $ret = nxs_doPostToSU($msg, $link, $options['suCat'], $tags, $options['nsfw']=='1'); // $extInfo .= "++".$msg."|".$link."|".$options['suCat']."|".$tags."|".$options['nsfw'];
253
+ if ($ret=='OK') $ret = array("code"=>"OK", "post_id"=>'');
254
+ if ( (!is_array($ret)) && $ret!='OK') { if ($postID=='0') prr($ret); nxs_addToLog($logNT, 'E', '-=ERROR=- '.print_r($ret, true), $extInfo);}
255
+ elseif ($ret['code']=='OK') if ($postID=='0') { nxs_addToLog($logNT, 'M', 'OK - TEST Message Posted '); echo ' OK - Message Posted, please see your StumbleUpon Page '; } else
256
+ { nxs_metaMarkAsPosted($postID, 'SU', $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); return 200; }
257
+ else { if ($options['reset'] == '1') {
258
+ nxs_addToLog($logNT, 'E', '-=ERROR TRY #2=- '.print_r($ret, true), $extInfo.$options['reset']);
259
+ return "ERROR = ".print_r($ret, true);
260
+ } else { $options['reset'] = '1'; $options['suSvC'] = ''; return nxs_doPublishToSU($postID, $options); }
261
+ }
262
+
263
 
264
  }
265
  }
inc-cl/tr.php CHANGED
@@ -60,12 +60,21 @@ if (!class_exists("nxs_snapClassTR")) { class nxs_snapClassTR {
60
  <div style="width:100%;"><strong>Account Nickname:</strong> <i>Just so you can easely identify it</i> </div><input name="tr[<?php echo $ii; ?>][nName]" id="trnName<?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")), 'NS_SNAutoPoster') ?>" /><br/>
61
  <?php echo nxs_addQTranslSel('tr', $ii, $options['qTLng']); ?><?php echo nxs_addPostingDelaySel('tr', $ii, $options['nHrs'], $options['nMin']); ?>
62
 
 
 
 
 
 
 
 
 
 
63
  <div style="width:100%;"><strong>Your Tumblr URL:</strong> </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")), 'NS_SNAutoPoster') ?>" /><span style="color: #F00000;" id="apTRURLerr<?php echo $ii; ?>"></span>
64
  <div style="width:100%;"><strong>Your 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")), 'NS_SNAutoPoster') ?>" />
65
  <div style="width:100%;"><strong>Your 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")), 'NS_SNAutoPoster') ?>" />
66
- <br/><br/>
67
 
68
- <div style="width:100%;"><strong id="altFormatText">Post Type:</strong></div>
69
  <div style="margin-left: 10px;">
70
 
71
  <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/>
@@ -90,6 +99,10 @@ if (!class_exists("nxs_snapClassTR")) { class nxs_snapClassTR {
90
  <strong>Defailt Image to Post:</strong>
91
  <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>
92
  </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")), 'NS_SNAutoPoster') ?>" />
 
 
 
 
93
  <br/><br/>
94
 
95
  </div>
@@ -145,6 +158,8 @@ if (!class_exists("nxs_snapClassTR")) { class nxs_snapClassTR {
145
  if (isset($pval['apTRPostType'])) $options[$ii]['trPostType'] = trim($pval['apTRPostType']);
146
  if (isset($pval['cImgURL'])) $options[$ii]['cImgURL'] = trim($pval['cImgURL']);
147
 
 
 
148
 
149
  if (isset($pval['apTRDefImg'])) $options[$ii]['trDefImg'] = trim($pval['apTRDefImg']);
150
  if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
@@ -154,25 +169,39 @@ if (!class_exists("nxs_snapClassTR")) { class nxs_snapClassTR {
154
  }
155
  //#### Show Post->Edit Meta Box Settings
156
  function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
157
- foreach($ntOpts as $ii=>$options) {$pMeta = maybe_unserialize(get_post_meta($post_id, 'snapTR', true)); if (is_array($pMeta)) $options = $this->adjMetaOpt($options, $pMeta[$ii]); $doTR = $options['doTR'];
158
  $isAvailTR = isset($options['trAccessTocken']) && isset($options['trAccessTocken']['oauth_token_secret']) && $options['trAccessTocken']['oauth_token_secret']!=='';
159
  $trMsgFormat = htmlentities($options['trMsgFormat'], ENT_COMPAT, "UTF-8"); $trMsgTFormat = htmlentities($options['trMsgTFormat'], ENT_COMPAT, "UTF-8");
160
  ?>
161
 
162
- <tr><th style="text-align:left;" colspan="2">
163
- <?php if ($isAvailTR) { ?><input class="nxsGrpDoChb" value="1" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="tr[<?php echo $ii; ?>][SNAPincludeTR]" <?php if (($post->post_status == "publish" && $options['isPosted'] == '1') || ($post->post_status != "publish" && ((int)$doTR == 1)) ) echo 'checked="checked" title="def"'; ?> /> <?php } ?>
164
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/tr16.png);">Tumblr - publish to (<i style="color: #005800;"><?php echo $options['nName']; ?></i>) </div></th><td><?php //## Only show RePost button if the post is "published"
165
  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', 're-post') ?>" />
166
  <?php wp_nonce_field( 'rePostToTR', 'rePostToTR_wpnonce' ); } ?>
 
 
 
 
 
 
167
  </td></tr>
168
  <?php if (!$isAvailTR) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup and authorize your Tumblr Account to AutoPost to Tumblr</b>
169
  <?php }elseif ($post->post_status != "puZblish") { ?>
170
 
171
  <tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;">
172
- <input type="radio" name="tr[<?php echo $ii; ?>][apTRPostType]" value="T" <?php if ($options['trPostType'] != 'I') echo 'checked="checked"'; ?> /> <br/>
 
 
 
173
 
 
 
174
  </th>
175
- <td><b><?php _e('Text Post. Title Format:', 'NS_SPAP') ?></b><input value="<?php echo $trMsgTFormat ?>" type="text" name="tr[<?php echo $ii; ?>][SNAPTformat]" style="width:270px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apTRTMsgFrmt<?php echo $ii; ?>');"/>&nbsp; .. or .. &nbsp;<input type="radio" name="tr[<?php echo $ii; ?>][apTRPostType]" value="I" <?php if ($options['trPostType'] == 'I') echo 'checked="checked"'; ?> /> <b>Image Post</b> <?php nxs_doShowHint("apTRTMsgFrmt".$ii); ?> </td></tr>
 
 
 
176
 
177
  <tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;"><?php _e('Text Format:', 'NS_SPAP') ?></th>
178
  <td><input value="<?php echo $trMsgFormat ?>" type="text" name="tr[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apTRMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apTRMsgFrmt".$ii); ?></td></tr>
@@ -192,9 +221,9 @@ if (!class_exists("nxs_snapClassTR")) { class nxs_snapClassTR {
192
  }}
193
 
194
  if (!function_exists("nxs_rePostToTR_ajax")) { function nxs_rePostToTR_ajax() { check_ajax_referer('rePostToTR'); $postID = $_POST['id']; // $result = nsPublishTo($id, 'FB', true);
195
- $options = get_option('NS_SNAutoPoster'); foreach ($options['tr'] as $ii=>$po) if ($ii==$_POST['nid']) { $po['ii'] = $ii; $po['pType'] = 'aj';
196
  $mpo = get_post_meta($postID, 'snapTR', true); $mpo = maybe_unserialize($mpo);
197
- if (is_array($mpo) && isset($mpo[$ii]) && is_array($mpo[$ii]) ){ $ntClInst = new nxs_snapClassPN(); $po = $ntClInst->adjMetaOpt($po, $mpo[$ii]); }
198
  $result = nxs_doPublishToTR($postID, $po); if ($result == 200 || $result == 201) die("Your post has been successfully sent to Tumblr."); else { echo $result; die(); }
199
  }
200
  }
@@ -213,7 +242,7 @@ if (!function_exists("nxs_doPublishToTR")) { //## Second Function to Post to TR
213
  if ($postID=='0') { echo "Testing ... <br/><br/>"; $msg = 'Test Post from '.$blogTitle; $msgT = 'Test Post from '.$blogTitle; $options['trPostType']=='T';}
214
  else{ $post = get_post($postID); if(!$post) return; $trMsgFormat = $options['trMsgFormat']; $msg = nsFormatMessage($trMsgFormat, $postID);
215
  $trMsgTFormat = $options['trMsgTFormat']; $msgT = nsFormatMessage($trMsgTFormat, $postID); nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
216
- }
217
  //## Post
218
  require_once('apis/trOAuth.php'); $consumer_key = $options['trConsKey']; $consumer_secret = $options['trConsSec'];
219
  $tum_oauth = new TumblrOAuth($consumer_key, $consumer_secret, $options['trAccessTocken']['oauth_token'], $options['trAccessTocken']['oauth_token_secret']); //prr($options);
@@ -222,16 +251,22 @@ if (!function_exists("nxs_doPublishToTR")) { //## Second Function to Post to TR
222
  $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
223
  $extInfo = ' | PostID: '.$postID." - ".$post->post_title; $logNT = '<span style="color:#014A76">Tumblr</span> - '.$options['nName'];
224
  $postArr = array('tags'=>$tags, 'date'=>$postDate);
 
 
225
  if ($options['trPostType']=='I') { $postArr['type'] = 'photo'; $postArr['caption'] = $msg; $postArr['source'] = nxs_getPostImage($postID, 'large', $options['trDefImg']);
226
  if (!isset($options['cImgURL']) || $options['cImgURL']=='' || $options['cImgURL']=='R' ) $postArr['link'] = get_permalink($postID);
227
  elseif ($options['cImgURL']=='S' ) {$postArr['link'] = get_permalink($postID); $postArr['link'] = nxs_mkShortURL($postArr['link']);}
 
 
 
 
228
  } else { $postArr['title'] = $msgT; $postArr['type'] = 'text'; $postArr['source'] = get_permalink($postID); $postArr['body'] = $msg; }
229
 
230
- $postinfo = $tum_oauth->post("http://api.tumblr.com/v2/blog/".$trURL."/post", $postArr); // prr($postArr);
231
 
232
  $code = $postinfo->meta->status;// echo "XX".print_r($code); prr($postinfo); // prr($msg); prr($postinfo); echo $code."VVVV"; die("|====");
233
  if ($code == 201) { if ($postID=='0') { nxs_addToLog($logNT, 'M', 'OK - TEST Message Posted '); echo 'OK - Message Posted, please see your Tumblr Page. <br/> Result:'; prr($postinfo->meta); }
234
- else { nxs_addToLog($logNT, 'M', 'OK - Message Posted ', $extInfo); nxs_metaMarkAsPosted($postID, 'TR', $options['ii']); } }
235
  else { nxs_addToLog($logNT, 'E', '-=ERROR=- '.print_r($postinfo, true), $extInfo); if ($postID=='0') prr($postinfo); $code .= " - ".$postinfo->meta->msg.$postinfo->errmsg; }
236
 
237
  return $code;
60
  <div style="width:100%;"><strong>Account Nickname:</strong> <i>Just so you can easely identify it</i> </div><input name="tr[<?php echo $ii; ?>][nName]" id="trnName<?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")), 'NS_SNAutoPoster') ?>" /><br/>
61
  <?php echo nxs_addQTranslSel('tr', $ii, $options['qTLng']); ?><?php echo nxs_addPostingDelaySel('tr', $ii, $options['nHrs'], $options['nMin']); ?>
62
 
63
+ <?php if (!$isNew) { ?>
64
+ <div style="width:100%;"><strong>Auto-Post Categories:</strong>
65
+ <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="tr[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
66
+ <input value="1" id="catSelSTR<?php echo $ii; ?>" type="radio" name="tr[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_TR<?php echo $ii; ?>" onclick="jQuery('#catSelSTR<?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('TR<?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_TR<?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>
67
+ <input type="hidden" name="tr[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_TR<?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
68
+ </div>
69
+ <br/>
70
+ <?php } ?>
71
+
72
  <div style="width:100%;"><strong>Your Tumblr URL:</strong> </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")), 'NS_SNAutoPoster') ?>" /><span style="color: #F00000;" id="apTRURLerr<?php echo $ii; ?>"></span>
73
  <div style="width:100%;"><strong>Your 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")), 'NS_SNAutoPoster') ?>" />
74
  <div style="width:100%;"><strong>Your 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")), 'NS_SNAutoPoster') ?>" />
75
+ <br/>
76
 
77
+ <div style="width:100%;"><strong id="altFormatText">Default Post Type:</strong></div>
78
  <div style="margin-left: 10px;">
79
 
80
  <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/>
99
  <strong>Defailt Image to Post:</strong>
100
  <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>
101
  </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")), 'NS_SNAutoPoster') ?>" />
102
+ <br/>
103
+ <input type="radio" name="tr[<?php echo $ii; ?>][apTRPostType]" value="U" <?php if ($options['trPostType'] == 'U') echo 'checked="checked"'; ?> /> Audio Post<br/>
104
+ <input type="radio" name="tr[<?php echo $ii; ?>][apTRPostType]" value="V" <?php if ($options['trPostType'] == 'V') echo 'checked="checked"'; ?> /> Video Post<br/>
105
+ <i style="">Tip: Your post must contain link to Audio or Video file if you select "Audio Post" or "Video Post" , otherwise it will reverted to the "Text Post"</i>
106
  <br/><br/>
107
 
108
  </div>
158
  if (isset($pval['apTRPostType'])) $options[$ii]['trPostType'] = trim($pval['apTRPostType']);
159
  if (isset($pval['cImgURL'])) $options[$ii]['cImgURL'] = trim($pval['cImgURL']);
160
 
161
+ if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']);
162
+ if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
163
 
164
  if (isset($pval['apTRDefImg'])) $options[$ii]['trDefImg'] = trim($pval['apTRDefImg']);
165
  if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
169
  }
170
  //#### Show Post->Edit Meta Box Settings
171
  function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
172
+ foreach($ntOpts as $ii=>$options) {$pMeta = maybe_unserialize(get_post_meta($post_id, 'snapTR', true)); if (is_array($pMeta)) $options = $this->adjMetaOpt($options, $pMeta[$ii]); $doTR = $options['doTR'] && $options['catSel']!='1';
173
  $isAvailTR = isset($options['trAccessTocken']) && isset($options['trAccessTocken']['oauth_token_secret']) && $options['trAccessTocken']['oauth_token_secret']!=='';
174
  $trMsgFormat = htmlentities($options['trMsgFormat'], ENT_COMPAT, "UTF-8"); $trMsgTFormat = htmlentities($options['trMsgTFormat'], ENT_COMPAT, "UTF-8");
175
  ?>
176
 
177
+ <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 } ?>
178
+ <?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; ?>][SNAPincludeTR]" <?php if (($post->post_status == "publish" && $options['isPosted'] == '1') || ($post->post_status != "publish" && ((int)$doTR == 1)) ) echo 'checked="checked" title="def"'; ?> /> <?php } ?>
179
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/tr16.png);">Tumblr - publish to (<i style="color: #005800;"><?php echo $options['nName']; ?></i>) </div></th><td><?php //## Only show RePost button if the post is "published"
180
  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', 're-post') ?>" />
181
  <?php wp_nonce_field( 'rePostToTR', 'rePostToTR_wpnonce' ); } ?>
182
+
183
+ <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
184
+ ?> <span id="pstdTR<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
185
+ <a style="font-size: 10px;" href="<?php echo $options['trURL']; ?>post/<?php echo $pMeta[$ii]['pgID']; ?>" target="_blank">Posted on Tumblr <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
186
+ </span><?php } ?>
187
+
188
  </td></tr>
189
  <?php if (!$isAvailTR) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup and authorize your Tumblr Account to AutoPost to Tumblr</b>
190
  <?php }elseif ($post->post_status != "puZblish") { ?>
191
 
192
  <tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;">
193
+ <input type="radio" name="tr[<?php echo $ii; ?>][apTRPostType]" value="T" <?php if ($options['trPostType'] != 'I') echo 'checked="checked"'; ?> /> <br/>
194
+ </th>
195
+ <td><b><?php _e('Text Post. Title Format:', 'NS_SPAP') ?></b>&nbsp;<input value="<?php echo $trMsgTFormat ?>" type="text" name="tr[<?php echo $ii; ?>][SNAPTformat]" style="width:270px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apTRTMsgFrmt<?php echo $ii; ?>');"/>
196
+ <?php nxs_doShowHint("apTRTMsgFrmt".$ii); ?> </td></tr>
197
 
198
+ <tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;">
199
+ <input type="radio" name="tr[<?php echo $ii; ?>][apTRPostType]" value="I" <?php if ($options['trPostType'] == 'I') echo 'checked="checked"'; ?> /> <br/>
200
  </th>
201
+ <td><b>Image Post</b>&nbsp;&nbsp;&nbsp;&nbsp;
202
+ <input type="radio" name="tr[<?php echo $ii; ?>][apTRPostType]" value="V" <?php if ($options['trPostType'] == 'V') echo 'checked="checked"'; ?> /> <b>Video Post</b> <?php nxs_doShowHint("apTRTMsgFrmt".$ii); ?> &nbsp;&nbsp;&nbsp;&nbsp;
203
+ <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); ?>
204
+ </td></tr>
205
 
206
  <tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;"><?php _e('Text Format:', 'NS_SPAP') ?></th>
207
  <td><input value="<?php echo $trMsgFormat ?>" type="text" name="tr[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apTRMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apTRMsgFrmt".$ii); ?></td></tr>
221
  }}
222
 
223
  if (!function_exists("nxs_rePostToTR_ajax")) { function nxs_rePostToTR_ajax() { check_ajax_referer('rePostToTR'); $postID = $_POST['id']; // $result = nsPublishTo($id, 'FB', true);
224
+ $options = get_option('NS_SNAutoPoster'); foreach ($options['tr'] as $ii=>$po) if ($ii==$_POST['nid']) { $po['ii'] = $ii; $po['pType'] = 'aj';
225
  $mpo = get_post_meta($postID, 'snapTR', true); $mpo = maybe_unserialize($mpo);
226
+ if (is_array($mpo) && isset($mpo[$ii]) && is_array($mpo[$ii]) ){ $ntClInst = new nxs_snapClassTR(); $po = $ntClInst->adjMetaOpt($po, $mpo[$ii]); }
227
  $result = nxs_doPublishToTR($postID, $po); if ($result == 200 || $result == 201) die("Your post has been successfully sent to Tumblr."); else { echo $result; die(); }
228
  }
229
  }
242
  if ($postID=='0') { echo "Testing ... <br/><br/>"; $msg = 'Test Post from '.$blogTitle; $msgT = 'Test Post from '.$blogTitle; $options['trPostType']=='T';}
243
  else{ $post = get_post($postID); if(!$post) return; $trMsgFormat = $options['trMsgFormat']; $msg = nsFormatMessage($trMsgFormat, $postID);
244
  $trMsgTFormat = $options['trMsgTFormat']; $msgT = nsFormatMessage($trMsgTFormat, $postID); nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
245
+ } //prr($options); die();
246
  //## Post
247
  require_once('apis/trOAuth.php'); $consumer_key = $options['trConsKey']; $consumer_secret = $options['trConsSec'];
248
  $tum_oauth = new TumblrOAuth($consumer_key, $consumer_secret, $options['trAccessTocken']['oauth_token'], $options['trAccessTocken']['oauth_token_secret']); //prr($options);
251
  $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
252
  $extInfo = ' | PostID: '.$postID." - ".$post->post_title; $logNT = '<span style="color:#014A76">Tumblr</span> - '.$options['nName'];
253
  $postArr = array('tags'=>$tags, 'date'=>$postDate);
254
+ if($options['trPostType']=='V') { $vids = nsFindVidsInPost($post); if (count($vids)>0) $ytUrl = $vids[0]; if (trim($ytUrl)=='') $options['trPostType']='T'; }
255
+ if($options['trPostType']=='U') { $aud = nsFindAudioInPost($post); if (count($aud)>0) $aUrl = $aud[0]; if (trim($aUrl)=='') $options['trPostType']='T'; }
256
  if ($options['trPostType']=='I') { $postArr['type'] = 'photo'; $postArr['caption'] = $msg; $postArr['source'] = nxs_getPostImage($postID, 'large', $options['trDefImg']);
257
  if (!isset($options['cImgURL']) || $options['cImgURL']=='' || $options['cImgURL']=='R' ) $postArr['link'] = get_permalink($postID);
258
  elseif ($options['cImgURL']=='S' ) {$postArr['link'] = get_permalink($postID); $postArr['link'] = nxs_mkShortURL($postArr['link']);}
259
+ } elseif($options['trPostType']=='U') { $postArr['type'] = 'audio'; $postArr['caption'] = $msg; $postArr['external_url'] = $aUrl;
260
+ } elseif($options['trPostType']=='V') { $postArr['type'] = 'video'; $postArr['caption'] = $msg;
261
+ $embedTxt = '<iframe width="560" height="315" src="http://www.youtube.com/embed/'.$ytUrl.'" frameborder="0" allowfullscreen></iframe>';
262
+ $postArr['embed'] = $embedTxt;
263
  } else { $postArr['title'] = $msgT; $postArr['type'] = 'text'; $postArr['source'] = get_permalink($postID); $postArr['body'] = $msg; }
264
 
265
+ $postinfo = $tum_oauth->post("http://api.tumblr.com/v2/blog/".$trURL."/post", $postArr); // prr($postinfo); prr($postArr);
266
 
267
  $code = $postinfo->meta->status;// echo "XX".print_r($code); prr($postinfo); // prr($msg); prr($postinfo); echo $code."VVVV"; die("|====");
268
  if ($code == 201) { if ($postID=='0') { nxs_addToLog($logNT, 'M', 'OK - TEST Message Posted '); echo 'OK - Message Posted, please see your Tumblr Page. <br/> Result:'; prr($postinfo->meta); }
269
+ else { nxs_addToLog($logNT, 'M', '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'))); } }
270
  else { nxs_addToLog($logNT, 'E', '-=ERROR=- '.print_r($postinfo, true), $extInfo); if ($postID=='0') prr($postinfo); $code .= " - ".$postinfo->meta->msg.$postinfo->errmsg; }
271
 
272
  return $code;
inc-cl/tw.php CHANGED
@@ -26,6 +26,16 @@ if (!class_exists("nxs_snapClassTW")) { class nxs_snapClassTW {
26
 
27
  <div style="width:100%;"><strong>Account Nickname:</strong> <i>Just so you can easely identify it</i> </div><input name="tw[<?php echo $ii; ?>][nName]" id="twnName<?php echo $ii; ?>" style="font-weight: bold; color: #005800; border: 1px solid #ACACAC; width: 40%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($two['nName'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" /><br/>
28
  <?php echo nxs_addQTranslSel('tw', $ii, $two['qTLng']); ?><?php echo nxs_addPostingDelaySel('tw', $ii, $two['nHrs'], $two['nMin']); ?>
 
 
 
 
 
 
 
 
 
 
29
  <div style="width:100%;"><strong>Your Twitter URL:</strong> </div><input name="tw[<?php echo $ii; ?>][apTWURL]" id="apTWURL" style="width: 40%;border: 1px solid #ACACAC;" value="<?php _e(apply_filters('format_to_edit', htmlentities($two['twURL'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" />
30
  <div style="width:100%;"><strong>Your Twitter Consumer Key:</strong> </div><input name="tw[<?php echo $ii; ?>][apTWConsKey]" id="apTWConsKey" style="width: 40%; border: 1px solid #ACACAC;" value="<?php _e(apply_filters('format_to_edit', htmlentities($two['twConsKey'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" />
31
  <div style="width:100%;"><strong>Your Twitter Consumer Secret:</strong> </div><input name="tw[<?php echo $ii; ?>][apTWConsSec]" id="apTWConsSec" style="width: 40%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($two['twConsSec'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" />
@@ -58,6 +68,10 @@ if (!class_exists("nxs_snapClassTW")) { class nxs_snapClassTW {
58
  if (isset($pval['apTWConsKey'])) $options[$ii]['twConsKey'] = trim($pval['apTWConsKey']);
59
  if (isset($pval['apTWConsSec'])) $options[$ii]['twConsSec'] = trim($pval['apTWConsSec']);
60
  if (isset($pval['apTWAccToken'])) $options[$ii]['twAccToken'] = trim($pval['apTWAccToken']);
 
 
 
 
61
  if (isset($pval['apTWAccTokenSec']))$options[$ii]['twAccTokenSec'] = trim($pval['apTWAccTokenSec']);
62
  if (isset($pval['apTWMsgFrmt'])) $options[$ii]['twMsgFormat'] = trim($pval['apTWMsgFrmt']);
63
  if (isset($pval['attchImg'])) $options[$ii]['attchImg'] = $pval['attchImg']; else $options[$ii]['attchImg'] = 0;
@@ -68,17 +82,17 @@ if (!class_exists("nxs_snapClassTW")) { class nxs_snapClassTW {
68
  }
69
  //#### Show Post->Edit Meta Box Settings
70
  function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
71
- foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapTW', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]); $doTW = $ntOpt['doTW'];
72
  $isAvailTW = $ntOpt['twURL']!='' && $ntOpt['twConsKey']!='' && $ntOpt['twConsSec']!='' && $ntOpt['twAccToken']!=''; $twMsgFormat = htmlentities($ntOpt['twMsgFormat'], ENT_COMPAT, "UTF-8"); $isAttchImg = $ntOpt['attchImg'];
73
  ?>
74
- <tr><th style="text-align:left;" colspan="2">
75
- <?php if ($isAvailTW) { ?><input class="nxsGrpDoChb" value="1" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="tw[<?php echo $ii; ?>][SNAPincludeTW]" <?php if (($post->post_status == "publish" && $ntOpt['isPosted'] == '1') || ($post->post_status != "publish" && ((int)$doTW == 1)) ) echo 'checked="checked" title="def"'; ?> /> <?php } ?>
76
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/tw16.png);">Twitter - publish to (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th><td><?php //## Only show RePost button if the post is "published"
77
  if ($post->post_status == "publish" && $isAvailTW) { ?>
78
  <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', 're-post') ?>" />
79
  <?php wp_nonce_field( 'rePostToTW', 'rePostToTW_wpnonce' ); } ?>
80
  <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID'])) { ?> <span style="float: right;padding-top: 4px; padding-right: 10px;">
81
- <a href="<?php echo $ntOpt['twURL'].'/status/'.$pMeta[$ii]['pgID']; ?>" target="_blank">Posted on Twitter <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
82
  </span><?php } ?>
83
  </td></tr>
84
  <?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>
@@ -88,6 +102,7 @@ if (!class_exists("nxs_snapClassTW")) { class nxs_snapClassTW {
88
  <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>
89
 
90
  <tr><th scope="row" style="text-align:right; width:150px; vertical-align:top; padding-top: 5px; padding-right:10px;">
 
91
  <input value="1" type="checkbox" name="tw[<?php echo $ii; ?>][attchImg]" <?php if ((int)$isAttchImg == 1) echo "checked"; ?> /> </th><td><strong>Attach Image to Twitter Post</strong></td> </tr>
92
  <?php }
93
  }
@@ -120,8 +135,9 @@ if (!function_exists("nxs_doPublishToTW")) { //## Second Function to Post to TW
120
  $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url(); $uln = 0;
121
 
122
  if ($options['attchImg']=='1') { $imgURL = nxs_getPostImage($postID); if(trim($imgURL)=='') $options['attchImg'] = 0; else {
123
- if (@getimagesize($imgURL)!==false) { $img = wp_remote_get($imgURL); if(is_wp_error($img)) $options['attchImg'] = 0; else $img = $img['body']; } else $options['attchImg'] = 0;
124
- }}
 
125
  if ($options['attchImg']=='1' && $img!='') $twLim = 119; else $twLim = 140;
126
 
127
  if ($postID=='0') { echo "Testing ... <br/><br/>"; $msg = 'Test Post from '.$blogTitle." - ".rand(1, 155); $uln = strlen($msg);}
@@ -138,7 +154,7 @@ if (!function_exists("nxs_doPublishToTW")) { //## Second Function to Post to TW
138
  $pFullText = apply_filters('the_content', $post->post_content);
139
  $pRawText = $post->post_content;
140
 
141
- if (stripos($twMsgFormat, '%TAGS%')!==false) {
142
  $t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) { $frmTag = trim(str_replace(' ','_', str_replace(' ', ' ', trim($tagA->name))));
143
  if (stripos($pTitle, $tagA->name)!==false) $pTitle = str_ireplace($tagA->name, '#'.$frmTag, $pTitle); elseif (stripos($pTitle, $frmTag)!==false) $pTitle = str_ireplace($frmTag, '#'.$frmTag, $pTitle);
144
  if (stripos($pText, $tagA->name)!==false) $pText = str_ireplace($tagA->name, '#'.$frmTag, $pText); elseif (stripos($pText, $frmTag)!==false) $pText = str_ireplace($frmTag, '#'.$frmTag, $pText);
@@ -148,9 +164,10 @@ if (!function_exists("nxs_doPublishToTW")) { //## Second Function to Post to TW
148
  ((stripos($twMsgFormat, '%TEXT%')!==false) && (stripos($pText, $tagA->name)!==false || stripos($pText, $frmTag)!==false)) ||
149
  ((stripos($twMsgFormat, '%FULLTEXT%')!==false) && (stripos($pFullText, $tagA->name)!==false || stripos($pFullText, $frmTag)!==false)) ||
150
  ((stripos($twMsgFormat, '%RAWTEXT%')!==false) && (stripos($pRawText, $tagA->name)!==false || stripos($pRawText, $frmTag)!==false)) ) {} else $tggs[] = '#'.$frmTag;
151
- } $tags = implode(' ',$tggs); $twMsgFormat = str_ireplace("%TAGS%", $tags, $twMsgFormat); $twLim = $twLim - strlen($tags);
 
152
  }
153
- if (stripos($twMsgFormat, '%CATS%')!==false) {
154
  $t = wp_get_post_categories($postID); $cats = array(); foreach($t as $c){ $cat = get_category($c); $frmTag = trim(str_replace(' ','_', str_replace(' ',' ',str_ireplace('&','&amp;',trim($cat->name)))));
155
  if (stripos($pTitle, $cat->name)!==false) $pTitle = str_ireplace($cat->name, '#'.$frmTag, $pTitle); elseif (stripos($pTitle, $frmTag)!==false) $pTitle = str_ireplace($frmTag, '#'.$frmTag, $pTitle);
156
  if (stripos($pText, $cat->name)!==false) $pText = str_ireplace($cat->name, '#'.$frmTag, $pText); elseif (stripos($pText, $frmTag)!==false) $pText = str_ireplace($frmTag, '#'.$frmTag, $pText);
@@ -160,10 +177,12 @@ if (!function_exists("nxs_doPublishToTW")) { //## Second Function to Post to TW
160
  ((stripos($twMsgFormat, '%TEXT%')!==false) && (stripos($pText, $cat->name)!==false || stripos($pText, $frmTag)!==false)) ||
161
  ((stripos($twMsgFormat, '%FULLTEXT%')!==false) && (stripos($pFullText, $cat->name)!==false || stripos($pFullText, $frmTag)!==false)) ||
162
  ((stripos($twMsgFormat, '%RAWTEXT%')!==false) && (stripos($pRawText, $cat->name)!==false || stripos($pRawText, $frmTag)!==false)) ) {} else $cats[] = '#'.$frmTag;
163
- } $ctts = implode(' ',$cats); $twMsgFormat = str_ireplace("%CATS%", $ctts, $twMsgFormat); $twLim = $twLim - strlen($ctts);
 
164
  }
165
  if (stripos($twMsgFormat, '%TITLE%')!==false) { if (stripos($pTitle, '.co.uk')!==false) $twLim = $twLim - 14;
166
  if (stripos($pTitle, '.com')!==false) $twLim = $twLim - 16; if (stripos($pTitle, '.net')!==false) $twLim = $twLim - 16; if (stripos($pTitle, '.org')!==false) $twLim = $twLim - 16;
 
167
  $pTitle = nsTrnc($pTitle, $twLim); $twMsgFormat = str_ireplace("%TITLE%", $pTitle, $twMsgFormat); $twLim = $twLim - strlen($pTitle);
168
  }
169
  if (stripos($twMsgFormat, '%SITENAME%')!==false) {
26
 
27
  <div style="width:100%;"><strong>Account Nickname:</strong> <i>Just so you can easely identify it</i> </div><input name="tw[<?php echo $ii; ?>][nName]" id="twnName<?php echo $ii; ?>" style="font-weight: bold; color: #005800; border: 1px solid #ACACAC; width: 40%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($two['nName'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" /><br/>
28
  <?php echo nxs_addQTranslSel('tw', $ii, $two['qTLng']); ?><?php echo nxs_addPostingDelaySel('tw', $ii, $two['nHrs'], $two['nMin']); ?>
29
+
30
+ <?php if (!$isNew) { ?>
31
+ <div style="width:100%;"><strong>Auto-Post Categories:</strong>
32
+ <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="tw[<?php echo $ii; ?>][catSel]" <?php if ((int)$two['catSel'] != 1) echo "checked"; ?> /> All
33
+ <input value="1" id="catSelSTW<?php echo $ii; ?>" type="radio" name="tw[<?php echo $ii; ?>][catSel]" <?php if ((int)$two['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_TW<?php echo $ii; ?>" onclick="jQuery('#catSelSTW<?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('TW<?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_TW<?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 ($two['catSelEd']!='') echo "[".(substr_count($two['catSelEd'], ",")+1)."]"; ?></a>
34
+ <input type="hidden" name="tw[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_TW<?php echo $ii; ?>" value="<?php echo $two['catSelEd']; ?>" />
35
+ </div>
36
+ <br/>
37
+ <?php } ?>
38
+
39
  <div style="width:100%;"><strong>Your Twitter URL:</strong> </div><input name="tw[<?php echo $ii; ?>][apTWURL]" id="apTWURL" style="width: 40%;border: 1px solid #ACACAC;" value="<?php _e(apply_filters('format_to_edit', htmlentities($two['twURL'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" />
40
  <div style="width:100%;"><strong>Your Twitter Consumer Key:</strong> </div><input name="tw[<?php echo $ii; ?>][apTWConsKey]" id="apTWConsKey" style="width: 40%; border: 1px solid #ACACAC;" value="<?php _e(apply_filters('format_to_edit', htmlentities($two['twConsKey'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" />
41
  <div style="width:100%;"><strong>Your Twitter Consumer Secret:</strong> </div><input name="tw[<?php echo $ii; ?>][apTWConsSec]" id="apTWConsSec" style="width: 40%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($two['twConsSec'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" />
68
  if (isset($pval['apTWConsKey'])) $options[$ii]['twConsKey'] = trim($pval['apTWConsKey']);
69
  if (isset($pval['apTWConsSec'])) $options[$ii]['twConsSec'] = trim($pval['apTWConsSec']);
70
  if (isset($pval['apTWAccToken'])) $options[$ii]['twAccToken'] = trim($pval['apTWAccToken']);
71
+
72
+ if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']);
73
+ if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
74
+
75
  if (isset($pval['apTWAccTokenSec']))$options[$ii]['twAccTokenSec'] = trim($pval['apTWAccTokenSec']);
76
  if (isset($pval['apTWMsgFrmt'])) $options[$ii]['twMsgFormat'] = trim($pval['apTWMsgFrmt']);
77
  if (isset($pval['attchImg'])) $options[$ii]['attchImg'] = $pval['attchImg']; else $options[$ii]['attchImg'] = 0;
82
  }
83
  //#### Show Post->Edit Meta Box Settings
84
  function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
85
+ foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapTW', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]); $doTW = $ntOpt['doTW'] && $ntOpt['catSel']!='1';
86
  $isAvailTW = $ntOpt['twURL']!='' && $ntOpt['twConsKey']!='' && $ntOpt['twConsSec']!='' && $ntOpt['twAccToken']!=''; $twMsgFormat = htmlentities($ntOpt['twMsgFormat'], ENT_COMPAT, "UTF-8"); $isAttchImg = $ntOpt['attchImg'];
87
  ?>
88
+ <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 } ?>
89
+ <?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; ?>][SNAPincludeTW]" <?php if (($post->post_status == "publish" && $ntOpt['isPosted'] == '1') || ($post->post_status != "publish" && ((int)$doTW == 1)) ) echo 'checked="checked" title="def"'; ?> /> <?php } ?>
90
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/tw16.png);">Twitter - publish to (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th><td><?php //## Only show RePost button if the post is "published"
91
  if ($post->post_status == "publish" && $isAvailTW) { ?>
92
  <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', 're-post') ?>" />
93
  <?php wp_nonce_field( 'rePostToTW', 'rePostToTW_wpnonce' ); } ?>
94
  <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID'])) { ?> <span style="float: right;padding-top: 4px; padding-right: 10px;">
95
+ <a id="pstdTW<?php echo $ii; ?>" style="font-size: 10px;" href="<?php echo $ntOpt['twURL'].'/status/'.$pMeta[$ii]['pgID']; ?>" target="_blank">Posted on Twitter <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
96
  </span><?php } ?>
97
  </td></tr>
98
  <?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>
102
  <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>
103
 
104
  <tr><th scope="row" style="text-align:right; width:150px; vertical-align:top; padding-top: 5px; padding-right:10px;">
105
+ <input value="0" type="hidden" name="tw[<?php echo $ii; ?>][attchImg]"/>
106
  <input value="1" type="checkbox" name="tw[<?php echo $ii; ?>][attchImg]" <?php if ((int)$isAttchImg == 1) echo "checked"; ?> /> </th><td><strong>Attach Image to Twitter Post</strong></td> </tr>
107
  <?php }
108
  }
135
  $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url(); $uln = 0;
136
 
137
  if ($options['attchImg']=='1') { $imgURL = nxs_getPostImage($postID); if(trim($imgURL)=='') $options['attchImg'] = 0; else {
138
+ if( ini_get('allow_url_fopen') ) { if (@getimagesize($imgURL)!==false) { $img = wp_remote_get($imgURL); if(is_wp_error($img)) $options['attchImg'] = 0; else $img = $img['body']; } else $options['attchImg'] = 0; }
139
+ 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; }
140
+ }}
141
  if ($options['attchImg']=='1' && $img!='') $twLim = 119; else $twLim = 140;
142
 
143
  if ($postID=='0') { echo "Testing ... <br/><br/>"; $msg = 'Test Post from '.$blogTitle." - ".rand(1, 155); $uln = strlen($msg);}
154
  $pFullText = apply_filters('the_content', $post->post_content);
155
  $pRawText = $post->post_content;
156
 
157
+ if (stripos($twMsgFormat, '%TAGS%')!==false || stripos($twMsgFormat, '%HTAGS%')!==false) {
158
  $t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) { $frmTag = trim(str_replace(' ','_', str_replace(' ', ' ', trim($tagA->name))));
159
  if (stripos($pTitle, $tagA->name)!==false) $pTitle = str_ireplace($tagA->name, '#'.$frmTag, $pTitle); elseif (stripos($pTitle, $frmTag)!==false) $pTitle = str_ireplace($frmTag, '#'.$frmTag, $pTitle);
160
  if (stripos($pText, $tagA->name)!==false) $pText = str_ireplace($tagA->name, '#'.$frmTag, $pText); elseif (stripos($pText, $frmTag)!==false) $pText = str_ireplace($frmTag, '#'.$frmTag, $pText);
164
  ((stripos($twMsgFormat, '%TEXT%')!==false) && (stripos($pText, $tagA->name)!==false || stripos($pText, $frmTag)!==false)) ||
165
  ((stripos($twMsgFormat, '%FULLTEXT%')!==false) && (stripos($pFullText, $tagA->name)!==false || stripos($pFullText, $frmTag)!==false)) ||
166
  ((stripos($twMsgFormat, '%RAWTEXT%')!==false) && (stripos($pRawText, $tagA->name)!==false || stripos($pRawText, $frmTag)!==false)) ) {} else $tggs[] = '#'.$frmTag;
167
+ } $tags = implode(' ',$tggs); while(strlen($tags)>($twLim-10)) {array_pop($tggs); $tags = implode(' ',$tggs);} $twMsgFormat = str_ireplace("%TAGS%", $tags, $twMsgFormat); $twMsgFormat = str_ireplace("%HTAGS%", $tags, $twMsgFormat);
168
+ $twLim = $twLim - strlen($tags);
169
  }
170
+ if (stripos($twMsgFormat, '%CATS%')!==false || stripos($twMsgFormat, '%HCATS%')!==false) {
171
  $t = wp_get_post_categories($postID); $cats = array(); foreach($t as $c){ $cat = get_category($c); $frmTag = trim(str_replace(' ','_', str_replace(' ',' ',str_ireplace('&','&amp;',trim($cat->name)))));
172
  if (stripos($pTitle, $cat->name)!==false) $pTitle = str_ireplace($cat->name, '#'.$frmTag, $pTitle); elseif (stripos($pTitle, $frmTag)!==false) $pTitle = str_ireplace($frmTag, '#'.$frmTag, $pTitle);
173
  if (stripos($pText, $cat->name)!==false) $pText = str_ireplace($cat->name, '#'.$frmTag, $pText); elseif (stripos($pText, $frmTag)!==false) $pText = str_ireplace($frmTag, '#'.$frmTag, $pText);
177
  ((stripos($twMsgFormat, '%TEXT%')!==false) && (stripos($pText, $cat->name)!==false || stripos($pText, $frmTag)!==false)) ||
178
  ((stripos($twMsgFormat, '%FULLTEXT%')!==false) && (stripos($pFullText, $cat->name)!==false || stripos($pFullText, $frmTag)!==false)) ||
179
  ((stripos($twMsgFormat, '%RAWTEXT%')!==false) && (stripos($pRawText, $cat->name)!==false || stripos($pRawText, $frmTag)!==false)) ) {} else $cats[] = '#'.$frmTag;
180
+ } $ctts = implode(' ',$cats); while(strlen($cats)>($twLim-10)) {array_pop($ctts); $cats = implode(' ',$ctts);} $twMsgFormat = str_ireplace("%CATS%", $ctts, $twMsgFormat); $twMsgFormat = str_ireplace("%HCATS%", $ctts, $twMsgFormat);
181
+ $twLim = $twLim - strlen($ctts);
182
  }
183
  if (stripos($twMsgFormat, '%TITLE%')!==false) { if (stripos($pTitle, '.co.uk')!==false) $twLim = $twLim - 14;
184
  if (stripos($pTitle, '.com')!==false) $twLim = $twLim - 16; if (stripos($pTitle, '.net')!==false) $twLim = $twLim - 16; if (stripos($pTitle, '.org')!==false) $twLim = $twLim - 16;
185
+ $pTitle = html_entity_decode(strip_tags($pTitle), ENT_NOQUOTES, 'UTF-8');
186
  $pTitle = nsTrnc($pTitle, $twLim); $twMsgFormat = str_ireplace("%TITLE%", $pTitle, $twMsgFormat); $twLim = $twLim - strlen($pTitle);
187
  }
188
  if (stripos($twMsgFormat, '%SITENAME%')!==false) {
inc-cl/vb.php CHANGED
@@ -33,6 +33,15 @@ if (!class_exists("nxs_snapClassVB")) { class nxs_snapClassVB {
33
  <div style="width:100%;"><strong>Account Nickname:</strong> <i>Just so you can easely identify it</i> </div><input name="vb[<?php echo $ii; ?>][nName]" id="vbnName<?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")), 'NS_SNAutoPoster') ?>" /><br/>
34
  <?php echo nxs_addQTranslSel('vb', $ii, $options['qTLng']); ?><?php echo nxs_addPostingDelaySel('vb', $ii, $options['nHrs'], $options['nMin']); ?>
35
 
 
 
 
 
 
 
 
 
 
36
  <div id="altFormat" style="">
37
  <div style="width:100%;"><strong id="altFormatText">vBulletin URL:</strong> <span style="font-size: 11px; margin: 0px;">Could be Forum URL or Thread URL. Either new thread of new post will be created.</span></div>
38
  <input name="vb[<?php echo $ii; ?>][apVBURL]" id="apVBURL" style="width: 60%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['vbURL'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" /> <br/>
@@ -81,6 +90,10 @@ if (!class_exists("nxs_snapClassVB")) { class nxs_snapClassVB {
81
  if (isset($pval['vbInclTags'])) $options[$ii]['vbInclTags'] = $pval['vbInclTags']; else $options[$ii]['vbInclTags'] = 0;
82
  if (isset($pval['apVBMsgTFrmt'])) $options[$ii]['vbMsgTFormat'] = trim($pval['apVBMsgTFrmt']);
83
  if (isset($pval['apVBMsgFrmt'])) $options[$ii]['vbMsgFormat'] = trim($pval['apVBMsgFrmt']);
 
 
 
 
84
  if (isset($pval['apDoVB'])) $options[$ii]['doVB'] = $pval['apDoVB']; else $options[$ii]['doVB'] = 0;
85
  if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
86
  if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
@@ -89,15 +102,22 @@ if (!class_exists("nxs_snapClassVB")) { class nxs_snapClassVB {
89
  }
90
  //#### Show Post->Edit Meta Box Settings
91
  function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
92
- foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapVB', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]); $doVB = $ntOpt['doVB'];
93
  $isAvailVB = $ntOpt['vbUName']!='' && $ntOpt['vbPass']!=''; $vbMsgFormat = htmlentities($ntOpt['vbMsgFormat'], ENT_COMPAT, "UTF-8"); $vbMsgTFormat = htmlentities($ntOpt['vbMsgTFormat'], ENT_COMPAT, "UTF-8");
94
  ?>
95
- <tr><th style="text-align:left;" colspan="2">
96
- <?php if ($isAvailVB) { ?><input class="nxsGrpDoChb" value="1" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="vb[<?php echo $ii; ?>][SNAPincludeVB]" <?php if (($post->post_status == "publish" && $ntOpt['isPosted'] == '1') || ($post->post_status != "publish" && ((int)$doVB == 1)) ) echo 'checked="checked" title="def"'; ?> /> <?php } ?>
97
 
98
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/vb16.png);">vBulletin - publish to (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
99
  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', 're-post') ?>" />
100
  <?php wp_nonce_field( 'rePostToVB', 'rePostToVB_wpnonce' ); } ?>
 
 
 
 
 
 
 
101
  </td></tr>
102
 
103
  <?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>
@@ -122,7 +142,7 @@ if (!function_exists("nxs_rePostToVB_ajax")) {
122
  function nxs_rePostToVB_ajax() { check_ajax_referer('rePostToVB'); $postID = $_POST['id']; $options = get_option('NS_SNAutoPoster');
123
  foreach ($options['vb'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj'; //if ($two['gpPageID'].$two['gpUName']==$_POST['nid']) {
124
  $gppo = get_post_meta($postID, 'snapVB', true); $gppo = maybe_unserialize($gppo);// prr($gppo);
125
- if (is_array($gppo) && isset($gppo[$ii]) && is_array($gppo[$ii])){ $ntClInst = new nxs_snapClassTW(); $two = $ntClInst->adjMetaOpt($two, $gppo[$ii]); }
126
  $result = nxs_doPublishToVB($postID, $two); if ($result == 200) die("Successfully sent your post to vBulletin."); else die($result);
127
  }
128
  }
@@ -143,7 +163,8 @@ if (!function_exists("nxs_doCheckVB")) {function nxs_doCheckVB($url){ global $nx
143
  return false;
144
  }}
145
  if (!function_exists("nxs_doConnectToVB")) { function nxs_doConnectToVB($u, $p, $url){ global $nxs_vbCkArray; $hdrsArr = nxs_getVBHeaders($url, true); echo "LOGGIN";
146
- $response = wp_remote_get($url); $contents = $response['body']; //$response['body'] = htmlentities($response['body']); prr($response); die();
 
147
  $ckArr = $response['cookies']; $mdhashLoc = stripos($contents, 'md5hash(vb_login_password');
148
  if ($mdhashLoc===false) return "No VB found";
149
  $frmTxt = CutFromTo($contents, 'md5hash(vb_login_password','</form>'); $md = array(); $flds = array();
@@ -164,6 +185,7 @@ if (!function_exists("nxs_doConnectToVB")) { function nxs_doConnectToVB($u, $p,
164
  }}
165
  if (!function_exists("nxs_doPostToVB")) { function nxs_doPostToVB($url, $subj, $msg, $lnk, $tags){ global $nxs_vbCkArray; $hdrsArr = nxs_getVBHeaders($url); $ckArr = $nxs_vbCkArray;
166
  $response = wp_remote_get($url, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr));
 
167
  $contents = $response['body']; //$response['body'] = htmlentities($response['body']); prr($response); die();
168
  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);}
169
  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";
@@ -191,11 +213,11 @@ if (!function_exists("nxs_doPostToVB")) { function nxs_doPostToVB($url, $subj,
191
  }
192
 
193
  //echo $smURL."|"; prr($flds);
194
- $r2 = wp_remote_post( $smURL, array( 'method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds, 'cookies' => $ckArr));
195
  if (stripos($r2['body'], 'errorblock')!==false) return trim(strip_tags( CutFromTo($r2['body'], 'errorblock','</div>')));
196
  if (stripos($r2['body'], 'exec_refresh()')!==false && stripos($r2['body'], 'blockrow restore">')!==false) return trim(strip_tags( CutFromTo($r2['body'], 'blockrow restore">','</p>')));
197
  if (stripos($r2['body'], '<error>')!==false) return trim(strip_tags( CutFromTo($r2['body'], '<error>','</error>')));
198
- if ( $r2['response']['code']=='302' || $r2['response']['code']=='303') return 'OK';
199
  if (stripos($r2['body'], '<newpostid>')!==false || stripos($r2['body'], 'postbit postid="')!==false ) return 'OK';
200
 
201
  // $r2['body'] = htmlentities($r2['body']); prr($r2); die();
@@ -229,9 +251,10 @@ if (!function_exists("nxs_doPublishToVB")) { //## Second Function to Post to VB
229
  } //var_dump($loginError);
230
  if ($loginError!==false) {if ($postID=='0') prr($loginError); nxs_addToLog($logNT, 'E', '-=ERROR=- '.print_r($loginError, true)." - BAD USER/PASS", $extInfo); return " -= BAD USER/PASS =- ";}
231
  $ret = nxs_doPostToVB($options['vbURL'], $msgT, $msg, $link, $tags);
232
- if ($ret!='OK') { if ($postID=='0') prr($ret); nxs_addToLog($logNT, 'E', '-=ERROR=- '.print_r($ret, true), $extInfo);}
233
- else if ($postID=='0') { nxs_addToLog($logNT, 'M', 'OK - TEST Message Posted '); echo ' OK - Message Posted, please see your vBulletin Page '; } else { nxs_metaMarkAsPosted($postID, 'VB', $options['ii']); nxs_addToLog($logNT, 'M', 'OK - Message Posted ', $extInfo); }
234
- if ($ret == 'OK') return 200; else return $ret;
 
235
 
236
  }
237
  }
33
  <div style="width:100%;"><strong>Account Nickname:</strong> <i>Just so you can easely identify it</i> </div><input name="vb[<?php echo $ii; ?>][nName]" id="vbnName<?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")), 'NS_SNAutoPoster') ?>" /><br/>
34
  <?php echo nxs_addQTranslSel('vb', $ii, $options['qTLng']); ?><?php echo nxs_addPostingDelaySel('vb', $ii, $options['nHrs'], $options['nMin']); ?>
35
 
36
+ <?php if (!$isNew) { ?>
37
+ <div style="width:100%;"><strong>Auto-Post Categories:</strong>
38
+ <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="vb[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
39
+ <input value="1" id="catSelSVB<?php echo $ii; ?>" type="radio" name="vb[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_VB<?php echo $ii; ?>" onclick="jQuery('#catSelSVB<?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('VB<?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_VB<?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>
40
+ <input type="hidden" name="vb[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_VB<?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
41
+ </div>
42
+ <br/>
43
+ <?php } ?>
44
+
45
  <div id="altFormat" style="">
46
  <div style="width:100%;"><strong id="altFormatText">vBulletin URL:</strong> <span style="font-size: 11px; margin: 0px;">Could be Forum URL or Thread URL. Either new thread of new post will be created.</span></div>
47
  <input name="vb[<?php echo $ii; ?>][apVBURL]" id="apVBURL" style="width: 60%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['vbURL'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" /> <br/>
90
  if (isset($pval['vbInclTags'])) $options[$ii]['vbInclTags'] = $pval['vbInclTags']; else $options[$ii]['vbInclTags'] = 0;
91
  if (isset($pval['apVBMsgTFrmt'])) $options[$ii]['vbMsgTFormat'] = trim($pval['apVBMsgTFrmt']);
92
  if (isset($pval['apVBMsgFrmt'])) $options[$ii]['vbMsgFormat'] = trim($pval['apVBMsgFrmt']);
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['apDoVB'])) $options[$ii]['doVB'] = $pval['apDoVB']; else $options[$ii]['doVB'] = 0;
98
  if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
99
  if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
102
  }
103
  //#### Show Post->Edit Meta Box Settings
104
  function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
105
+ foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapVB', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]); $doVB = $ntOpt['doVB'] && $ntOpt['catSel']!='1';
106
  $isAvailVB = $ntOpt['vbUName']!='' && $ntOpt['vbPass']!=''; $vbMsgFormat = htmlentities($ntOpt['vbMsgFormat'], ENT_COMPAT, "UTF-8"); $vbMsgTFormat = htmlentities($ntOpt['vbMsgTFormat'], ENT_COMPAT, "UTF-8");
107
  ?>
108
+ <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 } ?>
109
+ <?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; ?>][SNAPincludeVB]" <?php if (($post->post_status == "publish" && $ntOpt['isPosted'] == '1') || ($post->post_status != "publish" && ((int)$doVB == 1)) ) echo 'checked="checked" title="def"'; ?> /> <?php } ?>
110
 
111
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/vb16.png);">vBulletin - publish to (<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" && $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', 're-post') ?>" />
113
  <?php wp_nonce_field( 'rePostToVB', 'rePostToVB_wpnonce' ); } ?>
114
+
115
+ <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) { $wpURL = str_ireplace('/xmlrpc.php', '', $ntOpt['vbURL']);
116
+ if (substr($wpURL, -1)=='/') $wpURL = substr($wpURL, 0, -1); $wpURL = $wpURL."/";
117
+ ?> <span id="pstdVB<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
118
+ <a style="font-size: 10px;" href="<?php echo $pMeta[$ii]['pgID']; ?>" target="_blank">Posted on vBulletin <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
119
+ </span><?php } ?>
120
+
121
  </td></tr>
122
 
123
  <?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>
142
  function nxs_rePostToVB_ajax() { check_ajax_referer('rePostToVB'); $postID = $_POST['id']; $options = get_option('NS_SNAutoPoster');
143
  foreach ($options['vb'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj'; //if ($two['gpPageID'].$two['gpUName']==$_POST['nid']) {
144
  $gppo = get_post_meta($postID, 'snapVB', true); $gppo = maybe_unserialize($gppo);// prr($gppo);
145
+ if (is_array($gppo) && isset($gppo[$ii]) && is_array($gppo[$ii])){ $ntClInst = new nxs_snapClassVB(); $two = $ntClInst->adjMetaOpt($two, $gppo[$ii]); }
146
  $result = nxs_doPublishToVB($postID, $two); if ($result == 200) die("Successfully sent your post to vBulletin."); else die($result);
147
  }
148
  }
163
  return false;
164
  }}
165
  if (!function_exists("nxs_doConnectToVB")) { function nxs_doConnectToVB($u, $p, $url){ global $nxs_vbCkArray; $hdrsArr = nxs_getVBHeaders($url, true); echo "LOGGIN";
166
+ $response = wp_remote_get($url); if(is_wp_error($response)) { nxs_addToLog('VB', 'E', '-=ERROR=- '.print_r($response, true), ''); return "Invalid Connection. Please see log."; }
167
+ $contents = $response['body']; //$response['body'] = htmlentities($response['body']); prr($response); die();
168
  $ckArr = $response['cookies']; $mdhashLoc = stripos($contents, 'md5hash(vb_login_password');
169
  if ($mdhashLoc===false) return "No VB found";
170
  $frmTxt = CutFromTo($contents, 'md5hash(vb_login_password','</form>'); $md = array(); $flds = array();
185
  }}
186
  if (!function_exists("nxs_doPostToVB")) { function nxs_doPostToVB($url, $subj, $msg, $lnk, $tags){ global $nxs_vbCkArray; $hdrsArr = nxs_getVBHeaders($url); $ckArr = $nxs_vbCkArray;
187
  $response = wp_remote_get($url, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr));
188
+ if(is_wp_error($response)) { nxs_addToLog('VB', 'E', '-=ERROR=- '.print_r($response, true), ''); return "Invalid Connection. Please see log."; }
189
  $contents = $response['body']; //$response['body'] = htmlentities($response['body']); prr($response); die();
190
  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);}
191
  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";
213
  }
214
 
215
  //echo $smURL."|"; prr($flds);
216
+ $r2 = wp_remote_post( $smURL, array( 'method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds, 'cookies' => $ckArr));// prr($r2['response']); prr(htmlentities($r2['body'])); $r2['body'] = ''; prr($r2); die();
217
  if (stripos($r2['body'], 'errorblock')!==false) return trim(strip_tags( CutFromTo($r2['body'], 'errorblock','</div>')));
218
  if (stripos($r2['body'], 'exec_refresh()')!==false && stripos($r2['body'], 'blockrow restore">')!==false) return trim(strip_tags( CutFromTo($r2['body'], 'blockrow restore">','</p>')));
219
  if (stripos($r2['body'], '<error>')!==false) return trim(strip_tags( CutFromTo($r2['body'], '<error>','</error>')));
220
+ if ( $r2['response']['code']=='302' || $r2['response']['code']=='303') { return array("code"=>"OK", "post_id"=>$r2['headers']['location']); }
221
  if (stripos($r2['body'], '<newpostid>')!==false || stripos($r2['body'], 'postbit postid="')!==false ) return 'OK';
222
 
223
  // $r2['body'] = htmlentities($r2['body']); prr($r2); die();
251
  } //var_dump($loginError);
252
  if ($loginError!==false) {if ($postID=='0') prr($loginError); nxs_addToLog($logNT, 'E', '-=ERROR=- '.print_r($loginError, true)." - BAD USER/PASS", $extInfo); return " -= BAD USER/PASS =- ";}
253
  $ret = nxs_doPostToVB($options['vbURL'], $msgT, $msg, $link, $tags);
254
+ if ( (!is_array($ret)) && $ret!='OK'){ if ($postID=='0') prr($ret); nxs_addToLog($logNT, 'E', '-=ERROR=- '.print_r($ret, true), $extInfo);}
255
+ else if ($postID=='0') { nxs_addToLog($logNT, 'M', 'OK - TEST Message Posted '); echo ' OK - Message Posted, please see your vBulletin Page '; } else
256
+ { nxs_metaMarkAsPosted($postID, 'VB', $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); }
257
+ if ($ret['code']=='OK') return 200; else return $ret;
258
 
259
  }
260
  }
inc-cl/vk.php ADDED
@@ -0,0 +1,311 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //## NextScripts vKontakte(VK) Connection Class
3
+ $nxs_snapAvNts[] = array('code'=>'VK', 'lcode'=>'vk', 'name'=>'vKontakte(VK)');
4
+
5
+ if (!class_exists("nxs_snapClassVK")) { class nxs_snapClassVK {
6
+ //#### Show Common Settings
7
+ function showGenNTSettings($ntOpts){ global $nxs_snapThisPageUrl, $nxs_plurl; $code = 'VK'; $lcode = 'vk'; wp_nonce_field( 'ns'.$code, 'ns'.$code.'_wpnonce' ); ?>
8
+ <hr/><div class="nsx_iconedTitle" style="background-image: url(<?php echo $nxs_plurl; ?>img/<?php echo $lcode; ?>16.png);">vKontakte(VK) Settings: <?php $cNTo = count($ntOpts); ?> <?php wp_nonce_field( 'nsVK', 'nsVK_wpnonce' ); ?>
9
+ <div class="nsBigText">You have <?php echo $cNTo=='0'?'No':$cNTo; ?> vKontakte(VK) account<?php if ($cNTo!=1){ ?>s<?php } ?> </div></div>
10
+
11
+ <?php foreach ($ntOpts as $indx=>$nto){ $nto['ii'] = $indx; if (trim($nto['nName']=='')) $nto['nName'] = str_ireplace('https://vk.com','', str_ireplace('http://vk.com','', $nto['url'])); ?>
12
+ <p style="margin: 0px;margin-left: 5px;"><input value="1" id="apDoVK" name="vk[<?php echo $indx; ?>][apDoVK]" type="checkbox" <?php if ((int)$nto['doVK'] == 1) echo "checked"; ?> />
13
+ <strong>Auto-publish your Posts to your vKontakte(VK) Page or Profile <i style="color: #005800;"><?php if($nto['nName']!='') echo "(".$nto['nName'].")"; ?></i> </strong>
14
+ &nbsp;&nbsp;<a id="doVK<?php echo $indx; ?>A" href="#" onclick="doShowHideBlocks2('VK<?php echo $indx; ?>');return false;">[Show Settings]</a>&nbsp;&nbsp;
15
+ <a href="#" onclick="doDelAcct('vk', '<?php echo $indx; ?>', '<?php echo $nto['url']; ?>');return false;">[Remove Account]</a>
16
+ </p><?php $this->showNTSettings($indx, $nto);
17
+ } //## END VK Settings
18
+ }
19
+ //#### Show NEW Settings Page
20
+ function showNewNTSettings($mNTo){ $nto = array('nName'=>'', 'doVK'=>'1', 'url'=>'', 'vkAppID'=>'', 'imgUpl'=>'1', 'addBackLink'=>'1', 'vkPostType'=>'A', 'msgAFormat'=>'', 'attch'=>'1', 'vkPgID'=>'', 'vkAppAuthUser'=>'', 'msgFrmt'=>'New post has been published on %SITENAME%' ); $this->showNTSettings($mNTo, $nto, true);}
21
+ //#### Show Unit Settings
22
+ function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl, $nxs_snapThisPageUrl; if ((int)$options['attch']==0 && (!isset($options['trPostType']) || $options['trPostType']=='')) $options['trPostType'] = 'T';
23
+ if (!isset($options['nHrs'])) $options['nHrs'] = 0; if (!isset($options['nMin'])) $options['nMin'] = 0; if (!isset($options['catSel'])) $options['catSel'] = 0; if (!isset($options['catSelEd'])) $options['catSelEd'] = ''; ?>
24
+ <div id="doVK<?php echo $ii; ?>Div" <?php if ($isNew){ ?>class="clNewNTSets"<?php } ?> style="max-width: 1000px; background-color: #EBF4FB; background-image: url(<?php echo $nxs_plurl; ?>img/vk-bg.png); background-position:90% 10%; background-repeat: no-repeat; margin: 10px; border: 1px solid #808080; padding: 10px; <?php if ((isset($options['vkAppAuthUser']) && $options['vkAppAuthUser']>1)||$isNew) { ?>display:none;<?php } ?>"> <input type="hidden" name="apDoSVK<?php echo $ii; ?>" value="0" id="apDoSVK<?php echo $ii; ?>" />
25
+ <?php if ($isNew) { ?> <input type="hidden" name="vk[<?php echo $ii; ?>][apDoVK]" value="1" id="apDoNewVK<?php echo $ii; ?>" /> <?php } ?>
26
+
27
+ <div class="nsx_iconedTitle" style="float: right; max-width: 320px; text-align: right; background-image: url(<?php echo $nxs_plurl; ?>img/vk16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-vkontakte-social-networks-auto-poster-wordpress/">Detailed vKontakte Installation/Configuration Instructions</a><br/>
28
+ <span style="font-size: 10px;">Please use URL <em style="font-size: 10px; color:#CB4B16;">http://<?php echo $_SERVER["SERVER_NAME"] ?></em> and domain <em style="font-size: 10px; color:#CB4B16;"><?php echo $_SERVER["SERVER_NAME"] ?></em> in your vKontakte(VK) App</span>
29
+
30
+ </div>
31
+
32
+ <div style="width:100%;"><strong>Account Nickname:</strong> <i>Just so you can easely identify it</i> </div><input name="vk[<?php echo $ii; ?>][nName]" id="vknName<?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")), 'NS_SNAutoPoster') ?>" /><br/>
33
+ <?php echo nxs_addQTranslSel('vk', $ii, $options['qTLng']); ?>
34
+ <?php echo nxs_addPostingDelaySel('vk', $ii, $options['nHrs'], $options['nMin']); ?>
35
+
36
+ <?php if (!$isNew) { ?>
37
+ <div style="width:100%;"><strong>Auto-Post Categories:</strong>
38
+ <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="vk[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
39
+ <input value="1" id="catSelSVK<?php echo $ii; ?>" type="radio" name="vk[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_VK<?php echo $ii; ?>" onclick="jQuery('#catSelSVK<?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('VK<?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_VK<?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>
40
+ <input type="hidden" name="vk[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_VK<?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
41
+ </div>
42
+ <br/>
43
+ <?php } ?>
44
+
45
+ <div style="width:100%;"><strong>Your vKontakte(VK) URL:</strong> </div>
46
+ <p style="font-size: 11px; margin: 0px;">Could be your vKontakte(VK) Profile or vKontakte(VK) Group Page</p>
47
+ <input name="vk[<?php echo $ii; ?>][url]" id="apurl" style="width: 50%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['url'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" />
48
+
49
+ <div style="width:100%; margin-top: 15px; margin-bottom: 5px;"><b style="font-size: 14px;" >VK API</b> (It could be used for "Text" and "Image" posts)</div>
50
+
51
+ <div style="width:100%; margin-left: 15px;">
52
+
53
+ <div style="width:100%;"><strong>vKontakte(VK) Application ID:</strong> <a href="http://vk.com/editapp?act=create" target="_blank">[Create VK App]</a> <a href="http://vk.com/apps?act=settings" target="_blank">[Manage VK Apps]</a> </div>
54
+ <input name="vk[<?php echo $ii; ?>][apVKAppID]" id="apVKAppID" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['vkAppID'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" />
55
+ <br/>
56
+ <?php if($options['vkAppID']=='') { ?>
57
+ <b>Authorize Your vKontakte(VK) Account</b>. Please click "Update Settings" to be able to Authorize your account.
58
+ <?php } else { if(isset($options['vkAppAuthUser']) && $options['vkAppAuthUser']>0) { ?>
59
+ Your vKontakte(VK) Account has been authorized. User ID: <?php _e(apply_filters('format_to_edit', htmlentities($options['vkAppAuthUser'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>.
60
+ You can Re- <?php } ?>
61
+ <a target="_blank" href="http://api.vkontakte.ru/oauth/authorize?client_id=<?php echo $options['vkAppID'];?>&scope=offline,wall,photos,pages&redirect_uri=http://api.vkontakte.ru/blank.html&display=page&response_type=token<?php '&auth=vk&acc='.$options['ii'];?>">Authorize Your vKontakte(VK) Account</a>
62
+ <!-- <a href="http://api.vkontakte.ru/oauth/authorize?client_id=<?php echo $options['vkAppID'];?>&scope=offline,wall,photos,pages&redirect_uri=<?php echo urlencode($nxs_snapThisPageUrl.'&auth=vk&acc='.$options['ii']);?>">Authorize Your vKontakte(VK) Account</a> -->
63
+ <?php if (!isset($options['vkAppAuthUser']) || $options['vkAppAuthUser']<1) { ?> <div class="blnkg">&lt;=== Authorize your account ===</div> <?php } ?>
64
+
65
+ <div style="width:100%;"><strong>vKontakte(VK) Auth Responce:</strong> </div><input name="vk[<?php echo $ii; ?>][apVKAuthResp]" style="width: 50%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['apVKAuthResp'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" /><br/><br/>
66
+
67
+ <?php } ?>
68
+
69
+ </div>
70
+
71
+ <div style="width:100%; margin-bottom: 5px;"><b style="font-size: 14px;" >NextScripts VK API</b> (It could be used for "Text with attached link" posts)</div>
72
+
73
+ <div style="width:100%; margin-left: 15px;">
74
+ <?php if( function_exists("nxs_doPostToVK")) { ?>
75
+ <div style="width:100%;"><strong>vKontakte(VK) Username:</strong> </div><input name="vk[<?php echo $ii; ?>][uName]" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['uName'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" />
76
+ <div style="width:100%;"><strong>vKontakte(VK) Password:</strong> </div><input name="vk[<?php echo $ii; ?>][uPass]" type="password" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities(substr($options['uPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['uPass'], 5)):$options['uPass'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" />
77
+ <?php } else { ?> **** Please upgrade the plugin to "PRO" get NextScripts VK API <?php } ?>
78
+ </div>
79
+ <br/>
80
+ <div id="altFormat">
81
+ <div style="width:100%;"><strong id="altFormatText">Message text Format:</strong> (<a href="#" id="msgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('msgFrmt<?php echo $ii; ?>'); return false;">Show format info</a>)</div>
82
+ <input name="vk[<?php echo $ii; ?>][msgFrmt]" id="vkmsgFrmt<?php echo $ii; ?>" style="width: 50%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['msgFrmt'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" onfocus="mxs_showFrmtInfo('msgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("msgFrmt".$ii); ?><br/>
83
+ </div>
84
+ <div >
85
+ <input value="1" type="checkbox" name="vk[<?php echo $ii; ?>][addBackLink]" <?php if (isset($options['addBackLink']) && (int)$options['addBackLink'] == 1) echo "checked"; ?> /> Add backlink to the post
86
+ </div>
87
+ <br/>
88
+ <div style="width:100%;"><strong id="altFormatText">Post Type:</strong> </div>
89
+ <div style="margin-left: 10px;">
90
+
91
+ <input type="radio" name="vk[<?php echo $ii; ?>][postType]" value="T" <?php if ($options['postType'] == 'T') echo 'checked="checked"'; ?> /> Text Post - <i>just text message</i><br/>
92
+ <input type="radio" name="vk[<?php echo $ii; ?>][postType]" value="I" <?php if ($options['postType'] == 'I') echo 'checked="checked"'; ?> /> Image Post - <i>big image with text message</i><br/>
93
+ <input type="radio" <?php if( !function_exists("nxs_doPostToVK")) { ?> disabled="disabled" <?php } ?> name="vk[<?php echo $ii; ?>][postType]" value="A" <?php if ( !isset($options['postType']) || $options['postType'] == '' || $options['postType'] == 'A') echo 'checked="checked"'; ?> /> <span <?php if( !function_exists("nxs_doPostToVK")) { ?>style="color:#C0C0C0;"<?php } ?> >Text Post with "attached" link</span><br/>
94
+ <?php if( function_exists("nxs_doPostToVK")) { ?>
95
+ <div style="width:100%; margin-left: 15px;"><strong>Link attachment type:&nbsp;</strong>
96
+ <div style="margin-bottom: 5px; margin-left: 10px; "><input value="1" id="apattchAsVid" type="checkbox" name="vk[<?php echo $ii; ?>][attchAsVid]" <?php if (isset($options['attchAsVid']) && (int)$options['attchAsVid'] == 1) echo "checked"; ?> />
97
+ <strong>If post has video use it as an attachment thumbnail.</strong> <i>Video will be used for an attachment thumbnail instead of featured image. Only Youtube is supported at this time.</i><br/>
98
+
99
+ </div>
100
+ <strong>Attachment Text Format:</strong><br/>
101
+ <input value="1" id="apVKMsgAFrmtA<?php echo $ii; ?>" <?php if (trim($options['msgAFormat'])=='') echo "checked"; ?> onchange="if (jQuery(this).is(':checked')) { jQuery('#apVKMsgAFrmtDiv<?php echo $ii; ?>').hide(); jQuery('#apVKMsgAFrmt<?php echo $ii; ?>').val(''); }else jQuery('#apVKMsgAFrmtDiv<?php echo $ii; ?>').show();" type="checkbox" name="vk[<?php echo $ii; ?>][msgAFormat]"/> <strong>Auto</strong>
102
+ <i> - Recommended. Info from SEO Plugins will be used, then post excerpt, then post text </i><br/>
103
+ <div id="apVKMsgAFrmtDiv<?php echo $ii; ?>" style="<?php if ($options['msgAFormat']=='') echo "display:none;"; ?>" >&nbsp;&nbsp;&nbsp; Set your own format:<input name="vk[<?php echo $ii; ?>][msgAFormat]" id="apVKMsgAFrmt<?php echo $ii; ?>" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['msgAFormat'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" /><br/></div>
104
+ </div><br/>
105
+
106
+ <?php } ?>
107
+
108
+ </div><br/>
109
+
110
+ <div class="popShAtt" style="z-index: 9999" id="popShAtt<?php echo $ii; ?>X"><h3>vKontakte(VK) Post Types</h3><img src="<?php echo $nxs_plurl; ?>img/fbPostTypesDiff6.png" width="600" height="398" alt="vKontakte(VK) Post Types"/></div>
111
+
112
+
113
+ <?php if ($options['vkPgID']!='') {?><div style="width:100%;"><strong>Your vKontakte(VK) Page ID:</strong> <?php _e(apply_filters('format_to_edit', htmlentities($options['vkPgID'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?> </div><?php } ?>
114
+
115
+
116
+
117
+ <?php if(isset($options['vkAppAuthUser']) && $options['vkAppAuthUser']>0) { ?>
118
+ <?php wp_nonce_field( 'rePostToVK', 'rePostToVK_wpnonce' ); ?>
119
+ <br/><br/><b>Test your settings:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('VK','<?php echo $ii; ?>'); return false;">Submit Test Post to vKontakte(VK)</a>
120
+ <?php }?>
121
+ <div class="submit"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'NS_SNAutoPoster') ?>" /></div>
122
+
123
+ </div>
124
+ <?php
125
+
126
+ }
127
+ //#### Set Unit Settings from POST
128
+ function setNTSettings($post, $options){ global $nxs_snapThisPageUrl; $code = 'VK'; $lcode = 'vk';
129
+ foreach ($post as $ii => $pval){
130
+ if (isset($pval['apVKAppID']) && $pval['apVKAppID']!='') { if (!isset($options[$ii])) $options[$ii] = array();
131
+ if (isset($pval['apDoVK'])) $options[$ii]['doVK'] = $pval['apDoVK']; else $options[$ii]['doVK'] = 0;
132
+ if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']);
133
+ if (isset($pval['apVKAppID'])) $options[$ii]['vkAppID'] = trim($pval['apVKAppID']);
134
+
135
+
136
+ if (isset($pval['apVKAuthResp'])) { $options[$ii]['apVKAuthResp'] = trim($pval['apVKAuthResp']);
137
+ $options[$ii]['vkAppAuthToken'] = trim( CutFromTo($pval['apVKAuthResp'].'&', 'access_token=','&'));
138
+ $options[$ii]['vkAppAuthUser'] = trim( CutFromTo($pval['apVKAuthResp']."&", 'user_id=','&'));
139
+ $hdrsArr = nxs_getVKHeaders($pval['url']);
140
+ $response = wp_remote_get($pval['url'], array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr)); $contents = $response['body'];
141
+ if (stripos($contents, '"public_id":')!==false) { $options[$ii]['pgIntID'] = '-'.CutFromTo($contents, '"public_id":', ','); $type='all'; }
142
+ if (stripos($contents, '"user_id":')!==false) { $options[$ii]['pgIntID'] = CutFromTo($contents, '"user_id":', ','); $type='own'; }
143
+ }
144
+
145
+
146
+ if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']);
147
+ if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
148
+
149
+ if (isset($pval['postType'])) $options[$ii]['postType'] = trim($pval['postType']);
150
+ if (isset($pval['attch'])) $options[$ii]['attch'] = $pval['attch']; else $options[$ii]['attch'] = 0;
151
+ if (isset($pval['attchAsVid'])) $options[$ii]['attchAsVid'] = $pval['attchAsVid']; else $options[$ii]['attchAsVid'] = 0;
152
+
153
+ if (isset($pval['apVKImgUpl'])) $options[$ii]['imgUpl'] = $pval['apVKImgUpl']; else $options[$ii]['imgUpl'] = 0;
154
+ if (isset($pval['addBackLink'])) $options[$ii]['addBackLink'] = $pval['addBackLink']; else $options[$ii]['addBackLink'] = 0;
155
+
156
+ if (isset($pval['msgFrmt'])) $options[$ii]['msgFrmt'] = trim($pval['msgFrmt']);
157
+ if (isset($pval['msgAFormat'])) $options[$ii]['msgAFormat'] = trim($pval['msgAFormat']);
158
+
159
+ if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
160
+ if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
161
+
162
+ if (isset($pval['url'])) { $options[$ii]['url'] = trim($pval['url']); if ( substr($options[$ii]['url'], 0, 4)!='http' ) $options[$ii]['url'] = 'http://'.$options[$ii]['url'];
163
+ $vkPgID = $options[$ii]['url']; if (substr($vkPgID, -1)=='/') $vkPgID = substr($vkPgID, 0, -1); $vkPgID = substr(strrchr($vkPgID, "/"), 1);
164
+ if (strpos($vkPgID, '?')!==false) $vkPgID = substr($vkPgID, 0, strpos($vkPgID, '?'));
165
+ $options[$ii]['vkPgID'] = $vkPgID; //echo $vkPgID;
166
+ if (strpos($options[$ii]['url'], '?')!==false) $options[$ii]['url'] = substr($options[$ii]['url'], 0, strpos($options[$ii]['url'], '?'));// prr($pval); prr($options[$ii]); // die();
167
+ }
168
+ }
169
+ } return $options;
170
+ }
171
+ //#### Show Post->Edit Meta Box Settings
172
+ function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
173
+ foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapVK', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]); $doVK = $ntOpt['doVK'] && $ntOpt['catSel']!='1';
174
+ $isAvailVK = $ntOpt['url']!='' && $ntOpt['vkAppID']!='' || $ntOpt['uPass']!=''; $isAttachVK = $ntOpt['attch']; $msgFrmt = htmlentities($ntOpt['msgFrmt'], ENT_COMPAT, "UTF-8"); $postType = $ntOpt['postType'];
175
+ ?>
176
+ <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 } ?>
177
+ <?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; ?>][SNAPincludeVK]" <?php if (($post->post_status == "publish" && $ntOpt['isPosted'] == '1') || ($post->post_status != "publish" && ((int)$doVK == 1)) ) echo 'checked="checked" title="def"'; ?> /> <?php } ?>
178
+ <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 ', 'NS_SPAP'); ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th>
179
+ <td><?php //## Only show RePost button if the post is "published"
180
+ if ($post->post_status == "publish" && $isAvailVK) { ?>
181
+ <input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToVK_repostButton" id="rePostToVK_button" value="<?php _e('Repost to vKontakte(VK)', 're-post') ?>" />
182
+ <?php wp_nonce_field( 'rePostToVK', 'rePostToVK_wpnonce' ); } ?>
183
+ <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID'])) { ?> <span id="pstdVK<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
184
+ <a style="font-size: 10px;" href="http://vk.com/wall<?php echo $pMeta[$ii]['pgID']; ?>" target="_blank">Posted on vKontakte(VK) <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
185
+ </span>
186
+ <?php } ?>
187
+ </td></tr>
188
+ <?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>
189
+ <?php } elseif ($post->post_status != "puZblish") {?>
190
+ <tr id="altFormat1" style=""><th scope="row" valign="top" style="text-align:right; width:60px; padding-right:10px;"><?php _e('Message Format:', 'NS_SPAP') ?></th>
191
+ <td><input value="<?php echo $msgFrmt ?>" type="text" name="vk[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apVKTMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apVKTMsgFrmt".$ii); ?>
192
+ <br/><div ><input value="0" type="hidden" name="vk[<?php echo $ii; ?>][addBackLink]" />
193
+ <input value="1" type="checkbox" name="vk[<?php echo $ii; ?>][addBackLink]" <?php if (isset($ntOpt['addBackLink']) && (int)$ntOpt['addBackLink'] == 1) echo "checked"; ?> /> Add backlink to the post
194
+ </div>
195
+ </td></tr>
196
+ <tr><th scope="row" style="text-align:right; width:150px; vertical-align:top; padding-top: 0px; padding-right:10px;"> Post Type: <br/>
197
+ (<a id="showShAtt" style="font-weight: normal" onmouseout="hidePopShAtt('<?php echo $ii; ?>X');" onmouseover="showPopShAtt('<?php echo $ii; ?>X', event);" onclick="return false;" class="underdash" href="http://www.nextscripts.com/blog/">What's the difference?</a>)</th><td>
198
+ <input type="radio" name="vk[<?php echo $ii; ?>][PostType]" value="T" <?php if ($postType == 'T') echo 'checked="checked"'; ?> /> Text Post - <i>just text message</i><br/>
199
+ <input type="radio" name="vk[<?php echo $ii; ?>][PostType]" value="I" <?php if ($postType == 'I') echo 'checked="checked"'; ?> /> Image Post - <i>big image with text message</i>
200
+ <?php if( function_exists("nxs_doPostToVK")) { ?> <br/>
201
+ <input type="radio" name="vk[<?php echo $ii; ?>][PostType]" value="A" <?php if ( !isset($postType) || $postType == '' || $postType == 'A') echo 'checked="checked"'; ?> /> Text Post with "attached" blogpost
202
+ <?php } ?><br/><div class="popShAtt" id="popShAtt<?php echo $ii; ?>X"><h3>vKontakte(VK) Post Types</h3><img src="<?php echo $nxs_plurl; ?>img/fbPostTypesDiff6.png" width="600" height="398" alt="vKontakte(VK) Post Types"/></div>
203
+ </td></tr><?php }
204
+ }
205
+
206
+ }
207
+
208
+ function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
209
+ if (isset($pMeta['SNAPformat'])) $optMt['msgFrmt'] = $pMeta['SNAPformat'];
210
+ if (isset($pMeta['AttachPost'])) $optMt['attch'] = ($pMeta['AttachPost'] != '')?$pMeta['AttachPost']:0; else { if (isset($pMeta['SNAPformat'])) $optMt['attch'] = 0; }
211
+ if (isset($pMeta['addBackLink'])) $optMt['addBackLink'] = ($pMeta['addBackLink'] != '')?$pMeta['addBackLink']:0; else { if (isset($pMeta['SNAPformat'])) $optMt['addBackLink'] = 0; }
212
+ if (isset($pMeta['PostType'])) $optMt['postType'] = ($pMeta['PostType'] != '')?$pMeta['PostType']:0; else { if (isset($pMeta['SNAPformat'])) $optMt['postType'] = 'T'; }
213
+ if (isset($pMeta['SNAPincludeVK'])) $optMt['doVK'] = $pMeta['SNAPincludeVK'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doVK'] = 0; }
214
+ return $optMt;
215
+ }
216
+ }}
217
+
218
+ if (!function_exists("nxs_rePostToVK_ajax")) { function nxs_rePostToVK_ajax() { check_ajax_referer('rePostToVK'); $postID = $_POST['id']; // $result = nsPublishTo($id, 'VK', true);
219
+ $options = get_option('NS_SNAutoPoster'); foreach ($options['vk'] as $ii=>$nto) if ($ii==$_POST['nid']) { $nto['ii'] = $ii; $nto['pType'] = 'aj';
220
+ $ntpo = get_post_meta($postID, 'snapVK', true); /* echo $postID."|"; echo $fbpo; */ $ntpo = maybe_unserialize($ntpo); // prr($ntpo);
221
+ if (is_array($ntpo) && isset($ntpo[$ii]) && is_array($ntpo[$ii]) ){ $ntClInst = new nxs_snapClassVK(); $nto = $ntClInst->adjMetaOpt($nto, $ntpo[$ii]); } //prr($nto);
222
+ $result = nxs_doPublishToVK($postID, $nto); if ($result == 200) die("Successfully sent your post to vKontakte(VK)."); else die($result);
223
+ }
224
+ }
225
+ }
226
+
227
+ if (!function_exists("nxs_getVKHeaders")) { function nxs_getVKHeaders($ref, $post=false, $aj=false){ $hdrsArr = array();
228
+ $hdrsArr['Cache-Control']='no-cache'; $hdrsArr['Connection']='keep-alive'; $hdrsArr['Referer']=$ref;
229
+ $hdrsArr['User-Agent']='Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.45 Safari/537.17';
230
+ if($post===true) $hdrsArr['Content-Type']='application/x-www-form-urlencoded';
231
+ if($aj===true) $hdrsArr['X-Requested-With']='XMLHttpRequest';
232
+ $hdrsArr['Accept']='text/html, application/xhtml+xml, */*'; $hdrsArr['DNT']='1';
233
+ $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;
234
+ }}
235
+
236
+ if (!function_exists("nxs_uplImgtoVK")) { function nxs_uplImgtoVK($imgURL, $options){
237
+ $postUrl = 'https://api.vkontakte.ru/method/photos.getWallUploadServer?gid='.$options['pgIntID'].'&access_token='.$options['vkAppAuthToken'];
238
+ $response = wp_remote_get($postUrl); $thumbUploadUrl = $response['body'];
239
+ if (!empty($thumbUploadUrl)) { $thumbUploadUrlObj = json_decode($thumbUploadUrl); $VKuploadUrl = $thumbUploadUrlObj->response->upload_url; }
240
+ if (!empty($VKuploadUrl)) {
241
+ $remImgURL = urldecode($imgURL); $urlParced = pathinfo($remImgURL); $remImgURLFilename = $urlParced['basename']; $imgData = wp_remote_get($remImgURL); $imgData = $imgData['body'];
242
+ $tmp=array_search('uri', @array_flip(stream_get_meta_data($GLOBALS[mt_rand()]=tmpfile())));
243
+ rename($tmp, $tmp.='.png'); register_shutdown_function(create_function('', "unlink('{$tmp}');"));
244
+ file_put_contents($tmp, $imgData);
245
+
246
+ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $VKuploadUrl); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
247
+ curl_setopt($ch, CURLOPT_POSTFIELDS, array('photo' => '@' . $tmp)); $response = curl_exec($ch); $errmsg = curl_error($ch); curl_close($ch);
248
+
249
+ $uploadResultObj = json_decode($response);
250
+
251
+ if (!empty($uploadResultObj->server) && !empty($uploadResultObj->photo) && !empty($uploadResultObj->hash)) {
252
+ $postUrl = 'https://api.vkontakte.ru/method/photos.saveWallPhoto?server='.$uploadResultObj->server.'&photo='.$uploadResultObj->photo.'&hash='.$uploadResultObj->hash.'&gid='.$options['pgIntID'].'&access_token='.$options['vkAppAuthToken'];
253
+ $response = wp_remote_get($postUrl);
254
+ $resultObject = json_decode($response['body']);// prr($resultObject);
255
+ if (isset($resultObject) && isset($resultObject->response[0]->id)) { return $resultObject->response[0]; } else { return false; }
256
+ }
257
+ }
258
+ }}
259
+
260
+ if (!function_exists("nxs_doPublishToVK")) { //## Second Function to Post to VK
261
+ function nxs_doPublishToVK($postID, $options){ global $ShownAds, $nxs_vkCkArray; $ntCd = 'VK'; $ntCdL = 'vk'; $ntNm = 'vKontakte(VK)';
262
+ $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10)); $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
263
+ if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
264
+ nxs_addToLog($ntCd.' - '.$options['nName'], 'E', '-=Duplicate=- Post ID:'.$postID, 'Not posted. No reason for posting duplicate'); return;
265
+ }
266
+ $email = $options['uName']; $pass = (substr($options['uPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['uPass'], 5)):$options['uPass']);
267
+ if ($postID=='0') { echo "Testing ... <br/><br/>"; $link = home_url(); $msg = 'Test Link from '.$link; } else { $post = get_post($postID); if(!$post) return;
268
+ $msgFormat = $options['msgFrmt']; $msg = nsFormatMessage($msgFormat, $postID); $link = get_permalink($postID); nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
269
+ }
270
+ $dusername = $options['uName']; $postType = $options['postType']; //$link = urlencode($link); $desc = urlencode(substr($msg, 0, 500));
271
+ $extInfo = ' | PostID: '.$postID." - ".$post->post_title; $logNT = '<span style="color:#000080">StumbleUpon</span> - '.$options['nName'];
272
+
273
+ $msgOpts = array(); $msgOpts['type'] = $postType; $msgOpts['uid'] = $options['vkPgID']; $imgURL = nxs_getPostImage($postID);// if ($link!='') $msgOpts['link'] = $link;
274
+ if ($postType=='I' && trim($imgURL)=='') $postType='T';
275
+ if ($postType=='A' && $link!='') {
276
+ //## Login
277
+ if (isset($options['vkSvC'])) $nxs_vkCkArray = maybe_unserialize( $options['vkSvC']); $loginError = true;
278
+ if (is_array($nxs_vkCkArray)) $loginError = nxs_doCheckVK(); if ($loginError!=false) $loginError = nxs_doConnectToVK($email, $pass);
279
+ if (serialize($nxs_vkCkArray)!=$options['vkSvC']) { global $plgn_NS_SNAutoPoster; $gOptions = $plgn_NS_SNAutoPoster->nxs_options;
280
+ if (isset($options['ii']) && $options['ii']!=='') { $gOptions['vk'][$options['ii']]['vkSvC'] = serialize($nxs_vkCkArray); update_option('NS_SNAutoPoster', $gOptions); }
281
+ else foreach ($gOptions['vk'] as $ii=>$gpn) { $result = array_diff($options, $gpn);
282
+ if (!is_array($result) || count($result)<1) { $gOptions['vk'][$ii]['vkSvC'] = serialize($nxs_vkCkArray); update_option('NS_SNAutoPoster', $gOptions); break; }
283
+ }
284
+ }
285
+ if ($loginError!==false) {if ($postID=='0') prr($loginError); nxs_addToLog($logNT, 'E', '-=ERROR=- '.print_r($loginError, true)." - BAD USER/PASS", $extInfo); return " -= BAD USER/PASS =- ";}
286
+ //## Post
287
+ 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));
288
+ if (function_exists('wpseo_admin_init') && $dsc=='') $dsc = trim(get_post_meta($postID, '_yoast_wpseo_opengraph-description', true));
289
+ if (function_exists('wpseo_admin_init') && $dsc=='') $dsc = trim(get_post_meta($postID, '_yoast_wpseo_metadesc', true));
290
+ if ($dsc=='') $dsc = trim(apply_filters('the_content', nxs_doQTrans($post->post_excerpt, $lng))); if ($dsc=='') $dsc = trim(nxs_doQTrans($post->post_excerpt, $lng));
291
+ if ($dsc=='') $dsc = trim(apply_filters('the_content', nxs_doQTrans($post->post_content, $lng))); if ($dsc=='') $dsc = trim(nxs_doQTrans($post->post_content, $lng));
292
+ if ($dsc=='') $dsc = get_bloginfo('description');
293
+ } $dsc = strip_tags($dsc); $dsc = nxs_decodeEntitiesFull($dsc); $dsc = nsTrnc($dsc, 900, ' ');
294
+ $msgOpts['url'] = $link; $msgOpts['urlTitle'] = nxs_doQTrans($post->post_title, $lng); $msgOpts['urlDesc'] = $dsc; $msgOpts['imgURL'] = $imgURL;
295
+ $ret = nxs_doPostToVK($msg, $options['url'], $msgOpts); // prr($ret);
296
+ }
297
+ if ($postType=='I') { $imgUpld = nxs_uplImgtoVK($imgURL, $options); if (is_object($imgUpld)) { $imgID = $imgUpld->id; $atts[] = $imgID; }}
298
+ if ($postType!='A') { if( $options['addBackLink']=='1') $atts[] = $link;
299
+ if (is_array($atts)) $atts = implode(',', $atts);
300
+ $postUrl = 'https://api.vkontakte.ru/method/wall.post?owner_id='.$options['pgIntID'].'&access_token='.$options['vkAppAuthToken'].'&from_group=1&message='.urlencode($msg).'&attachment='.urlencode($atts);
301
+ $response = wp_remote_get($postUrl);
302
+ if ( is_wp_error($response) || (is_object($response) && (isset($response->errors))) || (is_array($response) && stripos($response['body'],'"error":')!==false )) {nxs_addToLog($logNT, 'E', '-=ERROR=- '.print_r($response, true), $extInfo); }
303
+ else { $respJ = json_decode($response['body'], true); $ret = array("code"=>"OK", "post_id"=>$options['pgIntID'].'_'.$respJ['response']['post_id']); }
304
+
305
+ }
306
+ if (is_array($ret) && $ret['code']=='OK') { if ($postID=='0') { nxs_addToLog($logNT, 'M', 'OK - TEST Message Posted '); echo ' OK - Message Posted, please see your VK Page '; } else
307
+ { nxs_metaMarkAsPosted($postID, 'VK', $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); return 200; }
308
+ } else {if ($postID=='0') prr($ret); nxs_addToLog($logNT, 'E', '-=ERROR=- '.print_r($ret, true), $extInfo);}
309
+ }
310
+ }
311
+ ?>
inc-cl/wp.php CHANGED
@@ -31,7 +31,16 @@ if (!class_exists("nxs_snapClassWP")) { class nxs_snapClassWP {
31
  <?php if ($isNew){ ?> <br/>You can setup any Wordpress based blog with activated XML-RPC support (WP Admin->Settimgs->Writing->Remote Publishing->Check XML-RPC). Wordpress.com and Blog.com supported as well.<br/><br/> <?php } ?>
32
 
33
  <div style="width:100%;"><strong>Account Nickname:</strong> <i>Just so you can easely identify it</i> </div><input name="wp[<?php echo $ii; ?>][nName]" id="wpnName<?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")), 'NS_SNAutoPoster') ?>" /><br/>
34
- <?php echo nxs_addQTranslSel('wp', $ii, $options['qTLng']); ?><?php echo nxs_addPostingDelaySel('wp', $ii, $gpo['nHrs'], $gpo['nMin']); ?>
 
 
 
 
 
 
 
 
 
35
 
36
  <div style="width:100%;"><strong>XMLRPC URL:</strong> </div><input name="wp[<?php echo $ii; ?>][apWPURL]" id="apWPURL" style="width: 50%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($gpo['wpURL'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" />
37
  <p style="font-size: 11px; margin: 0px;">Usually its a URL of your Wordpress installation with /xmlrpc.php at the end.<br/> Please use <b style="color: #005800;">http://YourUserName.wordpress.com/xmlrpc.php</b> (replace YourUserName with your user name - for example <i style="color: #005800;">http://nextscripts.wordpress.com/xmlrpc.php</i>) for Wordpress.com blogs. <br/> Please use <b style="color: #005800;">http://YourUserName.blog.com/xmlrpc.php</b> (replace YourUserName with your user name - for example <i style="color: #005800;">http://nextscripts.blog.com/xmlrpc.php</i> for Blog.com blogs</p>
@@ -69,7 +78,11 @@ if (!class_exists("nxs_snapClassWP")) { class nxs_snapClassWP {
69
  if (isset($pval['apWPUName'])) $options[$ii]['wpUName'] = trim($pval['apWPUName']);
70
  if (isset($pval['apWPPass'])) $options[$ii]['wpPass'] = 'n5g9a'.nsx_doEncode($pval['apWPPass']); else $options[$ii]['wpPass'] = '';
71
  if (isset($pval['apWPMsgFrmt'])) $options[$ii]['wpMsgFormat'] = trim($pval['apWPMsgFrmt']);
72
- if (isset($pval['apWPMsgTFrmt'])) $options[$ii]['wpMsgTFormat'] = trim($pval['apWPMsgTFrmt']);
 
 
 
 
73
  if (isset($pval['apDoWP'])) $options[$ii]['doWP'] = $pval['apDoWP']; else $options[$ii]['doWP'] = 0;
74
  if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
75
  if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
@@ -78,14 +91,21 @@ if (!class_exists("nxs_snapClassWP")) { class nxs_snapClassWP {
78
  }
79
  //#### Show Post->Edit Meta Box Settings
80
  function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
81
- foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapWP', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]); $doWP = $ntOpt['doWP'];
82
  $isAvailWP = $ntOpt['wpUName']!='' && $ntOpt['wpPass']!=''; $wpMsgFormat = htmlentities($ntOpt['wpMsgFormat'], ENT_COMPAT, "UTF-8"); $wpMsgTFormat = htmlentities($ntOpt['wpMsgTFormat'], ENT_COMPAT, "UTF-8");
83
  ?>
84
- <tr><th style="text-align:left;" colspan="2">
85
- <?php if ($isAvailWP) { ?><input class="nxsGrpDoChb" value="1" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="wp[<?php echo $ii; ?>][SNAPincludeWP]" <?php if (($post->post_status == "publish" && $ntOpt['isPosted'] == '1') || ($post->post_status != "publish" && ((int)$doWP == 1)) ) echo 'checked="checked" title="def"'; ?> /> <?php } ?>
86
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/wp16.png);">WP Blog - publish to (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
87
  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', 're-post') ?>" />
88
  <?php wp_nonce_field( 'rePostToWP', 'rePostToWP_wpnonce' ); } ?>
 
 
 
 
 
 
 
89
  </td></tr>
90
 
91
  <?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>
@@ -124,9 +144,9 @@ if (!function_exists("nxs_doPublishToWP")) { //## Second Function to Post to WP
124
  if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
125
  nxs_addToLog($ntCd.' - '.$options['nName'], 'E', '-=Duplicate=- Post ID:'.$postID, 'Not posted. No reason for posting duplicate'); return;
126
  }
127
- if (function_exists("get_post_thumbnail_id") ){ $src = wp_get_attachment_image_src(get_post_thumbnail_id($postID), 'thumbnail'); $src = $src[0];}
128
  $email = $options['wpUName']; $pass = substr($options['wpPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['wpPass'], 5)):$options['wpPass'];
129
- 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); $img = $src;
130
  $msgFormat = $options['wpMsgFormat']; $msg = nsFormatMessage($msgFormat, $postID); $msgTFormat = $options['wpMsgTFormat']; $msgT = nsFormatMessage($msgTFormat, $postID);
131
  nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
132
  }
@@ -136,8 +156,8 @@ if (!function_exists("nxs_doPublishToWP")) { //## Second Function to Post to WP
136
 
137
  //## Post
138
  require_once ('apis/xmlrpc-client.php'); $nxsToWPclient = new NXS_XMLRPC_Client($options['wpURL']); $nxsToWPclient->debug = false;
139
- if ($src!=='' && stripos($src, 'http')!==false) {
140
- $handle = fopen($src, "rb"); $filedata = ''; while (!feof($handle)) {$filedata .= fread($handle, 8192);} fclose($handle);
141
  $data = array('name' => 'image-'.$postID.'.jpg', 'type' => 'image/jpg', 'bits' => new NXS_XMLRPC_Base64($filedata), true);
142
  $status = $nxsToWPclient->query('metaWeblog.newMediaObject', $postID, $options['wpUName'], $pass, $data); $imgResp = $nxsToWPclient->getResponse(); $gid = $imgResp['id'];
143
  } else $gid = '';
@@ -172,7 +192,8 @@ if (!function_exists("nxs_doPublishToWP")) { //## Second Function to Post to WP
172
  }
173
  } if ($ret!='OK') { if ($postID=='0') echo $ret;
174
  nxs_addToLog($logNT, 'E', '-=ERROR=- '.print_r($ret, true), $extInfo);
175
- } else { if ($postID=='0') { echo 'OK - Message Posted, please see your WP Blog'; nxs_addToLog($logNT, 'M', 'OK - TEST Message Posted '); } else { nxs_metaMarkAsPosted($postID, 'WP', $options['ii']); nxs_addToLog($logNT, 'M', 'OK - Message Posted ', $extInfo);} }
 
176
  if ($ret == 'OK') return 200; else return $ret;
177
  }
178
  }
31
  <?php if ($isNew){ ?> <br/>You can setup any Wordpress based blog with activated XML-RPC support (WP Admin->Settimgs->Writing->Remote Publishing->Check XML-RPC). Wordpress.com and Blog.com supported as well.<br/><br/> <?php } ?>
32
 
33
  <div style="width:100%;"><strong>Account Nickname:</strong> <i>Just so you can easely identify it</i> </div><input name="wp[<?php echo $ii; ?>][nName]" id="wpnName<?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")), 'NS_SNAutoPoster') ?>" /><br/>
34
+ <?php echo nxs_addQTranslSel('wp', $ii, $gpo['qTLng']); ?><?php echo nxs_addPostingDelaySel('wp', $ii, $gpo['nHrs'], $gpo['nMin']); ?>
35
+
36
+ <?php if (!$isNew) { ?>
37
+ <div style="width:100%;"><strong>Auto-Post Categories:</strong>
38
+ <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="wp[<?php echo $ii; ?>][catSel]" <?php if ((int)$gpo['catSel'] != 1) echo "checked"; ?> /> All
39
+ <input value="1" id="catSelSWP<?php echo $ii; ?>" type="radio" name="wp[<?php echo $ii; ?>][catSel]" <?php if ((int)$gpo['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_WP<?php echo $ii; ?>" onclick="jQuery('#catSelSWP<?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('WP<?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_WP<?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>
40
+ <input type="hidden" name="wp[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_WP<?php echo $ii; ?>" value="<?php echo $gpo['catSelEd']; ?>" />
41
+ </div>
42
+ <br/>
43
+ <?php } ?>
44
 
45
  <div style="width:100%;"><strong>XMLRPC URL:</strong> </div><input name="wp[<?php echo $ii; ?>][apWPURL]" id="apWPURL" style="width: 50%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($gpo['wpURL'], ENT_COMPAT, "UTF-8")), 'NS_SNAutoPoster') ?>" />
46
  <p style="font-size: 11px; margin: 0px;">Usually its a URL of your Wordpress installation with /xmlrpc.php at the end.<br/> Please use <b style="color: #005800;">http://YourUserName.wordpress.com/xmlrpc.php</b> (replace YourUserName with your user name - for example <i style="color: #005800;">http://nextscripts.wordpress.com/xmlrpc.php</i>) for Wordpress.com blogs. <br/> Please use <b style="color: #005800;">http://YourUserName.blog.com/xmlrpc.php</b> (replace YourUserName with your user name - for example <i style="color: #005800;">http://nextscripts.blog.com/xmlrpc.php</i> for Blog.com blogs</p>
78
  if (isset($pval['apWPUName'])) $options[$ii]['wpUName'] = trim($pval['apWPUName']);
79
  if (isset($pval['apWPPass'])) $options[$ii]['wpPass'] = 'n5g9a'.nsx_doEncode($pval['apWPPass']); else $options[$ii]['wpPass'] = '';
80
  if (isset($pval['apWPMsgFrmt'])) $options[$ii]['wpMsgFormat'] = trim($pval['apWPMsgFrmt']);
81
+ if (isset($pval['apWPMsgTFrmt'])) $options[$ii]['wpMsgTFormat'] = trim($pval['apWPMsgTFrmt']);
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['apDoWP'])) $options[$ii]['doWP'] = $pval['apDoWP']; else $options[$ii]['doWP'] = 0;
87
  if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
88
  if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
91
  }
92
  //#### Show Post->Edit Meta Box Settings
93
  function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
94
+ foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapWP', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]); $doWP = $ntOpt['doWP'] && $ntOpt['catSel']!='1';
95
  $isAvailWP = $ntOpt['wpUName']!='' && $ntOpt['wpPass']!=''; $wpMsgFormat = htmlentities($ntOpt['wpMsgFormat'], ENT_COMPAT, "UTF-8"); $wpMsgTFormat = htmlentities($ntOpt['wpMsgTFormat'], 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_WP<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
98
+ <?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; ?>][SNAPincludeWP]" <?php if (($post->post_status == "publish" && $ntOpt['isPosted'] == '1') || ($post->post_status != "publish" && ((int)$doWP == 1)) ) echo 'checked="checked" title="def"'; ?> /> <?php } ?>
99
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/wp16.png);">WP Blog - publish to (<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" && $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', 're-post') ?>" />
101
  <?php wp_nonce_field( 'rePostToWP', 'rePostToWP_wpnonce' ); } ?>
102
+
103
+ <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) { $wpURL = str_ireplace('/xmlrpc.php', '', $ntOpt['wpURL']);
104
+ if (substr($wpURL, -1)=='/') $wpURL = substr($wpURL, 0, -1); $wpURL = $wpURL."/";
105
+ ?> <span id="pstdWP<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
106
+ <a style="font-size: 10px;" href="<?php echo $wpURL; ?>?p=<?php echo $pMeta[$ii]['pgID']; ?>" target="_blank">Posted on Wordpress Blog <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
107
+ </span><?php } ?>
108
+
109
  </td></tr>
110
 
111
  <?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>
144
  if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
145
  nxs_addToLog($ntCd.' - '.$options['nName'], 'E', '-=Duplicate=- Post ID:'.$postID, 'Not posted. No reason for posting duplicate'); return;
146
  }
147
+ $imgURL = nxs_getPostImage($postID);
148
  $email = $options['wpUName']; $pass = substr($options['wpPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['wpPass'], 5)):$options['wpPass'];
149
+ 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);
150
  $msgFormat = $options['wpMsgFormat']; $msg = nsFormatMessage($msgFormat, $postID); $msgTFormat = $options['wpMsgTFormat']; $msgT = nsFormatMessage($msgTFormat, $postID);
151
  nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
152
  }
156
 
157
  //## Post
158
  require_once ('apis/xmlrpc-client.php'); $nxsToWPclient = new NXS_XMLRPC_Client($options['wpURL']); $nxsToWPclient->debug = false;
159
+ if ($imgURL!=='' && stripos($imgURL, 'http')!==false) {
160
+ $handle = fopen($imgURL, "rb"); $filedata = ''; while (!feof($handle)) {$filedata .= fread($handle, 8192);} fclose($handle);
161
  $data = array('name' => 'image-'.$postID.'.jpg', 'type' => 'image/jpg', 'bits' => new NXS_XMLRPC_Base64($filedata), true);
162
  $status = $nxsToWPclient->query('metaWeblog.newMediaObject', $postID, $options['wpUName'], $pass, $data); $imgResp = $nxsToWPclient->getResponse(); $gid = $imgResp['id'];
163
  } else $gid = '';
192
  }
193
  } if ($ret!='OK') { if ($postID=='0') echo $ret;
194
  nxs_addToLog($logNT, 'E', '-=ERROR=- '.print_r($ret, true), $extInfo);
195
+ } else { if ($postID=='0') { echo 'OK - Message Posted, please see your WP Blog'; nxs_addToLog($logNT, 'M', 'OK - TEST Message Posted '); } else
196
+ { nxs_metaMarkAsPosted($postID, 'WP', $options['ii'], array('isPosted'=>'1', 'pgID'=>$pid, 'pDate'=>date('Y-m-d H:i:s'))); nxs_addToLog($logNT, 'M', 'OK - Message Posted ', $extInfo);} }
197
  if ($ret == 'OK') return 200; else return $ret;
198
  }
199
  }
js/js.js ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function(jQuery){ jQuery.generateFile = function(options){ options = options || {};
2
+ if(!options.script || !options.filename || !options.content){
3
+ throw new Error("Please enter all the required config options!");
4
+ }
5
+ var iframe = jQuery('<iframe>',{ width:1, height:1, frameborder:0, css:{ display:'none' } }).appendTo('body');
6
+ var formHTML = '<form action="" method="post"><input type="hidden" name="filename" /><input type="hidden" name="_wpnonce" /><input type="hidden" name="action" value="nxs_getExpSettings" /></form>';
7
+ setTimeout(function(){
8
+ var body = (iframe.prop('contentDocument') !== undefined) ? iframe.prop('contentDocument').body : iframe.prop('document').body; // IE
9
+ body = jQuery(body); body.html(formHTML); var form = body.find('form');
10
+ form.attr('action',options.script);
11
+ form.find('input[name=filename]').val(options.filename);
12
+ form.find('input[name=_wpnonce]').val(options.content);
13
+ form.submit();
14
+ },50);
15
+ };
16
+ })(jQuery);
17
+
18
+ function nxs_expSettings(){
19
+ jQuery.generateFile({ filename: 'nx-snap-settings.txt', content: jQuery('input#nsDN_wpnonce').val(), script: 'admin-ajax.php'});
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
+
28
+ //## Select/Unselect Categories
29
+ function nxs_chAllCatsL(ch, divID){ jQuery("#"+divID+" input:checkbox[name='post_category[]']").attr('checked', ch==1); }
30
+ function nxs_markCats(cats){ var catsA = cats.split(',');
31
+ jQuery("#showCatSel input:checkbox[name='post_category[]']").each(function(index) { jQuery(this).attr('checked', jQuery.inArray(jQuery(this).val(), catsA)>-1); });
32
+ }
33
+ function nxs_doSetSelCats(nt, idNum){ var scc = ''; var sccA = [];
34
+ jQuery("#showCatSel input:checkbox[name='post_category[]']").each(function(index) { if(jQuery(this).is(":checked")) sccA.push(jQuery(this).val()); });
35
+ var sccL = sccA.length; if (sccL>0) scc = sccA.join(","); jQuery('#nxs_SC_'+nt).val(scc); jQuery('#nxs_SCA_'+nt).html('Selected ['+sccL+']');
36
+ }
37
+
38
+ 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'); }
39
+ function hidePopShAtt(imid){ jQuery('div#popShAtt'+imid).hide(); }
40
+ function doSwitchShAtt(att, idNum){
41
+ //if (att==1) { jQuery('#apFBAttch'+idNum).attr('checked', true); jQuery('#apFBAttchShare'+idNum).attr('checked', false); } else {jQuery('#apFBAttch'+idNum).attr('checked', false); jQuery('#apFBAttchShare'+idNum).attr('checked', true);}
42
+ if (att==1) { if (jQuery('#apFBAttch'+idNum).is(":checked")) jQuery('#apFBAttchShare'+idNum).attr('checked', false); } else { if( jQuery('#apFBAttchShare'+idNum).is(":checked")) jQuery('#apFBAttch'+idNum).attr('checked', false);}
43
+ }
44
+
45
+ function doShowHideAltFormat(){ if (jQuery('#NS_SNAutoPosterAttachPost').is(':checked')) {
46
+ jQuery('#altFormat').css('margin-left', '20px'); jQuery('#altFormatText').html('Post Announce Text:'); } else {jQuery('#altFormat').css('margin-left', '0px'); jQuery('#altFormatText').html('Post Text Format:');}
47
+ }
48
+ function doShowHideBlocks(blID){ if (jQuery('#apDo'+blID).is(':checked')) jQuery('#do'+blID+'Div').show(); else jQuery('#do'+blID+'Div').hide();}
49
+ function doShowHideBlocks1(blID, shhd){ if (shhd==1) jQuery('#do'+blID+'Div').show(); else jQuery('#do'+blID+'Div').hide();}
50
+ function doShowHideBlocks2(blID){ if (jQuery('#apDoS'+blID).val()=='0') { jQuery('#do'+blID+'Div').show(); jQuery('#do'+blID+'A').text('[Hide Settings]'); jQuery('#apDoS'+blID).val('1'); }
51
+ else { jQuery('#do'+blID+'Div').hide(); jQuery('#do'+blID+'A').text('[Show Settings]'); jQuery('#apDoS'+blID).val('0'); }
52
+ }
53
+
54
+ function doShowFillBlock(blIDTo, blIDFrm){ jQuery('#'+blIDTo).html(jQuery('#do'+blIDFrm+'Div').html());}
55
+ function doCleanFillBlock(blIDFrm){ jQuery('#do'+blIDFrm+'Div').html('');}
56
+
57
+ function doShowFillBlockX(blIDFrm){ jQuery('.clNewNTSets').hide(); jQuery('#do'+blIDFrm+'Div').show(); }
58
+
59
+ function doDelAcct(nt, blID, blName){ var answer = confirm("Remove "+blName+" account?");
60
+ if (answer){ var data = { action: 'nsDN', id: 0, nt: nt, id: blID, _wpnonce: jQuery('input#nsDN_wpnonce').val()};
61
+ jQuery.post(ajaxurl, data, function(response) { location.reload(); });
62
+ }
63
+ }
64
+
65
+ function callAjSNAP(data, label) {
66
+ var style = "position: fixed; display: none; z-index: 1000; top: 50%; left: 50%; background-color: #E8E8E8; border: 1px solid #555; padding: 15px; width: 350px; min-height: 80px; margin-left: -175px; margin-top: -40px; text-align: center; vertical-align: middle;";
67
+ jQuery('body').append("<div id='test_results' style='" + style + "'></div>");
68
+ jQuery('#test_results').html("<p>Sending update to "+label+"</p>" + "<p><img src='http://gtln.us/img/misc/ajax-loader-med.gif' /></p>");
69
+ jQuery('#test_results').show();
70
+ jQuery.post(ajaxurl, data, function(response) { if (response=='') response = 'Message Posted';
71
+ jQuery('#test_results').html('<p> ' + response + '</p>' +'<input type="button" class="button" name="results_ok_button" id="results_ok_button" value="OK" />');
72
+ jQuery('#results_ok_button').click(remove_results);
73
+ });
74
+ }
75
+ function remove_results() { jQuery("#results_ok_button").unbind("click");jQuery("#test_results").remove();
76
+ if (typeof document.body.style.maxHeight == "undefined") { jQuery("body","html").css({height: "auto", width: "auto"}); jQuery("html").css("overflow","");}
77
+ document.onkeydown = "";document.onkeyup = ""; return false;
78
+ }
79
+
80
+ function mxs_showHideFrmtInfo(hid){
81
+ if(!jQuery('#'+hid+'Hint').is(':visible')) mxs_showFrmtInfo(hid); else {jQuery('#'+hid+'Hint').hide(); jQuery('#'+hid+'HintInfo').html('Show format info');}
82
+ }
83
+ function mxs_showFrmtInfo(hid){
84
+ jQuery('#'+hid+'Hint').show(); jQuery('#'+hid+'HintInfo').html('Hide format info');
85
+ }
86
+ function nxs_clLog(){
87
+ jQuery.post(ajaxurl,{action: 'nxs_clLgo', id: 0, _wpnonce: jQuery('input#nxsSsPageWPN_wpnonce').val(), ajax: 'true'}, function(j){ var options = '';
88
+ jQuery("#nxslogDiv").html('');
89
+ }, "html")
90
+ }
91
+ function nxs_rfLog(){
92
+ jQuery.post(ajaxurl,{action: 'nxs_rfLgo', id: 0, _wpnonce: jQuery('input#nxsSsPageWPN_wpnonce').val(), ajax: 'true'}, function(j){ var options = '';
93
+ jQuery("#nxslogDiv").html(j);
94
+ }, "html")
95
+ }
96
+ function nxs_prxTest(){ jQuery('#nxs_pchAjax').show();
97
+ jQuery.post(ajaxurl,{action: 'nxs_prxTest', id: 0, _wpnonce: jQuery('input#nxsSsPageWPN_wpnonce').val(), ajax: 'true'}, function(j){ var options = '';
98
+ jQuery('#nxs_pchAjax').hide(); jQuery("#prxList").html(j);
99
+ }, "html")
100
+ }
101
+ function nxs_prxGet(){ jQuery('#nxs_pchAjax').show();
102
+ jQuery.post(ajaxurl,{action: 'nxs_prxGet', id: 0, _wpnonce: jQuery('input#nxsSsPageWPN_wpnonce').val(), ajax: 'true'}, function(j){ var options = '';
103
+ jQuery('#nxs_pchAjax').hide(); jQuery("#prxList").html(j);
104
+ }, "html")
105
+ }
106
+ function nxs_TRSetEnable(ptype, ii){
107
+ if (ptype=='I'){ jQuery('#apTRMsgTFrmt'+ii).attr('disabled', 'disabled'); jQuery('#apTRDefImg'+ii).removeAttr('disabled'); }
108
+ else { jQuery('#apTRDefImg'+ii).attr('disabled', 'disabled'); jQuery('#apTRMsgTFrmt'+ii).removeAttr('disabled'); }
109
+ }
110
+ function nxsTRURLVal(ii){ var val = jQuery('#apTRURL'+ii).val(); var srch = val.toLowerCase().indexOf('http://www.tumblr.com/blog/');
111
+ if (srch>-1) { jQuery('#apTRURL'+ii).css({"background-color":"#FFC0C0"}); jQuery('#apTRURLerr'+ii).html('<br/>Incorrect URL: Please note that URL of your Tumblr Blog should be your public URL. (i.e. like http://nextscripts.tumblr.com/, not http://www.tumblr.com/blog/nextscripts'); } else { jQuery('#apTRURL'+ii).css({"background-color":"#ffffff"}); jQuery('#apTRURLerr'+ii).text(''); }
112
+ }
113
+
114
+ (function($) {
115
+ $(function() {
116
+ $('#nxs_snapAddNew').bind('click', function(e) { e.preventDefault(); $('#nxs_spPopup').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [65, 50]}); });
117
+ $('#showLic').bind('click', function(e) { e.preventDefault(); $('#showLicForm').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false]}); });
118
+ /* // Will move it here later for better compatibility
119
+ $('.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="" />');
120
+ str = str.replace(/post_category/g, "pk"); $('div.categorydiv').replaceWith('<input type="hidden" name="post_category" value="'+str+'" />');
121
+ });
122
+ */
123
+ });
124
+ })(jQuery);
125
+
126
+
127
+ /// #####
128
+ (function(b){b.fn.bPopup=function(n,p){function t(){b.isFunction(a.onOpen)&&a.onOpen.call(c);k=(e.data("bPopup")||0)+1;d="__bPopup"+k;l="auto"!==a.position[1];m="auto"!==a.position[0];i="fixed"===a.positionStyle;j=r(c,a.amsl);f=l?a.position[1]:j[1];g=m?a.position[0]:j[0];q=s();a.modal&&b('<div class="bModal '+d+'"></div>').css({"background-color":a.modalColor,height:"100%",left:0,opacity:0,position:"fixed",top:0,width:"100%","z-index":a.zIndex+k}).each(function(){a.appending&&b(this).appendTo(a.appendTo)}).animate({opacity:a.opacity},a.fadeSpeed);c.data("bPopup",a).data("id",d).css({left:!a.follow[0]&&m||i?g:h.scrollLeft()+g,position:a.positionStyle||"absolute",top:!a.follow[1]&&l||i?f:h.scrollTop()+f,"z-index":a.zIndex+k+1}).each(function(){a.appending&&b(this).appendTo(a.appendTo);if(null!=a.loadUrl)switch(a.contentContainer=b(a.contentContainer||c),a.content){case "iframe":b('<iframe scrolling="no" frameborder="0"></iframe>').attr("src",a.loadUrl).appendTo(a.contentContainer);break;default:a.contentContainer.load(a.loadUrl)}}).fadeIn(a.fadeSpeed,function(){b.isFunction(p)&&p.call(c);u()})}function o(){a.modal&&b(".bModal."+c.data("id")).fadeOut(a.fadeSpeed,function(){b(this).remove()});c.stop().fadeOut(a.fadeSpeed,function(){null!=a.loadUrl&&a.contentContainer.empty()});e.data("bPopup",0<e.data("bPopup")-1?e.data("bPopup")-1:null);a.scrollBar||b("html").css("overflow","auto");b("."+a.closeClass).die("click."+d);b(".bModal."+d).die("click");h.unbind("keydown."+d);e.unbind("."+d);c.data("bPopup",null);b.isFunction(a.onClose)&&setTimeout(function(){a.onClose.call(c)},a.fadeSpeed);return!1}function u(){e.data("bPopup",k);b("."+a.closeClass).live("click."+d,o);a.modalClose&&b(".bModal."+d).live("click",o).css("cursor","pointer");(a.follow[0]||a.follow[1])&&e.bind("scroll."+d,function(){q&&c.stop().animate({left:a.follow[0]&&!i?h.scrollLeft()+g:g,top:a.follow[1]&&!i?h.scrollTop()+f:f},a.followSpeed)}).bind("resize."+d,function(){if(q=s())j=r(c,a.amsl),a.follow[0]&&(g=m?g:j[0]),a.follow[1]&&(f=l?f:j[1]),c.stop().each(function(){i?b(this).css({left:g,top:f},a.followSpeed):b(this).animate({left:m?g:g+h.scrollLeft(),top:l?f:f+h.scrollTop()},a.followSpeed)})});a.escClose&&h.bind("keydown."+d,function(a){27==a.which&&o()})}function r(a,b){var c=(e.width()-a.outerWidth(!0))/2,d=(e.height()-a.outerHeight(!0))/2-b;return[c,20>d?20:d]}function s(){return e.height()>c.outerHeight(!0)+20&&e.width()>c.outerWidth(!0)+20}b.isFunction(n)&&(p=n,n=null);var a=b.extend({},b.fn.bPopup.defaults,n);a.scrollBar||b("html").css("overflow","hidden");var c=this,h=b(document),e=b(window),k,d,q,l,m,i,j,f,g;this.close=function(){a=c.data("bPopup");o()};return this.each(function(){c.data("bPopup")||t()})};b.fn.bPopup.defaults={amsl:50,appending:!0,appendTo:"body",closeClass:"bClose",content:"ajax",contentContainer:null,escClose:!0,fadeSpeed:250,follow:[!0,!0],followSpeed:500,loadUrl:null,modal:!0,modalClose:!0,modalColor:"#000",onClose:null,onOpen:null,opacity:0.7,position:["auto","auto"],positionStyle:"absolute",scrollBar:!0,zIndex:9997}})(jQuery);
nxs_functions.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  if (!function_exists('prr')){ function prr($str) { echo "<pre>"; print_r($str); echo "</pre>\r\n"; }}
4
  if (!function_exists('nsx_stripSlashes')){ function nsx_stripSlashes(&$value){$value = stripslashes($value);}}
5
  if (!function_exists('nsx_fixSlashes')){ function nsx_fixSlashes(&$value){ while (strpos($value, '\\\\')!==false) $value = str_replace('\\\\','\\',$value);
@@ -23,14 +22,34 @@ if (!function_exists('nxs_convertEntity')){ function nxs_convertEntity($matches,
23
  }}
24
  if (!function_exists('nsFindImgsInPost')){function nsFindImgsInPost($post, $advImgFnd=false) { global $ShownAds; if (isset($ShownAds)) $ShownAdsL = $ShownAds;
25
  if ($advImgFnd) $postCnt = apply_filters('the_content', $post->post_content); else $postCnt = $post->post_content; $postImgs = array();
26
- //$output = preg_match_all( '/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $postCnt, $matches ); if ($output === false){return false;} prr($matches);
27
- $postCnt = str_replace("'",'"',$postCnt); $output = preg_match_all( '/src="([^"]*)"/', $postCnt, $matches ); if ($output === false){return false;}// prr($matches);
28
- foreach ($matches[1] as $match) { if (!preg_match('/^https?:\/\//', $match ) ) $match = site_url( '/' ) . ltrim( $match, '/' ); $postImgs[] = $match;} if (isset($ShownAds)) $ShownAds = $ShownAdsL; return $postImgs;
 
 
 
29
  }}
30
- if (!function_exists('nsFindVidsInPost')){function nsFindVidsInPost($post) { //## Breaks ob_start() [ref.outcontrol]: Cannot use output buffering in output buffering display handlers - Investigate
31
- global $ShownAds; if (isset($ShownAds)) $ShownAdsL = $ShownAds; $postCnt = apply_filters('the_content', $post->post_content); $postVids = array();
32
- $output = preg_match_all( '%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $postCnt, $matches ); if ($output === false){return false;}
33
- foreach ($matches[1] as $match) { $match = trim($match); $postVids[] = $match;} if (isset($ShownAds)) $ShownAds = $ShownAdsL; return $postVids;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  }}
35
  if (!function_exists('nsTrnc')){ function nsTrnc($string, $limit, $break=" ", $pad=" ...") { if(strlen($string) <= $limit) return $string; $string = substr($string, 0, $limit-strlen($pad));
36
  $brLoc = strripos($string, $break); if ($brLoc===false) return $string.$pad; else return substr($string, 0, $brLoc).$pad;
@@ -40,29 +59,36 @@ if (!function_exists('nsSubStrEl')){ function nsSubStrEl($string, $length, $end=
40
  if (!function_exists('nxs_snapCleanHTML')){ function nxs_snapCleanHTML($html) {
41
  $html = preg_replace('/<script\b[^>]*>(.*?)<\/script>/is', "", $html); $html = preg_replace('/<!--(.*)-->/Uis', "", $html); return $html;
42
  }}
43
- if (!function_exists("nxs_getNXSHeaders")) { function nxs_getNXSHeaders($ref, $post=false){ $hdrsArr = array();
44
  $hdrsArr['Connection']='keep-alive'; $hdrsArr['Referer']=$ref;
45
  $hdrsArr['User-Agent']='Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.22 Safari/537.11';
46
  if($post) $hdrsArr['Content-Type']='application/x-www-form-urlencoded';
47
- $hdrsArr['Accept']='application/json, text/javascript, */*; q=0.01';
48
  $hdrsArr['Accept-Encoding']='gzip,deflate,sdch'; $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;
49
  }}
50
- if (!function_exists('nxs_chckRmImage')){function nxs_chckRmImage($url){ $hdrsArr = nxs_getNXSHeaders(home_url()); $rsp = wp_remote_head($url, array('headers' => $hdrsArr));
 
51
  if(is_wp_error($rsp)) { nxs_addToLog('IMAGE', 'E', '-=ERROR=- '.print_r($rsp, true), ''); return false; }
52
  if (is_array($rsp) && ($rsp['response']['code']=='200' || ( $rsp['response']['code']=='403' && $rsp['headers']['server']=='cloudflare-nginx') )) return true;
53
- else { nxs_addToLog('IMAGE', 'E', '-=ERROR=- '.print_r($rsp, true), ''); return false; }
 
54
  }}
55
  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;
56
  if (isset($options['featImgLoc']) && $options['featImgLoc']!=='') { $imgURL = trim(get_post_meta($postID, $options['featImgLocPrefix'], true)).trim(get_post_meta($postID, $options['featImgLoc'], true));
57
  if ($imgURL!='' && stripos($imgURL, 'http')===false) $imgURL = home_url().$imgURL;
58
  }
59
- if ($imgURL!='' && $options['imgNoCheck']!='1' && nxs_chckRmImage($imgURL)==false) $imgURL = '';
60
  if ($imgURL=='') { if (function_exists("get_post_thumbnail_id") ){ $imgURL = wp_get_attachment_image_src(get_post_thumbnail_id($postID), $size); $imgURL = $imgURL[0]; } }
61
- if ($imgURL!='' && $options['imgNoCheck']!='1' && nxs_chckRmImage($imgURL)==false) $imgURL = '';
62
- if ($imgURL=='') {$post = get_post($postID); $imgsFromPost = nsFindImgsInPost($post); if (is_array($imgsFromPost) && count($imgsFromPost)>0) $imgURL = $imgsFromPost[0]; } //echo "##".count($imgsFromPost); prr($imgsFromPost);
63
- if ($imgURL!='' && $options['imgNoCheck']!='1' && nxs_chckRmImage($imgURL)==false) $imgURL = '';
 
 
 
 
64
  if ($imgURL=='' && $def=='') $imgURL = $options['ogImgDef'];
65
  if ($imgURL=='' && $def!='') $imgURL = $def;
 
66
  return $imgURL;
67
  }}
68
 
@@ -96,167 +122,57 @@ if (!function_exists("jsPostToSNAP")) { function jsPostToSNAP() { global $nxs_s
96
  if (!function_exists("nxs_jsPostToSNAP2")){ function nxs_jsPostToSNAP2() { global $nxs_snapAvNts, $nxs_snapThisPageUrl, $plgn_NS_SNAutoPoster;
97
  if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
98
  ?>
99
-
100
- <script type="text/javascript"> if (typeof jQuery == 'undefined') {var script = document.createElement('script'); script.type = "text/javascript";
101
- script.src = "http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"; document.getElementsByTagName('head')[0].appendChild(script);
102
- }</script>
103
- <script type="text/javascript">
104
- (function(b){b.fn.bPopup=function(n,p){function t(){b.isFunction(a.onOpen)&&a.onOpen.call(c);k=(e.data("bPopup")||0)+1;d="__bPopup"+k;l="auto"!==a.position[1];m="auto"!==a.position[0];i="fixed"===a.positionStyle;j=r(c,a.amsl);f=l?a.position[1]:j[1];g=m?a.position[0]:j[0];q=s();a.modal&&b('<div class="bModal '+d+'"></div>').css({"background-color":a.modalColor,height:"100%",left:0,opacity:0,position:"fixed",top:0,width:"100%","z-index":a.zIndex+k}).each(function(){a.appending&&b(this).appendTo(a.appendTo)}).animate({opacity:a.opacity},a.fadeSpeed);c.data("bPopup",a).data("id",d).css({left:!a.follow[0]&&m||i?g:h.scrollLeft()+g,position:a.positionStyle||"absolute",top:!a.follow[1]&&l||i?f:h.scrollTop()+f,"z-index":a.zIndex+k+1}).each(function(){a.appending&&b(this).appendTo(a.appendTo);if(null!=a.loadUrl)switch(a.contentContainer=b(a.contentContainer||c),a.content){case "iframe":b('<iframe scrolling="no" frameborder="0"></iframe>').attr("src",a.loadUrl).appendTo(a.contentContainer);break;default:a.contentContainer.load(a.loadUrl)}}).fadeIn(a.fadeSpeed,function(){b.isFunction(p)&&p.call(c);u()})}function o(){a.modal&&b(".bModal."+c.data("id")).fadeOut(a.fadeSpeed,function(){b(this).remove()});c.stop().fadeOut(a.fadeSpeed,function(){null!=a.loadUrl&&a.contentContainer.empty()});e.data("bPopup",0<e.data("bPopup")-1?e.data("bPopup")-1:null);a.scrollBar||b("html").css("overflow","auto");b("."+a.closeClass).die("click."+d);b(".bModal."+d).die("click");h.unbind("keydown."+d);e.unbind("."+d);c.data("bPopup",null);b.isFunction(a.onClose)&&setTimeout(function(){a.onClose.call(c)},a.fadeSpeed);return!1}function u(){e.data("bPopup",k);b("."+a.closeClass).live("click."+d,o);a.modalClose&&b(".bModal."+d).live("click",o).css("cursor","pointer");(a.follow[0]||a.follow[1])&&e.bind("scroll."+d,function(){q&&c.stop().animate({left:a.follow[0]&&!i?h.scrollLeft()+g:g,top:a.follow[1]&&!i?h.scrollTop()+f:f},a.followSpeed)}).bind("resize."+d,function(){if(q=s())j=r(c,a.amsl),a.follow[0]&&(g=m?g:j[0]),a.follow[1]&&(f=l?f:j[1]),c.stop().each(function(){i?b(this).css({left:g,top:f},a.followSpeed):b(this).animate({left:m?g:g+h.scrollLeft(),top:l?f:f+h.scrollTop()},a.followSpeed)})});a.escClose&&h.bind("keydown."+d,function(a){27==a.which&&o()})}function r(a,b){var c=(e.width()-a.outerWidth(!0))/2,d=(e.height()-a.outerHeight(!0))/2-b;return[c,20>d?20:d]}function s(){return e.height()>c.outerHeight(!0)+20&&e.width()>c.outerWidth(!0)+20}b.isFunction(n)&&(p=n,n=null);var a=b.extend({},b.fn.bPopup.defaults,n);a.scrollBar||b("html").css("overflow","hidden");var c=this,h=b(document),e=b(window),k,d,q,l,m,i,j,f,g;this.close=function(){a=c.data("bPopup");o()};return this.each(function(){c.data("bPopup")||t()})};b.fn.bPopup.defaults={amsl:50,appending:!0,appendTo:"body",closeClass:"bClose",content:"ajax",contentContainer:null,escClose:!0,fadeSpeed:250,follow:[!0,!0],followSpeed:500,loadUrl:null,modal:!0,modalClose:!0,modalColor:"#000",onClose:null,onOpen:null,opacity:0.7,position:["auto","auto"],positionStyle:"absolute",scrollBar:!0,zIndex:9997}})(jQuery);
105
- </script>
106
- <script type="text/javascript">
107
 
108
- // function blinks(hide) { if(hide==1) { jQuery('.blnkg').show(); hide = 0; } else { jQuery('.blnkg').hide(); hide = 1; } setTimeout("blinks("+hide+")",400);}
109
- // jQuery(document).ready(function(){ blinks(1);});
110
- <?php if( isset($options['exclCats']) && $options['exclCats']!='' && $options['exclCats']!='a:0:{}') { ?>
111
 
112
- jQuery(function(){
113
- jQuery("form input:checkbox[name='post_category[]']").click ( function(){ var nxs_isLocked = jQuery('#nxsLockIt').val(); if (nxs_isLocked=='1') return;
114
- var thVal = jQuery(this).val(); var arr = [<?php $xarr = maybe_unserialize($options['exclCats']); if (is_array($xarr)) echo "'".implode("','", $xarr)."'"; ?>];
115
- if ( jQuery.inArray(thVal, arr)>-1) jQuery('.nxsGrpDoChb').removeAttr('checked'); else jQuery(".nxsGrpDoChb[title='def']").attr('checked','checked');
116
-
 
 
 
 
 
117
  });
118
- });
119
-
120
- <?php } ?>
121
-
122
-
123
- 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'); }
124
- function hidePopShAtt(imid){ jQuery('div#popShAtt'+imid).hide(); }
125
- function doSwitchShAtt(att, idNum){
126
- //if (att==1) { jQuery('#apFBAttch'+idNum).attr('checked', true); jQuery('#apFBAttchShare'+idNum).attr('checked', false); } else {jQuery('#apFBAttch'+idNum).attr('checked', false); jQuery('#apFBAttchShare'+idNum).attr('checked', true);}
127
- if (att==1) { if (jQuery('#apFBAttch'+idNum).is(":checked")) jQuery('#apFBAttchShare'+idNum).attr('checked', false); } else { if( jQuery('#apFBAttchShare'+idNum).is(":checked")) jQuery('#apFBAttch'+idNum).attr('checked', false);}
128
- }
129
-
130
-
131
- (function($) {
132
- $(function() {
133
- $('#nxs_snapAddNew').bind('click', function(e) { e.preventDefault(); $('#nxs_spPopup').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [65, 50]}); });
134
- $('#showLic').bind('click', function(e) { e.preventDefault(); $('#showLicForm').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false]}); });
135
- });
136
- })(jQuery);
137
-
138
- jQuery(document).ready(function() {
139
-
140
- jQuery('#nxsAPIUpd').dblclick(function() { doLic(); });
141
-
142
- //When page loads...
143
- jQuery(".nsx_tab_content").hide(); //Hide all content
144
- jQuery("ul.nsx_tabs li:first").addClass("active").show(); //Activate first tab
145
- jQuery(".nsx_tab_content:first").show(); //Show first tab content
146
-
147
- //On Click Event
148
- jQuery("ul.nsx_tabs li").click(function() {
149
-
150
- jQuery("ul.nsx_tabs li").removeClass("active"); //Remove any "active" class
151
- jQuery(this).addClass("active"); //Add "active" class to selected tab
152
- jQuery(".nsx_tab_content").hide(); //Hide all tab content
153
-
154
- var activeTab = jQuery(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
155
- jQuery(activeTab).fadeIn(); //Fade in the active ID content
156
- return false;
157
- });
158
-
159
- });
160
-
161
-
162
- function doShowHideAltFormat(){ if (jQuery('#NS_SNAutoPosterAttachPost').is(':checked')) {
163
- jQuery('#altFormat').css('margin-left', '20px'); jQuery('#altFormatText').html('Post Announce Text:'); } else {jQuery('#altFormat').css('margin-left', '0px'); jQuery('#altFormatText').html('Post Text Format:');}
164
- }
165
- function doShowHideBlocks(blID){ if (jQuery('#apDo'+blID).is(':checked')) jQuery('#do'+blID+'Div').show(); else jQuery('#do'+blID+'Div').hide();}
166
- function doShowHideBlocks1(blID, shhd){ if (shhd==1) jQuery('#do'+blID+'Div').show(); else jQuery('#do'+blID+'Div').hide();}
167
- function doShowHideBlocks2(blID){ if (jQuery('#apDoS'+blID).val()=='0') { jQuery('#do'+blID+'Div').show(); jQuery('#do'+blID+'A').text('[Hide Settings]'); jQuery('#apDoS'+blID).val('1'); }
168
- else { jQuery('#do'+blID+'Div').hide(); jQuery('#do'+blID+'A').text('[Show Settings]'); jQuery('#apDoS'+blID).val('0'); }
169
- }
170
-
171
- function doShowFillBlock(blIDTo, blIDFrm){ jQuery('#'+blIDTo).html(jQuery('#do'+blIDFrm+'Div').html());}
172
- function doCleanFillBlock(blIDFrm){ jQuery('#do'+blIDFrm+'Div').html('');}
173
-
174
- function doShowFillBlockX(blIDFrm){ jQuery('.clNewNTSets').hide(); jQuery('#do'+blIDFrm+'Div').show(); }
175
-
176
- function doDelAcct(nt, blID, blName){ var answer = confirm("Remove "+blName+" account?");
177
- if (answer){ var data = { action: 'nsDN', id: 0, nt: nt, id: blID, _wpnonce: jQuery('input#nsDN_wpnonce').val()};
178
- jQuery.post(ajaxurl, data, function(response) { location.reload(); });
179
- }
180
- }
181
- function seFBA(pgID,fbAppID,fbAppSec){ var data = { pgID: pgID, action: 'nsAuthFBSv', _wpnonce: jQuery('input#nsFB_wpnonce').val()};
182
- jQuery.post(ajaxurl, data, function(response) {
183
- window.location = "https://www.facebook.com/dialog/oauth?client_id="+fbAppID+"&client_secret="+fbAppSec+"&scope=publish_stream,offline_access,read_stream,manage_pages&redirect_uri=<?php echo $nxs_snapThisPageUrl;?>";
184
- });
185
- }
186
-
187
- function doLic(){ var lk = jQuery('#eLic').val();
188
- jQuery.post(ajaxurl,{lk:lk, action: 'nxsDoLic', id: 0, _wpnonce: jQuery('input#doLic_wpnonce').val(), ajax: 'true'}, function(j){
189
- if (jQuery.trim(j)=='OK') window.location = "<?php echo $nxs_snapThisPageUrl; ?>"; else alert('Wrong key, please contact support');
190
- }, "html")
191
- }
192
-
193
-
194
-
195
- function getBoards(u,p,ii){ jQuery("#pnLoadingImg"+ii).show();
196
-
197
- 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 = '';
198
- jQuery("select#apPNBoard"+ii).html(j); jQuery("#pnLoadingImg"+ii).hide();
199
- }, "html")
200
 
201
- }
202
-
203
- function callAjSNAP(data, label) {
204
- var style = "position: fixed; display: none; z-index: 1000; top: 50%; left: 50%; background-color: #E8E8E8; border: 1px solid #555; padding: 15px; width: 350px; min-height: 80px; margin-left: -175px; margin-top: -40px; text-align: center; vertical-align: middle;";
205
- jQuery('body').append("<div id='test_results' style='" + style + "'></div>");
206
- jQuery('#test_results').html("<p>Sending update to "+label+"</p>" + "<p><img src='http://gtln.us/img/misc/ajax-loader-med.gif' /></p>");
207
- jQuery('#test_results').show();
208
- jQuery.post(ajaxurl, data, function(response) { if (response=='') response = 'Message Posted';
209
- jQuery('#test_results').html('<p> ' + response + '</p>' +'<input type="button" class="button" name="results_ok_button" id="results_ok_button" value="OK" />');
210
-
211
- jQuery('#results_ok_button').click(remove_results);
212
- });
213
-
214
- }
215
- function remove_results() { jQuery("#results_ok_button").unbind("click");jQuery("#test_results").remove();
216
- if (typeof document.body.style.maxHeight == "undefined") { jQuery("body","html").css({height: "auto", width: "auto"}); jQuery("html").css("overflow","");}
217
- document.onkeydown = "";document.onkeyup = ""; return false;
218
- }
219
- function testPost(nt, nid){ jQuery(".blnkg").hide(); <?php foreach ($nxs_snapAvNts as $avNt) {?>
220
- if (nt=='<?php echo $avNt['code']; ?>') {
221
- var data = { action: 'rePostTo<?php echo $avNt['code']; ?>', id: 0, nid: nid, _wpnonce: jQuery('input#rePostTo<?php echo $avNt['code']; ?>_wpnonce').val()}; callAjSNAP(data, '<?php echo $avNt['name']; ?>');
222
- }<?php } ?>
223
- }
224
- function mxs_showHideFrmtInfo(hid){
225
- if(!jQuery('#'+hid+'Hint').is(':visible')) mxs_showFrmtInfo(hid); else {jQuery('#'+hid+'Hint').hide(); jQuery('#'+hid+'HintInfo').html('Show format info');}
226
- }
227
- function mxs_showFrmtInfo(hid){
228
- jQuery('#'+hid+'Hint').show(); jQuery('#'+hid+'HintInfo').html('Hide format info');
229
- }
230
- function nxs_clLog(){
231
- jQuery.post(ajaxurl,{action: 'nxs_clLgo', id: 0, _wpnonce: jQuery('input#nxsSsPageWPN_wpnonce').val(), ajax: 'true'}, function(j){ var options = '';
232
- jQuery("#nxslogDiv").html('');
233
- }, "html")
234
- }
235
- function nxs_rfLog(){
236
- jQuery.post(ajaxurl,{action: 'nxs_rfLgo', id: 0, _wpnonce: jQuery('input#nxsSsPageWPN_wpnonce').val(), ajax: 'true'}, function(j){ var options = '';
237
- jQuery("#nxslogDiv").html(j);
238
- }, "html")
239
- }
240
- function nxs_prxTest(){ jQuery('#nxs_pchAjax').show();
241
- jQuery.post(ajaxurl,{action: 'nxs_prxTest', id: 0, _wpnonce: jQuery('input#nxsSsPageWPN_wpnonce').val(), ajax: 'true'}, function(j){ var options = '';
242
- jQuery('#nxs_pchAjax').hide(); jQuery("#prxList").html(j);
243
- }, "html")
244
- }
245
- function nxs_TRSetEnable(ptype, ii){
246
- if (ptype=='I'){ jQuery('#apTRMsgTFrmt'+ii).attr('disabled', 'disabled'); jQuery('#apTRDefImg'+ii).removeAttr('disabled'); }
247
- else { jQuery('#apTRDefImg'+ii).attr('disabled', 'disabled'); jQuery('#apTRMsgTFrmt'+ii).removeAttr('disabled'); }
248
- }
249
- function nxsTRURLVal(ii){ var val = jQuery('#apTRURL'+ii).val(); var srch = val.toLowerCase().indexOf('http://www.tumblr.com/blog/');
250
- if (srch>-1) { jQuery('#apTRURL'+ii).css({"background-color":"#FFC0C0"}); jQuery('#apTRURLerr'+ii).html('<br/>Incorrect URL: Please note that URL of your Tumblr Blog should be your public URL. (i.e. like http://nextscripts.tumblr.com/, not http://www.tumblr.com/blog/nextscripts'); } else { jQuery('#apTRURL'+ii).css({"background-color":"#ffffff"}); jQuery('#apTRURLerr'+ii).text(''); }
251
 
252
-
253
- }
254
-
255
-
256
-
257
-
258
- </script>
259
- <link href='http://fonts.googleapis.com/css?family=News+Cycle' rel='stylesheet' type='text/css'>
260
  <style type="text/css">
261
  .NXSButton { background-color:#89c403;
262
  background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #89c403), color-stop(1, #77a809) );
@@ -311,7 +227,7 @@ if (!function_exists('nxs_doShowHint')){ function nxs_doShowHint($t){ ?>
311
  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/>You already have <?php echo $nType; ?> configured. This plugin supports only one <?php echo $nType; ?> account. <br/><br/> Please consider getting <a target="_blank" href="http://www.nextscripts.com/social-networks-auto-poster-for-wp-multiple-accounts">Multiple Accounts Edition</a> if you would like to add another <?php echo $nType; ?> account for auto-posting.</div></div><?php
312
  }}
313
 
314
- if (!function_exists('nxs_snapCleanup')){ function nxs_snapCleanup($options){ global $nxs_snapAvNts;
315
  foreach ($nxs_snapAvNts as $avNt) { if (!isset($options[$avNt['lcode']]) || count($options[$avNt['lcode']])>1) { $copt = ''; $t = '';
316
  if (isset($options[$avNt['lcode']]) && is_array($options[$avNt['lcode']])) $copt = array_values( $options[$avNt['lcode']] );
317
  $t = (isset($copt[0]) && is_array($copt[0]) && count($copt[0]>2))?$copt[0]:''; $options[$avNt['lcode']] = array(); if ($t!='') $options[$avNt['lcode']][] = $t;
@@ -335,7 +251,7 @@ if (!function_exists("nxs_metaMarkAsPosted")) { function nxs_metaMarkAsPosted($p
335
  if (is_array($args) && isset($args['isPrePosted']) && $args['isPrePosted']==1) $mpo[$did]['isPrePosted'] = '1';
336
  if (is_array($args) && isset($args['pgID'])) $mpo[$did]['pgID'] = $args['pgID'];
337
  if (is_array($args) && isset($args['pDate'])) $mpo[$did]['pDate'] = $args['pDate'];
338
- $mpo = mysql_real_escape_string(serialize($mpo)); delete_post_meta($postID, 'snap'.$nt); add_post_meta($postID, 'snap'.$nt, $mpo);
339
  }}
340
  if (!function_exists('nxs_addToLog')){ function nxs_addToLog ($nt, $type, $msg, $extInfo=''){ global $nxs_tpWMPU; if($nxs_tpWMPU=='S') switch_to_blog(1); $nxsDBLog = get_option('NS_SNAutoPosterLog'); $nxsDBLog = maybe_unserialize($nxsDBLog);
341
  $logItem = array('date'=>date('Y-m-d H:i:s'), 'msg'=>$msg, 'extInfo'=>$extInfo, 'type'=>$type, 'nt'=>$nt); if(!is_array($nxsDBLog)) $nxsDBLog = array();
@@ -343,7 +259,11 @@ if (!function_exists('nxs_addToLog')){ function nxs_addToLog ($nt, $type, $msg,
343
  }}
344
 
345
  if (!function_exists('nxsMergeArraysOV')){function nxsMergeArraysOV($Arr1, $Arr2){
346
- 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;
 
 
 
 
347
  }}
348
 
349
  if (!function_exists('nxs_addPostingDelaySel')){function nxs_addPostingDelaySel($nt, $ii, $hrs=0, $min=0){
1
  <?php
 
2
  if (!function_exists('prr')){ function prr($str) { echo "<pre>"; print_r($str); echo "</pre>\r\n"; }}
3
  if (!function_exists('nsx_stripSlashes')){ function nsx_stripSlashes(&$value){$value = stripslashes($value);}}
4
  if (!function_exists('nsx_fixSlashes')){ function nsx_fixSlashes(&$value){ while (strpos($value, '\\\\')!==false) $value = str_replace('\\\\','\\',$value);
22
  }}
23
  if (!function_exists('nsFindImgsInPost')){function nsFindImgsInPost($post, $advImgFnd=false) { global $ShownAds; if (isset($ShownAds)) $ShownAdsL = $ShownAds;
24
  if ($advImgFnd) $postCnt = apply_filters('the_content', $post->post_content); else $postCnt = $post->post_content; $postImgs = array();
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) { //## Breaks ob_start() [ref.outcontrol]: Cannot use output buffering in output buffering display handlers - Investigate
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('nsFindVidsInPost')){function nsFindVidsInPost($post, $raw=true) { //## Breaks ob_start() [ref.outcontrol]: Cannot use output buffering in output buffering display handlers - Investigate
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
+ $output = preg_match_all( '@((https?://)?([-\w]+\.[-\w\.]+)+\w(:\d+)?(/([-\w/_\.]*(\?\S+)?)?(#[a-z_.-][a-z0-9+\$_.-]*)?)*)@', $postCnt, $matches ); if ($output === false){return false;}
47
+ foreach ($matches[0] as $match) {
48
+ $output2 = preg_match_all( '%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"<>&?/ ]{11})%i', $match, $matches2 ); if ($output2 === false){return false;}
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;
59
  if (!function_exists('nxs_snapCleanHTML')){ function nxs_snapCleanHTML($html) {
60
  $html = preg_replace('/<script\b[^>]*>(.*?)<\/script>/is', "", $html); $html = preg_replace('/<!--(.*)-->/Uis', "", $html); return $html;
61
  }}
62
+ if (!function_exists("nxs_getNXSHeaders")) { function nxs_getNXSHeaders($ref='', $post=false){ $hdrsArr = array();
63
  $hdrsArr['Connection']='keep-alive'; $hdrsArr['Referer']=$ref;
64
  $hdrsArr['User-Agent']='Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.22 Safari/537.11';
65
  if($post) $hdrsArr['Content-Type']='application/x-www-form-urlencoded';
66
+ $hdrsArr['Accept']='application/json, text/javascript, */*; q=0.01';
67
  $hdrsArr['Accept-Encoding']='gzip,deflate,sdch'; $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;
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)) { nxs_addToLog('IMAGE', 'E', '-=ERROR=- '.print_r($rsp, true), ''); return false; }
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 { nxs_addToLog('IMAGE', 'E', '-=ERROR=- '.print_r($rsp, true), $url); return false; }
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
  if (isset($options['featImgLoc']) && $options['featImgLoc']!=='') { $imgURL = trim(get_post_meta($postID, $options['featImgLocPrefix'], true)).trim(get_post_meta($postID, $options['featImgLoc'], true));
78
  if ($imgURL!='' && stripos($imgURL, 'http')===false) $imgURL = home_url().$imgURL;
79
  }
80
+ if ($imgURL!='' && $options['imgNoCheck']!='1' && nxs_chckRmImage($imgURL)==false) $imgURL = ''; if ($imgURL!='') return $imgURL;
81
  if ($imgURL=='') { if (function_exists("get_post_thumbnail_id") ){ $imgURL = wp_get_attachment_image_src(get_post_thumbnail_id($postID), $size); $imgURL = $imgURL[0]; } }
82
+ if ($imgURL!='' && $options['imgNoCheck']!='1' && nxs_chckRmImage($imgURL)==false) $imgURL = ''; if ($imgURL!='') return $imgURL;
83
+ if ($imgURL=='') { $attachments = get_posts(array('post_type' => 'attachment', 'posts_per_page' => -1, 'post_parent' => $postID));
84
+ if (is_array($attachments) && is_object($attachments[0])) $imgURL = wp_get_attachment_image_src($attachments[0]->ID, $size); $imgURL = $imgURL[0];
85
+ }
86
+ if ($imgURL!='' && $options['imgNoCheck']!='1' && nxs_chckRmImage($imgURL)==false) $imgURL = ''; if ($imgURL!='') return $imgURL;
87
+ if ($imgURL=='') {$post = get_post($postID); $imgsFromPost = nsFindImgsInPost($post); if (is_array($imgsFromPost) && count($imgsFromPost)>0) $imgURL = $imgsFromPost[0]; } //echo "##".count($imgsFromPost); prr($imgsFromPost);
88
+ if ($imgURL!='' && $options['imgNoCheck']!='1' && nxs_chckRmImage($imgURL)==false) $imgURL = ''; if ($imgURL!='') return $imgURL;
89
  if ($imgURL=='' && $def=='') $imgURL = $options['ogImgDef'];
90
  if ($imgURL=='' && $def!='') $imgURL = $def;
91
+
92
  return $imgURL;
93
  }}
94
 
122
  if (!function_exists("nxs_jsPostToSNAP2")){ function nxs_jsPostToSNAP2() { global $nxs_snapAvNts, $nxs_snapThisPageUrl, $plgn_NS_SNAutoPoster;
123
  if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
124
  ?>
 
 
 
 
 
 
 
 
125
 
126
+ <script type="text/javascript">
 
 
127
 
128
+ jQuery(function(){
129
+ jQuery("form input:checkbox[name='post_category[]']").click ( function(){ var nxs_isLocked = jQuery('#nxsLockIt').val(); if (nxs_isLocked=='1') return;
130
+ var thVal = jQuery(this).val();
131
+ jQuery(".nxs_SC").each(function(index) { var cats = jQuery(this).val(); var catsA = cats.split(','); uqID = jQuery(this).attr('id'); uqID = uqID.replace("nxs_SC_", "do", "gi");
132
+ if (jQuery.inArray(thVal, catsA)>-1) jQuery('#'+uqID).attr('checked','checked')
133
+ //alert( uqID + "|" + catsA + "|" + thVal);
134
+ });
135
+ var arr = [<?php $xarr = maybe_unserialize($options['exclCats']); if (is_array($xarr)) echo "'".implode("','", $xarr)."'"; ?>];
136
+ if ( jQuery.inArray(thVal, arr)>-1) jQuery('.nxsGrpDoChb').removeAttr('checked'); else jQuery(".nxsGrpDoChb[title='def']").attr('checked','checked');
137
+ });
138
  });
139
+
140
+ function seFBA(pgID,fbAppID,fbAppSec){ var data = { pgID: pgID, action: 'nsAuthFBSv', _wpnonce: jQuery('input#nsFB_wpnonce').val()};
141
+ jQuery.post(ajaxurl, data, function(response) {
142
+ window.location = "https://www.facebook.com/dialog/oauth?client_id="+fbAppID+"&client_secret="+fbAppSec+"&scope=publish_stream,offline_access,read_stream,manage_pages&redirect_uri=<?php echo $nxs_snapThisPageUrl;?>";
143
+ });
144
+ }
145
+ function doLic(){ var lk = jQuery('#eLic').val(); jQuery.post(ajaxurl,{lk:lk, action: 'nxsDoLic', id: 0, _wpnonce: jQuery('input#doLic_wpnonce').val(), ajax: 'true'}, function(j){
146
+ if (jQuery.trim(j)=='OK') window.location = "<?php echo $nxs_snapThisPageUrl; ?>"; else alert('Wrong key, please contact support');
147
+ }, "html")
148
+ }
149
+ function testPost(nt, nid){ jQuery(".blnkg").hide(); <?php foreach ($nxs_snapAvNts as $avNt) {?>
150
+ if (nt=='<?php echo $avNt['code']; ?>') {
151
+ var data = { action: 'rePostTo<?php echo $avNt['code']; ?>', id: 0, nid: nid, _wpnonce: jQuery('input#rePostTo<?php echo $avNt['code']; ?>_wpnonce').val()}; callAjSNAP(data, '<?php echo $avNt['name']; ?>');
152
+ }<?php } ?>
153
+ }
154
+
155
+ jQuery(document).ready(function() {
156
+ jQuery('#nxsAPIUpd').dblclick(function() { doLic(); });
157
+ //When page loads...
158
+ jQuery(".nsx_tab_content").hide(); //Hide all content
159
+ jQuery("ul.nsx_tabs li:first").addClass("active").show(); //Activate first tab
160
+ jQuery(".nsx_tab_content:first").show(); //Show first tab content
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161
 
162
+ //On Click Event
163
+ jQuery("ul.nsx_tabs li").click(function() {
164
+ jQuery("ul.nsx_tabs li").removeClass("active"); //Remove any "active" class
165
+ jQuery(this).addClass("active"); //Add "active" class to selected tab
166
+ jQuery(".nsx_tab_content").hide(); //Hide all tab content
167
+
168
+ var activeTab = jQuery(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
169
+ jQuery(activeTab).fadeIn(); //Fade in the active ID content
170
+ return false;
171
+ });
172
+ });
173
+ </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
 
175
+ <link href='http://fonts.googleapis.com/css?family=News+Cycle' rel='stylesheet' type='text/css'>
 
 
 
 
 
 
 
176
  <style type="text/css">
177
  .NXSButton { background-color:#89c403;
178
  background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #89c403), color-stop(1, #77a809) );
227
  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/>You already have <?php echo $nType; ?> configured. This plugin supports only one <?php echo $nType; ?> account. <br/><br/> Please consider getting <a target="_blank" href="http://www.nextscripts.com/social-networks-auto-poster-for-wp-multiple-accounts">Multiple Accounts Edition</a> if you would like to add another <?php echo $nType; ?> account for auto-posting.</div></div><?php
228
  }}
229
 
230
+ if (!function_exists('nxs_snapCleanup')){ function nxs_snapCleanup($options){ global $nxs_snapAvNts;
231
  foreach ($nxs_snapAvNts as $avNt) { if (!isset($options[$avNt['lcode']]) || count($options[$avNt['lcode']])>1) { $copt = ''; $t = '';
232
  if (isset($options[$avNt['lcode']]) && is_array($options[$avNt['lcode']])) $copt = array_values( $options[$avNt['lcode']] );
233
  $t = (isset($copt[0]) && is_array($copt[0]) && count($copt[0]>2))?$copt[0]:''; $options[$avNt['lcode']] = array(); if ($t!='') $options[$avNt['lcode']][] = $t;
251
  if (is_array($args) && isset($args['isPrePosted']) && $args['isPrePosted']==1) $mpo[$did]['isPrePosted'] = '1';
252
  if (is_array($args) && isset($args['pgID'])) $mpo[$did]['pgID'] = $args['pgID'];
253
  if (is_array($args) && isset($args['pDate'])) $mpo[$did]['pDate'] = $args['pDate'];
254
+ /*$mpo = mysql_real_escape_string(serialize($mpo)); */ delete_post_meta($postID, 'snap'.$nt); add_post_meta($postID, 'snap'.$nt, $mpo);
255
  }}
256
  if (!function_exists('nxs_addToLog')){ function nxs_addToLog ($nt, $type, $msg, $extInfo=''){ global $nxs_tpWMPU; if($nxs_tpWMPU=='S') switch_to_blog(1); $nxsDBLog = get_option('NS_SNAutoPosterLog'); $nxsDBLog = maybe_unserialize($nxsDBLog);
257
  $logItem = array('date'=>date('Y-m-d H:i:s'), 'msg'=>$msg, 'extInfo'=>$extInfo, 'type'=>$type, 'nt'=>$nt); if(!is_array($nxsDBLog)) $nxsDBLog = array();
259
  }}
260
 
261
  if (!function_exists('nxsMergeArraysOV')){function nxsMergeArraysOV($Arr1, $Arr2){
262
+ 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;
263
+ }}
264
+
265
+ if (!function_exists('nxs_MergeCookieArr')){function nxs_MergeCookieArr($ArrO, $ArrN){ $namesArr = array(); foreach($ArrO as $key => $value) { if (is_object($value)) $namesArr[$key] = $value->name; }
266
+ foreach($ArrN as $key => $value) { if (is_object($value) && $value->value!='deleted') { $isEx = array_search($value->name, $namesArr); if ($isEx===false) $ArrO[] = $value; else $ArrO[$isEx] = $value;}} return $ArrO;
267
  }}
268
 
269
  if (!function_exists('nxs_addPostingDelaySel')){function nxs_addPostingDelaySel($nt, $ii, $hrs=0, $min=0){
readme.txt CHANGED
@@ -2,51 +2,43 @@
2
 
3
  Contributors: NextScripts
4
  Donate link: http://www.nextscripts.com/social-networks-auto-poster-for-wordpress
5
- Tags: automation, auto, 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, bookmarking, bookmarks, admin, images, image, social, sharing, share, repost, re-post, wordpress.com, StumbleUpon, Diigo, vBulletin, Plurk, forums, forum, open graph
6
- Requires at least: 2.8
7
- Tested up to: 3.4.2
8
- Stable tag: 2.4.8
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, Delicious, Diigo, Stumbleupon, LinkedIn, Pinterest, Plurk, Wordpress, and Tumblr profiles and/or pages. The whole process is completely automated. Just write a new post and either entire post or it's announcement with back link will be published to all your configured social networks.
16
 
17
  **Plugin makes 100% White Labeled Posts** The main idea behind the plugin is to give you the ability to promote only yourself. Plugin uses your own apps and all posts to all networks come only from you. No "Shared via NextScripts.com" or "Posted by SNAP for Wordpress" messages.
18
 
19
- Social Networks Auto Poster can automatically publish nicely formatted announcements to your Facebook, Twitter, LinkedIn, Tumblr, Wordpress, vBulletin, Delicious, Stumbleupon, Diigo, Plurk, Blogger, and Google+ (Google Plus) accounts, so 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, Facebook groups, etc. Plugin supports custom WordPress post types.
20
-
21
- **Latest version 2.4* - "Image" posts for Facebook and Twitter, bit.ly support, Plurk Support
22
-
23
- Supported Networks:
24
-
25
- **Blogger/Blogspot** - Autopost to your Blog.
26
-
27
- **Delicious** - Auto-submit bookmark to your account.
28
-
29
- **Diigo** - Auto-submit bookmark to your account.
30
-
31
- **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.
32
-
33
- **Google+** (*with third party library*) - Autopost to your profile or business page. Ability to attach your blogpost to Google+ post. Ability to make "Image" posts.
34
-
35
- **LinkedIn** - Autopost to your account. Ability to attach your blogpost to LinkedIn post. Autopost to LinkedIn Company pages (*with third party library*)
36
-
37
- **Pinterest** (*with third party library*) - Pin your blogpost's featured image to your Pinterest board.
38
-
39
- **Stumbleupon** - Auto-submit bookmark to your account.
40
-
41
- **Tumblr** - Autopost to your account. Ability to attach your blogpost to Tumblr post.
42
-
43
- **Twitter** - Autopost to your account. Ability to attach Image to tweets.
44
-
45
- **Plurk** - Autopost to your account. Ability to attach Image to messages.
46
-
47
- **vBulletin** - Auto-submit your blogpost to vBulletin forums. Could create new threads or new posts.
48
-
49
- **Wordpress** - Auto-submit your blogpost to another blog based on Wordpress. This options includes Wordpress.com, Blog.com, etc..
50
 
51
  ... more networks are coming soon ...
52
 
@@ -56,7 +48,7 @@ Please see <a href="http://www.nextscripts.com/installation-of-social-networks-a
56
 
57
  == Installation ==
58
 
59
- You need to have account with either Facebook, Tumblr, Google+, LinkedIn, Pinterest, Blogger, Twitter, Delicious, Diigo, Plurk, Stumbleupon or all of them.
60
 
61
  **Please, see more detailed installation instructions with screenshots here: http://www.nextscripts.com/installation-of-social-networks-auto-poster-for-wordpress **
62
 
@@ -125,7 +117,26 @@ Please see <a href="http://www.nextscripts.com/installation-of-social-networks-a
125
 
126
  == Frequently Asked Questions ==
127
 
128
- = Can I use it just for Twitter(Facebook, G+) or it requres all three networks to be set? =
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
 
130
  Sure you can use it for just one or two networks.
131
 
@@ -141,28 +152,78 @@ Please see more <a href="http://www.nextscripts.com/faq/">Frequently asked quest
141
 
142
  == Screenshots ==
143
 
144
- 1. Settings Page
145
- 2. Google+ Post
 
 
146
 
147
  == Changelog ==
148
 
149
- = 2.4.8 =
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
150
 
151
  * New/Improvement - external jQuery reference removed.
152
  * Bug fix - Pinterest board selection fix.
153
  * Bug fix - StumbleUpon connection fix.
154
  * Bug fix - Twitter %TAGS% and %CATS% for non English characters
155
  * Bug fix - Twitter %TAGS% and %CATS% were not found in the text sometimes.
156
- * Bug fix - Wordpress better handlying of connection errors.
157
  * Bug fix - Post status saving.
158
 
159
- = 2.4.7 =
160
 
161
  * New/Improvement - Ability to change format before reposting when you edit post.
162
  * Bug fix - Critical Blogger "Function not found" fix.
163
  * Bug fix - Escaped quotes in Message Format.
164
 
165
- = 2.4.6 =
166
 
167
  * Improvement - Wordpress 3.5 compatibility
168
  * Improvement/Bug fix - Better image handling.
@@ -170,14 +231,14 @@ Please see more <a href="http://www.nextscripts.com/faq/">Frequently asked quest
170
  * Bug fix - Fixed LinkedIn for European accounts.
171
  * Bug fix - Twitter Message length tweaks.
172
 
173
- = 2.4.5 =
174
 
175
  * Improvement/Bug fix - Google+ better "Post type" selection.
176
  * Bug fix - Google+ - image uploads for pages go to the right album, not profile.
177
  * Bug fix - Google+ - Correct image for "attached" posts
178
  * Bug fix - Twitter image attachment broken in 2.4.4
179
 
180
- = 2.4.4 =
181
 
182
  * Improvement - Twitter - If tags and categories are already in the text will become hashtags, not duplicates.
183
  * Improvement/Bug fix - "Check All/Uncheck All" links now have priority over category selection.
@@ -185,7 +246,7 @@ Please see more <a href="http://www.nextscripts.com/faq/">Frequently asked quest
185
  * Bug fix - Plurk - 180 characters limit.
186
  * Bug fix - Twitter correct characters count (119) for "Posts with image"
187
 
188
- = 2.4.3 =
189
 
190
  * New - Support for Wordpress Built-in Shortener
191
  * Improvement/Bug fix - Facebook - better image posting.
@@ -197,7 +258,7 @@ Please see more <a href="http://www.nextscripts.com/faq/">Frequently asked quest
197
  * Bug fix - Pinterest UTF characters in the Board names.
198
  * Bug fix - Pinterest - better Handling of Error 502.
199
 
200
- = 2.4.2 =
201
 
202
  * New - New network: Plurk. share your new blogpost on your Plurk account.
203
  * New - Twitter - ability to post tags and categories as #hashtags
@@ -206,14 +267,14 @@ Please see more <a href="http://www.nextscripts.com/faq/">Frequently asked quest
206
  * Bug fix - SSL connections fix and SSL cerificate update
207
  * Bug fix - Broken URL Shorthener selection
208
 
209
- = 2.4.1 =
210
 
211
  * Bug fix - Twitter error if attachmet image is missing
212
  * Bug fix - Issue with apostrophes and quotes
213
  * Improvement - "Click-through URL" for the Tumblr "Photo" posts can use shorthened URLs.
214
  * Improvement - Ability to select custom field instead of the featured image.
215
 
216
- = 2.4.0 =
217
 
218
  * New - Facebook "Photo" posts.
219
  * New - Ablity to attach image to Twitter posts
@@ -221,7 +282,7 @@ Please see more <a href="http://www.nextscripts.com/faq/">Frequently asked quest
221
  * New - wp.me support for short links. (Jetpack users only)
222
  * Improvement - "Click-through URL" for the Tumblr "Photo" posts.
223
 
224
- = 2.3.12 =
225
 
226
  * Improvement/Bug fix - Blogger Better support for broken HTML.
227
  * Bug fix - LinkedIn "Empty Message" Fix
@@ -303,7 +364,7 @@ Please see more <a href="http://www.nextscripts.com/faq/">Frequently asked quest
303
  * Bug fix - Facebook stability.
304
  * Bug fix - WP Multisite Management problems.
305
 
306
- = 2.3.0 =
307
 
308
  * New - Support for WP Multisite (Pro Only) - http://www.nextscripts.com/social-networks-auto-poster-pro-for-wordpress-compare-editions/
309
  * New - New network: Stumbleupon. Share your new blogpost on your StumbleUpon account.
@@ -353,7 +414,7 @@ Please see more <a href="http://www.nextscripts.com/faq/">Frequently asked quest
353
  * Bug fix - LinkedIn was still attaching a post if not selected.
354
  * Bug fix - Problem with Log/History saving.
355
 
356
- = 2.2.0 =
357
 
358
  * New - NextScript LinkeIn API support for company pages auto-posting (Beta).
359
  * New - Actions Log - see the log of the auto-postings.
@@ -382,7 +443,7 @@ Please see more <a href="http://www.nextscripts.com/faq/">Frequently asked quest
382
  * Bug fix - Broken quotes in the "Message Format".
383
  * Bug fix - "Post Immediately" was broken for free accounts.
384
 
385
- = 2.1.0 =
386
  * New - New network: Wordpress based websites. This option includes Wordpress.com, Blog.com, and and any other blogs based on WP.
387
  * Improvement - nicknames for your accounts. You can give each account a nickname to make it easier to identify in the list.
388
  * Improvement - better looking settings pages.
@@ -406,7 +467,7 @@ Please see more <a href="http://www.nextscripts.com/faq/">Frequently asked quest
406
  = 2.0.9 =
407
  * Bug fix - Facebook Authorization "Error 100" Fix.
408
 
409
- = 2.0.8 =
410
  * Improvement - Better list of available accounts.
411
  * Improvement/Bug fix - a lot of cosmetic interface changes and code optimizations for problem fixing and better looking.
412
  * Bug fix - Google+ Wrong options when using "Repost Button"
@@ -434,7 +495,7 @@ Please see more <a href="http://www.nextscripts.com/faq/">Frequently asked quest
434
  = 2.0.3 =
435
  * Initial public 2.0 Release.
436
 
437
- = 1.9.13 =
438
  * Improvement - Pinterest is caching login info to prevent "multiple logins" issues.
439
  * Bug fix - Pinterest special characters
440
  * Bug fix - Tumblr Authorization issue.
@@ -492,7 +553,7 @@ Please see more <a href="http://www.nextscripts.com/faq/">Frequently asked quest
492
  * Bug fix - Correct Special Character Encoding
493
  * Bug fix - Blooger Encoding issues.
494
 
495
- = 1.9.0 =
496
  * New - LinkedIn Support
497
  * Improvement - Post Options are now movable
498
  * Improvement - Security for Google+, Pinterest, Blogger - passwords are better encoded in the DB.
@@ -509,7 +570,7 @@ Please see more <a href="http://www.nextscripts.com/faq/">Frequently asked quest
509
  * Bug fix - Facebook %TEXT% and %FULLTEXT% formatiing issues.
510
  * Bug fix - Some Blogger Authorization issues.
511
 
512
- = 1.8.5 =
513
  * Bug fix - Format settings disappeared after update post
514
  * Bug fix - Twitter 140 characters limit when used with %TEXT% and %FULLTEXT%
515
 
@@ -532,7 +593,7 @@ Please see more <a href="http://www.nextscripts.com/faq/">Frequently asked quest
532
  * Improvement - Pinterest - ability to change board during the post writing
533
  * Bug fix - Several small bugs and formating fixes.
534
 
535
- = 1.8.0 =
536
  * New - Pinterest Support
537
  * New - Tumblr Support
538
  * New/Improvement - %IMG% replacement tag - Inserts Featured Image URL
@@ -547,7 +608,7 @@ Please see more <a href="http://www.nextscripts.com/faq/">Frequently asked quest
547
  * Improvement - Google+ Phone Verification support
548
  * Bug fix - Google+ "You are not authorized for this page" Error
549
 
550
- = 1.7.5 =
551
  * New/Improvement - %SURL% replacement tag - Shortens URL
552
  * Improvement - Wordpress 3.4 Compatibility
553
  * Improvement - Better handling of Twitter's "140 characters limit"
@@ -565,7 +626,7 @@ Please see more <a href="http://www.nextscripts.com/faq/">Frequently asked quest
565
  = 1.7.1 =
566
  * Bug fix - Repost button fixed.
567
 
568
- = 1.7.0 =
569
  * New - Support for Wordpress "Custom Post Types".
570
  * New - Ability to add open graph tags without third party plugins.
571
  * Improvement - Better compatibility/faster Google+ posting.
@@ -575,7 +636,7 @@ Please see more <a href="http://www.nextscripts.com/faq/">Frequently asked quest
575
  * Bug fix - Fixed missing "Pending-to-Publish" status change.
576
  * Bug fix - Twitter settings page format fixed.
577
 
578
- = 1.6.2 =
579
  * Bug fix - Fix for "Cannot modify header information" message while posting to Twitter.
580
 
581
  = 1.6.1 =
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, bookmarking, bookmarks, admin, images, image, social, sharing, share, repost, re-post, wordpress.com, StumbleUpon, Diigo, vBulletin, Plurk, forums, vKontakte, open graph, LiveJournal
6
+ Requires at least: 3.0
7
+ Tested up to: 3.5
8
+ Stable tag: 2.5.5
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, LiveJournal, Delicious, Diigo, Stumbleupon, LinkedIn, Pinterest, Plurk, VKontakte(VK.com), Wordpress, and Tumblr profiles and/or pages. The whole process is completely automated. Just write a new post and either entire post or it's announcement with back link will be published to all your configured social networks.
16
 
17
  **Plugin makes 100% White Labeled Posts** The main idea behind the plugin is to give you the ability to promote only yourself. Plugin uses your own apps and all posts to all networks come only from you. No "Shared via NextScripts.com" or "Posted by SNAP for Wordpress" messages.
18
 
19
+ Social Networks Auto Poster can automatically publish nicely formatted announcements to your Facebook, Twitter, LinkedIn, Tumblr, Wordpress, vBulletin, Delicious, Stumbleupon, LiveJournal, VKontakte(VK.com), Diigo, Plurk, Blogger, and Google+ (Google Plus) accounts, so 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, Facebook groups, etc. Plugin supports custom WordPress post types.
20
+
21
+ * **Latest 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
24
+
25
+ = Supported Networks =
26
+
27
+ * **Blogger/Blogspot** - Autopost to your Blog. HTML is supported.
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
+ * **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.
32
+ * **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*)
33
+ * **LiveJournal** - Auto-submit your blogpost to LiveJournal.
34
+ * **Pinterest** (*with third party API library*) - Pin your blogpost's featured image to your Pinterest board.
35
+ * **Stumbleupon** - Auto-submit bookmark to your account.
36
+ * **Tumblr** - Autopost to your account. Ability to attach your blogpost to Tumblr post. HTML is supported.
37
+ * **Twitter** - Autopost to your account. Ability to attach Image to tweets.
38
+ * **Plurk** - Autopost to your account. Ability to attach Image to messages.
39
+ * **vBulletin** - Auto-submit your blogpost to vBulletin forums. Could create new threads or new posts.
40
+ * **vKontakte(VK.com)** - Autopost to your profile or group page. Ability to attach your blogpost to Facebook post. Ability to make "Image" posts.
41
+ * **Wordpress** - Auto-submit your blogpost to another blog based on Wordpress. This options includes Wordpress.com, Blog.com, etc..
 
 
 
 
 
 
 
 
42
 
43
  ... more networks are coming soon ...
44
 
48
 
49
  == Installation ==
50
 
51
+ You need to have account with either Facebook, Tumblr, Google+, LinkedIn, Pinterest, Blogger, Twitter, Delicious, Diigo, Plurk, LiveJournal, Stumbleupon or all of them.
52
 
53
  **Please, see more detailed installation instructions with screenshots here: http://www.nextscripts.com/installation-of-social-networks-auto-poster-for-wordpress **
54
 
117
 
118
  == Frequently Asked Questions ==
119
 
120
+ = What is the difference between "Free" and "Pro" versions? =
121
+
122
+ Free plugin is limited to one account per each type of connected networks. In other words you can add 1 Facebook, AND 1 Twitter AND 1 LinkedIn AND 1 etc ... accounts in the "Free" version. This is enough for about 95% of users.
123
+
124
+ Pro plugin is NOT limited in number of accounts per each type of connected networks. You can add 10 (or 100) Facebook, AND 15 Twitter AND 5 LinkedIn AND 25 etc ... accounts in the "Pro" version.
125
+
126
+ Please see more here: <a href="http://www.nextscripts.com/social-networks-auto-poster-pro-for-wordpress-compare-editions//">Compare Editions</a>
127
+
128
+ = What networks in your auto-poster plugin are free and what are not? Why some networks are not free? =
129
+
130
+ All networks except Google+, Pinterest and LinkedIn Company Pages are available for free.
131
+
132
+ It really depends on the availability of the free API from the Social Network itself.
133
+ Facebook, Twitter, Tumblr, LinkedIn and others have a very good and powerful free APIs that could be used for publishing posts. Those networks are free for you. Some networks like Google+ and Pinterest don't have API or have a read-only API that doesn't allow to make posts. We had to create our own API libraries for such networks and those libraries are available separately for some fee.
134
+
135
+ = Does the free plugin support Wordpress Multisite (ex-WPMU)? =
136
+
137
+ Free plugin does not support Wordpress Multisite. There is a separate "Pro for WPMU" plugin available for Wordpress Multisite. Please see more here: <a href="http://www.nextscripts.com/social-networks-auto-poster-pro-for-wordpress-compare-editions//">Compare Editions</a>
138
+
139
+ = Can I use it just for Twitter (Facebook, LinkedIn, Delicious) or it requres all networks to be set? =
140
 
141
  Sure you can use it for just one or two networks.
142
 
152
 
153
  == Screenshots ==
154
 
155
+ 1. Add new post metadata box (Pro Version)
156
+ 2. Settings Page (Pro Version)
157
+ 3. Facebook Types of Post
158
+ 4. Google+ Types of Post
159
 
160
  == Changelog ==
161
 
162
+ = 2.5.5 [01/18/2013] =
163
+
164
+ * New/Improvement - Tumblr - Audio and Video Post types
165
+ * New/Improvement - %HTAGS% and %HCATS% for insert tags and categories as hashtags
166
+ * Bug fix - Critical Facebook Authorization Problem
167
+
168
+ = 2.5.4 [01/17/2013] =
169
+
170
+ * New - New network: VKontakte(vk.com). Repost your blogposts to your VK account.
171
+ * Bug fix - Facebook settings saving problem on some configurations
172
+ * Bug fix - Google+ debug text removed
173
+ * Bug fix - WPMU Edition only. - Lost settings opages on users websites.
174
+
175
+ = 2.5.3 [01/15/2013] =
176
+
177
+ * New - Support for posting to Google+ Communities.
178
+ * New - Auto-posting is now supported for Wordpress pages as well.
179
+ * Bug fix - Twitter over the limit if a lot of tags were used.
180
+ * Bug fix - Blogger posted the wrong title.
181
+
182
+ = 2.5.2 [01/07/2013] =
183
+
184
+ * Bug fix - Critical Facebook posting issue.
185
+ * Bug fix - Critical Stumbleupon posting issue.
186
+ * Bug fix - Tumblr and SU were not taking settings from the "Edit" page
187
+ * Bug fix - Post/Don't Post checkboxes issues.
188
+ * Bug fix - Twitter - incomatibility with url_f_open set to off.
189
+
190
+ = 2.5.1 [01/06/2013] =
191
+
192
+ * New - New network: LiveJournal. Repost your blogposts to your LiveJournal account.
193
+ * New/Improvement - Facebook - support for Vimeo videos
194
+ * Improvement/Bug fix - Facebook - better handling of videos in the post.
195
+ * Bug fix - Import was button broken on some sites
196
+
197
+ = 2.5.0 [01/02/2013] =
198
+
199
+ * New - Export/Import plugin settings
200
+ * New/Improvement - Direct links to posts in the "Edit" page.
201
+ * New/Improvement - Pinterest - ability to "Pin" videos.
202
+ * Improvement - Facebook - Photos could be posted to the App Album or to the "Wall" album to avoid grouping
203
+ * Improvement - if post has video and no images, video preview image wil be used.
204
+ * Improvement/Bug fix - Fixed incorrect image checking against websites blocking HEAD request.
205
+ * Improvement/Bug fix - support for "attached" but not "featured" images.
206
+ * Bug fix - Facebook were getting a broken "image" post if post contained a video.
207
+ * Bug fix - Plurk was not taking settings from the "Edit" page
208
+ * Bug fix - Blogger (Free API) iframe was breaking autoposting with "iframe" must be followed by the ' = ' character." message
209
+
210
+ = 2.4.8 [12/21/2012] =
211
 
212
  * New/Improvement - external jQuery reference removed.
213
  * Bug fix - Pinterest board selection fix.
214
  * Bug fix - StumbleUpon connection fix.
215
  * Bug fix - Twitter %TAGS% and %CATS% for non English characters
216
  * Bug fix - Twitter %TAGS% and %CATS% were not found in the text sometimes.
217
+ * Bug fix - Wordpress better handling of connection errors.
218
  * Bug fix - Post status saving.
219
 
220
+ = 2.4.7 [12/13/2012] =
221
 
222
  * New/Improvement - Ability to change format before reposting when you edit post.
223
  * Bug fix - Critical Blogger "Function not found" fix.
224
  * Bug fix - Escaped quotes in Message Format.
225
 
226
+ = 2.4.6 [12/12/2012] =
227
 
228
  * Improvement - Wordpress 3.5 compatibility
229
  * Improvement/Bug fix - Better image handling.
231
  * Bug fix - Fixed LinkedIn for European accounts.
232
  * Bug fix - Twitter Message length tweaks.
233
 
234
+ = 2.4.5 [12/07/2012] =
235
 
236
  * Improvement/Bug fix - Google+ better "Post type" selection.
237
  * Bug fix - Google+ - image uploads for pages go to the right album, not profile.
238
  * Bug fix - Google+ - Correct image for "attached" posts
239
  * Bug fix - Twitter image attachment broken in 2.4.4
240
 
241
+ = 2.4.4 [12/06/2012] =
242
 
243
  * Improvement - Twitter - If tags and categories are already in the text will become hashtags, not duplicates.
244
  * Improvement/Bug fix - "Check All/Uncheck All" links now have priority over category selection.
246
  * Bug fix - Plurk - 180 characters limit.
247
  * Bug fix - Twitter correct characters count (119) for "Posts with image"
248
 
249
+ = 2.4.3 [12/04/2012] =
250
 
251
  * New - Support for Wordpress Built-in Shortener
252
  * Improvement/Bug fix - Facebook - better image posting.
258
  * Bug fix - Pinterest UTF characters in the Board names.
259
  * Bug fix - Pinterest - better Handling of Error 502.
260
 
261
+ = 2.4.2 [11/30/2012] =
262
 
263
  * New - New network: Plurk. share your new blogpost on your Plurk account.
264
  * New - Twitter - ability to post tags and categories as #hashtags
267
  * Bug fix - SSL connections fix and SSL cerificate update
268
  * Bug fix - Broken URL Shorthener selection
269
 
270
+ = 2.4.1 [11/22/2012] =
271
 
272
  * Bug fix - Twitter error if attachmet image is missing
273
  * Bug fix - Issue with apostrophes and quotes
274
  * Improvement - "Click-through URL" for the Tumblr "Photo" posts can use shorthened URLs.
275
  * Improvement - Ability to select custom field instead of the featured image.
276
 
277
+ = 2.4.0 [11/13/2012] =
278
 
279
  * New - Facebook "Photo" posts.
280
  * New - Ablity to attach image to Twitter posts
282
  * New - wp.me support for short links. (Jetpack users only)
283
  * Improvement - "Click-through URL" for the Tumblr "Photo" posts.
284
 
285
+ = 2.3.12 [11/09/2012] =
286
 
287
  * Improvement/Bug fix - Blogger Better support for broken HTML.
288
  * Bug fix - LinkedIn "Empty Message" Fix
364
  * Bug fix - Facebook stability.
365
  * Bug fix - WP Multisite Management problems.
366
 
367
+ = 2.3.0 [10/12/2012] =
368
 
369
  * New - Support for WP Multisite (Pro Only) - http://www.nextscripts.com/social-networks-auto-poster-pro-for-wordpress-compare-editions/
370
  * New - New network: Stumbleupon. Share your new blogpost on your StumbleUpon account.
414
  * Bug fix - LinkedIn was still attaching a post if not selected.
415
  * Bug fix - Problem with Log/History saving.
416
 
417
+ = 2.2.0 [09/25/2012] =
418
 
419
  * New - NextScript LinkeIn API support for company pages auto-posting (Beta).
420
  * New - Actions Log - see the log of the auto-postings.
443
  * Bug fix - Broken quotes in the "Message Format".
444
  * Bug fix - "Post Immediately" was broken for free accounts.
445
 
446
+ = 2.1.0 [09/12/2012] =
447
  * New - New network: Wordpress based websites. This option includes Wordpress.com, Blog.com, and and any other blogs based on WP.
448
  * Improvement - nicknames for your accounts. You can give each account a nickname to make it easier to identify in the list.
449
  * Improvement - better looking settings pages.
467
  = 2.0.9 =
468
  * Bug fix - Facebook Authorization "Error 100" Fix.
469
 
470
+ = 2.0.8 [08/06/2012] =
471
  * Improvement - Better list of available accounts.
472
  * Improvement/Bug fix - a lot of cosmetic interface changes and code optimizations for problem fixing and better looking.
473
  * Bug fix - Google+ Wrong options when using "Repost Button"
495
  = 2.0.3 =
496
  * Initial public 2.0 Release.
497
 
498
+ = 1.9.13 [08/28/2012] =
499
  * Improvement - Pinterest is caching login info to prevent "multiple logins" issues.
500
  * Bug fix - Pinterest special characters
501
  * Bug fix - Tumblr Authorization issue.
553
  * Bug fix - Correct Special Character Encoding
554
  * Bug fix - Blooger Encoding issues.
555
 
556
+ = 1.9.0 [07/13/2012]=
557
  * New - LinkedIn Support
558
  * Improvement - Post Options are now movable
559
  * Improvement - Security for Google+, Pinterest, Blogger - passwords are better encoded in the DB.
570
  * Bug fix - Facebook %TEXT% and %FULLTEXT% formatiing issues.
571
  * Bug fix - Some Blogger Authorization issues.
572
 
573
+ = 1.8.5 [07/05/2012]=
574
  * Bug fix - Format settings disappeared after update post
575
  * Bug fix - Twitter 140 characters limit when used with %TEXT% and %FULLTEXT%
576
 
593
  * Improvement - Pinterest - ability to change board during the post writing
594
  * Bug fix - Several small bugs and formating fixes.
595
 
596
+ = 1.8.0 [06/29/2012]=
597
  * New - Pinterest Support
598
  * New - Tumblr Support
599
  * New/Improvement - %IMG% replacement tag - Inserts Featured Image URL
608
  * Improvement - Google+ Phone Verification support
609
  * Bug fix - Google+ "You are not authorized for this page" Error
610
 
611
+ = 1.7.5 [06/14/2012]=
612
  * New/Improvement - %SURL% replacement tag - Shortens URL
613
  * Improvement - Wordpress 3.4 Compatibility
614
  * Improvement - Better handling of Twitter's "140 characters limit"
626
  = 1.7.1 =
627
  * Bug fix - Repost button fixed.
628
 
629
+ = 1.7.0 [06/05/2012] =
630
  * New - Support for Wordpress "Custom Post Types".
631
  * New - Ability to add open graph tags without third party plugins.
632
  * Improvement - Better compatibility/faster Google+ posting.
636
  * Bug fix - Fixed missing "Pending-to-Publish" status change.
637
  * Bug fix - Twitter settings page format fixed.
638
 
639
+ = 1.6.2 [05/09/2012]=
640
  * Bug fix - Fix for "Cannot modify header information" message while posting to Twitter.
641
 
642
  = 1.6.1 =