<?php

/**
IC-Discuss (c) 2015 by Hope Consultants International Ltd.

IC-Discuss is licensed under a
Creative Commons Attribution-ShareAlike 4.0 International License.

You should have received a copy of the license along with this
work.  If not, see <http://creativecommons.org/licenses/by-sa/4.0/>.
**/
require_once 'includes/bootstrap.php';
assertAccess(SECTION_SYNTHESIZE);
$issue_id = Utils::requestOrDefault('issue', null);
$statement_id = Utils::requestOrDefault('statement', null);
$summary_id = Utils::requestOrDefault('summary', null);
$summary_id_old = Utils::requestOrDefault('summary_old', null);
$action = Utils::requestOrDefault('action', null);
/**
 * Check if statement exists
 *
 * @param string $statement_id statement id
 *
 * @return boolean true if statement exists
 */
function checkStatementExists($statement_id)
{
    return !is_null($statement_id) && !is_null(Utils::getStatement($statement_id));
}
/**
 * Check if summary exists
<?php

/**
IC-Discuss (c) 2015 by Hope Consultants International Ltd.

IC-Discuss is licensed under a
Creative Commons Attribution-ShareAlike 4.0 International License.

You should have received a copy of the license along with this
work.  If not, see <http://creativecommons.org/licenses/by-sa/4.0/>.
**/
require_once 'includes/bootstrap.php';
require_once 'php-excel/Classes/PHPExcel.php';
assertAccess(SECTION_UPLOAD);
/**
 * Try to get data, if none there, return default
 *
 * @param mixed $data    input data
 * @param mixed $default value if $data is empty (default: '')
 *
 * @return mixed $data if not emptu $default otherwise
 */
function _dataOrDefault($data, $default = '')
{
    return empty($data) ? $default : $data;
}
$action = Utils::requestOrDefault('action', 'nothing');
if ($action == 'import') {
    if (isset($_FILES['spreadsheet']) && !empty($_FILES['spreadsheet']['name'])) {
        if (empty($_FILES['spreadsheet']['error'])) {
            $inputFile = $_FILES['spreadsheet']['name'];
<?php

/**
IC-Discuss (c) 2015 by Hope Consultants International Ltd.

IC-Discuss is licensed under a
Creative Commons Attribution-ShareAlike 4.0 International License.

You should have received a copy of the license along with this
work.  If not, see <http://creativecommons.org/licenses/by-sa/4.0/>.
**/
require_once 'includes/bootstrap.php';
assertAccess(SECTION_MANAGE);
$issue_id = Utils::requestOrDefault('id', NEW_ENTRY_ID);
$action = Utils::requestOrDefault('action', 'list');
$page_url = strtok($_SERVER["REQUEST_URI"], '?');
// new issue?
$new_issue = false;
if ($issue_id == NEW_ENTRY_ID) {
    $new_issue = true;
}
switch ($action) {
    case 'delete':
        $query = "DELETE FROM `%table` WHERE IssueId = :id";
        $values = array('%table' => TABLE_ISSUES, ':id' => $issue_id);
        $stmt = db()->preparedStatement($query, $values);
        if (!$stmt->success) {
            die('Database delete fail: ' . $stmt->error);
        }
        header('Location: ' . $page_url . '?action=list', true, 302);
        break;
<?php

/**
IC-Discuss (c) 2015 by Hope Consultants International Ltd.

IC-Discuss is licensed under a
Creative Commons Attribution-ShareAlike 4.0 International License.

You should have received a copy of the license along with this
work.  If not, see <http://creativecommons.org/licenses/by-sa/4.0/>.
**/
require_once 'includes/bootstrap.php';
assertAccess(array(SECTION_SYNTHESIZE, SECTION_TICKER));
$issue_id = Utils::requestOrDefault('issue', 0);
$s_issues = db()->preparedStatement("SELECT IssueId, Title FROM `%table` WHERE Frontpage = 1 ORDER BY Title", array('%table' => TABLE_ISSUES));
$issues = $s_issues->fetchAll(PDO::FETCH_GROUP | PDO::FETCH_COLUMN);
$issues = array_map('reset', $issues);
if (count($issues) > 0) {
    if (!array_key_exists($issue_id, $issues) && $issue_id != 0) {
        $issue_id = key($issues);
    }
} else {
    $issue_id = 0;
}
$script = <<<EOJS
\tconst debug = %s;
\tconst ajaxHandlerURL = '%s';
\t
\tvar issue_id = %s;
EOJS;
$script = sprintf($script, DEBUG ? 'true' : 'false', htmlentities(BASE_URL . 'liveticker_callback.php'), $issue_id);