-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from Cyber-Root0/plano_ensino
feat: plano de ensino | aulas | materiais | resumo
- Loading branch information
Showing
9 changed files
with
490 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{ | ||
"_EventName":"W0008EHISTORYMANAGER.URLCHANGED.", | ||
"_EventGridId":"", | ||
"_EventRowId":"", | ||
"W0005_CMPPGM":"planotitulo.aspx", | ||
"W0008":"TabbedView", | ||
"W0008AV18Tabs_PARM":[ | ||
{ | ||
"Code":"1", | ||
"Description":"Apresentação", | ||
"Link":"planoensino.aspx?1", | ||
"WebComponent":"planoapresentacao.aspx?disciplina" | ||
}, | ||
{ | ||
"Code":"2", | ||
"Description":"Aulas", | ||
"Link":"planoensino.aspx?2", | ||
"WebComponent":"planoaulas.aspx?disciplina" | ||
}, | ||
{ | ||
"Code":"3", | ||
"Description":"Avaliações", | ||
"Link":"planoensino.aspx?3", | ||
"WebComponent":"planoavaliacoes.aspx?disciplina" | ||
}, | ||
{ | ||
"Code":"4", | ||
"Description":"Extra-classe", | ||
"Link":"planoensino.aspx?4", | ||
"WebComponent":"planoextraclasse.aspx?disciplina" | ||
}, | ||
{ | ||
"Code":"5", | ||
"Description":"Material", | ||
"Link":"planoensino.aspx?5", | ||
"WebComponent":"planomaterial.aspx?disciplina" | ||
}, | ||
{ | ||
"Code":"6", | ||
"Description":"Bibliografia", | ||
"Link":"planoensino.aspx?6", | ||
"WebComponent":"planobibliografia.aspx?disciplina" | ||
} | ||
], | ||
"W0008_CMPPGM":"tabbedview.aspx", | ||
"W0008HISTORYMANAGER_Hash":"5", | ||
"GX_AJAX_KEY":"47864ACC55A417C2EF949947B382C5F5", | ||
"AJAX_SECURITY_TOKEN":"FB5B4ADFA5A30DD14923A13AC1AE310451E1781A37B80C1C6CD4572C49B6B46E", | ||
"GX_RES_PROVIDER":"GXResourceProvider.aspx", | ||
"AV5SHOW_ACD_DisciplinaSigla":"disciplina", | ||
"W0008W0013":"planoapresentacao.aspx?disciplina", | ||
"W0008W0013AV39SHOW_ACD_DisciplinaSigla_PARM":"disciplina", | ||
"W0008W0013_CMPPGM":"planoapresentacao.aspx", | ||
"W0008W0013GX_FocusControl":"W0008W0013vACD_PLANOENSINOTITULO", | ||
"W0008W0013AV39SHOW_ACD_DisciplinaSigla":"disciplina", | ||
"AV39SHOW_ACD_DisciplinaSigla":"disciplina" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
/* | ||
* @software API for the Siga Student System | Fatec | ||
* @author Bruno Venancio Alves <boteistem@gmail.com> | ||
* @copyrigh (c) 2023 | ||
* @license Open Software License v. 3.0 (OSL-3.0) | ||
*/ | ||
namespace app\controller\planoensino; | ||
use GuzzleHttp\Client; | ||
trait MethodPlans{ | ||
|
||
public function GetAjaxKey($GXState){ | ||
|
||
$package = json_decode($GXState); | ||
if (!empty($package->GX_AJAX_KEY)){ | ||
return $package->GX_AJAX_KEY; | ||
} | ||
|
||
return false; | ||
|
||
} | ||
public function EncryptAjaxKey($key){ | ||
$URL = GENEXUS_BYPASS."?".http_build_query($this->PackageKey($key)); | ||
return $this->MakeRequest("GET", $URL, []); | ||
|
||
} | ||
private function GetPlan($json, $disciplina, $action_code, $cookie = null){ | ||
|
||
$ajax_key = $this->GetAjaxKey($json); | ||
$bypass_key = $this->EncryptAjaxKey($ajax_key); | ||
$GXState = $this->GetGXState($disciplina, $action_code); | ||
$PLAN_URL = PLANO_ENSINO_URL."?$bypass_key"; | ||
$plan = $this->MakeRequest("POST", $PLAN_URL, array( | ||
"GXState" => $GXState | ||
), $cookie); | ||
|
||
return $plan; | ||
} | ||
|
||
private function MakeRequest(string $method, string $url,array $params = [], $cookie =null){ | ||
$client = new Client(); | ||
$response = $client->request($method, $url, [ | ||
'form_params' => $params, | ||
'headers' => [ | ||
'gxajaxrequest' => '1', | ||
'content-type' => 'application/x-www-form-urlencoded', | ||
], | ||
'cookies' => $cookie, | ||
]); | ||
$body = $response->getBody()->getContents(); | ||
return $body; | ||
|
||
} | ||
|
||
private function GetGXState($disciplina, $action_code){ | ||
|
||
$Gxstate = json_decode(file_get_contents( __DIR__.'/Helper/json.json')); | ||
$GxstateReplaced = $this->ReplaceParamGxstate($Gxstate, $disciplina, $action_code); | ||
return $GxstateReplaced; | ||
|
||
} | ||
|
||
private function ReplaceParamGxstate($content, $disciplina, $action){ | ||
|
||
foreach( $content->W0008AV18Tabs_PARM as $key => $actions ){ | ||
|
||
$webComponent = $content->W0008AV18Tabs_PARM[$key]->WebComponent; | ||
$content->W0008AV18Tabs_PARM[$key]->WebComponent = str_replace("disciplina", $disciplina, $webComponent); | ||
} | ||
|
||
$content->W0008HISTORYMANAGER_Hash = $action; | ||
$content->AV5SHOW_ACD_DisciplinaSigla = $disciplina; | ||
$content->W0008W0013 = str_replace("disciplina", $disciplina, $content->W0008W0013); | ||
$content->W0008W0013AV39SHOW_ACD_DisciplinaSigla_PARM = str_replace("disciplina", $disciplina, $content->W0008W0013AV39SHOW_ACD_DisciplinaSigla_PARM); | ||
$content->W0008W0013AV39SHOW_ACD_DisciplinaSigla = str_replace("disciplina", $disciplina, $content->W0008W0013AV39SHOW_ACD_DisciplinaSigla); | ||
$content->AV39SHOW_ACD_DisciplinaSigla = str_replace("disciplina", $disciplina, $content->AV39SHOW_ACD_DisciplinaSigla); | ||
|
||
return json_encode($content); | ||
} | ||
|
||
private function PackageKey(string $key){ | ||
return array( | ||
"key" => $key, | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<?php | ||
/* | ||
* @software API for the Siga Student System | Fatec | ||
* @author Bruno Venancio Alves <boteistem@gmail.com> | ||
* @copyrigh (c) 2023 | ||
* @license Open Software License v. 3.0 (OSL-3.0) | ||
*/ | ||
namespace app\controller\planoensino\aulas; | ||
use app\core\Controller; | ||
use app\interfaces\ControllerInterface; | ||
use app\classes\Input; | ||
use app\classes\FixJson; | ||
use app\controller\Session\Cookie; | ||
use app\classes\HttpFactory; | ||
use Symfony\Component\DomCrawler\Crawler; | ||
use app\controller\planoensino\MethodPlans; | ||
|
||
Class aulas extends Controller{ | ||
use MethodPlans; | ||
public $uid = null; | ||
public $disciplina = null; | ||
protected $header = "Content-Type:text/html; charset=utf-8"; | ||
protected $http_client = null; | ||
|
||
protected Crawler $crawler; | ||
|
||
protected string $action_code = "2"; | ||
|
||
public function index(){ | ||
|
||
} | ||
|
||
public function __construct(){ | ||
|
||
$this->uid = Input::get("uid"); | ||
$this->disciplina = Input::get("disciplina"); | ||
$this->crawler = new Crawler; | ||
parent::__construct(); | ||
} | ||
|
||
public function get(){ | ||
|
||
|
||
if ($this->status_cookie && !empty($this->disciplina)){ | ||
|
||
$XML_HTML = $this->getContent($this->cookie->getCookie()); | ||
$this->crawler->addHtmlContent($XML_HTML); | ||
$notas = $this->crawler->filter('input[name="GXState"]')->attr('value'); | ||
$json = $this->fixJson($notas); | ||
|
||
$content = $this->GetPlan($json, $this->disciplina, $this->action_code, $this->cookie->getCookie()); | ||
$content = $this->fixJson($content); | ||
$output = $this->trataJson(json_decode($content)); | ||
$this->response($output); | ||
}else{ | ||
|
||
$this->response(array( | ||
"error" => 400, | ||
"msg" => "Crie uma sessão com um usuário válido || Envie o parametro disciplina" | ||
)); | ||
|
||
} | ||
|
||
} | ||
|
||
private function getContent($cookie){ | ||
|
||
$http_client= new HttpFactory( | ||
"GET", | ||
"https://siga.cps.sp.gov.br/aluno/notasparciais.aspx", | ||
null, | ||
null, | ||
$cookie | ||
); | ||
$response= $http_client->request(); | ||
return $response->getBody()->getContents(); | ||
} | ||
|
||
public function Post(){ | ||
|
||
|
||
|
||
} | ||
|
||
|
||
private function trataJson($dados){ | ||
$aulas = array(); | ||
$dados = $dados->gxHiddens->W0008W0013Grid1ContainerDataV; | ||
$dados = json_decode($dados); | ||
foreach($dados as $aula){ | ||
|
||
$aulas[] = array( | ||
"AULA" => $aula[4], | ||
"DESCRICAO" => $aula[11], | ||
"TIPO" => $aula[18], | ||
"DATA" => $aula[34], | ||
"CONTEUDO" => $aula[42], | ||
); | ||
|
||
} | ||
return $aulas; | ||
} | ||
|
||
} |
Oops, something went wrong.