Exemplo n.º 1
0
    $smarty->assign('reply_url', $reply_url);
    $smarty->assign(array('company_promoted_replies' => $company_promoted, 'star_promoted_replies' => $star_promoted));
    $smarty->assign('flagged_topic', request_param('flagged_topic'));
    $smarty->assign('own_topic', $topic_head['author']['canonical_name'] == $sprink->current_username());
    $smarty->assign('flagged_reply', request_param('flagged_reply'));
    if (request_param('shared_with')) {
        $smarty->assign('shared_with', explode(',', request_param('shared_with')));
    }
    if (request_param('share_failed')) {
        $smarty->assign('share_failed_msg', true);
    }
    if (request_param('me_tood_topic')) {
        $smarty->assign('me_tood_topic_msg', true);
    }
    if (request_param('me_too_failed')) {
        $smarty->assign('me_too_failed_error', true);
    }
    if (request_param('no_self_star')) {
        $smarty->assign('self_star_error', true);
    }
    if (request_param('blank_reply')) {
        $smarty->assign('blank_reply_error', true);
    }
    $smarty->assign('current_url', 'topic.php?id=' . $topic_id);
    $sprink->add_std_hash_elems($smarty);
    $smarty->display('topic.t');
    finish_request('topic');
} catch (Exception $e) {
    error_log("Exception thrown while preparing page: " . $e->getMessage());
    $smarty->display('error.t');
}
Exemplo n.º 2
0
<?php

try {
    require_once 'Sprinkles.php';
    $sprink = new Sprinkles();
    $subject = request_param('subject');
    $details = request_param('details');
    $tags = request_param('tags');
    $emoticon = request_param('emoticon');
    $emotion = request_param('emotion');
    $style = request_param('style');
    $selected_products = request_param('product');
    if (!$selected_products) {
        $selected_products = array();
    }
    $validation_errors = request_param('errs');
    $suggested = $sprink->topics(array('query' => $subject, "limit" => $submit_suggestions));
    $suggested = $suggested['topics'];
    $top_tags = take(8, $sprink->tags($api_root . 'companies/' . $sprink->company_sfnid . '/tags?on=topics&sort=usage&limit=8'));
    switch ($style) {
        case 'question':
            $friendly_style = 'question';
            break;
        case 'idea':
            $friendly_style = 'idea';
            break;
        case 'problem':
            $friendly_style = 'problem';
            break;
        case 'talk':
            $friendly_style = 'discussion';
Exemplo n.º 3
0
    $sprink = new Sprinkles();
    $reply_id = request_param('reply_id');
    $topic_id = request_param('topic_id');
    $creds = $sprink->current_user_session();
    if (!$creds) {
        $target_page = $preview_after_login ? 'topic.php' : 'handle-star.php';
        $args = 'reply_id=' . urlencode($reply_id) . '&topic_id=' . urlencode($topic_id);
        redirect('user-login.php?return=' . urlencode($target_page . '?' . $args));
        exit(0);
    }
    $POST_URL = $sprink->api_url($reply_id . "/stars");
    # FIXME use @rel=stars link from feed
    $params = array('reply_id' => $reply_id);
    $req = $sprink->oauthed_request('POST', $POST_URL, $creds, null, $params);
    if (400 == ($responseCode = $req->getResponseCode())) {
        # TBD: refine this to read HTTP reason
        redirect('topic.php?no_self_star=1&id=' . $topic_id);
        exit(0);
    }
    if (201 != $responseCode) {
        error("Failed starring with POST to {$POST_URL}: " . $req->getResponseBody());
        die("API Error {$responseCode} starring reply {$reply_id}.");
    }
    $topic_url = request_param('topic_id');
    invalidate_http_cache($topic_url);
    redirect('topic.php?id=' . urlencode($topic_url));
    exit(0);
} catch (Exception $e) {
    error_log("Exception thrown while preparing page: " . $e->getMessage());
    $smarty->display('error.t');
}
Exemplo n.º 4
0
<?php

try {
    require_once 'Sprinkles.php';
    require_once 'HTTP_Request_Oauth.php';
    $sprink = new Sprinkles();
    $return = request_param('return');
    $consumer_data = $sprink->oauth_consumer_data();
    if (!$consumer_data['key'] || !$consumer_data['secret']) {
        die("The OAuth consumer data was missing from the Instant-On Help " . "Center database! Perhaps something went wrong during installation " . "and setup.");
    }
    list($token, $secret) = get_oauth_request_token($consumer_data);
    if (!$token || !$secret) {
        error("Failed to fetch OAuth request token " . "(Result token: '{$token}'; Token secret: '{$token_secret}')");
        die("Failed to fetch OAuth request token from getsatisfaction.com.");
    }
    $result = insert_into('sessions', array('token' => $token, 'token_secret' => $secret));
    if (!$result) {
        die("Error inserting OAuth tokens into database.");
    }
    $first_login = request_param('first_login');
    $callback_url = $sprink->sprinkles_root_url() . 'handle-oauth-return.php?' . ($first_login ? 'first_login=true&' : '') . 'return=' . urlencode($return);
    redirect(oauth_authorization_url($token, $callback_url));
    exit(0);
} catch (Exception $e) {
    error_log("Exception thrown while preparing page: " . $e->getMessage());
    $smarty->display('error.t');
}
<?php

try {
    require_once 'Sprinkles.php';
    $sprink = new Sprinkles();
    $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));
