NextScripts: Social Networks Auto-Poster - Version 3.8.8

Version Description

[08/26/2017]

Download this release

Release Info

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

Code changes from version 3.4.31 to 3.8.8

Files changed (84) hide show
  1. NextScripts_SNAP.php +229 -252
  2. img/5p-bg.png +0 -0
  3. img/5p16.png +0 -0
  4. img/SNAP_Logo_2014.png +0 -0
  5. img/arrow_r_green_c1.png +0 -0
  6. img/cbch.png +0 -0
  7. img/cbrb.png +0 -0
  8. img/cbun.png +0 -0
  9. img/direct-nxsapi-usage-Facebook.php +92 -0
  10. img/fbPostTypesDiff6.png +0 -0
  11. img/icons/meta24.png +0 -0
  12. img/icons/post24.png +0 -0
  13. img/icons/search24.png +0 -0
  14. img/icons/tag24.png +0 -0
  15. img/icons/time24.png +0 -0
  16. img/icons/type24.png +0 -0
  17. img/icons/user24.png +0 -0
  18. img/ig-bg.png +0 -0
  19. img/ig16.png +0 -0
  20. img/ig16x.png +0 -0
  21. img/mc-bg.png +0 -0
  22. img/mc16.png +0 -0
  23. img/md-bg.png +0 -0
  24. img/md16.png +0 -0
  25. img/ok-bg.png +0 -0
  26. img/ok16.png +0 -0
  27. img/refresh16.png +0 -0
  28. img/snap-icon.png +0 -0
  29. img/sx-bg.png +0 -0
  30. img/tg-bg.png +0 -0
  31. img/tg16.png +0 -0
  32. img/wb-bg.png +0 -0
  33. img/wb16.png +0 -0
  34. img/yo-bg.png +0 -0
  35. img/yo16.png +0 -0
  36. inc-cl/5p.api.php +66 -0
  37. inc-cl/5p.php +130 -0
  38. inc-cl/ap.api.php +9 -11
  39. inc-cl/ap.php +83 -236
  40. inc-cl/apis/liOAuth.php +13 -10
  41. inc-cl/apis/plurkOAuth.php +7 -7
  42. inc-cl/apis/scOAuth.php +11 -11
  43. inc-cl/apis/startssl.pem +44 -0
  44. inc-cl/apis/xmlrpc-client.php +19 -483
  45. inc-cl/bg.api.php +14 -12
  46. inc-cl/bg.php +105 -292
  47. inc-cl/da.api.php +31 -28
  48. inc-cl/da.php +53 -219
  49. inc-cl/di.api.php +8 -8
  50. inc-cl/di.php +55 -210
  51. inc-cl/dl.api.php +22 -26
  52. inc-cl/dl.php +49 -207
  53. inc-cl/fb.api.php +44 -45
  54. inc-cl/fb.php +350 -475
  55. inc-cl/fl.api.php +13 -30
  56. inc-cl/fl.php +78 -252
  57. inc-cl/fp.api.php +14 -9
  58. inc-cl/fp.php +51 -230
  59. inc-cl/gp.api.php +18 -14
  60. inc-cl/gp.php +165 -248
  61. inc-cl/ig.api.php +38 -0
  62. inc-cl/ig.php +66 -0
  63. inc-cl/ip.api.php +8 -8
  64. inc-cl/ip.php +53 -210
  65. inc-cl/kt.api.php +0 -50
  66. inc-cl/kt.php +0 -206
  67. inc-cl/li.api.php +52 -56
  68. inc-cl/li.php +363 -403
  69. inc-cl/lj.api.php +5 -5
  70. inc-cl/lj.php +70 -217
  71. inc-cl/mc.api.php +55 -0
  72. inc-cl/mc.php +64 -0
  73. inc-cl/md.api.php +58 -0
  74. inc-cl/md.php +111 -0
  75. inc-cl/ok.api.php +58 -0
  76. inc-cl/ok.php +90 -0
  77. inc-cl/pk.api.php +6 -6
  78. inc-cl/pk.php +102 -291
  79. inc-cl/pn.api.php +16 -14
  80. inc-cl/pn.php +117 -230
  81. inc-cl/rd.api.php +15 -48
  82. inc-cl/rd.php +102 -241
  83. inc-cl/sc.api.php +2 -2
  84. inc-cl/sc.php +77 -248
NextScripts_SNAP.php CHANGED
@@ -3,36 +3,41 @@
3
  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: 3.4.31
8
  Author URI: http://www.nextscripts.com
9
  Text Domain: nxs_snap
10
- Copyright 2012-2015 Next Scripts, Inc
11
  */
12
- define( 'NextScripts_SNAP_Version' , '3.4.31' );
13
 
14
  $nxs_mLimit = ini_get('memory_limit'); if (strpos($nxs_mLimit, 'G')) {$nxs_mLimit = (int)$nxs_mLimit * 1024;} else {$nxs_mLimit = (int)$nxs_mLimit;}
15
  if ($nxs_mLimit>0 && $nxs_mLimit<64) { add_filter('plugin_action_links','ns_add_nomem_link', 10, 2 );
16
  if (!function_exists("ns_add_nomem_link")) { function ns_add_nomem_link($links, $file) { global $nxs_mLimit; static $this_plugin; if (!$this_plugin) $this_plugin = plugin_basename(__FILE__);
17
  if ($file == $this_plugin){ $settings_link = '<b style="color:red;">Not Enough Memory allowed for PHP.</b> <br/> You have '.$nxs_mLimit.' MB. You need at least 64MB'; array_unshift($links, $settings_link);} return $links;}}
18
  } else {
19
- require_once "nxs_functions.php"; require_once "inc/nxs_functions_adv.php"; require_once "inc/nxs_snap_class.php";
 
20
  //## Include All Available Networks
21
- //error_reporting(E_ALL); ini_set('display_errors', '1');
22
- global $nxs_snapAvNts, $nxs_snapThisPageUrl, $nxs_snapSetPgURL, $nxs_plurl, $nxs_plpath, $nxs_isWPMU, $nxs_tpWMPU, $nxs_skipSSLCheck;
23
 
24
- $nxs_snapSetPgURL = nxs_get_admin_url().'options-general.php?page=NextScripts_SNAP.php'; $nxs_snapThisPageUrl = $nxs_snapSetPgURL; $nxs_plurl = plugin_dir_url(__FILE__); $nxs_plpath = plugin_dir_path(__FILE__);
25
- $nxs_isWPMU = defined('MULTISITE') && MULTISITE==true;
 
 
26
 
27
- if (class_exists("NS_SNAutoPoster")) { nxs_checkAddLogTable(); $plgn_NS_SNAutoPoster = new NS_SNAutoPoster(); }
28
  do_action('nxs_doSomeMore');
29
  if (!isset($nxs_snapAvNts) || !is_array($nxs_snapAvNts)) $nxs_snapAvNts = array(); $nxs_snapAPINts = array(); foreach (glob($nxs_plpath.'inc-cl/*.php') as $filename) require_once $filename;
30
  if (file_exists(WP_CONTENT_DIR.'/nx-apis/')) foreach (glob(WP_CONTENT_DIR.'/nx-apis/*.php') as $filename) require_once $filename;
31
  do_action('nxs_doSomeMoreSecond');
 
 
32
  //## Tests
33
  if (isset($_GET['page']) && $_GET['page']=='NextScripts_SNAP.php' && isset($_GET['do']) && $_GET['do']=='test'){
34
- error_reporting(E_ALL); ini_set('error_reporting', E_ALL); ini_set('display_errors', 1); if (function_exists('gzdeflate')) echo "Y"; else echo "N"; echo "Testting... cURL<br/>";
35
- nxs_cURLTest("http://www.nextscripts.com/", "HTTPS to NXS", "Social Networks");
 
36
  nxs_cURLTest("http://www.google.com/intl/en/contact/", "HTTP to Google", "Mountain View, CA");
37
  nxs_cURLTest("https://www.google.com/intl/en/contact/", "HTTPS to Google", "Mountain View, CA");
38
  nxs_cURLTest("https://www.facebook.com/", "HTTPS to Facebook", 'id="facebook"');
@@ -40,7 +45,7 @@ if (isset($_GET['page']) && $_GET['page']=='NextScripts_SNAP.php' && isset($_GET
40
  nxs_cURLTest("https://www.linkedin.com/nhome/", "HTTPS to LinkedIn", 'rel="canonical" href="https://www.linkedin.com/');
41
  nxs_cURLTest("https://twitter.com/", "HTTPS to Twitter", '<link rel="canonical" href="https://twitter.com');
42
  nxs_cURLTest("https://www.pinterest.com/", "HTTPS to Pinterest", 'content="Pinterest"');
43
- nxs_cURLTest("http://www.livejournal.com/", "HTTP to LiveJournal", '1999 LiveJournal');
44
  die('Done');
45
  }
46
  if (isset($_GET['page']) && $_GET['page']=='NextScripts_SNAP.php' && isset($_GET['do']) && $_GET['do']=='crtest'){
@@ -55,113 +60,6 @@ if (isset($_GET['page']) && $_GET['page']=='NextScripts_SNAP.php' && isset($_GET
55
  echo '</div>';
56
  die();
57
  }
58
- //## Delete Account
59
- if (!function_exists("ns_delNT_ajax")) { function ns_delNT_ajax(){ check_ajax_referer('nxsSsPageWPN'); $indx = (int)$_POST['id'];
60
- global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
61
- unset($options[$_POST['nt']][$indx]); if (is_array($options)) { update_option('NS_SNAutoPoster', $options); $plgn_NS_SNAutoPoster->nxs_options = $options; }
62
- }}
63
- if (!function_exists("nsAuthFBSv_ajax")) { function nsAuthFBSv_ajax() { check_ajax_referer('nsFB'); $pgID = $_POST['pgID']; $fbs = array();
64
- global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
65
- foreach ($options['fb'] as $two) { if ($two['fbPgID']==$pgID) $two['wfa']=time(); $fbs[] = $two; } $options['fb'] = $fbs; if (is_array($options)) { update_option('NS_SNAutoPoster', $options); $plgn_NS_SNAutoPoster->nxs_options = $options; }
66
- }}
67
- if (!function_exists("nsGetBoards_ajax")) {
68
- function nsGetBoards_ajax() { global $nxs_gCookiesArr; check_ajax_referer('nxsSsPageWPN'); global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
69
- if (get_magic_quotes_gpc() || $_POST['nxs_mqTest']=="\'") { $_POST['u'] = stripslashes($_POST['u']); $_POST['p'] = stripslashes($_POST['p']);} $_POST['p'] = trim($_POST['p']); $u = trim($_POST['u']);
70
- $loginError = doConnectToPinterest($_POST['u'], substr($_POST['p'], 0, 5)=='g9c1a'?nsx_doDecode(substr($_POST['p'], 5)):$_POST['p'] ); if ($loginError!==false) {echo $loginError; return "BAD USER/PASS";}
71
- $gPNBoards = doGetBoardsFromPinterest(); $options['pn'][$_POST['ii']]['pnBoardsList'] = base64_encode($gPNBoards);
72
- $options['pn'][$_POST['ii']]['pnSvC'] = serialize($nxs_gCookiesArr); if (is_array($options)) update_option('NS_SNAutoPoster', $options); echo $gPNBoards; die();
73
- }
74
- }
75
-
76
- if (!function_exists("nxs_getBrdsOrCats_ajax")) {
77
- function nxs_getBrdsOrCats_ajax() { global $nxs_gCookiesArr; check_ajax_referer('nxsSsPageWPN'); global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
78
- if (get_magic_quotes_gpc() || $_POST['nxs_mqTest']=="\'") { $_POST['u'] = stripslashes($_POST['u']); $_POST['p'] = stripslashes($_POST['p']);} $_POST['p'] = trim($_POST['p']); $u = trim($_POST['u']);
79
-
80
- if ( $_POST['ty']=='pn') { $loginError = doConnectToPinterest($_POST['u'], substr($_POST['p'], 0, 5)=='g9c1a'?nsx_doDecode(substr($_POST['p'], 5)):$_POST['p'] ); if ($loginError!==false) {echo $loginError; return "BAD USER/PASS";}
81
- $gPNBoards = doGetBoardsFromPinterest(); $options['pn'][$_POST['ii']]['pnBoardsList'] = base64_encode($gPNBoards);
82
- $options['pn'][$_POST['ii']]['pnSvC'] = serialize($nxs_gCookiesArr); if (is_array($options)) update_option('NS_SNAutoPoster', $options); echo $gPNBoards; die();
83
- }
84
- if ( $_POST['ty']=='rd') { $loginError = doConnectToRD($_POST['u'], substr($_POST['p'], 0, 5)=='g9c1a'?nsx_doDecode(substr($_POST['p'], 5)):$_POST['p'] ); if (!is_array($loginError)) { echo $loginError; return "BAD USER/PASS";}
85
- $gBoards = doGetSubredditsFromRD(); $options['rd'][$_POST['ii']]['rdSubRedditsList'] = base64_encode($gBoards);
86
- if (is_array($options)) update_option('NS_SNAutoPoster', $options); echo $gBoards; die();
87
- }
88
-
89
- }
90
- }
91
-
92
-
93
- if (!function_exists("nxs_delPostSettings_ajax")) { function nxs_delPostSettings_ajax(){ check_ajax_referer('nxsSsPageWPN'); global $nxs_snapAvNts; $pid = (int)$_POST['pid'];
94
- foreach ($nxs_snapAvNts as $avNt) delete_post_meta($pid, 'snap'.strtoupper($avNt['code'])); delete_post_meta($pid, 'snap_isAutoPosted'); delete_post_meta($pid, 'snap_MYURL');
95
- echo "OK"; die();
96
- }}
97
-
98
- if (!function_exists("nsGetGPCats_ajax")) {
99
- function nsGetGPCats_ajax() { global $nxs_gCookiesArr; check_ajax_referer('nxsSsPageWPN'); global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
100
- if (get_magic_quotes_gpc() || $_POST['nxs_mqTest']=="\'") { $_POST['u'] = stripslashes($_POST['u']); $_POST['p'] = stripslashes($_POST['p']);} $_POST['p'] = trim($_POST['p']); $u = trim($_POST['u']);
101
- $loginError = doConnectToGooglePlus2($_POST['u'], substr($_POST['p'], 0, 5)=='g9c1a'?nsx_doDecode(substr($_POST['p'], 5)):$_POST['p'] ); if ($loginError!==false) {echo $loginError; return "BAD USER/PASS";}
102
- $gGPCCats = doGetCCatsFromGooglePlus($_POST['c']); $options['gp'][$_POST['ii']]['gpCCatsList'] = base64_encode($gGPCCats);
103
- if (is_array($options)) update_option('NS_SNAutoPoster', $options); echo $gGPCCats; die();
104
- }
105
- }
106
- if (!function_exists("nsGetWLBoards_ajax")) {
107
- function nsGetWLBoards_ajax() { global $nxs_gCookiesArr; check_ajax_referer('nxsSsPageWPN'); global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
108
- if (get_magic_quotes_gpc() || $_POST['nxs_mqTest']=="\'") { $_POST['u'] = stripslashes($_POST['u']); $_POST['p'] = stripslashes($_POST['p']);} $_POST['p'] = trim($_POST['p']); $u = trim($_POST['u']);
109
- $loginError = doConnectToWaNeLo($_POST['u'], substr($_POST['p'], 0, 5)=='g9c1a'?nsx_doDecode(substr($_POST['p'], 5)):$_POST['p'] ); if ($loginError!==false) {echo $loginError; return "BAD USER/PASS";}
110
- $gWLBoards = doGetBoardsFromWaNeLo(); $options['wl'][$_POST['ii']]['wlBoardsList'] = base64_encode($gWLBoards);
111
- $options['wl'][$_POST['ii']]['wlSvC'] = serialize($nxs_gCookiesArr); if (is_array($options)) update_option('NS_SNAutoPoster', $options); echo $gWLBoards; die();
112
- }
113
- }
114
- //## Set all posts to Include/exclude from/to Auto-Reposting
115
- if (!function_exists("nxs_SetRpstAll_ajax")) {
116
- function nxs_SetRpstAll_ajax() { check_ajax_referer('nxsSsPageWPN'); global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;// prr($options[$_POST['t']][$_POST['ii']]);
117
- if ($_POST['ed']=='X' || $_POST['ed']=='L') { // prr($options[$_POST['t']][$_POST['ii']]); prr($options); die();
118
- if ($_POST['ed']=='X') { $options[$_POST['t']][$_POST['ii']]['rpstLastPostID'] = '';
119
- $options[$_POST['t']][$_POST['ii']]['rpstLastShTime'] = ''; $options[$_POST['t']][$_POST['ii']]['rpstLastPostTime'] = ''; $options[$_POST['t']][$_POST['ii']]['rpstNxTime'] = '';
120
- } elseif ($_POST['ed']=='L' && trim($_POST['lpid'])!='' && (int)$_POST['lpid'] > 0) {
121
- $post = get_post($_POST['lpid']);
122
- $options[$_POST['t']][$_POST['ii']]['rpstLastPostTime'] = $post->post_date;
123
- $options[$_POST['t']][$_POST['ii']]['rpstLastPostID'] = trim($_POST['lpid']);
124
- }
125
- if (is_array($options)) { update_option('NS_SNAutoPoster', $options); $plgn_NS_SNAutoPoster->nxs_options = $options; } // echo "|".$_POST['t'].$_POST['ii']."|"; prr($options[$_POST['t']][$_POST['ii']]);
126
- } else {
127
- if (!empty($options['nxsCPTSeld'])) $tpArray = maybe_unserialize($options['nxsCPTSeld']); if (!is_array($tpArray)) $tpArray = array('post'); else $tpArray[] = 'post';
128
- foreach ($tpArray as $tp) if (!empty($tp)) {
129
- $args = array( 'post_type' => $tp, 'post_status' => 'publish', 'numberposts' => 30, 'offset'=> 0, 'fields'=>'ids' ); $posts = get_posts( $args );
130
- while (count($posts)>0){
131
- foreach ($posts as $postID){ $pMeta = maybe_unserialize(get_post_meta($postID, 'snap'.strtoupper($_POST['t']), true));
132
- if (!isset($pMeta) || !is_array($pMeta)) $pMeta = array(); if (!isset($pMeta[$_POST['ii']]) || !is_array($pMeta[$_POST['ii']])) $pMeta[$_POST['ii']] = array();
133
- if ($_POST['ed']!='2') $pMeta[$_POST['ii']]['rpstPostIncl'] = $_POST['ed']=='0'?'0':'nxsi'.$_POST['ii'].$_POST['t']; else {
134
- $doPost = true; $exclCats = maybe_unserialize($options['exclCats']); $postCats = wp_get_post_categories($postID);
135
- foreach ($postCats as $pCat) { if ( (is_array($exclCats)) && in_array($pCat, $exclCats)) $doPost = false; else {$doPost = true; break;}}
136
- $optMt = $options[$_POST['t']][$_POST['ii']];
137
- if ( $optMt['catSel']=='1' && trim($optMt['catSelEd'])!='' ) { $inclCats = explode(',',$optMt['catSelEd']); foreach ($postCats as $pCat) { if (!in_array($pCat, $inclCats)) $doPost = false; else {$doPost = true; break;}} }
138
- $pMeta[$_POST['ii']]['rpstPostIncl'] = $doPost?'nxsi'.$_POST['ii'].$_POST['t']:'0';
139
- } delete_post_meta($postID, 'snap'.strtoupper($_POST['t'])); add_post_meta($postID, 'snap'.strtoupper($_POST['t']), serialize($pMeta));
140
- } $args['offset'] = $args['offset']+30; $posts = get_posts( $args );
141
- }
142
- }
143
- } echo "OK"; die();
144
- }}
145
- if (!function_exists("nxs_clLgo_ajax")) { function nxs_clLgo_ajax() { check_ajax_referer('nxsSsPageWPN'); global $wpdb;
146
- //update_option('NS_SNAutoPosterLog', '');
147
- $wpdb->query( 'DELETE FROM '.$wpdb->prefix . 'nxs_log' ); echo "OK";
148
- }}
149
- if (!function_exists("nxs_rfLgo_ajax")) { function nxs_rfLgo_ajax() { check_ajax_referer('nxsSsPageWPN'); echo "Y:";
150
- //$log = get_option('NS_SNAutoPosterLog'); $logInfo = maybe_unserialize(get_option('NS_SNAutoPosterLog'));
151
- $logInfo = nxs_getnxsLog();
152
- if (is_array($logInfo))foreach (array_reverse($logInfo) as $logline) {
153
- if ($logline['type']=='E') $actSt = "color:#FF0000;"; elseif ($logline['type']=='M') $actSt = "color:#585858;"; elseif ($logline['type']=='BG') $actSt = "color:#008000; font-weight:bold;";
154
- elseif ($logline['type']=='I') $actSt = "color:#0000FF;"; elseif ($logline['type']=='W') $actSt = "color:#DB7224;"; elseif ($logline['type']=='A') $actSt = "color:#580058;";
155
- elseif ($logline['type']=='BI') $actSt = "color:#0000FF; font-weight:bold;"; elseif ($logline['type']=='GR') $actSt = "color:#008080;";
156
- elseif ($logline['type']=='S') $actSt = "color:#005800; font-weight:bold;"; else $actSt = "color:#585858;";
157
- if ($logline['type']=='E') $msgSt = "color:#FF0000;"; elseif ($logline['type']=='BG') $msgSt = "color:#008000; font-weight:bold;"; else $msgSt = "color:#585858;";
158
- if ($logline['nt']!='') $ntInfo = ' ['.$logline['nt'].'] '; else $ntInfo = '';
159
- echo '<snap style="color:#008000">['.$logline['date'].']</snap> - <snap style="'.$actSt.'">['.$logline['act'].']</snap>'.$ntInfo.'- <snap style="'.$msgSt.'">'.$logline['msg'].'</snap> '.$logline['extInfo'].'<br/>';
160
- }
161
-
162
-
163
- }}
164
-
165
 
166
  //## Initialize the admin panel if the plugin has been activated
167
  if (!function_exists("nxs_AddSUASettings")) { function nxs_AddSUASettings() { global $plgn_NS_SNAutoPoster, $nxs_plurl; // if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
@@ -170,81 +68,89 @@ if (!function_exists("nxs_AddSUASettings")) { function nxs_AddSUASettings() { g
170
  if (!function_exists("NS_SNAutoPoster_ap")) { function NS_SNAutoPoster_ap() { global $plgn_NS_SNAutoPoster, $nxs_plurl; // if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
171
  if (function_exists('add_options_page')) { add_options_page('Social Networks Auto Poster',
172
  '<span style="font-weight:bold; color:#2ecc2e;">{SNAP} </span>Social Networks Auto Poster', 'manage_options', basename(__FILE__), array(&$plgn_NS_SNAutoPoster, 'showSNAutoPosterOptionsPage'));
173
- }}}
 
 
174
  if (!function_exists("NS_SNAutoPoster_apx")) { function NS_SNAutoPoster_apx() { global $plgn_NS_SNAutoPoster, $nxs_plurl; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
175
  if (function_exists('add_options_page')) { add_options_page('Social Networks Auto Poster',
176
  '<span style="font-weight:bold; color:#2ecc2e">{SNAP} </span>Social Networks Auto Poster ', 'manage_options', basename(__FILE__), array(&$plgn_NS_SNAutoPoster, 'showSNAutoPosterOptionsPagex'));
177
  }}}
178
  //## Main Function to Post
179
- if (!function_exists("nxs_snapLogPublishTo")) { function nxs_snapLogPublishTo( $new_status, $old_status, $post ) { clean_post_cache( $post->ID );
180
- if ( $old_status!='publish' && $old_status!='trash' && $new_status == 'publish' ) { nxs_addToLogN('BG', "*** ID: {$post->ID}, Type: {$post->post_type}", '', ' Status Changed: '."{$old_status}_to_{$new_status}".'. Autopost requested.');
 
181
  nxs_snapPublishTo($post);
182
  }
183
  }}
184
- if (!function_exists("nxs_snapPublishTo")) { function nxs_snapPublishTo($postArr, $type='', $aj=false) { global $plgn_NS_SNAutoPoster, $nxs_snapAvNts, $blog_id, $nxs_tpWMPU; // echo " | nxs_doSMAS2 | "; prr($postArr);
185
- if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
 
 
 
186
  if (!empty($_POST['nxs_snapPostOptions'])) { $NXS_POSTX = $_POST['nxs_snapPostOptions']; $NXS_POST = array(); $NXS_POST = NXS_parseQueryStr($NXS_POSTX); } else $NXS_POST = $_POST;
187
- if(is_object($postArr)) $postID = $postArr->ID; else { $postID = $postArr; $postArr = get_post($postID); } $isPost = isset($NXS_POST["snapEdIT"]); $post = get_post($postID);
188
  if ($post->post_status != 'publish') { sleep(5); $post = get_post($postID); $postArr = $post;
189
- if ($post->post_status != 'publish') { nxs_addToLogN('I', 'Cancelled', '', 'Autopost Cancelled - Post is not "Published" Right now - Post ID:('.$postID.') - Current Post status -'.$post->post_status ); return; }
190
- }
191
- //nxs_addToLogN('BG', 'Post Status Changed', '', '-=## Autopost requested.'.($blog_id>1?'BlogID:'.$blog_id:'').' PostID:('.$postID.') Post Type: '.$post->post_type.' ##=-');
192
- //$args=array('public'=>true, '_builtin'=>false); $output = 'names'; $operator = 'and'; $post_types = array(); ## Removed because some post types are not available from WP Cron
193
- // if (function_exists('get_post_types')) { $post_types=get_post_types($args, $output, $operator); ## Removed because some post types are not available from WP Cron
194
- if ( isset($options['nxsCPTSeld']) && $options['nxsCPTSeld']!='') $nxsCPTSeld = unserialize($options['nxsCPTSeld']); else $nxsCPTSeld = array();
195
- // 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))) { ## Removed because some post types are not available from WP Cron
196
- $post_types = array();
197
- if ($post->post_type == 'post' || ($options['useForPages']=='1' && $post->post_type == 'page') || (in_array($post->post_type, $nxsCPTSeld))) {
198
- if ($isPost && $options['skipSecurity']!='1' && !current_user_can("make_snap_posts") && !current_user_can("manage_options")) { nxs_addToLogN('I', 'Skipped', '', 'Current user can\'t autopost - Post ID:('.$postID.')' ); return; }
199
- $postUser = $postArr->post_author;
200
- if ($options['skipSecurity']!='1' && !user_can( $postUser, "make_snap_posts" ) && !user_can( $postUser, "manage_options")){ nxs_addToLogN('I', 'Skipped', '', '', 'User ID '.$postUser.' can\'t autopost (please see <a target="_blank" href="http://www.nextscripts.com/support-faq/#a17">FAQ #1.7</a> for more info/solution) - Post ID:('.$postID.')' ); return; }
201
  if ($isPost) $plgn_NS_SNAutoPoster->NS_SNAP_SavePostMetaTags($postID);
202
  if (function_exists('nxs_doSMAS2')) { nxs_doSMAS2($postArr, $type, $aj); return; } else {
203
  $options = $plgn_NS_SNAutoPoster->nxs_options; $ltype=strtolower($type);
204
- if ($nxs_tpWMPU=='S') { switch_to_blog(1); $plgn_NS_SNAutoPoster = new NS_SNAutoPoster(); $options = $plgn_NS_SNAutoPoster->nxs_options; restore_current_blog(); }
 
 
205
  if (!isset($options['nxsHTDP']) || $options['nxsHTDP']=='S') { if(isset($NXS_POST["snapEdIT"]) && $NXS_POST["snapEdIT"]=='1') { $publtype='S'; $delay = rand(2,10); } else $publtype='A'; } else $publtype = 'I';
206
- nxs_addToLogN('BG', 'Start =- ', '', '------=========#### NEW AUTO-POST REQUEST '.($blog_id>1?'BlogID:'.$blog_id:'').' PostID:('.$postID.') '.($publtype=='S'?'Scheduled +'.$delay:($publtype=='A'?'Automated':'Immediate')).' ####=========------');
 
 
 
 
 
 
 
 
 
207
 
208
- $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted=='1') { nxs_addToLogN('W', 'Skipped', '', 'Already Autoposted - Post ID:('.$postID.')' ); return; }
209
- $snap_isEdIT = get_post_meta($postID, 'snapEdIT', true); if ($snap_isEdIT!='1') { $doPost = true; $exclCats = maybe_unserialize($options['exclCats']); $postCats = wp_get_post_categories($postID);
210
- foreach ($postCats as $pCat) { if ( (is_array($exclCats)) && in_array($pCat, $exclCats)) $doPost = false; else {$doPost = true; break;}}
211
- if (!$doPost) { nxs_addToLogN('I', 'Skipped', '', 'Automated Post - Category Excluded - Post ID:('.$postID.')' ); return; }
212
- }
213
  foreach ($nxs_snapAvNts as $avNt) {
214
- if (isset($options[$avNt['lcode']]) && count($options[$avNt['lcode']])>0 ){ $clName = 'nxs_snapClass'.$avNt['code'];
215
  if ($isPost && isset($NXS_POST[$avNt['lcode']])) $po = $NXS_POST[$avNt['lcode']]; else { $po = get_post_meta($postID, 'snap'.$avNt['code'], true); $po = maybe_unserialize($po);}
216
- if (isset($po) && is_array($po)) $isPostMeta = true; else { $isPostMeta = false; $po = $options[$avNt['lcode']]; }
217
  delete_post_meta($postID, 'snap_isAutoPosted'); add_post_meta($postID, 'snap_isAutoPosted', '1');
218
- $optMt = $options[$avNt['lcode']][0]; if ($isPostMeta) { $ntClInst = new $clName(); $optMt = $ntClInst->adjMetaOpt($optMt, $po[0]); }
219
- if ($snap_isEdIT!='1') { $doPost = true;
220
- if ( $optMt['catSel']=='1' && trim($optMt['catSelEd'])!='' ) { $inclCats = explode(',',$optMt['catSelEd']);
221
- foreach ($postCats as $pCat) { if (!in_array($pCat, $inclCats)) $doPost = false; else {$doPost = true; break;}}
222
- if (!$doPost) { nxs_addToLogN('I', 'Skipped', $avNt['name'].' ('.$optMt['nName'].')', '[Automated Post] - Individual Category Excluded - Post ID:('.$postID.')' ); continue; }
223
- }
224
- //## Get tags
225
- if (!empty($optMt['tagsSel'])) { $inclTags = explode(',',strtolower($optMt['tagsSel'])); $postTags = wp_get_post_tags( $postID, array( 'fields' => 'slugs' ) ); $postCust = array();
226
- //## Get all custom post types
227
- foreach ($inclTags as $iTag){
228
- if (strpos($iTag,'|')!==false){ $dd=explode('|',$itag); if (empty($postCust[$dd[0]])) $postCust[$dd[0]]=wp_get_object_terms($postID,$dd[0],array('fields'=>'slugs'));
229
- if (!in_array(strtolower($dd[1]), $postCust[$dd[0]])) $doPost = false; else {$doPost = true; break;}
230
- } else if (!in_array(strtolower($iTag), $postTags)) $doPost = false; else {$doPost = true; break;}
231
- }
232
- if (!$doPost) { nxs_addToLogN('I', 'Skipped', $avNt['name'].' ('.$optMt['nName'].')', '[Automated Post] - Tag Excluded - Post ID:('.$postID.') - Included Tags: '.$optMt['tagsSel'].' | Post Tags: '.print_r($postTags, true)." | ".print_r($postCust, true) ); continue; }
233
- }
234
- }
235
- if ($optMt['do'.$avNt['code']]=='1') { $optMt['ii'] = 0;
236
- if ($publtype=='A' && ($optMt['nMin']>0 || $optMt['nHrs']>0 || $optMt['nTime']!='')) $publtype='S';
237
- if ($publtype=='S') { if (isset($optMt['nHrs']) && isset($optMt['nMin']) && ($optMt['nHrs']>0 || $optMt['nMin']>0) ) { $delay = $optMt['nMin']*60+$optMt['nHrs']*3600;
238
- nxs_addToLogN('I', 'Delayed', $avNt['name'].' ('.$optMt['nName'].')', 'Post has been delayed for '.$delay.' Seconds ('.($optMt['nHrs']>0?$optMt['nHrs'].' Hours':'')." ".($optMt['nMin']>0?$optMt['nMin'].' Minutes':'').')' );
239
- } else $delay = rand(2,10); $optMt['timeToRun'] = time()+$delay;
240
  if ($options['ver']>300.330) { $shName = '_nxs_snap_sh_'.$avNt['code'].'0_'.$optMt['timeToRun']; delete_post_meta($postID, $shName); add_post_meta($postID, $shName, $optMt); $args = array($postID, $shName); }
241
  else $args = array($postID, $optMt);
242
  wp_schedule_single_event($optMt['timeToRun'],'ns_doPublishTo'.$avNt['code'], $args);
243
- nxs_addToLogN('BI', 'Scheduled', $avNt['name'].' ('.$optMt['nName'].') for '.$optMt['timeToRun']."(".date_i18n('Y-m-d H:i:s', $optMt['timeToRun'] + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS )).")", ' PostID:('.$postID.')' );
244
  } else { $fname = 'nxs_doPublishTo'.$avNt['code']; $fname($postID, $optMt); }
245
- } else { nxs_addToLogN('GR', 'Skipped', $avNt['name'].' ('.$optMt['nName'].')', '-=[Unchecked Account]=- - PostID:'.$postID.'' ); }
246
  }
247
- } } } else { nxs_addToLogN('I', 'Skipped', '', 'Excluded Post Type: '.$post->post_type.' (Post ID: '.$postID.')| NOT IN ('.print_r($nxsCPTSeld, true).')| ALL ('.print_r($post_types, true).')' ); return; }
248
  global $isS; if ($isS && function_exists("restore_current_blog")) restore_current_blog();
249
  }}
250
 
@@ -262,17 +168,47 @@ if (!function_exists("ns_add_settings_link")) { function ns_add_settings_link($l
262
  if (!function_exists("nxs_adminInitFunc")) { function nxs_adminInitFunc(){ global $plgn_NS_SNAutoPoster, $nxs_snapThisPageUrl, $pagenow, $nxs_isWPMU;
263
  $nxs_snapThisPageUrl = nxs_get_admin_url().($pagenow=='admin.php'?'network/':'').$pagenow.'?page=NextScripts_SNAP.php';
264
  if (function_exists('nxs_getInitUCheck') && (isset($plgn_NS_SNAutoPoster))) { $options = $plgn_NS_SNAutoPoster->nxs_options; if (is_array($options) && count($options)>1) nxs_getInitUCheck($options); }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
265
  //## Javascript to Admin Panel
266
  if (( ($pagenow=='options-general.php'||$pagenow=='admin.php') && isset($_GET['page']) && ( $_GET['page']=='NextScripts_SNAP.php' || stripos($_GET['page'], 'nxssnap')==0)) ||$pagenow=='post.php'||$pagenow=='post-new.php'){
267
- if ( isset($_GET['post_type']) && $_GET['post_type']=='page' && isset($options['useForPages']) && $options['useForPages']!=1 ) {}
268
- else { add_filter( 'tiny_mce_before_init', 'nxs_tiny_mce_before_init' ); add_action('admin_head', 'jsPostToSNAP'); add_action('admin_head', 'nxs_jsPostToSNAP2'); }
269
  }
270
  if (function_exists('nxsDoLic_ajax')) { add_action('wp_ajax_nxsDoLic', 'nxsDoLic_ajax'); }
271
  }}
272
  if (!function_exists("nxs_adminInitFunc2")) { function nxs_adminInitFunc2(){ global $plgn_NS_SNAutoPoster, $nxs_snapThisPageUrl, $pagenow; $nxs_snapThisPageUrl = nxs_get_admin_url().($pagenow=='admin.php'?'network/':'').$pagenow.'?page=NextScripts_SNAP.php'; //## Add MEtaBox to Post Edit Page
273
- if (current_user_can("see_snap_box") || current_user_can("manage_options")) { add_action('add_meta_boxes', array($plgn_NS_SNAutoPoster, 'NS_SNAP_addCustomBoxes'));
274
  if (!($pagenow=='options-general.php' && !empty($_GET['page']) && $_GET['page']=='NextScripts_SNAP.php')) add_action( 'admin_bar_menu', 'nxs_toolbar_link_to_mypage', 999 );
275
  }
 
 
276
  }}
277
 
278
  function nxs_saveSiteSets_ajax(){ check_ajax_referer('nxssnap');
@@ -286,30 +222,42 @@ function nxs_saveSiteSets_ajax(){ check_ajax_referer('nxssnap');
286
  echo "OK"; die();
287
  }
288
 
289
- //## OG:Tags
290
- function nxs_start_ob(){ if (!is_admin()) ob_start( 'nxs_ogtgCallback' );}
291
- function nxs_end_flush_ob(){ if (!is_admin()) @ob_end_flush();}
292
- function nxs_ogtgCallback($content){ global $post, $plgn_NS_SNAutoPoster;
 
 
 
293
  if (stripos($content, 'og:title')!==false) $ogOut = "\r\n"; else {
294
- if (!isset($plgn_NS_SNAutoPoster)) $options = get_option('NS_SNAutoPoster'); else $options = $plgn_NS_SNAutoPoster->nxs_options; $ogimgs = array();
295
- if (!empty($post) && !is_object($post) && int($post)>0) $post = get_post($post); if (empty($options['advFindOGImg'])) $options['advFindOGImg'] = 0;
296
- $title = preg_match( '/<title>(.*)<\/title>/', $content, $title_matches );
297
- if ($title !== false && count( $title_matches) == 2 ) $ogT ='<meta property="og:title" content="' . $title_matches[1] . '" />'."\r\n"; else {
298
- if (is_home() || is_front_page() ) $ogT = get_bloginfo( 'name' ); else $ogT = get_the_title();
299
- $ogT = '<meta property="og:title" content="' . esc_attr( apply_filters( 'nxsog_title', $ogT ) ) . '" />'."\r\n";
300
- }
301
- $prcRes = preg_match( '/<meta name="description" content="(.*)"/', $content, $description_matches );
302
- if ( $prcRes !== false && count( $description_matches ) == 2 ) $ogD = '<meta property="og:description" content="' . $description_matches[1] . '" />'."\r\n"; {
303
- if (!empty($post) && is_object($post) && is_singular()) {
304
- if(has_excerpt($post->ID))$ogD=strip_tags(nxs_snapCleanHTML($post->post_excerpt));else $ogD= str_replace(" ", ' ', str_replace("\r\n", ' ', trim(substr(strip_tags(nxs_snapCleanHTML(strip_shortcodes($post->post_content))), 0, 200))));
305
- } else $ogD = get_bloginfo('description'); $ogD = preg_replace('/\r\n|\r|\n/m','',$ogD);
 
 
 
306
  $ogD = '<meta property="og:description" content="'.esc_attr( apply_filters( 'nxsog_desc', $ogD ) ).'" />'."\r\n";
307
- }
308
  $ogSN = '<meta property="og:site_name" content="'.get_bloginfo('name').'" />'."\r\n";
309
  $ogLoc = strtolower(esc_attr(get_locale())); if (strlen($ogLoc)==2) $ogLoc .= "_".strtoupper($ogLoc);
310
  $ogLoc = '<meta property="og:locale" content="'.$ogLoc.'" />'."\r\n"; $iss = is_home();
 
 
 
 
 
 
 
311
  $ogType = is_singular()?'article':'website'; if(empty($vidsFromPost)) $ogType = '<meta property="og:type" content="'.esc_attr(apply_filters('nxsog_type', $ogType)).'" />'."\r\n";
312
-
313
  if (is_home() || is_front_page()) $ogUrl = get_bloginfo( 'url' ); else $ogUrl = 'http' . (is_ssl() ? 's' : '') . "://".$_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
314
  $ogUrl = '<meta property="og:url" content="'.esc_url( apply_filters( 'nxsog_url', $ogUrl ) ) . '" />' . "\r\n";
315
 
@@ -321,7 +269,7 @@ function nxs_ogtgCallback($content){ global $post, $plgn_NS_SNAutoPoster;
321
  echo '<meta property="og:image" content="http://i2.ytimg.com/vi/'.$vidsFromPost[0].'/mqdefault.jpg" />'."\n";
322
  echo '<meta property="og:type" content="video" />'."\n";
323
  } */
324
- if (is_object($post)) { $imgURL = nxs_getPostImage($post->ID, 'full', $options['ogImgDef']); if (!empty($imgURL)) $ogimgs[] = $imgURL;
325
  $imgsFromPost = nsFindImgsInPost($post, (int)$options['advFindOGImg']==1);
326
  if ($imgsFromPost !== false && is_singular() && is_array($ogimgs) && is_array($imgsFromPost)) $ogimgs = array_merge($ogimgs, $imgsFromPost);
327
  }
@@ -330,17 +278,33 @@ function nxs_ogtgCallback($content){ global $post, $plgn_NS_SNAutoPoster;
330
  if ( count($ogimgs)<1 && isset($options['ogImgDef']) && $options['ogImgDef']!='') $ogimgs[] = $options['ogImgDef'];
331
  //## Output og:image tags
332
  $ogImgsOut = ''; if (!empty($ogimgs) && is_array($ogimgs)) foreach ($ogimgs as $ogimage) $ogImgsOut .= '<meta property="og:image" content="'.esc_url(apply_filters('ns_ogimage', $ogimage)).'" />'."\r\n";
333
- $ogOut = "\r\n".$ogSN.$ogT.$ogD.$ogType.$ogUrl.$ogLoc.$ogImgsOut;
334
  } $content = str_ireplace('<!-- ## NXSOGTAGS ## -->', $ogOut, $content);
335
  return $content;
336
  }
337
  function nxs_addOGTagsPreHolder() { echo "<!-- ## NXS/OG ## --><!-- ## NXSOGTAGS ## --><!-- ## NXS/OG ## -->\n\r";}
338
 
339
- if (!function_exists("nxssnap_enqueue_scripts")) { function nxssnap_enqueue_scripts(){
340
- wp_enqueue_script( 'nxssnap-scripts', plugin_dir_url( __FILE__ ) . 'js/js.js', array( 'jquery' ), NextScripts_SNAP_Version);
341
- wp_enqueue_script( 'selectize', plugin_dir_url( __FILE__ ) . 'js/selectize.min.js', array( 'jquery' ), NextScripts_SNAP_Version);
342
- wp_enqueue_style( 'selectize', plugin_dir_url( __FILE__ ) . 'js/selectize.css' );
343
- wp_localize_script( 'nxssnap-scripts', 'MyAjax', array( 'ajaxurl' => nxs_get_admin_url( 'admin-ajax.php' ), 'nxsnapWPnonce' => wp_create_nonce( 'nxsnapWPnonce' ),));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
344
  }}
345
 
346
  function nxs_noR(&$item, &$key){ $item = is_string($item)?(str_replace("\r","\n",str_replace("\n\r","\n",str_replace("\r\n","\n",$item)))):$item; }
@@ -389,19 +353,15 @@ function nxs_showNewPostForm($options, $air = true) { global $nxs_snapAvNts, $nx
389
  <div class="nxsNPRow" style="font-size: 12px;">
390
  <?php
391
  foreach ($nxs_snapAvNts as $avNt) { $clName = 'nxs_snapClass'.$avNt['code']; $ntClInst = new $clName();
392
- if ( isset($options[$avNt['lcode']]) && count($options[$avNt['lcode']])>0) { ?>
393
-
394
- <div class="nsx_iconedTitle" style="margin-bottom:1px;background-image:url(<?php echo $nxs_plurl;?>img/<?php echo $avNt['lcode']; ?>16.png);"><?php echo $avNt['name']; ?><br/>
395
- <?php $ntOpts = $options[$avNt['lcode']]; foreach ($ntOpts as $indx=>$pbo){ ?>
396
- <input class="nxsNPDoChb" value="<?php echo $avNt['lcode']; ?>--<?php echo $indx; ?>" name="nxsNPNts" type="checkbox" <?php if ((int)$pbo['do'.$avNt['code']] == 1 && $pbo['catSel']!='1') echo "checked"; ?> />
397
-
398
- <?php echo $avNt['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></br>
399
-
400
- <?php } ?>
401
- </div> <?php
402
  } } ?>
403
- </div>
404
-
405
  </div>
406
  </div>
407
  </div>
@@ -412,12 +372,11 @@ function nxs_showNewPostForm($options, $air = true) { global $nxs_snapAvNts, $nx
412
  function nxs_doNewNPPost($options){ global $nxs_snapAvNts, $nxs_plurl; $postResults = '';
413
  if (!empty($_POST['mNts']) && is_array($_POST['mNts'])) { nxs_addToLogN('S', '-=== New Form Post requested ===-', 'Form', count($_POST['mNts']).' Networks', print_r($_POST['mNts'], true));
414
  $message = array('title'=>'', 'text'=>'', 'siteName'=>'', 'url'=>'', 'imageURL'=>'', 'videoURL'=>'', 'tags'=>'', 'urlDescr'=>'', 'urlTitle'=>'');
415
- if (get_magic_quotes_gpc() || $_POST['nxs_mqTest']=="\'") { $_POST['mText'] = stripslashes($_POST['mText']); $_POST['mTitle'] = stripslashes($_POST['mTitle']); }
416
- $message['pText'] = $_POST['mText']; $message['pTitle'] = $_POST['mTitle'];
417
  //## Get URL info
418
  if (!empty($_POST['mLink']) && substr($_POST['mLink'], 0, 4)=='http') { $message['url'] = $_POST['mLink'];
419
- $flds = array('id'=>$message['url'], 'scrape'=>'true'); $response = wp_remote_post('https://graph.facebook.com/v2.3/', array('body' => $flds));
420
- if (is_wp_error($response)) $badOut['Error'] = print_r($response, true)." - ERROR"; else { $response = json_decode($response['body'], true);
421
  if (!empty($response['description'])) $message['urlDescr'] = $response['description']; if (!empty($response['title'])) $message['urlTitle'] = $response['title'];
422
  if (!empty($response['site_name'])) $message['siteName'] = $response['site_name'];
423
  if (!empty($response['image'][0]['url'])) $message['imageURL'] = $response['image'][0]['url'];
@@ -426,10 +385,10 @@ function nxs_doNewNPPost($options){ global $nxs_snapAvNts, $nxs_plurl; $postResu
426
  if (!empty($_POST['mImg']) && substr($_POST['mImg'], 0, 4)=='http') $message['imageURL'] = $_POST['mImg'];
427
 
428
  foreach ($_POST['mNts'] as $ntC){ $ntA = explode('--',$ntC); $ntOpts = $options[$ntA[0]][$ntA[1]];
429
- if (!empty($ntOpts) && is_array($ntOpts)) { $logNT = $ntA[0]; $clName = 'nxs_class_SNAP_'.strtoupper($logNT);
430
  $logNT = '<span style="color:#800000">'.strtoupper($logNT).'</span> - '.$ntOpts['nName'];
431
  $ntOpts['postType'] = $_POST['mType']; $ntToPost = new $clName(); $ret = $ntToPost->doPostToNT($ntOpts, $message);
432
- if (!is_array($ret) || $ret['isPosted']!='1') { //## Error
433
  nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), ''); $postResults .= $logNT ." - Error (Please see log)<br/>";
434
  } else { // ## All Good - log it.
435
  if (!empty($ret['postURL'])) $extInfo = '<a href="'.$ret['postURL'].'" target="_blank">Post Link</a>';
@@ -439,28 +398,11 @@ function nxs_doNewNPPost($options){ global $nxs_snapAvNts, $nxs_plurl; $postResu
439
  } echo "Done. Results:<br/> ".$postResults; }
440
  }
441
 
442
- if (!function_exists("nxs_snapAjax")) { function nxs_snapAjax() { check_ajax_referer('nxsSsPageWPN'); $arg = '';
443
- global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
444
- if ($_POST['nxsact']=='getNTset'){$ii = $_POST['ii'];$nt = $_POST['nt'];$ntl = strtolower($nt); $pbo = $options[$ntl][$ii]; $pbo['ntInfo']['lcode'] = $ntl; $clName = 'nxs_snapClass'.$nt; $ntObj = new $clName();
445
- $ntObj->showNTSettings($ii, $pbo);
446
- }
447
- if ($_POST['nxsact']=='svEdFlds') {
448
- $cn = str_replace(']','',$_POST['cname']); $cna = explode('[',$cn); prr($cna); $id = $_POST['pid']; $nt = $cna[0]; $ntU = strtoupper($nt); $ii = $cna[1]; $fname = $cna[2];
449
- $savedMeta = maybe_unserialize(get_post_meta($id, 'snap'.$ntU, true)); $savedMeta[$ii][$fname] = $_POST['cval']; prr($savedMeta);
450
- delete_post_meta($id, 'snap'.$ntU); add_post_meta($id, 'snap'.$ntU, str_replace('\\','\\\\',serialize($savedMeta)));
451
- }
452
- if ($_POST['nxsact']=='getNewPostDlg') nxs_showNewPostForm($options);
453
- if ($_POST['nxsact']=='doNewPost') nxs_doNewNPPost($options);
454
- if ($_POST['nxsact']=='nxsCptCheckGP') nxs_CptCheckGP($options);
455
- do_action( 'nxsajax', $arg );
456
- die();
457
- }}
458
-
459
  function nxs_admin_footer() {global $nxs_plurl; ?> <div style="display: none;" id="nxs_popupDiv"><span class="nxspButton bClose"><span>X</span></span>
460
  <div id="nxsNPLoader" style="text-align: center; width: 100%; height: 80px; padding-top: 60px;";> <img src="<?php echo $nxs_plurl; ?>img/ajax-loader-med.gif" /> </div>
461
  <div id="nxs_popupDivCont" style="right: 10px; top:10px; font-size: 16px; font-weight: lighter;"> </div></div> <?php
462
  }
463
- function nxs_admin_header() { wp_nonce_field( 'nxsSsPageWPN', 'nxsSsPageWPN_wpnonce' ); }
464
  function nxs_popupCSS() {?><style type="text/css">
465
  .nxspButton:hover { background-color: #1E1E1E;}
466
  .nxspButton { background-color: #2B91AF; color: #FFFFFF; cursor: pointer; display: inline-block; text-align: center; text-decoration: none; border-radius: 6px 6px 6px 6px; box-shadow: none; font: bold 131% sans-serif; padding: 0 6px 2px; position: absolute; right: -7px; top: -7px;}
@@ -482,7 +424,7 @@ add_action('in_admin_footer', 'nxs_admin_footer');
482
  add_action('in_admin_header', 'nxs_admin_header');
483
 
484
  //## Actions and filters
485
- //add_action( 'transition_post_status', 'nxs_snapLogPublishTo', 10, 3 );
486
 
487
  add_filter('cron_schedules', 'cron_add_nxsreposter');
488
  add_action('nxs_hourly_event', 'nxs_do_this_hourly'); //## Adds Hourly Event
@@ -491,8 +433,19 @@ add_action('wp', 'nxs_activation');
491
  add_action('shutdown', 'nxs_psCron', 25);
492
 
493
  add_filter('get_avatar','ns_get_avatar', 10, 5 );
494
-
495
- if (isset($plgn_NS_SNAutoPoster)) { //## Actions
 
 
 
 
 
 
 
 
 
 
 
496
  //## Add the admin menu
497
  if ($nxs_skipSSLCheck===true){ add_filter('https_ssl_verify', '__return_false'); add_filter('https_local_ssl_verify', '__return_false'); }
498
  if ($nxs_isWPMU) { add_action('network_admin_menu', 'nxs_AddSUASettings'); global $blog_id; } $suOptions = array();
@@ -506,8 +459,7 @@ if (isset($plgn_NS_SNAutoPoster)) { //## Actions
506
  if (!$isO && !$isS && !$isPMB && !function_exists('showSNAP_WPMU_OptionsPageExt')) add_action('admin_menu', 'NS_SNAutoPoster_apx');
507
 
508
  add_action('admin_init', 'nxs_adminInitFunc');
509
- add_action( 'admin_enqueue_scripts', 'nxssnap_enqueue_scripts' );
510
-
511
  add_action('wp_ajax_nxs_snap_aj', 'nxs_snapAjax');
512
 
513
  add_action('wp_ajax_nxs_clLgo', 'nxs_clLgo_ajax');
@@ -517,19 +469,29 @@ if (isset($plgn_NS_SNAutoPoster)) { //## Actions
517
  add_action('wp_ajax_nxs_getExpSettings', 'nxs_getExpSettings_ajax');
518
  add_action('wp_ajax_nxs_hideTip', 'nxs_hideTip_ajax');
519
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
520
 
521
  if ($isO || $isS) {
522
- add_action( 'transition_post_status', 'nxs_snapLogPublishTo', 10, 3 );
523
 
524
  foreach ($nxs_snapAvNts as $avNt) { add_action('ns_doPublishTo'.$avNt['code'], 'nxs_doPublishTo'.$avNt['code'], 1, 2); }
525
  foreach ($nxs_snapAvNts as $avNt) { add_action('wp_ajax_rePostTo'.$avNt['code'], 'nxs_rePostTo'.$avNt['code'].'_ajax'); }
526
 
527
  //## Add AJAX Calls for Test and Repost
528
-
529
- add_action('wp_ajax_nxs_getBrdsOrCats' , 'nxs_getBrdsOrCats_ajax');
530
- add_action('wp_ajax_getBoards' , 'nsGetBoards_ajax');
531
- add_action('wp_ajax_getGPCats' , 'nsGetGPCats_ajax');
532
- add_action('wp_ajax_getWLBoards' , 'nsGetWLBoards_ajax');
533
  add_action('wp_ajax_SetRpstAll' , 'nxs_SetRpstAll_ajax');
534
  add_action('wp_ajax_nxs_delPostSettings' , 'nxs_delPostSettings_ajax');
535
  add_action('wp_ajax_nsDN', 'ns_delNT_ajax');
@@ -539,25 +501,29 @@ if (isset($plgn_NS_SNAutoPoster)) { //## Actions
539
  add_action('admin_menu', 'NS_SNAutoPoster_ap');
540
  add_action('admin_init', 'nxs_adminInitFunc2');
541
  //## Initialize options on plugin activation
542
- $myrelpath = preg_replace( '/.*wp-content.plugins./', '', __FILE__ );
543
- add_action("activate_".$myrelpath, array(&$plgn_NS_SNAutoPoster, 'init'));
544
 
545
  //## Add/Change meta on Save
546
  add_action('edit_post', array($plgn_NS_SNAutoPoster, 'NS_SNAP_SavePostMetaTags'));
547
  add_action('publish_post', array($plgn_NS_SNAutoPoster, 'NS_SNAP_SavePostMetaTags'));
548
  add_action('save_post', array($plgn_NS_SNAutoPoster, 'NS_SNAP_SavePostMetaTags'));
549
  // add_action('edit_page_form', array($plgn_NS_SNAutoPoster, 'NS_SNAP_SavePostMetaTags'));
 
 
550
 
551
  add_action('wp_ajax_nsAuthFBSv', 'nsAuthFBSv_ajax');
552
  //## Custom Post Types and OG tags
553
  add_filter('plugin_action_links','ns_add_settings_link', 10, 2 );
554
 
555
  //## Scedulled Publish Calls
556
- if (!empty($suOptions['nsOpenGraph']) && (int)$suOptions['nsOpenGraph'] == 1) {
557
- add_action( 'init', 'nxs_start_ob', 0 );
 
 
558
  add_action('wp_head', 'nxs_addOGTagsPreHolder', 150);
559
  add_action('shutdown', 'nxs_end_flush_ob', 1000);
560
- }
 
561
  }
562
  if ($nxs_isWPMU){
563
  if (function_exists('nxssnapmu_columns_head')) add_filter('wpmu_blogs_columns', 'nxssnapmu_columns_head');
@@ -567,5 +533,16 @@ if (isset($plgn_NS_SNAutoPoster)) { //## Actions
567
  if (function_exists('nxs_saveSiteSets_ajax')) add_action('wp_ajax_nxs_saveSiteSets', 'nxs_saveSiteSets_ajax');
568
  }
569
  }
 
570
  }
 
 
 
 
 
 
 
 
 
 
571
  ?>
3
  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: NextScripts
7
+ Version: 3.8.8
8
  Author URI: http://www.nextscripts.com
9
  Text Domain: nxs_snap
10
+ Copyright 2012-2017 NextScripts, Inc
11
  */
12
+ define( 'NextScripts_SNAP_Version' , '3.8.8' ); define( 'NextScripts_SNAP_Version_Date' , 'Sept 26, 2017' );
13
 
14
  $nxs_mLimit = ini_get('memory_limit'); if (strpos($nxs_mLimit, 'G')) {$nxs_mLimit = (int)$nxs_mLimit * 1024;} else {$nxs_mLimit = (int)$nxs_mLimit;}
15
  if ($nxs_mLimit>0 && $nxs_mLimit<64) { add_filter('plugin_action_links','ns_add_nomem_link', 10, 2 );
16
  if (!function_exists("ns_add_nomem_link")) { function ns_add_nomem_link($links, $file) { global $nxs_mLimit; static $this_plugin; if (!$this_plugin) $this_plugin = plugin_basename(__FILE__);
17
  if ($file == $this_plugin){ $settings_link = '<b style="color:red;">Not Enough Memory allowed for PHP.</b> <br/> You have '.$nxs_mLimit.' MB. You need at least 64MB'; array_unshift($links, $settings_link);} return $links;}}
18
  } else {
19
+ require_once "nxs_functions.php"; require_once "inc/nxs_functions_wp.php"; require_once "inc/nxs-http.php"; require_once "inc/nxs_functions_adv.php"; require_once "inc/nxs_functions_fv.php";
20
+ require_once "inc/nxs_flt_class.php"; require_once "inc/nxs_snap_class.php"; require_once "inc/nxs_ntlist_class.php"; require_once "inc/nxs_oauth_class.php";
21
  //## Include All Available Networks
22
+ //error_reporting(E_ALL); ini_set('display_errors', '1'); ini_set("log_errors", 1);
23
+ global $nxs_snapAvNts, $nxs_snapThisPageUrl, $nxs_snapSetPgURL, $nxs_plurl, $nxs_plpath, $nxs_isWPMU, $nxs_tpWMPU, $nxs_skipSSLCheck; if (!defined('NXS_PLPATH')) define( 'NXS_PLPATH', plugin_dir_path(__FILE__) ); define( 'NXS_PLURL', plugin_dir_url(__FILE__)); define( 'NXS_SETV', 360);
24
 
25
+ $nxs_snapSetPgURL = nxs_get_admin_url().'options-general.php?page=NextScripts_SNAP.php';
26
+
27
+ $nxs_snapThisPageUrl = $nxs_snapSetPgURL; $nxs_plurl = plugin_dir_url(__FILE__); $nxs_plpath = plugin_dir_path(__FILE__);
28
+ $nxs_isWPMU = defined('MULTISITE') && MULTISITE==true;
29
 
 
30
  do_action('nxs_doSomeMore');
31
  if (!isset($nxs_snapAvNts) || !is_array($nxs_snapAvNts)) $nxs_snapAvNts = array(); $nxs_snapAPINts = array(); foreach (glob($nxs_plpath.'inc-cl/*.php') as $filename) require_once $filename;
32
  if (file_exists(WP_CONTENT_DIR.'/nx-apis/')) foreach (glob(WP_CONTENT_DIR.'/nx-apis/*.php') as $filename) require_once $filename;
33
  do_action('nxs_doSomeMoreSecond');
34
+ //## Init Class
35
+ global $plgn_NS_SNAutoPoster;
36
  //## Tests
37
  if (isset($_GET['page']) && $_GET['page']=='NextScripts_SNAP.php' && isset($_GET['do']) && $_GET['do']=='test'){
38
+ error_reporting(E_ALL); ini_set('error_reporting', E_ALL); ini_set('display_errors', 1); echo "Testting... cURL (SSL/HTTPS Connections)<br/>SNAP Ver: ".NextScripts_SNAP_Version.(defined('NXSAPIVER')?" API: ".NXSAPIVER:'').(defined('NextScripts_UPG_SNAP_Version')?" | SNAP Helper Ver: ".NextScripts_UPG_SNAP_Version:'')."<br/>Deflate - "; echo (function_exists('gzdeflate'))?"Yes":"No"; echo "<br/><br/>";
39
+ nxs_cURLTest("http://whatismyip.org/", "HTTPS to whatismyip", 'getMyIP');
40
+ nxs_cURLTest("https://www.nextscripts.com/", "HTTPS to NXS", "Social Networks");
41
  nxs_cURLTest("http://www.google.com/intl/en/contact/", "HTTP to Google", "Mountain View, CA");
42
  nxs_cURLTest("https://www.google.com/intl/en/contact/", "HTTPS to Google", "Mountain View, CA");
43
  nxs_cURLTest("https://www.facebook.com/", "HTTPS to Facebook", 'id="facebook"');
45
  nxs_cURLTest("https://www.linkedin.com/nhome/", "HTTPS to LinkedIn", 'rel="canonical" href="https://www.linkedin.com/');
46
  nxs_cURLTest("https://twitter.com/", "HTTPS to Twitter", '<link rel="canonical" href="https://twitter.com');
47
  nxs_cURLTest("https://www.pinterest.com/", "HTTPS to Pinterest", 'content="Pinterest"');
48
+ nxs_cURLTest("https://www.livejournal.com/login.bml", "HTTPS to LiveJournal", 'livejournal.com/about');
49
  die('Done');
50
  }
51
  if (isset($_GET['page']) && $_GET['page']=='NextScripts_SNAP.php' && isset($_GET['do']) && $_GET['do']=='crtest'){
60
  echo '</div>';
61
  die();
62
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
 
64
  //## Initialize the admin panel if the plugin has been activated
65
  if (!function_exists("nxs_AddSUASettings")) { function nxs_AddSUASettings() { global $plgn_NS_SNAutoPoster, $nxs_plurl; // if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
68
  if (!function_exists("NS_SNAutoPoster_ap")) { function NS_SNAutoPoster_ap() { global $plgn_NS_SNAutoPoster, $nxs_plurl; // if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
69
  if (function_exists('add_options_page')) { add_options_page('Social Networks Auto Poster',
70
  '<span style="font-weight:bold; color:#2ecc2e;">{SNAP} </span>Social Networks Auto Poster', 'manage_options', basename(__FILE__), array(&$plgn_NS_SNAutoPoster, 'showSNAutoPosterOptionsPage'));
71
+ }
72
+ global $nxs_SNAP; if (empty($nxs_SNAP)) $nxs_SNAP = new nxs_SNAP();
73
+ }}
74
  if (!function_exists("NS_SNAutoPoster_apx")) { function NS_SNAutoPoster_apx() { global $plgn_NS_SNAutoPoster, $nxs_plurl; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
75
  if (function_exists('add_options_page')) { add_options_page('Social Networks Auto Poster',
76
  '<span style="font-weight:bold; color:#2ecc2e">{SNAP} </span>Social Networks Auto Poster ', 'manage_options', basename(__FILE__), array(&$plgn_NS_SNAutoPoster, 'showSNAutoPosterOptionsPagex'));
77
  }}}
78
  //## Main Function to Post
79
+ if (!function_exists("nxs_snapLogPublishTo")) { function nxs_snapLogPublishTo( $new_status, $old_status, $post ) { clean_post_cache( $post->ID ); $uid = 0;
80
+ $postUser = $post->post_author; $isItUserWhoCan = (!user_can($postUser, 'manage_options' ) && user_can($postUser, 'haveown_snap_accss')); if ($isItUserWhoCan) $uid = $postUser;
81
+ if ( $old_status!='publish' && $old_status!='trash' && $new_status == 'publish' ) { nxs_LogIt('BG', "*** ID: {$post->ID}, Type: {$post->post_type}", '','', ' Status Changed: '."{$old_status}_to_{$new_status}".'. Autopost requested.','','snap',$uid);
82
  nxs_snapPublishTo($post);
83
  }
84
  }}
85
+ if (!function_exists("nxs_snapPublishTo")) { function nxs_snapPublishTo($postArr, $type='', $aj=false) { global $plgn_NS_SNAutoPoster, $nxs_snapAvNts, $blog_id, $nxs_tpWMPU; $uid=0; if(is_object($postArr)) $postID = $postArr->ID; else { $postID = $postArr; $postArr = get_post($postID); }
86
+ $postUser = $postArr->post_author; $isItUserWhoCan = (!user_can($postUser, 'manage_options' ) && user_can($postUser, 'haveown_snap_accss')); if ($isItUserWhoCan) $uid = $postUser;
87
+ if (!isset($plgn_NS_SNAutoPoster)) { if (class_exists("NS_SNAutoPoster")) { nxs_checkAddLogTable(); $plgn_NS_SNAutoPoster = new NS_SNAutoPoster(); new nxs_Filters; } else nxs_LogIt('I', 'Cancelled', '', '', 'Autopost Aborted', 'SNAP Class is not found. Post ID:('.$postID.')','snap',$uid);}
88
+ if (!isset($plgn_NS_SNAutoPoster)) { nxs_LogIt('I', 'Cancelled', '', '', 'Autopost Aborted', 'SNAP is not loaded. Post ID:('.$postID.')','snap',$uid); return; } $options = $plgn_NS_SNAutoPoster->nxs_options;
89
+
90
  if (!empty($_POST['nxs_snapPostOptions'])) { $NXS_POSTX = $_POST['nxs_snapPostOptions']; $NXS_POST = array(); $NXS_POST = NXS_parseQueryStr($NXS_POSTX); } else $NXS_POST = $_POST;
91
+ $isPost = isset($NXS_POST["snapEdIT"]); $post = get_post($postID);
92
  if ($post->post_status != 'publish') { sleep(5); $post = get_post($postID); $postArr = $post;
93
+ if ($post->post_status != 'publish') { nxs_LogIt('I', 'Cancelled', '','', 'Autopost Cancelled - Post is not "Published" Right now - Post ID:('.$postID.') - Current Post status -'.$post->post_status ,'snap',$uid ); return; }
94
+ }
95
+
96
+ if ($isPost && $options['skipSecurity']!='1' && !current_user_can("make_snap_posts") && !current_user_can("haveown_snap_accss") && !current_user_can("manage_options")) { nxs_LogIt('I', 'Skipped', '','', 'Current user can\'t autopost - Post ID:('.$postID.')','','snap',$uid ); return; }
97
+
98
+ if ($options['skipSecurity']!='1' && !user_can( $postUser, "make_snap_posts" ) && !user_can( $postUser, "haveown_snap_accss" ) && !user_can( $postUser, "manage_options")){ nxs_LogIt('I', 'Skipped', '', '', 'User ID '.$postUser.' can\'t autopost (please see <a target="_blank" href="http://www.nextscripts.com/support-faq/#a17">FAQ #1.7</a> for more info/solution) - Post ID:('.$postID.')','','snap',$uid ); return; }
99
+
100
+
101
+
 
 
 
102
  if ($isPost) $plgn_NS_SNAutoPoster->NS_SNAP_SavePostMetaTags($postID);
103
  if (function_exists('nxs_doSMAS2')) { nxs_doSMAS2($postArr, $type, $aj); return; } else {
104
  $options = $plgn_NS_SNAutoPoster->nxs_options; $ltype=strtolower($type);
105
+ if ($nxs_tpWMPU=='S') { switch_to_blog(1); $plgn_NS_SNAutoPoster = new NS_SNAutoPoster(); $options = $plgn_NS_SNAutoPoster->nxs_options; restore_current_blog(); }
106
+ if ($isItUserWhoCan) { $nxs_SNAP = new nxs_SNAP($postUser); $networks = $nxs_SNAP->nxs_acctsU; $uid = $postUser;} else $networks = $options;
107
+
108
  if (!isset($options['nxsHTDP']) || $options['nxsHTDP']=='S') { if(isset($NXS_POST["snapEdIT"]) && $NXS_POST["snapEdIT"]=='1') { $publtype='S'; $delay = rand(2,10); } else $publtype='A'; } else $publtype = 'I';
109
+
110
+ if (!isset($options['nxsHTDP']) || $options['nxsHTDP']=='S') {
111
+ if (isset($NXS_POST["snapEdIT"]) && $NXS_POST["snapEdIT"]=='1') $publtype='S'; else $publtype='A';
112
+ if (!$aj && $options['quLimit']=='1' && function_exists('nxs_addToPostingQuery')) { nxs_addToPostingQuery($postID); nxs_addToLog('I', 'Queried', '', 'Post ID:('.$postID.')' ); return; }
113
+ } else $publtype = 'I';
114
+
115
+ //## Apply Global Filters (At the time of publishing)
116
+ $rMsg = nxs_snapCheckFilters($options, $postArr); if ($rMsg!==false) { nxs_LogIt('I', 'Skipped', '', '', 'Filter (Global) - Excluded - Post ID:('.$postID.')', $rMsg,'snap',$uid ); return; }
117
+
118
+ nxs_LogIt('BG', 'Start =- ', '', '', '---===### NEW AUTO-POST REQUEST '.($blog_id>1?'BlogID:'.$blog_id:'').' PostID:('.$postID.') '.($publtype=='S'?'Scheduled +'.$delay:($publtype=='A'?'Automated':'Immediate')).' ###===---','','snap',$uid);
119
 
120
+ $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted=='1') { nxs_LogIt('W', 'Skipped', '', '', 'Already Autoposted - Post ID:('.$postID.')','','snap',$uid ); return; }
121
+
 
 
 
122
  foreach ($nxs_snapAvNts as $avNt) {
123
+ if (isset($networks[$avNt['lcode']]) && count($networks[$avNt['lcode']])>0 ){ $clName = 'nxs_snapClass'.$avNt['code'];
124
  if ($isPost && isset($NXS_POST[$avNt['lcode']])) $po = $NXS_POST[$avNt['lcode']]; else { $po = get_post_meta($postID, 'snap'.$avNt['code'], true); $po = maybe_unserialize($po);}
125
+ if (isset($po) && is_array($po)) $isPostMeta = true; else { $isPostMeta = false; $po = $networks[$avNt['lcode']]; }
126
  delete_post_meta($postID, 'snap_isAutoPosted'); add_post_meta($postID, 'snap_isAutoPosted', '1');
127
+ $optMt = $networks[$avNt['lcode']][0]; if ($isPostMeta) { $ntClInst = new $clName(); $optMt = $ntClInst->adjMetaOpt($optMt, $po[0]); }
128
+
129
+
130
+
131
+ if (!isset($optMt['do'])) $optMt['do'] = $optMt['do'.$avNt['code']]; // prr($avNt['code']); prr($optMt['do']);
132
+ //## Filters
133
+ //prr($optMt);
134
+ if (!empty($optMt['catSel']) || !empty($optMt['tagsSel'])) { $optMt = nxs_FltrsV3toV4($optMt); if ($optMt['do']=='1') $optMt['do']='2'; }
135
+ if ($optMt['do']=='2') { unset($optMt['catSel']); unset($optMt['tagsSel']); $postObj = get_post($postID); $rMsg = nxs_snapCheckFilters($optMt, $postObj);
136
+ if ($rMsg!==false) { nxs_LogIt('GR', 'Skipped: Filter - Network', $avNt['name'].' ('.$optMt['nName'].')', $avNt['code'], 'Excluded - Post ID:('.$postID.')', $rMsg); continue; } else { $optMt['do'] = 1; $optMt['do'.$avNt['code']] = 1; }
137
+ }
138
+ if (!isset($optMt['do'])) $optMt['do'] = $optMt['do'.$avNt['code']];
139
+
140
+ if ($optMt['do']=='1') { $optMt['ii'] = 0; if (!isset($optMt['nDays'])) $optMt['nDays'] = 0; if (!isset($optMt['nHrs'])) $optMt['nHrs'] = 0; if (!isset($optMt['nMin'])) $optMt['nMin'] = 0;
141
+ if ($publtype=='A' && (!empty($optMt['nMin']) || !empty($optMt['nHrs']) || !empty($optMt['nTime']))) $publtype='S';
142
+ if ($publtype=='S') { if ( !empty($optMt['timeToRun']) && $optMt['timeToRun']<$curTime && ((int)$optMt['nDays']>0 || (int)$optMt['nHrs']>0 || (int)$optMt['nMin']>0) ) {
143
+ $delay = $delay+(int)$optMt['nDays']*86400+(int)$optMt['nHrs']*3600+(int)$optMt['nMin']*60;
144
+ nxs_LogIt('I','Delayed',$avNt['name'].' ('.$optMt['nName'].')',$avNt['code'],'Post has been delayed for '.$delay.' Seconds ('.($optMt['nDays']>0?$optMt['nDays'].' Days':'')." ".($optMt['nHrs']>0?$optMt['nHrs'].' Hours':'')." ".($optMt['nMin']>0?$optMt['nMin'].' Minutes':'').')' );
145
+ } else { if($avNt['code']=='FB') $delay = rand(20,40); else $delay = rand(5,15); } $optMt['timeToRun'] = time()+$delay;
 
 
 
146
  if ($options['ver']>300.330) { $shName = '_nxs_snap_sh_'.$avNt['code'].'0_'.$optMt['timeToRun']; delete_post_meta($postID, $shName); add_post_meta($postID, $shName, $optMt); $args = array($postID, $shName); }
147
  else $args = array($postID, $optMt);
148
  wp_schedule_single_event($optMt['timeToRun'],'ns_doPublishTo'.$avNt['code'], $args);
149
+ nxs_LogIt('BI', 'Scheduled', $avNt['name'].' ('.$optMt['nName'].')', $avNt['code'], ' for '.$optMt['timeToRun']."(".date_i18n('Y-m-d H:i:s', $optMt['timeToRun'] + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS )).")", ' PostID:('.$postID.')' );
150
  } else { $fname = 'nxs_doPublishTo'.$avNt['code']; $fname($postID, $optMt); }
151
+ } else { nxs_LogIt('GR', 'Skipped: Checkbox', $avNt['name'].' ('.$optMt['nName'].')', $avNt['code'], '-=[Unchecked Checkbox]=- - PostID:'.$postID.'' ); }
152
  }
153
+ } }
154
  global $isS; if ($isS && function_exists("restore_current_blog")) restore_current_blog();
155
  }}
156
 
168
  if (!function_exists("nxs_adminInitFunc")) { function nxs_adminInitFunc(){ global $plgn_NS_SNAutoPoster, $nxs_snapThisPageUrl, $pagenow, $nxs_isWPMU;
169
  $nxs_snapThisPageUrl = nxs_get_admin_url().($pagenow=='admin.php'?'network/':'').$pagenow.'?page=NextScripts_SNAP.php';
170
  if (function_exists('nxs_getInitUCheck') && (isset($plgn_NS_SNAutoPoster))) { $options = $plgn_NS_SNAutoPoster->nxs_options; if (is_array($options) && count($options)>1) nxs_getInitUCheck($options); }
171
+ //## Quick Post Type
172
+ $labels = array(
173
+ 'name' => __( 'SNAP Quick Post', 'social-networks-auto-poster-facebook-twitter-g' ),
174
+ 'singular_name' => __( 'Quick Post', 'social-networks-auto-poster-facebook-twitter-g' ),
175
+ 'add_new' => __( 'Add Quick Post', 'social-networks-auto-poster-facebook-twitter-g' ),
176
+ 'add_new_item' => __( 'Add new Quick Post', 'social-networks-auto-poster-facebook-twitter-g' ),
177
+ 'edit_item' => __( 'Edit Quick Post', 'social-networks-auto-poster-facebook-twitter-g' ),
178
+ 'new_item' => __( 'New Quick Post', 'social-networks-auto-poster-facebook-twitter-g' ),
179
+ 'view_item' => __( 'View Quick Post', 'social-networks-auto-poster-facebook-twitter-g' ),
180
+ 'search_items' => __( 'Find Quick Posts', 'social-networks-auto-poster-facebook-twitter-g' ),
181
+ 'not_found' => __( 'Quick Post not found', 'social-networks-auto-poster-facebook-twitter-g' ),
182
+ 'not_found_in_trash' => __( 'Quick Post not found in trash', 'social-networks-auto-poster-facebook-twitter-g' ),
183
+ 'menu_name' => __( 'Quick Posts', 'social-networks-auto-poster-facebook-twitter-g' )
184
+ );
185
+
186
+ $args = array(
187
+ 'labels' => $labels,
188
+ 'show_ui' => false,
189
+ 'menu_icon' => 'dashicons-forms',
190
+ 'supports' => array( 'title', 'author', 'thumbnail' ),
191
+ 'rewrite' => array( 'slug' => 'nxs_qp' ),
192
+ 'capabilities' => array(
193
+ 'edit_post' => 'edit_nxs_qp'
194
+ // 'create_posts' => false, // Removes support for the "Add New" function
195
+ )
196
+
197
+ ); register_post_type( 'nxs_qp', $args );
198
+
199
+
200
  //## Javascript to Admin Panel
201
  if (( ($pagenow=='options-general.php'||$pagenow=='admin.php') && isset($_GET['page']) && ( $_GET['page']=='NextScripts_SNAP.php' || stripos($_GET['page'], 'nxssnap')==0)) ||$pagenow=='post.php'||$pagenow=='post-new.php'){
202
+ add_filter( 'tiny_mce_before_init', 'nxs_tiny_mce_before_init' ); add_action('admin_head', 'jsPostToSNAP'); add_action('admin_head', 'nxs_jsPostToSNAP2');
 
203
  }
204
  if (function_exists('nxsDoLic_ajax')) { add_action('wp_ajax_nxsDoLic', 'nxsDoLic_ajax'); }
205
  }}
206
  if (!function_exists("nxs_adminInitFunc2")) { function nxs_adminInitFunc2(){ global $plgn_NS_SNAutoPoster, $nxs_snapThisPageUrl, $pagenow; $nxs_snapThisPageUrl = nxs_get_admin_url().($pagenow=='admin.php'?'network/':'').$pagenow.'?page=NextScripts_SNAP.php'; //## Add MEtaBox to Post Edit Page
207
+ if (current_user_can("haveown_snap_accss") || current_user_can("see_snap_box") || current_user_can("manage_options")) { add_action('add_meta_boxes', array($plgn_NS_SNAutoPoster, 'NS_SNAP_addCustomBoxes'));
208
  if (!($pagenow=='options-general.php' && !empty($_GET['page']) && $_GET['page']=='NextScripts_SNAP.php')) add_action( 'admin_bar_menu', 'nxs_toolbar_link_to_mypage', 999 );
209
  }
210
+ global $nxs_snapSetPgURL;
211
+ $nxs_snapSetPgURL = ((!current_user_can('manage_options' ) && current_user_can('haveown_snap_accss'))) ? nxs_get_admin_url().'admin.php?page=nxssnap' : nxs_get_admin_url().'options-general.php?page=NextScripts_SNAP.php';
212
  }}
213
 
214
  function nxs_saveSiteSets_ajax(){ check_ajax_referer('nxssnap');
222
  echo "OK"; die();
223
  }
224
 
225
+ //#### OG:Tags
226
+ function nxs_end_flush_ob(){
227
+ if ( strpos($_SERVER["HTTP_USER_AGENT"], "facebookexternalhit") !== false || strpos($_SERVER["HTTP_USER_AGENT"], "Facebot") !== false || strpos($_SERVER["HTTP_USER_AGENT"], "Chrome") !== false || strpos($_SERVER["HTTP_USER_AGENT"], "Google (") !== false || strpos($_SERVER["HTTP_USER_AGENT"], "LinkedInBot") !== false || strpos($_SERVER["HTTP_USER_AGENT"], "XING-contenttabreceiver") !== false || strpos($_SERVER["HTTP_USER_AGENT"], "Java/1.7.0_45") !== false) {
228
+ if (!is_admin()) @ob_end_flush();
229
+ }
230
+ }
231
+ function nxs_ogtgCallback($content){ global $post, $nxs_SNAP;
232
  if (stripos($content, 'og:title')!==false) $ogOut = "\r\n"; else {
233
+ if (!isset($nxs_SNAP)) $options = get_option('NS_SNAutoPoster'); else $options = $nxs_SNAP->nxs_options; $ogimgs = array(); $accs = $options; //$content = json_encode($accs['fb']).$content;
234
+ if (!empty($post) && !is_object($post) && (int)$post>0) $post = get_post($post); if (empty($options['advFindOGImg'])) $options['advFindOGImg'] = 0;
235
+
236
+
237
+ if (empty($post->post_title)) { $title = preg_match( '/<title>(.*)<\/title>/', $content, $title_matches );
238
+ if ($title !== false && count( $title_matches) == 2 ) $ogT ='<meta property="og:title" content="' . $title_matches[1] . '" />'."\r\n"; else {
239
+ if (is_home() || is_front_page() ) $ogT = get_bloginfo( 'name' ); else $ogT = get_the_title();
240
+ $ogT = '<meta property="og:title" content="' . esc_attr( apply_filters( 'nxsog_title', $ogT ) ) . '" />'."\r\n";
241
+ }
242
+ } else $ogT = '<meta property="og:title" content="' . esc_attr( apply_filters( 'nxsog_title', $post->post_title ) ) . '" />'."\r\n";
243
+ $prcRes = preg_match( '/<meta name="description" content="(.*)"/', $content, $description_matches );
244
+ if ( $prcRes !== false && count( $description_matches ) == 2 ) $ogD = '<meta property="og:description" content="' . $description_matches[1] . '" />'."\r\n"; {
245
+ if (!empty($post) && is_object($post) && is_singular()) {
246
+ if(has_excerpt($post->ID))$ogD=strip_tags(nxs_snapCleanHTML($post->post_excerpt));else $ogD= str_replace(" ", ' ', str_replace("\r\n", ' ', trim(substr(strip_tags(nxs_snapCleanHTML(strip_shortcodes($post->post_content))), 0, 200))));
247
+ } else $ogD = get_bloginfo('description'); $ogD = preg_replace('/\r\n|\r|\n/m','',$ogD);
248
  $ogD = '<meta property="og:description" content="'.esc_attr( apply_filters( 'nxsog_desc', $ogD ) ).'" />'."\r\n";
249
+ }
250
  $ogSN = '<meta property="og:site_name" content="'.get_bloginfo('name').'" />'."\r\n";
251
  $ogLoc = strtolower(esc_attr(get_locale())); if (strlen($ogLoc)==2) $ogLoc .= "_".strtoupper($ogLoc);
252
  $ogLoc = '<meta property="og:locale" content="'.$ogLoc.'" />'."\r\n"; $iss = is_home();
253
+
254
+ if (!empty($accs['fb']) && count($accs['fb'])>0) { $k = array_slice($accs['fb'], 0, 1); $k = array_shift($k); $ogappID = (!empty($k) && !empty($k['appKey'])) ? ('<meta property="fb:app_id" content="'.$k['appKey'].'"/>'."\r\n"):'';
255
+ $fbURL = (!empty($k) && !empty($k['pgID'])) ? ('https://www.facebook.com/'.$k['pgID'].'/'):'';
256
+ } else { $ogappID = ''; $fbURL = ''; } if (empty($options['ogAuthorFB']) && !empty($fbURL)) $options['ogAuthorFB'] = $fbURL;
257
+ if (!empty($options['ogAuthorFB'])) {
258
+ $author = "<meta property='article:author' content='".$options['ogAuthorFB']."' /><meta property='article:publisher' content='".$options['ogAuthorFB']."' />";
259
+ }
260
  $ogType = is_singular()?'article':'website'; if(empty($vidsFromPost)) $ogType = '<meta property="og:type" content="'.esc_attr(apply_filters('nxsog_type', $ogType)).'" />'."\r\n";
 
261
  if (is_home() || is_front_page()) $ogUrl = get_bloginfo( 'url' ); else $ogUrl = 'http' . (is_ssl() ? 's' : '') . "://".$_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
262
  $ogUrl = '<meta property="og:url" content="'.esc_url( apply_filters( 'nxsog_url', $ogUrl ) ) . '" />' . "\r\n";
263
 
269
  echo '<meta property="og:image" content="http://i2.ytimg.com/vi/'.$vidsFromPost[0].'/mqdefault.jpg" />'."\n";
270
  echo '<meta property="og:type" content="video" />'."\n";
271
  } */
272
+ if (is_object($post)) { $imgURL = nxs_getPostImage($post->ID, !empty($options['wpImgSize'])?$options['wpImgSize']:'full', $options['ogImgDef']); if (!empty($imgURL)) $ogimgs[] = $imgURL;
273
  $imgsFromPost = nsFindImgsInPost($post, (int)$options['advFindOGImg']==1);
274
  if ($imgsFromPost !== false && is_singular() && is_array($ogimgs) && is_array($imgsFromPost)) $ogimgs = array_merge($ogimgs, $imgsFromPost);
275
  }
278
  if ( count($ogimgs)<1 && isset($options['ogImgDef']) && $options['ogImgDef']!='') $ogimgs[] = $options['ogImgDef'];
279
  //## Output og:image tags
280
  $ogImgsOut = ''; if (!empty($ogimgs) && is_array($ogimgs)) foreach ($ogimgs as $ogimage) $ogImgsOut .= '<meta property="og:image" content="'.esc_url(apply_filters('ns_ogimage', $ogimage)).'" />'."\r\n";
281
+ $ogOut = "\r\n".$ogSN.$ogT.$ogD.$ogType.$ogUrl.$ogLoc.$ogImgsOut.$ogappID.$author;
282
  } $content = str_ireplace('<!-- ## NXSOGTAGS ## -->', $ogOut, $content);
283
  return $content;
284
  }
285
  function nxs_addOGTagsPreHolder() { echo "<!-- ## NXS/OG ## --><!-- ## NXSOGTAGS ## --><!-- ## NXS/OG ## -->\n\r";}
286
 
287
+ if (!function_exists("nxssnap_enqueue_scripts")) { function nxssnap_enqueue_scripts(){ if (function_exists('get_current_screen')) $screen = get_current_screen(); else return; // prr($screen->id); // prr($screen);
288
+ if( $screen->id == 'settings_page_NextScripts_SNAP' || $screen->id=='toplevel_page_NextScripts_SNAP-network' || $screen->base == 'post' || stripos($screen->id, 'snapautoposter_page_nxs')===0 || $screen->id=='toplevel_page_nxssnap' || $screen->id=='toplevel_page_nxssnap-network' || $screen->id =='toplevel_page_NextScripts_SNAP-network') {
289
+
290
+ wp_enqueue_script( 'nxssnap-scripts3p', plugin_dir_url( __FILE__ ) . 'js/js3p.js', array( 'jquery' ), NextScripts_SNAP_Version);
291
+ wp_enqueue_style( 'nxssnap-style3p', plugin_dir_url( __FILE__ ) . 'js/css3p.css', array(), NextScripts_SNAP_Version );
292
+
293
+ wp_enqueue_script( 'nxssnap-scripts', plugin_dir_url( __FILE__ ) . 'js/js.js', array( 'jquery' ), NextScripts_SNAP_Version);
294
+ wp_enqueue_style( 'nxssnap-style', plugin_dir_url( __FILE__ ) . 'js/snap.css', array(), NextScripts_SNAP_Version );
295
+
296
+ wp_enqueue_script( 'selectize', plugin_dir_url( __FILE__ ) . 'js/selectize.min.js', array( 'jquery' ), NextScripts_SNAP_Version);
297
+ wp_enqueue_style( 'selectize', plugin_dir_url( __FILE__ ) . 'js/selectize.css', array( ), NextScripts_SNAP_Version );
298
+
299
+ wp_enqueue_script( 'tokenize', plugin_dir_url( __FILE__ ) . 'js/jquery.tokenize.js', array( 'jquery' ), NextScripts_SNAP_Version);
300
+ wp_enqueue_style( 'tokenize', plugin_dir_url( __FILE__ ) . 'js/jquery.tokenize.css', array( ), NextScripts_SNAP_Version );
301
+
302
+ if( $screen->id == 'settings_page_NextScripts_SNAP' || $screen->id=='toplevel_page_NextScripts_SNAP-network' || $screen->id=='toplevel_page_nxssnap') { wp_enqueue_script( 'jquery-ui-datepicker' );
303
+ wp_enqueue_style( 'jquery-ui-datepicker', plugin_dir_url( __FILE__ ) . 'js/jquery-ui.css', array( ), NextScripts_SNAP_Version );
304
+ }
305
+ wp_localize_script( 'nxssnap-scripts', 'MyAjax', array( 'ajaxurl' => nxs_get_admin_url( 'admin-ajax.php' ), 'nxsnapWPnonce' => wp_create_nonce( 'nxsnapWPnonce' ),));
306
+
307
+ }
308
  }}
309
 
310
  function nxs_noR(&$item, &$key){ $item = is_string($item)?(str_replace("\r","\n",str_replace("\n\r","\n",str_replace("\r\n","\n",$item)))):$item; }
353
  <div class="nxsNPRow" style="font-size: 12px;">
354
  <?php
355
  foreach ($nxs_snapAvNts as $avNt) { $clName = 'nxs_snapClass'.$avNt['code']; $ntClInst = new $clName();
356
+ if ( isset($options[$avNt['lcode']]) && count($options[$avNt['lcode']])>0) { ?>
357
+ <div class="nsx_iconedTitle" style="margin-bottom:1px;background-image:url(<?php echo $nxs_plurl;?>img/<?php echo $avNt['lcode']; ?>16.png);"><?php echo $avNt['name']; ?><br/>
358
+ <?php $ntOpts = $options[$avNt['lcode']]; foreach ($ntOpts as $indx=>$pbo){ if (empty($pbo['do'])) $pbo['do'] = $pbo['do'.$avNt['code']]; ?>
359
+ <input class="nxsNPDoChb" value="<?php echo $avNt['lcode']; ?>--<?php echo $indx; ?>" name="nxsNPNts" type="checkbox" <?php if ((int)$pbo['do'] > 0) echo "checked"; ?> />
360
+ <?php echo $avNt['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></br>
361
+ <?php } ?>
362
+ </div> <?php
 
 
 
363
  } } ?>
364
+ </div>
 
365
  </div>
366
  </div>
367
  </div>
372
  function nxs_doNewNPPost($options){ global $nxs_snapAvNts, $nxs_plurl; $postResults = '';
373
  if (!empty($_POST['mNts']) && is_array($_POST['mNts'])) { nxs_addToLogN('S', '-=== New Form Post requested ===-', 'Form', count($_POST['mNts']).' Networks', print_r($_POST['mNts'], true));
374
  $message = array('title'=>'', 'text'=>'', 'siteName'=>'', 'url'=>'', 'imageURL'=>'', 'videoURL'=>'', 'tags'=>'', 'urlDescr'=>'', 'urlTitle'=>'');
375
+ if (!empty($_POST['nxs_mqTest']) && (get_magic_quotes_gpc() || $_POST['nxs_mqTest']=="\'")) { $_POST['mText'] = stripslashes($_POST['mText']); $_POST['mTitle'] = stripslashes($_POST['mTitle']); }
 
376
  //## Get URL info
377
  if (!empty($_POST['mLink']) && substr($_POST['mLink'], 0, 4)=='http') { $message['url'] = $_POST['mLink'];
378
+ $flds = array('id'=>$message['url'], 'scrape'=>'true'); $response = nxs_remote_post('https://graph.facebook.com/v2.3/', array('body' => $flds));
379
+ if (is_nxs_error($response)) $badOut['Error'] = print_r($response, true)." - ERROR"; else { $response = json_decode($response['body'], true);
380
  if (!empty($response['description'])) $message['urlDescr'] = $response['description']; if (!empty($response['title'])) $message['urlTitle'] = $response['title'];
381
  if (!empty($response['site_name'])) $message['siteName'] = $response['site_name'];
382
  if (!empty($response['image'][0]['url'])) $message['imageURL'] = $response['image'][0]['url'];
385
  if (!empty($_POST['mImg']) && substr($_POST['mImg'], 0, 4)=='http') $message['imageURL'] = $_POST['mImg'];
386
 
387
  foreach ($_POST['mNts'] as $ntC){ $ntA = explode('--',$ntC); $ntOpts = $options[$ntA[0]][$ntA[1]];
388
+ if (!empty($ntOpts) && is_array($ntOpts)) { $logNT = $ntA[0]; $clName = 'nxs_class_SNAP_'.strtoupper($logNT); $message['pText'] = nxs_doSpin($_POST['mText']); $message['pTitle'] = nxs_doSpin($_POST['mTitle']);
389
  $logNT = '<span style="color:#800000">'.strtoupper($logNT).'</span> - '.$ntOpts['nName'];
390
  $ntOpts['postType'] = $_POST['mType']; $ntToPost = new $clName(); $ret = $ntToPost->doPostToNT($ntOpts, $message);
391
+ if (!is_array($ret) || empty($ret['isPosted']) || $ret['isPosted']!='1') { //## Error
392
  nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), ''); $postResults .= $logNT ." - Error (Please see log)<br/>";
393
  } else { // ## All Good - log it.
394
  if (!empty($ret['postURL'])) $extInfo = '<a href="'.$ret['postURL'].'" target="_blank">Post Link</a>';
398
  } echo "Done. Results:<br/> ".$postResults; }
399
  }
400
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
401
  function nxs_admin_footer() {global $nxs_plurl; ?> <div style="display: none;" id="nxs_popupDiv"><span class="nxspButton bClose"><span>X</span></span>
402
  <div id="nxsNPLoader" style="text-align: center; width: 100%; height: 80px; padding-top: 60px;";> <img src="<?php echo $nxs_plurl; ?>img/ajax-loader-med.gif" /> </div>
403
  <div id="nxs_popupDivCont" style="right: 10px; top:10px; font-size: 16px; font-weight: lighter;"> </div></div> <?php
404
  }
405
+ if (!function_exists("nxs_admin_header")) { function nxs_admin_header() { wp_nonce_field( 'nxsSsPageWPN', 'nxsSsPageWPN_wpnonce' ); }}
406
  function nxs_popupCSS() {?><style type="text/css">
407
  .nxspButton:hover { background-color: #1E1E1E;}
408
  .nxspButton { background-color: #2B91AF; color: #FFFFFF; cursor: pointer; display: inline-block; text-align: center; text-decoration: none; border-radius: 6px 6px 6px 6px; box-shadow: none; font: bold 131% sans-serif; padding: 0 6px 2px; position: absolute; right: -7px; top: -7px;}
424
  add_action('in_admin_header', 'nxs_admin_header');
425
 
426
  //## Actions and filters
427
+ add_action( 'transition_post_status', 'nxs_snapLogPublishTo', 10, 3 );
428
 
429
  add_filter('cron_schedules', 'cron_add_nxsreposter');
430
  add_action('nxs_hourly_event', 'nxs_do_this_hourly'); //## Adds Hourly Event
433
  add_action('shutdown', 'nxs_psCron', 25);
434
 
435
  add_filter('get_avatar','ns_get_avatar', 10, 5 );
436
+
437
+ }
438
+ function nxs_snap_activate() {
439
+ $dir = explode('social-networks-auto-poster-facebook-twitter-g', plugin_dir_path( __FILE__ )); $pf = $dir[0].'nxs-snap-pro-upgrade/nxs-snap-pro-upgrade.php'; if (file_exists($pf) && !function_exists('nxs_getInitAdd') ) { require_once $pf; nxs_doChAPIU(); }
440
+ } register_activation_hook( __FILE__, 'nxs_snap_activate' );
441
+
442
+
443
+ //## MAIN
444
+ add_action( 'init', 'nxs_initSNAP' );
445
+
446
+ function nxs_initSNAP() { global $plgn_NS_SNAutoPoster; if (class_exists("NS_SNAutoPoster")) { nxs_checkAddLogTable(); $plgn_NS_SNAutoPoster = new NS_SNAutoPoster(); new nxs_Filters; }
447
+ global $nxs_snapAvNts, $nxs_snapThisPageUrl, $nxs_snapSetPgURL, $nxs_plurl, $nxs_plpath, $nxs_isWPMU, $nxs_tpWMPU, $nxs_skipSSLCheck;
448
+ if (isset($plgn_NS_SNAutoPoster)) { //## Actions
449
  //## Add the admin menu
450
  if ($nxs_skipSSLCheck===true){ add_filter('https_ssl_verify', '__return_false'); add_filter('https_local_ssl_verify', '__return_false'); }
451
  if ($nxs_isWPMU) { add_action('network_admin_menu', 'nxs_AddSUASettings'); global $blog_id; } $suOptions = array();
459
  if (!$isO && !$isS && !$isPMB && !function_exists('showSNAP_WPMU_OptionsPageExt')) add_action('admin_menu', 'NS_SNAutoPoster_apx');
460
 
461
  add_action('admin_init', 'nxs_adminInitFunc');
462
+ add_action( 'admin_enqueue_scripts', 'nxssnap_enqueue_scripts' );
 
463
  add_action('wp_ajax_nxs_snap_aj', 'nxs_snapAjax');
464
 
465
  add_action('wp_ajax_nxs_clLgo', 'nxs_clLgo_ajax');
469
  add_action('wp_ajax_nxs_getExpSettings', 'nxs_getExpSettings_ajax');
470
  add_action('wp_ajax_nxs_hideTip', 'nxs_hideTip_ajax');
471
 
472
+ add_action( 'http_api_curl','nxs_altCurlProxy', 15, 2);
473
+
474
+ //add_action( 'show_user_profile', 'nxsUserProfileSettings' );
475
+ //add_action( 'edit_user_profile', 'nxsUserProfileSettings' );
476
+ //add_action( 'profile_update', 'nxsUserProfileSettingsSave' );
477
+
478
+ if (!empty($suOptions['yo'])) {
479
+ //##Show
480
+ add_action( 'show_user_profile', 'nxs_show_yo_profile_fields' );
481
+ add_action( 'edit_user_profile', 'nxs_show_yo_profile_fields' );
482
+ //##Edit/Save
483
+ add_action( 'personal_options_update', 'nxs_save_yo_profile_fields' );
484
+ add_action( 'edit_user_profile_update', 'nxs_save_yo_profile_fields' );
485
+ }
486
 
487
  if ($isO || $isS) {
488
+ //add_action( 'transition_post_status', 'nxs_snapLogPublishTo', 100, 3 );
489
 
490
  foreach ($nxs_snapAvNts as $avNt) { add_action('ns_doPublishTo'.$avNt['code'], 'nxs_doPublishTo'.$avNt['code'], 1, 2); }
491
  foreach ($nxs_snapAvNts as $avNt) { add_action('wp_ajax_rePostTo'.$avNt['code'], 'nxs_rePostTo'.$avNt['code'].'_ajax'); }
492
 
493
  //## Add AJAX Calls for Test and Repost
494
+
 
 
 
 
495
  add_action('wp_ajax_SetRpstAll' , 'nxs_SetRpstAll_ajax');
496
  add_action('wp_ajax_nxs_delPostSettings' , 'nxs_delPostSettings_ajax');
497
  add_action('wp_ajax_nsDN', 'ns_delNT_ajax');
501
  add_action('admin_menu', 'NS_SNAutoPoster_ap');
502
  add_action('admin_init', 'nxs_adminInitFunc2');
503
  //## Initialize options on plugin activation
504
+ // $myrelpath = preg_replace( '/.*wp-content.plugins./', '', __FILE__ ); prr($myrelpath); add_action("activate_".$myrelpath, array(&$plgn_NS_SNAutoPoster, 'init'));
 
505
 
506
  //## Add/Change meta on Save
507
  add_action('edit_post', array($plgn_NS_SNAutoPoster, 'NS_SNAP_SavePostMetaTags'));
508
  add_action('publish_post', array($plgn_NS_SNAutoPoster, 'NS_SNAP_SavePostMetaTags'));
509
  add_action('save_post', array($plgn_NS_SNAutoPoster, 'NS_SNAP_SavePostMetaTags'));
510
  // add_action('edit_page_form', array($plgn_NS_SNAutoPoster, 'NS_SNAP_SavePostMetaTags'));
511
+
512
+
513
 
514
  add_action('wp_ajax_nsAuthFBSv', 'nsAuthFBSv_ajax');
515
  //## Custom Post Types and OG tags
516
  add_filter('plugin_action_links','ns_add_settings_link', 10, 2 );
517
 
518
  //## Scedulled Publish Calls
519
+ if (!empty($suOptions['nxsOG']) && ($suOptions['nxsOG'] == 'A' || $suOptions['nxsOG'] == 'N' ) ) {
520
+ if ( strpos($_SERVER["HTTP_USER_AGENT"], "facebookexternalhit") !== false || strpos($_SERVER["HTTP_USER_AGENT"], "Facebot") !== false || strpos($_SERVER["HTTP_USER_AGENT"], "Chrome") !== false || strpos($_SERVER["HTTP_USER_AGENT"], "Google (") !== false || strpos($_SERVER["HTTP_USER_AGENT"], "LinkedInBot") !== false || strpos($_SERVER["HTTP_USER_AGENT"], "XING-contenttabreceiver") !== false || strpos($_SERVER["HTTP_USER_AGENT"], "Java/1.7.0_45") !== false) {
521
+ if (!is_admin()) @ob_start( 'nxs_ogtgCallback' );
522
+ }
523
  add_action('wp_head', 'nxs_addOGTagsPreHolder', 150);
524
  add_action('shutdown', 'nxs_end_flush_ob', 1000);
525
+ }
526
+
527
  }
528
  if ($nxs_isWPMU){
529
  if (function_exists('nxssnapmu_columns_head')) add_filter('wpmu_blogs_columns', 'nxssnapmu_columns_head');
533
  if (function_exists('nxs_saveSiteSets_ajax')) add_action('wp_ajax_nxs_saveSiteSets', 'nxs_saveSiteSets_ajax');
534
  }
535
  }
536
+
537
  }
538
+
539
+
540
+ /*
541
+ function nxs_SNAP_PostOnUpdate($postID) {
542
+ delete_post_meta($postID, 'snap_isAutoPosted');
543
+ $post = get_post($postID);
544
+ nxs_snapPublishTo($post);
545
+ }
546
+ add_action('save_post', 'nxs_SNAP_PostOnUpdate');
547
+ */
548
  ?>
img/5p-bg.png ADDED
Binary file
img/5p16.png ADDED
Binary file
img/SNAP_Logo_2014.png ADDED
Binary file
img/arrow_r_green_c1.png ADDED
Binary file
img/cbch.png ADDED
Binary file
img/cbrb.png ADDED
Binary file
img/cbun.png ADDED
Binary file
img/direct-nxsapi-usage-Facebook.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*#############################################################################
4
+ Project Name: NextScripts Social Networks AutoPoster
5
+ Project URL: http://www.nextscripts.com/snap-api/
6
+ Description: Automatically posts to all your Social Networks
7
+ Author: NextScripts, Inc
8
+ Version: 1.0.0.Beta 19 (Jan 10, 2014)
9
+ Author URL: http://www.nextscripts.com
10
+ Copyright 2012-2014 NextScripts, Inc
11
+ #############################################################################*/
12
+
13
+ require_once "nxs-api/nxs-api.php"; require_once "nxs-api/nxs-http.php"; require_once "nxs-functions.php";
14
+
15
+ $email = 'YourEmail@gmail.com';
16
+ $pass = 'YourPassword';
17
+ $msg = 'Post this to Google Plus!';
18
+ $pageID = '109888164682746252347';
19
+ $lnk = 'http://www.nextscripts.com/social-networks-auto-poster-for-wp-multiple-accounts';
20
+
21
+ $email = 'vhrenov6@gmail.com';
22
+ $pass = '53456FT9';
23
+ $pageID = '';
24
+
25
+ //## Post simple message to account.
26
+
27
+ $nt = new nxsAPI_GP();
28
+ $loginError = $nt->connect($email, $pass);
29
+ if (!$loginError)
30
+ {
31
+ $result = $nt -> postGP($msg);
32
+ }
33
+ else echo $loginError;
34
+
35
+ if (!empty($result) && is_array($result) && !empty($result['post_url']))
36
+ echo '<a target="_blank" href="'.$result['post_url'].'">New Post</a>'; else echo "<pre>".print_r($result, true)."</pre>";
37
+
38
+ die();
39
+
40
+ //## Post simple message to page.
41
+ $nt = new nxsAPI_GP();
42
+ $loginError = $nt->connect($email, $pass);
43
+ if (!$loginError)
44
+ {
45
+ $result = $nt -> postGP($msg, '', $pageID);
46
+ }
47
+ else echo $loginError;
48
+
49
+ if (!empty($result) && is_array($result) && !empty($result['post_url']))
50
+ echo '<a target="_blank" href="'.$result['post_url'].'">New Post</a>'; else echo "<pre>".print_r($result, true)."</pre>";
51
+
52
+ die();
53
+
54
+ //## Post link message to page.
55
+ $nt = new nxsAPI_GP();
56
+ $loginError = $nt->connect($email, $pass);
57
+ if (!$loginError)
58
+ {
59
+ $lnk = array('img'=>'http://www.nextscripts.com/imgs/nextscripts.png');
60
+ $result = $nt -> postGP($msg, $lnk, $pageID);
61
+
62
+ if (!empty($result) && is_array($result) && !empty($result['post_url']))
63
+ echo '<a target="_blank" href="'.$result['post_url'].'">New Post Link</a>'; else echo "<pre>".print_r($result, true)."</pre>";
64
+ }
65
+ else echo $loginError;
66
+
67
+ die();
68
+
69
+ //## Post to Twitter
70
+
71
+ require_once "nxs-functions.php"; require_once "inc-cl/tw.api.php";
72
+
73
+ $message = array();
74
+ $message['text'] = 'Test Post';
75
+ $message['imageURL'] = 'http://www.nextscripts.com/imgs/nextscripts.png';
76
+
77
+ $TWoptions = array();
78
+
79
+ $TWoptions['twURL'] = 'https://twitter.com/YourTWPage';
80
+ $TWoptions['twConsKey'] = 'KEY';
81
+ $TWoptions['twConsSec'] = 'SEC';
82
+ $TWoptions['twAccToken'] = 'TTT-TOK';
83
+ $TWoptions['twAccTokenSec'] = 'TOKSEC';
84
+ $TWoptions['twMsgFormat'] = '%TEXT%';
85
+ $TWoptions['attchImg'] = '1';
86
+
87
+
88
+ $ntToPost = new nxs_class_SNAP_TW();
89
+ $ret = $ntToPost->doPostToNT($TWoptions, $message);
90
+ prr($ret);
91
+
92
+ die();
img/fbPostTypesDiff6.png CHANGED
Binary file
img/icons/meta24.png ADDED
Binary file
img/icons/post24.png ADDED
Binary file
img/icons/search24.png ADDED
Binary file
img/icons/tag24.png ADDED
Binary file
img/icons/time24.png ADDED
Binary file
img/icons/type24.png ADDED
Binary file
img/icons/user24.png ADDED
Binary file
img/ig-bg.png ADDED
Binary file
img/ig16.png ADDED
Binary file
img/ig16x.png ADDED
Binary file
img/mc-bg.png ADDED
Binary file
img/mc16.png ADDED
Binary file
img/md-bg.png ADDED
Binary file
img/md16.png ADDED
Binary file
img/ok-bg.png ADDED
Binary file
img/ok16.png ADDED
Binary file
img/refresh16.png CHANGED
Binary file
img/snap-icon.png ADDED
Binary file
img/sx-bg.png ADDED
Binary file
img/tg-bg.png ADDED
Binary file
img/tg16.png ADDED
Binary file
img/wb-bg.png ADDED
Binary file
img/wb16.png ADDED
Binary file
img/yo-bg.png ADDED
Binary file
img/yo16.png ADDED
Binary file
inc-cl/5p.api.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //## NextScripts 500px Connection Class
3
+
4
+ /*
5
+ 1. Options
6
+
7
+ nName - Nickname of the account [Optional] (Presentation purposes only - No affect on functionality)
8
+ postType - A or T - "Attached link" or "Text"
9
+
10
+ 2. Post Info
11
+
12
+ url
13
+ text
14
+
15
+ */
16
+ $nxs_snapAPINts[] = array('code'=>'5P', 'lcode'=>'5p', 'name'=>'500px');
17
+
18
+ if (!class_exists("nxs_class_SNAP_5P")) { class nxs_class_SNAP_5P {
19
+
20
+ var $ntCode = 'XI';
21
+ var $ntLCode = 'xi';
22
+
23
+ function doPost($options, $message){ if (!is_array($options)) return false; $out = array(); // return false;
24
+ foreach ($options as $ii=>$ntOpts) $out[$ii] = $this->doPostToNT($ntOpts, $message);
25
+ return $out;
26
+ }
27
+
28
+ function doPostToNT($options, $message){ global $nxs_urlLen; $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>'');
29
+ //## Check settings
30
+ if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
31
+ if (!isset($options['accessToken']) || trim($options['accessToken'])=='') { $badOut['Error'] = 'Not Authorized'; return $badOut; }
32
+ if (empty($options['imgSize'])) $options['imgSize'] = '';
33
+ //## Format Post
34
+ if (!empty($message['pText'])) $msg = $message['pText']; else $msg = nxs_doFormatMsg($options['msgFormat'], $message);
35
+ if (!empty($message['pTitle'])) $msgT = $message['pTitle']; else $msgT = nxs_doFormatMsg($options['msgTFormat'], $message);
36
+ if ($options['inclTags']=='1') $tags = nsTrnc($message['tags'], 195, ',', ''); else $tags = ''; if (empty($options['imgSize'])) $options['imgSize'] = 'original';
37
+ //## Make Post
38
+ if (isset($message['imageURL'])) $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); else $imgURL = ''; // $postType = $options['postType'];
39
+
40
+ $tum_oauth = new nxs_OAuthBaseCl($options['appKey'], $options['appSec'], $options['accessToken'], $options['accessTokenSec']);
41
+ $tum_oauth->baseURL = 'https://api.500px.com';
42
+
43
+ $msg = str_replace('&amp;#039;', "'", $msg); $msg = str_replace('&#039;', "'", $msg); $msg = str_replace('#039;', "'", $msg); $msg = str_replace('#039', "'", $msg);
44
+ $msg = str_replace('&amp;#8217;', "'", $msg); $msg = str_replace('&#8217;', "'", $msg); $msg = str_replace('#8217;', "'", $msg); $msg = str_replace('#8217', "'", $msg);
45
+ $msg = str_replace('&amp;#8220;', '"', $msg); $msg = str_replace('&#8220;', '"', $msg); $msg = str_replace('#8220;', '"', $msg); $msg = str_replace('#8220', "'", $msg);
46
+ $msg = str_replace('&amp;#8221;', '"', $msg); $msg = str_replace('&#8221;', '"', $msg); $msg = str_replace('#8221;', '"', $msg); $msg = str_replace('#8221', "'", $msg);
47
+ $msg = str_replace('&amp;#8212;', '-', $msg); $msg = str_replace('&#8212;', '-', $msg); $msg = str_replace('#8212;', '-', $msg); $msg = str_replace('#8212', "-", $msg);
48
+
49
+
50
+ $postArr = array('name' =>$msgT, 'description' =>$msg, 'tags'=>$tags, 'privacy'=>'0', 'category'=>$options['cat']);
51
+ $postinfo = $tum_oauth->makeReq('https://api.500px.com/v1/photos', $postArr, 'POST');// prr($options['appAppUserID']); prr($postArr); prr($postinfo, 'POSTINFO');
52
+ $uplk = $postinfo['upload_key']; $upid = $postinfo['photo']['id'];
53
+ $url = 'https://upload.500px.com/v1/upload'; $fields = array( 'photo_id' => $upid, 'upload_key' => $uplk, 'consumer_key' => $options['appKey'], 'access_key' => $options['accessToken'] ); $imgRes = nxs_curlUploadImg($imgURL, $url, $fields, 'file');
54
+ if (!empty($imgRes) && !empty($imgRes['body']) && stripos($imgRes['body'], '"error":"None')!==false) {
55
+ /*/## Gallery
56
+ $uinfo = $tum_oauth->makeReq('https://api.500px.com/v1/users/'.$options['appAppUserID'].'/galleries/'.$options['gal'], '');
57
+ if (!empty($uinfo) && !empty($uinfo['gallery'])) $gid = $uinfo['gallery']['id']; $postGArr = json_encode(array('add' =>array('after'=>array('id'=>'161754155'),'photos'=>array($upid)))); prr($postGArr); // {"add":{"photos":[161777661]}}
58
+ $postGinfo = $tum_oauth->makeReq('https://api.500px.com/v1/users/'.$options['appAppUserID'].'/galleries/'.$gid.'/items', $postGArr, 'PUT'); prr($postGinfo);
59
+ */
60
+ return array('postID'=>$upid, 'isPosted'=>1, 'postURL'=>'https://www.500px.com'.$postinfo['photo']['url'], 'pDate'=>date('Y-m-d H:i:s'));
61
+ } else $badOut['Error'] .= print_r($imgRes, true)." <br/> Code: ".print_r($postinfo, true);
62
+ return $badOut;
63
+ }
64
+
65
+ }}
66
+ ?>
inc-cl/5p.php ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //## NextScripts 500Px Connection Class
3
+ $nxs_snapAvNts[] = array('code'=>'5P', 'lcode'=>'5p', 'name'=>'500Px', 'type'=>'Image Sharing', 'ptype'=>'F', 'status'=>'A', 'desc'=>'Post images to your account');
4
+
5
+ if (!class_exists("nxs_snapClass5P")) { class nxs_snapClass5P extends nxs_snapClassNT {
6
+ var $ntInfo = array('code'=>'5P', 'lcode'=>'5p', 'name'=>'500Px', 'defNName'=>'', 'tstReq' => true, 'instrURL'=>'http://www.nextscripts.com/instructions/setup-installation-500px-social-networks-auto-poster/');
7
+ //#### Show Common Settings
8
+ function showGenNTSettings($ntOpts){ $this->nt = $ntOpts; $this->showNTGroup(); }
9
+ //#### Show NEW Settings Page
10
+ function showNewNTSettings($ii){ $defO = array('nName'=>'', 'do'=>'1', 'appKey'=>'', 'appSec'=>'', 'inclTags'=>'1', 'cat'=>0, 'gal'=>'', 'msgTFormat'=>"%TITLE%", 'msgFormat'=>"%EXCERPT%\r\n\r\n%URL%", 'imgSize'=>'original'); $this->showGNewNTSettings($ii, $defO); }
11
+ //#### Show Unit Settings
12
+ function checkIfSetupFinished($options) { return !empty($options['appAppUserID']) && !empty($options['accessToken']); }
13
+ public function doAuth() { $ntInfo = $this->ntInfo; global $nxs_snapSetPgURL; if (isset($_GET['acc'])) $options = $this->nt[$_GET['acc']];
14
+ if ( isset($_GET['auth']) && $_GET['auth']==$ntInfo['lcode']){
15
+ $consumer_key = $options['appKey']; $consumer_secret = $options['appSec']; $callback_url = $nxs_snapSetPgURL."&auth=".$ntInfo['lcode']."a&acc=".$_GET['acc'];
16
+ $tum_oauth = new nxs_OAuthBaseCl($consumer_key, $consumer_secret); $tum_oauth->baseURL = 'https://api.500px.com'; $tum_oauth->request_token_path = '/v1/oauth/request_token';
17
+ $request_token = $tum_oauth->getReqToken($callback_url); $options['oAuthToken'] = $request_token['oauth_token']; $options['oAuthTokenSecret'] = $request_token['oauth_token_secret'];
18
+ prr($tum_oauth); prr($options);
19
+ switch ($tum_oauth->http_code) { case 201: case 200: $url = 'https://api.500px.com/v1/oauth/authorize?oauth_token='.$options['oAuthToken']; nxs_save_glbNtwrks($ntInfo['lcode'],$_GET['acc'],$options,'*');
20
+ echo '<br/><br/>All good?! Redirecting ..... <script type="text/javascript">window.location = "'.$url.'"</script>'; break;
21
+ default: echo '<br/><b style="color:red">Could not connect to 500Px. Refresh the page or try again later.</b>'; die();
22
+ } die();
23
+ }
24
+ if ( isset($_GET['auth']) && $_GET['auth']==$ntInfo['lcode'].'a'){ $consumer_key = $options['appKey']; $consumer_secret = $options['appSec'];
25
+ $tum_oauth = new nxs_OAuthBaseCl($consumer_key, $consumer_secret, $options['oAuthToken'], $options['oAuthTokenSecret']); //prr($tum_oauth);
26
+ $tum_oauth->baseURL = 'https://api.500px.com'; $tum_oauth->access_token_path = '/v1/oauth/access_token'; $access_token = $tum_oauth->getAccToken($_GET['oauth_verifier']); prr($access_token);
27
+ $options['accessToken'] = $access_token['oauth_token']; $options['accessTokenSec'] = $access_token['oauth_token_secret'];
28
+ $tum_oauth = new nxs_OAuthBaseCl($consumer_key, $consumer_secret, $options['accessToken'], $options['accessTokenSec']);
29
+ $uinfo = $tum_oauth->makeReq('https://api.500px.com/v1/users', ''); prr($uinfo);
30
+ if (is_array($uinfo) && isset($uinfo['user']) && is_array($uinfo['user'])) { $uinfo = $uinfo['user'];
31
+ $options['appAppUserName'] = $uinfo['username']."(".$uinfo['fullname'].")"; $options['appAppUserID'] = $uinfo['id'];
32
+ } nxs_save_glbNtwrks($ntInfo['lcode'],$_GET['acc'],$options,'*'); //prr($options); die();
33
+ if (!empty($options['appAppUserID'])) { echo '<br/><br/>All good?! Redirecting ..... <script type="text/javascript">window.location = "'.$nxs_snapSetPgURL.'"</script>'; die();}
34
+ else die("<span style='color:red;'>ERROR: Authorization Error: <span style='color:darkred; font-weight: bold;'>".print_r($uinfo, true)."</span></span>");
35
+ }
36
+ }
37
+ function pCats() { return '<option value="0">Uncategorized</option><option value="10">Abstract</option><option value="11">Animals</option><option value="5">Black and White</option><option value="1">Celebrities</option><option value="9">City and Architecture</option><option value="15">Commercial</option><option value="16">Concert</option><option value="20">Family</option><option value="14">Fashion</option><option value="2">Film</option><option value="24">Fine Art</option><option value="23">Food</option><option value="3">Journalism</option><option value="8">Landscapes</option><option value="12">Macro</option><option value="18">Nature</option><option value="4">Nude</option><option value="7">People</option><option value="19">Performing Arts</option><option value="17">Sport</option><option value="6">Still Life</option><option value="21">Street</option><option value="26">Transportation</option><option value="13">Travel</option><option value="22">Underwater</option><option value="27">Urban Exploration</option><option value="25">Wedding</option>'; }
38
+
39
+
40
+ function accTab($ii, $options, $isNew=false){ global $nxs_snapSetPgURL; $ntInfo = $this->ntInfo; $nt = $ntInfo['lcode']; $this->elemKeySecret($ii,'500Px Consumer Key','500Px Consumer Secret', $options['appKey'], $options['appSec'],'appKey','appSec','https://500px.com/settings/applications'); ?>
41
+ <br/><?php $this->elemTitleFormat($ii,'Image Title Format','msgTFormat',$options['msgTFormat']); $this->elemMsgFormat($ii,'Image Description Format','msgFormat',$options['msgFormat']); ?>
42
+ <div style="margin-bottom: 20px;margin-top: 5px;"><input value="1" type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][inclTags]" <?php if ((int)$options['inclTags'] == 1) echo "checked"; ?> />
43
+ <strong><?php _e('Post with tags', 'social-networks-auto-poster-facebook-twitter-g'); ?></strong> <?php _e('Tags from the blogpost will be auto-posted to '.$ntInfo['name'], 'social-networks-auto-poster-facebook-twitter-g'); ?>
44
+ </div>
45
+ <?php /* Gallery ?>
46
+ <div>
47
+ <div style="width:100%;"><b style="font-size: 14px;"><?php _e('Gallery', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</b> </div><input name="<?php echo $nt; ?>[<?php echo $ii; ?>][gal]" style="width: 50%;" value="<?php echo htmlentities($options['gal'], ENT_COMPAT, "UTF-8"); ?>" />
48
+ </div><br/>
49
+ <?php */ ?>
50
+ <div>
51
+
52
+ <b style="font-size: 14px;"><?php _e('Category', 'social-networks-auto-poster-facebook-twitter-g'); ?>:&nbsp;</b>
53
+ <select name="5p[<?php echo $ii; ?>][cat]"><option value="error" selected="selected" disabled="">Select default Category</option>
54
+ <?php $suCats = $this->pCats(); if (isset($options['cat']) && $options['cat']!='') $suCats = str_replace('"'.$options['cat'].'"', '"'.$options['cat'].'" selected="selected"', $suCats); echo $suCats; ?>
55
+ </select>
56
+ </div>
57
+
58
+
59
+ <br/><br/>
60
+ <?php if($options['appKey']=='') { ?>
61
+ <b><?php _e('Authorize Your '.$ntInfo['name'].' Account', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> <?php _e('Please click "Update Settings" to be able to Authorize your account.', 'social-networks-auto-poster-facebook-twitter-g');
62
+ } else { if(isset($options['appAppUserID']) && $options['appAppUserID']>0) {
63
+ _e('Your '.$ntInfo['name'].' Account has been authorized.', 'social-networks-auto-poster-facebook-twitter-g'); ?> User ID: <?php _e(apply_filters('format_to_edit', htmlentities($options['appAppUserID'].' - '.$options['appAppUserName'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>.
64
+ <?php _e('You can', 'social-networks-auto-poster-facebook-twitter-g'); ?> Re- <?php } ?>
65
+ <a href="<?php echo $nxs_snapSetPgURL;?>&auth=<?php echo $nt; ?>&acc=<?php echo $ii; ?>">Authorize Your <?php echo $ntInfo['name']; ?> Account</a>
66
+ <?php if (!isset($options['appAppUserID']) || $options['appAppUserID']<1) { ?> <div class="blnkg">&lt;=== <?php _e('Authorize your account', 'social-networks-auto-poster-facebook-twitter-g'); ?> ===</div> <?php }
67
+ } ?><br/><br/> <?php
68
+ }
69
+ function advTab($ii, $options){}
70
+ //#### Set Unit Settings from POST
71
+ function setNTSettings($post, $options){
72
+ foreach ($post as $ii => $pval){
73
+ if (!empty($pval['appKey']) && !empty($pval['appKey'])){ if (!isset($options[$ii])) $options[$ii] = array(); $options[$ii] = $this->saveCommonNTSettings($pval,$options[$ii]);
74
+ //## Uniqe Items
75
+ if (isset($pval['inclTags'])) $options[$ii]['inclTags'] = trim($pval['inclTags']); else $options[$ii]['inclTags'] = 0;
76
+ if (isset($pval['cat'])) $options[$ii]['cat'] = $pval['cat']; else $options[$ii]['cat'] = 0;
77
+ if (isset($pval['gal'])) $options[$ii]['gal'] = trim($pval['gal']); else $options[$ii]['gal'] = '';
78
+ } elseif ( count($pval)==1 ) if (isset($pval['do'])) $options[$ii]['do'] = $pval['do']; else $options[$ii]['do'] = 0;
79
+ } return $options;
80
+ }
81
+
82
+ //#### Show Post->Edit Meta Box Settings
83
+
84
+ function showEdPostNTSettings($ntOpts, $post){ $post_id = $post->ID; $nt = $this->ntInfo['lcode']; $ntU = $this->ntInfo['code'];
85
+ foreach($ntOpts as $ii=>$ntOpt) { $isFin = $this->checkIfSetupFinished($ntOpt); if (!$isFin) continue;
86
+ $pMeta = maybe_unserialize(get_post_meta($post_id, 'snap'.$ntU, true)); if (is_array($pMeta) && !empty($pMeta[$ii])) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
87
+
88
+ if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = ''; if (empty($ntOpt['urlToUse'])) $ntOpt['urlToUse'] = ''; $postType = isset($ntOpt['postType'])?$ntOpt['postType']:'';
89
+ $msgFormat = !empty($ntOpt['msgFormat'])?htmlentities($ntOpt['msgFormat'], ENT_COMPAT, "UTF-8"):''; $msgTFormat = !empty($ntOpt['msgTFormat'])?htmlentities($ntOpt['msgTFormat'], ENT_COMPAT, "UTF-8"):'';
90
+ $imgToUse = $ntOpt['imgToUse']; $urlToUse = $ntOpt['urlToUse']; $ntOpt['ii']=$ii;
91
+
92
+ $this->nxs_tmpltAddPostMeta($post, $ntOpt, $pMeta);
93
+
94
+ $this->elemEdTitleFormat($ii, __('Title Format:', 'social-networks-auto-poster-facebook-twitter-g'),$msgTFormat); $this->elemEdMsgFormat($ii, __('Description Format:', 'social-networks-auto-poster-facebook-twitter-g'),$msgFormat);
95
+
96
+ ?>
97
+ <?php /* Gallery ?>
98
+ <tr class="<?php echo 'nxstbldo'.strtoupper($nt).$ii; ?>"><th scope="row" style="text-align:right; width:150px; vertical-align:top; padding-top: 0px; padding-right:10px;"> <?php _e('Gallery', 'social-networks-auto-poster-facebook-twitter-g'); ?> <br/></th><td>
99
+ <input name="<?php echo $nt; ?>[<?php echo $ii; ?>][gal]" style="width: 50%;" value="<?php echo htmlentities($ntOpt['gal'], ENT_COMPAT, "UTF-8"); ?>" />
100
+ </td></tr>
101
+ <?php */ ?>
102
+ <tr class="nxstbldo <?php echo 'nxstbldo'.strtoupper($nt).$ii; ?>"><th scope="row" style="text-align:right; width:150px; vertical-align:top; padding-top: 0px; padding-right:10px;"> <?php _e('Category', 'social-networks-auto-poster-facebook-twitter-g'); ?> <br/></th><td>
103
+ <select name="5p[<?php echo $ii; ?>][cat]"><option value="error" selected="selected" disabled=""><?php _e('Select Category', 'social-networks-auto-poster-facebook-twitter-g'); ?></option>
104
+ <?php $suCats = $this->pCats(); if (isset($ntOpt['cat']) && $ntOpt['cat']!='') $suCats = str_replace('"'.$ntOpt['cat'].'"', '"'.$ntOpt['cat'].'" selected="selected"', $suCats); echo $suCats; ?>
105
+ </select>
106
+ </td></tr>
107
+ <?php
108
+ /* ## Select Image & URL ## */ nxs_showURLToUseDlg($nt, $ii, $urlToUse); $this->nxs_tmpltAddPostMetaEnd($ii);
109
+ }
110
+ }
111
+
112
+ //#### Save Meta Tags to the Post
113
+ function adjMetaOpt($optMt, $pMeta){ $optMt = $this->adjMetaOptG($optMt, $pMeta);
114
+ if (!empty($pMeta['cat'])) $optMt['cat'] = $pMeta['cat'];
115
+ if (!empty($pMeta['gal'])) $optMt['gal'] = $pMeta['gal'];
116
+ return $optMt;
117
+ }
118
+
119
+ function adjPublishWP(&$options, &$message, $postID){ //prr($message); prr($options);
120
+ if (!empty($postID)) { $postType = $options['postType']; if (trim($options['imgToUse'])!='') $imgURL = $options['imgToUse']; else $imgURL = nxs_getPostImage($postID, !empty($options['wpImgSize'])?$options['wpImgSize']:'full');
121
+ if (preg_match("/noImg.\.png/i", $imgURL)) { $imgURL = ''; $isNoImg = true; }
122
+ $message['imageURL'] = $imgURL;
123
+ }
124
+ }
125
+
126
+ }}
127
+
128
+ if (!function_exists("nxs_doPublishTo5P")) { function nxs_doPublishTo5P($postID, $options){ if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true)); $cl = new nxs_snapClass5P(); $cl->nt[$options['ii']] = $options; return $cl->publishWP($options['ii'], $postID); }}
129
+
130
+ ?>
inc-cl/ap.api.php CHANGED
@@ -33,7 +33,7 @@ if (!class_exists("nxs_class_SNAP_AP")) { class nxs_class_SNAP_AP {
33
  }
34
  function createFile($imgURL, $auth) { $data = array();
35
  $remImgURL = urldecode($imgURL); $urlParced = pathinfo($remImgURL); $remImgURLFilename = $urlParced['basename'];
36
- $imgData = wp_remote_get($remImgURL); if (is_wp_error($imgData)) { $badOut['Error'] = print_r($imgData, true)." - ERROR"; return $badOut; }
37
  $imgData = $imgData['body'];
38
  $tmp=array_search('uri', @array_flip(stream_get_meta_data($GLOBALS[mt_rand()]=tmpfile())));
39
  if (!is_writable($tmp)) return "Your temporary folder or file (file - ".$tmp.") is not witable. Can't upload image to App.Net";
@@ -46,10 +46,9 @@ if (!class_exists("nxs_class_SNAP_AP")) { class nxs_class_SNAP_AP {
46
  if ($test && array_key_exists('mime', $test)) { $data['kind'] = 'image'; if (!$mimeType) $mimeType = $test['mime']; } else $data['kind'] = 'other';
47
  }
48
  if (!$mimeType && function_exists('finfo_open') ) { $finfo = finfo_open(FILEINFO_MIME_TYPE); $mimeType = finfo_file($finfo, $tmp); finfo_close($finfo); }
49
- if (!$mimeType) return 'Unable to determine mime type of file, try specifying it explicitly'; $data['type'] = "com.nextscripts.photos";
50
- $data['content'] = "@$tmp;type=$mimeType";
51
  $url = "https://alpha-api.app.net/stream/0/files?access_token=".$auth;
52
-
53
  $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
54
  global $nxs_skipSSLCheck; if ($nxs_skipSSLCheck===true) curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
55
  curl_setopt($ch, CURLOPT_POSTFIELDS, $data); $response = curl_exec($ch); $errmsg = curl_error($ch); curl_close($ch); //prr($response);
@@ -61,20 +60,19 @@ if (!class_exists("nxs_class_SNAP_AP")) { class nxs_class_SNAP_AP {
61
  function doPostToNT($options, $message){ global $nxs_urlLen; $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>'');
62
  //## Check settings
63
  if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
64
- if (!isset($options['apAppAuthToken']) || trim($options['apAppAuthToken'])=='') { $badOut['Error'] = 'Not Authorized'; return $badOut; }
65
  if (empty($options['imgSize'])) $options['imgSize'] = '';
66
  //## Format Post
67
- if (!empty($message['pText'])) $text = $message['pText']; else $text = nxs_doFormatMsg($options['apTextFormat'], $message); $text = nsTrnc($text, 256);
68
  //## Make Post
69
  if (isset($message['imageURL'])) $img = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); else $img = '';
70
- if ($options['attchImg']!=false && $img!='') $remoteImg = $this->createFile($img, $options['apAppAuthToken']); $ann = array();
71
  if (is_array($remoteImg)) {
72
  $ann[] = array("type"=>"net.app.core.oembed", "value"=> array("+net.app.core.file"=>array("file_id" => $remoteImg['id'], "file_token" => $remoteImg['file_token'], "format"=> "oembed")));
73
  }
74
- $url = "https://alpha-api.app.net/stream/0/posts?include_post_annotations=1&access_token=".$options['apAppAuthToken'];
75
- $flds = array('text' => $text, 'annotations' => $ann); $flds = json_encode($flds); $hdrsArr = array('Content-Type' => 'application/json');
76
- $response = wp_remote_post( $url, array( 'method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds));
77
- if (is_wp_error($response)) { $badOut['Error'] = print_r($response, true)." - ERROR"; return $badOut; }
78
  $response = json_decode($response['body'], true); //prr($response); die();
79
  //## Check Result
80
  if (!is_array($response) || !isset($response['meta']) || $response['meta']['code']!='200' || $response['data']['canonical_url']=='') { $badOut['Error'] = print_r($response, true)." - ERROR"; return $badOut; }
33
  }
34
  function createFile($imgURL, $auth) { $data = array();
35
  $remImgURL = urldecode($imgURL); $urlParced = pathinfo($remImgURL); $remImgURLFilename = $urlParced['basename'];
36
+ $imgData = nxs_remote_get($remImgURL); if (is_nxs_error($imgData)) { $badOut['Error'] = print_r($imgData, true)." - ERROR"; return $badOut; }
37
  $imgData = $imgData['body'];
38
  $tmp=array_search('uri', @array_flip(stream_get_meta_data($GLOBALS[mt_rand()]=tmpfile())));
39
  if (!is_writable($tmp)) return "Your temporary folder or file (file - ".$tmp.") is not witable. Can't upload image to App.Net";
46
  if ($test && array_key_exists('mime', $test)) { $data['kind'] = 'image'; if (!$mimeType) $mimeType = $test['mime']; } else $data['kind'] = 'other';
47
  }
48
  if (!$mimeType && function_exists('finfo_open') ) { $finfo = finfo_open(FILEINFO_MIME_TYPE); $mimeType = finfo_file($finfo, $tmp); finfo_close($finfo); }
49
+ if (!$mimeType) return 'Unable to determine mime type of file, try specifying it explicitly'; $data['type'] = "com.nextscripts.photos";
50
+ if (function_exists('curl_file_create')) $data['content'] = curl_file_create($tmp,$mimeType); else $data['content'] = "@$tmp;type=$mimeType";
51
  $url = "https://alpha-api.app.net/stream/0/files?access_token=".$auth;
 
52
  $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
53
  global $nxs_skipSSLCheck; if ($nxs_skipSSLCheck===true) curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
54
  curl_setopt($ch, CURLOPT_POSTFIELDS, $data); $response = curl_exec($ch); $errmsg = curl_error($ch); curl_close($ch); //prr($response);
60
  function doPostToNT($options, $message){ global $nxs_urlLen; $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>'');
61
  //## Check settings
62
  if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
63
+ if (!isset($options['accessToken']) || trim($options['accessToken'])=='') { $badOut['Error'] = 'Not Authorized'; return $badOut; }
64
  if (empty($options['imgSize'])) $options['imgSize'] = '';
65
  //## Format Post
66
+ if (!empty($message['pText'])) $text = $message['pText']; else $text = nxs_doFormatMsg($options['msgFormat'], $message); $text = nsTrnc($text, 256);
67
  //## Make Post
68
  if (isset($message['imageURL'])) $img = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); else $img = '';
69
+ if ($options['attchImg']!=false && $img!='') $remoteImg = $this->createFile($img, $options['accessToken']); $ann = array();
70
  if (is_array($remoteImg)) {
71
  $ann[] = array("type"=>"net.app.core.oembed", "value"=> array("+net.app.core.file"=>array("file_id" => $remoteImg['id'], "file_token" => $remoteImg['file_token'], "format"=> "oembed")));
72
  }
73
+ $url = "https://alpha-api.app.net/stream/0/posts?include_post_annotations=1&access_token=".$options['accessToken'];
74
+ $flds = array('text' => $text, 'annotations' => $ann); $flds = json_encode($flds); $hdrsArr = array('Content-Type' => 'application/json'); $advSet = nxs_mkRemOptsArr($hdrsArr,'',$flds); $response = nxs_remote_post($url, $advSet);
75
+ if (is_nxs_error($response)) { $badOut['Error'] = print_r($response, true)." - ERROR"; return $badOut; }
 
76
  $response = json_decode($response['body'], true); //prr($response); die();
77
  //## Check Result
78
  if (!is_array($response) || !isset($response['meta']) || $response['meta']['code']!='200' || $response['data']['canonical_url']=='') { $badOut['Error'] = print_r($response, true)." - ERROR"; return $badOut; }
inc-cl/ap.php CHANGED
@@ -1,258 +1,105 @@
1
  <?php
2
  //## NextScripts App.net Connection Class
3
- $nxs_snapAvNts[] = array('code'=>'AP', 'lcode'=>'ap', 'name'=>'App.net');
4
 
5
- if (!class_exists("nxs_snapClassAP")) { class nxs_snapClassAP { var $ntInfo = array('code'=>'AP', 'lcode'=>'ap', 'name'=>'App.Net', 'defNName'=>'', 'tstReq' => true);
 
 
 
 
 
 
 
 
 
 
6
  //#### Show Common Settings
7
- function showGenNTSettings($ntOpts){ global $nxs_plurl, $nxs_snapSetPgURL, $nxs_gOptions; $ntInfo = $this->ntInfo;
8
- if ( isset($_GET['code']) && $_GET['code']!='' && (isset($_GET['state']) && stripos($_GET['state'], 'ap-')!==false) ){ $at = $_GET['code']; $to = explode('-', $_GET['state']); $_GET['acc'] = $to[1];
 
 
 
 
 
9
  echo "-= This is normal technical authorization info that will dissapear (Unless you get some errors) =- <br/><br/><br/>";
10
- $fbo = $ntOpts[$_GET['acc']]; $wprg = array(); $response = wp_remote_get('https://graph.facebook.com/nextscripts', $wprg);
11
  echo $nxs_snapSetPgURL.'&auth=ap&acc='.$_GET['acc']."||"; if(stripos($nxs_snapSetPgURL, 'page=NextScripts_SNAP.php')===false) { $newURL = explode('?', $nxs_snapSetPgURL); $nxs_snapSetPgURL = $newURL[0]; }
12
- 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; }
13
- if (isset($fbo['appID'])){ echo "-="; prr($fbo);
14
- $wprg['body'] = array('client_id'=>$fbo['appID'], 'client_secret'=>$fbo['appSec'], 'grant_type'=>'authorization_code', 'redirect_uri'=>$nxs_snapSetPgURL, 'state'=>'ap-'.$_GET['acc'], 'code'=>$at); prr($wprg);
15
- $response = wp_remote_post('https://account.app.net/oauth/access_token', $wprg);
16
  if ( (is_object($response) && (isset($response->errors))) || (is_array($response) && stripos($response['body'],'"error":')!==false )) { prr($response); die(); }
17
- $params = json_decode($response['body'], true); $fbo['apAppAuthToken'] = $params['access_token']; if ($params['user_id']>0) { $fbo['appAppUserID'] = $params['user_id']; $fbo['appAppUserName'] = $params['username']; }
18
- if ($params['user_id']>0) { if (function_exists('get_option')) $nxs_gOptions = get_option('NS_SNAutoPoster'); if(!empty($nxs_gOptions)) {
19
- $nxs_gOptions['ap'][$_GET['acc']] = $fbo; nxs_settings_save($nxs_gOptions); } ?><script type="text/javascript">window.location = "<?php echo $nxs_snapSetPgURL; ?>"</script>
20
  <?php } die(); }
21
  }
22
- ?>
23
- <div class="nxs_box">
24
- <div class="nxs_box_header">
25
- <div class="nsx_iconedTitle" style="margin-bottom:1px;background-image:url(<?php echo $nxs_plurl;?>img/<?php echo $ntInfo['lcode']; ?>16.png);"><?php echo $ntInfo['name']; ?>
26
- <?php $cbo = count($ntOpts); ?>
27
- <?php if ($cbo>1){ ?><div class="nsBigText"><?php echo "(".($cbo=='0'?'No':$cbo)." "; _e('accounts', 'social-networks-auto-poster-facebook-twitter-g'); echo ")"; ?></div><?php } ?>
28
- </div>
29
- </div>
30
- <div class="nxs_box_inside">
31
- <?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = 'App.Net';
32
- if (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='') $pbo[$ntInfo['lcode'].'OK'] = (isset($pbo['appAppUserID']) && $pbo['appAppUserID']>1)?'1':'';
33
- ?>
34
- <p style="margin:0px;margin-left:5px;"> <img id="<?php echo $ntInfo['code'].$indx;?>LoadingImg" style="display: none;" src='<?php echo $nxs_plurl; ?>img/ajax-loader-sm.gif' />
35
-
36
- <input value="0" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" type="hidden" />
37
- <?php if ((int)$pbo['do'.$ntInfo['code']] == 1 && isset($pbo['catSel']) && (int)$pbo['catSel'] == 1) { ?> <input type="radio" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" id="rbtn<?php echo $ntInfo['lcode'].$indx; ?>" value="1" checked="checked" onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);" /> <?php } else { ?>
38
- <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1 && $pbo['catSel']!='1') echo "checked"; ?> />
39
-
40
- <?php } ?>
41
-
42
- <?php if (isset($pbo['catSel']) && (int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
43
- <?php if (isset($pbo['rpstOn']) && (int)$pbo['rpstOn'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popReActive');" onmouseover="nxs_showPopUpInfo('popReActive', event);"><?php echo "*[R]*" ?></span><?php } ?>
44
- <strong><?php _e('Auto-publish to', 'social-networks-auto-poster-facebook-twitter-g'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
45
- &nbsp;&nbsp;<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'social-networks-auto-poster-facebook-twitter-g'); ?> ==&gt;</b><?php } ?>
46
- <a id="do<?php echo $ntInfo['code'].$indx; ?>AG" href="#" onclick="doGetHideNTBlock('<?php echo $ntInfo['code'];?>' , '<?php echo $indx; ?>');return false;">[<?php _e('Show Settings', 'social-networks-auto-poster-facebook-twitter-g'); ?>]</a>&nbsp;&nbsp;
47
- <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'social-networks-auto-poster-facebook-twitter-g'); ?>]</a>
48
- </p><div id="nxsNTSetDiv<?php echo $ntInfo['code'].$indx; ?>"></div><?php //$pbo['ntInfo'] = $ntInfo; $this->showNTSettings($indx, $pbo);
49
- }?>
50
- </div>
51
- </div> <?php
52
- }
53
- //#### Show NEW Settings Page
54
- function showNewNTSettings($options){ $opts = array('nName'=>'', 'doAP'=>'1', 'apUName'=>'', 'apPageID'=>'', 'apCommID'=>'', 'postType'=>'A', 'apPass'=>''); $opts['ntInfo']= array('lcode'=>'ap'); $this->showNTSettings($options, $opts, true);}
55
- //#### Show Unit Settings
56
- function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl, $nxs_snapSetPgURL; $nt = $options['ntInfo']['lcode']; $ntU = strtoupper($nt);
57
- 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'] = '';
58
- if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; if (!isset($options['attchImg'])) $options['attchImg'] = '';
59
- if (!isset($options['appID'])) $options['appID'] = ''; if (!isset($options['appSec'])) $options['appSec'] = ''; ?>
60
- <div id="doAP<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>">
61
- <input type="hidden" value="0" id="apDoS<?php echo $ntU.$ii; ?>" />
62
- <div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/ap16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation/app-net-social-networks-auto-poster-wordpress/"><?php $nType="App.Net"; printf( __( 'Detailed %s Installation/Configuration Instructions', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?></a></div>
63
-
64
- <div style="width:100%;"><strong><?php _e('Account Nickname', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'social-networks-auto-poster-facebook-twitter-g'); ?></i> </div><input name="ap[<?php echo $ii; ?>][nName]" id="apnName<?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")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /><br/>
65
- <?php echo nxs_addQTranslSel('ap', $ii, $options['qTLng']); ?>
66
- <br/>
67
- <ul class="nsx_tabs">
68
- <li><a href="#nsx<?php echo $nt.$ii ?>_tab1"><?php _e('Account Info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li>
69
- <?php if (!$isNew) { ?> <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li> <?php } ?>
70
- </ul>
71
- <div class="nsx_tab_container"><?php /* ######################## Account Tab ####################### */ ?>
72
- <div id="nsx<?php echo $nt.$ii ?>_tab1" class="nsx_tab_content" style="background-image: url(<?php echo $nxs_plurl; ?>img/<?php echo $nt; ?>-bg.png); background-repeat: no-repeat; background-position:90% 10%;">
73
-
74
- <div style="width:100%;"><strong>App.Net Client ID:</strong> </div><input name="ap[<?php echo $ii; ?>][appID]" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['appID'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />
75
- <div style="width:100%;"><strong>App.Net Client Secret:</strong> </div><input name="ap[<?php echo $ii; ?>][appSec]" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['appSec'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /> <br/>
76
- <br/>
77
-
78
- <div id="altFormat" style="margin-left: 0px;">
79
- <div style="width:100%;"><strong id="altFormatText"><?php _e('Text Format', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> (<a href="#" id="apTextFormat<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apTextFormat<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>)
80
- </div>
81
-
82
- <textarea cols="150" rows="3" id="ap<?php echo $ii; ?>SNAPformat" name="ap[<?php echo $ii; ?>][apTextFormat]" style="width:51%;max-width: 650px;" onfocus="jQuery('#ap<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('apAPMsgFrmt<?php echo $ii; ?>');"><?php if ($isNew) _e("New post (%TITLE%) has been published on %SITENAME% - %URL%", 'social-networks-auto-poster-facebook-twitter-g'); else _e(apply_filters('format_to_edit', htmlentities($options['apTextFormat'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g'); ?></textarea>
83
-
84
- <?php nxs_doShowHint("apTextFormat".$ii); ?>
85
- </div>
86
-
87
- <p style="margin: 0px;"><input value="1" id="apAPAttch" type="checkbox" name="ap[<?php echo $ii; ?>][attchImg]" <?php if ((int)$options['attchImg'] == 1) echo "checked"; ?> /> <strong><?php _e('Attach Image to App.net Post', 'social-networks-auto-poster-facebook-twitter-g'); ?></strong></p>
88
- <br/><br/>
89
- <?php if($options['appID']=='') { ?>
90
- <b><?php _e('Authorize Your App.Net Account', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> <?php _e('Please click "Update Settings" to be able to Authorize your account.', 'social-networks-auto-poster-facebook-twitter-g'); ?>
91
- <?php } else { if(isset($options['appAppUserID']) && $options['appAppUserID']>0) { ?>
92
- <?php _e('Your App.Net Account has been authorized.', 'social-networks-auto-poster-facebook-twitter-g'); ?> User ID: <?php _e(apply_filters('format_to_edit', htmlentities($options['appAppUserID'].' - '.$options['appAppUserName'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>.
93
- <?php _e('You can', 'social-networks-auto-poster-facebook-twitter-g'); ?> Re- <?php } ?>
94
- <a href="https://account.app.net/oauth/authenticate?client_id=<?php echo trim($options['appID']);?>&response_type=code&redirect_uri=<?php echo trim(urlencode($nxs_snapSetPgURL).'&state=ap-'.$ii.'&scope=stream+write_post+follow+messages+update_profile+files');?>">Authorize Your App.Net Account</a>
95
- <?php if (!isset($options['appAppUserID']) || $options['appAppUserID']<1) { ?> <div class="blnkg">&lt;=== <?php _e('Authorize your account', 'social-networks-auto-poster-facebook-twitter-g'); ?> ===</div>
96
- <br/><br/><i> <?php _e('If you get App.Net message:', 'social-networks-auto-poster-facebook-twitter-g'); ?> <b>"Error. An error occurred. Please try again later."</b> or <b>"Error 191"</b> <?php _e('please make sure that domain name in your App.Net App matches your website domain exactly. Please note that www. and non www. versions are different domains.', 'social-networks-auto-poster-facebook-twitter-g'); ?></i> <?php }?>
97
- <?php } ?>
98
- <br/>
99
-
100
-
101
- <?php if ($isNew) { ?> <input type="hidden" name="ap[<?php echo $ii; ?>][apDoAP]" value="1" id="apDoNewAP<?php echo $ii; ?>" /> <?php } ?>
102
- <?php if (isset($options['appAppUserID']) && $options['appAppUserID']>0) { ?>
103
-
104
- <b><?php _e('Test your settings', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('AP', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?></a> <?php }
105
- ?>
106
 
107
- </div>
108
- <?php /* ######################## Tools Tab ####################### */ ?>
109
- <?php if (!$isNew) { ?><div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content">
110
- <?php nxs_showCatTagsCTFilters($nt, $ii, $options);
111
- nxs_addPostingDelaySelV3($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']);
112
- nxs_showRepostSettings($nt, $ii, $options); ?>
113
- </div> <?php } ?> <?php /* #### End of Tab #### */ ?>
114
- </div><br/> <?php /* #### End of Tabs #### */ ?>
115
 
116
- <div class="submitX nxclear" style="padding-bottom: 0px;"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'social-networks-auto-poster-facebook-twitter-g') ?>" /></div>
117
-
118
-
119
- </div><?php
 
 
 
 
 
120
  }
 
121
  //#### Set Unit Settings from POST
122
- function setNTSettings($post, $options){ $code = $this->ntInfo['code'];
123
- foreach ($post as $ii => $pval){
124
- if (isset($pval['appID']) && $pval['appID']!=''){ if (!isset($options[$ii])) $options[$ii] = array();
125
- if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']);
126
-
127
- if (isset($pval['appID'])) $options[$ii]['appID'] = trim($pval['appID']);
128
-
129
- if (isset($pval['appSec'])) $options[$ii]['appSec'] = trim($pval['appSec']);
130
- if (isset($pval['apSubReddit'])) $options[$ii]['apSubReddit'] = trim($pval['apSubReddit']);
 
 
 
 
 
131
 
132
- if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']); else $options[$ii]['catSel'] = 0;
133
- if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
134
-
135
- if (isset($pval['attchImg'])) $options[$ii]['attchImg'] = $pval['attchImg']; else $options[$ii]['attchImg'] = 0;
136
- if (isset($pval['apTextFormat'])) $options[$ii]['apTextFormat'] = trim($pval['apTextFormat']);
137
- if (isset($pval['apDoAP'])) $options[$ii]['doAP'] = $pval['apDoAP']; else $options[$ii]['doAP'] = 0;
138
 
139
- $options[$ii] = nxs_adjRpst($options[$ii], $pval);
140
 
141
- if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']);
142
- if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
143
- if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
144
- } elseif ( count($pval)==1 ) if (isset($pval['apDo'.$code])) $options[$ii]['do'.$code] = $pval['apDo'.$code]; else $options[$ii]['do'.$code] = 0;
145
- } return $options;
146
- }
147
- //#### Show Post->Edit Meta Box Settings
148
- function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID; $nt = 'ap'; $ntU = 'AP';
149
- foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapAP', true));
150
- if (is_array($pMeta) && isset($pMeta[$ii]) && is_array($pMeta[$ii])) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]); if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = '';
151
- $doAP = $ntOpt['doAP'] && (is_array($pMeta) || $ntOpt['catSel']!='1'); $imgToUse = $ntOpt['imgToUse'];
152
- $isAvailAP = $ntOpt['appID']!='' && $ntOpt['appSec']!=''; $apMsgFormat = htmlentities($ntOpt['apTextFormat'], ENT_COMPAT, "UTF-8");
153
- ?>
154
- <tr><th style="text-align:left;" colspan="2">
155
- <?php if ($ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='') { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
156
- <?php if (!empty($ntOpt['tagsSelX'])) { ?> <input type="hidden" class="nxs_TG" id="nxs_TG_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $ntOpt['tagsSelX']; ?>" /> <?php } ?>
157
- <?php if ($isAvailAP) { ?><input class="nxsGrpDoChb" value="1" id="doAP<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="ap[<?php echo $ii; ?>][doAP]" <?php if ((int)$doAP == 1) echo 'checked="checked" title="def"'; ?> />
158
- <?php if ($post->post_status == "publish") { ?> <input type="hidden" name="ap[<?php echo $ii; ?>][doAP]" value="<?php echo $doAP;?>"> <?php } ?> <?php } ?>
159
-
160
- <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/ap16.png);">App.Net - <?php _e('publish to', 'social-networks-auto-poster-facebook-twitter-g') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
161
- if ($post->post_status == "publish" && $isAvailAP) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToAP_repostButton" id="rePostToAP_button" value="<?php _e('Repost to App.Net', 'social-networks-auto-poster-facebook-twitter-g') ?>" />
162
- <?php } ?>
163
-
164
- <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
165
-
166
- ?> <span id="pstdAP<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
167
- <a style="font-size: 10px;" href="<?php echo $pMeta[$ii]['postURL']; ?>" target="_blank"><?php $nType="App.Net"; printf( __( 'Posted on', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
168
- </span><?php } ?>
169
-
170
- </td></tr>
171
-
172
- <?php if (!$isAvailAP) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your App.Net Account to AutoPost to App.Net</b></td></tr>
173
- <?php } else { if ($post->post_status != "publish" && function_exists('nxs_doSMAS5') ) { $ntOpt['postTime'] = get_post_time('U', false, $post_id); nxs_doSMAS5($nt, $ii, $ntOpt); } ?>
174
-
175
- <?php if ($ntOpt['rpstOn']=='1') { ?>
176
-
177
- <tr id="altFormat1" style=""><th scope="row" class="nxsTHRow">
178
- <input value="0" type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]"/><input value="nxsi<?php echo $ii; ?>ap" type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]" <?php if (!empty($ntOpt['rpstPostIncl'])) echo "checked"; ?> />
179
- </th>
180
- <td> <?php _e('Include in "Auto-Reposting" to this network.', 'social-networks-auto-poster-facebook-twitter-g') ?>
181
- </td></tr> <?php } ?>
182
-
183
-
184
- <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Text Format:', 'social-networks-auto-poster-facebook-twitter-g') ?></th><td>
185
-
186
- <textarea cols="150" rows="1" id="ap<?php echo $ii; ?>SNAPformat" name="ap[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('#ap<?php echo $ii; ?>SNAPformat').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apAPMsgFrmt<?php echo $ii; ?>');"><?php echo $apMsgFormat ?></textarea>
187
-
188
- </td></tr>
189
- <tr><th scope="row" style="text-align:right; width:150px; vertical-align:top; padding-top: 5px; padding-right:10px;">
190
- <input value="0" type="hidden" name="ap[<?php echo $ii; ?>][attchImg]"/>
191
- <input value="1" type="checkbox" name="ap[<?php echo $ii; ?>][attchImg]" <?php if ((int)$ntOpt['attchImg'] == 1) echo "checked"; ?> /> </th><td><strong>Attach Image to App.net Post</strong></td> </tr>
192
- <?php /* ## Select Image & URL ## */ nxs_showImgToUseDlg($nt, $ii, $imgToUse); ?>
193
-
194
-
195
-
196
- <?php }
197
-
198
  }
199
  }
 
200
  //#### Save Meta Tags to the Post
201
- function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
202
- if (isset($pMeta['SNAPformat'])) $optMt['apTextFormat'] = $pMeta['SNAPformat'];
203
- if (isset($pMeta['imgToUse'])) $optMt['imgToUse'] = $pMeta['imgToUse']; if (isset($pMeta['urlToUse'])) $optMt['urlToUse'] = $pMeta['urlToUse'];
204
- if (isset($pMeta['timeToRun'])) $optMt['timeToRun'] = $pMeta['timeToRun']; if (isset($pMeta['rpstPostIncl'])) $optMt['rpstPostIncl'] = $pMeta['rpstPostIncl'];
205
- if (isset($pMeta['attchImg'])) $optMt['attchImg'] = $pMeta['attchImg'] == 1?1:0; else { if (isset($pMeta['attchImg'])) $optMt['attchImg'] = 0; }
206
- if (isset($pMeta['doAP'])) $optMt['doAP'] = $pMeta['doAP'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doAP'] = 0; }
207
- if (isset($pMeta['SNAPincludeAP']) && $pMeta['SNAPincludeAP'] == '1' ) $optMt['doAP'] = 1;
208
  return $optMt;
209
- }
210
- }}
211
- if (!function_exists("nxs_rePostToAP_ajax")) {
212
- function nxs_rePostToAP_ajax() { check_ajax_referer('nxsSsPageWPN'); $postID = $_POST['id']; global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
213
- foreach ($options['ap'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj'; //if ($two['apPageID'].$two['apUName']==$_POST['nid']) {
214
- $appo = get_post_meta($postID, 'snapAP', true); $appo = maybe_unserialize($appo);// prr($appo);
215
- if (is_array($appo) && isset($appo[$ii]) && is_array($appo[$ii])){ $ntClInst = new nxs_snapClassAP(); $two = $ntClInst->adjMetaOpt($two, $appo[$ii]); }
216
- $result = nxs_doPublishToAP($postID, $two); if ($result == 200) die("Successfully sent your post to App.Net."); else die($result);
217
- }
218
  }
219
- }
220
- if (!function_exists("nxs_doPublishToAP")) { //## Post to AP. // V3 - imgToUse - Done, class_SNAP_AP - Done, New Format - Done
221
- function nxs_doPublishToAP($postID, $options){ $ntCd = 'AP'; $ntCdL = 'ap'; $ntNm = 'App.Net'; if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
222
- $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'POSTID'=>$postID, 'ACCNAME'=>$options['nName']));
223
- if (empty($options['imgToUse'])) $options['imgToUse'] = ''; if (empty($options['imgSize'])) $options['imgSize'] = '';
224
- $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
225
- $logNT = '<span style="color:#800000">App.Net</span> - '.$options['nName'];
226
- $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
227
- if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
228
- $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') {
229
- nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$uqID); return;
230
- }
231
- }
232
- $message = array('message'=>'', 'link'=>'', 'imageURL'=>'', 'videoURL'=>'');
233
-
234
- if ($postID=='0') { echo "Testing ... <br/><br/>"; $message['description'] = 'Test Post, Description'; $message['title'] = 'Test Post - Title'; $message['url'] = home_url();
235
- } else { nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1')); $post = get_post($postID); if(!$post) return;
236
- $apAttchImg = $options['attchImg']; $options['apTextFormat'] = nsFormatMessage($options['apTextFormat'], $postID, $addParams);
237
- $extInfo = ' | PostID: '.$postID." - ".(isset($post) && is_object($post)?$post->post_title:'');
238
- if ($options['attchImg']=='1') { if (trim($options['imgToUse'])!='') $imgURL = $options['imgToUse']; else $imgURL = nxs_getPostImage($postID);
239
- if (preg_match("/noImg.\.png/i", $imgURL)) $imgURL = ''; if(trim($imgURL)=='') $options['attchImg'] = 0;
240
- }
241
- $message = array('imageURL'=>$imgURL);
242
- }
243
- //## Actual Post
244
- $ntToPost = new nxs_class_SNAP_AP(); $ret = $ntToPost->doPostToNT($options, $message);
245
- //## Process Results
246
- if (!is_array($ret) || $ret['isPosted']!='1') { //## Error
247
- if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);
248
- } else { // ## All Good - log it.
249
- if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo _e('OK - Message Posted, please see your '.$logNT.' Page. ', 'social-networks-auto-poster-facebook-twitter-g'); }
250
- else { nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPosted'=>'1', 'pgID'=>$ret['postID'], 'postURL'=>$ret['postURL'], 'pDate'=>date('Y-m-d H:i:s')));
251
- $extInfo .= ' | <a href="'.$ret['postURL'].'" target="_blank">Post Link</a>'; nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); }
252
- }
253
- //## Return Result
254
- if ($ret['isPosted']=='1') return 200; else return print_r($ret, true);
255
-
256
- }
257
- }
258
  ?>
1
  <?php
2
  //## NextScripts App.net Connection Class
3
+ $nxs_snapAvNts[] = array('code'=>'AP', 'lcode'=>'ap', 'name'=>'App.net (!)', 'type'=>'Social Networks', 'ptype'=>'F', 'status'=>'D', 'desc'=>'Dead');
4
 
5
+ if (!class_exists("nxs_snapClassAP")) { class nxs_snapClassAP extends nxs_snapClassNT {
6
+ var $ntInfo = array('code'=>'AP', 'lcode'=>'ap', 'name'=>'App.net (!)', 'defNName'=>'', 'tstReq' => true, 'instrURL'=>'http://www.nextscripts.com/setup-installation/app-net-social-networks-auto-poster-wordpress/');
7
+ //#### Update
8
+ function toLatestVer($ntOpts){ if( !empty($ntOpts['v'])) $v = $ntOpts['v']; else $v = 340; $ntOptsOut = ''; switch ($v) {
9
+ case 340: $ntOptsOut = $this->toLatestVerNTGen($ntOpts); $ntOptsOut['do'] = $ntOpts['do'.$this->ntInfo['code']]; $ntOptsOut['nName'] = $ntOpts['nName']; $ntOptsOut['attchImg'] = $ntOpts['attchImg'];
10
+ $ntOptsOut['msgFormat'] = $ntOpts['apTextFormat']; $ntOptsOut['appKey'] = $ntOpts['appID']; $ntOptsOut['appSec'] = $ntOpts['appSec'];
11
+ $ntOptsOut['accessToken'] = $ntOpts['apAppAuthToken']; $ntOptsOut['authUserID'] = $ntOpts['appAppUserID']; $ntOptsOut['authUserName'] = $ntOpts['appAppUserName']; $ntOptsOut['isUpdd'] = '1'; $ntOptsOut['v'] = NXS_SETV;
12
+ break;
13
+ }
14
+ return !empty($ntOptsOut)?$ntOptsOut:$ntOpts;
15
+ }
16
  //#### Show Common Settings
17
+ function showGenNTSettings($ntOpts){ $this->nt = $ntOpts; $this->showNTGroup(); }
18
+ //#### Show NEW Settings Page
19
+ function showNewNTSettings($ii){ $defO = array('nName'=>'', 'do'=>'1', 'appKey'=>'', 'appSec'=>'', 'attchImg'=>1, 'msgFormat'=>"New post (%TITLE%) has been published on %SITENAME% - %URL%", 'imgSize'=>'original'); $this->showGNewNTSettings($ii, $defO); }
20
+ //#### Show Unit Settings
21
+ function checkIfSetupFinished($options) { return !empty($options['authUserID']) && !empty($options['accessToken']); }
22
+ public function doAuth() { $ntInfo = $this->ntInfo; global $nxs_snapSetPgURL;
23
+ if ( !empty($_GET['code']) && (!empty($_GET['state']) && stripos($_GET['state'], $ntInfo['lcode'].'-')!==false) ){ $at = $_GET['code']; $to = explode('-', $_GET['state']); $_GET['acc'] = $to[1];
24
  echo "-= This is normal technical authorization info that will dissapear (Unless you get some errors) =- <br/><br/><br/>";
25
+ if (isset($_GET['acc'])) $options = $this->nt[$_GET['acc']]; $wprg = array(); $response = nxs_remote_get('https://graph.facebook.com/nextscripts', $wprg);
26
  echo $nxs_snapSetPgURL.'&auth=ap&acc='.$_GET['acc']."||"; if(stripos($nxs_snapSetPgURL, 'page=NextScripts_SNAP.php')===false) { $newURL = explode('?', $nxs_snapSetPgURL); $nxs_snapSetPgURL = $newURL[0]; }
27
+ if( is_nxs_error( $response) && isset($response->errors['http_request_failed']) && stripos($response->errors['http_request_failed'][0], 'SSL')!==false ) { prr($response->errors); $wprg['sslverify'] = false; }
28
+ if (isset($options['appKey'])){ echo "-="; prr($options);
29
+ $wprg['body'] = array('client_id'=>$options['appKey'], 'client_secret'=>$options['appSec'], 'grant_type'=>'authorization_code', 'redirect_uri'=>$nxs_snapSetPgURL, 'state'=>'ap-'.$_GET['acc'], 'code'=>$at); prr($wprg);
30
+ $response = nxs_remote_post('https://account.app.net/oauth/access_token', $wprg);
31
  if ( (is_object($response) && (isset($response->errors))) || (is_array($response) && stripos($response['body'],'"error":')!==false )) { prr($response); die(); }
32
+ $params = json_decode($response['body'], true); $options['accessToken'] = $params['access_token']; if ($params['user_id']>0) { $options['authUserID'] = $params['user_id']; $options['authUserName'] = $params['username']; }
33
+ if ($params['user_id']>0) { nxs_save_glbNtwrks($ntInfo['lcode'],$_GET['acc'],$options,'*'); ?><script type="text/javascript">window.location = "<?php echo $nxs_snapSetPgURL; ?>"</script>
 
34
  <?php } die(); }
35
  }
36
+ }
37
+
38
+ function accTab($ii, $options, $isNew=false){ global $nxs_snapSetPgURL; $ntInfo = $this->ntInfo; $nt = $ntInfo['lcode']; ?>
39
+ <div style="color:red;padding:5px;margin:5px; border: 1px solid darkred;">[January 2017] App.net is shutting down on March 15, 2017. Please see the <a target="_blank" href="http://blog.app.net/2017/01/12/app-net-is-shutting-down/">blog post</a> for more information.<br/></div>
40
+ <?php $this->elemKeySecret($ii,'Client ID','Client Secret', $options['appKey'], $options['appSec'],'appKey','appSec','https://account.app.net/developer/apps/'); ?>
41
+ <br/><?php $this->elemMsgFormat($ii,'Message Format','msgFormat',$options['msgFormat']); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
 
43
+ <div style="margin: 0px;"><input value="1" type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][attchImg]" <?php if ((int)$options['attchImg'] == 1) echo "checked"; ?> /> <strong><?php _e('Attach Image to the Post', 'social-networks-auto-poster-facebook-twitter-g'); ?></strong></div>
 
 
 
 
 
 
 
44
 
45
+ <br/><br/>
46
+ <?php if($options['appKey']=='') { ?>
47
+ <b><?php _e('Authorize Your '.$ntInfo['name'].' Account', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> <?php _e('Please click "Update Settings" to be able to Authorize your account.', 'social-networks-auto-poster-facebook-twitter-g');
48
+ } else { if(isset($options['authUserID']) && $options['authUserID']>0) {
49
+ _e('Your '.$ntInfo['name'].' Account has been authorized.', 'social-networks-auto-poster-facebook-twitter-g'); ?> User ID: <?php _e(apply_filters('format_to_edit', htmlentities($options['authUserID'].' - '.$options['authUserName'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>.
50
+ <?php _e('You can', 'social-networks-auto-poster-facebook-twitter-g'); ?> Re- <?php } ?>
51
+ <a href="https://account.app.net/oauth/authenticate?client_id=<?php echo trim($options['appKey']);?>&response_type=code&redirect_uri=<?php echo trim(urlencode($nxs_snapSetPgURL).'&state='.$nt.'-'.$ii.'&scope=stream+write_post+follow+messages+update_profile+files');?>">Authorize Your <?php echo $ntInfo['name']; ?> Account</a>
52
+ <?php if (!isset($options['authUserID']) || $options['authUserID']<1) { ?> <div class="blnkg">&lt;=== <?php _e('Authorize your account', 'social-networks-auto-poster-facebook-twitter-g'); ?> ===</div> <?php }
53
+ } ?><br/><br/> <?php
54
  }
55
+ function advTab($ii, $options){}
56
  //#### Set Unit Settings from POST
57
+ function setNTSettings($post, $options){
58
+ foreach ($post as $ii => $pval){
59
+ if (!empty($pval['appKey']) && !empty($pval['appKey'])){ if (!isset($options[$ii])) $options[$ii] = array(); $options[$ii] = $this->saveCommonNTSettings($pval,$options[$ii]);
60
+ //## Uniqe Items
61
+ if (isset($pval['attchImg'])) $options[$ii]['attchImg'] = trim($pval['attchImg']); else $options[$ii]['attchImg'] = 0;
62
+ } elseif ( count($pval)==1 ) if (isset($pval['do'])) $options[$ii]['do'] = $pval['do']; else $options[$ii]['do'] = 0;
63
+ } return $options;
64
+ }
65
+
66
+ //#### Show Post->Edit Meta Box Settings
67
+
68
+ function showEdPostNTSettings($ntOpts, $post){ $post_id = $post->ID; $nt = $this->ntInfo['lcode']; $ntU = $this->ntInfo['code'];
69
+ foreach($ntOpts as $ii=>$ntOpt) { $isFin = $this->checkIfSetupFinished($ntOpt); if (!$isFin) continue;
70
+ $pMeta = maybe_unserialize(get_post_meta($post_id, 'snap'.$ntU, true)); if (is_array($pMeta) && !empty($pMeta[$ii])) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
71
 
72
+ if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = ''; if (empty($ntOpt['urlToUse'])) $ntOpt['urlToUse'] = ''; $postType = isset($ntOpt['postType'])?$ntOpt['postType']:'';
73
+ $msgFormat = !empty($ntOpt['msgFormat'])?htmlentities($ntOpt['msgFormat'], ENT_COMPAT, "UTF-8"):''; $msgTFormat = !empty($ntOpt['msgTFormat'])?htmlentities($ntOpt['msgTFormat'], ENT_COMPAT, "UTF-8"):'';
74
+ $imgToUse = $ntOpt['imgToUse']; $urlToUse = $ntOpt['urlToUse']; $ntOpt['ii']=$ii;
 
 
 
75
 
76
+ $this->nxs_tmpltAddPostMeta($post, $ntOpt, $pMeta);
77
 
78
+ $this->elemEdMsgFormat($ii, __('Message Format:', 'social-networks-auto-poster-facebook-twitter-g'),$msgFormat);
79
+ ?>
80
+ <tr><td>&nbsp;</td><td><div style="margin: 0px;"><input value="0" type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][attchImg]"/>
81
+ <input value="1" type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][attchImg]" <?php if ((int)$ntOpt['attchImg'] == 1) echo "checked"; ?> /> <strong><?php _e('Attach Image to the Post', 'social-networks-auto-poster-facebook-twitter-g'); ?></strong></div></td></tr> <?php
82
+ nxs_showImgToUseDlg($nt, $ii, $imgToUse);
83
+
84
+ /* ## Select Image & URL ## */ nxs_showURLToUseDlg($nt, $ii, $urlToUse); $this->nxs_tmpltAddPostMetaEnd($ii);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  }
86
  }
87
+
88
  //#### Save Meta Tags to the Post
89
+ function adjMetaOpt($optMt, $pMeta){ $optMt = $this->adjMetaOptG($optMt, $pMeta);
90
+ if (!empty($pMeta['attchImg'])) $optMt['attchImg'] = $pMeta['attchImg']; else $optMt['attchImg'] = 0;
 
 
 
 
 
91
  return $optMt;
 
 
 
 
 
 
 
 
 
92
  }
93
+
94
+ function adjPublishWP(&$options, &$message, $postID){
95
+ if (!empty($postID)) { if (trim($options['imgToUse'])!='') $imgURL = $options['imgToUse']; else $imgURL = nxs_getPostImage($postID, !empty($options['wpImgSize'])?$options['wpImgSize']:'full');
96
+ if (preg_match("/noImg.\.png/i", $imgURL)) { $imgURL = ''; $isNoImg = true; }
97
+ $message['imageURL'] = $imgURL;
98
+ }
99
+ }
100
+
101
+ }}
102
+
103
+ if (!function_exists("nxs_doPublishToAP")) { function nxs_doPublishToAP($postID, $options){ if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true)); $cl = new nxs_snapClassAP(); $cl->nt[$options['ii']] = $options; return $cl->publishWP($options['ii'], $postID); }}
104
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  ?>
inc-cl/apis/liOAuth.php CHANGED
@@ -58,7 +58,7 @@ class nsx_LinkedIn {
58
  $url = $request->to_url(); // echo "==========";
59
  $response = $this->httpRequest($url, $headers, "GET"); //prr($request);
60
  parse_str($response, $response_params); // prr($response_params);
61
- if($debug) {
62
  echo $response . "\n";
63
  }
64
  $this->access_token = new nsx_trOAuthConsumer($response_params['oauth_token'], $response_params['oauth_token_secret'], 1);
@@ -74,7 +74,7 @@ class nsx_LinkedIn {
74
  // $auth_header = preg_replace("/Authorization\: OAuth\,/", "Authorization: OAuth ", $auth_header);
75
  // # Make sure there is a space between OAuth attribute
76
  // $auth_header = preg_replace('/\"\,/', '", ', $auth_header);
77
- if ($debug) {
78
  echo $auth_header;
79
  }
80
  // $response will now hold the XML document
@@ -82,16 +82,19 @@ class nsx_LinkedIn {
82
  return $response;
83
  }
84
 
85
- function postShare($msg, $title='', $url='', $imgURL='', $dsc='') { $status_url = $this->base_url . "/v1/people/~/shares";
86
- $dsc = nxs_decodeEntitiesFull(strip_tags($dsc)); $msg = strip_tags(nxs_decodeEntitiesFull($msg)); $title = nxs_decodeEntitiesFull(strip_tags($title));
87
- $xml = '<?xml version="1.0" encoding="UTF-8"?><share><comment>'.htmlspecialchars($msg, ENT_NOQUOTES, "UTF-8").'</comment>'.
88
- ($url!=''?'<content><title>'.htmlspecialchars($title, ENT_NOQUOTES, "UTF-8").'</title><submitted-url>'.$url.'</submitted-url>'.(!empty($imgURL)?'<submitted-image-url>'.$imgURL.'</submitted-image-url>':'').'<description>'.htmlspecialchars($dsc, ENT_NOQUOTES, "UTF-8").'</description></content>':'').
89
- '<visibility><code>anyone</code></visibility></share>';
90
  $request = nsx_trOAuthRequest::from_consumer_and_token($this->consumer, $this->access_token, "POST", $status_url);
91
  $request->sign_request($this->signature_method, $this->consumer, $this->access_token);
92
- $auth_header = $request->to_header("https://api.linkedin.com");
 
 
 
 
 
93
  //if ($debug) echo $auth_header . "\n";
94
- $response = $this->httpRequest($status_url, $auth_header, "POST", $xml);
 
95
  return $response;
96
  }
97
 
@@ -103,7 +106,7 @@ class nsx_LinkedIn {
103
  $request = nsx_trOAuthRequest::from_consumer_and_token($this->consumer, $this->access_token, "PUT", $status_url);
104
  $request->sign_request($this->signature_method, $this->consumer, $this->access_token);
105
  $auth_header = $request->to_header("https://api.linkedin.com");
106
- if ($debug) {
107
  echo $auth_header . "\n";
108
  }
109
  $response = $this->httpRequest($status_url, $auth_header, "PUT", $xml); // prr($response);
58
  $url = $request->to_url(); // echo "==========";
59
  $response = $this->httpRequest($url, $headers, "GET"); //prr($request);
60
  parse_str($response, $response_params); // prr($response_params);
61
+ if($this->debug) {
62
  echo $response . "\n";
63
  }
64
  $this->access_token = new nsx_trOAuthConsumer($response_params['oauth_token'], $response_params['oauth_token_secret'], 1);
74
  // $auth_header = preg_replace("/Authorization\: OAuth\,/", "Authorization: OAuth ", $auth_header);
75
  // # Make sure there is a space between OAuth attribute
76
  // $auth_header = preg_replace('/\"\,/', '", ', $auth_header);
77
+ if ($this->debug) {
78
  echo $auth_header;
79
  }
80
  // $response will now hold the XML document
82
  return $response;
83
  }
84
 
85
+ function postShare($msg, $title='', $url='', $imgURL='', $dsc='') { $status_url = $this->base_url . "/v1/people/~/shares?format=json";
86
+ $dsc = nxs_decodeEntitiesFull(strip_tags($dsc)); $msg = strip_tags(nxs_decodeEntitiesFull($msg)); $title = nxs_decodeEntitiesFull(strip_tags($title));
 
 
 
87
  $request = nsx_trOAuthRequest::from_consumer_and_token($this->consumer, $this->access_token, "POST", $status_url);
88
  $request->sign_request($this->signature_method, $this->consumer, $this->access_token);
89
+ $auth_header = $request->to_header("https://api.linkedin.com");
90
+ $toPost = array('comment'=>htmlspecialchars($msg, ENT_NOQUOTES, "UTF-8"), 'visibility'=>array('code'=>'anyone'));
91
+ if (!empty($url)) $toPost['content'] = array('submitted-url'=>$url, 'title'=>htmlspecialchars($title, ENT_NOQUOTES, "UTF-8"), 'description'=>htmlspecialchars($dsc, ENT_NOQUOTES, "UTF-8"));
92
+ if (!empty($imgURL)) $toPost['content']['submitted-image-url'] = $imgURL;
93
+ $toPost = json_encode($toPost); $hdrsArr['Content-Type']='application/json'; $hdrsArr['x-li-format']='json';
94
+ $auth_header .= "\n".'Content-Type: application/json'."\n".'x-li-format: json';
95
  //if ($debug) echo $auth_header . "\n";
96
+ //prr($toPost);
97
+ $response = $this->httpRequest($status_url, $auth_header, "POST", $toPost); $response = json_decode($response, true);
98
  return $response;
99
  }
100
 
106
  $request = nsx_trOAuthRequest::from_consumer_and_token($this->consumer, $this->access_token, "PUT", $status_url);
107
  $request->sign_request($this->signature_method, $this->consumer, $this->access_token);
108
  $auth_header = $request->to_header("https://api.linkedin.com");
109
+ if ($this->debug) {
110
  echo $auth_header . "\n";
111
  }
112
  $response = $this->httpRequest($status_url, $auth_header, "PUT", $xml); // prr($response);
inc-cl/apis/plurkOAuth.php CHANGED
@@ -86,7 +86,7 @@ class nxspk_SigMethod_HMAC_SHA1 extends nxspk_SignatureMethod {
86
  }
87
 
88
  class wpPlurkOAuth{
89
- public $baseURL = 'http://www.plurk.com';
90
  public $http_code;
91
  protected $version = '1.0';
92
  protected $sign_method;
@@ -150,7 +150,7 @@ class wpPlurkOAuth{
150
  $url = $this->baseURL.PLURK_REQUEST_TOKEN_PATH.'?oauth_nonce='.$args['oauth_nonce'].'&oauth_timestamp='.$args['oauth_timestamp'].'&oauth_consumer_key='.$this->consumer_key.'&oauth_signature_method='.$args['oauth_signature_method'].'&oauth_version='.$args['oauth_version'].'&oauth_callback='.$cbu.'&oauth_signature='.$args['oauth_signature'];
151
  echo "<br/>REQ Token URL: ".$url."<br/>";
152
  $hdrsArr = $this->makeHTTPHeaders($url); $ckArr = $nxs_vbCkArray;
153
- $response = wp_remote_get($url, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr));
154
  if (is_nxs_error($response)){ $badOut = print_r($response, true)." - Connection ERROR"; return $badOut; }
155
  $this->http_code = $response['response']['code']; // prr($response);
156
  if (stripos($response['body'],'oauth_token_secret=')===false) echo 'Bad oAuth Login:'.$response['body']; else return $this->oAuthRespToArr($response['body']);
@@ -171,9 +171,9 @@ class wpPlurkOAuth{
171
  $args['oauth_signature'] = $this->sign_method->sign2($req, $this->consumer_secret, $this->access_secret);
172
  $url = $this->baseURL.PLURK_ACCESS_TOKEN_PATH.'?oauth_nonce='.$args['oauth_nonce'].'&oauth_timestamp='.$args['oauth_timestamp'].'&oauth_token_secret='.$this->access_secret.'&oauth_signature_method='.$args['oauth_signature_method'].'&oauth_consumer_key='.$this->consumer_key.'&oauth_verifier='.$verifier.'&oauth_version='.$args['oauth_version'].'&oauth_token='.$this->access_token.'&oauth_signature='.$args['oauth_signature'];
173
  echo "<br/>REQ Token URL: ".$url."<br/>";
174
- $hdrsArr = $this->makeHTTPHeaders($url); $ckArr = $nxs_vbCkArray;
175
- $response = wp_remote_get($url, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr));
176
- if ( is_wp_error($response) ) return $response;
177
  $this->http_code = $response['response']['code'];
178
  if (stripos($response['body'],'oauth_token_secret=')===false) echo 'Bad oAuth Login:'.$response['body']; else return $this->oAuthRespToArr($response['body']);
179
  }
@@ -194,8 +194,8 @@ class wpPlurkOAuth{
194
  if (is_array($params)) { $params = nxspk_SigMethod_HMAC_SHA1::urlencode_rfc3986($params); $args = array_merge($args, $params);} //prr($args);
195
  $argsStr = ''; $argsT = array(); foreach ($args as $arN=>$arV){$argsT[] = $arN.'='.$arV;} $argsStr = implode('&', $argsT); $url .= '?'.$argsStr;
196
  $hdrsArr = $this->makeHTTPHeaders($url); $ckArr = '';
197
- $response = wp_remote_get($url, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr)); // prr($response);
198
- if ( is_wp_error($response) ) return $response;
199
  $this->http_code = $response['response']['code'];
200
  return json_decode($response['body'], true);
201
  }
86
  }
87
 
88
  class wpPlurkOAuth{
89
+ public $baseURL = 'https://www.plurk.com';
90
  public $http_code;
91
  protected $version = '1.0';
92
  protected $sign_method;
150
  $url = $this->baseURL.PLURK_REQUEST_TOKEN_PATH.'?oauth_nonce='.$args['oauth_nonce'].'&oauth_timestamp='.$args['oauth_timestamp'].'&oauth_consumer_key='.$this->consumer_key.'&oauth_signature_method='.$args['oauth_signature_method'].'&oauth_version='.$args['oauth_version'].'&oauth_callback='.$cbu.'&oauth_signature='.$args['oauth_signature'];
151
  echo "<br/>REQ Token URL: ".$url."<br/>";
152
  $hdrsArr = $this->makeHTTPHeaders($url); $ckArr = $nxs_vbCkArray;
153
+ $response = nxs_remote_get($url, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr));
154
  if (is_nxs_error($response)){ $badOut = print_r($response, true)." - Connection ERROR"; return $badOut; }
155
  $this->http_code = $response['response']['code']; // prr($response);
156
  if (stripos($response['body'],'oauth_token_secret=')===false) echo 'Bad oAuth Login:'.$response['body']; else return $this->oAuthRespToArr($response['body']);
171
  $args['oauth_signature'] = $this->sign_method->sign2($req, $this->consumer_secret, $this->access_secret);
172
  $url = $this->baseURL.PLURK_ACCESS_TOKEN_PATH.'?oauth_nonce='.$args['oauth_nonce'].'&oauth_timestamp='.$args['oauth_timestamp'].'&oauth_token_secret='.$this->access_secret.'&oauth_signature_method='.$args['oauth_signature_method'].'&oauth_consumer_key='.$this->consumer_key.'&oauth_verifier='.$verifier.'&oauth_version='.$args['oauth_version'].'&oauth_token='.$this->access_token.'&oauth_signature='.$args['oauth_signature'];
173
  echo "<br/>REQ Token URL: ".$url."<br/>";
174
+ $hdrsArr = $this->makeHTTPHeaders($url); $ckArr = array();
175
+ $response = nxs_remote_get($url, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr));
176
+ if ( is_nxs_error($response) ) return $response;
177
  $this->http_code = $response['response']['code'];
178
  if (stripos($response['body'],'oauth_token_secret=')===false) echo 'Bad oAuth Login:'.$response['body']; else return $this->oAuthRespToArr($response['body']);
179
  }
194
  if (is_array($params)) { $params = nxspk_SigMethod_HMAC_SHA1::urlencode_rfc3986($params); $args = array_merge($args, $params);} //prr($args);
195
  $argsStr = ''; $argsT = array(); foreach ($args as $arN=>$arV){$argsT[] = $arN.'='.$arV;} $argsStr = implode('&', $argsT); $url .= '?'.$argsStr;
196
  $hdrsArr = $this->makeHTTPHeaders($url); $ckArr = '';
197
+ $response = nxs_remote_get($url, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr)); // prr($response);
198
+ if ( is_nxs_error($response) ) return $response;
199
  $this->http_code = $response['response']['code'];
200
  return json_decode($response['body'], true);
201
  }
inc-cl/apis/scOAuth.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- abstract class nxssc_SignatureMethod
4
  {
5
  abstract public function signing_base($request, $consumer, $token);
6
  abstract public function sign($request, $consumer, $token);
@@ -8,9 +8,9 @@ abstract class nxssc_SignatureMethod
8
  $built = $this->sign($request, $consumer, $token);
9
  return $built == $signature;
10
  }
11
- }
12
 
13
- class nxssc_SigMethod_HMAC_SHA1 extends nxssc_SignatureMethod {
14
  public $name = 'HMAC-SHA1';
15
  public function signing_base($request, $consumer_secret, $token) {
16
  $sig = array(rawurlencode($request['method']), rawurlencode($request['normalized_url']), rawurlencode($request['normalized_parameters']));
@@ -79,7 +79,7 @@ class nxssc_SigMethod_HMAC_SHA1 extends nxssc_SignatureMethod {
79
  $built = $this->sign($request, $consumer_secret, $token);
80
  return $built == $signature;
81
  }
82
- }
83
 
84
  class wpScoopITOAuth{
85
  public $baseURL = 'http://www.scoop.it';
@@ -148,8 +148,8 @@ class wpScoopITOAuth{
148
  $url = $this->baseURL.$this->request_token_path.'?oauth_nonce='.$args['oauth_nonce'].'&oauth_timestamp='.$args['oauth_timestamp'].'&oauth_consumer_key='.$this->consumer_key.'&oauth_signature_method='.$args['oauth_signature_method'].'&oauth_version='.$args['oauth_version'].'&oauth_callback='.$cbu.'&oauth_signature='.$args['oauth_signature'];
149
  echo "<br/>REQ Token URL: ".$url."<br/>";
150
  $hdrsArr = $this->makeHTTPHeaders($url); $ckArr = '';
151
- $response = wp_remote_get($url, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr));
152
- if ( is_wp_error($response) ) return print_r($response, true);
153
  $this->http_code = $response['response']['code']; // prr($response);
154
  if (stripos($response['body'],'oauth_token_secret=')===false) echo 'Bad oAuth Login:'.$response['body']; else return $this->oAuthRespToArr($response['body']);
155
  }
@@ -170,8 +170,8 @@ class wpScoopITOAuth{
170
  $url = $this->baseURL.$this->access_token_path.'?oauth_nonce='.$args['oauth_nonce'].'&oauth_timestamp='.$args['oauth_timestamp'].'&oauth_token_secret='.$this->access_secret.'&oauth_signature_method='.$args['oauth_signature_method'].'&oauth_consumer_key='.$this->consumer_key.'&oauth_verifier='.$verifier.'&oauth_version='.$args['oauth_version'].'&oauth_token='.$this->access_token.'&oauth_signature='.$args['oauth_signature'];
171
  echo "<br/>REQ Token URL: ".$url."<br/>";
172
  $hdrsArr = $this->makeHTTPHeaders($url); $ckArr = '';
173
- $response = wp_remote_get($url, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr));
174
- if ( is_wp_error($response) ) return $response;
175
  $this->http_code = $response['response']['code'];
176
  if (stripos($response['body'],'oauth_token_secret=')===false) echo 'Bad oAuth Login:'.$response['body']; else return $this->oAuthRespToArr($response['body']);
177
  }
@@ -203,11 +203,11 @@ class wpScoopITOAuth{
203
  $params = nxssc_SigMethod_HMAC_SHA1::urlencode_rfc3986($params); $args = array_merge($args, $params);
204
  } $argsStr = ''; $argsT = array(); uksort($args, 'strcmp'); foreach ($args as $arN=>$arV){$argsT[] = $arN.'='.$arV;} $argsStr = implode('&', $argsT);
205
  if ( $type=='GET') { $url .= '?'.$argsStr; $hdrsArr = $this->makeHTTPHeaders($url); $ckArr = ''; // prr($url);
206
- $response = wp_remote_get($url, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr)); //prr($response);
207
  } else { $hdrsArr = $this->makeHTTPHeaders($url, true); if (!empty($argsAddStr)) $argsStr .= $argsAddStr; //prr($url); prr($hdrsArr); prr($argsStr); prr($argsT);
208
- $response = wp_remote_post($url, array( 'timeout' => 45, 'redirection' => 0, 'body'=>$argsStr, 'headers' => $hdrsArr)); //prr($argsStr); prr($argsT); prr($response);
209
  }
210
- if ( is_wp_error($response) ) return $response;
211
  $this->http_code = $response['response']['code']; $body = $response['body']; $body = maybe_unserialize($body); if (is_array($body)) return $body; else return json_decode($body, true);
212
  }
213
 
1
  <?php
2
 
3
+ if (!class_exists('nxssc_SignatureMethod')) { abstract class nxssc_SignatureMethod
4
  {
5
  abstract public function signing_base($request, $consumer, $token);
6
  abstract public function sign($request, $consumer, $token);
8
  $built = $this->sign($request, $consumer, $token);
9
  return $built == $signature;
10
  }
11
+ }}
12
 
13
+ if (!class_exists('nxssc_SigMethod_HMAC_SHA1')) { class nxssc_SigMethod_HMAC_SHA1 extends nxssc_SignatureMethod {
14
  public $name = 'HMAC-SHA1';
15
  public function signing_base($request, $consumer_secret, $token) {
16
  $sig = array(rawurlencode($request['method']), rawurlencode($request['normalized_url']), rawurlencode($request['normalized_parameters']));
79
  $built = $this->sign($request, $consumer_secret, $token);
80
  return $built == $signature;
81
  }
82
+ }}
83
 
84
  class wpScoopITOAuth{
85
  public $baseURL = 'http://www.scoop.it';
148
  $url = $this->baseURL.$this->request_token_path.'?oauth_nonce='.$args['oauth_nonce'].'&oauth_timestamp='.$args['oauth_timestamp'].'&oauth_consumer_key='.$this->consumer_key.'&oauth_signature_method='.$args['oauth_signature_method'].'&oauth_version='.$args['oauth_version'].'&oauth_callback='.$cbu.'&oauth_signature='.$args['oauth_signature'];
149
  echo "<br/>REQ Token URL: ".$url."<br/>";
150
  $hdrsArr = $this->makeHTTPHeaders($url); $ckArr = '';
151
+ $response = nxs_remote_get($url, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr));
152
+ if ( is_nxs_error($response) ) return print_r($response, true);
153
  $this->http_code = $response['response']['code']; // prr($response);
154
  if (stripos($response['body'],'oauth_token_secret=')===false) echo 'Bad oAuth Login:'.$response['body']; else return $this->oAuthRespToArr($response['body']);
155
  }
170
  $url = $this->baseURL.$this->access_token_path.'?oauth_nonce='.$args['oauth_nonce'].'&oauth_timestamp='.$args['oauth_timestamp'].'&oauth_token_secret='.$this->access_secret.'&oauth_signature_method='.$args['oauth_signature_method'].'&oauth_consumer_key='.$this->consumer_key.'&oauth_verifier='.$verifier.'&oauth_version='.$args['oauth_version'].'&oauth_token='.$this->access_token.'&oauth_signature='.$args['oauth_signature'];
171
  echo "<br/>REQ Token URL: ".$url."<br/>";
172
  $hdrsArr = $this->makeHTTPHeaders($url); $ckArr = '';
173
+ $response = nxs_remote_get($url, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr));
174
+ if ( is_nxs_error($response) ) return $response;
175
  $this->http_code = $response['response']['code'];
176
  if (stripos($response['body'],'oauth_token_secret=')===false) echo 'Bad oAuth Login:'.$response['body']; else return $this->oAuthRespToArr($response['body']);
177
  }
203
  $params = nxssc_SigMethod_HMAC_SHA1::urlencode_rfc3986($params); $args = array_merge($args, $params);
204
  } $argsStr = ''; $argsT = array(); uksort($args, 'strcmp'); foreach ($args as $arN=>$arV){$argsT[] = $arN.'='.$arV;} $argsStr = implode('&', $argsT);
205
  if ( $type=='GET') { $url .= '?'.$argsStr; $hdrsArr = $this->makeHTTPHeaders($url); $ckArr = ''; // prr($url);
206
+ $response = nxs_remote_get($url, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr)); //prr($response);
207
  } else { $hdrsArr = $this->makeHTTPHeaders($url, true); if (!empty($argsAddStr)) $argsStr .= $argsAddStr; //prr($url); prr($hdrsArr); prr($argsStr); prr($argsT);
208
+ $response = nxs_remote_post($url, array( 'timeout' => 45, 'redirection' => 0, 'body'=>$argsStr, 'headers' => $hdrsArr)); //prr($argsStr); prr($argsT); prr($response);
209
  }
210
+ if ( is_nxs_error($response) ) return $response;
211
  $this->http_code = $response['response']['code']; $body = $response['body']; $body = maybe_unserialize($body); if (is_array($body)) return $body; else return json_decode($body, true);
212
  }
213
 
inc-cl/apis/startssl.pem ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIHyTCCBbGgAwIBAgIBATANBgkqhkiG9w0BAQUFADB9MQswCQYDVQQGEwJJTDEW
3
+ MBQGA1UEChMNU3RhcnRDb20gTHRkLjErMCkGA1UECxMiU2VjdXJlIERpZ2l0YWwg
4
+ Q2VydGlmaWNhdGUgU2lnbmluZzEpMCcGA1UEAxMgU3RhcnRDb20gQ2VydGlmaWNh
5
+ dGlvbiBBdXRob3JpdHkwHhcNMDYwOTE3MTk0NjM2WhcNMzYwOTE3MTk0NjM2WjB9
6
+ MQswCQYDVQQGEwJJTDEWMBQGA1UEChMNU3RhcnRDb20gTHRkLjErMCkGA1UECxMi
7
+ U2VjdXJlIERpZ2l0YWwgQ2VydGlmaWNhdGUgU2lnbmluZzEpMCcGA1UEAxMgU3Rh
8
+ cnRDb20gQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUA
9
+ A4ICDwAwggIKAoICAQDBiNsJvGxGfHiflXu1M5DycmLWwTYgIiRezul38kMKogZk
10
+ pMyONvg45iPwbm2xPN1yo4UcodM9tDMr0y+v/uqwQVlntsQGfQqedIXWeUyAN3rf
11
+ OQVSWff0G0ZDpNKFhdLDcfN1YjS6LIp/Ho/u7TTQEceWzVI9ujPW3U3eCztKS5/C
12
+ Ji/6tRYccjV3yjxd5srhJosaNnZcAdt0FCX+7bWgiA/deMotHweXMAEtcnn6RtYT
13
+ Kqi5pquDSR3l8u/d5AGOGAqPY1MWhWKpDhk6zLVmpsJrdAfkK+F2PrRt2PZE4XNi
14
+ HzvEvqBTViVsUQn3qqvKv3b9bZvzndu/PWa8DFaqr5hIlTpL36dYUNk4dalb6kMM
15
+ Av+Z6+hsTXBbKWWc3apdzK8BMewM69KN6Oqce+Zu9ydmDBpI125C4z/eIT574Q1w
16
+ +2OqqGwaVLRcJXrJosmLFqa7LH4XXgVNWG4SHQHuEhANxjJ/GP/89PrNbpHoNkm+
17
+ Gkhpi8KWTRoSsmkXwQqQ1vp5Iki/untp+HDH+no32NgN0nZPV/+Qt+OR0t3vwmC3
18
+ Zzrd/qqc8NSLf3Iizsafl7b4r4qgEKjZ+xjGtrVcUjyJthkqcwEKDwOzEmDyei+B
19
+ 26Nu/yYwl/WL3YlXtq09s68rxbd2AvCl1iuahhQqcvbjM4xdCUsT37uMdBNSSwID
20
+ AQABo4ICUjCCAk4wDAYDVR0TBAUwAwEB/zALBgNVHQ8EBAMCAa4wHQYDVR0OBBYE
21
+ FE4L7xqkQFulF2mHMMo0aEPQQa7yMGQGA1UdHwRdMFswLKAqoCiGJmh0dHA6Ly9j
22
+ ZXJ0LnN0YXJ0Y29tLm9yZy9zZnNjYS1jcmwuY3JsMCugKaAnhiVodHRwOi8vY3Js
23
+ LnN0YXJ0Y29tLm9yZy9zZnNjYS1jcmwuY3JsMIIBXQYDVR0gBIIBVDCCAVAwggFM
24
+ BgsrBgEEAYG1NwEBATCCATswLwYIKwYBBQUHAgEWI2h0dHA6Ly9jZXJ0LnN0YXJ0
25
+ Y29tLm9yZy9wb2xpY3kucGRmMDUGCCsGAQUFBwIBFilodHRwOi8vY2VydC5zdGFy
26
+ dGNvbS5vcmcvaW50ZXJtZWRpYXRlLnBkZjCB0AYIKwYBBQUHAgIwgcMwJxYgU3Rh
27
+ cnQgQ29tbWVyY2lhbCAoU3RhcnRDb20pIEx0ZC4wAwIBARqBl0xpbWl0ZWQgTGlh
28
+ YmlsaXR5LCByZWFkIHRoZSBzZWN0aW9uICpMZWdhbCBMaW1pdGF0aW9ucyogb2Yg
29
+ dGhlIFN0YXJ0Q29tIENlcnRpZmljYXRpb24gQXV0aG9yaXR5IFBvbGljeSBhdmFp
30
+ bGFibGUgYXQgaHR0cDovL2NlcnQuc3RhcnRjb20ub3JnL3BvbGljeS5wZGYwEQYJ
31
+ YIZIAYb4QgEBBAQDAgAHMDgGCWCGSAGG+EIBDQQrFilTdGFydENvbSBGcmVlIFNT
32
+ TCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTANBgkqhkiG9w0BAQUFAAOCAgEAFmyZ
33
+ 9GYMNPXQhV59CuzaEE44HF7fpiUFS5Eyweg78T3dRAlbB0mKKctmArexmvclmAk8
34
+ jhvh3TaHK0u7aNM5Zj2gJsfyOZEdUauCe37Vzlrk4gNXcGmXCPleWKYK34wGmkUW
35
+ FjgKXlf2Ysd6AgXmvB618p70qSmD+LIU424oh0TDkBreOKk8rENNZEXO3SipXPJz
36
+ ewT4F+irsfMuXGRuczE6Eri8sxHkfY+BUZo7jYn0TZNmezwD7dOaHZrzZVD1oNB1
37
+ ny+v8OqCQ5j4aZyJecRDjkZy42Q2Eq/3JR44iZB3fsNrarnDy0RLrHiQi+fHLB5L
38
+ EUTINFInzQpdn4XBidUaePKVEFMy3YCEZnXZtWgo+2EuvoSoOMCZEoalHmdkrQYu
39
+ L6lwhceWD3yJZfWOQ1QOq92lgDmUYMA0yZZwLKMS9R9Ie70cfmu3nZD0Ijuu+Pwq
40
+ yvqCUqDvr0tVk+vBtfAii6w0TiYiBKGHLHVKt+V9E9e4DGTANtLJL4YSjCMJwRuC
41
+ O3NJo2pXh5Tl1njFmUNj403gdy3hZZlyaQQaRwnmDwFWJPsfvw55qVguucQJAX6V
42
+ um0ABj6y6koQOdjQK/W/7HW/lwLFCRsI3FU34oH7N4RDYiDK51ZLZer+bMEkkySh
43
+ NOsF/5oirpt9P/FlUQqmMGqz9IgcgA38corog14=
44
+ -----END CERTIFICATE-----
inc-cl/apis/xmlrpc-client.php CHANGED
@@ -38,15 +38,15 @@
38
  * @link http://scripts.incutio.com/xmlrpc/ Site/manual
39
  *
40
  * Modified Nov 2014 by NextScripts.com to provide SSL compatiblity.
 
41
  */
42
 
43
-
44
  class NXS_XMLRPC_Value
45
  {
46
  var $data;
47
  var $type;
48
 
49
- function NXS_XMLRPC_Value($data, $type = false)
50
  {
51
  $this->data = $data;
52
  if (!$type) {
@@ -190,7 +190,7 @@ class NXS_XMLRPC_Message
190
  // The XML parser
191
  var $_parser;
192
 
193
- function NXS_XMLRPC_Message($message)
194
  {
195
  $this->message =& $message;
196
  }
@@ -335,209 +335,6 @@ class NXS_XMLRPC_Message
335
  }
336
  }
337
 
338
- /**
339
- * NXS_XMLRPC_Server
340
- *
341
- * @package IXR
342
- * @since 1.5
343
- */
344
- class NXS_XMLRPC_Server
345
- {
346
- var $data;
347
- var $callbacks = array();
348
- var $message;
349
- var $capabilities;
350
-
351
- function NXS_XMLRPC_Server($callbacks = false, $data = false, $wait = false)
352
- {
353
- $this->setCapabilities();
354
- if ($callbacks) {
355
- $this->callbacks = $callbacks;
356
- }
357
- $this->setCallbacks();
358
- if (!$wait) {
359
- $this->serve($data);
360
- }
361
- }
362
-
363
- function serve($data = false)
364
- {
365
- if (!$data) {
366
- if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] !== 'POST') {
367
- header('Content-Type: text/plain'); // merged from WP #9093
368
- die('XML-RPC server accepts POST requests only.');
369
- }
370
-
371
- global $HTTP_RAW_POST_DATA;
372
- if (empty($HTTP_RAW_POST_DATA)) {
373
- // workaround for a bug in PHP 5.2.2 - http://bugs.php.net/bug.php?id=41293
374
- $data = file_get_contents('php://input');
375
- } else {
376
- $data =& $HTTP_RAW_POST_DATA;
377
- }
378
- }
379
- $this->message = new NXS_XMLRPC_Message($data);
380
- if (!$this->message->parse()) {
381
- $this->error(-32700, 'parse error. not well formed');
382
- }
383
- if ($this->message->messageType != 'methodCall') {
384
- $this->error(-32600, 'server error. invalid xml-rpc. not conforming to spec. Request must be a methodCall');
385
- }
386
- $result = $this->call($this->message->methodName, $this->message->params);
387
-
388
- // Is the result an error?
389
- if (is_a($result, 'NXS_XMLRPC_Error')) {
390
- $this->error($result);
391
- }
392
-
393
- // Encode the result
394
- $r = new NXS_XMLRPC_Value($result);
395
- $resultxml = $r->getXml();
396
-
397
- // Create the XML
398
- $xml = <<<EOD
399
- <methodResponse>
400
- <params>
401
- <param>
402
- <value>
403
- $resultxml
404
- </value>
405
- </param>
406
- </params>
407
- </methodResponse>
408
-
409
- EOD;
410
- // Send it
411
- $this->output($xml);
412
- }
413
-
414
- function call($methodname, $args)
415
- {
416
- if (!$this->hasMethod($methodname)) {
417
- return new NXS_XMLRPC_Error(-32601, 'server error. requested method '.$methodname.' does not exist.');
418
- }
419
- $method = $this->callbacks[$methodname];
420
-
421
- // Perform the callback and send the response
422
- if (count($args) == 1) {
423
- // If only one paramater just send that instead of the whole array
424
- $args = $args[0];
425
- }
426
-
427
- // Are we dealing with a function or a method?
428
- if (is_string($method) && substr($method, 0, 5) == 'this:') {
429
- // It's a class method - check it exists
430
- $method = substr($method, 5);
431
- if (!method_exists($this, $method)) {
432
- return new NXS_XMLRPC_Error(-32601, 'server error. requested class method "'.$method.'" does not exist.');
433
- }
434
-
435
- //Call the method
436
- $result = $this->$method($args);
437
- } else {
438
- // It's a function - does it exist?
439
- if (is_array($method)) {
440
- if (!method_exists($method[0], $method[1])) {
441
- return new NXS_XMLRPC_Error(-32601, 'server error. requested object method "'.$method[1].'" does not exist.');
442
- }
443
- } else if (!function_exists($method)) {
444
- return new NXS_XMLRPC_Error(-32601, 'server error. requested function "'.$method.'" does not exist.');
445
- }
446
-
447
- // Call the function
448
- $result = call_user_func($method, $args);
449
- }
450
- return $result;
451
- }
452
-
453
- function error($error, $message = false)
454
- {
455
- // Accepts either an error object or an error code and message
456
- if ($message && !is_object($error)) {
457
- $error = new NXS_XMLRPC_Error($error, $message);
458
- }
459
- $this->output($error->getXml());
460
- }
461
-
462
- function output($xml)
463
- {
464
- $xml = '<?xml version="1.0"?>'."\n".$xml;
465
- $length = strlen($xml);
466
- header('Connection: close');
467
- header('Content-Length: '.$length);
468
- header('Content-Type: text/xml');
469
- header('Date: '.date('r'));
470
- echo $xml;
471
- exit;
472
- }
473
-
474
- function hasMethod($method)
475
- {
476
- return in_array($method, array_keys($this->callbacks));
477
- }
478
-
479
- function setCapabilities()
480
- {
481
- // Initialises capabilities array
482
- $this->capabilities = array(
483
- 'xmlrpc' => array(
484
- 'specUrl' => 'http://www.xmlrpc.com/spec',
485
- 'specVersion' => 1
486
- ),
487
- 'faults_interop' => array(
488
- 'specUrl' => 'http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php',
489
- 'specVersion' => 20010516
490
- ),
491
- 'system.multicall' => array(
492
- 'specUrl' => 'http://www.xmlrpc.com/discuss/msgReader$1208',
493
- 'specVersion' => 1
494
- ),
495
- );
496
- }
497
-
498
- function getCapabilities($args)
499
- {
500
- return $this->capabilities;
501
- }
502
-
503
- function setCallbacks()
504
- {
505
- $this->callbacks['system.getCapabilities'] = 'this:getCapabilities';
506
- $this->callbacks['system.listMethods'] = 'this:listMethods';
507
- $this->callbacks['system.multicall'] = 'this:multiCall';
508
- }
509
-
510
- function listMethods($args)
511
- {
512
- // Returns a list of methods - uses array_reverse to ensure user defined
513
- // methods are listed before server defined methods
514
- return array_reverse(array_keys($this->callbacks));
515
- }
516
-
517
- function multiCall($methodcalls)
518
- {
519
- // See http://www.xmlrpc.com/discuss/msgReader$1208
520
- $return = array();
521
- foreach ($methodcalls as $call) {
522
- $method = $call['methodName'];
523
- $params = $call['params'];
524
- if ($method == 'system.multicall') {
525
- $result = new NXS_XMLRPC_Error(-32600, 'Recursive calls to system.multicall are forbidden');
526
- } else {
527
- $result = $this->call($method, $params);
528
- }
529
- if (is_a($result, 'NXS_XMLRPC_Error')) {
530
- $return[] = array(
531
- 'faultCode' => $result->code,
532
- 'faultString' => $result->message
533
- );
534
- } else {
535
- $return[] = array($result);
536
- }
537
- }
538
- return $return;
539
- }
540
- }
541
 
542
  /**
543
  * NXS_XMLRPC_Request
@@ -551,7 +348,7 @@ class NXS_XMLRPC_Request
551
  var $args;
552
  var $xml;
553
 
554
- function NXS_XMLRPC_Request($method, $args)
555
  {
556
  $this->method = $method;
557
  $this->args = $args;
@@ -573,7 +370,8 @@ EOD;
573
 
574
  function getLength()
575
  {
576
- return strlen($this->xml);
 
577
  }
578
 
579
  function getXml()
@@ -604,7 +402,7 @@ class NXS_XMLRPC_Client
604
  // Storage place for an error message
605
  var $error = false;
606
 
607
- function NXS_XMLRPC_Client($server, $path = false, $port = 80, $timeout = 25)
608
  {
609
  if (!$path) {
610
  // Assume we have been given a URL instead
@@ -641,7 +439,7 @@ class NXS_XMLRPC_Client
641
  $this->headers['Host'] = $this->server;
642
  $this->headers['Content-Type'] = 'text/xml';
643
  $this->headers['User-Agent'] = $this->useragent;
644
- $this->headers['Content-Length']= $length;
645
 
646
  foreach( $this->headers as $header => $value ) {
647
  $request .= "{$header}: {$value}{$r}";
@@ -752,9 +550,8 @@ class NXS_XMLRPC_Client
752
  curl_setopt($curl, CURLOPT_POST, 1);
753
  curl_setopt($curl, CURLOPT_POSTFIELDS, $xml);
754
  curl_setopt($curl, CURLOPT_PORT, $this->port);
755
- curl_setopt($curl, CURLOPT_HTTPHEADER, array(
756
- "Content-Type: text/xml",
757
- "Content-length: {$length}"));
758
 
759
  curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
760
  global $nxs_skipSSLCheck; if ($nxs_skipSSLCheck===true) curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
@@ -829,7 +626,7 @@ class NXS_XMLRPC_Error
829
  var $code;
830
  var $message;
831
 
832
- function NXS_XMLRPC_Error($code, $message)
833
  {
834
  $this->code = $code;
835
  $this->message = htmlspecialchars($message);
@@ -875,7 +672,7 @@ class NXS_XMLRPC_Date {
875
  var $second;
876
  var $timezone;
877
 
878
- function NXS_XMLRPC_Date($time)
879
  {
880
  // $time can be a PHP timestamp or an ISO one
881
  if (is_numeric($time)) {
@@ -933,7 +730,7 @@ class NXS_XMLRPC_Base64
933
  {
934
  var $data;
935
 
936
- function NXS_XMLRPC_Base64($data)
937
  {
938
  $this->data = $data;
939
  }
@@ -944,169 +741,6 @@ class NXS_XMLRPC_Base64
944
  }
945
  }
946
 
947
- /**
948
- * NXS_XMLRPC_IntrospectionServer
949
- *
950
- * @package IXR
951
- * @since 1.5
952
- */
953
- class NXS_XMLRPC_IntrospectionServer extends NXS_XMLRPC_Server
954
- {
955
- var $signatures;
956
- var $help;
957
-
958
- function NXS_XMLRPC_IntrospectionServer()
959
- {
960
- $this->setCallbacks();
961
- $this->setCapabilities();
962
- $this->capabilities['introspection'] = array(
963
- 'specUrl' => 'http://xmlrpc.usefulinc.com/doc/reserved.html',
964
- 'specVersion' => 1
965
- );
966
- $this->addCallback(
967
- 'system.methodSignature',
968
- 'this:methodSignature',
969
- array('array', 'string'),
970
- 'Returns an array describing the return type and required parameters of a method'
971
- );
972
- $this->addCallback(
973
- 'system.getCapabilities',
974
- 'this:getCapabilities',
975
- array('struct'),
976
- 'Returns a struct describing the XML-RPC specifications supported by this server'
977
- );
978
- $this->addCallback(
979
- 'system.listMethods',
980
- 'this:listMethods',
981
- array('array'),
982
- 'Returns an array of available methods on this server'
983
- );
984
- $this->addCallback(
985
- 'system.methodHelp',
986
- 'this:methodHelp',
987
- array('string', 'string'),
988
- 'Returns a documentation string for the specified method'
989
- );
990
- }
991
-
992
- function addCallback($method, $callback, $args, $help)
993
- {
994
- $this->callbacks[$method] = $callback;
995
- $this->signatures[$method] = $args;
996
- $this->help[$method] = $help;
997
- }
998
-
999
- function call($methodname, $args)
1000
- {
1001
- // Make sure it's in an array
1002
- if ($args && !is_array($args)) {
1003
- $args = array($args);
1004
- }
1005
-
1006
- // Over-rides default call method, adds signature check
1007
- if (!$this->hasMethod($methodname)) {
1008
- return new NXS_XMLRPC_Error(-32601, 'server error. requested method "'.$this->message->methodName.'" not specified.');
1009
- }
1010
- $method = $this->callbacks[$methodname];
1011
- $signature = $this->signatures[$methodname];
1012
- $returnType = array_shift($signature);
1013
-
1014
- // Check the number of arguments
1015
- if (count($args) != count($signature)) {
1016
- return new NXS_XMLRPC_Error(-32602, 'server error. wrong number of method parameters');
1017
- }
1018
-
1019
- // Check the argument types
1020
- $ok = true;
1021
- $argsbackup = $args;
1022
- for ($i = 0, $j = count($args); $i < $j; $i++) {
1023
- $arg = array_shift($args);
1024
- $type = array_shift($signature);
1025
- switch ($type) {
1026
- case 'int':
1027
- case 'i4':
1028
- if (is_array($arg) || !is_int($arg)) {
1029
- $ok = false;
1030
- }
1031
- break;
1032
- case 'base64':
1033
- case 'string':
1034
- if (!is_string($arg)) {
1035
- $ok = false;
1036
- }
1037
- break;
1038
- case 'boolean':
1039
- if ($arg !== false && $arg !== true) {
1040
- $ok = false;
1041
- }
1042
- break;
1043
- case 'float':
1044
- case 'double':
1045
- if (!is_float($arg)) {
1046
- $ok = false;
1047
- }
1048
- break;
1049
- case 'date':
1050
- case 'dateTime.iso8601':
1051
- if (!is_a($arg, 'NXS_XMLRPC_Date')) {
1052
- $ok = false;
1053
- }
1054
- break;
1055
- }
1056
- if (!$ok) {
1057
- return new NXS_XMLRPC_Error(-32602, 'server error. invalid method parameters');
1058
- }
1059
- }
1060
- // It passed the test - run the "real" method call
1061
- return parent::call($methodname, $argsbackup);
1062
- }
1063
-
1064
- function methodSignature($method)
1065
- {
1066
- if (!$this->hasMethod($method)) {
1067
- return new NXS_XMLRPC_Error(-32601, 'server error. requested method "'.$method.'" not specified.');
1068
- }
1069
- // We should be returning an array of types
1070
- $types = $this->signatures[$method];
1071
- $return = array();
1072
- foreach ($types as $type) {
1073
- switch ($type) {
1074
- case 'string':
1075
- $return[] = 'string';
1076
- break;
1077
- case 'int':
1078
- case 'i4':
1079
- $return[] = 42;
1080
- break;
1081
- case 'double':
1082
- $return[] = 3.1415;
1083
- break;
1084
- case 'dateTime.iso8601':
1085
- $return[] = new NXS_XMLRPC_Date(time());
1086
- break;
1087
- case 'boolean':
1088
- $return[] = true;
1089
- break;
1090
- case 'base64':
1091
- $return[] = new NXS_XMLRPC_Base64('base64');
1092
- break;
1093
- case 'array':
1094
- $return[] = array('array');
1095
- break;
1096
- case 'struct':
1097
- $return[] = array('struct' => 'struct');
1098
- break;
1099
- }
1100
- }
1101
- return $return;
1102
- }
1103
-
1104
- function methodHelp($method)
1105
- {
1106
- return $this->help[$method];
1107
- }
1108
- }
1109
-
1110
  /**
1111
  * NXS_XMLRPC_ClientMulticall
1112
  *
@@ -1117,9 +751,9 @@ class NXS_XMLRPC_ClientMulticall extends NXS_XMLRPC_Client
1117
  {
1118
  var $calls = array();
1119
 
1120
- function NXS_XMLRPC_ClientMulticall($server, $path = false, $port = 80)
1121
  {
1122
- parent::NXS_XMLRPC_Client($server, $path, $port);
1123
  $this->useragent = 'The Incutio XML-RPC PHP Library (multicall client)';
1124
  }
1125
 
@@ -1188,9 +822,9 @@ class NXS_XMLRPC_ClientSSL extends NXS_XMLRPC_Client
1188
  * @param string $server URL of the Server to connect to
1189
  * @since 0.1.0
1190
  */
1191
- function NXS_XMLRPC_ClientSSL($server, $path = false, $port = 443, $timeout = false)
1192
  {
1193
- parent::NXS_XMLRPC_Client($server, $path, $port, $timeout);
1194
  $this->useragent = 'The Incutio XML-RPC PHP Library for SSL';
1195
 
1196
  // Set class fields
@@ -1293,9 +927,8 @@ class NXS_XMLRPC_ClientSSL extends NXS_XMLRPC_Client
1293
  curl_setopt($curl, CURLOPT_POST, 1);
1294
  curl_setopt($curl, CURLOPT_POSTFIELDS, $xml);
1295
  curl_setopt($curl, CURLOPT_PORT, $this->port);
1296
- curl_setopt($curl, CURLOPT_HTTPHEADER, array(
1297
- "Content-Type: text/xml",
1298
- "Content-length: {$length}"));
1299
 
1300
  // Process the SSL certificates, etc. to use
1301
  if (!($this->_certFile === false)) {
@@ -1359,101 +992,4 @@ class NXS_XMLRPC_ClientSSL extends NXS_XMLRPC_Client
1359
  }
1360
  }
1361
 
1362
- /**
1363
- * Extension of the {@link NXS_XMLRPC_Server} class to easily wrap objects.
1364
- *
1365
- * Class is designed to extend the existing XML-RPC server to allow the
1366
- * presentation of methods from a variety of different objects via an
1367
- * XML-RPC server.
1368
- * It is intended to assist in organization of your XML-RPC methods by allowing
1369
- * you to "write once" in your existing model classes and present them.
1370
- *
1371
- * @author Jason Stirk <jstirk@gmm.com.au>
1372
- * @version 1.0.1 19Apr2005 17:40 +0800
1373
- * @copyright Copyright (c) 2005 Jason Stirk
1374
- * @package IXR
1375
- */
1376
- class NXS_XMLRPC_ClassServer extends NXS_XMLRPC_Server
1377
- {
1378
- var $_objects;
1379
- var $_delim;
1380
-
1381
- function NXS_XMLRPC_ClassServer($delim = '.', $wait = false)
1382
- {
1383
- $this->NXS_XMLRPC_Server(array(), false, $wait);
1384
- $this->_delimiter = $delim;
1385
- $this->_objects = array();
1386
- }
1387
-
1388
- function addMethod($rpcName, $functionName)
1389
- {
1390
- $this->callbacks[$rpcName] = $functionName;
1391
- }
1392
-
1393
- function registerObject($object, $methods, $prefix=null)
1394
- {
1395
- if (is_null($prefix))
1396
- {
1397
- $prefix = get_class($object);
1398
- }
1399
- $this->_objects[$prefix] = $object;
1400
-
1401
- // Add to our callbacks array
1402
- foreach($methods as $method)
1403
- {
1404
- if (is_array($method))
1405
- {
1406
- $targetMethod = $method[0];
1407
- $method = $method[1];
1408
- }
1409
- else
1410
- {
1411
- $targetMethod = $method;
1412
- }
1413
- $this->callbacks[$prefix . $this->_delimiter . $method]=array($prefix, $targetMethod);
1414
- }
1415
- }
1416
-
1417
- function call($methodname, $args)
1418
- {
1419
- if (!$this->hasMethod($methodname)) {
1420
- return new NXS_XMLRPC_Error(-32601, 'server error. requested method '.$methodname.' does not exist.');
1421
- }
1422
- $method = $this->callbacks[$methodname];
1423
-
1424
- // Perform the callback and send the response
1425
- if (count($args) == 1) {
1426
- // If only one paramater just send that instead of the whole array
1427
- $args = $args[0];
1428
- }
1429
-
1430
- // See if this method comes from one of our objects or maybe self
1431
- if (is_array($method) || (substr($method, 0, 5) == 'this:')) {
1432
- if (is_array($method)) {
1433
- $object=$this->_objects[$method[0]];
1434
- $method=$method[1];
1435
- } else {
1436
- $object=$this;
1437
- $method = substr($method, 5);
1438
- }
1439
-
1440
- // It's a class method - check it exists
1441
- if (!method_exists($object, $method)) {
1442
- return new NXS_XMLRPC_Error(-32601, 'server error. requested class method "'.$method.'" does not exist.');
1443
- }
1444
-
1445
- // Call the method
1446
- $result = $object->$method($args);
1447
- } else {
1448
- // It's a function - does it exist?
1449
- if (!function_exists($method)) {
1450
- return new NXS_XMLRPC_Error(-32601, 'server error. requested function "'.$method.'" does not exist.');
1451
- }
1452
-
1453
- // Call the function
1454
- $result = $method($args);
1455
- }
1456
- return $result;
1457
- }
1458
- }
1459
  ?>
38
  * @link http://scripts.incutio.com/xmlrpc/ Site/manual
39
  *
40
  * Modified Nov 2014 by NextScripts.com to provide SSL compatiblity.
41
+ * Modified Oct 2016 by NextScripts.com - removed Server part due to PHP7 incompatibility.
42
  */
43
 
 
44
  class NXS_XMLRPC_Value
45
  {
46
  var $data;
47
  var $type;
48
 
49
+ function __construct($data, $type = false)
50
  {
51
  $this->data = $data;
52
  if (!$type) {
190
  // The XML parser
191
  var $_parser;
192
 
193
+ function __construct($message)
194
  {
195
  $this->message =& $message;
196
  }
335
  }
336
  }
337
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
338
 
339
  /**
340
  * NXS_XMLRPC_Request
348
  var $args;
349
  var $xml;
350
 
351
+ function __construct($method, $args)
352
  {
353
  $this->method = $method;
354
  $this->args = $args;
370
 
371
  function getLength()
372
  {
373
+
374
+ return nxs_strLen($this->xml);
375
  }
376
 
377
  function getXml()
402
  // Storage place for an error message
403
  var $error = false;
404
 
405
+ function __construct($server, $path = false, $port = 80, $timeout = 25)
406
  {
407
  if (!$path) {
408
  // Assume we have been given a URL instead
439
  $this->headers['Host'] = $this->server;
440
  $this->headers['Content-Type'] = 'text/xml';
441
  $this->headers['User-Agent'] = $this->useragent;
442
+ //$this->headers['Content-Length']= $length;
443
 
444
  foreach( $this->headers as $header => $value ) {
445
  $request .= "{$header}: {$value}{$r}";
550
  curl_setopt($curl, CURLOPT_POST, 1);
551
  curl_setopt($curl, CURLOPT_POSTFIELDS, $xml);
552
  curl_setopt($curl, CURLOPT_PORT, $this->port);
553
+ //curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: text/xml","Content-length: {$length}"));
554
+ curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
 
555
 
556
  curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
557
  global $nxs_skipSSLCheck; if ($nxs_skipSSLCheck===true) curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
626
  var $code;
627
  var $message;
628
 
629
+ function __construct($code, $message)
630
  {
631
  $this->code = $code;
632
  $this->message = htmlspecialchars($message);
672
  var $second;
673
  var $timezone;
674
 
675
+ function __construct($time)
676
  {
677
  // $time can be a PHP timestamp or an ISO one
678
  if (is_numeric($time)) {
730
  {
731
  var $data;
732
 
733
+ function __construct($data)
734
  {
735
  $this->data = $data;
736
  }
741
  }
742
  }
743
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
744
  /**
745
  * NXS_XMLRPC_ClientMulticall
746
  *
751
  {
752
  var $calls = array();
753
 
754
+ function __construct($server, $path = false, $port = 80)
755
  {
756
+ parent::__construct($server, $path, $port);
757
  $this->useragent = 'The Incutio XML-RPC PHP Library (multicall client)';
758
  }
759
 
822
  * @param string $server URL of the Server to connect to
823
  * @since 0.1.0
824
  */
825
+ function __construct($server, $path = false, $port = 443, $timeout = false)
826
  {
827
+ parent::__construct($server, $path, $port, $timeout);
828
  $this->useragent = 'The Incutio XML-RPC PHP Library for SSL';
829
 
830
  // Set class fields
927
  curl_setopt($curl, CURLOPT_POST, 1);
928
  curl_setopt($curl, CURLOPT_POSTFIELDS, $xml);
929
  curl_setopt($curl, CURLOPT_PORT, $this->port);
930
+ //curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: text/xml","Content-length: {$length}"));
931
+ curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
 
932
 
933
  // Process the SSL certificates, etc. to use
934
  if (!($this->_certFile === false)) {
992
  }
993
  }
994
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
995
  ?>
inc-cl/bg.api.php CHANGED
@@ -17,11 +17,11 @@ if (!class_exists("nxs_class_SNAP_BG")) { class nxs_class_SNAP_BG {
17
  //if (!function_exists('doConnectToBlogger')) if (file_exists('apis/postToGooglePlus.php')) require_once ('apis/postToGooglePlus.php'); elseif (file_exists('/home/_shared/deSrc.php')) require_once ('/home/_shared/deSrc.php');
18
  //## Check settings
19
  if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
20
- if ( (!isset($options['bgUName']) || empty($options['bgPass'])) && empty($options['AccessToken'])) { $badOut['Error'] = 'Not Configured'; return $badOut; }
21
  //## Format
22
- if (!empty($message['pText'])) $msg = $message['pText']; else $msg = nxs_doFormatMsg($options['bgMsgFormat'], $message);
23
- if (!empty($message['pTitle'])) $msgT = $message['pTitle']; else $msgT = nxs_doFormatMsg($options['bgMsgTFormat'], $message);
24
- if ($options['bgInclTags']=='1') $tags = nsTrnc($message['tags'], 195, ',', ''); else $tags = '';
25
  //## Check/Fix HTML
26
  if (class_exists('DOMDocument')) {$doc = new DOMDocument(); @$doc->loadHTML('<?xml encoding="UTF-8">' .$msg); $doc->encoding = 'UTF-8'; $msg = $doc->saveHTML(); $msg = CutFromTo($msg, '<body>', '</body>');
27
  $msg = preg_replace('/<br(.*?)\/?>/','<br$1/>',$msg); $msg = preg_replace('/<img(.*?)\/?>/','<img$1/>',$msg);
@@ -30,9 +30,11 @@ if (!class_exists("nxs_class_SNAP_BG")) { class nxs_class_SNAP_BG {
30
  $msg = preg_replace('/<script\b[^>]*>(.*?)<\/script>/is', "", $msg); $msg = preg_replace('/<!--(.*)-->/Uis', "", $msg); $nxshf = new NXS_HtmlFixer(); $nxshf->debug = false; $msg = $nxshf->getFixedHtml($msg);
31
  $msg = str_replace("\r\n","\n", $msg); $msg = str_replace("\n\r","\n", $msg); $msg = str_replace("\r","\n", $msg); $msg = str_replace("\n","<br/>", $msg);
32
  //## Make Post
33
- $email = $options['bgUName']; $pass = substr($options['bgPass'], 0, 5)=='b4d7s'?nsx_doDecode(substr($options['bgPass'], 5)):$options['bgPass']; $blogID = $options['bgBlogID']; // prr($msgT); prr($msg); die();
34
- if (class_exists('nxsAPI_GP') && !empty($options['bgUName']) && empty($options['APIKey'])) {
35
- $nt = new nxsAPI_GP(); if(!empty($options['ck'])) $nt->ck = $options['ck']; $nt->debug = false; $loginError = $nt->connect($email, $pass, 'BG');
 
 
36
  if (!$loginError){
37
  $result = $nt -> postBG($blogID, $msgT, $msg, $tags);// prr($result);
38
  } else { $badOut['Error'] = "Login/Connection Error: ". print_r($loginError, true); return $badOut; }
@@ -41,16 +43,16 @@ if (!class_exists("nxs_class_SNAP_BG")) { class nxs_class_SNAP_BG {
41
  } else {
42
  //## Refresh token
43
  if (function_exists('get_option')) $currTime = time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); else $currTime = time();
44
- if ($options['AccessTokenExp']<$currTime){
45
- $tknURL = 'https://www.googleapis.com/oauth2/v3/token?refresh_token='.$options['RefreshToken'].'&client_id='.$options['APIKey'].'&client_secret='.$options['APISec'].'&grant_type=refresh_token';
46
- $response = wp_remote_post($tknURL); $resp = json_decode($response['body'], true); $options['AccessToken'] = $resp['access_token']; $options['AccessTokenExp'] = $currTime + $resp['expires_in'];
47
- nxs_save_glbNtwrks('bg', $options['ii'], $resp['access_token'], 'AccessTokenExp'); nxs_save_glbNtwrks('bg', $options['ii'], $options['AccessTokenExp'], 'AccessTokenExp');
48
  //nxs_addToLogN('S', 'Test', $logNT, 'Token Refreshed '.date('Y-m-d H:i:s',$options['AccessTokenExp'])."|".$tknURL.$options['AccessToken'].print_r($response, true));
49
  }
50
  //## Post
51
  $post = array("kind"=>"blogger#post", "blog"=>array("id"=>$blogID), "title"=> $msgT, "content" => $msg ); $post = json_encode($post); // prr($post);
52
  $hdrsArr = array('Content-Type'=>'application/json'); $advSet = array('headers' => $hdrsArr, 'httpversion' => '1.1', 'timeout' => 45, 'redirection' => 0, 'body' => $post);
53
- $tknURL = 'https://www.googleapis.com/blogger/v3/blogs/'.$blogID.'/posts?access_token='.$options['AccessToken'].''; $ret = ''; $response = wp_remote_post($tknURL, $advSet); //prr($tknURL); prr($response);
54
  if ((is_object($response) && isset($response->errors))) $badOut['Error'] = print_r($response, true); else $ret = json_decode($response['body'], true); //prr($ret);
55
  if (is_array($ret) && !empty($ret['id'])) return array('postID'=>$ret['id'], 'isPosted'=>1, 'postURL'=>$ret['url'], 'pDate'=>date('Y-m-d H:i:s'));
56
  else { $badOut['Error'].= "Error: ".print_r($ret, true); return $badOut;}
17
  //if (!function_exists('doConnectToBlogger')) if (file_exists('apis/postToGooglePlus.php')) require_once ('apis/postToGooglePlus.php'); elseif (file_exists('/home/_shared/deSrc.php')) require_once ('/home/_shared/deSrc.php');
18
  //## Check settings
19
  if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
20
+ if ( (!isset($options['uName']) || empty($options['uPass'])) && empty($options['accessToken'])) { $badOut['Error'] = 'Not Configured'; return $badOut; }
21
  //## Format
22
+ if (!empty($message['pText'])) $msg = $message['pText']; else $msg = nxs_doFormatMsg($options['msgFormat'], $message);
23
+ if (!empty($message['pTitle'])) $msgT = $message['pTitle']; else $msgT = nxs_doFormatMsg($options['msgTFormat'], $message);
24
+ if ($options['inclTags']=='1') $tags = nsTrnc($message['tags'], 195, ',', ''); else $tags = '';
25
  //## Check/Fix HTML
26
  if (class_exists('DOMDocument')) {$doc = new DOMDocument(); @$doc->loadHTML('<?xml encoding="UTF-8">' .$msg); $doc->encoding = 'UTF-8'; $msg = $doc->saveHTML(); $msg = CutFromTo($msg, '<body>', '</body>');
27
  $msg = preg_replace('/<br(.*?)\/?>/','<br$1/>',$msg); $msg = preg_replace('/<img(.*?)\/?>/','<img$1/>',$msg);
30
  $msg = preg_replace('/<script\b[^>]*>(.*?)<\/script>/is', "", $msg); $msg = preg_replace('/<!--(.*)-->/Uis', "", $msg); $nxshf = new NXS_HtmlFixer(); $nxshf->debug = false; $msg = $nxshf->getFixedHtml($msg);
31
  $msg = str_replace("\r\n","\n", $msg); $msg = str_replace("\n\r","\n", $msg); $msg = str_replace("\r","\n", $msg); $msg = str_replace("\n","<br/>", $msg);
32
  //## Make Post
33
+ $blogID = $options['blogID'];
34
+ //prr($options); // prr($msgT); prr($msg); die();
35
+ if (class_exists('nxsAPI_GP') && !empty($options['uName']) && empty($options['accessToken'])) {
36
+ $pass = (substr($options['uPass'], 0, 5)=='n5g9a'||substr($options['uPass'], 0, 5)=='g9c1a'||substr($options['uPass'], 0, 5)=='b4d7s')?nsx_doDecode(substr($options['uPass'], 5)):$options['uPass'];
37
+ $nt = new nxsAPI_GP(); if(!empty($options['ck'])) $nt->ck = $options['ck']; $nt->debug = false; $loginError = $nt->connect($options['uName'], $pass, 'BG');
38
  if (!$loginError){
39
  $result = $nt -> postBG($blogID, $msgT, $msg, $tags);// prr($result);
40
  } else { $badOut['Error'] = "Login/Connection Error: ". print_r($loginError, true); return $badOut; }
43
  } else {
44
  //## Refresh token
45
  if (function_exists('get_option')) $currTime = time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); else $currTime = time();
46
+ if ($options['accessTokenExp']<$currTime){
47
+ $tknURL = 'https://www.googleapis.com/oauth2/v3/token?refresh_token='.$options['refreshToken'].'&client_id='.$options['appKey'].'&client_secret='.$options['appSec'].'&grant_type=refresh_token';
48
+ $response = nxs_remote_post($tknURL); $resp = json_decode($response['body'], true); $options['accessToken'] = $resp['access_token']; $options['accessTokenExp'] = $currTime + $resp['expires_in'];
49
+ nxs_save_glbNtwrks('bg', $options['ii'], $resp['access_token'], 'accessToken'); nxs_save_glbNtwrks('bg', $options['ii'], $options['accessTokenExp'], 'accessTokenExp');
50
  //nxs_addToLogN('S', 'Test', $logNT, 'Token Refreshed '.date('Y-m-d H:i:s',$options['AccessTokenExp'])."|".$tknURL.$options['AccessToken'].print_r($response, true));
51
  }
52
  //## Post
53
  $post = array("kind"=>"blogger#post", "blog"=>array("id"=>$blogID), "title"=> $msgT, "content" => $msg ); $post = json_encode($post); // prr($post);
54
  $hdrsArr = array('Content-Type'=>'application/json'); $advSet = array('headers' => $hdrsArr, 'httpversion' => '1.1', 'timeout' => 45, 'redirection' => 0, 'body' => $post);
55
+ $tknURL = 'https://www.googleapis.com/blogger/v3/blogs/'.$blogID.'/posts?access_token='.$options['accessToken'].''; $ret = ''; $response = nxs_remote_post($tknURL, $advSet); //prr($tknURL); prr($response);
56
  if ((is_object($response) && isset($response->errors))) $badOut['Error'] = print_r($response, true); else $ret = json_decode($response['body'], true); //prr($ret);
57
  if (is_array($ret) && !empty($ret['id'])) return array('postID'=>$ret['id'], 'isPosted'=>1, 'postURL'=>$ret['url'], 'pDate'=>date('Y-m-d H:i:s'));
58
  else { $badOut['Error'].= "Error: ".print_r($ret, true); return $badOut;}
inc-cl/bg.php CHANGED
@@ -1,324 +1,137 @@
1
  <?php
2
  //## NextScripts Blogger Connection Class
3
- $nxs_snapAvNts[] = array('code'=>'BG', 'lcode'=>'bg', 'name'=>'Blogger');
4
 
5
- if (!class_exists("nxs_snapClassBG")) { class nxs_snapClassBG { var $ntInfo = array('code'=>'BG', 'lcode'=>'bg', 'name'=>'Blogger', 'defNName'=>'ulName', 'tstReq' => true);
6
- //#### Show Common Settings
7
- function showGenNTSettings($ntOpts){ global $nxs_snapSetPgURL, $nxs_plurl, $nxs_gOptions; $ntInfo = $this->ntInfo;
8
- // V2 Auth
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  if ( isset($_GET['code']) && $_GET['code']!='' && isset($_GET['state']) && substr($_GET['state'], 0, 7) == 'nxs-bg-'){ $at = $_GET['code']; $ii = str_replace('nxs-bg-','',$_GET['state']);
10
  echo "----=={ oAuth 2.0 Wordflow }==----<br/>-= This is normal technical authorization info that will dissapear (Unless you get some errors) =- <br/><br/><br/>";
11
  $gGet = $_GET; unset($gGet['code']); unset($gGet['state']); unset($gGet['post_type']); unset($gGet['post']);
12
- $sturl = explode('?',$nxs_snapSetPgURL); $nxs_snapSetPgURL = $sturl[0].((!empty($gGet))?'?'.http_build_query($gGet):'');
13
-
14
- $nto = $ntOpts[$ii]; $wprg = array(); $wprg['sslverify'] = false;
15
- if (isset($nto['APIKey'])){ echo "-="; prr($nto);// die();
16
- $tknURL = 'https://www.googleapis.com/oauth2/v3/token?code='.$at.'&redirect_uri='.urlencode($nxs_snapSetPgURL).'&scope=&client_id='.$nto['APIKey'].'&client_secret='.$nto['APISec'].'&grant_type=authorization_code';
17
- $response = wp_remote_post($tknURL, $wprg); prr($tknURL);
18
  if((is_object($response)&&(isset($response->errors)))){ prr($response); die(); }
19
  if (is_array($response)&& stripos($response['body'],'"error":')!==false){ prr($response['body']); prr(json_decode($response['body'],true)); die(); }
20
  $resp = json_decode($response['body'], true); prr($resp); if (!is_array($resp) || empty($resp['access_token'])) { prr($resp); die(); }
21
  if (function_exists('get_option')) $currTime = time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); else $currTime = time();
22
- $nto['AccessToken'] = $resp['access_token']; $nto['AccessTokenSecret'] = 'No Need for oAuth V2'; $nto['OAuthVerifier'] = 'No Need for oAuth V2';
23
- $nto['AccessTokenExp'] = $currTime + $resp['expires_in']; $nto['RefreshToken'] = $resp['refresh_token']; echo "<br/>----=={ Expires: ".date('Y-m-d H:i:s', $nto['AccessTokenExp'])." }==---- <br/>";
24
 
25
- if (!empty($nto['bgBlogID'])){
26
- if (substr($nto['bgBlogID'], 0, 4)=='http') $tknURL = 'https://www.googleapis.com/blogger/v3/blogs/byurl/?url='.$nto['bgBlogID'].'?access_token='.$nto['AccessToken'];
27
- else $tknURL = 'https://www.googleapis.com/blogger/v3/blogs/'.$nto['bgBlogID'].'?access_token='.$nto['AccessToken'];
28
- }
29
-
30
- $response = wp_remote_get($tknURL, $wprg); prr($tknURL); prr($response); $user = json_decode($response['body'], true); prr($user);
31
-
32
- if (!empty($user['url'])) { $nto['blogURL'] = $user['url']; $nto['bgBlogID'] = $user['id']; $nto['blogInfo'] = $user['name']." [".$user['id']."] (".$user['url'].")";
33
- if (function_exists('get_option')) $nxs_gOptions = get_option('NS_SNAutoPoster'); if(!empty($nxs_gOptions)) { $nxs_gOptions['bg'][$ii] = $nto; prr($nto); nxs_settings_save($nxs_gOptions); }
34
  ?><script type="text/javascript">window.location = "<?php echo $nxs_snapSetPgURL; ?>"</script>
35
  <?php }
36
  }
37
  die();
38
- }
39
- ?>
40
- <div class="nxs_box">
41
- <div class="nxs_box_header">
42
- <div class="nsx_iconedTitle" style="margin-bottom:1px;background-image:url(<?php echo $nxs_plurl;?>img/<?php echo $ntInfo['lcode']; ?>16.png);"><?php echo $ntInfo['name']; ?>
43
- <?php $cbo = count($ntOpts); ?>
44
- <?php if ($cbo>1){ ?><div class="nsBigText"><?php echo "(".($cbo=='0'?'No':$cbo)." "; _e('accounts', 'social-networks-auto-poster-facebook-twitter-g'); echo ")"; ?></div><?php } ?>
45
- </div>
46
- </div>
47
- <div class="nxs_box_inside">
48
- <?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = !empty($pbo[$ntInfo['defNName']])?$pbo[$ntInfo['defNName']]:'Blogger';
49
- if (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='') $pbo[$ntInfo['lcode'].'OK'] = (isset($pbo['AccessToken']) && $pbo['AccessTokenSecret']!='')?'1':'';
50
- ?>
51
- <p style="margin:0px;margin-left:5px;"> <img id="<?php echo $ntInfo['code'].$indx;?>LoadingImg" style="display: none;" src='<?php echo $nxs_plurl; ?>img/ajax-loader-sm.gif' />
52
- <input value="0" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" type="hidden" />
53
- <?php if ((int)$pbo['do'.$ntInfo['code']] == 1 && isset($pbo['catSel']) && (int)$pbo['catSel'] == 1) { ?> <input type="radio" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" id="rbtn<?php echo $ntInfo['lcode'].$indx; ?>" value="1" checked="checked" onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);" /> <?php } else { ?>
54
- <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1 && $pbo['catSel']!='1') echo "checked"; ?> />
55
- <?php } ?>
56
- <?php if (isset($pbo['catSel']) && (int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
57
- <?php if (isset($pbo['rpstOn']) && (int)$pbo['rpstOn'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popReActive');" onmouseover="nxs_showPopUpInfo('popReActive', event);"><?php echo "*[R]*" ?></span><?php } ?>
58
- <strong><?php _e('Auto-publish to', 'social-networks-auto-poster-facebook-twitter-g'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
59
- &nbsp;&nbsp;<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'social-networks-auto-poster-facebook-twitter-g'); ?> ==&gt;</b><?php } ?> <?php if (!class_exists('nxsAPI_GP') && !empty($pbo['bgUName']) && empty($pbo['APIKey'])){ ?><b style="color: #800000"><?php _e('Attention requred. "ClientLogin" authentication method is no longer supported by Blogger', 'social-networks-auto-poster-facebook-twitter-g'); ?> ==&gt;</b><?php } ?> <a id="do<?php echo $ntInfo['code'].$indx; ?>AG" href="#" onclick="doGetHideNTBlock('<?php echo $ntInfo['code'];?>' , '<?php echo $indx; ?>');return false;">[<?php _e('Show Settings', 'social-networks-auto-poster-facebook-twitter-g'); ?>]</a>&nbsp;&nbsp;
60
- <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo addslashes($pbo['nName']); ?>');return false;">[<?php _e('Remove Account', 'social-networks-auto-poster-facebook-twitter-g'); ?>]</a>
61
- </p><div id="nxsNTSetDiv<?php echo $ntInfo['code'].$indx; ?>"></div><?php //$pbo['ntInfo'] = $ntInfo; $this->showNTSettings($indx, $pbo);
62
- }?>
63
- </div>
64
- </div> <?php
65
- }
66
- //#### Show NEW Settings Page
67
- function showNewNTSettings($bo){ $po = array('nName'=>'', 'ulName'=>'', 'bgPass'=>'', 'grpID'=>'', 'uPage'=>'', 'doBG'=>'1', 'APIKey'=>'', 'bgBlogID'=>'', 'APISec'=>'', 'userInfo'=>'', 'OAuthToken'=>'', 'msgFormat'=>'New post has been published on %SITENAME%', 'msgFormatT'=>'New post - %TITLE%' ); $po['ntInfo']= array('lcode'=>'bg'); $this->showNTSettings($bo, $po, true);}
68
- //#### Show Unit Settings
69
- function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl,$nxs_snapSetPgURL; $nt = $options['ntInfo']['lcode']; $ntU = strtoupper($nt); if (!isset($options['bgOK'])) $options['bgOK'] = '';
70
 
71
- 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'] = '';
72
- if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; if (!isset($options['msgAFrmt'])) $options['msgAFrmt'] = '';
73
- if (empty($options['apiToUse'])) { if (!empty($options['APIKey'])) $options['apiToUse'] = 'bg'; if (!empty($options['bgUName']) && !empty($options['bgPass'])) $options['apiToUse'] = 'nx'; } ?>
74
- <div id="doBG<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>"> <input type="hidden" name="apDoSBG<?php echo $ii; ?>" value="0" id="apDoSBG<?php echo $ii; ?>" />
75
- <?php if ($isNew) { ?> <input type="hidden" name="bg[<?php echo $ii; ?>][apDoBG]" value="1" id="apDoNewBG<?php echo $ii; ?>" /> <?php } ?>
76
- <div id="doBG<?php echo $ii; ?>Div" style="margin-left: 10px;">
77
-
78
- <div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/bg16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-blogger-social-networks-auto-poster-wordpress/"><?php $nType="Blogger"; printf( __( 'Detailed %s Installation/Configuration Instructions' , 'social-networks-auto-poster-facebook-twitter-g'), $nType); ?></a></div>
79
-
80
- <div style="width:100%;"><strong><?php _e('Account Nickname', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'social-networks-auto-poster-facebook-twitter-g'); ?></i> </div><input name="bg[<?php echo $ii; ?>][nName]" id="bgnName<?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")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /><br/>
81
- <?php echo nxs_addQTranslSel('bg', $ii, $options['qTLng']); ?>
82
-
83
- <br/>
84
- <ul class="nsx_tabs">
85
- <li><a href="#nsx<?php echo $nt.$ii ?>_tab1"><?php _e('Account Info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li>
86
- <?php if (!$isNew) { ?> <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li> <?php } ?>
87
- </ul>
88
- <div class="nsx_tab_container"><?php /* ######################## Account Tab ####################### */ ?>
89
- <div id="nsx<?php echo $nt.$ii ?>_tab1" class="nsx_tab_content" style="background-image: url(<?php echo $nxs_plurl; ?>img/<?php echo $nt; ?>-bg.png); background-repeat: no-repeat; background-position:90% 10%;">
90
-
91
- <?php if (!class_exists('nxsAPI_GP') && !empty($options['bgUName']) && empty($options['APIKey'])){ ?> <span style="color: red;">Blogger has <a style="color: red;" target="_blank" href="https://developers.google.com/identity/protocols/AuthForInstalledApps">discontinued support for "ClientLogin" authentication method</a>. This account should be removed and re-added with oAuth authentication method or upgraded to NextScripts API</span><br/></hr>
92
-
93
- <?php } ?>
94
-
95
- <div style="width:100%;"><strong>Blogger Blog ID:</strong>
96
- <p style="font-size: 11px; margin: 0px;"><?php _e('Log to your Blogger management panel and look at the URL of your blog: http://www.blogger.com/blogger.g?blogID=8959085979163812093#allposts. Your Blog ID will be: 8959085979163812093', 'social-networks-auto-poster-facebook-twitter-g'); ?></p>
97
- </div><input name="bg[<?php echo $ii; ?>][bgBlogID]" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['bgBlogID'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /> <br/><br/>
98
-
99
  <div style="display: <?php echo (empty($options['apiToUse']))?"block":"none"; ?>;">
100
- <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>
101
- <span style="color:#005800; font-weight: bold; font-size: 14px;">Blogger Native API:</span> Free built-in API from Blogger. More secure, more stable. More complicated - <b style="color: red;">requires approval of access to API by Google (3-5 days)</b> and authorization. <br/><br/>
102
- <span style="color:#005800; font-weight: bold; font-size: 14px;">NextScripts API for Blogger:</span> Premium API with extended functionality. Easier to configure, but less secure - requires your password.<br/><br/>
103
 
104
- <select name="bg[<?php echo $ii; ?>][apiToUse]" onchange="if (jQuery(this).val()=='bg') { jQuery('.nxs_bg_nxapi_<?php echo $ii; ?>').hide(); jQuery('.nxs_bg_bgapi_<?php echo $ii; ?>').show(); }else { jQuery('.nxs_bg_bgapi_<?php echo $ii; ?>').hide(); jQuery('.nxs_bg_nxapi_<?php echo $ii; ?>').show(); }"><option <?php echo (empty($options['apiToUse']) || $options['apiToUse'] =='bg')?"selected":""; ?> value="bg">Blogger API</option><option <?php echo (!empty($options['apiToUse']) && $options['apiToUse'] =='nx')?"selected":""; ?> value="nx">NextScripts API</option></select><hr/>
105
 
106
  </div>
107
 
108
- <div id="nxsAPIBG<?php echo $ii; ?>" class="nxs_bg_bgapi_<?php echo $ii; ?>" style="display: <?php echo (empty($options['apiToUse']) || $options['apiToUse'] =='bg')?"block":"none"; ?>;"><h3>Blogger API</h3>
109
-
110
- <div class="subDiv" id="sub<?php echo $ii; ?>DivL" style="display: block;">
111
-
112
- <div style="width:100%;"><strong>Client ID:</strong> </div><input name="bg[<?php echo $ii; ?>][APIKey]" style="width: 70%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['APIKey'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />
113
- <div style="width:100%;"><strong>Client Secret:</strong> </div><input name="bg[<?php echo $ii; ?>][APISec]" id="APISec" style="width: 70%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['APISec'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />
114
- <br/><br/>
115
- <?php
116
- if($options['APIKey']=='') { ?>
117
- <b>Authorize Your Blogger Account</b>. Please save your settings and come back here to Authorize your account.
118
- <?php } else { if(isset($options['AccessToken']) && isset($options['AccessTokenSecret']) && $options['AccessTokenSecret']!=='') { ?>
119
- Your Blogger Account has been authorized. <br/>Blog ID: <?php _e(apply_filters('format_to_edit', $options['blogInfo']), 'social-networks-auto-poster-facebook-twitter-g') ?>.
120
- <br/>You can Re- <?php } ?>
121
-
122
- <a href="https://accounts.google.com/o/oauth2/auth?redirect_uri=<?php echo trim(urlencode($nxs_snapSetPgURL));?>&response_type=code&client_id=<?php echo trim($options['APIKey']);?>&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fblogger&approval_prompt=force&access_type=offline&state=<?php echo 'nxs-bg-'.$ii; ?>">Authorize Your Blogger Account</a>
123
-
124
-
125
- <?php if (empty($options['AccessTokenSecret'])) { ?> <div class="blnkg">&lt;=== Authorize your account ===</div> <?php } ?>
126
-
127
- <?php } ?>
128
- </div>
129
- </div>
130
- <div id="nxsAPINX<?php echo $ii; ?>" class="nxs_bg_nxapi_<?php echo $ii; ?>" style="display: <?php echo (!empty($options['apiToUse']) && $options['apiToUse'] =='nx')?"block":"none"; ?>;"><h3>NextScripts API</h3>
131
-
132
- <?php if (class_exists('nxsAPI_GP')) { ?>
133
-
134
- <div class="subDiv" id="sub<?php echo $ii; ?>DivN" style="display: block;">
135
- <div style="width:100%;"><strong>Your Blogger Username/Email:</strong> </div><input name="bg[<?php echo $ii; ?>][bgUName]" style="width: 70%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['bgUName'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />
136
- <div style="width:100%;"><strong>Your Blogger Password:</strong> </div><input autocomplete="false" readonly onfocus="this.removeAttribute('readonly');" type="password" name="bg[<?php echo $ii; ?>][bgPass]" style="width: 75%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['bgPass'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />
137
-
138
- </div>
139
- <?php } else { nxs_show_noLibWrn('"NextScripts API Library for Blogger" is NOT installed'); } ?>
140
- </div>
141
- <br/><hr/>
142
- <div style="width:100%;"><strong id="altFormatText"><?php _e('Post Title Format', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> (<a href="#" id="apBGTMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apBGTMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>)</div>
143
-
144
- <input name="bg[<?php echo $ii; ?>][apBGMsgTFrmt]" id="apBGMsgTFrmt" style="width: 50%;" value="<?php if ($options['bgMsgTFormat']!='') _e(apply_filters('format_to_edit', htmlentities($options['bgMsgTFormat'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g'); else echo "%TITLE%"; ?>" onfocus="mxs_showFrmtInfo('apBGTMsgFrmt<?php echo $ii; ?>');" /><?php nxs_doShowHint("apBGTMsgFrmt".$ii); ?><br/>
145
-
146
- <div id="altFormat" style="">
147
- <div style="width:100%;"><strong id="altFormatText"><?php _e('Post Text Format', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> (<a href="#" id="apBGMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apBGMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>)
148
-
149
- <!--
150
- HTML is <?php if(!function_exists('doPostToGooglePlus')) {?> <b>NOT</b> <?php } ?> allowed. <?php if(!function_exists('doPostToGooglePlus')) {?> <i>- Blogger "Free API" limitation. Please get <a href="http://www.nextscripts.com/google-plus-automated-posting/#blogger">NextScripts API</a> to allow HTML</i> <?php } ?> -->
151
- </div>
152
-
153
- <textarea cols="150" rows="3" id="bg<?php echo $ii; ?>SNAPformat" name="bg[<?php echo $ii; ?>][apBGMsgFrmt]" style="width:51%;max-width: 650px;" onfocus="jQuery('#bg<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('apBGMsgFrmt<?php echo $ii; ?>');"><?php if ($options['bgMsgFormat']!='') _e(apply_filters('format_to_edit',htmlentities($options['bgMsgFormat'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g'); else echo "%FULLTEXT% <br/><a href='%URL%'>%TITLE%</a>"; ?></textarea>
154
-
155
- <?php nxs_doShowHint("apBGMsgFrmt".$ii, __('HTML is allowed', 'social-networks-auto-poster-facebook-twitter-g')); ?>
156
- </div>
157
-
158
- <p style="margin-bottom: 20px;margin-top: 5px;"><input value="1" id="bgInclTags" type="checkbox" name="bg[<?php echo $ii; ?>][bgInclTags]" <?php if ((int)$options['bgInclTags'] == 1) echo "checked"; ?> />
159
- <strong><?php _e('Post with tags', 'social-networks-auto-poster-facebook-twitter-g'); ?></strong> <?php _e('Tags from the blogpost will be auto-posted to Blogger/Blogspot', 'social-networks-auto-poster-facebook-twitter-g'); ?>
160
- </p>
161
-
162
- <?php if (!empty($options['bgPass']) || !empty($options['AccessToken'])) { ?>
163
-
164
- <b><?php _e('Test your settings', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</b>&nbsp;&nbsp;&nbsp; <?php if (!isset($options['bgOK']) || $options['bgOK']!='1') { ?> <div class="blnkg">=== <?php _e('Submit Test Post to Finish Configuration', 'social-networks-auto-poster-facebook-twitter-g'); ?> ===&gt;</div> <?php } ?> <a href="#" class="NXSButton" onclick="testPost('BG', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?></a>
165
- <?php } ?>
166
-
167
- </div>
168
-
169
- <?php /* ######################## Advanced Tab ####################### */ ?>
170
- <?php if (!$isNew) { ?> <div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content">
171
 
172
- <?php nxs_showCatTagsCTFilters($nt, $ii, $options);
173
- nxs_addPostingDelaySelV3($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']);
174
- nxs_showRepostSettings($nt, $ii, $options); ?>
175
-
176
-
177
- </div> <?php } ?> <?php /* #### End of Tab #### */ ?>
178
- </div><br/> <?php /* #### End of Tabs #### */ ?>
179
 
180
- <div class="submitX nxclear" style="padding-bottom: 0px;"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'social-networks-auto-poster-facebook-twitter-g') ?>" /></div>
181
-
182
- </div>
183
- </div>
184
- <?php
185
-
186
-
187
  }
188
- //#### Set Unit Settings from POST
189
- function setNTSettings($post, $options){ $code = $this->ntInfo['code'];
190
- foreach ($post as $ii => $pval){// prr($pval);
191
- if ( (!empty($pval['APISec']) && !empty($pval['APIKey'])) || (!empty($pval['bgUName']) && !empty($pval['bgPass'])) ) { if (!isset($options[$ii])) $options[$ii] = array();
192
-
193
- if (isset($pval['apDoBG'])) $options[$ii]['doBG'] = $pval['apDoBG']; else $options[$ii]['doBG'] = 0;
194
-
195
- if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']); else $options[$ii]['catSel'] = 0;
196
- if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
197
-
198
- if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']);
199
- if (isset($pval['bgUName'])) $options[$ii]['bgUName'] = trim($pval['bgUName']);
200
- if (isset($pval['bgPass'])) $options[$ii]['bgPass'] = 'b4d7s'.nsx_doEncode($pval['bgPass']); else $options[$ii]['bgPass'] = '';
201
-
202
- if (isset($pval['APIKey'])) $options[$ii]['APIKey'] = trim($pval['APIKey']);
203
- if (isset($pval['APISec'])) $options[$ii]['APISec'] = trim($pval['APISec']);
204
-
205
- if (isset($pval['bgBlogID'])) $options[$ii]['bgBlogID'] = trim($pval['bgBlogID']);
206
- if (isset($pval['apBGMsgFrmt'])) $options[$ii]['bgMsgFormat'] = trim($pval['apBGMsgFrmt']);
207
- if (isset($pval['apBGMsgTFrmt'])) $options[$ii]['bgMsgTFormat'] = trim($pval['apBGMsgTFrmt']);
208
- if (isset($pval['bgInclTags'])) $options[$ii]['bgInclTags'] = $pval['bgInclTags']; else $options[$ii]['bgInclTags'] = 0;
209
-
210
- $options[$ii] = nxs_adjRpst($options[$ii], $pval);
211
-
212
- if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']);
213
- if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
214
- if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
215
-
216
- } elseif ( count($pval)==1 ) if (isset($pval['apDo'.$code])) $options[$ii]['do'.$code] = $pval['apDo'.$code]; else $options[$ii]['do'.$code] = 0;
217
  } return $options;
218
- }
 
219
  //#### Show Post->Edit Meta Box Settings
220
- function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID; $nt = 'bg'; $ntU = 'BG';
221
- foreach($ntOpts as $ii=>$ntOpt){ $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapBG', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
222
- if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = '';
223
- $doBG = $ntOpt['doBG'] && (is_array($pMeta) || $ntOpt['catSel']!='1'); $imgToUse = $ntOpt['imgToUse']; $isAvailBG = (!empty($ntOpt['bgUName']) && !empty($ntOpt['bgPass'])) || !empty($ntOpt['AccessToken']);
224
- $bgMsgFormat = htmlentities($ntOpt['bgMsgFormat'], ENT_COMPAT, "UTF-8"); $bgMsgTFormat = htmlentities($ntOpt['bgMsgTFormat'], ENT_COMPAT, "UTF-8");
225
- ?>
226
-
227
- <tr><th style="text-align:left;" colspan="2">
228
- <?php if ($ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='') { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
229
- <?php if (!empty($ntOpt['tagsSel'])) { ?> <input type="hidden" class="nxs_TG" id="nxs_TG_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $ntOpt['tagsSel']; ?>" /> <?php } ?>
230
- <?php if ($isAvailBG) { ?><input class="nxsGrpDoChb" value="1" id="doBG<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="bg[<?php echo $ii; ?>][doBG]" <?php if ((int)$doBG == 1) echo 'checked="checked" title="def"'; ?> /> <?php if ($post->post_status == "publish") { ?> <input type="hidden" name="bg[<?php echo $ii; ?>][doBG]" value="<?php echo $doBG;?>"> <?php } ?> <?php } ?>
231
- <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/bg16.png);">Blogger - <?php _e('publish to', 'social-networks-auto-poster-facebook-twitter-g') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td style="min-width: 180px; width: 350px;" ><?php //## Only show RePost button if the post is "published"
232
- if ($post->post_status == "publish" && $isAvailBG) { ?>
233
- <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', 'social-networks-auto-poster-facebook-twitter-g') ?>" />
234
- <?php } ?>
235
-
236
- <?php if (is_array($pMeta) && !empty($pMeta[$ii]) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
237
- ?> <span id="pstdBG<?php echo $ii; ?>" style="float: right; padding-top: 4px; padding-right: 10px;">
238
- <a style="font-size: 10px;" href="<?php echo $pMeta[$ii]['pgID']; ?>" target="_blank"><?php $nType="Blogger"; printf( __( 'Posted on', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?><?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
239
- </span><?php } ?>
240
-
241
- </td></tr>
242
- <?php if (!$isAvailBG) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b><?php _e('Setup your Blogger Account to AutoPost to Blogger', 'social-networks-auto-poster-facebook-twitter-g') ?></b>
243
- <?php } else { if ($post->post_status != "publish" && function_exists('nxs_doSMAS5') ) { $ntOpt['postTime'] = get_post_time('U', false, $post_id); nxs_doSMAS5($nt, $ii, $ntOpt); } ?>
244
-
245
- <?php if ($ntOpt['rpstOn']=='1') { ?>
246
-
247
- <tr id="altFormat1" style=""><th scope="row" class="nxsTHRow">
248
- <input value="0" type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]"/><input value="nxsi<?php echo $ii; ?>bg" type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]" <?php if (!empty($ntOpt['rpstPostIncl'])) echo "checked"; ?> />
249
- </th>
250
- <td> <?php _e('Include in "Auto-Reposting" to this network.', 'social-networks-auto-poster-facebook-twitter-g') ?>
251
- </td></tr> <?php } ?>
252
-
253
- <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Title Format:', 'NS_SPAP') ?></th>
254
- <td><input class="nxs_postEditCtrl" value="<?php echo $bgMsgTFormat ?>" type="text" name="bg[<?php echo $ii; ?>][SNAPTformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apBGTMsgFrmt<?php echo $ii; ?>');" onchange="nxs_svPostStAjax(this)"/><?php nxs_doShowHint("apBGTMsgFrmt".$ii, '', '58'); ?></td></tr>
255
- <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Message Format:', 'NS_SPAP') ?></th>
256
- <td>
257
- <textarea class="nxs_postEditCtrl" cols="150" rows="1" id="bg<?php echo $ii; ?>SNAPformat" name="bg[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('#bg<?php echo $ii; ?>SNAPformat').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apBGMsgFrmt<?php echo $ii; ?>');"><?php echo $bgMsgFormat; ?></textarea>
258
- <?php nxs_doShowHint("apBGMsgFrmt".$ii, '', '58'); ?></td></tr>
259
- <?php }
260
- }
261
  }
262
 
263
- function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
264
- if (isset($pMeta['SNAPformat'])) $optMt['bgMsgFormat'] = $pMeta['SNAPformat']; if (isset($pMeta['imgToUse'])) $optMt['imgToUse'] = $pMeta['imgToUse'];
265
- if (isset($pMeta['timeToRun'])) $optMt['timeToRun'] = $pMeta['timeToRun']; if (isset($pMeta['rpstPostIncl'])) $optMt['rpstPostIncl'] = $pMeta['rpstPostIncl'];
266
- if (isset($pMeta['SNAPTformat'])) $optMt['bgMsgTFormat'] = $pMeta['SNAPTformat'];
267
- if (isset($pMeta['doBG'])) $optMt['doBG'] = $pMeta['doBG'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doBG'] = 0; }
268
- if (isset($pMeta['SNAPincludeBG']) && $pMeta['SNAPincludeBG'] == '1' ) $optMt['doBG'] = 1;
269
- return $optMt;
270
  }
 
 
 
 
 
 
 
 
271
  }}
272
 
273
- if (!function_exists("nxs_rePostToBG_ajax")) { function nxs_rePostToBG_ajax() { check_ajax_referer('nxsSsPageWPN'); $postID = $_POST['id']; // $result = nsPublishTo($id, 'FB', true);
274
- global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
275
- foreach ($options['bg'] as $ii=>$po) if ($ii==$_POST['nid']) { $po['ii'] = $ii; $po['pType'] = 'aj';
276
- $mpo = get_post_meta($postID, 'snapBG', true); $mpo = maybe_unserialize($mpo);
277
- if (is_array($mpo) && isset($mpo[$ii]) && is_array($mpo[$ii]) ){ $ntClInst = new nxs_snapClassBG(); $po = $ntClInst->adjMetaOpt($po, $mpo[$ii]); }
278
- $result = nxs_doPublishToBG($postID, $po); if ($result === 200) nxs_save_glbNtwrks('bg', $ii, 1, 'bgOK');
279
- if ($result == 200) die("Successfully sent your post to Blogger."); else die($result);
280
- }
281
- }
282
- }
283
-
284
- if (!function_exists("nxs_doPublishToBG")) { //## Second Function to Post to BG
285
- function nxs_doPublishToBG($postID, $options){ $ntCd = 'BG'; $ntCdL = 'bg'; $ntNm = 'Blogger'; if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
286
- //$backtrace = debug_backtrace(); nxs_addToLogN('W', 'Enter', $ntCd, 'I am here - '.$ntCd."|".print_r($backtrace, true), '');
287
- // if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToBG', array($postID, $options));
288
- $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url();
289
- $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'ACCNAME'=>$options['nName'], 'POSTID'=>$postID));
290
- $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
291
- $logNT = '<span style="color:#F87907">'.$ntNm.'</span> - '.$options['nName'];
292
- $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
293
- if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
294
- $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') {
295
- nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'); return;
296
- }
297
- }
298
-
299
- if ($postID=='0') { echo "Testing ... <br/><br/>"; $options['bgMsgTFormat'] = 'Test Post from '.htmlentities($blogTitle); $link = home_url(); $options['bgMsgFormat'] = 'Test Post from '.$blogTitle. ' <a href="'.$link.'">'.$link.'</a>'; }
300
- else { $post = get_post($postID); if(!$post) return; $options['bgMsgFormat'] = nsFormatMessage($options['bgMsgFormat'], $postID, $addParams);
301
- $options['bgMsgTFormat'] = nsFormatMessage($options['bgMsgTFormat'], $postID, $addParams); nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
302
- }
303
- $extInfo = ' | PostID: '.$postID." - ".(isset($post) && is_object($post)?$post->post_title:'');
304
- //## Actual POST Code
305
- if ($options['bgInclTags']=='1'){$t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = implode('","',$tggs); $tags = nsTrnc($tags, 195, ',', ''); }
306
- if (substr($tags, -1)=='"') $tags = substr($tags, 0, -1); if (substr($tags, -1)==',') $tags = substr($tags, 0, -1); if (substr($tags, -1)=='"') $tags = substr($tags, 0, -1);
307
- //## Set Message
308
- $message = array('title'=>'', 'announce'=>'', 'text'=>'', 'url'=>'', 'surl'=>'', 'urlDescr'=>'', 'urlTitle'=>'', 'imageURL' => array(), 'videoCode'=>'', 'videoURL'=>'', 'siteName'=>$blogTitle, 'tags'=>$tags, 'cats'=>'', 'authorName'=>'');
309
- //## Actual Post
310
- $ntToPost = new nxs_class_SNAP_BG(); $ret = $ntToPost->doPostToNT($options, $message);
311
- //## Process Results
312
- if (!is_array($ret) || $ret['isPosted']!='1') { //## Error
313
- if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);
314
- } else { // ## All Good - log it.
315
- if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo _e('OK - Message Posted, please see your '.$logNT.' Page. ', 'social-networks-auto-poster-facebook-twitter-g'); }
316
- else { nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPosted'=>'1', 'pgID'=>$ret['postID'], 'pDate'=>date('Y-m-d H:i:s')));
317
- $extInfo .= ' | <a href="'.$ret['postURL'].'" target="_blank">Post Link</a>'; nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); }
318
- }
319
- //## Return Result
320
- if (!empty($ret['isPosted']) && $ret['isPosted']=='1') return 200; else return print_r($ret, true);
321
- }
322
- }
323
 
324
- ?>
1
  <?php
2
  //## NextScripts Blogger Connection Class
3
+ $nxs_snapAvNts[] = array('code'=>'BG', 'lcode'=>'bg', 'name'=>'Blogger', 'type'=>'Blogs/Publishing Platforms', 'ptype'=>'B', 'status'=>'A', 'desc'=>'Autopost to your blog. HTML is supported');
4
 
5
+ if (!class_exists("nxs_snapClassBG")) { class nxs_snapClassBG extends nxs_snapClassNT {
6
+ var $ntInfo = array('code'=>'BG', 'lcode'=>'bg', 'name'=>'Blogger', 'defNName'=>'', 'tstReq' => true, 'instrURL'=>'http://www.nextscripts.com/setup-installation-blogger-social-networks-auto-poster-wordpress/');
7
+ //#### Update
8
+ function toLatestVer($ntOpts){ if( !empty($ntOpts['v'])) $v = $ntOpts['v']; else $v = 340; $ntOptsOut = ''; switch ($v) {
9
+ case 340: $ntOptsOut = $this->toLatestVerNTGen($ntOpts); $ntOptsOut['do'] = $ntOpts['do'.$this->ntInfo['code']]; $ntOptsOut['nName'] = $ntOpts['nName']; $ntOptsOut['blogID'] = $ntOpts['bgBlogID'];
10
+ if (empty($ntOpts['apiToUse'])) { if (!empty($ntOpts['APIKey'])) $ntOpts['apiToUse'] = 'bg'; if (!empty($ntOpts['bgUName']) && !empty($ntOpts['bgPass'])) $ntOpts['apiToUse'] = 'nx'; } $ntOptsOut['apiToUse'] = $ntOpts['apiToUse'];
11
+ if ($ntOptsOut['apiToUse']=='nx') { $ntOptsOut['uName'] = $ntOpts['bgUName']; $ntOptsOut['uPass'] = $ntOpts['bgPass']; } else { $ntOptsOut['appKey'] = $ntOpts['APIKey']; $ntOptsOut['appSec'] = $ntOpts['APISec'];
12
+ $ntOptsOut['accessToken'] = $ntOpts['AccessToken']; $ntOptsOut['accessTokenSec'] = $ntOpts['AccessTokenSecret']; $options['refreshToken'] = $options['RefreshToken']; $options['accessTokenExp'] = $options['AccessTokenExp']; $ntOptsOut['blogInfo'] = $ntOpts['blogInfo'];
13
+ } $ntOptsOut['inclTags'] = $ntOpts['bgInclTags']; $ntOptsOut['msgFormat'] = $ntOpts['bgMsgFormat']; $ntOptsOut['msgTFormat'] = $ntOpts['bgMsgTFormat']; $ntOptsOut['blogInfo'] = $ntOpts['blogInfo']; $ntOptsOut['blogURL'] = $ntOpts['blogURL'];
14
+ $ntOptsOut['isUpdd'] = '1'; $ntOptsOut['v'] = NXS_SETV;
15
+ break;
16
+ }
17
+ return !empty($ntOptsOut)?$ntOptsOut:$ntOpts;
18
+ }
19
+ //#### Show Common Settings
20
+ function showGenNTSettings($ntOpts){ $this->nt = $ntOpts; $this->showNTGroup(); }
21
+ //#### Show NEW Settings Page
22
+ function showNewNTSettings($ii){ $defO = array('nName'=>'', 'do'=>'1', 'blogID'=>'', 'appKey'=>'', 'appSec'=>'', 'uName'=>'', 'uPass'=>'', 'inclTags'=>1, 'msgFormat'=>"%RAWTEXT%", 'msgTFormat'=>"%TITLE%", 'imgSize'=>'original'); $this->showGNewNTSettings($ii, $defO); }
23
+ //#### Show Unit Settings
24
+ function checkIfSetupFinished($options) { return !empty($options['accessToken']) || !empty($options['uPass']); }
25
+ public function doAuth() { $ntInfo = $this->ntInfo; global $nxs_snapSetPgURL;
26
  if ( isset($_GET['code']) && $_GET['code']!='' && isset($_GET['state']) && substr($_GET['state'], 0, 7) == 'nxs-bg-'){ $at = $_GET['code']; $ii = str_replace('nxs-bg-','',$_GET['state']);
27
  echo "----=={ oAuth 2.0 Wordflow }==----<br/>-= This is normal technical authorization info that will dissapear (Unless you get some errors) =- <br/><br/><br/>";
28
  $gGet = $_GET; unset($gGet['code']); unset($gGet['state']); unset($gGet['post_type']); unset($gGet['post']);
29
+ $sturl = explode('?',$nxs_snapSetPgURL); $nxs_snapSetPgURL = $sturl[0].((!empty($gGet))?'?'.http_build_query($gGet):'');
30
+ $options = $this->nt[$ii]; $wprg = array(); $wprg['sslverify'] = false;
31
+ if (isset($options['appKey'])){ echo "-="; prr($options);// die();
32
+ $tknURL = 'https://www.googleapis.com/oauth2/v3/token?code='.$at.'&redirect_uri='.urlencode($nxs_snapSetPgURL).'&scope=&client_id='.$options['appKey'].'&client_secret='.$options['appSec'].'&grant_type=authorization_code';
33
+ $response = nxs_remote_post($tknURL, $wprg); prr($tknURL);
 
34
  if((is_object($response)&&(isset($response->errors)))){ prr($response); die(); }
35
  if (is_array($response)&& stripos($response['body'],'"error":')!==false){ prr($response['body']); prr(json_decode($response['body'],true)); die(); }
36
  $resp = json_decode($response['body'], true); prr($resp); if (!is_array($resp) || empty($resp['access_token'])) { prr($resp); die(); }
37
  if (function_exists('get_option')) $currTime = time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); else $currTime = time();
38
+ $options['accessToken'] = $resp['access_token']; $options['accessTokenSec'] = 'No Need for oAuth V2';
39
+ $options['accessTokenExp'] = $currTime + $resp['expires_in']; $options['refreshToken'] = $resp['refresh_token']; echo "<br/>----=={ Expires: ".date('Y-m-d H:i:s', $options['accessTokenExp'])." }==---- <br/>";
40
 
41
+ if (!empty($options['blogID'])){
42
+ if (substr($options['blogID'], 0, 4)=='http') $tknURL = 'https://www.googleapis.com/blogger/v3/blogs/byurl/?url='.$options['blogID'].'?access_token='.$options['accessToken'];
43
+ else $tknURL = 'https://www.googleapis.com/blogger/v3/blogs/'.$options['blogID'].'?access_token='.$options['accessToken'];
44
+ }
45
+ $response = nxs_remote_get($tknURL, $wprg); prr($tknURL); prr($response); $user = json_decode($response['body'], true); prr($user);
46
+ if (!empty($user['url'])) { $options['blogURL'] = $user['url']; $options['blogID'] = $user['id']; $options['blogInfo'] = $user['name']." [".$user['id']."] (".$user['url'].")"; nxs_save_glbNtwrks($ntInfo['lcode'],$ii,$options,'*');
 
 
 
47
  ?><script type="text/javascript">window.location = "<?php echo $nxs_snapSetPgURL; ?>"</script>
48
  <?php }
49
  }
50
  die();
51
+ }
52
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
 
54
+ function accTab($ii, $options, $isNew=false){ global $nxs_snapSetPgURL; $ntInfo = $this->ntInfo; $nt = $ntInfo['lcode'];?>
55
+ <div style="width:100%;"><strong><?php _e('Blogger Blog ID', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong><i><?php _e('Log to your Blogger management panel and look at the URL of your blog: http://www.blogger.com/blogger.g?blogID=8959085979163812093#allposts. Your Blog ID will be: 8959085979163812093', 'social-networks-auto-poster-facebook-twitter-g'); ?></i></div><input name="<?php echo $nt; ?>[<?php echo $ii; ?>][blogID]" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['blogID'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /><br/><br/>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  <div style="display: <?php echo (empty($options['apiToUse']))?"block":"none"; ?>;">
57
+ <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>
58
+ <span style="color:#005800; font-weight: bold; font-size: 14px;">Blogger Native API:</span> Free built-in API from Blogger. More secure, more stable. More complicated - <b style="color: red;">requires approval of access to API by Google (3-5 days)</b> and authorization. <br/><br/>
59
+ <span style="color:#005800; font-weight: bold; font-size: 14px;">NextScripts API for Blogger:</span> Premium API with extended functionality. Easier to configure, but less secure - requires your password.<br/><br/>
60
 
61
+ <select name="<?php echo $nt; ?>[<?php echo $ii; ?>][apiToUse]" onchange="if (jQuery(this).val()=='<?php echo $nt; ?>') { jQuery('.nxs_<?php echo $nt; ?>_nxapi_<?php echo $ii; ?>').hide(); jQuery('.nxs_<?php echo $nt; ?>_bgapi_<?php echo $ii; ?>').show(); }else { jQuery('.nxs_<?php echo $nt; ?>_bgapi_<?php echo $ii; ?>').hide(); jQuery('.nxs_<?php echo $nt; ?>_nxapi_<?php echo $ii; ?>').show(); }"><option <?php echo (empty($options['apiToUse']) || $options['apiToUse'] =='bg')?"selected":""; ?> value="bg">Blogger API</option><option <?php echo (!empty($options['apiToUse']) && $options['apiToUse'] =='nx')?"selected":""; ?> value="nx">NextScripts API</option></select><hr/>
62
 
63
  </div>
64
 
65
+ <div id="nxsAPIBG<?php echo $ii; ?>" class="nxs_<?php echo $nt; ?>_bgapi_<?php echo $ii; ?>" style="display: <?php echo (empty($options['apiToUse']) || $options['apiToUse'] =='bg')?"block":"none"; ?>;"><h3>Blogger API</h3>
66
+ <div class="subDiv" id="sub<?php echo $ii; ?>DivL" style="display: block;"> <?php $this->elemKeySecret($ii,'Client ID','Client Secret', $options['appKey'], $options['appSec'],'appKey','appSec','https://console.developers.google.com/'); ?>
67
+ <br/><br/>
68
+ <?php if($options['appKey']=='') { ?>
69
+ <b><?php _e('Authorize Your '.$ntInfo['name'].' Account', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> <?php _e('Please click "Update Settings" to be able to Authorize your account.', 'social-networks-auto-poster-facebook-twitter-g');
70
+ } else { if(!empty($options['accessToken']) && !empty($options['accessTokenSec'])) {
71
+ _e('Your '.$ntInfo['name'].' Account has been authorized.', 'social-networks-auto-poster-facebook-twitter-g'); ?> <br/>Blog ID: <?php _e(apply_filters('format_to_edit', htmlentities($options['blogInfo'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g'); ?>.
72
+ <?php _e('You can', 'social-networks-auto-poster-facebook-twitter-g'); ?> Re- <?php } ?>
73
+ <a href="https://accounts.google.com/o/oauth2/auth?redirect_uri=<?php echo trim(urlencode($nxs_snapSetPgURL));?>&response_type=code&client_id=<?php echo trim($options['appKey']);?>&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fblogger&approval_prompt=force&access_type=offline&state=<?php echo 'nxs-bg-'.$ii; ?>">Authorize Your Blogger Account</a>
74
+ <?php if (empty($options['accessToken'])) { ?> <div class="blnkg">&lt;=== <?php _e('Authorize your account', 'social-networks-auto-poster-facebook-twitter-g'); ?> ===</div> <?php }
75
+ } ?><br/><br/>
76
+ </div>
77
+ </div>
78
+ <div id="nxsAPINX<?php echo $ii; ?>" class="nxs_bg_nxapi_<?php echo $ii; ?>" style="display: <?php echo (!empty($options['apiToUse']) && $options['apiToUse'] =='nx')?"block":"none"; ?>;"><h3>NextScripts API</h3>
79
+ <?php if (class_exists('nxsAPI_GP')) { ?>
80
+ <div class="subDiv" id="sub<?php echo $ii; ?>DivN" style="display: block;"><?php $this->elemUserPass($ii, $options['uName'], $options['uPass']); ?></div>
81
+ <?php } else { nxs_show_noLibWrn('"NextScripts API Library for Blogger" is NOT installed'); } ?>
82
+ </div><br/>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
 
84
+ <br/><?php $this->elemTitleFormat($ii,'Message Title Format','msgTFormat',$options['msgTFormat']); $this->elemMsgFormat($ii,'Message Format','msgFormat',$options['msgFormat']); ?>
85
+ <div style="margin: 0px;"><input value="1" type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][inclTags]" <?php if ((int)$options['inclTags'] == 1) echo "checked"; ?> /> <strong><?php _e('Post with tags', 'social-networks-auto-poster-facebook-twitter-g'); ?></strong></div>
 
 
 
 
 
86
 
87
+ <?php
 
 
 
 
 
 
88
  }
89
+ function advTab($ii, $options){}
90
+ //#### Set Unit Settings from POST
91
+ function setNTSettings($post, $options){
92
+ foreach ($post as $ii => $pval){
93
+ if (!empty($pval['blogID']) && !empty($pval['blogID'])){ if (!isset($options[$ii])) $options[$ii] = array(); $options[$ii] = $this->saveCommonNTSettings($pval,$options[$ii]);
94
+ //## Uniqe Items
95
+ if (isset($pval['inclTags'])) $options[$ii]['inclTags'] = trim($pval['inclTags']); else $options[$ii]['inclTags'] = 0;
96
+ if (isset($pval['apiToUse'])) $options[$ii]['apiToUse'] = trim($pval['apiToUse']);
97
+ if (isset($pval['blogID'])) $options[$ii]['blogID'] = trim($pval['blogID']);
98
+ } elseif ( count($pval)==1 ) if (isset($pval['do'])) $options[$ii]['do'] = $pval['do']; else $options[$ii]['do'] = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  } return $options;
100
+ }
101
+
102
  //#### Show Post->Edit Meta Box Settings
103
+
104
+ function showEdPostNTSettings($ntOpts, $post){ $post_id = $post->ID; $nt = $this->ntInfo['lcode']; $ntU = $this->ntInfo['code'];
105
+ foreach($ntOpts as $ii=>$ntOpt) { $isFin = $this->checkIfSetupFinished($ntOpt); if (!$isFin) continue;
106
+ $pMeta = maybe_unserialize(get_post_meta($post_id, 'snap'.$ntU, true)); if (is_array($pMeta) && !empty($pMeta[$ii])) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
107
+
108
+ if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = ''; if (empty($ntOpt['urlToUse'])) $ntOpt['urlToUse'] = ''; $postType = isset($ntOpt['postType'])?$ntOpt['postType']:'';
109
+ $msgFormat = !empty($ntOpt['msgFormat'])?htmlentities($ntOpt['msgFormat'], ENT_COMPAT, "UTF-8"):''; $msgTFormat = !empty($ntOpt['msgTFormat'])?htmlentities($ntOpt['msgTFormat'], ENT_COMPAT, "UTF-8"):'';
110
+ $imgToUse = $ntOpt['imgToUse']; $urlToUse = $ntOpt['urlToUse']; $ntOpt['ii']=$ii;
111
+
112
+ $this->nxs_tmpltAddPostMeta($post, $ntOpt, $pMeta);
113
+
114
+ $this->elemEdTitleFormat($ii, __('Title Format:', 'social-networks-auto-poster-facebook-twitter-g'),$msgTFormat);
115
+ $this->elemEdMsgFormat($ii, __('Message Format:', 'social-networks-auto-poster-facebook-twitter-g'),$msgFormat);
116
+
117
+ /* ## Select Image & URL ## */ nxs_showURLToUseDlg($nt, $ii, $urlToUse); $this->nxs_tmpltAddPostMetaEnd($ii);
118
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  }
120
 
121
+ //#### Save Meta Tags to the Post
122
+ function adjMetaOpt($optMt, $pMeta){ $optMt = $this->adjMetaOptG($optMt, $pMeta);
123
+ return $optMt;
 
 
 
 
124
  }
125
+
126
+ function adjPublishWP(&$options, &$message, $postID){
127
+ if (!empty($postID)) { if (trim($options['imgToUse'])!='') $imgURL = $options['imgToUse']; else $imgURL = nxs_getPostImage($postID, !empty($options['wpImgSize'])?$options['wpImgSize']:'full');
128
+ if (preg_match("/noImg.\.png/i", $imgURL)) { $imgURL = ''; $isNoImg = true; }
129
+ $message['imageURL'] = $imgURL;
130
+ }
131
+ }
132
+
133
  }}
134
 
135
+ if (!function_exists("nxs_doPublishToBG")) { function nxs_doPublishToBG($postID, $options){ if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true)); $cl = new nxs_snapClassBG(); $cl->nt[$options['ii']] = $options; return $cl->publishWP($options['ii'], $postID); }}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
 
137
+ ?>
inc-cl/da.api.php CHANGED
@@ -36,7 +36,7 @@ if (!class_exists('nxsAPI_DA')){class nxsAPI_DA{ var $ck = array(); var $mh = ''
36
  }
37
  function check(){ $ck = $this->ck; if (!empty($ck) && is_array($ck)) { $hdrsArr = $this->headers('https://www.deviantart.com'); if ($this->debug) echo "[DA] Checking....;<br/>\r\n";
38
  $rep = nxs_remote_get('https://www.deviantart.com', array('headers' => $hdrsArr, 'httpversion' => '1.1', 'cookies' => $ck));
39
- if (is_wp_error($rep)) { $badOut = print_r($rep, true)." - ERROR https://www.deviantart.com is not accessible. "; return $badOut; }
40
  $ck2 = $rep['cookies']; for($i=0;$i<count($ck);$i++) if ($ck[$i]->name=='userinfo') $ck[$i]->value = urlencode($ck2[0]->value); $this->ck = $ck;
41
  if (is_nxs_error($rep)) return false; $contents = $rep['body']; //if ($this->debug) prr($contents);
42
  $mh = CutFromTo($rep['body'], '$(\'#logoutme\').submit();">', 'data-ga_click_event'); $mh = CutFromTo($mh, 'href="', '"'); $this->mh = $mh;
@@ -46,30 +46,29 @@ if (!class_exists('nxsAPI_DA')){class nxsAPI_DA{ var $ck = array(); var $mh = ''
46
  function connect($u,$p){ $badOut = 'Error: ';
47
  //## Check if alrady IN
48
  if (!$this->check()){ if ($this->debug) echo "[DA] NO Saved Data;<br/>\r\n";
49
- $url = "https://www.deviantart.com/users/login"; $hdrsArr = $this->headers('http://www.deviantart.com/');
50
- $rep = wp_remote_get($url, array( 'headers' => $hdrsArr, 'httpversion' => '1.1')); if (is_wp_error($rep)) { $badOut = print_r($rep, true)." - ERROR Login 1"; return $badOut; } $ck = $rep['cookies'];
51
  $rTok = CutFromTo($rep['body'], 'name="validate_token" value="', '"'); $rKey = CutFromTo($rep['body'], 'name="validate_key" value="', '"'); $ck[0]->value = urlencode($ck[0]->value);
52
  $hdrsArr = $this->headers('https://www.deviantart.com/users/login', 'https://www.deviantart.com/', true);
53
  $flds = array('ref' => 'https://www.deviantart.com/users/loggedin', 'username' => $u, 'password' => $p, 'remember_me' => '1', 'validate_token' => $rTok, 'validate_key' => $rKey);
54
- $response = wp_remote_post( $url, array( 'method' => 'POST', 'httpversion' => '1.1', 'timeout' => 45, 'redirection' => 0, 'cookies' => $ck, 'headers' => $hdrsArr, 'body' => $flds));
55
- if (is_wp_error($response)) { $badOut = print_r($response, true)." - ERROR Login 2"; return $badOut; }
56
- $ck = $response['cookies']; for($i=0;$i<4;$i++) $ck[$i]->value = urlencode($ck[$i]->value);
57
  if (isset($response['headers']['location']) && stripos($response['headers']['location'], 'wrong-password')!==false ) { $badOut = "Wrong Password - ERROR"; return $badOut; }
58
  if (isset($response['headers']['location']) && ( $response['headers']['location']=='http://www.deviantart.com' || $response['headers']['location']=='https://www.deviantart.com/users/loggedin')) {
59
- $hdrsArr = $this->headers('http://www.deviantart.com'); $rep = wp_remote_get( 'http://www.deviantart.com', array( 'headers' => $hdrsArr, 'httpversion' => '1.1', 'cookies' => $ck));// die(); prr($rep);
60
- if (is_wp_error($rep)) { $badOut = print_r($rep, true)." - ERROR Login 3"; return $badOut; }
61
- $mh = CutFromTo($rep['body'], '$(\'#logoutme\').submit();">', 'data-ga_click_event'); $mh = CutFromTo($mh, 'href="', '"');
 
62
  $ck2 = $rep['cookies']; for($i=0;$i<count($ck);$i++) if ($ck[$i]->name=='userinfo') $ck[$i]->value = urlencode($ck2[0]->value); $this->ck = $ck; $this->mh = $mh; return false;
63
  } else $badOut = print_r($response, true)." - ERROR Login 4"; return $badOut;
64
  } else { if ($this->debug) echo "[DA] Saved Data is OK;<br/>\r\n"; return false; }
65
  }
66
- function post($post){ $ck = $this->ck; $mh = $this->mh; $hdrsArr = $this->headers('http://www.deviantart.com/'); $badOut = '';
67
- $advSets = array( 'headers' => $hdrsArr, 'cookies' => $ck); // prr($advSets);
68
- $rep = wp_remote_get( $mh.'/journal/?edit', $advSets); if (is_wp_error($rep)) { $badOut = print_r($rep, true)." - ERROR Post 1"; return $badOut; }
69
  $contents = CutFromTo($rep['body'], '<h3 class="journal-editor-create">', '</form>'); // prr($contents);
70
  $md = array(); while (stripos($contents, '"hidden"')!==false){$contents = substr($contents, stripos($contents, '"hidden"')+8); $name = trim(CutFromTo($contents,'name="', '"'));
71
- if (!in_array($name, $md)) { $md[] = $name; $val = trim(CutFromTo($contents,'value="', '"')); $flds[$name]= urldecode (nxs_decodeEntities($val)); }
72
- } $flds['subject'] = nsTrnc(nxs_decodeEntities($post['title']), 50); $flds['body'] = trim($post['text']); $flds['song'] = '';
73
  $flds['game'] = ''; $flds['book'] = ''; $flds['food'] = ''; $flds['movie'] = ''; $flds['drink'] = ''; $flds['flip'] = '0'; $flds['featured'] = '1';
74
  $flds['portal'] = '1'; $flds['skinlabel'] = 'No+skin'; $flds['jheader'] = ''; $flds['jcss'] = ''; $flds['jfooter'] = '';
75
  $ck2 = $rep['cookies']; for($i=0;$i<count($ck);$i++) if ($ck[$i]->name=='userinfo') $ck[$i]->value = urlencode($ck2[0]->value);
@@ -78,18 +77,17 @@ if (!class_exists('nxsAPI_DA')){class nxsAPI_DA{ var $ck = array(); var $mh = ''
78
  $pid = CutFromTo($contents, '"pageviewID":"','"'); $iid = CutFromTo($contents, '"requestid":"','"');
79
  $dflds = array('ui'=>$ui,'pid'=>$pid, 'iid'=>$iid.'-i7ex4avh-1.0','t'=>'json'); $dfldsq = http_build_query($dflds);
80
  $dfldsq1 = 'ui='.$ui.'&c%5B%5D=%22Stash%22%2C%22create_journal%22%2C%5B%2235020854%22%2C%22'.urlencode($flds['subject']).'%22%2C%22'.urlencode($flds['subject']).'%22%2C%22-1%22%2C%7B%7D%5D&pid='.$pid.'&iid='.$iid.'-i7exlgzv-1.0&t=json';
81
- $hdrsArr = $this->headers($mh.'/journal/?edit', $mh, true); $advSets = array( 'method' => 'POST', 'httpversion' => '1.1', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ck);
82
- $advSets['body'] = $dfldsq1; $rep = wp_remote_post($mh.'/global/difi/?', $advSets); //prr($mh.'/global/difi/?'); prr($advSets); prr($rep);
83
- if (is_wp_error($rep)) { $badOut = print_r($rep, true)." - ERROR DFI 1"; return $badOut; } $cnt = $rep['body'];
84
  if (stripos($cnt, '"status":"SUCCESS"')===false || stripos($cnt, '"args":["')===false) { $badOut = print_r($cnt, true)." - ERROR DFI 1.1"; return $badOut; } else $npid = CutFromTo($cnt, '"args":["','"');
85
  $dfldsq2 = 'ui='.$ui.'&c%5B%5D=%22Deviation%22%2C%22DeleteSingle%22%2C%5B%'.$npid.'%22%2C%221%22%5D&pid='.$pid.'&iid='.$iid.'-i7exlgzv-1.0&t=json';
86
- $advSets['body'] = $dfldsq2; $rep = wp_remote_post($mh.'/global/difi/?', $advSets); // sleep(6); //## Important. //prr($advSets); prr($rep); die();
87
- $advSets['body'] = $fldsOut; $response = wp_remote_post($mh.'/journal/?edit', $advSets); //prr($mh.'/journal/?edit'); prr($advSets); prr($response);
88
  if ($response['response']['code']=='200' && stripos($response['body'],'field_error')!==false) { $eRRMsg = CutFromTo($response['body'],'field_error', '</div>'); $eRRMsg = trim(strip_tags(CutFromTo($eRRMsg."|GGG|",'>', '|GGG|')));
89
  $badOut = "POST Error: ".$eRRMsg; return $badOut;
90
  }
91
- if ($response['response']['code']=='302') { $hdrsArr = $this->headers($mh);
92
- $rep = wp_remote_get( $mh.'/journal/', array( 'headers' => $hdrsArr, 'cookies' => $ck));
93
  $daNewPostURL = CutFromTo($rep['body'], 'a data-deviationid="', '</a>'); $daNewPostURL = CutFromTo($daNewPostURL, 'href="', '"'); $daNewPostID = CutFromTo($rep['body'], 'a data-deviationid="', '"');
94
  return array('postID'=>$daNewPostID, 'isPosted'=>1, 'postURL'=>$daNewPostURL, 'pDate'=>date('Y-m-d H:i:s'));
95
  } else { $badOut .= 'Somethibng is not right';
@@ -113,16 +111,21 @@ if (!class_exists("nxs_class_SNAP_DA")) { class nxs_class_SNAP_DA {
113
  function doPostToNT($options, $message){ global $nxs_urlLen; $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>'');
114
  //## Check settings
115
  if (!is_array($options)) { $badOut = 'No Options'; return $badOut; }
116
- if (!isset($options['daUName']) || trim($options['daUName'])=='' || !isset($options['daPass']) || trim($options['daPass'])=='') { $badOut = 'No username/password Found'; return $badOut; }
117
  //## Format Post
118
- if (!empty($message['pTitle'])) $title = $message['pTitle']; else $title = nxs_doFormatMsg($options['daTitleFormat'], $message); $title = nsTrnc($title, 300);
119
- if (!empty($message['pText'])) $text = $message['pText']; else $text = nxs_doFormatMsg($options['daTextFormat'], $message);
 
 
120
  //## Make Post
121
- if (!empty($options['ck'])) $ck = maybe_unserialize($options['ck']); if (!empty($options['mh'])) $mh = maybe_unserialize($options['mh']);
122
- $pass = substr($options['daPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['daPass'], 5)):$options['uPass'];
123
- $nt = new nxsAPI_DA(); $nt->debug = false; if (!empty($ck)) $nt->ck = $ck; if (!empty($mh)) $nt->mh = $mh; $loginErr = $nt->connect($options['daUName'], $pass);
124
  if (!$loginErr) { $post = array('title'=>$title, 'text'=>$text ); $ret = $nt->post($post);
125
- if (is_array($ret)) { $ret['ck'] = $nt->ck; $ret['mh'] = $nt->mh; return $ret; } else return print_r($ret, true);
 
 
 
 
126
  } else return print_r($loginErr, true);
127
  }
128
  }}
36
  }
37
  function check(){ $ck = $this->ck; if (!empty($ck) && is_array($ck)) { $hdrsArr = $this->headers('https://www.deviantart.com'); if ($this->debug) echo "[DA] Checking....;<br/>\r\n";
38
  $rep = nxs_remote_get('https://www.deviantart.com', array('headers' => $hdrsArr, 'httpversion' => '1.1', 'cookies' => $ck));
39
+ if (is_nxs_error($rep)) { $badOut = print_r($rep, true)." - ERROR https://www.deviantart.com is not accessible. "; return $badOut; }
40
  $ck2 = $rep['cookies']; for($i=0;$i<count($ck);$i++) if ($ck[$i]->name=='userinfo') $ck[$i]->value = urlencode($ck2[0]->value); $this->ck = $ck;
41
  if (is_nxs_error($rep)) return false; $contents = $rep['body']; //if ($this->debug) prr($contents);
42
  $mh = CutFromTo($rep['body'], '$(\'#logoutme\').submit();">', 'data-ga_click_event'); $mh = CutFromTo($mh, 'href="', '"'); $this->mh = $mh;
46
  function connect($u,$p){ $badOut = 'Error: ';
47
  //## Check if alrady IN
48
  if (!$this->check()){ if ($this->debug) echo "[DA] NO Saved Data;<br/>\r\n";
49
+ $url = "https://www.deviantart.com/users/login"; $hdrsArr = $this->headers('http://www.deviantart.com/'); $advSet = nxs_mkRemOptsArr($hdrsArr); $rep = nxs_remote_get($url, $advSet);
50
+ if (is_nxs_error($rep)) { $badOut = print_r($rep, true)." - ERROR Login 1"; return $badOut; } $ck = $rep['cookies'];
51
  $rTok = CutFromTo($rep['body'], 'name="validate_token" value="', '"'); $rKey = CutFromTo($rep['body'], 'name="validate_key" value="', '"'); $ck[0]->value = urlencode($ck[0]->value);
52
  $hdrsArr = $this->headers('https://www.deviantart.com/users/login', 'https://www.deviantart.com/', true);
53
  $flds = array('ref' => 'https://www.deviantart.com/users/loggedin', 'username' => $u, 'password' => $p, 'remember_me' => '1', 'validate_token' => $rTok, 'validate_key' => $rKey);
54
+ $advSet = nxs_mkRemOptsArr($hdrsArr, $ck, $flds); $response = nxs_remote_post( $url, $advSet); if (is_nxs_error($response)) { $badOut = print_r($response, true)." - ERROR Login 2"; return $badOut; }
55
+ $ck = $response['cookies']; foreach ($ck as $i=>$ckk) $ck[$i]->value = urlencode($ckk->value);
 
56
  if (isset($response['headers']['location']) && stripos($response['headers']['location'], 'wrong-password')!==false ) { $badOut = "Wrong Password - ERROR"; return $badOut; }
57
  if (isset($response['headers']['location']) && ( $response['headers']['location']=='http://www.deviantart.com' || $response['headers']['location']=='https://www.deviantart.com/users/loggedin')) {
58
+ $hdrsArr = $this->headers('http://www.deviantart.com'); $advSet = nxs_mkRemOptsArr($hdrsArr, $ck, '', '', 2); $rep = nxs_remote_get('http://www.deviantart.com/browse/all/',$advSet);// prr($advSet); prr($rep); die();
59
+
60
+ if (is_nxs_error($rep)) { $badOut = "ERROR (Login 3): ".print_r($rep, true); return $badOut; }
61
+ $mh = CutFromTo($rep['body'], "logoutme').submit();\"><i></i>", 'data-ga_click_event'); $mh = CutFromTo($mh, 'href="', '"'); // prr($mh);
62
  $ck2 = $rep['cookies']; for($i=0;$i<count($ck);$i++) if ($ck[$i]->name=='userinfo') $ck[$i]->value = urlencode($ck2[0]->value); $this->ck = $ck; $this->mh = $mh; return false;
63
  } else $badOut = print_r($response, true)." - ERROR Login 4"; return $badOut;
64
  } else { if ($this->debug) echo "[DA] Saved Data is OK;<br/>\r\n"; return false; }
65
  }
66
+ function post($post){ $ck = $this->ck; $mh = $this->mh; $hdrsArr = $this->headers('http://www.deviantart.com/'); $badOut = '';
67
+ $rep = nxs_remote_get( $mh.'/journal/?edit', nxs_mkRemOptsArr($hdrsArr, $ck)); if (is_nxs_error($rep)) { $badOut = " - ERROR (Post 1): ".$mh.'/journal/?edit' . " | " . print_r($rep, true); return $badOut; }
 
68
  $contents = CutFromTo($rep['body'], '<h3 class="journal-editor-create">', '</form>'); // prr($contents);
69
  $md = array(); while (stripos($contents, '"hidden"')!==false){$contents = substr($contents, stripos($contents, '"hidden"')+8); $name = trim(CutFromTo($contents,'name="', '"'));
70
+ if (!in_array($name, $md)) { $md[] = $name; $val = trim(CutFromTo($contents,'value="', '"')); $flds[$name]= urldecode (nxs_decodeEntitiesFull($val)); }
71
+ } $flds['subject'] = nsTrnc(nxs_decodeEntitiesFull(addslashes($post['title'])), 50); $flds['body'] = trim(addslashes($post['text'])); $flds['song'] = '';
72
  $flds['game'] = ''; $flds['book'] = ''; $flds['food'] = ''; $flds['movie'] = ''; $flds['drink'] = ''; $flds['flip'] = '0'; $flds['featured'] = '1';
73
  $flds['portal'] = '1'; $flds['skinlabel'] = 'No+skin'; $flds['jheader'] = ''; $flds['jcss'] = ''; $flds['jfooter'] = '';
74
  $ck2 = $rep['cookies']; for($i=0;$i<count($ck);$i++) if ($ck[$i]->name=='userinfo') $ck[$i]->value = urlencode($ck2[0]->value);
77
  $pid = CutFromTo($contents, '"pageviewID":"','"'); $iid = CutFromTo($contents, '"requestid":"','"');
78
  $dflds = array('ui'=>$ui,'pid'=>$pid, 'iid'=>$iid.'-i7ex4avh-1.0','t'=>'json'); $dfldsq = http_build_query($dflds);
79
  $dfldsq1 = 'ui='.$ui.'&c%5B%5D=%22Stash%22%2C%22create_journal%22%2C%5B%2235020854%22%2C%22'.urlencode($flds['subject']).'%22%2C%22'.urlencode($flds['subject']).'%22%2C%22-1%22%2C%7B%7D%5D&pid='.$pid.'&iid='.$iid.'-i7exlgzv-1.0&t=json';
80
+ $hdrsArr = $this->headers($mh.'/journal/?edit', $mh, true); $advSets = nxs_mkRemOptsArr($hdrsArr, $ck, $dfldsq1); $rep = nxs_remote_post($mh.'/global/difi/?', $advSets); //prr($mh.'/global/difi/?'); prr($advSets); prr($rep);
81
+ if (is_nxs_error($rep)) { $badOut = print_r($rep, true)." - ERROR DFI 1"; return $badOut; } $cnt = $rep['body'];
 
82
  if (stripos($cnt, '"status":"SUCCESS"')===false || stripos($cnt, '"args":["')===false) { $badOut = print_r($cnt, true)." - ERROR DFI 1.1"; return $badOut; } else $npid = CutFromTo($cnt, '"args":["','"');
83
  $dfldsq2 = 'ui='.$ui.'&c%5B%5D=%22Deviation%22%2C%22DeleteSingle%22%2C%5B%'.$npid.'%22%2C%221%22%5D&pid='.$pid.'&iid='.$iid.'-i7exlgzv-1.0&t=json';
84
+ $advSets = nxs_mkRemOptsArr($hdrsArr, $ck, $dfldsq2); $rep = nxs_remote_post($mh.'/global/difi/?', $advSets); // sleep(6); //## Important. //prr($advSets); prr($rep); die();
85
+ $advSets = nxs_mkRemOptsArr($hdrsArr, $ck, $fldsOut); $response = nxs_remote_post($mh.'/journal/?edit', $advSets); //prr($mh.'/journal/?edit'); prr($advSets); prr($response);
86
  if ($response['response']['code']=='200' && stripos($response['body'],'field_error')!==false) { $eRRMsg = CutFromTo($response['body'],'field_error', '</div>'); $eRRMsg = trim(strip_tags(CutFromTo($eRRMsg."|GGG|",'>', '|GGG|')));
87
  $badOut = "POST Error: ".$eRRMsg; return $badOut;
88
  }
89
+ if ($response['response']['code']=='302') { $hdrsArr = $this->headers($mh); $advSet = nxs_mkRemOptsArr($hdrsArr, $ck);
90
+ $rep = nxs_remote_get( $mh.'/journal/', $advSet); if (is_nxs_error($rep)) { $badOut = print_r($rep, true)." - ERROR DFI 1"; return $badOut; }
91
  $daNewPostURL = CutFromTo($rep['body'], 'a data-deviationid="', '</a>'); $daNewPostURL = CutFromTo($daNewPostURL, 'href="', '"'); $daNewPostID = CutFromTo($rep['body'], 'a data-deviationid="', '"');
92
  return array('postID'=>$daNewPostID, 'isPosted'=>1, 'postURL'=>$daNewPostURL, 'pDate'=>date('Y-m-d H:i:s'));
93
  } else { $badOut .= 'Somethibng is not right';
111
  function doPostToNT($options, $message){ global $nxs_urlLen; $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>'');
112
  //## Check settings
113
  if (!is_array($options)) { $badOut = 'No Options'; return $badOut; }
114
+ if (!isset($options['uName']) || trim($options['uName'])=='' || !isset($options['uPass']) || trim($options['uPass'])=='') { $badOut = 'No username/password Found'; return $badOut; }
115
  //## Format Post
116
+ if (!empty($message['pTitle'])) $title = $message['pTitle']; else $title = nxs_doFormatMsg($options['msgTFormat'], $message); $title = nsTrnc($title, 300);
117
+ if (!empty($message['pText'])) $text = $message['pText']; else $text = nxs_doFormatMsg($options['msgFormat'], $message);
118
+ //## Get Saved Login Info
119
+ if (function_exists('nxs_getOption')) { $opVal = array(); $opNm = 'nxs_snap_da_'.sha1('nxs_snap_da'.$options['uName'].$options['uPass']); $opVal = nxs_getOption($opNm); if (!empty($opVal) & is_array($opVal)) $options = array_merge($options, $opVal); }
120
  //## Make Post
121
+ $pass = (substr($options['uPass'], 0, 5)=='n5g9a'||substr($options['uPass'], 0, 5)=='g9c1a'||substr($options['uPass'], 0, 5)=='b4d7s')?nsx_doDecode(substr($options['uPass'], 5)):$options['uPass'];
122
+ $nt = new nxsAPI_DA(); $nt->debug = false; if (!empty($options['ck'])) $nt->ck = $options['ck']; if (!empty($options['mh'])) $nt->mh = $options['mh']; $loginErr = $nt->connect($options['uName'], $pass);
 
123
  if (!$loginErr) { $post = array('title'=>$title, 'text'=>$text ); $ret = $nt->post($post);
124
+ if (is_array($ret)) {
125
+ //## Save Login Info
126
+ if (function_exists('nxs_saveOption')) { if (empty($opVal['ck'])) $opVal['ck'] = ''; if (is_array($ret) && $ret['isPosted']=='1' && $opVal['ck'] != $nt->ck) { $opVal['ck'] = $nt->ck; $opVal['mh'] = $nt->mh; nxs_saveOption($opNm, $opVal); } }
127
+ return $ret;
128
+ } else return print_r($ret, true);
129
  } else return print_r($loginErr, true);
130
  }
131
  }}
inc-cl/da.php CHANGED
@@ -1,235 +1,69 @@
1
  <?php
2
  //## NextScripts deviantART Connection Class
3
- $nxs_snapAvNts[] = array('code'=>'DA', 'lcode'=>'da', 'name'=>'deviantART (!)');
4
 
5
- if (!class_exists("nxs_snapClassDA")) { class nxs_snapClassDA {
 
 
 
 
 
 
 
 
 
 
 
6
  //#### Show Common Settings
7
- function showGenNTSettings($ntOpts){ global $nxs_plurl; $ntInfo = array('code'=>'DA', 'lcode'=>'da', 'name'=>'deviantART', 'defNName'=>'daUName', 'tstReq' => false); ?>
8
- <div class="nxs_box">
9
- <div class="nxs_box_header">
10
- <div class="nsx_iconedTitle" style="margin-bottom:1px;background-image:url(<?php echo $nxs_plurl;?>img/<?php echo $ntInfo['lcode']; ?>16.png);"><?php echo $ntInfo['name']; ?>
11
- <?php $cbo = count($ntOpts); ?>
12
- <?php if ($cbo>1){ ?><div class="nsBigText"><?php echo "(".($cbo=='0'?'No':$cbo)." "; _e('accounts', 'social-networks-auto-poster-facebook-twitter-g'); echo ")"; ?></div><?php } ?>
13
- </div>
14
- </div>
15
- <div class="nxs_box_inside">
16
- <?php if(!function_exists('doConnectToDeviantART')) {?> deviantART doesn't have a built-in API for automated posts yet. <br/>You need to get a special <a target="_blank" href="http://www.nextscripts.com/deviantart-automated-posting">library module</a> to be able to publish your content to deviantART.
17
- <?php } else foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
18
- <p style="margin:0px;margin-left:5px;"> <img id="<?php echo $ntInfo['code'].$indx;?>LoadingImg" style="display: none;" src='<?php echo $nxs_plurl; ?>img/ajax-loader-sm.gif' />
19
- <input value="0" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" type="hidden" />
20
- <?php if ((int)$pbo['do'.$ntInfo['code']] == 1 && isset($pbo['catSel']) && (int)$pbo['catSel'] == 1) { ?> <input type="radio" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" id="rbtn<?php echo $ntInfo['lcode'].$indx; ?>" value="1" checked="checked" onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);" /> <?php } else { ?>
21
- <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1 && $pbo['catSel']!='1') echo "checked"; ?> />
22
- <?php } ?>
23
- <?php if (isset($pbo['catSel']) && (int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
24
- <?php if (isset($pbo['rpstOn']) && (int)$pbo['rpstOn'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popReActive');" onmouseover="nxs_showPopUpInfo('popReActive', event);"><?php echo "*[R]*" ?></span><?php } ?>
25
- <strong><?php _e('Auto-publish to', 'social-networks-auto-poster-facebook-twitter-g'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
26
- &nbsp;&nbsp;<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'social-networks-auto-poster-facebook-twitter-g'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>AG" href="#" onclick="doGetHideNTBlock('<?php echo $ntInfo['code'];?>' , '<?php echo $indx; ?>');return false;">[<?php _e('Show Settings', 'social-networks-auto-poster-facebook-twitter-g'); ?>]</a>&nbsp;&nbsp;
27
- <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'social-networks-auto-poster-facebook-twitter-g'); ?>]</a>
28
- </p><div id="nxsNTSetDiv<?php echo $ntInfo['code'].$indx; ?>"></div><?php // $pbo['ntInfo'] = $ntInfo; $this->showNTSettings($indx, $pbo);
29
- }?>
30
- </div>
31
- </div> <?php
32
- }
33
  //#### Show NEW Settings Page
34
- function showNewNTSettings($options){ $nto = array('nName'=>'', 'doDA'=>'1', 'daUName'=>'', 'daPageID'=>'', 'daCommID'=>'', 'postType'=>'A', 'daPass'=>''); $nto['ntInfo']= array('lcode'=>'da'); $this->showNTSettings($options, $nto, true);}
35
- //#### Show Unit Settings
36
- function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl; $nt = $options['ntInfo']['lcode']; $ntU = strtoupper($nt);
37
- 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'] = '';
38
- if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; ?>
39
- <div id="doDA<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>"> <input type="hidden" value="0" id="apDoS<?php echo $ntU.$ii; ?>" />
40
-
41
- <div style="color:red;padding:5px;margin:5px; border: 1px solid darkred;">DeviantArt API is being extremely unstable and buggy on their side for the last several months. Until further notice DeviantArt connector is provided "as is". Please use it on your own risk. This may cause numerous of different issues including disapering posts, broken accounts, messed up posts, etc...<br/></div>
42
-
43
- <?php if(!function_exists('doConnectToDeviantART')) {?><span style="color:#580000; font-size: 16px;"><br/><br/>
44
- <b><?php _e('deviantART API Library not found', 'social-networks-auto-poster-facebook-twitter-g'); ?></b>
45
- <br/><br/> <?php _e('deviantART doesn\'t have a built-in API for automated posts yet.', 'social-networks-auto-poster-facebook-twitter-g'); ?> <br/><?php _e('<br/>You need to get a special <a target="_blank" href="http://www.nextscripts.com/deviantart-automated-posting"><b>API Library Module</b></a> to be able to publish your content to deviantART.', 'social-networks-auto-poster-facebook-twitter-g'); ?></span></div>
46
- <?php return; }; ?>
47
-
48
- <div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/da16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-deviantart-social-networks-auto-poster-wordpress/"><?php $nType="deviantART"; printf( __( 'Detailed %s Installation/Configuration Instructions', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?></a></div>
49
-
50
- <div style="width:100%;"><strong><?php _e('Account Nickname', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'social-networks-auto-poster-facebook-twitter-g'); ?></i> </div><input name="da[<?php echo $ii; ?>][nName]" id="danName<?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")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /><br/>
51
- <?php echo nxs_addQTranslSel('da', $ii, $options['qTLng']); ?>
52
-
53
-
54
- <br/>
55
- <ul class="nsx_tabs">
56
- <li><a href="#nsx<?php echo $nt.$ii ?>_tab1"><?php _e('Account Info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li>
57
- <?php if (!$isNew) { ?> <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li> <?php } ?>
58
- </ul>
59
- <div class="nsx_tab_container"><?php /* ######################## Account Tab ####################### */ ?>
60
- <div id="nsx<?php echo $nt.$ii ?>_tab1" class="nsx_tab_content" style="background-image: url(<?php echo $nxs_plurl; ?>img/<?php echo $nt; ?>-bg.png); background-repeat: no-repeat; background-position:90% 10%;">
61
-
62
-
63
- <div style="width:100%;"><strong>deviantART Username or Email:</strong> </div><input name="da[<?php echo $ii; ?>][uName]" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['daUName'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />
64
- <div style="width:100%;"><strong>deviantART Password:</strong> </div><input autocomplete="false" readonly onfocus="this.removeAttribute('readonly');" name="da[<?php echo $ii; ?>][uPass]" type="password" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities(substr($options['daPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['daPass'], 5)):$options['daPass'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /> <br/>
65
- <br/>
66
-
67
- <div id="altFormat" style="">
68
- <div style="width:100%;"><strong id="altFormatText"><?php _e('Post Title Format', 'social-networks-auto-poster-facebook-twitter-g'); ?></strong> (<a href="#" id="daTitleFormat<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('daTitleFormat<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>)</div>
69
- <input name="da[<?php echo $ii; ?>][daTitleFormat]" id="daTitleFormat<?php echo $ii; ?>" style="width: 50%;" value="<?php if ($isNew) echo "%TITLE%"; else _e(apply_filters('format_to_edit', htmlentities($options['daTitleFormat'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g'); ?>" onfocus="mxs_showFrmtInfo('daTitleFormat<?php echo $ii; ?>');" /><?php nxs_doShowHint("daTitleFormat".$ii); ?>
70
- </div><br/>
71
-
72
- <div id="altFormat" style="margin-left: 0px;">
73
- <div style="width:100%;"><strong id="altFormatText"><?php _e('Text Format', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> (<a href="#" id="daTextFormat<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('daTextFormat<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>)
74
- </div>
75
-
76
- <textarea cols="150" rows="3" id="da<?php echo $ii; ?>SNAPformat" name="da[<?php echo $ii; ?>][daTextFormat]" style="width:51%;max-width: 650px;" onfocus="jQuery('#da<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('apDAMsgFrmt<?php echo $ii; ?>');"><?php if ($isNew) _e("%FULLTEXT%", 'social-networks-auto-poster-facebook-twitter-g'); else _e(apply_filters('format_to_edit', htmlentities($options['daTextFormat'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g'); ?></textarea>
77
-
78
- <?php nxs_doShowHint("daTextFormat".$ii); ?>
79
- </div><br/>
80
-
81
-
82
- <?php if ($isNew) { ?> <input type="hidden" name="da[<?php echo $ii; ?>][apDoDA]" value="1" id="apDoNewDA<?php echo $ii; ?>" /> <?php } ?>
83
- <?php if ($options['daPass']!='') { ?>
84
-
85
- <b><?php _e('Test your settings', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('DA', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?></a> <?php }
86
- ?>
87
- </div>
88
-
89
- <?php /* ######################## Advanced Tab ####################### */ ?>
90
- <?php if (!$isNew) { ?> <div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content">
91
-
92
- <?php nxs_showCatTagsCTFilters($nt, $ii, $options);
93
- nxs_addPostingDelaySelV3($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']);
94
- nxs_showRepostSettings($nt, $ii, $options); ?>
95
-
96
-
97
- </div> <?php } ?> <?php /* #### End of Tab #### */ ?>
98
- </div><br/> <?php /* #### End of Tabs #### */ ?>
99
-
100
- <div class="submitX nxclear" style="padding-bottom: 0px;"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'social-networks-auto-poster-facebook-twitter-g') ?>" /></div>
101
-
102
- </div><?php
103
  }
 
104
  //#### Set Unit Settings from POST
105
- function setNTSettings($post, $options){ $code = 'DA'; $lcode = 'da';
106
- foreach ($post as $ii => $pval){
107
- if (!empty($pval['uName']) && !empty($pval['uPass'])){ if (!isset($options[$ii])) $options[$ii] = array();
108
- if (isset($pval['uName'])) $options[$ii]['daUName'] = trim($pval['uName']);
109
- if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']);
110
- if (isset($pval['uPass'])) $options[$ii]['daPass'] = 'n5g9a'.nsx_doEncode($pval['uPass']); else $options[$ii]['daPass'] = '';
111
-
112
- if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']); else $options[$ii]['catSel'] = 0;
113
- if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
114
-
115
- if (isset($pval['daTitleFormat'])) $options[$ii]['daTitleFormat'] = trim($pval['daTitleFormat']);
116
- if (isset($pval['daTextFormat'])) $options[$ii]['daTextFormat'] = trim($pval['daTextFormat']);
117
-
118
- if (isset($pval['apDoDA'])) $options[$ii]['doDA'] = $pval['apDoDA']; else $options[$ii]['doDA'] = 0;
119
-
120
- $options[$ii] = nxs_adjRpst($options[$ii], $pval);
121
-
122
- if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']);
123
- if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
124
- if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
125
- } elseif ( count($pval)==1 ) if (isset($pval['apDo'.$code])) $options[$ii]['do'.$code] = $pval['apDo'.$code]; else $options[$ii]['do'.$code] = 0;
126
  } return $options;
127
- }
 
128
  //#### Show Post->Edit Meta Box Settings
129
- function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID; $nt = 'da'; $ntU = 'DA';
130
- foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapDA', true)); if (is_array($pMeta) && !empty($pMeta[$ii])) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
131
- $doDA = $ntOpt['doDA'] && (is_array($pMeta) || $ntOpt['catSel']!='1');
132
- $isAvailDA = $ntOpt['daUName']!='' && $ntOpt['daPass']!=''; $daMsgFormat = htmlentities($ntOpt['daTextFormat'], ENT_COMPAT, "UTF-8"); $daMsgTFormat = htmlentities($ntOpt['daTitleFormat'], ENT_COMPAT, "UTF-8");
133
-
134
- ?>
135
- <tr><th style="text-align:left;" colspan="2">
136
- <?php if ($ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='') { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
137
- <?php if (!empty($ntOpt['tagsSelX'])) { ?> <input type="hidden" class="nxs_TG" id="nxs_TG_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $ntOpt['tagsSelX']; ?>" /> <?php } ?>
138
- <?php if ($isAvailDA) { ?><input class="nxsGrpDoChb" value="1" id="doDA<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="da[<?php echo $ii; ?>][doDA]" <?php if ((int)$doDA == 1) echo 'checked="checked" title="def"'; ?> />
139
- <?php if ($post->post_status == "publish") { ?> <input type="hidden" name="da[<?php echo $ii; ?>][doDA]" value="<?php echo $doDA;?>"> <?php } ?> <?php } ?>
140
-
141
- <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/da16.png);">deviantART - <?php _e('publish to', 'social-networks-auto-poster-facebook-twitter-g') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
142
- if ($post->post_status == "publish" && $isAvailDA) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToDA_repostButton" id="rePostToDA_button" value="<?php _e('Repost to deviantART', 'social-networks-auto-poster-facebook-twitter-g') ?>" />
143
- <?php } ?>
144
-
145
- <?php if (is_array($pMeta) && !empty($pMeta[$ii]) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
146
-
147
- ?> <span id="pstdDA<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
148
- <a style="font-size: 10px;" href="<?php echo $pMeta[$ii]['postURL']; ?>" target="_blank"><?php $nType="deviantART"; printf( __( 'Posted on', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
149
- </span><?php } ?>
150
-
151
- </td></tr>
152
-
153
- <?php if (!$isAvailDA) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your deviantART Account to AutoPost to deviantART</b></td></tr>
154
- <?php } else { if ($post->post_status != "publish" && function_exists('nxs_doSMAS5') ) { $ntOpt['postTime'] = get_post_time('U', false, $post_id); nxs_doSMAS5($nt, $ii, $ntOpt); } ?>
155
-
156
- <?php if ($ntOpt['rpstOn']=='1') { ?>
157
-
158
- <tr id="altFormat1" style=""><th scope="row" class="nxsTHRow">
159
- <input value="0" type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]"/><input value="nxsi<?php echo $ii; ?>da" type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]" <?php if (!empty($ntOpt['rpstPostIncl'])) echo "checked"; ?> />
160
- </th>
161
- <td> <?php _e('Include in "Auto-Reposting" to this network.', 'social-networks-auto-poster-facebook-twitter-g') ?>
162
- </td></tr> <?php } ?>
163
-
164
-
165
- <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Title Format:', 'social-networks-auto-poster-facebook-twitter-g') ?></th>
166
- <td><input value="<?php echo $daMsgTFormat ?>" type="text" name="da[<?php echo $ii; ?>][SNAPformatT]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apDAMsgTFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apDAMsgTFrmt".$ii, '', '58'); ?></td></tr>
167
-
168
- <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Text Format:', 'social-networks-auto-poster-facebook-twitter-g') ?></th><td>
169
-
170
- <textarea cols="150" rows="1" id="da<?php echo $ii; ?>SNAPformat" name="da[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('#da<?php echo $ii; ?>SNAPformat').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apDAMsgFrmt<?php echo $ii; ?>');"><?php echo $daMsgFormat ?></textarea>
171
-
172
- </td></tr>
173
- <?php }
174
  }
175
- }
176
  //#### Save Meta Tags to the Post
177
- function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
178
- if (isset($pMeta['SNAPformat'])) $optMt['daTextFormat'] = $pMeta['SNAPformat']; if (isset($pMeta['SNAPformatT'])) $optMt['daTitleFormat'] = $pMeta['SNAPformatT'];
179
- if (isset($pMeta['imgToUse'])) $optMt['imgToUse'] = $pMeta['imgToUse'];
180
- if (isset($pMeta['timeToRun'])) $optMt['timeToRun'] = $pMeta['timeToRun']; if (isset($pMeta['rpstPostIncl'])) $optMt['rpstPostIncl'] = $pMeta['rpstPostIncl'];
181
- if (isset($pMeta['doDA'])) $optMt['doDA'] = $pMeta['doDA'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doDA'] = 0; }
182
- if (isset($pMeta['SNAPincludeDA']) && $pMeta['SNAPincludeDA'] == '1' ) $optMt['doDA'] = 1;
183
  return $optMt;
184
- }
185
- }}
186
- if (!function_exists("nxs_rePostToDA_ajax")) {
187
- function nxs_rePostToDA_ajax() { check_ajax_referer('nxsSsPageWPN'); $postID = $_POST['id']; global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
188
- foreach ($options['da'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj'; //if ($two['daPageID'].$two['daUName']==$_POST['nid']) {
189
- $dapo = get_post_meta($postID, 'snapDA', true); $dapo = maybe_unserialize($dapo);// prr($dapo);
190
- if (is_array($dapo) && isset($dapo[$ii]) && is_array($dapo[$ii])){ $ntClInst = new nxs_snapClassDA(); $two = $ntClInst->adjMetaOpt($two, $dapo[$ii]); }
191
- $result = nxs_doPublishToDA($postID, $two); if ($result == 200) die("Successfully sent your post to deviantART."); else die($result);
192
- }
193
  }
194
- }
195
- if (!function_exists("nxs_doPublishToDA")) { //## Second Function to Post to DA
196
- function nxs_doPublishToDA($postID, $options){ $ntCd = 'DA'; $ntCdL = 'da'; $ntNm = 'deviantART'; if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
197
- $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'POSTID'=>$postID, 'ACCNAME'=>$options['nName']));
198
- $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url();
199
-
200
- $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
201
- $logNT = '<span style="color:#800000">deviantART</span> - '.$options['nName'];
202
- $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
203
- if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
204
- $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') {
205
- nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$uqID); return;
206
- }
207
- }
208
- $message = array('message'=>'', 'link'=>'', 'imageURL'=>'', 'videoURL'=>'');
209
-
210
- if ($postID=='0') { echo "Testing ... <br/><br/>"; $message['description'] = 'Test Post, Description'; $message['title'] = 'Test Post - Title'; $message['url'] = home_url();
211
- } else { nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1')); $post = get_post($postID); if(!$post) return;
212
-
213
- $options['daTitleFormat'] = nsFormatMessage($options['daTitleFormat'], $postID, $addParams); $options['daTextFormat'] = nsFormatMessage($options['daTextFormat'], $postID, $addParams); // prr($options['daTextFormat']); echo $postID;
214
- $extInfo = ' | PostID: '.$postID." - ".(isset($post) && is_object($post)?$post->post_title:'');
215
- }
216
- //## Actual Post
217
- $ntToPost = new nxs_class_SNAP_DA(); $ret = $ntToPost->doPostToNT($options, $message); // echo "~~~"; prr($ret); echo "+++";
218
- //## Save Session
219
- if (empty($options['ck'])) $options['ck'] = '';
220
- if (!empty($ret) && is_array($ret) && !empty($ret['ck']) && !empty($ret['ck']) && serialize($ret['ck'])!=$options['ck']) { $options['ck'] = serialize($ret['ck']); $options['mh'] = serialize($ret['mh']);
221
- if (function_exists('get_option')) $nxs_gOptions = get_option('NS_SNAutoPoster'); if(!empty($nxs_gOptions)) { $nxs_gOptions['da'][$ii] = $options; nxs_settings_save($nxs_gOptions); }
222
- }
223
- //## Process Results
224
- if (!is_array($ret) || $ret['isPosted']!='1') { //## Error
225
- if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);
226
- } else { // ## All Good - log it.
227
- if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo _e('OK - Message Posted, please see your '.$logNT.' Page. ', 'social-networks-auto-poster-facebook-twitter-g'); }
228
- else { nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPosted'=>'1', 'pgID'=>$ret['postID'], 'postURL'=>$ret['postURL'], 'pDate'=>date('Y-m-d H:i:s'))); nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); }
229
- }
230
- //## Return Result
231
- if ($ret['isPosted']=='1') return 200; else return print_r($ret, true);
232
 
233
  }
234
- }
 
 
 
 
 
235
  ?>
1
  <?php
2
  //## NextScripts deviantART Connection Class
3
+ $nxs_snapAvNts[] = array('code'=>'DA', 'lcode'=>'da', 'name'=>'deviantART (!)', 'type'=>'Image Sharing', 'ptype'=>'F', 'status'=>'B', 'desc'=>'Autopost to your blog. HTML is supported');
4
 
5
+ if (!class_exists("nxs_snapClassDA")) { class nxs_snapClassDA extends nxs_snapClassNT {
6
+ var $ntInfo = array('code'=>'DA', 'lcode'=>'da', 'name'=>'deviantART (!)', 'defNName'=>'uName', 'tstReq' => false, 'instrURL'=>'http://www.nextscripts.com/setup-installation-deviantart-social-networks-auto-poster-wordpress/');
7
+
8
+ function toLatestVer($ntOpts){ if( !empty($ntOpts['v'])) $v = $ntOpts['v']; else $v = 340; $ntOptsOut = ''; switch ($v) {
9
+ case 340: $ntOptsOut = $this->toLatestVerNTGen($ntOpts); $ntOptsOut['do'] = $ntOpts['do'.$this->ntInfo['code']]; $ntOptsOut['nName'] = $ntOpts['nName'];
10
+ $ntOptsOut['msgTFormat'] = $ntOpts['daTitleFormat']; $ntOptsOut['msgFormat'] = $ntOpts['daTextFormat']; $ntOptsOut['uName'] = $ntOpts['daUName']; $ntOptsOut['uPass'] = $ntOpts['daPass'];
11
+ $ntOptsOut['v'] = NXS_SETV;
12
+ break;
13
+ }
14
+ return !empty($ntOptsOut)?$ntOptsOut:$ntOpts;
15
+ }
16
+
17
  //#### Show Common Settings
18
+ function showGenNTSettings($ntOpts){ $this->nt = $ntOpts; $this->showNTGroup(); return; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  //#### Show NEW Settings Page
20
+ function showNewNTSettings($ii){ $defO = array('nName'=>'', 'do'=>'1', 'uName'=>'', 'uPass'=>'', 'msgTFormat'=>'%TITLE%', 'msgFormat'=>"%FULLTEXT%"); $this->showGNewNTSettings($ii, $defO); }
21
+ //#### Show Unit Settings
22
+ function checkIfSetupFinished($options) { return !empty($options['uPass']); }
23
+ function accTab($ii, $options, $isNew=false){ $ntInfo = $this->ntInfo; $nt = $ntInfo['lcode']; ?>
24
+ <div style="color:red;padding:5px;margin:5px; border: 1px solid darkred;">DeviantArt API is being extremely unstable and buggy on their side for the last several months. Until further notice DeviantArt connector is provided "as is". Please use it on your own risk. This may cause numerous of different issues including disapering posts, broken accounts, messed up posts, etc...<br/></div>
25
+ <?php $this->elemUserPass($ii, $options['uName'], $options['uPass']);
26
+ $this->elemTitleFormat($ii,'Post Title Format','msgTFormat',$options['msgTFormat']); $this->elemMsgFormat($ii,'Post Text Format','msgFormat',$options['msgFormat']);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  }
28
+ function advTab($ii, $options){}
29
  //#### Set Unit Settings from POST
30
+ function setNTSettings($post, $options){
31
+ foreach ($post as $ii => $pval){
32
+ if (!empty($pval['uPass']) && !empty($pval['uPass'])){ if (!isset($options[$ii])) $options[$ii] = array(); $options[$ii] = $this->saveCommonNTSettings($pval,$options[$ii]);
33
+ } elseif ( count($pval)==1 ) if (isset($pval['do'])) $options[$ii]['do'] = $pval['do']; else $options[$ii]['do'] = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  } return $options;
35
+ }
36
+
37
  //#### Show Post->Edit Meta Box Settings
38
+ function showEdPostNTSettings($ntOpts, $post){ $post_id = $post->ID; $nt = $this->ntInfo['lcode']; $ntU = $this->ntInfo['code'];
39
+ foreach($ntOpts as $ii=>$ntOpt) { $isFin = $this->checkIfSetupFinished($ntOpt); if (!$isFin) continue;
40
+ $pMeta = maybe_unserialize(get_post_meta($post_id, 'snap'.$ntU, true)); if (is_array($pMeta) && !empty($pMeta[$ii])) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
41
+
42
+ if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = ''; if (empty($ntOpt['urlToUse'])) $ntOpt['urlToUse'] = ''; $postType = isset($ntOpt['postType'])?$ntOpt['postType']:'';
43
+ $msgFormat = !empty($ntOpt['msgFormat'])?htmlentities($ntOpt['msgFormat'], ENT_COMPAT, "UTF-8"):''; $msgTFormat = !empty($ntOpt['msgTFormat'])?htmlentities($ntOpt['msgTFormat'], ENT_COMPAT, "UTF-8"):'';
44
+ $imgToUse = $ntOpt['imgToUse']; $urlToUse = $ntOpt['urlToUse']; $ntOpt['ii']=$ii;
45
+
46
+ $this->nxs_tmpltAddPostMeta($post, $ntOpt, $pMeta); ?>
47
+ <?php $this->elemEdTitleFormat($ii, __('Title Format:', 'social-networks-auto-poster-facebook-twitter-g'),$msgTFormat); $this->elemEdMsgFormat($ii, __('Message Format:', 'social-networks-auto-poster-facebook-twitter-g'),$msgFormat); ?>
48
+
49
+ <?php
50
+
51
+ /* ## Select Image & URL ## */ nxs_showURLToUseDlg($nt, $ii, $urlToUse); $this->nxs_tmpltAddPostMetaEnd($ii);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  }
53
+ }
54
  //#### Save Meta Tags to the Post
55
+ function adjMetaOpt($optMt, $pMeta){ $optMt = $this->adjMetaOptG($optMt, $pMeta); // prr($optMt);
56
+
 
 
 
 
57
  return $optMt;
 
 
 
 
 
 
 
 
 
58
  }
59
+
60
+ function adjPublishWP(&$options, &$message, $postID){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
 
62
  }
63
+
64
+ }}
65
+
66
+ if (!function_exists("nxs_doPublishToDA")) { function nxs_doPublishToDA($postID, $options){ if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
67
+ $cl = new nxs_snapClassDA(); $cl->nt[$options['ii']] = $options; return $cl->publishWP($options['ii'], $postID);
68
+ }}
69
  ?>
inc-cl/di.api.php CHANGED
@@ -22,17 +22,17 @@ if (!class_exists("nxs_class_SNAP_DI")) { class nxs_class_SNAP_DI {
22
  function doPostToNT($options, $message){ $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>'');
23
  //## Check settings
24
  if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
25
- if (!isset($options['diUName']) || trim($options['diPass'])=='') { $badOut['Error'] = 'Not Configured'; return $badOut; }
26
- $email = $options['diUName']; $pass = substr($options['diPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['diPass'], 5)):$options['diPass3'];
27
  //## Format
28
- if (!empty($message['pText'])) $msg = $message['pText']; else $msg = nxs_doFormatMsg($options['diMsgFormat'], $message);
29
- if (!empty($message['pTitle'])) $msgT = $message['pTitle']; else $msgT = nxs_doFormatMsg($options['diMsgTFormat'], $message);
30
- $flds = array(); $flds['key']=$options['diAPIKey']; $flds['url']=$message['url']; $flds['title']=nsTrnc($msgT, 250); $flds['desc']=nsTrnc($msg, 250); $flds['tags']=$message['tags']; $flds['shared']='yes'; // prr($flds); die();
31
- $hdrsArr = $this->nxs_getDIHeaders('https://www.diigo.com/api/v2/bookmarks', $email, $pass, true);
32
- $cnt = wp_remote_post( 'https://www.diigo.com/api/v2/bookmarks', array( 'method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds));
33
  //## Return
34
  if (is_array($cnt) && stripos($cnt['body'],'"code":1')!==false) {
35
- return array('postID'=>'DI', 'isPosted'=>1, 'postURL'=>'DI', 'pDate'=>date('Y-m-d H:i:s'));
36
  } else { $badOut['Error'] .= print_r($cnt, true);
37
  return $badOut;
38
  }
22
  function doPostToNT($options, $message){ $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>'');
23
  //## Check settings
24
  if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
25
+ if (!isset($options['uName']) || trim($options['uPass'])=='') { $badOut['Error'] = 'Not Configured'; return $badOut; }
26
+ $pass = (substr($options['uPass'], 0, 5)=='n5g9a'||substr($options['uPass'], 0, 5)=='g9c1a'||substr($options['uPass'], 0, 5)=='b4d7s')?nsx_doDecode(substr($options['uPass'], 5)):$options['uPass'];
27
  //## Format
28
+ if (!empty($message['pText'])) $msg = $message['pText']; else $msg = nxs_doFormatMsg($options['msgFormat'], $message);
29
+ if (!empty($message['pTitle'])) $msgT = $message['pTitle']; else $msgT = nxs_doFormatMsg($options['msgTFormat'], $message);
30
+ $flds = array(); $flds['key']=$options['apiKey']; $flds['url']=$message['url']; $flds['title']=nsTrnc($msgT, 250); $flds['desc']=nsTrnc($msg, 250); $flds['tags']=$message['tags']; $flds['shared']='yes'; // prr($flds); die();
31
+ $hdrsArr = $this->nxs_getDIHeaders('https://www.diigo.com/api/v2/bookmarks', $options['uName'], $pass, true);
32
+ $cnt = nxs_remote_post( 'https://www.diigo.com/api/v2/bookmarks', array( 'method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds));
33
  //## Return
34
  if (is_array($cnt) && stripos($cnt['body'],'"code":1')!==false) {
35
+ return array('postID'=>'DI', 'isPosted'=>1, 'postURL'=>'https://www.diigo.com/user/'.$options['uName'], 'pDate'=>date('Y-m-d H:i:s'));
36
  } else { $badOut['Error'] .= print_r($cnt, true);
37
  return $badOut;
38
  }
inc-cl/di.php CHANGED
@@ -1,224 +1,69 @@
1
  <?php
2
- //## NextScripts Facebook Connection Class
3
- $nxs_snapAvNts[] = array('code'=>'DI', 'lcode'=>'di', 'name'=>'Diigo');
4
 
5
- if (!class_exists("nxs_snapClassDI")) { class nxs_snapClassDI {
6
- //#### Show Common Settings
7
 
8
- function showGenNTSettings($ntOpts){ global $nxs_plurl; $ntInfo = array('code'=>'DI', 'lcode'=>'di', 'name'=>'Diigo', 'defNName'=>'diUName', 'tstReq' => false); ?>
9
- <div class="nxs_box">
10
- <div class="nxs_box_header">
11
- <div class="nsx_iconedTitle" style="margin-bottom:1px;background-image:url(<?php echo $nxs_plurl;?>img/<?php echo $ntInfo['lcode']; ?>16.png);"><?php echo $ntInfo['name']; ?>
12
- <?php $cbo = count($ntOpts); ?>
13
- <?php if ($cbo>1){ ?><div class="nsBigText"><?php echo "(".($cbo=='0'?'No':$cbo)." "; _e('accounts', 'social-networks-auto-poster-facebook-twitter-g'); echo ")"; ?></div><?php } ?>
14
- </div>
15
- </div>
16
- <div class="nxs_box_inside">
17
- <?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
18
- <p style="margin:0px;margin-left:5px;"> <img id="<?php echo $ntInfo['code'].$indx;?>LoadingImg" style="display: none;" src='<?php echo $nxs_plurl; ?>img/ajax-loader-sm.gif' />
19
- <input value="0" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" type="hidden" />
20
- <?php if ((int)$pbo['do'.$ntInfo['code']] == 1 && isset($pbo['catSel']) && (int)$pbo['catSel'] == 1) { ?> <input type="radio" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" id="rbtn<?php echo $ntInfo['lcode'].$indx; ?>" value="1" checked="checked" onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);" /> <?php } else { ?>
21
- <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1 && $pbo['catSel']!='1') echo "checked"; ?> />
22
- <?php } ?>
23
- <?php if (isset($pbo['catSel']) && (int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
24
- <?php if (isset($pbo['rpstOn']) && (int)$pbo['rpstOn'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popReActive');" onmouseover="nxs_showPopUpInfo('popReActive', event);"><?php echo "*[R]*" ?></span><?php } ?>
25
- <strong><?php _e('Auto-publish to', 'social-networks-auto-poster-facebook-twitter-g'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
26
- &nbsp;&nbsp;<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'social-networks-auto-poster-facebook-twitter-g'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>AG" href="#" onclick="doGetHideNTBlock('<?php echo $ntInfo['code'];?>' , '<?php echo $indx; ?>');return false;">[<?php _e('Show Settings', 'social-networks-auto-poster-facebook-twitter-g'); ?>]</a>&nbsp;&nbsp;
27
- <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'social-networks-auto-poster-facebook-twitter-g'); ?>]</a>
28
- </p><div id="nxsNTSetDiv<?php echo $ntInfo['code'].$indx; ?>"></div> <?php //$pbo['ntInfo'] = $ntInfo; $this->showNTSettings($indx, $pbo);
29
- }?>
30
- </div>
31
- </div> <?php
32
- }
33
 
 
 
34
  //#### Show NEW Settings Page
35
- function showNewNTSettings($mgpo){ $options = array('nName'=>'', 'doDI'=>'1', 'diUName'=>'', 'diInclTags'=>'1', 'diAttch'=>'', 'diAPIKey'=>'', 'diPass'=>''); $options['ntInfo']= array('lcode'=>'di'); $this->showNTSettings($mgpo, $options, true);}
36
-
37
- //#### Show Unit Settings
38
- function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl; $nt = $options['ntInfo']['lcode']; $ntU = strtoupper($nt);
39
- 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'] = '';
40
- if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; ?>
41
- <div id="doDI<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew){ ?> clNewNTSets<?php } ?>"> <input type="hidden" name="apDoSDI<?php echo $ii; ?>" value="0" id="apDoSDI<?php echo $ii; ?>" />
42
-
43
- <div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/di16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-diigo-social-networks-auto-poster-wordpress/"><?php $nType="Diigo"; printf( __( 'Detailed %s Installation/Configuration Instructions', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?></a></div>
44
-
45
- <div style="width:100%;"><strong><?php _e('Account Nickname', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'social-networks-auto-poster-facebook-twitter-g'); ?></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")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /><br/>
46
- <?php echo nxs_addQTranslSel('di', $ii, $options['qTLng']); ?>
47
-
48
- <br/>
49
- <ul class="nsx_tabs">
50
- <li><a href="#nsx<?php echo $nt.$ii ?>_tab1"><?php _e('Account Info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li>
51
- <?php if (!$isNew) { ?> <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li> <?php } ?>
52
- </ul>
53
- <div class="nsx_tab_container"><?php /* ######################## Account Tab ####################### */ ?>
54
- <div id="nsx<?php echo $nt.$ii ?>_tab1" class="nsx_tab_content" style="background-image: url(<?php echo $nxs_plurl; ?>img/<?php echo $nt; ?>-bg.png); background-repeat: no-repeat; background-position:90% 10%;">
55
-
56
-
57
-
58
- <div id="altFormat" style="">
59
- <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>
60
- <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")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /> <br/>
61
- </div>
62
- <div style="width:100%;"><strong>Diigo Username:</strong> </div><input name="di[<?php echo $ii; ?>][apDIUName]" id="apDIUName" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['diUName'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />
63
- <div style="width:100%;"><strong>Diigo Password:</strong> </div><input autocomplete="false" readonly onfocus="this.removeAttribute('readonly');" name="di[<?php echo $ii; ?>][apDIPass]" id="apDIPass" type="password" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities(substr($options['diPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['diPass'], 5)):$options['diPass'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /> <br/>
64
-
65
- <?php if ($isNew) { ?> <input type="hidden" name="di[<?php echo $ii; ?>][apDoDI]" value="1" id="apDoNewDI<?php echo $ii; ?>" /> <?php } ?><br/>
66
- <p style="margin-bottom: 20px;margin-top: 5px;"><input value="1" id="diInclTags" type="checkbox" name="di[<?php echo $ii; ?>][diInclTags]" <?php if ((int)$options['diInclTags'] == 1) echo "checked"; ?> />
67
- <strong><?php _e('Post with tags', 'social-networks-auto-poster-facebook-twitter-g'); ?></strong> <?php _e('Tags from the blogpost will be auto posted to Diigo', 'social-networks-auto-poster-facebook-twitter-g'); ?>
68
- </p>
69
-
70
- <div id="altFormat" style="">
71
- <div style="width:100%;"><strong id="altFormatText"><?php _e('Post Title Format', 'social-networks-auto-poster-facebook-twitter-g'); ?></strong> (<a href="#" id="apDIMsgTFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apDIMsgTFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>)</div>
72
- <input name="di[<?php echo $ii; ?>][apDIMsgTFrmt]" id="apDIMsgTFrmt<?php echo $ii; ?>" style="width: 50%;" value="<?php if ($isNew) echo "%TITLE%"; else _e(apply_filters('format_to_edit', htmlentities($options['diMsgTFormat'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g'); ?>" onfocus="mxs_showFrmtInfo('apDIMsgTFrmt<?php echo $ii; ?>');" /><?php nxs_doShowHint("apDIMsgTFrmt".$ii); ?>
73
- </div><br/>
74
-
75
- <div id="altFormat" style="">
76
- <div style="width:100%;"><strong id="altFormatText"><?php _e('Post Text Format', 'social-networks-auto-poster-facebook-twitter-g'); ?></strong> (<a href="#" id="apDIMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apDIMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>)</div>
77
-
78
-
79
- <textarea cols="150" rows="3" id="di<?php echo $ii; ?>SNAPformat" name="di[<?php echo $ii; ?>][apDIMsgFrmt]" style="width:51%;max-width: 650px;" onfocus="jQuery('#di<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('apDIMsgFrmt<?php echo $ii; ?>');"><?php if ($isNew) echo "%EXCERPT%"; else _e(apply_filters('format_to_edit', htmlentities($options['diMsgFormat'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g'); ?></textarea>
80
-
81
- <?php nxs_doShowHint("apDIMsgFrmt".$ii); ?>
82
- </div><br/>
83
-
84
- <?php if ($options['diPass']!='') { ?>
85
-
86
- <b><?php _e('Test your settings', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('DI', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?></a> <?php }
87
- ?>
88
- </div>
89
- <?php /* ######################## Advanced Tab ####################### */ ?>
90
- <?php if (!$isNew) { ?> <div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content">
91
-
92
- <?php nxs_showCatTagsCTFilters($nt, $ii, $options);
93
- nxs_addPostingDelaySelV3($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']);
94
- nxs_showRepostSettings($nt, $ii, $options); ?>
95
-
96
- </div> <?php } ?> <?php /* #### End of Tab #### */ ?>
97
- </div><br/> <?php /* #### End of Tabs #### */ ?>
98
-
99
- <div class="submitX nxclear" style="padding-bottom: 0px;"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'social-networks-auto-poster-facebook-twitter-g') ?>" /></div>
100
- </div><?php
101
  }
 
102
  //#### Set Unit Settings from POST
103
- function setNTSettings($post, $options){ $code = 'DI'; $lcode = 'di';
104
- foreach ($post as $ii => $pval){
105
-
106
- if (!empty($pval['apDIUName']) && !empty($pval['apDIPass'])){ if (!isset($options[$ii])) $options[$ii] = array();
107
- if (isset($pval['apDIUName'])) $options[$ii]['diUName'] = trim($pval['apDIUName']);
108
- if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']);
109
- if (isset($pval['apDIPass'])) $options[$ii]['diPass'] = 'n5g9a'.nsx_doEncode($pval['apDIPass']); else $options[$ii]['diPass'] = '';
110
- if (isset($pval['apDIAPIKey'])) $options[$ii]['diAPIKey'] = trim($pval['apDIAPIKey']);
111
-
112
- if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']); else $options[$ii]['catSel'] = 0;
113
- if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
114
-
115
- if (isset($pval['diInclTags'])) $options[$ii]['diInclTags'] = $pval['diInclTags']; else $options[$ii]['diInclTags'] = 0;
116
- if (isset($pval['apDIMsgTFrmt'])) $options[$ii]['diMsgTFormat'] = trim($pval['apDIMsgTFrmt']);
117
- if (isset($pval['apDIMsgFrmt'])) $options[$ii]['diMsgFormat'] = trim($pval['apDIMsgFrmt']);
118
- if (isset($pval['apDoDI'])) $options[$ii]['doDI'] = $pval['apDoDI']; else $options[$ii]['doDI'] = 0;
119
-
120
- $options[$ii] = nxs_adjRpst($options[$ii], $pval);
121
-
122
- if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']);
123
- if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
124
- if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
125
- } elseif ( count($pval)==1 ) if (isset($pval['apDo'.$code])) $options[$ii]['do'.$code] = $pval['apDo'.$code]; else $options[$ii]['do'.$code] = 0;
126
  } return $options;
127
- }
 
128
  //#### Show Post->Edit Meta Box Settings
129
- function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID; $nt = 'di'; $ntU = 'DI';
130
- 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]);
131
- $doDI = $ntOpt['doDI'] && (is_array($pMeta) || $ntOpt['catSel']!='1');
132
- $isAvailDI = $ntOpt['diUName']!='' && $ntOpt['diPass']!=''; $diMsgFormat = htmlentities($ntOpt['diMsgFormat'], ENT_COMPAT, "UTF-8"); $diMsgTFormat = htmlentities($ntOpt['diMsgTFormat'], ENT_COMPAT, "UTF-8");
133
- ?>
134
- <tr><th style="text-align:left;" colspan="2">
135
- <?php if ($ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='') { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
136
- <?php if (!empty($ntOpt['tagsSelX'])) { ?> <input type="hidden" class="nxs_TG" id="nxs_TG_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $ntOpt['tagsSelX']; ?>" /> <?php } ?>
137
- <?php if ($isAvailDI) { ?><input class="nxsGrpDoChb" value="1" id="doDI<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="di[<?php echo $ii; ?>][doDI]" <?php if ((int)$doDI == 1) echo 'checked="checked" title="def"'; ?> />
138
- <?php if ($post->post_status == "publish") { ?> <input type="hidden" name="di[<?php echo $ii; ?>][doDI]" value="<?php echo $doDI;?>"> <?php } ?> <?php } ?>
139
-
140
- <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/di16.png);">Diigo - <?php _e('publish to', 'social-networks-auto-poster-facebook-twitter-g') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
141
- 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', 'social-networks-auto-poster-facebook-twitter-g') ?>" />
142
- <?php } ?>
143
- <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
144
- ?> <span id="pstdDI<?php echo $ii; ?>" style="float: right; padding-top: 4px; padding-right: 10px;">
145
- <a style="font-size: 10px;" href="http://www.diigo.com/user/<?php echo $ntOpt['diUName']; ?>" target="_blank"><?php $nType="Diigo"; printf( __( 'Posted on', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
146
- </span><?php } ?>
147
- </td></tr>
148
- <?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>
149
- <?php } else { if ($post->post_status != "publish" && function_exists('nxs_doSMAS5') ) { $ntOpt['postTime'] = get_post_time('U', false, $post_id); nxs_doSMAS5($nt, $ii, $ntOpt); } ?>
150
-
151
- <?php if ($ntOpt['rpstOn']=='1') { ?>
152
-
153
- <tr id="altFormat1" style=""><th scope="row" class="nxsTHRow">
154
- <input value="0" type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]"/><input value="nxsi<?php echo $ii; ?>di" type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]" <?php if (!empty($ntOpt['rpstPostIncl'])) echo "checked"; ?> />
155
- </th>
156
- <td> <?php _e('Include in "Auto-Reposting" to this network.', 'social-networks-auto-poster-facebook-twitter-g') ?>
157
- </td></tr> <?php } ?>
158
-
159
- <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Title Format:', 'social-networks-auto-poster-facebook-twitter-g') ?></th>
160
- <td><input value="<?php echo $diMsgTFormat ?>" type="text" name="di[<?php echo $ii; ?>][SNAPformatT]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apDIMsgTFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apDIMsgTFrmt".$ii, '', '58'); ?></td></tr>
161
- <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Text Format:', 'social-networks-auto-poster-facebook-twitter-g') ?></th>
162
- <td>
163
- <textarea cols="150" rows="1" id="di<?php echo $ii; ?>SNAPformat" name="di[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('#di<?php echo $ii; ?>SNAPformat').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apDIMsgFrmt<?php echo $ii; ?>');"><?php echo $diMsgFormat; ?></textarea>
164
- <?php nxs_doShowHint("apDIMsgFrmt".$ii, '', '58'); ?></td></tr>
165
- <?php }
166
  }
167
- }
168
- //#### Save Meta Tags to the Post
169
- function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
170
- if (isset($pMeta['SNAPformat'])) $optMt['diMsgFormat'] = $pMeta['SNAPformat'];
171
- if (isset($pMeta['SNAPformatT'])) $optMt['diMsgTFormat'] = $pMeta['SNAPformatT'];
172
- if (isset($pMeta['imgToUse'])) $optMt['imgToUse'] = $pMeta['imgToUse'];
173
- if (isset($pMeta['timeToRun'])) $optMt['timeToRun'] = $pMeta['timeToRun']; if (isset($pMeta['rpstPostIncl'])) $optMt['rpstPostIncl'] = $pMeta['rpstPostIncl'];
174
- if (isset($pMeta['doDI'])) $optMt['doDI'] = $pMeta['doDI'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doDI'] = 0; }
175
- if (isset($pMeta['SNAPincludeDI']) && $pMeta['SNAPincludeDI'] == '1' ) $optMt['doDI'] = 1;
176
- return $optMt;
177
  }
178
- }}
179
- if (!function_exists("nxs_rePostToDI_ajax")) {
180
- function nxs_rePostToDI_ajax() { check_ajax_referer('nxsSsPageWPN'); $postID = $_POST['id']; $options = get_option('NS_SNAutoPoster');
181
- foreach ($options['di'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj'; //if ($two['gpPageID'].$two['gpUName']==$_POST['nid']) {
182
- $gppo = get_post_meta($postID, 'snapDI', true); $gppo = maybe_unserialize($gppo);// prr($gppo);
183
- if (is_array($gppo) && isset($gppo[$ii]) && is_array($gppo[$ii])){ $ntClInst = new nxs_snapClassDI(); $two = $ntClInst->adjMetaOpt($two, $gppo[$ii]); }
184
- $result = nxs_doPublishToDI($postID, $two); if ($result == 200) die("Successfully sent your post to Diigo."); else die($result);
185
- }
186
  }
187
- }
 
 
 
 
 
188
 
189
- if (!function_exists("nxs_doPublishToDI")) { //## Second Function to Post to DI
190
- function nxs_doPublishToDI($postID, $options){ global $nxs_diCkArray; $ntCd = 'DI'; $ntCdL = 'di'; $ntNm = 'Diigo'; if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
191
- // if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToDI', array($postID, $options));
192
- $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'POSTID'=>$postID, 'ACCNAME'=>$options['nName']));
193
- $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url();
194
- $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
195
- $logNT = '<span style="color:#000080">Diigo</span> - '.$options['nName'];
196
- $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
197
- if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
198
- $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') { sleep(5);
199
- nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'); return;
200
- }
201
- }
202
- if (empty($postID)) { echo "Testing ... <br/><br/>"; $urlToGo = home_url(); $options['diMsgFormat'] = 'Test Message from '.$urlToGo; $options['diMsgTFormat'] = 'Test Link from '.$urlToGo; } else {
203
- $post = get_post($postID); $options = nxs_getURL($options, $postID, $addParams); $urlToGo = $options['urlToUse'];
204
- $options['diMsgFormat'] = nxs_decodeEntitiesFull(nsFormatMessage( $options['diMsgFormat'], $postID, $addParams)); $options['diMsgTFormat'] = nxs_decodeEntitiesFull(nsFormatMessage($options['diMsgTFormat'], $postID, $addParams));
205
- nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
206
- }
207
- $extInfo = ' | PostID: '.$postID." - ".(isset($post) && is_object($post)?$post->post_title:'');
208
- //## Create and Format message
209
- $t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = (implode(',',$tggs)); $tags = str_replace(' ','+',$tags);
210
- $message = array('url'=>$urlToGo, 'surl'=>$urlToGo, 'siteName'=>$blogTitle, 'tags'=>$tags);
211
- //## Actual Post
212
- $ntToPost = new nxs_class_SNAP_DI(); $ret = $ntToPost->doPostToNT($options, $message);
213
- //## Process Results
214
- if (!is_array($ret) || $ret['isPosted']!='1') { //## Error
215
- if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);
216
- } else { // ## All Good - log it.
217
- if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo _e('OK - Message Posted, please see your '.$logNT.' Page. ', 'social-networks-auto-poster-facebook-twitter-g'); }
218
- else { nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPosted'=>'1', 'pgID'=>$ret['postID'], 'pDate'=>date('Y-m-d H:i:s'))); nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); }
219
- }
220
- //## Return Result
221
- if (!empty($ret['isPosted']) && $ret['isPosted']=='1') return 200; else return print_r($ret, true);
222
- }
223
- }
224
  ?>
1
  <?php
2
+ //## NextScripts Diigo Connection Class
3
+ $nxs_snapAvNts[] = array('code'=>'DI', 'lcode'=>'di', 'name'=>'Diigo', 'type'=>'Link Sharing/Boormarks', 'ptype'=>'F', 'status'=>'A', 'desc'=>'Auto-submit bookmark to your account');
4
 
5
+ if (!class_exists("nxs_snapClassDI")) { class nxs_snapClassDI extends nxs_snapClassNT {
6
+ var $ntInfo = array('code'=>'DI', 'lcode'=>'di', 'name'=>'Diigo', 'defNName'=>'uName', 'tstReq' => false, 'instrURL'=>'http://www.nextscripts.com/setup-installation-diigo-social-networks-auto-poster-wordpress/');
7
 
8
+ function toLatestVer($ntOpts){ if( !empty($ntOpts['v'])) $v = $ntOpts['v']; else $v = 340; $ntOptsOut = ''; switch ($v) {
9
+ case 340: $ntOptsOut = $this->toLatestVerNTGen($ntOpts); $ntOptsOut['do'] = $ntOpts['do'.$this->ntInfo['code']]; $ntOptsOut['nName'] = $ntOpts['nName']; $ntOptsOut['inclTags'] = $ntOpts['diInclTags'];
10
+ $ntOptsOut['msgTFormat'] = $ntOpts['diMsgTFormat']; $ntOptsOut['msgFormat'] = $ntOpts['diMsgFormat']; $ntOptsOut['uName'] = $ntOpts['diUName']; $ntOptsOut['uPass'] = $ntOpts['diPass']; $ntOptsOut['apiKey'] = $ntOpts['diAPIKey'];
11
+ $ntOptsOut['isUpdd'] = '1'; $ntOptsOut['v'] = NXS_SETV;
12
+ break;
13
+ }
14
+ return !empty($ntOptsOut)?$ntOptsOut:$ntOpts;
15
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
+ //#### Show Common Settings
18
+ function showGenNTSettings($ntOpts){ $this->nt = $ntOpts; $this->showNTGroup(); return; }
19
  //#### Show NEW Settings Page
20
+ function showNewNTSettings($ii){ $defO = array('nName'=>'', 'do'=>'1', 'uName'=>'', 'uPass'=>'', 'apiKey'=>'', 'inclTags'=>'1', 'msgTFormat'=>'%TITLE%', 'msgFormat'=>"%EXCERPT%"); $this->showGNewNTSettings($ii, $defO); }
21
+ //#### Show Unit Settings
22
+ function checkIfSetupFinished($options) { return !empty($options['uPass']); }
23
+ function accTab($ii, $options, $isNew=false){ $ntInfo = $this->ntInfo; $nt = $ntInfo['lcode']; ?><div id="altFormat" style="">
24
+ <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>
25
+ <input name="<?php echo $nt; ?>[<?php echo $ii; ?>][apiKey]" style="width: 60%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['apiKey'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /> <br/>
26
+ </div><?php $this->elemUserPass($ii, $options['uName'], $options['uPass']); $this->elemTitleFormat($ii,'Message Title Format','msgTFormat',$options['msgTFormat']);
27
+ $this->elemMsgFormat($ii,'Message Text Format','msgFormat',$options['msgFormat']);?><br/ >
28
+ <div style="margin-bottom: 20px;margin-top: 5px;"><input value="1" type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][inclTags]" <?php if ((int)$options['inclTags'] == 1) echo "checked"; ?> />
29
+ <strong><?php _e('Post with tags', 'social-networks-auto-poster-facebook-twitter-g'); ?></strong> <?php _e('Tags from the blogpost will be included', 'social-networks-auto-poster-facebook-twitter-g'); ?>
30
+ </div> <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  }
32
+ function advTab($ii, $options){}
33
  //#### Set Unit Settings from POST
34
+ function setNTSettings($post, $options){
35
+ foreach ($post as $ii => $pval){
36
+ if (!empty($pval['uPass']) && !empty($pval['uPass'])){ if (!isset($options[$ii])) $options[$ii] = array(); $options[$ii] = $this->saveCommonNTSettings($pval,$options[$ii]);
37
+ } elseif ( count($pval)==1 ) if (isset($pval['do'])) $options[$ii]['do'] = $pval['do']; else $options[$ii]['do'] = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  } return $options;
39
+ }
40
+
41
  //#### Show Post->Edit Meta Box Settings
42
+ function showEdPostNTSettings($ntOpts, $post){ $post_id = $post->ID; $nt = $this->ntInfo['lcode']; $ntU = $this->ntInfo['code'];
43
+ foreach($ntOpts as $ii=>$ntOpt) { $isFin = $this->checkIfSetupFinished($ntOpt); if (!$isFin) continue;
44
+ $pMeta = maybe_unserialize(get_post_meta($post_id, 'snap'.$ntU, true)); if (is_array($pMeta) && !empty($pMeta[$ii])) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
45
+
46
+ if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = ''; if (empty($ntOpt['urlToUse'])) $ntOpt['urlToUse'] = ''; $postType = isset($ntOpt['postType'])?$ntOpt['postType']:'';
47
+ $msgFormat = !empty($ntOpt['msgFormat'])?htmlentities($ntOpt['msgFormat'], ENT_COMPAT, "UTF-8"):''; $msgTFormat = !empty($ntOpt['msgTFormat'])?htmlentities($ntOpt['msgTFormat'], ENT_COMPAT, "UTF-8"):'';
48
+ $imgToUse = $ntOpt['imgToUse']; $urlToUse = $ntOpt['urlToUse']; $ntOpt['ii']=$ii;
49
+
50
+ $this->nxs_tmpltAddPostMeta($post, $ntOpt, $pMeta); ?>
51
+ <?php $this->elemEdTitleFormat($ii, __('Title Format:', 'social-networks-auto-poster-facebook-twitter-g'),$msgTFormat); $this->elemEdMsgFormat($ii, __('Message Format:', 'social-networks-auto-poster-facebook-twitter-g'),$msgFormat);
52
+ /* ## Select Image & URL ## */ nxs_showURLToUseDlg($nt, $ii, $urlToUse); $this->nxs_tmpltAddPostMetaEnd($ii);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  }
 
 
 
 
 
 
 
 
 
 
54
  }
55
+ //#### Save Meta Tags to the Post
56
+ function adjMetaOpt($optMt, $pMeta){ $optMt = $this->adjMetaOptG($optMt, $pMeta); // prr($optMt);
57
+ return $optMt;
 
 
 
 
 
58
  }
59
+
60
+ function adjPublishWP(&$options, &$message, $postID){
61
+
62
+ }
63
+
64
+ }}
65
 
66
+ if (!function_exists("nxs_doPublishToDI")) { function nxs_doPublishToDI($postID, $options){ if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
67
+ $cl = new nxs_snapClassDI(); $cl->nt[$options['ii']] = $options; return $cl->publishWP($options['ii'], $postID);
68
+ }}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  ?>
inc-cl/dl.api.php CHANGED
@@ -10,19 +10,10 @@ if (!class_exists("nxs_class_SNAP_DL")) { class nxs_class_SNAP_DL {
10
  function doPost($options, $message){ if (!is_array($options)) return false; $out = array();
11
  foreach ($options as $ii=>$ntOpts) $out[$ii] = $this->doPostToNT($ntOpts, $message);
12
  return $out;
13
- }
14
- function nxs_getDLHeaders($up){ $hdrsArr = array();
15
- $hdrsArr['Cache-Control']='no-cache'; $hdrsArr['Connection']='keep-alive';
16
- $hdrsArr['User-Agent']='SNAP for Wordpress; Ver 3';
17
- $hdrsArr['Accept']='text/html, application/xhtml+xml, */*'; $hdrsArr['DNT']='1';
18
- $hdrsArr['Authorization'] = 'Basic ' . base64_encode("$up");
19
- if (function_exists('gzdeflate')) $hdrsArr['Accept-Encoding']='gzip,deflate';
20
- $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;
21
- }
22
-
23
  function getHeaders($ref, $org='', $post=false, $aj=false){ $hdrsArr = array();
24
  $hdrsArr['Cache-Control']='max-age=0'; $hdrsArr['Connection']='keep-alive'; $hdrsArr['Referer']=$ref;
25
- $hdrsArr['User-Agent']='Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.22 Safari/537.36';
26
  if($post==='j') $hdrsArr['Content-Type']='application/json;charset=UTF-8'; elseif($post===true) $hdrsArr['Content-Type']='application/x-www-form-urlencoded';
27
  if($aj===true) $hdrsArr['X-Requested-With']='XMLHttpRequest'; if ($org!='') $hdrsArr['Origin']=$org;
28
  $hdrsArr['Accept']='text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';// $hdrsArr['DNT']='1';
@@ -33,24 +24,29 @@ if (!class_exists("nxs_class_SNAP_DL")) { class nxs_class_SNAP_DL {
33
  function doPostToNT($options, $message){ $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>'');
34
  //## Check settings
35
  if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
36
- if (!isset($options['dlUName']) || trim($options['dlPass'])=='') { $badOut['Error'] = 'Not Configured'; return $badOut; }
37
- $email = $options['dlUName']; $pass = substr($options['dlPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['dlPass'], 5)):$options['dlPass'];
38
  //## Format
39
- if (!empty($message['pText'])) $msg = $message['pText']; else $msg = nxs_doFormatMsg($options['dlMsgFormat'], $message);
40
- if (!empty($message['pTitle'])) $msgT = $message['pTitle']; else $msgT = nxs_doFormatMsg($options['dlMsgTFormat'], $message); $tags = nsTrnc($message['tags'], 195, ',', '');
41
 
42
  $link = $message['url']; $desc = substr($msgT, 0, 250); $ext = substr($msg, 0, 1000);
43
- $hdrsArr = $this->getHeaders('https://delicious.com','https://delicious.com',true); $flds = array('username'=>$email, 'password'=>base64_encode(strrev($pass)));
44
- $cnt = wp_remote_post( 'https://avosapi.delicious.com/api/v1/account/login', array( 'method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'body'=>$flds, 'headers' => $hdrsArr) );
45
- if (is_nxs_error($cnt)) { $badOut = "ERROR (Login Form): ".print_r($rep, true); return $badOut; } $rep = json_decode($cnt['body'], true);
46
-
47
- if ($rep['status']!='success') { $badOut = "ERROR (Login): ".print_r($rep, true); return $badOut; } $ck = $cnt['cookies'];
48
- $flds = array('url'=>$link, 'description'=>$desc, 'tags'=>$tags, 'note'=>$ext, 'replace'=>'true', 'private'=>'false', 'share'=>'');
49
- $advSts = array( 'method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'body'=>$flds, 'cookies' => $ck, 'headers' => $hdrsArr); //prr($advSts);
50
- $cnt = wp_remote_post( 'https://avosapi.delicious.com/api/v1/posts/addoredit', $advSts );
51
- if (is_nxs_error($cnt)) { $badOut = "ERROR (Login Form): ".print_r($rep, true); return $badOut; } $rep = json_decode($cnt['body'], true);
52
- if ($rep['status']!='success') { $badOut = "ERROR (Login): ".print_r($rep, true); return $badOut; }
53
- return array('postID'=>md5($message['url']), 'isPosted'=>1, 'postURL'=>'https://delicious.com/link/'.md5($message['url']), 'pDate'=>date('Y-m-d H:i:s'));
 
 
 
 
 
54
  }
55
  }}
56
  ?>
10
  function doPost($options, $message){ if (!is_array($options)) return false; $out = array();
11
  foreach ($options as $ii=>$ntOpts) $out[$ii] = $this->doPostToNT($ntOpts, $message);
12
  return $out;
13
+ }
 
 
 
 
 
 
 
 
 
14
  function getHeaders($ref, $org='', $post=false, $aj=false){ $hdrsArr = array();
15
  $hdrsArr['Cache-Control']='max-age=0'; $hdrsArr['Connection']='keep-alive'; $hdrsArr['Referer']=$ref;
16
+ $hdrsArr['User-Agent']='Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.36 Safari/537.36';
17
  if($post==='j') $hdrsArr['Content-Type']='application/json;charset=UTF-8'; elseif($post===true) $hdrsArr['Content-Type']='application/x-www-form-urlencoded';
18
  if($aj===true) $hdrsArr['X-Requested-With']='XMLHttpRequest'; if ($org!='') $hdrsArr['Origin']=$org;
19
  $hdrsArr['Accept']='text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';// $hdrsArr['DNT']='1';
24
  function doPostToNT($options, $message){ $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>'');
25
  //## Check settings
26
  if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
27
+ if (!isset($options['uName']) || trim($options['uPass'])=='') { $badOut['Error'] = 'Not Configured'; return $badOut; }
28
+ $email = $options['uName']; $pass = (substr($options['uPass'], 0, 5)=='g9c1a' || substr($options['uPass'], 0, 5)=='n5g9a')?nsx_doDecode(substr($options['uPass'], 5)):$options['uPass'];
29
  //## Format
30
+ if (!empty($message['pText'])) $msg = $message['pText']; else $msg = nxs_doFormatMsg($options['msgFormat'], $message);
31
+ if (!empty($message['pTitle'])) $msgT = $message['pTitle']; else $msgT = nxs_doFormatMsg($options['msgTFormat'], $message); $tags = nsTrnc($message['tags'], 195, ',', '');
32
 
33
  $link = $message['url']; $desc = substr($msgT, 0, 250); $ext = substr($msg, 0, 1000);
34
+ //$hdrsArr = $this->getHeaders('http://del.icio.us','http://del.icio.us',true); $flds = array('username'=>$email, 'password'=>base64_encode(strrev($pass)));
35
+ $hdrsArr = $this->getHeaders('https://del.icio.us','https://del.icio.us',true); $flds = array('username'=>$email, 'password'=>$pass);
36
+ $advSet = nxs_mkRemOptsArr($hdrsArr, '', $flds); $cnt = nxs_remote_post( 'https://del.icio.us/login', $advSet );
37
+ if (is_nxs_error($cnt)) { $badOut = "ERROR (Login Form): ".print_r($cnt, true); return $badOut; } $rep = json_decode($cnt['body'], true);
38
+ if ($rep['status']!='success') { $badOut = "ERROR (Login): ".print_r($cnt, true); return $badOut; } $ck = $cnt['cookies']; $ckk = explode('=', $rep['session'],1);
39
+ $ckX = new WP_Http_Cookie( array( 'name' => $ckk[0], 'value' => $ckk[1] )); $ck[] = $ckX; foreach ($ck as $ci=>$cc) $ck[$ci]->value = str_replace(' ','+', $cc->value);
40
+ $hdrsArr = $this->getHeaders('https://del.icio.us/',''); $hdrsArr['Accept'] = '*/*';
41
+ $advSet = nxs_mkRemOptsArr($hdrsArr, $ck); $cnt = nxs_remote_get( 'https://del.icio.us/save/get_iframe_savelink?url=&title=&notes=', $advSet );// prr($cnt);
42
+ if (is_nxs_error($cnt)) { $badOut = "ERROR (Login Form): ".print_r($cnt, true); return $badOut; } $ct = CutFromTo($cnt['body'],'csrf_token="','"');
43
+ $ck = $cnt['cookies']; $ck[] = $ckX; foreach ($ck as $ci=>$cc) $ck[$ci]->value = str_replace(' ','+', $cc->value);
44
+ $flds = array('url'=>$link, 'description'=>$desc, 'tags'=>$tags, 'note'=>$ext, 'replace'=>'true', 'private'=>'false', 'share'=>'', 'csrf_token'=>$ct);
45
+ $hdrsArr = $this->getHeaders('https://del.icio.us/save/get_iframe_savelink?url=&title=&notes=','https://del.icio.us',true, true); $hdrsArr['Accept']='application/json, text/javascript, */*; q=0.01';
46
+ $advSet = nxs_mkRemOptsArr($hdrsArr, $ck, $flds); $cnt = nxs_remote_post( 'https://del.icio.us/save/bookmark', $advSet ); // prr($advSet);
47
+ if (is_nxs_error($cnt)) { $badOut = "ERROR (Post Form): ".print_r($rep, true); return $badOut; } $rep = json_decode($cnt['body'], true);// prr($rep);
48
+ if (empty($rep['save_status']) || ($rep['save_status']!='new' && $rep['save_status']!='update')) { $badOut = "ERROR (Post): ".print_r($cnt, true); return $badOut; }
49
+ return array('postID'=>md5($message['url']), 'isPosted'=>1, 'postURL'=>'https://del.icio.us/url/'.md5($message['url']), 'pDate'=>date('Y-m-d H:i:s'));
50
  }
51
  }}
52
  ?>
inc-cl/dl.php CHANGED
@@ -1,221 +1,63 @@
1
  <?php
2
- //## NextScripts Facebook Connection Class
3
- $nxs_snapAvNts[] = array('code'=>'DL', 'lcode'=>'dl', 'name'=>'Delicious');
4
 
5
- if (!class_exists("nxs_snapClassDL")) { class nxs_snapClassDL {
6
- //#### Show Common Settings
7
- function showGenNTSettings($ntOpts){ global $nxs_plurl; $ntInfo = array('code'=>'DL', 'lcode'=>'dl', 'name'=>'Delicious', 'defNName'=>'dlUName', 'tstReq' => false); ?>
8
- <div class="nxs_box">
9
- <div class="nxs_box_header">
10
- <div class="nsx_iconedTitle" style="margin-bottom:1px;background-image:url(<?php echo $nxs_plurl;?>img/<?php echo $ntInfo['lcode']; ?>16.png);"><?php echo $ntInfo['name']; ?>
11
- <?php $cbo = count($ntOpts); ?>
12
- <?php if ($cbo>1){ ?><div class="nsBigText"><?php echo "(".($cbo=='0'?'No':$cbo)." "; _e('accounts', 'social-networks-auto-poster-facebook-twitter-g'); echo ")"; ?></div><?php } ?>
13
- </div>
14
- </div>
15
- <div class="nxs_box_inside">
16
- <?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
17
- <p style="margin:0px;margin-left:5px;"> <img id="<?php echo $ntInfo['code'].$indx;?>LoadingImg" style="display: none;" src='<?php echo $nxs_plurl; ?>img/ajax-loader-sm.gif' />
18
- <input value="0" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" type="hidden" />
19
- <?php if ((int)$pbo['do'.$ntInfo['code']] == 1 && isset($pbo['catSel']) && (int)$pbo['catSel'] == 1) { ?> <input type="radio" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" id="rbtn<?php echo $ntInfo['lcode'].$indx; ?>" value="1" checked="checked" onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);" /> <?php } else { ?>
20
- <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1 && $pbo['catSel']!='1') echo "checked"; ?> />
21
- <?php } ?>
22
- <?php if (isset($pbo['catSel']) && (int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
23
- <?php if (isset($pbo['rpstOn']) && (int)$pbo['rpstOn'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popReActive');" onmouseover="nxs_showPopUpInfo('popReActive', event);"><?php echo "*[R]*" ?></span><?php } ?>
24
- <strong><?php _e('Auto-publish to', 'social-networks-auto-poster-facebook-twitter-g'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
25
- &nbsp;&nbsp;<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'social-networks-auto-poster-facebook-twitter-g'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>AG" href="#" onclick="doGetHideNTBlock('<?php echo $ntInfo['code'];?>' , '<?php echo $indx; ?>');return false;">[<?php _e('Show Settings', 'social-networks-auto-poster-facebook-twitter-g'); ?>]</a>&nbsp;&nbsp;
26
- <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'social-networks-auto-poster-facebook-twitter-g'); ?>]</a>
27
- </p><div id="nxsNTSetDiv<?php echo $ntInfo['code'].$indx; ?>"></div><?php //$pbo['ntInfo'] = $ntInfo; $this->showNTSettings($indx, $pbo);
28
- }?>
29
- </div>
30
- </div> <?php
31
- }
32
- //#### Show NEW Settings Page
33
- function showNewNTSettings($mgpo){ $options = array('nName'=>'', 'doDL'=>'1', 'dlUName'=>'', 'dlPageID'=>'', 'dlAttch'=>'', 'dlPass'=>''); $options['ntInfo']= array('lcode'=>'dl'); $this->showNTSettings($mgpo, $options, true);}
34
- //#### Show Unit Settings
35
- function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl; $nt = $options['ntInfo']['lcode']; $ntU = strtoupper($nt);
36
- 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'] = '';
37
- if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; ?>
38
- <div id="doDL<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>" style="max-width: 1000px; background-color: #EBF4FB; margin: 10px; border: 1px solid #808080; padding: 10px; display:none;"> <input type="hidden" name="apDoSDL<?php echo $ii; ?>" value="0" id="apDoSDL<?php echo $ii; ?>" />
39
-
40
- <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/"><?php $nType="Delicious"; printf( __( 'Detailed %s Installation/Configuration Instructions', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?></a></div>
41
-
42
- <div style="width:100%;"><strong><?php _e('Account Nickname', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'social-networks-auto-poster-facebook-twitter-g'); ?></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($options['nName'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /><br/>
43
- <?php echo nxs_addQTranslSel('dl', $ii, $options['qTLng']); ?>
44
-
45
- <br/>
46
- <ul class="nsx_tabs">
47
- <li><a href="#nsx<?php echo $nt.$ii ?>_tab1"><?php _e('Account Info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li>
48
- <?php if (!$isNew) { ?> <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li> <?php } ?>
49
- </ul>
50
- <div class="nsx_tab_container"><?php /* ######################## Account Tab ####################### */ ?>
51
- <div id="nsx<?php echo $nt.$ii ?>_tab1" class="nsx_tab_content" style="background-image: url(<?php echo $nxs_plurl; ?>img/<?php echo $nt; ?>-bg.png); background-repeat: no-repeat; background-position:90% 10%;">
52
-
53
-
54
- <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($options['dlUName'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />
55
- <div style="width:100%;"><strong>Delicious Password:</strong> </div><input autocomplete="false" readonly onfocus="this.removeAttribute('readonly');" name="dl[<?php echo $ii; ?>][apDLPass]" id="apDLPass" type="password" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities(substr($options['dlPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['dlPass'], 5)):$options['dlPass'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /> <br/>
56
-
57
- <?php if ($isNew) { ?> <input type="hidden" name="dl[<?php echo $ii; ?>][apDoDL]" value="1" id="apDoNewDL<?php echo $ii; ?>" /> <?php } ?>
58
- <br/>
59
-
60
- <div id="altFormat" style="">
61
- <div style="width:100%;"><strong id="altFormatText"><?php _e('Post Title Format', 'social-networks-auto-poster-facebook-twitter-g'); ?></strong> (<a href="#" id="apDLTMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apDLTMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>)</div>
62
 
63
- <input name="dl[<?php echo $ii; ?>][apDLMsgTFrmt]" id="apDLMsgTFrmt" style="width: 50%;" value="<?php if ($isNew) echo "%TITLE%"; else _e(apply_filters('format_to_edit',htmlentities($options['dlMsgTFormat'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g'); ?>" onfocus="mxs_showFrmtInfo('apDLTMsgFrmt<?php echo $ii; ?>');" /><?php nxs_doShowHint("apDLTMsgFrmt".$ii); ?>
64
- </div>
65
-
66
- <div id="altFormat" style="">
67
- <div style="width:100%;"><strong id="altFormatText"><?php _e('Post Text Format', 'social-networks-auto-poster-facebook-twitter-g'); ?></strong> (<a href="#" id="apDLMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apDLMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>)</div>
 
 
68
 
69
- <textarea cols="150" rows="3" id="di<?php echo $ii; ?>SNAPformat" name="dl[<?php echo $ii; ?>][apDLMsgFrmt]" style="width:51%;max-width: 650px;" onfocus="jQuery('#dl<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('apDLMsgFrmt<?php echo $ii; ?>');"><?php if ($isNew) echo "%EXCERPT%"; else _e(apply_filters('format_to_edit', htmlentities($options['dlMsgFormat'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g'); ?></textarea>
70
-
71
- <?php nxs_doShowHint("apDLMsgFrmt".$ii); ?>
72
- </div><br/>
73
-
74
- <?php if ($options['dlPass']!='') { ?>
75
-
76
- <b><?php _e('Test your settings', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('DL', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?></a>
77
-
78
- <?php }
79
-
80
- ?></div>
81
- <?php /* ######################## Advanced Tab ####################### */ ?>
82
- <?php if (!$isNew) { ?> <div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content">
83
-
84
- <?php nxs_showCatTagsCTFilters($nt, $ii, $options);
85
- nxs_addPostingDelaySelV3($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']);
86
- nxs_showRepostSettings($nt, $ii, $options); ?>
87
-
88
-
89
- </div> <?php } ?> <?php /* #### End of Tab #### */ ?>
90
- </div><br/> <?php /* #### End of Tabs #### */ ?>
91
-
92
- <div class="submitX nxclear" style="padding-bottom: 0px;"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'social-networks-auto-poster-facebook-twitter-g') ?>" /></div></div><?php
93
  }
 
94
  //#### Set Unit Settings from POST
95
- function setNTSettings($post, $options){$code = 'DL'; $lcode = 'dl';
96
  foreach ($post as $ii => $pval){
97
- if (!empty($pval['apDLUName']) && !empty($pval['apDLPass'])){ if (!isset($options[$ii])) $options[$ii] = array();
98
- if (isset($pval['apDLUName'])) $options[$ii]['dlUName'] = trim($pval['apDLUName']);
99
- if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']);
100
- if (isset($pval['apDLPass'])) $options[$ii]['dlPass'] = 'n5g9a'.nsx_doEncode($pval['apDLPass']); else $options[$ii]['dlPass'] = '';
101
-
102
- if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']); else $options[$ii]['catSel'] = 0;
103
- if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
104
-
105
- if (isset($pval['apDLMsgFrmt'])) $options[$ii]['dlMsgFormat'] = trim($pval['apDLMsgFrmt']);
106
- if (isset($pval['apDLMsgTFrmt'])) $options[$ii]['dlMsgTFormat'] = trim($pval['apDLMsgTFrmt']);
107
- if (isset($pval['apDoDL'])) $options[$ii]['doDL'] = $pval['apDoDL']; else $options[$ii]['doDL'] = 0;
108
-
109
- $options[$ii] = nxs_adjRpst($options[$ii], $pval);
110
-
111
- if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']);
112
- if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
113
- if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
114
- } elseif ( count($pval)==1 ) if (isset($pval['apDo'.$code])) $options[$ii]['do'.$code] = $pval['apDo'.$code]; else $options[$ii]['do'.$code] = 0;
115
  } return $options;
116
- }
 
117
  //#### Show Post->Edit Meta Box Settings
118
- function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID; $nt = 'dl'; $ntU = 'DL';
119
- 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]);
120
- $doDL = $ntOpt['doDL'] && (is_array($pMeta) || $ntOpt['catSel']!='1');
121
- $isAvailDL = $ntOpt['dlUName']!='' && $ntOpt['dlPass']!=''; $dlMsgFormat = htmlentities($ntOpt['dlMsgFormat'], ENT_COMPAT, "UTF-8"); $dlMsgTFormat = htmlentities($ntOpt['dlMsgTFormat'], ENT_COMPAT, "UTF-8");
122
- ?>
123
- <tr><th style="text-align:left;" colspan="2">
124
- <?php if ($ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='') { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
125
- <?php if (!empty($ntOpt['tagsSelX'])) { ?> <input type="hidden" class="nxs_TG" id="nxs_TG_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $ntOpt['tagsSelX']; ?>" /> <?php } ?>
126
- <?php if ($isAvailDL) { ?><input class="nxsGrpDoChb" value="1" id="doDL<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="dl[<?php echo $ii; ?>][doDL]" <?php if ((int)$doDL == 1) echo 'checked="checked" title="def"'; ?> />
127
- <?php if ($post->post_status == "publish") { ?> <input type="hidden" name="dl[<?php echo $ii; ?>][doDL]" value="<?php echo $doDL;?>"> <?php } ?> <?php } ?>
128
-
129
- <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/dl16.png);">Delicious - <?php _e('publish to', 'social-networks-auto-poster-facebook-twitter-g') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
130
- 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', 'social-networks-auto-poster-facebook-twitter-g') ?>" />
131
- <?php } ?>
132
-
133
- <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
134
- ?> <span id="pstdDL<?php echo $ii; ?>" style="float: right; padding-top: 4px; padding-right: 10px;">
135
- <a style="font-size: 10px;" href="http://delicious.com/<?php echo $ntOpt['dlUName']; ?>" target="_blank"><?php $nType="Delicious"; printf( __( 'Posted on', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
136
- </span><?php } ?>
137
-
138
- </td></tr>
139
-
140
- <?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>
141
- <?php } else { if ($post->post_status != "publish" && function_exists('nxs_doSMAS5') ) { $ntOpt['postTime'] = get_post_time('U', false, $post_id); nxs_doSMAS5($nt, $ii, $ntOpt); } ?>
142
-
143
- <?php if ($ntOpt['rpstOn']=='1') { ?>
144
-
145
- <tr id="altFormat1" style=""><th scope="row" class="nxsTHRow">
146
- <input value="0" type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]"/><input value="nxsi<?php echo $ii; ?>dl" type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]" <?php if (!empty($ntOpt['rpstPostIncl'])) echo "checked"; ?> />
147
- </th>
148
- <td> <?php _e('Include in "Auto-Reposting" to this network.', 'social-networks-auto-poster-facebook-twitter-g') ?>
149
- </td></tr> <?php } ?>
150
-
151
-
152
- <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Title Format:', 'social-networks-auto-poster-facebook-twitter-g') ?></th>
153
- <td><input class="nxs_postEditCtrl" value="<?php echo $dlMsgTFormat ?>" type="text" name="dl[<?php echo $ii; ?>][SNAPformatT]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apDLTMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apDLTMsgFrmt".$ii, '', '58'); ?></td></tr>
154
-
155
- <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Text Format:', 'social-networks-auto-poster-facebook-twitter-g') ?></th>
156
- <td>
157
- <textarea class="nxs_postEditCtrl" cols="150" rows="1" id="dl<?php echo $ii; ?>SNAPformat" name="dl[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('#dl<?php echo $ii; ?>SNAPformat').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apDLMsgFrmt<?php echo $ii; ?>');"><?php echo $dlMsgFormat; ?></textarea>
158
- <?php nxs_doShowHint("apDLMsgFrmt".$ii, '', '58'); ?></td></tr>
159
- <?php }
160
  }
161
- }
162
- //#### Save Meta Tags to the Post
163
- function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
164
- if (isset($pMeta['SNAPformat'])) $optMt['dlMsgFormat'] = $pMeta['SNAPformat'];
165
- if (isset($pMeta['SNAPformatT'])) $optMt['dlMsgTFormat'] = $pMeta['SNAPformatT'];
166
- if (isset($pMeta['imgToUse'])) $optMt['imgToUse'] = $pMeta['imgToUse'];
167
- if (isset($pMeta['timeToRun'])) $optMt['timeToRun'] = $pMeta['timeToRun']; if (isset($pMeta['rpstPostIncl'])) $optMt['rpstPostIncl'] = $pMeta['rpstPostIncl'];
168
- if (isset($pMeta['doDL'])) $optMt['doDL'] = $pMeta['doDL'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doDL'] = 0; }
169
- if (isset($pMeta['SNAPincludeDL']) && $pMeta['SNAPincludeDL'] == '1' ) $optMt['doDL'] = 1;
170
- return $optMt;
171
  }
172
- }}
173
- if (!function_exists("nxs_rePostToDL_ajax")) {
174
- function nxs_rePostToDL_ajax() { check_ajax_referer('nxsSsPageWPN'); $postID = $_POST['id']; $options = get_option('NS_SNAutoPoster');
175
- foreach ($options['dl'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj'; //if ($two['gpPageID'].$two['gpUName']==$_POST['nid']) {
176
- $gppo = get_post_meta($postID, 'snapDL', true); $gppo = maybe_unserialize($gppo);// prr($gppo);
177
- if (is_array($gppo) && isset($gppo[$ii]) && is_array($gppo[$ii])){ $ntClInst = new nxs_snapClassDL(); $two = $ntClInst->adjMetaOpt($two, $gppo[$ii]);}
178
- $result = nxs_doPublishToDL($postID, $two); if ($result == 200) die("Successfully sent your post to Delicious."); else die($result);
179
- }
180
  }
181
- }
182
-
183
-
184
- if (!function_exists("nxs_doPublishToDL")) { //## Second Function to Post to DL
185
- function nxs_doPublishToDL($postID, $options){ $ntCd = 'DL'; $ntCdL = 'dl'; $ntNm = 'Delicious'; global $plgn_NS_SNAutoPoster; if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
186
- // if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToDL', array($postID, $options));
187
- $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'POSTID'=>$postID, 'ACCNAME'=>$options['nName']));
188
- $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url();
189
- $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
190
- $logNT = '<span style="color:#000080">Delicious</span> - '.$options['nName'];
191
- $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
192
- if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
193
- $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') { sleep(5);
194
- nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'); return;
195
- }
196
- }
197
- if ($postID=='0') { echo "Testing ... <br/><br/>"; $urlToGo = home_url(); $msgT = 'Test Link from '.$urlToGo; } else { $post = get_post($postID); if(!$post) return;
198
- $options['dlMsgTFormat'] = nsFormatMessage($options['dlMsgTFormat'], $postID); $options['dlMsgFormat'] = nsFormatMessage($options['dlMsgFormat'], $postID);
199
- nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
200
- //## MyURL - URLToGo code
201
- $options = nxs_getURL($options, $postID, $addParams); $urlToGo = $options['urlToUse'];
202
- }
203
- $extInfo = ' | PostID: '.$postID." - ".(isset($post) && is_object($post)?$post->post_title:'');
204
- //## Create and Format message
205
- $t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = implode(',',$tggs); // $tags = str_replace(' ','+',$tags);
206
 
207
- $message = array('url'=>$urlToGo, 'surl'=>$urlToGo, 'siteName'=>$blogTitle, 'tags'=>$tags);
208
- //## Actual Post
209
- $ntToPost = new nxs_class_SNAP_DL(); $ret = $ntToPost->doPostToNT($options, $message);
210
- //## Process Results
211
- if (!is_array($ret) || $ret['isPosted']!='1') { //## Error
212
- if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);
213
- } else { // ## All Good - log it.
214
- if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo _e('OK - Message Posted, please see your '.$logNT.' Page. ', 'social-networks-auto-poster-facebook-twitter-g'); }
215
- else { nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPosted'=>'1', 'pgID'=>$ret['postID'], 'pDate'=>date('Y-m-d H:i:s'))); nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); }
216
- }
217
- //## Return Result
218
- if (!empty($ret['isPosted']) && $ret['isPosted']=='1') return 200; else return print_r($ret, true);
219
- }
220
- }
221
  ?>
1
  <?php
2
+ //## NextScripts Delicious Connection Class
3
+ $nxs_snapAvNts[] = array('code'=>'DL', 'lcode'=>'dl', 'name'=>'Delicious', 'type'=>'Link Sharing/Boormarks', 'ptype'=>'F', 'status'=>'A', 'desc'=>'Auto-submit bookmark to your account');
4
 
5
+ if (!class_exists("nxs_snapClassDL")) { class nxs_snapClassDL extends nxs_snapClassNT {
6
+ var $ntInfo = array('code'=>'DL', 'lcode'=>'dl', 'name'=>'Delicious', 'defNName'=>'uName', 'tstReq' => false, 'instrURL'=>'http://www.nextscripts.com/setup-installation-delicious-social-networks-auto-poster-wordpress/');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
+ function toLatestVer($ntOpts){ if( !empty($ntOpts['v'])) $v = $ntOpts['v']; else $v = 340; $ntOptsOut = ''; switch ($v) {
9
+ case 340: $ntOptsOut = $this->toLatestVerNTGen($ntOpts); $ntOptsOut['do'] = $ntOpts['do'.$this->ntInfo['code']]; $ntOptsOut['nName'] = $ntOpts['nName'];
10
+ $ntOptsOut['msgTFormat'] = $ntOpts['dlMsgTFormat']; $ntOptsOut['msgFormat'] = $ntOpts['dlMsgFormat']; $ntOptsOut['uName'] = $ntOpts['dlUName']; $ntOptsOut['uPass'] = $ntOpts['dlPass'];
11
+ break;
12
+ }
13
+ return !empty($ntOptsOut)?$ntOptsOut:$ntOpts;
14
+ }
15
 
16
+ //#### Show Common Settings
17
+ function showGenNTSettings($ntOpts){ $this->nt = $ntOpts; $this->showNTGroup(); return; }
18
+ //#### Show NEW Settings Page
19
+ function showNewNTSettings($ii){ $defO = array('nName'=>'', 'do'=>'1', 'uName'=>'', 'uPass'=>'', 'msgTFormat'=>'%TITLE%', 'msgFormat'=>"%EXCERPT%"); $this->showGNewNTSettings($ii, $defO); }
20
+ //#### Show Unit Settings
21
+ function checkIfSetupFinished($options) { return !empty($options['uPass']); }
22
+ function accTab($ii, $options, $isNew=false){ $ntInfo = $this->ntInfo; $nt = $ntInfo['lcode']; $this->elemUserPass($ii, $options['uName'], $options['uPass']); $this->elemTitleFormat($ii,'Message Title Format','msgTFormat',$options['msgTFormat']);
23
+ $this->elemMsgFormat($ii,'Message Text Format','msgFormat',$options['msgFormat']);?><br/ ><?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  }
25
+ function advTab($ii, $options){}
26
  //#### Set Unit Settings from POST
27
+ function setNTSettings($post, $options){
28
  foreach ($post as $ii => $pval){
29
+ if (!empty($pval['uPass']) && !empty($pval['uPass'])){ if (!isset($options[$ii])) $options[$ii] = array(); $options[$ii] = $this->saveCommonNTSettings($pval,$options[$ii]);
30
+ } elseif ( count($pval)==1 ) if (isset($pval['do'])) $options[$ii]['do'] = $pval['do']; else $options[$ii]['do'] = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  } return $options;
32
+ }
33
+
34
  //#### Show Post->Edit Meta Box Settings
35
+ function showEdPostNTSettings($ntOpts, $post){ $post_id = $post->ID; $nt = $this->ntInfo['lcode']; $ntU = $this->ntInfo['code'];
36
+ foreach($ntOpts as $ii=>$ntOpt) { $isFin = $this->checkIfSetupFinished($ntOpt); if (!$isFin) continue;
37
+ $pMeta = maybe_unserialize(get_post_meta($post_id, 'snap'.$ntU, true)); if (is_array($pMeta) && !empty($pMeta[$ii])) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
38
+
39
+ if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = ''; if (empty($ntOpt['urlToUse'])) $ntOpt['urlToUse'] = ''; $postType = isset($ntOpt['postType'])?$ntOpt['postType']:'';
40
+ $msgFormat = !empty($ntOpt['msgFormat'])?htmlentities($ntOpt['msgFormat'], ENT_COMPAT, "UTF-8"):''; $msgTFormat = !empty($ntOpt['msgTFormat'])?htmlentities($ntOpt['msgTFormat'], ENT_COMPAT, "UTF-8"):'';
41
+ $imgToUse = $ntOpt['imgToUse']; $urlToUse = $ntOpt['urlToUse']; $ntOpt['ii']=$ii;
42
+
43
+ $this->nxs_tmpltAddPostMeta($post, $ntOpt, $pMeta); ?>
44
+ <?php $this->elemEdTitleFormat($ii, __('Title Format:', 'social-networks-auto-poster-facebook-twitter-g'),$msgTFormat); $this->elemEdMsgFormat($ii, __('Message Format:', 'social-networks-auto-poster-facebook-twitter-g'),$msgFormat);
45
+ /* ## Select Image & URL ## */ nxs_showURLToUseDlg($nt, $ii, $urlToUse); $this->nxs_tmpltAddPostMetaEnd($ii);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  }
 
 
 
 
 
 
 
 
 
 
47
  }
48
+ //#### Save Meta Tags to the Post
49
+ function adjMetaOpt($optMt, $pMeta){ $optMt = $this->adjMetaOptG($optMt, $pMeta); // prr($optMt);
50
+ //if (!empty($pMeta['dlBoard'])) $optMt['dlBoard'] = $pMeta['dlBoard']; if (!empty($pMeta['dlBoard'])) $optMt['dlBoard'] = $pMeta['dlBoard']; else $optMt['dlBoard'] = 0;
51
+ return $optMt;
 
 
 
 
52
  }
53
+
54
+ function adjPublishWP(&$options, &$message, $postID){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
+ }
57
+
58
+ }}
59
+
60
+ if (!function_exists("nxs_doPublishToDL")) { function nxs_doPublishToDL($postID, $options){ if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
61
+ $cl = new nxs_snapClassDL(); $cl->nt[$options['ii']] = $options; return $cl->publishWP($options['ii'], $postID);
62
+ }}
 
 
 
 
 
 
 
63
  ?>
inc-cl/fb.api.php CHANGED
@@ -11,73 +11,71 @@ if (!class_exists("nxs_class_SNAP_FB")) { class nxs_class_SNAP_FB {
11
  foreach ($options as $ii=>$ntOpts) $out[$ii] = $this->doPostToNT($ntOpts, $message);
12
  return $out;
13
  }
14
- function doPostToNT($options, $message){ $badOut = array('Warning'=>'', 'Error'=>''); $wprg = array('sslverify'=>false, 'timeout' => 30);
15
  //## Check settings
16
  if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
17
- if (empty($options['fbAppAuthToken']) && empty($options['atpKey']) && empty($options['uName'])) { $badOut['Error'] = 'No Auth Token Found/Not configured'; return $badOut; }
18
  //## Make Post
 
19
 
20
-
21
- // $facebook = new NXS_Facebook(array( 'appId' => $options['fbAppID'], 'secret' => $options['fbAppSec'], 'cookie' => true ));
22
- if (!empty($options['fbAppAuthToken'])) if (!isset($options['fbAppPageAuthToken']) || trim($options['fbAppPageAuthToken'])=='') $options['fbAppPageAuthToken'] = $options['fbAppAuthToken'];
23
-
24
- //## Some OLD Format Conversion
25
- if (!isset($options['attachType']) && isset($options['fbAttch'])) $options['attachType'] = $options['fbAttch'];
26
- if (!isset($options['postType']) && isset($options['fbPostType'])) $options['postType'] = $options['fbPostType']; $fbPostType = $options['postType']; //## Compatibility with v <3.2
27
- if (!isset($options['pgID']) && isset($options['fbPgID'])) $options['pgID'] = $options['fbPgID'];
28
-
29
- if ($fbPostType!='I' && $fbPostType!='T') { $url = $message['url']; $flds = array('id'=>$url, 'scrape'=>'true'); sleep(2); }
30
- //## Get URL info.
31
- if ($fbPostType!='I' && $fbPostType!='T' && !empty($options['atchUse']) && $options['atchUse'] == 'F') {
32
- $response = wp_remote_post('http://graph.facebook.com', array('body' => $flds, 'sslverify'=>false, 'timeout' => 30 ));
33
- if (is_wp_error($response)) $badOut['Error'] = "Error(URL-Info): ". print_r($response, true); else { $response = json_decode($response['body'], true); // prr($response); die();
34
  if (!empty($response['description'])) $message['urlDescr'] = $response['description']; if (!empty($response['title'])) $message['urlTitle'] = $response['title'];
35
  if (!empty($response['site_name'])) $message['siteName'] = $response['site_name']; elseif ($message['siteName']=='') $message['siteName'] = $message['title'];
36
  if (!empty($response['image'][0]['url'])) $message['imageURL'] = $response['image'][0]['url'];
 
37
  }
38
- } // prr($message);
39
- if (!empty($message['pText'])) $msg = $message['pText']; else $msg = nxs_doFormatMsg($options['fbMsgFormat'], $message);
40
- $imgURL = nxs_getImgfrOpt($message['imageURL']); $fbWhere = 'feed';
41
- $attachType = $options['attachType']; if ($attachType=='1') $attachType = 'A'; else $attachType = 'S';
42
  if ($options['imgUpl']!='2') $options['imgUpl'] = 'T'; else $options['imgUpl'] = 'A';
43
- if (stripos($options['fbURL'], '/groups/')!=false) $options['destType'] == 'gr';
44
 
45
- if (!empty($options['destType']) && $options['destType'] == 'pr') $page_id = $options['fbAppAuthUser']; else $page_id = $options['pgID'];
46
  $msg = strip_tags($msg); $msg = str_ireplace('&lt;(")','<(")', $msg); //## FB Smiles FIX 3
47
  if (substr($msg, 0, 1)=='@') $msg = ' '.$msg; // ERROR] couldn't open file fix
48
 
49
  //## Own App Post
50
- if (!empty($options['fbAppPageAuthToken'])) {
51
- if (empty($options['appsecret_proof'])) $options['appsecret_proof'] = hash_hmac('sha256', $options['fbAppPageAuthToken'], $options['fbAppSec']);
52
- $mssg = array('access_token'=>$options['fbAppPageAuthToken'], 'appsecret_proof'=>$options['appsecret_proof'], 'method'=>'post', 'message'=>$msg);
53
- if ($fbPostType=='I' && trim($imgURL)=='') $fbPostType='T';
54
- if ($fbPostType=='A' && !(preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $message['url']))) {
55
- $badOut['Warning'] = 'Unvalid URL: '.$message['url'].'| Will be posting as text message'; $fbPostType='T';
56
  }
57
- if ($fbPostType=='A' || $fbPostType=='') {
58
- if (($attachType=='A' || $attachType=='S')) { $message['urlTitle'] = nsTrnc($message['urlTitle'], 250, " ", "...");
59
- $attArr = array('name' => $message['urlTitle'], 'caption' => $message['siteName'], 'link' =>$message['url'], 'description' => $message['urlDescr']); $mssg = array_merge($mssg, $attArr); ;
60
- }
61
- if ($attachType=='A') $mssg['actions'] = json_encode(array('name' => $message['siteName'], 'link' =>$message['url']));
62
  if (trim($imgURL)!='') $mssg['picture'] = $imgURL; //if (trim($message['videoURL'])!='') $mssg['source'] = $message['videoURL'];
63
- } elseif ($fbPostType=='I') { /* $facebook->setFileUploadSupport(true); */ $fbWhere = 'photos'; $mssg['url'] = $imgURL;
 
64
  if ($options['imgUpl']=='T') { //## Try to Post to TImeline
65
- $aacct = array('access_token'=>$options['fbAppPageAuthToken'], 'appsecret_proof'=>$options['appsecret_proof'], 'method'=>'get');
66
- $res = wp_remote_get( "https://graph.facebook.com/$page_id/albums?".http_build_query($aacct, null, '&'),$wprg);
67
- if (is_wp_error($res) || empty($res['body'])) $badOut['Error'] = ' [ERROR(Albums)] '.print_r($res, true); else {
68
- $albums = json_decode($res['body'], true); if (empty($albums)) $badOut['Error'] .= "JSON ERROR (Albums): ".print_r($res, true); else {
69
- if (is_array($albums) && is_array($albums["data"])) foreach ($albums["data"] as $album) { if ($album["type"] == "wall") { $chosen_album = $album; break;}}
 
70
  if (isset($chosen_album) && isset($chosen_album["id"])) $page_id = $chosen_album["id"];
71
  }
72
  }
73
  }
74
- }
75
  //## Actual Post
76
- $destURL = "https://graph.facebook.com/$page_id/".$fbWhere; // prr($destURL); prr($args); prr($mssg); //die();
77
- $response = wp_remote_post( $destURL, array( 'method' => 'POST', 'httpversion' => '1.1', 'timeout' => 30, 'sslverify'=>false, 'redirection' => 0, 'body' => $mssg));
78
  }
79
 
80
- if (is_wp_error($response) || empty($response['body'])) return "ERROR: ".print_r($response, true);
81
  $res = json_decode($response['body'], true); if (empty($res)) return "JSON ERROR: ".print_r($response, true);
82
  if (!empty($res['error'])) if (!empty($res['error']['message'])) { $badOut['Error'] .= $res['error']['message']; //## Some Known Errors
83
  if (stripos($res['error']['message'], 'This API call requires a valid app_id')!==false) {
@@ -85,8 +83,9 @@ if (!class_exists("nxs_class_SNAP_FB")) { class nxs_class_SNAP_FB {
85
  else $badOut['Error'] .= " [ERROR] (invalid app_id) Authorization Error. <br/>\r\n<br/>\r\n Possible Reasons: <br/>\r\n 1. Your app is not authorized. Please go to the Plugin Settings - Facebook and authorize it.<br/>\r\n 2. The current authorized user have no rights to post to the specified page. Please login to Facebook as the correct user and Re-Authorize the Plugin.<br/>\r\n 3. You clicked 'Skip' or unchecked the 'Manage Pages' or 'Post on your behalf' permissions when Authorization wizard asked you. Please Re-Authorize the Plugin<br/>\r\n";
86
  }
87
  if (stripos($res['error']['message'], 'Some of the aliases you requested do not exist')!==false) $badOut['Error'] .= '| Please check what do you have in the "Facebook URL" field.';
88
- if (stripos($res['error']['message'], 'Unsupported post request')!==false) $badOut['Error'] .= "<br/>\r\n".'| Are you posting to a secret group? Please see: <a href="http://gd.is/fbe2">http://gd.is/fbe2</a>';
89
- if (stripos($res['error']['message'], 'The target user has not authorized this action')!==false) $badOut['Error'] .= '| Please Authorize the plugin from the plugin settings Page - Facebook.';
 
90
 
91
  return $badOut;
92
  } else return print_r($res['error'], true);
11
  foreach ($options as $ii=>$ntOpts) $out[$ii] = $this->doPostToNT($ntOpts, $message);
12
  return $out;
13
  }
14
+ function doPostToNT($options, $message){ $badOut = array('Warning'=>'', 'Error'=>''); $wprg = array('sslverify'=>false, 'timeout' => 30); //prr($options);
15
  //## Check settings
16
  if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
17
+ if (empty($options['accessToken']) && empty($options['pageAccessToken']) && empty($options['tpt'])) { $badOut['Error'] = 'No Auth Token Found/Not configured'; return $badOut; }
18
  //## Make Post
19
+ if (!empty($options['accessToken'])) if (!isset($options['pageAccessToken']) || trim($options['pageAccessToken'])=='') $options['pageAccessToken'] = $options['accessToken'];
20
 
21
+ //## Get URL info.
22
+ if ($options['postType']!='I' && $options['postType']!='T'){ $url=$message['url']; //#### Let's ask FB to scrape/re-scrape it.
23
+ $flds=array('id'=>$url, 'scrape'=>'true', 'access_token'=>$options['accessToken'], 'method'=>'post', 'limit'=>250); if (empty($options['tpt'])) $flds['appsecret_proof'] = hash_hmac('sha256', $options['accessToken'], $options['appSec']); sleep(2);
24
+ $advSet = nxs_mkRemOptsArr(nxs_getNXSHeaders(), '',$flds); $response = nxs_remote_post('https://graph.facebook.com', $advSet);
25
+
26
+ if (is_nxs_error($response)) $badOut['Error'] = "Error(URL-Info): ". print_r($response, true); else { $response = json_decode($response['body'], true); // prr($response); die();
27
+ global $plgn_NS_SNAutoPoster; if (!empty($plgn_NS_SNAutoPoster)) {
28
+ $gOptions = $plgn_NS_SNAutoPoster->nxs_options; {if (isset($gOptions['extDebug']) && $gOptions['extDebug']=='1') nxs_LogIt( 'S', 'Facebook URL Debug', 'FB', '', 'Facebook OG Metatags URL Scrape Info: ', print_r($response, true));}
29
+ }
 
 
 
 
 
30
  if (!empty($response['description'])) $message['urlDescr'] = $response['description']; if (!empty($response['title'])) $message['urlTitle'] = $response['title'];
31
  if (!empty($response['site_name'])) $message['siteName'] = $response['site_name']; elseif ($message['siteName']=='') $message['siteName'] = $message['title'];
32
  if (!empty($response['image'][0]['url'])) $message['imageURL'] = $response['image'][0]['url'];
33
+ $message['urlCaption'] = '';
34
  }
35
+ }
36
+ //prr($message); die();
37
+ if (!empty($message['pText'])) $msg = $message['pText']; else $msg = nxs_doFormatMsg($options['msgFormat'], $message);
38
+ $imgURL = nxs_getImgfrOpt($message['imageURL']); $fbWhere = 'feed';
39
  if ($options['imgUpl']!='2') $options['imgUpl'] = 'T'; else $options['imgUpl'] = 'A';
40
+ if (!empty($options['fbURL']) && stripos($options['fbURL'], '/groups/')!=false) $options['destType'] = 'gr';
41
 
42
+ if (!empty($options['destType']) && $options['destType'] == 'pr') $page_id = $options['authUser']; else $page_id = $options['pgID'];
43
  $msg = strip_tags($msg); $msg = str_ireplace('&lt;(")','<(")', $msg); //## FB Smiles FIX 3
44
  if (substr($msg, 0, 1)=='@') $msg = ' '.$msg; // ERROR] couldn't open file fix
45
 
46
  //## Own App Post
47
+ if (!empty($options['pageAccessToken'])) { $mssg = array('access_token'=>$options['pageAccessToken'], 'method'=>'post', 'message'=>$msg);
48
+ if (empty($options['tpt'])) $mssg['appsecret_proof'] = hash_hmac('sha256', $options['pageAccessToken'], $options['appSec']); //prr($mssg);
49
+
50
+ if ($options['postType']=='I' && trim($imgURL)=='') $options['postType']='T';
51
+ if ($options['postType']=='A' && !(preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $message['url']))) {
52
+ $badOut['Warning'] = 'Unvalid URL: '.$message['url'].'| Will be posting as text message'; $options['postType']='T';
53
  }
54
+ if ($options['postType']=='A' || $options['postType']=='') {
55
+ $message['urlTitle'] = nsTrnc($message['urlTitle'], 250, " ", "...");
56
+ $attArr = array('name' => nsTrnc($message['urlTitle'], 250, " ", "..."), 'caption' => $message['urlCaption'], 'link' =>$message['url'], 'description' => $message['urlDescr']); $mssg = array_merge($mssg, $attArr); ;
57
+ //if ($options['attachType']=='A') $mssg['actions'] = json_encode(array('name' => nsTrnc($message['siteName'], 250, " ", "..."), 'link' =>$message['url']));
 
58
  if (trim($imgURL)!='') $mssg['picture'] = $imgURL; //if (trim($message['videoURL'])!='') $mssg['source'] = $message['videoURL'];
59
+ }
60
+ elseif ($options['postType']=='I') { /* $facebook->setFileUploadSupport(true); */ $fbWhere = 'photos'; $mssg['url'] = $imgURL; $mssg['caption'] = $mssg['message'];
61
  if ($options['imgUpl']=='T') { //## Try to Post to TImeline
62
+
63
+ $aacct = array('access_token'=>$options['pageAccessToken'], 'method'=>'get'); if (empty($options['tpt'])) $aacct['appsecret_proof'] = hash_hmac('sha256', $options['pageAccessToken'], $options['appSec']);
64
+ $res = nxs_remote_get( "https://graph.facebook.com/$page_id/albums?".http_build_query($aacct, null, '&'), nxs_mkRemOptsArr(nxs_getNXSHeaders()));
65
+ if (is_nxs_error($res) || empty($res['body'])) $badOut['Error'] = ' [ERROR(Albums)] '.print_r($res, true); else {
66
+ $albums = json_decode($res['body'], true); if (empty($albums)) $badOut['Error'] .= "JSON ERROR (Albums): ".print_r($res, true); else {
67
+ if (is_array($albums) && is_array($albums["data"])) foreach ($albums["data"] as $album) { if (!empty($album["type"]) && $album["type"] == "wall") { $chosen_album = $album; break;}}
68
  if (isset($chosen_album) && isset($chosen_album["id"])) $page_id = $chosen_album["id"];
69
  }
70
  }
71
  }
72
+ } if (!empty($mssg['name']) && function_exists('mb_strcut')) { mb_internal_encoding('UTF-8'); $mssg['name'] = mb_strcut($mssg['name'], 0, 250); }
73
  //## Actual Post
74
+ $destURL = "https://graph.facebook.com/$page_id/".$fbWhere; // prr($destURL); prr($mssg); die();
75
+ $response = nxs_remote_post( $destURL, nxs_mkRemOptsArr(nxs_getNXSHeaders('',true),'',$mssg) ); // prr($response);
76
  }
77
 
78
+ if (is_nxs_error($response) || empty($response['body'])) return "ERROR: ".print_r($response, true);
79
  $res = json_decode($response['body'], true); if (empty($res)) return "JSON ERROR: ".print_r($response, true);
80
  if (!empty($res['error'])) if (!empty($res['error']['message'])) { $badOut['Error'] .= $res['error']['message']; //## Some Known Errors
81
  if (stripos($res['error']['message'], 'This API call requires a valid app_id')!==false) {
83
  else $badOut['Error'] .= " [ERROR] (invalid app_id) Authorization Error. <br/>\r\n<br/>\r\n Possible Reasons: <br/>\r\n 1. Your app is not authorized. Please go to the Plugin Settings - Facebook and authorize it.<br/>\r\n 2. The current authorized user have no rights to post to the specified page. Please login to Facebook as the correct user and Re-Authorize the Plugin.<br/>\r\n 3. You clicked 'Skip' or unchecked the 'Manage Pages' or 'Post on your behalf' permissions when Authorization wizard asked you. Please Re-Authorize the Plugin<br/>\r\n";
84
  }
85
  if (stripos($res['error']['message'], 'Some of the aliases you requested do not exist')!==false) $badOut['Error'] .= '| Please check what do you have in the "Facebook URL" field.';
86
+ if (stripos($res['error']['message'], 'Unsupported post request')!==false) $badOut['Error'] .= "<br/>\r\n".'| Are you posting to a secret or closed group? Please see: <a target="_blank" href="http://gd.is/fbe2">http://gd.is/fbe2</a>';
87
+ if (stripos($res['error']['message'], 'The target user has not authorized this action')!==false) $badOut['Error'] .= '| Please Authorize the plugin from the plugin settings Page - Facebook.';
88
+ if (stripos($res['error']['message'], 'The user has not authorized the application')!==false && $options['destType'] == 'gr') $badOut['Error'] .= '| Are you posting to a secret or closed group? Please see: <a target="_blank" href="http://gd.is/fbe2">http://gd.is/fbe2</a>';
89
 
90
  return $badOut;
91
  } else return print_r($res['error'], true);
inc-cl/fb.php CHANGED
@@ -1,115 +1,185 @@
1
  <?php
2
  //## NextScripts Facebook Connection Class
3
- $nxs_snapAvNts[] = array('code'=>'FB', 'lcode'=>'fb', 'name'=>'Facebook');
4
 
5
- if (!class_exists("nxs_snapClassFB")) { class nxs_snapClassFB {
6
- //#### Show Common Settings
7
- function showGenNTSettings($ntOpts){ global $nxs_snapSetPgURL, $nxs_plurl, $nxs_gOptions; $ntInfo = array('code'=>'FB', 'lcode'=>'fb', 'name'=>'Facebook', 'defNName'=>'dlUName', 'tstReq' => true);
8
- if ( isset($_GET['code']) && $_GET['code']!='' && isset($_GET['state']) && substr($_GET['state'], 0, 7) == 'nxs-fb-'){ $at = $_GET['code']; $ii = str_replace('nxs-fb-','',$_GET['state']);
9
- echo '-= This is normal technical authorization info that will dissapear. (Unless you get some errors. If you do get errors please check them at the <a target="_blank" href="http://www.nextscripts.com/support-faq/">FAQ Page</a>) =- <br/><br/><br/>'; $gGet = array();
10
- if (!empty($_SERVER['QUERY_STRING'])) parse_str($_SERVER['QUERY_STRING'], $gGet); elseif (!empty($_SERVER['argv'][0])) parse_str($_SERVER['argv'][0], $gGet);
11
- else { $gGet = $_GET; prr($_GET); unset($gGet['post_type']);} prr($gGet); unset($gGet['code']); unset($gGet['state']); prr($gGet);
12
- $sturl = explode('?',$nxs_snapSetPgURL); $nxs_snapSetPgURL = $sturl[0].((!empty($gGet))?'?'.http_build_query($gGet):''); $fbo = $ntOpts[$ii]; $wprg = array('sslverify'=>false, 'timeout' => 30);
13
- if (isset($fbo['fbPgID'])){ echo "-="; prr($fbo);// die();
14
- $tknURL = 'https://graph.facebook.com/v2.3/oauth/access_token?client_id='.$fbo['fbAppID'].'&state=nxs-fb-'.$ii.'&redirect_uri='.urlencode($nxs_snapSetPgURL).'&client_secret='.$fbo['fbAppSec'].'&code='.$at;
15
- $response = wp_remote_get($tknURL, $wprg); echo "<br/>TKN URL: "; prr($tknURL);
16
- if ( (is_object($response) && (isset($response->errors))) || (is_array($response) && stripos($response['body'],'"error":')!==false )) { prr($response); die(); }
17
- if (substr($response['body'],0,1)=='{') $params = json_decode($response['body'], true); else parse_str($response['body'], $params);
18
- $at = $params['access_token']; echo "<br/>TKN PARAMS: "; prr($params); echo "<br/>TKN RESP: "; prr($response);
19
- $response = wp_remote_get('https://graph.facebook.com/v2.3/oauth/access_token?client_secret='.$fbo['fbAppSec'].'&client_id='.$fbo['fbAppID'].'&grant_type=fb_exchange_token&fb_exchange_token='.$at, $wprg);
20
- if ((is_object($response) && isset($response->errors))) { prr($response); die();}
21
- if (substr($response['body'],0,1)=='{') $params = json_decode($response['body'], true); else parse_str($response['body'], $params); $at = $params['access_token']; $fbo['fbAppAuthToken'] = $at;
22
- $appsecret_proof = hash_hmac('sha256', $fbo['fbAppAuthToken'], $fbo['fbAppSec']);
23
- $aacct = array('access_token'=>$fbo['fbAppAuthToken'], 'appsecret_proof'=>$appsecret_proof, 'method'=>'get');
24
- $uurl = "https://graph.facebook.com/v2.3/me?".http_build_query($aacct, null, '&'); prr($uurl); $res = wp_remote_get( $uurl, $wprg);
25
- if (is_wp_error($res) || empty($res['body'])) { echo "Can't get Facebook User."; prr($res); die();} else {
26
- $user = json_decode($res['body'], true); if (empty($user)) {echo "Can't get Facebook User. JSON Error. "; prr($res); die();} else {
27
- if (!empty($user['id'])) { echo "-= Got user: "; prr($user);
28
- if (stripos($fbo['fbURL'], '/groups/')!==false) { $fbo['destType'] = 'gr'; $fbo['fbAppPageAuthToken'] = $fbo['fbAppAuthToken']; } else {
29
- $page_id = $fbo['fbPgID']; echo "-= Authorizing Page =-<br/>";
30
- $aacct = array('access_token'=>$fbo['fbAppAuthToken'], 'appsecret_proof'=>$appsecret_proof, 'method'=>'get'); $fbo['destType'] = '';
31
- echo "-= Getting List of Pages =-<br/>";
32
- $resP = wp_remote_get('https://graph.facebook.com/v2.3/'.$user['id'].'/accounts?'.http_build_query($aacct, null, '&'), $wprg); prr($resP); $pages = json_decode($resP['body'], true); prr($pages);
33
- echo "-= Getting Page Token =-<br/>";
34
- echo "https://graph.facebook.com/v2.3/$page_id?fields=access_token&".http_build_query($aacct, null, '&');
35
- $res = wp_remote_get( "https://graph.facebook.com/v2.3/$page_id?fields=access_token&".http_build_query($aacct, null, '&'), $wprg); prr($res);
36
- if (is_wp_error($res) || empty($res['body'])) { echo "Can't get Page Token."; prr($res); die();} else {
37
- $token = json_decode($res['body'], true); if (empty($token)) {echo "Can't get Page Token. JSON Error. "; prr($res); die();} else {
38
- if (!empty($token['error'])) if (!empty($token['error']['message'])) { $errMsg = $token['error']['message'];
39
- if ( stripos($errMsg, 'Unknown fields: access_token')!==false || stripos($errMsg, 'Cannot query users by their username')!==false || stripos($errMsg, 'node type (User)')!==false) {
40
- $token['access_token'] = $fbo['fbAppAuthToken']; $fbo['destType'] = (stripos($fbo['fbURL'], '/groups/')!=false)?'gr':'pr'; } else {
41
- if (stripos($errMsg, 'Unsupported get request')!==false) echo "<b style='color:red;'>Error </b>: Your Facebook URL ( <i>".$fbo['fbURL']."</i> ) is either incorrect or authorzing user don't have rights to post there.<br/>";
42
- echo '<br/>Reported Error: ', $errMsg, "\n"; die();
43
- }
44
- }
45
- if (!empty($token['access_token'])) { $fbo['fbAppPageAuthToken'] = $token['access_token']; } else { echo "Can't get Page Token. NO TOKEN RETURNED. Are you sure that user you are trying to authorize is an admin of the page? This message means user was authorized as profile, but page refused to return authorization token. This usually happens when user has <b>no rights</b> to post to that page. "; prr($res); die(); }
46
- }
47
- }
48
- }
49
- } else {echo "Can't get User. NO USER RETURNED. "; prr($res); die();}
50
- }
51
- }
52
-
53
- if (!empty($user['id'])) { $fbo['fbAppAuthUser'] = $user['id']; $fbo['fbAppAuthUserName'] = $user['name'].(!empty($user['username'])?" (".$user['username'].")":'');
54
- if (function_exists('get_option')) $nxs_gOptions = get_option('NS_SNAutoPoster'); if(!empty($nxs_gOptions)) { $nxs_gOptions['fb'][$ii] = $fbo; nxs_settings_save($nxs_gOptions); }
55
- ?><script type="text/javascript">window.location = "<?php echo $nxs_snapSetPgURL; ?>"</script>
56
- <?php } die(); }
57
- }
58
- $ntParams = array('ntInfo'=>$ntInfo, 'nxs_plurl'=>$nxs_plurl, 'ntOpts'=>$ntOpts, 'chkField'=>'fbAppAuthUser'); nxs_showListRow($ntParams);
59
  }
 
 
 
60
  //#### Show NEW Settings Page
61
- function showNewNTSettings($mfbo){ $fbo = array('nName'=>'', 'doFB'=>'1', 'fbURL'=>'', 'atpKey'=>'','uName'=>'','uPass'=>'', 'fbAppID'=>'', 'imgUpl'=>'1', 'postType'=>'A', 'fbMsgAFormat'=>'', 'fbAppSec'=>'', 'fbAttch'=>'2', 'fbPgID'=>'', 'fbAppAuthUser'=>'', 'fbMsgFormat'=>__('New post (%TITLE%) has been published on %SITENAME%', 'social-networks-auto-poster-facebook-twitter-g') ); $fbo['ntInfo']= array('lcode'=>'fb'); $this->showNTSettings($mfbo, $fbo, true);}
62
- //#### Show Unit Settings
63
- function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl, $nxs_snapSetPgURL, $plgn_NS_SNAutoPoster; $nt = $options['ntInfo']['lcode']; $ntU = strtoupper($nt); $tmzFrmt = _x('Y-m-d G:i:s', 'timezone date format');
64
- if (empty($options['postType']) && !empty($options['fbPostType'])) { $options['postType'] = $options['fbPostType']; unset($options['fbPostType']); } //## Compatibility with V <3.2
65
- if (empty($options['postType']) && !empty($options['PostType'])) { $pt = $options['PostType']; unset($options['PostType']); $options['postType'] = $pt; } //## Compatibility with V <3.2
66
- if ((int)$options['fbAttch']==0 && empty($options['postType'])) $options['postType'] = 'T';
67
- if (!isset($plgn_NS_SNAutoPoster)) $gOptions = array(); else $gOptions = $plgn_NS_SNAutoPoster->nxs_options;
68
- 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'] = '';
69
- if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; if (!isset($options['msgDAFrmt'])) $options['msgDAFrmt'] = '';
70
- if (!isset($options['msgTAFrmt'])) $options['msgTAFrmt'] = ''; if (!isset($options['riComments'])) $options['riComments'] = ''; if (!isset($options['riCommentsAA'])) $options['riCommentsAA'] = '';
71
-
72
- ?>
73
- <div id="doFB<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>"> <input type="hidden" name="apDoSFB<?php echo $ii; ?>" value="0" id="apDoSFB<?php echo $ii; ?>" />
74
- <?php if ($isNew) { ?> <input type="hidden" name="fb[<?php echo $ii; ?>][apDoFB]" value="1" id="apDoNewFB<?php echo $ii; ?>" /> <?php } ?>
75
-
76
- <div class="nsx_iconedTitle" style="float: right; max-width: 342px; text-align: right; background-image: url(<?php echo $nxs_plurl; ?>img/fb16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/instructions/facebook-social-networks-auto-poster-setup-installation"><?php $nType="Facebook"; printf( __( 'Detailed %s Installation/Configuration Instructions', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?></a><br/>
77
- <span style="font-size: 10px;"><?php _e('Please use in your Facebook App:', 'social-networks-auto-poster-facebook-twitter-g'); ?> <br/> URL: <em style="font-size: 10px; color:#CB4B16;"><?php echo !empty($_SERVER["REQUEST_SCHEME"])?$_SERVER["REQUEST_SCHEME"]:'http'; ?>://<?php echo $_SERVER["SERVER_NAME"] ?></em> <br/>Domain: <em style="font-size: 10px; color:#CB4B16;"><?php echo $_SERVER["SERVER_NAME"] ?></em> </span>
78
-
79
- </div>
80
-
81
- <div style="width:100%;"><strong><?php _e('Account Nickname', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'social-networks-auto-poster-facebook-twitter-g'); ?></i> </div><input name="fb[<?php echo $ii; ?>][nName]" id="fbnName<?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")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /><br/>
82
- <?php echo nxs_addQTranslSel('fb', $ii, $options['qTLng']); ?>
83
-
84
-
85
- <ul class="nsx_tabs">
86
- <li><a href="#nsx<?php echo $nt.$ii ?>_tab1"><?php _e('Account Info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li>
87
- <?php if (!$isNew) { ?> <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li> <?php } ?>
88
-
89
- </ul>
90
- <div class="nsx_tab_container"><?php /* ######################## Account Tab ####################### */ ?>
91
- <div id="nsx<?php echo $nt.$ii ?>_tab1" class="nsx_tab_content" style="background-image: url(<?php echo $nxs_plurl; ?>img/<?php echo $nt; ?>-bg.png); background-repeat: no-repeat; background-position:90% 10%;">
92
-
93
- <div style="width:100%;"><strong>Facebook URL:</strong> </div>
94
- <p style="font-size: 11px; margin: 0px;"><?php _e('Could be your Facebook Profile, Facebook Page, Facebook Group', 'social-networks-auto-poster-facebook-twitter-g'); ?></p>
95
- <input name="fb[<?php echo $ii; ?>][apFBURL]" id="apFBURL" style="width: 50%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['fbURL'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />
96
- <br/><br/> <?php /*
97
- <?php if ($isNew) { ?><b>Choose How to connect to Facebook:</b>&nbsp;&lt;-&nbsp;<a target="_blank" href="http://www.nextscripts.com/connect-facebook/">What is it?</a> <br/>
98
-
99
- <select onchange="nxs_showHideBlock('fbChooseSRVB'+this.value, 'fbChooseSRVC');" id="fbChooseSRV<?php echo $ii; ?>"><option value="0">Your own app</option><option value="1">Autopost.to Service</option><option value="2">Username/password (Pro Only)</option></select> <br/> <br/>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
 
101
- <?php } */ ?>
102
- <div id="fbChooseSRVB0" class="fbChooseSRVC" style="padding-left:15px; display: <?php if ($isNew || !empty($options['fbAppID'])) echo 'block'; else echo 'none'; ?>;">
103
- <div style="width:100%;"><strong>Facebook App ID:</strong> </div><input name="fb[<?php echo $ii; ?>][apFBAppID]" id="apFBAppID" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['fbAppID'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />
104
- <div style="width:100%;"><strong>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($options['fbAppSec'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />
105
- </div>
106
- <br/><br/>
107
- <div id="altFormat">
108
- <div style="width:100%;"><strong id="altFormatText"><?php _e('Message text Format', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> (<a href="#" id="apFBMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apFBMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>)</div>
109
-
110
- <textarea cols="150" rows="3" id="fb<?php echo $ii; ?>SNAPformat" name="fb[<?php echo $ii; ?>][apFBMsgFrmt]" style="width:51%;max-width: 610px;" onfocus="jQuery('#fb<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('apFBMsgFrmt<?php echo $ii; ?>');"><?php _e(apply_filters('format_to_edit', htmlentities($options['fbMsgFormat'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?></textarea> <?php nxs_doShowHint("apFBMsgFrmt".$ii); ?>
111
- <br/>
112
- </div><br/>
113
  <div style="width:100%;"><strong style="font-size: 16px;" 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/"><?php _e('What\'s the difference?', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>) </div>
114
  <div style="margin-left: 10px;">
115
 
@@ -117,310 +187,223 @@ if (!class_exists("nxs_snapClassFB")) { class nxs_snapClassFB {
117
 
118
  <input type="radio" name="fb[<?php echo $ii; ?>][postType]" value="I" <?php if ($options['postType'] == 'I') echo 'checked="checked"'; ?> onchange="if (jQuery(this).is(':checked')) { jQuery('.nxsDivFBPostTypeOpts<?php echo $ii; ?>').hide(); jQuery('#nxsDivFBImgUplOpts<?php echo $ii; ?>').show();}"/> <?php _e('Image Post', 'social-networks-auto-poster-facebook-twitter-g'); ?> - <i><?php _e('big image with text message', 'social-networks-auto-poster-facebook-twitter-g'); ?></i><br/>
119
  <div style="width:100%; margin-left: 15px;<?php if (empty($options['postType']) || $options['postType'] != 'I') echo "display:none;"; ?>" id="nxsDivFBImgUplOpts<?php echo $ii; ?>" class="nxsDivFBPostTypeOpts<?php echo $ii; ?>" ><strong><?php _e('Upload Images to', 'social-networks-auto-poster-facebook-twitter-g'); ?>:&nbsp;</strong>
120
- <input value="2" id="apFBImgUplAPP<?php echo $ii; ?>" type="radio" name="fb[<?php echo $ii; ?>][apFBImgUpl]" <?php if ((int)$options['imgUpl'] == 2) echo "checked"; ?> /> <?php _e('App Album', 'social-networks-auto-poster-facebook-twitter-g'); ?>
121
- <input value="1" id="apFBImgUplTML<?php echo $ii; ?>" type="radio" name="fb[<?php echo $ii; ?>][apFBImgUpl]" <?php if ((int)$options['imgUpl'] != 2) echo "checked"; ?> />
122
  <?php _e('Timeline', 'social-networks-auto-poster-facebook-twitter-g'); ?> &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/"><?php _e('What\'s the difference?', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>)
123
  </div>
124
 
125
  <input type="radio" name="fb[<?php echo $ii; ?>][postType]" value="A" <?php if ( !isset($options['postType']) || $options['postType'] == '' || $options['postType'] == 'A') echo 'checked="checked"'; ?> onchange="if (jQuery(this).is(':checked')) { jQuery('.nxsDivFBPostTypeOpts<?php echo $ii; ?>').hide(); jQuery('#nxsDivFBAttchLinkOpts<?php echo $ii; ?>').show();}" /> <?php _e('Text Post with "attached" link', 'social-networks-auto-poster-facebook-twitter-g'); ?><br/>
126
 
127
  <div id="nxsDivFBAttchLinkOpts<?php echo $ii; ?>" class="nxsDivFBPostTypeOpts<?php echo $ii; ?>" style="width:100%; margin-left: 15px; line-height: 22px;<?php if (!empty($options['postType']) && $options['postType'] != 'A') echo "display:none;"; ?>">
128
- <?php //prr($options);
129
- if (empty($options['atchUse'])) $options['atchUse'] = 'F';
130
- if (!empty($options['useFBGURLInfo']) && $options['useFBGURLInfo']=='1') $options['atchUse'] = 'F';
131
- if (isset($options['useFBGURLInfo']) && $options['useFBGURLInfo']=='0') $options['atchUse'] = 'A';
132
- if (!empty($options['fbMsgAFrmt']) && empty($options['msgDAFrmt'])) { $options['msgDAFrmt'] = $options['fbMsgAFrmt']; $options['msgTAFrmt'] = '%TITLE%'; }
133
- if (!empty($options['fbMsgAFrmt'])) $options['atchUse'] = 'M';
134
- if (isset($options['fbAttchAsVid']) && $options['fbAttchAsVid'] == '1') $options['fbAttchAsVid'] = 'A';
135
- if (empty($options['fbAttchAsVid'])) $options['fbAttchAsVid'] = 'N';
136
-
137
- ?>
138
- <strong><?php _e('Link attachment type', 'social-networks-auto-poster-facebook-twitter-g'); ?>:&nbsp;</strong> <input value="2" id="apFBAttchShare<?php echo $ii; ?>" type="radio" name="fb[<?php echo $ii; ?>][apFBAttch]" <?php if ((int)$options['fbAttch'] == 2) echo "checked"; ?> /><?php _e('Share a link to your blogpost', 'social-networks-auto-poster-facebook-twitter-g'); ?>&nbsp;&nbsp;&nbsp;
139
- <input value="1" id="apFBAttch<?php echo $ii; ?>" type="radio" name="fb[<?php echo $ii; ?>][apFBAttch]" <?php if ((int)$options['fbAttch'] == 1) echo "checked"; ?> />
140
- <?php _e('Attach your blogpost', 'social-networks-auto-poster-facebook-twitter-g'); ?>&nbsp;&nbsp;
141
- &lt;-- (<a id="showShAtt" onmouseout="hidePopShAtt('<?php echo $ii; ?>');" onmouseover="showPopShAtt('<?php echo $ii; ?>', event);" onclick="return false;" class="underdash" href="http://www.nextscripts.com/blog/"><?php _e('What\'s the difference?', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>)
142
- <br/>
143
- <strong><?php _e('What should fill attachment info:', 'social-networks-auto-poster-facebook-twitter-g'); ?>&nbsp;</strong>
144
- <input value="F" type="radio" name="fb[<?php echo $ii; ?>][atchUse]" <?php if ($options['atchUse'] == 'F') echo "checked"; ?> onchange="if (jQuery(this).is(':checked')) { jQuery('#apFBMsgAFrmtDiv<?php echo $ii; ?>').hide(); jQuery('#nxsRBVidThumb<?php echo $ii; ?>').prop('disabled', true); }"/><?php _e('Facebook', 'social-networks-auto-poster-facebook-twitter-g'); ?>&nbsp;&nbsp;&nbsp;
145
- <input value="A" type="radio" name="fb[<?php echo $ii; ?>][atchUse]" <?php if ($options['atchUse'] == 'A') echo "checked"; ?> onchange="if (jQuery(this).is(':checked')) { jQuery('#apFBMsgAFrmtDiv<?php echo $ii; ?>').hide(); jQuery('#nxsRBVidThumb<?php echo $ii; ?>').prop('disabled', false);}"/><?php _e('Plugin/API', 'social-networks-auto-poster-facebook-twitter-g'); ?>&nbsp;&nbsp;&nbsp;
146
- <input value="M" type="radio" name="fb[<?php echo $ii; ?>][atchUse]" <?php if ($options['atchUse'] == 'M') echo "checked"; ?> onchange="if (jQuery(this).is(':checked')) { jQuery('#apFBMsgAFrmtDiv<?php echo $ii; ?>').show(); jQuery('#nxsRBVidThumb<?php echo $ii; ?>').prop('disabled', false);}"/><?php _e('Set your own', 'social-networks-auto-poster-facebook-twitter-g'); ?>&nbsp;&nbsp;
147
- &lt;-- (<a id="showShAtt" onmouseout="hidePopShAtt('<?php echo $ii; ?>Fill');" onmouseover="showPopShAtt('<?php echo $ii; ?>Fill', event);" onclick="return false;" class="underdash" href="#"><?php _e('What\'s the difference?', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>)<br/>
148
-
149
- <div id="apFBMsgAFrmtDiv<?php echo $ii; ?>" style="<?php if ($options['atchUse'] != 'M') echo "display:none;"; ?>" >
150
- &nbsp;&nbsp;&nbsp; <?php _e('Attachment Title Format', 'social-networks-auto-poster-facebook-twitter-g'); ?>:<input name="fb[<?php echo $ii; ?>][msgTAFrmt]" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['msgTAFrmt'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /><br/>
151
- &nbsp;&nbsp;&nbsp; <?php _e('Attachment Text Format', 'social-networks-auto-poster-facebook-twitter-g'); ?>:<input name="fb[<?php echo $ii; ?>][msgDAFrmt]" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['msgDAFrmt'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />
152
- </div>
153
-
154
  <strong><?php _e('If post has a video:', 'social-networks-auto-poster-facebook-twitter-g'); ?>&nbsp;</strong>
155
- <input value="N" type="radio" name="fb[<?php echo $ii; ?>][fbAttchAsVid]" <?php if ($options['fbAttchAsVid'] == 'N') echo 'checked="checked"'; ?> /><?php _e('Do nothing', 'social-networks-auto-poster-facebook-twitter-g'); ?>&nbsp;&nbsp;&nbsp;
156
- <input value="A" id="nxsRBVidThumb<?php echo $ii; ?>" <?php if ($options['atchUse'] == 'F') echo "disabled"; ?> type="radio" name="fb[<?php echo $ii; ?>][fbAttchAsVid]" <?php if ($options['fbAttchAsVid'] == 'A') echo 'checked="checked"'; ?> /><?php _e('Use as thumbnail', 'social-networks-auto-poster-facebook-twitter-g'); ?>&nbsp;&nbsp;&nbsp;
157
- <input value="V" type="radio" name="fb[<?php echo $ii; ?>][fbAttchAsVid]" <?php if ($options['fbAttchAsVid'] == 'V') echo 'checked="checked"'; ?> />
158
  <?php _e('Attach Video(!)', 'social-networks-auto-poster-facebook-twitter-g'); ?>&nbsp;&nbsp;
159
  &lt;-- (<a id="showShAtt" onmouseout="hidePopShAtt('<?php echo $ii; ?>Video');" onmouseover="showPopShAtt('<?php echo $ii; ?>Video', event);" onclick="return false;" class="underdash" href="#"><?php _e('What\'s the difference?', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>)
160
- <br/>
161
-
162
 
163
  </div><br/></div>
164
 
165
  <div class="popShAtt" style="z-index: 9999; width: 350px;" id="popShAtt<?php echo $ii; ?>I"><h3><?php _e('Where to upload Images', 'social-networks-auto-poster-facebook-twitter-g'); ?></h3> <b><?php _e('(App Album)', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> <?php _e('Facebook automatically creates an album for your app. Images will be grouped there as in any regular album.', 'social-networks-auto-poster-facebook-twitter-g'); ?> <br/><br/><b><?php _e('(Timeline)', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> <?php _e('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.', 'social-networks-auto-poster-facebook-twitter-g'); ?></div>
166
- <div class="popShAtt" style="z-index: 9999" id="popShAtt<?php echo $ii; ?>"><h3><?php _e('Two ways of attaching post on Facebook', 'social-networks-auto-poster-facebook-twitter-g'); ?></h3><img src="<?php echo $nxs_plurl; ?>img/fb2wops.png" width="600" height="257" alt="<?php _e('Two ways of attaching post on Facebook', 'social-networks-auto-poster-facebook-twitter-g'); ?>"/></div>
167
- <div class="popShAtt" style="z-index: 9999" id="popShAtt<?php echo $ii; ?>X"><h3><?php _e('Facebook Post Types', 'social-networks-auto-poster-facebook-twitter-g'); ?></h3><img src="<?php echo $nxs_plurl; ?>img/fbPostTypesDiff6.png" width="600" height="398" alt="<?php _e('Facebook Post Types', 'social-networks-auto-poster-facebook-twitter-g'); ?>"/></div>
168
-
169
- <div class="popShAtt" style="z-index: 9999; width: 350px;" id="popShAtt<?php echo $ii; ?>Fill"><h3><?php _e('What should fill attachment info', 'social-networks-auto-poster-facebook-twitter-g'); ?></h3> <b><?php _e('(Facebook)', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> <?php _e('Recommended. Facebook will automatically take attached/shared link info from OG: tags or other sources.', 'social-networks-auto-poster-facebook-twitter-g'); ?> <br/><br/><b><?php _e('(Pluign/API)', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> <?php _e('Plugin will generate attachment title and description using info from SEO Plugins, then post excerpt, then post text and title.', 'social-networks-auto-poster-facebook-twitter-g'); ?><br/><br/><b><?php _e('(Set your own)', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> <?php _e('Set the format by yourself using message formatting tags', 'social-networks-auto-poster-facebook-twitter-g'); ?></div>
170
- <div class="popShAtt" style="z-index: 9999; width: 350px;" id="popShAtt<?php echo $ii; ?>Video"><h3><?php _e('If post has a video', 'social-networks-auto-poster-facebook-twitter-g'); ?></h3> <b><?php _e('(Do Nothing)', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> <?php _e('Plugin is not going to do anything specific about video', 'social-networks-auto-poster-facebook-twitter-g'); ?> <br/><br/><b><?php _e('(Use as thumbnail)', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> <?php _e('Video thumbnail will be used as attachment image. Please note - <b>it won\'t be playable.</b> This option is not compatible with "What should fill attachment info: Facebook"', 'social-networks-auto-poster-facebook-twitter-g'); ?><br/><br/><b><?php _e('(Attach video page to the Facebook post)', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> <?php _e('If you choose this, YouTube or Vimeo page will be attached to the Facebook post as <b>playable thumbnail</b>. Please note! <b>There will be no link to your site.</b> Please use %URL% in the message format if you need a backlink', 'social-networks-auto-poster-facebook-twitter-g'); ?></div>
171
-
172
 
173
-
174
-
175
- <?php if ($options['fbPgID']!='') {?><div style="width:100%;"><strong>Facebook Page ID:</strong> <?php if (!empty($options['destType']) && $options['destType'] == 'pr') _e('Profile', 'social-networks-auto-poster-facebook-twitter-g');
176
- if (!empty($options['destType']) && $options['destType'] == 'gr') _e('Group', 'social-networks-auto-poster-facebook-twitter-g');
177
- if (empty($options['destType']) || (!empty($options['destType']) && $options['destType'] == 'pg')) _e('Page', 'social-networks-auto-poster-facebook-twitter-g'); ?>&nbsp;-&nbsp;
178
- <?php _e(apply_filters('format_to_edit', htmlentities($options['fbPgID'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>
179
- </div><?php } ?>
180
- <?php
181
- if (!empty($options['fbAppID'])) {
182
- if($options['fbAppSec']=='') { ?>
183
- <b><?php _e('Authorize Your Facebook Account', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> <?php _e('Please click "Update Settings" to be able to Authorize your account.', 'social-networks-auto-poster-facebook-twitter-g'); ?>
184
- <?php } else { if(isset($options['fbAppAuthUser']) && $options['fbAppAuthUser']>0) { ?>
185
- <?php _e('Your Facebook Account has been authorized.', 'social-networks-auto-poster-facebook-twitter-g'); ?> User ID: <?php _e(apply_filters('format_to_edit', htmlentities($options['fbAppAuthUser'].(!empty($options['fbAppAuthUserName'])?" - ".$options['fbAppAuthUserName']:''), ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>.
186
  <br/><?php _e('You can', 'social-networks-auto-poster-facebook-twitter-g'); ?> Re- <?php } ?>
187
- <a href="https://www.facebook.com/dialog/oauth?client_id=<?php echo trim($options['fbAppID']);?>&scope=publish_actions,manage_pages,publish_pages,user_managed_groups,user_posts,user_photos&state=<?php echo 'nxs-fb-'.$ii; ?>&redirect_uri=<?php echo trim(urlencode($nxs_snapSetPgURL));?>">Authorize Your Facebook Account</a>
188
- <?php if (!isset($options['fbAppAuthUser']) || $options['fbAppAuthUser']<1) { ?> <div class="blnkg">&lt;=== <?php _e('Authorize your account', 'social-networks-auto-poster-facebook-twitter-g'); ?> ===</div>
189
  <br/><br/><i> <?php _e('If you get Facebook message:', 'social-networks-auto-poster-facebook-twitter-g'); ?> <b>"Error. An error occurred. Please try again later."</b> or <b>"Error 191"</b> <?php _e('please make sure that domain name in your Facebook App matches your website domain exactly. Please note that www. and non www. versions are different domains.', 'social-networks-auto-poster-facebook-twitter-g'); ?></i> <?php }?>
190
- <?php } } ?>
191
-
192
- <?php if((isset($options['fbAppAuthUser']) && $options['fbAppAuthUser']>0) || !empty($options['atpKey']) || !empty($options['uName']) ) { ?>
193
-
194
- <br/><br/><b><?php _e('Test your settings', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('FB','<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?></a>
195
- <?php }?>
196
-
197
- </div>
198
- <?php /* ######################## Tools Tab ####################### */ ?>
199
- <?php if (!$isNew) { ?> <div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content">
200
-
201
- <?php nxs_showCatTagsCTFilters($nt, $ii, $options);
202
- nxs_addPostingDelaySelV3($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']); ?>
203
-
204
- <div style="width:100%;"><strong style="font-size: 16px;"><?php _e('Facebook Comments:', 'social-networks-auto-poster-facebook-twitter-g'); ?></strong> </div>
205
  <div style="margin-bottom: 5px; margin-left: 10px; ">
206
  <p style="font-size: 11px; margin: 0px;"><?php _e('Plugin could grab comments from Facebook and import them as Wordpress Comments', 'social-networks-auto-poster-facebook-twitter-g'); ?></p>
207
 
208
- <?php if ( !empty($gOptions['riActive']) && $gOptions['riActive'] == '1' ) { ?>
209
- <input value="1" id="apFBMsgAFrmtA<?php echo $ii; ?>" <?php if (trim($options['riComments'])=='1') echo "checked"; ?> type="checkbox" name="fb[<?php echo $ii; ?>][riComments]"/> <strong><?php _e('Import Facebook Comments', 'social-networks-auto-poster-facebook-twitter-g'); ?></strong>
210
  <br/>
211
- <div style="margin-bottom: 5px; margin-left: 10px; ">
212
- <input value="1" id="apFBMsgAFrmtA<?php echo $ii; ?>" <?php if (trim($options['riCommentsAA'])=='1') echo "checked"; ?> type="checkbox" name="fb[<?php echo $ii; ?>][riCommentsAA]"/> <strong><?php _e('Auto-approve imported comments', 'social-networks-auto-poster-facebook-twitter-g'); ?></strong></div>
213
 
214
- <?php } else { echo "<br/>"; _e('Please activate the "Comments Import" from SNAP Settings Tab', 'social-networks-auto-poster-facebook-twitter-g'); } ?>
 
 
215
 
216
  </div>
217
-
218
- <?php nxs_showRepostSettings($nt, $ii, $options); ?>
219
-
220
-
221
- </div> <?php } ?> <?php /* #### End of Tab #### */ ?>
222
- </div><br/> <?php /* #### End of Tabs #### */ ?>
223
-
224
- <div class="submitX nxclear" style="padding-bottom: 0px;">
225
- <input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'social-networks-auto-poster-facebook-twitter-g') ?>" />
226
- <?php /* ?>
227
- <input type="button" id="svBtn<?php echo $nt.$ii ?>" onclick="nxs_svSet('<?php echo $nt; ?>', '<?php echo $ii; ?>')" class="button-primary" value="<?php _e('Update Settings', 'social-networks-auto-poster-facebook-twitter-g') ?>" />
228
- <div id="nxsSaveLoadingImg<?php echo $nt.$ii; ?>" class="doneMsg">Saving.....</div> <div id="doneMsg<?php echo $nt.$ii; ?>" class="doneMsg">Done</div>
229
- <?php */ ?>
230
- </div>
231
-
232
- </div>
233
- <?php
234
-
235
- }
236
  //#### Set Unit Settings from POST
237
- function setNTSettings($post, $options){ $code = 'FB'; $lcode = 'fb';
238
- foreach ($post as $ii => $pval){
239
- if (!empty($pval['apFBAppID']) || !empty($pval['atpKey']) || !empty($pval['uName'])) { if (!isset($options[$ii])) $options[$ii] = array();
240
-
241
- if (isset($pval['atpKey'])) $options[$ii]['atpKey'] = trim($pval['atpKey']);
242
- if (isset($pval['uName'])) $options[$ii]['uName'] = trim($pval['uName']);
243
- if (isset($pval['uPass'])) $options[$ii]['uPass'] = trim($pval['uPass']);
244
-
245
- if (isset($pval['apDoFB'])) $options[$ii]['doFB'] = $pval['apDoFB']; else $options[$ii]['doFB'] = 0;
246
- if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']);
247
- if (isset($pval['apFBAppID'])) $options[$ii]['fbAppID'] = trim($pval['apFBAppID']);
248
- if (isset($pval['apFBAppSec'])) $options[$ii]['fbAppSec'] = trim($pval['apFBAppSec']);
249
-
250
- if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']); else $options[$ii]['catSel'] = 0;
251
- if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
252
-
253
- if (isset($pval['postType'])) $options[$ii]['postType'] = trim($pval['postType']);
254
- if (isset($pval['apFBAttch'])) $options[$ii]['fbAttch'] = $pval['apFBAttch']; else $options[$ii]['fbAttch'] = 0;
255
- if (isset($pval['fbAttchAsVid'])) $options[$ii]['fbAttchAsVid'] = $pval['fbAttchAsVid']; else $options[$ii]['fbAttchAsVid'] = 0;
256
- if (isset($pval['atchUse'])) $options[$ii]['atchUse'] = trim($pval['atchUse']);
257
-
258
- if ($options[$ii]['atchUse']=='F' && $options[$ii]['fbAttchAsVid'] = 'A') $options[$ii]['fbAttchAsVid'] = 'N';
259
-
260
- if (isset($pval['apFBImgUpl'])) $options[$ii]['imgUpl'] = $pval['apFBImgUpl']; else $options[$ii]['imgUpl'] = 0;
261
 
262
- if (isset($pval['apFBMsgFrmt'])) $options[$ii]['fbMsgFormat'] = trim($pval['apFBMsgFrmt']);
263
-
264
-
265
- if (isset($pval['msgTAFrmt'])) $options[$ii]['msgTAFrmt'] = trim($pval['msgTAFrmt']);
266
- if (isset($pval['msgDAFrmt'])) $options[$ii]['msgDAFrmt'] = trim($pval['msgDAFrmt']);
267
-
268
- if (isset($options[$ii]['useFBGURLInfo'])) unset($options[$ii]['useFBGURLInfo']);
269
- if (isset($options[$ii]['fbMsgAFrmt'])) unset($options[$ii]['fbMsgAFrmt']);
270
-
271
- if (isset($pval['riComments'])) $options[$ii]['riComments'] = $pval['riComments']; else $options[$ii]['riComments'] = 0;
272
- if (isset($pval['riCommentsAA'])) $options[$ii]['riCommentsAA'] = $pval['riCommentsAA']; else $options[$ii]['riCommentsAA'] = 0;
273
-
274
- $options[$ii] = nxs_adjRpst($options[$ii], $pval);
275
-
276
- if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']);
277
- if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
 
 
 
 
 
 
 
278
 
279
- if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
280
-
281
- if (isset($pval['apFBURL'])) { $options[$ii]['fbURL'] = trim($pval['apFBURL']); if ( substr($options[$ii]['fbURL'], 0, 4)!='http' ) $options[$ii]['fbURL'] = 'http://'.$options[$ii]['fbURL'];
282
- $fbPgID = $options[$ii]['fbURL']; if (substr($fbPgID, -1)=='/') $fbPgID = substr($fbPgID, 0, -1); $fbPgID = substr(strrchr($fbPgID, "/"), 1);
283
- if (strpos($fbPgID, '?')!==false) $fbPgID = substr($fbPgID, 0, strpos($fbPgID, '?'));
284
- if (strpos($fbPgID, '-')!==false) { $possID = substr(strrchr($fbPgID, "-"), 1); $fbPgID = (strlen($possID)>10 && is_numeric($possID))?$possID:$fbPgID; } //prr($fbPgID); die();
285
- $options[$ii]['fbPgID'] = $fbPgID; //echo $fbPgID;
286
- if (strpos($options[$ii]['fbURL'], '?')!==false) $options[$ii]['fbURL'] = substr($options[$ii]['fbURL'], 0, strpos($options[$ii]['fbURL'], '?'));// prr($pval); prr($options[$ii]); // die();
287
- }
288
- //## Compatibility with ver <3.2
289
- if (empty($options[$ii]['postType']) && !empty($options[$ii]['fbPostType'])) { $options[$ii]['postType'] = $options[$ii]['fbPostType']; unset($options[$ii]['fbPostType']); }
290
- if (empty($options[$ii]['postType']) && !empty($options[$ii]['PostType'])) { $pt = $options[$ii]['PostType']; unset($options[$ii]['PostType']); $options[$ii]['postType'] = $pt; }
291
 
292
- } elseif ( count($pval)==1 ) if (isset($pval['apDo'.$code])) $options[$ii]['do'.$code] = $pval['apDo'.$code]; else $options[$ii]['do'.$code] = 0;
293
  } return $options;
294
- }
295
- //#### Show Post->Edit Meta Box Settings
296
- function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID; $nt = 'fb'; $ntU = 'FB';
297
- foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapFB', true)); if (is_array($pMeta) && isset($pMeta[$ii]) && is_array($pMeta[$ii])) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
298
- if (empty($ntOpt['postType']) && !empty($ntOpt['fbPostType'])) { $ntOpt['postType'] = $ntOpt['fbPostType']; unset($ntOpt['fbPostType']); } //## Compatibility with ver <3.2
299
- if (empty($ntOpt['postType']) && !empty($ntOpt['PostType'])) { $pt = $ntOpt['PostType']; unset($ntOpt['PostType']); $ntOpt['postType'] = $pt; } //## Compatibility with ver <3.2
300
- if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = ''; if (empty($ntOpt['urlToUse'])) $ntOpt['urlToUse'] = '';
301
- $doFB = $ntOpt['doFB'] && (is_array($pMeta) || $ntOpt['catSel']!='1');
302
- $imgToUse = $ntOpt['imgToUse']; $urlToUse = $ntOpt['urlToUse'];
303
- $isAvailFB = $ntOpt['fbURL']!='' && $ntOpt['fbAppID']!='' && $ntOpt['fbAppSec']!=''; $isAttachFB = $ntOpt['fbAttch']; $fbMsgFormat = htmlentities($ntOpt['fbMsgFormat'], ENT_COMPAT, "UTF-8"); $fbPostType = $ntOpt['postType'];
304
- ?>
305
-
306
- <tr><th style="text-align:left;" colspan="2">
307
- <?php if ($ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='') { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
308
- <?php if (!empty($ntOpt['tagsSelX'])) { ?> <input type="hidden" class="nxs_TG" id="nxs_TG_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $ntOpt['tagsSelX']; ?>" /> <?php } ?>
309
-
310
- <?php if ($isAvailFB) { ?><input class="nxsGrpDoChb" value="1" id="doFB<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="fb[<?php echo $ii; ?>][doFB]" <?php if ((int)$doFB == 1) echo 'checked="checked" title="def"'; ?> />
311
- <?php if ($post->post_status == "publish") { ?> <input type="hidden" name="fb[<?php echo $ii; ?>][doFB]" value="<?php echo $doFB;?>"> <?php } ?> <?php } ?>
312
-
313
- <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', 'social-networks-auto-poster-facebook-twitter-g') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th><td><?php //## Only show RePost button if the post is "published"
314
- if ($post->post_status == "publish" && $isAvailFB) { ?>
315
-
316
- <input alt="<?php echo $ii; ?>" style="float: right;margin-left: 10px" 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', 'social-networks-auto-poster-facebook-twitter-g') ?>" />
317
- <?php if ($ntOpt['riComments']=='1' && (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) && strpos($pMeta[$ii]['pgID'],'_')!==false ) ) { ?>
318
- <input alt="<?php echo $ii; ?>" style="float: right; " onclick="return false;" type="button" class="button" name="riToFB_repostButton" id="riToFB_button" value="<?php _e('Import Comments from Facebook', 'social-networks-auto-poster-facebook-twitter-g') ?>" />
319
- <?php } ?>
320
 
321
- <?php } ?>
322
-
323
- <?php if (is_array($pMeta) && isset($pMeta[$ii]) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) && strpos($pMeta[$ii]['pgID'],'_')!==false ) { $pid = explode('_', $pMeta[$ii]['pgID']);
324
-
325
- ?> <span id="pstdFB<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
326
- <a style="font-size: 10px;" href="http://www.facebook.com/permalink.php?story_fbid=<?php echo $pid[1].'&id='.$pid[0]; ?>" target="_blank"><?php $nType="Facebook"; printf( __( 'Posted on', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
327
- </span><?php } ?>
328
-
329
- </td></tr>
330
- <?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>
331
- <?php } else { if ($post->post_status != "publish" && function_exists('nxs_doSMAS5') ) { $ntOpt['postTime'] = get_post_time('U', false, $post_id); nxs_doSMAS5($nt, $ii, $ntOpt); } ?>
332
-
333
- <?php if ($ntOpt['rpstOn']=='1') { ?>
334
-
335
- <tr id="altFormat1" style=""><th scope="row" class="nxsTHRow">
336
- <input value="0" type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]"/><input value="nxsi<?php echo $ii; ?>fb" type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]" <?php if (!empty($ntOpt['rpstPostIncl'])) echo "checked"; ?> />
337
- </th>
338
- <td> <?php _e('Include in "Auto-Reposting" to this network.', 'social-networks-auto-poster-facebook-twitter-g') ?>
339
- </td></tr> <?php } ?>
340
-
341
- <tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;">
342
-
343
- <b></b>
344
- </th>
345
- <td></td>
346
- </tr>
347
-
348
- <tr><th scope="row" style="text-align:right; width:150px; vertical-align:top; padding-top: 0px; padding-right:10px;"> <?php _e('Post Type:', 'social-networks-auto-poster-facebook-twitter-g'); ?> <br/>
349
  (<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/"><?php _e('What\'s the difference?', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>)</th><td>
350
 
351
- <input class="nxs_postEditCtrl" type="radio" name="fb[<?php echo $ii; ?>][postType]" value="T" <?php if ($fbPostType == 'T') echo 'checked="checked"'; ?> /> <?php _e('Text Post', 'social-networks-auto-poster-facebook-twitter-g'); ?> - <i><?php _e('just text message', 'social-networks-auto-poster-facebook-twitter-g'); ?></i><br/>
352
- <input class="nxs_postEditCtrl" type="radio" name="fb[<?php echo $ii; ?>][postType]" value="I" <?php if ($fbPostType == 'I') echo 'checked="checked"'; ?> /> <?php _e('Image Post', 'social-networks-auto-poster-facebook-twitter-g'); ?> - <i><?php _e('big image with text message', 'social-networks-auto-poster-facebook-twitter-g'); ?></i><br/>
353
- <input class="nxs_postEditCtrl" type="radio" name="fb[<?php echo $ii; ?>][postType]" value="A" <?php if ( !isset($fbPostType) || $fbPostType == '' || $fbPostType == 'A') echo 'checked="checked"'; ?> /> <?php _e('Text Post with "attached" blogpost', 'social-networks-auto-poster-facebook-twitter-g'); ?> &lt;-- (<a id="showShAtt" onmouseout="hidePopShAtt('<?php echo $ii; ?>');" onmouseover="showPopShAtt('<?php echo $ii; ?>', event);" onclick="return false;" class="underdash" href="http://www.nextscripts.com/blog/"><?php _e('What\'s the difference?', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>) <br/>
354
 
355
- <div style="width:100%; margin-left: 25px;"><strong><?php _e('Link attachment type:', 'social-networks-auto-poster-facebook-twitter-g'); ?>&nbsp;</strong> <input value="2" id="apFBAttchShare<?php echo $ii; ?>" onchange="doSwitchShAtt(0,<?php echo $ii; ?>);" type="radio" name="fb[<?php echo $ii; ?>][AttachPost]" <?php if ((int)$isAttachFB == 2) echo "checked"; ?> />
356
- <?php _e('Share a link to your blogpost', 'social-networks-auto-poster-facebook-twitter-g'); ?> .. <?php _e('or', 'social-networks-auto-poster-facebook-twitter-g'); ?> ..
357
- <input class="nxs_postEditCtrl" value="1" id="apFBAttch<?php echo $ii; ?>" onchange="doSwitchShAtt(1,<?php echo $ii; ?>);" type="radio" name="fb[<?php echo $ii; ?>][AttachPost]" <?php if ((int)$isAttachFB == 1) echo "checked"; ?> />
358
- <?php _e('Attach your blogpost', 'social-networks-auto-poster-facebook-twitter-g'); ?>
359
- </div>
360
- <div class="popShAtt" id="popShAtt<?php echo $ii; ?>"><h3><?php _e('Two ways of attaching post on Facebook', 'social-networks-auto-poster-facebook-twitter-g'); ?></h3> <img src="<?php echo $nxs_plurl; ?>img/fb2wops.png" width="600" height="257" alt="<?php _e('Two ways of attaching post on Facebook', 'social-networks-auto-poster-facebook-twitter-g'); ?>"/></div>
361
- <div class="popShAtt" id="popShAtt<?php echo $ii; ?>X"><h3><?php _e('Facebook Post Types', 'social-networks-auto-poster-facebook-twitter-g'); ?></h3><img src="<?php echo $nxs_plurl; ?>img/fbPostTypesDiff6.png" width="600" height="398" alt="<?php _e('Facebook Post Types', 'social-networks-auto-poster-facebook-twitter-g'); ?>"/></div>
362
  </td></tr>
363
-
364
-
365
- <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Message Format:', 'social-networks-auto-poster-facebook-twitter-g') ?></th>
366
- <td>
367
- <?php if (1==1) { ?>
368
- <textarea class="nxs_postEditCtrl" cols="150" rows="2" id="fb<?php echo $ii; ?>SNAPformat" name="fb[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('#fb<?php echo $ii; ?>SNAPformat').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apFBTMsgFrmt<?php echo $ii; ?>');"><?php echo $fbMsgFormat ?></textarea>
369
- <?php } else { ?>
370
- <input class="nxs_postEditCtrl" value="<?php echo $fbMsgFormat ?>" type="text" name="fb[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apFBTMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apFBTMsgFrmt".$ii, '', '58'); ?>
371
- <?php } ?>
372
- </td></tr>
373
- <?php /* ## Select Image & URL ## */ nxs_showImgToUseDlg($nt, $ii, $imgToUse); nxs_showURLToUseDlg($nt, $ii, $urlToUse);
374
- }
375
- }
376
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
377
  }
378
 
379
- function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
380
- if (isset($pMeta['SNAPformat'])) $optMt['fbMsgFormat'] = $pMeta['SNAPformat'];
381
- if (isset($pMeta['imgToUse'])) $optMt['imgToUse'] = $pMeta['imgToUse']; if (isset($pMeta['urlToUse'])) $optMt['urlToUse'] = $pMeta['urlToUse'];
382
- if (isset($pMeta['timeToRun'])) $optMt['timeToRun'] = $pMeta['timeToRun']; if (isset($pMeta['rpstPostIncl'])) $optMt['rpstPostIncl'] = $pMeta['rpstPostIncl'];
383
- if (isset($pMeta['AttachPost'])) $optMt['fbAttch'] = ($pMeta['AttachPost'] != '')?$pMeta['AttachPost']:0; else { if (isset($pMeta['SNAPformat'])) $optMt['fbAttch'] = 0; }
384
- if (isset($pMeta['postType'])) $optMt['postType'] = $pMeta['postType'];
385
- if (isset($pMeta['doFB'])) $optMt['doFB'] = $pMeta['doFB'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doFB'] = 0; }
386
- if (isset($pMeta['SNAPincludeFB']) && $pMeta['SNAPincludeFB'] == '1' ) $optMt['doFB'] = 1; // <2.6 Compatibility fix
387
- return $optMt;
 
388
  }
389
- }}
390
 
391
- if (!function_exists("nxs_getBackFBComments")) { function nxs_getBackFBComments($postID, $options, $po) { $ci = 0; if (empty($options['fbAppPageAuthToken'])) return;
392
- $options['appsecret_proof'] = hash_hmac('sha256', $options['fbAppPageAuthToken'], $options['fbAppSec']); $wprg = array('sslverify'=>false, 'timeout' => 30);
393
- $aacct = array('access_token'=>$options['fbAppPageAuthToken'], 'appsecret_proof'=>$options['appsecret_proof'], 'method'=>'get'); $ptype = get_post_type( $postID );
394
- $res = wp_remote_get( "https://graph.facebook.com/v2.3/".$po['pgID']."/comments?filter=toplevel&limit=250&".http_build_query($aacct, null, '&'), $wprg);
395
- if (is_wp_error($res) || empty($res['body'])) $badOut['Error'] = ' [ERROR] '.print_r($res, true); else { //prr($res);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
396
  $ret = json_decode($res['body'], true); if (empty($ret)) $badOut['Error'] .= "JSON ERROR: ".print_r($res, true); else { // prr($ret);
397
  $impCmnts = get_post_meta($postID, 'snapImportedFBComments', true); if (!is_array($impCmnts)) $impCmnts = array(); //prr($impCmnts);
398
- if (is_array($ret) && is_array($ret['data'])) foreach ($ret['data'] as $comment){ $cid = $comment['id']; if (trim($cid)=='') continue;
399
- if (!in_array('fbxcw'.$cid, $impCmnts)) {
400
- $res = wp_remote_get( "https://graph.facebook.com/v2.3/".$comment['from']['id']."?".http_build_query($aacct, null, '&'), $wprg); $authData = json_decode($res['body'], true);
401
-
402
  if ($ptype=='topic'){ $my_post = array('post_title' => '', 'post_content' => $comment['message'], 'post_status' => 'publish', 'post_parent' => $postID, 'post_author' => 0, 'post_type' => 'reply');
403
  $wpCid = wp_insert_post($my_post); add_post_meta($wpCid, '_bbp_anonymous_name', $comment['from']['name']); $fid = get_post_meta($postID, '_bbp_forum_id', true);
404
  add_post_meta($wpCid, '_bbp_anonymous_email', $comment['from']['id'].'@facebook.com'); add_post_meta($wpCid, '_bbp_anonymous_website', 'http://www.facebook.com/'.$comment['from']['id']);
405
  add_post_meta($wpCid, '_bbp_topic_id', $postID); add_post_meta($wpCid, '_bbp_forum_id', $fid);
406
 
407
  } else { $commentdata = array( 'comment_post_ID' => $postID, 'comment_author' => $comment['from']['name'], 'comment_author_email' => $comment['from']['id'].'@facebook.com',
408
- 'comment_author_url' => $authData['link'], 'comment_content' => $comment['message'], 'comment_date_gmt' => date('Y-m-d H:i:s', strtotime( $comment['created_time'] ) ), 'comment_type' => '');
409
- $wpCid = nxs_postNewComment($commentdata, $options['riCommentsAA']=='1'); //prr($commentdata);
410
  } $ci++; $impCmnts[$wpCid] = 'fbxcw'.$cid;
411
- } else $wpCid = array_search('fbxcw'.$cid, $impCmnts);
412
-
413
- $res = wp_remote_get( "https://graph.facebook.com/v2.3/".$cid."/comments?".http_build_query($aacct, null, '&'), $wprg); $replRet = json_decode($res['body'], true);
414
  if (is_array($replRet) && is_array($replRet['data'])) foreach ($replRet['data'] as $rComment){ $rCid = $rComment['id'];
415
- if (trim($rCid)!='' && !in_array('fbxcw'.$rCid, $impCmnts)) { // prr($impCmnts);
416
- $res = wp_remote_get( "https://graph.facebook.com/v2.3/".$rComment['from']['id']."?".http_build_query($aacct, null, '&'), $wprg); $authData = json_decode($res['body'], true);
417
  if ($ptype=='topic'){ $my_post = array('post_title' => '', 'post_content' => $rComment['message'], 'post_status' => 'publish', 'post_parent' => $postID, 'post_author' => 0, 'post_type' => 'reply');
418
  $wpCid = wp_insert_post($my_post); add_post_meta($wpCid, '_bbp_anonymous_name', $rComment['from']['name']); $fid = get_post_meta($postID, '_bbp_forum_id', true);
419
  add_post_meta($wpCid, '_bbp_anonymous_email', $rComment['from']['id'].'@facebook.com'); add_post_meta($wpCid, '_bbp_anonymous_website', 'http://www.facebook.com/'.$rComment['from']['id']);
420
  add_post_meta($wpCid, '_bbp_topic_id', $postID); add_post_meta($wpCid, '_bbp_forum_id', $fid);
421
  } else {
422
  $commentdata = array( 'comment_parent' => $wpCid, 'comment_post_ID' => $postID, 'comment_author' => $rComment['from']['name'], 'comment_author_email' => $rComment['from']['id'].'@facebook.com',
423
- 'comment_author_url' => $authData['link'], 'comment_content' => $rComment['message'], 'comment_date_gmt' => date('Y-m-d H:i:s', strtotime( $rComment['created_time'] ) ), 'comment_type' => '');
424
  // prr($commentdata);
425
  nxs_postNewComment($commentdata, $options['riCommentsAA']=='1');
426
  } $ci++; $impCmnts[] = 'fbxcw'.$rCid;
@@ -429,135 +412,27 @@ if (!function_exists("nxs_getBackFBComments")) { function nxs_getBackFBComments(
429
  }
430
  delete_post_meta($postID, 'snapImportedFBComments'); add_post_meta($postID, 'snapImportedFBComments', $impCmnts );
431
  //## if Importing manually from Button echo result.
432
- if (isset($_POST['id']) && $_POST['id']!='') printf( _n( '%d comment has been imported.', '%d comments has been imported.', $ci, 'social-networks-auto-poster-facebook-twitter-g'), $ci );
433
  }}
 
 
434
  }}
435
 
 
 
436
  // ShortCode [nxs_fbembed accnum=0]
437
- function nxs_fbembed_func( $atts ) { extract( shortcode_atts( array('accnum' => '0'), $atts ) ); $pid = get_the_ID(); $fbpo = get_post_meta($pid, 'snapFB', true); $fbpo = maybe_unserialize($fbpo);
438
  if (!is_array($fbpo) || !is_array($fbpo[$accnum]) || !isset($fbpo[$accnum]['pgID']) || strpos($fbpo[$accnum]['pgID'], '_')===false ) return; $fbpo = $fbpo[$accnum]['pgID'];
439
  $fbpoA = explode('_',$fbpo); $fpg = $fbpoA[0]; $fpid = $fbpoA[1];
440
  $txtOut = '<div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, \'script\', \'facebook-jssdk\'));</script>
441
  <div class="fb-post" data-href="https://www.facebook.com/permalink.php?story_fbid='.$fpid.'&amp;id='.$fpg.'"><div class="fb-xfbml-parse-ignore"><a href="https://www.facebook.com/permalink.php?story_fbid='.$fpid.'&amp;id='.$fpg.'">Post</a></div></div>';
442
  return $txtOut;
443
- }
444
  if (function_exists("add_shortcode")) add_shortcode( 'nxs_fbembed', 'nxs_fbembed_func' );
445
 
446
- if (!function_exists("nxs_rePostToFB_ajax")) { function nxs_rePostToFB_ajax() { check_ajax_referer('nxsSsPageWPN'); $postID = $_POST['id']; // $result = nsPublishTo($id, 'FB', true);
447
- $options = get_option('NS_SNAutoPoster'); foreach ($options['fb'] as $ii=>$fbo) if ($ii==$_POST['nid']) { $fbo['ii'] = $ii; $fbo['pType'] = 'aj';
448
- $fbpo = get_post_meta($postID, 'snapFB', true); /* echo $postID."|"; echo $fbpo; */ $fbpo = maybe_unserialize($fbpo); //prr($fbpo);
449
- if (is_array($fbpo) && isset($fbpo[$ii]) && is_array($fbpo[$ii]) ){ $ntClInst = new nxs_snapClassFB(); $fbo = $ntClInst->adjMetaOpt($fbo, $fbpo[$ii]); } //prr($fbo);
450
- if (isset($_POST['ri']) && $_POST['ri']=='1') { nxs_getBackFBComments($postID, $fbo, $fbpo[$ii]); die(); } else {
451
- $result = nxs_doPublishToFB($postID, $fbo); if ($result == '200') die("Your post has been successfully sent to Facebook."); else die($result);
452
- }
453
- }
454
- }
455
- }
456
 
457
- if (!function_exists("nxs_doPublishToFB")) { //## Second Function to Post to FB
458
- function nxs_doPublishToFB($postID, $options){ global $ShownAds; $ntCd = 'FB'; $ntCdL = 'fb'; $ntNm = 'Facebook'; $dsc = ''; $vidURL = '';
459
- if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true)); $wprg = array('sslverify'=>false, 'timeout' => 30);
460
- if (!class_exists('nxs_class_SNAP_FB')) { nxs_addToLogN('E', 'Error', $ntCd, '-=ERROR=- No Facebook API Lib Detected', ''); return "No Facebook API Lib Detected";}
461
-
462
- $fbWhere = 'feed'; $page_id = $options['fbPgID']; if (isset($ShownAds)) $ShownAdsL = $ShownAds;
463
- $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'POSTID'=>$postID, 'ACCNAME'=>$options['nName']));
464
- //## Some Common stuff
465
- if (empty($options['postType']) && !empty($options['fbPostType'])) { $options['postType'] = $options['fbPostType']; unset($options['fbPostType']); } //## Compatibility with v <3.2
466
- if (empty($options['postType']) && !empty($options['PostType'])) { $pt = $options['PostType']; unset($options['PostType']); $options['postType'] = $pt; } //## Compatibility with v <3.2
467
- //## Compatibility with v <3.4.15
468
- if (empty($options['atchUse'])) $options['atchUse'] = 'F';
469
- if (!empty($options['useFBGURLInfo']) && $options['useFBGURLInfo']=='1') $options['atchUse'] = 'F';
470
- if (isset($options['useFBGURLInfo']) && $options['useFBGURLInfo']=='0') $options['atchUse'] = 'A';
471
- if (!empty($options['fbMsgAFrmt'])) $options['atchUse'] = 'M';
472
- if (!empty($options['fbMsgAFrmt']) && empty($options['msgDAFrmt'])) { $options['msgDAFrmt'] = $options['fbMsgAFrmt']; $options['msgTAFrmt'] = '%TITLE%'; }
473
- if (isset($options['fbAttchAsVid']) && $options['fbAttchAsVid'] == '1') $options['fbAttchAsVid'] = 'A';
474
- if (empty($options['fbAttchAsVid'])) $options['fbAttchAsVid'] = 'N';
475
-
476
- $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
477
- $logNT = '<span style="color:#0000FF">Facebook</span> - '.$options['nName'];
478
- $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
479
- if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
480
- $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') {
481
- nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$options['pType']); return;
482
- }
483
- }
484
- //## Make the post
485
- if (isset($options['qTLng'])) $lng = $options['qTLng']; else $lng = ''; if (!isset($options['fbAppPageAuthToken'])) $options['fbAppPageAuthToken'] = '';
486
- $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url();
487
- //## Initiate Posting Array
488
- $message = array('message'=>'', 'link'=>'', 'title'=>'', 'description'=>'', 'imageURL'=>'', 'videoURL'=>'', 'siteName'=>$blogTitle); $imgURL = '';
489
-
490
- if ($postID=='0') { $options['fbMsgFormat'] = 'Test Post, Please Ignore';
491
- $dsc = 'Test Post, Description'; $urlTitle = 'Test Post - Title'; $urlToGo = home_url();
492
- } else { $post = get_post($postID); if(!$post) return; $msg = nsFormatMessage($options['fbMsgFormat'], $postID, $addParams);
493
- $fbPostType = $options['postType']; if ($fbPostType=='A') $fbPostType = (int)$options['fbAttch']==2?'S':'A'; $isAttachVidFB = $options['fbAttchAsVid'];
494
- nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
495
- $extInfo = ' | PostID: '.$postID." - ".(isset($post) && is_object($post)?nxs_doQTrans($post->post_title, $lng):'').' |'.$options['pType'];
496
- if ($fbPostType=='A') $imgURL = nxs_getPostImage($postID, 'medium'); // prr($options); echo "PP - ".$postID; prr($src);
497
- if ($fbPostType=='I' || $fbPostType=='S') $imgURL = nxs_getPostImage($postID, 'full'); // prr($options); echo "PP - ".$postID; prr($src);
498
- if ( ($fbPostType=='A' || $fbPostType=='S') && $options['atchUse']!='F' ){
499
- //## AUTO - Get Post Descr from SEO Plugins or make it.
500
- if ($options['atchUse']=='M') {$dsc = nsFormatMessage($options['msgDAFrmt'], $postID, $addParams); $urlTitle = nsFormatMessage($options['msgTAFrmt'], $postID, $addParams); }
501
- else { if (function_exists('aioseop_mrt_fix_meta') && $dsc=='') $dsc = trim(get_post_meta($postID, '_aioseop_description', true));
502
- if (function_exists('wpseo_admin_init') && $dsc=='') $dsc = trim(get_post_meta($postID, '_yoast_wpseo_opengraph-description', true));
503
- if (function_exists('wpseo_admin_init') && $dsc=='') $dsc = trim(get_post_meta($postID, '_yoast_wpseo_metadesc', true));
504
- if ($dsc=='') $dsc = trim(nxs_doQTrans($post->post_excerpt, $lng));
505
- if ($dsc=='') $dsc = trim(nxs_doQTrans($post->post_content, $lng));
506
- global $plgn_NS_SNAutoPoster; $gOptions = $plgn_NS_SNAutoPoster->nxs_options;if (empty($gOptions['brokenCntFilters'])) $dsc = apply_filters('the_content', $dsc);
507
- if ($dsc=='') $dsc = get_bloginfo('description'); $urlTitle = nxs_doQTrans($post->post_title, $lng);
508
- }
509
- $dsc = strip_tags(strip_shortcodes($dsc));// $dsc = nxs_decodeEntitiesFull($dsc); /## This is commented out to support Emoji in Link Description
510
- $dsc = nsTrnc($dsc, 900, ' ');
511
- }
512
-
513
- $msg = str_replace('<br>', "\n", $msg); $msg = str_replace('<br/>', "\n", $msg); $msg = str_replace('<br />', "\n", $msg);
514
- $msg = str_ireplace('<3','&lt;3', $msg); $msg = str_ireplace('<(','&lt;(', $msg); //## FB Smiles FIX.
515
- $msg = strip_tags($msg); $msg = nxs_decodeEntitiesFull($msg);
516
- $msg = str_ireplace('&#039;',"'", $msg); $msg = str_ireplace('&039;',"'", $msg); $msg = str_ireplace('&#39;',"'", $msg); $msg = str_ireplace('<3','&lt;3', $msg); $msg = str_ireplace('<(','&lt;(', $msg); //## FB Smiles FIX 2.
517
-
518
- if ($isAttachVidFB=='V') {$vids = nsFindVidsInPost($post, false); if (count($vids)>0) {
519
- if (strlen($vids[0])==11) $options['urlToUse'] = 'http://youtu.be/'.$vids[0];
520
- if (strlen($vids[0])==8 || strlen($vids[0])==9) $options['urlToUse'] = 'https://vimeo.com/'.$vids[0];
521
- if (strlen($vids[0])==15) $options['urlToUse'] = 'https://www.facebook.com/video.php?v='.$vids[0];
522
- }}
523
-
524
- if ($isAttachVidFB=='A') {$vids = nsFindVidsInPost($post, false); if (count($vids)>0) {
525
- if (strlen($vids[0])==11) { $vidURL = 'http://www.youtube.com/v/'.$vids[0]; $imgURL = nsGetYTThumb($vids[0]); }
526
- if (strlen($vids[0])==8 || strlen($vids[0])==9) { // $vidURL = 'https://secure.vimeo.com/moogaloop.swf?clip_id='.$vids[0].'&autoplay=1';
527
- $vidURL = 'https://f.vimeocdn.com/p/flash/moogaloop/6.0.37/moogaloop.swf?autoplay=1&clip_id='.$vids[0];
528
- $apiURL = "http://vimeo.com/api/v2/video/".$vids[0].".json?callback=showThumb"; $json = wp_remote_get($apiURL, $wprg);
529
- if (!is_wp_error($json)) { $json = $json['body']; $json = str_replace('/**/','',$json);
530
- $json = str_replace('showThumb(','',$json); $json = str_replace('])',']',$json); $json = json_decode($json, true); $imgURL = $json[0]['thumbnail_large']; }
531
- }
532
- if (strlen($vids[0])==15) { // $vidURL = 'https://secure.vimeo.com/moogaloop.swf?clip_id='.$vids[0].'&autoplay=1';
533
- $vidURL = 'https://www.facebook.com/video.php?v='.$vids[0]; $apiURL = "https://graph.facebook.com/v2.3/".$vids[0]; $json = wp_remote_get($apiURL, $wprg);
534
- if (!is_wp_error($json)) { $json = $json['body']; $json = json_decode($json, true); $frmts = $json['format']; $imgURL = array_pop($frmts); $imgURL = $imgURL['picture']; }
535
- }
536
- }}
537
- if (!empty($options['imgToUse'])) $imgURL = $options['imgToUse']; if (preg_match("/noImg.\.png/i", $imgURL)) $imgURL = 'http://www.noimage.faketld';//$imgURL = 'http://cdn.gtln.us/img/t1x1.gif';
538
-
539
- $options = nxs_getURL($options, $postID, $addParams); $urlToGo = $options['urlToUse'];
540
- $options['fbMsgFormat'] = $msg; if (!empty($urlTitle)) $urlTitle = nxs_decodeEntitiesFull(strip_tags(strip_shortcodes($urlTitle)));
541
- }
542
-
543
- $message = array('url'=>$urlToGo, 'urlTitle'=>$urlTitle, 'urlDescr'=>$dsc, 'imageURL'=>$imgURL, 'videoURL'=>$vidURL, 'siteName'=>$blogTitle); // prr($message); die();
544
- if (isset($ShownAds)) $ShownAds = $ShownAdsL; // FIX for the quick-adsense plugin
545
-
546
- //## Actual Post
547
- $ntToPost = new nxs_class_SNAP_FB(); $ret = $ntToPost->doPostToNT($options, $message);
548
- //## Process Results
549
- if (!is_array($ret) || !isset($ret['isPosted']) || $ret['isPosted']!='1') { //## Error
550
- if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);
551
- } else { // ## All Good - log it.
552
- if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo _e('OK - Message Posted, please see your '.$logNT.' Page. ', 'social-networks-auto-poster-facebook-twitter-g'); }
553
- else { nxs_addToRI($postID); nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPosted'=>'1', 'pgID'=>$ret['postID'], 'pDate'=>date('Y-m-d H:i:s')));
554
- $extInfo .= ' | <a href="'.$ret['postURL'].'" target="_blank">Post Link</a>'; nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo);
555
- if (!empty($ret['log']) && !empty($ret['log']['Warning'])) nxs_addToLogN('W', 'Warning', $logNT, $ret['log']['Warning'], $extInfo);
556
- }
557
- }
558
- //## Return Result
559
- if (!empty($ret['isPosted']) && $ret['isPosted']=='1') return 200; else return print_r($ret, true);
560
- }
561
- }
562
 
563
  ?>
1
  <?php
2
  //## NextScripts Facebook Connection Class
3
+ $nxs_snapAvNts[] = array('code'=>'FB', 'lcode'=>'fb', 'name'=>'Facebook', 'type'=>'Social Networks', 'ptype'=>'F', 'status'=>'A', 'desc'=>'Autopost text, image or share a link to your profile, business page, community page, or Facebook group');
4
 
5
+ if (!class_exists("nxs_snapClassFB")) { class nxs_snapClassFB extends nxs_snapClassNT {
6
+ var $ntInfo = array('code'=>'FB', 'lcode'=>'fb', 'name'=>'Facebook', 'defNName'=>'', 'tstReq' => true, 'instrURL'=>'http://www.nextscripts.com/instructions/facebook-social-networks-auto-poster-setup-installation');
7
+ var $defO = array('nName'=>'', 'do'=>'1', 'appKey'=>'', 'appSec'=>'', 'tpt'=>'' ,'postType'=>'A', 'msgFormat'=>'New post (%TITLE%) has been published on %SITENAME%', 'attachInfo'=>'F', 'attachVideo'=>'N', 'pgID'=>'', 'msgATFormat'=>'%TITLE%', 'msgAFormat'=>'%EXCERPT%', 'msgACFormat'=>'', 'imgUpl'=>'T','fbURL'=>'');
8
+ //#### Update
9
+ public function toLatestVer($ntOpts){ if( !empty($ntOpts['v'])) $v = $ntOpts['v']; else $v = 340; $ntOptsOut = ''; switch ($v) {
10
+ case 340: $ntOptsOut = $this->toLatestVerNTGen($ntOpts); $ntOptsOut['do'] = $ntOpts['do'.$this->ntInfo['code']]; $ntOptsOut['nName'] = $ntOpts['nName']; // prr($ntOpts);
11
+ if (empty($ntOpts['atchUse'])) $ntOpts['atchUse'] = 'F'; if (!empty($ntOpts['useFBGURLInfo']) && $ntOpts['useFBGURLInfo']=='1') $ntOpts['atchUse'] = 'F';
12
+ if (isset($ntOpts['useFBGURLInfo']) && $ntOpts['useFBGURLInfo']=='0') $ntOpts['atchUse'] = 'A'; if (empty($ntOpts['fbAttchAsVid'])) $ntOpts['fbAttchAsVid'] = 'N';
13
+ if (!empty($ntOpts['fbMsgAFrmt']) && empty($ntOpts['msgDAFrmt'])) { $ntOpts['msgDAFrmt'] = $ntOpts['fbMsgAFrmt']; $ntOpts['msgTAFrmt'] = '%TITLE%'; }
14
+ if (!empty($ntOpts['fbMsgAFrmt'])) $ntOpts['atchUse'] = 'M'; if (isset($ntOpts['fbAttchAsVid']) && $ntOpts['fbAttchAsVid'] == '1') $ntOpts['fbAttchAsVid'] = 'A';
15
+ $ntOptsOut['msgFormat'] = (!empty($ntOpts['fbMsgFormat']))?$ntOpts['fbMsgFormat']:''; $ntOptsOut['msgAFormat'] = (!empty($ntOpts['msgTAFrmt']))?$ntOpts['msgTAFrmt']:''; $ntOptsOut['msgATFormat'] = (!empty($ntOpts['msgDAFrmt']))?$ntOpts['msgDAFrmt']:''; $ntOptsOut['msgACFormat'] = '';
16
+ if (!empty($ntOpts['fbAppID'])) $ntOptsOut['appKey'] = $ntOpts['fbAppID']; if (!empty($ntOpts['fbAppSec'])) $ntOptsOut['appSec'] = $ntOpts['fbAppSec']; if (!empty($ntOpts['fbPgID'])) $ntOptsOut['pgID'] = $ntOpts['fbPgID'];
17
+
18
+ $ntOptsOut['accessToken']=!empty($ntOpts['fbAppAuthToken'])?$ntOpts['fbAppAuthToken']:''; $ntOptsOut['authUser']=!empty($ntOpts['fbAppAuthUser'])?$ntOpts['fbAppAuthUser']:'';
19
+ $ntOptsOut['authUserName']=!empty($ntOpts['fbAppAuthUserName'])?$ntOpts['fbAppAuthUserName']:''; $ntOptsOut['pageAccessToken']=!empty($ntOpts['fbAppPageAuthToken'])?$ntOpts['fbAppPageAuthToken']:'';
20
+
21
+ $ntOptsOut['appsecret_proof']=(!empty($ntOpts['appsecret_proof']))?$ntOpts['appsecret_proof']:''; $ntOptsOut['postType'] = $ntOpts['postType']; if (!empty($ntOpts['pgID'])) $ntOptsOut['pgID'] = $ntOpts['pgID'];
22
+ $ntOptsOut['attachInfo'] = $ntOpts['atchUse']; $ntOptsOut['imgUpl'] = $ntOpts['imgUpl'];
23
+ $ntOptsOut['fbURL'] = $ntOpts['fbURL']; $ntOptsOut['destType'] = !empty($ntOpts['destType'])?$ntOpts['destType']:''; $ntOptsOut['attachVideo'] = $ntOpts['fbAttchAsVid'];
24
+ $ntOptsOut['riComments'] = $ntOpts['riComments']; $ntOptsOut['riCommentsAA'] = $ntOpts['riCommentsAA'];
25
+ if ($ntOptsOut['imgUpl']!='T' && $ntOptsOut['imgUpl']!='A') { if ($ntOptsOut['imgUpl']=='1') $ntOptsOut['imgUpl'] = 'T'; else $ntOptsOut['imgUpl'] = 'A'; }
26
+ $ntOptsOut = nxs_arrMergeCheck($ntOptsOut, $this->defO); $ntOptsOut['isUpdd'] = '1'; $ntOptsOut['v'] = NXS_SETV;
27
+ break;
28
+ }
29
+ return !empty($ntOptsOut)?$ntOptsOut:$ntOpts;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  }
31
+
32
+ //#### Show Common Settings
33
+ public function showGenNTSettings($ntOpts){ $this->nt = $ntOpts; $this->showNTGroup(); }
34
  //#### Show NEW Settings Page
35
+ public function showNewNTSettings($ii){ $this->showGNewNTSettings($ii, $this->defO); }
36
+ //#### Show Unit Settings
37
+ public function checkIfSetupFinished($options) { return !empty($options['appKey']) && !empty($options['accessToken']) && (!empty($options['pgID']) || !empty($options['fbURL']) ); }
38
+ public function makeUName($options, $ii) { return !empty($options['pgName'])?$options['pgName']: $this->ntInfo['name'].' #'.$ii; }
39
+ public function doAuth() { $ntInfo = $this->ntInfo; global $nxs_snapSetPgURL;
40
+ if ( !empty($_GET['code']) && isset($_GET['state']) && substr($_GET['state'], 0, 7) == 'nxs-fb-'){ $this->showAuthTop(); echo "--== Auth ==--"; $at = $_GET['code']; $ii = str_replace('nxs-fb-','',$_GET['state']); $gGet = array();
41
+ if (!empty($_SERVER['QUERY_STRING'])) parse_str($_SERVER['QUERY_STRING'], $gGet); elseif (!empty($_SERVER['argv'][0])) parse_str($_SERVER['argv'][0], $gGet); else { $gGet = $_GET; prr($_GET); unset($gGet['post_type']);} prr($gGet); unset($gGet['code']); unset($gGet['state']); prr($gGet);
42
+ $sturl = explode('?',$nxs_snapSetPgURL); $nxs_snapSetPgURL = $sturl[0].((!empty($gGet))?'?'.http_build_query($gGet):''); $fbo = $this->nt[$ii]; $advSet = nxs_mkRemOptsArr(nxs_getNXSHeaders()); prr($fbo); $fbo['uMsg'] = '';
43
+ $tknURL = 'https://graph.facebook.com/oauth/access_token?client_id='.$fbo['appKey'].'&state=nxs-fb-'.$ii.'&redirect_uri='.urlencode($nxs_snapSetPgURL).'&client_secret='.$fbo['appSec'].'&code='.$at; $response = nxs_remote_get($tknURL, $advSet); echo "<br/>TKN URL: "; prr($tknURL);
44
+ if ( (is_object($response) && (isset($response->errors))) || (is_array($response) && stripos($response['body'],'"error":')!==false )) { prr($response); die('</div></div>'); }
45
+ if (substr($response['body'],0,1)=='{') $params = json_decode($response['body'], true); else parse_str($response['body'], $params); $at = $params['access_token']; echo "<br/>TKN PARAMS: "; prr($params); echo "<br/>TKN RESP: "; prr($response);
46
+ $response = nxs_remote_get('https://graph.facebook.com/oauth/access_token?client_secret='.$fbo['appSec'].'&client_id='.$fbo['appKey'].'&grant_type=fb_exchange_token&fb_exchange_token='.$at, $advSet);
47
+ if ((is_object($response) && isset($response->errors))) { prr($response); die('</div></div>');}
48
+ if (substr($response['body'],0,1)=='{') $params = json_decode($response['body'], true); else parse_str($response['body'], $params); $at = $params['access_token']; $fbo['accessToken'] = $at;
49
+ /* What is it? What I tried??
50
+ $response = nxs_remote_get('https://graph.facebook.com/oauth/client_code?access_token='.$fbo['accessToken'].'&client_secret='.$fbo['appSec'].'&redirect_uri='.urlencode($nxs_snapSetPgURL).'&client_id='.$fbo['appKey'], $advSet);
51
+ $code = CutFromTo($response['body'],'code":"','"');
52
+ $response = nxs_remote_get('https://graph.facebook.com/oauth/access_token?code='.$code.'&client_id='.$fbo['appKey'].'&redirect_uri='.urlencode($nxs_snapSetPgURL).'&machine_id=');
53
+ if (substr($response['body'],0,1)=='{') $params = json_decode($response['body'], true); else parse_str($response['body'], $params); $at = $params['access_token']; $fbo['accessTokenUser'] = $at;
54
+ prr($response); //die();
55
+ */
56
+ $aacct = array('access_token'=>$fbo['accessToken'], 'appsecret_proof'=>hash_hmac('sha256', $fbo['accessToken'], $fbo['appSec']), 'method'=>'get');
57
+ //$uurl = "https://graph.facebook.com/".$fbo['appKey'].'?'.http_build_query($aacct, null, '&'); prr($uurl); $res = nxs_remote_get( $uurl, $advSet); prr($res); die('</div></div>');
58
+ $uurl = "https://graph.facebook.com/me?".http_build_query($aacct, null, '&'); prr($uurl); $res = nxs_remote_get( $uurl, $advSet);
59
+ if (is_nxs_error($res) || empty($res['body'])) { echo "Can't get Facebook User."; prr($res); die('</div></div>');} else {
60
+ $user = json_decode($res['body'], true); if (empty($user)) {echo "Can't get Facebook User. JSON Error. "; prr($res); die('</div></div>');} else {
61
+ if (!empty($user['id'])) { echo "<b>-= Got user: </b>"; $fbo['authUser'] = $user['id']; $fbo['authUserName'] = $user['name'].(!empty($user['username'])?" (".$user['username'].")":''); prr($user);
62
+ if (empty($fbo['pgID'])) $fbo['pgID'] = $user['id']; else { $advSet = nxs_mkRemOptsArr(nxs_getNXSHeaders()); $aacct = array('access_token'=>$fbo['accessToken'], 'method'=>'get', 'metadata'=>'1', 'limit'=>250);
63
+ if (empty($fbo['tpt'])) $aacct['appsecret_proof'] = hash_hmac('sha256', $fbo['accessToken'], $fbo['appSec']); $resP = nxs_remote_get('https://graph.facebook.com/'.$fbo['pgID'].'?'.http_build_query($aacct, null, '&'), $advSet); $resP = json_decode($resP['body'], true);
64
+ if (!empty($resP['metadata']) && !empty($resP['metadata']['type']) && $resP['metadata']['type']=='page') { echo "<br/>---==== GETTING TOKEN FOR ALREADY SELECTED PAGE - ID: ".$fbo['pgID'].'<br/>';
65
+ $fbo = $this->getPageToken($fbo); if (!empty($fbo['uMsg'])) { echo '<b style="color:red">'; prr($fbo['uMsg']); if (!empty($user['id'])) nxs_save_glbNtwrks($ntInfo['lcode'],$ii,$fbo,'*'); die("<br/>---==== Can't get TOKEN for selected PAGE ID: ".$fbo['pgID'].'</b>'); }
66
+ else echo "<br/>---====OK. GOT TOKEN SUCCESSFULLY<br/><br/>";
67
+ } else $fbo['pageAccessToken'] = $fbo['accessToken'];
68
+ }
69
+ } else {echo "Can't get User. NO USER RETURNED. "; prr($res); die('</div></div>');}
70
+ }
71
+ } if (!empty($user['id'])) { nxs_save_glbNtwrks($ntInfo['lcode'],$ii,$fbo,'*');
72
+ echo '<div style="text-align:center;color:green; font-weight: bold; font-size:22px;" >ALL OK. You have been authorized. Refreshing page....</div><script type="text/javascript">setTimeout(function(){ window.location = "'.$nxs_snapSetPgURL.'"; }, 3000);</script>'; die('</div></div>');
73
+ } die('</div></div>');
74
+ }
75
+ }
76
+ function fbURLToPageID($fbo, $ii){ if (empty($fbo['pgID']) && !empty($fbo['fbURL'])) { if (empty($fbo['pgID'])) { $fbo['uMsg'] = '';
77
+ if ( substr($fbo['fbURL'], 0, 4)!='http' ) $fbo['fbURL'] = 'http://'.$fbo['fbURL']; $fbPgID = $fbo['fbURL']; if (substr($fbPgID, -1)=='/') $fbPgID = substr($fbPgID, 0, -1); $fbPgID = substr(strrchr($fbPgID, "/"), 1);
78
+ if (strpos($fbPgID, '?')!==false) $fbPgID = substr($fbPgID, 0, strpos($fbPgID, '?')); if (strpos($fbPgID, '-')!==false) { $possID = substr(strrchr($fbPgID, "-"), 1); $fbPgID = (strlen($possID)>10 && is_numeric($possID))?$possID:$fbPgID; }
79
+ $fbo['pgID'] = $fbPgID; if (strpos($fbo['fbURL'], '?')!==false) $fbo['fbURL'] = substr($fbo['fbURL'], 0, strpos($fbo['fbURL'], '?')); //prr($fbo, 'BCHEK');// prr($pval); prr($options[$ii]); // die();
80
+ } if (!is_numeric($fbo['pgID'])) { $pgInfo = $this->getPageInfo($fbo); /* prr($pgInfo, "PAGE INFO"); */ if (!is_array($pgInfo)) $fbo['uMsg'].=$pgInfo; else $fbo['pgID'] = $pgInfo['id']; }
81
+ if (!empty($fbo['pgID'])) { unset($fbo['fbURL']); nxs_save_glbNtwrks($this->ntInfo['lcode'],$ii,$fbo,'*'); }
82
+ } return $fbo;
83
+ }
84
+ function getPageInfo($fbo){ $advSet = nxs_mkRemOptsArr(nxs_getNXSHeaders()); $aacct = array('access_token'=>$fbo['accessToken'], 'method'=>'get', 'metadata'=>'1', 'limit'=>250); if (empty($fbo['tpt'])) $aacct['appsecret_proof'] = hash_hmac('sha256', $fbo['accessToken'], $fbo['appSec']);
85
+ $resP = nxs_remote_get('https://graph.facebook.com/'.$fbo['pgID'].'?'.http_build_query($aacct, null, '&'), $advSet); if ((is_object($resP) && isset($resP->errors))) return 'Error PG_INFO #1: '.print_r($resP, true);
86
+ $page = json_decode($resP['body'], true); if ( is_array($page) && !empty($page['error']) ) return 'Error PG_INFO #2: '.(!empty($page['error'])?print_r($page['error'], true):''); return $page;
87
+ }
88
+ function getPageToken($fbo){ $advSet = nxs_mkRemOptsArr(nxs_getNXSHeaders()); $errMsg = ''; $fbPgID = $fbo['pgID'];
89
+ $aacct = array('access_token'=>$fbo['accessToken'], 'method'=>'get', 'limit'=>250); if (empty($fbo['tpt'])) $aacct['appsecret_proof'] = hash_hmac('sha256', $fbo['accessToken'], $fbo['appSec']);
90
+ $res = nxs_remote_get( "https://graph.facebook.com/$fbPgID?fields=access_token&".http_build_query($aacct, null, '&'), $advSet); // prr($res);
91
+ if (is_nxs_error($res) || empty($res['body']) || $res['response']['code']!='200') { $errMsg = "Can't get Page Token. ".print_r($res, true); $fbo['uMsg'] = $errMsg; return $fbo; } else {
92
+ $token = json_decode($res['body'], true); if (empty($token)) { $errMsg = "Can't get Page Token. JSON Error. ".print_r($res, true); $fbo['uMsg'] = $errMsg; return $fbo; } else {
93
+ if (!empty($token['error'])) if (!empty($token['error']['message'])) { $errMsg = $token['error']['message'];
94
+ if ( stripos($errMsg, 'Unknown fields: access_token')!==false || stripos($errMsg, 'Cannot query users by their username')!==false || stripos($errMsg, 'node type (User)')!==false) {
95
+ $token['access_token'] = $fbo['accessToken']; $fbo['destType'] = (stripos($fbo['fbURL'], '/groups/')!=false)?'gr':'pr'; } else {
96
+ if (stripos($errMsg, 'Unsupported get request')!==false) $errMsg = "<b style='color:red;'>Error </b>: Your Facebook URL ( <i>".$fbo['fbURL']."</i> ) is either incorrect or authorzing user don't have rights to post there.<br/><br/>Reported Error: ". $errMsg."\n";
97
+ $fbo['uMsg'] = $errMsg; return $fbo;
98
+ }
99
+ }
100
+ if (!empty($token['access_token'])) { $fbo['pageAccessToken'] = $token['access_token']; } else { $errMsg = "Can't get Page Token. NO TOKEN RETURNED. Are you sure that user you are trying to authorize is an admin of the page? This message means user was authorized as profile, but page refused to return authorization token. This usually happens when user has <b>no rights</b> to post to that page. ".print_r($res, true); $fbo['uMsg'] = $errMsg; return $fbo; }
101
+ }
102
+ } $fbo['uMsg'] = $errMsg; return $fbo;
103
+ }
104
+ function getListOfPages($networks){ $opVal = array(); $opNm = 'nxs_snap_fb_'.sha1('nxs_snap_fb'.$_POST['u'].$_POST['p']); $opVal = nxs_getOption($opNm); $ii = $_POST['ii']; $pgs = ''; if (empty($options['pgID'])) $options['pgID'] = '';
105
+ $currPstAs = !empty($_POST['pgID'])?$_POST['pgID']:(!empty($networks['fb'][$ii])?$networks['fb'][$ii]['pgID']:'');
106
+ if (empty($_POST['force']) && !empty($opVal['pageList']) ) $pgs = $opVal['pageList']; else { $options = $networks['fb'][$ii];
107
+ $advSet = nxs_mkRemOptsArr(nxs_getNXSHeaders()); $aacct = array('access_token'=>$options['accessToken'], 'method'=>'get', 'limit'=>250); if (empty($options['tpt'])) $aacct['appsecret_proof'] = hash_hmac('sha256', $options['accessToken'], $options['appSec']);
108
+ //## Account Info
109
+ $resP = nxs_remote_get('https://graph.facebook.com/'.$options['authUser'].'/?'.http_build_query($aacct, null, '&'), $advSet); //prr($resP, 'ACCOUNT');
110
+ if (is_nxs_error($resP) || empty($resP['body'])) { $outMsg= 'Auth Error Account #1: '.print_r($resP, true); if (!empty($_POST['isOut'])) echo $outMsg; return $outMsg; }
111
+ $accInfo = json_decode($resP['body'], true); if ((is_array($accInfo) && !empty($accInfo['error']))) { $outMsg = 'Auth Error Account #2: '.print_r($accInfo['error'], true); if (!empty($_POST['isOut'])) echo $outMsg; return $outMsg; }
112
+ $pgs .= '<option class="nxsTeal" '.($options['pgID']==$accInfo['id'] ? 'selected="selected"':'').' value="'.$accInfo['id'].'">Profile: '.$accInfo['name'].' ('.$accInfo['id'].')</option>';
113
+ //## List of pages
114
+ $resP = nxs_remote_get('https://graph.facebook.com/'.$options['authUser'].'/accounts?'.http_build_query($aacct, null, '&'), $advSet);
115
+ if (is_nxs_error($resP) || empty($resP['body'])) { $outMsg= 'Auth Error #1: '.print_r($resP, true); if (!empty($_POST['isOut'])) echo $outMsg; return $outMsg; }
116
+ $pages = json_decode($resP['body'], true); if ((is_array($pages) && !empty($pages['error']))) { $outMsg = 'Auth Error #2: '.print_r($pages['error'], true); if (!empty($_POST['isOut'])) echo $outMsg; return $outMsg; }
117
+ if (!empty($pages['data'])) { $pages = $pages['data']; $opVal = array();
118
+ $nxPgL = array(); foreach ($pages as $pg) $nxPgL[] = array('id'=>$pg['id'], 'nm'=>$pg['name'], 'tk'=>$pg['access_token']);
119
+ if (!empty($nxPgL)) { uasort($nxPgL, array($this, 'pgCmp')); $pgs .= '<option disabled>'.__('Pages', 'social-networks-auto-poster-facebook-twitter-g').'</option>';
120
+ foreach ($nxPgL as $pg) $pgs .= '<option class="nxsBlue" '.($options['pgID']==$pg['id'] ? 'selected="selected"':'').' value="p'.$pg['id'].'">&nbsp;&nbsp;&nbsp;'.$pg['nm'].' ('.$pg['id'].')</option>';
121
+ }
122
+ }
123
+ //## List of Groups
124
+ $resP = nxs_remote_get('https://graph.facebook.com/'.$options['authUser'].'/groups?'.http_build_query($aacct, null, '&'), $advSet); // prr($resP, 'GROUPS');
125
+ if (is_nxs_error($resP) || empty($resP['body'])) { $outMsg= 'Auth Error #1: '.print_r($resP, true); if (!empty($_POST['isOut'])) echo $outMsg; return $outMsg; }
126
+ $pages = json_decode($resP['body'], true); if ((is_array($pages) && !empty($pages['error']))) { $outMsg = 'Auth Error #2: '.print_r($pages['error'], true); if (!empty($_POST['isOut'])) echo $outMsg; return $outMsg; }
127
+ if (!empty($pages['data'])) { $pages = $pages['data']; $opVal = array();
128
+ $nxGpO = array(); $nxGpC = array(); $nxGpS = array(); foreach ($pages as $pg) { $arr = array('id'=>$pg['id'], 'nm'=>$pg['name']); //prr($pg);
129
+ if ($pg['privacy']=='OPEN') $nxGpO[] = $arr; elseif ($pg['privacy']=='SECRET' && (!isset($pg['administrator']) || !empty($pg['administrator']))) $nxGpS[] = $arr;
130
+ elseif ($pg['privacy']=='CLOSED' && (!isset($pg['administrator']) || !empty($pg['administrator']))) $nxGpC[] = $arr; }
131
+ if (!empty($nxGpO)) { uasort($nxGpS, array($this, 'pgCmp')); $pgs .= '<option disabled>'.__('Public Groups', 'social-networks-auto-poster-facebook-twitter-g').'</option>';
132
+ foreach ($nxGpO as $pg) $pgs .= '<option class="nxsGreen" '.($options['pgID']==$pg['id'] ? 'selected="selected"':'').' value="'.$pg['id'].'">&nbsp;&nbsp;&nbsp;'.$pg['nm'].' ('.$pg['id'].')</option>';
133
+ }
134
+ if (!empty($nxGpC)) { uasort($nxGpC, array($this, 'pgCmp')); $pgs .= '<option disabled>'.__('Closed Groups', 'social-networks-auto-poster-facebook-twitter-g').'</option>';
135
+ foreach ($nxGpC as $pg) $pgs .= '<option class="nxsOrange" '.($options['pgID']==$pg['id'] ? 'selected="selected"':'').' value="'.$pg['id'].'">&nbsp;&nbsp;&nbsp;'.$pg['nm'].' ('.$pg['id'].')</option>';
136
+ }
137
+ if (!empty($nxGpS)) { uasort($nxGpS, array($this, 'pgCmp')); $pgs .= '<option disabled>'.__('Secret Groups', 'social-networks-auto-poster-facebook-twitter-g').'</option>';
138
+ foreach ($nxGpS as $pg) $pgs .= '<option class="nxsDarkOrange" '.($options['pgID']==$pg['id'] ? 'selected="selected"':'').' value="'.$pg['id'].'">&nbsp;&nbsp;&nbsp;'.$pg['nm'].' ('.$pg['id'].')</option>';
139
+ }
140
+
141
+ $opVal['pageListArr'] = $nxPgL; // $opVal['pageList'] = $pgs;
142
+ }
143
+
144
+ } $pgCust = (!empty($pgs) && !empty($currPstAs) && stripos($pgs,$currPstAs)===false)?'<option selected="selected" value="'.$currPstAs.'">'.$currPstAs.'</option>':'';
145
+ if (!empty($_POST['isOut'])) echo $pgCust.$pgs.'<option style="color:#BD5200" value="a">'.__('...enter the Page ID').'</option>'; // .'<option style="color:#BD5200" value="a">'.__('...enter the SubReddit ID').'</option>';
146
+ $opVal['pageList'] = $pgs; nxs_saveOption($opNm, $opVal); return $opVal;
147
+ }
148
+
149
+ function pgCmp($a, $b) { return strcasecmp ($a['nm'],$b['nm']); }
150
+
151
+
152
+ function accTab($ii, $options, $isNew=false){ global $nxs_snapSetPgURL; $ntInfo = $this->ntInfo; $nt = $ntInfo['lcode']; $ntU = $ntInfo['code']; if (empty($options['uMsg'])) $options['uMsg'] = ''; // prr($options);
153
+ if (!empty($options['accessToken']) && !empty($options['authUser'])) { if (empty($options['authUser'])) $options['authUser'] = ''; $options = $this->fbURLToPageID($options, $ii);
154
+ if (!is_numeric($options['pgID'])) { $pgInfo = $this->getPageInfo($options); /* prr($pgInfo, "PAGE INFO"); */ if (!is_array($pgInfo)) $options['uMsg'].=$options; else $options['pgID'] = $pgInfo['id']; }
155
+ $opNm = 'nxs_snap_fb_'.sha1('nxs_snap_fb'.$options['authUser'].$options['appKey']); $opVal = nxs_getOption($opNm);// prr($opVal);
156
+ if (empty($opVal)) { $tPST = (!empty($_POST))?$_POST:''; $_POST['pgID'] = $options['pgID']; $_POST['u'] = $options['authUser']; $_POST['p'] = $options['appKey']; $_POST['ii'] = $ii; $ntw[$nt][$ii]=$options; $opVal = $this->getListOfPages($ntw); $_POST = $tPST; }
157
+ if (!empty($opVal) & !is_array($opVal)) $options['uMsg'] .= $opVal; else { if (!empty($opVal) & is_array($opVal)) $options = array_merge($options, $opVal); }
158
+ ?><br/ ><div style="width:100%; font-size: 14px;"><b><?php _e('Where to Post', 'nxs_snap'); ?></b>.&nbsp;<?php _e('Please select your profile/page/group', 'social-networks-auto-poster-facebook-twitter-g'); ?>.<span style="color:#580058; font-size: 12px;">&nbsp;(<?php _e('Please see ', 'social-networks-auto-poster-facebook-twitter-g'); ?> - <a href="http://nxs.fyi/fb-not-in-the-list" target="_blank"><?php _e('Why Page/Group is not in the list and how to add it', 'social-networks-auto-poster-facebook-twitter-g'); ?>)</a></span></div>
159
+ <div id="nxsFBInfoDiv<?php echo $ii; ?>">
160
+ <div style="width:100%;">
161
+ <div>
162
+ <select id="fbpgID<?php echo $ii; ?>" onchange="nxs_fbPageChange('<?php echo $ii;?>',jQuery(this));" name="fb[<?php echo $ii;?>][pgID]">
163
+ <?php $pgi = !empty($options['pageList'])?$options['pageList']:'';
164
+ if (!empty($options['pgID'])) { echo (!empty($options['pgID']) && stripos($pgi,$options['pgID'])===false)?'<option selected="selected" value="'.$options['pgID'].'">'.$options['pgID'].'</option>':''; }
165
+ if (!empty($options['pgID'])) { $pgi = str_ireplace('selected="selected" ','',$pgi); $pgi = str_ireplace('value="'.$options['pgID'].'"','selected="selected" value="'.$options['pgID'].'"',$pgi);
166
+ $pgi = str_ireplace('value="p'.$options['pgID'].'"','selected="selected" value="p'.$options['pgID'].'"',$pgi);
167
+ } echo $pgi;
168
+ ?><option value="a"><?php _e('.... Enter the Page ID'); ?></option>
169
+ </select> <div id="nxsFBInfoDivBlock<?php echo $ii; ?>" style="display: inline-block;">
170
+ <input type="text" name="fb[<?php echo $ii;?>][pgIDCst]" style="width:450px;display: none;" id="fbInpCst<?php echo $ii; ?>" value="<?php echo $options['pgID']; ?>" onblur="nxs_InpToDDBlur(jQuery(this));" onchange="nxs_InpToDDChange(jQuery(this));" data-tid="fbpgID<?php echo $ii; ?>" />
171
+ <div style="display: inline-block;"><a onclick="nxs_fbGetPages(<?php echo $ii;?>, 1); jQuery(this).blur(); return false;" href="#"><img id="<?php echo $nt.$ii;?>rfrshImg" style="vertical-align: middle;" src='<?php echo NXS_PLURL; ?>img/refresh16.png' /></a></div></div> <img id="<?php echo $nt.$ii;?>ldImg" style="display: none;vertical-align: middle;" src='<?php echo NXS_PLURL; ?>img/ajax-loader-sm.gif' />
172
+ <?php if (empty($options['pgID'])) {?> <div style="display: inline-block;" class="blnkg">&lt;=== <?php _e('Please select where to post', 'social-networks-auto-poster-facebook-twitter-g'); ?> ===</div><?php } ?>
173
+ </div>
174
+ </div> <div style="color:#BB2727;" id="nxsFBMsgDiv<?php echo $ii; ?>"><pre><?php if (!empty($options['uMsg'])) echo $options['uMsg']; ?></pre></div>
175
+ </div> <input type="hidden" id="fbAuthUser<?php echo $ii; ?>" value="<?php echo $options['authUser']; ?>"/> <br/>
176
+ <?php } else { ?> <div style="width:100%; font-size: 14px;"><b><?php _e('Where to Post', 'nxs_snap'); ?></b><br/><span style="color:#008000">&nbsp;&nbsp;&nbsp;<?php _e('Please enter App ID, App Secret and Authorize Your Account to be able to choose where to post....', 'social-networks-auto-poster-facebook-twitter-g'); ?></span></div>
177
+ <div style="color:#BB2727;" id="nxsFBMsgDiv<?php echo $ii; ?>"><pre><?php if (!empty($options['uMsg'])) echo $options['uMsg']; ?></pre></div>
178
+ <?php } ?>
179
+ <?php if (!empty($options['tpt'])) { echo '<span style="color:red;">*************'; _e('Third Party Auth Token is used', 'social-networks-auto-poster-facebook-twitter-g'); echo '</span><br/><br/>'; } else {
180
+ $this->elemKeySecret($ii,'App ID','App Secret', $options['appKey'], $options['appSec'],'appKey','appSec','https://developers.facebook.com/apps/'); ?><br/><br/><?php $this->elemMsgFormat($ii,'Post Format','msgFormat',$options['msgFormat']);
181
+ } ?>
182
 
 
 
 
 
 
 
 
 
 
 
 
 
183
  <div style="width:100%;"><strong style="font-size: 16px;" 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/"><?php _e('What\'s the difference?', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>) </div>
184
  <div style="margin-left: 10px;">
185
 
187
 
188
  <input type="radio" name="fb[<?php echo $ii; ?>][postType]" value="I" <?php if ($options['postType'] == 'I') echo 'checked="checked"'; ?> onchange="if (jQuery(this).is(':checked')) { jQuery('.nxsDivFBPostTypeOpts<?php echo $ii; ?>').hide(); jQuery('#nxsDivFBImgUplOpts<?php echo $ii; ?>').show();}"/> <?php _e('Image Post', 'social-networks-auto-poster-facebook-twitter-g'); ?> - <i><?php _e('big image with text message', 'social-networks-auto-poster-facebook-twitter-g'); ?></i><br/>
189
  <div style="width:100%; margin-left: 15px;<?php if (empty($options['postType']) || $options['postType'] != 'I') echo "display:none;"; ?>" id="nxsDivFBImgUplOpts<?php echo $ii; ?>" class="nxsDivFBPostTypeOpts<?php echo $ii; ?>" ><strong><?php _e('Upload Images to', 'social-networks-auto-poster-facebook-twitter-g'); ?>:&nbsp;</strong>
190
+ <input value="A" id="apFBImgUplAPP<?php echo $ii; ?>" type="radio" name="fb[<?php echo $ii; ?>][imgUpl]" <?php if ($options['imgUpl'] == 'A') echo "checked"; ?> /> <?php _e('App Album', 'social-networks-auto-poster-facebook-twitter-g'); ?>
191
+ <input value="T" id="apFBImgUplTML<?php echo $ii; ?>" type="radio" name="fb[<?php echo $ii; ?>][imgUpl]" <?php if ($options['imgUpl'] != 'A') echo "checked"; ?> />
192
  <?php _e('Timeline', 'social-networks-auto-poster-facebook-twitter-g'); ?> &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/"><?php _e('What\'s the difference?', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>)
193
  </div>
194
 
195
  <input type="radio" name="fb[<?php echo $ii; ?>][postType]" value="A" <?php if ( !isset($options['postType']) || $options['postType'] == '' || $options['postType'] == 'A') echo 'checked="checked"'; ?> onchange="if (jQuery(this).is(':checked')) { jQuery('.nxsDivFBPostTypeOpts<?php echo $ii; ?>').hide(); jQuery('#nxsDivFBAttchLinkOpts<?php echo $ii; ?>').show();}" /> <?php _e('Text Post with "attached" link', 'social-networks-auto-poster-facebook-twitter-g'); ?><br/>
196
 
197
  <div id="nxsDivFBAttchLinkOpts<?php echo $ii; ?>" class="nxsDivFBPostTypeOpts<?php echo $ii; ?>" style="width:100%; margin-left: 15px; line-height: 22px;<?php if (!empty($options['postType']) && $options['postType'] != 'A') echo "display:none;"; ?>">
198
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
199
  <strong><?php _e('If post has a video:', 'social-networks-auto-poster-facebook-twitter-g'); ?>&nbsp;</strong>
200
+ <input value="N" type="radio" name="fb[<?php echo $ii; ?>][attachVideo]" <?php if (empty($options['attachVideo']) || $options['attachVideo'] == 'N' || $options['attachVideo'] == 'A') echo 'checked="checked"'; ?> /><?php _e('Do nothing', 'social-networks-auto-poster-facebook-twitter-g'); ?>&nbsp;&nbsp;&nbsp;
201
+ <input value="V" id="nxsRBVidThumbV<?php echo $ii; ?>" type="radio" name="fb[<?php echo $ii; ?>][attachVideo]" <?php if ($options['attachVideo'] == 'V') echo 'checked="checked"'; ?> />
 
202
  <?php _e('Attach Video(!)', 'social-networks-auto-poster-facebook-twitter-g'); ?>&nbsp;&nbsp;
203
  &lt;-- (<a id="showShAtt" onmouseout="hidePopShAtt('<?php echo $ii; ?>Video');" onmouseover="showPopShAtt('<?php echo $ii; ?>Video', event);" onclick="return false;" class="underdash" href="#"><?php _e('What\'s the difference?', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>)
204
+ <br/>
 
205
 
206
  </div><br/></div>
207
 
208
  <div class="popShAtt" style="z-index: 9999; width: 350px;" id="popShAtt<?php echo $ii; ?>I"><h3><?php _e('Where to upload Images', 'social-networks-auto-poster-facebook-twitter-g'); ?></h3> <b><?php _e('(App Album)', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> <?php _e('Facebook automatically creates an album for your app. Images will be grouped there as in any regular album.', 'social-networks-auto-poster-facebook-twitter-g'); ?> <br/><br/><b><?php _e('(Timeline)', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> <?php _e('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.', 'social-networks-auto-poster-facebook-twitter-g'); ?></div>
209
+ <div class="popShAtt" style="z-index: 9999" id="popShAtt<?php echo $ii; ?>"><h3><?php _e('Two ways of attaching post on Facebook', 'social-networks-auto-poster-facebook-twitter-g'); ?></h3><img src="<?php echo NXS_PLURL; ?>img/fb2wops.png" width="600" height="257" alt="<?php _e('Two ways of attaching post on Facebook', 'social-networks-auto-poster-facebook-twitter-g'); ?>"/></div>
210
+ <div class="popShAtt" style="z-index: 9999" id="popShAtt<?php echo $ii; ?>X"><h3><?php _e('Facebook Post Types', 'social-networks-auto-poster-facebook-twitter-g'); ?></h3><img src="<?php echo NXS_PLURL; ?>img/fbPostTypesDiff6.png" width="600" height="398" alt="<?php _e('Facebook Post Types', 'social-networks-auto-poster-facebook-twitter-g'); ?>"/></div>
 
 
 
 
211
 
212
+ <div class="popShAtt" style="z-index: 9999; width: 350px;" id="popShAtt<?php echo $ii; ?>Video"><h3><?php _e('If post has a video', 'social-networks-auto-poster-facebook-twitter-g'); ?></h3> <b><?php _e('(Do Nothing)', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> <?php _e('Plugin is not going to do anything specific about video', 'social-networks-auto-poster-facebook-twitter-g'); ?> <br/><br/><b><?php _e('(Attach video page to the Facebook post)', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> <?php _e('If you choose this, YouTube or Vimeo page will be attached to the Facebook post as <b>playable thumbnail</b>. Please note! <b>There will be no link to your site.</b> Please use %URL% in the message format if you need a backlink', 'social-networks-auto-poster-facebook-twitter-g'); ?></div>
213
+ <br/><?php
214
+ if(isset($options['authUser']) && $options['authUser']>0) { ?>
215
+ <?php _e('Your Facebook Account has been authorized.', 'social-networks-auto-poster-facebook-twitter-g'); ?> User ID: <?php _e(apply_filters('format_to_edit', htmlentities($options['authUser'].(!empty($options['authUserName'])?" - ".$options['authUserName']:''), ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>.
 
 
 
 
 
 
 
 
 
216
  <br/><?php _e('You can', 'social-networks-auto-poster-facebook-twitter-g'); ?> Re- <?php } ?>
217
+ <a href="#" onclick="var url = 'https://www.facebook.com/dialog/oauth?client_id='+jQuery('#fbappKey<?php echo $ii; ?>').val()+'&scope=publish_actions,manage_pages,publish_pages,user_managed_groups,user_posts,user_photos&state=nxs-fb-<?php echo $ii; ?>&redirect_uri=<?php echo trim(urlencode($nxs_snapSetPgURL));?>'; nxs_svSetAdv('<?php echo $nt; ?>', '<?php echo $ii; ?>', '<?php echo $isNew?'dom'.$ntU.$ii.'Div':'nxsAllAccntsDiv'; ?>','nxs<?php echo $ntU; ?>MsgDiv<?php echo $ii; ?>',url,'1'); return false;">Authorize Your Facebook Account</a>
218
+ <?php if (!isset($options['authUser']) || $options['authUser']<1) { ?> <div class="blnkg">&lt;=== <?php _e('Authorize your account', 'social-networks-auto-poster-facebook-twitter-g'); ?> ===</div>
219
  <br/><br/><i> <?php _e('If you get Facebook message:', 'social-networks-auto-poster-facebook-twitter-g'); ?> <b>"Error. An error occurred. Please try again later."</b> or <b>"Error 191"</b> <?php _e('please make sure that domain name in your Facebook App matches your website domain exactly. Please note that www. and non www. versions are different domains.', 'social-networks-auto-poster-facebook-twitter-g'); ?></i> <?php }?>
220
+
221
+ <br/><br/><?php
222
+ }
223
+ function advTab($ii, $options){?>
224
+ <div style="width:100%;"><strong style="font-size: 16px;"><?php _e('Facebook Comments:', 'social-networks-auto-poster-facebook-twitter-g'); ?></strong> </div>
 
 
 
 
 
 
 
 
 
 
225
  <div style="margin-bottom: 5px; margin-left: 10px; ">
226
  <p style="font-size: 11px; margin: 0px;"><?php _e('Plugin could grab comments from Facebook and import them as Wordpress Comments', 'social-networks-auto-poster-facebook-twitter-g'); ?></p>
227
 
228
+ <?php global $plgn_NS_SNAutoPoster; $gOptions = $plgn_NS_SNAutoPoster->nxs_options; if ( !empty($gOptions['riActive']) && $gOptions['riActive'] == '1' ) { ?>
229
+ <input value="1" id="apFBMsgAFrmtA<?php echo $ii; ?>" <?php if (!empty($options['riComments']) && trim($options['riComments'])=='1') echo "checked"; ?> type="checkbox" name="fb[<?php echo $ii; ?>][riComments]"/> <strong><?php _e('Import Facebook Comments', 'social-networks-auto-poster-facebook-twitter-g'); ?></strong>
230
  <br/>
 
 
231
 
232
+ <div style="margin-bottom: 5px; margin-left: 10px; ">
233
+ <input value="1" id="apFBMsgAFrmtA<?php echo $ii; ?>" <?php if (!empty($options['riCommentsAA']) && trim($options['riCommentsAA'])=='1') echo "checked"; ?> type="checkbox" name="fb[<?php echo $ii; ?>][riCommentsAA]"/> <strong><?php _e('Auto-approve imported comments', 'social-networks-auto-poster-facebook-twitter-g'); ?></strong></div>
234
+ <?php } else { echo "<br/>"; _e('Please activate the "Comments Import" from SNAP Settings Tab', 'social-networks-auto-poster-facebook-twitter-g'); } ?>
235
 
236
  </div>
237
+
238
+ <div style="margin-bottom: 5px; margin-top: 10px; "> <b style="font-size: 16px;"><?php _e('Auth Token:', 'social-networks-auto-poster-facebook-twitter-g'); ?></b><br/>
239
+ <a href="#" style="margin-left:50px; " class="button" onclick="jQuery(this).next().show(); jQuery(this).hide(); return false;">I understand that this is an unofficial feature.</a>
240
+ <div style="margin-bottom: 5px; margin-left: 10px; display: none;"><div style="color:red;">
241
+ <?php _e('"Third party auth tokens" is an unofficial workaround for the limitations of the standard Facebook API functionality. By using this you are confirming that you understand and agree to:', 'social-networks-auto-poster-facebook-twitter-g'); ?><br/>
242
+ <div style="color:red; margin-left: 10px; margin-top: 5px; margin-bottom: 10px;">
243
+ -<?php _e('<b>We do not support</b> or encourage the usage of this feature', 'social-networks-auto-poster-facebook-twitter-g'); ?><br/>
244
+ -<?php _e('This functionality might not work or might stop working at any time', 'social-networks-auto-poster-facebook-twitter-g'); ?><br/>
245
+ -<?php _e('Your <b>Facebook account might be suspended</b>', 'social-networks-auto-poster-facebook-twitter-g'); ?><br/>
246
+ -<?php _e('You are using this feature at your own risk. We are not responsible for any outcome of it\'s usage.', 'social-networks-auto-poster-facebook-twitter-g'); ?><br/></div></div>
247
+ <a href="#" style="margin-left:50px; " class="button" onclick="jQuery(this).next().show(); jQuery(this).hide(); return false;">I understand that this risky feature is provided "as is" with <b>no support</b> and might not work correctly.</a>
248
+ <div style="margin-bottom: 5px; margin-left: 10px; display: none;"> <b style="font-size: 16px;"><?php _e('Auth Token:', 'social-networks-auto-poster-facebook-twitter-g'); ?></b><?php if (empty($options['tpt'])) $options['tpt'] = ''; ?>
249
+ <input type="text" name="fb[<?php echo $ii; ?>][tpt]" style="width: 40%;border: 1px solid #ACACAC;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['tpt'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />
250
+ </div> </div> </div>
251
+
252
+ <?php }
 
 
 
253
  //#### Set Unit Settings from POST
254
+ function setNTSettings($post, $options){
255
+ foreach ($post as $ii => $pval){
256
+ if (!empty($pval['appKey']) || !empty($pval['tpt'])){ if (!isset($options[$ii])) $options[$ii] = array(); $options[$ii] = $this->saveCommonNTSettings($pval,$options[$ii]);
257
+ //## Uniqe Items
258
+ if (isset($pval['tpt'])) { $options[$ii]['tpt'] = trim($pval['tpt']); if (empty($options[$ii]['appKey'])) $options[$ii]['appKey'] = 'AppKey';
259
+ if (!empty($pval['tpt'])) { $options[$ii]['pageAccessToken'] = trim($pval['tpt']); $options[$ii]['accessToken'] = trim($pval['tpt']); $options[$ii]['authUser'] = 'me'; }
260
+ } else $options[$ii]['tpt'] = ''; // prr($options);
261
+ if (isset($pval['postType'])) $options[$ii]['postType'] = trim($pval['postType']);
262
+ if (isset($pval['attachInfo'])) $options[$ii]['attachInfo'] = trim($pval['attachInfo']);
263
+ if (isset($pval['attachVideo'])) $options[$ii]['attachVideo'] = trim($pval['attachVideo']);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
264
 
265
+ if (isset($pval['pgID']) && $pval['pgID']!=$options[$ii]['pgID'] && $pval['pgID']!='p'.$options[$ii]['pgID']) {
266
+ if (!empty($pval['pgIDCst']) && $pval['pgID']==$pval['pgIDCst']) { $pval['pgIDCst'] = trim($pval['pgIDCst']); //## Custom Page
267
+ //## URL
268
+ if ( substr($pval['pgIDCst'], 0, 4)=='http' ) { if (strpos($pval['pgIDCst'], 'profile.php?')!==false) $pval['pgIDCst'] = CutFromTo($pval['pgIDCst'].'&', 'id=','&'); else {
269
+ if (strpos($pval['pgIDCst'], '?')!==false) $pval['pgIDCst'] = substr($pval['pgIDCst'], 0, strpos($pval['pgIDCst'], '?'));
270
+ if (substr($pval['pgIDCst'], -1)=='/') $pval['pgIDCst'] = substr($pval['pgIDCst'], 0, -1); $pval['pgIDCst'] = substr(strrchr($pval['pgIDCst'], "/"), 1);
271
+ if (strpos($pval['pgIDCst'], '-')!==false) { $possID = substr(strrchr($pval['pgIDCst'], "-"), 1); $pval['pgIDCst'] = (strlen($possID)>10 && is_numeric($possID))?$possID:$pval['pgIDCst']; }
272
+ }
273
+ }
274
+ //prr($pval['pgIDCst']); prr($pval['pgID']);
275
+ if ( (strlen($pval['pgIDCst'])<10 || !is_numeric($pval['pgIDCst'])) && (strpos($pval['pgID'], 'groups')!==false)) echo 'Please use numeric Group ID. <a href="http://nxs.fyi/faq216" target="_blank">FAQ #2.16</a>';
276
+
277
+ $options[$ii]['pgID'] = $pval['pgIDCst']; $pgInfo = $this->getPageInfo($options[$ii]); /* prr($pgInfo, "PAGE INFO"); */ if (!is_array($pgInfo)) echo 'Checking '.$options[$ii]['pgID'].' | '.$pgInfo; else $options[$ii]['pgID'] = $pgInfo['id'];
278
+ if (!empty($pgInfo['metadata']) && !empty($pgInfo['metadata']['type']) && $pgInfo['metadata']['type']=='page') $options[$ii]['pgID'] = 'p'.$options[$ii]['pgID'];
279
+
280
+ } else $options[$ii]['pgID'] = trim($pval['pgID']); // prr($options[$ii]['pgID']);
281
+ if (substr($options[$ii]['pgID'],0,1)=='p') { $options[$ii]['pgID'] = substr($options[$ii]['pgID'],1); $options[$ii] = $this->getPageToken($options[$ii]);
282
+ if (!empty($options[$ii]['uMsg']) && function_exists('nxs_LogIt')) nxs_LogIt('E', 'FB', 'Page Auth', '', 'Error - FB Auth', print_r($options[$ii]['uMsg'], true));
283
+ } else $options[$ii]['pageAccessToken'] = $options[$ii]['accessToken'];
284
+ }
285
+ if (isset($pval['imgUpl'])) $options[$ii]['imgUpl'] = trim($pval['imgUpl']); else $options[$ii]['imgUpl'] = 'T';
286
+ if (isset($pval['fbURL'])) $options[$ii]['fbURL'] = trim($pval['fbURL']);
287
+ if (isset($pval['destType'])) $options[$ii]['destType'] = trim($pval['destType']);
288
 
289
+ if (isset($pval['msgACFormat'])) $options[$ii]['msgACFormat'] = trim($pval['msgACFormat']);
290
+ if (isset($pval['riComments'])) $options[$ii]['riComments'] = $pval['riComments']; else $options[$ii]['riComments'] = 0;
291
+ if (isset($pval['riCommentsAA'])) $options[$ii]['riCommentsAA'] = $pval['riCommentsAA']; else $options[$ii]['riCommentsAA'] = 0;
 
 
 
 
 
 
 
 
 
292
 
293
+ } elseif ( count($pval)==1 ) if (isset($pval['do'])) $options[$ii]['do'] = $pval['do']; else $options[$ii]['do'] = 0;
294
  } return $options;
295
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
296
 
297
+ //#### Show Post->Edit Meta Box Settings
298
+
299
+ function showEdPostNTSettings($ntOpts, $post){ $post_id = $post->ID; $nt = $this->ntInfo['lcode']; $ntU = $this->ntInfo['code'];
300
+ foreach($ntOpts as $ii=>$ntOpt) { $isFin = $this->checkIfSetupFinished($ntOpt); if (!$isFin) continue;
301
+ $pMeta = maybe_unserialize(get_post_meta($post_id, 'snap'.$ntU, true)); if (is_array($pMeta) && !empty($pMeta[$ii])) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]); // prr($ntOpt);
302
+
303
+ if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = ''; if (empty($ntOpt['urlToUse'])) $ntOpt['urlToUse'] = ''; $postType = isset($ntOpt['postType'])?$ntOpt['postType']:'';
304
+ $msgFormat = !empty($ntOpt['msgFormat'])?htmlentities($ntOpt['msgFormat'], ENT_COMPAT, "UTF-8"):''; $msgTFormat = !empty($ntOpt['msgTFormat'])?htmlentities($ntOpt['msgTFormat'], ENT_COMPAT, "UTF-8"):'';
305
+ $imgToUse = $ntOpt['imgToUse']; $urlToUse = $ntOpt['urlToUse']; $ntOpt['ii']=$ii; $this->nxs_tmpltAddPostMeta($post, $ntOpt, $pMeta);
306
+ $this->elemEdMsgFormat($ii, __('Message Format:', 'social-networks-auto-poster-facebook-twitter-g'),$msgFormat);
307
+ ?>
308
+
309
+ <tr style="<?php echo !empty($ntOpt['do'])?'display:table-row;':'display:none;'; ?>" class="nxstbldo nxstbldo<?php echo strtoupper($nt).$ii; ?>"><th scope="row" style="text-align:right; width:150px; vertical-align:top; padding-top: 0px; padding-right:10px;"> <?php _e('Post Type:', 'social-networks-auto-poster-facebook-twitter-g'); ?> <br/>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
310
  (<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/"><?php _e('What\'s the difference?', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>)</th><td>
311
 
312
+ <input class="nxs_postEditCtrl" type="radio" name="fb[<?php echo $ii; ?>][postType]" value="T" <?php if ($ntOpt['postType'] == 'T') echo 'checked="checked"'; ?> /> <?php _e('Text Post', 'social-networks-auto-poster-facebook-twitter-g'); ?> - <i><?php _e('just text message', 'social-networks-auto-poster-facebook-twitter-g'); ?></i><br/>
313
+ <input class="nxs_postEditCtrl" type="radio" name="fb[<?php echo $ii; ?>][postType]" value="I" <?php if ($ntOpt['postType'] == 'I') echo 'checked="checked"'; ?> /> <?php _e('Image Post', 'social-networks-auto-poster-facebook-twitter-g'); ?> - <i><?php _e('big image with text message', 'social-networks-auto-poster-facebook-twitter-g'); ?></i><br/>
314
+ <input class="nxs_postEditCtrl" type="radio" name="fb[<?php echo $ii; ?>][postType]" value="A" <?php if ( !isset($ntOpt['postType']) || $ntOpt['postType'] == '' || $ntOpt['postType'] == 'A') echo 'checked="checked"'; ?> /> <?php _e('Text Post with "attached" blogpost', 'social-networks-auto-poster-facebook-twitter-g'); ?><br/>
315
 
316
+ <div class="popShAtt" id="popShAtt<?php echo $ii; ?>X"><h3><?php _e('Facebook Post Types', 'social-networks-auto-poster-facebook-twitter-g'); ?></h3><img src="<?php echo NXS_PLURL; ?>img/fbPostTypesDiff6.png" width="600" height="398" alt="<?php _e('Facebook Post Types', 'social-networks-auto-poster-facebook-twitter-g'); ?>"/></div>
 
 
 
 
 
 
317
  </td></tr>
318
+ <?php
319
+ nxs_showImgToUseDlg($nt, $ii, $imgToUse);
320
+ /* ## Select Image & URL ## */ nxs_showURLToUseDlg($nt, $ii, $urlToUse); $this->nxs_tmpltAddPostMetaEnd($ii);
321
+ }
322
+ }
323
+
324
+ function showEdPostNTSettingsV4($ntOpt, $post){ $post_id = $post->ID; $nt = $this->ntInfo['lcode']; $ntU = $this->ntInfo['code']; $ii = $ntOpt['ii']; //prr($ntOpt['postType']);
325
+ if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = ''; if (empty($ntOpt['urlToUse'])) $ntOpt['urlToUse'] = '';
326
+ $msgFormat = !empty($ntOpt['msgFormat'])?htmlentities($ntOpt['msgFormat'], ENT_COMPAT, "UTF-8"):''; $msgTFormat = !empty($ntOpt['msgTFormat'])?htmlentities($ntOpt['msgTFormat'], ENT_COMPAT, "UTF-8"):'';
327
+ $imgToUse = $ntOpt['imgToUse']; $urlToUse = $ntOpt['urlToUse'];
328
+
329
+ $this->elemEdMsgFormat($ii, __('Message Format:', 'social-networks-auto-poster-facebook-twitter-g'),$msgFormat);
330
+ ?>
331
+
332
+ <div class="nxsPostEd_ElemWrap"> <div class="nxsPostEd_ElemLabel">
333
+ <?php _e('Post Type:', 'social-networks-auto-poster-facebook-twitter-g'); ?>(<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/"><?php _e('What\'s the difference?', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>)
334
+ </div>
335
+ <div class="nxsPostEd_Elem">
336
+ <input type="radio" name="fb[<?php echo $ii; ?>][postType]" value="T" class="nxsEdElem" <?php if ($ntOpt['postType'] == 'T') echo 'checked="checked"'; ?> /> <?php _e('Text Post', 'social-networks-auto-poster-facebook-twitter-g'); ?> - <i><?php _e('just text message', 'social-networks-auto-poster-facebook-twitter-g'); ?></i><br/>
337
+ <input type="radio" name="fb[<?php echo $ii; ?>][postType]" value="I" class="nxsEdElem" <?php if ($ntOpt['postType'] == 'I') echo 'checked="checked"'; ?> /> <?php _e('Image Post', 'social-networks-auto-poster-facebook-twitter-g'); ?> - <i><?php _e('big image with text message', 'social-networks-auto-poster-facebook-twitter-g'); ?></i><br/>
338
+ <input type="radio" name="fb[<?php echo $ii; ?>][postType]" value="A" class="nxsEdElem" <?php if ( !isset($ntOpt['postType']) || $ntOpt['postType'] == '' || $ntOpt['postType'] == 'A') echo 'checked="checked"'; ?> /> <?php _e('Text Post with "attached" blogpost', 'social-networks-auto-poster-facebook-twitter-g'); ?>
339
+ </div>
340
+ <div class="popShAtt" id="popShAtt<?php echo $ii; ?>X"><h3><?php _e('Facebook Post Types', 'social-networks-auto-poster-facebook-twitter-g'); ?></h3><img src="<?php echo NXS_PLURL; ?>img/fbPostTypesDiff6.png" width="600" height="398" alt="<?php _e('Facebook Post Types', 'social-networks-auto-poster-facebook-twitter-g'); ?>"/></div>
341
+ </div>
342
+
343
+ <?php
344
+ // ## Select Image & URL
345
+ nxs_showImgToUseDlg($nt, $ii, $imgToUse);
346
+ nxs_showURLToUseDlg($nt, $ii, $urlToUse);
347
+
348
  }
349
 
350
+ //#### Save Meta Tags to the Post
351
+ function adjMetaOpt($optMt, $pMeta){ $optMt = $this->adjMetaOptG($optMt, $pMeta);
352
+ if (!empty($pMeta['postType'])) $optMt['postType'] = $pMeta['postType'];
353
+ return $optMt;
354
+ }
355
+
356
+ function fixFBMsgs($msg) { $msg = str_replace('<br>', "\n", $msg); $msg = str_replace('<br/>', "\n", $msg); $msg = str_replace('<br />', "\n", $msg); $msg = str_ireplace('<3','&lt;3', $msg); $msg = str_ireplace('<(','&lt;(', $msg); //## FB Smiles FIX.
357
+ $msg = strip_tags($msg); $msg = nxs_decodeEntitiesFull($msg);
358
+ $msg = str_ireplace('&#039;',"'", $msg); $msg = str_ireplace('&039;',"'", $msg); $msg = str_ireplace('&#39;',"'", $msg); $msg = str_ireplace('<3','&lt;3', $msg); $msg = str_ireplace('<(','&lt;(', $msg); //## FB Smiles FIX 2.
359
+ return $msg;
360
  }
 
361
 
362
+ function adjPreFormatWP(&$options, $postID){ $post = get_post($postID);
363
+ if ($options['attachVideo']=='V') {$vids = nsFindVidsInPost($post, false); if (count($vids)>0) { $options['attachVideo']='A';
364
+ if (strlen($vids[0])==11) $options['urlToUse'] = 'http://youtu.be/'.$vids[0];
365
+ if (strlen($vids[0])==8 || strlen($vids[0])==9) $options['urlToUse'] = 'https://vimeo.com/'.$vids[0];
366
+ if (strlen($vids[0])==15) $options['urlToUse'] = 'https://www.facebook.com/video.php?v='.$vids[0];
367
+ }}
368
+ }
369
+ function adjPublishWP(&$options, &$message, $postID){
370
+ if (!empty($postID)) { if (trim($options['imgToUse'])!='') $imgURL = $options['imgToUse']; else $imgURL = nxs_getPostImage($postID, !empty($options['wpImgSize'])?$options['wpImgSize']:'full');
371
+ if (preg_match("/noImg.\.png/i", $imgURL)) { $imgURL = ''; $isNoImg = true; } $post = get_post($postID);
372
+ } elseif ($postID==='0') { $message['urlTitle'] = 'Test Title'; $message['urlDescr'] = 'Test Descr'; $message['urlCaption'] = ''; }
373
+ $message['urlTitle'] = $this->fixFBMsgs($message['urlTitle']); $message['urlDescr'] = $this->fixFBMsgs($message['urlDescr']); $options['msgFormat'] = $this->fixFBMsgs($options['msgFormat']);
374
+ }
375
+
376
+ function importComments($options='', $postID='', $po='') { $ci = 0; if (empty($postID)) $postID = $_POST['pid'];
377
+ if (empty($options)) { global $plgn_NS_SNAutoPoster; $options = $plgn_NS_SNAutoPoster->nxs_options; } if (isset($_POST['ii'])) $options = $options[$_POST['nt']][$_POST['ii']];
378
+ if (empty($po)) { $po = maybe_unserialize(get_post_meta($postID, 'snap'.strtoupper($_POST['nt']), true)); $po = $po[$_POST['ii']]; }
379
+ if (empty($options) || empty($options['pageAccessToken'])) return; $ptype = get_post_type( $postID );
380
+ $aacct = array('access_token'=>$options['pageAccessToken'], 'method'=>'get'); if (empty($options['tpt'])) $aacct['appsecret_proof'] = hash_hmac('sha256', $options['pageAccessToken'], $options['appSec']);
381
+ $res = nxs_remote_get( "https://graph.facebook.com/".$po['pgID']."/comments?filter=toplevel&limit=250&".http_build_query($aacct, null, '&'), nxs_mkRemOptsArr(nxs_getNXSHeaders()));
382
+ if (is_nxs_error($res) || empty($res['body'])) $badOut['Error'] = ' [ERROR] '.print_r($res, true); else { //prr($res);
383
  $ret = json_decode($res['body'], true); if (empty($ret)) $badOut['Error'] .= "JSON ERROR: ".print_r($res, true); else { // prr($ret);
384
  $impCmnts = get_post_meta($postID, 'snapImportedFBComments', true); if (!is_array($impCmnts)) $impCmnts = array(); //prr($impCmnts);
385
+ if (is_array($ret) && !empty($ret['data']) && is_array($ret['data'])) foreach ($ret['data'] as $comment){ $cid = $comment['id']; if (empty($cid)) continue;
386
+ if (!empty($comment['message']) && !in_array('fbxcw'.$cid, $impCmnts)) { // prr($comment);
 
 
387
  if ($ptype=='topic'){ $my_post = array('post_title' => '', 'post_content' => $comment['message'], 'post_status' => 'publish', 'post_parent' => $postID, 'post_author' => 0, 'post_type' => 'reply');
388
  $wpCid = wp_insert_post($my_post); add_post_meta($wpCid, '_bbp_anonymous_name', $comment['from']['name']); $fid = get_post_meta($postID, '_bbp_forum_id', true);
389
  add_post_meta($wpCid, '_bbp_anonymous_email', $comment['from']['id'].'@facebook.com'); add_post_meta($wpCid, '_bbp_anonymous_website', 'http://www.facebook.com/'.$comment['from']['id']);
390
  add_post_meta($wpCid, '_bbp_topic_id', $postID); add_post_meta($wpCid, '_bbp_forum_id', $fid);
391
 
392
  } else { $commentdata = array( 'comment_post_ID' => $postID, 'comment_author' => $comment['from']['name'], 'comment_author_email' => $comment['from']['id'].'@facebook.com',
393
+ 'comment_author_url' => 'https://www.facebook.com/'.$comment['from']['id'], 'comment_content' => $comment['message'], 'comment_date_gmt' => date('Y-m-d H:i:s', strtotime( $comment['created_time'] ) ), 'comment_type' => '');
394
+ $wpCid = nxs_postNewComment($commentdata, $options['riCommentsAA']=='1'); // prr($commentdata);
395
  } $ci++; $impCmnts[$wpCid] = 'fbxcw'.$cid;
396
+ } else $wpCid = array_search('fbxcw'.$cid, $impCmnts);
397
+ $res = nxs_remote_get( "https://graph.facebook.com/".$cid."/comments?".http_build_query($aacct, null, '&'), nxs_mkRemOptsArr(nxs_getNXSHeaders())); $replRet = json_decode($res['body'], true);
 
398
  if (is_array($replRet) && is_array($replRet['data'])) foreach ($replRet['data'] as $rComment){ $rCid = $rComment['id'];
399
+ if (!empty($rCid) && !empty($comment['message']) && !in_array('fbxcw'.$rCid, $impCmnts)) { // prr($impCmnts);
 
400
  if ($ptype=='topic'){ $my_post = array('post_title' => '', 'post_content' => $rComment['message'], 'post_status' => 'publish', 'post_parent' => $postID, 'post_author' => 0, 'post_type' => 'reply');
401
  $wpCid = wp_insert_post($my_post); add_post_meta($wpCid, '_bbp_anonymous_name', $rComment['from']['name']); $fid = get_post_meta($postID, '_bbp_forum_id', true);
402
  add_post_meta($wpCid, '_bbp_anonymous_email', $rComment['from']['id'].'@facebook.com'); add_post_meta($wpCid, '_bbp_anonymous_website', 'http://www.facebook.com/'.$rComment['from']['id']);
403
  add_post_meta($wpCid, '_bbp_topic_id', $postID); add_post_meta($wpCid, '_bbp_forum_id', $fid);
404
  } else {
405
  $commentdata = array( 'comment_parent' => $wpCid, 'comment_post_ID' => $postID, 'comment_author' => $rComment['from']['name'], 'comment_author_email' => $rComment['from']['id'].'@facebook.com',
406
+ 'comment_author_url' => 'https://www.facebook.com/'.$rComment['from']['id'], 'comment_content' => $rComment['message'], 'comment_date_gmt' => date('Y-m-d H:i:s', strtotime( $rComment['created_time'] ) ), 'comment_type' => '');
407
  // prr($commentdata);
408
  nxs_postNewComment($commentdata, $options['riCommentsAA']=='1');
409
  } $ci++; $impCmnts[] = 'fbxcw'.$rCid;
412
  }
413
  delete_post_meta($postID, 'snapImportedFBComments'); add_post_meta($postID, 'snapImportedFBComments', $impCmnts );
414
  //## if Importing manually from Button echo result.
415
+ if (isset($_POST['pid']) && $_POST['pid']!='') printf( _n( '%d comment has been imported.', '%d comments has been imported.', $ci, 'social-networks-auto-poster-facebook-twitter-g'), $ci );
416
  }}
417
+ }
418
+
419
  }}
420
 
421
+
422
+ //if (!function_exists("nxs_getBackFBComments")) { function nxs_getBackFBComments}}
423
  // ShortCode [nxs_fbembed accnum=0]
424
+ if (!function_exists("nxs_fbembed_func")) {function nxs_fbembed_func( $atts ) { extract( shortcode_atts( array('accnum' => '0'), $atts ) ); $pid = get_the_ID(); $fbpo = get_post_meta($pid, 'snapFB', true); $fbpo = maybe_unserialize($fbpo);
425
  if (!is_array($fbpo) || !is_array($fbpo[$accnum]) || !isset($fbpo[$accnum]['pgID']) || strpos($fbpo[$accnum]['pgID'], '_')===false ) return; $fbpo = $fbpo[$accnum]['pgID'];
426
  $fbpoA = explode('_',$fbpo); $fpg = $fbpoA[0]; $fpid = $fbpoA[1];
427
  $txtOut = '<div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, \'script\', \'facebook-jssdk\'));</script>
428
  <div class="fb-post" data-href="https://www.facebook.com/permalink.php?story_fbid='.$fpid.'&amp;id='.$fpg.'"><div class="fb-xfbml-parse-ignore"><a href="https://www.facebook.com/permalink.php?story_fbid='.$fpid.'&amp;id='.$fpg.'">Post</a></div></div>';
429
  return $txtOut;
430
+ }}
431
  if (function_exists("add_shortcode")) add_shortcode( 'nxs_fbembed', 'nxs_fbembed_func' );
432
 
 
 
 
 
 
 
 
 
 
 
433
 
434
+ if (!function_exists("nxs_doPublishToFB")) { function nxs_doPublishToFB($postID, $options){
435
+ if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true)); $cl = new nxs_snapClassFB(); $cl->nt[$options['ii']] = $options; return $cl->publishWP($options['ii'], $postID);
436
+ }}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
437
 
438
  ?>
inc-cl/fl.api.php CHANGED
@@ -33,8 +33,8 @@ if (!class_exists("nxs_class_SNAP_FL")) { class nxs_class_SNAP_FL {
33
 
34
  function createFile($imgURL) {
35
  $remImgURL = urldecode($imgURL); $urlParced = pathinfo($remImgURL); $remImgURLFilename = $urlParced['basename'];
36
- $imgData = wp_remote_get($remImgURL, array('timeout' => 45)); if (is_wp_error($imgData)) { $badOut['Error'] = print_r($imgData, true)." - ERROR"; return $badOut; }
37
- if (isset($imgData['content-type'])) $cType = $imgData['content-type']; $imgData = $imgData['body'];
38
  $tmp=array_search('uri', @array_flip(stream_get_meta_data($GLOBALS[mt_rand()]=tmpfile())));
39
  if (!is_writable($tmp)) { $badOut['Error'] = "Your temporary folder or file (file - ".$tmp.") is not witable. Can't upload images to Flickr"; return $badOut; }
40
  rename($tmp, $tmp.='.png'); register_shutdown_function(create_function('', "unlink('{$tmp}');"));
@@ -55,47 +55,30 @@ if (!class_exists("nxs_class_SNAP_FL")) { class nxs_class_SNAP_FL {
55
  if (!isset($options['accessToken']) || trim($options['accessToken'])=='') { $badOut['Error'] = 'Not Authorized'; return $badOut; }
56
  if (empty($options['imgSize'])) $options['imgSize'] = '';
57
  //## Format Post
58
- if (!empty($message['pText'])) $text = $message['pText']; else $text = nxs_doFormatMsg($options['msgFrmt'], $message);
59
- if (!empty($message['pTitle'])) $msgT = $message['pTitle']; else $msgT = nxs_doFormatMsg($options['msgTFrmt'], $message);
60
  //## Make Post
61
- if (isset($message['imageURL'])) $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); else $imgURL = ''; $postType = $options['postType'];
62
-
63
  if (empty($imgURL)) { $badOut['Error'] = 'No Image. Flickr is an image-sharing network. You can\'t post to Flickr without image.'; return $badOut; }
64
-
65
  require_once('apis/scOAuth.php'); $tum_oauth = new wpScoopITOAuth($options['appKey'], $options['appSec'], $options['accessToken'], $options['accessTokenSec']);
66
  $tum_oauth->baseURL = 'https://www.flickr.com/services'; $tum_oauth->request_token_path = '/oauth/request_token'; $tum_oauth->access_token_path = '/oauth/access_token';
67
-
68
  $tags = $message['tags']; $postArr = array('title'=>$msgT, 'description'=>$text, 'tags'=>$tags, 'is_public'=>1, 'safety_level'=>1, 'content_type'=>1, 'hidden'=>1);
69
  $imgFile = $this->createFile($imgURL); if (empty($imgFile) || is_array($imgFile)) { $badOut['Error'] = 'Image Error - '.print_r($imgFile, true); return $badOut; }
70
-
71
  $phiID = $tum_oauth->flUploadPhoto($imgFile, $postArr); // prr($phiID);
72
-
73
  if (!empty($phiID) && strpos($phiID, 'Problem: ')===false) {
74
- $params = array ('format' => 'php_serial', 'method'=>'flickr.photosets.addPhoto', 'photo_id'=>$phiID, 'photoset_id'=>$options['setID']);
75
- $uinfo = $tum_oauth->makeReq('https://api.flickr.com/services/rest/',$params);
76
-
77
- if (!empty($message['latitude']) && !empty($message['longitude'])) {
78
-
79
- $params = array (
80
- 'format' => 'php_serial',
81
- 'method'=>'flickr.photos.geo.setLocation',
82
- 'photo_id'=>$phiID,
83
- 'lat'=>$message['latitude'],
84
- 'lon'=>$message['longitude'],
85
- );
86
-
87
  $uinfo = $tum_oauth->makeReq('https://api.flickr.com/services/rest/',$params);
88
- }
89
-
90
  }
91
-
92
  if (!empty($phiID) && strpos($phiID, 'Problem: ')===false) {
93
- return array('postID'=>$phiID, 'isPosted'=>1, 'postURL'=> str_ireplace('people', 'photos', $options['userURL']).$phiID, 'pDate'=>date('Y-m-d H:i:s'));
94
  } else { $badOut['Error'] .= print_r($phiID, true)." Code:".$tum_oauth->http_code;
95
  return $badOut;
96
- }
97
- return $badOut;
98
  }
99
 
100
  }}
101
- ?>
33
 
34
  function createFile($imgURL) {
35
  $remImgURL = urldecode($imgURL); $urlParced = pathinfo($remImgURL); $remImgURLFilename = $urlParced['basename'];
36
+ $imgData = nxs_remote_get($remImgURL, array('timeout' => 45)); if (is_nxs_error($imgData)) { $badOut['Error'] = print_r($imgData, true)." - ERROR"; return $badOut; }
37
+ if (isset($imgData['content-type'])) $cType = !empty($imgData['content-type'])?$imgData['content-type']:'image/jpeg'; $imgData = $imgData['body'];
38
  $tmp=array_search('uri', @array_flip(stream_get_meta_data($GLOBALS[mt_rand()]=tmpfile())));
39
  if (!is_writable($tmp)) { $badOut['Error'] = "Your temporary folder or file (file - ".$tmp.") is not witable. Can't upload images to Flickr"; return $badOut; }
40
  rename($tmp, $tmp.='.png'); register_shutdown_function(create_function('', "unlink('{$tmp}');"));
55
  if (!isset($options['accessToken']) || trim($options['accessToken'])=='') { $badOut['Error'] = 'Not Authorized'; return $badOut; }
56
  if (empty($options['imgSize'])) $options['imgSize'] = '';
57
  //## Format Post
58
+ if (!empty($message['pText'])) $text = $message['pText']; else $text = nxs_doFormatMsg($options['msgFormat'], $message);
59
+ if (!empty($message['pTitle'])) $msgT = $message['pTitle']; else $msgT = nxs_doFormatMsg($options['msgTFormat'], $message);
60
  //## Make Post
61
+ if (isset($message['imageURL'])) $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); else $imgURL = '';
 
62
  if (empty($imgURL)) { $badOut['Error'] = 'No Image. Flickr is an image-sharing network. You can\'t post to Flickr without image.'; return $badOut; }
 
63
  require_once('apis/scOAuth.php'); $tum_oauth = new wpScoopITOAuth($options['appKey'], $options['appSec'], $options['accessToken'], $options['accessTokenSec']);
64
  $tum_oauth->baseURL = 'https://www.flickr.com/services'; $tum_oauth->request_token_path = '/oauth/request_token'; $tum_oauth->access_token_path = '/oauth/access_token';
 
65
  $tags = $message['tags']; $postArr = array('title'=>$msgT, 'description'=>$text, 'tags'=>$tags, 'is_public'=>1, 'safety_level'=>1, 'content_type'=>1, 'hidden'=>1);
66
  $imgFile = $this->createFile($imgURL); if (empty($imgFile) || is_array($imgFile)) { $badOut['Error'] = 'Image Error - '.print_r($imgFile, true); return $badOut; }
 
67
  $phiID = $tum_oauth->flUploadPhoto($imgFile, $postArr); // prr($phiID);
68
+
69
  if (!empty($phiID) && strpos($phiID, 'Problem: ')===false) {
70
+ $params = array ('format' => 'php_serial', 'method'=>'flickr.photosets.addPhoto', 'photo_id'=>$phiID, 'photoset_id'=>$options['setID']); $uinfo = $tum_oauth->makeReq('https://api.flickr.com/services/rest/',$params);
71
+ if (!empty($message['latitude']) && !empty($message['longitude'])) {
72
+ $params = array ( 'format' => 'php_serial', 'method'=>'flickr.photos.geo.setLocation', 'photo_id'=>$phiID, 'lat'=>$message['latitude'], 'lon'=>$message['longitude'], );
 
 
 
 
 
 
 
 
 
 
73
  $uinfo = $tum_oauth->makeReq('https://api.flickr.com/services/rest/',$params);
74
+ }
 
75
  }
 
76
  if (!empty($phiID) && strpos($phiID, 'Problem: ')===false) {
77
+ return array('postID'=>$phiID, 'isPosted'=>1, 'postURL'=> str_ireplace('people', 'photos', $options['userURL']).$phiID, 'pDate'=>date('Y-m-d H:i:s'));
78
  } else { $badOut['Error'] .= print_r($phiID, true)." Code:".$tum_oauth->http_code;
79
  return $badOut;
80
+ } return $badOut;
 
81
  }
82
 
83
  }}
84
+ ?>
inc-cl/fl.php CHANGED
@@ -1,121 +1,75 @@
1
  <?php
2
- //## NextScripts App.net Connection Class
3
- $nxs_snapAvNts[] = array('code'=>'FL', 'lcode'=>'fl', 'name'=>'Flickr');
4
-
5
- if (!class_exists("nxs_snapClassFL")) { class nxs_snapClassFL { var $ntInfo = array('code'=>'FL', 'lcode'=>'fl', 'name'=>'Flickr', 'defNName'=>'', 'tstReq' => true);
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  //#### Show Common Settings
7
- function showGenNTSettings($ntOpts){ global $nxs_plurl, $nxs_snapSetPgURL, $nxs_gOptions; $ntInfo = $this->ntInfo;
8
- if ( isset($_GET['auth']) && $_GET['auth']==$ntInfo['lcode']){ require_once('apis/scOAuth.php'); $options = $ntOpts[$_GET['acc']];
 
 
 
 
 
9
  $consumer_key = $options['appKey']; $consumer_secret = $options['appSec'];
10
  $callback_url = $nxs_snapSetPgURL."&auth=".$ntInfo['lcode']."a&acc=".$_GET['acc'];
11
  $tum_oauth = new wpScoopITOAuth($consumer_key, $consumer_secret);
12
  $tum_oauth->baseURL = 'https://www.flickr.com/services'; $tum_oauth->request_token_path = '/oauth/request_token'; $tum_oauth->access_token_path = '/oauth/access_token';
13
  $request_token = $tum_oauth->getReqToken($callback_url); $options['oAuthToken'] = $request_token['oauth_token']; $options['oAuthTokenSecret'] = $request_token['oauth_token_secret'];
14
  switch ($tum_oauth->http_code) { case 200: $url = 'https://www.flickr.com/services/oauth/authorize?oauth_token='.$options['oAuthToken'];
15
- if (function_exists('get_option')) $nxs_gOptions = get_option('NS_SNAutoPoster'); if(!empty($nxs_gOptions)) { $nxs_gOptions[$ntInfo['lcode']][$_GET['acc']] = $options; nxs_settings_save($nxs_gOptions);}
16
  echo '<br/><br/>All good?! Redirecting ..... <script type="text/javascript">window.location = "'.$url.'"</script>'; break;
17
  default: echo '<br/><b style="color:red">Could not connect to Flickr. Refresh the page or try again later.</b>'; die();
18
  } die();
19
  }
20
- if ( isset($_GET['auth']) && $_GET['auth']==$ntInfo['lcode'].'a'){ require_once('apis/scOAuth.php'); $options = $ntOpts[$_GET['acc']];
21
  $consumer_key = $options['appKey']; $consumer_secret = $options['appSec'];
22
 
23
  $tum_oauth = new wpScoopITOAuth($consumer_key, $consumer_secret, $options['oAuthToken'], $options['oAuthTokenSecret']); //prr($tum_oauth);
24
  $tum_oauth->baseURL = 'https://www.flickr.com/services'; $tum_oauth->request_token_path = '/oauth/request_token'; $tum_oauth->access_token_path = '/oauth/access_token';
25
  $access_token = $tum_oauth->getAccToken($_GET['oauth_verifier']); prr($access_token);
26
  $options['accessToken'] = $access_token['oauth_token']; $options['accessTokenSec'] = $access_token['oauth_token_secret'];
27
- if (function_exists('get_option')) $nxs_gOptions = get_option('NS_SNAutoPoster'); if(!empty($nxs_gOptions)) { $nxs_gOptions[$ntInfo['lcode']][$_GET['acc']] = $options; nxs_settings_save($nxs_gOptions); }
28
  $tum_oauth = new wpScoopITOAuth($consumer_key, $consumer_secret, $options['accessToken'], $options['accessTokenSec']);
29
  echo "OK. Let's Get Profile: "; prr($access_token);
30
  $params = array ('format' => 'php_serial', 'method'=>'flickr.urls.getUserProfile');
31
  $uinfo = $tum_oauth->makeReq('https://api.flickr.com/services/rest/',$params); // prr($uinfo);die();
32
  if (is_array($uinfo) && isset($uinfo['user'])) { $options['appAppUserName'] = $access_token['username']."(".urldecode($access_token['fullname']).")";
33
  $options['appAppUserID'] = urldecode($uinfo['user']['nsid']); $options['userURL'] = urldecode($uinfo['user']['url']);
34
- if (function_exists('get_option')) $nxs_gOptions = get_option('NS_SNAutoPoster'); if(!empty($nxs_gOptions)) { $nxs_gOptions[$ntInfo['lcode']][$_GET['acc']] = $options; nxs_settings_save($nxs_gOptions); }
35
  } //die();
36
  if (!empty($options['appAppUserID'])) {
37
  $gGet = $_GET; unset($gGet['auth']); unset($gGet['acc']); unset($gGet['oauth_token']); unset($gGet['oauth_verifier']); unset($gGet['post_type']);
38
  $sturl = explode('?',$nxs_snapSetPgURL); $nxs_snapSetPgURL = $sturl[0].((!empty($gGet))?'?'.http_build_query($gGet):'');
39
  echo '<br/><br/>All good?! Redirecting ..... <script type="text/javascript">window.location = "'.$nxs_snapSetPgURL.'"</script>'; die();
40
  } else die("<span style='color:red;'>ERROR: Authorization Error: <span style='color:darkred; font-weight: bold;'>".print_r($uinfo, true)."</span></span>");
41
- }
42
-
43
- ?>
44
- <div class="nxs_box">
45
- <div class="nxs_box_header">
46
- <div class="nsx_iconedTitle" style="margin-bottom:1px;background-image:url(<?php echo $nxs_plurl;?>img/<?php echo $ntInfo['lcode']; ?>16.png);"><?php echo $ntInfo['name']; ?>
47
- <?php $cbo = count($ntOpts); ?>
48
- <?php if ($cbo>1){ ?><div class="nsBigText"><?php echo "(".($cbo=='0'?'No':$cbo)." "; _e('accounts', 'social-networks-auto-poster-facebook-twitter-g'); echo ")"; ?></div><?php } ?>
49
- </div>
50
- </div>
51
- <div class="nxs_box_inside">
52
- <?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $ntInfo['name'];
53
- if (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='') $pbo[$ntInfo['lcode'].'OK'] = (isset($pbo['appAppUserID']) && $pbo['appAppUserID']>1)?'1':'';
54
- ?>
55
- <p style="margin:0px;margin-left:5px;"> <img id="<?php echo $ntInfo['code'].$indx;?>LoadingImg" style="display: none;" src='<?php echo $nxs_plurl; ?>img/ajax-loader-sm.gif' />
56
-
57
- <?php if ((int)$pbo['do'.$ntInfo['code']] == 1 && isset($pbo['catSel']) && (int)$pbo['catSel'] == 1) { ?> <input type="radio" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" id="rbtn<?php echo $ntInfo['lcode'].$indx; ?>" value="1" checked="checked" onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);" /> <?php } else { ?>
58
- <input value="0" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" type="hidden" />
59
- <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1 && $pbo['catSel']!='1') echo "checked"; ?> />
60
- <?php } ?>
61
- <?php if (isset($pbo['catSel']) && (int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
62
- <?php if (isset($pbo['rpstOn']) && (int)$pbo['rpstOn'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popReActive');" onmouseover="nxs_showPopUpInfo('popReActive', event);"><?php echo "*[R]*" ?></span><?php } ?>
63
- <strong><?php _e('Auto-publish to', 'social-networks-auto-poster-facebook-twitter-g'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
64
- &nbsp;&nbsp;<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'social-networks-auto-poster-facebook-twitter-g'); ?> ==&gt;</b><?php } ?>
65
- <a id="do<?php echo $ntInfo['code'].$indx; ?>AG" href="#" onclick="doGetHideNTBlock('<?php echo $ntInfo['code'];?>' , '<?php echo $indx; ?>');return false;">[<?php _e('Show Settings', 'social-networks-auto-poster-facebook-twitter-g'); ?>]</a>&nbsp;&nbsp;
66
- <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'social-networks-auto-poster-facebook-twitter-g'); ?>]</a>
67
- </p><div id="nxsNTSetDiv<?php echo $ntInfo['code'].$indx; ?>"></div><?php //$pbo['ntInfo'] = $ntInfo; $this->showNTSettings($indx, $pbo);
68
- }?>
69
- </div>
70
- </div> <?php
71
- }
72
- //#### Show NEW Settings Page
73
- function showNewNTSettings($options){ $opts = array('nName'=>'', 'doFL'=>'1', 'appKey'=>'', 'appSec'=>'', 'setID'=>'', 'inclTags'=>'1', 'defImg'=>''); $opts['ntInfo']= $this->ntInfo; $this->showNTSettings($options, $opts, true);}
74
- //#### Show Unit Settings
75
- function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl, $nxs_snapSetPgURL; $ntInfo = $this->ntInfo; $nt = $ntInfo['lcode']; $ntU = $ntInfo['code'];
76
- 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'] = '';
77
- if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; if (!isset($options['setID'])) $options['setID'] = '';
78
- if (!isset($options['appKey'])) $options['appKey'] = ''; if (!isset($options['appSec'])) $options['appSec'] = ''; ?>
79
- <div id="do<?php echo $ntU; ?><?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>">
80
- <input type="hidden" value="0" id="apDoS<?php echo $ntU.$ii; ?>" />
81
- <div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/<?php echo $nt; ?>16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/instructions/flickr-social-networks-auto-poster-setup-installation/"><?php $nType=$ntInfo['name']; printf( __( 'Detailed %s Installation/Configuration Instructions', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?></a></div>
82
-
83
- <div style="width:100%;"><strong><?php _e('Account Nickname', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'social-networks-auto-poster-facebook-twitter-g'); ?></i> </div><input name="<?php echo $nt; ?>[<?php echo $ii; ?>][nName]" id="apnName<?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")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /><br/>
84
- <?php echo nxs_addQTranslSel($nt, $ii, $options['qTLng']); ?>
85
- <br/>
86
- <ul class="nsx_tabs">
87
- <li><a href="#nsx<?php echo $nt.$ii ?>_tab1"><?php _e('Account Info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li>
88
- <?php if (!$isNew) { ?> <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li> <?php } ?>
89
- </ul>
90
- <div class="nsx_tab_container"><?php /* ######################## Account Tab ####################### */ ?>
91
- <div id="nsx<?php echo $nt.$ii ?>_tab1" class="nsx_tab_content" style="background-image: url(<?php echo $nxs_plurl; ?>img/<?php echo $nt; ?>-bg.png); background-repeat: no-repeat; background-position:90% 10%;">
92
-
93
- <div style="width:100%;"><strong><?php echo $nType; ?> Consumer Key:</strong> </div><input name="<?php echo $nt; ?>[<?php echo $ii; ?>][appKey]" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['appKey'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />
94
- <div style="width:100%;"><strong><?php echo $nType; ?> Consumer Secret:</strong> </div><input name="<?php echo $nt; ?>[<?php echo $ii; ?>][appSec]" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['appSec'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /> <br/>
95
- <div style="width:100%;"><strong><?php echo $nType; ?> Set ID (Optional):</strong> </div><input name="<?php echo $nt; ?>[<?php echo $ii; ?>][setID]" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['setID'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /> <br/>
96
- <br/>
97
-
98
- <div style="width:100%;"><strong id="altFormatText"><?php _e('Post Title Format', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> (<a href="#" id="msgFrmtT<?php echo $ntU.$ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('msgFrmtT<?php echo $ntU.$ii; ?>'); return false;"><?php _e('Show format info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>)</div>
99
- <input name="<?php echo $nt; ?>[<?php echo $ii; ?>][msgTFrmt]" style="width: 50%;" value="<?php if (!empty($options['msgTFrmt'])) _e(apply_filters('format_to_edit', htmlentities($options['msgTFrmt'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g'); else echo "%TITLE%"; ?>" onfocus="mxs_showFrmtInfo('msgFrmtT<?php echo $ntU.$ii; ?>');" /><?php nxs_doShowHint("msgFrmtT".$ntU.$ii); ?><br/>
100
-
101
- <div id="altFormat" style="margin-left: 0px;">
102
- <div style="width:100%;"><strong id="altFormatText"><?php _e('Text Format', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> (<a href="#" id="msgFrmt<?php echo $ntU; ?><?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('msgFrmt<?php echo $ntU; ?><?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>)
103
- </div>
104
-
105
- <textarea cols="150" rows="3" id="<?php echo $nt; ?><?php echo $ii; ?>msgFrmt" name="<?php echo $nt; ?>[<?php echo $ii; ?>][msgFrmt]" style="width:51%;max-width: 650px;" onfocus="jQuery('#<?php echo $nt; ?><?php echo $ii; ?>msgFrmt').attr('rows', 6); mxs_showFrmtInfo('msgFrmt<?php echo $ntU.$ii; ?>');"><?php if ($isNew) _e("%EXCERPT% \r\n\r\n%URL%", 'social-networks-auto-poster-facebook-twitter-g'); else _e(apply_filters('format_to_edit', htmlentities($options['msgFrmt'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g'); ?></textarea><?php nxs_doShowHint("msgFrmt".$ntU.$ii); ?>
106
- </div>
107
-
108
- <p style="margin-bottom: 20px;margin-top: 5px;"><input value="1" type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][inclTags]" <?php if ((int)$options['inclTags'] == 1) echo "checked"; ?> />
109
- <strong><?php _e('Post with tags', 'social-networks-auto-poster-facebook-twitter-g'); ?></strong> <?php _e('Tags from the blogpost will be auto-posted to '.$ntInfo['name'], 'social-networks-auto-poster-facebook-twitter-g'); ?>
110
- </p>
111
-
112
- <div style="width:100%;"><strong>Default Image to use:</strong>
113
- <p style="font-size: 11px; margin: 0px;">If your post does not have any images this will be used instead.</p>
114
- </div><input name="<?php echo $nt; ?>[<?php echo $ii; ?>][defImg]" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['defImg'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />
115
- <br/><br/>
116
-
117
-
118
- <?php if($options['appKey']=='') { ?>
119
  <b><?php _e('Authorize Your '.$ntInfo['name'].' Account', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> <?php _e('Please click "Update Settings" to be able to Authorize your account.', 'social-networks-auto-poster-facebook-twitter-g'); ?>
120
  <?php } else { if(isset($options['appAppUserID']) && $options['appAppUserID']>0) { ?>
121
  <?php _e('Your '.$ntInfo['name'].' Account has been authorized.', 'social-networks-auto-poster-facebook-twitter-g'); ?> User ID: <?php _e(apply_filters('format_to_edit', htmlentities($options['appAppUserID'].' - '.$options['appAppUserName'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>.
@@ -124,181 +78,53 @@ if (!class_exists("nxs_snapClassFL")) { class nxs_snapClassFL { var $ntInfo = ar
124
 
125
  <?php if (!isset($options['appAppUserID']) || $options['appAppUserID']<1) { ?> <div class="blnkg">&lt;=== <?php _e('Authorize your account', 'social-networks-auto-poster-facebook-twitter-g'); ?> ===</div> <?php }?>
126
  <?php } ?>
127
- <br/><br/>
128
-
129
- <?php if ($isNew) { ?> <input type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][apDo<?php echo $ntU; ?>]" value="1" id="apDoNew<?php echo $ntU; ?><?php echo $ii; ?>" /> <?php } ?>
130
- <?php if (isset($options['appAppUserID']) && $options['appAppUserID']>0) { ?>
131
-
132
- <b><?php _e('Test your settings', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('<?php echo $ntU; ?>', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?></a> <?php }
133
- ?>
134
-
135
- </div>
136
- <?php /* ######################## Tools Tab ####################### */ ?>
137
- <?php if (!$isNew) { ?><div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content">
138
- <?php nxs_showCatTagsCTFilters($nt, $ii, $options);
139
- nxs_addPostingDelaySelV3($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']);
140
- nxs_showRepostSettings($nt, $ii, $options); ?>
141
- </div> <?php } ?> <?php /* #### End of Tab #### */ ?>
142
- </div><br/> <?php /* #### End of Tabs #### */ ?>
143
-
144
- <div class="submitX nxclear" style="padding-bottom: 0px;"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'social-networks-auto-poster-facebook-twitter-g') ?>" /></div>
145
-
146
-
147
- </div><?php
148
  }
 
149
  //#### Set Unit Settings from POST
150
- function setNTSettings($post, $options){ $code = $this->ntInfo['code'];
151
- foreach ($post as $ii => $pval){
152
- if (isset($pval['appKey']) && $pval['appKey']!=''){ if (!isset($options[$ii])) $options[$ii] = array();
153
-
154
- if (isset($pval['apDo'.$code])) $options[$ii]['do'.$code] = $pval['apDo'.$code]; else $options[$ii]['do'.$code] = 0;
155
- if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']);
156
-
157
- if (isset($pval['appKey'])) $options[$ii]['appKey'] = trim($pval['appKey']);
158
- if (isset($pval['appSec'])) $options[$ii]['appSec'] = trim($pval['appSec']);
159
  if (isset($pval['setID'])) $options[$ii]['setID'] = trim($pval['setID']);
160
-
161
-
162
- if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']); else $options[$ii]['catSel'] = 0;
163
- if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
164
-
165
- if (isset($pval['defImg'])) $options[$ii]['defImg'] = $pval['defImg'];
166
- if (isset($pval['inclTags'])) $options[$ii]['inclTags'] = trim($pval['inclTags']); else $options[$ii]['inclTags'] = 0;
167
- if (isset($pval['msgFrmt'])) $options[$ii]['msgFrmt'] = trim($pval['msgFrmt']);
168
- if (isset($pval['msgTFrmt'])) $options[$ii]['msgTFrmt'] = trim($pval['msgTFrmt']);
169
-
170
- $options[$ii] = nxs_adjRpst($options[$ii], $pval);
171
-
172
- if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']);
173
- if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
174
- if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
175
- } elseif ( count($pval)==1 ) if (isset($pval['apDo'.$code])) $options[$ii]['do'.$code] = $pval['apDo'.$code]; else $options[$ii]['do'.$code] = 0;
176
  } return $options;
177
  }
 
178
  //#### Show Post->Edit Meta Box Settings
179
- function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID; $nt = $this->ntInfo['lcode']; $ntU = $this->ntInfo['code'];
180
- foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snap'.$ntU, true));
181
- if (is_array($pMeta) && isset($pMeta[$ii]) && is_array($pMeta[$ii])) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]); if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = '';
182
- $doIT = $ntOpt['do'.$ntU] && (is_array($pMeta) || $ntOpt['catSel']!='1'); $imgToUse = $ntOpt['imgToUse'];
183
- $isAvail = $ntOpt['appKey']!='' && $ntOpt['appSec']!=''; $msgFormat = htmlentities($ntOpt['msgFrmt'], ENT_COMPAT, "UTF-8"); $msgFormatT = htmlentities($ntOpt['msgTFrmt'], ENT_COMPAT, "UTF-8");
184
- ?>
185
- <tr><th style="text-align:left;" colspan="2">
186
- <?php if ($ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='') { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
187
- <?php if (!empty($ntOpt['tagsSelX'])) { ?> <input type="hidden" class="nxs_TG" id="nxs_TG_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $ntOpt['tagsSelX']; ?>" /> <?php } ?>
188
- <?php if ($isAvail) { ?> <input type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][do<?php echo $ntU; ?>]" value="<?php echo ($post->post_status == "publish")?$doIT:'0';?>">
189
- <input class="nxsGrpDoChb" value="1" id="do<?php echo $ntU.$ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][do<?php echo $ntU; ?>]" <?php if ((int)$doIT == 1) echo 'checked="checked" title="def"'; ?> />
190
- <?php } ?>
191
-
192
- <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/<?php echo $nt; ?>16.png);"><?php echo $this->ntInfo['name']; ?> - <?php _e('publish to', 'social-networks-auto-poster-facebook-twitter-g') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
193
- if ($post->post_status == "publish" && $isAvail) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostTo<?php echo $ntU; ?>_repostButton" id="rePostTo<?php echo $ntU; ?>_button" value="<?php _e('Repost to '.$this->ntInfo['name'], 'social-networks-auto-poster-facebook-twitter-g') ?>" />
194
- <?php } ?>
195
-
196
- <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
197
-
198
- ?> <span id="pstd<?php echo $ntU; ?><?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
199
- <a style="font-size: 10px;" href="<?php echo $pMeta[$ii]['postURL']; ?>" target="_blank"><?php $nType=$this->ntInfo['name']; printf( __( 'Posted on', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
200
- </span><?php } ?>
201
-
202
- </td></tr>
203
-
204
- <?php if (!$isAvail) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your <?php echo $this->ntInfo['name']; ?> Account to AutoPost to <?php echo $this->ntInfo['name']; ?></b></td></tr>
205
- <?php } else { if ($post->post_status != "publish" && function_exists('nxs_doSMAS5') ) { $ntOpt['postTime'] = get_post_time('U', false, $post_id); nxs_doSMAS5($nt, $ii, $ntOpt); } ?>
206
-
207
- <?php if ($ntOpt['rpstOn']=='1') { ?>
208
-
209
- <tr id="altFormat1" style=""><th scope="row" class="nxsTHRow">
210
- <input value="0" type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]"/><input value="nxsi<?php echo $ii; ?>ap" type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]" <?php if (!empty($ntOpt['rpstPostIncl'])) echo "checked"; ?> />
211
- </th>
212
- <td> <?php _e('Include in "Auto-Reposting" to this network.', 'social-networks-auto-poster-facebook-twitter-g') ?>
213
- </td></tr> <?php } ?>
214
-
215
- <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Title Format:', 'NS_SPAP') ?></th>
216
- <td><input value="<?php echo $msgFormatT; ?>" type="text" name="<?php echo $nt; ?>[<?php echo $ii; ?>][msgTFrmt]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('msgFrmtT<?php echo $nt.$ii; ?>');"/><?php nxs_doShowHint("msgFrmtT".$nt.$ii, '', '58'); ?></td></tr>
217
-
218
- <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Text Format:', 'social-networks-auto-poster-facebook-twitter-g') ?></th><td>
219
-
220
- <textarea cols="150" rows="1" id="<?php echo $nt.$ii; ?>msgFrmt" name="<?php echo $nt; ?>[<?php echo $ii; ?>][msgFrmt]" style="width:60%;max-width: 610px;" onfocus="jQuery('#<?php echo $nt.$ii; ?>msgFrmt').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('msgFrmt<?php echo $nt.$ii; ?>');"><?php echo $msgFormat ?></textarea> <?php nxs_doShowHint("msgFrmt".$nt.$ii, '', '58'); ?>
221
-
222
- </td></tr>
223
-
224
- <?php /* ## Select Image & URL ## */ nxs_showImgToUseDlg($nt, $ii, $imgToUse); ?>
225
- <?php }
226
-
227
  }
228
  }
 
229
  //#### Save Meta Tags to the Post
230
- function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
231
- if (isset($pMeta['doFL'])) $optMt['doFL'] = $pMeta['doFL'] == 1?1:0;
232
-
233
- if (isset($pMeta['msgFrmt'])) $optMt['msgFrmt'] = $pMeta['msgFrmt']; if (isset($pMeta['msgTFrmt'])) $optMt['msgTFrmt'] = $pMeta['msgTFrmt'];
234
-
235
- if (isset($pMeta['imgToUse'])) $optMt['imgToUse'] = $pMeta['imgToUse']; if (isset($pMeta['urlToUse'])) $optMt['urlToUse'] = $pMeta['urlToUse'];
236
- if (isset($pMeta['timeToRun'])) $optMt['timeToRun'] = $pMeta['timeToRun']; if (isset($pMeta['rpstPostIncl'])) $optMt['rpstPostIncl'] = $pMeta['rpstPostIncl'];
237
- if (isset($pMeta['SNAPincludeFL']) && $pMeta['SNAPincludeFL'] == '1' ) $optMt['doFL'] = 1;
238
  return $optMt;
239
  }
240
- }}
241
- if (!function_exists("nxs_rePostToFL_ajax")) {
242
- function nxs_rePostToFL_ajax() { check_ajax_referer('nxsSsPageWPN'); $postID = $_POST['id']; global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
243
- foreach ($options['fl'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj'; //if ($two['apPageID'].$two['apUName']==$_POST['nid']) {
244
- $appo = get_post_meta($postID, 'snapFL', true); $appo = maybe_unserialize($appo);// prr($appo);
245
- if (is_array($appo) && isset($appo[$ii]) && is_array($appo[$ii])){ $ntClInst = new nxs_snapClassFL(); $two = $ntClInst->adjMetaOpt($two, $appo[$ii]); }
246
- $result = nxs_doPublishToFL($postID, $two); if ($result == 200) die("Successfully sent your post to Flickr. "); else die($result);
247
  }
248
- }
249
- }
250
- if (!function_exists("nxs_doPublishToFL")) { //## Post to FL. // V3 - imgToUse - Done, class_SNAP_AP - Done, New Format - Done
251
- function nxs_doPublishToFL($postID, $options){ $ntCd = 'FL'; $ntCdL = 'fl'; $ntNm = 'Flickr'; if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
252
- $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'POSTID'=>$postID, 'ACCNAME'=>$options['nName']));
253
- if (empty($options['imgToUse'])) $options['imgToUse'] = ''; if (empty($options['imgSize'])) $options['imgSize'] = '';
254
- $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
255
- $logNT = '<span style="color:#800000">Flickr</span> - '.$options['nName'];
256
- $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
257
- if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
258
- $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') {
259
- nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'); return;
260
- }
261
- }
262
- $message = array('message'=>'', 'link'=>'', 'imageURL'=>'', 'videoURL'=>'', 'announce'=>'');
263
-
264
- if ($postID=='0') { echo "Testing ... <br/><br/>"; $message['description'] = 'Test Post, Description'; $message['title'] = 'Test Post - Title'; $message['url'] = home_url(); $message['tags']='';
265
- if ($options['defImg']!='') $imgURL = $options['defImg']; else $imgURL ="http://direct.gtln.us/img/nxs/NXS-Lama.jpg"; $message['imageURL'] = $imgURL;
266
- } else { nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1')); $post = get_post($postID); if(!$post) return;
267
- $isNoImg = false; $tags = '';
268
-
269
- $options['msgFrmt'] = nsFormatMessage($options['msgFrmt'], $postID, $addParams); $options['msgTFrmt'] = nsFormatMessage($options['msgTFrmt'], $postID, $addParams);
270
-
271
- $tggs = array(); if ($options['inclTags']=='1'){ $t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = '"'.implode('" "',$tggs).'"'; }
272
-
273
- $imgURL = nxs_getPostImage($postID, 'full'); if (preg_match("/noImg.\.png/i", $imgURL)) { $imgURL = ''; $isNoImg = true; }
274
-
275
- $options = nxs_getURL($options, $postID); $urlToGo = $options['urlToUse'];
276
-
277
- $message = array('url'=>$urlToGo, 'imageURL'=>$imgURL, 'noImg'=>$isNoImg, 'tags'=>$tags);
278
-
279
- $lat = get_post_meta($postID, 'geo_latitude', true);
280
- $long = get_post_meta($postID, 'geo_longitude', true);
281
- if (!empty($lat) && !empty($long)) {
282
- $message['latitude'] = $lat;
283
- $message['longitude'] = $long;
284
- }
285
 
286
- $extInfo = ' | PostID: '.$postID." - ".(isset($post) && is_object($post)?$post->post_title:'');
287
- }
288
- //## Actual Post
289
- $ntToPost = new nxs_class_SNAP_FL(); $ret = $ntToPost->doPostToNT($options, $message); //prr($ret);
290
- //## Process Results
291
- if (!is_array($ret) || $ret['isPosted']!='1') { //## Error
292
- if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);
293
- } else { // ## All Good - log it.
294
- if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo _e('OK - Message Posted, please see your '.$logNT.' Page. ', 'social-networks-auto-poster-facebook-twitter-g'); }
295
- else { nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPosted'=>'1', 'pgID'=>$ret['postID'], 'postURL'=>$ret['postURL'], 'pDate'=>date('Y-m-d H:i:s')));
296
- $extInfo .= ' | <a href="'.$ret['postURL'].'" target="_blank">Post Link</a>'; nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo);
297
- }
298
- }
299
- //## Return Result
300
- if ($ret['isPosted']=='1') return 200; else return print_r($ret, true);
301
 
302
- }
303
- }
304
- ?>
1
  <?php
2
+ //## NextScripts Flickr Connection Class
3
+ $nxs_snapAvNts[] = array('code'=>'FL', 'lcode'=>'fl', 'name'=>'Flickr', 'type'=>'Image Sharing', 'ptype'=>'F', 'status'=>'A', 'desc'=>'Autopost images to your photostream and/or sets. Tags are supported');
4
+
5
+ if (!class_exists("nxs_snapClassFL")) { class nxs_snapClassFL extends nxs_snapClassNT {
6
+ var $ntInfo = array('code'=>'FL', 'lcode'=>'fl', 'name'=>'Flickr', 'defNName'=>'', 'tstReq' => true, 'instrURL'=>'http://www.nextscripts.com/instructions/flickr-social-networks-auto-poster-setup-installation/');
7
+ //#### Update
8
+ function toLatestVer($ntOpts){ if( !empty($ntOpts['v'])) $v = $ntOpts['v']; else $v = 340; $ntOptsOut = ''; switch ($v) {
9
+ case 340: $ntOptsOut = $this->toLatestVerNTGen($ntOpts); $ntOptsOut['do'] = $ntOpts['do'.$this->ntInfo['code']]; $ntOptsOut['nName'] = $ntOpts['nName'];
10
+ $ntOptsOut['msgTFormat'] = $ntOpts['msgTFrmt']; $ntOptsOut['msgFormat'] = $ntOpts['msgFrmt']; $ntOptsOut['appKey'] = $ntOpts['appKey']; $ntOptsOut['appSec'] = $ntOpts['appSec'];
11
+ $ntOptsOut['accessToken'] = $ntOpts['accessToken']; $ntOptsOut['accessTokenSec'] = $ntOpts['accessTokenSec'];
12
+ $ntOptsOut['appAppUserID'] = $ntOpts['appAppUserID']; $ntOptsOut['appAppUserName'] = $ntOpts['appAppUserName'];
13
+ $ntOptsOut['userURL'] = $ntOpts['userURL']; $ntOptsOut['setID'] = $ntOpts['setID']; $ntOptsOut['inclTags'] = $ntOpts['inclTags']; $ntOptsOut['defImg'] = $ntOpts['defImg'];
14
+ $ntOptsOut['isUpdd'] = '1'; $ntOptsOut['v'] = NXS_SETV;
15
+ break;
16
+ }
17
+ return !empty($ntOptsOut)?$ntOptsOut:$ntOpts;
18
+ }
19
  //#### Show Common Settings
20
+ function showGenNTSettings($ntOpts){ $this->nt = $ntOpts; $this->showNTGroup(); }
21
+ //#### Show NEW Settings Page
22
+ function showNewNTSettings($ii){ $defO = array('nName'=>'', 'do'=>'1', 'appKey'=>'', 'appSec'=>'', 'inclTags'=>1, 'msgFormat'=>"%EXCERPT% \r\n\r\n%URL%", 'msgTFormat'=>"%TITLE%", 'imgSize'=>'original', 'setID'=>'', 'userURL'=>''); $this->showGNewNTSettings($ii, $defO); }
23
+ //#### Show Unit Settings
24
+ function checkIfSetupFinished($options) { return !empty($options['appAppUserID']) && !empty($options['accessToken']); }
25
+ public function doAuth() { $ntInfo = $this->ntInfo; global $nxs_snapSetPgURL;
26
+ if ( isset($_GET['auth']) && $_GET['auth']==$ntInfo['lcode']){ require_once('apis/scOAuth.php'); $options = $this->nt[$_GET['acc']];
27
  $consumer_key = $options['appKey']; $consumer_secret = $options['appSec'];
28
  $callback_url = $nxs_snapSetPgURL."&auth=".$ntInfo['lcode']."a&acc=".$_GET['acc'];
29
  $tum_oauth = new wpScoopITOAuth($consumer_key, $consumer_secret);
30
  $tum_oauth->baseURL = 'https://www.flickr.com/services'; $tum_oauth->request_token_path = '/oauth/request_token'; $tum_oauth->access_token_path = '/oauth/access_token';
31
  $request_token = $tum_oauth->getReqToken($callback_url); $options['oAuthToken'] = $request_token['oauth_token']; $options['oAuthTokenSecret'] = $request_token['oauth_token_secret'];
32
  switch ($tum_oauth->http_code) { case 200: $url = 'https://www.flickr.com/services/oauth/authorize?oauth_token='.$options['oAuthToken'];
33
+ nxs_save_glbNtwrks($ntInfo['lcode'],$_GET['acc'],$options,'*');
34
  echo '<br/><br/>All good?! Redirecting ..... <script type="text/javascript">window.location = "'.$url.'"</script>'; break;
35
  default: echo '<br/><b style="color:red">Could not connect to Flickr. Refresh the page or try again later.</b>'; die();
36
  } die();
37
  }
38
+ if ( isset($_GET['auth']) && $_GET['auth']==$ntInfo['lcode'].'a'){ require_once('apis/scOAuth.php'); $options = $this->nt[$_GET['acc']];
39
  $consumer_key = $options['appKey']; $consumer_secret = $options['appSec'];
40
 
41
  $tum_oauth = new wpScoopITOAuth($consumer_key, $consumer_secret, $options['oAuthToken'], $options['oAuthTokenSecret']); //prr($tum_oauth);
42
  $tum_oauth->baseURL = 'https://www.flickr.com/services'; $tum_oauth->request_token_path = '/oauth/request_token'; $tum_oauth->access_token_path = '/oauth/access_token';
43
  $access_token = $tum_oauth->getAccToken($_GET['oauth_verifier']); prr($access_token);
44
  $options['accessToken'] = $access_token['oauth_token']; $options['accessTokenSec'] = $access_token['oauth_token_secret'];
45
+ nxs_save_glbNtwrks($ntInfo['lcode'],$_GET['acc'],$options,'*');
46
  $tum_oauth = new wpScoopITOAuth($consumer_key, $consumer_secret, $options['accessToken'], $options['accessTokenSec']);
47
  echo "OK. Let's Get Profile: "; prr($access_token);
48
  $params = array ('format' => 'php_serial', 'method'=>'flickr.urls.getUserProfile');
49
  $uinfo = $tum_oauth->makeReq('https://api.flickr.com/services/rest/',$params); // prr($uinfo);die();
50
  if (is_array($uinfo) && isset($uinfo['user'])) { $options['appAppUserName'] = $access_token['username']."(".urldecode($access_token['fullname']).")";
51
  $options['appAppUserID'] = urldecode($uinfo['user']['nsid']); $options['userURL'] = urldecode($uinfo['user']['url']);
52
+ nxs_save_glbNtwrks($ntInfo['lcode'],$_GET['acc'],$options,'*');
53
  } //die();
54
  if (!empty($options['appAppUserID'])) {
55
  $gGet = $_GET; unset($gGet['auth']); unset($gGet['acc']); unset($gGet['oauth_token']); unset($gGet['oauth_verifier']); unset($gGet['post_type']);
56
  $sturl = explode('?',$nxs_snapSetPgURL); $nxs_snapSetPgURL = $sturl[0].((!empty($gGet))?'?'.http_build_query($gGet):'');
57
  echo '<br/><br/>All good?! Redirecting ..... <script type="text/javascript">window.location = "'.$nxs_snapSetPgURL.'"</script>'; die();
58
  } else die("<span style='color:red;'>ERROR: Authorization Error: <span style='color:darkred; font-weight: bold;'>".print_r($uinfo, true)."</span></span>");
59
+ }
60
+ }
61
+
62
+ function accTab($ii, $options, $isNew=false){ global $nxs_snapSetPgURL; $ntInfo = $this->ntInfo; $nt = $ntInfo['lcode']; $this->elemKeySecret($ii,'Consumer Key','Consumer Secret', $options['appKey'], $options['appSec'],'appKey','appSec','https://www.flickr.com/services/apps/'); ?>
63
+ <div style="width:100%;"><strong><?php _e('Flickr Set ID', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong><i><?php _e('(Optional)', 'social-networks-auto-poster-facebook-twitter-g'); ?></i></div><input name="<?php echo $nt; ?>[<?php echo $ii; ?>][setID]" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['setID'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /><br/><br/>
64
+
65
+ <?php $this->elemTitleFormat($ii,'Post Title Format','msgTFormat',$options['msgTFormat']); $this->elemMsgFormat($ii,'Post Format','msgFormat',$options['msgFormat']); ?>
66
+ <div style="margin: 0px;"><input value="1" type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][inclTags]" <?php if ((int)$options['inclTags'] == 1) echo "checked"; ?> /> <strong><?php _e('Post with tags', 'social-networks-auto-poster-facebook-twitter-g'); ?></strong></div>
67
+
68
+ <div style="width:100%;"><strong><?php _e('Default Image to use', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong><i><?php _e('If your post does not have any images this will be used instead.', 'social-networks-auto-poster-facebook-twitter-g'); ?></i></div><input name="<?php echo $nt; ?>[<?php echo $ii; ?>][defImg]" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['defImg'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /><br/><br/>
69
+
70
+
71
+ <br/><br/>
72
+ <?php if($options['appKey']=='') { ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  <b><?php _e('Authorize Your '.$ntInfo['name'].' Account', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> <?php _e('Please click "Update Settings" to be able to Authorize your account.', 'social-networks-auto-poster-facebook-twitter-g'); ?>
74
  <?php } else { if(isset($options['appAppUserID']) && $options['appAppUserID']>0) { ?>
75
  <?php _e('Your '.$ntInfo['name'].' Account has been authorized.', 'social-networks-auto-poster-facebook-twitter-g'); ?> User ID: <?php _e(apply_filters('format_to_edit', htmlentities($options['appAppUserID'].' - '.$options['appAppUserName'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>.
78
 
79
  <?php if (!isset($options['appAppUserID']) || $options['appAppUserID']<1) { ?> <div class="blnkg">&lt;=== <?php _e('Authorize your account', 'social-networks-auto-poster-facebook-twitter-g'); ?> ===</div> <?php }?>
80
  <?php } ?>
81
+ <br/><br/><?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  }
83
+ function advTab($ii, $options){}
84
  //#### Set Unit Settings from POST
85
+ function setNTSettings($post, $options){
86
+ foreach ($post as $ii => $pval){
87
+ if (!empty($pval['appKey']) && !empty($pval['appKey'])){ if (!isset($options[$ii])) $options[$ii] = array(); $options[$ii] = $this->saveCommonNTSettings($pval,$options[$ii]);
88
+ //## Uniqe Items
 
 
 
 
 
89
  if (isset($pval['setID'])) $options[$ii]['setID'] = trim($pval['setID']);
90
+ if (isset($pval['defImg'])) $options[$ii]['defImg'] = trim($pval['defImg']);
91
+ } elseif ( count($pval)==1 ) if (isset($pval['do'])) $options[$ii]['do'] = $pval['do']; else $options[$ii]['do'] = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  } return $options;
93
  }
94
+
95
  //#### Show Post->Edit Meta Box Settings
96
+
97
+ function showEdPostNTSettings($ntOpts, $post){ $post_id = $post->ID; $nt = $this->ntInfo['lcode']; $ntU = $this->ntInfo['code'];
98
+ foreach($ntOpts as $ii=>$ntOpt) { $isFin = $this->checkIfSetupFinished($ntOpt); if (!$isFin) continue;
99
+ $pMeta = maybe_unserialize(get_post_meta($post_id, 'snap'.$ntU, true)); if (is_array($pMeta) && !empty($pMeta[$ii])) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
100
+
101
+ if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = ''; if (empty($ntOpt['urlToUse'])) $ntOpt['urlToUse'] = ''; $postType = isset($ntOpt['postType'])?$ntOpt['postType']:'';
102
+ $msgFormat = !empty($ntOpt['msgFormat'])?htmlentities($ntOpt['msgFormat'], ENT_COMPAT, "UTF-8"):''; $msgTFormat = !empty($ntOpt['msgTFormat'])?htmlentities($ntOpt['msgTFormat'], ENT_COMPAT, "UTF-8"):'';
103
+ $imgToUse = $ntOpt['imgToUse']; $urlToUse = $ntOpt['urlToUse']; $ntOpt['ii']=$ii; $this->nxs_tmpltAddPostMeta($post, $ntOpt, $pMeta);
104
+ $this->elemEdTitleFormat($ii, __('Title Format:', 'social-networks-auto-poster-facebook-twitter-g'),$msgTFormat);
105
+ $this->elemEdMsgFormat($ii, __('Message Format:', 'social-networks-auto-poster-facebook-twitter-g'),$msgFormat);
106
+ nxs_showImgToUseDlg($nt, $ii, $imgToUse);
107
+ /* ## Select Image & URL ## */ nxs_showURLToUseDlg($nt, $ii, $urlToUse); $this->nxs_tmpltAddPostMetaEnd($ii);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  }
109
  }
110
+
111
  //#### Save Meta Tags to the Post
112
+ function adjMetaOpt($optMt, $pMeta){ $optMt = $this->adjMetaOptG($optMt, $pMeta);
113
+ if (!empty($pMeta['attchImg'])) $optMt['attchImg'] = $pMeta['attchImg']; else $optMt['attchImg'] = 0;
 
 
 
 
 
 
114
  return $optMt;
115
  }
116
+
117
+ function adjPublishWP(&$options, &$message, $postID){
118
+ if (!empty($postID)) { if (trim($options['imgToUse'])!='') $imgURL = $options['imgToUse']; else $imgURL = nxs_getPostImage($postID, !empty($options['wpImgSize'])?$options['wpImgSize']:'full');
119
+ if (preg_match("/noImg.\.png/i", $imgURL)) { $imgURL = ''; $isNoImg = true; }
120
+ $message['imageURL'] = $imgURL;
 
 
121
  }
122
+ }
123
+
124
+ }}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
 
126
+ if (!function_exists("nxs_doPublishToFL")) { function nxs_doPublishToFL($postID, $options){
127
+ if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true)); $cl = new nxs_snapClassFL(); $cl->nt[$options['ii']] = $options; return $cl->publishWP($options['ii'], $postID);
128
+ }}
 
 
 
 
 
 
 
 
 
 
 
 
129
 
130
+ ?>
 
 
inc-cl/fp.api.php CHANGED
@@ -39,7 +39,7 @@ if (!class_exists("nxs_class_SNAP_FP")) { class nxs_class_SNAP_FP {
39
 
40
  function createFile($imgURL) {
41
  $remImgURL = urldecode($imgURL); $urlParced = pathinfo($remImgURL); $remImgURLFilename = $urlParced['basename'];
42
- $imgData = wp_remote_get($remImgURL); if (is_wp_error($imgData)) { $badOut['Error'] = print_r($imgData, true)." - ERROR"; return $badOut; }
43
  $imgData = $imgData['body'];
44
  $tmp=array_search('uri', @array_flip(stream_get_meta_data($GLOBALS[mt_rand()]=tmpfile())));
45
  if (!is_writable($tmp)) return "Your temporary folder or file (file - ".$tmp.") is not witable. Can't upload images to Flickr";
@@ -56,21 +56,26 @@ if (!class_exists("nxs_class_SNAP_FP")) { class nxs_class_SNAP_FP {
56
  return $out;
57
  }
58
 
59
- function doPostToNT($options, $message){ global $nxs_urlLen; $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>'');
 
60
  //## Check settings
61
  if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
62
  if (!isset($options['uPass']) || trim($options['uPass'])=='') { $badOut['Error'] = 'Not Authorized'; return $badOut; }
63
  if (empty($options['imgSize'])) $options['imgSize'] = '';
 
 
64
  //## Format Post
65
- if (!empty($message['pText'])) $text = $message['pText']; else $text = nxs_doFormatMsg($options['msgFrmt'], $message);
66
  //## Make Post
67
- if (isset($message['imageURL'])) $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); else $imgURL = '';
68
  //## Make Post
69
- if (!empty($options['ck'])){$ck = maybe_unserialize($options['ck']); $loginError = doCheckFlipboard($ck);}
70
- if (empty($ck) || $loginError!==false) { $pass = substr($options['uPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['uPass'], 5)):$options['uPass'];
71
- $loginInfo = doConnectToFlipboard($options['uName'], $pass); if (!is_array($loginInfo)) { $badOut['Error'] = print_r($loginInfo, true)." - ERROR"; return $badOut; } $ck = $loginInfo['ck'];
72
- } $post = array('url'=>$message['url'], 'mgzURL'=>$options['mgzURL'], 'imgURL'=>$imgURL, 'text'=>$text );
73
- return doPostToFlipboard($ck, $post);
 
 
74
  }
75
  }}
76
  ?>
39
 
40
  function createFile($imgURL) {
41
  $remImgURL = urldecode($imgURL); $urlParced = pathinfo($remImgURL); $remImgURLFilename = $urlParced['basename'];
42
+ $imgData = nxs_remote_get($remImgURL); if (is_nxs_error($imgData)) { $badOut['Error'] = print_r($imgData, true)." - ERROR"; return $badOut; }
43
  $imgData = $imgData['body'];
44
  $tmp=array_search('uri', @array_flip(stream_get_meta_data($GLOBALS[mt_rand()]=tmpfile())));
45
  if (!is_writable($tmp)) return "Your temporary folder or file (file - ".$tmp.") is not witable. Can't upload images to Flickr";
56
  return $out;
57
  }
58
 
59
+ function doPostToNT($options, $message){ global $nxs_urlLen; $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>'');
60
+ if (!class_exists("nxsAPI_FP")){ $badOut['Error'] .= "Flipboard API Library not found"; return $badOut; }
61
  //## Check settings
62
  if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
63
  if (!isset($options['uPass']) || trim($options['uPass'])=='') { $badOut['Error'] = 'Not Authorized'; return $badOut; }
64
  if (empty($options['imgSize'])) $options['imgSize'] = '';
65
+ //## Get Saved Login Info
66
+ if (function_exists('nxs_getOption')) { $opVal = array(); $opNm = 'nxs_snap_fp_'.sha1('nxs_snap_fp'.$options['uName'].$options['uPass']); $opVal = nxs_getOption($opNm); if (!empty($opVal) & is_array($opVal)) $options = array_merge($options, $opVal); }
67
  //## Format Post
68
+ if (!empty($message['pText'])) $text = $message['pText']; else $text = nxs_doFormatMsg($options['msgFormat'], $message);
69
  //## Make Post
70
+ if (isset($message['imageURL'])) $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); else $imgURL = '';
71
  //## Make Post
72
+ $pass = (substr($options['uPass'], 0, 5)=='n5g9a'||substr($options['uPass'], 0, 5)=='g9c1a'||substr($options['uPass'], 0, 5)=='b4d7s')?nsx_doDecode(substr($options['uPass'], 5)):$options['uPass'];
73
+ $nt = new nxsAPI_FP(); $nt->debug = false; if (!empty($ck)) $nt->ck = $ck; if (!empty($options['proxy'])&&!empty($options['proxyOn'])){ $nt->proxy['proxy'] = $options['proxy']['proxy']; if (!empty($options['proxy']['up'])) $nt->proxy['up'] = $options['proxy']['up'];};
74
+ $loginErr = $nt->connect($options['uName'], $pass); if ($loginErr) { $badOut['Error'] .= 'Can\'t Connect - '.print_r($loginErr, true); return $badOut; }
75
+ $post = array('url'=>$message['url'], 'mgzURL'=>$options['mgzURL'], 'imgURL'=>$imgURL, 'text'=>$text ); $ret = $nt->post($post);
76
+ //## Save Login Info
77
+ if (function_exists('nxs_saveOption')) { if (empty($opVal['ck'])) $opVal['ck'] = ''; if (is_array($ret) && $ret['isPosted']=='1' && $opVal['ck'] != $nt->ck) { $opVal['ck'] = $nt->ck; nxs_saveOption($opNm, $opVal); } }
78
+ return $ret;
79
  }
80
  }}
81
  ?>
inc-cl/fp.php CHANGED
@@ -1,245 +1,66 @@
1
  <?php
2
  //## NextScripts Flipboard Connection Class
3
- $nxs_snapAvNts[] = array('code'=>'FP', 'lcode'=>'fp', 'name'=>'Flipboard');
4
 
5
- if (!class_exists("nxs_snapClassFP")) { class nxs_snapClassFP { var $ntInfo = array('code'=>'FP', 'lcode'=>'fp', 'name'=>'Flipboard', 'defNName'=>'', 'tstReq' => false);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  //#### Show Common Settings
7
- function showGenNTSettings($ntOpts){ global $nxs_plurl, $nxs_snapSetPgURL; $ntInfo = $this->ntInfo;
8
- ?>
9
- <div class="nxs_box">
10
- <div class="nxs_box_header">
11
- <div class="nsx_iconedTitle" style="margin-bottom:1px;background-image:url(<?php echo $nxs_plurl;?>img/<?php echo $ntInfo['lcode']; ?>16.png);"><?php echo $ntInfo['name']; ?>
12
- <?php $cbo = count($ntOpts); ?>
13
- <?php if ($cbo>1){ ?><div class="nsBigText"><?php echo "(".($cbo=='0'?'No':$cbo)." "; _e('accounts', 'social-networks-auto-poster-facebook-twitter-g'); echo ")"; ?></div><?php } ?>
14
- </div>
15
- </div>
16
- <div class="nxs_box_inside">
17
- <?php if(!function_exists('doPostToFlipboard')) {?> Flipboard doesn't have a built-in API for automated posts yet. <br/>You need to get a special <a target="_blank" href="http://www.nextscripts.com/api/flipboard-automated-posting/">library module</a> to be able to publish your content to Flipboard.
18
- <?php } else foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $ntInfo['name'];
19
- if (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='') $pbo[$ntInfo['lcode'].'OK'] = (isset($pbo['appAppUserID']) && $pbo['appAppUserID']>1)?'1':'';
20
- ?>
21
- <p style="margin:0px;margin-left:5px;"> <img id="<?php echo $ntInfo['code'].$indx;?>LoadingImg" style="display: none;" src='<?php echo $nxs_plurl; ?>img/ajax-loader-sm.gif' />
22
-
23
-
24
- <?php if ((int)$pbo['do'.$ntInfo['code']] == 1 && isset($pbo['catSel']) && (int)$pbo['catSel'] == 1) { ?> <input type="radio" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" id="rbtn<?php echo $ntInfo['lcode'].$indx; ?>" value="1" checked="checked" onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);" /> <?php } else { ?>
25
- <input value="0" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" type="hidden" />
26
- <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1 && $pbo['catSel']!='1') echo "checked"; ?> />
27
- <?php } ?>
28
- <?php if (isset($pbo['catSel']) && (int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
29
- <?php if (isset($pbo['rpstOn']) && (int)$pbo['rpstOn'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popReActive');" onmouseover="nxs_showPopUpInfo('popReActive', event);"><?php echo "*[R]*" ?></span><?php } ?>
30
- <strong><?php _e('Auto-publish to', 'social-networks-auto-poster-facebook-twitter-g'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
31
- &nbsp;&nbsp;<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'social-networks-auto-poster-facebook-twitter-g'); ?> ==&gt;</b><?php } ?>
32
- <a id="do<?php echo $ntInfo['code'].$indx; ?>AG" href="#" onclick="doGetHideNTBlock('<?php echo $ntInfo['code'];?>' , '<?php echo $indx; ?>');return false;">[<?php _e('Show Settings', 'social-networks-auto-poster-facebook-twitter-g'); ?>]</a>&nbsp;&nbsp;
33
- <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'social-networks-auto-poster-facebook-twitter-g'); ?>]</a>
34
- </p><div id="nxsNTSetDiv<?php echo $ntInfo['code'].$indx; ?>"></div><?php //$pbo['ntInfo'] = $ntInfo; $this->showNTSettings($indx, $pbo);
35
- }?>
36
- </div>
37
- </div> <?php
38
- }
39
  //#### Show NEW Settings Page
40
- function showNewNTSettings($options){ $opts = array('nName'=>'', 'doFP'=>'1', 'uName'=>'', 'uPass'=>'', 'mgzURL'=>'', 'inclTags'=>'1', 'defImg'=>''); $opts['ntInfo']= $this->ntInfo; $this->showNTSettings($options, $opts, true);}
41
- //#### Show Unit Settings
42
- function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl, $nxs_snapSetPgURL; $ntInfo = $this->ntInfo; $nt = $ntInfo['lcode']; $ntU = $ntInfo['code'];
43
- 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'] = '';
44
- if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; if (!isset($options['mgzURL'])) $options['mgzURL'] = ''; ?>
45
- <div id="do<?php echo $ntU; ?><?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>">
46
- <input type="hidden" value="0" id="apDoS<?php echo $ntU.$ii; ?>" />
47
-
48
- <?php if(!function_exists('doPostToFlipboard')) {
49
- nxs_show_noLibWrn('Flipboard API Library module NOT found.<br/><br/><span style="color:black;">Flipboard does not have a free native API for automated posts yet.</span><br/><br/><span style="font-size: 12px;color:black;">You need to have a special API Library Module to be able to publish your content to Flipboard.</span>'); echo "</div>"; return; }; ?>
50
-
51
- <div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/<?php echo $nt; ?>16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/instructions/flipboard-social-networks-auto-poster-setup-installation/"><?php $nType=$ntInfo['name']; printf( __( 'Detailed %s Installation/Configuration Instructions', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?></a></div>
52
-
53
- <div style="width:100%;"><strong><?php _e('Account Nickname', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'social-networks-auto-poster-facebook-twitter-g'); ?></i> </div><input name="<?php echo $nt; ?>[<?php echo $ii; ?>][nName]" id="apnName<?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")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /><br/>
54
- <?php echo nxs_addQTranslSel($nt, $ii, $options['qTLng']); ?>
55
- <br/>
56
- <ul class="nsx_tabs">
57
- <li><a href="#nsx<?php echo $nt.$ii ?>_tab1"><?php _e('Account Info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li>
58
- <?php if (!$isNew) { ?> <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li> <?php } ?>
59
- </ul>
60
- <div class="nsx_tab_container"><?php /* ######################## Account Tab ####################### */ ?>
61
- <div id="nsx<?php echo $nt.$ii ?>_tab1" class="nsx_tab_content" style="background-image: url(<?php echo $nxs_plurl; ?>img/<?php echo $nt; ?>-bg.png); background-repeat: no-repeat; background-position:90% 10%;">
62
-
63
- <div style="width:100%;"><strong><?php echo $nType; ?> Login/Email:</strong> </div><input name="<?php echo $nt; ?>[<?php echo $ii; ?>][uName]" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['uName'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />
64
- <div style="width:100%;"><strong><?php echo $nType; ?> Password:</strong> </div><input autocomplete="false" readonly onfocus="this.removeAttribute('readonly');" name="<?php echo $nt; ?>[<?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")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /> <br/>
65
-
66
- <div style="width:100%;"><strong><?php echo $nType; ?> Magazine URL:</strong> </div><input name="<?php echo $nt; ?>[<?php echo $ii; ?>][mgzURL]" style="width: 60%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['mgzURL'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /> <br/>
67
- <br/>
68
-
69
- <div id="altFormat" style="margin-left: 0px;">
70
- <div style="width:100%;"><strong id="altFormatText"><?php _e('Comment Text Format', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> (<a href="#" id="msgFrmt<?php echo $ntU; ?><?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('msgFrmt<?php echo $ntU; ?><?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>)
71
- </div>
72
- <textarea cols="150" rows="3" id="<?php echo $nt; ?><?php echo $ii; ?>msgFrmt" name="<?php echo $nt; ?>[<?php echo $ii; ?>][msgFrmt]" style="width:51%;max-width: 650px;" onfocus="jQuery('#<?php echo $nt; ?><?php echo $ii; ?>msgFrmt').attr('rows', 6); mxs_showFrmtInfo('msgFrmt<?php echo $ntU.$ii; ?>');"><?php if ($isNew) _e("%EXCERPT% \r\n\r\n%URL%", 'social-networks-auto-poster-facebook-twitter-g'); else _e(apply_filters('format_to_edit', htmlentities($options['msgFrmt'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g'); ?></textarea><?php nxs_doShowHint("msgFrmt".$ntU.$ii); ?>
73
- </div>
74
- <br/>
75
-
76
- <?php if ($isNew) { ?> <input type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][apDo<?php echo $ntU; ?>]" value="1" id="apDoNew<?php echo $ntU; ?><?php echo $ii; ?>" /> <?php } ?>
77
- <?php if (!empty($options['uPass'])) { ?>
78
-
79
- <b><?php _e('Test your settings', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('<?php echo $ntU; ?>', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?></a> <?php }
80
- ?>
81
-
82
- </div>
83
- <?php /* ######################## Tools Tab ####################### */ ?>
84
- <?php if (!$isNew) { ?><div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content">
85
- <?php nxs_showCatTagsCTFilters($nt, $ii, $options);
86
- nxs_addPostingDelaySelV3($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']);
87
- nxs_showRepostSettings($nt, $ii, $options); ?>
88
- </div> <?php } ?> <?php /* #### End of Tab #### */ ?>
89
- </div><br/> <?php /* #### End of Tabs #### */ ?>
90
-
91
- <div class="submitX nxclear" style="padding-bottom: 0px;"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'social-networks-auto-poster-facebook-twitter-g') ?>" /></div>
92
-
93
-
94
- </div><?php
95
  }
 
96
  //#### Set Unit Settings from POST
97
- function setNTSettings($post, $options){ $code = $this->ntInfo['code'];
98
- foreach ($post as $ii => $pval){
99
- if (isset($pval['uName']) && $pval['uPass']!=''){ if (!isset($options[$ii])) $options[$ii] = array();
100
-
101
- if (isset($pval['apDo'.$code])) $options[$ii]['do'.$code] = $pval['apDo'.$code]; else $options[$ii]['do'.$code] = 0;
102
- if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']);
103
-
104
- if (isset($pval['uName'])) $options[$ii]['uName'] = trim($pval['uName']);
105
- if (isset($pval['uPass'])) $options[$ii]['uPass'] = 'n5g9a'.nsx_doEncode($pval['uPass']); else $options[$ii]['uPass'] = '';
106
- if (isset($pval['mgzURL'])) $options[$ii]['mgzURL'] = trim($pval['mgzURL']);
107
-
108
-
109
- if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']); else $options[$ii]['catSel'] = 0;
110
- if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
111
-
112
- if (isset($pval['msgFrmt'])) $options[$ii]['msgFrmt'] = trim($pval['msgFrmt']);
113
-
114
- $options[$ii] = nxs_adjRpst($options[$ii], $pval);
115
-
116
- if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']);
117
- if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
118
- if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
119
- } elseif ( count($pval)==1 ) if (isset($pval['apDo'.$code])) $options[$ii]['do'.$code] = $pval['apDo'.$code]; else $options[$ii]['do'.$code] = 0;
120
  } return $options;
121
- }
 
122
  //#### Show Post->Edit Meta Box Settings
123
- function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID; $nt = $this->ntInfo['lcode']; $ntU = $this->ntInfo['code'];
124
- foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snap'.$ntU, true));
125
- if (is_array($pMeta) && isset($pMeta[$ii]) && is_array($pMeta[$ii])) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]); if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = '';
126
- $doIT = $ntOpt['do'.$ntU] && (is_array($pMeta) || $ntOpt['catSel']!='1'); $imgToUse = $ntOpt['imgToUse']; if (empty($ntOpt['urlToUse'])) $ntOpt['urlToUse'] = ''; $urlToUse = $ntOpt['urlToUse'];
127
- $isAvail = $ntOpt['uPass']!='' && $ntOpt['uName']!=''; $msgFormat = htmlentities($ntOpt['msgFrmt'], ENT_COMPAT, "UTF-8");
128
- ?>
129
- <tr><th style="text-align:left;" colspan="2">
130
- <?php if ($ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='') { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
131
- <?php if (!empty($ntOpt['tagsSelX'])) { ?> <input type="hidden" class="nxs_TG" id="nxs_TG_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $ntOpt['tagsSelX']; ?>" /> <?php } ?>
132
- <?php if ($isAvail) { ?> <input type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][do<?php echo $ntU; ?>]" value="<?php echo ($post->post_status == "publish")?$doIT:'0';?>">
133
- <input class="nxsGrpDoChb" value="1" id="do<?php echo $ntU.$ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][do<?php echo $ntU; ?>]" <?php if ((int)$doIT == 1) echo 'checked="checked" title="def"'; ?> />
134
- <?php } ?>
135
-
136
- <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/<?php echo $nt; ?>16.png);"><?php echo $this->ntInfo['name']; ?> - <?php _e('publish to', 'social-networks-auto-poster-facebook-twitter-g') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
137
- if ($post->post_status == "publish" && $isAvail) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostTo<?php echo $ntU; ?>_repostButton" id="rePostTo<?php echo $ntU; ?>_button" value="<?php _e('Repost to '.$this->ntInfo['name'], 'social-networks-auto-poster-facebook-twitter-g') ?>" />
138
- <?php } ?>
139
-
140
- <?php if (is_array($pMeta) && isset($pMeta[$ii]) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
141
-
142
- ?> <span id="pstd<?php echo $ntU; ?><?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
143
- <a style="font-size: 10px;" href="<?php echo $pMeta[$ii]['postURL']; ?>" target="_blank"><?php $nType=$this->ntInfo['name']; printf( __( 'Posted on', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
144
- </span><?php } ?>
145
-
146
- </td></tr>
147
-
148
- <?php if (!$isAvail) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your <?php echo $this->ntInfo['name']; ?> Account to AutoPost to <?php echo $this->ntInfo['name']; ?></b></td></tr>
149
- <?php } else { if ($post->post_status != "publish" && function_exists('nxs_doSMAS5') ) { $ntOpt['postTime'] = get_post_time('U', false, $post_id); nxs_doSMAS5($nt, $ii, $ntOpt); } ?>
150
-
151
- <?php if ($ntOpt['rpstOn']=='1') { ?>
152
-
153
- <tr id="altFormat1" style=""><th scope="row" class="nxsTHRow">
154
- <input value="0" type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]"/><input value="nxsi<?php echo $ii; ?>ap" type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]" <?php if (!empty($ntOpt['rpstPostIncl'])) echo "checked"; ?> />
155
- </th>
156
- <td> <?php _e('Include in "Auto-Reposting" to this network.', 'social-networks-auto-poster-facebook-twitter-g') ?>
157
- </td></tr> <?php } ?>
158
-
159
- <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Comment Text Format:', 'social-networks-auto-poster-facebook-twitter-g') ?></th><td>
160
-
161
- <textarea cols="150" rows="1" id="<?php echo $nt.$ii; ?>msgFrmt" name="<?php echo $nt; ?>[<?php echo $ii; ?>][msgFrmt]" style="width:60%;max-width: 610px;" onfocus="jQuery('#<?php echo $nt.$ii; ?>msgFrmt').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('msgFrmt<?php echo $nt.$ii; ?>');"><?php echo $msgFormat ?></textarea> <?php nxs_doShowHint("msgFrmt".$nt.$ii, '', '58'); ?>
162
-
163
- </td></tr>
164
-
165
- <?php /* ## Select Image & URL ## */ nxs_showImgToUseDlg($nt, $ii, $imgToUse); nxs_showURLToUseDlg($nt, $ii, $urlToUse); ?>
166
- <?php }
167
-
168
  }
169
- }
170
  //#### Save Meta Tags to the Post
171
- function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
172
- if (isset($pMeta['doFP'])) $optMt['doFP'] = $pMeta['doFP'] == 1?1:0;
173
- if (isset($pMeta['msgFrmt'])) $optMt['msgFrmt'] = $pMeta['msgFrmt'];
174
- if (isset($pMeta['imgToUse'])) $optMt['imgToUse'] = $pMeta['imgToUse']; if (isset($pMeta['urlToUse'])) $optMt['urlToUse'] = $pMeta['urlToUse'];
175
- if (isset($pMeta['timeToRun'])) $optMt['timeToRun'] = $pMeta['timeToRun']; if (isset($pMeta['rpstPostIncl'])) $optMt['rpstPostIncl'] = $pMeta['rpstPostIncl'];
176
- if (isset($pMeta['SNAPincludeFP']) && $pMeta['SNAPincludeFP'] == '1' ) $optMt['doFP'] = 1;
177
  return $optMt;
178
- }
179
- }}
180
- if (!function_exists("nxs_rePostToFP_ajax")) {
181
- function nxs_rePostToFP_ajax() { check_ajax_referer('nxsSsPageWPN'); $postID = $_POST['id']; global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
182
- foreach ($options['fp'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj'; //if ($two['apPageID'].$two['apUName']==$_POST['nid']) {
183
- $appo = get_post_meta($postID, 'snapFP', true); $appo = maybe_unserialize($appo);// prr($appo);
184
- if (is_array($appo) && isset($appo[$ii]) && is_array($appo[$ii])){ $ntClInst = new nxs_snapClassFP(); $two = $ntClInst->adjMetaOpt($two, $appo[$ii]); }
185
- $result = nxs_doPublishToFP($postID, $two); if ($result == 200) die("Successfully sent your post to Flipboard. "); else die($result);
186
- }
187
  }
188
- }
189
- if (!function_exists("nxs_doPublishToFP")) { //## Post to FP. // V3 - imgToUse - Done, class_SNAP_AP - Done, New Format - Done
190
- function nxs_doPublishToFP($postID, $options){ global $plgn_NS_SNAutoPoster; $ntCd = 'FP'; $ntCdL = 'fp'; $ntNm = 'Flipboard'; if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
191
- $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'POSTID'=>$postID, 'ACCNAME'=>$options['nName']));
192
- if (empty($options['imgToUse'])) $options['imgToUse'] = ''; if (empty($options['imgSize'])) $options['imgSize'] = '';
193
- $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
194
- $logNT = '<span style="color:#800000">Flipboard</span> - '.$options['nName'];
195
- $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
196
- if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
197
- $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') {
198
- nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$uqID); return;
199
- }
200
- }
201
- $message = array('message'=>'', 'link'=>'', 'imageURL'=>'', 'videoURL'=>'', 'announce'=>'');
202
-
203
- if ($postID=='0') { echo "Testing ... <br/><br/>"; $message['description'] = 'Test Post, Description'; $message['title'] = 'Test Post - Title'; $message['url'] = home_url(); $message['tags']='';
204
- if ($options['defImg']!='') $imgURL = $options['defImg']; else $imgURL ="http://direct.gtln.us/img/nxs/NXS-Lama.jpg"; $message['imageURL'] = $imgURL;
205
- } else { nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1')); $post = get_post($postID); if(!$post) return;
206
- $isNoImg = false; $tags = '';
207
-
208
- $options['msgFrmt'] = nsFormatMessage($options['msgFrmt'], $postID, $addParams);
209
-
210
- $tggs = array(); if ($options['inclTags']=='1'){ $t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = '"'.implode('" "',$tggs).'"'; }
211
-
212
- if (trim($options['imgToUse'])!='') $imgURL = $options['imgToUse']; else $imgURL = nxs_getPostImage($postID, 'full'); if (preg_match("/noImg.\.png/i", $imgURL)) { $imgURL = ''; $isNoImg = true; }
213
-
214
- //## MyURL - URLToGo code
215
- if (!isset($options['urlToUse']) || trim($options['urlToUse'])=='') $myurl = trim(get_post_meta($postID, 'snap_MYURL', true)); if (!empty($myurl)) $options['urlToUse'] = $myurl;
216
- if (isset($options['urlToUse']) && trim($options['urlToUse'])!='') { $urlToGo = $options['urlToUse']; $options['useFBGURLInfo'] = true; } else $urlToGo = get_permalink($postID);
217
- $gOptions = $plgn_NS_SNAutoPoster->nxs_options; $addURLParams = trim($gOptions['addURLParams']); if($addURLParams!='') $urlToGo .= (strpos($urlToGo,'?')!==false?'&':'?').$addURLParams;
218
- $message = array('url'=>$urlToGo, 'imageURL'=>$imgURL, 'noImg'=>$isNoImg, 'tags'=>$tags);
219
- $extInfo = ' | PostID: '.$postID." - ".(isset($post) && is_object($post)?$post->post_title:'');
220
- }
221
- //## Actual Post
222
- $ntToPost = new nxs_class_SNAP_FP(); $ret = $ntToPost->doPostToNT($options, $message); //prr($ret);
223
- //## Save Session
224
- if (empty($options['ck'])) $options['ck'] = '';
225
- if (!empty($ret) && is_array($ret) && !empty($ret['ck']) && !empty($ret['ck']) && serialize($ret['ck'])!=$options['ck']) { global $plgn_NS_SNAutoPoster; $gOptions = $plgn_NS_SNAutoPoster->nxs_options; // prr($gOptions['pn']);
226
- if (isset($options['ii']) && $options['ii']!=='') { $gOptions[$ntCdL][$options['ii']]['ck'] = serialize($ret['ck']); update_option('NS_SNAutoPoster', $gOptions); }
227
- else foreach ($gOptions[$ntCdL] as $ii=>$gpn) { $result = array_diff($options, $gpn);
228
- if (!is_array($result) || count($result)<1) { $gOptions[$ntCdL][$ii]['ck'] = serialize($ret['ck']); $plgn_NS_SNAutoPoster->nxs_options = $gOptions; update_option('NS_SNAutoPoster', $gOptions); break; }
229
- }
230
- }
231
- //## Process Results
232
- if (!is_array($ret) || empty($ret['isPosted']) || $ret['isPosted']!='1') { //## Error
233
- if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);
234
- } else { // ## All Good - log it.
235
- if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo _e('OK - Message Posted, please see your '.$logNT.' Page. ', 'social-networks-auto-poster-facebook-twitter-g'); }
236
- else { nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPosted'=>'1', 'pgID'=>$ret['postID'], 'postURL'=>$ret['postURL'], 'pDate'=>date('Y-m-d H:i:s')));
237
- $extInfo .= ' | <a href="'.$ret['postURL'].'" target="_blank">Post Link</a>'; nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo);
238
- }
239
- }
240
- //## Return Result
241
- if (!empty($ret['isPosted']) && $ret['isPosted']=='1') return 200; else return print_r($ret, true);
242
 
243
- }
244
- }
 
 
 
 
245
  ?>
1
  <?php
2
  //## NextScripts Flipboard Connection Class
3
+ $nxs_snapAvNts[] = array('code'=>'FP', 'lcode'=>'fp', 'name'=>'Flipboard', 'type'=>'Blogs/Publishing Platforms', 'ptype'=>'P', 'status'=>'A', 'desc'=>'Autopost to your magazines');
4
 
5
+ if (!class_exists("nxs_snapClassFP")) { class nxs_snapClassFP extends nxs_snapClassNT {
6
+ var $ntInfo = array('code'=>'FP', 'lcode'=>'fp', 'name'=>'Flipboard', 'defNName'=>'uName', 'tstReq' => false, 'instrURL'=>'http://www.nextscripts.com/instructions/flipboard-social-networks-auto-poster-setup-installation/');
7
+
8
+ var $noFuncMsg = 'Flipboard doesn\'t have a built-in API for automated posts yet. <br/>You need to get a special <a target="_blank" href="http://www.nextscripts.com/snap-api/">library module</a> to be able to publish your content to Flipboard.';
9
+ function checkIfFunc() { return class_exists('nxsAPI_FP'); }
10
+
11
+ function toLatestVer($ntOpts){ if( !empty($ntOpts['v'])) $v = $ntOpts['v']; else $v = 340; $ntOptsOut = ''; switch ($v) {
12
+ case 340: $ntOptsOut = $this->toLatestVerNTGen($ntOpts); $ntOptsOut['do'] = $ntOpts['do'.$this->ntInfo['code']]; $ntOptsOut['nName'] = $ntOpts['nName'];
13
+ $ntOptsOut['msgFormat'] = $ntOpts['msgFrmt']; $ntOptsOut['uName'] = $ntOpts['uName']; $ntOptsOut['uPass'] = $ntOpts['uPass']; $ntOptsOut['mgzURL'] = $ntOpts['mgzURL'];
14
+ break;
15
+ }
16
+ return !empty($ntOptsOut)?$ntOptsOut:$ntOpts;
17
+ }
18
+
19
+
20
  //#### Show Common Settings
21
+ function showGenNTSettings($ntOpts){ $this->nt = $ntOpts; $this->showNTGroup(); return; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  //#### Show NEW Settings Page
23
+ function showNewNTSettings($ii){ $defO = array('nName'=>'', 'do'=>'1', 'uName'=>'', 'uPass'=>'', 'mgzURL'=>'', 'msgFormat'=>"%EXCERPT%\r\n\r\n%URL%"); $this->showGNewNTSettings($ii, $defO); }
24
+ //#### Show Unit Settings
25
+ function checkIfSetupFinished($options) { return !empty($options['uPass']); }
26
+ function accTab($ii, $options, $isNew=false){ $ntInfo = $this->ntInfo; $nt = $ntInfo['lcode']; $this->elemUserPass($ii, $options['uName'], $options['uPass']); ?>
27
+ <div style="width:100%;"><strong><?php _e('Where to Post', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong><i><?php _e('Flipboard Magazine URL', 'social-networks-auto-poster-facebook-twitter-g'); ?></i></div><input name="fp[<?php echo $ii; ?>][mgzURL]" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['mgzURL'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /><br/><br/>
28
+ <br/><?php $this->elemMsgFormat($ii,'Comment Text Format','msgFormat',$options['msgFormat']);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  }
30
+ function advTab($ii, $options){ $this->showProxies($this->ntInfo['lcode'], $ii, $options); }
31
  //#### Set Unit Settings from POST
32
+ function setNTSettings($post, $options){
33
+ foreach ($post as $ii => $pval){
34
+ if (!empty($pval['uPass']) && !empty($pval['uPass'])){ if (!isset($options[$ii])) $options[$ii] = array(); $options[$ii] = $this->saveCommonNTSettings($pval,$options[$ii]);
35
+ if (isset($pval['mgzURL'])) $options[$ii]['mgzURL'] = trim($pval['mgzURL']);
36
+ } elseif ( count($pval)==1 ) if (isset($pval['do'])) $options[$ii]['do'] = $pval['do']; else $options[$ii]['do'] = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  } return $options;
38
+ }
39
+
40
  //#### Show Post->Edit Meta Box Settings
41
+ function showEdPostNTSettings($ntOpts, $post){ $post_id = $post->ID; $nt = $this->ntInfo['lcode']; $ntU = $this->ntInfo['code'];
42
+ foreach($ntOpts as $ii=>$ntOpt) { $isFin = $this->checkIfSetupFinished($ntOpt); if (!$isFin) continue;
43
+ $pMeta = maybe_unserialize(get_post_meta($post_id, 'snap'.$ntU, true)); if (is_array($pMeta) && !empty($pMeta[$ii])) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
44
+ if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = ''; if (empty($ntOpt['urlToUse'])) $ntOpt['urlToUse'] = ''; $postType = isset($ntOpt['postType'])?$ntOpt['postType']:'';
45
+ $msgFormat = !empty($ntOpt['msgFormat'])?htmlentities($ntOpt['msgFormat'], ENT_COMPAT, "UTF-8"):''; $msgTFormat = !empty($ntOpt['msgTFormat'])?htmlentities($ntOpt['msgTFormat'], ENT_COMPAT, "UTF-8"):'';
46
+ $imgToUse = $ntOpt['imgToUse']; $urlToUse = $ntOpt['urlToUse']; $ntOpt['ii']=$ii;
47
+ $this->nxs_tmpltAddPostMeta($post, $ntOpt, $pMeta); ?>
48
+ <?php $this->elemEdMsgFormat($ii, __('Comment Text Format:', 'social-networks-auto-poster-facebook-twitter-g'),$msgFormat); ?>
49
+ <?php /* ## Select Image & URL ## */ nxs_showURLToUseDlg($nt, $ii, $urlToUse); $this->nxs_tmpltAddPostMetaEnd($ii);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  }
51
+ }
52
  //#### Save Meta Tags to the Post
53
+ function adjMetaOpt($optMt, $pMeta){ $optMt = $this->adjMetaOptG($optMt, $pMeta); // prr($optMt);
54
+
 
 
 
 
55
  return $optMt;
 
 
 
 
 
 
 
 
 
56
  }
57
+
58
+ function adjPublishWP(&$options, &$message, $postID){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
 
60
+ }
61
+ }}
62
+
63
+ if (!function_exists("nxs_doPublishToFP")) { function nxs_doPublishToFP($postID, $options){ if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
64
+ $cl = new nxs_snapClassFP(); $cl->nt[$options['ii']] = $options; return $cl->publishWP($options['ii'], $postID);
65
+ }}
66
  ?>
inc-cl/gp.api.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- //## NextScripts Facebook Connection Class
3
  $nxs_snapAPINts[] = array('code'=>'GP', 'lcode'=>'gp', 'name'=>'Google+');
4
 
5
  if (!class_exists("nxs_class_SNAP_GP")) { class nxs_class_SNAP_GP {
@@ -14,29 +14,33 @@ if (!class_exists("nxs_class_SNAP_GP")) { class nxs_class_SNAP_GP {
14
  function doPostToNT($options, $message){ $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>''); $lnk = '';
15
  //## Check API Lib
16
  // if (!function_exists('doPostToGooglePlus')) if (file_exists('apis/postToGooglePlus.php')) require_once ('apis/postToGooglePlus.php'); elseif (file_exists('/home/_shared/deSrc.php')) require_once ('/home/_shared/deSrc.php');
17
- if (!function_exists('doPostToGooglePlus')) { $badOut['Error'] = 'Google+ API Library not found'; return $badOut; }
18
  //## Check settings
19
  if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
20
- if (!isset($options['gpUName']) || trim($options['gpPass'])=='') { $badOut['Error'] = 'Not Configured'; return $badOut; }
21
- if (empty($options['imgSize'])) $options['imgSize'] = '';
22
  //## Make Post
23
- $gpPostType = $options['postType'];
24
- if (!empty($message['pText'])) $msg = $message['pText']; else $msg = nxs_doFormatMsg($options['gpMsgFormat'], $message); // Make "message default"
25
- if ($gpPostType=='I' || $gpPostType=='A') { if (isset($message['imageURL'])) $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); else $imgURL = ''; }
26
-
27
- $email = $options['gpUName']; $pass = substr($options['gpPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['gpPass'], 5)):$options['gpPass'];
28
 
29
- $nt = new nxsAPI_GP(); if(!empty($options['ck'])) $nt->ck = $options['ck']; $nt->debug = false; $loginError = $nt->connect($email, $pass);
 
30
  if (!$loginError){
31
  if ($gpPostType=='A') $lnk = $message['url']; elseif ($gpPostType=='I') { $lnk = array(); if ($imgURL!='') $lnk['img'] = $imgURL; if ($imgURL=='' && $message['noImg']===true) $lnk['img'] = '';
32
  if (!empty($message['videoURL'])) $lnk['video'] = $message['videoURL'];
33
- } $pageID = ''; $comPgID = ''; $comPGCatID = '';
34
  //if (!empty($options['gpPageID']) && empty($options['gpCommID'])) $pageID = $options['gpPageID'];
35
- if (!empty($options['gpPageID'])) $pageID = $options['gpPageID'];
36
- if (!empty($options['gpCommID'])) {$comPgID = $options['gpCommID']; $comPGCatID = $options['gpCCat'];}
 
 
37
  $result = $nt -> postGP($msg, $lnk, $pageID, $comPgID, $comPGCatID);
38
  } else { $badOut['Error'] = "Login/Connection Error: ". print_r($loginError, true); return $badOut; }
39
- if (is_array($result) && $result['isPosted']=='1') nxs_save_glbNtwrks('gp', $options['ii'], $nt->ck, 'ck');
 
40
  return $result;
41
  }
42
 
1
  <?php
2
+ //## NextScripts Google+ Connection Class
3
  $nxs_snapAPINts[] = array('code'=>'GP', 'lcode'=>'gp', 'name'=>'Google+');
4
 
5
  if (!class_exists("nxs_class_SNAP_GP")) { class nxs_class_SNAP_GP {
14
  function doPostToNT($options, $message){ $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>''); $lnk = '';
15
  //## Check API Lib
16
  // if (!function_exists('doPostToGooglePlus')) if (file_exists('apis/postToGooglePlus.php')) require_once ('apis/postToGooglePlus.php'); elseif (file_exists('/home/_shared/deSrc.php')) require_once ('/home/_shared/deSrc.php');
17
+ if (!class_exists('nxsAPI_GP')) { $badOut['Error'] = 'Google+ API Library not found'; return $badOut; }
18
  //## Check settings
19
  if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
20
+ if (!isset($options['uName']) || trim($options['uPass'])=='') { $badOut['Error'] = 'Not Configured'; return $badOut; }
21
+ if (empty($options['imgSize'])) $options['imgSize'] = ''; // prr($options); die();
22
  //## Make Post
23
+ $gpPostType = $options['postType']; $opVal = array(); $opNm = md5('nxs_snap_gp'.$options['uName'].$options['uPass']); $opVal = nxs_getOption($opNm); if (!empty($opVal) & is_array($opVal)) $options = array_merge($options, $opVal); // prr($opVal);
24
+ if (!empty($message['pText'])) $msg = $message['pText']; else $msg = nxs_doFormatMsg($options['msgFormat'], $message); // Make "message default"
25
+ if ($gpPostType=='I' || $gpPostType=='A') { if (isset($message['imageURL'])) $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); else $imgURL = ''; }
26
+ $email = $options['uName']; $pass = (substr($options['uPass'], 0, 5)=='n5g9a' || substr($options['uPass'], 0, 5)=='g9c1a')?nsx_doDecode(substr($options['uPass'], 5)):$options['uPass'];
27
+ //prr($options);
28
 
29
+ //prr($options['ck']);
30
+ $nt = new nxsAPI_GP(); if(!empty($options['ck'])) $nt->ck = $options['ck']; $nt->debug = false; $loginError = $nt->connect($email, $pass); // die('STOP IT');
31
  if (!$loginError){
32
  if ($gpPostType=='A') $lnk = $message['url']; elseif ($gpPostType=='I') { $lnk = array(); if ($imgURL!='') $lnk['img'] = $imgURL; if ($imgURL=='' && $message['noImg']===true) $lnk['img'] = '';
33
  if (!empty($message['videoURL'])) $lnk['video'] = $message['videoURL'];
34
+ } $comPgID = ''; $comPGCatID = '';
35
  //if (!empty($options['gpPageID']) && empty($options['gpCommID'])) $pageID = $options['gpPageID'];
36
+ $pageID = (!empty($options['postAs']) && $options['postAs']!='p')?$options['postAs']:''; $postTo = (!empty($options['postTo']) && $options['postTo']!='p')?$options['postTo']:'';
37
+ if (!empty($postTo)) { if (strlen($postTo)<10) { $comPgID = $postTo; /*Maybe get name */ }
38
+ elseif (substr($postTo,0,1)=='c') { $comPgID = substr($postTo,1); $comPGCatID = $options['commCat'];}
39
+ } // prr($pageID); prr($comPgID); prr($comPGCatID); //die();
40
  $result = $nt -> postGP($msg, $lnk, $pageID, $comPgID, $comPGCatID);
41
  } else { $badOut['Error'] = "Login/Connection Error: ". print_r($loginError, true); return $badOut; }
42
+ //if (is_array($result) && $result['isPosted']=='1') nxs_save_glbNtwrks('gp', $options['ii'], $nt->ck, 'ck');
43
+ if (is_array($result) && $result['isPosted']=='1') { $opVal['ck'] = $nt->ck; nxs_saveOption($opNm,$opVal); }
44
  return $result;
45
  }
46
 
inc-cl/gp.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
  //## NextScripts Facebook Connection Class
3
- $nxs_snapAvNts[] = array('code'=>'GP', 'lcode'=>'gp', 'name'=>'Google+');
4
 
5
 
6
- function nxs_CptCheckGP($o){ session_id("nxs-temp-gpcpt"); session_start(); $sess = unserialize($_SESSION['nxs-temp-gpcpt']);
7
  if (!empty($_POST['c'])) { $ck = $sess['c']; $flds = $sess['f'];
8
  $flds['recaptcha_response_field'] = $_POST['c']; $liObj = new nxsAPI_GP(); $hdrsArr = $liObj->headers('https://www.youtube.com/', 'https://www.youtube.com', 'POST', false);
9
  $advSet = array('headers' => $hdrsArr, 'httpversion' => '1.1', 'timeout' => 45, 'redirection' => 0, 'cookies' => $ck, 'body' => $flds); prr($advSet);
@@ -16,269 +16,186 @@ function nxs_CptCheckGP($o){ session_id("nxs-temp-gpcpt"); session_start(); $ses
16
  $rep = nxs_remote_get($rep['headers']['location'], $advSet); prr($ck); if (is_nxs_error($rep)) { $badOut = print_r($rep, true)." - ERROR"; return $badOut; } $ck = $rep['cookies'];
17
  }
18
  }
19
- }
20
 
21
- if (!class_exists("nxs_snapClassGP")) { class nxs_snapClassGP {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  //#### Show Common Settings
23
- function showGenNTSettings($ntOpts){ global $nxs_plurl; $ntInfo = array('code'=>'GP', 'lcode'=>'gp', 'name'=>'Google+', 'defNName'=>'gpUName', 'tstReq' => false);
24
- $fMsg = 'Google+ doesn\'t have a built-in API for automated posts yet. The current <a href="http://developers.google.com/+/api/">Google+ API</a> is "Read Only" and can\'t be used for posting. <br/>You need to get a special <a target="_blank" href="http://www.nextscripts.com/google-plus-automated-posting">library module</a> to be able to publish your content to Google+.';
25
- $ntParams = array('ntInfo'=>$ntInfo, 'nxs_plurl'=>$nxs_plurl, 'ntOpts'=>$ntOpts, 'chkField'=>'', 'checkFunc' => array('funcName'=>'doPostToGooglePlus', 'msg'=>$fMsg)); nxs_showListRow($ntParams);
26
- }
27
  //#### Show NEW Settings Page
28
- function showNewNTSettings($mgpo){ $options = array('nName'=>'', 'doGP'=>'1', 'gpUName'=>'', 'gpPageID'=>'', 'gpCommID'=>'', 'postType'=>'A', 'gpPass'=>''); $options['ntInfo']= array('lcode'=>'gp'); $this->showNTSettings($mgpo, $options, true);}
29
- //#### Show Unit Settings
30
- function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl; $nt = $options['ntInfo']['lcode']; $ntU = strtoupper($nt);
31
- 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'] = '';
32
- if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; if (!isset($options['gpCCatsList'])) $options['gpCCatsList'] = ''; ?>
33
- <div id="doGP<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>" > <input type="hidden" name="apDoSGP<?php echo $ii; ?>" value="0" id="apDoSGP<?php echo $ii; ?>" />
34
- <?php if(!class_exists('nxsAPI_GP') || (defined('d1') && d1==1)) {
35
- nxs_show_noLibWrn('Google+ API Library module NOT found.<br/><br/><span style="color:black;">Google+ does not have a free native API for automated posts yet. The current <a target="_blank" href="http://developers.google.com/+/api/">Google+ API</a> is "Read Only" and can\'t be used for posting.</span><br/><br/><span style="font-size: 12px;color:black;">You need to have a special API Library Module to be able to publish your content to Google+.</span>'); echo "</div>"; return; };
36
- ?>
37
- <div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/gp16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-google-plus-social-networks-auto-poster-wordpress/"><?php $nType="Google+"; printf( __( 'Detailed %s Installation/Configuration Instructions', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?></a></div>
38
-
39
- <div style="width:100%;"><strong><?php _e('Account Nickname', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'social-networks-auto-poster-facebook-twitter-g'); ?></i> </div><input name="gp[<?php echo $ii; ?>][nName]" id="gpnName<?php echo $ii; ?>" style="font-weight: bold; color: #005800; border: 1px solid #ACACAC; width: 40%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['nName'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /><br/>
40
- <?php echo nxs_addQTranslSel('gp', $ii, $options['qTLng']); ?>
41
- <br/>
42
- <ul class="nsx_tabs">
43
- <li><a href="#nsx<?php echo $nt.$ii ?>_tab1"><?php _e('Account Info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li>
44
- <?php if (!$isNew) { ?> <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li> <?php } ?>
45
- </ul>
46
- <div class="nsx_tab_container"><?php /* ######################## Account Tab ####################### */ ?>
47
- <div id="nsx<?php echo $nt.$ii ?>_tab1" class="nsx_tab_content" style="background-image: url(<?php echo $nxs_plurl; ?>img/<?php echo $nt; ?>-bg.png); background-repeat: no-repeat; background-position:90% 10%;">
48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
 
50
-
51
- <div style="width:100%;"><strong>Google+ Login Email:</strong> </div><input name="gp[<?php echo $ii; ?>][apGPUName]" id="apGPUName<?php echo $ii; ?>" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['gpUName'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />
52
- <div style="width:100%;"><strong>Google+ Password:</strong> </div><input autocomplete="false" readonly onfocus="this.removeAttribute('readonly');" name="gp[<?php echo $ii; ?>][apGPPass]" id="apGPPass<?php echo $ii; ?>" type="password" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities(substr($options['gpPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['gpPass'], 5)):$options['gpPass'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /> <br/>
53
- <p><div style="width:100%;"><strong>Google+ Page ID (Optional - for Google+ Pages Only. <b style="color: #580000;"> <?php _e('Leave Empty to publish to your profile or community', 'social-networks-auto-poster-facebook-twitter-g'); ?></b>):</strong>
54
- <p style="font-size: 11px; margin: 0px;">For example if URL of your page is https://plus.google.com/u/0/b/117008619877691455570/ your Page ID is: 117008619877691455570. <b><?php _e('Leave Empty to publish to your profile or community.', 'social-networks-auto-poster-facebook-twitter-g'); ?></b></p>
55
- </div><input name="gp[<?php echo $ii; ?>][apGPPage]" id="apGPPage" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['gpPageID'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />
56
- <br/>
57
- <p><div style="width:100%;"><strong>Google+ Community ID (Optional - for Google+ Communities Only. <b style="color: #580000;"> <?php _e('Leave Empty to publish to your profile or page', 'social-networks-auto-poster-facebook-twitter-g'); ?></b>):</strong>
58
- <p style="font-size: 11px; margin: 0px;">For example if URL of your Community is https://plus.google.com/communities/100396001601096060160 your Page ID is: 100396001601096060160. <b><?php _e('Leave Empty to publish to your profile or page', 'social-networks-auto-poster-facebook-twitter-g'); ?>.</b></p>
59
- </div><input name="gp[<?php echo $ii; ?>][gpCommID]" id="gpCommID<?php echo $ii; ?>" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['gpCommID'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />&nbsp;&nbsp;
60
- <a href="#" onclick="getGPCats(jQuery('<?php if ($isNew) echo "#nsx_addNT "; ?>#apGPUName<?php echo $ii; ?>').val(), jQuery('<?php if ($isNew) echo "#nsx_addNT "; ?>#apGPPass<?php echo $ii; ?>').val(), '<?php echo $ii; ?>', jQuery('<?php if ($isNew) echo "#nsx_addNT "; ?>#gpCommID<?php echo $ii; ?>').val()); return false;">
61
- <?php _e('Retrieve Categories and Page Names', 'social-networks-auto-poster-facebook-twitter-g'); ?>
62
- </a>
63
- <div style="padding-left: 15px; width:100%;"><strong>Community Category:</strong>
64
- <img id="gpLoadingImg<?php echo $ii; ?>" style="display: none;" src='<?php echo $nxs_plurl; ?>img/ajax-loader-sm.gif' />
65
- <select name="gp[<?php echo $ii; ?>][apGPCCats]" id="apGPCCats<?php echo $ii; ?>">
66
- <?php if ($options['gpCCatsList']!=''){ $gGPCats = $options['gpCCatsList']; if ( base64_encode(base64_decode($gGPCats)) === $gGPCats) $gGPCats = base64_decode($gGPCats);
67
- if ($options['gpCCat']!='') $gGPCats = str_replace($options['gpCCat'].'"', $options['gpCCat'].'" selected="selected"', $gGPCats); echo $gGPCats;} else { ?>
68
- <option value="0">None(Click above to retrieve your categories)</option>
69
- <?php } ?>
70
- </select>
71
- </div>
72
-
73
- <br/><br/>
74
-
75
- <div id="altFormat" style="">
76
- <div style="width:100%;"><strong id="altFormatText"><?php _e('Message text Format', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> (<a href="#" id="apGPMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apGPMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>)
77
- </div>
78
-
79
- <textarea cols="150" rows="3" id="gp<?php echo $ii; ?>SNAPformat" name="gp[<?php echo $ii; ?>][apGPMsgFrmt]" style="width:51%;max-width: 650px;" onfocus="jQuery('#gp<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('apGPMsgFrmt<?php echo $ii; ?>');"><?php if ($isNew) _e("New post (%TITLE%) has been published on %SITENAME%", 'social-networks-auto-poster-facebook-twitter-g'); else _e(apply_filters('format_to_edit', htmlentities($options['gpMsgFormat'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g'); ?></textarea>
80
-
81
- <?php nxs_doShowHint("apGPMsgFrmt".$ii); ?>
82
- </div><br/>
83
-
84
- <div style="width:100%;"><strong id="altFormatText">Post Type:</strong>&lt;-- (<a id="showShAtt" onmouseout="hidePopShAtt('<?php echo $ii; ?>XG');" onmouseover="showPopShAtt('<?php echo $ii; ?>XG', event);" onclick="return false;" class="underdash" href="http://www.nextscripts.com/blog/"><?php _e('What\'s the difference?', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>) </div>
85
- <div style="margin-left: 10px;">
86
- <?php if(!isset($options['postType']) || $options['postType']=='') {
87
- if ((int)$options['imgPost'] == 1) $options['postType'] = 'I';
88
- if ((int)$options['gpAttch'] == 1 || $isNew) $options['postType'] = 'A';
89
- } ?>
90
- <input type="radio" name="gp[<?php echo $ii; ?>][postType]" value="T" <?php if ($options['postType'] == 'T') echo 'checked="checked"'; ?> /> <?php _e('Text Post', 'social-networks-auto-poster-facebook-twitter-g'); ?> - <i><?php _e('just text message', 'social-networks-auto-poster-facebook-twitter-g'); ?></i><br/>
91
- <input type="radio" name="gp[<?php echo $ii; ?>][postType]" value="I" <?php if ($options['postType'] == 'I') echo 'checked="checked"'; ?> /> <?php _e('Google+ Image Post', 'social-networks-auto-poster-facebook-twitter-g'); ?> - <i><?php _e('big image with text message', 'social-networks-auto-poster-facebook-twitter-g'); ?></i><br/>
92
- <input type="radio" name="gp[<?php echo $ii; ?>][postType]" value="A" <?php if ( !isset($options['postType']) || $options['postType'] == '' || $options['postType'] == 'A') echo 'checked="checked"'; ?> /> <?php _e('Add blogpost to Google+ message as an attachment', 'social-networks-auto-poster-facebook-twitter-g'); ?><br/>
93
- <div class="popShAtt" id="popShAtt<?php echo $ii; ?>XG"><h3><?php _e('Google+ Post Types', 'social-networks-auto-poster-facebook-twitter-g'); ?></h3><img src="<?php echo $nxs_plurl; ?>img/gpPostTypesDiff6.png" width="600" height="285" alt="<?php _e('Google+ Post Types', 'social-networks-auto-poster-facebook-twitter-g'); ?>"/></div>
94
- </div><br/>
95
- <?php if ($isNew) { ?> <input type="hidden" name="gp[<?php echo $ii; ?>][apDoGP]" value="1" id="apDoNewGP<?php echo $ii; ?>" /> <?php } ?>
96
- <?php if ($options['gpPass']!='') { ?>
97
-
98
- <b><?php _e('Test your settings', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('GP', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?></a> <?php }
99
- ?>
100
-
101
- </div>
102
- <?php /* ######################## Advanced Tab ####################### */ ?>
103
- <?php if (!$isNew) { ?> <div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content">
104
 
105
- <?php nxs_showCatTagsCTFilters($nt, $ii, $options);
106
- nxs_addPostingDelaySelV3($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']);
107
- nxs_showRepostSettings($nt, $ii, $options); ?>
108
-
109
-
110
- </div> <?php } ?> <?php /* #### End of Tab #### */ ?>
111
- </div><br/> <?php /* #### End of Tabs #### */ ?>
112
 
113
- <div class="submitX nxclear" style="padding-bottom: 0px;"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'social-networks-auto-poster-facebook-twitter-g') ?>" /></div> </div>
114
-
115
- <?php
 
 
 
 
 
 
 
 
 
 
 
116
  }
 
117
  //#### Set Unit Settings from POST
118
- function setNTSettings($post, $options){ $code = 'GP'; $lcode = 'gp';
119
  foreach ($post as $ii => $pval){
120
- if (!empty($pval['apGPUName']) && !empty($pval['apGPPass'])){ if (!isset($options[$ii])) $options[$ii] = array();
121
- if (isset($pval['apGPUName'])) $options[$ii]['gpUName'] = trim($pval['apGPUName']);
122
- if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']);
123
- if (isset($pval['apGPPass'])) $options[$ii]['gpPass'] = 'n5g9a'.nsx_doEncode($pval['apGPPass']); else $options[$ii]['gpPass'] = '';
124
- if (isset($pval['apGPPage'])) $options[$ii]['gpPageID'] = trim($pval['apGPPage']);
125
- if (isset($pval['gpCommID'])) $options[$ii]['gpCommID'] = trim($pval['gpCommID']);
126
-
127
- if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']); else $options[$ii]['catSel'] = 0;
128
- if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
129
-
130
- if (isset($pval['apGPCCats'])) $options[$ii]['gpCCat'] = trim($pval['apGPCCats']);
131
-
132
- $options[$ii] = nxs_adjRpst($options[$ii], $pval);
133
-
134
- if (isset($pval['postType'])) $options[$ii]['postType'] = $pval['postType'];
135
- if (isset($pval['apGPMsgFrmt'])) $options[$ii]['gpMsgFormat'] = trim($pval['apGPMsgFrmt']);
136
- if (isset($pval['apDoGP'])) $options[$ii]['doGP'] = $pval['apDoGP']; else $options[$ii]['doGP'] = 0;
137
- if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']); if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
138
- if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
139
- } elseif ( count($pval)==1 ) if (isset($pval['apDo'.$code])) $options[$ii]['do'.$code] = $pval['apDo'.$code]; else $options[$ii]['do'.$code] = 0;
140
  } return $options;
141
- }
142
- //#### Show Post->Edit Meta Box Settings
143
- function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID; $nt = 'gp'; $ntU = 'GP';
144
- foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapGP', true)); if (is_array($pMeta) && isset($pMeta[$ii]) && is_array($pMeta[$ii])) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
145
- if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = ''; if (empty($ntOpt['urlToUse'])) $ntOpt['urlToUse'] = '';
146
- $doGP = $ntOpt['doGP'] && (is_array($pMeta) || $ntOpt['catSel']!='1'); $imgToUse = $ntOpt['imgToUse']; $urlToUse = $ntOpt['urlToUse'];
147
- $isAvailGP = $ntOpt['gpUName']!='' && $ntOpt['gpPass']!=''; $gpMsgFormat = htmlentities($ntOpt['gpMsgFormat'], ENT_COMPAT, "UTF-8");
148
- if(!isset($ntOpt['postType']) || $ntOpt['postType']=='') {
149
- if ((int)$ntOpt['imgPost'] == 1) $ntOpt['postType'] = 'I';
150
- if ((int)$ntOpt['gpAttch'] == 1 || $isNew) $ntOpt['postType'] = 'A';
151
- } $gpPostType = $ntOpt['postType'];
152
- ?>
153
- <tr><th style="text-align:left;" colspan="2">
154
- <?php if ($ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='') { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
155
- <?php if (!empty($ntOpt['tagsSelX'])) { ?> <input type="hidden" class="nxs_TG" id="nxs_TG_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $ntOpt['tagsSelX']; ?>" /> <?php } ?>
156
- <?php if ($isAvailGP) { ?><input class="nxsGrpDoChb" value="1" id="doGP<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="gp[<?php echo $ii; ?>][doGP]" <?php if ((int)$doGP == 1) echo 'checked="checked" title="def"'; ?> />
157
- <?php if ($post->post_status == "publish") { ?> <input type="hidden" name="gp[<?php echo $ii; ?>][doGP]" value="<?php echo $doGP;?>"> <?php } ?> <?php } ?>
158
-
159
- <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/gp16.png);">Google+ - <?php _e('publish to', 'social-networks-auto-poster-facebook-twitter-g') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
160
- 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+', 'social-networks-auto-poster-facebook-twitter-g') ?>" />
161
- <?php } ?>
162
-
163
- <?php if (is_array($pMeta) && isset($pMeta[$ii]) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
164
-
165
- ?> <span id="pstdGP<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
166
- <a style="font-size: 10px;" href="https://plus.google.com/<?php echo $pMeta[$ii]['pgID']; ?>" target="_blank"><?php $nType="Google+"; printf( __( 'Posted on', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
167
- </span><?php } ?>
168
-
169
- </td></tr>
170
-
171
- <?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>
172
- <?php } else { if ($post->post_status != "publish" && function_exists('nxs_doSMAS5') ) { $ntOpt['postTime'] = get_post_time('U', false, $post_id); nxs_doSMAS5($nt, $ii, $ntOpt); }
173
-
174
- if (((int)$doGP == 1) && $post->post_status == "publish" && isset($ntOpt['timeToRun']) && $ntOpt['timeToRun'] > time()) { ?> <tr><th style="text-align:left; color: purple;" colspan="2">
175
- ===&gt;&gt;&gt;&gt;&nbsp;<?php _e('Autopost has been schedulled for', 'social-networks-auto-poster-facebook-twitter-g') ?> <?php echo date('F j, Y, g:i a', $ntOpt['timeToRun']) ?></th> <?php } ?>
176
-
177
- <?php if ($ntOpt['rpstOn']=='1') { ?>
178
-
179
- <tr id="altFormat1" style=""><th scope="row" class="nxsTHRow">
180
- <input value="0" type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]"/><input value="nxsi<?php echo $ii; ?>gp" type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]" <?php if (!empty($ntOpt['rpstPostIncl'])) echo "checked"; ?> />
181
- </th>
182
- <td> <?php _e('Include in "Auto-Reposting" to this network.', 'social-networks-auto-poster-facebook-twitter-g') ?>
183
- </td></tr> <?php } ?>
184
-
185
- <tr><th scope="row" style="text-align:right; width:150px; vertical-align:top; padding-top: 0px; padding-right:10px;"> <?php _e('Post Type:', 'social-networks-auto-poster-facebook-twitter-g') ?> <br/>
186
- (<a id="showShAtt" style="font-weight: normal" onmouseout="hidePopShAtt('<?php echo $ii; ?>XG');" onmouseover="showPopShAtt('<?php echo $ii; ?>XG', event);" onclick="return false;" class="underdash" href="http://www.nextscripts.com/blog/"><?php _e('What\'s the difference?', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>)
187
- </th><td>
188
 
189
- <input class="nxs_postEditCtrl" type="radio" name="gp[<?php echo $ii; ?>][postType]" value="T" <?php if ($gpPostType == 'T') echo 'checked="checked"'; ?> /> <?php _e('Text Post', 'social-networks-auto-poster-facebook-twitter-g') ?> - <i><?php _e('just text message', 'social-networks-auto-poster-facebook-twitter-g') ?></i><br/>
190
- <input class="nxs_postEditCtrl" type="radio" name="gp[<?php echo $ii; ?>][postType]" value="I" <?php if ($gpPostType == 'I') echo 'checked="checked"'; ?> onchange="jQuery('#altFormatIMG<?php echo $nt.$ii;?>').show();" /> <?php _e('Post to Google+ as "Image post"', 'social-networks-auto-poster-facebook-twitter-g') ?> - <i><?php _e('big image with text message', 'social-networks-auto-poster-facebook-twitter-g') ?></i><br/>
191
- <input class="nxs_postEditCtrl" type="radio" name="gp[<?php echo $ii; ?>][postType]" value="A" <?php if ( !isset($gpPostType) || $gpPostType == '' || $gpPostType == 'A') echo 'checked="checked"'; ?> onchange="jQuery('#altFormatIMG<?php echo $nt.$ii;?>').hide();" /><?php _e('Text Post with "attached" blogpost', 'social-networks-auto-poster-facebook-twitter-g') ?>
192
- <div class="popShAtt" id="popShAtt<?php echo $ii; ?>XG"><h3><?php _e('Google+ Post Types', 'social-networks-auto-poster-facebook-twitter-g') ?></h3><img src="<?php echo $nxs_plurl; ?>img/gpPostTypesDiff6.png" width="600" height="285" alt="<?php _e('Google+ Post Types', 'social-networks-auto-poster-facebook-twitter-g') ?>"/></div>
193
- </td></tr>
194
- <?php if ($ntOpt['gpCommID']!='') { ?>
195
- <tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;">Community Category</th>
196
- <td><select class="nxs_postEditCtrl" name="gp[<?php echo $ii; ?>][apGPCCat]" id="apGPCCat">
197
- <?php if (!empty($ntOpt['gpCCatsList'])){ $gCats = $ntOpt['gpCCatsList']; if ( base64_encode(base64_decode($gCats)) === $gCats) $gCats = base64_decode($gCats);
198
- if ($ntOpt['gpCCat']!='') $gCats = str_replace($ntOpt['gpCCat'].'"', $ntOpt['gpCCat'].'" selected="selected"', $gCats); echo $gCats;} else { ?>
199
- <option value="0">None(Please go to settings and retreive)</option>
200
- <?php } ?>
201
- </select></td>
202
- </tr>
203
- <?php } ?>
204
- <?php /* ## Message Format ## */ ?>
205
- <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Message Format:', 'social-networks-auto-poster-facebook-twitter-g') ?></th>
206
- <td>
207
 
208
- <?php if (1==1) { ?>
209
- <textarea class="nxs_postEditCtrl" cols="150" rows="1" id="gp<?php echo $ii; ?>SNAPformat" name="gp[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('#gp<?php echo $ii; ?>SNAPformat').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apGPMsgFrmt<?php echo $ii; ?>');"><?php echo $gpMsgFormat ?></textarea>
210
- <?php } else { ?>
211
- <input class="nxs_postEditCtrl" value="<?php echo $gpMsgFormat ?>" type="text" name="gp[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apGPMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apGPMsgFrmt".$ii); ?>
212
- <?php } ?>
213
- </td></tr>
214
- <?php /* ## Select Image & URL ## */ nxs_showImgToUseDlg($nt, $ii, $imgToUse, ( !isset($gpPostType) || $gpPostType == '' || $gpPostType == 'A') ); nxs_showURLToUseDlg($nt, $ii, $urlToUse); ?>
215
- <?php }
 
216
  }
217
- }
218
  //#### Save Meta Tags to the Post
219
- function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
220
- if (isset($pMeta['SNAPformat'])) $optMt['gpMsgFormat'] = $pMeta['SNAPformat'];
221
- if (isset($pMeta['imgToUse'])) $optMt['imgToUse'] = $pMeta['imgToUse']; if (isset($pMeta['urlToUse'])) $optMt['urlToUse'] = $pMeta['urlToUse'];
222
- if (isset($pMeta['timeToRun'])) $optMt['timeToRun'] = $pMeta['timeToRun']; if (isset($pMeta['rpstPostIncl'])) $optMt['rpstPostIncl'] = $pMeta['rpstPostIncl'];
223
- if (isset($pMeta['postType'])) $optMt['postType'] = $pMeta['postType'];
224
- if (isset($pMeta['apGPCCat']) && $pMeta['apGPCCat']!='' && $pMeta['apGPCCat']!='0') $optMt['gpCCat'] = $pMeta['apGPCCat'];
225
- if (isset($pMeta['doGP'])) $optMt['doGP'] = $pMeta['doGP'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doGP'] = 0; }
226
- if (isset($pMeta['SNAPincludeGP']) && $pMeta['SNAPincludeGP'] == '1' ) $optMt['doGP'] = 1;
227
  return $optMt;
228
- }
229
- }}
230
- if (!function_exists("nxs_rePostToGP_ajax")) {
231
- function nxs_rePostToGP_ajax() { check_ajax_referer('nxsSsPageWPN'); $postID = $_POST['id']; global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
232
- foreach ($options['gp'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj'; //if ($two['gpPageID'].$two['gpUName']==$_POST['nid']) {
233
- $gppo = get_post_meta($postID, 'snapGP', true); $gppo = maybe_unserialize($gppo);// prr($gppo);
234
- if (is_array($gppo) && isset($gppo[$ii]) && is_array($gppo[$ii])){ $ntClInst = new nxs_snapClassGP(); $two = $ntClInst->adjMetaOpt($two, $gppo[$ii]); }
235
- $result = nxs_doPublishToGP($postID, $two); if ($result == 200) die("Successfully sent your post to Google+."); else die($result);
236
- }
237
  }
238
- }
239
- if (!function_exists("nxs_doPublishToGP")) { //## Second Function to Post to G+
240
- function nxs_doPublishToGP($postID, $options){ $ntCd = 'GP'; $ntCdL = 'gp'; $ntNm = 'Google+'; global $plgn_NS_SNAutoPoster; $ytCode = ''; $imgURL = '';
241
- if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
242
- if (!class_exists('nxsAPI_GP') || (defined('d1') && d1==1)) { nxs_addToLogN('E', 'Error', $ntCd, '-=ERROR=- No G+ API Lib Detected', ''); return "No G+ API Lib Detected";}
243
- $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'POSTID'=>$postID, 'ACCNAME'=>$options['nName']));
244
- if (empty($options['imgToUse'])) $options['imgToUse'] = ''; if (empty($options['imgSize'])) $options['imgSize'] = '';
245
-
246
- $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
247
- $logNT = '<span style="color:#800000">Google+</span> - '.$options['nName'];
248
- $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
249
- if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
250
- $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') {
251
- nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$uqID); return;
252
- }
253
- }
254
-
255
- $message = array('message'=>'', 'link'=>'', 'imageURL'=>'', 'videoURL'=>'', 'noImg'=>false); $isNoImg = false;
256
- if ($postID=='0') { echo "Testing ... <br/><br/>"; $options['gpMsgFormat'] = "Test Post from ". htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES)." - ".home_url(); $message['url'] = home_url();
257
- } else { nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1')); $post = get_post($postID); if(!$post) return;
258
- $gpMsgFormat = $options['gpMsgFormat']; $gpPostType = $options['postType']; $msg = nsFormatMessage($gpMsgFormat, $postID, $addParams); $options['gpMsgFormat'] = $msg;
259
- $extInfo = ' | PostID: '.$postID." - ".(isset($post) && is_object($post)?$post->post_title:'');
260
- if ($gpPostType=='I') { $vids = nsFindVidsInPost($post, false); if (count($vids)>0) $ytCode = $vids[0]; /* if (trim($ytCode)=='') $options['trPostType']='T'; /* What is it? */ }
261
- if ($gpPostType=='A') if (trim($options['imgToUse'])!='') $imgURL = $options['imgToUse']; else $imgURL = nxs_getPostImage($postID, 'medium');
262
- if ($gpPostType=='I') if (trim($options['imgToUse'])!='') $imgURL = $options['imgToUse']; else $imgURL = nxs_getPostImage($postID, 'full');
263
- if (preg_match("/noImg.\.png/i", $imgURL)) { $imgURL = ''; $isNoImg = true; }
264
-
265
- //## MyURL - URLToGo code
266
- $options = nxs_getURL($options, $postID, $addParams); $urlToGo = $options['urlToUse'];
267
- $message = array('url'=>$urlToGo, 'imageURL'=>$imgURL, 'videoCode'=>$ytCode, 'noImg'=>$isNoImg); //prr($message); die();
268
- }
269
- //## Actual Post
270
- $ntToPost = new nxs_class_SNAP_GP(); $ret = $ntToPost->doPostToNT($options, $message);
271
- //## Process Results
272
- if (!is_array($ret) || $ret['isPosted']!='1') { //## Error
273
- if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);
274
- } else { // ## All Good - log it.
275
- if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo _e('OK - Message Posted, please see your '.$logNT.' Page. ', 'social-networks-auto-poster-facebook-twitter-g'); }
276
- else { nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPosted'=>'1', 'pgID'=>$ret['postID'], 'pDate'=>date('Y-m-d H:i:s')));
277
- $extInfo .= ' | <a href="'.$ret['postURL'].'" target="_blank">Post Link</a>'; nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); }
278
- }
279
- //## Return Result
280
- if (!empty($ret['isPosted']) && $ret['isPosted']=='1') return 200; else return print_r($ret, true);
281
 
282
  }
283
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
284
  ?>
1
  <?php
2
  //## NextScripts Facebook Connection Class
3
+ $nxs_snapAvNts[] = array('code'=>'GP', 'lcode'=>'gp', 'name'=>'Google+', 'type'=>'Social Networks', 'ptype'=>'P', 'status'=>'A', 'desc'=>'Post text, image or share a link to your profile, collection, business page or community');
4
 
5
 
6
+ if (!function_exists("nxs_CptCheckGP")) { function nxs_CptCheckGP($o){ session_id("nxs-temp-gpcpt"); session_start(); $sess = unserialize($_SESSION['nxs-temp-gpcpt']);
7
  if (!empty($_POST['c'])) { $ck = $sess['c']; $flds = $sess['f'];
8
  $flds['recaptcha_response_field'] = $_POST['c']; $liObj = new nxsAPI_GP(); $hdrsArr = $liObj->headers('https://www.youtube.com/', 'https://www.youtube.com', 'POST', false);
9
  $advSet = array('headers' => $hdrsArr, 'httpversion' => '1.1', 'timeout' => 45, 'redirection' => 0, 'cookies' => $ck, 'body' => $flds); prr($advSet);
16
  $rep = nxs_remote_get($rep['headers']['location'], $advSet); prr($ck); if (is_nxs_error($rep)) { $badOut = print_r($rep, true)." - ERROR"; return $badOut; } $ck = $rep['cookies'];
17
  }
18
  }
19
+ }}
20
 
21
+ if (!class_exists("nxs_snapClassGP")) { class nxs_snapClassGP extends nxs_snapClassNT {
22
+ var $ntInfo = array('code'=>'GP', 'lcode'=>'gp', 'name'=>'Google+', 'defNName'=>'uName', 'tstReq' => false, 'imgAct'=>'E', 'instrURL'=>'http://www.nextscripts.com/instructions/setup-installation-google-plus-social-networks-auto-poster/');
23
+ var $noFuncMsg = 'Google+ doesn\'t have a built-in API for automated posts yet. <br/>You need to get a special <a target="_blank" href="http://www.nextscripts.com/google-plus-automated-posting//">library module</a> to be able to publish your content to Google+.';
24
+
25
+ function toLatestVer($ntOpts){ //return $ntOpts;
26
+ if( !empty($ntOpts['v'])) $v = $ntOpts['v']; else $v = 340; $ntOptsOut = $ntOpts; switch ($v) {
27
+ case 340: $ntOptsOut = $this->toLatestVerNTGen($ntOpts); $ntOptsOut['do'] = $ntOpts['do'.$this->ntInfo['code']]; $ntOptsOut['nName'] = $ntOpts['nName'];
28
+ $ntOptsOut['msgFormat'] = $ntOpts['gpMsgFormat']; $ntOptsOut['uName'] = $ntOpts['gpUName']; $ntOptsOut['uPass'] = $ntOpts['gpPass'];
29
+ $ntOptsOut['pageID'] = $ntOpts['gpPageID']; $ntOptsOut['postType'] = $ntOpts['postType'];
30
+ $ntOptsOut['commID'] = $ntOpts['gpCommID']; $ntOptsOut['commCat'] = $ntOpts['gpCCat'];
31
+ case 350:
32
+ if (empty($ntOptsOut['postTo'])) $ntOptsOut['postTo'] = !empty($ntOptsOut['commID']) ? 'c'.$ntOptsOut['commID'] : 'p';
33
+ if (empty($ntOptsOut['postAs'])) $ntOptsOut['postAs'] = !empty($ntOptsOut['pageID']) ? $ntOptsOut['pageID'] : 'p';
34
+ // unset($ntOptsOut['pageID']); unset($ntOptsOut['commID']); unset($ntOptsOut['ck']); unset($ntOptsOut['commCatsList']); //
35
+ $ntOptsOut['isUpdd'] = '1'; $ntOptsOut['v'] = NXS_SETV;
36
+ break;
37
+ }
38
+ return !empty($ntOptsOut)?$ntOptsOut:$ntOpts;
39
+ }
40
+ function checkIfFunc() { return class_exists('nxsAPI_GP'); }
41
  //#### Show Common Settings
42
+ function showGenNTSettings($ntOpts){ $this->nt = $ntOpts; $this->showNTGroup(); return; }
 
 
 
43
  //#### Show NEW Settings Page
44
+ function showNewNTSettings($ii){ $defO = array('nName'=>'', 'do'=>'1', 'uName'=>'', 'uPass'=>'', 'postType'=>'A', 'postTo'=>'', 'postAs'=>'', 'postAsNm'=>'', 'commCat'=>'', 'msgFormat'=>"New post: %TITLE% - %URL%"); $this->showGNewNTSettings($ii, $defO); }
45
+ //#### Show Unit Settings
46
+ function checkIfSetupFinished($options) { return !empty($options['uPass']); }
47
+ function accTab($ii, $options, $isNew=false){ // $options['v']='340'; $options = $this->toLatestVer($options);
48
+ $ntInfo = $this->ntInfo; $nt = $ntInfo['lcode']; $p = $options['uPass']; $this->elemUserPass($ii, $options['uName'], $p); //prr($options['postTo'], 'POST TO'); prr($options['postAs'], 'POST AS'); // prr($options);
49
+ if (!empty($p)) { $p = (substr($p, 0, 5)=='n5g9a'||substr($p, 0, 5)=='g9c1a'||substr($p, 0, 5)=='b4d7s')?nsx_doDecode(substr($p, 5)):$p; $options['uPass'] = 'g9c1a'.nsx_doEncode($p); $tPST = (!empty($_POST))?$_POST:'';
50
+ $_POST['pg'] = $options['postTo']; $_POST['pstAs'] = $options['postAs']; $_POST['u'] = $options['uName']; $_POST['p'] = $p; $_POST['ii'] = $ii; $ntw[$nt][$ii]=$options;
51
+ $opNm = 'nxs_snap_gp_'.sha1('nxs_snap_gp'.$options['uName'].$options['uPass']); $opVal = nxs_getOption($opNm); if (empty($opVal)) $opVal = $this->getListOfPages($ntw);
52
+ if (!empty($opVal) & !is_array($opVal)) $options['uMsg'] = $opVal; else { if (!empty($opVal) & is_array($opVal)) $options = array_merge($options, $opVal);
53
+ $opNm = 'nxs_snap_gp_wh'.sha1('nxs_snap_gpwh'.$options['uName'].$options['uPass'].$options['postAs']); $opVal = nxs_getOption($opNm);
54
+ if (empty($opVal)) $opVal = $this->getListWhereToPost($ntw); if (!empty($opVal) & is_array($opVal)) $options = array_merge($options, $opVal); // prr($opVal, 'opVal:');
55
+ if (substr($options['postTo'],0,1)=='c') { $opNm = 'nxs_snap_gp_cl_'.sha1('nxs_snap_gpcl'.$options['uName'].$options['uPass'].$options['postTo']); $opVal = nxs_getOption($opNm);
56
+ if (empty($opVal)) $opVal = $this->getGPCommInfo($ntw); if (!empty($opVal) & is_array($opVal)) $options = array_merge($options, $opVal); // prr($opVal, 'opVal:');
57
+ }
58
+ } $_POST = $tPST;
59
+ } if (empty($options['postAsNm']) && !empty($options['postAs']) && $options['postAs']!='p') $options['postAsNm'] = 'Page. ID:'.$options['postAs'].')';
60
+ ?>
 
 
 
61
 
62
+ <br/ ><div style="width:100%;"><b><?php _e('Post as', 'nxs_snap'); ?></b>&nbsp;(<?php _e('Please select profile, business page or branded page', 'nxs_snap'); ?>)</div>
63
+ <div id="nxsGPInfoDiv<?php echo $ii; ?>">
64
+ <div style="width:100%;">
65
+ <div>
66
+ <select id="gpPostAs<?php echo $ii; ?>" onchange="nxs_gpPostAsChange('<?php echo $ii;?>',jQuery(this));" name="gp[<?php echo $ii;?>][postAs]">
67
+ <?php $pgi = !empty($options['pgsList'])?$options['pgsList']:'';
68
+ if (!empty($options['postAs'])) { echo (!empty($pgi) && !empty($options['postAs']) && stripos($pgi,$options['postAs'])===false)?'<option selected="selected" value="'.$options['postAs'].'">'.$options['postAs'].'</option>':''; }
69
+ ?><option <?php if (empty($options['postAs'])) echo 'selected="selected"' ?> value="p"><?php _e('Profile'); ?></option><?php
70
+ if (!empty($options['postAs'])) { $pgi = str_ireplace('selected="selected" ','',$pgi); $pgi = str_ireplace('value="'.$options['postAs'].'"','selected="selected" value="'.$options['postAs'].'"',$pgi); } echo $pgi;
71
+ ?><option value="a"><?php _e('.... Enter the Page ID'); ?></option>
72
+ </select><input type="hidden" id="gpPostAsNm<?php echo $ii; ?>" name="gp[<?php echo $ii;?>][postAsNm]" value="<?php echo $options['postAsNm']; ?>"><div id="nxsGPInfoDivBlock<?php echo $ii; ?>" style="display: inline-block;"> <input type="text" style="display: none;" id="gpPstAsCst<?php echo $ii; ?>" value="<?php echo $options['postAs']; ?>" onchange="nxs_InpToDDChange(jQuery(this));" data-tid="gpPostAs<?php echo $ii; ?>" />
73
+ <div style="display: inline-block;"><a onclick="nxs_gpGetAllInfo(<?php echo $ii;?>, 1); jQuery(this).blur(); return false;" href="#"><img id="<?php echo $nt.$ii;?>rfrshImg" style="vertical-align: middle;" src='<?php echo NXS_PLURL; ?>img/refresh16.png' /></a></div></div> <img id="<?php echo $nt.$ii;?>ldImg" style="display: none;vertical-align: middle;" src='<?php echo NXS_PLURL; ?>img/ajax-loader-sm.gif' />
74
+ </div>
75
+ </div>
76
+ </div>
77
 
78
+ <br/><div style="width:100%;"><b><?php _e('Where to post:', 'nxs_snap'); ?></b>&nbsp;(<?php _e('Could be profile, page, collection or community', 'nxs_snap'); ?>)</div>
79
+ <div id="nxsGPInfoDiv<?php echo $ii; ?>">
80
+ <div style="width:100%;">
81
+ <div>
82
+ <select id="gpWhToPost<?php echo $ii; ?>" onchange="nxs_gpWhToPostChange('<?php echo $ii;?>',jQuery(this));" name="gp[<?php echo $ii;?>][postTo]">
83
+ <?php $pgi = !empty($options['whToList'])?$options['whToList']:'';
84
+ if (!empty($options['postTo'])) { echo (empty($pgi) || (!empty($pgi) && stripos($pgi,$options['postTo']))===false)?'<option selected="selected" value="'.$options['postTo'].'">'.$options['postTo'].'</option>':''; }
85
+ ?><option <?php if (empty($options['postTo']) || $options['postTo']=='p') echo 'selected="selected"' ?> value="p"><?php echo (!empty($options['postAsNm'])&& $options['postAs']!='p')?$options['postAsNm']:__('Profile'); ?></option><?php
86
+ if (!empty($options['postTo'])) { $pgi = str_ireplace('selected="selected" ','',$pgi); $pgi = str_ireplace('value="'.$options['postTo'].'"','selected="selected" value="'.$options['postTo'].'"',$pgi); } echo $pgi;
87
+ ?><option value="a"><?php _e('.... Enter the Collection or Community ID'); ?></option>
88
+ </select><div id="nxsGPInfoDivBlock<?php echo $ii; ?>" style="display: inline-block;"> <input type="text" style="display: none;" id="gpPgIDcst<?php echo $ii; ?>" value="<?php echo $options['postTo']; ?>" onchange="nxs_InpToDDChange(jQuery(this));" data-tid="gpWhToPost<?php echo $ii; ?>" /> </div>
89
+ </div>
90
+ </div>
91
+ <div id="nxsGPMsgDiv<?php echo $ii; ?>"><?php if (!empty($options['uMsg'])) echo $options['uMsg']; ?><?php if ($isNew) { ?><?php _e('Please enter your login/password to see the list of your pages, collections, and communities', 'nxs_snap'); ?><?php } ?></div>
92
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
 
94
+ <div id="nxsGPInfoDivComm<?php echo $ii; ?>" style="padding-left:15px; display: <?php echo (!empty($options['postTo']) && substr($options['postTo'],0,1)=='c')?'block':'none'; ?>;"><b><?php _e('Community Category:', 'nxs_snap'); ?></b>
95
+ <div style="padding-left:15px;">
96
+ <select id="gpCommCat<?php echo $ii; ?>" name="gp[<?php echo $ii;?>][commCat]">
97
+ <?php $pgi = (!empty($options['commCatsList']))?$options['commCatsList']:'';
98
+ if (!empty($options['commCat'])) { $pgi = str_ireplace('selected="selected" ','',$pgi); $pgi = str_ireplace('value="'.$options['commCat'].'"','selected="selected" value="'.$options['commCat'].'"',$pgi); } echo $pgi;
99
+ ?></select>
100
+ </div></div>
101
 
102
+
103
+ <br/><br/>
104
+ <div style="width:100%;"><strong id="altFormatText">Post Type:</strong>&lt;-- (<a id="showShAtt" onmouseout="hidePopShAtt('<?php echo $ii; ?>XG');" onmouseover="showPopShAtt('<?php echo $ii; ?>XG', event);" onclick="return false;" class="underdash" href="http://www.nextscripts.com/blog/"><?php _e('What\'s the difference?', 'nxs_snap'); ?></a>) </div>
105
+ <div style="margin-left: 10px;">
106
+ <input type="radio" name="gp[<?php echo $ii; ?>][postType]" value="T" <?php if ($options['postType'] == 'T') echo 'checked="checked"'; ?> /> <?php _e('Text Post', 'nxs_snap'); ?> - <i><?php _e('just text message', 'nxs_snap'); ?></i><br/>
107
+ <input type="radio" name="gp[<?php echo $ii; ?>][postType]" value="I" <?php if ($options['postType'] == 'I') echo 'checked="checked"'; ?> /> <?php _e('Google+ Image Post', 'nxs_snap'); ?> - <i><?php _e('big image with text message', 'nxs_snap'); ?></i><br/>
108
+ <input type="radio" name="gp[<?php echo $ii; ?>][postType]" value="A" <?php if ( !isset($options['postType']) || $options['postType'] == '' || $options['postType'] == 'A') echo 'checked="checked"'; ?> /> <?php _e('Add blogpost to Google+ message as an attachment', 'nxs_snap'); ?><br/>
109
+ <div class="popShAtt" id="popShAtt<?php echo $ii; ?>XG"><h3><?php _e('Google+ Post Types', 'nxs_snap'); ?></h3><img src="<?php echo NXS_PLURL; ?>img/gpPostTypesDiff6.png" width="600" height="285" alt="<?php _e('Google+ Post Types', 'nxs_snap'); ?>"/></div>
110
+ </div><br/>
111
+
112
+ <script type="text/javascript">
113
+ jQuery('#apGPUName<?php echo $ii; ?>').change(function() { var u = jQuery(this).val(); var p = jQuery('#apGPPass<?php echo $ii; ?>').val(); if( u!='' && p!='' ) { nxs_gpGetAllInfo(<?php echo $ii; ?>,0); } });
114
+ jQuery('#apGPPass<?php echo $ii; ?>').change(function() { var u = jQuery('#apGPUName<?php echo $ii; ?>').val(); var p = jQuery(this).val(); if( u!='' && p!='' ) { nxs_gpGetAllInfo(<?php echo $ii; ?>,0); } });
115
+ </script> <?php $this->elemMsgFormat($ii,'Message Format','msgFormat',$options['msgFormat']);
116
  }
117
+ function advTab($ii, $options){}
118
  //#### Set Unit Settings from POST
119
+ function setNTSettings($post, $options){
120
  foreach ($post as $ii => $pval){
121
+ if (!empty($pval['uPass']) && !empty($pval['uPass'])){ if (!isset($options[$ii])) $options[$ii] = array(); $options[$ii] = $this->saveCommonNTSettings($pval,$options[$ii]);
122
+ //if (empty($options[$ii]['pageID'])) { $loginError = $nt->connect($pval['uName'], $pval['uPass']); if (!$loginError){ $nt->getPgsCmns($pval['pageID']); }
123
+ if (isset($pval['postTo'])) $options[$ii]['postTo'] = trim($pval['postTo']);
124
+ if (isset($pval['postAs'])) $options[$ii]['postAs'] = trim($pval['postAs']); if (isset($pval['postAsNm'])) $options[$ii]['postAsNm'] = trim($pval['postAsNm']);
125
+ if (isset($pval['commCat'])) $options[$ii]['commCat'] = trim($pval['commCat']);
126
+ if (isset($pval['postType'])) $options[$ii]['postType'] = trim($pval['postType']); else $options[$ii]['postType'] = 'A';
127
+ } elseif ( count($pval)==1 ) if (isset($pval['do'])) $options[$ii]['do'] = $pval['do']; else $options[$ii]['do'] = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
128
  } return $options;
129
+ }
130
+
131
+ //#### Show Post->Edit Meta Box Settings
132
+ function showEdPostNTSettings($ntOpts, $post){ $post_id = $post->ID; $nt = $this->ntInfo['lcode']; $ntU = $this->ntInfo['code'];
133
+ foreach($ntOpts as $ii=>$ntOpt) { $isFin = $this->checkIfSetupFinished($ntOpt); if (!$isFin) continue;
134
+ $pMeta = maybe_unserialize(get_post_meta($post_id, 'snap'.$ntU, true)); if (is_array($pMeta) && !empty($pMeta[$ii])) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
 
136
+ if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = ''; if (empty($ntOpt['urlToUse'])) $ntOpt['urlToUse'] = ''; $postType = isset($ntOpt['postType'])?$ntOpt['postType']:'';
137
+ $msgFormat = !empty($ntOpt['msgFormat'])?htmlentities($ntOpt['msgFormat'], ENT_COMPAT, "UTF-8"):''; $msgTFormat = !empty($ntOpt['msgTFormat'])?htmlentities($ntOpt['msgTFormat'], ENT_COMPAT, "UTF-8"):'';
138
+ $imgToUse = $ntOpt['imgToUse']; $urlToUse = $ntOpt['urlToUse']; $ntOpt['ii']=$ii;
139
+
140
+ $this->nxs_tmpltAddPostMeta($post, $ntOpt, $pMeta); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
141
 
142
+ <?php $this->elemEdMsgFormat($ii, __('Message Format:', 'social-networks-auto-poster-facebook-twitter-g'),$msgFormat);
143
+ ?>
144
+ <tr class="nxstbldo <?php echo 'nxstbldo'.strtoupper($nt).$ii; ?>"><th scope="row" style="text-align:right; width:150px; vertical-align:top; padding-top: 0px; padding-right:10px;"> <?php _e('Post Type:', 'social-networks-auto-poster-facebook-twitter-g') ?> <br/></th><td>
145
+ <input type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][postType]" value="T" <?php if ($postType == 'T') echo 'checked="checked"'; ?> /> <?php _e('Text Post', 'social-networks-auto-poster-facebook-twitter-g') ?> - <i><?php _e('just text message', 'social-networks-auto-poster-facebook-twitter-g') ?></i><br/>
146
+ <input type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][postType]" value="I" <?php if ($postType == 'I') echo 'checked="checked"'; ?> /> <?php _e('Image Post', 'social-networks-auto-poster-facebook-twitter-g') ?> - <i><?php _e('Text with Image', 'social-networks-auto-poster-facebook-twitter-g') ?></i><br/>
147
+ <input type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][postType]" value="A" <?php if ( empty($postType) || $postType == 'A') echo 'checked="checked"'; ?> /><?php _e('Text Post with "attached" blogpost', 'social-networks-auto-poster-facebook-twitter-g') ?>
148
+ </td></tr>
149
+ <?php
150
+ /* ## Select Image & URL ## */ nxs_showImgToUseDlg($nt, $ii, $imgToUse); nxs_showURLToUseDlg($nt, $ii, $urlToUse); $this->nxs_tmpltAddPostMetaEnd($ii);
151
  }
152
+ }
153
  //#### Save Meta Tags to the Post
154
+ function adjMetaOpt($optMt, $pMeta){ $optMt = $this->adjMetaOptG($optMt, $pMeta);
155
+ //if (!empty($pMeta['igBoard'])) $optMt['igBoard'] = $pMeta['igBoard'];
 
 
 
 
 
 
156
  return $optMt;
 
 
 
 
 
 
 
 
 
157
  }
158
+
159
+ function adjPublishWP(&$options, &$message, $postID){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
 
161
  }
162
+ //## GP Specific
163
+ function getListOfPages($networks){ $opVal = array(); $pass = 'g9c1a'.nsx_doEncode($_POST['p']); $opNm = 'nxs_snap_gp_'.sha1('nxs_snap_gp'.$_POST['u'].$pass); $opVal = nxs_getOption($opNm); $ii = $_POST['ii']; $nt = new nxsAPI_GP(); // prr($opVal);
164
+ $currPstAs = !empty($_POST['pstAs'])?$_POST['pstAs']:(!empty($networks['gp'][$ii])?$networks['gp'][$ii]['postAs']:'');
165
+ if (empty($_POST['force']) && !empty($opVal['ck']) && !empty($opVal['pgsList']) ) $pgs = $opVal['pgsList']; else { if (!empty($opVal['ck'])) $nt->ck = $opVal['ck']; $loginError=$nt->connect($_POST['u'],$_POST['p']);
166
+ if (!$loginError){ $opVal['ck'] = $nt->ck; $pgs = $nt->getPgsList($currPstAs); }
167
+ else { $outMsg = '<b style="color:red;">'.__('Login Problem').'&nbsp;-&nbsp;'.$loginError.'</b>'; if (!empty($_POST['isOut'])) echo $outMsg; return $outMsg; }
168
+ } $pgCust = (!empty($pgs) && !empty($currPstAs) && stripos($pgs,$currPstAs)===false)?'<option selected="selected" value="'.$currPstAs.'">'.$currPstAs.'</option>':'';
169
+ if (!empty($_POST['isOut'])) echo $pgCust.'<option '.($currPstAs=='p'?'selected="selected" ':'').'value="p">'.__('Profile').'</option>'.$pgs.'<option style="color:#BD5200" value="a">'.__('...enter the Page ID').'</option>';
170
+ $opVal['pgsList'] = $pgs; nxs_saveOption($opNm, $opVal); return $opVal;
171
+ }
172
+ function getListWhereToPost($networks){ $opVal = array(); $pass = 'g9c1a'.nsx_doEncode($_POST['p']); $ii = $_POST['ii']; $nt = new nxsAPI_GP();
173
+ $currPstAs = !empty($_POST['pstAs'])?$_POST['pstAs']:(!empty($networks['gp'][$ii])?$networks['gp'][$ii]['postAs']:''); $currPg = !empty($_POST['pg'])?$_POST['pg']:(!empty($networks['gp'][$ii])?$networks['gp'][$ii]['postTo']:'');
174
+ $opNm = 'nxs_snap_gp_'.sha1('nxs_snap_gp'.$_POST['u'].$pass); $opVal = nxs_getOption($opNm); $opNm2 = 'nxs_snap_gp_wh'.sha1('nxs_snap_gpwh'.$_POST['u'].$pass.$currPstAs); $opVal2 = nxs_getOption($opNm2);
175
+
176
+ if (empty($_POST['force']) && !empty($opVal['ck']) && !empty($opVal2['whToList']) ) $pgs = $opVal2['whToList']; else { if (!empty($opVal['ck'])) $nt->ck = $opVal['ck']; $loginError=$nt->connect($_POST['u'],$_POST['p']);
177
+ if (!$loginError){ $opVal['ck'] = $nt->ck; $pgs = $nt->getWhereToPostList($currPg, $currPstAs); }
178
+ else { $outMsg = '<b style="color:red;">'.__('Login Problem').'&nbsp;-&nbsp;'.$loginError.'</b>'; if (!empty($_POST['isOut'])) echo $outMsg; return $outMsg; }
179
+ } $pgCust = (!empty($currPg) && (empty($pgs) || (!empty($pgs) && stripos($pgs,$currPg)===false)))?'<option selected="selected" value="'.$currPg.'">'.$currPg.'</option>':'';
180
+ if (!empty($_POST['isOut'])) echo $pgCust.'<option '.($currPg=='p'?'selected="selected" ':'').'value="p">'.(!empty($_POST['pstAsNm'])?$_POST['pstAsNm']:__('Profile')).'</option>'.$pgs.'<option style="color:#BD5200" value="a">'.__('...enter the Collection or Community ID').'</option>';
181
+ $opVal2['whToList'] = $pgs; nxs_saveOption($opNm2, $opVal2); return $opVal2;
182
+ }
183
+ function getGPCommInfo($networks){ $ii = $_POST['ii']; $currPgID = !empty($_POST['pg'])?$_POST['pg']:(!empty($networks['gp'][$ii])?$networks['gp'][$ii]['postTo']:'');
184
+ $opVal = array(); $pass = 'g9c1a'.nsx_doEncode($_POST['p']); $opNm = 'nxs_snap_gp_cl_'.sha1('nxs_snap_gpcl'.$_POST['u'].$pass.$currPgID); $opVal = nxs_getOption($opNm);
185
+ $currCat = !empty($_POST['comCat'])?$_POST['comCat']:(!empty($networks['gp'][$ii])?$networks['gp'][$ii]['commCat']:'');
186
+ if (empty($_POST['force']) && !empty($opVal) && !empty($opVal['commCatsList'])) {
187
+ if (!empty($currCat)) { $opVal['commCatsList'] = str_ireplace('selected="selected" ','',$opVal['commCatsList']); $opVal['commCatsList'] = str_ireplace('value="'.$currCat.'"','selected="selected" value="'.$currCat.'"',$opVal['commCatsList']); }
188
+ if (!empty($_POST['isOut'])) echo $opVal['commCatsList'];
189
+ } else { $nt = new nxsAPI_GP(); $ii = $_POST['ii']; $loginError = $nt->connect(!empty($_POST['u'])?$_POST['u']:$networks['gp'][$ii]['uName'],!empty($_POST['p'])?$_POST['p']:$networks['gp'][$ii]['uPass']);
190
+ if (!$loginError){ //!empty($networks['gp'][$ii])?$networks['gp'][$ii]['pageID']:''; echo "DX ".$currPgID;
191
+ if (!empty($currPgID) && substr($currPgID,0,1)=='c') { $currPgID = substr($currPgID,1); $opVal['commCatsList'] = $nt->getCCatsGP($currPgID,$currCat); nxs_saveOption($opNm, $opVal); if (!empty($_POST['isOut'])) echo $opVal['commCatsList']; }
192
+ } else { if (!empty($_POST['isOut'])) echo $loginError; return $loginError; }
193
+ } return $opVal;
194
+ }
195
+ }}
196
+
197
+
198
+ if (!function_exists("nxs_doPublishToGP")) { function nxs_doPublishToGP($postID, $options){ if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
199
+ ini_set('memory_limit','256M'); $cl = new nxs_snapClassGP(); $cl->nt[$options['ii']] = $options; return $cl->publishWP($options['ii'], $postID);
200
+ }}
201
  ?>
inc-cl/ig.api.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //## NextScripts Instagram Connection Class
3
+ $nxs_snapAPINts[] = array('code'=>'IG', 'lcode'=>'ig', 'name'=>'Instagram');
4
+
5
+ if (!class_exists("nxs_class_SNAP_IG")) { class nxs_class_SNAP_IG {
6
+
7
+ var $ntCode = 'IG';
8
+ var $ntLCode = 'ig';
9
+
10
+ function doPost($options, $message){ if (!is_array($options)) return false; $out = array();
11
+ foreach ($options as $ii=>$ntOpts) $out[$ii] = $this->doPostToNT($ntOpts, $message);
12
+ return $out;
13
+ }
14
+ function doPostToNT($options, $message){ $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>''); if (!class_exists("nxsAPI_IG")){ $badOut['Error'] .= "Instagram API not found"; return $badOut; }
15
+ //## Check settings
16
+ if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; } if (empty($options['uPass'])) { $badOut['Error'] = 'Not Configured'; return $badOut; }
17
+ //## Format
18
+ if (!empty($message['pText'])) $msg = $message['pText']; else $msg = nxs_doFormatMsg($options['msgFormat'], $message);
19
+ if (isset($message['imageURL'])) $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); else $imgURL = '';
20
+ $urlToGo = (!empty($message['url']))?$message['url']:''; if (empty($options['imgAct'])) $options['imgAct'] = 'E';
21
+
22
+ $msg = nsTrnc(html_entity_decode($msg) , 2200); $pass = substr($options['uPass'], 0, 5)=='g9c1a'?nsx_doDecode(substr($options['uPass'], 5)):$options['uPass'];
23
+
24
+ //## Get Saved Login Info
25
+ if (function_exists('nxs_getOption')) { $opVal = array(); $opNm = 'nxs_snap_ig_'.sha1('nxs_snap_ig'.$options['uName'].$options['uPass']); $opVal = nxs_getOption($opNm); if (!empty($opVal) & is_array($opVal)) $options = array_merge($options, $opVal); }
26
+
27
+ $nt = new nxsAPI_IG(); $nt->debug = false; if(!empty($options['ck'])) $nt->ck = $options['ck']; if (!empty($options['proxy'])&&!empty($options['proxyOn'])){ $nt->proxy['proxy'] = $options['proxy']['proxy']; if (!empty($options['proxy']['up'])) $nt->proxy['up'] = $options['proxy']['up'];};
28
+ $loginErr = $nt->connect($options['uName'], $pass);
29
+ if (!$loginErr) $ret = $nt->post($msg, $imgURL, $options['imgAct']); else { $badOut['Error'] .= 'Something went wrong - '.print_r($loginErr, true); $ret = $badOut; }
30
+
31
+ //## Save Login Info
32
+ if (function_exists('nxs_saveOption')) { if (empty($opVal['ck'])) $opVal['ck'] = ''; if (is_array($ret) && $ret['isPosted']=='1' && $opVal['ck'] != $nt->ck) { $opVal['ck'] = $nt->ck; nxs_saveOption($opNm, $opVal); } }
33
+
34
+ return $ret;
35
+ }
36
+ }}
37
+
38
+ ?>
inc-cl/ig.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //## NextScripts Instagram Connection Class (##Can't replace - it has .png)
3
+ $nxs_snapAvNts[] = array('code'=>'IG', 'lcode'=>'ig', 'name'=>'Instagram', 'type'=>'Social Networks', 'type'=>'Social Networks', 'ptype'=>'P', 'status'=>'A', 'desc'=>'Upload your blogpost\'s image to your Instagram account.');
4
+
5
+ if (!class_exists("nxs_snapClassIG")) { class nxs_snapClassIG extends nxs_snapClassNT {
6
+ var $ntInfo = array('code'=>'IG', 'lcode'=>'ig', 'name'=>'Instagram', 'defNName'=>'uName', 'tstReq' => false, 'imgAct'=>'E', 'instrURL'=>'http://www.nextscripts.com/instructions/instagram-auto-poster-setup-installation/');
7
+ var $noFuncMsg = 'Instagram doesn\'t have a built-in API for automated posts yet. <br/>You need to get a special <a target="_blank" href="http://www.nextscripts.com/api/instagram-automated-posting/">library module</a> to be able to publish your content to Instagram.';
8
+ var $noFuncMsg2 = 'Instagram API Library module NOT found.<br/><br/><span style="color:black; font-size:15px;">It looks like you got a SNAP Pro plugin with API package using "One time fee" promo offer more then a year ago. <br/>We are sorry, but Instagram was not a part of that package. <br/>As part of the offer agreement, you will be getting indefinite support and updates for Google+, Pinterest, LinkedIn, Reddit, Flipboard and all other networks what were included with your order, but Instagram and all other future networks requre an active API subscription. <a target="_blank" href="http://gd.is/expi">Please see here for more info</a></span><hr/>';
9
+ function checkIfFunc() { return class_exists('nxsAPI_IG'); }
10
+ //#### Show Common Settings
11
+ function showGenNTSettings($ntOpts){ $this->nt = $ntOpts; $this->showNTGroup(); return; }
12
+ //#### Show NEW Settings Page
13
+ function showNewNTSettings($ii){ $defO = array('nName'=>'', 'do'=>'1', 'uName'=>'', 'uPass'=>'', 'msgTFormat'=>'', 'msgFormat'=>"%TITLE% \n %HTAGS%"); $this->showGNewNTSettings($ii, $defO); }
14
+ //#### Show Unit Settings
15
+ function checkIfSetupFinished($options) { return !empty($options['uPass']); }
16
+ function accTab($ii, $options, $isNew=false){ $ntInfo = $this->ntInfo; $nt = $ntInfo['lcode']; $this->elemUserPass($ii, $options['uName'], $options['uPass']); ?> <br/ >
17
+ <div style="width:100%;"><strong id="altFormatText"><?php _e('What do to with the image', 'social-networks-auto-poster-facebook-twitter-g'); ?> :</strong>&lt;-- (<a id="showShAtt" onmouseout="hidePopShAtt('<?php echo $ii; ?>IG');" onmouseover="showPopShAtt('<?php echo $ii; ?>IG', event);" onclick="return false;" class="underdash" href="#"><?php _e('What\'s the difference?', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>) </div>
18
+ <div style="margin-left: 10px;">
19
+ <input type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][imgAct]" value="E" <?php if (empty($options['imgAct']) || $options['imgAct'] == 'E') echo 'checked="checked"'; ?> /> <?php _e('Make it Square: Extend', 'social-networks-auto-poster-facebook-twitter-g'); ?> - <i><?php _e('Image will be extended to square', 'social-networks-auto-poster-facebook-twitter-g'); ?></i><br/>
20
+ <input type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][imgAct]" value="C" <?php if (!empty($options['imgAct']) && $options['imgAct'] == 'C') echo 'checked="checked"'; ?> /> <?php _e('Make it Square: Crop', 'social-networks-auto-poster-facebook-twitter-g'); ?> - <i><?php _e('Image will be cropped to square', 'social-networks-auto-poster-facebook-twitter-g'); ?></i><br/>
21
+ <input type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][imgAct]" value="D" <?php if (!empty($options['imgAct']) && $options['imgAct'] == 'D') echo 'checked="checked"'; ?> /> <?php _e("Don't change", 'social-networks-auto-poster-facebook-twitter-g'); ?> - <i><?php _e('Image will be untouched. (Could cause "Uploaded image isn\'t in an allowed aspect ratio" Error)', 'social-networks-auto-poster-facebook-twitter-g'); ?></i><br/>
22
+ <br/></div>
23
+ <?php $this->elemMsgFormat($ii,'Pin Description Format','msgFormat',$options['msgFormat']);
24
+ }
25
+ function advTab($ii, $options){$this->showProxies($this->ntInfo['lcode'], $ii, $options);}
26
+ //#### Set Unit Settings from POST
27
+ function setNTSettings($post, $options){
28
+ foreach ($post as $ii => $pval){
29
+ if (!empty($pval['uPass']) && !empty($pval['uPass'])){ if (!isset($options[$ii])) $options[$ii] = array(); $options[$ii] = $this->saveCommonNTSettings($pval,$options[$ii]);
30
+ if (isset($pval['imgAct'])) $options[$ii]['imgAct'] = trim($pval['imgAct']); else $options[$ii]['imgAct'] = 'E';
31
+ } elseif ( count($pval)==1 ) if (isset($pval['do'])) $options[$ii]['do'] = $pval['do']; else $options[$ii]['do'] = 0;
32
+ } return $options;
33
+ }
34
+
35
+ //#### Show Post->Edit Meta Box Settings
36
+ function showEdPostNTSettings($ntOpts, $post){ $post_id = $post->ID; $nt = $this->ntInfo['lcode']; $ntU = $this->ntInfo['code'];
37
+ foreach($ntOpts as $ii=>$ntOpt) { $isFin = $this->checkIfSetupFinished($ntOpt); if (!$isFin) continue;
38
+ $pMeta = maybe_unserialize(get_post_meta($post_id, 'snap'.$ntU, true)); if (is_array($pMeta) && !empty($pMeta[$ii])) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
39
+
40
+ if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = ''; if (empty($ntOpt['urlToUse'])) $ntOpt['urlToUse'] = ''; $postType = isset($ntOpt['postType'])?$ntOpt['postType']:'';
41
+ $msgFormat = !empty($ntOpt['msgFormat'])?htmlentities($ntOpt['msgFormat'], ENT_COMPAT, "UTF-8"):''; $msgTFormat = !empty($ntOpt['msgTFormat'])?htmlentities($ntOpt['msgTFormat'], ENT_COMPAT, "UTF-8"):'';
42
+ $imgToUse = $ntOpt['imgToUse']; $urlToUse = $ntOpt['urlToUse']; $ntOpt['ii']=$ii;
43
+
44
+ $this->nxs_tmpltAddPostMeta($post, $ntOpt, $pMeta); ?>
45
+
46
+ <?php $this->elemEdMsgFormat($ii, __('Message Format:', 'social-networks-auto-poster-facebook-twitter-g'),$msgFormat);
47
+ /* ## Select Image & URL ## */ nxs_showImgToUseDlg($nt, $ii, $imgToUse); nxs_showURLToUseDlg($nt, $ii, $urlToUse); $this->nxs_tmpltAddPostMetaEnd($ii);
48
+ }
49
+ }
50
+ //#### Save Meta Tags to the Post
51
+ function adjMetaOpt($optMt, $pMeta){ $optMt = $this->adjMetaOptG($optMt, $pMeta);
52
+ //if (!empty($pMeta['igBoard'])) $optMt['igBoard'] = $pMeta['igBoard'];
53
+ return $optMt;
54
+ }
55
+
56
+ function adjPublishWP(&$options, &$message, $postID){
57
+
58
+ }
59
+
60
+ }}
61
+
62
+
63
+ if (!function_exists("nxs_doPublishToIG")) { function nxs_doPublishToIG($postID, $options){ if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
64
+ ini_set('memory_limit','256M'); $cl = new nxs_snapClassIG(); $cl->nt[$options['ii']] = $options; return $cl->publishWP($options['ii'], $postID);
65
+ }}
66
+ ?>
inc-cl/ip.api.php CHANGED
@@ -22,20 +22,20 @@ if (!class_exists("nxs_class_SNAP_IP")) { class nxs_class_SNAP_IP {
22
  function doPostToNT($options, $message){ $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>'');
23
  //## Check settings
24
  if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
25
- if (!isset($options['ipUName']) || trim($options['ipPass'])=='') { $badOut['Error'] = 'Not Configured'; return $badOut; }
26
- $dusername = $options['ipUName']; $pass = (substr($options['ipPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['ipPass'], 5)):$options['ipPass']);
27
  //## Format
28
- if (!empty($message['pText'])) $msg = $message['pText']; else $msg = nxs_doFormatMsg($options['ipMsgFormat'], $message);
29
- if (!empty($message['pTitle'])) $msgT = $message['pTitle']; else $msgT = nxs_doFormatMsg($options['ipMsgTFormat'], $message);
30
  $link = urlencode($message['url']); $desc = urlencode(substr($msgT, 0, 250)); $ext = urlencode(substr($msg, 0, 1000)); $tags = $message['tags'];
31
  if (!(preg_match("@^(https?|ftp)://[^\s/$.?#].[^\s]*$@iS", $message['url']))) return 'Error: Unvalid URL: '.$message['url'];
32
  $apicall = "https://www.instapaper.com/api/add?red=api&url=$link&title=$desc&selection=$ext";
33
- $hdrsArr = $this->nxs_getIPHeaders($dusername.':'.$pass); $cnt = wp_remote_get( $apicall, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr) );// prr($cnt);
34
 
35
- if(is_wp_error($cnt)) { $error_string = $cnt->get_error_message(); if (stripos($error_string, ' timed out')!==false) { sleep(10);
36
- $cnt = wp_remote_get( $apicall, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr) );}
37
  }
38
- if(is_wp_error($cnt)) $ret = 'Something went wrong - '.print_r($cnt, true); else {
39
  if (is_array($cnt) && stripos($cnt['body'],'bookmark_id')!==false) return array('postID'=>CutFromTo($cnt['body'],'"bookmark_id": ','}'), 'isPosted'=>1, 'postURL'=>'IP', 'pDate'=>date('Y-m-d H:i:s'));
40
  else { $ret = "Error: "; if ( is_array($cnt) && $cnt['response']['code']=='401') $ret .= " Incorrect Username/Password "; else $ret .= print_r($cnt, true); $ret .= $cnt['response']['message']; }
41
  } $badOut['Error'] .= $ret; return $badOut;
22
  function doPostToNT($options, $message){ $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>'');
23
  //## Check settings
24
  if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
25
+ if (!isset($options['uName']) || trim($options['uPass'])=='') { $badOut['Error'] = 'Not Configured'; return $badOut; }
26
+ $pass = (substr($options['uPass'], 0, 5)=='n5g9a'||substr($options['uPass'], 0, 5)=='g9c1a'||substr($options['uPass'], 0, 5)=='b4d7s')?nsx_doDecode(substr($options['uPass'], 5)):$options['uPass'];
27
  //## Format
28
+ if (!empty($message['pText'])) $msg = $message['pText']; else $msg = nxs_doFormatMsg($options['msgFormat'], $message);
29
+ if (!empty($message['pTitle'])) $msgT = $message['pTitle']; else $msgT = nxs_doFormatMsg($options['msgTFormat'], $message);
30
  $link = urlencode($message['url']); $desc = urlencode(substr($msgT, 0, 250)); $ext = urlencode(substr($msg, 0, 1000)); $tags = $message['tags'];
31
  if (!(preg_match("@^(https?|ftp)://[^\s/$.?#].[^\s]*$@iS", $message['url']))) return 'Error: Unvalid URL: '.$message['url'];
32
  $apicall = "https://www.instapaper.com/api/add?red=api&url=$link&title=$desc&selection=$ext";
33
+ $hdrsArr = $this->nxs_getIPHeaders($options['uName'].':'.$pass); $advSet = nxs_mkRemOptsArr($hdrsArr); $cnt = nxs_remote_get( $apicall, $advSet );// prr($cnt);
34
 
35
+ if(is_nxs_error($cnt)) { $error_string = $cnt->get_error_message(); if (stripos($error_string, ' timed out')!==false) { sleep(10);
36
+ $cnt = nxs_remote_get( $apicall, $advSet );}
37
  }
38
+ if(is_nxs_error($cnt)) $ret = 'Something went wrong - '.print_r($cnt, true); else {
39
  if (is_array($cnt) && stripos($cnt['body'],'bookmark_id')!==false) return array('postID'=>CutFromTo($cnt['body'],'"bookmark_id": ','}'), 'isPosted'=>1, 'postURL'=>'IP', 'pDate'=>date('Y-m-d H:i:s'));
40
  else { $ret = "Error: "; if ( is_array($cnt) && $cnt['response']['code']=='401') $ret .= " Incorrect Username/Password "; else $ret .= print_r($cnt, true); $ret .= $cnt['response']['message']; }
41
  } $badOut['Error'] .= $ret; return $badOut;
inc-cl/ip.php CHANGED
@@ -1,224 +1,67 @@
1
  <?php
2
- //## NextScripts Facebook Connection Class
3
- $nxs_snapAvNts[] = array('code'=>'IP', 'lcode'=>'ip', 'name'=>'Instapaper');
4
 
5
- if (!class_exists("nxs_snapClassIP")) { class nxs_snapClassIP {
 
 
 
 
 
 
 
 
 
 
 
6
  //#### Show Common Settings
7
- function showGenNTSettings($ntOpts){ global $nxs_plurl; $ntInfo = array('code'=>'IP', 'lcode'=>'ip', 'name'=>'Instapaper', 'defNName'=>'ipUName', 'tstReq' => false); ?>
8
- <div class="nxs_box">
9
- <div class="nxs_box_header">
10
- <div class="nsx_iconedTitle" style="margin-bottom:1px;background-image:url(<?php echo $nxs_plurl;?>img/<?php echo $ntInfo['lcode']; ?>16.png);"><?php echo $ntInfo['name']; ?>
11
- <?php $cbo = count($ntOpts); ?>
12
- <?php if ($cbo>1){ ?><div class="nsBigText"><?php echo "(".($cbo=='0'?'No':$cbo)." "; _e('accounts', 'social-networks-auto-poster-facebook-twitter-g'); echo ")"; ?></div><?php } ?>
13
- </div>
14
- </div>
15
- <div class="nxs_box_inside">
16
- <?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
17
- <p style="margin:0px;margin-left:5px;"> <img id="<?php echo $ntInfo['code'].$indx;?>LoadingImg" style="display: none;" src='<?php echo $nxs_plurl; ?>img/ajax-loader-sm.gif' />
18
- <input value="0" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" type="hidden" />
19
- <?php if ((int)$pbo['do'.$ntInfo['code']] == 1 && isset($pbo['catSel']) && (int)$pbo['catSel'] == 1) { ?> <input type="radio" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" id="rbtn<?php echo $ntInfo['lcode'].$indx; ?>" value="1" checked="checked" onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);" /> <?php } else { ?>
20
- <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1 && $pbo['catSel']!='1') echo "checked"; ?> />
21
- <?php } ?>
22
- <?php if (isset($pbo['catSel']) && (int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
23
- <?php if (isset($pbo['rpstOn']) && (int)$pbo['rpstOn'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popReActive');" onmouseover="nxs_showPopUpInfo('popReActive', event);"><?php echo "*[R]*" ?></span><?php } ?>
24
- <strong><?php _e('Auto-publish to', 'social-networks-auto-poster-facebook-twitter-g'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
25
- &nbsp;&nbsp;<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'social-networks-auto-poster-facebook-twitter-g'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>AG" href="#" onclick="doGetHideNTBlock('<?php echo $ntInfo['code'];?>' , '<?php echo $indx; ?>');return false;">[<?php _e('Show Settings', 'social-networks-auto-poster-facebook-twitter-g'); ?>]</a>&nbsp;&nbsp;
26
- <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'social-networks-auto-poster-facebook-twitter-g'); ?>]</a>
27
- </p><div id="nxsNTSetDiv<?php echo $ntInfo['code'].$indx; ?>"></div><?php //$pbo['ntInfo'] = $ntInfo; $this->showNTSettings($indx, $pbo);
28
- }?>
29
- </div>
30
- </div> <?php
31
- }
32
  //#### Show NEW Settings Page
33
- function showNewNTSettings($mgpo){ $options = array('nName'=>'', 'doIP'=>'1', 'ipUName'=>'', 'ipPageID'=>'', 'ipAttch'=>'', 'ipPass'=>''); $options['ntInfo']= array('lcode'=>'ip'); $this->showNTSettings($mgpo, $options, true);}
34
- //#### Show Unit Settings
35
- function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl; $nt = $options['ntInfo']['lcode']; $ntU = strtoupper($nt);
36
- 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'] = '';
37
- if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; ?>
38
- <div id="doIP<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>" style="max-width: 1000px; margin: 10px; border: 1px solid #808080; padding: 10px; display:none;"> <input type="hidden" name="apDoSIP<?php echo $ii; ?>" value="0" id="apDoSIP<?php echo $ii; ?>" />
39
-
40
- <div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/ip16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-instapaper-social-networks-auto-poster-wordpress/"><?php $nType="Instapaper"; printf( __( 'Detailed %s Installation/Configuration Instructions', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?></a></div>
41
-
42
- <div style="width:100%;"><strong><?php _e('Account Nickname', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'social-networks-auto-poster-facebook-twitter-g'); ?></i> </div><input name="ip[<?php echo $ii; ?>][nName]" id="ipnName<?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")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /><br/>
43
- <?php echo nxs_addQTranslSel('ip', $ii, $options['qTLng']); ?>
44
-
45
- <br/>
46
- <ul class="nsx_tabs">
47
- <li><a href="#nsx<?php echo $nt.$ii ?>_tab1"><?php _e('Account Info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li>
48
- <?php if (!$isNew) { ?> <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li> <?php } ?>
49
- </ul>
50
- <div class="nsx_tab_container"><?php /* ######################## Account Tab ####################### */ ?>
51
- <div id="nsx<?php echo $nt.$ii ?>_tab1" class="nsx_tab_content" style="background-image: url(<?php echo $nxs_plurl; ?>img/<?php echo $nt; ?>-bg.png); background-repeat: no-repeat; background-position:90% 10%;">
52
-
53
-
54
- <div style="width:100%;"><strong>Instapaper Username:</strong> </div><input name="ip[<?php echo $ii; ?>][apIPUName]" id="apIPUName" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit',htmlentities($options['ipUName'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />
55
- <div style="width:100%;"><strong>Instapaper Password:</strong> </div><input autocomplete="false" readonly onfocus="this.removeAttribute('readonly');" name="ip[<?php echo $ii; ?>][apIPPass]" id="apIPPass" type="password" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities(substr($options['ipPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['ipPass'], 5)):$options['ipPass'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /> <br/>
56
-
57
- <?php if ($isNew) { ?> <input type="hidden" name="ip[<?php echo $ii; ?>][apDoIP]" value="1" id="apDoNewIP<?php echo $ii; ?>" /> <?php } ?>
58
- <br/>
59
-
60
- <div id="altFormat" style="">
61
- <div style="width:100%;"><strong id="altFormatText"><?php _e('Post Title Format', 'social-networks-auto-poster-facebook-twitter-g'); ?></strong> (<a href="#" id="apIPTMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apIPTMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>)</div>
62
-
63
- <input name="ip[<?php echo $ii; ?>][apIPMsgTFrmt]" id="apIPMsgTFrmt" style="width: 50%;" value="<?php if ($isNew) echo "%TITLE%"; else _e(apply_filters('format_to_edit',htmlentities($options['ipMsgTFormat'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g'); ?>" onfocus="mxs_showFrmtInfo('apIPTMsgFrmt<?php echo $ii; ?>');" /><?php nxs_doShowHint("apIPTMsgFrmt".$ii); ?>
64
- </div>
65
-
66
- <div id="altFormat" style="">
67
- <div style="width:100%;"><strong id="altFormatText"><?php _e('Post Text Format', 'social-networks-auto-poster-facebook-twitter-g'); ?></strong> (<a href="#" id="apIPMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apIPMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>)</div>
68
-
69
- <textarea cols="150" rows="3" id="ip<?php echo $ii; ?>SNAPformat" name="ip[<?php echo $ii; ?>][apIPMsgFrmt]" style="width:51%;max-width: 650px;" onfocus="jQuery('#ip<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('apIPMsgFrmt<?php echo $ii; ?>');"><?php if ($isNew) echo "%EXCERPT%"; else _e(apply_filters('format_to_edit', htmlentities($options['ipMsgFormat'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g'); ?></textarea>
70
-
71
- <?php nxs_doShowHint("apIPMsgFrmt".$ii); ?>
72
- </div><br/>
73
-
74
- <?php if ($options['ipPass']!='') { ?>
75
-
76
- <b><?php _e('Test your settings', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('IP', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?></a>
77
-
78
- <?php }
79
-
80
- ?></div>
81
- <?php /* ######################## Advanced Tab ####################### */ ?>
82
- <?php if (!$isNew) { ?> <div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content">
83
-
84
- <?php nxs_showCatTagsCTFilters($nt, $ii, $options);
85
- nxs_addPostingDelaySelV3($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']);
86
- nxs_showRepostSettings($nt, $ii, $options); ?>
87
-
88
-
89
- </div> <?php } ?> <?php /* #### End of Tab #### */ ?>
90
- </div><br/> <?php /* #### End of Tabs #### */ ?>
91
-
92
- <div class="submitX nxclear" style="padding-bottom: 0px;"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'social-networks-auto-poster-facebook-twitter-g') ?>" /></div></div><?php
93
  }
 
94
  //#### Set Unit Settings from POST
95
- function setNTSettings($post, $options){ $code = 'IP'; $lcode = 'ip';
96
  foreach ($post as $ii => $pval){
97
- if (!empty($pval['apIPUName']) && !empty($pval['apIPPass'])){ if (!isset($options[$ii])) $options[$ii] = array();
98
- if (isset($pval['apIPUName'])) $options[$ii]['ipUName'] = trim($pval['apIPUName']);
99
- if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']);
100
- if (isset($pval['apIPPass'])) $options[$ii]['ipPass'] = 'n5g9a'.nsx_doEncode($pval['apIPPass']); else $options[$ii]['ipPass'] = '';
101
-
102
- if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']); else $options[$ii]['catSel'] = 0;
103
- if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
104
-
105
- if (isset($pval['apIPMsgFrmt'])) $options[$ii]['ipMsgFormat'] = trim($pval['apIPMsgFrmt']);
106
- if (isset($pval['apIPMsgTFrmt'])) $options[$ii]['ipMsgTFormat'] = trim($pval['apIPMsgTFrmt']);
107
- if (isset($pval['apDoIP'])) $options[$ii]['doIP'] = $pval['apDoIP']; else $options[$ii]['doIP'] = 0;
108
-
109
- $options[$ii] = nxs_adjRpst($options[$ii], $pval);
110
-
111
- if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']);
112
- if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
113
- if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
114
- } elseif ( count($pval)==1 ) if (isset($pval['apDo'.$code])) $options[$ii]['do'.$code] = $pval['apDo'.$code]; else $options[$ii]['do'.$code] = 0;
115
  } return $options;
116
- }
 
117
  //#### Show Post->Edit Meta Box Settings
118
- function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID; $nt = 'ip'; $ntU = 'IP';
119
- foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapIP', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
120
- $doIP = $ntOpt['doIP'] && (is_array($pMeta) || $ntOpt['catSel']!='1');
121
- $isAvailIP = $ntOpt['ipUName']!='' && $ntOpt['ipPass']!=''; $ipMsgFormat = htmlentities($ntOpt['ipMsgFormat'], ENT_COMPAT, "UTF-8"); $ipMsgTFormat = htmlentities($ntOpt['ipMsgTFormat'], ENT_COMPAT, "UTF-8");
122
- ?>
123
- <tr><th style="text-align:left;" colspan="2">
124
- <?php if ($ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='') { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
125
- <?php if (!empty($ntOpt['tagsSelX'])) { ?> <input type="hidden" class="nxs_TG" id="nxs_TG_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $ntOpt['tagsSelX']; ?>" /> <?php } ?>
126
- <?php if ($isAvailIP) { ?><input class="nxsGrpDoChb" value="1" id="doIP<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="ip[<?php echo $ii; ?>][doIP]" <?php if ((int)$doIP == 1) echo 'checked="checked" title="def"'; ?> />
127
- <?php if ($post->post_status == "publish") { ?> <input type="hidden" name="ip[<?php echo $ii; ?>][doIP]" value="<?php echo $doIP;?>"> <?php } ?> <?php } ?>
128
-
129
- <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/ip16.png);">Instapaper - <?php _e('publish to', 'social-networks-auto-poster-facebook-twitter-g') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
130
- if ($post->post_status == "publish" && $isAvailIP) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToIP_repostButton" id="rePostToIP_button" value="<?php _e('Repost to Instapaper', 'social-networks-auto-poster-facebook-twitter-g') ?>" />
131
- <?php } ?>
132
-
133
- <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
134
- ?> <span id="pstdIP<?php echo $ii; ?>" style="float: right; padding-top: 4px; padding-right: 10px;">
135
- <a style="font-size: 10px;" href="http://www.instapaper.com/u" target="_blank"><?php $nType="Instapaper"; printf( __( 'Posted on', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
136
- </span><?php } ?>
137
-
138
- </td></tr>
139
-
140
- <?php if (!$isAvailIP) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your Instapaper Account to AutoPost to Instapaper</b>
141
- <?php } else { if ($post->post_status != "publish" && function_exists('nxs_doSMAS5') ) { $ntOpt['postTime'] = get_post_time('U', false, $post_id); nxs_doSMAS5($nt, $ii, $ntOpt); } ?>
142
-
143
- <?php if ($ntOpt['rpstOn']=='1') { ?>
144
-
145
- <tr id="altFormat1" style=""><th scope="row" class="nxsTHRow">
146
- <input value="0" type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]"/><input value="nxsi<?php echo $ii; ?>ip" type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]" <?php if (!empty($ntOpt['rpstPostIncl'])) echo "checked"; ?> />
147
- </th>
148
- <td> <?php _e('Include in "Auto-Reposting" to this network.', 'social-networks-auto-poster-facebook-twitter-g') ?>
149
- </td></tr> <?php } ?>
150
-
151
-
152
- <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Title Format:', 'social-networks-auto-poster-facebook-twitter-g') ?></th>
153
- <td><input value="<?php echo $ipMsgTFormat ?>" type="text" name="ip[<?php echo $ii; ?>][SNAPformatT]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apIPTMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apIPTMsgFrmt".$ii); ?></td></tr>
154
-
155
- <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Text Format:', 'social-networks-auto-poster-facebook-twitter-g') ?></th>
156
- <td>
157
- <textarea cols="150" rows="1" id="ip<?php echo $ii; ?>SNAPformat" name="ip[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('#ip<?php echo $ii; ?>SNAPformat').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apIPMsgFrmt<?php echo $ii; ?>');"><?php echo $ipMsgFormat; ?></textarea>
158
- <?php nxs_doShowHint("apIPMsgFrmt".$ii); ?></td></tr>
159
- <?php }
160
  }
161
- }
162
- //#### Save Meta Tags to the Post
163
- function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
164
- if (isset($pMeta['SNAPformat'])) $optMt['ipMsgFormat'] = $pMeta['SNAPformat'];
165
- if (isset($pMeta['SNAPformatT'])) $optMt['ipMsgTFormat'] = $pMeta['SNAPformatT'];
166
- if (isset($pMeta['imgToUse'])) $optMt['imgToUse'] = $pMeta['imgToUse'];
167
- if (isset($pMeta['timeToRun'])) $optMt['timeToRun'] = $pMeta['timeToRun']; if (isset($pMeta['rpstPostIncl'])) $optMt['rpstPostIncl'] = $pMeta['rpstPostIncl'];
168
- if (isset($pMeta['doIP'])) $optMt['doIP'] = $pMeta['doIP'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doIP'] = 0; }
169
- if (isset($pMeta['SNAPincludeIP']) && $pMeta['SNAPincludeIP'] == '1' ) $optMt['doIP'] = 1;
170
- return $optMt;
171
  }
172
- }}
173
- if (!function_exists("nxs_rePostToIP_ajax")) {
174
- function nxs_rePostToIP_ajax() { check_ajax_referer('nxsSsPageWPN'); $postID = $_POST['id']; $options = get_option('NS_SNAutoPoster');
175
- foreach ($options['ip'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj'; //if ($two['gpPageID'].$two['gpUName']==$_POST['nid']) {
176
- $gppo = get_post_meta($postID, 'snapIP', true); $gppo = maybe_unserialize($gppo);// prr($gppo);
177
- if (is_array($gppo) && isset($gppo[$ii]) && is_array($gppo[$ii])){ $ntClInst = new nxs_snapClassIP(); $two = $ntClInst->adjMetaOpt($two, $gppo[$ii]);}
178
- $result = nxs_doPublishToIP($postID, $two); if ($result == 200) die("Successfully sent your post to Instapaper."); else die($result);
179
- }
180
  }
181
- }
182
-
183
-
184
-
185
- if (!function_exists("nxs_doPublishToIP")) { //## Second Function to Post to IP
186
- function nxs_doPublishToIP($postID, $options){ $ntCd = 'IP'; $ntCdL = 'ip'; $ntNm = 'Instapaper'; global $plgn_NS_SNAutoPoster;
187
- if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
188
- //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToIP', array($postID, $options));
189
- $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'POSTID'=>$postID, 'ACCNAME'=>$options['nName']));
190
- $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url();
191
- $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
192
- $logNT = '<span style="color:#000080">Instapaper</span> - '.$options['nName'];
193
- $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
194
- if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
195
- $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') { sleep(5);
196
- nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$uqID); return;
197
- }
198
- }
199
- if ($postID=='0') { echo "Testing ... <br/><br/>"; $urlToGo = home_url(); $options['ipMsgTFormat'] = 'Test Link from '.$urlToGo; } else { $post = get_post($postID); if(!$post) return;
200
- //## MyURL - URLToGo code
201
- $options = nxs_getURL($options, $postID, $addParams); $urlToGo = $options['urlToUse'];
202
-
203
- $options['ipMsgTFormat'] = nsFormatMessage($options['ipMsgTFormat'], $postID, $addParams); $options['ipMsgFormat'] = nsFormatMessage($options['ipMsgFormat'], $postID, $addParams);
204
- nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
205
- }
206
- $extInfo = ' | PostID: '.$postID." - ".(is_object($post)?$post->post_title:'');
207
-
208
- $t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = urlencode(implode(',',$tggs)); $tags = str_replace(' ','+',$tags);
209
- $message = array('url'=>$urlToGo, 'surl'=>$urlToGo, 'siteName'=>$blogTitle, 'tags'=>$tags);
210
- //## Actual Post
211
- $ntToPost = new nxs_class_SNAP_IP(); $ret = $ntToPost->doPostToNT($options, $message);
212
- //## Process Results
213
- if (!is_array($ret) || $ret['isPosted']!='1') { //## Error
214
- if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);
215
- } else { // ## All Good - log it.
216
- if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo _e('OK - Message Posted, please see your '.$logNT.' Page. ', 'social-networks-auto-poster-facebook-twitter-g'); }
217
- else { nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPosted'=>'1', 'pgID'=>$ret['postID'], 'pDate'=>date('Y-m-d H:i:s'))); nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); }
218
- }
219
- //## Return Result
220
- if ($ret['isPosted']=='1') return 200; else return print_r($ret, true);
221
 
222
- }
223
- }
 
 
 
 
 
224
  ?>
1
  <?php
2
+ //## NextScripts Instapaper Connection Class
3
+ $nxs_snapAvNts[] = array('code'=>'IP', 'lcode'=>'ip', 'name'=>'Instapaper', 'type'=>'Blogs/Publishing Platforms', 'ptype'=>'F', 'status'=>'A', 'desc'=>'Autopost to your account');
4
 
5
+ if (!class_exists("nxs_snapClassIP")) { class nxs_snapClassIP extends nxs_snapClassNT {
6
+ var $ntInfo = array('code'=>'IP', 'lcode'=>'ip', 'name'=>'Instapaper', 'defNName'=>'uName', 'tstReq' => false, 'instrURL'=>'http://www.nextscripts.com/setup-installation-instapaper-social-networks-auto-poster-wordpress/');
7
+
8
+ function toLatestVer($ntOpts){ if( !empty($ntOpts['v'])) $v = $ntOpts['v']; else $v = 340; $ntOptsOut = ''; switch ($v) {
9
+ case 340: $ntOptsOut = $this->toLatestVerNTGen($ntOpts); $ntOptsOut['do'] = $ntOpts['do'.$this->ntInfo['code']]; $ntOptsOut['nName'] = $ntOpts['nName'];
10
+ $ntOptsOut['msgTFormat'] = $ntOpts['ipMsgTFormat']; $ntOptsOut['msgFormat'] = $ntOpts['ipMsgFormat']; $ntOptsOut['uName'] = $ntOpts['ipUName']; $ntOptsOut['uPass'] = $ntOpts['ipPass'];
11
+ $ntOptsOut['v'] = NXS_SETV;
12
+ break;
13
+ }
14
+ return !empty($ntOptsOut)?$ntOptsOut:$ntOpts;
15
+ }
16
+
17
  //#### Show Common Settings
18
+ function showGenNTSettings($ntOpts){ $this->nt = $ntOpts; $this->showNTGroup(); return; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  //#### Show NEW Settings Page
20
+ function showNewNTSettings($ii){ $defO = array('nName'=>'', 'do'=>'1', 'uName'=>'', 'uPass'=>'', 'msgTFormat'=>'%TITLE%', 'msgFormat'=>"%FULLTEXT%"); $this->showGNewNTSettings($ii, $defO); }
21
+ //#### Show Unit Settings
22
+ function checkIfSetupFinished($options) { return !empty($options['uPass']); }
23
+ function accTab($ii, $options, $isNew=false){ $ntInfo = $this->ntInfo; $nt = $ntInfo['lcode']; $this->elemUserPass($ii, $options['uName'], $options['uPass']);
24
+ $this->elemTitleFormat($ii,'Post Title Format','msgTFormat',$options['msgTFormat']); $this->elemMsgFormat($ii,'Post Text Format','msgFormat',$options['msgFormat']);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  }
26
+ function advTab($ii, $options){}
27
  //#### Set Unit Settings from POST
28
+ function setNTSettings($post, $options){
29
  foreach ($post as $ii => $pval){
30
+ if (!empty($pval['uPass']) && !empty($pval['uPass'])){ if (!isset($options[$ii])) $options[$ii] = array(); $options[$ii] = $this->saveCommonNTSettings($pval,$options[$ii]);
31
+ } elseif ( count($pval)==1 ) if (isset($pval['do'])) $options[$ii]['do'] = $pval['do']; else $options[$ii]['do'] = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  } return $options;
33
+ }
34
+
35
  //#### Show Post->Edit Meta Box Settings
36
+ function showEdPostNTSettings($ntOpts, $post){ $post_id = $post->ID; $nt = $this->ntInfo['lcode']; $ntU = $this->ntInfo['code'];
37
+ foreach($ntOpts as $ii=>$ntOpt) { $isFin = $this->checkIfSetupFinished($ntOpt); if (!$isFin) continue;
38
+ $pMeta = maybe_unserialize(get_post_meta($post_id, 'snap'.$ntU, true)); if (is_array($pMeta) && !empty($pMeta[$ii])) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
39
+
40
+ if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = ''; if (empty($ntOpt['urlToUse'])) $ntOpt['urlToUse'] = ''; $postType = isset($ntOpt['postType'])?$ntOpt['postType']:'';
41
+ $msgFormat = !empty($ntOpt['msgFormat'])?htmlentities($ntOpt['msgFormat'], ENT_COMPAT, "UTF-8"):''; $msgTFormat = !empty($ntOpt['msgTFormat'])?htmlentities($ntOpt['msgTFormat'], ENT_COMPAT, "UTF-8"):'';
42
+ $imgToUse = $ntOpt['imgToUse']; $urlToUse = $ntOpt['urlToUse']; $ntOpt['ii']=$ii;
43
+
44
+ $this->nxs_tmpltAddPostMeta($post, $ntOpt, $pMeta); ?>
45
+ <?php $this->elemEdTitleFormat($ii, __('Title Format:', 'social-networks-auto-poster-facebook-twitter-g'),$msgTFormat); $this->elemEdMsgFormat($ii, __('Message Format:', 'social-networks-auto-poster-facebook-twitter-g'),$msgFormat); ?>
46
+
47
+ <?php
48
+
49
+ /* ## Select Image & URL ## */ nxs_showURLToUseDlg($nt, $ii, $urlToUse); $this->nxs_tmpltAddPostMetaEnd($ii);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  }
 
 
 
 
 
 
 
 
 
 
51
  }
52
+ //#### Save Meta Tags to the Post
53
+ function adjMetaOpt($optMt, $pMeta){ $optMt = $this->adjMetaOptG($optMt, $pMeta); // prr($optMt);
54
+
55
+ return $optMt;
 
 
 
 
56
  }
57
+
58
+ function adjPublishWP(&$options, &$message, $postID){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
 
60
+ }
61
+
62
+ }}
63
+
64
+ if (!function_exists("nxs_doPublishToIP")) { function nxs_doPublishToIP($postID, $options){ if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
65
+ $cl = new nxs_snapClassIP(); $cl->nt[$options['ii']] = $options; return $cl->publishWP($options['ii'], $postID);
66
+ }}
67
  ?>
inc-cl/kt.api.php DELETED
@@ -1,50 +0,0 @@
1
- <?php
2
- //## NextScripts Kippt Connection Class
3
- $nxs_snapAPINts[] = array('code'=>'KT', 'lcode'=>'kt', 'name'=>'Kippt');
4
-
5
- if (!class_exists("nxs_class_SNAP_KT")) { class nxs_class_SNAP_KT {
6
-
7
- var $ntCode = 'KT';
8
- var $ntLCode = 'kt';
9
-
10
- function doPost($options, $message){ if (!is_array($options)) return false; $out = array();
11
- foreach ($options as $ii=>$ntOpts) $out[$ii] = $this->doPostToNT($ntOpts, $message);
12
- return $out;
13
- }
14
- function nxs_getKTHeaders($ref, $uname, $pass, $post=false){ $hdrsArr = array();
15
- $hdrsArr['X-Requested-With']='XMLHttpRequest'; $hdrsArr['Connection']='keep-alive'; $hdrsArr['Referer']=$ref;
16
- $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';
17
- if($post) $hdrsArr['Content-Type']='application/x-www-form-urlencoded';
18
- $hdrsArr['Accept']='application/json, text/javascript, */*; q=0.01';
19
- //$hdrsArr['Authorization']= 'Basic '.base64_encode($uname.':'.$pass);
20
- $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;
21
- }
22
- function doPostToNT($options, $message){ $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>'');
23
- //## Check settings
24
- if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
25
- if (!isset($options['uName']) || trim($options['uPass'])=='') { $badOut['Error'] = 'Not Configured'; return $badOut; }
26
- $email = $options['uName']; $pass = substr($options['uPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['uPass'], 5)):$options['uPass'];
27
- //## Format
28
- if (!empty($message['pText'])) $msg = $message['pText']; else $msg = nxs_doFormatMsg($options['msgFormat'], $message);
29
- if (!empty($message['pTitle'])) $msgT = $message['pTitle']; else $msgT = nxs_doFormatMsg($options['msgTFrmt'], $message);
30
- //###### ===============
31
-
32
- $hdrsArr = $this->nxs_getKTHeaders('https://kippt.com/api/clips/', $email, $pass, true); $hdrsArr['X-Kippt-Username'] = $email; $hdrsArr['X-Kippt-API-Token'] = $pass;
33
- $cnt = wp_remote_get( 'https://kippt.com/api/lists/', array( 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr)); $lists = json_decode($cnt['body'], true);
34
- foreach ($lists['objects'] as $list) if ($list['slug'] == $options['list']) $listID = $list['resource_uri']; if (empty($listID)) $listID = '';
35
- $flds = array(); $flds['url']=$message['url']; $flds['notes']=$msg; $flds['title']=$msgT; $flds['list']=$listID; $flds = json_encode($flds); // prr($flds);
36
- $cnt = wp_remote_post( 'https://kippt.com/api/clips/', array( 'method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds));
37
- if (is_wp_error($cnt) || empty($cnt['body']) || $cnt['response']['code']!='201') return "ERROR: ".print_r($cnt, true);
38
-
39
- //prr($cnt['body']);
40
-
41
- //## Return
42
- if (stripos($cnt['body'],'"resource_uri": "')!==false) {
43
- $pid = CutFromTo($cnt['body'], '"resource_uri": "', '"'); $purl = 'https://kippt.com'.CutFromTo($cnt['body'], '"app_url": "', '"');
44
- return array('postID'=>$pid, 'isPosted'=>1, 'postURL'=>$purl, 'pDate'=>date('Y-m-d H:i:s'));
45
- } else { $badOut['Error'] .= print_r($cnt, true);
46
- return $badOut;
47
- }
48
- }
49
- }}
50
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc-cl/kt.php DELETED
@@ -1,206 +0,0 @@
1
- <?php
2
- //## NextScripts Facebook Connection Class
3
- $nxs_snapAvNts[] = array('code'=>'KT', 'lcode'=>'kt', 'name'=>'Kippt');
4
-
5
- if (!class_exists("nxs_snapClassKT")) { class nxs_snapClassKT { var $ntInfo = array('code'=>'KT', 'lcode'=>'kt', 'name'=>'Kippt', 'defNName'=>'uName', 'tstReq' => false);
6
- //#### Show Common Settings
7
- function showGenNTSettings($ntOpts){ global $nxs_plurl, $nxs_snapSetPgURL; $ntInfo = $this->ntInfo;
8
- $ntParams = array('ntInfo'=>$ntInfo, 'nxs_plurl'=>$nxs_plurl, 'ntOpts'=>$ntOpts, 'chkField'=>'uPass'); nxs_showListRow($ntParams);
9
- }
10
-
11
- //#### Show NEW Settings Page
12
- function showNewNTSettings($mgpo){ $options = array('nName'=>'', 'doKT'=>'1', 'uName'=>'', 'uPass'=>''); $options['ntInfo']= array('lcode'=>'kt'); $this->showNTSettings($mgpo, $options, true);}
13
-
14
- //#### Show Unit Settings
15
- function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl; $nt = $options['ntInfo']['lcode']; $ntU = strtoupper($nt);
16
- 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'] = '';
17
- if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; ?>
18
- <div id="doKT<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew){ ?> clNewNTSets<?php } ?>"> <input type="hidden" name="apDoSKT<?php echo $ii; ?>" value="0" id="apDoSKT<?php echo $ii; ?>" />
19
-
20
- <div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/<?php echo $nt; ?>16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/instructions/kippt-social-networks-auto-poster-setup-installation/"><?php $nType="Kippt"; printf( __( 'Detailed %s Installation/Configuration Instructions', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?></a></div>
21
-
22
- <div style="width:100%;"><strong><?php _e('Account Nickname', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'social-networks-auto-poster-facebook-twitter-g'); ?></i> </div><input name="<?php echo $nt; ?>[<?php echo $ii; ?>][nName]" id="nName<?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")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /><br/>
23
- <?php echo nxs_addQTranslSel($nt, $ii, $options['qTLng']); ?>
24
-
25
- <br/>
26
- <ul class="nsx_tabs">
27
- <li><a href="#nsx<?php echo $nt.$ii ?>_tab1"><?php _e('Account Info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li>
28
- <?php if (!$isNew) { ?> <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li> <?php } ?>
29
- </ul>
30
- <div class="nsx_tab_container"><?php /* ######################## Account Tab ####################### */ ?>
31
- <div id="nsx<?php echo $nt.$ii ?>_tab1" class="nsx_tab_content" style="background-image: url(<?php echo $nxs_plurl; ?>img/<?php echo $nt; ?>-bg.png); background-repeat: no-repeat; background-position:90% 10%;">
32
-
33
-
34
-
35
- <div style="width:100%;"><strong><?php echo $nType; ?> Username:</strong> </div><input name="<?php echo $nt; ?>[<?php echo $ii; ?>][uName]" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['uName'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />
36
-
37
- <div style="width:100%;"><strong><?php echo $nType; ?> Token:</strong> <span style="font-size: 11px; margin: 0px;">Get it from <a target="_blank" href="http://developers.kippt.com/">developers.kippt.com</a>.</span></div><input name="<?php echo $nt; ?>[<?php echo $ii; ?>][uPass]" 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")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /> <br/>
38
-
39
- <div style="width:100%;"><strong><?php echo $nType; ?> List:</strong> </div><input name="<?php echo $nt; ?>[<?php echo $ii; ?>][list]" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['list'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />
40
- <br/><br/>
41
- <?php if ($isNew) { ?> <input type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][apDo<?php echo $ntU; ?>]" value="1" id="apDoNew<?php echo $ntU; ?><?php echo $ii; ?>" /> <?php } ?><br/>
42
-
43
-
44
- <div style="width:100%;"><strong id="altFormatText"><?php _e('Post Title Format', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> (<a href="#" id="msgFrmtT<?php echo $ntU.$ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('msgFrmtT<?php echo $ntU.$ii; ?>'); return false;"><?php _e('Show format info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>)</div>
45
- <input name="<?php echo $nt; ?>[<?php echo $ii; ?>][msgTFrmt]" style="width: 50%;" value="<?php if (!empty($options['msgTFrmt'])) _e(apply_filters('format_to_edit', htmlentities($options['msgTFrmt'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g'); else echo "%TITLE%"; ?>" onfocus="mxs_showFrmtInfo('msgFrmtT<?php echo $ntU.$ii; ?>');" /><?php nxs_doShowHint("msgFrmtT".$ntU.$ii); ?><br/>
46
-
47
-
48
-
49
- <div id="altFormat" style="margin-left: 0px;">
50
- <div style="width:100%;"><strong id="altFormatText"><?php _e('Text Format', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> (<a href="#" id="msgFrmt<?php echo $ntU; ?><?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('msgFrmt<?php echo $ntU; ?><?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>)
51
- </div>
52
- <textarea cols="150" rows="3" id="<?php echo $nt; ?><?php echo $ii; ?>msgFrmt" name="<?php echo $nt; ?>[<?php echo $ii; ?>][msgFrmt]" style="width:51%;max-width: 650px;" onfocus="jQuery('#<?php echo $nt; ?><?php echo $ii; ?>msgFrmt').attr('rows', 6); mxs_showFrmtInfo('msgFrmt<?php echo $ntU.$ii; ?>');"><?php if ($isNew) _e("%EXCERPT%", 'social-networks-auto-poster-facebook-twitter-g'); else _e(apply_filters('format_to_edit', htmlentities($options['msgFrmt'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g'); ?></textarea><?php nxs_doShowHint("msgFrmt".$ntU.$ii); ?>
53
- </div>
54
-
55
- <?php if ($options['uPass']!='') { ?>
56
-
57
- <b><?php _e('Test your settings', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('<?php echo $ntU; ?>', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?></a> <?php }
58
- ?>
59
- </div>
60
- <?php /* ######################## Advanced Tab ####################### */ ?>
61
- <?php if (!$isNew) { ?> <div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content">
62
-
63
- <?php nxs_showCatTagsCTFilters($nt, $ii, $options);
64
- nxs_addPostingDelaySelV3($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']);
65
- nxs_showRepostSettings($nt, $ii, $options); ?>
66
-
67
- </div> <?php } ?> <?php /* #### End of Tab #### */ ?>
68
- </div><br/> <?php /* #### End of Tabs #### */ ?>
69
-
70
- <div class="submit nxclear" style="padding-bottom: 0px;"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'social-networks-auto-poster-facebook-twitter-g') ?>" /></div>
71
- </div><?php
72
- }
73
- //#### Set Unit Settings from POST
74
- function setNTSettings($post, $options){ $code = 'KT'; $lcode = 'kt';
75
- foreach ($post as $ii => $pval){
76
- if (!empty($pval['uName']) && !empty($pval['uPass'])){ if (!isset($options[$ii])) $options[$ii] = array();
77
- if (isset($pval['uName'])) $options[$ii]['uName'] = trim($pval['uName']);
78
- if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']);
79
- if (isset($pval['uPass'])) $options[$ii]['uPass'] = 'n5g9a'.nsx_doEncode($pval['uPass']); else $options[$ii]['uPass'] = '';
80
- if (isset($pval['list'])) $options[$ii]['list'] = trim($pval['list']);
81
-
82
- if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']); else $options[$ii]['catSel'] = 0;
83
- if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
84
-
85
- if (isset($pval['msgFrmt'])) $options[$ii]['msgFrmt'] = trim($pval['msgFrmt']);
86
- if (isset($pval['msgTFrmt'])) $options[$ii]['msgTFrmt'] = trim($pval['msgTFrmt']);
87
-
88
- if (isset($pval['apDoKT'])) $options[$ii]['doKT'] = $pval['apDoKT']; else $options[$ii]['doKT'] = 0;
89
-
90
- $options[$ii] = nxs_adjRpst($options[$ii], $pval);
91
-
92
- if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']);
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']);
95
- } elseif ( count($pval)==1 ) if (isset($pval['apDo'.$code])) $options[$ii]['do'.$code] = $pval['apDo'.$code]; else $options[$ii]['do'.$code] = 0;
96
- } return $options;
97
- }
98
- //#### Show Post->Edit Meta Box Settings
99
- function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID; $nt = $this->ntInfo['lcode']; $ntU = $this->ntInfo['code'];
100
- foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snap'.$ntU, true));
101
- if (is_array($pMeta) && isset($pMeta[$ii]) && is_array($pMeta[$ii])) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]); if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = '';
102
- $doIT = $ntOpt['do'.$ntU] && (is_array($pMeta) || $ntOpt['catSel']!='1'); $imgToUse = $ntOpt['imgToUse']; if (empty($ntOpt['urlToUse'])) $ntOpt['urlToUse'] = ''; $urlToUse = $ntOpt['urlToUse'];
103
- $isAvail = $ntOpt['uPass']!='' && $ntOpt['uName']!=''; $msgFormat = htmlentities($ntOpt['msgFrmt'], ENT_COMPAT, "UTF-8"); $msgFormatT = htmlentities($ntOpt['msgTFrmt'], ENT_COMPAT, "UTF-8");
104
- ?>
105
- <tr><th style="text-align:left;" colspan="2">
106
- <?php if ($ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='') { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
107
- <?php if (!empty($ntOpt['tagsSelX'])) { ?> <input type="hidden" class="nxs_TG" id="nxs_TG_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $ntOpt['tagsSelX']; ?>" /> <?php } ?>
108
- <?php if ($isAvail) { ?> <input type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][do<?php echo $ntU; ?>]" value="<?php echo ($post->post_status == "publish")?$doIT:'0';?>">
109
- <input class="nxsGrpDoChb" value="1" id="do<?php echo $ntU.$ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][do<?php echo $ntU; ?>]" <?php if ((int)$doIT == 1) echo 'checked="checked" title="def"'; ?> />
110
- <?php } ?>
111
-
112
- <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/<?php echo $nt; ?>16.png);"><?php echo $this->ntInfo['name']; ?> - <?php _e('publish to', 'social-networks-auto-poster-facebook-twitter-g') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
113
- if ($post->post_status == "publish" && $isAvail) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostTo<?php echo $ntU; ?>_repostButton" id="rePostTo<?php echo $ntU; ?>_button" value="<?php _e('Repost to '.$this->ntInfo['name'], 'social-networks-auto-poster-facebook-twitter-g') ?>" />
114
- <?php } ?>
115
-
116
- <?php if (is_array($pMeta) && isset($pMeta[$ii]) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
117
-
118
- ?> <span id="pstd<?php echo $ntU; ?><?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
119
- <a style="font-size: 10px;" href="<?php echo $pMeta[$ii]['postURL']; ?>" target="_blank"><?php $nType=$this->ntInfo['name']; printf( __( 'Posted on', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
120
- </span><?php } ?>
121
-
122
- </td></tr>
123
-
124
- <?php if (!$isAvail) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your <?php echo $this->ntInfo['name']; ?> Account to AutoPost to <?php echo $this->ntInfo['name']; ?></b></td></tr>
125
- <?php } else { if ($post->post_status != "publish" && function_exists('nxs_doSMAS5') ) { $ntOpt['postTime'] = get_post_time('U', false, $post_id); nxs_doSMAS5($nt, $ii, $ntOpt); } ?>
126
-
127
- <?php if ($ntOpt['rpstOn']=='1') { ?>
128
-
129
- <tr id="altFormat1" style=""><th scope="row" class="nxsTHRow">
130
- <input value="0" type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]"/><input value="nxsi<?php echo $ii; ?>ap" type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]" <?php if (!empty($ntOpt['rpstPostIncl'])) echo "checked"; ?> />
131
- </th>
132
- <td> <?php _e('Include in "Auto-Reposting" to this network.', 'social-networks-auto-poster-facebook-twitter-g') ?>
133
- </td></tr> <?php } ?>
134
-
135
- <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Title Format:', 'NS_SPAP') ?></th>
136
- <td><input value="<?php echo $msgFormatT; ?>" type="text" name="<?php echo $nt; ?>[<?php echo $ii; ?>][msgTFrmt]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('msgFrmtT<?php echo $nt.$ii; ?>');"/><?php nxs_doShowHint("msgFrmtT".$nt.$ii, '', '58'); ?></td></tr>
137
-
138
- <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Text Format:', 'social-networks-auto-poster-facebook-twitter-g') ?></th><td>
139
-
140
- <textarea cols="150" rows="1" id="<?php echo $nt.$ii; ?>msgFrmt" name="<?php echo $nt; ?>[<?php echo $ii; ?>][msgFrmt]" style="width:60%;max-width: 610px;" onfocus="jQuery('#<?php echo $nt.$ii; ?>msgFrmt').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('msgFrmt<?php echo $nt.$ii; ?>');"><?php echo $msgFormat ?></textarea> <?php nxs_doShowHint("msgFrmt".$nt.$ii, '', '58'); ?>
141
-
142
- </td></tr>
143
-
144
- <?php /* ## Select Image & URL ## */ nxs_showImgToUseDlg($nt, $ii, $imgToUse); nxs_showURLToUseDlg($nt, $ii, $urlToUse); ?>
145
- <?php }
146
-
147
- }
148
- }
149
- //#### Save Meta Tags to the Post
150
- function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
151
- if (isset($pMeta['msgFrmt'])) $optMt['msgFrmt'] = $pMeta['msgFrmt']; if (isset($pMeta['msgTFrmt'])) $optMt['msgTFrmt'] = $pMeta['msgTFrmt'];
152
- if (isset($pMeta['imgToUse'])) $optMt['imgToUse'] = $pMeta['imgToUse'];
153
- if (isset($pMeta['timeToRun'])) $optMt['timeToRun'] = $pMeta['timeToRun']; if (isset($pMeta['rpstPostIncl'])) $optMt['rpstPostIncl'] = $pMeta['rpstPostIncl'];
154
- if (isset($pMeta['doKT'])) $optMt['doKT'] = $pMeta['doKT'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doKT'] = 0; }
155
- if (isset($pMeta['SNAPincludeKT']) && $pMeta['SNAPincludeKT'] == '1' ) $optMt['doKT'] = 1;
156
- return $optMt;
157
- }
158
- }}
159
- if (!function_exists("nxs_rePostToKT_ajax")) {
160
- function nxs_rePostToKT_ajax() { check_ajax_referer('nxsSsPageWPN'); $postID = $_POST['id']; $options = get_option('NS_SNAutoPoster');
161
- foreach ($options['kt'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj'; //if ($two['gpPageID'].$two['gpUName']==$_POST['nid']) {
162
- $gppo = get_post_meta($postID, 'snapKT', true); $gppo = maybe_unserialize($gppo);// prr($gppo);
163
- if (is_array($gppo) && isset($gppo[$ii]) && is_array($gppo[$ii])){ $ntClInst = new nxs_snapClassKT(); $two = $ntClInst->adjMetaOpt($two, $gppo[$ii]); }
164
- $result = nxs_doPublishToKT($postID, $two); if ($result == 200) die("Successfully sent your post to Kippt."); else die($result);
165
- }
166
- }
167
- }
168
-
169
- if (!function_exists("nxs_doPublishToKT")) { //## Second Function to Post to KT
170
- function nxs_doPublishToKT($postID, $options){ global $nxs_ktCkArray; $ntCd = 'KT'; $ntCdL = 'kt'; $ntNm = 'Kippt'; if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
171
- // if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToDI', array($postID, $options));
172
- $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'POSTID'=>$postID, 'ACCNAME'=>$options['nName']));
173
- $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url();
174
- $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
175
- $logNT = '<span style="color:#000080">Kippt</span> - '.$options['nName'];
176
- $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
177
- if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
178
- $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') { sleep(5);
179
- nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'); return;
180
- }
181
- }
182
- if ($postID=='0') { echo "Testing ... <br/><br/>"; $link = home_url(); $options['msgFormat'] = 'Test Message from '.$link; } else {
183
- $post = get_post($postID); if(!$post) return; $link = get_permalink($postID);
184
- $options['msgFrmt'] = nsFormatMessage($options['msgFrmt'], $postID, $addParams); $options['msgTFrmt'] = nsFormatMessage($options['msgTFrmt'], $postID, $addParams);
185
- nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
186
- }
187
- $extInfo = ' | PostID: '.$postID." - ".(isset($post) && is_object($post)?$post->post_title:'');
188
- //## Create and Format message
189
- $t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = (implode(',',$tggs)); $tags = str_replace(' ','+',$tags);
190
- $message = array('url'=>$link, 'surl'=>$link, 'siteName'=>$blogTitle, 'tags'=>$tags);
191
- //## Actual Post
192
- $ntToPost = new nxs_class_SNAP_KT(); $ret = $ntToPost->doPostToNT($options, $message);
193
- //## Process Results
194
- if (!is_array($ret) || $ret['isPosted']!='1') { //## Error
195
- if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);
196
- } else { // ## All Good - log it.
197
- if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo _e('OK - Message Posted, please see your '.$logNT.' Page. ', 'social-networks-auto-poster-facebook-twitter-g'); }
198
- else {nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPosted'=>'1', 'pgID'=>$ret['postID'], 'postURL'=>$ret['postURL'], 'pDate'=>date('Y-m-d H:i:s')));
199
- nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo);
200
- }
201
- }
202
- //## Return Result
203
- if ($ret['isPosted']=='1') return 200; else return print_r($ret, true);
204
- }
205
- }
206
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc-cl/li.api.php CHANGED
@@ -8,82 +8,78 @@ if (!class_exists("nxs_class_SNAP_LI")) { class nxs_class_SNAP_LI {
8
 
9
  var $ntCode = 'LI';
10
  var $ntLCode = 'li';
11
-
12
- function postShare($tkn, $msg, $title='', $url='', $imgURL='', $dsc='') { $nURL = 'https://api.linkedin.com/v1/people/~/shares?format=json&oauth2_access_token='.$tkn;
13
- $dsc = nxs_decodeEntitiesFull(strip_tags($dsc)); $msg = strip_tags(nxs_decodeEntitiesFull($msg)); $title = nxs_decodeEntitiesFull(strip_tags($title));
14
- $xml = '<?xml version="1.0" encoding="UTF-8"?><share><comment>'.htmlspecialchars($msg, ENT_NOQUOTES, "UTF-8").'</comment>'.
15
- ($url!=''?'<content><title>'.htmlspecialchars($title, ENT_NOQUOTES, "UTF-8").'</title><submitted-url>'.$url.'</submitted-url>'.(!empty($imgURL)?'<submitted-image-url>'.$imgURL.'</submitted-image-url>':'').'<description>'.htmlspecialchars($dsc, ENT_NOQUOTES, "UTF-8").'</description></content>':'').
16
- '<visibility><code>anyone</code></visibility></share>'; $hdrsArr = array(); $hdrsArr['Content-Type']='application/xml'; // prr($xml);
17
- $wprg = array( 'method' => 'POST', 'headers' => $hdrsArr, 'httpversion' => '1.1', 'timeout' => 45, 'redirection' => 0, 'body' => $xml); $wprg['sslverify'] = false;
18
- $response = wp_remote_post($nURL, $wprg); if (is_wp_error($response) || empty($response['body'])) return "ERROR: ".print_r($response, true);
19
  $post = json_decode($response['body'], true); return $post;
20
  }
21
-
22
- function postToGroup($tkn, $msg, $title, $groupID, $url='', $imgURL='', $dsc='') { $nURL = 'https://api.linkedin.com/v1/groups/'.$groupID.'/posts?oauth2_access_token='.$tkn;
23
- $dsc = nxs_decodeEntitiesFull(strip_tags($dsc)); $msg = strip_tags(nxs_decodeEntitiesFull($msg)); $title = nxs_decodeEntitiesFull(strip_tags($title));
24
- $xml = '<?xml version="1.0" encoding="UTF-8"?><post><title>'.htmlspecialchars($title, ENT_NOQUOTES, "UTF-8").'</title>'."\n".'<summary>'.htmlspecialchars($msg, ENT_NOQUOTES, "UTF-8").'</summary>'."\n".'
25
- '.($url!=''?'<content><title>'.htmlspecialchars($title, ENT_NOQUOTES, "UTF-8").'</title>'."\n".'<submitted-url>'.$url.'</submitted-url>'."\n".(!empty($imgURL)?'<submitted-image-url>'.$imgURL.'</submitted-image-url>':'')."\n".'<description>'.htmlspecialchars($dsc, ENT_NOQUOTES, "UTF-8").'</description><category>discussion</category></content><category>discussion</category>':'').'</post>'; $hdrsArr = array(); $hdrsArr['Content-Type']='application/xml';
26
- $wprg = array( 'method' => 'POST', 'headers' => $hdrsArr, 'httpversion' => '1.1', 'timeout' => 45, 'redirection' => 0, 'body' => $xml); $wprg['sslverify'] = false;
27
- $response = wp_remote_post($nURL, $wprg);if (is_wp_error($response) || $response['response']['code']!='201') return "ERROR: ".print_r($response, true);
28
- return array('updateUrl'=>'https://www.linkedin.com/groups?home=&gid='.$groupID);
29
- }
30
 
31
  function doPost($options, $message){ if (!is_array($options)) return false; $out = array();
32
  foreach ($options as $ii=>$ntOpts) $out[$ii] = $this->doPostToNT($ntOpts, $message);
33
  return $out;
34
  }
35
- function doPostToNT($options, $message){ $badOut = array('postID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>''); $liPostID = '';
36
 
37
  //## Check settings
38
  if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
39
- if ((!isset($options['ulName']) || trim($options['uPass'])=='') && (empty($options['liOAuthVerifier']))) { $badOut['Error'] = 'Not Configured'; return $badOut; }
40
- if (empty($options['imgSize'])) $options['imgSize'] = ''; if (empty($options['liMsgFormatT'])) $options['liMsgFormatT'] = '%TITLE%';
41
  //## Format
42
- if (!empty($message['pText'])) $msg = $message['pText']; else $msg = nxs_doFormatMsg($options['liMsgFormat'], $message);
43
- if (!empty($message['pTitle'])) $msgT = $message['pTitle']; else $msgT = nxs_doFormatMsg($options['liMsgFormatT'], $message);
44
- if(empty($options['postType'])) { if ((int)$options['liAttch'] == 1 || $isNew) $options['postType'] = 'A';}
 
 
 
 
 
 
45
  if ( $options['postType'] == 'A' || $options['postType'] == 'I') {
46
  if (isset($message['imageURL'])) $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); else $imgURL = ''; if (preg_match("/noImg.\.png/i", $imgURL)) $imgURL = '';
47
- if (!empty($message['urlDescr'])) $dsc = $message['urlDescr']; else $dsc = $msg;
48
- $dsc = strip_tags($dsc); $dsc = nxs_decodeEntitiesFull($dsc); $dsc = nxs_html_to_utf8($dsc); $dsc = nsTrnc($dsc, 300);
49
  }
50
- $msg = strip_tags($msg); $msg = nxs_html_to_utf8($msg); $msgT = nxs_html_to_utf8($msgT); $urlToGo = $message['url'];
51
 
52
- if (function_exists("doConnectToLinkedIn") && $options['ulName']!='' && $options['uPass']!='') {
53
- $dusername = $options['ulName']; $pass = (substr($options['uPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['uPass'], 5)):$options['uPass']); // ??? Do we need that??????
54
- $auth = doConnectToLinkedIn($options['ulName'], $options['uPass'], $options['ii']); if ($auth!=false) { $badOut['Error'] .= "|Auth Error - ".$auth; return $badOut; }
55
- $to = $options['uPage']!=''?$options['uPage']:'https://www.linkedin.com/home'; $lnk = array(); $msg = str_ireplace('&nbsp;',' ',$msg); $msg = nsTrnc(strip_tags($msg), 700); $lnk['postTitle'] = $msgT;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  if ($options['postType'] == 'A'){ $lnk['title']=$message['urlTitle']; $lnk['desc'] = $message['urlDescr']; $lnk['url'] = $urlToGo; $lnk['img'] = $imgURL; $lnk['postType'] = 'A';}
57
  if ($options['postType'] == 'I'){ $lnk['title'] = ''; $lnk['desc']=''; $lnk['url'] = $imgURL; $lnk['img'] = $imgURL; $lnk['postType'] = 'I'; $lnk['postTitle'] = $msgT;}
58
  if ($options['postType'] == 'T'){ $lnk['postType'] = 'T'; }
59
- global $nxs_gCookiesArr; $li = new nxsAPI_LI(); $li->debug = false; if (!empty($nxs_gCookiesArr)) $li->ck = $nxs_gCookiesArr; $ret = $li->post($msg, $lnk, $to);
60
- if (is_array($ret) && !empty($ret['isPosted'])) return $ret; $liPostID = $options['uPage'];
61
- } else {
62
- if (!empty($options['isV2'])) { //## V2
63
- if ($options['grpID']!=''){
64
- try { if ($msgT == '') $msgT = ' ';
65
- if( $options['postType'] == 'A') $ret = $this->postToGroup($options['liAccessToken'], $msg, $msgT, $options['grpID'], str_replace('&', '&amp;', $urlToGo), $imgURL, $dsc);
66
- else $ret = $this->postToGroup($options['liAccessToken'], $msg, $msgT, $options['grpID']);
67
- $liPostID= 'http://www.linkedin.com/groups?gid='.$options['grpID'];
68
- } catch (Exception $o){ $ret="ERROR: ".print_r($o, true); }
69
- } else { //echo $msg ."|". nsTrnc($msgT, 200) ."|". $urlToGo ."|". $imgURL ."|". $dsc;
70
- if($options['postType'] == 'A') $ret = $this->postShare($options['liAccessToken'], $msg, nsTrnc($msgT, 200), str_replace('&', '&amp;', $urlToGo), $imgURL, $dsc);
71
- else $ret = $this->postShare($options['liAccessToken'], $msg);
72
- }
73
  } else { //## V1
74
- require_once ('apis/liOAuth.php'); $linkedin = new nsx_LinkedIn($options['liAPIKey'], $options['liAPISec']); $linkedin->oauth_verifier = $options['liOAuthVerifier'];
75
- $linkedin->request_token = new nsx_trOAuthConsumer($options['liOAuthToken'], $options['liOAuthTokenSecret'], 1);
76
- $linkedin->access_token = new nsx_trOAuthConsumer($options['liAccessToken'], $options['liAccessTokenSecret'], 1);
77
  $msg = nsTrnc($msg, 700); //prr($urlToGo); $urlToGo = urlencode($urlToGo); prr($urlToGo); die();
78
- if ($options['grpID']!=''){
79
- try{ if ($msgT == '') $msgT = ' ';
80
- if($options['postType'] == 'A') $ret = $linkedin->postToGroup($msg, $msgT, $options['grpID'], str_replace('&', '&amp;', $urlToGo), $imgURL, $dsc);
81
- else $ret = $linkedin->postToGroup($msg, $msgT, $options['grpID']);
82
- $liPostID= 'http://www.linkedin.com/groups?gid='.$options['grpID']; if ($ret=='201') $ret = array('updateUrl'=>$liPostID);
83
- } catch (Exception $o){ $ret="ERROR: ".print_r($o, true); }
84
- } else { //echo $msg ."|". nsTrnc($msgT, 200) ."|". $urlToGo ."|". $imgURL ."|". $dsc;
85
- try{ if($options['postType'] == 'A') $ret = $linkedin->postShare($msg, nsTrnc($msgT, 200), str_replace('&', '&amp;', $urlToGo), $imgURL, $dsc); else $ret = $linkedin->postShare($msg); } catch (Exception $o){ $ret="ERROR:".print_r($o, true); }
86
- }
87
  }
88
  if ($liPostID=='') $liPostID = $options['liUserInfo'];
89
  } // prr($ret);
8
 
9
  var $ntCode = 'LI';
10
  var $ntLCode = 'li';
11
+
12
+ function postShare($tkn, $msg, $pgID='', $title='', $url='', $imgURL='', $dsc='') { $nURL = 'https://api.linkedin.com/v1/'.(empty($pgID)?'people/~':'companies/'.$pgID).'/shares?format=json&oauth2_access_token='.$tkn;
13
+ $dsc = nxs_decodeEntitiesFull(strip_tags($dsc)); $msg = strip_tags(nxs_decodeEntitiesFull($msg)); $title = nxs_decodeEntitiesFull(strip_tags($title));
14
+ $toPost = array('comment'=>htmlspecialchars($msg, ENT_NOQUOTES, "UTF-8"), 'visibility'=>array('code'=>'anyone'));
15
+ if (!empty($url)) $toPost['content'] = array('submitted-url'=>$url, 'title'=>htmlspecialchars($title, ENT_NOQUOTES, "UTF-8"), 'description'=>htmlspecialchars($dsc, ENT_NOQUOTES, "UTF-8"));
16
+ if (!empty($imgURL)) $toPost['content']['submitted-image-url'] = $imgURL; $hdrsArr['Content-Type']='application/json'; $hdrsArr['x-li-format']='json'; $toPost = json_encode($toPost);
17
+ $advSet = nxs_mkRemOptsArr($hdrsArr, '', $toPost); $response = nxs_remote_post($nURL, $advSet); if (is_nxs_error($response) || empty($response['body'])) return "ERROR: ".print_r($response, true);
 
18
  $post = json_decode($response['body'], true); return $post;
19
  }
 
 
 
 
 
 
 
 
 
20
 
21
  function doPost($options, $message){ if (!is_array($options)) return false; $out = array();
22
  foreach ($options as $ii=>$ntOpts) $out[$ii] = $this->doPostToNT($ntOpts, $message);
23
  return $out;
24
  }
25
+ function doPostToNT($options, $message){ $badOut = array('postID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>''); $liPostID = ''; // prr($message); prr($options);
26
 
27
  //## Check settings
28
  if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
29
+ if ((!isset($options['uName']) || empty($options['uPass'])) && (empty($options['accessToken']))) { $badOut['Error'] = 'Not Configured'; return $badOut; }
30
+ if (empty($options['imgSize'])) $options['imgSize'] = ''; if (empty($options['msgTFormat'])) $options['msgTFormat'] = '%TITLE%'; if (empty($options['msgATFormat'])) $options['msgATFormat'] = '%TITLE%';
31
  //## Format
32
+ if (!empty($message['pText'])) $msg = $message['pText']; else $msg = nxs_doFormatMsg($options['msgFormat'], $message);
33
+ if (!empty($message['pTitle'])) $msgT = $message['pTitle']; else $msgT = nxs_doFormatMsg($options['msgTFormat'], $message);
34
+
35
+ if (!empty($message['urlTitle'])) $msgAT = $message['urlTitle']; else $msgAT = nxs_doFormatMsg($options['msgATFormat'], $message);
36
+ if (!empty($message['urlDescr'])) $msgA = $message['urlDescr']; else $msgA = nxs_doFormatMsg($options['msgAFormat'], $message);
37
+
38
+ if ($options['whToPost']=='P') { $title = nxs_doFormatMsg($options['msgCTFormat'], $message); $html = nxs_doFormatMsg($options['msgCFormat'], $message); }
39
+ if(empty($options['postType'])) $options['postType'] = 'A';
40
+
41
  if ( $options['postType'] == 'A' || $options['postType'] == 'I') {
42
  if (isset($message['imageURL'])) $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); else $imgURL = ''; if (preg_match("/noImg.\.png/i", $imgURL)) $imgURL = '';
43
+ if (empty($msgA)) $msgA = $msg; if (!empty($msgAT)) $msgAT = nxs_html_to_utf8($msgAT);
44
+ $msgA = strip_tags($msgA); $msgA = nxs_decodeEntitiesFull($msgA); if (!empty($msgA)) $msgA = nxs_html_to_utf8($msgA); $msgA = nsTrnc($msgA, 300);
45
  }
46
+ $msg = strip_tags($msg); if (!empty($msg)) $msg = nxs_html_to_utf8($msg); if (!empty($msgT)) $msgT = nxs_html_to_utf8($msgT); $urlToGo = $message['url'];
47
 
48
+ if (class_exists('nxsAPI_LI') && $options['uName']!='' && $options['uPass']!='') {
49
+ //## Get Saved Login Info
50
+ if (function_exists('nxs_getOption')) { $opVal = array(); $opNm = 'nxs_snap_li_'.sha1('nxs_snap_li'.$options['uName'].$options['uPass']); $opVal = nxs_getOption($opNm); if (!empty($opVal) & is_array($opVal)) $options = array_merge($options, $opVal); } // prr($opVal);
51
+ $uname = $options['uName']; $pass = (substr($options['uPass'], 0, 5)=='n5g9a'||substr($options['uPass'], 0, 5)=='g9c1a'||substr($options['uPass'], 0, 5)=='b4d7s')?nsx_doDecode(substr($options['uPass'], 5)):$options['uPass'];
52
+ $ck = !empty($options['ck'])?maybe_unserialize($options['ck']):''; if (!empty($ck)) $ck = nxsClnCookies($ck);
53
+ $nt = new nxsAPI_LI(); $nt->debug = false; if (!empty($ck)) $nt->ck = $ck; if (!empty($options['proxy'])&&!empty($options['proxyOn'])){ $nt->proxy['proxy'] = $options['proxy']['proxy']; if (!empty($options['proxy']['up'])) $nt->proxy['up'] = $options['proxy']['up']; }
54
+ $loginErr = $nt->connect($uname, $pass);
55
+ //## LinkedIn Email Code Verification.
56
+ if (is_array($loginErr) && !empty($loginErr['out']) ) { if (function_exists('update_option')) update_option('nxs_li_ctp_save', $loginErr['ser']); $text = $loginErr['out'];
57
+ echo "#2. LinkedIn asked you to enter verification code. Please check your email or phone, enter the code and click \"Confirm Code\""; $text = str_ireplace('This login attempt seems suspicious. ', '', $text); echo $text;
58
+ echo '<br/><input type="hidden" id="nxsLiNum" name="nxsLiNum" value="'.$options['ii'].'" /><input type="button" value="Click to Confirm Code" onclick="doCtpSave(); return false;" id="results_ok_button" name="nxs_go" class="button" /><br/><br/><div style="color:red;" id="nxsLITestResults"></div>';
59
+ ?><script type="text/javascript"> function doCtpSave(){ var u = jQuery('#verification-code').val(); var ii = jQuery('#nxsLiNum').val(); //alert(ii);
60
+ jQuery.post(ajaxurl,{s:u, i:ii, action: 'nxs_snap_aj',"nxsact":"getItFromNT", "fName":"nxsCptCheck", nt:"LI", id: 0, _wpnonce: jQuery('input#nxsSsPageWPN_wpnonce').val()}, function(j){
61
+ jQuery('#nxsLITestResults').html(j);
62
+ }, "html")
63
+ }</script> <?php return '<br/>#2. LinkedIn asked you to enter verification code<br/>';
64
+ }
65
+ if ($loginErr) { $badOut['Error'] .= 'Can\'t Connect - '.print_r($loginErr, true); return $badOut; } $options['ck'] = $nt->ck; if (function_exists('nxs_save_glbNtwrks')) nxs_save_glbNtwrks('li', $options['ii'], $nt->ck, 'ck');
66
+ if ( $options['whToPost']=='C' && !empty($options['pgcID'])) $to = 'https://www.linkedin.com/company/'.$options['pgcID']; elseif ( $options['whToPost']=='G' && !empty($options['pggID'])) $to = 'https://www.linkedin.com/groups/'.$options['pggID'];
67
+ elseif ( $options['whToPost']=='PR' ) $to = 'https://www.linkedin.com/home';
68
+
69
+ $lnk = array(); $msg = str_ireplace('&nbsp;',' ',$msg); $msg = nsTrnc(strip_tags($msg), 700); $lnk['postTitle'] = $msgT;
70
  if ($options['postType'] == 'A'){ $lnk['title']=$message['urlTitle']; $lnk['desc'] = $message['urlDescr']; $lnk['url'] = $urlToGo; $lnk['img'] = $imgURL; $lnk['postType'] = 'A';}
71
  if ($options['postType'] == 'I'){ $lnk['title'] = ''; $lnk['desc']=''; $lnk['url'] = $imgURL; $lnk['img'] = $imgURL; $lnk['postType'] = 'I'; $lnk['postTitle'] = $msgT;}
72
  if ($options['postType'] == 'T'){ $lnk['postType'] = 'T'; }
73
+ if ($options['whToPost']=='P') $ret = $nt->postToPulse($msg, $title, $html, $imgURL); else $ret = $nt->post($msg, $lnk, $to); if (is_array($ret) && !empty($ret['isPosted'])) return $ret; $liPostID = $to;
74
+ } else {
75
+ if (!empty($options['apiToUse']) && $options['apiToUse']=='liv2') { if (empty($options['pgID'])||$options['pgID']=='p') $options['pgID'] = ''; //## V2
76
+ if($options['postType'] == 'A') $ret = $this->postShare($options['accessToken'], $msg, $options['pgID'], nsTrnc($msgAT, 200), str_replace('&', '&amp;', $urlToGo), $imgURL, $msgA); else $ret = $this->postShare($options['accessToken'], $msg, $options['pgID']);
 
 
 
 
 
 
 
 
 
 
77
  } else { //## V1
78
+ require_once ('apis/liOAuth.php'); $linkedin = new nsx_LinkedIn($options['appKey'], $options['appSec']); $linkedin->oauth_verifier = $options['oAuthVerifier'];
79
+ $linkedin->request_token = new nsx_trOAuthConsumer($options['oAuthToken'], $options['oAuthTokenSecret'], 1);
80
+ $linkedin->access_token = new nsx_trOAuthConsumer($options['accessToken'], $options['accessTokenSec'], 1);
81
  $msg = nsTrnc($msg, 700); //prr($urlToGo); $urlToGo = urlencode($urlToGo); prr($urlToGo); die();
82
+ try{ if($options['postType'] == 'A') $ret = $linkedin->postShare($msg, nsTrnc($msgAT, 200), str_replace('&', '&amp;', $urlToGo), $imgURL, $msgA); else $ret = $linkedin->postShare($msg); } catch (Exception $o){ $ret="ERROR:".print_r($o, true); }
 
 
 
 
 
 
 
 
83
  }
84
  if ($liPostID=='') $liPostID = $options['liUserInfo'];
85
  } // prr($ret);
inc-cl/li.php CHANGED
@@ -7,446 +7,406 @@ if (isset($_GET['pg']) && $_GET['pg']=='nxs' && isset($_GET['ca']) && $_GET['ca'
7
  header("Cache-Control: private",false); header("Content-Type: image/jpg"); header("Content-Transfer-Encoding: binary"); echo $imageData; die();
8
  }
9
 
10
- if (function_exists("add_action")) add_action('wp_ajax_nxsCptCheck' , 'nxsCptCheck_ajax');
11
-
12
- if (!function_exists("nxsCptCheck_ajax")) { function nxsCptCheck_ajax() { global $nxs_gCookiesArr; $advSettings = array();
13
- if (!empty($_POST['c'])) { $seForDB = get_option('nxs_li_ctp_save'); $ser = maybe_unserialize($seForDB); $nxs_gCookiesArr = $ser['c']; $ck = $nxs_gCookiesArr; $flds = $ser['f'];
14
- $flds['recaptcha_response_field'] = $_POST['c']; $liObj = new nxsAPI_LI(); $hdrsArr = $liObj->headers('https://www.linkedin.com/uas/login-submit', 'https://www.linkedin.com', 'POST', false);
15
- $advSet = array('headers' => $hdrsArr, 'httpversion' => '1.1', 'timeout' => 45, 'redirection' => 0, 'cookies' => $ck, 'body' => $flds); // prr($advSet);
16
- $rep = nxs_remote_post('https://www.linkedin.com/uas/captcha-submit', $advSet); if (is_nxs_error($rep)) { $badOut = print_r($rep, true)." - ERROR"; return $badOut; } $contents2 = $rep['body'];
17
- if (stripos($contents2, '<span class="error">')!==false) { echo strip_tags(CutFromTo($contents2, '<span class="error">', '</span>')); die(); }
18
- if (stripos($contents2, '<div id="global-error">')!==false) { echo CutFromTo($contents2, '<div role="alert" class="alert error">', '</div>'); die(); }
19
- if (stripos($contents2, 'The email address or password you provided does not match our records')!==false) { echo "Invalid Login/Password"; die(); }
20
- if (stripos($contents2, 'Hmm, ')!==false) { echo "Invalid Login/Password"; die(); }
21
- if ($rep['response']['code']=='302' && !empty($rep['headers']['location']) && stripos($rep['headers']['location'], 'linkedin.com/uas/captcha-submit')!==false) echo "Wrong Captcha. Please try Again";
22
- if ($rep['response']['code']=='302' && !empty($rep['headers']['location']) && (stripos($rep['headers']['location'], 'linkedin.com/nhome')!==false || stripos($rep['headers']['location'], 'linkedin.com/home')!==false)) { echo "OK. You are In";
23
- $hdrsArr = $liObj->headers('http://www.linkedin.com/home', 'https://www.linkedin.com'); $ck = $rep['cookies'];
24
- $advSet = array('headers' => $hdrsArr, 'httpversion' => '1.1', 'timeout' => 45, 'redirection' => 0, 'cookies' => $ck); // prr($advSet);
25
- $rep = nxs_remote_get('http://www.linkedin.com/profile/edit?trk=tab_pro', $advSet); if (is_nxs_error($rep)) { $badOut = print_r($rep, true)." - ERROR"; return $badOut; } $ck = $rep['cookies'];
26
- if ($_POST['i']!='') { global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
27
- $options['li'][$_POST['i']]['ck'] = $ck; if (is_array($options)) update_option('NS_SNAutoPoster', $options);
28
- }
29
- }
30
- }
31
- if (!empty($_POST['s'])) { $seForDB = get_option('nxs_li_ctp_save'); $ser = maybe_unserialize($seForDB); $ck = $ser['c']; $flds = $ser['f'];
32
- $flds['PinVerificationForm_pinParam'] = $_POST['s']; $liObj = new nxsAPI_LI(); $hdrsArr = $liObj->headers('https://www.linkedin.com/uas/login-submit', 'https://www.linkedin.com', 'POST', true);
33
- $advSet = array('headers' => $hdrsArr, 'httpversion' => '1.1', 'timeout' => 45, 'redirection' => 0, 'cookies' => $ck, 'body' => $flds); // prr($advSet);
34
- $rep=nxs_remote_post('https://www.linkedin.com/uas/ato-pin-challenge-submit',$advSet); if (is_nxs_error($rep)) {$badOut = print_r($rep, true)." - ERROR"; return $badOut; } $contents2 = $rep['body']; // prr($rep);
35
-
36
- if (stripos($contents2, 'The email address or password you provided does not match our records')!==false) { echo "Invalid Login/Password"; die(); }
37
- if (stripos($contents2, '<div id="global-error">')!==false) { echo CutFromTo($contents2, '<div role="alert" class="alert error">', '</div>'); die(); }
38
- if (stripos($contents2, 'Hmm, ')!==false) { echo "Invalid Login/Password"; die(); }
39
- if ($rep['response']['code']=='302' && !empty($rep['headers']['location']) && stripos($rep['headers']['location'], 'linkedin.com/uas/ato-pin-challenge-submit')!==false) echo "Wrong Code. Please try Again";
40
- if ($rep['response']['code']=='302' && !empty($rep['headers']['location']) && (stripos($rep['headers']['location'], 'linkedin.com/nhome')!==false || stripos($rep['headers']['location'], 'linkedin.com/home')!==false)) echo "OK. You are In";
41
-
42
- $hdrsArr = $liObj->headers('http://www.linkedin.com/home', 'https://www.linkedin.com'); $ck = $rep['cookies'];
43
- $advSet = array('headers' => $hdrsArr, 'httpversion' => '1.1', 'timeout' => 45, 'redirection' => 0, 'cookies' => $ck); // prr($advSet);
44
- $rep = nxs_remote_get('http://www.linkedin.com/profile/edit?trk=tab_pro', $advSet); if (is_nxs_error($rep)) { $badOut = print_r($rep, true)." - ERROR"; return $badOut; } $ck = $rep['cookies'];
45
- if ($_POST['i']!='') { global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
46
- $options['li'][$_POST['i']]['ck'] = $ck; if (is_array($options)) update_option('NS_SNAutoPoster', $options);
47
- }
48
- } die();
49
- }}
50
-
51
  //## NextScripts Facebook Connection Class
52
- $nxs_snapAvNts[] = array('code'=>'LI', 'lcode'=>'li', 'name'=>'LinkedIn');
53
 
54
  if (!function_exists("nxs_ntp_time")) { function nxs_ntp_time($host='time.nist.gov') { $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); socket_connect($sock, $host, 123);
55
  $msg = "\010" . str_repeat("\0", 47); socket_send($sock, $msg, strlen($msg), 0); socket_recv($sock, $recv, 48, MSG_WAITALL); socket_close($sock);
56
  $data = unpack('N12', $recv); $timestamp = sprintf('%u', $data[9]); $timestamp -= 2208988800; return $timestamp;
57
  }}
58
 
59
- if (!class_exists("nxs_snapClassLI")) { class nxs_snapClassLI { var $ntInfo = array('code'=>'LI', 'lcode'=>'li', 'name'=>'LinkedIn', 'defNName'=>'ulName', 'tstReq' => true);
60
- //#### Show Common Settings
61
- function showGenNTSettings($ntOpts){ global $nxs_snapSetPgURL, $nxs_plurl, $nxs_gOptions; $ntInfo = $this->ntInfo;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  // V2 Auth
63
- if ( isset($_GET['code']) && $_GET['code']!='' && isset($_GET['state']) && substr($_GET['state'], 0, 7) == 'nxs-li-'){ $at = $_GET['code']; $ii = str_replace('nxs-li-','',$_GET['state']);
64
- echo "----=={ oAuth 2.0 Wordflow }==----<br/>-= This is normal technical authorization info that will dissapear (Unless you get some errors) =- <br/><br/><br/>";
65
- $gGet = $_GET; unset($gGet['code']); unset($gGet['state']); unset($gGet['post_type']); $sturl = explode('?',$nxs_snapSetPgURL); $nxs_snapSetPgURL = $sturl[0].((!empty($gGet))?'?'.http_build_query($gGet):'');
66
-
67
- $nto = $ntOpts[$ii]; $wprg = array(); $wprg['sslverify'] = false;
68
- if (isset($nto['liAPIKey'])){ echo "-="; prr($nto);// die();
69
- $tknURL = 'https://www.linkedin.com/uas/oauth2/accessToken?grant_type=authorization_code&code='.$at.'&redirect_uri='.urlencode($nxs_snapSetPgURL).'&client_id='.$nto['liAPIKey'].'&client_secret='.$nto['liAPISec'];
70
- $response = wp_remote_post($tknURL, $wprg); prr($tknURL);
71
- if((is_object($response)&&(isset($response->errors)))){ prr($response); die(); }
72
- if (is_array($response)&& stripos($response['body'],'"error":')!==false){ prr($response['body']); prr(json_decode($response['body'],true)); die(); }
73
- $resp = json_decode($response['body'], true); prr($resp); if (!is_array($resp) || empty($resp['access_token'])) { prr($resp); die(); }
74
  if (function_exists('get_option')) $currTime = time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); else $currTime = time();
75
- $nto['liAccessToken'] = $resp['access_token']; $nto['liAccessTokenSecret'] = 'No Need for oAuth V2'; $nto['liOAuthVerifier'] = 'No Need for oAuth V2';
76
- $nto['liAccessTokenExp'] = $currTime + $resp['expires_in']; echo "<br/>----=={ Expires: ".date('Y-m-d H:i:s', $nto['liAccessTokenExp'])." }==---- <br/>";
77
- $tknURL = 'https://api.linkedin.com/v1/people/~:(id,first-name,last-name)?format=json&oauth2_access_token='.$nto['liAccessToken'];
78
- $response = wp_remote_get($tknURL, $wprg); prr($tknURL); prr($response); $user = json_decode($response['body'], true);
79
-
80
- if (!empty($user['id'])) { $nto['liUserID'] = $user['id']; $nto['liUserInfo'] = $user['firstName'].$user['lastName'].(!empty($user['id'])?" (".$user['id'].")":''); $nto['isV2'] = true;
81
- if (function_exists('get_option')) $nxs_gOptions = get_option('NS_SNAutoPoster'); if(!empty($nxs_gOptions)) { $nxs_gOptions['li'][$ii] = $nto; prr($nto); nxs_settings_save($nxs_gOptions); }
82
- ?><script type="text/javascript">window.location = "<?php echo $nxs_snapSetPgURL; ?>"</script>
83
- <?php }
84
- }
85
- die();
 
 
86
  }
87
  // V1 Auth
88
- if ( isset($_GET['auth']) && $_GET['auth']=='li'){ require_once('apis/liOAuth.php'); $options = $ntOpts[$_GET['acc']];
89
-
90
- $api_key = $options['liAPIKey']; $api_secret = $options['liAPISec'];
91
- $callback_url = $nxs_snapSetPgURL."&auth=lia&acc=".$_GET['acc'];
92
- $li_oauth = new nsx_LinkedIn($api_key, $api_secret, $callback_url);
93
- $request_token = $li_oauth->getRequestToken(); //echo "####"; prr($request_token); die();
94
- if (!is_object($request_token)) { echo "### LinkedIn Authorization Error:"; prr($request_token);
95
- if (is_string($request_token) && stripos($request_token, 'timestamp')!==false) { echo "Your Server Time: ".date('m/d/Y h:i:s a'); echo " Correct Time: ".date('m/d/Y h:i:s a', nxs_ntp_time('t1.timegps.net')); } die();
96
- }
97
- $options['liOAuthToken'] = $request_token->key;
98
- $options['liOAuthTokenSecret'] = $request_token->secret; // prr($li_oauth);
99
- switch ($li_oauth->http_code) { case 200: $url = $li_oauth->generateAuthorizeUrl();
100
- $optionsG = get_option('NS_SNAutoPoster'); $optionsG['li'][$_GET['acc']] = $options; update_option('NS_SNAutoPoster', $optionsG);
101
- echo '<script type="text/javascript">window.location = "'.$url.'"</script>'; break;
102
- default: echo '<br/><b style="color:red">Could not connect to LinkedIn. Refresh the page or try again later.</b>'; die();
103
- }die();
104
- }
105
- if ( isset($_GET['auth']) && $_GET['auth']=='lia'){ require_once('apis/liOAuth.php'); $options = $ntOpts[$_GET['acc']]; $api_key = $options['liAPIKey']; $api_secret = $options['liAPISec'];
106
- $li_oauth = new nsx_LinkedIn($api_key, $api_secret); $li_oauth->request_token = new nsx_trOAuthConsumer($options['liOAuthToken'], $options['liOAuthTokenSecret'], 1);
107
- $li_oauth->oauth_verifier = $_REQUEST['oauth_verifier']; $li_oauth->getAccessToken($_REQUEST['oauth_verifier']); $options['liOAuthVerifier'] = $_REQUEST['oauth_verifier'];
108
- $options['liAccessToken'] = $li_oauth->access_token->key; $options['liAccessTokenSecret'] = $li_oauth->access_token->secret;
109
- try{$xml_response = $li_oauth->getProfile("~:(id,first-name,last-name)");} catch (Exception $o){prr($o); die("<span style='color:red;'>ERROR: Authorization Error</span>");}
110
- if (stripos($xml_response,'<first-name>')!==false) $userinfo = CutFromTo($xml_response, '<id>','</id>')." - ".CutFromTo($xml_response, '<first-name>','</first-name>')." ".CutFromTo($xml_response, '<last-name>','</last-name>'); else $userinfo='';
111
- if ($userinfo!='') { $options['liUserInfo'] = $userinfo; $optionsG = get_option('NS_SNAutoPoster'); $optionsG['li'][$_GET['acc']] = $options; update_option('NS_SNAutoPoster', $optionsG);
112
- echo '<script type="text/javascript">window.location = "'.$nxs_snapSetPgURL.'"</script>'; die();
113
- } prr($xml_response); die("<span style='color:red;'>ERROR: Something is Wrong with your LinkedIn account</span>");
114
- }
115
-
116
- ?>
117
- <div class="nxs_box">
118
- <div class="nxs_box_header">
119
- <div class="nsx_iconedTitle" style="margin-bottom:1px;background-image:url(<?php echo $nxs_plurl;?>img/<?php echo $ntInfo['lcode']; ?>16.png);"><?php echo $ntInfo['name']; ?>
120
- <?php $cbo = count($ntOpts); ?>
121
- <?php if ($cbo>1){ ?><div class="nsBigText"><?php echo "(".($cbo=='0'?'No':$cbo)." "; _e('accounts', 'social-networks-auto-poster-facebook-twitter-g'); echo ")"; ?></div><?php } ?>
122
- </div>
123
- </div>
124
- <div class="nxs_box_inside">
125
- <?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = !empty($pbo[$ntInfo['defNName']])?$pbo[$ntInfo['defNName']]:'LinkedIn';
126
- if (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='') $pbo[$ntInfo['lcode'].'OK'] = (isset($pbo['liAccessToken']) && $pbo['liAccessTokenSecret']!='')?'1':'';
127
- ?>
128
- <p style="margin:0px;margin-left:5px;"> <img id="<?php echo $ntInfo['code'].$indx;?>LoadingImg" style="display: none;" src='<?php echo $nxs_plurl; ?>img/ajax-loader-sm.gif' />
129
- <input value="0" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" type="hidden" />
130
- <?php if ((int)$pbo['do'.$ntInfo['code']] == 1 && isset($pbo['catSel']) && (int)$pbo['catSel'] == 1) { ?> <input type="radio" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" id="rbtn<?php echo $ntInfo['lcode'].$indx; ?>" value="1" checked="checked" onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);" /> <?php } else { ?>
131
- <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1 && $pbo['catSel']!='1') echo "checked"; ?> />
132
- <?php } ?>
133
- <?php if (isset($pbo['catSel']) && (int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
134
- <?php if (isset($pbo['rpstOn']) && (int)$pbo['rpstOn'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popReActive');" onmouseover="nxs_showPopUpInfo('popReActive', event);"><?php echo "*[R]*" ?></span><?php } ?>
135
- <strong><?php _e('Auto-publish to', 'social-networks-auto-poster-facebook-twitter-g'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
136
- &nbsp;&nbsp;<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'social-networks-auto-poster-facebook-twitter-g'); ?> ==&gt;</b><?php } ?> <?php if (!empty($pbo['grpID'])){ ?><b style="color: #800000"><?php _e('Attention requred. Groups are no longer supported by LinkedIn Native API', 'social-networks-auto-poster-facebook-twitter-g'); ?> ==&gt;</b><?php } ?> <a id="do<?php echo $ntInfo['code'].$indx; ?>AG" href="#" onclick="doGetHideNTBlock('<?php echo $ntInfo['code'];?>' , '<?php echo $indx; ?>');return false;">[<?php _e('Show Settings', 'social-networks-auto-poster-facebook-twitter-g'); ?>]</a>&nbsp;&nbsp;
137
- <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'social-networks-auto-poster-facebook-twitter-g'); ?>]</a>
138
- </p><div id="nxsNTSetDiv<?php echo $ntInfo['code'].$indx; ?>"></div><?php //$pbo['ntInfo'] = $ntInfo; $this->showNTSettings($indx, $pbo);
139
- }?>
140
- </div>
141
- </div> <?php
142
- }
143
- //#### Show NEW Settings Page
144
- function showNewNTSettings($bo){ $po = array('nName'=>'', 'ulName'=>'', 'uPass'=>'', 'grpID'=>'', 'uPage'=>'', 'doLI'=>'1', 'liAPIKey'=>'', 'liAPISec'=>'', 'liUserInfo'=>'', 'liOAuthToken'=>'', 'liMsgFormat'=>'New post has been published on %SITENAME%', 'liMsgFormatT'=>'New post - %TITLE%' ); $po['ntInfo']= array('lcode'=>'li'); $this->showNTSettings($bo, $po, true);}
145
- //#### Show Unit Settings
146
- function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl,$nxs_snapSetPgURL; $nt = $options['ntInfo']['lcode']; $ntU = strtoupper($nt); if (!isset($options['liOK'])) $options['liOK'] = '';
147
 
148
- 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'] = '';
149
- if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; if (!isset($options['liMsgAFrmt'])) $options['liMsgAFrmt'] = '';
150
- if (empty($options['apiToUse'])) { if (!empty($options['liAPIKey'])) $options['apiToUse'] = 'li'; if (!empty($options['ulName']) && !empty($options['uPass'])) $options['apiToUse'] = 'nx'; } ?>
151
- <div id="doLI<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>"> <input type="hidden" name="apDoSLI<?php echo $ii; ?>" value="0" id="apDoSLI<?php echo $ii; ?>" />
152
- <?php if ($isNew) { ?> <input type="hidden" name="li[<?php echo $ii; ?>][apDoLI]" value="1" id="apDoNewLI<?php echo $ii; ?>" /> <?php } ?>
153
- <div id="doLI<?php echo $ii; ?>Div" style="margin-left: 10px;">
154
-
155
- <div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/li16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-linkedin-social-networks-auto-poster-wordpress/"><?php $nType="LinkedIn"; printf( __( 'Detailed %s Installation/Configuration Instructions' , 'social-networks-auto-poster-facebook-twitter-g'), $nType); ?></a></div>
156
-
157
- <div style="width:100%;"><strong><?php _e('Account Nickname', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'social-networks-auto-poster-facebook-twitter-g'); ?></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")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /><br/>
158
- <?php echo nxs_addQTranslSel('li', $ii, $options['qTLng']); ?>
159
-
160
- <br/>
161
- <ul class="nsx_tabs">
162
- <li><a href="#nsx<?php echo $nt.$ii ?>_tab1"><?php _e('Account Info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li>
163
- <?php if (!$isNew) { ?> <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li> <?php } ?>
164
- </ul>
165
- <div class="nsx_tab_container"><?php /* ######################## Account Tab ####################### */ ?>
166
- <div id="nsx<?php echo $nt.$ii ?>_tab1" class="nsx_tab_content" style="background-image: url(<?php echo $nxs_plurl; ?>img/<?php echo $nt; ?>-bg.png); background-repeat: no-repeat; background-position:90% 10%;">
167
-
168
- <div style="display: <?php echo (empty($options['apiToUse']))?"block":"none"; ?>;">
169
-
170
- <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>
171
-
172
- <span style="color:#005800; font-weight: bold; font-size: 14px;">LinkedIn Native API:</span> Free built-in API from LinkedIn. Can be used for posting to your profile. More secure, more stable. More complicated - requires LinkedIn App and authorization. <br/><br/>
 
 
 
 
 
 
173
 
174
- <span style="color:#005800; font-weight: bold; font-size: 14px;">NextScripts API for LinkedIn:</span> Premium API with extended functionality. Can be used for posting to your profile, <b>group page</b> or <b>company page</b>. Easier to configure, but less secure - requires your password.<br/><br/>
 
 
 
 
175
 
176
- <select name="li[<?php echo $ii; ?>][apiToUse]" onchange="if (jQuery(this).val()=='li') { jQuery('.nxs_li_nxapi_<?php echo $ii; ?>').hide(); jQuery('.nxs_li_liapi_<?php echo $ii; ?>').show(); }else { jQuery('.nxs_li_liapi_<?php echo $ii; ?>').hide(); jQuery('.nxs_li_nxapi_<?php echo $ii; ?>').show(); }"><option <?php echo (empty($options['apiToUse']) || $options['apiToUse'] =='li')?"selected":""; ?> value="li">LinkedIn API</option><option <?php echo (!empty($options['apiToUse']) && $options['apiToUse'] =='nx')?"selected":""; ?> value="nx">NextScripts API</option></select><hr/>
177
 
178
  </div>
179
 
180
- <div id="nxsAPILI<?php echo $ii; ?>" class="nxs_li_liapi_<?php echo $ii; ?>" style="display: <?php echo (empty($options['apiToUse']) || $options['apiToUse'] =='li')?"block":"none"; ?>;"><h3>LinkedIn API</h3>
181
-
182
- <div class="subDiv" id="sub<?php echo $ii; ?>DivL" style="display: block;">
183
-
184
- <?php if (!empty($options['grpID'])) { ?> <span style="color: red;">LinkedIn has <a style="color: red;" target="_blank" href="https://developer.linkedin.com/support/developer-program-transition">discontinued support for groups</a> from it's free native API. This account should be removed or switched to NextScripts API</span> <br/>
185
- <br/><a onclick="jQuery('#nxsAPILI<?php echo $ii; ?>').hide(); jQuery('#nxsAPINX<?php echo $ii; ?>').show(); jQuery('#liuPage<?php echo $ii; ?>').val('https://www.linkedin.com/groups/?gid=<?php echo $options['grpID']; ?>'); jQuery('#sub<?php echo $ii; ?>DivL').append('<input type=hidden name=li[<?php echo $ii; ?>][apiToUse] value=nx />'); return false;" style="font-size: 16px;" href="#">&gt;&gt;&gt;&nbsp;Switch to NextScripts API Now&nbsp;&lt;&lt;&lt;</a><br/><br/></hr>
186
-
187
- <?php } ?>
188
-
189
- <div style="width:100%;"><strong>LinkedIn Client ID:</strong> </div><input name="li[<?php echo $ii; ?>][apLIAPIKey]" id="apLIAPIKey" style="width: 70%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['liAPIKey'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />
190
- <div style="width:100%;"><strong>LinkedIn Client Secret:</strong> </div><input name="li[<?php echo $ii; ?>][apLIAPISec]" id="apLIAPISec" style="width: 70%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['liAPISec'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />
191
- <br/>
192
- <?php
193
- if($options['liAPIKey']=='') { ?>
194
- <b>Authorize Your LinkedIn Account</b>. Please save your settings and come back here to Authorize your account.
195
- <?php } else { if(isset($options['liAccessToken']) && isset($options['liAccessTokenSecret']) && $options['liAccessTokenSecret']!=='') { ?>
196
- Your LinkedIn Account has been authorized. <br/>User ID: <?php _e(apply_filters('format_to_edit', $options['liUserInfo']), 'social-networks-auto-poster-facebook-twitter-g') ?>.
197
- <br/>You can Re- <?php } ?>
198
-
199
- <?php if (class_exists("cl_nxsAutoPostToSN")) { ?><a href="https://www.linkedin.com/uas/oauth2/authorization?response_type=code&client_id=<?php echo trim($options['liAPIKey']);?>&scope=r_basicprofile+r_emailaddress+w_share&state=<?php echo 'nxs-li-'.$ii; ?>&redirect_uri=<?php echo trim(urlencode($nxs_snapSetPgURL));?>">Authorize Your LinkedIn Account</a>
200
- <?php } else { ?><a href="<?php echo $nxs_snapSetPgURL; ?>&auth=li&acc=<?php echo $ii; ?>">Authorize Your LinkedIn Account</a> <?php } ?>
201
-
202
- <?php if (!isset($options['liAccessTokenSecret']) || $options['liAccessTokenSecret']=='') { ?> <div class="blnkg">&lt;=== Authorize your account ===</div> <?php } ?>
203
-
204
- <?php } ?>
205
- </div>
206
- </div>
207
- <div id="nxsAPINX<?php echo $ii; ?>" class="nxs_li_nxapi_<?php echo $ii; ?>" style="display: <?php echo (!empty($options['apiToUse']) && $options['apiToUse'] =='nx')?"block":"none"; ?>;"><h3>NextScripts API</h3>
208
-
209
- <?php if (function_exists("doConnectToLinkedIn")) { ?>
210
-
211
- <div class="subDiv" id="sub<?php echo $ii; ?>DivN" style="display: block;">
212
- <div style="width:100%;"><strong>Your LinkedIn Page URL:</strong> Could be your company page or group page. Leave empty to post to your own profile.</div><input name="li[<?php echo $ii; ?>][uPage]" id="liuPage<?php echo $ii; ?>" style="width: 90%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['uPage'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />
213
- <br/>
214
- <div style="width:100%;"><strong>Your LinkedIn Username/Email:</strong> </div><input name="li[<?php echo $ii; ?>][ulName]" id="liulName" style="width: 70%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['ulName'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />
215
- <div style="width:100%;"><strong>Your LinkedIn Password:</strong> </div><input type="password" name="li[<?php echo $ii; ?>][uPass]" id="liuPass" style="width: 75%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['uPass'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />
216
-
217
- </div>
218
- <?php } else { nxs_show_noLibWrn('NextScripts API Library for LinkedIn module NOT found'); } ?>
219
- </div>
220
-
221
- <br/><hr/>
222
-
223
- <div id="altFormat">
224
- <div style="width:100%;"><strong id="altFormatText"><?php _e('Message text Format', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> </div>
225
- <textarea cols="150" rows="3" id="li<?php echo $ii; ?>SNAPformat" name="li[<?php echo $ii; ?>][apLIMsgFrmt]" style="width:51%;max-width: 650px;" onfocus="jQuery('#li<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('apLIMsgFrmt<?php echo $ii; ?>');"><?php _e(apply_filters('format_to_edit',htmlentities($options['liMsgFormat'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?></textarea>
226
- <?php nxs_doShowHint("apIPMsgFrmt".$ii); ?>
227
- </div>
228
-
229
- <div style="width:100%;"><strong id="altFormatText">Post Type:</strong> </div>
230
- <div style="margin-left: 10px;">
231
- <?php if(empty($options['postType'])) {if ((int)$options['liAttch'] == 1 || $isNew) $options['postType'] = 'A';} ?>
232
- <input type="radio" name="li[<?php echo $ii; ?>][postType]" value="T" <?php if ($options['postType'] == 'T') echo 'checked="checked"'; ?> /> <?php _e('Text Post', 'social-networks-auto-poster-facebook-twitter-g'); ?> - <i><?php _e('just text message', 'social-networks-auto-poster-facebook-twitter-g'); ?></i><br/>
233
- <span class="nxs_li_nxapi_<?php echo $ii; ?>" style="display: <?php echo (!empty($options['apiToUse']) && $options['apiToUse'] =='nx')?"block":"none"; ?>;">
234
- <input type="radio" name="li[<?php echo $ii; ?>][postType]" value="I" <?php if ($options['postType'] == 'I') echo 'checked="checked"'; ?> /> <?php _e('Image Post', 'social-networks-auto-poster-facebook-twitter-g'); ?> - <i><?php _e('big image with text message (Profiles and Company pages only)', 'social-networks-auto-poster-facebook-twitter-g'); ?></i><br/> </span>
235
- <input type="radio" name="li[<?php echo $ii; ?>][postType]" value="A" <?php if ( !isset($options['postType']) || $options['postType'] == '' || $options['postType'] == 'A') echo 'checked="checked"'; ?> /> <?php _e('Add blogpost to LinkedIn message as an attachment', 'social-networks-auto-poster-facebook-twitter-g'); ?><br/>
236
-
237
- <div style="margin-left: 10px;">
238
- <strong><?php _e('Attachment Text Format', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong><br/>
239
- <input value="1" id="apLIMsgAFrmtA<?php echo $ii; ?>" <?php if (trim($options['liMsgAFrmt'])=='') echo "checked"; ?> onchange="if (jQuery(this).is(':checked')) { jQuery('#apLIMsgAFrmtDiv<?php echo $ii; ?>').hide(); jQuery('#apLIMsgAFrmt<?php echo $ii; ?>').val(''); }else jQuery('#apLIMsgAFrmtDiv<?php echo $ii; ?>').show();" type="checkbox" name="li[<?php echo $ii; ?>][apLIMsgAFrmtA]"/> <strong><?php _e('Auto', 'social-networks-auto-poster-facebook-twitter-g'); ?></strong>
240
- <i> - <?php _e('Recommended. Info from SEO Plugins will be used, then post excerpt, then post text', 'social-networks-auto-poster-facebook-twitter-g'); ?> </i><br/>
241
- <div id="apLIMsgAFrmtDiv<?php echo $ii; ?>" style="<?php if ($options['liMsgAFrmt']=='') echo "display:none;"; ?>" >&nbsp;&nbsp;&nbsp; <?php _e('Set your own format', 'social-networks-auto-poster-facebook-twitter-g'); ?>:<input name="li[<?php echo $ii; ?>][apLIMsgAFrmt]" id="apLIMsgAFrmt<?php echo $ii; ?>" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['liMsgAFrmt'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /><br/></div>
242
-
243
- </div>
244
-
245
- </div><br/>
246
-
247
- <br/>
248
- <div id="altFormat" style="display: <?php echo (!empty($options['apiToUse']) && $options['apiToUse'] =='nx')?"block":"none"; ?>;">
249
- <div style="width:100%;"><strong id="altFormatText"><?php _e('Message title Format (Groups Only)', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> </div>
250
-
251
- <input name="li[<?php echo $ii; ?>][apLIMsgFrmtT]" id="li<?php echo $ii; ?>SNAPformatT" style="width: 50%;" value="<?php if ($isNew) echo "New Post - %TITLE%"; else _e(apply_filters('format_to_edit',htmlentities($options['liMsgFormatT'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g'); ?>" onfocus="mxs_showFrmtInfo('apLIMsgFrmtT<?php echo $ii; ?>');" /><?php nxs_doShowHint("apIPMsgFrmt".$ii); ?>
252
-
253
- </div>
254
-
255
- <br/>
256
-
257
- <?php if($options['liAPIKey']!='' || (isset($options['uPass']) && $options['uPass']!='')) { ?>
258
-
259
- <br/><b><?php _e('Test your settings', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('LI', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?></a>
260
-
261
- <?php if (!isset($options['liOK']) || $options['liOK']=='') { ?> <div class="blnkg">&lt;=== Click "Test" to finish setup ===</div> <?php } ?>
262
-
263
- <br/><?php }?>
264
- </div>
265
-
266
- <?php /* ######################## Advanced Tab ####################### */ ?>
267
- <?php if (!$isNew) { ?> <div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content">
268
-
269
- <?php nxs_showCatTagsCTFilters($nt, $ii, $options);
270
- nxs_addPostingDelaySelV3($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']);
271
- nxs_showRepostSettings($nt, $ii, $options); ?>
272
-
273
-
274
- </div> <?php } ?> <?php /* #### End of Tab #### */ ?>
275
- </div><br/> <?php /* #### End of Tabs #### */ ?>
276
 
277
- <div class="submitX nxclear" style="padding-bottom: 0px;"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'social-networks-auto-poster-facebook-twitter-g') ?>" /></div>
278
-
279
- </div>
280
- </div>
281
- <?php
 
 
 
 
282
 
 
283
 
284
- }
285
- //#### Set Unit Settings from POST
286
- function setNTSettings($post, $options){ $code = $this->ntInfo['code'];
287
- foreach ($post as $ii => $pval){ // prr($ii); prr($pval);
288
- if ( (isset($pval['apLIAPIKey']) && $pval['apLIAPISec']!='') || (isset($pval['uPass']) && $pval['uPass']!='') ) { if (!isset($options[$ii])) $options[$ii] = array(); $options[$ii]['ii'] = $ii;
289
- if (isset($pval['apDoLI'])) $options[$ii]['doLI'] = $pval['apDoLI']; else $options[$ii]['doLI'] = 0;
290
- if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']);
291
 
292
- if (isset($pval['apiToUse'])) $options[$ii]['apiToUse'] = trim($pval['apiToUse']);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
293
 
294
- if (isset($options[$ii]['grpID']) && isset($pval['apiToUse']) && ($pval['apiToUse'])=='nx') unset($options[$ii]['grpID']); //## Switch/Upgrade
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
295
 
296
- if (isset($pval['apLIAPIKey']))$options[$ii]['liAPIKey'] = trim($pval['apLIAPIKey']);
297
- if (isset($pval['apLIAPISec']))$options[$ii]['liAPISec'] = trim($pval['apLIAPISec']);
298
- if (isset($pval['postType'])) $options[$ii]['postType'] = trim($pval['postType']);
299
 
300
- if (isset($pval['apiToUse']) && $pval['apiToUse']=='li' && ($options[$ii]['postType']=='I')) $options[$ii]['postType'] = 'T';
301
 
302
- if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']); else $options[$ii]['catSel'] = 0;
303
- if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
 
 
 
 
 
 
 
 
 
 
 
 
 
304
 
305
- if (isset($pval['ulName'])) $options[$ii]['ulName'] = trim($pval['ulName']);
306
- if (isset($pval['uPass'])) $options[$ii]['uPass'] = trim($pval['uPass']);
307
- if (isset($pval['grpID'])) $options[$ii]['grpID'] = trim($pval['grpID']);
308
- if (isset($pval['uPage'])) $options[$ii]['uPage'] = trim($pval['uPage']);
309
- if (isset($pval['apLIMsgFrmt'])) $options[$ii]['liMsgFormat'] = trim($pval['apLIMsgFrmt']);
310
- if (isset($pval['apLIMsgFrmtT'])) $options[$ii]['liMsgFormatT'] = trim($pval['apLIMsgFrmtT']);
311
- if (isset($pval['apLIMsgAFrmt'])) $options[$ii]['liMsgAFrmt'] = trim($pval['apLIMsgAFrmt']);
312
 
313
- $options[$ii] = nxs_adjRpst($options[$ii], $pval);
 
 
 
 
 
 
 
 
 
 
314
 
315
- if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']);
316
- if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
317
- if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
318
- } elseif ( count($pval)==1 ) if (isset($pval['apDo'.$code])) $options[$ii]['do'.$code] = $pval['apDo'.$code]; else $options[$ii]['do'.$code] = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
319
  } return $options;
320
- }
 
321
  //#### Show Post->Edit Meta Box Settings
322
- function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID; $nt = 'li'; $ntU = 'LI';
323
- foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapLI', true)); if (is_array($pMeta) && isset($pMeta[$ii])) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
324
- if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = ''; if (empty($ntOpt['urlToUse'])) $ntOpt['urlToUse'] = ''; if (empty($ntOpt['catSel'])) $ntOpt['catSel'] = '';
325
- $doLI = $ntOpt['doLI'] && (is_array($pMeta) || $ntOpt['catSel']!='1'); $imgToUse = $ntOpt['imgToUse']; $urlToUse = $ntOpt['urlToUse'];
326
- $isAvailLI = (isset($ntOpt['liOAuthVerifier']) && $ntOpt['liOAuthVerifier']!='' && $ntOpt['liAccessTokenSecret']!='' && $ntOpt['liAccessToken']!='' && $ntOpt['liAPIKey']!='') || ($ntOpt['ulName']!=='' && $ntOpt['uPass']!=='');
327
- $liMsgFormat = htmlentities($ntOpt['liMsgFormat'], ENT_COMPAT, "UTF-8"); $liMsgFormatT = htmlentities($ntOpt['liMsgFormatT'], ENT_COMPAT, "UTF-8");
328
- ?>
329
-
330
- <tr><th style="text-align:left;" colspan="2">
331
- <?php if ($ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='') { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
332
- <?php if (!empty($ntOpt['tagsSelX'])) { ?> <input type="hidden" class="nxs_TG" id="nxs_TG_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $ntOpt['tagsSelX']; ?>" /> <?php } ?>
333
- <?php if ($isAvailLI) { ?><input class="nxsGrpDoChb" value="1" id="doLI<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="li[<?php echo $ii; ?>][doLI]" <?php if ((int)$doLI == 1) echo 'checked="checked" title="def"'; ?> />
334
- <?php if ($post->post_status == "publish") { ?> <input type="hidden" name="li[<?php echo $ii; ?>][doLI]" value="<?php echo $doLI;?>"> <?php } ?> <?php } ?>
335
- <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/li16.png);">LinkedIn - <?php _e('publish to', 'social-networks-auto-poster-facebook-twitter-g') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th><td><?php //## Only show RePost button if the post is "published"
336
- 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', 'social-networks-auto-poster-facebook-twitter-g') ?>" />
337
- <?php } ?>
338
-
339
- <?php if (is_array($pMeta) && isset($pMeta[$ii]) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) { // prr($pMeta[$ii]);
340
- ?> <span id="pstdLI<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
341
- <a style="font-size: 10px;" href="<?php if ( $pMeta[$ii]['postURL']!='') echo $pMeta[$ii]['postURL']; elseif ($ntOpt['uPage']!='') echo $ntOpt['uPage']; else { } ?>" target="_blank"><?php $nType="LinkedIn"; printf( __( 'Posted on', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
342
- </span><?php } ?>
343
-
344
- </td></tr>
345
- <?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>
346
- <?php } else { if ($post->post_status != "publish" && function_exists('nxs_doSMAS5') ) { $ntOpt['postTime'] = get_post_time('U', false, $post_id); nxs_doSMAS5($nt, $ii, $ntOpt); } ?>
347
-
348
- <?php if ($ntOpt['rpstOn']=='1') { ?>
349
-
350
- <tr id="altFormat1" style=""><th scope="row" class="nxsTHRow">
351
- <input value="0" type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]"/><input value="nxsi<?php echo $ii; ?>li" type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]" <?php if (!empty($ntOpt['rpstPostIncl'])) echo "checked"; ?> />
352
- </th>
353
- <td> <?php _e('Include in "Auto-Reposting" to this network.', 'social-networks-auto-poster-facebook-twitter-g') ?>
354
- </td></tr> <?php } ?>
355
-
356
- <tr><th scope="row" style="text-align:right; width:150px; vertical-align:top; padding-top: 0px; padding-right:10px;"> <?php _e('Post Type:', 'social-networks-auto-poster-facebook-twitter-g') ?>
357
  </th><td>
358
 
359
- <input type="radio" name="li[<?php echo $ii; ?>][postType]" value="T" <?php if ($ntOpt['postType'] == 'T') echo 'checked="checked"'; ?> /><?php _e('Text Post', 'social-networks-auto-poster-facebook-twitter-g') ?> - <i><?php _e('just text message', 'social-networks-auto-poster-facebook-twitter-g') ?></i><br/>
360
  <span class="nxs_li_nxapi_<?php echo $ii; ?>" style="display: <?php echo (!empty($ntOpt['apiToUse']) && $ntOpt['apiToUse'] =='nx')?"block":"none"; ?>;">
361
- <input type="radio" name="li[<?php echo $ii; ?>][postType]" value="I" <?php if ($ntOpt['postType'] == 'I') echo 'checked="checked"'; ?> onchange="jQuery('#altFormatIMG<?php echo $nt.$ii;?>').show();" /> <?php _e('Post to LinkedIn as "Image post"', 'social-networks-auto-poster-facebook-twitter-g') ?> - <i><?php _e('big image with text message', 'social-networks-auto-poster-facebook-twitter-g') ?></i><br/> </span>
362
- <input type="radio" name="li[<?php echo $ii; ?>][postType]" value="A" <?php if ( !isset($ntOpt['postType']) || $ntOpt['postType'] == '' || $ntOpt['postType'] == 'A') echo 'checked="checked"'; ?> onchange="jQuery('#altFormatIMG<?php echo $nt.$ii;?>').hide();" /><?php _e('Text Post with "attached" blogpost', 'social-networks-auto-poster-facebook-twitter-g') ?>
363
- </td></tr>
364
-
365
- <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Message Format:', 'social-networks-auto-poster-facebook-twitter-g') ?></th>
366
- <td>
367
- <textarea cols="150" rows="1" id="li<?php echo $ii; ?>SNAPformat" name="li[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('#li<?php echo $ii; ?>SNAPformat').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apLIMsgFrmt<?php echo $ii; ?>');"><?php echo $liMsgFormat; ?></textarea>
368
- <?php nxs_doShowHint("apLIMsgFrmt".$ii); ?></td></tr>
369
-
370
- <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Title Format (Groups Only):', 'social-networks-auto-poster-facebook-twitter-g') ?></th>
371
- <td><input value="<?php echo $liMsgFormatT ?>" type="text" name="li[<?php echo $ii; ?>][SNAPformatT]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apLIMsgFrmtT<?php echo $ii; ?>');"/><?php nxs_doShowHint("apLIMsgFrmtT".$ii, '', '58'); ?></td></tr>
372
- <?php /* ## Select Image & URL ## */ nxs_showImgToUseDlg($nt, $ii, $imgToUse); nxs_showURLToUseDlg($nt, $ii, $urlToUse); ?>
373
-
374
- <?php }
375
- }
376
  }
377
 
378
- function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
379
- if (isset($pMeta['SNAPformat'])) $optMt['liMsgFormat'] = $pMeta['SNAPformat']; if (trim($optMt['liMsgFormat'])=='') $optMt['liMsgFormat'] = ' ';
380
- if (isset($pMeta['SNAPformatT'])) $optMt['liMsgFormatT'] = $pMeta['SNAPformatT']; if (trim($optMt['liMsgFormatT'])=='') $optMt['liMsgFormatT'] = ' ';
381
- if (isset($pMeta['imgToUse'])) $optMt['imgToUse'] = $pMeta['imgToUse']; if (isset($pMeta['urlToUse'])) $optMt['urlToUse'] = $pMeta['urlToUse'];
382
- if (isset($pMeta['postType'])) $optMt['postType'] = $pMeta['postType'];
383
- if (isset($pMeta['timeToRun'])) $optMt['timeToRun'] = $pMeta['timeToRun']; if (isset($pMeta['rpstPostIncl'])) $optMt['rpstPostIncl'] = $pMeta['rpstPostIncl'];
384
- if (isset($pMeta['doLI'])) $optMt['doLI'] = $pMeta['doLI'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doLI'] = 0; }
385
- if (isset($pMeta['SNAPincludeLI']) && $pMeta['SNAPincludeLI'] == '1' ) $optMt['doLI'] = 1;
386
- return $optMt;
387
- }
388
- }}
389
-
390
- if (!function_exists("nxs_rePostToLI_ajax")) { function nxs_rePostToLI_ajax() { check_ajax_referer('nxsSsPageWPN'); $postID = $_POST['id']; // $result = nsPublishTo($id, 'FB', true);
391
- global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
392
- foreach ($options['li'] as $ii=>$po) if ($ii==$_POST['nid']) { $po['ii'] = $ii; $po['pType'] = 'aj';
393
- $mpo = get_post_meta($postID, 'snapLI', true); $mpo = maybe_unserialize($mpo);
394
- if (is_array($mpo) && isset($mpo[$ii]) && is_array($mpo[$ii]) ){ $ntClInst = new nxs_snapClassLI(); $po = $ntClInst->adjMetaOpt($po, $mpo[$ii]); }
395
- $result = nxs_doPublishToLI($postID, $po);
396
- if ($result == 200 && ($postID=='0') && (!isset($options['li'][$ii]['liOK']) || $options['li'][$ii]['liOK']!='1')) { $options['li'][$ii]['liOK']=1; update_option('NS_SNAutoPoster', $options); }
397
- if ($result == 200) die("Successfully sent your post to LinkedIn."); else die($result);
398
- }
399
  }
400
- }
401
-
402
- if (!function_exists("nxs_doPublishToLI")) { //## Second Function to Post to LI
403
- function nxs_doPublishToLI($postID, $options){ global $nxs_gCookiesArr; $ntCd = 'LI'; $ntCdL = 'li'; $ntNm = 'LinkedIn'; $urlDescr = ''; $myurl = '';
404
- if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
405
- //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToLI', array($postID, $options));
406
- $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'POSTID'=>$postID, 'ACCNAME'=>$options['nName']));
407
- if (empty($options['imgToUse'])) $options['imgToUse'] = ''; if (empty($options['imgSize'])) $options['imgSize'] = '';
408
- $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
409
- $logNT = '<span style="color:#000058">LinkedIn</span> - '.$options['nName'];
410
- $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
411
- if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
412
- $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') { sleep(5);
413
- nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$uqID); return;
414
- }
415
- }
416
 
417
- $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url(); $imgURL=''; // prr($options);
418
- if ($postID=='0') { echo "Testing ... <br/><br/>"; $options['liMsgFormatT'] = 'Test Post from '.$blogTitle; $urlToGo = home_url(); $options['liMsgFormat'] = 'Test Post from '.$blogTitle. " ".$urlToGo; $title = $blogTitle; }
419
- else { $post = get_post($postID); if(!$post) return;
420
- $options['liMsgFormat'] = nsFormatMessage($options['liMsgFormat'], $postID, $addParams); $options['liMsgFormatT'] = nsTrnc(nsFormatMessage($options['liMsgFormatT'], $postID, $addParams), 200);
421
- //## MyURL - URLToGo code
422
- $options = nxs_getURL($options, $postID, $addParams); $urlToGo = $options['urlToUse'];
423
- $title = nsTrnc($post->post_title, 200); nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
424
-
425
- if(empty($options['postType'])) { if ((int)$options['liAttch'] == 1 || $isNew) $options['postType'] = 'A';}
426
- if ($options['postType'] == 'A' || $options['postType'] == 'I') {
427
- if (trim($options['liMsgAFrmt'])!='') { $urlDescr = nsFormatMessage($options['liMsgAFrmt'], $postID, $addParams); } else {
428
- $urlDescr = trim(apply_filters('the_content', $post->post_excerpt)); if ($urlDescr=='') $urlDescr = apply_filters('the_content', $post->post_content);
429
- } if (trim($options['imgToUse'])!='') $imgURL = $options['imgToUse']; else $imgURL = nxs_getPostImage($postID, 'full');
430
- if (preg_match("/noImg.\.png/i", $imgURL)) $imgURL = '';
431
- $urlDescr = strip_tags($urlDescr); $urlDescr = nxs_decodeEntitiesFull($urlDescr); $urlDescr = nxs_html_to_utf8($urlDescr); $urlDescr = nsTrnc($urlDescr, 300);
432
- }
433
- }
434
- $extInfo = ' | PostID: '.$postID." - ".(isset($post) && is_object($post)?$post->post_title:'');
435
- //$images = array(nxs_getPostImage($postID, 'thumb'), nxs_getPostImage($postID, 'medium'), nxs_getPostImage($postID, 'full'), nxs_getPostImage($postID, 'original'));
436
- $message = array('url'=>$urlToGo, 'surl'=>$urlToGo, 'urlDescr'=>$urlDescr, 'urlTitle'=>$title, 'title'=>$title, 'imageURL' => $imgURL, 'videoCode'=>'', 'videoURL'=>'', 'siteName'=>$blogTitle, 'cats'=>'', 'authorName'=>'');
437
- //## Actual Post
438
- $ntToPost = new nxs_class_SNAP_LI(); $ret = $ntToPost->doPostToNT($options, $message);
439
- //## Process Results
440
- if (!is_array($ret) || $ret['isPosted']!='1') { //## Error
441
- if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);
442
- } else { $extInfo .= ' | '.$ret['postID']; // ## All Good - log it.
443
- if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo _e('OK - Message Posted, please see your '.$logNT.' Page. ', 'social-networks-auto-poster-facebook-twitter-g'); }
444
- else { nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPosted'=>'1', 'postID'=>$ret['postID'], 'postURL'=>$ret['postURL'], 'pgID'=>$ret['postID'], 'pDate'=>date('Y-m-d H:i:s')));
445
- if (!empty($ret['postURL'])) $extInfo .= ' | <a href="'.$ret['postURL'].'" target="_blank">Post Link</a>'; nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); }
446
  }
447
- //## Return Result
448
- if ($ret['isPosted']=='1') return 200; else return print_r($ret, true);
449
  }
450
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
451
 
452
- ?>
7
  header("Cache-Control: private",false); header("Content-Type: image/jpg"); header("Content-Transfer-Encoding: binary"); echo $imageData; die();
8
  }
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  //## NextScripts Facebook Connection Class
11
+ $nxs_snapAvNts[] = array('code'=>'LI', 'lcode'=>'li', 'name'=>'LinkedIn', 'type'=>'Social Networks', 'ptype'=>'B', 'status'=>'A', 'desc'=>'Post text, article, image or share a link to your profile, group, or company page. ');
12
 
13
  if (!function_exists("nxs_ntp_time")) { function nxs_ntp_time($host='time.nist.gov') { $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); socket_connect($sock, $host, 123);
14
  $msg = "\010" . str_repeat("\0", 47); socket_send($sock, $msg, strlen($msg), 0); socket_recv($sock, $recv, 48, MSG_WAITALL); socket_close($sock);
15
  $data = unpack('N12', $recv); $timestamp = sprintf('%u', $data[9]); $timestamp -= 2208988800; return $timestamp;
16
  }}
17
 
18
+ if (!class_exists("nxs_snapClassLI")) { class nxs_snapClassLI extends nxs_snapClassNT {
19
+ var $ntInfo = array('code'=>'LI', 'lcode'=>'li', 'name'=>'LinkedIn', 'defNName'=>'', 'tstReq' => true, 'instrURL'=>'http://www.nextscripts.com/setup-installation-linkedin-social-networks-auto-poster-wordpress/');
20
+ var $defO = array('nName'=>'', 'do'=>'1', 'pgID'=>'', 'pgcID'=>'', 'appKey'=>'', 'appSec'=>'', 'uName'=>'', 'uPass'=>'', 'uPage'=>'', 'inclTags'=>1, 'msgFormat'=>"New post (%TITLE%) has been published on %SITENAME%", 'msgTFormat'=>"%TITLE%", 'msgCTFormat'=>"%TITLE%", 'msgCFormat'=>"%RAWTEXT%", 'msgATFormat'=>"", 'msgAFormat'=>"", 'imgSize'=>'original');
21
+ //#### Update
22
+ function toLatestVer($ntOpts){ if( !empty($ntOpts['v'])) $v = $ntOpts['v']; else $v = 340; $ntOptsOut = ''; switch ($v) {
23
+ case 340: $ntOptsOut = $this->toLatestVerNTGen($ntOpts); $ntOptsOut['do'] = $ntOpts['do'.$this->ntInfo['code']]; $ntOptsOut['nName'] = $ntOpts['nName'];
24
+ if (!empty($ntOpts['liAPIKey'])) $ntOpts['apiToUse'] = (!empty($ntOpts['isV2']))?'liv2':'liv1'; else if (!empty($ntOpts['ulName']) && !empty($ntOpts['uPass'])) $ntOpts['apiToUse'] = 'nx'; $ntOptsOut['apiToUse'] = $ntOpts['apiToUse'];
25
+ if ($ntOptsOut['apiToUse']=='nx') { $ntOptsOut['uName'] = $ntOpts['ulName']; $ntOptsOut['uPass'] = $ntOpts['uPass']; } else { $ntOptsOut['appKey'] = $ntOpts['liAPIKey']; $ntOptsOut['appSec'] = $ntOpts['liAPISec'];
26
+ $ntOptsOut['oAuthVerifier'] = !empty($ntOpts['liOAuthVerifier'])?$ntOpts['liOAuthVerifier']:''; $ntOptsOut['accessToken'] = !empty($ntOpts['liAccessToken'])?$ntOpts['liAccessToken']:'';
27
+ $ntOptsOut['accessTokenSec'] = !empty($ntOpts['liAccessTokenSecret'])?$ntOpts['liAccessTokenSecret']:''; $ntOptsOut['oAuthToken'] = !empty($ntOpts['liOAuthToken'])?$ntOpts['liOAuthToken']:'';
28
+ $ntOptsOut['oAuthTokenSecret'] = !empty($ntOpts['liOAuthTokenSecret'])?$ntOpts['liOAuthTokenSecret']:''; $ntOptsOut['accessTokenExp'] = !empty($ntOpts['liAccessTokenExp'])?$ntOpts['liAccessTokenExp']:'';
29
+ $ntOptsOut['liUserID'] = !empty($ntOpts['liUserID'])?$ntOpts['liUserID']:''; $ntOptsOut['liUserInfo'] = !empty($ntOpts['liUserInfo'])?$ntOpts['liUserInfo']:'';
30
+ } $ntOptsOut['imgSize'] = !empty($ntOpts['imgSize'])?$ntOpts['imgSize']:''; $ntOptsOut['msgFormat'] = $ntOpts['liMsgFormat']; $ntOptsOut['msgTFormat'] = $ntOpts['liMsgFormatT']; $ntOptsOut['msgAFormat'] = $ntOpts['liMsgAFrmt'];
31
+ $ntOptsOut['liUserInfo'] = !empty($ntOpts['liUserInfo'])?$ntOpts['liUserInfo']:''; $ntOptsOut['postType'] = $ntOpts['postType']; $ntOptsOut['grpID'] = !empty($ntOpts['grpID'])?$ntOpts['grpID']:''; $ntOptsOut['whToPost'] = 'PR';
32
+ if ( substr($ntOpts['uPage'], 0, 4)=='http' ) { if (stripos($ntOpts['uPage'], 'groups')!==false && stripos($ntOpts['uPage'], 'gid=')!==false) { $lid = CutFromTo($ntOpts['uPage'].'&', 'gid=', '&'); }
33
+ else { $lid = $ntOpts['uPage']; if (strpos($lid, '?')!==false) $lid = substr($lid, 0, strpos($lid, '?')); if (substr($lid, -1)=='/') $lid = substr($lid, 0, -1); $lid = substr(strrchr($lid, "/"), 1); }
34
+ } $ntOptsOut['pgcID'] = ''; $ntOptsOut['pggID'] = ''; if (!empty($lid)) { if (stripos($ntOpts['uPage'], 'groups')!==false) { $ntOptsOut['whToPost'] = 'G'; $ntOptsOut['pggID'] = $lid; } else { $ntOptsOut['whToPost'] = 'C'; $ntOptsOut['pgcID'] = $lid; }}
35
+ $ntOptsOut = nxs_arrMergeCheck($ntOptsOut, $this->defO); $ntOptsOut['isUpdd'] = '1'; $ntOptsOut['v'] = NXS_SETV;
36
+ break;
37
+ }
38
+ return !empty($ntOptsOut)?$ntOptsOut:$ntOpts;
39
+ }
40
+ //#### Show Common Settings
41
+ function showGenNTSettings($ntOpts){ $this->nt = $ntOpts; $this->showNTGroup(); }
42
+ //#### Show NEW Settings Page
43
+ function showNewNTSettings($ii){$this->showGNewNTSettings($ii, $this->defO); }
44
+ //#### Show Unit Settings
45
+ function checkIfSetupFinished($options) { return !empty($options['accessToken']) || !empty($options['uPass']); }
46
+ public function doAuth() { $ntInfo = $this->ntInfo; global $nxs_snapSetPgURL;
47
  // V2 Auth
48
+ if ( isset($_GET['code']) && $_GET['code']!='' && isset($_GET['state']) && substr($_GET['state'], 0, 7) == 'nxs-li-'){ $this->showAuthTop(); $at = $_GET['code']; $ii = str_replace('nxs-li-','',$_GET['state']);
49
+ echo "----=={ oAuth 2.0 Wordflow }==----<br/><br/>";
50
+ $gGet = $_GET; unset($gGet['code']); unset($gGet['state']); unset($gGet['post_type']); unset($gGet['activated']); unset($gGet['stylesheet']); $sturl = explode('?',$nxs_snapSetPgURL); $nxs_snapSetPgURL = $sturl[0].((!empty($gGet))?'?'.http_build_query($gGet):'');
51
+ $nto = $this->nt[$ii]; $wprg = array(); $wprg['sslverify'] = false;
52
+ if (isset($nto['appKey'])){ echo "-="; prr($nto);// die();
53
+ $tknURL = 'https://www.linkedin.com/uas/oauth2/accessToken?grant_type=authorization_code&code='.$at.'&redirect_uri='.urlencode($nxs_snapSetPgURL).'&client_id='.$nto['appKey'].'&client_secret='.$nto['appSec'];
54
+ $response = nxs_remote_post($tknURL, $wprg); prr($tknURL);
55
+ if((is_object($response)&&(isset($response->errors)))){ prr($response); die('</div></div>'); }
56
+ if (is_array($response)&& stripos($response['body'],'"error":')!==false){ prr($response['body']); prr(json_decode($response['body'],true)); die('</div></div>'); }
57
+ $resp = json_decode($response['body'], true); prr($resp); if (!is_array($resp) || empty($resp['access_token'])) { prr($resp); die('</div></div>'); }
 
58
  if (function_exists('get_option')) $currTime = time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); else $currTime = time();
59
+ $nto['accessToken'] = $resp['access_token']; // $nto['accessTokenSec'] = 'No Need for oAuth V2'; $nto['oAuthVerifier'] = 'No Need for oAuth V2';
60
+ $nto['accessTokenExp'] = $currTime + $resp['expires_in']; echo "<br/>----=={ Expires: ".date('Y-m-d H:i:s', $nto['accessTokenExp'])." }==---- <br/>";
61
+ $tknURL = 'https://api.linkedin.com/v1/people/~:(id,first-name,last-name)?format=json&oauth2_access_token='.$nto['accessToken']; $response = nxs_remote_get( $tknURL, nxs_mkRemOptsArr(nxs_getNXSHeaders()) );
62
+ prr($tknURL); prr($response); if (is_nxs_error($response)) die('</div></div>'); $user = json_decode($response['body'], true);
63
+ if (!empty($user['id'])) { $nto['liUserID'] = $user['id']; $nto['liUserInfo'] = $user['firstName'].$user['lastName'].(!empty($user['id'])?" (".$user['id'].")":'');
64
+ if (empty($nto['pgID'])) $nto['pgID'] = 'p'; nxs_save_glbNtwrks($ntInfo['lcode'],$ii,$nto,'*'); prr($nto['liUserInfo'], 'Authorized user');
65
+ $gURL = 'https://api.linkedin.com/v1/companies?format=json&is-company-admin=true&oauth2_access_token='.$nto['accessToken']; $response = nxs_remote_get( $gURL, nxs_mkRemOptsArr(nxs_getNXSHeaders()) );
66
+ prr($response); $userPages = json_decode($response['body'], true); prr($userPages, 'USER PAGES:'); $pgs = '';
67
+ if (!empty($userPages['values'])) foreach ($userPages['values'] as $up) $pgs .= '<option '.($up['id']==$nto['pgID'] ? 'selected="selected"':'').' value="'.$up['id'].'">'.$up['name'].' ('.$up['id'].')</option>';
68
+ $opVal = array(); $opNm = 'nxs_snap_li_'.sha1('nxs_snap_li'.$nto['liUserID'].$nto['appKey']); $opVal['pgList'] = $pgs; nxs_saveOption($opNm, $opVal);
69
+ echo '<div style="text-align:center;color:green; font-weight: bold; font-size:20px;"> ALL OK. You have been authorized.</div><script type="text/javascript">setTimeout(function(){ window.location = "'.$nxs_snapSetPgURL.'"; }, 1000);</script>';
70
+ }
71
+ } die('</div></div>');
72
  }
73
  // V1 Auth
74
+ if ( isset($_GET['auth']) && $_GET['auth']=='li'){ $this->showAuthTop(); require_once('apis/liOAuth.php'); $options = $this->nt[$_GET['acc']]; $ii = $_GET['acc'];
75
+ $api_key = $options['appKey']; $api_secret = $options['appSec']; $callback_url = $nxs_snapSetPgURL."&auth=lia&acc=".$_GET['acc'];
76
+ $li_oauth = new nsx_LinkedIn($api_key, $api_secret, $callback_url); $request_token = $li_oauth->getRequestToken(); //echo "####"; prr($request_token); die();
77
+ if (!is_object($request_token)) { echo "### LinkedIn Authorization Error:"; prr($request_token);
78
+ if (is_string($request_token) && stripos($request_token, 'timestamp')!==false) { echo "Your Server Time: ".date('m/d/Y h:i:s a'); echo " Correct Time: ".date('m/d/Y h:i:s a', nxs_ntp_time('t1.timegps.net')); } die('</div></div>');
79
+ } $options['oAuthToken'] = $request_token->key; $options['oAuthTokenSecret'] = $request_token->secret; prr($li_oauth);
80
+ switch ($li_oauth->http_code) { case 200: $url = $li_oauth->generateAuthorizeUrl(); nxs_save_glbNtwrks($ntInfo['lcode'],$ii,$options,'*'); prr($url);
81
+ echo '<div style="text-align:center;color:green; font-weight: bold; font-size:20px;" >ALL OK. Redirecting to authorization....</div><script type="text/javascript">setTimeout(function(){ window.location = "'.$url.'"; }, 1000);</script>'; break;
82
+ default: echo '<br/><b style="color:red">Could not connect to LinkedIn. Refresh the page or try again later.</b>'; die('</div></div>');
83
+ } die('</div></div>');
84
+ }
85
+ if ( isset($_GET['auth']) && $_GET['auth']=='lia'){ $this->showAuthTop(); require_once('apis/liOAuth.php'); $ii = $_GET['acc']; $options = $this->nt[$_GET['acc']]; $api_key = $options['appKey']; $api_secret = $options['appSec'];
86
+ $li_oauth = new nsx_LinkedIn($api_key, $api_secret); $li_oauth->request_token = new nsx_trOAuthConsumer($options['oAuthToken'], $options['oAuthTokenSecret'], 1);
87
+ $li_oauth->oauth_verifier = $_REQUEST['oauth_verifier']; $li_oauth->getAccessToken($_REQUEST['oauth_verifier']); $options['oAuthVerifier'] = $_REQUEST['oauth_verifier'];
88
+ $options['accessToken'] = $li_oauth->access_token->key; $options['accessTokenSec'] = $li_oauth->access_token->secret;
89
+ try{$xml_response = $li_oauth->getProfile("~:(id,first-name,last-name)");} catch (Exception $o){prr($o); die("<span style='color:red;'>ERROR: Authorization Error</span></div></div>");}
90
+ if (stripos($xml_response,'<first-name>')!==false) $userinfo = CutFromTo($xml_response, '<id>','</id>')." - ".CutFromTo($xml_response, '<first-name>','</first-name>')." ".CutFromTo($xml_response, '<last-name>','</last-name>'); else $userinfo='';
91
+ if ($userinfo!='') { $options['liUserInfo'] = $userinfo; prr($userinfo); nxs_save_glbNtwrks($ntInfo['lcode'],$ii,$options,'*');
92
+ echo '<div style="text-align:center;color:green; font-weight: bold; font-size:20px;" >ALL OK. You have been authorized. Refreshing page....</div><script type="text/javascript">setTimeout(function(){ window.location = "'.$nxs_snapSetPgURL.'"; }, 3000);</script>'; die('</div></div>');
93
+ } prr($xml_response); die("<span style='color:red;'>ERROR: Something is Wrong with your LinkedIn account</span></div></div>");
94
+ }
95
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
 
97
+ function getListOfPagesLIV2($networks){ $opVal = array(); if (empty($_POST['u'])) return $opVal; $opNm = 'nxs_snap_li_'.sha1('nxs_snap_li'.$_POST['u'].$_POST['p']); $opVal = nxs_getOption($opNm); $ii = $_POST['ii']; if (empty($networks['li'][$ii]['accessToken'])) return $opVal;
98
+ $currPstAs = !empty($_POST['pgID'])?$_POST['pgID']:(!empty($networks['li'][$ii])?$networks['li'][$ii]['pgID']:'');
99
+ if (empty($_POST['force']) && !empty($opVal['pgList']) ) $pgs = $opVal['pgList']; else { $options = $networks['li'][$ii];
100
+ $gURL = 'https://api.linkedin.com/v1/companies?format=json&is-company-admin=true&count=100&oauth2_access_token='.$options['accessToken']; $response = nxs_remote_get( $gURL, nxs_mkRemOptsArr(nxs_getNXSHeaders()) );
101
+ $userPages = json_decode($response['body'], true); $pgs = '';
102
+ if (!empty($userPages['values'])) foreach ($userPages['values'] as $up) $pgs .= '<option '.($up['id']==$options['pgID'] ? 'selected="selected"':'').' value="'.$up['id'].'">'.$up['name'].' ('.$up['id'].')</option>';
103
+ } $pgCust = (!empty($pgs) && !empty($currPstAs) && stripos($pgs,$currPstAs)===false)?'<option selected="selected" value="'.$currPstAs.'">'.$currPstAs.'</option>':'';
104
+ if (!empty($_POST['isOut'])) echo $pgCust.'<option '.($options['pgID']=='p'?'selected="selected" ':'').'value="p">'.__('Profile').'</option>'.$pgs.'<option style="color:#BD5200" value="a">'.__('...enter the Page ID').'</option>';
105
+ $opVal['pgList'] = $pgs; nxs_saveOption($opNm, $opVal); return $opVal;
106
+ }
107
+
108
+ function getListOfPagesNXS($networks){ $opVal = array(); $pass = 'g9c1a'.nsx_doEncode($_POST['p']); $opNm = 'nxs_snap_li_'.sha1('nxs_snap_li'.$_POST['u'].$pass); $opVal = nxs_getOption($opNm); $ii = $_POST['ii']; $nt = new nxsAPI_LI(); // prr($opVal);
109
+ $currPstAs = !empty($_POST['pgcID'])?$_POST['pgcID']:(!empty($networks['li'][$ii])?$networks['li'][$ii]['pgcID']:'');
110
+ if (empty($_POST['force']) && !empty($opVal['ck']) && !empty($opVal['pgsList']) ) $pgs = $opVal['pgsList']; else { if (!empty($opVal['ck'])) $nt->ck = $opVal['ck']; $loginError=$nt->connect($_POST['u'],$_POST['p']);
111
+ if (!$loginError){ $opVal['ck'] = $nt->ck; $pgs = $nt->getPgsList($currPstAs); }
112
+ else { $outMsg = '<b style="color:red;">'.__('Login Problem').'&nbsp;-&nbsp;'.$loginError.'</b>'; if (!empty($_POST['isOut'])) echo $outMsg; return $outMsg; }
113
+ } $pgCust = (!empty($pgs) && !empty($currPstAs) && stripos($pgs,$currPstAs)===false)?'<option selected="selected" value="'.$currPstAs.'">'.$currPstAs.'</option>':'';
114
+ if (!empty($_POST['isOut'])) echo $pgCust.$pgs.'<option style="color:#BD5200" value="a">'.__('...enter the Company Page ID').'</option>';
115
+ $opVal['pgsList'] = $pgs; nxs_saveOption($opNm, $opVal); return $opVal;
116
+ }
117
+ function getListOfGroupsNXS($networks){ $opVal = array(); $pass = 'g9c1a'.nsx_doEncode($_POST['p']); $opNm = 'nxs_snap_li_'.sha1('nxs_snap_li'.$_POST['u'].$pass); $opVal = nxs_getOption($opNm); $ii = $_POST['ii']; $nt = new nxsAPI_LI(); // prr($opVal);
118
+ $currPstAs = !empty($_POST['pggID'])?$_POST['pggID']:(!empty($networks['li'][$ii]['pggID'])?$networks['li'][$ii]['pggID']:'');
119
+ if (empty($_POST['force']) && !empty($opVal['ck']) && !empty($opVal['grpList']) ) $pgs = $opVal['grpList']; else { if (!empty($opVal['ck'])) $nt->ck = $opVal['ck']; $loginError=$nt->connect($_POST['u'],$_POST['p']);
120
+ if (!$loginError){ $opVal['ck'] = $nt->ck; $pgs = $nt->getGrpList($currPstAs); }
121
+ else { $outMsg = '<b style="color:red;">'.__('Login Problem').'&nbsp;-&nbsp;'.$loginError.'</b>'; if (!empty($_POST['isOut'])) echo $outMsg; return $outMsg; }
122
+ } $pgCust = (!empty($pgs) && !empty($currPstAs) && stripos($pgs,$currPstAs)===false)?'<option selected="selected" value="'.$currPstAs.'">'.$currPstAs.'</option>':'';
123
+ if (!empty($_POST['isOut'])) echo $pgCust.$pgs.'<option style="color:#BD5200" value="a">'.__('...enter the Group ID').'</option>';
124
+ $opVal['grpList'] = $pgs; nxs_saveOption($opNm, $opVal); return $opVal;
125
+ }
126
+
127
+ function accTab($ii, $options, $isNew=false){ global $nxs_snapSetPgURL; $ntInfo = $this->ntInfo; $nt = $ntInfo['lcode']; $ntU = $ntInfo['code']; /* prr($options); */?>
128
 
129
+ <div style="display: <?php echo (empty($options['apiToUse']))?"block":"none"; ?>;">
130
+ <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>
131
+ <span style="color:#005800; font-weight: bold; font-size: 14px;">LinkedIn Native API V1:</span> Free built-in API from LinkedIn. oAuth 1.0a. <br/><b>Can post to profiles only</b>. <br/><span style="color:#000080"><?php _e('Advantages', 'nxs_snap'); ?></span>: Free, Official. <b>Tokens do not expire</b>. <br/><span style="color:#800000"><?php _e('Disadvantages', 'nxs_snap'); ?></span>: Depreciated by LinkedIn. Can't make "image" posts. It can't post to Pulse, Company pages, and Groups. <br/><br/>
132
+ <span style="color:#005800; font-weight: bold; font-size: 14px;">LinkedIn Native API V2:</span> Free built-in API from LinkedIn. oAuth 2.0. <br/><b>Can post to profiles and company pages.</b> <br/><span style="color:#000080"><?php _e('Advantages', 'nxs_snap'); ?></span>: Free, Official. <br/><span style="color:#800000"><?php _e('Disadvantages', 'nxs_snap'); ?></span>: <b>Tokens expire every 30 days</b>. Can't make "image" posts. It can't post to Pulse and Groups.<br/><br/>
133
+ <span style="color:#005800; font-weight: bold; font-size: 14px;">NextScripts API for LinkedIn:</span> Premium API with extended functionality. <br/><b>Can post to Pulse, Profile, Company pages, and Groups.</b> <br/><span style="color:#000080"><?php _e('Advantages', 'nxs_snap'); ?></span>: Easier to configure. Only API that can post to Pulse, Groups and make Image posts.<br/><span style="color:#800000"><?php _e('Disadvantages', 'nxs_snap'); ?></span>: Not free. Less secure - requires your password.<br/><br/>
134
 
135
+ <select name="<?php echo $nt; ?>[<?php echo $ii; ?>][apiToUse]" onchange="jQuery('.nxs_<?php echo $nt; ?>_apidiv_<?php echo $ii; ?>').hide(); jQuery('.nxs_<?php echo $nt; ?>_api'+jQuery(this).val()+'div_<?php echo $ii; ?>').show(); "><option <?php echo (!empty($options['apiToUse']) && $options['apiToUse'] =='liv1')?"selected":""; ?> value="liv1">LinkedIn V1 API</option><option <?php echo (empty($options['apiToUse']) || $options['apiToUse'] =='liv2')?"selected":""; ?> value="liv2">LinkedIn V2 API</option><option <?php echo (!empty($options['apiToUse']) && $options['apiToUse'] =='nx')?"selected":""; ?> value="nx">NextScripts API</option></select><hr/>
136
 
137
  </div>
138
 
139
+ <div id="nxs_<?php echo $nt; ?>_apiliv1div_<?php echo $ii; ?>" class="nxs_<?php echo $nt; ?>_apidiv_<?php echo $ii; ?> nxs_<?php echo $nt; ?>_apiliv1div_<?php echo $ii; ?>" style="display: <?php echo (!empty($options['apiToUse']) && $options['apiToUse'] =='liv1')?"block":"none"; ?>;"><h3>LinkedIn API V1</h3>
140
+ <div class="subDiv" id="sub<?php echo $ii; ?>DivL" style="display: block;"> <?php $this->elemKeySecret($ii,'Client ID','Client Secret', $options['appKey'], $options['appSec'],'appKey','appSec','https://www.linkedin.com/developer/apps'); ?>
141
+ <br/><br/>
142
+ <?php if($options['appKey']=='') { ?>
143
+ <b><?php _e('Authorize Your '.$ntInfo['name'].' Account', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> <?php _e('Please click "Update Settings" to be able to Authorize your account.', 'social-networks-auto-poster-facebook-twitter-g');
144
+ } else { if(!empty($options['accessToken']) && !empty($options['accessTokenSec'])) {
145
+ _e('Your '.$ntInfo['name'].' Account has been authorized.', 'social-networks-auto-poster-facebook-twitter-g'); ?> <br/>User: <?php _e(apply_filters('format_to_edit', htmlentities($options['liUserInfo'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g'); ?>.
146
+ <?php _e('You can', 'social-networks-auto-poster-facebook-twitter-g'); ?> Re- <?php } ?>
147
+ <a href="<?php echo $nxs_snapSetPgURL; ?>&auth=li&acc=<?php echo $ii; ?>">Authorize Your LinkedIn Account</a>
148
+ <?php if (empty($options['accessToken'])) { ?> <div class="blnkg">&lt;=== <?php _e('Authorize your account', 'social-networks-auto-poster-facebook-twitter-g'); ?> ===</div> <?php }
149
+ } ?><br/><br/>
150
+ </div>
151
+ </div>
152
+ <div id="nxs_<?php echo $nt; ?>_apiliv2div_<?php echo $ii; ?>" class="nxs_<?php echo $nt; ?>_apidiv_<?php echo $ii; ?> nxs_<?php echo $nt; ?>_apiliv2div_<?php echo $ii; ?>" style="display: <?php echo (empty($options['apiToUse']) || $options['apiToUse'] =='liv2')?"block":"none"; ?>;"><h3>LinkedIn API V2</h3>
153
+ <div class="subDiv" id="sub<?php echo $ii; ?>DivL" style="display: block;"> <?php $this->elemKeySecret($ii,'Client ID','Client Secret', $options['appKey'], $options['appSec'],'appKey2','appSec2','https://www.linkedin.com/developer/apps'); ?><br/><br/>
154
+ <?php if(!empty($options['accessToken'])) {
155
+ _e('Your '.$ntInfo['name'].' Account has been authorized.', 'social-networks-auto-poster-facebook-twitter-g'); ?> <br/>User: <?php _e(apply_filters('format_to_edit', htmlentities($options['liUserInfo'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g'); ?>.
156
+ <?php _e('You can', 'social-networks-auto-poster-facebook-twitter-g'); ?> Re- <?php } ?>
157
+ <a href="#" onclick="var url = 'https://www.linkedin.com/uas/oauth2/authorization?response_type=code&client_id='+jQuery('#liappKey2<?php echo $ii; ?>').val()+'&scope=r_basicprofile+r_emailaddress+w_share+rw_company_admin&state=nxs-li-<?php echo $ii; ?>&redirect_uri=<?php echo trim(urlencode($nxs_snapSetPgURL));?>'; nxs_svSetAdv('<?php echo $nt; ?>', '<?php echo $ii; ?>', '<?php echo $isNew?'dom'.$ntU.$ii.'Div':'nxsAllAccntsDiv'; ?>','nxs<?php echo $ntU; ?>MsgDiv<?php echo $ii; ?>',url,'1'); return false;">Authorize Your LinkedIn Account</a>
158
+ <?php if (empty($options['accessToken'])) { ?> <div class="blnkg">&lt;=== <?php _e('Authorize your account', 'social-networks-auto-poster-facebook-twitter-g'); ?> ===</div> <?php } ?><br/><br/>
159
+ </div>
160
+
161
+ <?php if (empty($options['liUserID'])) $options['liUserID'] = ''; //## List of Pages
162
+ $opNm = 'nxs_snap_li_'.sha1('nxs_snap_li'.$options['liUserID'].$options['appKey']); $opVal = nxs_getOption($opNm);
163
+ if (empty($opVal)) { $tPST = (!empty($_POST))?$_POST:''; $_POST['pgID'] = $options['pgID']; $_POST['u'] = $options['liUserID']; $_POST['p'] = $options['appKey']; $_POST['ii'] = $ii; $ntw[$nt][$ii]=$options; $opVal = $this->getListOfPagesLIV2($ntw); $_POST = $tPST; }
164
+ if (!empty($opVal) & !is_array($opVal)) $options['uMsg'] = $opVal; else { if (!empty($opVal) & is_array($opVal)) $options = array_merge($options, $opVal); }
165
+ ?><br/ ><div style="width:100%;"><b><?php _e('Where to Post', 'nxs_snap'); ?></b>&nbsp;(<?php _e('Please select your Profile or Company Page', 'nxs_snap'); ?>)</div>
166
+ <div id="nxsLIInfoDiv<?php echo $ii; ?>" style="<?php echo empty($options['accessToken'])?'display:none;':''; ?>">
167
+ <div style="width:100%;">
168
+ <div>
169
+ <select id="lipgID<?php echo $ii; ?>" onchange="nxs_liPageChange('<?php echo $ii;?>',jQuery(this));" name="li[<?php echo $ii;?>][pgID]">
170
+ <?php $pgi = !empty($options['pgList'])?$options['pgList']:'';
171
+ if (!empty($options['pgID'])) { echo (!empty($options['pgID']) && stripos($pgi,$options['pgID'])===false)?'<option selected="selected" value="'.$options['pgID'].'">'.$options['pgID'].'</option>':''; }
172
+ if (!empty($options['pgID'])) { $pgi = str_ireplace('selected="selected" ','',$pgi); $pgi = str_ireplace('value="'.$options['pgID'].'"','selected="selected" value="'.$options['pgID'].'"',$pgi); }
173
+ echo '<option '.($options['pgID']=='p'?'selected="selected" ':'').'value="p">'.__('Profile').'</option>'; echo $pgi;
174
+ ?><option value="a"><?php _e('.... Enter the Page ID'); ?></option>
175
+ </select><div id="nxsLIInfoDivBlock<?php echo $ii; ?>" style="display: inline-block;"> <input type="text" style="display: none;" id="liInpCst<?php echo $ii; ?>" value="<?php echo $options['pgID']; ?>" onchange="nxs_InpToDDChange(jQuery(this));" data-tid="lipgID<?php echo $ii; ?>" />
176
+ <div style="display: inline-block;"><a onclick="nxs_liGetPages(<?php echo $ii;?>, 1); jQuery(this).blur(); return false;" href="#"><img id="<?php echo $nt.$ii;?>rfrshImg" style="vertical-align: middle;" src='<?php echo NXS_PLURL; ?>img/refresh16.png' /></a></div></div> <img id="<?php echo $nt.$ii;?>ldImg" style="display: none;vertical-align: middle;" src='<?php echo NXS_PLURL; ?>img/ajax-loader-sm.gif' />
177
+ </div>
178
+ </div> <div id="nxsLIMsgDiv<?php echo $ii; ?>"><?php if (!empty($options['uMsg'])) echo $options['uMsg']; ?><?php if ($isNew) { ?><?php _e('Please authorize your account', 'nxs_snap'); ?><?php } ?></div>
179
+ </div> <input type="hidden" id="liAuthUser<?php echo $ii; ?>" value="<?php echo $options['authUser']; ?>"/> <br/>
180
+
181
+
182
+ </div>
183
+ <div id="nxs_<?php echo $nt; ?>_apinxdiv_<?php echo $ii; ?>" class="nxs_<?php echo $nt; ?>_apidiv_<?php echo $ii; ?> nxs_<?php echo $nt; ?>_apinxdiv_<?php echo $ii; ?>" style="display: <?php echo (!empty($options['apiToUse']) && $options['apiToUse'] =='nx')?"block":"none"; ?>;"><h3>NextScripts API</h3>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
184
 
185
+ <?php if (class_exists('nxsAPI_LI')) { $opNm = 'nxs_snap_li_'.sha1('nxs_snap_li'.$options['uName'].$options['uPass']); $opVal = nxs_getOption($opNm); //prr($opVal);
186
+ if (empty($opVal)){$tPST=(!empty($_POST))?$_POST:''; $_POST['pgcID']=!empty($options['pgcID'])?$options['pgcID']:''; $_POST['pggID']=!empty($options['pggID'])?$options['pggID']:'';
187
+ if(!empty($options['uPass'])){ $_POST['u']=$options['uName']; $_POST['p']=$options['uPass']; $_POST['ii']=$ii; $ntw[$nt][$ii]=$options; $opVal = $this->getListOfPagesNXS($ntw); $opVal = $this->getListOfGroupsNXS($ntw); }$_POST = $tPST; }
188
+ if (!empty($opVal) & !is_array($opVal)) $options['uMsg'] = $opVal; else { if (!empty($opVal) & is_array($opVal)) $options = array_merge($options, $opVal); }
189
+ ?>
190
+ <div class="subDiv" id="sub<?php echo $ii; ?>DivN" style="display: block;"><?php $this->elemUserPass($ii, $options['uName'], $options['uPass']); ?></div><br/>
191
+ <script type="text/javascript">
192
+ jQuery('#apLIUName<?php echo $ii; ?>').change(function() { var u = jQuery(this).val(); var p = jQuery('#apLIPass<?php echo $ii; ?>').val(); if( u!='' && p!='' ) { nxs_li2GetPages(<?php echo $ii; ?>,0); } });
193
+ jQuery('#apLIPass<?php echo $ii; ?>').change(function() { var u = jQuery('#apLIUName<?php echo $ii; ?>').val(); var p = jQuery(this).val(); if( u!='' && p!='' ) { nxs_li2GetPages(<?php echo $ii; ?>,0); } });
194
 
195
+ jQuery('.liWhereToPost<?php echo $ii; ?>').change(function() { if (jQuery(this).val()!='P') jQuery('#liPostType<?php echo $ii; ?>').show(); else jQuery('#liPostType<?php echo $ii; ?>').hide(); });
196
 
197
+ </script>
198
+ <div style="width:100%;"><b style="font-size: 15px;"><?php _e('Where to Post', 'social-networks-auto-poster-facebook-twitter-g'); if (empty($options['whToPost'])) $options['whToPost'] = 'PR'; ?>:</b> </div>
199
+ <div style="margin-left: 10px;">
200
+ <input class="liWhereToPost<?php echo $ii; ?>" type="radio" name="li[<?php echo $ii; ?>][whToPost]" value="PR" <?php if ($options['whToPost'] == 'PR') echo 'checked="checked"'; ?> /> <?php _e('Profile Update', 'social-networks-auto-poster-facebook-twitter-g'); ?> - <i><?php _e('Post to your profile', 'social-networks-auto-poster-facebook-twitter-g'); ?></i><br/>
201
+ <input class="liWhereToPost<?php echo $ii; ?>" type="radio" name="li[<?php echo $ii; ?>][whToPost]" value="C" <?php if ($options['whToPost'] == 'C') echo 'checked="checked"'; ?> /> <?php _e('Company Page', 'social-networks-auto-poster-facebook-twitter-g'); ?> - <i><?php _e('Post to Company page', 'social-networks-auto-poster-facebook-twitter-g'); ?></i><br/>
 
 
202
 
203
+ <div style="margin-left: 30px;<?php echo (empty($options['uName']) && empty($options['uPass']))?'display:none;':''; ?>" id="nxsLI2InfoDiv<?php echo $ii; ?>">
204
+ <div style="width:100%;">
205
+ <div>
206
+ <select id="li2pgID<?php echo $ii; ?>" onchange="nxs_li2PageChange('<?php echo $ii;?>',jQuery(this));" name="li[<?php echo $ii;?>][pgcID]">
207
+ <?php $pgi = !empty($options['pgsList'])?$options['pgsList']:'';
208
+ if (!empty($options['pgcID'])) { echo (!empty($options['pgcID']) && stripos($pgi,$options['pgcID'])===false)?'<option selected="selected" value="'.$options['pgcID'].'">'.$options['pgcID'].'</option>':''; }
209
+ if (!empty($options['pgcID'])) { $pgi = str_ireplace('selected="selected" ','',$pgi); $pgi = str_ireplace('value="'.$options['pgcID'].'"','selected="selected" value="'.$options['pgcID'].'"',$pgi);
210
+ $pgi = str_ireplace('data-val="'.$options['pgcID'].'"','selected="selected" data-val="'.$options['pgcID'].'"',$pgi);
211
+ }
212
+ echo $pgi;
213
+ ?><option value="a"><?php _e('.... Enter the Company Page ID'); ?></option>
214
+ </select>
215
+ <div id="nxsLI2InfoDivBlock<?php echo $ii; ?>" style="display: inline-block;">
216
+ <input type="text" style="display: none;" id="li2InpCst<?php echo $ii; ?>" value="<?php echo $options['pgcID']; ?>" onblur="nxs_InpToDDBlur(jQuery(this));" onchange="nxs_InpToDDChange(jQuery(this));" data-tid="li2pgID<?php echo $ii; ?>" />
217
+ <div style="display: inline-block;"><a onclick="nxs_li2GetPages(<?php echo $ii;?>, 1); jQuery(this).blur(); return false;" href="#"><img id="<?php echo $nt.$ii;?>2rfrshImg" style="vertical-align: middle;" src='<?php echo NXS_PLURL; ?>img/refresh16.png' /></a></div></div> <img id="<?php echo $nt.$ii;?>2ldImg" style="display: none;vertical-align: middle;" src='<?php echo NXS_PLURL; ?>img/ajax-loader-sm.gif' />
218
+ </div>
219
+ </div> <div id="nxsLI2MsgDiv<?php echo $ii; ?>"><?php if (!empty($options['uMsg'])) echo $options['uMsg']; ?><?php if ($isNew) { ?><i style="color: #800080"><?php _e('Please Enter your username and password to select your page', 'nxs_snap'); ?><?php } ?></i></div>
220
+ </div>
221
+ <input class="liWhereToPost<?php echo $ii; ?>" type="radio" name="li[<?php echo $ii; ?>][whToPost]" value="G" <?php if ($options['whToPost'] == 'G') echo 'checked="checked"'; ?> /> <?php _e('Group', 'social-networks-auto-poster-facebook-twitter-g'); ?> - <i><?php _e('Post to LinkedIn Group', 'social-networks-auto-poster-facebook-twitter-g'); ?></i><br/>
222
 
223
+ <div style="margin-left: 30px;<?php echo (empty($options['uName']) && empty($options['uPass']))?'display:none;':''; ?>" id="nxsLI2GInfoDiv<?php echo $ii; ?>">
224
+ <div style="width:100%;">
225
+ <div>
226
+ <select id="li2GpgID<?php echo $ii; ?>" onchange="nxs_li2GPageChange('<?php echo $ii;?>',jQuery(this));" name="li[<?php echo $ii;?>][pggID]">
227
+ <?php $pgi = !empty($options['grpList'])?$options['grpList']:'';
228
+ if (!empty($options['pggID'])) { echo (!empty($options['pggID']) && stripos($pgi,$options['pggID'])===false)?'<option selected="selected" value="'.$options['pggID'].'">'.$options['pggID'].'</option>':''; }
229
+ if (!empty($options['pggID'])) { $pgi = str_ireplace('selected="selected" ','',$pgi); $pgi = str_ireplace('value="'.$options['pggID'].'"','selected="selected" value="'.$options['pggID'].'"',$pgi);
230
+ $pgi = str_ireplace('data-val="'.$options['pggID'].'"','selected="selected" data-val="'.$options['pggID'].'"',$pgi);
231
+ }
232
+ echo $pgi;
233
+ ?><option value="a"><?php _e('.... Enter the Group ID'); ?></option>
234
+ </select>
235
+ <div id="nxsLI2GInfoDivBlock<?php echo $ii; ?>" style="display: inline-block;">
236
+ <input type="text" style="display: none;" id="li2GInpCst<?php echo $ii; ?>" value="<?php echo $options['pgcID']; ?>" onblur="nxs_InpToDDBlur(jQuery(this));" onchange="nxs_InpToDDChange(jQuery(this));" data-tid="li2GpgID<?php echo $ii; ?>" />
237
+ </div> <img id="<?php echo $nt.$ii;?>3ldImg" style="display: none;vertical-align: middle;" src='<?php echo NXS_PLURL; ?>img/ajax-loader-sm.gif' />
238
+ </div>
239
+ </div>
240
+ <?php $this->elemTitleFormat($ii,'Group Title Format','msgTFormat',empty($options['msgTFormat'])?'%TITLE%':$options['msgTFormat']); ?>
241
+ </div>
242
+ <input class="liWhereToPost<?php echo $ii; ?>" type="radio" name="li[<?php echo $ii; ?>][whToPost]" value="P" <?php if ($options['whToPost'] == 'P') echo 'checked="checked"'; ?> /> <?php _e('Pulse Article', 'social-networks-auto-poster-facebook-twitter-g'); ?> - <i><?php _e('Rich text post article shared to the "Pulse" section', 'social-networks-auto-poster-facebook-twitter-g'); ?></i><br/>
243
 
244
+ <div style="margin-left: 30px;">
245
+ <?php $this->elemTitleFormat($ii,'Article Title Format','msgCTFormat',empty($options['msgCTFormat'])?'%TITLE%':$options['msgCTFormat']); ?> <?php $this->elemMsgFormat($ii,'Article Text Format','msgCFormat',empty($options['msgCFormat'])?'%RAWTEXT%':$options['msgCFormat']); ?>
246
+ </div>
247
 
248
+ </div>
249
 
250
+ <br/>
251
+
252
+ <?php } else { nxs_show_noLibWrn('"NextScripts API Library for LinkedIN" is NOT installed'); } ?>
253
+ </div><br/>
254
+
255
+ <?php $this->elemMsgFormat($ii,'Message Format','msgFormat',$options['msgFormat']); ?>
256
+
257
+ <div id="liPostType<?php echo $ii; ?>" style="<?php echo (!empty($options['whToPost']) && $options['whToPost']=='P')?'display:none;':''; ?>">
258
+ <div style="width:100%;"><strong id="altFormatText">Post Type:</strong> </div>
259
+ <div style="margin-left: 10px;">
260
+ <?php if(empty($options['postType'])) {if (( !empty($options['liAttch']) && (int)$options['liAttch'] == 1) || $isNew) $options['postType'] = 'A';} ?>
261
+ <input class="liPostType<?php echo $ii; ?>" type="radio" name="li[<?php echo $ii; ?>][postType]" value="T" <?php if ($options['postType'] == 'T') echo 'checked="checked"'; ?> /> <?php _e('Text Post', 'social-networks-auto-poster-facebook-twitter-g'); ?> - <i><?php _e('just text message', 'social-networks-auto-poster-facebook-twitter-g'); ?></i><br/>
262
+ <span class="nxs_li_nxapi_<?php echo $ii; ?> nxs_<?php echo $nt; ?>_apidiv_<?php echo $ii; ?> nxs_<?php echo $nt; ?>_apinxdiv_<?php echo $ii; ?>" style="display: <?php echo (!empty($options['apiToUse']) && $options['apiToUse'] =='nx')?"block":"none"; ?>;">
263
+ <input class="liPostType<?php echo $ii; ?>" type="radio" name="li[<?php echo $ii; ?>][postType]" value="I" <?php if ($options['postType'] == 'I') echo 'checked="checked"'; ?> /> <?php _e('Image Post', 'social-networks-auto-poster-facebook-twitter-g'); ?> - <i><?php _e('big image with text message (Profiles and Company pages only)', 'social-networks-auto-poster-facebook-twitter-g'); ?></i><br/> </span>
264
+ <input class="liPostType<?php echo $ii; ?>" type="radio" name="li[<?php echo $ii; ?>][postType]" value="A" <?php if ( empty($options['postType']) || $options['postType'] == 'A') echo 'checked="checked"'; ?> /> <?php _e('Add blogpost to LinkedIn message as an attachment', 'social-networks-auto-poster-facebook-twitter-g'); ?><br/>
265
 
266
+
 
 
 
 
 
 
267
 
268
+ <div style="margin-left: 10px;">
269
+ <strong><?php _e('Attachment Text Format', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong><br/>
270
+ <input value="1" id="apLIMsgAFrmtA<?php echo $ii; ?>" <?php if (empty($options['msgAFormat']) || trim($options['msgAFormat'])=='' ) echo "checked"; ?> onchange="if (jQuery(this).is(':checked')) { jQuery('#apLIMsgAFrmtDiv<?php echo $ii; ?>').hide(); jQuery('#apLIMsgAFrmt<?php echo $ii; ?>').val(''); }else jQuery('#apLIMsgAFrmtDiv<?php echo $ii; ?>').show();" type="checkbox" name="li[<?php echo $ii; ?>][msgAFormatCB]"/> <strong><?php _e('Auto', 'social-networks-auto-poster-facebook-twitter-g'); ?></strong>
271
+ <i> - <?php _e('Recommended. Info from SEO Plugins will be used, then post excerpt, then post text', 'social-networks-auto-poster-facebook-twitter-g'); ?> </i><br/>
272
+ <div id="apLIMsgAFrmtDiv<?php echo $ii; ?>" style="<?php if (empty($options['msgAFormat']) || trim($options['msgAFormat'])=='' ) echo "display:none;"; ?>" >
273
+ <?php $this->elemTitleFormat($ii,'Title Format','msgATFormat',$options['msgATFormat']); $this->elemMsgFormat($ii,'Message Format','msgAFormat',$options['msgAFormat']); ?>
274
+
275
+ </div>
276
+ </div>
277
+
278
+ </div>
279
 
280
+ </div><br/>
281
+
282
+ <?php
283
+ }
284
+ function advTab($ii, $options){ $this->showProxies($this->ntInfo['lcode'], $ii, $options); }
285
+ //#### Set Unit Settings from POST
286
+ function setNTSettings($post, $options){
287
+ foreach ($post as $ii => $pval){
288
+ if (!empty($pval['appKey']) || !empty($pval['appKey2']) || !empty($pval['uPass'])){ if (!isset($options[$ii])) $options[$ii] = array(); $options[$ii] = $this->saveCommonNTSettings($pval,$options[$ii]);
289
+ //## Uniqe Items
290
+ if (isset($pval['apiToUse'])) $options[$ii]['apiToUse'] = trim($pval['apiToUse']);
291
+ if (isset($pval['msgCFormat'])) $options[$ii]['msgCFormat'] = trim($pval['msgCFormat']);
292
+ if (isset($pval['msgCTFormat'])) $options[$ii]['msgCTFormat'] = trim($pval['msgCTFormat']);
293
+ if ($options[$ii]['apiToUse']=='liv2') {
294
+ if (isset($pval['appKey2'])) $options[$ii]['appKey'] = trim($pval['appKey2']);
295
+ if (isset($pval['appSec2'])) $options[$ii]['appSec'] = trim($pval['appSec2']);
296
+ }
297
+ if (isset($pval['whToPost'])) $options[$ii]['whToPost'] = trim($pval['whToPost']);
298
+ if (isset($pval['pgcID'])) $options[$ii]['pgcID'] = trim($pval['pgcID']);
299
+ if (isset($pval['pggID'])) $options[$ii]['pggID'] = trim($pval['pggID']);
300
+ if (isset($pval['pgID'])) $options[$ii]['pgID'] = trim($pval['pgID']);
301
+ if (isset($pval['grpID'])) $options[$ii]['grpID'] = trim($pval['grpID']);
302
+ } elseif ( count($pval)==1 ) if (isset($pval['do'])) $options[$ii]['do'] = $pval['do']; else $options[$ii]['do'] = 0;
303
  } return $options;
304
+ }
305
+
306
  //#### Show Post->Edit Meta Box Settings
307
+
308
+ function showEdPostNTSettings($ntOpts, $post){ $post_id = $post->ID; $nt = $this->ntInfo['lcode']; $ntU = $this->ntInfo['code'];
309
+ foreach($ntOpts as $ii=>$ntOpt) { $isFin = $this->checkIfSetupFinished($ntOpt); if (!$isFin) continue;
310
+ $pMeta = maybe_unserialize(get_post_meta($post_id, 'snap'.$ntU, true)); if (is_array($pMeta) && !empty($pMeta[$ii])) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
311
+
312
+ if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = ''; if (empty($ntOpt['urlToUse'])) $ntOpt['urlToUse'] = ''; $postType = isset($ntOpt['postType'])?$ntOpt['postType']:'';
313
+ $msgFormat = !empty($ntOpt['msgFormat'])?htmlentities($ntOpt['msgFormat'], ENT_COMPAT, "UTF-8"):''; $msgTFormat = !empty($ntOpt['msgTFormat'])?htmlentities($ntOpt['msgTFormat'], ENT_COMPAT, "UTF-8"):'';
314
+ $imgToUse = $ntOpt['imgToUse']; $urlToUse = $ntOpt['urlToUse']; $ntOpt['ii']=$ii;
315
+
316
+ $this->nxs_tmpltAddPostMeta($post, $ntOpt, $pMeta);
317
+
318
+ if ($ntOpt['whToPost']=='G') $this->elemEdTitleFormat($ii, __('Title Format:', 'social-networks-auto-poster-facebook-twitter-g'),$msgTFormat);
319
+ $this->elemEdMsgFormat($ii, __('Message Format:', 'social-networks-auto-poster-facebook-twitter-g'),$msgFormat);
320
+
321
+ if ($ntOpt['whToPost']!='P') { if (!empty($ntOpt['apiToUse']) && $ntOpt['apiToUse'] !='nx' && !empty($ntOpt['postType']) && $ntOpt['postType'] == 'I') $ntOpt['postType'] = 'A';
322
+ ?>
323
+ <tr style="<?php echo !empty($ntOpt['do'])?'display:table-row;':'display:none;'; ?>" class="nxstbldo nxstbldo<?php echo strtoupper($nt).$ii; ?>"><th scope="row" style="text-align:right; width:150px; vertical-align:top; padding-top: 0px; padding-right:10px;"> <?php _e('Post Type:', 'social-networks-auto-poster-facebook-twitter-g') ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
324
  </th><td>
325
 
326
+ <input type="radio" name="li[<?php echo $ii; ?>][postType]" value="T" <?php if (!empty($ntOpt['postType']) && $ntOpt['postType'] == 'T') echo 'checked="checked"'; ?> /><?php _e('Text Post', 'social-networks-auto-poster-facebook-twitter-g') ?> - <i><?php _e('just text message', 'social-networks-auto-poster-facebook-twitter-g') ?></i><br/>
327
  <span class="nxs_li_nxapi_<?php echo $ii; ?>" style="display: <?php echo (!empty($ntOpt['apiToUse']) && $ntOpt['apiToUse'] =='nx')?"block":"none"; ?>;">
328
+ <input type="radio" name="li[<?php echo $ii; ?>][postType]" value="I" <?php if (!empty($ntOpt['postType']) && $ntOpt['postType'] == 'I') echo 'checked="checked"'; ?> onchange="jQuery('#altFormatIMG<?php echo $nt.$ii;?>').show();" /> <?php _e('Post to LinkedIn as "Image post"', 'social-networks-auto-poster-facebook-twitter-g') ?> - <i><?php _e('big image with text message', 'social-networks-auto-poster-facebook-twitter-g') ?></i><br/> </span>
329
+ <input type="radio" name="li[<?php echo $ii; ?>][postType]" value="A" <?php if ( empty($ntOpt['postType']) || $ntOpt['postType'] == 'A') echo 'checked="checked"'; ?> onchange="jQuery('#altFormatIMG<?php echo $nt.$ii;?>').hide();" /><?php _e('Text Post with "attached" blogpost', 'social-networks-auto-poster-facebook-twitter-g') ?>
330
+ </td></tr> <?php } else {
331
+ $this->elemEdTitleFormat($ii, __('Pulse Title Format:', 'social-networks-auto-poster-facebook-twitter-g'),htmlentities($ntOpt['msgCTFormat']));
332
+ $this->elemEdMsgFormat($ii, __('Pulse Text Format:', 'social-networks-auto-poster-facebook-twitter-g'),htmlentities($ntOpt['msgCFormat']));
333
+
334
+ }
335
+ nxs_showImgToUseDlg($nt, $ii, $imgToUse);
336
+
337
+ /* ## Select Image & URL ## */ nxs_showURLToUseDlg($nt, $ii, $urlToUse); $this->nxs_tmpltAddPostMetaEnd($ii);
338
+ }
 
 
 
 
339
  }
340
 
341
+ //#### Save Meta Tags to the Post
342
+ function adjMetaOpt($optMt, $pMeta){ $optMt = $this->adjMetaOptG($optMt, $pMeta);
343
+
344
+ return $optMt;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
345
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
346
 
347
+ function adjPublishWP(&$options, &$message, $postID){ //prr($message); prr($options);
348
+ if (!empty($postID)) { if (trim($options['imgToUse'])!='') $imgURL = $options['imgToUse']; else $imgURL = nxs_getPostImage($postID, !empty($options['wpImgSize'])?$options['wpImgSize']:'full');
349
+ if (preg_match("/noImg.\.png/i", $imgURL)) { $imgURL = ''; $isNoImg = true; } $message['imageURL'] = $imgURL; $post = get_post($postID);
350
+ $addParams = nxs_makeURLParams(array('NTNAME'=>$this->ntInfo['name'], 'NTCODE'=>$this->ntInfo['code'], 'POSTID'=>$postID, 'ACCNAME'=>$options['nName']));
351
+ if (!empty($options['msgCFormat'])) $options['msgCFormat'] = nsFormatMessage( $options['msgCFormat'], $postID, $addParams);
352
+ if (!empty($options['msgCTFormat'])) $options['msgCTFormat'] = nsFormatMessage( $options['msgCTFormat'], $postID, $addParams);
353
+ if ($options['postType']=='A'){ $lng = '';
354
+ //## AUTO - Get Post Descr from SEO Plugins or make it.
355
+ if (!empty($options['msgAFormat'])) { $dsc = nsFormatMessage($options['msgAFormat'], $postID, $addParams); $urlTitle = (!empty($options['msgATFormat']))?nsFormatMessage($options['msgATFormat'], $postID, $addParams): nxs_doQTrans($post->post_title, $lng); }
356
+ else { if (function_exists('aioseop_mrt_fix_meta') && empty($dsc)) $dsc = trim(get_post_meta($postID, '_aioseop_description', true));
357
+ if (function_exists('wpseo_admin_init') && empty($dsc)) $dsc = trim(get_post_meta($postID, '_yoast_wpseo_opengraph-description', true));
358
+ if (function_exists('wpseo_admin_init') && empty($dsc)) $dsc = trim(get_post_meta($postID, '_yoast_wpseo_metadesc', true));
359
+ if (empty($dsc)) $dsc = trim(nxs_doQTrans($post->post_excerpt, $lng));
360
+ if (empty($dsc)) $dsc = trim(nxs_doQTrans($post->post_content, $lng));
361
+ global $plgn_NS_SNAutoPoster; $gOptions = $plgn_NS_SNAutoPoster->nxs_options;if (empty($gOptions['brokenCntFilters'])) $dsc = apply_filters('the_content', $dsc);
362
+ if (empty($dsc)) $dsc = get_bloginfo('description'); $urlTitle = nxs_doQTrans($post->post_title, $lng);
363
+ } $dsc = strip_tags(strip_shortcodes($dsc));// $dsc = nxs_decodeEntitiesFull($dsc); /## This is commented out to support Emoji in Link Description
364
+ $dsc = nsTrnc($dsc, 900, ' '); $message['urlDescr'] = $dsc; if (!empty($urlTitle)) $message['urlTitle'] = strip_tags(strip_shortcodes($urlTitle));
365
+ }
 
 
 
 
 
 
 
 
 
 
366
  }
 
 
367
  }
368
+
369
+ function nxsCptCheck() { $advSettings = array();
370
+ if (!empty($_POST['c'])) { $seForDB = get_option('nxs_li_ctp_save'); $ser = maybe_unserialize($seForDB); $ck = $ser['c']; $flds = $ser['f'];
371
+ $flds['recaptcha_response_field'] = $_POST['c']; $liObj = new nxsAPI_LI(); $hdrsArr = $liObj->headers('https://www.linkedin.com/uas/login-submit', 'https://www.linkedin.com', 'POST', false);
372
+ $advSet = array('headers' => $hdrsArr, 'httpversion' => '1.1', 'timeout' => 45, 'redirection' => 0, 'cookies' => $ck, 'body' => $flds); // prr($advSet);
373
+ $rep = nxs_remote_post('https://www.linkedin.com/uas/captcha-submit', $advSet); if (is_nxs_error($rep)) { $badOut = print_r($rep, true)." - ERROR"; return $badOut; } $contents2 = $rep['body'];
374
+ if (stripos($contents2, '<span class="error">')!==false) { echo strip_tags(CutFromTo($contents2, '<span class="error">', '</span>')); die(); }
375
+ if (stripos($contents2, '<div id="global-error">')!==false) { echo CutFromTo($contents2, '<div role="alert" class="alert error">', '</div>'); die(); }
376
+ if (stripos($contents2, 'The email address or password you provided does not match our records')!==false) { echo "Invalid Login/Password"; die(); }
377
+ if (stripos($contents2, 'Hmm, ')!==false) { echo "Invalid Login/Password"; die(); }
378
+ if ($rep['response']['code']=='302' && !empty($rep['headers']['location']) && stripos($rep['headers']['location'], 'linkedin.com/uas/captcha-submit')!==false) echo "Wrong Captcha. Please try Again";
379
+ if ($rep['response']['code']=='302' && !empty($rep['headers']['location']) && (stripos($rep['headers']['location'], 'linkedin.com/nhome')!==false || stripos($rep['headers']['location'], 'linkedin.com/home')!==false)) { echo "OK. You are In";
380
+ $hdrsArr = $liObj->headers('http://www.linkedin.com/home', 'https://www.linkedin.com'); $ck = $rep['cookies'];
381
+ $advSet = array('headers' => $hdrsArr, 'httpversion' => '1.1', 'timeout' => 45, 'redirection' => 0, 'cookies' => $ck); // prr($advSet);
382
+ $rep = nxs_remote_get('http://www.linkedin.com/profile/edit?trk=tab_pro', $advSet); if (is_nxs_error($rep)) { $badOut = print_r($rep, true)." - ERROR"; return $badOut; } $ck = $rep['cookies'];
383
+ if ($_POST['i']!='') { global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
384
+ $options['li'][$_POST['i']]['ck'] = $ck; if (is_array($options)) update_option('NS_SNAutoPoster', $options);
385
+ }
386
+ }
387
+ }
388
+ if (!empty($_POST['s'])) { echo "CODE!"; $seForDB = get_option('nxs_li_ctp_save'); $ser = maybe_unserialize($seForDB); $ck = $ser['c']; $flds = $ser['f']; $fa = $ser['fa']; // prr($ser);
389
+ $flds['PinVerificationForm_pinParam'] = $_POST['s']; $liObj = new nxsAPI_LI(); $hdrsArr = $liObj->headers('https://www.linkedin.com/uas/login-submit', 'https://www.linkedin.com', 'POST', true);
390
+ $advSet = nxs_mkRemOptsArr($hdrsArr, $ck, $flds, $liObj->proxy); $rep=nxs_remote_post('https://www.linkedin.com'.$fa,$advSet); if (is_nxs_error($rep)) {$badOut = print_r($rep, true)." - ERROR"; return $badOut; } $contents2 = $rep['body']; // prr($rep);
391
+
392
+ if (stripos($contents2, 'The email address or password you provided does not match our records')!==false) { echo "Invalid Login/Password"; die(); }
393
+ if (stripos($contents2, '<div id="global-error">')!==false) { echo CutFromTo($contents2, '<div role="alert" class="alert error">', '</div>'); die(); }
394
+ if (stripos($contents2, 'Hmm, ')!==false) { echo "Invalid Login/Password"; die(); }
395
+ if ($rep['response']['code']=='302' && !empty($rep['headers']['location']) && stripos($rep['headers']['location'], 'linkedin.com/uas/ato-pin-challenge-submit')!==false) echo "Wrong Code. Please try Again";
396
+ if ($rep['response']['code']=='302' && !empty($rep['headers']['location']) && (stripos($rep['headers']['location'], 'linkedin.com/nhome')!==false || stripos($rep['headers']['location'], 'linkedin.com/home')!==false)) echo "OK. You are In";
397
+
398
+ $hdrsArr = $liObj->headers('http://www.linkedin.com/home', 'https://www.linkedin.com'); $ck = nxsMergeArraysOV($ck, $rep['cookies']); $advSet = nxs_mkRemOptsArr($hdrsArr, $ck, '', $liObj->proxy);
399
+ $rep = nxs_remote_get('http://www.linkedin.com/profile/edit?trk=tab_pro', $advSet);if (is_nxs_error($rep)) { $badOut = print_r($rep, true)." - ERROR"; return $badOut; } $ck = nxsMergeArraysOV($ck, $rep['cookies']);
400
+ if (!empty($ck)) $ck = nxsClnCookies($ck);
401
+
402
+ if ($_POST['i']!='') { global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options; $nto = $options['li'][$_POST['i']];
403
+ $opVal = array(); $opNm = 'nxs_snap_li_'.sha1('nxs_snap_li'.$nto['uName'].$nto['uPass']); $opVal['ck'] = $ck; nxs_saveOption($opNm, $opVal);
404
+ }
405
+ } die();
406
+ }
407
+
408
+ }}
409
+
410
+ if (!function_exists("nxs_doPublishToLI")) { function nxs_doPublishToLI($postID, $options){ if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true)); $cl = new nxs_snapClassLI(); $cl->nt[$options['ii']] = $options; return $cl->publishWP($options['ii'], $postID); }}
411
 
412
+ ?>
inc-cl/lj.api.php CHANGED
@@ -22,17 +22,17 @@ if (!class_exists("nxs_class_SNAP_LJ")) { class nxs_class_SNAP_LJ {
22
  function doPostToNT($options, $message){ $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>'');
23
  //## Check settings
24
  if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
25
- if (!isset($options['ljUName']) || trim($options['ljPass'])=='') { $badOut['Error'] = 'Not Configured'; return $badOut; }
26
- $pass = (substr($options['ljPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['ljPass'], 5)):$options['ljPass']);
27
  //## Format
28
- if (!empty($message['pText'])) $msg = $message['pText']; else $msg = nxs_doFormatMsg($options['ljMsgFormat'], $message);
29
- if (!empty($message['pTitle'])) $msgT = $message['pTitle']; else $msgT = nxs_doFormatMsg($options['ljMsgTFormat'], $message);
30
 
31
  require_once ('apis/xmlrpc-client.php'); if (!empty($options['ljSrv']) && $options['ljSrv']=='DW') $server = 'dreamwidth.org'; else $server = 'livejournal.com';
32
  $nxsToLJclient = new NXS_XMLRPC_Client('http://www.'.$server.'/interface/xmlrpc'); $nxsToLJclient->debug = false;
33
 
34
  $date = time(); $year = date("Y", $date); $mon = date("m", $date); $day = date("d", $date); $hour = date("G", $date); $min = date("i", $date);
35
- $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);
36
  if (!empty($options['commID']) && $options['commID']!='') $nxsToLJContent["usejournal"] = $options['commID'];
37
  if (!empty($options['inclTags']) && $options['inclTags']=='1' && !empty($message['tags'])) $nxsToLJContent['props'] = array('taglist' => $message['tags']);
38
  // prr($nxsToLJContent);
22
  function doPostToNT($options, $message){ $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>'');
23
  //## Check settings
24
  if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
25
+ if (!isset($options['uName']) || trim($options['uPass'])=='') { $badOut['Error'] = 'Not Configured'; return $badOut; }
26
+ $pass = (substr($options['uPass'], 0, 5)=='n5g9a'||substr($options['uPass'], 0, 5)=='g9c1a'||substr($options['uPass'], 0, 5)=='b4d7s')?nsx_doDecode(substr($options['uPass'], 5)):$options['uPass'];
27
  //## Format
28
+ if (!empty($message['pText'])) $msg = $message['pText']; else $msg = nxs_doFormatMsg($options['msgFormat'], $message);
29
+ if (!empty($message['pTitle'])) $msgT = $message['pTitle']; else $msgT = nxs_doFormatMsg($options['msgTFormat'], $message);
30
 
31
  require_once ('apis/xmlrpc-client.php'); if (!empty($options['ljSrv']) && $options['ljSrv']=='DW') $server = 'dreamwidth.org'; else $server = 'livejournal.com';
32
  $nxsToLJclient = new NXS_XMLRPC_Client('http://www.'.$server.'/interface/xmlrpc'); $nxsToLJclient->debug = false;
33
 
34
  $date = time(); $year = date("Y", $date); $mon = date("m", $date); $day = date("d", $date); $hour = date("G", $date); $min = date("i", $date);
35
+ $nxsToLJContent = array( "username" => $options['uName'], "password" => $pass, "event" => $msg, "subject" => $msgT, "lineendings" => "unix", "year" => $year, "mon" => $mon, "day" => $day, "hour" => $hour, "min" => $min, "ver" => 2);
36
  if (!empty($options['commID']) && $options['commID']!='') $nxsToLJContent["usejournal"] = $options['commID'];
37
  if (!empty($options['inclTags']) && $options['inclTags']=='1' && !empty($message['tags'])) $nxsToLJContent['props'] = array('taglist' => $message['tags']);
38
  // prr($nxsToLJContent);
inc-cl/lj.php CHANGED
@@ -1,236 +1,89 @@
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_plurl; $ntInfo = array('code'=>'LJ', 'lcode'=>'lj', 'name'=>'LiveJournal', 'defNName'=>'', 'tstReq' => false); ?>
8
- <div class="nxs_box">
9
- <div class="nxs_box_header">
10
- <div class="nsx_iconedTitle" style="margin-bottom:1px;background-image:url(<?php echo $nxs_plurl;?>img/<?php echo $ntInfo['lcode']; ?>16.png);"><?php echo $ntInfo['name']; ?>
11
- <?php $cbo = count($ntOpts); ?>
12
- <?php if ($cbo>1){ ?><div class="nsBigText"><?php echo "(".($cbo=='0'?'No':$cbo)." "; _e('accounts', 'social-networks-auto-poster-facebook-twitter-g'); echo ")"; ?></div><?php } ?>
13
- </div>
14
- </div>
15
- <div class="nxs_box_inside">
16
- <?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = str_ireplace('/xmlrpc.php','', str_ireplace('http://','', str_ireplace('https://','', $pbo['ljURL']))); ?>
17
- <p style="margin:0px;margin-left:5px;"> <img id="<?php echo $ntInfo['code'].$indx;?>LoadingImg" style="display: none;" src='<?php echo $nxs_plurl; ?>img/ajax-loader-sm.gif' />
18
- <input value="0" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" type="hidden" />
19
- <?php if ((int)$pbo['do'.$ntInfo['code']] == 1 && isset($pbo['catSel']) && (int)$pbo['catSel'] == 1) { ?> <input type="radio" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" id="rbtn<?php echo $ntInfo['lcode'].$indx; ?>" value="1" checked="checked" onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);" /> <?php } else { ?>
20
- <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1 && $pbo['catSel']!='1') echo "checked"; ?> />
21
- <?php } ?>
22
- <?php if (isset($pbo['catSel']) && (int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
23
- <?php if (isset($pbo['rpstOn']) && (int)$pbo['rpstOn'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popReActive');" onmouseover="nxs_showPopUpInfo('popReActive', event);"><?php echo "*[R]*" ?></span><?php } ?>
24
- <strong><?php _e('Auto-publish to', 'social-networks-auto-poster-facebook-twitter-g'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
25
- &nbsp;&nbsp;<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'social-networks-auto-poster-facebook-twitter-g'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>AG" href="#" onclick="doGetHideNTBlock('<?php echo $ntInfo['code'];?>' , '<?php echo $indx; ?>');return false;">[<?php _e('Show Settings', 'social-networks-auto-poster-facebook-twitter-g'); ?>]</a>&nbsp;&nbsp;
26
- <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'social-networks-auto-poster-facebook-twitter-g'); ?>]</a>
27
- </p><div id="nxsNTSetDiv<?php echo $ntInfo['code'].$indx; ?>"></div><?php //$pbo['ntInfo'] = $ntInfo; $this->showNTSettings($indx, $pbo);
28
- }?>
29
- </div>
30
- </div> <?php
31
- }
32
  //#### Show NEW Settings Page
33
- function showNewNTSettings($mgpo){ $options = array('nName'=>'', 'doLJ'=>'1', 'ljUName'=>'', 'ljPageID'=>'', 'inclTags'=>'1', 'ljAttch'=>'', 'ljPass'=>'', 'ljURL'=>''); $options['ntInfo']= array('lcode'=>'lj'); $this->showNTSettings($mgpo, $options, true);}
34
- //#### Show Unit Settings
35
- function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl; $nt = $options['ntInfo']['lcode']; $ntU = strtoupper($nt);
36
- 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'] = '';
37
- if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; if (!isset($options['commID'])) $options['commID'] = ''; ?>
38
- <div id="doLJ<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>"> <input type="hidden" name="apDoSLJ<?php echo $ii; ?>" value="0" id="apDoSLJ<?php echo $ii; ?>" />
39
-
40
- <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/"><?php $nType="LiveJournal"; printf( __( 'Detailed %s Installation/Configuration Instructions', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?></a></div>
41
- <?php if ($isNew){ ?> <br/><?php _e('You can setup LiveJournal blog.', 'social-networks-auto-poster-facebook-twitter-g'); ?><br/><br/> <?php } ?>
42
-
43
- <div style="width:100%;"><strong><?php _e('Account Nickname', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'social-networks-auto-poster-facebook-twitter-g'); ?></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($options['nName'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /><br/>
44
- <?php echo nxs_addQTranslSel('lj', $ii, $options['qTLng']); ?>
45
-
46
- <br/>
47
- <ul class="nsx_tabs">
48
- <li><a href="#nsx<?php echo $nt.$ii ?>_tab1"><?php _e('Account Info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li>
49
- <?php if (!$isNew) { ?> <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li> <?php } ?>
50
- </ul>
51
- <div class="nsx_tab_container"><?php /* ######################## Account Tab ####################### */ ?>
52
- <div id="nsx<?php echo $nt.$ii ?>_tab1" class="nsx_tab_content" style="background-image: url(<?php echo $nxs_plurl; ?>img/<?php echo $nt; ?>-bg.png); background-repeat: no-repeat; background-position:90% 10%;">
53
-
54
 
55
- <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($options['ljUName'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />
56
- <div style="width:100%;"><strong>LiveJournal Password:</strong> </div><input autocomplete="false" readonly onfocus="this.removeAttribute('readonly');" name="lj[<?php echo $ii; ?>][apLJPass]" id="apLJPass" type="password" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities(substr($options['ljPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['ljPass'], 5)):$options['ljPass'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /> <br/>
57
-
58
- <div style="width:100%;"><br/><strong>Blog/Community URL or ID:</strong> Please specify the Blog or Community URL or ID. <i>Use this only if you are posting NOT to your own journal. </i></div>
59
- <input name="lj[<?php echo $ii; ?>][commID]" id="commID" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['commID'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />
60
-
61
- <div style="width:100%;"><br/><strong>Website:</strong> Please select your website. <i>SNAP could also post to other LJ Engine Based sites like DreamWidth.org </i></div>
62
-
63
- <select id="lj1delayHrs" name="lj[<?php echo $ii; ?>][ljSrv]"><option <?php if ( !isset($options['ljSrv']) || $options['ljSrv']=='' || $options['ljSrv']=='LJ') {?> selected="selected" <?php } ?> value="LJ">LiveJournal.com</option>
64
- <option <?php if ( isset($options['ljSrv']) && $options['ljSrv']=='DW') {?> selected="selected" <?php } ?> value="DW">DreamWidth.org</option>
65
- </select>
66
-
67
- <br/>
68
-
69
- <?php if ($isNew) { ?> <input type="hidden" name="lj[<?php echo $ii; ?>][apDoLJ]" value="1" id="apDoNewLJ<?php echo $ii; ?>" /> <?php } ?>
70
-
71
- <br/><strong id="altFormatText"><?php _e('Post Title and Post Text Formats', 'social-networks-auto-poster-facebook-twitter-g'); ?></strong>
72
- <div id="altFormat" style="">
73
- <div style="width:100%;"><strong id="altFormatText"><?php _e('Post Title Format', 'social-networks-auto-poster-facebook-twitter-g'); ?></strong> (<a href="#" id="apLJMsgTFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apLJMsgTFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>)
74
- </div><input name="lj[<?php echo $ii; ?>][apLJMsgTFrmt]" id="apLJMsgTFrmt<?php echo $ii; ?>" style="width: 50%;" value="<?php if ($isNew) echo "%TITLE%"; else _e(apply_filters('format_to_edit', htmlentities($options['ljMsgTFormat'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g'); ?>" onfocus="mxs_showFrmtInfo('apLJMsgTFrmt<?php echo $ii; ?>');" /><?php nxs_doShowHint("apLJMsgTFrmt".$ii); ?>
75
- </div>
76
- <div id="altFormat" style="">
77
- <div style="width:100%;"><strong id="altFormatText"><?php _e('Post Text Format', 'social-networks-auto-poster-facebook-twitter-g'); ?></strong> (<a href="#" id="apLJMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apLJMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>)
78
- </div>
79
-
80
- <textarea cols="150" rows="3" id="lj<?php echo $ii; ?>SNAPformat" name="lj[<?php echo $ii; ?>][apLJMsgFrmt]" style="width:51%;max-width: 650px;" onfocus="jQuery('#lj<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('apLJMsgFrmt<?php echo $ii; ?>');"><?php if ($isNew) echo "%FULLTEXT%"; else _e(apply_filters('format_to_edit', htmlentities($options['ljMsgFormat'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g'); ?></textarea>
81
-
82
- <?php nxs_doShowHint("apLJMsgFrmt".$ii); ?>
83
- </div>
84
- <p style="margin-bottom: 20px;margin-top: 5px;"><input value="1" id="ljInclTags<?php echo $ii; ?>" type="checkbox" name="lj[<?php echo $ii; ?>][inclTags]" <?php if ((int)$options['inclTags'] == 1) echo "checked"; ?> />
85
- <strong><?php _e('Post with tags.', 'social-networks-auto-poster-facebook-twitter-g') ?></strong> <?php _e('Tags from the blogpost will be auto posted to LiveJournal', 'social-networks-auto-poster-facebook-twitter-g') ?>
86
- </p><br/>
87
- <?php if ($options['ljPass']!='') { ?>
88
-
89
- <b><?php _e('Test your settings', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('LJ', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?></a> <?php } ?>
90
- </div>
91
- <?php /* ######################## Advanced Tab ####################### */ ?>
92
- <?php if (!$isNew) { ?> <div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content">
93
 
94
- <?php nxs_showCatTagsCTFilters($nt, $ii, $options);
95
- nxs_addPostingDelaySelV3($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']);
96
- nxs_showRepostSettings($nt, $ii, $options); ?>
97
-
98
-
99
- </div> <?php } ?> <?php /* #### End of Tab #### */ ?>
100
- </div><br/> <?php /* #### End of Tabs #### */ ?>
101
-
102
- <div class="submitX nxclear" style="padding-bottom: 0px;"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'social-networks-auto-poster-facebook-twitter-g') ?>" /></div></div><?php
103
  }
 
104
  //#### Set Unit Settings from POST
105
- function setNTSettings($post, $options){ $code = 'LJ'; $lcode = 'lj';
106
  foreach ($post as $ii => $pval){
107
- if (!empty($pval['apLJUName']) && !empty($pval['apLJPass'])){ if (!isset($options[$ii])) $options[$ii] = array();
108
- if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']);
109
- if (isset($pval['ljSrv'])) $options[$ii]['ljSrv'] = trim($pval['ljSrv']); if ($options[$ii]['ljSrv']=='DW') $server = 'dreamwidth.org'; else $server = 'livejournal.com';
110
- if (isset($pval['apLJUName'])) $options[$ii]['ljUName'] = trim($pval['apLJUName']); $options[$ii]['ljURL'] = 'http://'.$options[$ii]['ljUName'].".".$server;
111
- if (isset($pval['apLJPass'])) $options[$ii]['ljPass'] = 'n5g9a'.nsx_doEncode($pval['apLJPass']); else $options[$ii]['ljPass'] = '';
112
- if (isset($pval['apLJMsgFrmt'])) $options[$ii]['ljMsgFormat'] = trim($pval['apLJMsgFrmt']);
113
- if (isset($pval['apLJMsgTFrmt'])) $options[$ii]['ljMsgTFormat'] = trim($pval['apLJMsgTFrmt']);
114
- if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']); else $options[$ii]['catSel'] = 0;
115
- if (isset($pval['inclTags'])) $options[$ii]['inclTags'] = $pval['inclTags']; else $options[$ii]['inclTags'] = 0;
116
-
117
- if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
118
-
119
- if (isset($pval['commID'])) {
120
- if (stripos($pval['commID'], '.')!==false) $pval['commID'] = CutFromTo($pval['commID'], '://', '.');
121
- $options[$ii]['commID'] = trim($pval['commID']);
122
- }
123
- if (isset($pval['apDoLJ'])) $options[$ii]['doLJ'] = $pval['apDoLJ']; else $options[$ii]['doLJ'] = 0;
124
 
125
- $options[$ii] = nxs_adjRpst($options[$ii], $pval);
 
126
 
127
- if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']);
128
- if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
129
- if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
130
- } elseif ( count($pval)==1 ) if (isset($pval['apDo'.$code])) $options[$ii]['do'.$code] = $pval['apDo'.$code]; else $options[$ii]['do'.$code] = 0;
131
  } return $options;
132
- }
 
133
  //#### Show Post->Edit Meta Box Settings
134
- function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID; $nt = 'lj'; $ntU = 'LJ';
135
- 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]);
136
- $doLJ = $ntOpt['doLJ'] && (is_array($pMeta) || $ntOpt['catSel']!='1');
137
- $isAvailLJ = $ntOpt['ljUName']!='' && $ntOpt['ljPass']!=''; $ljMsgFormat = htmlentities($ntOpt['ljMsgFormat'], ENT_COMPAT, "UTF-8"); $ljMsgTFormat = htmlentities($ntOpt['ljMsgTFormat'], ENT_COMPAT, "UTF-8");
138
- ?>
139
- <tr><th style="text-align:left;" colspan="2">
140
- <?php if ($ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='') { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
141
- <?php if (!empty($ntOpt['tagsSelX'])) { ?> <input type="hidden" class="nxs_TG" id="nxs_TG_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $ntOpt['tagsSelX']; ?>" /> <?php } ?>
142
- <?php if ($isAvailLJ) { ?><input class="nxsGrpDoChb" value="1" id="doLJ<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="lj[<?php echo $ii; ?>][doLJ]" <?php if ((int)$doLJ == 1) echo 'checked="checked" title="def"'; ?> />
143
-
144
-
145
- <?php if ($post->post_status == "publish") { ?> <input type="hidden" name="lj[<?php echo $ii; ?>][doLJ]" value="<?php echo $doLJ;?>"> <?php } ?> <?php } ?>
146
- <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/lj16.png);">LiveJournal - <?php _e('publish to', 'social-networks-auto-poster-facebook-twitter-g') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
147
- 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', 'social-networks-auto-poster-facebook-twitter-g') ?>" />
148
- <?php } ?>
149
-
150
- <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
151
- ?> <span id="pstdLJ<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
152
- <a style="font-size: 10px;" href="<?php echo $pMeta[$ii]['pgID']; ?>" target="_blank"><?php $nType="LiveJournal"; printf( __( 'Posted on', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
153
- </span><?php } ?>
154
-
155
- </td></tr>
156
-
157
- <?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>
158
- <?php } else { if ($post->post_status != "publish" && function_exists('nxs_doSMAS5') ) { $ntOpt['postTime'] = get_post_time('U', false, $post_id); nxs_doSMAS5($nt, $ii, $ntOpt); } ?>
159
-
160
- <?php if ($ntOpt['rpstOn']=='1') { ?>
161
-
162
- <tr id="altFormat1" style=""><th scope="row" class="nxsTHRow">
163
- <input value="0" type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]"/><input value="nxsi<?php echo $ii; ?>lj" type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]" <?php if (!empty($ntOpt['rpstPostIncl'])) echo "checked"; ?> />
164
- </th>
165
- <td> <?php _e('Include in "Auto-Reposting" to this network.', 'social-networks-auto-poster-facebook-twitter-g') ?>
166
- </td></tr> <?php } ?>
167
-
168
- <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Title Format:', 'social-networks-auto-poster-facebook-twitter-g') ?></th>
169
- <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>
170
-
171
- <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Text Format:', 'social-networks-auto-poster-facebook-twitter-g') ?></th>
172
- <td>
173
- <textarea cols="150" rows="1" id="lj<?php echo $ii; ?>SNAPformat" name="lj[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('#lj<?php echo $ii; ?>SNAPformat').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apLJMsgFrmt<?php echo $ii; ?>');"><?php echo $ljMsgFormat; ?></textarea>
174
- <?php nxs_doShowHint("apLJMsgFrmt".$ii); ?></td></tr>
175
-
176
- <?php }
177
  }
178
- }
179
  //#### Save Meta Tags to the Post
180
- function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
181
- if (isset($pMeta['SNAPformat'])) $optMt['ljMsgFormat'] = $pMeta['SNAPformat'];
182
- if (isset($pMeta['SNAPformatT'])) $optMt['ljMsgTFormat'] = $pMeta['SNAPformatT'];
183
- if (isset($pMeta['imgToUse'])) $optMt['imgToUse'] = $pMeta['imgToUse'];
184
- if (isset($pMeta['timeToRun'])) $optMt['timeToRun'] = $pMeta['timeToRun']; if (isset($pMeta['rpstPostIncl'])) $optMt['rpstPostIncl'] = $pMeta['rpstPostIncl'];
185
- if (isset($pMeta['doLJ'])) $optMt['doLJ'] = $pMeta['doLJ'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doLJ'] = 0; }
186
- if (isset($pMeta['SNAPincludeLJ']) && $pMeta['SNAPincludeLJ'] == '1' ) $optMt['doLJ'] = 1;
187
  return $optMt;
188
- }
189
- }}
190
- if (!function_exists("nxs_rePostToLJ_ajax")) {
191
- function nxs_rePostToLJ_ajax() { check_ajax_referer('nxsSsPageWPN'); $postID = $_POST['id']; $options = get_option('NS_SNAutoPoster');
192
- foreach ($options['lj'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj';//if ($two['gpPageID'].$two['gpUName']==$_POST['nid']) {
193
- $gppo = get_post_meta($postID, 'snapLJ', true); $gppo = maybe_unserialize($gppo);// prr($gppo);
194
- if (is_array($gppo) && isset($gppo[$ii]) && is_array($gppo[$ii])){ $ntClInst = new nxs_snapClassLJ(); $two = $ntClInst->adjMetaOpt($two, $gppo[$ii]); }
195
- $result = nxs_doPublishToLJ($postID, $two); if ($result == 200) die("Successfully sent your post to LiveJournal."); else die($result);
196
- }
197
  }
198
- }
 
 
 
 
 
199
 
200
- if (!function_exists("nxs_doPublishToLJ")) { //## Second Function to Post to LJ
201
- function nxs_doPublishToLJ($postID, $options){ $ntCd = 'LJ'; $ntCdL = 'lj'; $ntNm = 'LJ Based Blog'; if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
202
- //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToLJ', array($postID, $options));
203
- $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url();
204
- $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'ACCNAME'=>$options['nName'], 'POSTID'=>$postID));
205
- $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
206
- $logNT = '<span style="color:#2097EE">LJ</span> - '.$options['nName'];
207
- $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
208
- if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
209
- $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') {
210
- nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$uqID); return;
211
- }
212
- }
213
- //$imgURL = nxs_getPostImage($postID);
214
- $email = $options['ljUName']; $pass = substr($options['ljPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['ljPass'], 5)):$options['ljPass'];
215
- if ($postID=='0') { echo "Testing ... <br/><br/>"; $options['ljMsgTFormat'] = 'Test Link from '. home_url(); $options['ljMsgFormat'] = 'Test post please ignore'; } else { $post = get_post($postID); if(!$post) return;
216
- $options['ljMsgFormat'] = nsFormatMessage($options['ljMsgFormat'], $postID, $addParams); $options['ljMsgTFormat'] = nsFormatMessage($options['ljMsgTFormat'], $postID, $addParams);
217
- nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
218
- } //prr($msg); prr($msgFormat);
219
- $extInfo = ' | PostID: '.$postID." - ".(isset($post) && is_object($post)?$post->post_title:'');
220
- //## Post
221
- $t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = implode(',', $tggs);
222
- $message = array('siteName'=>$blogTitle, 'tags'=>$tags);// prr($message);
223
- //## Actual Post
224
- $ntToPost = new nxs_class_SNAP_LJ(); $ret = $ntToPost->doPostToNT($options, $message);
225
- //## Process Results
226
- if (!is_array($ret) || $ret['isPosted']!='1') { //## Error
227
- if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);
228
- } else { // ## All Good - log it.
229
- if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo _e('OK - Message Posted, please see your '.$logNT.' Page. ', 'social-networks-auto-poster-facebook-twitter-g'); }
230
- else { nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPosted'=>'1', 'pgID'=>$ret['postID'], 'pDate'=>date('Y-m-d H:i:s'))); nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); }
231
- }
232
- //## Return Result
233
- if ($ret['isPosted']=='1') return 200; else return print_r($ret, true);
234
- }
235
- }
236
  ?>
1
  <?php
2
+ //## NextScripts LJ Connection Class
3
+ $nxs_snapAvNts[] = array('code'=>'LJ', 'lcode'=>'lj', 'name'=>'LiveJournal', 'type'=>'Blogs/Publishing Platforms', 'ptype'=>'F', 'status'=>'A', 'desc'=>'Auto-submit your blogpost to LiveJournal blog or community. LiveJournal engine based website DreamWidth.org is also supported');
4
 
5
+ if (!class_exists("nxs_snapClassLJ")) { class nxs_snapClassLJ extends nxs_snapClassNT {
6
+ var $ntInfo = array('code'=>'LJ', 'lcode'=>'lj', 'name'=>'LiveJournal', 'defNName'=>'uName', 'tstReq' => false, 'instrURL'=>'http://www.nextscripts.com/setup-installation-livejournal-social-networks-auto-poster-for-wordpress/');
7
+
8
+ function toLatestVer($ntOpts){ if( !empty($ntOpts['v'])) $v = $ntOpts['v']; else $v = 340; $ntOptsOut = ''; switch ($v) {
9
+ case 340: $ntOptsOut = $this->toLatestVerNTGen($ntOpts); $ntOptsOut['do'] = $ntOpts['do'.$this->ntInfo['code']]; $ntOptsOut['nName'] = $ntOpts['nName'];
10
+ $ntOptsOut['msgTFormat'] = $ntOpts['ljMsgTFormat']; $ntOptsOut['msgFormat'] = $ntOpts['ljMsgFormat']; $ntOptsOut['uName'] = $ntOpts['ljUName']; $ntOptsOut['uPass'] = $ntOpts['ljPass'];
11
+ $ntOptsOut['commID'] = $ntOpts['commID']; $ntOptsOut['ljSrv'] = $ntOpts['ljSrv']; $ntOptsOut['inclTags'] = $ntOpts['inclTags'];
12
+ $ntOptsOut['v'] = NXS_SETV;
13
+ break;
14
+ }
15
+ return !empty($ntOptsOut)?$ntOptsOut:$ntOpts;
16
+ }
17
+
18
  //#### Show Common Settings
19
+ function showGenNTSettings($ntOpts){ $this->nt = $ntOpts; $this->showNTGroup(); return; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  //#### Show NEW Settings Page
21
+ function showNewNTSettings($ii){ $defO = array('nName'=>'', 'do'=>'1', 'uName'=>'', 'uPass'=>'', 'ljSrv'=>'livejournal.com', 'commID'=>'', 'inclTags'=>'1', 'msgTFormat'=>'%TITLE%', 'msgFormat'=>"%FULLTEXT%"); $this->showGNewNTSettings($ii, $defO); }
22
+ //#### Show Unit Settings
23
+ function checkIfSetupFinished($options) { return !empty($options['uPass']); }
24
+ function accTab($ii, $options, $isNew=false){ $ntInfo = $this->ntInfo; $nt = $ntInfo['lcode']; $this->elemUserPass($ii, $options['uName'], $options['uPass']); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
+ <br/ ><div style="width:100%;"><b><?php _e('Website', 'nxs_snap'); ?></b><br/><?php _e('Please select your website. SNAP could post to LJ Engine Based sites like DreamWidth.org', 'social-networks-auto-poster-facebook-twitter-g'); ?></div>
27
+ <div id="nxsLJInfoDiv<?php echo $ii; ?>">
28
+ <div style="width:100%;">
29
+ <select id="lj1delayHrs" name="lj[<?php echo $ii; ?>][ljSrv]"><option <?php if ( empty($options['ljSrv']) || $options['ljSrv']=='LJ') {?> selected="selected" <?php } ?> value="LJ">LiveJournal.com</option>
30
+ <option <?php if ( isset($options['ljSrv']) && $options['ljSrv']=='DW') {?> selected="selected" <?php } ?> value="DW">DreamWidth.org</option>
31
+ </select>
32
+ </div>
33
+ </div><br/>
34
+ <div style="width:100%;"><br/><b><?php _e('Blog/Community URL or ID', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</b><br/><?php _e('Please specify the Blog or Community URL or ID. Use this only if you are posting NOT to your own journal.', 'social-networks-auto-poster-facebook-twitter-g'); ?><br/><input name="lj[<?php echo $ii; ?>][commID]" id="commID" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['commID'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />
35
+ </div>
36
+ <br/><br/>
37
+ <?php $this->elemTitleFormat($ii,'Post Title Format','msgTFormat',$options['msgTFormat']); $this->elemMsgFormat($ii,'Post Text Format','msgFormat',$options['msgFormat']);?>
38
+ <div style="margin-bottom: 20px;margin-top: 5px;"><input value="1" id="ljInclTags<?php echo $ii; ?>" type="checkbox" name="lj[<?php echo $ii; ?>][inclTags]" <?php if ((int)$options['inclTags'] == 1) echo "checked"; ?> />
39
+ <b><?php _e('Post with tags.', 'social-networks-auto-poster-facebook-twitter-g') ?></b> <?php _e('Tags from the blogpost will be auto posted to LiveJournal', 'social-networks-auto-poster-facebook-twitter-g') ?>
40
+ </div><br/>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
 
42
+ <br/ ><?php
 
 
 
 
 
 
 
 
43
  }
44
+ function advTab($ii, $options){}
45
  //#### Set Unit Settings from POST
46
+ function setNTSettings($post, $options){
47
  foreach ($post as $ii => $pval){
48
+ if (!empty($pval['uPass']) && !empty($pval['uPass'])){ if (!isset($options[$ii])) $options[$ii] = array(); $options[$ii] = $this->saveCommonNTSettings($pval,$options[$ii]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
 
50
+ if (isset($pval['commID'])) $options[$ii]['commID'] = trim($pval['commID']);
51
+ if (isset($pval['ljSrv'])) $options[$ii]['ljSrv'] = trim($pval['ljSrv']);
52
 
53
+ } elseif ( count($pval)==1 ) if (isset($pval['do'])) $options[$ii]['do'] = $pval['do']; else $options[$ii]['do'] = 0;
 
 
 
54
  } return $options;
55
+ }
56
+
57
  //#### Show Post->Edit Meta Box Settings
58
+ function showEdPostNTSettings($ntOpts, $post){ $post_id = $post->ID; $nt = $this->ntInfo['lcode']; $ntU = $this->ntInfo['code'];
59
+ foreach($ntOpts as $ii=>$ntOpt) { $isFin = $this->checkIfSetupFinished($ntOpt); if (!$isFin) continue;
60
+ $pMeta = maybe_unserialize(get_post_meta($post_id, 'snap'.$ntU, true)); if (is_array($pMeta) && !empty($pMeta[$ii])) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
61
+
62
+ if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = ''; if (empty($ntOpt['urlToUse'])) $ntOpt['urlToUse'] = ''; $postType = isset($ntOpt['postType'])?$ntOpt['postType']:'';
63
+ $msgFormat = !empty($ntOpt['msgFormat'])?htmlentities($ntOpt['msgFormat'], ENT_COMPAT, "UTF-8"):''; $msgTFormat = !empty($ntOpt['msgTFormat'])?htmlentities($ntOpt['msgTFormat'], ENT_COMPAT, "UTF-8"):'';
64
+ $imgToUse = $ntOpt['imgToUse']; $urlToUse = $ntOpt['urlToUse']; $ntOpt['ii']=$ii;
65
+
66
+ $this->nxs_tmpltAddPostMeta($post, $ntOpt, $pMeta); ?>
67
+ <?php $this->elemEdTitleFormat($ii, __('Title Format:', 'social-networks-auto-poster-facebook-twitter-g'),$msgTFormat); $this->elemEdMsgFormat($ii, __('Message Format:', 'social-networks-auto-poster-facebook-twitter-g'),$msgFormat); ?>
68
+
69
+ <?php
70
+
71
+ /* ## Select Image & URL ## */ nxs_showURLToUseDlg($nt, $ii, $urlToUse); $this->nxs_tmpltAddPostMetaEnd($ii);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  }
73
+ }
74
  //#### Save Meta Tags to the Post
75
+ function adjMetaOpt($optMt, $pMeta){ $optMt = $this->adjMetaOptG($optMt, $pMeta); // prr($optMt);
76
+
 
 
 
 
 
77
  return $optMt;
 
 
 
 
 
 
 
 
 
78
  }
79
+
80
+ function adjPublishWP(&$options, &$message, $postID){
81
+
82
+ }
83
+
84
+ }}
85
 
86
+ if (!function_exists("nxs_doPublishToLJ")) { function nxs_doPublishToLJ($postID, $options){ if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
87
+ $cl = new nxs_snapClassLJ(); $cl->nt[$options['ii']] = $options; return $cl->publishWP($options['ii'], $postID);
88
+ }}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  ?>
inc-cl/mc.api.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ //## NextScripts FriendFeed Connection Class
4
+ $nxs_snapAPINts[] = array('code'=>'MC', 'lcode'=>'mc', 'name'=>'MailChimp');
5
+
6
+ if (!class_exists("nxs_class_SNAP_MC")) { class nxs_class_SNAP_MC {
7
+
8
+ var $ntCode = 'MC';
9
+ var $ntLCode = 'mc';
10
+
11
+ function doPost($options, $message){ if (!is_array($options)) return false; $out = array();
12
+ foreach ($options as $ii=>$ntOpts) $out[$ii] = $this->doPostToNT($ntOpts, $message);
13
+ return $out;
14
+ }
15
+ function nxs_getHeaders($ref, $post=false){ $hdrsArr = array();
16
+ $hdrsArr['X-Requested-With']='XMLHttpRequest'; $hdrsArr['Connection']='keep-alive'; $hdrsArr['Referer']=$ref;
17
+ $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';
18
+ if($post) $hdrsArr['Content-Type']='application/x-www-form-urlencoded'; $hdrsArr['Accept']='application/json, text/javascript, */*; q=0.01';
19
+ $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;
20
+ }
21
+ function doPostToNT($options, $message){ global $nxs_gCookiesArr; $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>'');
22
+ //## Check settings
23
+ if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; } if (empty($options['apikey'])) { $badOut['Error'] = 'Not Configured'; return $badOut; }
24
+ //## Format
25
+ if (!empty($message['tText'])) $msgT = $message['tText']; else $msgT = nxs_doFormatMsg($options['msgTFormat'], $message);
26
+ if (!empty($message['pText'])) $msg = $message['pText']; else $msg = nxs_doFormatMsg($options['msgFormat'], $message);
27
+ if (isset($message['imageURL'])) $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); else $imgURL = '';
28
+ $urlToGo = (!empty($message['url']))?$message['url']:'';
29
+
30
+ //$fields = array( 'chat_id' => $chatter,'photo' =>'@'. $photo. ';filename=' . $photo, 'caption' => $caption );
31
+ //$url = 'https://api.telegram.org/bot'.$token.'/sendPhoto';
32
+
33
+ $msg = nsTrnc($msg , 3000); $url = 'https://'.$options['dc'].'.api.mailchimp.com/3.0/campaigns'; $msgArr = array ("subject_line"=>$msgT,"reply_to"=>$options['fromEmail'],"from_name"=>$options['fromName']);
34
+
35
+ $flds = array('recipients' => array('list_id' => $options['listID']), 'settings' => $msgArr, 'type' => 'regular'); $flds = json_encode($flds);
36
+
37
+ $hdrsArr = $this->nxs_getHeaders('https://'.$options['dc'].'.api.mailchimp.com', true); $hdrsArr['Authorization'] = 'Basic '.base64_encode('apikey:'.$options['apikey']); //prr($hdrsArr);
38
+ $advSet = nxs_mkRemOptsArr($hdrsArr, '', $flds); $ret = wp_remote_post( $url, $advSet); if (is_nxs_error($ret)) { $badOut = print_r($ret, true)." - ERROR"; return $badOut; }
39
+ $contents = $ret['body']; $resp = json_decode($contents, true); prr($resp);
40
+
41
+
42
+
43
+ if (is_array($resp) && !empty($resp['id'] )){ $url = 'https://'.$options['dc'].'.api.mailchimp.com/3.0/campaigns/'.$resp['id'].'/content'; $flds = array('html' => $msg); $flds = json_encode($flds);
44
+ $advSet = nxs_mkRemOptsArr($hdrsArr, '', $flds); $advSet['method']='PUT'; $ret = wp_remote_request( $url, $advSet); if (is_nxs_error($ret)) { $badOut = print_r($ret, true)." - ERROR"; return $badOut; }
45
+ $contents = $ret['body']; $respX = json_decode($contents, true); prr($respX);
46
+ if (is_array($respX) && !empty($respX['plain_text'] )){ $url = 'https://'.$options['dc'].'.api.mailchimp.com/3.0/campaigns/'.$resp['id'].'/actions/send';
47
+ $advSet = nxs_mkRemOptsArr($hdrsArr, '', $flds); $ret = wp_remote_post( $url, $advSet);
48
+ if ($ret['response']['code']=='204') return array('postID'=>$resp['id'], 'isPosted'=>1, 'postURL'=>$resp['archive_url'], 'pDate'=>date('Y-m-d H:i:s')); else $badOut['Error'] .= 'Something went wrong - '.print_r($ret, true);
49
+ }
50
+ } else $badOut['Error'] .= 'Something went wrong - '.print_r($ret, true);
51
+ return $badOut;
52
+ }
53
+ }}
54
+
55
+ ?>
inc-cl/mc.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //## NextScripts Telegram Connection Class (##Can't replace MC - it has showNTGroup, mc - ok to replace)
3
+ $nxs_snapAvNts[] = array('code'=>'MC', 'lcode'=>'mc', 'name'=>'MailChimp', 'type'=>'Email Marketing', 'ptype'=>'F', 'status'=>'A', 'desc'=>'One of the most popular email marketing tools. You can send your blogposts as email campaigns to specific subscribers');
4
+
5
+ if (!class_exists("nxs_snapClassMC")) { class nxs_snapClassMC extends nxs_snapClassNT {
6
+ var $ntInfo = array('code'=>'MC', 'lcode'=>'mc', 'name'=>'MailChimp', 'defNName'=>'uName', 'tstReq' => false, 'instrURL'=>'http://www.nextscripts.com/instructions/mailchimp-auto-poster-setup-installation/');
7
+ //#### Show Common Settings
8
+ function showGenNTSettings($ntOpts){ $this->nt = $ntOpts; $this->showNTGroup(); return; }
9
+ //#### Show NEW Settings Page
10
+ function showNewNTSettings($ii){ $defO = array('nName'=>'', 'do'=>'1', 'apikey'=>'', 'fromEmail'=>'', 'fromName'=>'', 'dc'=>'', 'msgTFormat'=>'%TITLE%', 'listID'=>'', 'msgFormat'=>'%EXCERPT% - %URL%'); $this->showGNewNTSettings($ii, $defO); }
11
+ //#### Show Unit Settings
12
+ function checkIfSetupFinished($options) { return !empty($options['apikey']); }
13
+ function accTab($ii, $options, $isNew=false){ $ntInfo = $this->ntInfo; $nt = $ntInfo['lcode']; ?> <br/ >
14
+
15
+ <div style="width:100%;"><strong><?php _e('API Key', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong></div><input name="mc[<?php echo $ii; ?>][apikey]" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['apikey'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /><br/><br/>
16
+ <div style="width:100%;"><strong><?php _e('Recipients List ID', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong><i><?php _e('The unique recipients list id', 'social-networks-auto-poster-facebook-twitter-g'); ?></i></div><input name="mc[<?php echo $ii; ?>][listID]" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['listID'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /><br/><br/>
17
+ <div style="width:100%;"><strong><?php _e('From name', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong><i><?php _e('The [From] name on the campaign (not an email address).', 'social-networks-auto-poster-facebook-twitter-g'); ?></i></div><input name="mc[<?php echo $ii; ?>][fromName]" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['fromName'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /><br/><br/>
18
+ <div style="width:100%;"><strong><?php _e('From Email', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong><i><?php _e('The reply-to email address for the campaign', 'social-networks-auto-poster-facebook-twitter-g'); ?></i></div><input name="mc[<?php echo $ii; ?>][fromEmail]" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['fromEmail'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /><br/><br/>
19
+ <br/><?php $this->elemTitleFormat($ii,'Message Subject','msgTFormat',$options['msgTFormat']); $this->elemMsgFormat($ii,'Message Text','msgFormat',$options['msgFormat']);
20
+ }
21
+ function advTab(){}
22
+ //#### Set Unit Settings from POST
23
+ function setNTSettings($post, $options){
24
+ foreach ($post as $ii => $pval){
25
+ if (!empty($pval['apikey']) && !empty($pval['apikey'])){ if (!isset($options[$ii])) $options[$ii] = array(); $options[$ii] = $this->saveCommonNTSettings($pval,$options[$ii]);
26
+ //## Uniqe Items
27
+ if (isset($pval['apikey'])) { $options[$ii]['apikey'] = trim($pval['apikey']); $options[$ii]['dc'] = end(explode('-',trim($pval['apikey']))); }
28
+ if (isset($pval['listID'])) $options[$ii]['listID'] = trim($pval['listID']);
29
+ if (isset($pval['fromEmail'])) $options[$ii]['fromEmail'] = trim($pval['fromEmail']);
30
+ if (isset($pval['fromName'])) $options[$ii]['fromName'] = trim($pval['fromName']);
31
+ } elseif ( count($pval)==1 ) if (isset($pval['do'])) $options[$ii]['do'] = $pval['do']; else $options[$ii]['do'] = 0;
32
+ } return $options;
33
+ }
34
+
35
+ //#### Show Post->Edit Meta Box Settings
36
+ function showEdPostNTSettings($ntOpts, $post){ $post_id = $post->ID; $nt = $this->ntInfo['lcode']; $ntU = $this->ntInfo['code'];
37
+ foreach($ntOpts as $ii=>$ntOpt) { $isFin = $this->checkIfSetupFinished($ntOpt); if (!$isFin) continue;
38
+ $pMeta = maybe_unserialize(get_post_meta($post_id, 'snap'.$ntU, true)); if (is_array($pMeta) && !empty($pMeta[$ii])) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
39
+
40
+ if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = ''; if (empty($ntOpt['urlToUse'])) $ntOpt['urlToUse'] = ''; $postType = isset($ntOpt['postType'])?$ntOpt['postType']:'';
41
+ $msgFormat = !empty($ntOpt['msgFormat'])?htmlentities($ntOpt['msgFormat'], ENT_COMPAT, "UTF-8"):''; $msgTFormat = !empty($ntOpt['msgTFormat'])?htmlentities($ntOpt['msgTFormat'], ENT_COMPAT, "UTF-8"):'';
42
+ $doNT = $ntOpt['do'] && (is_array($pMeta) || $ntOpt['fltrsOn']!='1'); $imgToUse = $ntOpt['imgToUse']; $urlToUse = $ntOpt['urlToUse']; $ntOpt['ii']=$ii; $ntOpt['doNT'] = $doNT;
43
+
44
+ $this->nxs_tmpltAddPostMeta($post, $ntOpt, $pMeta); ?>
45
+
46
+ <?php $this->elemEdTitleFormat($ii, __('Subject Format:', 'social-networks-auto-poster-facebook-twitter-g'),$msgTFormat); $this->elemEdMsgFormat($ii, __('Message Format:', 'social-networks-auto-poster-facebook-twitter-g'),$msgFormat);
47
+ /* ## Select Image & URL ## */ nxs_showImgToUseDlg($nt, $ii, $imgToUse); nxs_showURLToUseDlg($nt, $ii, $urlToUse); $this->nxs_tmpltAddPostMetaEnd($ii);
48
+ }
49
+ }
50
+ //#### Save Meta Tags to the Post
51
+ function adjMetaOpt($optMt, $pMeta){ $optMt = $this->adjMetaOptG($optMt, $pMeta);
52
+ //if (!empty($pMeta['mcBoard'])) $optMt['mcBoard'] = $pMeta['mcBoard'];
53
+ return $optMt;
54
+ }
55
+
56
+ function adjPublishWP(&$options, &$message, $postID){
57
+
58
+ }
59
+
60
+
61
+ }}
62
+
63
+ if (!function_exists("nxs_doPublishToMC")) { function nxs_doPublishToMC($postID, $options){ if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true)); $cl = new nxs_snapClassMC(); $cl->nt[$options['ii']] = $options; return $cl->publishWP($options['ii'], $postID); }}
64
+ ?>
inc-cl/md.api.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //## NextScripts Medium Connection Class
3
+
4
+ /*
5
+ 1. Options
6
+
7
+ nName - Nickname of the account [Optional] (Presentation purposes only - No affect on functionality)
8
+ postType - A or T - "Attached link" or "Text"
9
+
10
+ 2. Post Info
11
+
12
+ url
13
+ text
14
+
15
+ */
16
+ $nxs_snapAPINts[] = array('code'=>'MD', 'lcode'=>'md', 'name'=>'Medium');
17
+
18
+ if (!class_exists("nxs_class_SNAP_MD")) { class nxs_class_SNAP_MD {
19
+
20
+ var $ntCode = 'MD';
21
+ var $ntLCode = 'md';
22
+
23
+ function doPost($options, $message){ if (!is_array($options)) return false; $out = array(); // return false;
24
+ foreach ($options as $ii=>$ntOpts) $out[$ii] = $this->doPostToNT($ntOpts, $message);
25
+ return $out;
26
+ }
27
+
28
+ function doPostToNT($options, $message){ global $nxs_urlLen; $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>'');
29
+ //## Check settings
30
+ if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
31
+ if (!isset($options['accessToken']) || trim($options['accessToken'])=='') { $badOut['Error'] = 'Not Authorized'; return $badOut; }
32
+ if (empty($options['imgSize'])) $options['imgSize'] = '';
33
+ //## Format Post
34
+ if (!empty($message['pText'])) $msg = $message['pText']; else $msg = nxs_doFormatMsg($options['msgFormat'], $message);
35
+ if (!empty($message['pTitle'])) $msgT = $message['pTitle']; else $msgT = nxs_doFormatMsg($options['msgTFormat'], $message);
36
+ if ($options['inclTags']=='1') $tags = nsTrnc($message['tags'], 195, ',', ''); else $tags = '';
37
+
38
+ //## Make Post
39
+ if (isset($message['imageURL'])) $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); else $imgURL = ''; $postType = $options['postType'];
40
+
41
+ $msg = str_replace('&amp;#039;', "'", $msg); $msg = str_replace('&#039;', "'", $msg); $msg = str_replace('#039;', "'", $msg); $msg = str_replace('#039', "'", $msg);
42
+ $msg = str_replace('&amp;#8217;', "'", $msg); $msg = str_replace('&#8217;', "'", $msg); $msg = str_replace('#8217;', "'", $msg); $msg = str_replace('#8217', "'", $msg);
43
+ $msg = str_replace('&amp;#8220;', '"', $msg); $msg = str_replace('&#8220;', '"', $msg); $msg = str_replace('#8220;', '"', $msg); $msg = str_replace('#8220', "'", $msg);
44
+ $msg = str_replace('&amp;#8221;', '"', $msg); $msg = str_replace('&#8221;', '"', $msg); $msg = str_replace('#8221;', '"', $msg); $msg = str_replace('#8221', "'", $msg);
45
+ $msg = str_replace('&amp;#8212;', '-', $msg); $msg = str_replace('&#8212;', '-', $msg); $msg = str_replace('#8212;', '-', $msg); $msg = str_replace('#8212', "-", $msg);
46
+
47
+ $data = array( 'title'=>$msgT, 'content'=>$msg, 'contentFormat'=>'html', 'canonicalUrl'=>$message['url'], 'tags'=>$message['tagsA'], 'publishStatus'=>'public');
48
+ $hdrsArr = array(); $hdrsArr['Content-Type']='application/x-www-form-urlencoded'; $hdrsArr['Accept']='application/json'; $hdrsArr['Accept-Charset']='utf-8';
49
+ $hdrsArr['Cache-Control']='max-age=0'; $hdrsArr['Connection']='keep-alive'; $hdrsArr['Referer']=''; $hdrsArr['Authorization']='Bearer '.$options['accessToken'];
50
+ $hdrsArr['User-Agent']='Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.54 Safari/537.36';
51
+ $pURL = empty($options['publ'])?'https://api.medium.com/v1/users/'.$options['appAppUserID'].'/posts':'https://api.medium.com/v1/publications/'.$options['publ'].'/posts';
52
+ $advSet = nxs_mkRemOptsArr($hdrsArr, '', $data); $rep = nxs_remote_post($pURL, $advSet); //prr($advSet); prr($rep);
53
+ $bd = json_decode($rep['body'], true); if (!is_array($bd) || !is_array($bd['data'])) { $badOut['Error'] = 'ERROR: '.print_r($rep, true); return $badOut; } $bd = $bd['data']; //prr($bd);
54
+ return array('postID'=>$bd['id'], 'isPosted'=>1, 'postURL'=>$bd['url'], 'pDate'=>date('Y-m-d H:i:s'));
55
+ }
56
+
57
+ }}
58
+ ?>
inc-cl/md.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php //## NextScripts Medium Connection Class
2
+ $nxs_snapAvNts[] = array('code'=>'MD', 'lcode'=>'md', 'name'=>'Medium', 'type'=>'Blogs/Publishing Platforms', 'ptype'=>'F', 'status'=>'A', 'desc'=>'Autopost to your profile or publications');
3
+
4
+ if (!class_exists("nxs_snapClassMD")) { class nxs_snapClassMD extends nxs_snapClassNT {
5
+ var $ntInfo = array('code'=>'MD', 'lcode'=>'md', 'name'=>'Medium', 'defNName'=>'', 'tstReq' => true, 'instrURL'=>'http://www.nextscripts.com/instructions/medium-auto-poster-setup-installation/');
6
+
7
+ //#### Show Common Settings
8
+ function showGenNTSettings($ntOpts){ $this->nt = $ntOpts; $this->showNTGroup(); }
9
+ //#### Show NEW Settings Page
10
+ function showNewNTSettings($ii){ $defO = array('nName'=>'', 'do'=>'1', 'appKey'=>'', 'appSec'=>'', 'inclTags'=>'1', 'pubList'=>'', 'publ'=>'0', 'msgTFormat'=>'%TITLE%', 'msgFormat'=>"%FULLTEXT%\r\n\r\n%URL%"); $this->showGNewNTSettings($ii, $defO); }
11
+ //#### Show Unit Settings
12
+ function checkIfSetupFinished($options) { return !empty($options['accessToken']) && !empty($options['appKey']); }
13
+ function doAuth() { $ntInfo = $this->ntInfo; global $nxs_snapSetPgURL; if (isset($_GET['acc'])) $options = $this->nt[$_GET['acc']];
14
+ if ( isset($_GET['auth']) && $_GET['auth']==$ntInfo['lcode']){
15
+ if(stripos($nxs_snapSetPgURL, 'page=NextScripts_SNAP.php')===false) { $newURL = explode('?', $nxs_snapSetPgURL); $nxs_snapSetPgURL = $newURL[0]; }
16
+ $url = 'https://medium.com/m/oauth/authorize?client_id='.$options['appKey'].'&scope=basicProfile,publishPost,listPublications&state=nxsmdauth-'. $_GET['auth'].'-'.$_GET['acc'].'&response_type=code&redirect_uri='.urlencode($nxs_snapSetPgURL);
17
+ echo '<br/><br/>All good?! Redirecting ..... <script type="text/javascript">window.location = "'.$url.'"</script>';
18
+ die();
19
+ }
20
+ if ( isset($_GET['state']) && strlen($_GET['state'])>13 && substr($_GET['state'],0,12)=='nxsmdauth-md'){ $ii = explode('-',$_GET['state']); $ii = $ii[2]; $options = $this->nt[$ii];
21
+ $data = array('code'=>$_GET['code'], 'client_id'=>$options['appKey'],'client_secret'=>$options['appSec'],'grant_type'=>'authorization_code','redirect_uri'=>$nxs_snapSetPgURL);
22
+ $hdrsArr = array(); $hdrsArr['Content-Type']='application/x-www-form-urlencoded'; $hdrsArr['Accept']='application/json'; $hdrsArr['Accept-Charset']='utf-8';
23
+ $hdrsArr['Cache-Control']='max-age=0'; $hdrsArr['Connection']='keep-alive'; $hdrsArr['Referer']='';
24
+ $hdrsArr['User-Agent']='Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.54 Safari/537.36';
25
+ $advSet = nxs_mkRemOptsArr($hdrsArr, '', $data); $rep = nxs_remote_post('https://api.medium.com/v1/tokens/', $advSet); prr($advSet); prr($rep);
26
+ $bd = json_decode($rep['body'], true); if (!is_array($bd)) die('ERROR'); else prr($bd); $options['accessToken'] = $bd['access_token'];
27
+
28
+ $hdrsArr['Authorization']='Bearer '.$options['accessToken'];
29
+ $advSet = nxs_mkRemOptsArr($hdrsArr); $rep = nxs_remote_get('https://api.medium.com/v1/me', $advSet); prr($advSet); prr($rep); if (is_nxs_error($rep)) { $badOut = print_r($rep, true)." - ERROR -02-"; return $badOut; }
30
+ $bd = json_decode($rep['body'], true); if (!is_array($bd) || !is_array($bd['data'])) die('ERROR'); else prr($bd); $bd = $bd['data'];
31
+ $options['appAppUserID'] = $bd['id']; $options['appAppUserName'] = $bd['name'].' ('.$bd['username'].')'; $options['appAppUserURL'] = $bd['url'];
32
+
33
+ $rep = nxs_remote_get('https://api.medium.com/v1/users/'.$options['appAppUserID'].'/publications', $advSet); prr($advSet); prr($rep);
34
+ $bd = json_decode($rep['body'], true); if (!is_array($bd) || !is_array($bd['data'])) die('ERROR'); else prr($bd); $bd = $bd['data']; $pubList = array();
35
+ foreach ($bd as $d) { $repX = nxs_remote_get('https://api.medium.com/v1/publications/'.$d['id'].'/contributors', $advSet);
36
+ $bdX = json_decode($repX['body'], true); if (!is_array($bdX) || !is_array($bdX['data'])) die('ERROR'); else prr($bdX); $bdX = $bdX['data'];
37
+ foreach ($bdX as $dX) { if ($dX['userId']==$options['appAppUserID']) { $pubList[] = array('id'=>$d['id'], 'name'=>$d['name']); break; }}
38
+ } $options['pubList'] = $pubList;
39
+
40
+ nxs_save_glbNtwrks($ntInfo['lcode'],$ii,$options,'*'); prr($options);
41
+ echo '<br/><br/>All good?! Redirecting ..... <script type="text/javascript">window.location = "'.$nxs_snapSetPgURL.'"</script>'; die();
42
+ }
43
+ }
44
+ function accTab($ii, $options, $isNew=false){ global $nxs_snapSetPgURL; $ntInfo = $this->ntInfo; $nt = $ntInfo['lcode']; $this->elemKeySecret($ii,'Medium Client ID','Medium Client Secret', $options['appKey'], $options['appSec']);
45
+ ?><br/><br/><div><b style="font-size: 15px;"><?php _e('Where to post:', 'social-networks-auto-poster-facebook-twitter-g'); ?></b><select name="md[<?php echo $ii; ?>][publ]"><option <?php if (empty($options['publ'])) echo 'selected="selected"'; ?> value="0">Profile</option>
46
+ <?php if (!empty($options['pubList'])) { ?> <?php foreach ($options['pubList'] as $pb) {?> <option <?php if ((string)$pb['id']==(string)$options['publ']) echo 'selected="selected"'; ?> value="<?php echo $pb['id']; ?>">[Publication]&nbsp;<?php echo $pb['name']; ?></option> <?php }} ?></select>
47
+ </div>
48
+ <br/><?php $this->elemTitleFormat($ii,'Title Format','msgTFormat',$options['msgTFormat']); ?> <br/><?php $this->elemMsgFormat($ii,'Message Text Format','msgFormat',$options['msgFormat']); ?>
49
+ <div style="margin-bottom: 20px;margin-top: 5px;"><input value="1" type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][inclTags]" <?php if ((int)$options['inclTags'] == 1) echo "checked"; ?> />
50
+ <strong><?php _e('Post with tags', 'social-networks-auto-poster-facebook-twitter-g'); ?></strong> <?php _e('Tags from the blogpost will be auto-posted to '.$ntInfo['name'], 'social-networks-auto-poster-facebook-twitter-g'); ?>
51
+ </div> <br/>
52
+ <?php if($options['appKey']=='') { ?>
53
+ <b><?php _e('Authorize Your '.$ntInfo['name'].' Account', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> <?php _e('Please click "Update Settings" to be able to Authorize your account.', 'social-networks-auto-poster-facebook-twitter-g');
54
+ } else { if(isset($options['accessToken'])) {
55
+ _e('Your '.$ntInfo['name'].' Account has been authorized.', 'social-networks-auto-poster-facebook-twitter-g'); ?> User: <?php _e(apply_filters('format_to_edit', htmlentities($options['appAppUserName'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>.
56
+ <?php _e('You can', 'social-networks-auto-poster-facebook-twitter-g'); ?> Re- <?php } ?>
57
+ <a href="<?php echo $nxs_snapSetPgURL;?>&auth=<?php echo $nt; ?>&acc=<?php echo $ii; ?>">Authorize Your <?php echo $ntInfo['name']; ?> Account</a>
58
+ <?php if (!isset($options['appAppUserID']) || $options['appAppUserID']<1) { ?> <div class="blnkg">&lt;=== <?php _e('Authorize your account', 'social-networks-auto-poster-facebook-twitter-g'); ?> ===</div> <?php }
59
+ } ?><br/><br/> <?php
60
+ }
61
+ function advTab($ii, $options){}
62
+ //#### Set Unit Settings from POST
63
+ function setNTSettings($post, $options){
64
+ foreach ($post as $ii => $pval){
65
+ if (!empty($pval['appKey']) && !empty($pval['appKey'])){ if (!isset($options[$ii])) $options[$ii] = array(); $options[$ii] = $this->saveCommonNTSettings($pval,$options[$ii]);
66
+ //## Uniqe Items
67
+ if (isset($pval['inclTags'])) $options[$ii]['inclTags'] = trim($pval['inclTags']); else $options[$ii]['inclTags'] = 0;
68
+ if (isset($pval['publ'])) $options[$ii]['publ'] = trim($pval['publ']); else $options[$ii]['publ'] = 0;
69
+ } elseif ( count($pval)==1 ) if (isset($pval['do'])) $options[$ii]['do'] = $pval['do']; else $options[$ii]['do'] = 0;
70
+ } return $options;
71
+ }
72
+
73
+ //#### Show Post->Edit Meta Box Settings
74
+
75
+ function showEdPostNTSettings($ntOpts, $post){ $post_id = $post->ID; $nt = $this->ntInfo['lcode']; $ntU = $this->ntInfo['code'];
76
+ foreach($ntOpts as $ii=>$ntOpt) { $isFin = $this->checkIfSetupFinished($ntOpt); if (!$isFin) continue;
77
+ $pMeta = maybe_unserialize(get_post_meta($post_id, 'snap'.$ntU, true)); if (is_array($pMeta) && !empty($pMeta[$ii])) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
78
+
79
+ if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = ''; if (empty($ntOpt['urlToUse'])) $ntOpt['urlToUse'] = ''; $postType = isset($ntOpt['postType'])?$ntOpt['postType']:'';
80
+ $msgFormat = !empty($ntOpt['msgFormat'])?htmlentities($ntOpt['msgFormat'], ENT_COMPAT, "UTF-8"):''; $msgTFormat = !empty($ntOpt['msgTFormat'])?htmlentities($ntOpt['msgTFormat'], ENT_COMPAT, "UTF-8"):'';
81
+ $imgToUse = $ntOpt['imgToUse']; $urlToUse = $ntOpt['urlToUse']; $ntOpt['ii']=$ii;
82
+
83
+ $this->nxs_tmpltAddPostMeta($post, $ntOpt, $pMeta); ?>
84
+
85
+ <?php $this->elemEdTitleFormat($ii, __('Title Format:', 'social-networks-auto-poster-facebook-twitter-g'),$msgTFormat); $this->elemEdMsgFormat($ii, __('Message Format:', 'social-networks-auto-poster-facebook-twitter-g'),$msgFormat);
86
+ /* ## Select Image & URL ## */ nxs_showURLToUseDlg($nt, $ii, $urlToUse); $this->nxs_tmpltAddPostMetaEnd($ii);
87
+ }
88
+ }
89
+
90
+ //#### Save Meta Tags to the Post
91
+ function adjMetaOpt($optMt, $pMeta){ $optMt = $this->adjMetaOptG($optMt, $pMeta);
92
+ //if (!empty($pMeta['tgBoard'])) $optMt['tgBoard'] = $pMeta['tgBoard'];
93
+ return $optMt;
94
+ }
95
+
96
+ function adjPublishWP(&$options, &$message, $postID){ //prr($message); prr($options);
97
+ if (!empty($postID)) { $postType = $options['postType'];
98
+ if ($postType=='A') if (trim($options['imgToUse'])!='') $imgURL = $options['imgToUse']; else $imgURL = nxs_getPostImage($postID, !empty($options['wpImgSize'])?$options['wpImgSize']:'medium');
99
+ if ($postType=='I') if (trim($options['imgToUse'])!='') $imgURL = $options['imgToUse']; else $imgURL = nxs_getPostImage($postID, !empty($options['wpImgSize'])?$options['wpImgSize']:'full');
100
+ if (preg_match("/noImg.\.png/i", $imgURL)) { $imgURL = ''; $isNoImg = true; }
101
+ $message['imageURL'] = $imgURL;
102
+ }
103
+ }
104
+
105
+ }}
106
+
107
+ if (!function_exists("nxs_doPublishToMD")) { function nxs_doPublishToMD($postID, $options){
108
+ if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true)); $cl = new nxs_snapClassMD(); $cl->nt[$options['ii']] = $options; return $cl->publishWP($options['ii'], $postID);
109
+ }}
110
+
111
+ ?>
inc-cl/ok.api.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //## NextScripts weibo Connection Class
3
+
4
+ /*
5
+ 1. Options
6
+
7
+ nName - Nickname of the account [Optional] (Presentation purposes only - No affect on functionality)
8
+ postType - A or T - "Attached link" or "Text"
9
+
10
+ 2. Post Info
11
+
12
+ url
13
+ text
14
+
15
+ */
16
+ $nxs_snapAPINts[] = array('code'=>'OK', 'lcode'=>'ok', 'name'=>'weibo');
17
+
18
+ if (!class_exists("nxs_class_SNAP_OK")) { class nxs_class_SNAP_OK {
19
+
20
+ var $ntCode = 'OK';
21
+ var $ntLCode = 'ok';
22
+
23
+ function doPost($options, $message){ if (!is_array($options)) return false; $out = array(); // return false;
24
+ foreach ($options as $ii=>$ntOpts) $out[$ii] = $this->doPostToNT($ntOpts, $message);
25
+ return $out;
26
+ }
27
+
28
+
29
+ function doPostToNT($options, $message){ global $nxs_urlLen; $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>'');
30
+ //## Check settings
31
+ if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
32
+ if (empty($options['imgSize'])) $options['imgSize'] = '';
33
+ //## Format Post
34
+ if (!empty($message['pText'])) $msg = $message['pText']; else $msg = nxs_doFormatMsg($options['msgFormat'], $message); $msg = strip_tags($msg); $msg = nxs_decodeEntitiesFull($msg);
35
+ //if (!empty($message['pTitle'])) $msgT = $message['pTitle']; else $msgT = nxs_doFormatMsg($options['msgTFormat'], $message);
36
+ if ($options['inclTags']=='1') $tags = nsTrnc($message['tags'], 195, ',', ''); else $tags = ''; if (empty($options['imgSize'])) $options['imgSize'] = 'original';
37
+ //## Make Post
38
+ if (isset($message['imageURL'])) $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); else $imgURL = ''; //$postType = $options['postType'];
39
+
40
+ $baseURL = 'https://api.ok.ru/fb.do'; $jsonArr = array('media'=>array()); $jsonArr['media'][] = array('type'=>'text', 'text'=>$msg);
41
+ if ($options['postType']=='A') $jsonArr['media'][] = array('type'=>'link', 'url'=>$message['url']);
42
+ if ($options['postType']=='I') { $toSigStr = ''; $getArr = array('application_key'=>$options['appKey'], 'format'=>'json', 'gid'=>$options['gid'], 'method'=>'photosV2.getUploadUrl');
43
+ foreach ($getArr as $k=>$v) $toSigStr .= $k.'='.$v; $secKey = md5($options['access_token'].$options['appSec']); $sig = md5($toSigStr.$secKey); $getArr['sig'] = $sig; $getArr['access_token'] = $options['access_token'];
44
+ $getStr = http_build_query($getArr); $hdrsArr = array(); $advSet = nxs_mkRemOptsArr($hdrsArr, ''); $rep = nxs_remote_get($baseURL.'?'.$getStr, $advSet); if(is_nxs_error($rep)) $badOut['Error'] .= 'IMAGE URL #1 ERROR: '. print_r($rep, true);
45
+ $cont = $rep['body']; if (empty($cont) || stripos($cont, 'error')!==false) { $rep['body']=''; $badOut['Error'] .= 'IMAGE URL ERROR: '. print_r($cont, true)."\r\n<br/>". print_r($rep, true); } $cont = json_decode($cont, true);
46
+ $uplURL = $cont['upload_url']; $phID = $cont['photo_ids']['0']; $fields = array(); $imgRes = nxs_curlUploadImg($imgURL, $uplURL, $fields, 'file');
47
+ $imgRes = $imgRes['body']; if (empty($imgRes) || stripos($imgRes, 'error')!==false) $badOut['Error'] .= 'IMAGE UPLOAD ERROR: ('.$imgURL.') '. print_r($imgRes, true)."\r\n<br/>"; $imgRes = json_decode($imgRes, true);
48
+ if (!empty($imgRes['photos'])) { $phID = $imgRes['photos'][$phID]['token']; $jsonArr['media'][] = array('type'=>'photo', 'list'=>array(array('id'=>$phID))); } // prr($cont); prr($jsonArr); //die();
49
+ } $jsonToPost = json_encode($jsonArr); //prr($jsonToPost);
50
+ $toSigStr = ''; $getArr = array('application_key'=>$options['appKey'], 'attachment'=>$jsonToPost, 'format'=>'json', 'gid'=>$options['gid'], 'method'=>'mediatopic.post', 'text_link_preview'=>'false', 'type'=>'GROUP_THEME');
51
+ foreach ($getArr as $k=>$v) $toSigStr .= $k.'='.$v; $secKey = md5($options['access_token'].$options['appSec']); $sig = md5($toSigStr.$secKey); $getArr['sig'] = $sig; $getArr['access_token'] = $options['access_token'];
52
+ $getStr = http_build_query($getArr); $hdrsArr = array(); $advSet = nxs_mkRemOptsArr($hdrsArr, ''); $rep = nxs_remote_get($baseURL.'?'.$getStr, $advSet); if(is_nxs_error($rep)) { $badOut['Error'] .= 'POST #1 ERROR: '. print_r($rep, true); return $badOut; }
53
+ $cont = $rep['body']; if (empty($cont) || stripos($cont, 'error')!==false) { $rep['body']=''; $badOut['Error'] .= 'POST ERROR: '. print_r($cont, true)."\r\n<br/>". print_r($rep, true); return $badOut; } $cont = str_replace('"','',$cont);
54
+ return array('postID'=>$cont, 'isPosted'=>1, 'postURL'=>'https://ok.ru/group/'.$options['gid'].'/topic/'.$cont, 'pDate'=>date('Y-m-d H:i:s'), 'msg'=>$badOut['Error']);
55
+ }
56
+
57
+ }}
58
+ ?>
inc-cl/ok.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //## NextScripts 500Px Connection Class
3
+ $nxs_snapAvNts[] = array('code'=>'OK', 'lcode'=>'ok', 'name'=>'ok.ru', 'type'=>'Social Networks', 'ptype'=>'F', 'status'=>'A', 'desc'=>'Autopost text, image or share a link to your profile or group');
4
+
5
+ if (!class_exists("nxs_snapClassOK")) { class nxs_snapClassOK extends nxs_snapClassNT {
6
+ var $ntInfo = array('code'=>'OK', 'lcode'=>'ok', 'name'=>'ok.ru', 'defNName'=>'', 'tstReq' => true, 'instrURL'=>'http://www.nextscripts.com/instructions/setup-installation-okru-social-networks-auto-poster/');
7
+ //#### Show Common Settings
8
+ function showGenNTSettings($ntOpts){ $this->nt = $ntOpts; $this->showNTGroup(); }
9
+ //#### Show NEW Settings Page
10
+ function showNewNTSettings($ii){ $defO = array('nName'=>'', 'do'=>'1', 'appKey'=>'', 'appSec'=>'', 'gid'=>'', 'access_token'=>'', 'secret_session_key'=>'', 'postType'=>'A', 'msgFormat'=>"%EXCERPT%\r\n\r\n%URL%", 'imgSize'=>'original'); $this->showGNewNTSettings($ii, $defO); }
11
+ //#### Show Unit Settings
12
+ function checkIfSetupFinished($options) { return !empty($options['gid']) && !empty($options['appKey']); }
13
+ public function doAuth() { }
14
+
15
+ function accTab($ii, $options, $isNew=false){ global $nxs_snapSetPgURL; $ntInfo = $this->ntInfo; $nt = $ntInfo['lcode'];
16
+ $this->elemKeySecret($ii,'App Key','App Secret', $options['appKey'], $options['appSec'],'appKey','appSec'); $this->elemKeySecret($ii,'access_token','secret_session_key', $options['access_token'], $options['secret_session_key'],'access_token','secret_session_key'); ?>
17
+
18
+ <div style="width:100%;"><strong>Group ID:</strong> </div>
19
+ <input name="<?php echo $nt; ?>[<?php echo $ii; ?>][gid]"style="width: 50%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['gid'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />
20
+ <br/><br/>
21
+
22
+ <br/><?php $this->elemMsgFormat($ii,'Message Format','msgFormat',$options['msgFormat']); ?>
23
+
24
+ <div style="width:100%;"><strong id="altFormatText">Post Type:</strong></div>
25
+ <div style="margin-left: 10px;">
26
+ <input type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][postType]" value="T" <?php if ($options['postType'] == 'T') echo 'checked="checked"'; ?> /> <?php _e('Text Post', 'social-networks-auto-poster-facebook-twitter-g'); ?> - <i><?php _e('just text message', 'social-networks-auto-poster-facebook-twitter-g'); ?></i><br/>
27
+ <input type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][postType]" value="I" <?php if ($options['postType'] == 'T') echo 'checked="checked"'; ?> /> <?php _e('Image Post', 'social-networks-auto-poster-facebook-twitter-g'); ?> - <i><?php _e('Text with image', 'social-networks-auto-poster-facebook-twitter-g'); ?></i><br/>
28
+ <input type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][postType]" value="A" <?php if ( empty($options['postType']) || $options['postType'] == 'A') echo 'checked="checked"'; ?> /> <?php _e('Post link to the blogpost', 'social-networks-auto-poster-facebook-twitter-g'); ?><br/>
29
+ </div><br/><br/>
30
+
31
+ <br/><br/> <?php
32
+ }
33
+ function advTab($ii, $options){}
34
+ //#### Set Unit Settings from POST
35
+ function setNTSettings($post, $options){
36
+ foreach ($post as $ii => $pval){
37
+ if (!empty($pval['appKey']) && !empty($pval['appKey'])){ if (!isset($options[$ii])) $options[$ii] = array(); $options[$ii] = $this->saveCommonNTSettings($pval,$options[$ii]);
38
+ //## Uniqe Items
39
+ if (isset($pval['gid'])) $options[$ii]['gid'] = trim($pval['gid']);
40
+ if (isset($pval['access_token'])) $options[$ii]['access_token'] = trim($pval['access_token']);
41
+ if (isset($pval['secret_session_key'])) $options[$ii]['secret_session_key'] = trim($pval['secret_session_key']);
42
+ if (isset($pval['postType'])) $options[$ii]['postType'] = trim($pval['postType']); else $options[$ii]['postType'] = 'A';
43
+ } elseif ( count($pval)==1 ) if (isset($pval['do'])) $options[$ii]['do'] = $pval['do']; else $options[$ii]['do'] = 0;
44
+ } return $options;
45
+ }
46
+
47
+ //#### Show Post->Edit Meta Box Settings
48
+
49
+ function showEdPostNTSettings($ntOpts, $post){ $post_id = $post->ID; $nt = $this->ntInfo['lcode']; $ntU = $this->ntInfo['code'];
50
+ foreach($ntOpts as $ii=>$ntOpt) { $isFin = $this->checkIfSetupFinished($ntOpt); if (!$isFin) continue;
51
+ $pMeta = maybe_unserialize(get_post_meta($post_id, 'snap'.$ntU, true)); if (is_array($pMeta) && !empty($pMeta[$ii])) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
52
+
53
+ if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = ''; if (empty($ntOpt['urlToUse'])) $ntOpt['urlToUse'] = ''; $postType = isset($ntOpt['postType'])?$ntOpt['postType']:'';
54
+ $msgFormat = !empty($ntOpt['msgFormat'])?htmlentities($ntOpt['msgFormat'], ENT_COMPAT, "UTF-8"):''; $msgTFormat = !empty($ntOpt['msgTFormat'])?htmlentities($ntOpt['msgTFormat'], ENT_COMPAT, "UTF-8"):'';
55
+ $imgToUse = $ntOpt['imgToUse']; $urlToUse = $ntOpt['urlToUse']; $ntOpt['ii']=$ii;
56
+
57
+ $this->nxs_tmpltAddPostMeta($post, $ntOpt, $pMeta);
58
+
59
+ $this->elemEdMsgFormat($ii, __('Message Format:', 'social-networks-auto-poster-facebook-twitter-g'),$msgFormat);
60
+ ?>
61
+ <tr class="nxstbldo <?php echo 'nxstbldo'.strtoupper($nt).$ii; ?>"><th scope="row" style="text-align:right; width:150px; vertical-align:top; padding-top: 0px; padding-right:10px;"> <?php _e('Post Type:', 'social-networks-auto-poster-facebook-twitter-g') ?> <br/></th><td>
62
+ <input type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][postType]" value="T" <?php if ($postType == 'T') echo 'checked="checked"'; ?> /> <?php _e('Text Post', 'social-networks-auto-poster-facebook-twitter-g') ?> - <i><?php _e('just text message', 'social-networks-auto-poster-facebook-twitter-g') ?></i><br/>
63
+ <input type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][postType]" value="I" <?php if ($postType == 'I') echo 'checked="checked"'; ?> /> <?php _e('Image Post', 'social-networks-auto-poster-facebook-twitter-g') ?> - <i><?php _e('Text with Image', 'social-networks-auto-poster-facebook-twitter-g') ?></i><br/>
64
+ <input type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][postType]" value="A" <?php if ( empty($postType) || $postType == 'A') echo 'checked="checked"'; ?> /><?php _e('Text Post with "attached" blogpost', 'social-networks-auto-poster-facebook-twitter-g') ?>
65
+ </td></tr>
66
+ <?php
67
+ nxs_showImgToUseDlg($nt, $ii, $imgToUse);
68
+
69
+ /* ## Select Image & URL ## */ nxs_showURLToUseDlg($nt, $ii, $urlToUse); $this->nxs_tmpltAddPostMetaEnd($ii);
70
+ }
71
+ }
72
+
73
+ //#### Save Meta Tags to the Post
74
+ function adjMetaOpt($optMt, $pMeta){ $optMt = $this->adjMetaOptG($optMt, $pMeta);
75
+ if (!empty($pMeta['attchImg'])) $optMt['attchImg'] = $pMeta['attchImg']; else $optMt['attchImg'] = 0;
76
+ return $optMt;
77
+ }
78
+
79
+ function adjPublishWP(&$options, &$message, $postID){
80
+ if (!empty($postID)) { if (trim($options['imgToUse'])!='') $imgURL = $options['imgToUse']; else $imgURL = nxs_getPostImage($postID, !empty($options['wpImgSize'])?$options['wpImgSize']:'full');
81
+ if (preg_match("/noImg.\.png/i", $imgURL)) { $imgURL = ''; $isNoImg = true; }
82
+ $message['imageURL'] = $imgURL;
83
+ }
84
+ }
85
+
86
+ }}
87
+
88
+ if (!function_exists("nxs_doPublishToOK")) { function nxs_doPublishToOK($postID, $options){ if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true)); $cl = new nxs_snapClassOK(); $cl->nt[$options['ii']] = $options; return $cl->publishWP($options['ii'], $postID); }}
89
+
90
+ ?>
inc-cl/pk.api.php CHANGED
@@ -14,22 +14,22 @@ if (!class_exists("nxs_class_SNAP_PK")) { class nxs_class_SNAP_PK {
14
  function doPostToNT($options, $message){ $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>'');
15
  //## Check settings
16
  if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
17
- if (!isset($options['pkConsKey']) || trim($options['pkConsSec'])=='' || empty($options['pkAccessTocken'])) { $badOut['Error'] = 'Not Configured'; return $badOut; }
18
  if (empty($options['imgSize'])) $options['imgSize'] = '';
19
  //## Format
20
- if (!empty($message['pText'])) $msg = $message['pText']; else $msg = nxs_doFormatMsg($options['pkMsgFormat'], $message);
21
  //## Post
22
- require_once('apis/plurkOAuth.php'); $consumer_key = $options['pkConsKey']; $consumer_secret = $options['pkConsSec'];
23
- $tum_oauth = new wpPlurkOAuth($consumer_key, $consumer_secret, $options['pkAccessTocken'], $options['pkAccessTockenSec']);
24
  $pkURL = trim(str_ireplace('http://', '', $options['pkURL'])); if (substr($pkURL,-1)=='/') $pkURL = substr($pkURL,0,-1);
25
  if ($options['pkCat']=='') $options['pkCat'] = ':';
26
  if ($options['attchImg']=='1') { if (isset($message['imageURL'])) $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); else $imgURL = ''; if ($imgURL!='') $msg .= " ".$imgURL; }
27
 
28
- $postArr = array('content'=>$msg, 'qualifier'=>$options['pkCat']); $postinfo = $tum_oauth->makeReq('http://www.plurk.com/APP/Timeline/plurkAdd', $postArr); // prr($postinfo);
29
  if (is_array($postinfo) && isset($postinfo['plurk_id'])) $pkID = $postinfo['plurk_id']; $code = $tum_oauth->http_code; // echo "XX".print_r($code); prr($postinfo); // prr($msg); prr($postinfo); echo $code."VVVV"; die("|====");
30
 
31
  if ($code == 200 && $pkID!='') { $alphabet = str_split("0123456789abcdefghijklmnopqrstuvwxyz"); $shorten = ''; $plurk_id = $pkID;
32
- while ($plurk_id != 0){ $i = $plurk_id % 36; $plurk_id = intval($plurk_id / 36); $shorten = $alphabet[$i].$shorten;} $link = 'http://www.plurk.com/p/'.$shorten;
33
  return array('postID'=>$pkID, 'isPosted'=>1, 'postURL'=>$link, 'pDate'=>date('Y-m-d H:i:s'));
34
  } else { $badOut['Error'] .= " ERROR: - ".$postinfo['error_text']; }
35
  return $badOut;
14
  function doPostToNT($options, $message){ $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>'');
15
  //## Check settings
16
  if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
17
+ if (!isset($options['appKey']) || trim($options['appSec'])=='' || empty($options['accessToken'])) { $badOut['Error'] = 'Not Configured'; return $badOut; }
18
  if (empty($options['imgSize'])) $options['imgSize'] = '';
19
  //## Format
20
+ if (!empty($message['pText'])) $msg = $message['pText']; else $msg = nxs_doFormatMsg($options['msgFormat'], $message);
21
  //## Post
22
+ require_once('apis/plurkOAuth.php'); $consumer_key = $options['appKey']; $consumer_secret = $options['appSec'];
23
+ $tum_oauth = new wpPlurkOAuth($consumer_key, $consumer_secret, $options['accessToken'], $options['accessTokenSec']);
24
  $pkURL = trim(str_ireplace('http://', '', $options['pkURL'])); if (substr($pkURL,-1)=='/') $pkURL = substr($pkURL,0,-1);
25
  if ($options['pkCat']=='') $options['pkCat'] = ':';
26
  if ($options['attchImg']=='1') { if (isset($message['imageURL'])) $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); else $imgURL = ''; if ($imgURL!='') $msg .= " ".$imgURL; }
27
 
28
+ $postArr = array('content'=>$msg, 'qualifier'=>$options['pkCat']); $postinfo = $tum_oauth->makeReq('https://www.plurk.com/APP/Timeline/plurkAdd', $postArr); // prr($postinfo);
29
  if (is_array($postinfo) && isset($postinfo['plurk_id'])) $pkID = $postinfo['plurk_id']; $code = $tum_oauth->http_code; // echo "XX".print_r($code); prr($postinfo); // prr($msg); prr($postinfo); echo $code."VVVV"; die("|====");
30
 
31
  if ($code == 200 && $pkID!='') { $alphabet = str_split("0123456789abcdefghijklmnopqrstuvwxyz"); $shorten = ''; $plurk_id = $pkID;
32
+ while ($plurk_id != 0){ $i = $plurk_id % 36; $plurk_id = intval($plurk_id / 36); $shorten = $alphabet[$i].$shorten;} $link = 'https://www.plurk.com/p/'.$shorten;
33
  return array('postID'=>$pkID, 'isPosted'=>1, 'postURL'=>$link, 'pDate'=>date('Y-m-d H:i:s'));
34
  } else { $badOut['Error'] .= " ERROR: - ".$postinfo['error_text']; }
35
  return $badOut;
inc-cl/pk.php CHANGED
@@ -1,320 +1,131 @@
1
  <?php
2
  //## NextScripts Facebook Connection Class
3
- $nxs_snapAvNts[] = array('code'=>'PK', 'lcode'=>'pk', 'name'=>'Plurk');
4
 
5
- if (!class_exists("nxs_snapClassPK")) { class nxs_snapClassPK { var $ntInfo = array('code'=>'PK', 'lcode'=>'pk', 'name'=>'Plurk', 'defNName'=>'', 'tstReq' => true);
6
-
7
- function pkCats() { return '<option value="">:freestyle(None)</option><option value="loves">loves</option><option value="likes">likes</option><option value="shares">shares</option><option value="gives">gives</option><option value="hates">hates</option><option value="wants">wants</option><option value="wishes">wishes</option><option value="needs">needs</option><option value="will">will</option><option value="hopes">hopes</option><option value="asks">asks</option><option value="has">has</option><option value="was">was</option><option value="wonders">wonders</option><option value="feels on">feels</option><option value="thinks">thinks</option><option value="says">says</option><option value="is">is</option>';}
8
- //#### Show Common Settings
9
- function showGenNTSettings($ntOpts){ global $nxs_snapSetPgURL, $nxs_plurl, $nxs_gOptions; $ntInfo = $this->ntInfo;
10
- if ( isset($_GET['auth']) && $_GET['auth']=='pk'){ require_once('apis/plurkOAuth.php'); $options = $ntOpts[$_GET['acc']];
11
- $consumer_key = $options['pkConsKey']; $consumer_secret = $options['pkConsSec'];
12
- $callback_url = $nxs_snapSetPgURL."&auth=pka&acc=".$_GET['acc'];
13
-
14
- $tum_oauth = new wpPlurkOAuth($consumer_key, $consumer_secret); //prr($tum_oauth);
15
- $request_token = $tum_oauth->getReqToken($callback_url);
16
- $options['pkOAuthToken'] = $request_token['oauth_token'];
17
- $options['pkOAuthTokenSecret'] = $request_token['oauth_token_secret'];// prr($tum_oauth ); die();
18
-
19
- //prr($tum_oauth); prr($options); die();
20
-
21
- switch ($tum_oauth->http_code) { case 200: $url = 'http://www.plurk.com/OAuth/authorize?oauth_token='.$options['pkOAuthToken'];
22
- if (function_exists('get_option')) $nxs_gOptions = get_option('NS_SNAutoPoster'); if(!empty($nxs_gOptions)) { $nxs_gOptions['pk'][$_GET['acc']] = $options; nxs_settings_save($nxs_gOptions); }
 
 
 
 
 
 
 
 
 
 
23
  echo '<br/><br/>All good?! Redirecting ..... <script type="text/javascript">window.location = "'.$url.'"</script>'; break;
24
  default: echo '<br/><b style="color:red">Could not connect to Plurk. Refresh the page or try again later.</b>'; die();
25
  }
26
  die();
27
  }
28
- if ( isset($_GET['auth']) && $_GET['auth']=='pka'){ require_once('apis/plurkOAuth.php'); $options = $ntOpts[$_GET['acc']];
29
- $consumer_key = $options['pkConsKey']; $consumer_secret = $options['pkConsSec'];
30
-
31
- $tum_oauth = new wpPlurkOAuth($consumer_key, $consumer_secret, $options['pkOAuthToken'], $options['pkOAuthTokenSecret']); //prr($tum_oauth);
32
  $access_token = $tum_oauth->getAccToken($_GET['oauth_verifier']); prr($access_token);
33
- $options['pkAccessTocken'] = $access_token['oauth_token']; $options['pkAccessTockenSec'] = $access_token['oauth_token_secret'];
34
- if (function_exists('get_option')) $nxs_gOptions = get_option('NS_SNAutoPoster'); if(!empty($nxs_gOptions)) { $nxs_gOptions['pk'][$_GET['acc']] = $options; nxs_settings_save($nxs_gOptions); }
35
-
36
- $tum_oauth = new wpPlurkOAuth($consumer_key, $consumer_secret, $options['pkAccessTocken'], $options['pkAccessTockenSec']);
37
- $uinfo = $tum_oauth->makeReq('http://www.plurk.com/APP/Profile/getOwnProfile', $params);
38
  if (is_array($uinfo) && isset($uinfo['user_info'])) $userinfo = $uinfo['user_info']['display_name'];
39
- if (empty($userinfo) && is_array($uinfo) && isset($uinfo['user_info'])) $userinfo = $uinfo['user_info']['nick_name']; $options['pkPgID'] = $userinfo;
40
- if (function_exists('get_option')) $nxs_gOptions = get_option('NS_SNAutoPoster'); if(!empty($nxs_gOptions)) { $nxs_gOptions['pk'][$_GET['acc']] = $options; nxs_settings_save($nxs_gOptions); }
41
- if ($options['pkPgID']!='') {
42
  $gGet = $_GET; unset($gGet['auth']); unset($gGet['acc']); unset($gGet['oauth_token']); unset($gGet['oauth_verifier']); unset($gGet['post_type']);
43
  $sturl = explode('?',$nxs_snapSetPgURL); $nxs_snapSetPgURL = $sturl[0].((!empty($gGet))?'?'.http_build_query($gGet):'');
44
  echo '<br/><br/>All good?! Redirecting ..... <script type="text/javascript">window.location = "'.$nxs_snapSetPgURL.'"</script>'; die();
45
  }
46
- else die("<span style='color:red;'>ERROR: Authorization Error: <span style='color:darkred; font-weight: bold;'>".$options['pkPgID']."</span></span>");
47
- }
48
- global $nxs_plurl; ?>
49
- <div class="nxs_box">
50
- <div class="nxs_box_header">
51
- <div class="nsx_iconedTitle" style="margin-bottom:1px;background-image:url(<?php echo $nxs_plurl;?>img/<?php echo $ntInfo['lcode']; ?>16.png);"><?php echo $ntInfo['name']; ?>
52
- <?php $cbo = count($ntOpts); ?>
53
- <?php if ($cbo>1){ ?><div class="nsBigText"><?php echo "(".($cbo=='0'?'No':$cbo)." "; _e('accounts', 'social-networks-auto-poster-facebook-twitter-g'); echo ")"; ?></div><?php } ?>
54
- </div>
55
- </div>
56
- <div class="nxs_box_inside">
57
- <?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = str_ireplace('https://','', str_ireplace('http://','', $pbo['pkURL']));
58
- if (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='') $pbo[$ntInfo['lcode'].'OK'] = (isset($pbo['pkOAuthTokenSecret']) && $pbo['pkOAuthTokenSecret']!='')?'1':''; ?>
59
- <p style="margin:0px;margin-left:5px;"> <img id="<?php echo $ntInfo['code'].$indx;?>LoadingImg" style="display: none;" src='<?php echo $nxs_plurl; ?>img/ajax-loader-sm.gif' />
60
- <input value="0" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" type="hidden" />
61
- <?php if ((int)$pbo['do'.$ntInfo['code']] == 1 && isset($pbo['catSel']) && (int)$pbo['catSel'] == 1) { ?> <input type="radio" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" id="rbtn<?php echo $ntInfo['lcode'].$indx; ?>" value="1" checked="checked" onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);" /> <?php } else { ?>
62
- <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1 && $pbo['catSel']!='1') echo "checked"; ?> />
63
- <?php } ?>
64
- <?php if (isset($pbo['catSel']) && (int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
65
- <?php if (isset($pbo['rpstOn']) && (int)$pbo['rpstOn'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popReActive');" onmouseover="nxs_showPopUpInfo('popReActive', event);"><?php echo "*[R]*" ?></span><?php } ?>
66
- <strong><?php _e('Auto-publish to', 'social-networks-auto-poster-facebook-twitter-g'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
67
- &nbsp;&nbsp;<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'social-networks-auto-poster-facebook-twitter-g'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>AG" href="#" onclick="doGetHideNTBlock('<?php echo $ntInfo['code'];?>' , '<?php echo $indx; ?>');return false;">[<?php _e('Show Settings', 'social-networks-auto-poster-facebook-twitter-g'); ?>]</a>&nbsp;&nbsp;
68
- <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'social-networks-auto-poster-facebook-twitter-g'); ?>]</a>
69
- </p><div id="nxsNTSetDiv<?php echo $ntInfo['code'].$indx; ?>"></div><?php //$pbo['ntInfo'] = $ntInfo; $this->showNTSettings($indx, $pbo);
70
- }?>
71
- </div>
72
- </div> <?php
73
- }
74
- //#### Show NEW Settings Page
75
- function showNewNTSettings($bo){ $po = array('nName'=>'', 'doPK'=>'1', 'pkURL'=>'', 'pkPgID'=>'', 'pkConsKey'=>'', 'pkInclTags'=>'1', 'cImgURL'=>'R', 'pkConsSec'=>'', 'pkPostType'=>'T', 'pkDefImg'=>'', 'pkOAuthTokenSecret'=>'', 'pkAccessTocken'=>'', 'pkMsgFormat'=>'%TITLE% - %URL%'); $po['ntInfo']= array('lcode'=>'pk'); $this->showNTSettings($bo, $po, true);}
76
- //#### Show Unit Settings
77
- function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl,$nxs_snapSetPgURL; $nt = $options['ntInfo']['lcode']; $ntU = strtoupper($nt);
78
- 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'] = '';
79
- if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; if (!isset($options['attchImg'])) $options['attchImg'] = ''; ?>
80
- <div id="doPK<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>"> <input type="hidden" name="apDoSPK<?php echo $ii; ?>" value="0" id="apDoSPK<?php echo $ii; ?>" />
81
- <?php if ($isNew) { ?> <input type="hidden" name="pk[<?php echo $ii; ?>][apDoPK]" value="1" id="apDoNewPK<?php echo $ii; ?>" /> <?php } ?>
82
-
83
- <div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/pk16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-plurk-social-networks-auto-poster-wordpress/"><?php $nType="Plurk"; printf( __( 'Detailed %s Installation/Configuration Instructions', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?></a></div>
84
-
85
- <div style="width:100%;"><strong><?php _e('Account Nickname', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'social-networks-auto-poster-facebook-twitter-g'); ?></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")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /><br/>
86
- <?php echo nxs_addQTranslSel('pk', $ii, $options['qTLng']); ?>
87
-
88
- <br/>
89
- <ul class="nsx_tabs">
90
- <li><a href="#nsx<?php echo $nt.$ii ?>_tab1"><?php _e('Account Info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li>
91
- <?php if (!$isNew) { ?> <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li> <?php } ?>
92
- </ul>
93
- <div class="nsx_tab_container"><?php /* ######################## Account Tab ####################### */ ?>
94
- <div id="nsx<?php echo $nt.$ii ?>_tab1" class="nsx_tab_content" style="background-image: url(<?php echo $nxs_plurl; ?>img/<?php echo $nt; ?>-bg.png); background-repeat: no-repeat; background-position:90% 10%;">
95
-
96
-
97
- <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")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /><span style="color: #F00000;" id="apPKURLerr<?php echo $ii; ?>"></span>
98
- <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")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />
99
- <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")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />
100
- <br/><br/>
101
-
102
- <div id="altFormat" style="">
103
- <div style="width:100%;"><strong id="altFormatText">Plurk prefix:</strong> </div>
104
 
105
- <select name="pk[<?php echo $ii; ?>][Cat]" id="pkCat<?php echo $ii; ?>">
106
- <?php $pkCats = $this->pkCats();
107
- if (isset($options['pkCat']) && $options['pkCat']!='') $pkCats = str_replace($options['pkCat'].'"', $options['pkCat'].'" selected="selected"', $pkCats); echo $pkCats;
108
- ?>
109
- </select>
110
- </div>
111
- <br/>
112
- <p style="margin: 0px;"><input value="1" id="apLIAttch" type="checkbox" name="pk[<?php echo $ii; ?>][attchImg]" <?php if ((int)$options['attchImg'] == 1) echo "checked"; ?> /> <strong>Attach Image to Plurk Post</strong></p>
113
- <br/>
114
-
115
- <div style="width:100%;"><strong id="altFormatText"><?php _e('Post Text Format', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> (<a href="#" id="apPKMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apPKMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>) </div>
116
-
117
- <textarea cols="150" rows="3" id="pk<?php echo $ii; ?>SNAPformat" name="pk[<?php echo $ii; ?>][apPKMsgFrmt]" style="width:51%;max-width: 650px;" onfocus="jQuery('#pk<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('apPKMsgFrmt<?php echo $ii; ?>');"><?php if ($options['pkMsgFormat']!='') _e(apply_filters('format_to_edit', htmlentities($options['pkMsgFormat'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g'); else echo htmlentities("%TITLE% - %URL%"); ?></textarea>
118
-
119
- <br/>
120
- <?php nxs_doShowHint("apPKMsgFrmt".$ii); ?>
121
- <br/>
122
- <?php
123
- if($options['pkConsSec']=='') { ?>
124
  <b>Authorize Your Plurk Account</b>. Please save your settings and come back here to Authorize your account.
125
- <?php } else { if (!empty($options['pkAccessTocken']) && $options['pkAccessTockenSec']!=='') { ?>
126
- Your Plurk Account has been authorized. Your display name: <?php _e(apply_filters('format_to_edit', htmlentities($options['pkPgID'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>.
127
  You can Re- <?php } ?>
128
  <a href="<?php echo $nxs_snapSetPgURL.(stripos($nxs_snapSetPgURL, '?')!==false?'&':'?');?>auth=pk&acc=<?php echo $ii; ?>">Authorize Your Plurk Account</a>
129
- <?php if (!isset($options['pkOAuthTokenSecret']) || $options['pkOAuthTokenSecret']=='') { ?> <div class="blnkg">&lt;=== Authorize your account ===</div> <?php } ?>
130
- <?php } ?>
131
-
132
-
133
- <?php if( isset($options['pkOAuthTokenSecret']) && $options['pkOAuthTokenSecret']!='') { ?>
134
-
135
- <br/><br/><b><?php _e('Test your settings', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('PK', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?></a> <br/><br/>
136
- <?php }?>
137
- </div>
138
- <?php /* ######################## Advanced Tab ####################### */ ?>
139
- <?php if (!$isNew) { ?> <div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content">
140
-
141
- <?php nxs_showCatTagsCTFilters($nt, $ii, $options);
142
- nxs_addPostingDelaySelV3($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']);
143
- nxs_showRepostSettings($nt, $ii, $options); ?>
144
-
145
-
146
- </div> <?php } ?><?php /* #### End of Tab #### */ ?>
147
- </div><br/> <?php /* #### End of Tabs #### */ ?>
148
-
149
- <div class="submitX nxclear" style="padding-bottom: 0px;"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'social-networks-auto-poster-facebook-twitter-g') ?>" /></div>
150
-
151
- </div>
152
- <?php
153
-
154
-
155
  }
 
156
  //#### Set Unit Settings from POST
157
- function setNTSettings($post, $options){ $code = $this->ntInfo['code'];
158
- foreach ($post as $ii => $pval){
159
- if (isset($pval['apPKConsKey']) && $pval['apPKConsSec']!='') { if (!isset($options[$ii])) $options[$ii] = array();
160
-
161
- if (isset($pval['apPKURL'])) { $options[$ii]['pkURL'] = trim($pval['apPKURL']); if ( substr($options[$ii]['pkURL'], 0, 4)!='http' ) $options[$ii]['pkURL'] = 'http://'.$options[$ii]['pkURL'];
162
- $pkPgID = $options[$ii]['pkURL']; if (substr($pkPgID, -1)=='/') $pkPgID = substr($pkPgID, 0, -1); $pkPgID = substr(strrchr($pkPgID, "/"), 1);
163
- $options[$ii]['pkPgID'] = $pkPgID; //echo $fbPgID;
164
- }
165
- if (isset($pval['apDoPK'])) $options[$ii]['doPK'] = $pval['apDoPK']; else $options[$ii]['doPK'] = 0;
166
- if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']);
167
- if (isset($pval['apPKConsKey'])) $options[$ii]['pkConsKey'] = trim($pval['apPKConsKey']);
168
- if (isset($pval['apPKConsSec'])) $options[$ii]['pkConsSec'] = trim($pval['apPKConsSec']);
169
-
170
- if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']); else $options[$ii]['catSel'] = 0;
171
- if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
172
-
173
- if (isset($pval['apPKMsgFrmt'])) $options[$ii]['pkMsgFormat'] = trim($pval['apPKMsgFrmt']);
174
- if (isset($pval['Cat'])) $options[$ii]['pkCat'] = $pval['Cat']; else $options[$ii]['pkCat'] = "";
175
- if (isset($pval['attchImg'])) $options[$ii]['attchImg'] = $pval['attchImg']; else $options[$ii]['attchImg'] = 0;
176
-
177
- $options[$ii] = nxs_adjRpst($options[$ii], $pval);
178
-
179
- if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']);
180
- if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
181
- if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
182
- } elseif ( count($pval)==1 ) if (isset($pval['apDo'.$code])) $options[$ii]['do'.$code] = $pval['apDo'.$code]; else $options[$ii]['do'.$code] = 0;
183
  } return $options;
184
- }
 
185
  //#### Show Post->Edit Meta Box Settings
186
- function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID; $nt = 'pk'; $ntU = 'PK';
187
- foreach($ntOpts as $ii=>$ntOpt) {$pMeta = maybe_unserialize(get_post_meta($post_id, 'snapPK', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
188
- $doPK = $ntOpt['doPK'] && (is_array($pMeta) || $ntOpt['catSel']!='1');// prr($ntOpt);
189
- $isAvailPK = (!empty($ntOpt['pkAccessTocken']) && !empty($ntOpt['pkOAuthTokenSecret']));
190
- $pkMsgFormat = htmlentities($ntOpt['pkMsgFormat'], ENT_COMPAT, "UTF-8");
191
- ?>
192
-
193
- <tr><th style="text-align:left;" colspan="2">
194
- <?php if ($ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='') { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
195
- <?php if (!empty($ntOpt['tagsSelX'])) { ?> <input type="hidden" class="nxs_TG" id="nxs_TG_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $ntOpt['tagsSelX']; ?>" /> <?php } ?>
196
- <?php if ($isAvailPK) { ?><input class="nxsGrpDoChb" value="1" id="doPK<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="pk[<?php echo $ii; ?>][doPK]" <?php if ((int)$doPK == 1) echo 'checked="checked" title="def"'; ?> />
197
- <?php if ($post->post_status == "publish") { ?> <input type="hidden" name="pk[<?php echo $ii; ?>][doPK]" value="<?php echo $doPK;?>"> <?php } ?> <?php } ?>
198
- <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/pk16.png);">Plurk - <?php _e('publish to', 'social-networks-auto-poster-facebook-twitter-g') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>) </div></th><td><?php //## Only show RePost button if the post is "published"
199
- 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', 'social-networks-auto-poster-facebook-twitter-g') ?>" />
200
- <?php } ?>
201
-
202
- <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
203
- ?> <span id="pstdPK<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
204
- <a style="font-size: 10px;" href="http://www.plurk.com/p/<?php echo base_convert($pMeta[$ii]['pgID'], 10, 36); ?>" target="_blank"><?php $nType="Plurk"; printf( __( 'Posted on', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
205
- </span><?php } ?>
206
-
207
- </td></tr>
208
- <?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>
209
- <?php }else { if ($post->post_status != "publish" && function_exists('nxs_doSMAS5') ) { $ntOpt['postTime'] = get_post_time('U', false, $post_id); nxs_doSMAS5($nt, $ii, $ntOpt); } ?>
210
-
211
- <?php if ($ntOpt['rpstOn']=='1') { ?>
212
-
213
- <tr id="altFormat1" style=""><th scope="row" class="nxsTHRow">
214
- <input value="0" type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]"/><input value="nxsi<?php echo $ii; ?>pk" type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]" <?php if (!empty($ntOpt['rpstPostIncl'])) echo "checked"; ?> />
215
- </th>
216
- <td> <?php _e('Include in "Auto-Reposting" to this network.', 'social-networks-auto-poster-facebook-twitter-g') ?>
217
- </td></tr> <?php } ?>
218
-
219
- <tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;">
220
- Prefix:
221
-
222
- </th>
223
- <td><select name="pk[<?php echo $ii; ?>][Cat]" id="apPKCat<?php echo $ii; ?>">
224
- <?php $pkCats = $this->pkCats();
225
- if ($ntOpt['pkCat']!='') $pkCats = str_replace($ntOpt['pkCat'].'"', $ntOpt['pkCat'].'" selected="selected"', $pkCats); echo $pkCats;
226
-
227
- ?>
228
- </select></td></tr>
229
-
230
- <tr id="altFormat1" style=""><th scope="row" class="nxsTHRow"><?php _e('Text Format:', 'social-networks-auto-poster-facebook-twitter-g') ?></th>
231
- <td>
232
- <textarea cols="150" rows="1" id="pk<?php echo $ii; ?>SNAPformat" name="pk[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('#pk<?php echo $ii; ?>SNAPformat').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apPKMsgFrmt<?php echo $ii; ?>');"><?php echo $pkMsgFormat; ?></textarea>
233
- <?php nxs_doShowHint("apPKMsgFrmt".$ii); ?></td></tr>
234
-
235
- <?php }
236
- }
237
-
238
  }
239
 
240
- function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
241
- if (isset($pMeta['SNAPformat'])) $optMt['pkMsgFormat'] = $pMeta['SNAPformat'];
242
- if (isset($pMeta['imgToUse'])) $optMt['imgToUse'] = $pMeta['imgToUse'];
243
- if (isset($pMeta['timeToRun'])) $optMt['timeToRun'] = $pMeta['timeToRun']; if (isset($pMeta['rpstPostIncl'])) $optMt['rpstPostIncl'] = $pMeta['rpstPostIncl'];
244
- if (isset($pMeta['Cat'])) $optMt['pkCat'] = $pMeta['Cat'];
245
- if (isset($pMeta['doPK'])) $optMt['doPK'] = $pMeta['doPK'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doPK'] = 0; }
246
- if (isset($pMeta['SNAPincludePK']) && $pMeta['SNAPincludePK'] == '1' ) $optMt['doPK'] = 1;
247
- return $optMt;
248
  }
 
 
 
 
 
 
 
 
249
  }}
250
 
251
- if (!function_exists("nxs_rePostToPK_ajax")) { function nxs_rePostToPK_ajax() { check_ajax_referer('nxsSsPageWPN'); $postID = $_POST['id']; // $result = nsPublishTo($id, 'FB', true);
252
- $options = get_option('NS_SNAutoPoster'); foreach ($options['pk'] as $ii=>$po) if ($ii==$_POST['nid']) { $po['ii'] = $ii; $po['pType'] = 'aj';
253
- $mpo = get_post_meta($postID, 'snapPK', true); $mpo = maybe_unserialize($mpo);
254
- if (is_array($mpo) && isset($mpo[$ii]) && is_array($mpo[$ii]) ){ $ntClInst = new nxs_snapClassPK(); $po = $ntClInst->adjMetaOpt($po, $mpo[$ii]); }
255
- $result = nxs_doPublishToPK($postID, $po); if ($result == 200 || $result == 201) die("Your post has been successfully sent to Plurk."); else { echo $result; die(); }
256
- }
257
- }
258
- }
259
-
260
- if (!function_exists("nxs_doPublishToPK")) { //## Second Function to Post to TR
261
- function nxs_doPublishToPK($postID, $options){ $ntCd = 'PK'; $ntCdL = 'pk'; $ntNm = 'Plurk'; if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
262
- //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToPK', array($postID, $options));
263
- $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url();
264
- $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'POSTID'=>$postID, 'ACCNAME'=>$options['nName']));
265
- if (empty($options['imgToUse'])) $options['imgToUse'] = ''; if (empty($options['imgSize'])) $options['imgSize'] = '';
266
-
267
- $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
268
- $logNT = '<span style="color:#014A76">Plurk</span> - '.$options['nName'];
269
- $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
270
- if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
271
- $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') { sleep(5);
272
- nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$uqID); return;
273
- }
274
- }
275
- //## Format
276
- if ($postID=='0') { echo "Testing ... <br/><br/>"; $msg = 'Test Post from '.$blogTitle; $msgT = 'Test Post from '.$blogTitle;}
277
- else { $post = get_post($postID); if(!$post) return; $twMsgFormat = $options['pkMsgFormat']; nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1')); $twLim = 180;
278
- $extInfo = ' | PostID: '.$postID." - ".$post->post_title;
279
-
280
- if (stripos($twMsgFormat, '%URL%')!==false || stripos($twMsgFormat, '%SURL%')!==false) $twLim = $twLim - 5;
281
- if (stripos($twMsgFormat, '%AUTHORNAME%')!==false) { $aun = $post->post_author; $aun = get_the_author_meta('display_name', $aun ); $twLim = $twLim - strlen($aun); }
282
-
283
- $noRepl = str_ireplace("%TITLE%", "", $twMsgFormat); $noRepl = str_ireplace("%SITENAME%", "", $noRepl); $noRepl = str_ireplace("%URL%", "", $noRepl);$noRepl = str_ireplace("%RAWEXCERPT%", "", $noRepl);
284
- $noRepl = str_ireplace("%SURL%", "", $noRepl);$noRepl = str_ireplace("%TEXT%", "", $noRepl);$noRepl = str_ireplace("%FULLTEXT%", "", $noRepl);$noRepl = str_ireplace("%EXCERPT%", "", $noRepl);
285
- $noRepl = str_ireplace("%ANNOUNCE%", "", $noRepl); $noRepl = str_ireplace("%AUTHORNAME%", "", $noRepl); $twLim = $twLim - strlen($noRepl);
286
-
287
- $pTitle = $title = $post->post_title;
288
- if ($post->post_excerpt!="") $pText = apply_filters('the_content', $post->post_excerpt); else $pText= apply_filters('the_content', $post->post_content);
289
- $pFullText = apply_filters('the_content', $post->post_content); $pRawText = $post->post_content;
290
-
291
- if (stripos($twMsgFormat, '%TITLE%')!==false) { $pTitle = nsTrnc($pTitle, $twLim); $twMsgFormat = str_ireplace("%TITLE%", $pTitle, $twMsgFormat); $twLim = $twLim - strlen($pTitle); }
292
- if (stripos($twMsgFormat, '%SITENAME%')!==false) {
293
- $siteTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); $siteTitle = nsTrnc($siteTitle, $twLim); $twMsgFormat = str_ireplace("%SITENAME%", $siteTitle, $twMsgFormat); $twLim = $twLim - strlen($siteTitle);
294
- }
295
- if (stripos($twMsgFormat, '%EXCERPT%')!==false) { $pText = nsTrnc(strip_tags(strip_shortcodes($pText)), 300, " ", "...");
296
- $pText = nsTrnc($pText, $twLim); $twMsgFormat = str_ireplace("%EXCERPT%", $pText, $twMsgFormat); $twLim = $twLim - strlen($pText);
297
- }
298
- if (stripos($twMsgFormat, '%FULLTEXT%')!==false) { $pFullText = nsTrnc(strip_tags($pFullText), $twLim); $twMsgFormat = str_ireplace("%FULLTEXT%", $pFullText, $twMsgFormat); $twLim = $twLim - strlen($pFullText); }
299
- if (stripos($twMsgFormat, '%RAWTEXT%')!==false) { $pRawText = nsTrnc(strip_tags($pRawText), $twLim); $twMsgFormat = str_ireplace("%FULLTEXT%", $pRawText, $twMsgFormat); $twLim = $twLim - strlen($pRawText); }
300
- $options['pkMsgFormat'] = nsFormatMessage($twMsgFormat, $postID, $addParams);
301
- }
302
- if (isset($options['attchImg']) && $options['attchImg']=='1' ) if (!empty($options['imgToUse'])) $imgURL = $options['imgToUse']; else $imgURL = nxs_getPostImage($postID, 'full'); else $imgURL='';
303
- if (preg_match("/noImg.\.png/i", $imgURL)) $imgURL = '';
304
- //## Post
305
- $message = array('siteName'=>$blogTitle, 'tags'=>'', 'imageURL'=>$imgURL);// prr($message);
306
- //## Actual Post
307
- $ntToPost = new nxs_class_SNAP_PK(); $ret = $ntToPost->doPostToNT($options, $message);
308
- //## Process Results
309
- if (!is_array($ret) || $ret['isPosted']!='1') { //## Error
310
- if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);
311
- } else { // ## All Good - log it.
312
- if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo _e('OK - Message Posted, please see your '.$logNT.' Page. ', 'social-networks-auto-poster-facebook-twitter-g'); }
313
- else { nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPosted'=>'1', 'pgID'=>$ret['postID'], 'pDate'=>date('Y-m-d H:i:s'))); nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); }
314
- }
315
- //## Return Result
316
- if ($ret['isPosted']=='1') return 200; else return print_r($ret, true);
317
- }
318
- }
319
 
320
  ?>
1
  <?php
2
  //## NextScripts Facebook Connection Class
3
+ $nxs_snapAvNts[] = array('code'=>'PK', 'lcode'=>'pk', 'name'=>'Plurk', 'type'=>'Social Networks', 'ptype'=>'F', 'status'=>'A', 'desc'=>'Autopost to your account. Ability to attach Image to messages');
4
 
5
+ if (!class_exists("nxs_snapClassPK")) { class nxs_snapClassPK extends nxs_snapClassNT {
6
+ var $ntInfo = array('code'=>'PK', 'lcode'=>'pk', 'name'=>'Plurk', 'defNName'=>'', 'tstReq' => true, 'instrURL'=>'http://www.nextscripts.com/setup-installation-plurk-social-networks-auto-poster-wordpress/');
7
+ var $defO = array('nName'=>'', 'do'=>'1', 'appKey'=>'', 'appSec'=>'', 'attchImg'=>1, 'msgFormat'=>"%TITLE% - %URL%", 'pkCat'=>'', 'pkURL'=>'');
8
+ //#### Update
9
+ function toLatestVer($ntOpts){ if( !empty($ntOpts['v'])) $v = $ntOpts['v']; else $v = 340; $ntOptsOut = ''; switch ($v) {
10
+ case 340: $ntOptsOut = $this->toLatestVerNTGen($ntOpts); $ntOptsOut['do'] = $ntOpts['do'.$this->ntInfo['code']]; $ntOptsOut['nName'] = !empty($ntOpts['nName'])?$ntOpts['nName']:'';
11
+ $ntOptsOut['msgFormat'] = !empty($ntOpts['pkMsgFormat'])?$ntOpts['pkMsgFormat']:''; $ntOptsOut['appKey'] = !empty($ntOpts['pkConsKey'])?$ntOpts['pkConsKey']:''; $ntOptsOut['appSec'] = !empty($ntOpts['pkConsSec'])?$ntOpts['pkConsSec']:'';
12
+ $ntOptsOut['accessToken'] = !empty($ntOpts['pkAccessTocken'])?$ntOpts['pkAccessTocken']:''; $ntOptsOut['accessTokenSec'] = !empty($ntOpts['pkAccessTockenSec'])?$ntOpts['pkAccessTockenSec']:'';
13
+ $ntOptsOut['oAuthToken'] = !empty($ntOpts['pkOAuthToken'])?$ntOpts['pkOAuthToken']:''; $ntOptsOut['oAuthTokenSecret'] = !empty($ntOpts['pkOAuthTokenSecret'])?$ntOpts['pkOAuthTokenSecret']:'';
14
+ $ntOptsOut['pgID'] = !empty($ntOpts['pkPgID'])?$ntOpts['pkPgID']:''; $ntOptsOut['pkURL'] = !empty($ntOpts['pkURL'])?$ntOpts['pkURL']:''; $ntOptsOut['pkCat'] =!empty($ntOpts['pkCat'])?$ntOpts['pkCat']:''; $ntOptsOut['attchImg'] = !empty($ntOpts['attchImg'])?$ntOpts['attchImg']:'';
15
+ $ntOptsOut = nxs_arrMergeCheck($ntOptsOut, $this->defO); $ntOptsOut['isUpdd'] = '1'; $ntOptsOut['v'] = NXS_SETV;
16
+ break;
17
+ }
18
+ return !empty($ntOptsOut)?$ntOptsOut:$ntOpts;
19
+ }
20
+ function pkCats() { return '<option value="">:freestyle(None)</option><option value="loves">loves</option><option value="likes">likes</option><option value="shares">shares</option><option value="gives">gives</option><option value="hates">hates</option><option value="wants">wants</option><option value="wishes">wishes</option><option value="needs">needs</option><option value="will">will</option><option value="hopes">hopes</option><option value="asks">asks</option><option value="has">has</option><option value="was">was</option><option value="wonders">wonders</option><option value="feels on">feels</option><option value="thinks">thinks</option><option value="says">says</option><option value="is">is</option>';}
21
+ //#### Show Common Settings
22
+ function showGenNTSettings($ntOpts){ $this->nt = $ntOpts; $this->showNTGroup(); }
23
+ //#### Show NEW Settings Page
24
+ function showNewNTSettings($ii){ $this->showGNewNTSettings($ii, $this->defO); }
25
+ //#### Show Unit Settings
26
+ function checkIfSetupFinished($options) { return !empty($options['pgID']) && !empty($options['accessToken']); }
27
+ public function doAuth() { $ntInfo = $this->ntInfo; global $nxs_snapSetPgURL;
28
+ if ( isset($_GET['auth']) && $_GET['auth']=='pk'){ require_once('apis/plurkOAuth.php'); $options = $this->nt[$_GET['acc']]; prr($options, 'OPTS:'); prr($this->nt, 'OPTS:');
29
+ $consumer_key = $options['appKey']; $consumer_secret = $options['appSec']; $callback_url = $nxs_snapSetPgURL."&auth=pka&acc=".$_GET['acc'];
30
+ $tum_oauth = new wpPlurkOAuth($consumer_key, $consumer_secret); $request_token = $tum_oauth->getReqToken($callback_url);
31
+ $options['oAuthToken'] = $request_token['oauth_token']; $options['oAuthTokenSecret'] = $request_token['oauth_token_secret']; //prr($tum_oauth); prr($options); //die();
32
+ switch ($tum_oauth->http_code) { case 200: $url = 'https://www.plurk.com/OAuth/authorize?oauth_token='.$options['oAuthToken']; nxs_save_glbNtwrks($ntInfo['lcode'],$_GET['acc'],$options,'*');
33
  echo '<br/><br/>All good?! Redirecting ..... <script type="text/javascript">window.location = "'.$url.'"</script>'; break;
34
  default: echo '<br/><b style="color:red">Could not connect to Plurk. Refresh the page or try again later.</b>'; die();
35
  }
36
  die();
37
  }
38
+ if ( isset($_GET['auth']) && $_GET['auth']=='pka'){ require_once('apis/plurkOAuth.php'); $options = $this->nt[$_GET['acc']];
39
+ $consumer_key = $options['appKey']; $consumer_secret = $options['appSec']; prr($options, 'OPTS:');
40
+ $tum_oauth = new wpPlurkOAuth($consumer_key, $consumer_secret, $options['oAuthToken'], $options['oAuthTokenSecret']); //prr($tum_oauth);
 
41
  $access_token = $tum_oauth->getAccToken($_GET['oauth_verifier']); prr($access_token);
42
+ $options['accessToken'] = $access_token['oauth_token']; $options['accessTokenSec'] = $access_token['oauth_token_secret'];
43
+ nxs_save_glbNtwrks($ntInfo['lcode'],$_GET['acc'],$options,'*');
44
+ $tum_oauth = new wpPlurkOAuth($consumer_key, $consumer_secret, $options['accessToken'], $options['accessTokenSec']);
45
+ $uinfo = $tum_oauth->makeReq('https://www.plurk.com/APP/Profile/getOwnProfile', $params);
 
46
  if (is_array($uinfo) && isset($uinfo['user_info'])) $userinfo = $uinfo['user_info']['display_name'];
47
+ if (empty($userinfo) && is_array($uinfo) && isset($uinfo['user_info'])) $userinfo = $uinfo['user_info']['nick_name']; $options['pgID'] = $userinfo;
48
+ nxs_save_glbNtwrks($ntInfo['lcode'],$_GET['acc'],$options,'*');
49
+ if ($options['pgID']!='') {
50
  $gGet = $_GET; unset($gGet['auth']); unset($gGet['acc']); unset($gGet['oauth_token']); unset($gGet['oauth_verifier']); unset($gGet['post_type']);
51
  $sturl = explode('?',$nxs_snapSetPgURL); $nxs_snapSetPgURL = $sturl[0].((!empty($gGet))?'?'.http_build_query($gGet):'');
52
  echo '<br/><br/>All good?! Redirecting ..... <script type="text/javascript">window.location = "'.$nxs_snapSetPgURL.'"</script>'; die();
53
  }
54
+ else die("<span style='color:red;'>ERROR: Authorization Error: <span style='color:darkred; font-weight: bold;'>".$options['pgID']."</span></span>");
55
+ }
56
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
 
58
+ function accTab($ii, $options, $isNew=false){ global $nxs_snapSetPgURL; $ntInfo = $this->ntInfo; $nt = $ntInfo['lcode']; ?>
59
+ <div style="width:100%;"><strong><?php _e('Where to Post', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong><i><?php _e('Your Plurk URL', 'social-networks-auto-poster-facebook-twitter-g'); ?></i></div><input name="<?php echo $nt; ?>[<?php echo $ii; ?>][pkURL]" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['pkURL'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /><br/><br/>
60
+ <?php $this->elemKeySecret($ii,'App Key','App Secret', $options['appKey'], $options['appSec'],'appKey','appSec','https://www.plurk.com/PlurkApp/'); ?>
61
+ <div style=""> <div style="width:100%;"><strong id="altFormatText">Plurk prefix:</strong> </div>
62
+ <select name="pk[<?php echo $ii; ?>][pkCat]" id="pkCat<?php echo $ii; ?>">
63
+ <?php $pkCats = $this->pkCats(); if (isset($options['pkCat']) && $options['pkCat']!='') $pkCats = str_replace($options['pkCat'].'"', $options['pkCat'].'" selected="selected"', $pkCats); echo $pkCats; ?>
64
+ </select>
65
+ </div>
66
+ <div style="margin: 0px;"><input value="1" id="apLIAttch" type="checkbox" name="pk[<?php echo $ii; ?>][attchImg]" <?php if ((int)$options['attchImg'] == 1) echo "checked"; ?> /> <strong>Attach Image to Plurk Post</strong></div>
67
+ <?php $this->elemMsgFormat($ii,'Post Format','msgFormat',$options['msgFormat']); ?>
68
+
69
+ <br/><br/>
70
+ <?php
71
+ if($options['appSec']=='') { ?>
 
 
 
 
 
72
  <b>Authorize Your Plurk Account</b>. Please save your settings and come back here to Authorize your account.
73
+ <?php } else { if (!empty($options['accessToken']) && $options['accessTokenSec']!=='') { ?>
74
+ Your Plurk Account has been authorized. Your display name: <?php _e(apply_filters('format_to_edit', htmlentities($options['pgID'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>.
75
  You can Re- <?php } ?>
76
  <a href="<?php echo $nxs_snapSetPgURL.(stripos($nxs_snapSetPgURL, '?')!==false?'&':'?');?>auth=pk&acc=<?php echo $ii; ?>">Authorize Your Plurk Account</a>
77
+ <?php if (empty($options['oAuthTokenSecret'])) { ?> <div class="blnkg">&lt;=== Authorize your account ===</div> <?php } ?>
78
+ <?php } ?>
79
+ <br/><br/><?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  }
81
+ function advTab($ii, $options){}
82
  //#### Set Unit Settings from POST
83
+ function setNTSettings($post, $options){
84
+ foreach ($post as $ii => $pval){
85
+ if (!empty($pval['appKey']) && !empty($pval['appKey'])){ if (!isset($options[$ii])) $options[$ii] = array(); $options[$ii] = $this->saveCommonNTSettings($pval,$options[$ii]);
86
+ //## Uniqe Items
87
+ if (isset($pval['pkCat'])) $options[$ii]['pkCat'] = trim($pval['pkCat']);
88
+ if (isset($pval['attchImg'])) $options[$ii]['attchImg'] = $pval['attchImg']; else $options[$ii]['attchImg'] = 0;
89
+ if (isset($pval['pkURL'])) { $options[$ii]['pkURL'] = trim($pval['pkURL']); if ( substr($options[$ii]['pkURL'], 0, 4)!='http' ) $options[$ii]['pkURL'] = 'http://'.$options[$ii]['pkURL'];
90
+ $pkPgID = $options[$ii]['pkURL']; if (substr($pkPgID, -1)=='/') $pkPgID = substr($pkPgID, 0, -1); $pkPgID = substr(strrchr($pkPgID, "/"), 1);
91
+ $options[$ii]['pgID'] = $pkPgID;
92
+ }
93
+ } elseif ( count($pval)==1 ) if (isset($pval['do'])) $options[$ii]['do'] = $pval['do']; else $options[$ii]['do'] = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  } return $options;
95
+ }
96
+
97
  //#### Show Post->Edit Meta Box Settings
98
+
99
+ function showEdPostNTSettings($ntOpts, $post){ $post_id = $post->ID; $nt = $this->ntInfo['lcode']; $ntU = $this->ntInfo['code'];
100
+ foreach($ntOpts as $ii=>$ntOpt) { $isFin = $this->checkIfSetupFinished($ntOpt); if (!$isFin) continue;
101
+ $pMeta = maybe_unserialize(get_post_meta($post_id, 'snap'.$ntU, true)); if (is_array($pMeta) && !empty($pMeta[$ii])) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
102
+
103
+ if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = ''; if (empty($ntOpt['urlToUse'])) $ntOpt['urlToUse'] = ''; $postType = isset($ntOpt['postType'])?$ntOpt['postType']:'';
104
+ $msgFormat = !empty($ntOpt['msgFormat'])?htmlentities($ntOpt['msgFormat'], ENT_COMPAT, "UTF-8"):''; $msgTFormat = !empty($ntOpt['msgTFormat'])?htmlentities($ntOpt['msgTFormat'], ENT_COMPAT, "UTF-8"):'';
105
+ $imgToUse = $ntOpt['imgToUse']; $urlToUse = $ntOpt['urlToUse']; $ntOpt['ii']=$ii; $this->nxs_tmpltAddPostMeta($post, $ntOpt, $pMeta);
106
+ $this->elemEdMsgFormat($ii, __('Message Format:', 'social-networks-auto-poster-facebook-twitter-g'),$msgFormat);
107
+ nxs_showImgToUseDlg($nt, $ii, $imgToUse);
108
+ /* ## Select Image & URL ## */ nxs_showURLToUseDlg($nt, $ii, $urlToUse); $this->nxs_tmpltAddPostMetaEnd($ii);
109
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
  }
111
 
112
+ //#### Save Meta Tags to the Post
113
+ function adjMetaOpt($optMt, $pMeta){ $optMt = $this->adjMetaOptG($optMt, $pMeta);
114
+ if (!empty($pMeta['attchImg'])) $optMt['attchImg'] = $pMeta['attchImg']; else $optMt['attchImg'] = 0;
115
+ return $optMt;
 
 
 
 
116
  }
117
+
118
+ function adjPublishWP(&$options, &$message, $postID){
119
+ if (!empty($postID)) { if (trim($options['imgToUse'])!='') $imgURL = $options['imgToUse']; else $imgURL = nxs_getPostImage($postID, !empty($options['wpImgSize'])?$options['wpImgSize']:'full');
120
+ if (preg_match("/noImg.\.png/i", $imgURL)) { $imgURL = ''; $isNoImg = true; }
121
+ $message['imageURL'] = $imgURL;
122
+ }
123
+ }
124
+
125
  }}
126
 
127
+ if (!function_exists("nxs_doPublishToPK")) { function nxs_doPublishToPK($postID, $options){
128
+ if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true)); $cl = new nxs_snapClassPK(); $cl->nt[$options['ii']] = $options; return $cl->publishWP($options['ii'], $postID);
129
+ }}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
 
131
  ?>
inc-cl/pn.api.php CHANGED
@@ -12,27 +12,29 @@ if (!class_exists("nxs_class_SNAP_PN")) { class nxs_class_SNAP_PN {
12
  return $out;
13
  }
14
  function doPostToNT($options, $message){ global $nxs_gCookiesArr; $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>'');
 
15
  //## Check settings
16
  if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
17
- if (!isset($options['pnUName']) || trim($options['pnPass'])=='') { $badOut['Error'] = 'Not Configured'; return $badOut; }
18
- $pass = substr($options['pnPass'], 0, 5)=='g9c1a'?nsx_doDecode(substr($options['pnPass'], 5)):$options['pnPass'];
19
  if (empty($options['imgSize'])) $options['imgSize'] = '';
20
  //## Format
21
- if (!empty($message['pText'])) $msg = $message['pText']; else $msg = nxs_doFormatMsg($options['pnMsgFormat'], $message); $boardID = $options['pnBoard']; // prr($boardID); prr($_POST); die();
22
  if (isset($message['imageURL'])) $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); else $imgURL = ''; if ($imgURL=='') $badOut['Error'] .= 'NO Image.';
23
  $urlToGo = (!empty($message['url']))?$message['url']:'';
24
- //## Check for existing session
25
- if (isset($options['ck'])) $nxs_gCookiesArr = maybe_unserialize( $options['ck']); $loginError = true; if (is_array($nxs_gCookiesArr)) $loginError = doCheckPinterest();
26
- if ($loginError!==false) $loginError = doConnectToPinterest($options['pnUName'], $pass); if ($loginError!==false) { $badOut['Error'] = print_r($loginError, true)." - BAD USER/PASS"; return $badOut; }
27
- if (preg_match ( '/\$(\d+\.\d+)/', $msg, $matches )) $price = $matches[0]; else $price = '';
28
 
29
- if (isset($options['cImgURL']) && $options['cImgURL']=='S' ) $urlToGo = nxs_mkShortURL($urlToGo); elseif (isset($options['cImgURL']) && $options['cImgURL']=='N' ) $urlToGo = '';
30
-
31
- $ret = doPostToPinterest($msg, $imgURL, $urlToGo, $boardID, 'TITLE WHERE IS IT?', $price, $urlToGo."/GTH/" ); if ($ret=='OK') $ret = array("code"=>"OK", "post_id"=>'');
32
- //prr($ret);
33
- if (is_array($ret) && !empty($ret['post_id'])) return array('postID'=>str_ireplace('/pin/', '', $ret['post_id']), 'isPosted'=>1, 'postURL'=>$ret['post_url'], 'pDate'=>date('Y-m-d H:i:s'));
34
- else $badOut['Error'] .= 'Something went wrong - '.print_r($ret, true);
35
- return $badOut;
 
 
36
  }
37
  }}
38
  ?>
12
  return $out;
13
  }
14
  function doPostToNT($options, $message){ global $nxs_gCookiesArr; $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>'');
15
+ if (!class_exists("nxsAPI_PN")){ $badOut['Error'] .= "Pinterest API Library not found"; return $badOut; }
16
  //## Check settings
17
  if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
18
+ if (!isset($options['uName']) || trim($options['uPass'])=='') { $badOut['Error'] = 'Not Configured'; return $badOut; }
19
+ $pass = (substr($options['uPass'], 0, 5)=='n5g9a'||substr($options['uPass'], 0, 5)=='g9c1a'||substr($options['uPass'], 0, 5)=='b4d7s')?nsx_doDecode(substr($options['uPass'], 5)):$options['uPass'];
20
  if (empty($options['imgSize'])) $options['imgSize'] = '';
21
  //## Format
22
+ if (!empty($message['pText'])) $msg = $message['pText']; else $msg = nxs_doFormatMsg($options['msgFormat'], $message); $boardID = $options['pnBoard']; // prr($boardID); prr($_POST); die();
23
  if (isset($message['imageURL'])) $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); else $imgURL = ''; if ($imgURL=='') $badOut['Error'] .= 'NO Image.';
24
  $urlToGo = (!empty($message['url']))?$message['url']:'';
25
+
26
+ //## Get Saved Login Info
27
+ if (function_exists('nxs_getOption')) { $opVal = array(); $opNm = 'nxs_snap_pn_'.sha1('nxs_snap_pn'.$options['uName'].$options['uPass']); $opVal = nxs_getOption($opNm); if (!empty($opVal) & is_array($opVal)) $options = array_merge($options, $opVal); }
 
28
 
29
+ $nt = new nxsAPI_PN(); $nt->debug = false; if(!empty($options['ck'])) $nt->ck = $options['ck']; if (!empty($options['proxy'])&&!empty($options['proxyOn'])){ $nt->proxy['proxy'] = $options['proxy']['proxy']; if (!empty($options['proxy']['up'])) $nt->proxy['up'] = $options['proxy']['up'];};
30
+ $loginErr = $nt->connect($options['uName'], $pass); if ($loginErr) { $badOut['Error'] .= 'Can\'t Connect - '.print_r($loginErr, true); return $badOut; }
31
+
32
+ if (preg_match ( '/\$(\d+\.\d+)/', $msg, $matches )) $price = $matches[0]; else $price = '';
33
+ if (isset($options['cImgURL']) && $options['cImgURL']=='S' ) $urlToGo = nxs_mkShortURL($urlToGo); elseif (isset($options['cImgURL']) && $options['cImgURL']=='N' ) $urlToGo = '';
34
+ if (!empty($nt->ck['chkPnt3'])) unset($nt->ck['chkPnt3']); $ret = $nt->post($msg, $imgURL, $urlToGo, $boardID, 'T', $price, $urlToGo);
35
+ //## Save Login Info
36
+ if (function_exists('nxs_saveOption')) { if (empty($opVal['ck'])) $opVal['ck'] = ''; if (is_array($ret) && $ret['isPosted']=='1' && $opVal['ck'] != $nt->ck) { $opVal['ck'] = $nt->ck; nxs_saveOption($opNm, $opVal); } }
37
+ return $ret;
38
  }
39
  }}
40
  ?>
inc-cl/pn.php CHANGED
@@ -1,251 +1,138 @@
1
  <?php
2
  //## NextScripts Facebook Connection Class
3
- $nxs_snapAvNts[] = array('code'=>'PN', 'lcode'=>'pn', 'name'=>'Pinterest');
4
 
5
- if (!class_exists("nxs_snapClassPN")) { class nxs_snapClassPN { var $ntInfo = array('code'=>'PN', 'lcode'=>'pn', 'name'=>'Pinterest', 'defNName'=>'pnUName', 'tstReq' => false);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  //#### Show Common Settings
7
- function showGenNTSettings($ntOpts){ global $nxs_plurl; $ntInfo = $this->ntInfo;
8
- $fMsg = 'Pinterest doesn\'t have a built-in API for automated posts yet. <br/>You need to get a special <a target="_blank" href="http://www.nextscripts.com/pinterest-automated-posting">library module</a> to be able to publish your content to Pinterest.';
9
- $ntParams = array('ntInfo'=>$ntInfo, 'nxs_plurl'=>$nxs_plurl, 'ntOpts'=>$ntOpts, 'chkField'=>'apPNUName', 'checkFunc' => array('funcName'=>'doPostToPinterest', 'msg'=>$fMsg)); nxs_showListRow($ntParams); ?>
10
- <?php
11
- }
12
  //#### Show NEW Settings Page
13
- function showNewNTSettings($mgpo){ $po = array('nName'=>'', 'doPN'=>'1', 'pnUName'=>'', 'pnBoard'=>'', 'gpAttch'=>'', 'cImgURL'=>'R', 'pnPass'=>'', 'pnDefImg'=>'', 'pnMsgFormat'=>'', 'pnBoard'=>'', 'pnBoardsList'=>'');
14
- $po['ntInfo']= array('lcode'=>'pn'); $this->showNTSettings($mgpo, $po, true);}
15
- //#### Show Unit Settings
16
- function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl; $nt = $options['ntInfo']['lcode']; $ntU = strtoupper($nt);
17
- 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'] = '';
18
- if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; ?>
19
- <div id="doPN<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>"> <input type="hidden" name="apDoSPN<?php echo $ii; ?>" value="0" id="apDoSPN<?php echo $ii; ?>" />
20
- <?php if (!function_exists('doPostToPinterest') || (defined('d1') && d1==1)) {
21
- nxs_show_noLibWrn('Pinterest API Library module NOT found.<br/><br/><span style="color:black;">Pinterest doesn\'t have a free native API for automated posts yet.</span><br/><br/><span style="font-size: 12px;color:black;">You need to have a special API Library Module to be able to publish your content to Pinterest.</span>'); echo "</div>"; return; };
22
- ?>
23
-
24
- <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/"><?php $nType="Pinterest"; printf( __( 'Detailed %s Installation/Configuration Instructions', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?></a></div>
25
- <div style="width:100%;"><strong><?php _e('Account Nickname', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'social-networks-auto-poster-facebook-twitter-g'); ?></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")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /><br/>
26
- <?php echo nxs_addQTranslSel('pn', $ii, $options['qTLng']); ?>
27
-
28
- <br/>
29
- <ul class="nsx_tabs">
30
- <li><a href="#nsx<?php echo $nt.$ii ?>_tab1"><?php _e('Account Info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li>
31
- <?php if (!$isNew) { ?> <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li> <?php } ?>
32
- </ul>
33
- <div class="nsx_tab_container"><?php /* ######################## Account Tab ####################### */ ?>
34
- <div id="nsx<?php echo $nt.$ii ?>_tab1" class="nsx_tab_content" style="background-image: url(<?php echo $nxs_plurl; ?>img/<?php echo $nt; ?>-bg.png); background-repeat: no-repeat; background-position:90% 10%;">
35
-
36
 
37
-
38
- <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")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />
39
- <div style="width:100%;"><strong>Pinterest Password:</strong> </div><input autocomplete="false" readonly onfocus="this.removeAttribute('readonly');" 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")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /> <br/>
40
-
41
- <strong>Clickthrough URL:</strong>
42
- <p style="margin-bottom: 20px;margin-top: 5px;">
43
- <input type="radio" name="pn[<?php echo $ii; ?>][cImgURL]" value="R" <?php if ( !isset($options['cImgURL']) || $options['cImgURL'] == '' || $options['cImgURL'] == 'R') echo 'checked="checked"'; ?> /> Regular Post URL&nbsp;&nbsp;
44
- <!-- <input type="radio" name="pn[<?php echo $ii; ?>][cImgURL]" value="S" <?php if ($options['cImgURL'] == 'S') echo 'checked="checked"'; ?> /> Shortened Post URL&nbsp;&nbsp; -->
45
- <input type="radio" name="pn[<?php echo $ii; ?>][cImgURL]" value="N" <?php if ($options['cImgURL'] == 'N') echo 'checked="checked"'; ?> /> No Clickthrough URL&nbsp;&nbsp;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
 
47
- <div style="width:100%;"><strong>Default Image to Pin:</strong>
48
- <p style="font-size: 11px; margin: 0px;">If your post does not have any images this will be used instead.</p>
49
- </div><input name="pn[<?php echo $ii; ?>][apPNDefImg]" id="apPNDefImg" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['pnDefImg'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />
50
- <br/><br/>
51
-
52
- <div style="width:100%;"><strong>Board:</strong>
53
- Please <a href="#" onclick="nxs_getPNBoards(jQuery('<?php if ($isNew) echo "#nsx_addNT "; ?>#apPNUName<?php echo $ii; ?>').val(),jQuery('<?php if ($isNew) echo "#nsx_addNT "; ?>#apPNPass<?php echo $ii; ?>').val(), '<?php echo $ii; ?>'); return false;">click here to retrieve your boards</a>
54
- </div>
55
- <img id="pnLoadingImg<?php echo $ii; ?>" style="display: none;" src='<?php echo $nxs_plurl; ?>img/ajax-loader-sm.gif' />
56
- <select name="pn[<?php echo $ii; ?>][apPNBoard]" id="apPNBoard<?php echo $ii; ?>">
57
- <?php if ($options['pnBoardsList']!=''){ $gPNBoards = $options['pnBoardsList']; if ( base64_encode(base64_decode($gPNBoards)) === $gPNBoards) $gPNBoards = base64_decode($gPNBoards);
58
- if ($options['pnBoard']!='') $gPNBoards = str_replace($options['pnBoard'].'"', $options['pnBoard'].'" selected="selected"', $gPNBoards); echo $gPNBoards;} else { ?>
59
- <option value="0">None(Click above to retrieve your boards)</option>
60
- <?php } ?>
61
- </select>
62
-
63
- <br/><br/>
64
-
65
- <div style="margin-bottom: 5px; margin-left: 0px; "><input value="1" id="isAttachVid" type="checkbox" name="pn[<?php echo $ii; ?>][isAttachVid]" <?php if (isset($options['isAttachVid']) && (int)$options['isAttachVid'] == 1) echo "checked"; ?> /> <strong><?php _e('If post has a video use it instead of image', 'social-networks-auto-poster-facebook-twitter-g'); ?></strong> <i><?php _e('Video will be pinned instead of featured image. Only Youtube is supported at this time.', 'social-networks-auto-poster-facebook-twitter-g'); ?></i>
66
- <br/></div>
67
-
68
- <div id="altFormat" style="">
69
- <div style="width:100%;"><strong id="altFormatText"><?php _e('Message text Format', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> <a href="#" id="apPNMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apPNMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>
70
- </div>
71
-
72
- <textarea cols="150" rows="3" id="pn<?php echo $ii; ?>SNAPformat" name="pn[<?php echo $ii; ?>][apPNMsgFrmt]" style="width:51%;max-width: 650px;" onfocus="jQuery('#pn<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('apPNMsgFrmt<?php echo $ii; ?>');"><?php if ($options['pnMsgFormat']!='') _e(apply_filters('format_to_edit', htmlentities($options['pnMsgFormat'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g'); else echo "%TITLE% - %URL%"; ?></textarea>
73
-
74
- <?php nxs_doShowHint("apPNMsgFrmt".$ii); ?>
75
- </div><br/>
76
- <?php if ($isNew) { ?> <input type="hidden" name="pn[<?php echo $ii; ?>][apDoPN]" value="1" id="apDoNewPN<?php echo $ii; ?>" /> <?php } ?>
77
- <?php if ($options['pnPass']!='') { ?>
78
-
79
- <b><?php _e('Test your settings', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('PN', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?></a>
80
- <?php } ?>
81
-
82
- </div>
83
- <?php /* ######################## Advanced Tab ####################### */ ?>
84
- <?php if (!$isNew) { ?> <div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content">
85
-
86
- <?php nxs_showCatTagsCTFilters($nt, $ii, $options);
87
- nxs_addPostingDelaySelV3($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']);
88
- nxs_showRepostSettings($nt, $ii, $options); ?>
89
-
90
-
91
- </div> <?php } ?> <?php /* #### End of Tab #### */ ?>
92
- </div><br/> <?php /* #### End of Tabs #### */ ?>
93
-
94
- <div class="submitX nxclear" style="padding-bottom: 0px;"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'social-networks-auto-poster-facebook-twitter-g') ?>" /></div>
95
-
96
- </div>
97
- </div>
98
- <?php
99
  }
 
100
  //#### Set Unit Settings from POST
101
- function setNTSettings($post, $options){ $code = $this->ntInfo['code'];
102
  foreach ($post as $ii => $pval){
103
- if (!empty($pval['apPNUName']) && !empty($pval['apPNPass'])){ if (!isset($options[$ii])) $options[$ii] = array();
104
- if (isset($pval['apDoPN'])) $options[$ii]['doPN'] = $pval['apDoPN']; else $options[$ii]['doPN'] = 0;
105
- if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']);
106
- if (isset($pval['apPNUName'])) $options[$ii]['pnUName'] = trim($pval['apPNUName']);
107
- if (isset($pval['apPNPass'])) $options[$ii]['pnPass'] = 'g9c1a'.nsx_doEncode($pval['apPNPass']); else $options[$ii]['pnPass'] = '';
108
- if (isset($pval['apPNBoard'])) $options[$ii]['pnBoard'] = trim($pval['apPNBoard']);
109
- if (isset($pval['apPNDefImg'])) $options[$ii]['pnDefImg'] = trim($pval['apPNDefImg']);
110
- if (isset($pval['isAttachVid'])) $options[$ii]['isAttachVid'] = $pval['isAttachVid']; else $options[$ii]['isAttachVid'] = 0;
111
- if (isset($pval['cImgURL'])) $options[$ii]['cImgURL'] = trim($pval['cImgURL']);
112
 
113
- if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']); else $options[$ii]['catSel'] = 0;
114
- if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
 
 
115
 
116
- if (isset($pval['apPNMsgFrmt'])) $options[$ii]['pnMsgFormat'] = trim($pval['apPNMsgFrmt']);
117
-
118
- $options[$ii] = nxs_adjRpst($options[$ii], $pval);
119
-
120
- if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']);
121
- if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
122
- if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
123
- } elseif ( count($pval)==1 ) if (isset($pval['apDo'.$code])) $options[$ii]['do'.$code] = $pval['apDo'.$code]; else $options[$ii]['do'.$code] = 0;
124
  } return $options;
125
- }
 
126
  //#### Show Post->Edit Meta Box Settings
127
- function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID; $nt = 'pn'; $ntU = 'PN'; //prr($ntOpts);
128
- foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapPN', true)); if (is_array($pMeta) && !empty($pMeta[$ii])) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
129
- if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = ''; if (empty($ntOpt['urlToUse'])) $ntOpt['urlToUse'] = '';
130
- $doPN = $ntOpt['doPN'] && (is_array($pMeta) || $ntOpt['catSel']!='1'); $imgToUse = $ntOpt['imgToUse']; $urlToUse = $ntOpt['urlToUse'];
131
- $isAvailPN = $ntOpt['pnUName']!='' && $ntOpt['pnPass']!=''; $pnMsgFormat = htmlentities($ntOpt['pnMsgFormat'], ENT_COMPAT, "UTF-8");
132
- ?>
133
- <tr><th style="text-align:left;" colspan="2">
134
- <?php if ($ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='') { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
135
- <?php if (!empty($ntOpt['tagsSelX'])) { ?> <input type="hidden" class="nxs_TG" id="nxs_TG_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $ntOpt['tagsSelX']; ?>" /> <?php } ?>
136
- <?php if ($isAvailPN) { ?><input class="nxsGrpDoChb" value="1" id="doPN<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="pn[<?php echo $ii; ?>][doPN]" <?php if ((int)$doPN == 1) echo 'checked="checked" title="def"'; ?> />
137
- <?php if ($post->post_status == "publish") { ?> <input type="hidden" name="pn[<?php echo $ii; ?>][doPN]" value="<?php echo $doPN;?>"> <?php } ?> <?php } ?>
138
- <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/pn16.png);">Pinterest - <?php _e('publish to', 'social-networks-auto-poster-facebook-twitter-g') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
139
- 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', 'social-networks-auto-poster-facebook-twitter-g') ?>" />
140
- <?php } ?>
141
-
142
- <?php if (is_array($pMeta) && !empty($pMeta[$ii]) && isset($pMeta[$ii]['postURL']) ) {
143
- ?> <span id="pstdPN<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
144
- <a style="font-size: 10px;" href="<?php echo $pMeta[$ii]['postURL']; ?>" target="_blank"><?php $nType="Pinterest"; printf( __( 'Posted on', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
145
- </span><?php } ?>
146
-
147
- </td></tr>
148
-
149
- <?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>
150
- <?php } else { if ($post->post_status != "publish" && function_exists('nxs_doSMAS5') ) { $ntOpt['postTime'] = get_post_time('U', false, $post_id); nxs_doSMAS5($nt, $ii, $ntOpt); } ?>
151
-
152
- <?php if ($ntOpt['rpstOn']=='1') { ?>
153
-
154
- <tr id="altFormat1" style=""><th scope="row" class="nxsTHRow">
155
- <input value="0" type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]"/><input value="nxsi<?php echo $ii; ?>pn" type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]" <?php if (!empty($ntOpt['rpstPostIncl'])) echo "checked"; ?> />
156
- </th>
157
- <td> <?php _e('Include in "Auto-Reposting" to this network.', 'social-networks-auto-poster-facebook-twitter-g') ?>
158
- </td></tr> <?php } ?>
159
-
160
- <tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;">Select Board</th>
161
- <td><select name="pn[<?php echo $ii; ?>][apPNBoard]" id="apPNBoard">
162
- <?php if (!empty($ntOpt['pnBoardsList'])){ $gPNBoards = $ntOpt['pnBoardsList']; if ( base64_encode(base64_decode($gPNBoards)) === $gPNBoards) $gPNBoards = base64_decode($gPNBoards);
163
- if ($ntOpt['pnBoard']!='') $gPNBoards = str_replace($ntOpt['pnBoard'].'"', $ntOpt['pnBoard'].'" selected="selected"', $gPNBoards); echo $gPNBoards;} else { ?>
164
- <option value="0">None(Click above to retrieve your boards)</option>
165
  <?php } ?>
166
  </select></td>
167
- </tr>
168
-
169
- <tr id="altFormat1" style=""><th scope="row" class="nxsTHRow"><?php _e('Text Message Format:', 'social-networks-auto-poster-facebook-twitter-g') ?></th>
170
- <td>
171
- <textarea cols="150" rows="1" id="pn<?php echo $ii; ?>SNAPformat" name="pn[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('#pn<?php echo $ii; ?>SNAPformat').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apPNMsgFrmt<?php echo $ii; ?>');"><?php echo $pnMsgFormat; ?></textarea>
172
- <?php nxs_doShowHint("apPNMsgFrmt".$ii); ?></td></tr>
173
-
174
- <?php /* ## Select Image & URL ## */ nxs_showImgToUseDlg($nt, $ii, $imgToUse); nxs_showURLToUseDlg($nt, $ii, $urlToUse); ?>
175
- <?php }
176
  }
177
- }
178
- //#### Save Meta Tags to the Post
179
- function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
180
- if (isset($pMeta['SNAPformat'])) $optMt['pnMsgFormat'] = $pMeta['SNAPformat'];
181
- if (isset($pMeta['imgToUse'])) $optMt['imgToUse'] = $pMeta['imgToUse']; if (isset($pMeta['urlToUse'])) $optMt['urlToUse'] = $pMeta['urlToUse'];
182
- if (isset($pMeta['timeToRun'])) $optMt['timeToRun'] = $pMeta['timeToRun']; if (isset($pMeta['rpstPostIncl'])) $optMt['rpstPostIncl'] = $pMeta['rpstPostIncl'];
183
- if (isset($pMeta['doPN'])) $optMt['doPN'] = $pMeta['doPN'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doPN'] = 0; }
184
- if (isset($pMeta['apPNBoard']) && $pMeta['apPNBoard']!='' && $pMeta['apPNBoard']!='0') $optMt['pnBoard'] = $pMeta['apPNBoard'];
185
- if (isset($pMeta['SNAPincludePN']) && $pMeta['SNAPincludePN'] == '1' ) $optMt['doPN'] = 1;
186
- return $optMt;
187
  }
188
- }}
189
- if (!function_exists("nxs_rePostToPN_ajax")) {
190
- function nxs_rePostToPN_ajax() { check_ajax_referer('nxsSsPageWPN'); $postID = $_POST['id']; $options = get_option('NS_SNAutoPoster');
191
- foreach ($options['pn'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj'; //if ($two['gpPageID'].$two['gpUName']==$_POST['nid']) {
192
- $po = get_post_meta($postID, 'snapPN', true); $po = maybe_unserialize($po);// prr($gppo);
193
- if (is_array($po) && isset($po[$ii]) && is_array($po[$ii])){ $ntClInst = new nxs_snapClassPN(); $two = $ntClInst->adjMetaOpt($two, $po[$ii]); }
194
- $result = nxs_doPublishToPN($postID, $two); if ($result == 200) die("Successfully sent your post to Pinterest."); else die($result);
195
- }
196
  }
197
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
 
199
- if (!function_exists("nxs_doPublishToPN")) { //## Second Function to Post to G+
200
- function nxs_doPublishToPN($postID, $options){ global $nxs_gCookiesArr, $plgn_NS_SNAutoPoster; $ntCd = 'PN'; $ntCdL = 'pn'; $ntNm = 'Pinterest'; $price = '';
201
- if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true)); if (empty($options['ck'])) $options['ck'] = '';
202
- // $backtrace = debug_backtrace(); nxs_addToLogN('W', 'Enter', $ntCd, 'I am here - '.$ntCd."|".print_r($backtrace, true), '');
203
- //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToPN', array($postID, $options));
204
- $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'POSTID'=>$postID, 'ACCNAME'=>$options['nName']));
205
- $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url();
206
- if (empty($options['imgToUse'])) $options['imgToUse'] = ''; if (empty($options['imgSize'])) $options['imgSize'] = ''; if (empty($options['cImgURL'])) $options['cImgURL'] = 'R';
207
-
208
- $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
209
- $logNT = '<span style="color:#FA5069">Pinterest</span> - '.$options['nName'];
210
- $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap); $isAttachVid = $options['isAttachVid'];
211
- if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
212
- $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') { sleep(5);
213
- nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate |'.$uqID); return;
214
- }
215
- }
216
- if ($postID=='0') { echo "Testing ... <br/><br/>"; $options['pnMsgFormat'] = 'Test Post from '.$blogTitle; $urlToGo = home_url();
217
- if ($options['pnDefImg']!='') $imgURL = $options['pnDefImg']; else $imgURL ="http://direct.gtln.us/img/nxs/NXS-Lama.jpg";
218
- }
219
- else { $post = get_post($postID); if(!$post) return; $options['pnMsgFormat'] = nsFormatMessage( $options['pnMsgFormat'], $postID, $addParams);
220
- //## MyURL - URLToGo code
221
- $options = nxs_getURL($options, $postID, $addParams); $urlToGo = $options['urlToUse']; if (is_object($post)) $urlToGo = apply_filters( 'nxs_adjust_ex_url', $urlToGo, $post->post_content);
222
-
223
- if (!empty($options['imgToUse'])) $imgURL = $options['imgToUse']; else $imgURL = nxs_getPostImage($postID, 'full', $options['pnDefImg']); if (preg_match("/noImg.\.png/i", $imgURL)) $imgURL = '';
224
- 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'; }}
225
- $extInfo = ' | PostID: '.$postID." - ".(is_object($post))?$post->post_title:'';
226
- }
227
- if ($options['cImgURL']=='S') $options['cImgURL'] = 'R'; //## Pinterest no longer allows shorthened URLs.
228
- //## Post
229
- $message = array('siteName'=>$blogTitle, 'tags'=>'', 'url'=>$urlToGo, 'imageURL'=>$imgURL);// prr($message);
230
- //## Actual Post
231
- $ntToPost = new nxs_class_SNAP_PN(); $ret = $ntToPost->doPostToNT($options, $message);
232
- //## Save Session
233
- if (serialize($nxs_gCookiesArr)!=$options['ck']) { global $plgn_NS_SNAutoPoster; $gOptions = $plgn_NS_SNAutoPoster->nxs_options; // prr($gOptions['pn']);
234
- if (isset($options['ii']) && $options['ii']!=='') { $gOptions['pn'][$options['ii']]['ck'] = serialize($nxs_gCookiesArr); update_option('NS_SNAutoPoster', $gOptions); }
235
- else foreach ($gOptions['pn'] as $ii=>$gpn) { $result = array_diff($options, $gpn);
236
- if (!is_array($result) || count($result)<1) { $gOptions['pn'][$ii]['ck'] = serialize($nxs_gCookiesArr); update_option('NS_SNAutoPoster', $gOptions); break; }
237
- }
238
- }
239
- //## Process Results
240
- if (!is_array($ret) || $ret['isPosted']!='1') { //## Error
241
- if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);
242
- } else { // ## All Good - log it.
243
- if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo _e('OK - Message Posted, please see your '.$logNT.' Page. ', 'social-networks-auto-poster-facebook-twitter-g'); }
244
- else { nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPosted'=>'1', 'pgID'=>$ret['postID'], 'postURL'=>$ret['postURL'], 'pDate'=>date('Y-m-d H:i:s')));
245
- $extInfo .= ' | <a href="'.$ret['postURL'].'" target="_blank">Post Link</a>'; nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); }
246
- } //prr($ret);
247
- //## Return Result
248
- if ($ret['isPosted']=='1') return 200; else return print_r($ret, true);
249
- }
250
- }
251
  ?>
1
  <?php
2
  //## NextScripts Facebook Connection Class
3
+ $nxs_snapAvNts[] = array('code'=>'PN', 'lcode'=>'pn', 'name'=>'Pinterest', 'type'=>'Social Networks', 'ptype'=>'P', 'status'=>'A', 'desc'=>'Post your blogpost\'s image to your Pinterest board.');
4
 
5
+ if (!class_exists("nxs_snapClassPN")) { class nxs_snapClassPN extends nxs_snapClassNT {
6
+ var $ntInfo = array('code'=>'PN', 'lcode'=>'pn', 'name'=>'Pinterest', 'defNName'=>'uName', 'tstReq' => false, 'instrURL'=>'http://www.nextscripts.com/setup-installation-pinterest-social-networks-auto-poster-wordpress');
7
+
8
+ var $noFuncMsg = 'Pinterest doesn\'t have a built-in API for automated posts yet. <br/>You need to get a special <a target="_blank" href="http://www.nextscripts.com/snap-api/">library module</a> to be able to publish your content to Pinterest.';
9
+ function checkIfFunc() { return class_exists('nxsAPI_PN'); }
10
+
11
+ function toLatestVer($ntOpts){ if( !empty($ntOpts['v'])) $v = $ntOpts['v']; else $v = 340; $ntOptsOut = ''; switch ($v) {
12
+ case 340: $ntOptsOut = $this->toLatestVerNTGen($ntOpts); $ntOptsOut['do'] = $ntOpts['do'.$this->ntInfo['code']]; $ntOptsOut['nName'] = $ntOpts['nName'];
13
+ $ntOptsOut['msgFormat'] = $ntOpts['pnMsgFormat']; $ntOptsOut['uName'] = $ntOpts['pnUName']; $ntOptsOut['uPass'] = $ntOpts['pnPass'];
14
+ $ntOptsOut['cImgURL'] = $ntOpts['cImgURL']; $ntOptsOut['pnBoard'] = $ntOpts['pnBoard']; $ntOptsOut['isAttachVid'] = $ntOpts['isAttachVid']; $ntOptsOut['defImg'] = $ntOpts['pnDefImg'];
15
+ $ntOptsOut['v'] = NXS_SETV;
16
+ break;
17
+ }
18
+ return !empty($ntOptsOut)?$ntOptsOut:$ntOpts;
19
+ }
20
+
21
  //#### Show Common Settings
22
+ function showGenNTSettings($ntOpts){ $this->nt = $ntOpts; $this->showNTGroup(); return; }
 
 
 
 
23
  //#### Show NEW Settings Page
24
+ function showNewNTSettings($ii){ $defO = array('nName'=>'', 'do'=>'1', 'uName'=>'', 'uPass'=>'', 'cImgURL'=>'', 'isAttachVid'=>'', 'isAttachVid'=>'', 'defImg'=>'', 'msgFormat'=>"%EXCERPT%"); $this->showGNewNTSettings($ii, $defO); }
25
+ //#### Show Unit Settings
26
+ function checkIfSetupFinished($options) { return !empty($options['uPass']); }
27
+
28
+ function getMergeOptInfo($options, $ii) { $p = $options['uPass'];
29
+ if (!empty($p)) { $p = (substr($p, 0, 5)=='n5g9a'||substr($p, 0, 5)=='g9c1a'||substr($p, 0, 5)=='b4d7s')?nsx_doDecode(substr($p, 5)):$p; $options['uPass'] = 'g9c1a'.nsx_doEncode($p); $tPST = (!empty($_POST))?$_POST:'';
30
+ $_POST['pnBoard'] = $options['pnBoard']; $_POST['u'] = $options['uName']; $_POST['p'] = $p; $_POST['ii'] = $ii;
31
+ $opNm = 'nxs_snap_pn_'.sha1('nxs_snap_pn'.$options['uName'].$options['uPass']); $opVal = nxs_getOption($opNm); if (empty($opVal)) { $ntw[$nt][$ii]=$options; $opVal = $this->getListOfPNBoards($ntw); }
32
+ if (!empty($opVal) & !is_array($opVal)) $options['uMsg'] = $opVal; else { if (!empty($opVal) & is_array($opVal)) $options = array_merge($options, $opVal); } $_POST = $tPST;
33
+ } return $options;
34
+ }
35
+
36
+ function accTab($ii, $options, $isNew=false){ $ntInfo = $this->ntInfo; $nt = $ntInfo['lcode']; $this->elemUserPass($ii, $options['uName'], $options['uPass']); $options = $this->getMergeOptInfo($options, $ii); ?>
 
 
 
 
 
 
 
 
 
 
37
 
38
+ <br/ ><div style="width:100%;"><b><?php _e('Board', 'nxs_snap'); ?></b>&nbsp;(<?php _e('Please select the board to post to', 'nxs_snap'); ?>)</div>
39
+ <div id="nxsPNInfoDiv<?php echo $ii; ?>">
40
+ <div style="width:100%;">
41
+ <div>
42
+ <select id="pnBoard<?php echo $ii; ?>" onchange="nxs_pnBoardChange('<?php echo $ii;?>',jQuery(this));" name="pn[<?php echo $ii;?>][pnBoard]">
43
+ <?php $pgi = !empty($options['pnBoardsList'])?$options['pnBoardsList']:'';
44
+ echo (!empty($pgi) && stripos($pgi,$options['pnBoard'])===false)?'<option selected="selected" value="'.$options['pnBoard'].'">'.$options['pnBoard'].'</option>':'';
45
+ if (!empty($options['pnBoard'])) { $pgi = str_ireplace('selected="selected" ','',$pgi); $pgi = str_ireplace('value="'.$options['pnBoard'].'"','selected="selected" value="'.$options['pnBoard'].'"',$pgi); }
46
+ else echo '<option value="">None(Click refresh icon to retrieve your boards)</option>';
47
+ echo $pgi;
48
+ ?>
49
+ </select><div id="nxsPNInfoDivBlock<?php echo $ii; ?>" style="display: inline-block;"> <input type="text" style="display: none;" id="pnBRDIDCst<?php echo $ii; ?>" value="<?php echo $options['pnBoard']; ?>" class="nxs_pnBRDIDcst" data-tid="pnBoard<?php echo $ii; ?>" />
50
+ <div style="display: inline-block;"><a onclick="nxs_pnGetBoards(<?php echo $ii;?>, 1); jQuery(this).blur(); return false;" href="#"><img id="<?php echo $nt.$ii;?>rfrshImg" style="vertical-align: middle;" src='<?php echo NXS_PLURL; ?>img/refresh16.png' /></a></div></div> <img id="<?php echo $nt.$ii;?>ldImg" style="display: none;vertical-align: middle;" src='<?php echo NXS_PLURL; ?>img/ajax-loader-sm.gif' />
51
+ </div>
52
+ </div>
53
+ <div id="nxsPNMsgDiv<?php echo $ii; ?>"><?php if (!empty($options['uMsg'])) echo $options['uMsg']; ?><?php if ($isNew) { ?><?php _e('Please enter your login/password to see the list of your boards', 'nxs_snap'); ?><?php } ?></div>
54
+ </div>
55
+ <script type="text/javascript">
56
+ jQuery('#apPNUName<?php echo $ii; ?>').change(function() { var u = jQuery(this).val(); var p = jQuery('#apPNPass<?php echo $ii; ?>').val(); if( u!='' && p!='' ) { nxs_pnGetBoards(<?php echo $ii; ?>,0); } });
57
+ jQuery('#apPNPass<?php echo $ii; ?>').change(function() { var u = jQuery('#apPNUName<?php echo $ii; ?>').val(); var p = jQuery(this).val(); if( u!='' && p!='' ) { nxs_pnGetBoards(<?php echo $ii; ?>,0); } });
58
+ </script>
59
+
60
+ <br/><strong><?php _e('Clickthrough URL', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong>
61
+ <div style="margin-bottom: 20px;margin-top: 5px;">
62
+ <input type="radio" name="pn[<?php echo $ii; ?>][cImgURL]" value="R" <?php if ( empty($options['cImgURL']) || $options['cImgURL'] == 'R') echo 'checked="checked"'; ?> /><?php _e('Regular Post URL', 'social-networks-auto-poster-facebook-twitter-g'); ?>&nbsp;&nbsp;
63
+ <!-- <input type="radio" name="pn[<?php echo $ii; ?>][cImgURL]" value="S" <?php if (!empty($options['cImgURL']) && $options['cImgURL'] == 'S') echo 'checked="checked"'; ?> /> Shortened Post URL&nbsp;&nbsp; -->
64
+ <input type="radio" name="pn[<?php echo $ii; ?>][cImgURL]" value="N" <?php if (!empty($options['cImgURL']) && $options['cImgURL'] == 'N') echo 'checked="checked"'; ?> /><?php _e('No Clickthrough URL', 'social-networks-auto-poster-facebook-twitter-g'); ?>&nbsp;&nbsp;</div>
65
 
66
+ <div style="width:100%;"><strong><?php _e('URL of the Default Image to Pin', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong>
67
+ <div style="font-size: 11px; margin: 0px;"><?php _e('If your post does not have any images this will be used instead.', 'social-networks-auto-poster-facebook-twitter-g'); ?></div>
68
+ </div><input style="width:400px;" name="pn[<?php echo $ii; ?>][defImg]" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['defImg'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />
69
+ <br/><br/>
70
+
71
+ <div style="margin-bottom: 5px; margin-left: 0px; "><input value="1" id="isAttachVid" type="checkbox" name="pn[<?php echo $ii; ?>][isAttachVid]" <?php if (isset($options['isAttachVid']) && (int)$options['isAttachVid'] == 1) echo "checked"; ?> /> <strong><?php _e('If post has a video use it instead of image.', 'social-networks-auto-poster-facebook-twitter-g'); ?></strong><br/><i><?php _e('Video will be pinned instead of featured image. Only Youtube is supported at this time.', 'social-networks-auto-poster-facebook-twitter-g'); ?></i>
72
+ <br/><br/></div>
73
+ <?php $this->elemMsgFormat($ii,'Post Text Format','msgFormat',$options['msgFormat']);?><br/ ><?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  }
75
+ function advTab($ii, $options){ $this->showProxies($this->ntInfo['lcode'], $ii, $options); }
76
  //#### Set Unit Settings from POST
77
+ function setNTSettings($post, $options){
78
  foreach ($post as $ii => $pval){
79
+ if (!empty($pval['uPass']) && !empty($pval['uPass'])){ if (!isset($options[$ii])) $options[$ii] = array(); $options[$ii] = $this->saveCommonNTSettings($pval,$options[$ii]);
 
 
 
 
 
 
 
 
80
 
81
+ if (isset($pval['cImgURL'])) $options[$ii]['cImgURL'] = trim($pval['cImgURL']);
82
+ if (isset($pval['pnBoard'])) $options[$ii]['pnBoard'] = trim($pval['pnBoard']);
83
+ if (isset($pval['isAttachVid'])) $options[$ii]['isAttachVid'] = trim($pval['isAttachVid']); else $options[$ii]['isAttachVid'] = '0';
84
+ if (isset($pval['defImg'])) $options[$ii]['defImg'] = trim($pval['defImg']);
85
 
86
+ } elseif ( count($pval)==1 ) if (isset($pval['do'])) $options[$ii]['do'] = $pval['do']; else $options[$ii]['do'] = 0;
 
 
 
 
 
 
 
87
  } return $options;
88
+ }
89
+
90
  //#### Show Post->Edit Meta Box Settings
91
+ function showEdPostNTSettings($ntOpts, $post){ $post_id = $post->ID; $nt = $this->ntInfo['lcode']; $ntU = $this->ntInfo['code'];
92
+ foreach($ntOpts as $ii=>$ntOpt) { $isFin = $this->checkIfSetupFinished($ntOpt); if (!$isFin) continue;
93
+ $pMeta = maybe_unserialize(get_post_meta($post_id, 'snap'.$ntU, true)); if (is_array($pMeta) && !empty($pMeta[$ii])) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
94
+
95
+ if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = ''; if (empty($ntOpt['urlToUse'])) $ntOpt['urlToUse'] = ''; $postType = isset($ntOpt['postType'])?$ntOpt['postType']:'';
96
+ $msgFormat = !empty($ntOpt['msgFormat'])?htmlentities($ntOpt['msgFormat'], ENT_COMPAT, "UTF-8"):''; $msgTFormat = !empty($ntOpt['msgTFormat'])?htmlentities($ntOpt['msgTFormat'], ENT_COMPAT, "UTF-8"):'';
97
+ $imgToUse = $ntOpt['imgToUse']; $urlToUse = $ntOpt['urlToUse']; $ntOpt['ii']=$ii;
98
+
99
+ $this->nxs_tmpltAddPostMeta($post, $ntOpt, $pMeta); ?>
100
+ <tr style="<?php echo !empty($ntOpt['do'])?'display:table-row;':'display:none;'; ?>" class="nxstbldo nxstbldo<?php echo strtoupper($nt).$ii; ?>"><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;">Select Board</th>
101
+ <td><select name="pn[<?php echo $ii; ?>][pnBoard]">
102
+ <?php $ntOpt = $this->getMergeOptInfo($ntOpt, $ii); if (!empty($ntOpt['pnBoardsList'])){
103
+ if ($ntOpt['pnBoard']!='') $gPNBoards = str_replace($ntOpt['pnBoard'].'"', $ntOpt['pnBoard'].'" selected="selected"', str_ireplace('selected="selected" ','', $ntOpt['pnBoardsList'])); echo $gPNBoards;} else { ?>
104
+ <option value=""><?php _e('None(Please go to the settings and retrieve the list of boards)', 'social-networks-auto-poster-facebook-twitter-g'); ?></option>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  <?php } ?>
106
  </select></td>
107
+ </tr>
108
+ <?php $this->elemEdMsgFormat($ii, __('Message Format:', 'social-networks-auto-poster-facebook-twitter-g'),$msgFormat);
109
+ /* ## Select Image & URL ## */ nxs_showImgToUseDlg($nt, $ii, $imgToUse); nxs_showURLToUseDlg($nt, $ii, $urlToUse); $this->nxs_tmpltAddPostMetaEnd($ii);
 
 
 
 
 
 
110
  }
 
 
 
 
 
 
 
 
 
 
111
  }
112
+ //#### Save Meta Tags to the Post
113
+ function adjMetaOpt($optMt, $pMeta){ $optMt = $this->adjMetaOptG($optMt, $pMeta); // prr($optMt);
114
+ if (isset($pMeta['pnBoard']) && $pMeta['pnBoard']!='' && $pMeta['pnBoard']!='0') $optMt['pnBoard'] = $pMeta['pnBoard'];
115
+ return $optMt;
 
 
 
 
116
  }
117
+
118
+ function adjPublishWP(&$options, &$message, $postID){
119
+
120
+ }
121
+ //## PN Specific
122
+ function getListOfPNBoards($networks){ $opVal = array(); $pass = 'g9c1a'.nsx_doEncode($_POST['p']); $opNm = 'nxs_snap_pn_'.sha1('nxs_snap_pn'.$_POST['u'].$pass); $opVal = nxs_getOption($opNm); $ii = $_POST['ii'];
123
+ if (!class_exists("nxsAPI_PN")) { $outMsg = '<b style="color:red;">'.__('API Not Found').'&nbsp;-&nbsp;'.$loginError.'</b>'; if (!empty($_POST['isOut'])) echo $outMsg; return $outMsg; } $nt = new nxsAPI_PN(); $nt->debug = false; // prr($opVal);
124
+ $currPstAs = !empty($_POST['pnBoard'])?$_POST['pnBoard']:(!empty($networks['pn'][$ii])?$networks['pn'][$ii]['pnBoard']:'');
125
+ if (empty($_POST['force']) && !empty($opVal['ck']) && !empty($opVal['pnBoardsList']) ) $pgs = $opVal['pnBoardsList']; else { if (!empty($opVal['ck'])) $nt->ck = $opVal['ck']; $loginError=$nt->connect($_POST['u'],$_POST['p']);// var_dump($loginError);
126
+ if (!$loginError){ $opVal['ck'] = $nt->ck; $pgs = $nt->getBoards($currPstAs); }
127
+ else { $outMsg = '<b style="color:red;">'.__('Login Problem').'&nbsp;-&nbsp;'.$loginError.'</b>'; if (!empty($_POST['isOut'])) echo $outMsg; return $outMsg; }
128
+ } $pgCust = (!empty($pgs) && !empty($currPstAs) && stripos($pgs,$currPstAs)===false)?'<option selected="selected" value="'.$currPstAs.'">'.$currPstAs.'</option>':'';
129
+ if (!empty($_POST['isOut'])) echo (stripos($pgs, 'No Boards Found')===false?$pgCust:'').$pgs; // .'<option style="color:#BD5200" value="a">'.__('...enter the SubReddit ID').'</option>';
130
+ $opVal['pnBoardsList'] = $pgs; nxs_saveOption($opNm, $opVal); return $opVal;
131
+ }
132
+
133
+ }}
134
 
135
+ if (!function_exists("nxs_doPublishToPN")) { function nxs_doPublishToPN($postID, $options){ if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
136
+ $cl = new nxs_snapClassPN(); $cl->nt[$options['ii']] = $options; return $cl->publishWP($options['ii'], $postID);
137
+ }}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
  ?>
inc-cl/rd.api.php CHANGED
@@ -1,25 +1,6 @@
1
  <?php
2
- //## NextScripts Twitter Connection Class
3
 
4
- /*
5
- 1. Options
6
-
7
- nName - Nickname of the account [Optional] (Presentation purposes only - No affect on functionality)
8
- rdUName - Reddit User Name
9
- rdPass - Reddit User Passord
10
- rdSubReddit - Name of the Sub-Reddit
11
- postType - A or T - "Attached link" or "Text"
12
-
13
- rdTitleFormat
14
- rdTextFormat
15
-
16
- 2. Post Info
17
-
18
- url
19
- title - [up to 300 characters long] - title of the submission
20
- text
21
-
22
- */
23
  $nxs_snapAPINts[] = array('code'=>'RD', 'lcode'=>'rd', 'name'=>'Reddit');
24
 
25
  if (!class_exists("nxs_class_SNAP_RD")) { class nxs_class_SNAP_RD {
@@ -34,34 +15,20 @@ if (!class_exists("nxs_class_SNAP_RD")) { class nxs_class_SNAP_RD {
34
  function doPostToNT($options, $message){ global $nxs_urlLen; $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>'');
35
  //## Check settings
36
  if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
37
- if (!isset($options['rdUName']) || trim($options['rdUName'])=='' || !isset($options['rdPass']) || trim($options['rdPass'])=='') { $badOut['Error'] = 'No username/password Found'; return $badOut; }
 
 
38
  //## Format Post
39
- if (!empty($message['pTitle'])) $title = $message['pTitle']; else $title = nxs_doFormatMsg($options['rdTitleFormat'], $message); $title = nsTrnc($title, 300);
40
- if (!empty($message['pText'])) $text = $message['pText']; else $text = nxs_doFormatMsg($options['rdTextFormat'], $message);
41
- //## Make Post
42
- $pass = substr($options['rdPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['rdPass'], 5)):$options['rdPass']; $hdrsArr = '';
43
- $loginInfo = doConnectToRD($options['rdUName'], $pass); if (!is_array($loginInfo)) { $badOut['Error'] = print_r($loginInfo, true)." - ERROR"; return $badOut; }
44
- $mh = $loginInfo['mh']; $ck = $loginInfo['ck']; $post = array('uh'=>$mh, 'sr'=>$options['rdSubReddit'], 'title'=>$title, 'save'=>true);
45
- if ($options['postType']=='A') { $post['url'] = $message['url']; $post['kind']='link'; $retNum = 16; } else { $post['text'] = $text; $post['kind']='self'; $retNum = 10; }
46
- $url = "http://www.reddit.com/api/submit"; $postParams = array( 'method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'extension'=>'json', 'headers' => $hdrsArr, 'body' => $post, 'cookies' => $ck);
47
- $response = wp_remote_post($url, $postParams); // prr($postParams); prr($response);
48
- if (is_wp_error($response)) { $badOut['Error'] = print_r($response, true)." - ERROR"; return $badOut; }
49
- $response = json_decode($response['body'], true); $rdNewPostID = 'http://www.reddit.com'; // prr($response);
50
-
51
- if (!isset($response['jquery']) || !is_array($response['jquery'])) { $badOut['Error'] = print_r($response, true)." - ERROR"; return $badOut; }
52
- $r = $response['jquery']; if (is_array($r[$retNum][3]) && count($r[$retNum][3])>0 && stripos($r[$retNum][3][0], 'http://')!==false) $rdNewPostID = $r[$retNum][3][0];
53
- if (isset($r[18]) && is_array($r[18][3]) && count($r[18][3])>0 && stripos($r[18][3][0], 'error.BAD_CAPTCHA')!==false ) { $badOut['Error'] = "ERROR: Post Rejected. Reddit thinks that you don't have rights to post here"; return $badOut; }
54
- if (isset($r[18]) && is_array($r[18][3]) && count($r[18][3])>0 && stripos($r[18][3][0], 'error')!==false ) { $badOut['Error'] = "ERROR: ".$r[18][3][0]; return $badOut; }
55
- if (is_array($r[$retNum][3]) && count($r[$retNum][3])>0 && stripos($r[$retNum][3][0], 'http://')===false) { $badOut['Error'] = print_r($r[$retNum][3][0], true)." - ERROR"; return $badOut; }
56
- if (isset($r[18]) && is_array($r[18][3]) && count($r[18][3])>0 && stripos($r[18][3][0], 'already been submitted')!==false ) $rdNewPostID .= str_ireplace('?already_submitted=true', '', $r[10][3][0]);
57
- // echo "ID:".$rdNewPostID;
58
- if ($rdNewPostID!='http://www.reddit.com') {
59
- return array('postID'=>$rdNewPostID, 'isPosted'=>1, 'postURL'=>$rdNewPostID, 'pDate'=>date('Y-m-d H:i:s'));
60
- } else { $badOut['Error'] .= print_r($tmhOAuth->response['response'], true)." MSG:".print_r($msg, true);
61
- return $badOut;
62
- }
63
- return $badOut;
64
- }
65
-
66
  }}
67
  ?>
1
  <?php
2
+ //## NextScripts Reddit Connection Class
3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  $nxs_snapAPINts[] = array('code'=>'RD', 'lcode'=>'rd', 'name'=>'Reddit');
5
 
6
  if (!class_exists("nxs_class_SNAP_RD")) { class nxs_class_SNAP_RD {
15
  function doPostToNT($options, $message){ global $nxs_urlLen; $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>'');
16
  //## Check settings
17
  if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
18
+ if (!isset($options['uName']) || trim($options['uName'])=='' || !isset($options['uPass']) || trim($options['uPass'])=='') { $badOut['Error'] = 'No username/password Found'; return $badOut; }
19
+ //## Get Saved Login Info
20
+ if (function_exists('nxs_getOption')) { $opVal = array(); $opNm = 'nxs_snap_rd_'.sha1('nxs_snap_rd'.$options['uName'].$options['uPass']); $opVal = nxs_getOption($opNm); if (!empty($opVal) & is_array($opVal)) $options = array_merge($options, $opVal); }
21
  //## Format Post
22
+ if (!empty($message['pText'])) $text = $message['pText']; else $text = nxs_doFormatMsg($options['msgFormat'], $message);
23
+ if (!empty($message['pTitle'])) $title = $message['pTitle']; else $title = nxs_doFormatMsg($options['msgTFormat'], $message); $title = nsTrnc($title, 300);
24
+ //## Make Post
25
+ $pass = (substr($options['uPass'], 0, 5)=='n5g9a'||substr($options['uPass'], 0, 5)=='g9c1a'||substr($options['uPass'], 0, 5)=='b4d7s')?nsx_doDecode(substr($options['uPass'], 5)):$options['uPass'];
26
+ $nt = new nxsAPI_RD(); $nt->debug = false; if (!empty($options['ck'])) $nt->ck = $options['ck']; $loginErr = $nt->connect($options['uName'], $pass);
27
+ if (!$loginErr) { $ret = $nt->post($text, $title, $options['rdSubReddit'], $options['postType']=='A'?$message['url']:'');
28
+ //## Save Login Info
29
+ if (function_exists('nxs_saveOption')) { if (empty($opVal['ck'])) $opVal['ck'] = ''; if (is_array($ret) && !empty($ret['isPosted']) && $ret['isPosted']=='1' && $opVal['ck'] != $nt->ck) { $opVal['ck'] = $nt->ck; nxs_saveOption($opNm, $opVal); } }
30
+ } else { $badOut['Error'] .= 'Something went wrong - '.print_r($loginErr, true); $ret = $badOut; }
31
+ return $ret;
32
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  }}
34
  ?>
inc-cl/rd.php CHANGED
@@ -1,265 +1,126 @@
1
  <?php
2
  //## NextScripts Reddit Connection Class
3
- $nxs_snapAvNts[] = array('code'=>'RD', 'lcode'=>'rd', 'name'=>'Reddit');
4
 
5
- if (!class_exists("nxs_snapClassRD")) { class nxs_snapClassRD {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  //#### Show Common Settings
7
- function showGenNTSettings($ntOpts){ global $nxs_plurl; $ntInfo = array('code'=>'RD', 'lcode'=>'rd', 'name'=>'Reddit', 'defNName'=>'rdUName', 'tstReq' => false); ?>
8
- <div class="nxs_box">
9
- <div class="nxs_box_header">
10
- <div class="nsx_iconedTitle" style="margin-bottom:1px;background-image:url(<?php echo $nxs_plurl;?>img/<?php echo $ntInfo['lcode']; ?>16.png);"><?php echo $ntInfo['name']; ?>
11
- <?php $cbo = count($ntOpts); ?>
12
- <?php if ($cbo>1){ ?><div class="nsBigText"><?php echo "(".($cbo=='0'?'No':$cbo)." "; _e('accounts', 'social-networks-auto-poster-facebook-twitter-g'); echo ")"; ?></div><?php } ?>
13
- </div>
14
- </div>
15
- <div class="nxs_box_inside">
16
- <?php if(!function_exists('doConnectToRD')) {?> Reddit doesn't have a built-in API for automated posts yet. <br/>You need to get a special <a target="_blank" href="http://www.nextscripts.com/reddit-automated-posting">library module</a> to be able to publish your content to Reddit.
17
- <?php } else foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
18
- <p style="margin:0px;margin-left:5px;"> <img id="<?php echo $ntInfo['code'].$indx;?>LoadingImg" style="display: none;" src='<?php echo $nxs_plurl; ?>img/ajax-loader-sm.gif' />
19
- <input value="0" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" type="hidden" />
20
- <?php if ((int)$pbo['do'.$ntInfo['code']] == 1 && isset($pbo['catSel']) && (int)$pbo['catSel'] == 1) { ?> <input type="radio" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" id="rbtn<?php echo $ntInfo['lcode'].$indx; ?>" value="1" checked="checked" onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);" /> <?php } else { ?>
21
- <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1 && $pbo['catSel']!='1') echo "checked"; ?> />
22
- <?php } ?>
23
- <?php if (isset($pbo['catSel']) && (int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
24
- <?php if (isset($pbo['rpstOn']) && (int)$pbo['rpstOn'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popReActive');" onmouseover="nxs_showPopUpInfo('popReActive', event);"><?php echo "*[R]*" ?></span><?php } ?>
25
- <strong><?php _e('Auto-publish to', 'social-networks-auto-poster-facebook-twitter-g'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
26
- &nbsp;&nbsp;<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'social-networks-auto-poster-facebook-twitter-g'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>AG" href="#" onclick="doGetHideNTBlock('<?php echo $ntInfo['code'];?>' , '<?php echo $indx; ?>');return false;">[<?php _e('Show Settings', 'social-networks-auto-poster-facebook-twitter-g'); ?>]</a>&nbsp;&nbsp;
27
- <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'social-networks-auto-poster-facebook-twitter-g'); ?>]</a>
28
- </p><div id="nxsNTSetDiv<?php echo $ntInfo['code'].$indx; ?>"></div><?php //$pbo['ntInfo'] = $ntInfo; $this->showNTSettings($indx, $pbo);
29
- }?>
30
- </div>
31
- </div> <?php
32
- }
33
  //#### Show NEW Settings Page
34
- function showNewNTSettings($mrdo){ $rdo = array('nName'=>'', 'doRD'=>'1', 'rdUName'=>'', 'rdPageID'=>'', 'rdCommID'=>'', 'postType'=>'A', 'rdPass'=>''); $rdo['ntInfo']= array('lcode'=>'rd'); $this->showNTSettings($mrdo, $rdo, true);}
35
- //#### Show Unit Settings
36
- function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl; $nt = $options['ntInfo']['lcode']; $ntU = strtoupper($nt);
37
- 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'] = '';
38
- if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; if (!isset($options['rdSubReddit'])) $options['rdSubReddit'] = ''; ?>
39
- <div id="doRD<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>"> <input type="hidden" name="apDoSRD<?php echo $ii; ?>" value="0" id="apDoSRD<?php echo $ii; ?>" />
40
-
41
- <?php if(!function_exists('doConnectToRD')) {
42
- nxs_show_noLibWrn('Reddit API Library module NOT found.<br/><br/><span style="color:black;">Reddit does not have a free native API for automated posts yet.</span><br/><br/><span style="font-size: 12px;color:black;">You need to have a special API Library Module to be able to publish your content to Reddit.</span>'); echo "</div>"; return; }; ?>
43
-
44
- <div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/rd16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-reddit-social-networks-auto-poster-wordpress/"><?php $nType="Reddit"; printf( __( 'Detailed %s Installation/Configuration Instructions', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?></a></div>
45
-
46
- <div style="width:100%;"><strong><?php _e('Account Nickname', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'social-networks-auto-poster-facebook-twitter-g'); ?></i> </div><input name="rd[<?php echo $ii; ?>][nName]" id="rdnName<?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")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /><br/>
47
- <?php echo nxs_addQTranslSel('rd', $ii, $options['qTLng']); ?>
48
-
49
-
50
- <br/>
51
- <ul class="nsx_tabs">
52
- <li><a href="#nsx<?php echo $nt.$ii ?>_tab1"><?php _e('Account Info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li>
53
- <?php if (!$isNew) { ?> <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li> <?php } ?>
54
- </ul>
55
- <div class="nsx_tab_container"><?php /* ######################## Account Tab ####################### */ ?>
56
- <div id="nsx<?php echo $nt.$ii ?>_tab1" class="nsx_tab_content" style="background-image: url(<?php echo $nxs_plurl; ?>img/<?php echo $nt; ?>-bg.png); background-repeat: no-repeat; background-position:90% 10%;">
57
-
58
-
59
- <div style="width:100%;"><strong>Reddit Username:</strong> </div><input name="rd[<?php echo $ii; ?>][uName]" id="apRDUName<?php echo $ii; ?>" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['rdUName'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />
60
- <div style="width:100%;"><strong>Reddit Password:</strong> </div><input autocomplete="false" readonly onfocus="this.removeAttribute('readonly');" name="rd[<?php echo $ii; ?>][uPass]" id="apRDPass<?php echo $ii; ?>" type="password" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities(substr($options['rdPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['rdPass'], 5)):$options['rdPass'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /> <br/>
61
-
62
- <div style="width:100%;"><strong>Subreddit ID:</strong>
63
- Please <a href="#" onclick="nxs_getBrdsOrCats(jQuery('<?php if ($isNew) echo "#nsx_addNT "; ?>#apRDUName<?php echo $ii; ?>').val(),jQuery('<?php if ($isNew) echo "#nsx_addNT "; ?>#apRDPass<?php echo $ii; ?>').val(), 'rd' , '<?php echo $ii; ?>', 'rdSubReddit'); return false;">click here to retrieve your subreddits</a>
64
- </div>
65
- <img id="rdLoadingImg<?php echo $ii; ?>" style="display: none;" src='<?php echo $nxs_plurl; ?>img/ajax-loader-sm.gif' />
66
- <select name="rd[<?php echo $ii; ?>][rdSubReddit]" id="rdSubReddit<?php echo $ii; ?>">
67
- <?php if ($options['rdSubRedditsList']!=''){ $gBoards = $options['rdSubRedditsList']; if ( base64_encode(base64_decode($gBoards)) === $gBoards) $gBoards = base64_decode($gBoards);
68
- if ($options['rdSubReddit']!='') $gBoards = str_replace($options['rdSubReddit'].'"', $options['rdSubReddit'].'" selected="selected"', $gBoards); echo $gBoards;} else { ?>
69
- <option value="0">None(Click above to retrieve your subreddits)</option>
70
- <?php } ?>
71
- </select>
72
-
73
- <br/><br/>
74
- <?php /* <input name="rd[<?php echo $ii; ?>][rdSubReddit]" id="apRDPage" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['rdSubReddit'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /> */ ?>
75
- <i style="color: #580000;">Please do not try to post to subredits that you do not own. Reddit is very serious about it's policy that prohibits sharing your own links. You will loose posting privileges and you account will be <b>banned</b> if you post to public subreddits. </i>
76
  <br/> <br/>
77
 
78
- <div id="altFormat" style="">
79
- <div style="width:100%;"><strong id="altFormatText"><?php _e('Post Title Format', 'social-networks-auto-poster-facebook-twitter-g'); ?></strong> (<a href="#" id="rdTitleFormat<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('rdTitleFormat<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>)</div>
80
- <input name="rd[<?php echo $ii; ?>][rdTitleFormat]" id="rdTitleFormat<?php echo $ii; ?>" style="width: 50%;" value="<?php if ($isNew) echo "%TITLE%"; else _e(apply_filters('format_to_edit', htmlentities($options['rdTitleFormat'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g'); ?>" onfocus="mxs_showFrmtInfo('rdTitleFormat<?php echo $ii; ?>');" /><?php nxs_doShowHint("rdTitleFormat".$ii); ?>
81
- </div><br/>
82
-
83
- <div style="width:100%;"><strong id="altFormatText">Post Type:</strong></div>
84
  <div style="margin-left: 10px;">
85
- <input type="radio" name="rd[<?php echo $ii; ?>][postType]" value="A" <?php if ( !isset($options['postType']) || $options['postType'] == '' || $options['postType'] == 'A') echo 'checked="checked"'; ?> /> <?php _e('Link Post', 'social-networks-auto-poster-facebook-twitter-g'); ?>
86
  <br/>
87
- <input type="radio" name="rd[<?php echo $ii; ?>][postType]" value="T" <?php if ($options['postType'] == 'T') echo 'checked="checked"'; ?> /> <?php _e('Text Post', 'social-networks-auto-poster-facebook-twitter-g'); ?> - <i><?php _e('set the text format below', 'social-networks-auto-poster-facebook-twitter-g'); ?></i>
88
- </div><br/>
89
-
90
- <div id="altFormat" style="margin-left: 20px;">
91
- <div style="width:100%;"><strong id="altFormatText"><?php _e('Text Format', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> (<a href="#" id="rdTextFormat<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('rdTextFormat<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>)
92
- </div>
93
-
94
- <textarea cols="150" rows="3" id="rd<?php echo $ii; ?>SNAPformat" name="rd[<?php echo $ii; ?>][rdTextFormat]" style="width:51%;max-width: 650px;" onfocus="jQuery('#rd<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('apRDMsgFrmt<?php echo $ii; ?>');"><?php if ($isNew) _e("New post (%TITLE%) has been published on %SITENAME%", 'social-networks-auto-poster-facebook-twitter-g'); else _e(apply_filters('format_to_edit', htmlentities($options['rdTextFormat'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g'); ?></textarea>
95
-
96
- <?php nxs_doShowHint("rdTextFormat".$ii); ?>
97
- </div><br/>
98
-
99
-
100
- <?php if ($isNew) { ?> <input type="hidden" name="rd[<?php echo $ii; ?>][apDoRD]" value="1" id="apDoNewRD<?php echo $ii; ?>" /> <?php } ?>
101
- <?php if ($options['rdPass']!='') { ?>
102
-
103
- <b><?php _e('Test your settings', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('RD', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?></a> <?php }
104
- ?>
105
- </div>
106
-
107
- <?php /* ######################## Advanced Tab ####################### */ ?>
108
- <?php if (!$isNew) { ?> <div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content">
109
-
110
- <?php nxs_showCatTagsCTFilters($nt, $ii, $options);
111
- nxs_addPostingDelaySelV3($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']);
112
- nxs_showRepostSettings($nt, $ii, $options); ?>
113
-
114
-
115
- </div> <?php } ?> <?php /* #### End of Tab #### */ ?>
116
- </div><br/> <?php /* #### End of Tabs #### */ ?>
117
-
118
- <div class="submitX nxclear" style="padding-bottom: 0px;"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'social-networks-auto-poster-facebook-twitter-g') ?>" /></div>
119
-
120
- </div><?php
121
  }
 
122
  //#### Set Unit Settings from POST
123
- function setNTSettings($post, $options){ $code = 'RD'; $lcode = 'rd';
124
- foreach ($post as $ii => $pval){
125
- if (!empty($pval['uName']) && !empty($pval['uPass'])){ if (!isset($options[$ii])) $options[$ii] = array();
126
- if (isset($pval['uName'])) $options[$ii]['rdUName'] = trim($pval['uName']);
127
- if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']);
128
- if (isset($pval['uPass'])) $options[$ii]['rdPass'] = 'n5g9a'.nsx_doEncode($pval['uPass']); else $options[$ii]['rdPass'] = '';
129
-
130
- if (empty($options[$ii]['rdSubRedditsList'])) { $pass = substr($options[$ii]['rdPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options[$ii]['rdPass'], 5)):$options[$ii]['rdPass'];
131
- $loginInfo = doConnectToRD($options[$ii]['rdUName'], $pass); if (is_array($loginInfo)) {
132
- $options[$ii]['rdSubRedditsList'] = doGetSubredditsFromRD();
133
- }
134
- }
135
-
136
- if (isset($pval['rdSubReddit'])) $options[$ii]['rdSubReddit'] = trim($pval['rdSubReddit']);
137
-
138
- if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']); else $options[$ii]['catSel'] = 0;
139
- if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
140
-
141
- if (isset($pval['postType'])) $options[$ii]['postType'] = $pval['postType'];
142
- if (isset($pval['rdTitleFormat'])) $options[$ii]['rdTitleFormat'] = trim($pval['rdTitleFormat']);
143
- if (isset($pval['rdTextFormat'])) $options[$ii]['rdTextFormat'] = trim($pval['rdTextFormat']);
144
 
145
- if (isset($pval['apDoRD'])) $options[$ii]['doRD'] = $pval['apDoRD']; else $options[$ii]['doRD'] = 0;
146
 
147
- $options[$ii] = nxs_adjRpst($options[$ii], $pval);
148
-
149
- if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']);
150
- if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
151
- if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
152
- } elseif ( count($pval)==1 ) if (isset($pval['apDo'.$code])) $options[$ii]['do'.$code] = $pval['apDo'.$code]; else $options[$ii]['do'.$code] = 0;
153
  } return $options;
154
- }
 
155
  //#### Show Post->Edit Meta Box Settings
156
- function showEdPostNTSettings($ntOpts, $post){global $nxs_plurl; $post_id = $post->ID; $nt = 'rd'; $ntU = 'RD';
157
- foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapRD', true)); if (!empty($pMeta) && is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
158
- $doRD = $ntOpt['doRD'] && (is_array($pMeta) || $ntOpt['catSel']!='1');
159
- $isAvailRD = $ntOpt['rdUName']!='' && $ntOpt['rdPass']!=''; $rdMsgFormat = htmlentities($ntOpt['rdTextFormat'], ENT_COMPAT, "UTF-8"); $rdMsgTFormat = htmlentities($ntOpt['rdTitleFormat'], ENT_COMPAT, "UTF-8");
160
- $rdPostType = $ntOpt['postType'];
161
- ?>
162
- <tr><th style="text-align:left;" colspan="2">
163
- <?php if ($ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='') { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
164
- <?php if (!empty($ntOpt['tagsSelX'])) { ?> <input type="hidden" class="nxs_TG" id="nxs_TG_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $ntOpt['tagsSelX']; ?>" /> <?php } ?>
165
- <?php if ($isAvailRD) { ?><input class="nxsGrpDoChb" value="1" id="doRD<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="rd[<?php echo $ii; ?>][doRD]" <?php if ((int)$doRD == 1) echo 'checked="checked" title="def"'; ?> />
166
- <?php if ($post->post_status == "publish") { ?> <input type="hidden" name="rd[<?php echo $ii; ?>][doRD]" value="<?php echo $doRD;?>"> <?php } ?> <?php } ?>
167
-
168
- <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/rd16.png);">Reddit - <?php _e('publish to', 'social-networks-auto-poster-facebook-twitter-g') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
169
- if ($post->post_status == "publish" && $isAvailRD) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToRD_repostButton" id="rePostToRD_button" value="<?php _e('Repost to Reddit', 'social-networks-auto-poster-facebook-twitter-g') ?>" />
170
- <?php } ?>
171
-
172
- <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
173
-
174
- ?> <span id="pstdRD<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
175
- <a style="font-size: 10px;" href="<?php echo $pMeta[$ii]['pgID']; ?>" target="_blank"><?php $nType="Reddit"; printf( __( 'Posted on', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
176
- </span><?php } ?>
177
-
178
- </td></tr>
179
-
180
- <?php if (!$isAvailRD) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your Reddit Account to AutoPost to Reddit</b></td></tr>
181
- <?php } else { if ($post->post_status != "publish" && function_exists('nxs_doSMAS5') ) { $ntOpt['postTime'] = get_post_time('U', false, $post_id); nxs_doSMAS5($nt, $ii, $ntOpt); } ?>
182
-
183
- <?php if ($ntOpt['rpstOn']=='1') { ?>
184
-
185
- <tr id="altFormat1" style=""><th scope="row" class="nxsTHRow">
186
- <input value="0" type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]"/><input value="nxsi<?php echo $ii; ?>rd" type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]" <?php if (!empty($ntOpt['rpstPostIncl'])) echo "checked"; ?> />
187
- </th>
188
- <td> <?php _e('Include in "Auto-Reposting" to this network.', 'social-networks-auto-poster-facebook-twitter-g') ?>
189
- </td></tr> <?php } ?>
190
-
191
-
192
- <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Title Format:', 'social-networks-auto-poster-facebook-twitter-g') ?></th>
193
- <td><input value="<?php echo $rdMsgTFormat ?>" type="text" name="rd[<?php echo $ii; ?>][SNAPformatT]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apRDMsgTFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apRDMsgTFrmt".$ii, '', '58'); ?></td></tr>
194
-
195
- <tr><th scope="row" style="text-align:right; width:150px; vertical-align:top; padding-top: 0px; padding-right:10px;"> <?php _e('Post Type:', 'social-networks-auto-poster-facebook-twitter-g') ?> </th><td>
196
- <input type="radio" name="rd[<?php echo $ii; ?>][postType]" value="A" <?php if ( !isset($rdPostType) || $rdPostType == '' || $rdPostType == 'A') echo 'checked="checked"'; ?> /><?php _e('Link Post', 'social-networks-auto-poster-facebook-twitter-g') ?>
197
  <br/>
198
- <input type="radio" name="rd[<?php echo $ii; ?>][postType]" value="T" <?php if ($rdPostType == 'T') echo 'checked="checked"'; ?> /> <?php _e('Text Post', 'social-networks-auto-poster-facebook-twitter-g') ?><br/>
199
  </td></tr>
200
-
201
- <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Text Format:', 'social-networks-auto-poster-facebook-twitter-g') ?></th><td>
202
-
203
- <textarea cols="150" rows="1" id="rd<?php echo $ii; ?>SNAPformat" name="rd[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('#rd<?php echo $ii; ?>SNAPformat').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apRDMsgFrmt<?php echo $ii; ?>');"><?php echo $rdMsgFormat ?></textarea>
204
-
205
- </td></tr>
206
- <?php }
207
  }
208
- }
209
  //#### Save Meta Tags to the Post
210
- function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
211
- if (isset($pMeta['SNAPformat'])) $optMt['rdTextFormat'] = $pMeta['SNAPformat']; if (isset($pMeta['SNAPformatT'])) $optMt['rdTitleFormat'] = $pMeta['SNAPformatT'];
212
- if (isset($pMeta['imgToUse'])) $optMt['imgToUse'] = $pMeta['imgToUse'];
213
- if (isset($pMeta['timeToRun'])) $optMt['timeToRun'] = $pMeta['timeToRun']; if (isset($pMeta['rpstPostIncl'])) $optMt['rpstPostIncl'] = $pMeta['rpstPostIncl'];
214
- if (isset($pMeta['postType'])) $optMt['postType'] = $pMeta['postType'];
215
- if (isset($pMeta['doRD'])) $optMt['doRD'] = $pMeta['doRD'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doRD'] = 0; }
216
- if (isset($pMeta['SNAPincludeRD']) && $pMeta['SNAPincludeRD'] == '1' ) $optMt['doRD'] = 1;
217
  return $optMt;
218
- }
219
- }}
220
- if (!function_exists("nxs_rePostToRD_ajax")) {
221
- function nxs_rePostToRD_ajax() { check_ajax_referer('nxsSsPageWPN'); $postID = $_POST['id']; global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
222
- foreach ($options['rd'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj'; //if ($two['rdPageID'].$two['rdUName']==$_POST['nid']) {
223
- $rdpo = get_post_meta($postID, 'snapRD', true); $rdpo = maybe_unserialize($rdpo);// prr($rdpo);
224
- if (is_array($rdpo) && isset($rdpo[$ii]) && is_array($rdpo[$ii])){ $ntClInst = new nxs_snapClassRD(); $two = $ntClInst->adjMetaOpt($two, $rdpo[$ii]); }
225
- $result = nxs_doPublishToRD($postID, $two); if ($result == 200) die("Successfully sent your post to Reddit."); else die($result);
226
- }
227
  }
228
- }
229
- if (!function_exists("nxs_doPublishToRD")) { //## Second Function to Post to RD
230
- function nxs_doPublishToRD($postID, $options){ $ntCd = 'RD'; $ntCdL = 'rd'; $ntNm = 'Reddit'; if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
231
- $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
232
- $logNT = '<span style="color:#800000">Reddit</span> - '.$options['nName'];
233
- $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
234
- $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'POSTID'=>$postID, 'ACCNAME'=>$options['nName']));
235
- if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
236
- $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') {
237
- nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'); return;
238
- }
239
- }
240
- $message = array('message'=>'', 'link'=>'', 'imageURL'=>'', 'videoURL'=>'');
241
-
242
- if ($postID=='0') { echo "Testing ... <br/><br/>"; $message['description'] = 'Test Post, Description'; $message['title'] = 'Test Post - Title'; $message['url'] = home_url();
243
- } else { nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1')); $post = get_post($postID); if(!$post) return;
244
- $rdPostType = $options['postType'];
245
- $options['rdTitleFormat'] = nsFormatMessage($options['rdTitleFormat'], $postID); $options['rdTextFormat'] = nsFormatMessage($options['rdTextFormat'], $postID); // prr($msg); echo $postID;
246
- $extInfo = ' | PostID: '.$postID." - ".$post->post_title;
247
- $options = nxs_getURL($options, $postID, $addParams); $urlToGo = $options['urlToUse'];
248
- $message = array('message'=>$options['rdTextFormat'], 'url'=>$urlToGo, 'title'=>$options['rdTitleFormat']);
249
- }
250
- //## Actual Post
251
- $ntToPost = new nxs_class_SNAP_RD(); $ret = $ntToPost->doPostToNT($options, $message); // echo "~~~"; prr($ret); echo "+++";
252
- //## Process Results
253
- if (!is_array($ret) || $ret['isPosted']!='1') { //## Error
254
- if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);
255
- } else { // ## All Good - log it.
256
- if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo _e('OK - Message Posted, please see your '.$logNT.' Page. ', 'social-networks-auto-poster-facebook-twitter-g'); }
257
- else { nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPosted'=>'1', 'pgID'=>$ret['postID'], 'pDate'=>date('Y-m-d H:i:s')));
258
- $extInfo .= ' | <a href="'.$ret['postURL'].'" target="_blank">Post Link</a>'; nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); }
259
- }
260
- //## Return Result
261
- if ($ret['isPosted']=='1') return 200; else return print_r($ret, true);
262
 
263
  }
264
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
265
  ?>
1
  <?php
2
  //## NextScripts Reddit Connection Class
3
+ $nxs_snapAvNts[] = array('code'=>'RD', 'lcode'=>'rd', 'name'=>'Reddit', 'type'=>'Link Sharing/Boormarks', 'ptype'=>'P', 'status'=>'A', 'desc'=>'Autopost to your subreddits');
4
 
5
+ if (!class_exists("nxs_snapClassRD")) { class nxs_snapClassRD extends nxs_snapClassNT {
6
+ var $ntInfo = array('code'=>'RD', 'lcode'=>'rd', 'name'=>'Reddit', 'defNName'=>'uName', 'tstReq' => false, 'instrURL'=>'http://www.nextscripts.com/setup-installation-reddit-social-networks-auto-poster-wordpress/');
7
+
8
+ var $noFuncMsg = 'Reddit doesn\'t have a built-in API for automated posts yet. <br/>You need to get a special <a target="_blank" href="http://www.nextscripts.com/snap-api/">library module</a> to be able to publish your content to Reddit.';
9
+ function checkIfFunc() { return class_exists('nxsAPI_RD'); }
10
+
11
+ function toLatestVer($ntOpts){ if( !empty($ntOpts['v'])) $v = $ntOpts['v']; else $v = 340; $ntOptsOut = ''; switch ($v) {
12
+ case 340: $ntOptsOut = $this->toLatestVerNTGen($ntOpts); $ntOptsOut['do'] = $ntOpts['do'.$this->ntInfo['code']]; $ntOptsOut['nName'] = $ntOpts['nName'];
13
+ $ntOptsOut['msgTFormat'] = $ntOpts['rdTitleFormat']; $ntOptsOut['msgFormat'] = $ntOpts['rdTextFormat']; $ntOptsOut['uName'] = $ntOpts['rdUName']; $ntOptsOut['uPass'] = $ntOpts['rdPass'];
14
+ $ntOptsOut['postType'] = $ntOpts['postType']; $ntOptsOut['rdSubReddit'] = $ntOpts['rdSubReddit'];
15
+ $ntOptsOut['v'] = NXS_SETV;
16
+ break;
17
+ }
18
+ return !empty($ntOptsOut)?$ntOptsOut:$ntOpts;
19
+ }
20
+
21
  //#### Show Common Settings
22
+ function showGenNTSettings($ntOpts){ $this->nt = $ntOpts; $this->showNTGroup(); return; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  //#### Show NEW Settings Page
24
+ function showNewNTSettings($ii){ $defO = array('nName'=>'', 'do'=>'1', 'uName'=>'', 'uPass'=>'', 'postType'=>'', 'rdSubReddit'=>'', 'msgTFormat'=>'%TITLE%', 'msgFormat'=>"%EXCERPT%"); $this->showGNewNTSettings($ii, $defO); }
25
+ //#### Show Unit Settings
26
+ function checkIfSetupFinished($options) { return !empty($options['uPass']); }
27
+ function accTab($ii, $options, $isNew=false){ $ntInfo = $this->ntInfo; $nt = $ntInfo['lcode']; $this->elemUserPass($ii, $options['uName'], $options['uPass']); $p = $options['uPass'];
28
+ if (!empty($p)) { $p = (substr($p, 0, 5)=='n5g9a'||substr($p, 0, 5)=='g9c1a'||substr($p, 0, 5)=='b4d7s')?nsx_doDecode(substr($p, 5)):$p; $options['uPass'] = 'g9c1a'.nsx_doEncode($p); $tPST = (!empty($_POST))?$_POST:'';
29
+ $_POST['rdSR'] = $options['rdSubReddit']; $_POST['u'] = $options['uName']; $_POST['p'] = $p; $_POST['ii'] = $ii;
30
+ $opNm = 'nxs_snap_rd_'.sha1('nxs_snap_rd'.$options['uName'].$options['uPass']); $opVal = nxs_getOption($opNm); if (empty($opVal)) { $ntw[$nt][$ii]=$options; $opVal = $this->getListOfSubReddits($ntw); }
31
+ if (!empty($opVal) & !is_array($opVal)) $options['uMsg'] = $opVal; else { if (!empty($opVal) & is_array($opVal)) $options = array_merge($options, $opVal); } $_POST = $tPST;
32
+ } ?>
33
+
34
+ <br/ ><div style="width:100%;"><b><?php _e('Subreddit ID', 'nxs_snap'); ?></b>&nbsp;(<?php _e('Please select Subreddit', 'nxs_snap'); ?>)</div>
35
+ <div id="nxsRDInfoDiv<?php echo $ii; ?>">
36
+ <div style="width:100%;">
37
+ <div>
38
+ <select id="rdSubReddit<?php echo $ii; ?>" onchange="nxs_rdSRChange('<?php echo $ii;?>',jQuery(this));" name="rd[<?php echo $ii;?>][rdSubReddit]">
39
+ <?php $pgi = !empty($options['rdSubRedditsList'])?$options['rdSubRedditsList']:'';
40
+ echo (!empty($pgi) && stripos($pgi,$options['rdSubReddit'])===false)?'<option selected="selected" value="'.$options['rdSubReddit'].'">'.$options['rdSubReddit'].'</option>':'';
41
+ if (!empty($options['rdSubReddit'])) { $pgi = str_ireplace('selected="selected" ','',$pgi); $pgi = str_ireplace('value="'.$options['rdSubReddit'].'"','selected="selected" value="'.$options['rdSubReddit'].'"',$pgi); }
42
+ else echo '<option value="">None(Click refresh icon to retrieve your subreddits)</option>';
43
+ echo $pgi;
44
+ ?>
45
+ </select><div id="nxsRDInfoDivBlock<?php echo $ii; ?>" style="display: inline-block;"> <input type="text" style="display: none;" id="rdSRIDCst<?php echo $ii; ?>" value="<?php echo $options['rdSubReddit']; ?>" class="nxs_rdSRIDcst" data-tid="rdSubReddit<?php echo $ii; ?>" />
46
+ <div style="display: inline-block;"><a onclick="nxs_rdGetSRs(<?php echo $ii;?>, 1); jQuery(this).blur(); return false;" href="#"><img id="<?php echo $nt.$ii;?>rfrshImg" style="vertical-align: middle;" src='<?php echo NXS_PLURL; ?>img/refresh16.png' /></a></div></div> <img id="<?php echo $nt.$ii;?>ldImg" style="display: none;vertical-align: middle;" src='<?php echo NXS_PLURL; ?>img/ajax-loader-sm.gif' />
47
+ </div>
48
+ </div>
49
+ <div id="nxsRDMsgDiv<?php echo $ii; ?>"><?php if (!empty($options['uMsg'])) echo $options['uMsg']; ?><?php if ($isNew) { ?><?php _e('Please enter your login/password to see the list of your subreddits', 'nxs_snap'); ?><?php } ?></div>
50
+ </div><i style="color: #580000;">Please do not try to post to subredits that you do not own. Reddit is very serious about it's policy that prohibits sharing your own links. You will loose posting privileges and you account will be <b>banned</b> if you post to public subreddits. </i>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  <br/> <br/>
52
 
53
+ <div style="width:100%;"><strong id="altFormatText">Post Type:</strong></div>
 
 
 
 
 
54
  <div style="margin-left: 10px;">
55
+ <input type="radio" name="rd[<?php echo $ii; ?>][postType]" value="A" <?php if ( empty($options['postType']) || $options['postType'] == 'A') echo 'checked="checked"'; ?> /> <?php _e('Link Post', 'social-networks-auto-poster-facebook-twitter-g'); ?>
56
  <br/>
57
+ <input type="radio" name="rd[<?php echo $ii; ?>][postType]" value="T" <?php if (!empty($options['postType']) && $options['postType'] == 'T') echo 'checked="checked"'; ?> /> <?php _e('Text Post', 'social-networks-auto-poster-facebook-twitter-g'); ?> - <i><?php _e('set the text format below', 'social-networks-auto-poster-facebook-twitter-g'); ?></i>
58
+ </div>
59
+
60
+ <script type="text/javascript">
61
+ jQuery('#apRDUName<?php echo $ii; ?>').change(function() { var u = jQuery(this).val(); var p = jQuery('#apRDPass<?php echo $ii; ?>').val(); if( u!='' && p!='' ) { nxs_rdGetSRs(<?php echo $ii; ?>,0); } });
62
+ jQuery('#apRDPass<?php echo $ii; ?>').change(function() { var u = jQuery('#apRDUName<?php echo $ii; ?>').val(); var p = jQuery(this).val(); if( u!='' && p!='' ) { nxs_rdGetSRs(<?php echo $ii; ?>,0); } });
63
+ </script>
64
+
65
+ <?php $this->elemTitleFormat($ii,'Post Title Format','msgTFormat',$options['msgTFormat']);
66
+ $this->elemMsgFormat($ii,'Post Text Format','msgFormat',$options['msgFormat']);?><br/ ><?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  }
68
+ function advTab($ii, $options){}
69
  //#### Set Unit Settings from POST
70
+ function setNTSettings($post, $options){
71
+ foreach ($post as $ii => $pval){
72
+ if (!empty($pval['uPass']) && !empty($pval['uPass'])){ if (!isset($options[$ii])) $options[$ii] = array(); $options[$ii] = $this->saveCommonNTSettings($pval,$options[$ii]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
 
74
+ if (isset($pval['rdSubReddit'])) $options[$ii]['rdSubReddit'] = trim($pval['rdSubReddit']);
75
 
76
+ } elseif ( count($pval)==1 ) if (isset($pval['do'])) $options[$ii]['do'] = $pval['do']; else $options[$ii]['do'] = 0;
 
 
 
 
 
77
  } return $options;
78
+ }
79
+
80
  //#### Show Post->Edit Meta Box Settings
81
+ function showEdPostNTSettings($ntOpts, $post){ $post_id = $post->ID; $nt = $this->ntInfo['lcode']; $ntU = $this->ntInfo['code'];
82
+ foreach($ntOpts as $ii=>$ntOpt) { $isFin = $this->checkIfSetupFinished($ntOpt); if (!$isFin) continue;
83
+ $pMeta = maybe_unserialize(get_post_meta($post_id, 'snap'.$ntU, true)); if (is_array($pMeta) && !empty($pMeta[$ii])) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
84
+
85
+ if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = ''; if (empty($ntOpt['urlToUse'])) $ntOpt['urlToUse'] = ''; $postType = isset($ntOpt['postType'])?$ntOpt['postType']:'';
86
+ $msgFormat = !empty($ntOpt['msgFormat'])?htmlentities($ntOpt['msgFormat'], ENT_COMPAT, "UTF-8"):''; $msgTFormat = !empty($ntOpt['msgTFormat'])?htmlentities($ntOpt['msgTFormat'], ENT_COMPAT, "UTF-8"):'';
87
+ $imgToUse = $ntOpt['imgToUse']; $urlToUse = $ntOpt['urlToUse']; $ntOpt['ii']=$ii;
88
+
89
+ $this->nxs_tmpltAddPostMeta($post, $ntOpt, $pMeta); ?>
90
+ <?php $this->elemEdTitleFormat($ii, __('Title Format:', 'social-networks-auto-poster-facebook-twitter-g'),$msgTFormat); $this->elemEdMsgFormat($ii, __('Message Format:', 'social-networks-auto-poster-facebook-twitter-g'),$msgFormat); ?>
91
+ <tr style="<?php echo !empty($ntOpt['do'])?'display:table-row;':'display:none;'; ?>" class="nxstbldo nxstbldo<?php echo strtoupper($nt).$ii; ?>"><th scope="row" style="text-align:right; width:150px; vertical-align:top; padding-top: 0px; padding-right:10px;"> <?php _e('Post Type:', 'social-networks-auto-poster-facebook-twitter-g') ?> </th><td>
92
+ <input type="radio" name="rd[<?php echo $ii; ?>][postType]" value="A" <?php if ( empty($postType) || $postType == 'A') echo 'checked="checked"'; ?> /><?php _e('Link Post', 'social-networks-auto-poster-facebook-twitter-g') ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  <br/>
94
+ <input type="radio" name="rd[<?php echo $ii; ?>][postType]" value="T" <?php if ($postType == 'T') echo 'checked="checked"'; ?> /> <?php _e('Text Post', 'social-networks-auto-poster-facebook-twitter-g') ?><br/>
95
  </td></tr>
96
+ <?php
97
+
98
+ /* ## Select Image & URL ## */ nxs_showURLToUseDlg($nt, $ii, $urlToUse); $this->nxs_tmpltAddPostMetaEnd($ii);
 
 
 
 
99
  }
100
+ }
101
  //#### Save Meta Tags to the Post
102
+ function adjMetaOpt($optMt, $pMeta){ $optMt = $this->adjMetaOptG($optMt, $pMeta); // prr($optMt);
103
+ //if (!empty($pMeta['dlBoard'])) $optMt['dlBoard'] = $pMeta['dlBoard']; if (!empty($pMeta['dlBoard'])) $optMt['dlBoard'] = $pMeta['dlBoard']; else $optMt['dlBoard'] = 0;
 
 
 
 
 
104
  return $optMt;
 
 
 
 
 
 
 
 
 
105
  }
106
+
107
+ function adjPublishWP(&$options, &$message, $postID){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
 
109
  }
110
+ //## RD Specific
111
+ function getListOfSubReddits($networks){ $opVal = array(); $pass = 'g9c1a'.nsx_doEncode($_POST['p']); $opNm = 'nxs_snap_rd_'.sha1('nxs_snap_rd'.$_POST['u'].$pass); $opVal = nxs_getOption($opNm); $ii = $_POST['ii']; $nt = new nxsAPI_RD(); $nt->debug = false; // prr($opVal);
112
+ $currPstAs = !empty($_POST['rdSR'])?$_POST['rdSR']:(!empty($networks['rd'][$ii])?$networks['rd'][$ii]['rdSubReddit']:'');
113
+ if (empty($_POST['force']) && !empty($opVal['ck']) && !empty($opVal['rdSubRedditsList']) ) $pgs = $opVal['rdSubRedditsList']; else { if (!empty($opVal['ck'])) $nt->ck = $opVal['ck']; $loginError=$nt->connect($_POST['u'],$_POST['p']);// var_dump($loginError);
114
+ if (!$loginError){ $opVal['ck'] = $nt->ck; $nt->getSubReddits($currPstAs); $pgs = $nt->srList; }
115
+ else { $outMsg = '<b style="color:red;">'.__('Login Problem').'&nbsp;-&nbsp;'.$loginError.'</b>'; if (!empty($_POST['isOut'])) echo $outMsg; return $outMsg; }
116
+ } $pgCust = (!empty($pgs) && !empty($currPstAs) && stripos($pgs,$currPstAs)===false)?'<option selected="selected" value="'.$currPstAs.'">'.$currPstAs.'</option>':'';
117
+ if (!empty($_POST['isOut'])) echo $pgCust.$pgs; // .'<option style="color:#BD5200" value="a">'.__('...enter the SubReddit ID').'</option>';
118
+ $opVal['rdSubRedditsList'] = $pgs; nxs_saveOption($opNm, $opVal); return $opVal;
119
+ }
120
+
121
+ }}
122
+
123
+ if (!function_exists("nxs_doPublishToRD")) { function nxs_doPublishToRD($postID, $options){ if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
124
+ $cl = new nxs_snapClassRD(); $cl->nt[$options['ii']] = $options; return $cl->publishWP($options['ii'], $postID);
125
+ }}
126
  ?>
inc-cl/sc.api.php CHANGED
@@ -38,8 +38,8 @@ if (!class_exists("nxs_class_SNAP_SC")) { class nxs_class_SNAP_SC {
38
  if (!isset($options['accessToken']) || trim($options['accessToken'])=='') { $badOut['Error'] = 'Not Authorized'; return $badOut; }
39
  if (empty($options['imgSize'])) $options['imgSize'] = '';
40
  //## Format Post
41
- if (!empty($message['pText'])) $text = $message['pText']; else $text = nxs_doFormatMsg($options['msgFrmt'], $message);
42
- if (!empty($message['pTitle'])) $msgT = $message['pTitle']; else $msgT = nxs_doFormatMsg($options['msgTFrmt'], $message);
43
  //## Make Post
44
  if (isset($message['imageURL'])) $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); else $imgURL = ''; $postType = $options['postType'];
45
 
38
  if (!isset($options['accessToken']) || trim($options['accessToken'])=='') { $badOut['Error'] = 'Not Authorized'; return $badOut; }
39
  if (empty($options['imgSize'])) $options['imgSize'] = '';
40
  //## Format Post
41
+ if (!empty($message['pText'])) $text = $message['pText']; else $text = nxs_doFormatMsg($options['msgFormat'], $message);
42
+ if (!empty($message['pTitle'])) $msgT = $message['pTitle']; else $msgT = nxs_doFormatMsg($options['msgTFormat'], $message);
43
  //## Make Post
44
  if (isset($message['imageURL'])) $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); else $imgURL = ''; $postType = $options['postType'];
45
 
inc-cl/sc.php CHANGED
@@ -1,11 +1,29 @@
1
  <?php
2
  //## NextScripts App.net Connection Class
3
- $nxs_snapAvNts[] = array('code'=>'SC', 'lcode'=>'sc', 'name'=>'Scoop.It');
4
 
5
- if (!class_exists("nxs_snapClassSC")) { class nxs_snapClassSC { var $ntInfo = array('code'=>'SC', 'lcode'=>'sc', 'name'=>'Scoop.It', 'defNName'=>'', 'tstReq' => true);
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  //#### Show Common Settings
7
- function showGenNTSettings($ntOpts){ global $nxs_plurl, $nxs_snapSetPgURL; $ntInfo = $this->ntInfo;
8
- if ( isset($_GET['auth']) && $_GET['auth']==$ntInfo['lcode']){ require_once('apis/scOAuth.php'); $options = $ntOpts[$_GET['acc']];
 
 
 
 
 
9
 
10
  $consumer_key = $options['appKey']; $consumer_secret = $options['appSec'];
11
  $callback_url = $nxs_snapSetPgURL."&auth=".$ntInfo['lcode']."a&acc=".$_GET['acc'];
@@ -24,7 +42,7 @@ if (!class_exists("nxs_snapClassSC")) { class nxs_snapClassSC { var $ntInfo = ar
24
  }
25
  die();
26
  }
27
- if ( isset($_GET['auth']) && $_GET['auth']==$ntInfo['lcode'].'a'){ require_once('apis/scOAuth.php'); $options = $ntOpts[$_GET['acc']];
28
  $consumer_key = $options['appKey']; $consumer_secret = $options['appSec'];
29
 
30
  $tum_oauth = new wpScoopITOAuth($consumer_key, $consumer_secret, $options['oAuthToken'], $options['oAuthTokenSecret']); //prr($tum_oauth);
@@ -38,88 +56,24 @@ if (!class_exists("nxs_snapClassSC")) { class nxs_snapClassSC { var $ntInfo = ar
38
  } //die();
39
  if (!empty($options['appAppUserID'])) { echo '<br/><br/>All good?! Redirecting ..... <script type="text/javascript">window.location = "'.$nxs_snapSetPgURL.'"</script>'; die();}
40
  else die("<span style='color:red;'>ERROR: Authorization Error: <span style='color:darkred; font-weight: bold;'>".print_r($uinfo, true)."</span></span>");
41
- }
 
 
 
 
42
 
43
- ?>
44
- <div class="nxs_box">
45
- <div class="nxs_box_header">
46
- <div class="nsx_iconedTitle" style="margin-bottom:1px;background-image:url(<?php echo $nxs_plurl;?>img/<?php echo $ntInfo['lcode']; ?>16.png);"><?php echo $ntInfo['name']; ?>
47
- <?php $cbo = count($ntOpts); ?>
48
- <?php if ($cbo>1){ ?><div class="nsBigText"><?php echo "(".($cbo=='0'?'No':$cbo)." "; _e('accounts', 'social-networks-auto-poster-facebook-twitter-g'); echo ")"; ?></div><?php } ?>
49
- </div>
50
- </div>
51
- <div class="nxs_box_inside">
52
- <?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $ntInfo['name'];
53
- if (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='') $pbo[$ntInfo['lcode'].'OK'] = (isset($pbo['appAppUserID']) && $pbo['appAppUserID']>1)?'1':'';
54
- ?>
55
- <p style="margin:0px;margin-left:5px;"> <img id="<?php echo $ntInfo['code'].$indx;?>LoadingImg" style="display: none;" src='<?php echo $nxs_plurl; ?>img/ajax-loader-sm.gif' />
56
-
57
- <input value="0" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" type="hidden" />
58
- <?php if ((int)$pbo['do'.$ntInfo['code']] == 1 && isset($pbo['catSel']) && (int)$pbo['catSel'] == 1) { ?> <input type="radio" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" id="rbtn<?php echo $ntInfo['lcode'].$indx; ?>" value="1" checked="checked" onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);" /> <?php } else { ?>
59
- <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1 && $pbo['catSel']!='1') echo "checked"; ?> />
60
-
61
- <?php } ?>
62
-
63
- <?php if (isset($pbo['catSel']) && (int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
64
- <?php if (isset($pbo['rpstOn']) && (int)$pbo['rpstOn'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popReActive');" onmouseover="nxs_showPopUpInfo('popReActive', event);"><?php echo "*[R]*" ?></span><?php } ?>
65
- <strong><?php _e('Auto-publish to', 'social-networks-auto-poster-facebook-twitter-g'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
66
- &nbsp;&nbsp;<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'social-networks-auto-poster-facebook-twitter-g'); ?> ==&gt;</b><?php } ?>
67
- <a id="do<?php echo $ntInfo['code'].$indx; ?>AG" href="#" onclick="doGetHideNTBlock('<?php echo $ntInfo['code'];?>' , '<?php echo $indx; ?>');return false;">[<?php _e('Show Settings', 'social-networks-auto-poster-facebook-twitter-g'); ?>]</a>&nbsp;&nbsp;
68
- <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'social-networks-auto-poster-facebook-twitter-g'); ?>]</a>
69
- </p><div id="nxsNTSetDiv<?php echo $ntInfo['code'].$indx; ?>"></div><?php //$pbo['ntInfo'] = $ntInfo; $this->showNTSettings($indx, $pbo);
70
- }?>
71
- </div>
72
- </div> <?php
73
- }
74
- //#### Show NEW Settings Page
75
- function showNewNTSettings($options){ $opts = array('nName'=>'', 'doSC'=>'1', 'appKey'=>'', 'appSec'=>'', 'topicURL'=>'', 'inclTags'=>'1', 'postType'=>'A'); $opts['ntInfo']= $this->ntInfo; $this->showNTSettings($options, $opts, true);}
76
- //#### Show Unit Settings
77
- function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl, $nxs_snapSetPgURL; $ntInfo = $this->ntInfo; $nt = $ntInfo['lcode']; $ntU = $ntInfo['code'];
78
- 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'] = '';
79
- if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; if (!isset($options['topicURL'])) $options['topicURL'] = '';
80
- if (!isset($options['appKey'])) $options['appKey'] = ''; if (!isset($options['appSec'])) $options['appSec'] = ''; ?>
81
- <div id="do<?php echo $ntU; ?><?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>">
82
- <input type="hidden" value="0" id="apDoS<?php echo $ntU.$ii; ?>" />
83
- <div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/<?php echo $nt; ?>16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/instructions/scoopit-social-networks-auto-poster-setup-installation/"><?php $nType=$ntInfo['name']; printf( __( 'Detailed %s Installation/Configuration Instructions', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?></a></div>
84
-
85
- <div style="width:100%;"><strong><?php _e('Account Nickname', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'social-networks-auto-poster-facebook-twitter-g'); ?></i> </div><input name="<?php echo $nt; ?>[<?php echo $ii; ?>][nName]" id="apnName<?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")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /><br/>
86
- <?php echo nxs_addQTranslSel($nt, $ii, $options['qTLng']); ?>
87
- <br/>
88
- <ul class="nsx_tabs">
89
- <li><a href="#nsx<?php echo $nt.$ii ?>_tab1"><?php _e('Account Info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li>
90
- <?php if (!$isNew) { ?> <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li> <?php } ?>
91
- </ul>
92
- <div class="nsx_tab_container"><?php /* ######################## Account Tab ####################### */ ?>
93
- <div id="nsx<?php echo $nt.$ii ?>_tab1" class="nsx_tab_content" style="background-image: url(<?php echo $nxs_plurl; ?>img/<?php echo $nt; ?>-bg.png); background-repeat: no-repeat; background-position:90% 10%;">
94
-
95
- <div style="width:100%;"><strong><?php echo $nType; ?> Consumer Key:</strong> </div><input name="<?php echo $nt; ?>[<?php echo $ii; ?>][appKey]" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['appKey'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />
96
- <div style="width:100%;"><strong><?php echo $nType; ?> Consumer Secret:</strong> </div><input name="<?php echo $nt; ?>[<?php echo $ii; ?>][appSec]" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['appSec'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /> <br/>
97
- <div style="width:100%;"><strong><?php echo $nType; ?> Topic URL:</strong> </div>http://www.scoop.it/t/<input name="<?php echo $nt; ?>[<?php echo $ii; ?>][topicURL]" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['topicURL'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /> <br/>
98
- <br/>
99
-
100
- <div style="width:100%;"><strong id="altFormatText"><?php _e('Post Title Format', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> (<a href="#" id="msgFrmtT<?php echo $ntU.$ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('msgFrmtT<?php echo $ntU.$ii; ?>'); return false;"><?php _e('Show format info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>)</div>
101
- <input name="<?php echo $nt; ?>[<?php echo $ii; ?>][msgTFrmt]" style="width: 50%;" value="<?php if (!empty($options['msgTFrmt'])) _e(apply_filters('format_to_edit', htmlentities($options['msgTFrmt'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g'); else echo "%TITLE%"; ?>" onfocus="mxs_showFrmtInfo('msgFrmtT<?php echo $ntU.$ii; ?>');" /><?php nxs_doShowHint("msgFrmtT".$ntU.$ii); ?><br/>
102
-
103
- <div id="altFormat" style="margin-left: 0px;">
104
- <div style="width:100%;"><strong id="altFormatText"><?php _e('Text Format', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> (<a href="#" id="msgFrmt<?php echo $ntU; ?><?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('msgFrmt<?php echo $ntU; ?><?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>)
105
- </div>
106
-
107
- <textarea cols="150" rows="3" id="<?php echo $nt; ?><?php echo $ii; ?>msgFrmt" name="<?php echo $nt; ?>[<?php echo $ii; ?>][msgFrmt]" style="width:51%;max-width: 650px;" onfocus="jQuery('#<?php echo $nt; ?><?php echo $ii; ?>msgFrmt').attr('rows', 6); mxs_showFrmtInfo('msgFrmt<?php echo $ntU.$ii; ?>');"><?php if ($isNew) _e("%EXCERPT% \r\n\r\n%URL%", 'social-networks-auto-poster-facebook-twitter-g'); else _e(apply_filters('format_to_edit', htmlentities($options['msgFrmt'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g'); ?></textarea><?php nxs_doShowHint("msgFrmt".$ntU.$ii); ?>
108
- </div>
109
-
110
- <p style="margin-bottom: 20px;margin-top: 5px;"><input value="1" type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][inclTags]" <?php if ((int)$options['inclTags'] == 1) echo "checked"; ?> />
111
- <strong><?php _e('Post with tags', 'social-networks-auto-poster-facebook-twitter-g'); ?></strong> <?php _e('Tags from the blogpost will be auto-posted to '.$ntInfo['name'], 'social-networks-auto-poster-facebook-twitter-g'); ?>
112
- </p>
113
-
114
- <div style="width:100%;"><strong id="altFormatText">Post Type:</strong></div>
115
- <div style="margin-left: 10px;">
116
- <input type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][postType]" value="T" <?php if ($options['postType'] == 'T') echo 'checked="checked"'; ?> /> <?php _e('Text Post', 'social-networks-auto-poster-facebook-twitter-g'); ?> - <i><?php _e('just text message', 'social-networks-auto-poster-facebook-twitter-g'); ?></i><br/>
117
- <input type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][postType]" value="I" <?php if ($options['postType'] == 'I') echo 'checked="checked"'; ?> /> <?php _e('Image Post', 'social-networks-auto-poster-facebook-twitter-g'); ?> - <i><?php _e('big image with text message', 'social-networks-auto-poster-facebook-twitter-g'); ?></i><br/>
118
- <input type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][postType]" value="A" <?php if ( !isset($options['postType']) || $options['postType'] == '' || $options['postType'] == 'A') echo 'checked="checked"'; ?> /> <?php _e('Add blogpost to message as an attachment', 'social-networks-auto-poster-facebook-twitter-g'); ?><br/>
119
- </div>
120
-
121
- <br/><br/>
122
- <?php if($options['appKey']=='') { ?>
123
  <b><?php _e('Authorize Your '.$ntInfo['name'].' Account', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> <?php _e('Please click "Update Settings" to be able to Authorize your account.', 'social-networks-auto-poster-facebook-twitter-g'); ?>
124
  <?php } else { if(isset($options['appAppUserID']) && $options['appAppUserID']>0) { ?>
125
  <?php _e('Your '.$ntInfo['name'].' Account has been authorized.', 'social-networks-auto-poster-facebook-twitter-g'); ?> User ID: <?php _e(apply_filters('format_to_edit', htmlentities($options['appAppUserID'].' - '.$options['appAppUserName'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>.
@@ -128,179 +82,63 @@ if (!class_exists("nxs_snapClassSC")) { class nxs_snapClassSC { var $ntInfo = ar
128
 
129
  <?php if (!isset($options['appAppUserID']) || $options['appAppUserID']<1) { ?> <div class="blnkg">&lt;=== <?php _e('Authorize your account', 'social-networks-auto-poster-facebook-twitter-g'); ?> ===</div> <?php }?>
130
  <?php } ?>
131
- <br/><br/>
132
-
133
- <?php if ($isNew) { ?> <input type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][apDo<?php echo $ntU; ?>]" value="1" id="apDoNew<?php echo $ntU; ?><?php echo $ii; ?>" /> <?php } ?>
134
- <?php if (isset($options['appAppUserID']) && $options['appAppUserID']>0) { ?>
135
-
136
- <b><?php _e('Test your settings', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('<?php echo $ntU; ?>', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?></a> <?php }
137
- ?>
138
-
139
- </div>
140
- <?php /* ######################## Tools Tab ####################### */ ?>
141
- <?php if (!$isNew) { ?><div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content">
142
- <?php nxs_showCatTagsCTFilters($nt, $ii, $options);
143
- nxs_addPostingDelaySelV3($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']);
144
- nxs_showRepostSettings($nt, $ii, $options); ?>
145
- </div> <?php } ?> <?php /* #### End of Tab #### */ ?>
146
- </div><br/> <?php /* #### End of Tabs #### */ ?>
147
-
148
- <div class="submitX nxclear" style="padding-bottom: 0px;"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'social-networks-auto-poster-facebook-twitter-g') ?>" /></div>
149
-
150
-
151
- </div><?php
152
  }
 
153
  //#### Set Unit Settings from POST
154
- function setNTSettings($post, $options){ $code = $this->ntInfo['code'];
155
- foreach ($post as $ii => $pval){
156
- if (isset($pval['appKey']) && $pval['appKey']!=''){ if (!isset($options[$ii])) $options[$ii] = array();
157
-
158
- if (isset($pval['apDo'.$code])) $options[$ii]['do'.$code] = $pval['apDo'.$code]; else $options[$ii]['do'.$code] = 0;
159
- if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']);
160
-
161
- if (isset($pval['appKey'])) $options[$ii]['appKey'] = trim($pval['appKey']);
162
- if (isset($pval['appSec'])) $options[$ii]['appSec'] = trim($pval['appSec']);
163
- if (isset($pval['topicURL'])) $options[$ii]['topicURL'] = trim($pval['topicURL']);
164
-
165
-
166
- if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']); else $options[$ii]['catSel'] = 0;
167
- if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
168
-
169
- if (isset($pval['postType'])) $options[$ii]['postType'] = $pval['postType'];
170
- if (isset($pval['inclTags'])) $options[$ii]['inclTags'] = trim($pval['inclTags']); else $options[$ii]['inclTags'] = 0;
171
- if (isset($pval['msgFrmt'])) $options[$ii]['msgFrmt'] = trim($pval['msgFrmt']);
172
- if (isset($pval['msgTFrmt'])) $options[$ii]['msgTFrmt'] = trim($pval['msgTFrmt']);
173
-
174
- $options[$ii] = nxs_adjRpst($options[$ii], $pval);
175
-
176
- if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']);
177
- if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
178
- if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
179
- } elseif ( count($pval)==1 ) if (isset($pval['apDo'.$code])) $options[$ii]['do'.$code] = $pval['apDo'.$code]; else $options[$ii]['do'.$code] = 0;
180
  } return $options;
181
- }
 
182
  //#### Show Post->Edit Meta Box Settings
183
- function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID; $nt = $this->ntInfo['lcode']; $ntU = $this->ntInfo['code'];
184
- foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snap'.$ntU, true));
185
- if (is_array($pMeta) && isset($pMeta[$ii]) && is_array($pMeta[$ii])) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]); if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = '';
186
- $doIT = $ntOpt['do'.$ntU] && (is_array($pMeta) || $ntOpt['catSel']!='1'); $imgToUse = $ntOpt['imgToUse'];
187
- $isAvail = $ntOpt['appKey']!='' && $ntOpt['appSec']!=''; $msgFormat = htmlentities($ntOpt['msgFrmt'], ENT_COMPAT, "UTF-8"); $msgFormatT = htmlentities($ntOpt['msgTFrmt'], ENT_COMPAT, "UTF-8");
188
- $postType = $ntOpt['postType'];
189
- ?>
190
- <tr><th style="text-align:left;" colspan="2">
191
- <?php if ($ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='') { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
192
- <?php if (!empty($ntOpt['tagsSelX'])) { ?> <input type="hidden" class="nxs_TG" id="nxs_TG_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $ntOpt['tagsSelX']; ?>" /> <?php } ?>
193
- <?php if ($isAvail) { ?><input class="nxsGrpDoChb" value="1" id="do<?php echo $ntU.$ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][do<?php echo $ntU; ?>]" <?php if ((int)$doIT == 1) echo 'checked="checked" title="def"'; ?> />
194
- <?php if ($post->post_status == "publish") { ?> <input type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][do<?php echo $ntU; ?>]" value="<?php echo $doIT;?>"> <?php } ?> <?php } ?>
195
-
196
- <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/<?php echo $nt; ?>16.png);"><?php echo $this->ntInfo['name']; ?> - <?php _e('publish to', 'social-networks-auto-poster-facebook-twitter-g') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
197
- if ($post->post_status == "publish" && $isAvail) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostTo<?php echo $ntU; ?>_repostButton" id="rePostTo<?php echo $ntU; ?>_button" value="<?php _e('Repost to '.$this->ntInfo['name'], 'social-networks-auto-poster-facebook-twitter-g') ?>" />
198
- <?php } ?>
199
-
200
- <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
201
-
202
- ?> <span id="pstd<?php echo $ntU; ?><?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
203
- <a style="font-size: 10px;" href="<?php echo $pMeta[$ii]['postURL']; ?>" target="_blank"><?php $nType=$this->ntInfo['name']; printf( __( 'Posted on', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
204
- </span><?php } ?>
205
-
206
- </td></tr>
207
-
208
- <?php if (!$isAvail) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your <?php echo $this->ntInfo['name']; ?> Account to AutoPost to <?php echo $this->ntInfo['name']; ?></b></td></tr>
209
- <?php } else { if ($post->post_status != "publish" && function_exists('nxs_doSMAS5') ) { $ntOpt['postTime'] = get_post_time('U', false, $post_id); nxs_doSMAS5($nt, $ii, $ntOpt); } ?>
210
-
211
- <?php if ($ntOpt['rpstOn']=='1') { ?>
212
-
213
- <tr id="altFormat1" style=""><th scope="row" class="nxsTHRow">
214
- <input value="0" type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]"/><input value="nxsi<?php echo $ii; ?>ap" type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]" <?php if (!empty($ntOpt['rpstPostIncl'])) echo "checked"; ?> />
215
- </th>
216
- <td> <?php _e('Include in "Auto-Reposting" to this network.', 'social-networks-auto-poster-facebook-twitter-g') ?>
217
- </td></tr> <?php } ?>
218
-
219
- <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Title Format:', 'NS_SPAP') ?></th>
220
- <td><input value="<?php echo $msgFormatT; ?>" type="text" name="<?php echo $nt; ?>[<?php echo $ii; ?>][msgTFrmt]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('msgFrmtT<?php echo $nt.$ii; ?>');"/><?php nxs_doShowHint("msgFrmtT".$nt.$ii, '', '58'); ?></td></tr>
221
-
222
- <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Text Format:', 'social-networks-auto-poster-facebook-twitter-g') ?></th><td>
223
-
224
- <textarea cols="150" rows="1" id="<?php echo $nt.$ii; ?>msgFrmt" name="<?php echo $nt; ?>[<?php echo $ii; ?>][msgFrmt]" style="width:60%;max-width: 610px;" onfocus="jQuery('#<?php echo $nt.$ii; ?>msgFrmt').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('msgFrmt<?php echo $nt.$ii; ?>');"><?php echo $msgFormat ?></textarea> <?php nxs_doShowHint("msgFrmt".$nt.$ii, '', '58'); ?>
225
-
226
- </td></tr>
227
-
228
- <tr><th scope="row" style="text-align:right; width:150px; vertical-align:top; padding-top: 0px; padding-right:10px;"> <?php _e('Post Type:', 'social-networks-auto-poster-facebook-twitter-g') ?> <br/></th><td>
229
  <input type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][postType]" value="T" <?php if ($postType == 'T') echo 'checked="checked"'; ?> /> <?php _e('Text Post', 'social-networks-auto-poster-facebook-twitter-g') ?> - <i><?php _e('just text message', 'social-networks-auto-poster-facebook-twitter-g') ?></i><br/>
230
  <input type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][postType]" value="I" <?php if ($postType == 'I') echo 'checked="checked"'; ?> /> <?php _e('Post as "Image post"', 'social-networks-auto-poster-facebook-twitter-g') ?> - <i><?php _e('big image with text message', 'social-networks-auto-poster-facebook-twitter-g') ?></i><br/>
231
  <input type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][postType]" value="A" <?php if ( !isset($postType) || $postType == '' || $postType == 'A') echo 'checked="checked"'; ?> /><?php _e('Text Post with "attached" blogpost', 'social-networks-auto-poster-facebook-twitter-g') ?>
232
  </td></tr>
233
-
234
- <?php /* ## Select Image & URL ## */ nxs_showImgToUseDlg($nt, $ii, $imgToUse); ?>
235
- <?php }
236
-
237
  }
238
  }
 
239
  //#### Save Meta Tags to the Post
240
- function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
241
- if (isset($pMeta['doSC'])) $optMt['doSC'] = $pMeta['doSC'] == 1?1:0; else { if (isset($pMeta['msgFormat'])) $optMt['doSC'] = 0; }
242
-
243
- if (isset($pMeta['msgFrmt'])) $optMt['msgFrmt'] = $pMeta['msgFrmt']; if (isset($pMeta['msgTFrmt'])) $optMt['msgTFrmt'] = $pMeta['msgTFrmt'];
244
- if (isset($pMeta['postType'])) $optMt['postType'] = $pMeta['postType'];
245
-
246
- if (isset($pMeta['imgToUse'])) $optMt['imgToUse'] = $pMeta['imgToUse']; if (isset($pMeta['urlToUse'])) $optMt['urlToUse'] = $pMeta['urlToUse'];
247
- if (isset($pMeta['timeToRun'])) $optMt['timeToRun'] = $pMeta['timeToRun']; if (isset($pMeta['rpstPostIncl'])) $optMt['rpstPostIncl'] = $pMeta['rpstPostIncl'];
248
- if (isset($pMeta['SNAPincludeSC']) && $pMeta['SNAPincludeSC'] == '1' ) $optMt['doSC'] = 1;
249
  return $optMt;
250
- }
251
- }}
252
- if (!function_exists("nxs_rePostToSC_ajax")) {
253
- function nxs_rePostToSC_ajax() { check_ajax_referer('nxsSsPageWPN'); $postID = $_POST['id']; global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
254
- foreach ($options['sc'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj'; //if ($two['apPageID'].$two['apUName']==$_POST['nid']) {
255
- $appo = get_post_meta($postID, 'snapSC', true); $appo = maybe_unserialize($appo);// prr($appo);
256
- if (is_array($appo) && isset($appo[$ii]) && is_array($appo[$ii])){ $ntClInst = new nxs_snapClassSC(); $two = $ntClInst->adjMetaOpt($two, $appo[$ii]); }
257
- $result = nxs_doPublishToSC($postID, $two); if ($result == 200) die("Successfully sent your post to Scoop.It. "); else die($result);
258
- }
259
  }
260
- }
261
- if (!function_exists("nxs_doPublishToSC")) { //## Post to SC. // V3 - imgToUse - Done, class_SNAP_AP - Done, New Format - Done
262
- function nxs_doPublishToSC($postID, $options){ global $plgn_NS_SNAutoPoster; $ntCd = 'SC'; $ntCdL = 'sc'; $ntNm = 'Scoop.It'; if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
263
- $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'POSTID'=>$postID, 'ACCNAME'=>$options['nName']));
264
- if (empty($options['imgToUse'])) $options['imgToUse'] = ''; if (empty($options['imgSize'])) $options['imgSize'] = '';
265
- $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
266
- $logNT = '<span style="color:#800000">Scoop.It</span> - '.$options['nName'];
267
- $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
268
- if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
269
- $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') {
270
- nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$uqID); return;
271
- }
272
- }
273
- $message = array('message'=>'', 'link'=>'', 'imageURL'=>'', 'videoURL'=>'');
274
-
275
- if ($postID=='0') { echo "Testing ... <br/><br/>"; $message['description'] = 'Test Post, Description'; $message['title'] = 'Test Post - Title'; $message['url'] = home_url();
276
- } else { nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1')); $post = get_post($postID); if(!$post) return;
277
- $postType = $options['postType']; $isNoImg = false; $tags = '';
278
-
279
- $options['msgFrmt'] = nsFormatMessage($options['msgFrmt'], $postID, $addParams); $options['msgTFrmt'] = nsFormatMessage($options['msgTFrmt'], $postID, $addParams);
280
-
281
- $tggs = array(); if ($options['inclTags']=='1'){ $t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = $tggs; }
282
-
283
- if ($postType=='A') if (trim($options['imgToUse'])!='') $imgURL = $options['imgToUse']; else $imgURL = nxs_getPostImage($postID, 'medium');
284
- if ($postType=='I') if (trim($options['imgToUse'])!='') $imgURL = $options['imgToUse']; else $imgURL = nxs_getPostImage($postID, 'full');
285
- if (preg_match("/noImg.\.png/i", $imgURL)) { $imgURL = ''; $isNoImg = true; }
286
-
287
- //## MyURL - URLToGo code
288
- $options = nxs_getURL($options, $postID, $addParams); $urlToGo = $options['urlToUse']; $message = array('url'=>$urlToGo, 'imageURL'=>$imgURL, 'noImg'=>$isNoImg, 'tags'=>$tags);
289
- $extInfo = ' | PostID: '.$postID." - ".(isset($post) && is_object($post)?$post->post_title:'');
290
- }
291
- //## Actual Post
292
- $ntToPost = new nxs_class_SNAP_SC(); $ret = $ntToPost->doPostToNT($options, $message); //prr($ret);
293
- //## Process Results
294
- if (!is_array($ret) || $ret['isPosted']!='1') { //## Error
295
- if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);
296
- } else { // ## All Good - log it.
297
- if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo _e('OK - Message Posted, please see your '.$logNT.' Page. ', 'social-networks-auto-poster-facebook-twitter-g'); }
298
- else { nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPosted'=>'1', 'pgID'=>$ret['postID'], 'postURL'=>$ret['postURL'], 'pDate'=>date('Y-m-d H:i:s')));
299
- $extInfo .= ' | <a href="'.$ret['postURL'].'" target="_blank">Post Link</a>'; nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); }
300
- }
301
- //## Return Result
302
- if ($ret['isPosted']=='1') return 200; else return print_r($ret, true);
303
-
304
- }
305
- }
1
  <?php
2
  //## NextScripts App.net Connection Class
3
+ $nxs_snapAvNts[] = array('code'=>'SC', 'lcode'=>'sc', 'name'=>'Scoop.It', 'type'=>'Blogs/Publishing Platforms', 'ptype'=>'F', 'status'=>'A', 'desc'=>'Autopost to your "Topics". Ability to attach your blogpost to scoop. Ability to make "Image" posts');
4
 
5
+ if (!class_exists("nxs_snapClassSC")) { class nxs_snapClassSC extends nxs_snapClassNT {
6
+ var $ntInfo = array('code'=>'SC', 'lcode'=>'sc', 'name'=>'Scoop.It', 'defNName'=>'', 'tstReq' => true, 'instrURL'=>'http://www.nextscripts.com/instructions/scoopit-social-networks-auto-poster-setup-installation/');
7
+ //#### Update
8
+ function toLatestVer($ntOpts){ if( !empty($ntOpts['v'])) $v = $ntOpts['v']; else $v = 340; $ntOptsOut = ''; switch ($v) {
9
+ case 340: $ntOptsOut = $this->toLatestVerNTGen($ntOpts); $ntOptsOut['do'] = $ntOpts['do'.$this->ntInfo['code']]; $ntOptsOut['nName'] = $ntOpts['nName'];
10
+ $ntOptsOut['msgTFormat'] = $ntOpts['msgTFrmt']; $ntOptsOut['msgFormat'] = $ntOpts['msgFrmt']; $ntOptsOut['appKey'] = $ntOpts['appKey']; $ntOptsOut['appSec'] = $ntOpts['appSec'];
11
+ $ntOptsOut['accessToken'] = $ntOpts['accessToken']; $ntOptsOut['accessTokenSec'] = $ntOpts['accessTokenSec']; $ntOptsOut['oAuthToken'] = $ntOpts['oAuthToken']; $ntOptsOut['oAuthTokenSecret'] = $ntOpts['oAuthTokenSecret'];
12
+ $ntOptsOut['topicURL'] = $ntOpts['topicURL'];$ntOptsOut['inclTags'] = $ntOpts['inclTags']; $ntOptsOut['postType'] = $ntOpts['postType'];
13
+ $ntOptsOut['appAppUserID'] = $ntOpts['appAppUserID']; $ntOptsOut['appAppUserName'] = $ntOpts['appAppUserName'];
14
+ $ntOptsOut['isUpdd'] = '1'; $ntOptsOut['v'] = NXS_SETV;
15
+ break;
16
+ }
17
+ return !empty($ntOptsOut)?$ntOptsOut:$ntOpts;
18
+ }
19
  //#### Show Common Settings
20
+ function showGenNTSettings($ntOpts){ $this->nt = $ntOpts; $this->showNTGroup(); }
21
+ //#### Show NEW Settings Page
22
+ function showNewNTSettings($ii){ $defO = array('nName'=>'', 'do'=>'1', 'appKey'=>'', 'appSec'=>'', 'inclTags'=>1, 'msgFormat'=>"%EXCERPT% \r\n\r\n%URL%", 'msgTFormat'=>"%TITLE%", 'imgSize'=>'original', 'topicURL'=>'', 'postType'=>'A'); $this->showGNewNTSettings($ii, $defO); }
23
+ //#### Show Unit Settings
24
+ function checkIfSetupFinished($options) { return !empty($options['appAppUserID']) && !empty($options['accessToken']); }
25
+ public function doAuth() { $ntInfo = $this->ntInfo; global $nxs_snapSetPgURL;
26
+ if ( isset($_GET['auth']) && $_GET['auth']==$ntInfo['lcode']){ require_once('apis/scOAuth.php'); $options = $this->nt[$_GET['acc']];
27
 
28
  $consumer_key = $options['appKey']; $consumer_secret = $options['appSec'];
29
  $callback_url = $nxs_snapSetPgURL."&auth=".$ntInfo['lcode']."a&acc=".$_GET['acc'];
42
  }
43
  die();
44
  }
45
+ if ( isset($_GET['auth']) && $_GET['auth']==$ntInfo['lcode'].'a'){ require_once('apis/scOAuth.php'); $options = $this->nt[$_GET['acc']];
46
  $consumer_key = $options['appKey']; $consumer_secret = $options['appSec'];
47
 
48
  $tum_oauth = new wpScoopITOAuth($consumer_key, $consumer_secret, $options['oAuthToken'], $options['oAuthTokenSecret']); //prr($tum_oauth);
56
  } //die();
57
  if (!empty($options['appAppUserID'])) { echo '<br/><br/>All good?! Redirecting ..... <script type="text/javascript">window.location = "'.$nxs_snapSetPgURL.'"</script>'; die();}
58
  else die("<span style='color:red;'>ERROR: Authorization Error: <span style='color:darkred; font-weight: bold;'>".print_r($uinfo, true)."</span></span>");
59
+ }
60
+ }
61
+
62
+ function accTab($ii, $options, $isNew=false){ global $nxs_snapSetPgURL; $ntInfo = $this->ntInfo; $nt = $ntInfo['lcode']; $this->elemKeySecret($ii,'Consumer Key','Consumer Secret', $options['appKey'], $options['appSec'],'appKey','appSec','https://www.scoop.it/dev/apps'); ?>
63
+ <div style="width:100%;"><strong><?php echo $ntInfo['name']; ?> Topic URL:</strong> </div>http://www.scoop.it/t/<input name="<?php echo $nt; ?>[<?php echo $ii; ?>][topicURL]" style="width: 20%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['topicURL'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /><br/><br/>
64
 
65
+ <?php $this->elemTitleFormat($ii,'Post Title Format','msgTFormat',$options['msgTFormat']); $this->elemMsgFormat($ii,'Post Format','msgFormat',$options['msgFormat']); ?>
66
+ <div style="margin: 0px;"><input value="1" type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][inclTags]" <?php if ((int)$options['inclTags'] == 1) echo "checked"; ?> /> <strong><?php _e('Post with tags', 'social-networks-auto-poster-facebook-twitter-g'); ?></strong></div>
67
+
68
+ <div style="width:100%;"><strong id="altFormatText">Post Type:</strong></div>
69
+ <div style="margin-left: 10px;">
70
+ <input type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][postType]" value="T" <?php if ($options['postType'] == 'T') echo 'checked="checked"'; ?> /> <?php _e('Text Post', 'social-networks-auto-poster-facebook-twitter-g'); ?> - <i><?php _e('just text message', 'social-networks-auto-poster-facebook-twitter-g'); ?></i><br/>
71
+ <input type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][postType]" value="I" <?php if ($options['postType'] == 'I') echo 'checked="checked"'; ?> /> <?php _e('Image Post', 'social-networks-auto-poster-facebook-twitter-g'); ?> - <i><?php _e('big image with text message', 'social-networks-auto-poster-facebook-twitter-g'); ?></i><br/>
72
+ <input type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][postType]" value="A" <?php if ( !isset($options['postType']) || $options['postType'] == '' || $options['postType'] == 'A') echo 'checked="checked"'; ?> /> <?php _e('Add blogpost to message as an attachment', 'social-networks-auto-poster-facebook-twitter-g'); ?><br/>
73
+ </div>
74
+
75
+ <br/><br/>
76
+ <?php if($options['appKey']=='') { ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  <b><?php _e('Authorize Your '.$ntInfo['name'].' Account', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> <?php _e('Please click "Update Settings" to be able to Authorize your account.', 'social-networks-auto-poster-facebook-twitter-g'); ?>
78
  <?php } else { if(isset($options['appAppUserID']) && $options['appAppUserID']>0) { ?>
79
  <?php _e('Your '.$ntInfo['name'].' Account has been authorized.', 'social-networks-auto-poster-facebook-twitter-g'); ?> User ID: <?php _e(apply_filters('format_to_edit', htmlentities($options['appAppUserID'].' - '.$options['appAppUserName'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>.
82
 
83
  <?php if (!isset($options['appAppUserID']) || $options['appAppUserID']<1) { ?> <div class="blnkg">&lt;=== <?php _e('Authorize your account', 'social-networks-auto-poster-facebook-twitter-g'); ?> ===</div> <?php }?>
84
  <?php } ?>
85
+ <br/><br/><?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  }
87
+ function advTab($ii, $options){}
88
  //#### Set Unit Settings from POST
89
+ function setNTSettings($post, $options){
90
+ foreach ($post as $ii => $pval){
91
+ if (!empty($pval['appKey']) && !empty($pval['appKey'])){ if (!isset($options[$ii])) $options[$ii] = array(); $options[$ii] = $this->saveCommonNTSettings($pval,$options[$ii]);
92
+ //## Uniqe Items
93
+ if (isset($pval['topicURL'])) $options[$ii]['topicURL'] = trim($pval['topicURL']);
94
+ if (isset($pval['postType'])) $options[$ii]['postType'] = trim($pval['postType']);
95
+ } elseif ( count($pval)==1 ) if (isset($pval['do'])) $options[$ii]['do'] = $pval['do']; else $options[$ii]['do'] = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  } return $options;
97
+ }
98
+
99
  //#### Show Post->Edit Meta Box Settings
100
+
101
+ function showEdPostNTSettings($ntOpts, $post){ $post_id = $post->ID; $nt = $this->ntInfo['lcode']; $ntU = $this->ntInfo['code'];
102
+ foreach($ntOpts as $ii=>$ntOpt) { $isFin = $this->checkIfSetupFinished($ntOpt); if (!$isFin) continue;
103
+ $pMeta = maybe_unserialize(get_post_meta($post_id, 'snap'.$ntU, true)); if (is_array($pMeta) && !empty($pMeta[$ii])) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
104
+
105
+ if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = ''; if (empty($ntOpt['urlToUse'])) $ntOpt['urlToUse'] = ''; $postType = isset($ntOpt['postType'])?$ntOpt['postType']:'';
106
+ $msgFormat = !empty($ntOpt['msgFormat'])?htmlentities($ntOpt['msgFormat'], ENT_COMPAT, "UTF-8"):''; $msgTFormat = !empty($ntOpt['msgTFormat'])?htmlentities($ntOpt['msgTFormat'], ENT_COMPAT, "UTF-8"):'';
107
+ $imgToUse = $ntOpt['imgToUse']; $urlToUse = $ntOpt['urlToUse']; $ntOpt['ii']=$ii; $this->nxs_tmpltAddPostMeta($post, $ntOpt, $pMeta);
108
+ $this->elemEdTitleFormat($ii, __('Title Format:', 'social-networks-auto-poster-facebook-twitter-g'),$msgTFormat);
109
+ $this->elemEdMsgFormat($ii, __('Message Format:', 'social-networks-auto-poster-facebook-twitter-g'),$msgFormat);
110
+ ?>
111
+ <tr style="<?php echo !empty($ntOpt['do'])?'display:table-row;':'display:none;'; ?>" class="nxstbldo nxstbldo<?php echo strtoupper($nt).$ii; ?>"><th scope="row" style="text-align:right; width:150px; vertical-align:top; padding-top: 0px; padding-right:10px;"> <?php _e('Post Type:', 'social-networks-auto-poster-facebook-twitter-g') ?> <br/></th><td>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  <input type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][postType]" value="T" <?php if ($postType == 'T') echo 'checked="checked"'; ?> /> <?php _e('Text Post', 'social-networks-auto-poster-facebook-twitter-g') ?> - <i><?php _e('just text message', 'social-networks-auto-poster-facebook-twitter-g') ?></i><br/>
113
  <input type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][postType]" value="I" <?php if ($postType == 'I') echo 'checked="checked"'; ?> /> <?php _e('Post as "Image post"', 'social-networks-auto-poster-facebook-twitter-g') ?> - <i><?php _e('big image with text message', 'social-networks-auto-poster-facebook-twitter-g') ?></i><br/>
114
  <input type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][postType]" value="A" <?php if ( !isset($postType) || $postType == '' || $postType == 'A') echo 'checked="checked"'; ?> /><?php _e('Text Post with "attached" blogpost', 'social-networks-auto-poster-facebook-twitter-g') ?>
115
  </td></tr>
116
+ <?php
117
+
118
+ nxs_showImgToUseDlg($nt, $ii, $imgToUse);
119
+ /* ## Select Image & URL ## */ nxs_showURLToUseDlg($nt, $ii, $urlToUse); $this->nxs_tmpltAddPostMetaEnd($ii);
120
  }
121
  }
122
+
123
  //#### Save Meta Tags to the Post
124
+ function adjMetaOpt($optMt, $pMeta){ $optMt = $this->adjMetaOptG($optMt, $pMeta);
125
+ if (!empty($pMeta['postType'])) $optMt['postType'] = $pMeta['postType'];
 
 
 
 
 
 
 
126
  return $optMt;
 
 
 
 
 
 
 
 
 
127
  }
128
+
129
+ function adjPublishWP(&$options, &$message, $postID){
130
+ if (!empty($postID)) { $postType = $options['postType'];
131
+ if ($postType=='A') if (trim($options['imgToUse'])!='') $imgURL = $options['imgToUse']; else $imgURL = nxs_getPostImage($postID, !empty($options['wpImgSize'])?$options['wpImgSize']:'medium');
132
+ if ($postType=='I') if (trim($options['imgToUse'])!='') $imgURL = $options['imgToUse']; else $imgURL = nxs_getPostImage($postID, !empty($options['wpImgSize'])?$options['wpImgSize']:'full');
133
+ if (preg_match("/noImg.\.png/i", $imgURL)) { $imgURL = ''; $isNoImg = true; }
134
+ $message['imageURL