Esempio n. 1
0
 public function mathml2accessible($data, $config)
 {
     $availableLangs = array('en', 'es');
     $parsedUrl = parse_url($data['src']);
     parse_str($parsedUrl['query']);
     $md5 = substr($formula, 0, strlen($formula) - 4);
     $lang = 'en';
     if (in_array($data['lang'], $availableLangs)) {
         $lang = $data['lang'];
     }
     $accessibilityTextPath = wrs_getCacheDirectory($config) . '/' . $md5 . '.' . $lang . '.txt';
     if (is_file($accessibilityTextPath) || $this->createAndSaveAccessibilityText($config, $accessibilityTextPath, $data)) {
         return file_get_contents($accessibilityTextPath);
     } else {
         echo 'Error creating the accessibility file.';
     }
 }
Esempio n. 2
0
//  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 {
    echo $currentPath . '../core/cas.gif';
}
//  This file is part of WIRIS Plugin.
//
//  WIRIS Plugin is free software: you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  any later version.
//
//  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';
if (empty($_GET['formula'])) {
    echo 'Error: no image name has been sended.';
} else {
    $config = wrs_loadConfig(WRS_CONFIG_FILE);
    $formula = basename($_GET['formula']);
    $filePath = wrs_getCacheDirectory($config) . '/' . $formula;
    if (is_file($filePath)) {
        header('Content-Type: image/png');
        readfile($filePath);
    } else {
        header('Content-Type: image/gif');
        readfile('../core/cas.gif');
    }
}
Esempio n. 4
0
{
    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');
            echo $imageStream;
        }
    }
Esempio n. 5
0
$test_name = 'Creating a random image';
$mathml = '<math xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mn>' . rand(0, 9999) . '</mn><mo>+</mo><mn>' . rand(0, 9999) . '</mn></mrow></math>';
$api = new com_wiris_plugin_PluginAPI();
$src = $api->mathml2img($mathml, dirname($_SERVER["REQUEST_URI"]));
$prefix = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] ? 'https://' : 'http://';
if (isset($_SERVER['HTTP_HOST'])) {
    $host = $_SERVER['HTTP_HOST'] . '/';
} else {
    $host = $_SERVER['SERVER_NAME'] . '/';
}
$query = parse_url($src, PHP_URL_QUERY);
$query_array = array();
parse_str($query, $query_array);
$report_text = '<img align="middle" src="' . $src . '" />';
$solution_link = '';
$imageFile = wrs_getCacheDirectory($config) . '/' . $query_array['formula'];
if (ini_get('allow_url_fopen')) {
    @fopen($prefix . $host . $src, 'r');
    echo wrs_createTableRow($test_name, $report_text, $solution_link, file_exists($imageFile));
} else {
    if (function_exists('curl_init')) {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $prefix . $host . $src);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $content = curl_exec($ch);
        curl_close($ch);
        echo wrs_createTableRow($test_name, $report_text, $solution_link, file_exists($imageFile));
    } else {
        echo wrs_createTableRow($test_name, $report_text, $solution_link, false, false);
    }
}