예제 #1
0
<?php

try {
    require_once 'Sprinkles.php';
    $sprink = new Sprinkles();
    if ($sprink->site_configured()) {
        redirect('helpstart.php');
        exit(0);
    }
    $defaults = $sprink->findsite_data();
    $sprinkles_root_url = request_param('sprinkles_root_url');
    if (!$sprinkles_root_url) {
        $sprinkles_root_url = $defaults[sprinkles_root_url];
    }
    if (!$sprinkles_root_url) {
        $uri = 'http' . ($_SERVER['HTTPS'] ? 's' : null) . '://' . $_SERVER['HTTP_HOST'];
        $uri .= $_SERVER['SERVER_PORT'] == '80' ? '' : ":" . $_SERVER['SERVER_PORT'];
        $uri .= $_SERVER['REQUEST_URI'];
        $sprinkles_root_url = $uri;
    }
    $smarty->assign('sprinkles_root_url', $sprinkles_root_url);
    $oauth_consumer_key = request_param('oauth_consumer_key');
    if (!$oauth_consumer_key) {
        $oauth_consumer_key = $defaults['oauth_consumer_key'];
    }
    $oauth_consumer_secret = request_param('oauth_consumer_secret');
    if (!$oauth_consumer_secret) {
        $oauth_consumer_secret = $defaults['oauth_consumer_secret'];
    }
    $company_sfnid = request_param('company_sfnid');
    if (!$company_sfnid) {
예제 #2
0
 }
 $cols = mysql_fetch_array($result);
 $request_token_secret = $cols[0];
 $sprink = new Sprinkles();
 $consumer_data = $sprink->oauth_consumer_data();
 list($token, $token_secret) = get_oauth_access_token($consumer_data, $request_token, $request_token_secret);
 if (!$token || !$token_secret) {
     throw new Exception("Getting OAuth access token from Get Satisfaction failed.");
 }
 $result = mysql_query("update sessions set token = '" . mysql_real_escape_string($token) . "', token_secret = '" . mysql_real_escape_string($token_secret) . "' where token = '" . mysql_real_escape_string($request_token) . "'");
 if (!$result) {
     throw new Exception("Failed to store auth tokens on oauth response");
 }
 $sprink = new Sprinkles();
 $sprink->open_session($token);
 if (!$sprink->site_configured() && request_param('first_login')) {
     $user = $sprink->current_user();
     if (!$user) {
         throw new Exception("Internal error: No current user just after opening session.");
     }
     $sprink->set_admin_users(array($user['canonical_name']));
     $result = $sprink->set_site_settings(array('configured' => 'Y'));
     if (!$result) {
         die(mysql_error());
     }
 }
 $return = request_param('return');
 if (!$return) {
     $return = 'helpstart.php';
 }
 redirect($return);
예제 #3
0
<?php

try {
    require_once "Sprinkles.php";
    $sprink = new Sprinkles();
    $message = $_GET['wrong_password'] ? 'The username and password you entered did not match. Please try again.' : '';
    $smarty->assign('site_configured', $sprink->site_configured());
    $smarty->assign('message', $message);
    $smarty->assign('current_url', 'admin.php');
    $sprink->add_std_hash_elems($smarty);
    $smarty->display('admin-login.t');
    finish_request('admin-login');
} catch (Exception $e) {
    error_log("Exception thrown while preparing page: " . $e->getMessage());
    $smarty->display('error.t');
}
    $company_sfnid = request_param('company_sfnid');
    $oauth_consumer_key = request_param('oauth_consumer_key');
    $oauth_consumer_secret = request_param('oauth_consumer_secret');
    $sprinkles_root_url = request_param('sprinkles_root_url');
    if (!$oauth_consumer_key || !$oauth_consumer_secret) {
        redirect('admin-findsite.php?msg=missing_oauth' . '&company_sfnid=' . $company_sfnid . '&oauth_consumer_key=' . $oauth_consumer_key . '&oauth_consumer_secret=' . $oauth_consumer_secret . '&sprinkles_root_url=' . $sprinkles_root_url);
        exit;
    }
    if (!$sprinkles_root_url) {
        redirect('admin-findsite.php?msg=missing_sprinkles_root_url' . '&company_sfnid=' . $company_sfnid . '&oauth_consumer_key=' . $oauth_consumer_key . '&oauth_consumer_secret=' . $oauth_consumer_secret . '&sprinkles_root_url=' . $sprinkles_root_url);
        exit;
    }
    if (!$company_sfnid) {
        redirect('admin-findsite.php?msg=missing_company_sfnid' . '&company_sfnid=' . $company_sfnid . '&oauth_consumer_key=' . $oauth_consumer_key . '&oauth_consumer_secret=' . $oauth_consumer_secret . '&sprinkles_root_url=' . $sprinkles_root_url);
        exit;
    }
    $sprinkles_root_url = preg_replace('|[^/]*.php$|', '', $sprinkles_root_url);
    # Note: the naive regex you'd usee below doesn't work; pcre is not in fact
    # Perl-compatible in this case
    $sprinkles_root_url = preg_replace('|([^/])/*$|', '\\1/', $sprinkles_root_url);
    $result = $sprink->set_site_settings(array('company_id' => $company_sfnid, 'oauth_consumer_key' => $oauth_consumer_key, 'oauth_consumer_secret' => $oauth_consumer_secret, 'sprinkles_root_url' => $sprinkles_root_url));
    if (!$result) {
        die(mysql_error());
    }
    message($sprink->site_configured());
    redirect($sprink->authorize_url('admin.php?hooked=true', true));
    exit(0);
} catch (Exception $e) {
    error_log("Exception thrown while preparing page: " . $e->getMessage());
    $smarty->display('error.t');
}