Пример #1
0
function add_script($arr)
{
    global $SCRIPTS, $APAGES;
    $custom = array('code' => '', 'type' => 'script', 'link' => '', 'function' => '', 'priority' => '30', 'auto' => '', 'category' => 'public', 'zone' => '');
    $custom = set_merge($custom, $arr);
    $key = $custom['code'] = canone_code($custom['code']);
    if (validate_code($key) && !isset($SCRIPTS[$key]) && (isset($APAGES['index']) && $custom['category'] == $APAGES['index']->category || $custom['category'] == 'all')) {
        $SCRIPTS[$key] = new scripts_collector($custom);
    }
}
Пример #2
0
function add_action($arr)
{
    global $ACTIONS, $APAGES;
    $custom = array('code' => '', 'function' => '', 'rule' => 'admin', 'category' => 'public', 'priority' => 30, 'zone' => '', 'auto' => '');
    $custom = set_merge($custom, $arr);
    $key = $custom['code'] = canone_code($custom['code']);
    if (validate_code($key) && !isset($ACTIONS[$key]) && (isset($APAGES['index']) && $custom['category'] == $APAGES['index']->category || $custom['category'] == 'all')) {
        $ACTIONS[$key] = new actions_collector($custom);
    }
}
Пример #3
0
function add_apage($arr)
{
    global $APAGES;
    $custom = (array) new page_collector($arr);
    $custom = set_merge($custom, $arr);
    $key = $custom['code'] = canone_code($custom['code']);
    if (validate_code($key) && !isset($APAGES[$key]) && ($key == 'index' || $custom['category'] == $APAGES['index']->category || $custom['category'] == 'all')) {
        $APAGES[$key] = new page_collector($custom);
        if ($APAGES[$key]->parent != '' && isset($APAGES[$APAGES[$key]->parent]) && $APAGES[$key]->priority >= 0) {
            $APAGES[$APAGES[$key]->parent]->childs[] = $key;
        }
    }
}
Пример #4
0
/**
 * Creates a new liveticker.
 * @param string team_a The home team's name.
 * @param string team_b The guest team's name.
 * @param int duration Each game half's duration in minutes.
 * @param string name The game's name.
 * @param string location The game's location.
 * @param mixed[] players The players of both teams. Structure: {team => true/false, "number", "name"}
 * @param string code The passcode that can be used to manage this ticker.
 * @return int The newly created ticker's id, or null if the creation failed.
 */
function create_ticker($team_a, $team_b, $duration, $name, $location, $players, $code)
{
    global $con;
    //value validation and sanitizing
    try {
        validate_duration($duration);
        validate_code($code);
        $players = sanitize_players($players);
    } catch (Exception $e) {
        return null;
    }
    $codehash = hash_code($code);
    //create ticker
    $sql = 'INSERT INTO tickers (`team_a`, `team_b`, `duration`, `name`, `location`, `code`) VALUES (?, ?, ?, ?, ?, ?)';
    $stmt = $con->prepare($sql);
    $stmt->bindParam(1, $team_a);
    $stmt->bindParam(2, $team_b);
    $stmt->bindParam(3, $duration);
    $stmt->bindParam(4, $name);
    $stmt->bindParam(5, $location);
    $stmt->bindParam(6, $codehash);
    $stmt->execute();
    $id = $con->lastInsertId();
    //add players
    if (!empty($players)) {
        $sql = "INSERT INTO players (`ticker`, `team`, `number`, `name`) VALUES ";
        $all_values = array();
        $i = 0;
        foreach ($players as $player) {
            $sql .= "(?, ?, ?, ?)";
            if ($i < sizeof($players) - 1) {
                $sql .= ", ";
            }
            $i++;
            $team = false;
            if ($player["team"] == "b") {
                $team = true;
            }
            $all_values = array_merge($all_values, array($id, $team, $player["number"], $player["name"]));
        }
        $stmt = $con->prepare($sql);
        $stmt->execute($all_values);
    }
    return $id;
}
Пример #5
0
function add_option($params)
{
    global $DETDB;
    if (is_array($params)) {
        $custom = (array) new option($params, true);
        $custom['code'] = canone_code($custom['code']);
        if (validate_code($custom['code'])) {
            if (!check_code('options', $custom['code'], 'code')) {
                return $DETDB->insert('options', $custom);
            } else {
                push_output_message(array('text' => 'Данный код уже занят.', 'title' => 'Ошибка!', 'class' => 'alert alert-warning', 'type' => 'error'));
            }
        } else {
            push_output_message(array('text' => 'Отправлен неправильный (невалидный) код.', 'title' => 'Ошибка!', 'class' => 'alert alert-warning', 'type' => 'error'));
        }
    }
    return false;
}
Пример #6
0
function update_detblock($ID, $par)
{
    global $DETDB;
    if (is_merged($par) && is_numeric($ID) && ($obj = $DETDB->isset_cell('detblocks_types', $ID))) {
        $par = (array) $par;
        $custom = array();
        if (isset($par['code']) && $par['code']) {
            $par['code'] = canone_code($par['code']);
            if (!validate_code($par['code'])) {
                return false;
            } else {
                $custom['code'] = $par['code'];
            }
        }
        if (isset($par['name'])) {
            $custom['name'] = $par['name'];
        }
        if (isset($par['description'])) {
            $custom['description'] = $par['description'];
        }
        return $DETDB->update('detblocks_types', $custom, "WHERE ID={$ID}");
    }
    return false;
}
Пример #7
0
        $error .= "- Code is blank<br>";
    }
    if ($new_description == '') {
        $error .= "- Description is blank<br>";
    }
    if ($new_code != '') {
        $sql = "SELECT * from codes where field_id={$field_id} AND code like '%{$new_code}%' ";
        $result = mysql_query($sql) or die(mysql_error());
        if (mysql_num_rows($result) > 0) {
            $error .= "- The new Code is too similar to an already existing code. Please try to come up with a different code.<br>";
        }
    }
    return $error;
}
if ($_REQUEST['new_code'] != '') {
    $error = validate_code($field_id, $_REQUEST['new_code'], $_REQUEST['new_description']);
    if ($error == '') {
        insert_code($field_id, $_REQUEST['new_code'], $_REQUEST['new_description']);
        $_REQUEST['new_code'] = '';
        $_REQUEST['new_description'] = '';
        ?>


	   <?php 
    } else {
        ?>
<b><font color="#ff0000">ERROR:</font> Cannot save new code because:</b><br>
		   <?php 
        echo $error;
    }
}
Пример #8
0
function update_users_groups($par, $cond)
{
    global $DETDB;
    if (is_merged($par)) {
        $par = (array) $par;
        if (isset($par['code'])) {
            $par['code'] = canone_code($par['code']);
            if (!validate_code($par['code'])) {
                return false;
            }
        }
        return $DETDB->update('users_groups', $par, $cond);
    }
    return false;
}
Пример #9
0
function set_ID($ID)
{
    if ($ID && is_numeric($ID)) {
        $param = 'ID';
    } elseif (validate_code($ID)) {
        $param = 'code';
    } else {
        $param = null;
    }
    return $param;
}