// vim:ts=4:et // Copyright (c) 2009-2010, LoveMachine Inc. // All Rights Reserved. // http://www.lovemachineinc.com // this file handles AJAX requests to rewarder include "config.php"; include "class.session_handler.php"; include "functions.php"; $con = mysql_connect(DB_SERVER, DB_USER, DB_PASSWORD); mysql_select_db(DB_NAME, $con); if (!isset($_SESSION['userid'])) { echo json_encode(array('error' => 'unauthorized')); return; } $user = new User(); $user->findUserById(getSessionUserId()); // array of actions with audit permissions $auditActions = array('get-audit-list', 'update-rewarder-auditor'); if (in_array($_REQUEST['action'], $auditActions)) { if (!$user->getIs_auditor()) { echo json_encode(array('error' => 'unauthorized')); return; } } // array of actions with admin permissions $adminActions = array('end-period', 'reset_user_review'); if (in_array($_REQUEST['action'], $adminActions)) { // THIS IS TEMPORARY UNTIL LOGIN MODULE IS IN PLACE if (!$user->getIs_admin()) { echo json_encode(array('error' => 'unauthorized - not admin')); return;
* ineligible to receive and/or distribute rewarder * points. * Author: Jason (jkofoed@gmail.com) * Date: 2010-05-04 */ ini_set('display_errors', 1); error_reporting(E_ALL); include "config.php"; include "class.session_handler.php"; include_once "functions.php"; include_once "send_email.php"; //send non-admins back to main. if (empty($_SESSION['is_admin'])) { // header("Location:rewarder.php"); } $userId = getSessionUserId(); //open db connection $db = @mysql_connect(DB_SERVER, DB_USER, DB_PASSWORD) or die('I cannot connect to the database because: ' . mysql_error()); $db = @mysql_select_db(DB_NAME); $rowclass = 'rowodd'; //If $action is set, it should be 'grantpoints' if (isset($_POST["action"]) && $_POST["action"] == 'grant-points') { foreach ($_POST["points"] as $user => $rewarder_points) { if ($rewarder_points != '') { $user_points_sql = 'SELECT id, rewarder_points, username FROM ' . REVIEW_USERS . ' WHERE id = ' . $user; $user_points_query = mysql_query($user_points_sql); $user_data = mysql_fetch_array($user_points_query); $updated_rewarder_points = $user_data["rewarder_points"] + $rewarder_points; if ($updated_rewarder_points < 0) { $rewarder_points = $user_data["rewarder_points"]; $updated_rewarder_points = 0;