Esempio n. 1
0
 public function getContent()
 {
     // User is logged in
     if (LOGGED) {
         $this->subcodename = 'logged';
         $tpl = new PHPTAL('blocks/user_panel/logged.html');
         $tpl->user = User::format(User::$id, User::$nickname, User::$groupId);
         $pm_item = User::$pmNew ? array(t('Messages <strong>(New: %new)</strong>', array('%new' => $user->pm_new)), 'pm/inbox') : array(t('Messages'), 'pm');
         $tpl->items = items(array($pm_item[0] => HREF . $pm_item[1], t('Administration') => HREF . 'admin', t('Edit profile') => HREF . 'edit_profile', t('Log out') => HREF . 'logout'));
         return $tpl->execute();
     } else {
         $err = new Error();
         $note = new Notifier('note-user_panel');
         $this->subcodename = 'not_logged';
         $form = array('logname' => null, 'password' => null);
         if ($_POST['login'] && $_POST['user_panel']) {
             $form['logname'] = $_POST['logname-session'] ? filter($_POST['logname-session'], 100) : '';
             $form['password'] = $_POST['password-session'] ? $_POST['password-session'] : '';
             $err->setError('logname_empty', t('Logname field is required.'))->condition(!$form['logname']);
             $err->setError('logname_not_exists', t('Entered logname is not registered.'))->condition(!User::loginNameRegistered($form['logname']));
             $err->setError('password_empty', t('Password field is required.'))->condition(!$form['password']);
             $err->setError('password_incorrect', t('ERROR_PASS_INCORRECT'))->condition($form['password'] && !User::loginPasswordCorrect($form['password']));
             if ($err->noErrors()) {
                 redirect('./');
             } else {
                 $note->error($err->toArray());
             }
         }
         $tpl = new PHPTAL('blocks/user_panel/not_logged.html');
         $tpl->note = $note;
         $tpl->form = $form;
         $tpl->err = $err->toArray();
         return $tpl->execute();
     }
 }
