Ejemplo n.º 1
0
function breakAndMendFile($file)
{
    $intime = time();
    if ($file == '' || !is_file($file)) {
        return "Please specify the rdf/n3 file to restore";
        exit;
    }
    breakFile($file);
    removeFiles($file);
    rebuildFile($file);
}
Ejemplo n.º 2
0
 function serviceAcceptFileInfo()
 {
     $iAuthorId = $this->_getAuthorId();
     $sJSPhotoId = (int) $_POST['file_id'];
     switch ($_POST['type']) {
         case 'embed':
         case 'record':
             global $sFilesPath;
             $iPhotoID = (int) $this->performPhotoUpload($sFilesPath . $iAuthorId . IMAGE_EXTENSION, array(), false, false);
             removeFiles($iAuthorId);
             break;
         case 'upload':
         default:
             $iPhotoID = $sJSPhotoId;
             break;
     }
     if ($iPhotoID && $iAuthorId) {
         $sTitle = $_POST['title'];
         $sTags = $_POST['tags'];
         $sDescription = $_POST['description'];
         $aCategories = array();
         foreach ($_POST['Categories'] as $sKey => $sVal) {
             if ($sVal != '') {
                 $aCategories[] = $sVal;
             }
         }
         $sCategories = implode(CATEGORIES_DIVIDER, $aCategories);
         if ($this->initFile($iPhotoID, $sTitle, $sCategories, $sTags, $sDescription)) {
             $this->alertAdd($iPhotoID);
             return '<script type="text/javascript">parent.' . $this->_sJsPostObject . '.onSuccessSendingFileInfo("' . $sJSPhotoId . '");</script>';
         }
     }
     return '<script type="text/javascript">parent.' . $this->_sJsPostObject . '.showErrorMsg("photo_failed_message");</script>';
 }
