示例#1
0
        header('Content-Disposition: inline; filename="phpmyfamily.gv"');
        $fp = fopen($file, 'rb');
        fpassthru($fp);
        fclose($fp);
        unlink($file);
    } else {
        $g->display($output);
    }
} else {
    ?>
<dl>
<dt>GraphViz</dt>
<dd>
<ul>
<?php 
    if (is_exec_available()) {
        ?>
<li><a href="?use=gv&amp;output=svg">SVG</a></li>
<li><a href="?use=gv&amp;output=pdf">pdf</a></li>
<li><a href="?use=gv&amp;output=png">png</a></li>
<li><a href="?use=gv&amp;output=bmp">bmp</a></li>
<?php 
    }
    ?>
<li><a href="?use=gv&amp;output=dot">dot</a></li>
</ul>
See <a href="http://www.graphviz.org/Resources.php">here</a> for resources to use dot files.
</dd>
<dt><a href="?use=jit">Jit</a></dt>
<dt><a href="?use=arbor">Arbor</a></dt>
</dl>
 /**
  * Add file to the repository
  *
  * @param string $source Path of the source file
  * @param array $attributes Array of file attributes
  * @return string File ID
  * @throws FileDnxError if source is not readable
  * @throws FailedToCreateFolderError if we fail to create subdirectory
  * @throws FileRepositoryAddError if we fail to move file to the repository
  */
 function addFile($source, $attributes = null)
 {
     if (!is_readable($source)) {
         throw new FileDnxError($source);
     }
     // if
     $file_id = $this->getUniqueId();
     $file_path = $this->getFilePath($file_id);
     $destination_dir = dirname($file_path);
     if (!is_dir($destination_dir)) {
         //if(!force_mkdir_from_base($this->getRepositoryDir(), dirname($this->idToPath($file_id)), 0777)) {
         if (!force_mkdir($destination_dir, 0777)) {
             throw new FailedToCreateFolderError($destination_dir);
         }
         // if
         if (is_exec_available()) {
             exec("chmod -R 777 {$destination_dir}");
         }
     }
     // if
     if (!copy($source, $file_path)) {
         throw new FileRepositoryAddError($source, $file_id);
     }
     // if
     if (is_array($attributes)) {
         foreach ($attributes as $attribute_name => $attribute_value) {
             $this->setFileAttribute($file_id, $attribute_name, $attribute_value);
         }
         // foreach
     }
     // if
     Hook::fire('after_adding_file_to_repository', $file_path, $ret);
     return $file_id;
 }
示例#3
0
function can_save_permissions_in_background()
{
    if (defined('DONT_SAVE_PERMISSIONS_IN_BACKGROUND') && DONT_SAVE_PERMISSIONS_IN_BACKGROUND) {
        return false;
    }
    return defined('SAVE_PERMISSIONS_IN_BACKGROUND') && SAVE_PERMISSIONS_IN_BACKGROUND && is_exec_available();
}
示例#4
0
function convert_to_pdf($html_to_convert, $orientation = 'Protrait', $genid)
{
    $pdf_filename = null;
    if (is_exec_available()) {
        //controlar q sea linux
        $pdf_filename = $genid . "_pdf.pdf";
        $pdf_path = "tmp/" . $pdf_filename;
        $tmp_html_path = "tmp/tmp_html_" . $genid . ".html";
        file_put_contents($tmp_html_path, $html_to_convert);
        if (!in_array($orientation, array('Portrait', 'Landscape'))) {
            $orientation = 'Portrait';
        }
        //convert png to pdf in background
        exec("wkhtmltopdf -s A4 --encoding utf8 -O {$orientation} " . $tmp_html_path . " " . $pdf_path . " > /dev/null &", $result, $return_var);
        if ($return_var > 0) {
            Logger::log("command not found convert", Logger::WARNING);
            return false;
        }
        //wait for the file
        $seconds = 8;
        while (!file_exists(ROOT . "/tmp/" . $pdf_filename) && $seconds > 0) {
            sleep(1);
            $seconds = $seconds - 1;
        }
        //give time to finish
        sleep(2);
        //delete the png file
        unlink($tmp_html_path);
        //check if pdf exist
        if (!file_exists(ROOT . "/tmp/" . $pdf_filename)) {
            return false;
        }
        return $pdf_filename;
    }
}
示例#5
0
 /**
  * Get file's mime type
  *
  * @return string
  */
 public final function type()
 {
     $mime = '';
     if (class_exists('finfo')) {
         $finfo = finfo_open(FILEINFO_MIME_TYPE);
         $mime = finfo_file($finfo, $this->path);
     } elseif (!strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
         $filename = escapeshellcmd($this->path);
         $mime = shell_exec("file -b --mime-type '" . $filename . "'");
     } elseif (is_exec_available()) {
         $filename = escapeshellcmd($this->path);
         $mime = exec("file -b --mime-type '" . $filename . "'");
     }
     return $mime;
 }
 function view_custom_report_print()
 {
     $this->setLayout("html");
     set_time_limit(0);
     $params = json_decode(str_replace("'", '"', array_var($_POST, 'post')), true);
     $report_params = json_decode(str_replace("'", '"', array_var($_POST, 'report_params')), true);
     $report_id = array_var($_POST, 'id');
     $order_by = array_var($_POST, 'order_by');
     if (!isset($order_by)) {
         $order_by = '';
     }
     tpl_assign('order_by', $order_by);
     $order_by_asc = array_var($_POST, 'order_by_asc');
     if (!isset($order_by_asc)) {
         $order_by_asc = true;
     }
     tpl_assign('order_by_asc', $order_by_asc);
     $report = Reports::getReport($report_id);
     $limit = array_var($_POST, 'exportCSV') || array_var($_POST, 'exportPDF') ? -1 : 50;
     $results = Reports::executeReport($report_id, $report_params, $order_by, $order_by_asc, 0, $limit, true);
     if (isset($results['columns'])) {
         tpl_assign('columns', $results['columns']);
     }
     if (isset($results['rows'])) {
         tpl_assign('rows', $results['rows']);
     }
     tpl_assign('db_columns', $results['db_columns']);
     if (array_var($_POST, 'exportCSV')) {
         $filename = $this->generateCSVReport($report, $results);
         ajx_current("empty");
         ajx_extra_data(array('filename' => $filename));
     } else {
         if (array_var($_POST, 'exportPDF') && !is_exec_available()) {
             $this->generatePDFReport($report, $results);
         } else {
             tpl_assign('types', self::get_report_column_types($report_id));
             tpl_assign('template_name', 'view_custom_report');
             tpl_assign('title', $report->getObjectName());
             $ot = ObjectTypes::findById($report->getReportObjectTypeId());
             tpl_assign('model', $ot->getHandlerClass());
             tpl_assign('description', $report->getDescription());
             $conditions = ReportConditions::getAllReportConditions($report_id);
             tpl_assign('conditions', $conditions);
             tpl_assign('parameters', $params);
             tpl_assign('id', $report_id);
             tpl_assign('to_print', true);
             if (array_var($_POST, 'exportPDF')) {
                 tpl_assign('pdf_export', true);
                 $html_filename = ROOT . '/tmp/' . gen_id() . 'pdf.html';
                 $pdf_filename = $report->getObjectName() . '.pdf';
                 tpl_assign('html_filename', $html_filename);
                 tpl_assign('pdf_filename', $pdf_filename);
                 tpl_assign('orientation', array_var($_POST, 'pdfPageLayout') == 'L' ? 'Landscape' : 'Portrait');
                 ob_start();
             }
             $this->setTemplate('report_printer');
         }
     }
 }