Ejemplo n.º 1
0
function create_player($player, $cards)
{
    $values["player"] = $player;
    $values["cards"] = $cards;
    $values["game"] = game;
    return create_entry("player", array("player", "cards", "game"), array(), $values);
}
Ejemplo n.º 2
0
function add_card_owner_status($card, $player, $status)
{
    if (get_status($card, $player) != $status) {
        $values["player"] = $player;
        $values["card"] = $card;
        $values["game"] = game;
        $values["turn"] = turn;
        $values["status"] = $status;
        create_entry("owned", array("card", "game", "player", "status", "turn"), array(), $values);
        $card_type = select_card($card, array("type"))["type"];
        $all_typed_cards = array_of_ids(select_cards(array("type" => $card_type)));
        if ($status == owned) {
            foreach (select_suspects() as $other_player) {
                if ($other_player["id"] != $player) {
                    add_card_owner_status($card, $other_player["id"], not_owned);
                }
            }
            $known_cards = known_cards_player($player);
            if (count($known_cards) == select_cards_player($player)) {
                foreach (select_cards(array("id" => array("NOT IN", $known_cards))) as $other_card) {
                    add_card_owner_status($other_card["id"], $player, not_owned);
                }
            }
            $known_cards = known_cards_type($card_type);
            if (count($known_cards) + 1 == count($all_typed_cards)) {
                foreach (array_diff($all_typed_cards, $known_cards) as $left_out_card) {
                    foreach (select_suspects() as $other_player) {
                        add_card_owner_status($left_out_card, $other_player["id"], not_owned);
                    }
                }
            }
        } elseif ($status == not_owned) {
            foreach (select_turns() as $turn) {
                $turn = select_turn($turn["id"], array("weapon", "room", "suspect", "witness"));
                if ($turn["witness"] == $player) {
                    if ($turn["weapon"] == $card && get_status($turn["room"], $player) == not_owned || $turn["room"] == $card && get_status($turn["weapon"], $player) == not_owned) {
                        add_card_owner_status($turn["suspect"], $player, owned);
                    } elseif ($turn["weapon"] == $card && get_status($turn["suspect"], $player) == not_owned || $turn["suspect"] == $card && get_status($turn["weapon"], $player) == not_owned) {
                        add_card_owner_status($turn["room"], $player, owned);
                    } elseif ($turn["suspect"] == $card && get_status($turn["room"], $player) == not_owned || $turn["room"] == $card && get_status($turn["suspect"], $player) == not_owned) {
                        add_card_owner_status($turn["weapon"], $player, owned);
                    }
                }
            }
            if (exists_murder_card($card_type)) {
                foreach (select_cards(array("type" => $card_type)) as $other_card) {
                    $unknown_owners = select_unknown_owners($other_card["id"]);
                    if (count($unknown_owners) == 1) {
                        foreach ($unknown_owners as $owner) {
                            add_card_owner_status($other_card["id"], $owner, owned);
                        }
                    }
                }
            }
        }
    }
}
Ejemplo n.º 3
0
function create_game($my_player)
{
    return create_entry("game", array("date", "my_player"), array(), array("date" => current_date(), "my_player" => $my_player));
}
Ejemplo n.º 4
0
#
# Load up files
#
require_once 'config.php';
require_once 'setup.php';
require_once 'functions.php';
#
# Route URLS
#
if (isset($_REQUEST['migrate'])) {
    require_once 'migrate.php';
} elseif ($_POST['action'] == 'create') {
    $person_id = $_REQUEST['person_id'];
    $project_id = $_REQUEST['project_id'];
    $startdate = $_REQUEST['startdate'];
    create_entry($person_id, $project_id, $startdate);
} elseif ($_POST['action'] == 'update') {
    $entry_id = $_REQUEST['entry_id'];
    $project_id = $_REQUEST['project_id'];
    $startdate = $_REQUEST['startdate'];
    update_entry($entry_id, $project_id, $startdate);
} elseif ($_POST['action'] == 'delete') {
    $entry_id = $_REQUEST['entry_id'];
    delete_entry($entry_id);
} elseif ($_POST['action'] == 'reorder') {
    $new_order = $_REQUEST['new_order'];
    reorder_entries($new_order);
} elseif ($_POST['action'] == 'add_project') {
    $project_name = $_REQUEST['project_name'];
    $project_url = $_REQUEST['project_url'];
    add_project($project_name, $project_url);
Ejemplo n.º 5
0
{
    global $link;
    $query = "INSERT INTO `guestbook` " . "SET `username` = '{$p['username']}', " . "`content` = '{$p['content']}'";
    mysqli_query($link, $query);
}
// create_entry()
$posts = entries();
if ($_SERVER['REQUEST_METHOD'] == "POST") {
    $new_post = ['username' => $_POST['user_name'], 'content' => $_POST['content']];
    foreach ($new_post as $node => $value) {
        if (!$value) {
            $errors[] = $node;
        }
    }
    if (empty($errors)) {
        create_entry($new_post);
        header('Location: guestbook.php');
    }
    // if
}
// if
?>

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Guestbook</title>
        <style>
            #container {
                display: block;
                float: left;
Ejemplo n.º 6
0
<body>
<?php 
include 'SCA/SCA.php';
date_default_timezone_set('Europe/London');
/***********************************************/
/* Get the component which calls the Atom feed */
/***********************************************/
$contact_service = SCA::getService('ContactFeedConsumer.php');
/***********************************************/
/* Create an XML entry and send it to the      */
/* Atom component via the ContactFeedConsumer. */
/***********************************************/
echo '<p>';
echo '<b>Testing Create<br/></b>';
echo '<p>This is the XML we are going to send';
$entryXML = create_entry();
echo '<pre>';
write_entry_xml($entryXML);
echo '</pre>';
$entry = $contact_service->create($entryXML);
// Write out the response (the id should have been
// changed to that of the database.
echo '<b><br/>Response from create (the id should be different)<br/></b>';
echo '<pre>';
write_entry($entry);
echo '</pre>';
echo '</p>';
echo '<p>';
// Remember the id because we will delete it later
// I would like to just get the id value, but it is the uri
$segments = explode('/', $entry->id[0]->value);
Ejemplo n.º 7
0
function create_turn($values)
{
    $values["player"] = get_current_player();
    $values["game"] = game;
    return create_entry("turn", array("player", "room", "weapon", "suspect", "witness", "evidence", "game"), array(), $values);
}
Ejemplo n.º 8
0
function create_sitemap_pages()
{
    global $db, $my_base_url, $my_pligg_base, $URLMethod;
    if (XmlSitemaps_use_cache) {
        $icf = "cache/sitemap-pages.xml";
        if (file_exists($icf) && ($s = stat($icf)) && time() - $s['mtime'] < XmlSitemaps_cache_ttl) {
            echo my_file_get_contents($icf);
            return true;
        }
        ob_start();
    }
    echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
    echo '<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/09/sitemap.xsd"     xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
    $sql = "SELECT link_modified  FROM " . table_links . " WHERE link_status!='discard' ORDER BY link_modified DESC LIMIT 1";
    $res = $db->get_col($sql);
    if (isset($res[0])) {
        $path = "{$my_base_url}{$my_pligg_base}";
        create_entry(strtotime($res[0]), $path);
    }
    ///////////////// Upcoming.............
    $sql = "SELECT UNIX_TIMESTAMP(link_date)  FROM " . table_links . " WHERE link_status='queued' ORDER BY link_date DESC LIMIT 1";
    $res = $db->get_col($sql);
    if (isset($res[0])) {
        if ($URLMethod == 1) {
            $path = "{$my_base_url}{$my_pligg_base}/upcoming.php";
        } else {
            if ($URLMethod == 2) {
                $path = "{$my_base_url}{$my_pligg_base}/upcoming";
            }
        }
        create_entry($res[0], $path);
    }
    //////////////////////...........categories.................
    $sql = "SELECT category_id,category_name,category_safe_name FROM " . table_categories . " WHERE category_enabled=1 AND category_name!='new category'";
    $cat = $db->get_results($sql);
    foreach ($cat as $i) {
        $sql = "SELECT UNIX_TIMESTAMP(link_published_date),link_id FROM " . table_links . " WHERE link_category=" . $i->category_id . " AND link_status='published' ORDER BY link_published_date DESC LIMIT 1";
        $res = $db->get_col($sql);
        if (isset($res[0])) {
            $path = getmyFullurl('maincategory', urlencode($i->category_safe_name));
            create_entry($res[0], $path);
        }
    }
    ////////////////////.............upcoming categories..........
    foreach ($cat as $i) {
        $sql = "SELECT UNIX_TIMESTAMP(link_date) FROM " . table_links . " WHERE link_category=" . $i->category_id . " AND link_status='queued' ORDER BY link_date DESC LIMIT 1";
        $res = $db->get_col($sql);
        if (isset($res[0])) {
            $path = getmyFullurl('queuedcategory', urlencode($i->category_safe_name));
            create_entry($res[0], $path);
        }
    }
    if (check_for_enabled_module('extra_pages', 0.1)) {
        //.............Tips page...............
        $sql = "SELECT UNIX_TIMESTAMP(modified_date) FROM " . table_prefix . "extra_pages  WHERE type='Tip' ORDER BY modified_date DESC LIMIT 1";
        $res = $db->get_col($sql);
        if (isset($res[0])) {
            if ($URLMethod == 1) {
                $path = "{$my_base_url}{$my_pligg_base}/module.php?module=extra_pages&amp;action=show_tips";
            } else {
                if ($URLMethod == 2) {
                    $path = "{$my_base_url}{$my_pligg_base}/tips";
                }
            }
            create_entry($res[0], $path);
        }
        //.............FAQ page................
        $sql = "SELECT UNIX_TIMESTAMP(modified_date) FROM " . table_prefix . "extra_pages  WHERE type='FAQ' ORDER BY modified_date DESC LIMIT 1";
        $res = $db->get_col($sql);
        if (isset($res[0])) {
            if ($URLMethod == 1) {
                $path = "{$my_base_url}{$my_pligg_base}/module.php?module=extra_pages&amp;action=show_faq";
            } else {
                if ($URLMethod == 2) {
                    $path = "{$my_base_url}{$my_pligg_base}/faq";
                }
            }
            create_entry($res[0], $path);
        }
    }
    //close xml
    echo '</urlset>';
    if (XmlSitemaps_use_cache) {
        $ret = ob_get_contents();
        ob_end_flush();
        my_file_put_contents($icf, $ret);
    }
    return true;
}
Ejemplo n.º 9
0
function sitemap_add_page($name, $sql)
{
    global $db;
    $res = $db->get_var($sql);
    if ($res) {
        create_entry($res, getmyFullurl($name));
    }
}