Esempio n. 2
0
    public function getContent()
    {
        global $sql;
        //Lang::load('blocks/shoutbox/lang.*.php');
        $err = new Error();
        $note = new Notifier('note-shoutbox');
        $form['author'] = LOGGED ? User::$nickname : '';
        $form['message'] = '';
        if (isset($_POST['reply-shoutbox'])) {
            $form['author'] = LOGGED ? User::$nickname : filter($_POST['author-shoutbox'], 100);
            $form['message'] = filter($_POST['message-shoutbox'], Kio::getConfig('message_max', 'shoutbox'));
            $err->setError('author_empty', t('Author field is required.'))->condition(!$form['author']);
            $err->setError('author_exists', t('Entered nickname is registered.'))->condition(!LOGGED && is_registered($form['author']));
            $err->setError('message_empty', t('Message field is required.'))->condition(!$form['message']);
            // No errors
            if ($err->noErrors()) {
                $sql->exec('
					INSERT INTO ' . DB_PREFIX . 'shoutbox (added, author, message, author_id, author_ip)
					VALUES (
						' . TIMESTAMP . ',
						"' . $form['author'] . '",
						"' . cut($form['message'], Kio::getConfig('message_max', 'shoutbox')) . '",
						' . UID . ',
						"' . IP . '")');
                $sql->clearCache('shoutbox');
                $note->success(t('Entry was added successfully.'));
                redirect(HREF . PATH . '#shoutbox');
            } else {
                $note->error($err->toArray());
            }
        }
        // If cache for shoutbox doesn't exists
        if (!($entries = $sql->getCache('shoutbox'))) {
            $query = $sql->query('
				SELECT u.nickname, u.group_id, s.added, s.author, s.author_id, s.message
				FROM ' . DB_PREFIX . 'shoutbox s
				LEFT JOIN ' . DB_PREFIX . 'users u ON u.id = s.author_id
				ORDER BY s.id DESC
				LIMIT ' . Kio::getConfig('limit', 'shoutbox'));
            while ($row = $query->fetch()) {
                if ($row['author_id']) {
                    $row['author'] = User::format($row['author_id'], $row['nickname'], $row['group_id']);
                    $row['message'] = parse($row['message'], Kio::getConfig('parser', 'shoutbox'));
                }
                $entries[] = $row;
            }
            $sql->putCacheContent('shoutbox', $entries);
        }
        try {
            $tpl = new PHPTAL('blocks/shoutbox/shoutbox.tpl.html');
            $tpl->entries = $entries;
            $tpl->err = $err->toArray();
            $tpl->form = $form;
            $tpl->note = $note;
            return $tpl->execute();
        } catch (Exception $e) {
            return template_error($e->getMessage());
            //echo Note::error($e->getMessage());
        }
    }
Esempio n. 3
0
 public static function getForm($errors = array())
 {
     global $cfg;
     if (LOGGED) {
         redirect(REFERER);
     }
     $note = new Notifier();
     $err = new Error();
     if ($errors) {
         $note->error($errors);
     }
     if ($_POST['login'] && $_POST['module']) {
         $form = array('logname' => $_POST['logname-session'] ? filter($_POST['logname-session'], 100) : '', 'password' => $_POST['password-session'] ? filter($_POST['password-session'], 100) : '');
         $err->setError('empty_logname', t('Logname field is required.'))->condition(!$form['logname']);
         $err->setError('logname_not_exists', t('The logname you used isn&apos;t registered.'))->condition($form['logname'] && !User::loginNameRegistered($form['logname']));
         $err->setError('password_empty', t('Password field is required.'))->condition(!$form['password']);
         $err->setError('password_invalid', t('Password is invalid.'))->condition($form['password'] && !User::loginPasswordCorrect($form['password']));
         $err->noErrors() ? redirect(REFERER) : $note->restore()->error($err->toArray());
     }
     $tpl = new PHPTAL('modules/login/form.html');
     $tpl->form = $form;
     $tpl->err = $err->toArray();
     $tpl->note = $note;
     echo $tpl->execute();
 }
Esempio n. 4
0
 public static function validateModel($model, $attrmapping = false)
 {
     //		if(\GO\Base\Util\Http::isPostRequest()){
     //			if(!empty($attrmapping)){
     //				foreach($attrmapping as $attr=>$replaceattr){
     //					$model->$replaceattr = $_POST[$attr];
     //				}
     //			}
     $errors = array();
     if (!$model->validate()) {
         $errors = $model->getValidationErrors();
     }
     if ($model->customfieldsRecord && !$model->customfieldsRecord->validate()) {
         $errors = array_merge($errors, $model->customfieldsRecord->getValidationErrors());
     }
     if (count($errors)) {
         foreach ($errors as $attribute => $message) {
             $formAttribute = isset($attrmapping[$attribute]) ? $attrmapping[$attribute] : $attribute;
             Input::setError($formAttribute, $message);
             // replace is needed because of a mix up with order model and company model
         }
         Error::setError(\GO::t('errorsInForm'));
         return false;
     } else {
         return true;
     }
 }
Esempio n. 5
0
 public function connect()
 {
     if (!isset($this->_dbh)) {
         if ($this->_dbh = @mysql_connect(HOST, USER, PASS)) {
             $this->_dbh = @mysql_select_db(BD, $this->_dbh);
         } else {
             $Error = new Error();
             $Error->setError('Não foi possível efetuar a conexão com o MySQL.');
             $Error->ShowError();
         }
     }
     return $this;
 }
Esempio n. 6
0
 function Show()
 {
     $va_nums = explode(';', $this->request->getParameter('n', pString));
     $va_error_messages = array();
     if (is_array($va_nums)) {
         $o_err = new Error(0, '', '', '', false, false);
         foreach ($va_nums as $vn_error_number) {
             $o_err->setError($vn_error_number, '', '', false, false);
             $va_error_messages[] = $o_err->getErrorMessage();
         }
     }
     $this->view->setVar('error_messages', $va_error_messages);
     $this->view->setVar('referrer', $this->request->getParameter('r', pString));
     $this->render('error_html.php');
 }
Esempio n. 7
0
 function Show()
 {
     $o_purify = new HTMLPurifier();
     $va_nums = explode(';', $this->request->getParameter('n', pString));
     $va_error_messages = $this->notification->getNotifications();
     if ((!is_array($va_error_messages) || sizeof($va_error_messages) == 0) && is_array($va_nums)) {
         $o_err = new Error(0, '', '', '', false, false);
         foreach ($va_nums as $vn_error_number) {
             $o_err->setError($vn_error_number, '', '', false, false);
             $va_error_messages[] = $o_err->getErrorMessage();
         }
     }
     $this->view->setVar('error_messages', $va_error_messages);
     $this->view->setVar('referrer', $o_purify->purify($this->request->getParameter('r', pString)));
     $this->render('error_html.php');
 }
Esempio n. 8
0
    public function getContent()
    {
        global $sql;
        $this->note = new Notifier();
        $err = new Error();
        // Redirect logged users to front page
        // Activate account
        // registration/activate/234/sfs9fsefsef36dsdgesefe4td
        if (u1 == 'activate' && ctype_digit(u2)) {
            return $this->accountActivation();
        } else {
            if (Kio::getConfig('type', 'registration') == 0) {
                return $this->note->error('Rejestracja została <strong>wstrzymana</strong>.');
            } else {
                //			Kio::addJsCode('$(\'#check_logname\').click(function(){alert();});');
                // Registering
                if (isset($_POST['register'])) {
                    // filter(string, limit)
                    $form = array('logname' => $_POST['logname'] ? filter($_POST['logname'], 100) : '', 'nickname' => $_POST['nickname'] ? filter($_POST['nickname'], 100) : '', 'pass' => $_POST['pass'] ? filter($_POST['pass'], 100) : '', 'pass2' => $_POST['pass2'] ? filter($_POST['pass2'], 100) : '', 'email' => strtolower(filter($_POST['email'], 100)), 'rules' => $_POST['rules'] ? true : false, 'newsletter' => $_POST['newsletter'] ? 1 : 0, 'pm_notify' => $_POST['pm_notify'] ? 1 : 0, 'hide_email' => $_POST['hide_email'] ? 1 : 0);
                    // Errors
                    $err->setError('logname_empty', t('Logname field is required.'))->condition(!$form['logname']);
                    $err->setError('logname_exists', t('The logname you used is already registered.'))->condition(is_registered($form['logname'], 'logname'));
                    $err->setError('nickname_empty', t('Nickname field is required.'))->condition(!$form['nickname']);
                    $err->setError('nickname_exists', t('The nickname you used is already registered.'))->condition(is_registered($form['nickname'], 'nickname'));
                    $err->setError('pass_empty', t('Password field is required.'))->condition(!$form['pass']);
                    $err->setError('pass_not_match', t('Passwords do not match.'))->condition($form['pass'] != $form['pass2'] && $form['pass']);
                    $err->setError('email_empty', t('E-mail field is required.'))->condition(!$form['email']);
                    $err->setError('email_invalid', t('E-mail address you entered is invalid.'))->condition($form['email'] && !is_email($form['email']));
                    $err->setError('email_exists', t('The e-mail you used is already registered.'))->condition(is_registered($form['email'], 'email'));
                    $err->setError('rules_not_accepted', t('Accepting the rules is required.'))->condition(!$form['rules'] && Kio::getConfig('show_rules', 'registration'));
                    // No errors
                    if ($err->noErrors()) {
                        $blocked = 1;
                        switch (Kio::getConfig('type', 'registration')) {
                            case 1:
                                $blocked = 'NULL';
                                $message = 'Rejestracja przebiegła pomyślnie, możesz się teraz zalogować.';
                                break;
                            case 2:
                                $message = 'Rejestracja przebiegła pomyślnie.<br />Wymagana jest aktywacja konta poprzez kliknięcie w odnośnik wysłany na Twoją skrzynkę e-mail.';
                                break;
                            default:
                                $message = 'Rejestracja przebiegła pomyślnie.<br />Wymagana jest aktywacja konta przez administratora, wówczas zostaniesz powiadomiony e-mail&#39;em.';
                        }
                        // Detect country
                        $form['country'] = end(explode('.', gethostbyaddr(IP)));
                        $form['country'] = $lang_system['COUNTRIES'][$form['country']] ? $form['country'] : '';
                        $stmt = $sql->prepare('
						INSERT INTO ' . DB_PREFIX . 'users
						SET
							logname = :logname,
							nickname = :nickname,
							email = :email,
							pass = :pass,
							registered = :registered,
							country = :country,
							newsletter = :newsletter,
							pm_notify = :pm_notify,
							hide_email = :hide_email,
							blocked = :blocked,
							time_zone = :time_zone,
							ip = :ip,
							auth_code = :auth_code,
							http_agent = :http_agent;
							
						UPDATE ' . DB_PREFIX . 'stats
						SET content = content + 1
						WHERE name = "registered_users"');
                        $stmt->execute(array('logname' => $form['logname'], 'nickname' => $form['nickname'], 'email' => $form['email'], 'pass' => md5($form['pass']), 'registered' => TIMESTAMP, 'country' => $form['country'], 'newsletter' => $form['newsletter'], 'pm_notify' => $form['pm_notify'], 'hide_email' => $form['hide_email'], 'blocked' => 1, 'time_zone' => Kio::getConfig('time_zone'), 'ip' => IP, 'auth_code' => auth_code($form['logname']), 'http_agent' => filter($_SERVER['HTTP_USER_AGENT'], 250)));
                        $this->note->success($message);
                        redirect(HREF . 'registration');
                    } else {
                        $this->note->error($err->toArray());
                    }
                }
                //			// No action
                //			else
                //			{
                //				$this->note->info(array(t('Register and enjoy additional services.')));
                //			}
                try {
                    $tpl = new PHPTAL('modules/registration/registration.tpl.html');
                    $tpl->form = $form;
                    $tpl->entries = $entries;
                    $tpl->err = $err->toArray();
                    $tpl->note = $this->note;
                    return $tpl->execute();
                } catch (Exception $e) {
                    return template_error($e);
                }
            }
        }
    }
Esempio n. 9
0
    $row['ESTADOCIVIL'] == 'V' ? print 'selected="selected"' : "";
    ?>
 value="V"><span>Viuvo(a)</span></option>
                            <option <?php 
    $row['ESTADOCIVIL'] == 'D' ? print 'selected="selected"' : "";
    ?>
 value="D"><span>Divorciado(a)</span></option>
                        </select>
                    </p>
                    <p><span style="width: 120px">Avaliação Médica:</span><textarea rows="5" cols="50"
                                                                                    name="avaliacao"><?php 
    $row['AVALIACAOMEDICA'];
    ?>
</textarea></p>
                    <hr>
					<input name="Id" type="hidden" value="<?php 
    echo $_GET['id'];
    ?>
"/>
					<input class="submit" type="submit" name="alterarcliente" style="margin: 10px 0 0 0;"  value="Alterar"/>
                    <input class="submit" type="button" onclick="history.go(-1);" value="Cancelar" style="margin: 0 0 0 10px;"/>
						
                </form>
            </div>
        </div>
    </div>
<?php 
} else {
    $Error->setError('� preciso estar logado para acessar a p�gina!');
    $Error->ShowDie();
}
Esempio n. 10
0
    public function getContent()
    {
        global $sql;
        $err = new Error();
        $form = array();
        if (Kio::getConfig('informations', 'contact')) {
            $info = Notifier::factory('note-contact_info')->info(parse(Kio::getConfig('informations', 'contact'), BBCODE . AUTOLINKS . EMOTICONS . CENSURE . PRE));
        }
        if (isset($_POST['send'])) {
            // Form values
            $form = array('receiver' => filter($_POST['receiver'], 100), 'sender' => LOGGED ? User::$nickname : filter($_POST['sender'], 100), 'email' => LOGGED ? User::$email : filter($_POST['email'], 100), 'subject' => filter($_POST['subject'], 100), 'message' => filter($_POST['message'], 250));
            if (!empty($_COOKIE[COOKIE . '-flood-contact']) && Kio::getConfig('flood_interval')) {
                $err->setError('flood', t('ERROR_FLOOD'));
            } else {
                // Errors
                if (!LOGGED) {
                    $err->setError('sender_empty', t('Sender field is required.'))->condition(!$form['sender']);
                    $err->setError('sender_exists', t('ERROR_SENDER_EXISTS'))->condition(is_registered($form['sender'], 'nickname'));
                    $err->setError('email_empty', t('E-mail address field is required.'))->condition(!$form['email']);
                    $err->setError('email_invalid', t('ERROR_EMAIL_INVALID'))->condition($form['email'] && !is_email($form['email']));
                }
                //				$err->setError('phone_invalid', t('ERROR_PHONE_INVALID'))
                //					->condition($form['phone'] && !preg_match('#^[0-9 ()+-]+$#', $form['phone']));
                $err->setError('subject_empty', t('Subject field is required.'))->condition(!$form['subject']);
                $err->setError('message_empty', t('Message field is required.'))->condition(!$form['message']);
            }
            if ($err->noErrors()) {
                $from = "From: {$form['email']}2";
                $msg = "Imię: {$imie}\nE-Mail: {$form['email']}2\nTelefon: {$telefon}\n\nTreść wiadomości:\n{$form['message']}\n\n\n----\nWiadomość została wysłana ze strony {$adres}\nIP: {$ip}";
                echo mail($form['email'], $temat, $msg, $from) ? $note->success(t('SUCCESS')) . redirect() : $note->error(t('Wystąpił błąd, spróbuj wysłać później'));
                if (Kio::getConfig('flood_interval')) {
                    setcookie(COOKIE . '-contact', 'true', TIMESTAMP + Kio::getConfig('flood_interval') + 1, '/');
                }
                $to = "*****@*****.**";
                $subject = "Test mail";
                $message = "Hello! This is a simple email message.";
                $from = "*****@*****.**";
                $headers = "From: {$from}";
                mail($to, $subject, $message, $headers);
            } else {
                $this->note->error($err->toArray());
            }
        }
        $stmt = $sql->setCache('contact')->prepare('
			SELECT id, nickname, group_id
			FROM ' . DB_PREFIX . 'users
			WHERE id IN (:receivers)');
        $stmt->bindParam(':receivers', Kio::getConfig('receivers', 'contact'));
        $stmt->execute();
        while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
            $row['g_name'] = Kio::getGroup($row['group_id'], 'name');
            $receivers[] = $row;
        }
        try {
            $tpl = new PHPTAL('modules/contact/contact.tpl.html');
            $tpl->message_limit = Kio::getConfig('message_max', 'contact');
            $tpl->form = $form;
            $tpl->user = User::toArray();
            $tpl->receivers = $receivers;
            $tpl->err = $err->toArray();
            $tpl->note = $this->note;
            $tpl->info = isset($info) ? $info : '';
            return $tpl->execute();
        } catch (Exception $e) {
            return template_error($e);
        }
    }
Esempio n. 11
0
                                        href="?page=UsuariosAlter&id=<?php 
            echo $value['CDUSUARIO'];
            ?>
"
                                        style="text-decoration: none; color: #FFFFFF;">Alterar</a></th>
                                <th class="delete" id="ExclUsuarios"><a
                                        href="?page=UsuariosExcl&id=<?php 
            echo $value['CDUSUARIO'];
            ?>
"
                                        style="text-decoration: none; color: #FFFFFF;">Excluir</a></th>
                            </tr>
                                <?php 
        }
    }
    ?>
                    <tr>
                        <th class="insert" id="InsUsuarios"><a href="?page=UsuariosCad"
                                                            style="text-decoration: none; color: #FFFFFF;">Incluir</a>
                        </th>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
