예제 #1
0
function xml_response($data = array(), $root = 'response', $indent = 0)
{
    $tab = str_repeat("\t", $indent);
    $do_root = !empty($root);
    $xml = $do_root ? "{$tab}<{$root}>\n" : "";
    foreach ($data as $key => $value) {
        if (is_array($value)) {
            $xml .= xml_response($value, $key, $indent + 1);
        } else {
            if (is_numeric($key)) {
                $key = 'index';
            }
            $xml .= "{$tab}\t<{$key}>";
            // one extra tab is added to nest under its root node
            if (strpos($value, '<') || strpos($value, '>') || strpos($value, '&')) {
                $xml .= "<![CDATA[{$value}]]>";
            } else {
                $xml .= $value;
            }
            $xml .= "</{$key}>\n";
        }
    }
    if ($do_root) {
        $xml .= "{$tab}</{$root}>\n";
    }
    return $xml;
}
예제 #2
0
파일: dao.php 프로젝트: engcampo/engcampo
function mysqlConnection()
{
    //$mysql_host, $mysql_user_name, $mysql_password, $mysql_db_name){
    if (!mysql_connect($GLOBALS["mysql_host"], $GLOBALS["mysql_user_name"], $GLOBALS["mysql_password"])) {
        xml_response('false', 'true', 'Erro do servidor', 'Não foi possível conectar ao banco de dados.', 'OK');
        exit;
    }
    if (!mysql_select_db($GLOBALS["mysql_db_name"])) {
        xml_response('false', 'true', 'Erro do servidor', 'Não foi possível consultar o banco de dados.', 'OK');
        exit;
    }
}
예제 #3
0
**/
include '../configs.php';
include "../lang/{$LANG}.php";
include 'common.php';
$dir = $_POST['dir'];
$file = $_POST['file'];
$directory = $PUBLIC_HTML_DIR . $dir;
$path = $directory . $file;
if ($dir == "") {
    die(xml_response('alert', $DLG['select_dir']));
}
if (!is_writable($directory)) {
    die(xml_response('error', $DLG['no_permission']));
}
if (!validate_path($dir)) {
    die(xml_response('error', $DLG['invalid_dir'] . " [b]({$directory})[/b]"));
}
//cheking file name
if (ereg("[^a-zA-Z0-9._ -]", $file) || substr($file, 0, 1) == ".") {
    die(xml_response('alert', $DLG['invalid_dirname']));
}
//check is file name exists
if (file_exists($directory . $file)) {
    die(xml_response('alert', $DLG['dir_exists']));
}
umask(02);
if (mkdir($directory . $file, 0775)) {
    die(xml_response('done', "[b]'{$file}'[/b] " . $DLG['dir_add_success']));
}
die(xml_response('error', "[b]'{$file}'[/b] " . $DLG['dir_add_failure']));
예제 #4
0
파일: index.php 프로젝트: engcampo/engcampo
function mysqlConnection($mysql_host, $mysql_user_name, $mysql_password, $mysql_db_name)
{
    if (!mysql_connect($mysql_host, $mysql_user_name, $mysql_password)) {
        xml_response('false', 'true', 'Remote Server Error', 'Could not connect to MySQL. Please try again later.', 'OK');
        exit;
    }
    if (!mysql_select_db($mysql_db_name)) {
        xml_response('false', 'true', 'Remote Server Error', 'Could not select the database in MySQL. Please try again later.', 'OK');
        exit;
    }
}
예제 #5
0
function retornaMensagem($valida, $show_alert, $titulo, $msg, $botao)
{
    xml_response($valida, $show_alert, $titulo, $msg, $botao);
}
예제 #6
0
}
if (!file_exists($path)) {
    die(xml_response('error', $DLG['file_not_found'] . " [b]({$file})[/b]"));
}
if (!validate_path($path)) {
    die(xml_response('error', $DLG['invalid_dir'] . " [b]({$dir}{$file})[/b]"));
}
if (!is_writable($path)) {
    die(xml_response('error', $DLG['no_permission'] . " [b]({$file})[/b]"));
}
$new_filename = format_filename($new_name);
if (ereg("[^a-zA-Z0-9._-]", $new_filename)) {
    die(xml_response('alert', $DLG['invalid_filename']));
}
$info = swampy_pathinfo($path);
$ext = $info['extension'] != "" ? "." . $info['extension'] : "";
$nfile = $new_filename . $ext;
if (file_exists($directory . $nfile)) {
    die(xml_response('alert', $DLG['file_exists']));
}
foreach ($IMAGE_FORMATS as $format) {
    $ext = $format['ext'] ? "." . $format['ext'] : "." . $info['extension'];
    $format_path = $directory . $format['dir'] . $info['filename'] . $ext;
    if (file_exists($format_path)) {
        if (!rename($format_path, $directory . $format['dir'] . $new_filename . $ext)) {
            die(xml_response('error', $DLG['rename_failure']));
        }
    }
}
die(xml_response('done', "[b]'{$file}'[/b] {$DLG['rename_success']} [b]'{$nfile}'[/b]"));
예제 #7
0
$path = $directory . $file;
if ($file == "") {
    die(xml_response('alert', $DLG['select_file']));
}
if (!file_exists($path)) {
    die(xml_response('error', $DLG['file_not_found'] . " [b]({$file})[/b]"));
}
if (!validate_path($path)) {
    die(xml_response('error', $DLG['invalid_dir'] . " [b]({$dir}{$file})[/b]"));
}
if (is_dir($path)) {
    die(xml_response('alert', $DLG['not_file'] . " [b]({$file})[/b]"));
}
if (!is_writable($path)) {
    die(xml_response('error', $DLG['no_permission'] . " [b]({$file})[/b]"));
}
if ($_POST['confirm']) {
    $info = swampy_pathinfo($path);
    //Deletes all posibal same image formats
    foreach ($IMAGE_FORMATS as $format) {
        $ext = $format['ext'] ? "." . $format['ext'] : "." . $info['extension'];
        $format_path = $directory . $format['dir'] . $info['filename'] . $ext;
        if (file_exists($format_path)) {
            unlink($format_path);
        }
    }
    if (file_exists($path) && !unlink($path)) {
        die(xml_response('error', "[b]'{$file}'[/b] " . $DLG['file_delete_failure']));
    }
    die(xml_response('done', "[b]'{$file}'[/b] " . $DLG['file_delete_success']));
}
예제 #8
0
    } else {
        array_push($ofiles, $file);
    }
}
$files = array_merge($odirs, $ofiles);
/* Parent dir */
$parent_dir = str_replace(basename($dir) . "/", "", $dir);
if (validate_path($parent_dir)) {
    $xml = "\t<file type='parent' dir='{$parent_dir}' file='' extension='' size='' dimentions='' bg=''>{$DLG['up']}</file>\n";
}
//	echo "<div onDblClick=\"browser.enterDir('$parent_dir');\" class='fim-thumb'>\n\t<div class='image ext-parent'></div>\n\t<div class='filename'>{$DLG['up']}</div>\n</div>\n";
/* Prints file thubms */
foreach ($files as $file) {
    $xml .= fileXML($file);
}
die(xml_response('data', $xml));
function fileXML($file)
{
    global $HOST, $PUBLIC_HTML_DIR, $IMAGE_EXTENSIONS, $IMAGE_FORMATS, $dir, $directory, $DLG;
    if (substr($file, 0, 1) == ".") {
        return;
    }
    $path = $directory . $file;
    $pathinfo = swampy_pathinfo($path);
    $size = "";
    $dimentions = "";
    if (is_dir($path)) {
        $filename = $file;
        $extension = $DLG['dir'];
        $ext = "dir";
        $type = "dir";
예제 #9
0
function output_result($code, $message = array(), $json = true)
{
    $data = array();
    if (!is_array($message)) {
        $data = array('code' => $code, 'message' => $message);
    } else {
        $data = array_merge(array('code' => $code), $message);
    }
    if ($json) {
        header("Content-Type: application/x-javascript");
        print json_encode($data);
    } else {
        header("Content-Type: text/xml", true);
        print xml_response($data);
    }
    exit;
}
예제 #10
0
        $device_uuid8 = $_POST['device_uuid8'];
    }
    if (isset($_POST['form_version'])) {
        if (version_compare($_POST['form_version'], '2.0', '<')) {
            $show_alert = "true";
            // true or false
            $title = "Novo formulário disponível";
            // Text for the pop up alert
            $message = "Olá, há um novo formulário 'Vistoria' disponivel para download. Por favor, baixe e instale.";
            //Message body for the pop up alert
            $version = "2.0";
            // Newer version
            $form_url = "http://www.skyengenhariadecampo.com.br/files/Vistoria.form";
            // If there is no <form_url> element, the button does not turn into a download link.
            $button_label = "Download";
            xml_response('true', $title, $message, $version, $form_url, 'OK');
        }
    }
}
/**
 * Send XML Response.
 *
 * @param string $success String for success or failure ('true' is success, 'false' is failure)
 * @param string $show_alert String for showing alert on FormEntry Touch ('true' to show, 'false' to not show)
 * @param string $title String for displaying title of alert on FormEntry Touch
 * @param string $message String for displaying body message of alert on FormEntry Touch
 * @param string $version String for information FormEntry Touch of the version at the server
 * @param string $form_url String fully qualified URL of the new form (.form file)
 * @param string $button_label String for displaying button label of alert on FormEntry Touch
 */
function xml_response($show_alert = 'true', $title = 'Novo formulário disponível', $message = 'Olá, há um novo formulário de Vistoria disponivel', $version = '1.1', $form_url = NULL, $button_label = 'OK')