Beispiel #1
0
 function nxs_doPostToSU($msg, $lnk, $cat, $tags, $nsfw = false)
 {
     global $nxs_suCkArray;
     $r2 = wp_remote_get($lnk);
     $hdrsArr = $this->nxs_getSUHeaders('https://www.stumbleupon.com/submit', false, false);
     $ckArr = $nxs_suCkArray;
     $response = wp_remote_get('https://www.stumbleupon.com/submit', array('method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ckArr));
     $ckArr2 = nxsMergeArraysOV($ckArr, $response['cookies']);
     //$nxs_suCkArray = $ckArr;
     $contents = $response['body'];
     //$response['body'] = htmlentities($response['body']);  prr($response);
     //$ckArr = nxsMergeArraysOV($ckArr, $response['cookies']);
     $hdrsArr = $this->nxs_getSUHeaders('https://www.stumbleupon.com/submit', true);
     $frmTxt = CutFromTo($contents, '<form method="post" id="submit-form"', '</form>');
     $md = array();
     $flds = array();
     $mids = '';
     // prr($contents);
     while (stripos($frmTxt, '<input') !== false) {
         $inpField = trim(CutFromTo($frmTxt, '<input', '>'));
         $name = trim(CutFromTo($inpField, 'name="', '"'));
         if (stripos($inpField, '"hidden"') !== false && $name != '' && !in_array($name, $md)) {
             $md[] = $name;
             $val = trim(CutFromTo($inpField, 'value="', '"'));
             $flds[$name] = $val;
             $mids .= "&" . $name . "=" . $val;
         }
         $frmTxt = substr($frmTxt, stripos($frmTxt, '<input') + 8);
     }
     $flds['url'] = $lnk;
     $flds['review'] = $msg;
     $flds['tags'] = $cat;
     $flds['nsfw'] = $nsfw ? 'true' : 'false';
     $flds['user-tags'] = $tags;
     $flds['_output'] = 'Json';
     $flds['_method'] = 'create';
     $flds['language'] = 'EN';
     $r2 = wp_remote_post('https://www.stumbleupon.com/submit', array('method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds, 'cookies' => $ckArr));
     $resp = json_decode($r2['body'], true);
     if (isset($resp['_reason']) && is_array($resp['_reason']) && count($resp['_reason']) > 0 && stripos($resp['_reason'][0]['message'], 'Failed to add URL') !== false) {
         sleep(5);
         $r2 = wp_remote_post('https://www.stumbleupon.com/submit', array('method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds, 'cookies' => $ckArr));
         $resp = json_decode($r2['body'], true);
     }
     if (stripos($resp['_error'], 'Invalid token') !== false) {
         // In case we got the Wrong Cookies
         $r2 = wp_remote_post('https://www.stumbleupon.com/submit', array('method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds, 'cookies' => $ckArr2));
         $resp = json_decode($r2['body'], true);
         if (stripos($resp['_reason'][0]['message'], 'Failed to add URL') !== false) {
             sleep(5);
             $r2 = wp_remote_post('https://www.stumbleupon.com/submit', array('method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds, 'cookies' => $ckArr2));
             $resp = json_decode($r2['body'], true);
             // prr($flds);  prr($resp); //nxs_addToLogN('SU', 'E', '-=DBG=- '.print_r($resp, true)." - #####", $extInfo);
         }
     }
     if (isset($resp['discovery']['publicid'])) {
         $pageID = $resp['discovery']['publicid'];
     } elseif (isset($resp['discovery']['url']['publicid'])) {
         $pageID = $resp['discovery']['url']['publicid'];
     }
     if ($resp['_success'] == '1') {
         $ckArr = nxsMergeArraysOV($ckArr, $r2['cookies']);
         $nxs_suCkArray = $ckArr;
         return array("code" => "OK", "post_id" => $pageID);
     } elseif (isset($resp['_reason'])) {
         $resp['_reason']['NXS_FIELDS'] = $flds;
         $resp['_reason']['NXS_RESP'] = $resp;
         return $resp['_reason'];
     } else {
         return "ERROR" . print_r($resp, true);
     }
 }
Beispiel #2
0
 function nxs_doConnectToVB($u, $p, $url)
 {
     global $nxs_vbCkArray;
     $hdrsArr = $this->nxs_getVBHeaders($url);
     $mids = '';
     //   echo "LOGGIN";
     $response = wp_remote_get($url, array('method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => ''));
     if (is_wp_error($response)) {
         return "Invalid Connection. " . print_r($response, true);
     }
     $contents = $response['body'];
     //$response['body'] = htmlentities($response['body']);  prr($response);    die();
     $ckArr = $response['cookies'];
     $mdhashLoc = stripos($contents, 'md5hash(vb_login_password');
     if ($mdhashLoc === false) {
         return "No VB found";
     }
     $frmTxt = CutFromTo($contents, 'md5hash(vb_login_password', '</form>');
     $md = array();
     $flds = array();
     while (stripos($frmTxt, '<input') !== false) {
         $inpField = trim(CutFromTo($frmTxt, '<input', '>'));
         $name = trim(CutFromTo($inpField, 'name="', '"'));
         if (stripos($inpField, '"hidden"') !== false && $name != '' && !in_array($name, $md)) {
             $md[] = $name;
             $val = trim(CutFromTo($inpField, 'value="', '"'));
             $flds[$name] = $val;
             $mids .= "&" . $name . "=" . $val;
         }
         $frmTxt = substr($frmTxt, stripos($frmTxt, '<input') + 8);
     }
     $flds['vb_login_username'] = $u;
     $flds['vb_login_md5password'] = md5($p);
     $flds['vb_login_md5password_utf'] = md5($p);
     $flds['cookieuser'] = '******';
     $flds['do'] = 'login';
     // $logURL = substr($contents, $mdhashLoc-250, 250); $logURL = CutFromTo($logURL, 'action="', '"');
     if (stripos($contents, 'base href="') !== false) {
         $baseURL = trim(CutFromTo($contents, 'base href="', '"'));
     } else {
         $uarr = explode('/', $url);
         $dd = $uarr[count($uarr) - 1];
         $baseURL = str_replace($dd, '', $url);
     }
     $hdrsArr = $this->nxs_getVBHeaders($url, true);
     $r2 = wp_remote_post($baseURL . 'login.php?do=login', array('method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds, 'cookies' => $ckArr));
     // prr($r2);
     if (stripos($r2['body'], 'exec_refresh()') !== false) {
         $ckArr = nxsMergeArraysOV($ckArr, $r2['cookies']);
         $nxs_vbCkArray = $ckArr;
         return false;
     } else {
         return "Bad Username/Password";
     }
 }
Beispiel #3
0
 function nxsMergeArraysOV($Arr1, $Arr2)
 {
     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;
 }
 function NS_SNAP_SavePostMetaTags($id)
 {
     global $nxs_snapAvNts, $plgn_NS_SNAutoPoster;
     if (!empty($_POST['nxs_snapPostOptions'])) {
         $NXS_POSTX = $_POST['nxs_snapPostOptions'];
         $NXS_POST = array();
         $NXS_POST = NXS_parseQueryStr($NXS_POSTX);
     } else {
         $NXS_POST = $_POST;
     }
     if (count($NXS_POST) < 1 || !isset($NXS_POST["snapEdIT"]) || empty($NXS_POST["snapEdIT"])) {
         return;
     }
     if (get_magic_quotes_gpc() || !empty($_POST['nxs_mqTest']) && $_POST['nxs_mqTest'] == "\\'") {
         array_walk_recursive($NXS_POST, 'nsx_stripSlashes');
     }
     array_walk_recursive($NXS_POST, 'nsx_fixSlashes');
     if (!isset($plgn_NS_SNAutoPoster)) {
         return;
     }
     $options = $plgn_NS_SNAutoPoster->nxs_options;
     //  echo "| NS_SNAP_SavePostMetaTags - ".$id." |";
     $post = get_post($id);
     if ($post->post_type == 'revision' && $post->post_status == 'inherit' && $post->post_parent != '0') {
         return;
     }
     // prr($NXS_POST);
     if (empty($NXS_POST["useSURL"])) {
         $NXS_POST["useSURL"] = '2';
     }
     delete_post_meta($id, '_snap_forceSURL');
     add_post_meta($id, '_snap_forceSURL', $NXS_POST["useSURL"]);
     delete_post_meta($id, 'snap_MYURL');
     add_post_meta($id, 'snap_MYURL', $NXS_POST["urlToUse"]);
     delete_post_meta($id, 'snapEdIT');
     add_post_meta($id, 'snapEdIT', '1');
     $snap_isAutoPosted = get_post_meta($id, 'snap_isAutoPosted', true);
     if ($snap_isAutoPosted == '1' && $post->post_status == 'future') {
         delete_post_meta($id, 'snap_isAutoPosted');
         add_post_meta($id, 'snap_isAutoPosted', '2');
     }
     foreach ($nxs_snapAvNts as $avNt) {
         // echo "--------------------------------------------";  prr($avNt);
         if (isset($options[$avNt['lcode']]) && count($options[$avNt['lcode']]) > 0 && isset($NXS_POST[$avNt['lcode']]) && count($NXS_POST[$avNt['lcode']]) > 0) {
             $savedMeta = maybe_unserialize(get_post_meta($id, 'snap' . $avNt['code'], true));
             if (is_array($NXS_POST[$avNt['lcode']])) {
                 $ii = 0;
                 foreach ($NXS_POST[$avNt['lcode']] as $pst) {
                     // echo "###########";  prr($pst);
                     if (is_array($pst) && empty($pst['do' . $avNt['code']]) && empty($NXS_POST[$avNt['lcode']][$ii]['do' . $avNt['code']])) {
                         $NXS_POST[$avNt['lcode']][$ii]['do' . $avNt['code']] = 0;
                     }
                     $ii++;
                 }
             }
             $newMeta = $NXS_POST[$avNt['lcode']];
             if (is_array($savedMeta) && is_array($newMeta)) {
                 $newMeta = nxsMergeArraysOV($savedMeta, $newMeta);
             }
             // echo "#####~~~~~~~~~ ".$id."| snap".$avNt['code']; prr($savedMeta); echo "||"; prr($newMeta);// $newMeta = 'AAA';
             delete_post_meta($id, 'snap' . $avNt['code']);
             add_post_meta($id, 'snap' . $avNt['code'], str_replace('\\', '\\\\', serialize($newMeta)));
         }
     }
     //    die();
     // prr($_POST);
 }
Beispiel #5
0
 function NS_SNAP_SavePostMetaTags($id)
 {
     global $nxs_snapAvNts, $plgn_NS_SNAutoPoster;
     if (!isset($plgn_NS_SNAutoPoster)) {
         return;
     }
     $options = $plgn_NS_SNAutoPoster->nxs_options;
     //  echo "| NS_SNAP_SavePostMetaTags - ".$id." |";
     $post = get_post($id);
     if ($post->post_type == 'revision' && $post->post_status == 'inherit' && $post->post_parent != '0') {
         return;
     }
     if (isset($_POST["snapEdIT"])) {
         $nspost_edit = $_POST["snapEdIT"];
     }
     //echo "| snapEdIT |";  // prr($nspost_edit);
     if (get_magic_quotes_gpc() || $_POST['nxs_mqTest'] == "\\'") {
         array_walk_recursive($_POST, 'nsx_stripSlashes');
     }
     $snap_isAutoPosted = get_post_meta($id, 'snap_isAutoPosted', true);
     if ($snap_isAutoPosted == '1' && $post->post_status == 'future') {
         delete_post_meta($id, 'snap_isAutoPosted');
         add_post_meta($id, 'snap_isAutoPosted', '2');
     }
     if (isset($nspost_edit) && !empty($nspost_edit)) {
         delete_post_meta($id, 'snapEdIT');
         add_post_meta($id, 'snapEdIT', '1');
         foreach ($nxs_snapAvNts as $avNt) {
             if (count($options[$avNt['lcode']]) > 0 && isset($_POST[$avNt['lcode']]) && count($_POST[$avNt['lcode']]) > 0) {
                 $savedMeta = maybe_unserialize(get_post_meta($id, 'snap' . $avNt['code'], true));
                 if (is_array($_POST[$avNt['lcode']])) {
                     $ii = 0;
                     foreach ($_POST[$avNt['lcode']] as $pst) {
                         // echo "#############################################################################";  prr($pst);
                         if (is_array($pst) && $pst['do' . $avNt['code']] == '' && $_POST[$avNt['lcode']][$ii]['do' . $avNt['code']] == '') {
                             $_POST[$avNt['lcode']][$ii]['do' . $avNt['code']] = 0;
                         }
                         $ii++;
                     }
                 }
                 $newMeta = $_POST[$avNt['lcode']];
                 if (is_array($savedMeta) && is_array($newMeta)) {
                     $newMeta = nxsMergeArraysOV($savedMeta, $newMeta);
                 }
                 // echo "##### ".$id."| snap".$avNt['code']; prr($savedMeta); echo "||"; prr($newMeta);// $newMeta = 'AAA';
                 delete_post_meta($id, 'snap' . $avNt['code']);
                 add_post_meta($id, 'snap' . $avNt['code'], serialize($newMeta));
             }
         }
     }
     // prr($_POST);
 }