<?php 
} else {
    $Error->setError('É preciso estar logado para acessar a página!');
    $Error->ShowDie();
}
Esempio n. 12
0
 /**
  * Adds a new error
  *
  * @param int $pn_num
  * @param string $ps_message
  * @param string $ps_context
  */
 function postError($pn_num, $ps_message, $ps_context, $ps_source = '')
 {
     $o_error = new Error();
     $o_error->setErrorOutput($this->opb_die_on_error);
     $o_error->setHaltOnError($this->opb_die_on_error);
     $o_error->setError($pn_num, $ps_message, $ps_context, $ps_source);
     array_push($this->errors, $o_error);
     return true;
 }
Esempio n. 13
0
 public function postError($pn_num, $ps_message, $ps_context, $ps_source = '')
 {
     $o_error = new Error();
     $o_error->setErrorOutput($this->error_output);
     $o_error->setError($pn_num, $ps_message, $ps_context, $ps_source);
     if (!$this->errors) {
         $this->errors = array();
     }
     array_push($this->errors, $o_error);
     return true;
 }
Esempio n. 14
0
                                <li><a href="?page=PosicaoEstoque">Posição de estoque</a></li>
                                <li><a href="?page=LogAtivos">Saída/Entrada Ativos</a></li>
                            </ul>
                        </li>
                    </ul>
                </li>
                <li><a href="?page=Logout">Sair do Sistema</a>
            </ul>
        </nav>
    </header>
    <div id="site_content">
        <div id="content">
            <h1>Produtos</h1>
			<?php 
    if (empty($arrValue)) {
        $Error->setError('Não há produto cadastrado!');
        $Error->ShowError();
    }
    ?>
            <div id="table">
                <table>
                    <thead>
                    <tr>
                        <th>Id</th>
                        <th>Nome</th>
                        <th>Descrição</th>
                        <th>Tipo de Produto</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php 
