Esempio n. 1
0
 function getLocalGroupsArray()
 {
     $localGroupsArray = array();
     try {
         $localGroupsArray = unserialize(parent::getLocalGroups());
     } catch (Exception $exc) {
         $error = new Error($exc->getMessage());
         $error->writeLog();
     }
     return $localGroupsArray;
 }
Esempio n. 2
0
 function getLdapEgnInfo()
 {
     $ldapAttributeValue = "";
     // ldap connecting: must be a valid LDAP server!
     $ds = ldap_connect("ds.uni-sofia.bg");
     // try ldap bind
     if ($ds) {
         // set ldap bind variables
         $ldaprdn = 'uid=schedule,ou=System,dc=uni-sofia,dc=bg';
         $ldappass = '******';
         $ldapbind = ldap_bind($ds, $ldaprdn, $ldappass);
         if ($ldapbind) {
             // data array
             $array = array('supersonalid');
             $sr = ldap_search($ds, "ou=People,dc=uni-sofia,dc=bg", "(uid=" . $this->getUsername() . ")", $array, 0, 0, 0);
             $info = ldap_get_entries($ds, $sr);
             //                $ldapAttributeValue = egnDecode($info[0]['supersonalid'][0]);
             $this->egn_parse($info[0]['supersonalid'][0]);
             ldap_close($ds);
         }
     } else {
         $error = new Error("LDAP server unavailable");
         $error->writeLog();
     }
     $egnArray = array("gender" => $this->gender, "birthYear" => $this->birthYear);
     return $egnArray;
 }
