-
Notifications
You must be signed in to change notification settings - Fork 1
/
generator2.php
executable file
·137 lines (133 loc) · 3.9 KB
/
generator2.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php
ini_set('max_execution_time', 900); // Onde 60 é o tempo em segundos
ini_set("memory_limit", "512M");
require ('class/database.php');
require ('class/geradordeclasse.php');
require ('class/geradordedoc.php');
require ('class/geradordeform.php');
require('class/zip.lib.php');
function delTree($dir){
$files = glob($dir . '*', GLOB_MARK );
foreach($files as $file){
if( substr( $file, -1 ) == '/' )
delTree( $file );
else
unlink( $file );
}
if (is_dir($dir)) rmdir( $dir );
}
if(
strlen($_POST['host'])<=0 ||
strlen($_POST['user'])<=0 ||
strlen($_POST['passwd'])<=0 ||
strlen($_POST['db'])<=0
)
{
$action="generator2.php";
include("index.php");
exit(0);
}
$database =@ new DataBase(
$_POST['host'],
$_POST['user'],
$_POST['passwd'],
$_POST['db']
);
if(!@$database->get_db_info())
{
$action="generator2.php";
include("index.php");
exit(0);
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Gerador de classes versao 1.0</title>
<script type="text/javascript">
<!--
function selectall(campo,opt) {
var aselect = campo;
var aselectLen = aselect.length;
for(i = 0; i < aselectLen; i++) {
aselect.options[i].selected = opt;
}
}
-->
</script>
</head>
<body>
<center>
<fieldset style="width: 600px;">
<legend>
<font face="Arial" size="3">
<b>
Gerador de classes versao 1.0
</b>
</font>
</legend>
<br/>
<?php
if(strlen($_POST)>0) //submit form
{
echo '
<fieldset style="width: 90%;">
<legend>
<b>Geraçao concluida!</b>
</legend>
<div align="center" style="text-align:left;width:90%;overflow:auto;">';
$user=$_POST['user'];
$passwd=$_POST['passwd'];
$db=$_POST['db'];
$host=$_POST['host'];
$project=$_POST['project'];
$autor=$_POST['autor'];
$name=ereg_replace("[^a-zA-Z0-9_.]", "",$project);
$tab=false;
$allinone='s';
if(@mkdir("projetos/".$name) || @opendir("projetos/".$name)){
$erro=0;
$errod=0;
$errod2=0;
$errof=0;
$erroc=0;
$classes=new geradordeclasse($host,$user,$passwd,$db,$tab,$project,$autor,"projetos/".$name);
echo "Criando classes para banco de dados <b>{$db}</b>:";
$erroc=$classes->grava();
echo $erroc==0?"<font color=\"green\">OK</font>":"<font color=\"red\">ERRO</font>";
echo "<br>";
$form=new geradordeform($host,$user,$passwd,$db,$tab,$project,$autor,"projetos/".$name,$dict);
echo "Criando arquivos de gerencia para banco de dados <b>{$db}</b>:";
$errof=$form->grava(false,$allinone);
$errof=$form->grava(false,false);
echo $errof==0?"<font color=\"green\">OK</font>":"<font color=\"red\">ERRO</font>";
echo "<br>";
$erro+=$erroc+$errod+$errof;
echo "<hr>";
$doc=new geradordedoc($host,$user,$passwd,$db,false,$project,$autor,"projetos/".$name);
echo "Criando diagramas uml para o banco de dados <b>{$db}</b>:";
$errod=$doc->grava2();
echo $errod2==0?"<font color=\"green\">OK</font>":"<font color=\"red\">ERRO</font>";
echo "<br>";
$erro+=$erroc+$errod+$errof+$errod2;
if($erro>0){
echo "<font color=\"red\">PASTA SEM PERMIÇÕES!<br>POR FAVOR DÊ PERMIÇÕES DE LEITURA E ESCRITA NA PASTA PROJETOS</font>";
}else{
@unlink("projetos/".$name."/".$name.".zip");
$zipfile=new zipfile();
$zipfile->addDirContent("projetos/".$name."/",1);
$zipfile->save("projetos/tmp/".$name.".zip");
echo '<a href="'."projetos/tmp/".$name.".zip".'">Download</a>';
exec("chmod -R 777 "."projetos/".$name."/");
exec("chmod 777 "."projetos/tmp/".$name.".zip");
delTree("projetos/".$name."/");
}
}else{
echo "<font color=\"red\">PASTA SEM PERMIÇÕES!<br>POR FAVOR DÊ PERMIÇÕES DE LEITURA E ESCRITA NA PASTA PROJETOS</font>";
}
echo "
</div>
</fieldset>";
}//end if
?>