// // WIRIS Plugin is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with WIRIS Plugin. If not, see <http://www.gnu.org/licenses/>. // require_once 'bootstrap.php'; include 'libwiris.php'; $currentPath = dirname($_SERVER['PHP_SELF']) . '/'; if (isset($_POST['image'])) { $fileName = md5($_POST['image']); $config = wrs_loadConfig(WRS_CONFIG_FILE); $formulaPath = wrs_getFormulaDirectory($config) . '/' . $fileName . '.xml'; if (isset($_POST['mml']) && !is_file($formulaPath)) { file_put_contents($formulaPath, $_POST['mml']); } $url = $currentPath . 'showcasimage.php?formula=' . $fileName . '.png'; $imagePath = wrs_getCacheDirectory($config) . '/' . $fileName . '.png'; if (!is_file($imagePath)) { if (file_put_contents($imagePath, base64_decode($_POST['image'])) !== false) { echo $url; } else { echo $currentPath . '../core/cas.gif'; } } else { echo $url; } } else {
// require_once 'bootstrap.php'; include 'libwiris.php'; $digest = NULL; if (isset($_POST['md5']) && mb_strlen($_POST['md5']) == 32) { // Support for "generic simple" integration. $digest = $_POST['md5']; } else { if (isset($_POST['digest'])) { // Support for future integrations (where maybe they aren't using md5 sums). $digest = $_POST['digest']; } } if (!is_null($digest)) { $config = wrs_loadConfig(WRS_CONFIG_FILE); $filePath = wrs_getFormulaDirectory($config) . '/' . basename($digest); if (is_file($filePath . '.ini')) { $formula = wrs_parseIni($filePath . '.ini'); if ($formula !== false) { if (isset($formula['mml'])) { echo $formula['mml']; } } else { echo 'Error: could not read the formula. Check your file permissions.'; } } else { if (is_file($filePath . '.xml')) { if (($handle = fopen($filePath, 'r')) !== false) { if (($line = fgets($handle)) !== false) { echo $line; }
return true; } function mustBeCached() { global $wrs_xmlFileAttributes; foreach ($_GET as $key => $value) { if (in_array($key, $wrs_xmlFileAttributes) || substr($key, 0, 4) == 'font') { return false; } } return true; } if (!empty($_GET['formula'])) { $config = wrs_loadConfig(WRS_CONFIG_FILE); $formula = rtrim(basename($_GET['formula']), '.png'); $formulaPath = wrs_getFormulaDirectory($config) . '/' . $formula; $extension = is_file($formulaPath . '.ini') ? 'ini' : 'xml'; if (mustBeCached()) { $imagePath = wrs_getCacheDirectory($config) . '/' . $formula . '.png'; if (is_file($imagePath) || createAndSaveImage($config, $formulaPath, $extension, $imagePath)) { header('Content-Type: image/png'); readfile($imagePath); } else { echo 'Error creating the image.'; } } else { $imageStream = createImage($config, $formulaPath, $extension, true); if (is_null($imageStream)) { echo 'Error creating the image.'; } else { header('Content-Type: image/png');
public function com_wiris_plugin_PluginAPI() { $this->formulaDirectory = wrs_getFormulaDirectory(wrs_loadConfig(WRS_CONFIG_FILE)); $this->TAGS = new stdClass(); }
?> </tr> <tr> <?php $file = wrs_getFormulaDirectory($config) . '/test.xml'; $test_name = 'Writing a formula file'; $report_text = 'Writing file ' . $file; $solution_link = ''; echo wrs_createTableRow($test_name, $report_text, $solution_link, @fopen($file, 'w') !== false); ?> </tr> <tr> <?php $file = wrs_getFormulaDirectory($config) . '/test.xml'; $test_name = 'Reading a formula file'; $report_text = 'Reading file ' . $file; $solution_link = ''; echo wrs_createTableRow($test_name, $report_text, $solution_link, @fopen($file, 'r') !== false); ?> </tr> <tr> <?php $file = wrs_getCacheDirectory($config) . '/test.png'; $test_name = 'Writing an image file'; $report_text = 'Writing file ' . $file; $solution_link = ''; echo wrs_createTableRow($test_name, $report_text, $solution_link, @fopen($file, 'w') !== false); ?>