Esempio n. 3
0
function elementFunction()
{
    // get global user object
    global $user;
    // set connection var
    global $db;
    // get current time
    $time_now = date("Y-m-d H:i:s");
    // protect from unauthorized access
    if (!isset($user) or !isset($_POST['formElementFunction'])) {
        logout();
        die;
    }
    // set empty survey
    $session_question = new Question();
    $session_question = get_session_question();
    $question_id = $_POST['formElementFunction'];
    if ($question_id != "") {
        $session_question->get_from_db($question_id);
    }
    // get the function
    $function = '';
    foreach ($_POST as $key => $post) {
        if ($post != $question_id) {
            $function = substr($key, 11);
        }
    }
    if ($function == 'Edit') {
        // set security
        $survey = new Survey();
        $survey->get_from_db($session_question->getSurvey());
        if ($survey->getCreatedBy() != $user->getId()) {
            if ($user->getAdmin() != 1) {
                logout();
                die;
            }
        }
        $_SESSION['session_question'] = serialize($session_question);
        // get session answers
        $session_answers = array();
        $session_answer_ids = get_survey_answers($session_question->getId());
        foreach ($session_answer_ids as $answer_id) {
            $answer = new Answer();
            $answer->get_from_db($answer_id);
            array_push($session_answers, $answer);
        }
        $_SESSION['session_answers'] = serialize($session_answers);
        $cookie_key = 'msg';
        $cookie_value = 'Вие избрахте елемент от анкетата за редакция!<br />Отидете на раздел "Добавете или редактирайте елемент към анкетата"';
        setcookie($cookie_key, $cookie_value, time() + 1);
        header('Location: ' . ROOT_DIR . '?page=survey_edit');
        die;
    } elseif ($function == 'PrintExcel') {
        // get global user object
        global $user;
        // get survey id
        $question_id = $_POST['formElementFunction'];
        // check if the user is the surveyCreator or systemAdmin
        $question = new Question();
        $question->get_from_db($question_id);
        $survey = new Survey();
        $survey->get_from_db($question->getSurvey());
        if (intval($survey->getCreatedBy()) != $user->getId() && $user->getAdmin() != 1) {
            $error = new Error("Question PrintExcel: unathorised access");
            $error->writeLog();
            logout();
            die;
        }
        header('Location: ' . ROOT_DIR . 'functions/print/excel/questionReport.php?question_id=' . $question_id);
        die;
    } elseif ($function == 'PrintExcelGroups') {
        // get global user object
        global $user;
        // get survey id
        $question_id = $_POST['formElementFunction'];
        // check if the user is the surveyCreator or systemAdmin
        $question = new Question();
        $question->get_from_db($question_id);
        $survey = new Survey();
        $survey->get_from_db($question->getSurvey());
        if (intval($survey->getCreatedBy()) != $user->getId() && $user->getAdmin() != 1) {
            $error = new Error("Question PrintExcelGroups: unathorised access");
            $error->writeLog();
            logout();
            die;
        }
        header('Location: ' . ROOT_DIR . 'functions/print/excel/questionReportGroups.php?question_id=' . $question_id);
        die;
    } elseif ($function == 'PrintExcelGender') {
        // get global user object
        global $user;
        // get survey id
        $question_id = $_POST['formElementFunction'];
        // check if the user is the surveyCreator or systemAdmin
        $question = new Question();
        $question->get_from_db($question_id);
        $survey = new Survey();
        $survey->get_from_db($question->getSurvey());
        if (intval($survey->getCreatedBy()) != $user->getId() && $user->getAdmin() != 1) {
            $error = new Error("Question PrintExcelGender: unathorised access");
            $error->writeLog();
            logout();
            die;
        }
        header('Location: ' . ROOT_DIR . 'functions/print/excel/questionReportGender.php?question_id=' . $question_id);
        die;
    } elseif ($function == 'PrintExcelAge') {
        // get global user object
        global $user;
        // get survey id
        $question_id = $_POST['formElementFunction'];
        // check if the user is the surveyCreator or systemAdmin
        $question = new Question();
        $question->get_from_db($question_id);
        $survey = new Survey();
        $survey->get_from_db($question->getSurvey());
        if (intval($survey->getCreatedBy()) != $user->getId() && $user->getAdmin() != 1) {
            $error = new Error("Question PrintExcelAge: unathorised access");
            $error->writeLog();
            logout();
            die;
        }
        header('Location: ' . ROOT_DIR . 'functions/print/excel/questionReportAge.php?question_id=' . $question_id);
        die;
    }
    die;
}
Esempio n. 4
0
function afooter($unfoot = null)
{
    static $showafooter;
    global $db_redundancy, $wind_version, $db, $db_debug, $admin_keyword;
    $showafooter = false;
    if (empty($unfoot)) {
        $showafooter = true;
        require PrintEot('adminbottom');
    }
    $output = ob_get_contents();
    $output = str_replace(array('<!--<!--<!---->', '<!--<!---->', '<!---->-->', '<!---->'), '', $output);
    if ($admin_keyword) {
        $output = preg_replace('/(' . preg_quote($admin_keyword, '/') . ')([^">;]*<)(?!\\/script|\\/textarea)/si', '<font color="red"><u>\\1</u></font>\\2', $output);
    }
    $output = preg_replace("/\\<form([^\\<\\>]*)\\saction=['|\"]?([^\\s\"'\\<\\>]+)['|\"]?([^\\<\\>]*)\\>/ies", "FormCheck('\\1','\\2','\\3')", rtrim($output, '<!--'));
    echo ObContents($output);
    unset($output);
    if (defined('SHOWLOG')) {
        Error::writeLog();
    }
    exit;
}
Esempio n. 5
0
 public function send()
 {
     $resposta = false;
     $mail = new PHPMailer();
     flush();
     ob_start();
     //Debug::p("CONTEUDO", Run::$control->string->encodeFixUtf8($this->mailManager->content_html));
     //exit;
     //$mail->IsSendmail(); // telling the class to use SendMail transport
     $mail->IsSMTP();
     // usando função padrão de email php
     //$mail->Debugoutput = 'html';
     $mail->Subject = Run::$control->string->encodeFixUtf8($this->mailManager->send_subject);
     $mail->AltBody = strip_tags($this->mailManager->send_message);
     // optional, comment out and test
     $mail->setFrom($this->mailManager->send_from['mail'], Run::$control->string->encodeFixUtf8($this->mailManager->send_from['name']));
     $mail->AddAddress($this->mailManager->send_to['mail'], Run::$control->string->encodeFixUtf8($this->mailManager->send_to['name']));
     if (isset($this->mailManager->send_reply['mail']) && $this->mailManager->send_reply['mail'] != "") {
         $mail->AddReplyTo($this->mailManager->send_reply['mail'], Run::$control->string->encodeFixUtf8($this->mailManager->send_reply['name']));
     }
     $this->mailManager->content_html = str_replace("[id]", $this->mailManager->ref_pk, $this->mailManager->content_html);
     if (count($this->mailManager->send_copy) > 0) {
         foreach ($this->mailManager->send_copy as $k => $copy) {
             $mail->AddCC($copy['mail'], $copy['name']);
         }
     }
     if (count($this->mailManager->send_hidden) > 0) {
         foreach ($this->mailManager->send_hidden as $k => $copy) {
             $mail->AddBCC($copy['mail'], $copy['name']);
         }
     }
     $mail->CharSet = 'UTF-8';
     $mail->MsgHTML(Run::$control->string->encodeFixUtf8($this->mailManager->content_html));
     $mail->IsHTML(true);
     $mail->Host = $this->mailManager->properties[$this->mailManager->send_prefix . 'host'];
     $mail->SMTPAuth = $this->mailManager->properties[$this->mailManager->send_prefix . 'smtp'];
     $mail->Sender = $this->mailManager->properties[$this->mailManager->send_prefix . 'mail'];
     $mail->Username = $this->mailManager->properties[$this->mailManager->send_prefix . 'login'];
     $mail->Password = $this->mailManager->properties[$this->mailManager->send_prefix . 'pass'];
     // enable SMTP authentication
     $door = $this->mailManager->properties[$this->mailManager->send_prefix . 'door'];
     $crypt = $this->mailManager->properties[$this->mailManager->send_prefix . 'crypt'];
     if (isset($door) && $door != "") {
         $mail->Port = $door;
     } else {
         $mail->Port = 25;
     }
     if (isset($crypt) && $crypt != "") {
         $mail->SMTPSecure = $crypt;
     }
     $mail->SMTPDebug = 1;
     // sets the prefix to the servier
     $resposta = $mail->Send();
     //echo ">>>> ".$mail->SMTPAuth;
     $error = ob_get_contents();
     ob_end_clean();
     flush();
     if (!$resposta) {
         Error::writeLog("Erro MailInfo: " . $mail->ErrorInfo . "\n" . $error, __FILE__, __LINE__, '');
         Debug::p("Erro: " . $mail->ErrorInfo, $error);
         Error::show(0, "MailSender: Ocorreu um erro ao enviar e-mail: \n " . $mail->ErrorInfo . __FUNCTION__, __FILE__, __LINE__, '');
         if (Config::MAIL_TRY_SEND_SERVER === true) {
             $mail->IsMail();
             $resposta = $mail->Send();
             ob_flush();
             flush();
             if (!$resposta) {
                 return -2;
             } else {
                 return 2;
             }
         }
         return -1;
     }
     return 1;
 }
