/**
  * executes tidy and gets the value
  * @param string column name from transaction
  * @param string string to test
  * @return boolean true if tidy executed succesfully
  * @access private
  */
 function execTidy($colName, $value)
 {
     $arg_test = array('--version');
     if (isset($_SESSION['TidyContent']['ExecPath'])) {
         $loc = array($_SESSION['TidyContent']['ExecPath']);
     } else {
         $loc = $GLOBALS['TidyContent_TidyLocations'];
         if (isset($GLOBALS['KT_prefered_tidy_path'])) {
             array_unshift($loc, $GLOBALS['KT_prefered_tidy_path'] . 'tidy');
             array_unshift($loc, $GLOBALS['KT_prefered_tidy_path'] . 'tidy.exe');
         }
     }
     $shell = new KT_shell();
     $shell->execute($loc, $arg_test);
     if ($shell->hasError()) {
         $arr = $shell->getError();
         $this->setErrorMsg($arr[0], $arr[1]);
         return false;
     }
     $execPath = $shell->getExecutedCommand();
     if (!isset($_SESSION['TidyContent']['ExecPath']) && $execPath != '') {
         $_SESSION['TidyContent']['ExecPath'] = $execPath;
         $loc = array($execPath);
     }
     $tidyEncoding = 'raw';
     if (strtolower($this->outEncoding) == 'iso-8859-1') {
         $tidyEncoding = 'ascii';
     }
     if (strpos(strtolower($this->outEncoding), 'utf-8') !== false) {
         $tidyEncoding = 'utf8';
     }
     $string = $value;
     $string = str_replace(" ", " ", $string);
     $string = str_replace(" ", " ", $string);
     if (!file_exists($this->folderName)) {
         $folder = new KT_folder();
         $folder->createFolder($this->folderName);
         if ($folder->hasError()) {
             $arr = $folder->getError();
             $this->setErrorMsg($arr[0], $arr[1]);
             return false;
         }
     }
     $f = tempnam(substr($this->folderName, 0, -1), 'tidy');
     if ($f === false) {
         $err = KT_getResource('ERROR_TIDY_CONTENT', 'tNG', array());
         $this->setErrorMsg($err, $err);
         return false;
     }
     $fout = $f . '_out';
     $file = new KT_file();
     $file->writeFile($f, 'append', $string);
     if ($file->hasError()) {
         $arr = $file->getError();
         $this->setErrorMsg($arr[0], $arr[1]);
         return false;
     }
     $path = $GLOBALS['TidyContent_TidyConfiguration'];
     $arg = array("-config", $path, '-' . $tidyEncoding, "-o", $fout, $f);
     $shell = new KT_shell();
     $output = $shell->execute($loc, $arg);
     if ($shell->hasError() && !file_exists($fout)) {
         $arr = $shell->getError();
         $this->setErrorMsg($arr[0], $arr[1]);
         @unlink($f);
         @unlink($fout);
         return false;
     }
     $file = new KT_file();
     $content = $file->readFile($fout);
     if ($file->hasError()) {
         $arr = $file->getError();
         $this->setErrorMsg($arr[0], $arr[1]);
         @unlink($f);
         @unlink($fout);
         return false;
     }
     $file->deleteFile($f);
     if ($file->hasError()) {
         $arr = $file->getError();
         $this->setErrorMsg($arr[0], $arr[1]);
         @unlink($fout);
         return false;
     }
     $file->deleteFile($fout);
     if ($file->hasError()) {
         $arr = $file->getError();
         $this->setErrorMsg($arr[0], $arr[1]);
         return false;
     }
     $content = str_replace(" ", " ", $content);
     $content = str_replace(" ", " ", $content);
     $content = $this->cleanContent($content);
     $this->tidiedValues[$colName] = $content;
     return true;
 }
Beispiel #2
0
$folder = '../../../' . $folder;
// create the folder if not exists
if (!file_exists($folder)) {
    $folderObj = new KT_folder();
    $folderObj->createFolder($folder);
    if ($folderObj->hasError()) {
        $err = $folderObj->getError();
        echo '<html><head><title>Multilpe Upload</title><link href="../../../includes/skins/mxkollection3.css" rel="stylesheet" type="text/css" media="all" /></head><body><div id="KT_tngerror"><label>' . KT_getResource('ERROR_LABEL', 'tNG') . '</label><div>';
        echo isset($GLOBALS['tNG_debug_mode']) && $GLOBALS['tNG_debug_mode'] == 'DEVELOPMENT' ? $err[1] : $err[0];
        echo '</div></div></body></html>';
        exit;
    }
}
// delete selected file
if (isset($_POST['delete']) && isset($_SESSION['tng_upload_delete'][$_POST['delete']])) {
    $file = new KT_file();
    $file->deleteFile($folder . $_SESSION['tng_upload_delete'][$_POST['delete']]);
    if ($file->hasError()) {
        $err = $file->getError();
    } else {
        // delete thumbnails
        tNG_deleteThumbnails($folder . '/thumbnails/', $_SESSION['tng_upload_delete'][$_POST['delete']], '');
    }
    $_SESSION['tng_upload_delete'] = array();
    KT_redir(KT_getFullUri());
}
$_SESSION['tng_upload_delete'] = array();
// upload the files;
if (isset($_FILES['Filedata'])) {
    $folderObj = new KT_folder();
    $entries = $folderObj->readFolder($folder);