/** * 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(); }
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; } }