Ejemplo n.º 3
0
        proc_terminate($process);
        echo json_encode(array('type' => 'ERROR', 'content' => 'Time limit exceeded'));
        removeFiles();
        exit;
    }
    if (is_resource($process)) {
        // It is important that you close any pipes before calling
        // proc_close in order to avoid a deadlock
        $return_value = proc_close($process);
        $end_time = time();
        // echo "Total Time taken - " . date('H:m:s', $end_time - $start_time);
        //		echo $return_value;
        $command_output = str_replace("\r\n", "\n", rtrim(trim(file_get_contents($cwd . 'output.txt'))));
        if (substr($command_output, 0, 26) == "<<entering SECCOMP mode>>\n") {
            $command_output = substr($command_output, 26);
        }
        if ($return_value == 0 || $command_output) {
            echo json_encode(array('type' => 'SUCCESS', 'content' => $command_output));
            removeFiles();
            exit;
        } else {
            echo json_encode(array('type' => 'ERROR', 'content' => 'Run Time Error'));
            removeFiles();
            exit;
        }
    } else {
        echo json_encode(array('type' => 'ERROR', 'content' => 'Someting is Wrong with compiler'));
        removeFiles();
        exit;
    }
}
Ejemplo n.º 4
0
            }
        }
        //--- Save image file ---//
        $sFileName = $sFilesPath . $sId . IMAGE_EXTENSION;
        $iQuality = getSettingValue($sModule, "quality");
        if (!is_numeric($iQuality)) {
            $iQuality = 75;
        }
        if (!@imagejpeg($rImage, $sFileName, $iQuality)) {
            $sContents = parseXml($aXmlTemplates['result'], 'msgErrorFile', FAILED_VAL);
        } else {
            $sContents = parseXml($aXmlTemplates['result'], '', SUCCESS_VAL);
        }
        break;
    case 'post':
        $sTable = isset($_REQUEST['table']) ? process_db_input($_REQUEST['table']) : "";
        $sAuthor = isset($_REQUEST['author']) ? process_db_input($_REQUEST['author']) : "";
        $sParent = isset($_REQUEST['parent']) ? process_db_input($_REQUEST['parent']) : "";
        $sMood = isset($_REQUEST['mood']) ? process_db_input($_REQUEST['mood']) : "";
        $sContents = "";
        $aResult = initFile($sAuthor);
        if ($aResult['status'] == SUCCESS_VAL) {
            $sContents = post($sTable, $sId, $sAuthor, $sParent, $sMood, $aResult['file']);
        }
        $sContentsType = "text";
        //break shouln't be here
    //break shouln't be here
    case 'removeTempFiles':
        removeFiles($sId);
        break;
}
Ejemplo n.º 5
0
        throw new Exception('Error in request data.');
    }
    // get request parameters
    $html = json_decode($_POST['html'], true);
    $format = stripslashes($_POST['format']);
    $orientation = stripslashes($_POST['orientation']);
    $range = stripslashes($_POST['range']);
    $fileFormat = stripslashes($_POST['fileFormat']);
    // generate name of the created single PDF file
    $out = $range . buildUniqueFileName('-exportedPanel', '.') . $fileFormat;
    // output file full path
    $outputFilePath = OUTPUT_PATH . "/{$out}";
    // output file URL
    $outputFileURL = OUTPUT_URL . $out;
    // put transferred pages HTML code to temporary files
    $files = buildHTMLFiles(OUTPUT_PATH, $html);
    // render HTML files to PNG images
    $images = renderHTMLFiles($files, OUTPUT_PATH, OUTPUT_URL, $format, $orientation);
    // build single PDF/PNG output file
    convertImagesToFile($images, $outputFilePath, $fileFormat);
    // cleanup temporary png/html files
    removeFiles(array_merge($images, $files), OUTPUT_PATH);
    header('Content-Type: application/json; charset=utf-8');
    //header("access-control-allow-origin: *");
    // return response
    die(json_encode(array('success' => true, 'url' => $outputFileURL)));
} catch (Exception $e) {
    header('Content-Type: application/json; charset=utf-8');
    //header("access-control-allow-origin: *");
    die(json_encode(array('success' => false, 'msg' => $e->getMessage())));
}
Ejemplo n.º 6
0
 function serviceAcceptFileInfo()
 {
     $iAuthorId = $this->_getAuthorId();
     $sJSPhotoId = (int) $_POST['file_id'];
     switch ($_POST['type']) {
         case 'embed':
         case 'record':
             global $sFilesPath;
             $iPhotoID = (int) $this->performPhotoUpload($sFilesPath . $iAuthorId . IMAGE_EXTENSION, array(), false, false);
             removeFiles($iAuthorId);
             break;
         case 'upload':
         default:
             $iPhotoID = $sJSPhotoId;
             break;
     }
     if ($iPhotoID && $iAuthorId) {
         $sTitle = $_POST['title'];
         $sTags = $_POST['tags'];
         $sDescription = $_POST['description'];
         $aCategories = array();
         foreach ($_POST['Categories'] as $sKey => $sVal) {
             if ($sVal != '') {
                 $aCategories[] = $sVal;
             }
         }
         $sCategories = implode(CATEGORIES_DIVIDER, $aCategories);
         if ($this->initPhotoFile($iPhotoID, $sTitle, $sCategories, $sTags, $sDescription)) {
             $aExtra = $this->_getExtraParams($_POST);
             $aExtra = $this->_updateExtraParams($aExtra, $iPhotoID, $iAuthorId);
             //--- BxPhoto -> Upload unit for Alerts Engine ---//
             require_once BX_DIRECTORY_PATH_CLASSES . 'BxDolAlerts.php';
             $oZ = new BxDolAlerts('bx_photos', 'add', $iPhotoID, $iAuthorId, $aExtra);
             $oZ->alert();
             //--- BxPhoto -> Upload unit for Alerts Engine ---//
             return '<script type="text/javascript">parent.' . $this->_sJsPostObject . '.onSuccessSendingFileInfo("' . $sJSPhotoId . '");</script>';
         }
     }
     return '<script type="text/javascript">parent.' . $this->_sJsPostObject . '.showErrorMsg("photo_failed_message");</script>';
 }
Ejemplo n.º 7
0
}
if (count($argv) == 1) {
    printUsage();
}
db_init();
$db = ORM::get_db();
$db->beginTransaction();
if ($argv[1] == '--crawler' || $argv[1] == '-c') {
    function removeFiles($regexPath)
    {
        exec("rm -rf {$regexPath}");
    }
    try {
        // șterge toate fișierele salvate
        removeFiles('ParsedText/*');
        removeFiles('RawPage/*');
        echo "files deleted\n";
        $db->exec('TRUNCATE Table CrawledPage;');
        $db->exec('TRUNCATE Table Link;');
        $db->commit();
        echo "tables 'Link' and 'CrawledPage' truncated\n";
        echo "The cleaning process was successful\n";
    } catch (Exception $ex) {
        echo "The cleaning process encountered a problem: " . $ex->getMessage() . "\n";
    }
} else {
    if ($argv[1] == '--diacritics' || $argv[1] == '-d') {
        try {
            $db->exec('TRUNCATE Table Diacritics;');
            $db->exec('TRUNCATE Table FilesUsedInDiacritics;');
            $db->commit();