Example #1
0
function fetchClassData($year, $db)
{
    $statement = $db->prepare("SELECT DISTINCT(name) FROM UWISE.donors WHERE year = :year");
    $statement->execute(array(':year' => $year));
    $row = $statement->fetchAll();
    returnData($row);
}
Example #2
0
 /**
     Querys the database with the given request.
     @param string $query db query.
     @return string
     **/
 public function makeRequest($query)
 {
     $content = file_get_contents($this->_url . urlencode($query));
     if ($content === false) {
         returnData('Influxdb not reachable', 1, 'Influxdb not reachable');
     } else {
         return json_decode($content, true)['results'];
     }
 }
Example #3
0
function testDb()
{
    global $Dbc, $debug, $message, $success;
    if (!empty($_POST['email']) && emailValidate($_POST['email']) && !empty($_POST['firstName']) && !empty($_POST['lastName']) && !empty($_POST['password']) && passwordValidate($_POST['password'])) {
        destroySession();
        $email = trim($_POST['email']);
        $pass = sha1(trim($_POST['password']));
        $firstName = trim($_POST['firstName']);
        $lastName = trim($_POST['lastName']);
        $rememberMeCode = sha1($email);
        $Dbc->beginTransaction();
        try {
            $stmt = $Dbc->prepare("SELECT getUserIdByEmail(?) AS 'userId'");
            $stmt .= $stmt->execute(array($email));
            while ($row = $stmt->fetch()) {
                $debug->add('$row[\'userId\']: ' . $row['userId']);
                $debug->printArray($row, '$row');
                if (empty($row['userId'])) {
                    //There are no users with the email address, so continue.
                    pdoError(__LINE__, $stmt, 1);
                    $stmt = $Dbc->prepare("INSERT INTO\n\tusers\nSET\n\tprimaryEmail = ?,\n\tuserPassword = ?,\n\tfirstName = ?,\n\tlastName = ?,\n\tjoinDate = ?");
                    if ($stmt->execute(array($email, $pass, $firstName, $lastName, DATETIME))) {
                        $debug->add('last id: ' . $Dbc->lastInsertId());
                    } else {
                        pdoError(__LINE__, $stmt);
                    }
                } else {
                    $message .= 'That email address is already associated with an account. Please enter a different email address.<br>';
                }
            }
        } catch (PDOException $e) {
            //Rollback occurs automatically if an exception is thrown.
            error(__LINE__, '', '<pre>' . $e . '</pre>');
            pdoError(__LINE__);
        }
    } elseif (empty($_POST['email'])) {
        $debug->add('email is empty on line ' . __LINE__ . '');
        $message .= 'Please enter an email address.';
    } elseif (!emailValidate($_POST['email'])) {
        $message .= 'Please enter a valid email address.';
        $debug->add('Email address is not valid.');
    } elseif (empty($_POST['firstName'])) {
        $debug->add('first name is empty on line ' . __LINE__ . '.');
        $message .= 'Please enter a First Name.';
    } elseif (empty($_POST['lastName'])) {
        $debug->add('last name is empty on line ' . __LINE__ . '.');
        $message .= 'Please enter a Last Name.';
    } elseif (empty($_POST['password'])) {
        $debug->add('password is empty on line ' . __LINE__ . '.');
        $message .= 'Please enter a password.';
    } else {
        $debug->add('Something is missing.');
    }
    returnData();
}
Example #4
0
/**
Parses the configuration file.
@param string $filename Path to the configuration file.
@return null.
**/
function parsIni($filename)
{
    if (empty($filename) || !file_exists($filename)) {
        returnData("", 1, "Configuration not found: " . $filename);
    }
    $config = parse_ini_file($filename, true);
    setConstant("DEFAULT_SOCKET_TIMEOUT", $config['general']['socketTimeout'], 10);
    setConstant("INFLUX_URL", $config['influxdb']['influxdbUrl'], "http://127.0.0.1:8086/query?db=icinga");
    setConstant("INFLUX_FIELDSEPERATOR", $config['influxdb']['influxFieldseperator'], "&");
    setConstant("DEFAULT_TEMPLATE_FOLDER", $config['folder']['defaultTemplateFolder'], "histou/templates/default/");
    setConstant("CUSTOM_TEMPLATE_FOLDER", $config['folder']['customTemplateFolder'], "histou/templates/custom/");
}
Example #5
0
 function storeData($library_id, $command, $table, $values)
 {
     $event_tables = array('answers', 'borrows', 'open_scores', 'permissions', 'supports', 'belongs', 'transactions');
     $entity_tables = array('roots', 'branches', 'users', 'authors', 'publications', 'objects', 'matches', 'files');
     if (count($values) > 0 && (in_array($table, $event_tables) || in_array($table, $entity_tables))) {
         $query = '';
         $values = join(',', $values);
         if ($command == 'insert') {
             $query = "insert ignore into {$table} values {$values}";
         } else {
             if ($command == 'update') {
                 $query = "replace into {$table} values {$values}";
             } else {
                 if ($command == 'delete') {
                     $query = "delete from {$table} where id in ({$values})" . (in_array($table, $event_tables) ? " and library_id = {$library_id}" : '');
                 } else {
                     returnData('Invalid Db Command');
                 }
             }
         }
         DB::query($query);
     }
 }
