예제 #1
0
</label>
                <textarea id="summary" name="summary"><?php 
echo Helper::getPostField('summary');
?>
</textarea>
            </p>
            <p>
                <label for="avatar"><?php 
echo Helper::lang('avatar');
?>
</label>
                <input type="file" id="avatar" name="avatar" <?php 
echo Helper::isHasError($model, 'avatar');
?>
 >
                <span id="avatar-error" class="error-msg">
                    <?php 
echo Helper::displayErrors('avatar', $model, ['file' => str_replace('{{filesize}}', ini_get('upload_max_filesize'), str_replace('{{extensions}}', 'jpg, png, gif', Helper::lang('wrong_file')))]);
?>
                </span>
            </p>
        </fieldset>
        <p>
            <input type="submit" id="register" name="register" value="<?php 
echo Helper::lang('register');
?>
" class="btn register">
        </p>
    </form>
</div>
예제 #2
0
<h1 class="error-msg"><?php 
echo \System\Helper::lang('enable_cookies');
?>
</h1>
예제 #3
0
 public function add()
 {
     if ($this->hasErrors) {
         return false;
     } else {
         $db = $this->getInstance();
         $stmt = $db->prepare('INSERT INTO profile SET surname = :surname,
                                                       first_name = :first_name,
                                                       last_name = :last_name,
                                                       birthday = :birthday,
                                                       sex = :sex,
                                                       marital_status = :marital_status');
         // create new profile
         $stmt->execute([':surname' => $this->surname, ':first_name' => $this->firstName, ':last_name' => $this->lastName, ':birthday' => strtotime($this->birthday), ':sex' => (int) $this->sex, ':marital_status' => (int) $this->maritalStatus]);
         // get profile id
         $profileId = (int) $db->lastInsertId();
         if (!isset($this->errors['education'])) {
             $stmt = $db->prepare('INSERT INTO education SET institution_name = :inst_name,
                                                             faculty = :faculty,
                                                             specialty = :specialty,
                                                             year_from = :year_from,
                                                             year_to = :year_to,
                                                             created = :created
                                 ');
             $stmt->execute([':inst_name' => $this->institutionName, ':faculty' => $this->faculty, ':specialty' => $this->specialty, ':year_from' => $this->from, ':year_to' => $this->to, ':created' => time()]);
             $educationId = (int) $db->lastInsertId();
             $stmt = $db->query('INSERT INTO profile_education SET profile_id = ' . $profileId . ', education_id = ' . $educationId);
         }
         $stmt = $db->prepare('INSERT INTO user SET login = :login,
                                                    hash = :hash,
                                                    status = :status,
                                                    created = :created,
                                                    profile_id = :profile_id
                              ');
         // create new user
         $stmt->execute([':login' => $this->login, ':hash' => password_hash($this->password, PASSWORD_BCRYPT), ':status' => self::STATUS_ACTIVE, ':created' => time(), ':profile_id' => $profileId]);
         if ($stmt->errorCode() == self::USER_EXISTS_CODE) {
             $this->hasErrors = true;
             $this->errors['login'][] = 'exists';
             return false;
         }
         $stmt = $db->prepare('INSERT INTO address SET country = :country,
                                                       city = :city,
                                                       street = :street,
                                                       build = :build,
                                                       profile_id = :profile_id
                             ');
         // add address
         $stmt->execute([':country' => $this->country, ':city' => $this->city, ':street' => $this->street, ':build' => $this->build, ':profile_id' => $profileId]);
         $stmt = $db->prepare('INSERT INTO telephone SET telephone_number = :telephone_number,
                                                         status = :status,
                                                         created = :created
                             ');
         // add telephone
         $stmt->execute([':telephone_number' => $this->telephone, ':status' => self::STATUS_ACTIVE, ':created' => time()]);
         //add depend telephone to profile
         $telephoneId = (int) $db->lastInsertId();
         $stmt = $db->query("INSERT INTO profile_telephone SET profile_id = {$profileId}, telephone_id = {$telephoneId}");
         $stmt = $db->prepare('INSERT INTO email SET email = :email,
                                                     status = :status,
                                                     created = :created
                             ');
         $stmt->execute([':email' => $this->email, ':status' => self::STATUS_ACTIVE, ':created' => time()]);
         //add depend email to profile
         $emailId = (int) $db->lastInsertId();
         $stmt = $db->query("INSERT INTO profile_email SET profile_id = {$profileId}, email_id = {$emailId}");
         if (!empty(trim($this->experience))) {
             // if fill experience insert in db
             $stmt = $db->prepare('INSERT INTO experience SET profile_id = :profile_id,
                                                              content = :content,
                                                              created = :created
                                 ');
             $stmt->execute([':profile_id' => $profileId, ':content' => htmlspecialchars(trim($this->experience)), ':created' => time()]);
         }
         if (!empty(trim($this->summary))) {
             $stmt = $db->prepare('INSERT INTO summary SET profile_id = :profile_id,
                                                           content = :content,
                                                           created = :created
                                 ');
             $stmt->execute([':profile_id' => $profileId, ':content' => htmlspecialchars(trim($this->summary)), ':created' => time()]);
         }
         if (!empty(trim($this->avatar))) {
             $result = Helper::upload('avatar');
             if (isset($result['uploaded']) && $result['uploaded'] == true) {
                 $stmt = $db->prepare('INSERT INTO avatar SET profile_id = :profile_id,
                                                              src = :src,
                                                              status = :status,
                                                              created = :created
                                     ');
                 $stmt->execute([':profile_id' => $profileId, ':src' => $result['fileName'], ':status' => self::STATUS_ACTIVE, ':created' => time()]);
             }
         }
         return true;
     }
 }
예제 #4
0
<h1><?php 
echo \System\Helper::lang('congratulations');
?>
<a href="?page=singin"><?php 
echo \System\Helper::lang('sing_in');
?>
</a></h1>
예제 #5
0
        <label for="login"><?php 
echo \System\Helper::lang('login');
?>
</label>
        <input type="text" id="login" name="login">
        <span id="login-error" class="error-msg"></span>
    </p>
    <p>
        <label for="password"><?php 
echo \System\Helper::lang('password');
?>
</label>
        <input type="password" id="password" name="password">
        <span id="password-error" class="error-msg"></span>
        <span id="auth-error" class="error-msg"><?php 
echo $errorMsg;
?>
</span>
    </p>
    <input type="submit" id="sing-in" name="sing-in" value="<?php 
echo \System\Helper::lang('sing_in');
?>
" class="btn">
    <a href="?page=registration<?php 
echo \System\Helper::getLang();
?>
" class="btn"><?php 
echo \System\Helper::lang('register');
?>
</a>
</form>
예제 #6
0
                header('Location: /' . \System\Helper::getLang());
            }
            break;
        case 'profile':
            if (\System\Models\Auth::isLogin()) {
                $profile = \System\Models\User::get();
                if ($profile) {
                    View::render('profile', ['profile' => $profile]);
                } else {
                    \System\Models\Auth::logOut();
                    header('Location: /' . \System\Helper::getLang());
                }
            } else {
                header('Location: /' . \System\Helper::getLang());
            }
            break;
        case 'logout':
            \System\Models\Auth::logOut();
            header('Location: /' . \System\Helper::getLang());
            break;
        default:
            View::render('404' . \System\Helper::getLang());
    }
    ?>
    <?php 
}
?>
</div>
<footer></footer>
</body>
</html>
예제 #7
0
<h1>404 : <?php 
echo \System\Helper::lang('404');
?>
</h1>
예제 #8
0
    echo \System\Helper::lang('experience');
    ?>
</td>
                <td><?php 
    echo $profile->experience->content;
    ?>
</td>
            </tr>
            <?php 
}
?>

            <?php 
if ($profile->summary) {
    ?>
            <tr>
                <td><?php 
    echo \System\Helper::lang('summary');
    ?>
</td>
                <td><?php 
    echo $profile->summary->content;
    ?>
</td>
            </tr>
            <?php 
}
?>
        </tbody>
    </table>
</div>