Initial commit
This commit is contained in:
11
plugins/AsdCurl/README.md
Normal file
11
plugins/AsdCurl/README.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# AsdCurl plugin for CakePHP
|
||||
|
||||
## Installation
|
||||
|
||||
You can install this plugin into your CakePHP application using [composer](http://getcomposer.org).
|
||||
|
||||
The recommended way to install composer packages is:
|
||||
|
||||
```
|
||||
composer require your-name-here/AsdCurl
|
||||
```
|
||||
23
plugins/AsdCurl/composer.json
Normal file
23
plugins/AsdCurl/composer.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "your-name-here/AsdCurl",
|
||||
"description": "AsdCurl plugin for CakePHP",
|
||||
"type": "cakephp-plugin",
|
||||
"require": {
|
||||
"php": ">=5.5.9",
|
||||
"cakephp/cakephp": ">=3.3.2 <4.0.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "*"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"AsdCurl\\": "src"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"AsdCurl\\Test\\": "tests",
|
||||
"Cake\\Test\\": "./vendor/cakephp/cakephp/tests"
|
||||
}
|
||||
}
|
||||
}
|
||||
35
plugins/AsdCurl/config/bootstrap.php
Normal file
35
plugins/AsdCurl/config/bootstrap.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Cake\Core\Configure;
|
||||
use Cake\Core\Configure\Engine\PhpConfig;
|
||||
|
||||
try {
|
||||
Configure::config('default', new PhpConfig());
|
||||
Configure::load('app', 'default', false);
|
||||
} catch (\Exception $e) {
|
||||
exit($e->getMessage() . "\n");
|
||||
}
|
||||
|
||||
//define('SCHULPORTAL_BASE0_URL', "https://portal.schulen.bayern.de");
|
||||
//define('SCHULPORTAL_BASE_URL', SCHULPORTAL_BASE0_URL . '/uniquesig2d1dfad4a11c25e42c462e53b4721e48/uniquesig0');
|
||||
//define('SCHULPORTAL_ASD_BASE_URL', SCHULPORTAL_BASE0_URL . '/uniquesigc3ba1685059aaf325d44099df697a0a635e79a4ec36ec614a98f3bf4b79d7c043ac3880605b7751df91d11233380ad86/uniquesig0/asd');
|
||||
define('SCHULPORTAL_ASD_BASE_URL', 'http://192.168.56.3:8280/asd');
|
||||
|
||||
|
||||
|
||||
//Configure::write('AsdCurl.proxy','10.1.248.1:82');
|
||||
//Configure::write('AsdCurl.cookiejar', '/tmp/cookies.txt');
|
||||
//Configure::write('AsdCurl.cookiefile', '/tmp/cookies.txt');
|
||||
Configure::write('AsdCurl.cookiejar', 'C:/xampp/tmp/cookies.txt');
|
||||
Configure::write('AsdCurl.cookiefile', 'C:/xampp/tmp/cookies.txt');
|
||||
|
||||
Configure::write('AsdCurl.cookie', 'cookiename=cookievalue');
|
||||
Configure::write('AsdCurl.useragent', 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0');
|
||||
Configure::write('AsdCurl.cert','C:/xampp/htdocs/ssl_KM_Z2016_asd.trinkl.pem');
|
||||
//Configure::write('AsdCurl.schulbase0url',SCHULPORTAL_BASE0_URL);
|
||||
//Configure::write('AsdCurl.schulbaseurl',SCHULPORTAL_BASE_URL);
|
||||
Configure::write('AsdCurl.asdbaseurl',SCHULPORTAL_ASD_BASE_URL);
|
||||
|
||||
|
||||
?>
|
||||
|
||||
12
plugins/AsdCurl/config/routes.php
Normal file
12
plugins/AsdCurl/config/routes.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
use Cake\Routing\RouteBuilder;
|
||||
use Cake\Routing\Router;
|
||||
use Cake\Routing\Route\DashedRoute;
|
||||
|
||||
Router::plugin(
|
||||
'AsdCurl',
|
||||
['path' => '/asd-curl'],
|
||||
function (RouteBuilder $routes) {
|
||||
$routes->fallbacks(DashedRoute::class);
|
||||
}
|
||||
);
|
||||
43
plugins/AsdCurl/phpunit.xml.dist
Normal file
43
plugins/AsdCurl/phpunit.xml.dist
Normal file
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit
|
||||
colors="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
syntaxCheck="false"
|
||||
bootstrap="./tests/bootstrap.php"
|
||||
>
|
||||
<php>
|
||||
<ini name="memory_limit" value="-1"/>
|
||||
<ini name="apc.enable_cli" value="1"/>
|
||||
</php>
|
||||
|
||||
<!-- Add any additional test suites you want to run here -->
|
||||
<testsuites>
|
||||
<testsuite name="AsdCurl Test Suite">
|
||||
<directory>./tests/TestCase</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<!-- Setup a listener for fixtures -->
|
||||
<listeners>
|
||||
<listener
|
||||
class="\Cake\TestSuite\Fixture\FixtureInjector"
|
||||
file="./vendor/cakephp/cakephp/src/TestSuite/Fixture/FixtureInjector.php">
|
||||
<arguments>
|
||||
<object class="\Cake\TestSuite\Fixture\FixtureManager" />
|
||||
</arguments>
|
||||
</listener>
|
||||
</listeners>
|
||||
|
||||
<!-- Prevent coverage reports from looking in tests and vendors -->
|
||||
<filter>
|
||||
<blacklist>
|
||||
<directory suffix=".php">./vendor/</directory>
|
||||
<directory suffix=".ctp">./vendor/</directory>
|
||||
|
||||
<directory suffix=".php">./tests/</directory>
|
||||
<directory suffix=".ctp">./tests/</directory>
|
||||
</blacklist>
|
||||
</filter>
|
||||
|
||||
</phpunit>
|
||||
198
plugins/AsdCurl/src/AsdCurl.php
Normal file
198
plugins/AsdCurl/src/AsdCurl.php
Normal file
@@ -0,0 +1,198 @@
|
||||
<?php
|
||||
namespace AsdCurl;
|
||||
|
||||
use Cake\Core\Configure;
|
||||
|
||||
|
||||
|
||||
class AsdCurl
|
||||
{
|
||||
public $status;
|
||||
public $error;
|
||||
public $html;
|
||||
public $message;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->status = false;
|
||||
$this->error = false;
|
||||
$this->html = '';
|
||||
$this->message = '';
|
||||
}
|
||||
|
||||
public function init_curl_params()
|
||||
{
|
||||
$ch = curl_init();
|
||||
//curl_setopt($ch, CURLOPT_PROXY, Configure::read('AsdCurl.proxy'));
|
||||
curl_setopt($ch, CURLOPT_PROXY, false);
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, Configure::read('AsdCurl.useragent'));
|
||||
curl_setopt($ch, CURLOPT_HEADER, false);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
|
||||
curl_setopt($ch, CURLOPT_COOKIEJAR, Configure::read('AsdCurl.cookiejar'));
|
||||
curl_setopt($ch, CURLOPT_COOKIEFILE, Configure::read('AsdCurl.cookiefile'));
|
||||
curl_setopt($ch, CURLOPT_COOKIE, Configure::read('AsdCurl.cookie'));
|
||||
//curl_setopt($ch, CURLOPT_SSLCERT, Configure::read('AsdCurl.cert'));
|
||||
//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
return ($ch);
|
||||
}
|
||||
|
||||
public function get_string_between($string, $start, $end)
|
||||
{
|
||||
//debug($start);
|
||||
//debug($end);
|
||||
$string = " " . $string;
|
||||
$ini = strpos($string, $start);
|
||||
//debug($ini);
|
||||
//debug($string);die;
|
||||
if ($ini == 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
$ini += strlen($start);
|
||||
$len = strpos($string, $end, $ini) - $ini;
|
||||
$sub = substr($string, $ini, $len);
|
||||
$elem = explode(' ', $sub)[0];
|
||||
return str_replace('"', '', $elem);
|
||||
}
|
||||
|
||||
public function exec_curl($ch, $url, $post)
|
||||
{
|
||||
if ($post == false) {
|
||||
curl_setopt($ch, CURLOPT_POST, 0);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array());
|
||||
} else {
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
$this->html = curl_exec($ch);
|
||||
//debug(curl_errno($ch));
|
||||
//debug(curl_getinfo($ch, CURLINFO_HTTP_CODE));
|
||||
if (curl_errno($ch)) {
|
||||
$this->status = false;
|
||||
$this->error = 'Couldn\'t send request: ' . curl_error($ch);
|
||||
} else {
|
||||
$resultStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
if ($resultStatus != 200) {
|
||||
$this->status = false;
|
||||
$this->error = 'Request failed: HTTP status code: ' . $resultStatus;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function login_asd($ch)
|
||||
{
|
||||
$SCHULPORTAL_ASD_BASE_URL = Configure::read('AsdCurl.asdbaseurl');
|
||||
$this->exec_curl($ch, $SCHULPORTAL_ASD_BASE_URL . '/asddv/dv_xy_00.jsf', false);
|
||||
if(!($this->status)) {
|
||||
die($this->error);
|
||||
}
|
||||
$viewstate = $this->get_string_between($this->html, 'id="javax.faces.ViewState" value="', '" autocomplete');
|
||||
|
||||
$login_data = [
|
||||
//'asd_username' => 'A005_TrinklW',
|
||||
//'asd_password' => 'HiegTzs!12',
|
||||
'asd_username' => 'A005_Superuser',
|
||||
'asd_password' => 'asdtest01',
|
||||
];
|
||||
$post = [
|
||||
'login:username' => $login_data['asd_username'],
|
||||
'login:password' => $login_data['asd_password'],
|
||||
'login' => 'login',
|
||||
'javax.faces.ViewState' => $viewstate,
|
||||
'login:loginButton' => 'login:loginButton',
|
||||
];
|
||||
//debug($SCHULPORTAL_ASD_BASE_URL . '/login/login.jsf');die;
|
||||
|
||||
$this->exec_curl($ch, $SCHULPORTAL_ASD_BASE_URL . '/login/login.jsf', $post);
|
||||
if(!($this->status)) {
|
||||
die($this->error);
|
||||
}
|
||||
$viewstate = $this->get_string_between($this->html, 'id="javax.faces.ViewState" value="', '" autocomplete');
|
||||
Configure::write('Session', ['viewstate' => $viewstate]);
|
||||
}
|
||||
|
||||
public function login_mstr($ch) {
|
||||
$SCHULPORTAL_MSTR_BASE_URL = Configure::read('AsdCurl.mstrbaseurl');
|
||||
$url = '/asp';
|
||||
//debug($SCHULPORTAL_MSTR_BASE_URL . $url);die;
|
||||
$this->exec_curl($ch, $SCHULPORTAL_MSTR_BASE_URL . $url, false);
|
||||
|
||||
//debug($this->html);die;
|
||||
|
||||
$post = [
|
||||
'Uid' => 'A005_TrinklW',
|
||||
'Pwd' => 'HiegTzs!12',
|
||||
];
|
||||
$pvar['ConnMode'] = $this->get_string_between($this->html, '<input name="ConnMode" id="ConnMode" type="hidden" class="mstrHiddenInput" value="', '"/>');
|
||||
$pvar['3054'] = $this->get_string_between($this->html, '<input name="3054" id="3054" type="submit" value="', '" class="mstrButton"/>');
|
||||
$mstr_login_vars = array('evt', 'src', 'target', 'key', 'Port', 'Project', 'Server', 'login', 'smartBanner', 'lb');
|
||||
foreach ($mstr_login_vars as $var) {
|
||||
$value = $this->get_string_between($this->html, 'name="' . $var . '" type="hidden" class="mstrHiddenInput" value="', '"/>');
|
||||
//$value = $this->get_string_between($this->html, 'name="' . $var . '" value=', 'type="hidden"');
|
||||
$pvar[$var] = $value;
|
||||
}
|
||||
|
||||
$post = array_merge($post, $pvar);
|
||||
//debug($post);die;
|
||||
$this->exec_curl($ch, $SCHULPORTAL_MSTR_BASE_URL . '/asp/Main.aspx', $post);
|
||||
if(strpos($this->html,'Login failure')) {
|
||||
$this->status = false;
|
||||
}
|
||||
//debug($this->html);die;
|
||||
}
|
||||
|
||||
public function logout_mstr($ch) {
|
||||
$SCHULPORTAL_MSTR_BASE_URL = Configure::read('AsdCurl.mstrbaseurl');
|
||||
$url = '/asp/Main.aspx';
|
||||
$post = [
|
||||
'evt' => '3008',
|
||||
'src' => 'mstrWeb.3008',
|
||||
'xts' => exec('date +%s%3N'),
|
||||
];
|
||||
$this->exec_curl($ch, $SCHULPORTAL_MSTR_BASE_URL . $url, $post);
|
||||
curl_close($ch);
|
||||
}
|
||||
|
||||
public function login_school($ch)
|
||||
{
|
||||
$SCHULPORTAL_BASE0_URL = Configure::read('AsdCurl.schulbase0url');
|
||||
$SCHULPORTAL_BASE_URL = Configure::read('AsdCurl.schulbaseurl');
|
||||
//$login_data = $this->request->session()->read('data');
|
||||
|
||||
$this->exec_curl($ch, $SCHULPORTAL_BASE_URL, false);
|
||||
if(!($this->status)) {
|
||||
die($this->error);
|
||||
}
|
||||
$login_data = [
|
||||
'portal_username' => 'asd.trinkl',
|
||||
'portal_password' => 'HiegTzs!181',
|
||||
];
|
||||
|
||||
$post = [
|
||||
'user_name' => $login_data['portal_username'],
|
||||
'password' => $login_data['portal_password'],
|
||||
'repository' => 'schulen.bayern.de',
|
||||
'site_name' => 'schulportal',
|
||||
'secure' => '1',
|
||||
'resource_id' => '2',
|
||||
'login_type' => '2',
|
||||
];
|
||||
// Anmeldeformular fuer das Schulportal abschicken - Step 2
|
||||
|
||||
$this->exec_curl($ch, $SCHULPORTAL_BASE_URL . '/InternalSite/Validate.asp', $post);
|
||||
if(!($this->status)) {
|
||||
die($this->error);
|
||||
}
|
||||
}
|
||||
|
||||
public function exec_mstr($ch, $url, $post)
|
||||
{
|
||||
$SCHULPORTAL_MSTR_BASE_URL = Configure::read('AsdCurl.mstrbaseurl');
|
||||
$html = $this->exec_curl($ch, $SCHULPORTAL_MSTR_BASE_URL . $url, $post);
|
||||
return ($html);
|
||||
}
|
||||
}
|
||||
336
plugins/AsdCurl/src/AsdUp.php
Normal file
336
plugins/AsdCurl/src/AsdUp.php
Normal file
@@ -0,0 +1,336 @@
|
||||
<?php
|
||||
|
||||
namespace AsdCurl;
|
||||
|
||||
use App\Controller\AppController;
|
||||
use Cake\ORM\TableRegistry;
|
||||
use AsdCurl\AsdCurl;
|
||||
use Cake\Core\Configure;
|
||||
use Cake\I18n\Time;
|
||||
|
||||
class AsdUp extends AsdCurl
|
||||
{
|
||||
public function __construct($url = null)
|
||||
{
|
||||
$this->status = true;
|
||||
$this->error = false;
|
||||
}
|
||||
|
||||
public function change_school($ch,$snr) {
|
||||
$SCHULPORTAL_ASD_BASE_URL = Configure::read('AsdCurl.asdbaseurl');
|
||||
// Schule wechseln
|
||||
$viewstate = $this->get_string_between($this->html, 'id="javax.faces.ViewState" value="', '" autocomplete');
|
||||
$conversationId = $this->get_string_between($this->html, 'name="conversationId" value="', '" />');
|
||||
|
||||
$post = [
|
||||
'mainForm' => 'mainForm',
|
||||
'referenzBaumAnzeigen' => 'false',
|
||||
'conversationId' => $conversationId,
|
||||
'changeNotification' => 'true',
|
||||
'mainForm:hasChanged' => 'false',
|
||||
'mainForm:hasNotReleased' => 'false',
|
||||
'mainForm:hasPopUpChanged' => 'false',
|
||||
'mainForm:hasAdresseChanged' => 'false',
|
||||
'mainForm:confirmedOverride' => 'true',
|
||||
'mainForm:zuordnungNotification' => 'false',
|
||||
'skipvalidation' => 'true',
|
||||
'mainForm:istAnzeigeMaske' => 'false',
|
||||
'mainForm:schulnr' => $snr,
|
||||
'mainForm:action_anzeigen' => 'Direkt zur gewählten Schule',
|
||||
'mainForm:schuljahr' => '23',
|
||||
'javax.faces.ViewState' => $viewstate
|
||||
];
|
||||
|
||||
$this->exec_curl($ch, $SCHULPORTAL_ASD_BASE_URL . '/asdbu/up_07_50.jsf?cid=' . $conversationId, $post);
|
||||
if(!($this->status)) {
|
||||
die($this->error);
|
||||
}
|
||||
echo $this->html;die;
|
||||
}
|
||||
|
||||
public function goto_budget($ch,$budget) {
|
||||
$SCHULPORTAL_ASD_BASE_URL = Configure::read('AsdCurl.asdbaseurl');
|
||||
// Reiter Unterrichtsplanung aufrufen
|
||||
$viewstate = $this->get_string_between($this->html, 'id="javax.faces.ViewState" value="', '" autocomplete');
|
||||
$conversationId = $this->get_string_between($this->html, 'name="conversationId" value="', '" />');
|
||||
|
||||
$post = [
|
||||
'headerMenu' => 'headerMenu',
|
||||
'javax.faces.ViewState' => $viewstate,
|
||||
'headerMenu:j_idt29' => 'headerMenu:j_idt29'
|
||||
];
|
||||
$this->exec_curl($ch, $SCHULPORTAL_ASD_BASE_URL . '/asdbv/bv_01_02.jsf?cid=' . $conversationId, $post);
|
||||
if(!($this->status)) {
|
||||
die($this->error);
|
||||
}
|
||||
// Im linken Menue Budget GY anzeigen
|
||||
$viewstate = $this->get_string_between($this->html, 'id="javax.faces.ViewState" value="', '" autocomplete');
|
||||
$conversationId = $this->get_string_between($this->html, 'name="conversationId" value="', '" />');
|
||||
|
||||
$post = [
|
||||
'sideMenu' => 'sideMenu',
|
||||
'javax.faces.ViewState' => $viewstate,
|
||||
'sideMenu:j_idt52:1:j_idt58:6:j_idt60' => 'sideMenu:j_idt52:1:j_idt58:6:j_idt60'
|
||||
];
|
||||
$this->exec_curl($ch, $SCHULPORTAL_ASD_BASE_URL . '/asdup/up_00_00.jsf?cid=' . $conversationId, $post);
|
||||
if(!($this->status)) {
|
||||
die($this->error);
|
||||
}
|
||||
|
||||
// Schule auswählen
|
||||
$viewstate = $this->get_string_between($this->html, 'id="javax.faces.ViewState" value="', '" autocomplete');
|
||||
$conversationId = $this->get_string_between($this->html, 'name="conversationId" value="', '" />');
|
||||
|
||||
$post = [
|
||||
'mainForm' => 'mainForm',
|
||||
'referenzBaumAnzeigen' => 'false',
|
||||
'conversationId' => $conversationId,
|
||||
'changeNotification' => 'true',
|
||||
'mainForm:hasChanged' => 'false',
|
||||
'mainForm:hasNotReleased' => 'false',
|
||||
'mainForm:hasPopUpChanged' => 'false',
|
||||
'mainForm:hasAdresseChanged' => 'false',
|
||||
'mainForm:confirmedOverride' => 'true',
|
||||
'mainForm:zuordnungNotification' => 'false',
|
||||
'skipvalidation' => 'false',
|
||||
'mainForm:istAnzeigeMaske' => 'false',
|
||||
'mainForm:nameOffiziell' => 'Bayer.Staatsministerium für Unterricht und Kultus München',
|
||||
'mainForm:schulstellePlzStrasse' => '80333',
|
||||
'mainForm:schulstelleOrt' => 'München',
|
||||
'mainForm:schulnummer' => $budget['snr'],
|
||||
'mainForm:action_anzeigen' => 'Direkt zur gewählten Schule',
|
||||
'javax.faces.ViewState' => $viewstate
|
||||
];
|
||||
$this->exec_curl($ch, $SCHULPORTAL_ASD_BASE_URL . '/asdbu/up_07_51.jsf?cid=' . $conversationId, $post);
|
||||
if(!($this->status)) {
|
||||
die($this->error);
|
||||
}
|
||||
|
||||
// Auf anderen Reiter wechseln
|
||||
$viewstate = $this->get_string_between($this->html, 'id="javax.faces.ViewState" value="', '" autocomplete');
|
||||
$conversationId = $this->get_string_between($this->html, 'name="conversationId" value="', '" />');
|
||||
|
||||
$post = [
|
||||
'mainForm' => 'mainForm',
|
||||
'referenzBaumAnzeigen' => 'false',
|
||||
'conversationId' => $conversationId,
|
||||
'changeNotification' => 'true',
|
||||
'mainForm:hasChanged' => 'false',
|
||||
'mainForm:hasNotReleased' => 'false',
|
||||
'mainForm:hasPopUpChanged' => 'false',
|
||||
'mainForm:hasAdresseChanged' => 'false',
|
||||
'mainForm:confirmedOverride' => 'true',
|
||||
'mainForm:zuordnungNotification' => 'false',
|
||||
'skipvalidation' => 'false',
|
||||
'mainForm:istAnzeigeMaske' => 'false',
|
||||
'mainForm:schulnr' => '',
|
||||
'mainForm:schuljahr' => '23',
|
||||
'mainForm:schulnummer' => $budget['snr'],
|
||||
'mainForm:tabs.1' => 'Budgetzuschläge',
|
||||
'javax.faces.ViewState' => $viewstate
|
||||
];
|
||||
$this->exec_curl($ch, $SCHULPORTAL_ASD_BASE_URL . '/asdbu/up_07_50.jsf?cid=' . $conversationId, $post);
|
||||
if(!($this->status)) {
|
||||
die($this->error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function read_budget($ch,$snr) {
|
||||
$SCHULPORTAL_ASD_BASE_URL = Configure::read('AsdCurl.asdbaseurl');
|
||||
$htmlParser = new \DOMDocument(); //to parse html using DOMDocument
|
||||
libxml_use_internal_errors(true); // your HTML gives parser warnings, keep them internal
|
||||
$htmlParser->loadHTML($this->html); //Loaded the html string we took from simple xml
|
||||
$htmlParser->preserveWhiteSpace = false;
|
||||
|
||||
$headers = ['checkbox','herkunft','budget','von','bis','count','comment'];
|
||||
$table = $htmlParser->getElementById('mainForm:dataTable:zuschlaege');
|
||||
|
||||
$rows = $table->getElementsByTagName('tr');
|
||||
|
||||
for($i=0;$i < (sizeof($rows)-1);$i++) {
|
||||
$cols = $rows[$i]->getElementsByTagName('td');
|
||||
$j = 0;
|
||||
foreach($cols as $col) {
|
||||
$span = $col->getElementsByTagName('span');
|
||||
//debug(sizeof($span));
|
||||
if(sizeof($span) > 0) {
|
||||
$data[$i][$headers[$j]] = $span->item(0)->nodeValue;
|
||||
}
|
||||
$j++;
|
||||
}
|
||||
}
|
||||
$cols = $rows[sizeof($rows)-1]->getElementsByTagName('td');
|
||||
$span = $cols[1]->getElementsByTagName('span');
|
||||
$sum = $span->item(0)->nodeValue;
|
||||
//$data['sum'] = $sum;
|
||||
return($data);
|
||||
}
|
||||
|
||||
public function del_all_budget($ch,$snr) {
|
||||
//debug($snr);
|
||||
//echo($this->html);
|
||||
$SCHULPORTAL_ASD_BASE_URL = Configure::read('AsdCurl.asdbaseurl');
|
||||
|
||||
$htmlParser = new \DOMDocument(); //to parse html using DOMDocument
|
||||
libxml_use_internal_errors(true); // your HTML gives parser warnings, keep them internal
|
||||
$htmlParser->loadHTML($this->html); //Loaded the html string we took from simple xml
|
||||
$htmlParser->preserveWhiteSpace = false;
|
||||
|
||||
$table = $htmlParser->getElementById('mainForm:dataTable:zuschlaege');
|
||||
|
||||
$rows = $table->getElementsByTagName('tr');
|
||||
$to_del = array();
|
||||
for($i=1;$i < sizeof($rows);$i++) {
|
||||
$cols = $rows[$i]->getElementsByTagName('td');
|
||||
debug(Sizeof($cols));
|
||||
$herkunft = $cols[1]->getElementsByTagName('span')->item(0)->nodeValue;
|
||||
debug($herkunft);
|
||||
if($herkunft == 'ASD') {
|
||||
array_push($to_del,$i);
|
||||
}
|
||||
}
|
||||
debug($to_del);
|
||||
//die;
|
||||
|
||||
$viewstate = $this->get_string_between($this->html, 'id="javax.faces.ViewState" value="', '" autocomplete');
|
||||
$conversationId = $this->get_string_between($this->html, 'name="conversationId" value="', '" />');
|
||||
|
||||
$post = [
|
||||
'mainForm' => 'mainForm',
|
||||
'referenzBaumAnzeigen' => 'false',
|
||||
'conversationId' => $conversationId,
|
||||
'changeNotification' => 'true',
|
||||
'mainForm:hasChanged' => 'true',
|
||||
'mainForm:hasNotReleased' => 'false',
|
||||
'mainForm:hasPopUpChanged' => 'false',
|
||||
'mainForm:hasAdresseChanged' => 'false',
|
||||
'mainForm:confirmedOverride' => 'true',
|
||||
'mainForm:zuordnungNotification' => 'false',
|
||||
'skipvalidation' => 'false',
|
||||
'mainForm:istAnzeigeMaske' => 'false',
|
||||
'mainForm:schulnr' => '',
|
||||
'mainForm:schuljahr' => '23',
|
||||
'mainForm:schulnummer' => $snr,
|
||||
'mainForm:tab2:artZuschlag' => 'com.hp.asd.wl.domain.standard.Budgetform:1502',
|
||||
'mainForm:tab2:datumBis' => '31.07.2019',
|
||||
'mainForm:tab2:_edit_budget' => '',
|
||||
'mainForm:tab2:_edit_bemerkung' => '',
|
||||
'mainForm:loeschen' => 'Löschen',
|
||||
'javax.faces.ViewState' => $viewstate
|
||||
];
|
||||
foreach($to_del as $value) {
|
||||
$post['mainForm:tab2:_' . $value .'_select'] = 'on';
|
||||
}
|
||||
//debug($post);die;
|
||||
$this->exec_curl($ch, $SCHULPORTAL_ASD_BASE_URL . '/asdbu/up_07_50.jsf?cid=' . $conversationId, $post);
|
||||
if(!($this->status)) {
|
||||
die($this->error);
|
||||
}
|
||||
|
||||
// Budget speichern
|
||||
$viewstate = $this->get_string_between($this->html, 'id="javax.faces.ViewState" value="', '" autocomplete');
|
||||
$conversationId = $this->get_string_between($this->html, 'name="conversationId" value="', '" />');
|
||||
|
||||
$post = [
|
||||
'mainForm' => 'mainForm',
|
||||
'referenzBaumAnzeigen' => 'false',
|
||||
'conversationId' => $conversationId,
|
||||
'changeNotification' => 'true',
|
||||
'mainForm:hasChanged' => 'true',
|
||||
'mainForm:hasNotReleased' => 'false',
|
||||
'mainForm:hasPopUpChanged' => 'false',
|
||||
'mainForm:hasAdresseChanged' => 'false',
|
||||
'mainForm:confirmedOverride' => 'true',
|
||||
'mainForm:zuordnungNotification' => 'false',
|
||||
'skipvalidation' => 'false',
|
||||
'mainForm:istAnzeigeMaske' => 'false',
|
||||
'mainForm:schulnr' => '',
|
||||
'mainForm:schuljahr' => '23',
|
||||
'mainForm:schulnummer' => $snr,
|
||||
'mainForm:tab2:artZuschlag' => 'com.hp.asd.wl.domain.standard.Budgetform:1502',
|
||||
'mainForm:tab2:datumBis' => '31.07.2019',
|
||||
'mainForm:tab2:_edit_budget' => '',
|
||||
'mainForm:tab2:_edit_bemerkung' => '',
|
||||
'mainForm:speichern' => 'Speichern',
|
||||
'javax.faces.ViewState' => $viewstate
|
||||
];
|
||||
$this->exec_curl($ch, $SCHULPORTAL_ASD_BASE_URL . '/asdbu/up_07_50.jsf?cid=' . $conversationId, $post);
|
||||
if(!($this->status)) {
|
||||
die($this->error);
|
||||
}
|
||||
return($to_del);
|
||||
}
|
||||
|
||||
public function write_budget($ch,$budget) {
|
||||
$SCHULPORTAL_ASD_BASE_URL = Configure::read('AsdCurl.asdbaseurl');
|
||||
|
||||
// Budget eintragen
|
||||
$viewstate = $this->get_string_between($this->html, 'id="javax.faces.ViewState" value="', '" autocomplete');
|
||||
$conversationId = $this->get_string_between($this->html, 'name="conversationId" value="', '" />');
|
||||
|
||||
$post = [
|
||||
'mainForm' => 'mainForm',
|
||||
'referenzBaumAnzeigen' => 'false',
|
||||
'conversationId' => $conversationId,
|
||||
'changeNotification' => 'true',
|
||||
'mainForm:hasChanged' => 'true',
|
||||
'mainForm:hasNotReleased' => 'false',
|
||||
'mainForm:hasPopUpChanged' => 'false',
|
||||
'mainForm:hasAdresseChanged' => 'false',
|
||||
'mainForm:confirmedOverride' => 'true',
|
||||
'mainForm:zuordnungNotification' => 'false',
|
||||
'skipvalidation' => 'false',
|
||||
'mainForm:istAnzeigeMaske' => 'false',
|
||||
'mainForm:schulnr' => '',
|
||||
'mainForm:schuljahr' => '23',
|
||||
'mainForm:schulnummer' => $budget['snr'],
|
||||
'mainForm:tab2:artZuschlag' => 'com.hp.asd.wl.domain.standard.Budgetform:' . $budget['budget_id'],
|
||||
'mainForm:tab2:datumBis' => '31.07.2019',
|
||||
'mainForm:tab2:_edit_budget' => $budget['count'],
|
||||
'mainForm:tab2:_edit_bemerkung' => $budget['comment'],
|
||||
'mainForm:tab2:hinzufuegen' => 'Hinzufügen',
|
||||
'javax.faces.ViewState' => $viewstate
|
||||
];
|
||||
$this->exec_curl($ch, $SCHULPORTAL_ASD_BASE_URL . '/asdbu/up_07_50.jsf?cid=' . $conversationId, $post);
|
||||
if(!($this->status)) {
|
||||
die($this->error);
|
||||
}
|
||||
|
||||
// Budget speichern
|
||||
$viewstate = $this->get_string_between($this->html, 'id="javax.faces.ViewState" value="', '" autocomplete');
|
||||
$conversationId = $this->get_string_between($this->html, 'name="conversationId" value="', '" />');
|
||||
|
||||
$post = [
|
||||
'mainForm' => 'mainForm',
|
||||
'referenzBaumAnzeigen' => 'false',
|
||||
'conversationId' => $conversationId,
|
||||
'changeNotification' => 'true',
|
||||
'mainForm:hasChanged' => 'true',
|
||||
'mainForm:hasNotReleased' => 'false',
|
||||
'mainForm:hasPopUpChanged' => 'false',
|
||||
'mainForm:hasAdresseChanged' => 'false',
|
||||
'mainForm:confirmedOverride' => 'true',
|
||||
'mainForm:zuordnungNotification' => 'false',
|
||||
'skipvalidation' => 'false',
|
||||
'mainForm:istAnzeigeMaske' => 'false',
|
||||
'mainForm:schulnr' => '',
|
||||
'mainForm:schuljahr' => '23',
|
||||
'mainForm:schulnummer' => $budget['snr'],
|
||||
'mainForm:tab2:artZuschlag' => 'com.hp.asd.wl.domain.standard.Budgetform:' . $budget['budget_id'],
|
||||
'mainForm:tab2:datumBis' => '31.07.2019',
|
||||
'mainForm:tab2:_edit_budget' => '',
|
||||
'mainForm:tab2:_edit_bemerkung' => '',
|
||||
'mainForm:speichern' => 'Speichern',
|
||||
'javax.faces.ViewState' => $viewstate
|
||||
];
|
||||
$this->exec_curl($ch, $SCHULPORTAL_ASD_BASE_URL . '/asdbu/up_07_50.jsf?cid=' . $conversationId, $post);
|
||||
if(!($this->status)) {
|
||||
die($this->error);
|
||||
}
|
||||
|
||||
//echo $this->html;die;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
10
plugins/AsdCurl/src/Controller/AppController.php
Normal file
10
plugins/AsdCurl/src/Controller/AppController.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace AsdCurl\Controller;
|
||||
|
||||
use App\Controller\AppController as BaseController;
|
||||
|
||||
class AppController extends BaseController
|
||||
{
|
||||
|
||||
}
|
||||
35
plugins/AsdCurl/src/Url.php
Normal file
35
plugins/AsdCurl/src/Url.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace AsdCurl;
|
||||
|
||||
class Url
|
||||
{
|
||||
/**
|
||||
* URL source
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $src;
|
||||
|
||||
public function __construct($url)
|
||||
{
|
||||
// Prepend http:// if the url doesn't contain it
|
||||
if (!stristr($url, 'http://') && !stristr($url, 'https://')) {
|
||||
$url = 'http://' . $url;
|
||||
}
|
||||
|
||||
if (!$url || !filter_var($url, FILTER_VALIDATE_URL)) {
|
||||
throw new InvalidUrlException($url);
|
||||
}
|
||||
|
||||
$url = str_replace(array(';', '"', '<?'), '', strip_tags($url));
|
||||
$url = str_replace(array('\077', '\''), array(' ', '/'), $url);
|
||||
|
||||
$this->src = $url;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->src;
|
||||
}
|
||||
}
|
||||
0
plugins/AsdCurl/webroot/empty
Normal file
0
plugins/AsdCurl/webroot/empty
Normal file
0
plugins/empty
Normal file
0
plugins/empty
Normal file
Reference in New Issue
Block a user