Esempio n. 1
0
function check_against_compiled($program)
{
    global $filename;
    // Interpret
    $result = run_with_php($program, $filename);
    if ($result == false) {
        return false;
    }
    list($php_out, $php_err, $php_exit) = $result;
    // Compile
    $result = run_with_phc($program, $filename);
    if ($result == false) {
        return false;
    }
    list($phc_out, $phc_err, $phc_exit) = $result;
    if ($phc_out != $php_out || $phc_err != $php_err || $phc_exit != $php_exit) {
        mydebug(1, "Outputs differ");
        return true;
    }
    mydebug(1, "Outputs are the same");
    return false;
}
Esempio n. 2
0
 function debug()
 {
     // forces debug
     //var_dump($this);
     $GLOBALS['debug'] = 1;
     mydebug(__LINE__, __FILE__, "FDIR: " . $this->family);
     mydebug(__LINE__, __FILE__, "CSS: " . $this->CSS_filename);
     mydebug(__LINE__, __FILE__, "CSSDIR: " . $this->CSS_dir);
     mydebug(__LINE__, __FILE__, "TPL: " . $this->template);
     mydebug(__LINE__, __FILE__, "TPLDIR: " . $this->template_dir);
     mydebug(__LINE__, __FILE__, "JS: " . $this->JS_filename);
     mydebug(__LINE__, __FILE__, "JSDIR: " . $this->JS_dir);
     mydebug(__LINE__, __FILE__, "MDIR: " . $this->module_dir);
     $GLOBALS['debug'] = 0;
 }