Esempio n. 6
0
 public function exeCheckErrors()
 {
     if (Run::$router->getLevel(0, true) == "form") {
         //Run::$DEBUG_PRINT = 1;
         //// Debug::p($_SERVER);
         //// Debug::p($_REQUEST);
         if (count($_POST) < 1 && count($_GET) < 1) {
             Error::writeLog("modelForm: A requisição form foi realizada de forma incorreta. A URL foi chamada deliberadamente, sem request.", __FILE__, __LINE__);
             View::redirect("500");
         } else {
             if (count($_POST) < 1) {
                 Error::writeLog("modelForm: A requisição form foi realizada de forma incorreta. A URL foi chamada deliberadamente, sem post.", __FILE__, __LINE__);
                 Run::$view->render->setResponse("<p>Você tentou acessar uma URL inválida ou tentou enviar os dados do formulário e ocorreu um erro interno.</p><p>Caso esteja com dificuldades em enviar os dados, por favor, entre em contato com o suporte técnico.</p>", "danger msg-error500 msg-" . $this->session->getFormSessionId(), $this->session->getFormSessionId());
                 View::redirect("500");
             } else {
                 if (count($_POST) > 1 || count($_GET) > 1) {
                     Error::writeLog("modelForm: Ocorreu um erro ao processar os dados enviados.", __FILE__, __LINE__);
                     Run::$view->render->setResponse("<p>Você tentou enviar os dados do formulário e ocorreu um erro interno.</p><p>Caso esteja com dificuldades em enviar os dados, por favor, entre em contato com o suporte técnico.</p>", "danger msg-error500 msg-" . $this->session->getFormSessionId(), $this->session->getFormSessionId());
                     View::redirect("500");
                 } else {
                     Error::writeLog("modelForm: Ocorreu um erro ao processar os dados enviados, sem request.", __FILE__, __LINE__);
                     Run::$view->render->setResponse("<p>Você tentou acessar uma URL inválida ou tentou enviar os dados do formulário e ocorreu um erro interno.</p><p>Caso esteja com dificuldades em enviar os dados, por favor, entre em contato com o suporte técnico.</p>", "danger msg-error500 msg-" . $this->session->getFormSessionId(), $this->session->getFormSessionId());
                     View::redirect("500");
                 }
             }
         }
     }
     Run::$benchmark->writeMark("FormModel/Inicio", "FormModel/Final");
     // finaliza o flush para exibir tudo que foi impresso ao longo do processamento
     //ob_end_flush();
 }
Esempio n. 7
0
/**
 * 将输出缓存中的内容以ajax格式输出,并中断程序
 *
 * @global string $db_charset
 */
