/** * Perform the main actions of the page. */ protected function action() { function set_cookie($Name, $Value = '', $MaxAge = 0, $Path = '', $Domain = '', $Secure = false, $HTTPOnly = false) { header('Set-Cookie: ' . rawurlencode($Name) . '=' . rawurlencode($Value) . (empty($MaxAge) ? '' : '; Max-Age=' . $MaxAge) . (empty($Path) ? '' : '; path=' . $Path) . (empty($Domain) ? '' : '; domain=' . $Domain) . (!$Secure ? '' : '; secure') . (!$HTTPOnly ? '' : '; HttpOnly'), false); } $url = false; if (!I2CE::getConfig()->setIfIsSet($url, "/modules/DHIS-Dashboard/urls/web_dash") || !$url) { I2CE::raiseError("Bad url for web dashboard: {$url}"); return false; } $myCurl = new MyCurl($url); $myCurl->useAuth(true); $myCurl->setName("admin"); $myCurl->setPass("district"); $myCurl->setPost(true); $myCurl->setIncludeHeader(true); $myCurl->createCurl($url); $data = $myCurl->getWebpage(); // In this case, I am only passing along the PHPSESSID, but you will likely want to pass along everything. $cstart = strpos($data, "JSESSIONID"); $cend = strpos($data, ";", $cstart) - $cstart; $cookie = substr($data, $cstart, $cend); // Likewise. $cookie = explode('=', $cookie); $cookie_domain = false; $cookie_path = false; if (!I2CE::getConfig()->setIfIsSet($cookie_domain, "/modules/DHIS-Dashboard/cookie/domain") || !$domain) { I2CE::raiseError("No domain set for cookie"); return false; } if (!I2CE::getConfig()->setIfIsSet($cookie_path, "/modules/DHIS-Dashboard/cookie/path") || !$path) { I2CE::raiseError("No path set for cookie"); return false; } set_cookie('JSESSIONID', $cookie[1], time() + 6000, $cookie_path, $cookie_domain, 0); //echo $_COOKIE['JSESSIONID']; $this->template->setAttribute("class", "active", "menuDashboard", "a[@href='sagar']"); parent::action(); }
//if we got a url, we'll return a json response if (!empty($_POST['url'])) { //if the url doesn't start with http then add it if (strpos($_POST['url'], 'http') !== 0) { $_POST['url'] = "http://" . $_POST['url']; } //set defaults for json response array $response['tagCount'] = array(); $response['html'] = ""; $response['code'] = "N/A"; $response['message'] = ""; //use php's filter to check for a valid url if (!filter_var($_POST['url'], FILTER_VALIDATE_URL) === false) { $url = $_POST['url']; $curl = new MyCurl($url); $curl->createCurl(); $response['code'] = $curl->getHttpStatus(); $response['message'] = HttpCodes::getType($response['code']); $html = $curl->__toString(); if (!is_string($html)) { $response['message'] = "Page Could not be loaded, check the domain. Nothing was returned."; } else { $tidy = new Tidy(); //load page into tidy object, set options, and clean html $tidy->parseString($html, array('indent' => 2, 'output-xhtml' => true)); $tidy->cleanRepair(); //html is now nicely indented $html = (string) $tidy; //count the tags and get the result in a $tag => $count array $tagCount = countTags($html); $response['tagCount'] = $tagCount;
/** * 得到公众号的AppId和AppSecret,本地可以,服务器失败 * @return Ambigous <unknown, string> */ public function getAppIdSecret() { $url = "https://mp.weixin.qq.com/advanced/advanced?action=dev&t=advanced/dev&token=" . GetWeiXinCookie::$token . "&lang=zh_CN"; $c = new MyCurl($url); $c->setCookie(GetWeiXinCookie::$cookie); $c->createCurl(); $body = $c->getCurlBody(); if ($this->debug) { echo '<br />得到公众号的AppId和AppSecret getHttpStatus:' . $c->getHttpStatus(); echo '<br />得到公众号的AppId和AppSecret cookie:' . GetWeiXinCookie::$cookie; echo '<br />得到公众号的AppId和AppSecret url:' . $url; echo '<br />得到公众号的AppId和AppSecret body:' . $body; } if ($c->getHttpStatus() != "200") { //CURLE_SSL_CONNECT_ERROR(35)出现问题的地方,在SSL / TLS握手。你真正想要的的错误缓冲区和阅读邮件,因为它针对问题稍微。可能是证书(文件格式,路径,权限),密码,和其他人 echo '<br />得到公众号的AppId和AppSecret CURL错误信息:' . $c->getCurlError(); } preg_match("/\\{name:\"AppId\",value:\"(\\w*?)\"\\},\\s*?\\{name:\"AppSecret\",value:\"(\\w*?)\"\\}/", $body, $out); return array('appId' => $out[1], 'appSecret' => $out[2]); }
public function advancedswitchform() { $url = "https://mp.weixin.qq.com/misc/skeyform?form=advancedswitchform&lang=zh_CN"; //关闭编辑模式 $post_query = http_build_query(array('flag' => 0, 'type' => 1, 'token' => $this->_token)); $MyCurl2 = new MyCurl($url); $MyCurl2->setCookie(GetWeiXinCookie::$cookie); $MyCurl2->setPost($post_query); $MyCurl2->setReferer("https://mp.weixin.qq.com/advanced/advanced?action=edit&t=advanced/edit&token=" . $this->_token . "&lang=zh_CN"); $MyCurl2->createCurl(); $res2 = $MyCurl2->getCurlResult(); if ($this->debug) { echo "关闭公众号的编辑模式httpresult:<br/>" . $res2 . "<br/>"; echo '关闭公众号的编辑模式 TOKEN' . $this->_token; } if ($MyCurl2->getHttpStatus() != "200") { echo "关闭公众号的编辑模式, 失败"; echo $res2; exit; } //开启开发者模式 $post_query1 = http_build_query(array('flag' => 1, 'type' => 2, 'token' => $this->_token)); $MyCurl1 = new MyCurl($url); $MyCurl1->setCookie(GetWeiXinCookie::$cookie); $MyCurl1->setPost($post_query1); $MyCurl1->setReferer("https://mp.weixin.qq.com/advanced/advanced?action=dev&t=advanced/dev&token=" . $this->_token . "&lang=zh_CN"); $MyCurl1->createCurl(); $res1 = $MyCurl1->getCurlResult(); if ($this->debug) { echo "开启公众号的开发者模式httpresult:<br/>" . $res1 . "<br/>"; echo "开启公众号的开发者模式TOEKN:" . $this->_token; } if ($MyCurl1->getHttpStatus() != "200") { echo "开启公众号的开发者模式失败"; echo $res1; exit; } }