Exemplo n.º 6
0
<?php

require_once "Sprinkles.php";
$sprink = new Sprinkles();
$page_num = request_param('page');
if (!$page_num) {
    $page_num = 0;
}
$topic_filters = array("limit" => $discuss_page_size, "page" => $page_num);
$filter_style = request_param('style');
if ($filter_style) {
    $topic_filters['style'] = $filter_style;
    $smarty->assign('style', $filter_style);
}
$filter_query = request_param('query');
if ($filter_query) {
    $topic_filters['query'] = $filter_query;
    $smarty->assign('query', $filter_query);
}
$topics = $sprink->topics($topic_filters);
$topic_count = $topics['totals']['this'];
// $sprink->resolve_authors($topics['topics']);
$smarty->assign('page_num', $page_num);
$smarty->assign('num_pages', ceil($topic_count / $discuss_page_size));
$smarty->assign('topics', $topics['topics']);
$smarty->assign('topic_count', $topic_count);
$smarty->assign('totals', $topics['totals']);
$sprink->add_std_hash_elems($smarty);
$smarty->display('results.t');
finish_request('results');
Exemplo n.º 7
0
<?php

try {
    # POST to /topics/$sfn_id/me_toos
    require_once 'Sprinkles.php';
    $sprink = new Sprinkles();
    $sfn_id = request_param('sfn_id');
    $creds = $sprink->current_user_session();
    if (!$creds) {
        $target_page = $preview_after_login ? 'topic.php' : 'handle-me-too.php';
        $args = 'sfn_id=' . urlencode($sfn_id);
        redirect('user-login.php?return=' . urlencode($target_page . '?' . $args));
        exit(0);
    }
    $POST_URL = $sprink->api_url("topics/" . $sfn_id . "/me_toos");
    $req = $sprink->oauthed_request('POST', $POST_URL, $creds, null, array("askdjnaksjdbas" => "aksjhdaksjdnaksjdnka"));
    $responseCode = $req->getResponseCode();
    if (0 == $responseCode) {
        die("Timeout accessing the API, while posting to {$POST_URL}.");
        # FIXME: recover for user
    } else {
        if (400 == $responseCode) {
            redirect('topic.php?sfn_id=' . $sfn_id . '&me_too_failed=true');
            exit(0);
        } else {
            if (201 != $responseCode) {
                die("API Error {$responseCode} me-tooing topic {$sfn_id}.");
            }
        }
    }
    $topic_url = $sprink->api_url("topics/" . $sfn_id);
Exemplo n.º 8
0
<?php

require_once 'Sprinkles.php';
$query = request_param('query');
$mode = request_param('mode');
if (!$mode) {
    $mode = 'simple';
}
$sprink = new Sprinkles();
$suggested = $sprink->topics(array('query' => $query, "limit" => 3));
$topics = $suggested['topics'];
if ($mode == 'fancy') {
    $sprink->resolve_authors($topics);
}
$smarty->assign('suggested_topics', $topics);
$smarty->assign('mode', $mode);
$smarty->display('topic-suggestions.t');
finish_request('topic-suggestions');
Exemplo n.º 9
0
<?php

try {
    require_once 'Sprinkles.php';
    $sprink = new Sprinkles();
    $smarty->assign('complainant_name', request_param('name'));
    $sprink->add_std_hash_elems($smarty);
    $smarty->display('contactus-success.t');
} catch (Exception $e) {
    error_log("Exception thrown while preparing page: " . $e->getMessage());
    $smarty->display('error.t');
}
Exemplo n.º 10
0
<?php

try {
    require_once "Sprinkles.php";
    $sprink = new Sprinkles();
    $topic_id = request_param('id');
    if (!$topic_id) {
        die("Internal error: expected id parameter.");
    }
    $items = $sprink->topic($topic_id);
    if (!$items) {
        die("Internal error: Empty topic {$topic_id}.");
    }
    $topic_head = array_shift($items['replies']);
    $smarty->assign('topic_head', $topic_head);
    $smarty->assign('topic_id', $topic_id);
    $smarty->assign('body_css_id', 'share-topic');
    $smarty->assign('current_url', 'share-topic.php?id=' . $topic_id);
    $sprink->add_std_hash_elems($smarty);
    $smarty->display('share-topic.t');
    finish_request('share-topic');
} catch (Exception $e) {
    error_log("Exception thrown while preparing page: " . $e->getMessage());
    $smarty->display('error.t');
}
Exemplo n.º 11
0
        $settings[$field] = request_param($field);
    }
}
if (request_param('admin_users')) {
    $settings['admin_users_str'] = request_param('admin_users');
}
$company_hcard = $sprink->company_hcard();
$smarty->assign('company_url', is_array($company_hcard['url']) ? $company_hcard['url'][0] : $company_hcard['url']);
$sprinkles_tagged_topics = $sprink->topics(array('tag' => 'sprinkles', 'limit' => '3'));
$sprinkles_tagged_topics = $sprinkles_tagged_topics['topics'];
$site_links = $sprink->site_links();
$smarty->assign('site_links', $site_links);
$smarty->assign('invalid', request_param('invalid'));
$smarty->assign('errors', request_param('errors'));
$smarty->assign('settings_saved', request_param('settings_saved'));
$smarty->assign('hooked_msg', request_param('hooked'));
$new_admins = request_param('new_admins');
if ($new_admins) {
    $smarty->assign('new_admins', split(',', $new_admins));
}
$smarty->assign('settings', $settings);
$smarty->assign('sprinkles_root_url', $sprink->sprinkles_root_url());
$smarty->assign('sprinkles_tagged_topics', $sprinkles_tagged_topics);
$smarty->assign('current_url', 'admin.php');
# FIXME: this leads to odd behavior on
# logout: user goes straight to sign-in
# page; consider taking the logout link
# to some other page.
$sprink->add_std_hash_elems($smarty);
$smarty->display('admin.t');
finish_request('admin');
Exemplo n.º 12
0
    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);
    exit(0);
} catch (Exception $e) {
    error_log("Exception thrown while preparing page: " . $e->getMessage());
    $smarty->display('error.t');
}
Exemplo n.º 13
0
<?php

