Esempio n. 1
0
if ($stier->getOption('processMode') !== 0) {
    require_once "Mstat.php";
    require_once "lib/ZipStatEngine.php";
    require_once "lib/SiteContext.php";
    require_once "lib/Localizer.php";
    //Loads the data file
    $datafil = DataSource::createInstance($ind['brugernavn'], $stier);
    $res = $datafil->hentFil();
    //Handle errors:
    $errors = new Errors();
    //Was the datafile fetched successfully
    if ($res === -2) {
        //Temporarely instance for error handling
        //'da' is danish, currently the only user interface language.
        $siteContext = new ShortSiteContext($stier, $ind, 'da');
        $errors->addError(new Error(2, sprintf($siteContext->getLocale('errDamagedDatasource'), $stier->getOption('name_of_service'))));
    } elseif (!$res or $res === 0) {
        //Temporarely instance for error handling
        $siteContext = new ShortSiteContext($stier, $ind, 'da');
        $errors->addError(new Error(2, sprintf($siteContext->getLocale('errDatasourceInaccessible'), $stier->getOption('name_of_service'))));
    }
    $lib = new Html($ind, $datafil);
    $lib->setStier($stier);
    //Write the stat image
    if (!$errors->isOccured()) {
        //'billed' is 'image' in danish: The image to display.
        if (!array_key_exists('billed', $ind)) {
            writeImage("stats1.gif", $stier);
        } else {
            //1-8: Normal images. trans: transparent/invisible.
            //sh: Blach/white, hs: White/blach.
Esempio n. 2
0
        $sv = explode("::", $svar[$i]);
        $svarmug .= "<h3>{$sp[$i]}</h3>\n";
        for ($n = 0; $n < $pro_max_sv; $n++) {
            if (isset($sv[$n]) and strlen($sv[$n]) > 0) {
                $j = $i + 1;
                $k = $n + 1;
                $svarmug .= "<input type=radio name=\"sp{$j}\" value=\"{$k}\">{$sv[$n]}<BR>\n";
            }
        }
    }
}
if (isset($svarmug) and strlen($svarmug) > 0) {
    $svarmug = "<div class=forside><h2>Hvis du vil svare p flere sprgsml</h2>\n" . $svarmug . "<input type=submit value=\"Svar\"> <input type=reset value=\"Nulstil formular\"></div>\n";
} else {
    $svarmug = "<div class=forside><h2>Tak!</h2>\nNu er der ikke flere sprgsml at svare p!</div>\n";
}
$uaUtils = new UsersAreaUtils($siteContext);
//Did something go wrong?
if (strlen($problemer) > 0) {
    $errors = new Errors();
    $errors->addError(new Error(2, "<div class=problemer><h1>Der opstod desvrre problemer...</h1>{$problemer}</div>"));
    $uaUtils->showErrors($errors);
    exit;
} else {
    if (isset($fsvaret) and strlen($fsvaret) > 0) {
        $fxsvaret = "<p>Da du fr har svaret p {$fsvaret} er dette/disse svar ikke talt med.</p>";
    }
    $uaUtils->echoSiteHead("Tak fordi du har svaret!", 1);
    echo "<div class=forside>{$fxsvaret} <form action=\"" . $stier->getOption('cgiURL') . "/pollAnswer.php\" method=POST><input type=hidden name=brugernavn value=\"" . htmlentities($ind['brugernavn']) . "\"><input type=hidden name=svaret value=\"{$svaret}\">\n" . $svarmug . "</form><BR><a href=\"" . $stier->getOption('urlStatsite') . "?brugernavn=" . htmlentities($ind['brugernavn']) . "&amp;show[]=HitsVotes\">Se hvad folk svarede...</A></div>";
    $uaUtils->echoSiteEnd();
}
Esempio n. 3
0
 public function doLoginSubmit()
 {
     $username = Request::get("username");
     $password = Request::get("password");
     $userService = new UserService();
     $userValue = new UserValue();
     $userValue->addUsernameCondition($username, Value::LIKE);
     $userValue->addPasswordCondition(md5($password), Value::EQUAL);
     $userVo = Zee::registry("DB")->fetch($userValue);
     if ($userVo == false) {
         Errors::addError('用户名密码错误', 'login');
         View::display("Login");
     } else {
         //$_SESSION['user']=$userVo;
         $_SESSION['user_id'] = $userVo->user_id;
         $_SESSION['user_role'] = $userVo->role;
         $_SESSION['user_realname'] = $userVo->realname;
         Zee::redirect(Zee::url("index", 'index'));
     }
 }
Esempio n. 4
0
 public function doCreateSubmit()
 {
     $ordersService = new OrdersService();
     $ordersVo = Request::getValue("orders", "OrdersValue");
     $ordersAssign = Request::get('orders_assign');
     if (count($ordersAssign) > 0) {
         $ordersVo->assign = implode(',', $ordersAssign);
     } else {
         $ordersVo->assign = '';
     }
     $ordersVo->addtime = date("Y-m-d H:i:s");
     $ordersVo->user_id = $_SESSION['user_id'];
     $ordersVo->status = Value::STATUS_NOT_SEE;
     $ordersVo->operate_status = Value::OPERATE_STATUS_NOT_OPERATE;
     $ordersVo->contact_status = Value::CONTACT_STATUS_NOT_CONTACT;
     //var_dump($ordersVo);exit;
     if ($ordersVo->mobile == '' and $ordersVo->telephone == '') {
         //如果同时为空
         Errors::addError('手机和电话至少要填一个', 'MOBILE');
         $flag_mobile = true;
     }
     if (!$ordersVo->checkOptions($ordersVo->getCreateOptions()) or $flag_mobile) {
         $projectService = new ProjectService();
         $projectlist = $projectService->getList(new ProjectValue());
         $areaService = new AreaService();
         $arealist = $areaService->getList(new AreaValue());
         View::set("Arealist", $arealist);
         View::set("Projectlist", $projectlist);
         View::set("OrdersCreateValue", $ordersVo);
         View::display("Create");
         return;
     }
     $ordersVo = $ordersService->create($ordersVo);
     Zee::redirect(Zee::url("orders", "list"));
 }
Esempio n. 5
0
 /**
  * Validates the start page and returns the result as an Errors object.
  */
 function validateStartPage()
 {
     $errors = new Errors();
     $in = $this->siteContext->getHTTP_VARS();
     $lib = $this->siteContext->getCodeLib();
     if (!isset($in['navn']) or strlen($in['navn']) === 0) {
         $errors->addError(new Error(2, $this->siteContext->getLocale('regErrorNoName')));
     }
     if (!isset($in['e-mail']) or strlen($in['e-mail']) === 0 or !$lib->okmail($in['e-mail'])) {
         $errors->addError(new Error(2, $this->siteContext->getLocale('regErrorBadEmail')));
     }
     if (!isset($in['url']) or strlen($in['url']) === 0 or !$lib->okurl($in['url'])) {
         $errors->addError(new Error(2, $this->siteContext->getLocale('regErrorBadUrl')));
     }
     if (!isset($in['titel']) or strlen($in['titel']) === 0) {
         $errors->addError(new Error(2, $this->siteContext->getLocale('regErrorNoTitle')));
     }
     if (!isset($in['brugernavn']) or strlen($in['brugernavn']) === 0 or !Datafil::isUsernameValid($in['brugernavn'])) {
         $errors->addError(new Error(2, $this->siteContext->getLocale('regBadUsername')));
     } else {
         $datasource = DataSource::createInstance($in['brugernavn'], $this->siteContext->getOptions());
         if ($datasource->userExists()) {
             $errors->addError(new Error(2, $this->siteContext->getLocale('regTakenUsername')));
         }
     }
     if (!isset($in['pwd1']) or strlen($in['pwd1']) === 0 or !isset($in['pwd2']) or strlen($in['pwd2']) === 0 or $in['pwd1'] !== $in['pwd2']) {
         $errors->addError(new Error(2, $this->siteContext->getLocale('regBadPassword')));
     }
     return $errors;
 }
Esempio n. 6
0
 /**
  * Check value
  *
  * @param array $options
  */
 public final function checkOptions($checkOptions)
 {
     $attributes = get_object_vars($this);
     $checkPass = true;
     foreach ($attributes as $attribute => $value) {
         if (in_array($attribute, array('primary', 'tableName', 'fieldMap', 'conditions'))) {
             continue;
         }
         $checkOptionString = trim($checkOptions[$attribute]);
         if (strlen($checkOptionString) <= 0) {
             continue;
         }
         $checkList = explode(';', $checkOptionString);
         //var_dump($checkList);
         foreach ($checkList as $check) {
             //var_dump($check);
             $field = strtoupper($attribute);
             $checkInfo = explode(':', $check);
             //var_dump($checkInfo);
             //var_dump($valueObject->$attribute, $field, $checkInfo[1]);
             switch ($checkInfo[0]) {
                 case 'required':
                     if (!trim($this->{$attribute})) {
                         $message = Language::content($checkInfo[1]);
                         Errors::addError($message, $field);
                         $checkPass = false;
                     }
                     break;
                 case 'number':
                     if (strlen(trim($this->{$attribute})) <= 0) {
                         break;
                     }
                     if (strlen($valueObject->{$attribute}) > 0 && !is_numeric($valueObject->{$attribute})) {
                         $message = Language::content($checkInfo[1]);
                         Errors::addError($message, $field);
                         $checkPass = false;
                     }
                     break;
                 case 'email':
                     if (strlen(trim($this->{$attribute})) <= 0) {
                         break;
                     }
                     if (!Validation::isEmail($valueObject->{$attribute})) {
                         $message = Language::content($checkInfo[1]);
                         Errors::addError($message, $field);
                         $checkPass = false;
                     }
                     break;
                 case 'date':
                     //var_dump($valueObject->$attribute);
                     if (strlen(trim($this->{$attribute})) <= 0) {
                         break;
                     }
                     if (!Validation::isDate($valueObject->{$attribute})) {
                         $message = Language::content($checkInfo[1]);
                         Errors::addError($message, $field);
                         $checkPass = false;
                         break;
                     }
                 case 'alnum':
                     if (strlen(trim($this->{$attribute})) <= 0) {
                         break;
                     }
                     if (!Validation::isAlnum($valueObject->{$attribute})) {
                         $message = Language::content($checkInfo[1]);
                         Errors::addError($message, $field);
                         $checkPass = false;
                     }
                     break;
                 case 'minLength':
                     if (strlen(trim($this->{$attribute})) <= 0) {
                         break;
                     }
                     if (strlen($valueObject->{$attribute}) < $checkInfo[2]) {
                         $messageTpl = Language::content($checkInfo[1]);
                         $message = str_replace('{0}', $checkInfo[2], $messageTpl);
                         Errors::addError($message, $field);
                         $checkPass = false;
                     }
                     break;
                 case 'maxLength':
                     if (strlen(trim($this->{$attribute})) <= 0) {
                         break;
                     }
                     if (strlen($valueObject->{$attribute}) > $checkInfo[2]) {
                         $messageTpl = Language::content($checkInfo[1]);
                         $message = str_replace('{0}', $checkInfo[2], $messageTpl);
                         Errors::addError($message, $field);
                         $checkPass = false;
                     }
                     break;
             }
         }
     }
     return $checkPass;
 }