Esempio n. 15
0
 /**
  * 消息体加密处理.
  * @param unknown $msg
  * @return unknown|string
  */
 private function _msgEnCrypt($msg)
 {
     if (!$this->is_encrypt) {
         return $msg;
     }
     $timeStamp = trim($_GET['timestamp']);
     $nonce = trim($_GET['nonce']);
     $pc = $this->_getCryptObject();
     $ret_msg = '';
     $errCode = $pc->encryptMsg($msg, $timeStamp, $nonce, $ret_msg);
     if ($errCode == 0) {
         return $ret_msg;
     }
     Error::setError('124', '消息加密失败');
     $this->_exit();
 }
Esempio n. 16
0
                             <li><a href="?page=PosicaoEstoque">Posição de estoque</a></li>
                             <li><a href="?page=LogAtivos">Saída/Entrada Ativos</a></li>
                         </ul>
                     </li>
                 </ul>
             </li>
             <li><a href="?page=Logout">Sair do Sistema</a>
         </ul>
     </nav>
 </header>
 <div id="site_content">
     <div id="content">
         <h1>Saída de Ativos</h1>
         <?php 
 if (empty($arrValue)) {
     $Error->setError('Não há produto cadastrado para ser realizado a operação!');
     $Error->ShowError();
 } elseif (isset($_POST['confirmarsaida'])) {
     $Product->setQtd($_POST['nome'])->setId($_POST['sele'])->updateSaidaFromQtd();
     unset($_POST['confirmarsaida']);
     ?>
             <div class="back"><a href="?page=SaidaAtivos">Voltar</a></div>
             <?php 
 } else {
     ?>
             <div class="form_settings">
                 <form id="SaidaAtivos" method="post" action="">
                     <p><span>Produto(s)</span>
                         <select id="sele" name="sele" style="height: 22px;">
                             <?php 
     foreach ($arrValue as $value) {
Esempio n. 17
0
 public function postError($pn_num, $ps_message, $ps_context, $ps_source = '')
 {
     $o_error = new Error();
     $o_error->setErrorOutput($this->error_output);
     $o_error->setError($pn_num, $ps_message, $ps_context, $ps_source);
     if (!$this->errors) {
         $this->errors = array();
     }
     array_push($this->errors, $o_error);
     if (($app = AppController::getInstance()) && ($o_request = $app->getRequest()) && defined('__CA_ENABLE_DEBUG_OUTPUT__') && __CA_ENABLE_DEBUG_OUTPUT__) {
         $va_trace = debug_backtrace();
         array_shift($va_trace);
         $vs_stacktrace = '';
         while ($va_source = array_shift($va_trace)) {
             $vs_stacktrace .= " [{$va_source['file']}:{$va_source['line']}]";
         }
         $o_notification = new NotificationManager($o_request);
         $o_notification->addNotification("[{$pn_num}] {$ps_message} ({$ps_context}" . ($ps_source ? "; {$ps_source}" : '') . $vs_stacktrace);
     }
     return true;
 }
Esempio n. 18
0
                                <li><a href="?page=PosicaoEstoque">Posição de estoque</a></li>
                                <li><a href="?page=LogAtivos">Saída/Entrada Ativos</a></li>
                            </ul>
                        </li>
                    </ul>
                </li>
                <li><a href="?page=Logout">Sair do Sistema</a></li>
            </ul>
        </nav>
    </header>
	<div id="site_content">
        <div id="content">
				<h1>Idosos</h1>
			<?php 
    if (empty($arrValue)) {
        $Error->setError('Não há idosos cadastrados!');
        $Error->ShowError();
    }
    ?>
            <div id="table">
                <table>
                    <thead>
                    <tr>
                        <th>Id</th>
                        <th>Nome completo</th>
                        <th>Dt. Nascimento</th>
                    </tr>
                    </thead>
                    <tbody>
                        <?php 
    if (!empty($arrValue)) {
Esempio n. 19
0
    function getContent()
    {
        global $cfg, $user, $sql, $plug;
        $note = new Notifier();
        $tpl = new PHPTAL('plugins/comments/comments.tpl.html');
        $err = new Error();
        $tpl->entries = '';
        if ($this->total_comments != -1 && !Kio::getConfig('view_only_logged', 'comments')) {
            if ($this->total_comments > 0) {
                $tpl->backlink = $this->backlink;
                $tpl->cfg = $cfg;
                $tpl->user = $user;
                $tpl->entries = $this->getEntries();
            } else {
                $note->info('There is no comments.');
            }
            if (!Kio::getConfig('add_only_logged', 'comments') || LOGGED) {
                if ($this->edited) {
                    $form = array('id' => $this->edited['comment_id'], 'author' => $this->edited['comment_author'], 'author_id' => $this->edited['comment_author_id'], 'message' => $this->edited['comment_message']);
                    if (!$form['author']) {
                        $form['author'] = User::getNickname(BY_ID, $this->edited['comment_author_id']);
                    }
                    $this->edit_mode = true;
                } else {
                    $form['author'] = User::$nickname;
                }
                $add = isset($_POST['add']) ? true : false;
                $edit = isset($_POST['edit']) ? true : false;
                // Add or delete
                if (isset($_POST['add']) || $edit) {
                    $form['author'] = isset($_POST['add']) && LOGGED ? User::$nickname : filter($_POST['author'], 100);
                    $form['message'] = filter($_POST['message'], Kio::getConfig('message_max', 'comments'));
                    $err->setError('author_empty', t('Author field is required.'))->condition(!$form['author']);
                    $err->setError('author_exists', t('Entered nickname is registered.'))->condition($add && !LOGGED && is_registered($form['author'], 'nickname'));
                    $err->setError('message_empty', t('Message field is required.'))->condition(!$form['message']);
                    // No errors
                    if ($err->noErrors()) {
                        // Add
                        if (isset($_POST['add'])) {
                            $sql->exec('
								INSERT INTO ' . DB_PREFIX . 'comments (
									comment_owner, comment_owner_child_id, comment_author,
									comment_author_id, comment_author_ip, comment_added,
									comment_message, comment_backlink)
								VALUES(
									"' . u0 . '",
									' . $this->connector_id . ',
									"' . (!LOGGED || isset($_POST['edit']) ? $form['author'] : '') . '",
									' . UID . ',
									"' . IP . '",
									' . TIMESTAMP . ',
									"' . $form['message'] . '",
									"' . $this->backlink . '")');
                            $last = $sql->lastInsertId();
                            $sql->exec('
								UPDATE ' . DB_PREFIX . $this->owner . '
								SET comments = (comments + 1)
								WHERE id = ' . $this->connector_id);
                            setcookie(COOKIE . '-comments', 'true', TIMESTAMP + Kio::getConfig('flood_interval', 'comments') + 1, '/');
                            redirect(HREF . PATH . '#comment-' . $last);
                        } else {
                            if (isset($_POST['edit'])) {
                                if ($form['author_id'] = User::getId(BY_NICKNAME, $form['author'])) {
                                    $form['author'] = '';
                                } else {
                                    $form['author_id'] = 0;
                                }
                                $sql->exec('
								UPDATE ' . DB_PREFIX . 'comments
								SET
									comment_author = "' . $form['author'] . '",
									comment_author_id = ' . $form['author_id'] . ',
									comment_message = "' . $form['message'] . '"
								WHERE comment_id = ' . $this->edited['comment_id']);
                                redirect(HREF . $this->edited['comment_backlink'] . '#comment-' . $this->edited['comment_id']);
                            }
                        }
                    } else {
                        $note->error($err->toArray());
                    }
                } else {
                    if (isset($_POST['delete_id']) && ctype_digit($_POST['delete_id'])) {
                        $sql->exec('
						DELETE FROM ' . DB_PREFIX . 'comments WHERE comment_id = ' . $_POST['delete_id'] . ';
						UPDATE ' . DB_PREFIX . $this->owner . ' SET comments = (comments - 1) WHERE id = ' . $this->connector_id);
                        redirect(strpos(REFERER, 'admin') ? REFERER : '#comments');
                    }
                }
                //$tpl->comments = $comments;
                $tpl->form = $form;
                $tpl->err = $err->toArray();
            } else {
                $note->error(sprintf('Dodawanie komentarzy jest możliwe tylko dla <a href="%1$slogin">zalogowanych</a> osób, <a href="%1$sregistration">zarejestruj się</a> jeśli nie masz jeszcze konta.', HREF));
            }
        } else {
            if ($this->total_comments != -1) {
                $note->error(array('Komentarze są widoczne tylko dla zalogowanych osób.', '<a href="' . HREF . 'registration">Zarejestruj się</a> jeśli nie masz jeszcze konta.'));
            }
        }
        $tpl->edit_mode = $this->edit_mode;
        $tpl->total_comments = $this->total_comments;
        $tpl->note = $note;
        return $tpl->execute();
    }
Esempio n. 20
0
 public function actionShow()
 {
     $id = Auth::getUser()['id'];
     $model = UsersModel::model()->where("`id`='{$id}'")->findRow();
     if (isset($_POST['user_data'])) {
         $model->email = $_POST['email'];
         $model->name = $_POST['name'];
         $model->save();
         Auth::logOut();
         Auth::login($model->login, $model->password);
     }
     if (isset($_POST['passwrds'])) {
         if (Auth::hashPassword($_POST['altpass']) != $model->password) {
             Error::setError("password", "Вы указали неверный пароль.");
             //echo "<script>alert('ne ok')</script>";
         } else {
             if ($_POST['password1']) {
                 $model->password = Auth::hashPassword($_POST['password1']);
             }
             $model->save();
             Auth::logOut();
             Auth::login($model->login, $model->password);
             //Message::setMessage("success", Lang::get("data_success"));
             //echo "<script>alert('ne ok')</script>";
         }
     }
     if (isset($_POST['updates'])) {
         // echo "1111";
     }
     if (isset($_POST['subscribe'])) {
         //  echo "11111";
     }
     if (isset($_POST['avatar_update'])) {
         $max_size = 400 * 1024;
         $valid_types = array("image/jpg", "image/jpeg");
         if ($_FILES['image']['name']) {
             $f_size = $_FILES['image']['size'];
             $f_type = $_FILES['image']['type'];
             if ($f_size > $max_size) {
                 echo 'wrong_size';
             } else {
                 if (!in_array($f_type, $valid_types)) {
                     echo 'wrong_type';
                 } else {
                     $model->user_avatar = File::save($_FILES['image'], "assets/images/avatar");
                     File::resizeImage($model->user_avatar, 300, 300);
                     $model->save();
                     $this->redirect("/profile");
                 }
             }
         }
     }
     if (isset($_POST['deleteProfile'])) {
         $id = Auth::getUser()['id'];
         $_SESSION["login"] = "";
         $_SESSION["id"] = "";
         $_SESSION["password"] = "";
         $_SESSION["admin"] = "";
         $_SESSION["email"] = "";
         Auth::logOut();
         UsersModel::model()->where("`id`='" . $id . "'")->delete();
         $this->redirect("/");
     }
     if (isset($_POST['deleteAvatar'])) {
         $model->user_avatar = "";
         $model->save();
         $this->redirect("/profile");
     }
     $viewed_series = UserSeriesViewedModel::model()->order("date DESC")->where("user_id=" . Auth::getUser()['id'])->findAll();
     $serials = MoviesModel::model()->findAll();
     $userId = Auth::getUser()['id'];
     $favors = FavoritesModel::model()->where("`user_id`='{$userId}'")->findAll();
     $in = "(";
     foreach ($favors as $favor) {
         $in .= "'{$favor->video_id}'" . ", ";
     }
     $in = substr($in, 0, -2);
     $in .= ")";
     if ($in == ")") {
         $movies = array();
     } else {
         $movies_count = MoviesModel::model()->where("`id` IN {$in}")->countAll();
     }
     $movies = MoviesModel::model()->where("`id` IN {$in}")->findAll();
     $dicts = DictModel::model()->where("`user_id`='" . Auth::getUser()['id'] . "'")->countAll();
     $userSubscribe = UserSubscribeModel::model()->where("`user_id`=" . Auth::getUser()['id'])->findAll();
     $this->view("profile/show", array("serials" => $serials, "user" => $model, "movies" => $movies, "movies_count" => $movies_count, "viewed_series" => $viewed_series, "dicts" => $dicts, "user_subscribe" => $userSubscribe), false);
 }
Esempio n. 21
0
 public function actionLogin()
 {
     if (isset($_POST['login'])) {
         if (!Auth::login($_POST['login'], $_POST['password'])) {
             Error::setError("login", Lang::get("wrong_authorization"));
         }
     }
     UserStats::logincount();
     $this->redirect("/");
 }
Esempio n. 22
0
                             <li><a href="?page=PosicaoEstoque">Posição de estoque</a></li>
                             <li><a href="?page=LogAtivos">Saída/Entrada Ativos</a></li>
                         </ul>
                     </li>
                 </ul>
             </li>
             <li><a href="?page=Logout">Sair do Sistema</a>
         </ul>
     </nav>
 </header>
 <div id="site_content">
     <div id="content">
         <h1>Relação de Dietas</h1>
         <?php 
 if (empty($arrDietas)) {
     $Error->setError('Não há dieta cadastrada para ser realizada a operação!');
     $Error->ShowError();
 } elseif (empty($arrValue)) {
     $Error->setError('Não há idosos cadastrados para ser realizado a operação!');
     $Error->ShowError();
 } else {
     ?>
             <div class="form_settings">
                 <p>O relatório de relação de dietas permite imprimir qual a dieta que o idoso irá ter.</p>
                 <hr>
                 <form id="relacDieta" method="post" action="" style="margin: 10px 0 0 0">
                     <p><span>Dieta(s)</span>
                         <select id="sele" name="sele" style="height: 22px;">
                             <?php 
     foreach ($arrDietas as $value) {
         ?>
Esempio n. 23
0
    public function getContent()
    {
        global $sql;
        if (!LOGGED) {
            return no_access('By mieć dostęp do edycji profilu musisz się zalogować.');
        }
        $note = new Notifier();
        $err = new Error();
        $edit = isset($_POST['edit']) ? true : false;
        $countries = (include 'lang/countries.php');
        asort($countries);
        //Edit user by ID
        if (ctype_digit(u1)) {
            $profile = $sql->query('
				SELECT u.*
				FROM ' . DB_PREFIX . 'users u
				WHERE u.id = ' . u1)->fetch(PDO::FETCH_ASSOC);
            if ($profile) {
                Kio::addTitle(t('Users'));
                Kio::addBreadcrumb(t('Users'), 'users');
                Kio::addTitle($profile['nickname'] . ' - ' . t('Edit profile'));
                Kio::addBreadcrumb($profile['nickname'], 'profile/' . u1);
                Kio::addBreadcrumb(t('Edit profile'), 'edit_profile/' . u1);
                $form = $profile;
            } else {
                return not_found(t('Selected user doesn&apos;t exists.'), array(t('This person was deleted from database.'), t('Entered URL is invalid.')));
            }
        } else {
            $profile = User::toArray();
            Kio::addTitle(t('Edit profile'));
            Kio::addBreadcrumb(t('Edit profile'), 'edit_profile');
        }
        $form = $profile;
        $form['password'] = '';
        $form['password2'] = '';
        $form['birthdate'] = explode('-', $profile['birthdate']);
        $form['newsletter'] = $profile['newsletter'] ? 1 : 0;
        $form['pm_notify'] = $profile['pm_notify'] ? 1 : 0;
        $form['hide_email'] = $profile['hide_email'] ? 1 : 0;
        if (!u1 || $profile) {
            // Edit profile
            if (!empty($edit)) {
                $form = array('nickname' => Kio::getConfig('allow_change_nick', 'edit_profile') ? filter($_POST['nickname'], 100) : User::$nickname, 'password' => filter($_POST['password'], 100), 'password2' => filter($_POST['password2'], 100), 'email' => strtolower(filter($_POST['email'], 100)), 'forename' => $_POST['forename'], 'surname' => $_POST['surname'], 'gender' => $_POST['gender'], 'locality' => $_POST['locality'], 'country' => !empty($countries[$_POST['country']]) ? $_POST['country'] : '', 'communicator' => $_POST['communicator'], 'website' => $_POST['website'], 'birthdate' => array_map('intval', (array) $_POST['birthdate']), 'newsletter' => isset($_POST['newsletter']) ? 1 : 0, 'pm_notify' => isset($_POST['pm_notify']) ? 1 : 0, 'hide_email' => isset($_POST['hide_email']) ? 1 : 0, 'avatar' => $_FILES['avatar']['error'] == 0 && !$_POST['delete_avatar'] ? $_FILES['avatar'] : array(), 'delete_avatar' => isset($_POST['delete_avatar']) ? 1 : 0, 'photo' => isset($_FILES['photo']) ? $_FILES['photo'] : null, 'delete_photo' => isset($_POST['delete_photo']) ? 1 : 0, 'title' => $_POST['title'], 'interests' => $_POST['interests'], 'signature' => $_POST['signature']);
                $allowed_types = array('image/png' => 'png', 'image/jpeg' => 'jpg', 'image/gif' => 'gif');
                // Nickname
                $err->setError('nickname_empty', t('ERROR_NICKNAME_EMPTY'))->condition(!$form['nickname']);
                $err->setError('nickname_exists', t('ERROR_NICKNAME_EXISTS'))->condition(Kio::getConfig('allow_change_nick', 'edit_profile') && $form['nickname'] && strtolower($form['nickname']) != strtolower($profile['nickname']) && is_registered($form['nickname']));
                // Password
                $err->setError('password_differ', t('ERROR_PASSWORD_DIFFER'))->condition($form['password'] != $form['password2']);
                // E-mail
                $err->setError('email_empty', t('ERROR_EMAIL_EMPTY'))->condition(!$form['email']);
                if ($form['email']) {
                    $err->setError('email_invalid', t('ERROR_EMAIL_INVALID'))->condition($form['email'] && !is_email($form['email']));
                    $err->setError('email_exists', t('ERROR_EMAIL_EXISTS'))->condition($form['email'] != $profile['email'] && is_email($form['email']) && is_registered($form['email'], 'email'));
                }
                // Birthdate
                $err->setError('birthdate_invalid', t('ERROR_BIRTHDATE'))->condition(array_sum($form['birthdate']) > 0 && !is_date('Y-n-j', $form['birthdate'][0] . '-' . $form['birthdate'][1] . '-' . $form['birthdate'][2]));
                // Avatar
                if ($form['avatar']) {
                    $err->avatar_invalid_type(t('ERROR_ava'))->condition(!in_array($form['avatar']['type'], array_keys($allowed_types)));
                    $err->avatar_exceeded_max_size(t('ERROR_ava'))->condition(Kio::getConfig('avatar_size_max', 'edit_profile') && !$err->isError('avatar_invalid_type') && $form['avatar']['size'] > Kio::getConfig('avatar_size_max', 'edit_profile'));
                }
                // No errors
                if ($err->noErrors()) {
                    if ($form['delete_avatar']) {
                        unlink(ROOT . 'images/avatars/' . $profile['id'] . '.' . User::$avatar);
                    }
                    if ($form['avatar']) {
                        move_uploaded_file($_FILES['avatar']['tmp_name'], ROOT . 'images/avatars/' . $profile['id'] . '.' . $allowed_types[$form['avatar']['type']]);
                        if ($allowed_types[$form['avatar']['type']] != User::$avatar) {
                            unlink(ROOT . 'images/avatars/' . $profile['id'] . '.' . User::$avatar);
                        }
                    }
                    $form['birthdate'] = array_sum($form['birthdate']) > 0 ? $form['birthdate'][0] . '-' . $form['birthdate'][1] . '-' . $form['birthdate'][2] : '';
                    $sql->exec('
						UPDATE ' . DB_PREFIX . 'users
						SET nickname		= "' . (Kio::getConfig('allow_change_nick', 'edit_profile') ? $form['nickname'] : User::$nickname) . '",
							' . ($form['password'] ? 'pass = "******",' : '') . '
							email			= "' . $form['email'] . '",
							forename		= "' . $form['forename'] . '",
							surname			= "' . $form['surname'] . '",
							gender			= ' . ($form['gender'] == 1 || $form['gender'] == 2 ? (int) $form['gender'] : 0) . ',
							locality		= "' . $form['locality'] . '",
							country			= "' . $form['country'] . '",
							communicator	= "' . $form['communicator'] . '",
							website			= "' . $form['website'] . '",
							birthdate		= "' . $form['birthdate'] . '",
							newsletter		= ' . $form['newsletter'] . ',
							pm_notify		= ' . $form['pm_notify'] . ',
							hide_email		= ' . $form['hide_email'] . ',
							' . ($form['avatar'] ? 'avatar = "' . $allowed_types[$form['avatar']['type']] . '",' : ($form['delete_avatar'] ? 'avatar = "",' : '')) . '
							title			= "' . $form['title'] . '",
							interests		= "' . $form['interests'] . '",
							signature		= "' . $form['signature'] . '"
						WHERE id = ' . $profile['id']);
                    $note->success(t('Your profile was modified successfully.'));
                    redirect(HREF . 'edit_profile');
                } else {
                    $note->error($err->toArray());
                }
            }
            try {
                $tpl = new PHPTAL('modules/edit_profile/edit_profile.tpl.html');
                $tpl->profile = $profile;
                $tpl->countries = $countries;
                $tpl->allow_change_nick = Kio::getConfig('allow_change_nick', 'edit_profile');
                $tpl->form = $form;
                $tpl->err = $err->toArray();
                $tpl->note = $note;
                return $tpl->execute();
            } catch (Exception $e) {
                return template_error($e);
            }
        }
    }
Esempio n. 24
0
                             <li><a href="?page=PosicaoEstoque">Posição de estoque</a></li>
                             <li><a href="?page=LogAtivos">Saída/Entrada Ativos</a></li>
                         </ul>
                     </li>
                 </ul>
             </li>
             <li><a href="?page=Logout">Sair do Sistema</a>
         </ul>
     </nav>
 </header>
 <div id="site_content">
     <div id="content">
         <h1>Dietas</h1>
         <?php 
 if (empty($arrValue)) {
     $Error->setError('Não há dieta cadastrada!');
     $Error->ShowError();
 }
 ?>
         <div id="table">
             <table>
                 <thead>
                 <tr>
                     <th>Id</th>
                     <th>Nome</th>
                     <th>Descrição</th>
                     <th>Status</th>
                 </tr>
                 </thead>
                 <tbody>
                 <?php 
Esempio n. 25
0
    private function getComposeForm()
    {
        global $sql;
        Kio::addTitle(t('Compose message'));
        Kio::addBreadcrumb(t('Compose message'), 'pm/write');
        $err = new Error();
        $note = new Notifier();
        if ((u2 == 'resend' || u2 == 'reply') && ctype_digit(u3)) {
            if (u2 == 'reply') {
                $message = $sql->query('
					SELECT connector_id, subject
					FROM ' . DB_PREFIX . 'pm
					WHERE id = ' . u3 . ' AND folder != 1')->fetch(PDO::FETCH_ASSOC);
                $form['subject'] = 'Re: ' . $message['subject'];
            } else {
                $message = $sql->query('
					SELECT connector_id, subject, message
					FROM ' . DB_PREFIX . 'pm
					WHERE id = ' . (int) u3 . ' AND folder = 1')->fetch(PDO::FETCH_ASSOC);
                $form['subject'] = $message['subject'];
                $form['message'] = $message['message'];
            }
            $form['receiver'] = User::getNickname(BY_ID, $message['connector_id']);
        } else {
            if (ctype_digit(u2)) {
                $form['receiver'] = User::getNickname(BY_ID, u2);
            }
        }
        if (isset($_POST['send'])) {
            // Form values
            $form = array('receiver' => filter($_POST['receiver'], 100), 'subject' => filter($_POST['subject'], 100), 'save' => $_POST['save'], 'bbcode' => $_POST['bbcode'] ? BBCODE : 0, 'emoticons' => $_POST['emoticons'] ? EMOTICONS : 0, 'autolinks' => $_POST['autolinks'] ? AUTOLINKS : 0, 'message' => filter($_POST['message'], 250));
            $err->setError('receiver_empty', t('ERROR_RECEIVER_EMPTY'))->condition(!$form['receiver']);
            $err->setError('receiver_not_exists', t('ERROR_RECEIVER_NOT_EXISTS'))->condition($form['receiver'] && !User::getId(BY_NICKNAME, $form['receiver']));
            $err->setError('subject_empty', t('ERROR_SUBJECT_EMPTY'))->condition(!$form['subject']);
            $err->setError('message_empty', t('ERROR_MESSAGE_EMPTY'))->condition(!$form['message']);
            // No errors
            if ($err->noErrors()) {
                $form['receiver'] = User::getId(BY_NICKNAME, $form['receiver']);
                $form['message'] = cut($form['message'], Kio::getConfig('message_max', 'pm'));
                $form['parsers'] = $form['bbcode'] . $form['autolinks'] . $form['emoticons'] . CENSURE . PRE;
                $stmt = $sql->prepare('
					INSERT INTO ' . DB_PREFIX . 'pm
						(sent, owner_id, connector_id, subject, message, folder, is_read, parsers)
					VALUES
						(:sent, :owner_id, :connector_id, :subject, :message, :folder, :is_read, :parsers)' . ($form['save'] ? ', (:sent, :owner_id, :connector_id, :subject, :message, :folder, :is_read, :parsers)' : ''));
                $stmt->execute(array('sent' => TIMESTAMP, 'owner_id' => $form['receiver'], 'connector_id' => UID, 'subject' => $form['subject'], 'message' => $form['message'], 'folder' => 0, 'is_read' => 0, 'parsers' => $form['parsers']));
                setcookie(COOKIE . '-pm', 'true', TIMESTAMP + Kio::getConfig('flood_interval', 'pm') + 1, '/');
                $note->success('Wiadomość została wysłana.');
                redirect(HREF . 'pm/inbox');
            } else {
                $note->error($err->toArray());
            }
        } else {
            $note->info(array(t('WELCOME_MESSAGE'), t('REQUIRED')));
        }
        try {
            $tpl = new PHPTAL('modules/pm/write.tpl.html');
            $tpl->err = $err->toArray();
            $tpl->form = $form;
            $tpl->note = $note;
            return $tpl->execute();
        } catch (Exception $e) {
            return template_error($e);
        }
    }