Esempio n. 3
0
function make_linkFN($children_ha, $im_dest, $position_node)
{
    $background_R = $GLOBALS['background_R'];
    $background_G = $GLOBALS['background_G'];
    $background_B = $GLOBALS['background_B'];
    $foreground_R = $GLOBALS['foreground_R'];
    $foreground_G = $GLOBALS['foreground_R'];
    $foreground_B = $GLOBALS['foreground_R '];
    $root_dir = $GLOBALS['root_dir'];
    $layout_template = $GLOBALS['layout_template'];
    $duplicate_dir_structure = $GLOBALS['duplicate_dir_structure'];
    $family = $GLOBALS['family'];
    $debug = $GLOBALS['debug'];
    $src_x = 0;
    $src_y = 0;
    $text_color = ImageColorAllocate($im_dest, $foreground_R, $foreground_G, $foreground_B);
    $node_from_found = 0;
    $node_to_found = 0;
    foreach ($children_ha as $child) {
        $id_node_from = $child['id_child'];
        $linked = $child['linked'];
        if (!empty($linked)) {
            foreach ($linked as $link) {
                $id_node_to = $link['id_node_to'];
                mydebug(__LINE__, __FILE__, array('id_node_to' => $id_node_to, 'id_node_from' => $id_node_from));
                foreach ($position_node as $pos) {
                    $id_node = $pos['id_node'];
                    mydebug(__LINE__, __FILE__, array('id_node_from' => $id_node_from, 'id_node_to' => $id_node_to, 'id_node' => $id_node, 'trovato' => $node_from_found));
                    if ($id_node == $id_node_from and !$node_from_found) {
                        // get position of node from
                        mydebug(__LINE__, __FILE__, $id_node);
                        $bounds = $pos['bounds'];
                        $bounds = explode(",", $bounds);
                        $xa1 = $bounds[0];
                        $ya1 = $bounds[1];
                        // left top corner
                        $xa4 = $bounds[2];
                        $ya4 = $bounds[3];
                        // right bottom corner
                        $xa2 = $xa4;
                        $ya2 = $ya1;
                        // right top corner
                        $xa3 = $xa1;
                        $ya3 = $ya4;
                        // left bottom corner
                        $node_from_found = 1;
                    } elseif ($id_node == $id_node_to and !$node_to_found) {
                        // get position of node to
                        $node_to_found = 1;
                        $bounds = $pos['bounds'];
                        $bounds = explode(",", $bounds);
                        $xb1 = $bounds[0];
                        $yb1 = $bounds[1];
                        // left top corner
                        $xb4 = $bounds[2];
                        $yb4 = $bounds[3];
                        // right bottom corner
                        $xb2 = $xb4;
                        $yb2 = $yb1;
                        // right top corner
                        $xb3 = $xb1;
                        $yb3 = $yb4;
                        // left bottom corner
                    }
                }
                if ($node_from_found and $node_to_found) {
                    $node_from_found = 0;
                    $node_to_found = 0;
                    // Calcola la distanza tra i punti
                    $min_dist = 10000;
                    $min_array = 0;
                    $distanza_ar = array();
                    $coordinate_ar = array();
                    for ($i = 1; $i <= 4; $i++) {
                        $XA = "xa" . $i;
                        $YA = "ya" . $i;
                        for ($o = 1; $o <= 4; $o++) {
                            $XB = "xb" . $o;
                            $YB = "yb" . $o;
                            $distanza_ar[] = round(sqrt(abs(pow(${$XA} - ${$XB}, 2) + pow(${$YA} - ${$YB}, 2))));
                            $coordinate_ar[] = ${$XA} . "," . ${$YA} . "," . ${$XB} . "," . ${$YB};
                        }
                    }
                    for ($i = 0; $i <= 15; $i++) {
                        if ($distanza_ar[$i] < $min_dist) {
                            $min_array = $i;
                            $min_dist = $distanza_ar[$i];
                            # echo "Minore = $min_array, distanza Minore = $min_dist <BR>";
                        }
                    }
                    $coordinate = $coordinate_ar[$min_array];
                    $coord_final = explode(",", $coordinate);
                    # echo "$coordinate<BR><BR>";
                    $x_from = $coord_final[0];
                    $y_from = $coord_final[1];
                    $x_to = $coord_final[2];
                    $y_to = $coord_final[3];
                    imagedashedline($im_dest, $x_from, $y_from, $x_to, $y_to, $text_color);
                }
            }
        }
    }
    return true;
}
    $xp->data_void();
    if ($ris_ar['0'] != 'errore') {
        $dati = translateFN('Risultato: ') . $ris_ar[0] . '<br>';
        $dati .= translateFN('Nodi processati: ') . $ris_ar['1'] . '<br>';
        $dati .= translateFN('Media copiati: ') . $ris_ar['2'] . '<br>';
        $dati .= translateFN('Media non copiati: ') . count($ris_ar['3']) . '<br>';
        $backup_copy = copy(realpath(AUTHOR_COURSE_PATH_DEFAULT . '/' . $xml_file), realpath(UPLOAD_PATH . $author_id . '/' . $id . '.xml'));
    } else {
        $dati = translateFN('Risultato: ') . $ris_ar[0] . '<br>';
        $dati .= translateFN('Nodi processati: ') . @$ris_ar['1'] . '<br>';
        $dati .= translateFN('Media copiati: ') . @$ris_ar['2'] . '<br>';
        $dati .= translateFN('Media non copiati: ') . count(@$ris_ar['3']) . '<br>';
        while (list($key, $val) = each($ris_ar['errori'])) {
            $dati .= $val . '<br>';
        }
    }
} else {
    mydebug(__LINE__, __FILE__, $xp->init_error);
    $dati .= translateFN('ERRORE: Non è stato scelto un file XML o la sintassi non &egrave; corretta.');
}
// elimina l'oggetto dalla memoria
unset($xp);
$menu = '<a href="' . HTTP_ROOT_DIR . '/courses/author.php">' . translateFN('home') . '</a>';
$menu .= '<br><a href="' . HTTP_ROOT_DIR . '/admin/author_add_course.php">' . translateFN('nuovo corso') . '</a>';
$banner = (include ROOT_DIR . '/include/banner.inc.php');
$help = translateFN("Da qui l'Autore del corso pu&ograve; inserire un corso in formato XML nel database ADA.");
$status = translateFN('Inserimento corso');
// preparazione output HTML e print dell' output
$title = translateFN('ADA - Inserimento del corso nel database');
$content_dataAr = array('menu' => $menu, 'banner' => $banner, 'dati' => $dati, 'help' => $help, 'status' => $status, 'user_name' => $user_name, 'user_type' => $user_type, 'agenda' => $user_agenda->getHtml(), 'messages' => $user_messages->getHtml());
ARE::render($layout_dataAr, $content_dataAr);