NextScripts: Social Networks Auto-Poster - Version 3.0.9

Version Description

[11/18/2013] =

  • New - %FULLTITLE% tag will insert processed title.
  • Bug Fix - YouTube - Google+ page setting were not saved.
  • Bug Fix - LinkedIn - Titles for groups were ignored.
  • Bug Fix - Set Time was not working in Firefox.
  • Bug Fix - Plurk authorization problems.
  • Bug Fix - Individual Category Excluded was breaking autoposting.
  • Bug Fix - Wordpress [caption] tag were broken
Download this release

Release Info

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

Code changes from version 2.7.22 to 3.0.9

NextScripts_SNAP.php CHANGED
@@ -4,744 +4,45 @@ Plugin Name: NextScripts: Social Networks Auto-Poster
4
  Plugin URI: http://www.nextscripts.com/social-networks-auto-poster-for-wordpress
5
  Description: This plugin automatically publishes posts from your blog to multiple accounts on Facebook, Twitter, and Google+ profiles and/or pages.
6
  Author: Next Scripts
7
- Version: 2.7.22
8
  Author URI: http://www.nextscripts.com
 
9
  Copyright 2012 Next Scripts, Inc
10
  */
11
- define( 'NextScripts_SNAP_Version' , '2.7.22' ); require_once "nxs_functions.php";
12
- //## Include All Available Networks
13
- global $nxs_snapAvNts, $nxs_snapThisPageUrl, $nxs_plurl, $nxs_isWPMU, $nxs_tpWMPU;
14
- if (!isset($nxs_snapAvNts) || !is_array($nxs_snapAvNts)) $nxs_snapAvNts = array(); $nxs_snapAPINts = array(); foreach (glob(plugin_dir_path( __FILE__ ).'inc-cl/*.php') as $filename){ require_once $filename; }
15
- do_action('nxs_doSomeMore');
16
-
17
- $nxs_snapThisPageUrl = admin_url().'options-general.php?page=NextScripts_SNAP.php';
18
- $nxs_plurl = plugin_dir_url(__FILE__);
19
- $nxs_isWPMU = defined('MULTISITE') && MULTISITE==true;
20
-
21
- //## Define SNAutoPoster class
22
- if (!class_exists("NS_SNAutoPoster")) {
23
- class NS_SNAutoPoster {//## General Functions
24
- var $dbOptionsName = "NS_SNAutoPoster";
25
- var $nxs_options = ""; var $nxs_ntoptions = "";
26
-
27
- function __construct() { load_plugin_textdomain('nxs_snap', FALSE, dirname(plugin_basename(__FILE__)).'/lang/'); $this->nxs_options = $this->getAPOptions();}
28
- //## Constructor
29
- function NS_SNAutoPoster() { }
30
- //## Initialization function
31
- function init() { $this->getAPOptions(); }
32
- //## Administrative Functions
33
- //## Options loader function
34
- function getAPOptions() { global $nxs_isWPMU, $blog_id; $dbMUOptions = array();
35
- //## Some Default Values
36
- //$options = array('nsOpenGraph'=>1);
37
- $dbOptions = get_option($this->dbOptionsName);
38
- $this->nxs_ntoptions = get_site_option($this->dbOptionsName); $nxs_UPPath = 'nxs-snap-pro-upgrade';
39
- $pf = ABSPATH . 'wp-content/plugins/'.$nxs_UPPath.'/'.$nxs_UPPath.'.php'; if (file_exists($pf) && !function_exists('nxs_getInitAdd') ) require_once $pf;
40
- if ($nxs_isWPMU && $blog_id>1) { switch_to_blog(1); $dbMUOptions = get_option($this->dbOptionsName);
41
- if (function_exists('nxs_getInitAdd')) nxs_getInitAdd($dbMUOptions); restore_current_blog();
42
- $dbOptions['lk'] = $dbMUOptions['lk']; $dbOptions['ukver'] = $dbMUOptions['ukver']; $dbOptions['uklch'] = $dbMUOptions['uklch']; $dbOptions['uk'] = $dbMUOptions['uk'];
43
- }
44
- if (!empty($dbOptions) && is_array($dbOptions)) foreach ($dbOptions as $key => $option) if (trim($key)!='') $options[$key] = $option;
45
- if ( (!$nxs_isWPMU || $blog_id==1) && function_exists('nxs_getInitAdd')) nxs_getInitAdd($options); //$ttt = function_exists('nxs_getInitAdd'); var_dump($ttt);
46
- if (isset($options['uk']) && $options['uk']!='') $options['uk']='API';
47
-
48
- if (defined('NXSAPIVER') && $options['ukver']!=NXSAPIVER){$options['ukver']=NXSAPIVER; update_option($this->dbOptionsName, $options);}
49
- $options['isMA'] = function_exists('nxs_doSMAS1') && isset($options['lk']) && isset($options['uk']) && $options['uk']!='';
50
- $options['isMU'] = function_exists('showSNAP_WPMU_OptionsPageExt') && isset($options['lk']) && isset($options['uk']) && $options['uk']!='';
51
- $options['isMUx'] = function_exists('showSNAP_WPMU_OptionsPageExtX') && isset($options['lk']) && isset($options['uk']) && $options['uk']!=''; // prr($options);
52
-
53
- if (!isset($options['isPro']) || $options['isPro']!='1'){ //## Upgrade from non-pro version
54
- $optPro = array();foreach ($options as $indx => $opt){
55
- if (substr($indx, 0, 2)=='fb') $optPro['fb'][0][$indx] = $opt;
56
- elseif (substr($indx, 0, 2)=='gp') $optPro['gp'][0][$indx] = $opt;
57
- elseif (substr($indx, 0, 2)=='tw') $optPro['tw'][0][$indx] = $opt;
58
- elseif (substr($indx, 0, 2)=='tr') $optPro['tr'][0][$indx] = $opt;
59
- elseif (substr($indx, 0, 2)=='bg') $optPro['bg'][0][$indx] = $opt;
60
- elseif (substr($indx, 0, 2)=='li') $optPro['li'][0][$indx] = $opt;
61
- elseif (substr($indx, 0, 2)=='pn') $optPro['pn'][0][$indx] = $opt;
62
- elseif ($indx=='doFB') $optPro['fb'][0][$indx] = $opt;
63
- elseif ($indx=='doGP') $optPro['gp'][0][$indx] = $opt;
64
- elseif ($indx=='doTW') $optPro['tw'][0][$indx] = $opt;
65
- elseif ($indx=='doTR') $optPro['tr'][0][$indx] = $opt;
66
- elseif ($indx=='doBG') $optPro['bg'][0][$indx] = $opt;
67
- elseif ($indx=='doLI') $optPro['li'][0][$indx] = $opt;
68
- elseif ($indx=='doPN') $optPro['pn'][0][$indx] = $opt;
69
- elseif (trim($indx)!='') $optPro[$indx] = $opt;
70
- if ($options['twAccTokenSec']!='') $optPro['tw'][0]['twOK'] = '1';
71
- if ($options['bgBlogID']!='') $optPro['bg'][0]['bgOK'] = '1';
72
- $optPro['isPro'] = '1';
73
- }
74
- //## Update the options for the panel
75
- $options = $optPro; update_option($this->dbOptionsName, $options);
76
- }
77
- // if(!$options['isMA']) $options = nxs_snapCleanup($options);
78
- return $options;
79
- }
80
-
81
- function showSNAP_WPMU_OptionsPage(){ global $nxs_snapAvNts, $nxs_snapThisPageUrl, $nxsOne, $wpdb, $nxs_isWPMU; $nxsOne = ''; $options = $this->nxs_options;
82
- $this->NS_SNAP_ShowPageTop();
83
- if ($nxs_isWPMU && function_exists('showSNAP_WPMU_OptionsPageExt')) { showSNAP_WPMU_OptionsPageExt($this); } elseif ($nxs_isWPMU && function_exists('showSNAP_WPMU_OptionsPageExtX')) { ?>
84
- <br/><br/><b style="font-size:16px; line-height:24px; color:red;">You are running SNAP <?php echo $options['isMA']?'Single Site Pro':'Free'; ?> <br/> </b>
85
- This version does not fully support Wordpress Multisite (ex Wordpress MU) Advanced Features. SNAP is available for all sites/blogs in your networks and each individual blog admin can setup and manage it.
86
- <br/>Please upgrade to <a href="http://www.nextscripts.com/social-networks-auto-poster-pro-for-wpmu/" target="_blank"> SNAP For Wordpress Multisite</a> if you need advanced Super Admin management of SNAP for sites/blogs in your networks. Please see <a href="http://www.nextscripts.com/social-networks-auto-poster-pro-for-wpmu/" target="_blank">here</a> for more info
87
- <br/><br/>Please <a href="http://www.nextscripts.com/contact-us/" target="_blank"> contact us</a> if you got the SNAP PRO before Oct 1st, 2012. You may be eligible for upgrade discount.
88
- <br/><br/>
89
- <?php return;
90
- } elseif ( !$options['isMA']) {
91
- ?> <br/><br/><b style="font-size:16px; line-height:24px; color:red;">You are running SNAP <?php echo $options['isMA']?'Single Site Pro':'Free'; ?> <br/> This version does not support Wordpress Multisite (ex Wordpress MU). <br/>Please upgrade to <a href="http://www.nextscripts.com/social-networks-auto-poster-pro-for-wpmu/" target="_blank"> SNAP Pro for Wordpress Multisite</a></b>
92
- <br/><br/><hr/>
93
- <h3>FAQ:</h3> <b>Question:</b> I am not running Wordpress Multisite! Why I am seeing this?<br/><b>Answer:</b>
94
- Your Wordpress is configured to run as a Wordpress Multisite. Please open your wp-config.php and change: <br/><br/>
95
- define('WP_ALLOW_MULTISITE', true);<br/>to<br/>define('WP_ALLOW_MULTISITE', false);<br/><br/>and<br/><br/>define('MULTISITE', true);<br/>to<br/>define('MULTISITE', false);<br/><br/>
96
- <b>Question:</b> I am running Wordpress Multisite, but I need SNAP on one blog only? Can I use it?<br/><b>Answer:</b>We are sorry, but it is not possible to run "SNAP Free" on Wordpress Multisite. You need to either upgrade plugin to "SNAP Pro" to run it on one blog or to "SNAP Pro for WPNU" to run it on all blogs or disable Wordpress Multisite.
97
- <br/><br/><hr/>
98
- <?php return;
99
- } else {
100
- ?> <br/><b style="font-size:16px; line-height:24px; color:red;">You are running SNAP <?php echo $options['isMA']?'Single Site Pro':'Free'; ?> <br/> This version does not fully support Wordpress Multisite (ex Wordpress MU).</b> <br/>
101
-
102
- <br/><span style="font-size: 16px;"> You can use SNAP for your main blog only. <a href="<?php echo admin_url(); ?>options-general.php?page=NextScripts_SNAP.php">Click here to setup it.</a></span><br/><br/>
103
-
104
- <span style="font-size: 12px; font-weight: bold;">Please upgrade to <a href="http://www.nextscripts.com/social-networks-auto-poster-pro-for-wpmu/" target="_blank"> SNAP Pro for Wordpress Multisite</a> to get all features: </span>
105
- <br/>
106
- - All Blogs/Sites autopost to networks configured by Super Admin <br/>
107
- - Each Blog/Site Admin can configure and auto-post to it's own networks <br/>
108
- - Super Admin can enable/disable auto-posting for each site and the whole network<br/>
109
- - Super Admin can also manage/setup/disable/override SNAP settings for each Blog/Site.<br/>
110
-
111
- <br/>
112
- <?php return;
113
- }
114
- }
115
- function showSNAutoPosterOptionsPage() { global $nxs_snapAvNts, $nxs_snapThisPageUrl, $nxsOne, $nxs_plurl, $nxs_isWPMU, $nxs_tpWMPU; $nxsOne = ''; $options = $this->nxs_options; //prr($options);
116
- //if($acid==1) $options = $this->nxs_options; else { switch_to_blog($acid); $options = $this->getAPOptions(); }
117
- if (isset($_POST['upload_NS_SNAutoPoster_settings'])) { if (get_magic_quotes_gpc() || $_POST['nxs_mqTest']=="\'") {array_walk_recursive($_POST, 'nsx_stripSlashes');} array_walk_recursive($_POST, 'nsx_fixSlashes');
118
- //## Import Settings
119
- $secCheck = wp_verify_nonce($_POST['nxsChkUpl_wpnonce'], 'nxsChkUpl');
120
- if ($secCheck!==false && isset($_FILES['impFileSettings_button']) && is_uploaded_file($_FILES['impFileSettings_button']['tmp_name'])) { $fileData = trim(file_get_contents($_FILES['impFileSettings_button']['tmp_name']));
121
- while (substr($fileData, 0,1)!=='a') $fileData = substr($fileData, 1);
122
- $uplOpt = maybe_unserialize($fileData); if (is_array($uplOpt) && isset($uplOpt['imgNoCheck'])) { $options = $uplOpt; update_option($this->dbOptionsName, $options); } else { ?><div class="error" id="message"><p><strong>Incorrect Import file.</div><?php }
123
- }
124
- }
125
-
126
- if (isset($_POST['update_NS_SNAutoPoster_settings'])) { if (get_magic_quotes_gpc() || $_POST['nxs_mqTest']=="\'") {array_walk_recursive($_POST, 'nsx_stripSlashes');} array_walk_recursive($_POST, 'nsx_fixSlashes');
127
- //## Load Networks Settings
128
- foreach ($nxs_snapAvNts as $avNt) if (isset($_POST[$avNt['lcode']])) { $clName = 'nxs_snapClass'.$avNt['code']; if (!isset($options[$avNt['lcode']])) $options[$avNt['lcode']] = array();
129
- $ntClInst = new $clName(); $ntOpt = $ntClInst->setNTSettings($_POST[$avNt['lcode']], $options[$avNt['lcode']]); $options[$avNt['lcode']] = $ntOpt;
130
- }
131
- if (isset($_POST['apCats'])) $options['apCats'] = $_POST['apCats'];
132
- if (isset($_POST['nxsHTDP'])) $options['nxsHTDP'] = $_POST['nxsHTDP'];
133
- if (isset($_POST['ogImgDef'])) $options['ogImgDef'] = $_POST['ogImgDef'];
134
- if (isset($_POST['featImgLoc'])) $options['featImgLoc'] = $_POST['featImgLoc'];
135
- if (isset($_POST['anounTagLimit'])) $options['anounTagLimit'] = $_POST['anounTagLimit'];
136
- if (isset($_POST['featImgLocPrefix'])) $options['featImgLocPrefix'] = $_POST['featImgLocPrefix'];
137
- if (isset($_POST['featImgLocArrPath'])) $options['featImgLocArrPath'] = $_POST['featImgLocArrPath'];
138
-
139
-
140
- if (isset($_POST['nxsURLShrtnr']))$options['nxsURLShrtnr'] = $_POST['nxsURLShrtnr'];
141
- if (isset($_POST['bitlyUname'])) $options['bitlyUname'] = $_POST['bitlyUname'];
142
- if (isset($_POST['bitlyAPIKey'])) $options['bitlyAPIKey'] = $_POST['bitlyAPIKey'];
143
-
144
- if (isset($_POST['YOURLSKey'])) $options['YOURLSKey'] = $_POST['YOURLSKey'];
145
- if (isset($_POST['YOURLSURL'])) $options['YOURLSURL'] = $_POST['YOURLSURL'];
146
-
147
- if (isset($_POST['gglAPIKey'])) $options['gglAPIKey'] = $_POST['gglAPIKey'];
148
-
149
- if ($options['nxsURLShrtnr']=='B' && (trim($_POST['bitlyAPIKey'])=='' || trim($_POST['bitlyAPIKey'])=='')) $options['nxsURLShrtnr'] = 'G';
150
- if ($options['nxsURLShrtnr']=='Y' && (trim($_POST['YOURLSKey'])=='' || trim($_POST['YOURLSURL'])=='')) $options['nxsURLShrtnr'] = 'G';
151
-
152
- if (isset($_POST['nsOpenGraph'])) $options['nsOpenGraph'] = $_POST['nsOpenGraph']; else $options['nsOpenGraph'] = 0;
153
- if (isset($_POST['imgNoCheck'])) $options['imgNoCheck'] = 0; else $options['imgNoCheck'] = 1;
154
- if (isset($_POST['useForPages'])) $options['useForPages'] = 1; else $options['useForPages'] = 0;
155
-
156
- if (isset($_POST['showPrxTab'])) $options['showPrxTab'] = 1; else $options['showPrxTab'] = 0;
157
- if (isset($_POST['useRndProxy'])) $options['useRndProxy'] = 1; else $options['useRndProxy'] = 0;
158
-
159
- if (isset($_POST['prxList'])) $options['prxList'] = $_POST['prxList'];
160
- if (isset($_POST['addURLParams'])) $options['addURLParams'] = $_POST['addURLParams'];
161
-
162
- if (isset($_POST['riActive'])) $options['riActive'] = 1; else $options['riActive'] = 0;
163
- if (isset($_POST['riHowManyPostsToTrack'])) $options['riHowManyPostsToTrack'] = $_POST['riHowManyPostsToTrack'];
164
-
165
- if (isset($_POST['useUnProc'])) $options['useUnProc'] = $_POST['useUnProc']; else $options['useUnProc'] = 0;
166
- if (isset($_POST['nxsCPTSeld'])) $options['nxsCPTSeld'] = serialize($_POST['nxsCPTSeld']);
167
- if (isset($_POST['post_category'])) { $pk = $_POST['post_category']; if (!is_array($pk)) { $pk = urldecode($pk); parse_str($pk); }
168
- $cIds = get_all_category_ids(); if(is_array($pk) && $cIds) $options['exclCats'] = serialize(array_diff($cIds, $pk)); else $options['exclCats'] = '';
169
- } //prr($options['exclCats']);
170
- if (!isset($_POST['whoCanSeeSNAPBox'])) $_POST['whoCanSeeSNAPBox'] = array(); $_POST['whoCanSeeSNAPBox'][] = 'administrator';
171
- if (isset($_POST['whoCanSeeSNAPBox'])) $options['whoCanSeeSNAPBox'] = $_POST['whoCanSeeSNAPBox'];
172
- if (!isset($_POST['whoCanMakePosts'])) $_POST['whoCanMakePosts'] = array(); $_POST['whoCanMakePosts'][] = 'administrator';
173
- if (isset($_POST['whoCanMakePosts'])) $options['whoCanMakePosts'] = $_POST['whoCanMakePosts'];
174
-
175
- if (isset($_POST['skipSecurity'])) $options['skipSecurity'] = 1; else $options['skipSecurity'] = 0;
176
-
177
- if ($nxs_isWPMU && (!isset($options['suaMode'])||$options['suaMode'] == '')) $options['suaMode'] = $nxs_tpWMPU;
178
- $editable_roles = get_editable_roles(); foreach ( $editable_roles as $roleX => $details ) {$role = get_role($roleX); $role->remove_cap('see_snap_box'); $role->remove_cap('make_snap_posts'); }
179
-
180
- foreach ($options['whoCanSeeSNAPBox'] as $uRole) { $role = get_role($uRole); $role->add_cap('see_snap_box'); $role->add_cap('make_snap_posts'); }
181
- foreach ($options['whoCanMakePosts'] as $uRole) { $role = get_role($uRole); $role->add_cap('make_snap_posts'); }
182
-
183
- update_option($this->dbOptionsName, $options); // prr($options);
184
- ?><div class="updated"><p><strong><?php _e("Settings Updated.", 'nxs_snap');?></strong></p></div><?php
185
- }
186
- $isNoNts = true; foreach ($nxs_snapAvNts as $avNt) if (isset($options[$avNt['lcode']]) && is_array($options[$avNt['lcode']]) && count($options[$avNt['lcode']])>0) {$isNoNts = false; break;}
187
-
188
- $category_ids = get_all_category_ids(); if(isset($options['exclCats'])) $pk = maybe_unserialize($options['exclCats']); else $pk = '';
189
- if ( is_array($category_ids) && is_array($pk) && count($category_ids) == count($pk)) { ?>
190
- <div class="error" id="message"><p><strong>All your categories are excluded from auto-posting.</strong> Nothing will be auto-posted. Please Click "Settings Tab" and select some categories.</div>
191
- <?php }
192
-
193
- if(!$nxs_isWPMU) $this->NS_SNAP_ShowPageTop(); ?>
194
- Please see the <a target="_blank" href="http://www.nextscripts.com/installation-of-social-networks-auto-poster-for-wordpress">detailed installation/configuration instructions</a> (will open in a new tab)<br/>
195
- <?php if(!isset($options['hideTopTip']) || (int)$options['hideTopTip'] != 1) { /* ?>
196
- <div id="nxs_TopTip" class="nxsInfoMsg" style="font-size: 11px; margin-left: 3px; max-width: 1100px; display: block; font-style: italic; margin-bottom: 5px;">Tip: If autoposting works when you click "Test" buttons, but is not working when you publish new posts, try to switch from "Scheduled" to "Immediately" in the Plugin Settings->Other Settings->How to make auto-posts.
197
- <span style="float: right;"><a style="text-decoration: none" href="#" onclick="nxs_hideTip('nxs_TopTip'); return false;">[Hide]</a></span>
198
- </div>
199
- <?php */ } else { ?><br/><?php } ?>
200
-
201
- <ul class="nsx_tabs">
202
- <li><a href="#nsx_tab1">Your Social Networks Accounts</a></li>
203
- <li><a href="#nsx_tab2"><?php _e('Settings', 'nxs_snap') ?></a></li>
204
- <?php if ((function_exists("nxs_showPRXTab")) && (int)$options['showPrxTab'] == 1) { ?> <li><a href="#nsx_tab5">Proxies</a></li> <?php } ?>
205
- <li><a href="#nsx_tab3">Log/History</a></li>
206
- <li><a href="#nsx_tab4">Help/Support</a></li>
207
- </ul>
208
- <form method="post" id="nsStForm" action="<?php echo $nxs_snapThisPageUrl?>">
209
- <div class="nsx_tab_container">
210
- <div id="nsx_tab1" class="nsx_tab_content"><a href="#" class="NXSButton" id="nxs_snapAddNew">Add new account</a> <div class="nxsInfoMsg"><img style="position: relative; top: 8px;" alt="Arrow" src="<?php echo $nxs_plurl; ?>img/arrow_l_green_c1.png"/> You can add Facebook, Twitter, Google+, Pinterest, LinkedIn, Tumblr, Blogger/Blogspot, Delicious, etc accounts</div><br/><br/>
211
- <div id="nxs_spPopup"><span class="nxspButton bClose"><span>X</span></span>Add New Network: <select onchange="doShowFillBlockX(this.value);" id="nxs_ntType"><option value =""></option>
212
- <?php foreach ($nxs_snapAvNts as $avNt) { if (!isset($options[$avNt['lcode']]) || count($options[$avNt['lcode']])==0) $mt=0; else $mt = 1+max(array_keys($options[$avNt['lcode']]));
213
- echo '<option value ="'.$avNt['code'].$mt.'">'.$avNt['name'].'</option>';
214
- } ?>
215
- </select>
216
- <div id="nsx_addNT">
217
- <?php foreach ($nxs_snapAvNts as $avNt) { $clName = 'nxs_snapClass'.$avNt['code']; $ntClInst = new $clName();
218
- if (!isset($options[$avNt['lcode']]) || count($options[$avNt['lcode']])==0) { $ntClInst->showNewNTSettings(0); } else {
219
- $mt = 1+max(array_keys($options[$avNt['lcode']])); if (function_exists('nxs_doSMAS1')) nxs_doSMAS1($ntClInst, $mt); else nxs_doSMAS($avNt['name'], $avNt['code'].$mt);
220
- }} ?>
221
- </div>
222
-
223
- </div>
224
-
225
- <div class="popShAtt" id="popOnlyCat"><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></div>
226
- <div id="showCatSel" style="display: none;background-color: #fff; width: 300px; padding: 25px;"><span class="nxspButton bClose"><span>X</span></span>Select Categories:
227
- <div id="fbSelCats<?php echo $ii; ?>" class="categorydivInd" style="padding-left: 15px; background-color: #fff;">
228
- <a href="#" onclick="nxs_chAllCatsL(1, 'fbSelCats<?php echo $ii; ?>'); return false;">Check all</a> &nbsp;|&nbsp; <a href="#" onclick="nxs_chAllCatsL(0, 'fbSelCats<?php echo $ii; ?>'); return false;">UnCheck all</a>
229
- <div id="category-all" class="tabs-panel"> <input type="hidden" id="tmpCatSelNT" name="tmpCatSelNT" value="" />
230
- <ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
231
- <?php $args = array( 'descendants_and_self' => 0, 'selected_cats' => '', 'taxonomy' => 'category', 'checked_ontop' => false);
232
- if (function_exists('wp_terms_checklist')) wp_terms_checklist(0, $args ); ?>
233
- </ul>
234
- </div>
235
- </div> <div class="submit"><input type="button" id="" class="button-primary" name="btnSelCats" onclick="nxs_doSetSelCats( jQuery('#tmpCatSelNT').val() ); jQuery('#showCatSel').bPopup().close();" value="Select Categories" /></div>
236
- </div>
237
-
238
- <?php wp_nonce_field( 'nsDN', 'nsDN_wpnonce' );
239
- foreach ($nxs_snapAvNts as $avNt) { $clName = 'nxs_snapClass'.$avNt['code']; $ntClInst = new $clName();
240
- if ( isset($options[$avNt['lcode']]) && count($options[$avNt['lcode']])>0) { $ntClInst->showGenNTSettings($options[$avNt['lcode']]); } // else $ntClInst->showNewNTSettings(0);
241
- }
242
- if ($isNoNts) { ?><br/><br/><br/>You don't have any configured social networks yet. Please click "Add new account" button.<br/><br/>
243
- <input onclick="jQuery('#impFileSettings_button').click(); return false;" type="button" class="button" name="impSettings_repostButton" id="impSettings_button" value="<?php _e('Import Settings', 'nxs_snap') ?>" />
244
- <?php } else {?>
245
-
246
- <div style="float: right; padding: 1.5em;">
247
-
248
- <input onclick="nxs_expSettings(); return false;" type="button" class="button" name="expSettings_repostButton" id="expSettings_button" value="<?php _e('Export Settings', 'nxs_snap') ?>" />
249
- <input onclick="jQuery('#impFileSettings_button').click(); return false;" type="button" class="button" name="impSettings_repostButton" id="impSettings_button" value="<?php _e('Import Settings', 'nxs_snap') ?>" />
250
- </div>
251
- <input value="'" type="hidden" name="nxs_mqTest" />
252
- <div class="submit"><input type="submit" id="nxs-button-primary-submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div>
253
-
254
- <?php } ?>
255
- </div> <!-- END TAB -->
256
- <div id="nsx_tab2" class="nsx_tab_content">
257
- <!-- ##################### OTHER #####################-->
258
- <?php wp_nonce_field( 'nxsSsPageWPN', 'nxsSsPageWPN_wpnonce' ); ?>
259
- <!-- How to make auto-posts? -->
260
- <div class="nxs_box"> <div class="nxs_box_header"><h3><?php _e('How to make auto-posts?', 'nxs_snap') ?> &lt;-- (<a id="showShAttIS" onmouseover="showPopShAtt('IS', event);" onmouseout="hidePopShAtt('IS');" onclick="return false;" class="underdash" href="#"><?php _e('What\'s the difference?', 'nxs_snap') ?></a>)</h3></div>
261
- <div class="popShAtt" id="popShAttIS">
262
- <h3><?php _e('The difference between "Immediately" and "Scheduled"', 'nxs_snap') ?></h3>
263
- <?php _e('<b>"Immediately"</b> - Once you click "Publish" button plugin starts pushing your update to configured social networks. At this time you need to wait and look at the turning circle. Some APIs are pretty slow, so you have to wait and wait and wait until all updates are posted and page released back to you.', 'nxs_snap') ?><br/><br/>
264
- <?php _e('<b>"Scheduled"</b> - Releases the page immediately back to you, so you can proceed with something else and it schedules all auto-posting jobs to your WP-Cron. This is much faster and much more efficient, but it could not work if your WP-Cron is disabled or broken.', 'nxs_snap') ?>
265
- </div>
266
- <div class="nxs_box_inside">
267
- <div class="itemDiv">
268
- <input type="radio" name="nxsHTDP" value="I" <?php if (isset($options['nxsHTDP']) && $options['nxsHTDP']=='I') echo 'checked="checked"'; ?> /> <b><?php _e('Publish Immediately', 'nxs_snap') ?></b> - <i><?php _e('Use if WP Cron is disabled or broken on your website', 'nxs_snap') ?></i><br/>
269
- </div>
270
-
271
- <div class="itemDiv">
272
- <input type="radio" name="nxsHTDP" value="S" <?php if (!isset($options['nxsHTDP']) || $options['nxsHTDP']=='S') echo 'checked="checked"'; ?> /> <b><?php _e('Schedule (Recommended)', 'nxs_snap') ?></b> - <i><?php _e('Faster Performance - requires working WP Cron', 'nxs_snap') ?></i><br/> <?php /* ?>
273
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="runNXSCron" value="1"> <b><?php _e('Try to process missed "Scheduled" posts.', 'nxs_snap') ?></b> <i><?php _e('Usefull when WP Cron is disabled or broken, but can cause some short perfomance issues and duplicates. It is <b>highly</b> recomended to setup a proper cron job of fix WP Cron instead', 'nxs_snap') ?></i>. <?php */ ?>
274
- </div>
275
- </div></div>
276
- <!-- #### Who can see auto-posting options on the "New Post" pages? ##### -->
277
- <div class="nxs_box"> <div class="nxs_box_header"><h3><?php _e('User Privileges/Security', 'nxs_snap') ?></h3></div>
278
- <div class="nxs_box_inside">
279
- <div class="itemDiv">
280
-
281
- <input value="set" id="skipSecurity" name="skipSecurity" type="checkbox" <?php if ((int)$options['skipSecurity'] == 1) echo "checked"; ?> /> <b><?php _e('Skip User Security Check', 'nxs_snap') ?></b>
282
- <span style="font-size: 11px; margin-left: 1px;"><?php _e('NOT Recommended, but usefull in some situations. This will allow autoposting for everyone even for the non-existent users.', 'nxs_snap') ?></span>
283
-
284
- <h4><?php _e('Who can make autoposts without seeing any auto-posting options?', 'nxs_snap') ?></h4>
285
-
286
- <?php $editable_roles = get_editable_roles(); if (!isset($options['whoCanMakePosts']) || !is_array($options['whoCanMakePosts'])) $options['whoCanMakePosts'] = array();
287
 
288
- foreach ( $editable_roles as $role => $details ) { $name = translate_user_role($details['name'] ); echo '<input type="checkbox" ';
289
- if (in_array($role, $options['whoCanMakePosts']) || $role=='administrator') echo ' checked="checked" '; if ($role=='administrator') echo ' disabled="disabled" ';
290
- echo 'name="whoCanMakePosts[]" value="'.esc_attr($role).'"> '.$name;
291
- if ($role=='administrator') echo ' - Somebody who has access to all the administration features';
292
- if ($role=='editor') echo " - Somebody who can publish and manage posts and pages as well as manage other users' posts, etc. ";
293
- if ($role=='author') echo ' - Somebody who can publish and manage their own posts ';
294
- if ($role=='contributor') echo ' - Somebody who can write and manage their posts but not publish them';
295
- if ($role=='subscriber') echo ' - Somebody who can only manage their profile';
296
- echo '<br/>';
297
- } ?>
298
 
299
- <h4><?php _e('Who can see auto-posting options on the "New Post" and "Edit Post" pages and make autoposts?', 'nxs_snap') ?></h4>
300
-
301
- <?php $editable_roles = get_editable_roles(); if (!isset($options['whoCanSeeSNAPBox']) || !is_array($options['whoCanSeeSNAPBox'])) $options['whoCanSeeSNAPBox'] = array();
 
302
 
303
- foreach ( $editable_roles as $role => $details ) { $name = translate_user_role($details['name'] ); echo '<input type="checkbox" ';
304
- if (in_array($role, $options['whoCanSeeSNAPBox']) || $role=='administrator') echo ' checked="checked" '; if ($role=='administrator' || $role=='subscriber') echo ' disabled="disabled" ';
305
- echo 'name="whoCanSeeSNAPBox[]" value="'.esc_attr($role).'"> '.$name;
306
- if ($role=='administrator') echo ' - Somebody who has access to all the administration features';
307
- if ($role=='editor') echo " - Somebody who can publish and manage posts and pages as well as manage other users' posts, etc. ";
308
- if ($role=='author') echo ' - Somebody who can publish and manage their own posts ';
309
- if ($role=='contributor') echo ' - Somebody who can write and manage their posts but not publish them';
310
- if ($role=='subscriber') echo ' - Somebody who can only manage their profile';
311
- echo '<br/>';
312
- } ?>
313
-
314
-
315
-
316
-
317
- </div>
318
-
319
- </div></div>
320
- <!-- #### Include/Exclude Wordpress Pages and Custom Post Types ##### -->
321
- <div class="nxs_box"> <div class="nxs_box_header"><h3><?php _e('Include/Exclude Wordpress Pages and Custom Post Types', 'nxs_snap') ?></h3></div>
322
- <div class="nxs_box_inside">
323
- <div class="itemDiv">
324
- <input value="set" id="useForPages" name="useForPages" type="checkbox" <?php if ((int)$options['useForPages'] == 1) echo "checked"; ?> /> <b><?php _e('Use for Wordpress Pages', 'nxs_snap') ?></b>
325
- <span style="font-size: 11px; margin-left: 1px;"><?php _e('Show the SNAP metabox and auto-post for pages, not just posts.', 'nxs_snap') ?></span>
326
- </div>
327
- <div class="itemDiv"><b><br/><?php _e('Custom Post Types:', 'nxs_snap') ?></b>
328
- <span style="font-size: 11px; margin-left: 1px;"><?php _e('Please select "Custom Post Types" that you would like to be autoposted to your social networks', 'nxs_snap') ?> </span> <br/>
329
- <?php $nxsOne = base64_encode("v=".$nxsOne);
330
- $args=array('public'=>true, '_builtin'=>false); $output = 'names'; $operator = 'and'; $post_types = array(); if (function_exists('get_post_types')) $post_types=get_post_types($args, $output, $operator);
331
- if ($options['nxsCPTSeld']!='') $nxsCPTSeld = unserialize($options['nxsCPTSeld']); else $nxsCPTSeld = array_keys($post_types);
332
-
333
- ?> <div class="taxonomydiv"><div class="tabs-panel" style="padding: 10px;"><input type="hidden" name="nxsCPTSeld[]" value="0" /> <?php //prr($nxsCPTSeld); prr($post_types); prr($_POST['nxsCPTSeld']);
334
- foreach ($post_types as $cptID=>$cptName){ if (in_array($cptID, $nxsCPTSeld)) $dCh = ' checked="checked" '; else $dCh = "";
335
- ?><input type="checkbox" name="nxsCPTSeld[]" value="<?php echo esc_attr($cptID); ?>"<?php echo $dCh ?>>&nbsp;<?php echo $cptName ?><br/> <?php
336
- }
337
- ?></div></div>
338
- </div>
339
- </div></div>
340
- <!-- #### Categories to Include/Exclude: ##### -->
341
- <script type="text/javascript"> function nxs_chAllCats(ch){ jQuery("form input:checkbox[name='post_category[]']").attr('checked', ch==1);}
342
- (function($) { $(function() {
343
- $('.button-primary[name="update_NS_SNAutoPoster_settings"]').bind('click', function(e) { var str = $('input[name="post_category[]"]').serialize(); $('div.categorydivInd').replaceWith('<input type="hidden" name="pcInd" value="" />');
344
- str = str.replace(/post_category/g, "pk"); $('div.categorydiv').replaceWith('<input type="hidden" name="post_category" value="'+str+'" />');
345
- }); }); })(jQuery); </script>
346
- <div class="nxs_box"> <div class="nxs_box_header"><h3><?php _e('Categories to Include/Exclude:', 'nxs_snap') ?></h3></div>
347
- <div class="nxs_box_inside"> <span style="font-size: 11px; margin-left: 1px;"><?php _e('Each blogpost will be autoposted to all categories selected below. All categories are selected by default.
348
- <b>Uncheck</b> categories that you would like <b>NOT</b> to auto-post by default. Assigning the uncheked category to the new blogpost will turn off auto-posting to all configured networks.', 'nxs_snap') ?> </span> <br/>
349
- <div class="itemDiv">
350
- <a href="#" onclick="nxs_chAllCats(1); return false;">Check all</a> &nbsp;|&nbsp; <a href="#" onclick="nxs_chAllCats(0); return false;">UnCheck all</a>
351
-
352
- <div id="taxonomy-category" class="categorydiv">
353
- <div id="category-all" class="tabs-panel"><input type='hidden' name='post_category[]' value='0' />
354
- <ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
355
- <?php if(isset($options['exclCats'])) $pk = maybe_unserialize($options['exclCats']); else $pk = '';
356
- if (is_array($pk) && count($pk)>0 ) $selCats = array_diff($category_ids, $pk); else $selCats = $category_ids;
357
- $args = array( 'descendants_and_self' => 0, 'selected_cats' => $selCats, 'taxonomy' => 'category', 'checked_ontop' => false);
358
- if (function_exists('wp_terms_checklist')) wp_terms_checklist(0, $args );
359
- ?>
360
- </ul>
361
- </div>
362
- </div>
363
- </div>
364
- </div></div>
365
- <!-- ##################### URL Shortener #####################-->
366
- <div class="nxs_box"> <div class="nxs_box_header"><h3><?php _e('URL Shortener', 'nxs_snap') ?></h3></div>
367
- <div class="nxs_box_inside"> <span style="font-size: 11px; margin-left: 1px;">Please use %SURL% in "Message Format" to get shortened urls. </span> <br/>
368
- <!-- <div class="itemDiv">
369
- <input type="radio" name="nxsURLShrtnr" value="G" <?php if (!isset($options['nxsURLShrtnr']) || $options['nxsURLShrtnr']=='' || $options['nxsURLShrtnr']=='G') echo 'checked="checked"'; ?> /> <b>gd.is</b> (Default) - fast, simple, free, no configuration nessesary.
370
- </div> -->
371
- <div class="itemDiv">
372
- <input type="radio" name="nxsURLShrtnr" value="O" <?php if (isset($options['nxsURLShrtnr']) && $options['nxsURLShrtnr']=='O' || $options['nxsURLShrtnr']=='' || $options['nxsURLShrtnr']=='G') echo 'checked="checked"'; ?> /> <b>goo.gl</b> - <i> Enter goo.gl <a target="_blank" href="https://developers.google.com/url-shortener/v1/getting_started#APIKey">API Key</a> below [Optional]</i><br/>
373
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;goo.gl&nbsp;&nbsp;API Key:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name="gglAPIKey" style="width: 20%;" value="<?php if (isset($options['gglAPIKey'])) _e(apply_filters('format_to_edit',$options['gglAPIKey']), 'nxs_snap') ?>" />
374
- </div>
375
-
376
- <?php if (function_exists('wp_get_shortlink')) { ?><div class="itemDiv">
377
- <input type="radio" name="nxsURLShrtnr" value="W" <?php if (isset($options['nxsURLShrtnr']) && $options['nxsURLShrtnr']=='W') echo 'checked="checked"'; ?> /> <b>Wordpress Built-in Shortener</b> (wp.me if you use Jetpack)<br/>
378
- </div><?php } ?>
379
-
380
- <div class="itemDiv">
381
- <input type="radio" name="nxsURLShrtnr" value="B" <?php if (isset($options['nxsURLShrtnr']) && $options['nxsURLShrtnr']=='B') echo 'checked="checked"'; ?> /> <b>bit.ly</b> - <i>Enter bit.ly username and <a target="_blank" href="http://bitly.com/a/your_api_key">API Key</a> below</i><br/>
382
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bit.ly Username: <input name="bitlyUname" style="width: 20%;" value="<?php if (isset($options['bitlyUname'])) _e(apply_filters('format_to_edit',$options['bitlyUname']), 'nxs_snap') ?>" /><br/>
383
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bit.ly&nbsp;&nbsp;API Key:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name="bitlyAPIKey" style="width: 20%;" value="<?php if (isset($options['bitlyAPIKey'])) _e(apply_filters('format_to_edit',$options['bitlyAPIKey']), 'nxs_snap') ?>" />
384
- </div>
385
-
386
- <div class="itemDiv">
387
- <input type="radio" name="nxsURLShrtnr" value="Y" <?php if (isset($options['nxsURLShrtnr']) && $options['nxsURLShrtnr']=='Y') echo 'checked="checked"'; ?> /> <b>YOURLS (Your Own URL Shortener)</b> -
388
- &nbsp;<i>YOURLS API URL - usually sonething like http://yourdomain.cc/yourls-api.php; YOURLS API Secret Signature Token can be found in your YOURLS Admin Panel-&gt;Tools</i><br/>
389
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;YOURLS API URL: <input name="YOURLSURL" style="width: 19.4%;" value="<?php if (isset($options['YOURLSURL'])) _e(apply_filters('format_to_edit',$options['YOURLSURL']), 'nxs_snap') ?>" /><br/>
390
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;YOURLS API Secret Signature Token:&nbsp;&nbsp;&nbsp;<input name="YOURLSKey" style="width: 13%;" value="<?php if (isset($options['YOURLSKey'])) _e(apply_filters('format_to_edit',$options['YOURLSKey']), 'nxs_snap') ?>" />
391
- </div>
392
-
393
- </div></div>
394
- <!-- ##################### Auto-Import comments from Social Networks #####################-->
395
- <div class="nxs_box"> <div class="nxs_box_header"><h3><?php _e('Auto-Import comments from Social Networks', 'nxs_snap') ?><span class="nxs_newLabel">[<?php _e('New', 'nxs_snap') ?>]</span></h3></div>
396
- <div class="nxs_box_inside"> <span style="font-size: 11px; margin-left: 1px;">Plugin will automatically grab the comments posted on Social Networks and insert them as "Comments to your post". Plugin will check for the new comments every hour. </span> <br/>
397
- <div class="itemDiv">
398
- <input value="set" id="riActive" name="riActive" type="checkbox" <?php if ((int)$options['riActive'] == 1) echo "checked"; ?> />
399
- <strong>Enable "Comments Import"</strong>
400
- </div>
401
- <div class="itemDiv">
402
- <strong style="font-size: 12px; margin: 10px; margin-left: 1px;">How many posts should be tracked:</strong>
403
- <input name="riHowManyPostsToTrack" style="width: 50px;" value="<?php if (isset($options['riHowManyPostsToTrack'])) _e(apply_filters('format_to_edit', $options['riHowManyPostsToTrack']), 'nxs_snap'); else echo "10"; ?>" /> <br/>
404
-
405
- <span style="font-size: 11px; margin-left: 1px;">Setting two many will degrade your website's performance. 10-20 posts are recommended</span>
406
- </div>
407
-
408
- </div></div>
409
- <!-- ##################### Additional URL Parameters #####################-->
410
- <div class="nxs_box"> <div class="nxs_box_header"><h3><?php _e('Additional URL Parameters', 'nxs_snap') ?> <span class="nxs_newLabel">[<?php _e('New', 'nxs_snap') ?>]</span></h3></div>
411
- <div class="nxs_box_inside"> <span style="font-size: 11px; margin-left: 1px;"><?php _e('Will be added to backlinks.', 'nxs_snap') ?> </span> <br/>
412
- <div class="itemDiv">
413
- <b><?php _e('Additional URL Parameters:', 'nxs_snap') ?></b> <input name="addURLParams" style="width: 800px;" value="<?php if (isset($options['addURLParams'])) _e(apply_filters('format_to_edit', $options['addURLParams']), 'nxs_snap'); ?>" />
414
- </div>
415
- <span style="font-size: 11px; margin-left: 1px;"> <?php _e('You can use %NTNAME% for social network name, %NTCODE% for social network two-letter code, %ACCNAME% for account name, %POSTID% for post ID, %POSTTITLE% for post title, %SITENAME% for website name. <b>Any text must be URL Encoded</b><br/>Example: utm_source=%NTCODE%&utm_medium=%ACCNAME%&utm_campaign=SNAP%2Bfrom%2B%SITENAME%', 'nxs_snap') ?></span>
416
- </div></div>
417
-
418
- <!-- ##### ANOUNCE TAG ##### -->
419
- <div class="nxs_box"> <div class="nxs_box_header"><h3><?php _e('%ANNOUNCE% tag settings', 'nxs_snap') ?></h3></div>
420
- <div class="nxs_box_inside"> <span style="font-size: 11px; margin-left: 1px;"><?php _e('Plugin will take text untill the &lt;!--more--&gt; tag. Please specify how many characters should it get if &lt;!--more--&gt; tag is not found', 'nxs_snap') ?> </span> <br/>
421
- <div class="itemDiv">
422
- <b><?php _e('How many characters:', 'nxs_snap') ?></b> <input name="anounTagLimit" style="width: 100px;" value="<?php if (isset($options['anounTagLimit'])) _e(apply_filters('format_to_edit',$options['anounTagLimit']), 'nxs_snap'); else echo "300"; ?>" />
423
- </div>
424
- </div></div>
425
-
426
- <!-- ##################### Open Graph #####################-->
427
- <div class="nxs_box"> <div class="nxs_box_header"><h3><?php _e('"Open Graph" Tags', 'nxs_snap') ?></h3></div>
428
- <div class="nxs_box_inside"> <span style="font-size: 11px; margin-left: 1px;"><?php _e('"Open Graph" tags are used for generating title, description and preview image for your Facebook and Google+ posts. This is quite simple implementation of "Open Graph" Tags. This option will only add tags needed for "Auto Posting". If you need something more serious uncheck this and use other specialized plugins.', 'nxs_snap') ?> </span> <br/>
429
- <div class="itemDiv">
430
- <input value="1" id="nsOpenGraph" name="nsOpenGraph" type="checkbox" <?php if ((int)$options['nsOpenGraph'] == 1) echo "checked"; ?> /> <b><?php _e('Add Open Graph Tags', 'nxs_snap') ?></b>
431
- </div>
432
- <div class="itemDiv">
433
- <b><?php _e('Default Image URL for og:image tag:', 'nxs_snap') ?></b>
434
- <input name="ogImgDef" style="width: 30%;" value="<?php if (isset($options['ogImgDef'])) _e(apply_filters('format_to_edit',$options['ogImgDef']), 'nxs_snap') ?>" />
435
- </div>
436
- </div></div>
437
- <!-- #### "Featured" Image ##### -->
438
- <div class="nxs_box"> <div class="nxs_box_header"><h3><?php _e('Advanced "Featured" Image Settings', 'nxs_snap') ?></h3></div>
439
- <div class="nxs_box_inside">
440
- <div class="itemDiv">
441
- <input value="set" id="imgNoCheck" name="imgNoCheck" type="checkbox" <?php if ((int)$options['imgNoCheck'] != 1) echo "checked"; ?> /> <strong>Verify "Featured" Image</strong>
442
- <br/><span style="font-size: 11px; margin-left: 1px;"><?php _e('Advanced Setting. Uncheck only if you are 100% sure that your images are valid or if you have troubles with image verification.', 'nxs_snap') ?> </span> <br/>
443
- </div>
444
-
445
- <div class="itemDiv">
446
- <input value="1" id="useUnProc" name="useUnProc" type="checkbox" <?php if (isset($options['useUnProc']) && (int)$options['useUnProc'] == 1) echo "checked"; ?> />
447
- <b><?php _e('Use advanced image finder', 'nxs_snap') ?></b>
448
- <br/>
449
- <span style="font-size: 11px; margin-left: 1px;"> <?php _e('Check this if your images could be found only in the fully processed posts. <br/>This feature could interfere with some plugins using post processing functions incorrectly. Your site could become messed up, have troubles displaying content or start giving you "ob_start() [ref.outcontrol]: Cannot use output buffering in output buffering display handlers" errors.', 'nxs_snap') ?></span>
450
- </div>
451
-
452
- </div></div>
453
-
454
- <!-- ##### Alternative "Featured Image" location ##### -->
455
- <div class="nxs_box"> <div class="nxs_box_header"><h3><?php _e('Alternative "Featured Image" location', 'nxs_snap') ?></h3></div>
456
- <div class="nxs_box_inside"> <span style="font-size: 11px; margin-left: 1px;"><?php _e('Plugin uses standard Wordpress "Featured Image" by default. If your theme stores "Featured Image" in the custom field, please enter the name of it. Use prefix if your custom field has only partial location.', 'nxs_snap') ?> </span> <br/>
457
- <div class="itemDiv">
458
- <b><?php _e('Custom field name:', 'nxs_snap') ?></b> <input name="featImgLoc" style="width: 200px;" value="<?php if (isset($options['featImgLoc'])) _e(apply_filters('format_to_edit',$options['featImgLoc']), 'nxs_snap') ?>" />
459
- <br/>
460
- <span style="font-size: 11px; margin-left: 1px;"><?php _e('Set the name of the custom field that contains image info', 'nxs_snap') ?></span>
461
- </div>
462
- <div class="itemDiv">
463
- <b><?php _e('Custom field Array Path:', 'nxs_snap') ?></b> <input name="featImgLocArrPath" style="width: 200px;" value="<?php if (isset($options['featImgLocArrPath'])) _e(apply_filters('format_to_edit',$options['featImgLocArrPath']), 'nxs_snap') ?>" />
464
- <br/>
465
- <span style="font-size: 11px; margin-left: 1px;">[<?php _e('Optional', 'nxs_snap') ?>] <?php _e('If your custom field contain an array, please enter the path to the image field. For example: [\'images\'][\'image\']', 'nxs_snap') ?></span>
466
- </div>
467
- <div class="itemDiv">
468
- <b><?php _e('Custom field Image Prefix:', 'nxs_snap') ?></b> <input name="featImgLocPrefix" style="width: 200px;" value="<?php if (isset($options['featImgLocPrefix'])) _e(apply_filters('format_to_edit',$options['featImgLocPrefix']), 'nxs_snap') ?>" />
469
- <br/>
470
- <span style="font-size: 11px; margin-left: 1px;">[<?php _e('Optional', 'nxs_snap') ?>] <?php _e('If your custom field contain only the last part of the image path, please enter the prefix', 'nxs_snap') ?></span>
471
- </div>
472
- </div></div>
473
-
474
-
475
-
476
- <?php if (function_exists("nxs_showPRXTab")) { ?>
477
- <h3 style="font-size: 14px; margin-bottom: 2px;">Show "Proxies" Tab</h3>
478
- <p style="margin: 0px;margin-left: 5px;"><input value="set" id="showPrxTab" name="showPrxTab" type="checkbox" <?php if ((int)$options['showPrxTab'] == 1) echo "checked"; ?> />
479
- <strong>Show "Proxies" Tab</strong> <span style="font-size: 11px; margin-left: 1px;">Advanced Setting. Check to enable "Proxies" tab where you can setup autoposting proxies.</span>
480
- </p>
481
- <?php } ?>
482
-
483
- <div class="submit"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div>
484
- </div>
485
-
486
- <?php if ((function_exists("nxs_showPRXTab")) && (int)$options['showPrxTab'] == 1) { nxs_showPRXTab($options); } ?>
487
- <div id="nsx_tab3" class="nsx_tab_content">
488
- <div style="width:760px;">
489
- <a href="#" style="float: right" onclick="nxs_rfLog();return false;" class="NXSButton" id="nxs_clearLog">Refresh</a>
490
-
491
- Showing last 150 records <a href="#" onclick="nxs_clLog();return false;" class="NXSButton" id="nxs_clearLog">Clear Log</a><br/><br/>
492
- <div style="overflow: auto; border: 1px solid #999; width: 750px; height: 600px; font-size: 11px;" class="logDiv" id="nxslogDiv">
493
- <?php //$logInfo = maybe_unserialize(get_option('NS_SNAutoPosterLog'));
494
- $logInfo = nxs_getnxsLog();
495
- if (is_array($logInfo))
496
- foreach (array_reverse($logInfo) as $logline) {
497
- if ($logline['type']=='E') $actSt = "color:#FF0000;"; elseif ($logline['type']=='M') $actSt = "color:#585858;"; elseif ($logline['type']=='BG') $actSt = "color:#008000; font-weight:bold;";
498
- elseif ($logline['type']=='I') $actSt = "color:#0000FF;"; elseif ($logline['type']=='W') $actSt = "color:#DB7224;"; elseif ($logline['type']=='BI') $actSt = "color:#0000FF; font-weight:bold;";
499
- elseif ($logline['type']=='GR') $actSt = "color:#008080;"; elseif ($logline['type']=='S') $actSt = "color:#005800; font-weight:bold;"; else $actSt = "color:#585858;";
500
- if ($logline['type']=='E') $msgSt = "color:#FF0000;"; elseif ($logline['type']=='BG') $msgSt = "color:#008000; font-weight:bold;"; else $msgSt = "color:#585858;";
501
- if ($logline['nt']!='') $ntInfo = ' ['.$logline['nt'].'] '; else $ntInfo = '';
502
- echo '<snap style="color:#008000">['.$logline['date'].']</snap> - <snap style="'.$actSt.'">['.$logline['act'].']</snap>'.$ntInfo.'- <snap style="'.$msgSt.'">'.$logline['msg'].'</snap> '.$logline['extInfo'].'<br/>';
503
- } ?>
504
- </div>
505
- </div>
506
- </div>
507
-
508
- <div id="nsx_tab4" class="nsx_tab_content">
509
-
510
- <div style="max-width:1000px;">
511
-
512
- <h3> Setup/Installation/Configuration Instructions </h3>
513
- <table style="max-width:1000px"><tr><td valign="top" width="250">
514
-
515
-
516
-
517
- <div style="margin:0 25px 0 0; line-height: 24px;">
518
-
519
- <a style="background-image:url(<?php echo $nxs_plurl; ?>img/led/application_form.png) !important;" class="nxs_icon16" target="_parent" href="http://www.nextscripts.com/installation-of-social-networks-auto-poster-for-wordpress/">Plugin Setup/Installation</a>
520
- <br/>
521
- &nbsp;&nbsp;&nbsp;&nbsp;<a style="background-image:url(<?php echo $nxs_plurl; ?>img/led/facebook.png) !important;" class="nxs_icon16" target="_parent" href="http://www.nextscripts.com/setup-installation-facebook-social-networks-auto-poster-wordpress/"> Facebook </a>
522
- <br/>
523
- &nbsp;&nbsp;&nbsp;&nbsp;<a style="background-image:url(<?php echo $nxs_plurl; ?>img/led/twitter.png) !important;" class="nxs_icon16" target="_parent" href="http://www.nextscripts.com/setup-installation-twitter-social-networks-auto-poster-wordpress/"> Twitter </a>
524
- <br/>
525
- &nbsp;&nbsp;&nbsp;&nbsp;<a style="background-image:url(<?php echo $nxs_plurl; ?>img/led/googleplus.png) !important;" class="nxs_icon16" target="_parent" href="http://www.nextscripts.com/setup-installation-google-plus-social-networks-auto-poster-wordpress/"> Google+ </a>
526
- <br>
527
- &nbsp;&nbsp;&nbsp;&nbsp;<a style="background-image:url(<?php echo $nxs_plurl; ?>img/led/pinterest.png) !important;" class="nxs_icon16" target="_parent" href="http://www.nextscripts.com/setup-installation-pinterest-social-networks-auto-poster-wordpress/"> Pinterest</a>
528
- <br>
529
- &nbsp;&nbsp;&nbsp;&nbsp;<a style="background-image:url(<?php echo $nxs_plurl; ?>img/led/tumblr.png) !important;" class="nxs_icon16" target="_parent" href="http://www.nextscripts.com/setup-installation-tumblr-social-networks-auto-poster-wordpress/"> Tumblr </a>
530
- <br>
531
- &nbsp;&nbsp;&nbsp;&nbsp;<a style="background-image:url(<?php echo $nxs_plurl; ?>img/led/linkedin.png) !important;" class="nxs_icon16" target="_parent" href="http://www.nextscripts.com/setup-installation-linkedin-social-networks-auto-poster-wordpress/"> LinkedIn </a>
532
- <br>
533
- &nbsp;&nbsp;&nbsp;&nbsp;<a style="background-image:url(<?php echo $nxs_plurl; ?>img/led/blogger.png) !important;" class="nxs_icon16" target="_parent" href="http://www.nextscripts.com/setup-installation-blogger-social-networks-auto-poster-wordpress/"> Blogger </a>
534
- <br>
535
- &nbsp;&nbsp;&nbsp;&nbsp;<a style="background-image:url(<?php echo $nxs_plurl; ?>img/led/delicious.png) !important;" class="nxs_icon16" target="_parent" href="http://www.nextscripts.com/setup-installation-delicious-social-networks-auto-poster-wordpress/"> Delicious </a>
536
- <br>
537
- &nbsp;&nbsp;&nbsp;&nbsp;<a style="background-image:url(<?php echo $nxs_plurl; ?>img/led/blogcom.png) !important;" class="nxs_icon16" target="_parent" href="http://www.nextscripts.com/setup-installation-wp-based-social-networks-auto-poster-wordpress/"> Wordpress.com/Blog.com</a>
538
- <br/><br/>
539
- <a style="font-weight: normal; font-size: 16px; line-height: 24px;" target="_blank" href="http://www.nextscripts.com/faq">FAQ</a><br/>
540
- <a style="font-weight: normal; font-size: 16px; line-height: 24px;" target="_blank" href="http://www.nextscripts.com/troubleshooting-social-networks-auto-poster">Troubleshooting FAQ</a>
541
-
542
- </div>
543
-
544
- </td>
545
- <td valign="top" style="font-size: 14px;">
546
- <h3 style="margin-top: 0px;">Have questions/suggestions?</h3>
547
- <a style="font-weight: normal; font-size: 18px; line-height: 24px;" target="_blank" href="http://www.nextscripts.com/contact-us">===&gt; Contact us &lt;===</a> <br/>
548
- <h3 style="margin-top: 20px;">Have troubles/problems/found a bug?</h3>
549
- <a style="font-weight: normal; font-size: 18px; line-height: 24px;" target="_blank" href="http://www.nextscripts.com/support">===&gt; Open support ticket &lt;===</a>
550
-
551
-
552
- <h3 style="margin-top: 30px;">Like the Plugin? Would you like to support developers?</h3>
553
- <div style="line-height: 24px;">
554
- <b>Here is what you can do:</b><br/>
555
- <?php if(function_exists('doPostToGooglePlus')) { ?><s><?php } ?><img src="<?php echo $nxs_plurl; ?>img/snap-icon12.png"/> Get the <a href="http://www.nextscripts.com/social-networks-auto-poster-for-wp-multiple-accounts/#getit">"Pro" Edition</a>. You will be able to add several accounts for each network as well as post to Google+, Pinterest and LinkedIn company pages.<?php if(function_exists('doPostToGooglePlus')) { ?></s> <i>Done! Thank you!</i><?php } ?><br/>
556
- <img src="<?php echo $nxs_plurl; ?>img/snap-icon12.png"/> Rate the plugin 5 stars at <a href="http://wordpress.org/extend/plugins/social-networks-auto-poster-facebook-twitter-g/">wordpress.org page</a>.<br/>
557
- <img src="<?php echo $nxs_plurl; ?>img/snap-icon12.png"/> <a href="<?php echo admin_url(); ?>post-new.php">Write a blogpost</a> about the plugin and don't forget to auto-post this blogpost to all your social networks ;-).<br/>
558
- </div>
559
- </td></tr></table>
560
-
561
- <br/><br/>
562
- <h3>Solutions for some common problems </h3>
563
-
564
- <b>Problem:</b> <i>I can't create an app on developers.facebook.com/apps</i>. When I am trying to enter that page it redirects me back to my account?<br/>
565
- <b>Solution:</b> Facebook "Business" or "Advertising" accounts can't manage apps. This is an unavoidable Facebook limitation. Only real user accounts are able to create and manage apps. Please login to Facebook as a personal account to be able to create app. You will need to add your personal Facebook account as "Administrator" to your page..
566
- <br/><br/>
567
- <b>Problem:</b> When I follow the instructions to allow plugin authorize/access to my Facebook/Twitter/Tumblr/LinkedIn account, it redirects me to my <i>"Google Analytics for WordPress Configuration"</i> page.<br/>
568
- <b>Solution:</b> It's a known issue. Google Analytics plugin hijacks the authorization workflow. Please temporary deactivate Google Analytics plugin, do all authorizations and then activate it back. There are some other plugins ("Blog Promoter", "Tweet Old Post", etc.. ) that could also hijack the authorization. Solution is the same: Deactivate the other plugin, do authorization, reactivate it.
569
- <br/><br/>
570
-
571
- <b>Problem:</b> Plugin breaks <i>NextGen galleries</i>. I got error <i>"Fatal error: Class 'nggMeta' not found"</i>.<br/>
572
- <b>Solution:</b>There is a known bug in NextGen galleries that was reported back to them over a year ago, but still hasn't been fixed. Any plugin calling standard wordpress function apply_filters('the_content' will break NextGen galleries.
573
- We have posted the solution here: <a target="_blank" href="http://wordpress.org/support/topic/plugin-nextgen-gallery-fatal-error-insert-picture-in-event?replies=4">http://wordpress.org/support/topic/plugin-nextgen-gallery-fatal-error-insert-picture-in-event?replies=4</a>
574
- <br/><br/>
575
-
576
- <b>Problem:</b> When I publish a new post to <i>Facebook</i> I am getting this weird Twitter Error:<i> Error:(#100) The status you are trying to publish is a duplicate of, or too similar to, one that we recently posted to Twitter</i>.<br/>
577
- <b>Solution:</b> Your Facebook is already auto-posting to Twitter. When it sees the same tweet made by our plugin it fails with this error. You need to either unlink your Facebook from Twitter or disable Twitter auto-posting from our plugin.
578
- If you decide to unlink your Facebook from Twitter:<br/>
579
- Go to http://www.facebook.com/twitter and remove the link to twitter from the affected wall (Click on "Unlink from Twitter").
580
- <br/><br/>
581
-
582
- <b>Problem:</b> Facebook Error: <i>"The user hasn't authorized the application to perform this action"</i><br/>
583
- <b>Solution:</b>
584
- The most popular cause for "The user hasn't authorized the application to perform this action" is that your domain is not configured for your app.<br/>
585
- Please read and carefully follow the installation instructions:<br/>
586
- You missed/messed steps 1.4 and 1.5 from Facebook section:<br/>
587
- 4. Click "Website", enter your website URL<br/>
588
- 5. Enter your domain to the App Domain. Domain should be the same domain from URL that you have entered to the "Website" during the step 4.
589
- <br/><br/>
590
-
591
-
592
- <b>Problem:</b> Facebook Error: <i>SSL certificate problem, verify that the CA cert is OK. Details:error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed</i><br/>
593
- <b>Solution:</b>
594
- This error means that cURL is misconfigured on your server. Most probably curl ssl(open SSL) is broken or it simply can't find the certificates at the pointed location. Please contact your hosting provider and ask them to fix this.<br/>
595
- http://curl.haxx.se/docs/sslcerts.html<br/>
596
- Unlike Twitter or Google+ that could be automatically switched to non-SSL connections in such cases, Facebook requires to be accessed by SSL at all times.
597
-
598
- <br/><br/>
599
-
600
- <b>Problem:</b> Twitter Error: <i>{"error":"Read-only application cannot POST","request":"/1/statuses/update.json"}</i><br/>
601
- <b>Solution:</b>You just need to follow the instructions step by step. Please don't skip anything.<br/>
602
- <br/>
603
- Please see #4 and #5 for Twitter:<br/>
604
- <br/>
605
- 4. Click "Settings" tab. Scroll to the "Application type", change Access level from "Read Only" to <b>"Read and Write"</b>. Click "Update this Twitter application settings".<br/>
606
- 5. Come back to "Details" tab. Scroll to the "Your access token" and click "Create my access token" button. Refresh page and notice "Access token" and "Access token secret". Make sure you have <b>"Read and Write"</b> access level.<br/>
607
-
608
- </div>
609
-
610
- </div>
611
- </div>
612
-
613
- </form>
614
-
615
- <form method="post" enctype="multipart/form-data" id="nsStFormUpl" action="<?php echo $nxs_snapThisPageUrl?>">
616
- <input type="file" accept="text/plain" onchange="jQuery('#nsStFormUpl').submit();" id="impFileSettings_button" name="impFileSettings_button" style="display: block; visibility: hidden; width: 0; height: 0;" size="chars">
617
- <input type="hidden" value="1" name="upload_NS_SNAutoPoster_settings" /> <input value="'" type="hidden" name="nxs_mqTest" /> <?php wp_nonce_field( 'nxsChkUpl', 'nxsChkUpl_wpnonce' ); ?>
618
- </form>
619
-
620
- <br/>&nbsp;<br/> <?php
621
- }
622
- function showSNAutoPosterOptionsPagex() { global $nxs_snapAvNts, $nxs_snapThisPageUrl, $nxsOne, $nxs_plurl, $nxs_isWPMU; $nxsOne = ''; $options = $this->nxs_options; ?>
623
- <br/><br/><br/>This version of the plugin is not compatible with <b>Wordpress Multisite Edition</b>. Please contact your Network Admin for the upgrade. <?php }
624
-
625
- function NS_SNAP_ShowPageTop(){ global $nxs_snapAvNts, $nxs_snapThisPageUrl, $nxsOne, $nxs_plurl, $nxs_isWPMU; $nxsOne = ''; $options = $this->nxs_options;
626
- if ($_GET['page']=='NextScripts_SNAP.php' && isset($_GET['do']) && $_GET['do']=='h'){ nxs_do_this_hourly(); die(); }
627
- $nxsOne = NextScripts_SNAP_Version; if (defined('NXSAPIVER')) $nxsOne .= " (<span id='nxsAPIUpd'>API</span> Version: ".NXSAPIVER.")"; ?>
628
-
629
- <div style="float:right; padding-top: 10px; padding-right: 10px;">
630
- <div style="float:right; text-align: center;"><a target="_blank" href="http://www.nextscripts.com"><img src="<?php echo $nxs_plurl; ?>img/Next_Scripts_Logo2.1-HOR-100px.png"></a><br/>
631
- <a style="font-weight: normal; font-size: 16px; line-height: 24px;" target="_blank" href="http://www.nextscripts.com/support">[<?php _e('Contact support', 'nxs_snap'); ?>]</a>
632
- <?php if(!$options['isMA']) { ?><br/> <span style="color:#800000;"><?php _e('Ready to to Upgrade to Multiple Accounts Edition<br/> and get Google+ and Pinterest Auto-Posting?', 'nxs_snap'); ?></span>
633
- <?php if(function_exists('nxsDoLic_ajax')) { ?> <br/><a style="font-weight: normal; font-size: 12px; line-height: 24px;" target="_blank" id="showLic" href="#">[<?php _e('Enter your Activation Key', 'nxs_snap'); ?>]</a>&nbsp;&nbsp;&nbsp;&nbsp; <?php } ?>
634
- <a target="_blank" href="http://www.nextscripts.com/social-networks-auto-poster-for-wp-multiple-accounts#getit">[<?php _e('Get It here', 'nxs_snap'); ?>]</a> <?php } ?>
635
- </div>
636
- <div id="showLicForm"><span class="nxspButton bClose"><span>X</span></span><div style="position: absolute; right: 10px; top:10px; font-family: 'News Cycle'; font-size: 34px; font-weight: lighter;"><?php _e('Activation', 'nxs_snap'); ?></div>
637
- <br/><br/>
638
- <h3><?php _e('Multiple Accounts Edition and Google+ and Pinterest Auto-Posting', 'nxs_snap'); ?></h3><br/><?php _e('You can find your key on this page', 'nxs_snap'); ?>: <a href="http://www.nextscripts.com/mypage">http://www.nextscripts.com/mypage</a>
639
- <br/><br/> <?php _e('Enter your Key', 'nxs_snap'); ?>: <input name="eLic" id="eLic" style="width: 50%;"/>
640
- <input type="button" class="button-primary" name="eLicDo" onclick="doLic();" value="Enter" />
641
- <br/><br/><?php _e('Your plugin will be automatically upgraded', 'nxs_snap'); ?>. <?php wp_nonce_field( 'doLic', 'doLic_wpnonce' ); ?>
642
- </div>
643
- </div>
644
-
645
-
646
- <div class=wrap><h2><?php _e('Next Scripts: Social Networks Auto Poster Options', 'nxs_snap'); ?></h2> <?php _e('Plugin Version', 'nxs_snap'); ?>: <span style="color:#008000;font-weight: bold;"><?php echo $nxsOne; ?></span> <?php if($options['isMA']) { ?> [Pro - Multiple Accounts Edition]&nbsp;&nbsp;<?php } else {?>
647
- <span style="color:#800000; font-weight: bold;">[Single Accounts Edition]</span>
648
- <?php if(!$nxs_isWPMU) { ?>
649
- - <a target="_blank" href="http://www.nextscripts.com/social-networks-auto-poster-for-wp-multiple-accounts"><?php _e('Get', 'nxs_snap'); ?> PRO - Multiple Accounts Edition</a><br/><br/>
650
-
651
- <?php _e('Here you can setup "Social Networks Auto Poster".', 'nxs_snap'); ?><br/> <?php _e('You can start by clicking "Add new account" button and choosing the Social Network you would like to add.', 'nxs_snap'); ?><?php }} ?><br/>
652
- <?php $disabled_functions = @ini_get('disable_functions');
653
- if (!function_exists('curl_init')) {
654
- echo ("<br/><b style='font-size:16px; color:red;'>Error: No CURL Found</b> - <i style='font-size:12px; color:red;'>Social Networks AutoPoster needs the CURL PHP extension. Please install it or contact your hosting company to install it.</i><br/><br/>");
655
- }
656
- if (stripos($disabled_functions, 'curl_exec')!==false) {
657
- echo ("<br/><b style='font-size:16px; color:red;'>curl_exec function is disabled in php.ini</b> - <i style='font-size:12px; color:red;'>Social Networks AutoPoster needs the CURL PHP extension. Please enable it or contact your hosting company to enable it.</i><br/><br/>");
658
- }
659
- /*
660
- if ((defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE==true) || (defined('MULTISITE') && MULTISITE==true) ) {
661
- echo "<br/><br/><br/><b style=\"font-size:16px; color:red;\">Sorry, we do not support Multiuser Wordpress at this time</b>"; return;
662
- }
663
- */
664
- ?>
665
-
666
- <?php if (function_exists('yoast_analytics')) { $plgnsLink = admin_url().'/plugins.php' ?>
667
- <div class="error" id="message"><p><strong><?php _e('You have Google Analytics Plugin installed and activated.', 'nxs_snap'); ?></strong> <?php _e('This plugin hijacks the authorization workflow.', 'nxs_snap'); ?>
668
- <?php printf( __( 'Please temporary <a href="%s">deactivate</a> Google Analytics plugin, do all authorizations and then activate it back.', 'nxs_snap' ), $plgnsLink ); ?></div>
669
- <?php }
670
- }
671
-
672
- function NS_SNAP_SavePostMetaTags($id) { global $nxs_snapAvNts, $plgn_NS_SNAutoPoster; if (count($_POST)<1 || !isset($_POST["snapEdIT"]) || empty($_POST["snapEdIT"])) return;
673
- if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options; // echo "| NS_SNAP_SavePostMetaTags - ".$id." |";
674
- $post = get_post($id); //prr($post); die();
675
- if ($post->post_type=='revision' && $post->post_status=='inherit' && $post->post_parent!='0') return;
676
- if (get_magic_quotes_gpc() || ( isset($_POST['nxs_mqTest']) && $_POST['nxs_mqTest']=="\'")){ array_walk_recursive($_POST, 'nsx_stripSlashes'); }
677
- $snap_isAutoPosted = get_post_meta($id, 'snap_isAutoPosted', true); if ($snap_isAutoPosted=='1' && $post->post_status=='future') { delete_post_meta($id, 'snap_isAutoPosted'); add_post_meta($id, 'snap_isAutoPosted', '2'); }
678
- delete_post_meta($id, 'snapEdIT'); add_post_meta($id, 'snapEdIT', '1' );
679
- foreach ($nxs_snapAvNts as $avNt) {
680
- if (count($options[$avNt['lcode']])>0 && isset($_POST[$avNt['lcode']]) && count($_POST[$avNt['lcode']])>0) { $savedMeta = maybe_unserialize(get_post_meta($id, 'snap'.$avNt['code'], true));
681
- if(is_array($_POST[$avNt['lcode']])) { $ii=0;
682
- foreach ($_POST[$avNt['lcode']] as $pst ) { //echo "#############################################################################"; prr($pst);
683
- if (is_array($pst) && empty( $pst['do'.$avNt['code']]) && empty($_POST[$avNt['lcode']][$ii]['do'.$avNt['code']])) $_POST[$avNt['lcode']][$ii]['do'.$avNt['code']]= 0; $ii++;
684
- }
685
- } $newMeta = $_POST[$avNt['lcode']];
686
- if (is_array($savedMeta) && is_array($newMeta)) $newMeta = nxsMergeArraysOV($savedMeta, $newMeta); // echo "##### ".$id."| snap".$avNt['code']; prr($savedMeta); echo "||"; prr($newMeta);// $newMeta = 'AAA';
687
- delete_post_meta($id, 'snap'.$avNt['code']); add_post_meta($id, 'snap'.$avNt['code'], serialize($newMeta));
688
- }
689
- }
690
- //prr($_POST);
691
- }
692
-
693
- function NS_SNAP_AddPostMetaTags() { global $post, $nxs_snapAvNts, $plgn_NS_SNAutoPoster; $post_id = $post; if (is_object($post_id)) $post_id = $post_id->ID; if (!is_object($post)) $post = get_post($post_id);
694
- if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
695
- ?>
696
- <div id="postftfp" class="postbox"><div class="inside"><div id="postftfp">
697
- <style type="text/css">div#popShAtt {display: none; position: absolute; width: 600px; padding: 10px; background: #eeeeee; color: #000000; border: 1px solid #1a1a1a; font-size: 90%; }
698
- .underdash {border-bottom: 1px #21759B dashed; text-decoration:none;}
699
- .underdash a:hover {border-bottom: 1px #21759B dashed}
700
- </style>
701
-
702
- <input value="1" type="hidden" name="snapEdIT" /> <input value="'" type="hidden" name="nxs_mqTest" />
703
- <div class="popShAtt" style="width: 200px;" id="popShAttSV"><?php _e('If you made any changes to the format, please "Update" the post before reposting', 'nxs_snap'); ?></div>
704
- <?php if($post->post_status != "publish" ) { ?>
705
- <div style="float: right;"> <input type="hidden" id="nxsLockIt" value="0" />
706
- <a href="#" onclick="jQuery('#nxsLockIt').val('1'); jQuery('.nxsGrpDoChb').attr('checked','checked'); return false;"><?php _e('Check All', 'nxs_snap'); ?></a>&nbsp;<a href="#" onclick="jQuery('#nxsLockIt').val('1');jQuery('.nxsGrpDoChb').removeAttr('checked'); return false;"><?php _e('Uncheck All', 'nxs_snap'); ?></a>
707
- </div>
708
- <?php } ?>
709
- <table style="margin-bottom:40px; clear:both;" width="100%" border="0"><?php
710
- foreach ($nxs_snapAvNts as $avNt) { $clName = 'nxs_snapClass'.$avNt['code'];
711
- if ( isset($avNt['lcode']) && isset($options[$avNt['lcode']]) && count($options[$avNt['lcode']])>0) { $ntClInst = new $clName(); $ntClInst->showEdPostNTSettings($options[$avNt['lcode']], $post); }
712
- }
713
- ?></table></div></div></div> <?php
714
- }
715
- //## Add MetaBox to Post->Edit
716
- function NS_SNAP_addCustomBoxes() { add_meta_box( 'NS_SNAP_AddPostMetaTags', __( 'NextScripts: Social Networks Auto Poster - Post Options', 'nxs_snap' ), array($this, 'NS_SNAP_AddPostMetaTags'), 'post' );
717
- global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
718
-
719
- if ($options['useForPages']=='1') add_meta_box( 'NS_SNAP_AddPostMetaTags', __( 'NextScripts: Social Networks Auto Poster - Post Options', 'nxs_snap' ), array($this, 'NS_SNAP_AddPostMetaTags'), 'page' );
720
-
721
- $args=array('public'=>true, '_builtin'=>false); $output = 'names'; $operator = 'and'; $post_types = array(); if (function_exists('get_post_types')) $post_types=get_post_types($args, $output, $operator);
722
- if ((isset($options['nxsCPTSeld'])) && $options['nxsCPTSeld']!='') $nxsCPTSeld = unserialize($options['nxsCPTSeld']); else $nxsCPTSeld = array_keys($post_types); //prr($nxsCPTSeld); prr($post_types);
723
- foreach ($post_types as $cptID=>$cptName) if (in_array($cptID, $nxsCPTSeld)){
724
- add_meta_box( 'NS_SNAP_AddPostMetaTags', __('NextScripts: Social Networks Auto Poster - Post Options', 'nxs_snap'), array($this, 'NS_SNAP_AddPostMetaTags'), $cptID );
725
- }
726
- }
727
- }
728
- }
729
 
730
- if (isset($_GET['page']) && $_GET['page']=='NextScripts_SNAP.php' && isset($_GET['do']) && $_GET['do']=='test'){ echo "Testting... cURL<br/>";
 
 
 
 
 
 
731
  nxs_cURLTest("http://www.google.com/intl/en/contact/", "HTTP to Google", "Mountain View, CA");
732
  nxs_cURLTest("https://www.google.com/intl/en/contact/", "HTTPS to Google", "Mountain View, CA");
733
  nxs_cURLTest("https://www.facebook.com/", "HTTPS to Facebook", 'id="facebook"');
734
  nxs_cURLTest("https://graph.facebook.com/nextscripts", "HTTPS to API (Graph) Facebook", '270851199672443');
735
  nxs_cURLTest("https://www.linkedin.com/", "HTTPS to LinkedIn", 'rel="canonical" href="https://www.linkedin.com/"');
736
  nxs_cURLTest("https://twitter.com/", "HTTPS to Twitter", '<link rel="canonical" href="https://twitter.com/">');
737
- nxs_cURLTest("http://pinterest.com/", "HTTPS to Pinterest", 'content="Pinterest"');
738
  nxs_cURLTest("http://www.livejournal.com/", "HTTP to LiveJournal", '1999 LiveJournal');
739
  die('Done');
740
  }
741
-
742
- if (class_exists("NS_SNAutoPoster")) { nxs_checkAddLogTable(); $plgn_NS_SNAutoPoster = new NS_SNAutoPoster(); }
743
  //## Delete Account
744
- if (!function_exists("ns_delNT_ajax")) { function ns_delNT_ajax(){ check_ajax_referer('nsDN'); $indx = (int)$_POST['id'];
745
  global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
746
  unset($options[$_POST['nt']][$indx]); if (is_array($options)) update_option('NS_SNAutoPoster', $options);
747
  }}
@@ -750,7 +51,7 @@ if (!function_exists("nsAuthFBSv_ajax")) { function nsAuthFBSv_ajax() { check_aj
750
  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);
751
  }}
752
  if (!function_exists("nsGetBoards_ajax")) {
753
- function nsGetBoards_ajax() { global $nxs_gCookiesArr; check_ajax_referer('getBoards'); global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
754
  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']);
755
  $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";}
756
  $gPNBoards = doGetBoardsFromPinterest(); $options['pn'][$_POST['ii']]['pnBoardsList'] = base64_encode($gPNBoards);
@@ -758,8 +59,30 @@ if (!function_exists("nsGetBoards_ajax")) {
758
  }
759
  }
760
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
761
  if (!function_exists("nsGetGPCats_ajax")) {
762
- function nsGetGPCats_ajax() { global $nxs_gCookiesArr; check_ajax_referer('getGPCats'); global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
763
  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']);
764
  $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";}
765
  $gGPCCats = doGetCCatsFromGooglePlus($_POST['c']); $options['gp'][$_POST['ii']]['gpCCatsList'] = base64_encode($gGPCCats);
@@ -767,19 +90,43 @@ if (!function_exists("nsGetGPCats_ajax")) {
767
  }
768
  }
769
  if (!function_exists("nsGetWLBoards_ajax")) {
770
- function nsGetWLBoards_ajax() { global $nxs_gCookiesArr; check_ajax_referer('getWLBoards'); global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
771
  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']);
772
  $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";}
773
  $gWLBoards = doGetBoardsFromWaNeLo(); $options['wl'][$_POST['ii']]['wlBoardsList'] = base64_encode($gWLBoards);
774
  $options['wl'][$_POST['ii']]['wlSvC'] = serialize($nxs_gCookiesArr); if (is_array($options)) update_option('NS_SNAutoPoster', $options); echo $gWLBoards; die();
775
  }
776
  }
777
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
778
  if (!function_exists("nxs_clLgo_ajax")) { function nxs_clLgo_ajax() { check_ajax_referer('nxsSsPageWPN'); global $wpdb;
779
  //update_option('NS_SNAutoPosterLog', '');
780
  $wpdb->query( 'DELETE FROM '.$wpdb->prefix . 'nxs_log' ); echo "OK";
781
  }}
782
-
783
  if (!function_exists("nxs_rfLgo_ajax")) { function nxs_rfLgo_ajax() { check_ajax_referer('nxsSsPageWPN'); echo "Y:";
784
  //$log = get_option('NS_SNAutoPosterLog'); $logInfo = maybe_unserialize(get_option('NS_SNAutoPosterLog'));
785
  $logInfo = nxs_getnxsLog();
@@ -792,27 +139,27 @@ if (!function_exists("nxs_rfLgo_ajax")) { function nxs_rfLgo_ajax() { check_ajax
792
  echo '<snap style="color:#008000">['.$logline['date'].']</snap> - <snap style="'.$actSt.'">['.$logline['act'].']</snap>'.$ntInfo.'- <snap style="'.$msgSt.'">'.$logline['msg'].'</snap> '.$logline['extInfo'].'<br/>';
793
  }
794
  }}
795
-
796
  //## Initialize the admin panel if the plugin has been activated
797
- 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;
798
  add_menu_page('Social Networks Auto Poster', 'Social Networks Auto Poster', 'manage_options', basename(__FILE__), array(&$plgn_NS_SNAutoPoster, 'showSNAP_WPMU_OptionsPage'), $nxs_plurl.'img/snap-icon12.png'); }}
799
  //## Initialize the admin panel if the plugin has been activated
800
- 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;
801
- if (function_exists('add_options_page')) { add_options_page('Social Networks Auto Poster',
802
- '<img src="'.$nxs_plurl.'img/snap-icon12.png"/><span style="color:#287A0A">{SNAP}</span> Social Networks Auto Poster', 'manage_options', basename(__FILE__), array(&$plgn_NS_SNAutoPoster, 'showSNAutoPosterOptionsPage'));
803
  }}}
804
  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;
805
- if (function_exists('add_options_page')) { add_options_page('Social Networks Auto Poster',
806
- '<img src="'.$nxs_plurl.'img/snap-icon12.png"/><span style="color:#287A0A">{SNAP}</span> Social Networks Auto Poster', 'manage_options', basename(__FILE__), array(&$plgn_NS_SNAutoPoster, 'showSNAutoPosterOptionsPagex'));
807
  }}}
808
-
809
  //## Main Function to Post
810
  if (!function_exists("nxs_snapLogPublishTo")) { function nxs_snapLogPublishTo( $new_status, $old_status, $post ) {
811
- if ( $old_status!='publish' && $new_status == 'publish' ) nxs_addToLogN('BG', "*** ID: {$post->ID}, Type: {$post->post_type}", '', ' Status Changed: '."{$old_status}_to_{$new_status}".'. Autopost requested.');
812
  }}
813
  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);
814
- if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
815
- if(is_object($postArr)) $postID = $postArr->ID; else { $postID = $postArr; $postArr = get_post($postID); } $isPost = isset($_POST["snapEdIT"]); $post = get_post($postID);
 
 
816
  //nxs_addToLogN('BG', 'Post Status Changed', '', '-=## Autopost requested.'.($blog_id>1?'BlogID:'.$blog_id:'').' PostID:('.$postID.') Post Type: '.$post->post_type.' ##=-');
817
  $args=array('public'=>true, '_builtin'=>false); $output = 'names'; $operator = 'and'; $post_types = array(); if (function_exists('get_post_types')) $post_types=get_post_types($args, $output, $operator);
818
  if ( isset($options['nxsCPTSeld']) && $options['nxsCPTSeld']!='') $nxsCPTSeld = unserialize($options['nxsCPTSeld']); else $nxsCPTSeld = array(); // $nxsCPTSeld = array_keys($post_types); - why we needed it?
@@ -825,8 +172,8 @@ if (!function_exists("nxs_snapPublishTo")) { function nxs_snapPublishTo($postArr
825
  if (function_exists('nxs_doSMAS2')) { nxs_doSMAS2($postArr, $type, $aj); return; } else {
826
  $options = $plgn_NS_SNAutoPoster->nxs_options; $ltype=strtolower($type);
827
  if ($nxs_tpWMPU=='S') { switch_to_blog(1); $plgn_NS_SNAutoPoster = new NS_SNAutoPoster(); $options = $plgn_NS_SNAutoPoster->nxs_options; restore_current_blog(); }
828
- if (!isset($options['nxsHTDP']) || $options['nxsHTDP']=='S') { if(isset($_POST["snapEdIT"]) && $_POST["snapEdIT"]=='1') { $publtype='S'; $delay = rand(2,10); } else $publtype='A'; } else $publtype = 'I';
829
- nxs_addToLogN('BG', 'Start =- ', '', '------=========#### NEW AUTO-POST REQUEST '.($blog_id>1?'BlogID:'.$blog_id:'').' PostID:('.$postID.') '.($publtype=='S'?'Scheduled +'.$delay:($publtype=='A'?'Non Human':'Immediate')).' ####=========------');
830
 
831
  $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted=='1') { nxs_addToLogN('W', 'Skipped', '', 'Already Autoposted - Post ID:('.$postID.')' ); return; }
832
  $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);
@@ -836,7 +183,7 @@ if (!function_exists("nxs_snapPublishTo")) { function nxs_snapPublishTo($postArr
836
 
837
  foreach ($nxs_snapAvNts as $avNt) {
838
  if (count($options[$avNt['lcode']])>0) { $clName = 'nxs_snapClass'.$avNt['code'];
839
- if ($isPost && isset($_POST[$avNt['lcode']])) $po = $_POST[$avNt['lcode']]; else { $po = get_post_meta($postID, 'snap'.$avNt['code'], true); $po = maybe_unserialize($po);}
840
 
841
  if (isset($po) && is_array($po)) $isPostMeta = true; else { $isPostMeta = false; $po = $options[$avNt['lcode']]; }
842
  delete_post_meta($postID, 'snap_isAutoPosted'); add_post_meta($postID, 'snap_isAutoPosted', '1');
@@ -844,24 +191,25 @@ if (!function_exists("nxs_snapPublishTo")) { function nxs_snapPublishTo($postArr
844
  $optMt = $options[$avNt['lcode']][0]; if ($isPostMeta) { $ntClInst = new $clName(); $optMt = $ntClInst->adjMetaOpt($optMt, $po[0]); }
845
  if ($snap_isEdIT!='1') { $doPost = true;
846
  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;}}
847
- if (!$doPost) { nxs_addToLogN('I', 'Skipped', $avNt['name'].' ('.$optMt['nName'].')', '[Non-Human Post] - Individual Category Excluded - Post ID:('.$postID.')' ); return; }
848
  }
849
  }
850
  if ($optMt['do'.$avNt['code']]=='1') { $optMt['ii'] = 0;
851
  if ($publtype=='A' && ($optMt['nMin']>0 || $optMt['nHrs']>0 || $optMt['nTime']!='')) $publtype='S';
852
  if ($publtype=='S') { if (isset($optMt['nHrs']) && isset($optMt['nMin']) && ($optMt['nHrs']>0 || $optMt['nMin']>0) ) { $delay = $optMt['nMin']*60+$optMt['nHrs']*3600;
853
  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':'').')' );
854
- } else $delay = rand(2,10); $optMt['timeToRun'] = time()+$delay; $args = array($postID, $optMt); wp_schedule_single_event($optMt['timeToRun'],'ns_doPublishTo'.$avNt['code'], $args);
 
 
 
855
  nxs_addToLogN('BI', 'Scheduled', $avNt['name'].' ('.$optMt['nName'].')', ' PostID:('.$postID.')' );
856
  } else { $fname = 'nxs_doPublishTo'.$avNt['code']; $fname($postID, $optMt); }
857
  } else { nxs_addToLogN('GR', 'Skipped', $avNt['name'].' ('.$optMt['nName'].')', '-=[Unchecked Account]=- - PostID:'.$postID.'' ); }
858
  }
859
- } } } else { nxs_addToLogN('I', 'Skipped', '', 'Excluded Post Type:(Post ID: '.$postID.')' ); return; }
860
  if ($isS) restore_current_blog();
861
  }}
862
 
863
- //## AJAX to Post to Google+
864
-
865
  //## Add settings link to plugins list
866
  if (!function_exists("ns_add_settings_link")) { function ns_add_settings_link($links, $file) {
867
  static $this_plugin;
@@ -874,109 +222,38 @@ if (!function_exists("ns_add_settings_link")) { function ns_add_settings_link($l
874
  }}
875
  //## Actions and filters
876
 
877
- //## Process Spin
878
- if (!function_exists("nxs_spinRecursion")) { function nxs_spinRecursion(&$txt, $startCh) { global $nxs_spin_lCh, $nxs_spin_rCh, $nxs_spin_splCh; $startPos = $startCh;
879
- while ($startCh++ < strlen($txt)) {
880
- if (substr($txt, $startCh, strlen($nxs_spin_lCh)) == $nxs_spin_lCh) $txt = nxs_spinRecursion($txt, $startCh);
881
- elseif (substr($txt, $startCh, strlen($nxs_spin_rCh)) == $nxs_spin_rCh) {
882
- $tmpTxt = substr($txt, $startPos+strlen($nxs_spin_lCh), ($startCh - $startPos)-strlen($nxs_spin_rCh));
883
- $toRepl = nxs_spinReplace($tmpTxt); $txt = str_replace($nxs_spin_lCh.$tmpTxt.$nxs_spin_rCh, $toRepl, $txt);
884
- }
885
- } return $txt;
886
- }}
887
- if (!function_exists("nxs_spinReplace")) { function nxs_spinReplace($txt) { global $nxs_spin_splCh; $txt = explode($nxs_spin_splCh, $txt); $out = $txt[mt_rand(0,count($txt)-1)]; return $out; }}
888
- if (!function_exists("nxs_doSpin")) { function nxs_doSpin($msg){ global $nxs_spin_lCh, $nxs_spin_rCh, $nxs_spin_splCh;
889
- $nxs_spin_lCh = '{'; $nxs_spin_rCh='}'; $nxs_spin_splCh='|'; $msg = nxs_spinRecursion($msg, -1); return $msg;
890
- }}
891
-
892
- //## Format Message
893
- if (!function_exists("nsFormatMessage")) { function nsFormatMessage($msg, $postID, $addURLParams=''){ global $ShownAds, $plgn_NS_SNAutoPoster, $nxs_urlLen; $post = get_post($postID); $options = $plgn_NS_SNAutoPoster->nxs_options;
894
- if ($addURLParams=='' && $options['addURLParams']!='') $addURLParams = $options['addURLParams'];
895
- $msg = stripcslashes($msg); if (isset($ShownAds)) $ShownAdsL = $ShownAds; // $msg = htmlspecialchars(stripcslashes($msg));
896
- $msg = nxs_doSpin($msg);
897
- if (preg_match('%URL%', $msg)) { $url = get_permalink($postID); if($addURLParams!='') $url .= (strpos($url,'?')!==false?'&':'?').$addURLParams; $nxs_urlLen = nxs_strLen($url); $msg = str_ireplace("%URL%", $url, $msg);}
898
- if (preg_match('%SURL%', $msg)) { $url = get_permalink($postID); if($addURLParams!='') $url .= (strpos($url,'?')!==false?'&':'?').$addURLParams;
899
- $url = nxs_mkShortURL($url, $postID); $nxs_urlLen = nxs_strLen($url); $msg = str_ireplace("%SURL%", $url, $msg);
900
- }
901
- if (preg_match('%IMG%', $msg)) { $imgURL = nxs_getPostImage($postID); $msg = str_ireplace("%IMG%", $imgURL, $msg); }
902
- if (preg_match('%TITLE%', $msg)) { $title = nxs_doQTrans($post->post_title, $lng); $msg = str_ireplace("%TITLE%", $title, $msg); }
903
- if (preg_match('%STITLE%', $msg)) { $title = nxs_doQTrans($post->post_title, $lng); $title = substr($title, 0, 115); $msg = str_ireplace("%STITLE%", $title, $msg); }
904
- if (preg_match('%AUTHORNAME%', $msg)) { $aun = $post->post_author; $aun = get_the_author_meta('display_name', $aun ); $msg = str_ireplace("%AUTHORNAME%", $aun, $msg);}
905
- if (preg_match('%ANNOUNCE%', $msg)) { $postContent = nxs_doQTrans($post->post_content, $lng);
906
- $postContent = strip_tags(strip_shortcodes(str_ireplace('<!--more-->', '#####!--more--!#####', str_ireplace("&lt;!--more--&gt;", '<!--more-->', $postContent))));
907
- if (stripos($postContent, '#####!--more--!#####')!==false) { $postContentEx = explode('#####!--more--!#####',$postContent); $postContent = $postContentEx[0]; }
908
- else $postContent = nsTrnc($postContent, $options['anounTagLimit']); $msg = str_ireplace("%ANNOUNCE%", $postContent, $msg);
909
- }
910
- if (preg_match('%TEXT%', $msg)) {
911
- if ($post->post_excerpt!="") $excerpt = apply_filters('the_content', nxs_doQTrans($post->post_excerpt, $lng)); else $excerpt= apply_filters('the_content', nxs_doQTrans($post->post_content, $lng));
912
- $excerpt = nsTrnc(strip_tags(strip_shortcodes($excerpt)), 300, " ", "..."); $msg = str_ireplace("%TEXT%", $excerpt, $msg);
913
- }
914
- if (preg_match('%EXCERPT%', $msg)) {
915
- if ($post->post_excerpt!="") $excerpt = apply_filters('the_content', nxs_doQTrans($post->post_excerpt, $lng)); else $excerpt= apply_filters('the_content', nxs_doQTrans($post->post_content, $lng));
916
- $excerpt = nsTrnc(strip_tags(strip_shortcodes($excerpt)), 300, " ", "..."); $msg = str_ireplace("%EXCERPT%", $excerpt, $msg);
917
- }
918
- if (preg_match('%RAWEXTEXT%', $msg)) {
919
- if ($post->post_excerpt!="") $excerpt = nxs_doQTrans($post->post_excerpt, $lng); else $excerpt= nxs_doQTrans($post->post_content, $lng);
920
- $excerpt = nsTrnc(strip_tags(strip_shortcodes($excerpt)), 300, " ", "..."); $msg = str_ireplace("%RAWEXTEXT%", $excerpt, $msg);
921
- }
922
- if (preg_match('%RAWEXCERPT%', $msg)) {
923
- if ($post->post_excerpt!="") $excerpt = nxs_doQTrans($post->post_excerpt, $lng); else $excerpt= nxs_doQTrans($post->post_content, $lng);
924
- $excerpt = nsTrnc(strip_tags(strip_shortcodes($excerpt)), 300, " ", "..."); $msg = str_ireplace("%RAWEXCERPT%", $excerpt, $msg);
925
- }
926
- if (preg_match('%TAGS%', $msg)) { $t = wp_get_object_terms($postID, 'product_tag'); if ( empty($t) || is_wp_error($pt) || !is_array($t) ) $t = wp_get_post_tags($postID);
927
- $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = implode(', ',$tggs); $msg = str_ireplace("%TAGS%", $tags, $msg);
928
- }
929
- if (preg_match('%CATS%', $msg)) { $t = wp_get_post_categories($postID); $cats = array(); foreach($t as $c){ $cat = get_category($c); $cats[] = str_ireplace('&','&amp;',$cat->name); }
930
- $ctts = implode(', ',$cats); $msg = str_ireplace("%CATS%", $ctts, $msg);
931
- }
932
- if (preg_match('%HCATS%', $msg)) { $t = wp_get_post_categories($postID); $cats = array();
933
- foreach($t as $c){ $cat = get_category($c); $cats[] = "#".trim(str_replace(' ','', str_replace(' ', '', trim(str_ireplace('&','',str_ireplace('&amp;','',$cat->name)))))); }
934
- $ctts = implode(', ',$cats); $msg = str_ireplace("%HCATS%", $ctts, $msg);
935
- }
936
- if (preg_match('%HTAGS%', $msg)) { $t = wp_get_object_terms($postID, 'product_tag'); if ( empty($t) || is_wp_error($pt) || !is_array($t) ) $t = wp_get_post_tags($postID);
937
- $tggs = array(); foreach ($t as $tagA) {$tggs[] = "#".trim(str_replace(' ','',preg_replace('/[^a-zA-Z0-9\p{L}\p{N}\s]/u', '', trim(ucwords(str_ireplace('&','',str_ireplace('&amp;','',$tagA->name))))))); }
938
- $tags = implode(', ',$tggs); $msg = str_ireplace("%HTAGS%", $tags, $msg);
939
- }
940
- if (preg_match('%CF-[a-zA-Z0-9]%', $msg)) { $msgA = explode('%CF', $msg); $mout = '';
941
- foreach ($msgA as $mms) {
942
- if (substr($mms, 0, 1)=='-' && stripos($mms, '%')!==false) { $mGr = CutFromTo($mms, '-', '%'); $cfItem = get_post_meta($postID, $mGr, true); $mms = str_ireplace("-".$mGr."%", $cfItem, $mms); } $mout .= $mms;
943
- } $msg = $mout;
944
- }
945
- if (preg_match('%FULLTEXT%', $msg)) { $postContent = apply_filters('the_content', nxs_doQTrans($post->post_content, $lng)); $msg = str_ireplace("%FULLTEXT%", $postContent, $msg);}
946
- if (preg_match('%RAWTEXT%', $msg)) { $postContent = nxs_doQTrans($post->post_content, $lng); $msg = str_ireplace("%RAWTEXT%", $postContent, $msg);}
947
- if (preg_match('%SITENAME%', $msg)) { $siteTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); $msg = str_ireplace("%SITENAME%", $siteTitle, $msg);}
948
- if (isset($ShownAds)) $ShownAds = $ShownAdsL; // FIX for the quick-adsense plugin
949
- return trim($msg);
950
- }}
951
-
952
  if (!function_exists("nxs_adminInitFunc")) { function nxs_adminInitFunc(){ global $plgn_NS_SNAutoPoster, $nxs_snapThisPageUrl, $pagenow, $nxs_isWPMU;
953
- $nxs_snapThisPageUrl = admin_url().($pagenow=='admin.php'?'network/':'').$pagenow.'?page=NextScripts_SNAP.php';
 
954
  //## Javascript to Admin Panel
955
- if (( ($pagenow=='options-general.php'||$pagenow=='admin.php') && isset($_GET['page']) && $_GET['page']=='NextScripts_SNAP.php') ||$pagenow=='post.php'||$pagenow=='post-new.php'){add_action('admin_head', 'jsPostToSNAP'); add_action('admin_head', 'nxs_jsPostToSNAP2');}
 
 
 
956
  if (function_exists('nxsDoLic_ajax')) { add_action('wp_ajax_nxsDoLic', 'nxsDoLic_ajax'); }
957
- 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); }
958
-
959
  }}
960
- if (!function_exists("nxs_adminInitFunc2")) { function nxs_adminInitFunc2(){ global $plgn_NS_SNAutoPoster, $nxs_snapThisPageUrl, $pagenow; $nxs_snapThisPageUrl = admin_url().($pagenow=='admin.php'?'network/':'').$pagenow.'?page=NextScripts_SNAP.php'; //## Add MEtaBox to Post Edit Page
961
  if (current_user_can("see_snap_box") || current_user_can("manage_options")) add_action('add_meta_boxes', array($plgn_NS_SNAutoPoster, 'NS_SNAP_addCustomBoxes'));
962
  }}
963
 
964
  function nxs_saveSiteSets_ajax(){ check_ajax_referer('nxssnap');
965
  if ($_POST['sid']=='A'){ global $wpdb; $allBlogs = $wpdb->get_results("SELECT blog_id FROM wp_blogs where blog_id > 1");
966
- foreach( $allBlogs as $aBlog ) { switch_to_blog($aBlog->blog_id); $plgn_NS_SNAutoPoster = new NS_SNAutoPoster();
967
- $options = $plgn_NS_SNAutoPoster->nxs_options; $options['suaMode'] = $_POST['sset']; update_option($plgn_NS_SNAutoPoster->dbOptionsName, $options);
968
  }
969
- } else { switch_to_blog($_POST['sid']); $plgn_NS_SNAutoPoster = new NS_SNAutoPoster();
970
- $options = $plgn_NS_SNAutoPoster->nxs_options; $options['suaMode'] = $_POST['sset']; update_option($plgn_NS_SNAutoPoster->dbOptionsName, $options); // prr($plgn_NS_SNAutoPoster->dbOptionsName); prr($options);
971
  }
 
972
  }
973
 
974
- function nxs_start_ob(){ob_start( 'nxs_ogtgCallback' );}
975
- function nxs_end_flush_ob(){ob_end_flush();}
976
-
977
- function nxs_ogtgCallback($content){ global $post, $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options; $ogimgs = array();
978
- if (!is_object($post) && (int)$post > 0) $post = get_post($post); if (empty($options['advFindOGImg'])) $options['advFindOGImg'] = 0;
979
- if (stripos($content, 'og:title')!==false) $ogOut = "\r\n"; else {
 
980
  $title = preg_match( '/<title>(.*)<\/title>/', $content, $title_matches );
981
  if ($title !== false && count( $title_matches) == 2 ) $ogT ='<meta property="og:title" content="' . $title_matches[1] . '" />'."\r\n"; else {
982
  if (is_home() || is_front_page() ) $ogT = get_bloginfo( 'name' ); else $ogT = get_the_title();
@@ -984,7 +261,7 @@ function nxs_ogtgCallback($content){ global $post, $plgn_NS_SNAutoPoster; if (!
984
  }
985
  $prcRes = preg_match( '/<meta name="description" content="(.*)"/', $content, $description_matches );
986
  if ( $prcRes !== false && count( $description_matches ) == 2 ) $ogD = '<meta property="og:description" content="' . $description_matches[1] . '" />'."\r\n"; {
987
- if (is_singular()) {
988
  if(has_excerpt($post->ID))$ogD=strip_tags(nxs_snapCleanHTML(get_the_excerpt($post->ID)));else $ogD= str_replace(" ", ' ', str_replace("\r\n", ' ', trim(substr(strip_tags(nxs_snapCleanHTML(strip_shortcodes($post->post_content))), 0, 200))));
989
  } else $ogD = get_bloginfo('description'); $ogD = preg_replace('/\r\n|\r|\n/m','',$ogD);
990
  $ogD = '<meta property="og:description" content="'.esc_attr( apply_filters( 'nxsog_desc', $ogD ) ).'" />'."\r\n";
@@ -992,9 +269,7 @@ function nxs_ogtgCallback($content){ global $post, $plgn_NS_SNAutoPoster; if (!
992
  $ogSN = '<meta property="og:site_name" content="'.get_bloginfo('name').'" />'."\r\n";
993
  $ogLoc = strtolower(esc_attr(get_locale())); if (strlen($ogLoc)==2) $ogLoc .= "_".strtoupper($ogLoc);
994
  $ogLoc = '<meta property="og:locale" content="'.$ogLoc.'" />'."\r\n"; $iss = is_home();
995
- $ogType = is_singular()?'article':'website';
996
- //if($vidsFromPost == false)
997
- $ogType = '<meta property="og:type" content="'.esc_attr(apply_filters('nxsog_type', $ogType)).'" />'."\r\n";
998
 
999
  if (is_home() || is_front_page()) $ogUrl = get_bloginfo( 'url' ); else $ogUrl = 'http' . (is_ssl() ? 's' : '') . "://".$_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
1000
  $ogUrl = '<meta property="og:url" content="'.esc_url( apply_filters( 'nxsog_url', $ogUrl ) ) . '" />' . "\r\n";
@@ -1007,8 +282,9 @@ function nxs_ogtgCallback($content){ global $post, $plgn_NS_SNAutoPoster; if (!
1007
  echo '<meta property="og:image" content="http://i2.ytimg.com/vi/'.$vidsFromPost[0].'/mqdefault.jpg" />'."\n";
1008
  echo '<meta property="og:type" content="video" />'."\n";
1009
  } */
 
1010
  if (function_exists('has_post_thumbnail') && is_object($post) && has_post_thumbnail($post->ID)) {
1011
- $thumbnail_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'thumbnail' ); $ogimgs[] = $thumbnail_src[0];
1012
  } $imgsFromPost = nsFindImgsInPost($post, (int)$options['advFindOGImg']==1);
1013
  if ($imgsFromPost !== false && is_singular() && is_array($ogimgs) && is_array($imgsFromPost)) $ogimgs = array_merge($ogimgs, $imgsFromPost);
1014
  }
@@ -1020,24 +296,34 @@ function nxs_ogtgCallback($content){ global $post, $plgn_NS_SNAutoPoster; if (!
1020
  } $content = str_ireplace('<!-- ## NXSOGTAGS ## -->', $ogOut, $content);
1021
  return $content;
1022
  }
1023
-
1024
  function nxs_addOGTagsPreHolder() { echo "<!-- ## NXS/OG ## --><!-- ## NXSOGTAGS ## --><!-- ## NXS/OG ## -->\n\r";}
1025
 
1026
  if (!function_exists("nxssnap_enqueue_scripts")) { function nxssnap_enqueue_scripts(){
1027
  wp_enqueue_script( 'nxssnap-scripts', plugin_dir_url( __FILE__ ) . 'js/js.js', array( 'jquery' ) );
1028
- wp_localize_script( 'nxssnap-scripts', 'MyAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'nxsnapWPnonce' => wp_create_nonce( 'nxsnapWPnonce' ),));
1029
  }}
1030
 
1031
- if (!function_exists("nxs_getExpSettings_ajax")) { function nxs_getExpSettings_ajax() { check_ajax_referer('nsDN'); $filename = preg_replace('/[^a-z0-9\-\_\.]/i','',$_POST['filename']);
1032
  header("Cache-Control: "); header("Content-type: text/plain"); header('Content-Disposition: attachment; filename="'.$filename.'"');
1033
  global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
1034
  echo serialize($options); die();
1035
  }}
 
 
1036
 
1037
  //## Actions and filters
 
 
 
 
 
 
 
 
1038
  if (isset($plgn_NS_SNAutoPoster)) { //## Actions
1039
  //## Add the admin menu
1040
- if ($nxs_isWPMU) add_action('network_admin_menu', 'nxs_AddSUASettings'); $suOptions = array();
 
1041
  $suOptions = $plgn_NS_SNAutoPoster->nxs_options; if ($nxs_isWPMU) { $ntOptions = $plgn_NS_SNAutoPoster->nxs_ntoptions; if (!isset($suOptions['suaMode'])) $suOptions['suaMode'] = ''; }
1042
  $isPMB = $nxs_isWPMU && function_exists('nxs_doSMAS1') && $blog_id==1;
1043
  $isO = !$nxs_isWPMU || ($nxs_isWPMU && ($suOptions['isMU']||$suOptions['isMUx']) && ($suOptions['suaMode']=='O' || ($suOptions['suaMode']=='' && $ntOptions['nxsSUType']=='O')));
@@ -1045,7 +331,7 @@ if (isset($plgn_NS_SNAutoPoster)) { //## Actions
1045
  if ($nxs_isWPMU) { if ($isO) $nxs_tpWMPU = 'O'; elseif ($isS) $nxs_tpWMPU = 'S';} // prr($nxs_tpWMPU); prr($suOptions);
1046
 
1047
  if (function_exists('nxs_doSMAS3')) nxs_doSMAS3($isS, $isO);
1048
- if (!$isO && !$isS && !$isPMB) add_action('admin_menu', 'NS_SNAutoPoster_apx');
1049
 
1050
  add_action('admin_init', 'nxs_adminInitFunc');
1051
  add_action( 'admin_enqueue_scripts', 'nxssnap_enqueue_scripts' );
@@ -1059,10 +345,6 @@ if (isset($plgn_NS_SNAutoPoster)) { //## Actions
1059
  add_action('wp_ajax_nxs_getExpSettings', 'nxs_getExpSettings_ajax');
1060
  add_action('wp_ajax_nxs_hideTip', 'nxs_hideTip_ajax');
1061
 
1062
- add_action('nxs_hourly_event', 'nxs_do_this_hourly');
1063
- add_action('wp', 'nxs_activation');
1064
- add_action('shutdown', 'nxs_psCron');
1065
-
1066
 
1067
  if ($isO || $isS) {
1068
  add_action( 'transition_post_status', 'nxs_snapLogPublishTo', 10, 3 );
@@ -1079,9 +361,13 @@ if (isset($plgn_NS_SNAutoPoster)) { //## Actions
1079
  foreach ($nxs_snapAvNts as $avNt) { add_action('wp_ajax_rePostTo'.$avNt['code'], 'nxs_rePostTo'.$avNt['code'].'_ajax'); }
1080
 
1081
  //## Add AJAX Calls for Test and Repost
 
 
1082
  add_action('wp_ajax_getBoards' , 'nsGetBoards_ajax');
1083
  add_action('wp_ajax_getGPCats' , 'nsGetGPCats_ajax');
1084
  add_action('wp_ajax_getWLBoards' , 'nsGetWLBoards_ajax');
 
 
1085
  add_action('wp_ajax_nsDN', 'ns_delNT_ajax');
1086
  }
1087
 
@@ -1101,14 +387,12 @@ if (isset($plgn_NS_SNAutoPoster)) { //## Actions
1101
  add_action('wp_ajax_nsAuthFBSv', 'nsAuthFBSv_ajax');
1102
  //## Custom Post Types and OG tags
1103
  add_filter('plugin_action_links','ns_add_settings_link', 10, 2 );
1104
-
1105
- add_filter('get_avatar','ns_get_avatar', 10, 5 );
1106
 
1107
  //## Scedulled Publish Calls
1108
- if ((int)$suOptions['nsOpenGraph'] == 1) {
1109
  add_action( 'init', 'nxs_start_ob', 0 );
1110
- add_action( 'wp_footer', 'nxs_end_flush_ob', 10000 );
1111
- add_action('wp_head', 'nxs_addOGTagsPreHolder', 150);
1112
  }
1113
  }
1114
  if ($nxs_isWPMU){
@@ -1119,4 +403,5 @@ if (isset($plgn_NS_SNAutoPoster)) { //## Actions
1119
  if (function_exists('nxs_saveSiteSets_ajax')) add_action('wp_ajax_nxs_saveSiteSets', 'nxs_saveSiteSets_ajax');
1120
  }
1121
  }
 
1122
  ?>
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.0.9
8
  Author URI: http://www.nextscripts.com
9
+ Text Domain: nxs_snap
10
  Copyright 2012 Next Scripts, Inc
11
  */
12
+ define( 'NextScripts_SNAP_Version' , '3.0.9' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
+ $nxs_mLimit = (int)ini_get('memory_limit'); if ($nxs_mLimit>0 && $nxs_mLimit<64) { add_filter('plugin_action_links','ns_add_nomem_link', 10, 2 );
15
+ 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__);
16
+ 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;}}
17
+ } else {
 
 
 
 
 
 
18
 
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_plurl, $nxs_plpath, $nxs_isWPMU, $nxs_tpWMPU;
23
 
24
+ $nxs_snapThisPageUrl = nxs_get_admin_url().'options-general.php?page=NextScripts_SNAP.php'; $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
+ do_action('nxs_doSomeMoreSecond');
31
+ //## Tests
32
+ if (isset($_GET['page']) && $_GET['page']=='NextScripts_SNAP.php' && isset($_GET['do']) && $_GET['do']=='test'){
33
+ 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/>";
34
  nxs_cURLTest("http://www.google.com/intl/en/contact/", "HTTP to Google", "Mountain View, CA");
35
  nxs_cURLTest("https://www.google.com/intl/en/contact/", "HTTPS to Google", "Mountain View, CA");
36
  nxs_cURLTest("https://www.facebook.com/", "HTTPS to Facebook", 'id="facebook"');
37
  nxs_cURLTest("https://graph.facebook.com/nextscripts", "HTTPS to API (Graph) Facebook", '270851199672443');
38
  nxs_cURLTest("https://www.linkedin.com/", "HTTPS to LinkedIn", 'rel="canonical" href="https://www.linkedin.com/"');
39
  nxs_cURLTest("https://twitter.com/", "HTTPS to Twitter", '<link rel="canonical" href="https://twitter.com/">');
40
+ nxs_cURLTest("https://www.pinterest.com/", "HTTPS to Pinterest", 'content="Pinterest"');
41
  nxs_cURLTest("http://www.livejournal.com/", "HTTP to LiveJournal", '1999 LiveJournal');
42
  die('Done');
43
  }
 
 
44
  //## Delete Account
45
+ if (!function_exists("ns_delNT_ajax")) { function ns_delNT_ajax(){ check_ajax_referer('nxsSsPageWPN'); $indx = (int)$_POST['id'];
46
  global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
47
  unset($options[$_POST['nt']][$indx]); if (is_array($options)) update_option('NS_SNAutoPoster', $options);
48
  }}
51
  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);
52
  }}
53
  if (!function_exists("nsGetBoards_ajax")) {
54
+ 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;
55
  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']);
56
  $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";}
57
  $gPNBoards = doGetBoardsFromPinterest(); $options['pn'][$_POST['ii']]['pnBoardsList'] = base64_encode($gPNBoards);
59
  }
60
  }
61
 
62
+ if (!function_exists("nxs_getBrdsOrCats_ajax")) {
63
+ 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;
64
+ 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']);
65
+
66
+ 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";}
67
+ $gPNBoards = doGetBoardsFromPinterest(); $options['pn'][$_POST['ii']]['pnBoardsList'] = base64_encode($gPNBoards);
68
+ $options['pn'][$_POST['ii']]['pnSvC'] = serialize($nxs_gCookiesArr); if (is_array($options)) update_option('NS_SNAutoPoster', $options); echo $gPNBoards; die();
69
+ }
70
+ 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";}
71
+ $gBoards = doGetSubredditsFromRD(); $options['rd'][$_POST['ii']]['rdSubRedditsList'] = base64_encode($gBoards);
72
+ if (is_array($options)) update_option('NS_SNAutoPoster', $options); echo $gBoards; die();
73
+ }
74
+
75
+ }
76
+ }
77
+
78
+
79
+ if (!function_exists("nxs_delPostSettings_ajax")) { function nxs_delPostSettings_ajax(){ check_ajax_referer('nxsSsPageWPN'); global $nxs_snapAvNts; $pid = (int)$_POST['pid'];
80
+ foreach ($nxs_snapAvNts as $avNt) delete_post_meta($pid, 'snap'.strtoupper($avNt['code']));
81
+ echo "OK"; die();
82
+ }}
83
+
84
  if (!function_exists("nsGetGPCats_ajax")) {
85
+ 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;
86
  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']);
87
  $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";}
88
  $gGPCCats = doGetCCatsFromGooglePlus($_POST['c']); $options['gp'][$_POST['ii']]['gpCCatsList'] = base64_encode($gGPCCats);
90
  }
91
  }
92
  if (!function_exists("nsGetWLBoards_ajax")) {
93
+ 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;
94
  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']);
95
  $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";}
96
  $gWLBoards = doGetBoardsFromWaNeLo(); $options['wl'][$_POST['ii']]['wlBoardsList'] = base64_encode($gWLBoards);
97
  $options['wl'][$_POST['ii']]['wlSvC'] = serialize($nxs_gCookiesArr); if (is_array($options)) update_option('NS_SNAutoPoster', $options); echo $gWLBoards; die();
98
  }
99
  }
100
+ //## Set all posts to Include/exclude from/to Auto-Reposting
101
+ if (!function_exists("nxs_SetRpstAll_ajax")) {
102
+ 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']]);
103
+
104
+ if ($_POST['ed']=='X' || $_POST['ed']=='L') { // prr($options[$_POST['t']][$_POST['ii']]); prr($options); die();
105
+ if ($_POST['ed']=='X') { $options[$_POST['t']][$_POST['ii']]['rpstLastPostID'] = '';
106
+ $options[$_POST['t']][$_POST['ii']]['rpstLastShTime'] = ''; $options[$_POST['t']][$_POST['ii']]['rpstLastPostTime'] = ''; $options[$_POST['t']][$_POST['ii']]['rpstNxTime'] = '';
107
+ } elseif ($_POST['ed']=='L' && trim($_POST['lpid'])!='' && (int)$_POST['lpid'] > 0) {
108
+ $post = get_post($_POST['lpid']);
109
+ $options[$_POST['t']][$_POST['ii']]['rpstLastPostTime'] = $post->post_date;
110
+ $options[$_POST['t']][$_POST['ii']]['rpstLastPostID'] = trim($_POST['lpid']);
111
+ }
112
+ 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']]);
113
+ } else {
114
+ if (!empty($options['nxsCPTSeld'])) $tpArray = maybe_unserialize($options['nxsCPTSeld']); if (!is_array($tpArray)) $tpArray = array('post'); else $tpArray[] = 'post';
115
+ foreach ($tpArray as $tp) if (!empty($tp)) {
116
+ $args = array( 'post_type' => $tp, 'post_status' => 'publish', 'numberposts' => 30, 'offset'=> 0, 'fields'=>'ids' ); $posts = get_posts( $args );
117
+ while (count($posts)>0){
118
+ foreach ($posts as $postID){ $pMeta = maybe_unserialize(get_post_meta($postID, 'snap'.strtoupper($_POST['t']), true));
119
+ if (!isset($pMeta) || !is_array($pMeta)) $pMeta = array(); if (!isset($pMeta[$_POST['ii']]) || !is_array($pMeta[$_POST['ii']])) $pMeta[$_POST['ii']] = array();
120
+ $pMeta[$_POST['ii']]['rpstPostIncl'] = $_POST['ed']=='0'?'0':'nxsi'.$_POST['ii'].$_POST['t']; delete_post_meta($postID, 'snap'.strtoupper($_POST['t'])); add_post_meta($postID, 'snap'.strtoupper($_POST['t']), serialize($pMeta));
121
+ } $args['offset'] = $args['offset']+30; $posts = get_posts( $args );
122
+ }
123
+ }
124
+ } echo "OK"; die();
125
+ }}
126
  if (!function_exists("nxs_clLgo_ajax")) { function nxs_clLgo_ajax() { check_ajax_referer('nxsSsPageWPN'); global $wpdb;
127
  //update_option('NS_SNAutoPosterLog', '');
128
  $wpdb->query( 'DELETE FROM '.$wpdb->prefix . 'nxs_log' ); echo "OK";
129
  }}
 
130
  if (!function_exists("nxs_rfLgo_ajax")) { function nxs_rfLgo_ajax() { check_ajax_referer('nxsSsPageWPN'); echo "Y:";
131
  //$log = get_option('NS_SNAutoPosterLog'); $logInfo = maybe_unserialize(get_option('NS_SNAutoPosterLog'));
132
  $logInfo = nxs_getnxsLog();
139
  echo '<snap style="color:#008000">['.$logline['date'].']</snap> - <snap style="'.$actSt.'">['.$logline['act'].']</snap>'.$ntInfo.'- <snap style="'.$msgSt.'">'.$logline['msg'].'</snap> '.$logline['extInfo'].'<br/>';
140
  }
141
  }}
 
142
  //## Initialize the admin panel if the plugin has been activated
143
+ 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;
144
  add_menu_page('Social Networks Auto Poster', 'Social Networks Auto Poster', 'manage_options', basename(__FILE__), array(&$plgn_NS_SNAutoPoster, 'showSNAP_WPMU_OptionsPage'), $nxs_plurl.'img/snap-icon12.png'); }}
145
  //## Initialize the admin panel if the plugin has been activated
146
+ 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;
147
+ if (function_exists('add_options_page')) { add_options_page('Social Networks Auto Poster',
148
+ '<img src="'.$nxs_plurl.'img/snap-icon12.png"/><span style="color:#287A0A">{SNAP}</span> Social Networks Auto Poster', 'manage_options', basename(__FILE__), array(&$plgn_NS_SNAutoPoster, 'showSNAutoPosterOptionsPage'));
149
  }}}
150
  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;
151
+ if (function_exists('add_options_page')) { add_options_page('Social Networks Auto Poster',
152
+ '<img src="'.$nxs_plurl.'img/snap-icon12.png"/><span style="color:#287A0A">{SNAP}</span> Social Networks Auto Poster', 'manage_options', basename(__FILE__), array(&$plgn_NS_SNAutoPoster, 'showSNAutoPosterOptionsPagex'));
153
  }}}
 
154
  //## Main Function to Post
155
  if (!function_exists("nxs_snapLogPublishTo")) { function nxs_snapLogPublishTo( $new_status, $old_status, $post ) {
156
+ 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.');
157
  }}
158
  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);
159
+ if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
160
+ if (!empty($_POST['nxs_snapPostOptions'])) { $NXS_POSTX = $_POST['nxs_snapPostOptions']; $NXS_POST = array(); $NXS_POST = NXS_parseQueryStr($NXS_POSTX); } else $NXS_POST = $_POST;
161
+ if(is_object($postArr)) $postID = $postArr->ID; else { $postID = $postArr; $postArr = get_post($postID); } $isPost = isset($NXS_POST["snapEdIT"]); $post = get_post($postID);
162
+ if ($post->post_status != 'publish') { nxs_addToLogN('I', 'Cancelled', '', 'Autopost Cancelled - Post is not "Published" Right now - Post ID:('.$postID.')' ); return; }
163
  //nxs_addToLogN('BG', 'Post Status Changed', '', '-=## Autopost requested.'.($blog_id>1?'BlogID:'.$blog_id:'').' PostID:('.$postID.') Post Type: '.$post->post_type.' ##=-');
164
  $args=array('public'=>true, '_builtin'=>false); $output = 'names'; $operator = 'and'; $post_types = array(); if (function_exists('get_post_types')) $post_types=get_post_types($args, $output, $operator);
165
  if ( isset($options['nxsCPTSeld']) && $options['nxsCPTSeld']!='') $nxsCPTSeld = unserialize($options['nxsCPTSeld']); else $nxsCPTSeld = array(); // $nxsCPTSeld = array_keys($post_types); - why we needed it?
172
  if (function_exists('nxs_doSMAS2')) { nxs_doSMAS2($postArr, $type, $aj); return; } else {
173
  $options = $plgn_NS_SNAutoPoster->nxs_options; $ltype=strtolower($type);
174
  if ($nxs_tpWMPU=='S') { switch_to_blog(1); $plgn_NS_SNAutoPoster = new NS_SNAutoPoster(); $options = $plgn_NS_SNAutoPoster->nxs_options; restore_current_blog(); }
175
+ 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';
176
+ nxs_addToLogN('BG', 'Start =- ', '', '------=========#### NEW AUTO-POST REQUEST '.($blog_id>1?'BlogID:'.$blog_id:'').' PostID:('.$postID.') '.($publtype=='S'?'Scheduled +'.$delay:($publtype=='A'?'Automated':'Immediate')).' ####=========------');
177
 
178
  $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted=='1') { nxs_addToLogN('W', 'Skipped', '', 'Already Autoposted - Post ID:('.$postID.')' ); return; }
179
  $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);
183
 
184
  foreach ($nxs_snapAvNts as $avNt) {
185
  if (count($options[$avNt['lcode']])>0) { $clName = 'nxs_snapClass'.$avNt['code'];
186
+ 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);}
187
 
188
  if (isset($po) && is_array($po)) $isPostMeta = true; else { $isPostMeta = false; $po = $options[$avNt['lcode']]; }
189
  delete_post_meta($postID, 'snap_isAutoPosted'); add_post_meta($postID, 'snap_isAutoPosted', '1');
191
  $optMt = $options[$avNt['lcode']][0]; if ($isPostMeta) { $ntClInst = new $clName(); $optMt = $ntClInst->adjMetaOpt($optMt, $po[0]); }
192
  if ($snap_isEdIT!='1') { $doPost = true;
193
  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;}}
194
+ if (!$doPost) { nxs_addToLogN('I', 'Skipped', $avNt['name'].' ('.$optMt['nName'].')', '[Non-Human Post] - Individual Category Excluded - Post ID:('.$postID.')' ); continue; }
195
  }
196
  }
197
  if ($optMt['do'.$avNt['code']]=='1') { $optMt['ii'] = 0;
198
  if ($publtype=='A' && ($optMt['nMin']>0 || $optMt['nHrs']>0 || $optMt['nTime']!='')) $publtype='S';
199
  if ($publtype=='S') { if (isset($optMt['nHrs']) && isset($optMt['nMin']) && ($optMt['nHrs']>0 || $optMt['nMin']>0) ) { $delay = $optMt['nMin']*60+$optMt['nHrs']*3600;
200
  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':'').')' );
201
+ } else $delay = rand(2,10); $optMt['timeToRun'] = time()+$delay;
202
+ 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); }
203
+ else $args = array($postID, $optMt);
204
+ wp_schedule_single_event($optMt['timeToRun'],'ns_doPublishTo'.$avNt['code'], $args);
205
  nxs_addToLogN('BI', 'Scheduled', $avNt['name'].' ('.$optMt['nName'].')', ' PostID:('.$postID.')' );
206
  } else { $fname = 'nxs_doPublishTo'.$avNt['code']; $fname($postID, $optMt); }
207
  } else { nxs_addToLogN('GR', 'Skipped', $avNt['name'].' ('.$optMt['nName'].')', '-=[Unchecked Account]=- - PostID:'.$postID.'' ); }
208
  }
209
+ } } } else { nxs_addToLogN('I', 'Skipped', '', 'Excluded Post Type: '.$post->post_type.' (Post ID: '.$postID.')' ); return; }
210
  if ($isS) restore_current_blog();
211
  }}
212
 
 
 
213
  //## Add settings link to plugins list
214
  if (!function_exists("ns_add_settings_link")) { function ns_add_settings_link($links, $file) {
215
  static $this_plugin;
222
  }}
223
  //## Actions and filters
224
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
225
  if (!function_exists("nxs_adminInitFunc")) { function nxs_adminInitFunc(){ global $plgn_NS_SNAutoPoster, $nxs_snapThisPageUrl, $pagenow, $nxs_isWPMU;
226
+ $nxs_snapThisPageUrl = nxs_get_admin_url().($pagenow=='admin.php'?'network/':'').$pagenow.'?page=NextScripts_SNAP.php';
227
+ 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); }
228
  //## Javascript to Admin Panel
229
+ if (( ($pagenow=='options-general.php'||$pagenow=='admin.php') && isset($_GET['page']) && $_GET['page']=='NextScripts_SNAP.php') ||$pagenow=='post.php'||$pagenow=='post-new.php'){
230
+ if ( isset($_GET['post_type']) && $_GET['post_type']=='page' && isset($options['useForPages']) && $options['useForPages']!=1 ) {}
231
+ else { add_filter( 'tiny_mce_before_init', 'nxs_tiny_mce_before_init' ); add_action('admin_head', 'jsPostToSNAP'); add_action('admin_head', 'nxs_jsPostToSNAP2'); }
232
+ }
233
  if (function_exists('nxsDoLic_ajax')) { add_action('wp_ajax_nxsDoLic', 'nxsDoLic_ajax'); }
 
 
234
  }}
235
+ 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
236
  if (current_user_can("see_snap_box") || current_user_can("manage_options")) add_action('add_meta_boxes', array($plgn_NS_SNAutoPoster, 'NS_SNAP_addCustomBoxes'));
237
  }}
238
 
239
  function nxs_saveSiteSets_ajax(){ check_ajax_referer('nxssnap');
240
  if ($_POST['sid']=='A'){ global $wpdb; $allBlogs = $wpdb->get_results("SELECT blog_id FROM wp_blogs where blog_id > 1");
241
+ foreach( $allBlogs as $aBlog ) { switch_to_blog($aBlog->blog_id);
242
+ $options = get_option('NS_SNAutoPoster'); $options['suaMode'] = $_POST['sset']; update_option('NS_SNAutoPoster', $options);
243
  }
244
+ } else { switch_to_blog($_POST['sid']);
245
+ $options = get_option('NS_SNAutoPoster'); $options['suaMode'] = $_POST['sset']; update_option('NS_SNAutoPoster', $options); // prr($plgn_NS_SNAutoPoster->dbOptionsName); prr($options);
246
  }
247
+ echo "OK"; die();
248
  }
249
 
250
+ //## OG:Tags
251
+ function nxs_start_ob(){ if (!is_admin()) ob_start( 'nxs_ogtgCallback' );}
252
+ function nxs_end_flush_ob(){ if (!is_admin()) @ob_end_flush();}
253
+ function nxs_ogtgCallback($content){ global $post, $plgn_NS_SNAutoPoster;
254
+ if (stripos($content, 'og:title')!==false) $ogOut = "\r\n"; else {
255
+ if (!isset($plgn_NS_SNAutoPoster)) $options = get_option('NS_SNAutoPoster'); else $options = $plgn_NS_SNAutoPoster->nxs_options; $ogimgs = array();
256
+ if (!empty($post) && !is_object($post) && int($post)>0) $post = get_post($post); if (empty($options['advFindOGImg'])) $options['advFindOGImg'] = 0;
257
  $title = preg_match( '/<title>(.*)<\/title>/', $content, $title_matches );
258
  if ($title !== false && count( $title_matches) == 2 ) $ogT ='<meta property="og:title" content="' . $title_matches[1] . '" />'."\r\n"; else {
259
  if (is_home() || is_front_page() ) $ogT = get_bloginfo( 'name' ); else $ogT = get_the_title();
261
  }
262
  $prcRes = preg_match( '/<meta name="description" content="(.*)"/', $content, $description_matches );
263
  if ( $prcRes !== false && count( $description_matches ) == 2 ) $ogD = '<meta property="og:description" content="' . $description_matches[1] . '" />'."\r\n"; {
264
+ if (!empty($post) && is_object($post) && is_singular()) {
265
  if(has_excerpt($post->ID))$ogD=strip_tags(nxs_snapCleanHTML(get_the_excerpt($post->ID)));else $ogD= str_replace(" ", ' ', str_replace("\r\n", ' ', trim(substr(strip_tags(nxs_snapCleanHTML(strip_shortcodes($post->post_content))), 0, 200))));
266
  } else $ogD = get_bloginfo('description'); $ogD = preg_replace('/\r\n|\r|\n/m','',$ogD);
267
  $ogD = '<meta property="og:description" content="'.esc_attr( apply_filters( 'nxsog_desc', $ogD ) ).'" />'."\r\n";
269
  $ogSN = '<meta property="og:site_name" content="'.get_bloginfo('name').'" />'."\r\n";
270
  $ogLoc = strtolower(esc_attr(get_locale())); if (strlen($ogLoc)==2) $ogLoc .= "_".strtoupper($ogLoc);
271
  $ogLoc = '<meta property="og:locale" content="'.$ogLoc.'" />'."\r\n"; $iss = is_home();
272
+ $ogType = is_singular()?'article':'website'; if($vidsFromPost == false) $ogType = '<meta property="og:type" content="'.esc_attr(apply_filters('nxsog_type', $ogType)).'" />'."\r\n";
 
 
273
 
274
  if (is_home() || is_front_page()) $ogUrl = get_bloginfo( 'url' ); else $ogUrl = 'http' . (is_ssl() ? 's' : '') . "://".$_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
275
  $ogUrl = '<meta property="og:url" content="'.esc_url( apply_filters( 'nxsog_url', $ogUrl ) ) . '" />' . "\r\n";
282
  echo '<meta property="og:image" content="http://i2.ytimg.com/vi/'.$vidsFromPost[0].'/mqdefault.jpg" />'."\n";
283
  echo '<meta property="og:type" content="video" />'."\n";
284
  } */
285
+
286
  if (function_exists('has_post_thumbnail') && is_object($post) && has_post_thumbnail($post->ID)) {
287
+ $thumbnail_src = nxs_getPostImage($post->ID, 'full', $options['ogImgDef']); $ogimgs[] = $thumbnail_src[0];
288
  } $imgsFromPost = nsFindImgsInPost($post, (int)$options['advFindOGImg']==1);
289
  if ($imgsFromPost !== false && is_singular() && is_array($ogimgs) && is_array($imgsFromPost)) $ogimgs = array_merge($ogimgs, $imgsFromPost);
290
  }
296
  } $content = str_ireplace('<!-- ## NXSOGTAGS ## -->', $ogOut, $content);
297
  return $content;
298
  }
 
299
  function nxs_addOGTagsPreHolder() { echo "<!-- ## NXS/OG ## --><!-- ## NXSOGTAGS ## --><!-- ## NXS/OG ## -->\n\r";}
300
 
301
  if (!function_exists("nxssnap_enqueue_scripts")) { function nxssnap_enqueue_scripts(){
302
  wp_enqueue_script( 'nxssnap-scripts', plugin_dir_url( __FILE__ ) . 'js/js.js', array( 'jquery' ) );
303
+ wp_localize_script( 'nxssnap-scripts', 'MyAjax', array( 'ajaxurl' => nxs_get_admin_url( 'admin-ajax.php' ), 'nxsnapWPnonce' => wp_create_nonce( 'nxsnapWPnonce' ),));
304
  }}
305
 
306
+ if (!function_exists("nxs_getExpSettings_ajax")) { function nxs_getExpSettings_ajax() { /* check_ajax_referer('nsDN'); */ $filename = preg_replace('/[^a-z0-9\-\_\.]/i','',$_POST['filename']);
307
  header("Cache-Control: "); header("Content-type: text/plain"); header('Content-Disposition: attachment; filename="'.$filename.'"');
308
  global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
309
  echo serialize($options); die();
310
  }}
311
+
312
+ function cron_add_nxsreposter( $schedules ) { $schedules['nxsreposter'] = array( 'interval' => 90, 'display' => __( 'NXS Reposter' )); return $schedules;} // Do this every 90 seconds
313
 
314
  //## Actions and filters
315
+ add_action('shutdown', 'nxs_psCron', 25); //add_action( 'transition_post_status', 'nxs_snapLogPublishTo', 10, 3 );
316
+
317
+ add_filter('cron_schedules', 'cron_add_nxsreposter');
318
+ add_action('nxs_hourly_event', 'nxs_do_this_hourly');
319
+ add_action('nxs_querypost_event', 'nxs_do_post_from_query');
320
+ add_action('wp', 'nxs_activation'); //## Adds Hourly Event
321
+ add_filter('get_avatar','ns_get_avatar', 10, 5 );
322
+
323
  if (isset($plgn_NS_SNAutoPoster)) { //## Actions
324
  //## Add the admin menu
325
+
326
+ if ($nxs_isWPMU) { add_action('network_admin_menu', 'nxs_AddSUASettings'); global $blog_id; } $suOptions = array();
327
  $suOptions = $plgn_NS_SNAutoPoster->nxs_options; if ($nxs_isWPMU) { $ntOptions = $plgn_NS_SNAutoPoster->nxs_ntoptions; if (!isset($suOptions['suaMode'])) $suOptions['suaMode'] = ''; }
328
  $isPMB = $nxs_isWPMU && function_exists('nxs_doSMAS1') && $blog_id==1;
329
  $isO = !$nxs_isWPMU || ($nxs_isWPMU && ($suOptions['isMU']||$suOptions['isMUx']) && ($suOptions['suaMode']=='O' || ($suOptions['suaMode']=='' && $ntOptions['nxsSUType']=='O')));
331
  if ($nxs_isWPMU) { if ($isO) $nxs_tpWMPU = 'O'; elseif ($isS) $nxs_tpWMPU = 'S';} // prr($nxs_tpWMPU); prr($suOptions);
332
 
333
  if (function_exists('nxs_doSMAS3')) nxs_doSMAS3($isS, $isO);
334
+ if (!$isO && !$isS && !$isPMB && !function_exists('showSNAP_WPMU_OptionsPageExt')) add_action('admin_menu', 'NS_SNAutoPoster_apx');
335
 
336
  add_action('admin_init', 'nxs_adminInitFunc');
337
  add_action( 'admin_enqueue_scripts', 'nxssnap_enqueue_scripts' );
345
  add_action('wp_ajax_nxs_getExpSettings', 'nxs_getExpSettings_ajax');
346
  add_action('wp_ajax_nxs_hideTip', 'nxs_hideTip_ajax');
347
 
 
 
 
 
348
 
349
  if ($isO || $isS) {
350
  add_action( 'transition_post_status', 'nxs_snapLogPublishTo', 10, 3 );
361
  foreach ($nxs_snapAvNts as $avNt) { add_action('wp_ajax_rePostTo'.$avNt['code'], 'nxs_rePostTo'.$avNt['code'].'_ajax'); }
362
 
363
  //## Add AJAX Calls for Test and Repost
364
+
365
+ add_action('wp_ajax_nxs_getBrdsOrCats' , 'nxs_getBrdsOrCats_ajax');
366
  add_action('wp_ajax_getBoards' , 'nsGetBoards_ajax');
367
  add_action('wp_ajax_getGPCats' , 'nsGetGPCats_ajax');
368
  add_action('wp_ajax_getWLBoards' , 'nsGetWLBoards_ajax');
369
+ add_action('wp_ajax_SetRpstAll' , 'nxs_SetRpstAll_ajax');
370
+ add_action('wp_ajax_nxs_delPostSettings' , 'nxs_delPostSettings_ajax');
371
  add_action('wp_ajax_nsDN', 'ns_delNT_ajax');
372
  }
373
 
387
  add_action('wp_ajax_nsAuthFBSv', 'nsAuthFBSv_ajax');
388
  //## Custom Post Types and OG tags
389
  add_filter('plugin_action_links','ns_add_settings_link', 10, 2 );
 
 
390
 
391
  //## Scedulled Publish Calls
392
+ if (!empty($suOptions['nsOpenGraph']) && (int)$suOptions['nsOpenGraph'] == 1) {
393
  add_action( 'init', 'nxs_start_ob', 0 );
394
+ add_action('wp_head', 'nxs_addOGTagsPreHolder', 150);
395
+ add_action('shutdown', 'nxs_end_flush_ob', 1000);
396
  }
397
  }
398
  if ($nxs_isWPMU){
403
  if (function_exists('nxs_saveSiteSets_ajax')) add_action('wp_ajax_nxs_saveSiteSets', 'nxs_saveSiteSets_ajax');
404
  }
405
  }
406
+ }
407
  ?>
img/da-bg.png ADDED
Binary file
img/da16.png ADDED
Binary file
inc-cl/ap.api.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //## NextScripts App.net 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'=>'AP', 'lcode'=>'ap', 'name'=>'app.net');
24
+
25
+ if (!class_exists("nxs_class_SNAP_AP")) { class nxs_class_SNAP_AP {
26
+
27
+ var $ntCode = 'AP';
28
+ var $ntLCode = 'ap';
29
+
30
+ function doPost($options, $message){ if (!is_array($options)) return false; $out = array(); // return false;
31
+ foreach ($options as $ii=>$ntOpts) $out[$ii] = $this->doPostToNT($ntOpts, $message);
32
+ return $out;
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";
40
+ rename($tmp, $tmp.='.png'); register_shutdown_function(create_function('', "unlink('{$tmp}');"));
41
+ file_put_contents($tmp, $imgData); if (!$tmp) return 'You must specify a path to a file'; if (!file_exists($tmp)) return 'File path specified does not exist';
42
+ if (!is_readable($tmp)) return 'File path specified is not readable';
43
+ if (!array_key_exists('name', $data)) $data['name'] = basename($tmp);
44
+ if (array_key_exists('mime-type', $data)) { $mimeType = $data['mime-type']; unset($data['mime-type']);} else $mimeType = null;
45
+ if (!array_key_exists('kind', $data)) { $test = @getimagesize($tmp);
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
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data); $response = curl_exec($ch); $errmsg = curl_error($ch); curl_close($ch); //prr($response);
55
+ if ($errmsg!='') return $errmsg; else $response = json_decode($response, true);
56
+ if (!is_array($response) || !isset($response['meta']) || $response['meta']['code']!='200' || $response['data']['file_token']=='') return print_r($response, true);
57
+ return array('id'=>$response['data']['id'], 'file_token'=>$response['data']['file_token'], 'url'=>$response['data']['url']);
58
+ }
59
+
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['apAppAuthToken']) || trim($options['apAppAuthToken'])=='') { $badOut['Error'] = 'Not Authorized'; return $badOut; }
64
+ //## Format Post
65
+ $text = nxs_doFormatMsg($options['apTextFormat'], $message); $text = nsTrnc($text, 256);
66
+ //## Make Post
67
+ if (isset($message['imageURL'])) $img = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); else $img = '';
68
+ if ($options['attchImg']!=false && $img!='') $remoteImg = $this->createFile($img, $options['apAppAuthToken']); $ann = array();
69
+ if (is_array($remoteImg)) {
70
+ $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")));
71
+ }
72
+ $url = "https://alpha-api.app.net/stream/0/posts?include_post_annotations=1&access_token=".$options['apAppAuthToken'];
73
+ $flds = array('text' => $text, 'annotations' => $ann); $flds = json_encode($flds); $hdrsArr = array('Content-Type' => 'application/json');
74
+ $response = wp_remote_post( $url, array( 'method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds));
75
+ if (is_wp_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; }
79
+ $apNewPostURL = $response['data']['canonical_url']; $apNewPostID = $response['data']['id'];
80
+ if ($apNewPostID!='') {
81
+ return array('postID'=>$apNewPostID, 'isPosted'=>1, 'postURL'=>$apNewPostURL, 'pDate'=>date('Y-m-d H:i:s'));
82
+ } else { $badOut['Error'] .= print_r($tmhOAuth->response['response'], true)." MSG:".print_r($msg, true);
83
+ return $badOut;
84
+ }
85
+ return $badOut;
86
+ }
87
+
88
+ }}
89
+ ?>
inc-cl/ap.php ADDED
@@ -0,0 +1,257 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 {
6
+ //#### Show Common Settings
7
+ function showGenNTSettings($ntOpts){ global $nxs_plurl, $nxs_snapThisPageUrl; $ntInfo = array('code'=>'AP', 'lcode'=>'ap', 'name'=>'App.Net', 'defNName'=>'', 'tstReq' => true);
8
+ if ( isset($_GET['code']) && $_GET['code']!='' && (isset($_GET['auth']) && $_GET['auth']=='ap') ){ $at = $_GET['code'];
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_snapThisPageUrl.'&auth=ap&acc='.$_GET['acc']."||";
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_snapThisPageUrl.'&auth=ap&acc='.$_GET['acc'], 'code'=>$at);
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) { $optionsG = get_option('NS_SNAutoPoster'); $optionsG['ap'][$_GET['acc']] = $fbo; update_option('NS_SNAutoPoster', $optionsG);
19
+ ?><script type="text/javascript">window.location = "<?php echo $nxs_snapThisPageUrl; ?>"</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', 'nxs_snap'); 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;">
35
+ <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> />
36
+ <?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 } ?>
37
+ <?php if (isset($pbo['rpstOn']) && (int)$pbo['rpstOn'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popReActive');" onmouseover="nxs_showPopUpInfo('popReActive', event);"><?php echo "*[R]*" ?></span><?php } ?>
38
+ <strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
39
+ &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', 'nxs_snap'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>&nbsp;&nbsp;
40
+ <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
41
+ </p><?php $pbo['ntInfo'] = $ntInfo; $this->showNTSettings($indx, $pbo);
42
+ }?>
43
+ </div>
44
+ </div> <?php
45
+ }
46
+ //#### Show NEW Settings Page
47
+ function showNewNTSettings($options){ $opts = array('nName'=>'', 'doAP'=>'1', 'apUName'=>'', 'apPageID'=>'', 'apCommID'=>'', 'postType'=>'A', 'apPass'=>''); $opts['ntInfo']= array('lcode'=>'ap'); $this->showNTSettings($options, $opts, true);}
48
+ //#### Show Unit Settings
49
+ function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl, $nxs_snapThisPageUrl; $nt = $options['ntInfo']['lcode']; $ntU = strtoupper($nt);
50
+ 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'] = '';
51
+ if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; if (!isset($options['attchImg'])) $options['attchImg'] = '';
52
+ if (!isset($options['appID'])) $options['appID'] = ''; if (!isset($options['appSec'])) $options['appSec'] = ''; ?>
53
+ <div id="doAP<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>">
54
+ <input type="hidden" name="apDoSAP<?php echo $ii; ?>" value="0" id="apDoSAP<?php echo $ii; ?>" />
55
+ <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', 'nxs_snap' ), $nType); ?></a></div>
56
+
57
+ <div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'nxs_snap'); ?></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")), 'nxs_snap') ?>" /><br/>
58
+ <?php echo nxs_addQTranslSel('ap', $ii, $options['qTLng']); ?>
59
+ <br/>
60
+ <ul class="nsx_tabs">
61
+ <li><a href="#nsx<?php echo $nt.$ii ?>_tab1"><?php _e('Account Info', 'nxs_snap'); ?></a></li>
62
+ <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'nxs_snap'); ?></a></li>
63
+ </ul>
64
+ <div class="nsx_tab_container"><?php /* ######################## Account Tab ####################### */ ?>
65
+ <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%;">
66
+
67
+ <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")), 'nxs_snap') ?>" />
68
+ <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")), 'nxs_snap') ?>" /> <br/>
69
+ <br/>
70
+
71
+ <div id="altFormat" style="margin-left: 0px;">
72
+ <div style="width:100%;"><strong id="altFormatText"><?php _e('Text Format', 'nxs_snap'); ?>:</strong> (<a href="#" id="apTextFormat<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apTextFormat<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)
73
+ </div>
74
+
75
+ <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%", 'nxs_snap'); else _e(apply_filters('format_to_edit', htmlentities($options['apTextFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap'); ?></textarea>
76
+
77
+ <?php nxs_doShowHint("apTextFormat".$ii); ?>
78
+ </div>
79
+
80
+ <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', 'nxs_snap'); ?></strong></p>
81
+ <br/><br/>
82
+ <?php if($options['appID']=='') { ?>
83
+ <b><?php _e('Authorize Your App.Net Account', 'nxs_snap'); ?></b> <?php _e('Please click "Update Settings" to be able to Authorize your account.', 'nxs_snap'); ?>
84
+ <?php } else { if(isset($options['appAppUserID']) && $options['appAppUserID']>0) { ?>
85
+ <?php _e('Your App.Net Account has been authorized.', 'nxs_snap'); ?> User ID: <?php _e(apply_filters('format_to_edit', htmlentities($options['appAppUserID'].' - '.$options['appAppUserName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>.
86
+ <?php _e('You can', 'nxs_snap'); ?> Re- <?php } ?>
87
+ <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_snapThisPageUrl.'&auth=ap&acc='.$ii));?>&scope=stream+write_post+follow+messages+update_profile+files">Authorize Your App.Net Account</a>
88
+ <?php if (!isset($options['appAppUserID']) || $options['appAppUserID']<1) { ?> <div class="blnkg">&lt;=== <?php _e('Authorize your account', 'nxs_snap'); ?> ===</div>
89
+ <br/><br/><i> <?php _e('If you get App.Net message:', 'nxs_snap'); ?> <b>"Error. An error occurred. Please try again later."</b> or <b>"Error 191"</b> <?php _e('please make sure that domain name in your App.Net App matches your website domain exactly. Please note that www. and non www. versions are different domains.', 'nxs_snap'); ?></i> <?php }?>
90
+ <?php } ?>
91
+ <br/>
92
+
93
+
94
+ <?php if ($isNew) { ?> <input type="hidden" name="ap[<?php echo $ii; ?>][apDoAP]" value="1" id="apDoNewAP<?php echo $ii; ?>" /> <?php } ?>
95
+ <?php if (isset($options['appAppUserID']) && $options['appAppUserID']>0) { ?>
96
+
97
+ <b><?php _e('Test your settings', 'nxs_snap'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('AP', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'nxs_snap' ), $nType); ?></a> <?php }
98
+ ?>
99
+
100
+ </div>
101
+ <?php /* ######################## Tools Tab ####################### */ ?>
102
+ <div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content">
103
+
104
+ <?php if (!$isNew) { ?> <div class="nxs_tls_cpt"><?php _e('Categories', 'nxs_snap'); ?></div>
105
+ <div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
106
+ <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
107
+ <input value="1" id="catSelS<?php echo strtoupper($nt); ?><?php echo $ii; ?>" type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_<?php echo strtoupper($nt); ?><?php echo $ii; ?>" onclick="jQuery('#catSelS<?php echo strtoupper($nt); ?><?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('<?php echo strtoupper($nt); ?><?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_<?php echo strtoupper($nt); ?><?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($options['catSelEd']!='') echo "[".(substr_count($options['catSelEd'], ",")+1)."]"; ?></a>
108
+ <input type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_<?php echo strtoupper($nt); ?><?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
109
+ <br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
110
+ <br/>
111
+ <?php } ?>
112
+ <?php nxs_addPostingDelaySelV3($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']); ?>
113
+ <?php nxs_showRepostSettings($nt, $ii, $options); ?>
114
+
115
+ </div> <?php /* #### End of Tab #### */ ?>
116
+ </div><br/> <?php /* #### End of Tabs #### */ ?>
117
+
118
+ <div class="submit clear" style="padding-bottom: 0px;"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div>
119
+
120
+
121
+ </div><?php
122
+ }
123
+ //#### Set Unit Settings from POST
124
+ function setNTSettings($post, $options){ global $nxs_snapThisPageUrl; $code = 'AP'; $lcode = 'ap';
125
+ foreach ($post as $ii => $pval){
126
+ if (isset($pval['appID']) && $pval['appID']!=''){ if (!isset($options[$ii])) $options[$ii] = array();
127
+ if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']);
128
+
129
+ if (isset($pval['appID'])) $options[$ii]['appID'] = trim($pval['appID']);
130
+
131
+ if (isset($pval['appSec'])) $options[$ii]['appSec'] = trim($pval['appSec']);
132
+ if (isset($pval['apSubReddit'])) $options[$ii]['apSubReddit'] = trim($pval['apSubReddit']);
133
+
134
+ if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']); else $options[$ii]['catSel'] = 0;
135
+ if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
136
+
137
+ if (isset($pval['attchImg'])) $options[$ii]['attchImg'] = $pval['attchImg']; else $options[$ii]['attchImg'] = 0;
138
+ if (isset($pval['apTextFormat'])) $options[$ii]['apTextFormat'] = trim($pval['apTextFormat']);
139
+ if (isset($pval['apDoAP'])) $options[$ii]['doAP'] = $pval['apDoAP']; else $options[$ii]['doAP'] = 0;
140
+
141
+ $options[$ii] = nxs_adjRpst($options[$ii], $pval);
142
+
143
+ if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']);
144
+ if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
145
+ if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
146
+ }
147
+ } return $options;
148
+ }
149
+ //#### Show Post->Edit Meta Box Settings
150
+ function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID; $nt = 'ap'; $ntU = 'AP';
151
+ foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapAP', true));
152
+ if (is_array($pMeta) && isset($pMeta[$ii]) && is_array($pMeta[$ii])) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]); if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = '';
153
+ $doAP = $ntOpt['doAP'] && (is_array($pMeta) || $ntOpt['catSel']!='1'); $imgToUse = $ntOpt['imgToUse'];
154
+ $isAvailAP = $ntOpt['appID']!='' && $ntOpt['appSec']!=''; $apMsgFormat = htmlentities($ntOpt['apTextFormat'], ENT_COMPAT, "UTF-8");
155
+ ?>
156
+ <tr><th style="text-align:left;" colspan="2"><?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_AP<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?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', 'nxs_snap') ?> (<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', 'nxs_snap') ?>" />
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', 'nxs_snap' ), $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') ) { nxs_doSMAS5($nt, $ii, $ntOpt); } ?>
174
+
175
+ <?php if ($ntOpt['rpstOn']=='1') { ?>
176
+
177
+ <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top:6px; text-align:right; width:60px; padding-right:10px;">
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.', 'nxs_snap') ?>
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:', 'nxs_snap') ?></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. ', 'nxs_snap'); }
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'))); nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); }
251
+ }
252
+ //## Return Result
253
+ if ($ret['isPosted']=='1') return 200; else return print_r($ret, true);
254
+
255
+ }
256
+ }
257
+ ?>
inc-cl/apis/base_facebook.php DELETED
@@ -1,1431 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright 2011 Facebook, Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License"); you may
6
- * not use this file except in compliance with the License. You may obtain
7
- * a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
- * License for the specific language governing permissions and limitations
15
- * under the License.
16
- */
17
-
18
- if (!function_exists('curl_init')) {
19
- throw new Exception('Facebook needs the CURL PHP extension.');
20
- }
21
- if (!function_exists('json_decode')) {
22
- throw new Exception('Facebook needs the JSON PHP extension.');
23
- }
24
-
25
- /**
26
- * Thrown when an API call returns an exception.
27
- *
28
- * @author Naitik Shah <naitik@facebook.com>
29
- */
30
- class NXS_FacebookApiException extends Exception
31
- {
32
- /**
33
- * The result from the API server that represents the exception information.
34
- */
35
- protected $result;
36
-
37
- /**
38
- * Make a new API Exception with the given result.
39
- *
40
- * @param array $result The result from the API server
41
- */
42
- public function __construct($result) {
43
- $this->result = $result;
44
-
45
- $code = isset($result['error_code']) ? $result['error_code'] : 0;
46
-
47
- if (isset($result['error_description'])) {
48
- // OAuth 2.0 Draft 10 style
49
- $msg = $result['error_description'];
50
- } else if (isset($result['error']) && is_array($result['error'])) {
51
- // OAuth 2.0 Draft 00 style
52
- $msg = $result['error']['message'];
53
- if ($code==0 && isset($result['error']['code'])) $code = $result['error']['code'];
54
- } else if (isset($result['error_msg'])) {
55
- // Rest server style
56
- $msg = $result['error_msg'];
57
- } else {
58
- $msg = 'Unknown Error. Check getResult()';
59
- }
60
-
61
- parent::__construct($msg, $code);
62
- }
63
-
64
- /**
65
- * Return the associated result object returned by the API server.
66
- *
67
- * @return array The result from the API server
68
- */
69
- public function getResult() {
70
- return $this->result;
71
- }
72
-
73
- /**
74
- * Returns the associated type for the error. This will default to
75
- * 'Exception' when a type is not available.
76
- *
77
- * @return string
78
- */
79
- public function getType() {
80
- if (isset($this->result['error'])) {
81
- $error = $this->result['error'];
82
- if (is_string($error)) {
83
- // OAuth 2.0 Draft 10 style
84
- return $error;
85
- } else if (is_array($error)) {
86
- // OAuth 2.0 Draft 00 style
87
- if (isset($error['type'])) {
88
- return $error['type'];
89
- }
90
- }
91
- }
92
-
93
- return 'Exception';
94
- }
95
-
96
- /**
97
- * To make debugging easier.
98
- *
99
- * @return string The string representation of the error
100
- */
101
- public function __toString() {
102
- $str = $this->getType() . ': ';
103
- if ($this->code != 0) {
104
- $str .= $this->code . ': ';
105
- }
106
- return $str . $this->message;
107
- }
108
- }
109
-
110
- /**
111
- * Provides access to the Facebook Platform. This class provides
112
- * a majority of the functionality needed, but the class is abstract
113
- * because it is designed to be sub-classed. The subclass must
114
- * implement the four abstract methods listed at the bottom of
115
- * the file.
116
- *
117
- * @author Naitik Shah <naitik@facebook.com>
118
- */
119
- abstract class NXS_BaseFacebook
120
- {
121
- /**
122
- * Version.
123
- */
124
- const VERSION = '3.2.0';
125
-
126
- /**
127
- * Signed Request Algorithm.
128
- */
129
- const SIGNED_REQUEST_ALGORITHM = 'HMAC-SHA256';
130
-
131
- /**
132
- * Default options for curl.
133
- */
134
- public static $CURL_OPTS = array(
135
- CURLOPT_CONNECTTIMEOUT => 10,
136
- CURLOPT_RETURNTRANSFER => true,
137
- CURLOPT_TIMEOUT => 60,
138
- CURLOPT_USERAGENT => 'facebook-php-3.2',
139
- );
140
-
141
- /**
142
- * List of query parameters that get automatically dropped when rebuilding
143
- * the current URL.
144
- */
145
- protected static $DROP_QUERY_PARAMS = array(
146
- 'code',
147
- 'state',
148
- 'signed_request',
149
- );
150
-
151
- /**
152
- * Maps aliases to Facebook domains.
153
- */
154
- public static $DOMAIN_MAP = array(
155
- 'api' => 'https://api.facebook.com/',
156
- 'api_video' => 'https://api-video.facebook.com/',
157
- 'api_read' => 'https://api-read.facebook.com/',
158
- 'graph' => 'https://graph.facebook.com/',
159
- 'graph_video' => 'https://graph-video.facebook.com/',
160
- 'www' => 'https://www.facebook.com/',
161
- );
162
-
163
- /**
164
- * The Application ID.
165
- *
166
- * @var string
167
- */
168
- protected $appId;
169
-
170
- /**
171
- * The Application App Secret.
172
- *
173
- * @var string
174
- */
175
- protected $appSecret;
176
-
177
- /**
178
- * The ID of the Facebook user, or 0 if the user is logged out.
179
- *
180
- * @var integer
181
- */
182
- protected $user;
183
-
184
- /**
185
- * The data from the signed_request token.
186
- */
187
- protected $signedRequest;
188
-
189
- /**
190
- * A CSRF state variable to assist in the defense against CSRF attacks.
191
- */
192
- protected $state;
193
-
194
- /**
195
- * The OAuth access token received in exchange for a valid authorization
196
- * code. null means the access token has yet to be determined.
197
- *
198
- * @var string
199
- */
200
- protected $accessToken = null;
201
-
202
- /**
203
- * Indicates if the CURL based @ syntax for file uploads is enabled.
204
- *
205
- * @var boolean
206
- */
207
- protected $fileUploadSupport = false;
208
-
209
- /**
210
- * Indicates if we trust HTTP_X_FORWARDED_* headers.
211
- *
212
- * @var boolean
213
- */
214
- protected $trustForwarded = false;
215
-
216
- /**
217
- * Initialize a Facebook Application.
218
- *
219
- * The configuration:
220
- * - appId: the application ID
221
- * - secret: the application secret
222
- * - fileUpload: (optional) boolean indicating if file uploads are enabled
223
- *
224
- * @param array $config The application configuration
225
- */
226
- public function __construct($config) {
227
- $this->setAppId($config['appId']);
228
- $this->setAppSecret($config['secret']);
229
- if (isset($config['fileUpload'])) {
230
- $this->setFileUploadSupport($config['fileUpload']);
231
- }
232
- if (isset($config['trustForwarded']) && $config['trustForwarded']) {
233
- $this->trustForwarded = true;
234
- }
235
- $state = $this->getPersistentData('state');
236
- if (!empty($state)) {
237
- $this->state = $state;
238
- }
239
- }
240
-
241
- /**
242
- * Set the Application ID.
243
- *
244
- * @param string $appId The Application ID
245
- * @return BaseFacebook
246
- */
247
- public function setAppId($appId) {
248
- $this->appId = $appId;
249
- return $this;
250
- }
251
-
252
- /**
253
- * Get the Application ID.
254
- *
255
- * @return string the Application ID
256
- */
257
- public function getAppId() {
258
- return $this->appId;
259
- }
260
-
261
- /**
262
- * Set the App Secret.
263
- *
264
- * @param string $apiSecret The App Secret
265
- * @return BaseFacebook
266
- * @deprecated
267
- */
268
- public function setApiSecret($apiSecret) {
269
- $this->setAppSecret($apiSecret);
270
- return $this;
271
- }
272
-
273
- /**
274
- * Set the App Secret.
275
- *
276
- * @param string $appSecret The App Secret
277
- * @return BaseFacebook
278
- */
279
- public function setAppSecret($appSecret) {
280
- $this->appSecret = $appSecret;
281
- return $this;
282
- }
283
-
284
- /**
285
- * Get the App Secret.
286
- *
287
- * @return string the App Secret
288
- * @deprecated
289
- */
290
- public function getApiSecret() {
291
- return $this->getAppSecret();
292
- }
293
-
294
- /**
295
- * Get the App Secret.
296
- *
297
- * @return string the App Secret
298
- */
299
- public function getAppSecret() {
300
- return $this->appSecret;
301
- }
302
-
303
- /**
304
- * Set the file upload support status.
305
- *
306
- * @param boolean $fileUploadSupport The file upload support status.
307
- * @return BaseFacebook
308
- */
309
- public function setFileUploadSupport($fileUploadSupport) {
310
- $this->fileUploadSupport = $fileUploadSupport;
311
- return $this;
312
- }
313
-
314
- /**
315
- * Get the file upload support status.
316
- *
317
- * @return boolean true if and only if the server supports file upload.
318
- */
319
- public function getFileUploadSupport() {
320
- return $this->fileUploadSupport;
321
- }
322
-
323
- /**
324
- * DEPRECATED! Please use getFileUploadSupport instead.
325
- *
326
- * Get the file upload support status.
327
- *
328
- * @return boolean true if and only if the server supports file upload.
329
- */
330
- public function useFileUploadSupport() {
331
- return $this->getFileUploadSupport();
332
- }
333
-
334
- /**
335
- * Sets the access token for api calls. Use this if you get
336
- * your access token by other means and just want the SDK
337
- * to use it.
338
- *
339
- * @param string $access_token an access token.
340
- * @return BaseFacebook
341
- */
342
- public function setAccessToken($access_token) {
343
- $this->accessToken = $access_token;
344
- return $this;
345
- }
346
-
347
- /**
348
- * Extend an access token, while removing the short-lived token that might
349
- * have been generated via client-side flow. Thanks to http://bit.ly/b0Pt0H
350
- * for the workaround.
351
- */
352
- public function setExtendedAccessToken() {
353
- try {
354
- // need to circumvent json_decode by calling _oauthRequest
355
- // directly, since response isn't JSON format.
356
- $access_token_response = $this->_oauthRequest(
357
- $this->getUrl('graph', '/oauth/access_token'),
358
- $params = array(
359
- 'client_id' => $this->getAppId(),
360
- 'client_secret' => $this->getAppSecret(),
361
- 'grant_type' => 'fb_exchange_token',
362
- 'fb_exchange_token' => $this->getAccessToken(),
363
- )
364
- );
365
- }
366
- catch (NXS_FacebookApiException $e) {
367
- // most likely that user very recently revoked authorization.
368
- // In any event, we don't have an access token, so say so.
369
- return false;
370
- }
371
-
372
- if (empty($access_token_response)) {
373
- return false;
374
- }
375
-
376
- $response_params = array();
377
- parse_str($access_token_response, $response_params);
378
-
379
- if (!isset($response_params['access_token'])) {
380
- return false;
381
- }
382
-
383
- $this->destroySession();
384
-
385
- $this->setPersistentData(
386
- 'access_token', $response_params['access_token']
387
- );
388
- }
389
-
390
- /**
391
- * Determines the access token that should be used for API calls.
392
- * The first time this is called, $this->accessToken is set equal
393
- * to either a valid user access token, or it's set to the application
394
- * access token if a valid user access token wasn't available. Subsequent
395
- * calls return whatever the first call returned.
396
- *
397
- * @return string The access token
398
- */
399
- public function getAccessToken() {
400
- if ($this->accessToken !== null) {
401
- // we've done this already and cached it. Just return.
402
- return $this->accessToken;
403
- }
404
-
405
- // first establish access token to be the application
406
- // access token, in case we navigate to the /oauth/access_token
407
- // endpoint, where SOME access token is required.
408
- $this->setAccessToken($this->getApplicationAccessToken());
409
- $user_access_token = $this->getUserAccessToken();
410
- if ($user_access_token) {
411
- $this->setAccessToken($user_access_token);
412
- }
413
-
414
- return $this->accessToken;
415
- }
416
-
417
- /**
418
- * Determines and returns the user access token, first using
419
- * the signed request if present, and then falling back on
420
- * the authorization code if present. The intent is to
421
- * return a valid user access token, or false if one is determined
422
- * to not be available.
423
- *
424
- * @return string A valid user access token, or false if one
425
- * could not be determined.
426
- */
427
- protected function getUserAccessToken() {
428
- // first, consider a signed request if it's supplied.
429
- // if there is a signed request, then it alone determines
430
- // the access token.
431
- $signed_request = $this->getSignedRequest();
432
- if ($signed_request) {
433
- // apps.facebook.com hands the access_token in the signed_request
434
- if (array_key_exists('oauth_token', $signed_request)) {
435
- $access_token = $signed_request['oauth_token'];
436
- $this->setPersistentData('access_token', $access_token);
437
- return $access_token;
438
- }
439
-
440
- // the JS SDK puts a code in with the redirect_uri of ''
441
- if (array_key_exists('code', $signed_request)) {
442
- $code = $signed_request['code'];
443
- $access_token = $this->getAccessTokenFromCode($code, '');
444
- if ($access_token) {
445
- $this->setPersistentData('code', $code);
446
- $this->setPersistentData('access_token', $access_token);
447
- return $access_token;
448
- }
449
- }
450
-
451
- // signed request states there's no access token, so anything
452
- // stored should be cleared.
453
- $this->clearAllPersistentData();
454
- return false; // respect the signed request's data, even
455
- // if there's an authorization code or something else
456
- }
457
-
458
- $code = $this->getCode();
459
- if ($code && $code != $this->getPersistentData('code')) {
460
- $access_token = $this->getAccessTokenFromCode($code);
461
- if ($access_token) {
462
- $this->setPersistentData('code', $code);
463
- $this->setPersistentData('access_token', $access_token);
464
- return $access_token;
465
- }
466
-
467
- // code was bogus, so everything based on it should be invalidated.
468
- $this->clearAllPersistentData();
469
- return false;
470
- }
471
-
472
- // as a fallback, just return whatever is in the persistent
473
- // store, knowing nothing explicit (signed request, authorization
474
- // code, etc.) was present to shadow it (or we saw a code in $_REQUEST,
475
- // but it's the same as what's in the persistent store)
476
- return $this->getPersistentData('access_token');
477
- }
478
-
479
- /**
480
- * Retrieve the signed request, either from a request parameter or,
481
- * if not present, from a cookie.
482
- *
483
- * @return string the signed request, if available, or null otherwise.
484
- */
485
- public function getSignedRequest() {
486
- if (!$this->signedRequest) {
487
- if (isset($_REQUEST['signed_request'])) {
488
- $this->signedRequest = $this->parseSignedRequest(
489
- $_REQUEST['signed_request']);
490
- } else if (isset($_COOKIE[$this->getSignedRequestCookieName()])) {
491
- $this->signedRequest = $this->parseSignedRequest(
492
- $_COOKIE[$this->getSignedRequestCookieName()]);
493
- }
494
- }
495
- return $this->signedRequest;
496
- }
497
-
498
- /**
499
- * Get the UID of the connected user, or 0
500
- * if the Facebook user is not connected.
501
- *
502
- * @return string the UID if available.
503
- */
504
- public function getUser() {
505
- if ($this->user !== null) {
506
- // we've already determined this and cached the value.
507
- return $this->user;
508
- }
509
-
510
- return $this->user = $this->getUserFromAvailableData();
511
- }
512
-
513
- /**
514
- * Determines the connected user by first examining any signed
515
- * requests, then considering an authorization code, and then
516
- * falling back to any persistent store storing the user.
517
- *
518
- * @return integer The id of the connected Facebook user,
519
- * or 0 if no such user exists.
520
- */
521
- protected function getUserFromAvailableData() {
522
- // if a signed request is supplied, then it solely determines
523
- // who the user is.
524
- $signed_request = $this->getSignedRequest();
525
- if ($signed_request) {
526
- if (array_key_exists('user_id', $signed_request)) {
527
- $user = $signed_request['user_id'];
528
- $this->setPersistentData('user_id', $signed_request['user_id']);
529
- return $user;
530
- }
531
-
532
- // if the signed request didn't present a user id, then invalidate
533
- // all entries in any persistent store.
534
- $this->clearAllPersistentData();
535
- return 0;
536
- }
537
-
538
- $user = $this->getPersistentData('user_id', $default = 0);
539
- $persisted_access_token = $this->getPersistentData('access_token');
540
-
541
- // use access_token to fetch user id if we have a user access_token, or if
542
- // the cached access token has changed.
543
- $access_token = $this->getAccessToken();
544
- if ($access_token &&
545
- $access_token != $this->getApplicationAccessToken() &&
546
- !($user && $persisted_access_token == $access_token)) {
547
- $user = $this->getUserFromAccessToken();
548
- if ($user) {
549
- $this->setPersistentData('user_id', $user);
550
- } else {
551
- $this->clearAllPersistentData();
552
- }
553
- }
554
-
555
- return $user;
556
- }
557
-
558
- /**
559
- * Get a Login URL for use with redirects. By default, full page redirect is
560
- * assumed. If you are using the generated URL with a window.open() call in
561
- * JavaScript, you can pass in display=popup as part of the $params.
562
- *
563
- * The parameters:
564
- * - redirect_uri: the url to go to after a successful login
565
- * - scope: comma separated list of requested extended perms
566
- *
567
- * @param array $params Provide custom parameters
568
- * @return string The URL for the login flow
569
- */
570
- public function getLoginUrl($params=array()) {
571
- $this->establishCSRFTokenState();
572
- $currentUrl = $this->getCurrentUrl();
573
-
574
- // if 'scope' is passed as an array, convert to comma separated list
575
- $scopeParams = isset($params['scope']) ? $params['scope'] : null;
576
- if ($scopeParams && is_array($scopeParams)) {
577
- $params['scope'] = implode(',', $scopeParams);
578
- }
579
-
580
- return $this->getUrl(
581
- 'www',
582
- 'dialog/oauth',
583
- array_merge(array(
584
- 'client_id' => $this->getAppId(),
585
- 'redirect_uri' => $currentUrl, // possibly overwritten
586
- 'state' => $this->state),
587
- $params));
588
- }
589
-
590
- /**
591
- * Get a Logout URL suitable for use with redirects.
592
- *
593
- * The parameters:
594
- * - next: the url to go to after a successful logout
595
- *
596
- * @param array $params Provide custom parameters
597
- * @return string The URL for the logout flow
598
- */
599
- public function getLogoutUrl($params=array()) {
600
- return $this->getUrl(
601
- 'www',
602
- 'logout.php',
603
- array_merge(array(
604
- 'next' => $this->getCurrentUrl(),
605
- 'access_token' => $this->getUserAccessToken(),
606
- ), $params)
607
- );
608
- }
609
-
610
- /**
611
- * Get a login status URL to fetch the status from Facebook.
612
- *
613
- * The parameters:
614
- * - ok_session: the URL to go to if a session is found
615
- * - no_session: the URL to go to if the user is not connected
616
- * - no_user: the URL to go to if the user is not signed into facebook
617
- *
618
- * @param array $params Provide custom parameters
619
- * @return string The URL for the logout flow
620
- */
621
- public function getLoginStatusUrl($params=array()) {
622
- return $this->getUrl(
623
- 'www',
624
- 'extern/login_status.php',
625
- array_merge(array(
626
- 'api_key' => $this->getAppId(),
627
- 'no_session' => $this->getCurrentUrl(),
628
- 'no_user' => $this->getCurrentUrl(),
629
- 'ok_session' => $this->getCurrentUrl(),
630
- 'session_version' => 3,
631
- ), $params)
632
- );
633
- }
634
-
635
- /**
636
- * Make an API call.
637
- *
638
- * @return mixed The decoded response
639
- */
640
- public function api(/* polymorphic */) {
641
- $args = func_get_args();
642
- if (is_array($args[0])) {
643
- return $this->_restserver($args[0]);
644
- } else {
645
- return call_user_func_array(array($this, '_graph'), $args);
646
- }
647
- }
648
-
649
- /**
650
- * Constructs and returns the name of the cookie that
651
- * potentially houses the signed request for the app user.
652
- * The cookie is not set by the BaseFacebook class, but
653
- * it may be set by the JavaScript SDK.
654
- *
655
- * @return string the name of the cookie that would house
656
- * the signed request value.
657
- */
658
- protected function getSignedRequestCookieName() {
659
- return 'fbsr_'.$this->getAppId();
660
- }
661
-
662
- /**
663
- * Constructs and returns the name of the coookie that potentially contain
664
- * metadata. The cookie is not set by the BaseFacebook class, but it may be
665
- * set by the JavaScript SDK.
666
- *
667
- * @return string the name of the cookie that would house metadata.
668
- */
669
- protected function getMetadataCookieName() {
670
- return 'fbm_'.$this->getAppId();
671
- }
672
-
673
- /**
674
- * Get the authorization code from the query parameters, if it exists,
675
- * and otherwise return false to signal no authorization code was
676
- * discoverable.
677
- *
678
- * @return mixed The authorization code, or false if the authorization
679
- * code could not be determined.
680
- */
681
- protected function getCode() {
682
- if (isset($_REQUEST['code'])) {
683
- if ($this->state !== null &&
684
- isset($_REQUEST['state']) &&
685
- $this->state === $_REQUEST['state']) {
686
-
687
- // CSRF state has done its job, so clear it
688
- $this->state = null;
689
- $this->clearPersistentData('state');
690
- return $_REQUEST['code'];
691
- } else {
692
- self::errorLog('CSRF state token does not match one provided.');
693
- return false;
694
- }
695
- }
696
-
697
- return false;
698
- }
699
-
700
- /**
701
- * Retrieves the UID with the understanding that
702
- * $this->accessToken has already been set and is
703
- * seemingly legitimate. It relies on Facebook's Graph API
704
- * to retrieve user information and then extract
705
- * the user ID.
706
- *
707
- * @return integer Returns the UID of the Facebook user, or 0
708
- * if the Facebook user could not be determined.
709
- */
710
- protected function getUserFromAccessToken() {
711
- try {
712
- $user_info = $this->api('/me');
713
- return $user_info['id'];
714
- } catch (NXS_FacebookApiException $e) {
715
- return 0;
716
- }
717
- }
718
-
719
- /**
720
- * Returns the access token that should be used for logged out
721
- * users when no authorization code is available.
722
- *
723
- * @return string The application access token, useful for gathering
724
- * public information about users and applications.
725
- */
726
- protected function getApplicationAccessToken() {
727
- return $this->appId.'|'.$this->appSecret;
728
- }
729
-
730
- /**
731
- * Lays down a CSRF state token for this process.
732
- *
733
- * @return void
734
- */
735
- protected function establishCSRFTokenState() {
736
- if ($this->state === null) {
737
- $this->state = md5(uniqid(mt_rand(), true));
738
- $this->setPersistentData('state', $this->state);
739
- }
740
- }
741
-
742
- /**
743
- * Retrieves an access token for the given authorization code
744
- * (previously generated from www.facebook.com on behalf of
745
- * a specific user). The authorization code is sent to graph.facebook.com
746
- * and a legitimate access token is generated provided the access token
747
- * and the user for which it was generated all match, and the user is
748
- * either logged in to Facebook or has granted an offline access permission.
749
- *
750
- * @param string $code An authorization code.
751
- * @return mixed An access token exchanged for the authorization code, or
752
- * false if an access token could not be generated.
753
- */
754
- protected function getAccessTokenFromCode($code, $redirect_uri = null) {
755
- if (empty($code)) {
756
- return false;
757
- }
758
-
759
- if ($redirect_uri === null) {
760
- $redirect_uri = $this->getCurrentUrl();
761
- }
762
-
763
- try {
764
- // need to circumvent json_decode by calling _oauthRequest
765
- // directly, since response isn't JSON format.
766
- $access_token_response =
767
- $this->_oauthRequest(
768
- $this->getUrl('graph', '/oauth/access_token'),
769
- $params = array('client_id' => $this->getAppId(),
770
- 'client_secret' => $this->getAppSecret(),
771
- 'redirect_uri' => $redirect_uri,
772
- 'code' => $code));
773
- } catch (NXS_FacebookApiException $e) {
774
- // most likely that user very recently revoked authorization.
775
- // In any event, we don't have an access token, so say so.
776
- return false;
777
- }
778
-
779
- if (empty($access_token_response)) {
780
- return false;
781
- }
782
-
783
- $response_params = array();
784
- parse_str($access_token_response, $response_params);
785
- if (!isset($response_params['access_token'])) {
786
- return false;
787
- }
788
-
789
- return $response_params['access_token'];
790
- }
791
-
792
- /**
793
- * Invoke the old restserver.php endpoint.
794
- *
795
- * @param array $params Method call object
796
- *
797
- * @return mixed The decoded response object
798
- * @throws NXS_FacebookApiException
799
- */
800
- protected function _restserver($params) {
801
- // generic application level parameters
802
- $params['api_key'] = $this->getAppId();
803
- $params['format'] = 'json-strings';
804
-
805
- $result = json_decode($this->_oauthRequest(
806
- $this->getApiUrl($params['method']),
807
- $params
808
- ), true);
809
-
810
- // results are returned, errors are thrown
811
- if (is_array($result) && isset($result['error_code'])) {
812
- $this->throwAPIException($result);
813
- // @codeCoverageIgnoreStart
814
- }
815
- // @codeCoverageIgnoreEnd
816
-
817
- $method = strtolower($params['method']);
818
- if ($method === 'auth.expiresession' ||
819
- $method === 'auth.revokeauthorization') {
820
- $this->destroySession();
821
- }
822
-
823
- return $result;
824
- }
825
-
826
- /**
827
- * Return true if this is video post.
828
- *
829
- * @param string $path The path
830
- * @param string $method The http method (default 'GET')
831
- *
832
- * @return boolean true if this is video post
833
- */
834
- protected function isVideoPost($path, $method = 'GET') {
835
- if ($method == 'POST' && preg_match("/^(\/)(.+)(\/)(videos)$/", $path)) {
836
- return true;
837
- }
838
- return false;
839
- }
840
-
841
- /**
842
- * Invoke the Graph API.
843
- *
844
- * @param string $path The path (required)
845
- * @param string $method The http method (default 'GET')
846
- * @param array $params The query/post data
847
- *
848
- * @return mixed The decoded response object
849
- * @throws NXS_FacebookApiException
850
- */
851
- protected function _graph($path, $method = 'GET', $params = array()) {
852
- if (is_array($method) && empty($params)) {
853
- $params = $method;
854
- $method = 'GET';
855
- }
856
- $params['method'] = $method; // method override as we always do a POST
857
-
858
- if ($this->isVideoPost($path, $method)) {
859
- $domainKey = 'graph_video';
860
- } else {
861
- $domainKey = 'graph';
862
- }
863
-
864
- $result = json_decode($this->_oauthRequest(
865
- $this->getUrl($domainKey, $path),
866
- $params
867
- ), true);
868
-
869
- // prr($domainKey); prr($path); prr($params);
870
- // results are returned, errors are thrown
871
- if (is_array($result) && isset($result['error'])) {
872
- $this->throwAPIException($result);
873
- // @codeCoverageIgnoreStart
874
- }
875
- // @codeCoverageIgnoreEnd
876
-
877
- return $result;
878
- }
879
-
880
- /**
881
- * Make a OAuth Request.
882
- *
883
- * @param string $url The path (required)
884
- * @param array $params The query/post data
885
- *
886
- * @return string The decoded response object
887
- * @throws NXS_FacebookApiException
888
- */
889
- protected function _oauthRequest($url, $params) {
890
- if (!isset($params['access_token'])) {
891
- $params['access_token'] = $this->getAccessToken();
892
- }
893
-
894
- // json_encode all params values that are not strings
895
- foreach ($params as $key => $value) {
896
- if (!is_string($value)) {
897
- $params[$key] = json_encode($value);
898
- }
899
- }
900
-
901
- return $this->makeRequest($url, $params);
902
- }
903
-
904
- /**
905
- * Makes an HTTP request. This method can be overridden by subclasses if
906
- * developers want to do fancier things or use something other than curl to
907
- * make the request.
908
- *
909
- * @param string $url The URL to make the request to
910
- * @param array $params The parameters to use for the POST body
911
- * @param CurlHandler $ch Initialized curl handle
912
- *
913
- * @return string The response text
914
- */
915
- protected function makeRequest($url, $params, $ch=null) {
916
- if (!$ch) {
917
- $ch = curl_init();
918
- }
919
- // echo $url;
920
- $opts = self::$CURL_OPTS;
921
- if ($this->getFileUploadSupport()) {
922
- $opts[CURLOPT_POSTFIELDS] = $params;
923
- } else {
924
- $opts[CURLOPT_POSTFIELDS] = http_build_query($params, null, '&');
925
- }
926
- $opts[CURLOPT_URL] = $url;
927
-
928
- // disable the 'Expect: 100-continue' behaviour. This causes CURL to wait
929
- // for 2 seconds if the server does not support this header.
930
- if (isset($opts[CURLOPT_HTTPHEADER])) {
931
- $existing_headers = $opts[CURLOPT_HTTPHEADER];
932
- $existing_headers[] = 'Expect:';
933
- $opts[CURLOPT_HTTPHEADER] = $existing_headers;
934
- } else {
935
- $opts[CURLOPT_HTTPHEADER] = array('Expect:');
936
- }
937
-
938
- curl_setopt_array($ch, $opts);
939
-
940
- $result = curl_exec($ch);
941
-
942
- if (curl_errno($ch) == 60) { // CURLE_SSL_CACERT
943
- self::errorLog('Invalid or no certificate authority found, using bundled information');
944
- curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/fb_ca_chain_bundle.crt');
945
- $result = curl_exec($ch);
946
- }
947
-
948
- if (curl_errno($ch) == 60) { // CURLE_SSL_CACERT
949
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
950
- $result = curl_exec($ch);
951
- }
952
-
953
- // With dual stacked DNS responses, it's possible for a server to
954
- // have IPv6 enabled but not have IPv6 connectivity. If this is
955
- // the case, curl will try IPv4 first and if that fails, then it will
956
- // fall back to IPv6 and the error EHOSTUNREACH is returned by the
957
- // operating system.
958
- if ($result === false && empty($opts[CURLOPT_IPRESOLVE])) {
959
- $matches = array();
960
- $regex = '/Failed to connect to ([^:].*): Network is unreachable/';
961
- if (preg_match($regex, curl_error($ch), $matches)) {
962
- if (strlen(@inet_pton($matches[1])) === 16) {
963
- self::errorLog('Invalid IPv6 configuration on server, '.
964
- 'Please disable or get native IPv6 on your server.');
965
- self::$CURL_OPTS[CURLOPT_IPRESOLVE] = CURL_IPRESOLVE_V4;
966
- curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
967
- $result = curl_exec($ch);
968
- }
969
- }
970
- }
971
-
972
- if ($result === false) {
973
- $e = new NXS_FacebookApiException(array(
974
- 'error_code' => curl_errno($ch),
975
- 'error' => array(
976
- 'message' => curl_error($ch),
977
- 'type' => 'CurlException',
978
- ),
979
- ));
980
- curl_close($ch);
981
- throw $e;
982
- }
983
- curl_close($ch);
984
- return $result;
985
- }
986
-
987
- /**
988
- * Parses a signed_request and validates the signature.
989
- *
990
- * @param string $signed_request A signed token
991
- * @return array The payload inside it or null if the sig is wrong
992
- */
993
- protected function parseSignedRequest($signed_request) {
994
- list($encoded_sig, $payload) = explode('.', $signed_request, 2);
995
-
996
- // decode the data
997
- $sig = self::base64UrlDecode($encoded_sig);
998
- $data = json_decode(self::base64UrlDecode($payload), true);
999
-
1000
- if (strtoupper($data['algorithm']) !== self::SIGNED_REQUEST_ALGORITHM) {
1001
- self::errorLog(
1002
- 'Unknown algorithm. Expected ' . self::SIGNED_REQUEST_ALGORITHM);
1003
- return null;
1004
- }
1005
-
1006
- // check sig
1007
- $expected_sig = hash_hmac('sha256', $payload,
1008
- $this->getAppSecret(), $raw = true);
1009
- if ($sig !== $expected_sig) {
1010
- self::errorLog('Bad Signed JSON signature!');
1011
- return null;
1012
- }
1013
-
1014
- return $data;
1015
- }
1016
-
1017
- /**
1018
- * Makes a signed_request blob using the given data.
1019
- *
1020
- * @param array The data array.
1021
- * @return string The signed request.
1022
- */
1023
- protected function makeSignedRequest($data) {
1024
- if (!is_array($data)) {
1025
- throw new InvalidArgumentException(
1026
- 'makeSignedRequest expects an array. Got: ' . print_r($data, true));
1027
- }
1028
- $data['algorithm'] = self::SIGNED_REQUEST_ALGORITHM;
1029
- $data['issued_at'] = time();
1030
- $json = json_encode($data);
1031
- $b64 = self::base64UrlEncode($json);
1032
- $raw_sig = hash_hmac('sha256', $b64, $this->getAppSecret(), $raw = true);
1033
- $sig = self::base64UrlEncode($raw_sig);
1034
- return $sig.'.'.$b64;
1035
- }
1036
-
1037
- /**
1038
- * Build the URL for api given parameters.
1039
- *
1040
- * @param $method String the method name.
1041
- * @return string The URL for the given parameters
1042
- */
1043
- protected function getApiUrl($method) {
1044
- static $READ_ONLY_CALLS =
1045
- array('admin.getallocation' => 1,
1046
- 'admin.getappproperties' => 1,
1047
- 'admin.getbannedusers' => 1,
1048
- 'admin.getlivestreamvialink' => 1,
1049
- 'admin.getmetrics' => 1,
1050
- 'admin.getrestrictioninfo' => 1,
1051
- 'application.getpublicinfo' => 1,
1052
- 'auth.getapppublickey' => 1,
1053
- 'auth.getsession' => 1,
1054
- 'auth.getsignedpublicsessiondata' => 1,
1055
- 'comments.get' => 1,
1056
- 'connect.getunconnectedfriendscount' => 1,
1057
- 'dashboard.getactivity' => 1,
1058
- 'dashboard.getcount' => 1,
1059
- 'dashboard.getglobalnews' => 1,
1060
- 'dashboard.getnews' => 1,
1061
- 'dashboard.multigetcount' => 1,
1062
- 'dashboard.multigetnews' => 1,
1063
- 'data.getcookies' => 1,
1064
- 'events.get' => 1,
1065
- 'events.getmembers' => 1,
1066
- 'fbml.getcustomtags' => 1,
1067
- 'feed.getappfriendstories' => 1,
1068
- 'feed.getregisteredtemplatebundlebyid' => 1,
1069
- 'feed.getregisteredtemplatebundles' => 1,
1070
- 'fql.multiquery' => 1,
1071
- 'fql.query' => 1,
1072
- 'friends.arefriends' => 1,
1073
- 'friends.get' => 1,
1074
- 'friends.getappusers' => 1,
1075
- 'friends.getlists' => 1,
1076
- 'friends.getmutualfriends' => 1,
1077
- 'gifts.get' => 1,
1078
- 'groups.get' => 1,
1079
- 'groups.getmembers' => 1,
1080
- 'intl.gettranslations' => 1,
1081
- 'links.get' => 1,
1082
- 'notes.get' => 1,
1083
- 'notifications.get' => 1,
1084
- 'pages.getinfo' => 1,
1085
- 'pages.isadmin' => 1,
1086
- 'pages.isappadded' => 1,
1087
- 'pages.isfan' => 1,
1088
- 'permissions.checkavailableapiaccess' => 1,
1089
- 'permissions.checkgrantedapiaccess' => 1,
1090
- 'photos.get' => 1,
1091
- 'photos.getalbums' => 1,
1092
- 'photos.gettags' => 1,
1093
- 'profile.getinfo' => 1,
1094
- 'profile.getinfooptions' => 1,
1095
- 'stream.get' => 1,
1096
- 'stream.getcomments' => 1,
1097
- 'stream.getfilters' => 1,
1098
- 'users.getinfo' => 1,
1099
- 'users.getloggedinuser' => 1,
1100
- 'users.getstandardinfo' => 1,
1101
- 'users.hasapppermission' => 1,
1102
- 'users.isappuser' => 1,
1103
- 'users.isverified' => 1,
1104
- 'video.getuploadlimits' => 1);
1105
- $name = 'api';
1106
- if (isset($READ_ONLY_CALLS[strtolower($method)])) {
1107
- $name = 'api_read';
1108
- } else if (strtolower($method) == 'video.upload') {
1109
- $name = 'api_video';
1110
- }
1111
- return self::getUrl($name, 'restserver.php');
1112
- }
1113
-
1114
- /**
1115
- * Build the URL for given domain alias, path and parameters.
1116
- *
1117
- * @param $name string The name of the domain
1118
- * @param $path string Optional path (without a leading slash)
1119
- * @param $params array Optional query parameters
1120
- *
1121
- * @return string The URL for the given parameters
1122
- */
1123
- protected function getUrl($name, $path='', $params=array()) {
1124
- $url = self::$DOMAIN_MAP[$name];
1125
- if ($path) {
1126
- if ($path[0] === '/') {
1127
- $path = substr($path, 1);
1128
- }
1129
- $url .= $path;
1130
- }
1131
- if ($params) {
1132
- $url .= '?' . http_build_query($params, null, '&');
1133
- }
1134
-
1135
- return $url;
1136
- }
1137
-
1138
- protected function getHttpHost() {
1139
- if ($this->trustForwarded && isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
1140
- return $_SERVER['HTTP_X_FORWARDED_HOST'];
1141
- }
1142
- return $_SERVER['HTTP_HOST'];
1143
- }
1144
-
1145
- protected function getHttpProtocol() {
1146
- if ($this->trustForwarded && isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) {
1147
- if ($_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
1148
- return 'https';
1149
- }
1150
- return 'http';
1151
- }
1152
- if (isset($_SERVER['HTTPS']) &&
1153
- ($_SERVER['HTTPS'] === 'on' || $_SERVER['HTTPS'] == 1)) {
1154
- return 'https';
1155
- }
1156
- return 'http';
1157
- }
1158
-
1159
- /**
1160
- * Get the base domain used for the cookie.
1161
- */
1162
- protected function getBaseDomain() {
1163
- // The base domain is stored in the metadata cookie if not we fallback
1164
- // to the current hostname
1165
- $metadata = $this->getMetadataCookie();
1166
- if (array_key_exists('base_domain', $metadata) &&
1167
- !empty($metadata['base_domain'])) {
1168
- return trim($metadata['base_domain'], '.');
1169
- }
1170
- return $this->getHttpHost();
1171
- }
1172
-
1173
- /**
1174
-
1175
- /**
1176
- * Returns the Current URL, stripping it of known FB parameters that should
1177
- * not persist.
1178
- *
1179
- * @return string The current URL
1180
- */
1181
- protected function getCurrentUrl() {
1182
- $protocol = $this->getHttpProtocol() . '://';
1183
- $host = $this->getHttpHost();
1184
- $currentUrl = $protocol.$host.$_SERVER['REQUEST_URI'];
1185
- $parts = parse_url($currentUrl);
1186
-
1187
- $query = '';
1188
- if (!empty($parts['query'])) {
1189
- // drop known fb params
1190
- $params = explode('&', $parts['query']);
1191
- $retained_params = array();
1192
- foreach ($params as $param) {
1193
- if ($this->shouldRetainParam($param)) {
1194
- $retained_params[] = $param;
1195
- }
1196
- }
1197
-
1198
- if (!empty($retained_params)) {
1199
- $query = '?'.implode($retained_params, '&');
1200
- }
1201
- }
1202
-
1203
- // use port if non default
1204
- $port =
1205
- isset($parts['port']) &&
1206
- (($protocol === 'http://' && $parts['port'] !== 80) ||
1207
- ($protocol === 'https://' && $parts['port'] !== 443))
1208
- ? ':' . $parts['port'] : '';
1209
-
1210
- // rebuild
1211
- return $protocol . $parts['host'] . $port . $parts['path'] . $query;
1212
- }
1213
-
1214
- /**
1215
- * Returns true if and only if the key or key/value pair should
1216
- * be retained as part of the query string. This amounts to
1217
- * a brute-force search of the very small list of Facebook-specific
1218
- * params that should be stripped out.
1219
- *
1220
- * @param string $param A key or key/value pair within a URL's query (e.g.
1221
- * 'foo=a', 'foo=', or 'foo'.
1222
- *
1223
- * @return boolean
1224
- */
1225
- protected function shouldRetainParam($param) {
1226
- foreach (self::$DROP_QUERY_PARAMS as $drop_query_param) {
1227
- if (strpos($param, $drop_query_param.'=') === 0) {
1228
- return false;
1229
- }
1230
- }
1231
-
1232
- return true;
1233
- }
1234
-
1235
- /**
1236
- * Analyzes the supplied result to see if it was thrown
1237
- * because the access token is no longer valid. If that is
1238
- * the case, then we destroy the session.
1239
- *
1240
- * @param $result array A record storing the error message returned
1241
- * by a failed API call.
1242
- */
1243
- protected function throwAPIException($result) { //prr($result);
1244
- $e = new NXS_FacebookApiException($result);
1245
- switch ($e->getType()) {
1246
- // OAuth 2.0 Draft 00 style
1247
- case 'OAuthException':
1248
- // OAuth 2.0 Draft 10 style
1249
- case 'invalid_token':
1250
- // REST server errors are just Exceptions
1251
- case 'Exception':
1252
- $message = $e->getMessage();
1253
- if ((strpos($message, 'Error validating access token') !== false) ||
1254
- (strpos($message, 'Invalid OAuth access token') !== false) ||
1255
- (strpos($message, 'An active access token must be used') !== false)
1256
- ) {
1257
- $this->destroySession();
1258
- }
1259
- break;
1260
- }
1261
-
1262
- throw $e;
1263
- }
1264
-
1265
-
1266
- /**
1267
- * Prints to the error log if you aren't in command line mode.
1268
- *
1269
- * @param string $msg Log message
1270
- */
1271
- protected static function errorLog($msg) {
1272
- // disable error log if we are running in a CLI environment
1273
- // @codeCoverageIgnoreStart
1274
- if (php_sapi_name() != 'cli') {
1275
- error_log($msg);
1276
- }
1277
- // uncomment this if you want to see the errors on the page
1278
- // print 'error_log: '.$msg."\n";
1279
- // @codeCoverageIgnoreEnd
1280
- }
1281
-
1282
- /**
1283
- * Base64 encoding that doesn't need to be urlencode()ed.
1284
- * Exactly the same as base64_encode except it uses
1285
- * - instead of +
1286
- * _ instead of /
1287
- * No padded =
1288
- *
1289
- * @param string $input base64UrlEncoded string
1290
- * @return string
1291
- */
1292
- protected static function base64UrlDecode($input) {
1293
- return base64_decode(strtr($input, '-_', '+/'));
1294
- }
1295
-
1296
- /**
1297
- * Base64 encoding that doesn't need to be urlencode()ed.
1298
- * Exactly the same as base64_encode except it uses
1299
- * - instead of +
1300
- * _ instead of /
1301
- *
1302
- * @param string $input string
1303
- * @return string base64Url encoded string
1304
- */
1305
- protected static function base64UrlEncode($input) {
1306
- $str = strtr(base64_encode($input), '+/', '-_');
1307
- $str = str_replace('=', '', $str);
1308
- return $str;
1309
- }
1310
-
1311
- /**
1312
- * Destroy the current session
1313
- */
1314
- public function destroySession() {
1315
- $this->accessToken = null;
1316
- $this->signedRequest = null;
1317
- $this->user = null;
1318
- $this->clearAllPersistentData();
1319
-
1320
- // Javascript sets a cookie that will be used in getSignedRequest that we
1321
- // need to clear if we can
1322
- $cookie_name = $this->getSignedRequestCookieName();
1323
- if (array_key_exists($cookie_name, $_COOKIE)) {
1324
- unset($_COOKIE[$cookie_name]);
1325
- if (!headers_sent()) {
1326
- $base_domain = $this->getBaseDomain();
1327
- setcookie($cookie_name, '', 1, '/', '.'.$base_domain);
1328
- } else {
1329
- // @codeCoverageIgnoreStart
1330
- self::errorLog(
1331
- 'There exists a cookie that we wanted to clear that we couldn\'t '.
1332
- 'clear because headers was already sent. Make sure to do the first '.
1333
- 'API call before outputing anything.'
1334
- );
1335
- // @codeCoverageIgnoreEnd
1336
- }
1337
- }
1338
- }
1339
-
1340
- /**
1341
- * Parses the metadata cookie that our Javascript API set
1342
- *
1343
- * @return an array mapping key to value
1344
- */
1345
- protected function getMetadataCookie() {
1346
- $cookie_name = $this->getMetadataCookieName();
1347
- if (!array_key_exists($cookie_name, $_COOKIE)) {
1348
- return array();
1349
- }
1350
-
1351
- // The cookie value can be wrapped in "-characters so remove them
1352
- $cookie_value = trim($_COOKIE[$cookie_name], '"');
1353
-
1354
- if (empty($cookie_value)) {
1355
- return array();
1356
- }
1357
-
1358
- $parts = explode('&', $cookie_value);
1359
- $metadata = array();
1360
- foreach ($parts as $part) {
1361
- $pair = explode('=', $part, 2);
1362
- if (!empty($pair[0])) {
1363
- $metadata[urldecode($pair[0])] =
1364
- (count($pair) > 1) ? urldecode($pair[1]) : '';
1365
- }
1366
- }
1367
-
1368
- return $metadata;
1369
- }
1370
-
1371
- protected static function isAllowedDomain($big, $small) {
1372
- if ($big === $small) {
1373
- return true;
1374
- }
1375
- return self::endsWith($big, '.'.$small);
1376
- }
1377
-
1378
- protected static function endsWith($big, $small) {
1379
- $len = strlen($small);
1380
- if ($len === 0) {
1381
- return true;
1382
- }
1383
- return substr($big, -$len) === $small;
1384
- }
1385
-
1386
- /**
1387
- * Each of the following four methods should be overridden in
1388
- * a concrete subclass, as they are in the provided Facebook class.
1389
- * The Facebook class uses PHP sessions to provide a primitive
1390
- * persistent store, but another subclass--one that you implement--
1391
- * might use a database, memcache, or an in-memory cache.
1392
- *
1393
- * @see Facebook
1394
- */
1395
-
1396
- /**
1397
- * Stores the given ($key, $value) pair, so that future calls to
1398
- * getPersistentData($key) return $value. This call may be in another request.
1399
- *
1400
- * @param string $key
1401
- * @param array $value
1402
- *
1403
- * @return void
1404
- */
1405
- abstract protected function setPersistentData($key, $value);
1406
-
1407
- /**
1408
- * Get the data for $key, persisted by BaseFacebook::setPersistentData()
1409
- *
1410
- * @param string $key The key of the data to retrieve
1411
- * @param boolean $default The default value to return if $key is not found
1412
- *
1413
- * @return mixed
1414
- */
1415
- abstract protected function getPersistentData($key, $default = false);
1416
-
1417
- /**
1418
- * Clear the data with $key from the persistent storage
1419
- *
1420
- * @param string $key
1421
- * @return void
1422
- */
1423
- abstract protected function clearPersistentData($key);
1424
-
1425
- /**
1426
- * Clear all data from the persistent storage
1427
- *
1428
- * @return void
1429
- */
1430
- abstract protected function clearAllPersistentData();
1431
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc-cl/apis/facebook.php CHANGED
@@ -15,10 +15,1450 @@
15
  * under the License.
16
  */
17
 
18
- require_once "base_facebook.php";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
  /**
21
- * Extends the BaseFacebook class with the intent of using
22
  * PHP sessions to store user ids and access tokens.
23
  */
24
  class NXS_Facebook extends NXS_BaseFacebook
@@ -42,15 +1482,25 @@ class NXS_Facebook extends NXS_BaseFacebook
42
  * accepts "sharedSession" as a boolean to turn on a secondary
43
  * cookie for environments with a shared session (that is, your app
44
  * shares the domain with other apps).
45
- * @see BaseFacebook::__construct in facebook.php
46
  */
47
  public function __construct($config) {
48
- if (!session_id() && !headers_sent() ) {
49
  session_start();
50
  }
51
  parent::__construct($config);
52
  if (!empty($config['sharedSession'])) {
53
  $this->initSharedSession();
 
 
 
 
 
 
 
 
 
 
54
  }
55
  }
56
 
@@ -127,7 +1577,9 @@ class NXS_Facebook extends NXS_BaseFacebook
127
  }
128
 
129
  $session_var_name = $this->constructSessionVariableName($key);
130
- unset($_SESSION[$session_var_name]);
 
 
131
  }
132
 
133
  protected function clearAllPersistentData() {
@@ -158,3 +1610,4 @@ class NXS_Facebook extends NXS_BaseFacebook
158
  return implode('_', $parts);
159
  }
160
  }
 
15
  * under the License.
16
  */
17
 
18
+ if (!function_exists('curl_init')) {
19
+ throw new Exception('Facebook needs the CURL PHP extension.');
20
+ }
21
+ if (!function_exists('json_decode')) {
22
+ throw new Exception('Facebook needs the JSON PHP extension.');
23
+ }
24
+
25
+ /**
26
+ * Thrown when an API call returns an exception.
27
+ *
28
+ * @author Naitik Shah <naitik@facebook.com>
29
+ */
30
+ class NXS_FacebookApiException extends Exception
31
+ {
32
+ /**
33
+ * The result from the API server that represents the exception information.
34
+ */
35
+ protected $result;
36
+
37
+ /**
38
+ * Make a new API Exception with the given result.
39
+ *
40
+ * @param array $result The result from the API server
41
+ */
42
+ public function __construct($result) {
43
+ $this->result = $result;
44
+
45
+ $code = isset($result['error_code']) ? $result['error_code'] : 0;
46
+
47
+ if (isset($result['error_description'])) {
48
+ // OAuth 2.0 Draft 10 style
49
+ $msg = $result['error_description'];
50
+ } else if (isset($result['error']) && is_array($result['error'])) {
51
+ // OAuth 2.0 Draft 00 style
52
+ $msg = $result['error']['message'];
53
+ } else if (isset($result['error_msg'])) {
54
+ // Rest server style
55
+ $msg = $result['error_msg'];
56
+ } else {
57
+ $msg = 'Unknown Error. Check getResult()';
58
+ }
59
+
60
+ parent::__construct($msg, $code);
61
+ }
62
+
63
+ /**
64
+ * Return the associated result object returned by the API server.
65
+ *
66
+ * @return array The result from the API server
67
+ */
68
+ public function getResult() {
69
+ return $this->result;
70
+ }
71
+
72
+ /**
73
+ * Returns the associated type for the error. This will default to
74
+ * 'Exception' when a type is not available.
75
+ *
76
+ * @return string
77
+ */
78
+ public function getType() {
79
+ if (isset($this->result['error'])) {
80
+ $error = $this->result['error'];
81
+ if (is_string($error)) {
82
+ // OAuth 2.0 Draft 10 style
83
+ return $error;
84
+ } else if (is_array($error)) {
85
+ // OAuth 2.0 Draft 00 style
86
+ if (isset($error['type'])) {
87
+ return $error['type'];
88
+ }
89
+ }
90
+ }
91
+
92
+ return 'Exception';
93
+ }
94
+
95
+ /**
96
+ * To make debugging easier.
97
+ *
98
+ * @return string The string representation of the error
99
+ */
100
+ public function __toString() {
101
+ $str = $this->getType() . ': ';
102
+ if ($this->code != 0) {
103
+ $str .= $this->code . ': ';
104
+ }
105
+ return $str . $this->message;
106
+ }
107
+ }
108
+
109
+ /**
110
+ * Provides access to the Facebook Platform. This class provides
111
+ * a majority of the functionality needed, but the class is abstract
112
+ * because it is designed to be sub-classed. The subclass must
113
+ * implement the four abstract methods listed at the bottom of
114
+ * the file.
115
+ *
116
+ * @author Naitik Shah <naitik@facebook.com>
117
+ */
118
+ abstract class NXS_BaseFacebook
119
+ {
120
+ /**
121
+ * Version.
122
+ */
123
+ const VERSION = '3.2.2';
124
+
125
+ /**
126
+ * Signed Request Algorithm.
127
+ */
128
+ const SIGNED_REQUEST_ALGORITHM = 'HMAC-SHA256';
129
+
130
+ /**
131
+ * Default options for curl.
132
+ */
133
+ public static $CURL_OPTS = array(
134
+ CURLOPT_CONNECTTIMEOUT => 10,
135
+ CURLOPT_RETURNTRANSFER => true,
136
+ CURLOPT_TIMEOUT => 60,
137
+ CURLOPT_USERAGENT => 'facebook-php-3.2',
138
+ );
139
+
140
+ /**
141
+ * List of query parameters that get automatically dropped when rebuilding
142
+ * the current URL.
143
+ */
144
+ protected static $DROP_QUERY_PARAMS = array(
145
+ 'code',
146
+ 'state',
147
+ 'signed_request',
148
+ );
149
+
150
+ /**
151
+ * Maps aliases to Facebook domains.
152
+ */
153
+ public static $DOMAIN_MAP = array(
154
+ 'api' => 'https://api.facebook.com/',
155
+ 'api_video' => 'https://api-video.facebook.com/',
156
+ 'api_read' => 'https://api-read.facebook.com/',
157
+ 'graph' => 'https://graph.facebook.com/',
158
+ 'graph_video' => 'https://graph-video.facebook.com/',
159
+ 'www' => 'https://www.facebook.com/',
160
+ );
161
+
162
+ /**
163
+ * The Application ID.
164
+ *
165
+ * @var string
166
+ */
167
+ protected $appId;
168
+
169
+ /**
170
+ * The Application App Secret.
171
+ *
172
+ * @var string
173
+ */
174
+ protected $appSecret;
175
+
176
+ /**
177
+ * The ID of the Facebook user, or 0 if the user is logged out.
178
+ *
179
+ * @var integer
180
+ */
181
+ protected $user;
182
+
183
+ /**
184
+ * The data from the signed_request token.
185
+ */
186
+ protected $signedRequest;
187
+
188
+ /**
189
+ * A CSRF state variable to assist in the defense against CSRF attacks.
190
+ */
191
+ protected $state;
192
+
193
+ /**
194
+ * The OAuth access token received in exchange for a valid authorization
195
+ * code. null means the access token has yet to be determined.
196
+ *
197
+ * @var string
198
+ */
199
+ protected $accessToken = null;
200
+
201
+ /**
202
+ * Indicates if the CURL based @ syntax for file uploads is enabled.
203
+ *
204
+ * @var boolean
205
+ */
206
+ protected $fileUploadSupport = false;
207
+
208
+ /**
209
+ * Indicates if we trust HTTP_X_FORWARDED_* headers.
210
+ *
211
+ * @var boolean
212
+ */
213
+ protected $trustForwarded = false;
214
+
215
+ /**
216
+ * Initialize a Facebook Application.
217
+ *
218
+ * The configuration:
219
+ * - appId: the application ID
220
+ * - secret: the application secret
221
+ * - fileUpload: (optional) boolean indicating if file uploads are enabled
222
+ *
223
+ * @param array $config The application configuration
224
+ */
225
+ public function __construct($config) {
226
+ $this->setAppId($config['appId']);
227
+ $this->setAppSecret($config['secret']);
228
+ if (isset($config['fileUpload'])) {
229
+ $this->setFileUploadSupport($config['fileUpload']);
230
+ }
231
+ if (isset($config['trustForwarded']) && $config['trustForwarded']) {
232
+ $this->trustForwarded = true;
233
+ }
234
+ $state = $this->getPersistentData('state');
235
+ if (!empty($state)) {
236
+ $this->state = $state;
237
+ }
238
+ }
239
+
240
+ /**
241
+ * Set the Application ID.
242
+ *
243
+ * @param string $appId The Application ID
244
+ * @return NXS_BaseFacebook
245
+ */
246
+ public function setAppId($appId) {
247
+ $this->appId = $appId;
248
+ return $this;
249
+ }
250
+
251
+ /**
252
+ * Get the Application ID.
253
+ *
254
+ * @return string the Application ID
255
+ */
256
+ public function getAppId() {
257
+ return $this->appId;
258
+ }
259
+
260
+ /**
261
+ * Set the App Secret.
262
+ *
263
+ * @param string $apiSecret The App Secret
264
+ * @return NXS_BaseFacebook
265
+ * @deprecated Use setAppSecret instead.
266
+ */
267
+ public function setApiSecret($apiSecret) {
268
+ $this->setAppSecret($apiSecret);
269
+ return $this;
270
+ }
271
+
272
+ /**
273
+ * Set the App Secret.
274
+ *
275
+ * @param string $appSecret The App Secret
276
+ * @return NXS_BaseFacebook
277
+ */
278
+ public function setAppSecret($appSecret) {
279
+ $this->appSecret = $appSecret;
280
+ return $this;
281
+ }
282
+
283
+ /**
284
+ * Get the App Secret.
285
+ *
286
+ * @return string the App Secret
287
+ * @deprecated Use getAppSecret instead.
288
+ */
289
+ public function getApiSecret() {
290
+ return $this->getAppSecret();
291
+ }
292
+
293
+ /**
294
+ * Get the App Secret.
295
+ *
296
+ * @return string the App Secret
297
+ */
298
+ public function getAppSecret() {
299
+ return $this->appSecret;
300
+ }
301
+
302
+ /**
303
+ * Set the file upload support status.
304
+ *
305
+ * @param boolean $fileUploadSupport The file upload support status.
306
+ * @return NXS_BaseFacebook
307
+ */
308
+ public function setFileUploadSupport($fileUploadSupport) {
309
+ $this->fileUploadSupport = $fileUploadSupport;
310
+ return $this;
311
+ }
312
+
313
+ /**
314
+ * Get the file upload support status.
315
+ *
316
+ * @return boolean true if and only if the server supports file upload.
317
+ */
318
+ public function getFileUploadSupport() {
319
+ return $this->fileUploadSupport;
320
+ }
321
+
322
+ /**
323
+ * Get the file upload support status.
324
+ *
325
+ * @return boolean true if and only if the server supports file upload.
326
+ * @deprecated Use getFileUploadSupport instead.
327
+ */
328
+ public function useFileUploadSupport() {
329
+ return $this->getFileUploadSupport();
330
+ }
331
+
332
+ /**
333
+ * Sets the access token for api calls. Use this if you get
334
+ * your access token by other means and just want the SDK
335
+ * to use it.
336
+ *
337
+ * @param string $access_token an access token.
338
+ * @return NXS_BaseFacebook
339
+ */
340
+ public function setAccessToken($access_token) {
341
+ $this->accessToken = $access_token;
342
+ return $this;
343
+ }
344
+
345
+ /**
346
+ * Extend an access token, while removing the short-lived token that might
347
+ * have been generated via client-side flow. Thanks to http://bit.ly/b0Pt0H
348
+ * for the workaround.
349
+ */
350
+ public function setExtendedAccessToken() {
351
+ try {
352
+ // need to circumvent json_decode by calling _oauthRequest
353
+ // directly, since response isn't JSON format.
354
+ $access_token_response = $this->_oauthRequest(
355
+ $this->getUrl('graph', '/oauth/access_token'),
356
+ $params = array(
357
+ 'client_id' => $this->getAppId(),
358
+ 'client_secret' => $this->getAppSecret(),
359
+ 'grant_type' => 'fb_exchange_token',
360
+ 'fb_exchange_token' => $this->getAccessToken(),
361
+ )
362
+ );
363
+ }
364
+ catch (NXS_FacebookApiException $e) {
365
+ // most likely that user very recently revoked authorization.
366
+ // In any event, we don't have an access token, so say so.
367
+ return false;
368
+ }
369
+
370
+ if (empty($access_token_response)) {
371
+ return false;
372
+ }
373
+
374
+ $response_params = array();
375
+ parse_str($access_token_response, $response_params);
376
+
377
+ if (!isset($response_params['access_token'])) {
378
+ return false;
379
+ }
380
+
381
+ $this->destroySession();
382
+
383
+ $this->setPersistentData(
384
+ 'access_token', $response_params['access_token']
385
+ );
386
+ }
387
+
388
+ /**
389
+ * Determines the access token that should be used for API calls.
390
+ * The first time this is called, $this->accessToken is set equal
391
+ * to either a valid user access token, or it's set to the application
392
+ * access token if a valid user access token wasn't available. Subsequent
393
+ * calls return whatever the first call returned.
394
+ *
395
+ * @return string The access token
396
+ */
397
+ public function getAccessToken() {
398
+ if ($this->accessToken !== null) {
399
+ // we've done this already and cached it. Just return.
400
+ return $this->accessToken;
401
+ }
402
+
403
+ // first establish access token to be the application
404
+ // access token, in case we navigate to the /oauth/access_token
405
+ // endpoint, where SOME access token is required.
406
+ $this->setAccessToken($this->getApplicationAccessToken());
407
+ $user_access_token = $this->getUserAccessToken();
408
+ if ($user_access_token) {
409
+ $this->setAccessToken($user_access_token);
410
+ }
411
+
412
+ return $this->accessToken;
413
+ }
414
+
415
+ /**
416
+ * Determines and returns the user access token, first using
417
+ * the signed request if present, and then falling back on
418
+ * the authorization code if present. The intent is to
419
+ * return a valid user access token, or false if one is determined
420
+ * to not be available.
421
+ *
422
+ * @return string A valid user access token, or false if one
423
+ * could not be determined.
424
+ */
425
+ protected function getUserAccessToken() {
426
+ // first, consider a signed request if it's supplied.
427
+ // if there is a signed request, then it alone determines
428
+ // the access token.
429
+ $signed_request = $this->getSignedRequest();
430
+ if ($signed_request) {
431
+ // apps.facebook.com hands the access_token in the signed_request
432
+ if (array_key_exists('oauth_token', $signed_request)) {
433
+ $access_token = $signed_request['oauth_token'];
434
+ $this->setPersistentData('access_token', $access_token);
435
+ return $access_token;
436
+ }
437
+
438
+ // the JS SDK puts a code in with the redirect_uri of ''
439
+ if (array_key_exists('code', $signed_request)) {
440
+ $code = $signed_request['code'];
441
+ if ($code && $code == $this->getPersistentData('code')) {
442
+ // short-circuit if the code we have is the same as the one presented
443
+ return $this->getPersistentData('access_token');
444
+ }
445
+
446
+ $access_token = $this->getAccessTokenFromCode($code, '');
447
+ if ($access_token) {
448
+ $this->setPersistentData('code', $code);
449
+ $this->setPersistentData('access_token', $access_token);
450
+ return $access_token;
451
+ }
452
+ }
453
+
454
+ // signed request states there's no access token, so anything
455
+ // stored should be cleared.
456
+ $this->clearAllPersistentData();
457
+ return false; // respect the signed request's data, even
458
+ // if there's an authorization code or something else
459
+ }
460
+
461
+ $code = $this->getCode();
462
+ if ($code && $code != $this->getPersistentData('code')) {
463
+ $access_token = $this->getAccessTokenFromCode($code);
464
+ if ($access_token) {
465
+ $this->setPersistentData('code', $code);
466
+ $this->setPersistentData('access_token', $access_token);
467
+ return $access_token;
468
+ }
469
+
470
+ // code was bogus, so everything based on it should be invalidated.
471
+ $this->clearAllPersistentData();
472
+ return false;
473
+ }
474
+
475
+ // as a fallback, just return whatever is in the persistent
476
+ // store, knowing nothing explicit (signed request, authorization
477
+ // code, etc.) was present to shadow it (or we saw a code in $_REQUEST,
478
+ // but it's the same as what's in the persistent store)
479
+ return $this->getPersistentData('access_token');
480
+ }
481
+
482
+ /**
483
+ * Retrieve the signed request, either from a request parameter or,
484
+ * if not present, from a cookie.
485
+ *
486
+ * @return string the signed request, if available, or null otherwise.
487
+ */
488
+ public function getSignedRequest() {
489
+ if (!$this->signedRequest) {
490
+ if (!empty($_REQUEST['signed_request'])) {
491
+ $this->signedRequest = $this->parseSignedRequest(
492
+ $_REQUEST['signed_request']);
493
+ } else if (!empty($_COOKIE[$this->getSignedRequestCookieName()])) {
494
+ $this->signedRequest = $this->parseSignedRequest(
495
+ $_COOKIE[$this->getSignedRequestCookieName()]);
496
+ }
497
+ }
498
+ return $this->signedRequest;
499
+ }
500
+
501
+ /**
502
+ * Get the UID of the connected user, or 0
503
+ * if the Facebook user is not connected.
504
+ *
505
+ * @return string the UID if available.
506
+ */
507
+ public function getUser() {
508
+ if ($this->user !== null) {
509
+ // we've already determined this and cached the value.
510
+ return $this->user;
511
+ }
512
+
513
+ return $this->user = $this->getUserFromAvailableData();
514
+ }
515
+
516
+ /**
517
+ * Determines the connected user by first examining any signed
518
+ * requests, then considering an authorization code, and then
519
+ * falling back to any persistent store storing the user.
520
+ *
521
+ * @return integer The id of the connected Facebook user,
522
+ * or 0 if no such user exists.
523
+ */
524
+ protected function getUserFromAvailableData() {
525
+ // if a signed request is supplied, then it solely determines
526
+ // who the user is.
527
+ $signed_request = $this->getSignedRequest();
528
+ if ($signed_request) {
529
+ if (array_key_exists('user_id', $signed_request)) {
530
+ $user = $signed_request['user_id'];
531
+
532
+ if($user != $this->getPersistentData('user_id')){
533
+ $this->clearAllPersistentData();
534
+ }
535
+
536
+ $this->setPersistentData('user_id', $signed_request['user_id']);
537
+ return $user;
538
+ }
539
+
540
+ // if the signed request didn't present a user id, then invalidate
541
+ // all entries in any persistent store.
542
+ $this->clearAllPersistentData();
543
+ return 0;
544
+ }
545
+
546
+ $user = $this->getPersistentData('user_id', $default = 0);
547
+ $persisted_access_token = $this->getPersistentData('access_token');
548
+
549
+ // use access_token to fetch user id if we have a user access_token, or if
550
+ // the cached access token has changed.
551
+ $access_token = $this->getAccessToken();
552
+ if ($access_token &&
553
+ $access_token != $this->getApplicationAccessToken() &&
554
+ !($user && $persisted_access_token == $access_token)) {
555
+ $user = $this->getUserFromAccessToken();
556
+ if ($user) {
557
+ $this->setPersistentData('user_id', $user);
558
+ } else {
559
+ $this->clearAllPersistentData();
560
+ }
561
+ }
562
+
563
+ return $user;
564
+ }
565
+
566
+ /**
567
+ * Get a Login URL for use with redirects. By default, full page redirect is
568
+ * assumed. If you are using the generated URL with a window.open() call in
569
+ * JavaScript, you can pass in display=popup as part of the $params.
570
+ *
571
+ * The parameters:
572
+ * - redirect_uri: the url to go to after a successful login
573
+ * - scope: comma separated list of requested extended perms
574
+ *
575
+ * @param array $params Provide custom parameters
576
+ * @return string The URL for the login flow
577
+ */
578
+ public function getLoginUrl($params=array()) {
579
+ $this->establishCSRFTokenState();
580
+ $currentUrl = $this->getCurrentUrl();
581
+
582
+ // if 'scope' is passed as an array, convert to comma separated list
583
+ $scopeParams = isset($params['scope']) ? $params['scope'] : null;
584
+ if ($scopeParams && is_array($scopeParams)) {
585
+ $params['scope'] = implode(',', $scopeParams);
586
+ }
587
+
588
+ return $this->getUrl(
589
+ 'www',
590
+ 'dialog/oauth',
591
+ array_merge(
592
+ array(
593
+ 'client_id' => $this->getAppId(),
594
+ 'redirect_uri' => $currentUrl, // possibly overwritten
595
+ 'state' => $this->state,
596
+ 'sdk' => 'php-sdk-'.self::VERSION
597
+ ),
598
+ $params
599
+ ));
600
+ }
601
+
602
+ /**
603
+ * Get a Logout URL suitable for use with redirects.
604
+ *
605
+ * The parameters:
606
+ * - next: the url to go to after a successful logout
607
+ *
608
+ * @param array $params Provide custom parameters
609
+ * @return string The URL for the logout flow
610
+ */
611
+ public function getLogoutUrl($params=array()) {
612
+ return $this->getUrl(
613
+ 'www',
614
+ 'logout.php',
615
+ array_merge(array(
616
+ 'next' => $this->getCurrentUrl(),
617
+ 'access_token' => $this->getUserAccessToken(),
618
+ ), $params)
619
+ );
620
+ }
621
+
622
+ /**
623
+ * Get a login status URL to fetch the status from Facebook.
624
+ *
625
+ * @param array $params Provide custom parameters
626
+ * @return string The URL for the logout flow
627
+ */
628
+ public function getLoginStatusUrl($params=array()) {
629
+ return $this->getLoginUrl(
630
+ array_merge(array(
631
+ 'response_type' => 'code',
632
+ 'display' => 'none',
633
+ ), $params)
634
+ );
635
+ }
636
+
637
+ /**
638
+ * Make an API call.
639
+ *
640
+ * @return mixed The decoded response
641
+ */
642
+ public function api(/* polymorphic */) {
643
+ $args = func_get_args();
644
+ if (is_array($args[0])) {
645
+ return $this->_restserver($args[0]);
646
+ } else {
647
+ return call_user_func_array(array($this, '_graph'), $args);
648
+ }
649
+ }
650
+
651
+ /**
652
+ * Constructs and returns the name of the cookie that
653
+ * potentially houses the signed request for the app user.
654
+ * The cookie is not set by the NXS_BaseFacebook class, but
655
+ * it may be set by the JavaScript SDK.
656
+ *
657
+ * @return string the name of the cookie that would house
658
+ * the signed request value.
659
+ */
660
+ protected function getSignedRequestCookieName() {
661
+ return 'fbsr_'.$this->getAppId();
662
+ }
663
+
664
+ /**
665
+ * Constructs and returns the name of the coookie that potentially contain
666
+ * metadata. The cookie is not set by the NXS_BaseFacebook class, but it may be
667
+ * set by the JavaScript SDK.
668
+ *
669
+ * @return string the name of the cookie that would house metadata.
670
+ */
671
+ protected function getMetadataCookieName() {
672
+ return 'fbm_'.$this->getAppId();
673
+ }
674
+
675
+ /**
676
+ * Get the authorization code from the query parameters, if it exists,
677
+ * and otherwise return false to signal no authorization code was
678
+ * discoverable.
679
+ *
680
+ * @return mixed The authorization code, or false if the authorization
681
+ * code could not be determined.
682
+ */
683
+ protected function getCode() {
684
+ if (isset($_REQUEST['code'])) {
685
+ if ($this->state !== null &&
686
+ isset($_REQUEST['state']) &&
687
+ $this->state === $_REQUEST['state']) {
688
+
689
+ // CSRF state has done its job, so clear it
690
+ $this->state = null;
691
+ $this->clearPersistentData('state');
692
+ return $_REQUEST['code'];
693
+ } else {
694
+ self::errorLog('CSRF state token does not match one provided.');
695
+ return false;
696
+ }
697
+ }
698
+
699
+ return false;
700
+ }
701
+
702
+ /**
703
+ * Retrieves the UID with the understanding that
704
+ * $this->accessToken has already been set and is
705
+ * seemingly legitimate. It relies on Facebook's Graph API
706
+ * to retrieve user information and then extract
707
+ * the user ID.
708
+ *
709
+ * @return integer Returns the UID of the Facebook user, or 0
710
+ * if the Facebook user could not be determined.
711
+ */
712
+ protected function getUserFromAccessToken() {
713
+ try {
714
+ $user_info = $this->api('/me');
715
+ return $user_info['id'];
716
+ } catch (NXS_FacebookApiException $e) {
717
+ return 0;
718
+ }
719
+ }
720
+
721
+ /**
722
+ * Returns the access token that should be used for logged out
723
+ * users when no authorization code is available.
724
+ *
725
+ * @return string The application access token, useful for gathering
726
+ * public information about users and applications.
727
+ */
728
+ public function getApplicationAccessToken() {
729
+ return $this->appId.'|'.$this->appSecret;
730
+ }
731
+
732
+ /**
733
+ * Lays down a CSRF state token for this process.
734
+ *
735
+ * @return void
736
+ */
737
+ protected function establishCSRFTokenState() {
738
+ if ($this->state === null) {
739
+ $this->state = md5(uniqid(mt_rand(), true));
740
+ $this->setPersistentData('state', $this->state);
741
+ }
742
+ }
743
+
744
+ /**
745
+ * Retrieves an access token for the given authorization code
746
+ * (previously generated from www.facebook.com on behalf of
747
+ * a specific user). The authorization code is sent to graph.facebook.com
748
+ * and a legitimate access token is generated provided the access token
749
+ * and the user for which it was generated all match, and the user is
750
+ * either logged in to Facebook or has granted an offline access permission.
751
+ *
752
+ * @param string $code An authorization code.
753
+ * @return mixed An access token exchanged for the authorization code, or
754
+ * false if an access token could not be generated.
755
+ */
756
+ protected function getAccessTokenFromCode($code, $redirect_uri = null) {
757
+ if (empty($code)) {
758
+ return false;
759
+ }
760
+
761
+ if ($redirect_uri === null) {
762
+ $redirect_uri = $this->getCurrentUrl();
763
+ }
764
+
765
+ try {
766
+ // need to circumvent json_decode by calling _oauthRequest
767
+ // directly, since response isn't JSON format.
768
+ $access_token_response =
769
+ $this->_oauthRequest(
770
+ $this->getUrl('graph', '/oauth/access_token'),
771
+ $params = array('client_id' => $this->getAppId(),
772
+ 'client_secret' => $this->getAppSecret(),
773
+ 'redirect_uri' => $redirect_uri,
774
+ 'code' => $code));
775
+ } catch (NXS_FacebookApiException $e) {
776
+ // most likely that user very recently revoked authorization.
777
+ // In any event, we don't have an access token, so say so.
778
+ return false;
779
+ }
780
+
781
+ if (empty($access_token_response)) {
782
+ return false;
783
+ }
784
+
785
+ $response_params = array();
786
+ parse_str($access_token_response, $response_params);
787
+ if (!isset($response_params['access_token'])) {
788
+ return false;
789
+ }
790
+
791
+ return $response_params['access_token'];
792
+ }
793
+
794
+ /**
795
+ * Invoke the old restserver.php endpoint.
796
+ *
797
+ * @param array $params Method call object
798
+ *
799
+ * @return mixed The decoded response object
800
+ * @throws NXS_FacebookApiException
801
+ */
802
+ protected function _restserver($params) {
803
+ // generic application level parameters
804
+ $params['api_key'] = $this->getAppId();
805
+ $params['format'] = 'json-strings';
806
+
807
+ $result = json_decode($this->_oauthRequest(
808
+ $this->getApiUrl($params['method']),
809
+ $params
810
+ ), true);
811
+
812
+ // results are returned, errors are thrown
813
+ if (is_array($result) && isset($result['error_code'])) {
814
+ $this->throwAPIException($result);
815
+ // @codeCoverageIgnoreStart
816
+ }
817
+ // @codeCoverageIgnoreEnd
818
+
819
+ $method = strtolower($params['method']);
820
+ if ($method === 'auth.expiresession' ||
821
+ $method === 'auth.revokeauthorization') {
822
+ $this->destroySession();
823
+ }
824
+
825
+ return $result;
826
+ }
827
+
828
+ /**
829
+ * Return true if this is video post.
830
+ *
831
+ * @param string $path The path
832
+ * @param string $method The http method (default 'GET')
833
+ *
834
+ * @return boolean true if this is video post
835
+ */
836
+ protected function isVideoPost($path, $method = 'GET') {
837
+ if ($method == 'POST' && preg_match("/^(\/)(.+)(\/)(videos)$/", $path)) {
838
+ return true;
839
+ }
840
+ return false;
841
+ }
842
+
843
+ /**
844
+ * Invoke the Graph API.
845
+ *
846
+ * @param string $path The path (required)
847
+ * @param string $method The http method (default 'GET')
848
+ * @param array $params The query/post data
849
+ *
850
+ * @return mixed The decoded response object
851
+ * @throws NXS_FacebookApiException
852
+ */
853
+ protected function _graph($path, $method = 'GET', $params = array()) {
854
+ if (is_array($method) && empty($params)) {
855
+ $params = $method;
856
+ $method = 'GET';
857
+ }
858
+ $params['method'] = $method; // method override as we always do a POST
859
+
860
+ if ($this->isVideoPost($path, $method)) {
861
+ $domainKey = 'graph_video';
862
+ } else {
863
+ $domainKey = 'graph';
864
+ }
865
+
866
+ $result = json_decode($this->_oauthRequest(
867
+ $this->getUrl($domainKey, $path),
868
+ $params
869
+ ), true);
870
+
871
+ // results are returned, errors are thrown
872
+ if (is_array($result) && isset($result['error'])) {
873
+ $this->throwAPIException($result);
874
+ // @codeCoverageIgnoreStart
875
+ }
876
+ // @codeCoverageIgnoreEnd
877
+
878
+ return $result;
879
+ }
880
+
881
+ /**
882
+ * Make a OAuth Request.
883
+ *
884
+ * @param string $url The path (required)
885
+ * @param array $params The query/post data
886
+ *
887
+ * @return string The decoded response object
888
+ * @throws NXS_FacebookApiException
889
+ */
890
+ protected function _oauthRequest($url, $params) {
891
+ if (!isset($params['access_token'])) {
892
+ $params['access_token'] = $this->getAccessToken();
893
+ }
894
+
895
+ if (isset($params['access_token'])) {
896
+ $params['appsecret_proof'] = $this->getAppSecretProof($params['access_token']);
897
+ }
898
+
899
+ // json_encode all params values that are not strings
900
+ foreach ($params as $key => $value) {
901
+ if (!is_string($value)) {
902
+ $params[$key] = json_encode($value);
903
+ }
904
+ }
905
+
906
+ return $this->makeRequest($url, $params);
907
+ }
908
+
909
+ /**
910
+ * Generate a proof of App Secret
911
+ * This is required for all API calls originating from a server
912
+ * It is a sha256 hash of the access_token made using the app secret
913
+ *
914
+ * @param string $access_token The access_token to be hashed (required)
915
+ *
916
+ * @return string The sha256 hash of the access_token
917
+ */
918
+ protected function getAppSecretProof($access_token) {
919
+ return hash_hmac('sha256', $access_token, $this->getAppSecret());
920
+ }
921
+
922
+ /**
923
+ * Makes an HTTP request. This method can be overridden by subclasses if
924
+ * developers want to do fancier things or use something other than curl to
925
+ * make the request.
926
+ *
927
+ * @param string $url The URL to make the request to
928
+ * @param array $params The parameters to use for the POST body
929
+ * @param CurlHandler $ch Initialized curl handle
930
+ *
931
+ * @return string The response text
932
+ */
933
+ protected function makeRequest($url, $params, $ch=null) {
934
+ if (!$ch) {
935
+ $ch = curl_init();
936
+ }
937
+
938
+ $opts = self::$CURL_OPTS;
939
+ if ($this->getFileUploadSupport()) {
940
+ $opts[CURLOPT_POSTFIELDS] = $params;
941
+ } else {
942
+ $opts[CURLOPT_POSTFIELDS] = http_build_query($params, null, '&');
943
+ }
944
+ $opts[CURLOPT_URL] = $url;
945
+
946
+ // disable the 'Expect: 100-continue' behaviour. This causes CURL to wait
947
+ // for 2 seconds if the server does not support this header.
948
+ if (isset($opts[CURLOPT_HTTPHEADER])) {
949
+ $existing_headers = $opts[CURLOPT_HTTPHEADER];
950
+ $existing_headers[] = 'Expect:';
951
+ $opts[CURLOPT_HTTPHEADER] = $existing_headers;
952
+ } else {
953
+ $opts[CURLOPT_HTTPHEADER] = array('Expect:');
954
+ }
955
+
956
+ if(defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) { curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); }
957
+
958
+ curl_setopt_array($ch, $opts);
959
+ $result = curl_exec($ch);
960
+
961
+ $errno = curl_errno($ch);
962
+ // CURLE_SSL_CACERT || CURLE_SSL_CACERT_BADFILE
963
+ if ($errno == 60 || $errno == 77) {
964
+ self::errorLog('Invalid or no certificate authority found, '.
965
+ 'using bundled information');
966
+ curl_setopt($ch, CURLOPT_CAINFO,
967
+ dirname(__FILE__) . '/fb_ca_chain_bundle.crt');
968
+ $result = curl_exec($ch);
969
+ }
970
+
971
+ if (curl_errno($ch) == 60) { // CURLE_SSL_CACERT NXS Change
972
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
973
+ $result = curl_exec($ch);
974
+ }
975
+
976
+ // With dual stacked DNS responses, it's possible for a server to
977
+ // have IPv6 enabled but not have IPv6 connectivity. If this is
978
+ // the case, curl will try IPv4 first and if that fails, then it will
979
+ // fall back to IPv6 and the error EHOSTUNREACH is returned by the
980
+ // operating system.
981
+ if ($result === false && empty($opts[CURLOPT_IPRESOLVE])) {
982
+ $matches = array();
983
+ $regex = '/Failed to connect to ([^:].*): Network is unreachable/';
984
+ if (preg_match($regex, curl_error($ch), $matches)) {
985
+ if (strlen(@inet_pton($matches[1])) === 16) {
986
+ self::errorLog('Invalid IPv6 configuration on server, '.
987
+ 'Please disable or get native IPv6 on your server.');
988
+ self::$CURL_OPTS[CURLOPT_IPRESOLVE] = CURL_IPRESOLVE_V4;
989
+ curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
990
+ $result = curl_exec($ch);
991
+ }
992
+ }
993
+ }
994
+
995
+ if ($result === false) {
996
+ $e = new NXS_FacebookApiException(array(
997
+ 'error_code' => curl_errno($ch),
998
+ 'error' => array(
999
+ 'message' => curl_error($ch),
1000
+ 'type' => 'CurlException',
1001
+ ),
1002
+ ));
1003
+ curl_close($ch);
1004
+ throw $e;
1005
+ }
1006
+ curl_close($ch);
1007
+ return $result;
1008
+ }
1009
+
1010
+ /**
1011
+ * Parses a signed_request and validates the signature.
1012
+ *
1013
+ * @param string $signed_request A signed token
1014
+ * @return array The payload inside it or null if the sig is wrong
1015
+ */
1016
+ protected function parseSignedRequest($signed_request) {
1017
+ list($encoded_sig, $payload) = explode('.', $signed_request, 2);
1018
+
1019
+ // decode the data
1020
+ $sig = self::base64UrlDecode($encoded_sig);
1021
+ $data = json_decode(self::base64UrlDecode($payload), true);
1022
+
1023
+ if (strtoupper($data['algorithm']) !== self::SIGNED_REQUEST_ALGORITHM) {
1024
+ self::errorLog(
1025
+ 'Unknown algorithm. Expected ' . self::SIGNED_REQUEST_ALGORITHM);
1026
+ return null;
1027
+ }
1028
+
1029
+ // check sig
1030
+ $expected_sig = hash_hmac('sha256', $payload,
1031
+ $this->getAppSecret(), $raw = true);
1032
+ if ($sig !== $expected_sig) {
1033
+ self::errorLog('Bad Signed JSON signature!');
1034
+ return null;
1035
+ }
1036
+
1037
+ return $data;
1038
+ }
1039
+
1040
+ /**
1041
+ * Makes a signed_request blob using the given data.
1042
+ *
1043
+ * @param array The data array.
1044
+ * @return string The signed request.
1045
+ */
1046
+ protected function makeSignedRequest($data) {
1047
+ if (!is_array($data)) {
1048
+ throw new InvalidArgumentException(
1049
+ 'makeSignedRequest expects an array. Got: ' . print_r($data, true));
1050
+ }
1051
+ $data['algorithm'] = self::SIGNED_REQUEST_ALGORITHM;
1052
+ $data['issued_at'] = time();
1053
+ $json = json_encode($data);
1054
+ $b64 = self::base64UrlEncode($json);
1055
+ $raw_sig = hash_hmac('sha256', $b64, $this->getAppSecret(), $raw = true);
1056
+ $sig = self::base64UrlEncode($raw_sig);
1057
+ return $sig.'.'.$b64;
1058
+ }
1059
+
1060
+ /**
1061
+ * Build the URL for api given parameters.
1062
+ *
1063
+ * @param $method String the method name.
1064
+ * @return string The URL for the given parameters
1065
+ */
1066
+ protected function getApiUrl($method) {
1067
+ static $READ_ONLY_CALLS =
1068
+ array('admin.getallocation' => 1,
1069
+ 'admin.getappproperties' => 1,
1070
+ 'admin.getbannedusers' => 1,
1071
+ 'admin.getlivestreamvialink' => 1,
1072
+ 'admin.getmetrics' => 1,
1073
+ 'admin.getrestrictioninfo' => 1,
1074
+ 'application.getpublicinfo' => 1,
1075
+ 'auth.getapppublickey' => 1,
1076
+ 'auth.getsession' => 1,
1077
+ 'auth.getsignedpublicsessiondata' => 1,
1078
+ 'comments.get' => 1,
1079
+ 'connect.getunconnectedfriendscount' => 1,
1080
+ 'dashboard.getactivity' => 1,
1081
+ 'dashboard.getcount' => 1,
1082
+ 'dashboard.getglobalnews' => 1,
1083
+ 'dashboard.getnews' => 1,
1084
+ 'dashboard.multigetcount' => 1,
1085
+ 'dashboard.multigetnews' => 1,
1086
+ 'data.getcookies' => 1,
1087
+ 'events.get' => 1,
1088
+ 'events.getmembers' => 1,
1089
+ 'fbml.getcustomtags' => 1,
1090
+ 'feed.getappfriendstories' => 1,
1091
+ 'feed.getregisteredtemplatebundlebyid' => 1,
1092
+ 'feed.getregisteredtemplatebundles' => 1,
1093
+ 'fql.multiquery' => 1,
1094
+ 'fql.query' => 1,
1095
+ 'friends.arefriends' => 1,
1096
+ 'friends.get' => 1,
1097
+ 'friends.getappusers' => 1,
1098
+ 'friends.getlists' => 1,
1099
+ 'friends.getmutualfriends' => 1,
1100
+ 'gifts.get' => 1,
1101
+ 'groups.get' => 1,
1102
+ 'groups.getmembers' => 1,
1103
+ 'intl.gettranslations' => 1,
1104
+ 'links.get' => 1,
1105
+ 'notes.get' => 1,
1106
+ 'notifications.get' => 1,
1107
+ 'pages.getinfo' => 1,
1108
+ 'pages.isadmin' => 1,
1109
+ 'pages.isappadded' => 1,
1110
+ 'pages.isfan' => 1,
1111
+ 'permissions.checkavailableapiaccess' => 1,
1112
+ 'permissions.checkgrantedapiaccess' => 1,
1113
+ 'photos.get' => 1,
1114
+ 'photos.getalbums' => 1,
1115
+ 'photos.gettags' => 1,
1116
+ 'profile.getinfo' => 1,
1117
+ 'profile.getinfooptions' => 1,
1118
+ 'stream.get' => 1,
1119
+ 'stream.getcomments' => 1,
1120
+ 'stream.getfilters' => 1,
1121
+ 'users.getinfo' => 1,
1122
+ 'users.getloggedinuser' => 1,
1123
+ 'users.getstandardinfo' => 1,
1124
+ 'users.hasapppermission' => 1,
1125
+ 'users.isappuser' => 1,
1126
+ 'users.isverified' => 1,
1127
+ 'video.getuploadlimits' => 1);
1128
+ $name = 'api';
1129
+ if (isset($READ_ONLY_CALLS[strtolower($method)])) {
1130
+ $name = 'api_read';
1131
+ } else if (strtolower($method) == 'video.upload') {
1132
+ $name = 'api_video';
1133
+ }
1134
+ return self::getUrl($name, 'restserver.php');
1135
+ }
1136
+
1137
+ /**
1138
+ * Build the URL for given domain alias, path and parameters.
1139
+ *
1140
+ * @param $name string The name of the domain
1141
+ * @param $path string Optional path (without a leading slash)
1142
+ * @param $params array Optional query parameters
1143
+ *
1144
+ * @return string The URL for the given parameters
1145
+ */
1146
+ protected function getUrl($name, $path='', $params=array()) {
1147
+ $url = self::$DOMAIN_MAP[$name];
1148
+ if ($path) {
1149
+ if ($path[0] === '/') {
1150
+ $path = substr($path, 1);
1151
+ }
1152
+ $url .= $path;
1153
+ }
1154
+ if ($params) {
1155
+ $url .= '?' . http_build_query($params, null, '&');
1156
+ }
1157
+
1158
+ return $url;
1159
+ }
1160
+
1161
+ protected function getHttpHost() {
1162
+ if ($this->trustForwarded && isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
1163
+ return $_SERVER['HTTP_X_FORWARDED_HOST'];
1164
+ }
1165
+ return $_SERVER['HTTP_HOST'];
1166
+ }
1167
+
1168
+ protected function getHttpProtocol() {
1169
+ if ($this->trustForwarded && isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) {
1170
+ if ($_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
1171
+ return 'https';
1172
+ }
1173
+ return 'http';
1174
+ }
1175
+ /*apache + variants specific way of checking for https*/
1176
+ if (isset($_SERVER['HTTPS']) &&
1177
+ ($_SERVER['HTTPS'] === 'on' || $_SERVER['HTTPS'] == 1)) {
1178
+ return 'https';
1179
+ }
1180
+ /*nginx way of checking for https*/
1181
+ if (isset($_SERVER['SERVER_PORT']) &&
1182
+ ($_SERVER['SERVER_PORT'] === '443')) {
1183
+ return 'https';
1184
+ }
1185
+ return 'http';
1186
+ }
1187
+
1188
+ /**
1189
+ * Get the base domain used for the cookie.
1190
+ */
1191
+ protected function getBaseDomain() {
1192
+ // The base domain is stored in the metadata cookie if not we fallback
1193
+ // to the current hostname
1194
+ $metadata = $this->getMetadataCookie();
1195
+ if (array_key_exists('base_domain', $metadata) &&
1196
+ !empty($metadata['base_domain'])) {
1197
+ return trim($metadata['base_domain'], '.');
1198
+ }
1199
+ return $this->getHttpHost();
1200
+ }
1201
+
1202
+ /**
1203
+ * Returns the Current URL, stripping it of known FB parameters that should
1204
+ * not persist.
1205
+ *
1206
+ * @return string The current URL
1207
+ */
1208
+ protected function getCurrentUrl() {
1209
+ $protocol = $this->getHttpProtocol() . '://';
1210
+ $host = $this->getHttpHost();
1211
+ $currentUrl = $protocol.$host.$_SERVER['REQUEST_URI'];
1212
+ $parts = parse_url($currentUrl);
1213
+
1214
+ $query = '';
1215
+ if (!empty($parts['query'])) {
1216
+ // drop known fb params
1217
+ $params = explode('&', $parts['query']);
1218
+ $retained_params = array();
1219
+ foreach ($params as $param) {
1220
+ if ($this->shouldRetainParam($param)) {
1221
+ $retained_params[] = $param;
1222
+ }
1223
+ }
1224
+
1225
+ if (!empty($retained_params)) {
1226
+ $query = '?'.implode($retained_params, '&');
1227
+ }
1228
+ }
1229
+
1230
+ // use port if non default
1231
+ $port =
1232
+ isset($parts['port']) &&
1233
+ (($protocol === 'http://' && $parts['port'] !== 80) ||
1234
+ ($protocol === 'https://' && $parts['port'] !== 443))
1235
+ ? ':' . $parts['port'] : '';
1236
+
1237
+ // rebuild
1238
+ return $protocol . $parts['host'] . $port . $parts['path'] . $query;
1239
+ }
1240
+
1241
+ /**
1242
+ * Returns true if and only if the key or key/value pair should
1243
+ * be retained as part of the query string. This amounts to
1244
+ * a brute-force search of the very small list of Facebook-specific
1245
+ * params that should be stripped out.
1246
+ *
1247
+ * @param string $param A key or key/value pair within a URL's query (e.g.
1248
+ * 'foo=a', 'foo=', or 'foo'.
1249
+ *
1250
+ * @return boolean
1251
+ */
1252
+ protected function shouldRetainParam($param) {
1253
+ foreach (self::$DROP_QUERY_PARAMS as $drop_query_param) {
1254
+ if (strpos($param, $drop_query_param.'=') === 0) {
1255
+ return false;
1256
+ }
1257
+ }
1258
+
1259
+ return true;
1260
+ }
1261
+
1262
+ /**
1263
+ * Analyzes the supplied result to see if it was thrown
1264
+ * because the access token is no longer valid. If that is
1265
+ * the case, then we destroy the session.
1266
+ *
1267
+ * @param $result array A record storing the error message returned
1268
+ * by a failed API call.
1269
+ */
1270
+ protected function throwAPIException($result) {
1271
+ $e = new NXS_FacebookApiException($result);
1272
+ switch ($e->getType()) {
1273
+ // OAuth 2.0 Draft 00 style
1274
+ case 'OAuthException':
1275
+ // OAuth 2.0 Draft 10 style
1276
+ case 'invalid_token':
1277
+ // REST server errors are just Exceptions
1278
+ case 'Exception':
1279
+ $message = $e->getMessage();
1280
+ if ((strpos($message, 'Error validating access token') !== false) ||
1281
+ (strpos($message, 'Invalid OAuth access token') !== false) ||
1282
+ (strpos($message, 'An active access token must be used') !== false)
1283
+ ) {
1284
+ $this->destroySession();
1285
+ }
1286
+ break;
1287
+ }
1288
+
1289
+ throw $e;
1290
+ }
1291
+
1292
+
1293
+ /**
1294
+ * Prints to the error log if you aren't in command line mode.
1295
+ *
1296
+ * @param string $msg Log message
1297
+ */
1298
+ protected static function errorLog($msg) {
1299
+ // disable error log if we are running in a CLI environment
1300
+ // @codeCoverageIgnoreStart
1301
+ if (php_sapi_name() != 'cli') {
1302
+ error_log($msg);
1303
+ }
1304
+ // uncomment this if you want to see the errors on the page
1305
+ // print 'error_log: '.$msg."\n";
1306
+ // @codeCoverageIgnoreEnd
1307
+ }
1308
+
1309
+ /**
1310
+ * Base64 encoding that doesn't need to be urlencode()ed.
1311
+ * Exactly the same as base64_encode except it uses
1312
+ * - instead of +
1313
+ * _ instead of /
1314
+ * No padded =
1315
+ *
1316
+ * @param string $input base64UrlEncoded string
1317
+ * @return string
1318
+ */
1319
+ protected static function base64UrlDecode($input) {
1320
+ return base64_decode(strtr($input, '-_', '+/'));
1321
+ }
1322
+
1323
+ /**
1324
+ * Base64 encoding that doesn't need to be urlencode()ed.
1325
+ * Exactly the same as base64_encode except it uses
1326
+ * - instead of +
1327
+ * _ instead of /
1328
+ *
1329
+ * @param string $input string
1330
+ * @return string base64Url encoded string
1331
+ */
1332
+ protected static function base64UrlEncode($input) {
1333
+ $str = strtr(base64_encode($input), '+/', '-_');
1334
+ $str = str_replace('=', '', $str);
1335
+ return $str;
1336
+ }
1337
+
1338
+ /**
1339
+ * Destroy the current session
1340
+ */
1341
+ public function destroySession() {
1342
+ $this->accessToken = null;
1343
+ $this->signedRequest = null;
1344
+ $this->user = null;
1345
+ $this->clearAllPersistentData();
1346
+
1347
+ // Javascript sets a cookie that will be used in getSignedRequest that we
1348
+ // need to clear if we can
1349
+ $cookie_name = $this->getSignedRequestCookieName();
1350
+ if (array_key_exists($cookie_name, $_COOKIE)) {
1351
+ unset($_COOKIE[$cookie_name]);
1352
+ if (!headers_sent()) {
1353
+ $base_domain = $this->getBaseDomain();
1354
+ setcookie($cookie_name, '', 1, '/', '.'.$base_domain);
1355
+ } else {
1356
+ // @codeCoverageIgnoreStart
1357
+ self::errorLog(
1358
+ 'There exists a cookie that we wanted to clear that we couldn\'t '.
1359
+ 'clear because headers was already sent. Make sure to do the first '.
1360
+ 'API call before outputing anything.'
1361
+ );
1362
+ // @codeCoverageIgnoreEnd
1363
+ }
1364
+ }
1365
+ }
1366
+
1367
+ /**
1368
+ * Parses the metadata cookie that our Javascript API set
1369
+ *
1370
+ * @return an array mapping key to value
1371
+ */
1372
+ protected function getMetadataCookie() {
1373
+ $cookie_name = $this->getMetadataCookieName();
1374
+ if (!array_key_exists($cookie_name, $_COOKIE)) {
1375
+ return array();
1376
+ }
1377
+
1378
+ // The cookie value can be wrapped in "-characters so remove them
1379
+ $cookie_value = trim($_COOKIE[$cookie_name], '"');
1380
+
1381
+ if (empty($cookie_value)) {
1382
+ return array();
1383
+ }
1384
+
1385
+ $parts = explode('&', $cookie_value);
1386
+ $metadata = array();
1387
+ foreach ($parts as $part) {
1388
+ $pair = explode('=', $part, 2);
1389
+ if (!empty($pair[0])) {
1390
+ $metadata[urldecode($pair[0])] =
1391
+ (count($pair) > 1) ? urldecode($pair[1]) : '';
1392
+ }
1393
+ }
1394
+
1395
+ return $metadata;
1396
+ }
1397
+
1398
+ protected static function isAllowedDomain($big, $small) {
1399
+ if ($big === $small) {
1400
+ return true;
1401
+ }
1402
+ return self::endsWith($big, '.'.$small);
1403
+ }
1404
+
1405
+ protected static function endsWith($big, $small) {
1406
+ $len = strlen($small);
1407
+ if ($len === 0) {
1408
+ return true;
1409
+ }
1410
+ return substr($big, -$len) === $small;
1411
+ }
1412
+
1413
+ /**
1414
+ * Each of the following four methods should be overridden in
1415
+ * a concrete subclass, as they are in the provided Facebook class.
1416
+ * The Facebook class uses PHP sessions to provide a primitive
1417
+ * persistent store, but another subclass--one that you implement--
1418
+ * might use a database, memcache, or an in-memory cache.
1419
+ *
1420
+ * @see Facebook
1421
+ */
1422
+
1423
+ /**
1424
+ * Stores the given ($key, $value) pair, so that future calls to
1425
+ * getPersistentData($key) return $value. This call may be in another request.
1426
+ *
1427
+ * @param string $key
1428
+ * @param array $value
1429
+ *
1430
+ * @return void
1431
+ */
1432
+ abstract protected function setPersistentData($key, $value);
1433
+
1434
+ /**
1435
+ * Get the data for $key, persisted by NXS_BaseFacebook::setPersistentData()
1436
+ *
1437
+ * @param string $key The key of the data to retrieve
1438
+ * @param boolean $default The default value to return if $key is not found
1439
+ *
1440
+ * @return mixed
1441
+ */
1442
+ abstract protected function getPersistentData($key, $default = false);
1443
+
1444
+ /**
1445
+ * Clear the data with $key from the persistent storage
1446
+ *
1447
+ * @param string $key
1448
+ * @return void
1449
+ */
1450
+ abstract protected function clearPersistentData($key);
1451
+
1452
+ /**
1453
+ * Clear all data from the persistent storage
1454
+ *
1455
+ * @return void
1456
+ */
1457
+ abstract protected function clearAllPersistentData();
1458
+ }
1459
 
1460
  /**
1461
+ * Extends the NXS_BaseFacebook class with the intent of using
1462
  * PHP sessions to store user ids and access tokens.
1463
  */
1464
  class NXS_Facebook extends NXS_BaseFacebook
1482
  * accepts "sharedSession" as a boolean to turn on a secondary
1483
  * cookie for environments with a shared session (that is, your app
1484
  * shares the domain with other apps).
1485
+ * @see NXS_BaseFacebook::__construct in facebook.php
1486
  */
1487
  public function __construct($config) {
1488
+ if (!session_id()) {
1489
  session_start();
1490
  }
1491
  parent::__construct($config);
1492
  if (!empty($config['sharedSession'])) {
1493
  $this->initSharedSession();
1494
+
1495
+ // re-load the persisted state, since parent
1496
+ // attempted to read out of non-shared cookie
1497
+ $state = $this->getPersistentData('state');
1498
+ if (!empty($state)) {
1499
+ $this->state = $state;
1500
+ } else {
1501
+ $this->state = null;
1502
+ }
1503
+
1504
  }
1505
  }
1506
 
1577
  }
1578
 
1579
  $session_var_name = $this->constructSessionVariableName($key);
1580
+ if (isset($_SESSION[$session_var_name])) {
1581
+ unset($_SESSION[$session_var_name]);
1582
+ }
1583
  }
1584
 
1585
  protected function clearAllPersistentData() {
1610
  return implode('_', $parts);
1611
  }
1612
  }
1613
+ ?>
inc-cl/apis/liOAuth.php CHANGED
@@ -92,21 +92,22 @@ class nsx_LinkedIn {
92
  $request = nsx_trOAuthRequest::from_consumer_and_token($this->consumer, $this->access_token, "POST", $status_url);
93
  $request->sign_request($this->signature_method, $this->consumer, $this->access_token);
94
  $auth_header = $request->to_header("https://api.linkedin.com");
95
- if ($debug) echo $auth_header . "\n";
96
  $response = $this->httpRequest($status_url, $auth_header, "POST", $xml);
97
  return $response;
98
  }
99
 
100
  function postToGroup($msg, $title, $groupID, $url='', $imgURL='', $dsc='') { $status_url = $this->base_url . "/v1/groups/".$groupID."/posts"; //$debug = true;
101
  $dsc = nxs_decodeEntitiesFull(strip_tags($dsc)); $msg = strip_tags(nxs_decodeEntitiesFull($msg)); $title = nxs_decodeEntitiesFull(strip_tags($title));
102
- $xml = '<?xml version="1.0" encoding="UTF-8"?><post><title>'.htmlspecialchars($title, ENT_NOQUOTES, "UTF-8").'</title><summary>'.htmlspecialchars($msg, ENT_NOQUOTES, "UTF-8").'</summary>
103
- '.($url!=''?'<content><title>'.htmlspecialchars($title, ENT_NOQUOTES, "UTF-8").'</title><submitted-url>'.$url.'</submitted-url><submitted-image-url>'.$imgURL.'</submitted-image-url><description>'.htmlspecialchars($dsc, ENT_NOQUOTES, "UTF-8").'</description></content>':'').'</post>';
104
-
105
  $request = nsx_trOAuthRequest::from_consumer_and_token($this->consumer, $this->access_token, "POST", $status_url);
106
  $request->sign_request($this->signature_method, $this->consumer, $this->access_token);
107
  $auth_header = $request->to_header("https://api.linkedin.com");
108
- if ($debug) echo $auth_header . "\n";
109
- $response = $this->httpRequest($status_url, $auth_header, "POST", $xml);//prr($response);
 
110
  return $response;
111
  }
112
 
92
  $request = nsx_trOAuthRequest::from_consumer_and_token($this->consumer, $this->access_token, "POST", $status_url);
93
  $request->sign_request($this->signature_method, $this->consumer, $this->access_token);
94
  $auth_header = $request->to_header("https://api.linkedin.com");
95
+ //if ($debug) echo $auth_header . "\n";
96
  $response = $this->httpRequest($status_url, $auth_header, "POST", $xml);
97
  return $response;
98
  }
99
 
100
  function postToGroup($msg, $title, $groupID, $url='', $imgURL='', $dsc='') { $status_url = $this->base_url . "/v1/groups/".$groupID."/posts"; //$debug = true;
101
  $dsc = nxs_decodeEntitiesFull(strip_tags($dsc)); $msg = strip_tags(nxs_decodeEntitiesFull($msg)); $title = nxs_decodeEntitiesFull(strip_tags($title));
102
+ $xml = '<?xml version="1.0" encoding="UTF-8"?><post><title>'.htmlspecialchars($title, ENT_NOQUOTES, "UTF-8").'</title>'."\n".'<summary>'.htmlspecialchars($msg, ENT_NOQUOTES, "UTF-8").'</summary>'."\n".'
103
+ '.($url!=''?'<content><title>'.htmlspecialchars($title, ENT_NOQUOTES, "UTF-8").'</title>'."\n".'<submitted-url>'.$url.'</submitted-url>'."\n".'<submitted-image-url>'.$imgURL.'</submitted-image-url>'."\n".'<description>'.htmlspecialchars($dsc, ENT_NOQUOTES, "UTF-8").'</description></content>':'').'</post>';
104
+ // prr($xml);
105
  $request = nsx_trOAuthRequest::from_consumer_and_token($this->consumer, $this->access_token, "POST", $status_url);
106
  $request->sign_request($this->signature_method, $this->consumer, $this->access_token);
107
  $auth_header = $request->to_header("https://api.linkedin.com");
108
+ //if ($debug)
109
+ //echo $auth_header . "\n";
110
+ $response = $this->httpRequest($status_url, $auth_header, "POST", $xml); //prr($response);
111
  return $response;
112
  }
113
 
inc-cl/apis/plurkOAuth.php CHANGED
@@ -192,7 +192,7 @@ class wpPlurkOAuth{
192
  $args['oauth_signature'] = $this->sign_method->sign2($req, $this->consumer_secret, $this->access_secret);
193
  if (is_array($params)) { $params = nxspk_SigMethod_HMAC_SHA1::urlencode_rfc3986($params); $args = array_merge($args, $params);} //prr($args);
194
  $argsStr = ''; $argsT = array(); foreach ($args as $arN=>$arV){$argsT[] = $arN.'='.$arV;} $argsStr = implode('&', $argsT); $url .= '?'.$argsStr;
195
- $hdrsArr = $this->makeHTTPHeaders($url); $ckArr = $nxs_vbCkArray;
196
  $response = wp_remote_get($url, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr)); // prr($response);
197
  if ( is_wp_error($response) ) return $response;
198
  $this->http_code = $response['response']['code'];
192
  $args['oauth_signature'] = $this->sign_method->sign2($req, $this->consumer_secret, $this->access_secret);
193
  if (is_array($params)) { $params = nxspk_SigMethod_HMAC_SHA1::urlencode_rfc3986($params); $args = array_merge($args, $params);} //prr($args);
194
  $argsStr = ''; $argsT = array(); foreach ($args as $arN=>$arV){$argsT[] = $arN.'='.$arV;} $argsStr = implode('&', $argsT); $url .= '?'.$argsStr;
195
+ $hdrsArr = $this->makeHTTPHeaders($url); $ckArr = '';
196
  $response = wp_remote_get($url, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr)); // prr($response);
197
  if ( is_wp_error($response) ) return $response;
198
  $this->http_code = $response['response']['code'];
inc-cl/apis/tmhOAuth.php CHANGED
@@ -32,7 +32,7 @@ class NXS_tmhOAuth {
32
  // something that clearly identifies your app
33
  'user_agent' => '',
34
 
35
- 'use_ssl' => false,
36
  'host' => 'api.twitter.com',
37
 
38
  'consumer_key' => '',
32
  // something that clearly identifies your app
33
  'user_agent' => '',
34
 
35
+ 'use_ssl' => true,
36
  'host' => 'api.twitter.com',
37
 
38
  'consumer_key' => '',
inc-cl/bg.api.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //## NextScripts Facebook Connection Class
3
+ $nxs_snapAPINts[] = array('code'=>'BG', 'lcode'=>'bg', 'name'=>'Blogger');
4
+
5
+ if (!class_exists("nxs_class_SNAP_BG")) { class nxs_class_SNAP_BG {
6
+
7
+ var $ntCode = 'BG';
8
+ var $ntLCode = 'bg';
9
+
10
+ function doPost($options, $message){ if (!is_array($options)) return false;
11
+ foreach ($options as $ntOpts) $out[] = $this->doPostToNT($ntOpts, $message);
12
+ return $out;
13
+ }
14
+
15
+ function nsBloggerGetAuth($email, $pass) { $pass = urlencode($pass);
16
+ $ch = curl_init("https://www.google.com/accounts/ClientLogin?Email=$email&Passwd=$pass&service=blogger&accountType=GOOGLE");
17
+ $headers = array(); $headers[] = 'Accept: text/html, application/xhtml+xml, */*';
18
+ $headers[] = 'Connection: Keep-Alive'; $headers[] = 'Accept-Language: en-us';
19
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
20
+ curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0)");
21
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,10); curl_setopt($ch, CURLOPT_TIMEOUT, 10);
22
+ curl_setopt($ch, CURLOPT_HEADER,0); curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1);
23
+ $result = curl_exec($ch); $resultArray = curl_getinfo($ch); $errmsg = curl_error($ch);
24
+ if (trim($errmsg)!=='' || (is_array($resultArray) && $resultArray['http_code']!='200')) return array('result'=>'Error', 'error'=>"Error: ".$resultArray['http_code']." | Invalid Login ".$errmsg);
25
+ curl_close($ch); $arr = explode("=",$result); $token = $arr[3]; if (trim($token)=='') return false; else return $token;
26
+ }
27
+ function nsBloggerNewPost($auth, $blogID, $title, $text) {$text = str_ireplace('allowfullscreen','', $text); $title = utf8_decode(strip_tags($title));
28
+ $text = preg_replace('/<object\b[^>]*>(.*?)<\/object>/is', "", $text); $text = preg_replace('/<iframe\b[^>]*>(.*?)<\/iframe>/is', "", $text); $text = utf8_decode($text);
29
+
30
+ $postText = '<entry xmlns="http://www.w3.org/2005/Atom"><title type="text">'.$title.'</title><content type="xhtml">'.$text.'</content></entry>'; //prr($postText);
31
+ $len = strlen($entry); $ch = curl_init("https://www.blogger.com/feeds/$blogID/posts/default");
32
+ $headers = array("Content-type: application/atom+xml", "Content-Length: ".strlen($postText), "Authorization: GoogleLogin auth=".$auth, $postText);
33
+ curl_setopt($ch, CURLOPT_UNRESTRICTED_AUTH, 1); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
34
+ curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0)");
35
+ curl_setopt($ch, CURLOPT_HEADER,0); curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1); curl_setopt($ch, CURLINFO_HEADER_OUT, true);
36
+ $result = curl_exec($ch); curl_close($ch);
37
+ if (stripos($result,'tag:blogger.com')!==false) { $postID = CutFromTo($result, " rel='alternate' type='text/html' href='", "'"); return array("code"=>"OK", "post_id"=>$postID); } else return array("code"=>"ERR", "error"=>$result);
38
+ }
39
+
40
+ function doPostToNT($options, $message){ $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>''); //prr($message); prr($options);
41
+ //## Check API Lib
42
+ 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');
43
+ //## Check settings
44
+ if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
45
+ if (!isset($options['bgUName']) || trim($options['bgPass'])=='') { $badOut['Error'] = 'Not Configured'; return $badOut; }
46
+ //## Format
47
+ $msg = nxs_doFormatMsg($options['bgMsgFormat'], $message); $msgT = nxs_doFormatMsg($options['bgMsgTFormat'], $message);
48
+ if ($options['bgInclTags']=='1') $tags = nsTrnc($message['tags'], 195, ',', ''); else $tags = '';
49
+ //## Check/Fix HTML
50
+ 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>');
51
+ $msg = preg_replace('/<br(.*?)\/?>/','<br$1/>',$msg); $msg = preg_replace('/<img(.*?)\/?>/','<img$1/>',$msg);
52
+ require_once ('apis/htmlNumTable.php'); if (is_array($HTML401NamedToNumeric)) { $msg = strtr($msg, $HTML401NamedToNumeric); $msgT = strtr($msgT, $HTML401NamedToNumeric); }
53
+ }
54
+ $msg = preg_replace('/<script\b[^>]*>(.*?)<\/script>/is', "", $msg); $msg = preg_replace('/<!--(.*)-->/Uis', "", $msg); $nxshf = new NXS_HtmlFixer(); $nxshf->debug = false; $msg = $nxshf->getFixedHtml($msg);
55
+ $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);
56
+ //## Make Post
57
+ $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();
58
+ if (function_exists("doConnectToBlogger")) { $auth = doConnectToBlogger($email, $pass); if ($auth!==false) $ret = $auth; else $ret = doPostToBlogger($blogID, $msgT, $msg, $tags);}
59
+ else { $auth = $this->nsBloggerGetAuth($email, $pass); if ($auth===false) $ret = 'Incorrect Username/Password'; else {
60
+ if (is_array($auth)) $ret = $auth['error']; else {
61
+ $msgT = str_ireplace('&amp;', '&', $msgT); $msgT = utf8_encode(str_ireplace('&', '&amp;', $msgT)); $msg = utf8_encode($msg); $ret = $this->nsBloggerNewPost($auth, $blogID, $msgT, $msg);
62
+ }
63
+ }}
64
+ //## Return
65
+ if (is_array($ret) && $ret['post_id']!='') {
66
+ return array('postID'=>$ret['post_id'], 'isPosted'=>1, 'postURL'=>$ret['post_id'], 'pDate'=>date('Y-m-d H:i:s'));
67
+ } else { $badOut['Error'] .= print_r($ret, true);
68
+ return $badOut;
69
+ }
70
+ }
71
+ }}
72
+ ?>
inc-cl/bg.php CHANGED
@@ -4,52 +4,55 @@ $nxs_snapAvNts[] = array('code'=>'BG', 'lcode'=>'bg', 'name'=>'Blogger');
4
 
5
  if (!class_exists("nxs_snapClassBG")) { class nxs_snapClassBG {
6
  //#### Show Common Settings
7
- function showGenNTSettings($ntOpts){ global $nxs_plurl; $ntInfo = array('code'=>'BG', 'lcode'=>'bg', 'name'=>'Blogger', 'defNName'=>'diUName', 'tstReq' => true); ?>
8
  <div class="nxs_box">
9
  <div class="nxs_box_header">
10
  <div class="nsx_iconedTitle" style="margin-bottom:1px;background-image:url(<?php echo $nxs_plurl;?>img/<?php echo $ntInfo['lcode']; ?>16.png);"><?php echo $ntInfo['name']; ?>
11
- <?php $cbo = count($ntOpts); ?> <?php wp_nonce_field( 'ns'.$ntInfo['code'], 'ns'.$ntInfo['code'].'_wpnonce' ); ?>
12
  <?php if ($cbo>1){ ?><div class="nsBigText"><?php echo "(".($cbo=='0'?'No':$cbo)." "; _e('accounts', 'nxs_snap'); echo ")"; ?></div><?php } ?>
13
  </div>
14
  </div>
15
  <div class="nxs_box_inside">
16
  <?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
17
  <p style="margin:0px;margin-left:5px;">
18
- <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> /> <?php if ((int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
 
 
19
  <strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
20
  &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', 'nxs_snap'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>&nbsp;&nbsp;
21
  <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
22
- </p><?php $this->showNTSettings($indx, $pbo);
23
  }?>
24
  </div>
25
  </div> <?php //## END Settings
26
  }
27
  //#### Show NEW Settings Page
28
- function showNewNTSettings($bo){ $po = array('nName'=>'', 'doBG'=>'1', 'bgUName'=>'', 'bgPass'=>'', 'bgBlogID'=>'', 'bgInclTags'=>'1', 'bgMsgFormat'=>'%FULLTEXT% <br/><a href=\'%URL%\'>%TITLE%</a>', 'bgMsgTFormat'=>'%TITLE%' ); $this->showNTSettings($bo, $po, true);}
 
29
  //#### Show Unit Settings
30
- function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl;
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'] = ''; ?>
33
- <div id="doBG<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew){ ?> clNewNTSets<?php } ?>" style="background-image: url(<?php echo $nxs_plurl; ?>img/bg-bg.png);background-position:90% 10%;"> <input type="hidden" name="apDoSBG<?php echo $ii; ?>" value="0" id="apDoSBG<?php echo $ii; ?>" />
34
  <?php if ($isNew) { ?> <input type="hidden" name="bg[<?php echo $ii; ?>][apDoBG]" value="1" id="apDoNewBG<?php echo $ii; ?>" /> <?php } ?>
35
 
36
  <div style="display: none;"><input name="bg[<?php echo $ii; ?>][apBGPassChr]" id="apBGPassChr" type="password" value="" /></div>
37
 
38
  <div id="doBG<?php echo $ii; ?>Div" style="margin-left: 10px;"> <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', 'nxs_snap' ), $nType); ?></a></div>
39
 
40
- <div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easely identify it', 'nxs_snap'); ?></i> </div><input name="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")), 'nxs_snap') ?>" /><br/>
41
  <?php echo nxs_addQTranslSel('bg', $ii, $options['qTLng']); ?>
42
- <?php echo nxs_addPostingDelaySel('bg', $ii, $options['nHrs'], $options['nMin'], $options['nDays']); ?>
43
 
44
- <?php if (!$isNew) { ?>
45
- <div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
46
- <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="bg[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
47
- <input value="1" id="catSelSBG<?php echo $ii; ?>" type="radio" name="bg[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_BG<?php echo $ii; ?>" onclick="jQuery('#catSelSBG<?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('BG<?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_BG<?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($options['catSelEd']!='') echo "[".(substr_count($options['catSelEd'], ",")+1)."]"; ?></a>
48
- <input type="hidden" name="bg[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_BG<?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
49
- <br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i>
50
- </div>
51
- <br/>
52
- <?php } ?>
 
53
 
54
  <div style="width:100%;"><strong>Blogger Username/Email:</strong> </div><input name="bg[<?php echo $ii; ?>][apBGUName]" id="apBGUName" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit',htmlentities($options['bgUName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
55
  <div style="width:100%;"><strong>Blogger Password:</strong> </div><input name="bg[<?php echo $ii; ?>][apBGPass]" id="apBGPass" autocomplete="off" type="password" style="width: 30%;" value="<?php if (trim($options['bgPass'])!='') _e(apply_filters('format_to_edit', htmlentities(substr($options['bgPass'], 0, 5)=='b4d7s'?nsx_doDecode(substr($options['bgPass'], 5)):$options['bgPass'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /> <br/>
@@ -79,11 +82,33 @@ if (!class_exists("nxs_snapClassBG")) { class nxs_snapClassBG {
79
  </p>
80
 
81
  <?php if ($options['bgPass']!='') { ?>
82
- <?php wp_nonce_field( 'rePostToBG', 'rePostToBG_wpnonce' ); ?>
83
  <b><?php _e('Test your settings', 'nxs_snap'); ?>:</b>&nbsp;&nbsp;&nbsp; <?php if (!isset($options['bgOK']) || $options['bgOK']!='1') { ?> <div class="blnkg">=== <?php _e('Submit Test Post to Finish Configuration', 'nxs_snap'); ?> ===&gt;</div> <?php } ?> <a href="#" class="NXSButton" onclick="testPost('BG', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'nxs_snap' ), $nType); ?></a>
84
  <?php } ?>
85
 
86
- <div class="submit"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  </div>
88
  </div>
89
  <?php
@@ -108,7 +133,9 @@ if (!class_exists("nxs_snapClassBG")) { class nxs_snapClassBG {
108
  if (isset($pval['apBGMsgTFrmt'])) $options[$ii]['bgMsgTFormat'] = trim($pval['apBGMsgTFrmt']);
109
  if (isset($pval['bgInclTags'])) $options[$ii]['bgInclTags'] = $pval['bgInclTags']; else $options[$ii]['bgInclTags'] = 0;
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
 
@@ -116,9 +143,10 @@ if (!class_exists("nxs_snapClassBG")) { class nxs_snapClassBG {
116
  } return $options;
117
  }
118
  //#### Show Post->Edit Meta Box Settings
119
- function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
120
  foreach($ntOpts as $ii=>$options){ $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapBG', true)); if (is_array($pMeta)) $options = $this->adjMetaOpt($options, $pMeta[$ii]);
121
- $doBG = $options['doBG'] && (is_array($pMeta) || $options['catSel']!='1');
 
122
  $isAvailBG = $options['bgUName']!='' && $options['bgPass']!=''; $bgMsgFormat = htmlentities($options['bgMsgFormat'], ENT_COMPAT, "UTF-8"); $bgMsgTFormat = htmlentities($options['bgMsgTFormat'], ENT_COMPAT, "UTF-8");
123
  ?>
124
 
@@ -127,7 +155,7 @@ if (!class_exists("nxs_snapClassBG")) { class nxs_snapClassBG {
127
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/bg16.png);">Blogger - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $options['nName']; ?></i>)</div></th> <td style="min-width: 180px; width: 350px;" ><?php //## Only show RePost button if the post is "published"
128
  if ($post->post_status == "publish" && $isAvailBG) { ?>
129
  <input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToBG_repostButton" id="rePostToBG_button" value="<?php _e('Repost to Blogger', 'nxs_snap') ?>" />
130
- <?php wp_nonce_field( 'rePostToBG', 'rePostToBG_wpnonce' ); } ?>
131
 
132
  <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
133
  ?> <span id="pstdBG<?php echo $ii; ?>" style="float: right; padding-top: 4px; padding-right: 10px;">
@@ -136,19 +164,29 @@ if (!class_exists("nxs_snapClassBG")) { class nxs_snapClassBG {
136
 
137
  </td></tr>
138
  <?php if (!$isAvailBG) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b><?php _e('Setup your Blogger Account to AutoPost to Blogger', 'nxs_snap') ?></b>
139
- <?php } elseif ($post->post_status != "puZblish") { ?>
 
 
 
 
 
 
 
 
 
140
  <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>
141
  <td><input value="<?php echo $bgMsgTFormat ?>" type="text" name="bg[<?php echo $ii; ?>][SNAPTformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apBGTMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apBGTMsgFrmt".$ii, '', '58'); ?></td></tr>
142
  <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>
143
  <td>
144
  <textarea cols="150" rows="1" id="bg<?php echo $ii; ?>SNAPformat" name="bg[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('#bg<?php echo $ii; ?>SNAPformat').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apBGMsgFrmt<?php echo $ii; ?>');"><?php echo $bgMsgFormat; ?></textarea>
145
- <?php nxs_doShowHint("apBGMsgFrmt".$ii, '', '58'); ?></td></tr>
146
  <?php }
147
  }
148
  }
149
 
150
  function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
151
- if (isset($pMeta['SNAPformat'])) $optMt['bgMsgFormat'] = $pMeta['SNAPformat'];
 
152
  if (isset($pMeta['SNAPTformat'])) $optMt['bgMsgTFormat'] = $pMeta['SNAPTformat'];
153
  if (isset($pMeta['doBG'])) $optMt['doBG'] = $pMeta['doBG'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doBG'] = 0; }
154
  if (isset($pMeta['SNAPincludeBG']) && $pMeta['SNAPincludeBG'] == '1' ) $optMt['doBG'] = 1;
@@ -156,42 +194,20 @@ if (!class_exists("nxs_snapClassBG")) { class nxs_snapClassBG {
156
  }
157
  }}
158
 
159
- if (!function_exists("nxs_rePostToBG_ajax")) { function nxs_rePostToBG_ajax() { check_ajax_referer('rePostToBG'); $postID = $_POST['id']; // $result = nsPublishTo($id, 'FB', true);
160
  global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
161
  foreach ($options['bg'] as $ii=>$po) if ($ii==$_POST['nid']) { $po['ii'] = $ii; $po['pType'] = 'aj';
162
  $mpo = get_post_meta($postID, 'snapBG', true); $mpo = maybe_unserialize($mpo);
163
  if (is_array($mpo) && isset($mpo[$ii]) && is_array($mpo[$ii]) ){ $ntClInst = new nxs_snapClassBG(); $po = $ntClInst->adjMetaOpt($po, $mpo[$ii]); }
164
- $result = nxs_doPublishToBG($postID, $po); if ($result == 201) { $options['bg'][$ii]['bgOK']=1; update_option('NS_SNAutoPoster', $options); }
165
 
166
- if ($result == 200) die("Successfully sent your post to Blooger."); else die($result);
167
  }
168
  }
169
  }
170
- if (!function_exists('nsBloggerGetAuth')){ function nsBloggerGetAuth($email, $pass) { $pass = urlencode($pass);
171
- $ch = curl_init("https://www.google.com/accounts/ClientLogin?Email=$email&Passwd=$pass&service=blogger&accountType=GOOGLE");
172
- $headers = array(); $headers[] = 'Accept: text/html, application/xhtml+xml, */*';
173
- $headers[] = 'Connection: Keep-Alive'; $headers[] = 'Accept-Language: en-us';
174
- curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
175
- curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0)");
176
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,10); curl_setopt($ch, CURLOPT_TIMEOUT, 10);
177
- curl_setopt($ch, CURLOPT_HEADER,0); curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1);
178
- $result = curl_exec($ch); $resultArray = curl_getinfo($ch);
179
- curl_close($ch); $arr = explode("=",$result); $token = $arr[3]; if (trim($token)=='') return false; else return $token;
180
- }}
181
- if (!function_exists('nsBloggerNewPost')){ function nsBloggerNewPost($auth, $blogID, $title, $text) {$text = str_ireplace('allowfullscreen','', $text); $title = utf8_decode(strip_tags($title));
182
- $text = preg_replace('/<object\b[^>]*>(.*?)<\/object>/is', "", $text); $text = preg_replace('/<iframe\b[^>]*>(.*?)<\/iframe>/is', "", $text); $text = utf8_decode($text);
183
-
184
- $postText = '<entry xmlns="http://www.w3.org/2005/Atom"><title type="text">'.$title.'</title><content type="xhtml">'.$text.'</content></entry>'; //prr($postText);
185
- $len = strlen($entry); $ch = curl_init("https://www.blogger.com/feeds/$blogID/posts/default");
186
- $headers = array("Content-type: application/atom+xml", "Content-Length: ".strlen($postText), "Authorization: GoogleLogin auth=".$auth, $postText);
187
- curl_setopt($ch, CURLOPT_UNRESTRICTED_AUTH, 1); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
188
- curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0)");
189
- curl_setopt($ch, CURLOPT_HEADER,0); curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1); curl_setopt($ch, CURLINFO_HEADER_OUT, true);
190
- $result = curl_exec($ch); curl_close($ch);
191
- if (stripos($result,'tag:blogger.com')!==false) { $postID = CutFromTo($result, " rel='alternate' type='text/html' href='", "'"); return array("code"=>"OK", "post_id"=>$postID); } else { prr($result); return false;}
192
- }}
193
  if (!function_exists("nxs_doPublishToBG")) { //## Second Function to Post to BG
194
- function nxs_doPublishToBG($postID, $options){ $ntCd = 'BG'; $ntCdL = 'bg'; $ntNm = 'Blogger'; // $uqID = uniqid('BG_');
195
  //$backtrace = debug_backtrace(); nxs_addToLogN('W', 'Enter', $ntCd, 'I am here - '.$ntCd."|".print_r($backtrace, true), '');
196
  // if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToBG', array($postID, $options));
197
  $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url();
@@ -205,35 +221,27 @@ if (!function_exists("nxs_doPublishToBG")) { //## Second Function to Post to BG
205
  }
206
  }
207
 
208
- if ($postID=='0') { echo "Testing ... <br/><br/>"; $msgT = 'Test Post from '.htmlentities($blogTitle); $link = home_url(); $msg = 'Test Post from '.$blogTitle. " ".$link; }
209
- else { $post = get_post($postID); if(!$post) return; $msgFormat = $options['bgMsgFormat']; $msg = nsFormatMessage($msgFormat, $postID, $addParams);
210
- $link = get_permalink($postID); $msgTFormat = $options['bgMsgTFormat']; $msgT = nsFormatMessage($msgTFormat, $postID, $addParams); nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
211
  }
212
- $extInfo = ' | PostID: '.$postID." - ".nxs_doQTrans($post->post_title, $lng);
213
  //## Actual POST Code
214
- $email = $options['bgUName']; $pass = substr($options['bgPass'], 0, 5)=='b4d7s'?nsx_doDecode(substr($options['bgPass'], 5)):$options['bgPass']; $blogID = $options['bgBlogID'];
215
- //echo "###".$auth."|".$blogID."|".$msgT."|".$msg;
216
  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, ',', ''); }
217
  if (substr($tags, -1)=='"') $tags = substr($tags, 0, -1);
218
-
219
- 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>');
220
- $msg = preg_replace('/<br(.*?)\/?>/','<br$1/>',$msg); $msg = preg_replace('/<img(.*?)\/?>/','<img$1/>',$msg);
221
- require_once ('apis/htmlNumTable.php'); if (is_array($HTML401NamedToNumeric)) { $msg = strtr($msg, $HTML401NamedToNumeric); $msgT = strtr($msgT, $HTML401NamedToNumeric); }
222
- } // prr($text);
223
- // prr($msg); echo " =HT= ";
224
- $msg = preg_replace('/<script\b[^>]*>(.*?)<\/script>/is', "", $msg); $msg = preg_replace('/<!--(.*)-->/Uis', "", $msg); $nxshf = new NXS_HtmlFixer(); $nxshf->debug = false; $msg = $nxshf->getFixedHtml($msg);
225
- $msg = str_replace("\r\n","\n", $msg); $msg = str_replace("\n\r","\n", $msg); $msg = str_replace("\r","\n", $msg); $msg = str_replace("\n","<br/>", $msg); // prr($msg); die();
226
- if (function_exists("doConnectToBlogger")) {$auth = doConnectToBlogger($email, $pass); if ($auth!==false) $ret = $auth; else $ret = doPostToBlogger($blogID, $msgT, $msg, $tags);}
227
- else {$auth = nsBloggerGetAuth($email, $pass); if ($auth===false) $ret = 'Incorrect Username/Password'; else { $msgT = str_ireplace('&amp;', '&', $msgT);
228
- $msgT = utf8_encode(str_ireplace('&', '&amp;', $msgT)); $msg = utf8_encode($msg); $ret = nsBloggerNewPost($auth, $blogID, $msgT, $msg);
229
- }}
230
- //## /Actual POST Code
231
- if ( (!is_array($ret)) && $ret!='OK') { if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '. strip_tags(print_r($ret, true)), $extInfo); return $ret; }
232
- else { if ($postID=='0') { echo 'OK - Message Posted, please see your '.$ntNm.' Page '; nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); return 201;}
233
- else { nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPosted'=>'1', 'pgID'=>$ret['post_id'], 'pDate'=>date('Y-m-d H:i:s')));
234
- do_action('nxs_actOnBG', array('postID'=>$postID, 'pgID'=>$ret['post_id'], 'ii'=>$ii)); nxs_addToLogN( 'S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo);
235
- } return 200;
236
- }
237
  }
238
  }
239
 
4
 
5
  if (!class_exists("nxs_snapClassBG")) { class nxs_snapClassBG {
6
  //#### Show Common Settings
7
+ function showGenNTSettings($ntOpts){ global $nxs_plurl; $ntInfo = array('code'=>'BG', 'lcode'=>'bg', 'name'=>'Blogger', 'defNName'=>'bgUName', 'tstReq' => true); ?>
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', 'nxs_snap'); echo ")"; ?></div><?php } ?>
13
  </div>
14
  </div>
15
  <div class="nxs_box_inside">
16
  <?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
17
  <p style="margin:0px;margin-left:5px;">
18
+ <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> />
19
+ <?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 } ?>
20
+ <?php if (isset($pbo['rpstOn']) && (int)$pbo['rpstOn'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popReActive');" onmouseover="nxs_showPopUpInfo('popReActive', event);"><?php echo "*[R]*" ?></span><?php } ?>
21
  <strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
22
  &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', 'nxs_snap'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>&nbsp;&nbsp;
23
  <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
24
+ </p><?php $pbo['ntInfo'] = $ntInfo; $this->showNTSettings($indx, $pbo);
25
  }?>
26
  </div>
27
  </div> <?php //## END Settings
28
  }
29
  //#### Show NEW Settings Page
30
+ function showNewNTSettings($bo){ $po = array('nName'=>'', 'doBG'=>'1', 'bgUName'=>'', 'bgPass'=>'', 'bgBlogID'=>'', 'bgInclTags'=>'1', 'bgMsgFormat'=>'%FULLTEXT% <br/><a href=\'%URL%\'>%TITLE%</a>', 'bgMsgTFormat'=>'%TITLE%' );
31
+ $po['ntInfo']= array('lcode'=>'bg'); $this->showNTSettings($bo, $po, true);}
32
  //#### Show Unit Settings
33
+ function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl; $nt = $options['ntInfo']['lcode']; $ntU = strtoupper($nt);
34
  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'] = '';
35
  if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; ?>
36
+ <div id="doBG<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew){ ?> clNewNTSets<?php } ?>"> <input type="hidden" name="apDoSBG<?php echo $ii; ?>" value="0" id="apDoSBG<?php echo $ii; ?>" />
37
  <?php if ($isNew) { ?> <input type="hidden" name="bg[<?php echo $ii; ?>][apDoBG]" value="1" id="apDoNewBG<?php echo $ii; ?>" /> <?php } ?>
38
 
39
  <div style="display: none;"><input name="bg[<?php echo $ii; ?>][apBGPassChr]" id="apBGPassChr" type="password" value="" /></div>
40
 
41
  <div id="doBG<?php echo $ii; ?>Div" style="margin-left: 10px;"> <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', 'nxs_snap' ), $nType); ?></a></div>
42
 
43
+ <div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'nxs_snap'); ?></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")), 'nxs_snap') ?>" /><br/>
44
  <?php echo nxs_addQTranslSel('bg', $ii, $options['qTLng']); ?>
 
45
 
46
+
47
+ <br/>
48
+ <ul class="nsx_tabs">
49
+ <li><a href="#nsx<?php echo $nt.$ii ?>_tab1"><?php _e('Account Info', 'nxs_snap'); ?></a></li>
50
+ <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'nxs_snap'); ?></a></li>
51
+ </ul>
52
+ <div class="nsx_tab_container"><?php /* ######################## Account Tab ####################### */ ?>
53
+ <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%;">
54
+
55
+
56
 
57
  <div style="width:100%;"><strong>Blogger Username/Email:</strong> </div><input name="bg[<?php echo $ii; ?>][apBGUName]" id="apBGUName" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit',htmlentities($options['bgUName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
58
  <div style="width:100%;"><strong>Blogger Password:</strong> </div><input name="bg[<?php echo $ii; ?>][apBGPass]" id="apBGPass" autocomplete="off" type="password" style="width: 30%;" value="<?php if (trim($options['bgPass'])!='') _e(apply_filters('format_to_edit', htmlentities(substr($options['bgPass'], 0, 5)=='b4d7s'?nsx_doDecode(substr($options['bgPass'], 5)):$options['bgPass'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /> <br/>
82
  </p>
83
 
84
  <?php if ($options['bgPass']!='') { ?>
85
+
86
  <b><?php _e('Test your settings', 'nxs_snap'); ?>:</b>&nbsp;&nbsp;&nbsp; <?php if (!isset($options['bgOK']) || $options['bgOK']!='1') { ?> <div class="blnkg">=== <?php _e('Submit Test Post to Finish Configuration', 'nxs_snap'); ?> ===&gt;</div> <?php } ?> <a href="#" class="NXSButton" onclick="testPost('BG', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'nxs_snap' ), $nType); ?></a>
87
  <?php } ?>
88
 
89
+ </div>
90
+ <?php /* ######################## Advanced Tab ####################### */ ?>
91
+ <div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content">
92
+
93
+ <?php if (!$isNew) { ?> <div class="nxs_tls_cpt"><?php _e('Categories', 'nxs_snap'); ?></div>
94
+ <div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
95
+ <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
96
+ <input value="1" id="catSelS<?php echo $ntU; ?><?php echo $ii; ?>" type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_<?php echo $ntU; ?><?php echo $ii; ?>" onclick="jQuery('#catSelS<?php echo $ntU; ?><?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('<?php echo $ntU; ?><?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($options['catSelEd']!='') echo "[".(substr_count($options['catSelEd'], ",")+1)."]"; ?></a>
97
+ <input type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
98
+ <br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
99
+ <br/>
100
+ <?php } ?>
101
+
102
+ <?php nxs_addPostingDelaySelV3($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']); ?>
103
+ <?php nxs_showRepostSettings($nt, $ii, $options); ?>
104
+
105
+
106
+ </div> <?php /* #### End of Tab #### */ ?>
107
+ </div><br/> <?php /* #### End of Tabs #### */ ?>
108
+
109
+ <div class="submit clear" style="padding-bottom: 0px;"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div>
110
+
111
+
112
  </div>
113
  </div>
114
  <?php
133
  if (isset($pval['apBGMsgTFrmt'])) $options[$ii]['bgMsgTFormat'] = trim($pval['apBGMsgTFrmt']);
134
  if (isset($pval['bgInclTags'])) $options[$ii]['bgInclTags'] = $pval['bgInclTags']; else $options[$ii]['bgInclTags'] = 0;
135
 
136
+ $options[$ii] = nxs_adjRpst($options[$ii], $pval);
137
+
138
+ if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']);
139
  if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
140
  if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
141
 
143
  } return $options;
144
  }
145
  //#### Show Post->Edit Meta Box Settings
146
+ function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID; $nt = 'bg'; $ntU = 'BG';
147
  foreach($ntOpts as $ii=>$options){ $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapBG', true)); if (is_array($pMeta)) $options = $this->adjMetaOpt($options, $pMeta[$ii]);
148
+ if (empty($options['imgToUse'])) $options['imgToUse'] = '';
149
+ $doBG = $options['doBG'] && (is_array($pMeta) || $options['catSel']!='1'); $imgToUse = $options['imgToUse'];
150
  $isAvailBG = $options['bgUName']!='' && $options['bgPass']!=''; $bgMsgFormat = htmlentities($options['bgMsgFormat'], ENT_COMPAT, "UTF-8"); $bgMsgTFormat = htmlentities($options['bgMsgTFormat'], ENT_COMPAT, "UTF-8");
151
  ?>
152
 
155
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/bg16.png);">Blogger - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $options['nName']; ?></i>)</div></th> <td style="min-width: 180px; width: 350px;" ><?php //## Only show RePost button if the post is "published"
156
  if ($post->post_status == "publish" && $isAvailBG) { ?>
157
  <input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToBG_repostButton" id="rePostToBG_button" value="<?php _e('Repost to Blogger', 'nxs_snap') ?>" />
158
+ <?php } ?>
159
 
160
  <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
161
  ?> <span id="pstdBG<?php echo $ii; ?>" style="float: right; padding-top: 4px; padding-right: 10px;">
164
 
165
  </td></tr>
166
  <?php if (!$isAvailBG) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b><?php _e('Setup your Blogger Account to AutoPost to Blogger', 'nxs_snap') ?></b>
167
+ <?php } else { if ($post->post_status != "publish" && function_exists('nxs_doSMAS5') ) { nxs_doSMAS5($nt, $ii, $options); } ?>
168
+
169
+ <?php if ($options['rpstOn']=='1') { ?>
170
+
171
+ <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top:6px; text-align:right; width:60px; padding-right:10px;">
172
+ <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"; ?> />
173
+ </th>
174
+ <td> <?php _e('Include in "Auto-Reposting" to this network.', 'nxs_snap') ?>
175
+ </td></tr> <?php } ?>
176
+
177
  <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>
178
  <td><input value="<?php echo $bgMsgTFormat ?>" type="text" name="bg[<?php echo $ii; ?>][SNAPTformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apBGTMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apBGTMsgFrmt".$ii, '', '58'); ?></td></tr>
179
  <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>
180
  <td>
181
  <textarea cols="150" rows="1" id="bg<?php echo $ii; ?>SNAPformat" name="bg[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('#bg<?php echo $ii; ?>SNAPformat').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apBGMsgFrmt<?php echo $ii; ?>');"><?php echo $bgMsgFormat; ?></textarea>
182
+ <?php nxs_doShowHint("apBGMsgFrmt".$ii, '', '58'); ?></td></tr>
183
  <?php }
184
  }
185
  }
186
 
187
  function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
188
+ if (isset($pMeta['SNAPformat'])) $optMt['bgMsgFormat'] = $pMeta['SNAPformat']; if (isset($pMeta['imgToUse'])) $optMt['imgToUse'] = $pMeta['imgToUse'];
189
+ if (isset($pMeta['timeToRun'])) $optMt['timeToRun'] = $pMeta['timeToRun']; if (isset($pMeta['rpstPostIncl'])) $optMt['rpstPostIncl'] = $pMeta['rpstPostIncl'];
190
  if (isset($pMeta['SNAPTformat'])) $optMt['bgMsgTFormat'] = $pMeta['SNAPTformat'];
191
  if (isset($pMeta['doBG'])) $optMt['doBG'] = $pMeta['doBG'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doBG'] = 0; }
192
  if (isset($pMeta['SNAPincludeBG']) && $pMeta['SNAPincludeBG'] == '1' ) $optMt['doBG'] = 1;
194
  }
195
  }}
196
 
197
+ if (!function_exists("nxs_rePostToBG_ajax")) { function nxs_rePostToBG_ajax() { check_ajax_referer('nxsSsPageWPN'); $postID = $_POST['id']; // $result = nsPublishTo($id, 'FB', true);
198
  global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
199
  foreach ($options['bg'] as $ii=>$po) if ($ii==$_POST['nid']) { $po['ii'] = $ii; $po['pType'] = 'aj';
200
  $mpo = get_post_meta($postID, 'snapBG', true); $mpo = maybe_unserialize($mpo);
201
  if (is_array($mpo) && isset($mpo[$ii]) && is_array($mpo[$ii]) ){ $ntClInst = new nxs_snapClassBG(); $po = $ntClInst->adjMetaOpt($po, $mpo[$ii]); }
202
+ $result = nxs_doPublishToBG($postID, $po); if ($result == 200) { $options['bg'][$ii]['bgOK']=1; update_option('NS_SNAutoPoster', $options); }
203
 
204
+ if ($result == 200) die("Successfully sent your post to Blogger."); else die($result);
205
  }
206
  }
207
  }
208
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
209
  if (!function_exists("nxs_doPublishToBG")) { //## Second Function to Post to BG
210
+ function nxs_doPublishToBG($postID, $options){ $ntCd = 'BG'; $ntCdL = 'bg'; $ntNm = 'Blogger'; if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
211
  //$backtrace = debug_backtrace(); nxs_addToLogN('W', 'Enter', $ntCd, 'I am here - '.$ntCd."|".print_r($backtrace, true), '');
212
  // if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToBG', array($postID, $options));
213
  $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url();
221
  }
222
  }
223
 
224
+ if ($postID=='0') { echo "Testing ... <br/><br/>"; $options['bgMsgTFormat'] = 'Test Post from '.htmlentities($blogTitle); $link = home_url(); $options['bgMsgFormat'] = 'Test Post from '.$blogTitle. " ".$link; }
225
+ else { $post = get_post($postID); if(!$post) return; $options['bgMsgFormat'] = nsFormatMessage($options['bgMsgFormat'], $postID, $addParams);
226
+ $options['bgMsgTFormat'] = nsFormatMessage($options['bgMsgTFormat'], $postID, $addParams); nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
227
  }
228
+ $extInfo = ' | PostID: '.$postID." - ".(isset($post) && is_object($post)?$post->post_title:'');
229
  //## Actual POST Code
 
 
230
  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, ',', ''); }
231
  if (substr($tags, -1)=='"') $tags = substr($tags, 0, -1);
232
+ //## Set Message
233
+ $message = array('title'=>'', 'announce'=>'', 'text'=>'', 'url'=>'', 'surl'=>'', 'urlDescr'=>'', 'urlTitle'=>'', 'imageURL' => array(), 'videoCode'=>'', 'videoURL'=>'', 'siteName'=>$blogTitle, 'tags'=>$tags, 'cats'=>'', 'authorName'=>'');
234
+ //## Actual Post
235
+ $ntToPost = new nxs_class_SNAP_BG(); $ret = $ntToPost->doPostToNT($options, $message);
236
+ //## Process Results
237
+ if (!is_array($ret) || $ret['isPosted']!='1') { //## Error
238
+ if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);
239
+ } else { // ## All Good - log it.
240
+ if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo _e('OK - Message Posted, please see your '.$logNT.' Page. ', 'nxs_snap'); }
241
+ 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); }
242
+ }
243
+ //## Return Result
244
+ if ($ret['isPosted']=='1') return 200; else return print_r($ret, true);
 
 
 
 
 
 
245
  }
246
  }
247
 
inc-cl/da.api.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //## NextScripts deviantART 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
+
12
+ rdTitleFormat
13
+ rdTextFormat
14
+
15
+ 2. Post Info
16
+
17
+ url
18
+ title - [up to 300 characters long] - title of the submission
19
+ text
20
+
21
+ */
22
+ $nxs_snapAPINts[] = array('code'=>'DA', 'lcode'=>'da', 'name'=>'deviantART');
23
+
24
+ if (!function_exists("doConnectToDeviantART")) { function doConnectToDeviantART($unm, $pass){ $url = "https://www.deviantart.com/users/login"; $hdrsArr = nxs_getDAHeaders('http://www.deviantart.com/');
25
+ $rep = wp_remote_get($url, array( 'headers' => $hdrsArr, 'httpversion' => '1.1')); $ck = $rep['cookies'];
26
+ $rTok = CutFromTo($rep['body'], 'name="validate_token" value="', '"'); $rKey = CutFromTo($rep['body'], 'name="validate_key" value="', '"'); $ck[0]->value = urlencode($ck[0]->value);
27
+ $hdrsArr = nxs_getDAHeaders('https://www.deviantart.com/users/login', 'https://www.deviantart.com/', true);
28
+ $flds = array('ref' => 'https://www.deviantart.com/users/loggedin', 'username' => $unm, 'password' => $pass, 'remember_me' => '1', 'validate_token' => $rTok, 'validate_key' => $rKey);
29
+ $response = wp_remote_post( $url, array( 'method' => 'POST', 'httpversion' => '1.1', 'timeout' => 45, 'redirection' => 0, 'cookies' => $ck, 'headers' => $hdrsArr, 'body' => $flds));
30
+ if (is_wp_error($response)) { $badOut = print_r($response, true)." - ERROR"; return $badOut; }
31
+ $ck = $response['cookies']; for($i=0;$i<4;$i++) $ck[$i]->value = urlencode($ck[$i]->value);
32
+ if (isset($response['headers']['location']) && stripos($response['headers']['location'], 'wrong-password')!==false ) { $badOut = "Wrong Password - ERROR"; return $badOut; }
33
+ if (isset($response['headers']['location']) && ( $response['headers']['location']=='http://www.deviantart.com' || $response['headers']['location']=='https://www.deviantart.com/users/loggedin')) {
34
+ $hdrsArr = nxs_getDAHeaders('http://www.deviantart.com'); $rep = wp_remote_get( 'http://www.deviantart.com', array( 'headers' => $hdrsArr, 'httpversion' => '1.1', 'cookies' => $ck));// die(); prr($rep);
35
+ if (is_wp_error($rep)) { $badOut = print_r($rep, true)." - ERROR"; return $badOut; } $mh = CutFromTo($rep['body'], 'Your Account</b><br><a href="', '"'); $mh = str_ireplace('/journal/', '', $mh);
36
+ return array('mh'=>$mh, 'ck'=>$ck);
37
+ } else $badOut = print_r($response, true)." - ERROR"; return $badOut;
38
+ }}
39
+
40
+ if (!function_exists("nxs_getDAHeaders")) { function nxs_getDAHeaders($ref, $org='', $post=false, $aj=false){ $hdrsArr = array();
41
+ $hdrsArr['Cache-Control']='max-age=0'; $hdrsArr['Connection']='keep-alive'; $hdrsArr['Referer']=$ref;
42
+ $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';
43
+ if($post===true) $hdrsArr['Content-Type']='application/x-www-form-urlencoded';
44
+ if($aj===true) $hdrsArr['X-Requested-With']='XMLHttpRequest';
45
+ if ($org!='') $hdrsArr['Origin']=$org;
46
+ $hdrsArr['Accept']='text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';// $hdrsArr['DNT']='1';
47
+ if (function_exists('gzdeflate')) $hdrsArr['Accept-Encoding']='gzip,deflate,sdch';
48
+ $hdrsArr['Accept-Language']='en-US,en;q=0.8'; return $hdrsArr;
49
+ }}
50
+
51
+ if (!class_exists("nxs_class_SNAP_DA")) { class nxs_class_SNAP_DA {
52
+
53
+ var $ntCode = 'DA';
54
+ var $ntLCode = 'da';
55
+
56
+ function doPost($options, $message){ if (!is_array($options)) return false; $out = array(); // return false;
57
+ foreach ($options as $ii=>$ntOpts) $out[$ii] = $this->doPostToNT($ntOpts, $message);
58
+ return $out;
59
+ }
60
+
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['daUName']) || trim($options['daUName'])=='' || !isset($options['daPass']) || trim($options['daPass'])=='') { $badOut['Error'] = 'No username/password Found'; return $badOut; }
65
+ //## Format Post
66
+ $title = nxs_doFormatMsg($options['daTitleFormat'], $message); $title = nsTrnc($title, 300); $text = nxs_doFormatMsg($options['daTextFormat'], $message);
67
+ //## Make Post
68
+ $pass = substr($options['daPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['daPass'], 5)):$options['daPass']; $hdrsArr = nxs_getDAHeaders('http://okapy6.deviantart.com/journal/?edit', 'https://www.deviantart.com');
69
+ $loginInfo = doConnectToDeviantART($options['daUName'], $pass); if (!is_array($loginInfo)) { $badOut['Error'] = print_r($loginInfo, true)." - ERROR"; return $badOut; }
70
+
71
+ $ck = $loginInfo['ck']; $mh = $loginInfo['mh'];
72
+ $rep = wp_remote_get( $mh.'/journal/?edit', array( 'headers' => $hdrsArr, 'cookies' => $ck)); //prr($rep); die();
73
+ if (is_wp_error($rep)) { $badOut = print_r($rep, true)." - ERROR"; return $badOut; }
74
+ $contents = CutFromTo($rep['body'], '<h3 class="journal-editor-create">', '</form>'); // prr($contents);
75
+
76
+ $md = array();
77
+ while (stripos($contents, '"hidden"')!==false){$contents = substr($contents, stripos($contents, '"hidden"')+8); $name = trim(CutFromTo($contents,'name="', '"'));
78
+ if (!in_array($name, $md)) { $md[] = $name; $val = trim(CutFromTo($contents,'value="', '"')); $flds[$name]= urldecode (nxs_decodeEntities($val)); }
79
+ } $flds['subject'] = nsTrnc(nxs_decodeEntities($title), 50); $flds['body'] = trim($text); $flds['song'] = '';
80
+
81
+ $flds['game'] = ''; $flds['book'] = ''; $flds['food'] = ''; $flds['movie'] = ''; $flds['drink'] = ''; $flds['flip'] = '0'; $flds['featured'] = '1';
82
+ $flds['portal'] = '1'; $flds['skinlabel'] = 'No+skin'; $flds['jheader'] = ''; $flds['jcss'] = ''; $flds['jfooter'] = '';
83
+ $ck2 = $rep['cookies']; for($i=0;$i<3;$i++) if ($ck[$i]->name=='userinfo') $ck[$i]->value = urlencode($ck2[0]->value);
84
+ $hdrsArr = nxs_getDAHeaders($mh.'/journal/?edit', $mh, true);
85
+ $response = wp_remote_post($mh.'/journal/?edit', array( 'method' => 'POST', 'httpversion' => '1.1', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds, 'cookies' => $ck));
86
+
87
+
88
+ if ($response['response']['code']=='302') { $hdrsArr = nxs_getDAHeaders('http://okapy6.deviantart.com/journal/?edit');
89
+ $rep = wp_remote_get( $mh.'/journal/', array( 'headers' => $hdrsArr, 'cookies' => $ck));
90
+ $daNewPostURL = CutFromTo($rep['body'], 'a data-deviationid="', '</a>'); $daNewPostURL = CutFromTo($daNewPostURL, 'href="', '"'); $daNewPostID = CutFromTo($rep['body'], 'a data-deviationid="', '"');
91
+ return array('postID'=>$daNewPostID, 'isPosted'=>1, 'postURL'=>$daNewPostURL, 'pDate'=>date('Y-m-d H:i:s'));
92
+ } else { $badOut['Error'] .= 'Somethibng is not right';
93
+ return $badOut;
94
+ }
95
+ return $badOut;
96
+ }
97
+
98
+ }}
99
+ ?>
inc-cl/da.php ADDED
@@ -0,0 +1,234 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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', 'nxs_snap'); 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;">
19
+ <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> />
20
+ <?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 } ?>
21
+ <?php if (isset($pbo['rpstOn']) && (int)$pbo['rpstOn'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popReActive');" onmouseover="nxs_showPopUpInfo('popReActive', event);"><?php echo "*[R]*" ?></span><?php } ?>
22
+ <strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
23
+ &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', 'nxs_snap'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>&nbsp;&nbsp;
24
+ <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
25
+ </p><?php $pbo['ntInfo'] = $ntInfo; $this->showNTSettings($indx, $pbo);
26
+ }?>
27
+ </div>
28
+ </div> <?php
29
+ }
30
+ //#### Show NEW Settings Page
31
+ function showNewNTSettings($options){ $nto = array('nName'=>'', 'doDA'=>'1', 'daUName'=>'', 'daPageID'=>'', 'daCommID'=>'', 'postType'=>'A', 'daPass'=>''); $nto['ntInfo']= array('lcode'=>'da'); $this->showNTSettings($options, $nto, true);}
32
+ //#### Show Unit Settings
33
+ function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl; $nt = $options['ntInfo']['lcode']; $ntU = strtoupper($nt);
34
+ 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'] = '';
35
+ if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; ?>
36
+ <div id="doDA<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>"> <input type="hidden" name="apDoSDA<?php echo $ii; ?>" value="0" id="apDoSDA<?php echo $ii; ?>" />
37
+
38
+ <?php if(!function_exists('doConnectToDeviantART')) {?><span style="color:#580000; font-size: 16px;"><br/><br/>
39
+ <b><?php _e('deviantART API Library not found', 'nxs_snap'); ?></b>
40
+ <br/><br/> <?php _e('deviantART doesn\'t have a built-in API for automated posts yet.', 'nxs_snap'); ?> <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.', 'nxs_snap'); ?></span></div>
41
+ <?php return; }; ?>
42
+
43
+ <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', 'nxs_snap' ), $nType); ?></a></div>
44
+
45
+ <div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'nxs_snap'); ?></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")), 'nxs_snap') ?>" /><br/>
46
+ <?php echo nxs_addQTranslSel('da', $ii, $options['qTLng']); ?>
47
+
48
+
49
+ <br/>
50
+ <ul class="nsx_tabs">
51
+ <li><a href="#nsx<?php echo $nt.$ii ?>_tab1"><?php _e('Account Info', 'nxs_snap'); ?></a></li>
52
+ <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'nxs_snap'); ?></a></li>
53
+ </ul>
54
+ <div class="nsx_tab_container"><?php /* ######################## Account Tab ####################### */ ?>
55
+ <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%;">
56
+
57
+
58
+ <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")), 'nxs_snap') ?>" />
59
+ <div style="width:100%;"><strong>deviantART Password:</strong> </div><input 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")), 'nxs_snap') ?>" /> <br/>
60
+ <br/>
61
+
62
+ <div id="altFormat" style="">
63
+ <div style="width:100%;"><strong id="altFormatText"><?php _e('Post Title Format', 'nxs_snap'); ?></strong> (<a href="#" id="daTitleFormat<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('daTitleFormat<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)</div>
64
+ <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")), 'nxs_snap'); ?>" onfocus="mxs_showFrmtInfo('daTitleFormat<?php echo $ii; ?>');" /><?php nxs_doShowHint("daTitleFormat".$ii); ?>
65
+ </div><br/>
66
+
67
+ <div id="altFormat" style="margin-left: 0px;">
68
+ <div style="width:100%;"><strong id="altFormatText"><?php _e('Text Format', 'nxs_snap'); ?>:</strong> (<a href="#" id="daTextFormat<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('daTextFormat<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)
69
+ </div>
70
+
71
+ <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%", 'nxs_snap'); else _e(apply_filters('format_to_edit', htmlentities($options['daTextFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap'); ?></textarea>
72
+
73
+ <?php nxs_doShowHint("daTextFormat".$ii); ?>
74
+ </div><br/>
75
+
76
+
77
+ <?php if ($isNew) { ?> <input type="hidden" name="da[<?php echo $ii; ?>][apDoDA]" value="1" id="apDoNewDA<?php echo $ii; ?>" /> <?php } ?>
78
+ <?php if ($options['daPass']!='') { ?>
79
+
80
+ <b><?php _e('Test your settings', 'nxs_snap'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('DA', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'nxs_snap' ), $nType); ?></a> <?php }
81
+ ?>
82
+ </div>
83
+
84
+ <?php /* ######################## Advanced Tab ####################### */ ?>
85
+ <div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content">
86
+
87
+ <?php if (!$isNew) { ?> <div class="nxs_tls_cpt"><?php _e('Categories', 'nxs_snap'); ?></div>
88
+ <div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
89
+ <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
90
+ <input value="1" id="catSelS<?php echo $ntU; ?><?php echo $ii; ?>" type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_<?php echo $ntU; ?><?php echo $ii; ?>" onclick="jQuery('#catSelS<?php echo $ntU; ?><?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('<?php echo $ntU; ?><?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($options['catSelEd']!='') echo "[".(substr_count($options['catSelEd'], ",")+1)."]"; ?></a>
91
+ <input type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
92
+ <br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
93
+ <br/>
94
+ <?php } ?>
95
+
96
+ <div class="nxs_tls_cpt"><?php _e('Posting Delay', 'nxs_snap'); ?></div>
97
+ <div class="nxs_tls_bd">
98
+ <?php echo nxs_addPostingDelaySel($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']); ?>
99
+ </div>
100
+ <?php nxs_showRepostSettings($nt, $ii, $options); ?>
101
+
102
+
103
+ </div> <?php /* #### End of Tab #### */ ?>
104
+ </div><br/> <?php /* #### End of Tabs #### */ ?>
105
+
106
+ <div class="submit clear" style="padding-bottom: 0px;"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div>
107
+
108
+ </div><?php
109
+ }
110
+ //#### Set Unit Settings from POST
111
+ function setNTSettings($post, $options){ global $nxs_snapThisPageUrl; $code = 'DA'; $lcode = 'da';
112
+ foreach ($post as $ii => $pval){
113
+ if (isset($pval['uName']) && $pval['uName']!=''){ if (!isset($options[$ii])) $options[$ii] = array();
114
+ if (isset($pval['uName'])) $options[$ii]['daUName'] = trim($pval['uName']);
115
+ if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']);
116
+ if (isset($pval['uPass'])) $options[$ii]['daPass'] = 'n5g9a'.nsx_doEncode($pval['uPass']); else $options[$ii]['daPass'] = '';
117
+
118
+ if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']);
119
+ if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
120
+
121
+ if (isset($pval['daTitleFormat'])) $options[$ii]['daTitleFormat'] = trim($pval['daTitleFormat']);
122
+ if (isset($pval['daTextFormat'])) $options[$ii]['daTextFormat'] = trim($pval['daTextFormat']);
123
+
124
+ if (isset($pval['apDoDA'])) $options[$ii]['doDA'] = $pval['apDoDA']; else $options[$ii]['doDA'] = 0;
125
+
126
+ $options[$ii] = nxs_adjRpst($options[$ii], $pval);
127
+
128
+ if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']);
129
+ if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
130
+ if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
131
+ }
132
+ } return $options;
133
+ }
134
+ //#### Show Post->Edit Meta Box Settings
135
+ function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID; $nt = 'da'; $ntU = 'DA';
136
+ foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapDA', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
137
+ $doDA = $ntOpt['doDA'] && (is_array($pMeta) || $ntOpt['catSel']!='1');
138
+ $isAvailDA = $ntOpt['daUName']!='' && $ntOpt['daPass']!=''; $daMsgFormat = htmlentities($ntOpt['daTextFormat'], ENT_COMPAT, "UTF-8"); $daMsgTFormat = htmlentities($ntOpt['daTitleFormat'], ENT_COMPAT, "UTF-8");
139
+
140
+ ?>
141
+ <tr><th style="text-align:left;" colspan="2"><?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_DA<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
142
+ <?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"'; ?> />
143
+ <?php if ($post->post_status == "publish") { ?> <input type="hidden" name="da[<?php echo $ii; ?>][doDA]" value="<?php echo $doDA;?>"> <?php } ?> <?php } ?>
144
+
145
+ <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', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
146
+ 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', 'nxs_snap') ?>" />
147
+ <?php } ?>
148
+
149
+ <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
150
+
151
+ ?> <span id="pstdDA<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
152
+ <a style="font-size: 10px;" href="<?php echo $pMeta[$ii]['postURL']; ?>" target="_blank"><?php $nType="deviantART"; printf( __( 'Posted on', 'nxs_snap' ), $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 (!$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>
158
+ <?php } else { if ($post->post_status != "publish" && function_exists('nxs_doSMAS5') ) { nxs_doSMAS5($nt, $ii, $ntOpt); } ?>
159
+
160
+ <?php if ($ntOpt['rpstOn']=='1') { ?>
161
+
162
+ <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top:6px; text-align:right; width:60px; padding-right:10px;">
163
+ <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"; ?> />
164
+ </th>
165
+ <td> <?php _e('Include in "Auto-Reposting" to this network.', 'nxs_snap') ?>
166
+ </td></tr> <?php } ?>
167
+
168
+
169
+ <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Title Format:', 'nxs_snap') ?></th>
170
+ <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>
171
+
172
+ <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Text Format:', 'nxs_snap') ?></th><td>
173
+
174
+ <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>
175
+
176
+ </td></tr>
177
+ <?php }
178
+ }
179
+ }
180
+ //#### Save Meta Tags to the Post
181
+ function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
182
+ if (isset($pMeta['SNAPformat'])) $optMt['daTextFormat'] = $pMeta['SNAPformat']; if (isset($pMeta['SNAPformatT'])) $optMt['daTitleFormat'] = $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['doDA'])) $optMt['doDA'] = $pMeta['doDA'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doDA'] = 0; }
186
+ if (isset($pMeta['SNAPincludeDA']) && $pMeta['SNAPincludeDA'] == '1' ) $optMt['doDA'] = 1;
187
+ return $optMt;
188
+ }
189
+ }}
190
+ if (!function_exists("nxs_rePostToDA_ajax")) {
191
+ 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;
192
+ foreach ($options['da'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj'; //if ($two['daPageID'].$two['daUName']==$_POST['nid']) {
193
+ $dapo = get_post_meta($postID, 'snapDA', true); $dapo = maybe_unserialize($dapo);// prr($dapo);
194
+ if (is_array($dapo) && isset($dapo[$ii]) && is_array($dapo[$ii])){ $ntClInst = new nxs_snapClassDA(); $two = $ntClInst->adjMetaOpt($two, $dapo[$ii]); }
195
+ $result = nxs_doPublishToDA($postID, $two); if ($result == 200) die("Successfully sent your post to deviantART."); else die($result);
196
+ }
197
+ }
198
+ }
199
+ if (!function_exists("nxs_doPublishToDA")) { //## Second Function to Post to DA
200
+ function nxs_doPublishToDA($postID, $options){ $ntCd = 'DA'; $ntCdL = 'da'; $ntNm = 'deviantART'; if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
201
+ $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'POSTID'=>$postID, 'ACCNAME'=>$options['nName']));
202
+ $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url();
203
+
204
+ $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
205
+ $logNT = '<span style="color:#800000">deviantART</span> - '.$options['nName'];
206
+ $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
207
+ if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
208
+ $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') {
209
+ nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$uqID); return;
210
+ }
211
+ }
212
+ $message = array('message'=>'', 'link'=>'', 'imageURL'=>'', 'videoURL'=>'');
213
+
214
+ if ($postID=='0') { echo "Testing ... <br/><br/>"; $message['description'] = 'Test Post, Description'; $message['title'] = 'Test Post - Title'; $message['url'] = home_url();
215
+ } else { nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1')); $post = get_post($postID); if(!$post) return;
216
+
217
+ $options['daTitleFormat'] = nsFormatMessage($options['daTitleFormat'], $postID, $addParams); $options['daTextFormat'] = nsFormatMessage($options['daTextFormat'], $postID, $addParams); // prr($options['daTextFormat']); echo $postID;
218
+ $extInfo = ' | PostID: '.$postID." - ".(isset($post) && is_object($post)?$post->post_title:'');
219
+ }
220
+ //## Actual Post
221
+ $ntToPost = new nxs_class_SNAP_DA(); $ret = $ntToPost->doPostToNT($options, $message); // echo "~~~"; prr($ret); echo "+++";
222
+ //## Process Results
223
+ if (!is_array($ret) || $ret['isPosted']!='1') { //## Error
224
+ if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);
225
+ } else { // ## All Good - log it.
226
+ if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo _e('OK - Message Posted, please see your '.$logNT.' Page. ', 'nxs_snap'); }
227
+ 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); }
228
+ }
229
+ //## Return Result
230
+ if ($ret['isPosted']=='1') return 200; else return print_r($ret, true);
231
+
232
+ }
233
+ }
234
+ ?>
inc-cl/di.api.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //## NextScripts Diigo Connection Class
3
+ $nxs_snapAPINts[] = array('code'=>'DI', 'lcode'=>'bg', 'name'=>'Diigo');
4
+
5
+ if (!class_exists("nxs_class_SNAP_DI")) { class nxs_class_SNAP_DI {
6
+
7
+ var $ntCode = 'DI';
8
+ var $ntLCode = 'di';
9
+
10
+ function doPost($options, $message){ if (!is_array($options)) return false;
11
+ foreach ($options as $ntOpts) $out[] = $this->doPostToNT($ntOpts, $message);
12
+ return $out;
13
+ }
14
+ function nxs_getDIHeaders($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['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
+ $msg = nxs_doFormatMsg($options['diMsgFormat'], $message); $msgT = nxs_doFormatMsg($options['diMsgTFormat'], $message);
29
+ $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();
30
+ $hdrsArr = $this->nxs_getDIHeaders('https://secure.diigo.com/api/v2/bookmarks', $email, $pass, true);
31
+ $cnt = wp_remote_post( 'https://secure.diigo.com/api/v2/bookmarks', array( 'method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds));
32
+ //## Return
33
+ if (is_array($cnt) && stripos($cnt['body'],'"code":1')!==false) {
34
+ return array('postID'=>'DI', 'isPosted'=>1, 'postURL'=>'DI', 'pDate'=>date('Y-m-d H:i:s'));
35
+ } else { $badOut['Error'] .= print_r($cnt, true);
36
+ return $badOut;
37
+ }
38
+ }
39
+ }}
40
+ ?>
inc-cl/di.php CHANGED
@@ -9,46 +9,48 @@ if (!class_exists("nxs_snapClassDI")) { class nxs_snapClassDI {
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); ?> <?php wp_nonce_field( 'ns'.$ntInfo['code'], 'ns'.$ntInfo['code'].'_wpnonce' ); ?>
13
  <?php if ($cbo>1){ ?><div class="nsBigText"><?php echo "(".($cbo=='0'?'No':$cbo)." "; _e('accounts', 'nxs_snap'); 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;">
19
- <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> /> <?php if ((int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
 
 
20
  <strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
21
  &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', 'nxs_snap'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>&nbsp;&nbsp;
22
  <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
23
- </p><?php $this->showNTSettings($indx, $pbo);
24
  }?>
25
  </div>
26
  </div> <?php
27
  }
28
 
29
  //#### Show NEW Settings Page
30
- function showNewNTSettings($mgpo){ $options = array('nName'=>'', 'doDI'=>'1', 'diUName'=>'', 'diInclTags'=>'1', 'diAttch'=>'', 'diAPIKey'=>'', 'diPass'=>''); $this->showNTSettings($mgpo, $options, true);}
31
 
32
  //#### Show Unit Settings
33
- function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl;
34
  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'] = '';
35
  if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; ?>
36
- <div id="doDI<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew){ ?> clNewNTSets<?php } ?>" style="background-image: url(<?php echo $nxs_plurl; ?>img/di-bg.png);background-position:90% 10%;"> <input type="hidden" name="apDoSDI<?php echo $ii; ?>" value="0" id="apDoSDI<?php echo $ii; ?>" />
37
 
38
  <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', 'nxs_snap' ), $nType); ?></a></div>
39
 
40
- <div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easely identify it', 'nxs_snap'); ?></i> </div><input name="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")), 'nxs_snap') ?>" /><br/>
41
  <?php echo nxs_addQTranslSel('di', $ii, $options['qTLng']); ?>
42
- <?php echo nxs_addPostingDelaySel('di', $ii, $options['nHrs'], $options['nMin']); ?>
43
 
44
- <?php if (!$isNew) { ?>
45
- <div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
46
- <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="di[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
47
- <input value="1" id="catSelSDI<?php echo $ii; ?>" type="radio" name="di[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_DI<?php echo $ii; ?>" onclick="jQuery('#catSelSDI<?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('DI<?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_DI<?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($options['catSelEd']!='') echo "[".(substr_count($options['catSelEd'], ",")+1)."]"; ?></a>
48
- <input type="hidden" name="di[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_DI<?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
49
- <br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
50
- <br/>
51
- <?php } ?>
 
52
 
53
  <div id="altFormat" style="">
54
  <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>
@@ -77,9 +79,31 @@ if (!class_exists("nxs_snapClassDI")) { class nxs_snapClassDI {
77
  </div><br/>
78
 
79
  <?php if ($options['diPass']!='') { ?>
80
- <?php wp_nonce_field( 'rePostToDI', 'rePostToDI_wpnonce' ); ?>
81
  <b><?php _e('Test your settings', 'nxs_snap'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('DI', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'nxs_snap' ), $nType); ?></a> <?php }
82
- ?><div class="submit"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div></div><?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  }
84
  //#### Set Unit Settings from POST
85
  function setNTSettings($post, $options){ global $nxs_snapThisPageUrl; $code = 'DI'; $lcode = 'di';
@@ -97,13 +121,17 @@ if (!class_exists("nxs_snapClassDI")) { class nxs_snapClassDI {
97
  if (isset($pval['apDIMsgTFrmt'])) $options[$ii]['diMsgTFormat'] = trim($pval['apDIMsgTFrmt']);
98
  if (isset($pval['apDIMsgFrmt'])) $options[$ii]['diMsgFormat'] = trim($pval['apDIMsgFrmt']);
99
  if (isset($pval['apDoDI'])) $options[$ii]['doDI'] = $pval['apDoDI']; else $options[$ii]['doDI'] = 0;
 
 
 
 
100
  if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
101
  if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
102
  }
103
  } return $options;
104
  }
105
  //#### Show Post->Edit Meta Box Settings
106
- function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
107
  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]);
108
  $doDI = $ntOpt['doDI'] && (is_array($pMeta) || $ntOpt['catSel']!='1');
109
  $isAvailDI = $ntOpt['diUName']!='' && $ntOpt['diPass']!=''; $diMsgFormat = htmlentities($ntOpt['diMsgFormat'], ENT_COMPAT, "UTF-8"); $diMsgTFormat = htmlentities($ntOpt['diMsgTFormat'], ENT_COMPAT, "UTF-8");
@@ -114,14 +142,23 @@ if (!class_exists("nxs_snapClassDI")) { class nxs_snapClassDI {
114
 
115
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/di16.png);">Diigo - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
116
  if ($post->post_status == "publish" && $isAvailDI) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToDI_repostButton" id="rePostToDI_button" value="<?php _e('Repost to Diigo', 'nxs_snap') ?>" />
117
- <?php wp_nonce_field( 'rePostToDI', 'rePostToDI_wpnonce' ); } ?>
118
  <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
119
  ?> <span id="pstdDI<?php echo $ii; ?>" style="float: right; padding-top: 4px; padding-right: 10px;">
120
  <a style="font-size: 10px;" href="http://www.diigo.com/user/<?php echo $ntOpt['diUName']; ?>" target="_blank"><?php $nType="Diigo"; printf( __( 'Posted on', 'nxs_snap' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
121
  </span><?php } ?>
122
  </td></tr>
123
  <?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>
124
- <?php } elseif ($post->post_status != "pubZlish") { ?>
 
 
 
 
 
 
 
 
 
125
  <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Title Format:', 'nxs_snap') ?></th>
126
  <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>
127
  <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Text Format:', 'nxs_snap') ?></th>
@@ -135,13 +172,15 @@ if (!class_exists("nxs_snapClassDI")) { class nxs_snapClassDI {
135
  function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
136
  if (isset($pMeta['SNAPformat'])) $optMt['diMsgFormat'] = $pMeta['SNAPformat'];
137
  if (isset($pMeta['SNAPformatT'])) $optMt['diMsgTFormat'] = $pMeta['SNAPformatT'];
 
 
138
  if (isset($pMeta['doDI'])) $optMt['doDI'] = $pMeta['doDI'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doDI'] = 0; }
139
  if (isset($pMeta['SNAPincludeDI']) && $pMeta['SNAPincludeDI'] == '1' ) $optMt['doDI'] = 1;
140
  return $optMt;
141
  }
142
  }}
143
  if (!function_exists("nxs_rePostToDI_ajax")) {
144
- function nxs_rePostToDI_ajax() { check_ajax_referer('rePostToDI'); $postID = $_POST['id']; $options = get_option('NS_SNAutoPoster');
145
  foreach ($options['di'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj'; //if ($two['gpPageID'].$two['gpUName']==$_POST['nid']) {
146
  $gppo = get_post_meta($postID, 'snapDI', true); $gppo = maybe_unserialize($gppo);// prr($gppo);
147
  if (is_array($gppo) && isset($gppo[$ii]) && is_array($gppo[$ii])){ $ntClInst = new nxs_snapClassDI(); $two = $ntClInst->adjMetaOpt($two, $gppo[$ii]); }
@@ -150,86 +189,11 @@ if (!function_exists("nxs_rePostToDI_ajax")) {
150
  }
151
  }
152
 
153
- if (!function_exists("nxs_getDIHeaders")) { function nxs_getDIHeaders($ref, $uname, $pass, $post=false){ $hdrsArr = array();
154
- $hdrsArr['X-Requested-With']='XMLHttpRequest'; $hdrsArr['Connection']='keep-alive'; $hdrsArr['Referer']=$ref;
155
- $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';
156
- if($post) $hdrsArr['Content-Type']='application/x-www-form-urlencoded';
157
- $hdrsArr['Accept']='application/json, text/javascript, */*; q=0.01';
158
- $hdrsArr['Authorization']= 'Basic '.base64_encode($uname.':'.$pass);
159
- $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;
160
- }}
161
- if (!function_exists("nxs_doCheckDI")) {function nxs_doCheckDI($url){ global $nxs_diCkArray; $hdrsArr = nxs_getDIHeaders($url); $ckArr = $nxs_diCkArray;
162
- $response = wp_remote_get($url, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr));
163
- if (stripos($response['body'],'logouthash=')===false) return 'Bad Saved Login';
164
- if ( stripos($response['body'], 'usercp.php')!==false && stripos($response['body'], 'logouthash')!==false){ /*echo "You are IN"; */ return false;
165
- } else return 'No Saved Login';
166
- return false;
167
- }}
168
- if (!function_exists("nxs_doConnectToDI")) { function nxs_doConnectToDI($u, $p, $url){ global $nxs_diCkArray; $hdrsArr = nxs_getDIHeaders($url, true); echo "LOGGIN";
169
- $response = wp_remote_get($url); $contents = $response['body']; //$response['body'] = htmlentities($response['body']); prr($response); die();
170
- $ckArr = $response['cookies']; $mdhashLoc = stripos($contents, 'md5hash(di_login_password');
171
- if ($mdhashLoc===false) return "No DI found";
172
- $frmTxt = CutFromTo($contents, 'md5hash(di_login_password','</form>'); $md = array(); $flds = array();
173
- while (stripos($frmTxt, '<input')!==false){ $inpField = trim(CutFromTo($frmTxt,'<input', '>')); $name = trim(CutFromTo($inpField,'name="', '"'));
174
- if ( stripos($inpField, '"hidden"')!==false && $name!='' && !in_array($name, $md)) { $md[] = $name; $val = trim(CutFromTo($inpField,'value="', '"')); $flds[$name]= $val; $mids .= "&".$name."=".$val;}
175
- $frmTxt = substr($frmTxt, stripos($frmTxt, '<input')+8);
176
- } $flds['di_login_username'] = $u; $flds['di_login_md5password'] = md5($p); $flds['di_login_md5password_utf'] = md5($p); $flds['cookieuser'] = '1'; $flds['do'] = 'login';
177
-
178
- // $logURL = substr($contents, $mdhashLoc-250, 250); $logURL = CutFromTo($logURL, 'action="', '"');
179
- if (stripos($contents, 'base href="')!==false) $baseURL = trim(CutFromTo($contents,'base href="', '"')); else { $uarr = explode('/',$url); $dd = $uarr[count($uarr)-1]; $baseURL = str_replace($dd, '', $url);}
180
-
181
- //echo $baseURL.'login.php?do=login'; prr($flds);
182
- $r2 = wp_remote_post( $baseURL.'login.php?do=login', array( 'method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds, 'cookies' => $ckArr));
183
-
184
- //$r2['body'] = htmlentities($r2['body']); prr($r2);
185
-
186
- if (stripos($r2['body'],'exec_refresh()')!==false) { $ckArr = nxsMergeArraysOV($ckArr, $r2['cookies']); $nxs_diCkArray = $ckArr; return false; } else return "Bad Username/Password";
187
- }}
188
-
189
- if (!function_exists("nxs_doPostToDI")) { function nxs_doPostToDI($url, $subj, $msg, $lnk, $tags){ global $nxs_diCkArray; $hdrsArr = nxs_getDIHeaders($url); $ckArr = $nxs_diCkArray;
190
- $response = wp_remote_get($url, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr));
191
- $contents = $response['body']; //$response['body'] = htmlentities($response['body']); prr($response); die();
192
- if (stripos($contents, 'base href="')!==false) $baseURL = trim(CutFromTo($contents,'base href="', '"')); else { $uarr = explode('/',$url); $dd = $uarr[count($uarr)-1]; $baseURL = str_replace($dd, '', $url);}
193
- if (stripos($contents, 'newthread.php?do=newthread')!==false) $mdd='t'; elseif (stripos($contents, 'newreply.php?')!==false) $mdd='p'; else return "No Thread/Post Controls found";
194
-
195
- if ($mdd=='t'){ $fid = CutFromTo($contents, 'newthread.php?do=newthread','"'); // echo $baseURL.'newthread.php?do=newthread'.str_replace('&amp;','&',$fid);
196
- $response = wp_remote_get( $baseURL.'newthread.php?do=newthread'.str_replace('&amp;','&',$fid), array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr)); $contents = $response['body'];
197
- $frmTxt = CutFromTo($contents, 'newthread.php?do=postthread','</form>'); $md = array(); $flds = array(); //prr($frmTxt);
198
- while (stripos($frmTxt, '<input')!==false){ $inpField = trim(CutFromTo($frmTxt,'<input', '>')); $name = trim(CutFromTo($inpField,'name="', '"'));
199
- if ( stripos($inpField, '"hidden"')!==false && $name!='' && !in_array($name, $md)) { $md[] = $name; $val = trim(CutFromTo($inpField,'value="', '"')); $flds[$name]= $val; $mids .= "&".$name."=".$val;}
200
- $frmTxt = substr($frmTxt, stripos($frmTxt, '<input')+8);
201
- } $flds['subject'] = $subj; $flds['message'] = $msg; $flds['message_backup'] = $msg; $flds['wysiwyg'] = '1'; $flds['do'] = 'postthread'; $flds['taglist'] = $tags; $flds['parseurl'] = '1'; $flds['sbutton'] = 'Submit+New+Thread';
202
- $smURL = $baseURL.'newthread.php?do=postthread'.str_replace('&amp;','&',$fid);
203
- }
204
-
205
- if ($mdd=='p'){ $fid = CutFromTo($contents, 'newreply.php?do=newreply','"');
206
- $response = wp_remote_get( $baseURL.'newreply.php?do=newreply'.str_replace('&amp;','&',$fid), array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr)); $contents = $response['body'];
207
-
208
- $frmTxt = CutFromTo($contents, 'newreply.php?do=postreply','</form>'); $md = array(); $flds = array(); //prr($frmTxt);
209
-
210
- while (stripos($frmTxt, '<input')!==false){ $inpField = trim(CutFromTo($frmTxt,'<input', '>')); $name = trim(CutFromTo($inpField,'name="', '"'));
211
- if ( stripos($inpField, '"hidden"')!==false && $name!='' && !in_array($name, $md)) { $md[] = $name; $val = trim(CutFromTo($inpField,'value="', '"')); $flds[$name]= $val; $mids .= "&".$name."=".$val;}
212
- $frmTxt = substr($frmTxt, stripos($frmTxt, '<input')+8);
213
- } $flds['title'] = $subj; $flds['message'] = $msg; $flds['message_backup'] = $msg; $flds['wysiwyg'] = '1'; $flds['do'] = 'postreply'; $flds['parseurl'] = '1'; $flds['sbutton'] = 'Submit+Reply';
214
- $smURL = $baseURL.'newreply.php?do=postreply'.str_replace('&amp;','&',$fid);
215
- }
216
-
217
- //echo $smURL."|"; prr($flds);
218
- $r2 = wp_remote_post( $smURL, array( 'method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds, 'cookies' => $ckArr));
219
- if (stripos($r2['body'], 'errorblock')!==false) return trim(strip_tags( CutFromTo($r2['body'], 'errorblock','</div>')));
220
- if (stripos($r2['body'], 'exec_refresh()')!==false && stripos($r2['body'], 'blockrow restore">')!==false) return trim(strip_tags( CutFromTo($r2['body'], 'blockrow restore">','</p>')));
221
- if (stripos($r2['body'], '<error>')!==false) return trim(strip_tags( CutFromTo($r2['body'], '<error>','</error>')));
222
- if ( $r2['response']['code']=='302' || $r2['response']['code']=='303') return 'OK';
223
- if (stripos($r2['body'], '<newpostid>')!==false || stripos($r2['body'], 'postbit postid="')!==false ) return 'OK';
224
-
225
- // $r2['body'] = htmlentities($r2['body']); prr($r2); die();
226
-
227
- return "Something wrong";
228
- }}
229
-
230
  if (!function_exists("nxs_doPublishToDI")) { //## Second Function to Post to DI
231
- function nxs_doPublishToDI($postID, $options){ global $nxs_diCkArray; $ntCd = 'DI'; $ntCdL = 'di'; $ntNm = 'Diigo';
232
  // if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToDI', array($postID, $options));
 
 
233
  $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
234
  $logNT = '<span style="color:#000080">Diigo</span> - '.$options['nName'];
235
  $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
@@ -238,33 +202,26 @@ if (!function_exists("nxs_doPublishToDI")) { //## Second Function to Post to DI
238
  nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'); return;
239
  }
240
  }
241
- if ($postID=='0') { echo "Testing ... <br/><br/>"; $link = home_url(); $msg = 'Test Message from '.$link; $msgT = 'Test Link from '.$link; } else {
242
  $post = get_post($postID); if(!$post) return; $link = get_permalink($postID);
243
- $msgFormat = $options['diMsgFormat']; $diCat = $options['diCat']; $msg = nsFormatMessage($msgFormat, $postID); $msgFormatT = $options['diMsgTFormat']; $msgT = nsFormatMessage($msgFormatT, $postID);
244
  nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
245
  }
246
- $extInfo = ' | PostID: '.$postID." - ".$post->post_title;
247
- //## Actual POST Code
248
- $email = $options['diUName']; $pass = (substr($options['diPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['diPass'], 5)):$options['diPass']);
249
- $dusername = $options['diUName']; //$link = urlencode($link); $desc = urlencode(substr($msg, 0, 500));
250
-
251
- $t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = (implode(',',$tggs)); $tags = str_replace(' ','+',$tags);
252
-
253
- $flds = array(); $flds['key']=$options['diAPIKey']; $flds['url']=$link; $flds['title']=nsTrnc($msgT, 250); $flds['desc']=nsTrnc($msg, 250); $flds['tags']=$tags; $flds['shared']='yes';
254
- $hdrsArr = nxs_getDIHeaders('https://secure.diigo.com/api/v2/bookmarks', $dusername, $pass, true);
255
- $cnt = wp_remote_post( 'https://secure.diigo.com/api/v2/bookmarks', array( 'method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds));
256
-
257
- if( is_wp_error( $cnt ) ) {
258
- $ret = 'Something went wrong - '; nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.$ret. "ERR: ".print_r($cnt, true), $extInfo);
259
- } else {
260
- if (is_array($cnt) && stripos($cnt['body'],'"code":1')!==false)
261
- { $ret = 'OK'; nxs_metaMarkAsPosted($postID, 'DI', $options['ii'], array('isPosted'=>'1', 'pgID'=>'DI', 'pDate'=>date('Y-m-d H:i:s'))); nxs_addToLogN( 'S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); }
262
- else { if ($cnt['response']['code']=='401') $ret = " Incorrect Username/Password "; else $ret = 'Something went wrong - '; nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.$ret. "ERR: ".print_r($cnt, true), $extInfo);
263
- }
264
- }
265
- if ($ret!='OK') { if ($postID=='0') echo $ret; } else if ($postID=='0') { echo 'OK - Message Posted, please see your Diigo Page'; nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); }
266
- if ($ret == 'OK') return 200; else return $ret;
267
-
268
  }
269
  }
270
  ?>
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', 'nxs_snap'); 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;">
19
+ <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> />
20
+ <?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 } ?>
21
+ <?php if (isset($pbo['rpstOn']) && (int)$pbo['rpstOn'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popReActive');" onmouseover="nxs_showPopUpInfo('popReActive', event);"><?php echo "*[R]*" ?></span><?php } ?>
22
  <strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
23
  &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', 'nxs_snap'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>&nbsp;&nbsp;
24
  <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
25
+ </p><?php $pbo['ntInfo'] = $ntInfo; $this->showNTSettings($indx, $pbo);
26
  }?>
27
  </div>
28
  </div> <?php
29
  }
30
 
31
  //#### Show NEW Settings Page
32
+ function showNewNTSettings($mgpo){ $options = array('nName'=>'', 'doDI'=>'1', 'diUName'=>'', 'diInclTags'=>'1', 'diAttch'=>'', 'diAPIKey'=>'', 'diPass'=>''); $options['ntInfo']= array('lcode'=>'di'); $this->showNTSettings($mgpo, $options, true);}
33
 
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="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; ?>" />
39
 
40
  <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', 'nxs_snap' ), $nType); ?></a></div>
41
 
42
+ <div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'nxs_snap'); ?></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")), 'nxs_snap') ?>" /><br/>
43
  <?php echo nxs_addQTranslSel('di', $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', 'nxs_snap'); ?></a></li>
48
+ <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'nxs_snap'); ?></a></li>
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
 
55
  <div id="altFormat" style="">
56
  <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>
79
  </div><br/>
80
 
81
  <?php if ($options['diPass']!='') { ?>
82
+
83
  <b><?php _e('Test your settings', 'nxs_snap'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('DI', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'nxs_snap' ), $nType); ?></a> <?php }
84
+ ?>
85
+ </div>
86
+ <?php /* ######################## Advanced Tab ####################### */ ?>
87
+ <div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content">
88
+
89
+ <?php if (!$isNew) { ?> <div class="nxs_tls_cpt"><?php _e('Categories', 'nxs_snap'); ?></div>
90
+ <div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
91
+ <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
92
+ <input value="1" id="catSelS<?php echo $ntU; ?><?php echo $ii; ?>" type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_<?php echo $ntU; ?><?php echo $ii; ?>" onclick="jQuery('#catSelS<?php echo $ntU; ?><?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('<?php echo $ntU; ?><?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($options['catSelEd']!='') echo "[".(substr_count($options['catSelEd'], ",")+1)."]"; ?></a>
93
+ <input type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
94
+ <br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
95
+ <br/>
96
+ <?php } ?>
97
+
98
+ <?php nxs_addPostingDelaySelV3($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']); ?>
99
+ <?php nxs_showRepostSettings($nt, $ii, $options); ?>
100
+
101
+
102
+ </div> <?php /* #### End of Tab #### */ ?>
103
+ </div><br/> <?php /* #### End of Tabs #### */ ?>
104
+
105
+ <div class="submit clear" style="padding-bottom: 0px;"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div>
106
+ </div><?php
107
  }
108
  //#### Set Unit Settings from POST
109
  function setNTSettings($post, $options){ global $nxs_snapThisPageUrl; $code = 'DI'; $lcode = 'di';
121
  if (isset($pval['apDIMsgTFrmt'])) $options[$ii]['diMsgTFormat'] = trim($pval['apDIMsgTFrmt']);
122
  if (isset($pval['apDIMsgFrmt'])) $options[$ii]['diMsgFormat'] = trim($pval['apDIMsgFrmt']);
123
  if (isset($pval['apDoDI'])) $options[$ii]['doDI'] = $pval['apDoDI']; else $options[$ii]['doDI'] = 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
  }
131
  } return $options;
132
  }
133
  //#### Show Post->Edit Meta Box Settings
134
+ function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID; $nt = 'di'; $ntU = 'DI';
135
  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]);
136
  $doDI = $ntOpt['doDI'] && (is_array($pMeta) || $ntOpt['catSel']!='1');
137
  $isAvailDI = $ntOpt['diUName']!='' && $ntOpt['diPass']!=''; $diMsgFormat = htmlentities($ntOpt['diMsgFormat'], ENT_COMPAT, "UTF-8"); $diMsgTFormat = htmlentities($ntOpt['diMsgTFormat'], ENT_COMPAT, "UTF-8");
142
 
143
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/di16.png);">Diigo - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
144
  if ($post->post_status == "publish" && $isAvailDI) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToDI_repostButton" id="rePostToDI_button" value="<?php _e('Repost to Diigo', 'nxs_snap') ?>" />
145
+ <?php } ?>
146
  <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
147
  ?> <span id="pstdDI<?php echo $ii; ?>" style="float: right; padding-top: 4px; padding-right: 10px;">
148
  <a style="font-size: 10px;" href="http://www.diigo.com/user/<?php echo $ntOpt['diUName']; ?>" target="_blank"><?php $nType="Diigo"; printf( __( 'Posted on', 'nxs_snap' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
149
  </span><?php } ?>
150
  </td></tr>
151
  <?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>
152
+ <?php } else { if ($post->post_status != "publish" && function_exists('nxs_doSMAS5') ) { nxs_doSMAS5($nt, $ii, $ntOpt); } ?>
153
+
154
+ <?php if ($ntOpt['rpstOn']=='1') { ?>
155
+
156
+ <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top:6px; text-align:right; width:60px; padding-right:10px;">
157
+ <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"; ?> />
158
+ </th>
159
+ <td> <?php _e('Include in "Auto-Reposting" to this network.', 'nxs_snap') ?>
160
+ </td></tr> <?php } ?>
161
+
162
  <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Title Format:', 'nxs_snap') ?></th>
163
  <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>
164
  <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Text Format:', 'nxs_snap') ?></th>
172
  function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
173
  if (isset($pMeta['SNAPformat'])) $optMt['diMsgFormat'] = $pMeta['SNAPformat'];
174
  if (isset($pMeta['SNAPformatT'])) $optMt['diMsgTFormat'] = $pMeta['SNAPformatT'];
175
+ if (isset($pMeta['imgToUse'])) $optMt['imgToUse'] = $pMeta['imgToUse'];
176
+ if (isset($pMeta['timeToRun'])) $optMt['timeToRun'] = $pMeta['timeToRun']; if (isset($pMeta['rpstPostIncl'])) $optMt['rpstPostIncl'] = $pMeta['rpstPostIncl'];
177
  if (isset($pMeta['doDI'])) $optMt['doDI'] = $pMeta['doDI'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doDI'] = 0; }
178
  if (isset($pMeta['SNAPincludeDI']) && $pMeta['SNAPincludeDI'] == '1' ) $optMt['doDI'] = 1;
179
  return $optMt;
180
  }
181
  }}
182
  if (!function_exists("nxs_rePostToDI_ajax")) {
183
+ function nxs_rePostToDI_ajax() { check_ajax_referer('nxsSsPageWPN'); $postID = $_POST['id']; $options = get_option('NS_SNAutoPoster');
184
  foreach ($options['di'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj'; //if ($two['gpPageID'].$two['gpUName']==$_POST['nid']) {
185
  $gppo = get_post_meta($postID, 'snapDI', true); $gppo = maybe_unserialize($gppo);// prr($gppo);
186
  if (is_array($gppo) && isset($gppo[$ii]) && is_array($gppo[$ii])){ $ntClInst = new nxs_snapClassDI(); $two = $ntClInst->adjMetaOpt($two, $gppo[$ii]); }
189
  }
190
  }
191
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192
  if (!function_exists("nxs_doPublishToDI")) { //## Second Function to Post to DI
193
+ 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));
194
  // if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToDI', array($postID, $options));
195
+ $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'POSTID'=>$postID, 'ACCNAME'=>$options['nName']));
196
+ $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url();
197
  $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
198
  $logNT = '<span style="color:#000080">Diigo</span> - '.$options['nName'];
199
  $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
202
  nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'); return;
203
  }
204
  }
205
+ if ($postID=='0') { echo "Testing ... <br/><br/>"; $link = home_url(); $options['diMsgFormat'] = 'Test Message from '.$link; $options['diMsgTFormat'] = 'Test Link from '.$link; } else {
206
  $post = get_post($postID); if(!$post) return; $link = get_permalink($postID);
207
+ $options['diMsgFormat'] = nxs_decodeEntitiesFull(nsFormatMessage( $options['diMsgFormat'], $postID, $addParams)); $options['diMsgTFormat'] = nxs_decodeEntitiesFull(nsFormatMessage($options['diMsgTFormat'], $postID, $addParams));
208
  nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
209
  }
210
+ $extInfo = ' | PostID: '.$postID." - ".(isset($post) && is_object($post)?$post->post_title:'');
211
+ //## Create and Format message
212
+ $t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = (implode(',',$tggs)); $tags = str_replace(' ','+',$tags);
213
+ $message = array('url'=>$link, 'surl'=>$link, 'siteName'=>$blogTitle, 'tags'=>$tags);
214
+ //## Actual Post
215
+ $ntToPost = new nxs_class_SNAP_DI(); $ret = $ntToPost->doPostToNT($options, $message);
216
+ //## Process Results
217
+ if (!is_array($ret) || $ret['isPosted']!='1') { //## Error
218
+ if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);
219
+ } else { // ## All Good - log it.
220
+ if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo _e('OK - Message Posted, please see your '.$logNT.' Page. ', 'nxs_snap'); }
221
+ 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); }
222
+ }
223
+ //## Return Result
224
+ if ($ret['isPosted']=='1') return 200; else return print_r($ret, true);
 
 
 
 
 
 
 
225
  }
226
  }
227
  ?>
inc-cl/dl.api.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //## NextScripts Delicious Connection Class
3
+ $nxs_snapAPINts[] = array('code'=>'DL', 'lcode'=>'dl', 'name'=>'Delicious');
4
+
5
+ if (!class_exists("nxs_class_SNAP_DL")) { class nxs_class_SNAP_DL {
6
+
7
+ var $ntCode = 'DL';
8
+ var $ntLCode = 'dl';
9
+
10
+ function doPost($options, $message){ if (!is_array($options)) return false;
11
+ foreach ($options as $ntOpts) $out[] = $this->doPostToNT($ntOpts, $message);
12
+ return $out;
13
+ }
14
+ function nxs_getDLHeaders($up){ $hdrsArr = array();
15
+ $hdrsArr['Cache-Control']='no-cache'; $hdrsArr['Connection']='keep-alive';
16
+ $hdrsArr['User-Agent']='SNAP for Wordpress; Ver '.NextScripts_SNAP_Version;
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
+ 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['dlUName']) || trim($options['dlPass'])=='') { $badOut['Error'] = 'Not Configured'; return $badOut; }
26
+ $email = $options['dlUName']; $pass = substr($options['dlPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['dlPass'], 5)):$options['dlPass'];
27
+ //## Format
28
+ $msg = nxs_doFormatMsg($options['dlMsgFormat'], $message); $msgT = nxs_doFormatMsg($options['dlMsgTFormat'], $message); $tags = nsTrnc($message['tags'], 195, ',', '');
29
+
30
+ $api = "api.del.icio.us/v1"; $link = urlencode($message['url']); $desc = urlencode(substr($msgT, 0, 250)); $ext = urlencode(substr($msg, 0, 1000));
31
+ $apicall = "https://$api/posts/add?red=api&url=$link&description=$desc&extended=$ext&tags=$tags";
32
+ $hdrsArr = $this->nxs_getDLHeaders($email.':'.$pass); $cnt = wp_remote_get( $apicall, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr) ); // prr($cnt);
33
+
34
+ if(is_wp_error($cnt)) { $error_string = $cnt->get_error_message(); if (stripos($error_string, ' timed out')!==false) { sleep(10);
35
+ $cnt = wp_remote_get( $apicall, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr) );}
36
+ }
37
+ if(is_wp_error($cnt)) {
38
+ $badOut['Error'] .= 'Something went wrong - '."http://$dusername:*********@$api/posts/add?&url=$link&description=$desc&extended=$ext&tags=$tags | ERR: ".print_r($cnt, true);
39
+ } else {
40
+ if (is_array($cnt) && stripos($cnt['body'],'code="done"')!==false) {
41
+ return array('postID'=>'DL', 'isPosted'=>1, 'postURL'=>'DL', 'pDate'=>date('Y-m-d H:i:s'));
42
+ } elseif (is_array($cnt) && $cnt['body']=='<?xml version="1.0" encoding="UTF-8"?>') $ret = 'It looks like Delicious API is Down';
43
+ elseif (is_array($cnt) && stripos($cnt['body'],'item already exists')!==false) $ret = '..All good, but this link has already been bookmarked..';
44
+ else { if ($cnt['response']['code']=='401') $ret = " Incorrect Username/Password "; else $ret = 'Something went wrong - '."https://$dusername:*********@$api/posts/add?&url=$link&description=$desc&extended=$ext&tags=$tags"; }
45
+ }
46
+ $badOut['Error'] .= $ret; return $badOut;
47
+ }
48
+ }}
49
+ ?>
inc-cl/dl.php CHANGED
@@ -8,46 +8,48 @@ if (!class_exists("nxs_snapClassDL")) { class nxs_snapClassDL {
8
  <div class="nxs_box">
9
  <div class="nxs_box_header">
10
  <div class="nsx_iconedTitle" style="margin-bottom:1px;background-image:url(<?php echo $nxs_plurl;?>img/<?php echo $ntInfo['lcode']; ?>16.png);"><?php echo $ntInfo['name']; ?>
11
- <?php $cbo = count($ntOpts); ?> <?php wp_nonce_field( 'ns'.$ntInfo['code'], 'ns'.$ntInfo['code'].'_wpnonce' ); ?>
12
  <?php if ($cbo>1){ ?><div class="nsBigText"><?php echo "(".($cbo=='0'?'No':$cbo)." "; _e('accounts', 'nxs_snap'); echo ")"; ?></div><?php } ?>
13
  </div>
14
  </div>
15
  <div class="nxs_box_inside">
16
  <?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
17
  <p style="margin:0px;margin-left:5px;">
18
- <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> /> <?php if ((int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
 
 
19
  <strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
20
  &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', 'nxs_snap'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>&nbsp;&nbsp;
21
  <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
22
- </p><?php $this->showNTSettings($indx, $pbo);
23
  }?>
24
  </div>
25
  </div> <?php
26
  }
27
  //#### Show NEW Settings Page
28
- function showNewNTSettings($mgpo){ $gpo = array('nName'=>'', 'doDL'=>'1', 'dlUName'=>'', 'dlPageID'=>'', 'dlAttch'=>'', 'dlPass'=>''); $this->showNTSettings($mgpo, $gpo, true);}
29
  //#### Show Unit Settings
30
- function showNTSettings($ii, $gpo, $isNew=false){ global $nxs_plurl;
31
- if (!isset($gpo['nHrs'])) $gpo['nHrs'] = 0; if (!isset($gpo['nMin'])) $gpo['nMin'] = 0; if (!isset($gpo['catSel'])) $gpo['catSel'] = 0; if (!isset($gpo['catSelEd'])) $gpo['catSelEd'] = '';
32
- if (!isset($gpo['nDays'])) $gpo['nDays'] = 0; if (!isset($gpo['qTLng'])) $gpo['qTLng'] = ''; ?>
33
- <div id="doDL<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>" style="max-width: 1000px; background-color: #EBF4FB; background-image: url(<?php echo $nxs_plurl; ?>img/dl-bg.png); background-position:90% 10%; background-repeat: no-repeat; 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; ?>" />
34
 
35
  <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', 'nxs_snap' ), $nType); ?></a></div>
36
 
37
- <div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easely identify it', 'nxs_snap'); ?></i> </div><input name="dl[<?php echo $ii; ?>][nName]" id="dlnName<?php echo $ii; ?>" style="font-weight: bold; color: #005800; border: 1px solid #ACACAC; width: 40%;" value="<?php _e(apply_filters('format_to_edit',htmlentities($gpo['nName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /><br/>
38
- <?php echo nxs_addQTranslSel('dl', $ii, $gpo['qTLng']); ?><?php echo nxs_addPostingDelaySel('dl', $ii, $gpo['nHrs'], $gpo['nMin']); ?>
39
 
40
- <?php if (!$isNew) { ?>
41
- <div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
42
- <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="dl[<?php echo $ii; ?>][catSel]" <?php if ((int)$gpo['catSel'] != 1) echo "checked"; ?> /> All
43
- <input value="1" id="catSelSDL<?php echo $ii; ?>" type="radio" name="dl[<?php echo $ii; ?>][catSel]" <?php if ((int)$gpo['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_DL<?php echo $ii; ?>" onclick="jQuery('#catSelSDL<?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('DL<?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_DL<?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($gpo['catSelEd']!='') echo "[".(substr_count($gpo['catSelEd'], ",")+1)."]"; ?></a>
44
- <input type="hidden" name="dl[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_DL<?php echo $ii; ?>" value="<?php echo $gpo['catSelEd']; ?>" />
45
- <br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
46
- <br/>
47
- <?php } ?>
48
 
49
- <div style="width:100%;"><strong>Delicious Username:</strong> </div><input name="dl[<?php echo $ii; ?>][apDLUName]" id="apDLUName" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit',htmlentities($gpo['dlUName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
50
- <div style="width:100%;"><strong>Delicious Password:</strong> </div><input name="dl[<?php echo $ii; ?>][apDLPass]" id="apDLPass" type="password" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities(substr($gpo['dlPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($gpo['dlPass'], 5)):$gpo['dlPass'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /> <br/>
51
 
52
  <?php if ($isNew) { ?> <input type="hidden" name="dl[<?php echo $ii; ?>][apDoDL]" value="1" id="apDoNewDL<?php echo $ii; ?>" /> <?php } ?>
53
  <br/>
@@ -55,24 +57,44 @@ if (!class_exists("nxs_snapClassDL")) { class nxs_snapClassDL {
55
  <div id="altFormat" style="">
56
  <div style="width:100%;"><strong id="altFormatText"><?php _e('Post Title Format', 'nxs_snap'); ?></strong> (<a href="#" id="apDLTMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apDLTMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)</div>
57
 
58
- <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($gpo['dlMsgTFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap'); ?>" onfocus="mxs_showFrmtInfo('apDLTMsgFrmt<?php echo $ii; ?>');" /><?php nxs_doShowHint("apDLTMsgFrmt".$ii); ?>
59
  </div>
60
 
61
  <div id="altFormat" style="">
62
  <div style="width:100%;"><strong id="altFormatText"><?php _e('Post Text Format', 'nxs_snap'); ?></strong> (<a href="#" id="apDLMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apDLMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)</div>
63
 
64
- <textarea cols="150" rows="3" id="di<?php echo $ii; ?>SNAPformat" name="dl[<?php echo $ii; ?>][apDLMsgFrmt]" style="width:51%;max-width: 650px;" onfocus="jQuery('#dl<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('apDLMsgFrmt<?php echo $ii; ?>');"><?php if ($isNew) echo "%EXCERPT%"; else _e(apply_filters('format_to_edit', htmlentities($gpo['dlMsgFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap'); ?></textarea>
65
 
66
  <?php nxs_doShowHint("apDLMsgFrmt".$ii); ?>
67
  </div><br/>
68
 
69
- <?php if ($gpo['dlPass']!='') { ?>
70
- <?php wp_nonce_field( 'rePostToDL', 'rePostToDL_wpnonce' ); ?>
71
  <b><?php _e('Test your settings', 'nxs_snap'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('DL', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'nxs_snap' ), $nType); ?></a>
72
 
73
  <?php }
74
 
75
- ?><div class="submit"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div></div><?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  }
77
  //#### Set Unit Settings from POST
78
  function setNTSettings($post, $options){ global $nxs_snapThisPageUrl; $code = 'DL'; $lcode = 'dl';
@@ -88,13 +110,17 @@ if (!class_exists("nxs_snapClassDL")) { class nxs_snapClassDL {
88
  if (isset($pval['apDLMsgFrmt'])) $options[$ii]['dlMsgFormat'] = trim($pval['apDLMsgFrmt']);
89
  if (isset($pval['apDLMsgTFrmt'])) $options[$ii]['dlMsgTFormat'] = trim($pval['apDLMsgTFrmt']);
90
  if (isset($pval['apDoDL'])) $options[$ii]['doDL'] = $pval['apDoDL']; else $options[$ii]['doDL'] = 0;
 
 
 
 
91
  if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
92
  if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
93
  }
94
  } return $options;
95
  }
96
  //#### Show Post->Edit Meta Box Settings
97
- function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
98
  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]);
99
  $doDL = $ntOpt['doDL'] && (is_array($pMeta) || $ntOpt['catSel']!='1');
100
  $isAvailDL = $ntOpt['dlUName']!='' && $ntOpt['dlPass']!=''; $dlMsgFormat = htmlentities($ntOpt['dlMsgFormat'], ENT_COMPAT, "UTF-8"); $dlMsgTFormat = htmlentities($ntOpt['dlMsgTFormat'], ENT_COMPAT, "UTF-8");
@@ -105,7 +131,7 @@ if (!class_exists("nxs_snapClassDL")) { class nxs_snapClassDL {
105
 
106
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/dl16.png);">Delicious - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
107
  if ($post->post_status == "publish" && $isAvailDL) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToDL_repostButton" id="rePostToDL_button" value="<?php _e('Repost to Delicious', 'nxs_snap') ?>" />
108
- <?php wp_nonce_field( 'rePostToDL', 'rePostToDL_wpnonce' ); } ?>
109
 
110
  <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
111
  ?> <span id="pstdDL<?php echo $ii; ?>" style="float: right; padding-top: 4px; padding-right: 10px;">
@@ -115,7 +141,16 @@ if (!class_exists("nxs_snapClassDL")) { class nxs_snapClassDL {
115
  </td></tr>
116
 
117
  <?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>
118
- <?php } elseif ($post->post_status != "pubZlish") { ?>
 
 
 
 
 
 
 
 
 
119
 
120
  <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Title Format:', 'nxs_snap') ?></th>
121
  <td><input value="<?php echo $dlMsgTFormat ?>" type="text" name="dl[<?php echo $ii; ?>][SNAPformatT]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apDLTMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apDLTMsgFrmt".$ii, '', '58'); ?></td></tr>
@@ -130,14 +165,16 @@ if (!class_exists("nxs_snapClassDL")) { class nxs_snapClassDL {
130
  //#### Save Meta Tags to the Post
131
  function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
132
  if (isset($pMeta['SNAPformat'])) $optMt['dlMsgFormat'] = $pMeta['SNAPformat'];
133
- if (isset($pMeta['SNAPformatT'])) $optMt['dlMsgTFormat'] = $pMeta['SNAPformatT'];
 
 
134
  if (isset($pMeta['doDL'])) $optMt['doDL'] = $pMeta['doDL'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doDL'] = 0; }
135
  if (isset($pMeta['SNAPincludeDL']) && $pMeta['SNAPincludeDL'] == '1' ) $optMt['doDL'] = 1;
136
  return $optMt;
137
  }
138
  }}
139
  if (!function_exists("nxs_rePostToDL_ajax")) {
140
- function nxs_rePostToDL_ajax() { check_ajax_referer('rePostToDL'); $postID = $_POST['id']; $options = get_option('NS_SNAutoPoster');
141
  foreach ($options['dl'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj'; //if ($two['gpPageID'].$two['gpUName']==$_POST['nid']) {
142
  $gppo = get_post_meta($postID, 'snapDL', true); $gppo = maybe_unserialize($gppo);// prr($gppo);
143
  if (is_array($gppo) && isset($gppo[$ii]) && is_array($gppo[$ii])){ $ntClInst = new nxs_snapClassDL(); $two = $ntClInst->adjMetaOpt($two, $gppo[$ii]);}
@@ -145,25 +182,13 @@ if (!function_exists("nxs_rePostToDL_ajax")) {
145
  }
146
  }
147
  }
148
- if (!function_exists("doConnectToDelicious")) { function doConnectToDelicious($u, $p){ global $nxs_gCookiesArr; $nxs_gCookiesArr = array(); $advSettings = array();
149
- $fldsTxt = 'username='.$u.'&password='.$p;
150
- $contents = getCurlPageX(' http://www.delicious.com/login ','', false, $fldsTxt, false, $advSettings); // prr($nxs_gCookiesArr); prr($contents);
151
- }}
152
- if (!function_exists("doPostToDelicious")) { function doPostToDelicious($postID, $options){ global $nxs_gCookiesArr;
153
 
154
- }}
155
-
156
- if (!function_exists("nxs_getDLHeaders")) { function nxs_getDLHeaders($up){ $hdrsArr = array();
157
- $hdrsArr['Cache-Control']='no-cache'; $hdrsArr['Connection']='keep-alive';
158
- $hdrsArr['User-Agent']='SNAP for Wordpress; Ver '.NextScripts_SNAP_Version;
159
- $hdrsArr['Accept']='text/html, application/xhtml+xml, */*'; $hdrsArr['DNT']='1';
160
- $hdrsArr['Authorization'] = 'Basic ' . base64_encode("$up");
161
- $hdrsArr['Accept-Encoding']='gzip,deflate'; $hdrsArr['Accept-Language']='en-US,en;q=0.8'; $hdrsArr['Accept-Charset']='ISO-8859-1,utf-8;q=0.7,*;q=0.3'; return $hdrsArr;
162
- }}
163
 
164
  if (!function_exists("nxs_doPublishToDL")) { //## Second Function to Post to DL
165
- function nxs_doPublishToDL($postID, $options){ $ntCd = 'DL'; $ntCdL = 'dl'; $ntNm = 'Delicious';
166
- // if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToDL', array($postID, $options));
 
 
167
  $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
168
  $logNT = '<span style="color:#000080">Delicious</span> - '.$options['nName'];
169
  $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
@@ -171,36 +196,31 @@ if (!function_exists("nxs_doPublishToDL")) { //## Second Function to Post to DL
171
  $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') { sleep(5);
172
  nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'); return;
173
  }
174
- }
175
-
176
- if ($postID=='0') { echo "Testing ... <br/><br/>"; $link = home_url(); $msgT = 'Test Link from '.$link; } else { $post = get_post($postID); if(!$post) return; $link = get_permalink($postID);
177
- $msgFormat = $options['dlMsgFormat']; $msgTFormat = $options['dlMsgTFormat']; $msgT = nsFormatMessage($msgTFormat, $postID); $msg = nsFormatMessage($msgFormat, $postID);
178
  nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
 
 
 
 
179
  }
180
- $extInfo = ' | PostID: '.$postID." - ".$post->post_title;
181
- $dusername = $options['dlUName']; $pass = (substr($options['dlPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['dlPass'], 5)):$options['dlPass']);
182
- $api = "api.del.icio.us/v1"; $link = urlencode($link); $desc = urlencode(substr($msgT, 0, 250)); $ext = urlencode(substr($msg, 0, 1000));
183
  $t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = urlencode(implode(',',$tggs)); $tags = str_replace(' ','+',$tags);
184
- $apicall = "https://$api/posts/add?red=api&url=$link&description=$desc&extended=$ext&tags=$tags";
185
- $hdrsArr = nxs_getDLHeaders($dusername.':'.$pass); $cnt = wp_remote_get( $apicall, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr) ); // prr($cnt);
186
 
187
- if(is_wp_error($cnt)) { $error_string = $cnt->get_error_message(); if (stripos($error_string, ' timed out')!==false) { sleep(10);
188
- $cnt = wp_remote_get( $apicall, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr) );}
189
- }
190
- if(is_wp_error($cnt)) {
191
- $ret = 'Something went wrong - '."http://$dusername:*********@$api/posts/add?&url=$link&description=$desc&extended=$ext&tags=$tags"; nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.$ret. "ERR: ".print_r($cnt, true), $extInfo);
192
- } else {
193
- if (is_array($cnt) && stripos($cnt['body'],'code="done"')!==false)
194
- { $ret = 'OK'; nxs_metaMarkAsPosted($postID, 'DL', $options['ii'], array('isPosted'=>'1', 'pgID'=>'DL', 'pDate'=>date('Y-m-d H:i:s'))); nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); }
195
- elseif (is_array($cnt) && $cnt['body']=='<?xml version="1.0" encoding="UTF-8"?>') { $ret = 'It looks like Delicious API is Down'; nxs_addToLogN('E', 'Error', $logNT, 'It looks like Delicious API is Down', $extInfo); }
196
- elseif (is_array($cnt) && stripos($cnt['body'],'item already exists')!==false) { $ret = '..All good, but this link has already been bookmarked..'; nxs_addToLogN('S', 'Skipped', $logNT, 'All good, but this link has already been bookmarked', $extInfo); }
197
- else { if ($cnt['response']['code']=='401') $ret = " Incorrect Username/Password "; else $ret = 'Something went wrong - '."https://$dusername:*********@$api/posts/add?&url=$link&description=$desc&extended=$ext&tags=$tags";
198
- nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.$ret. "ERR: ".print_r($cnt, true), $extInfo);
199
- }
200
  }
201
- if ($ret!='OK') { if ($postID=='0') echo $ret; } else if ($postID=='0') { echo 'OK - Message Posted, please see your Delicious Page'; nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); }
202
- if ($ret == 'OK') return 200; else return $ret;
203
-
204
  }
205
  }
206
  ?>
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', 'nxs_snap'); echo ")"; ?></div><?php } ?>
13
  </div>
14
  </div>
15
  <div class="nxs_box_inside">
16
  <?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
17
  <p style="margin:0px;margin-left:5px;">
18
+ <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> />
19
+ <?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 } ?>
20
+ <?php if (isset($pbo['rpstOn']) && (int)$pbo['rpstOn'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popReActive');" onmouseover="nxs_showPopUpInfo('popReActive', event);"><?php echo "*[R]*" ?></span><?php } ?>
21
  <strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
22
  &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', 'nxs_snap'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>&nbsp;&nbsp;
23
  <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
24
+ </p><?php $pbo['ntInfo'] = $ntInfo; $this->showNTSettings($indx, $pbo);
25
  }?>
26
  </div>
27
  </div> <?php
28
  }
29
  //#### Show NEW Settings Page
30
+ function showNewNTSettings($mgpo){ $options = array('nName'=>'', 'doDL'=>'1', 'dlUName'=>'', 'dlPageID'=>'', 'dlAttch'=>'', 'dlPass'=>''); $options['ntInfo']= array('lcode'=>'dl'); $this->showNTSettings($mgpo, $options, true);}
31
  //#### Show Unit Settings
32
+ function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl; $nt = $options['ntInfo']['lcode']; $ntU = strtoupper($nt);
33
+ 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'] = '';
34
+ if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; ?>
35
+ <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; ?>" />
36
 
37
  <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', 'nxs_snap' ), $nType); ?></a></div>
38
 
39
+ <div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'nxs_snap'); ?></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")), 'nxs_snap') ?>" /><br/>
40
+ <?php echo nxs_addQTranslSel('dl', $ii, $options['qTLng']); ?>
41
 
42
+ <br/>
43
+ <ul class="nsx_tabs">
44
+ <li><a href="#nsx<?php echo $nt.$ii ?>_tab1"><?php _e('Account Info', 'nxs_snap'); ?></a></li>
45
+ <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'nxs_snap'); ?></a></li>
46
+ </ul>
47
+ <div class="nsx_tab_container"><?php /* ######################## Account Tab ####################### */ ?>
48
+ <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%;">
49
+
50
 
51
+ <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")), 'nxs_snap') ?>" />
52
+ <div style="width:100%;"><strong>Delicious Password:</strong> </div><input name="dl[<?php echo $ii; ?>][apDLPass]" id="apDLPass" type="password" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities(substr($options['dlPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['dlPass'], 5)):$options['dlPass'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /> <br/>
53
 
54
  <?php if ($isNew) { ?> <input type="hidden" name="dl[<?php echo $ii; ?>][apDoDL]" value="1" id="apDoNewDL<?php echo $ii; ?>" /> <?php } ?>
55
  <br/>
57
  <div id="altFormat" style="">
58
  <div style="width:100%;"><strong id="altFormatText"><?php _e('Post Title Format', 'nxs_snap'); ?></strong> (<a href="#" id="apDLTMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apDLTMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)</div>
59
 
60
+ <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")), 'nxs_snap'); ?>" onfocus="mxs_showFrmtInfo('apDLTMsgFrmt<?php echo $ii; ?>');" /><?php nxs_doShowHint("apDLTMsgFrmt".$ii); ?>
61
  </div>
62
 
63
  <div id="altFormat" style="">
64
  <div style="width:100%;"><strong id="altFormatText"><?php _e('Post Text Format', 'nxs_snap'); ?></strong> (<a href="#" id="apDLMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apDLMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)</div>
65
 
66
+ <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")), 'nxs_snap'); ?></textarea>
67
 
68
  <?php nxs_doShowHint("apDLMsgFrmt".$ii); ?>
69
  </div><br/>
70
 
71
+ <?php if ($options['dlPass']!='') { ?>
72
+
73
  <b><?php _e('Test your settings', 'nxs_snap'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('DL', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'nxs_snap' ), $nType); ?></a>
74
 
75
  <?php }
76
 
77
+ ?></div>
78
+ <?php /* ######################## Advanced Tab ####################### */ ?>
79
+ <div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content">
80
+
81
+ <?php if (!$isNew) { ?> <div class="nxs_tls_cpt"><?php _e('Categories', 'nxs_snap'); ?></div>
82
+ <div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
83
+ <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
84
+ <input value="1" id="catSelS<?php echo $ntU; ?><?php echo $ii; ?>" type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_<?php echo $ntU; ?><?php echo $ii; ?>" onclick="jQuery('#catSelS<?php echo $ntU; ?><?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('<?php echo $ntU; ?><?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($options['catSelEd']!='') echo "[".(substr_count($options['catSelEd'], ",")+1)."]"; ?></a>
85
+ <input type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
86
+ <br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
87
+ <br/>
88
+ <?php } ?>
89
+
90
+ <?php nxs_addPostingDelaySelV3($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']); ?>
91
+ <?php nxs_showRepostSettings($nt, $ii, $options); ?>
92
+
93
+
94
+ </div> <?php /* #### End of Tab #### */ ?>
95
+ </div><br/> <?php /* #### End of Tabs #### */ ?>
96
+
97
+ <div class="submit clear" style="padding-bottom: 0px;"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div></div><?php
98
  }
99
  //#### Set Unit Settings from POST
100
  function setNTSettings($post, $options){ global $nxs_snapThisPageUrl; $code = 'DL'; $lcode = 'dl';
110
  if (isset($pval['apDLMsgFrmt'])) $options[$ii]['dlMsgFormat'] = trim($pval['apDLMsgFrmt']);
111
  if (isset($pval['apDLMsgTFrmt'])) $options[$ii]['dlMsgTFormat'] = trim($pval['apDLMsgTFrmt']);
112
  if (isset($pval['apDoDL'])) $options[$ii]['doDL'] = $pval['apDoDL']; else $options[$ii]['doDL'] = 0;
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
  }
120
  } return $options;
121
  }
122
  //#### Show Post->Edit Meta Box Settings
123
+ function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID; $nt = 'dl'; $ntU = 'DL';
124
  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]);
125
  $doDL = $ntOpt['doDL'] && (is_array($pMeta) || $ntOpt['catSel']!='1');
126
  $isAvailDL = $ntOpt['dlUName']!='' && $ntOpt['dlPass']!=''; $dlMsgFormat = htmlentities($ntOpt['dlMsgFormat'], ENT_COMPAT, "UTF-8"); $dlMsgTFormat = htmlentities($ntOpt['dlMsgTFormat'], ENT_COMPAT, "UTF-8");
131
 
132
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/dl16.png);">Delicious - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
133
  if ($post->post_status == "publish" && $isAvailDL) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToDL_repostButton" id="rePostToDL_button" value="<?php _e('Repost to Delicious', 'nxs_snap') ?>" />
134
+ <?php } ?>
135
 
136
  <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
137
  ?> <span id="pstdDL<?php echo $ii; ?>" style="float: right; padding-top: 4px; padding-right: 10px;">
141
  </td></tr>
142
 
143
  <?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>
144
+ <?php } else { if ($post->post_status != "publish" && function_exists('nxs_doSMAS5') ) { nxs_doSMAS5($nt, $ii, $ntOpt); } ?>
145
+
146
+ <?php if ($ntOpt['rpstOn']=='1') { ?>
147
+
148
+ <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top:6px; text-align:right; width:60px; padding-right:10px;">
149
+ <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"; ?> />
150
+ </th>
151
+ <td> <?php _e('Include in "Auto-Reposting" to this network.', 'nxs_snap') ?>
152
+ </td></tr> <?php } ?>
153
+
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('Title Format:', 'nxs_snap') ?></th>
156
  <td><input value="<?php echo $dlMsgTFormat ?>" type="text" name="dl[<?php echo $ii; ?>][SNAPformatT]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apDLTMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apDLTMsgFrmt".$ii, '', '58'); ?></td></tr>
165
  //#### Save Meta Tags to the Post
166
  function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
167
  if (isset($pMeta['SNAPformat'])) $optMt['dlMsgFormat'] = $pMeta['SNAPformat'];
168
+ if (isset($pMeta['SNAPformatT'])) $optMt['dlMsgTFormat'] = $pMeta['SNAPformatT'];
169
+ if (isset($pMeta['imgToUse'])) $optMt['imgToUse'] = $pMeta['imgToUse'];
170
+ if (isset($pMeta['timeToRun'])) $optMt['timeToRun'] = $pMeta['timeToRun']; if (isset($pMeta['rpstPostIncl'])) $optMt['rpstPostIncl'] = $pMeta['rpstPostIncl'];
171
  if (isset($pMeta['doDL'])) $optMt['doDL'] = $pMeta['doDL'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doDL'] = 0; }
172
  if (isset($pMeta['SNAPincludeDL']) && $pMeta['SNAPincludeDL'] == '1' ) $optMt['doDL'] = 1;
173
  return $optMt;
174
  }
175
  }}
176
  if (!function_exists("nxs_rePostToDL_ajax")) {
177
+ function nxs_rePostToDL_ajax() { check_ajax_referer('nxsSsPageWPN'); $postID = $_POST['id']; $options = get_option('NS_SNAutoPoster');
178
  foreach ($options['dl'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj'; //if ($two['gpPageID'].$two['gpUName']==$_POST['nid']) {
179
  $gppo = get_post_meta($postID, 'snapDL', true); $gppo = maybe_unserialize($gppo);// prr($gppo);
180
  if (is_array($gppo) && isset($gppo[$ii]) && is_array($gppo[$ii])){ $ntClInst = new nxs_snapClassDL(); $two = $ntClInst->adjMetaOpt($two, $gppo[$ii]);}
182
  }
183
  }
184
  }
 
 
 
 
 
185
 
 
 
 
 
 
 
 
 
 
186
 
187
  if (!function_exists("nxs_doPublishToDL")) { //## Second Function to Post to DL
188
+ function nxs_doPublishToDL($postID, $options){ $ntCd = 'DL'; $ntCdL = 'dl'; $ntNm = 'Delicious'; if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
189
+ // if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToDL', array($postID, $options));
190
+ $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'POSTID'=>$postID, 'ACCNAME'=>$options['nName']));
191
+ $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url();
192
  $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
193
  $logNT = '<span style="color:#000080">Delicious</span> - '.$options['nName'];
194
  $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
196
  $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') { sleep(5);
197
  nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'); return;
198
  }
199
+ }
200
+ if ($postID=='0') { echo "Testing ... <br/><br/>"; $urlToGo = home_url(); $msgT = 'Test Link from '.$urlToGo; } else { $post = get_post($postID); if(!$post) return;
201
+ $options['dlMsgTFormat'] = nsFormatMessage($options['dlMsgTFormat'], $postID); $options['dlMsgFormat'] = nsFormatMessage($options['dlMsgFormat'], $postID);
 
202
  nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
203
+ //## MyURL - URLToGo code
204
+ if (!isset($options['urlToUse']) || trim($options['urlToUse'])=='') $myurl = trim(get_post_meta($postID, 'snap_MYURL', true)); if ($myurl!='') $options['urlToUse'] = $myurl;
205
+ if (isset($options['urlToUse']) && trim($options['urlToUse'])!='') { $urlToGo = $options['urlToUse']; $options['useFBGURLInfo'] = true; } else $urlToGo = get_permalink($postID);
206
+ $gOptions = $plgn_NS_SNAutoPoster->nxs_options; $addURLParams = trim($gOptions['addURLParams']); if($addURLParams!='') $urlToGo .= (strpos($urlToGo,'?')!==false?'&':'?').$addURLParams;
207
  }
208
+ $extInfo = ' | PostID: '.$postID." - ".(isset($post) && is_object($post)?$post->post_title:'');
209
+ //## Create and Format message
 
210
  $t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = urlencode(implode(',',$tggs)); $tags = str_replace(' ','+',$tags);
 
 
211
 
212
+ $message = array('url'=>$urlToGo, 'surl'=>$urlToGo, 'siteName'=>$blogTitle, 'tags'=>$tags);
213
+ //## Actual Post
214
+ $ntToPost = new nxs_class_SNAP_DL(); $ret = $ntToPost->doPostToNT($options, $message);
215
+ //## Process Results
216
+ if (!is_array($ret) || $ret['isPosted']!='1') { //## Error
217
+ if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);
218
+ } else { // ## All Good - log it.
219
+ if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo _e('OK - Message Posted, please see your '.$logNT.' Page. ', 'nxs_snap'); }
220
+ 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); }
 
 
 
 
221
  }
222
+ //## Return Result
223
+ if ($ret['isPosted']=='1') return 200; else return print_r($ret, true);
 
224
  }
225
  }
226
  ?>
inc-cl/fb.api.php CHANGED
@@ -11,7 +11,7 @@ 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){ require_once ('apis/facebook.php'); $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>''); // prr($message); prr($options);
15
  //## Check settings
16
  if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
17
  if (!isset($options['fbAppAuthToken']) || trim($options['fbAppAuthToken'])=='') { $badOut['Error'] = 'No Auth Token Found'; return $badOut; }
@@ -24,17 +24,26 @@ if (!class_exists("nxs_class_SNAP_FB")) { class nxs_class_SNAP_FB {
24
  if (!isset($options['postType']) && isset($options['fbPostType'])) $options['postType'] = $options['fbPostType'];
25
  if (!isset($options['pgID']) && isset($options['fbPgID'])) $options['pgID'] = $options['fbPgID'];
26
 
27
- $msg = $message['message']; $imgURL = $message['imageURL']; $fbPostType = $options['postType']; $fbWhere = 'feed';
 
 
 
 
 
 
 
 
 
28
  $attachType = $options['attachType']; if ($attachType=='1') $attachType = 'A'; else $attachType = 'S';
29
- if ($options['imgUpl']!='2') $options['imgUpl'] = 'T'; else $options['imgUpl'] = 'A'; $page_id = $options['pgID'];
30
  $msg = strip_tags($msg); $msg = str_ireplace('&lt;(")','<(")', $msg); //## FB Smiles FIX 3
31
- if (substr($msg, 0, 1)=='@') $msg = ' '.$msg;
32
- $mssg = array('access_token' => $options['fbAppPageAuthToken'], 'message' => $msg);
33
 
34
  if ($fbPostType=='I' && trim($imgURL)=='') $fbPostType='T';
35
  if ($fbPostType=='A' || $fbPostType=='') {
36
- if (($attachType=='A' || $attachType=='S')) { $attArr = array('name' => $message['title'], 'caption' => $message['siteName'], 'link' =>$message['link'], 'description' => $message['description']); $mssg = array_merge($mssg, $attArr); ; }
37
- if ($attachType=='A') $mssg['actions'] = array(array('name' => $message['siteName'], 'link' =>$message['link']));
38
  if (trim($imgURL)!='') $mssg['picture'] = $imgURL; if (trim($message['videoURL'])!='') $mssg['source'] = $message['videoURL'];
39
  } elseif ($fbPostType=='I') { $facebook->setFileUploadSupport(true); $fbWhere = 'photos'; $mssg['url'] = $imgURL;
40
  if ($options['imgUpl']=='T') { //## Try to Post to TImeline
@@ -45,7 +54,7 @@ if (!class_exists("nxs_class_SNAP_FB")) { class nxs_class_SNAP_FB {
45
  if (isset($chosen_album) && isset($chosen_album["id"])) $page_id = $chosen_album["id"];
46
  }
47
  }
48
- //prr($message); prr($mssg); prr($options); //die();
49
  try { $ret = $facebook->api("/$page_id/".$fbWhere, "post", $mssg);} catch (NXS_FacebookApiException $e) { $badOut['Error'] = ' [ERROR] '.$e->getMessage()."<br/>\n";
50
  if (stripos($e->getMessage(),'This API call requires a valid app_id')!==false) {
51
  if ( !is_numeric($page_id) && stripos($options['fbURL'], '/groups/')!=false) $badOut['Error'] .= ' [ERROR] Unrecognized Facebook Group ID. Please use numeric ID.';
11
  foreach ($options as $ii=>$ntOpts) $out[$ii] = $this->doPostToNT($ntOpts, $message);
12
  return $out;
13
  }
14
+ function doPostToNT($options, $message){ require_once ('apis/facebook.php'); $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>''); // prr($message); // prr($options);
15
  //## Check settings
16
  if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
17
  if (!isset($options['fbAppAuthToken']) || trim($options['fbAppAuthToken'])=='') { $badOut['Error'] = 'No Auth Token Found'; return $badOut; }
24
  if (!isset($options['postType']) && isset($options['fbPostType'])) $options['postType'] = $options['fbPostType'];
25
  if (!isset($options['pgID']) && isset($options['fbPgID'])) $options['pgID'] = $options['fbPgID'];
26
 
27
+ //## Get URL info.
28
+ if ($fbPostType!='I' && $fbPostType!='T' && isset($options['useFBGURLInfo']) && $options['useFBGURLInfo']=='1') { $url = $message['url']; $params = array();
29
+ $flds = array('id'=>$url, 'scrape'=>'true'); $response = wp_remote_post('http://graph.facebook.com', array('body' => $flds));
30
+ if (is_wp_error($response)) $badOut['Error'] = print_r($response, true)." - ERROR"; else { $response = json_decode($response['body'], true); // prr($response); die();
31
+ if (trim($response['description']!='')) $message['urlDescr'] = $response['description']; if (trim($response['title']!='')) $message['urlTitle'] = $response['title'];
32
+ if (!empty($response['site_name'])) $message['siteName'] = $response['site_name']; elseif ($message['siteName']=='') $message['siteName'] = $message['title'];
33
+ if (!empty($response['image'][0]['url'])) $message['imageURL'] = $response['image'][0]['url'];
34
+ }
35
+ } // prr($message);
36
+ $msg = nxs_doFormatMsg($options['fbMsgFormat'], $message); $imgURL = $message['imageURL']; $fbPostType = $options['postType']; $fbWhere = 'feed';
37
  $attachType = $options['attachType']; if ($attachType=='1') $attachType = 'A'; else $attachType = 'S';
38
+ if ($options['imgUpl']!='2') $options['imgUpl'] = 'T'; else $options['imgUpl'] = 'A'; $page_id = $options['pgID'];
39
  $msg = strip_tags($msg); $msg = str_ireplace('&lt;(")','<(")', $msg); //## FB Smiles FIX 3
40
+ if (substr($msg, 0, 1)=='@') $msg = ' '.$msg; // ERROR] couldn't open file fix
41
+ $mssg = array('access_token' => $options['fbAppPageAuthToken'], 'message' => $msg); //prr($message);
42
 
43
  if ($fbPostType=='I' && trim($imgURL)=='') $fbPostType='T';
44
  if ($fbPostType=='A' || $fbPostType=='') {
45
+ if (($attachType=='A' || $attachType=='S')) { $attArr = array('name' => $message['urlTitle'], 'caption' => $message['siteName'], 'link' =>$message['url'], 'description' => $message['urlDescr']); $mssg = array_merge($mssg, $attArr); ; }
46
+ if ($attachType=='A') $mssg['actions'] = array(array('name' => $message['siteName'], 'link' =>$message['url']));
47
  if (trim($imgURL)!='') $mssg['picture'] = $imgURL; if (trim($message['videoURL'])!='') $mssg['source'] = $message['videoURL'];
48
  } elseif ($fbPostType=='I') { $facebook->setFileUploadSupport(true); $fbWhere = 'photos'; $mssg['url'] = $imgURL;
49
  if ($options['imgUpl']=='T') { //## Try to Post to TImeline
54
  if (isset($chosen_album) && isset($chosen_album["id"])) $page_id = $chosen_album["id"];
55
  }
56
  }
57
+ // prr($message); prr($mssg); prr($options); // die();
58
  try { $ret = $facebook->api("/$page_id/".$fbWhere, "post", $mssg);} catch (NXS_FacebookApiException $e) { $badOut['Error'] = ' [ERROR] '.$e->getMessage()."<br/>\n";
59
  if (stripos($e->getMessage(),'This API call requires a valid app_id')!==false) {
60
  if ( !is_numeric($page_id) && stripos($options['fbURL'], '/groups/')!=false) $badOut['Error'] .= ' [ERROR] Unrecognized Facebook Group ID. Please use numeric ID.';
inc-cl/fb.php CHANGED
@@ -43,7 +43,7 @@ if (!class_exists("nxs_snapClassFB")) { class nxs_snapClassFB {
43
  <div class="nxs_box">
44
  <div class="nxs_box_header">
45
  <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']; ?>
46
- <?php $cbo = count($ntOpts); ?> <?php wp_nonce_field( 'ns'.$ntInfo['code'], 'ns'.$ntInfo['code'].'_wpnonce' ); ?>
47
  <?php if ($cbo>1){ ?><div class="nsBigText"><?php echo "(".($cbo=='0'?'No':$cbo)." "; _e('accounts', 'nxs_snap'); echo ")"; ?></div><?php } ?>
48
  </div>
49
  </div>
@@ -51,11 +51,13 @@ if (!class_exists("nxs_snapClassFB")) { class nxs_snapClassFB {
51
  <?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = str_ireplace('https://www.facebook.com','', str_ireplace('http://www.facebook.com','', $pbo['fbURL']));
52
  if (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='') $pbo[$ntInfo['lcode'].'OK'] = (isset($pbo['fbAppAuthUser']) && $pbo['fbAppAuthUser']>1)?'1':''; ?>
53
  <p style="margin:0px;margin-left:5px;">
54
- <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> /> <?php if ((int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
 
 
55
  <strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
56
  &nbsp;&nbsp;<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention required. Unfinished setup', 'nxs_snap'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>&nbsp;&nbsp;
57
  <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
58
- </p><?php $this->showNTSettings($indx, $pbo);
59
  }?>
60
  </div>
61
  </div> <?php
@@ -63,15 +65,17 @@ if (!class_exists("nxs_snapClassFB")) { class nxs_snapClassFB {
63
 
64
  }
65
  //#### Show NEW Settings Page
66
- function showNewNTSettings($mfbo){ $fbo = array('nName'=>'', 'doFB'=>'1', 'fbURL'=>'', 'fbAppID'=>'', 'imgUpl'=>'1', 'fbPostType'=>'A', 'fbMsgAFormat'=>'', 'fbAppSec'=>'', 'fbAttch'=>'1', 'fbPgID'=>'', 'fbAppAuthUser'=>'', 'fbMsgFormat'=>__('New post (%TITLE%) has been published on %SITENAME%', 'nxs_snap') ); $this->showNTSettings($mfbo, $fbo, true);}
67
  //#### Show Unit Settings
68
- function showNTSettings($ii, $fbo, $isNew=false){ global $nxs_plurl, $nxs_snapThisPageUrl, $plgn_NS_SNAutoPoster; if ((int)$fbo['fbAttch']==0 && (!isset($fbo['trPostType']) || $fbo['trPostType']=='')) $fbo['trPostType'] = 'T';
 
69
  if (!isset($plgn_NS_SNAutoPoster)) return; $gOptions = $plgn_NS_SNAutoPoster->nxs_options;
70
- if (!isset($fbo['nHrs'])) $fbo['nHrs'] = 0; if (!isset($fbo['nMin'])) $fbo['nMin'] = 0; if (!isset($fbo['catSel'])) $fbo['catSel'] = 0; if (!isset($fbo['catSelEd'])) $fbo['catSelEd'] = '';
71
- if (!isset($fbo['nDays'])) $fbo['nDays'] = 0; if (!isset($fbo['qTLng'])) $fbo['qTLng'] = ''; if (!isset($fbo['fbMsgAFrmt'])) $fbo['fbMsgAFrmt'] = '';
72
- if (!isset($fbo['riComments'])) $fbo['riComments'] = ''; if (!isset($fbo['riCommentsAA'])) $fbo['riCommentsAA'] = '';
 
73
  ?>
74
- <div id="doFB<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>" style="background-image: url(<?php echo $nxs_plurl; ?>img/fb-bg.png); background-position:90% 10%;"> <input type="hidden" name="apDoSFB<?php echo $ii; ?>" value="0" id="apDoSFB<?php echo $ii; ?>" />
75
  <?php if ($isNew) { ?> <input type="hidden" name="fb[<?php echo $ii; ?>][apDoFB]" value="1" id="apDoNewFB<?php echo $ii; ?>" /> <?php } ?>
76
 
77
  <div class="nsx_iconedTitle" style="float: right; max-width: 322px; text-align: right; background-image: url(<?php echo $nxs_plurl; ?>img/fb16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-facebook-social-networks-auto-poster-wordpress/"><?php $nType="Facebook"; printf( __( 'Detailed %s Installation/Configuration Instructions', 'nxs_snap' ), $nType); ?></a><br/>
@@ -79,72 +83,62 @@ if (!class_exists("nxs_snapClassFB")) { class nxs_snapClassFB {
79
 
80
  </div>
81
 
82
- <div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easely identify it', 'nxs_snap'); ?></i> </div><input name="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($fbo['nName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /><br/>
83
- <?php echo nxs_addQTranslSel('fb', $ii, $fbo['qTLng']); ?>
84
- <?php echo nxs_addPostingDelaySel('fb', $ii, $fbo['nHrs'], $fbo['nMin'], $fbo['nDays']); ?>
85
 
86
- <?php if (!$isNew) { ?>
87
- <div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
88
- <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="fb[<?php echo $ii; ?>][catSel]" <?php if ((int)$fbo['catSel'] != 1) echo "checked"; ?> /> All
89
- <input value="1" id="catSelSFB<?php echo $ii; ?>" type="radio" name="fb[<?php echo $ii; ?>][catSel]" <?php if ((int)$fbo['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_FB<?php echo $ii; ?>" onclick="jQuery('#catSelSFB<?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('FB<?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_FB<?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($fbo['catSelEd']!='') echo "[".(substr_count($fbo['catSelEd'], ",")+1)."]"; ?></a>
90
- <input type="hidden" name="fb[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_FB<?php echo $ii; ?>" value="<?php echo $fbo['catSelEd']; ?>" />
91
- <br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
92
- <br/>
93
- <?php } ?>
94
- <div style="width:100%;"><strong style="font-size: 16px;">Facebook Settings:</strong> </div>
95
 
96
  <div style="width:100%;"><strong>Facebook URL:</strong> </div>
97
  <p style="font-size: 11px; margin: 0px;"><?php _e('Could be your Facebook Profile, Facebook Page, Facebook Group', 'nxs_snap'); ?></p>
98
- <input name="fb[<?php echo $ii; ?>][apFBURL]" id="apFBURL" style="width: 50%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($fbo['fbURL'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
99
- <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($fbo['fbAppID'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
100
- <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($fbo['fbAppSec'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /><br/><br/>
101
  <div id="altFormat">
102
  <div style="width:100%;"><strong id="altFormatText"><?php _e('Message text Format', 'nxs_snap'); ?>:</strong> (<a href="#" id="apFBMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apFBMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)</div>
103
 
104
- <textarea cols="150" rows="3" id="fb<?php echo $ii; ?>SNAPformat" name="fb[<?php echo $ii; ?>][apFBMsgFrmt]" style="width:51%;max-width: 610px;" onfocus="jQuery('#fb<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('apFBMsgFrmt<?php echo $ii; ?>');"><?php _e(apply_filters('format_to_edit', htmlentities($fbo['fbMsgFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?></textarea> <?php nxs_doShowHint("apFBMsgFrmt".$ii); ?>
105
  <br/>
106
  </div><br/>
107
  <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?', 'nxs_snap'); ?></a>) </div>
108
  <div style="margin-left: 10px;">
109
 
110
- <input type="radio" name="fb[<?php echo $ii; ?>][fbPostType]" value="T" <?php if ($fbo['fbPostType'] == 'T') echo 'checked="checked"'; ?> /> <?php _e('Text Post', 'nxs_snap'); ?> - <i><?php _e('just text message', 'nxs_snap'); ?></i><br/>
111
 
112
- <input type="radio" name="fb[<?php echo $ii; ?>][fbPostType]" value="I" <?php if ($fbo['fbPostType'] == 'I') echo 'checked="checked"'; ?> /> <?php _e('Image Post', 'nxs_snap'); ?> - <i><?php _e('big image with text message', 'nxs_snap'); ?></i><br/>
113
  <div style="width:100%; margin-left: 15px;"><strong><?php _e('Upload Images to', 'nxs_snap'); ?>:&nbsp;</strong>
114
- <input value="2" id="apFBImgUplAPP<?php echo $ii; ?>" type="radio" name="fb[<?php echo $ii; ?>][apFBImgUpl]" <?php if ((int)$fbo['imgUpl'] == 2) echo "checked"; ?> /> <?php _e('App Album', 'nxs_snap'); ?> .. <?php _e('or', 'nxs_snap'); ?> ..
115
- <input value="1" id="apFBImgUplTML<?php echo $ii; ?>" type="radio" name="fb[<?php echo $ii; ?>][apFBImgUpl]" <?php if ((int)$fbo['imgUpl'] != 2) echo "checked"; ?> />
116
  <?php _e('Timeline', 'nxs_snap'); ?> &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?', 'nxs_snap'); ?></a>)
117
  </div>
118
 
119
- <input type="radio" name="fb[<?php echo $ii; ?>][fbPostType]" value="A" <?php if ( !isset($fbo['fbPostType']) || $fbo['fbPostType'] == '' || $fbo['fbPostType'] == 'A') echo 'checked="checked"'; ?> /> <?php _e('Text Post with "attached" link', 'nxs_snap'); ?><br/>
120
 
121
- <div style="width:100%; margin-left: 15px;"><strong><?php _e('Link attachment type', 'nxs_snap'); ?>:&nbsp;</strong> <input value="2" id="apFBAttchShare<?php echo $ii; ?>" type="radio" name="fb[<?php echo $ii; ?>][apFBAttch]" <?php if ((int)$fbo['fbAttch'] == 2) echo "checked"; ?> />
122
  <?php _e('Share a link to your blogpost', 'nxs_snap'); ?> .. <?php _e('or', 'nxs_snap'); ?> ..
123
- <input value="1" id="apFBAttch<?php echo $ii; ?>" type="radio" name="fb[<?php echo $ii; ?>][apFBAttch]" <?php if ((int)$fbo['fbAttch'] == 1) echo "checked"; ?> />
124
  <?php _e('Attach your blogpost', 'nxs_snap'); ?> &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?', 'nxs_snap'); ?></a>)
125
- <div style="margin-bottom: 5px; margin-left: 10px; "><input value="1" id="apFBAttchAsVid" type="checkbox" name="fb[<?php echo $ii; ?>][apFBAttchAsVid]" <?php if (isset($fbo['fbAttchAsVid']) && (int)$fbo['fbAttchAsVid'] == 1) echo "checked"; ?> /> <strong><?php _e('If post has video use it as an attachment thumbnail.', 'nxs_snap'); ?></strong> <i><?php _e('Video will be used for an attachment thumbnail instead of featured image. Only Youtube is supported at this time.', 'nxs_snap'); ?></i>
126
  <br/></div>
127
- <strong><?php _e('Attachment Text Format', 'nxs_snap'); ?>:</strong><br/>
128
- <input value="1" id="apFBMsgAFrmtA<?php echo $ii; ?>" <?php if (trim($fbo['fbMsgAFrmt'])=='') echo "checked"; ?> onchange="if (jQuery(this).is(':checked')) { jQuery('#apFBMsgAFrmtDiv<?php echo $ii; ?>').hide(); jQuery('#apFBMsgAFrmt<?php echo $ii; ?>').val(''); }else jQuery('#apFBMsgAFrmtDiv<?php echo $ii; ?>').show();" type="checkbox" name="fb[<?php echo $ii; ?>][apFBMsgAFrmtA]"/> <strong><?php _e('Auto', 'nxs_snap'); ?></strong>
 
 
 
 
 
 
129
  <i> - <?php _e('Recommended. Info from SEO Plugins will be used, then post excerpt, then post text', 'nxs_snap'); ?> </i><br/>
130
- <div id="apFBMsgAFrmtDiv<?php echo $ii; ?>" style="<?php if ($fbo['fbMsgAFrmt']=='') echo "display:none;"; ?>" >&nbsp;&nbsp;&nbsp; <?php _e('Set your own format', 'nxs_snap'); ?>:<input name="fb[<?php echo $ii; ?>][apFBMsgAFrmt]" id="apFBMsgAFrmt<?php echo $ii; ?>" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($fbo['fbMsgAFrmt'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /><br/></div>
131
- </div><br/>
132
- </div>
133
- <div style="width:100%;"><strong style="font-size: 16px;"><?php _e('Facebook Comments:', 'nxs_snap'); ?></strong> </div>
134
- <div style="margin-bottom: 5px; margin-left: 10px; ">
135
- <p style="font-size: 11px; margin: 0px;"><?php _e('Plugin could grab comments from Facebook and import them as Wordpress Comments', 'nxs_snap'); ?></p>
136
-
137
- <?php if ( $gOptions['riActive'] == '1' ) { ?>
138
- <input value="1" id="apFBMsgAFrmtA<?php echo $ii; ?>" <?php if (trim($fbo['riComments'])=='1') echo "checked"; ?> type="checkbox" name="fb[<?php echo $ii; ?>][riComments]"/> <strong><?php _e('Import Facebook Comments', 'nxs_snap'); ?></strong>
139
- <br/>
140
- <div style="margin-bottom: 5px; margin-left: 10px; ">
141
- <input value="1" id="apFBMsgAFrmtA<?php echo $ii; ?>" <?php if (trim($fbo['riCommentsAA'])=='1') echo "checked"; ?> type="checkbox" name="fb[<?php echo $ii; ?>][riCommentsAA]"/> <strong><?php _e('Auto-approve imported comments', 'nxs_snap'); ?></strong></div>
142
-
143
- <?php } else { echo "<br/>"; _e('Please activate the "Comments Import" from SNAP Settings - Other Settings', 'nxs_snap'); } ?>
144
-
145
- </div>
146
-
147
- <br/><br/>
148
 
149
  <div class="popShAtt" style="z-index: 9999; width: 350px;" id="popShAtt<?php echo $ii; ?>I"><h3><?php _e('Where to upload Images', 'nxs_snap'); ?></h3> <b><?php _e('(App Album)', 'nxs_snap'); ?></b> <?php _e('Facebook automatically creates an album for your app. Images will be grouped there as in any regular album.', 'nxs_snap'); ?> <br/><br/><b><?php _e('(Timeline)', 'nxs_snap'); ?></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.', 'nxs_snap'); ?></div>
150
  <div class="popShAtt" style="z-index: 9999" id="popShAtt<?php echo $ii; ?>"><h3><?php _e('Two ways of attaching post on Facebook', 'nxs_snap'); ?></h3><img src="<?php echo $nxs_plurl; ?>img/fb2wops.png" width="600" height="257" alt="<?php _e('Two ways of attaching post on Facebook', 'nxs_snap'); ?>"/></div>
@@ -153,23 +147,59 @@ if (!class_exists("nxs_snapClassFB")) { class nxs_snapClassFB {
153
 
154
 
155
 
156
- <?php if ($fbo['fbPgID']!='') {?><div style="width:100%;"><strong>Facebook Page ID:</strong> <?php _e(apply_filters('format_to_edit', htmlentities($fbo['fbPgID'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?> </div><?php } ?>
157
  <?php
158
- if($fbo['fbAppSec']=='') { ?>
159
  <b><?php _e('Authorize Your Facebook Account', 'nxs_snap'); ?></b> <?php _e('Please click "Update Settings" to be able to Authorize your account.', 'nxs_snap'); ?>
160
- <?php } else { if(isset($fbo['fbAppAuthUser']) && $fbo['fbAppAuthUser']>0) { ?>
161
- <?php _e('Your Facebook Account has been authorized.', 'nxs_snap'); ?> User ID: <?php _e(apply_filters('format_to_edit', htmlentities($fbo['fbAppAuthUser'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>.
162
  <?php _e('You can', 'nxs_snap'); ?> Re- <?php } ?>
163
- <a href="https://www.facebook.com/dialog/oauth?client_id=<?php echo trim($fbo['fbAppID']);?>&client_secret=<?php echo trim($fbo['fbAppSec']);?>&scope=publish_stream,user_photos,photo_upload,friends_photos,offline_access,read_stream,manage_pages,user_groups,friends_groups&redirect_uri=<?php echo trim(urlencode($nxs_snapThisPageUrl.'&auth=fb&acc='.$ii));?>">Authorize Your Facebook Account</a>
164
- <?php if (!isset($fbo['fbAppAuthUser']) || $fbo['fbAppAuthUser']<1) { ?> <div class="blnkg">&lt;=== <?php _e('Authorize your account', 'nxs_snap'); ?> ===</div>
165
  <br/><br/><i> <?php _e('If you get Facebook message:', 'nxs_snap'); ?> <b>"Error. An error occurred. Please try again later."</b> or <b>"Error 191"</b> <?php _e('please make sure that domain name in your Facebook App matches your website domain exactly. Please note that www. and non www. versions are different domains.', 'nxs_snap'); ?></i> <?php }?>
166
  <?php } ?>
167
 
168
- <?php if(isset($fbo['fbAppAuthUser']) && $fbo['fbAppAuthUser']>0) { ?>
169
- <?php wp_nonce_field( 'rePostToFB', 'rePostToFB_wpnonce' ); ?>
170
  <br/><br/><b><?php _e('Test your settings', 'nxs_snap'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('FB','<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'nxs_snap' ), $nType); ?></a>
171
  <?php }?>
172
- <div class="submit"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
173
 
174
  </div>
175
  <?php
@@ -196,11 +226,16 @@ if (!class_exists("nxs_snapClassFB")) { class nxs_snapClassFB {
196
  if (isset($pval['apFBMsgFrmt'])) $options[$ii]['fbMsgFormat'] = trim($pval['apFBMsgFrmt']);
197
  if (isset($pval['apFBMsgAFrmt'])) $options[$ii]['fbMsgAFrmt'] = trim($pval['apFBMsgAFrmt']);
198
 
 
 
199
  if (isset($pval['riComments'])) $options[$ii]['riComments'] = $pval['riComments']; else $options[$ii]['riComments'] = 0;
200
  if (isset($pval['riCommentsAA'])) $options[$ii]['riCommentsAA'] = $pval['riCommentsAA']; else $options[$ii]['riCommentsAA'] = 0;
201
 
202
- if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']);
 
 
203
  if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
 
204
  if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
205
 
206
  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'];
@@ -213,9 +248,10 @@ if (!class_exists("nxs_snapClassFB")) { class nxs_snapClassFB {
213
  } return $options;
214
  }
215
  //#### Show Post->Edit Meta Box Settings
216
- function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
217
- foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapFB', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
218
- $doFB = $ntOpt['doFB'] && (is_array($pMeta) || $ntOpt['catSel']!='1');
 
219
  $isAvailFB = $ntOpt['fbURL']!='' && $ntOpt['fbAppID']!='' && $ntOpt['fbAppSec']!=''; $isAttachFB = $ntOpt['fbAttch']; $fbMsgFormat = htmlentities($ntOpt['fbMsgFormat'], ENT_COMPAT, "UTF-8"); $fbPostType = $ntOpt['fbPostType'];
220
  ?>
221
 
@@ -232,9 +268,9 @@ if (!class_exists("nxs_snapClassFB")) { class nxs_snapClassFB {
232
  <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', 'nxs_snap') ?>" />
233
  <?php } ?>
234
 
235
- <?php wp_nonce_field( 'rePostToFB', 'rePostToFB_wpnonce' ); } ?>
236
 
237
- <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) && strpos($pMeta[$ii]['pgID'],'_')!==false ) { $pid = explode('_', $pMeta[$ii]['pgID']);
238
 
239
  ?> <span id="pstdFB<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
240
  <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', 'nxs_snap' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
@@ -242,7 +278,15 @@ if (!class_exists("nxs_snapClassFB")) { class nxs_snapClassFB {
242
 
243
  </td></tr>
244
  <?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>
245
- <?php } elseif ($post->post_status != "puZblish") {?>
 
 
 
 
 
 
 
 
246
 
247
  <tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;">
248
 
@@ -266,11 +310,8 @@ if (!class_exists("nxs_snapClassFB")) { class nxs_snapClassFB {
266
  <div class="popShAtt" id="popShAtt<?php echo $ii; ?>"><h3><?php _e('Two ways of attaching post on Facebook', 'nxs_snap'); ?></h3> <img src="<?php echo $nxs_plurl; ?>img/fb2wops.png" width="600" height="257" alt="<?php _e('Two ways of attaching post on Facebook', 'nxs_snap'); ?>"/></div>
267
  <div class="popShAtt" id="popShAtt<?php echo $ii; ?>X"><h3><?php _e('Facebook Post Types', 'nxs_snap'); ?></h3><img src="<?php echo $nxs_plurl; ?>img/fbPostTypesDiff6.png" width="600" height="398" alt="<?php _e('Facebook Post Types', 'nxs_snap'); ?>"/></div>
268
  </td></tr>
269
- <!--
270
- <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Image(s) to use:', 'nxs_snap') ?></th>
271
- <td><input type="checkbox" class="isAutoImg" checked="checked" id="isAutoImg-fb<?php echo $ii; ?>" name="fb[<?php echo $ii; ?>][isAutoImg]" value="A"/> <?php _e('Auto', 'nxs_snap'); ?><br/>
272
- <div id="imgPrevList-fb<?php echo $ii; ?>" class="nxs_imgPrevList"></div></td></tr>
273
- -->
274
  <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Message Format:', 'nxs_snap') ?></th>
275
  <td>
276
  <?php if (1==1) { ?>
@@ -279,14 +320,16 @@ if (!class_exists("nxs_snapClassFB")) { class nxs_snapClassFB {
279
  <input value="<?php echo $fbMsgFormat ?>" type="text" name="fb[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apFBTMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apFBTMsgFrmt".$ii, '', '58'); ?>
280
  <?php } ?>
281
  </td></tr>
282
-
283
- <?php }
284
  }
285
 
286
  }
287
 
288
  function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
289
- if (isset($pMeta['SNAPformat'])) $optMt['fbMsgFormat'] = $pMeta['SNAPformat'];
 
 
290
  if (isset($pMeta['AttachPost'])) $optMt['fbAttch'] = ($pMeta['AttachPost'] != '')?$pMeta['AttachPost']:0; else { if (isset($pMeta['SNAPformat'])) $optMt['fbAttch'] = 0; }
291
  if (isset($pMeta['PostType'])) $optMt['fbPostType'] = ($pMeta['PostType'] != '')?$pMeta['PostType']:0; else { if (isset($pMeta['SNAPformat'])) $optMt['fbPostType'] = 'T'; }
292
  if (isset($pMeta['doFB'])) $optMt['doFB'] = $pMeta['doFB'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doFB'] = 0; }
@@ -295,17 +338,8 @@ if (!class_exists("nxs_snapClassFB")) { class nxs_snapClassFB {
295
  }
296
  }}
297
 
298
- // ShortCode [nxs_fbembed accnum=0]
299
- 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);
300
- if (!is_array($fbpo) || !is_array($fbpo[$accnum]) || !isset($fbpo[$accnum]['pgID']) || strpos($fbpo[$accnum]['pgID'], '_')===false ) return; $fbpo = $fbpo[$accnum]['pgID'];
301
- $fbpoA = explode('_',$fbpo); $fpg = $fbpoA[0]; $fpid = $fbpoA[1];
302
- $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>
303
- <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>';
304
- return $txtOut;
305
- }
306
- add_shortcode( 'nxs_fbembed', 'nxs_fbembed_func' );
307
-
308
- if (!function_exists("nxs_getBackFBComments")) { function nxs_getBackFBComments($postID, $options, $po) { require_once ('apis/facebook.php'); $opts = array('access_token' => $options['fbAppPageAuthToken']);
309
  $facebook = new NXS_Facebook(array( 'appId' => $options['fbAppID'], 'secret' => $options['fbAppSec'], 'cookie' => true )); $ci = 0;
310
  $ret = $facebook->api($po['pgID']."/comments?filter=toplevel", "GET", $opts);
311
  $impCmnts = get_post_meta($postID, 'snapImportedFBComments', true); if (!is_array($impCmnts)) $impCmnts = array(); //prr($impCmnts);
@@ -329,14 +363,24 @@ if (!function_exists("nxs_getBackFBComments")) { function nxs_getBackFBComments(
329
  }
330
  delete_post_meta($postID, 'snapImportedFBComments'); add_post_meta($postID, 'snapImportedFBComments', $impCmnts );
331
  //## if Importing manually from Button echo result.
332
- if ($_POST['id']!='') printf( _n( '%d comment has been imported.', '%d comments has been imported.', $ci, 'nxs_snap'), $ci );
333
  }}
334
 
335
- if (!function_exists("nxs_rePostToFB_ajax")) { function nxs_rePostToFB_ajax() { check_ajax_referer('rePostToFB'); $postID = $_POST['id']; // $result = nsPublishTo($id, 'FB', true);
 
 
 
 
 
 
 
 
 
 
336
  $options = get_option('NS_SNAutoPoster'); foreach ($options['fb'] as $ii=>$fbo) if ($ii==$_POST['nid']) { $fbo['ii'] = $ii; $fbo['pType'] = 'aj';
337
  $fbpo = get_post_meta($postID, 'snapFB', true); /* echo $postID."|"; echo $fbpo; */ $fbpo = maybe_unserialize($fbpo); // prr($fbpo);
338
  if (is_array($fbpo) && isset($fbpo[$ii]) && is_array($fbpo[$ii]) ){ $ntClInst = new nxs_snapClassFB(); $fbo = $ntClInst->adjMetaOpt($fbo, $fbpo[$ii]); } //prr($fbo);
339
- if ($_POST['ri']=='1') { nxs_getBackFBComments($postID, $fbo, $fbpo[$ii]); die(); } else {
340
  $result = nxs_doPublishToFB($postID, $fbo); if ($result == '200') die("Your post has been successfully sent to FaceBook."); else die($result);
341
  }
342
  }
@@ -344,7 +388,8 @@ if (!function_exists("nxs_rePostToFB_ajax")) { function nxs_rePostToFB_ajax() {
344
  }
345
 
346
  if (!function_exists("nxs_doPublishToFB")) { //## Second Function to Post to FB
347
- function nxs_doPublishToFB($postID, $options){ global $ShownAds; $ntCd = 'FB'; $ntCdL = 'fb'; $ntNm = 'Facebook'; $dsc = '';
 
348
  if (!class_exists('nxs_class_SNAP_FB')) { nxs_addToLogN('E', 'Error', $ntCd, '-=ERROR=- No Facebook API Lib Detected', ''); return "No Facebook API Lib Detected";}
349
 
350
  $fbWhere = 'feed'; $page_id = $options['fbPgID']; if (isset($ShownAds)) $ShownAdsL = $ShownAds; $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'POSTID'=>$postID, 'ACCNAME'=>$options['nName']));
@@ -363,14 +408,15 @@ if (!function_exists("nxs_doPublishToFB")) { //## Second Function to Post to FB
363
  //## Initiate Posting Array
364
  $message = array('message'=>'', 'link'=>'', 'title'=>'', 'description'=>'', 'imageURL'=>'', 'videoURL'=>'', 'siteName'=>$blogTitle);
365
 
366
- if ($postID=='0') { $message['message'] = 'Test Post, Please Ignore';
367
- $message['description'] = 'Test Post, Description'; $message['title'] = 'Test Post - Title'; $message['link'] = home_url();
368
  } else { $post = get_post($postID); if(!$post) return; $msg = nsFormatMessage($options['fbMsgFormat'], $postID, $addParams);
369
- $isAttachFB = $options['fbAttch']; $fbPostType = $options['fbPostType']; $isAttachVidFB = $options['fbAttchAsVid'];
370
- nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1')); $extInfo = ' | PostID: '.$postID." - ".nxs_doQTrans($post->post_title, $lng).' |'.$options['pType'];
371
- if (($isAttachFB=='1' || $isAttachFB=='2' || $fbPostType=='A')) $imgURL = nxs_getPostImage($postID, 'medium'); // prr($options); echo "PP - ".$postID; prr($src);
372
- if ($fbPostType=='I') $imgURL = nxs_getPostImage($postID, 'full'); // prr($options); echo "PP - ".$postID; prr($src);
373
- if (($isAttachFB=='1' || $fbPostType=='A' || $fbPostType=='S')){
 
374
  //## AUTO - Get Post Descr from SEO Plugins or make it.
375
  if (trim($options['fbMsgAFrmt'])!='') {$dsc = nsFormatMessage($options['fbMsgAFrmt'], $postID, $addParams);} else { if (function_exists('aioseop_mrt_fix_meta') && $dsc=='') $dsc = trim(get_post_meta($postID, '_aioseop_description', true));
376
  if (function_exists('wpseo_admin_init') && $dsc=='') $dsc = trim(get_post_meta($postID, '_yoast_wpseo_opengraph-description', true));
@@ -385,7 +431,7 @@ if (!function_exists("nxs_doPublishToFB")) { //## Second Function to Post to FB
385
  $msg = str_replace('<br>', "\n", $msg); $msg = str_replace('<br/>', "\n", $msg); $msg = str_replace('<br />', "\n", $msg);
386
  $msg = str_ireplace('<3','&lt;3', $msg); $msg = str_ireplace('<(','&lt;(', $msg); //## FB Smiles FIX.
387
  $msg = strip_tags($msg); $msg = nxs_decodeEntitiesFull($msg);
388
- $msg = str_ireplace('&#39;',"'", $msg); $msg = str_ireplace('<3','&lt;3', $msg); $msg = str_ireplace('<(','&lt;(', $msg); //## FB Smiles FIX 2.
389
 
390
  if ($isAttachVidFB=='1') {$vids = nsFindVidsInPost($post, false); if (count($vids)>0) {
391
  if (strlen($vids[0])==11) { $vidURL = 'http://www.youtube.com/v/'.$vids[0]; $imgURL = nsGetYTThumb($vids[0]); }
@@ -394,14 +440,18 @@ if (!function_exists("nxs_doPublishToFB")) { //## Second Function to Post to FB
394
  if (!is_wp_error($json)) { $json = $json['body']; $json = str_replace('showThumb(','',$json); $json = str_replace('])',']',$json); $json = json_decode($json, true); $imgURL = $json[0]['thumbnail_large']; }
395
  }
396
  }}
 
 
397
  //## MyURL - URLToGo code
398
  if (!isset($options['urlToUse']) || trim($options['urlToUse'])=='') $myurl = trim(get_post_meta($postID, 'snap_MYURL', true)); if ($myurl!='') $options['urlToUse'] = $myurl;
399
- if (isset($options['urlToUse']) && trim($options['urlToUse'])!='') { $urlToGo = $options['urlToUse']; $options['useFBGURLInfo'] = true; } else $urlToGo = get_permalink($postID);
400
  if($addParams!='') $urlToGo .= (strpos($urlToGo,'?')!==false?'&':'?').$addParams;
401
-
402
- $message = array('message'=>$msg, 'link'=>$urlToGo, 'title'=>nxs_doQTrans($post->post_title, $lng), 'description'=>$dsc, 'imageURL'=>$imgURL, 'videoURL'=>$vidURL, 'siteName'=>$blogTitle);
403
  } // prr($mssg); // prr($options); // prr($facebook); echo "/$page_id/feed";
404
- if (isset($ShownAds)) $ShownAds = $ShownAdsL; // FIX for the quick-adsense plugin
 
 
405
 
406
  //## Actual Post
407
  $ntToPost = new nxs_class_SNAP_FB(); $ret = $ntToPost->doPostToNT($options, $message);
43
  <div class="nxs_box">
44
  <div class="nxs_box_header">
45
  <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']; ?>
46
+ <?php $cbo = count($ntOpts); ?>
47
  <?php if ($cbo>1){ ?><div class="nsBigText"><?php echo "(".($cbo=='0'?'No':$cbo)." "; _e('accounts', 'nxs_snap'); echo ")"; ?></div><?php } ?>
48
  </div>
49
  </div>
51
  <?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = str_ireplace('https://www.facebook.com','', str_ireplace('http://www.facebook.com','', $pbo['fbURL']));
52
  if (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='') $pbo[$ntInfo['lcode'].'OK'] = (isset($pbo['fbAppAuthUser']) && $pbo['fbAppAuthUser']>1)?'1':''; ?>
53
  <p style="margin:0px;margin-left:5px;">
54
+ <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> />
55
+ <?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 } ?>
56
+ <?php if (isset($pbo['rpstOn']) && (int)$pbo['rpstOn'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popReActive');" onmouseover="nxs_showPopUpInfo('popReActive', event);"><?php echo "*[R]*" ?></span><?php } ?>
57
  <strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
58
  &nbsp;&nbsp;<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention required. Unfinished setup', 'nxs_snap'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>&nbsp;&nbsp;
59
  <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
60
+ </p><?php $pbo['ntInfo'] = $ntInfo; $this->showNTSettings($indx, $pbo);
61
  }?>
62
  </div>
63
  </div> <?php
65
 
66
  }
67
  //#### Show NEW Settings Page
68
+ function showNewNTSettings($mfbo){ $fbo = array('nName'=>'', 'doFB'=>'1', 'fbURL'=>'', 'fbAppID'=>'', 'imgUpl'=>'1', 'fbPostType'=>'A', 'fbMsgAFormat'=>'', 'fbAppSec'=>'', 'fbAttch'=>'1', 'fbPgID'=>'', 'fbAppAuthUser'=>'', 'fbMsgFormat'=>__('New post (%TITLE%) has been published on %SITENAME%', 'nxs_snap') ); $fbo['ntInfo']= array('lcode'=>'fb'); $this->showNTSettings($mfbo, $fbo, true);}
69
  //#### Show Unit Settings
70
+ function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl, $nxs_snapThisPageUrl, $plgn_NS_SNAutoPoster; $nt = $options['ntInfo']['lcode']; $ntU = strtoupper($nt); $tmzFrmt = _x('Y-m-d G:i:s', 'timezone date format');
71
+ if ((int)$options['fbAttch']==0 && (!isset($options['trPostType']) || $options['trPostType']=='')) $options['trPostType'] = 'T';
72
  if (!isset($plgn_NS_SNAutoPoster)) return; $gOptions = $plgn_NS_SNAutoPoster->nxs_options;
73
+ 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'] = '';
74
+ if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; if (!isset($options['fbMsgAFrmt'])) $options['fbMsgAFrmt'] = '';
75
+ if (!isset($options['riComments'])) $options['riComments'] = ''; if (!isset($options['riCommentsAA'])) $options['riCommentsAA'] = '';
76
+ if (!isset($options['useFBGURLInfo'])) $options['useFBGURLInfo'] = '';
77
  ?>
78
+ <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; ?>" />
79
  <?php if ($isNew) { ?> <input type="hidden" name="fb[<?php echo $ii; ?>][apDoFB]" value="1" id="apDoNewFB<?php echo $ii; ?>" /> <?php } ?>
80
 
81
  <div class="nsx_iconedTitle" style="float: right; max-width: 322px; text-align: right; background-image: url(<?php echo $nxs_plurl; ?>img/fb16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-facebook-social-networks-auto-poster-wordpress/"><?php $nType="Facebook"; printf( __( 'Detailed %s Installation/Configuration Instructions', 'nxs_snap' ), $nType); ?></a><br/>
83
 
84
  </div>
85
 
86
+ <div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'nxs_snap'); ?></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")), 'nxs_snap') ?>" /><br/>
87
+ <?php echo nxs_addQTranslSel('fb', $ii, $options['qTLng']); ?>
 
88
 
89
+
90
+ <ul class="nsx_tabs">
91
+ <li><a href="#nsx<?php echo $nt.$ii ?>_tab1"><?php _e('Account Info', 'nxs_snap'); ?></a></li>
92
+ <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'nxs_snap'); ?></a></li>
93
+ </ul>
94
+ <div class="nsx_tab_container"><?php /* ######################## Account Tab ####################### */ ?>
95
+ <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%;">
 
 
96
 
97
  <div style="width:100%;"><strong>Facebook URL:</strong> </div>
98
  <p style="font-size: 11px; margin: 0px;"><?php _e('Could be your Facebook Profile, Facebook Page, Facebook Group', 'nxs_snap'); ?></p>
99
+ <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")), 'nxs_snap') ?>" />
100
+ <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")), 'nxs_snap') ?>" />
101
+ <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")), 'nxs_snap') ?>" /><br/><br/>
102
  <div id="altFormat">
103
  <div style="width:100%;"><strong id="altFormatText"><?php _e('Message text Format', 'nxs_snap'); ?>:</strong> (<a href="#" id="apFBMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apFBMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)</div>
104
 
105
+ <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")), 'nxs_snap') ?></textarea> <?php nxs_doShowHint("apFBMsgFrmt".$ii); ?>
106
  <br/>
107
  </div><br/>
108
  <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?', 'nxs_snap'); ?></a>) </div>
109
  <div style="margin-left: 10px;">
110
 
111
+ <input type="radio" name="fb[<?php echo $ii; ?>][fbPostType]" value="T" <?php if ($options['fbPostType'] == 'T') echo 'checked="checked"'; ?> /> <?php _e('Text Post', 'nxs_snap'); ?> - <i><?php _e('just text message', 'nxs_snap'); ?></i><br/>
112
 
113
+ <input type="radio" name="fb[<?php echo $ii; ?>][fbPostType]" value="I" <?php if ($options['fbPostType'] == 'I') echo 'checked="checked"'; ?> /> <?php _e('Image Post', 'nxs_snap'); ?> - <i><?php _e('big image with text message', 'nxs_snap'); ?></i><br/>
114
  <div style="width:100%; margin-left: 15px;"><strong><?php _e('Upload Images to', 'nxs_snap'); ?>:&nbsp;</strong>
115
+ <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', 'nxs_snap'); ?> .. <?php _e('or', 'nxs_snap'); ?> ..
116
+ <input value="1" id="apFBImgUplTML<?php echo $ii; ?>" type="radio" name="fb[<?php echo $ii; ?>][apFBImgUpl]" <?php if ((int)$options['imgUpl'] != 2) echo "checked"; ?> />
117
  <?php _e('Timeline', 'nxs_snap'); ?> &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?', 'nxs_snap'); ?></a>)
118
  </div>
119
 
120
+ <input type="radio" name="fb[<?php echo $ii; ?>][fbPostType]" value="A" <?php if ( !isset($options['fbPostType']) || $options['fbPostType'] == '' || $options['fbPostType'] == 'A') echo 'checked="checked"'; ?> /> <?php _e('Text Post with "attached" link', 'nxs_snap'); ?><br/>
121
 
122
+ <div style="width:100%; margin-left: 15px;"><strong><?php _e('Link attachment type', 'nxs_snap'); ?>:&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"; ?> />
123
  <?php _e('Share a link to your blogpost', 'nxs_snap'); ?> .. <?php _e('or', 'nxs_snap'); ?> ..
124
+ <input value="1" id="apFBAttch<?php echo $ii; ?>" type="radio" name="fb[<?php echo $ii; ?>][apFBAttch]" <?php if ((int)$options['fbAttch'] == 1) echo "checked"; ?> />
125
  <?php _e('Attach your blogpost', 'nxs_snap'); ?> &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?', 'nxs_snap'); ?></a>)
126
+ <div style="margin-bottom: 5px; margin-left: 10px; "><input value="1" id="apFBAttchAsVid" type="checkbox" name="fb[<?php echo $ii; ?>][apFBAttchAsVid]" <?php if (isset($options['fbAttchAsVid']) && (int)$options['fbAttchAsVid'] == 1) echo "checked"; ?> /> <strong><?php _e('If post has video use it as an attachment thumbnail.', 'nxs_snap'); ?></strong> <i><?php _e('Video will be used for an attachment thumbnail instead of featured image. Only Youtube is supported at this time.', 'nxs_snap'); ?></i>
127
  <br/></div>
128
+
129
+ <input value="1" id="useFBGURLInfo<?php echo $ii; ?>" <?php if (!empty($options['useFBGURLInfo']) && $options['useFBGURLInfo']=='1') echo "checked"; ?> onchange="if (jQuery(this).is(':checked')) { jQuery('#useFBGURLInfoDiv<?php echo $ii; ?>').hide(); }else jQuery('#useFBGURLInfoDiv<?php echo $ii; ?>').show();" type="checkbox" name="fb[<?php echo $ii; ?>][useFBGURLInfo]"/> <strong><?php _e('Let Facebook fill the link info', 'nxs_snap'); ?></strong>
130
+ <i> - <?php _e('Recommended. Facebook will automatically take attached/shared link info from OG: tags or other sources.', 'nxs_snap'); ?> </i><br/>
131
+
132
+ <div id="useFBGURLInfoDiv<?php echo $ii; ?>" style="<?php if (trim($options['useFBGURLInfo'])=='' || $options['useFBGURLInfo']=='1') echo "display:none;"; ?>" >&nbsp;&nbsp;&nbsp;
133
+
134
+ <strong><?php _e('Attachment Text Format', 'nxs_snap'); ?>:</strong><br/>
135
+ &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <input value="1" id="apFBMsgAFrmtA<?php echo $ii; ?>" <?php if (trim($options['fbMsgAFrmt'])=='') echo "checked"; ?> onchange="if (jQuery(this).is(':checked')) { jQuery('#apFBMsgAFrmtDiv<?php echo $ii; ?>').hide(); jQuery('#apFBMsgAFrmt<?php echo $ii; ?>').val(''); }else jQuery('#apFBMsgAFrmtDiv<?php echo $ii; ?>').show();" type="checkbox" name="fb[<?php echo $ii; ?>][apFBMsgAFrmtA]"/> <strong><?php _e('Auto', 'nxs_snap'); ?></strong>
136
  <i> - <?php _e('Recommended. Info from SEO Plugins will be used, then post excerpt, then post text', 'nxs_snap'); ?> </i><br/>
137
+ <div id="apFBMsgAFrmtDiv<?php echo $ii; ?>" style="<?php if ($options['fbMsgAFrmt']=='') echo "display:none;"; ?>" >&nbsp;&nbsp;&nbsp; <?php _e('Set your own format', 'nxs_snap'); ?>:<input name="fb[<?php echo $ii; ?>][apFBMsgAFrmt]" id="apFBMsgAFrmt<?php echo $ii; ?>" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['fbMsgAFrmt'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /><br/></div>
138
+
139
+ </div>
140
+
141
+ </div><br/></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
142
 
143
  <div class="popShAtt" style="z-index: 9999; width: 350px;" id="popShAtt<?php echo $ii; ?>I"><h3><?php _e('Where to upload Images', 'nxs_snap'); ?></h3> <b><?php _e('(App Album)', 'nxs_snap'); ?></b> <?php _e('Facebook automatically creates an album for your app. Images will be grouped there as in any regular album.', 'nxs_snap'); ?> <br/><br/><b><?php _e('(Timeline)', 'nxs_snap'); ?></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.', 'nxs_snap'); ?></div>
144
  <div class="popShAtt" style="z-index: 9999" id="popShAtt<?php echo $ii; ?>"><h3><?php _e('Two ways of attaching post on Facebook', 'nxs_snap'); ?></h3><img src="<?php echo $nxs_plurl; ?>img/fb2wops.png" width="600" height="257" alt="<?php _e('Two ways of attaching post on Facebook', 'nxs_snap'); ?>"/></div>
147
 
148
 
149
 
150
+ <?php if ($options['fbPgID']!='') {?><div style="width:100%;"><strong>Facebook Page ID:</strong> <?php _e(apply_filters('format_to_edit', htmlentities($options['fbPgID'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?> </div><?php } ?>
151
  <?php
152
+ if($options['fbAppSec']=='') { ?>
153
  <b><?php _e('Authorize Your Facebook Account', 'nxs_snap'); ?></b> <?php _e('Please click "Update Settings" to be able to Authorize your account.', 'nxs_snap'); ?>
154
+ <?php } else { if(isset($options['fbAppAuthUser']) && $options['fbAppAuthUser']>0) { ?>
155
+ <?php _e('Your Facebook Account has been authorized.', 'nxs_snap'); ?> User ID: <?php _e(apply_filters('format_to_edit', htmlentities($options['fbAppAuthUser'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>.
156
  <?php _e('You can', 'nxs_snap'); ?> Re- <?php } ?>
157
+ <a href="https://www.facebook.com/dialog/oauth?client_id=<?php echo trim($options['fbAppID']);?>&client_secret=<?php echo trim($options['fbAppSec']);?>&scope=publish_stream,user_photos,photo_upload,friends_photos,offline_access,read_stream,manage_pages,user_groups,friends_groups&redirect_uri=<?php echo trim(urlencode($nxs_snapThisPageUrl.'&auth=fb&acc='.$ii));?>">Authorize Your Facebook Account</a>
158
+ <?php if (!isset($options['fbAppAuthUser']) || $options['fbAppAuthUser']<1) { ?> <div class="blnkg">&lt;=== <?php _e('Authorize your account', 'nxs_snap'); ?> ===</div>
159
  <br/><br/><i> <?php _e('If you get Facebook message:', 'nxs_snap'); ?> <b>"Error. An error occurred. Please try again later."</b> or <b>"Error 191"</b> <?php _e('please make sure that domain name in your Facebook App matches your website domain exactly. Please note that www. and non www. versions are different domains.', 'nxs_snap'); ?></i> <?php }?>
160
  <?php } ?>
161
 
162
+ <?php if(isset($options['fbAppAuthUser']) && $options['fbAppAuthUser']>0) { ?>
163
+
164
  <br/><br/><b><?php _e('Test your settings', 'nxs_snap'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('FB','<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'nxs_snap' ), $nType); ?></a>
165
  <?php }?>
166
+
167
+ </div>
168
+ <?php /* ######################## Tools Tab ####################### */ ?>
169
+ <div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content">
170
+
171
+ <?php if (!$isNew) { ?> <div class="nxs_tls_cpt"><?php _e('Categories', 'nxs_snap'); ?></div>
172
+ <div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
173
+ <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="fb[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
174
+ <input value="1" id="catSelSFB<?php echo $ii; ?>" type="radio" name="fb[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_FB<?php echo $ii; ?>" onclick="jQuery('#catSelSFB<?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('FB<?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_FB<?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($options['catSelEd']!='') echo "[".(substr_count($options['catSelEd'], ",")+1)."]"; ?></a>
175
+ <input type="hidden" name="fb[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_FB<?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
176
+ <br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
177
+ <br/>
178
+ <?php } ?>
179
+
180
+ <?php nxs_addPostingDelaySelV3($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']); ?>
181
+
182
+ <div style="width:100%;"><strong style="font-size: 16px;"><?php _e('Facebook Comments:', 'nxs_snap'); ?></strong> </div>
183
+ <div style="margin-bottom: 5px; margin-left: 10px; ">
184
+ <p style="font-size: 11px; margin: 0px;"><?php _e('Plugin could grab comments from Facebook and import them as Wordpress Comments', 'nxs_snap'); ?></p>
185
+
186
+ <?php if ( $gOptions['riActive'] == '1' ) { ?>
187
+ <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', 'nxs_snap'); ?></strong>
188
+ <br/>
189
+ <div style="margin-bottom: 5px; margin-left: 10px; ">
190
+ <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', 'nxs_snap'); ?></strong></div>
191
+
192
+ <?php } else { echo "<br/>"; _e('Please activate the "Comments Import" from SNAP Settings Tab', 'nxs_snap'); } ?>
193
+
194
+ </div>
195
+
196
+ <?php nxs_showRepostSettings($nt, $ii, $options); ?>
197
+
198
+
199
+ </div> <?php /* #### End of Tab #### */ ?>
200
+ </div><br/> <?php /* #### End of Tabs #### */ ?>
201
+
202
+ <div class="submit clear" style="padding-bottom: 0px;"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div>
203
 
204
  </div>
205
  <?php
226
  if (isset($pval['apFBMsgFrmt'])) $options[$ii]['fbMsgFormat'] = trim($pval['apFBMsgFrmt']);
227
  if (isset($pval['apFBMsgAFrmt'])) $options[$ii]['fbMsgAFrmt'] = trim($pval['apFBMsgAFrmt']);
228
 
229
+ if (isset($pval['useFBGURLInfo'])) $options[$ii]['useFBGURLInfo'] = $pval['useFBGURLInfo']; else $options[$ii]['useFBGURLInfo'] = 0;
230
+
231
  if (isset($pval['riComments'])) $options[$ii]['riComments'] = $pval['riComments']; else $options[$ii]['riComments'] = 0;
232
  if (isset($pval['riCommentsAA'])) $options[$ii]['riCommentsAA'] = $pval['riCommentsAA']; else $options[$ii]['riCommentsAA'] = 0;
233
 
234
+ $options[$ii] = nxs_adjRpst($options[$ii], $pval);
235
+
236
+ if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']);
237
  if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
238
+
239
  if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
240
 
241
  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'];
248
  } return $options;
249
  }
250
  //#### Show Post->Edit Meta Box Settings
251
+ function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID; $nt = 'fb'; $ntU = 'FB';
252
+ 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]);
253
+ if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = ''; if (empty($ntOpt['urlToUse'])) $ntOpt['urlToUse'] = '';
254
+ $doFB = $ntOpt['doFB'] && (is_array($pMeta) || $ntOpt['catSel']!='1'); $imgToUse = $ntOpt['imgToUse']; $urlToUse = $ntOpt['urlToUse'];
255
  $isAvailFB = $ntOpt['fbURL']!='' && $ntOpt['fbAppID']!='' && $ntOpt['fbAppSec']!=''; $isAttachFB = $ntOpt['fbAttch']; $fbMsgFormat = htmlentities($ntOpt['fbMsgFormat'], ENT_COMPAT, "UTF-8"); $fbPostType = $ntOpt['fbPostType'];
256
  ?>
257
 
268
  <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', 'nxs_snap') ?>" />
269
  <?php } ?>
270
 
271
+ <?php } ?>
272
 
273
+ <?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']);
274
 
275
  ?> <span id="pstdFB<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
276
  <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', 'nxs_snap' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
278
 
279
  </td></tr>
280
  <?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>
281
+ <?php } else { if ($post->post_status != "publish" && function_exists('nxs_doSMAS5') ) { nxs_doSMAS5($nt, $ii, $ntOpt); } ?>
282
+
283
+ <?php if ($ntOpt['rpstOn']=='1') { ?>
284
+
285
+ <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top:6px; text-align:right; width:60px; padding-right:10px;">
286
+ <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"; ?> />
287
+ </th>
288
+ <td> <?php _e('Include in "Auto-Reposting" to this network.', 'nxs_snap') ?>
289
+ </td></tr> <?php } ?>
290
 
291
  <tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;">
292
 
310
  <div class="popShAtt" id="popShAtt<?php echo $ii; ?>"><h3><?php _e('Two ways of attaching post on Facebook', 'nxs_snap'); ?></h3> <img src="<?php echo $nxs_plurl; ?>img/fb2wops.png" width="600" height="257" alt="<?php _e('Two ways of attaching post on Facebook', 'nxs_snap'); ?>"/></div>
311
  <div class="popShAtt" id="popShAtt<?php echo $ii; ?>X"><h3><?php _e('Facebook Post Types', 'nxs_snap'); ?></h3><img src="<?php echo $nxs_plurl; ?>img/fbPostTypesDiff6.png" width="600" height="398" alt="<?php _e('Facebook Post Types', 'nxs_snap'); ?>"/></div>
312
  </td></tr>
313
+
314
+
 
 
 
315
  <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Message Format:', 'nxs_snap') ?></th>
316
  <td>
317
  <?php if (1==1) { ?>
320
  <input value="<?php echo $fbMsgFormat ?>" type="text" name="fb[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apFBTMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apFBTMsgFrmt".$ii, '', '58'); ?>
321
  <?php } ?>
322
  </td></tr>
323
+ <?php /* ## Select Image & URL ## */ nxs_showImgToUseDlg($nt, $ii, $imgToUse); nxs_showURLToUseDlg($nt, $ii, $urlToUse);
324
+ }
325
  }
326
 
327
  }
328
 
329
  function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
330
+ if (isset($pMeta['SNAPformat'])) $optMt['fbMsgFormat'] = $pMeta['SNAPformat'];
331
+ if (isset($pMeta['imgToUse'])) $optMt['imgToUse'] = $pMeta['imgToUse']; if (isset($pMeta['urlToUse'])) $optMt['urlToUse'] = $pMeta['urlToUse'];
332
+ if (isset($pMeta['timeToRun'])) $optMt['timeToRun'] = $pMeta['timeToRun']; if (isset($pMeta['rpstPostIncl'])) $optMt['rpstPostIncl'] = $pMeta['rpstPostIncl'];
333
  if (isset($pMeta['AttachPost'])) $optMt['fbAttch'] = ($pMeta['AttachPost'] != '')?$pMeta['AttachPost']:0; else { if (isset($pMeta['SNAPformat'])) $optMt['fbAttch'] = 0; }
334
  if (isset($pMeta['PostType'])) $optMt['fbPostType'] = ($pMeta['PostType'] != '')?$pMeta['PostType']:0; else { if (isset($pMeta['SNAPformat'])) $optMt['fbPostType'] = 'T'; }
335
  if (isset($pMeta['doFB'])) $optMt['doFB'] = $pMeta['doFB'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doFB'] = 0; }
338
  }
339
  }}
340
 
341
+ if (!function_exists("nxs_getBackFBComments")) { function nxs_getBackFBComments($postID, $options, $po) { require_once ('apis/facebook.php'); if (empty($options['fbAppPageAuthToken'])) return;
342
+ $opts = array('access_token' => $options['fbAppPageAuthToken']);
 
 
 
 
 
 
 
 
 
343
  $facebook = new NXS_Facebook(array( 'appId' => $options['fbAppID'], 'secret' => $options['fbAppSec'], 'cookie' => true )); $ci = 0;
344
  $ret = $facebook->api($po['pgID']."/comments?filter=toplevel", "GET", $opts);
345
  $impCmnts = get_post_meta($postID, 'snapImportedFBComments', true); if (!is_array($impCmnts)) $impCmnts = array(); //prr($impCmnts);
363
  }
364
  delete_post_meta($postID, 'snapImportedFBComments'); add_post_meta($postID, 'snapImportedFBComments', $impCmnts );
365
  //## if Importing manually from Button echo result.
366
+ if (isset($_POST['id']) && $_POST['id']!='') printf( _n( '%d comment has been imported.', '%d comments has been imported.', $ci, 'nxs_snap'), $ci );
367
  }}
368
 
369
+ // ShortCode [nxs_fbembed accnum=0]
370
+ 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);
371
+ if (!is_array($fbpo) || !is_array($fbpo[$accnum]) || !isset($fbpo[$accnum]['pgID']) || strpos($fbpo[$accnum]['pgID'], '_')===false ) return; $fbpo = $fbpo[$accnum]['pgID'];
372
+ $fbpoA = explode('_',$fbpo); $fpg = $fbpoA[0]; $fpid = $fbpoA[1];
373
+ $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>
374
+ <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>';
375
+ return $txtOut;
376
+ }
377
+ add_shortcode( 'nxs_fbembed', 'nxs_fbembed_func' );
378
+
379
+ if (!function_exists("nxs_rePostToFB_ajax")) { function nxs_rePostToFB_ajax() { check_ajax_referer('nxsSsPageWPN'); $postID = $_POST['id']; // $result = nsPublishTo($id, 'FB', true);
380
  $options = get_option('NS_SNAutoPoster'); foreach ($options['fb'] as $ii=>$fbo) if ($ii==$_POST['nid']) { $fbo['ii'] = $ii; $fbo['pType'] = 'aj';
381
  $fbpo = get_post_meta($postID, 'snapFB', true); /* echo $postID."|"; echo $fbpo; */ $fbpo = maybe_unserialize($fbpo); // prr($fbpo);
382
  if (is_array($fbpo) && isset($fbpo[$ii]) && is_array($fbpo[$ii]) ){ $ntClInst = new nxs_snapClassFB(); $fbo = $ntClInst->adjMetaOpt($fbo, $fbpo[$ii]); } //prr($fbo);
383
+ if (isset($_POST['ri']) && $_POST['ri']=='1') { nxs_getBackFBComments($postID, $fbo, $fbpo[$ii]); die(); } else {
384
  $result = nxs_doPublishToFB($postID, $fbo); if ($result == '200') die("Your post has been successfully sent to FaceBook."); else die($result);
385
  }
386
  }
388
  }
389
 
390
  if (!function_exists("nxs_doPublishToFB")) { //## Second Function to Post to FB
391
+ function nxs_doPublishToFB($postID, $options){ global $ShownAds; $ntCd = 'FB'; $ntCdL = 'fb'; $ntNm = 'Facebook'; $dsc = ''; $vidURL = '';
392
+ if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
393
  if (!class_exists('nxs_class_SNAP_FB')) { nxs_addToLogN('E', 'Error', $ntCd, '-=ERROR=- No Facebook API Lib Detected', ''); return "No Facebook API Lib Detected";}
394
 
395
  $fbWhere = 'feed'; $page_id = $options['fbPgID']; if (isset($ShownAds)) $ShownAdsL = $ShownAds; $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'POSTID'=>$postID, 'ACCNAME'=>$options['nName']));
408
  //## Initiate Posting Array
409
  $message = array('message'=>'', 'link'=>'', 'title'=>'', 'description'=>'', 'imageURL'=>'', 'videoURL'=>'', 'siteName'=>$blogTitle);
410
 
411
+ if ($postID=='0') { $options['fbMsgFormat'] = 'Test Post, Please Ignore'; $imgURL = '';
412
+ $dsc = 'Test Post, Description'; $urlTitle = 'Test Post - Title'; $urlToGo = home_url();
413
  } else { $post = get_post($postID); if(!$post) return; $msg = nsFormatMessage($options['fbMsgFormat'], $postID, $addParams);
414
+ $fbPostType = $options['fbPostType']; if ($fbPostType=='A') $fbPostType = (int)$options['fbAttch']==2?'S':'A'; $isAttachVidFB = $options['fbAttchAsVid'];
415
+ nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
416
+ $extInfo = ' | PostID: '.$postID." - ".(isset($post) && is_object($post)?nxs_doQTrans($post->post_title, $lng):'').' |'.$options['pType'];
417
+ if ($fbPostType=='A') $imgURL = nxs_getPostImage($postID, 'medium'); // prr($options); echo "PP - ".$postID; prr($src);
418
+ if ($fbPostType=='I' || $fbPostType=='S') $imgURL = nxs_getPostImage($postID, 'full'); // prr($options); echo "PP - ".$postID; prr($src);
419
+ if (($fbPostType=='A' || $fbPostType=='S')){
420
  //## AUTO - Get Post Descr from SEO Plugins or make it.
421
  if (trim($options['fbMsgAFrmt'])!='') {$dsc = nsFormatMessage($options['fbMsgAFrmt'], $postID, $addParams);} else { if (function_exists('aioseop_mrt_fix_meta') && $dsc=='') $dsc = trim(get_post_meta($postID, '_aioseop_description', true));
422
  if (function_exists('wpseo_admin_init') && $dsc=='') $dsc = trim(get_post_meta($postID, '_yoast_wpseo_opengraph-description', true));
431
  $msg = str_replace('<br>', "\n", $msg); $msg = str_replace('<br/>', "\n", $msg); $msg = str_replace('<br />', "\n", $msg);
432
  $msg = str_ireplace('<3','&lt;3', $msg); $msg = str_ireplace('<(','&lt;(', $msg); //## FB Smiles FIX.
433
  $msg = strip_tags($msg); $msg = nxs_decodeEntitiesFull($msg);
434
+ $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.
435
 
436
  if ($isAttachVidFB=='1') {$vids = nsFindVidsInPost($post, false); if (count($vids)>0) {
437
  if (strlen($vids[0])==11) { $vidURL = 'http://www.youtube.com/v/'.$vids[0]; $imgURL = nsGetYTThumb($vids[0]); }
440
  if (!is_wp_error($json)) { $json = $json['body']; $json = str_replace('showThumb(','',$json); $json = str_replace('])',']',$json); $json = json_decode($json, true); $imgURL = $json[0]['thumbnail_large']; }
441
  }
442
  }}
443
+ if (trim($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';
444
+
445
  //## MyURL - URLToGo code
446
  if (!isset($options['urlToUse']) || trim($options['urlToUse'])=='') $myurl = trim(get_post_meta($postID, 'snap_MYURL', true)); if ($myurl!='') $options['urlToUse'] = $myurl;
447
+ if (isset($options['urlToUse']) && trim($options['urlToUse'])!='') { $urlToGo = $options['urlToUse']; $options['useFBGURLInfo'] = true; } else $urlToGo = get_permalink($postID);
448
  if($addParams!='') $urlToGo .= (strpos($urlToGo,'?')!==false?'&':'?').$addParams;
449
+ //prr($options);
450
+ $urlTitle = nxs_doQTrans($post->post_title, $lng); $options['fbMsgFormat'] = $msg;
451
  } // prr($mssg); // prr($options); // prr($facebook); echo "/$page_id/feed";
452
+
453
+ $message = array('url'=>$urlToGo, 'urlTitle'=>$urlTitle, 'urlDescr'=>$dsc, 'imageURL'=>$imgURL, 'videoURL'=>$vidURL, 'siteName'=>$blogTitle);
454
+ if (isset($ShownAds)) $ShownAds = $ShownAdsL; // FIX for the quick-adsense plugin
455
 
456
  //## Actual Post
457
  $ntToPost = new nxs_class_SNAP_FB(); $ret = $ntToPost->doPostToNT($options, $message);
inc-cl/ff.api.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //## NextScripts FriendFeed Connection Class
3
+ $nxs_snapAPINts[] = array('code'=>'FF', 'lcode'=>'ff', 'name'=>'FriendFeed');
4
+
5
+ if (!class_exists("nxs_class_SNAP_FF")) { class nxs_class_SNAP_FF {
6
+
7
+ var $ntCode = 'FF';
8
+ var $ntLCode = 'ff';
9
+
10
+ function doPost($options, $message){ if (!is_array($options)) return false;
11
+ foreach ($options as $ntOpts) $out[] = $this->doPostToNT($ntOpts, $message);
12
+ return $out;
13
+ }
14
+ function nxs_getFFHeaders($up){ $hdrsArr = array();
15
+ $hdrsArr['Cache-Control']='no-cache'; $hdrsArr['Connection']='keep-alive';
16
+ $hdrsArr['User-Agent']='SNAP for Wordpress; Ver '.NextScripts_SNAP_Version;
17
+ $hdrsArr['Accept']='text/html, application/xhtml+xml, */*'; $hdrsArr['DNT']='1';
18
+ $hdrsArr['Content-Type']='application/x-www-form-urlencoded';
19
+ $hdrsArr['Authorization'] = 'Basic ' . base64_encode("$up");
20
+ if (function_exists('gzdeflate')) $hdrsArr['Accept-Encoding']='gzip,deflate';
21
+ $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;
22
+ }
23
+ function doPostToNT($options, $message){ $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>'');
24
+ //## Check settings
25
+ if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
26
+ if (!isset($options['ffUName']) || trim($options['ffPass'])=='') { $badOut['Error'] = 'Not Configured'; return $badOut; }
27
+ $dusername = $options['ffUName']; $pass = (substr($options['ffPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['ffPass'], 5)):$options['ffPass']);
28
+ //## Format
29
+ $msg = nxs_doFormatMsg($options['ffMsgFormat'], $message);
30
+ if ($options['attchImg']=='1') { if (isset($message['imageURL'])) $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); else $imgURL = ''; } else $imgURL = '';
31
+
32
+ $postArr = array('title'=>$msg, 'image0_link'=>'', 'room'=>($options['grpID']!=''?strtolower($options['grpID']):''), 'image0_url'=>($imgURL!=''?$imgURL:''));
33
+ $apicall = "http://friendfeed.com/api/share"; $hdrsArr = $this->nxs_getFFHeaders($dusername.':'.$pass);
34
+ $paramcall = array( 'method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'body'=> $postArr, 'headers' => $hdrsArr);
35
+
36
+ $cnt = wp_remote_post( $apicall, $paramcall ); // prr(json_decode($cnt['body'], true));
37
+
38
+ if(is_wp_error($cnt)) $ret = 'Something went wrong - '.print_r($cnt, true);
39
+ else { if (is_array($cnt)) $retInfo = json_decode($cnt['body'], true); else $retInfo = false;
40
+ if (is_array($cnt) && $cnt['response']['code']=='200' && is_array($retInfo)) return array('postID'=>$retInfo['entries'][0]['id'], 'isPosted'=>1, 'postURL'=>'DL', 'pDate'=>date('Y-m-d H:i:s'));
41
+ else { $ret = "Error: "; if ($cnt['response']['code']=='401') $ret .= " Incorrect Username/Password "; $ret .= $cnt['response']['message']; }
42
+ } $badOut['Error'] .= $ret; return $badOut;
43
+ }
44
+ }}
45
+ ?>
inc-cl/ff.php CHANGED
@@ -8,70 +8,92 @@ if (!class_exists("nxs_snapClassFF")) { class nxs_snapClassFF {
8
  <div class="nxs_box">
9
  <div class="nxs_box_header">
10
  <div class="nsx_iconedTitle" style="margin-bottom:1px;background-image:url(<?php echo $nxs_plurl;?>img/<?php echo $ntInfo['lcode']; ?>16.png);"><?php echo $ntInfo['name']; ?>
11
- <?php $cbo = count($ntOpts); ?> <?php wp_nonce_field( 'ns'.$ntInfo['code'], 'ns'.$ntInfo['code'].'_wpnonce' ); ?>
12
  <?php if ($cbo>1){ ?><div class="nsBigText"><?php echo "(".($cbo=='0'?'No':$cbo)." "; _e('accounts', 'nxs_snap'); echo ")"; ?></div><?php } ?>
13
  </div>
14
  </div>
15
  <div class="nxs_box_inside">
16
  <?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
17
  <p style="margin:0px;margin-left:5px;">
18
- <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> /> <?php if ((int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
 
 
19
  <strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
20
  &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', 'nxs_snap'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>&nbsp;&nbsp;
21
  <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
22
- </p><?php $this->showNTSettings($indx, $pbo);
23
  }?>
24
  </div>
25
  </div> <?php
26
  }
27
  //#### Show NEW Settings Page
28
- function showNewNTSettings($mgpo){ $gpo = array('nName'=>'', 'doFF'=>'1', 'ffUName'=>'', 'ffPageID'=>'', 'ffAttch'=>'', 'ffPass'=>''); $this->showNTSettings($mgpo, $gpo, true);}
29
  //#### Show Unit Settings
30
- function showNTSettings($ii, $gpo, $isNew=false){ global $nxs_plurl;
31
- if (!isset($gpo['nHrs'])) $gpo['nHrs'] = 0; if (!isset($gpo['nMin'])) $gpo['nMin'] = 0; if (!isset($gpo['catSel'])) $gpo['catSel'] = 0; if (!isset($gpo['catSelEd'])) $gpo['catSelEd'] = '';
32
- if (!isset($gpo['nDays'])) $gpo['nDays'] = 0; if (!isset($gpo['qTLng'])) $gpo['qTLng'] = ''; ?>
33
-
34
- <div id="doFF<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>" style="max-width: 1000px; background-color: #EBF4FB; background-image: url(<?php echo $nxs_plurl; ?>img/ff-bg.png); background-position:90% 10%; background-repeat: no-repeat; margin: 10px; border: 1px solid #808080; padding: 10px; display:none;"> <input type="hidden" name="apDoSFF<?php echo $ii; ?>" value="0" id="apDoSFF<?php echo $ii; ?>" />
35
 
36
  <div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/ff16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-FriendFeed-social-networks-auto-poster-wordpress/"><?php $nType="FriendFeed"; printf( __( 'Detailed %s Installation/Configuration Instructions', 'nxs_snap' ), $nType); ?></a></div>
37
 
38
- <div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easely identify it', 'nxs_snap'); ?></i> </div><input name="ff[<?php echo $ii; ?>][nName]" id="ffnName<?php echo $ii; ?>" style="font-weight: bold; color: #005800; border: 1px solid #ACACAC; width: 40%;" value="<?php _e(apply_filters('format_to_edit',htmlentities($gpo['nName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /><br/>
39
- <?php echo nxs_addQTranslSel('ff', $ii, $gpo['qTLng']); ?><?php echo nxs_addPostingDelaySel('ff', $ii, $gpo['nHrs'], $gpo['nMin']); ?>
40
 
41
- <?php if (!$isNew) { ?>
42
- <div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
43
- <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="ff[<?php echo $ii; ?>][catSel]" <?php if ((int)$gpo['catSel'] != 1) echo "checked"; ?> /> All
44
- <input value="1" id="catSelSFF<?php echo $ii; ?>" type="radio" name="ff[<?php echo $ii; ?>][catSel]" <?php if ((int)$gpo['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_FF<?php echo $ii; ?>" onclick="jQuery('#catSelSFF<?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('FF<?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_FF<?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($gpo['catSelEd']!='') echo "[".(substr_count($gpo['catSelEd'], ",")+1)."]"; ?></a>
45
- <input type="hidden" name="ff[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_FF<?php echo $ii; ?>" value="<?php echo $gpo['catSelEd']; ?>" />
46
- <br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
47
- <br/>
48
- <?php } ?>
49
 
50
- <div style="width:100%;"><strong>FriendFeed nickname:</strong> <span style="font-size: 11px; margin: 0px;">Get it from <a target="_blank" href="https://friendfeed.com/account/api">https://friendfeed.com/account/api</a>.</span></div><input name="ff[<?php echo $ii; ?>][apFFUName]" id="apFFUName" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit',htmlentities($gpo['ffUName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
51
  <div style="width:100%;"><strong>FriendFeed remote key:</strong> <span style="font-size: 11px; margin: 0px;">Get it from <a target="_blank" href="https://friendfeed.com/account/api">https://friendfeed.com/account/api</a>.</span>
52
 
53
- </div><input name="ff[<?php echo $ii; ?>][apFFPass]" id="apFFPass" type="password" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities(substr($gpo['ffPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($gpo['ffPass'], 5)):$gpo['ffPass'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /> <br/>
54
 
55
  <div style="width:100%;"><br/><strong>Group ID:</strong> [Optional] Please specify Group ID. <i>Use this <b>only</b> if you are posting NOT to your own feed. </i></div>
56
- <input name="ff[<?php echo $ii; ?>][grpID]" id="grpID" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($gpo['grpID'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
57
 
58
  <?php if ($isNew) { ?> <input type="hidden" name="ff[<?php echo $ii; ?>][apDoFF]" value="1" id="apDoNewFF<?php echo $ii; ?>" /> <?php } ?>
59
  <br/> <br/>
60
 
61
  <div id="altFormat" style="">
62
  <div style="width:100%;"><strong id="altFormatText"><?php _e('Post Text Format', 'nxs_snap'); ?></strong> (<a href="#" id="apFFMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apFFMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)</div>
63
- <input name="ff[<?php echo $ii; ?>][apFFMsgFrmt]" id="apFFMsgFrmt" style="width: 50%;" value="<?php if ($isNew) echo "%TITLE% - %URL% %EXCERPT%"; else _e(apply_filters('format_to_edit',htmlentities($gpo['ffMsgFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap'); ?>" onfocus="mxs_showFrmtInfo('apFFMsgFrmt<?php echo $ii; ?>');" /><?php nxs_doShowHint("apFFMsgFrmt".$ii); ?>
64
  </div>
65
- <p style="margin: 0px;"><input value="1" id="apLIAttch" type="checkbox" name="ff[<?php echo $ii; ?>][attchImg]" <?php if ((int)$gpo['attchImg'] == 1) echo "checked"; ?> /> <strong><?php _e('Attach Image to FriendFeed Post', 'nxs_snap'); ?></strong></p>
66
  <br/>
67
 
68
- <?php if ($gpo['ffPass']!='') { ?>
69
- <?php wp_nonce_field( 'rePostToFF', 'rePostToFF_wpnonce' ); ?>
70
  <b><?php _e('Test your settings', 'nxs_snap'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('FF', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'nxs_snap' ), $nType); ?></a>
71
 
72
  <?php }
73
 
74
- ?><div class="submit"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div></div><?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  }
76
  //#### Set Unit Settings from POST
77
  function setNTSettings($post, $options){ global $nxs_snapThisPageUrl; $code = 'FF'; $lcode = 'ff';
@@ -88,16 +110,21 @@ if (!class_exists("nxs_snapClassFF")) { class nxs_snapClassFF {
88
  if (isset($pval['grpID'])) $options[$ii]['grpID'] = trim($pval['grpID']);
89
  if (isset($pval['attchImg'])) $options[$ii]['attchImg'] = $pval['attchImg']; else $options[$ii]['attchImg'] = 0;
90
  if (isset($pval['apDoFF'])) $options[$ii]['doFF'] = $pval['apDoFF']; else $options[$ii]['doFF'] = 0;
 
 
 
 
91
  if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
92
  if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
93
  }
94
  } return $options;
95
  }
96
  //#### Show Post->Edit Meta Box Settings
97
- function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
98
  foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapFF', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
99
- $doFF = $ntOpt['doFF'] && (is_array($pMeta) || $ntOpt['catSel']!='1');
100
- $isAvailFF = $ntOpt['ffUName']!='' && $ntOpt['ffPass']!=''; $ffMsgFormat = htmlentities($ntOpt['ffMsgFormat'], ENT_COMPAT, "UTF-8"); $ffMsgTFormat = htmlentities($ntOpt['ffMsgTFormat'], ENT_COMPAT, "UTF-8");
 
101
  $isAttchImg = $ntOpt['attchImg'];
102
  ?>
103
  <tr><th style="text-align:left;" colspan="2"><?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_FF<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
@@ -106,9 +133,9 @@ if (!class_exists("nxs_snapClassFF")) { class nxs_snapClassFF {
106
 
107
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/ff16.png);">FriendFeed - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
108
  if ($post->post_status == "publish" && $isAvailFF) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToFF_repostButton" id="rePostToFF_button" value="<?php _e('Repost to FriendFeed', 'nxs_snap') ?>" />
109
- <?php wp_nonce_field( 'rePostToFF', 'rePostToFF_wpnonce' ); } ?>
110
 
111
- <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
112
  ?> <span id="pstdFF<?php echo $ii; ?>" style="float: right; padding-top: 4px; padding-right: 10px;">
113
  <a style="font-size: 10px;" href="http://www.FriendFeed.com/e/<?php echo $pMeta[$ii]['pgID']; ?>" target="_blank"><?php $nType="FriendFeed"; printf( __( 'Posted on', 'nxs_snap' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
114
  </span><?php } ?>
@@ -120,11 +147,20 @@ if (!class_exists("nxs_snapClassFF")) { class nxs_snapClassFF {
120
  <input value="1" type="checkbox" name="ff[<?php echo $ii; ?>][attchImg]" <?php if ((int)$isAttchImg == 1) echo "checked"; ?> /> </th><td><strong>Attach Image to FriendFeed Post</strong></td> </tr>
121
 
122
  <?php if (!$isAvailFF) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your FriendFeed Account to AutoPost to FriendFeed</b>
123
- <?php } elseif ($post->post_status != "pubZlish") { ?>
 
 
 
 
 
 
 
 
 
124
 
125
  <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Title Format:', 'nxs_snap') ?></th>
126
  <td><input value="<?php echo $ffMsgFormat ?>" type="text" name="ff[<?php echo $ii; ?>][SNAPformatT]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apFFMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apFFMsgFrmt".$ii, '', '58'); ?></td></tr>
127
-
128
  <?php }
129
  }
130
  }
@@ -132,14 +168,15 @@ if (!class_exists("nxs_snapClassFF")) { class nxs_snapClassFF {
132
  function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
133
  if (isset($pMeta['SNAPformat'])) $optMt['ffMsgFormat'] = $pMeta['SNAPformat'];
134
  if (isset($pMeta['attchImg'])) $optMt['attchImg'] = $pMeta['attchImg'] == 1?1:0; else { if (isset($pMeta['attchImg'])) $optMt['attchImg'] = 0; }
135
-
 
136
  if (isset($pMeta['doFF'])) $optMt['doFF'] = $pMeta['doFF'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doFF'] = 0; }
137
  if (isset($pMeta['SNAPincludeFF']) && $pMeta['SNAPincludeFF'] == '1' ) $optMt['doFF'] = 1;
138
  return $optMt;
139
  }
140
  }}
141
  if (!function_exists("nxs_rePostToFF_ajax")) {
142
- function nxs_rePostToFF_ajax() { check_ajax_referer('rePostToFF'); $postID = $_POST['id']; $options = get_option('NS_SNAutoPoster');
143
  foreach ($options['ff'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj'; //if ($two['gpPageID'].$two['gpUName']==$_POST['nid']) {
144
  $gppo = get_post_meta($postID, 'snapFF', true); $gppo = maybe_unserialize($gppo);// prr($gppo);
145
  if (is_array($gppo) && isset($gppo[$ii]) && is_array($gppo[$ii])){ $ntClInst = new nxs_snapClassFF(); $two = $ntClInst->adjMetaOpt($two, $gppo[$ii]);}
@@ -148,20 +185,14 @@ if (!function_exists("nxs_rePostToFF_ajax")) {
148
  }
149
  }
150
 
151
- if (!function_exists("nxs_getFFHeaders")) { function nxs_getFFHeaders($up){ $hdrsArr = array();
152
- $hdrsArr['Cache-Control']='no-cache'; $hdrsArr['Connection']='keep-alive';
153
- $hdrsArr['User-Agent']='SNAP for Wordpress; Ver '.NextScripts_SNAP_Version;
154
- $hdrsArr['Accept']='text/html, application/xhtml+xml, */*'; $hdrsArr['DNT']='1';
155
- $hdrsArr['Content-Type']='application/x-www-form-urlencoded';
156
- $hdrsArr['Authorization'] = 'Basic ' . base64_encode("$up");
157
- //$hdrsArr['Authorization'] = $up;
158
- $hdrsArr['Accept-Encoding']='gzip,deflate'; $hdrsArr['Accept-Language']='en-US,en;q=0.8'; $hdrsArr['Accept-Charset']='ISO-8859-1,utf-8;q=0.7,*;q=0.3'; return $hdrsArr;
159
- }}
160
 
161
  if (!function_exists("nxs_doPublishToFF")) { //## Second Function to Post to FF
162
- function nxs_doPublishToFF($postID, $options){ $ntCd = 'FF'; $ntCdL = 'ff'; $ntNm = 'FriendFeed';
163
  //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToFF', array($postID, $options));
164
-
 
 
165
  $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
166
  $logNT = '<span style="color:#000080">FriendFeed</span> - '.$options['nName'];
167
  $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
@@ -171,35 +202,26 @@ if (!function_exists("nxs_doPublishToFF")) { //## Second Function to Post to FF
171
  }
172
  }
173
 
174
- if ($postID=='0') { echo "Testing ... <br/><br/>"; $link = home_url(); $msg = 'Test Link from '.$link; } else { $post = get_post($postID); if(!$post) return; $link = get_permalink($postID);
175
- $msgFormat = $options['ffMsgFormat']; $msgTFormat = $options['ffMsgTFormat']; $msgT = nsFormatMessage($msgTFormat, $postID); $msg = nsFormatMessage($msgFormat, $postID);
176
  nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
177
  }
178
- $extInfo = ' | PostID: '.$postID." - ".$post->post_title;
179
- $dusername = $options['ffUName']; $pass = (substr($options['ffPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['ffPass'], 5)):$options['ffPass']);
180
- $link = urlencode($link); $ext = urlencode(substr($msg, 0, 1000));
181
- // API/V2 if we ever switch - $postArr = array('body'=>$msg, 'link'=>'', 'to'=>($options['grpID']!=''?$options['grpID']:'me'), 'image_url'=>($imgURL!=''?$imgURL:'me'), 'short'=>0); prr($postArr);
182
-
183
- if ($options['attchImg']=='1') $imgURL = nxs_getPostImage($postID, 'full'); else $imgURL = '';
184
- $postArr = array('title'=>$msg, 'image0_link'=>'', 'room'=>($options['grpID']!=''?$options['grpID']:''), 'image0_url'=>($imgURL!=''?$imgURL:''));
185
- $apicall = "http://friendfeed.com/api/share"; $hdrsArr = nxs_getFFHeaders($dusername.':'.$pass);
186
- $paramcall = array( 'method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'body'=> $postArr, 'headers' => $hdrsArr);
187
-
188
- $cnt = wp_remote_post( $apicall, $paramcall ); // prr(json_decode($cnt['body'], true));
189
 
190
- if(is_wp_error($cnt)) {
191
- $ret = 'Something went wrong - '.""; nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.$ret. "ERR: ".print_r($cnt, true), $extInfo);
192
- } else {
193
- if (is_array($cnt) && $cnt['response']['code']=='200' && is_array(json_decode($cnt['body'], true)))
194
- { $ret = 'OK'; $retInfo = json_decode($cnt['body'], true);
195
- nxs_metaMarkAsPosted($postID, 'FF', $options['ii'], array('isPosted'=>'1', 'pgID'=>$retInfo['entries'][0]['id'], 'pDate'=>date('Y-m-d H:i:s'))); nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); }
196
- else { $ret = "Error: ";
197
- if ($cnt['response']['code']=='401') $ret .= " Incorrect Username/Password ";
198
- $ret .= $cnt['response']['message']; nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.$ret. " | ERR: ".print_r($cnt, true), $extInfo);
199
- }
 
200
  }
201
- if ($ret!='OK') { if ($postID=='0') echo $ret; } else if ($postID=='0') { echo 'OK - Message Posted, please see your FriendFeed Page. '; nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); }
202
- if ($ret == 'OK') return 200; else return $ret;
 
203
  }
204
  }
205
  ?>
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', 'nxs_snap'); echo ")"; ?></div><?php } ?>
13
  </div>
14
  </div>
15
  <div class="nxs_box_inside">
16
  <?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
17
  <p style="margin:0px;margin-left:5px;">
18
+ <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> />
19
+ <?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 } ?>
20
+ <?php if (isset($pbo['rpstOn']) && (int)$pbo['rpstOn'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popReActive');" onmouseover="nxs_showPopUpInfo('popReActive', event);"><?php echo "*[R]*" ?></span><?php } ?>
21
  <strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
22
  &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', 'nxs_snap'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>&nbsp;&nbsp;
23
  <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
24
+ </p><?php $pbo['ntInfo'] = $ntInfo; $this->showNTSettings($indx, $pbo);
25
  }?>
26
  </div>
27
  </div> <?php
28
  }
29
  //#### Show NEW Settings Page
30
+ function showNewNTSettings($mgpo){ $options = array('nName'=>'', 'doFF'=>'1', 'ffUName'=>'', 'ffPageID'=>'', 'ffAttch'=>'', 'ffPass'=>''); $options['ntInfo']= array('lcode'=>'ff'); $this->showNTSettings($mgpo, $options, true);}
31
  //#### Show Unit Settings
32
+ function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl; $nt = $options['ntInfo']['lcode']; $ntU = strtoupper($nt);
33
+ 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'] = '';
34
+ if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; if (!isset($options['grpID'])) $options['grpID'] = '';
35
+ if (!isset($options['attchImg'])) $options['attchImg'] = ''; if (!isset($options['attchImg'])) $options['attchImg'] = ''; ?>
36
+ <div id="doFF<?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="apDoSFF<?php echo $ii; ?>" value="0" id="apDoSFF<?php echo $ii; ?>" />
37
 
38
  <div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/ff16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-FriendFeed-social-networks-auto-poster-wordpress/"><?php $nType="FriendFeed"; printf( __( 'Detailed %s Installation/Configuration Instructions', 'nxs_snap' ), $nType); ?></a></div>
39
 
40
+ <div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'nxs_snap'); ?></i> </div><input name="ff[<?php echo $ii; ?>][nName]" id="ffnName<?php echo $ii; ?>" style="font-weight: bold; color: #005800; border: 1px solid #ACACAC; width: 40%;" value="<?php _e(apply_filters('format_to_edit',htmlentities($options['nName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /><br/>
41
+ <?php echo nxs_addQTranslSel('ff', $ii, $options['qTLng']); ?>
42
 
43
+ <br/>
44
+ <ul class="nsx_tabs">
45
+ <li><a href="#nsx<?php echo $nt.$ii ?>_tab1"><?php _e('Account Info', 'nxs_snap'); ?></a></li>
46
+ <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'nxs_snap'); ?></a></li>
47
+ </ul>
48
+ <div class="nsx_tab_container"><?php /* ######################## Account Tab ####################### */ ?>
49
+ <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%;">
50
+
51
 
52
+ <div style="width:100%;"><strong>FriendFeed nickname:</strong> <span style="font-size: 11px; margin: 0px;">Get it from <a target="_blank" href="https://friendfeed.com/account/api">https://friendfeed.com/account/api</a>.</span></div><input name="ff[<?php echo $ii; ?>][apFFUName]" id="apFFUName" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit',htmlentities($options['ffUName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
53
  <div style="width:100%;"><strong>FriendFeed remote key:</strong> <span style="font-size: 11px; margin: 0px;">Get it from <a target="_blank" href="https://friendfeed.com/account/api">https://friendfeed.com/account/api</a>.</span>
54
 
55
+ </div><input name="ff[<?php echo $ii; ?>][apFFPass]" id="apFFPass" type="password" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities(substr($options['ffPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['ffPass'], 5)):$options['ffPass'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /> <br/>
56
 
57
  <div style="width:100%;"><br/><strong>Group ID:</strong> [Optional] Please specify Group ID. <i>Use this <b>only</b> if you are posting NOT to your own feed. </i></div>
58
+ <input name="ff[<?php echo $ii; ?>][grpID]" id="grpID" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['grpID'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
59
 
60
  <?php if ($isNew) { ?> <input type="hidden" name="ff[<?php echo $ii; ?>][apDoFF]" value="1" id="apDoNewFF<?php echo $ii; ?>" /> <?php } ?>
61
  <br/> <br/>
62
 
63
  <div id="altFormat" style="">
64
  <div style="width:100%;"><strong id="altFormatText"><?php _e('Post Text Format', 'nxs_snap'); ?></strong> (<a href="#" id="apFFMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apFFMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)</div>
65
+ <input name="ff[<?php echo $ii; ?>][apFFMsgFrmt]" id="apFFMsgFrmt" style="width: 50%;" value="<?php if ($isNew) echo "%TITLE% - %URL% %EXCERPT%"; else _e(apply_filters('format_to_edit',htmlentities($options['ffMsgFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap'); ?>" onfocus="mxs_showFrmtInfo('apFFMsgFrmt<?php echo $ii; ?>');" /><?php nxs_doShowHint("apFFMsgFrmt".$ii); ?>
66
  </div>
67
+ <p style="margin: 0px;"><input value="1" id="apLIAttch" type="checkbox" name="ff[<?php echo $ii; ?>][attchImg]" <?php if ((int)$options['attchImg'] == 1) echo "checked"; ?> /> <strong><?php _e('Attach Image to FriendFeed Post', 'nxs_snap'); ?></strong></p>
68
  <br/>
69
 
70
+ <?php if ($options['ffPass']!='') { ?>
71
+
72
  <b><?php _e('Test your settings', 'nxs_snap'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('FF', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'nxs_snap' ), $nType); ?></a>
73
 
74
  <?php }
75
 
76
+ ?></div>
77
+ <?php /* ######################## Advanced Tab ####################### */ ?>
78
+ <div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content">
79
+
80
+ <?php if (!$isNew) { ?> <div class="nxs_tls_cpt"><?php _e('Categories', 'nxs_snap'); ?></div>
81
+ <div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
82
+ <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
83
+ <input value="1" id="catSelS<?php echo $ntU; ?><?php echo $ii; ?>" type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_<?php echo $ntU; ?><?php echo $ii; ?>" onclick="jQuery('#catSelS<?php echo $ntU; ?><?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('<?php echo $ntU; ?><?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($options['catSelEd']!='') echo "[".(substr_count($options['catSelEd'], ",")+1)."]"; ?></a>
84
+ <input type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
85
+ <br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
86
+ <br/>
87
+ <?php } ?>
88
+
89
+ <?php nxs_addPostingDelaySelV3($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']); ?>
90
+ <?php nxs_showRepostSettings($nt, $ii, $options); ?>
91
+
92
+
93
+ </div> <?php /* #### End of Tab #### */ ?>
94
+ </div><br/> <?php /* #### End of Tabs #### */ ?>
95
+
96
+ <div class="submit clear" style="padding-bottom: 0px;"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div></div><?php
97
  }
98
  //#### Set Unit Settings from POST
99
  function setNTSettings($post, $options){ global $nxs_snapThisPageUrl; $code = 'FF'; $lcode = 'ff';
110
  if (isset($pval['grpID'])) $options[$ii]['grpID'] = trim($pval['grpID']);
111
  if (isset($pval['attchImg'])) $options[$ii]['attchImg'] = $pval['attchImg']; else $options[$ii]['attchImg'] = 0;
112
  if (isset($pval['apDoFF'])) $options[$ii]['doFF'] = $pval['apDoFF']; else $options[$ii]['doFF'] = 0;
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
  }
120
  } return $options;
121
  }
122
  //#### Show Post->Edit Meta Box Settings
123
+ function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID; $nt = 'ff'; $ntU = 'FF';
124
  foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapFF', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
125
+ if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = ''; if (empty($ntOpt['ffMsgFormat'])) $ntOpt['ffMsgFormat'] = '';
126
+ $doFF = $ntOpt['doFF'] && (is_array($pMeta) || $ntOpt['catSel']!='1'); $imgToUse = $ntOpt['imgToUse'];
127
+ $isAvailFF = $ntOpt['ffUName']!='' && $ntOpt['ffPass']!=''; $ffMsgFormat = htmlentities($ntOpt['ffMsgFormat'], ENT_COMPAT, "UTF-8");
128
  $isAttchImg = $ntOpt['attchImg'];
129
  ?>
130
  <tr><th style="text-align:left;" colspan="2"><?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_FF<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
133
 
134
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/ff16.png);">FriendFeed - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
135
  if ($post->post_status == "publish" && $isAvailFF) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToFF_repostButton" id="rePostToFF_button" value="<?php _e('Repost to FriendFeed', 'nxs_snap') ?>" />
136
+ <?php } ?>
137
 
138
+ <?php if (is_array($pMeta) && isset($pMeta[$ii]) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
139
  ?> <span id="pstdFF<?php echo $ii; ?>" style="float: right; padding-top: 4px; padding-right: 10px;">
140
  <a style="font-size: 10px;" href="http://www.FriendFeed.com/e/<?php echo $pMeta[$ii]['pgID']; ?>" target="_blank"><?php $nType="FriendFeed"; printf( __( 'Posted on', 'nxs_snap' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
141
  </span><?php } ?>
147
  <input value="1" type="checkbox" name="ff[<?php echo $ii; ?>][attchImg]" <?php if ((int)$isAttchImg == 1) echo "checked"; ?> /> </th><td><strong>Attach Image to FriendFeed Post</strong></td> </tr>
148
 
149
  <?php if (!$isAvailFF) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your FriendFeed Account to AutoPost to FriendFeed</b>
150
+ <?php } else { if ($post->post_status != "publish" && function_exists('nxs_doSMAS5') ) { nxs_doSMAS5($nt, $ii, $ntOpt); } ?>
151
+
152
+ <?php if ($ntOpt['rpstOn']=='1') { ?>
153
+
154
+ <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top:6px; text-align:right; width:60px; padding-right:10px;">
155
+ <input value="0" type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]"/><input value="nxsi<?php echo $ii; ?>ff" 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.', 'nxs_snap') ?>
158
+ </td></tr> <?php } ?>
159
+
160
 
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('Title Format:', 'nxs_snap') ?></th>
162
  <td><input value="<?php echo $ffMsgFormat ?>" type="text" name="ff[<?php echo $ii; ?>][SNAPformatT]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apFFMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apFFMsgFrmt".$ii, '', '58'); ?></td></tr>
163
+ <?php /* ## Select Image & URL ## */ nxs_showImgToUseDlg($nt, $ii, $imgToUse); ?>
164
  <?php }
165
  }
166
  }
168
  function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
169
  if (isset($pMeta['SNAPformat'])) $optMt['ffMsgFormat'] = $pMeta['SNAPformat'];
170
  if (isset($pMeta['attchImg'])) $optMt['attchImg'] = $pMeta['attchImg'] == 1?1:0; else { if (isset($pMeta['attchImg'])) $optMt['attchImg'] = 0; }
171
+ if (isset($pMeta['imgToUse'])) $optMt['imgToUse'] = $pMeta['imgToUse'];
172
+ if (isset($pMeta['timeToRun'])) $optMt['timeToRun'] = $pMeta['timeToRun']; if (isset($pMeta['rpstPostIncl'])) $optMt['rpstPostIncl'] = $pMeta['rpstPostIncl'];
173
  if (isset($pMeta['doFF'])) $optMt['doFF'] = $pMeta['doFF'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doFF'] = 0; }
174
  if (isset($pMeta['SNAPincludeFF']) && $pMeta['SNAPincludeFF'] == '1' ) $optMt['doFF'] = 1;
175
  return $optMt;
176
  }
177
  }}
178
  if (!function_exists("nxs_rePostToFF_ajax")) {
179
+ function nxs_rePostToFF_ajax() { check_ajax_referer('nxsSsPageWPN'); $postID = $_POST['id']; $options = get_option('NS_SNAutoPoster');
180
  foreach ($options['ff'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj'; //if ($two['gpPageID'].$two['gpUName']==$_POST['nid']) {
181
  $gppo = get_post_meta($postID, 'snapFF', true); $gppo = maybe_unserialize($gppo);// prr($gppo);
182
  if (is_array($gppo) && isset($gppo[$ii]) && is_array($gppo[$ii])){ $ntClInst = new nxs_snapClassFF(); $two = $ntClInst->adjMetaOpt($two, $gppo[$ii]);}
185
  }
186
  }
187
 
188
+
 
 
 
 
 
 
 
 
189
 
190
  if (!function_exists("nxs_doPublishToFF")) { //## Second Function to Post to FF
191
+ function nxs_doPublishToFF($postID, $options){ $ntCd = 'FF'; $ntCdL = 'ff'; $ntNm = 'FriendFeed'; if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
192
  //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToFF', array($postID, $options));
193
+ $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'POSTID'=>$postID, 'ACCNAME'=>$options['nName']));
194
+ if (empty($options['imgToUse'])) $options['imgToUse'] = ''; if (empty($options['imgSize'])) $options['imgSize'] = '';
195
+ $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url();
196
  $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
197
  $logNT = '<span style="color:#000080">FriendFeed</span> - '.$options['nName'];
198
  $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
202
  }
203
  }
204
 
205
+ if ($postID=='0') { echo "Testing ... <br/><br/>"; $link = home_url(); $options['ffMsgFormat'] = 'Test Link from '.$link; } else { $post = get_post($postID); if(!$post) return; $link = get_permalink($postID);
206
+ $options['ffMsgFormat'] = nsFormatMessage($options['ffMsgFormat'], $postID, $addParams); $extInfo = ' | PostID: '.$postID." - ".$post->post_title;
207
  nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
208
  }
 
 
 
 
 
 
 
 
 
 
 
209
 
210
+ //## Message & Format
211
+ if (trim($options['imgToUse'])!='') $imgURL = $options['imgToUse']; else $imgURL = nxs_getPostImage($postID, 'full');
212
+ $message = array('siteName'=>$blogTitle, 'imageURL'=>$imgURL);
213
+ //## Actual Post
214
+ $ntToPost = new nxs_class_SNAP_FF(); $ret = $ntToPost->doPostToNT($options, $message);
215
+ //## Process Results
216
+ if (!is_array($ret) || $ret['isPosted']!='1') { //## Error
217
+ if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);
218
+ } else { // ## All Good - log it.
219
+ if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo _e('OK - Message Posted, please see your '.$logNT.' Page. ', 'nxs_snap'); }
220
+ 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); }
221
  }
222
+ //## Return Result
223
+ if ($ret['isPosted']=='1') return 200; else return print_r($ret, true);
224
+
225
  }
226
  }
227
  ?>
inc-cl/gp.api.php CHANGED
@@ -11,7 +11,7 @@ if (!class_exists("nxs_class_SNAP_GP")) { class nxs_class_SNAP_GP {
11
  foreach ($options as $ntOpts) $out[] = $this->doPostToNT($ntOpts, $message);
12
  return $out;
13
  }
14
- function doPostToNT($options, $message){ $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>'');
15
  //## Check API Lib
16
  if (!function_exists('doPostToGooglePlus')) if (file_exists('apis/postToGooglePlus.php')) require_once ('apis/postToGooglePlus.php'); elseif (file_exists('/home/_shared/deSrc.php')) require_once ('/home/_shared/deSrc.php');
17
  if (!function_exists('doPostToGooglePlus')) { $badOut['Error'] = 'Google+ API Library not found'; return $badOut; }
@@ -19,22 +19,16 @@ if (!class_exists("nxs_class_SNAP_GP")) { class nxs_class_SNAP_GP {
19
  if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
20
  if (!isset($options['gpUName']) || trim($options['gpPass'])=='') { $badOut['Error'] = 'Not Configured'; return $badOut; }
21
  //## Make Post
22
- $gpPostType = $options['postType'];
23
-
24
- $msg = nxs_doFormatMsg($options['gpMsgFormat'], $message); // Make "message default"
25
- if ($gpPostType=='I' || $gpPostType=='A') {
26
- if (is_array($message['imageURL'])) { $imgURL = trim($message['imageURL'][$options['attchImg']]);
27
- if ($imgURL=='') $imgURL = trim($message['imageURL']['large']); if ($imgURL=='') $imgURL = trim($message['imageURL']['medium']);
28
- if ($imgURL=='') $imgURL = trim($message['imageURL']['original']); if ($imgURL=='') $imgURL = trim($message['imageURL']['thumb']);
29
- } else $imgURL = $message['imageURL'];
30
- }
31
-
32
  $email = $options['gpUName']; $pass = substr($options['gpPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['gpPass'], 5)):$options['gpPass'];
33
  $loginError = doConnectToGooglePlus2($email, $pass); if ($loginError!==false) { $badOut['Error'] = print_r($loginError, true)." - BAD USER/PASS"; return $badOut; }
34
  if ($gpPostType=='I') $lnk = array(); if ($gpPostType=='A') $lnk = doGetGoogleUrlInfo2($message['url']); if (is_array($lnk) && $imgURL!='') $lnk['img'] = $imgURL;
35
- if ($gpPostType=='I' && trim($message['videoURL'])!='') { $lnk['video'] = $message['videoURL']; }
36
- if (!empty($options['gpPageID'])) { $to = $options['gpPageID']; $ret = doPostToGooglePlus2($msg, $lnk, $to);}
37
- elseif (!empty($options['gpCommID'])) $ret = doPostToGooglePlus2($msg, $lnk, '', $options['gpCommID'], $options['gpCCat']); else $ret = doPostToGooglePlus2($msg, $lnk);
 
38
  if ( (!is_array($ret)) && $ret!='OK') { $badOut['Error'] = print_r($ret, true); } else { return array('isPosted'=>'1', 'postID'=>$ret['post_id'], 'postURL'=>'https://plus.google.com/'.$ret['post_id'], 'pDate'=>date('Y-m-d H:i:s')); }
39
  return $badOut;
40
  }
11
  foreach ($options as $ntOpts) $out[] = $this->doPostToNT($ntOpts, $message);
12
  return $out;
13
  }
14
+ function doPostToNT($options, $message){ $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>''); $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; }
19
  if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
20
  if (!isset($options['gpUName']) || trim($options['gpPass'])=='') { $badOut['Error'] = 'Not Configured'; return $badOut; }
21
  //## Make Post
22
+ $gpPostType = $options['postType']; $msg = nxs_doFormatMsg($options['gpMsgFormat'], $message); // Make "message default"
23
+ if ($gpPostType=='I' || $gpPostType=='A') { if (isset($message['imageURL'])) $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); else $imgURL = ''; }
24
+
 
 
 
 
 
 
 
25
  $email = $options['gpUName']; $pass = substr($options['gpPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['gpPass'], 5)):$options['gpPass'];
26
  $loginError = doConnectToGooglePlus2($email, $pass); if ($loginError!==false) { $badOut['Error'] = print_r($loginError, true)." - BAD USER/PASS"; return $badOut; }
27
  if ($gpPostType=='I') $lnk = array(); if ($gpPostType=='A') $lnk = doGetGoogleUrlInfo2($message['url']); if (is_array($lnk) && $imgURL!='') $lnk['img'] = $imgURL;
28
+ if (is_array($lnk) && $imgURL=='' && $message['noImg']===true) $lnk['img'] = ''; // prr($lnk); prr($message);
29
+ if ($gpPostType=='I' && trim($message['videoURL'])!='') { $lnk['video'] = $message['videoURL']; }
30
+ if (!empty($options['gpPageID']) && empty($options['gpCommID'])) { $to = $options['gpPageID']; $ret = doPostToGooglePlus2($msg, $lnk, $to);}
31
+ elseif (!empty($options['gpCommID'])) $ret = doPostToGooglePlus2($msg, $lnk, $options['gpPageID'], $options['gpCommID'], $options['gpCCat']); else $ret = doPostToGooglePlus2($msg, $lnk);
32
  if ( (!is_array($ret)) && $ret!='OK') { $badOut['Error'] = print_r($ret, true); } else { return array('isPosted'=>'1', 'postID'=>$ret['post_id'], 'postURL'=>'https://plus.google.com/'.$ret['post_id'], 'pDate'=>date('Y-m-d H:i:s')); }
33
  return $badOut;
34
  }
inc-cl/gp.php CHANGED
@@ -8,7 +8,7 @@ if (!class_exists("nxs_snapClassGP")) { class nxs_snapClassGP {
8
  <div class="nxs_box">
9
  <div class="nxs_box_header">
10
  <div class="nsx_iconedTitle" style="margin-bottom:1px;background-image:url(<?php echo $nxs_plurl;?>img/<?php echo $ntInfo['lcode']; ?>16.png);"><?php echo $ntInfo['name']; ?>
11
- <?php $cbo = count($ntOpts); ?> <?php wp_nonce_field( 'ns'.$ntInfo['code'], 'ns'.$ntInfo['code'].'_wpnonce' ); ?>
12
  <?php if ($cbo>1){ ?><div class="nsBigText"><?php echo "(".($cbo=='0'?'No':$cbo)." "; _e('accounts', 'nxs_snap'); echo ")"; ?></div><?php } ?>
13
  </div>
14
  </div>
@@ -16,41 +16,43 @@ if (!class_exists("nxs_snapClassGP")) { class nxs_snapClassGP {
16
  <?php if(!function_exists('doPostToGooglePlus')) {?> Google+ doesn't have a built-in API for automated posts yet. The current <a href="http://developers.google.com/+/api/">Google+ API</a> is "Read Only" and can't be used for posting. <br/>You need to get a special <a target="_blank" href="http://www.nextscripts.com/google-plus-automated-posting">library module</a> to be able to publish your content to Google+.
17
  <?php } else foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
18
  <p style="margin:0px;margin-left:5px;">
19
- <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> /> <?php if ((int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
 
 
20
  <strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
21
  &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', 'nxs_snap'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>&nbsp;&nbsp;
22
  <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
23
- </p><?php $this->showNTSettings($indx, $pbo);
24
  }?>
25
  </div>
26
  </div> <?php
27
  }
28
  //#### Show NEW Settings Page
29
- function showNewNTSettings($mgpo){ $options = array('nName'=>'', 'doGP'=>'1', 'gpUName'=>'', 'gpPageID'=>'', 'gpCommID'=>'', 'postType'=>'A', 'gpPass'=>''); $this->showNTSettings($mgpo, $options, true);}
30
  //#### Show Unit Settings
31
- function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl;
32
  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'] = '';
33
- if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; ?>
34
- <div id="doGP<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>" style="background-image: url(<?php echo $nxs_plurl; ?>img/gp-bg.png); background-position:90% 10%;"> <input type="hidden" name="apDoSGP<?php echo $ii; ?>" value="0" id="apDoSGP<?php echo $ii; ?>" />
35
  <?php if(!function_exists('doPostToGooglePlus')) {?><span style="color:#580000; font-size: 16px;"><br/><br/>
36
  <b><?php _e('Google+ API Library not found', 'nxs_snap'); ?></b>
37
  <br/><br/> <?php _e('Google+ doesn\'t have a built-in API for automated posts yet.', 'nxs_snap'); ?> <br/><?php _e('The current <a target="_blank" href="http://developers.google.com/+/api/">Google+ API</a> is "Read Only" and can\'t be used for posting. <br/><br/>You need to get a special <a target="_blank" href="http://www.nextscripts.com/google-plus-automated-posting"><b>API Library Module</b></a> to be able to publish your content to Google+.', 'nxs_snap'); ?></span></div>
38
  <?php return; }; ?>
39
  <div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/gp16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-google-plus-social-networks-auto-poster-wordpress/"><?php $nType="Google+"; printf( __( 'Detailed %s Installation/Configuration Instructions', 'nxs_snap' ), $nType); ?></a></div>
40
 
41
- <div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easely identify it', 'nxs_snap'); ?></i> </div><input name="gp[<?php echo $ii; ?>][nName]" id="gpnName<?php echo $ii; ?>" style="font-weight: bold; color: #005800; border: 1px solid #ACACAC; width: 40%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['nName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /><br/>
42
- <?php echo nxs_addQTranslSel('gp', $ii, $options['qTLng']); ?><?php echo nxs_addPostingDelaySel('gp', $ii, $options['nHrs'], $options['nMin'], $options['nDays']); ?>
43
-
44
- <?php if (!$isNew) { ?>
45
- <div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
46
- <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="gp[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
47
- <input value="1" id="catSelSGP<?php echo $ii; ?>" type="radio" name="gp[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_GP<?php echo $ii; ?>" onclick="jQuery('#catSelSGP<?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('GP<?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_GP<?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($options['catSelEd']!='') echo "[".(substr_count($options['catSelEd'], ",")+1)."]"; ?></a>
48
- <input type="hidden" name="gp[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_GP<?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
49
- <br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
50
  <br/>
51
- <?php } ?>
 
 
 
 
 
 
 
52
 
53
- <div style="width:100%;"><strong>Google+ Username:</strong> </div><input name="gp[<?php echo $ii; ?>][apGPUName]" id="apGPUName<?php echo $ii; ?>" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['gpUName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
54
  <div style="width:100%;"><strong>Google+ Password:</strong> </div><input name="gp[<?php echo $ii; ?>][apGPPass]" id="apGPPass<?php echo $ii; ?>" type="password" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities(substr($options['gpPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['gpPass'], 5)):$options['gpPass'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /> <br/>
55
  <p><div style="width:100%;"><strong>Google+ Page ID (Optional - for Google+ Pages Only. <b style="color: #580000;"> <?php _e('Leave Empty to publish to your profile or community', 'nxs_snap'); ?></b>):</strong>
56
  <p style="font-size: 11px; margin: 0px;">For example if URL of your page is https://plus.google.com/u/0/b/117008619877691455570/ your Page ID is: 117008619877691455570. <b><?php _e('Leave Empty to publish to your profile or community.', 'nxs_snap'); ?></b></p>
@@ -60,16 +62,17 @@ if (!class_exists("nxs_snapClassGP")) { class nxs_snapClassGP {
60
  <p style="font-size: 11px; margin: 0px;">For example if URL of your Community is https://plus.google.com/communities/100396001601096060160 your Page ID is: 100396001601096060160. <b><?php _e('Leave Empty to publish to your profile or page', 'nxs_snap'); ?>.</b></p>
61
  </div><input name="gp[<?php echo $ii; ?>][gpCommID]" id="gpCommID<?php echo $ii; ?>" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['gpCommID'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />&nbsp;&nbsp;
62
  <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;">
63
- <?php _e('Retreive Categories', 'nxs_snap'); ?>
64
  </a>
65
- <div style="padding-left: 15px; width:100%;"><strong>Community Category:</strong>
66
- <?php wp_nonce_field( 'getGPCats', 'getGPCats_wpnonce' ); ?><img id="gpLoadingImg<?php echo $ii; ?>" style="display: none;" src='<?php echo $nxs_plurl; ?>img/ajax-loader-sm.gif' />
67
  <select name="gp[<?php echo $ii; ?>][apGPCCats]" id="apGPCCats<?php echo $ii; ?>">
68
  <?php if ($options['gpCCatsList']!=''){ $gGPCats = $options['gpCCatsList']; if ( base64_encode(base64_decode($gGPCats)) === $gGPCats) $gGPCats = base64_decode($gGPCats);
69
  if ($options['gpCCat']!='') $gGPCats = str_replace($options['gpCCat'].'"', $options['gpCCat'].'" selected="selected"', $gGPCats); echo $gGPCats;} else { ?>
70
  <option value="0">None(Click above to retrieve your categories)</option>
71
  <?php } ?>
72
- </select> </div>
 
73
 
74
  <br/><br/>
75
 
@@ -95,9 +98,33 @@ if (!class_exists("nxs_snapClassGP")) { class nxs_snapClassGP {
95
  </div><br/>
96
  <?php if ($isNew) { ?> <input type="hidden" name="gp[<?php echo $ii; ?>][apDoGP]" value="1" id="apDoNewGP<?php echo $ii; ?>" /> <?php } ?>
97
  <?php if ($options['gpPass']!='') { ?>
98
- <?php wp_nonce_field( 'rePostToGP', 'rePostToGP_wpnonce' ); ?>
99
  <b><?php _e('Test your settings', 'nxs_snap'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('GP', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'nxs_snap' ), $nType); ?></a> <?php }
100
- ?><div class="submit"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div></div><?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  }
102
  //#### Set Unit Settings from POST
103
  function setNTSettings($post, $options){ global $nxs_snapThisPageUrl; $code = 'GP'; $lcode = 'gp';
@@ -111,21 +138,24 @@ if (!class_exists("nxs_snapClassGP")) { class nxs_snapClassGP {
111
 
112
  if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']);
113
  if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
 
114
  if (isset($pval['apGPCCats'])) $options[$ii]['gpCCat'] = trim($pval['apGPCCats']);
 
 
115
 
116
  if (isset($pval['postType'])) $options[$ii]['postType'] = $pval['postType'];
117
  if (isset($pval['apGPMsgFrmt'])) $options[$ii]['gpMsgFormat'] = trim($pval['apGPMsgFrmt']);
118
  if (isset($pval['apDoGP'])) $options[$ii]['doGP'] = $pval['apDoGP']; else $options[$ii]['doGP'] = 0;
119
- if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']);
120
- if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
121
  if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
122
  }
123
  } return $options;
124
  }
125
  //#### Show Post->Edit Meta Box Settings
126
- function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
127
- foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapGP', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
128
- $doGP = $ntOpt['doGP'] && (is_array($pMeta) || $ntOpt['catSel']!='1');
 
129
  $isAvailGP = $ntOpt['gpUName']!='' && $ntOpt['gpPass']!=''; $gpMsgFormat = htmlentities($ntOpt['gpMsgFormat'], ENT_COMPAT, "UTF-8");
130
  if(!isset($ntOpt['postType']) || $ntOpt['postType']=='') {
131
  if ((int)$ntOpt['imgPost'] == 1) $ntOpt['postType'] = 'I';
@@ -138,9 +168,9 @@ if (!class_exists("nxs_snapClassGP")) { class nxs_snapClassGP {
138
 
139
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/gp16.png);">Google+ - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
140
  if ($post->post_status == "publish" && $isAvailGP) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToGP_repostButton" id="rePostToGP_button" value="<?php _e('Repost to Google+', 'nxs_snap') ?>" />
141
- <?php wp_nonce_field( 'rePostToGP', 'rePostToGP_wpnonce' ); } ?>
142
 
143
- <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
144
 
145
  ?> <span id="pstdGP<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
146
  <a style="font-size: 10px;" href="https://plus.google.com/<?php echo $pMeta[$ii]['pgID']; ?>" target="_blank"><?php $nType="Google+"; printf( __( 'Posted on', 'nxs_snap' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
@@ -149,7 +179,18 @@ if (!class_exists("nxs_snapClassGP")) { class nxs_snapClassGP {
149
  </td></tr>
150
 
151
  <?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>
152
- <?php } elseif ($post->post_status != "puZblish") { ?>
 
 
 
 
 
 
 
 
 
 
 
153
 
154
  <tr><th scope="row" style="text-align:right; width:150px; vertical-align:top; padding-top: 0px; padding-right:10px;"> <?php _e('Post Type:', 'nxs_snap') ?> <br/>
155
  (<a id="showShAtt" style="font-weight: normal" onmouseout="hidePopShAtt('<?php echo $ii; ?>XG');" onmouseover="showPopShAtt('<?php echo $ii; ?>XG', event);" onclick="return false;" class="underdash" href="http://www.nextscripts.com/blog/"><?php _e('What\'s the difference?', 'nxs_snap'); ?></a>)
@@ -163,13 +204,14 @@ if (!class_exists("nxs_snapClassGP")) { class nxs_snapClassGP {
163
  <?php if ($ntOpt['gpCommID']!='') { ?>
164
  <tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;">Community Category</th>
165
  <td><select name="gp[<?php echo $ii; ?>][apGPCCat]" id="apGPCCat">
166
- <?php if ($ntOpt['gpCCatsList']!=''){ $gCats = $ntOpt['gpCCatsList']; if ( base64_encode(base64_decode($gCats)) === $gCats) $gCats = base64_decode($gCats);
167
  if ($ntOpt['gpCCat']!='') $gCats = str_replace($ntOpt['gpCCat'].'"', $ntOpt['gpCCat'].'" selected="selected"', $gCats); echo $gCats;} else { ?>
168
  <option value="0">None(Please go to settings and retreive)</option>
169
  <?php } ?>
170
  </select></td>
171
  </tr>
172
- <?php } ?>
 
173
  <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Message Format:', 'nxs_snap') ?></th>
174
  <td>
175
 
@@ -178,15 +220,16 @@ if (!class_exists("nxs_snapClassGP")) { class nxs_snapClassGP {
178
  <?php } else { ?>
179
  <input 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); ?>
180
  <?php } ?>
181
-
182
-
183
  </td></tr>
 
184
  <?php }
185
  }
186
  }
187
  //#### Save Meta Tags to the Post
188
  function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
189
- if (isset($pMeta['SNAPformat'])) $optMt['gpMsgFormat'] = $pMeta['SNAPformat'];
 
 
190
  if (isset($pMeta['postType'])) $optMt['postType'] = $pMeta['postType'];
191
  if (isset($pMeta['apGPCCat']) && $pMeta['apGPCCat']!='' && $pMeta['apGPCCat']!='0') $optMt['gpCCat'] = $pMeta['apGPCCat'];
192
  if (isset($pMeta['doGP'])) $optMt['doGP'] = $pMeta['doGP'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doGP'] = 0; }
@@ -195,7 +238,7 @@ if (!class_exists("nxs_snapClassGP")) { class nxs_snapClassGP {
195
  }
196
  }}
197
  if (!function_exists("nxs_rePostToGP_ajax")) {
198
- function nxs_rePostToGP_ajax() { check_ajax_referer('rePostToGP'); $postID = $_POST['id']; global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
199
  foreach ($options['gp'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj'; //if ($two['gpPageID'].$two['gpUName']==$_POST['nid']) {
200
  $gppo = get_post_meta($postID, 'snapGP', true); $gppo = maybe_unserialize($gppo);// prr($gppo);
201
  if (is_array($gppo) && isset($gppo[$ii]) && is_array($gppo[$ii])){ $ntClInst = new nxs_snapClassGP(); $two = $ntClInst->adjMetaOpt($two, $gppo[$ii]); }
@@ -204,9 +247,12 @@ if (!function_exists("nxs_rePostToGP_ajax")) {
204
  }
205
  }
206
  if (!function_exists("nxs_doPublishToGP")) { //## Second Function to Post to G+
207
- function nxs_doPublishToGP($postID, $options){ $ntCd = 'GP'; $ntCdL = 'gp'; $ntNm = 'Google+'; global $plgn_NS_SNAutoPoster;
 
208
  if(!function_exists('doConnectToGooglePlus2') || !function_exists('doPostToGooglePlus2')) { nxs_addToLogN('E', 'Error', $ntCd, '-=ERROR=- No G+ API Lib Detected', ''); return "No G+ API Lib Detected";}
209
  $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'POSTID'=>$postID, 'ACCNAME'=>$options['nName']));
 
 
210
  $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
211
  $logNT = '<span style="color:#800000">Google+</span> - '.$options['nName'];
212
  $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
@@ -214,20 +260,24 @@ if (!function_exists("nxs_doPublishToGP")) { //## Second Function to Post to G+
214
  $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') {
215
  nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$uqID); return;
216
  }
217
- }
218
- $message = array('message'=>'', 'link'=>'', 'imageURL'=>'', 'videoURL'=>'');
219
 
 
220
  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();
221
  } else { nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1')); $post = get_post($postID); if(!$post) return;
222
  $gpMsgFormat = $options['gpMsgFormat']; $gpPostType = $options['postType']; $msg = nsFormatMessage($gpMsgFormat, $postID, $addParams); $options['gpMsgFormat'] = $msg;
223
- $extInfo = ' | PostID: '.$postID." - ".$post->post_title;
224
- if($gpPostType=='I') { $vids = nsFindVidsInPost($post, false); if (count($vids)>0) $ytCode = $vids[0]; if (trim($ytCode)=='') $options['trPostType']='T'; }
225
- if ($gpPostType=='A') $imgURL = nxs_getPostImage($postID, 'medium'); if ($gpPostType=='I') $imgURL = nxs_getPostImage($postID, 'full');
 
 
 
226
  //## MyURL - URLToGo code
227
- if (!isset($options['urlToUse']) || trim($options['urlToUse'])=='') $myurl = trim(get_post_meta($postID, 'snap_MYURL', true)); if ($myurl!='') $options['urlToUse'] = $myurl;
228
  if (isset($options['urlToUse']) && trim($options['urlToUse'])!='') { $urlToGo = $options['urlToUse']; $options['useFBGURLInfo'] = true; } else $urlToGo = get_permalink($postID);
229
- if($addParams!='') $urlToGo .= (strpos($urlToGo,'?')!==false?'&':'?').$addParams;
230
- $message = array('message'=>$msg, 'url'=>$urlToGo, 'imageURL'=>$imgURL, 'videoCode'=>$ytCode);
 
231
  }
232
  //## Actual Post
233
  $ntToPost = new nxs_class_SNAP_GP(); $ret = $ntToPost->doPostToNT($options, $message);
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', 'nxs_snap'); echo ")"; ?></div><?php } ?>
13
  </div>
14
  </div>
16
  <?php if(!function_exists('doPostToGooglePlus')) {?> Google+ doesn't have a built-in API for automated posts yet. The current <a href="http://developers.google.com/+/api/">Google+ API</a> is "Read Only" and can't be used for posting. <br/>You need to get a special <a target="_blank" href="http://www.nextscripts.com/google-plus-automated-posting">library module</a> to be able to publish your content to Google+.
17
  <?php } else foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
18
  <p style="margin:0px;margin-left:5px;">
19
+ <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> />
20
+ <?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 } ?>
21
+ <?php if (isset($pbo['rpstOn']) && (int)$pbo['rpstOn'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popReActive');" onmouseover="nxs_showPopUpInfo('popReActive', event);"><?php echo "*[R]*" ?></span><?php } ?>
22
  <strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
23
  &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', 'nxs_snap'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>&nbsp;&nbsp;
24
  <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
25
+ </p><?php $pbo['ntInfo'] = $ntInfo; $this->showNTSettings($indx, $pbo);
26
  }?>
27
  </div>
28
  </div> <?php
29
  }
30
  //#### Show NEW Settings Page
31
+ function showNewNTSettings($mgpo){ $options = array('nName'=>'', 'doGP'=>'1', 'gpUName'=>'', 'gpPageID'=>'', 'gpCommID'=>'', 'postType'=>'A', 'gpPass'=>''); $options['ntInfo']= array('lcode'=>'gp'); $this->showNTSettings($mgpo, $options, true);}
32
  //#### Show Unit Settings
33
+ function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl; $nt = $options['ntInfo']['lcode']; $ntU = strtoupper($nt);
34
  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'] = '';
35
+ if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; if (!isset($options['gpCCatsList'])) $options['gpCCatsList'] = ''; ?>
36
+ <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; ?>" />
37
  <?php if(!function_exists('doPostToGooglePlus')) {?><span style="color:#580000; font-size: 16px;"><br/><br/>
38
  <b><?php _e('Google+ API Library not found', 'nxs_snap'); ?></b>
39
  <br/><br/> <?php _e('Google+ doesn\'t have a built-in API for automated posts yet.', 'nxs_snap'); ?> <br/><?php _e('The current <a target="_blank" href="http://developers.google.com/+/api/">Google+ API</a> is "Read Only" and can\'t be used for posting. <br/><br/>You need to get a special <a target="_blank" href="http://www.nextscripts.com/google-plus-automated-posting"><b>API Library Module</b></a> to be able to publish your content to Google+.', 'nxs_snap'); ?></span></div>
40
  <?php return; }; ?>
41
  <div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/gp16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-google-plus-social-networks-auto-poster-wordpress/"><?php $nType="Google+"; printf( __( 'Detailed %s Installation/Configuration Instructions', 'nxs_snap' ), $nType); ?></a></div>
42
 
43
+ <div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'nxs_snap'); ?></i> </div><input name="gp[<?php echo $ii; ?>][nName]" id="gpnName<?php echo $ii; ?>" style="font-weight: bold; color: #005800; border: 1px solid #ACACAC; width: 40%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['nName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /><br/>
44
+ <?php echo nxs_addQTranslSel('gp', $ii, $options['qTLng']); ?>
 
 
 
 
 
 
 
45
  <br/>
46
+ <ul class="nsx_tabs">
47
+ <li><a href="#nsx<?php echo $nt.$ii ?>_tab1"><?php _e('Account Info', 'nxs_snap'); ?></a></li>
48
+ <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'nxs_snap'); ?></a></li>
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
 
55
+ <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")), 'nxs_snap') ?>" />
56
  <div style="width:100%;"><strong>Google+ Password:</strong> </div><input name="gp[<?php echo $ii; ?>][apGPPass]" id="apGPPass<?php echo $ii; ?>" type="password" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities(substr($options['gpPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['gpPass'], 5)):$options['gpPass'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /> <br/>
57
  <p><div style="width:100%;"><strong>Google+ Page ID (Optional - for Google+ Pages Only. <b style="color: #580000;"> <?php _e('Leave Empty to publish to your profile or community', 'nxs_snap'); ?></b>):</strong>
58
  <p style="font-size: 11px; margin: 0px;">For example if URL of your page is https://plus.google.com/u/0/b/117008619877691455570/ your Page ID is: 117008619877691455570. <b><?php _e('Leave Empty to publish to your profile or community.', 'nxs_snap'); ?></b></p>
62
  <p style="font-size: 11px; margin: 0px;">For example if URL of your Community is https://plus.google.com/communities/100396001601096060160 your Page ID is: 100396001601096060160. <b><?php _e('Leave Empty to publish to your profile or page', 'nxs_snap'); ?>.</b></p>
63
  </div><input name="gp[<?php echo $ii; ?>][gpCommID]" id="gpCommID<?php echo $ii; ?>" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['gpCommID'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />&nbsp;&nbsp;
64
  <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;">
65
+ <?php _e('Retrieve Categories and Page Names', 'nxs_snap'); ?>
66
  </a>
67
+ <div style="padding-left: 15px; width:100%;"><strong>Community Category:</strong>
68
+ <img id="gpLoadingImg<?php echo $ii; ?>" style="display: none;" src='<?php echo $nxs_plurl; ?>img/ajax-loader-sm.gif' />
69
  <select name="gp[<?php echo $ii; ?>][apGPCCats]" id="apGPCCats<?php echo $ii; ?>">
70
  <?php if ($options['gpCCatsList']!=''){ $gGPCats = $options['gpCCatsList']; if ( base64_encode(base64_decode($gGPCats)) === $gGPCats) $gGPCats = base64_decode($gGPCats);
71
  if ($options['gpCCat']!='') $gGPCats = str_replace($options['gpCCat'].'"', $options['gpCCat'].'" selected="selected"', $gGPCats); echo $gGPCats;} else { ?>
72
  <option value="0">None(Click above to retrieve your categories)</option>
73
  <?php } ?>
74
+ </select>
75
+ </div>
76
 
77
  <br/><br/>
78
 
98
  </div><br/>
99
  <?php if ($isNew) { ?> <input type="hidden" name="gp[<?php echo $ii; ?>][apDoGP]" value="1" id="apDoNewGP<?php echo $ii; ?>" /> <?php } ?>
100
  <?php if ($options['gpPass']!='') { ?>
101
+
102
  <b><?php _e('Test your settings', 'nxs_snap'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('GP', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'nxs_snap' ), $nType); ?></a> <?php }
103
+ ?>
104
+
105
+ </div>
106
+ <?php /* ######################## Advanced Tab ####################### */ ?>
107
+ <div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content">
108
+
109
+ <?php if (!$isNew) { ?> <div class="nxs_tls_cpt"><?php _e('Categories', 'nxs_snap'); ?></div>
110
+ <div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
111
+ <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
112
+ <input value="1" id="catSelS<?php echo $ntU; ?><?php echo $ii; ?>" type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_<?php echo $ntU; ?><?php echo $ii; ?>" onclick="jQuery('#catSelS<?php echo $ntU; ?><?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('<?php echo $ntU; ?><?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($options['catSelEd']!='') echo "[".(substr_count($options['catSelEd'], ",")+1)."]"; ?></a>
113
+ <input type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
114
+ <br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
115
+ <br/>
116
+ <?php } ?>
117
+
118
+ <?php nxs_addPostingDelaySelV3($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']); ?>
119
+ <?php nxs_showRepostSettings($nt, $ii, $options); ?>
120
+
121
+
122
+ </div> <?php /* #### End of Tab #### */ ?>
123
+ </div><br/> <?php /* #### End of Tabs #### */ ?>
124
+
125
+ <div class="submit clear" style="padding-bottom: 0px;"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div> </div>
126
+
127
+ <?php
128
  }
129
  //#### Set Unit Settings from POST
130
  function setNTSettings($post, $options){ global $nxs_snapThisPageUrl; $code = 'GP'; $lcode = 'gp';
138
 
139
  if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']);
140
  if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
141
+
142
  if (isset($pval['apGPCCats'])) $options[$ii]['gpCCat'] = trim($pval['apGPCCats']);
143
+
144
+ $options[$ii] = nxs_adjRpst($options[$ii], $pval);
145
 
146
  if (isset($pval['postType'])) $options[$ii]['postType'] = $pval['postType'];
147
  if (isset($pval['apGPMsgFrmt'])) $options[$ii]['gpMsgFormat'] = trim($pval['apGPMsgFrmt']);
148
  if (isset($pval['apDoGP'])) $options[$ii]['doGP'] = $pval['apDoGP']; else $options[$ii]['doGP'] = 0;
149
+ 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']);
 
150
  if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
151
  }
152
  } return $options;
153
  }
154
  //#### Show Post->Edit Meta Box Settings
155
+ function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID; $nt = 'gp'; $ntU = 'GP';
156
+ 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]);
157
+ if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = ''; if (empty($ntOpt['urlToUse'])) $ntOpt['urlToUse'] = '';
158
+ $doGP = $ntOpt['doGP'] && (is_array($pMeta) || $ntOpt['catSel']!='1'); $imgToUse = $ntOpt['imgToUse']; $urlToUse = $ntOpt['urlToUse'];
159
  $isAvailGP = $ntOpt['gpUName']!='' && $ntOpt['gpPass']!=''; $gpMsgFormat = htmlentities($ntOpt['gpMsgFormat'], ENT_COMPAT, "UTF-8");
160
  if(!isset($ntOpt['postType']) || $ntOpt['postType']=='') {
161
  if ((int)$ntOpt['imgPost'] == 1) $ntOpt['postType'] = 'I';
168
 
169
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/gp16.png);">Google+ - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
170
  if ($post->post_status == "publish" && $isAvailGP) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToGP_repostButton" id="rePostToGP_button" value="<?php _e('Repost to Google+', 'nxs_snap') ?>" />
171
+ <?php } ?>
172
 
173
+ <?php if (is_array($pMeta) && isset($pMeta[$ii]) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
174
 
175
  ?> <span id="pstdGP<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
176
  <a style="font-size: 10px;" href="https://plus.google.com/<?php echo $pMeta[$ii]['pgID']; ?>" target="_blank"><?php $nType="Google+"; printf( __( 'Posted on', 'nxs_snap' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
179
  </td></tr>
180
 
181
  <?php if (!$isAvailGP) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your Google+ Account to AutoPost to Google+</b>
182
+ <?php } else { if ($post->post_status != "publish" && function_exists('nxs_doSMAS5') ) { nxs_doSMAS5($nt, $ii, $ntOpt); }
183
+
184
+ if (((int)$doGP == 1) && $post->post_status == "publish" && isset($ntOpt['timeToRun']) && $ntOpt['timeToRun'] > time()) { ?> <tr><th style="text-align:left; color: purple;" colspan="2">
185
+ ===&gt;&gt;&gt;&gt;&nbsp;<?php _e('Autopost has been schedulled for', 'nxs_snap') ?> <?php echo date('F j, Y, g:i a', $ntOpt['timeToRun']) ?></th> <?php } ?>
186
+
187
+ <?php if ($ntOpt['rpstOn']=='1') { ?>
188
+
189
+ <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top:6px; text-align:right; width:60px; padding-right:10px;">
190
+ <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"; ?> />
191
+ </th>
192
+ <td> <?php _e('Include in "Auto-Reposting" to this network.', 'nxs_snap') ?>
193
+ </td></tr> <?php } ?>
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:', 'nxs_snap') ?> <br/>
196
  (<a id="showShAtt" style="font-weight: normal" onmouseout="hidePopShAtt('<?php echo $ii; ?>XG');" onmouseover="showPopShAtt('<?php echo $ii; ?>XG', event);" onclick="return false;" class="underdash" href="http://www.nextscripts.com/blog/"><?php _e('What\'s the difference?', 'nxs_snap'); ?></a>)
204
  <?php if ($ntOpt['gpCommID']!='') { ?>
205
  <tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;">Community Category</th>
206
  <td><select name="gp[<?php echo $ii; ?>][apGPCCat]" id="apGPCCat">
207
+ <?php if (!empty($ntOpt['gpCCatsList'])){ $gCats = $ntOpt['gpCCatsList']; if ( base64_encode(base64_decode($gCats)) === $gCats) $gCats = base64_decode($gCats);
208
  if ($ntOpt['gpCCat']!='') $gCats = str_replace($ntOpt['gpCCat'].'"', $ntOpt['gpCCat'].'" selected="selected"', $gCats); echo $gCats;} else { ?>
209
  <option value="0">None(Please go to settings and retreive)</option>
210
  <?php } ?>
211
  </select></td>
212
  </tr>
213
+ <?php } ?>
214
+ <?php /* ## Message Format ## */ ?>
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('Message Format:', 'nxs_snap') ?></th>
216
  <td>
217
 
220
  <?php } else { ?>
221
  <input 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); ?>
222
  <?php } ?>
 
 
223
  </td></tr>
224
+ <?php /* ## Select Image & URL ## */ nxs_showImgToUseDlg($nt, $ii, $imgToUse); nxs_showURLToUseDlg($nt, $ii, $urlToUse); ?>
225
  <?php }
226
  }
227
  }
228
  //#### Save Meta Tags to the Post
229
  function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
230
+ if (isset($pMeta['SNAPformat'])) $optMt['gpMsgFormat'] = $pMeta['SNAPformat'];
231
+ if (isset($pMeta['imgToUse'])) $optMt['imgToUse'] = $pMeta['imgToUse']; if (isset($pMeta['urlToUse'])) $optMt['urlToUse'] = $pMeta['urlToUse'];
232
+ if (isset($pMeta['timeToRun'])) $optMt['timeToRun'] = $pMeta['timeToRun']; if (isset($pMeta['rpstPostIncl'])) $optMt['rpstPostIncl'] = $pMeta['rpstPostIncl'];
233
  if (isset($pMeta['postType'])) $optMt['postType'] = $pMeta['postType'];
234
  if (isset($pMeta['apGPCCat']) && $pMeta['apGPCCat']!='' && $pMeta['apGPCCat']!='0') $optMt['gpCCat'] = $pMeta['apGPCCat'];
235
  if (isset($pMeta['doGP'])) $optMt['doGP'] = $pMeta['doGP'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doGP'] = 0; }
238
  }
239
  }}
240
  if (!function_exists("nxs_rePostToGP_ajax")) {
241
+ 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;
242
  foreach ($options['gp'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj'; //if ($two['gpPageID'].$two['gpUName']==$_POST['nid']) {
243
  $gppo = get_post_meta($postID, 'snapGP', true); $gppo = maybe_unserialize($gppo);// prr($gppo);
244
  if (is_array($gppo) && isset($gppo[$ii]) && is_array($gppo[$ii])){ $ntClInst = new nxs_snapClassGP(); $two = $ntClInst->adjMetaOpt($two, $gppo[$ii]); }
247
  }
248
  }
249
  if (!function_exists("nxs_doPublishToGP")) { //## Second Function to Post to G+
250
+ function nxs_doPublishToGP($postID, $options){ $ntCd = 'GP'; $ntCdL = 'gp'; $ntNm = 'Google+'; global $plgn_NS_SNAutoPoster; $ytCode = ''; $imgURL = '';
251
+ if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
252
  if(!function_exists('doConnectToGooglePlus2') || !function_exists('doPostToGooglePlus2')) { nxs_addToLogN('E', 'Error', $ntCd, '-=ERROR=- No G+ API Lib Detected', ''); return "No G+ API Lib Detected";}
253
  $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'POSTID'=>$postID, 'ACCNAME'=>$options['nName']));
254
+ if (empty($options['imgToUse'])) $options['imgToUse'] = ''; if (empty($options['imgSize'])) $options['imgSize'] = '';
255
+
256
  $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
257
  $logNT = '<span style="color:#800000">Google+</span> - '.$options['nName'];
258
  $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
260
  $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') {
261
  nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$uqID); return;
262
  }
263
+ }
 
264
 
265
+ $message = array('message'=>'', 'link'=>'', 'imageURL'=>'', 'videoURL'=>'', 'noImg'=>false); $isNoImg = false;
266
  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();
267
  } else { nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1')); $post = get_post($postID); if(!$post) return;
268
  $gpMsgFormat = $options['gpMsgFormat']; $gpPostType = $options['postType']; $msg = nsFormatMessage($gpMsgFormat, $postID, $addParams); $options['gpMsgFormat'] = $msg;
269
+ $extInfo = ' | PostID: '.$postID." - ".(isset($post) && is_object($post)?$post->post_title:'');
270
+ if ($gpPostType=='I') { $vids = nsFindVidsInPost($post, false); if (count($vids)>0) $ytCode = $vids[0]; /* if (trim($ytCode)=='') $options['trPostType']='T'; /* What is it? */ }
271
+ if ($gpPostType=='A') if (trim($options['imgToUse'])!='') $imgURL = $options['imgToUse']; else $imgURL = nxs_getPostImage($postID, 'medium');
272
+ if ($gpPostType=='I') if (trim($options['imgToUse'])!='') $imgURL = $options['imgToUse']; else $imgURL = nxs_getPostImage($postID, 'full');
273
+ if (preg_match("/noImg.\.png/i", $imgURL)) { $imgURL = ''; $isNoImg = true; }
274
+
275
  //## MyURL - URLToGo code
276
+ if (!isset($options['urlToUse']) || trim($options['urlToUse'])=='') $myurl = trim(get_post_meta($postID, 'snap_MYURL', true)); if ($myurl!='') $options['urlToUse'] = $myurl;
277
  if (isset($options['urlToUse']) && trim($options['urlToUse'])!='') { $urlToGo = $options['urlToUse']; $options['useFBGURLInfo'] = true; } else $urlToGo = get_permalink($postID);
278
+ $gOptions = $plgn_NS_SNAutoPoster->nxs_options; $addURLParams = trim($gOptions['addURLParams']); if($addURLParams!='') $urlToGo .= (strpos($urlToGo,'?')!==false?'&':'?').$addURLParams;
279
+
280
+ $message = array('url'=>$urlToGo, 'imageURL'=>$imgURL, 'videoCode'=>$ytCode, 'noImg'=>$isNoImg);
281
  }
282
  //## Actual Post
283
  $ntToPost = new nxs_class_SNAP_GP(); $ret = $ntToPost->doPostToNT($options, $message);
inc-cl/ip.api.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //## NextScripts FriendFeed Connection Class
3
+ $nxs_snapAPINts[] = array('code'=>'IP', 'lcode'=>'ip', 'name'=>'Instapaper');
4
+
5
+ if (!class_exists("nxs_class_SNAP_IP")) { class nxs_class_SNAP_IP {
6
+
7
+ var $ntCode = 'IP';
8
+ var $ntLCode = 'ip';
9
+
10
+ function doPost($options, $message){ if (!is_array($options)) return false;
11
+ foreach ($options as $ntOpts) $out[] = $this->doPostToNT($ntOpts, $message);
12
+ return $out;
13
+ }
14
+ function nxs_getIPHeaders($up){ $hdrsArr = array();
15
+ $hdrsArr['Cache-Control']='no-cache'; $hdrsArr['Connection']='keep-alive';
16
+ $hdrsArr['User-Agent']='SNAP for Wordpress; Ver '.NextScripts_SNAP_Version;
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
+ 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
+ $msg = nxs_doFormatMsg($options['ipMsgFormat'], $message); $msgT = nxs_doFormatMsg($options['ipMsgTFormat'], $message);
29
+ $link = urlencode($message['url']); $desc = urlencode(substr($msgT, 0, 250)); $ext = urlencode(substr($msg, 0, 1000)); $tags = $message['tags'];
30
+
31
+ $apicall = "https://www.instapaper.com/api/add?red=api&url=$link&title=$desc&selection=$ext";// prr($apicall);
32
+ $hdrsArr = $this->nxs_getIPHeaders($dusername.':'.$pass); $cnt = wp_remote_get( $apicall, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr) );// prr($cnt);
33
+
34
+ if(is_wp_error($cnt)) { $error_string = $cnt->get_error_message(); if (stripos($error_string, ' timed out')!==false) { sleep(10);
35
+ $cnt = wp_remote_get( $apicall, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr) );}
36
+ }
37
+ if(is_wp_error($cnt)) $ret = 'Something went wrong - '.print_r($cnt, true); else {
38
+ if (is_array($cnt) && stripos($cnt['body'],'201')!==false) return array('postID'=>'IP', 'isPosted'=>1, 'postURL'=>'IP', 'pDate'=>date('Y-m-d H:i:s'));
39
+ 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']; }
40
+ } $badOut['Error'] .= $ret; return $badOut;
41
+ }
42
+ }}
43
+ ?>
inc-cl/ip.php CHANGED
@@ -8,44 +8,48 @@ if (!class_exists("nxs_snapClassIP")) { class nxs_snapClassIP {
8
  <div class="nxs_box">
9
  <div class="nxs_box_header">
10
  <div class="nsx_iconedTitle" style="margin-bottom:1px;background-image:url(<?php echo $nxs_plurl;?>img/<?php echo $ntInfo['lcode']; ?>16.png);"><?php echo $ntInfo['name']; ?>
11
- <?php $cbo = count($ntOpts); ?> <?php wp_nonce_field( 'ns'.$ntInfo['code'], 'ns'.$ntInfo['code'].'_wpnonce' ); ?>
12
  <?php if ($cbo>1){ ?><div class="nsBigText"><?php echo "(".($cbo=='0'?'No':$cbo)." "; _e('accounts', 'nxs_snap'); echo ")"; ?></div><?php } ?>
13
  </div>
14
  </div>
15
  <div class="nxs_box_inside">
16
  <?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
17
  <p style="margin:0px;margin-left:5px;">
18
- <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> /> <?php if ((int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
 
 
19
  <strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
20
  &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', 'nxs_snap'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>&nbsp;&nbsp;
21
  <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
22
- </p><?php $this->showNTSettings($indx, $pbo);
23
  }?>
24
  </div>
25
  </div> <?php
26
  }
27
  //#### Show NEW Settings Page
28
- function showNewNTSettings($mgpo){ $gpo = array('nName'=>'', 'doIP'=>'1', 'ipUName'=>'', 'ipPageID'=>'', 'ipAttch'=>'', 'ipPass'=>''); $this->showNTSettings($mgpo, $gpo, true);}
29
  //#### Show Unit Settings
30
- function showNTSettings($ii, $gpo, $isNew=false){ global $nxs_plurl; ?>
31
- <div id="doIP<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>" style="max-width: 1000px; background-color: #EBF4FB; background-image: url(<?php echo $nxs_plurl; ?>img/ip-bg.png); background-position:90% 10%; background-repeat: no-repeat; 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; ?>" />
 
 
32
 
33
  <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', 'nxs_snap' ), $nType); ?></a></div>
34
 
35
- <div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easely identify it', 'nxs_snap'); ?></i> </div><input name="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($gpo['nName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /><br/>
36
- <?php echo nxs_addQTranslSel('ip', $ii, $gpo['qTLng']); ?><?php echo nxs_addPostingDelaySel('ip', $ii, $gpo['nHrs'], $gpo['nMin']); ?>
37
 
38
- <?php if (!$isNew) { ?>
39
- <div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
40
- <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="ip[<?php echo $ii; ?>][catSel]" <?php if ((int)$gpo['catSel'] != 1) echo "checked"; ?> /> All
41
- <input value="1" id="catSelSIP<?php echo $ii; ?>" type="radio" name="ip[<?php echo $ii; ?>][catSel]" <?php if ((int)$gpo['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_IP<?php echo $ii; ?>" onclick="jQuery('#catSelSIP<?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('IP<?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_IP<?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($gpo['catSelEd']!='') echo "[".(substr_count($gpo['catSelEd'], ",")+1)."]"; ?></a>
42
- <input type="hidden" name="ip[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_IP<?php echo $ii; ?>" value="<?php echo $gpo['catSelEd']; ?>" />
43
- <br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
44
- <br/>
45
- <?php } ?>
46
 
47
- <div style="width:100%;"><strong>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($gpo['ipUName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
48
- <div style="width:100%;"><strong>Instapaper Password:</strong> </div><input name="ip[<?php echo $ii; ?>][apIPPass]" id="apIPPass" type="password" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities(substr($gpo['ipPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($gpo['ipPass'], 5)):$gpo['ipPass'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /> <br/>
49
 
50
  <?php if ($isNew) { ?> <input type="hidden" name="ip[<?php echo $ii; ?>][apDoIP]" value="1" id="apDoNewIP<?php echo $ii; ?>" /> <?php } ?>
51
  <br/>
@@ -53,24 +57,44 @@ if (!class_exists("nxs_snapClassIP")) { class nxs_snapClassIP {
53
  <div id="altFormat" style="">
54
  <div style="width:100%;"><strong id="altFormatText"><?php _e('Post Title Format', 'nxs_snap'); ?></strong> (<a href="#" id="apIPTMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apIPTMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)</div>
55
 
56
- <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($gpo['ipMsgTFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap'); ?>" onfocus="mxs_showFrmtInfo('apIPTMsgFrmt<?php echo $ii; ?>');" /><?php nxs_doShowHint("apIPTMsgFrmt".$ii); ?>
57
  </div>
58
 
59
  <div id="altFormat" style="">
60
  <div style="width:100%;"><strong id="altFormatText"><?php _e('Post Text Format', 'nxs_snap'); ?></strong> (<a href="#" id="apIPMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apIPMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)</div>
61
 
62
- <textarea cols="150" rows="3" id="ip<?php echo $ii; ?>SNAPformat" name="ip[<?php echo $ii; ?>][apIPMsgFrmt]" style="width:51%;max-width: 650px;" onfocus="jQuery('#ip<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('apIPMsgFrmt<?php echo $ii; ?>');"><?php if ($isNew) echo "%EXCERPT%"; else _e(apply_filters('format_to_edit', htmlentities($gpo['ipMsgFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap'); ?></textarea>
63
 
64
  <?php nxs_doShowHint("apIPMsgFrmt".$ii); ?>
65
  </div><br/>
66
 
67
- <?php if ($gpo['ipPass']!='') { ?>
68
- <?php wp_nonce_field( 'rePostToIP', 'rePostToIP_wpnonce' ); ?>
69
  <b><?php _e('Test your settings', 'nxs_snap'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('IP', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'nxs_snap' ), $nType); ?></a>
70
 
71
  <?php }
72
 
73
- ?><div class="submit"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div></div><?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  }
75
  //#### Set Unit Settings from POST
76
  function setNTSettings($post, $options){ global $nxs_snapThisPageUrl; $code = 'IP'; $lcode = 'ip';
@@ -86,13 +110,17 @@ if (!class_exists("nxs_snapClassIP")) { class nxs_snapClassIP {
86
  if (isset($pval['apIPMsgFrmt'])) $options[$ii]['ipMsgFormat'] = trim($pval['apIPMsgFrmt']);
87
  if (isset($pval['apIPMsgTFrmt'])) $options[$ii]['ipMsgTFormat'] = trim($pval['apIPMsgTFrmt']);
88
  if (isset($pval['apDoIP'])) $options[$ii]['doIP'] = $pval['apDoIP']; else $options[$ii]['doIP'] = 0;
 
 
 
 
89
  if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
90
  if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
91
  }
92
  } return $options;
93
  }
94
  //#### Show Post->Edit Meta Box Settings
95
- function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
96
  foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapIP', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
97
  $doIP = $ntOpt['doIP'] && (is_array($pMeta) || $ntOpt['catSel']!='1');
98
  $isAvailIP = $ntOpt['ipUName']!='' && $ntOpt['ipPass']!=''; $ipMsgFormat = htmlentities($ntOpt['ipMsgFormat'], ENT_COMPAT, "UTF-8"); $ipMsgTFormat = htmlentities($ntOpt['ipMsgTFormat'], ENT_COMPAT, "UTF-8");
@@ -103,7 +131,7 @@ if (!class_exists("nxs_snapClassIP")) { class nxs_snapClassIP {
103
 
104
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/ip16.png);">Instapaper - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
105
  if ($post->post_status == "publish" && $isAvailIP) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToIP_repostButton" id="rePostToIP_button" value="<?php _e('Repost to Instapaper', 'nxs_snap') ?>" />
106
- <?php wp_nonce_field( 'rePostToIP', 'rePostToIP_wpnonce' ); } ?>
107
 
108
  <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
109
  ?> <span id="pstdIP<?php echo $ii; ?>" style="float: right; padding-top: 4px; padding-right: 10px;">
@@ -113,7 +141,16 @@ if (!class_exists("nxs_snapClassIP")) { class nxs_snapClassIP {
113
  </td></tr>
114
 
115
  <?php if (!$isAvailIP) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your Instapaper Account to AutoPost to Instapaper</b>
116
- <?php } elseif ($post->post_status != "pubZlish") { ?>
 
 
 
 
 
 
 
 
 
117
 
118
  <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Title Format:', 'nxs_snap') ?></th>
119
  <td><input value="<?php echo $ipMsgTFormat ?>" type="text" name="ip[<?php echo $ii; ?>][SNAPformatT]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apIPTMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apIPTMsgFrmt".$ii); ?></td></tr>
@@ -128,14 +165,16 @@ if (!class_exists("nxs_snapClassIP")) { class nxs_snapClassIP {
128
  //#### Save Meta Tags to the Post
129
  function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
130
  if (isset($pMeta['SNAPformat'])) $optMt['ipMsgFormat'] = $pMeta['SNAPformat'];
131
- if (isset($pMeta['SNAPformatT'])) $optMt['ipMsgTFormat'] = $pMeta['SNAPformatT'];
 
 
132
  if (isset($pMeta['doIP'])) $optMt['doIP'] = $pMeta['doIP'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doIP'] = 0; }
133
  if (isset($pMeta['SNAPincludeIP']) && $pMeta['SNAPincludeIP'] == '1' ) $optMt['doIP'] = 1;
134
  return $optMt;
135
  }
136
  }}
137
  if (!function_exists("nxs_rePostToIP_ajax")) {
138
- function nxs_rePostToIP_ajax() { check_ajax_referer('rePostToIP'); $postID = $_POST['id']; $options = get_option('NS_SNAutoPoster');
139
  foreach ($options['ip'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj'; //if ($two['gpPageID'].$two['gpUName']==$_POST['nid']) {
140
  $gppo = get_post_meta($postID, 'snapIP', true); $gppo = maybe_unserialize($gppo);// prr($gppo);
141
  if (is_array($gppo) && isset($gppo[$ii]) && is_array($gppo[$ii])){ $ntClInst = new nxs_snapClassIP(); $two = $ntClInst->adjMetaOpt($two, $gppo[$ii]);}
@@ -144,18 +183,14 @@ if (!function_exists("nxs_rePostToIP_ajax")) {
144
  }
145
  }
146
 
147
- if (!function_exists("nxs_getIPHeaders")) { function nxs_getIPHeaders($up){ $hdrsArr = array();
148
- $hdrsArr['Cache-Control']='no-cache'; $hdrsArr['Connection']='keep-alive';
149
- $hdrsArr['User-Agent']='SNAP for Wordpress; Ver '.NextScripts_SNAP_Version;
150
- $hdrsArr['Accept']='text/html, application/xhtml+xml, */*'; $hdrsArr['DNT']='1';
151
- $hdrsArr['Authorization'] = 'Basic ' . base64_encode("$up");
152
- $hdrsArr['Accept-Encoding']='gzip,deflate'; $hdrsArr['Accept-Language']='en-US,en;q=0.8'; $hdrsArr['Accept-Charset']='ISO-8859-1,utf-8;q=0.7,*;q=0.3'; return $hdrsArr;
153
- }}
154
 
155
  if (!function_exists("nxs_doPublishToIP")) { //## Second Function to Post to IP
156
- function nxs_doPublishToIP($postID, $options){ $ntCd = 'IP'; $ntCdL = 'ip'; $ntNm = 'Instapaper';
 
157
  //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToIP', array($postID, $options));
158
-
 
159
  $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
160
  $logNT = '<span style="color:#000080">Instapaper</span> - '.$options['nName'];
161
  $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
@@ -163,33 +198,31 @@ if (!function_exists("nxs_doPublishToIP")) { //## Second Function to Post to IP
163
  $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') { sleep(5);
164
  nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$uqID); return;
165
  }
166
- }
 
 
 
 
 
167
 
168
- if ($postID=='0') { echo "Testing ... <br/><br/>"; $link = home_url(); $msgT = 'Test Link from '.$link; } else { $post = get_post($postID); if(!$post) return; $link = get_permalink($postID);
169
- $msgFormat = $options['ipMsgFormat']; $msgTFormat = $options['ipMsgTFormat']; $msgT = nsFormatMessage($msgTFormat, $postID); $msg = nsFormatMessage($msgFormat, $postID);
170
  nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
171
  }
172
- $extInfo = ' | PostID: '.$postID." - ".$post->post_title;
173
- $dusername = $options['ipUName']; $pass = (substr($options['ipPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['ipPass'], 5)):$options['ipPass']);
174
- $link = urlencode($link); $desc = urlencode(substr($msgT, 0, 250)); $ext = urlencode(substr($msg, 0, 1000));
175
- $t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = urlencode(implode(',',$tggs)); $tags = str_replace(' ','+',$tags);
176
- $apicall = "https://www.instapaper.com/api/add?red=api&url=$link&title=$desc&selection=$ext";
177
- $hdrsArr = nxs_getIPHeaders($dusername.':'.$pass); $cnt = wp_remote_get( $apicall, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr) );// prr($cnt);
178
 
179
- if(is_wp_error($cnt)) { $error_string = $cnt->get_error_message(); if (stripos($error_string, ' timed out')!==false) { sleep(10);
180
- $cnt = wp_remote_get( $apicall, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr) );}
181
- }
182
- if(is_wp_error($cnt)) {
183
- $ret = 'Something went wrong - '.""; nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.$ret. "ERR: ".print_r($cnt, true), $extInfo);
184
- } else {
185
- if (is_array($cnt) && stripos($cnt['body'],'201')!==false)
186
- { $ret = 'OK'; nxs_metaMarkAsPosted($postID, 'IP', $options['ii'], array('isPosted'=>'1', 'pgID'=>'IP', 'pDate'=>date('Y-m-d H:i:s'))); nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); }
187
- else { if ($cnt['response']['code']=='401') $ret = " Incorrect Username/Password "; else $ret = 'Something went wrong - '."https://$dusername:*********@$api/posts/add?&url=$link&description=$desc&extended=$ext&tags=$tags";
188
- nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.$ret. "ERR: ".print_r($cnt, true), $extInfo);
189
- }
190
  }
191
- if ($ret!='OK') { if ($postID=='0') echo $ret; } else if ($postID=='0') { echo 'OK - Message Posted, please see your Instapaper Page. '; nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); }
192
- if ($ret == 'OK') return 200; else return $ret;
193
 
194
  }
195
  }
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', 'nxs_snap'); echo ")"; ?></div><?php } ?>
13
  </div>
14
  </div>
15
  <div class="nxs_box_inside">
16
  <?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
17
  <p style="margin:0px;margin-left:5px;">
18
+ <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> />
19
+ <?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 } ?>
20
+ <?php if (isset($pbo['rpstOn']) && (int)$pbo['rpstOn'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popReActive');" onmouseover="nxs_showPopUpInfo('popReActive', event);"><?php echo "*[R]*" ?></span><?php } ?>
21
  <strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
22
  &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', 'nxs_snap'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>&nbsp;&nbsp;
23
  <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
24
+ </p><?php $pbo['ntInfo'] = $ntInfo; $this->showNTSettings($indx, $pbo);
25
  }?>
26
  </div>
27
  </div> <?php
28
  }
29
  //#### Show NEW Settings Page
30
+ function showNewNTSettings($mgpo){ $options = array('nName'=>'', 'doIP'=>'1', 'ipUName'=>'', 'ipPageID'=>'', 'ipAttch'=>'', 'ipPass'=>''); $options['ntInfo']= array('lcode'=>'ip'); $this->showNTSettings($mgpo, $options, true);}
31
  //#### Show Unit Settings
32
+ function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl; $nt = $options['ntInfo']['lcode']; $ntU = strtoupper($nt);
33
+ 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'] = '';
34
+ if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; ?>
35
+ <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; ?>" />
36
 
37
  <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', 'nxs_snap' ), $nType); ?></a></div>
38
 
39
+ <div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'nxs_snap'); ?></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")), 'nxs_snap') ?>" /><br/>
40
+ <?php echo nxs_addQTranslSel('ip', $ii, $options['qTLng']); ?>
41
 
42
+ <br/>
43
+ <ul class="nsx_tabs">
44
+ <li><a href="#nsx<?php echo $nt.$ii ?>_tab1"><?php _e('Account Info', 'nxs_snap'); ?></a></li>
45
+ <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'nxs_snap'); ?></a></li>
46
+ </ul>
47
+ <div class="nsx_tab_container"><?php /* ######################## Account Tab ####################### */ ?>
48
+ <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%;">
49
+
50
 
51
+ <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")), 'nxs_snap') ?>" />
52
+ <div style="width:100%;"><strong>Instapaper Password:</strong> </div><input 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")), 'nxs_snap') ?>" /> <br/>
53
 
54
  <?php if ($isNew) { ?> <input type="hidden" name="ip[<?php echo $ii; ?>][apDoIP]" value="1" id="apDoNewIP<?php echo $ii; ?>" /> <?php } ?>
55
  <br/>
57
  <div id="altFormat" style="">
58
  <div style="width:100%;"><strong id="altFormatText"><?php _e('Post Title Format', 'nxs_snap'); ?></strong> (<a href="#" id="apIPTMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apIPTMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)</div>
59
 
60
+ <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")), 'nxs_snap'); ?>" onfocus="mxs_showFrmtInfo('apIPTMsgFrmt<?php echo $ii; ?>');" /><?php nxs_doShowHint("apIPTMsgFrmt".$ii); ?>
61
  </div>
62
 
63
  <div id="altFormat" style="">
64
  <div style="width:100%;"><strong id="altFormatText"><?php _e('Post Text Format', 'nxs_snap'); ?></strong> (<a href="#" id="apIPMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apIPMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)</div>
65
 
66
+ <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")), 'nxs_snap'); ?></textarea>
67
 
68
  <?php nxs_doShowHint("apIPMsgFrmt".$ii); ?>
69
  </div><br/>
70
 
71
+ <?php if ($options['ipPass']!='') { ?>
72
+
73
  <b><?php _e('Test your settings', 'nxs_snap'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('IP', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'nxs_snap' ), $nType); ?></a>
74
 
75
  <?php }
76
 
77
+ ?></div>
78
+ <?php /* ######################## Advanced Tab ####################### */ ?>
79
+ <div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content">
80
+
81
+ <?php if (!$isNew) { ?> <div class="nxs_tls_cpt"><?php _e('Categories', 'nxs_snap'); ?></div>
82
+ <div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
83
+ <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
84
+ <input value="1" id="catSelS<?php echo $ntU; ?><?php echo $ii; ?>" type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_<?php echo $ntU; ?><?php echo $ii; ?>" onclick="jQuery('#catSelS<?php echo $ntU; ?><?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('<?php echo $ntU; ?><?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($options['catSelEd']!='') echo "[".(substr_count($options['catSelEd'], ",")+1)."]"; ?></a>
85
+ <input type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
86
+ <br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
87
+ <br/>
88
+ <?php } ?>
89
+
90
+ <?php nxs_addPostingDelaySelV3($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']); ?>
91
+ <?php nxs_showRepostSettings($nt, $ii, $options); ?>
92
+
93
+
94
+ </div> <?php /* #### End of Tab #### */ ?>
95
+ </div><br/> <?php /* #### End of Tabs #### */ ?>
96
+
97
+ <div class="submit clear" style="padding-bottom: 0px;"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div></div><?php
98
  }
99
  //#### Set Unit Settings from POST
100
  function setNTSettings($post, $options){ global $nxs_snapThisPageUrl; $code = 'IP'; $lcode = 'ip';
110
  if (isset($pval['apIPMsgFrmt'])) $options[$ii]['ipMsgFormat'] = trim($pval['apIPMsgFrmt']);
111
  if (isset($pval['apIPMsgTFrmt'])) $options[$ii]['ipMsgTFormat'] = trim($pval['apIPMsgTFrmt']);
112
  if (isset($pval['apDoIP'])) $options[$ii]['doIP'] = $pval['apDoIP']; else $options[$ii]['doIP'] = 0;
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
  }
120
  } return $options;
121
  }
122
  //#### Show Post->Edit Meta Box Settings
123
+ function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID; $nt = 'ip'; $ntU = 'IP';
124
  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]);
125
  $doIP = $ntOpt['doIP'] && (is_array($pMeta) || $ntOpt['catSel']!='1');
126
  $isAvailIP = $ntOpt['ipUName']!='' && $ntOpt['ipPass']!=''; $ipMsgFormat = htmlentities($ntOpt['ipMsgFormat'], ENT_COMPAT, "UTF-8"); $ipMsgTFormat = htmlentities($ntOpt['ipMsgTFormat'], ENT_COMPAT, "UTF-8");
131
 
132
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/ip16.png);">Instapaper - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
133
  if ($post->post_status == "publish" && $isAvailIP) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToIP_repostButton" id="rePostToIP_button" value="<?php _e('Repost to Instapaper', 'nxs_snap') ?>" />
134
+ <?php } ?>
135
 
136
  <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
137
  ?> <span id="pstdIP<?php echo $ii; ?>" style="float: right; padding-top: 4px; padding-right: 10px;">
141
  </td></tr>
142
 
143
  <?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>
144
+ <?php } else { if ($post->post_status != "publish" && function_exists('nxs_doSMAS5') ) { nxs_doSMAS5($nt, $ii, $ntOpt); } ?>
145
+
146
+ <?php if ($ntOpt['rpstOn']=='1') { ?>
147
+
148
+ <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top:6px; text-align:right; width:60px; padding-right:10px;">
149
+ <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"; ?> />
150
+ </th>
151
+ <td> <?php _e('Include in "Auto-Reposting" to this network.', 'nxs_snap') ?>
152
+ </td></tr> <?php } ?>
153
+
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('Title Format:', 'nxs_snap') ?></th>
156
  <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>
165
  //#### Save Meta Tags to the Post
166
  function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
167
  if (isset($pMeta['SNAPformat'])) $optMt['ipMsgFormat'] = $pMeta['SNAPformat'];
168
+ if (isset($pMeta['SNAPformatT'])) $optMt['ipMsgTFormat'] = $pMeta['SNAPformatT'];
169
+ if (isset($pMeta['imgToUse'])) $optMt['imgToUse'] = $pMeta['imgToUse'];
170
+ if (isset($pMeta['timeToRun'])) $optMt['timeToRun'] = $pMeta['timeToRun']; if (isset($pMeta['rpstPostIncl'])) $optMt['rpstPostIncl'] = $pMeta['rpstPostIncl'];
171
  if (isset($pMeta['doIP'])) $optMt['doIP'] = $pMeta['doIP'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doIP'] = 0; }
172
  if (isset($pMeta['SNAPincludeIP']) && $pMeta['SNAPincludeIP'] == '1' ) $optMt['doIP'] = 1;
173
  return $optMt;
174
  }
175
  }}
176
  if (!function_exists("nxs_rePostToIP_ajax")) {
177
+ function nxs_rePostToIP_ajax() { check_ajax_referer('nxsSsPageWPN'); $postID = $_POST['id']; $options = get_option('NS_SNAutoPoster');
178
  foreach ($options['ip'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj'; //if ($two['gpPageID'].$two['gpUName']==$_POST['nid']) {
179
  $gppo = get_post_meta($postID, 'snapIP', true); $gppo = maybe_unserialize($gppo);// prr($gppo);
180
  if (is_array($gppo) && isset($gppo[$ii]) && is_array($gppo[$ii])){ $ntClInst = new nxs_snapClassIP(); $two = $ntClInst->adjMetaOpt($two, $gppo[$ii]);}
183
  }
184
  }
185
 
186
+
 
 
 
 
 
 
187
 
188
  if (!function_exists("nxs_doPublishToIP")) { //## Second Function to Post to IP
189
+ function nxs_doPublishToIP($postID, $options){ $ntCd = 'IP'; $ntCdL = 'ip'; $ntNm = 'Instapaper'; global $plgn_NS_SNAutoPoster;
190
+ if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
191
  //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToIP', 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">Instapaper</span> - '.$options['nName'];
196
  $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
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'.' |'.$uqID); return;
200
  }
201
+ }
202
+ if ($postID=='0') { echo "Testing ... <br/><br/>"; $urlToGo = home_url(); $options['ipMsgTFormat'] = 'Test Link from '.$urlToGo; } else { $post = get_post($postID); if(!$post) return;
203
+ //## MyURL - URLToGo code
204
+ if (!isset($options['urlToUse']) || trim($options['urlToUse'])=='') $myurl = trim(get_post_meta($postID, 'snap_MYURL', true)); if ($myurl!='') $options['urlToUse'] = $myurl;
205
+ if (isset($options['urlToUse']) && trim($options['urlToUse'])!='') { $urlToGo = $options['urlToUse']; $options['useFBGURLInfo'] = true; } else $urlToGo = get_permalink($postID);
206
+ $gOptions = $plgn_NS_SNAutoPoster->nxs_options; $addURLParams = trim($gOptions['addURLParams']); if($addURLParams!='') $urlToGo .= (strpos($urlToGo,'?')!==false?'&':'?').$addURLParams;
207
 
208
+ $options['ipMsgTFormat'] = nsFormatMessage($options['ipMsgTFormat'], $postID, $addParams); $options['ipMsgFormat'] = nsFormatMessage($options['ipMsgFormat'], $postID, $addParams);
 
209
  nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
210
  }
211
+ $extInfo = ' | PostID: '.$postID." - ".(is_object($post)?$post->post_title:'');
 
 
 
 
 
212
 
213
+ $t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = urlencode(implode(',',$tggs)); $tags = str_replace(' ','+',$tags);
214
+ $message = array('url'=>$urlToGo, 'surl'=>$urlToGo, 'siteName'=>$blogTitle, 'tags'=>$tags);
215
+ //## Actual Post
216
+ $ntToPost = new nxs_class_SNAP_IP(); $ret = $ntToPost->doPostToNT($options, $message);
217
+ //## Process Results
218
+ if (!is_array($ret) || $ret['isPosted']!='1') { //## Error
219
+ if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);
220
+ } else { // ## All Good - log it.
221
+ if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo _e('OK - Message Posted, please see your '.$logNT.' Page. ', 'nxs_snap'); }
222
+ 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); }
 
223
  }
224
+ //## Return Result
225
+ if ($ret['isPosted']=='1') return 200; else return print_r($ret, true);
226
 
227
  }
228
  }
inc-cl/li.api.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //## NextScripts FriendFeed Connection Class
3
+ $nxs_snapAPINts[] = array('code'=>'LI', 'lcode'=>'li', 'name'=>'LinkedIn');
4
+
5
+ if (!class_exists("nxs_class_SNAP_LI")) { class nxs_class_SNAP_LI {
6
+
7
+ var $ntCode = 'LI';
8
+ var $ntLCode = 'li';
9
+
10
+ function doPost($options, $message){ if (!is_array($options)) return false;
11
+ foreach ($options as $ntOpts) $out[] = $this->doPostToNT($ntOpts, $message);
12
+ return $out;
13
+ }
14
+ function doPostToNT($options, $message){ $badOut = array('postID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>''); $liPostID = '';
15
+
16
+ //## Check settings
17
+ if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
18
+ if ((!isset($options['ulName']) || trim($options['uPass'])=='') && (empty($options['liOAuthVerifier']))) { $badOut['Error'] = 'Not Configured'; return $badOut; }
19
+ //## Format
20
+ $msg = nxs_doFormatMsg($options['liMsgFormat'], $message); $msgT = nxs_doFormatMsg($options['liMsgFormatT'], $message);
21
+
22
+ if ($options['liAttch']=='1') {
23
+ if (isset($message['imageURL'])) $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); else $imgURL = ''; if (preg_match("/noImg.\.png/i", $imgURL)) $imgURL = '';
24
+ if (trim($message['urlDescr'])!='') $dsc = $message['urlDescr']; else $dsc = $msg;
25
+ $dsc = strip_tags($dsc); $dsc = nxs_decodeEntitiesFull($dsc); $dsc = nxs_html_to_utf8($dsc); $dsc = nsTrnc($dsc, 300);
26
+ }
27
+ $msg = strip_tags($msg); $msg = nxs_html_to_utf8($msg); $msgT = nxs_html_to_utf8($msgT); $urlToGo = $message['url'];
28
+
29
+ if (function_exists("doConnectToLinkedIn") && $options['ulName']!='' && $options['uPass']!='') {
30
+ $dusername = $options['ulName']; $pass = (substr($options['uPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['uPass'], 5)):$options['uPass']); // ??? Do we need that??????
31
+ $auth = doConnectToLinkedIn($options['ulName'], $options['uPass'], $options['ii']); if ($auth!==false) die($auth);
32
+ $to = $options['uPage']!=''?$options['uPage']:'http://www.linkedin.com/home'; $lnk = array(); $msg = str_ireplace('&nbsp;',' ',$msg); $msg = nsTrnc(strip_tags($msg), 700);
33
+ if ($options['liAttch']=='1') { $lnk['title'] = $message['urlTitle']; $lnk['postTitle'] = $msgT; $lnk['desc'] = $message['urlDescr']; $lnk['url'] = $urlToGo; $lnk['img'] = $imgURL; }
34
+ $ret = doPostToLinkedIn($msg, $lnk, $to); $liPostID = $options['uPage'];
35
+ } else { require_once ('apis/liOAuth.php'); $linkedin = new nsx_LinkedIn($options['liAPIKey'], $options['liAPISec']); $linkedin->oauth_verifier = $options['liOAuthVerifier'];
36
+ $linkedin->request_token = new nsx_trOAuthConsumer($options['liOAuthToken'], $options['liOAuthTokenSecret'], 1);
37
+ $linkedin->access_token = new nsx_trOAuthConsumer($options['liAccessToken'], $options['liAccessTokenSecret'], 1); $msg = nsTrnc($msg, 700); //prr($urlToGo); $urlToGo = urlencode($urlToGo); prr($urlToGo); die();
38
+ if ($options['grpID']!=''){
39
+ try{ if ($msgT == '') $msgT = ' ';
40
+ if($options['liAttch']=='1') $ret = $linkedin->postToGroup($msg, $msgT, $options['grpID'], str_replace('&', '&amp;', $urlToGo), $imgURL, $dsc); else $ret = $linkedin->postToGroup($msg, $msgT, $options['grpID']);
41
+ $liPostID= 'http://www.linkedin.com/groups?gid='.$options['grpID'];
42
+ } catch (Exception $o){ $ret="ERROR: ".print_r($o, true); }
43
+ } else { //echo $msg ."|". nsTrnc($msgT, 200) ."|". $urlToGo ."|". $imgURL ."|". $dsc;
44
+ try{ if($options['liAttch']=='1') $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); }
45
+ }
46
+ if ($liPostID=='') $liPostID = $options['liUserInfo'];
47
+ }
48
+ if (stripos($ret, 'update-url')!==false) { $liPostID = CutFromTo($ret, '<update-url>','</update-url>'); $ret = '201'; }
49
+ if ($ret!='201') { $badOut['Error'] .= $ret; } else return array('isPosted'=>'1', 'postID'=>$liPostID, 'postURL'=>$liPostID, 'pDate'=>date('Y-m-d H:i:s'));
50
+ return $badOut;
51
+ }
52
+ }}
53
+ ?>
inc-cl/li.php CHANGED
@@ -2,6 +2,7 @@
2
 
3
  if (isset($_GET['ca']) && $_GET['ca']!='') { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://www.google.com/recaptcha/api/image?c='.$_GET['ca']);
4
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_REFERER, 'https://www.google.com/'); $imageData = curl_exec($ch);
 
5
  header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
6
  header("Cache-Control: private",false); header("Content-Type: image/jpg"); header("Content-Transfer-Encoding: binary"); echo $imageData; die();
7
  }
@@ -9,9 +10,10 @@ if (isset($_GET['ca']) && $_GET['ca']!='') { $ch = curl_init(); curl_setopt($ch
9
  add_action('wp_ajax_nxsCptCheck' , 'nxsCptCheck_ajax');
10
  if (!function_exists("nxsCptCheck_ajax")) { function nxsCptCheck_ajax() { global $nxs_gCookiesArr;
11
  if ($_POST['c']!='') { $seForDB = get_option('nxs_li_ctp_save'); $ser = maybe_unserialize($seForDB); $nxs_gCookiesArr = $ser['c']; $flds = $ser['f'];
12
- $flds['recaptcha_response_field'] = $_POST['c']; $cfldsTxt = build_http_query($flds); // prr($cfldsTxt); prr($nxs_gCookiesArr);
13
- $contents2 = getCurlPageX('https://www.linkedin.com/uas/captcha-submit','https://www.linkedin.com/uas/login-submit', false, $cfldsTxt, false, $advSettings); // prr($contents2);
14
  if (stripos($contents2['content'], 'The email address or password you provided does not match our records')!==false) { echo "Invalid Login/Password"; die(); }
 
15
  if (stripos($contents2['url'], 'linkedin.com/uas/captcha-submit')!==false) echo "Wrong Captcha. Please try Again";
16
  if (stripos($contents2['url'], 'linkedin.com/home')!==false) { echo "OK. You are In";
17
  $contents3 = getCurlPageX('http://www.linkedin.com/profile/edit?trk=tab_pro', 'http://www.linkedin.com/home', false, '', false, $advSettings); // prr($contents3);
@@ -25,16 +27,24 @@ if (!function_exists("nxsCptCheck_ajax")) { function nxsCptCheck_ajax() { global
25
  //## NextScripts Facebook Connection Class
26
  $nxs_snapAvNts[] = array('code'=>'LI', 'lcode'=>'li', 'name'=>'LinkedIn');
27
 
 
 
 
 
 
28
  if (!class_exists("nxs_snapClassLI")) { class nxs_snapClassLI {
29
  //#### Show Common Settings
30
  function showGenNTSettings($ntOpts){ global $nxs_snapThisPageUrl, $nxs_plurl; $ntInfo = array('code'=>'LI', 'lcode'=>'li', 'name'=>'LinkedIn', 'defNName'=>'ulName', 'tstReq' => true);
31
 
32
  if ( isset($_GET['auth']) && $_GET['auth']=='li'){ require_once('apis/liOAuth.php'); $options = $ntOpts[$_GET['acc']];
33
-
34
  $api_key = $options['liAPIKey']; $api_secret = $options['liAPISec'];
35
  $callback_url = $nxs_snapThisPageUrl."&auth=lia&acc=".$_GET['acc'];
36
  $li_oauth = new nsx_LinkedIn($api_key, $api_secret, $callback_url);
37
  $request_token = $li_oauth->getRequestToken(); //echo "####"; prr($request_token); die();
 
 
 
38
  $options['liOAuthToken'] = $request_token->key;
39
  $options['liOAuthTokenSecret'] = $request_token->secret; // prr($li_oauth);
40
  switch ($li_oauth->http_code) { case 200: $url = $li_oauth->generateAuthorizeUrl(); $optionsG = get_option('NS_SNAutoPoster'); $optionsG['li'][$_GET['acc']] = $options; update_option('NS_SNAutoPoster', $optionsG);
@@ -57,7 +67,7 @@ if (!class_exists("nxs_snapClassLI")) { class nxs_snapClassLI {
57
  <div class="nxs_box">
58
  <div class="nxs_box_header">
59
  <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']; ?>
60
- <?php $cbo = count($ntOpts); ?> <?php wp_nonce_field( 'ns'.$ntInfo['code'], 'ns'.$ntInfo['code'].'_wpnonce' ); ?>
61
  <?php if ($cbo>1){ ?><div class="nsBigText"><?php echo "(".($cbo=='0'?'No':$cbo)." "; _e('accounts', 'nxs_snap'); echo ")"; ?></div><?php } ?>
62
  </div>
63
  </div>
@@ -66,36 +76,39 @@ if (!class_exists("nxs_snapClassLI")) { class nxs_snapClassLI {
66
  if (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='') $pbo[$ntInfo['lcode'].'OK'] = (isset($pbo['liAccessToken']) && $pbo['liAccessTokenSecret']!='')?'1':'';
67
  ?>
68
  <p style="margin:0px;margin-left:5px;">
69
- <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> /> <?php if ((int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
 
 
70
  <strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
71
  &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', 'nxs_snap'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>&nbsp;&nbsp;
72
  <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
73
- </p><?php $this->showNTSettings($indx, $pbo);
74
  }?>
75
  </div>
76
  </div> <?php
77
  }
78
  //#### Show NEW Settings Page
79
- function showNewNTSettings($bo){ $po = array('nName'=>'', 'ulName'=>'', 'uPass'=>'', 'grpID'=>'', 'uPage'=>'', 'doLI'=>'1', 'liAPIKey'=>'', 'liAPISec'=>'', 'liUserInfo'=>'', 'liAttch'=>'1', 'liOAuthToken'=>'', 'liMsgFormat'=>'New post has been published on %SITENAME%', 'liMsgFormatT'=>'New post - %TITLE%' ); $this->showNTSettings($bo, $po, true);}
80
  //#### Show Unit Settings
81
- function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl,$nxs_snapThisPageUrl; if (!isset($options['liOK'])) $options['liOK'] = ''; ?>
82
- <div id="doLI<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>" style="background-image: url(<?php echo $nxs_plurl; ?>img/li-bg.png); background-position:90% 10%;"> <input type="hidden" name="apDoSLI<?php echo $ii; ?>" value="0" id="apDoSLI<?php echo $ii; ?>" />
 
 
83
  <?php if ($isNew) { ?> <input type="hidden" name="li[<?php echo $ii; ?>][apDoLI]" value="1" id="apDoNewLI<?php echo $ii; ?>" /> <?php } ?>
84
  <div id="doLI<?php echo $ii; ?>Div" style="margin-left: 10px;">
85
 
86
  <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' , 'nxs_snap'), $nType); ?></a></div>
87
 
88
- <div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easely identify it', 'nxs_snap'); ?></i> </div><input name="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")), 'nxs_snap') ?>" /><br/>
89
- <?php echo nxs_addQTranslSel('li', $ii, $options['qTLng']); ?><?php echo nxs_addPostingDelaySel('li', $ii, $options['nHrs'], $options['nMin'], $options['nDays']); ?>
90
 
91
- <?php if (!$isNew) { ?>
92
- <div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
93
- <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="li[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
94
- <input value="1" id="catSelSLI<?php echo $ii; ?>" type="radio" name="li[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_LI<?php echo $ii; ?>" onclick="jQuery('#catSelSLI<?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('LI<?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_LI<?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($options['catSelEd']!='') echo "[".(substr_count($options['catSelEd'], ",")+1)."]"; ?></a>
95
- <input type="hidden" name="li[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_LI<?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
96
- <br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
97
- <br/>
98
- <?php } ?>
99
 
100
  <table width="800" border="0" cellpadding="10">
101
  <tr><td colspan="2">
@@ -132,7 +145,7 @@ if (!class_exists("nxs_snapClassLI")) { class nxs_snapClassLI {
132
 
133
  <?php if (function_exists("doConnectToLinkedIn")) { ?>
134
 
135
- <div class="subDiv" id="sub<?php echo $ii; ?>DivN" style="display: block;"> <span style="color:#800000; font-size: 14px;"> <b>Beta</b>, please <a target="_blank" href="http://www.nextscripts.com/support/">report</a> any problems.</span><br/><br/>
136
  <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" style="width: 90%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['uPage'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
137
  <br/>
138
  <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")), 'nxs_snap') ?>" />
@@ -180,13 +193,35 @@ if (!class_exists("nxs_snapClassLI")) { class nxs_snapClassLI {
180
  <br/>
181
 
182
  <?php if($options['liAPIKey']!='' || (isset($options['uPass']) && $options['uPass']!='')) { ?>
183
- <?php wp_nonce_field( 'rePostToLI', 'rePostToLI_wpnonce' ); ?>
184
  <br/><b><?php _e('Test your settings', 'nxs_snap'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('LI', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'nxs_snap' ), $nType); ?></a>
185
 
186
  <?php if (!isset($options['liOK']) || $options['liOK']=='') { ?> <div class="blnkg">&lt;=== Click "Test" to finish setup ===</div> <?php } ?>
187
 
188
  <br/><?php }?>
189
- <div class="submit"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
190
  </div>
191
  </div>
192
  <?php
@@ -214,18 +249,21 @@ if (!class_exists("nxs_snapClassLI")) { class nxs_snapClassLI {
214
  if (isset($pval['apLIMsgFrmtT'])) $options[$ii]['liMsgFormatT'] = trim($pval['apLIMsgFrmtT']);
215
  if (isset($pval['apLIMsgAFrmt'])) $options[$ii]['liMsgAFrmt'] = trim($pval['apLIMsgAFrmt']);
216
 
217
- if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']);
 
 
218
  if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
219
  if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
220
- } //prr($options);
221
  } return $options;
222
  }
223
  //#### Show Post->Edit Meta Box Settings
224
- function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID; //prr($ntOpts);
225
- foreach($ntOpts as $ii=>$options) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapLI', true)); if (is_array($pMeta)) $options = $this->adjMetaOpt($options, $pMeta[$ii]);
226
- $doLI = $options['doLI'] && (is_array($pMeta) || $options['catSel']!='1');
227
- $isAvailLI = (isset($options['liOAuthVerifier']) && $options['liOAuthVerifier']!='' && $options['liAccessTokenSecret']!='' && $options['liAccessToken']!='' && $options['liAPIKey']!='') || ($options['ulName']!=='' && $options['uPass']!=='');
228
- $isAttachLI = $options['liAttch']; $liMsgFormat = htmlentities($options['liMsgFormat'], ENT_COMPAT, "UTF-8"); $liMsgFormatT = htmlentities($options['liMsgFormatT'], ENT_COMPAT, "UTF-8");
 
229
  ?>
230
 
231
  <tr><th style="text-align:left;" colspan="2"><?php if ( $options['catSel']=='1' && trim($options['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_LI<?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" /> <?php } ?>
@@ -233,16 +271,24 @@ if (!class_exists("nxs_snapClassLI")) { class nxs_snapClassLI {
233
  <?php if ($post->post_status == "publish") { ?> <input type="hidden" name="li[<?php echo $ii; ?>][doLI]" value="<?php echo $doLI;?>"> <?php } ?> <?php } ?>
234
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/li16.png);">LinkedIn - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $options['nName']; ?></i>)</div></th><td><?php //## Only show RePost button if the post is "published"
235
  if ($post->post_status == "publish" && $isAvailLI) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToLI_repostButton" id="rePostToLI_button" value="<?php _e('Repost to LinkedIn', 'nxs_snap') ?>" />
236
- <?php wp_nonce_field( 'rePostToLI', 'rePostToLI_wpnonce' ); } ?>
237
 
238
- <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
239
  ?> <span id="pstdLI<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
240
- <a style="font-size: 10px;" href="<?php if ($options['uPage']!='') echo $options['uPage']; else { echo $pMeta[$ii]['pgID']; } ?>" target="_blank"><?php $nType="LinkedIn"; printf( __( 'Posted on', 'nxs_snap' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
241
  </span><?php } ?>
242
 
243
  </td></tr>
244
  <?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>
245
- <?php } elseif ($post->post_status != "puZblish") { ?>
 
 
 
 
 
 
 
 
246
 
247
  <tr><th scope="row" style="text-align:right; width:150px; vertical-align:top; padding-top: 5px; padding-right:10px;">
248
  <input value="0" type="hidden" name="li[<?php echo $ii; ?>][AttachPost]"/>
@@ -254,37 +300,42 @@ if (!class_exists("nxs_snapClassLI")) { class nxs_snapClassLI {
254
  <?php nxs_doShowHint("apLIMsgFrmt".$ii); ?></td></tr>
255
 
256
  <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Title Format (Groups Only):', 'nxs_snap') ?></th>
257
- <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>
 
258
 
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['liMsgFormat'] = $pMeta['SNAPformat']; if (trim($optMt['liMsgFormat'])=='') $optMt['liMsgFormat'] = '&nbsp;';
265
- if (isset($pMeta['SNAPformatT'])) $optMt['liMsgFormatT'] = $pMeta['SNAPformatT']; if (trim($optMt['liMsgFormatT'])=='') $optMt['liMsgFormatT'] = '&nbsp;';
 
 
266
  if (isset($pMeta['AttachPost'])) $optMt['liAttch'] = $pMeta['AttachPost'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['liAttch'] = 0; }
267
  if (isset($pMeta['doLI'])) $optMt['doLI'] = $pMeta['doLI'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doLI'] = 0; }
268
- if (isset($pMeta['SNAPincludeLI']) && $pMeta['SNAPincludeLI'] == '1' ) $optMt['doLI'] = 1;
269
  return $optMt;
270
  }
271
  }}
272
 
273
- if (!function_exists("nxs_rePostToLI_ajax")) { function nxs_rePostToLI_ajax() { check_ajax_referer('rePostToLI'); $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['li'] as $ii=>$po) if ($ii==$_POST['nid']) { $po['ii'] = $ii; $po['pType'] = 'aj';
276
  $mpo = get_post_meta($postID, 'snapLI', true); $mpo = maybe_unserialize($mpo);
277
  if (is_array($mpo) && isset($mpo[$ii]) && is_array($mpo[$ii]) ){ $ntClInst = new nxs_snapClassLI(); $po = $ntClInst->adjMetaOpt($po, $mpo[$ii]); }
278
- $result = nxs_doPublishToLI($postID, $po); if ($result == 200 && ($postID=='0') && $options['li'][$ii]['liOK']!='1') { $options['li'][$ii]['liOK']=1; update_option('NS_SNAutoPoster', $options); }
279
  if ($result == 200) die("Successfully sent your post to LinkedIn."); else die($result);
280
  }
281
  }
282
  }
283
 
284
  if (!function_exists("nxs_doPublishToLI")) { //## Second Function to Post to LI
285
- function nxs_doPublishToLI($postID, $options){ global $nxs_gCookiesArr; $ntCd = 'LI'; $ntCdL = 'li'; $ntNm = 'LinkedIn';
 
286
  //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToLI', array($postID, $options));
287
  $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'POSTID'=>$postID, 'ACCNAME'=>$options['nName']));
 
288
  $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
289
  $logNT = '<span style="color:#000058">LinkedIn</span> - '.$options['nName'];
290
  $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
@@ -294,48 +345,39 @@ if (!function_exists("nxs_doPublishToLI")) { //## Second Function to Post to LI
294
  }
295
  }
296
 
297
- $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url(); // prr($options);
298
- if ($postID=='0') { echo "Testing ... <br/><br/>"; $msgT = 'Test Post from '.$blogTitle; $urlToGo = home_url(); $msg = 'Test Post from '.$blogTitle. " ".$urlToGo; $isAttachLI = ''; $title = $blogTitle; }
299
- else { $post = get_post($postID); if(!$post) return; $liMsgFormat = $options['liMsgFormat']; $msg = nsFormatMessage($liMsgFormat, $postID, $addParams); $msgT = nsFormatMessage($options['liMsgFormatT'], $postID, $addParams);
 
300
  //## MyURL - URLToGo code
301
  if (!isset($options['urlToUse']) || trim($options['urlToUse'])=='') $myurl = trim(get_post_meta($postID, 'snap_MYURL', true)); if ($myurl!='') $options['urlToUse'] = $myurl;
302
  if (isset($options['urlToUse']) && trim($options['urlToUse'])!='') { $urlToGo = $options['urlToUse']; $options['useFBGURLInfo'] = true; } else $urlToGo = get_permalink($postID);
303
  if($addParams!='') $urlToGo .= (strpos($urlToGo,'?')!==false?'&':'?').$addParams;
304
  $isAttachLI = $options['liAttch']; $title = nsTrnc($post->post_title, 200); nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
 
 
 
 
 
 
 
 
 
305
  }
306
- $extInfo = ' | PostID: '.$postID." - ".$post->post_title; $msgT = nsTrnc($msgT, 200);
307
- if ($isAttachLI=='1') {
308
- if (trim($options['liMsgAFrmt'])!='') {$dsc = nsFormatMessage($options['liMsgAFrmt'], $postID, $addParams);} else {
309
- $src = nxs_getPostImage($postID); $dsc = trim(apply_filters('the_content', $post->post_excerpt)); if ($dsc=='') $dsc = apply_filters('the_content', $post->post_content);
310
- } $dsc = strip_tags($dsc); $dsc = nxs_decodeEntitiesFull($dsc); $dsc = nxs_html_to_utf8($dsc); $dsc = nsTrnc($dsc, 300);
311
- }
312
- $msg = nxs_html_to_utf8($msg); $msgT = nxs_html_to_utf8($msgT);
313
- if (function_exists("doConnectToLinkedIn") && $options['ulName']!='' && $options['uPass']!='') {
314
- $auth = doConnectToLinkedIn($options['ulName'], $options['uPass'], $options['ii']); if ($auth!==false) die($auth);
315
- $to = $options['uPage']!=''?$options['uPage']:'http://www.linkedin.com/home'; $lnk = array(); $msg = str_ireplace('&nbsp;',' ',$msg); $msg = nsTrnc(strip_tags($msg), 700);
316
- if ($postID=='0') { $lnk['title'] = get_bloginfo('name'); $lnk['desc'] = get_bloginfo('description'); $lnk['url'] = home_url();
317
- } else { if ($isAttachLI=='1') { $lnk['title'] = nsTrnc( strip_tags($post->post_title), 200); $lnk['postTitle'] = $msgT; $lnk['desc'] = $dsc; $lnk['url'] = $urlToGo; $lnk['img'] = $src; }} //prr($msg);
318
- $ret = doPostToLinkedIn($msg, $lnk, $to); $liPostID = $options['uPage'];
319
- } else { require_once ('apis/liOAuth.php'); $linkedin = new nsx_LinkedIn($options['liAPIKey'], $options['liAPISec']); $linkedin->oauth_verifier = $options['liOAuthVerifier'];
320
- $linkedin->request_token = new nsx_trOAuthConsumer($options['liOAuthToken'], $options['liOAuthTokenSecret'], 1);
321
- $linkedin->access_token = new nsx_trOAuthConsumer($options['liAccessToken'], $options['liAccessTokenSecret'], 1); $msg = nsTrnc($msg, 700);
322
- if ($options['grpID']!=''){
323
- try{
324
- if($isAttachLI=='1') $ret = $linkedin->postToGroup($msg, $msgT, $options['grpID'], $urlToGo, $src, $dsc); else $ret = $linkedin->postToGroup($msg, $msgT, $options['grpID']);
325
- $liPostID= 'http://www.linkedin.com/groups?gid='.$options['grpID'];
326
- } catch (Exception $o){ nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '."Linkedin Status couldn't be updated! - ".print_r($o, true)); $ret="ERROR:".print_r($o, true); }
327
- } else {
328
- try{ if($isAttachLI=='1') $ret = $linkedin->postShare($msg, nsTrnc($post->post_title, 200), $urlToGo, $src, $dsc); else $ret = $linkedin->postShare($msg); }
329
- catch (Exception $o){ nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '."<br/>Linkedin Status couldn't be updated! - ".print_r($o, true)); $ret="ERROR:".print_r($o, true); }
330
- }
331
- //$liPostID = $linkedin->getCurrentShare(); prr($liPostID);
332
- if ($liPostID=='') $liPostID = $options['liUserInfo'];
333
  }
334
- if (stripos($ret, 'update-url')!==false) { $liPostID = CutFromTo($ret, '<update-url>','</update-url>'); $ret = '201'; }
335
- if ($ret!='201') { if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo); }
336
- else if ($postID=='0') { echo 'OK - Linkedin status updated successfully'; nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); } else
337
- { nxs_metaMarkAsPosted($postID, 'LI', $options['ii'], array('isPosted'=>'1', 'pgID'=>$liPostID, 'pDate'=>date('Y-m-d H:i:s'))); nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); }
338
- if ($ret=='201') return true; else return 'Something Wrong';
339
  }
340
  }
341
 
2
 
3
  if (isset($_GET['ca']) && $_GET['ca']!='') { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://www.google.com/recaptcha/api/image?c='.$_GET['ca']);
4
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_REFERER, 'https://www.google.com/'); $imageData = curl_exec($ch);
5
+ if ($imageData === false) { echo 'Curl error: ' . curl_error($ch); die(); }
6
  header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
7
  header("Cache-Control: private",false); header("Content-Type: image/jpg"); header("Content-Transfer-Encoding: binary"); echo $imageData; die();
8
  }
10
  add_action('wp_ajax_nxsCptCheck' , 'nxsCptCheck_ajax');
11
  if (!function_exists("nxsCptCheck_ajax")) { function nxsCptCheck_ajax() { global $nxs_gCookiesArr;
12
  if ($_POST['c']!='') { $seForDB = get_option('nxs_li_ctp_save'); $ser = maybe_unserialize($seForDB); $nxs_gCookiesArr = $ser['c']; $flds = $ser['f'];
13
+ $flds['recaptcha_response_field'] = $_POST['c']; $cfldsTxt = build_http_query($flds); // prr($cfldsTxt); prr($nxs_gCookiesArr);
14
+ $contents2 = getCurlPageX('https://www.linkedin.com/uas/captcha-submit','https://www.linkedin.com/uas/login-submit', false, $cfldsTxt, false, $advSettings); // prr($contents2);
15
  if (stripos($contents2['content'], 'The email address or password you provided does not match our records')!==false) { echo "Invalid Login/Password"; die(); }
16
+ if (stripos($contents2['content'], 'Hmm, ')!==false) { echo "Invalid Login/Password"; die(); }
17
  if (stripos($contents2['url'], 'linkedin.com/uas/captcha-submit')!==false) echo "Wrong Captcha. Please try Again";
18
  if (stripos($contents2['url'], 'linkedin.com/home')!==false) { echo "OK. You are In";
19
  $contents3 = getCurlPageX('http://www.linkedin.com/profile/edit?trk=tab_pro', 'http://www.linkedin.com/home', false, '', false, $advSettings); // prr($contents3);
27
  //## NextScripts Facebook Connection Class
28
  $nxs_snapAvNts[] = array('code'=>'LI', 'lcode'=>'li', 'name'=>'LinkedIn');
29
 
30
+ function nxs_ntp_time($host='time.nist.gov') { $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); socket_connect($sock, $host, 123);
31
+ $msg = "\010" . str_repeat("\0", 47); socket_send($sock, $msg, strlen($msg), 0); socket_recv($sock, $recv, 48, MSG_WAITALL); socket_close($sock);
32
+ $data = unpack('N12', $recv); $timestamp = sprintf('%u', $data[9]); $timestamp -= 2208988800; return $timestamp;
33
+ }
34
+
35
  if (!class_exists("nxs_snapClassLI")) { class nxs_snapClassLI {
36
  //#### Show Common Settings
37
  function showGenNTSettings($ntOpts){ global $nxs_snapThisPageUrl, $nxs_plurl; $ntInfo = array('code'=>'LI', 'lcode'=>'li', 'name'=>'LinkedIn', 'defNName'=>'ulName', 'tstReq' => true);
38
 
39
  if ( isset($_GET['auth']) && $_GET['auth']=='li'){ require_once('apis/liOAuth.php'); $options = $ntOpts[$_GET['acc']];
40
+
41
  $api_key = $options['liAPIKey']; $api_secret = $options['liAPISec'];
42
  $callback_url = $nxs_snapThisPageUrl."&auth=lia&acc=".$_GET['acc'];
43
  $li_oauth = new nsx_LinkedIn($api_key, $api_secret, $callback_url);
44
  $request_token = $li_oauth->getRequestToken(); //echo "####"; prr($request_token); die();
45
+ if (!is_object($request_token)) { echo "### LinkedIn Authorization Error:"; prr($request_token);
46
+ 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();
47
+ }
48
  $options['liOAuthToken'] = $request_token->key;
49
  $options['liOAuthTokenSecret'] = $request_token->secret; // prr($li_oauth);
50
  switch ($li_oauth->http_code) { case 200: $url = $li_oauth->generateAuthorizeUrl(); $optionsG = get_option('NS_SNAutoPoster'); $optionsG['li'][$_GET['acc']] = $options; update_option('NS_SNAutoPoster', $optionsG);
67
  <div class="nxs_box">
68
  <div class="nxs_box_header">
69
  <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']; ?>
70
+ <?php $cbo = count($ntOpts); ?>
71
  <?php if ($cbo>1){ ?><div class="nsBigText"><?php echo "(".($cbo=='0'?'No':$cbo)." "; _e('accounts', 'nxs_snap'); echo ")"; ?></div><?php } ?>
72
  </div>
73
  </div>
76
  if (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='') $pbo[$ntInfo['lcode'].'OK'] = (isset($pbo['liAccessToken']) && $pbo['liAccessTokenSecret']!='')?'1':'';
77
  ?>
78
  <p style="margin:0px;margin-left:5px;">
79
+ <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> />
80
+ <?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 } ?>
81
+ <?php if (isset($pbo['rpstOn']) && (int)$pbo['rpstOn'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popReActive');" onmouseover="nxs_showPopUpInfo('popReActive', event);"><?php echo "*[R]*" ?></span><?php } ?>
82
  <strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
83
  &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', 'nxs_snap'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>&nbsp;&nbsp;
84
  <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
85
+ </p><?php $pbo['ntInfo'] = $ntInfo; $this->showNTSettings($indx, $pbo);
86
  }?>
87
  </div>
88
  </div> <?php
89
  }
90
  //#### Show NEW Settings Page
91
+ function showNewNTSettings($bo){ $po = array('nName'=>'', 'ulName'=>'', 'uPass'=>'', 'grpID'=>'', 'uPage'=>'', 'doLI'=>'1', 'liAPIKey'=>'', 'liAPISec'=>'', 'liUserInfo'=>'', 'liAttch'=>'1', 'liOAuthToken'=>'', 'liMsgFormat'=>'New post has been published on %SITENAME%', 'liMsgFormatT'=>'New post - %TITLE%' ); $po['ntInfo']= array('lcode'=>'li'); $this->showNTSettings($bo, $po, true);}
92
  //#### Show Unit Settings
93
+ function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl,$nxs_snapThisPageUrl; $nt = $options['ntInfo']['lcode']; $ntU = strtoupper($nt); if (!isset($options['liOK'])) $options['liOK'] = '';
94
+ 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'] = '';
95
+ if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; if (!isset($options['liMsgAFrmt'])) $options['liMsgAFrmt'] = ''; ?>
96
+ <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; ?>" />
97
  <?php if ($isNew) { ?> <input type="hidden" name="li[<?php echo $ii; ?>][apDoLI]" value="1" id="apDoNewLI<?php echo $ii; ?>" /> <?php } ?>
98
  <div id="doLI<?php echo $ii; ?>Div" style="margin-left: 10px;">
99
 
100
  <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' , 'nxs_snap'), $nType); ?></a></div>
101
 
102
+ <div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'nxs_snap'); ?></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")), 'nxs_snap') ?>" /><br/>
103
+ <?php echo nxs_addQTranslSel('li', $ii, $options['qTLng']); ?>
104
 
105
+ <br/>
106
+ <ul class="nsx_tabs">
107
+ <li><a href="#nsx<?php echo $nt.$ii ?>_tab1"><?php _e('Account Info', 'nxs_snap'); ?></a></li>
108
+ <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'nxs_snap'); ?></a></li>
109
+ </ul>
110
+ <div class="nsx_tab_container"><?php /* ######################## Account Tab ####################### */ ?>
111
+ <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%;">
 
112
 
113
  <table width="800" border="0" cellpadding="10">
114
  <tr><td colspan="2">
145
 
146
  <?php if (function_exists("doConnectToLinkedIn")) { ?>
147
 
148
+ <div class="subDiv" id="sub<?php echo $ii; ?>DivN" style="display: block;">
149
  <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" style="width: 90%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['uPage'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
150
  <br/>
151
  <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")), 'nxs_snap') ?>" />
193
  <br/>
194
 
195
  <?php if($options['liAPIKey']!='' || (isset($options['uPass']) && $options['uPass']!='')) { ?>
196
+
197
  <br/><b><?php _e('Test your settings', 'nxs_snap'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('LI', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'nxs_snap' ), $nType); ?></a>
198
 
199
  <?php if (!isset($options['liOK']) || $options['liOK']=='') { ?> <div class="blnkg">&lt;=== Click "Test" to finish setup ===</div> <?php } ?>
200
 
201
  <br/><?php }?>
202
+ </div>
203
+
204
+ <?php /* ######################## Advanced Tab ####################### */ ?>
205
+ <div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content">
206
+
207
+ <?php if (!$isNew) { ?> <div class="nxs_tls_cpt"><?php _e('Categories', 'nxs_snap'); ?></div>
208
+ <div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
209
+ <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
210
+ <input value="1" id="catSelS<?php echo $ntU; ?><?php echo $ii; ?>" type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_<?php echo $ntU; ?><?php echo $ii; ?>" onclick="jQuery('#catSelS<?php echo $ntU; ?><?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('<?php echo $ntU; ?><?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($options['catSelEd']!='') echo "[".(substr_count($options['catSelEd'], ",")+1)."]"; ?></a>
211
+ <input type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
212
+ <br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
213
+ <br/>
214
+ <?php } ?>
215
+
216
+ <?php nxs_addPostingDelaySelV3($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']); ?>
217
+ <?php nxs_showRepostSettings($nt, $ii, $options); ?>
218
+
219
+
220
+ </div> <?php /* #### End of Tab #### */ ?>
221
+ </div><br/> <?php /* #### End of Tabs #### */ ?>
222
+
223
+ <div class="submit clear" style="padding-bottom: 0px;"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div>
224
+
225
  </div>
226
  </div>
227
  <?php
249
  if (isset($pval['apLIMsgFrmtT'])) $options[$ii]['liMsgFormatT'] = trim($pval['apLIMsgFrmtT']);
250
  if (isset($pval['apLIMsgAFrmt'])) $options[$ii]['liMsgAFrmt'] = trim($pval['apLIMsgAFrmt']);
251
 
252
+ $options[$ii] = nxs_adjRpst($options[$ii], $pval);
253
+
254
+ if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']);
255
  if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
256
  if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
257
+ }
258
  } return $options;
259
  }
260
  //#### Show Post->Edit Meta Box Settings
261
+ function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID; $nt = 'li'; $ntU = 'LI';
262
+ foreach($ntOpts as $ii=>$options) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapLI', true)); if (is_array($pMeta) && isset($pMeta[$ii])) $options = $this->adjMetaOpt($options, $pMeta[$ii]);
263
+ if (empty($options['imgToUse'])) $options['imgToUse'] = ''; if (empty($options['urlToUse'])) $options['urlToUse'] = ''; if (empty($options['catSel'])) $options['catSel'] = '';
264
+ $doLI = $options['doLI'] && (is_array($pMeta) || $options['catSel']!='1'); $imgToUse = $options['imgToUse']; $urlToUse = $options['urlToUse'];
265
+ $isAvailLI = (isset($options['liOAuthVerifier']) && $options['liOAuthVerifier']!='' && $options['liAccessTokenSecret']!='' && $options['liAccessToken']!='' && $options['liAPIKey']!='') || ($options['ulName']!=='' && $options['uPass']!=='');
266
+ $isAttachLI = $options['liAttch']; $liMsgFormat = htmlentities($options['liMsgFormat'], ENT_COMPAT, "UTF-8"); $liMsgFormatT = htmlentities($options['liMsgFormatT'], ENT_COMPAT, "UTF-8");
267
  ?>
268
 
269
  <tr><th style="text-align:left;" colspan="2"><?php if ( $options['catSel']=='1' && trim($options['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_LI<?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" /> <?php } ?>
271
  <?php if ($post->post_status == "publish") { ?> <input type="hidden" name="li[<?php echo $ii; ?>][doLI]" value="<?php echo $doLI;?>"> <?php } ?> <?php } ?>
272
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/li16.png);">LinkedIn - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $options['nName']; ?></i>)</div></th><td><?php //## Only show RePost button if the post is "published"
273
  if ($post->post_status == "publish" && $isAvailLI) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToLI_repostButton" id="rePostToLI_button" value="<?php _e('Repost to LinkedIn', 'nxs_snap') ?>" />
274
+ <?php } ?>
275
 
276
+ <?php if (is_array($pMeta) && isset($pMeta[$ii]) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) { // prr($pMeta[$ii]);
277
  ?> <span id="pstdLI<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
278
+ <a style="font-size: 10px;" href="<?php if ( $pMeta[$ii]['pgID']!='') echo $pMeta[$ii]['pgID']; elseif ($options['uPage']!='') echo $options['uPage']; else { } ?>" target="_blank"><?php $nType="LinkedIn"; printf( __( 'Posted on', 'nxs_snap' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
279
  </span><?php } ?>
280
 
281
  </td></tr>
282
  <?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>
283
+ <?php } else { if ($post->post_status != "publish" && function_exists('nxs_doSMAS5') ) { nxs_doSMAS5($nt, $ii, $options); } ?>
284
+
285
+ <?php if ($options['rpstOn']=='1') { ?>
286
+
287
+ <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top:6px; text-align:right; width:60px; padding-right:10px;">
288
+ <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"; ?> />
289
+ </th>
290
+ <td> <?php _e('Include in "Auto-Reposting" to this network.', 'nxs_snap') ?>
291
+ </td></tr> <?php } ?>
292
 
293
  <tr><th scope="row" style="text-align:right; width:150px; vertical-align:top; padding-top: 5px; padding-right:10px;">
294
  <input value="0" type="hidden" name="li[<?php echo $ii; ?>][AttachPost]"/>
300
  <?php nxs_doShowHint("apLIMsgFrmt".$ii); ?></td></tr>
301
 
302
  <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Title Format (Groups Only):', 'nxs_snap') ?></th>
303
+ <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>
304
+ <?php /* ## Select Image & URL ## */ nxs_showImgToUseDlg($nt, $ii, $imgToUse); nxs_showURLToUseDlg($nt, $ii, $urlToUse); ?>
305
 
306
  <?php }
307
  }
308
  }
309
 
310
  function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
311
+ if (isset($pMeta['SNAPformat'])) $optMt['liMsgFormat'] = $pMeta['SNAPformat']; if (trim($optMt['liMsgFormat'])=='') $optMt['liMsgFormat'] = ' ';
312
+ if (isset($pMeta['SNAPformatT'])) $optMt['liMsgFormatT'] = $pMeta['SNAPformatT']; if (trim($optMt['liMsgFormatT'])=='') $optMt['liMsgFormatT'] = ' ';
313
+ if (isset($pMeta['imgToUse'])) $optMt['imgToUse'] = $pMeta['imgToUse']; if (isset($pMeta['urlToUse'])) $optMt['urlToUse'] = $pMeta['urlToUse'];
314
+ if (isset($pMeta['timeToRun'])) $optMt['timeToRun'] = $pMeta['timeToRun']; if (isset($pMeta['rpstPostIncl'])) $optMt['rpstPostIncl'] = $pMeta['rpstPostIncl'];
315
  if (isset($pMeta['AttachPost'])) $optMt['liAttch'] = $pMeta['AttachPost'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['liAttch'] = 0; }
316
  if (isset($pMeta['doLI'])) $optMt['doLI'] = $pMeta['doLI'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doLI'] = 0; }
317
+ if (isset($pMeta['SNAPincludeLI']) && $pMeta['SNAPincludeLI'] == '1' ) $optMt['doLI'] = 1;
318
  return $optMt;
319
  }
320
  }}
321
 
322
+ if (!function_exists("nxs_rePostToLI_ajax")) { function nxs_rePostToLI_ajax() { check_ajax_referer('nxsSsPageWPN'); $postID = $_POST['id']; // $result = nsPublishTo($id, 'FB', true);
323
  global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
324
  foreach ($options['li'] as $ii=>$po) if ($ii==$_POST['nid']) { $po['ii'] = $ii; $po['pType'] = 'aj';
325
  $mpo = get_post_meta($postID, 'snapLI', true); $mpo = maybe_unserialize($mpo);
326
  if (is_array($mpo) && isset($mpo[$ii]) && is_array($mpo[$ii]) ){ $ntClInst = new nxs_snapClassLI(); $po = $ntClInst->adjMetaOpt($po, $mpo[$ii]); }
327
+ $result = nxs_doPublishToLI($postID, $po); 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); }
328
  if ($result == 200) die("Successfully sent your post to LinkedIn."); else die($result);
329
  }
330
  }
331
  }
332
 
333
  if (!function_exists("nxs_doPublishToLI")) { //## Second Function to Post to LI
334
+ function nxs_doPublishToLI($postID, $options){ global $nxs_gCookiesArr; $ntCd = 'LI'; $ntCdL = 'li'; $ntNm = 'LinkedIn'; $urlDescr = ''; $myurl = '';
335
+ if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
336
  //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToLI', array($postID, $options));
337
  $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'POSTID'=>$postID, 'ACCNAME'=>$options['nName']));
338
+ if (empty($options['imgToUse'])) $options['imgToUse'] = ''; if (empty($options['imgSize'])) $options['imgSize'] = '';
339
  $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
340
  $logNT = '<span style="color:#000058">LinkedIn</span> - '.$options['nName'];
341
  $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
345
  }
346
  }
347
 
348
+ $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url(); $imgURL=''; // prr($options);
349
+ if ($postID=='0') { echo "Testing ... <br/><br/>"; $options['liMsgFormatT'] = 'Test Post from '.$blogTitle; $urlToGo = home_url(); $options['liMsgFormat'] = 'Test Post from '.$blogTitle. " ".$urlToGo; $isAttachLI = ''; $title = $blogTitle; }
350
+ else { $post = get_post($postID); if(!$post) return;
351
+ $options['liMsgFormat'] = nsFormatMessage($options['liMsgFormat'], $postID, $addParams); $options['liMsgFormatT'] = nsTrnc(nsFormatMessage($options['liMsgFormatT'], $postID, $addParams), 200);
352
  //## MyURL - URLToGo code
353
  if (!isset($options['urlToUse']) || trim($options['urlToUse'])=='') $myurl = trim(get_post_meta($postID, 'snap_MYURL', true)); if ($myurl!='') $options['urlToUse'] = $myurl;
354
  if (isset($options['urlToUse']) && trim($options['urlToUse'])!='') { $urlToGo = $options['urlToUse']; $options['useFBGURLInfo'] = true; } else $urlToGo = get_permalink($postID);
355
  if($addParams!='') $urlToGo .= (strpos($urlToGo,'?')!==false?'&':'?').$addParams;
356
  $isAttachLI = $options['liAttch']; $title = nsTrnc($post->post_title, 200); nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
357
+
358
+ if ($options['liAttch']=='1') {
359
+ if (trim($options['liMsgAFrmt'])!='') { $urlDescr = nsFormatMessage($options['liMsgAFrmt'], $postID, $addParams); } else {
360
+ $urlDescr = trim(apply_filters('the_content', $post->post_excerpt)); if ($urlDescr=='') $urlDescr = apply_filters('the_content', $post->post_content);
361
+ } if (trim($options['imgToUse'])!='') $imgURL = $options['imgToUse']; else $imgURL = nxs_getPostImage($postID, 'full');
362
+ if (preg_match("/noImg.\.png/i", $imgURL)) $imgURL = '';
363
+ $urlDescr = strip_tags($urlDescr); $urlDescr = nxs_decodeEntitiesFull($urlDescr); $urlDescr = nxs_html_to_utf8($urlDescr); $urlDescr = nsTrnc($urlDescr, 300);
364
+
365
+ }
366
  }
367
+ $extInfo = ' | PostID: '.$postID." - ".(isset($post) && is_object($post)?$post->post_title:'');
368
+ //$images = array(nxs_getPostImage($postID, 'thumb'), nxs_getPostImage($postID, 'medium'), nxs_getPostImage($postID, 'full'), nxs_getPostImage($postID, 'original'));
369
+ $message = array('url'=>$urlToGo, 'surl'=>$urlToGo, 'urlDescr'=>$urlDescr, 'urlTitle'=>$title, 'imageURL' => $imgURL, 'videoCode'=>'', 'videoURL'=>'', 'siteName'=>$blogTitle, 'cats'=>'', 'authorName'=>'');
370
+ //## Actual Post
371
+ $ntToPost = new nxs_class_SNAP_LI(); $ret = $ntToPost->doPostToNT($options, $message);
372
+ //## Process Results
373
+ if (!is_array($ret) || $ret['isPosted']!='1') { //## Error
374
+ if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);
375
+ } else { // ## All Good - log it.
376
+ if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo _e('OK - Message Posted, please see your '.$logNT.' Page. ', 'nxs_snap'); }
377
+ 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); }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
378
  }
379
+ //## Return Result
380
+ if ($ret['isPosted']=='1') return 200; else return print_r($ret, true);
 
 
 
381
  }
382
  }
383
 
inc-cl/lj.api.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //## NextScripts FriendFeed Connection Class
3
+ $nxs_snapAPINts[] = array('code'=>'LJ', 'lcode'=>'lj', 'name'=>'LiveJournal');
4
+
5
+ if (!class_exists("nxs_class_SNAP_LJ")) { class nxs_class_SNAP_LJ {
6
+
7
+ var $ntCode = 'LJ';
8
+ var $ntLCode = 'lj';
9
+
10
+ function doPost($options, $message){ if (!is_array($options)) return false;
11
+ foreach ($options as $ntOpts) $out[] = $this->doPostToNT($ntOpts, $message);
12
+ return $out;
13
+ }
14
+ function nxs_getLJHeaders($up){ $hdrsArr = array();
15
+ $hdrsArr['Cache-Control']='no-cache'; $hdrsArr['Connection']='keep-alive';
16
+ $hdrsArr['User-Agent']='SNAP for Wordpress; Ver '.NextScripts_SNAP_Version;
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
+ 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
+ $msg = nxs_doFormatMsg($options['ljMsgFormat'], $message); $msgT = nxs_doFormatMsg($options['ljMsgTFormat'], $message);
29
+
30
+ require_once ('apis/xmlrpc-client.php'); if ($options['ljSrv']=='DW') $server = 'dreamwidth.org'; else $server = 'livejournal.com';
31
+ $nxsToLJclient = new NXS_XMLRPC_Client('http://www.'.$server.'/interface/xmlrpc'); $nxsToLJclient->debug = false;
32
+
33
+ $date = time(); $year = date("Y", $date); $mon = date("m", $date); $day = date("d", $date); $hour = date("G", $date); $min = date("i", $date);
34
+ $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);
35
+ if ($options['commID']!='') $nxsToLJContent["usejournal"] = $options['commID']; if ($options['inclTags']=='1' && !empty($message['tags'])) $nxsToLJContent['props'] = array('taglist' => $message['tags']);
36
+
37
+ if (!$nxsToLJclient->query('LJ.XMLRPC.postevent', $nxsToLJContent)) { $ret = 'Something went wrong - '.$nxsToLJclient->getErrorCode().' : '.$nxsToLJclient->getErrorMessage();} else $ret = 'OK';
38
+ $pid = $nxsToLJclient->getResponse();
39
+ if (is_array($pid) && !empty($pid['url'])) return array('postID'=>$pid['url'], 'isPosted'=>1, 'postURL'=>$pid['url'], 'pDate'=>date('Y-m-d H:i:s'));
40
+ else $badOut['Error'] .= 'Something went wrong - NO PID '.print_r($pid, true);
41
+ return $badOut;
42
+ }
43
+ }}
44
+ ?>
inc-cl/lj.php CHANGED
@@ -8,51 +8,57 @@ if (!class_exists("nxs_snapClassLJ")) { class nxs_snapClassLJ {
8
  <div class="nxs_box">
9
  <div class="nxs_box_header">
10
  <div class="nsx_iconedTitle" style="margin-bottom:1px;background-image:url(<?php echo $nxs_plurl;?>img/<?php echo $ntInfo['lcode']; ?>16.png);"><?php echo $ntInfo['name']; ?>
11
- <?php $cbo = count($ntOpts); ?> <?php wp_nonce_field( 'ns'.$ntInfo['code'], 'ns'.$ntInfo['code'].'_wpnonce' ); ?>
12
  <?php if ($cbo>1){ ?><div class="nsBigText"><?php echo "(".($cbo=='0'?'No':$cbo)." "; _e('accounts', 'nxs_snap'); echo ")"; ?></div><?php } ?>
13
  </div>
14
  </div>
15
  <div class="nxs_box_inside">
16
  <?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = str_ireplace('/xmlrpc.php','', str_ireplace('http://','', str_ireplace('https://','', $pbo['ljURL']))); ?>
17
  <p style="margin:0px;margin-left:5px;">
18
- <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> /> <?php if ((int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
 
 
19
  <strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
20
  &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', 'nxs_snap'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>&nbsp;&nbsp;
21
  <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
22
- </p><?php $this->showNTSettings($indx, $pbo);
23
  }?>
24
  </div>
25
  </div> <?php
26
  }
27
  //#### Show NEW Settings Page
28
- function showNewNTSettings($mgpo){ $gpo = array('nName'=>'', 'doLJ'=>'1', 'ljUName'=>'', 'ljPageID'=>'', 'inclTags'=>'1', 'ljAttch'=>'', 'ljPass'=>'', 'ljURL'=>''); $this->showNTSettings($mgpo, $gpo, true);}
29
  //#### Show Unit Settings
30
- function showNTSettings($ii, $gpo, $isNew=false){ global $nxs_plurl; ?>
31
- <div id="doLJ<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>" style="background-image: url(<?php echo $nxs_plurl; ?>img/lj-bg.png); background-position:90% 10%;"> <input type="hidden" name="apDoSLJ<?php echo $ii; ?>" value="0" id="apDoSLJ<?php echo $ii; ?>" />
 
 
32
 
33
  <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', 'nxs_snap' ), $nType); ?></a></div>
34
  <?php if ($isNew){ ?> <br/><?php _e('You can setup LiveJournal blog.', 'nxs_snap'); ?><br/><br/> <?php } ?>
35
 
36
- <div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easely identify it', 'nxs_snap'); ?></i> </div><input name="lj[<?php echo $ii; ?>][nName]" id="ljnName<?php echo $ii; ?>" style="font-weight: bold; color: #005800; border: 1px solid #ACACAC; width: 40%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($gpo['nName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /><br/>
37
- <?php echo nxs_addQTranslSel('lj', $ii, $gpo['qTLng']); ?><?php echo nxs_addPostingDelaySel('lj', $ii, $gpo['nHrs'], $gpo['nMin']); ?>
38
 
39
- <?php if (!$isNew) { ?>
40
- <div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
41
- <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="lj[<?php echo $ii; ?>][catSel]" <?php if ((int)$gpo['catSel'] != 1) echo "checked"; ?> /> All
42
- <input value="1" id="catSelSLJ<?php echo $ii; ?>" type="radio" name="lj[<?php echo $ii; ?>][catSel]" <?php if ((int)$gpo['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_LJ<?php echo $ii; ?>" onclick="jQuery('#catSelSLJ<?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('LJ<?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_LJ<?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($gpo['catSelEd']!='') echo "[".(substr_count($gpo['catSelEd'], ",")+1)."]"; ?></a>
43
- <input type="hidden" name="lj[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_LJ<?php echo $ii; ?>" value="<?php echo $gpo['catSelEd']; ?>" />
44
- <br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
45
- <?php } ?>
46
- <div style="width:100%;"><br/><strong>LiveJournal Username:</strong> </div><input name="lj[<?php echo $ii; ?>][apLJUName]" id="apLJUName" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($gpo['ljUName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
47
- <div style="width:100%;"><strong>LiveJournal Password:</strong> </div><input name="lj[<?php echo $ii; ?>][apLJPass]" id="apLJPass" type="password" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities(substr($gpo['ljPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($gpo['ljPass'], 5)):$gpo['ljPass'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /> <br/>
 
 
48
 
49
  <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>
50
- <input name="lj[<?php echo $ii; ?>][commID]" id="commID" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($gpo['commID'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
51
 
52
  <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>
53
 
54
- <select id="lj1delayHrs" name="lj[<?php echo $ii; ?>][ljSrv]"><option <?php if ( !isset($gpo['ljSrv']) || $gpo['ljSrv']=='' || $gpo['ljSrv']=='LJ') {?> selected="selected" <?php } ?> value="LJ">LiveJournal.com</option>
55
- <option <?php if ( isset($gpo['ljSrv']) && $gpo['ljSrv']=='DW') {?> selected="selected" <?php } ?> value="DW">DreamWidth.org</option>
56
  </select>
57
 
58
  <br/>
@@ -62,23 +68,43 @@ if (!class_exists("nxs_snapClassLJ")) { class nxs_snapClassLJ {
62
  <br/><strong id="altFormatText"><?php _e('Post Title and Post Text Formats', 'nxs_snap'); ?></strong>
63
  <div id="altFormat" style="">
64
  <div style="width:100%;"><strong id="altFormatText"><?php _e('Post Title Format', 'nxs_snap'); ?></strong> (<a href="#" id="apLJMsgTFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apLJMsgTFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)
65
- </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($gpo['ljMsgTFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap'); ?>" onfocus="mxs_showFrmtInfo('apLJMsgTFrmt<?php echo $ii; ?>');" /><?php nxs_doShowHint("apLJMsgTFrmt".$ii); ?>
66
  </div>
67
  <div id="altFormat" style="">
68
  <div style="width:100%;"><strong id="altFormatText"><?php _e('Post Text Format', 'nxs_snap'); ?></strong> (<a href="#" id="apLJMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apLJMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)
69
  </div>
70
 
71
- <textarea cols="150" rows="3" id="lj<?php echo $ii; ?>SNAPformat" name="lj[<?php echo $ii; ?>][apLJMsgFrmt]" style="width:51%;max-width: 650px;" onfocus="jQuery('#lj<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('apLJMsgFrmt<?php echo $ii; ?>');"><?php if ($isNew) echo "%FULLTEXT%"; else _e(apply_filters('format_to_edit', htmlentities($gpo['ljMsgFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap'); ?></textarea>
72
 
73
  <?php nxs_doShowHint("apLJMsgFrmt".$ii); ?>
74
  </div>
75
- <p style="margin-bottom: 20px;margin-top: 5px;"><input value="1" id="ljInclTags<?php echo $ii; ?>" type="checkbox" name="lj[<?php echo $ii; ?>][inclTags]" <?php if ((int)$gpo['inclTags'] == 1) echo "checked"; ?> />
76
  <strong><?php _e('Post with tags.', 'nxs_snap') ?></strong> <?php _e('Tags from the blogpost will be auto posted to LiveJournal', 'nxs_snap') ?>
77
  </p><br/>
78
- <?php if ($gpo['ljPass']!='') { ?>
79
- <?php wp_nonce_field( 'rePostToLJ', 'rePostToLJ_wpnonce' ); ?>
80
  <b><?php _e('Test your settings', 'nxs_snap'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('LJ', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'nxs_snap' ), $nType); ?></a> <?php } ?>
81
- <div class="submit"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div></div><?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  }
83
  //#### Set Unit Settings from POST
84
  function setNTSettings($post, $options){ global $nxs_snapThisPageUrl; $code = 'LJ'; $lcode = 'lj';
@@ -100,23 +126,29 @@ if (!class_exists("nxs_snapClassLJ")) { class nxs_snapClassLJ {
100
  $options[$ii]['commID'] = trim($pval['commID']);
101
  }
102
  if (isset($pval['apDoLJ'])) $options[$ii]['doLJ'] = $pval['apDoLJ']; else $options[$ii]['doLJ'] = 0;
 
 
 
 
103
  if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
104
  if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
105
  }
106
  } return $options;
107
  }
108
  //#### Show Post->Edit Meta Box Settings
109
- function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
110
  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]);
111
  $doLJ = $ntOpt['doLJ'] && (is_array($pMeta) || $ntOpt['catSel']!='1');
112
  $isAvailLJ = $ntOpt['ljUName']!='' && $ntOpt['ljPass']!=''; $ljMsgFormat = htmlentities($ntOpt['ljMsgFormat'], ENT_COMPAT, "UTF-8"); $ljMsgTFormat = htmlentities($ntOpt['ljMsgTFormat'], ENT_COMPAT, "UTF-8");
113
  ?>
114
  <tr><th style="text-align:left;" colspan="2"><?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_LJ<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
115
  <?php if ($isAvailLJ) { ?><input class="nxsGrpDoChb" value="1" id="doLJ<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="lj[<?php echo $ii; ?>][doLJ]" <?php if ((int)$doLJ == 1) echo 'checked="checked" title="def"'; ?> />
 
 
116
  <?php if ($post->post_status == "publish") { ?> <input type="hidden" name="lj[<?php echo $ii; ?>][doLJ]" value="<?php echo $doLJ;?>"> <?php } ?> <?php } ?>
117
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/lj16.png);">LiveJournal - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
118
  if ($post->post_status == "publish" && $isAvailLJ) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="shoLJopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToLJ_repostButton" id="rePostToLJ_button" value="<?php _e('Repost to LiveJournal', 'nxs_snap') ?>" />
119
- <?php wp_nonce_field( 'rePostToLJ', 'rePostToLJ_wpnonce' ); } ?>
120
 
121
  <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
122
  ?> <span id="pstdLJ<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
@@ -126,7 +158,15 @@ if (!class_exists("nxs_snapClassLJ")) { class nxs_snapClassLJ {
126
  </td></tr>
127
 
128
  <?php if (!$isAvailLJ) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your LiveJournal Account to AutoPost to LiveJournal</b>
129
- <?php } elseif ($post->post_status != "puZblish") { ?>
 
 
 
 
 
 
 
 
130
 
131
  <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Title Format:', 'nxs_snap') ?></th>
132
  <td><input value="<?php echo $ljMsgTFormat ?>" type="text" name="lj[<?php echo $ii; ?>][SNAPformatT]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apLJTMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apLJTMsgFrmt".$ii); ?></td></tr>
@@ -143,13 +183,15 @@ if (!class_exists("nxs_snapClassLJ")) { class nxs_snapClassLJ {
143
  function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
144
  if (isset($pMeta['SNAPformat'])) $optMt['ljMsgFormat'] = $pMeta['SNAPformat'];
145
  if (isset($pMeta['SNAPformatT'])) $optMt['ljMsgTFormat'] = $pMeta['SNAPformatT'];
 
 
146
  if (isset($pMeta['doLJ'])) $optMt['doLJ'] = $pMeta['doLJ'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doLJ'] = 0; }
147
  if (isset($pMeta['SNAPincludeLJ']) && $pMeta['SNAPincludeLJ'] == '1' ) $optMt['doLJ'] = 1;
148
  return $optMt;
149
  }
150
  }}
151
  if (!function_exists("nxs_rePostToLJ_ajax")) {
152
- function nxs_rePostToLJ_ajax() { check_ajax_referer('rePostToLJ'); $postID = $_POST['id']; $options = get_option('NS_SNAutoPoster');
153
  foreach ($options['lj'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj';//if ($two['gpPageID'].$two['gpUName']==$_POST['nid']) {
154
  $gppo = get_post_meta($postID, 'snapLJ', true); $gppo = maybe_unserialize($gppo);// prr($gppo);
155
  if (is_array($gppo) && isset($gppo[$ii]) && is_array($gppo[$ii])){ $ntClInst = new nxs_snapClassLJ(); $two = $ntClInst->adjMetaOpt($two, $gppo[$ii]); }
@@ -159,8 +201,10 @@ if (!function_exists("nxs_rePostToLJ_ajax")) {
159
  }
160
 
161
  if (!function_exists("nxs_doPublishToLJ")) { //## Second Function to Post to LJ
162
- function nxs_doPublishToLJ($postID, $options){ $ntCd = 'LJ'; $ntCdL = 'lj'; $ntNm = 'LJ Based Blog';
163
  //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToLJ', array($postID, $options));
 
 
164
  $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
165
  $logNT = '<span style="color:#2097EE">LJ</span> - '.$options['nName'];
166
  $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
@@ -169,33 +213,27 @@ if (!function_exists("nxs_doPublishToLJ")) { //## Second Function to Post to LJ
169
  nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$uqID); return;
170
  }
171
  }
172
- $imgURL = nxs_getPostImage($postID);
173
  $email = $options['ljUName']; $pass = substr($options['ljPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['ljPass'], 5)):$options['ljPass'];
174
- if ($postID=='0') { echo "Testing ... <br/><br/>"; $link = home_url(); $msgT = 'Test Link from '.$link; $msg = 'Test post please ignore'; } else { $post = get_post($postID); if(!$post) return; $link = get_permalink($postID);
175
- $msgFormat = $options['ljMsgFormat']; $msg = nsFormatMessage($msgFormat, $postID); $msgTFormat = $options['ljMsgTFormat']; $msgT = nsFormatMessage($msgTFormat, $postID);
176
  nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
177
  } //prr($msg); prr($msgFormat);
178
- $msg = str_ireplace("&lt;!--more--&gt;", '<!--more-->', $msg); if (stripos($msg, '<!--more-->')!==false) $msg = str_ireplace('<!--more-->', '<lj-cut>', $msg).'</lj-cut>';
179
- $extInfo = ' | PostID: '.$postID." - ".$post->post_title;
180
- //## Post
181
- require_once ('apis/xmlrpc-client.php'); if ($options['ljSrv']=='DW') $server = 'dreamwidth.org'; else $server = 'livejournal.com';
182
- $nxsToLJclient = new NXS_XMLRPC_Client('http://www.'.$server.'/interface/xmlrpc'); $nxsToLJclient->debug = false;
183
-
184
- $date = time(); $year = date("Y", $date); $mon = date("m", $date); $day = date("d", $date); $hour = date("G", $date); $min = date("i", $date);
185
- $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);
186
- if ($options['commID']!='') $nxsToLJContent["usejournal"] = $options['commID'];
187
-
188
- if ($options['inclTags']=='1'){ $t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = implode(',', $tggs); $nxsToLJContent['props'] = array('taglist' => $tags); }
189
-
190
-
191
- if (!$nxsToLJclient->query('LJ.XMLRPC.postevent', $nxsToLJContent)) { $ret = 'Something went wrong - '.$nxsToLJclient->getErrorCode().' : '.$nxsToLJclient->getErrorMessage();} else $ret = 'OK';
192
- $pid = $nxsToLJclient->getResponse(); if (is_array($pid)) $pid = $pid['url']; else { $ret = 'Something went wrong - NO PID '.print_r($pid, true);}
193
-
194
- if ($ret!='OK') { if ($postID=='0') echo $ret;
195
- nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);
196
- } else { if ($postID=='0') { echo 'OK - Message Posted, please see your LiveJournal'; nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); } else
197
- { nxs_metaMarkAsPosted($postID, 'LJ', $options['ii'], array('isPosted'=>'1', 'pgID'=>$pid, 'pDate'=>date('Y-m-d H:i:s'))); nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo);} }
198
- if ($ret == 'OK') return 200; else return $ret;
199
  }
200
  }
201
  ?>
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', 'nxs_snap'); echo ")"; ?></div><?php } ?>
13
  </div>
14
  </div>
15
  <div class="nxs_box_inside">
16
  <?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = str_ireplace('/xmlrpc.php','', str_ireplace('http://','', str_ireplace('https://','', $pbo['ljURL']))); ?>
17
  <p style="margin:0px;margin-left:5px;">
18
+ <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> />
19
+ <?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 } ?>
20
+ <?php if (isset($pbo['rpstOn']) && (int)$pbo['rpstOn'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popReActive');" onmouseover="nxs_showPopUpInfo('popReActive', event);"><?php echo "*[R]*" ?></span><?php } ?>
21
  <strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
22
  &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', 'nxs_snap'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>&nbsp;&nbsp;
23
  <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
24
+ </p><?php $pbo['ntInfo'] = $ntInfo; $this->showNTSettings($indx, $pbo);
25
  }?>
26
  </div>
27
  </div> <?php
28
  }
29
  //#### Show NEW Settings Page
30
+ 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);}
31
  //#### Show Unit Settings
32
+ function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl; $nt = $options['ntInfo']['lcode']; $ntU = strtoupper($nt);
33
+ 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'] = '';
34
+ if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; if (!isset($options['commID'])) $options['commID'] = ''; ?>
35
+ <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; ?>" />
36
 
37
  <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', 'nxs_snap' ), $nType); ?></a></div>
38
  <?php if ($isNew){ ?> <br/><?php _e('You can setup LiveJournal blog.', 'nxs_snap'); ?><br/><br/> <?php } ?>
39
 
40
+ <div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'nxs_snap'); ?></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")), 'nxs_snap') ?>" /><br/>
41
+ <?php echo nxs_addQTranslSel('lj', $ii, $options['qTLng']); ?>
42
 
43
+ <br/>
44
+ <ul class="nsx_tabs">
45
+ <li><a href="#nsx<?php echo $nt.$ii ?>_tab1"><?php _e('Account Info', 'nxs_snap'); ?></a></li>
46
+ <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'nxs_snap'); ?></a></li>
47
+ </ul>
48
+ <div class="nsx_tab_container"><?php /* ######################## Account Tab ####################### */ ?>
49
+ <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%;">
50
+
51
+
52
+ <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")), 'nxs_snap') ?>" />
53
+ <div style="width:100%;"><strong>LiveJournal Password:</strong> </div><input name="lj[<?php echo $ii; ?>][apLJPass]" id="apLJPass" type="password" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities(substr($options['ljPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['ljPass'], 5)):$options['ljPass'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /> <br/>
54
 
55
  <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>
56
+ <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")), 'nxs_snap') ?>" />
57
 
58
  <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>
59
 
60
+ <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>
61
+ <option <?php if ( isset($options['ljSrv']) && $options['ljSrv']=='DW') {?> selected="selected" <?php } ?> value="DW">DreamWidth.org</option>
62
  </select>
63
 
64
  <br/>
68
  <br/><strong id="altFormatText"><?php _e('Post Title and Post Text Formats', 'nxs_snap'); ?></strong>
69
  <div id="altFormat" style="">
70
  <div style="width:100%;"><strong id="altFormatText"><?php _e('Post Title Format', 'nxs_snap'); ?></strong> (<a href="#" id="apLJMsgTFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apLJMsgTFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)
71
+ </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")), 'nxs_snap'); ?>" onfocus="mxs_showFrmtInfo('apLJMsgTFrmt<?php echo $ii; ?>');" /><?php nxs_doShowHint("apLJMsgTFrmt".$ii); ?>
72
  </div>
73
  <div id="altFormat" style="">
74
  <div style="width:100%;"><strong id="altFormatText"><?php _e('Post Text Format', 'nxs_snap'); ?></strong> (<a href="#" id="apLJMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apLJMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)
75
  </div>
76
 
77
+ <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")), 'nxs_snap'); ?></textarea>
78
 
79
  <?php nxs_doShowHint("apLJMsgFrmt".$ii); ?>
80
  </div>
81
+ <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"; ?> />
82
  <strong><?php _e('Post with tags.', 'nxs_snap') ?></strong> <?php _e('Tags from the blogpost will be auto posted to LiveJournal', 'nxs_snap') ?>
83
  </p><br/>
84
+ <?php if ($options['ljPass']!='') { ?>
85
+
86
  <b><?php _e('Test your settings', 'nxs_snap'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('LJ', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'nxs_snap' ), $nType); ?></a> <?php } ?>
87
+ </div>
88
+ <?php /* ######################## Advanced Tab ####################### */ ?>
89
+ <div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content">
90
+
91
+ <?php if (!$isNew) { ?> <div class="nxs_tls_cpt"><?php _e('Categories', 'nxs_snap'); ?></div>
92
+ <div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
93
+ <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
94
+ <input value="1" id="catSelS<?php echo $ntU; ?><?php echo $ii; ?>" type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_<?php echo $ntU; ?><?php echo $ii; ?>" onclick="jQuery('#catSelS<?php echo $ntU; ?><?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('<?php echo $ntU; ?><?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($options['catSelEd']!='') echo "[".(substr_count($options['catSelEd'], ",")+1)."]"; ?></a>
95
+ <input type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
96
+ <br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
97
+ <br/>
98
+ <?php } ?>
99
+
100
+ <?php nxs_addPostingDelaySelV3($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']); ?>
101
+ <?php nxs_showRepostSettings($nt, $ii, $options); ?>
102
+
103
+
104
+ </div> <?php /* #### End of Tab #### */ ?>
105
+ </div><br/> <?php /* #### End of Tabs #### */ ?>
106
+
107
+ <div class="submit clear" style="padding-bottom: 0px;"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div></div><?php
108
  }
109
  //#### Set Unit Settings from POST
110
  function setNTSettings($post, $options){ global $nxs_snapThisPageUrl; $code = 'LJ'; $lcode = 'lj';
126
  $options[$ii]['commID'] = trim($pval['commID']);
127
  }
128
  if (isset($pval['apDoLJ'])) $options[$ii]['doLJ'] = $pval['apDoLJ']; else $options[$ii]['doLJ'] = 0;
129
+
130
+ $options[$ii] = nxs_adjRpst($options[$ii], $pval);
131
+
132
+ if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']);
133
  if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
134
  if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
135
  }
136
  } return $options;
137
  }
138
  //#### Show Post->Edit Meta Box Settings
139
+ function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID; $nt = 'lj'; $ntU = 'LJ';
140
  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]);
141
  $doLJ = $ntOpt['doLJ'] && (is_array($pMeta) || $ntOpt['catSel']!='1');
142
  $isAvailLJ = $ntOpt['ljUName']!='' && $ntOpt['ljPass']!=''; $ljMsgFormat = htmlentities($ntOpt['ljMsgFormat'], ENT_COMPAT, "UTF-8"); $ljMsgTFormat = htmlentities($ntOpt['ljMsgTFormat'], ENT_COMPAT, "UTF-8");
143
  ?>
144
  <tr><th style="text-align:left;" colspan="2"><?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_LJ<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
145
  <?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"'; ?> />
146
+
147
+
148
  <?php if ($post->post_status == "publish") { ?> <input type="hidden" name="lj[<?php echo $ii; ?>][doLJ]" value="<?php echo $doLJ;?>"> <?php } ?> <?php } ?>
149
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/lj16.png);">LiveJournal - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
150
  if ($post->post_status == "publish" && $isAvailLJ) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="shoLJopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToLJ_repostButton" id="rePostToLJ_button" value="<?php _e('Repost to LiveJournal', 'nxs_snap') ?>" />
151
+ <?php } ?>
152
 
153
  <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
154
  ?> <span id="pstdLJ<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
158
  </td></tr>
159
 
160
  <?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>
161
+ <?php } else { if ($post->post_status != "publish" && function_exists('nxs_doSMAS5') ) { nxs_doSMAS5($nt, $ii, $ntOpt); } ?>
162
+
163
+ <?php if ($ntOpt['rpstOn']=='1') { ?>
164
+
165
+ <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top:6px; text-align:right; width:60px; padding-right:10px;">
166
+ <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"; ?> />
167
+ </th>
168
+ <td> <?php _e('Include in "Auto-Reposting" to this network.', 'nxs_snap') ?>
169
+ </td></tr> <?php } ?>
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('Title Format:', 'nxs_snap') ?></th>
172
  <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>
183
  function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
184
  if (isset($pMeta['SNAPformat'])) $optMt['ljMsgFormat'] = $pMeta['SNAPformat'];
185
  if (isset($pMeta['SNAPformatT'])) $optMt['ljMsgTFormat'] = $pMeta['SNAPformatT'];
186
+ if (isset($pMeta['imgToUse'])) $optMt['imgToUse'] = $pMeta['imgToUse'];
187
+ if (isset($pMeta['timeToRun'])) $optMt['timeToRun'] = $pMeta['timeToRun']; if (isset($pMeta['rpstPostIncl'])) $optMt['rpstPostIncl'] = $pMeta['rpstPostIncl'];
188
  if (isset($pMeta['doLJ'])) $optMt['doLJ'] = $pMeta['doLJ'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doLJ'] = 0; }
189
  if (isset($pMeta['SNAPincludeLJ']) && $pMeta['SNAPincludeLJ'] == '1' ) $optMt['doLJ'] = 1;
190
  return $optMt;
191
  }
192
  }}
193
  if (!function_exists("nxs_rePostToLJ_ajax")) {
194
+ function nxs_rePostToLJ_ajax() { check_ajax_referer('nxsSsPageWPN'); $postID = $_POST['id']; $options = get_option('NS_SNAutoPoster');
195
  foreach ($options['lj'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj';//if ($two['gpPageID'].$two['gpUName']==$_POST['nid']) {
196
  $gppo = get_post_meta($postID, 'snapLJ', true); $gppo = maybe_unserialize($gppo);// prr($gppo);
197
  if (is_array($gppo) && isset($gppo[$ii]) && is_array($gppo[$ii])){ $ntClInst = new nxs_snapClassLJ(); $two = $ntClInst->adjMetaOpt($two, $gppo[$ii]); }
201
  }
202
 
203
  if (!function_exists("nxs_doPublishToLJ")) { //## Second Function to Post to LJ
204
+ 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));
205
  //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToLJ', array($postID, $options));
206
+ $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url();
207
+ $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'ACCNAME'=>$options['nName'], 'POSTID'=>$postID));
208
  $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
209
  $logNT = '<span style="color:#2097EE">LJ</span> - '.$options['nName'];
210
  $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
213
  nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$uqID); return;
214
  }
215
  }
216
+ //$imgURL = nxs_getPostImage($postID);
217
  $email = $options['ljUName']; $pass = substr($options['ljPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['ljPass'], 5)):$options['ljPass'];
218
+ 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;
219
+ $options['ljMsgFormat'] = nsFormatMessage($options['ljMsgFormat'], $postID, $addParams); $options['ljMsgTFormat'] = nsFormatMessage($options['ljMsgTFormat'], $postID, $addParams);
220
  nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
221
  } //prr($msg); prr($msgFormat);
222
+ $extInfo = ' | PostID: '.$postID." - ".(isset($post) && is_object($post)?$post->post_title:'');
223
+ //## Post
224
+ $t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = implode(',', $tggs);
225
+ $message = array('siteName'=>$blogTitle, 'tags'=>$tags);// prr($message);
226
+ //## Actual Post
227
+ $ntToPost = new nxs_class_SNAP_LJ(); $ret = $ntToPost->doPostToNT($options, $message);
228
+ //## Process Results
229
+ if (!is_array($ret) || $ret['isPosted']!='1') { //## Error
230
+ if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);
231
+ } else { // ## All Good - log it.
232
+ if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo _e('OK - Message Posted, please see your '.$logNT.' Page. ', 'nxs_snap'); }
233
+ 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); }
234
+ }
235
+ //## Return Result
236
+ if ($ret['isPosted']=='1') return 200; else return print_r($ret, true);
 
 
 
 
 
 
237
  }
238
  }
239
  ?>
inc-cl/pk.api.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //## NextScripts FriendFeed Connection Class
3
+ $nxs_snapAPINts[] = array('code'=>'PK', 'lcode'=>'pk', 'name'=>'Plurk');
4
+
5
+ if (!class_exists("nxs_class_SNAP_PK")) { class nxs_class_SNAP_PK {
6
+
7
+ var $ntCode = 'PK';
8
+ var $ntLCode = 'pk';
9
+
10
+ function doPost($options, $message){ if (!is_array($options)) return false;
11
+ foreach ($options as $ntOpts) $out[] = $this->doPostToNT($ntOpts, $message);
12
+ return $out;
13
+ }
14
+ function doPostToNT($options, $message){ $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>'');
15
+ //## Check settings
16
+ if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
17
+ if (!isset($options['pkConsKey']) || trim($options['pkConsSec'])=='') { $badOut['Error'] = 'Not Configured'; return $badOut; }
18
+ //## Format
19
+ $msg = nxs_doFormatMsg($options['pkMsgFormat'], $message);
20
+ //## Post
21
+ require_once('apis/plurkOAuth.php'); $consumer_key = $options['pkConsKey']; $consumer_secret = $options['pkConsSec'];
22
+ $tum_oauth = new wpPlurkOAuth($consumer_key, $consumer_secret, $options['pkAccessTocken'], $options['pkAccessTockenSec']);
23
+ $pkURL = trim(str_ireplace('http://', '', $options['pkURL'])); if (substr($pkURL,-1)=='/') $pkURL = substr($pkURL,0,-1);
24
+ if ($options['pkCat']=='') $options['pkCat'] = ':';
25
+ if ($options['attchImg']=='1') { if (isset($message['imageURL'])) $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); else $imgURL = ''; if ($imgURL!='') $msg .= " ".$imgURL; }
26
+
27
+ $postArr = array('content'=>$msg, 'qualifier'=>$options['pkCat']); $postinfo = $tum_oauth->makeReq('http://www.plurk.com/APP/Timeline/plurkAdd', $postArr); // prr($postinfo);
28
+ 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("|====");
29
+
30
+ if ($code == 200 && $pkID!='') return array('postID'=>$pkID, 'isPosted'=>1, 'postURL'=>$pkID, 'pDate'=>date('Y-m-d H:i:s'));
31
+ else { $badOut['Error'] .= " ERROR: - ".$postinfo['error_text']; }
32
+ return $badOut;
33
+ }
34
+ }}
35
+ ?>
inc-cl/pk.php CHANGED
@@ -36,6 +36,7 @@ if (!class_exists("nxs_snapClassPK")) { class nxs_snapClassPK {
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
 
40
  $options['pkPgID'] = $userinfo; $optionsG = get_option('NS_SNAutoPoster'); $optionsG['pk'][$_GET['acc']] = $options; update_option('NS_SNAutoPoster', $optionsG);
41
 
@@ -46,7 +47,7 @@ if (!class_exists("nxs_snapClassPK")) { class nxs_snapClassPK {
46
  <div class="nxs_box">
47
  <div class="nxs_box_header">
48
  <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']; ?>
49
- <?php $cbo = count($ntOpts); ?> <?php wp_nonce_field( 'ns'.$ntInfo['code'], 'ns'.$ntInfo['code'].'_wpnonce' ); ?>
50
  <?php if ($cbo>1){ ?><div class="nsBigText"><?php echo "(".($cbo=='0'?'No':$cbo)." "; _e('accounts', 'nxs_snap'); echo ")"; ?></div><?php } ?>
51
  </div>
52
  </div>
@@ -54,35 +55,39 @@ if (!class_exists("nxs_snapClassPK")) { class nxs_snapClassPK {
54
  <?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = str_ireplace('https://','', str_ireplace('http://','', $pbo['pkURL']));
55
  if (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='') $pbo[$ntInfo['lcode'].'OK'] = (isset($pbo['pkOAuthTokenSecret']) && $pbo['pkOAuthTokenSecret']!='')?'1':''; ?>
56
  <p style="margin:0px;margin-left:5px;">
57
- <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> /> <?php if ((int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
 
 
58
  <strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
59
  &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', 'nxs_snap'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>&nbsp;&nbsp;
60
  <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
61
- </p><?php $this->showNTSettings($indx, $pbo);
62
  }?>
63
  </div>
64
  </div> <?php
65
  }
66
  //#### Show NEW Settings Page
67
- function showNewNTSettings($bo){ $po = array('nName'=>'', 'doPK'=>'1', 'pkURL'=>'', 'pkPgID'=>'', 'pkConsKey'=>'', 'pkInclTags'=>'1', 'cImgURL'=>'R', 'pkConsSec'=>'', 'pkPostType'=>'T', 'pkDefImg'=>'', 'pkOAuthTokenSecret'=>'', 'pkAccessTocken'=>'', 'pkMsgFormat'=>'%TITLE% - %URL%'); $this->showNTSettings($bo, $po, true);}
68
  //#### Show Unit Settings
69
- function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl,$nxs_snapThisPageUrl; ?>
70
- <div id="doPK<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>" style="background-image: url(<?php echo $nxs_plurl; ?>img/pk-bg.png); background-position:90% 10%;"> <input type="hidden" name="apDoSPK<?php echo $ii; ?>" value="0" id="apDoSPK<?php echo $ii; ?>" />
 
 
71
  <?php if ($isNew) { ?> <input type="hidden" name="pk[<?php echo $ii; ?>][apDoPK]" value="1" id="apDoNewPK<?php echo $ii; ?>" /> <?php } ?>
72
 
73
  <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', 'nxs_snap' ), $nType); ?></a></div>
74
 
75
- <div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easely identify it', 'nxs_snap'); ?></i> </div><input name="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")), 'nxs_snap') ?>" /><br/>
76
- <?php echo nxs_addQTranslSel('pk', $ii, $options['qTLng']); ?><?php echo nxs_addPostingDelaySel('pk', $ii, $options['nHrs'], $options['nMin']); ?>
77
 
78
- <?php if (!$isNew) { ?>
79
- <div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
80
- <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="pk[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
81
- <input value="1" id="catSelSPK<?php echo $ii; ?>" type="radio" name="pk[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_PK<?php echo $ii; ?>" onclick="jQuery('#catSelSPK<?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('PK<?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_PK<?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($options['catSelEd']!='') echo "[".(substr_count($options['catSelEd'], ",")+1)."]"; ?></a>
82
- <input type="hidden" name="pk[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_PK<?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
83
- <br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
84
- <br/>
85
- <?php } ?>
86
 
87
  <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")), 'nxs_snap') ?>" /><span style="color: #F00000;" id="apPKURLerr<?php echo $ii; ?>"></span>
88
  <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")), 'nxs_snap') ?>" />
@@ -121,10 +126,30 @@ if (!class_exists("nxs_snapClassPK")) { class nxs_snapClassPK {
121
 
122
 
123
  <?php if( isset($options['pkOAuthTokenSecret']) && $options['pkOAuthTokenSecret']!='') { ?>
124
- <?php wp_nonce_field( 'rePostToPK', 'rePostToPK_wpnonce' ); ?>
125
  <br/><br/><b><?php _e('Test your settings', 'nxs_snap'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('PK', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'nxs_snap' ), $nType); ?></a> <br/><br/>
126
  <?php }?>
127
- <div class="submit"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
 
129
  </div>
130
  <?php
@@ -151,17 +176,21 @@ if (!class_exists("nxs_snapClassPK")) { class nxs_snapClassPK {
151
  if (isset($pval['apPKMsgFrmt'])) $options[$ii]['pkMsgFormat'] = trim($pval['apPKMsgFrmt']);
152
  if (isset($pval['Cat'])) $options[$ii]['pkCat'] = $pval['Cat']; else $options[$ii]['pkCat'] = "";
153
  if (isset($pval['attchImg'])) $options[$ii]['attchImg'] = $pval['attchImg']; else $options[$ii]['attchImg'] = 0;
 
 
 
 
154
  if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
155
  if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
156
  } // prr($options);
157
  } return $options;
158
  }
159
  //#### Show Post->Edit Meta Box Settings
160
- function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
161
  foreach($ntOpts as $ii=>$options) {$pMeta = maybe_unserialize(get_post_meta($post_id, 'snapPK', true)); if (is_array($pMeta)) $options = $this->adjMetaOpt($options, $pMeta[$ii]);
162
  $doPK = $options['doPK'] && (is_array($pMeta) || $options['catSel']!='1');
163
  $isAvailPK = isset($options['pkAccessTocken']) && isset($options['pkAccessTocken']['oauth_token_secret']) && $options['pkAccessTocken']['oauth_token_secret']!=='';
164
- $pkMsgFormat = htmlentities($options['pkMsgFormat'], ENT_COMPAT, "UTF-8"); $pkMsgTFormat = htmlentities($options['pkMsgTFormat'], ENT_COMPAT, "UTF-8");
165
  ?>
166
 
167
  <tr><th style="text-align:left;" colspan="2"><?php if ( $options['catSel']=='1' && trim($options['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_PK<?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" /> <?php } ?>
@@ -169,7 +198,7 @@ if (!class_exists("nxs_snapClassPK")) { class nxs_snapClassPK {
169
  <?php if ($post->post_status == "publish") { ?> <input type="hidden" name="pk[<?php echo $ii; ?>][doPK]" value="<?php echo $doPK;?>"> <?php } ?> <?php } ?>
170
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/pk16.png);">Plurk - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $options['nName']; ?></i>) </div></th><td><?php //## Only show RePost button if the post is "published"
171
  if ($post->post_status == "publish" && $isAvailPK) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToPK_repostButton" id="rePostToPK_button" value="<?php _e('Repost to Plurk', 'nxs_snap') ?>" />
172
- <?php wp_nonce_field( 'rePostToPK', 'rePostToPK_wpnonce' ); } ?>
173
 
174
  <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
175
  ?> <span id="pstdPK<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
@@ -178,7 +207,15 @@ if (!class_exists("nxs_snapClassPK")) { class nxs_snapClassPK {
178
 
179
  </td></tr>
180
  <?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>
181
- <?php }elseif ($post->post_status != "puZblish") { ?>
 
 
 
 
 
 
 
 
182
 
183
  <tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;">
184
  Prefix:
@@ -186,7 +223,7 @@ if (!class_exists("nxs_snapClassPK")) { class nxs_snapClassPK {
186
  </th>
187
  <td><select name="pk[<?php echo $ii; ?>][Cat]" id="apPKCat<?php echo $ii; ?>">
188
  <?php $pkCats = $this->pkCats();
189
- if ($ntOpt['pkCat']!='') $pkCats = str_replace($ntOpt['pkCat'].'"', $ntOpt['pkCat'].'" selected="selected"', $pkCats); echo $pkCats;
190
 
191
  ?>
192
  </select></td></tr>
@@ -203,6 +240,8 @@ if (!class_exists("nxs_snapClassPK")) { class nxs_snapClassPK {
203
 
204
  function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
205
  if (isset($pMeta['SNAPformat'])) $optMt['pkMsgFormat'] = $pMeta['SNAPformat'];
 
 
206
  if (isset($pMeta['Cat'])) $optMt['pkCat'] = $pMeta['Cat'];
207
  if (isset($pMeta['doPK'])) $optMt['doPK'] = $pMeta['doPK'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doPK'] = 0; }
208
  if (isset($pMeta['SNAPincludePK']) && $pMeta['SNAPincludePK'] == '1' ) $optMt['doPK'] = 1;
@@ -210,7 +249,7 @@ if (!class_exists("nxs_snapClassPK")) { class nxs_snapClassPK {
210
  }
211
  }}
212
 
213
- if (!function_exists("nxs_rePostToPK_ajax")) { function nxs_rePostToPK_ajax() { check_ajax_referer('rePostToPK'); $postID = $_POST['id']; // $result = nsPublishTo($id, 'FB', true);
214
  $options = get_option('NS_SNAutoPoster'); foreach ($options['pk'] as $ii=>$po) if ($ii==$_POST['nid']) { $po['ii'] = $ii; $po['pType'] = 'aj';
215
  $mpo = get_post_meta($postID, 'snapPK', true); $mpo = maybe_unserialize($mpo);
216
  if (is_array($mpo) && isset($mpo[$ii]) && is_array($mpo[$ii]) ){ $ntClInst = new nxs_snapClassPK(); $po = $ntClInst->adjMetaOpt($po, $mpo[$ii]); }
@@ -220,9 +259,11 @@ if (!function_exists("nxs_rePostToPK_ajax")) { function nxs_rePostToPK_ajax() {
220
  }
221
 
222
  if (!function_exists("nxs_doPublishToPK")) { //## Second Function to Post to TR
223
- function nxs_doPublishToPK($postID, $options){ $ntCd = 'PK'; $ntCdL = 'pk'; $ntNm = 'Plurk';
224
  //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToPK', array($postID, $options));
225
  $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url();
 
 
226
 
227
  $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
228
  $logNT = '<span style="color:#014A76">Plurk</span> - '.$options['nName'];
@@ -234,9 +275,10 @@ if (!function_exists("nxs_doPublishToPK")) { //## Second Function to Post to TR
234
  }
235
  //## Format
236
  if ($postID=='0') { echo "Testing ... <br/><br/>"; $msg = 'Test Post from '.$blogTitle; $msgT = 'Test Post from '.$blogTitle;}
237
- else{ $post = get_post($postID); if(!$post) return; $twMsgFormat = $options['pkMsgFormat']; nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1')); $twLim = 180;
238
- $extInfo = ' | PostID: '.$postID." - ".$post->post_title;
239
- if (stripos($twMsgFormat, '%URL%')!==false || stripos($twMsgFormat, '%SURL%')!==false) $twLim = $twLim - 5;
 
240
  if (stripos($twMsgFormat, '%AUTHORNAME%')!==false) { $aun = $post->post_author; $aun = get_the_author_meta('display_name', $aun ); $twLim = $twLim - strlen($aun); }
241
 
242
  $noRepl = str_ireplace("%TITLE%", "", $twMsgFormat); $noRepl = str_ireplace("%SITENAME%", "", $noRepl); $noRepl = str_ireplace("%URL%", "", $noRepl);$noRepl = str_ireplace("%RAWEXCERPT%", "", $noRepl);
@@ -245,50 +287,34 @@ if (!function_exists("nxs_doPublishToPK")) { //## Second Function to Post to TR
245
 
246
  $pTitle = $title = $post->post_title;
247
  if ($post->post_excerpt!="") $pText = apply_filters('the_content', $post->post_excerpt); else $pText= apply_filters('the_content', $post->post_content);
248
- $pFullText = apply_filters('the_content', $post->post_content);
249
- $pRawText = $post->post_content;
250
-
251
-
252
- if (stripos($twMsgFormat, '%TITLE%')!==false) {
253
- $pTitle = nsTrnc($pTitle, $twLim); $twMsgFormat = str_ireplace("%TITLE%", $pTitle, $twMsgFormat); $twLim = $twLim - strlen($pTitle);
254
- }
255
  if (stripos($twMsgFormat, '%SITENAME%')!==false) {
256
  $siteTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); $siteTitle = nsTrnc($siteTitle, $twLim); $twMsgFormat = str_ireplace("%SITENAME%", $siteTitle, $twMsgFormat); $twLim = $twLim - strlen($siteTitle);
257
  }
258
- if (stripos($twMsgFormat, '%EXCERPT%')!==false) {
259
- $pText = nsTrnc(strip_tags(strip_shortcodes($pText)), 300, " ", "...");
260
  $pText = nsTrnc($pText, $twLim); $twMsgFormat = str_ireplace("%EXCERPT%", $pText, $twMsgFormat); $twLim = $twLim - strlen($pText);
261
  }
262
- if (stripos($twMsgFormat, '%FULLTEXT%')!==false) {
263
- $pFullText = nsTrnc(strip_tags($pFullText), $twLim); $twMsgFormat = str_ireplace("%FULLTEXT%", $pFullText, $twMsgFormat); $twLim = $twLim - strlen($pFullText);
264
- }
265
- if (stripos($twMsgFormat, '%RAWTEXT%')!==false) {
266
- $pRawText = nsTrnc(strip_tags($pRawText), $twLim); $twMsgFormat = str_ireplace("%FULLTEXT%", $pRawText, $twMsgFormat); $twLim = $twLim - strlen($pRawText);
267
- }
268
-
269
- $msg = nsFormatMessage($twMsgFormat, $postID);
270
-
271
  }
272
- //## Post
273
- require_once('apis/plurkOAuth.php'); $consumer_key = $options['pkConsKey']; $consumer_secret = $options['pkConsSec'];
274
- $tum_oauth = new wpPlurkOAuth($consumer_key, $consumer_secret, $options['pkAccessTocken'], $options['pkAccessTockenSec']);
275
- $pkURL = trim(str_ireplace('http://', '', $options['pkURL'])); if (substr($pkURL,-1)=='/') $pkURL = substr($pkURL,0,-1);
276
- if ($options['pkCat']=='')$options['pkCat'] = ':';
277
-
278
- if ($options['attchImg']=='1') { $imgURL = nxs_getPostImage($postID); $msg .= " ".$imgURL; }
279
-
280
- $postDate = ($post->post_date_gmt!='0000-00-00 00:00:00'?$post->post_date_gmt:gmdate("Y-m-d H:i:s", strtotime($post->post_date)))." GMT"; //## Adds date to Tumblr post. Thanks to Kenneth Lecky
281
-
282
- $postArr = array('content'=>$msg, 'qualifier'=>$options['pkCat']);
283
- $postinfo = $tum_oauth->makeReq('http://www.plurk.com/APP/Timeline/plurkAdd', $postArr); // prr($postinfo);
284
- if (is_array($postinfo) && isset($postinfo['plurk_id'])) $pkID = $postinfo['plurk_id'];
285
-
286
- $code = $tum_oauth->http_code;// echo "XX".print_r($code); prr($postinfo); // prr($msg); prr($postinfo); echo $code."VVVV"; die("|====");
287
- if ($code == 200) { if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo 'OK - Message Posted, please see your Plurk Page. <br/> Result:'; }
288
- else { nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); nxs_metaMarkAsPosted($postID, 'PK', $options['ii'], array('isPosted'=>'1', 'pgID'=>$pkID, 'pDate'=>date('Y-m-d H:i:s'))); } }
289
- else { nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($postinfo, true), $extInfo); if ($postID=='0') prr($postinfo); $code .= " ERROR: - ".$postinfo['error_text']; }
290
-
291
- return $code;
292
  }
293
  }
294
 
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'];
40
 
41
  $options['pkPgID'] = $userinfo; $optionsG = get_option('NS_SNAutoPoster'); $optionsG['pk'][$_GET['acc']] = $options; update_option('NS_SNAutoPoster', $optionsG);
42
 
47
  <div class="nxs_box">
48
  <div class="nxs_box_header">
49
  <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']; ?>
50
+ <?php $cbo = count($ntOpts); ?>
51
  <?php if ($cbo>1){ ?><div class="nsBigText"><?php echo "(".($cbo=='0'?'No':$cbo)." "; _e('accounts', 'nxs_snap'); echo ")"; ?></div><?php } ?>
52
  </div>
53
  </div>
55
  <?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = str_ireplace('https://','', str_ireplace('http://','', $pbo['pkURL']));
56
  if (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='') $pbo[$ntInfo['lcode'].'OK'] = (isset($pbo['pkOAuthTokenSecret']) && $pbo['pkOAuthTokenSecret']!='')?'1':''; ?>
57
  <p style="margin:0px;margin-left:5px;">
58
+ <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> />
59
+ <?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 } ?>
60
+ <?php if (isset($pbo['rpstOn']) && (int)$pbo['rpstOn'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popReActive');" onmouseover="nxs_showPopUpInfo('popReActive', event);"><?php echo "*[R]*" ?></span><?php } ?>
61
  <strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
62
  &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', 'nxs_snap'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>&nbsp;&nbsp;
63
  <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
64
+ </p><?php $pbo['ntInfo'] = $ntInfo; $this->showNTSettings($indx, $pbo);
65
  }?>
66
  </div>
67
  </div> <?php
68
  }
69
  //#### Show NEW Settings Page
70
+ 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);}
71
  //#### Show Unit Settings
72
+ function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl,$nxs_snapThisPageUrl; $nt = $options['ntInfo']['lcode']; $ntU = strtoupper($nt);
73
+ 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'] = '';
74
+ if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; if (!isset($options['attchImg'])) $options['attchImg'] = ''; ?>
75
+ <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; ?>" />
76
  <?php if ($isNew) { ?> <input type="hidden" name="pk[<?php echo $ii; ?>][apDoPK]" value="1" id="apDoNewPK<?php echo $ii; ?>" /> <?php } ?>
77
 
78
  <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', 'nxs_snap' ), $nType); ?></a></div>
79
 
80
+ <div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'nxs_snap'); ?></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")), 'nxs_snap') ?>" /><br/>
81
+ <?php echo nxs_addQTranslSel('pk', $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', 'nxs_snap'); ?></a></li>
86
+ <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'nxs_snap'); ?></a></li>
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
 
92
  <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")), 'nxs_snap') ?>" /><span style="color: #F00000;" id="apPKURLerr<?php echo $ii; ?>"></span>
93
  <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")), 'nxs_snap') ?>" />
126
 
127
 
128
  <?php if( isset($options['pkOAuthTokenSecret']) && $options['pkOAuthTokenSecret']!='') { ?>
129
+
130
  <br/><br/><b><?php _e('Test your settings', 'nxs_snap'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('PK', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'nxs_snap' ), $nType); ?></a> <br/><br/>
131
  <?php }?>
132
+ </div>
133
+ <?php /* ######################## Advanced Tab ####################### */ ?>
134
+ <div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content">
135
+
136
+ <?php if (!$isNew) { ?> <div class="nxs_tls_cpt"><?php _e('Categories', 'nxs_snap'); ?></div>
137
+ <div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
138
+ <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
139
+ <input value="1" id="catSelS<?php echo $ntU; ?><?php echo $ii; ?>" type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_<?php echo $ntU; ?><?php echo $ii; ?>" onclick="jQuery('#catSelS<?php echo $ntU; ?><?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('<?php echo $ntU; ?><?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($options['catSelEd']!='') echo "[".(substr_count($options['catSelEd'], ",")+1)."]"; ?></a>
140
+ <input type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
141
+ <br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
142
+ <br/>
143
+ <?php } ?>
144
+
145
+ <?php nxs_addPostingDelaySelV3($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']); ?>
146
+ <?php nxs_showRepostSettings($nt, $ii, $options); ?>
147
+
148
+
149
+ </div> <?php /* #### End of Tab #### */ ?>
150
+ </div><br/> <?php /* #### End of Tabs #### */ ?>
151
+
152
+ <div class="submit clear" style="padding-bottom: 0px;"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div>
153
 
154
  </div>
155
  <?php
176
  if (isset($pval['apPKMsgFrmt'])) $options[$ii]['pkMsgFormat'] = trim($pval['apPKMsgFrmt']);
177
  if (isset($pval['Cat'])) $options[$ii]['pkCat'] = $pval['Cat']; else $options[$ii]['pkCat'] = "";
178
  if (isset($pval['attchImg'])) $options[$ii]['attchImg'] = $pval['attchImg']; else $options[$ii]['attchImg'] = 0;
179
+
180
+ $options[$ii] = nxs_adjRpst($options[$ii], $pval);
181
+
182
+ if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']);
183
  if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
184
  if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
185
  } // prr($options);
186
  } return $options;
187
  }
188
  //#### Show Post->Edit Meta Box Settings
189
+ function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID; $nt = 'pk'; $ntU = 'PK';
190
  foreach($ntOpts as $ii=>$options) {$pMeta = maybe_unserialize(get_post_meta($post_id, 'snapPK', true)); if (is_array($pMeta)) $options = $this->adjMetaOpt($options, $pMeta[$ii]);
191
  $doPK = $options['doPK'] && (is_array($pMeta) || $options['catSel']!='1');
192
  $isAvailPK = isset($options['pkAccessTocken']) && isset($options['pkAccessTocken']['oauth_token_secret']) && $options['pkAccessTocken']['oauth_token_secret']!=='';
193
+ $pkMsgFormat = htmlentities($options['pkMsgFormat'], ENT_COMPAT, "UTF-8");
194
  ?>
195
 
196
  <tr><th style="text-align:left;" colspan="2"><?php if ( $options['catSel']=='1' && trim($options['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_PK<?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" /> <?php } ?>
198
  <?php if ($post->post_status == "publish") { ?> <input type="hidden" name="pk[<?php echo $ii; ?>][doPK]" value="<?php echo $doPK;?>"> <?php } ?> <?php } ?>
199
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/pk16.png);">Plurk - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $options['nName']; ?></i>) </div></th><td><?php //## Only show RePost button if the post is "published"
200
  if ($post->post_status == "publish" && $isAvailPK) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToPK_repostButton" id="rePostToPK_button" value="<?php _e('Repost to Plurk', 'nxs_snap') ?>" />
201
+ <?php } ?>
202
 
203
  <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
204
  ?> <span id="pstdPK<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
207
 
208
  </td></tr>
209
  <?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>
210
+ <?php }else { if ($post->post_status != "publish" && function_exists('nxs_doSMAS5') ) { nxs_doSMAS5($nt, $ii, $options); } ?>
211
+
212
+ <?php if ($options['rpstOn']=='1') { ?>
213
+
214
+ <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top:6px; text-align:right; width:60px; padding-right:10px;">
215
+ <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"; ?> />
216
+ </th>
217
+ <td> <?php _e('Include in "Auto-Reposting" to this network.', 'nxs_snap') ?>
218
+ </td></tr> <?php } ?>
219
 
220
  <tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;">
221
  Prefix:
223
  </th>
224
  <td><select name="pk[<?php echo $ii; ?>][Cat]" id="apPKCat<?php echo $ii; ?>">
225
  <?php $pkCats = $this->pkCats();
226
+ if ($options['pkCat']!='') $pkCats = str_replace($options['pkCat'].'"', $options['pkCat'].'" selected="selected"', $pkCats); echo $pkCats;
227
 
228
  ?>
229
  </select></td></tr>
240
 
241
  function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
242
  if (isset($pMeta['SNAPformat'])) $optMt['pkMsgFormat'] = $pMeta['SNAPformat'];
243
+ if (isset($pMeta['imgToUse'])) $optMt['imgToUse'] = $pMeta['imgToUse'];
244
+ if (isset($pMeta['timeToRun'])) $optMt['timeToRun'] = $pMeta['timeToRun']; if (isset($pMeta['rpstPostIncl'])) $optMt['rpstPostIncl'] = $pMeta['rpstPostIncl'];
245
  if (isset($pMeta['Cat'])) $optMt['pkCat'] = $pMeta['Cat'];
246
  if (isset($pMeta['doPK'])) $optMt['doPK'] = $pMeta['doPK'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doPK'] = 0; }
247
  if (isset($pMeta['SNAPincludePK']) && $pMeta['SNAPincludePK'] == '1' ) $optMt['doPK'] = 1;
249
  }
250
  }}
251
 
252
+ if (!function_exists("nxs_rePostToPK_ajax")) { function nxs_rePostToPK_ajax() { check_ajax_referer('nxsSsPageWPN'); $postID = $_POST['id']; // $result = nsPublishTo($id, 'FB', true);
253
  $options = get_option('NS_SNAutoPoster'); foreach ($options['pk'] as $ii=>$po) if ($ii==$_POST['nid']) { $po['ii'] = $ii; $po['pType'] = 'aj';
254
  $mpo = get_post_meta($postID, 'snapPK', true); $mpo = maybe_unserialize($mpo);
255
  if (is_array($mpo) && isset($mpo[$ii]) && is_array($mpo[$ii]) ){ $ntClInst = new nxs_snapClassPK(); $po = $ntClInst->adjMetaOpt($po, $mpo[$ii]); }
259
  }
260
 
261
  if (!function_exists("nxs_doPublishToPK")) { //## Second Function to Post to TR
262
+ function nxs_doPublishToPK($postID, $options){ $ntCd = 'PK'; $ntCdL = 'pk'; $ntNm = 'Plurk'; if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
263
  //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToPK', array($postID, $options));
264
  $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url();
265
+ $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'POSTID'=>$postID, 'ACCNAME'=>$options['nName']));
266
+ if (empty($options['imgToUse'])) $options['imgToUse'] = ''; if (empty($options['imgSize'])) $options['imgSize'] = '';
267
 
268
  $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
269
  $logNT = '<span style="color:#014A76">Plurk</span> - '.$options['nName'];
275
  }
276
  //## Format
277
  if ($postID=='0') { echo "Testing ... <br/><br/>"; $msg = 'Test Post from '.$blogTitle; $msgT = 'Test Post from '.$blogTitle;}
278
+ else { $post = get_post($postID); if(!$post) return; $twMsgFormat = $options['pkMsgFormat']; nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1')); $twLim = 180;
279
+ $extInfo = ' | PostID: '.$postID." - ".$post->post_title;
280
+
281
+ if (stripos($twMsgFormat, '%URL%')!==false || stripos($twMsgFormat, '%SURL%')!==false) $twLim = $twLim - 5;
282
  if (stripos($twMsgFormat, '%AUTHORNAME%')!==false) { $aun = $post->post_author; $aun = get_the_author_meta('display_name', $aun ); $twLim = $twLim - strlen($aun); }
283
 
284
  $noRepl = str_ireplace("%TITLE%", "", $twMsgFormat); $noRepl = str_ireplace("%SITENAME%", "", $noRepl); $noRepl = str_ireplace("%URL%", "", $noRepl);$noRepl = str_ireplace("%RAWEXCERPT%", "", $noRepl);
287
 
288
  $pTitle = $title = $post->post_title;
289
  if ($post->post_excerpt!="") $pText = apply_filters('the_content', $post->post_excerpt); else $pText= apply_filters('the_content', $post->post_content);
290
+ $pFullText = apply_filters('the_content', $post->post_content); $pRawText = $post->post_content;
291
+
292
+ if (stripos($twMsgFormat, '%TITLE%')!==false) { $pTitle = nsTrnc($pTitle, $twLim); $twMsgFormat = str_ireplace("%TITLE%", $pTitle, $twMsgFormat); $twLim = $twLim - strlen($pTitle); }
 
 
 
 
293
  if (stripos($twMsgFormat, '%SITENAME%')!==false) {
294
  $siteTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); $siteTitle = nsTrnc($siteTitle, $twLim); $twMsgFormat = str_ireplace("%SITENAME%", $siteTitle, $twMsgFormat); $twLim = $twLim - strlen($siteTitle);
295
  }
296
+ if (stripos($twMsgFormat, '%EXCERPT%')!==false) { $pText = nsTrnc(strip_tags(strip_shortcodes($pText)), 300, " ", "...");
 
297
  $pText = nsTrnc($pText, $twLim); $twMsgFormat = str_ireplace("%EXCERPT%", $pText, $twMsgFormat); $twLim = $twLim - strlen($pText);
298
  }
299
+ if (stripos($twMsgFormat, '%FULLTEXT%')!==false) { $pFullText = nsTrnc(strip_tags($pFullText), $twLim); $twMsgFormat = str_ireplace("%FULLTEXT%", $pFullText, $twMsgFormat); $twLim = $twLim - strlen($pFullText); }
300
+ if (stripos($twMsgFormat, '%RAWTEXT%')!==false) { $pRawText = nsTrnc(strip_tags($pRawText), $twLim); $twMsgFormat = str_ireplace("%FULLTEXT%", $pRawText, $twMsgFormat); $twLim = $twLim - strlen($pRawText); }
301
+ $options['pkMsgFormat'] = nsFormatMessage($twMsgFormat, $postID, $addParams);
 
 
 
 
 
 
302
  }
303
+ if (isset($options['attchImg']) && $options['attchImg']=='1' ) if (!empty($options['imgToUse'])) $imgURL = $options['imgToUse']; else $imgURL = nxs_getPostImage($postID, 'full'); else $imgURL='';
304
+ if (preg_match("/noImg.\.png/i", $imgURL)) $imgURL = '';
305
+ //## Post
306
+ $message = array('siteName'=>$blogTitle, 'tags'=>'', 'imageURL'=>$imgURL);// prr($message);
307
+ //## Actual Post
308
+ $ntToPost = new nxs_class_SNAP_PK(); $ret = $ntToPost->doPostToNT($options, $message);
309
+ //## Process Results
310
+ if (!is_array($ret) || $ret['isPosted']!='1') { //## Error
311
+ if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);
312
+ } else { // ## All Good - log it.
313
+ if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo _e('OK - Message Posted, please see your '.$logNT.' Page. ', 'nxs_snap'); }
314
+ 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); }
315
+ }
316
+ //## Return Result
317
+ if ($ret['isPosted']=='1') return 200; else return print_r($ret, true);
 
 
 
 
 
318
  }
319
  }
320
 
inc-cl/pn.api.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //## NextScripts FriendFeed Connection Class
3
+ $nxs_snapAPINts[] = array('code'=>'PN', 'lcode'=>'pn', 'name'=>'Pinterest');
4
+
5
+ if (!class_exists("nxs_class_SNAP_PN")) { class nxs_class_SNAP_PN {
6
+
7
+ var $ntCode = 'PN';
8
+ var $ntLCode = 'pn';
9
+
10
+ function doPost($options, $message){ if (!is_array($options)) return false;
11
+ foreach ($options as $ntOpts) $out[] = $this->doPostToNT($ntOpts, $message);
12
+ return $out;
13
+ }
14
+ function doPostToNT($options, $message){ 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
+ //## Format
20
+ $msg = nxs_doFormatMsg($options['pnMsgFormat'], $message); $boardID = $options['pnBoard']; // prr($boardID); prr($_POST); die();
21
+ if (isset($message['imageURL'])) $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); else $imgURL = ''; if ($imgURL=='') $badOut['Error'] .= 'NO Image.';
22
+ $urlToGo = (!empty($message['url']))?$message['url']:'';
23
+ //## Check for existing session
24
+ if (isset($options['pnSvC'])) $nxs_gCookiesArr = maybe_unserialize( $options['pnSvC']); $loginError = true; if (is_array($nxs_gCookiesArr)) $loginError = doCheckPinterest();
25
+ if ($loginError!==false) $loginError = doConnectToPinterest($options['pnUName'], $pass); if ($loginError!==false) { $badOut['Error'] = print_r($loginError, true)." - BAD USER/PASS"; return $badOut; }
26
+ if (preg_match ( '/\$(\d+\.\d+)/', $msg, $matches )) $price = $matches[0]; else $price = '';
27
+
28
+ if (isset($options['cImgURL']) && $options['cImgURL']=='S' ) $urlToGo = nxs_mkShortURL($urlToGo); elseif (isset($options['cImgURL']) && $options['cImgURL']=='N' ) $urlToGo = '';
29
+
30
+ $ret = doPostToPinterest($msg, $imgURL, $urlToGo, $boardID, 'TITLE WHERE IS IT?', $price, $urlToGo."/GTH/" ); if ($ret=='OK') $ret = array("code"=>"OK", "post_id"=>'');
31
+ //prr($ret);
32
+ if (is_array($ret) && !empty($ret['post_id'])) return array('postID'=>str_ireplace('/pin/', '', $ret['post_id']), 'isPosted'=>1, 'postURL'=>'http://www.pinterest.com'.$ret['post_id'].'/', 'pDate'=>date('Y-m-d H:i:s'));
33
+ else $badOut['Error'] .= 'Something went wrong - '.print_r($ret, true);
34
+ return $badOut;
35
+ }
36
+ }}
37
+ ?>
inc-cl/pn.php CHANGED
@@ -8,7 +8,7 @@ if (!class_exists("nxs_snapClassPN")) { class nxs_snapClassPN {
8
  <div class="nxs_box">
9
  <div class="nxs_box_header">
10
  <div class="nsx_iconedTitle" style="margin-bottom:1px;background-image:url(<?php echo $nxs_plurl;?>img/<?php echo $ntInfo['lcode']; ?>16.png);"><?php echo $ntInfo['name']; ?>
11
- <?php $cbo = count($ntOpts); ?> <?php wp_nonce_field( 'ns'.$ntInfo['code'], 'ns'.$ntInfo['code'].'_wpnonce' ); ?>
12
  <?php if ($cbo>1){ ?><div class="nsBigText"><?php echo "(".($cbo=='0'?'No':$cbo)." "; _e('accounts', 'nxs_snap'); echo ")"; ?></div><?php } ?>
13
  </div>
14
  </div>
@@ -16,20 +16,25 @@ if (!class_exists("nxs_snapClassPN")) { class nxs_snapClassPN {
16
  <?php if(!function_exists('doPostToPinterest')) {?> Pinterest doesn't have a built-in API for automated posts yet. <br/>You need to get a special <a target="_blank" href="http://www.nextscripts.com/pinterest-automated-posting">library module</a> to be able to publish your content to Pinterest.
17
  <?php } else foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
18
  <p style="margin:0px;margin-left:5px;">
19
- <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> /> <?php if ((int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
 
 
20
  <strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
21
  &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', 'nxs_snap'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>&nbsp;&nbsp;
22
  <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
23
- </p><?php $this->showNTSettings($indx, $pbo);
24
  } ?>
25
  </div>
26
  </div> <?php
27
  }
28
  //#### Show NEW Settings Page
29
- function showNewNTSettings($mgpo){ $po = array('nName'=>'', 'doPN'=>'1', 'pnUName'=>'', 'pnBoard'=>'', 'gpAttch'=>'', 'pnPass'=>'', 'pnDefImg'=>'', 'pnMsgFormat'=>'', 'pnBoard'=>'', 'pnBoardsList'=>'', 'doPN'=>1); $this->showNTSettings($mgpo, $po, true);}
 
30
  //#### Show Unit Settings
31
- function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl; ?>
32
- <div id="doPN<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>" style="background-image: url(<?php echo $nxs_plurl; ?>img/pn-bg.png); background-position:90% 10%;"> <input type="hidden" name="apDoSPN<?php echo $ii; ?>" value="0" id="apDoSPN<?php echo $ii; ?>" />
 
 
33
 
34
  <?php if(!function_exists('doPostToPinterest')) {?><span style="color:#580000; font-size: 16px;"><br/><br/>
35
  <b>Pinterest API Library not found</b>
@@ -39,20 +44,28 @@ if (!class_exists("nxs_snapClassPN")) { class nxs_snapClassPN {
39
 
40
 
41
  <div id="doPN<?php echo $ii; ?>Div" style="margin-left: 10px;"> <div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/pn16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-pinterest-social-networks-auto-poster-wordpress/"><?php $nType="Pinterest"; printf( __( 'Detailed %s Installation/Configuration Instructions', 'nxs_snap' ), $nType); ?></a></div>
42
- <div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easely identify it', 'nxs_snap'); ?></i> </div><input name="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")), 'nxs_snap') ?>" /><br/>
43
- <?php echo nxs_addQTranslSel('pn', $ii, $options['qTLng']); ?><?php echo nxs_addPostingDelaySel('pn', $ii, $options['nHrs'], $options['nMin'], $options['nDays']); ?>
44
 
45
- <?php if (!$isNew) { ?>
46
- <div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
47
- <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="pn[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
48
- <input value="1" id="catSelSPN<?php echo $ii; ?>" type="radio" name="pn[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_PN<?php echo $ii; ?>" onclick="jQuery('#catSelSPN<?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('PN<?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_PN<?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($options['catSelEd']!='') echo "[".(substr_count($options['catSelEd'], ",")+1)."]"; ?></a>
49
- <input type="hidden" name="pn[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_PN<?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
50
- <br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
51
- <br/>
52
- <?php } ?>
 
53
 
54
  <div style="width:100%;"><strong>Pinterest Email:</strong> </div><input name="pn[<?php echo $ii; ?>][apPNUName]" id="apPNUName<?php echo $ii; ?>" class="apPNUName<?php echo $ii; ?>" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['pnUName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
55
  <div style="width:100%;"><strong>Pinterest Password:</strong> </div><input name="pn[<?php echo $ii; ?>][apPNPass]" id="apPNPass<?php echo $ii; ?>" type="password" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities(substr($options['pnPass'], 0, 5)=='g9c1a'?nsx_doDecode(substr($options['pnPass'], 5)):$options['pnPass'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /> <br/>
 
 
 
 
 
 
 
56
  <div style="width:100%;"><strong>Default Image to Pin:</strong>
57
  <p style="font-size: 11px; margin: 0px;">If your post missing Featured Image this will be used instead.</p>
58
  </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")), 'nxs_snap') ?>" />
@@ -61,7 +74,7 @@ if (!class_exists("nxs_snapClassPN")) { class nxs_snapClassPN {
61
  <div style="width:100%;"><strong>Board:</strong>
62
  Please <a href="#" onclick="getBoards(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>
63
  </div>
64
- <?php wp_nonce_field( 'getBoards', 'getBoards_wpnonce' ); ?><img id="pnLoadingImg<?php echo $ii; ?>" style="display: none;" src='<?php echo $nxs_plurl; ?>img/ajax-loader-sm.gif' />
65
  <select name="pn[<?php echo $ii; ?>][apPNBoard]" id="apPNBoard<?php echo $ii; ?>">
66
  <?php if ($options['pnBoardsList']!=''){ $gPNBoards = $options['pnBoardsList']; if ( base64_encode(base64_decode($gPNBoards)) === $gPNBoards) $gPNBoards = base64_decode($gPNBoards);
67
  if ($options['pnBoard']!='') $gPNBoards = str_replace($options['pnBoard'].'"', $options['pnBoard'].'" selected="selected"', $gPNBoards); echo $gPNBoards;} else { ?>
@@ -69,11 +82,10 @@ if (!class_exists("nxs_snapClassPN")) { class nxs_snapClassPN {
69
  <?php } ?>
70
  </select>
71
 
72
- <br/><br/>
73
 
74
  <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', 'nxs_snap'); ?></strong> <i><?php _e('Video will be pinned instead of featured image. Only Youtube is supported at this time.', 'nxs_snap'); ?></i>
75
- <br/></div>
76
-
77
 
78
  <div id="altFormat" style="">
79
  <div style="width:100%;"><strong id="altFormatText"><?php _e('Message text Format', 'nxs_snap'); ?>:</strong> <a href="#" id="apPNMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apPNMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>
@@ -85,11 +97,32 @@ if (!class_exists("nxs_snapClassPN")) { class nxs_snapClassPN {
85
  </div><br/>
86
  <?php if ($isNew) { ?> <input type="hidden" name="pn[<?php echo $ii; ?>][apDoPN]" value="1" id="apDoNewPN<?php echo $ii; ?>" /> <?php } ?>
87
  <?php if ($options['pnPass']!='') { ?>
88
- <?php wp_nonce_field( 'rePostToPN', 'rePostToPN_wpnonce' ); ?>
89
  <b><?php _e('Test your settings', 'nxs_snap'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('PN', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'nxs_snap' ), $nType); ?></a>
90
  <?php } ?>
91
 
92
- <div class="submit"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  </div>
94
  </div>
95
  <?php
@@ -105,22 +138,26 @@ if (!class_exists("nxs_snapClassPN")) { class nxs_snapClassPN {
105
  if (isset($pval['apPNBoard'])) $options[$ii]['pnBoard'] = trim($pval['apPNBoard']);
106
  if (isset($pval['apPNDefImg'])) $options[$ii]['pnDefImg'] = trim($pval['apPNDefImg']);
107
  if (isset($pval['isAttachVid'])) $options[$ii]['isAttachVid'] = $pval['isAttachVid']; else $options[$ii]['isAttachVid'] = 0;
 
108
 
109
  if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']);
110
  if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
111
 
112
  if (isset($pval['apPNMsgFrmt'])) $options[$ii]['pnMsgFormat'] = trim($pval['apPNMsgFrmt']);
113
 
114
- if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']);
 
 
115
  if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
116
  if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
117
  }
118
  } return $options;
119
  }
120
  //#### Show Post->Edit Meta Box Settings
121
- function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
122
  foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapPN', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
123
- $doPN = $ntOpt['doPN'] && (is_array($pMeta) || $ntOpt['catSel']!='1');
 
124
  $isAvailPN = $ntOpt['pnUName']!='' && $ntOpt['pnPass']!=''; $pnMsgFormat = htmlentities($ntOpt['pnMsgFormat'], ENT_COMPAT, "UTF-8");
125
  ?>
126
  <tr><th style="text-align:left;" colspan="2"><?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_PN<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
@@ -128,21 +165,29 @@ if (!class_exists("nxs_snapClassPN")) { class nxs_snapClassPN {
128
  <?php if ($post->post_status == "publish") { ?> <input type="hidden" name="pn[<?php echo $ii; ?>][doPN]" value="<?php echo $doPN;?>"> <?php } ?> <?php } ?>
129
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/pn16.png);">Pinterest - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
130
  if ($post->post_status == "publish" && $isAvailPN) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToPN_repostButton" id="rePostToPN_button" value="<?php _e('Repost to Pinterest', 'nxs_snap') ?>" />
131
- <?php wp_nonce_field( 'rePostToPN', 'rePostToPN_wpnonce' ); } ?>
132
 
133
- <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
134
  ?> <span id="pstdPN<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
135
- <a style="font-size: 10px;" href="http://pinterest.com<?php echo $pMeta[$ii]['pgID']; ?>" target="_blank"><?php $nType="Pinterest"; printf( __( 'Posted on', 'nxs_snap' ), $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 (!$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>
141
- <?php } elseif ($post->post_status != "puZblish") { ?>
 
 
 
 
 
 
 
 
142
 
143
  <tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;">Select Board</th>
144
  <td><select name="pn[<?php echo $ii; ?>][apPNBoard]" id="apPNBoard">
145
- <?php if ($ntOpt['pnBoardsList']!=''){ $gPNBoards = $ntOpt['pnBoardsList']; if ( base64_encode(base64_decode($gPNBoards)) === $gPNBoards) $gPNBoards = base64_decode($gPNBoards);
146
  if ($ntOpt['pnBoard']!='') $gPNBoards = str_replace($ntOpt['pnBoard'].'"', $ntOpt['pnBoard'].'" selected="selected"', $gPNBoards); echo $gPNBoards;} else { ?>
147
  <option value="0">None(Click above to retrieve your boards)</option>
148
  <?php } ?>
@@ -152,14 +197,17 @@ if (!class_exists("nxs_snapClassPN")) { class nxs_snapClassPN {
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('Text Message Format:', 'nxs_snap') ?></th>
153
  <td>
154
  <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>
155
- <?php nxs_doShowHint("apPNMsgFrmt".$ii); ?></td></tr>
156
-
 
157
  <?php }
158
  }
159
  }
160
  //#### Save Meta Tags to the Post
161
  function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
162
  if (isset($pMeta['SNAPformat'])) $optMt['pnMsgFormat'] = $pMeta['SNAPformat'];
 
 
163
  if (isset($pMeta['doPN'])) $optMt['doPN'] = $pMeta['doPN'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doPN'] = 0; }
164
  if (isset($pMeta['apPNBoard']) && $pMeta['apPNBoard']!='' && $pMeta['apPNBoard']!='0') $optMt['pnBoard'] = $pMeta['apPNBoard'];
165
  if (isset($pMeta['SNAPincludePN']) && $pMeta['SNAPincludePN'] == '1' ) $optMt['doPN'] = 1;
@@ -167,7 +215,7 @@ if (!class_exists("nxs_snapClassPN")) { class nxs_snapClassPN {
167
  }
168
  }}
169
  if (!function_exists("nxs_rePostToPN_ajax")) {
170
- function nxs_rePostToPN_ajax() { check_ajax_referer('rePostToPN'); $postID = $_POST['id']; $options = get_option('NS_SNAutoPoster');
171
  foreach ($options['pn'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj'; //if ($two['gpPageID'].$two['gpUName']==$_POST['nid']) {
172
  $po = get_post_meta($postID, 'snapPN', true); $po = maybe_unserialize($po);// prr($gppo);
173
  if (is_array($po) && isset($po[$ii]) && is_array($po[$ii])){ $ntClInst = new nxs_snapClassPN(); $two = $ntClInst->adjMetaOpt($two, $po[$ii]); }
@@ -177,47 +225,56 @@ if (!function_exists("nxs_rePostToPN_ajax")) {
177
  }
178
 
179
  if (!function_exists("nxs_doPublishToPN")) { //## Second Function to Post to G+
180
- function nxs_doPublishToPN($postID, $options){ global $nxs_gCookiesArr, $plgn_NS_SNAutoPoster; $ntCd = 'PN'; $ntCdL = 'pn'; $ntNm = 'Pinterest';
 
181
  // $backtrace = debug_backtrace(); nxs_addToLogN('W', 'Enter', $ntCd, 'I am here - '.$ntCd."|".print_r($backtrace, true), '');
182
- //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToPN', array($postID, $options));
183
- $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'POSTID'=>$postID, 'ACCNAME'=>$options['nName']));
 
 
 
184
  $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
185
  $logNT = '<span style="color:#FA5069">Pinterest</span> - '.$options['nName'];
186
- $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
187
- $isAttachVid = $options['isAttachVid'];
188
  if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
189
  $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') { sleep(5);
190
- nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$uqID); return;
191
  }
192
- }
193
- $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url();
194
-
195
  if ($postID=='0') { echo "Testing ... <br/><br/>"; $msg = 'Test Post from '.$blogTitle; $urlToGo = home_url();
196
- if ($options['pnDefImg']!='') $imgURL = $options['pnDefImg']; else $imgURL ="http://direct.gtln.us/img/nxs/NextScriptsLogoT.png";
197
  }
198
- else { $post = get_post($postID); if(!$post) return; $pnMsgFormat = $options['pnMsgFormat']; $msg = nsFormatMessage($pnMsgFormat, $postID, $addParams);
199
  //## MyURL - URLToGo code
200
  if (!isset($options['urlToUse']) || trim($options['urlToUse'])=='') $myurl = trim(get_post_meta($postID, 'snap_MYURL', true)); if ($myurl!='') $options['urlToUse'] = $myurl;
201
  if (isset($options['urlToUse']) && trim($options['urlToUse'])!='') { $urlToGo = $options['urlToUse']; $options['useFBGURLInfo'] = true; } else $urlToGo = get_permalink($postID);
202
- if($addParams!='') $urlToGo .= (strpos($urlToGo,'?')!==false?'&':'?').$addParams;
203
- nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1')); $imgURL = nxs_getPostImage($postID, 'large', $options['pnDefImg']); //prr($options); echo $imgURL."######"; // echo "WW".$postID."|";
204
- 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'; }}
205
- }
206
- $email = $options['pnUName']; $boardID = $options['pnBoard']; $pass = substr($options['pnPass'], 0, 5)=='g9c1a'?nsx_doDecode(substr($options['pnPass'], 5)):$options['pnPass'];// prr($boardID); prr($_POST); die();
207
- if (isset($options['pnSvC'])) $nxs_gCookiesArr = maybe_unserialize( $options['pnSvC']); $loginError = true;
208
- if (is_array($nxs_gCookiesArr)) $loginError = doCheckPinterest();
209
- $extInfo = ' | PostID: '.$postID." - ".$post->post_title;
210
- if ($loginError!==false) $loginError = doConnectToPinterest($email, $pass); if ($loginError!==false) {echo $loginError; nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($loginError, true), $extInfo); return "BAD USER/PASS";}
 
 
 
211
  if (serialize($nxs_gCookiesArr)!=$options['pnSvC']) { global $plgn_NS_SNAutoPoster; $gOptions = $plgn_NS_SNAutoPoster->nxs_options; // prr($gOptions['pn']);
212
  if (isset($options['ii']) && $options['ii']!=='') { $gOptions['pn'][$options['ii']]['pnSvC'] = serialize($nxs_gCookiesArr); update_option('NS_SNAutoPoster', $gOptions); }
213
  else foreach ($gOptions['pn'] as $ii=>$gpn) { $result = array_diff($options, $gpn);
214
  if (!is_array($result) || count($result)<1) { $gOptions['pn'][$ii]['pnSvC'] = serialize($nxs_gCookiesArr); update_option('NS_SNAutoPoster', $gOptions); break; }
215
  }
216
- } // echo "PN SET:".$msg."|".$imgURL."|".$link."|".$boardID;
217
- if (preg_match ( '/\$(\d+\.\d+)/', $msg, $matches )) $price = $matches[0]; $urlToGo = apply_filters( 'nxs_adjust_ex_url', $urlToGo, $post->post_content );
218
- $ret = doPostToPinterest($msg, $imgURL, $urlToGo, $boardID, 'TITLE WHERE IS IT?', $price, $urlToGo."/GTH/" ); if ($ret=='OK') $ret = array("code"=>"OK", "post_id"=>'');
219
- if ( (!is_array($ret)) && $ret!='OK') { if ($postID=='0') echo $ret; nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo); } else { if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo 'OK - Message Posted, please see your Pinterest Page'; } else { nxs_metaMarkAsPosted($postID, 'PN', $options['ii'], array('isPosted'=>'1', 'pgID'=>$ret['post_id'], 'pDate'=>date('Y-m-d H:i:s'))); nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo);} }
220
- if (is_array($ret) && isset($ret['code']) && $ret['code']=='OK') return 200; else return $ret;
 
 
 
 
 
221
  }
222
  }
223
  ?>
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', 'nxs_snap'); echo ")"; ?></div><?php } ?>
13
  </div>
14
  </div>
16
  <?php if(!function_exists('doPostToPinterest')) {?> Pinterest doesn't have a built-in API for automated posts yet. <br/>You need to get a special <a target="_blank" href="http://www.nextscripts.com/pinterest-automated-posting">library module</a> to be able to publish your content to Pinterest.
17
  <?php } else foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
18
  <p style="margin:0px;margin-left:5px;">
19
+ <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> />
20
+ <?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 } ?>
21
+ <?php if (isset($pbo['rpstOn']) && (int)$pbo['rpstOn'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popReActive');" onmouseover="nxs_showPopUpInfo('popReActive', event);"><?php echo "*[R]*" ?></span><?php } ?>
22
  <strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
23
  &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', 'nxs_snap'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>&nbsp;&nbsp;
24
  <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
25
+ </p><?php $pbo['ntInfo'] = $ntInfo; $this->showNTSettings($indx, $pbo);
26
  } ?>
27
  </div>
28
  </div> <?php
29
  }
30
  //#### Show NEW Settings Page
31
+ function showNewNTSettings($mgpo){ $po = array('nName'=>'', 'doPN'=>'1', 'pnUName'=>'', 'pnBoard'=>'', 'gpAttch'=>'', 'cImgURL'=>'R', 'pnPass'=>'', 'pnDefImg'=>'', 'pnMsgFormat'=>'', 'pnBoard'=>'', 'pnBoardsList'=>'');
32
+ $po['ntInfo']= array('lcode'=>'pn'); $this->showNTSettings($mgpo, $po, true);}
33
  //#### Show Unit Settings
34
+ function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl; $nt = $options['ntInfo']['lcode']; $ntU = strtoupper($nt);
35
+ 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'] = '';
36
+ if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; ?>
37
+ <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; ?>" />
38
 
39
  <?php if(!function_exists('doPostToPinterest')) {?><span style="color:#580000; font-size: 16px;"><br/><br/>
40
  <b>Pinterest API Library not found</b>
44
 
45
 
46
  <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', 'nxs_snap' ), $nType); ?></a></div>
47
+ <div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'nxs_snap'); ?></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")), 'nxs_snap') ?>" /><br/>
48
+ <?php echo nxs_addQTranslSel('pn', $ii, $options['qTLng']); ?>
49
 
50
+ <br/>
51
+ <ul class="nsx_tabs">
52
+ <li><a href="#nsx<?php echo $nt.$ii ?>_tab1"><?php _e('Account Info', 'nxs_snap'); ?></a></li>
53
+ <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'nxs_snap'); ?></a></li>
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
 
60
  <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")), 'nxs_snap') ?>" />
61
  <div style="width:100%;"><strong>Pinterest Password:</strong> </div><input name="pn[<?php echo $ii; ?>][apPNPass]" id="apPNPass<?php echo $ii; ?>" type="password" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities(substr($options['pnPass'], 0, 5)=='g9c1a'?nsx_doDecode(substr($options['pnPass'], 5)):$options['pnPass'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /> <br/>
62
+
63
+ <strong>Clickthrough URL:</strong>
64
+ <p style="margin-bottom: 20px;margin-top: 5px;">
65
+ <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;
66
+ <!-- <input type="radio" name="pn[<?php echo $ii; ?>][cImgURL]" value="S" <?php if ($options['cImgURL'] == 'S') echo 'checked="checked"'; ?> /> Shortened Post URL&nbsp;&nbsp; -->
67
+ <input type="radio" name="pn[<?php echo $ii; ?>][cImgURL]" value="N" <?php if ($options['cImgURL'] == 'N') echo 'checked="checked"'; ?> /> No Clickthrough URL&nbsp;&nbsp;
68
+
69
  <div style="width:100%;"><strong>Default Image to Pin:</strong>
70
  <p style="font-size: 11px; margin: 0px;">If your post missing Featured Image this will be used instead.</p>
71
  </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")), 'nxs_snap') ?>" />
74
  <div style="width:100%;"><strong>Board:</strong>
75
  Please <a href="#" onclick="getBoards(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>
76
  </div>
77
+ <img id="pnLoadingImg<?php echo $ii; ?>" style="display: none;" src='<?php echo $nxs_plurl; ?>img/ajax-loader-sm.gif' />
78
  <select name="pn[<?php echo $ii; ?>][apPNBoard]" id="apPNBoard<?php echo $ii; ?>">
79
  <?php if ($options['pnBoardsList']!=''){ $gPNBoards = $options['pnBoardsList']; if ( base64_encode(base64_decode($gPNBoards)) === $gPNBoards) $gPNBoards = base64_decode($gPNBoards);
80
  if ($options['pnBoard']!='') $gPNBoards = str_replace($options['pnBoard'].'"', $options['pnBoard'].'" selected="selected"', $gPNBoards); echo $gPNBoards;} else { ?>
82
  <?php } ?>
83
  </select>
84
 
85
+ <br/><br/>
86
 
87
  <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', 'nxs_snap'); ?></strong> <i><?php _e('Video will be pinned instead of featured image. Only Youtube is supported at this time.', 'nxs_snap'); ?></i>
88
+ <br/></div>
 
89
 
90
  <div id="altFormat" style="">
91
  <div style="width:100%;"><strong id="altFormatText"><?php _e('Message text Format', 'nxs_snap'); ?>:</strong> <a href="#" id="apPNMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apPNMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>
97
  </div><br/>
98
  <?php if ($isNew) { ?> <input type="hidden" name="pn[<?php echo $ii; ?>][apDoPN]" value="1" id="apDoNewPN<?php echo $ii; ?>" /> <?php } ?>
99
  <?php if ($options['pnPass']!='') { ?>
100
+
101
  <b><?php _e('Test your settings', 'nxs_snap'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('PN', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'nxs_snap' ), $nType); ?></a>
102
  <?php } ?>
103
 
104
+ </div>
105
+ <?php /* ######################## Advanced Tab ####################### */ ?>
106
+ <div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content">
107
+
108
+ <?php if (!$isNew) { ?> <div class="nxs_tls_cpt"><?php _e('Categories', 'nxs_snap'); ?></div>
109
+ <div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
110
+ <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
111
+ <input value="1" id="catSelS<?php echo $ntU; ?><?php echo $ii; ?>" type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_<?php echo $ntU; ?><?php echo $ii; ?>" onclick="jQuery('#catSelS<?php echo $ntU; ?><?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('<?php echo $ntU; ?><?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($options['catSelEd']!='') echo "[".(substr_count($options['catSelEd'], ",")+1)."]"; ?></a>
112
+ <input type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
113
+ <br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
114
+ <br/>
115
+ <?php } ?>
116
+
117
+ <?php nxs_addPostingDelaySelV3($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']); ?>
118
+ <?php nxs_showRepostSettings($nt, $ii, $options); ?>
119
+
120
+
121
+ </div> <?php /* #### End of Tab #### */ ?>
122
+ </div><br/> <?php /* #### End of Tabs #### */ ?>
123
+
124
+ <div class="submit clear" style="padding-bottom: 0px;"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div>
125
+
126
  </div>
127
  </div>
128
  <?php
138
  if (isset($pval['apPNBoard'])) $options[$ii]['pnBoard'] = trim($pval['apPNBoard']);
139
  if (isset($pval['apPNDefImg'])) $options[$ii]['pnDefImg'] = trim($pval['apPNDefImg']);
140
  if (isset($pval['isAttachVid'])) $options[$ii]['isAttachVid'] = $pval['isAttachVid']; else $options[$ii]['isAttachVid'] = 0;
141
+ if (isset($pval['cImgURL'])) $options[$ii]['cImgURL'] = trim($pval['cImgURL']);
142
 
143
  if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']);
144
  if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
145
 
146
  if (isset($pval['apPNMsgFrmt'])) $options[$ii]['pnMsgFormat'] = trim($pval['apPNMsgFrmt']);
147
 
148
+ $options[$ii] = nxs_adjRpst($options[$ii], $pval);
149
+
150
+ if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']);
151
  if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
152
  if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
153
  }
154
  } return $options;
155
  }
156
  //#### Show Post->Edit Meta Box Settings
157
+ function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID; $nt = 'pn'; $ntU = 'PN';
158
  foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapPN', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
159
+ if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = ''; if (empty($ntOpt['urlToUse'])) $ntOpt['urlToUse'] = '';
160
+ $doPN = $ntOpt['doPN'] && (is_array($pMeta) || $ntOpt['catSel']!='1'); $imgToUse = $ntOpt['imgToUse']; $urlToUse = $ntOpt['urlToUse'];
161
  $isAvailPN = $ntOpt['pnUName']!='' && $ntOpt['pnPass']!=''; $pnMsgFormat = htmlentities($ntOpt['pnMsgFormat'], ENT_COMPAT, "UTF-8");
162
  ?>
163
  <tr><th style="text-align:left;" colspan="2"><?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_PN<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
165
  <?php if ($post->post_status == "publish") { ?> <input type="hidden" name="pn[<?php echo $ii; ?>][doPN]" value="<?php echo $doPN;?>"> <?php } ?> <?php } ?>
166
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/pn16.png);">Pinterest - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
167
  if ($post->post_status == "publish" && $isAvailPN) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToPN_repostButton" id="rePostToPN_button" value="<?php _e('Repost to Pinterest', 'nxs_snap') ?>" />
168
+ <?php } ?>
169
 
170
+ <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['postURL']) ) {
171
  ?> <span id="pstdPN<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
172
+ <a style="font-size: 10px;" href="<?php echo $pMeta[$ii]['postURL']; ?>" target="_blank"><?php $nType="Pinterest"; printf( __( 'Posted on', 'nxs_snap' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
173
  </span><?php } ?>
174
 
175
  </td></tr>
176
 
177
  <?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>
178
+ <?php } else { if ($post->post_status != "publish" && function_exists('nxs_doSMAS5') ) { nxs_doSMAS5($nt, $ii, $ntOpt); } ?>
179
+
180
+ <?php if ($ntOpt['rpstOn']=='1') { ?>
181
+
182
+ <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top:6px; text-align:right; width:60px; padding-right:10px;">
183
+ <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"; ?> />
184
+ </th>
185
+ <td> <?php _e('Include in "Auto-Reposting" to this network.', 'nxs_snap') ?>
186
+ </td></tr> <?php } ?>
187
 
188
  <tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;">Select Board</th>
189
  <td><select name="pn[<?php echo $ii; ?>][apPNBoard]" id="apPNBoard">
190
+ <?php if (!empty($ntOpt['pnBoardsList'])){ $gPNBoards = $ntOpt['pnBoardsList']; if ( base64_encode(base64_decode($gPNBoards)) === $gPNBoards) $gPNBoards = base64_decode($gPNBoards);
191
  if ($ntOpt['pnBoard']!='') $gPNBoards = str_replace($ntOpt['pnBoard'].'"', $ntOpt['pnBoard'].'" selected="selected"', $gPNBoards); echo $gPNBoards;} else { ?>
192
  <option value="0">None(Click above to retrieve your boards)</option>
193
  <?php } ?>
197
  <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top:6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Text Message Format:', 'nxs_snap') ?></th>
198
  <td>
199
  <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>
200
+ <?php nxs_doShowHint("apPNMsgFrmt".$ii); ?></td></tr>
201
+
202
+ <?php /* ## Select Image & URL ## */ nxs_showImgToUseDlg($nt, $ii, $imgToUse); nxs_showURLToUseDlg($nt, $ii, $urlToUse); ?>
203
  <?php }
204
  }
205
  }
206
  //#### Save Meta Tags to the Post
207
  function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
208
  if (isset($pMeta['SNAPformat'])) $optMt['pnMsgFormat'] = $pMeta['SNAPformat'];
209
+ if (isset($pMeta['imgToUse'])) $optMt['imgToUse'] = $pMeta['imgToUse']; if (isset($pMeta['urlToUse'])) $optMt['urlToUse'] = $pMeta['urlToUse'];
210
+ if (isset($pMeta['timeToRun'])) $optMt['timeToRun'] = $pMeta['timeToRun']; if (isset($pMeta['rpstPostIncl'])) $optMt['rpstPostIncl'] = $pMeta['rpstPostIncl'];
211
  if (isset($pMeta['doPN'])) $optMt['doPN'] = $pMeta['doPN'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doPN'] = 0; }
212
  if (isset($pMeta['apPNBoard']) && $pMeta['apPNBoard']!='' && $pMeta['apPNBoard']!='0') $optMt['pnBoard'] = $pMeta['apPNBoard'];
213
  if (isset($pMeta['SNAPincludePN']) && $pMeta['SNAPincludePN'] == '1' ) $optMt['doPN'] = 1;
215
  }
216
  }}
217
  if (!function_exists("nxs_rePostToPN_ajax")) {
218
+ function nxs_rePostToPN_ajax() { check_ajax_referer('nxsSsPageWPN'); $postID = $_POST['id']; $options = get_option('NS_SNAutoPoster');
219
  foreach ($options['pn'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj'; //if ($two['gpPageID'].$two['gpUName']==$_POST['nid']) {
220
  $po = get_post_meta($postID, 'snapPN', true); $po = maybe_unserialize($po);// prr($gppo);
221
  if (is_array($po) && isset($po[$ii]) && is_array($po[$ii])){ $ntClInst = new nxs_snapClassPN(); $two = $ntClInst->adjMetaOpt($two, $po[$ii]); }
225
  }
226
 
227
  if (!function_exists("nxs_doPublishToPN")) { //## Second Function to Post to G+
228
+ function nxs_doPublishToPN($postID, $options){ global $nxs_gCookiesArr, $plgn_NS_SNAutoPoster; $ntCd = 'PN'; $ntCdL = 'pn'; $ntNm = 'Pinterest'; $price = '';
229
+ if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
230
  // $backtrace = debug_backtrace(); nxs_addToLogN('W', 'Enter', $ntCd, 'I am here - '.$ntCd."|".print_r($backtrace, true), '');
231
+ //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToPN', array($postID, $options));
232
+ $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'POSTID'=>$postID, 'ACCNAME'=>$options['nName']));
233
+ $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url();
234
+ if (empty($options['imgToUse'])) $options['imgToUse'] = ''; if (empty($options['imgSize'])) $options['imgSize'] = ''; if (empty($options['cImgURL'])) $options['cImgURL'] = 'R';
235
+
236
  $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
237
  $logNT = '<span style="color:#FA5069">Pinterest</span> - '.$options['nName'];
238
+ $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap); $isAttachVid = $options['isAttachVid'];
 
239
  if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
240
  $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') { sleep(5);
241
+ nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate |'.$uqID); return;
242
  }
243
+ }
 
 
244
  if ($postID=='0') { echo "Testing ... <br/><br/>"; $msg = 'Test Post from '.$blogTitle; $urlToGo = home_url();
245
+ if ($options['pnDefImg']!='') $imgURL = $options['pnDefImg']; else $imgURL ="http://direct.gtln.us/img/nxs/NXS-Lama.jpg";
246
  }
247
+ else { $post = get_post($postID); if(!$post) return; $options['pnMsgFormat'] = nsFormatMessage( $options['pnMsgFormat'], $postID, $addParams);
248
  //## MyURL - URLToGo code
249
  if (!isset($options['urlToUse']) || trim($options['urlToUse'])=='') $myurl = trim(get_post_meta($postID, 'snap_MYURL', true)); if ($myurl!='') $options['urlToUse'] = $myurl;
250
  if (isset($options['urlToUse']) && trim($options['urlToUse'])!='') { $urlToGo = $options['urlToUse']; $options['useFBGURLInfo'] = true; } else $urlToGo = get_permalink($postID);
251
+ if($addParams!='') $urlToGo .= (strpos($urlToGo,'?')!==false?'&':'?').$addParams; if (is_object($post)) $urlToGo = apply_filters( 'nxs_adjust_ex_url', $urlToGo, $post->post_content);
252
+
253
+ if (!empty($options['imgToUse'])) $imgURL = $options['imgToUse']; else $imgURL = nxs_getPostImage($postID, 'full', $options['pnDefImg']); if (preg_match("/noImg.\.png/i", $imgURL)) $imgURL = '';
254
+ 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'; }}
255
+ }
256
+ $extInfo = ' | PostID: '.$postID." - ".(is_object($post))?$post->post_title:'';
257
+ if ($options['cImgURL']=='S') $options['cImgURL'] = 'R'; //## Pinterest no longer allows shorthened URLs.
258
+ //## Post
259
+ $message = array('siteName'=>$blogTitle, 'tags'=>'', 'url'=>$urlToGo, 'imageURL'=>$imgURL);// prr($message);
260
+ //## Actual Post
261
+ $ntToPost = new nxs_class_SNAP_PN(); $ret = $ntToPost->doPostToNT($options, $message);
262
+ //## Save Session
263
  if (serialize($nxs_gCookiesArr)!=$options['pnSvC']) { global $plgn_NS_SNAutoPoster; $gOptions = $plgn_NS_SNAutoPoster->nxs_options; // prr($gOptions['pn']);
264
  if (isset($options['ii']) && $options['ii']!=='') { $gOptions['pn'][$options['ii']]['pnSvC'] = serialize($nxs_gCookiesArr); update_option('NS_SNAutoPoster', $gOptions); }
265
  else foreach ($gOptions['pn'] as $ii=>$gpn) { $result = array_diff($options, $gpn);
266
  if (!is_array($result) || count($result)<1) { $gOptions['pn'][$ii]['pnSvC'] = serialize($nxs_gCookiesArr); update_option('NS_SNAutoPoster', $gOptions); break; }
267
  }
268
+ }
269
+ //## Process Results
270
+ if (!is_array($ret) || $ret['isPosted']!='1') { //## Error
271
+ if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);
272
+ } else { // ## All Good - log it.
273
+ if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo _e('OK - Message Posted, please see your '.$logNT.' Page. ', 'nxs_snap'); }
274
+ 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); }
275
+ } //prr($ret);
276
+ //## Return Result
277
+ if ($ret['isPosted']=='1') return 200; else return print_r($ret, true);
278
  }
279
  }
280
  ?>
inc-cl/rd.api.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 {
26
+
27
+ var $ntCode = 'RD';
28
+ var $ntLCode = 'rd';
29
+
30
+ function doPost($options, $message){ if (!is_array($options)) return false; $out = array(); // return false;
31
+ foreach ($options as $ii=>$ntOpts) $out[$ii] = $this->doPostToNT($ntOpts, $message);
32
+ return $out;
33
+ }
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
+ $title = nxs_doFormatMsg($options['rdTitleFormat'], $message); $title = nsTrnc($title, 300); $text = nxs_doFormatMsg($options['rdTextFormat'], $message);
40
+ //## Make Post
41
+ $pass = substr($options['rdPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['rdPass'], 5)):$options['rdPass']; $hdrsArr = '';
42
+ $loginInfo = doConnectToRD($options['rdUName'], $pass); if (!is_array($loginInfo)) { $badOut['Error'] = print_r($loginInfo, true)." - ERROR"; return $badOut; }
43
+ $mh = $loginInfo['mh']; $ck = $loginInfo['ck']; $post = array('uh'=>$mh, 'sr'=>$options['rdSubReddit'], 'title'=>$title, 'save'=>true);
44
+ if ($options['postType']=='A') { $post['url'] = $message['url']; $post['kind']='link'; $retNum = 16; } else { $post['text'] = $text; $post['kind']='self'; $retNum = 10; }
45
+ $url = "http://www.reddit.com/api/submit"; $postParams = array( 'method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'extension'=>'json', 'headers' => $hdrsArr, 'body' => $post, 'cookies' => $ck);
46
+ $response = wp_remote_post($url, $postParams); // prr($postParams); prr($response);
47
+ if (is_wp_error($response)) { $badOut['Error'] = print_r($response, true)." - ERROR"; return $badOut; }
48
+ $response = json_decode($response['body'], true); $rdNewPostID = 'http://www.reddit.com'; // prr($response);
49
+
50
+ if (!isset($response['jquery']) || !is_array($response['jquery'])) { $badOut['Error'] = print_r($response, true)." - ERROR"; return $badOut; }
51
+ $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];
52
+ 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; }
53
+ 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; }
54
+ 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; }
55
+ 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]);
56
+ // echo "ID:".$rdNewPostID;
57
+ if ($rdNewPostID!='http://www.reddit.com') {
58
+ return array('postID'=>$rdNewPostID, 'isPosted'=>1, 'postURL'=>$rdNewPostID, 'pDate'=>date('Y-m-d H:i:s'));
59
+ } else { $badOut['Error'] .= print_r($tmhOAuth->response['response'], true)." MSG:".print_r($msg, true);
60
+ return $badOut;
61
+ }
62
+ return $badOut;
63
+ }
64
+
65
+ }}
66
+ ?>
inc-cl/rd.php ADDED
@@ -0,0 +1,271 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //## NextScripts Reddit Connection Class
3
+ if(function_exists('doConnectToRD')) { $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', 'nxs_snap'); 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;">
19
+ <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> />
20
+ <?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 } ?>
21
+ <?php if (isset($pbo['rpstOn']) && (int)$pbo['rpstOn'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popReActive');" onmouseover="nxs_showPopUpInfo('popReActive', event);"><?php echo "*[R]*" ?></span><?php } ?>
22
+ <strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
23
+ &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', 'nxs_snap'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>&nbsp;&nbsp;
24
+ <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
25
+ </p><?php $pbo['ntInfo'] = $ntInfo; $this->showNTSettings($indx, $pbo);
26
+ }?>
27
+ </div>
28
+ </div> <?php
29
+ }
30
+ //#### Show NEW Settings Page
31
+ function showNewNTSettings($mrdo){ $rdo = array('nName'=>'', 'doRD'=>'1', 'rdUName'=>'', 'rdPageID'=>'', 'rdCommID'=>'', 'postType'=>'A', 'rdPass'=>''); $rdo['ntInfo']= array('lcode'=>'rd'); $this->showNTSettings($mrdo, $rdo, true);}
32
+ //#### Show Unit Settings
33
+ function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl; $nt = $options['ntInfo']['lcode']; $ntU = strtoupper($nt);
34
+ 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'] = '';
35
+ if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; if (!isset($options['rdSubReddit'])) $options['rdSubReddit'] = ''; ?>
36
+ <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; ?>" />
37
+
38
+ <?php if(!function_exists('doConnectToRD')) {?><span style="color:#580000; font-size: 16px;"><br/><br/>
39
+ <b><?php _e('Reddit API Library not found', 'nxs_snap'); ?></b>
40
+ <br/><br/> <?php _e('Reddit doesn\'t have a built-in API for automated posts yet.', 'nxs_snap'); ?> <br/><?php _e('<br/>You need to get a special <a target="_blank" href="http://www.nextscripts.com/reddit-automated-posting"><b>API Library Module</b></a> to be able to publish your content to Reddit.', 'nxs_snap'); ?></span></div>
41
+ <?php return; }; ?>
42
+
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', 'nxs_snap' ), $nType); ?></a></div>
45
+
46
+ <div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'nxs_snap'); ?></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")), 'nxs_snap') ?>" /><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', 'nxs_snap'); ?></a></li>
53
+ <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'nxs_snap'); ?></a></li>
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")), 'nxs_snap') ?>" />
60
+ <div style="width:100%;"><strong>Reddit Password:</strong> </div><input 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")), 'nxs_snap') ?>" /> <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; ?>', ''); 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")), 'nxs_snap') ?>" /> */ ?>
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', 'nxs_snap'); ?></strong> (<a href="#" id="rdTitleFormat<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('rdTitleFormat<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></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")), 'nxs_snap'); ?>" 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', 'nxs_snap'); ?>
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', 'nxs_snap'); ?> - <i><?php _e('set the text format below', 'nxs_snap'); ?></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', 'nxs_snap'); ?>:</strong> (<a href="#" id="rdTextFormat<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('rdTextFormat<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></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%", 'nxs_snap'); else _e(apply_filters('format_to_edit', htmlentities($options['rdTextFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap'); ?></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', 'nxs_snap'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('RD', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'nxs_snap' ), $nType); ?></a> <?php }
104
+ ?>
105
+ </div>
106
+
107
+ <?php /* ######################## Advanced Tab ####################### */ ?>
108
+ <div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content">
109
+
110
+ <?php if (!$isNew) { ?> <div class="nxs_tls_cpt"><?php _e('Categories', 'nxs_snap'); ?></div>
111
+ <div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
112
+ <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
113
+ <input value="1" id="catSelS<?php echo $ntU; ?><?php echo $ii; ?>" type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_<?php echo $ntU; ?><?php echo $ii; ?>" onclick="jQuery('#catSelS<?php echo $ntU; ?><?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('<?php echo $ntU; ?><?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($options['catSelEd']!='') echo "[".(substr_count($options['catSelEd'], ",")+1)."]"; ?></a>
114
+ <input type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
115
+ <br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
116
+ <br/>
117
+ <?php } ?>
118
+
119
+ <div class="nxs_tls_cpt"><?php _e('Posting Delay', 'nxs_snap'); ?></div>
120
+ <div class="nxs_tls_bd">
121
+ <?php echo nxs_addPostingDelaySel($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']); ?>
122
+ </div>
123
+ <?php nxs_showRepostSettings($nt, $ii, $options); ?>
124
+
125
+
126
+ </div> <?php /* #### End of Tab #### */ ?>
127
+ </div><br/> <?php /* #### End of Tabs #### */ ?>
128
+
129
+ <div class="submit clear" style="padding-bottom: 0px;"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div>
130
+
131
+ </div><?php
132
+ }
133
+ //#### Set Unit Settings from POST
134
+ function setNTSettings($post, $options){ global $nxs_snapThisPageUrl; $code = 'RD'; $lcode = 'rd';
135
+ foreach ($post as $ii => $pval){
136
+ if (isset($pval['uName']) && $pval['uName']!=''){ if (!isset($options[$ii])) $options[$ii] = array();
137
+ if (isset($pval['uName'])) $options[$ii]['rdUName'] = trim($pval['uName']);
138
+ if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']);
139
+ if (isset($pval['uPass'])) $options[$ii]['rdPass'] = 'n5g9a'.nsx_doEncode($pval['uPass']); else $options[$ii]['rdPass'] = '';
140
+
141
+ if (empty($options[$ii]['rdSubRedditsList'])) { $pass = substr($options[$ii]['rdPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options[$ii]['rdPass'], 5)):$options[$ii]['rdPass'];
142
+ $loginInfo = doConnectToRD($options[$ii]['rdUName'], $pass); if (is_array($loginInfo)) {
143
+ $options[$ii]['rdSubRedditsList'] = doGetSubredditsFromRD();
144
+ }
145
+ }
146
+
147
+ if (isset($pval['rdSubReddit'])) $options[$ii]['rdSubReddit'] = trim($pval['rdSubReddit']);
148
+
149
+ if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']);
150
+ if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
151
+
152
+ if (isset($pval['postType'])) $options[$ii]['postType'] = $pval['postType'];
153
+ if (isset($pval['rdTitleFormat'])) $options[$ii]['rdTitleFormat'] = trim($pval['rdTitleFormat']);
154
+ if (isset($pval['rdTextFormat'])) $options[$ii]['rdTextFormat'] = trim($pval['rdTextFormat']);
155
+
156
+ if (isset($pval['apDoRD'])) $options[$ii]['doRD'] = $pval['apDoRD']; else $options[$ii]['doRD'] = 0;
157
+
158
+ $options[$ii] = nxs_adjRpst($options[$ii], $pval);
159
+
160
+ if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']);
161
+ if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
162
+ if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
163
+ }
164
+ } return $options;
165
+ }
166
+ //#### Show Post->Edit Meta Box Settings
167
+ function showEdPostNTSettings($ntOpts, $post){global $nxs_plurl; $post_id = $post->ID; $nt = 'rd'; $ntU = 'RD';
168
+ 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]);
169
+ $doRD = $ntOpt['doRD'] && (is_array($pMeta) || $ntOpt['catSel']!='1');
170
+ $isAvailRD = $ntOpt['rdUName']!='' && $ntOpt['rdPass']!=''; $rdMsgFormat = htmlentities($ntOpt['rdTextFormat'], ENT_COMPAT, "UTF-8"); $rdMsgTFormat = htmlentities($ntOpt['rdTitleFormat'], ENT_COMPAT, "UTF-8");
171
+ $rdPostType = $ntOpt['postType'];
172
+ ?>
173
+ <tr><th style="text-align:left;" colspan="2"><?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_RD<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
174
+ <?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"'; ?> />
175
+ <?php if ($post->post_status == "publish") { ?> <input type="hidden" name="rd[<?php echo $ii; ?>][doRD]" value="<?php echo $doRD;?>"> <?php } ?> <?php } ?>
176
+
177
+ <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', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
178
+ 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', 'nxs_snap') ?>" />
179
+ <?php } ?>
180
+
181
+ <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
182
+
183
+ ?> <span id="pstdRD<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
184
+ <a style="font-size: 10px;" href="<?php echo $pMeta[$ii]['pgID']; ?>" target="_blank"><?php $nType="Reddit"; printf( __( 'Posted on', 'nxs_snap' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
185
+ </span><?php } ?>
186
+
187
+ </td></tr>
188
+
189
+ <?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>
190
+ <?php } else { if ($post->post_status != "publish" && function_exists('nxs_doSMAS5') ) { nxs_doSMAS5($nt, $ii, $ntOpt); } ?>
191
+
192
+ <?php if ($ntOpt['rpstOn']=='1') { ?>
193
+
194
+ <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top:6px; text-align:right; width:60px; padding-right:10px;">
195
+ <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"; ?> />
196
+ </th>
197
+ <td> <?php _e('Include in "Auto-Reposting" to this network.', 'nxs_snap') ?>
198
+ </td></tr> <?php } ?>
199
+
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('Title Format:', 'nxs_snap') ?></th>
202
+ <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>
203
+
204
+ <tr><th scope="row" style="text-align:right; width:150px; vertical-align:top; padding-top: 0px; padding-right:10px;"> <?php _e('Post Type:', 'nxs_snap') ?> </th><td>
205
+ <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', 'nxs_snap') ?>
206
+ <br/>
207
+ <input type="radio" name="rd[<?php echo $ii; ?>][postType]" value="T" <?php if ($rdPostType == 'T') echo 'checked="checked"'; ?> /> <?php _e('Text Post', 'nxs_snap') ?><br/>
208
+ </td></tr>
209
+
210
+ <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Text Format:', 'nxs_snap') ?></th><td>
211
+
212
+ <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>
213
+
214
+ </td></tr>
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['rdTextFormat'] = $pMeta['SNAPformat']; if (isset($pMeta['SNAPformatT'])) $optMt['rdTitleFormat'] = $pMeta['SNAPformatT'];
221
+ if (isset($pMeta['imgToUse'])) $optMt['imgToUse'] = $pMeta['imgToUse'];
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['doRD'])) $optMt['doRD'] = $pMeta['doRD'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doRD'] = 0; }
225
+ if (isset($pMeta['SNAPincludeRD']) && $pMeta['SNAPincludeRD'] == '1' ) $optMt['doRD'] = 1;
226
+ return $optMt;
227
+ }
228
+ }}
229
+ if (!function_exists("nxs_rePostToRD_ajax")) {
230
+ 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;
231
+ foreach ($options['rd'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj'; //if ($two['rdPageID'].$two['rdUName']==$_POST['nid']) {
232
+ $rdpo = get_post_meta($postID, 'snapRD', true); $rdpo = maybe_unserialize($rdpo);// prr($rdpo);
233
+ if (is_array($rdpo) && isset($rdpo[$ii]) && is_array($rdpo[$ii])){ $ntClInst = new nxs_snapClassRD(); $two = $ntClInst->adjMetaOpt($two, $rdpo[$ii]); }
234
+ $result = nxs_doPublishToRD($postID, $two); if ($result == 200) die("Successfully sent your post to Reddit."); else die($result);
235
+ }
236
+ }
237
+ }
238
+ if (!function_exists("nxs_doPublishToRD")) { //## Second Function to Post to RD
239
+ function nxs_doPublishToRD($postID, $options){ $ntCd = 'RD'; $ntCdL = 'rd'; $ntNm = 'Reddit'; if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
240
+ $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
241
+ $logNT = '<span style="color:#800000">Reddit</span> - '.$options['nName'];
242
+ $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
243
+ if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
244
+ $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') {
245
+ nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$uqID); return;
246
+ }
247
+ }
248
+ $message = array('message'=>'', 'link'=>'', 'imageURL'=>'', 'videoURL'=>'');
249
+
250
+ if ($postID=='0') { echo "Testing ... <br/><br/>"; $message['description'] = 'Test Post, Description'; $message['title'] = 'Test Post - Title'; $message['url'] = home_url();
251
+ } else { nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1')); $post = get_post($postID); if(!$post) return;
252
+ $rdPostType = $options['postType'];
253
+ $options['rdTitleFormat'] = nsFormatMessage($options['rdTitleFormat'], $postID); $options['rdTextFormat'] = nsFormatMessage($options['rdTextFormat'], $postID); // prr($msg); echo $postID;
254
+ $extInfo = ' | PostID: '.$postID." - ".$post->post_title;
255
+ $message = array('message'=>$options['rdTextFormat'], 'url'=>get_permalink($postID), 'title'=>$options['rdTitleFormat']);
256
+ }
257
+ //## Actual Post
258
+ $ntToPost = new nxs_class_SNAP_RD(); $ret = $ntToPost->doPostToNT($options, $message); // echo "~~~"; prr($ret); echo "+++";
259
+ //## Process Results
260
+ if (!is_array($ret) || $ret['isPosted']!='1') { //## Error
261
+ if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);
262
+ } else { // ## All Good - log it.
263
+ if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo _e('OK - Message Posted, please see your '.$logNT.' Page. ', 'nxs_snap'); }
264
+ 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); }
265
+ }
266
+ //## Return Result
267
+ if ($ret['isPosted']=='1') return 200; else return print_r($ret, true);
268
+
269
+ }
270
+ }
271
+ ?>
inc-cl/su.api.php ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //## NextScripts FriendFeed Connection Class
3
+ $nxs_snapAPINts[] = array('code'=>'SU', 'lcode'=>'su', 'name'=>'StumbleUpon');
4
+
5
+ if (!class_exists("nxs_class_SNAP_SU")) { class nxs_class_SNAP_SU {
6
+
7
+ var $ntCode = 'SU';
8
+ var $ntLCode = 'su';
9
+
10
+ function doPost($options, $message){ if (!is_array($options)) return false;
11
+ foreach ($options as $ntOpts) $out[] = $this->doPostToNT($ntOpts, $message);
12
+ return $out;
13
+ }
14
+ function nxs_getSUHeaders($ref, $post=false, $xhr=true){ $hdrsArr = array();
15
+ if ($xhr) $hdrsArr['X-Requested-With']='XMLHttpRequest';
16
+ $hdrsArr['Connection']='keep-alive'; $hdrsArr['Referer']=$ref;
17
+ $hdrsArr['User-Agent']='Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)';
18
+ if($post) $hdrsArr['Content-Type']='application/x-www-form-urlencoded';
19
+ if ($xhr) $hdrsArr['Accept']='application/json, text/javascript, */*; q=0.01'; else $hdrsArr['Accept']='text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
20
+ $hdrsArr['Origin']='http://www.stumbleupon.com';
21
+ if (function_exists('gzdeflate')) $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;
22
+ }
23
+ function nxs_doCheckSU(){ global $nxs_suCkArray; $hdrsArr = $this->nxs_getSUHeaders('https://www.stumbleupon.com/submit'); $ckArr = $nxs_suCkArray;
24
+ $response = wp_remote_get('http://www.stumbleupon.com/submit', array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr));
25
+ $response['body'] = htmlentities($response['body'], ENT_COMPAT, "UTF-8"); // $response['body'] = htmlentities($response['body']); prr($response); die();
26
+ if (isset($response['headers']['location']) && $response['headers']['location']=='/submit/visitor') return 'Bad Saved Login';
27
+ if ( $response['response']['code']=='200' && stripos($response['body'], 'Add a New Page')!==false){
28
+ /*echo "You are IN"; */ return false;
29
+ } else return 'No Saved Login';
30
+ return false;
31
+ }
32
+ function nxs_doConnectToSU($u, $p){ global $nxs_suCkArray; $hdrsArr = $this->nxs_getSUHeaders('https://www.stumbleupon.com/', false, false); // echo "LOGGIN";
33
+ $response = wp_remote_get('https://www.stumbleupon.com/login', array('headers' => $hdrsArr)); $p = substr($p, 0, 16);
34
+ if (is_wp_error($response)) { nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($response, true), ''); return "Connection ERROR. Please see log";}
35
+ $contents = $response['body']; $ckArr = $response['cookies']; //$response['body'] = htmlentities($response['body']); prr($response); die();
36
+ $frmTxt = CutFromTo($contents, '<form id="login-form"','</form>'); $md = array(); $flds = array(); $mids = '';// prr($frmTxt);
37
+ while (stripos($frmTxt, '<input')!==false){ $inpField = trim(CutFromTo($frmTxt,'<input', '>')); $name = trim(CutFromTo($inpField,'name="', '"'));
38
+ if ( stripos($inpField, '"hidden"')!==false && $name!='' && !in_array($name, $md)) { $md[] = $name; $val = trim(CutFromTo($inpField,'value="', '"')); $flds[$name]= $val; $mids .= "&".$name."=".$val;}
39
+ $frmTxt = substr($frmTxt, stripos($frmTxt, '<input')+8);
40
+ } $flds['user'] = $u; $flds['pass'] = $p; $flds['remember'] = 'true'; $flds['nativeSubmit'] = '0'; $flds['_method'] = 'create'; $flds['_output'] = 'Json';
41
+ $hdrsArr = $this->nxs_getSUHeaders('https://www.stumbleupon.com/login', true, true);
42
+ $r2 = wp_remote_post( 'https://www.stumbleupon.com/login?_nospa=true', array( 'method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds, 'cookies' => $ckArr));
43
+ if (is_wp_error($r2)) { nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($r2, true), ''); return "Connection ERROR. Please see log";}
44
+ $ckArr = nxsMergeArraysOV($ckArr, $r2['cookies']); //prr($flds); prr($ckArr); prr($r2); prr($ckArr);
45
+ if (is_array($r2) && !empty($r2['response']['code']) && $r2['response']['code']=='302') { $hdrsArr = $this->nxs_getSUHeaders('https://www.stumbleupon.com/login', false, false);
46
+ $r2 = wp_remote_get( 'https://www.stumbleupon.com/settings/profile/', array( 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr));
47
+ if (is_wp_error($r2)) { nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($r2, true), ''); return "Connection ERROR. Please see log";} //prr($r2);
48
+ if (stripos($r2['body'], '<a href="#" class="logout ')!==false) { $nxs_suCkArray = $ckArr; return false; }
49
+ } $resp = json_decode($r2['body'], true);
50
+ if ($resp['_success']=='1') { $ckArr = nxsMergeArraysOV($ckArr, $r2['cookies']); $nxs_suCkArray = $ckArr; return false; } elseif (isset($resp['_reason'])) { return $resp['_reason']; } else return "ERROR";
51
+ }
52
+ function nxs_doPostToSU($msg, $lnk, $cat, $tags, $nsfw=false){ global $nxs_suCkArray; $r2 = wp_remote_get($lnk);
53
+ $hdrsArr = $this->nxs_getSUHeaders('https://www.stumbleupon.com/submit', false, false); $ckArr = $nxs_suCkArray;
54
+ $response = wp_remote_get('https://www.stumbleupon.com/submit', array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr));
55
+ $ckArr2 = nxsMergeArraysOV($ckArr, $response['cookies']); //$nxs_suCkArray = $ckArr;
56
+
57
+ $contents = $response['body']; //$response['body'] = htmlentities($response['body']); prr($response);
58
+ //$ckArr = nxsMergeArraysOV($ckArr, $response['cookies']);
59
+ $hdrsArr = $this->nxs_getSUHeaders('https://www.stumbleupon.com/submit', true);
60
+ $frmTxt = CutFromTo($contents, '<form method="post" id="submit-form"','</form>'); $md = array(); $flds = array(); $mids = ''; // prr($contents);
61
+ while (stripos($frmTxt, '<input')!==false){ $inpField = trim(CutFromTo($frmTxt,'<input', '>')); $name = trim(CutFromTo($inpField,'name="', '"'));
62
+ if ( stripos($inpField, '"hidden"')!==false && $name!='' && !in_array($name, $md)) { $md[] = $name; $val = trim(CutFromTo($inpField,'value="', '"')); $flds[$name]= $val; $mids .= "&".$name."=".$val;}
63
+ $frmTxt = substr($frmTxt, stripos($frmTxt, '<input')+8);
64
+ } $flds['url'] = $lnk; $flds['review'] = $msg; $flds['tags'] = $cat; $flds['nsfw'] = $nsfw?'true':'false'; $flds['user-tags'] = $tags; $flds['_output'] = 'Json'; $flds['_method'] = 'create'; $flds['language'] = 'EN';
65
+
66
+ $r2 = wp_remote_post('https://www.stumbleupon.com/submit', array('method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds, 'cookies' => $ckArr));
67
+ $resp = json_decode($r2['body'], true);
68
+
69
+ if ( isset($resp['_reason']) && is_array($resp['_reason']) && count($resp['_reason'])>0 && stripos($resp['_reason'][0]['message'], 'Failed to add URL')!==false) { sleep(5);
70
+ $r2 = wp_remote_post('https://www.stumbleupon.com/submit', array('method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds, 'cookies' => $ckArr));
71
+ $resp = json_decode($r2['body'], true);
72
+ }
73
+
74
+ if (stripos($resp['_error'], 'Invalid token')!==false) { // In case we got the Wrong Cookies
75
+ $r2 = wp_remote_post('https://www.stumbleupon.com/submit', array('method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds, 'cookies' => $ckArr2));
76
+ $resp = json_decode($r2['body'], true);
77
+
78
+ if (stripos($resp['_reason'][0]['message'], 'Failed to add URL')!==false) { sleep(5);
79
+ $r2 = wp_remote_post('https://www.stumbleupon.com/submit', array('method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds, 'cookies' => $ckArr2));
80
+ $resp = json_decode($r2['body'], true); // prr($flds); prr($resp); //nxs_addToLogN('SU', 'E', '-=DBG=- '.print_r($resp, true)." - #####", $extInfo);
81
+ }
82
+ }
83
+
84
+ if (isset($resp['discovery']['publicid'])) $pageID = $resp['discovery']['publicid']; elseif (isset($resp['discovery']['url']['publicid']))$pageID = $resp['discovery']['url']['publicid'];
85
+ if ($resp['_success']=='1') { $ckArr = nxsMergeArraysOV($ckArr, $r2['cookies']); $nxs_suCkArray = $ckArr; return array("code"=>"OK", "post_id"=>$pageID); }
86
+ elseif (isset($resp['_reason'])) { $resp['_reason']['NXS_FIELDS'] = $flds; $resp['_reason']['NXS_RESP'] = $resp; return $resp['_reason']; } else return "ERROR".print_r($resp, true);
87
+ }
88
+
89
+ function doPostToNT($options, $message){ global $nxs_suCkArray; $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>'');
90
+ //## Check settings
91
+ if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
92
+ if (!isset($options['suUName']) || trim($options['suPass'])=='') { $badOut['Error'] = 'Not Configured'; return $badOut; }
93
+ $pass = (substr($options['suPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['suPass'], 5)):$options['suPass']);
94
+ //## Format
95
+ $msg = nxs_doFormatMsg($options['suMsgFormat'], $message); $urlToGo = (!empty($message['url']))?$message['url']:''; $tags = $message['tags'];
96
+
97
+ if (isset($options['suSvC'])) $nxs_suCkArray = maybe_unserialize( $options['suSvC']); $loginError = true;
98
+ if (is_array($nxs_suCkArray)) $loginError = $this->nxs_doCheckSU(); if ($loginError!=false) $loginError = $this->nxs_doConnectToSU($options['suUName'], $pass);
99
+ if ($loginError!==false) { $badOut['Error'] = print_r($loginError, true)." - BAD USER/PASS"; return $badOut; }
100
+
101
+ $ret = $this->nxs_doPostToSU($msg, $urlToGo, $options['suCat'], $tags, $options['nsfw']=='1'); // $extInfo .= "++".$msg."|".$link."|".$options['suCat']."|".$tags."|".$options['nsfw'];
102
+
103
+ if ($ret=='OK') $ret = array("code"=>"OK", "post_id"=>'');
104
+ if ( (!is_array($ret)) && $ret!='OK') { $badOut['Error'] .= 'Something went wrong - '.print_r($ret, true); }
105
+ elseif (isset($ret['code']) && $ret['code']=='OK') return array('isPosted'=>'1', 'postID'=>$ret['post_id'], 'postURL'=>$ret['post_id'], 'pDate'=>date('Y-m-d H:i:s')); else $badOut['Error'] .= 'Error - '.print_r($ret, true);
106
+ return $badOut;
107
+ }
108
+ }}
109
+ ?>
inc-cl/su.php CHANGED
@@ -8,45 +8,47 @@ if (!class_exists("nxs_snapClassSU")) { class nxs_snapClassSU {
8
  <div class="nxs_box">
9
  <div class="nxs_box_header">
10
  <div class="nsx_iconedTitle" style="margin-bottom:1px;background-image:url(<?php echo $nxs_plurl;?>img/<?php echo $ntInfo['lcode']; ?>16.png);"><?php echo $ntInfo['name']; ?>
11
- <?php $cbo = count($ntOpts); ?> <?php wp_nonce_field( 'ns'.$ntInfo['code'], 'ns'.$ntInfo['code'].'_wpnonce' ); ?>
12
  <?php if ($cbo>1){ ?><div class="nsBigText"><?php echo "(".($cbo=='0'?'No':$cbo)." "; _e('accounts', 'nxs_snap'); echo ")"; ?></div><?php } ?>
13
  </div>
14
  </div>
15
  <div class="nxs_box_inside">
16
  <?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
17
  <p style="margin:0px;margin-left:5px;">
18
- <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> /> <?php if ((int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
 
 
19
  <strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
20
  &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', 'nxs_snap'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>&nbsp;&nbsp;
21
  <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
22
- </p><?php $this->showNTSettings($indx, $pbo);
23
  }?>
24
  </div>
25
  </div> <?php
26
  }
27
  //#### Show NEW Settings Page
28
- function showNewNTSettings($mgpo){ $options = array('nName'=>'', 'doSU'=>'1', 'suUName'=>'', 'suInclTags'=>'1', 'suAttch'=>'', 'suPass'=>''); $this->showNTSettings($mgpo, $options, true);}
29
 
30
  function suCats() { return '<option value="A.I.">A.I.</option><option value="AIDS">AIDS</option><option value="Accounting">Accounting</option><option value="Acting">Acting</option><option value="Action Movies">Action Movies</option><option value="Activism">Activism</option><option value="Adult Humor">Adult Humor</option><option value="Advertising">Advertising</option><option value="Africa">Africa</option><option value="African Americans">African Americans</option><option value="Aging">Aging</option><option value="Agriculture">Agriculture</option><option value="Alcoholic Drinks">Alcoholic Drinks</option><option value="Alternative Energy">Alternative Energy</option><option value="Alternative Health">Alternative Health</option><option value="Alternative News">Alternative News</option><option value="Alternative Rock">Alternative Rock</option><option value="Amateur Radio">Amateur Radio</option><option value="Ambient Music">Ambient Music</option><option value="American Football">American Football</option><option value="American History">American History</option><option value="American Lit.">American Lit.</option><option value="Anarchism">Anarchism</option><option value="Anatomy">Anatomy</option><option value="Ancient History">Ancient History</option><option value="Animals">Animals</option><option value="Animation">Animation</option><option value="Anime">Anime</option><option value="Anthropology">Anthropology</option><option value="Antiaging">Antiaging</option><option value="Antiques">Antiques</option><option value="Archaeology">Archaeology</option><option value="Architecture">Architecture</option><option value="Art History">Art History</option><option value="Arthritis">Arthritis</option><option value="Arts">Arts</option><option value="Asia">Asia</option><option value="Asthma">Asthma</option><option value="Astrology/Psychics">Astrology/Psychics</option><option value="Astronomy">Astronomy</option><option value="Atheist/Agnostic">Atheist/Agnostic</option><option value="Audio Equipment">Audio Equipment</option><option value="Australia">Australia</option><option value="Aviation/Aerospace">Aviation/Aerospace</option><option value="BDSM">BDSM</option><option value="Babes">Babes</option><option value="Babies">Babies</option><option value="Badminton">Badminton</option><option value="Ballet">Ballet</option><option value="Banking">Banking</option><option value="Bargains/Coupons">Bargains/Coupons</option><option value="Baseball">Baseball</option><option value="Basketball">Basketball</option><option value="Beauty">Beauty</option><option value="Beer">Beer</option><option value="Beverages">Beverages</option><option value="Bicycling">Bicycling</option><option value="Billiards">Billiards</option><option value="Biographies">Biographies</option><option value="Biology">Biology</option><option value="Biomechanics">Biomechanics</option><option value="Biotech">Biotech</option><option value="Bird Watching">Bird Watching</option><option value="Birds">Birds</option><option value="Bisexual Culture">Bisexual Culture</option><option value="Bisexual Sex">Bisexual Sex</option><option value="Bizarre/Oddities">Bizarre/Oddities</option><option value="Blues music">Blues music</option><option value="Board Games">Board Games</option><option value="Boating">Boating</option><option value="Bodybuilding">Bodybuilding</option><option value="Books">Books</option><option value="Botany">Botany</option><option value="Bowling">Bowling</option><option value="Boxing">Boxing</option><option value="Brain Disorders">Brain Disorders</option><option value="Brazil">Brazil</option><option value="British Literature">British Literature</option><option value="Britpop">Britpop</option><option value="Buddhism">Buddhism</option><option value="Business">Business</option><option value="C.A.D.">C.A.D.</option><option value="Camping">Camping</option><option value="Canada">Canada</option><option value="Cancer">Cancer</option><option value="Canoeing/Kayaking">Canoeing/Kayaking</option><option value="Capitalism">Capitalism</option><option value="Car Parts">Car Parts</option><option value="Card Games">Card Games</option><option value="Career planning">Career planning</option><option value="Caribbean">Caribbean</option><option value="Cars">Cars</option><option value="Cartoons">Cartoons</option><option value="Catholic">Catholic</option><option value="Cats">Cats</option><option value="Celebrities">Celebrities</option><option value="Cell Phones">Cell Phones</option><option value="Celtic Music">Celtic Music</option><option value="Central America">Central America</option><option value="Chaos/Complexity">Chaos/Complexity</option><option value="Cheerleading">Cheerleading</option><option value="Chemical Eng.">Chemical Eng.</option><option value="Chemistry">Chemistry</option><option value="Chess">Chess</option><option value="Children\'s Books">Children\'s Books</option><option value="China">China</option><option value="Christian Music">Christian Music</option><option value="Christianity">Christianity</option><option value="Christmas">Christmas</option><option value="Cigars">Cigars</option><option value="Civil Engineering">Civil Engineering</option><option value="Classic Films">Classic Films</option><option value="Classic Rock">Classic Rock</option><option value="Classical Music">Classical Music</option><option value="Classical Studies">Classical Studies</option><option value="Climbing">Climbing</option><option value="Clothing">Clothing</option><option value="Coffee">Coffee</option><option value="Cognitive Science">Cognitive Science</option><option value="Cold War">Cold War</option><option value="Collecting">Collecting</option><option value="Comedy Movies">Comedy Movies</option><option value="Comic Books">Comic Books</option><option value="Communism">Communism</option><option value="Computer Graphics">Computer Graphics</option><option value="Computer Hardware">Computer Hardware</option><option value="Computer Science">Computer Science</option><option value="Computer Security">Computer Security</option><option value="Computers">Computers</option><option value="Conservative Politics">Conservative Politics</option><option value="Conspiracies">Conspiracies</option><option value="Construction">Construction</option><option value="Consumer Info">Consumer Info</option><option value="Continuing Education">Continuing Education</option><option value="Counterculture">Counterculture</option><option value="Country music">Country music</option><option value="Crafts">Crafts</option><option value="Cricket">Cricket</option><option value="Crime">Crime</option><option value="Crochet">Crochet</option><option value="Cult Films">Cult Films</option><option value="Culture/Ethnicity">Culture/Ethnicity</option><option value="Cyberculture">Cyberculture</option><option value="DJ\'s/Mixing">DJ\'s/Mixing</option><option value="Dance Music">Dance Music</option><option value="Dancing">Dancing</option><option value="Databases">Databases</option><option value="Dating Tips">Dating Tips</option><option value="Daytrading">Daytrading</option><option value="Dentistry">Dentistry</option><option value="Design">Design</option><option value="Desktop Publishing">Desktop Publishing</option><option value="Diabetes">Diabetes</option><option value="Disabilities">Disabilities</option><option value="Disco">Disco</option><option value="Divorce">Divorce</option><option value="Doctors/Surgeons">Doctors/Surgeons</option><option value="Dogs">Dogs</option><option value="Dolls/Puppets">Dolls/Puppets</option><option value="Drama Movies">Drama Movies</option><option value="Drawing">Drawing</option><option value="Drugs">Drugs</option><option value="Drum\'n\'Bass">Drum\'n\'Bass</option><option value="Eastern Studies">Eastern Studies</option><option value="Eating Disorders">Eating Disorders</option><option value="Ecology">Ecology</option><option value="Ecommerce">Ecommerce</option><option value="Economics">Economics</option><option value="Education">Education</option><option value="Electrical Eng.">Electrical Eng.</option><option value="Electronic Devices">Electronic Devices</option><option value="Electronic Parts">Electronic Parts</option><option value="Electronica/IDM">Electronica/IDM</option><option value="Embedded Systems">Embedded Systems</option><option value="Encryption">Encryption</option><option value="Energy Industry">Energy Industry</option><option value="Entertaining Guests">Entertaining Guests</option><option value="Entrepreneurship">Entrepreneurship</option><option value="Environment">Environment</option><option value="Equestrian/Horses">Equestrian/Horses</option><option value="Ergonomics">Ergonomics</option><option value="Erotic Literature">Erotic Literature</option><option value="Ethics">Ethics</option><option value="Ethnic Music">Ethnic Music</option><option value="Europe">Europe</option><option value="Evolution">Evolution</option><option value="Exotic Pets">Exotic Pets</option><option value="Extreme Sports">Extreme Sports</option><option value="Facebook">Facebook</option><option value="Family">Family</option><option value="Fantasy Books">Fantasy Books</option><option value="Fashion">Fashion</option><option value="Feminism">Feminism</option><option value="Fetish Sexuality">Fetish Sexuality</option><option value="Figure Skating">Figure Skating</option><option value="Film Noir">Film Noir</option><option value="Filmmaking">Filmmaking</option><option value="Financial planning">Financial planning</option><option value="Fine Arts">Fine Arts</option><option value="Firefox">Firefox</option><option value="Fish">Fish</option><option value="Fishing">Fishing</option><option value="Fitness">Fitness</option><option value="Flyfishing">Flyfishing</option><option value="Folk music">Folk music</option><option value="Food/Cooking">Food/Cooking</option><option value="For Kids">For Kids</option><option value="Foreign Films">Foreign Films</option><option value="Forensics">Forensics</option><option value="Forestry">Forestry</option><option value="Forums">Forums</option><option value="France">France</option><option value="Funk">Funk</option><option value="Futurism">Futurism</option><option value="Gadgets">Gadgets</option><option value="Gambling">Gambling</option><option value="Gardening">Gardening</option><option value="Gay Culture">Gay Culture</option><option value="Gay Sex">Gay Sex</option><option value="Genealogy">Genealogy</option><option value="Genetics">Genetics</option><option value="Geography">Geography</option><option value="Geoscience">Geoscience</option><option value="Germany">Germany</option><option value="Glaucoma">Glaucoma</option><option value="Golf">Golf</option><option value="Gospel music">Gospel music</option><option value="Goth Culture">Goth Culture</option><option value="Government">Government</option><option value="Graphic Design">Graphic Design</option><option value="Guitar">Guitar</option><option value="Guns">Guns</option><option value="Gymnastics">Gymnastics</option><option value="Hacking">Hacking</option><option value="Health">Health</option><option value="Heart Conditions">Heart Conditions</option><option value="Heavy metal">Heavy metal</option><option value="Hedonism">Hedonism</option><option value="Hentai Anime">Hentai Anime</option><option value="Hiking">Hiking</option><option value="Hinduism">Hinduism</option><option value="HipHop/Rap">HipHop/Rap</option><option value="History">History</option><option value="Hockey">Hockey</option><option value="Home Business">Home Business</option><option value="Home Improvement">Home Improvement</option><option value="Homebrewing">Homebrewing</option><option value="Homemaking">Homemaking</option><option value="Homeschooling">Homeschooling</option><option value="Horror Movies">Horror Movies</option><option value="Hotels">Hotels</option><option value="House music">House music</option><option value="Humanitarianism">Humanitarianism</option><option value="Humanities">Humanities</option><option value="Humor">Humor</option><option value="Hunting">Hunting</option><option value="IT">IT</option><option value="Independent Film">Independent Film</option><option value="India">India</option><option value="Indie Rock/Pop">Indie Rock/Pop</option><option value="Industrial Design">Industrial Design</option><option value="Industrial Music">Industrial Music</option><option value="Instant Messaging">Instant Messaging</option><option value="Insurance">Insurance</option><option value="Int\'l Development">Int\'l Development</option><option value="Interior Design">Interior Design</option><option value="Internet">Internet</option><option value="Internet Tools">Internet Tools</option><option value="Investing">Investing</option><option value="Ipod">Ipod</option><option value="Iraq">Iraq</option><option value="Ireland">Ireland</option><option value="Islam">Islam</option><option value="Israel">Israel</option><option value="Italy">Italy</option><option value="Japan">Japan</option><option value="Java">Java</option><option value="Jazz">Jazz</option><option value="Jewelry">Jewelry</option><option value="Journalism">Journalism</option><option value="Judaism">Judaism</option><option value="Karaoke">Karaoke</option><option value="Kids">Kids</option><option value="Kinesiology">Kinesiology</option><option value="Knitting">Knitting</option><option value="Korea">Korea</option><option value="Landscaping">Landscaping</option><option value="Latin Music">Latin Music</option><option value="Law">Law</option><option value="Learning Disorders">Learning Disorders</option><option value="Lefthanded">Lefthanded</option><option value="Lesbian Culture">Lesbian Culture</option><option value="Lesbian Sex">Lesbian Sex</option><option value="Liberal Politics">Liberal Politics</option><option value="Liberties/Rights">Liberties/Rights</option><option value="Library Resources">Library Resources</option><option value="Lingerie">Lingerie</option><option value="Linguistics">Linguistics</option><option value="Linux/Unix">Linux/Unix</option><option value="Literature">Literature</option><option value="Live Theatre">Live Theatre</option><option value="Logic">Logic</option><option value="Lounge Music">Lounge Music</option><option value="Luxury">Luxury</option><option value="MacOS">MacOS</option><option value="Machinery">Machinery</option><option value="Magic/Illusions">Magic/Illusions</option><option value="Management/HR">Management/HR</option><option value="Manufacturing">Manufacturing</option><option value="Marine Biology">Marine Biology</option><option value="Marketing">Marketing</option><option value="Married Life">Married Life</option><option value="Martial Arts">Martial Arts</option><option value="Matchmaking">Matchmaking</option><option value="Mathematics">Mathematics</option><option value="Mechanical Eng.">Mechanical Eng.</option><option value="Medical Science">Medical Science</option><option value="Medieval History">Medieval History</option><option value="Memorabilia">Memorabilia</option><option value="Men\'s Issues">Men\'s Issues</option><option value="Mental Health">Mental Health</option><option value="Meteorology">Meteorology</option><option value="Mexico">Mexico</option><option value="Microbiology">Microbiology</option><option value="Middle East">Middle East</option><option value="Military">Military</option><option value="Mining/Metallurgy">Mining/Metallurgy</option><option value="Mobile Computing">Mobile Computing</option><option value="Mormon">Mormon</option><option value="Motor Sports">Motor Sports</option><option value="Motorcycles">Motorcycles</option><option value="Movies">Movies</option><option value="Multimedia">Multimedia</option><option value="Music">Music</option><option value="Music Composition">Music Composition</option><option value="Music Instruments">Music Instruments</option><option value="Music Theory">Music Theory</option><option value="Musicals">Musicals</option><option value="Musician Resources">Musician Resources</option><option value="Mutual Funds">Mutual Funds</option><option value="Mystery Novels">Mystery Novels</option><option value="Mythology">Mythology</option><option value="Nanotech">Nanotech</option><option value="Native Americans">Native Americans</option><option value="Nature">Nature</option><option value="Netherlands">Netherlands</option><option value="Network Security">Network Security</option><option value="Neuroscience">Neuroscience</option><option value="New Age">New Age</option><option value="New York">New York</option><option value="News(General)">News(General)</option><option value="Nightlife">Nightlife</option><option value="Nonprofit/Charity">Nonprofit/Charity</option><option value="Nuclear Science">Nuclear Science</option><option value="Nude Art">Nude Art</option><option value="Nursing">Nursing</option><option value="Nutrition">Nutrition</option><option value="Oceania">Oceania</option><option value="Oldies Music">Oldies Music</option><option value="Online Games">Online Games</option><option value="Open Source">Open Source</option><option value="Opera">Opera</option><option value="Operating Systems">Operating Systems</option><option value="Options/Futures">Options/Futures</option><option value="Orthodox">Orthodox</option><option value="Outdoors">Outdoors</option><option value="P2P">P2P</option><option value="PHP">PHP</option><option value="Paganism">Paganism</option><option value="Painting">Painting</option><option value="Paleontology">Paleontology</option><option value="Paranormal">Paranormal</option><option value="Parenting">Parenting</option><option value="Percussion">Percussion</option><option value="Performing Arts">Performing Arts</option><option value="Peripheral Devices">Peripheral Devices</option><option value="Perl">Perl</option><option value="Personal Sites">Personal Sites</option><option value="Petroleum">Petroleum</option><option value="Pets">Pets</option><option value="Pharmacology">Pharmacology</option><option value="Philosophy">Philosophy</option><option value="Photo Gear">Photo Gear</option><option value="Photography">Photography</option><option value="Photoshop">Photoshop</option><option value="Physical Therapy">Physical Therapy</option><option value="Physics">Physics</option><option value="Physiology">Physiology</option><option value="Poetry">Poetry</option><option value="Poker">Poker</option><option value="Political Science">Political Science</option><option value="Politics">Politics</option><option value="Pop music">Pop music</option><option value="Pornography">Pornography</option><option value="Postmodernism">Postmodernism</option><option value="Pregnancy/Birth">Pregnancy/Birth</option><option value="Programming">Programming</option><option value="Protestant">Protestant</option><option value="Proxy">Proxy</option><option value="Psychiatry">Psychiatry</option><option value="Psychology">Psychology</option><option value="Punk Rock">Punk Rock</option><option value="Puzzles">Puzzles</option><option value="Quilting">Quilting</option><option value="Quizzes">Quizzes</option><option value="Quotes">Quotes</option><option value="Racquetball">Racquetball</option><option value="Radio Broadcasts">Radio Broadcasts</option><option value="Rave Culture">Rave Culture</option><option value="Real Estate">Real Estate</option><option value="Recording Gear">Recording Gear</option><option value="Reggae">Reggae</option><option value="Relationships">Relationships</option><option value="Religion">Religion</option><option value="Research">Research</option><option value="Restaurants">Restaurants</option><option value="Restoration">Restoration</option><option value="Robotics">Robotics</option><option value="Rock music">Rock music</option><option value="Rodeo">Rodeo</option><option value="Roleplaying Games">Roleplaying Games</option><option value="Romance Novels">Romance Novels</option><option value="Rugby">Rugby</option><option value="Running">Running</option><option value="Russia">Russia</option><option value="SEO">SEO</option><option value="Sailing">Sailing</option><option value="Satire">Satire</option><option value="Science">Science</option><option value="Science Fiction">Science Fiction</option><option value="Scientology">Scientology</option><option value="Scouting">Scouting</option><option value="Scrapbooking">Scrapbooking</option><option value="Scuba Diving">Scuba Diving</option><option value="Sculpting">Sculpting</option><option value="Search">Search</option><option value="Self Improvement">Self Improvement</option><option value="Semiconductors">Semiconductors</option><option value="Senior Citizens">Senior Citizens</option><option value="Sewing">Sewing</option><option value="Sex Industry">Sex Industry</option><option value="Sex Toys">Sex Toys</option><option value="Sexual Health">Sexual Health</option><option value="Sexuality">Sexuality</option><option value="Shakespeare">Shakespeare</option><option value="Shareware">Shareware</option><option value="Shopping">Shopping</option><option value="Skateboarding">Skateboarding</option><option value="Skiing">Skiing</option><option value="Skydiving">Skydiving</option><option value="Snowboarding">Snowboarding</option><option value="Soap Operas">Soap Operas</option><option value="Soccer">Soccer</option><option value="Socialism">Socialism</option><option value="Sociology">Sociology</option><option value="Software">Software</option><option value="Songwriting">Songwriting</option><option value="Soul/R&amp;B">Soul/R&amp;B</option><option value="Soundtracks">Soundtracks</option><option value="South America">South America</option><option value="Space Exploration">Space Exploration</option><option value="Spain">Spain</option><option value="Spas">Spas</option><option value="Spirituality">Spirituality</option><option value="Sports(General)">Sports(General)</option><option value="Squash">Squash</option><option value="Statistics">Statistics</option><option value="StumbleUpon">StumbleUpon</option><option value="Subculture">Subculture</option><option value="Substance Abuse">Substance Abuse</option><option value="Sufism">Sufism</option><option value="Sunni">Sunni</option><option value="Supercomputing">Supercomputing</option><option value="Surfing">Surfing</option><option value="Survivalist">Survivalist</option><option value="Swimming">Swimming</option><option value="Swingers">Swingers</option><option value="Tattoos/Piercing">Tattoos/Piercing</option><option value="Taxation">Taxation</option><option value="Tea">Tea</option><option value="Techno">Techno</option><option value="Technology">Technology</option><option value="Teen Life">Teen Life</option><option value="Teen Parenting">Teen Parenting</option><option value="Telecom">Telecom</option><option value="Television">Television</option><option value="Tennis">Tennis</option><option value="Terrorism">Terrorism</option><option value="Toys">Toys</option><option value="Track/Field">Track/Field</option><option value="Trains/Railroads">Trains/Railroads</option><option value="Trance">Trance</option><option value="Transexual Sex">Transexual Sex</option><option value="Transportation">Transportation</option><option value="Travel">Travel</option><option value="TripHop/Downtempo">TripHop/Downtempo</option><option value="UFOs">UFOs</option><option value="UK">UK</option><option value="USA">USA</option><option value="University/College">University/College</option><option value="Vegetarian">Vegetarian</option><option value="Video Equipment">Video Equipment</option><option value="Video Games">Video Games</option><option value="Vintage Cars">Vintage Cars</option><option value="Virtual Reality">Virtual Reality</option><option value="Vocal Music">Vocal Music</option><option value="Volleyball">Volleyball</option><option value="Water Sports">Water Sports</option><option value="Web Development">Web Development</option><option value="Webhosting">Webhosting</option><option value="Weblogs">Weblogs</option><option value="Weddings">Weddings</option><option value="Weight Loss">Weight Loss</option><option value="Wicca">Wicca</option><option value="Windows">Windows</option><option value="Windows Dev">Windows Dev</option><option value="Windsurfing">Windsurfing</option><option value="Wine">Wine</option><option value="Women\'s Issues">Women\'s Issues</option><option value="Woodworking">Woodworking</option><option value="Wrestling">Wrestling</option><option value="Writing">Writing</option><option value="Yoga">Yoga</option><option value="Zoology">Zoology</option>'; }
31
  //#### Show Unit Settings
32
- function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl;
33
  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'] = '';
34
- if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; ?>
35
- <div id="doSU<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>" style="background-image: url(<?php echo $nxs_plurl; ?>img/su-bg.png); background-position:90% 10%;"> <input type="hidden" name="apDoSSU<?php echo $ii; ?>" value="0" id="apDoSSU<?php echo $ii; ?>" />
36
 
37
  <div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/su16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-stumbleupon-social-networks-auto-poster-wordpress/"><?php $nType="StumbleUpon"; printf( __( 'Detailed %s Installation/Configuration Instructions', 'nxs_snap' ), $nType); ?></a></div>
38
 
39
- <div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easely identify it', 'nxs_snap'); ?></i> </div><input name="su[<?php echo $ii; ?>][nName]" id="sunName<?php echo $ii; ?>" style="font-weight: bold; color: #005800; border: 1px solid #ACACAC; width: 40%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['nName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /><br/>
40
- <?php echo nxs_addQTranslSel('su', $ii, $options['qTLng']); ?><?php echo nxs_addPostingDelaySel('su', $ii, $options['nHrs'], $options['nMin']); ?>
41
 
42
- <?php if (!$isNew) { ?>
43
- <div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
44
- <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="su[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
45
- <input value="1" id="catSelSSU<?php echo $ii; ?>" type="radio" name="su[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_SU<?php echo $ii; ?>" onclick="jQuery('#catSelSSU<?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('SU<?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_SU<?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($options['catSelEd']!='') echo "[".(substr_count($options['catSelEd'], ",")+1)."]"; ?></a>
46
- <input type="hidden" name="su[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_SU<?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
47
- <br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
48
- <br/>
49
- <?php } ?>
50
 
51
  <div style="width:100%;"><strong>StumbleUpon Username:</strong> </div><input name="su[<?php echo $ii; ?>][apSUUName]" id="apSUUName" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['suUName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
52
  <div style="width:100%;"><strong>StumbleUpon Password:</strong> </div><input name="su[<?php echo $ii; ?>][apSUPass]" id="apSUPass" type="password" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities(substr($options['suPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['suPass'], 5)):$options['suPass'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /> <br/>
@@ -80,37 +82,66 @@ if (!class_exists("nxs_snapClassSU")) { class nxs_snapClassSU {
80
  </div><br/>
81
 
82
  <?php if ($options['suPass']!='') { ?>
83
- <?php wp_nonce_field( 'rePostToSU', 'rePostToSU_wpnonce' ); ?>
84
  <b><?php _e('Test your settings', 'nxs_snap'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('SU', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s' , 'nxs_snap'), $nType); ?></a>
85
 
86
  <?php }
87
 
88
- ?><div class="submit"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div></div><?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  }
90
  //#### Set Unit Settings from POST
91
  function setNTSettings($post, $options){ global $nxs_snapThisPageUrl; $code = 'SU'; $lcode = 'su';
92
  foreach ($post as $ii => $pval){
93
  if (isset($pval['apSUUName']) && $pval['apSUUName']!=''){ if (!isset($options[$ii])) $options[$ii] = array();
 
 
 
 
 
94
  if (isset($pval['apSUUName'])) $options[$ii]['suUName'] = trim($pval['apSUUName']);
95
  if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']);
96
  if (isset($pval['apSUPass'])) $options[$ii]['suPass'] = 'n5g9a'.nsx_doEncode($pval['apSUPass']); else $options[$ii]['suPass'] = '';
97
  if (isset($pval['apSUCat'])) $options[$ii]['suCat'] = trim($pval['apSUCat']);
98
  if (isset($pval['suInclTags'])) $options[$ii]['suInclTags'] = $pval['suInclTags']; else $options[$ii]['suInclTags'] = 0;
99
  if (isset($pval['apSUMsgFrmt'])) $options[$ii]['suMsgFormat'] = trim($pval['apSUMsgFrmt']);
100
-
101
  if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']);
102
- if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
103
 
104
  if (isset($pval['apDoSU'])) $options[$ii]['doSU'] = $pval['apDoSU']; else $options[$ii]['doSU'] = 0;
105
  if (isset($pval['nsfw'])) $options[$ii]['nsfw'] = $pval['nsfw']; else $options[$ii]['nsfw'] = 0;
 
 
 
 
106
  if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
107
  if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
108
  }
109
  } return $options;
110
  }
111
  //#### Show Post->Edit Meta Box Settings
112
- function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
113
- foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapSU', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
114
  $doSU = $ntOpt['doSU'] && (is_array($pMeta) || $ntOpt['catSel']!='1');
115
  $isAvailSU = $ntOpt['suUName']!='' && $ntOpt['suPass']!=''; $suMsgFormat = htmlentities($ntOpt['suMsgFormat'], ENT_COMPAT, "UTF-8");
116
  ?>
@@ -120,7 +151,7 @@ if (!class_exists("nxs_snapClassSU")) { class nxs_snapClassSU {
120
 
121
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/su16.png);">StumbleUpon - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
122
  if ($post->post_status == "publish" && $isAvailSU) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToSU_repostButton" id="rePostToSU_button" value="<?php _e('Repost to StumbleUpon', 'nxs_snap') ?>" />
123
- <?php wp_nonce_field( 'rePostToSU', 'rePostToSU_wpnonce' ); } ?>
124
 
125
  <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
126
 
@@ -130,7 +161,15 @@ if (!class_exists("nxs_snapClassSU")) { class nxs_snapClassSU {
130
  </td></tr>
131
 
132
  <?php if (!$isAvailSU) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your StumbleUpon Account to AutoPost to StumbleUpon</b>
133
- <?php } elseif ($post->post_status != "puZblish") { ?>
 
 
 
 
 
 
 
 
134
 
135
  <tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;">Category:</th>
136
  <td><div id="altFormat" style="">
@@ -138,7 +177,9 @@ if (!class_exists("nxs_snapClassSU")) { class nxs_snapClassSU {
138
  <?php $suCats = $this->suCats();
139
  if (isset($ntOpt['suCat']) && $ntOpt['suCat']!='') $suCats = str_replace('"'.$ntOpt['suCat'].'"', '"'.$ntOpt['suCat'].'" selected="selected"', $suCats); echo $suCats;
140
  ?>
141
- </select> <input value="1" id="sunsfw<?php echo $ii; ?>" type="checkbox" name="su[<?php echo $ii; ?>][nsfw]" <?php if ((int)$ntOpt['nsfw'] == 1) echo "checked"; ?> /> <strong>NSFW</strong>
 
 
142
 
143
  </div> </td></tr>
144
 
@@ -153,14 +194,16 @@ if (!class_exists("nxs_snapClassSU")) { class nxs_snapClassSU {
153
  function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
154
  if (isset($pMeta['nsfw'])) $optMt['nsfw'] = $pMeta['nsfw']; else $optMt['nsfw'] = 0;
155
  if (isset($pMeta['SNAPformat'])) $optMt['suMsgFormat'] = $pMeta['SNAPformat'];
 
 
156
  if (isset($pMeta['apSUCat'])) $optMt['suCat'] = $pMeta['apSUCat'];
157
  if (isset($pMeta['doSU'])) $optMt['doSU'] = $pMeta['doSU'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doSU'] = 0; }
158
- if (isset($pMeta['SNAPincludeSU']) && $pMeta['SNAPincludeSU'] == '1' ) $optMt['doSU'] = 1;
159
  return $optMt;
160
  }
161
  }}
162
  if (!function_exists("nxs_rePostToSU_ajax")) {
163
- function nxs_rePostToSU_ajax() { check_ajax_referer('rePostToSU'); $postID = $_POST['id']; $options = get_option('NS_SNAutoPoster');
164
  foreach ($options['su'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj'; //if ($two['gpPageID'].$two['gpUName']==$_POST['nid']) {
165
  $gppo = get_post_meta($postID, 'snapSU', true); $gppo = maybe_unserialize($gppo);// prr($gppo);
166
  if (is_array($gppo) && isset($gppo[$ii]) && is_array($gppo[$ii])){ $ntClInst = new nxs_snapClassSU(); $two = $ntClInst->adjMetaOpt($two, $gppo[$ii]); }
@@ -169,126 +212,55 @@ if (!function_exists("nxs_rePostToSU_ajax")) {
169
  }
170
  }
171
 
172
- if (!function_exists("nxs_getSUHeaders")) { function nxs_getSUHeaders($ref, $post=false, $xhr=true){ $hdrsArr = array();
173
- if ($xhr) $hdrsArr['X-Requested-With']='XMLHttpRequest';
174
- $hdrsArr['Connection']='keep-alive'; $hdrsArr['Referer']=$ref;
175
- $hdrsArr['User-Agent']='Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)';
176
- if($post) $hdrsArr['Content-Type']='application/x-www-form-urlencoded';
177
- if ($xhr) $hdrsArr['Accept']='application/json, text/javascript, */*; q=0.01'; else $hdrsArr['Accept']='text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
178
- $hdrsArr['Origin']='http://www.stumbleupon.com';
179
- $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;
180
- }}
181
- if (!function_exists("nxs_doCheckSU")) {function nxs_doCheckSU(){ global $nxs_suCkArray; $hdrsArr = nxs_getSUHeaders('https://www.stumbleupon.com/submit'); $ckArr = $nxs_suCkArray;
182
- $response = wp_remote_get('http://www.stumbleupon.com/submit', array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr));
183
- $response['body'] = htmlentities($response['body'], ENT_COMPAT, "UTF-8"); // $response['body'] = htmlentities($response['body']); prr($response); die();
184
- if (isset($response['headers']['location']) && $response['headers']['location']=='/submit/visitor') return 'Bad Saved Login';
185
- if ( $response['response']['code']=='200' && stripos($response['body'], 'Add a New Page')!==false){
186
-
187
-
188
- /*echo "You are IN"; */ return false;
189
- } else return 'No Saved Login';
190
- return false;
191
- }}
192
- if (!function_exists("nxs_doConnectToSU")) { function nxs_doConnectToSU($u, $p){ global $nxs_suCkArray; $hdrsArr = nxs_getSUHeaders('https://www.stumbleupon.com/'); // echo "LOGGIN";
193
- $response = wp_remote_get('https://www.stumbleupon.com/login', array('headers' => $hdrsArr)); $p = substr($p, 0, 16);
194
- if (is_wp_error($response)) { nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($response, true), ''); return "Connection ERROR. Please see log";}
195
- $contents = $response['body']; $ckArr = $response['cookies']; //$response['body'] = htmlentities($response['body']); prr($response); die();
196
- //$iimax = count($ckArr)-1; for($i=0;$i<$iimax;$i++) $ckArr [$i]->value = urlencode($ckArr [$i]->value);
197
- $frmTxt = CutFromTo($contents, '<form id="login-form"','</form>'); $md = array(); $flds = array(); $mids = '';// prr($frmTxt);
198
- while (stripos($frmTxt, '<input')!==false){ $inpField = trim(CutFromTo($frmTxt,'<input', '>')); $name = trim(CutFromTo($inpField,'name="', '"'));
199
- if ( stripos($inpField, '"hidden"')!==false && $name!='' && !in_array($name, $md)) { $md[] = $name; $val = trim(CutFromTo($inpField,'value="', '"')); $flds[$name]= $val; $mids .= "&".$name."=".$val;}
200
- $frmTxt = substr($frmTxt, stripos($frmTxt, '<input')+8);
201
- } $flds['user'] = $u; $flds['pass'] = $p; $flds['remember'] = 'true'; $flds['nativeSubmit'] = '0'; $flds['_method'] = 'create'; $flds['_output'] = 'Json';
202
- $hdrsArr = nxs_getSUHeaders('https://www.stumbleupon.com/login', true, true);
203
- $r2 = wp_remote_post( 'https://www.stumbleupon.com/login?_nospa=true', array( 'method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds, 'cookies' => $ckArr));
204
- $ckArr = nxsMergeArraysOV($ckArr, $r2['cookies']);
205
- if (is_array($r2) && !empty($r2['response']['code']) && $r2['response']['code']=='302') { $hdrsArr = nxs_getSUHeaders('https://www.stumbleupon.com/login', false, false);
206
- $r2 = wp_remote_get( 'https://www.stumbleupon.com/settings/profile/', array( 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr));
207
- if (is_wp_error($r2)) { nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($r2, true), ''); return "Connection ERROR. Please see log";}
208
- if (stripos($r2['body'], '<a href="#" class="logout ')!==false) { $nxs_suCkArray = $ckArr; return false; }
209
- } $resp = json_decode($r2['body'], true);
210
- if ($resp['_success']=='1') { $ckArr = nxsMergeArraysOV($ckArr, $r2['cookies']); $nxs_suCkArray = $ckArr; return false; } elseif (isset($resp['_reason'])) { return $resp['_reason']; } else return "ERROR";
211
- }}
212
- if (!function_exists("nxs_doPostToSU")) { function nxs_doPostToSU($msg, $lnk, $cat, $tags, $nsfw=false){ global $nxs_suCkArray; $r2 = wp_remote_get($lnk);
213
- $hdrsArr = nxs_getSUHeaders('https://www.stumbleupon.com/submit', false, false); $ckArr = $nxs_suCkArray;
214
- $response = wp_remote_get('https://www.stumbleupon.com/submit', array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr));
215
- $ckArr2 = nxsMergeArraysOV($ckArr, $response['cookies']); //$nxs_suCkArray = $ckArr;
216
-
217
- $contents = $response['body']; //$response['body'] = htmlentities($response['body']); prr($response);
218
- //$ckArr = nxsMergeArraysOV($ckArr, $response['cookies']);
219
- $hdrsArr = nxs_getSUHeaders('https://www.stumbleupon.com/submit', true);
220
- $frmTxt = CutFromTo($contents, '<form method="post" id="submit-form"','</form>'); $md = array(); $flds = array(); // prr($contents);
221
- while (stripos($frmTxt, '<input')!==false){ $inpField = trim(CutFromTo($frmTxt,'<input', '>')); $name = trim(CutFromTo($inpField,'name="', '"'));
222
- if ( stripos($inpField, '"hidden"')!==false && $name!='' && !in_array($name, $md)) { $md[] = $name; $val = trim(CutFromTo($inpField,'value="', '"')); $flds[$name]= $val; $mids .= "&".$name."=".$val;}
223
- $frmTxt = substr($frmTxt, stripos($frmTxt, '<input')+8);
224
- } $flds['url'] = $lnk; $flds['review'] = $msg; $flds['tags'] = $cat; $flds['nsfw'] = $nsfw?'true':'false'; $flds['user-tags'] = $tags; $flds['_output'] = 'Json'; $flds['_method'] = 'create'; $flds['language'] = 'EN';
225
-
226
- $r2 = wp_remote_post('https://www.stumbleupon.com/submit', array('method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds, 'cookies' => $ckArr));
227
- $resp = json_decode($r2['body'], true);
228
-
229
- if (stripos($resp['_reason'][0]['message'], 'Failed to add URL')!==false) { sleep(5);
230
- $r2 = wp_remote_post('https://www.stumbleupon.com/submit', array('method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds, 'cookies' => $ckArr));
231
- $resp = json_decode($r2['body'], true);
232
- }
233
-
234
- if (stripos($resp['_error'], 'Invalid token')!==false) { // In case we got the Wrong Cookies
235
- $r2 = wp_remote_post('https://www.stumbleupon.com/submit', array('method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds, 'cookies' => $ckArr2));
236
- $resp = json_decode($r2['body'], true);
237
-
238
- if (stripos($resp['_reason'][0]['message'], 'Failed to add URL')!==false) { sleep(5);
239
- $r2 = wp_remote_post('https://www.stumbleupon.com/submit', array('method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds, 'cookies' => $ckArr2));
240
- $resp = json_decode($r2['body'], true); // prr($flds); prr($resp); //nxs_addToLogN('SU', 'E', '-=DBG=- '.print_r($resp, true)." - #####", $extInfo);
241
- }
242
- }
243
-
244
- if (isset($resp['discovery']['publicid'])) $pageID = $resp['discovery']['publicid']; elseif (isset($resp['discovery']['url']['publicid']))$pageID = $resp['discovery']['url']['publicid'];
245
- if ($resp['_success']=='1') { $ckArr = nxsMergeArraysOV($ckArr, $r2['cookies']); $nxs_suCkArray = $ckArr; return array("code"=>"OK", "post_id"=>$pageID); }
246
- elseif (isset($resp['_reason'])) { $resp['_reason']['NXS_FIELDS'] = $flds; $resp['_reason']['NXS_RESP'] = $resp; return $resp['_reason']; } else return "ERROR".print_r($resp, true);
247
- }}
248
-
249
  if (!function_exists("nxs_doPublishToSU")) { //## Second Function to Post to SU
250
- function nxs_doPublishToSU($postID, $options){ global $nxs_suCkArray; $ntCd = 'SU'; $ntCdL = 'su'; $ntNm = 'StumbleUpon';
251
  //$backtrace = debug_backtrace(); nxs_addToLogN('W', 'Enter', $ntCd, 'I am here - '.$ntCd."|".print_r($backtrace, true), '');
252
  //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToSU', array($postID, $options));
 
 
 
253
  $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
254
  $logNT = '<span style="color:#000080">StumbleUpon</span> - '.$options['nName'];
255
  $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
 
256
  if ($options['reset'] != '1' && $options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
257
  $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') { sleep(5);
258
  nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$uqID); return;
259
  }
260
  }
261
- $suCat = $options['suCat'];
262
- // if (function_exists("get_post_thumbnail_id") ){ $src = wp_get_attachment_image_src(get_post_thumbnail_id($postID), 'thumbnail'); $src = $src[0];}
263
- $email = $options['suUName']; $pass = (substr($options['suPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['suPass'], 5)):$options['suPass']);
264
- if ($postID=='0') { echo "Testing ... <br/><br/>"; $link = home_url(); $msg = 'Test Link from '.$link; } else { $post = get_post($postID); if(!$post) return;
265
- $msgFormat = $options['suMsgFormat']; $msg = nsFormatMessage($msgFormat, $postID); $link = get_permalink($postID); nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
266
- }
267
- $dusername = $options['suUName']; //$link = urlencode($link); $desc = urlencode(substr($msg, 0, 500));
268
- $extInfo = ' | PostID: '.$postID." - ".$post->post_title;
269
- if ($options['suInclTags']=='1') { $t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = urlencode(implode(',',$tggs)); $tags = str_replace(' ','+',$tags); } else $tags = '';
270
- if (isset($options['suSvC'])) $nxs_suCkArray = maybe_unserialize( $options['suSvC']); $loginError = true;
271
- if (is_array($nxs_suCkArray)) $loginError = nxs_doCheckSU(); if ($loginError!=false) $loginError = nxs_doConnectToSU($email, $pass);
272
- if (serialize($nxs_suCkArray)!=$options['suSvC']) { global $plgn_NS_SNAutoPoster; $gOptions = $plgn_NS_SNAutoPoster->nxs_options;
 
 
 
 
 
 
 
273
  if (isset($options['ii']) && $options['ii']!=='') { $gOptions['su'][$options['ii']]['suSvC'] = serialize($nxs_suCkArray); update_option('NS_SNAutoPoster', $gOptions); }
274
  else foreach ($gOptions['su'] as $ii=>$gpn) { $result = array_diff($options, $gpn);
275
  if (!is_array($result) || count($result)<1) { $gOptions['su'][$ii]['suSvC'] = serialize($nxs_suCkArray); update_option('NS_SNAutoPoster', $gOptions); break; }
276
  }
277
  }
278
- if ($loginError!==false) {if ($postID=='0') prr($loginError); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($loginError, true)." - BAD USER/PASS", $extInfo); return " -= BAD USER/PASS =- ";}
279
-
280
- $ret = nxs_doPostToSU($msg, $link, $options['suCat'], $tags, $options['nsfw']=='1'); // $extInfo .= "++".$msg."|".$link."|".$options['suCat']."|".$tags."|".$options['nsfw'];
281
- if ($ret=='OK') $ret = array("code"=>"OK", "post_id"=>'');
282
- if ( (!is_array($ret)) && $ret!='OK') { if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);}
283
- elseif ($ret['code']=='OK') if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo ' OK - Message Posted, please see your StumbleUpon Page '; } else
284
- { nxs_metaMarkAsPosted($postID, 'SU', $options['ii'], array('isPosted'=>'1', 'pgID'=>$ret['post_id'], 'pDate'=>date('Y-m-d H:i:s'))); nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); return 200; }
285
- else { if ($options['reset'] == '1') {
286
- nxs_addToLogN('E', 'Error', $logNT, '-=ERROR TRY #2=- '.print_r($ret, true), $extInfo.$options['reset']);
287
- return "ERROR = ".print_r($ret, true);
288
- } else { $options['reset'] = '1'; $options['suSvC'] = ''; return nxs_doPublishToSU($postID, $options); }
289
- }
290
-
291
-
292
  }
293
  }
294
  ?>
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', 'nxs_snap'); echo ")"; ?></div><?php } ?>
13
  </div>
14
  </div>
15
  <div class="nxs_box_inside">
16
  <?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
17
  <p style="margin:0px;margin-left:5px;">
18
+ <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> />
19
+ <?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 } ?>
20
+ <?php if (isset($pbo['rpstOn']) && (int)$pbo['rpstOn'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popReActive');" onmouseover="nxs_showPopUpInfo('popReActive', event);"><?php echo "*[R]*" ?></span><?php } ?>
21
  <strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
22
  &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', 'nxs_snap'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>&nbsp;&nbsp;
23
  <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
24
+ </p><?php $pbo['ntInfo'] = $ntInfo; $this->showNTSettings($indx, $pbo);
25
  }?>
26
  </div>
27
  </div> <?php
28
  }
29
  //#### Show NEW Settings Page
30
+ function showNewNTSettings($mgpo){ $options = array('nName'=>'', 'doSU'=>'1', 'suUName'=>'', 'suInclTags'=>'1', 'suAttch'=>'', 'suPass'=>''); $options['ntInfo']= array('lcode'=>'su'); $this->showNTSettings($mgpo, $options, true);}
31
 
32
  function suCats() { return '<option value="A.I.">A.I.</option><option value="AIDS">AIDS</option><option value="Accounting">Accounting</option><option value="Acting">Acting</option><option value="Action Movies">Action Movies</option><option value="Activism">Activism</option><option value="Adult Humor">Adult Humor</option><option value="Advertising">Advertising</option><option value="Africa">Africa</option><option value="African Americans">African Americans</option><option value="Aging">Aging</option><option value="Agriculture">Agriculture</option><option value="Alcoholic Drinks">Alcoholic Drinks</option><option value="Alternative Energy">Alternative Energy</option><option value="Alternative Health">Alternative Health</option><option value="Alternative News">Alternative News</option><option value="Alternative Rock">Alternative Rock</option><option value="Amateur Radio">Amateur Radio</option><option value="Ambient Music">Ambient Music</option><option value="American Football">American Football</option><option value="American History">American History</option><option value="American Lit.">American Lit.</option><option value="Anarchism">Anarchism</option><option value="Anatomy">Anatomy</option><option value="Ancient History">Ancient History</option><option value="Animals">Animals</option><option value="Animation">Animation</option><option value="Anime">Anime</option><option value="Anthropology">Anthropology</option><option value="Antiaging">Antiaging</option><option value="Antiques">Antiques</option><option value="Archaeology">Archaeology</option><option value="Architecture">Architecture</option><option value="Art History">Art History</option><option value="Arthritis">Arthritis</option><option value="Arts">Arts</option><option value="Asia">Asia</option><option value="Asthma">Asthma</option><option value="Astrology/Psychics">Astrology/Psychics</option><option value="Astronomy">Astronomy</option><option value="Atheist/Agnostic">Atheist/Agnostic</option><option value="Audio Equipment">Audio Equipment</option><option value="Australia">Australia</option><option value="Aviation/Aerospace">Aviation/Aerospace</option><option value="BDSM">BDSM</option><option value="Babes">Babes</option><option value="Babies">Babies</option><option value="Badminton">Badminton</option><option value="Ballet">Ballet</option><option value="Banking">Banking</option><option value="Bargains/Coupons">Bargains/Coupons</option><option value="Baseball">Baseball</option><option value="Basketball">Basketball</option><option value="Beauty">Beauty</option><option value="Beer">Beer</option><option value="Beverages">Beverages</option><option value="Bicycling">Bicycling</option><option value="Billiards">Billiards</option><option value="Biographies">Biographies</option><option value="Biology">Biology</option><option value="Biomechanics">Biomechanics</option><option value="Biotech">Biotech</option><option value="Bird Watching">Bird Watching</option><option value="Birds">Birds</option><option value="Bisexual Culture">Bisexual Culture</option><option value="Bisexual Sex">Bisexual Sex</option><option value="Bizarre/Oddities">Bizarre/Oddities</option><option value="Blues music">Blues music</option><option value="Board Games">Board Games</option><option value="Boating">Boating</option><option value="Bodybuilding">Bodybuilding</option><option value="Books">Books</option><option value="Botany">Botany</option><option value="Bowling">Bowling</option><option value="Boxing">Boxing</option><option value="Brain Disorders">Brain Disorders</option><option value="Brazil">Brazil</option><option value="British Literature">British Literature</option><option value="Britpop">Britpop</option><option value="Buddhism">Buddhism</option><option value="Business">Business</option><option value="C.A.D.">C.A.D.</option><option value="Camping">Camping</option><option value="Canada">Canada</option><option value="Cancer">Cancer</option><option value="Canoeing/Kayaking">Canoeing/Kayaking</option><option value="Capitalism">Capitalism</option><option value="Car Parts">Car Parts</option><option value="Card Games">Card Games</option><option value="Career planning">Career planning</option><option value="Caribbean">Caribbean</option><option value="Cars">Cars</option><option value="Cartoons">Cartoons</option><option value="Catholic">Catholic</option><option value="Cats">Cats</option><option value="Celebrities">Celebrities</option><option value="Cell Phones">Cell Phones</option><option value="Celtic Music">Celtic Music</option><option value="Central America">Central America</option><option value="Chaos/Complexity">Chaos/Complexity</option><option value="Cheerleading">Cheerleading</option><option value="Chemical Eng.">Chemical Eng.</option><option value="Chemistry">Chemistry</option><option value="Chess">Chess</option><option value="Children\'s Books">Children\'s Books</option><option value="China">China</option><option value="Christian Music">Christian Music</option><option value="Christianity">Christianity</option><option value="Christmas">Christmas</option><option value="Cigars">Cigars</option><option value="Civil Engineering">Civil Engineering</option><option value="Classic Films">Classic Films</option><option value="Classic Rock">Classic Rock</option><option value="Classical Music">Classical Music</option><option value="Classical Studies">Classical Studies</option><option value="Climbing">Climbing</option><option value="Clothing">Clothing</option><option value="Coffee">Coffee</option><option value="Cognitive Science">Cognitive Science</option><option value="Cold War">Cold War</option><option value="Collecting">Collecting</option><option value="Comedy Movies">Comedy Movies</option><option value="Comic Books">Comic Books</option><option value="Communism">Communism</option><option value="Computer Graphics">Computer Graphics</option><option value="Computer Hardware">Computer Hardware</option><option value="Computer Science">Computer Science</option><option value="Computer Security">Computer Security</option><option value="Computers">Computers</option><option value="Conservative Politics">Conservative Politics</option><option value="Conspiracies">Conspiracies</option><option value="Construction">Construction</option><option value="Consumer Info">Consumer Info</option><option value="Continuing Education">Continuing Education</option><option value="Counterculture">Counterculture</option><option value="Country music">Country music</option><option value="Crafts">Crafts</option><option value="Cricket">Cricket</option><option value="Crime">Crime</option><option value="Crochet">Crochet</option><option value="Cult Films">Cult Films</option><option value="Culture/Ethnicity">Culture/Ethnicity</option><option value="Cyberculture">Cyberculture</option><option value="DJ\'s/Mixing">DJ\'s/Mixing</option><option value="Dance Music">Dance Music</option><option value="Dancing">Dancing</option><option value="Databases">Databases</option><option value="Dating Tips">Dating Tips</option><option value="Daytrading">Daytrading</option><option value="Dentistry">Dentistry</option><option value="Design">Design</option><option value="Desktop Publishing">Desktop Publishing</option><option value="Diabetes">Diabetes</option><option value="Disabilities">Disabilities</option><option value="Disco">Disco</option><option value="Divorce">Divorce</option><option value="Doctors/Surgeons">Doctors/Surgeons</option><option value="Dogs">Dogs</option><option value="Dolls/Puppets">Dolls/Puppets</option><option value="Drama Movies">Drama Movies</option><option value="Drawing">Drawing</option><option value="Drugs">Drugs</option><option value="Drum\'n\'Bass">Drum\'n\'Bass</option><option value="Eastern Studies">Eastern Studies</option><option value="Eating Disorders">Eating Disorders</option><option value="Ecology">Ecology</option><option value="Ecommerce">Ecommerce</option><option value="Economics">Economics</option><option value="Education">Education</option><option value="Electrical Eng.">Electrical Eng.</option><option value="Electronic Devices">Electronic Devices</option><option value="Electronic Parts">Electronic Parts</option><option value="Electronica/IDM">Electronica/IDM</option><option value="Embedded Systems">Embedded Systems</option><option value="Encryption">Encryption</option><option value="Energy Industry">Energy Industry</option><option value="Entertaining Guests">Entertaining Guests</option><option value="Entrepreneurship">Entrepreneurship</option><option value="Environment">Environment</option><option value="Equestrian/Horses">Equestrian/Horses</option><option value="Ergonomics">Ergonomics</option><option value="Erotic Literature">Erotic Literature</option><option value="Ethics">Ethics</option><option value="Ethnic Music">Ethnic Music</option><option value="Europe">Europe</option><option value="Evolution">Evolution</option><option value="Exotic Pets">Exotic Pets</option><option value="Extreme Sports">Extreme Sports</option><option value="Facebook">Facebook</option><option value="Family">Family</option><option value="Fantasy Books">Fantasy Books</option><option value="Fashion">Fashion</option><option value="Feminism">Feminism</option><option value="Fetish Sexuality">Fetish Sexuality</option><option value="Figure Skating">Figure Skating</option><option value="Film Noir">Film Noir</option><option value="Filmmaking">Filmmaking</option><option value="Financial planning">Financial planning</option><option value="Fine Arts">Fine Arts</option><option value="Firefox">Firefox</option><option value="Fish">Fish</option><option value="Fishing">Fishing</option><option value="Fitness">Fitness</option><option value="Flyfishing">Flyfishing</option><option value="Folk music">Folk music</option><option value="Food/Cooking">Food/Cooking</option><option value="For Kids">For Kids</option><option value="Foreign Films">Foreign Films</option><option value="Forensics">Forensics</option><option value="Forestry">Forestry</option><option value="Forums">Forums</option><option value="France">France</option><option value="Funk">Funk</option><option value="Futurism">Futurism</option><option value="Gadgets">Gadgets</option><option value="Gambling">Gambling</option><option value="Gardening">Gardening</option><option value="Gay Culture">Gay Culture</option><option value="Gay Sex">Gay Sex</option><option value="Genealogy">Genealogy</option><option value="Genetics">Genetics</option><option value="Geography">Geography</option><option value="Geoscience">Geoscience</option><option value="Germany">Germany</option><option value="Glaucoma">Glaucoma</option><option value="Golf">Golf</option><option value="Gospel music">Gospel music</option><option value="Goth Culture">Goth Culture</option><option value="Government">Government</option><option value="Graphic Design">Graphic Design</option><option value="Guitar">Guitar</option><option value="Guns">Guns</option><option value="Gymnastics">Gymnastics</option><option value="Hacking">Hacking</option><option value="Health">Health</option><option value="Heart Conditions">Heart Conditions</option><option value="Heavy metal">Heavy metal</option><option value="Hedonism">Hedonism</option><option value="Hentai Anime">Hentai Anime</option><option value="Hiking">Hiking</option><option value="Hinduism">Hinduism</option><option value="HipHop/Rap">HipHop/Rap</option><option value="History">History</option><option value="Hockey">Hockey</option><option value="Home Business">Home Business</option><option value="Home Improvement">Home Improvement</option><option value="Homebrewing">Homebrewing</option><option value="Homemaking">Homemaking</option><option value="Homeschooling">Homeschooling</option><option value="Horror Movies">Horror Movies</option><option value="Hotels">Hotels</option><option value="House music">House music</option><option value="Humanitarianism">Humanitarianism</option><option value="Humanities">Humanities</option><option value="Humor">Humor</option><option value="Hunting">Hunting</option><option value="IT">IT</option><option value="Independent Film">Independent Film</option><option value="India">India</option><option value="Indie Rock/Pop">Indie Rock/Pop</option><option value="Industrial Design">Industrial Design</option><option value="Industrial Music">Industrial Music</option><option value="Instant Messaging">Instant Messaging</option><option value="Insurance">Insurance</option><option value="Int\'l Development">Int\'l Development</option><option value="Interior Design">Interior Design</option><option value="Internet">Internet</option><option value="Internet Tools">Internet Tools</option><option value="Investing">Investing</option><option value="Ipod">Ipod</option><option value="Iraq">Iraq</option><option value="Ireland">Ireland</option><option value="Islam">Islam</option><option value="Israel">Israel</option><option value="Italy">Italy</option><option value="Japan">Japan</option><option value="Java">Java</option><option value="Jazz">Jazz</option><option value="Jewelry">Jewelry</option><option value="Journalism">Journalism</option><option value="Judaism">Judaism</option><option value="Karaoke">Karaoke</option><option value="Kids">Kids</option><option value="Kinesiology">Kinesiology</option><option value="Knitting">Knitting</option><option value="Korea">Korea</option><option value="Landscaping">Landscaping</option><option value="Latin Music">Latin Music</option><option value="Law">Law</option><option value="Learning Disorders">Learning Disorders</option><option value="Lefthanded">Lefthanded</option><option value="Lesbian Culture">Lesbian Culture</option><option value="Lesbian Sex">Lesbian Sex</option><option value="Liberal Politics">Liberal Politics</option><option value="Liberties/Rights">Liberties/Rights</option><option value="Library Resources">Library Resources</option><option value="Lingerie">Lingerie</option><option value="Linguistics">Linguistics</option><option value="Linux/Unix">Linux/Unix</option><option value="Literature">Literature</option><option value="Live Theatre">Live Theatre</option><option value="Logic">Logic</option><option value="Lounge Music">Lounge Music</option><option value="Luxury">Luxury</option><option value="MacOS">MacOS</option><option value="Machinery">Machinery</option><option value="Magic/Illusions">Magic/Illusions</option><option value="Management/HR">Management/HR</option><option value="Manufacturing">Manufacturing</option><option value="Marine Biology">Marine Biology</option><option value="Marketing">Marketing</option><option value="Married Life">Married Life</option><option value="Martial Arts">Martial Arts</option><option value="Matchmaking">Matchmaking</option><option value="Mathematics">Mathematics</option><option value="Mechanical Eng.">Mechanical Eng.</option><option value="Medical Science">Medical Science</option><option value="Medieval History">Medieval History</option><option value="Memorabilia">Memorabilia</option><option value="Men\'s Issues">Men\'s Issues</option><option value="Mental Health">Mental Health</option><option value="Meteorology">Meteorology</option><option value="Mexico">Mexico</option><option value="Microbiology">Microbiology</option><option value="Middle East">Middle East</option><option value="Military">Military</option><option value="Mining/Metallurgy">Mining/Metallurgy</option><option value="Mobile Computing">Mobile Computing</option><option value="Mormon">Mormon</option><option value="Motor Sports">Motor Sports</option><option value="Motorcycles">Motorcycles</option><option value="Movies">Movies</option><option value="Multimedia">Multimedia</option><option value="Music">Music</option><option value="Music Composition">Music Composition</option><option value="Music Instruments">Music Instruments</option><option value="Music Theory">Music Theory</option><option value="Musicals">Musicals</option><option value="Musician Resources">Musician Resources</option><option value="Mutual Funds">Mutual Funds</option><option value="Mystery Novels">Mystery Novels</option><option value="Mythology">Mythology</option><option value="Nanotech">Nanotech</option><option value="Native Americans">Native Americans</option><option value="Nature">Nature</option><option value="Netherlands">Netherlands</option><option value="Network Security">Network Security</option><option value="Neuroscience">Neuroscience</option><option value="New Age">New Age</option><option value="New York">New York</option><option value="News(General)">News(General)</option><option value="Nightlife">Nightlife</option><option value="Nonprofit/Charity">Nonprofit/Charity</option><option value="Nuclear Science">Nuclear Science</option><option value="Nude Art">Nude Art</option><option value="Nursing">Nursing</option><option value="Nutrition">Nutrition</option><option value="Oceania">Oceania</option><option value="Oldies Music">Oldies Music</option><option value="Online Games">Online Games</option><option value="Open Source">Open Source</option><option value="Opera">Opera</option><option value="Operating Systems">Operating Systems</option><option value="Options/Futures">Options/Futures</option><option value="Orthodox">Orthodox</option><option value="Outdoors">Outdoors</option><option value="P2P">P2P</option><option value="PHP">PHP</option><option value="Paganism">Paganism</option><option value="Painting">Painting</option><option value="Paleontology">Paleontology</option><option value="Paranormal">Paranormal</option><option value="Parenting">Parenting</option><option value="Percussion">Percussion</option><option value="Performing Arts">Performing Arts</option><option value="Peripheral Devices">Peripheral Devices</option><option value="Perl">Perl</option><option value="Personal Sites">Personal Sites</option><option value="Petroleum">Petroleum</option><option value="Pets">Pets</option><option value="Pharmacology">Pharmacology</option><option value="Philosophy">Philosophy</option><option value="Photo Gear">Photo Gear</option><option value="Photography">Photography</option><option value="Photoshop">Photoshop</option><option value="Physical Therapy">Physical Therapy</option><option value="Physics">Physics</option><option value="Physiology">Physiology</option><option value="Poetry">Poetry</option><option value="Poker">Poker</option><option value="Political Science">Political Science</option><option value="Politics">Politics</option><option value="Pop music">Pop music</option><option value="Pornography">Pornography</option><option value="Postmodernism">Postmodernism</option><option value="Pregnancy/Birth">Pregnancy/Birth</option><option value="Programming">Programming</option><option value="Protestant">Protestant</option><option value="Proxy">Proxy</option><option value="Psychiatry">Psychiatry</option><option value="Psychology">Psychology</option><option value="Punk Rock">Punk Rock</option><option value="Puzzles">Puzzles</option><option value="Quilting">Quilting</option><option value="Quizzes">Quizzes</option><option value="Quotes">Quotes</option><option value="Racquetball">Racquetball</option><option value="Radio Broadcasts">Radio Broadcasts</option><option value="Rave Culture">Rave Culture</option><option value="Real Estate">Real Estate</option><option value="Recording Gear">Recording Gear</option><option value="Reggae">Reggae</option><option value="Relationships">Relationships</option><option value="Religion">Religion</option><option value="Research">Research</option><option value="Restaurants">Restaurants</option><option value="Restoration">Restoration</option><option value="Robotics">Robotics</option><option value="Rock music">Rock music</option><option value="Rodeo">Rodeo</option><option value="Roleplaying Games">Roleplaying Games</option><option value="Romance Novels">Romance Novels</option><option value="Rugby">Rugby</option><option value="Running">Running</option><option value="Russia">Russia</option><option value="SEO">SEO</option><option value="Sailing">Sailing</option><option value="Satire">Satire</option><option value="Science">Science</option><option value="Science Fiction">Science Fiction</option><option value="Scientology">Scientology</option><option value="Scouting">Scouting</option><option value="Scrapbooking">Scrapbooking</option><option value="Scuba Diving">Scuba Diving</option><option value="Sculpting">Sculpting</option><option value="Search">Search</option><option value="Self Improvement">Self Improvement</option><option value="Semiconductors">Semiconductors</option><option value="Senior Citizens">Senior Citizens</option><option value="Sewing">Sewing</option><option value="Sex Industry">Sex Industry</option><option value="Sex Toys">Sex Toys</option><option value="Sexual Health">Sexual Health</option><option value="Sexuality">Sexuality</option><option value="Shakespeare">Shakespeare</option><option value="Shareware">Shareware</option><option value="Shopping">Shopping</option><option value="Skateboarding">Skateboarding</option><option value="Skiing">Skiing</option><option value="Skydiving">Skydiving</option><option value="Snowboarding">Snowboarding</option><option value="Soap Operas">Soap Operas</option><option value="Soccer">Soccer</option><option value="Socialism">Socialism</option><option value="Sociology">Sociology</option><option value="Software">Software</option><option value="Songwriting">Songwriting</option><option value="Soul/R&amp;B">Soul/R&amp;B</option><option value="Soundtracks">Soundtracks</option><option value="South America">South America</option><option value="Space Exploration">Space Exploration</option><option value="Spain">Spain</option><option value="Spas">Spas</option><option value="Spirituality">Spirituality</option><option value="Sports(General)">Sports(General)</option><option value="Squash">Squash</option><option value="Statistics">Statistics</option><option value="StumbleUpon">StumbleUpon</option><option value="Subculture">Subculture</option><option value="Substance Abuse">Substance Abuse</option><option value="Sufism">Sufism</option><option value="Sunni">Sunni</option><option value="Supercomputing">Supercomputing</option><option value="Surfing">Surfing</option><option value="Survivalist">Survivalist</option><option value="Swimming">Swimming</option><option value="Swingers">Swingers</option><option value="Tattoos/Piercing">Tattoos/Piercing</option><option value="Taxation">Taxation</option><option value="Tea">Tea</option><option value="Techno">Techno</option><option value="Technology">Technology</option><option value="Teen Life">Teen Life</option><option value="Teen Parenting">Teen Parenting</option><option value="Telecom">Telecom</option><option value="Television">Television</option><option value="Tennis">Tennis</option><option value="Terrorism">Terrorism</option><option value="Toys">Toys</option><option value="Track/Field">Track/Field</option><option value="Trains/Railroads">Trains/Railroads</option><option value="Trance">Trance</option><option value="Transexual Sex">Transexual Sex</option><option value="Transportation">Transportation</option><option value="Travel">Travel</option><option value="TripHop/Downtempo">TripHop/Downtempo</option><option value="UFOs">UFOs</option><option value="UK">UK</option><option value="USA">USA</option><option value="University/College">University/College</option><option value="Vegetarian">Vegetarian</option><option value="Video Equipment">Video Equipment</option><option value="Video Games">Video Games</option><option value="Vintage Cars">Vintage Cars</option><option value="Virtual Reality">Virtual Reality</option><option value="Vocal Music">Vocal Music</option><option value="Volleyball">Volleyball</option><option value="Water Sports">Water Sports</option><option value="Web Development">Web Development</option><option value="Webhosting">Webhosting</option><option value="Weblogs">Weblogs</option><option value="Weddings">Weddings</option><option value="Weight Loss">Weight Loss</option><option value="Wicca">Wicca</option><option value="Windows">Windows</option><option value="Windows Dev">Windows Dev</option><option value="Windsurfing">Windsurfing</option><option value="Wine">Wine</option><option value="Women\'s Issues">Women\'s Issues</option><option value="Woodworking">Woodworking</option><option value="Wrestling">Wrestling</option><option value="Writing">Writing</option><option value="Yoga">Yoga</option><option value="Zoology">Zoology</option>'; }
33
  //#### Show Unit Settings
34
+ function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl; $nt = $options['ntInfo']['lcode']; $ntU = strtoupper($nt);
35
  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'] = '';
36
+ if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; if (!isset($options['nsfw'])) $options['nsfw'] = ''; ?>
37
+ <div id="doSU<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>"> <input type="hidden" name="apDoSSU<?php echo $ii; ?>" value="0" id="apDoSSU<?php echo $ii; ?>" />
38
 
39
  <div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/su16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-stumbleupon-social-networks-auto-poster-wordpress/"><?php $nType="StumbleUpon"; printf( __( 'Detailed %s Installation/Configuration Instructions', 'nxs_snap' ), $nType); ?></a></div>
40
 
41
+ <div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'nxs_snap'); ?></i> </div><input name="su[<?php echo $ii; ?>][nName]" id="sunName<?php echo $ii; ?>" style="font-weight: bold; color: #005800; border: 1px solid #ACACAC; width: 40%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['nName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /><br/>
42
+ <?php echo nxs_addQTranslSel('su', $ii, $options['qTLng']); ?>
43
 
44
+ <br/>
45
+ <ul class="nsx_tabs">
46
+ <li><a href="#nsx<?php echo $nt.$ii ?>_tab1"><?php _e('Account Info', 'nxs_snap'); ?></a></li>
47
+ <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'nxs_snap'); ?></a></li>
48
+ </ul>
49
+ <div class="nsx_tab_container"><?php /* ######################## Account Tab ####################### */ ?>
50
+ <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%;">
51
+
52
 
53
  <div style="width:100%;"><strong>StumbleUpon Username:</strong> </div><input name="su[<?php echo $ii; ?>][apSUUName]" id="apSUUName" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['suUName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
54
  <div style="width:100%;"><strong>StumbleUpon Password:</strong> </div><input name="su[<?php echo $ii; ?>][apSUPass]" id="apSUPass" type="password" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities(substr($options['suPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['suPass'], 5)):$options['suPass'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /> <br/>
82
  </div><br/>
83
 
84
  <?php if ($options['suPass']!='') { ?>
85
+
86
  <b><?php _e('Test your settings', 'nxs_snap'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('SU', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s' , 'nxs_snap'), $nType); ?></a>
87
 
88
  <?php }
89
 
90
+ ?></div>
91
+ <?php /* ######################## Advanced Tab ####################### */ ?>
92
+ <div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content">
93
+
94
+ <?php if (!$isNew) { ?> <div class="nxs_tls_cpt"><?php _e('Categories', 'nxs_snap'); ?></div>
95
+ <div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
96
+ <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
97
+ <input value="1" id="catSelS<?php echo $ntU; ?><?php echo $ii; ?>" type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_<?php echo $ntU; ?><?php echo $ii; ?>" onclick="jQuery('#catSelS<?php echo $ntU; ?><?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('<?php echo $ntU; ?><?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($options['catSelEd']!='') echo "[".(substr_count($options['catSelEd'], ",")+1)."]"; ?></a>
98
+ <input type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
99
+ <br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
100
+ <br/>
101
+ <?php } ?>
102
+
103
+ <?php nxs_addPostingDelaySelV3($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']); ?>
104
+ <?php nxs_showRepostSettings($nt, $ii, $options); ?>
105
+
106
+
107
+ </div> <?php /* #### End of Tab #### */ ?>
108
+ </div><br/> <?php /* #### End of Tabs #### */ ?>
109
+
110
+ <div class="submit clear" style="padding-bottom: 0px;"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div></div><?php
111
  }
112
  //#### Set Unit Settings from POST
113
  function setNTSettings($post, $options){ global $nxs_snapThisPageUrl; $code = 'SU'; $lcode = 'su';
114
  foreach ($post as $ii => $pval){
115
  if (isset($pval['apSUUName']) && $pval['apSUUName']!=''){ if (!isset($options[$ii])) $options[$ii] = array();
116
+
117
+ $isUPChanged = ((isset($pval['apSUPass']) && isset($options[$ii]['suPass']) && 'n5g9a'.nsx_doEncode($pval['apSUPass'])!=$options[$ii]['suPass']) || !isset($options[$ii]['suPass'])) ||
118
+ ((isset($pval['apSUUName']) && isset($options[$ii]['suUName']) && $pval['apSUUName']!=$options[$ii]['suUName']) || !isset($options[$ii]['suUName']));
119
+ if ($isUPChanged) $options[$ii]['suSvC'] = '';
120
+
121
  if (isset($pval['apSUUName'])) $options[$ii]['suUName'] = trim($pval['apSUUName']);
122
  if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']);
123
  if (isset($pval['apSUPass'])) $options[$ii]['suPass'] = 'n5g9a'.nsx_doEncode($pval['apSUPass']); else $options[$ii]['suPass'] = '';
124
  if (isset($pval['apSUCat'])) $options[$ii]['suCat'] = trim($pval['apSUCat']);
125
  if (isset($pval['suInclTags'])) $options[$ii]['suInclTags'] = $pval['suInclTags']; else $options[$ii]['suInclTags'] = 0;
126
  if (isset($pval['apSUMsgFrmt'])) $options[$ii]['suMsgFormat'] = trim($pval['apSUMsgFrmt']);
127
+
128
  if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']);
129
+ if (!empty($options[$ii]['catSel']) && $options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
130
 
131
  if (isset($pval['apDoSU'])) $options[$ii]['doSU'] = $pval['apDoSU']; else $options[$ii]['doSU'] = 0;
132
  if (isset($pval['nsfw'])) $options[$ii]['nsfw'] = $pval['nsfw']; else $options[$ii]['nsfw'] = 0;
133
+
134
+ $options[$ii] = nxs_adjRpst($options[$ii], $pval);
135
+
136
+ if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']);
137
  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
  }
140
  } return $options;
141
  }
142
  //#### Show Post->Edit Meta Box Settings
143
+ function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID; $nt = 'su'; $ntU = 'SU'; //prr($post); prr($ntOpts);
144
+ foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapSU', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
145
  $doSU = $ntOpt['doSU'] && (is_array($pMeta) || $ntOpt['catSel']!='1');
146
  $isAvailSU = $ntOpt['suUName']!='' && $ntOpt['suPass']!=''; $suMsgFormat = htmlentities($ntOpt['suMsgFormat'], ENT_COMPAT, "UTF-8");
147
  ?>
151
 
152
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/su16.png);">StumbleUpon - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
153
  if ($post->post_status == "publish" && $isAvailSU) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToSU_repostButton" id="rePostToSU_button" value="<?php _e('Repost to StumbleUpon', 'nxs_snap') ?>" />
154
+ <?php } ?>
155
 
156
  <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
157
 
161
  </td></tr>
162
 
163
  <?php if (!$isAvailSU) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your StumbleUpon Account to AutoPost to StumbleUpon</b>
164
+ <?php } else { if ($post->post_status != "publish" && function_exists('nxs_doSMAS5') ) { nxs_doSMAS5($nt, $ii, $ntOpt); } ?>
165
+
166
+ <?php if ($ntOpt['rpstOn']=='1') { ?>
167
+
168
+ <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top:6px; text-align:right; width:60px; padding-right:10px;">
169
+ <input value="0" type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]"/><input value="nxsi<?php echo $ii; ?>su" type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]" <?php if (!empty($ntOpt['rpstPostIncl'])) echo "checked"; ?> />
170
+ </th>
171
+ <td> <?php _e('Include in "Auto-Reposting" to this network.', 'nxs_snap') ?>
172
+ </td></tr> <?php } ?>
173
 
174
  <tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;">Category:</th>
175
  <td><div id="altFormat" style="">
177
  <?php $suCats = $this->suCats();
178
  if (isset($ntOpt['suCat']) && $ntOpt['suCat']!='') $suCats = str_replace('"'.$ntOpt['suCat'].'"', '"'.$ntOpt['suCat'].'" selected="selected"', $suCats); echo $suCats;
179
  ?>
180
+ </select>
181
+ <input value="0" id="sunsfw<?php echo $ii; ?>" type="hidden" name="su[<?php echo $ii; ?>][nsfw]" />
182
+ <input value="1" id="sunsfw<?php echo $ii; ?>" type="checkbox" name="su[<?php echo $ii; ?>][nsfw]" <?php if ((int)$ntOpt['nsfw'] == 1) echo "checked"; ?> /> <strong>NSFW</strong>
183
 
184
  </div> </td></tr>
185
 
194
  function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
195
  if (isset($pMeta['nsfw'])) $optMt['nsfw'] = $pMeta['nsfw']; else $optMt['nsfw'] = 0;
196
  if (isset($pMeta['SNAPformat'])) $optMt['suMsgFormat'] = $pMeta['SNAPformat'];
197
+ if (isset($pMeta['imgToUse'])) $optMt['imgToUse'] = $pMeta['imgToUse'];
198
+ if (isset($pMeta['timeToRun'])) $optMt['timeToRun'] = $pMeta['timeToRun']; if (isset($pMeta['rpstPostIncl'])) $optMt['rpstPostIncl'] = $pMeta['rpstPostIncl'];
199
  if (isset($pMeta['apSUCat'])) $optMt['suCat'] = $pMeta['apSUCat'];
200
  if (isset($pMeta['doSU'])) $optMt['doSU'] = $pMeta['doSU'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doSU'] = 0; }
201
+ if (isset($pMeta['SNAPincludeSU']) && $pMeta['SNAPincludeSU'] == '1' ) $optMt['doSU'] = 1;
202
  return $optMt;
203
  }
204
  }}
205
  if (!function_exists("nxs_rePostToSU_ajax")) {
206
+ function nxs_rePostToSU_ajax() { check_ajax_referer('nxsSsPageWPN'); $postID = $_POST['id']; $options = get_option('NS_SNAutoPoster');
207
  foreach ($options['su'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj'; //if ($two['gpPageID'].$two['gpUName']==$_POST['nid']) {
208
  $gppo = get_post_meta($postID, 'snapSU', true); $gppo = maybe_unserialize($gppo);// prr($gppo);
209
  if (is_array($gppo) && isset($gppo[$ii]) && is_array($gppo[$ii])){ $ntClInst = new nxs_snapClassSU(); $two = $ntClInst->adjMetaOpt($two, $gppo[$ii]); }
212
  }
213
  }
214
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
215
  if (!function_exists("nxs_doPublishToSU")) { //## Second Function to Post to SU
216
+ function nxs_doPublishToSU($postID, $options){ global $nxs_suCkArray; $ntCd = 'SU'; $ntCdL = 'su'; $ntNm = 'StumbleUpon'; if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
217
  //$backtrace = debug_backtrace(); nxs_addToLogN('W', 'Enter', $ntCd, 'I am here - '.$ntCd."|".print_r($backtrace, true), '');
218
  //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToSU', array($postID, $options));
219
+ $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'POSTID'=>$postID, 'ACCNAME'=>$options['nName']));
220
+ $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url();
221
+
222
  $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
223
  $logNT = '<span style="color:#000080">StumbleUpon</span> - '.$options['nName'];
224
  $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
225
+ /* Check is still nessesary or redo
226
  if ($options['reset'] != '1' && $options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
227
  $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') { sleep(5);
228
  nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$uqID); return;
229
  }
230
  }
231
+ */
232
+ $suCat = $options['suCat'];
233
+ // if (function_exists("get_post_thumbnail_id") ){ $src = wp_get_attachment_image_src(get_post_thumbnail_id($postID), 'thumbnail'); $src = $src[0];}
234
+ if ($postID=='0') { echo "Testing ... <br/><br/>"; $urlToGo = home_url(); $options['suMsgFormat'] = 'Test Link from '.$urlToGo; } else { $post = get_post($postID); if(!$post) return;
235
+ $options['suMsgFormat'] = nsFormatMessage($options['suMsgFormat'], $postID, $addParams); nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
236
+ //## MyURL - URLToGo code
237
+ if (!isset($options['urlToUse']) || trim($options['urlToUse'])=='') $myurl = trim(get_post_meta($postID, 'snap_MYURL', true)); if ($myurl!='') $options['urlToUse'] = $myurl;
238
+ if (isset($options['urlToUse']) && trim($options['urlToUse'])!='') { $urlToGo = $options['urlToUse']; $options['useFBGURLInfo'] = true; } else $urlToGo = get_permalink($postID);
239
+ if($addParams!='') $urlToGo .= (strpos($urlToGo,'?')!==false?'&':'?').$addParams;
240
+ }
241
+ $dusername = $options['suUName']; //$link = urlencode($link); $desc = urlencode(substr($msg, 0, 500));
242
+ if ($options['suInclTags']=='1') { $t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = urlencode(implode(',',$tggs)); $tags = str_replace(' ','+',$tags); } else $tags = '';
243
+ $extInfo = ' | PostID: '.$postID." - ".(isset($post) && is_object($post)?$post->post_title:'');
244
+ //## Post
245
+ $message = array('siteName'=>$blogTitle, 'tags'=>$tags, 'url'=>$urlToGo);
246
+ //## Actual Post
247
+ $ntToPost = new nxs_class_SNAP_SU(); $ret = $ntToPost->doPostToNT($options, $message);
248
+ //## Save Session
249
+ if (serialize($nxs_suCkArray)!=$options['suSvC']) { global $plgn_NS_SNAutoPoster; $gOptions = $plgn_NS_SNAutoPoster->nxs_options;
250
  if (isset($options['ii']) && $options['ii']!=='') { $gOptions['su'][$options['ii']]['suSvC'] = serialize($nxs_suCkArray); update_option('NS_SNAutoPoster', $gOptions); }
251
  else foreach ($gOptions['su'] as $ii=>$gpn) { $result = array_diff($options, $gpn);
252
  if (!is_array($result) || count($result)<1) { $gOptions['su'][$ii]['suSvC'] = serialize($nxs_suCkArray); update_option('NS_SNAutoPoster', $gOptions); break; }
253
  }
254
  }
255
+ //## Process Results
256
+ if (!is_array($ret) || $ret['isPosted']!='1') { //## Error
257
+ if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);
258
+ } else { // ## All Good - log it.
259
+ if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo _e('OK - Message Posted, please see your '.$logNT.' Page. ', 'nxs_snap'); }
260
+ 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); }
261
+ } //prr($ret);
262
+ //## Return Result
263
+ if ($ret['isPosted']=='1') return 200; else return print_r($ret, true);
 
 
 
 
 
264
  }
265
  }
266
  ?>
inc-cl/tr.api.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //## NextScripts FriendFeed Connection Class
3
+ $nxs_snapAPINts[] = array('code'=>'TR', 'lcode'=>'tr', 'name'=>'Tumblr');
4
+
5
+ if (!class_exists("nxs_class_SNAP_TR")) { class nxs_class_SNAP_TR {
6
+
7
+ var $ntCode = 'TR';
8
+ var $ntLCode = 'tr';
9
+
10
+ function doPost($options, $message){ if (!is_array($options)) return false;
11
+ foreach ($options as $ntOpts) $out[] = $this->doPostToNT($ntOpts, $message);
12
+ return $out;
13
+ }
14
+ function doPostToNT($options, $message){ $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>'');
15
+ //## Check settings
16
+ if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
17
+ if (!isset($options['trConsKey']) || trim($options['trConsSec'])=='') { $badOut['Error'] = 'Not Configured'; return $badOut; }
18
+ //## Format
19
+ $msg = nxs_doFormatMsg($options['trMsgFormat'], $message); $msgT = nxs_doFormatMsg($options['trMsgTFormat'], $message);
20
+
21
+
22
+ //## Post
23
+ require_once('apis/trOAuth.php'); $consumer_key = $options['trConsKey']; $consumer_secret = $options['trConsSec'];
24
+ $tum_oauth = new TumblrOAuth($consumer_key, $consumer_secret, $options['trAccessTocken']['oauth_token'], $options['trAccessTocken']['oauth_token_secret']); //prr($options);
25
+
26
+ $postArr = array('tags'=>$message['tags'], 'date'=>$message['postDate']);
27
+ if (isset($message['imageURL'])) $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); else $imgURL = '';
28
+
29
+ if ($options['trPostType']=='I') { $postArr['type'] = 'photo'; $postArr['caption'] = $msg; $postArr['source'] = $imgURL;
30
+ if (!isset($options['cImgURL']) || $options['cImgURL']=='' || $options['cImgURL']=='R' ) $postArr['link'] = $message['url'];
31
+ elseif ($options['cImgURL']=='S' ) { $postArr['link'] = $message['url']; $postArr['link'] = nxs_mkShortURL($postArr['link']);}
32
+ } elseif($options['trPostType']=='U') { $postArr['type'] = 'audio'; $postArr['caption'] = $msg; $postArr['external_url'] = $aUrl;
33
+ } elseif($options['trPostType']=='V') { $postArr['type'] = 'video'; $postArr['caption'] = $msg;
34
+ $embedTxt = '<iframe width="560" height="315" src="http://www.youtube.com/embed/'.$message['videoURL'].'" frameborder="0" allowfullscreen></iframe>';
35
+ $postArr['embed'] = $embedTxt;
36
+ } else { $postArr['title'] = $msgT; $postArr['type'] = 'text'; $postArr['source'] = $message['url']; $postArr['body'] = $msg; }
37
+
38
+ $postinfo = $tum_oauth->post("http://api.tumblr.com/v2/blog/".$options['trURL']."/post", $postArr); // prr($postinfo); prr($postArr);
39
+
40
+ $code = $postinfo->meta->status;// echo "XX".print_r($code); prr($postinfo); // prr($msg); prr($postinfo); echo $code."VVVV"; die("|====");
41
+
42
+ if ($code == 201) { return array('postID'=>$postinfo->response->id, 'isPosted'=>1, 'postURL'=>$postinfo->response->id, 'pDate'=>date('Y-m-d H:i:s')); }
43
+ else $badOut['Error'] .= $code . " - ".($postinfo->meta->msg).(isset($postinfo->errmsg)?$postinfo->errmsg:'')." | ".print_r($postinfo, true);
44
+ return $badOut;
45
+ }
46
+ }}
47
+ ?>
inc-cl/tr.php CHANGED
@@ -36,7 +36,7 @@ if (!class_exists("nxs_snapClassTR")) { class nxs_snapClassTR {
36
  <div class="nxs_box">
37
  <div class="nxs_box_header">
38
  <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']; ?>
39
- <?php $cbo = count($ntOpts); ?> <?php wp_nonce_field( 'ns'.$ntInfo['code'], 'ns'.$ntInfo['code'].'_wpnonce' ); ?>
40
  <?php if ($cbo>1){ ?><div class="nsBigText"><?php echo "(".($cbo=='0'?'No':$cbo)." "; _e('accounts', 'nxs_snap'); echo ")"; ?></div><?php } ?>
41
  </div>
42
  </div>
@@ -44,35 +44,41 @@ if (!class_exists("nxs_snapClassTR")) { class nxs_snapClassTR {
44
  <?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = str_ireplace('https://','', str_ireplace('http://','', $pbo['trURL']));
45
  if (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='') $pbo[$ntInfo['lcode'].'OK'] = (isset($pbo['trOAuthTokenSecret']) && $pbo['trOAuthTokenSecret']!='')?'1':''; ?>
46
  <p style="margin:0px;margin-left:5px;">
47
- <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> /> <?php if ((int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
 
 
48
  <strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
49
  &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', 'nxs_snap'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>&nbsp;&nbsp;
50
  <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
51
- </p><?php $this->showNTSettings($indx, $pbo);
52
  }?>
53
  </div>
54
  </div> <?php
55
  }
56
  //#### Show NEW Settings Page
57
- function showNewNTSettings($bo){ $po = array('nName'=>'', 'doTR'=>'1', 'trURL'=>'', 'trPgID'=>'', 'trConsKey'=>'', 'trInclTags'=>'1', 'trInclCats'=>'0', 'cImgURL'=>'R', 'trConsSec'=>'', 'trPostType'=>'T', 'trDefImg'=>'', 'trOAuthTokenSecret'=>'', 'trAccessTocken'=>'', 'trMsgFormat'=>'<p>New Post has been published on %URL%</p><blockquote><p><strong>%TITLE%</strong></p><p><img src=\'%IMG%\'/></p><p>%FULLTEXT%</p></blockquote>', 'trMsgTFormat'=>'New Post has been published on %SITENAME%' ); $this->showNTSettings($bo, $po, true);}
 
58
  //#### Show Unit Settings
59
- function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl,$nxs_snapThisPageUrl; ?>
 
 
60
  <div id="doTR<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>" style="background-image: url(<?php echo $nxs_plurl; ?>img/tr-bg.png); background-position:90% 10%;"> <input type="hidden" name="apDoSTR<?php echo $ii; ?>" value="0" id="apDoSTR<?php echo $ii; ?>" />
61
  <?php if ($isNew) { ?> <input type="hidden" name="tr[<?php echo $ii; ?>][apDoTR]" value="1" id="apDoNewTR<?php echo $ii; ?>" /> <?php } ?>
62
 
63
  <div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/tr16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-tumblr-social-networks-auto-poster-wordpress/"><?php $nType="Tumblr"; printf( __( 'Detailed %s Installation/Configuration Instructions' , 'nxs_snap'), $nType); ?></a></div>
64
 
65
- <div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easely identify it', 'nxs_snap'); ?></i> </div><input name="tr[<?php echo $ii; ?>][nName]" id="trnName<?php echo $ii; ?>" style="font-weight: bold; color: #005800; border: 1px solid #ACACAC; width: 40%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['nName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /><br/>
66
- <?php echo nxs_addQTranslSel('tr', $ii, $options['qTLng']); ?><?php echo nxs_addPostingDelaySel('tr', $ii, $options['nHrs'], $options['nMin'], $options['nDays']); ?>
67
 
68
- <?php if (!$isNew) { ?>
69
- <div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
70
- <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="tr[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
71
- <input value="1" id="catSelSTR<?php echo $ii; ?>" type="radio" name="tr[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_TR<?php echo $ii; ?>" onclick="jQuery('#catSelSTR<?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('TR<?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_TR<?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($options['catSelEd']!='') echo "[".(substr_count($options['catSelEd'], ",")+1)."]"; ?></a>
72
- <input type="hidden" name="tr[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_TR<?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
73
- <br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
74
- <br/>
75
- <?php } ?>
 
76
 
77
  <div style="width:100%;"><strong>Tumblr URL:</strong> <i>It should be your public URL. (i.e. like <b>http://nextscripts.tumblr.com/</b>, not http://www.tumblr.com/blog/nextscripts</i> </div><input onchange="nxsTRURLVal(<?php echo $ii; ?>);" name="tr[<?php echo $ii; ?>][apTRURL]" id="apTRURL<?php echo $ii; ?>" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['trURL'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /><span style="color: #F00000;" id="apTRURLerr<?php echo $ii; ?>"></span>
78
  <div style="width:100%;"><strong>Tumblr OAuth Consumer Key:</strong> </div><input name="tr[<?php echo $ii; ?>][apTRConsKey]" id="apTRConsKey" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['trConsKey'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
@@ -137,10 +143,31 @@ if (!class_exists("nxs_snapClassTR")) { class nxs_snapClassTR {
137
 
138
 
139
  <?php if( isset($options['trOAuthTokenSecret']) && $options['trOAuthTokenSecret']!='') { ?>
140
- <?php wp_nonce_field( 'rePostToTR', 'rePostToTR_wpnonce' ); ?>
141
  <br/><br/><b><?php _e('Test your settings', 'nxs_snap'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('TR', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s' , 'nxs_snap'), $nType); ?></a> <br/><br/>
142
  <?php }?>
143
- <div class="submit"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144
 
145
  </div>
146
  <?php
@@ -173,16 +200,20 @@ if (!class_exists("nxs_snapClassTR")) { class nxs_snapClassTR {
173
 
174
  if (isset($pval['apTRDefImg'])) $options[$ii]['trDefImg'] = trim($pval['apTRDefImg']);
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
  } // prr($options);
180
  } return $options;
181
  }
182
  //#### Show Post->Edit Meta Box Settings
183
- function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
184
- foreach($ntOpts as $ii=>$options) {$pMeta = maybe_unserialize(get_post_meta($post_id, 'snapTR', true)); if (is_array($pMeta)) $options = $this->adjMetaOpt($options, $pMeta[$ii]);
185
- $doTR = $options['doTR'] && (is_array($pMeta) || (is_array($pMeta) || $options['catSel']!='1'));
 
 
186
  $isAvailTR = isset($options['trAccessTocken']) && isset($options['trAccessTocken']['oauth_token_secret']) && $options['trAccessTocken']['oauth_token_secret']!=='';
187
  $trMsgFormat = htmlentities($options['trMsgFormat'], ENT_COMPAT, "UTF-8"); $trMsgTFormat = htmlentities($options['trMsgTFormat'], ENT_COMPAT, "UTF-8");
188
  ?>
@@ -192,16 +223,24 @@ if (!class_exists("nxs_snapClassTR")) { class nxs_snapClassTR {
192
  <?php if ($post->post_status == "publish") { ?> <input type="hidden" name="tr[<?php echo $ii; ?>][doTR]" value="<?php echo $doTR;?>"> <?php } ?> <?php } ?>
193
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/tr16.png);">Tumblr - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $options['nName']; ?></i>) </div></th><td><?php //## Only show RePost button if the post is "published"
194
  if ($post->post_status == "publish" && $isAvailTR) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;"Z type="button" class="button" name="rePostToTR_repostButton" id="rePostToTR_button" value="<?php _e('Repost to Tumblr', 'nxs_snap') ?>" />
195
- <?php wp_nonce_field( 'rePostToTR', 'rePostToTR_wpnonce' ); } ?>
196
 
197
- <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
198
  ?> <span id="pstdTR<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
199
  <a style="font-size: 10px;" href="<?php echo $options['trURL']; ?>post/<?php echo $pMeta[$ii]['pgID']; ?>" target="_blank"><?php $nType="Tumblr"; printf( __( 'Posted on', 'nxs_snap' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
200
  </span><?php } ?>
201
 
202
  </td></tr>
203
  <?php if (!$isAvailTR) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup and authorize your Tumblr Account to AutoPost to Tumblr</b>
204
- <?php }elseif ($post->post_status != "puZblish") { ?>
 
 
 
 
 
 
 
 
205
 
206
  <tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;">
207
  <input type="radio" name="tr[<?php echo $ii; ?>][apTRPostType]" value="T" <?php if ($options['trPostType'] != 'I') echo 'checked="checked"'; ?> /> <br/>
@@ -221,6 +260,8 @@ if (!class_exists("nxs_snapClassTR")) { class nxs_snapClassTR {
221
  <td>
222
  <textarea cols="150" rows="1" id="tr<?php echo $ii; ?>SNAPformat" name="tr[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('#tr<?php echo $ii; ?>SNAPformat').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apTRMsgFrmt<?php echo $ii; ?>');"><?php echo $trMsgFormat; ?></textarea>
223
  <?php nxs_doShowHint("apTRMsgFrmt".$ii); ?></td></tr>
 
 
224
 
225
  <?php }
226
  }
@@ -228,8 +269,9 @@ if (!class_exists("nxs_snapClassTR")) { class nxs_snapClassTR {
228
  }
229
 
230
  function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
231
- if (isset($pMeta['SNAPformat'])) $optMt['trMsgFormat'] = $pMeta['SNAPformat'];
232
- if (isset($pMeta['SNAPTformat'])) $optMt['trMsgTFormat'] = $pMeta['SNAPTformat'];
 
233
  if (isset($pMeta['apTRPostType'])) $optMt['trPostType'] = $pMeta['apTRPostType'];
234
  if (isset($pMeta['AttachPost'])) $optMt['trAttch'] = $pMeta['AttachPost'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['trAttch'] = 0; }
235
  if (isset($pMeta['doTR'])) $optMt['doTR'] = $pMeta['doTR'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doTR'] = 0; }
@@ -238,7 +280,7 @@ if (!class_exists("nxs_snapClassTR")) { class nxs_snapClassTR {
238
  }
239
  }}
240
 
241
- if (!function_exists("nxs_rePostToTR_ajax")) { function nxs_rePostToTR_ajax() { check_ajax_referer('rePostToTR'); $postID = $_POST['id'];
242
  $options = get_option('NS_SNAutoPoster'); foreach ($options['tr'] as $ii=>$po) if ($ii==$_POST['nid']) { $po['ii'] = $ii; $po['pType'] = 'aj';
243
  $mpo = get_post_meta($postID, 'snapTR', true); $mpo = maybe_unserialize($mpo);
244
  if (is_array($mpo) && isset($mpo[$ii]) && is_array($mpo[$ii]) ){ $ntClInst = new nxs_snapClassTR(); $po = $ntClInst->adjMetaOpt($po, $mpo[$ii]); }
@@ -248,8 +290,12 @@ if (!function_exists("nxs_rePostToTR_ajax")) { function nxs_rePostToTR_ajax() {
248
  }
249
 
250
  if (!function_exists("nxs_doPublishToTR")) { //## Second Function to Post to TR
251
- function nxs_doPublishToTR($postID, $options){ $ntCd = 'TR'; $ntCdL = 'tr'; $ntNm = 'Tumblr';
252
- //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToTR', array($postID, $options));
 
 
 
 
253
  $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url();
254
  $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
255
  $logNT = '<span style="color:#014A76">Tumblr</span> - '.$options['nName'];
@@ -260,39 +306,41 @@ if (!function_exists("nxs_doPublishToTR")) { //## Second Function to Post to TR
260
  }
261
  }
262
  //## Format
263
- if ($postID=='0') { echo "Testing ... <br/><br/>"; $msg = 'Test Post from '.$blogTitle; $msgT = 'Test Post from '.$blogTitle; $options['trPostType']=='T';}
264
- else{ $post = get_post($postID); if(!$post) return; $trMsgFormat = $options['trMsgFormat']; $msg = nsFormatMessage($trMsgFormat, $postID);
265
- $trMsgTFormat = $options['trMsgTFormat']; $msgT = nsFormatMessage($trMsgTFormat, $postID); nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
266
- } //prr($options); die();
267
- //## Post
268
- require_once('apis/trOAuth.php'); $consumer_key = $options['trConsKey']; $consumer_secret = $options['trConsSec'];
269
- $tum_oauth = new TumblrOAuth($consumer_key, $consumer_secret, $options['trAccessTocken']['oauth_token'], $options['trAccessTocken']['oauth_token_secret']); //prr($options);
270
- $trURL = trim(str_ireplace('http://', '', $options['trURL'])); if (substr($trURL,-1)=='/') $trURL = substr($trURL,0,-1); $tggs = array();
271
- if ($options['trInclTags']=='1'){ $t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = implode(',', $tggs); }
272
- if ($options['trInclCats']=='1'){ $t = wp_get_post_categories($postID); foreach($t as $c){ $cat = get_category($c); $tggs[] = $cat->name; } $tags = implode(',', $tggs); }
273
- $postDate = ($post->post_date_gmt!='0000-00-00 00:00:00'?$post->post_date_gmt:gmdate("Y-m-d H:i:s", strtotime($post->post_date)))." GMT"; //## Adds date to Tumblr post. Thanks to Kenneth Lecky
274
- $extInfo = ' | PostID: '.$postID." - ".$post->post_title.' |'.$options['pType'];
275
- $postArr = array('tags'=>$tags, 'date'=>$postDate);
276
- if($options['trPostType']=='V') { $vids = nsFindVidsInPost($post); if (count($vids)>0) $ytUrl = $vids[0]; if (trim($ytUrl)=='') $options['trPostType']='T'; }
277
- if($options['trPostType']=='U') { $aud = nsFindAudioInPost($post); if (count($aud)>0) $aUrl = $aud[0]; if (trim($aUrl)=='') $options['trPostType']='T'; }
278
- if($options['trPostType']=='I') { $imgURL = nxs_getPostImage($postID, 'large', $options['trDefImg']); if (trim($imgURL)=='') $options['trPostType']='T'; }
279
- if ($options['trPostType']=='I') { $postArr['type'] = 'photo'; $postArr['caption'] = $msg; $postArr['source'] = $imgURL;
280
- if (!isset($options['cImgURL']) || $options['cImgURL']=='' || $options['cImgURL']=='R' ) $postArr['link'] = get_permalink($postID);
281
- elseif ($options['cImgURL']=='S' ) {$postArr['link'] = get_permalink($postID); $postArr['link'] = nxs_mkShortURL($postArr['link']);}
282
- } elseif($options['trPostType']=='U') { $postArr['type'] = 'audio'; $postArr['caption'] = $msg; $postArr['external_url'] = $aUrl;
283
- } elseif($options['trPostType']=='V') { $postArr['type'] = 'video'; $postArr['caption'] = $msg;
284
- $embedTxt = '<iframe width="560" height="315" src="http://www.youtube.com/embed/'.$ytUrl.'" frameborder="0" allowfullscreen></iframe>';
285
- $postArr['embed'] = $embedTxt;
286
- } else { $postArr['title'] = $msgT; $postArr['type'] = 'text'; $postArr['source'] = get_permalink($postID); $postArr['body'] = $msg; }
287
-
288
- $postinfo = $tum_oauth->post("http://api.tumblr.com/v2/blog/".$trURL."/post", $postArr); // prr($postinfo); prr($postArr);
289
-
290
- $code = $postinfo->meta->status;// echo "XX".print_r($code); prr($postinfo); // prr($msg); prr($postinfo); echo $code."VVVV"; die("|====");
291
- if ($code == 201) { if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo 'OK - Message Posted, please see your Tumblr Page. <br/> Result:'; prr($postinfo->meta); }
292
- else { nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); nxs_metaMarkAsPosted($postID, 'TR', $options['ii'], array('isPosted'=>'1', 'pgID'=>$postinfo->response->id, 'pDate'=>date('Y-m-d H:i:s'))); } }
293
- else { nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($postinfo, true), $extInfo); if ($postID=='0') prr($postinfo); $code .= " - ".$postinfo->meta->msg.$postinfo->errmsg; }
294
 
295
- return $code;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
296
  }
297
  }
298
 
36
  <div class="nxs_box">
37
  <div class="nxs_box_header">
38
  <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']; ?>
39
+ <?php $cbo = count($ntOpts); ?>
40
  <?php if ($cbo>1){ ?><div class="nsBigText"><?php echo "(".($cbo=='0'?'No':$cbo)." "; _e('accounts', 'nxs_snap'); echo ")"; ?></div><?php } ?>
41
  </div>
42
  </div>
44
  <?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = str_ireplace('https://','', str_ireplace('http://','', $pbo['trURL']));
45
  if (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='') $pbo[$ntInfo['lcode'].'OK'] = (isset($pbo['trOAuthTokenSecret']) && $pbo['trOAuthTokenSecret']!='')?'1':''; ?>
46
  <p style="margin:0px;margin-left:5px;">
47
+ <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> />
48
+ <?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 } ?>
49
+ <?php if (isset($pbo['rpstOn']) && (int)$pbo['rpstOn'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popReActive');" onmouseover="nxs_showPopUpInfo('popReActive', event);"><?php echo "*[R]*" ?></span><?php } ?>
50
  <strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
51
  &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', 'nxs_snap'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>&nbsp;&nbsp;
52
  <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
53
+ </p><?php $pbo['ntInfo'] = $ntInfo; $this->showNTSettings($indx, $pbo);
54
  }?>
55
  </div>
56
  </div> <?php
57
  }
58
  //#### Show NEW Settings Page
59
+ function showNewNTSettings($bo){ $po = array('nName'=>'', 'doTR'=>'1', 'trURL'=>'', 'trPgID'=>'', 'trConsKey'=>'', 'trInclTags'=>'1', 'trInclCats'=>'0', 'cImgURL'=>'R', 'trConsSec'=>'', 'trPostType'=>'T', 'trDefImg'=>'', 'trOAuthTokenSecret'=>'', 'trAccessTocken'=>'', 'trMsgFormat'=>'<p>New Post has been published on %URL%</p><blockquote><p><strong>%TITLE%</strong></p><p><img src=\'%IMG%\'/></p><p>%FULLTEXT%</p></blockquote>', 'trMsgTFormat'=>'New Post has been published on %SITENAME%' );
60
+ $po['ntInfo']= array('lcode'=>'tr'); $this->showNTSettings($bo, $po, true);}
61
  //#### Show Unit Settings
62
+ function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl,$nxs_snapThisPageUrl; $nt = $options['ntInfo']['lcode']; $ntU = strtoupper($nt);
63
+ 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'] = '';
64
+ if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; if (!isset($options['trMsgTFormat'])) $options['trMsgTFormat'] = ''; ?>
65
  <div id="doTR<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>" style="background-image: url(<?php echo $nxs_plurl; ?>img/tr-bg.png); background-position:90% 10%;"> <input type="hidden" name="apDoSTR<?php echo $ii; ?>" value="0" id="apDoSTR<?php echo $ii; ?>" />
66
  <?php if ($isNew) { ?> <input type="hidden" name="tr[<?php echo $ii; ?>][apDoTR]" value="1" id="apDoNewTR<?php echo $ii; ?>" /> <?php } ?>
67
 
68
  <div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/tr16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-tumblr-social-networks-auto-poster-wordpress/"><?php $nType="Tumblr"; printf( __( 'Detailed %s Installation/Configuration Instructions' , 'nxs_snap'), $nType); ?></a></div>
69
 
70
+ <div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'nxs_snap'); ?></i> </div><input name="tr[<?php echo $ii; ?>][nName]" id="trnName<?php echo $ii; ?>" style="font-weight: bold; color: #005800; border: 1px solid #ACACAC; width: 40%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['nName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /><br/>
71
+ <?php echo nxs_addQTranslSel('tr', $ii, $options['qTLng']); ?>
72
 
73
+ <br/>
74
+ <ul class="nsx_tabs">
75
+ <li><a href="#nsx<?php echo $nt.$ii ?>_tab1"><?php _e('Account Info', 'nxs_snap'); ?></a></li>
76
+ <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'nxs_snap'); ?></a></li>
77
+ </ul>
78
+ <div class="nsx_tab_container"><?php /* ######################## Account Tab ####################### */ ?>
79
+ <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%;">
80
+
81
+
82
 
83
  <div style="width:100%;"><strong>Tumblr URL:</strong> <i>It should be your public URL. (i.e. like <b>http://nextscripts.tumblr.com/</b>, not http://www.tumblr.com/blog/nextscripts</i> </div><input onchange="nxsTRURLVal(<?php echo $ii; ?>);" name="tr[<?php echo $ii; ?>][apTRURL]" id="apTRURL<?php echo $ii; ?>" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['trURL'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /><span style="color: #F00000;" id="apTRURLerr<?php echo $ii; ?>"></span>
84
  <div style="width:100%;"><strong>Tumblr OAuth Consumer Key:</strong> </div><input name="tr[<?php echo $ii; ?>][apTRConsKey]" id="apTRConsKey" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['trConsKey'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
143
 
144
 
145
  <?php if( isset($options['trOAuthTokenSecret']) && $options['trOAuthTokenSecret']!='') { ?>
146
+
147
  <br/><br/><b><?php _e('Test your settings', 'nxs_snap'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('TR', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s' , 'nxs_snap'), $nType); ?></a> <br/><br/>
148
  <?php }?>
149
+
150
+ </div>
151
+ <?php /* ######################## Advanced Tab ####################### */ ?>
152
+ <div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content">
153
+
154
+ <?php if (!$isNew) { ?> <div class="nxs_tls_cpt"><?php _e('Categories', 'nxs_snap'); ?></div>
155
+ <div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
156
+ <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
157
+ <input value="1" id="catSelS<?php echo $ntU; ?><?php echo $ii; ?>" type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_<?php echo $ntU; ?><?php echo $ii; ?>" onclick="jQuery('#catSelS<?php echo $ntU; ?><?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('<?php echo $ntU; ?><?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($options['catSelEd']!='') echo "[".(substr_count($options['catSelEd'], ",")+1)."]"; ?></a>
158
+ <input type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
159
+ <br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
160
+ <br/>
161
+ <?php } ?>
162
+
163
+ <?php nxs_addPostingDelaySelV3($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']); ?>
164
+ <?php nxs_showRepostSettings($nt, $ii, $options); ?>
165
+
166
+
167
+ </div> <?php /* #### End of Tab #### */ ?>
168
+ </div><br/> <?php /* #### End of Tabs #### */ ?>
169
+
170
+ <div class="submit clear" style="padding-bottom: 0px;"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div>
171
 
172
  </div>
173
  <?php
200
 
201
  if (isset($pval['apTRDefImg'])) $options[$ii]['trDefImg'] = trim($pval['apTRDefImg']);
202
 
203
+ $options[$ii] = nxs_adjRpst($options[$ii], $pval);
204
+
205
+ if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']);
206
  if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
207
  if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
208
  } // prr($options);
209
  } return $options;
210
  }
211
  //#### Show Post->Edit Meta Box Settings
212
+ function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID; $nt = 'tr'; $ntU = 'TR';
213
+ foreach($ntOpts as $ii=>$options) {$pMeta = maybe_unserialize(get_post_meta($post_id, 'snapTR', true)); // prr($ntOpts); echo "~~~~~~~~~~~~~~~~"; prr($pMeta); echo "#######";
214
+ if (is_array($pMeta) && isset($pMeta[$ii]) && is_array($pMeta[$ii])) $options = $this->adjMetaOpt($options, $pMeta[$ii]);
215
+ if (empty($options['imgToUse'])) $options['imgToUse'] = ''; if (empty($options['urlToUse'])) $options['urlToUse'] = ''; if (empty($options['trMsgTFormat'])) $options['trMsgTFormat'] = '';
216
+ $doTR = $options['doTR'] && (is_array($pMeta) || (is_array($pMeta) || $options['catSel']!='1')); $imgToUse = $options['imgToUse']; $urlToUse = $options['urlToUse'];
217
  $isAvailTR = isset($options['trAccessTocken']) && isset($options['trAccessTocken']['oauth_token_secret']) && $options['trAccessTocken']['oauth_token_secret']!=='';
218
  $trMsgFormat = htmlentities($options['trMsgFormat'], ENT_COMPAT, "UTF-8"); $trMsgTFormat = htmlentities($options['trMsgTFormat'], ENT_COMPAT, "UTF-8");
219
  ?>
223
  <?php if ($post->post_status == "publish") { ?> <input type="hidden" name="tr[<?php echo $ii; ?>][doTR]" value="<?php echo $doTR;?>"> <?php } ?> <?php } ?>
224
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/tr16.png);">Tumblr - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $options['nName']; ?></i>) </div></th><td><?php //## Only show RePost button if the post is "published"
225
  if ($post->post_status == "publish" && $isAvailTR) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;"Z type="button" class="button" name="rePostToTR_repostButton" id="rePostToTR_button" value="<?php _e('Repost to Tumblr', 'nxs_snap') ?>" />
226
+ <?php } ?>
227
 
228
+ <?php if (is_array($pMeta) && isset($pMeta[$ii]) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
229
  ?> <span id="pstdTR<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
230
  <a style="font-size: 10px;" href="<?php echo $options['trURL']; ?>post/<?php echo $pMeta[$ii]['pgID']; ?>" target="_blank"><?php $nType="Tumblr"; printf( __( 'Posted on', 'nxs_snap' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
231
  </span><?php } ?>
232
 
233
  </td></tr>
234
  <?php if (!$isAvailTR) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup and authorize your Tumblr Account to AutoPost to Tumblr</b>
235
+ <?php } else { if ($post->post_status != "publish" && function_exists('nxs_doSMAS5') ) { nxs_doSMAS5($nt, $ii, $options); } ?>
236
+
237
+ <?php if ($options['rpstOn']=='1') { ?>
238
+
239
+ <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top:6px; text-align:right; width:60px; padding-right:10px;">
240
+ <input value="0" type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]"/><input value="nxsi<?php echo $ii; ?>tr" type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]" <?php if (!empty($ntOpt['rpstPostIncl'])) echo "checked"; ?> />
241
+ </th>
242
+ <td> <?php _e('Include in "Auto-Reposting" to this network.', 'nxs_snap') ?>
243
+ </td></tr> <?php } ?>
244
 
245
  <tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;">
246
  <input type="radio" name="tr[<?php echo $ii; ?>][apTRPostType]" value="T" <?php if ($options['trPostType'] != 'I') echo 'checked="checked"'; ?> /> <br/>
260
  <td>
261
  <textarea cols="150" rows="1" id="tr<?php echo $ii; ?>SNAPformat" name="tr[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('#tr<?php echo $ii; ?>SNAPformat').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apTRMsgFrmt<?php echo $ii; ?>');"><?php echo $trMsgFormat; ?></textarea>
262
  <?php nxs_doShowHint("apTRMsgFrmt".$ii); ?></td></tr>
263
+
264
+ <?php /* ## Select Image & URL ## */ nxs_showImgToUseDlg($nt, $ii, $imgToUse); nxs_showURLToUseDlg($nt, $ii, $urlToUse); ?>
265
 
266
  <?php }
267
  }
269
  }
270
 
271
  function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
272
+ if (isset($pMeta['SNAPformat'])) $optMt['trMsgFormat'] = $pMeta['SNAPformat']; if (isset($pMeta['SNAPTformat'])) $optMt['trMsgTFormat'] = $pMeta['SNAPTformat'];
273
+ if (isset($pMeta['imgToUse'])) $optMt['imgToUse'] = $pMeta['imgToUse']; if (isset($pMeta['urlToUse'])) $optMt['urlToUse'] = $pMeta['urlToUse'];
274
+ if (isset($pMeta['timeToRun'])) $optMt['timeToRun'] = $pMeta['timeToRun']; if (isset($pMeta['rpstPostIncl'])) $optMt['rpstPostIncl'] = $pMeta['rpstPostIncl'];
275
  if (isset($pMeta['apTRPostType'])) $optMt['trPostType'] = $pMeta['apTRPostType'];
276
  if (isset($pMeta['AttachPost'])) $optMt['trAttch'] = $pMeta['AttachPost'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['trAttch'] = 0; }
277
  if (isset($pMeta['doTR'])) $optMt['doTR'] = $pMeta['doTR'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doTR'] = 0; }
280
  }
281
  }}
282
 
283
+ if (!function_exists("nxs_rePostToTR_ajax")) { function nxs_rePostToTR_ajax() { check_ajax_referer('nxsSsPageWPN'); $postID = $_POST['id'];
284
  $options = get_option('NS_SNAutoPoster'); foreach ($options['tr'] as $ii=>$po) if ($ii==$_POST['nid']) { $po['ii'] = $ii; $po['pType'] = 'aj';
285
  $mpo = get_post_meta($postID, 'snapTR', true); $mpo = maybe_unserialize($mpo);
286
  if (is_array($mpo) && isset($mpo[$ii]) && is_array($mpo[$ii]) ){ $ntClInst = new nxs_snapClassTR(); $po = $ntClInst->adjMetaOpt($po, $mpo[$ii]); }
290
  }
291
 
292
  if (!function_exists("nxs_doPublishToTR")) { //## Second Function to Post to TR
293
+ function nxs_doPublishToTR($postID, $options){ $ntCd = 'TR'; $ntCdL = 'tr'; $ntNm = 'Tumblr'; global $plgn_NS_SNAutoPoster; $ytUrl = ''; $imgURL = '';
294
+ if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
295
+ //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToTR', array($postID, $options));
296
+ if (empty($options['imgToUse'])) $options['imgToUse'] = ''; if (empty($options['urlToUse'])) $options['urlToUse'] = ''; if (empty($options['trMsgTFormat'])) $options['trMsgTFormat'] = '';
297
+ $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'POSTID'=>$postID, 'ACCNAME'=>$options['nName']));
298
+ if (empty($options['imgToUse'])) $options['imgToUse'] = ''; if (empty($options['imgSize'])) $options['imgSize'] = '';
299
  $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url();
300
  $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
301
  $logNT = '<span style="color:#014A76">Tumblr</span> - '.$options['nName'];
306
  }
307
  }
308
  //## Format
309
+ if ($postID=='0') { echo "Testing ... <br/><br/>"; $options['trMsgFormat'] = 'Test Post from '.$blogTitle; $msgT = 'Test Post from '.$blogTitle; $options['trPostType']=='T';}
310
+ else{ $post = get_post($postID); if(!$post) return; $options['trMsgFormat'] = nsFormatMessage($options['trMsgFormat'], $postID, $addParams);
311
+ $options['trMsgTFormat'] = nsFormatMessage($options['trMsgTFormat'], $postID, $addParams); nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
312
+
313
+ $tggs = array();
314
+ if ($options['trInclTags']=='1'){ $t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = implode(',', $tggs); }
315
+ if ($options['trInclCats']=='1'){ $t = wp_get_post_categories($postID); foreach($t as $c){ $cat = get_category($c); $tggs[] = $cat->name; } $tags = implode(',', $tggs); }
316
+ $postDate = ($post->post_date_gmt!='0000-00-00 00:00:00'?$post->post_date_gmt:gmdate("Y-m-d H:i:s", strtotime($post->post_date)))." GMT"; //## Adds date to Tumblr post. Thanks to Kenneth Lecky
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
317
 
318
+ if($options['trPostType']=='V') { $vids = nsFindVidsInPost($post); if (count($vids)>0) $ytUrl = $vids[0]; if (trim($ytUrl)=='') $options['trPostType']='T'; }
319
+ if($options['trPostType']=='U') { $aud = nsFindAudioInPost($post); if (count($aud)>0) $aUrl = $aud[0]; if (trim($aUrl)=='') $options['trPostType']='T'; }
320
+ if($options['trPostType']=='I') { if (trim($options['imgToUse'])!='') $imgURL = $options['imgToUse']; else $imgURL = nxs_getPostImage($postID, 'large', $options['trDefImg']);
321
+ if (preg_match("/noImg.\.png/i", $imgURL)) $imgURL = ''; if (trim($imgURL)=='') $options['trPostType']='T';
322
+ }
323
+ //## MyURL - URLToGo code
324
+ if (!isset($options['urlToUse']) || trim($options['urlToUse'])=='') $myurl = trim(get_post_meta($postID, 'snap_MYURL', true)); if ($myurl!='') $options['urlToUse'] = $myurl;
325
+ if (isset($options['urlToUse']) && trim($options['urlToUse'])!='') { $urlToGo = $options['urlToUse']; $options['useFBGURLInfo'] = true; } else $urlToGo = get_permalink($postID);
326
+ $gOptions = $plgn_NS_SNAutoPoster->nxs_options; $addURLParams = trim($gOptions['addURLParams']); if($addURLParams!='') $urlToGo .= (strpos($urlToGo,'?')!==false?'&':'?').$addURLParams;
327
+
328
+ }
329
+ $extInfo = ' | PostID: '.$postID." - ".(isset($post) && is_object($post)?$post->post_title:'').' |'.$options['pType'];
330
+ $options['trURL'] = trim(str_ireplace('http://', '', $options['trURL'])); if (substr($options['trURL'],-1)=='/') $options['trURL'] = substr($options['trURL'], 0, -1);
331
+ //## Post
332
+ $message = array('siteName'=>$blogTitle, 'imageURL'=>$imgURL, 'tags'=>$tags, 'url'=>$urlToGo, 'postDate'=>$postDate, 'videoURL'=>$ytUrl); // prr($message); prr($options); die();
333
+ //## Actual Post
334
+ $ntToPost = new nxs_class_SNAP_TR(); $ret = $ntToPost->doPostToNT($options, $message);
335
+ //## Process Results
336
+ if (!is_array($ret) || $ret['isPosted']!='1') { //## Error
337
+ if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);
338
+ } else { // ## All Good - log it.
339
+ if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo _e('OK - Message Posted, please see your '.$logNT.' Page. ', 'nxs_snap'); }
340
+ 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); }
341
+ } //prr($ret);
342
+ //## Return Result
343
+ if ($ret['isPosted']=='1') return 200; else return print_r($ret, true);
344
  }
345
  }
346
 
inc-cl/tw.api.php CHANGED
@@ -17,13 +17,10 @@ if (!class_exists("nxs_class_SNAP_TW")) { class nxs_class_SNAP_TW {
17
  if (!isset($options['twAccToken']) || trim($options['twAccToken'])=='') { $badOut['Error'] = 'No Auth Token Found'; return $badOut; }
18
  //## Old Settings Fix
19
  if ($options['attchImg']=='1') $options['attchImg'] = 'large'; if ($options['attchImg']=='0') $options['attchImg'] = false;
20
- if (isset($message['img'])) $img = trim($message['img']); else $img = ''; // prr($message);
21
  //## Format Post
22
- $msg = nxs_doFormatMsg($options['twMsgFormat'], $message); if ($options['attchImg']!=false) { $imgURL = trim($message['imgURL'][$options['attchImg']]);
23
- if ($imgURL=='') $imgURL = trim($message['imgURL']['large']); if ($imgURL=='') $imgURL = trim($message['imgURL']['medium']);
24
- if ($imgURL=='') $imgURL = trim($message['imgURL']['original']); if ($imgURL=='') $imgURL = trim($message['imgURL']['thumb']);
25
- }
26
- if ($imgURL=='' && $img=='') $options['attchImg'] = false;
27
  //## Make Post
28
  //$msg = $message['message']; $imgURL = trim($message['imageURL']); $img = trim($message['img']); $nxs_urlLen = $message['urlLength'];
29
  if ($options['attchImg']!=false && $img=='' && $imgURL!='' ) {
@@ -32,10 +29,10 @@ if (!class_exists("nxs_class_SNAP_TW")) { class nxs_class_SNAP_TW {
32
  }
33
  if ($options['attchImg']!=false && $img!='') $twLim = 118; else $twLim = 140;
34
 
35
- require_once ('apis/tmhOAuth.php'); if ($nxs_urlLen>0) { $msg = nsTrnc($msg, $twLim-22+$nxs_urlLen); } else $msg = nsTrnc($msg, $twLim);
36
  $tmhOAuth = new NXS_tmhOAuth(array( 'consumer_key' => $options['twConsKey'], 'consumer_secret' => $options['twConsSec'], 'user_token' => $options['twAccToken'], 'user_secret' => $options['twAccTokenSec']));
37
  if ($options['attchImg']!=false && $img!='') $code = $tmhOAuth -> request('POST', 'http://api.twitter.com/1.1/statuses/update_with_media.json', array( 'media[]' => $img, 'status' => $msg), true, true);
38
- else $code = $tmhOAuth->request('POST', $tmhOAuth->url('1.1/statuses/update'), array('status' =>$msg));
39
  if ( $code=='403' && stripos($tmhOAuth->response['response'], 'User is over daily photo limit')!==false && $options['attchImg']!=false && $img!='') {
40
  $badOut['Error'] .= "User is over daily photo limit. Will post without image\r\n"; $code = $tmhOAuth->request('POST', $tmhOAuth->url('1.1/statuses/update'), array('status' =>$msg));
41
  }
17
  if (!isset($options['twAccToken']) || trim($options['twAccToken'])=='') { $badOut['Error'] = 'No Auth Token Found'; return $badOut; }
18
  //## Old Settings Fix
19
  if ($options['attchImg']=='1') $options['attchImg'] = 'large'; if ($options['attchImg']=='0') $options['attchImg'] = false;
20
+ if (isset($message['img']) && !is_array($message['img']) ) $img = trim($message['img']); else $img = '';
21
  //## Format Post
22
+ $msg = nxs_doFormatMsg($options['twMsgFormat'], $message); if ($options['attchImg']!=false) { if (isset($message['imageURL'])) $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); else $imgURL = ''; }
23
+ if (empty($imgURL) && $img=='') $options['attchImg'] = false;
 
 
 
24
  //## Make Post
25
  //$msg = $message['message']; $imgURL = trim($message['imageURL']); $img = trim($message['img']); $nxs_urlLen = $message['urlLength'];
26
  if ($options['attchImg']!=false && $img=='' && $imgURL!='' ) {
29
  }
30
  if ($options['attchImg']!=false && $img!='') $twLim = 118; else $twLim = 140;
31
 
32
+ require_once ('apis/tmhOAuth.php'); if ($nxs_urlLen>0) { $msg = nsTrnc($msg, $twLim-22+$nxs_urlLen); } else $msg = nsTrnc($msg, $twLim); if (substr($msg, 0, 1)=='@') $msg = ' '.$msg;
33
  $tmhOAuth = new NXS_tmhOAuth(array( 'consumer_key' => $options['twConsKey'], 'consumer_secret' => $options['twConsSec'], 'user_token' => $options['twAccToken'], 'user_secret' => $options['twAccTokenSec']));
34
  if ($options['attchImg']!=false && $img!='') $code = $tmhOAuth -> request('POST', 'http://api.twitter.com/1.1/statuses/update_with_media.json', array( 'media[]' => $img, 'status' => $msg), true, true);
35
+ else $code = $tmhOAuth->request('POST', $tmhOAuth->url('1.1/statuses/update'), array('status' =>$msg));
36
  if ( $code=='403' && stripos($tmhOAuth->response['response'], 'User is over daily photo limit')!==false && $options['attchImg']!=false && $img!='') {
37
  $badOut['Error'] .= "User is over daily photo limit. Will post without image\r\n"; $code = $tmhOAuth->request('POST', $tmhOAuth->url('1.1/statuses/update'), array('status' =>$msg));
38
  }
inc-cl/tw.php CHANGED
@@ -8,81 +8,102 @@ if (!class_exists("nxs_snapClassTW")) { class nxs_snapClassTW {
8
  <div class="nxs_box">
9
  <div class="nxs_box_header">
10
  <div class="nsx_iconedTitle" style="margin-bottom:1px;background-image:url(<?php echo $nxs_plurl;?>img/<?php echo $ntInfo['lcode']; ?>16.png);"><?php echo $ntInfo['name']; ?>
11
- <?php $cbo = count($ntOpts); ?> <?php wp_nonce_field( 'ns'.$ntInfo['code'], 'ns'.$ntInfo['code'].'_wpnonce' ); ?>
12
  <?php if ($cbo>1){ ?><div class="nsBigText"><?php echo "(".($cbo=='0'?'No':$cbo)." "; _e('accounts', 'nxs_snap'); echo ")"; ?></div><?php } ?>
13
  </div>
14
  </div>
15
  <div class="nxs_box_inside">
16
  <?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = str_ireplace('https://','', str_ireplace('http://','', $pbo['twURL'])); ?>
17
  <p style="margin:0px;margin-left:5px;">
18
- <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> /> <?php if ((int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
 
 
19
  <strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
20
  &nbsp;&nbsp;<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention required. Unfinished setup', 'nxs_snap'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>&nbsp;&nbsp;
21
  <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
22
- </p><?php $this->showNTSettings($indx, $pbo);
23
  }?>
24
  </div>
25
  </div> <?php
26
  }
27
  //#### Show NEW Settings Page
28
- function showNewNTSettings($mtwo){ $two = array('nName'=>'', 'doTW'=>'1', 'twURL'=>'', 'twConsKey'=>'', 'twConsSec'=>'', 'twAccToken'=>'', 'twAccTokenSec'=>'', 'attchImg'=>0, 'twAttch'=>'', 'twAccTokenSec'=>''); $this->showNTSettings($mtwo, $two, true);}
 
29
  //#### Show Unit Settings
30
- function showNTSettings($ii, $two, $isNew=false){ global $nxs_plurl, $plgn_NS_SNAutoPoster;
31
  if (!isset($plgn_NS_SNAutoPoster)) return; $gOptions = $plgn_NS_SNAutoPoster->nxs_options;
32
- if (!isset($two['nHrs'])) $two['nHrs'] = 0; if (!isset($two['nMin'])) $two['nMin'] = 0; if (!isset($two['catSel'])) $two['catSel'] = 0; if (!isset($two['catSelEd'])) $two['catSelEd'] = '';
33
- if (!isset($two['nDays'])) $two['nDays'] = 0; if (!isset($two['qTLng'])) $two['qTLng'] = ''; ?>
 
34
 
35
- <div id="doTW<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>" style="background-image: url(<?php echo $nxs_plurl; ?>img/tw-bg.png); background-position:90% 10%;"> <input type="hidden" name="apDoSTW<?php echo $ii; ?>" value="0" id="apDoSTW<?php echo $ii; ?>" />
36
 
37
  <div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/tw16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-twitter-social-networks-auto-poster-wordpress/"><?php $nType="Twitter"; printf( __( 'Detailed %s Installation/Configuration Instructions', 'nxs_snap' ), $nType); ?></a></div>
38
 
39
- <div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easely identify it', 'nxs_snap'); ?></i> </div><input name="tw[<?php echo $ii; ?>][nName]" id="twnName<?php echo $ii; ?>" style="font-weight: bold; color: #005800; border: 1px solid #ACACAC; width: 40%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($two['nName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /><br/>
40
- <?php echo nxs_addQTranslSel('tw', $ii, $two['qTLng']); ?><?php echo nxs_addPostingDelaySel('tw', $ii, $two['nHrs'], $two['nMin'], $two['nDays']); ?>
41
-
42
- <?php if (!$isNew) { ?>
43
- <div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
44
- <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="tw[<?php echo $ii; ?>][catSel]" <?php if ((int)$two['catSel'] != 1) echo "checked"; ?> /> All
45
- <input value="1" id="catSelSTW<?php echo $ii; ?>" type="radio" name="tw[<?php echo $ii; ?>][catSel]" <?php if ((int)$two['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_TW<?php echo $ii; ?>" onclick="jQuery('#catSelSTW<?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('TW<?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_TW<?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($two['catSelEd']!='') echo "[".(substr_count($two['catSelEd'], ",")+1)."]"; ?></a>
46
- <input type="hidden" name="tw[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_TW<?php echo $ii; ?>" value="<?php echo $two['catSelEd']; ?>" />
47
- <br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
48
  <br/>
49
- <?php } ?>
 
 
 
 
 
50
 
51
- <div style="width:100%;"><strong>Your Twitter URL:</strong> </div><input name="tw[<?php echo $ii; ?>][apTWURL]" id="apTWURL" style="width: 40%;border: 1px solid #ACACAC;" value="<?php _e(apply_filters('format_to_edit', htmlentities($two['twURL'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
52
- <div style="width:100%;"><strong>Your Twitter Consumer Key:</strong> </div><input name="tw[<?php echo $ii; ?>][apTWConsKey]" id="apTWConsKey" style="width: 40%; border: 1px solid #ACACAC;" value="<?php _e(apply_filters('format_to_edit', htmlentities($two['twConsKey'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
53
- <div style="width:100%;"><strong>Your Twitter Consumer Secret:</strong> </div><input name="tw[<?php echo $ii; ?>][apTWConsSec]" id="apTWConsSec" style="width: 40%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($two['twConsSec'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
54
- <div style="width:100%;"><strong>Your Access Token:</strong> </div><input name="tw[<?php echo $ii; ?>][apTWAccToken]" id="apTWAccToken" style="width: 40%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($two['twAccToken'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
55
- <div style="width:100%;"><strong>Your Access Token Secret:</strong> </div><input name="tw[<?php echo $ii; ?>][apTWAccTokenSec]" id="apTWAccTokenSec" style="width: 40%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($two['twAccTokenSec'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
56
  <?php if ($isNew) { ?> <input type="hidden" name="tw[<?php echo $ii; ?>][apDoTW]" value="1" id="apDoNewTW<?php echo $ii; ?>" /> <?php } ?>
57
  <br/><br/>
58
- <p style="margin: 0px;"><input value="1" id="apLIAttch" type="checkbox" name="tw[<?php echo $ii; ?>][attchImg]" <?php if ((int)$two['attchImg'] == 1) echo "checked"; ?> /> <strong><?php _e('Attach Image to Twitter Post', 'nxs_snap'); ?></strong></p>
59
  <br/>
60
  <strong id="altFormatText"><?php _e('Message text Format', 'nxs_snap'); ?>:</strong>
61
- <input name="tw[<?php echo $ii; ?>][apTWMsgFrmt]" id="apTWMsgFrmt" style="width: 50%;" value="<?php if (!$isNew) _e(apply_filters('format_to_edit', htmlentities($two['twMsgFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap'); else echo "%TITLE% - %URL%"; ?>" onfocus="mxs_showFrmtInfo('apTWMsgFrmt<?php echo $ii; ?>');" />
62
 
63
  <?php nxs_doShowHint("apTWMsgFrmt".$ii, '<br/><br/><b>%TAGS% and %CATS% will be posted as hashtags. <br/>Please remember that Twitter takes only 140 characters.</b>'); ?>
64
 
65
- <br/><br/>
66
- <div style="width:100%;"><strong style="font-size: 16px;"><?php _e('Twitter Replies and Mentions:', 'nxs_snap'); ?></strong> </div>
67
- <div style="margin-bottom: 5px; margin-left: 10px; ">
68
- <p style="font-size: 11px; margin: 0px;"><?php _e('Plugin could grab Replies and Mentions from Twitter and import them as Wordpress Comments', 'nxs_snap'); ?></p>
69
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  <?php if ( $gOptions['riActive'] == '1' ) { ?>
71
- <input value="1" id="riC<?php echo $ii; ?>" <?php if (trim($two['riComments'])=='1') echo "checked"; ?> type="checkbox" name="tw[<?php echo $ii; ?>][riComments]"/> <strong><?php _e('Import Twitter Replies', 'nxs_snap'); ?></strong>
72
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
73
- <input value="1" id="riCM<?php echo $ii; ?>" <?php if (trim($two['riCommentsM'])=='1') echo "checked"; ?> type="checkbox" name="tw[<?php echo $ii; ?>][riCommentsM]"/> <strong><?php _e('Import Twitter Mentions', 'nxs_snap'); ?></strong>
74
  <br/>
75
- <div style="margin-bottom: 5px; margin-left: 10px; ">
76
- <input value="1" id="riCA<?php echo $ii; ?>" <?php if (trim($two['riCommentsAA'])=='1') echo "checked"; ?> type="checkbox" name="tw[<?php echo $ii; ?>][riCommentsAA]"/> <strong><?php _e('Auto-approve imported comments', 'nxs_snap'); ?></strong></div>
 
 
 
77
 
78
- <?php } else { echo "<br/>"; _e('Please activate the "Comments Import" from SNAP Settings - Other Settings', 'nxs_snap'); } ?>
79
 
80
- </div>
81
-
82
- <?php if($two['twAccTokenSec']!='') { ?> <?php wp_nonce_field( 'rePostToTW', 'rePostToTW_wpnonce' ); ?>
83
- <br/><br/><b><?php _e('Test your settings', 'nxs_snap'); ?>:</b>&nbsp;&nbsp;&nbsp; <?php if (!isset($two['twOK']) || $two['twOK']!='1') { ?> <div class="blnkg">=== Submit Test Post to Complete ===&gt;</div> <?php } ?> <a href="#" class="NXSButton" onclick="testPost('TW', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s' , 'nxs_snap'), $nType); ?></a> <br/>
84
- <?php }?>
85
- <div class="submit"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div>
86
  </div>
87
  <?php
88
  }
@@ -98,45 +119,55 @@ if (!class_exists("nxs_snapClassTW")) { class nxs_snapClassTW {
98
  if (isset($pval['apTWAccToken'])) $options[$ii]['twAccToken'] = trim($pval['apTWAccToken']);
99
 
100
  if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']);
101
- if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
102
 
103
  if (isset($pval['riComments'])) $options[$ii]['riComments'] = $pval['riComments']; else $options[$ii]['riComments'] = 0;
104
- if (isset($pval['riCommentsM'])) $options[$ii]['riCommentsM'] = $pval['riCommentsM']; else $options[$ii]['riCommentsM'] = 0;
105
  if (isset($pval['riCommentsAA'])) $options[$ii]['riCommentsAA'] = $pval['riCommentsAA']; else $options[$ii]['riCommentsAA'] = 0;
106
 
 
 
107
  if (isset($pval['apTWAccTokenSec']))$options[$ii]['twAccTokenSec'] = trim($pval['apTWAccTokenSec']);
108
  if (isset($pval['apTWMsgFrmt'])) $options[$ii]['twMsgFormat'] = trim($pval['apTWMsgFrmt']);
109
- if (isset($pval['attchImg'])) $options[$ii]['attchImg'] = $pval['attchImg']; else $options[$ii]['attchImg'] = 0;
110
- if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']);
111
- if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
112
  if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
113
  }
114
  } return $options;
115
  }
116
  //#### Show Post->Edit Meta Box Settings
117
- function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
118
- foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapTW', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
119
- $doTW = $ntOpt['doTW'] && (is_array($pMeta) || $ntOpt['catSel']!='1');
 
120
  $isAvailTW = $ntOpt['twURL']!='' && $ntOpt['twConsKey']!='' && $ntOpt['twConsSec']!='' && $ntOpt['twAccToken']!=''; $twMsgFormat = htmlentities($ntOpt['twMsgFormat'], ENT_COMPAT, "UTF-8"); $isAttchImg = $ntOpt['attchImg'];
121
  ?>
122
  <tr><th style="text-align:left;" colspan="2"><?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_TW<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
123
  <?php if ($isAvailTW) { ?><input class="nxsGrpDoChb" value="1" id="doTW<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="tw[<?php echo $ii; ?>][doTW]" <?php if ((int)$doTW == 1) echo 'checked="checked" title="def"'; ?> />
124
  <?php if ($post->post_status == "publish") { ?> <input type="hidden" name="tw[<?php echo $ii; ?>][doTW]" value="<?php echo $doTW;?>"> <?php } ?> <?php } ?>
125
- <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/tw16.png);">Twitter - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th><td><?php //## Only show RePost button if the post is "published"
 
126
  if ($post->post_status == "publish" && $isAvailTW) { ?>
127
  <input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToTW_repostButton" id="rePostToTW_button" value="<?php _e('Repost to Twitter', 'nxs_snap') ?>" />
128
 
129
- <?php if ($ntOpt['riComments']=='1' && (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) && $pMeta[$ii]['pgID']!='' ) ) { ?>
130
  <input alt="<?php echo $ii; ?>" style="float: right; " onclick="return false;" type="button" class="button" name="riToTW_repostButton" id="riToTW_button" value="<?php _e('Import Replies/Mentions from Twitter', 'nxs_snap') ?>" />
131
- <?php } ?>
132
-
133
- <?php wp_nonce_field( 'rePostToTW', 'rePostToTW_wpnonce' ); } ?>
134
- <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID'])) { ?> <span style="float: right;padding-top: 4px; padding-right: 10px;">
135
  <a id="pstdTW<?php echo $ii; ?>" style="font-size: 10px;" href="<?php echo $ntOpt['twURL'].'/status/'.$pMeta[$ii]['pgID']; ?>" target="_blank"><?php $nType="Twitter"; printf( __( 'Posted on', 'nxs_snap' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
136
  </span><?php } ?>
137
  </td></tr>
 
138
  <?php if (!$isAvailTW) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your Twitter Account to AutoPost to Twitter</b>
139
- <?php }elseif ($post->post_status != "puZblish") { ?>
 
 
 
 
 
 
 
 
140
 
141
  <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top:6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Message Format:', 'nxs_snap') ?></th>
142
  <td><input value="<?php echo $twMsgFormat ?>" type="text" name="tw[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apTWMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apTWMsgFrmt".$ii); ?></td></tr>
@@ -144,12 +175,17 @@ if (!class_exists("nxs_snapClassTW")) { class nxs_snapClassTW {
144
  <tr><th scope="row" style="text-align:right; width:150px; vertical-align:top; padding-top: 5px; padding-right:10px;">
145
  <input value="0" type="hidden" name="tw[<?php echo $ii; ?>][attchImg]"/>
146
  <input value="1" type="checkbox" name="tw[<?php echo $ii; ?>][attchImg]" <?php if ((int)$isAttchImg == 1) echo "checked"; ?> /> </th><td><strong>Attach Image to Twitter Post</strong></td> </tr>
 
 
 
147
  <?php }
148
  }
149
  }
150
  //####
151
- function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
152
- if (isset($pMeta['SNAPformat'])) $optMt['twMsgFormat'] = $pMeta['SNAPformat'];
 
 
153
  if (isset($pMeta['attchImg'])) $optMt['attchImg'] = $pMeta['attchImg'] == 1?1:0; else { if (isset($pMeta['attchImg'])) $optMt['attchImg'] = 0; }
154
  if (isset($pMeta['doTW'])) $optMt['doTW'] = $pMeta['doTW'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doTW'] = 0; }
155
  if (isset($pMeta['SNAPincludeTW']) && $pMeta['SNAPincludeTW'] == '1' ) $optMt['doTW'] = 1; // <2.6 Compatibility fix
@@ -164,7 +200,7 @@ if (!function_exists("nxs_getBackTWCommentsList")) { function nxs_getBackTWComme
164
  }}
165
 
166
  if (!function_exists("nxs_getBackTWComments")) { function nxs_getBackTWComments($postID, $options, $po, $twList) { $impCmnts = get_post_meta($postID, 'snapImportedComments', true);
167
- if(!is_array($impCmnts)) $impCmnts = array(); $twsToImp = array();
168
  //## Do Replies
169
  foreach ($twList as $tw) if ($tw['in_reply_to_status_id_str'] == $po['pgID']) $twsToImp[] = $tw;
170
  if (is_array($twsToImp) && count($twsToImp)>0)
@@ -173,7 +209,8 @@ if (!function_exists("nxs_getBackTWComments")) { function nxs_getBackTWComments(
173
  'comment_author_email' => $comment['user']['screen_name'].'@twitter.com', 'comment_author_url' => 'http://twitter.com/'.$comment['user']['screen_name'],
174
  'comment_content' => str_ireplace('@'.$comment['in_reply_to_screen_name'],'', $comment['text']), 'comment_date_gmt' => date('Y-m-d H:i:s', strtotime( $comment['created_at'] ) ), 'comment_type' => '');
175
  nxs_postNewComment($commentdata, $options['riCommentsAA']=='1'); $ci++;
176
- }
 
177
  //## Do mentions.
178
  require_once ('apis/tmhOAuth.php'); $tmhOAuth = new NXS_tmhOAuth(array( 'consumer_key' => $options['twConsKey'], 'consumer_secret' => $options['twConsSec'], 'user_token' => $options['twAccToken'], 'user_secret' => $options['twAccTokenSec']));
179
  if (isset($options['urlToUse']) && trim($options['urlToUse'])!='') $urlToSrch = $options['urlToUse']; else $urlToSrch = get_permalink($postID);
@@ -188,25 +225,27 @@ if (!function_exists("nxs_getBackTWComments")) { function nxs_getBackTWComments(
188
  }
189
  }}
190
  delete_post_meta($postID, 'snapImportedComments'); add_post_meta($postID, 'snapImportedComments', $impCmnts );
191
- if ($_POST['id']!='') printf( _n( '%d comment has been imported.', '%d comments has been imported.', $ci, 'nxs_snap'), $ci );
192
  }}
193
 
194
  if (!function_exists("nxs_rePostToTW_ajax")) {
195
- function nxs_rePostToTW_ajax() { check_ajax_referer('rePostToTW'); $postID = $_POST['id']; $options = get_option('NS_SNAutoPoster');
196
- foreach ($options['tw'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj';
197
  $twpo = get_post_meta($postID, 'snapTW', true); $twpo = maybe_unserialize($twpo);
198
- if (is_array($twpo) && isset($twpo[$ii]) && is_array($twpo[$ii]) && isset($twpo[$ii]['SNAPformat']) ) { $ntClInst = new nxs_snapClassTW(); $two = $ntClInst->adjMetaOpt($two, $twpo[$ii]);}
199
- if ($_POST['ri']=='1') { nxs_getBackTWComments($postID, $two, $twpo[$ii]); die(); } else {
200
- $result = nxs_doPublishToTW($postID, $two); if ($result == 200) {$options['tw'][$ii]['twOK']=1; update_option('NS_SNAutoPoster', $options); } if ($result == 200) die("Successfully sent your post to Twitter."); else die($result);
201
  }
202
  }
203
  }
204
  }
205
 
206
  if (!function_exists("nxs_doPublishToTW")) { //## Second Function to Post to TW
207
- function nxs_doPublishToTW($postID, $options){ $ntCd = 'TW'; $ntCdL = 'tw'; $ntNm = 'Twitter'; $img = ''; $imgURL = ''; global $nxs_urlLen; $nxs_urlLen = 0;
 
208
  //$backtrace = debug_backtrace(); nxs_addToLogN('W', 'Error', $logNT, 'I am here - '.$ntCd."|".print_r($backtrace, true), '');
209
  //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToTW', array($postID, $options));
 
210
  $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'POSTID'=>$postID, 'ACCNAME'=>$options['nName']));
211
  $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
212
  $logNT = '<span style="color:#00FFFF">Twitter</span> - '.$options['nName'];
@@ -216,19 +255,22 @@ if (!function_exists("nxs_doPublishToTW")) { //## Second Function to Post to TW
216
  nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$options['pType']); return;
217
  }
218
  }
219
- $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url(); $uln = 0;
 
220
 
221
- if ($options['attchImg']=='1') { $imgURL = nxs_getPostImage($postID); if(trim($imgURL)=='') $options['attchImg'] = 0; else {
222
- if( ini_get('allow_url_fopen') ) { if (@getimagesize($imgURL)!==false) { $img = wp_remote_get($imgURL);
223
- if(is_wp_error($img)) $options['attchImg'] = 0; else if ($img['headers']['content-length']<200) { $options['attchImg'] = 0; } else $img = $img['body']; } else $options['attchImg'] = 0;
224
- } else { $img = wp_remote_get($imgURL); if(is_wp_error($img)) $options['attchImg'] = 0; elseif (isset($img['body'])&& trim($img['body'])!='') $img = $img['body']; else $options['attchImg'] = 0; }
225
- }
226
- if ($options['attchImg'] == 0) nxs_addToLogN('E', 'Error', $logNT, 'Could not get image, will post without it - Error:'.print_r($img), $extInfo);
 
227
  }
228
  if ($options['attchImg']=='1' && $img!='') $twLim = 117; else $twLim = 140;
229
 
230
  if ($postID=='0') { echo "Testing ... <br/><br/>"; $msg = 'Test Post from '.nsTrnc($blogTitle, $twLim - 24)." - ".rand(1, 155); $uln = nxs_strLen($msg);}
231
- else{ $post = get_post($postID); if(!$post) return; $twMsgFormat = $options['twMsgFormat']; nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
 
232
  if (stripos($twMsgFormat, '%URL%')!==false || stripos($twMsgFormat, '%SURL%')!==false) $twLim = $twLim - 22;
233
  if (stripos($twMsgFormat, '%AUTHORNAME%')!==false) { $aun = $post->post_author; $aun = get_the_author_meta('display_name', $aun ); $twLim = $twLim - nxs_strLen($aun); }
234
 
@@ -236,12 +278,12 @@ if (!function_exists("nxs_doPublishToTW")) { //## Second Function to Post to TW
236
  $noRepl = str_ireplace("%SURL%", "", $noRepl);$noRepl = str_ireplace("%TEXT%", "", $noRepl);$noRepl = str_ireplace("%FULLTEXT%", "", $noRepl);$noRepl = str_ireplace("%EXCERPT%", "", $noRepl);
237
  $noRepl = str_ireplace("%ANNOUNCE%", "", $noRepl); $noRepl = str_ireplace("%AUTHORNAME%", "", $noRepl); $twLim = $twLim - nxs_strLen($noRepl);
238
 
239
- $pTitle = $title = $post->post_title;
240
- if ($post->post_excerpt!="") $exrText = $post->post_excerpt; else $exrText= $post->post_content; $pText = apply_filters('the_content', $exrText);
241
- $pRawText = $post->post_content; $pFullText = apply_filters('the_content', $pRawText);
242
  if (stripos($twMsgFormat, '%TAGS%')!==false || stripos($twMsgFormat, '%HTAGS%')!==false) {
243
  $t = wp_get_object_terms($postID, 'product_tag'); if ( empty($t) || is_wp_error($pt) || !is_array($t) ) $t = wp_get_post_tags($postID);
244
- $tggs = array(); foreach ($t as $tagA) { $frmTag = trim(str_replace(' ','',preg_replace('/[^a-zA-Z0-9\p{L}\p{N}\s]/u', '', trim(ucwords(str_ireplace('&','',str_ireplace('&amp;','',$tagA->name)))))));
245
  if (preg_match('/\b'.$frmTag.'\b/iu', $pTitle)) $pTitle = trim(preg_replace('/\b'.$frmTag.'\b/iu', '#'.$frmTag, $pTitle));
246
  if (preg_match('/\b'.$frmTag.'\b/iu', $pFullText)) $pFullText = trim(preg_replace('/\b'.$frmTag.'\b/iu', '#'.$frmTag, $pFullText));
247
  if (preg_match('/\b'.$frmTag.'\b/iu', $pText)) $pText = trim(preg_replace('/\b'.$frmTag.'\b/iu', '#'.$frmTag, $pText));
@@ -257,7 +299,8 @@ if (!function_exists("nxs_doPublishToTW")) { //## Second Function to Post to TW
257
  $twLim = $twLim - nxs_strLen($tags);
258
  }
259
  if (stripos($twMsgFormat, '%CATS%')!==false || stripos($twMsgFormat, '%HCATS%')!==false) {
260
- $t = wp_get_post_categories($postID); $ctts = array(); foreach($t as $c){ $cat = get_category($c); $frmTag = trim(str_replace(' ','', str_replace(' ',' ',str_ireplace('&','&amp;',trim(ucwords($cat->name))))));
 
261
  if (stripos($pTitle, $cat->name)!==false) $pTitle = str_ireplace($cat->name, '#'.$frmTag, $pTitle); elseif (stripos($pTitle, $frmTag)!==false) $pTitle = str_ireplace($frmTag, '#'.$frmTag, $pTitle);
262
  if (stripos($pText, $cat->name)!==false) $pText = str_ireplace($cat->name, '#'.$frmTag, $pText); elseif (stripos($pText, $frmTag)!==false) $pText = str_ireplace($frmTag, '#'.$frmTag, $pText);
263
  if (stripos($pFullText, $cat->name)!==false) $pFullText = str_ireplace($cat->name, '#'.$frmTag, $pFullText); elseif (stripos($pFullText, $frmTag)!==false) $pFullText = str_ireplace($frmTag, '#'.$frmTag, $pFullText);
@@ -274,7 +317,7 @@ if (!function_exists("nxs_doPublishToTW")) { //## Second Function to Post to TW
274
  }
275
  if (stripos($twMsgFormat, '%TITLE%')!==false) { if (stripos($pTitle, '.co.uk')!==false) $twLim = $twLim - 14;
276
  if (stripos($pTitle, '.com')!==false) $twLim = $twLim - 16; if (stripos($pTitle, '.net')!==false) $twLim = $twLim - 16; if (stripos($pTitle, '.org')!==false) $twLim = $twLim - 16;
277
- $pTitle = html_entity_decode(strip_tags($pTitle), ENT_NOQUOTES, 'UTF-8');
278
  $pTitle = nsTrnc($pTitle, $twLim); $twMsgFormat = str_ireplace("%TITLE%", $pTitle, $twMsgFormat); $twLim = $twLim - nxs_strLen($pTitle);
279
  }
280
  if (stripos($twMsgFormat, '%SITENAME%')!==false) {
@@ -299,7 +342,7 @@ if (!function_exists("nxs_doPublishToTW")) { //## Second Function to Post to TW
299
  $pRawText = nsTrnc(strip_tags($pRawText), $twLim); $twMsgFormat = str_ireplace("%RAWTEXT%", $pRawText, $twMsgFormat); $twLim = $twLim - nxs_strLen($pRawText);
300
  }
301
  $msg = nsFormatMessage($twMsgFormat, $postID, $addParams);
302
- }
303
  $msg = str_replace('&amp;#039;', "'", $msg); $msg = str_replace('&#039;', "'", $msg); $msg = str_replace('#039;', "'", $msg); $msg = str_replace('#039', "'", $msg);
304
  $msg = str_replace('&amp;#8217;', "'", $msg); $msg = str_replace('&#8217;', "'", $msg); $msg = str_replace('#8217;', "'", $msg); $msg = str_replace('#8217', "'", $msg);
305
  $msg = str_replace('&amp;#8220;', '"', $msg); $msg = str_replace('&#8220;', '"', $msg); $msg = str_replace('#8220;', '"', $msg); $msg = str_replace('#8220', "'", $msg);
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', 'nxs_snap'); echo ")"; ?></div><?php } ?>
13
  </div>
14
  </div>
15
  <div class="nxs_box_inside">
16
  <?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = str_ireplace('https://','', str_ireplace('http://','', $pbo['twURL'])); ?>
17
  <p style="margin:0px;margin-left:5px;">
18
+ <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> />
19
+ <?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 } ?>
20
+ <?php if (isset($pbo['rpstOn']) && (int)$pbo['rpstOn'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popReActive');" onmouseover="nxs_showPopUpInfo('popReActive', event);"><?php echo "*[R]*" ?></span><?php } ?>
21
  <strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
22
  &nbsp;&nbsp;<?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')){ ?><b style="color: #800000"><?php _e('Attention required. Unfinished setup', 'nxs_snap'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>&nbsp;&nbsp;
23
  <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
24
+ </p><?php $pbo['ntInfo'] = $ntInfo; $this->showNTSettings($indx, $pbo);
25
  }?>
26
  </div>
27
  </div> <?php
28
  }
29
  //#### Show NEW Settings Page
30
+ function showNewNTSettings($mtwo){ $options = array('nName'=>'', 'doTW'=>'1', 'twURL'=>'', 'twConsKey'=>'', 'twConsSec'=>'', 'twAccToken'=>'', 'twAccTokenSec'=>'', 'attchImg'=>0, 'twAttch'=>'', 'twAccTokenSec'=>'');
31
+ $options['ntInfo']= array('lcode'=>'tw'); $this->showNTSettings($mtwo, $options, true);}
32
  //#### Show Unit Settings
33
+ function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl, $plgn_NS_SNAutoPoster; $nt = $options['ntInfo']['lcode']; $ntU = strtoupper($nt); $tmzFrmt = _x('Y-m-d G:i:s', 'timezone date format');
34
  if (!isset($plgn_NS_SNAutoPoster)) return; $gOptions = $plgn_NS_SNAutoPoster->nxs_options;
35
+ 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'] = '';
36
+ if (!isset($options['riComments'])) $options['riComments'] = ''; if (!isset($options['riCommentsAA'])) $options['riCommentsAA'] = ''; if (!isset($options['riCommentsM'])) $options['riCommentsM'] = '';
37
+ if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; ?>
38
 
39
+ <div id="doTW<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>" > <input type="hidden" name="apDoSTW<?php echo $ii; ?>" value="0" id="apDoSTW<?php echo $ii; ?>" />
40
 
41
  <div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/tw16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-twitter-social-networks-auto-poster-wordpress/"><?php $nType="Twitter"; printf( __( 'Detailed %s Installation/Configuration Instructions', 'nxs_snap' ), $nType); ?></a></div>
42
 
43
+ <div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'nxs_snap'); ?></i> </div><input type="text" name="tw[<?php echo $ii; ?>][nName]" id="twnName<?php echo $ii; ?>" style="font-weight: bold; color: #005800; border: 1px solid #ACACAC; width: 40%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['nName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /><br/>
44
+ <?php echo nxs_addQTranslSel('tw', $ii, $options['qTLng']); ?>
 
 
 
 
 
 
 
45
  <br/>
46
+ <ul class="nsx_tabs">
47
+ <li><a href="#nsx<?php echo $nt.$ii ?>_tab1"><?php _e('Account Info', 'nxs_snap'); ?></a></li>
48
+ <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'nxs_snap'); ?></a></li>
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/tw-bg.png); background-repeat: no-repeat; background-position:90% 10%;">
52
 
53
+ <div class="nxs_tls_lbl"><strong>Your Twitter URL:</strong> </div><input type="text" name="tw[<?php echo $ii; ?>][apTWURL]" id="apTWURL" style="width: 40%;border: 1px solid #ACACAC;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['twURL'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
54
+ <div class="nxs_tls_lbl"><strong>Your Twitter Consumer Key:</strong> </div><input type="text" name="tw[<?php echo $ii; ?>][apTWConsKey]" id="apTWConsKey" style="width: 40%; border: 1px solid #ACACAC;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['twConsKey'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
55
+ <div class="nxs_tls_lbl"><strong>Your Twitter Consumer Secret:</strong> </div><input type="text" name="tw[<?php echo $ii; ?>][apTWConsSec]" id="apTWConsSec" style="width: 40%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['twConsSec'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
56
+ <div class="nxs_tls_lbl"><strong>Your Access Token:</strong> </div><input type="text" name="tw[<?php echo $ii; ?>][apTWAccToken]" id="apTWAccToken" style="width: 40%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['twAccToken'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
57
+ <div class="nxs_tls_lbl"><strong>Your Access Token Secret:</strong> </div><input type="text" name="tw[<?php echo $ii; ?>][apTWAccTokenSec]" id="apTWAccTokenSec" style="width: 40%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['twAccTokenSec'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
58
  <?php if ($isNew) { ?> <input type="hidden" name="tw[<?php echo $ii; ?>][apDoTW]" value="1" id="apDoNewTW<?php echo $ii; ?>" /> <?php } ?>
59
  <br/><br/>
60
+ <p style="margin: 0px;"><input value="1" id="apLIAttch" type="checkbox" name="tw[<?php echo $ii; ?>][attchImg]" <?php if ((int)$options['attchImg'] == 1) echo "checked"; ?> /> <strong><?php _e('Attach Image to Twitter Post', 'nxs_snap'); ?></strong></p>
61
  <br/>
62
  <strong id="altFormatText"><?php _e('Message text Format', 'nxs_snap'); ?>:</strong>
63
+ <input type="text" name="tw[<?php echo $ii; ?>][apTWMsgFrmt]" id="apTWMsgFrmt" style="width: 50%;" value="<?php if (!$isNew) _e(apply_filters('format_to_edit', htmlentities($options['twMsgFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap'); else echo "%TITLE% - %URL%"; ?>" onfocus="mxs_showFrmtInfo('apTWMsgFrmt<?php echo $ii; ?>');" />
64
 
65
  <?php nxs_doShowHint("apTWMsgFrmt".$ii, '<br/><br/><b>%TAGS% and %CATS% will be posted as hashtags. <br/>Please remember that Twitter takes only 140 characters.</b>'); ?>
66
 
67
+
68
+
69
+ <?php if($options['twAccTokenSec']!='') { ?>
70
+ <br/><br/><b><?php _e('Test your settings', 'nxs_snap'); ?>:</b>&nbsp;&nbsp;&nbsp; <?php if (!isset($options['twOK']) || $options['twOK']!='1') { ?> <div class="blnkg">=== Submit Test Post to Complete ===&gt;</div> <?php } ?> <a href="#" class="NXSButton" onclick="testPost('TW', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s' , 'nxs_snap'), $nType); ?></a> <br/>
71
+ <?php }?>
72
+
73
+
74
+ </div>
75
+ <?php /* ######################## Tools Tab ####################### */ ?>
76
+ <div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content">
77
+
78
+ <?php if (!$isNew) { ?> <div class="nxs_tls_cpt"><?php _e('Categories', 'nxs_snap'); ?></div>
79
+ <div class="nxs_tls_bd"> <div class="nxs_tls_sbInfo"><?php _e('Only selected categories will be autoposted to this account.', 'nxs_snap'); ?></div>
80
+ <strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
81
+ <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
82
+ <input value="1" id="catSelSTW<?php echo $ii; ?>" type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_TW<?php echo $ii; ?>" onclick="jQuery('#catSelSTW<?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('TW<?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_TW<?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($options['catSelEd']!='') echo "[".(substr_count($options['catSelEd'], ",")+1)."]"; ?></a>
83
+ <input type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_TW<?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
84
+ </div>
85
+ <?php } ?>
86
+
87
+ <?php nxs_addPostingDelaySelV3($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']); ?>
88
+
89
+ <div class="nxs_tls_cpt"><?php _e('Auto Import of Replies and Mentions:', 'nxs_snap'); ?></div>
90
+ <div class="nxs_tls_bd">
91
+ <div class="nxs_tls_sbInfo"><?php _e('Plugin could grab Replies and Mentions from Twitter and import them as Wordpress Comments', 'nxs_snap'); ?></div>
92
  <?php if ( $gOptions['riActive'] == '1' ) { ?>
93
+ <input value="1" id="riC<?php echo $ii; ?>" <?php if (trim($options['riComments'])=='1') echo "checked"; ?> type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][riComments]"/> <b><?php _e('Import Twitter Replies', 'nxs_snap'); ?></b>
 
 
94
  <br/>
95
+ <input value="1" id="riCM<?php echo $ii; ?>" <?php if (trim($options['riCommentsM'])=='1') echo "checked"; ?> type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][riCommentsM]"/> <b><?php _e('Import Twitter Mentions', 'nxs_snap'); ?></b>
96
+ <br/>
97
+ <input value="1" id="riCA<?php echo $ii; ?>" <?php if (trim($options['riCommentsAA'])=='1') echo "checked"; ?> type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][riCommentsAA]"/> <b><?php _e('Auto-approve imported comments', 'nxs_snap'); ?></b>
98
+ <?php } else { echo "<br/>"; _e('Please activate the "Comments Import" from SNAP Settings Tab', 'nxs_snap'); } ?>
99
+ </div>
100
 
101
+ <?php nxs_showRepostSettings($nt, $ii, $options); ?>
102
 
103
+ </div>
104
+ </div><br/>
105
+ <div class="submit clear" style="padding-bottom: 0px;"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div>
106
+
 
 
107
  </div>
108
  <?php
109
  }
119
  if (isset($pval['apTWAccToken'])) $options[$ii]['twAccToken'] = trim($pval['apTWAccToken']);
120
 
121
  if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']);
122
+ if (isset($options[$ii]['catSel']) && $options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
123
 
124
  if (isset($pval['riComments'])) $options[$ii]['riComments'] = $pval['riComments']; else $options[$ii]['riComments'] = 0;
125
+ if (isset($pval['riCommentsM'])) $options[$ii]['riCommentsM'] = $pval['riCommentsM']; else $options[$ii]['riCommentsM'] = 0;
126
  if (isset($pval['riCommentsAA'])) $options[$ii]['riCommentsAA'] = $pval['riCommentsAA']; else $options[$ii]['riCommentsAA'] = 0;
127
 
128
+ $options[$ii] = nxs_adjRpst($options[$ii], $pval);
129
+
130
  if (isset($pval['apTWAccTokenSec']))$options[$ii]['twAccTokenSec'] = trim($pval['apTWAccTokenSec']);
131
  if (isset($pval['apTWMsgFrmt'])) $options[$ii]['twMsgFormat'] = trim($pval['apTWMsgFrmt']);
132
+ if (isset($pval['attchImg'])) $options[$ii]['attchImg'] = $pval['attchImg']; else $options[$ii]['attchImg'] = 0;
133
+ if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']); if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']);
 
134
  if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
135
  }
136
  } return $options;
137
  }
138
  //#### Show Post->Edit Meta Box Settings
139
+ function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID; $nt = 'tw'; $ntU = 'TW';
140
+ foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapTW', true)); if (is_array($pMeta) && isset($pMeta[$ii]) && is_array($pMeta[$ii])) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
141
+ if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = ''; if (empty($ntOpt['urlToUse'])) $ntOpt['urlToUse'] = '';
142
+ $doTW = $ntOpt['doTW'] && (is_array($pMeta) || $ntOpt['catSel']!='1'); $imgToUse = $ntOpt['imgToUse'];
143
  $isAvailTW = $ntOpt['twURL']!='' && $ntOpt['twConsKey']!='' && $ntOpt['twConsSec']!='' && $ntOpt['twAccToken']!=''; $twMsgFormat = htmlentities($ntOpt['twMsgFormat'], ENT_COMPAT, "UTF-8"); $isAttchImg = $ntOpt['attchImg'];
144
  ?>
145
  <tr><th style="text-align:left;" colspan="2"><?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_TW<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
146
  <?php if ($isAvailTW) { ?><input class="nxsGrpDoChb" value="1" id="doTW<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="tw[<?php echo $ii; ?>][doTW]" <?php if ((int)$doTW == 1) echo 'checked="checked" title="def"'; ?> />
147
  <?php if ($post->post_status == "publish") { ?> <input type="hidden" name="tw[<?php echo $ii; ?>][doTW]" value="<?php echo $doTW;?>"> <?php } ?> <?php } ?>
148
+ <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/tw16.png);">Twitter - <?php _e('autopost to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)
149
+ </div></th><td><?php //## Only show RePost button if the post is "published"
150
  if ($post->post_status == "publish" && $isAvailTW) { ?>
151
  <input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToTW_repostButton" id="rePostToTW_button" value="<?php _e('Repost to Twitter', 'nxs_snap') ?>" />
152
 
153
+ <?php if ($ntOpt['riComments']=='1' && (is_array($pMeta) && isset($pMeta[$ii]) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) && $pMeta[$ii]['pgID']!='' ) ) { ?>
154
  <input alt="<?php echo $ii; ?>" style="float: right; " onclick="return false;" type="button" class="button" name="riToTW_repostButton" id="riToTW_button" value="<?php _e('Import Replies/Mentions from Twitter', 'nxs_snap') ?>" />
155
+ <?php } } ?>
156
+ <?php if (is_array($pMeta) && isset($pMeta[$ii]) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID'])) { ?> <span style="float: right;padding-top: 4px; padding-right: 10px;">
 
 
157
  <a id="pstdTW<?php echo $ii; ?>" style="font-size: 10px;" href="<?php echo $ntOpt['twURL'].'/status/'.$pMeta[$ii]['pgID']; ?>" target="_blank"><?php $nType="Twitter"; printf( __( 'Posted on', 'nxs_snap' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
158
  </span><?php } ?>
159
  </td></tr>
160
+
161
  <?php if (!$isAvailTW) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your Twitter Account to AutoPost to Twitter</b>
162
+ <?php }else { if ($post->post_status != "publish" && function_exists('nxs_doSMAS5') ) { nxs_doSMAS5($nt, $ii, $ntOpt); } ?>
163
+
164
+ <?php if ($ntOpt['rpstOn']=='1') { ?>
165
+
166
+ <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top:6px; text-align:right; width:60px; padding-right:10px;">
167
+ <input value="0" type="hidden" name="tw[<?php echo $ii; ?>][rpstPostIncl]"/><input value="nxsi<?php echo $ii; ?>tw" type="checkbox" name="tw[<?php echo $ii; ?>][rpstPostIncl]" <?php if (!empty($ntOpt['rpstPostIncl'])) echo "checked"; ?> />
168
+ </th>
169
+ <td> <?php _e('Include in "Auto-Reposting" to this network.', 'nxs_snap') ?>
170
+ </td></tr> <?php } ?>
171
 
172
  <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top:6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Message Format:', 'nxs_snap') ?></th>
173
  <td><input value="<?php echo $twMsgFormat ?>" type="text" name="tw[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apTWMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apTWMsgFrmt".$ii); ?></td></tr>
175
  <tr><th scope="row" style="text-align:right; width:150px; vertical-align:top; padding-top: 5px; padding-right:10px;">
176
  <input value="0" type="hidden" name="tw[<?php echo $ii; ?>][attchImg]"/>
177
  <input value="1" type="checkbox" name="tw[<?php echo $ii; ?>][attchImg]" <?php if ((int)$isAttchImg == 1) echo "checked"; ?> /> </th><td><strong>Attach Image to Twitter Post</strong></td> </tr>
178
+
179
+ <?php /* ## Select Image & URL ## */ nxs_showImgToUseDlg($nt, $ii, $imgToUse); ?>
180
+
181
  <?php }
182
  }
183
  }
184
  //####
185
+ function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
186
+ if (isset($pMeta['SNAPformat'])) $optMt['twMsgFormat'] = $pMeta['SNAPformat'];
187
+ if (isset($pMeta['imgToUse'])) $optMt['imgToUse'] = $pMeta['imgToUse'];
188
+ if (isset($pMeta['timeToRun'])) $optMt['timeToRun'] = $pMeta['timeToRun']; if (isset($pMeta['rpstPostIncl'])) $optMt['rpstPostIncl'] = $pMeta['rpstPostIncl'];
189
  if (isset($pMeta['attchImg'])) $optMt['attchImg'] = $pMeta['attchImg'] == 1?1:0; else { if (isset($pMeta['attchImg'])) $optMt['attchImg'] = 0; }
190
  if (isset($pMeta['doTW'])) $optMt['doTW'] = $pMeta['doTW'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doTW'] = 0; }
191
  if (isset($pMeta['SNAPincludeTW']) && $pMeta['SNAPincludeTW'] == '1' ) $optMt['doTW'] = 1; // <2.6 Compatibility fix
200
  }}
201
 
202
  if (!function_exists("nxs_getBackTWComments")) { function nxs_getBackTWComments($postID, $options, $po, $twList) { $impCmnts = get_post_meta($postID, 'snapImportedComments', true);
203
+ if(!is_array($impCmnts)) $impCmnts = array(); $twsToImp = array(); $lastID = '';
204
  //## Do Replies
205
  foreach ($twList as $tw) if ($tw['in_reply_to_status_id_str'] == $po['pgID']) $twsToImp[] = $tw;
206
  if (is_array($twsToImp) && count($twsToImp)>0)
209
  'comment_author_email' => $comment['user']['screen_name'].'@twitter.com', 'comment_author_url' => 'http://twitter.com/'.$comment['user']['screen_name'],
210
  'comment_content' => str_ireplace('@'.$comment['in_reply_to_screen_name'],'', $comment['text']), 'comment_date_gmt' => date('Y-m-d H:i:s', strtotime( $comment['created_at'] ) ), 'comment_type' => '');
211
  nxs_postNewComment($commentdata, $options['riCommentsAA']=='1'); $ci++;
212
+ }
213
+
214
  //## Do mentions.
215
  require_once ('apis/tmhOAuth.php'); $tmhOAuth = new NXS_tmhOAuth(array( 'consumer_key' => $options['twConsKey'], 'consumer_secret' => $options['twConsSec'], 'user_token' => $options['twAccToken'], 'user_secret' => $options['twAccTokenSec']));
216
  if (isset($options['urlToUse']) && trim($options['urlToUse'])!='') $urlToSrch = $options['urlToUse']; else $urlToSrch = get_permalink($postID);
225
  }
226
  }}
227
  delete_post_meta($postID, 'snapImportedComments'); add_post_meta($postID, 'snapImportedComments', $impCmnts );
228
+ if ( isset($_POST['id']) && $_POST['id']!='') printf( _n('%d comment has been imported.', '%d comments has been imported.', $ci, 'nxs_snap'), $ci );
229
  }}
230
 
231
  if (!function_exists("nxs_rePostToTW_ajax")) {
232
+ function nxs_rePostToTW_ajax() { check_ajax_referer('nxsSsPageWPN'); $postID = $_POST['id']; $options = get_option('NS_SNAutoPoster');
233
+ foreach ($options['tw'] as $ii=>$nto) if ($ii==$_POST['nid']) { $nto['ii'] = $ii; $nto['pType'] = 'aj';
234
  $twpo = get_post_meta($postID, 'snapTW', true); $twpo = maybe_unserialize($twpo);
235
+ if (is_array($twpo) && isset($twpo[$ii]) && is_array($twpo[$ii]) && isset($twpo[$ii]['SNAPformat']) ) { $ntClInst = new nxs_snapClassTW(); $nto = $ntClInst->adjMetaOpt($nto, $twpo[$ii]);}
236
+ if (isset($_POST['ri']) && $_POST['ri']=='1') { $twList = nxs_getBackTWCommentsList($nto); nxs_getBackTWComments($postID, $nto, $twpo[$ii], $twList); die(); } else {
237
+ $result = nxs_doPublishToTW($postID, $nto); if ($result == 200) {$options['tw'][$ii]['twOK']=1; update_option('NS_SNAutoPoster', $options); } if ($result == 200) die("Successfully sent your post to Twitter."); else die($result);
238
  }
239
  }
240
  }
241
  }
242
 
243
  if (!function_exists("nxs_doPublishToTW")) { //## Second Function to Post to TW
244
+ function nxs_doPublishToTW($postID, $options){ $ntCd = 'TW'; $ntCdL = 'tw'; $ntNm = 'Twitter'; $img = ''; $imgURL = ''; global $plgn_NS_SNAutoPoster, $nxs_urlLen; $nxs_urlLen = 0;
245
+ if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
246
  //$backtrace = debug_backtrace(); nxs_addToLogN('W', 'Error', $logNT, 'I am here - '.$ntCd."|".print_r($backtrace, true), '');
247
  //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToTW', array($postID, $options));
248
+ $gOptions = $plgn_NS_SNAutoPoster->nxs_options; if (!empty($gOptions['nxsHTSpace'])) $htS = $gOptions['nxsHTSpace']; else $htS = '';
249
  $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'POSTID'=>$postID, 'ACCNAME'=>$options['nName']));
250
  $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
251
  $logNT = '<span style="color:#00FFFF">Twitter</span> - '.$options['nName'];
255
  nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$options['pType']); return;
256
  }
257
  }
258
+ $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url(); $uln = 0; $extInfo = ' | PostID: '.$postID;
259
+
260
 
261
+ if ($options['attchImg']=='1') { if (trim($options['imgToUse'])!='') $imgURL = $options['imgToUse']; else $imgURL = nxs_getPostImage($postID); if (preg_match("/noImg.\.png/i", $imgURL)) $imgURL = '';
262
+ if(trim($imgURL)=='') $options['attchImg'] = 0; else {
263
+ if( ini_get('allow_url_fopen') ) { if (@getimagesize($imgURL)!==false) { $img = wp_remote_get($imgURL);
264
+ if (is_wp_error($img)) $options['attchImg'] = 0; else if ($img['headers']['content-length']<200) { $options['attchImg'] = 0; } else $img = $img['body']; } else $options['attchImg'] = 0;
265
+ } else { $img = wp_remote_get($imgURL); if(is_wp_error($img)) $options['attchImg'] = 0; elseif (isset($img['body'])&& trim($img['body'])!='') $img = $img['body']; else $options['attchImg'] = 0; }
266
+ }
267
+ if ($options['attchImg'] == 0) nxs_addToLogN('E', 'Error', $logNT, 'Could not get image ('.$imgURL.'), will post without it - Error:'.print_r($img), $extInfo);
268
  }
269
  if ($options['attchImg']=='1' && $img!='') $twLim = 117; else $twLim = 140;
270
 
271
  if ($postID=='0') { echo "Testing ... <br/><br/>"; $msg = 'Test Post from '.nsTrnc($blogTitle, $twLim - 24)." - ".rand(1, 155); $uln = nxs_strLen($msg);}
272
+ else{ $post = get_post($postID); if(!$post) return; $twMsgFormat = $options['twMsgFormat']; nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
273
+ $extInfo = ' | PostID: '.$postID." - ".$post->post_title.' |'.$options['pType'];
274
  if (stripos($twMsgFormat, '%URL%')!==false || stripos($twMsgFormat, '%SURL%')!==false) $twLim = $twLim - 22;
275
  if (stripos($twMsgFormat, '%AUTHORNAME%')!==false) { $aun = $post->post_author; $aun = get_the_author_meta('display_name', $aun ); $twLim = $twLim - nxs_strLen($aun); }
276
 
278
  $noRepl = str_ireplace("%SURL%", "", $noRepl);$noRepl = str_ireplace("%TEXT%", "", $noRepl);$noRepl = str_ireplace("%FULLTEXT%", "", $noRepl);$noRepl = str_ireplace("%EXCERPT%", "", $noRepl);
279
  $noRepl = str_ireplace("%ANNOUNCE%", "", $noRepl); $noRepl = str_ireplace("%AUTHORNAME%", "", $noRepl); $twLim = $twLim - nxs_strLen($noRepl);
280
 
281
+ $pTitle = nxs_doQTrans($post->post_title);
282
+ if ($post->post_excerpt!="") $exrText = nxs_doQTrans($post->post_excerpt); else $exrText= nxs_doQTrans($post->post_content); $pText = apply_filters('the_content', $exrText);
283
+ $pRawText = nxs_doQTrans($post->post_content); $pFullText = apply_filters('the_content', $pRawText);
284
  if (stripos($twMsgFormat, '%TAGS%')!==false || stripos($twMsgFormat, '%HTAGS%')!==false) {
285
  $t = wp_get_object_terms($postID, 'product_tag'); if ( empty($t) || is_wp_error($pt) || !is_array($t) ) $t = wp_get_post_tags($postID);
286
+ $tggs = array(); foreach ($t as $tagA) { $frmTag = trim(str_replace(' ', $htS, preg_replace('/[^a-zA-Z0-9\p{L}\p{N}\s]/u', '', trim(ucwords(str_ireplace('&','',str_ireplace('&amp;','',$tagA->name)))))));
287
  if (preg_match('/\b'.$frmTag.'\b/iu', $pTitle)) $pTitle = trim(preg_replace('/\b'.$frmTag.'\b/iu', '#'.$frmTag, $pTitle));
288
  if (preg_match('/\b'.$frmTag.'\b/iu', $pFullText)) $pFullText = trim(preg_replace('/\b'.$frmTag.'\b/iu', '#'.$frmTag, $pFullText));
289
  if (preg_match('/\b'.$frmTag.'\b/iu', $pText)) $pText = trim(preg_replace('/\b'.$frmTag.'\b/iu', '#'.$frmTag, $pText));
299
  $twLim = $twLim - nxs_strLen($tags);
300
  }
301
  if (stripos($twMsgFormat, '%CATS%')!==false || stripos($twMsgFormat, '%HCATS%')!==false) {
302
+ $t = wp_get_post_categories($postID); $ctts = array(); foreach($t as $c){ $cat = get_category($c); //$frmTag = trim(str_replace(' ','', str_replace(' ',' ',str_ireplace('&','&amp;',trim(ucwords($cat->name)))))); prr($frmTag);
303
+ $frmTag = trim(str_replace(' ',$htS,preg_replace('/[^a-zA-Z0-9\p{L}\p{N}\s]/u', '', trim(ucwords(str_ireplace('&','',str_ireplace('&amp;','',$cat->name)))))));
304
  if (stripos($pTitle, $cat->name)!==false) $pTitle = str_ireplace($cat->name, '#'.$frmTag, $pTitle); elseif (stripos($pTitle, $frmTag)!==false) $pTitle = str_ireplace($frmTag, '#'.$frmTag, $pTitle);
305
  if (stripos($pText, $cat->name)!==false) $pText = str_ireplace($cat->name, '#'.$frmTag, $pText); elseif (stripos($pText, $frmTag)!==false) $pText = str_ireplace($frmTag, '#'.$frmTag, $pText);
306
  if (stripos($pFullText, $cat->name)!==false) $pFullText = str_ireplace($cat->name, '#'.$frmTag, $pFullText); elseif (stripos($pFullText, $frmTag)!==false) $pFullText = str_ireplace($frmTag, '#'.$frmTag, $pFullText);
317
  }
318
  if (stripos($twMsgFormat, '%TITLE%')!==false) { if (stripos($pTitle, '.co.uk')!==false) $twLim = $twLim - 14;
319
  if (stripos($pTitle, '.com')!==false) $twLim = $twLim - 16; if (stripos($pTitle, '.net')!==false) $twLim = $twLim - 16; if (stripos($pTitle, '.org')!==false) $twLim = $twLim - 16;
320
+ $pTitle = html_entity_decode(strip_tags($pTitle), ENT_NOQUOTES, 'UTF-8');
321
  $pTitle = nsTrnc($pTitle, $twLim); $twMsgFormat = str_ireplace("%TITLE%", $pTitle, $twMsgFormat); $twLim = $twLim - nxs_strLen($pTitle);
322
  }
323
  if (stripos($twMsgFormat, '%SITENAME%')!==false) {
342
  $pRawText = nsTrnc(strip_tags($pRawText), $twLim); $twMsgFormat = str_ireplace("%RAWTEXT%", $pRawText, $twMsgFormat); $twLim = $twLim - nxs_strLen($pRawText);
343
  }
344
  $msg = nsFormatMessage($twMsgFormat, $postID, $addParams);
345
+ }
346
  $msg = str_replace('&amp;#039;', "'", $msg); $msg = str_replace('&#039;', "'", $msg); $msg = str_replace('#039;', "'", $msg); $msg = str_replace('#039', "'", $msg);
347
  $msg = str_replace('&amp;#8217;', "'", $msg); $msg = str_replace('&#8217;', "'", $msg); $msg = str_replace('#8217;', "'", $msg); $msg = str_replace('#8217', "'", $msg);
348
  $msg = str_replace('&amp;#8220;', '"', $msg); $msg = str_replace('&#8220;', '"', $msg); $msg = str_replace('#8220;', '"', $msg); $msg = str_replace('#8220', "'", $msg);
inc-cl/vb.api.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //## NextScripts FriendFeed Connection Class
3
+ $nxs_snapAPINts[] = array('code'=>'VB', 'lcode'=>'vb', 'name'=>'vBulletin');
4
+
5
+ if (!class_exists("nxs_class_SNAP_VB")) { class nxs_class_SNAP_VB {
6
+
7
+ var $ntCode = 'VB';
8
+ var $ntLCode = 'vb';
9
+
10
+ function doPost($options, $message){ if (!is_array($options)) return false;
11
+ foreach ($options as $ntOpts) $out[] = $this->doPostToNT($ntOpts, $message);
12
+ return $out;
13
+ }
14
+ function nxs_getVBHeaders($ref, $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
+ if (function_exists('gzdeflate')) $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 nxs_doCheckVB($url){ global $nxs_vbCkArray; $hdrsArr = $this->nxs_getVBHeaders($url); $ckArr = $nxs_vbCkArray;
22
+ $response = wp_remote_get($url, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr));
23
+ if (stripos($response['body'],'logouthash=')===false) return 'Bad Saved Login';
24
+ if ( stripos($response['body'], 'usercp.php')!==false && stripos($response['body'], 'logouthash')!==false){ /*echo "You are IN"; */ return false;
25
+ } else return 'No Saved Login';
26
+ return false;
27
+ }
28
+ function nxs_doConnectToVB($u, $p, $url){ global $nxs_vbCkArray; $hdrsArr = $this->nxs_getVBHeaders($url, true); $mids = '';// echo "LOGGIN";
29
+ $response = wp_remote_get($url); if(is_wp_error($response)) return "Invalid Connection. ".print_r($response, true);
30
+ $contents = $response['body']; //$response['body'] = htmlentities($response['body']); prr($response); die();
31
+ $ckArr = $response['cookies']; $mdhashLoc = stripos($contents, 'md5hash(vb_login_password');
32
+ if ($mdhashLoc===false) return "No VB found";
33
+ $frmTxt = CutFromTo($contents, 'md5hash(vb_login_password','</form>'); $md = array(); $flds = array();
34
+ while (stripos($frmTxt, '<input')!==false){ $inpField = trim(CutFromTo($frmTxt,'<input', '>')); $name = trim(CutFromTo($inpField,'name="', '"'));
35
+ if ( stripos($inpField, '"hidden"')!==false && $name!='' && !in_array($name, $md)) { $md[] = $name; $val = trim(CutFromTo($inpField,'value="', '"')); $flds[$name]= $val; $mids .= "&".$name."=".$val;}
36
+ $frmTxt = substr($frmTxt, stripos($frmTxt, '<input')+8);
37
+ } $flds['vb_login_username'] = $u; $flds['vb_login_md5password'] = md5($p); $flds['vb_login_md5password_utf'] = md5($p); $flds['cookieuser'] = '1'; $flds['do'] = 'login';
38
+
39
+ // $logURL = substr($contents, $mdhashLoc-250, 250); $logURL = CutFromTo($logURL, 'action="', '"');
40
+ if (stripos($contents, 'base href="')!==false) $baseURL = trim(CutFromTo($contents,'base href="', '"')); else { $uarr = explode('/',$url); $dd = $uarr[count($uarr)-1]; $baseURL = str_replace($dd, '', $url);}
41
+ $r2 = wp_remote_post( $baseURL.'login.php?do=login', array( 'method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds, 'cookies' => $ckArr)); // prr($r2);
42
+ if (stripos($r2['body'],'exec_refresh()')!==false) { $ckArr = nxsMergeArraysOV($ckArr, $r2['cookies']); $nxs_vbCkArray = $ckArr; return false; } else return "Bad Username/Password";
43
+ }
44
+ function nxs_doPostToVB($url, $subj, $msg, $lnk, $tags){ global $nxs_vbCkArray; $hdrsArr = $this->nxs_getVBHeaders($url); $ckArr = $nxs_vbCkArray; $mids='';
45
+ $response = wp_remote_get($url, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr));
46
+ if(is_wp_error($response)) return "Invalid Connection. ".print_r($response, true);
47
+ $contents = $response['body']; // $response['body'] = htmlentities($response['body']); prr($response); die();
48
+ if (stripos($contents, 'base href="')!==false) $baseURL = trim(CutFromTo($contents,'base href="', '"')); else { $uarr = explode('/',$url); $dd = $uarr[count($uarr)-1]; $baseURL = str_replace($dd, '', $url);}
49
+ if (stripos($contents, 'newthread.php?do=newthread')!==false) $mdd='t'; elseif (stripos($contents, 'newreply.php?')!==false) $mdd='p'; else return "No Thread/Post Controls found";
50
+
51
+ if ($mdd=='t'){ $fid = CutFromTo($contents, 'newthread.php?do=newthread','"'); // echo $baseURL.'newthread.php?do=newthread'.str_replace('&amp;','&',$fid);
52
+ $response = wp_remote_get( $baseURL.'newthread.php?do=newthread'.str_replace('&amp;','&',$fid), array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr)); $contents = $response['body'];
53
+ $frmTxt = CutFromTo($contents, 'newthread.php?do=postthread','</form>'); $md = array(); $flds = array(); //prr($frmTxt);
54
+ while (stripos($frmTxt, '<input')!==false){ $inpField = trim(CutFromTo($frmTxt,'<input', '>')); $name = trim(CutFromTo($inpField,'name="', '"'));
55
+ if ( stripos($inpField, '"hidden"')!==false && $name!='' && !in_array($name, $md)) { $md[] = $name; $val = trim(CutFromTo($inpField,'value="', '"')); $flds[$name]= $val; $mids .= "&".$name."=".$val;}
56
+ $frmTxt = substr($frmTxt, stripos($frmTxt, '<input')+8);
57
+ } $flds['subject'] = $subj; $flds['message'] = $msg; $flds['message_backup'] = $msg; $flds['wysiwyg'] = '1'; $flds['do'] = 'postthread'; $flds['taglist'] = $tags; $flds['parseurl'] = '1'; $flds['sbutton'] = 'Submit+New+Thread';
58
+ $smURL = $baseURL.'newthread.php?do=postthread'.str_replace('&amp;','&',$fid);
59
+ } //prr($flds);
60
+ if ($mdd=='p'){ $fid = CutFromTo($contents, 'newreply.php?do=newreply','"');
61
+ $response = wp_remote_get( $baseURL.'newreply.php?do=newreply'.str_replace('&amp;','&',$fid), array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr)); $contents = $response['body'];
62
+ $frmTxt = CutFromTo($contents, 'newreply.php?do=postreply','</form>'); $md = array(); $flds = array(); //prr($frmTxt);
63
+
64
+ while (stripos($frmTxt, '<input')!==false){ $inpField = trim(CutFromTo($frmTxt,'<input', '>')); $name = trim(CutFromTo($inpField,'name="', '"'));
65
+ if ( stripos($inpField, '"hidden"')!==false && $name!='' && !in_array($name, $md)) { $md[] = $name; $val = trim(CutFromTo($inpField,'value="', '"')); $flds[$name]= $val; $mids .= "&".$name."=".$val;}
66
+ $frmTxt = substr($frmTxt, stripos($frmTxt, '<input')+8);
67
+ } $flds['title'] = $subj; $flds['message'] = $msg; $flds['message_backup'] = $msg; $flds['wysiwyg'] = '1'; $flds['do'] = 'postreply'; $flds['parseurl'] = '1'; $flds['sbutton'] = 'Submit+Reply';
68
+ $smURL = $baseURL.'newreply.php?do=postreply'.str_replace('&amp;','&',$fid);
69
+ } //prr($flds);
70
+ $r2 = wp_remote_post( $smURL, array( 'method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds, 'cookies' => $ckArr));// prr($r2['response']); prr(htmlentities($r2['body'])); $r2['body'] = ''; prr($r2); die();
71
+ if (stripos($r2['body'], 'tag can only be ')!==false) { $lgLim = trim(CutFromTo($r2['body'], 'tag can only be ',' characters')); $flds['taglist'] = substr($flds['taglist'], 0, $lgLim);
72
+ $r2 = wp_remote_post( $smURL, array( 'method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds, 'cookies' => $ckArr));
73
+ }
74
+ if (stripos($r2['body'], 'errorblock')!==false) return trim(strip_tags( CutFromTo($r2['body'], 'errorblock','</div>')));
75
+ if (stripos($r2['body'], 'exec_refresh()')!==false && stripos($r2['body'], 'blockrow restore">')!==false) return trim(strip_tags( CutFromTo($r2['body'], 'blockrow restore">','</p>')));
76
+ if (stripos($r2['body'], '<error>')!==false) return trim(strip_tags( CutFromTo($r2['body'], '<error>','</error>')));
77
+ if ( $r2['response']['code']=='302' || $r2['response']['code']=='303') { return array("code"=>"OK", "post_id"=>$r2['headers']['location']); }
78
+ if (stripos($r2['body'], '<newpostid>')!==false || stripos($r2['body'], 'postbit postid="')!==false ) return 'OK';
79
+ return "Something wrong";
80
+ }
81
+
82
+ function doPostToNT($options, $message){ $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>''); global $nxs_vbCkArray;
83
+ //## Check settings
84
+ if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
85
+ if (!isset($options['vbUName']) || trim($options['vbPass'])=='') { $badOut['Error'] = 'Not Configured'; return $badOut; }
86
+ $pass = (substr($options['vbPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['vbPass'], 5)):$options['vbPass']);
87
+ //## Format
88
+ $msg = nxs_doFormatMsg($options['vbMsgFormat'], $message); $msgT = nxs_doFormatMsg($options['vbMsgTFormat'], $message);
89
+ $urlToGo = (!empty($message['url']))?$message['url']:'';
90
+ //## Post
91
+ if (isset($options['vbSvC'])) $nxs_vbCkArray = maybe_unserialize( $options['vbSvC']); $loginError = true;
92
+ if (is_array($nxs_vbCkArray)) $loginError = $this->nxs_doCheckVB( $options['vbURL']); if ($loginError!==false) $loginError = $this->nxs_doConnectToVB( $options['vbUName'], $pass, $options['vbURL']);
93
+ if ($loginError!==false) return "ERROR - BAD USER/PASS - ".print_r($loginError, true);
94
+ $ret = $this->nxs_doPostToVB($options['vbURL'], $msgT, $msg, $urlToGo, $message['tags']);
95
+
96
+ if ( (!is_array($ret)) && $ret!='OK') $badOut['Error'] .= 'Something went wrong - NO PID '.print_r($ret, true); else return array('postID'=>$ret['post_id'], 'isPosted'=>1, 'postURL'=>$ret['post_id'], 'pDate'=>date('Y-m-d H:i:s'));
97
+ return $badOut;
98
+ }
99
+ }}
100
+ ?>
inc-cl/vb.php CHANGED
@@ -8,43 +8,47 @@ if (!class_exists("nxs_snapClassVB")) { class nxs_snapClassVB {
8
  <div class="nxs_box">
9
  <div class="nxs_box_header">
10
  <div class="nsx_iconedTitle" style="margin-bottom:1px;background-image:url(<?php echo $nxs_plurl;?>img/<?php echo $ntInfo['lcode']; ?>16.png);"><?php echo $ntInfo['name']; ?>
11
- <?php $cbo = count($ntOpts); ?> <?php wp_nonce_field( 'ns'.$ntInfo['code'], 'ns'.$ntInfo['code'].'_wpnonce' ); ?>
12
  <?php if ($cbo>1){ ?><div class="nsBigText"><?php echo "(".($cbo=='0'?'No':$cbo)." "; _e('accounts', 'nxs_snap'); echo ")"; ?></div><?php } ?>
13
  </div>
14
  </div>
15
  <div class="nxs_box_inside">
16
  <?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
17
  <p style="margin:0px;margin-left:5px;">
18
- <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> /> <?php if ((int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
 
 
19
  <strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
20
  &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', 'nxs_snap'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>&nbsp;&nbsp;
21
  <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
22
- </p><?php $this->showNTSettings($indx, $pbo);
23
  }?>
24
  </div>
25
  </div> <?php
26
  }
27
  //#### Show NEW Settings Page
28
- function showNewNTSettings($mgpo){ $options = array('nName'=>'', 'doVB'=>'1', 'vbUName'=>'', 'vbInclTags'=>'1', 'vbAttch'=>'', 'vbURL'=>'', 'vbPass'=>''); $this->showNTSettings($mgpo, $options, true);}
29
 
30
 
31
  //#### Show Unit Settings
32
- function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl; ?>
33
- <div id="doVB<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>" style="background-image: url(<?php echo $nxs_plurl; ?>img/vb-bg.png); background-position:90% 10%;"> <input type="hidden" name="apDoSVB<?php echo $ii; ?>" value="0" id="apDoSVB<?php echo $ii; ?>" />
 
 
34
 
35
  <div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/vb16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-vbulletin-social-networks-auto-poster-wordpress/"><?php $nType="vBulletin"; printf( __( 'Detailed %s Installation/Configuration Instructions', 'nxs_snap' ), $nType); ?></a></div>
36
 
37
- <div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easely identify it', 'nxs_snap'); ?></i> </div><input name="vb[<?php echo $ii; ?>][nName]" id="vbnName<?php echo $ii; ?>" style="font-weight: bold; color: #005800; border: 1px solid #ACACAC; width: 40%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['nName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /><br/>
38
- <?php echo nxs_addQTranslSel('vb', $ii, $options['qTLng']); ?><?php echo nxs_addPostingDelaySel('vb', $ii, $options['nHrs'], $options['nMin']); ?>
39
 
40
- <?php if (!$isNew) { ?>
41
- <div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
42
- <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="vb[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
43
- <input value="1" id="catSelSVB<?php echo $ii; ?>" type="radio" name="vb[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_VB<?php echo $ii; ?>" onclick="jQuery('#catSelSVB<?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('VB<?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_VB<?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($options['catSelEd']!='') echo "[".(substr_count($options['catSelEd'], ",")+1)."]"; ?></a>
44
- <input type="hidden" name="vb[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_VB<?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
45
- <br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
46
- <br/>
47
- <?php } ?>
48
 
49
  <div id="altFormat" style="">
50
  <div style="width:100%;"><strong id="altFormatText">vBulletin URL:</strong> <span style="font-size: 11px; margin: 0px;">Could be Forum URL or Thread URL. Either new thread of new post will be created.</span></div>
@@ -78,12 +82,32 @@ if (!class_exists("nxs_snapClassVB")) { class nxs_snapClassVB {
78
  </div><br/>
79
 
80
  <?php if ($options['vbPass']!='') { ?>
81
- <?php wp_nonce_field( 'rePostToVB', 'rePostToVB_wpnonce' ); ?>
82
  <b><?php _e('Test your settings', 'nxs_snap'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('VB', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'nxs_snap' ), $nType); ?></a>
83
 
84
  <?php }
85
 
86
- ?><div class="submit"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div></div><?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  }
88
  //#### Set Unit Settings from POST
89
  function setNTSettings($post, $options){ global $nxs_snapThisPageUrl; $code = 'VB'; $lcode = 'vb';
@@ -102,13 +126,17 @@ if (!class_exists("nxs_snapClassVB")) { class nxs_snapClassVB {
102
  if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
103
 
104
  if (isset($pval['apDoVB'])) $options[$ii]['doVB'] = $pval['apDoVB']; else $options[$ii]['doVB'] = 0;
 
 
 
 
105
  if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
106
  if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
107
  }
108
  } return $options;
109
  }
110
  //#### Show Post->Edit Meta Box Settings
111
- function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
112
  foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapVB', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
113
  $doVB = $ntOpt['doVB'] && (is_array($pMeta) || $ntOpt['catSel']!='1');
114
  $isAvailVB = $ntOpt['vbUName']!='' && $ntOpt['vbPass']!=''; $vbMsgFormat = htmlentities($ntOpt['vbMsgFormat'], ENT_COMPAT, "UTF-8"); $vbMsgTFormat = htmlentities($ntOpt['vbMsgTFormat'], ENT_COMPAT, "UTF-8");
@@ -119,7 +147,7 @@ if (!class_exists("nxs_snapClassVB")) { class nxs_snapClassVB {
119
 
120
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/vb16.png);">vBulletin - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
121
  if ($post->post_status == "publish" && $isAvailVB) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToVB_repostButton" id="rePostToVB_button" value="<?php _e('Repost to vBulletin', 'nxs_snap') ?>" />
122
- <?php wp_nonce_field( 'rePostToVB', 'rePostToVB_wpnonce' ); } ?>
123
 
124
  <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) { $wpURL = str_ireplace('/xmlrpc.php', '', $ntOpt['vbURL']);
125
  if (substr($wpURL, -1)=='/') $wpURL = substr($wpURL, 0, -1); $wpURL = $wpURL."/";
@@ -130,7 +158,15 @@ if (!class_exists("nxs_snapClassVB")) { class nxs_snapClassVB {
130
  </td></tr>
131
 
132
  <?php if (!$isAvailVB) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your vBulletin Account to AutoPost to vBulletin</b>
133
- <?php } elseif ($post->post_status != "puZblish") { ?>
 
 
 
 
 
 
 
 
134
 
135
  <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top:6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Text Format:', 'nxs_snap') ?></th>
136
  <td><input value="<?php echo $vbMsgTFormat ?>" type="text" name="vb[<?php echo $ii; ?>][SNAPformatT]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apVBMsgTFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apVBMsgTFrmt".$ii); ?></td></tr>
@@ -146,13 +182,15 @@ if (!class_exists("nxs_snapClassVB")) { class nxs_snapClassVB {
146
  function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
147
  if (isset($pMeta['SNAPformat'])) $optMt['vbMsgFormat'] = $pMeta['SNAPformat'];
148
  if (isset($pMeta['SNAPformatT'])) $optMt['vbMsgTFormat'] = $pMeta['SNAPformatT'];
 
 
149
  if (isset($pMeta['doVB'])) $optMt['doVB'] = $pMeta['doVB'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doVB'] = 0; }
150
  if (isset($pMeta['SNAPincludeVB']) && $pMeta['SNAPincludeVB'] == '1' ) $optMt['doVB'] = 1;
151
  return $optMt;
152
  }
153
  }}
154
  if (!function_exists("nxs_rePostToVB_ajax")) {
155
- function nxs_rePostToVB_ajax() { check_ajax_referer('rePostToVB'); $postID = $_POST['id']; $options = get_option('NS_SNAutoPoster');
156
  foreach ($options['vb'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj'; //if ($two['gpPageID'].$two['gpUName']==$_POST['nid']) {
157
  $gppo = get_post_meta($postID, 'snapVB', true); $gppo = maybe_unserialize($gppo);// prr($gppo);
158
  if (is_array($gppo) && isset($gppo[$ii]) && is_array($gppo[$ii])){ $ntClInst = new nxs_snapClassVB(); $two = $ntClInst->adjMetaOpt($two, $gppo[$ii]); }
@@ -161,85 +199,13 @@ if (!function_exists("nxs_rePostToVB_ajax")) {
161
  }
162
  }
163
 
164
- if (!function_exists("nxs_getVBHeaders")) { function nxs_getVBHeaders($ref, $post=false){ $hdrsArr = array();
165
- $hdrsArr['X-Requested-With']='XMLHttpRequest'; $hdrsArr['Connection']='keep-alive'; $hdrsArr['Referer']=$ref;
166
- $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';
167
- if($post) $hdrsArr['Content-Type']='application/x-www-form-urlencoded';
168
- $hdrsArr['Accept']='application/json, text/javascript, */*; q=0.01';
169
- $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;
170
- }}
171
- if (!function_exists("nxs_doCheckVB")) {function nxs_doCheckVB($url){ global $nxs_vbCkArray; $hdrsArr = nxs_getVBHeaders($url); $ckArr = $nxs_vbCkArray;
172
- $response = wp_remote_get($url, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr));
173
- if (stripos($response['body'],'logouthash=')===false) return 'Bad Saved Login';
174
- if ( stripos($response['body'], 'usercp.php')!==false && stripos($response['body'], 'logouthash')!==false){ /*echo "You are IN"; */ return false;
175
- } else return 'No Saved Login';
176
- return false;
177
- }}
178
- if (!function_exists("nxs_doConnectToVB")) { function nxs_doConnectToVB($u, $p, $url){ global $nxs_vbCkArray; $hdrsArr = nxs_getVBHeaders($url, true); // echo "LOGGIN";
179
- $response = wp_remote_get($url); if(is_wp_error($response)) { nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($response, true), ''); return "Invalid Connection. Please see log."; }
180
- $contents = $response['body']; //$response['body'] = htmlentities($response['body']); prr($response); die();
181
- $ckArr = $response['cookies']; $mdhashLoc = stripos($contents, 'md5hash(vb_login_password');
182
- if ($mdhashLoc===false) return "No VB found";
183
- $frmTxt = CutFromTo($contents, 'md5hash(vb_login_password','</form>'); $md = array(); $flds = array();
184
- while (stripos($frmTxt, '<input')!==false){ $inpField = trim(CutFromTo($frmTxt,'<input', '>')); $name = trim(CutFromTo($inpField,'name="', '"'));
185
- if ( stripos($inpField, '"hidden"')!==false && $name!='' && !in_array($name, $md)) { $md[] = $name; $val = trim(CutFromTo($inpField,'value="', '"')); $flds[$name]= $val; $mids .= "&".$name."=".$val;}
186
- $frmTxt = substr($frmTxt, stripos($frmTxt, '<input')+8);
187
- } $flds['vb_login_username'] = $u; $flds['vb_login_md5password'] = md5($p); $flds['vb_login_md5password_utf'] = md5($p); $flds['cookieuser'] = '1'; $flds['do'] = 'login';
188
-
189
- // $logURL = substr($contents, $mdhashLoc-250, 250); $logURL = CutFromTo($logURL, 'action="', '"');
190
- if (stripos($contents, 'base href="')!==false) $baseURL = trim(CutFromTo($contents,'base href="', '"')); else { $uarr = explode('/',$url); $dd = $uarr[count($uarr)-1]; $baseURL = str_replace($dd, '', $url);}
191
-
192
- //echo $baseURL.'login.php?do=login'; prr($flds);
193
- $r2 = wp_remote_post( $baseURL.'login.php?do=login', array( 'method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds, 'cookies' => $ckArr));
194
-
195
- //$r2['body'] = htmlentities($r2['body']); prr($r2);
196
-
197
- if (stripos($r2['body'],'exec_refresh()')!==false) { $ckArr = nxsMergeArraysOV($ckArr, $r2['cookies']); $nxs_vbCkArray = $ckArr; return false; } else return "Bad Username/Password";
198
- }}
199
- if (!function_exists("nxs_doPostToVB")) { function nxs_doPostToVB($url, $subj, $msg, $lnk, $tags){ global $nxs_vbCkArray; $hdrsArr = nxs_getVBHeaders($url); $ckArr = $nxs_vbCkArray;
200
- $response = wp_remote_get($url, array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr));
201
- if(is_wp_error($response)) { nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($response, true), ''); return "Invalid Connection. Please see log."; }
202
- $contents = $response['body']; //$response['body'] = htmlentities($response['body']); prr($response); die();
203
- if (stripos($contents, 'base href="')!==false) $baseURL = trim(CutFromTo($contents,'base href="', '"')); else { $uarr = explode('/',$url); $dd = $uarr[count($uarr)-1]; $baseURL = str_replace($dd, '', $url);}
204
- if (stripos($contents, 'newthread.php?do=newthread')!==false) $mdd='t'; elseif (stripos($contents, 'newreply.php?')!==false) $mdd='p'; else return "No Thread/Post Controls found";
205
-
206
- if ($mdd=='t'){ $fid = CutFromTo($contents, 'newthread.php?do=newthread','"'); // echo $baseURL.'newthread.php?do=newthread'.str_replace('&amp;','&',$fid);
207
- $response = wp_remote_get( $baseURL.'newthread.php?do=newthread'.str_replace('&amp;','&',$fid), array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr)); $contents = $response['body'];
208
- $frmTxt = CutFromTo($contents, 'newthread.php?do=postthread','</form>'); $md = array(); $flds = array(); //prr($frmTxt);
209
- while (stripos($frmTxt, '<input')!==false){ $inpField = trim(CutFromTo($frmTxt,'<input', '>')); $name = trim(CutFromTo($inpField,'name="', '"'));
210
- if ( stripos($inpField, '"hidden"')!==false && $name!='' && !in_array($name, $md)) { $md[] = $name; $val = trim(CutFromTo($inpField,'value="', '"')); $flds[$name]= $val; $mids .= "&".$name."=".$val;}
211
- $frmTxt = substr($frmTxt, stripos($frmTxt, '<input')+8);
212
- } $flds['subject'] = $subj; $flds['message'] = $msg; $flds['message_backup'] = $msg; $flds['wysiwyg'] = '1'; $flds['do'] = 'postthread'; $flds['taglist'] = $tags; $flds['parseurl'] = '1'; $flds['sbutton'] = 'Submit+New+Thread';
213
- $smURL = $baseURL.'newthread.php?do=postthread'.str_replace('&amp;','&',$fid);
214
- } //prr($flds);
215
- if ($mdd=='p'){ $fid = CutFromTo($contents, 'newreply.php?do=newreply','"');
216
- $response = wp_remote_get( $baseURL.'newreply.php?do=newreply'.str_replace('&amp;','&',$fid), array( 'method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr)); $contents = $response['body'];
217
-
218
- $frmTxt = CutFromTo($contents, 'newreply.php?do=postreply','</form>'); $md = array(); $flds = array(); //prr($frmTxt);
219
-
220
- while (stripos($frmTxt, '<input')!==false){ $inpField = trim(CutFromTo($frmTxt,'<input', '>')); $name = trim(CutFromTo($inpField,'name="', '"'));
221
- if ( stripos($inpField, '"hidden"')!==false && $name!='' && !in_array($name, $md)) { $md[] = $name; $val = trim(CutFromTo($inpField,'value="', '"')); $flds[$name]= $val; $mids .= "&".$name."=".$val;}
222
- $frmTxt = substr($frmTxt, stripos($frmTxt, '<input')+8);
223
- } $flds['title'] = $subj; $flds['message'] = $msg; $flds['message_backup'] = $msg; $flds['wysiwyg'] = '1'; $flds['do'] = 'postreply'; $flds['parseurl'] = '1'; $flds['sbutton'] = 'Submit+Reply';
224
- $smURL = $baseURL.'newreply.php?do=postreply'.str_replace('&amp;','&',$fid);
225
- }
226
-
227
- //echo $smURL."|"; prr($flds);
228
- $r2 = wp_remote_post( $smURL, array( 'method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds, 'cookies' => $ckArr));// prr($r2['response']); prr(htmlentities($r2['body'])); $r2['body'] = ''; prr($r2); die();
229
- if (stripos($r2['body'], 'errorblock')!==false) return trim(strip_tags( CutFromTo($r2['body'], 'errorblock','</div>')));
230
- if (stripos($r2['body'], 'exec_refresh()')!==false && stripos($r2['body'], 'blockrow restore">')!==false) return trim(strip_tags( CutFromTo($r2['body'], 'blockrow restore">','</p>')));
231
- if (stripos($r2['body'], '<error>')!==false) return trim(strip_tags( CutFromTo($r2['body'], '<error>','</error>')));
232
- if ( $r2['response']['code']=='302' || $r2['response']['code']=='303') { return array("code"=>"OK", "post_id"=>$r2['headers']['location']); }
233
- if (stripos($r2['body'], '<newpostid>')!==false || stripos($r2['body'], 'postbit postid="')!==false ) return 'OK';
234
-
235
- // $r2['body'] = htmlentities($r2['body']); prr($r2); die();
236
-
237
- return "Something wrong";
238
- }}
239
-
240
  if (!function_exists("nxs_doPublishToVB")) { //## Second Function to Post to VB
241
- function nxs_doPublishToVB($postID, $options){ global $nxs_vbCkArray; $ntCd = 'VB'; $ntCdL = 'vb'; $ntNm = 'vBulletin';
 
242
  //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToVB', array($postID, $options));
 
 
 
243
  $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
244
  $logNT = '<span style="color:#000080">vBulletin</span> - '.$options['nName'];
245
  $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
@@ -249,29 +215,39 @@ if (!function_exists("nxs_doPublishToVB")) { //## Second Function to Post to VB
249
  }
250
  }
251
 
252
- $vbCat = $options['vbCat']; $email = $options['vbUName']; $pass = (substr($options['vbPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['vbPass'], 5)):$options['vbPass']);
253
- if ($postID=='0') { echo "Testing ... <br/><br/>"; $link = home_url(); $msg = 'Test Message from '.$link; $msgT = 'Test Link from '.$link; }
254
- else { $post = get_post($postID); if(!$post) return; $link = get_permalink($postID); nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
255
- $msgFormat = $options['vbMsgFormat']; $msg = nsFormatMessage($msgFormat, $postID); $msgFormatT = $options['vbMsgTFormat']; $msgT = nsFormatMessage($msgFormatT, $postID);
 
 
 
 
256
  }
257
  $dusername = $options['vbUName']; //$link = urlencode($link); $desc = urlencode(substr($msg, 0, 500));
258
- $extInfo = ' | PostID: '.$postID." - ".$post->post_title;
259
- if ($options['vbInclTags']=='1') { $t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = urlencode(implode(', ',$tggs)); $tags = str_replace(' ','+',$tags); } else $tags = '';
260
- if (isset($options['vbSvC'])) $nxs_vbCkArray = maybe_unserialize( $options['vbSvC']); $loginError = true;
261
- if (is_array($nxs_vbCkArray)) $loginError = nxs_doCheckVB( $options['vbURL']); if ($loginError!==false) $loginError = nxs_doConnectToVB($email, $pass, $options['vbURL']);
262
- if (serialize($nxs_vbCkArray)!=$options['vbSvC']) { global $plgn_NS_SNAutoPoster; $gOptions = $plgn_NS_SNAutoPoster->nxs_options;
 
 
 
 
263
  if (isset($options['ii']) && $options['ii']!=='') { $gOptions['vb'][$options['ii']]['vbSvC'] = serialize($nxs_vbCkArray); update_option('NS_SNAutoPoster', $gOptions); }
264
  else foreach ($gOptions['vb'] as $ii=>$gpn) { $result = array_diff($options, $gpn);
265
  if (!is_array($result) || count($result)<1) { $gOptions['vb'][$ii]['vbSvC'] = serialize($nxs_vbCkArray); update_option('NS_SNAutoPoster', $gOptions); break; }
266
  }
267
- } //var_dump($loginError);
268
- if ($loginError!==false) {if ($postID=='0') prr($loginError); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($loginError, true)." - BAD USER/PASS", $extInfo); return " -= BAD USER/PASS =- ";}
269
- $ret = nxs_doPostToVB($options['vbURL'], $msgT, $msg, $link, $tags);
270
- if ( (!is_array($ret)) && $ret!='OK'){ if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);}
271
- else if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo ' OK - Message Posted, please see your vBulletin Page '; } else
272
- { nxs_metaMarkAsPosted($postID, 'VB', $options['ii'], array('isPosted'=>'1', 'pgID'=>$ret['post_id'], 'pDate'=>date('Y-m-d H:i:s'))); nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); }
273
- if ($ret['code']=='OK') return 200; else return $ret;
274
-
 
 
275
  }
276
  }
277
  ?>
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', 'nxs_snap'); echo ")"; ?></div><?php } ?>
13
  </div>
14
  </div>
15
  <div class="nxs_box_inside">
16
  <?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
17
  <p style="margin:0px;margin-left:5px;">
18
+ <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> />
19
+ <?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 } ?>
20
+ <?php if (isset($pbo['rpstOn']) && (int)$pbo['rpstOn'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popReActive');" onmouseover="nxs_showPopUpInfo('popReActive', event);"><?php echo "*[R]*" ?></span><?php } ?>
21
  <strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
22
  &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', 'nxs_snap'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>&nbsp;&nbsp;
23
  <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
24
+ </p><?php $pbo['ntInfo'] = $ntInfo; $this->showNTSettings($indx, $pbo);
25
  }?>
26
  </div>
27
  </div> <?php
28
  }
29
  //#### Show NEW Settings Page
30
+ function showNewNTSettings($mgpo){ $options = array('nName'=>'', 'doVB'=>'1', 'vbUName'=>'', 'vbInclTags'=>'1', 'vbAttch'=>'', 'vbURL'=>'', 'vbPass'=>''); $options['ntInfo']= array('lcode'=>'vb'); $this->showNTSettings($mgpo, $options, true);}
31
 
32
 
33
  //#### Show Unit Settings
34
+ function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl; $nt = $options['ntInfo']['lcode']; $ntU = strtoupper($nt);
35
+ 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'] = '';
36
+ if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; ?>
37
+ <div id="doVB<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>"> <input type="hidden" name="apDoSVB<?php echo $ii; ?>" value="0" id="apDoSVB<?php echo $ii; ?>" />
38
 
39
  <div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/vb16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-vbulletin-social-networks-auto-poster-wordpress/"><?php $nType="vBulletin"; printf( __( 'Detailed %s Installation/Configuration Instructions', 'nxs_snap' ), $nType); ?></a></div>
40
 
41
+ <div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'nxs_snap'); ?></i> </div><input name="vb[<?php echo $ii; ?>][nName]" id="vbnName<?php echo $ii; ?>" style="font-weight: bold; color: #005800; border: 1px solid #ACACAC; width: 40%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['nName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /><br/>
42
+ <?php echo nxs_addQTranslSel('vb', $ii, $options['qTLng']); ?>
43
 
44
+ <br/>
45
+ <ul class="nsx_tabs">
46
+ <li><a href="#nsx<?php echo $nt.$ii ?>_tab1"><?php _e('Account Info', 'nxs_snap'); ?></a></li>
47
+ <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'nxs_snap'); ?></a></li>
48
+ </ul>
49
+ <div class="nsx_tab_container"><?php /* ######################## Account Tab ####################### */ ?>
50
+ <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%;">
51
+
52
 
53
  <div id="altFormat" style="">
54
  <div style="width:100%;"><strong id="altFormatText">vBulletin URL:</strong> <span style="font-size: 11px; margin: 0px;">Could be Forum URL or Thread URL. Either new thread of new post will be created.</span></div>
82
  </div><br/>
83
 
84
  <?php if ($options['vbPass']!='') { ?>
85
+
86
  <b><?php _e('Test your settings', 'nxs_snap'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('VB', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'nxs_snap' ), $nType); ?></a>
87
 
88
  <?php }
89
 
90
+ ?></div>
91
+ <?php /* ######################## Advanced Tab ####################### */ ?>
92
+ <div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content">
93
+
94
+ <?php if (!$isNew) { ?> <div class="nxs_tls_cpt"><?php _e('Categories', 'nxs_snap'); ?></div>
95
+ <div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
96
+ <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
97
+ <input value="1" id="catSelS<?php echo $ntU; ?><?php echo $ii; ?>" type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_<?php echo $ntU; ?><?php echo $ii; ?>" onclick="jQuery('#catSelS<?php echo $ntU; ?><?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('<?php echo $ntU; ?><?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($options['catSelEd']!='') echo "[".(substr_count($options['catSelEd'], ",")+1)."]"; ?></a>
98
+ <input type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
99
+ <br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
100
+ <br/>
101
+ <?php } ?>
102
+
103
+ <?php nxs_addPostingDelaySelV3($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']); ?>
104
+ <?php nxs_showRepostSettings($nt, $ii, $options); ?>
105
+
106
+
107
+ </div> <?php /* #### End of Tab #### */ ?>
108
+ </div><br/> <?php /* #### End of Tabs #### */ ?>
109
+
110
+ <div class="submit clear" style="padding-bottom: 0px;"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div></div><?php
111
  }
112
  //#### Set Unit Settings from POST
113
  function setNTSettings($post, $options){ global $nxs_snapThisPageUrl; $code = 'VB'; $lcode = 'vb';
126
  if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
127
 
128
  if (isset($pval['apDoVB'])) $options[$ii]['doVB'] = $pval['apDoVB']; else $options[$ii]['doVB'] = 0;
129
+
130
+ $options[$ii] = nxs_adjRpst($options[$ii], $pval);
131
+
132
+ if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']);
133
  if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
134
  if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
135
  }
136
  } return $options;
137
  }
138
  //#### Show Post->Edit Meta Box Settings
139
+ function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID; $nt = 'vb'; $ntU = 'VB';
140
  foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapVB', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
141
  $doVB = $ntOpt['doVB'] && (is_array($pMeta) || $ntOpt['catSel']!='1');
142
  $isAvailVB = $ntOpt['vbUName']!='' && $ntOpt['vbPass']!=''; $vbMsgFormat = htmlentities($ntOpt['vbMsgFormat'], ENT_COMPAT, "UTF-8"); $vbMsgTFormat = htmlentities($ntOpt['vbMsgTFormat'], ENT_COMPAT, "UTF-8");
147
 
148
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/vb16.png);">vBulletin - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
149
  if ($post->post_status == "publish" && $isAvailVB) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToVB_repostButton" id="rePostToVB_button" value="<?php _e('Repost to vBulletin', 'nxs_snap') ?>" />
150
+ <?php } ?>
151
 
152
  <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) { $wpURL = str_ireplace('/xmlrpc.php', '', $ntOpt['vbURL']);
153
  if (substr($wpURL, -1)=='/') $wpURL = substr($wpURL, 0, -1); $wpURL = $wpURL."/";
158
  </td></tr>
159
 
160
  <?php if (!$isAvailVB) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your vBulletin Account to AutoPost to vBulletin</b>
161
+ <?php } else { if ($post->post_status != "publish" && function_exists('nxs_doSMAS5') ) { nxs_doSMAS5($nt, $ii, $ntOpt); } ?>
162
+
163
+ <?php if ($ntOpt['rpstOn']=='1') { ?>
164
+
165
+ <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top:6px; text-align:right; width:60px; padding-right:10px;">
166
+ <input value="0" type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]"/><input value="nxsi<?php echo $ii; ?>vb" type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]" <?php if (!empty($ntOpt['rpstPostIncl'])) echo "checked"; ?> />
167
+ </th>
168
+ <td> <?php _e('Include in "Auto-Reposting" to this network.', 'nxs_snap') ?>
169
+ </td></tr> <?php } ?>
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:', 'nxs_snap') ?></th>
172
  <td><input value="<?php echo $vbMsgTFormat ?>" type="text" name="vb[<?php echo $ii; ?>][SNAPformatT]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apVBMsgTFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apVBMsgTFrmt".$ii); ?></td></tr>
182
  function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
183
  if (isset($pMeta['SNAPformat'])) $optMt['vbMsgFormat'] = $pMeta['SNAPformat'];
184
  if (isset($pMeta['SNAPformatT'])) $optMt['vbMsgTFormat'] = $pMeta['SNAPformatT'];
185
+ if (isset($pMeta['imgToUse'])) $optMt['imgToUse'] = $pMeta['imgToUse'];
186
+ if (isset($pMeta['timeToRun'])) $optMt['timeToRun'] = $pMeta['timeToRun']; if (isset($pMeta['rpstPostIncl'])) $optMt['rpstPostIncl'] = $pMeta['rpstPostIncl'];
187
  if (isset($pMeta['doVB'])) $optMt['doVB'] = $pMeta['doVB'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doVB'] = 0; }
188
  if (isset($pMeta['SNAPincludeVB']) && $pMeta['SNAPincludeVB'] == '1' ) $optMt['doVB'] = 1;
189
  return $optMt;
190
  }
191
  }}
192
  if (!function_exists("nxs_rePostToVB_ajax")) {
193
+ function nxs_rePostToVB_ajax() { check_ajax_referer('nxsSsPageWPN'); $postID = $_POST['id']; $options = get_option('NS_SNAutoPoster');
194
  foreach ($options['vb'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj'; //if ($two['gpPageID'].$two['gpUName']==$_POST['nid']) {
195
  $gppo = get_post_meta($postID, 'snapVB', true); $gppo = maybe_unserialize($gppo);// prr($gppo);
196
  if (is_array($gppo) && isset($gppo[$ii]) && is_array($gppo[$ii])){ $ntClInst = new nxs_snapClassVB(); $two = $ntClInst->adjMetaOpt($two, $gppo[$ii]); }
199
  }
200
  }
201
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
202
  if (!function_exists("nxs_doPublishToVB")) { //## Second Function to Post to VB
203
+ function nxs_doPublishToVB($postID, $options){ global $nxs_vbCkArray, $plgn_NS_SNAutoPoster; $ntCd = 'VB'; $ntCdL = 'vb'; $ntNm = 'vBulletin';
204
+ if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
205
  //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToVB', array($postID, $options));
206
+ $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url();
207
+ $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'POSTID'=>$postID, 'ACCNAME'=>$options['nName']));
208
+
209
  $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
210
  $logNT = '<span style="color:#000080">vBulletin</span> - '.$options['nName'];
211
  $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
215
  }
216
  }
217
 
218
+
219
+ if ($postID=='0') { echo "Testing ... <br/><br/>"; $urlToGo = home_url(); $options['vbMsgFormat'] = 'Test Message from '.$urlToGo; $options['vbMsgTFormat'] = 'Test Link from '.$urlToGo; }
220
+ else { $post = get_post($postID); nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
221
+ $options['vbMsgFormat'] = nsFormatMessage($options['vbMsgFormat'], $postID, $addParams); $options['vbMsgTFormat'] = nsFormatMessage($options['vbMsgTFormat'], $postID, $addParams);
222
+ //## MyURL - URLToGo code
223
+ if (!isset($options['urlToUse']) || trim($options['urlToUse'])=='') $myurl = trim(get_post_meta($postID, 'snap_MYURL', true)); if ($myurl!='') $options['urlToUse'] = $myurl;
224
+ if (isset($options['urlToUse']) && trim($options['urlToUse'])!='') { $urlToGo = $options['urlToUse']; $options['useFBGURLInfo'] = true; } else $urlToGo = get_permalink($postID);
225
+ $gOptions = $plgn_NS_SNAutoPoster->nxs_options; $addURLParams = trim($gOptions['addURLParams']); if($addURLParams!='') $urlToGo .= (strpos($urlToGo,'?')!==false?'&':'?').$addURLParams;
226
  }
227
  $dusername = $options['vbUName']; //$link = urlencode($link); $desc = urlencode(substr($msg, 0, 500));
228
+ $extInfo = ' | PostID: '.$postID." - ".(!empty($post) && is_object($post)?$post->post_title:'');
229
+
230
+ //## Message & Format
231
+ if ($options['vbInclTags']=='1') { $t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = (implode(', ',$tggs)); /* $tags = str_replace(' ','+',$tags); */ } else $tags = '';
232
+ $message = array('siteName'=>$blogTitle, 'tags'=>$tags);
233
+ //## Actual Post
234
+ $ntToPost = new nxs_class_SNAP_VB(); $ret = $ntToPost->doPostToNT($options, $message);
235
+ //## Save Session
236
+ if (empty($options['vkSvC']) || serialize($nxs_vbCkArray)!=$options['vbSvC']) { global $plgn_NS_SNAutoPoster; $gOptions = $plgn_NS_SNAutoPoster->nxs_options;
237
  if (isset($options['ii']) && $options['ii']!=='') { $gOptions['vb'][$options['ii']]['vbSvC'] = serialize($nxs_vbCkArray); update_option('NS_SNAutoPoster', $gOptions); }
238
  else foreach ($gOptions['vb'] as $ii=>$gpn) { $result = array_diff($options, $gpn);
239
  if (!is_array($result) || count($result)<1) { $gOptions['vb'][$ii]['vbSvC'] = serialize($nxs_vbCkArray); update_option('NS_SNAutoPoster', $gOptions); break; }
240
  }
241
+ }
242
+ //## Process Results
243
+ if (!is_array($ret) || $ret['isPosted']!='1') { //## Error
244
+ if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);
245
+ } else { // ## All Good - log it.
246
+ if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo _e('OK - Message Posted, please see your '.$logNT.' Page. ', 'nxs_snap'); }
247
+ 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); }
248
+ }
249
+ //## Return Result
250
+ if ($ret['isPosted']=='1') return 200; else return print_r($ret, true);
251
  }
252
  }
253
  ?>
inc-cl/vk.api.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //## NextScripts FriendFeed Connection Class
3
+ $nxs_snapAPINts[] = array('code'=>'VK', 'lcode'=>'vk', 'name'=>'vKontakte(VK)');
4
+
5
+ if (!class_exists("nxs_class_SNAP_VK")) { class nxs_class_SNAP_VK {
6
+
7
+ var $ntCode = 'VK';
8
+ var $ntLCode = 'vk';
9
+
10
+ function doPost($options, $message){ if (!is_array($options)) return false;
11
+ foreach ($options as $ntOpts) $out[] = $this->doPostToNT($ntOpts, $message);
12
+ return $out;
13
+ }
14
+ function nxs_uplImgtoVK($imgURL, $options){
15
+ $postUrl = 'https://api.vkontakte.ru/method/photos.getWallUploadServer?gid='.(str_replace('-','',$options['pgIntID'])).'&access_token='.$options['vkAppAuthToken'];
16
+ $response = wp_remote_get($postUrl); $thumbUploadUrl = $response['body'];
17
+ if (!empty($thumbUploadUrl)) { $thumbUploadUrlObj = json_decode($thumbUploadUrl); $VKuploadUrl = $thumbUploadUrlObj->response->upload_url; }
18
+ if (!empty($VKuploadUrl)) {
19
+ $remImgURL = urldecode($imgURL); $urlParced = pathinfo($remImgURL); $remImgURLFilename = $urlParced['basename']; $imgData = wp_remote_get($remImgURL); $imgData = $imgData['body'];
20
+ $tmp=array_search('uri', @array_flip(stream_get_meta_data($GLOBALS[mt_rand()]=tmpfile())));
21
+ if (!is_writable($tmp)) return "Your temporary folder or file (file - ".$tmp.") is not witable. Can't upload image to VK";
22
+ rename($tmp, $tmp.='.png'); register_shutdown_function(create_function('', "unlink('{$tmp}');"));
23
+ file_put_contents($tmp, $imgData);
24
+
25
+ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $VKuploadUrl); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
26
+ curl_setopt($ch, CURLOPT_POSTFIELDS, array('photo' => '@' . $tmp)); $response = curl_exec($ch); $errmsg = curl_error($ch); curl_close($ch); //prr($response);
27
+
28
+ $uploadResultObj = json_decode($response); // prr($response); //prr($uploadResultObj);
29
+
30
+ if (!empty($uploadResultObj->server) && !empty($uploadResultObj->photo) && !empty($uploadResultObj->hash)) {
31
+ $postUrl = 'https://api.vkontakte.ru/method/photos.saveWallPhoto?server='.$uploadResultObj->server.'&photo='.$uploadResultObj->photo.'&hash='.$uploadResultObj->hash.'&gid='.(str_replace('-','',$options['pgIntID'])).'&access_token='.$options['vkAppAuthToken'];
32
+ $response = wp_remote_get($postUrl);
33
+ $resultObject = json_decode($response['body']); //prr($resultObject);
34
+ if (isset($resultObject) && isset($resultObject->response[0]->id)) { return $resultObject->response[0]; } else { return false; }
35
+ }
36
+ }
37
+ }
38
+ function doPostToNT($options, $message){ $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>''); global $nxs_vkCkArray;
39
+ //## Check settings
40
+ if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
41
+ if ((!isset($options['uName']) || trim($options['uPass'])=='') && (!isset($options['vkAppAuthToken']) || trim($options['vkAppAuthToken'])=='')) { $badOut['Error'] = 'Not Configured'; return $badOut; }
42
+ $pass = (substr($options['uPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['uPass'], 5)):$options['uPass']);
43
+ //## Format
44
+ $msg = nxs_doFormatMsg($options['msgFrmt'], $message); $urlToGo = (!empty($message['url']))?$message['url']:'';
45
+
46
+ $postType = $options['postType']; //$link = urlencode($link); $desc = urlencode(substr($msg, 0, 500));
47
+
48
+ if (isset($message['imageURL'])) $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); else $imgURL = '';
49
+ $msgOpts = array(); $msgOpts['uid'] = $options['vkPgID']; // if ($link!='') $msgOpts['link'] = $link;
50
+ if (!empty($message['videoURL']) && $postType=="I") { $postType='A'; $urlToGo=$message['videoURL']; $msgOpts['vID'] = $vids[0]; }
51
+ if ($postType=='I' && trim($imgURL)=='') $postType='T'; $msgOpts['type'] = $postType;
52
+ if (function_exists('nxs_doPostToVK') && $postType=='A' && $urlToGo!='') {
53
+ //## Login
54
+ if (isset($options['vkSvC'])) $nxs_vkCkArray = maybe_unserialize( $options['vkSvC']); $loginError = true;
55
+ if (is_array($nxs_vkCkArray)) $loginError = nxs_doCheckVK(); if ($loginError!=false) {
56
+ if (!empty($options['vkPh'])) { $ph = str_replace('+','',$options['vkPh']); $ph = substr($ph,2,-2);} else $ph = ''; $loginError = nxs_doConnectToVK($options['uName'], $pass, $ph);
57
+ } // prr($loginError);
58
+ if ($loginError!==false) { if (stripos($loginError, 'Phone verification required:')!==false) return $loginError; else return "ERROR - BAD USER/PASS - ".print_r($loginError, true); }
59
+ //## Post
60
+ $msgOpts['url'] = $urlToGo; $msgOpts['urlTitle'] = $message['urlTitle']; $msgOpts['urlDesc'] = $message['urlDescr']; $msgOpts['imgURL'] = $imgURL;
61
+ $ret = nxs_doPostToVK($msg, $options['url'], $msgOpts);
62
+ if (is_array($ret) && !empty($ret['code']) && $ret['code']=='OK') return array('postID'=>$ret['post_id'], 'isPosted'=>1, 'postURL'=>'http://vk.com/wall'.$ret['post_id'], 'pDate'=>date('Y-m-d H:i:s'));
63
+ else $badOut .= 'ERROR: '.print_r($ret, true);
64
+ } //prr($postType);
65
+
66
+ if ($postType=='I') { $imgUpld = $this->nxs_uplImgtoVK($imgURL, $options); if (is_object($imgUpld)) { $imgID = $imgUpld->id; $atts[] = $imgID; } else $badOut['Error'] .= '-=ERROR=- '.print_r($imgUpld, true); }
67
+ if ($postType!='A') { if( $options['addBackLink']=='1') $atts[] = $urlToGo;
68
+ if (is_array($atts)) $atts = implode(',', $atts);
69
+
70
+ $postUrl = 'https://api.vkontakte.ru/method/wall.post';
71
+ $postArr = array('owner_id'=>$options['pgIntID'], 'access_token'=>$options['vkAppAuthToken'], 'from_group'=>'1', 'message'=>$msg, 'attachment'=>$atts);
72
+ $response = wp_remote_post($postUrl, array('body' => $postArr));
73
+ if ( is_wp_error($response) || (is_object($response) && (isset($response->errors))) || (is_array($response) && stripos($response['body'],'"error":')!==false )) {
74
+ $badOut['Error'] .= 'Error: '. print_r($response['body'], true);
75
+ } else { $respJ = json_decode($response['body'], true); $ret = $options['pgIntID'].'_'.$respJ['response']['post_id']; }
76
+
77
+ }
78
+ if (isset($ret) && $ret!='') return array('postID'=>$ret, 'isPosted'=>1, 'postURL'=>'http://vk.com/wall'.$ret, 'pDate'=>date('Y-m-d H:i:s'));
79
+ return $badOut;
80
+ }
81
+ }}
82
+ ?>
inc-cl/vk.php CHANGED
@@ -8,29 +8,32 @@ if (!class_exists("nxs_snapClassVK")) { class nxs_snapClassVK {
8
  <div class="nxs_box">
9
  <div class="nxs_box_header">
10
  <div class="nsx_iconedTitle" style="margin-bottom:1px;background-image:url(<?php echo $nxs_plurl;?>img/<?php echo $ntInfo['lcode']; ?>16.png);"><?php echo $ntInfo['name']; ?>
11
- <?php $cbo = count($ntOpts); ?> <?php wp_nonce_field( 'ns'.$ntInfo['code'], 'ns'.$ntInfo['code'].'_wpnonce' ); ?>
12
  <?php if ($cbo>1){ ?><div class="nsBigText"><?php echo "(".($cbo=='0'?'No':$cbo)." "; _e('accounts', 'nxs_snap'); echo ")"; ?></div><?php } ?>
13
  </div>
14
  </div>
15
  <div class="nxs_box_inside">
16
  <?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = str_ireplace('https://vk.com','', str_ireplace('http://vk.com','', $pbo['url'])); ?>
17
  <p style="margin:0px;margin-left:5px;">
18
- <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> /> <?php if ((int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
 
 
19
  <strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
20
  &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', 'nxs_snap'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>&nbsp;&nbsp;
21
  <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
22
- </p><?php $this->showNTSettings($indx, $pbo);
23
  }?>
24
  </div>
25
  </div> <?php
26
  }
27
  //#### Show NEW Settings Page
28
- function showNewNTSettings($mNTo){ $nto = array('nName'=>'', 'doVK'=>'1', 'url'=>'', 'vkAppID'=>'', 'imgUpl'=>'1', 'addBackLink'=>'1', 'vkPostType'=>'T', 'msgAFormat'=>'', 'attch'=>'1', 'vkPgID'=>'', 'vkAppAuthUser'=>'', 'msgFrmt'=>'New post has been published on %SITENAME%' ); $this->showNTSettings($mNTo, $nto, true);}
29
  //#### Show Unit Settings
30
- function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl, $nxs_snapThisPageUrl; if ((int)$options['attch']==0 && (!isset($options['trPostType']) || $options['trPostType']=='')) $options['trPostType'] = 'T';
 
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['uName '])) $options['uName '] = ''; if (!isset($options['uPass'])) $options['uPass'] = '';
33
- ?>
34
  <div id="doVK<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>" style="background-image: url(<?php echo $nxs_plurl; ?>img/vk-bg.png); background-position:90% 10%;"> <input type="hidden" name="apDoSVK<?php echo $ii; ?>" value="0" id="apDoSVK<?php echo $ii; ?>" />
35
  <?php if ($isNew) { ?> <input type="hidden" name="vk[<?php echo $ii; ?>][apDoVK]" value="1" id="apDoNewVK<?php echo $ii; ?>" /> <?php } ?>
36
 
@@ -39,18 +42,18 @@ if (!class_exists("nxs_snapClassVK")) { class nxs_snapClassVK {
39
 
40
  </div>
41
 
42
- <div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easely identify it', 'nxs_snap'); ?></i> </div><input name="vk[<?php echo $ii; ?>][nName]" id="vknName<?php echo $ii; ?>" style="font-weight: bold; color: #005800; border: 1px solid #ACACAC; width: 40%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['nName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /><br/>
43
  <?php echo nxs_addQTranslSel('vk', $ii, $options['qTLng']); ?>
44
- <?php echo nxs_addPostingDelaySel('vk', $ii, $options['nHrs'], $options['nMin'], $options['nDays']); ?>
45
 
46
- <?php if (!$isNew) { ?>
47
- <div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
48
- <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="vk[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
49
- <input value="1" id="catSelSVK<?php echo $ii; ?>" type="radio" name="vk[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_VK<?php echo $ii; ?>" onclick="jQuery('#catSelSVK<?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('VK<?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_VK<?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($options['catSelEd']!='') echo "[".(substr_count($options['catSelEd'], ",")+1)."]"; ?></a>
50
- <input type="hidden" name="vk[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_VK<?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
51
- <br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
52
- <br/>
53
- <?php } ?>
 
54
 
55
  <div style="width:100%;"><strong>vKontakte(VK) URL:</strong> </div>
56
  <p style="font-size: 11px; margin: 0px;"><?php _e('Could be your vKontakte(VK) Profile or vKontakte(VK) Group Page', 'nxs_snap'); ?></p>
@@ -68,8 +71,7 @@ if (!class_exists("nxs_snapClassVK")) { class nxs_snapClassVK {
68
  <?php } else { if(isset($options['vkAppAuthUser']) && $options['vkAppAuthUser']>0) { ?>
69
  <?php _e('Your vKontakte(VK) Account has been authorized.'); ?> User ID: <?php _e(apply_filters('format_to_edit', htmlentities($options['vkAppAuthUser'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>.
70
  <?php _e('You can', 'nxs_snap'); ?> Re- <?php } ?>
71
- <a target="_blank" href="http://api.vkontakte.ru/oauth/authorize?client_id=<?php echo $options['vkAppID'];?>&scope=offline,wall,photos,pages&redirect_uri=http://api.vkontakte.ru/blank.html&display=page&response_type=token<?php '&auth=vk&acc='.$ii;?>">Authorize Your vKontakte(VK) Account</a>
72
- <!-- <a href="http://api.vkontakte.ru/oauth/authorize?client_id=<?php echo $options['vkAppID'];?>&scope=offline,wall,photos,pages&redirect_uri=<?php echo urlencode($nxs_snapThisPageUrl.'&auth=vk&acc='.$options['ii']);?>">Authorize Your vKontakte(VK) Account</a> -->
73
  <?php if (!isset($options['vkAppAuthUser']) || $options['vkAppAuthUser']<1) { ?> <div class="blnkg">&lt;=== <?php _e('Authorize your account', 'nxs_snap'); ?> ===</div> <?php } ?>
74
 
75
  <div style="width:100%;"><strong>vKontakte(VK) Auth Response:</strong> </div><input name="vk[<?php echo $ii; ?>][apVKAuthResp]" style="width: 50%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['apVKAuthResp'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /><br/><br/>
@@ -84,7 +86,7 @@ if (!class_exists("nxs_snapClassVK")) { class nxs_snapClassVK {
84
  <?php if( function_exists("nxs_doPostToVK")) { ?>
85
  <div style="width:100%;"><strong>vKontakte(VK) Email:</strong> </div><input name="vk[<?php echo $ii; ?>][uName]" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['uName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
86
  <div style="width:100%;"><strong>vKontakte(VK) Password:</strong> </div><input name="vk[<?php echo $ii; ?>][uPass]" type="password" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities(substr($options['uPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['uPass'], 5)):$options['uPass'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
87
- <?php if( isset($options['vkPhReq'])) { ?>
88
  <div style="width:100%;"><strong>vKontakte(VK) Phone Number (<?php _e(apply_filters('format_to_edit', htmlentities($options['vkPhReq'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>) :</strong> </div><input name="vk[<?php echo $ii; ?>][vkPh]" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['vkPh'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
89
  <?php } ?>
90
  <?php } else { ?> **** <?php _e('Please upgrade the plugin to "PRO" get NextScripts VK API', 'nxs_snap'); ?> <?php } ?>
@@ -127,10 +129,31 @@ if (!class_exists("nxs_snapClassVK")) { class nxs_snapClassVK {
127
  <?php if ($options['vkPgID']!='') {?><div style="width:100%;"><strong>Your vKontakte(VK) Page ID:</strong> <?php _e(apply_filters('format_to_edit', htmlentities($options['vkPgID'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?> </div><?php } ?>
128
 
129
  <?php if(isset($options['vkAppAuthUser']) && $options['vkAppAuthUser']>0) { ?>
130
- <?php wp_nonce_field( 'rePostToVK', 'rePostToVK_wpnonce' ); ?>
131
  <br/><br/><b><?php _e('Test your settings', 'nxs_snap'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('VK','<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'nxs_snap' ), $nType); ?></a>
132
  <?php }?>
133
- <div class="submit"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
 
135
  </div>
136
  <?php
@@ -138,15 +161,16 @@ if (!class_exists("nxs_snapClassVK")) { class nxs_snapClassVK {
138
  }
139
  //#### Set Unit Settings from POST
140
  function setNTSettings($post, $options){ global $nxs_snapThisPageUrl; $code = 'VK'; $lcode = 'vk';
141
- foreach ($post as $ii => $pval){
142
  if (isset($pval['apVKAppID']) && $pval['apVKAppID']!='') { if (!isset($options[$ii])) $options[$ii] = array();
143
  if (isset($pval['apDoVK'])) $options[$ii]['doVK'] = $pval['apDoVK']; else $options[$ii]['doVK'] = 0;
144
  if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']);
145
  if (isset($pval['apVKAppID'])) $options[$ii]['vkAppID'] = trim($pval['apVKAppID']);
146
 
147
  if (isset($pval['uName'])) $options[$ii]['uName'] = trim($pval['uName']);
148
- if (isset($pval['uPass'])) $options[$ii]['uPass'] = 'n5g9a'.nsx_doEncode($pval['uPass']); else $options[$ii]['uPass'] = '';
149
- if (isset($pval['vkPh'])) $options[$ii]['vkPh'] = trim($pval['vkPh']);
 
150
 
151
  if (isset($pval['apVKAuthResp'])) { $options[$ii]['apVKAuthResp'] = trim($pval['apVKAuthResp']);
152
  $options[$ii]['vkAppAuthToken'] = trim( CutFromTo($pval['apVKAuthResp'].'&', 'access_token=','&'));
@@ -173,7 +197,9 @@ if (!class_exists("nxs_snapClassVK")) { class nxs_snapClassVK {
173
  if (isset($pval['msgFrmt'])) $options[$ii]['msgFrmt'] = trim($pval['msgFrmt']);
174
  if (isset($pval['msgAFormat'])) $options[$ii]['msgAFormat'] = trim($pval['msgAFormat']);
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
 
@@ -187,9 +213,10 @@ if (!class_exists("nxs_snapClassVK")) { class nxs_snapClassVK {
187
  } return $options;
188
  }
189
  //#### Show Post->Edit Meta Box Settings
190
- function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
191
  foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapVK', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
192
- $doVK = $ntOpt['doVK'] && (is_array($pMeta) || $ntOpt['catSel']!='1');
 
193
  $isAvailVK = $ntOpt['url']!='' && $ntOpt['vkAppID']!='' || $ntOpt['uPass']!=''; $isAttachVK = $ntOpt['attch']; $msgFrmt = htmlentities($ntOpt['msgFrmt'], ENT_COMPAT, "UTF-8"); $postType = $ntOpt['postType'];
194
  ?>
195
  <tr><th style="text-align:left;" colspan="2"> <?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_VK<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
@@ -199,14 +226,22 @@ if (!class_exists("nxs_snapClassVK")) { class nxs_snapClassVK {
199
  <td><?php //## Only show RePost button if the post is "published"
200
  if ($post->post_status == "publish" && $isAvailVK) { ?>
201
  <input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToVK_repostButton" id="rePostToVK_button" value="<?php _e('Repost to vKontakte(VK)', 'nxs_snap') ?>" />
202
- <?php wp_nonce_field( 'rePostToVK', 'rePostToVK_wpnonce' ); } ?>
203
  <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID'])) { ?> <span id="pstdVK<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
204
  <a style="font-size: 10px;" href="http://vk.com/wall<?php echo $pMeta[$ii]['pgID']; ?>" target="_blank"><?php $nType="vKontakte(VK)"; printf( __( 'Posted on', 'nxs_snap' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
205
  </span>
206
  <?php } ?>
207
  </td></tr>
208
  <?php if (!$isAvailVK) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup and Authorize your vKontakte(VK) Account to AutoPost to vKontakte(VK)</b>
209
- <?php } elseif ($post->post_status != "puZblish") {?>
 
 
 
 
 
 
 
 
210
  <tr id="altFormat1" style=""><th scope="row" valign="top" style="vertical-align:top; padding-top:6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Message Format:', 'nxs_snap') ?></th>
211
  <td>
212
  <textarea cols="150" rows="1" id="vk<?php echo $ii; ?>SNAPformat" name="vk[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('#vk<?php echo $ii; ?>SNAPformat').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apVKTMsgFrmt<?php echo $ii; ?>');"><?php echo $msgFrmt; ?></textarea>
@@ -223,13 +258,17 @@ if (!class_exists("nxs_snapClassVK")) { class nxs_snapClassVK {
223
  <?php if( function_exists("nxs_doPostToVK")) { ?> <br/>
224
  <input type="radio" name="vk[<?php echo $ii; ?>][PostType]" value="A" <?php if ( !isset($postType) || $postType == '' || $postType == 'A') echo 'checked="checked"'; ?> /> <?php _e('Text Post with "attached" blogpost', 'nxs_snap') ?>
225
  <?php } ?><br/><div class="popShAtt" id="popShAtt<?php echo $ii; ?>VKX"><h3>vKontakte(VK) <?php _e('Post Types', 'nxs_snap') ?></h3><img src="<?php echo $nxs_plurl; ?>img/vkPostTypesDiff6.png" width="600" height="257" alt="<?php _e('Post Types', 'nxs_snap') ?>"/></div>
226
- </td></tr><?php }
 
 
 
227
  }
228
 
229
  }
230
 
231
  function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
232
  if (isset($pMeta['SNAPformat'])) $optMt['msgFrmt'] = $pMeta['SNAPformat'];
 
233
  if (isset($pMeta['AttachPost'])) $optMt['attch'] = ($pMeta['AttachPost'] != '')?$pMeta['AttachPost']:0; else { if (isset($pMeta['SNAPformat'])) $optMt['attch'] = 0; }
234
  if (isset($pMeta['addBackLink'])) $optMt['addBackLink'] = ($pMeta['addBackLink'] != '')?$pMeta['addBackLink']:0; else { if (isset($pMeta['SNAPformat'])) $optMt['addBackLink'] = 0; }
235
  if (isset($pMeta['PostType'])) $optMt['postType'] = ($pMeta['PostType'] != '')?$pMeta['PostType']:0; else { if (isset($pMeta['SNAPformat'])) $optMt['postType'] = 'T'; }
@@ -239,7 +278,7 @@ if (!class_exists("nxs_snapClassVK")) { class nxs_snapClassVK {
239
  }
240
  }}
241
 
242
- if (!function_exists("nxs_rePostToVK_ajax")) { function nxs_rePostToVK_ajax() { check_ajax_referer('rePostToVK'); $postID = $_POST['id']; // $result = nsPublishTo($id, 'VK', true);
243
  $options = get_option('NS_SNAutoPoster'); foreach ($options['vk'] as $ii=>$nto) if ($ii==$_POST['nid']) { $nto['ii'] = $ii; $nto['pType'] = 'aj';
244
  $ntpo = get_post_meta($postID, 'snapVK', true); /* echo $postID."|"; echo $fbpo; */ $ntpo = maybe_unserialize($ntpo); // prr($ntpo);
245
  if (is_array($ntpo) && isset($ntpo[$ii]) && is_array($ntpo[$ii]) ){ $ntClInst = new nxs_snapClassVK(); $nto = $ntClInst->adjMetaOpt($nto, $ntpo[$ii]); } //prr($nto);
@@ -254,38 +293,19 @@ if (!function_exists("nxs_getVKHeaders")) { function nxs_getVKHeaders($ref, $po
254
  if($post===true) $hdrsArr['Content-Type']='application/x-www-form-urlencoded';
255
  if($aj===true) $hdrsArr['X-Requested-With']='XMLHttpRequest';
256
  $hdrsArr['Accept']='text/html, application/xhtml+xml, */*'; $hdrsArr['DNT']='1';
257
- $hdrsArr['Accept-Encoding']='gzip,deflate'; $hdrsArr['Accept-Language']='en-US,en;q=0.8'; $hdrsArr['Accept-Charset']='ISO-8859-1,utf-8;q=0.7,*;q=0.3'; return $hdrsArr;
258
  }}
259
 
260
- if (!function_exists("nxs_uplImgtoVK")) { function nxs_uplImgtoVK($imgURL, $options){
261
- $postUrl = 'https://api.vkontakte.ru/method/photos.getWallUploadServer?gid='.(str_replace('-','',$options['pgIntID'])).'&access_token='.$options['vkAppAuthToken'];
262
- $response = wp_remote_get($postUrl); $thumbUploadUrl = $response['body'];
263
- if (!empty($thumbUploadUrl)) { $thumbUploadUrlObj = json_decode($thumbUploadUrl); $VKuploadUrl = $thumbUploadUrlObj->response->upload_url; }
264
- if (!empty($VKuploadUrl)) {
265
- $remImgURL = urldecode($imgURL); $urlParced = pathinfo($remImgURL); $remImgURLFilename = $urlParced['basename']; $imgData = wp_remote_get($remImgURL); $imgData = $imgData['body'];
266
- $tmp=array_search('uri', @array_flip(stream_get_meta_data($GLOBALS[mt_rand()]=tmpfile())));
267
- if (!is_writable($tmp)) return "Your temporary folder or file (file - ".$tmp.") is not witable. Can't upload image to VK";
268
- rename($tmp, $tmp.='.png'); register_shutdown_function(create_function('', "unlink('{$tmp}');"));
269
- file_put_contents($tmp, $imgData);
270
-
271
- $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $VKuploadUrl); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
272
- curl_setopt($ch, CURLOPT_POSTFIELDS, array('photo' => '@' . $tmp)); $response = curl_exec($ch); $errmsg = curl_error($ch); curl_close($ch); //prr($response);
273
-
274
- $uploadResultObj = json_decode($response); // prr($response); //prr($uploadResultObj);
275
-
276
- if (!empty($uploadResultObj->server) && !empty($uploadResultObj->photo) && !empty($uploadResultObj->hash)) {
277
- $postUrl = 'https://api.vkontakte.ru/method/photos.saveWallPhoto?server='.$uploadResultObj->server.'&photo='.$uploadResultObj->photo.'&hash='.$uploadResultObj->hash.'&gid='.(str_replace('-','',$options['pgIntID'])).'&access_token='.$options['vkAppAuthToken'];
278
- $response = wp_remote_get($postUrl);
279
- $resultObject = json_decode($response['body']); //prr($resultObject);
280
- if (isset($resultObject) && isset($resultObject->response[0]->id)) { return $resultObject->response[0]; } else { return false; }
281
- }
282
- }
283
- }}
284
 
285
  if (!function_exists("nxs_doPublishToVK")) { //## Second Function to Post to VK
286
- function nxs_doPublishToVK($postID, $options){ global $ShownAds, $nxs_vkCkArray; $ntCd = 'VK'; $ntCdL = 'vk'; $ntNm = 'vKontakte(VK)';
 
287
  //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToVK', array($postID, $options));
288
  $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'POSTID'=>$postID, 'ACCNAME'=>$options['nName']));
 
 
 
289
  $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
290
  $logNT = '<span style="color:#000080">vKontakte</span> - '.$options['nName'];
291
  $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
@@ -294,74 +314,64 @@ if (!function_exists("nxs_doPublishToVK")) { //## Second Function to Post to VK
294
  nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$options['pType']); return;
295
  }
296
  }
297
- $email = $options['uName']; $pass = (substr($options['uPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['uPass'], 5)):$options['uPass']);
298
  if ($postID=='0') { echo "Testing ... <br/><br/>"; $urlToGo = home_url(); $msg = 'Test Link from '.$urlToGo; } else { $post = get_post($postID); if(!$post) return;
299
- $msgFormat = $options['msgFrmt']; $msg = strip_tags(nsFormatMessage($msgFormat, $postID, $addParams));
300
  //## MyURL - URLToGo code
301
  if (!isset($options['urlToUse']) || trim($options['urlToUse'])=='') $myurl = trim(get_post_meta($postID, 'snap_MYURL', true)); if ($myurl!='') $options['urlToUse'] = $myurl;
302
  if (isset($options['urlToUse']) && trim($options['urlToUse'])!='') { $urlToGo = $options['urlToUse']; $options['useFBGURLInfo'] = true; } else $urlToGo = get_permalink($postID);
303
  if($addParams!='') $urlToGo .= (strpos($urlToGo,'?')!==false?'&':'?').$addParams;
304
  nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
305
- }
306
- $dusername = $options['uName']; $postType = $options['postType']; //$link = urlencode($link); $desc = urlencode(substr($msg, 0, 500));
307
- $extInfo = ' | PostID: '.$postID." - ".$post->post_title.' |'.$options['pType']; $imgURL = nxs_getPostImage($postID);
308
-
309
- $vids = nsFindVidsInPost($post); if (count($vids)>0) {
 
310
  if (strlen($vids[0])==11) { $vidURL = 'http://www.youtube.com/watch?v='.$vids[0]; $imgURL = 'http://img.youtube.com/vi/'.$vids[0].'/maxresdefault.jpg'; }
311
  if (strlen($vids[0])==8) { $vidURL = 'https://secure.vimeo.com/moogaloop.swf?clip_id='.$vids[0].'&autoplay=1';
312
  //$mssg['source'] = 'http://player.vimeo.com/video/'.$vids[0];
313
  $apiURL = "http://vimeo.com/api/v2/video/".$vids[0].".json?callback=showThumb"; $json = wp_remote_get($apiURL);
314
- if (!is_wp_error($json)) { $json = $json['body']; $json = str_replace('showThumb(','',$json); $json = str_replace('])',']',$json); $json = json_decode($json, true); $imgURL = $json[0]['thumbnail_large']; }
315
  }
316
- }
317
- $msgOpts = array(); $msgOpts['uid'] = $options['vkPgID']; // if ($link!='') $msgOpts['link'] = $link;
318
- if ($vidURL!='' && $postType=="I") { $postType='A'; $urlToGo=$vidURL; $msgOpts['vID'] = $vids[0]; }
319
- if ($postType=='I' && trim($imgURL)=='') $postType='T'; $msgOpts['type'] = $postType;
320
- if ($postType=='A' && $urlToGo!='') {
321
- //## Login
322
- if (isset($options['vkSvC'])) $nxs_vkCkArray = maybe_unserialize( $options['vkSvC']); $loginError = true;
323
- if (is_array($nxs_vkCkArray)) $loginError = nxs_doCheckVK(); if ($loginError!=false) {
324
- if ($options['vkPh']!='') { $ph = str_replace('+','',$options['vkPh']); $ph = substr($ph,2,-2);} else $ph = ''; $loginError = nxs_doConnectToVK($email, $pass, $ph);
325
- }
326
- if (serialize($nxs_vkCkArray)!=$options['vkSvC']) { global $plgn_NS_SNAutoPoster; $gOptions = $plgn_NS_SNAutoPoster->nxs_options;
 
 
 
 
 
 
 
 
 
 
 
 
 
327
  if (isset($options['ii']) && $options['ii']!=='') { $gOptions['vk'][$options['ii']]['vkSvC'] = serialize($nxs_vkCkArray); update_option('NS_SNAutoPoster', $gOptions); }
328
  else foreach ($gOptions['vk'] as $ii=>$gpn) { $result = array_diff($options, $gpn);
329
  if (!is_array($result) || count($result)<1) { $gOptions['vk'][$ii]['vkSvC'] = serialize($nxs_vkCkArray); update_option('NS_SNAutoPoster', $gOptions); break; }
330
  }
331
- }
332
- if ($loginError!==false) {
333
- if (stripos($loginError, 'Phone verification required:')!==false) {
334
- $phtext = str_ireplace('Phone verification required: ','',$loginError); $loginError .= ". Please refresh/reload the SNAP settings page and enter your phone.";
335
- $gOptions['vk'][$ii]['vkPhReq'] = $phtext; update_option('NS_SNAutoPoster', $gOptions);
336
- } if ($postID=='0') prr($loginError); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($loginError, true)." - BAD USER/PASS", $extInfo); return " -= BAD USER/PASS =- ";
337
- }
338
- //## Post
339
- if (trim($fbMsgAFormat)!='') {$dsc = nsFormatMessage($fbMsgAFormat, $postID, $addParams);} else { if (function_exists('aioseop_mrt_fix_meta') && $dsc=='') $dsc = trim(get_post_meta($postID, '_aioseop_description', true));
340
- if (function_exists('wpseo_admin_init') && $dsc=='') $dsc = trim(get_post_meta($postID, '_yoast_wpseo_opengraph-description', true));
341
- if (function_exists('wpseo_admin_init') && $dsc=='') $dsc = trim(get_post_meta($postID, '_yoast_wpseo_metadesc', true));
342
- if ($dsc=='') $dsc = trim(apply_filters('the_content', nxs_doQTrans($post->post_excerpt, $lng))); if ($dsc=='') $dsc = trim(nxs_doQTrans($post->post_excerpt, $lng));
343
- if ($dsc=='') $dsc = trim(apply_filters('the_content', nxs_doQTrans($post->post_content, $lng))); if ($dsc=='') $dsc = trim(nxs_doQTrans($post->post_content, $lng));
344
- if ($dsc=='') $dsc = get_bloginfo('description');
345
- } $dsc = strip_tags($dsc); $dsc = nxs_decodeEntitiesFull($dsc); $dsc = nsTrnc($dsc, 900, ' ');
346
- $msgOpts['url'] = $urlToGo; $msgOpts['urlTitle'] = nxs_doQTrans($post->post_title, $lng); $msgOpts['urlDesc'] = $dsc; $msgOpts['imgURL'] = $imgURL;
347
- $ret = nxs_doPostToVK($msg, $options['url'], $msgOpts); // prr($ret);
348
- } //prr($postType);
349
-
350
- if ($postType=='I') { $imgUpld = nxs_uplImgtoVK($imgURL, $options); if (is_object($imgUpld)) { $imgID = $imgUpld->id; $atts[] = $imgID; } else nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($imgUpld, true), $extInfo); }
351
- if ($postType!='A') { if( $options['addBackLink']=='1') $atts[] = $urlToGo;
352
- if (is_array($atts)) $atts = implode(',', $atts);
353
-
354
- $postUrl = 'https://api.vkontakte.ru/method/wall.post';
355
- $postArr = array('owner_id'=>$options['pgIntID'], 'access_token'=>$options['vkAppAuthToken'], 'from_group'=>'1', 'message'=>$msg, 'attachment'=>$atts);
356
- $response = wp_remote_post($postUrl, array('body' => $postArr));
357
- if ( is_wp_error($response) || (is_object($response) && (isset($response->errors))) || (is_array($response) && stripos($response['body'],'"error":')!==false )) {
358
- $ret = $response['body'];
359
- } else { $respJ = json_decode($response['body'], true); $ret = array("code"=>"OK", "post_id"=>$options['pgIntID'].'_'.$respJ['response']['post_id']); }
360
-
361
- }
362
- if (is_array($ret) && $ret['code']=='OK') { if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo ' OK - Message Posted, please see your VK Page '; } else
363
- { nxs_metaMarkAsPosted($postID, 'VK', $options['ii'], array('isPosted'=>'1', 'pgID'=>$ret['post_id'], 'pDate'=>date('Y-m-d H:i:s'))); nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); return 200; }
364
- } else {if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);}
365
  }
366
  }
367
  ?>
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', 'nxs_snap'); echo ")"; ?></div><?php } ?>
13
  </div>
14
  </div>
15
  <div class="nxs_box_inside">
16
  <?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = str_ireplace('https://vk.com','', str_ireplace('http://vk.com','', $pbo['url'])); ?>
17
  <p style="margin:0px;margin-left:5px;">
18
+ <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> />
19
+ <?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 } ?>
20
+ <?php if (isset($pbo['rpstOn']) && (int)$pbo['rpstOn'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popReActive');" onmouseover="nxs_showPopUpInfo('popReActive', event);"><?php echo "*[R]*" ?></span><?php } ?>
21
  <strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
22
  &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', 'nxs_snap'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>&nbsp;&nbsp;
23
  <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
24
+ </p><?php $pbo['ntInfo'] = $ntInfo; $this->showNTSettings($indx, $pbo);
25
  }?>
26
  </div>
27
  </div> <?php
28
  }
29
  //#### Show NEW Settings Page
30
+ function showNewNTSettings($mNTo){ $nto = array('nName'=>'', 'doVK'=>'1', 'url'=>'', 'vkAppID'=>'', 'imgUpl'=>'1', 'addBackLink'=>'1', 'vkPostType'=>'T', 'msgAFormat'=>'', 'attch'=>'1', 'vkPgID'=>'', 'vkAppAuthUser'=>'', 'msgFrmt'=>'New post has been published on %SITENAME%' ); $nto['ntInfo']= array('lcode'=>'vk'); $this->showNTSettings($mNTo, $nto, true);}
31
  //#### Show Unit Settings
32
+ function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl, $nxs_snapThisPageUrl; $nt = $options['ntInfo']['lcode']; $ntU = strtoupper($nt);
33
+ if ((int)$options['attch']==0 && (!isset($options['trPostType']) || $options['trPostType']=='')) $options['trPostType'] = 'T'; if (!isset($options['uName '])) $options['uName '] = ''; if (!isset($options['uPass'])) $options['uPass'] = '';
34
  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'] = '';
35
+ if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; if (!isset($options['uName'])) $options['uName'] = ''; if (!isset($options['postType'])) $options['postType'] = ''; ?>
36
+
37
  <div id="doVK<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>" style="background-image: url(<?php echo $nxs_plurl; ?>img/vk-bg.png); background-position:90% 10%;"> <input type="hidden" name="apDoSVK<?php echo $ii; ?>" value="0" id="apDoSVK<?php echo $ii; ?>" />
38
  <?php if ($isNew) { ?> <input type="hidden" name="vk[<?php echo $ii; ?>][apDoVK]" value="1" id="apDoNewVK<?php echo $ii; ?>" /> <?php } ?>
39
 
42
 
43
  </div>
44
 
45
+ <div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'nxs_snap'); ?></i> </div><input name="vk[<?php echo $ii; ?>][nName]" id="vknName<?php echo $ii; ?>" style="font-weight: bold; color: #005800; border: 1px solid #ACACAC; width: 40%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['nName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /><br/>
46
  <?php echo nxs_addQTranslSel('vk', $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', 'nxs_snap'); ?></a></li>
51
+ <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'nxs_snap'); ?></a></li>
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 style="width:100%;"><strong>vKontakte(VK) URL:</strong> </div>
59
  <p style="font-size: 11px; margin: 0px;"><?php _e('Could be your vKontakte(VK) Profile or vKontakte(VK) Group Page', 'nxs_snap'); ?></p>
71
  <?php } else { if(isset($options['vkAppAuthUser']) && $options['vkAppAuthUser']>0) { ?>
72
  <?php _e('Your vKontakte(VK) Account has been authorized.'); ?> User ID: <?php _e(apply_filters('format_to_edit', htmlentities($options['vkAppAuthUser'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>.
73
  <?php _e('You can', 'nxs_snap'); ?> Re- <?php } ?>
74
+ <a target="_blank" href="http://api.vkontakte.ru/oauth/authorize?client_id=<?php echo $options['vkAppID'];?>&scope=offline,wall,photos,pages&redirect_uri=http://api.vkontakte.ru/blank.html&display=page&response_type=token<?php '&auth=vk&acc='.$ii;?>">Authorize Your vKontakte(VK) Account</a>
 
75
  <?php if (!isset($options['vkAppAuthUser']) || $options['vkAppAuthUser']<1) { ?> <div class="blnkg">&lt;=== <?php _e('Authorize your account', 'nxs_snap'); ?> ===</div> <?php } ?>
76
 
77
  <div style="width:100%;"><strong>vKontakte(VK) Auth Response:</strong> </div><input name="vk[<?php echo $ii; ?>][apVKAuthResp]" style="width: 50%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['apVKAuthResp'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /><br/><br/>
86
  <?php if( function_exists("nxs_doPostToVK")) { ?>
87
  <div style="width:100%;"><strong>vKontakte(VK) Email:</strong> </div><input name="vk[<?php echo $ii; ?>][uName]" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['uName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
88
  <div style="width:100%;"><strong>vKontakte(VK) Password:</strong> </div><input name="vk[<?php echo $ii; ?>][uPass]" type="password" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities(substr($options['uPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['uPass'], 5)):$options['uPass'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
89
+ <?php if( isset($options['vkPhReq'])) { if (empty($options['vkPh'])) $options['vkPh'] =''; ?>
90
  <div style="width:100%;"><strong>vKontakte(VK) Phone Number (<?php _e(apply_filters('format_to_edit', htmlentities($options['vkPhReq'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>) :</strong> </div><input name="vk[<?php echo $ii; ?>][vkPh]" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['vkPh'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
91
  <?php } ?>
92
  <?php } else { ?> **** <?php _e('Please upgrade the plugin to "PRO" get NextScripts VK API', 'nxs_snap'); ?> <?php } ?>
129
  <?php if ($options['vkPgID']!='') {?><div style="width:100%;"><strong>Your vKontakte(VK) Page ID:</strong> <?php _e(apply_filters('format_to_edit', htmlentities($options['vkPgID'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?> </div><?php } ?>
130
 
131
  <?php if(isset($options['vkAppAuthUser']) && $options['vkAppAuthUser']>0) { ?>
132
+
133
  <br/><br/><b><?php _e('Test your settings', 'nxs_snap'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('VK','<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'nxs_snap' ), $nType); ?></a>
134
  <?php }?>
135
+
136
+ </div>
137
+ <?php /* ######################## Advanced Tab ####################### */ ?>
138
+ <div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content">
139
+
140
+ <?php if (!$isNew) { ?> <div class="nxs_tls_cpt"><?php _e('Categories', 'nxs_snap'); ?></div>
141
+ <div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
142
+ <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
143
+ <input value="1" id="catSelS<?php echo $ntU; ?><?php echo $ii; ?>" type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_<?php echo $ntU; ?><?php echo $ii; ?>" onclick="jQuery('#catSelS<?php echo $ntU; ?><?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('<?php echo $ntU; ?><?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($options['catSelEd']!='') echo "[".(substr_count($options['catSelEd'], ",")+1)."]"; ?></a>
144
+ <input type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
145
+ <br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
146
+ <br/>
147
+ <?php } ?>
148
+
149
+ <?php nxs_addPostingDelaySelV3($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']); ?>
150
+ <?php nxs_showRepostSettings($nt, $ii, $options); ?>
151
+
152
+
153
+ </div> <?php /* #### End of Tab #### */ ?>
154
+ </div><br/> <?php /* #### End of Tabs #### */ ?>
155
+
156
+ <div class="submit clear" style="padding-bottom: 0px;"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div>
157
 
158
  </div>
159
  <?php
161
  }
162
  //#### Set Unit Settings from POST
163
  function setNTSettings($post, $options){ global $nxs_snapThisPageUrl; $code = 'VK'; $lcode = 'vk';
164
+ foreach ($post as $ii => $pval){
165
  if (isset($pval['apVKAppID']) && $pval['apVKAppID']!='') { if (!isset($options[$ii])) $options[$ii] = array();
166
  if (isset($pval['apDoVK'])) $options[$ii]['doVK'] = $pval['apDoVK']; else $options[$ii]['doVK'] = 0;
167
  if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']);
168
  if (isset($pval['apVKAppID'])) $options[$ii]['vkAppID'] = trim($pval['apVKAppID']);
169
 
170
  if (isset($pval['uName'])) $options[$ii]['uName'] = trim($pval['uName']);
171
+ if (isset($pval['uPass'])) $options[$ii]['uPass'] = 'n5g9a'.nsx_doEncode($pval['uPass']); else $options[$ii]['uPass'] = '';
172
+ if (isset($pval['vkPh'])) $options[$ii]['vkPh'] = trim($pval['vkPh']);
173
+
174
 
175
  if (isset($pval['apVKAuthResp'])) { $options[$ii]['apVKAuthResp'] = trim($pval['apVKAuthResp']);
176
  $options[$ii]['vkAppAuthToken'] = trim( CutFromTo($pval['apVKAuthResp'].'&', 'access_token=','&'));
197
  if (isset($pval['msgFrmt'])) $options[$ii]['msgFrmt'] = trim($pval['msgFrmt']);
198
  if (isset($pval['msgAFormat'])) $options[$ii]['msgAFormat'] = trim($pval['msgAFormat']);
199
 
200
+ $options[$ii] = nxs_adjRpst($options[$ii], $pval);
201
+
202
+ if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']);
203
  if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
204
  if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
205
 
213
  } return $options;
214
  }
215
  //#### Show Post->Edit Meta Box Settings
216
+ function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID; $nt = 'vk'; $ntU = 'VK';
217
  foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapVK', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
218
+ if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = ''; if (empty($ntOpt['urlToUse'])) $ntOpt['urlToUse'] = '';
219
+ $doVK = $ntOpt['doVK'] && (is_array($pMeta) || $ntOpt['catSel']!='1'); $imgToUse = $ntOpt['imgToUse']; $urlToUse = $ntOpt['urlToUse'];
220
  $isAvailVK = $ntOpt['url']!='' && $ntOpt['vkAppID']!='' || $ntOpt['uPass']!=''; $isAttachVK = $ntOpt['attch']; $msgFrmt = htmlentities($ntOpt['msgFrmt'], ENT_COMPAT, "UTF-8"); $postType = $ntOpt['postType'];
221
  ?>
222
  <tr><th style="text-align:left;" colspan="2"> <?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_VK<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
226
  <td><?php //## Only show RePost button if the post is "published"
227
  if ($post->post_status == "publish" && $isAvailVK) { ?>
228
  <input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToVK_repostButton" id="rePostToVK_button" value="<?php _e('Repost to vKontakte(VK)', 'nxs_snap') ?>" />
229
+ <?php } ?>
230
  <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID'])) { ?> <span id="pstdVK<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;">
231
  <a style="font-size: 10px;" href="http://vk.com/wall<?php echo $pMeta[$ii]['pgID']; ?>" target="_blank"><?php $nType="vKontakte(VK)"; printf( __( 'Posted on', 'nxs_snap' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a>
232
  </span>
233
  <?php } ?>
234
  </td></tr>
235
  <?php if (!$isAvailVK) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup and Authorize your vKontakte(VK) Account to AutoPost to vKontakte(VK)</b>
236
+ <?php } else { if ($post->post_status != "publish" && function_exists('nxs_doSMAS5') ) { nxs_doSMAS5($nt, $ii, $ntOpt); } ?>
237
+
238
+ <?php if ($ntOpt['rpstOn']=='1') { ?>
239
+
240
+ <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top:6px; text-align:right; width:60px; padding-right:10px;">
241
+ <input value="0" type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]"/><input value="nxsi<?php echo $ii; ?>vk" type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]" <?php if (!empty($ntOpt['rpstPostIncl'])) echo "checked"; ?> />
242
+ </th>
243
+ <td> <?php _e('Include in "Auto-Reposting" to this network.', 'nxs_snap') ?>
244
+ </td></tr> <?php } ?>
245
  <tr id="altFormat1" style=""><th scope="row" valign="top" style="vertical-align:top; padding-top:6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Message Format:', 'nxs_snap') ?></th>
246
  <td>
247
  <textarea cols="150" rows="1" id="vk<?php echo $ii; ?>SNAPformat" name="vk[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('#vk<?php echo $ii; ?>SNAPformat').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apVKTMsgFrmt<?php echo $ii; ?>');"><?php echo $msgFrmt; ?></textarea>
258
  <?php if( function_exists("nxs_doPostToVK")) { ?> <br/>
259
  <input type="radio" name="vk[<?php echo $ii; ?>][PostType]" value="A" <?php if ( !isset($postType) || $postType == '' || $postType == 'A') echo 'checked="checked"'; ?> /> <?php _e('Text Post with "attached" blogpost', 'nxs_snap') ?>
260
  <?php } ?><br/><div class="popShAtt" id="popShAtt<?php echo $ii; ?>VKX"><h3>vKontakte(VK) <?php _e('Post Types', 'nxs_snap') ?></h3><img src="<?php echo $nxs_plurl; ?>img/vkPostTypesDiff6.png" width="600" height="257" alt="<?php _e('Post Types', 'nxs_snap') ?>"/></div>
261
+ </td></tr>
262
+
263
+ <?php /* ## Select Image & URL ## */ nxs_showImgToUseDlg($nt, $ii, $imgToUse); nxs_showURLToUseDlg($nt, $ii, $urlToUse); ?>
264
+ <?php }
265
  }
266
 
267
  }
268
 
269
  function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
270
  if (isset($pMeta['SNAPformat'])) $optMt['msgFrmt'] = $pMeta['SNAPformat'];
271
+ if (isset($pMeta['imgToUse'])) $optMt['imgToUse'] = $pMeta['imgToUse']; if (isset($pMeta['urlToUse'])) $optMt['urlToUse'] = $pMeta['urlToUse'];
272
  if (isset($pMeta['AttachPost'])) $optMt['attch'] = ($pMeta['AttachPost'] != '')?$pMeta['AttachPost']:0; else { if (isset($pMeta['SNAPformat'])) $optMt['attch'] = 0; }
273
  if (isset($pMeta['addBackLink'])) $optMt['addBackLink'] = ($pMeta['addBackLink'] != '')?$pMeta['addBackLink']:0; else { if (isset($pMeta['SNAPformat'])) $optMt['addBackLink'] = 0; }
274
  if (isset($pMeta['PostType'])) $optMt['postType'] = ($pMeta['PostType'] != '')?$pMeta['PostType']:0; else { if (isset($pMeta['SNAPformat'])) $optMt['postType'] = 'T'; }
278
  }
279
  }}
280
 
281
+ if (!function_exists("nxs_rePostToVK_ajax")) { function nxs_rePostToVK_ajax() { check_ajax_referer('nxsSsPageWPN'); $postID = $_POST['id']; // $result = nsPublishTo($id, 'VK', true);
282
  $options = get_option('NS_SNAutoPoster'); foreach ($options['vk'] as $ii=>$nto) if ($ii==$_POST['nid']) { $nto['ii'] = $ii; $nto['pType'] = 'aj';
283
  $ntpo = get_post_meta($postID, 'snapVK', true); /* echo $postID."|"; echo $fbpo; */ $ntpo = maybe_unserialize($ntpo); // prr($ntpo);
284
  if (is_array($ntpo) && isset($ntpo[$ii]) && is_array($ntpo[$ii]) ){ $ntClInst = new nxs_snapClassVK(); $nto = $ntClInst->adjMetaOpt($nto, $ntpo[$ii]); } //prr($nto);
293
  if($post===true) $hdrsArr['Content-Type']='application/x-www-form-urlencoded';
294
  if($aj===true) $hdrsArr['X-Requested-With']='XMLHttpRequest';
295
  $hdrsArr['Accept']='text/html, application/xhtml+xml, */*'; $hdrsArr['DNT']='1';
296
+ if (function_exists('gzdeflate')) $hdrsArr['Accept-Encoding']='gzip,deflate'; $hdrsArr['Accept-Language']='en-US,en;q=0.8'; $hdrsArr['Accept-Charset']='ISO-8859-1,utf-8;q=0.7,*;q=0.3'; return $hdrsArr;
297
  }}
298
 
299
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
300
 
301
  if (!function_exists("nxs_doPublishToVK")) { //## Second Function to Post to VK
302
+ function nxs_doPublishToVK($postID, $options){ global $ShownAds, $nxs_vkCkArray; $ntCd = 'VK'; $ntCdL = 'vk'; $ntNm = 'vKontakte(VK)'; $vidURL = ''; $imgVURL = ''; $dsc = ''; $lng = '';
303
+ if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
304
  //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToVK', array($postID, $options));
305
  $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'POSTID'=>$postID, 'ACCNAME'=>$options['nName']));
306
+ if (empty($options['imgToUse'])) $options['imgToUse'] = ''; if (empty($options['imgSize'])) $options['imgSize'] = '';
307
+ $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url();
308
+
309
  $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
310
  $logNT = '<span style="color:#000080">vKontakte</span> - '.$options['nName'];
311
  $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
314
  nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$options['pType']); return;
315
  }
316
  }
317
+
318
  if ($postID=='0') { echo "Testing ... <br/><br/>"; $urlToGo = home_url(); $msg = 'Test Link from '.$urlToGo; } else { $post = get_post($postID); if(!$post) return;
319
+ $options['msgFrmt'] = strip_tags(nsFormatMessage($options['msgFrmt'], $postID, $addParams));
320
  //## MyURL - URLToGo code
321
  if (!isset($options['urlToUse']) || trim($options['urlToUse'])=='') $myurl = trim(get_post_meta($postID, 'snap_MYURL', true)); if ($myurl!='') $options['urlToUse'] = $myurl;
322
  if (isset($options['urlToUse']) && trim($options['urlToUse'])!='') { $urlToGo = $options['urlToUse']; $options['useFBGURLInfo'] = true; } else $urlToGo = get_permalink($postID);
323
  if($addParams!='') $urlToGo .= (strpos($urlToGo,'?')!==false?'&':'?').$addParams;
324
  nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
325
+ }
326
+ $extInfo = ' | PostID: '.$postID." - ".(is_object($post)?$post->post_title:'').' |'.$options['pType'];
327
+ //## Message & Format
328
+ if (trim($options['imgToUse'])!='') $imgURL = $options['imgToUse']; else $imgURL = nxs_getPostImage($postID, 'full'); if (preg_match("/noImg.\.png/i", $imgURL)) $imgURL = '';
329
+
330
+ if (function_exists('nxs_doPostToVK')) { $vids = nsFindVidsInPost($post); if (count($vids)>0) {
331
  if (strlen($vids[0])==11) { $vidURL = 'http://www.youtube.com/watch?v='.$vids[0]; $imgURL = 'http://img.youtube.com/vi/'.$vids[0].'/maxresdefault.jpg'; }
332
  if (strlen($vids[0])==8) { $vidURL = 'https://secure.vimeo.com/moogaloop.swf?clip_id='.$vids[0].'&autoplay=1';
333
  //$mssg['source'] = 'http://player.vimeo.com/video/'.$vids[0];
334
  $apiURL = "http://vimeo.com/api/v2/video/".$vids[0].".json?callback=showThumb"; $json = wp_remote_get($apiURL);
335
+ if (!is_wp_error($json)) { $json = $json['body']; $json = str_replace('showThumb(','',$json); $json = str_replace('])',']',$json); $json = json_decode($json, true); $imgVURL = $json[0]['thumbnail_large']; }
336
  }
337
+ }
338
+ }
339
+ if (!empty($options['attchAsVid']) && $options['attchAsVid']=='1' && trim($imgVURL)!='') $imgURL = $imgVURL;
340
+
341
+ if (trim($options['msgAFormat'])!='') {$dsc = nsFormatMessage($options['msgAFormat'], $postID, $addParams);} else {
342
+ if (function_exists('aioseop_mrt_fix_meta') && $dsc=='') $dsc = trim(get_post_meta($postID, '_aioseop_description', true));
343
+ if (function_exists('wpseo_admin_init') && $dsc=='') $dsc = trim(get_post_meta($postID, '_yoast_wpseo_opengraph-description', true));
344
+ if (function_exists('wpseo_admin_init') && $dsc=='') $dsc = trim(get_post_meta($postID, '_yoast_wpseo_metadesc', true));
345
+ if (is_object($post) && $dsc=='') $dsc = trim(apply_filters('the_content', nxs_doQTrans($post->post_excerpt, $lng))); if ($dsc=='') $dsc = trim(nxs_doQTrans($post->post_excerpt, $lng));
346
+ if (is_object($post) && $dsc=='') $dsc = trim(apply_filters('the_content', nxs_doQTrans($post->post_content, $lng))); if ($dsc=='') $dsc = trim(nxs_doQTrans($post->post_content, $lng));
347
+ if (is_object($post) && $dsc=='') $dsc = get_bloginfo('description');
348
+ } $dsc = strip_tags($dsc); $dsc = nxs_decodeEntitiesFull($dsc); $dsc = nsTrnc($dsc, 900, ' ');
349
+
350
+ $message = array('siteName'=>$blogTitle, 'url'=>$urlToGo, 'imageURL'=>$imgURL, 'videoURL'=>$vidURL, 'urlTitle'=>nxs_doQTrans($post->post_title, $lng), 'urlDescr'=>$dsc);
351
+ //## Actual Post
352
+ $ntToPost = new nxs_class_SNAP_VK(); $ret = $ntToPost->doPostToNT($options, $message);
353
+ //## Check Phone Req Return
354
+ if ( is_string($ret) && stripos($ret, 'Phone verification required:')!==false) { global $plgn_NS_SNAutoPoster; $gOptions = $plgn_NS_SNAutoPoster->nxs_options;
355
+ $phtext = str_ireplace('Phone verification required: ','',$ret); $ret .= ". Please refresh/reload the SNAP settings page and enter your phone.";
356
+ $gOptions['vk'][$ii]['vkPhReq'] = $phtext; update_option('NS_SNAutoPoster', $gOptions);
357
+ if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true)." - BAD USER/PASS", $extInfo); return " -= BAD USER/PASS - Phone verification required =- ";
358
+ }
359
+ //## Save Session
360
+ if (empty($options['vkSvC']) || serialize($nxs_vkCkArray)!=$options['vkSvC']) { global $plgn_NS_SNAutoPoster; $gOptions = $plgn_NS_SNAutoPoster->nxs_options;
361
  if (isset($options['ii']) && $options['ii']!=='') { $gOptions['vk'][$options['ii']]['vkSvC'] = serialize($nxs_vkCkArray); update_option('NS_SNAutoPoster', $gOptions); }
362
  else foreach ($gOptions['vk'] as $ii=>$gpn) { $result = array_diff($options, $gpn);
363
  if (!is_array($result) || count($result)<1) { $gOptions['vk'][$ii]['vkSvC'] = serialize($nxs_vkCkArray); update_option('NS_SNAutoPoster', $gOptions); break; }
364
  }
365
+ }
366
+ //## Process Results
367
+ if (!is_array($ret) || $ret['isPosted']!='1') { //## Error
368
+ if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);
369
+ } else { // ## All Good - log it.
370
+ if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo _e('OK - Message Posted, please see your '.$logNT.' Page. ', 'nxs_snap'); }
371
+ 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); }
372
+ }
373
+ //## Return Result
374
+ if ($ret['isPosted']=='1') return 200; else return print_r($ret, true);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
375
  }
376
  }
377
  ?>
inc-cl/wp.api.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //## NextScripts FriendFeed Connection Class
3
+ $nxs_snapAPINts[] = array('code'=>'WP', 'lcode'=>'wp', 'name'=>'WP Based Blog');
4
+
5
+ if (!class_exists("nxs_class_SNAP_WP")) { class nxs_class_SNAP_WP {
6
+
7
+ var $ntCode = 'WP';
8
+ var $ntLCode = 'wp';
9
+
10
+ function doPost($options, $message){ if (!is_array($options)) return false;
11
+ foreach ($options as $ntOpts) $out[] = $this->doPostToNT($ntOpts, $message);
12
+ return $out;
13
+ }
14
+ function nxs_getLJHeaders($up){ $hdrsArr = array();
15
+ $hdrsArr['Cache-Control']='no-cache'; $hdrsArr['Connection']='keep-alive';
16
+ $hdrsArr['User-Agent']='SNAP for Wordpress; Ver '.NextScripts_SNAP_Version;
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'; $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){ $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; }
24
+ if (!isset($options['wpUName']) || trim($options['wpPass'])=='') { $badOut['Error'] = 'Not Configured'; return $badOut; }
25
+ $pass = substr($options['wpPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['wpPass'], 5)):$options['wpPass'];
26
+ //## Format
27
+ $msg = nxs_doFormatMsg($options['wpMsgFormat'], $message); $msgT = nxs_doFormatMsg($options['wpMsgTFormat'], $message);
28
+ if (isset($message['imageURL'])) $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); else $imgURL = '';
29
+
30
+
31
+ $link = urlencode($message['url']); $ext = substr($msg, 0, 1000);
32
+
33
+ //## Post
34
+ require_once ('apis/xmlrpc-client.php'); $nxsToWPclient = new NXS_XMLRPC_Client($options['wpURL']); $nxsToWPclient->debug = false;
35
+ if ($imgURL!=='' && stripos($imgURL, 'http')!==false) {
36
+ // $handle = fopen($imgURL, "rb"); $filedata = ''; while (!feof($handle)) {$filedata .= fread($handle, 8192);} fclose($handle);
37
+ $filedata = wp_remote_get($imgURL); if (! is_wp_error($filedata) ) $filedata = $filedata['body']; // echo "AWC?";
38
+ $data = array('name' => 'image-'.$message['orID'].'.jpg', 'type' => 'image/jpg', 'bits' => new NXS_XMLRPC_Base64($filedata), true);
39
+ $status = $nxsToWPclient->query('metaWeblog.newMediaObject', $message['orID'], $options['wpUName'], $pass, $data); $imgResp = $nxsToWPclient->getResponse(); $gid = $imgResp['id'];
40
+ } else $gid = '';
41
+
42
+ $params = array(0, $options['wpUName'], $pass, array('software_version'));
43
+ if (!$nxsToWPclient->query('wp.getOptions', $params)) { $ret = 'Something went wrong - '.$nxsToWPclient->getErrorCode().' : '.$nxsToWPclient->getErrorMessage();} else $ret = 'OK';
44
+ $rwpOpt = $nxsToWPclient->getResponse(); $rwpOpt = $rwpOpt['software_version']['value']; $rwpOpt = floatval($rwpOpt); //prr($rwpOpt);prr($nxsToWPclient);
45
+ //## MAIN Post
46
+ if ($rwpOpt==0) {
47
+ $errMsg = $nxsToWPclient->getErrorMessage(); if ($errMsg!='') $ret = $errMsg; else $ret = 'XMLRPC is not found or not active. WP admin - Settings - Writing - Enable XML-RPC';
48
+ } else if ($rwpOpt<3.0) $ret = 'XMLRPC is too OLD - '.$rwpOpt.' You need at least 3.0'; else {
49
+
50
+ if ($rwpOpt>3.3){
51
+ $nxsToWPContent = array('title'=>$msgT, 'description'=>$msg, 'post_status'=>'draft', 'mt_excerpt'=>$ext, 'mt_allow_comments'=>1, 'mt_allow_pings'=>1, 'post_type'=>'post', 'mt_keywords'=>$message['tags'], 'categories'=>$message['cats'], 'custom_fields' => '');
52
+ $params = array(0, $options['wpUName'], $pass, $nxsToWPContent, true);
53
+ if (!$nxsToWPclient->query('metaWeblog.newPost', $params)) { $ret = 'Something went wrong - '.$nxsToWPclient->getErrorCode().' : '.$nxsToWPclient->getErrorMessage();} else $ret = 'OK';
54
+ $pid = $nxsToWPclient->getResponse();
55
+
56
+ if ($gid!='') {
57
+ $nxsToWPContent = array('post_thumbnail'=>$gid); $params = array(0, $options['wpUName'], $pass, $pid, $nxsToWPContent, true);
58
+ if (!$nxsToWPclient->query('wp.editPost', $params)) { $ret = 'Something went wrong - '.$nxsToWPclient->getErrorCode().' : '.$nxsToWPclient->getErrorMessage();} else $ret = 'OK';
59
+ }
60
+ $nxsToWPContent = array('post_status'=>'publish'); $params = array(0, $options['wpUName'], $pass, $pid, $nxsToWPContent, true);
61
+ if (!$nxsToWPclient->query('wp.editPost', $params)) { $ret = 'Something went wrong - '.$nxsToWPclient->getErrorCode().' : '.$nxsToWPclient->getErrorMessage();} else $ret = 'OK';
62
+ } else {
63
+ $nxsToWPContent = array('title'=>$msgT, 'description'=>$msg, 'post_status'=>'publish', 'mt_allow_comments'=>1, 'mt_allow_pings'=>1, 'post_type'=>'post', 'mt_keywords'=>$message['tags'], 'categories'=>$message['cats'], 'custom_fields' => '');
64
+ $params = array(0, $options['wpUName'], $pass, $nxsToWPContent, true);
65
+ if (!$nxsToWPclient->query('metaWeblog.newPost', $params)) { $ret = 'Something went wrong - '.$nxsToWPclient->getErrorCode().' : '.$nxsToWPclient->getErrorMessage();} else $ret = 'OK';
66
+ $pid = $nxsToWPclient->getResponse();
67
+ }
68
+ }
69
+ if ($ret!='OK') $badOut['Error'] .= '-=ERROR=- '.print_r($ret, true); else return array('postID'=>$pid, 'isPosted'=>1, 'postURL'=>$pid, 'pDate'=>date('Y-m-d H:i:s'));
70
+ return $badOut;
71
+ }
72
+ }}
73
+ ?>
inc-cl/wp.php CHANGED
@@ -8,49 +8,53 @@ if (!class_exists("nxs_snapClassWP")) { class nxs_snapClassWP {
8
  <div class="nxs_box">
9
  <div class="nxs_box_header">
10
  <div class="nsx_iconedTitle" style="margin-bottom:1px;background-image:url(<?php echo $nxs_plurl;?>img/<?php echo $ntInfo['lcode']; ?>16.png);"><?php echo $ntInfo['name']; ?>
11
- <?php $cbo = count($ntOpts); ?> <?php wp_nonce_field( 'ns'.$ntInfo['code'], 'ns'.$ntInfo['code'].'_wpnonce' ); ?>
12
  <?php if ($cbo>1){ ?><div class="nsBigText"><?php echo "(".($cbo=='0'?'No':$cbo)." "; _e('accounts', 'nxs_snap'); echo ")"; ?></div><?php } ?>
13
  </div>
14
  </div>
15
  <div class="nxs_box_inside">
16
  <?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = str_ireplace('/xmlrpc.php','', str_ireplace('http://','', str_ireplace('https://','', $pbo['wpURL']))); ?>
17
  <p style="margin:0px;margin-left:5px;">
18
- <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> /> <?php if ((int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
 
 
19
  <strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
20
  &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', 'nxs_snap'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>&nbsp;&nbsp;
21
  <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
22
- </p><?php $this->showNTSettings($indx, $pbo);
23
  }?>
24
  </div>
25
  </div> <?php
26
  }
27
  //#### Show NEW Settings Page
28
- function showNewNTSettings($mgpo){ $gpo = array('nName'=>'', 'doWP'=>'1', 'wpUName'=>'', 'wpPageID'=>'', 'wpAttch'=>'', 'wpPass'=>'', 'wpURL'=>''); $this->showNTSettings($mgpo, $gpo, true);}
29
  //#### Show Unit Settings
30
- function showNTSettings($ii, $gpo, $isNew=false){ global $nxs_plurl; ?>
31
- <div id="doWP<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>" style="background-image: url(<?php echo $nxs_plurl; ?>img/wp-bg.png); background-position:90% 10%;"> <input type="hidden" name="apDoSWP<?php echo $ii; ?>" value="0" id="apDoSWP<?php echo $ii; ?>" />
 
 
32
 
33
  <div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/wp16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-wp-based-social-networks-auto-poster-wordpress/"><?php $nType="Wordpress"; printf( __( 'Detailed %s Installation/Configuration Instructions', 'nxs_snap' ), $nType); ?></a></div>
34
 
35
  <?php if ($isNew){ ?> <br/>You can setup any Wordpress based blog with activated XML-RPC support (WP Admin->Settimgs->Writing->Remote Publishing->Check XML-RPC). Wordpress.com and Blog.com supported as well.<br/><br/> <?php } ?>
36
 
37
- <div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easely identify it', 'nxs_snap'); ?></i> </div><input name="wp[<?php echo $ii; ?>][nName]" id="wpnName<?php echo $ii; ?>" style="font-weight: bold; color: #005800; border: 1px solid #ACACAC; width: 40%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($gpo['nName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /><br/>
38
- <?php echo nxs_addQTranslSel('wp', $ii, $gpo['qTLng']); ?><?php echo nxs_addPostingDelaySel('wp', $ii, $gpo['nHrs'], $gpo['nMin'], $gpo['nDays']); ?>
39
 
40
- <?php if (!$isNew) { ?>
41
- <div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
42
- <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="wp[<?php echo $ii; ?>][catSel]" <?php if ((int)$gpo['catSel'] != 1) echo "checked"; ?> /> All
43
- <input value="1" id="catSelSWP<?php echo $ii; ?>" type="radio" name="wp[<?php echo $ii; ?>][catSel]" <?php if ((int)$gpo['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_WP<?php echo $ii; ?>" onclick="jQuery('#catSelSWP<?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('WP<?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_WP<?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($gpo['catSelEd']!='') echo "[".(substr_count($gpo['catSelEd'], ",")+1)."]"; ?></a>
44
- <input type="hidden" name="wp[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_WP<?php echo $ii; ?>" value="<?php echo $gpo['catSelEd']; ?>" />
45
- <br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
46
- <br/>
47
- <?php } ?>
48
 
49
- <div style="width:100%;"><strong>XMLRPC URL:</strong> </div><input name="wp[<?php echo $ii; ?>][apWPURL]" id="apWPURL" style="width: 50%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($gpo['wpURL'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
50
  <p style="font-size: 11px; margin: 0px;">Usually its a URL of your Wordpress installation with /xmlrpc.php at the end.<br/> Please use <b style="color: #005800;">http://YourUserName.wordpress.com/xmlrpc.php</b> (replace YourUserName with your user name - for example <i style="color: #005800;">http://nextscripts.wordpress.com/xmlrpc.php</i>) for Wordpress.com blogs. <br/> Please use <b style="color: #005800;">http://YourUserName.blog.com/xmlrpc.php</b> (replace YourUserName with your user name - for example <i style="color: #005800;">http://nextscripts.blog.com/xmlrpc.php</i> for Blog.com blogs</p>
51
 
52
- <div style="width:100%;"><br/><strong>Blog Username:</strong> </div><input name="wp[<?php echo $ii; ?>][apWPUName]" id="apWPUName" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($gpo['wpUName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
53
- <div style="width:100%;"><strong>Blog Password:</strong> </div><input name="wp[<?php echo $ii; ?>][apWPPass]" id="apWPPass" type="password" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities(substr($gpo['wpPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($gpo['wpPass'], 5)):$gpo['wpPass'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /> <br/>
54
 
55
  <?php if ($isNew) { ?> <input type="hidden" name="wp[<?php echo $ii; ?>][apDoWP]" value="1" id="apDoNewWP<?php echo $ii; ?>" /> <?php } ?>
56
 
@@ -60,7 +64,7 @@ if (!class_exists("nxs_snapClassWP")) { class nxs_snapClassWP {
60
  <div style="width:100%;"><strong id="altFormatText"><?php _e('Post Title Format', 'nxs_snap'); ?></strong>
61
  (<a href="#" id="apWPMsgTFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apWPMsgTFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)
62
  </div>
63
- <input name="wp[<?php echo $ii; ?>][apWPMsgTFrmt]" id="apWPMsgTFrmt" style="width: 50%;" onfocus="mxs_showFrmtInfo('apWPMsgTFrmt<?php echo $ii; ?>');" value="<?php if ($isNew) echo "%TITLE%"; else _e(apply_filters('format_to_edit', htmlentities($gpo['wpMsgTFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap'); ?>" /> <?php nxs_doShowHint("apWPMsgTFrmt".$ii); ?>
64
 
65
  </div>
66
  <div id="altFormat" style="">
@@ -69,18 +73,38 @@ if (!class_exists("nxs_snapClassWP")) { class nxs_snapClassWP {
69
  </div>
70
 
71
 
72
- <textarea cols="150" rows="3" id="wp<?php echo $ii; ?>SNAPformat" name="wp[<?php echo $ii; ?>][apWPMsgFrmt]" style="width:51%;max-width: 650px;" onfocus="jQuery('#wp<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('apWPMsgFrmt<?php echo $ii; ?>');"><?php if ($isNew) echo "%EXCERPT%"; else _e(apply_filters('format_to_edit', htmlentities($gpo['wpMsgFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap'); ?></textarea>
73
  <?php nxs_doShowHint("apWPMsgFrmt".$ii); ?>
74
 
75
  </div><br/>
76
 
77
- <?php if ($gpo['wpPass']!='') { ?>
78
- <?php wp_nonce_field( 'rePostToWP', 'rePostToWP_wpnonce' ); ?>
79
  <b><?php _e('Test your settings', 'nxs_snap'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('WP', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'nxs_snap' ), $nType); ?></a>
80
 
81
  <?php }
82
 
83
- ?><div class="submit"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div></div><?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  }
85
  //#### Set Unit Settings from POST
86
  function setNTSettings($post, $options){ global $nxs_snapThisPageUrl; $code = 'WP'; $lcode = 'wp';
@@ -97,16 +121,20 @@ if (!class_exists("nxs_snapClassWP")) { class nxs_snapClassWP {
97
  if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
98
 
99
  if (isset($pval['apDoWP'])) $options[$ii]['doWP'] = $pval['apDoWP']; else $options[$ii]['doWP'] = 0;
100
- if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']);
 
 
 
101
  if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
102
  if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
103
  }
104
  } return $options;
105
  }
106
  //#### Show Post->Edit Meta Box Settings
107
- function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
108
- foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapWP', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
109
- $doWP = $ntOpt['doWP'] && (is_array($pMeta) || $ntOpt['catSel']!='1');
 
110
  $isAvailWP = $ntOpt['wpUName']!='' && $ntOpt['wpPass']!=''; $wpMsgFormat = htmlentities($ntOpt['wpMsgFormat'], ENT_COMPAT, "UTF-8"); $wpMsgTFormat = htmlentities($ntOpt['wpMsgTFormat'], ENT_COMPAT, "UTF-8");
111
  ?>
112
  <tr><th style="text-align:left;" colspan="2"><?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_WP<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
@@ -114,7 +142,7 @@ if (!class_exists("nxs_snapClassWP")) { class nxs_snapClassWP {
114
  <?php if ($post->post_status == "publish") { ?> <input type="hidden" name="wp[<?php echo $ii; ?>][doWP]" value="<?php echo $doWP;?>"> <?php } ?> <?php } ?>
115
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/wp16.png);">WP Blog - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
116
  if ($post->post_status == "publish" && $isAvailWP) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToWP_repostButton" id="rePostToWP_button" value="<?php _e('Repost to WP Blog', 'nxs_snap') ?>" />
117
- <?php wp_nonce_field( 'rePostToWP', 'rePostToWP_wpnonce' ); } ?>
118
 
119
  <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) { $wpURL = str_ireplace('/xmlrpc.php', '', $ntOpt['wpURL']);
120
  if (substr($wpURL, -1)=='/') $wpURL = substr($wpURL, 0, -1); $wpURL = $wpURL."/";
@@ -125,7 +153,15 @@ if (!class_exists("nxs_snapClassWP")) { class nxs_snapClassWP {
125
  </td></tr>
126
 
127
  <?php if (!$isAvailWP) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your WP Blog Account to AutoPost to WP Blogs</b>
128
- <?php } elseif ($post->post_status != "puZblish") { ?>
 
 
 
 
 
 
 
 
129
 
130
  <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top:6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Title Format:', 'nxs_snap') ?></th>
131
  <td><input value="<?php echo $wpMsgTFormat ?>" type="text" name="wp[<?php echo $ii; ?>][SNAPformatT]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apWPTMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apWPTMsgFrmt".$ii); ?></td></tr>
@@ -134,6 +170,7 @@ if (!class_exists("nxs_snapClassWP")) { class nxs_snapClassWP {
134
  <td>
135
  <textarea cols="150" rows="1" id="wp<?php echo $ii; ?>SNAPformat" name="wp[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('#wp<?php echo $ii; ?>SNAPformat').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apWPMsgFrmt<?php echo $ii; ?>');"><?php echo $wpMsgFormat; ?></textarea>
136
  <?php nxs_doShowHint("apWPMsgFrmt".$ii); ?></td></tr>
 
137
 
138
  <?php }
139
  }
@@ -142,13 +179,15 @@ if (!class_exists("nxs_snapClassWP")) { class nxs_snapClassWP {
142
  function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
143
  if (isset($pMeta['SNAPformat'])) $optMt['wpMsgFormat'] = $pMeta['SNAPformat'];
144
  if (isset($pMeta['SNAPformatT'])) $optMt['wpMsgTFormat'] = $pMeta['SNAPformatT'];
 
 
145
  if (isset($pMeta['doWP'])) $optMt['doWP'] = $pMeta['doWP'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doWP'] = 0; }
146
  if (isset($pMeta['SNAPincludeWP']) && $pMeta['SNAPincludeWP'] == '1' ) $optMt['doWP'] = 1;
147
  return $optMt;
148
  }
149
  }}
150
  if (!function_exists("nxs_rePostToWP_ajax")) {
151
- function nxs_rePostToWP_ajax() { check_ajax_referer('rePostToWP'); $postID = $_POST['id']; $options = get_option('NS_SNAutoPoster');
152
  foreach ($options['wp'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj';//if ($two['gpPageID'].$two['gpUName']==$_POST['nid']) {
153
  $gppo = get_post_meta($postID, 'snapWP', true); $gppo = maybe_unserialize($gppo);// prr($gppo);
154
  if (is_array($gppo) && isset($gppo[$ii]) && is_array($gppo[$ii])){ $ntClInst = new nxs_snapClassWP(); $two = $ntClInst->adjMetaOpt($two, $gppo[$ii]); }
@@ -158,8 +197,13 @@ if (!function_exists("nxs_rePostToWP_ajax")) {
158
  }
159
 
160
  if (!function_exists("nxs_doPublishToWP")) { //## Second Function to Post to WP
161
- function nxs_doPublishToWP($postID, $options){ $ntCd = 'WP'; $ntCdL = 'wp'; $ntNm = 'WP Based Blog';
 
162
  //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToWP', array($postID, $options));
 
 
 
 
163
  $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
164
  $logNT = '<span style="color:#1A9EE6">WP</span> - '.$options['nName'];
165
  $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
@@ -168,61 +212,39 @@ if (!function_exists("nxs_doPublishToWP")) { //## Second Function to Post to WP
168
  nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$uqID); return;
169
  }
170
  }
171
- $imgURL = nxs_getPostImage($postID);
172
- $email = $options['wpUName']; $pass = substr($options['wpPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['wpPass'], 5)):$options['wpPass'];
173
- if ($postID=='0') { echo "Testing ... <br/><br/>"; $link = home_url(); $msgT = 'Test Link from '.$link; $msg = 'Test post please ignore'; } else { $post = get_post($postID); if(!$post) return; $link = get_permalink($postID);
174
- $msgFormat = $options['wpMsgFormat']; $msg = nsFormatMessage($msgFormat, $postID); $msgTFormat = $options['wpMsgTFormat']; $msgT = nsFormatMessage($msgTFormat, $postID);
 
 
 
 
 
175
  nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
176
  }
177
- $dusername = $options['wpUName']; $link = urlencode($link); $desc = urlencode(substr($msgT, 0, 250)); $ext = urlencode(substr($msg, 0, 1000));
178
  $t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = implode(',',$tggs);
179
  $postCats = wp_get_post_categories($postID); $cats = array(); foreach($postCats as $c){ $cat = get_category($c); $cats[] = str_ireplace('&','&amp;',$cat->name); } // $cats = implode(',',$catsA);
180
-
181
- //## Post
182
- require_once ('apis/xmlrpc-client.php'); $nxsToWPclient = new NXS_XMLRPC_Client($options['wpURL']); $nxsToWPclient->debug = false;
183
- if ($imgURL!=='' && stripos($imgURL, 'http')!==false) {
184
- // $handle = fopen($imgURL, "rb"); $filedata = ''; while (!feof($handle)) {$filedata .= fread($handle, 8192);} fclose($handle);
185
- $filedata = wp_remote_get($imgURL); if (! is_wp_error($filedata) ) $filedata = $filedata['body']; // echo "AWC?";
186
- $data = array('name' => 'image-'.$postID.'.jpg', 'type' => 'image/jpg', 'bits' => new NXS_XMLRPC_Base64($filedata), true);
187
- $status = $nxsToWPclient->query('metaWeblog.newMediaObject', $postID, $options['wpUName'], $pass, $data); $imgResp = $nxsToWPclient->getResponse(); $gid = $imgResp['id'];
188
- } else $gid = '';
189
-
190
- $params = array(0, $options['wpUName'], $pass, array('software_version'));
191
- if (!$nxsToWPclient->query('wp.getOptions', $params)) { $ret = 'Something went wrong - '.$nxsToWPclient->getErrorCode().' : '.$nxsToWPclient->getErrorMessage();} else $ret = 'OK';
192
- $rwpOpt = $nxsToWPclient->getResponse(); $rwpOpt = $rwpOpt['software_version']['value']; $rwpOpt = floatval($rwpOpt); //prr($rwpOpt);prr($nxsToWPclient);
193
-
194
- $extInfo = ' | PostID: '.$postID." - ".$post->post_title;
195
 
196
- if ($rwpOpt==0) {
197
- $errMsg = $nxsToWPclient->getErrorMessage(); if ($errMsg!='') $ret = $errMsg; else $ret = 'XMLRPC is not found or not active. WP admin - Settings - Writing - Enable XML-RPC';
198
- } else if ($rwpOpt<3.0) $ret = 'XMLRPC is too OLD - '.$rwpOpt.' You need at least 3.0'; else {
199
-
200
- if ($rwpOpt>3.3){
201
- $nxsToWPContent = array('title'=>$msgT, 'description'=>$msg, 'post_status'=>'draft', 'mt_excerpt'=>$post->post_excerpt, 'mt_allow_comments'=>1, 'mt_allow_pings'=>1, 'post_type'=>'post', 'mt_keywords'=>$tags, 'categories'=>($cats), 'custom_fields' => $customfields);
202
- $params = array(0, $options['wpUName'], $pass, $nxsToWPContent, true);
203
- if (!$nxsToWPclient->query('metaWeblog.newPost', $params)) { $ret = 'Something went wrong - '.$nxsToWPclient->getErrorCode().' : '.$nxsToWPclient->getErrorMessage();} else $ret = 'OK';
204
- $pid = $nxsToWPclient->getResponse();
205
-
206
- if ($gid!='') {
207
- $nxsToWPContent = array('post_thumbnail'=>$gid); $params = array(0, $options['wpUName'], $pass, $pid, $nxsToWPContent, true);
208
- if (!$nxsToWPclient->query('wp.editPost', $params)) { $ret = 'Something went wrong - '.$nxsToWPclient->getErrorCode().' : '.$nxsToWPclient->getErrorMessage();} else $ret = 'OK';
209
  }
210
- $nxsToWPContent = array('post_status'=>'publish'); $params = array(0, $options['wpUName'], $pass, $pid, $nxsToWPContent, true);
211
- if (!$nxsToWPclient->query('wp.editPost', $params)) { $ret = 'Something went wrong - '.$nxsToWPclient->getErrorCode().' : '.$nxsToWPclient->getErrorMessage();} else $ret = 'OK';
212
- } else {
213
- $nxsToWPContent = array('title'=>$msgT, 'description'=>$msg, 'post_status'=>'publish', 'mt_allow_comments'=>1, 'mt_allow_pings'=>1, 'post_type'=>'post', 'mt_keywords'=>$tags, 'categories'=>($cats), 'custom_fields' => $customfields);
214
- $params = array(0, $options['wpUName'], $pass, $nxsToWPContent, true);
215
- if (!$nxsToWPclient->query('metaWeblog.newPost', $params)) { $ret = 'Something went wrong - '.$nxsToWPclient->getErrorCode().' : '.$nxsToWPclient->getErrorMessage();} else $ret = 'OK';
216
- $pid = $nxsToWPclient->getResponse();
217
- }
218
- } if ($ret!='OK') { if ($postID=='0') echo $ret;
219
- nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);
220
- } else { if ($postID=='0') { echo 'OK - Message Posted, please see your WP Blog'; nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); } else
221
- { nxs_metaMarkAsPosted($postID, 'WP', $options['ii'], array('isPosted'=>'1', 'pgID'=>$pid, 'pDate'=>date('Y-m-d H:i:s')));
222
- do_action('nxs_actOnWP', array('postID'=>$postID, 'pgID'=>$pid, 'wpURL'=>$options['wpURL'], 'ii'=>$ii)); nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo);
223
- }
224
  }
225
- if ($ret == 'OK') return 200; else return $ret;
 
226
  }
227
  }
228
  ?>
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', 'nxs_snap'); echo ")"; ?></div><?php } ?>
13
  </div>
14
  </div>
15
  <div class="nxs_box_inside">
16
  <?php foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = str_ireplace('/xmlrpc.php','', str_ireplace('http://','', str_ireplace('https://','', $pbo['wpURL']))); ?>
17
  <p style="margin:0px;margin-left:5px;">
18
+ <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> />
19
+ <?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 } ?>
20
+ <?php if (isset($pbo['rpstOn']) && (int)$pbo['rpstOn'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popReActive');" onmouseover="nxs_showPopUpInfo('popReActive', event);"><?php echo "*[R]*" ?></span><?php } ?>
21
  <strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
22
  &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', 'nxs_snap'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>&nbsp;&nbsp;
23
  <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
24
+ </p><?php $pbo['ntInfo'] = $ntInfo; $this->showNTSettings($indx, $pbo);
25
  }?>
26
  </div>
27
  </div> <?php
28
  }
29
  //#### Show NEW Settings Page
30
+ function showNewNTSettings($mgpo){ $options = array('nName'=>'', 'doWP'=>'1', 'wpUName'=>'', 'wpPageID'=>'', 'wpAttch'=>'', 'wpPass'=>'', 'wpURL'=>''); $options['ntInfo']= array('lcode'=>'wp'); $this->showNTSettings($mgpo, $options, true);}
31
  //#### Show Unit Settings
32
+ function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl; $nt = $options['ntInfo']['lcode']; $ntU = strtoupper($nt);
33
+ 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'] = '';
34
+ if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; ?>
35
+ <div id="doWP<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>"> <input type="hidden" name="apDoSWP<?php echo $ii; ?>" value="0" id="apDoSWP<?php echo $ii; ?>" />
36
 
37
  <div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/wp16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-wp-based-social-networks-auto-poster-wordpress/"><?php $nType="Wordpress"; printf( __( 'Detailed %s Installation/Configuration Instructions', 'nxs_snap' ), $nType); ?></a></div>
38
 
39
  <?php if ($isNew){ ?> <br/>You can setup any Wordpress based blog with activated XML-RPC support (WP Admin->Settimgs->Writing->Remote Publishing->Check XML-RPC). Wordpress.com and Blog.com supported as well.<br/><br/> <?php } ?>
40
 
41
+ <div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'nxs_snap'); ?></i> </div><input name="wp[<?php echo $ii; ?>][nName]" id="wpnName<?php echo $ii; ?>" style="font-weight: bold; color: #005800; border: 1px solid #ACACAC; width: 40%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['nName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /><br/>
42
+ <?php echo nxs_addQTranslSel('wp', $ii, $options['qTLng']); ?>
43
 
44
+ <br/>
45
+ <ul class="nsx_tabs">
46
+ <li><a href="#nsx<?php echo $nt.$ii ?>_tab1"><?php _e('Account Info', 'nxs_snap'); ?></a></li>
47
+ <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'nxs_snap'); ?></a></li>
48
+ </ul>
49
+ <div class="nsx_tab_container"><?php /* ######################## Account Tab ####################### */ ?>
50
+ <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%;">
51
+
52
 
53
+ <div style="width:100%;"><strong>XMLRPC URL:</strong> </div><input name="wp[<?php echo $ii; ?>][apWPURL]" id="apWPURL" style="width: 50%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['wpURL'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
54
  <p style="font-size: 11px; margin: 0px;">Usually its a URL of your Wordpress installation with /xmlrpc.php at the end.<br/> Please use <b style="color: #005800;">http://YourUserName.wordpress.com/xmlrpc.php</b> (replace YourUserName with your user name - for example <i style="color: #005800;">http://nextscripts.wordpress.com/xmlrpc.php</i>) for Wordpress.com blogs. <br/> Please use <b style="color: #005800;">http://YourUserName.blog.com/xmlrpc.php</b> (replace YourUserName with your user name - for example <i style="color: #005800;">http://nextscripts.blog.com/xmlrpc.php</i> for Blog.com blogs</p>
55
 
56
+ <div style="width:100%;"><br/><strong>Blog Username:</strong> </div><input name="wp[<?php echo $ii; ?>][apWPUName]" id="apWPUName" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['wpUName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
57
+ <div style="width:100%;"><strong>Blog Password:</strong> </div><input name="wp[<?php echo $ii; ?>][apWPPass]" id="apWPPass" type="password" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities(substr($options['wpPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['wpPass'], 5)):$options['wpPass'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /> <br/>
58
 
59
  <?php if ($isNew) { ?> <input type="hidden" name="wp[<?php echo $ii; ?>][apDoWP]" value="1" id="apDoNewWP<?php echo $ii; ?>" /> <?php } ?>
60
 
64
  <div style="width:100%;"><strong id="altFormatText"><?php _e('Post Title Format', 'nxs_snap'); ?></strong>
65
  (<a href="#" id="apWPMsgTFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apWPMsgTFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)
66
  </div>
67
+ <input name="wp[<?php echo $ii; ?>][apWPMsgTFrmt]" id="apWPMsgTFrmt" style="width: 50%;" onfocus="mxs_showFrmtInfo('apWPMsgTFrmt<?php echo $ii; ?>');" value="<?php if ($isNew) echo "%TITLE%"; else _e(apply_filters('format_to_edit', htmlentities($options['wpMsgTFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap'); ?>" /> <?php nxs_doShowHint("apWPMsgTFrmt".$ii); ?>
68
 
69
  </div>
70
  <div id="altFormat" style="">
73
  </div>
74
 
75
 
76
+ <textarea cols="150" rows="3" id="wp<?php echo $ii; ?>SNAPformat" name="wp[<?php echo $ii; ?>][apWPMsgFrmt]" style="width:51%;max-width: 650px;" onfocus="jQuery('#wp<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('apWPMsgFrmt<?php echo $ii; ?>');"><?php if ($isNew) echo "%EXCERPT%"; else _e(apply_filters('format_to_edit', htmlentities($options['wpMsgFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap'); ?></textarea>
77
  <?php nxs_doShowHint("apWPMsgFrmt".$ii); ?>
78
 
79
  </div><br/>
80
 
81
+ <?php if ($options['wpPass']!='') { ?>
82
+
83
  <b><?php _e('Test your settings', 'nxs_snap'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('WP', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'nxs_snap' ), $nType); ?></a>
84
 
85
  <?php }
86
 
87
+ ?></div>
88
+ <?php /* ######################## Advanced Tab ####################### */ ?>
89
+ <div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content">
90
+
91
+ <?php if (!$isNew) { ?> <div class="nxs_tls_cpt"><?php _e('Categories', 'nxs_snap'); ?></div>
92
+ <div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
93
+ <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
94
+ <input value="1" id="catSelS<?php echo $ntU; ?><?php echo $ii; ?>" type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_<?php echo $ntU; ?><?php echo $ii; ?>" onclick="jQuery('#catSelS<?php echo $ntU; ?><?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('<?php echo $ntU; ?><?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($options['catSelEd']!='') echo "[".(substr_count($options['catSelEd'], ",")+1)."]"; ?></a>
95
+ <input type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
96
+ <br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
97
+ <br/>
98
+ <?php } ?>
99
+
100
+ <?php nxs_addPostingDelaySelV3($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']); ?>
101
+ <?php nxs_showRepostSettings($nt, $ii, $options); ?>
102
+
103
+
104
+ </div> <?php /* #### End of Tab #### */ ?>
105
+ </div><br/> <?php /* #### End of Tabs #### */ ?>
106
+
107
+ <div class="submit clear" style="padding-bottom: 0px;"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div></div><?php
108
  }
109
  //#### Set Unit Settings from POST
110
  function setNTSettings($post, $options){ global $nxs_snapThisPageUrl; $code = 'WP'; $lcode = 'wp';
121
  if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
122
 
123
  if (isset($pval['apDoWP'])) $options[$ii]['doWP'] = $pval['apDoWP']; else $options[$ii]['doWP'] = 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
  }
131
  } return $options;
132
  }
133
  //#### Show Post->Edit Meta Box Settings
134
+ function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID; $nt = 'wp'; $ntU = 'WP';
135
+ foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapWP', true)); if (!empty($pMeta) && is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
136
+ if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = ''; if (empty($ntOpt['urlToUse'])) $ntOpt['urlToUse'] = '';
137
+ $doWP = $ntOpt['doWP'] && (is_array($pMeta) || $ntOpt['catSel']!='1'); $imgToUse = $ntOpt['imgToUse'];
138
  $isAvailWP = $ntOpt['wpUName']!='' && $ntOpt['wpPass']!=''; $wpMsgFormat = htmlentities($ntOpt['wpMsgFormat'], ENT_COMPAT, "UTF-8"); $wpMsgTFormat = htmlentities($ntOpt['wpMsgTFormat'], ENT_COMPAT, "UTF-8");
139
  ?>
140
  <tr><th style="text-align:left;" colspan="2"><?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_WP<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
142
  <?php if ($post->post_status == "publish") { ?> <input type="hidden" name="wp[<?php echo $ii; ?>][doWP]" value="<?php echo $doWP;?>"> <?php } ?> <?php } ?>
143
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/wp16.png);">WP Blog - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
144
  if ($post->post_status == "publish" && $isAvailWP) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToWP_repostButton" id="rePostToWP_button" value="<?php _e('Repost to WP Blog', 'nxs_snap') ?>" />
145
+ <?php } ?>
146
 
147
  <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) { $wpURL = str_ireplace('/xmlrpc.php', '', $ntOpt['wpURL']);
148
  if (substr($wpURL, -1)=='/') $wpURL = substr($wpURL, 0, -1); $wpURL = $wpURL."/";
153
  </td></tr>
154
 
155
  <?php if (!$isAvailWP) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your WP Blog Account to AutoPost to WP Blogs</b>
156
+ <?php } else { if ($post->post_status != "publish" && function_exists('nxs_doSMAS5') ) { nxs_doSMAS5($nt, $ii, $ntOpt); } ?>
157
+
158
+ <?php if ($ntOpt['rpstOn']=='1') { ?>
159
+
160
+ <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top:6px; text-align:right; width:60px; padding-right:10px;">
161
+ <input value="0" type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]"/><input value="nxsi<?php echo $ii; ?>wp" type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]" <?php if (!empty($ntOpt['rpstPostIncl'])) echo "checked"; ?> />
162
+ </th>
163
+ <td> <?php _e('Include in "Auto-Reposting" to this network.', 'nxs_snap') ?>
164
+ </td></tr> <?php } ?>
165
 
166
  <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top:6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Title Format:', 'nxs_snap') ?></th>
167
  <td><input value="<?php echo $wpMsgTFormat ?>" type="text" name="wp[<?php echo $ii; ?>][SNAPformatT]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apWPTMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apWPTMsgFrmt".$ii); ?></td></tr>
170
  <td>
171
  <textarea cols="150" rows="1" id="wp<?php echo $ii; ?>SNAPformat" name="wp[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('#wp<?php echo $ii; ?>SNAPformat').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apWPMsgFrmt<?php echo $ii; ?>');"><?php echo $wpMsgFormat; ?></textarea>
172
  <?php nxs_doShowHint("apWPMsgFrmt".$ii); ?></td></tr>
173
+ <?php /* ## Select Image & URL ## */ nxs_showImgToUseDlg($nt, $ii, $imgToUse); ?>
174
 
175
  <?php }
176
  }
179
  function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
180
  if (isset($pMeta['SNAPformat'])) $optMt['wpMsgFormat'] = $pMeta['SNAPformat'];
181
  if (isset($pMeta['SNAPformatT'])) $optMt['wpMsgTFormat'] = $pMeta['SNAPformatT'];
182
+ if (isset($pMeta['imgToUse'])) $optMt['imgToUse'] = $pMeta['imgToUse'];
183
+ if (isset($pMeta['timeToRun'])) $optMt['timeToRun'] = $pMeta['timeToRun']; if (isset($pMeta['rpstPostIncl'])) $optMt['rpstPostIncl'] = $pMeta['rpstPostIncl'];
184
  if (isset($pMeta['doWP'])) $optMt['doWP'] = $pMeta['doWP'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doWP'] = 0; }
185
  if (isset($pMeta['SNAPincludeWP']) && $pMeta['SNAPincludeWP'] == '1' ) $optMt['doWP'] = 1;
186
  return $optMt;
187
  }
188
  }}
189
  if (!function_exists("nxs_rePostToWP_ajax")) {
190
+ function nxs_rePostToWP_ajax() { check_ajax_referer('nxsSsPageWPN'); $postID = $_POST['id']; $options = get_option('NS_SNAutoPoster');
191
  foreach ($options['wp'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj';//if ($two['gpPageID'].$two['gpUName']==$_POST['nid']) {
192
  $gppo = get_post_meta($postID, 'snapWP', true); $gppo = maybe_unserialize($gppo);// prr($gppo);
193
  if (is_array($gppo) && isset($gppo[$ii]) && is_array($gppo[$ii])){ $ntClInst = new nxs_snapClassWP(); $two = $ntClInst->adjMetaOpt($two, $gppo[$ii]); }
197
  }
198
 
199
  if (!function_exists("nxs_doPublishToWP")) { //## Second Function to Post to WP
200
+ function nxs_doPublishToWP($postID, $options){ $ntCd = 'WP'; $ntCdL = 'wp'; $ntNm = 'WP Based Blog'; global $plgn_NS_SNAutoPoster;
201
+ if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
202
  //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToWP', 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, 'POSTID'=>$postID, 'ACCNAME'=>$options['nName']));
205
+ if (empty($options['imgToUse'])) $options['imgToUse'] = ''; if (empty($options['imgSize'])) $options['imgSize'] = '';
206
+
207
  $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));
208
  $logNT = '<span style="color:#1A9EE6">WP</span> - '.$options['nName'];
209
  $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);
212
  nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$uqID); return;
213
  }
214
  }
215
+
216
+ if ($postID=='0') {
217
+ echo "Testing ... <br/><br/>"; $urlToGo = home_url(); $options['wpMsgTFormat'] = 'Test Link from '.$urlToGo; $options['wpMsgFormat'] = 'Test post please ignore';
218
+ } else { $post = get_post($postID); if(!$post) return; $link = get_permalink($postID);
219
+ $options['wpMsgFormat'] = nsFormatMessage($options['wpMsgFormat'], $postID); $options['wpMsgTFormat'] = nsFormatMessage($options['wpMsgTFormat'], $postID);
220
+ //## MyURL - URLToGo code
221
+ if (!isset($options['urlToUse']) || trim($options['urlToUse'])=='') $myurl = trim(get_post_meta($postID, 'snap_MYURL', true)); if ($myurl!='') $options['urlToUse'] = $myurl;
222
+ if (isset($options['urlToUse']) && trim($options['urlToUse'])!='') { $urlToGo = $options['urlToUse']; $options['useFBGURLInfo'] = true; } else $urlToGo = get_permalink($postID);
223
+ $gOptions = $plgn_NS_SNAutoPoster->nxs_options; $addURLParams = trim($gOptions['addURLParams']); if($addURLParams!='') $urlToGo .= (strpos($urlToGo,'?')!==false?'&':'?').$addURLParams;
224
  nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));
225
  }
226
+
227
  $t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = implode(',',$tggs);
228
  $postCats = wp_get_post_categories($postID); $cats = array(); foreach($postCats as $c){ $cat = get_category($c); $cats[] = str_ireplace('&','&amp;',$cat->name); } // $cats = implode(',',$catsA);
229
+
230
+ $extInfo = ' | PostID: '.$postID." - ".(!empty($post) && is_object($post)?$post->post_title:'');
 
 
 
 
 
 
 
 
 
 
 
 
 
231
 
232
+ //## Message & Format
233
+ if (trim($options['imgToUse'])!='') $imgURL = $options['imgToUse']; else $imgURL = nxs_getPostImage($postID, 'full');
234
+ $message = array('siteName'=>$blogTitle, 'url'=>$urlToGo, 'imageURL'=>$imgURL, 'tags'=>$tags, 'cats'=>$cats, 'authorName'=>'', 'orID'=>$postID);
235
+ //## Actual Post
236
+ $ntToPost = new nxs_class_SNAP_WP(); $ret = $ntToPost->doPostToNT($options, $message);
237
+ //## Process Results
238
+ if (!is_array($ret) || $ret['isPosted']!='1') { //## Error
239
+ if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);
240
+ } else { // ## All Good - log it.
241
+ if ($postID=='0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo _e('OK - Message Posted, please see your '.$logNT.' Page. ', 'nxs_snap'); }
242
+ else { do_action('nxs_actOnWP', array('postID'=>$postID, 'pgID'=>$ret['postID'], 'wpURL'=>$options['wpURL'], 'ii'=>$ii));
243
+ 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);
 
244
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
245
  }
246
+ //## Return Result
247
+ if ($ret['isPosted']=='1') return 200; else return print_r($ret, true);
248
  }
249
  }
250
  ?>
inc-cl/yt.api.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //## NextScripts FriendFeed Connection Class
3
+ $nxs_snapAPINts[] = array('code'=>'YT', 'lcode'=>'yt', 'name'=>'YouTube');
4
+
5
+ if (!class_exists("nxs_class_SNAP_YT")) { class nxs_class_SNAP_YT {
6
+
7
+ var $ntCode = 'YT';
8
+ var $ntLCode = 'yt';
9
+
10
+ function doPost($options, $message){ if (!is_array($options)) return false;
11
+ foreach ($options as $ntOpts) $out[] = $this->doPostToNT($ntOpts, $message);
12
+ return $out;
13
+ }
14
+ function doPostToNT($options, $message){ $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>'');
15
+ //## Check settings
16
+ if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }
17
+ if (!isset($options['ytUName']) || trim($options['ytPass'])=='') { $badOut['Error'] = 'Not Configured'; return $badOut; }
18
+ $pass = substr($options['ytPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['ytPass'], 5)):$options['ytPass'];
19
+ //## Format
20
+ $msg = nxs_doFormatMsg($options['ytMsgFormat'], $message);
21
+
22
+ $loginError = doConnectToGooglePlus2($options['ytUName'], $pass, 'YT');
23
+ if ($loginError!==false) {if ($postID=='0') echo $loginError; nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($loginError, true)." - BAD USER/PASS", $extInfo); return "BAD USER/PASS";}
24
+
25
+ $ret = doPostToYouTube($msg, $options['ytPageID'], $message['videoURL'], $options['ytGPPageID']); //prr($ret);
26
+ if ($ret=='OK') $ret = array("code"=>"OK", "post_id"=>'');
27
+ if ( (!is_array($ret)) && $ret!='OK') { $badOut['Error'] .= 'Something went wrong - NO PID '.print_r($ret, true); }
28
+ else return array('postID'=>$ret['post_id'], 'isPosted'=>1, 'postURL'=>$ret['post_id'], 'pDate'=>date('Y-m-d H:i:s'));
29
+ return $badOut;
30
+ }
31
+ }}
32
+ ?>
inc-cl/yt.php CHANGED
@@ -8,7 +8,7 @@ if (!class_exists("nxs_snapClassYT")) { class nxs_snapClassYT {
8
  <div class="nxs_box">
9
  <div class="nxs_box_header">
10
  <div class="nsx_iconedTitle" style="margin-bottom:1px;background-image:url(<?php echo $nxs_plurl;?>img/<?php echo $ntInfo['lcode']; ?>16.png);"><?php echo $ntInfo['name']; ?>
11
- <?php $cbo = count($ntOpts); ?> <?php wp_nonce_field( 'ns'.$ntInfo['code'], 'ns'.$ntInfo['code'].'_wpnonce' ); ?>
12
  <?php if ($cbo>1){ ?><div class="nsBigText"><?php echo "(".($cbo=='0'?'No':$cbo)." "; _e('accounts', 'nxs_snap'); echo ")"; ?></div><?php } ?>
13
  </div>
14
  </div>
@@ -16,64 +16,88 @@ if (!class_exists("nxs_snapClassYT")) { class nxs_snapClassYT {
16
  <?php if(!function_exists('doPostToGooglePlus')) {?> YouTube doesn't have a built-in API for automated posts yet. The current <a href="http://developers.google.com/+/api/">YouTube API</a> is "Read Only" and can't be used for posting. <br/>You need to get a special <a target="_blank" href="http://www.nextscripts.com/google-plus-automated-posting">library module</a> to be able to publish your content to YouTube.
17
  <?php } else foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
18
  <p style="margin:0px;margin-left:5px;">
19
- <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> /> <?php if ((int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ",")+1)."]*" ?></span><?php } ?>
 
 
20
  <strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
21
  &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', 'nxs_snap'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>&nbsp;&nbsp;
22
  <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
23
- </p><?php $this->showNTSettings($indx, $pbo);
24
  }?>
25
  </div>
26
  </div> <?php
27
  }
28
  //#### Show NEW Settings Page
29
- function showNewNTSettings($myto){ $yto = array('nName'=>'', 'doYT'=>'1', 'ytUName'=>'', 'ytPageID'=>'', 'ytCommID'=>'', 'postType'=>'A', 'ytPass'=>''); $this->showNTSettings($myto, $yto, true);}
30
  //#### Show Unit Settings
31
- function showNTSettings($ii, $yto, $isNew=false){ global $nxs_plurl; ?>
32
- <div id="doYT<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>" style="background-image: url(<?php echo $nxs_plurl; ?>img/yt-bg.png); background-position:90% 10%;"> <input type="hidden" name="apDoSYT<?php echo $ii; ?>" value="0" id="apDoSYT<?php echo $ii; ?>" />
 
 
33
  <?php if(!function_exists('doPostToGooglePlus')) {?><span style="color:#580000; font-size: 16px;"><br/><br/>
34
  <b><?php _e('YouTube API Library not found', 'nxs_snap'); ?></b>
35
  <br/><br/> <?php _e('YouTube doesn\'t have a built-in API for automated posts yet.', 'nxs_snap'); ?> <br/><?php _e('The current <a target="_blank" href="http://developers.google.com/+/api/">YouTube API</a> is "Read Only" and can\'t be used for posting. <br/><br/>You need to get a special <a target="_blank" href="http://www.nextscripts.com/google-plus-automated-posting"><b>API Library Module</b></a> to be able to publish your content to YouTube.', 'nxs_snap'); ?></span></div>
36
  <?php return; }; ?>
37
  <div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/yt16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-google-plus-social-networks-auto-poster-wordpress/"><?php $nType="YouTube"; printf( __( 'Detailed %s Installation/Configuration Instructions', 'nxs_snap' ), $nType); ?></a></div>
38
 
39
- <div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easely identify it', 'nxs_snap'); ?></i> </div><input name="yt[<?php echo $ii; ?>][nName]" id="ytnName<?php echo $ii; ?>" style="font-weight: bold; color: #005800; border: 1px solid #ACACAC; width: 40%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($yto['nName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /><br/>
40
- <?php echo nxs_addQTranslSel('yt', $ii, $yto['qTLng']); ?><?php echo nxs_addPostingDelaySel('yt', $ii, $yto['nHrs'], $yto['nMin']); ?>
41
 
42
- <?php if (!$isNew) { ?>
43
- <div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
44
- <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="yt[<?php echo $ii; ?>][catSel]" <?php if ((int)$yto['catSel'] != 1) echo "checked"; ?> /> All
45
- <input value="1" id="catSelSYT<?php echo $ii; ?>" type="radio" name="yt[<?php echo $ii; ?>][catSel]" <?php if ((int)$yto['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_YT<?php echo $ii; ?>" onclick="jQuery('#catSelSYT<?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('YT<?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_YT<?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($yto['catSelEd']!='') echo "[".(substr_count($yto['catSelEd'], ",")+1)."]"; ?></a>
46
- <input type="hidden" name="yt[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_YT<?php echo $ii; ?>" value="<?php echo $yto['catSelEd']; ?>" />
47
- <br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
48
- <br/>
49
- <?php } ?>
50
 
51
- <div style="width:100%;"><strong>YouTube(Google) Username:</strong> </div><input name="yt[<?php echo $ii; ?>][apYTUName]" id="apYTUName" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($yto['ytUName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
52
- <div style="width:100%;"><strong>YouTube(Google) Password:</strong> </div><input name="yt[<?php echo $ii; ?>][apYTPass]" id="apYTPass" type="password" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities(substr($yto['ytPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($yto['ytPass'], 5)):$yto['ytPass'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /> <br/>
53
  <p><div style="width:100%;"><strong>YouTube Channel Page URL:</strong>
54
 
55
- </div><input name="yt[<?php echo $ii; ?>][apYTPage]" id="apYTPage" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($yto['ytPageID'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
56
  <br/><br/>
57
 
58
  <p><div style="width:100%;"><i style="color: gray;"><strong >Google+ Page ID:</strong>&nbsp;Fill this only if you are posting to youTube as your Google+ page. Please leave this empty otherwise.</i>
59
 
60
- </div><input name="yt[<?php echo $ii; ?>][ytGPPageID]" id="ytGPPageID" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($yto['ytGPPageID'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
61
  <br/><br/>
62
 
63
  <div id="altFormat" style="">
64
  <div style="width:100%;"><strong id="altFormatText"><?php _e('Message text Format', 'nxs_snap'); ?>:</strong> (<a href="#" id="apYTMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apYTMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)
65
  </div>
66
 
67
- <textarea cols="150" rows="3" id="yt<?php echo $ii; ?>SNAPformat" name="yt[<?php echo $ii; ?>][apYTMsgFrmt]" style="width:51%;max-width: 650px;" onfocus="jQuery('#yt<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('apYTMsgFrmt<?php echo $ii; ?>');"><?php if ($isNew) _e("New post: %TITLE% - %URL%", 'nxs_snap'); else _e(apply_filters('format_to_edit', htmlentities($yto['ytMsgFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap'); ?></textarea>
68
 
69
  <?php nxs_doShowHint("apYTMsgFrmt".$ii); ?>
70
  </div><br/>
71
 
72
  <?php if ($isNew) { ?> <input type="hidden" name="yt[<?php echo $ii; ?>][apDoYT]" value="1" id="apDoNewYT<?php echo $ii; ?>" /> <?php } ?>
73
- <?php if ($yto['ytPass']!='') { ?>
74
- <?php wp_nonce_field( 'rePostToYT', 'rePostToYT_wpnonce' ); ?>
75
  <b><?php _e('Test your settings', 'nxs_snap'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('YT', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'nxs_snap' ), $nType); ?></a> <?php }
76
- ?><div class="submit"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div></div><?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  }
78
  //#### Set Unit Settings from POST
79
  function setNTSettings($post, $options){ global $nxs_snapThisPageUrl; $code = 'YT'; $lcode = 'yt';
@@ -85,28 +109,26 @@ if (!class_exists("nxs_snapClassYT")) { class nxs_snapClassYT {
85
  if (isset($pval['apYTPage'])) $options[$ii]['ytPageID'] = trim($pval['apYTPage']);
86
  if (isset($pval['ytGPPageID'])) $options[$ii]['ytGPPageID'] = trim($pval['ytGPPageID']);
87
 
88
- if (isset($pval['ytCommID'])) $options[$ii]['ytCommID'] = trim($pval['ytCommID']);
89
-
90
  if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']);
91
  if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
92
 
93
  if (isset($pval['postType'])) $options[$ii]['postType'] = $pval['postType'];
94
  if (isset($pval['apYTMsgFrmt'])) $options[$ii]['ytMsgFormat'] = trim($pval['apYTMsgFrmt']);
95
  if (isset($pval['apDoYT'])) $options[$ii]['doYT'] = $pval['apDoYT']; else $options[$ii]['doYT'] = 0;
 
 
 
 
96
  if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
97
  if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
98
  }
99
  } return $options;
100
  }
101
  //#### Show Post->Edit Meta Box Settings
102
- function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID;
103
  foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapYT', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
104
  $doYT = $ntOpt['doYT'] && (is_array($pMeta) || $ntOpt['catSel']!='1');
105
- $isAvailYT = $ntOpt['ytUName']!='' && $ntOpt['ytPass']!=''; $ytMsgFormat = htmlentities($ntOpt['ytMsgFormat'], ENT_COMPAT, "UTF-8");
106
- if(!isset($ntOpt['postType']) || $ntOpt['postType']=='') {
107
- if ((int)$ntOpt['imgPost'] == 1) $ntOpt['postType'] = 'I';
108
- if ((int)$ntOpt['ytAttch'] == 1 || $isNew) $ntOpt['postType'] = 'A';
109
- } $ytPostType = $ntOpt['postType'];
110
  ?>
111
  <tr><th style="text-align:left;" colspan="2"><?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_YT<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
112
  <?php if ($isAvailYT) { ?><input class="nxsGrpDoChb" value="1" id="doYT<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="yt[<?php echo $ii; ?>][doYT]" <?php if ((int)$doYT == 1) echo 'checked="checked" title="def"'; ?> />
@@ -114,7 +136,7 @@ if (!class_exists("nxs_snapClassYT")) { class nxs_snapClassYT {
114
 
115
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/yt16.png);">YouTube - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
116
  if ($post->post_status == "publish" && $isAvailYT) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToYT_repostButton" id="rePostToYT_button" value="<?php _e('Repost to YouTube', 'nxs_snap') ?>" />
117
- <?php wp_nonce_field( 'rePostToYT', 'rePostToYT_wpnonce' ); } ?>
118
 
119
  <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
120
 
@@ -125,7 +147,15 @@ if (!class_exists("nxs_snapClassYT")) { class nxs_snapClassYT {
125
  </td></tr>
126
 
127
  <?php if (!$isAvailYT) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your YouTube Account to AutoPost to YouTube</b>
128
- <?php } elseif ($post->post_status != "puZblish") { ?>
 
 
 
 
 
 
 
 
129
 
130
 
131
  <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Message Format:', 'nxs_snap') ?></th>
@@ -144,7 +174,9 @@ if (!class_exists("nxs_snapClassYT")) { class nxs_snapClassYT {
144
  }
145
  //#### Save Meta Tags to the Post
146
  function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
147
- if (isset($pMeta['SNAPformat'])) $optMt['ytMsgFormat'] = $pMeta['SNAPformat'];
 
 
148
  if (isset($pMeta['postType'])) $optMt['postType'] = $pMeta['postType'];
149
  if (isset($pMeta['doYT'])) $optMt['doYT'] = $pMeta['doYT'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doYT'] = 0; }
150
  if (isset($pMeta['SNAPincludeYT']) && $pMeta['SNAPincludeYT'] == '1' ) $optMt['doYT'] = 1;
@@ -152,7 +184,7 @@ if (!class_exists("nxs_snapClassYT")) { class nxs_snapClassYT {
152
  }
153
  }}
154
  if (!function_exists("nxs_rePostToYT_ajax")) {
155
- function nxs_rePostToYT_ajax() { check_ajax_referer('rePostToYT'); $postID = $_POST['id']; global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;
156
  foreach ($options['yt'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj'; //if ($two['ytPageID'].$two['ytUName']==$_POST['nid']) {
157
  $ytpo = get_post_meta($postID, 'snapYT', true); $ytpo = maybe_unserialize($ytpo);// prr($ytpo);
158
  if (is_array($ytpo) && isset($ytpo[$ii]) && is_array($ytpo[$ii])){ $ntClInst = new nxs_snapClassYT(); $two = $ntClInst->adjMetaOpt($two, $ytpo[$ii]); }
@@ -162,9 +194,13 @@ if (!function_exists("nxs_rePostToYT_ajax")) {
162
  }
163
 
164
  if (!function_exists("nxs_doPublishToYT")) { //## Second Function to Post to G+
165
- function nxs_doPublishToYT($postID, $options){ $ntCd = 'YT'; $ntCdL = 'yt'; $ntNm = 'YouTube'; global $nxs_gCookiesArr;
 
166
  // $backtrace = debug_backtrace();
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', 'nxs_snap'); echo ")"; ?></div><?php } ?>
13
  </div>
14
  </div>
16
  <?php if(!function_exists('doPostToGooglePlus')) {?> YouTube doesn't have a built-in API for automated posts yet. The current <a href="http://developers.google.com/+/api/">YouTube API</a> is "Read Only" and can't be used for posting. <br/>You need to get a special <a target="_blank" href="http://www.nextscripts.com/google-plus-automated-posting">library module</a> to be able to publish your content to YouTube.
17
  <?php } else foreach ($ntOpts as $indx=>$pbo){ if (trim($pbo['nName']=='')) $pbo['nName'] = $pbo[$ntInfo['defNName']]; ?>
18
  <p style="margin:0px;margin-left:5px;">
19
+ <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" onchange="doShowHideBlocks('<?php echo $ntInfo['code']; ?>');" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1) echo "checked"; ?> />
20
+ <?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 } ?>
21
+ <?php if (isset($pbo['rpstOn']) && (int)$pbo['rpstOn'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popReActive');" onmouseover="nxs_showPopUpInfo('popReActive', event);"><?php echo "*[R]*" ?></span><?php } ?>
22
  <strong><?php _e('Auto-publish to', 'nxs_snap'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong>
23
  &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', 'nxs_snap'); ?> ==&gt;</b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>A" href="#" onclick="doShowHideBlocks2('<?php echo $ntInfo['code'].$indx; ?>');return false;">[<?php _e('Show Settings', 'nxs_snap'); ?>]</a>&nbsp;&nbsp;
24
  <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'nxs_snap'); ?>]</a>
25
+ </p><?php $pbo['ntInfo'] = $ntInfo; $this->showNTSettings($indx, $pbo);
26
  }?>
27
  </div>
28
  </div> <?php
29
  }
30
  //#### Show NEW Settings Page
31
+ function showNewNTSettings($myto){ $options = array('nName'=>'', 'doYT'=>'1', 'ytUName'=>'', 'ytPageID'=>'', 'ytGPPageID'=>'', 'postType'=>'A', 'ytPass'=>''); $options['ntInfo']= array('lcode'=>'yt'); $this->showNTSettings($myto, $options, true);}
32
  //#### Show Unit Settings
33
+ function showNTSettings($ii, $options, $isNew=false){ global $nxs_plurl; $nt = $options['ntInfo']['lcode']; $ntU = strtoupper($nt);
34
+ 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'] = '';
35
+ if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; if (!isset($options['ytGPPageID'])) $options['ytGPPageID'] = ''; ?>
36
+ <div id="doYT<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>"> <input type="hidden" name="apDoSYT<?php echo $ii; ?>" value="0" id="apDoSYT<?php echo $ii; ?>" />
37
  <?php if(!function_exists('doPostToGooglePlus')) {?><span style="color:#580000; font-size: 16px;"><br/><br/>
38
  <b><?php _e('YouTube API Library not found', 'nxs_snap'); ?></b>
39
  <br/><br/> <?php _e('YouTube doesn\'t have a built-in API for automated posts yet.', 'nxs_snap'); ?> <br/><?php _e('The current <a target="_blank" href="http://developers.google.com/+/api/">YouTube API</a> is "Read Only" and can\'t be used for posting. <br/><br/>You need to get a special <a target="_blank" href="http://www.nextscripts.com/google-plus-automated-posting"><b>API Library Module</b></a> to be able to publish your content to YouTube.', 'nxs_snap'); ?></span></div>
40
  <?php return; }; ?>
41
  <div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/yt16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-google-plus-social-networks-auto-poster-wordpress/"><?php $nType="YouTube"; printf( __( 'Detailed %s Installation/Configuration Instructions', 'nxs_snap' ), $nType); ?></a></div>
42
 
43
+ <div style="width:100%;"><strong><?php _e('Account Nickname', 'nxs_snap'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'nxs_snap'); ?></i> </div><input name="yt[<?php echo $ii; ?>][nName]" id="ytnName<?php echo $ii; ?>" style="font-weight: bold; color: #005800; border: 1px solid #ACACAC; width: 40%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['nName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /><br/>
44
+ <?php echo nxs_addQTranslSel('yt', $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', 'nxs_snap'); ?></a></li>
49
+ <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'nxs_snap'); ?></a></li>
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%;"><strong>YouTube(Google) Username:</strong> </div><input name="yt[<?php echo $ii; ?>][apYTUName]" id="apYTUName" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['ytUName'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
56
+ <div style="width:100%;"><strong>YouTube(Google) Password:</strong> </div><input name="yt[<?php echo $ii; ?>][apYTPass]" id="apYTPass" type="password" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities(substr($options['ytPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['ytPass'], 5)):$options['ytPass'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" /> <br/>
57
  <p><div style="width:100%;"><strong>YouTube Channel Page URL:</strong>
58
 
59
+ </div><input name="yt[<?php echo $ii; ?>][apYTPage]" id="apYTPage" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['ytPageID'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
60
  <br/><br/>
61
 
62
  <p><div style="width:100%;"><i style="color: gray;"><strong >Google+ Page ID:</strong>&nbsp;Fill this only if you are posting to youTube as your Google+ page. Please leave this empty otherwise.</i>
63
 
64
+ </div><input name="yt[<?php echo $ii; ?>][ytGPPageID]" id="ytGPPageID" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['ytGPPageID'], ENT_COMPAT, "UTF-8")), 'nxs_snap') ?>" />
65
  <br/><br/>
66
 
67
  <div id="altFormat" style="">
68
  <div style="width:100%;"><strong id="altFormatText"><?php _e('Message text Format', 'nxs_snap'); ?>:</strong> (<a href="#" id="apYTMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apYTMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'nxs_snap'); ?></a>)
69
  </div>
70
 
71
+ <textarea cols="150" rows="3" id="yt<?php echo $ii; ?>SNAPformat" name="yt[<?php echo $ii; ?>][apYTMsgFrmt]" style="width:51%;max-width: 650px;" onfocus="jQuery('#yt<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('apYTMsgFrmt<?php echo $ii; ?>');"><?php if ($isNew) _e("New post: %TITLE% - %URL%", 'nxs_snap'); else _e(apply_filters('format_to_edit', htmlentities($options['ytMsgFormat'], ENT_COMPAT, "UTF-8")), 'nxs_snap'); ?></textarea>
72
 
73
  <?php nxs_doShowHint("apYTMsgFrmt".$ii); ?>
74
  </div><br/>
75
 
76
  <?php if ($isNew) { ?> <input type="hidden" name="yt[<?php echo $ii; ?>][apDoYT]" value="1" id="apDoNewYT<?php echo $ii; ?>" /> <?php } ?>
77
+ <?php if ($options['ytPass']!='') { ?>
78
+
79
  <b><?php _e('Test your settings', 'nxs_snap'); ?>:</b>&nbsp;&nbsp;&nbsp; <a href="#" class="NXSButton" onclick="testPost('YT', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'nxs_snap' ), $nType); ?></a> <?php }
80
+ ?></div>
81
+ <?php /* ######################## Advanced Tab ####################### */ ?>
82
+ <div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content">
83
+
84
+ <?php if (!$isNew) { ?> <div class="nxs_tls_cpt"><?php _e('Categories', 'nxs_snap'); ?></div>
85
+ <div style="width:100%;"><strong><?php _e('Categories', 'nxs_snap'); ?>:</strong>
86
+ <input value="0" id="catSelA<?php echo $ii; ?>" type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] != 1) echo "checked"; ?> /> All
87
+ <input value="1" id="catSelS<?php echo $ntU; ?><?php echo $ii; ?>" type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSel]" <?php if ((int)$options['catSel'] == 1) echo "checked"; ?> /> <a href="#" style="text-decoration: none;" class="showCats" id="nxs_SCA_<?php echo $ntU; ?><?php echo $ii; ?>" onclick="jQuery('#catSelS<?php echo $ntU; ?><?php echo $ii; ?>').attr('checked', true); jQuery('#tmpCatSelNT').val('<?php echo $ntU; ?><?php echo $ii; ?>'); nxs_markCats( jQuery('#nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>').val() ); jQuery('#showCatSel').bPopup({ modalClose: false, appendTo: '#nsStForm', opacity: 0.6, follow: [false, false], position: [75, 'auto']}); return false;">Selected<?php if ($options['catSelEd']!='') echo "[".(substr_count($options['catSelEd'], ",")+1)."]"; ?></a>
88
+ <input type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][catSelEd]" id="nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $options['catSelEd']; ?>" />
89
+ <br/><i><?php _e('Only selected categories will be autoposted to this account', 'nxs_snap'); ?></i></div>
90
+ <br/>
91
+ <?php } ?>
92
+
93
+ <?php nxs_addPostingDelaySelV3($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']); ?>
94
+ <?php nxs_showRepostSettings($nt, $ii, $options); ?>
95
+
96
+
97
+ </div> <?php /* #### End of Tab #### */ ?>
98
+ </div><br/> <?php /* #### End of Tabs #### */ ?>
99
+
100
+ <div class="submit clear" style="padding-bottom: 0px;"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'nxs_snap') ?>" /></div></div><?php
101
  }
102
  //#### Set Unit Settings from POST
103
  function setNTSettings($post, $options){ global $nxs_snapThisPageUrl; $code = 'YT'; $lcode = 'yt';
109
  if (isset($pval['apYTPage'])) $options[$ii]['ytPageID'] = trim($pval['apYTPage']);
110
  if (isset($pval['ytGPPageID'])) $options[$ii]['ytGPPageID'] = trim($pval['ytGPPageID']);
111
 
 
 
112
  if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']);
113
  if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';
114
 
115
  if (isset($pval['postType'])) $options[$ii]['postType'] = $pval['postType'];
116
  if (isset($pval['apYTMsgFrmt'])) $options[$ii]['ytMsgFormat'] = trim($pval['apYTMsgFrmt']);
117
  if (isset($pval['apDoYT'])) $options[$ii]['doYT'] = $pval['apDoYT']; else $options[$ii]['doYT'] = 0;
118
+
119
+ $options[$ii] = nxs_adjRpst($options[$ii], $pval);
120
+
121
+ if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']);
122
  if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);
123
  if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);
124
  }
125
  } return $options;
126
  }
127
  //#### Show Post->Edit Meta Box Settings
128
+ function showEdPostNTSettings($ntOpts, $post){ global $nxs_plurl; $post_id = $post->ID; $nt = 'yt'; $ntU = 'YT';
129
  foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapYT', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);
130
  $doYT = $ntOpt['doYT'] && (is_array($pMeta) || $ntOpt['catSel']!='1');
131
+ $isAvailYT = $ntOpt['ytUName']!='' && $ntOpt['ytPass']!=''; $ytMsgFormat = htmlentities($ntOpt['ytMsgFormat'], ENT_COMPAT, "UTF-8");
 
 
 
 
132
  ?>
133
  <tr><th style="text-align:left;" colspan="2"><?php if ( $ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='' ) { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_YT<?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?>
134
  <?php if ($isAvailYT) { ?><input class="nxsGrpDoChb" value="1" id="doYT<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="yt[<?php echo $ii; ?>][doYT]" <?php if ((int)$doYT == 1) echo 'checked="checked" title="def"'; ?> />
136
 
137
  <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/yt16.png);">YouTube - <?php _e('publish to', 'nxs_snap') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td><?php //## Only show RePost button if the post is "published"
138
  if ($post->post_status == "publish" && $isAvailYT) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToYT_repostButton" id="rePostToYT_button" value="<?php _e('Repost to YouTube', 'nxs_snap') ?>" />
139
+ <?php } ?>
140
 
141
  <?php if (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {
142
 
147
  </td></tr>
148
 
149
  <?php if (!$isAvailYT) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your YouTube Account to AutoPost to YouTube</b>
150
+ <?php } else { if ($post->post_status != "publish" && function_exists('nxs_doSMAS5') ) { nxs_doSMAS5($nt, $ii, $ntOpt); } ?>
151
+
152
+ <?php if ($ntOpt['rpstOn']=='1') { ?>
153
+
154
+ <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top:6px; text-align:right; width:60px; padding-right:10px;">
155
+ <input value="0" type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]"/><input value="nxsi<?php echo $ii; ?>yt" 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.', 'nxs_snap') ?>
158
+ </td></tr> <?php } ?>
159
 
160
 
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('Message Format:', 'nxs_snap') ?></th>
174
  }
175
  //#### Save Meta Tags to the Post
176
  function adjMetaOpt($optMt, $pMeta){ if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = '';
177
+ if (isset($pMeta['SNAPformat'])) $optMt['ytMsgFormat'] = $pMeta['SNAPformat'];
178
+ if (isset($pMeta['imgToUse'])) $optMt['imgToUse'] = $pMeta['imgToUse'];
179
+ if (isset($pMeta['timeToRun'])) $optMt['timeToRun'] = $pMeta['timeToRun']; if (isset($pMeta['rpstPostIncl'])) $optMt['rpstPostIncl'] = $pMeta['rpstPostIncl'];
180
  if (isset($pMeta['postType'])) $optMt['postType'] = $pMeta['postType'];
181
  if (isset($pMeta['doYT'])) $optMt['doYT'] = $pMeta['doYT'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doYT'] = 0; }
182
  if (isset($pMeta['SNAPincludeYT']) && $pMeta['SNAPincludeYT'] == '1' ) $optMt['doYT'] = 1;
184
  }
185
  }}
186
  if (!function_exists("nxs_rePostToYT_ajax")) {
187
+ function nxs_rePostToYT_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['yt'] as $ii=>$two) if ($ii==$_POST['nid']) { $two['ii'] = $ii; $two['pType'] = 'aj'; //if ($two['ytPageID'].$two['ytUName']==$_POST['nid']) {
189
  $ytpo = get_post_meta($postID, 'snapYT', true); $ytpo = maybe_unserialize($ytpo);// prr($ytpo);
190
  if (is_array($ytpo) && isset($ytpo[$ii]) && is_array($ytpo[$ii])){ $ntClInst = new nxs_snapClassYT(); $two = $ntClInst->adjMetaOpt($two, $ytpo[$ii]); }
194
  }
195
 
196
  if (!function_exists("nxs_doPublishToYT")) { //## Second Function to Post to G+
197
+ function nxs_doPublishToYT($postID, $options){ $ntCd = 'YT'; $ntCdL = 'yt'; $ntNm = 'YouTube'; global $nxs_gCookiesArr; $vUrl = '';
198
+ if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true));
199
  // $backtrace = debug_backtrace();