コード例 #1
0
 public function handlePost($get, $post, $files, $cookies)
 {
     session_start();
     if (!isset($post['host'])) {
         throw new \Exception('HOST is missing');
     }
     if (!isset($post['name'])) {
         throw new \Exception('NAME is missing');
     }
     if (!isset($post['user'])) {
         throw new \Exception('USER is missing');
     }
     if (!isset($post['pass'])) {
         throw new \Exception('PASS is missing');
     }
     if (!isset($post['prefix'])) {
         throw new \Exception('PREFIX is missing');
     }
     if (!isset($_SESSION['openid_identity'])) {
         throw new \Exception('OpenID login is missing');
     }
     Models\Database::$dsn = "mysql:host={$post['host']};dbname={$post['name']}";
     Models\Database::$username = $post['user'];
     Models\Database::$password = $post['pass'];
     Models\Database::$prefix = $post['prefix'];
     Models\Database::setupTables();
     Models\Preferences::setFactoryDefaults();
     Models\User::userWithOpenId($_SESSION['openid_identity'], $_SESSION['openid_email']);
     Models\Database::update('users', ['auth' => 5], 'email="' . $_SESSION['openid_email'] . '"');
     //todo security
     header('Location: ' . MainPageController::getUrl());
     //todo URL / url http://www.teamten.com/lawrence/writings/capitalization_of_initialisms.html
 }
コード例 #2
0
 public function handleGet($get, $post, $files, $cookies)
 {
     Models\User::logoutCurrentUser();
     header('Location: ' . MainPageController::getUrl());
 }
コード例 #3
0
    public function handleGet($get, $post, $files, $cookies)
    {
        /* Set up common page parts */
        $this->htmlHeader($cookies);
        try {
            // Mewp told me specifically not to use SERVER_NAME.
            // Change 'localhost' to your domain name.
            $openid = new \LightOpenID($_SERVER['SERVER_NAME']);
            if (!$openid->mode) {
                if (isset($post['openid_identifier'])) {
                    $openid->identity = $post['openid_identifier'];
                    $openid->required = array('contact/email');
                    $openid->optional = array('namePerson', 'namePerson/friendly');
                    header('Location: ' . $openid->authUrl());
                    return;
                }
            } elseif ($openid->mode == 'cancel') {
                echo 'User has canceled authentication!';
            } else {
                $identity = "";
                $email = "";
                if ($openid->validate()) {
                    $identity = $openid->identity;
                    $attr = $openid->getAttributes();
                    $email = $attr['contact/email'];
                    if (strlen($email)) {
                        session_start();
                        $_SESSION['openid_identity'] = $openid->identity;
                        $_SESSION['openid_email'] = $attr['contact/email'];
                        Models\User::userWithOpenId($_SESSION['openid_identity'], $_SESSION['openid_email']);
                        header('Location: ' . MainPageController::getUrl());
                        return;
                    } else {
                        throw new \Exception('Enough detail (email address) was not provided to process your login.');
                    }
                } else {
                    throw new \Exception('Provider did not validate your login');
                }
            }
        } catch (\ErrorException $e) {
            echo $e->getMessage();
        }
        if (file_exists('../../config.php')) {
            throw new \Exception("Camera Life already appears to be set up, because modules/config.inc exists.");
        }
        ?>
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">Login</h3>
                </div>
                <div class="panel-body">
                        <p class="lead">Choose an OpenID provider to login:</p>

                        <form class="form-inline" method="post">
                            <input type="hidden" name="action" value="verify"/>
                            <button class="btn btn-primary"  name="openid_identifier" value="https://www.google.com/accounts/o8/id"><i class="fa fa-google"></i> Google</button>
                            <button class="btn btn-primary"  name="openid_identifier" value="http://me.yahoo.com/"><i class="fa fa-yahoo"></i> Yahoo</button>
                        </form>

                        <hr>

                        <form class="form-inline" method="post">
                            <input type="hidden" name="action" value="verify"/>
                            Other OpenID
                            <input name="openid_identifier" class="form-control" value="http://"/>
                            <input class="btn btn-primary" type="submit" value="Login"/>
                        </form>
                </div>
            </div>
<?php 
        /* Render footer */
        $this->htmlFooter();
    }