Example #6
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $count = Category::destroy($id);
     if ($count > 0) {
         return returnData(true, [], true);
     }
     return returnData(false, [], true);
 }
            }
        }
        returnData($data);
        saveData($data);
        break;
    case 'DELETE':
        $index = 0;
        $i = 0;
        foreach ($data as $val) {
            if ($val['ranges']['0']['start'] == $jsonObj['ranges']['0']['start'] && $val['ranges']['0']['startOffset'] == $jsonObj['ranges']['0']['startOffset'] && $val['ranges']['0']['end'] == $jsonObj['ranges']['0']['end'] && $val['ranges']['0']['endOffset'] == $jsonObj['ranges']['0']['endOffset'] && $val['quote'] == $jsonObj['quote']) {
                $index = $i;
            }
            $i++;
        }
        unset($data[$index]);
        returnData($data);
        saveData($data);
        break;
}
/* TODO 
-> authentication
-> multi-users
*/
/**/
function saveData($data)
{
    $data = json_encode($data);
    file_put_contents('data.json', $data);
}
function returnData($data)
{
Example #8
0
<?php

/*
 * Copyright (c) 2006/2007 Flipperwing Ltd. (http://www.flipperwing.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
/**
 * @author andy.scholz@gmail.com
 * @copyright (c)2006-2007 Flipperwing Ltd.
 */
// Set flag that this is a parent file
define('_VALID_MOS', 1);
require_once "../../init.php";
require_once $csModelsDir . "/JUser.php";
$filter = new Filter($_REQUEST);
$obj = new JUser(&$database);
$results = $obj->listObjects($filter);
returnData($results);
Example #9
0
function returnOK($message = null, $attributes = null)
{
    returnData(new RemoteStatus(STATUS_OK, $message, $attributes));
}
Example #10
0
/**
Parses the GET parameter.
@return null.
**/
function parsArgs()
{
    if (isset($_GET['host']) && !empty($_GET['host'])) {
        define("HOST", $_GET["host"]);
    } else {
        returnData('Hostname is missing!', 1, 'Hostname is missing!');
    }
    if (isset($_GET['service']) && !empty($_GET['service'])) {
        define("SERVICE", $_GET["service"]);
    } else {
        define("SERVICE", "");
    }
    if (isset($_GET['debug'])) {
        Debug::enable();
    }
    if (isset($_GET['height']) && !empty($_GET['height'])) {
        define("HEIGHT", $_GET["height"]);
    } else {
        define("HEIGHT", "400px");
    }
    if (isset($_GET['legend']) && !empty($_GET['legend'])) {
        if ($_GET["legend"] == "true") {
            define("LEGEND_SHOW", true);
        } else {
            define("LEGEND_SHOW", false);
        }
    } else {
        define("LEGEND_SHOW", true);
    }
}
Example #11
0
function getFolderInfo($requestingUserId, $folderId)
{
    /*
    Get a folder's information as it relates to a user. The name, created date, modified date, creator, modifier, folderRoleId, and it's lists in an array(listId=>listname).
    $userId = (int) the id of the requesting user. This is to verify the user has role of Member (1) or greater.
    $folderId = (int) the id of the folder.
    Returns (array) of the lists in the folder and the user's role, otherwise (boolean) false. Use === false to check for failure as it's possible a list could be named "0".
    */
    global $debug, $message, $success, $Dbc;
    $output = '';
    try {
        if (empty($requestingUserId)) {
            throw new Adrlist_CustomException('', '$requestingUserId is empty.');
        } elseif (empty($folderId)) {
            throw new Adrlist_CustomException('', '$folderId is empty.');
        }
        $requestingUserId = intThis($requestingUserId);
        $folderId = intThis($folderId);
        //Get the folder's name.
        $stmt = $Dbc->prepare("SELECT\n\tfolders.folderName AS 'folderName',\n\tfolders.cId AS 'cId',\n\tfolders.created AS 'created',\n\tfolders.mId AS 'mId',\n\tfolders.modified AS 'modified',\n\tlists.listId AS 'listId',\n\tlists.listName AS 'listName',\n\tuserFolderSettings.folderRoleId AS 'folderRoleId'\nFROM\n\tuserFolderSettings\nJOIN\n\tfolders ON userFolderSettings.folderId = folders.folderId\nLEFT JOIN\n\tlists ON lists.folderId = userFolderSettings.folderId\nWHERE\n\tuserFolderSettings.userId = ? AND\n\tuserFolderSettings.folderId = ?");
        $params = array($requestingUserId, $folderId);
        $stmt->execute($params);
        $folderArray = array();
        $listArray = array();
        $foundRecords = false;
        while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
            if ($row['folderName'] === '' || $row['folderName'] === NULL) {
                pdoError(__LINE__, $stmt, $params, true);
                return false;
            }
            $folderArray['folderName'] = $row['folderName'];
            $folderArray['cId'] = $row['cId'];
            $folderArray['created'] = $row['created'];
            $folderArray['mId'] = $row['mId'];
            $folderArray['modified'] = $row['modified'];
            $folderArray['folderRoleId'] = empty($row['folderRoleId']) ? 0 : $row['folderRoleId'];
            $listArray[] = array($row['listId'] => $row['listName']);
            $foundRecords = true;
        }
        if (!$foundRecords) {
            return false;
        } else {
            $folderArray['listArray'] = $listArray;
            return $folderArray;
        }
    } catch (Adrlist_CustomException $e) {
    } catch (PDOException $e) {
        error(__LINE__, '', '<pre>' . $e . '</pre>');
        if (MODE !== '') {
            returnData();
        }
    }
    return false;
}
Example #12
0
        if ($favourites != "") {
            $list .= '<div id="favourites"><table border="2"><tr><th><center><div id="title">Game</div></center></th><th><center><div id="title">Remove</div></center></th></tr>';
            foreach ($arr as $id) {
                if ($id != "") {
                    $data = mysql_fetch_array(mysql_query("SELECT * FROM gmes WHERE id = '{$id}'"));
                    $gme_name = $data['gme_name'];
                    $list .= '<tr><td><div id="gmeName"><a id="link" href="' . $mirrorUrl . '?ext=/scripts/PlaySWF.php?id=' . $id . '">' . $gme_name . '</a></div></td><td><a id="x" href="javascript:removeFav(' . $id . ')"><center>Remove</center></a></td></tr>';
                }
            }
            $list .= "</div></table>";
            $list = base64_encode($list);
            returnData($list);
            break;
        }
        break;
    case "removeRequest":
        $id = secureForDB($_POST['id']);
        mysql_query("UPDATE requests SET hidden = '1' WHERE id = '{$id}'");
        $q = mysql_query("SELECT * FROM requests WHERE hidden = '0'");
        if (!mysql_num_rows($q) == 0) {
            $tbl = '<div id="requests"><table border="1"><tr><th>Game Name</th><th>Username</th><th>Email</th><th>Date</th><th>Remove</th></tr>';
            while ($row = mysql_fetch_array($q)) {
                $tbl .= '<tr><td><a href="' . $row['game_url'] . '">' . $row['game_name'] . '</a></td><td>' . $row['username'] . '</td><td>' . $row['email'] . '</td><td>' . $row['date'] . '</td><td><a id="remove" href="javascript:removeRequest(' . $row['id'] . ');">X</a></td></tr>';
            }
            $tbl .= "</table>";
            returnData(base64_encode($tbl));
        } else {
            returnData(base64_encode("There are currently no requests"));
        }
        break;
}
Example #13
0
function buildTRT()
{
    //The total running time of all adr lines, according to the TC in and out points. Lines with malformed or missing TC are not counted.
    global $debug, $message, $success, $Dbc;
    try {
        $output = '';
        $Dbc->beginTransaction();
        $stmt = $Dbc->prepare("SELECT\n\tlineId as 'lineId',\n\ttcIn as 'tcIn',\n\ttcOut as 'tcOut'\nFROM\n\tlinesTable\nWHERE\n\tlistId = ? AND\n\ttcIn <> ? AND\n\ttcOut <> ?");
        $params = array($_SESSION['listId'], '', '');
        $stmt->execute($params);
        $rowsFound = 0;
        $hours = 0;
        $minutes = 0;
        $seconds = 0;
        $frames = 0;
        while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
            //Validate the tc first.
            $output .= 'In: ' . $row['tcIn'] . ', Out: ' . $row['tcOut'] . '<br>';
            $tcInNumbers = str_replace(':', '', $row['tcIn']);
            $tcOutNumbers = str_replace(':', '', $row['tcOut']);
            $thisCount = $tcOutNumbers - $tcInNumbers;
            if ($thisCount < 0) {
                return 'The TC Out value is earlier than the TC In value for line ID: ' . $row['lineId'] . '.<br>';
            } else {
                $hours = $count += $thisCount;
            }
            $tcInArray = splitTC($row['tcIn']);
            $tcOutArray = splitTC($row['tcOut']);
            $rowsFound++;
        }
        if (!$rowsFound) {
            $output .= 'There were no valid time code fields.';
        }
        $Dbc->commit();
    } catch (PDOException $e) {
        error(__LINE__, '', '<pre>' . $e . '</pre>');
        if (MODE == 'buildTRT') {
            returnData();
        } else {
            return $output;
        }
    }
    if (MODE == 'buildTRT') {
        returnData();
    } else {
        return $output;
    }
}
Example #14
0
    public static function buildTimeZones()
    {
        //Build a drop down list of times every 15 minutes. This function is dependent on date_default_timezone_set('UTC').
        global $debug, $message, $success, $Dbc, $returnThis;
        $output = '';
        try {
            if (empty($_POST['timestampMilliseconds'])) {
                throw new Adrlist_CustomException('', '$_POST[\'timestamp\'] is empty.');
            } elseif (empty($_POST['offsetMinutes'])) {
                throw new Adrlist_CustomException('', '$_POST[\'offsetMinutes\'] is empty.');
            }
            $label = empty($_POST['label']) ? 'Time Zone' : $_POST['label'];
            $jsTimestamp = round(($_POST['timestampMilliseconds'] - $_POST['offsetMinutes'] * 1000 * 60) / 1000);
            $debug->add('$_POST[\'timestampMilliseconds\']: ' . $_POST['timestampMilliseconds'] . '<br>
	$_POST[\'offsetMinutes\']: ' . $_POST['offsetMinutes'] . '<br>
	$jsTimestamp: ' . "{$jsTimestamp}.");
            $now = time();
            $timeZones = DateTimeZone::listIdentifiers();
            $potentialTimeZones = array();
            $allTimeZones = array();
            foreach ($timeZones as $timeZone) {
                //Use the DateTime class to determine the local time for $location.
                $dt = new DateTime('@' . $now);
                //Accepts a strtotime() string.
                $dt->setTimeZone(new DateTimeZone($timeZone));
                //Change to a different timezone.
                //$timestamp = $dt->format('U');
                $formatted = $dt->format('M j, g:i A');
                $timestamp = strtotime($formatted);
                $allTimeZones[$timeZone] = $timestamp . ', ' . $formatted;
                if (abs($timestamp - $jsTimestamp) < 450) {
                    //7 1/2 minutes
                    $potentialTimeZones[] = $timeZone;
                }
            }
            //$debug->printArray($allTimeZones,'$allTimeZones');
            //$debug->printArray($potentialTimeZones,'$potentialTimeZones');
            //If the user is logged in, select their current timezone.
            if (!empty($_SESSION['userId'])) {
                $checkStmt = $Dbc->prepare("SELECT\n\ttimeZone AS 'timeZone'\nFROM\n\tuserSiteSettings\nWHERE\n\tuserId = ?");
                $checkStmt->execute(array($_SESSION['userId']));
                $row = $checkStmt->fetch(PDO::FETCH_ASSOC);
                $selectedTimeZone = $row['timeZone'];
            } else {
                $selectedTimeZone = '';
            }
            $output .= '<div class="ui-field-contain">';
            $output .= '<label for="timeZoneSelect" class="select">' . $label . '</label>
<select name="timeZoneSelect" id="timeZoneSelect" data-mini="false" data-inline="true">';
            foreach ($potentialTimeZones as $timeZone) {
                $output .= '<option value="' . $timeZone . '"';
                if ($selectedTimeZone && $timeZone == $selectedTimeZone) {
                    $output .= ' selected="selected"';
                } elseif ($timeZone == 'America/Los_Angeles') {
                    $output .= ' selected="selected"';
                }
                $output .= '>' . Adrlist_Time::timeZoneDisplay($timeZone) . '</option>';
            }
            $output .= '</select>
</div>';
            $success = true;
            $returnThis['timeZones'] = $output;
        } catch (Adrlist_CustomException $e) {
        } catch (PDOException $e) {
            error(__LINE__, '', '<pre>' . $e . '</pre>');
        }
        if (MODE == 'buildTimeZones') {
            returnData();
        } else {
            return $output;
        }
    }
Example #15
0
function saveSettings()
{
    //Save the user's settings.
    global $debug, $message, $success, $Dbc, $returnThis;
    $output = '';
    try {
        if (empty($_POST['timeZone'])) {
            throw new Adrlist_CustomException('', '$_POST[\'timeZone\'] is empty.');
        } elseif (empty($_POST['dateFormat'])) {
            throw new Adrlist_CustomException('', '$_POST[\'dateFormat\'] is empty.');
        } elseif (!isset($_POST['viewListOnLogin'])) {
            throw new Adrlist_CustomException('', '$_POST[\'viewListOnLogin\'] is not set.');
        } elseif (!isset($_POST['defaultShowCharacterColors'])) {
            throw new Adrlist_CustomException('', '$_POST[\'defaultShowCharacterColors\'] is not set.');
        }
        $debug->add('$_POST[\'dateFormat\']: ' . $_POST['dateFormat'] . '<br>
$_POST[\'viewListOnLogin\']: ' . $_POST['viewListOnLogin'] . '<br>
$_POST[\'defaultShowCharacterColors\']: ' . $_POST['defaultShowCharacterColors']);
        //Get the dateFormat.
        $dateFormatArray = Adrlist_Time::getDateFormats();
        list($dateFormat, $example) = $dateFormatArray[$_POST['dateFormat']];
        $_SESSION['dateFormat'] = $dateFormat;
        $viewListOnLogin = $_POST['viewListOnLogin'] === 'true' ? 1 : 0;
        $defaultShowCharacterColors = $_POST['defaultShowCharacterColors'] === 'true' ? 1 : 0;
        $debug->add('viewListOnLogin: '******'<br>
defaultShowCharacterColors: ' . "{$defaultShowCharacterColors}.");
        $stmt = $Dbc->prepare("UPDATE\n\tuserSiteSettings\nSET\n\ttimeZone = ?,\n\tdateFormatId = ?,\n\tviewListOnLogin = ?,\n\tdefaultShowCharacterColors = ?\nWHERE\n\tuserSiteSettings.userId = ?");
        $params = array($_POST['timeZone'], $_POST['dateFormat'], $viewListOnLogin, $defaultShowCharacterColors, $_SESSION['userId']);
        $stmt->execute($params);
        $message .= 'Saved Settings';
        $success = MODE == 'saveSettings' ? true : $success;
        //It's okay if no lines were updated by these queries.
    } catch (Adrlist_CustomException $e) {
    } catch (PDOException $e) {
        error(__LINE__, '', '<pre>' . $e . '</pre>');
    }
    if (MODE == 'saveSettings') {
        returnData();
    }
}
function undeleteLine()
{
    global $debug, $message, $success, $Dbc, $returnThis;
    $output = '';
    try {
        if (!isset($_SESSION['listRoleId']) || $_SESSION['listRoleId'] < 2) {
            throw new Adrlist_CustomException("Your role doesn't allow you to edit this list.", '');
        } elseif (empty($_POST['lineId'])) {
            throw new Adrlist_CustomException('', 'lineId is empty.');
        } elseif (empty($_POST['charId'])) {
            throw new Adrlist_CustomException('', 'charName is empty.');
        }
        $Dbc->beginTransaction();
        $updateDeletedLinesStmt = $Dbc->prepare("UPDATE\n\tlinesTable\nSET\n\tlinesTable.dId = NULL,\n\tlinesTable.deleted = NULL\nWHERE\n\tlinesTable.lineId = ?");
        $updateDeletedLinesStmt->execute(array(intThis($_POST['lineId'])));
        $updateDeletedCharactersStmt = $Dbc->prepare("UPDATE\n\tcharacters\nSET\n\tcharacters.dId = NULL,\n\tcharacters.deleted = NULL\nWHERE\n\tcharacters.charId = ?");
        $updateDeletedCharactersStmt->execute(array(intThis($_POST['charId'])));
        $Dbc->commit();
        updateListHist($_SESSION['listId']);
        if (MODE == 'undeleteLine') {
            $success = true;
            $returnThis['buildLines'] = buildLines();
        }
    } catch (Adrlist_CustomException $e) {
    } catch (PDOException $e) {
        error(__LINE__, '', '<pre>' . $e . '</pre>');
    }
    if (MODE == 'undeleteLine') {
        returnData();
    }
}
Example #17
0
/**
 *
 */
function printFormat($format, $formatedRecords, $arrayRecordsFacic, $arrayRecordsHolding)
{
    global $BVS_LANG;
    if ($arrayRecords[0][1002]) {
        $totalRecordsReturned = $arrayRecords[0][1002];
    } else {
        $totalRecordsReturned = 0;
    }
    $content = "";
    switch ($format) {
        case 'titCurrColect':
            $allDataTitle = returnData($formatedRecords, $totalRecordsReturned, $results, $startIndex, $sort, $dir, $sort_dir);
            $allDataFacic = returnData($arrayRecordsFacic, $totalRecordsReturned, $results, $startIndex, $sort, $dir, $sort_dir);
            foreach ($allDataFacic[records] as $keyFacic => $valueFacic) {
                foreach ($allDataTitle[records] as $key => $value) {
                    if ($valueFacic[1] == $value[30]) {
                        if ($value[30]) {
                            $content .= "<div class='reportLeft'>[" . $value[30] . "] ";
                        }
                        if ($value[100]) {
                            $content .= $value[100] . " ";
                        }
                        if ($value[110]) {
                            $content .= $value[110] . " ";
                        }
                        if ($value[120]) {
                            $content .= $value[120] . " ";
                        }
                        if ($value[400]) {
                            $content .= "(" . $value[400] . ") </div>";
                        }
                        $content .= "<div class='reportRight'>" . $BVS_LANG['lblColection'] . ": " . $valueFacic[970] . " " . $BVS_LANG['lblTotalOf'] . " " . $valueFacic[999] . " " . $BVS_LANG['lblFacic'] . "</div>";
                    }
                }
            }
            break;
        case 'titWCurrColect':
            $allDataTitle = returnData($formatedRecords, $totalRecordsReturned, $results, $startIndex, $sort, $dir, $sort_dir);
            foreach ($allDataTitle[records] as $key => $value) {
                if ($value[30]) {
                    $content .= "[" . $value[30] . "] ";
                }
                if ($value[100]) {
                    $content .= $value[100] . " ";
                }
                if ($value[110]) {
                    $content .= $value[110] . " ";
                }
                if ($value[120]) {
                    $content .= $value[120] . " ";
                }
                if ($value[400]) {
                    $content .= "(" . $value[400] . ") ";
                }
                $content .= "<br/>";
            }
            break;
        case 'titFinishColect':
            $allDataTitle = returnData($formatedRecords, $totalRecordsReturned, $results, $startIndex, $sort, $dir, $sort_dir);
            $allDataFacic = returnData($arrayRecordsFacic, $totalRecordsReturned, $results, $startIndex, $sort, $dir, $sort_dir);
            foreach ($allDataFacic[records] as $keyFacic => $valueFacic) {
                foreach ($allDataTitle[records] as $key => $value) {
                    if ($valueFacic[1] == $value[30]) {
                        if ($value[30]) {
                            $content .= "<div class='reportLeft'>[" . $value[30] . "] ";
                        }
                        if ($value[100]) {
                            $content .= $value[100] . " ";
                        }
                        if ($value[110]) {
                            $content .= $value[110] . " ";
                        }
                        if ($value[120]) {
                            $content .= $value[120] . " ";
                        }
                        if ($value[400]) {
                            $content .= "(" . $value[400] . ") </div>";
                        }
                        $content .= "<div class='reportRight'>" . $BVS_LANG['lblColection'] . ": " . $valueFacic[970] . " " . $BVS_LANG['lblTotalOf'] . " " . $valueFacic[999] . " " . $BVS_LANG['lblFacic'] . "</div>";
                    }
                }
            }
            break;
        case 'titWithoutColect':
            $allDataTitle = returnData($formatedRecords, $totalRecordsReturned, $results, $startIndex, $sort, $dir, $sort_dir);
            foreach ($allDataTitle[records] as $key => $value) {
                if ($value[30]) {
                    $content .= "[" . $value[30] . "] ";
                }
                if ($value[100]) {
                    $content .= $value[100] . " ";
                }
                if ($value[110]) {
                    $content .= $value[110] . " ";
                }
                if ($value[120]) {
                    $content .= $value[120] . " ";
                }
                if ($value[400]) {
                    $content .= "(" . $value[400] . ") ";
                }
                $content .= "<br/>";
            }
            break;
    }
    if (empty($content)) {
        print $BVS_LANG["lblReportEmpty"];
    }
    print $content;
}
function parseReturnUrl()
{
    /*
    The user has authorized recurring payments at Amazon. Parse the url returned from Amazon CBUI. This will validate that the return Url came from Amazon. There are several checks performed here:
    1. The return url must have a query string with the following parameters:
    	tokenID
    	signatureMethod
    	status
    	signatureVersion
    	signature
    	certificateUrl
    	expiry
    	callerReference
    2. The signature of the returnUrl must be verified.
    3. The callerReference is a foreign key in the database. If it doesn't match existing records, this function will fail.
    We will check the tokenId and callerReference fields against the database to see if an entry with matching values already exists.
    Be aware that if this function is called via AJAX the query string will have to be passed via javascript.
    
    After validating the return url we make a pay request.
    */
    global $debug, $message, $success, $Dbc, $returnThis;
    try {
        $messageCenter = new Adrlist_MessageCenter();
        $success = MODE == 'parseReturnUrl' ? true : $success;
        //We set success to true here because a failure below will change it to false.
        $errorMessage = 'We were unable to get a proper response from the payment processor.  No payments or charges have been made. Please return to <a href="' . LINKMYACCOUNT . '">My Account</a> and try again.<br>
<br>
If the problem persists please <a href="' . LINKSUPPORT . '">contact support</a>.';
        if (empty($_POST['returnUrl'])) {
            throw new Adrlist_CustomException($errorMessage, '$_POST[\'returnUrl\'] is empty.');
        } else {
            $goodStatusCodes = array('SA' => 'Success status for the ABT payment method.', 'SB' => 'Success status for the ACH (bank account) payment method.', 'SC' => 'Success status for the credit card payment method.');
            $badStatusCodes = array('SE' => 'System error.', 'A' => 'Buyer abandoned the pipeline.', 'CE' => 'Specifies a caller exception.', 'PE' => 'Payment Method Mismatch Error: Specifies that the buyer does not have payment method that you have requested.', 'NP' => 'There are four cases where the NP status is returned:
1. The payment instruction installation was not allowed on the sender\'s account, because the sender\'s email account is not verified
2. The sender and the recipient are the same
3. The recipient account is a personal account, and therefore cannot
accept credit card payments
4. A user error occurred because the pipeline was cancelled and then
restarted', 'NM' => 'You are not registered as a third-party caller to make this transaction. Contact Amazon Payments for more information.');
            $urlParts = parse_url($_POST['returnUrl']);
            $debug->printArray($urlParts, '$urlParts');
            parse_str($urlParts['query'], $queryArray);
            //Convert the url parameters into an associative array.
            $debug->printArray($queryArray, '$queryArray');
            if (empty($queryArray['callerReference'])) {
                throw new Adrlist_CustomException($errorMessage, '$queryArray[\'callerReference\'] is empty.');
            }
            $utils = new Amazon_IpnReturnUrlValidation_SignatureUtilsForOutbound();
            $validate = $utils->validateRequest($queryArray, AUTOLINK . $_SERVER['PHP_SELF'], "GET");
            if ($validate !== true) {
                //Verify the signature of the payment processor.
                throw new Adrlist_CustomException($errorMessage, 'Could not validate the signature of the payment processor for the return url. This is probably due to an error with the url parameters.');
            } elseif (empty($urlParts['query'])) {
                //We must have a query from the url.
                throw new Adrlist_CustomException($errorMessage, 'There was no query string returned from the payment processor.');
            } elseif (empty($queryArray['callerReference']) || !preg_match("/^\\d+\$/", $queryArray['callerReference'])) {
                //Check the query for callerReference. Check callerReference against a regular expression.
                throw new Adrlist_CustomException($errorMessage, 'There was a problem with $queryArray[\'callerReference\']: ' . $queryArray['callerReference']);
            } elseif (!array_key_exists($queryArray['status'], $goodStatusCodes)) {
                throw new Adrlist_CustomException($errorMessage, 'No good status codes were returned. ' . $queryArray['status'] . ': ' . $badStatusCodes[$queryArray['status']]);
            } else {
                //Get the billingOfferId.
                $billingOfferStmt = $Dbc->prepare("SELECT\n\tbillingOfferId AS 'billingOfferId'\nFROM\n\tuserBillingActions\nWHERE\n\tuserBillingActions.userBillingActionId = ?");
                $billingOfferStmt->execute(array($queryArray['callerReference']));
                $billingOfferRow = $billingOfferStmt->fetch(PDO::FETCH_ASSOC);
                if (empty($billingOfferRow)) {
                    throw new Adrlist_CustomException($errorMessage, 'No billingOfferId was returned. $queryArray[\'status\']: ' . $queryArray['status']);
                }
                //Add a billing action. The recurring payment authorization was successful.
                $userBillingActionId = Adrlist_Billing::addBillingAction($_SESSION['userId'], $billingOfferRow['billingOfferId'], 2, 1, __FILE__ . ' ' . __LINE__);
                //See if the request has already been inserted.
                $responseCheckStmt = $Dbc->prepare("SELECT\n\tamazonCBUIResponseId AS 'amazonCBUIResponseId'\nFROM\n\tamazonCBUIResponses\nWHERE\n\tcallerReference = ? AND\n\ttokenId = ?");
                $responseCheckStmt->execute(array($queryArray['callerReference'], $queryArray['tokenID']));
                $responseRow = $responseCheckStmt->fetch(PDO::FETCH_ASSOC);
                if (empty($responseRow)) {
                    //There is no matching response, so insert the new response to the database.
                    //Convert expiry to Mysql date (YYYY-MM-DD) format. Both the original format and the converted format will be stored in the database.
                    $expiryParts = explode('/', $queryArray['expiry']);
                    if (preg_match('/\\d{2}/', $expiryParts[0]) && preg_match('/\\d{4}/', $expiryParts[1])) {
                        $expiryDatetime = $expiryParts[1] . '-' . $expiryParts[0] . '-01';
                    } else {
                        $expiryDatetime = '0000-00-00';
                    }
                    $amazonCBUIResponseStmt = "INSERT INTO\n\tamazonCBUIResponses\nSET\n\tuserBillingActionId = ?,\n\tcallerReference = ?,\n\tcertificateUrl = ?,\n\taDatetime = ?,\n\texpiry = ?,\n\texpiryDate = ?,\n\tfullUrl = ?,\n\tsignature = ?,\n\tsignatureMethod = ?,\n\tsignatureVersion = ?,\n\taStatus = ?,\n\ttokenId = ?";
                    $amazonCBUIResponseParams = array($userBillingActionId, $queryArray['callerReference'], $queryArray['certificateUrl'], DATETIME, $queryArray['expiry'], $expiryDatetime, $_SERVER['REQUEST_URI'], $queryArray['signature'], $queryArray['signatureMethod'], $queryArray['signatureVersion'], $queryArray['status'], $queryArray['tokenID']);
                    $debug->add('$amazonCBUIResponseStmt: ' . $amazonCBUIResponseStmt);
                    $debug->printArray($amazonCBUIResponseParams, '$amazonCBUIResponseParams');
                    $amazonCBUIResponseStmt = $Dbc->prepare($amazonCBUIResponseStmt);
                    $amazonCBUIResponseStmt->execute($amazonCBUIResponseParams);
                }
                //Make a payment request.
                if (Adrlist_Billing::amazonPayRequest($queryArray['callerReference']) !== true) {
                    $success = false;
                    throw new Adrlist_CustomException('', 'Adrlist_Billing::amazonPayRequest returned false.');
                }
                $returnThis['successUrl'] = LINKMYACCOUNT;
            }
        }
    } catch (Adrlist_CustomException $e) {
        $success = false;
        $debug->add('<pre>' . $e . '</pre>');
        error(__LINE__, ' ', '');
        $messageCenter->newMessage(1, 1, 'Problem with Amazon Payments transaction', '', $debug->output());
    } catch (PDOException $e) {
        $success = false;
        $debug->add('<pre>' . $e . '</pre>');
        error(__LINE__, '', '');
        $messageCenter->newMessage(1, 1, 'Problem with Amazon Payments transaction', '', $debug->output());
    }
    if (MODE == 'parseReturnUrl') {
        $debug->add('$success: ' . $success);
        returnData();
    }
}
Example #19
0
    $startIndex = $_GET['startIndex'];
}
// Sorted?
if (strlen($_GET['sort']) > 0) {
    $sort = $_GET['sort'];
}
// Sort dir?
if (strlen($_GET['dir']) > 0 && $_GET['dir'] == 'desc') {
    $dir = 'desc';
    $sort_dir = SORT_DESC;
} else {
    $dir = 'asc';
    $sort_dir = SORT_ASC;
}
// Return the data
returnData($total, $results, $startIndex, $sort, $dir, $sort_dir);
function returnData($total, $results, $startIndex, $sort, $dir, $sort_dir)
{
    // All records
    $allRecords = initArray($total);
    // Need to sort records
    if (!is_null($sort)) {
        // Obtain a list of columns
        foreach ($allRecords as $key => $row) {
            $sortByCol[$key] = $row[$sort];
        }
        // Valid sort value
        if (count($sortByCol) > 0) {
            // Sort the original data
            // Add $allRecords as the last parameter, to sort by the common key
            array_multisort($sortByCol, $sort_dir, $allRecords);
function buildAmazonBilling()
{
    global $debug, $message, $success, $Dbc, $returnThis;
    $output = '';
    try {
        //See if the user has an account.
        $accountCheckCountStmt = "SELECT\n\tCOUNT(*) AS 'count'\nFROM\n\tbillingOffers\nJOIN\n\tuserBilling ON userBilling.billingOfferId = billingOffers.billingOfferId\nJOIN\n\tusers ON users.userId = userBilling.userId\nWHERE\n\tbillingOffers.renewable = 1";
        $accountCheckStmt = "SELECT\n\tuserBilling.userId AS 'userId',\n\t(SELECT CONCAT_WS(' ', users.firstName, users.lastName)) as 'userName',\n\tbillingOffers.billingOfferId AS 'billingOfferId',\n\tbillingOffers.offerName AS 'planName',\n\tbillingOffers.period AS 'period',\n\tuserBilling.dateAdded AS 'dateAdded'\nFROM\n\tbillingOffers\nJOIN\n\tuserBilling ON userBilling.billingOfferId = billingOffers.billingOfferId\nJOIN\n\tusers ON users.userId = userBilling.userId\nWHERE\n\tbillingOffers.renewable = 1";
        if (empty($_POST['searchVal'])) {
            $search = false;
            $accountCheckParams = array();
            $accountCheckCountStmt = $Dbc->prepare($accountCheckCountStmt);
        } else {
            $search = true;
            $searchVal = '%' . trim($_POST['searchVal']) . '%';
            $debug->add('$searchval: ' . $searchVal);
            $endStmt = " AND\n\t(users.firstName LIKE ? || users.lastName LIKE ? || billingOffers.offerName LIKE ?)\n";
            $accountCheckStmt .= $endStmt;
            $accountCheckParams = array($searchVal, $searchVal, $searchVal);
            $accountCheckCountStmt = $Dbc->prepare($accountCheckCountStmt . $endStmt);
        }
        $accountCheckCountStmt->execute($accountCheckParams);
        $count = $accountCheckCountStmt->fetch(PDO::FETCH_ASSOC);
        $itemCount = $count['count'];
        $pagination = new Adrlist_Pagination('buildAmazonBilling', 'buildAmazonBilling', $itemCount, 'Search Billing', $search);
        list($offset, $limit) = $pagination->offsetLimit();
        $accountCheckStmt .= "\nLIMIT {$offset}, {$limit}";
        $accountCheckStmt = $Dbc->prepare($accountCheckStmt);
        $accountCheckStmt->execute($accountCheckParams);
        $userPlans = array();
        $foundRows = false;
        while ($row = $accountCheckStmt->fetch(PDO::FETCH_ASSOC)) {
            $foundRows = true;
            //Add the question to the user's support section.
            if ($row['period'] == 'month') {
                $date = Adrlist_Time::addToDate($row['dateAdded'], $row['period'], 1);
                $row[] = $date = $date->format('Y-m-d');
            } elseif ($row['period'] == 'year') {
                $date = Adrlist_Time::addToDate($row['dateAdded'], $row['period'], 1);
                $row[] = $date = $date->format('Y-m-d');
            }
            $userPlans[] = $row;
        }
        $cssWidths = array(3, 20, 10, 20, 5, 20, 20);
        $titleRowArray = array('userId', 'User', 'billingOfferId', 'Plan Name', 'Period', 'Date Added', 'Next Billing Date');
        $buildRows = new Adrlist_BuildRows($titleRowArray, $userPlans, $cssWidths);
        $output .= '<div>
	<input type="text" style="width:20em" id="billingDate"> Date <span class="buttonBlueThin" id="addMonth">Add a Month</span> <input type="text" id="dateDestination">
</div>' . $pagination->output();
        $output .= $foundRows ? $buildRows->output() : '<div class="textCenter" style="margin:1em">No records were found.</div>';
        if (MODE == 'buildAmazonBilling') {
            $success = true;
            $returnThis['holder'] = 'amazonBillingHolder';
            $returnThis['output'] = $output;
        }
    } catch (PDOException $e) {
        error(__LINE__, '', '<pre>' . $e . '</pre>');
    }
    if (MODE == 'buildAmazonBilling') {
        returnData();
    } else {
        return $output;
    }
}
Example #21
0
function buildPdtErrors()
{
    global $debug, $message, $success, $Dbc;
    $output = '';
    try {
        $pdtErrorQueryStart = "SELECT\n\tpdtErrorId AS pdtErrorId,\n\ttime AS 'time',\n\terrorMessage AS 'error'\nFROM\n\tpdtError";
        if (isset($_POST['searchVal']) && !empty($_POST['searchVal'])) {
            $search = true;
            $searchVal = '%' . trim($_POST['searchVal']) . '%';
            $debug->add('$searchVal: ' . "{$searchVal}.");
            $pdtErrorQuery = $pdtErrorQueryStart . "\nWHERE\n\tpdtErrorId LIKE ?\nORDER BY\n\tpdtErrorId DESC";
            $pdtErrorStmt = $Dbc->prepare($pdtErrorQuery);
            $pdtErrorParams = array($searchVal);
            $pdtErrorStmt->execute($pdtErrorParams);
        } else {
            $search = false;
            $searchVal = '';
            $pdtErrorQuery = $pdtErrorQueryStart . "\nORDER BY\n\tpdtErrorId DESC";
            $pdtErrorStmt = $Dbc->prepare($pdtErrorQuery);
            $pdtErrorStmt->execute();
        }
        $class = 'rowAlt';
        $foundRows = false;
        $content = '';
        while ($row = $pdtErrorStmt->fetch(PDO::FETCH_ASSOC)) {
            $pdtErrorId = $row['ipnId'];
            if ($class == 'rowWhite') {
                $class = 'rowAlt';
            } else {
                $class = 'rowWhite';
            }
            $time = Adrlist_Time::utcToLocal($row['time']);
            $output .= '
		<div class="break ' . $class . '">
			<div class="absolute" style="line-height:.9em;right:8px">
				<div class="textRight textXsmall">PDT Id: ' . $row[pdtErrorId] . '</div>
				<div class="textRight textSmall">' . $time . '</div>
			</div>
			<div class="row textSmall" style="width:60px">' . $row['tx'] . '</div>
			<div class="textLeft">' . $row['error'] . '</div>
		</div>';
        }
        $success = true;
        $returnThis['returnCode'] = $output;
        if ($foundRows) {
            $output .= '<div class="rowTitle" style="width:60px">tx</div>
			<div class="rowTitle" style="width:300px">Actions</div>' . $content;
        } else {
            $output .= '<div class="break">No PDT errors found.</div>';
        }
        $success = true;
        $returnThis['buildPdtErrors'] = $output;
    } catch (PDOException $e) {
        error(__LINE__, '', '<pre>' . $e . '</pre>');
        if (MODE == 'buildPdt') {
            returnData();
        }
    }
    if (MODE == 'buildPdt') {
        returnData();
    } else {
        return $output;
    }
}
Example #22
0
function modifyTopic()
{
    global $debug, $message, $success, $Dbc, $returnThis;
    $output = '';
    if (empty($_POST['topic'])) {
        $message .= 'Please enter a topic.';
    } else {
        try {
            $stmt = $Dbc->prepare("UPDATE\n\tfaqTopics\nSET\n\tfaqTopics.topic = ?\nWHERE\n\tfaqTopics.topicId = ?\nLIMIT 1");
            $stmt->execute(array($_POST['topic'], $_POST['topicId']));
            $stmt = $Dbc->prepare("SELECT\n\tfaqTopics.topic AS 'newTopic'\nFROM\n\tfaqTopics\nWHERE\n\tfaqTopics.topicId = ?");
            $stmt->execute(array($_POST['topicId']));
            $message .= 'Saved';
            $success = MODE == 'modifyTopic' ? true : $success;
            $returnThis['buildFaqs'] = buildFaqs();
        } catch (PDOException $e) {
            error(__LINE__, '', '<pre>' . $e . '</pre>');
        }
    }
    if (MODE == 'modifyTopic') {
        returnData();
    }
}
                }
            }
            $data["length"] = count($_SESSION["shopping-cart"]);
            $data["success"] = "true";
            $data["totalprice"] = getCartTotalPrice($_SESSION["shopping-cart"], $dbconnection);
        }
        if ($action == "update") {
            $total = getCartTotalPrice($_SESSION["shopping-cart"], $dbconnection);
            if ($total > 0) {
            }
        }
        if ($action == "empty") {
            unset($_SESSION["shopping-cart"]);
            $data["success"] = "true";
        }
        returnData($data, $errors);
    }
}
//function to return data request as JSON
function returnData($data, $errors)
{
    if (count($errors) > 0) {
        $data["error"] = $errors;
    }
    echo json_encode($data);
}
function updateCartQuantity($cartid, $requestid, $index)
{
    if ($cartid == $requestid) {
        //update only the quantity instead of creating duplicate
        //items in the shopping cart
Example #24
0
function supportSend()
{
    //Disabled the recaptcha 2014-03-09.
    global $debug, $message, $success, $Dbc, $returnThis;
    $output = '';
    try {
        $emailValidate = emailValidate($_POST['supportEmail']);
        if (empty($_POST['supportName'])) {
            throw new Adrlist_CustomException('', '$_POST[\'supportName\'] is empty.');
        } elseif ($emailValidate === false) {
            throw new Adrlist_CustomException('', '$_POST[\'supportEmail\'] is not valid.');
        } elseif (empty($_POST['supportMessage'])) {
            throw new Adrlist_CustomException('', '$_POST[\'supportMessage\'] is empty.');
        }
        /*elseif(empty($_POST['recaptcha_challenge_field'])){
        			throw new Adrlist_CustomException('','$_POST[\'recaptcha_challenge_field\'] is empty.');
        		}elseif(empty($_POST['recaptcha_response_field'])){
        			throw new Adrlist_CustomException('','$_POST[\'recaptcha_response_field\'] is empty.');
        		}
        		$resp = recaptcha_check_answer(RECAPTCHAPRIVATEKEY, $_SERVER["REMOTE_ADDR"], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field']);
        		if($resp->is_valid || LOCAL){
        			$debug->add('The recaptcha response is valid.');*/
        //See if the user has an account.
        $accountCheckStmt = $Dbc->prepare("SELECT\n\tuserId AS 'userId'\nFROM\n\tusers\nWHERE\n\tprimaryEmail = ? OR\n\tsecondaryEmail = ?");
        $accountCheckStmt->execute(array($_POST['supportEmail'], $_POST['supportEmail']));
        if ($row = $accountCheckStmt->fetch(PDO::FETCH_ASSOC)) {
            //Add the question to the user's support section.
            $newMessage = new Adrlist_MessageCenter();
            $message .= 'Thank you for contacting us!<br>
<br>
Your message has been received. A response will be sent to the message center.';
            $newMessage->newMessage($row['userId'], 1, 'A message sent from the contact page', $_POST['supportMessage']);
        } else {
            //Send the message.
            $subject = $_POST['supportName'] . ' sent a message to support at ' . THENAMEOFTHESITE . '.';
            $bodyText = 'From: ' . $_POST['supportName'] . ' (' . $_POST['supportEmail'] . ')
Sent on: ' . Adrlist_Time::utcToLocal(false, false)->format('F d, Y H:i:s') . '.';
            $bodyHtml = 'From: ' . $_POST['supportName'] . ' (' . $_POST['supportEmail'] . ')<br>
Sent on: ' . Adrlist_Time::utcToLocal(false, false)->format('F d, Y H:i:s') . '<br>
Mesage:<br>
' . nl2br($_POST['supportMessage']);
            //$fromAddress,$toAddress,$subject,$bodyHtml,$bodyText,$senderAddress = NULL,$returnAddress = NULL
            if (email($_POST['supportEmail'], EMAILSUPPORT, $subject, $bodyHtml, $bodyText, $_POST['supportEmail'])) {
                $message .= 'Thank you for contacting us! We will get back to you as soon as we can.';
                $success = true;
                $debug->add('used the function email(' . $_POST['supportEmail'] . ',' . EMAILSUPPORT . ',$subject,$bodyHtml,$bodyText,' . EMAILSUPPORT);
                $debug->add('$subject:' . $subject . '<br>
$bodyHtml:' . $bodyHtml . '<br>
$bodyText:' . $bodyText);
            } else {
                throw new Adrlist_CustomException('', 'There was a problem trying to send an email.');
            }
        }
        /*}else{
        			//Set the error code so that we can display it.
        			$message .= 'The reCAPTCHA wasn\'t entered correctly. Please enter the new reCAPTCHA.';
        			$debug->add('reCAPTCHA said: ' . $resp->error);
        		}*/
    } catch (PDOException $e) {
        error(__LINE__, '', '<pre>' . $e . '</pre>');
    }
    if (MODE == 'supportSend') {
        returnData();
    }
}
    ?>
" />
<input type="hidden" id="svcnotifenabled" name="svcnotifenabled" value="<?php 
    echo returnData($contactSvcNotifEn);
    ?>
" />
<input type="hidden" id="svcnotifperiod" name="svcnotifperiod" value="<?php 
    echo returnData($contactSvcNotifTime);
    ?>
" />
<input type="hidden" id="svcnotifopts" name="svcnotifopts[]" value="<?php 
    echo returnData($contactSvcNotifOpts);
    ?>
" />
<input type="hidden" id="svcnotifcmd" name="svcnotifcmd" value="<?php 
    echo returnData($contactSvcNotifCmd);
    ?>
" />
<?php 
}
?>
<div class="divCacGroup"><!-- 5 Pixel Spacer --></div>
<div class="divCacGroup admin_box_blue" style="width:6%;">
    <input type="submit" value="Submit" style="font-size:14px;padding:5px;" />
</div>
</form>
</div>
<?php 
function returnData($payload)
{
    if (is_array($payload)) {
Example #26
0
function buildListMaint()
{
    /*
    	Find errors in the database:
    1. Lines missing listId, charId, and/or cId.
    2. Folders or lists with more than one owner or no owner.
    3. Verify that all users of lists inside folders have a folderRoleId.
    4. Verify that all users of lists inside folders have a userSiteSettings.
    */
    global $debug, $message, $success, $Dbc, $returnThis;
    $output = '';
    try {
        //Check for lines missing listId, charId, and/or cId.
        $badLinesCountStmt = $Dbc->query("SELECT\n\tCOUNT(*) AS 'count'\nFROM\n\tlinesTable\nWHERE\n\tlistId = '' OR\n\tlistId IS NULL OR\n\tcharId = '' OR\n\tcharId IS NULL OR\n\tcId = '' OR\n\tcId IS NULL");
        $badLinesCountStmt->execute();
        $badLinesCount = $badLinesCountStmt->fetch(PDO::FETCH_ASSOC);
        $badLinesCount = $badLinesCount['count'];
        $badLinesPagination = new Adrlist_Pagination('buildListMaint', 'badLines', $badLinesCount);
        list($offset, $limit) = $badLinesPagination->offsetLimit();
        $checkLinesStmt = $Dbc->query("SELECT\n\tlinesTable.lineId AS 'lineId',\n\tlinesTable.listId AS 'listId',\n\tlists.listName AS 'listName',\n\tlinesTable.charId AS 'charId',\n\tlinesTable.cId AS 'cId',\n\tlinesTable.line AS 'line'\nFROM\n\tlinesTable\nLEFT JOIN\n\tlists ON lists.listId = linesTable.listId\nWHERE\n\tlinesTable.listId = '' OR\n\tlinesTable.listId IS NULL OR\n\tlinesTable.charId = '' OR\n\tlinesTable.charId IS NULL OR\n\tlinesTable.cId = '' OR\n\tlinesTable.cId IS NULL\nLIMIT {$offset}, {$limit}");
        $checkLinesStmt->execute();
        $badLines = array();
        $foundBadLines = false;
        while ($row = $checkLinesStmt->fetch(PDO::FETCH_ASSOC)) {
            $badLines[] = $row;
            $foundBadLines = true;
        }
        //$debug->printArray($badLines,'$badLines');
        //Verify all lists have one owner.
        $multipleListOwnersCountStmt = $Dbc->query("SELECT\n\tCOUNT(*) AS 'count'\nFROM\n\tlists\nJOIN\n\t(userListSettings JOIN users ON userListSettings.userId = users.userId) ON lists.listId = userListSettings.listId AND\n\tuserListSettings.listRoleId = 4 AND\n\tlists.listId IN (SELECT listId FROM userListSettings WHERE listRoleId = 4 GROUP BY listId HAVING COUNT(userId)>1)");
        $multipleListOwnersCountStmt->execute();
        $multipleListOwnersCount = $multipleListOwnersCountStmt->fetch(PDO::FETCH_ASSOC);
        $multipleListOwnersCount = $multipleListOwnersCount['count'];
        $mulitpleListOwnersPagination = new Adrlist_Pagination('buildListMaint', 'multipleListOwners', $multipleListOwnersCount);
        list($offset, $limit) = $mulitpleListOwnersPagination->offsetLimit();
        $multipleListOwnersStmt = $Dbc->query("SELECT\n\tlists.listId AS 'listId',\n\tlists.listName AS 'listName',\n\tlists.cId AS 'cId',\n\tusers.userId AS 'userId',\n\tprimaryEmail AS 'primaryEmail',\n\tCONCAT_WS(' ', users.firstName, users.lastName) AS 'userName'\nFROM\n\tlists\nJOIN\n\t(userListSettings JOIN users ON userListSettings.userId = users.userId) ON lists.listId = userListSettings.listId AND\n\tuserListSettings.listRoleId = 4 AND\n\tlists.listId IN (SELECT listId FROM userListSettings WHERE listRoleId = 4 GROUP BY listId HAVING COUNT(userId)>1)\nORDER BY\n\tlists.listId ASC\nLIMIT {$offset}, {$limit}");
        $multipleListOwnersStmt->execute();
        $listOwners = array();
        $foundMultipleListOwners = false;
        while ($row = $multipleListOwnersStmt->fetch(PDO::FETCH_ASSOC)) {
            $multipleListOwners[] = $row;
            $foundMultipleListOwners = true;
        }
        //$debug->printArray($listOwners,'$listOwners');
        if ($foundBadLines) {
            $badLinesTitleArray = array(array('lineId'), array('listId'), array('List Name'), array('charId'), array('cId'), array('line'));
            $buildBadLines = new Adrlist_BuildRows('badLines', $badLinesTitleArray, $badLines);
            $badLinesOutput = $badLinesPagination->output() . $buildBadLines->output();
        } else {
            $badLinesOutput = '<div class="break textCenter">
	All lines are good.
</div>';
        }
        if ($foundMultipleListOwners) {
            $multipleListOwnersTitleArray = array(array('listId'), array('List Name'), array('cId'), array('userId'), array('Email'), array('Name'));
            $multipleListOwnersBuildRows = new Adrlist_BuildRows('multipleOwners', $multipleListOwnersTitleArray, $multipleListOwners);
            $multipleOwnersOuput = $mulitpleListOwnersPagination->output() . $multipleListOwnersBuildRows->output();
        } else {
            $multipleOwnersOuput = '<div class="break textCenter">
	All lists have proper ownership.
</div>';
        }
        //Build the output.
        $output .= '<div class="bold textCenter textLarge">Bad Lines</div>
	' . $badLinesOutput . '
<div class="break" style="margin-top:2em">
	<div class="bold textCenter textLarge">Multiple List Owners</div>
	' . $multipleOwnersOuput . '
</div>';
        if (MODE == 'buildListMaint') {
            $success = true;
            $returnThis['holder'] = 'listMaintHolder';
            $returnThis['output'] = $output;
        }
    } catch (PDOException $e) {
        error(__LINE__, '', '<pre>' . $e . '</pre>');
    }
    if (MODE == 'buildListMaint') {
        returnData();
    } else {
        return $output;
    }
}
Example #27
0
/*
 * Copyright (c) 2006/2007 Flipperwing Ltd. (http://www.flipperwing.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
/**
 * @author andy.scholz@gmail.com
 * @copyright (c)2006-2007 Flipperwing Ltd.
 */
// Set flag that this is a parent file
define('_VALID_MOS', 1);
require_once "../../init.php";
require_once $csModelsDir . "/JUser.php";
$id = intval($_REQUEST['id']);
$obj = new JUser(&$database);
if (!$obj->load($id)) {
    returnError("Could not find user with id#{$id}");
}
returnData($obj);
function getOldLines()
{
    global $debug, $message, $Dbc;
    $success = false;
    $output = '';
    if (oldDB()) {
        $oldLines = array();
        $oldLinesSelect = "SELECT\n\tadr_lines.line_id AS 'lineId',\n\tadr_lines.list_id AS 'listId',\n\tadr_lines.character AS 'char',\n\tadr_lines.reel_number AS 'reel',\n\tadr_lines.scene_number AS 'scene',\n\tadr_lines.tc_in AS 'tcIn',\n\tadr_lines.tc_out AS 'tcOut',\n\tadr_lines.linesTable AS 'line',\n\tadr_lines.notes AS 'notes',\n\tadr_lists.list_name AS 'listName'\nFROM\n\tadr_lines\nJOIN\n\tadr_lists ON adr_lines.list_id = adr_lists.list_id";
        if ($result = mysql_query($oldLinesSelect)) {
            if (mysql_affected_rows() == 0) {
                $debug->add('Zero rows were affected by the query on line ' . __LINE__ . ": {$oldLinesSelect}.");
            } else {
                $debug->add('Entering loop.');
                while ($row = mysql_fetch_assoc($result)) {
                    $lineHistQuery = "SELECT\n\tadr_lines_history.status AS 'statusId',\n\tadr_lines_history.status_date AS 'statusDate',\n\tusers.user_id AS 'userId'\nFROM\n\tadr_lines_history\nJOIN\n\tusers ON users.user_id = adr_lines_history.user_id AND\n\tadr_lines_history.line_id = '" . $row['lineId'] . "'";
                    if ($result2 = mysql_query($lineHistQuery)) {
                        if (mysql_affected_rows() == 0) {
                            $debug->add('Zero rows were affected by the query on line ' . __LINE__ . ": {$lineHistQuery} on line.");
                        } else {
                            while ($row2 = mysql_fetch_assoc($result2)) {
                                if ($row2['statusId'] == 1) {
                                    $row['creatorId'] = $row2['userId'];
                                    $row['created'] = $row2['statusDate'];
                                } elseif ($row2['statusId'] == 2) {
                                    $row['modifierId'] = $row2['userId'];
                                    $row['modified'] = $row2['statusDate'];
                                } elseif ($row2['statusId'] == 3) {
                                    $row['deleterId'] = $row2['userId'];
                                    $row['deleted'] = $row2['statusDate'];
                                }
                            }
                        }
                    } else {
                        error(__LINE__);
                        $debug->add('There is an error with the query on line ' . __LINE__ . ": {$lineHistQuery}<br>\nThe error is: <span class=\"bold\">" . mysql_error() . '</span>');
                    }
                    $oldLines[] = $row;
                }
                mysql_close();
                $debug->add('Successfully retrieved old lines.');
                $x = 0;
                if ($Dbc) {
                    //Insert line info into new db.
                    foreach ($oldLines as $key => $value) {
                        $x++;
                        $insertLinesQuery = "INSERT INTO\n\tlinesTable\nSET\n\treel = '" . $value['reel'] . "',\n\tscene = '" . $value['scene'] . "',\n\ttcIn = '" . $value['tcIn'] . "',\n\ttcOut = '" . $value['tcOut'] . "',\n\tline = '" . mysqlSafe($value['line']) . "',\n\tnotes = '" . mysqlSafe($value['notes']) . "'";
                        if (mysql_query($insertLinesQuery)) {
                            if (mysql_affected_rows() == 0) {
                                die('Zero rows were affected by the query on line ' . __LINE__ . ": {$insertLinesQuery} <br>\n");
                            } else {
                                $lineId = mysql_insert_id();
                                //Insert line history info into new db.
                                //These lines will make sure values are created even if they weren't in the old list.
                                $value['creator'] = !isset($value['creator']) ? '1' : $value['creator'];
                                $value['created'] = !isset($value['created']) ? "'" . '2011-03-30 17:00:00' . "'" : "'" . $value['created'] . "'";
                                $value['modifierId'] = !isset($value['modifierId']) ? '1' : $value['modifierId'];
                                $value['modified'] = !isset($value['modified']) ? "'" . '2011-03-30 17:00:00' . "'" : "'" . $value['modified'] . "'";
                                $value['deleterId'] = !isset($value['deleterId']) ? '1' : $value['deleterId'];
                                $value['deleted'] = !isset($value['deleted']) ? 'NULL' : "'" . $value['deleted'] . "'";
                                $insertLineHistQuery = "INSERT INTO\n\tlineHist (lineId, userId, statusId, statusDate)\nVALUES\n\t('{$lineId}', '" . $value['creatorId'] . "', '1', " . $value['created'] . "),\n\t('{$lineId}', '" . $value['modifierId'] . "', '2', " . $value['modified'] . "),\n\t('{$lineId}', '" . $value['deleterId'] . "', '3', " . $value['deleted'] . ")";
                                if (mysql_query($insertLineHistQuery)) {
                                    if (mysql_affected_rows() == 0) {
                                        die('Zero rows were affected by the query on line ' . __LINE__ . ": {$insertLineHistQuery}<br>\n");
                                    } else {
                                        $lineListMapQuery = "INSERT INTO\n\tlineListMap\nSET\n\tlistId = '" . $value['listId'] . "',\n\tlineId = '{$lineId}'";
                                        if (mysql_query($lineListMapQuery)) {
                                            if (mysql_affected_rows() == 0) {
                                                die('Zero rows were affected by the query on line ' . __LINE__ . ": {$lineListMapQuery} <br>\n");
                                            } else {
                                                //Check to see if the char already exists.
                                                $charCheckQuery = "SELECT\n\tcharacters.charId AS 'charId'\nFROM\n\tcharacters\nWHERE\n\tcharacters.charFirstName = '" . mysqlSafe($value['char']) . "' AND\n\tcharacters.listId = '" . $value['listId'] . "'";
                                                if ($charCheckResult = mysql_query($charCheckQuery)) {
                                                    if (mysql_affected_rows() == 0) {
                                                        $debug->add('Zero rows were affected by the query on line ' . __LINE__ . ": {$charCheckQuery} ");
                                                        $insertCharQuery = "INSERT INTO\n\tcharacters\nSET\n\tlistId = '" . $value['listId'] . "',\n\tcharFirstName = '" . mysqlSafe($value['char']) . "'";
                                                        if (mysql_query($insertCharQuery)) {
                                                            if (mysql_affected_rows() == 0) {
                                                                die('Zero rows were affected by the query on line ' . __LINE__ . ": {$insertCharQuery} <br>\n");
                                                            } else {
                                                                $charId = mysql_insert_id();
                                                                //Create the char history.
                                                                $charHistQuery = "INSERT INTO\n\tcharHist (charId, userId, statusId, statusDate)\nVALUES\n\t('{$charId}', '" . $value['creatorId'] . "', '1', " . $value['created'] . "),\n\t('{$charId}', '" . $value['modifierId'] . "', '2', " . $value['modified'] . "),\n\t('{$charId}', '" . $value['deleterId'] . "', '3', " . $value['deleted'] . ")";
                                                                if (mysql_query($charHistQuery)) {
                                                                    if (mysql_affected_rows() == 0) {
                                                                        die('Zero rows were affected by the query on line ' . __LINE__ . ": {$charHistQuery} <br>\n");
                                                                    }
                                                                } else {
                                                                    error(__LINE__);
                                                                    die('There is an error with the query on line ' . __LINE__ . ": {$charHistQuery}<br>\nThe error is: <span class=\"bold\">" . mysql_error() . '</span><br>
');
                                                                }
                                                            }
                                                        } else {
                                                            error(__LINE__);
                                                            die('There is an error with the query on line ' . __LINE__ . ": {$insertCharQuery}<br>\nThe error is: <span class=\"bold\">" . mysql_error() . '</span><br>
');
                                                        }
                                                    } else {
                                                        $row3 = mysql_fetch_assoc($charCheckResult);
                                                        $charId = $row3['charId'];
                                                    }
                                                    //Create the character to line link.
                                                    $charLineMapQuery = "INSERT INTO\n\tcharLineMap\nSET\n\tcharId = '{$charId}',\n\tlineId = '{$lineId}'";
                                                    if (mysql_query($charLineMapQuery)) {
                                                        if (mysql_affected_rows() == 0) {
                                                            die('Zero rows were affected by the query on line ' . __LINE__ . ": {$charLineMapQuery} <br>\n");
                                                        } else {
                                                            $success = true;
                                                        }
                                                    } else {
                                                        error(__LINE__);
                                                        die('There is an error with the query on line ' . __LINE__ . ": {$charLineMapQuery}<br>\nThe error is: <span class=\"bold\">" . mysql_error() . '</span><br>
');
                                                    }
                                                } else {
                                                    error(__LINE__);
                                                    die('There is an error with the query on line ' . __LINE__ . ": {$charCheckQuery}<br>\nThe error is: <span class=\"bold\">" . mysql_error() . '</span><br>
');
                                                }
                                            }
                                        } else {
                                            error(__LINE__);
                                            die('There is an error with the query on line ' . __LINE__ . ": {$lineListMapQuery}<br>\nThe error is: <span class=\"bold\">" . mysql_error() . '</span><br>
');
                                        }
                                    }
                                } else {
                                    error(__LINE__);
                                    die('There is an error with the query on line ' . __LINE__ . ": {$insertLineHistQuery}<br>\nThe error is: <span class=\"bold\">" . mysql_error() . '</span><br>
');
                                }
                            }
                        } else {
                            error(__LINE__);
                            die('There is an error with the query on line ' . __LINE__ . ": {$insertLinesQuery}<br>\nThe error is: <span class=\"bold\">" . mysql_error() . '</span><br>
');
                        }
                    }
                }
                //$debug->printArray($oldLines,'$oldLines');
            }
        } else {
            error(__LINE__);
            $debug->add('There is an error with the query on line ' . __LINE__ . ": {$oldLinesSelect}<br>\nThe error is: <span class=\"bold\">" . mysql_error() . '</span>');
        }
    }
    returnData();
}
Example #29
0
function viewInvitations()
{
    global $debug, $message, $success;
    $output = '	<div class="textLeft" id="viewInvitationsReturn">';
    $class = 'rowAlt';
    $getInvitationsQuery = "SELECT\n\tfolders.folderName AS 'folderName',\n\tinvitations.invitationId AS 'invitationId',\n\tinvitations.folderRoleId AS 'folderRoleId',\n\tinvitations.email AS 'email',\n\tinvitations.listRoleId AS 'listRoleId',\n\tDATE_FORMAT(invitations.sentDate, '%b %e, %Y %l:%i %p') AS 'sentDate',\n\tDATE_FORMAT(invitations.responded, '%b %e, %Y %l:%i %p') AS 'responded',\n\tlists.listName AS 'listName'\nFROM\n\tinvitations\nLEFT JOIN\n\tlists ON lists.listId = invitations.listId\nJOIN\n\tfolders ON folders.folderId = invitations.folderId AND\n\tinvitations.senderId = '" . $_SESSION['userId'] . "'\nORDER BY\n\t(SELECT userSiteSettings.folderLinksOrderBy FROM userSiteSettings WHERE userSiteSettings.userId = '" . $_SESSION['userId'] . "')";
    if ($result = mysql_query($getInvitationsQuery)) {
        if (mysql_affected_rows() == 0) {
            $message .= 'You haven\'t sent any invitations.';
            pdoError(__LINE__, $getInvitationsQuery, '$getInvitationsQuery', 1);
        } else {
            $output .= '	<div class="break relative" style="width:100%">
		<div class="rowTitle" style="width:140px; padding-left:5px"><br>
Email</div>
		<div class="rowTitle" style="width:120px">Invited to Folder</div>
		<div class="rowTitle" style="width:80px">Folder Role</div>
		<div class="rowTitle" style="width:130px"><br>
Invited to ADR List</div>
		<div class="rowTitle" style="width:80px">List Role</div>
		<div class="rowTitle" style="width:110px"><br>
Sent</div>
		<div class="rowTitle" style="width:110px"><br>
Responded</div>
	</div>';
            while ($row = mysql_fetch_assoc($result)) {
                if ($class == 'rowWhite') {
                    $class = 'rowAlt';
                } else {
                    $class = 'rowWhite';
                }
                $responded = empty($row['responded']) ? 'No response' : $row['responded'];
                $listName = empty($row['listName']) ? '&nbsp;' : $row['listName'];
                $output .= '	<div class="break relative ' . $class . '">
		<div class="row" style="width:140px; padding-left:5px"><img alt="" class="left" height="16" id="deleteInvitation' . $row['invitationId'] . '" onClick="" src="' . LINKIMAGES . '/xRed.png" width="16"> ' . breakEmail($row['email'], 16) . '</div>
		<div class="row" style="width:120px">' . $row['folderName'] . '</div>
		<div class="row" style="width:80px;">' . roles($row['folderRoleId']) . '</div>
		<div class="row" style="width:130px">' . $listName . '</div>
		<div class="row" style="width:80px">' . roles($row['listRoleId']) . '</div>
		<div class="row textSmall" style="width:110px">' . $row['sentDate'] . '</div>
		<div class="row textSmall" style="width:110px">' . $responded . '</div>
	</div>
';
            }
            $output .= '		</table>
</div>';
            $success = true;
            $returnThis['returnViewInvitations'] = $output;
        }
    } else {
        error(__LINE__);
        pdoError(__LINE__, $getInvitationsQuery, '$getInvitationsQuery');
    }
    if (MODE == 'viewInvitations') {
        returnData();
    } else {
        return $output;
    }
}
Example #30
0
<?php

session_start();
require 'rb-p533.php';
if (!isset($_SESSION['login_user'])) {
    // if(!session_is_registered("uid")){
    header("location:intro.php");
}
R::setup('mysql:host=localhost;dbname=smartqna', 'root', '');
if (is_ajax()) {
    returnData();
}
// Function to check if the request is an AJAX request
function is_ajax()
{
    return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
}
function returnData()
{
    $return = $_POST;
    // Do what you need to do with the info. The following are some examples.
    // if ($return["favorite_beverage"] == ""){
    // $return["favorite_beverage"] = "Coke";
    // }
    // $return["favorite_restaurant"] = "McDonald's";
    R::dispense('user');
    $id = $_SESSION['login_user'];
    $user = R::findOne('user', "uid = '{$id}'");
    $return["userName"] = $user->name;
    $return["userHp"] = $user->hp;
    //$return ["json"] = json_encode ( $return );