Issues (379)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

perguntas.php (7 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
// $Id: perguntas.php,v 1.18 2007/03/24 20:08:53 marcellobrandao Exp $
3
//  ------------------------------------------------------------------------ //
4
//                XOOPS - PHP Content Management System                      //
5
//                    Copyright (c) 2000 XOOPS.org                           //
6
//                       <http://www.xoops.org/>                             //
7
//  ------------------------------------------------------------------------ //
8
//  This program is free software; you can redistribute it and/or modify     //
9
//  it under the terms of the GNU General Public License as published by     //
10
//  the Free Software Foundation; either version 2 of the License, or        //
11
//  (at your option) any later version.                                      //
12
//                                                                           //
13
//  You may not change or alter any portion of this comment or credits       //
14
//  of supporting developers from this source code or any supporting         //
15
//  source code which is considered copyrighted (c) material of the          //
16
//  original comment or credit authors.                                      //
17
//                                                                           //
18
//  This program is distributed in the hope that it will be useful,          //
19
//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
20
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
21
//  GNU General Public License for more details.                             //
22
//                                                                           //
23
//  You should have received a copy of the GNU General Public License        //
24
//  along with this program; if not, write to the Free Software              //
25
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
26
//  ------------------------------------------------------------------------ //
27
/**
28
 * perguntas.php, Respons�vel por exibir a pergunta da vez
29
 *
30
 * Este arquivo prepara o formul�rio com a pergunta e se houver um
31
 * documento para ele ele tamb�m o exibe
32
 *
33
 * @author  Marcello Brand�o <[email protected]>
34
 * @version 1.0
35
 * @package assessment
36
 */
37
38
/**
39
 * Arquivos de cabe�alho do Xoops para carregar ...
40
 */
41
include dirname(dirname(__DIR__)) . '/mainfile.php';
42
43
/**
44
 * Definindo arquivo de template da p�gina
45
 */
46
$xoopsOption['template_main'] = 'assessment_perguntas.tpl';
47
48
include dirname(dirname(__DIR__)) . '/header.php';
49
50
/**
51
 * Inclus�es das classes do m�dulo
52
 */
53
include __DIR__ . '/class/assessment_perguntas.php';
54
include __DIR__ . '/class/assessment_provas.php';
55
include __DIR__ . '/class/assessment_respostas.php';
56
include __DIR__ . '/class/assessment_resultados.php';
57
include __DIR__ . '/class/assessment_documentos.php';
58
include __DIR__ . '/class/navegacao.php'; // classe derivada da pagenav do xoops para exibir as perguntas que j� foram respondidas
59
60
/**
61
 * Inclus�o de classe de barra de navega��o
62
 */
63
include_once dirname(dirname(__DIR__)) . '/class/pagenav.php';
64
65
/**
66
 * Pegando cod_prova  e start do GET e uid do aluno da session
67
 * o start � a possi��o em que a prova est�, a quest�o
68
 */
69
$cod_prova = $_GET['cod_prova'];
70
$uid       = $xoopsUser->getVar('uid');
71
$start     = $_GET['start'];
72
73
/**
74
 * Cria��o das F�bricas de objetos que vamos precisar
75
 */
76
$fabrica_de_provas     = new Xoopsassessment_provasHandler($xoopsDB);
77
$fabrica_resultados    = new Xoopsassessment_resultadosHandler($xoopsDB);
78
$fabrica_de_respostas  = new Xoopsassessment_respostasHandler($xoopsDB);
79
$fabrica_de_perguntas  = new Xoopsassessment_perguntasHandler($xoopsDB);
80
$fabrica_de_documentos = new Xoopsassessment_documentosHandler($xoopsDB);
81
82
/**
83
 * Buscando na f�brica a prova a que esta pergunta pertence
84
 */
85
$prova = $fabrica_de_provas->get($cod_prova);
86
87
/**
88
 * Verificando privil�gios do aluno para esta prova
89
 */
90
if (!$prova->isAutorizado()) {
91
    redirect_header('index.php', 5, _MA_ASSESSMENT_PROIBIDO);
92
}
93
94
/**
95
 * Verificando prova j� expirou
96
 */
97
$fim          = $prova->getVar('data_fim', 'n');
98
$tempo        = $prova->getVar('tempo', 'n');
99
$fimmaistempo = $fabrica_de_provas->dataMysql2dataUnix($fim) + $tempo;
100
101
if ($fimmaistempo < time()) {
102
    redirect_header('index.php', 5, _MA_ASSESSMENT_PROIBIDO);
103
}
104
105
/**
106
 * Verificando se aluno j� tinha terminado a prova antes em caso positivo
107
 * informa atraves de mensagem
108
 */
109
$criteria_prova = new criteria('cod_prova', $cod_prova);
110
$criteria_prova->setOrder('ASC');
111
$criteria_prova->setSort('ordem');
112
$criteria_aluno     = new criteria('uid_aluno', $uid);
113
$criteria_terminou  = new criteria('terminou', 1);
114
$criteria_resultado = new criteriaCompo($criteria_aluno);
115
$criteria_resultado->add($criteria_prova);
116
$criteria_resultado->add($criteria_terminou);
117
if ($fabrica_resultados->getCount($criteria_resultado) > 0) {
118
    redirect_header('index.php', 5, _MA_ASSESSMENT_JATERMINOU);
119
}
120
/**
121
 * Verificando se a prova j� tem perguntas cadastradas se n�o
122
 * tiver , n�o deixa aluno ter acesso
123
 */
124
$qtd_perguntas = $fabrica_de_perguntas->getCount($criteria_prova);
125
if ($qtd_perguntas < 1) {
126
    redirect_header('index.php', 5, _MA_ASSESSMENT_PROVAVAZIA);
127
}
128
129
/**
130
 * Cria��o de objetos de crit�rio para passar para as F�bricas
131
 */
132
$criteria_compo = new criteriaCompo($criteria_prova);
133
$criteria_compo->add($criteria_aluno);
134
135
/**
136
 * Buscando na f�brica a quantidade de resultados desta prova para este aluno
137
 * para logo em seguida verificar se j� existe este objeto, n�o exisitndo
138
 * joga de volta para a introdu��o. O aluno n�o pode pular a instrocu��o por
139
 * quest�es funcionais
140
 */
141
$qtd_resultados = $fabrica_resultados->getCount($criteria_compo);
142
if ($qtd_resultados < 1) {
143
    redirect_header('verprova.php?cod_prova=' . $cod_prova, 5, 'Voc� n�o pode pular a parte de iniciar prova');
144
}
145
146
/**
147
 * Buscando o objeto resultado desta prova deste aluno na f�brica
148
 */
149
$resultados = $fabrica_resultados->getObjects($criteria_compo);
150
$resultado  = $resultados[0];
151
152
/**
153
 * Calculos de tempo restante, tempo gasto e hor�rio do fim da prova
154
 * obs: cabe passar isso para dentro da classe resultado ou prova
155
 */
156
$horaatual = time() - 18000;
157
//echo $horaatual . 'horaatual </br>';
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
158
$serverXX = abs((int)($GLOBALS['xoopsConfig']['server_TZ'] * 3600.0));
159
//echo $serverXX . 'server TZ </br>';
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
160
//echo 'Local: ' . date('r') . 'n<br />GMT: ' . gmdate('r') . '<br />';
161
162
$data_inicio_segundos = $fabrica_de_provas->dataMysql2dataUnix($resultado->getVar('data_inicio'));
163
//echo $data_inicio_segundos . 'data_inicio_segundos </br>';
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
164
165
$tempo_prova = $prova->getVar('tempo');
166
//echo $tempo_prova . 'tempo_prova   </br>';
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
167
168
$tempo_restante = $fabrica_de_provas->converte_segundos(($data_inicio_segundos + $tempo_prova) - $horaatual, 'H');
169
//echo $tempo_restante . 'tempo_restante </br>';
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
170
//var_dump($tempo_restante);
171
172
$tempo_gasto = $fabrica_de_provas->converte_segundos($horaatual - $data_inicio_segundos, 'H');
173
//echo $tempo_gasto . 'tempo_gasto  </br>';
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
174
//var_dump($$tempo_gasto);
175
176
$hora_fim_da_prova = $fabrica_de_provas->converte_segundos($data_inicio_segundos + $tempo_prova, 'H');
177
//echo $hora_fim_da_prova . 'hora_fim_da_prova  </br>';
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
178
//var_dump($hora_fim_da_prova);
179
/**
180
 * Verifica��o de tempo da prova: se estourar o tempo salvar o resultado e
181
 * avisar o aluno com a possibilidade de dar a nota direto pro aluno se assim
182
 * estiver definido na administra��o
183
 */
184
if ($tempo_restante['segundos'] < 0) {
185
    $resultado->setVar('terminou', 1);
186
    $resultado->unsetNew();
187
    if ($xoopsModuleConfig['notadireta'] == 1) {
188
        $resultado->setVar('fechada', 1);
189
    }
190
    $fabrica_resultados->insert($resultado, true);
191
    redirect_header('index.php', 5, _MA_ASSESSMENT_ACABOU);
192
}
193
194
//busca titulo da prova
195
$titulo_prova = $prova->getVar('titulo', 's');
196
197
/**
198
 * buscando as perguntas da prova, depois separando
199
 * a nossa pergunta e enfim pegando o c�digo dela que vamos precisar
200
 */
201
$perguntas    = $fabrica_de_perguntas->getObjects($criteria_prova);
202
$pergunta     = $perguntas[$start];
203
$cod_pergunta = $pergunta->getVar('cod_pergunta');
204
205
/**
206
 * buscando documentos a serem exibidos antes da pergunta
207
 */
208
$documentos =& $fabrica_de_documentos->getDocumentosProvaPergunta($cod_prova, $cod_pergunta);
209
210
/**
211
 * Cria��o de objetos de crit�rio para passar para as F�bricas
212
 */
213
$criteria_pergunta = new criteria('cod_pergunta', $cod_pergunta);
214
215
/**
216
 * buscando as respostas a serem exibidas
217
 */
218
$respostas = $fabrica_de_respostas->getObjects($criteria_pergunta);
219
220
/**
221
 * buscar resposta anterior a esta pergunta caso
222
 * o aluno j� a tenha respondido e o n�mero de perguntas que
223
 * ele j� respondeu
224
 */
225
$cod_resposta_anterior = $resultado->getRespostaUsuario($cod_pergunta);
226
$qtd_respostas         = $resultado->contarRespostas();
227
228
$cod_resultado = $resultado->getVar('cod_resultado');
229
230
/**
231
 * Vamos buscar os codigos das perguntas respondidas e os codigos das perguntas
232
 * para passar como parametros para a barra de navega��o que marca as perguntas
233
 * que j� foram respondidas em vermelho.
234
 */
235
$cod_perguntas_respondidas = $resultado->getCodPerguntasAsArray();
236
$cod_perguntas             =& $fabrica_de_perguntas->getCodObjects($criteria_prova);
237
$navegacao                 = new NavegadorProva($qtd_perguntas, 1, $start, 'start', 'cod_prova=' . $cod_prova);
238
$barra_navegacao           = $navegacao->renderImageNav($cod_perguntas, $cod_perguntas_respondidas, $xoopsModuleConfig['qtdmenu']);
239
240
//Montando o Formul�rio
241
$formulario = $fabrica_de_perguntas->renderFormResponder('form_resposta.php', $pergunta, $respostas, $cod_resposta_anterior);
242
$formulario->assign($xoopsTpl);
243
244
//sanitizing
245
//falta um if para n�o dar uma notice
246
foreach ($documentos as $doc) {
247
    //    $doc['documento'] = text_filter($doc['documento'],true);
248
    $doc['documento'] = $doc['documento'];
249
}
250
//nome do m�dulo
251
$nome_modulo = $xoopsModule->getVar('name');
252
253
//Repassando as vari�veis para o template
254
$xoopsTpl->assign('xoops_pagetitle', $xoopsModule->getVar('name') . ' - ' . $titulo_prova);
255
$xoopsTpl->assign('nome_modulo', $nome_modulo);
256
$xoopsTpl->assign('documentos', $documentos);
257
$xoopsTpl->assign('barra_navegacao', $barra_navegacao);
258
$xoopsTpl->assign('start', $start);
259
$xoopsTpl->assign('titulo', $titulo_prova);
260
$xoopsTpl->assign('cod_prova', $cod_prova);
261
$xoopsTpl->assign('cod_resultado', $cod_resultado);
262
$xoopsTpl->assign('qtd_perguntas', $qtd_perguntas);
263
$xoopsTpl->assign('qtd_respostas', $qtd_respostas);
264
$xoopsTpl->assign('lang_andamento', sprintf(_MA_ASSESSMENT_ANDAMENTO, $qtd_respostas, $qtd_perguntas));
265
$xoopsTpl->assign('lang_encerrar', _MA_ASSESSMENT_ENCERRARPROVA);
266
$xoopsTpl->assign('lang_temporestante', sprintf(_MA_ASSESSMENT_TEMPORESTANTECOMPOSTO, $tempo_restante['horas'], $tempo_restante['minutos']));
267
$xoopsTpl->assign('lang_textosapoio', _MA_ASSESSMENT_TEXTOSAPOIO);
268
$xoopsTpl->assign('lang_pergunta', _MA_ASSESSMENT_PERGUNTA);
269
$xoopsTpl->assign('lang_respostas', _MA_ASSESSMENT_RESPOSTAS);
270
$xoopsTpl->assign('lang_legenda', _MA_ASSESSMENT_LEGENDA);
271
$xoopsTpl->assign('lang_jaresp', _MA_ASSESSMENT_JARESP);
272
$xoopsTpl->assign('lang_naoresp', _MA_ASSESSMENT_NAORESP);
273
$xoopsTpl->assign('lang_iconjaresp', _MA_ASSESSMENT_ICONJARESP);
274
$xoopsTpl->assign('lang_iconnaoresp', _MA_ASSESSMENT_ICONNAORESP);
275
$xoopsTpl->assign('tempo_restante', $tempo_restante);
276
277
//Fecha a p�gina com seu rodap�. Inclus�o Obrigat�ria
278
include dirname(dirname(__DIR__)) . '/footer.php';
279