nxs_snapClassBG

The NextScripts: Social Networks Auto-Poster nxs snapClassBG class.

Defined (1)

The class is defined in the following location(s).

/inc-cl/bg.php  
  1. if (!class_exists("nxs_snapClassBG")) { class nxs_snapClassBG { var $ntInfo = array('code'=>'BG', 'lcode'=>'bg', 'name'=>'Blogger', 'defNName'=>'ulName', 'tstReq' => true); 
  2. //#### Show Common Settings  
  3. function showGenNTSettings($ntOpts) { global $nxs_snapSetPgURL, $nxs_plurl, $nxs_gOptions; $ntInfo = $this->ntInfo;  
  4. // V2 Auth 
  5. if ( isset($_GET['code']) && $_GET['code']!='' && isset($_GET['state']) && substr($_GET['state'], 0, 7) == 'nxs-bg-') { $at = $_GET['code']; $ii = str_replace('nxs-bg-', '', $_GET['state']); 
  6. echo "----=={ oAuth 2.0 Wordflow }==----<br/>-= This is normal technical authorization info that will dissapear (Unless you get some errors) =- <br/><br/><br/>";  
  7. $gGet = $_GET; unset($gGet['code']); unset($gGet['state']); unset($gGet['post_type']); unset($gGet['post']);  
  8. $sturl = explode('?', $nxs_snapSetPgURL); $nxs_snapSetPgURL = $sturl[0].((!empty($gGet))?'?'.http_build_query($gGet):'');  
  9.  
  10. $nto = $ntOpts[$ii]; $wprg = array(); $wprg['sslverify'] = false; 
  11. if (isset($nto['APIKey'])) { echo "-="; prr($nto);// die(); 
  12. $tknURL = 'https://www.googleapis.com/oauth2/v3/token?code='.$at.'&redirect_uri='.urlencode($nxs_snapSetPgURL).'&scope=&client_id='.$nto['APIKey'].'&client_secret='.$nto['APISec'].'&grant_type=authorization_code'; 
  13. $response = wp_remote_post($tknURL, $wprg); prr($tknURL);  
  14. if((is_object($response)&&(isset($response->errors)))) { prr($response); die(); } 
  15. if (is_array($response)&& stripos($response['body'], '"error":')!==false) { prr($response['body']); prr(json_decode($response['body'], true)); die(); } 
  16. $resp = json_decode($response['body'], true); prr($resp); if (!is_array($resp) || empty($resp['access_token'])) { prr($resp); die(); } 
  17. if (function_exists('get_option')) $currTime = time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); else $currTime = time(); 
  18. $nto['AccessToken'] = $resp['access_token']; $nto['AccessTokenSecret'] = 'No Need for oAuth V2'; $nto['OAuthVerifier'] = 'No Need for oAuth V2'; 
  19. $nto['AccessTokenExp'] = $currTime + $resp['expires_in']; $nto['RefreshToken'] = $resp['refresh_token']; echo "<br/>----=={ Expires: ".date('Y-m-d H:i:s', $nto['AccessTokenExp'])." }==---- <br/>"; 
  20.  
  21. if (!empty($nto['bgBlogID'])) { 
  22. if (substr($nto['bgBlogID'], 0, 4)=='http') $tknURL = 'https://www.googleapis.com/blogger/v3/blogs/byurl/?url='.$nto['bgBlogID'].'?access_token='.$nto['AccessToken'];  
  23. else $tknURL = 'https://www.googleapis.com/blogger/v3/blogs/'.$nto['bgBlogID'].'?access_token='.$nto['AccessToken'];  
  24.  
  25. $response = wp_remote_get($tknURL, $wprg); prr($tknURL); prr($response); $user = json_decode($response['body'], true); prr($user); 
  26.  
  27. if (!empty($user['url'])) { $nto['blogURL'] = $user['url']; $nto['bgBlogID'] = $user['id']; $nto['blogInfo'] = $user['name']." [".$user['id']."] (".$user['url'].")";  
  28. if (function_exists('get_option')) $nxs_gOptions = get_option('NS_SNAutoPoster'); if(!empty($nxs_gOptions)) { $nxs_gOptions['bg'][$ii] = $nto; prr($nto); nxs_settings_save($nxs_gOptions); } 
  29. ?><script type="text/javascript">window.location = "<?php echo $nxs_snapSetPgURL; ?>"</script>  
  30. <?php }  
  31. die(); 
  32. ?>  
  33. <div class="nxs_box"> 
  34. <div class="nxs_box_header">  
  35. <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']; ?> 
  36. <?php $cbo = count($ntOpts); ?>  
  37. <?php if ($cbo>1) { ?><div class="nsBigText"><?php echo "(".($cbo=='0'?'No':$cbo)." "; _e('accounts', 'social-networks-auto-poster-facebook-twitter-g'); echo ")"; ?></div><?php } ?> 
  38. </div> 
  39. </div> 
  40. <div class="nxs_box_inside"> 
  41. <?php foreach ($ntOpts as $indx=>$pbo) { if (trim($pbo['nName']=='')) $pbo['nName'] = !empty($pbo[$ntInfo['defNName']])?$pbo[$ntInfo['defNName']]:'Blogger';  
  42. if (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='') $pbo[$ntInfo['lcode'].'OK'] = (isset($pbo['AccessToken']) && $pbo['AccessTokenSecret']!='')?'1':''; 
  43. ?> 
  44. <p style="margin:0px;margin-left:5px;"> <img id="<?php echo $ntInfo['code'].$indx;?>LoadingImg" style="display: none;" src='<?php echo $nxs_plurl; ?>img/ajax-loader-sm.gif' /> 
  45. <input value="0" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" type="hidden" />  
  46. <?php if ((int)$pbo['do'.$ntInfo['code']] == 1 && isset($pbo['catSel']) && (int)$pbo['catSel'] == 1) { ?> <input type="radio" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" id="rbtn<?php echo $ntInfo['lcode'].$indx; ?>" value="1" checked="checked" onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);" /> <?php } else { ?>  
  47. <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1 && $pbo['catSel']!='1') echo "checked"; ?> /> 
  48. <?php } ?> 
  49. <?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 } ?> 
  50. <?php if (isset($pbo['rpstOn']) && (int)$pbo['rpstOn'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popReActive');" onmouseover="nxs_showPopUpInfo('popReActive', event);"><?php echo "*[R]*" ?></span><?php } ?> 
  51. <strong><?php _e('Auto-publish to', 'social-networks-auto-poster-facebook-twitter-g'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong> 
  52.   <?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')) { ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'social-networks-auto-poster-facebook-twitter-g'); ?> ==></b><?php } ?> <?php if (!class_exists('nxsAPI_GP') && !empty($pbo['bgUName']) && empty($pbo['APIKey'])) { ?><b style="color: #800000"><?php _e('Attention requred. "ClientLogin" authentication method is no longer supported by Blogger', 'social-networks-auto-poster-facebook-twitter-g'); ?> ==></b><?php } ?> <a id="do<?php echo $ntInfo['code'].$indx; ?>AG" href="#" onclick="doGetHideNTBlock('<?php echo $ntInfo['code'];?>' , '<?php echo $indx; ?>');return false;">[<?php _e('Show Settings', 'social-networks-auto-poster-facebook-twitter-g'); ?>]</a>   
  53. <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo addslashes($pbo['nName']); ?>');return false;">[<?php _e('Remove Account', 'social-networks-auto-poster-facebook-twitter-g'); ?>]</a> 
  54. </p><div id="nxsNTSetDiv<?php echo $ntInfo['code'].$indx; ?>"></div><?php //$pbo['ntInfo'] = $ntInfo; $this->showNTSettings($indx, $pbo);  
  55. }?> 
  56. </div> 
  57. </div> <?php  
  58. }  
  59. //#### Show NEW Settings Page 
  60. function showNewNTSettings($bo) { $po = array('nName'=>'', 'ulName'=>'', 'bgPass'=>'', 'grpID'=>'', 'uPage'=>'', 'doBG'=>'1', 'APIKey'=>'', 'bgBlogID'=>'', 'APISec'=>'', 'userInfo'=>'', 'OAuthToken'=>'', 'msgFormat'=>'New post has been published on %SITENAME%', 'msgFormatT'=>'New post - %TITLE%' ); $po['ntInfo']= array('lcode'=>'bg'); $this->showNTSettings($bo, $po, true);} 
  61. //#### Show Unit Settings 
  62. function showNTSettings($ii, $options, $isNew=false) { global $nxs_plurl, $nxs_snapSetPgURL; $nt = $options['ntInfo']['lcode']; $ntU = strtoupper($nt); if (!isset($options['bgOK'])) $options['bgOK'] = '';  
  63.  
  64. 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'] = '';  
  65. if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; if (!isset($options['msgAFrmt'])) $options['msgAFrmt'] = '';  
  66. if (empty($options['apiToUse'])) { if (!empty($options['APIKey'])) $options['apiToUse'] = 'bg'; if (!empty($options['bgUName']) && !empty($options['bgPass'])) $options['apiToUse'] = 'nx'; } ?> 
  67. <div id="doBG<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>"> <input type="hidden" name="apDoSBG<?php echo $ii; ?>" value="0" id="apDoSBG<?php echo $ii; ?>" />  
  68. <?php if ($isNew) { ?> <input type="hidden" name="bg[<?php echo $ii; ?>][apDoBG]" value="1" id="apDoNewBG<?php echo $ii; ?>" /> <?php } ?> 
  69. <div id="doBG<?php echo $ii; ?>Div" style="margin-left: 10px;">  
  70.  
  71. <div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/bg16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-blogger-social-networks-auto-poster-wordpress/"><?php $nType="Blogger"; printf( __( 'Detailed %s Installation/Configuration Instructions' , 'social-networks-auto-poster-facebook-twitter-g'), $nType); ?></a></div> 
  72.  
  73. <div style="width:100%;"><strong><?php _e('Account Nickname', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'social-networks-auto-poster-facebook-twitter-g'); ?></i> </div><input name="bg[<?php echo $ii; ?>][nName]" id="bgnName<?php echo $ii; ?>" style="font-weight: bold; color: #005800; border: 1px solid #ACACAC; width: 40%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['nName'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /><br/> 
  74. <?php echo nxs_addQTranslSel('bg', $ii, $options['qTLng']); ?> 
  75.  
  76. <br/> 
  77. <ul class="nsx_tabs"> 
  78. <li><a href="#nsx<?php echo $nt.$ii ?>_tab1"><?php _e('Account Info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li>  
  79. <?php if (!$isNew) { ?> <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li> <?php } ?> 
  80. </ul> 
  81. <div class="nsx_tab_container"><?php /** ######################## Account Tab ####################### */ ?> 
  82. <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%;"> 
  83.  
  84. <?php if (!class_exists('nxsAPI_GP') && !empty($options['bgUName']) && empty($options['APIKey'])) { ?> <span style="color: red;">Blogger has <a style="color: red;" target="_blank" href="https://developers.google.com/identity/protocols/AuthForInstalledApps">discontinued support for "ClientLogin" authentication method</a>. This account should be removed and re-added with oAuth authentication method or upgraded to NextScripts API</span><br/></hr> 
  85.  
  86. <?php } ?> 
  87.  
  88. <div style="width:100%;"><strong>Blogger Blog ID:</strong>  
  89. <p style="font-size: 11px; margin: 0px;"><?php _e('Log to your Blogger management panel and look at the URL of your blog: http://www.blogger.com/blogger.g?blogID=8959085979163812093#allposts. Your Blog ID will be: 8959085979163812093', 'social-networks-auto-poster-facebook-twitter-g'); ?></p> 
  90. </div><input name="bg[<?php echo $ii; ?>][bgBlogID]" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['bgBlogID'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /> <br/><br/> 
  91.  
  92. <div style="display: <?php echo (empty($options['apiToUse']))?"block":"none"; ?>;">  
  93. <div style="width:100%; text-align: center; color:#005800; font-weight: bold; font-size: 14px;">You can choose what API you would like to use. </div>  
  94. <span style="color:#005800; font-weight: bold; font-size: 14px;">Blogger Native API:</span> Free built-in API from Blogger. More secure, more stable. More complicated - <b style="color: red;">requires approval of access to API by Google (3-5 days)</b> and authorization. <br/><br/>  
  95. <span style="color:#005800; font-weight: bold; font-size: 14px;">NextScripts API for Blogger:</span> Premium API with extended functionality. Easier to configure, but less secure - requires your password.<br/><br/> 
  96.  
  97. <select name="bg[<?php echo $ii; ?>][apiToUse]" onchange="if (jQuery(this).val()=='bg') { jQuery('.nxs_bg_nxapi_<?php echo $ii; ?>').hide(); jQuery('.nxs_bg_bgapi_<?php echo $ii; ?>').show(); }else { jQuery('.nxs_bg_bgapi_<?php echo $ii; ?>').hide(); jQuery('.nxs_bg_nxapi_<?php echo $ii; ?>').show(); }"><option <?php echo (empty($options['apiToUse']) || $options['apiToUse'] =='bg')?"selected":""; ?> value="bg">Blogger API</option><option <?php echo (!empty($options['apiToUse']) && $options['apiToUse'] =='nx')?"selected":""; ?> value="nx">NextScripts API</option></select><hr/> 
  98.  
  99. </div> 
  100.  
  101. <div id="nxsAPIBG<?php echo $ii; ?>" class="nxs_bg_bgapi_<?php echo $ii; ?>" style="display: <?php echo (empty($options['apiToUse']) || $options['apiToUse'] =='bg')?"block":"none"; ?>;"><h3>Blogger API</h3> 
  102.  
  103. <div class="subDiv" id="sub<?php echo $ii; ?>DivL" style="display: block;"> 
  104.  
  105. <div style="width:100%;"><strong>Client ID:</strong> </div><input name="bg[<?php echo $ii; ?>][APIKey]" style="width: 70%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['APIKey'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />  
  106. <div style="width:100%;"><strong>Client Secret:</strong> </div><input name="bg[<?php echo $ii; ?>][APISec]" id="APISec" style="width: 70%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['APISec'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /> 
  107. <br/><br/> 
  108. <?php  
  109. if($options['APIKey']=='') { ?> 
  110. <b>Authorize Your Blogger Account</b>. Please save your settings and come back here to Authorize your account. 
  111. <?php } else { if(isset($options['AccessToken']) && isset($options['AccessTokenSecret']) && $options['AccessTokenSecret']!=='') { ?> 
  112. Your Blogger Account has been authorized. <br/>Blog ID: <?php _e(apply_filters('format_to_edit', $options['blogInfo']), 'social-networks-auto-poster-facebook-twitter-g') ?>.  
  113. <br/>You can Re- <?php } ?>  
  114.  
  115. <a href="https://accounts.google.com/o/oauth2/auth?redirect_uri=<?php echo trim(urlencode($nxs_snapSetPgURL));?>&response_type=code&client_id=<?php echo trim($options['APIKey']);?>&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fblogger&approval_prompt=force&access_type=offline&state=<?php echo 'nxs-bg-'.$ii; ?>">Authorize Your Blogger Account</a>  
  116.  
  117.  
  118. <?php if (empty($options['AccessTokenSecret'])) { ?> <div class="blnkg"><=== Authorize your account ===</div> <?php } ?> 
  119.  
  120. <?php } ?> 
  121. </div> 
  122. </div> 
  123. <div id="nxsAPINX<?php echo $ii; ?>" class="nxs_bg_nxapi_<?php echo $ii; ?>" style="display: <?php echo (!empty($options['apiToUse']) && $options['apiToUse'] =='nx')?"block":"none"; ?>;"><h3>NextScripts API</h3> 
  124.  
  125. <?php if (class_exists('nxsAPI_GP')) { ?> 
  126.  
  127. <div class="subDiv" id="sub<?php echo $ii; ?>DivN" style="display: block;">  
  128. <div style="width:100%;"><strong>Your Blogger Username/Email:</strong> </div><input name="bg[<?php echo $ii; ?>][bgUName]" style="width: 70%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['bgUName'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />  
  129. <div style="width:100%;"><strong>Your Blogger Password:</strong> </div><input autocomplete="false" readonly onfocus="this.removeAttribute('readonly');" type="password" name="bg[<?php echo $ii; ?>][bgPass]" style="width: 75%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['bgPass'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /> 
  130.  
  131. </div>  
  132. <?php } else { nxs_show_noLibWrn('"NextScripts API Library for Blogger" is NOT installed'); } ?>  
  133. </div> 
  134. <br/><hr/>  
  135. <div style="width:100%;"><strong id="altFormatText"><?php _e('Post Title Format', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> (<a href="#" id="apBGTMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apBGTMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>)</div>  
  136.  
  137. <input name="bg[<?php echo $ii; ?>][apBGMsgTFrmt]" id="apBGMsgTFrmt" style="width: 50%;" value="<?php if ($options['bgMsgTFormat']!='') _e(apply_filters('format_to_edit', htmlentities($options['bgMsgTFormat'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g'); else echo "%TITLE%"; ?>" onfocus="mxs_showFrmtInfo('apBGTMsgFrmt<?php echo $ii; ?>');" /><?php nxs_doShowHint("apBGTMsgFrmt".$ii); ?><br/> 
  138.  
  139. <div id="altFormat" style=""> 
  140. <div style="width:100%;"><strong id="altFormatText"><?php _e('Post Text Format', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> (<a href="#" id="apBGMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apBGMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>)  
  141.  
  142. <!--  
  143. HTML is <?php if(!function_exists('doPostToGooglePlus')) {?> <b>NOT</b> <?php } ?> allowed. <?php if(!function_exists('doPostToGooglePlus')) {?> <i>- Blogger "Free API" limitation. Please get <a href="http://www.nextscripts.com/google-plus-automated-posting/#blogger">NextScripts API</a> to allow HTML</i> <?php } ?> --> 
  144. </div>  
  145.  
  146. <textarea cols="150" rows="3" id="bg<?php echo $ii; ?>SNAPformat" name="bg[<?php echo $ii; ?>][apBGMsgFrmt]" style="width:51%;max-width: 650px;" onfocus="jQuery('#bg<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('apBGMsgFrmt<?php echo $ii; ?>');"><?php if ($options['bgMsgFormat']!='') _e(apply_filters('format_to_edit', htmlentities($options['bgMsgFormat'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g'); else echo "%FULLTEXT% <br/><a href='%URL%'>%TITLE%</a>"; ?></textarea> 
  147.  
  148. <?php nxs_doShowHint("apBGMsgFrmt".$ii, __('HTML is allowed', 'social-networks-auto-poster-facebook-twitter-g')); ?> 
  149. </div> 
  150.  
  151. <p style="margin-bottom: 20px;margin-top: 5px;"><input value="1" id="bgInclTags" type="checkbox" name="bg[<?php echo $ii; ?>][bgInclTags]" <?php if ((int)$options['bgInclTags'] == 1) echo "checked"; ?> />  
  152. <strong><?php _e('Post with tags', 'social-networks-auto-poster-facebook-twitter-g'); ?></strong> <?php _e('Tags from the blogpost will be auto-posted to Blogger/Blogspot', 'social-networks-auto-poster-facebook-twitter-g'); ?>  
  153. </p>  
  154.  
  155. <?php if (!empty($options['bgPass']) || !empty($options['AccessToken'])) { ?> 
  156.  
  157. <b><?php _e('Test your settings', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</b>    <?php if (!isset($options['bgOK']) || $options['bgOK']!='1') { ?> <div class="blnkg">=== <?php _e('Submit Test Post to Finish Configuration', 'social-networks-auto-poster-facebook-twitter-g'); ?> ===></div> <?php } ?> <a href="#" class="NXSButton" onclick="testPost('BG', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?></a>  
  158. <?php } ?> 
  159.  
  160. </div> 
  161.  
  162. <?php /** ######################## Advanced Tab ####################### */ ?> 
  163. <?php if (!$isNew) { ?> <div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content"> 
  164.  
  165. <?php nxs_showCatTagsCTFilters($nt, $ii, $options);  
  166. nxs_addPostingDelaySelV3($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']);  
  167. nxs_showRepostSettings($nt, $ii, $options); ?> 
  168.  
  169.  
  170. </div> <?php } ?> <?php /** #### End of Tab #### */ ?> 
  171. </div><br/> <?php /** #### End of Tabs #### */ ?> 
  172.  
  173. <div class="submitX nxclear" style="padding-bottom: 0px;"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'social-networks-auto-poster-facebook-twitter-g') ?>" /></div> 
  174.  
  175. </div> 
  176. </div> 
  177. <?php 
  178.  
  179.  
  180. //#### Set Unit Settings from POST 
  181. function setNTSettings($post, $options) { $code = $this->ntInfo['code']; 
  182. foreach ($post as $ii => $pval) {// prr($pval); 
  183. if ( (!empty($pval['APISec']) && !empty($pval['APIKey'])) || (!empty($pval['bgUName']) && !empty($pval['bgPass'])) ) { if (!isset($options[$ii])) $options[$ii] = array(); 
  184.  
  185. if (isset($pval['apDoBG'])) $options[$ii]['doBG'] = $pval['apDoBG']; else $options[$ii]['doBG'] = 0; 
  186.  
  187. if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']); else $options[$ii]['catSel'] = 0; 
  188. if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = ''; 
  189.  
  190. if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']); 
  191. if (isset($pval['bgUName'])) $options[$ii]['bgUName'] = trim($pval['bgUName']); 
  192. if (isset($pval['bgPass'])) $options[$ii]['bgPass'] = 'b4d7s'.nsx_doEncode($pval['bgPass']); else $options[$ii]['bgPass'] = ''; 
  193.  
  194. if (isset($pval['APIKey'])) $options[$ii]['APIKey'] = trim($pval['APIKey']); 
  195. if (isset($pval['APISec'])) $options[$ii]['APISec'] = trim($pval['APISec']); 
  196.  
  197. if (isset($pval['bgBlogID'])) $options[$ii]['bgBlogID'] = trim($pval['bgBlogID']);  
  198. if (isset($pval['apBGMsgFrmt'])) $options[$ii]['bgMsgFormat'] = trim($pval['apBGMsgFrmt']);  
  199. if (isset($pval['apBGMsgTFrmt'])) $options[$ii]['bgMsgTFormat'] = trim($pval['apBGMsgTFrmt']);  
  200. if (isset($pval['bgInclTags'])) $options[$ii]['bgInclTags'] = $pval['bgInclTags']; else $options[$ii]['bgInclTags'] = 0;  
  201.  
  202. $options[$ii] = nxs_adjRpst($options[$ii], $pval);  
  203.  
  204. if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']); 
  205. if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);  
  206. if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);  
  207.  
  208. } elseif ( count($pval)==1 ) if (isset($pval['apDo'.$code])) $options[$ii]['do'.$code] = $pval['apDo'.$code]; else $options[$ii]['do'.$code] = 0;  
  209. } return $options; 
  210. }  
  211. //#### Show Post->Edit Meta Box Settings 
  212. function showEdPostNTSettings($ntOpts, $post) { global $nxs_plurl; $post_id = $post->ID; $nt = 'bg'; $ntU = 'BG'; 
  213. foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapBG', true)); if (is_array($pMeta)) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);  
  214. if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = ''; 
  215. $doBG = $ntOpt['doBG'] && (is_array($pMeta) || $ntOpt['catSel']!='1'); $imgToUse = $ntOpt['imgToUse']; $isAvailBG = (!empty($ntOpt['bgUName']) && !empty($ntOpt['bgPass'])) || !empty($ntOpt['AccessToken']);  
  216. $bgMsgFormat = htmlentities($ntOpt['bgMsgFormat'], ENT_COMPAT, "UTF-8"); $bgMsgTFormat = htmlentities($ntOpt['bgMsgTFormat'], ENT_COMPAT, "UTF-8"); 
  217. ?>  
  218.  
  219. <tr><th style="text-align:left;" colspan="2"> 
  220. <?php if ($ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='') { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?> 
  221. <?php if (!empty($ntOpt['tagsSel'])) { ?> <input type="hidden" class="nxs_TG" id="nxs_TG_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $ntOpt['tagsSel']; ?>" /> <?php } ?> 
  222. <?php if ($isAvailBG) { ?><input class="nxsGrpDoChb" value="1" id="doBG<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="bg[<?php echo $ii; ?>][doBG]" <?php if ((int)$doBG == 1) echo 'checked="checked" title="def"'; ?> /> <?php if ($post->post_status == "publish") { ?> <input type="hidden" name="bg[<?php echo $ii; ?>][doBG]" value="<?php echo $doBG;?>"> <?php } ?> <?php } ?> 
  223. <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/bg16.png);">Blogger - <?php _e('publish to', 'social-networks-auto-poster-facebook-twitter-g') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th> <td style="min-width: 180px; width: 350px;" ><?php //## Only show RePost button if the post is "published" 
  224. if ($post->post_status == "publish" && $isAvailBG) { ?> 
  225. <input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToBG_repostButton" id="rePostToBG_button" value="<?php _e('Repost to Blogger', 'social-networks-auto-poster-facebook-twitter-g') ?>" />  
  226. <?php } ?> 
  227.  
  228. <?php if (is_array($pMeta) && !empty($pMeta[$ii]) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {  
  229. ?> <span id="pstdBG<?php echo $ii; ?>" style="float: right; padding-top: 4px; padding-right: 10px;"> 
  230. <a style="font-size: 10px;" href="<?php echo $pMeta[$ii]['pgID']; ?>" target="_blank"><?php $nType="Blogger"; printf( __( 'Posted on', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?><?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a> 
  231. </span><?php } ?>  
  232.  
  233. </td></tr> 
  234. <?php if (!$isAvailBG) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b><?php _e('Setup your Blogger Account to AutoPost to Blogger', 'social-networks-auto-poster-facebook-twitter-g') ?></b> 
  235. <?php } else { if ($post->post_status != "publish" && function_exists('nxs_doSMAS5') ) { $ntOpt['postTime'] = get_post_time('U', false, $post_id); nxs_doSMAS5($nt, $ii, $ntOpt); } ?> 
  236.  
  237. <?php if ($ntOpt['rpstOn']=='1') { ?>  
  238.  
  239. <tr id="altFormat1" style=""><th scope="row" class="nxsTHRow"> 
  240. <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"; ?> />  
  241. </th> 
  242. <td> <?php _e('Include in "Auto-Reposting" to this network.', 'social-networks-auto-poster-facebook-twitter-g') ?>  
  243. </td></tr> <?php } ?> 
  244.  
  245. <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> 
  246. <td><input class="nxs_postEditCtrl" value="<?php echo $bgMsgTFormat ?>" type="text" name="bg[<?php echo $ii; ?>][SNAPTformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apBGTMsgFrmt<?php echo $ii; ?>');" onchange="nxs_svPostStAjax(this)"/><?php nxs_doShowHint("apBGTMsgFrmt".$ii, '', '58'); ?></td></tr> 
  247. <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> 
  248. <td> 
  249. <textarea class="nxs_postEditCtrl" cols="150" rows="1" id="bg<?php echo $ii; ?>SNAPformat" name="bg[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('#bg<?php echo $ii; ?>SNAPformat').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apBGMsgFrmt<?php echo $ii; ?>');"><?php echo $bgMsgFormat; ?></textarea>  
  250. <?php nxs_doShowHint("apBGMsgFrmt".$ii, '', '58'); ?></td></tr>  
  251. <?php } 
  252. }  
  253.  
  254. function adjMetaOpt($optMt, $pMeta) { if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = ''; 
  255. if (isset($pMeta['SNAPformat'])) $optMt['bgMsgFormat'] = $pMeta['SNAPformat']; if (isset($pMeta['imgToUse'])) $optMt['imgToUse'] = $pMeta['imgToUse'];  
  256. if (isset($pMeta['timeToRun'])) $optMt['timeToRun'] = $pMeta['timeToRun']; if (isset($pMeta['rpstPostIncl'])) $optMt['rpstPostIncl'] = $pMeta['rpstPostIncl'];  
  257. if (isset($pMeta['SNAPTformat'])) $optMt['bgMsgTFormat'] = $pMeta['SNAPTformat'];  
  258. if (isset($pMeta['doBG'])) $optMt['doBG'] = $pMeta['doBG'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doBG'] = 0; }  
  259. if (isset($pMeta['SNAPincludeBG']) && $pMeta['SNAPincludeBG'] == '1' ) $optMt['doBG'] = 1;  
  260. return $optMt; 
  261. }}