try {
    require_once 'Sprinkles.php';
    $sprink = new Sprinkles();
    $type = request_param('type');
    if ($type != 'topic' && $type != 'reply') {
        die("unknown type '{$type}' while flagging");
    }
    $POST_URL = $type == 'topic' ? $sprink->api_url("flagged/topics") : ($type == 'reply' ? $sprink->api_url("flagged/replies") : '');
    $id = request_param('id');
    $params = $type == 'topic' ? array('topic_id' => $id) : ($type == 'reply' ? array('reply_id' => $id) : '');
    $creds = $sprink->current_user_session();
    if (!$creds) {
        die("Not logged in");
    }
    # FIXME
    $req = $sprink->oauthed_request('POST', $POST_URL, $creds, null, $params);
    if (201 != ($responseCode = $req->getResponseCode())) {
        die("API Error {$responseCode} flagging item {$type} {$id}.");
    }
    redirect('topic.php?id=' . request_param('topic_id') . ($type == 'topic' ? '&flagged_topic=' : ($type == 'reply' ? '&flagged_reply=' : '')) . $id);
    exit(0);
} catch (Exception $e) {
    error_log("Exception thrown while preparing page: " . $e->getMessage());
    $smarty->display('error.t');
}
Exemplo n.º 14
0
        $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) {
        $company_sfnid = $defaults['company_sfnid'];
    }
    $smarty->assign(array('oauth_consumer_key' => $oauth_consumer_key, 'oauth_consumer_secret' => $oauth_consumer_secret, 'company_sfnid' => $company_sfnid));
    $smarty->assign('msg', request_param('msg'));
    $smarty->assign('background_color', '#86fff6');
    $smarty->assign('no_admin_link', true);
    $smarty->display('admin-findsite.t');
    finish_request('admin-findsite');
} catch (Exception $e) {
    error_log("Exception thrown while preparing page: " . $e->getMessage());
    $smarty->display('error.t');
}
Exemplo n.º 15
0
<?php

