function nxsCptCheck_ajax() { global $nxs_gCookiesArr; $advSettings = array(); if (!empty($_POST['c'])) { $seForDB = get_option('nxs_li_ctp_save'); $ser = maybe_unserialize($seForDB); $nxs_gCookiesArr = $ser['c']; $ck = $nxs_gCookiesArr; $flds = $ser['f']; $flds['recaptcha_response_field'] = $_POST['c']; $liObj = new nxsAPI_LI(); $hdrsArr = $liObj->headers('https://www.linkedin.com/uas/login-submit', 'https://www.linkedin.com', 'POST', false); $advSet = array('headers' => $hdrsArr, 'httpversion' => '1.1', 'timeout' => 45, 'redirection' => 0, 'cookies' => $ck, 'body' => $flds); // prr($advSet); $rep = nxs_remote_post('https://www.linkedin.com/uas/captcha-submit', $advSet); if (is_nxs_error($rep)) { $badOut = print_r($rep, true) . " - ERROR"; return $badOut; } $contents2 = $rep['body']; if (stripos($contents2, '<span class="error">') !== false) { echo strip_tags(CutFromTo($contents2, '<span class="error">', '</span>')); die; } if (stripos($contents2, '<div id="global-error">') !== false) { echo CutFromTo($contents2, '<div role="alert" class="alert error">', '</div>'); die; } if (stripos($contents2, 'The email address or password you provided does not match our records') !== false) { echo "Invalid Login/Password"; die; } if (stripos($contents2, 'Hmm, ') !== false) { echo "Invalid Login/Password"; die; } if ($rep['response']['code'] == '302' && !empty($rep['headers']['location']) && stripos($rep['headers']['location'], 'linkedin.com/uas/captcha-submit') !== false) { echo "Wrong Captcha. Please try Again"; } if ($rep['response']['code'] == '302' && !empty($rep['headers']['location']) && (stripos($rep['headers']['location'], 'linkedin.com/nhome') !== false || stripos($rep['headers']['location'], 'linkedin.com/home') !== false)) { echo "OK. You are In"; $hdrsArr = $liObj->headers('http://www.linkedin.com/home', 'https://www.linkedin.com'); $ck = $rep['cookies']; $advSet = array('headers' => $hdrsArr, 'httpversion' => '1.1', 'timeout' => 45, 'redirection' => 0, 'cookies' => $ck); // prr($advSet); $rep = nxs_remote_get('http://www.linkedin.com/profile/edit?trk=tab_pro', $advSet); if (is_nxs_error($rep)) { $badOut = print_r($rep, true) . " - ERROR"; return $badOut; } $ck = $rep['cookies']; if ($_POST['i'] != '') { global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) { return; } $options = $plgn_NS_SNAutoPoster->nxs_options; $options['li'][$_POST['i']]['ck'] = $ck; if (is_array($options)) { update_option('NS_SNAutoPoster', $options); } } } } if (!empty($_POST['s'])) { $seForDB = get_option('nxs_li_ctp_save'); $ser = maybe_unserialize($seForDB); $ck = $ser['c']; $flds = $ser['f']; $flds['PinVerificationForm_pinParam'] = $_POST['s']; $liObj = new nxsAPI_LI(); $hdrsArr = $liObj->headers('https://www.linkedin.com/uas/login-submit', 'https://www.linkedin.com', 'POST', true); $advSet = array('headers' => $hdrsArr, 'httpversion' => '1.1', 'timeout' => 45, 'redirection' => 0, 'cookies' => $ck, 'body' => $flds); // prr($advSet); $rep = nxs_remote_post('https://www.linkedin.com/uas/ato-pin-challenge-submit', $advSet); if (is_nxs_error($rep)) { $badOut = print_r($rep, true) . " - ERROR"; return $badOut; } $contents2 = $rep['body']; // prr($rep); if (stripos($contents2, 'The email address or password you provided does not match our records') !== false) { echo "Invalid Login/Password"; die; } if (stripos($contents2, '<div id="global-error">') !== false) { echo CutFromTo($contents2, '<div role="alert" class="alert error">', '</div>'); die; } if (stripos($contents2, 'Hmm, ') !== false) { echo "Invalid Login/Password"; die; } if ($rep['response']['code'] == '302' && !empty($rep['headers']['location']) && stripos($rep['headers']['location'], 'linkedin.com/uas/ato-pin-challenge-submit') !== false) { echo "Wrong Code. Please try Again"; } if ($rep['response']['code'] == '302' && !empty($rep['headers']['location']) && (stripos($rep['headers']['location'], 'linkedin.com/nhome') !== false || stripos($rep['headers']['location'], 'linkedin.com/home') !== false)) { echo "OK. You are In"; } $hdrsArr = $liObj->headers('http://www.linkedin.com/home', 'https://www.linkedin.com'); $ck = $rep['cookies']; $advSet = array('headers' => $hdrsArr, 'httpversion' => '1.1', 'timeout' => 45, 'redirection' => 0, 'cookies' => $ck); // prr($advSet); $rep = nxs_remote_get('http://www.linkedin.com/profile/edit?trk=tab_pro', $advSet); if (is_nxs_error($rep)) { $badOut = print_r($rep, true) . " - ERROR"; return $badOut; } $ck = $rep['cookies']; if ($_POST['i'] != '') { global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) { return; } $options = $plgn_NS_SNAutoPoster->nxs_options; $options['li'][$_POST['i']]['ck'] = $ck; if (is_array($options)) { update_option('NS_SNAutoPoster', $options); } } } die; }
function doPostToNT($options, $message) { $badOut = array('postID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => ''); $liPostID = ''; //## Check settings if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; } if ((!isset($options['ulName']) || trim($options['uPass']) == '') && empty($options['liOAuthVerifier'])) { $badOut['Error'] = 'Not Configured'; return $badOut; } if (empty($options['imgSize'])) { $options['imgSize'] = ''; } if (empty($options['liMsgFormatT'])) { $options['liMsgFormatT'] = '%TITLE%'; } //## Format if (!empty($message['pText'])) { $msg = $message['pText']; } else { $msg = nxs_doFormatMsg($options['liMsgFormat'], $message); } if (!empty($message['pTitle'])) { $msgT = $message['pTitle']; } else { $msgT = nxs_doFormatMsg($options['liMsgFormatT'], $message); } if (empty($options['postType'])) { if ((int) $options['liAttch'] == 1 || $isNew) { $options['postType'] = 'A'; } } if ($options['postType'] == 'A' || $options['postType'] == 'I') { if (isset($message['imageURL'])) { $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); } else { $imgURL = ''; } if (preg_match("/noImg.\\.png/i", $imgURL)) { $imgURL = ''; } if (!empty($message['urlDescr'])) { $dsc = $message['urlDescr']; } else { $dsc = $msg; } $dsc = strip_tags($dsc); $dsc = nxs_decodeEntitiesFull($dsc); $dsc = nxs_html_to_utf8($dsc); $dsc = nsTrnc($dsc, 300); } $msg = strip_tags($msg); $msg = nxs_html_to_utf8($msg); $msgT = nxs_html_to_utf8($msgT); $urlToGo = $message['url']; if (function_exists("doConnectToLinkedIn") && $options['ulName'] != '' && $options['uPass'] != '') { $dusername = $options['ulName']; $pass = substr($options['uPass'], 0, 5) == 'n5g9a' ? nsx_doDecode(substr($options['uPass'], 5)) : $options['uPass']; // ??? Do we need that?????? $auth = doConnectToLinkedIn($options['ulName'], $options['uPass'], $options['ii']); if ($auth != false) { $badOut['Error'] .= "|Auth Error - " . $auth; return $badOut; } $to = $options['uPage'] != '' ? $options['uPage'] : 'https://www.linkedin.com/home'; $lnk = array(); $msg = str_ireplace(' ', ' ', $msg); $msg = nsTrnc(strip_tags($msg), 700); $lnk['postTitle'] = $msgT; if ($options['postType'] == 'A') { $lnk['title'] = $message['urlTitle']; $lnk['desc'] = $message['urlDescr']; $lnk['url'] = $urlToGo; $lnk['img'] = $imgURL; $lnk['postType'] = 'A'; } if ($options['postType'] == 'I') { $lnk['title'] = ''; $lnk['desc'] = ''; $lnk['url'] = $imgURL; $lnk['img'] = $imgURL; $lnk['postType'] = 'I'; $lnk['postTitle'] = $msgT; } if ($options['postType'] == 'T') { $lnk['postType'] = 'T'; } global $nxs_gCookiesArr; $li = new nxsAPI_LI(); $li->debug = false; if (!empty($nxs_gCookiesArr)) { $li->ck = $nxs_gCookiesArr; } $ret = $li->post($msg, $lnk, $to); if (is_array($ret) && !empty($ret['isPosted'])) { return $ret; } $liPostID = $options['uPage']; } else { if (!empty($options['isV2'])) { //## V2 if ($options['grpID'] != '') { try { if ($msgT == '') { $msgT = ' '; } if ($options['postType'] == 'A') { $ret = $this->postToGroup($options['liAccessToken'], $msg, $msgT, $options['grpID'], str_replace('&', '&', $urlToGo), $imgURL, $dsc); } else { $ret = $this->postToGroup($options['liAccessToken'], $msg, $msgT, $options['grpID']); } $liPostID = 'http://www.linkedin.com/groups?gid=' . $options['grpID']; } catch (Exception $o) { $ret = "ERROR: " . print_r($o, true); } } else { //echo $msg ."|". nsTrnc($msgT, 200) ."|". $urlToGo ."|". $imgURL ."|". $dsc; if ($options['postType'] == 'A') { $ret = $this->postShare($options['liAccessToken'], $msg, nsTrnc($msgT, 200), str_replace('&', '&', $urlToGo), $imgURL, $dsc); } else { $ret = $this->postShare($options['liAccessToken'], $msg); } } } else { //## V1 require_once 'apis/liOAuth.php'; $linkedin = new nsx_LinkedIn($options['liAPIKey'], $options['liAPISec']); $linkedin->oauth_verifier = $options['liOAuthVerifier']; $linkedin->request_token = new nsx_trOAuthConsumer($options['liOAuthToken'], $options['liOAuthTokenSecret'], 1); $linkedin->access_token = new nsx_trOAuthConsumer($options['liAccessToken'], $options['liAccessTokenSecret'], 1); $msg = nsTrnc($msg, 700); //prr($urlToGo); $urlToGo = urlencode($urlToGo); prr($urlToGo); die(); if ($options['grpID'] != '') { try { if ($msgT == '') { $msgT = ' '; } if ($options['postType'] == 'A') { $ret = $linkedin->postToGroup($msg, $msgT, $options['grpID'], str_replace('&', '&', $urlToGo), $imgURL, $dsc); } else { $ret = $linkedin->postToGroup($msg, $msgT, $options['grpID']); } $liPostID = 'http://www.linkedin.com/groups?gid=' . $options['grpID']; if ($ret == '201') { $ret = array('updateUrl' => $liPostID); } } catch (Exception $o) { $ret = "ERROR: " . print_r($o, true); } } else { //echo $msg ."|". nsTrnc($msgT, 200) ."|". $urlToGo ."|". $imgURL ."|". $dsc; try { if ($options['postType'] == 'A') { $ret = $linkedin->postShare($msg, nsTrnc($msgT, 200), str_replace('&', '&', $urlToGo), $imgURL, $dsc); } else { $ret = $linkedin->postShare($msg); } } catch (Exception $o) { $ret = "ERROR:" . print_r($o, true); } } } if ($liPostID == '') { $liPostID = $options['liUserInfo']; } } // prr($ret); if (!is_array($ret) && stripos($ret, '<update-url>') !== false) { $rurl = CutFromTo($ret, '<update-url>', '</update-url>'); $ret = array('updateUrl' => $rurl); } if (is_array($ret) && !empty($ret['updateUrl'])) { if (stripos($ret['updateUrl'], 'topic=') !== false) { $liPostID = CutFromTo($ret['updateUrl'], 'topic=', '&'); } else { $liPostID = ''; } return array('isPosted' => '1', 'postID' => $liPostID, 'postURL' => $ret['updateUrl'], 'pDate' => date('Y-m-d H:i:s')); } else { $badOut['Error'] .= print_r($ret, true); } return $badOut; }