$_SESSION['type'] = $type2; } else { //is upload from converted file $ext_ok = array('8xp', '83p', '84p', '82p'); $dir = 'files/'; if ($_FILES['fichier']['error'] == 0) { $name_input = htmlspecialchars($_FILES['fichier']['name']); $id_saved = uniqid(); $ext_file = strtolower(substr(strrchr($_FILES['fichier']['name'], '.'), 1)); $name_saved = $id_saved . '.' . $ext_file; //création d'un fichier unique $_SESSION['file'] == $name_saved; if (in_array($ext_file, $ext_ok)) { $result = move_uploaded_file($_FILES['fichier']['tmp_name'], $dir . $name_saved); if ($result) { $testPrgm = TIVarFile::loadFromFile('files/' . $name_saved); $global_src = $testPrgm->getReadableContent(['lang' => strtolower($lang2)]); $_SESSION['lang'] = $lang2; $_SESSION['type'] = $type2; $_SESSION['src'] = $global_src; } } else { $_SESSION['error_file_uploaded'] = 'Ce fichier n\'est pas un programme pour calculatrice TI'; } } elseif ($_FILES['fichier']['size'] == 0) { $_SESSION['error_file_uploaded'] = 'Vous devez entrer un fichier!'; } else { $_SESSION['error_file_uploaded'] = 'Le fichier contient des erreurs'; } } header('location:verifbeforeconvert.php');
//$newPrgm->setContentFromString("Asm(prgmABCD"); //print_r($newPrgm->getRawContent()); //$newPrgm = TIVarFile::createNew(TIVarType::createFromName("Real")); //$newPrgm->setContentFromString("45.2"); //print_r($newPrgm->getRawContent()); $testData = tivars\TypeHandlers\TH_0x05::makeDataFromString("Disp Toto"); $goodTypeForCalc = TIVarFile::createNew(TIVarType::createFromName("Program"), "Bla", TIModel::createFromName("84+")); $goodTypeForCalc->setContentFromData($testData); $goodTypeForCalc->saveVarToFile("/", "trololol"); //try //{ //$goodTypeForCalc = TIVarFile::createNew(TIVarType::createFromName('ExactComplexFrac'), 'Bla', TIModel::createFromName('84+')); //assert(false); //} catch (Exception $e) {} //assert(TIVarTypes::getIDFromName("ExactRealPi") === 32); $testPrgm = TIVarFile::loadFromFile('testData/Program.8xp'); //echo "testPrgm->getHeader()['entries_len'] == " . $testPrgm->getHeader()['entries_len'] . "\n"; //echo "testPrgm->size() - 57 == " . ($testPrgm->size() - 57) . "\n"; //assert($testPrgm->getHeader()['entries_len'] === $testPrgm->size() - 57); //$newPrgm = TIVarFile::createNew(TIVarType::createFromName("Program")); //$testPrgmcontent = $testPrgm->getReadableContent(['lang' => 'fr']); //echo "testPrgmContent :\n$testPrgmcontent\n"; //$newPrgm->setContentFromString($testPrgmcontent); //ssert($testPrgm->getRawContent() === $newPrgm->getRawContent()); //$newPrgm->saveVarToFile(); /* $testPrgm = TIVarFile::loadFromFile('testData/ProtectedProgram_long.8xp'); $testPrgmcontent = $testPrgm->getReadableContent(['prettify' => true, 'reindent' => true]); echo "All prettified and reindented:\n" . $testPrgmcontent . "\n"; $testPrgm = TIVarFile::loadFromFile('/Users/adriweb/Downloads/DynaTrig/83PremiumCE - 84PlusCE/DYNATRIG.8Xp');
$newExactComplexPiFrac = TIVarFile::createNew(TIVarType::createFromName("ExactComplexPiFrac"), "A", TIModel::createFromName('83PCE')); //$newExactComplexPiFrac->setContentFromString('-42.1337'); //assert($testExactComplexPiFrac->getRawContent() === $newExactComplexPiFrac->getRawContent()); //$newExactComplexPiFrac->saveVarToFile("testData", "Exact_ComplexPiFrac_new"); $testExactComplexRadical = TIVarFile::loadFromFile('testData/Exact_ComplexRadical.8xc'); assert($testExactComplexRadical->getReadableContent() === '((√(6)+√(2))/4)+((√(6)-√(2))/4)*i'); echo "Before: " . $testExactComplexRadical->getReadableContent() . "\n"; $newExactComplexRadical = TIVarFile::createNew(TIVarType::createFromName("ExactComplexRadical"), "A", TIModel::createFromName('83PCE')); //$newExactComplexRadical->setContentFromString('-42.1337'); //assert($testExactComplexRadical->getRawContent() === $newExactComplexRadical->getRawContent()); //$newExactComplexRadical->saveVarToFile("testData", "Exact_ComplexRadical_new"); $testExactRealPi = TIVarFile::loadFromFile('testData/Exact_RealPi.8xn'); assert($testExactRealPi->getReadableContent() === '30*π'); echo "Before: " . $testExactRealPi->getReadableContent() . "\n"; $newExactRealPi = TIVarFile::createNew(TIVarType::createFromName("ExactRealPi"), "A", TIModel::createFromName('83PCE')); //$newExactRealPi->setContentFromString('-42.1337'); //assert($testExactRealPi->getRawContent() === $newExactRealPi->getRawContent()); //$newExactRealPi->saveVarToFile("testData", "Exact_RealPi_new"); $testExactRealPiFrac = TIVarFile::loadFromFile('testData/Exact_RealPiFrac.8xn'); assert($testExactRealPiFrac->getReadableContent() === '2/7*π'); echo "Before: " . $testExactRealPiFrac->getReadableContent() . "\n"; $newExactRealPiFrac = TIVarFile::createNew(TIVarType::createFromName("ExactRealPiFrac"), "A", TIModel::createFromName('83PCE')); //$newExactRealPiFrac->setContentFromString('-42.1337'); //assert($testExactRealPiFrac->getRawContent() === $newExactRealPiFrac->getRawContent()); //$newExactRealPiFrac->saveVarToFile("testData", "Exact_RealPiFrac_new"); //$testMatrixStandard = TIVarFile::loadFromFile('testData/Matrix_3x3_standard.8xm'); //print_r($testMatrixStandard); //echo "Before: " . $testExactRealFrac->getReadableContent() . "\t" . "Now: "; //$testExactRealFrac->setContentFromString("0.2"); //echo $testExactRealFrac->getReadableContent() . "\n"; //$testExactRealFrac->saveVarToFile();
<?php include_once "src/autoloader.php"; use tivars\TIVarFile; use tivars\TIVarType; use tivars\TIVarTypes; $testPrgm = TIVarFile::loadFromFile('../ressources/SNAKE.8xp'); echo "Code TI-Basic: " . $testPrgm->getReadableContent(['lang' => 'fr']) . "\n"; ?>
<?php $source_code = $_SESSION['src_conv']; include_once "libAdriweb\\src/autoloader.php"; include_once "libAdriweb\\src/TypeHandlers/TH_0x05.php"; use tivars\TIModel; use tivars\TIVarFile; use tivars\TIVarType; use tivars\TIVarTypes; $id_test = uniqid(); $newPrgm = TIVarFile::createNew(TIVarType::createFromName("Program"), "CONVERT", TIModel::createFromName("84+")); $newPrgm->setContentFromString($source_code); $newPrgm->saveVarToFile("exported", $id_test); echo '<a href="exported/' . $id_test . '.8xp">Telecharge le programme</a>';
<p> </p> <p>GlobalTest</p> <?php include_once "libAdriweb\\src/autoloader.php"; use tivars\TIVarFile; use tivars\TIVarType; use tivars\TIVarTypes; $testPrgm = TIVarFile::loadFromFile('ressources/FRANCE.8xp'); $toto = $testPrgm->getReadableContent(['lang' => 'fr']); //$myprgm = new converter($toto, 'input'); //$toto = "Line(2A+3,5,999,88,Red)\nDisp A\nTextColor(RED)\nVerticale 999\nDisp \"Background On\"\nBackground On\nBackground Off\nDisp B+D\nBorderColor\nGraphColor RED\nLine(0,0,0,0)\nHorizontale 20,BLEU CMR\nVertical A+2, Navy\nText(0,0,\"dj++-956sfh//*sfhkjh\",BLEU CMR)\nPt-On(2,5,RED)\nPt-Aff(A+B/C,78,BLEU CMR)\nPxl-Aff(56,A+9-9*8,ORANGE)\n"; function iscoloredtotal($currentline) { include 'php/regex.php'; $totalcolor = array('Background', 'TextColor', 'CouleurTexte', 'ArrPlan', 'GraphColor', 'CouleurGraph', 'BorderColor', 'CouleurBord'); for ($i = 0; $i <= count($totalcolor) - 1; $i++) { if (preg_match('#^' . $totalcolor[$i] . '#i', $currentline)) { return "delall"; } } if (preg_match($linecolor, $currentline, $regexline)) { //lignes couleurs vers lignes monochromes $correction = substr($currentline, 0, stripos($currentline, $regexline[2]) - 1) . ')';
$newPrgm->setContentFromString($testPrgmcontent); assert($testPrgm->getRawContent() === $newPrgm->getRawContent()); //$newPrgm->saveVarToFile(); $testPrgm = TIVarFile::loadFromFile('testData/ProtectedProgram_long.8xp'); $testPrgmcontent = $testPrgm->getReadableContent(['prettify' => true, 'reindent' => true]); echo "All prettified and reindented:\n" . $testPrgmcontent . "\n"; $testPrgm = TIVarFile::loadFromFile('/Users/adriweb/Downloads/DynaTrig/83PremiumCE - 84PlusCE/DYNATRIG.8Xp'); $testPrgmcontent = $testPrgm->getReadableContent(['prettify' => true, 'reindent' => true]); echo "All prettified and reindented:\n" . $testPrgmcontent . "\n"; $testPrgm = TIVarFile::loadFromFile('testData/Program.8xp'); $newPrgm = TIVarFile::createNew(TIVarType::createFromName("Program")); $newPrgm->setContentFromString($testPrgm->getReadableContent(['lang' => 'en'])); assert($testPrgm->getRawContent() === $newPrgm->getRawContent()); $testReal = TIVarFile::loadFromFile('testData/Real.8xn'); // -42.1337 $newReal = TIVarFile::createNew(TIVarType::createFromName("Real"), "A"); $newReal->setContentFromString('-42.1337'); assert($testReal->getReadableContent() === '-42.1337'); assert($testReal->getRawContent() === $newReal->getRawContent()); //$newReal->saveVarToFile("/Users/adriweb/", "trololol"); $testExactRealFrac = TIVarFile::loadFromFile('testData/Exact_RealFrac.8xn'); echo "Before: " . $testExactRealFrac->getReadableContent() . "\t" . "Now: "; $testExactRealFrac->setContentFromString("0.2"); echo $testExactRealFrac->getReadableContent() . "\n"; //$testExactRealFrac->saveVarToFile(); //$testMatrixStandard = TIVarFile::loadFromFile('testData/Matrix_3x3_standard.8xm'); //print_r($testMatrixStandard); //echo "Before: " . $testExactRealFrac->getReadableContent() . "\t" . "Now: "; //$testExactRealFrac->setContentFromString("0.2"); //echo $testExactRealFrac->getReadableContent() . "\n"; //$testExactRealFrac->saveVarToFile();
<?php $source_code = $_SESSION['src_conv']; include_once "libAdriweb\\src/autoloader.php"; include_once "libAdriweb\\src/TypeHandlers/TH_0x05.php"; use tivars\TIModel; use tivars\TIVarFile; use tivars\TIVarType; use tivars\TIVarTypes; $id_test = uniqid(); $newPrgm = TIVarFile::createNew(TIVarType::createFromName("Program"), $_SESSION['filename'], TIModel::createFromName("84+")); $newPrgm->setContentFromString($source_code); $newPrgm->saveVarToFile("exported", $_SESSION['filename']); echo '<a href="exported/' . $_SESSION['filename'] . '.8xp">Telecharge le programme</a>';
<p> <?php /* * * ONLY TESTS HERE * * * */ include_once "libAdriweb\\src/autoloader.php"; use tivars\TIVarFile; use tivars\TIVarType; use tivars\TIVarTypes; $testPrgm = TIVarFile::loadFromFile('libAdriweb/testData/ProtectedProgram_long.8xp'); $sourceFR = $testPrgm->getReadableContent(['lang' => 'en']); function get_line($line, $source, $type) { if ($type == 'input') { $gcode = explode("\n", $source); } elseif ($type == 'file') { $rpl = str_replace('\\n', '<br />', $source); //on transforme provisoirement les \n en <br />, car les \n ne sont pas détecté par la suite par le explode..??? $gcode = explode("<br />", $rpl); } return $gcode[$line - 1]; } for ($i = 1; $i <= linesofprgm($sourceFR, 'file'); $i++) { echo get_line($i, $sourceFR, 'file') . '<br />'; }