try {
    require_once 'Sprinkles.php';
    $subject = request_param('subject');
    $details = request_param('details');
    $tags = request_param('tags');
    $face = request_param('emoticon');
    $emotion = request_param('emotion');
    $style = request_param('style');
    $products = request_param('products');
    $args = 'subject=' . urlencode($subject) . '&details=' . urlencode($details) . '&tags=' . urlencode($tags) . '&emoticon=' . urlencode($face) . '&emotion=' . urlencode($emotion) . '&style=' . urlencode($style);
    foreach ($products as $product) {
        $args .= '&product[]=' . urlencode($product);
    }
    if ($subject == '') {
        redirect('submit.php?' . $args . '&errs[]=subject');
        exit(0);
    }
    if (!$products) {
        $products = array();
    }
    $products_commasep = join(',', $products);
    $sprink = new Sprinkles();
    $creds = $sprink->current_user_session();
    if (!$creds) {
        $target_page = $preview_after_login ? 'submit.php' : 'handle-submit.php';
        redirect('user-login.php?return=' . urlencode($target_page . '?' . $args));
        exit(0);
    }
    $POST_URL = $api_root . 'companies/' . $sprink->company_sfnid . '/topics';
Exemplo n.º 16
0
<?php

try {
    require_once 'Sprinkles.php';
    $sprink = new Sprinkles();
    $from = request_param('email');
    $from = preg_replace('/\\n.*$/', ' ', $from);
    # Sanitizes $from; it'll go verbatim in the SMTP headers
    $message = request_param('name') . ' reported a problem in the Get Satisfaction Instant On Help Center at ' . date('H:i:s T, Y/m/d') . '.' . "\n\n" . 'Summary: ' . request_param('summary') . "\n\n" . 'Details: ' . request_param('observed') . "\n\n" . 'I\'m ' . request_param('feeling');
    $subject = request_param('summary');
    $contact = $sprink->site_contact_info();
    $to = $contact['contact_email'];
    mail($to, $subject, $message, "From: {$from}");
    $name = request_param('name');
    redirect('contactus-success.php?name=' . urlencode($name));
    exit(0);
} catch (Exception $e) {
    error_log("Exception thrown while preparing page: " . $e->getMessage());
    $smarty->display('error.t');
}
Exemplo n.º 17
0
<?php

try {
    require_once 'Sprinkles.php';
    $sprink = new Sprinkles();
    $topic_id = request_param('topic_id');
    $reply_url = request_param('replies_url');
    if (!($content = request_param('content'))) {
        redirect('topic.php?blank_reply=1&id=' . urlencode($topic_id));
        exit(0);
    }
    $params = array('reply[content]' => $content);
    if ($parent_id = request_param('parent_id')) {
        $params['reply[parent_id]'] = $parent_id;
    }
    $creds = $sprink->current_user_session();
    if (!$creds) {
        die("Not logged in! (FIXME)");
    }
    $req = $sprink->oauthed_request('POST', $reply_url, $creds, null, $params);
    if (201 != ($responseCode = $req->getResponseCode())) {
        die("API Error {$responseCode} replying to {$topic_id}.");
    }
    $topic_url = $topic_id;
    invalidate_http_cache($topic_url);
    redirect('topic.php?id=' . urlencode($topic_id));
    exit(0);
} catch (Exception $e) {
    error_log("Exception thrown while preparing page: " . $e->getMessage());
    $smarty->display('error.t');
}
Exemplo n.º 18
0
        //   }
        // }
        // $sprink->set_site_links($links);
        $sql = 'update site_settings set ' . 'background_color = \'' . mysql_real_escape_string($background_color) . '\', ' . 'contact_email = \'' . mysql_real_escape_string($contact_email) . '\', ' . 'contact_address = \'' . mysql_real_escape_string($contact_address) . '\', ' . 'map_url = \'' . mysql_real_escape_string($map_url) . '\', ' . 'contact_phone = \'' . mysql_real_escape_string($contact_phone) . '\', ' . 'configured = \'Y\', ' . 'logo_link = \'' . mysql_real_escape_string($logo_link) . '\' ' . ($logo_data ? ', logo_data = \'' . mysql_real_escape_string($logo_data) . '\'' : '');
        $result = mysql_query($sql);
        if (!$result) {
            print mysql_error();
            return;
        }
        $sprink->set_admin_users($admin_users);
        $params = '';
        if ($new_admins) {
            $params .= '&new_admins=' . join(',', $new_admins);
        }
        redirect('admin.php?settings_saved=true' . $params);
        exit(0);
    } else {
        foreach ($bad_fields as $field) {
            $params .= '&invalid[' . $field . ']=true';
        }
        foreach ($fields as $field) {
            $params .= '&' . $field . '=' . urlencode(request_param($field));
        }
        $params .= '&admin_users=' . urlencode($admin_users_str);
        redirect('admin.php?errors=true' . $params);
        exit(0);
    }
} catch (Exception $e) {
    error_log("Exception thrown while preparing page: " . $e->getMessage());
    $smarty->display('error.t');
}
Exemplo n.º 19
0
    $sprink = new Sprinkles();
    $id = request_param('id');
    $topic = $sprink->topic($id);
    $topic = $topic['replies'][0];
    $from = request_param('from_email');
    $from = preg_replace('/\\n.*$/', ' ', $from);
    # Sanitizes $from; it'll go verbatim in the SMTP headers
    $user_fn = request_param('sender_name');
    if (!$user_fn) {
        $user = $sprink->current_user();
        $user_fn = $user['fn'];
    }
    $personal_message = request_param('personal_message');
    $message = $user_fn . " thinks you might be interested in this discussion from Get Satisfaction:\n\n" . "\"" . $topic['title'] . "\n\n" . $topic['content'] . "\"\n\n" . $topic['author']['fn'] . " asked this on " . $topic['published_formatted'] . (!$personal_message ? '' : "\n\n" . $user_fn . " says: \n\n" . $personal_message);
    $subject = "'" . $topic['title'] . "' on Get Satisfaction!";
    $to = request_param('to_email');
    # TBD: handle more than one address
    if (preg_match('/,/', $to)) {
        die("Sharing with more than one recipient is not yet implemented. :-(");
    }
    # FIXME: not graceful.
    $result = mail($to, $subject, $message, "From: {$from}");
    if ($result) {
        redirect('topic.php?id=' . $id . '&shared_with=' . urlencode($to));
    } else {
        redirect('topic.php?id=' . $id . '&share_failed=true');
    }
    exit(0);
} catch (Exception $e) {
    error_log("Exception thrown while preparing page: " . $e->getMessage());
    $smarty->display('error.t');