function ajax_footer()
{
    global $db_charset, $db_htmifopen;
    if (defined('SHOWLOG')) {
        Error::writeLog();
    }
    $output = str_replace(array('<!--<!--<!---->', '<!--<!---->', '<!---->-->', '<!---->', '<!-- -->'), '', ob_get_contents());
    if (P_W == 'admincp') {
        $output = preg_replace("/\\<form([^\\<\\>]*)\\saction=['|\"]?([^\\s\"'\\<\\>]+)['|\"]?([^\\<\\>]*)\\>/ies", "FormCheck('\\1','\\2','\\3')", rtrim($output, '<!--'));
    } else {
        $output = parseHtmlUrlRewrite($output, $db_htmifopen);
    }
    header("Content-Type: text/xml;charset={$db_charset}");
    echo ObContents("<?xml version=\"1.0\" encoding=\"{$db_charset}\"?><ajax><![CDATA[" . $output . "]]></ajax>");
    exit;
}
Esempio n. 8
0
 private function loadPageFile($pag)
 {
     Run::$benchmark->mark("loadPageFile/Inicio");
     Debug::log("Router - loadPageFile() ", __LINE__, __FUNCTION__, __CLASS__, __FILE__);
     $page_control = APP_PATH . Run::PATH_PAG . "control/" . $pag . "_control.php";
     $page_view = APP_PATH . Run::PATH_PAG . "view/" . $pag . "_view.php";
     $page_single = APP_PATH . Run::PATH_PAG . "view/" . $pag;
     $page_single_full = APP_PATH . Run::PATH_PAG . "view/" . implode(self::$levels, "__");
     //tenta carregar o controle ou o view
     if (file_exists($page_control)) {
         $this->loadControl($pag);
         Run::$benchmark->writeMark("loadPageFile/Inicio", "loadPageFile/if/Final");
     } else {
         if (file_exists($page_single_full . ".php")) {
             $this->loadPath($page_single_full . ".php");
             Run::$benchmark->writeMark("loadPageFile/Inicio", "loadPageFile/else1/Final");
             exit;
         } else {
             if (file_exists($page_single_full . ".htm")) {
                 $this->loadPath($page_single_full . ".htm");
                 Run::$benchmark->writeMark("loadPageFile/Inicio", "loadPageFile/else2/Final");
                 exit;
             } else {
                 if (file_exists($page_single . ".php")) {
                     $this->loadPath($page_single . ".php");
                     Run::$benchmark->writeMark("loadPageFile/Inicio", "loadPageFile/else3/Final");
                     exit;
                 } else {
                     if (file_exists($page_single . ".htm")) {
                         $this->loadPath($page_single . ".htm");
                         Run::$benchmark->writeMark("loadPageFile/Inicio", "loadPageFile/else4/Final");
                         exit;
                     } else {
                         echo "<!-- {$page_control}, {$page_view}, {$page_single}, {$page_single_full} não existe -->";
                         $this->load("404");
                         Run::$benchmark->writeMark("loadPageFile/Inicio", "loadPageFile/else/Final");
                         Error::writeLog("Router->loadPageFile: Pág Control ou View <b>{$pag}</b> não existe. (control/" . $pag . "_control.php).", __FILE__, __LINE__);
                         exit;
                     }
                 }
             }
         }
     }
 }
Esempio n. 9
0
function pwOutPut()
{
    global $db_htmifopen, $db_redundancy, $SCR, $groupid;
    $masterDb = $GLOBALS['db']->getMastdb();
    if ($masterDb->arr_query) {
        writeover(D_P . "data/sqllist.txt", $masterDb->arr_query, 'wb');
    }
    Update_ol();
    $output = parseHtmlUrlRewrite(ob_get_contents(), $db_htmifopen);
    if ($db_redundancy && $SCR != 'post') {
        $output = str_replace(array("\r", '<!--<!---->-->', '<!---->-->', '<!--<!---->', "<!---->\n", '<!---->', '<!-- -->', "<!--\n-->", "\t\t", '    ', "\n\t", "\n\n"), array('', '', '', '', '', '', '', '', '', '', "\n", "\n"), $output);
    } else {
        $output = str_replace(array('<!--<!---->-->', '<!---->-->', '<!--<!---->', "<!---->\r\n", '<!---->', '<!-- -->', "\t\t\t"), '', $output);
    }
    if (!defined('AJAX')) {
        require_once R_P . 'aCloud/aCloud.php';
        $output .= ACloud_App_Guiding::getApp();
    }
    if ($SCR != 'post' && !defined('AJAX')) {
        $ceversion = defined('CE') ? 1 : 0;
        $output .= "<script type=\"text/javascript\">(function(d,t){\r\nvar url=\"http://init.phpwind.net/init.php?sitehash={$GLOBALS[db_sitehash]}&v={$GLOBALS[wind_version]}&c={$ceversion}\";\r\nvar g=d.createElement(t);g.async=1;g.src=url;d.body.insertBefore(g,d.body.firstChild);}(document,\"script\"));</script>";
    }
    if ($groupid == 'guest' && !defined('MSG') && GetGcache()) {
        require_once R_P . 'require/guestfunc.php';
        creatguestcache($output);
    }
    if (defined('SHOWLOG')) {
        Error::writeLog();
    }
    if (defined('PW_PACK_FILES')) {
        pwPack::files();
    }
    echo ObContents($output);
    unset($output);
    N_flush();
    exit;
}