} //HTML Template for the user-specific part on the website $userTemplate = new Template("www/templates/loggedin_template.html"); //Give the template the possibility to use the UserAuthentification class. $userTemplate->setVar("UserAuthentification", $userAuth); //Array mapping a champion name to its icon. Array ( ["ChampionName"] => "Icon", ["ChampionName2"] => "Icon2" ) $champJson = cURL("https://global.api.pvp.net/api/lol/static-data/euw/v1.2/champion?champData=image&api_key=" . $apiKey); $championData = parseChampJSON($champJson, array("Champion" => new ArrayObject(array("img" => "www/any.png", "name" => "Any Champion", "key" => "Champion"), ArrayObject::ARRAY_AS_PROPS))); //$spellData = parseSpellJSON(cURL("https://global.api.pvp.net/api/lol/static-data/euw/v1.2/summoner-spell?spellData=image,key&api_key=" . $apiKey)); //Get all those items... $itemdata = recursiveArrayObject(collapseResultArray2($database->query("SELECT i.ID AS ItemID, i.Gold, i.Name AS ItemName, i.Description, ibi.BuildsIntoID, ibf.BuildsFromID, it.Tag FROM `Items` i LEFT JOIN `ItemBuildsFrom` ibf ON i.ID = ibf.ItemID LEFT JOIN `ItemBuildsInto` ibi ON i.ID = ibi.ItemID LEFT JOIN `ItemTags` it ON i.ID = it.ItemID"), true, true, true), ArrayObject::ARRAY_AS_PROPS); $headerTemplate = new Template("www/templates/header_template.html"); $headerTemplate->setVar("UserTemplate", $userTemplate); $headerTemplate->setVar("buttons", array(new ArrayObject(array("name" => "Home", "href" => "index.php"), ArrayObject::ARRAY_AS_PROPS), new ArrayObject(array("name" => "My Sets", "href" => "mysets.php"), ArrayObject::ARRAY_AS_PROPS))); //And then, printerino! $csTemplate = new Template("www/templates/createset_template.html"); $csTemplate->setVar("ChampionData", $championData); $csTemplate->setVar("ItemSet", $itemset); //$csTemplate->setVar("SpellData", $spellData); $csTemplate->setVar("Items", $itemdata); $csTemplate->setVar("i", 1); $csTemplate->setVar("TypusMaximusWaddafakius", $type); $csTemplate->setVar("ChampionData", $championData); $footerTemplate = new Template("www/templates/footer_template.html"); $userTemplate->prepare(); $headerTemplate->prepare(); $csTemplate->prepare(); $footerTemplate->prepare(); echo $headerTemplate->printTemplate(); echo $csTemplate->printTemplate(); echo $footerTemplate->printTemplate();
private function startExecutor() { $view = new View(); $healer = new Healer(); if (!empty($_POST) && !empty($_POST['recipe'])) { $xmlRecipe = $_POST['recipe']; $validator = new XmlValidator(); global $projectRootDir; if (get_magic_quotes_gpc()) { $xmlRecipe = stripslashes($xmlRecipe); } //TODO: implement proper XXE prevention or switch to JSON instead if (strpos(strtoupper($xmlRecipe), '<!ENTITY') !== false) { die('XXE detected'); } if (!$validator->validate($xmlRecipe, $projectRootDir . '/static/xsd/recipe.xsd')) { die(PS_ERR_BROKEN_XML_FILE); } $executeList = ''; $itemTemplate = new Template('executor_item.tpl'); $quarantineFiles = array(); $deleteFiles = array(); $healer->prepareList($xmlRecipe, $quarantineFiles, $deleteFiles); for ($i = 0; $i < count($deleteFiles); $i++) { $itemTemplate->prepare(); $itemTemplate->set('PREFIX', 'd'); $itemTemplate->set('NUM', $i); $itemTemplate->set('ACTION', PS_RECIPE_ACTION_DEL); $itemTemplate->set('FILENAME', $this->getShortFilename($deleteFiles[$i])); $itemTemplate->set('FILENAME_B64', base64_encode($deleteFiles[$i])); $executeList .= $itemTemplate->get(); } for ($i = 0; $i < count($quarantineFiles); $i++) { $itemTemplate->prepare(); $itemTemplate->set('PREFIX', 'q'); $itemTemplate->set('NUM', $i); $itemTemplate->set('ACTION', PS_RECIPE_ACTION_QUARANTINE); $itemTemplate->set('FILENAME', $this->getShortFilename($quarantineFiles[$i])); $itemTemplate->set('FILENAME_B64', base64_encode($quarantineFiles[$i])); $executeList .= $itemTemplate->get(); } define('PS_EXECUTE_LIST', $executeList); define('PS_EXECUTE_TOTAL_D', count($deleteFiles)); define('PS_EXECUTE_TOTAL_Q', count($quarantineFiles)); $view->display('executor_changes.tpl'); } else { if (isset($_POST['a']) && $_POST['a'] === 'apply') { $deleteTotal = (int) $_POST['total_d']; $quarantineTotal = (int) $_POST['total_q']; $deleteFiles = array(); $quarantineFiles = array(); for ($i = 0; $i < $deleteTotal; $i++) { if (!empty($_POST['d_' . $i]) && $_POST['d_' . $i] === 'on') { $deleteFiles[] = base64_decode($_POST['fn_d_' . $i]); } } for ($i = 0; $i < $quarantineTotal; $i++) { if (!empty($_POST['q_' . $i]) && $_POST['q_' . $i] === 'on') { $quarantineFiles[] = base64_decode($_POST['fn_q_' . $i]); } } $numQuarantined = 0; define('PS_EXECUTOR_LOG', $healer->executeXmlRecipe($deleteFiles, $quarantineFiles, $numQuarantined)); $quarantineUrl = $_SERVER['PHP_SELF'] . '?controller=download&f=quarantine'; define('PS_QUARANTINE_URL', $quarantineUrl); $view->display('executor_done.tpl'); } else { if (isset($_REQUEST['a']) && $_REQUEST['a'] == 'selfDelete') { global $projectRootDir, $projectTmpDir; if ($projectTmpDir == sys_get_temp_dir()) { @unlink($projectTmpDir . '/scan_log.xml'); array_map('unlink', glob($projectTmpDir . '/*.manul.tmp.txt')); array_map('unlink', glob($projectTmpDir . '/*.manul.tmp')); array_map('unlink', glob($projectTmpDir . '/config.php')); } $deleteResult = $healer->deleteDir($projectRootDir); if ($deleteResult) { print json_encode(array('result' => 'ok')); } else { print json_encode(array('result' => 'error', 'details' => $deleteResult)); } } else { $view->display('executor.tpl'); } } } }