/nxs_functions.php

  1. <?php 
  2. if (!function_exists('prr')) { function prr($str) { echo "<pre>"; print_r($str); echo "</pre>\r\n"; }}  
  3. if (!function_exists('nsx_stripSlashes')) { function nsx_stripSlashes(&$value) {$value = stripslashes($value);}} 
  4. if (!function_exists('nsx_fixSlashes')) { function nsx_fixSlashes(&$value) { while (strpos($value, '\\\\')!==false) $value = str_replace('\\\\', '\\', $value); 
  5. if (strpos($value, "\\'")!==false) $value = str_replace("\\'", "'", $value); if (strpos($value, '\\"')!==false) $value = str_replace('\\"', '"', $value); 
  6. }} 
  7. if (!function_exists('CutFromTo')) { function CutFromTo($string, $from, $to) {$fstart = stripos($string, $from); $tmp = substr($string, $fstart+strlen($from)); $flen = stripos($tmp, $to); return substr($tmp, 0, $flen);}} 
  8. if (!function_exists('nsx_doEncode')) { function nsx_doEncode($string, $key='NSX') { $key = sha1($key); $strLen = strlen($string);$keyLen = strlen($key); $j = 0; $hash = ''; 
  9. for ($i = 0; $i < $strLen; $i++) { $ordStr = ord(substr($string, $i, 1)); if ($j == $keyLen) $j = 0; $ordKey = ord(substr($key, $j, 1)); $j++; $hash .= strrev(base_convert(dechex($ordStr + $ordKey), 16, 36));} return $hash; 
  10. }} 
  11. if (!function_exists('nsx_doDecode')) { function nsx_doDecode($string, $key='NSX') { $key = sha1($key); $keyLen = strlen($key); $hash = ''; $sX = str_split($string, 2560); 
  12. foreach($sX as $ss) {$j=0; $sA=str_split($ss, 2); foreach($sA as $oS) {$oS=hexdec(base_convert(strrev($oS), 36, 16)); if ($j==$keyLen) $j=0; $oK=ord(substr($key, $j, 1)); $j++; $hash.=chr($oS-$oK);}} return $hash; 
  13. }} 
  14. if (!function_exists('nxs_decodeEntitiesFull')) { function nxs_decodeEntitiesFull($string, $quotes = ENT_COMPAT, $charset = 'utf-8') { 
  15. return html_entity_decode(preg_replace_callback('/&([a-zA-Z][a-zA-Z0-9]+);/', 'nxs_convertEntity', $string), $quotes, $charset);  
  16. }} 
  17. if (!function_exists('nxs_substr')) { function nxs_substr($str, $start) { preg_match_all("/./su", $str, $ar); 
  18. if(func_num_args() >= 3) { $end = func_get_arg(2); return join("", array_slice($ar[0], $start, $end)); } else return join("", array_slice($ar[0], $start)); 
  19. }} 
  20. if (!function_exists('nxs_strLen')) { function nxs_strLen($str) { return count(str_split(utf8_decode($str))); }} 
  21. if (!function_exists('nxs_convertEntity')) { function nxs_convertEntity($matches, $destroy = true) { 
  22. static $table = array('quot' => '"', 'amp' => '&', 'lt' => '<', 'gt' => '>', 'apos' => ''', 'OElig' => 'Œ', 'oelig' => 'œ', 'Scaron' => 'Š', 'scaron' => 'š', 'Yuml' => 'Ÿ', 'circ' => 'ˆ', 'tilde' => '˜', 'ensp' => ' ', 'emsp' => ' ', 'thinsp' => ' ', 'zwnj' => '‌', 'zwj' => '‍', 'lrm' => '‎', 'rlm' => '‏', 'ndash' => '–', 'mdash' => '—', 'lsquo' => '‘', 'rsquo' => '’', 'sbquo' => '‚', 'ldquo' => '“', 'rdquo' => '”', 'bdquo' => '„', 'dagger' => '†', 'Dagger' => '‡', 'permil' => '‰', 'lsaquo' => '‹', 'rsaquo' => '›', 'euro' => '€', 'fnof' => 'ƒ', 'Alpha' => 'Α', 'Beta' => 'Β', 'Gamma' => 'Γ', 'Delta' => 'Δ', 'Epsilon' => 'Ε', 'Zeta' => 'Ζ', 'Eta' => 'Η', 'Theta' => 'Θ', 'Iota' => 'Ι', 'Kappa' => 'Κ', 'Lambda' => 'Λ', 'Mu' => 'Μ', 'Nu' => 'Ν', 'Xi' => 'Ξ', 'Omicron' => 'Ο', 'Pi' => 'Π', 'Rho' => 'Ρ', 'Sigma' => 'Σ', 'Tau' => 'Τ', 'Upsilon' => 'Υ', 'Phi' => 'Φ', 'Chi' => 'Χ', 'Psi' => 'Ψ', 'Omega' => 'Ω', 'alpha' => 'α', 'beta' => 'β', 'gamma' => 'γ', 'delta' => 'δ', 'epsilon' => 'ε', 'zeta' => 'ζ', 'eta' => 'η', 'theta' => 'θ', 'iota' => 'ι', 'kappa' => 'κ', 'lambda' => 'λ', 'mu' => 'μ', 'nu' => 'ν', 'xi' => 'ξ', 'omicron' => 'ο', 'pi' => 'π', 'rho' => 'ρ', 'sigmaf' => 'ς', 'sigma' => 'σ', 'tau' => 'τ', 'upsilon' => 'υ', 'phi' => 'φ', 'chi' => 'χ', 'psi' => 'ψ', 'omega' => 'ω', 'thetasym' => 'ϑ', 'upsih' => 'ϒ', 'piv' => 'ϖ', 'bull' => '•', 'hellip' => '…', 'prime' => '′', 'Prime' => '″', 'oline' => '‾', 'frasl' => '⁄', 'weierp' => '℘', 'image' => 'ℑ', 'real' => 'ℜ', 'trade' => '™', 'alefsym' => 'ℵ', 'larr' => '←', 'uarr' => '↑', 'rarr' => '→', 'darr' => '↓', 'harr' => '↔', 'crarr' => '↵', 'lArr' => '⇐', 'uArr' => '⇑', 'rArr' => '⇒', 'dArr' => '⇓', 'hArr' => '⇔', 'forall' => '∀', 'part' => '∂', 'exist' => '∃', 'empty' => '∅', 'nabla' => '∇', 'isin' => '∈', 'notin' => '∉', 'ni' => '∋', 'prod' => '∏', 'sum' => '∑', 'minus' => '−', 'lowast' => '∗', 'radic' => '√', 'prop' => '∝', 'infin' => '∞', 'ang' => '∠', 'and' => '∧', 'or' => '∨', 'cap' => '∩', 'cup' => '∪', 'int' => '∫', 'there4' => '∴', 'sim' => '∼', 'cong' => '≅', 'asymp' => '≈', 'ne' => '≠', 'equiv' => '≡', 'le' => '≤', 'ge' => '≥', 'sub' => '⊂', 'sup' => '⊃', 'nsub' => '⊄', 'sube' => '⊆', 'supe' => '⊇', 'oplus' => '⊕', 'otimes' => '⊗', 'perp' => '⊥', 'sdot' => '⋅', 'lceil' => '⌈', 'rceil' => '⌉', 'lfloor' => '⌊', 'rfloor' => '⌋', 'lang' => '〈', 'rang' => '〉', 'loz' => '◊', 'spades' => '♠', 'clubs' => '♣', 'hearts' => '♥', 'diams' => '♦', 'nbsp' => ' ', 'iexcl' => '¡', 'cent' => '¢', 'pound' => '£', 'curren' => '¤', 'yen' => '¥', 'brvbar' => '¦', 'sect' => '§', 'uml' => '¨', 'copy' => '©', 'ordf' => 'ª', 'laquo' => '«', 'not' => '¬', 'shy' => '­', 'reg' => '®', 'macr' => '¯', 'deg' => '°', 'plusmn' => '±', 'sup2' => '²', 'sup3' => '³', 'acute' => '´', 'micro' => 'µ', 'para' => '¶', 'middot' => '·', 'cedil' => '¸', 'sup1' => '¹', 'ordm' => 'º', 'raquo' => '»', 'frac14' => '¼', 'frac12' => '½', 'frac34' => '¾', 'iquest' => '¿', 'Agrave' => 'À', 'Aacute' => 'Á', 'Acirc' => 'Â', 'Atilde' => 'Ã', 'Auml' => 'Ä', 'Aring' => 'Å', 'AElig' => 'Æ', 'Ccedil' => 'Ç', 'Egrave' => 'È', 'Eacute' => 'É', 'Ecirc' => 'Ê', 'Euml' => 'Ë', 'Igrave' => 'Ì', 'Iacute' => 'Í', 'Icirc' => 'Î', 'Iuml' => 'Ï', 'ETH' => 'Ð', 'Ntilde' => 'Ñ', 'Ograve' => 'Ò', 'Oacute' => 'Ó', 'Ocirc' => 'Ô', 'Otilde' => 'Õ', 'Ouml' => 'Ö', 'times' => '×', 'Oslash' => 'Ø', 'Ugrave' => 'Ù', 'Uacute' => 'Ú', 'Ucirc' => 'Û', 'Uuml' => 'Ü', 'Yacute' => 'Ý', 'THORN' => 'Þ', 'szlig' => 'ß', 'agrave' => 'à', 'aacute' => 'á', 'acirc' => 'â', 'atilde' => 'ã', 'auml' => 'ä', 'aring' => 'å', 'aelig' => 'æ', 'ccedil' => 'ç', 'egrave' => 'è', 'eacute' => 'é', 'ecirc' => 'ê', 'euml' => 'ë', 'igrave' => 'ì', 'iacute' => 'í', 'icirc' => 'î', 'iuml' => 'ï', 'eth' => 'ð', 'ntilde' => 'ñ', 'ograve' => 'ò', 'oacute' => 'ó', 'ocirc' => 'ô', 'otilde' => 'õ', 'ouml' => 'ö', 'divide' => '÷', 'oslash' => 'ø', 'ugrave' => 'ù', 'uacute' => 'ú', 'ucirc' => 'û', 'uuml' => 'ü', 'yacute' => 'ý', 'thorn' => 'þ', 'yuml' => 'ÿ'); 
  23. if (isset($table[$matches[1]])) return $table[$matches[1]]; 
  24. // else  
  25. return $destroy ? '' : $matches[0]; 
  26. }} 
  27. if (!function_exists('nxs_decodeEntities')) {function nxs_decodeEntities($text) { 
  28. $text= html_entity_decode($text, ENT_QUOTES, "ISO-8859-1"); #NOTE: UTF-8 does not work! 
  29. $text= preg_replace('/&#(\d+);/me', "chr(\\1)", $text); #decimal notation 
  30. $text= preg_replace('/&#x([a-f0-9]+);/mei', "chr(0x\\1)", $text); #hex notation 
  31. return $text; 
  32. }} 
  33. if (!function_exists('nsFindImgsInPost')) {function nsFindImgsInPost($post, $advImgFnd=false) { global $ShownAds; if (isset($ShownAds)) $ShownAdsL = $ShownAds; $postImgs = array(); if (!is_object($post)) return; 
  34. if ($advImgFnd) $postCntEx = apply_filters('the_content', $post->post_excerpt); else $postCntEx = $post->post_excerpt;  
  35. if ($advImgFnd) $postCnt = apply_filters('the_content', $post->post_content); else $postCnt = $post->post_content;  
  36. $postCnt = $postCntEx.$postCnt; 
  37. //$output = preg_match_all( '/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $postCnt, $matches ); if ($output === false) {return false;}  
  38. //$postCnt = str_replace("'", '"', $postCnt); $output = preg_match_all( '/src="([^"]*)"/', $postCnt, $matches ); if ($output === false) {return false;} 
  39. $postCnt = str_replace("'", '"', $postCnt); $output = preg_match_all( '/< *img[^>]*src *= *["\']?([^"\']*)/i', $postCnt, $matches ); // prr($matches);  
  40. if ($output === false || $output == 0) { $vids = nsFindVidsInPost($post, $advImgFnd==false); if (count($vids)>0) $postImgs[] = 'http://img.youtube.com/vi/'.$vids[0].'/0.jpg'; else return false;}  
  41. else { foreach ($matches[1] as $match) { if (!preg_match('/^https?:\/\//', $match ) ) $match = site_url( '/' ) . ltrim( $match, '/' ); $postImgs[] = $match;} if (isset($ShownAds)) $ShownAds = $ShownAdsL; }  
  42. return $postImgs; 
  43. }} 
  44.  
  45.  
  46. if (!function_exists('nsFindAudioInPost')) {function nsFindAudioInPost($post, $raw=true) { //### !!! $raw=false Breaks ob_start() [ref.outcontrol]: Cannot use output buffering in output buffering display handlers - Investigate 
  47. global $ShownAds; if (isset($ShownAds)) $ShownAdsL = $ShownAds; $postVids = array(); 
  48. if (is_object($post)) { if ($raw) $postCnt = $post->post_content; else $postCnt = apply_filters('the_content', $post->post_content); } else $postCnt = $post; 
  49. $regex_pattern = "((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*\.(mp3|aac|m4a))"; 
  50. $output = preg_match_all( $regex_pattern, $postCnt, $matches ); if ($output === false) {return false;}  
  51. foreach ($matches[0] as $match) { $postAu[] = $match; } $postAu = array_unique($postAu); if (isset($ShownAds)) $ShownAds = $ShownAdsL; return $postAu; 
  52. }} 
  53. if (!function_exists('nsGetYTThumb')) {function nsGetYTThumb($yt) {  
  54. $out = 'http://img.youtube.com/vi/'.$yt.'/maxresdefault.jpg'; $response = wp_remote_get($out);  
  55. if (is_wp_error($response) || $response['response']['code']!='200' ) { $out = 'http://img.youtube.com/vi/'.$yt.'/sddefault.jpg';  
  56. $response = wp_remote_get($out); if (is_wp_error($response) || $response['response']['code']!='200' ) $out = 'http://img.youtube.com/vi/'.$yt.'/0.jpg'; 
  57. } return $out;  
  58. }} 
  59. if (!function_exists('nsFindVidsInPost')) {function nsFindVidsInPost($post, $raw=true) { //### !!! $raw=false ## Breaks ob_start() [ref.outcontrol]: Cannot use output buffering in output buffering display handlers - Investigate 
  60. global $ShownAds; if (isset($ShownAds)) $ShownAdsL = $ShownAds; $postVids = array(); 
  61. if (is_object($post)) { if ($raw) $postCnt = $post->post_content; else $postCnt = apply_filters('the_content', $post->post_content); } else $postCnt = $post; //prr($postCnt); 
  62. $postCnt = preg_replace('/youtube.com\/vi\/(.*)\/(.*).jpg/isU', "youtube.com/v/$1/", $postCnt);  
  63. $output = preg_match_all( '@((https?://)?([-\w]+\.[-\w\.]+)+\w(:\d+)?(/([-\w/_\.]*(\?\S+)?)?(#[a-z_.-][a-z0-9+\$_.-]*)?)*)@', $postCnt, $matches ); if ($output === false) {return false;}  
  64. foreach ($matches[0] as $match) {  
  65. $output2 = preg_match_all( '%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"<>&?/ ]{11})%i', $match, $matches2 ); if ($output2 === false) {return false;}  
  66. foreach ($matches2[1] as $match2) { $match2 = trim($match2); if (strlen($match2)==11) $postVids[] = $match2;}  
  67. $output3 = preg_match_all( '/^https?:\/\/(www\.)?vimeo\.com\/(clip\:)?(\d+).*$/', $match, $matches3 ); if ($output3 === false) {return false;}  
  68. foreach ($matches3[3] as $match3) { $match3 = trim($match3); if (strlen($match3)==8 || strlen($match3)==9) $postVids[] = $match3;}  
  69. $output3 = preg_match_all( '#https?://(player\.)?vimeo\.com(/video)?/(\d+)#i', $match, $matches3 ); if ($output3 === false) {return false;}  
  70. foreach ($matches3[3] as $match3) { $match3 = trim($match3); if (strlen($match3)==8 || strlen($match3)==9) $postVids[] = $match3;}  
  71. $output3 = preg_match_all( '#https?://(www\.)?facebook\.com/video\.php\?v=(\d+)#i', $match, $matches3 ); if ($output3 === false) {return false;}  
  72. foreach ($matches3[2] as $match3) { $match3 = trim($match3); if (strlen($match3)==15) $postVids[] = $match3;}  
  73. $output3 = preg_match_all( '#https?://(www\.)?facebook\.com/video/embed(/)?\?video_id=(\d+)#i', $match, $matches3 ); if ($output3 === false) {return false;}  
  74. foreach ($matches3[3] as $match3) { $match3 = trim($match3); if (strlen($match3)==15) $postVids[] = $match3;}  
  75. } $postVids = array_unique($postVids); if (isset($ShownAds)) $ShownAds = $ShownAdsL; return $postVids;  
  76. }} 
  77. if (!function_exists('nsTrnc')) { function nsTrnc($string, $limit, $break=" ", $pad=" ...") { if(nxs_strLen($string) <= $limit) return $string; if(nxs_strLen($pad) >= $limit) return ''; $string = nxs_substr($string, 0, $limit-nxs_strLen($pad));  
  78. $brLoc = strripos($string, $break); if ($brLoc===false) return $string.$pad; else return nxs_substr($string, 0, $brLoc).$pad;  
  79. }} 
  80. if (!function_exists('nsSubStrEl')) { function nsSubStrEl($string, $length, $end='...') { if (strlen($string) > $length) { $length -= strlen($end); $string = substr($string, 0, $length); $string .= $end; } return $string;}} 
  81.  
  82. if (!function_exists('nxs_snapCleanHTML')) { function nxs_snapCleanHTML($html) {  
  83. $html = preg_replace('/<script\b[^>]*>(.*?)<\/script>/is', "", $html); $html = preg_replace('/<!--(.*)-->/Uis', "", $html); return $html; 
  84. }} 
  85. if (!function_exists("nxs_getNXSHeaders")) { function nxs_getNXSHeaders($ref='', $post=false) { $hdrsArr = array();  
  86. $hdrsArr['Connection']='keep-alive'; $hdrsArr['Referer']=$ref; 
  87. $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'; 
  88. if($post) $hdrsArr['Content-Type']='application/x-www-form-urlencoded';  
  89. $hdrsArr['Accept']='application/json, text/javascript, */*; q=0.01';  
  90. if (function_exists('gzdeflate')) $hdrsArr['Accept-Encoding']='gzip, deflate, sdch';  
  91. $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; 
  92. }} 
  93. if (!function_exists('nxs_chckRmImage')) {function nxs_chckRmImage($url, $chType='head') { if( ini_get('allow_url_fopen')=='1' && @getimagesize($url)!==false) return true; 
  94. $hdrsArr = nxs_getNXSHeaders(); $nxsWPRemWhat = 'wp_remote_'.$chType; $rsp = $nxsWPRemWhat($url, array('headers' => $hdrsArr));  
  95. if(is_wp_error($rsp)) { nxs_addToLogN('E', 'Error', 'IMAGE', '-=ERROR=- Server can\'t access it\'s own images. (Image URL: '.$url.') Most probably it\'s a DNS problem. Please contact your hosting provider. '.serialize($rsp), ''); return false; } 
  96. if (is_array($rsp) && ($rsp['response']['code']=='200' || ( $rsp['response']['code']=='403' && $rsp['headers']['server']=='cloudflare-nginx') )) return true;  
  97. else { if ($chType=='head') { return nxs_chckRmImage($url, 'get'); } else { nxs_addToLogN('E', 'Error', 'IMAGE', '-=ERROR=- Server can\'t access it\'s own images. (Image URL: '.$url.') Most probably it\'s a DNS problem. Please contact your hosting provider. '.serialize($rsp), $url); return false; } 
  98. }  
  99. }} 
  100. if (!function_exists('nxs_getPostImage')) { function nxs_getPostImage($postID, $size='large', $def='') { $imgURL = ''; global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options; $options['sImg'] = (defined('NXSAPIVER') && NXSAPIVER == '2.15.11')?1:0;  
  101. if (empty($options['imgNoCheck']) || $options['imgNoCheck'] != '1') { $indx = rand(0, 2);  
  102. $iTstArr = array('https://www.bing.com/s/a/hpc12.png', 'https://www.apple.com/global/elements/flags/16x16/usa_2x.png', 'https://s.yimg.com/rz/l/yahoo_en-US_f_p_142x37.png');  
  103. $imgURL = $iTstArr[$indx]; $res = nxs_chckRmImage($imgURL); $imgURL = ''; if (!$res) $options['imgNoCheck'] = '1'; } if ($options['sImg']==1) return $options['useSSLCert'].'/logo2.png'; 
  104. //## Featured Image from Specified Location 
  105. if ((int)$postID>0 && isset($options['featImgLoc']) && $options['featImgLoc']!=='') { $afiLoc= get_post_meta($postID, $options['featImgLoc'], true);  
  106. if (is_array($afiLoc) && $options['featImgLocArrPath']!='') { $cPath = $options['featImgLocArrPath']; 
  107. while (strpos($cPath, '[')!==false) { $arrIt = CutFromTo($cPath, '[', ']'); $arrIt = str_replace("'", "", str_replace('"', '', $arrIt)); $afiLoc = $afiLoc[$arrIt]; $cPath = substr($cPath, strpos($cPath, ']'));}  
  108. } $imgURL = trim($options['featImgLocPrefix']).trim($afiLoc); if ($imgURL!='' && stripos($imgURL, 'http')===false) $imgURL = home_url().$imgURL; 
  109. } 
  110. if ($imgURL!='' && $options['imgNoCheck']!='1' && nxs_chckRmImage($imgURL)==false) $imgURL = ''; if ($imgURL!='') return $imgURL; 
  111. //## Featured Image 
  112. if ($imgURL=='') { if ((int)$postID>0 && function_exists("get_post_thumbnail_id") && function_exists('has_post_thumbnail') && has_post_thumbnail($postID) ) {  
  113. $imgURL = wp_get_attachment_image_src(get_post_thumbnail_id($postID), $size); $imgURL = $imgURL[0]; if ((trim($imgURL)!='') && substr($imgURL, 0, 4)!='http') $imgURL = site_url($imgURL); 
  114. }}  
  115. if ($imgURL!='' && $options['imgNoCheck']!='1' && nxs_chckRmImage($imgURL)==false) $imgURL = ''; if ($imgURL!='') return $imgURL;  
  116. //## plugin/categories-images 
  117. if ((int)$postID>0 && function_exists('z_taxonomy_image_url')) { $post_categories = wp_get_post_categories( $postID ); 
  118. foreach($post_categories as $c) { $cat = get_category( $c ); $imgURL = trim(z_taxonomy_image_url($cat->term_id)); if ($imgURL!='') break; } 
  119. if ($imgURL!='' && substr($imgURL, 0, 4)!='http') { 
  120. $stURL = site_url(); if (substr($stURL, -1)=='/') $stURL = substr($stURL, 0, -1); if ($imgURL!='') $imgURL = $stURL.$imgURL;  
  121. } 
  122. } 
  123. if ($imgURL!='' && $options['imgNoCheck']!='1' && nxs_chckRmImage($imgURL)==false) $imgURL = ''; if ($imgURL!='') return $imgURL; 
  124. //## YAPB 
  125. if ((int)$postID>0 && class_exists("YapbImage")) { $imgURLObj = YapbImage::getInstanceFromDb($postID); if (is_object($imgURLObj)) $imgURL = $imgURLObj->uri;  
  126. $stURL = site_url(); if (substr($stURL, -1)=='/') $stURL = substr($stURL, 0, -1); if ($imgURL!='') $imgURL = $stURL.$imgURL;  
  127. } 
  128. if ($imgURL!='' && $options['imgNoCheck']!='1' && nxs_chckRmImage($imgURL)==false) $imgURL = ''; if ($imgURL!='') return $imgURL; 
  129. //## Find Images in Post 
  130. if ((int)$postID>0 && $imgURL=='') {$post = get_post($postID); $imgsFromPost = nsFindImgsInPost($post, $options['useUnProc'] == '1'); if (is_array($imgsFromPost) && count($imgsFromPost)>0) $imgURL = $imgsFromPost[0]; } //echo "##".count($imgsFromPost); prr($imgsFromPost); 
  131. if ($imgURL!='' && $options['imgNoCheck']!='1' && nxs_chckRmImage($imgURL)==false) $imgURL = ''; if ($imgURL!='') return $imgURL; 
  132. //## Attachements 
  133. if ((int)$postID>0 && $imgURL=='') { $attachments = get_posts(array('post_type' => 'attachment', 'posts_per_page' => -1, 'post_parent' => $postID));  
  134. if (is_array($attachments) && count($attachments)>0 && is_object($attachments[0])) { $imgURL = wp_get_attachment_image_src($attachments[0]->ID, $size); $imgURL = $imgURL[0]; }  
  135. } 
  136. if ($imgURL!='' && $options['imgNoCheck']!='1' && nxs_chckRmImage($imgURL)==false) $imgURL = ''; if ($imgURL!='') return $imgURL;  
  137. //## Default 
  138. if (trim($imgURL)=='' && trim($def)=='') $imgURL = $options['ogImgDef'];  
  139. if (trim($imgURL)=='' && trim($def)!='') $imgURL = $def;  
  140.   
  141. return $imgURL; 
  142. }} 
  143. if (!function_exists('nxs_makeURLParams')) { function nxs_makeURLParams($params) { global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options; 
  144. if (!isset($options['addURLParams']) || $options['addURLParams']=='') return false; else $templ = $options['addURLParams']; 
  145. if (preg_match('%NTNAME%', $templ)) $templ = str_ireplace("%NTNAME%", urlencode($params['NTNAME']), $templ); 
  146. if (preg_match('%NTCODE%', $templ)) $templ = str_ireplace("%NTCODE%", urlencode($params['NTCODE']), $templ); 
  147. if (preg_match('%ACCNAME%', $templ)) $templ = str_ireplace("%ACCNAME%", urlencode($params['ACCNAME']), $templ); 
  148. if (preg_match('%POSTID%', $templ)) $templ = str_ireplace("%POSTID%", urlencode($params['POSTID']), $templ); 
  149. if (preg_match('%POSTTITLE%', $templ)) { $post = get_post($params['POSTID']); if (is_object($post)) {$postName = $post->post_title; $templ = str_ireplace("%POSTTITLE%", urlencode($postName), $templ);}} 
  150. if (preg_match('%SITENAME%', $templ)) { $siteTitle = urlencode(htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES)); $templ = str_ireplace("%SITENAME%", $siteTitle, $templ); } 
  151. return $templ; 
  152. }} 
  153.   
  154. function nxs_tiny_mce_before_init($init) { global $tinymce_version;  
  155. if (substr($tinymce_version, 0, 1)<4) $init['setup'] = "function( ed ) { ed.onChange.add( function( ed, e ) { nxs_updateGetImgsX( e ); }); }"; else 
  156. $init['setup'] = "function(ed) {ed.on('NodeChange', function(e) {nxs_updateGetImgsX(e);});}";  
  157. return $init; 
  158. } 
  159.   
  160. //## CSS && JS 
  161. if (!function_exists("jsPostToSNAP")) { function jsPostToSNAP() { global $nxs_snapAvNts, $nxs_plurl; ?> 
  162. <script type="text/javascript" >  
  163. function nxs_updateGetImgsX(e) { } 
  164. jQuery(document).on('change', '#content', function( e ) { nxs_updateGetImgsX( e ); }); 
  165.  
  166. function nxs_updateGetImgsXX(e) {  
  167. var targetId = e.target.id;  
  168. var text = 'Kortinko'; 
  169. switch ( targetId ) { 
  170. case 'content': 
  171. text = jQuery('#content').val();  
  172. break; 
  173. case 'tinymce': 
  174. if ( tinymce.activeEditor ) text = tinymce.activeEditor.getContent(); 
  175. break; 
  176. } 
  177. jQuery('.nxs_imgPrevList').html( text ); 
  178. }  
  179. function nxs_clPrvImgShow(tIdN) { jQuery("#isAutoImg-"+tIdN).trigger('click'); jQuery("#isAutoImg-"+tIdN).trigger('click'); }  
  180. function nxs_clPrvImg(id, ii) { jQuery("#imgToUse-"+ii).val(jQuery("#"+id+" img").attr('src')); jQuery(".nxs_prevIDiv"+ii+" .nxs_checkIcon").hide(); 
  181. jQuery(".nxs_prevIDiv"+ii).removeClass("nxs_chImg_selDiv"); jQuery(".nxs_prevIDiv"+ii+" img").removeClass("nxs_chImg_selImg");  
  182. jQuery("#"+id+" img").addClass("nxs_chImg_selImg"); jQuery("#"+id).addClass("nxs_chImg_selDiv"); jQuery("#"+id+" .nxs_checkIcon").show(); 
  183. }  
  184. function nxs_getOriginalWidthOfImg(img_element) { var t = new Image(); t.src = (img_element.getAttribute ? img_element.getAttribute("src") : false) || img_element.src; /* alert(t.src+" | "+t.width); */ return t.width; }  
  185. function nxs_updateGetImgs(e) {  
  186. var textOut=''; var text = ''; 
  187. var tId = e.target.id;  
  188. var tIdN = tId.replace("isAutoImg-", ""); 
  189. if ( tinymce.activeEditor ) text = tinymce.activeEditor.getContent(); 
  190. if ( text == '' ) text = jQuery('#content').val();  
  191.  
  192. jQuery('#NS_SNAP_AddPostMetaTags').append('<div id="nxs_tempDivImgs" style="display: none;"></div>'); jQuery('#nxs_tempDivImgs').append(text); 
  193. var textOutA = new Array(); var currSelImg = jQuery("#imgToUse-"+tIdN).val(); 
  194.  
  195. textOutA.push('http://cdn.gtln.us/img/nxs/noImgC.png');  
  196. //var fImg = jQuery('.attachment-post-thumbnail').attr('src'); if (fImg!='' && fImg!=undefined) { textOutA.push(fImg); if (currSelImg=='') currSelImg = fImg; }  
  197. var fImg = jQuery('#set-post-thumbnail > img').attr('src'); if (fImg!='' && fImg!=undefined) { textOutA.push(fImg); if (currSelImg=='') currSelImg = fImg; }  
  198. var fImg = jQuery('#yapbdiv img').attr('src'); if (fImg!='' && fImg!=undefined) { textOutA.push(fImg); if (currSelImg=='') currSelImg = fImg; } 
  199.  
  200. jQuery('#nxs_tempDivImgs img').each(function() { var prWidth; prWidth = nxs_getOriginalWidthOfImg(this); if (prWidth!=1) textOutA.push(jQuery(this).attr('src')); });  
  201. jQuery('#nxs_tempDivImgs').remove(); 
  202. var index; for (index = 0; index < textOutA.length; ++index) { var isSel = currSelImg == textOutA[index] ? 'nxs_chImg_selImg' : ''; var isSelDisp = currSelImg == textOutA[index] ? 'style="display:block;"' : '';  
  203. textOut = textOut + '<div class="nxs_prevIDiv'+tIdN+' nxs_prevImagesDiv" id="nxs_idiv'+tIdN+index+'" onclick="nxs_clPrvImg(\'nxs_idiv'+tIdN+index+'\', \''+tIdN+'\');"><img class="nxs_prevImages '+isSel+'" src="'+textOutA[index]+'"><div '+isSelDisp+' class="nxs_checkIcon"><div class="media-modal-icon"></div></div></div>';  
  204. jQuery('#imgPrevList-'+tIdN).html( textOut ); 
  205. if (jQuery('#'+tId).is(":checked")) jQuery('#imgPrevList-'+tIdN).hide(); else { jQuery('#nxs_'+tIdN+'_idivD').hide(); jQuery('#imgPrevList-'+tIdN).show(); } 
  206.  
  207.  
  208. jQuery(document).on('change', '.isAutoURL', function( e ) { var tId = e.target.id; var tIdN = tId.replace("isAutoURL-", ""); 
  209. if (jQuery('#'+tId).is(":checked")) { jQuery('#isAutoURLFld-'+tIdN).hide(); jQuery('#URLToUse-'+tIdN).val(''); } else { jQuery('#isAutoURLFld-'+tIdN).show(); } 
  210. });  
  211. jQuery(document).on('change', '.isAutoImg', function( e ) {  
  212. nxs_updateGetImgs( e ); 
  213. });  
  214. jQuery(document).on('change', '#wp-content-editor-container #conXXtent', function() { 
  215. nxs_updateGetImgs(); 
  216. }); 
  217. jQuery(document).on('change', '#tinXXymce', function() { 
  218. nxs_updateGetImgs(); 
  219. });  
  220. jQuery(document).ready(function($) {  
  221. <?php  
  222. foreach ($nxs_snapAvNts as $avNt) {?> 
  223. jQuery('input#rePostTo<?php echo $avNt['code']; ?>_button').click(function() { var data = { action: 'rePostTo<?php echo $avNt['code']; ?>', id: jQuery('input#post_ID').val(), nid:jQuery(this).attr('alt'), _wpnonce: jQuery('input#nxsSsPageWPN_wpnonce').val()}; callAjSNAP(data, '<?php echo $avNt['name']; ?>'); }); 
  224. <?php }  
  225. foreach ($nxs_snapAvNts as $avNt) {?> 
  226. jQuery('input#riTo<?php echo $avNt['code']; ?>_button').click(function() { var data = { action: 'rePostTo<?php echo $avNt['code']; ?>', id: jQuery('input#post_ID').val(), ri:1, nid:jQuery(this).attr('alt'), _wpnonce: jQuery('input#nxsSsPageWPN_wpnonce').val()}; callAjSNAP(data, '<?php echo $avNt['name']; ?>'); }); 
  227. <?php } ?> 
  228. function callAjSNAP(data, label) {  
  229. var style = "position: fixed; display: none; z-index: 1000; top: 50%; left: 50%; background-color: #E8E8E8; border: 1px solid #555; padding: 15px; width: 350px; min-height: 80px; margin-left: -175px; margin-top: -40px; text-align: center; vertical-align: middle;"; 
  230. jQuery('body').append("<div id='test_results' style='" + style + "'></div>"); 
  231. jQuery('#test_results').html("<p>Sending update to "+label+"</p>" + "<p><img src='<?php echo $nxs_plurl; ?>img/ajax-loader-med.gif' /></p>"); 
  232. jQuery('#test_results').show();  
  233. jQuery.post(ajaxurl, data, function(response) { if (response=='') response = 'Message Posted'; 
  234. jQuery('#test_results').html('<p> ' + response + '</p>' +'<input type="button" class="button" name="results_ok_button" id="results_ok_button" value="OK" />'); 
  235. jQuery('#results_ok_button').click(remove_results); 
  236. });  
  237. }  
  238. function remove_results() { jQuery("#results_ok_button").unbind("click");jQuery("#test_results").remove(); 
  239. if (typeof document.body.style.maxHeight == "undefined") { jQuery("body", "html").css({height: "auto", width: "auto"}); jQuery("html").css("overflow", "");} 
  240. document.onkeydown = "";document.onkeyup = ""; return false; 
  241. }); 
  242. </script>  
  243. <?php 
  244. if (!function_exists("nxs_jsPostToSNAP2")) { function nxs_jsPostToSNAP2() { global $nxs_snapAvNts, $nxs_snapThisPageUrl, $plgn_NS_SNAutoPoster, $nxs_plurl;  
  245. if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;  
  246. ?> 
  247.  
  248. <script type="text/javascript">  
  249.  
  250. jQuery(function() { 
  251. jQuery("form .categorydiv .selectit input:checkbox").click ( function() { var nxs_isLocked = jQuery('#nxsLockIt').val(); if (nxs_isLocked=='1') return;  
  252. var thVal = jQuery(this).val(); if (!jQuery(this).is(":checked")) return;  
  253.  
  254. var arr = [<?php if (!empty($options['exclCats'])) { $xarr = maybe_unserialize($options['exclCats']); if (is_array($xarr)) echo "'".implode("', '", $xarr)."'"; } ?>]; 
  255. if ( jQuery.inArray(thVal, arr)>-1) jQuery('.nxsGrpDoChb').removeAttr('checked'); else jQuery(".nxsGrpDoChb[title='def']").attr('checked', 'checked'); 
  256.  
  257. jQuery(".nxs_SC").each(function(index) { var cats = jQuery(this).val(); var catsA = cats.split(', '); uqID = jQuery(this).attr('id'); uqID = uqID.replace("nxs_SC_", "do", "gi"); 
  258. if (jQuery.inArray(thVal, catsA)>-1) jQuery('#'+uqID).attr('checked', 'checked') 
  259. // alert( uqID + "|" + catsA + "|" + thVal);  
  260. });  
  261.  
  262. jQuery(".nxs_TG").each(function(index) { var cats = jQuery(this).val(); var catsA = cats.split(', '); uqID = jQuery(this).attr('id'); uqID = uqID.replace("nxs_TG_", "do", "gi"); 
  263. if (jQuery.inArray(thVal, catsA)>-1) jQuery('#'+uqID).attr('checked', 'checked') 
  264. // alert( uqID + "|" + catsA + "|" + thVal);  
  265. });  
  266.  
  267. }); 
  268. }); 
  269.  
  270. function seFBA(pgID, fbAppID, fbAppSec) { var data = { pgID: pgID, action: 'nsAuthFBSv', _wpnonce: jQuery('input#nxsSsPageWPN_wpnonce').val()};  
  271. jQuery.post(ajaxurl, data, function(response) {  
  272. window.location = "https://www.facebook.com/dialog/oauth?client_id="+fbAppID+"&client_secret="+fbAppSec+"&scope=publish_stream, offline_access, read_stream, manage_pages&redirect_uri=<?php echo $nxs_snapThisPageUrl;?>"; 
  273. });  
  274. function doLic() { var lk = jQuery('#eLic').val(); jQuery.post(ajaxurl, {lk:lk, action: 'nxsDoLic', id: 0, _wpnonce: jQuery('input#doLic_wpnonce').val()}, function(j) {  
  275. if (jQuery.trim(j)=='OK') window.location = "<?php echo $nxs_snapThisPageUrl; ?>"; else alert('<?php _e('Wrong key, please contact support', 'social-networks-auto-poster-facebook-twitter-g'); ?>'); 
  276. }, "html") 
  277. function testPost(nt, nid) { jQuery(".blnkg").hide(); <?php foreach ($nxs_snapAvNts as $avNt) {?> 
  278. if (nt=='<?php echo $avNt['code']; ?>') {  
  279. var data = { action: 'rePostTo<?php echo $avNt['code']; ?>', id: 0, nid: nid, _wpnonce: jQuery('input#nxsSsPageWPN_wpnonce').val()}; callAjSNAP(data, '<?php echo $avNt['name']; ?>');  
  280. }<?php } ?> 
  281.  
  282. function nxs_doTabs() { 
  283. jQuery('#nxsAPIUpd').dblclick(function() { doLic(); }); 
  284. //When page loads... 
  285. jQuery(".nsx_tab_content").hide(); //Hide all content 
  286. jQuery("ul.nsx_tabs > li:first-child").addClass("active").show(); //Activate first tab 
  287. jQuery(".nsx_tab_container > .nsx_tab_content:first-child").show(); //Show first tab content 
  288.  
  289. //On Click Event 
  290. jQuery("ul.nsx_tabs li").click(function() { 
  291. jQuery(this).parent().children("li").removeClass("active"); //Remove any "active" class 
  292. jQuery(this).addClass("active"); //Add "active" class to selected tab 
  293. jQuery(this).parent().parent().children(".nsx_tab_container").children(".nsx_tab_content").hide(); //Hide all tab content  
  294. var activeTab = jQuery(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content 
  295. jQuery(activeTab).show(); //Fade in the active ID content 
  296. return false; 
  297. }); 
  298.  
  299.  
  300. function nxs_doTabsInd(iid) {  
  301. //When page loads... 
  302. jQuery(iid+" .nsx_tab_content").hide(); //Hide all content 
  303. jQuery(iid+" ul.nsx_tabs > li:first-child").addClass("active").show(); //Activate first tab 
  304. jQuery(iid+" .nsx_tab_container > .nsx_tab_content:first-child").show(); //Show first tab content 
  305.  
  306. //On Click Event 
  307. jQuery(iid+" ul.nsx_tabs li").click(function() { 
  308. jQuery(this).parent().children("li").removeClass("active"); //Remove any "active" class 
  309. jQuery(this).addClass("active"); //Add "active" class to selected tab 
  310. jQuery(this).parent().parent().children(".nsx_tab_container").children(".nsx_tab_content").hide(); //Hide all tab content  
  311. var activeTab = jQuery(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content 
  312. jQuery(activeTab).show(); //Fade in the active ID content 
  313. return false; 
  314. }); 
  315.  
  316.  
  317. function nxs_in_array(needle, haystack) { for(var i in haystack) { if(haystack[i] == needle) return true;} return false; } 
  318.  
  319.  
  320.  
  321. jQuery(document).ready(function() { nxs_doTabs(); 
  322. //## Check for excluded Tags  
  323. var nxs_curTagsValue = []; jQuery('.the-tags').each(function() {if (jQuery(this).val()!='') nxs_curTagsValue[jQuery(this).attr('id')] = jQuery(this).val(); }); 
  324. jQuery(function () { setTimeout(nxs_checkTagsChangesX, 50); }); 
  325.  
  326. function nxs_checkTagsChangesX() { var isChanged = false; var nxs_isLocked = jQuery('#nxsLockIt').val(); if (nxs_isLocked=='1') return; 
  327. jQuery('.the-tags').each(function() {  
  328. currentValue = jQuery( this ).val(); currID = jQuery(this).attr('id'); // console.log( currID );  
  329. if ((currentValue) && currentValue != nxs_curTagsValue[currID] && currentValue != '') isChanged = true; 
  330. });  
  331. if (isChanged) { //## Changed 
  332. jQuery('.the-tags').each(function() { if (jQuery(this).val()!='') nxs_curTagsValue[jQuery(this).attr('id')] = jQuery(this).val(); }); 
  333. var nxs_curTagsValueX = ''; var tValX = []; 
  334. jQuery('.the-tags').each(function() {  
  335. var tVals = jQuery( this ).val().toLowerCase().split(", "); var tID = jQuery( this ).attr('id').replace("tax-input-", "");  
  336. for(var ii in tVals) tValX.push(tID+"|"+jQuery.trim(tVals[ii]));  
  337. }); // console.log( tValX ); 
  338. jQuery(".nxs_TG").each(function(index) { var cats = jQuery(this).val(); var catsA = cats.split(', '); uqID = jQuery(this).attr('id'); uqID = uqID.replace("nxs_TG_", "do", "gi"); 
  339. // console.log( uqID ); console.log( JSON.stringify( catsA ) ); 
  340. for(var ii in catsA) { var tgVal = jQuery.trim(catsA[ii]).toLowerCase(); 
  341. if (tgVal.indexOf("|")<1 && tgVal!="") tgVal = "post_tag|"+tgVal; 
  342. if (tgVal!="" && jQuery.inArray(tgVal, tValX)>-1) { jQuery('#'+uqID).attr('checked', 'checked'); }  
  343. }  
  344. }); 
  345. } setTimeout(nxs_checkTagsChangesX, 50); 
  346.  
  347. }); 
  348. </script> 
  349.  
  350. <style type="text/css"> 
  351. .NXSButton { background-color:#89c403; 
  352. background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #89c403), color-stop(1, #77a809) ); 
  353. background:-moz-linear-gradient( center top, #89c403 5%, #77a809 100% ); 
  354. filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#89c403', endColorstr='#77a809');  
  355. -moz-border-radius:4px; -webkit-border-radius:4px; border-radius:4px; border:1px solid #74b807; display:inline-block; color:#ffffff; 
  356. font-family:Trebuchet MS; font-size:12px; font-weight:bold; padding:4px 5px; text-decoration:none; text-shadow:1px 1px 0px #528009; 
  357. }.NXSButton:hover {color:#ffffff; background-color:#77a809; 
  358. background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #77a809), color-stop(1, #89c403) ); 
  359. background:-moz-linear-gradient( center top, #77a809 5%, #89c403 100% ); 
  360. filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#77a809', endColorstr='#89c403');  
  361. }.NXSButton:active {color:#ffffff; position:relative; top:1px;}.NXSButton:focus {color:#ffffff; position:relative; top:1px;} .nsBigText{font-size: 14px; color: #585858; font-weight: bold; display: inline;} 
  362. .NXSButtonB { background-color:#038bc4; 
  363. background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #038bc4), color-stop(1, #096aa8) ); 
  364. background:-moz-linear-gradient( center top, #038bc4 5%, #096aa8 100% ); 
  365. filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#038bc4', endColorstr='#096aa8');  
  366. -moz-border-radius:4px; -webkit-border-radius:4px; border-radius:4px; border:1px solid #077cb8; display:inline-block; color:#ffffff; 
  367. font-family:Trebuchet MS; font-size:12px; font-weight:bold; padding:4px 5px; text-decoration:none; text-shadow:1px 1px 0px #095d80; 
  368. }.NXSButtonB:hover {color:#ffffff; background-color:#096aa8; 
  369. background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #096aa8), color-stop(1, #038bc4) ); 
  370. background:-moz-linear-gradient( center top, #096aa8 5%, #038bc4 100% ); 
  371. filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#096aa8', endColorstr='#038bc4');  
  372. }.NXSButtonB:active {color:#ffffff; position:relative; top:1px;}.NXSButton:focus {color:#ffffff; position:relative; top:1px;} .nsBigText{font-size: 14px; color: #585858; font-weight: bold; display: inline;} 
  373. #nxs_ntType {width: 150px;} 
  374. #nsx_addNT {width: 600px;} 
  375. .nxsInfoMsg{ margin: 1px auto; padding: 3px 10px 3px 5px; border: 1px solid #ffea90; background-color: #fdfae4; display: inline; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; } 
  376. .blnkg{text-decoration:blink; font-size: 17px; color: #0CB107; font-weight: bold; display: inline;} 
  377.  
  378. div.popShAtt { display: none; position: absolute; width: 600px; padding: 10px; background: #eeeeee; color: #000000; border: 1px solid #1a1a1a; font-size: 90%; } 
  379. .underdash {border-bottom: 1px #21759B dashed; text-decoration:none;} 
  380. .underdash a:hover {border-bottom: 1px #21759B dashed} 
  381.  
  382. .nxsTHRow {vertical-align:top; padding-top:6px; text-align:right; width:80px; padding-right:10px;} 
  383.  
  384. ul.nsx_tabs {margin: 0;padding: 0; margin-top:5px;float: left;list-style: none;height: 32px;border-bottom: 1px solid #999;border-left: 1px solid #999;width: 99%;} 
  385. ul.nsx_tabs li {float: left;margin: 0;padding: 0;height: 31px;line-height: 31px;border: 1px solid #999;border-left: none;margin-bottom: -1px;overflow: hidden;position: relative;background: #e0e0e0;} 
  386. ul.nsx_tabs li a {text-decoration: none;color: #000; display: block; font-size: 1.2em; padding: 0 20px; border: 1px solid #fff; outline: none;} 
  387. ul.nsx_tabs li a:hover { background: #ccc;} 
  388. html ul.nsx_tabs li.active, html ul.nsx_tabs li.active a:hover { background: #fff; border-bottom: 1px solid #fff; } 
  389. .nsx_tab_container {border: 1px solid #999; border-top: none; overflow: hidden; clear: both; float: left; width: 99%; background: #fff;} 
  390. .nsx_tab_content {padding: 10px;} 
  391.  
  392. .nxs_tls_cpt{width:100%; padding-bottom: 5px; padding-top: 10px;font-size: 16px; font-weight: bold;} 
  393. .nxs_tls_bd{width:100%; padding-left: 10px; padding-bottom: 10px;} 
  394. .nxs_tls_sbInfo{font-style: italic; padding-bottom: 10px; padding-top: 2px;} 
  395. .nxs_tls_sbInfo2{font-style: italic; padding-left: 10px; padding-bottom: 5px; line-height: 10px; font-size: 11px;} 
  396. .nxs_tls_lbl{width:100%;padding-top:7px;padding-bottom:1px;} 
  397. .nxsInstrSpan{ font-size: 11px; } 
  398.  
  399.  
  400. .subDiv{margin-left: 15px;} 
  401. .nxs_hili {color:#008000;} 
  402. .clNewNTSets{width: 800px;} 
  403. .nxclear {clear: both;} 
  404.  
  405. .nxs_icon16 { font-size: 14px; line-height: 18px; 
  406. background-position: 3px 50% !important; 
  407. background-repeat: no-repeat !important; 
  408. display: inline-block; 
  409. padding: 1px 0 1px 23px !important; 
  410.  
  411. .nxs_box{border-color: #DFDFDF; border-radius: 3px 3px 3px 3px; box-shadow: 0 1px 0 #FFFFFF inset; border-style: solid; border-width: 1px; line-height: 1; margin-bottom: 10px; padding: 0; /* max-width: 1080px; */
  412. .nxs_box_header{border-bottom-color: #DFDFDF; box-shadow: 0 1px 0 #FFFFFF; text-shadow: 0 1px 0 #FFFFFF;font-size: 15px;font-weight: normal;line-height: 1;margin: 0;padding: 6px; 
  413. background:#f1f1f1;background-image:-webkit-gradient(linear, left bottom, left top, from(#ececec), to(#f9f9f9));background-image:-webkit-linear-gradient(bottom, #ececec, #f9f9f9);background-image:-moz-linear-gradient(bottom, #ececec, #f9f9f9);background-image:-o-linear-gradient(bottom, #ececec, #f9f9f9);background-image:linear-gradient(to top, #ececec, #f9f9f9) 
  414. -moz-user-select: none;border-bottom-style: solid;border-bottom-width: 1px;} 
  415. .nxs_box_inside{line-height: 1.4em; padding: 10px;} 
  416. .nxs_box_inside input[type=text]{ padding: 5px; height: 24px; border: 1px solid #ACACAC;} 
  417. .nxs_box_inside .insOneDiv, #nsx_addNT .insOneDiv{max-width: 1020px; background-color: #f8f9f9; background-repeat: no-repeat; margin: 10px; border: 1px solid #808080; padding: 10px; display:none; overflow: hidden;} 
  418. .nxs_box_inside .itemDiv {margin:5px;margin-left:10px;} 
  419. .nxs_box_header h3 {font-size: 14px; margin-bottom: 2px; margin-top: 2px;} 
  420. .nxs_newLabel {font-size: 11px; color:red; padding-left: 5px; padding-right: 5px;} 
  421.  
  422. .nxs_prevImagesDiv {border:1px solid #0f3c6d; width:110px; height:110px; margin:3px; padding:3px; text-align:center; float:left; position: relative;} 
  423. .nxs_prevImages {padding:1px; max-height:100px; max-width:100px;} 
  424. .nxs_chImg_selDiv {border:1px solid #800000;} 
  425. .nxs_chImg_selImg {border:4px solid #800000;} 
  426. .nxs_checkIcon{position: absolute;} 
  427.  
  428. .nxs_checkIcon{display:none; height:24px;width:24px;position:absolute;top:-7px;right:-7px;outline:0;border:1px solid #fff;border-radius:3px;box-shadow:0 0 0 1px rgba(0, 0, 0, 0.4);background:#800000;background-image:-webkit-gradient(linear, left top, left bottom, from(#800000), to(#570000));background-image:-webkit-linear-gradient(top, #800000, #570000);background-image:-moz-linear-gradient(top, #800000, #570000);background-image:-o-linear-gradient(top, #800000, #570000);background-image:linear-gradient(to bottom, #800000, #570000)} 
  429. .nxs_checkIcon{ top:-5px; right: -3px; width: 15px; height: 15px; box-shadow:0 0 0 1px #800000;background:#800000;background-image:-webkit-gradient(linear, left top, left bottom, from(#800000), to(#570000));background-image:-webkit-linear-gradient(top, #800000, #570000);background-image:-moz-linear-gradient(top, #800000, #570000);background-image:-o-linear-gradient(top, #800000, #570000);background-image:linear-gradient(to bottom, #800000, #570000)} 
  430. .nxs_checkIcon div{background-position:-21px 0; width: 15px; height: 15px;} 
  431. /* #nxsDivWrap .postbox .inside {overflow: hidden;} */ 
  432. #nxsDivWrap .postbox .description {vertical-align: middle; color: #ACACAC;}  
  433.  
  434. .submitX {padding-top: 7px; padding-bottom: 5px;} 
  435.  
  436. .nxs_txtIcon { margin: 0px; padding-left: 20px; background-repeat: no-repeat;} .nxs_ti_gp {background-image: url('<?php echo $nxs_plurl; ?>img/gp16.png');}  
  437. .nxs_ti_li {background-image: url('<?php echo $nxs_plurl; ?>img/li16.png');} .nxs_ti_rd {background-image: url('<?php echo $nxs_plurl; ?>img/rd16.png');}  
  438. .nxs_ti_fp {background-image: url('<?php echo $nxs_plurl; ?>img/fp16.png');} .nxs_ti_yt {background-image: url('<?php echo $nxs_plurl; ?>img/yt16.png');}  
  439. .nxs_ti_bg {background-image: url('<?php echo $nxs_plurl; ?>img/bg16.png');} .nxs_ti_pn {background-image: url('<?php echo $nxs_plurl; ?>img/pn16.png');}  
  440.  
  441. input[readonly]{ background-color:white; }  
  442. .nxs-selz-dropwodn {max-width: 200px;} 
  443. </style> 
  444. <?php }} 
  445.  
  446. if (!function_exists('nxs_doShowHint')) { function nxs_doShowHint($t, $ex='', $wdth='79') { ?> 
  447. <div id="<?php echo $t; ?>Hint" class="nxs_FRMTHint" style="font-size: 11px; margin: 2px; margin-top: 0px; padding:7px; border: 1px solid #C0C0C0; width: <?php echo $wdth; ?>%; background: #fff; display: none;"><span class="nxs_hili">%TITLE%</span> - <?php _e('Inserts the Title of the post', 'social-networks-auto-poster-facebook-twitter-g'); ?>, <span class="nxs_hili">%URL%</span> - <?php _e('Inserts the URL of the post', 'social-networks-auto-poster-facebook-twitter-g'); ?>, <span class="nxs_hili">%SURL%</span> - <?php _e('Inserts the <b>shortened URL</b> of your post', 'social-networks-auto-poster-facebook-twitter-g'); ?>, <span class="nxs_hili">%IMG%</span> - <?php _e('Inserts the featured image URL', 'social-networks-auto-poster-facebook-twitter-g'); ?>, <span class="nxs_hili">%EXCERPT%</span> - <?php _e('Inserts the excerpt of the post (processed)', 'social-networks-auto-poster-facebook-twitter-g'); ?>, <span class="nxs_hili">%RAWEXCERPT%</span> - <?php _e('Inserts the excerpt of the post (as typed)', 'social-networks-auto-poster-facebook-twitter-g'); ?>, <span class="nxs_hili">%ANNOUNCE%</span> - <?php _e('Inserts the text till the <!--more--> tag or first N words of the post', 'social-networks-auto-poster-facebook-twitter-g'); ?>, <span class="nxs_hili">%FULLTEXT%</span> - <?php _e('Inserts the processed body(text) of the post', 'social-networks-auto-poster-facebook-twitter-g'); ?>, <span class="nxs_hili">%RAWTEXT%</span> - <?php _e('Inserts the body(text) of the post as typed', 'social-networks-auto-poster-facebook-twitter-g'); ?>, <span class="nxs_hili">%TAGS%</span> - <?php _e('Inserts post tags', 'social-networks-auto-poster-facebook-twitter-g'); ?>, <span class="nxs_hili">%CATS%</span> - <?php _e('Inserts post categories', 'social-networks-auto-poster-facebook-twitter-g'); ?>, <span class="nxs_hili">%HTAGS%</span> - <?php _e('Inserts post tags as hashtags', 'social-networks-auto-poster-facebook-twitter-g'); ?>, <span class="nxs_hili">%HCATS%</span> - <?php _e('Inserts post categories as hashtags', 'social-networks-auto-poster-facebook-twitter-g'); ?>, <span class="nxs_hili">%AUTHORNAME%</span> - <?php _e('Inserts the author\'s name', 'social-networks-auto-poster-facebook-twitter-g'); ?>, <span class="nxs_hili">%SITENAME%</span> - <?php _e('Inserts the the Blog/Site name', 'social-networks-auto-poster-facebook-twitter-g'); ?>. <?php echo $ex; ?></div> 
  448. <?php }} 
  449.  
  450. if (!function_exists('nxs_doSMAS')) { function nxs_doSMAS($nType, $typeii) { ?><div id="do<?php echo $typeii; ?>Div" class="clNewNTSets" style="margin-left: 10px; display:none; "><div style="font-size: 15px; text-align: center;"><br/><br/> 
  451. <?php printf( __( 'You already have %s configured. This plugin supports only one %s account. <br/><br/> Please consider getting <a target="_blank" href="http://www.nextscripts.com/social-networks-auto-poster-for-wp-multiple-accounts">Multiple Accounts Edition</a> if you would like to add another %s account for auto-posting.', 'social-networks-auto-poster-facebook-twitter-g' ), $nType, $nType, $nType ); ?> 
  452. </div></div><?php  
  453. }} 
  454.  
  455. if (!function_exists('nxs_snapCleanup')) { function nxs_snapCleanup($options) { global $nxs_snapAvNts;  
  456. foreach ($nxs_snapAvNts as $avNt) { if (!isset($options[$avNt['lcode']]) || count($options[$avNt['lcode']])>1) { $copt = ''; $t = ''; 
  457. if (isset($options[$avNt['lcode']]) && is_array($options[$avNt['lcode']])) $copt = array_values( $options[$avNt['lcode']] );  
  458. $t = (isset($copt[0]) && is_array($copt[0]) && count($copt[0]>2))?$copt[0]:''; $options[$avNt['lcode']] = array(); if ($t!='') $options[$avNt['lcode']][] = $t; 
  459. }} 
  460. return $options; 
  461. }} 
  462.  
  463. //if (!function_exists('nxs_html_to_utf8')) { function nxs_html_to_utf8 ($data) {return preg_replace("/\\&\\#([0-9]{3, 10})\\;/e", 'nxs__html_to_utf8("\\1")', $data); }} 
  464. if (!function_exists('nxs_html_to_utf8')) { function nxs_html_to_utf8 ($data) {return preg_replace_callback("/\\&\\#([0-9]{3, 10})\\;/", create_function ('$matches', 'return nxs__html_to_utf8($matches[2]);'), $data); }} 
  465. if (!function_exists('nxs__html_to_utf8')) { function nxs__html_to_utf8 ($data) { if ($data > 127) { $i = 5; while (($i--) > 0) { 
  466. if ($data != ($a = $data % ($p = pow(64, $i)))) {  
  467. $ret = chr(base_convert(str_pad(str_repeat(1, $i + 1), 8, "0"), 2, 10) + (($data - $a) / $p)); for ($i; $i > 0; $i--) $ret .= chr(128 + ((($data % pow(64, $i)) - ($data % ($p = pow(64, $i - 1)))) / $p)); break; } 
  468. }} else $ret = "&#$data;"; 
  469. return $ret; 
  470. }} 
  471. if (!function_exists("nxs_chArrVar")) { function nxs_chArrVar($arr, $varN, $varV) { return (isset($arr) && is_array($arr) && isset($arr[$varN]) && $arr[$varN]==$varV); }} 
  472.  
  473.  
  474. if (!function_exists("nxs_metaMarkAsPosted")) { function nxs_metaMarkAsPosted($postID, $nt, $did, $args='') { $mpo = get_post_meta($postID, 'snap'.$nt, true); $mpo = maybe_unserialize($mpo); 
  475. //prr($postID); prr('snap'.$nt); prr($mpo); echo "#####".$postID."|".$nt."|".$did."|".$args; 
  476. if (!is_array($mpo)) $mpo = array(); if (!isset($mpo[$did]) || !is_array($mpo[$did])) $mpo[$did] = array(); 
  477. if ($args=='' || ( is_array($args) && isset($args['isPosted']) && $args['isPosted']=='1')) $mpo[$did]['isPosted'] = '1';  
  478. if (is_array($args) && isset($args['isPrePosted']) && $args['isPrePosted']==1) $mpo[$did]['isPrePosted'] = '1';  
  479. if (is_array($args) && isset($args['pgID'])) $mpo[$did]['pgID'] = $args['pgID'];  
  480. if (is_array($args) && isset($args['postURL'])) $mpo[$did]['postURL'] = $args['postURL'];  
  481. if (is_array($args) && isset($args['pDate'])) $mpo[$did]['pDate'] = $args['pDate'];  
  482. /**$mpo = mysql_real_escape_string(serialize($mpo)); */ delete_post_meta($postID, 'snap'.$nt); add_post_meta($postID, 'snap'.$nt, str_replace('\\', '\\\\', serialize($mpo))); 
  483. }} 
  484. if (!function_exists('nxs_checkAddLogTable')) { function nxs_checkAddLogTable() { global $nxs_tpWMPU, $wpdb; if($nxs_tpWMPU=='S') switch_to_blog(1);  
  485. $installed_ver = get_option( "nxs_log_db_table_version" ); if ($installed_ver=='1.1') return true; 
  486. $table_name = $wpdb->prefix . "nxs_log"; 
  487. $sql = "CREATE TABLE $table_name ( 
  488. id bigint(20) NOT NULL AUTO_INCREMENT,  
  489. date datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,  
  490. act VARCHAR(255) DEFAULT '' NOT NULL,  
  491. nt VARCHAR(255) DEFAULT '' NOT NULL,  
  492. type VARCHAR(255) DEFAULT '' NOT NULL,  
  493. msg text NOT NULL,  
  494. extInfo text NOT NULL,  
  495. UNIQUE KEY id (id) 
  496. ) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;"; 
  497. require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($sql); 
  498. delete_option("nxs_log_db_table_version"); add_option("nxs_log_db_table_version", '1.1'); 
  499. if($nxs_tpWMPU=='S' && function_exists("restore_current_blog")) restore_current_blog(); 
  500. }} 
  501. if (!function_exists('nxs_getnxsLog')) { function nxs_getnxsLog() { global $nxs_tpWMPU, $wpdb; if($nxs_tpWMPU=='S') switch_to_blog(1);  
  502. $log = $wpdb->get_results( "SELECT * FROM ". $wpdb->prefix . "nxs_log ORDER BY id", ARRAY_A ); if (!is_array($log)) return array(); else return $log; 
  503. }} 
  504.  
  505. if (!function_exists('nxs_addToLog')) { function nxs_addToLog ($type, $action, $nt, $msg='') { nxs_addToLogN ($type, $action, $nt, $msg); }} 
  506. if (!function_exists('nxs_addToLogN')) { function nxs_addToLogN ($type, $action, $nt, $msg, $extInfo='') { global $nxs_tpWMPU, $wpdb; if($nxs_tpWMPU=='S') switch_to_blog(1);  
  507. global $plgn_NS_SNAutoPoster; if (isset($plgn_NS_SNAutoPoster)) $options = $plgn_NS_SNAutoPoster->nxs_options; if (!empty($options) && !empty($options['numLogRows'])) $numLogRows = $options['numLogRows']; else $numLogRows = 150; 
  508. //## Skip if Minimal Only Setting 
  509. if (isset($options['extDebug']) && $options['extDebug']=='2' && stripos($action, 'Skipped')!==false ) return;  
  510.  
  511. $logItem = array('date'=>date_i18n('Y-m-d H:i:s'), 'act'=>$action, 'msg'=> strip_tags($msg), 'extInfo'=>$extInfo, 'type'=>$type, 'nt'=>$nt);  
  512. $nxDB = $wpdb->insert( $wpdb->prefix . "nxs_log", $logItem ); $lid = $wpdb->insert_id; $lid = $lid-$numLogRows; 
  513. if ($lid>0) $wpdb->query( 'DELETE FROM '.$wpdb->prefix . 'nxs_log WHERE id<'.$lid );  
  514.  
  515. if ($type=='E' && (isset($options['errNotifEmailCB']) && (int)$options['errNotifEmailCB'] == 1 && isset($options['errNotifEmail']) && trim($options['errNotifEmail']) != '')) {  
  516. $log = maybe_unserialize(get_option('NSX_LogToEmail')); if (!is_array($log)) $log = array(); $log[] = $logItem; delete_option("NSX_LogToEmail"); add_option("NSX_LogToEmail", $log, '', 'no'); 
  517.  
  518. // $nxsDBLog = get_option('NS_SNAutoPosterLog'); $nxsDBLog = maybe_unserialize($nxsDBLog); if(!is_array($nxsDBLog)) $nxsDBLog = array(); $nxsDBLog[] = $logItem; $nxsDBLog = array_slice($nxsDBLog, -150);  
  519. // $res = update_option('NS_SNAutoPosterLog', ($nxsDBLog));  
  520. //delete_option('NS_SNAutoPosterLog'); add_option('NS_SNAutoPosterLog', ($nxsDBLog));  
  521. if($nxs_tpWMPU=='S' && function_exists("restore_current_blog")) restore_current_blog();  
  522. }} 
  523.  
  524.  
  525.  
  526. if (!function_exists('nxsMergeArraysOV')) {function nxsMergeArraysOV($Arr1, $Arr2) { 
  527. foreach($Arr2 as $key => $value) { if(array_key_exists($key, $Arr1) && is_array($value)) $Arr1[$key] = nxsMergeArraysOV($Arr1[$key], $Arr2[$key]); else $Arr1[$key] = $value;} return $Arr1; 
  528. }} 
  529.  
  530. if (!function_exists('nxs_MergeCookieArr')) {function nxs_MergeCookieArr($ArrO, $ArrN) { $namesArr = array(); foreach($ArrO as $key => $value) { if (is_object($value)) $namesArr[$key] = $value->name; }  
  531. foreach($ArrN as $key => $value) { if (is_object($value) && $value->value!='deleted') { $isEx = array_search($value->name, $namesArr); if ($isEx===false) $ArrO[] = $value; else $ArrO[$isEx] = $value;}} return $ArrO; 
  532. }} 
  533.  
  534. if (!function_exists('nxs_addPostingDelaySel')) {function nxs_addPostingDelaySel($nt, $ii, $hrs=0, $min=0, $days=0) {  
  535. global $plgn_NS_SNAutoPoster, $nxs_plurl; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options; if ($options['nxsHTDP']=='I') return 'Not Compatible with "Publish Immediately"'; 
  536. if (function_exists('nxs_doSMAS4')) return nxs_doSMAS4($nt, $ii, $hrs, $min, $days); else return '<br/>'; 
  537. }} 
  538. if (!function_exists('nxs_addPostingDelaySelV3')) {function nxs_addPostingDelaySelV3($nt, $ii, $hrs=0, $min=0, $days=0) {  
  539. if (function_exists('nxs_doSMAS4')) { ?> <div class="nxs_tls_cpt"><?php _e('Posting Delay', 'social-networks-auto-poster-facebook-twitter-g'); ?></div>  
  540. <div class="nxs_tls_bd"><?php global $plgn_NS_SNAutoPoster, $nxs_plurl; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;  
  541. if ($options['nxsHTDP']=='I') _e('Not Compatible with "Publish Immediately"'); else echo nxs_doSMAS4($nt, $ii, $hrs, $min, $days); ?></div>  
  542. <?php } else echo '<br/>'; 
  543. }} 
  544.  
  545.  
  546. if (!function_exists("nxs_doQTrans")) { function nxs_doQTrans($txt, $lng='') { if (!function_exists("qtrans_split") && !function_exists("qtranxf_split")) return $txt;  
  547. $txt = str_ireplace('<3', '<3', $txt); $txt = str_ireplace('<(', '<(', $txt); //$txt = preg_replace('/\]*\]/', '', $txt); 
  548. $txt = preg_replace('/\{0, }(.*?)\][\s]{0, }(<a[\s]{0, }.*?<\/a>)[\s]{0, }(.*?)\[\/caption\]/ims', '<p $1> $2 <snap class="wpimgcaption">$3</snap> </p>', $txt); // WP Image with Caption fix 
  549. if (function_exists("qtrans_split") && strpos($txt, '<!--:')!==false ) { $tta = qtrans_split($txt); if ($lng!='') return $tta[$lng]; else return reset($tta); } 
  550. if (function_exists("qtranxf_split") && (strpos($txt, '<!--:')!==false || strpos($txt, '[:')!==false) ) { $tta = qtranxf_split($txt); if ($lng!='') return $tta[$lng]; else return reset($tta); }  
  551. }} 
  552.  
  553. if (!function_exists('nxs_addQTranslSel')) {function nxs_addQTranslSel($nt, $ii, $selLng) {  
  554. if (function_exists('nxs_doSMAS6')) return nxs_doSMAS6($nt, $ii, $selLng); else return '';  
  555. }} 
  556.  
  557. if (!function_exists("nxs_hideTip_ajax")) { function nxs_hideTip_ajax() { check_ajax_referer('nxsSsPageWPN');  
  558. global $plgn_NS_SNAutoPoster, $nxs_plurl; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;  
  559. $options['hideTopTip'] = '1'; update_option($plgn_NS_SNAutoPoster->dbOptionsName, $options); $plgn_NS_SNAutoPoster->nxs_options = $options; 
  560. }} 
  561.  
  562. if (!function_exists("nxs_mkShortURL")) { function nxs_mkShortURL($url, $postID='') { $rurl = ''; global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options; 
  563. if ($options['nxsURLShrtnr']=='B' && trim($options['bitlyUname']!='') && trim($options['bitlyAPIKey']!='')) {  
  564. $response = wp_remote_get('http://api-ssl.bitly.com/v3/shorten?login='.$options['bitlyUname'].'&apiKey='.$options['bitlyAPIKey'].'&longUrl='.urlencode($url));  
  565. if (is_wp_error($response)) { nxs_addToLogN('E', 'bit.ly', '', '-=ERROR=- '.print_r($response, true)); return $url; } 
  566. $rtr = json_decode($response['body'], true); 
  567. if ($rtr['status_code']=='200') $rurl = $rtr['data']['url']; 
  568. } //echo "###".$rurl; 
  569. if ($options['nxsURLShrtnr']=='A' && trim($options['adflyUname']!='') && trim($options['adflyAPIKey']!='')) {  
  570. $response = wp_remote_get('http://api.adf.ly/api.php?key='.$options['adflyAPIKey'].'&uid='.$options['adflyUname'].'&advert_type=int&domain='.$options['adflyDomain'].'&url='.urlencode($url));  
  571. if (is_wp_error($response)) { nxs_addToLogN('E', 'adf.ly', '', '-=ERROR=- '.print_r($response, true)); return $url; }  
  572. if ( $response['body']!='error') $rurl = $response['body']; else { nxs_addToLogN('E', 'adf.ly', '', '-=ERROR=- '.print_r($response, true)); return $url; } 
  573. if ($options['nxsURLShrtnr']=='C' && trim($options['clkimAPIKey']!='')) {  
  574. $response = wp_remote_get('http://clk.im/api?api='.$options['clkimAPIKey'].'&url='.urlencode($url)); 
  575. if (is_wp_error($response)) { nxs_addToLogN('E', 'clk.im', '', '-=ERROR (SYS)=- '.print_r($response, true)); return $url; } $r = json_decode($response['body'], true); //prr($r); die(); 
  576. if (!is_array($r) || $r['error']!='0') { nxs_addToLogN('E', 'clk.im', '', '-=ERROR (JSON)=- '.print_r($response['body'], true)); return $url; } else $rurl = urldecode($r['short']); 
  577. if ($options['nxsURLShrtnr']=='X' && trim($options['xcoAPIKey']!='')) {  
  578. $response = wp_remote_get('http://api.x.co/Squeeze.svc/text/'.$options['xcoAPIKey'].'?url='.urlencode($url));  
  579. if (is_wp_error($response)) { nxs_addToLogN('E', 'x.co', '', '-=ERROR (SYS)=- '.print_r($response, true)); return $url; } $r = $response['body']; 
  580. if (empty($r) || stripos($r, 'http://')===false) { nxs_addToLogN('E', 'x.co', '', '-=ERROR (RES)=- '.print_r($r, true)); return $url; } else $rurl = $r; 
  581.  
  582. if ($options['nxsURLShrtnr']=='U') {  
  583. $flds = array('a'=>'add', 'url'=>$url); $response = wp_remote_post('http://u.to/', array('body' => $flds));  
  584. if (is_wp_error($response)) { nxs_addToLogN('E', 'u.to', '', '-=ERROR (SYS)=- '.print_r($response, true)); return $url; } $r = $response['body']; 
  585. if (empty($r) || stripos($r, "#shurlout').val('")===false) { nxs_addToLogN('E', 'x.co', '', '-=ERROR (RES)=- '.print_r($r, true)); return $url; } else $rurl = CutFromTo($r, "#shurlout').val('", "'"); 
  586.  
  587. if ($options['nxsURLShrtnr']=='P' && trim($options['postAPIKey']!='')) {  
  588. $response = wp_remote_get('http://po.st/api/shorten?longUrl='.urlencode($url).'&apiKey='.$options['postAPIKey']);  
  589. if (is_wp_error($response)) { nxs_addToLogN('E', 'po.st', '', '-=ERROR (SYS)=- '.print_r($response, true)); return $url; } $r = json_decode($response['body'], true);  
  590. if (!is_array($r) || $r['status_txt']!='OK') { nxs_addToLogN('E', 'po.st', '', '-=ERROR (JSON)=- '.print_r($response['body'], true)); return $url; } else $rurl = $r['short_url']; 
  591. if ($options['nxsURLShrtnr']=='W' && function_exists('wp_get_shortlink')) { global $post; $post = get_post($postID); $rurl = wp_get_shortlink($postID, 'post'); } 
  592. if ($options['nxsURLShrtnr']=='Y' && trim($options['YOURLSKey']!='') && trim($options['YOURLSURL']!='')) { $timestamp = time(); $signature = md5( $timestamp . $options['YOURLSKey'] );  
  593. $flds = array('signature'=>$signature, 'action' => 'shorturl', 'url'=>$url, 'format'=>'json', 'timestamp'=>$timestamp);  
  594. $response = wp_remote_post(($options['YOURLSURL']), array('body' => $flds));  
  595. if (is_wp_error($response)) { nxs_addToLogN('E', 'YOURLS', '', '-=ERROR=- '.print_r($response, true)); return $url; }  
  596. $rtr = json_decode($response['body'], true); if (!is_array($rtr) || !isset($rtr['shorturl']) ) { nxs_addToLogN('E', 'goo.gl', '', '-=ERROR=- '.print_r($response, true)); return $url; }  
  597. $rurl = $rtr['shorturl']; 
  598.  
  599. }  
  600. if ($options['nxsURLShrtnr']=='O' || $options['nxsURLShrtnr']=='' || $options['nxsURLShrtnr']=='G') {  
  601. $response = wp_remote_post('https://www.googleapis.com/urlshortener/v1/url'.($options['gglAPIKey']!=''?'?key='.$options['gglAPIKey']:''), array('headers' => array('Content-Type'=>'application/json'), 'body' => '{"longUrl": "'.$url.'"}'));  
  602. if (is_wp_error($response)) { nxs_addToLogN('E', 'goo.gl', '', '-=ERROR=- '.print_r($response, true)); return $url; }  
  603. $rtr = json_decode($response['body'], true); if (!is_array($rtr) || isset($rtr['error']) || !isset($rtr['id']) ) { nxs_addToLogN('E', 'goo.gl', '', '-=ERROR=- '.print_r($response, true)); return $url; }  
  604. $rurl = $rtr['id']; 
  605. }  
  606. //if ($rurl=='') { $response = wp_remote_get('http://gd.is/gtq/'.$url); if ((is_array($response) && ($response['response']['code']=='200'))) $rurl = $response['body']; } 
  607. if ($rurl!='') $url = $rurl; return $url; 
  608. }} 
  609. //## Comments - DISQUS native function has global $post; overwriting $post parameter in the middle of it. 
  610. function nxs_dsq_export_wp($nxPost, $comments=null) { global $wpdb, $wp_query, $post; $post = $nxPost; ob_start(); echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?' . ">\n";?> 
  611. <?php the_generator('export');?><rss version="2.0" xmlns:excerpt="http://wordpress.org/export/<?php echo WXR_VERSION; ?>/excerpt/" xmlns:content="http://purl.org/rss/1.0/modules/content/" 
  612. xmlns:dsq="http://www.disqus.com/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:wp="http://wordpress.org/export/<?php echo WXR_VERSION; ?>/"> 
  613. <channel> 
  614. <title><?php bloginfo_rss('name'); ?></title><link><?php bloginfo_rss('url') ?></link><pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></pubDate> 
  615. <generator>WordPress <?php bloginfo_rss('version'); ?>; Disqus <?php echo DISQUS_VERSION; ?></generator> 
  616. <?php $wp_query->in_the_loop = true; setup_postdata($post); ?> 
  617. <item><title><?php echo apply_filters('the_title_rss', $post->post_title); ?></title><link><?php the_permalink_rss() ?></link> 
  618. <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate> 
  619. <dc:creator><?php echo dsq_export_wxr_cdata(get_the_author()); ?></dc:creator> 
  620. <guid isPermaLink="false"><?php the_guid(); ?></guid> 
  621. <content:encoded><?php echo dsq_export_wxr_cdata( apply_filters('the_content_export', $post->post_content) ); ?></content:encoded> 
  622. <dsq:thread_identifier><?php echo dsq_identifier_for_post($post); ?></dsq:thread_identifier> 
  623. <wp:post_id><?php echo $post->ID; ?></wp:post_id> 
  624. <wp:post_date_gmt><?php echo $post->post_date_gmt; ?></wp:post_date_gmt> 
  625. <wp:comment_status><?php echo $post->comment_status; ?></wp:comment_status> 
  626. <?php 
  627. if ( $comments ) { foreach ( $comments as $c ) { ?> 
  628. <wp:comment> 
  629. <wp:comment_id><?php echo $c->comment_ID; ?></wp:comment_id> 
  630. <wp:comment_author><?php echo dsq_export_wxr_cdata($c->comment_author); ?></wp:comment_author> 
  631. <wp:comment_author_email><?php echo $c->comment_author_email; ?></wp:comment_author_email> 
  632. <wp:comment_author_url><?php echo $c->comment_author_url; ?></wp:comment_author_url> 
  633. <wp:comment_author_IP><?php echo $c->comment_author_IP; ?></wp:comment_author_IP> 
  634. <wp:comment_date><?php echo $c->comment_date; ?></wp:comment_date> 
  635. <wp:comment_date_gmt><?php echo $c->comment_date_gmt; ?></wp:comment_date_gmt> 
  636. <wp:comment_content><?php echo dsq_export_wxr_cdata($c->comment_content) ?></wp:comment_content> 
  637. <wp:comment_approved><?php echo $c->comment_approved; ?></wp:comment_approved> 
  638. <wp:comment_type><?php echo $c->comment_type; ?></wp:comment_type> 
  639. <wp:comment_parent><?php echo $c->comment_parent; ?></wp:comment_parent> 
  640. </wp:comment> 
  641. <?php } } // comments ?> 
  642. </item> 
  643. </channel> 
  644. </rss> 
  645. <?php $output = ob_get_clean(); return $output; 
  646. //##  
  647. if (!function_exists("nxs_postNewComment")) { function nxs_postNewComment($cmnt, $aa = false) { $cmnt['comment_post_ID'] = (int) $cmnt['comment_post_ID']; 
  648. $cmnt['comment_parent'] = isset($cmnt['comment_parent']) ? absint($cmnt['comment_parent']) : 0; $ae = get_option('admin_email'); 
  649. //$u = get_user_by( 'email', get_option('admin_email') ); $cmnt['user_id'] = $u->ID; //??? 
  650. $u = get_user_by( 'email', $cmnt['comment_author_email'] ); if (!empty($u)) $cmnt['user_id'] = $u->ID; else $cmnt['user_id'] = 0; 
  651.  
  652. $parent_status = ( 0 < $cmnt['comment_parent'] ) ? wp_get_comment_status($cmnt['comment_parent']) : '';  
  653. $cmnt['comment_parent'] = ( 'approved' == $parent_status || 'unapproved' == $parent_status ) ? $cmnt['comment_parent'] : 0; 
  654. $cmnt['comment_author_IP'] = ''; if (empty($cmnt['comment_agent'])) $cmnt['comment_agent'] = 'SNAP'; $cmnt['comment_date'] = get_date_from_gmt( $cmnt['comment_date_gmt'] );  
  655. $cmnt = wp_filter_comment($cmnt); if ($aa) $cmnt['comment_approved'] = 1; else $cmnt['comment_approved'] = nxs_wp_allow_comment($cmnt); // echo "INSERT"; prr($cmnt); 
  656. if ( $cmnt['comment_approved'] != 'spam' && $cmnt['comment_approved']>1 ) return $cmnt['comment_approved']; else $cmntID = wp_insert_comment($cmnt);  
  657. if (empty($cmntID)) { nxs_addToLogN('E', 'Error', 'Comments', '-=ERROR=-', print_r($cmnt, true)); return; } 
  658.  
  659. if ( 'spam' !== $cmnt['comment_approved'] ) { if ( '0' == $cmnt['comment_approved'] ) wp_notify_moderator($cmntID); $post = get_post($cmnt['comment_post_ID']); 
  660. if ( get_option('comments_notify') && $cmnt['comment_approved'] && ( ! isset( $cmnt['user_id'] ) || $post->post_author != $cmnt['user_id'] ) ) wp_notify_postauthor($cmntID);  
  661. global $wpdb, $dsq_api; 
  662. if (isset($dsq_api) && is_object($post)) { $plugins_url = str_replace( 'social-networks-auto-poster-facebook-twitter-g/', '', plugin_dir_path( __FILE__ )); require_once( $plugins_url.'disqus-comment-system/export.php');  
  663. if (function_exists('dsq_export_wp')) { 
  664. $comments = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_ID = %d", $cmntID) );  
  665. $wxr = nxs_dsq_export_wp($post, $comments); $response = $dsq_api->import_wordpress_comments($wxr, time());  
  666. }} 
  667. }  
  668. return $cmntID; 
  669. }} 
  670.  
  671. //#### Native WP Function that has wp_die in the middle of it ????? 
  672. function nxs_wp_allow_comment($commentdata) { global $wpdb; extract($commentdata, EXTR_SKIP);  
  673. // Simple duplicate check // expected_slashed ($comment_post_ID, $comment_author, $comment_author_email, $comment_content) 
  674. $dupe = "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND comment_parent = '$comment_parent' AND comment_approved != 'trash' AND ( comment_author = '$comment_author' "; 
  675. if ( $comment_author_email ) $dupe .= "OR comment_author_email = '$comment_author_email' "; $dupe .= ") AND comment_content = '$comment_content' LIMIT 1"; 
  676. $dupeID = $wpdb->get_var($dupe); if ( $dupeID ) { do_action( 'comment_duplicate_trigger', $commentdata ); return $dupeID; }  
  677. do_action( 'check_comment_flood', $comment_author_IP, $comment_author_email, $comment_date_gmt ); 
  678. if ( ! empty( $user_id ) ) { $user = get_userdata( $user_id ); $post_author = $wpdb->get_var($wpdb->prepare("SELECT post_author FROM $wpdb->posts WHERE ID = %d LIMIT 1", $comment_post_ID)); } 
  679. if ( isset( $user ) && ( $user_id == $post_author || $user->has_cap( 'moderate_comments' ) ) ) { // The author and the admins get respect. 
  680. $approved = 1; 
  681. } else { // Everyone else's comments will be checked. 
  682. if ( check_comment($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent, $comment_type) ) $approved = 1; else $approved = 0; 
  683. if ( wp_blacklist_check($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent) ) $approved = 'spam'; 
  684. } $approved = apply_filters( 'pre_comment_approved', $approved, $commentdata ); return $approved; 
  685.  
  686. if (!function_exists("ns_get_avatar")) { function ns_get_avatar($avatar, $id_or_email, $size=96, $default='', $alt='') {  
  687. if ( is_object($id_or_email) ) {  
  688. if ($id_or_email->comment_agent=='SNAP' && stripos($id_or_email->comment_author_url, 'facebook.com')!==false) { $fbuID = str_ireplace('@facebook.com', '', $id_or_email->comment_author_email);  
  689. $avatar = "<img alt='{$id_or_email->comment_author}' src='https://graph.facebook.com/v2.3/$fbuID/picture' class='avatar avatar-{$size} photo avatar-default' height='{$size}' width='{$size}' />"; } 
  690. if (stripos($id_or_email->comment_agent, 'SNAP||')!==false && stripos($id_or_email->comment_author_url, 'twitter.com')!==false) { $fbuID = str_ireplace('SNAP||', '', $id_or_email->comment_agent); 
  691. $avatar = "<img alt='{$id_or_email->comment_author}' src='{$fbuID}' class='avatar avatar-{$size} photo avatar-default' height='{$size}' width='{$size}' />";  
  692.  
  693. return $avatar; 
  694. }} 
  695.  
  696. if (!function_exists('nxs_doProcessTags')) { function nxs_doProcessTags($tags) { $tagsA = array(); if (!is_array($tags)) { $tags = explode(', ', $tags);  
  697. foreach ($tags as $tg) $tagsA[] = trim($tg); } else $tagsA = $tags; $tagsA = array_unique($tagsA); $tags = array();  
  698. foreach ($tagsA as $tg) { $tags['tagsA'][] = $tg; $tags['htagsA'][] = "#".trim(str_replace(' ', '', preg_replace('/[^a-zA-Z0-9\p{L}\p{N}\s]/u', '', trim(ucwords(str_ireplace('&', '', str_ireplace('&', '', $tg))))))); }  
  699. $tags['tags'] = implode(', ', $tags['tagsA']); $tags['htags'] = implode(', ', $tags['htagsA']); 
  700. return $tags; 
  701. }}  
  702. if (!function_exists('nxs_doFormatMsg')) { function nxs_doFormatMsg($format, $message, $addURLParams='') { global $nxs_urlLen; $msg = nxs_doSpin($format);// prr($msg); prr($message);// Make "message default" 
  703. $msgDef = array('title'=>'', 'announce'=>'', 'text'=>'', 'url'=>'', 'surl'=>'', 'urlDescr'=>'', 'urlTitle'=>'', 'imageURL' => array(), 'videoCode'=>'', 'videoURL'=>'', 'siteName'=>'', 'tags'=>'', 'cats'=>'', 'authorName'=>'', 'orID'=>''); $message = array_merge($msgDef, $message); 
  704. if (preg_match('/%URL%/', $msg)) { $url = $message['url']; if($addURLParams!='') $url .= (strpos($url, '?')!==false?'&':'?').$addURLParams; $nxs_urlLen = nxs_strLen($url); $msg = str_ireplace("%URL%", $url, $msg);} 
  705. if (preg_match('/%SURL%/', $msg)) {  
  706. if (isset($message['surl']) && $message['surl']!='') $url = $message['surl']; else { $url = $message['url']; if($addURLParams!='') $url .= (strpos($url, '?')!==false?'&':'?').$addURLParams; $url = nxs_mkShortURL($url); }  
  707. $nxs_urlLen = nxs_strLen($url); $msg = str_ireplace("%SURL%", $url, $msg); 
  708. if (preg_match('/%IMG%/', $msg)) { if (isset($message['imgURL']) && is_array($message['imgURL'])) { $imgURL = trim($message['imgURL']['large']); if ($imgURL=='') $imgURL = trim($message['imgURL']['medium']);  
  709. if ($imgURL=='') $imgURL = trim($message['imgURL']['original']); if ($imgURL=='') $imgURL = trim($message['imgURL']['thumb']); 
  710. } elseif (!empty($message['imgURL'])) $imgURL = $message['imgURL']; else $imgURL = ''; $msg = str_ireplace("%IMG%", $imgURL, $msg);  
  711. if (preg_match('/%IMGLARGE%/', $msg)) $msg = str_ireplace("%IMG%", trim($message['imgURL']['large'], $msg));  
  712. if (preg_match('/%IMGMEDIUM%/', $msg)) $msg = str_ireplace("%IMGMEDIUM%", trim($message['imgURL']['medium'], $msg));  
  713. if (preg_match('/%IMGTHUMB%/', $msg)) $msg = str_ireplace("%IMGTHUMB%", trim($message['imgURL']['thumb'], $msg));  
  714. if (preg_match('/%IMGORIGINAL%/', $msg)) $msg = str_ireplace("%IMGORIGINAL%", trim($message['imgURL']['original'], $msg));  
  715.  
  716. if (preg_match('/%ORID%/', $msg)) $msg = str_ireplace("%ORID%", $message['orID'], $msg);  
  717. if (preg_match('/%TITLE%/', $msg)) $msg = str_ireplace("%TITLE%", $message['title'], $msg);  
  718. if (preg_match('/%STITLE%/', $msg)) { $title = substr($message['title'], 0, 115); $msg = str_ireplace("%STITLE%", $title, $msg); }  
  719. if (preg_match('/%AUTHORNAME%/', $msg)) $msg = str_ireplace("%AUTHORNAME%", $message['authorName'], $msg); 
  720. if (preg_match('/%SITENAME%/', $msg)) $msg = str_ireplace("%SITENAME%", $message['siteName'], $msg);  
  721.  
  722. if (preg_match('/%ANNOUNCE%/', $msg)) { $sText = trim($message['announce'])!=''?$message['announce']:nsTrnc($message['description'], 300, " ", "..."); $msg = str_ireplace("%ANNOUNCE%", $sText, $msg); } 
  723. if (preg_match('/%EXCERPT%/', $msg)) { $sText = trim($message['announce'])!=''?$message['announce']:nsTrnc($message['description'], 300, " ", "..."); $msg = str_ireplace("%EXCERPT%", $sText, $msg); } 
  724. if (preg_match('/%RAWEXCERPT%/', $msg)) { $sText = trim($message['announce'])!=''?$message['announce']:nsTrnc($message['description'], 300, " ", "..."); $msg = str_ireplace("%RAWEXCERPT%", $sText, $msg); } 
  725.  
  726. if (preg_match('/%TEXT%/', $msg)) $msg = str_ireplace("%TEXT%", $message['description'], $msg);  
  727. if (preg_match('/%FULLTEXT%/', $msg)) $msg = str_ireplace("%FULLTEXT%", $message['description'], $msg);  
  728. if (preg_match('/%RAWTEXT%/', $msg)) $msg = str_ireplace("%RAWTEXT%", $message['description'], $msg);  
  729.  
  730.  
  731. if (preg_match('/%TAGS%/', $msg)) { $tags = nxs_doProcessTags($message['tags']); $msg = str_ireplace("%TAGS%", $tags['tags'], $msg); } 
  732. if (preg_match('/%HTAGS%/', $msg)) { $tags = nxs_doProcessTags($message['tags']); $msg = str_ireplace("%HTAGS%", $tags['htags'], $msg); } 
  733. if (preg_match('/%CATS%/', $msg)) { $tags = nxs_doProcessTags($message['cats']); $msg = str_ireplace("%CATS%", $tags['cats'], $msg); } 
  734. if (preg_match('/%HCATS%/', $msg)) { $tags = nxs_doProcessTags($message['hcats']); $msg = str_ireplace("%HCATS%", $tags['hcats'], $msg); } 
  735.  
  736. if (preg_match('/%+CF-[a-zA-Z0-9-_]+%/', $msg)) { $msgA = explode('%CF', $msg); $mout = ''; 
  737. foreach ($msgA as $mms) {  
  738. if (substr($mms, 0, 1)=='-' && stripos($mms, '%')!==false) { $mGr = CutFromTo($mms, '-', '%'); $cfItem = $message[$mGr]; $mms = str_ireplace("-".$mGr."%", $cfItem, $mms); } $mout .= $mms;  
  739. } $msg = $mout;  
  740. }  
  741.  
  742.  
  743.  
  744. return trim($msg); 
  745. }} 
  746. //## Common Dialogs 
  747. if (!function_exists('nxs_showImgToUseDlg')) { function nxs_showImgToUseDlg($nt, $ii, $imgToUse, $hide=false) { ?> 
  748. <tr id="altFormatIMG<?php echo $nt.$ii; ?>" style="<?php echo $hide?'display:none;':''; ?>"><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Image(s) to use:', 'social-networks-auto-poster-facebook-twitter-g') ?></th> 
  749. <td><input type="checkbox" class="isAutoImg" <?php if ($imgToUse=='') { ?>checked="checked"<?php } ?> id="isAutoImg-<?php echo $nt; ?><?php echo $ii; ?>" name="<?php echo $nt; ?>[<?php echo $ii; ?>][isAutoImg]" value="A"/> <?php _e('Auto', 'social-networks-auto-poster-facebook-twitter-g'); ?> 
  750. <?php if ($imgToUse!='') { ?> <a onclick="nxs_clPrvImgShow('<?php echo $nt; ?><?php echo $ii; ?>');return false;" href="#"><?php _e('Show all', 'social-networks-auto-poster-facebook-twitter-g'); ?></a><br/>  
  751. <div class="nxs_prevImagesDiv" id="nxs_<?php echo $nt; ?><?php echo $ii; ?>_idivD"><img class="nxs_prevImages" src="<?php echo $imgToUse; ?>"><div style="display:block;" class="nxs_checkIcon"><div class="media-modal-icon"></div></div></div> 
  752. <?php } else { ?><br/><?php } ?> 
  753. <div id="imgPrevList-<?php echo $nt; ?><?php echo $ii; ?>" class="nxs_imgPrevList"></div>  
  754. <input type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][imgToUse]" value="<?php echo $imgToUse ?>" id="imgToUse-<?php echo $nt; ?><?php echo $ii; ?>" />  
  755. </td></tr>  
  756. <?php }} 
  757. if (!function_exists('nxs_showURLToUseDlg')) { function nxs_showURLToUseDlg($nt, $ii, $urlToUse) { ?> 
  758. <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('URL to use:', 'social-networks-auto-poster-facebook-twitter-g') ?></th> 
  759. <td><input type="checkbox" class="isAutoURL" <?php if ($urlToUse=='') { ?>checked="checked"<?php } ?> id="isAutoURL-<?php echo $nt; ?><?php echo $ii; ?>" name="<?php echo $nt; ?>[<?php echo $ii; ?>][isAutoURL]" value="A"/> <?php _e('Auto', 'social-networks-auto-poster-facebook-twitter-g'); ?> - <i><?php _e('Post URL or globally defined URL will be used', 'social-networks-auto-poster-facebook-twitter-g'); ?></i> 
  760.  
  761. <div class="nxs_prevURLDiv" <?php if (trim($urlToUse)=='') { ?> style="display:none;"<?php } ?> id="isAutoURLFld-<?php echo $nt; ?><?php echo $ii; ?>"> 
  762.    <?php _e('URL:', 'social-networks-auto-poster-facebook-twitter-g') ?> <input size="90" type="text" name="<?php echo $nt; ?>[<?php echo $ii; ?>][urlToUse]" value="<?php echo $urlToUse ?>" id="URLToUse-<?php echo $nt; ?><?php echo $ii; ?>" />  
  763. <br/><span><?php _e('This will trigger "Network will decide attachment info". Image and other settings will be ignored.', 'social-networks-auto-poster-facebook-twitter-g') ?></span> 
  764. </div> 
  765.  
  766. </td></tr>  
  767. <?php }} 
  768.  
  769. //## Tests 
  770. function nxs_cURLTestCode($url) {  
  771. $out = 'There is a problem with cURL. You need to contact your server admin or hosting provider. Here is the PHP code to reproduce the problem:<br/><pre style="color:#005800"><?php '."\r\n".' $ch = curl_init(); '."\r\n".' curl_setopt($ch, CURLOPT_URL, "'.$url.'"); '."\r\n".' curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.73 Safari/537.36"); '."\r\n".' curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); '."\r\n".' curl_setopt($ch, CURLOPT_TIMEOUT, 10); '."\r\n".' curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); '."\r\n".' $response = curl_exec($ch); '."\r\n".' $errmsg = curl_error($ch); '."\r\n".' $cInfo = curl_getinfo($ch); '."\r\n".' curl_close($ch); '."\r\n".' print_r($errmsg); '."\r\n".' print_r($cInfo); '."\r\n".' print_r($response); '."\r\n".'?></pre>'; return $out;  
  772. function nxs_cURLTest($url, $msg, $testText) { echo "<br/>--== Test Requested ... ".$url."<br/>"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url);  
  773. curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.39 Safari/537.36");  
  774. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); 
  775. $response = curl_exec($ch); $errmsg = curl_error($ch); $cInfo = curl_getinfo($ch); curl_close($ch); echo "Testing ... ".$url." - ".$cInfo['url']."<br/>"; 
  776. if (stripos($response, $testText)!==false) echo "....".$msg." - OK<br/>"; else { echo "....<b style='color:red;'>".$msg." - Problem</b><br/>"; prr($response); prr($errmsg); prr($cInfo); echo nxs_cURLTestCode($url); } 
  777.  
  778. //## Reposter 
  779. function nxs_adjRpst($optionsii, $pval) { if (empty($optionsii['rpstDays'])) $optionsii['rpstDays'] = 0; if (empty($optionsii['rpstHrs'])) $optionsii['rpstHrs'] = 0; if (empty($optionsii['rpstMins'])) $optionsii['rpstMins'] = 0; 
  780.  
  781. $rpstEvrySecEx = $optionsii['rpstDays']*86400+$optionsii['rpstHrs']*3600+$optionsii['rpstMins']*60; $isRpstWasOn = isset($optionsii['rpstOn']) && $optionsii['rpstOn']=='1'; 
  782.  
  783. if (isset($pval['rpstOn'])) $optionsii['rpstOn'] = $pval['rpstOn']; else $optionsii['rpstOn'] = 0; 
  784.  
  785. if (isset($pval['rpstDays'])) $optionsii['rpstDays'] = trim($pval['rpstDays']);  
  786. if (isset($pval['rpstHrs'])) $optionsii['rpstHrs'] = trim($pval['rpstHrs']); if ((int)$optionsii['rpstHrs']>23) $optionsii['rpstHrs'] = 23; 
  787. if (isset($pval['rpstMins'])) $optionsii['rpstMins'] = trim($pval['rpstMins']); if ((int)$optionsii['rpstMins']>59) $optionsii['rpstMins'] = 59;  
  788. if (isset($pval['rpstRndMins'])) $optionsii['rpstRndMins'] = trim($pval['rpstRndMins']);  
  789. if (isset($pval['rpstPostIncl'])) $optionsii['rpstPostIncl'] = trim($pval['rpstPostIncl']);  
  790.  
  791. if (isset($pval['rpstStop'])) $optionsii['rpstStop'] = trim($pval['rpstStop']); else $optionsii['rpstStop'] = 'O';  
  792.  
  793.  
  794. $rpstEvrySecNew = $optionsii['rpstDays']*86400+$optionsii['rpstHrs']*3600+$optionsii['rpstMins']*60; 
  795. $rpstRNDSecs = isset($optionsii['rpstRndMins'])?$optionsii['rpstRndMins']*60:0; if ($rpstRNDSecs>$rpstEvrySecNew) $optionsii['rpstRndMins'] = 0; 
  796.  
  797. if ($rpstEvrySecNew!=$rpstEvrySecEx || (!$isRpstWasOn && $optionsii['rpstOn']=='1')) { $currTime = time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); $optionsii['rpstNxTime'] = $currTime + $rpstEvrySecNew; } 
  798. if (isset($pval['rpstType'])) $optionsii['rpstType'] = trim($pval['rpstType']);  
  799. if (isset($pval['rpstTimeType'])) $optionsii['rpstTimeType'] = trim($pval['rpstTimeType']);  
  800. if (isset($pval['rpstFromTime'])) $optionsii['rpstFromTime'] = trim($pval['rpstFromTime']);  
  801. if (isset($pval['rpstToTime'])) $optionsii['rpstToTime'] = trim($pval['rpstToTime']);  
  802. if (isset($pval['rpstOLDays'])) $optionsii['rpstOLDays'] = trim($pval['rpstOLDays']);  
  803. if (isset($pval['rpstNWDays'])) $optionsii['rpstNWDays'] = trim($pval['rpstNWDays']);  
  804. if (isset($pval['rpstOnlyPUP'])) $optionsii['rpstOnlyPUP'] = trim($pval['rpstOnlyPUP']); else $optionsii['rpstOnlyPUP'] = 0;  
  805.  
  806. if (isset($pval['nxsCPTSeld'])) $optionsii['nxsCPTSeld'] = serialize($pval['nxsCPTSeld']);  
  807.  
  808. if (isset($pval['fltrsOn'])) $optionsii['fltrsOn'] = trim($pval['fltrsOn']); else $optionsii['fltrsOn'] = 0;  
  809.  
  810. if (isset($pval['tagsSel'])) { $optionsii['tagsSel'] = trim($pval['tagsSel']); $tagsSelX = array(); $tggsSel = explode(', ', $optionsii['tagsSel']);  
  811. foreach ($tggsSel as $tggg) { $tggg = trim($tggg); $tagsSelX[] = $tggg;  
  812. if (stripos($tggg, '|')!==false) { $tgArr = explode('|', $tggg); $taxonomy = $tgArr[0]; $tgggT = $tgArr[1]; } else { $taxonomy = 'post_tag'; $tgggT = $tggg; }  
  813. $tgArr = get_term_by( 'slug', $tgggT, $taxonomy, ARRAY_A); if (is_array($tgArr)) $tagsSelX[] = $tgArr['term_id']; 
  814. } $optionsii['tagsSelX'] = implode(', ', $tagsSelX);  
  815. if (isset($pval['custTaxSel'])) $optionsii['custTaxSel'] = trim($pval['custTaxSel']);  
  816.  
  817. if (isset($pval['rpstBtwHrsType'])) $optionsii['rpstBtwHrsType'] = trim($pval['rpstBtwHrsType']);  
  818. if (isset($pval['rpstBtwHrsT'])) $optionsii['rpstBtwHrsT'] = trim($pval['rpstBtwHrsT']); if (isset($optionsii['rpstBtwHrsT'])&&(int)$optionsii['rpstBtwHrsT']>23) $optionsii['rpstBtwHrsT'] = 23;  
  819. if (isset($pval['rpstBtwHrsF'])) $optionsii['rpstBtwHrsF'] = trim($pval['rpstBtwHrsF']); if (isset($optionsii['rpstBtwHrsF'])&&(int)$optionsii['rpstBtwHrsF']>23) $optionsii['rpstBtwHrsF'] = 23;  
  820. if (isset($pval['rpstBtwDays'])) $optionsii['rpstBtwDays'] = $pval['rpstBtwDays']; else $optionsii['rpstBtwDays'] = array();  
  821. return $optionsii; 
  822.  
  823. function nxs_showCatTagsCTFilters($nt, $ii, $options) { global $nxs_snapAvNts, $nxs_plurl;  
  824. if (!isset($options['tagsSel'])) $options['tagsSel'] = ''; if (!isset($options['custTaxSel'])) $options['custTaxSel'] = ''; 
  825. ?> <div class="nxs_tls_cpt"> 
  826.  
  827. <?php _e('Filter Autoposting by', 'social-networks-auto-poster-facebook-twitter-g'); ?></div> 
  828. <div class="nxs_tls_bd"> 
  829. <div style="width:100%;"><strong><?php _e('Categories', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> 
  830. <input value="0" id="catSelA<?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"; ?> /> <?php _e('All', 'social-networks-auto-poster-facebook-twitter-g'); ?> 
  831. <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;"><?php _e('Selected', 'social-networks-auto-poster-facebook-twitter-g'); ?><?php if ($options['catSelEd']!='') echo "[".(substr_count($options['catSelEd'], ", ")+1)."]"; ?></a>  
  832. <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']; ?>" /> 
  833. <br/><i><?php _e('Only selected categories will be autoposted to this account', 'social-networks-auto-poster-facebook-twitter-g'); ?></i></div>  
  834. <br/> 
  835. <div style="width:100%;"><strong><?php _e('Tags and Custom Taxonomies', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> 
  836. <input name="<?php echo $nt; ?>[<?php echo $ii; ?>][tagsSel]" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['tagsSel'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />  
  837. <br/><i><?php _e('Only posts with those tags assigned will be autoposted to this account, you can include custom taxonomy tags in taxonomy_slug|tag format.', 'social-networks-auto-poster-facebook-twitter-g'); ?></i></div>  
  838. <br/> 
  839. </div> <?php 
  840.  
  841.  
  842. function nxs_showRepostSettings($nt, $ii, $options) { global $nxs_snapAvNts, $nxs_plurl;  
  843. if (empty($options['rpstPostIncl'])) $options['rpstPostIncl'] = 0; if (empty($options['rpstPostIncl'])) $options['rpstLastShTime'] = ''; if (empty($options['rpstNxTime'])) $options['rpstNxTime'] = ''; 
  844. if (empty($options['rpstLastPostID'])) $options['rpstLastPostID'] = ''; 
  845.  
  846. ?> 
  847. <div class="nxs_tls_cpt"> 
  848. <?php _e('Auto Reposting', 'social-networks-auto-poster-facebook-twitter-g'); ?>  <span class="nxsInstrSpan"><a href="http://www.nextscripts.com/snap-features/old-posts-auto-reposting/" target="_blank"><?php _e('[Instructions]', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>    <b style="color: darkred;">Please note:</b> This feature is depreciated, <a href="http://www.nextscripts.com/blog/old-posts-reposting-no-longer-supported/" target="_blank">no longer supported</a> and will be replaced with something much better in the upcoming ver 3.5 </span> 
  849. </div> 
  850.  
  851. <?php $cr = get_option('NXS_cronCheck'); if (!empty($cr) && is_array($cr) && isset($cr['status']) && $cr['status']=='0') {  
  852. global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $gOptions = $plgn_NS_SNAutoPoster->nxs_options;  
  853. if (isset($gOptions['forceBrokenCron']) && $gOptions['forceBrokenCron'] =='1') { ?>  
  854. <span style="color: red"> <?php _e('Your WP Cron is not working correctly. Auto Reposting service is active by force. <br/> This might cause problems. Please see the test results and recommendations', 'social-networks-auto-poster-facebook-twitter-g'); ?> 
  855.  - <a target="_blank" href="<?php global $nxs_snapThisPageUrl; echo $nxs_snapThisPageUrl; ?>&do=crtest">WP Cron Test Results</a></span> 
  856. <?php } else { ?> <span style="color: red"> <?php _e('Auto Reposting service is Disabled. Your WP Cron is not working correctly. Please see the test results and recommendations', 'social-networks-auto-poster-facebook-twitter-g'); ?> 
  857.  - <a target="_blank" href="<?php global $nxs_snapThisPageUrl; echo $nxs_snapThisPageUrl; ?>&do=crtest">WP Cron Test Results</a></span> 
  858. <?php return; } } ?> 
  859.  
  860.  
  861. <div class="nxs_tls_bd"> 
  862. <div class="nxs_tls_sbInfo"><?php _e('Plugin could autorepost existing posts', 'social-networks-auto-poster-facebook-twitter-g'); ?></div> 
  863. <input value="1" id="riC<?php echo $ii; ?>" <?php if (isset($options['rpstOn']) && trim($options['rpstOn'])=='1') echo "checked"; ?> type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstOn]"/>  
  864. <b><?php _e('Repost existing posts every', 'social-networks-auto-poster-facebook-twitter-g'); ?> </b> 
  865.  
  866. <input type="text" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstDays]" style="width: 35px;" value="<?php echo isset($options['rpstDays'])?$options['rpstDays']:'0'; ?>" /> <?php _e('Days', 'social-networks-auto-poster-facebook-twitter-g'); ?>   
  867. <input type="text" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstHrs]" style="width: 35px;" value="<?php echo isset($options['rpstHrs'])?$options['rpstHrs']:'2'; ?>" /> <?php _e('Hours', 'social-networks-auto-poster-facebook-twitter-g'); ?>   
  868. <input type="text" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstMins]" style="width: 35px;" value="<?php echo isset($options['rpstMins'])?$options['rpstMins']:'0'; ?>" /> <?php _e('Minutes', 'social-networks-auto-poster-facebook-twitter-g'); ?>  
  869. <div style="padding-left:10px;padding-top:10px;line-height:30px;">  
  870.  
  871. <b><?php _e('Randomize posting time ±', 'social-networks-auto-poster-facebook-twitter-g'); ?> </b> 
  872. <input type="text" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstRndMins]" style="width: 35px;" value="<?php echo isset($options['rpstRndMins'])?$options['rpstRndMins']:'15'; ?>" onmouseout="hidePopShAtt('RPST1');" onmouseover="showPopShAtt('RPST1', event);" /> <?php _e('Minutes', 'social-networks-auto-poster-facebook-twitter-g'); ?> 
  873. <br/>  
  874. <input value="1" id="riOC<?php echo $ii; ?>" <?php if (isset($options['rpstOnlyPUP']) && trim($options['rpstOnlyPUP'])=='1') echo "checked"; ?> type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstOnlyPUP]"/>  
  875. <b><?php _e('Repost ONLY previously unautoposted posts', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> 
  876. <br/> 
  877. <?php $args=array('public'=>true, '_builtin'=>false); $output = 'names'; $operator = 'and'; $post_types = array();  
  878. if (function_exists('get_post_types')) $post_types=get_post_types($args, $output, $operator);  
  879. if (!empty($post_types) && is_array($post_types)) { ?> 
  880. <b><?php _e('Repost: (Choose Posts, Pages, Custom Post Types)', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> 
  881. <?php $post_typesIncl = array('post'=>'post', 'page'=>'page'); $post_types = array_merge($post_typesIncl, $post_types); if ($options['nxsCPTSeld']=='a:1:{i:0;s:1:"0";}') $options['nxsCPTSeld'] = ''; 
  882. if (!empty($options['nxsCPTSeld'])) $nxsCPTSeld = unserialize($options['nxsCPTSeld']); else $nxsCPTSeld = array('post');  
  883. ?> <div class="nxs_box_inside" style="padding: 0px;" > <div class="itemDiv" style="padding: 0px;"> <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']);  
  884. foreach ($post_types as $cptID=>$cptName) { if (in_array($cptID, $nxsCPTSeld)) $dCh = ' checked="checked" '; else $dCh = ""; 
  885. ?><input type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][nxsCPTSeld][]" value="<?php echo esc_attr($cptID); ?>"<?php echo $dCh ?>> <?php echo $cptName ?><br/> <?php 
  886. ?></div></div> </div> </div>  
  887. <?php } ?> 
  888. <?php if (function_exists('nxs_doSMAS41')) nxs_doSMAS41($nt, $ii, $options); ?>  
  889. <b><?php _e('Get posts', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> 
  890. <select id="riS<?php echo $nt; ?><?php echo $ii; ?>" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstType]" onchange="nxs_actDeActTurnOff(jQuery(this).attr('id'));"><?php if (function_exists('nxs_doSMAS42')) nxs_doSMAS42($options); ?>  
  891. <option value="2" <?php if (isset($options['rpstType']) && $options['rpstType']=='2') echo 'selected="selected"' ?>>One By One - Old to New</option><option value="3" <?php if (isset($options['rpstType']) && $options['rpstType']=='3') echo 'selected="selected"' ?>>One By One - New to Old</option> 
  892. </select>  
  893. <br/>  
  894. <div style="padding-left: 15px;"> 
  895. <input type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstTimeType]" value="D" <?php if (isset($options['rpstTimeType']) && $options['rpstTimeType']=='D') echo 'checked="checked"'; ?> /> 
  896.  
  897. <?php _e('from', 'social-networks-auto-poster-facebook-twitter-g'); ?> <input type="text" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstFromTime]" style="width: 75px;" value="<?php echo isset($options['rpstFromTime'])?$options['rpstFromTime']:''; ?>" />   
  898. <?php _e('to', 'social-networks-auto-poster-facebook-twitter-g'); ?> <input type="text" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstToTime]" style="width: 75px;" value="<?php echo isset($options['rpstToTime'])?$options['rpstToTime']:''; ?>" /> 
  899. <br/> 
  900. <input type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstTimeType]" value="A" <?php if (!isset($options['rpstTimeType']) || $options['rpstTimeType']=='A') echo 'checked="checked"'; ?> /> 
  901. <?php _e('Older then', 'social-networks-auto-poster-facebook-twitter-g'); ?> <input type="text" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstOLDays]" style="width: 35px;" value="<?php echo isset($options['rpstOLDays'])?$options['rpstOLDays']:'30'; ?>" /> <?php _e('Days', 'social-networks-auto-poster-facebook-twitter-g'); ?>  
  902. <?php _e('and Newer then', 'social-networks-auto-poster-facebook-twitter-g'); ?> <input type="text" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstNWDays]" style="width: 35px;" value="<?php echo isset($options['rpstNWDays'])?$options['rpstNWDays']:'365'; ?>" /> <?php _e('Days', 'social-networks-auto-poster-facebook-twitter-g'); ?>  
  903. </div> 
  904. <div id="riS<?php echo $nt; ?><?php echo $ii; ?>xd" style="padding-left: 0px;<?php if (isset($options['rpstType']) && $options['rpstType']=='1') echo "display:none;"; ?>"><b><?php _e('When finished', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</b>  
  905. <input type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstStop]" value="O" <?php if (empty($options['rpstStop']) || (isset($options['rpstStop']) && trim($options['rpstStop'])=='O')) echo "checked"; ?> /> <?php _e('Auto Turn Reposting Off', 'social-networks-auto-poster-facebook-twitter-g') ?> 
  906.     
  907. <input type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstStop]" value="W" <?php if (isset($options['rpstStop']) && trim($options['rpstStop'])=='W') echo 'checked="cheXcked"'; ?> /> <?php _e('Wait for new posts', 'social-networks-auto-poster-facebook-twitter-g') ?> 
  908.     
  909. <input type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstStop]" value="R" <?php if (isset($options['rpstStop']) && trim($options['rpstStop'])=='R') echo 'checked="cheTcked"'; ?> /> <?php _e('Loop it. Reset and Start from the begining', 'social-networks-auto-poster-facebook-twitter-g'); ?> 
  910. </div> 
  911.  
  912. <hr/> 
  913. <strong style="font-size: 12px; margin: 10px; margin-left: 1px;">New posts will be set by default to:</strong> 
  914. <select name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]"><option <?php echo !empty($options['rpstPostIncl'])?'selected="selected"':''; ?> value="nxsi<?php echo $ii.$nt; ?>">Enabled for Repost</option> 
  915. <option <?php echo empty($options['rpstPostIncl'])?'selected="selected"':''; ?> value="0">Disabled for Repost</option></select><br/> 
  916. <div style="padding-left: 15px;"> <img id="nxsLoadingImg<?php echo $nt; ?><?php echo $ii; ?>" style="display: none;" src='<?php echo $nxs_plurl; ?>img/ajax-loader-sm.gif' />  
  917.  
  918. <?php  
  919. global $nxs_rpst_older, $nxs_rpst_newer, $nxs_rpst_lastID, $nxs_rpst_lastTime, $nxs_rpst_type, $nxs_rpst_code, $nxs_rpst_NT; $ntOpts = $options;  
  920. $currTime = time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); 
  921. if (!empty($ntOpts['nxsCPTSeld'])) $tpArray = maybe_unserialize($ntOpts['nxsCPTSeld']); else $tpArray = 'post'; 
  922. if ($ntOpts['rpstType']=='1') $args = array ( 'orderby' => 'rand', 'posts_per_page' => '1', 'post_type' => $tpArray, 'ignore_sticky_posts' => 1, 'post_status' => 'publish', 'suppress_filters' => false );  
  923. if ($ntOpts['rpstType']=='2') $args = array ( 'posts_per_page' => '1', 'orderby' => 'date ID', 'order'=>'ASC', 'post_type' => $tpArray, 'post_status' => 'publish', 'suppress_filters' => false ); 
  924. if ($ntOpts['rpstType']=='3') $args = array ( 'posts_per_page' => '1', 'orderby' => 'date ID', 'order'=>'DESC', 'post_type' => $tpArray, 'post_status' => 'publish', 'suppress_filters' => false );  
  925. $rpstToTime = strtotime($ntOpts['rpstToTime']); if ($currTime < $rpstToTime) $rpstToTime = $currTime; 
  926. $rpstFromTime = strtotime($ntOpts['rpstFromTime']); if ($currTime < $rpstFromTime) $rpstFromTime = $currTime; 
  927. if ($ntOpts['rpstTimeType']=='D') { $nxs_rpst_older = ceil(abs($currTime - $rpstToTime) / 86400); $nxs_rpst_newer = ceil(abs($currTime - $rpstFromTime) / 86400);  
  928. } else { $nxs_rpst_older = $ntOpts['rpstOLDays']; $nxs_rpst_newer = $ntOpts['rpstNWDays']; } $ggg = $ntOpts['rpstType']=='1'?'Random':($ntOpts['rpstType']=='3'?'New to Old':'Old to New'); 
  929. if ($nxs_rpst_newer>5000) $nxs_rpst_newer = 5000; if ($nxs_rpst_newer<$nxs_rpst_older) $nxs_rpst_older = 0;  
  930. $nxs_rpst_code = 'nxsi'.$ii.$nt; $nxs_rpst_NT = strtoupper($nt); 
  931. add_filter( 'posts_join' , 'nxs_custom_posts_join'); 
  932. if (isset($ntOpts['rpstOnlyPUP']) && trim($ntOpts['rpstOnlyPUP'])=='1') { add_filter( 'posts_where', 'nxs_filter_where_only' ); } 
  933. add_filter( 'posts_where', 'nxs_filter_where' ); $query = new WP_Query( $args ); remove_filter( 'posts_where', 'filter_where' );  
  934. echo "Total posts included in reposting: ".$query->found_posts;  
  935. ?><br/> 
  936.  
  937. <?php _e('Set All Existing Posts to: ', 'social-networks-auto-poster-facebook-twitter-g'); ?> 
  938.   <span class="nxsInstrSpan"><a href="#" onclick="nxs_setRpstAll('<?php echo $nt; ?>', '1', '<?php echo $ii; ?>'); return false;"><?php _e('[Enabled for Repost]', 'social-networks-auto-poster-facebook-twitter-g'); ?></a> </span> 
  939.   <span class="nxsInstrSpan"><a href="#" onclick="nxs_setRpstAll('<?php echo $nt; ?>', '0', '<?php echo $ii; ?>'); return false;"><?php _e('[Disabled for Repost]', 'social-networks-auto-poster-facebook-twitter-g'); ?></a> </span>  
  940.   <span class="nxsInstrSpan"><a href="#" onclick="nxs_setRpstAll('<?php echo $nt; ?>', '2', '<?php echo $ii; ?>'); return false;"><?php _e('[Enabled/Disabled for Repost according to Categories/Tags/Taxonomies filters]', 'social-networks-auto-poster-facebook-twitter-g'); ?></a> </span>  
  941.  
  942. </div><hr/> 
  943. <b><?php _e('Last post', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> (ID: <?php echo !empty($options['rpstLastPostID'])?$options['rpstLastPostID']:''; ?>) <b><?php _e('was re-posted on:', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> <?php echo $options['rpstLastShTime']>0?date_i18n('Y-m-d H:i', $options['rpstLastShTime']):'Never'; ?> 
  944.   <b><?php _e('Next post will be ~', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> <?php echo $options['rpstNxTime']>0?date_i18n('Y-m-d H:i', $options['rpstNxTime']):'Never'; ?> <== 
  945.   <span class="nxsInstrSpan"><a href="#" onclick="nxs_setRpstAll('<?php echo $nt; ?>', 'X', '<?php echo $ii; ?>'); return false;"><?php _e('[Reset]', 'social-networks-auto-poster-facebook-twitter-g'); ?></a> </span> 
  946. <br/> 
  947. <b><?php _e('Set "Last re-posted post ID" to:', 'social-networks-auto-poster-facebook-twitter-g'); ?> <input type="text" id="<?php echo $nt; ?><?php echo $ii; ?>SetLPID" style="width: 65px;" value="<?php echo $options['rpstLastPostID']; ?>" /> 
  948.   <span class="nxsInstrSpan"><a href="#" onclick="nxs_setRpstAll('<?php echo $nt; ?>', 'L', '<?php echo $ii; ?>'); return false;"><?php _e('[Set]', 'social-networks-auto-poster-facebook-twitter-g'); ?></a> </span></b> 
  949. </div>  
  950. </div>  
  951. <?php  
  952. function nxs_custom_posts_join($join) { global $wpdb; $join .= " LEFT JOIN $wpdb->postmeta ON $wpdb->posts.ID = $wpdb->postmeta.post_id "; return $join;} 
  953. function nxs_filter_where_only( $where = '' ) { global $wpdb; $where .= " AND ($wpdb->postmeta.meta_key = 'snap_isAutoPosted' AND $wpdb->postmeta.meta_value = '1') "; return $where; } 
  954. function nxs_filter_where( $where = '' ) { global $wpdb, $nxs_rpst_older, $nxs_rpst_newer, $nxs_rpst_lastID, $nxs_rpst_lastTime, $nxs_rpst_type, $nxs_rpst_typeONLY, $nxs_rpst_code, $nxs_rpst_NT;  
  955. $where .= " AND post_date > '" . date_i18n('Y-m-d', strtotime('-'.$nxs_rpst_newer.' days')) . " 00:00:00'" . " AND post_date < '" . date_i18n('Y-m-d', strtotime('-'.$nxs_rpst_older.' days')) . " 23:59:59'";  
  956. $where .= " AND ($wpdb->postmeta.meta_key = 'snap".$nxs_rpst_NT."' AND $wpdb->postmeta.meta_value LIKE '%".$nxs_rpst_code."%') "; 
  957. if ($nxs_rpst_type=='2' && $nxs_rpst_lastID!='') $where .= " AND ( (post_date = '".$nxs_rpst_lastTime."' && ID > ".$nxs_rpst_lastID." ) || post_date > '".$nxs_rpst_lastTime."' )"; 
  958. if ($nxs_rpst_type=='3' && $nxs_rpst_lastID!='') $where .= " AND ( (post_date = '".$nxs_rpst_lastTime."' && ID < ".$nxs_rpst_lastID." ) || post_date < '".$nxs_rpst_lastTime."' )"; 
  959. if ($nxs_rpst_typeONLY) $where .= " AND ($wpdb->postmeta.meta_key = 'snap_isAutoPosted' AND $wpdb->postmeta.meta_value = '1') "; 
  960. return $where;  
  961.  
  962. function nxs_rePoster() { global $nxs_snapAvNts, $plgn_NS_SNAutoPoster, $nxs_rpst_older, $nxs_rpst_newer, $nxs_rpst_lastID, $nxs_rpst_lastTime, $nxs_rpst_type, $nxs_rpst_code, $nxs_rpst_NT;  
  963. if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options; $rpstBtwHrsF = 0; $rpstBtwHrsT = 0; 
  964. $currTime = time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); $hasChanged = false;  
  965. // if (stripos($_SERVER["REQUEST_URI"], 'wp-cron.php')!==false) nxs_addToLogN('A', 'NXSPoster - Cron', $logNT, '-=Time=- '.$ret. "ERR: ".$currTime, $extInfo); 
  966. if (stripos($_SERVER["REQUEST_URI"], 'wp-cron.php')===false) return false; $warn = true; 
  967.  
  968. foreach ($nxs_snapAvNts as $avNt) { 
  969. if (isset($options[$avNt['lcode']]) && is_array($options[$avNt['lcode']]) && count($options[$avNt['lcode']])>0) {  
  970. foreach ($options[$avNt['lcode']] as $ii=>$ntOpts) { $logNT = '<span style="color:#800000">'.$avNt['name'].'</span> - '.(isset($ntOpts['nName'])?$ntOpts['nName']:'');  
  971. if (isset($ntOpts['rpstOn']) && $ntOpts['rpstOn']=='1') {  
  972. //## Calculate Times 
  973. $lastTime = (isset($ntOpts['rpstLastShTime']) && (int)$ntOpts['rpstLastShTime']>0 )?$ntOpts['rpstLastShTime']:$currTime; 
  974. $rpstEvrySec = $ntOpts['rpstDays']*86400+$ntOpts['rpstHrs']*3600+$ntOpts['rpstMins']*60; $rndSec = $ntOpts['rpstRndMins']*60; 
  975. $nxTime = (isset($ntOpts['rpstNxTime']) && (int)$ntOpts['rpstNxTime']>0)?$ntOpts['rpstNxTime']:$currTime+$rpstEvrySec;  
  976. //## First time? Set the options and get out.  
  977. if (empty($ntOpts['rpstLastShTime'])) { $ntOpts['rpstLastShTime'] = $currTime; $ntOpts['rpstNxTime'] = $lastTime + $rpstEvrySec + rand(0-$rndSec, $rndSec);  
  978. $options[$avNt['lcode']][$ii] = $ntOpts; update_option($plgn_NS_SNAutoPoster->dbOptionsName, $options); $plgn_NS_SNAutoPoster->nxs_options = $options;  
  979. nxs_addToLogN('S', 'RE-Poster', $logNT, 'Initialization - First post will be: '.date_i18n('Y-m-d H:i:s', $ntOpts['rpstNxTime']), $extInfo); continue;  
  980. //## Is it time to post? 
  981. if ($nxTime < $currTime) { $times = "Requested Time: ".date_i18n('Y-m-d H:i:s', $nxTime)." | Current Time:".date_i18n('Y-m-d H:i:s', $currTime)." | ";  
  982. //## Check if WP Cron is healthy  
  983. if ($warn) { $cr = get_option('NXS_cronCheck'); $warn = false; if (!empty($cr) && is_array($cr) && isset($cr['status']) && $cr['status']=='0') { global $nxs_snapThisPageUrl;  
  984. if (isset($options['forceBrokenCron']) && $options['forceBrokenCron'] =='1')  
  985. nxs_addToLogN('W', 'Re-Poster is active by force. This could cause problems.', $logNT, 'Please see ', '<a target="_blank" href="'.$nxs_snapThisPageUrl.'&do=crtest">WP Cron Test Results</a>|'.$times);  
  986. else { nxs_addToLogN('W', 'Re-Poster is Disabled', $logNT, 'Please see ', '<a target="_blank" href="'.$nxs_snapThisPageUrl.'&do=crtest">WP Cron Test Results</a>|'.$times); return; } 
  987. }}  
  988.  
  989. if (!isset($ntOpts['rpstNxTime']) || (int)$ntOpts['rpstNxTime']<1) $ntOpts['rpstNxTime'] = 0; //prr($ntOpts);  
  990. //## Check if Day or Hour is excluded 
  991. if (isset($ntOpts['rpstBtwHrsType']) && $ntOpts['rpstBtwHrsType']=='D') {  
  992. //## Check Days 
  993. if (isset($ntOpts['rpstBtwDays']) && count($ntOpts['rpstBtwDays'])>0 ) $rpstBtwDays = $ntOpts['rpstBtwDays']; else $rpstBtwDays = array();  
  994. if (is_array($rpstBtwDays) && count($rpstBtwDays)>0) { $currDay = (int)date_i18n('w'); if (!(in_array($currDay, $rpstBtwDays))) { // echo "D :( "; 
  995. nxs_addToLogN('S', 'RE-Poster', $logNT, 'Skipped - Excluded Day - '.$currDay, $extInfo); continue;  
  996. }} 
  997. //## Check Hours 
  998. if (isset($ntOpts['rpstBtwHrsF']) && (int)$ntOpts['rpstBtwHrsF']>0) $rpstBtwHrsF = (int)$ntOpts['rpstBtwHrsF']; else $rpstBtwHrsF = 0; 
  999. if (isset($ntOpts['rpstBtwHrsT']) && (int)$ntOpts['rpstBtwHrsT']>0) $rpstBtwHrsT = (int)$ntOpts['rpstBtwHrsT']; 
  1000. if ($rpstBtwHrsT>0) { $currHour = (int)date_i18n('H', $currTime); //echo "H ".$currHour." ?"; 
  1001. if ( !( ($rpstBtwHrsF<$rpstBtwHrsT && $currHour<$rpstBtwHrsT && $currHour>=$rpstBtwHrsF) || ($rpstBtwHrsF>$rpstBtwHrsT && $currHour<$rpstBtwHrsF && $currHour>=$rpstBtwHrsT) )) { //echo "H :( "; 
  1002. nxs_addToLogN('S', 'RE-Poster', $logNT, 'Skipped - Excluded Hour - '.$currHour, $extInfo); continue;  
  1003. }} 
  1004. //## Do Post  
  1005. $hasChanged = true; $nxs_rpst_type = $ntOpts['rpstType']; 
  1006. $nxs_rpst_lastID = (isset($ntOpts['rpstLastPostID']) && (int)$ntOpts['rpstLastPostID']>0)?$ntOpts['rpstLastPostID']:($ntOpts['rpstType']=='3'?'90000000':'0'); 
  1007. $nxs_rpst_lastTime = (!empty($ntOpts['rpstLastPostTime']) && $ntOpts['rpstLastPostTime']!='2050-12-12' && $ntOpts['rpstLastPostTime']!='1975-01-01')?$ntOpts['rpstLastPostTime']:($ntOpts['rpstType']=='3'?'2050-12-12':'1975-01-01'); 
  1008. if (!empty($ntOpts['nxsCPTSeld'])) $tpArray = maybe_unserialize($ntOpts['nxsCPTSeld']); else $tpArray = 'post'; 
  1009. //nxs_addToLogN('S', 'pTypes', $logNT, print_r($tpArray, true), $extInfo); // $tpArray = array('post', 'location'); 
  1010. if ($ntOpts['rpstType']=='1') $args = array ( 'orderby' => 'rand', 'posts_per_page' => '1', 'post_type' => $tpArray, 'ignore_sticky_posts' => 1, 'post_status' => 'publish', 'suppress_filters' => false );  
  1011. if ($ntOpts['rpstType']=='2') $args = array ( 'posts_per_page' => '1', 'orderby' => 'date ID', 'order'=>'ASC', 'post_type' => $tpArray, 'post_status' => 'publish', 'suppress_filters' => false ); 
  1012. if ($ntOpts['rpstType']=='3') $args = array ( 'posts_per_page' => '1', 'orderby' => 'date ID', 'order'=>'DESC', 'post_type' => $tpArray, 'post_status' => 'publish', 'suppress_filters' => false );  
  1013. //## Get Post for Reposting 
  1014. // nxs_addToLogN('S', 'pTypes- ARG', $logNT, print_r($args, true), $extInfo); 
  1015. $rpstToTime = strtotime($ntOpts['rpstToTime']); if ($currTime < $rpstToTime) $rpstToTime = $currTime; $rpstFromTime = strtotime($ntOpts['rpstFromTime']); if ($currTime < $rpstFromTime) $rpstFromTime = $currTime; 
  1016. if ($ntOpts['rpstTimeType']=='D') { $nxs_rpst_older = ceil(abs($currTime - $rpstToTime) / 86400);  
  1017. $nxs_rpst_newer = ceil(abs($currTime - $rpstFromTime) / 86400);  
  1018. } else { $nxs_rpst_older = $ntOpts['rpstOLDays']; $nxs_rpst_newer = $ntOpts['rpstNWDays']; } $ggg = $ntOpts['rpstType']=='1'?'Random':($ntOpts['rpstType']=='3'?'New to Old':'Old to New'); 
  1019. if ($nxs_rpst_newer>5000) $nxs_rpst_newer = 5000; if ($nxs_rpst_newer<$nxs_rpst_older) $nxs_rpst_older = 0; 
  1020. $nxs_rpst_code = 'nxsi'.$ii.$avNt['lcode']; $nxs_rpst_NT = strtoupper($avNt['lcode']); 
  1021. add_filter( 'posts_join' , 'nxs_custom_posts_join'); 
  1022. if (isset($ntOpts['rpstOnlyPUP']) && trim($ntOpts['rpstOnlyPUP'])=='1') { add_filter( 'posts_where', 'nxs_filter_where_only' ); } 
  1023. add_filter( 'posts_where', 'nxs_filter_where' ); $query = new WP_Query( $args ); remove_filter( 'posts_where', 'filter_where' ); // $extInfo = print_r($query, true);  
  1024.  
  1025. $rpstLastPostID = $query->posts[0]->ID; $rpstLastPostTime = $query->posts[0]->post_date; $ntOpts['rpstLastPostTime'] = ($rpstLastPostTime!='')?$rpstLastPostTime:($ntOpts['rpstType']=='3'?'1985-01-01':'2050-12-12'); 
  1026. $extInfo = " | Reposting (<b>".$ggg."</b>) POST ID:".$rpstLastPostID. " | Total posts included in reposting: ".$query->found_posts." | Prev Post ID:".$nxs_rpst_lastID ." | ".($options['extDebug']=='1'?"|Query: ".print_r($query->request, true):''); 
  1027.  
  1028. //echo "<br/>\r\n".$rpstEvrySec."<br/>\r\n"; 
  1029. $ntOpts['rpstLastShTime'] = $currTime; $rndTime = rand(0-$rndSec, $rndSec); $ntOpts['rpstNxTime'] = $lastTime + $rpstEvrySec*2 + $rndTime;  
  1030. if ((int)$rpstLastPostID<1) {  
  1031. $extInfo = " | Reposting (<b>".$ggg."</b>) | Total posts included in reposting: ".$query->found_posts." | ".($options['extDebug']=='1'?"|Query: ".print_r($query->request, true):'');  
  1032. if ($ntOpts['rpstType']=='1') nxs_addToLogN('S', 'Random Re-Posting - Nothing to post', $logNT, $times.'| Last Time:'.date_i18n('Y-m-d H:i:s', $lastTime).' RND Time: '.$rndTime.' - Next Time - '.date_i18n('Y-m-d H:i:s', $ntOpts['rpstNxTime']).")", $extInfo); 
  1033. else { if (!isset($ntOpts['rpstStop']) || (isset($ntOpts['rpstStop']) && trim($ntOpts['rpstStop'])=='O')) { $ntOpts['rpstOn']='0';  
  1034. nxs_addToLogN('S', 'RE-Posting', $logNT, 'End of Query - Turning Auto-Reposting Off - '.$times.' | Last Time:'.date_i18n('Y-m-d H:i:s', $lastTime).' Next Time - '.date_i18n('Y-m-d H:i:s', $ntOpts['rpstNxTime']).")", $extInfo); 
  1035. } elseif ( trim($ntOpts['rpstStop'])=='W')  
  1036. nxs_addToLogN('S', 'RE-Posting', $logNT, '(Waiting mode is ON) <b>Nothing to Repost.</b> | '.$times.' | Last Time:'.date_i18n('Y-m-d H:i:s', $lastTime).' Next Time - '.date_i18n('Y-m-d H:i:s', $ntOpts['rpstNxTime']).")", $extInfo); 
  1037. elseif ( trim($ntOpts['rpstStop'])=='R') { $ntOpts['rpstLastPostID'] = ($ntOpts['rpstType']=='3'?'90000000':'0'); 
  1038. nxs_addToLogN('S', 'RE-Posting', $logNT, '(<b>Nothing to Repost.</b> - End of Query - <b>Resetting<b>) | '.$times.' | Last Time:'.date_i18n('Y-m-d H:i:s', $lastTime).' Next Time - '.date_i18n('Y-m-d H:i:s', $ntOpts['rpstNxTime']).")", $extInfo); } 
  1039. } else { $ntOpts['rpstLastPostID'] = $rpstLastPostID;  
  1040. //## Actual Post  
  1041. $clName = 'nxs_snapClass'.strtoupper($avNt['lcode']); $pFuncName = 'nxs_doPublishTo'.strtoupper($avNt['lcode']);  
  1042. $po = get_post_meta($rpstLastPostID, 'snap'.strtoupper($avNt['lcode']), true); $po = maybe_unserialize($po);  
  1043. $ntClInst = new $clName(); $ntOpts['ii'] = $ii; $ntOpts['pType'] = 'aj'; $ntOptsPost = $ntClInst->adjMetaOpt($ntOpts, $po[$ii]);  
  1044. if ($options['extDebug']=='1') $extInfo .= "<br/><br/>NT OPTS: ".print_r($ntOptsPost, true); if ($options['extDebug']=='1') $extInfo .= "ARGS: <br/><br/>".print_r($args, true); 
  1045. $result = $pFuncName($rpstLastPostID, $ntOptsPost); //if ($result == 200) die("Successfully sent your post to App.Net."); else die($result);  
  1046. nxs_addToLogN('S', 'RE-Posting', $logNT, 'OK | '.$times.' | Previous Time:'.date_i18n('Y-m-d H:i:s', $lastTime).'| Next Shedulled Time - '.date_i18n('Y-m-d H:i:s', $ntOpts['rpstNxTime']).")<br/>", $extInfo); 
  1047. } $options[$avNt['lcode']][$ii] = $ntOpts; // prr($ntOpts); 
  1048. }  
  1049. } if ($hasChanged) { update_option($plgn_NS_SNAutoPoster->dbOptionsName, $options); $plgn_NS_SNAutoPoster->nxs_options = $options; } 
  1050.  
  1051. function nxs_chckBrwsr() { $isOK = false; if (empty($_SERVER['HTTP_USER_AGENT'])) return true; 
  1052. if (preg_match('/MSIE/i', $_SERVER['HTTP_USER_AGENT'])) $isOK = true; if (preg_match('/Internet Explorer/i', $_SERVER['HTTP_USER_AGENT'])) $isOK = true; 
  1053. if (preg_match('/Firefox/i', $_SERVER['HTTP_USER_AGENT'])) $isOK = true; if (preg_match('/Opera/i', $_SERVER['HTTP_USER_AGENT'])) $isOK = true; 
  1054. if (preg_match('/Chrome/i', $_SERVER['HTTP_USER_AGENT'])) $isOK = true; if (preg_match('/Safari/i', $_SERVER['HTTP_USER_AGENT'])) $isOK = true; 
  1055. if (preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone)/i', strtolower($_SERVER['HTTP_USER_AGENT'])) || (!empty($_SERVER['HTTP_ACCEPT']) && strpos(strtolower($_SERVER['HTTP_ACCEPT']), 'application/vnd.wap.xhtml+xml')>0) or ((isset($_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE'])))) $isOK = false; 
  1056. return $isOK; 
  1057.  
  1058. //## NXS Cron 
  1059. if (!function_exists("nxs_psCron")) { function nxs_psCron() { if (!is_home() && !is_front_page()) return; if (nxs_chckBrwsr()==false) return;  
  1060. //if (stripos($_SERVER["REQUEST_URI"], 'admin-ajax.php')!==false || stripos($_SERVER["REQUEST_URI"], 'cf_action')!==false || stripos($_SERVER["REQUEST_URI"], 'wp-cron.php')!==false) return;  
  1061. $ltc = get_option('NSX_LastTChecked'); if (empty($ltc)) { add_option("NSX_LastTChecked", time()); return; } if (time()<$ltc+300) return; $sh =_get_cron_array(); $itmsToPush = array();  
  1062. if (is_array($sh)) foreach ($sh as $evTime => $evDataX) if (is_array($evDataX)) foreach ($evDataX as $evFunc=>$evData) if (strpos($evFunc, 'ns_doPublishTo')!==false) { $chkTime = rand(360, 600); //$chkTime = rand(5, 7); 
  1063. if ($evTime>'1359495839' && $evTime<time()-$chkTime) $itmsToPush[] = array('time'=>$evTime); 
  1064. } if (count($itmsToPush)<1) return;  
  1065. /** 
  1066. $snapIP = get_post_meta($toPush['args'][0], 'snap_mp_'.$toPush['func'], true);  
  1067. nxs_addToLogN('S', 'Missed Scheduled Autoposts Found', '', ' - ('.$evTime."<".(time()-$chkTime).') - Trying to Post', ''); 
  1068. delete_post_meta(); add_post_meta($toPush['args'][0], 'snap_mp_'.$toPush['func'], (time()+300)); 
  1069. */ 
  1070. update_option("NSX_LastTChecked", time()); 
  1071. $cron_url = site_url('wp-cron.php?doing_wp_cron=0'); ?><script type="text/javascript" > jQuery(document).ready(function($) { jQuery.get('<?php echo $cron_url; ?>'); }); </script><?php // die(); 
  1072. return true;  
  1073. }} 
  1074.  
  1075. if (!function_exists("nxs_addToRI")) { function nxs_addToRI($postID) { global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options; 
  1076. $riPosts = get_option('NS_SNriPosts'); if (!is_array($riPosts)) $riPosts = array(); $options['riHowManyPostsToTrack'] = (int) $options['riHowManyPostsToTrack']; if ($options['riHowManyPostsToTrack']==0) return; 
  1077. array_unshift($riPosts, $postID); $riPosts = array_unique($riPosts); $riPosts = array_slice($riPosts, 0, $options['riHowManyPostsToTrack']); update_option('NS_SNriPosts', $riPosts); 
  1078. }} 
  1079.  
  1080. function nxs_activation() { if (!wp_next_scheduled('nxs_hourly_event')) {wp_schedule_event(time(), 'hourly', 'nxs_hourly_event');} if (!wp_next_scheduled('nxs_querypost_event')) {wp_schedule_event(time(), 'nxsreposter', 'nxs_querypost_event');} } 
  1081. function nxs_do_this_hourly() { $options = get_option('NS_SNAutoPoster');  
  1082. if (isset($options['errNotifEmailCB']) && (int)$options['errNotifEmailCB'] == 1 && isset($options['errNotifEmail']) && trim($options['errNotifEmail']) != '') { $logToSend = maybe_unserialize(get_option('NSX_LogToEmail')); // echo "SSS";  
  1083. // prr($logToSend); 
  1084. if (is_array($logToSend) && count($logToSend)>0) { $to = $options['errNotifEmail']; $subject = "SNAP Error Log for ".$_SERVER["SERVER_NAME"]; $message = print_r($logToSend, true); 
  1085. $eml = get_bloginfo('admin_email'); if (trim($eml)=='') $eml = "snap-notify@".str_ireplace('www.', '', $_SERVER["SERVER_NAME"]);  
  1086. $headers = "From: " . $eml . "\r\n"; $headers .= "Reply-To: ". $eml . "\r\n"; $headers .= "MIME-Version: 1.0\r\n"; 
  1087. $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; $retval = wp_mail($to, $subject, $message, $headers); echo ($to ."|". $subject."|". $message."|". $headers); 
  1088. if ($retval == true) nxs_addToLogN( 'S', 'Log sent to email '.$options['errNotifEmail'], 'ALL', count($logToSend).' records sent', '');  
  1089. else nxs_addToLogN( 'ER', '[FALIED] Log sent to email '.$options['errNotifEmail'], 'ALL', count($logToSend).' records were NOT sent', '');  
  1090. delete_option("NSX_LogToEmail");  
  1091. }}  
  1092. $riPosts = get_option('NS_SNriPosts'); if (!is_array($riPosts)) $riPosts = array(); //## Check for Incoming Comments if nessesary.  
  1093. if ($options['riActive'] != 1 || count($riPosts)<1 ) return; 
  1094. if (isset($options['extDebug']) && $options['extDebug']=='1') nxs_addToLogN( 'S', 'Comments Import', 'ALL', 'Checking for new comments now...', print_r($riPosts, true)); 
  1095. //## Facebook 
  1096. if (is_array($options['fb'])) foreach ($options['fb'] as $ii=>$fbo) if ($fbo['riComments']=='1') { $fbo['ii'] = $ii; $fbo['pType'] = 'aj'; 
  1097. foreach ($riPosts as $postID) {  
  1098. $fbpo = get_post_meta($postID, 'snapFB', true); $fbpo = maybe_unserialize($fbpo);  
  1099. if (is_array($fbpo) && isset($fbpo[$ii]) && is_array($fbpo[$ii]) && isset($fbpo[$ii]['pgID']) && trim($fbpo[$ii]['pgID'])!='') {  
  1100. $ntClInst = new nxs_snapClassFB(); $fbo = $ntClInst->adjMetaOpt($fbo, $fbpo[$ii]); nxs_getBackFBComments($postID, $fbo, $fbpo[$ii]); 
  1101. }  
  1102. }  
  1103. //## Twitter 
  1104. if (is_array($options['tw'])) foreach ($options['tw'] as $ii=>$fbo) if ($fbo['riComments']=='1') { $fbo['ii'] = $ii; $fbo['pType'] = 'aj'; $twList = nxs_getBackTWCommentsList($fbo);  
  1105. foreach ($riPosts as $postID) {  
  1106. $fbpo = get_post_meta($postID, 'snapTW', true); $fbpo = maybe_unserialize($fbpo);  
  1107. if (is_array($fbpo) && isset($fbpo[$ii]) && is_array($fbpo[$ii]) && isset($fbpo[$ii]['pgID']) && trim($fbpo[$ii]['pgID'])!='') {  
  1108. $ntClInst = new nxs_snapClassTW(); $fbo = $ntClInst->adjMetaOpt($fbo, $fbpo[$ii]); nxs_getBackTWComments($postID, $fbo, $fbpo[$ii], $twList); 
  1109. }  
  1110. }  
  1111.  
  1112. if (!function_exists('nxsClnCookies')) { function nxsClnCookies($ck) { $ckOut = array(); $t =time(); foreach ($ck as $c) { if ($c->value!='deleted' && $c->value!='deleteMe' && $c->value!='delete me' && (empty($c->expires) || $c->expires>$t)) $ckOut[] = $c; } return $ckOut; }} 
  1113.  
  1114. //#### V3 new Query Poster 
  1115. function nxs_addToPostingQuery($postID) { global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;  
  1116. $quPosts = maybe_unserialize(get_option('NSX_PostsQuery')); if (!is_array($quPosts)) $quPosts = array();  
  1117. if (!in_array($postID, $quPosts)) $quPosts[] = $postID; update_option('NSX_PostsQuery', $quPosts);  
  1118. //## Update Next Post time 
  1119. $currTime = time() + 10 + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); $nxTime = !empty($options['quNxTime'])?$options['quNxTime']:0; 
  1120. if (empty($nxTime) || $nxTime < $currTime) { $options['quNxTime'] = $currTime; update_option('NS_SNAutoPoster', $options); $plgn_NS_SNAutoPoster->nxs_options = $options; } 
  1121. function nxs_do_post_from_query() { nxs_cron_check(); // nxs_addToLogN('A', 'Debug info only. - Cron Time', 'X', '', $extInfo);  
  1122. if (stripos($_SERVER["REQUEST_URI"], 'wp-cron.php')!==false) nxs_rePoster(); //## Run Reposter. 
  1123. $options = get_option('NS_SNAutoPoster'); $quPosts = maybe_unserialize(get_option('NSX_PostsQuery')); if (!is_array($quPosts)) $quPosts = array(); 
  1124. if ($options['quLimit'] != '1' || count($quPosts)<1) return; $currTime = time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); $hasChanged = false;  
  1125. $postToPost = array_shift($quPosts);  
  1126.  
  1127. $pstEvrySec = $options['quDays']*86400+$options['quHrs']*3600+$options['quMins']*60; $rndSec = $options['quLimitRndMins']*60;  
  1128. $nxTime = !empty($options['quNxTime'])?$options['quNxTime']:$currTime+$pstEvrySec;  
  1129.  
  1130. $extInfo = 'Query Time:'.date_i18n('Y-m-d H:i:s', $options['quNxTime'])."|Previous Time:".date_i18n('Y-m-d H:i:s', $options['quLastShTime']); 
  1131.  
  1132. if (empty($options['quNxTime']) || $nxTime < $currTime) $hasChanged = true; // Do Post  
  1133.  
  1134. if ($hasChanged) { //## Do Post  
  1135. nxs_addToLogN('A', '**POST STARTED** NXSPoster - WP CRON - Post from Query - Post ID: '.$postToPost, '', 'Curr Time: '.date_i18n('Y-m-d H:i:s', $currTime).'~', $extInfo);  
  1136. $options['quLastShTime'] = $currTime; $rndTime = rand(0-$rndSec, $rndSec); $options['quNxTime'] = $currTime + $pstEvrySec + $rndTime;  
  1137. if ($options['nxsOverLimit']=='D') { $dateC = date("d"); $dayN = date("d", $nxTime); if ($dayN!=$dateC) $quPosts = array(); }  
  1138. update_option('NSX_PostsQuery', $quPosts); update_option('NS_SNAutoPoster', $options);  
  1139. nxs_snapPublishTo($postToPost, '', true);  
  1140. nxs_addToLogN('A', '**POST FINISHED** NXSPoster - WP CRON - Post from Query - Post ID: '.$postToPost, '', '-=Time=- '.$currTime, $extInfo);  
  1141.  
  1142. class NXS_HtmlFixer { public $dirtyhtml; public $fixedhtml; public $allowed_styles; private $matrix; public $debug; private $fixedhtmlDisplayCode; 
  1143. public function __construct() { $this->dirtyhtml = ""; $this->fixedhtml = ""; $this->debug = false; $this->fixedhtmlDisplayCode = ""; $this->allowed_styles = array();} 
  1144. public function getFixedHtml($dirtyhtml) { $c = 0; $this->dirtyhtml = $dirtyhtml; $this->fixedhtml = ""; $this->fixedhtmlDisplayCode = ""; if (is_array($this->matrix)) unset($this->matrix); $errorsFound=0; 
  1145. while ($c<10) { if ($c>0) $this->dirtyhtml = $this->fixedxhtml; $errorsFound = $this->charByCharJob(); if (!$errorsFound) $c=10; $this->fixedxhtml=str_replace('<root>', '', $this->fixedxhtml);  
  1146. $this->fixedxhtml=str_replace('</root>', '', $this->fixedxhtml); $this->fixedxhtml = $this->removeSpacesAndBadTags($this->fixedxhtml); $c++; 
  1147. } return $this->fixedxhtml; 
  1148. private function fixStrToLower($m) { $right = strstr($m, '='); $left = str_replace($right, '', $m); return strtolower($left).$right;} 
  1149. private function fixQuotes($s) { $q = "\""; if (!stristr($s, "=")) return $s; $out = $s; preg_match_all("|=(.*)|", $s, $o, PREG_PATTERN_ORDER); 
  1150. for ($i = 0; $i< count ($o[1]); $i++) { $t = trim ( $o[1][$i] ) ; $lc=""; if ($t!="") { if ($t[strlen($t)-1]==">") { $lc= ($t[strlen($t)-2].$t[strlen($t)-1])=="/>" ? "/>" : ">" ; $t=substr($t, 0, -1);} 
  1151. if (($t[0]!="\"")&&($t[0]!="'")) $out = str_replace( $t, "\"".$t, $out); else $q=$t[0]; if (($t[strlen($t)-1]!="\"")&&($t[strlen($t)-1]!="'")) $out = str_replace( $t.$lc, $t.$q.$lc, $out); 
  1152. }} return $out; 
  1153. private function fixTag($t) { $t = preg_replace ( array( '/borderColor=([^ >])*/i', '/border=([^ >])*/i' ), array('', ''), $t); 
  1154. preg_match_all('/(?:"[^"]*"|\'[^\']*\'|[^"\'\s]+)+/', $t, $ar); $ar = $ar[0];// prr($ar); 
  1155. $nt = ""; for ($i=0;$i<count($ar);$i++) { if (strpos($ar[$i], 'href=\\\\\\"')!==false) {$ar[$i] = str_replace('\\\\\\"', '"', $ar[$i]);} 
  1156. if (strpos($ar[$i], 'href=\\"')!==false) {$ar[$i] = str_replace('\\"', '"', $ar[$i]);} if (strpos($ar[$i], 'href=\"')!==false) {$ar[$i] = str_replace('\"', '"', $ar[$i]);} 
  1157. $ar[$i]=$this->fixStrToLower($ar[$i]); if (stristr($ar[$i], "=")) $ar[$i] = $this->fixQuotes($ar[$i]); $nt.=$ar[$i]." ";  
  1158. } $nt=preg_replace("/<( )*/i", "<", $nt); $nt=preg_replace("/( )*>/i", ">", $nt); return trim($nt); 
  1159. private function extractChars($tag1, $tag2, $tutto) { if (!stristr($tutto, $tag1)) return ''; $s=stristr($tutto, $tag1); $s=substr( $s, strlen($tag1)); if (!stristr($s, $tag2)) return ''; 
  1160. $s1=stristr($s, $tag2); return substr($s, 0, strlen($s)-strlen($s1)); 
  1161. private function mergeStyleAttributes($s) { $x = ""; $temp = ""; $c = 0; 
  1162. while(stristr($s, "style=\"")) {$temp = $this->extractChars("style=\"", "\"", $s); if ($temp=="") { return preg_replace("/(\/)?>/i", "\"\\1>", $s);} 
  1163. if ($c==0) $s = str_replace("style=\"".$temp."\"", "##PUTITHERE##", $s); $s = str_replace("style=\"".$temp."\"", "", $s); if (!preg_match("/;$/i", $temp)) $temp.=";"; $x.=$temp; $c++; 
  1164. if (count($this->allowed_styles)>0) { $check=explode(';', $x); $x=""; foreach($check as $chk) { foreach($this->allowed_styles as $as) if(stripos($chk, $as) !== False) { $x.=$chk.';'; break; } }} 
  1165. if ($c>0) $s = str_replace("##PUTITHERE##", "style=\"".$x."\"", $s);return $s; 
  1166. private function fixAutoclosingTags($tag, $tipo="") { if (in_array( $tipo, array ("img", "input", "br", "hr")) ) { if (!stristr($tag, '/>')) $tag = str_replace('>', '/>', $tag ); } return $tag; } 
  1167. private function getTypeOfTag($tag) { $tag = trim(preg_replace("/[\>\<\/]/i", "", $tag)); $a = explode(" ", $tag); return $a[0];} 
  1168. private function checkTree() { $errorsCounter = 0; for ($i=1;$i<count($this->matrix);$i++) { $flag=false; 
  1169. if ($this->matrix[$i]["tagType"]=="div") { $parentType = $this->matrix[$this->matrix[$i]["parentTag"]]["tagType"]; if (in_array($parentType, array("p", "b", "i", "font", "u", "small", "strong", "em"))) $flag=true; } 
  1170. if (in_array( $this->matrix[$i]["tagType"], array( "b", "strong" )) ) { $parentType = $this->matrix[$this->matrix[$i]["parentTag"]]["tagType"]; if (in_array($parentType, array("b", "strong"))) $flag=true; } 
  1171. if (in_array( $this->matrix[$i]["tagType"], array ( "i", "em") )) { $parentType = $this->matrix[$this->matrix[$i]["parentTag"]]["tagType"]; if (in_array($parentType, array("i", "em"))) $flag=true; } 
  1172. if ($this->matrix[$i]["tagType"]=="p") { $parentType = $this->matrix[$this->matrix[$i]["parentTag"]]["tagType"]; if (in_array($parentType, array("p", "b", "i", "font", "u", "small", "strong", "em"))) $flag=true; } 
  1173. if ($this->matrix[$i]["tagType"]=="table") { $parentType = $this->matrix[$this->matrix[$i]["parentTag"]]["tagType"]; if (in_array($parentType, array("p", "b", "i", "font", "u", "small", "strong", "em", "tr", "table"))) $flag=true; } 
  1174. if ($flag) { $errorsCounter++; if ($this->debug) echo "<div style='color:#ff0000'>Found a <b>".$this->matrix[$i]["tagType"]."</b> tag inside a <b>".htmlspecialchars($parentType)."</b> tag at node $i: MOVED</div>";  
  1175. $swap = $this->matrix[$this->matrix[$i]["parentTag"]]["parentTag"]; if ($this->debug) echo "<div style='color:#ff0000'>Every node that has parent ".$this->matrix[$i]["parentTag"]." will have parent ".$swap."</div>"; 
  1176. $this->matrix[$this->matrix[$i]["parentTag"]]["tag"]="<!-- T A G \"".$this->matrix[$this->matrix[$i]["parentTag"]]["tagType"]."\" R E M O V E D -->"; $this->matrix[$this->matrix[$i]["parentTag"]]["tagType"]=""; 
  1177. $hoSpostato=0;for ($j=count($this->matrix)-1;$j>=$i;$j--) { if ($this->matrix[$j]["parentTag"]==$this->matrix[$i]["parentTag"]) { $this->matrix[$j]["parentTag"] = $swap; $hoSpostato=1; }} 
  1178. }}return $errorsCounter; 
  1179. private function findSonsOf($parentTag) { $out= ""; 
  1180. for ($i=1;$i<count($this->matrix);$i++) { if ($this->matrix[$i]["parentTag"]==$parentTag) { 
  1181. if ($this->matrix[$i]["tag"]!="") { $out.=$this->matrix[$i]["pre"]; $out.=$this->matrix[$i]["tag"]; $out.=$this->matrix[$i]["post"]; } else { $out.=$this->matrix[$i]["pre"]; $out.=$this->matrix[$i]["post"];} 
  1182. if ($this->matrix[$i]["tag"]!="") { $out.=$this->findSonsOf($i); if ($this->matrix[$i]["tagType"]!="") { if (!in_array($this->matrix[$i]["tagType"], array ( "br", "img", "hr", "input"))) $out.="</". $this->matrix[$i]["tagType"].">";}} 
  1183. }}return $out; 
  1184. private function findSonsOfDisplayCode($parentTag) { $out= ""; 
  1185. for ($i=1;$i<count($this->matrix);$i++) { 
  1186. if ($this->matrix[$i]["parentTag"]==$parentTag) { $out.= "<div style=\"padding-left:15\"><span style='float:left;background-color:#FFFF99;color:#000;'>{$i}:</span>"; 
  1187. if ($this->matrix[$i]["tag"]!="") { if ($this->matrix[$i]["pre"]!="") $out.=htmlspecialchars($this->matrix[$i]["pre"])."<br>"; 
  1188. $out.="".htmlspecialchars($this->matrix[$i]["tag"])."<span style='background-color:red; color:white'>{$i} <em>".$this->matrix[$i]["tagType"]."</em></span>"; 
  1189. $out.=htmlspecialchars($this->matrix[$i]["post"]); 
  1190. } else { if ($this->matrix[$i]["pre"]!="") $out.=htmlspecialchars($this->matrix[$i]["pre"])."<br>"; $out.=htmlspecialchars($this->matrix[$i]["post"]);} 
  1191. if ($this->matrix[$i]["tag"]!="") { $out.="<div>".$this->findSonsOfDisplayCode($i)."</div>\n"; 
  1192. if ($this->matrix[$i]["tagType"]!="") { 
  1193. if (($this->matrix[$i]["tagType"]!="br") && ($this->matrix[$i]["tagType"]!="img") && ($this->matrix[$i]["tagType"]!="hr")&& ($this->matrix[$i]["tagType"]!="input")) 
  1194. $out.="<div style='color:red'>".htmlspecialchars("</". $this->matrix[$i]["tagType"].">")."{$i} <em>".$this->matrix[$i]["tagType"]."</em></div>"; 
  1195. } $out.="</div>\n"; 
  1196. }return $out; 
  1197. private function removeSpacesAndBadTags($s) { $i=0; 
  1198. while ($i<10) { $i++; $s = preg_replace ( 
  1199. array( '/ /i', '/<p([^>])*>( )*\s*<\/p>/i', '/<span([^>])*>( )*\s*<\/span>/i', '/<strong([^>])*>( )*\s*<\/strong>/i', '/<em([^>])*>( )*\s*<\/em>/i',  
  1200. '/<font([^>])*>( )*\s*<\/font>/i', '/<small([^>])*>( )*\s*<\/small>/i', '/<\?xml:namespace([^>])*><\/\?xml:namespace>/i', '/<\?xml:namespace([^>])*\/>/i', '/class=\"MsoNormal\"/i',  
  1201. '/<o:p><\/o:p>/i', '/<!DOCTYPE([^>])*>/i', '/<!--(.|\s)*?-->/', '/<\?(.|\s)*?\?>/'),  
  1202. array(' ', ' ', '', '', '', '', '', '', '', '', '', ' ', '', '' ) , trim($s)); 
  1203. }return $s; 
  1204. private function charByCharJob() { $s = $this->removeSpacesAndBadTags($this->dirtyhtml); if ($s=="") return; //echo "\r\n=!= ".$s." =!=\r\n<br/>\r\n"; 
  1205. $s = "<root>".$s."</root>"; $contenuto = ""; $ns = ""; $i=0; $j=0; $ss=''; $indexparentTag=0; $padri=array(); array_push($padri, "0"); $this->matrix[$j]["tagType"]=""; 
  1206. $this->matrix[$j]["tag"]=""; $this->matrix[$j]["parentTag"]="0"; $this->matrix[$j]["pre"]=""; $this->matrix[$j]["post"]=""; $tags=array(); 
  1207. // echo "\r\n=#= ".$s." =#=\r\n<br/>\r\n"; 
  1208. while($i<strlen($s)) { 
  1209. if ( $s[$i] =="<") { $contenuto = $ns; $ns = ""; $tag=""; while( $i<strlen($s) && $s[$i]!=">" ) { $tag.=$s[$i]; $i++;} $tag.=$s[$i]; if (stristr($tag, '<param') && stristr($tag, '/>')) $tag = str_replace('/>', '></param>', $tag); 
  1210. $ss .= $tag;  
  1211. } else $ss .= $s[$i]; $i++; } 
  1212. $i=0; $s = $ss; //echo "\r\n== ".$s." ==\r\n<br/>\r\n"; 
  1213. while($i<strlen($s)) { 
  1214. if ( $s[$i] =="<") { $contenuto = $ns; $ns = ""; $tag=""; while( $i<strlen($s) && $s[$i]!=">" ) { $tag.=$s[$i]; $i++;} $tag.=$s[$i];  
  1215. if($s[$i]==">") { $tag = $this->fixTag($tag); $tagType = $this->getTypeOfTag($tag); $tag = $this->fixAutoclosingTags($tag, $tagType); 
  1216. $tag = $this->mergeStyleAttributes($tag); if (!isset($tags[$tagType])) $tags[$tagType]=0; $tagok=true; 
  1217. if (($tags[$tagType]==0)&&(stristr($tag, '/'.$tagType.'>'))&&(stristr($tag, '<'.$tagType)!==false)) { $tagok=false; if ($this->debug) echo "<div style='color:#ff0000'>Found a closing tag <b>".htmlspecialchars($tag)."</b> at char $i without open tag: REMOVED</div>";} else $tagok=true; 
  1218. if ($tagok) { $j++; $this->matrix[$j]["pre"]=""; $this->matrix[$j]["post"]=""; $this->matrix[$j]["parentTag"]=""; $this->matrix[$j]["tag"]=""; $this->matrix[$j]["tagType"]=""; 
  1219. if (stristr($tag, '/'.$tagType.'>')) { $ind = array_pop($padri); $this->matrix[$j]["post"]=$contenuto; $this->matrix[$j]["parentTag"]=$ind; $tags[$tagType]--; 
  1220. } else { if (@preg_match("/".$tagType."\/>$/i", $tag)||preg_match("/\/>/i", $tag)) { $this->matrix[$j]["tagType"]=$tagType; $this->matrix[$j]["tag"]=$tag; 
  1221. $indexparentTag = array_pop($padri); array_push($padri, $indexparentTag); $this->matrix[$j]["parentTag"]=$indexparentTag; $this->matrix[$j]["pre"]=$contenuto; $this->matrix[$j]["post"]=""; 
  1222. } else { $tags[$tagType]++; $this->matrix[$j]["tagType"]=$tagType; $this->matrix[$j]["tag"]=$tag; $indexparentTag = array_pop($padri); array_push($padri, $indexparentTag); 
  1223. array_push($padri, $j); $this->matrix[$j]["parentTag"]=$indexparentTag; $this->matrix[$j]["pre"]=$contenuto; $this->matrix[$j]["post"]=""; } 
  1224. } else { $ns.=$s[$i]; } $i++; 
  1225. } for ($eli=$j+1;$eli<count($this->matrix);$eli++) { $this->matrix[$eli]["pre"]=""; $this->matrix[$eli]["post"]=""; $this->matrix[$eli]["parentTag"]=""; $this->matrix[$eli]["tag"]=""; $this->matrix[$eli]["tagType"]="";} 
  1226. $errorsCounter = $this->checkTree(); $this->fixedxhtml=$this->findSonsOf(0);return $errorsCounter; 
  1227.  
  1228. //## parse_str() implementation - max_vars fix. 
  1229. if (!function_exists("NXS_doSetArrRecursive")) { function NXS_doSetArrRecursive(&$array, $path, $value) { $key = array_shift($path); //prr($path); prr($key); echo "|-"; prr($array); echo "-|"; 
  1230. if (empty($path)) if (trim($key)=='') $array[] = $value; else $array[$key] = $value; else { if (!isset($array[$key]) || !is_array($array[$key])) $array[$key] = array(); NXS_doSetArrRecursive($array[$key], $path, $value); } 
  1231. }} 
  1232. if (!function_exists("NXS_parseQueryStr")) { function NXS_parseQueryStr($url) { $tokens = explode("&", $url); $urlVars = array(); 
  1233. foreach ($tokens as $token) { $token = urldecode($token); $value = NXS_parseEQStr($token, "=", "");  
  1234. if (preg_match('/^([^\[]*)(\[.*\])$/', $token, $matches)) { if (preg_match_all('/\[([^\]]*)\]/', $matches[2], $matches2)) $gg = $matches2[1]; array_unshift($gg, $matches[1]); NXS_doSetArrRecursive($urlVars, $gg, $value);}  
  1235. else $urlVars[$token] = $value; 
  1236. } return $urlVars; 
  1237. }} 
  1238. if (!function_exists("NXS_parseEQStr")) { function NXS_parseEQStr(&$a, $delim='.', $default=false) { $n = strpos($a, $delim); if ($n === false) return $default; $result = substr($a, $n+strlen($delim)); $a = substr($a, 0, $n); return $result;}} 
  1239. ?> 
.