function addEvents()
{
    global $o, $c, $m, $a, $y, $w, $id, $table_prefix, $page_title, $calendar_title, $supergroup, $supercategory, $lang;
    $title = $_REQUEST["title"];
    $venue = $_REQUEST["venue"];
    $contact = $_REQUEST["contact"];
    $category = $_REQUEST["category"];
    $group = $_REQUEST["group"];
    $date = $_REQUEST["date"];
    $start = $_REQUEST["start"];
    $end = $_REQUEST["end"];
    $description = $_REQUEST["description"];
    while (list($k, $v) = each($start)) {
        $dstart = eregi_replace("([0-9]{1,2}:[0-9]{2}):[0-9]{2}([ ]?[a|p]m)", "\\1\\2", $v);
        $dend = eregi_replace("([0-9]{1,2}:[0-9]{2}):[0-9]{2}([ ]?[a|p]m)", "\\1\\2", $end[$k]);
        $dc = "";
        $sc = "";
        $ec = "";
        if (!ereg("([0-9]{1,2})[\\/-]+([0-9]{1,2})[\\/-]+([0-9]{4})", $date[$k])) {
            $dc = " class=\"error\"";
        }
        if (!eregi("([0-9]{1,2}):([0-9]{2})[ ]?([a|p]m)", $dstart)) {
            $sc = " class=\"error\"";
        }
        if ($dend && !eregi("([0-9]{1,2}):([0-9]{2})[ ]?([a|p]m)", $dend)) {
            $ec = " class=\"error\"";
        }
        if ($dc | $sc | $ec) {
            $verify .= "There are date/time errors in your listings. ";
        }
        if (!$supercategory) {
            $q = "select * from " . $table_prefix . "users_to_categories where category_id = " . $category[$k] . " and user_id = " . $_SESSION["user_id"];
            $qu = mysql_query($q);
            if (mysql_num_rows($qu) < 2) {
                $verify = $lang["no_permision_post_events"];
            }
        }
        if (!$supergroup) {
            $q = "select * from " . $table_prefix . "users_to_groups where group_id = " . $group[$k] . " and user_id = " . $_SESSION["user_id"];
            $qu = mysql_query($q);
            if (mysql_num_rows($qu) < 2) {
                $verify = $lang["no_permision_post_events"];
            }
        }
        // verify categories
    }
    reset($start);
    if ($verify) {
        include "includes/header.php";
        ?>
<form action="<?php 
        echo $PHP_SELF;
        ?>
" method="post">
<?php 
        include "includes/hidden_fields.php";
        ?>
<h3><?php 
        echo $lang["verify_event_listings_title"];
        ?>
</h3>
<p><?php 
        echo $lang["errors_in_listings"];
        ?>
 <?php 
        echo $verify;
        ?>
</p>
<table>
<tr><th><?php 
        echo $lang["title"];
        ?>
</th><th><?php 
        echo $lang["venue"];
        ?>
</th><th><?php 
        echo $lang["contact_sponsor"];
        ?>
</th><th><?php 
        echo $lang["category"];
        ?>
</th><th><?php 
        echo $lang["group"];
        ?>
</th><th><?php 
        echo $lang["date"];
        ?>
</th><th><?php 
        echo $lang["start_time"];
        ?>
</th><th<?php 
        echo $lang["end_time"];
        ?>
</th><th><?php 
        echo $lang["description"];
        ?>
</th></tr>
<?php 
        while (list($k, $v) = each($start)) {
            $dstart = eregi_replace("([0-9]{1,2}:[0-9]{2}):[0-9]{2}([ ]?[a|p]m)", "\\1\\2", $v);
            $dend = eregi_replace("([0-9]{1,2}:[0-9]{2}):[0-9]{2}([ ]?[a|p]m)", "\\1\\2", $end[$k]);
            $dc = "";
            $sc = "";
            $ec = "";
            if (!ereg("([0-9]{1,2})[\\/-]+([0-9]{1,2})[\\/-]+([0-9]{4})", $date[$k])) {
                $dc = " class=\"error\"";
            }
            if (!eregi("([0-9]{1,2}):([0-9]{2})[ ]?([a|p]m)", $dstart)) {
                $sc = " class=\"error\"";
            }
            if ($dend && !eregi("([0-9]{1,2}):([0-9]{2})[ ]?([a|p]m)", $dend)) {
                $ec = " class=\"error\"";
            }
            echo "<tr>\n";
            echo "<td><input type=\"text\" size=\"20\" id=\"title[]\" name=\"title[]\" value=\"" . $title[$k] . "\"></td>\n";
            echo "<td><select name=\"venue[]\" id=\"venue[]\" size=\"1\"><option value=\"1\">" . $lang["in_main_description"] . "</option>\n";
            select_place($venue[$k]);
            echo "</select></td>\n";
            echo "<td><select name=\"contact[]\" id=\"contact[]\" size=\"1\"><option value=\"1\">" . $lang["none"] . "</option>\n";
            select_place($contact[$k]);
            echo "</select></td>\n";
            echo "<td><select name=\"category[]\" id=\"category[]\" size=\"1\">\n";
            $scategory = $category[$k];
            category_tree(0);
            echo "</select></td>\n";
            echo "<td><select name=\"category[]\" id=\"category[]\" size=\"1\">\n";
            $sgroup = $group[$k];
            group_tree(0);
            echo "</select></td>\n";
            echo "<td><input type=\"text\"" . $dc . " id=\"date[]\" size=\"10\" name=\"date[]\" value=\"" . $date[$k] . "\"></td>\n";
            echo "<td><input type=\"text\"" . $sc . " id=\"start[]\" size=\"8\" name=\"start[]\" value=\"" . $dstart . "\"></td>\n";
            echo "<td><input type=\"text\"" . $ec . " id=\"end[]\" size=\"8\" name=\"end[]\" value=\"" . $dend . "\"></td>\n";
            echo "<td><textarea cols=\"30\" rows=\"1\" name=\"description[]\">" . $description[$k] . "</textarea></td>\n";
            echo "</tr>\n";
        }
        echo "</table>\n";
        echo "<INPUT TYPE=\"submit\" NAME=\"mode\" VALUE=\"" . $lang["add_events"] . "\"></form>";
    } else {
        while (list($k, $v) = each($start)) {
            $dstart = eregi_replace("([0-9]{1,2}:[0-9]{2}):[0-9]{2}([ ]?[a|p]m)", "\\1\\2", $v);
            $dend = eregi_replace("([0-9]{1,2}:[0-9]{2}):[0-9]{2}([ ]?[a|p]m)", "\\1\\2", $end[$k]);
            $title[$k] = addslashes(strip_tags($title[$k]));
            $descriptioni[$k] = addslashes($description[$k]);
            $q = "INSERT into " . $table_prefix . "events (title, venue_id, contact_id, description, category_id, user_id, group_id) values ('" . $title[$k] . "', " . $venue[$k] . ", " . $contact[$k] . ", '" . $description[$k] . "', " . $category[$k] . ", " . $_SESSION["user_id"] . ", " . $group[$k] . ")";
            $query = mysql_query($q);
            $event_id = mysql_insert_id();
            if (!$query) {
                $msg .= "Database Error : " . $q;
            } else {
                if (!ereg("([0-9]{1,2})[\\/-]+([0-9]{1,2})[\\/-]+([0-9]{4})", $date[$k], $d_date)) {
                    $msg .= "Bad Date:" . $date[$k];
                } else {
                    if (!eregi("([0-9]{1,2}):([0-9]{2})[ ]?([a|p]m)", $dstart, $start_time)) {
                        $msg .= "Bad Start Time:" . $dstart;
                    } else {
                        if ($dend && !eregi("([0-9]{1,2}):([0-9]{2})[ ]?([a|p]m)", $dend, $end_time)) {
                            $msg .= "Bad End Time:" . $dend;
                        } else {
                            if (strlen($d_date[1]) == 1) {
                                $d_date[1] = "0" . $d_date[1];
                            }
                            if (strlen($d_date[2]) == 1) {
                                $d_date[2] = "0" . $d_date[2];
                            }
                            if (eregi("pm", $start_time[3]) && $start_time[1] < 12) {
                                $start_time[1] = $start_time[1] + 12;
                            }
                            if (eregi("pm", $end_time[3]) && $end_time[1] < 12) {
                                $end_time[1] = $end_time[1] + 12;
                            }
                            if (strlen($start_time[1]) == 1) {
                                $start_time[1] = "0" . $start_time[1];
                            }
                            if (strlen($end_time[1]) == 1) {
                                $end_time[1] = "0" . $end_time[1];
                            }
                            $start_date = $d_date[3] . "-" . $d_date[1] . "-" . $d_date[2] . " " . $start_time[1] . ":" . $start_time[2];
                            if ($dend) {
                                $end_date = $d_date[3] . "-" . $d_date[1] . "-" . $d_date[2] . " " . $end_time[1] . ":" . $end_time[2];
                                if ($end_time[1] . $end_time[2] > $start_time[1] . $start_time[2]) {
                                    $q = "INSERT into " . $table_prefix . "dates (event_id, date, end_date) values (" . $event_id . ", '" . $start_date . "', '" . $end_date . "')";
                                } else {
                                    $q = "INSERT into " . $table_prefix . "dates (event_id, date) values (" . $event_id . ", '" . $start_date . "')";
                                }
                            } else {
                                $q = "INSERT into " . $table_prefix . "dates (event_id, date) values (" . $event_id . ", '" . $start_date . "')";
                            }
                            $query = mysql_query($q);
                            if (!$query) {
                                $msg .= "Database Error : " . $q;
                            }
                        }
                    }
                }
            }
        }
        if (!$msg) {
            $msg = $lang["events_added"];
        }
        header("Location: upload_events.php?msg=" . $msg . "&" . $common_get);
    }
}
Example #2
0
function show_form_all()
{
    global $cmd;
    # XXX - Construct form for editing all feeds.
    $groups = group_tree();
    echo '<', '?xml version="1.0" encoding="UTF-8"?', ">\n";
    ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>NewsBite: Editing groups</title>
<link rel="stylesheet" type="text/css" href="css/style.css" media="all" />
<link rel="stylesheet" type="text/css" href="css/editgroups.css" media="all" />
<meta name="theme-color" content="#8080c0" />
<!-- Template for tree of groups -->
<template id="groupentry">
  <li id="group_@GID@" class="group-entry">
    <label id="groupname_@GID@">@GROUPNAME@</label>
    <button class="edit-group-button">Edit</button>
    <button class="delete-group-button">Delete</button>
    <div class="child-groups" id="children_@GID@"></div>
  </li>
</template>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/group.js"></script>
</head>
<body id="edit-group">

<?php 
    /* XXX - Links to get back to interesting places, like feed list */
    ?>
<h1>Groups</h1>

<form name="edit-groups" method="post" action="group.php">
<input type="hidden" name="command" value="<?php 
    echo $cmd;
    ?>
"/>
<ul id="group-tree"></ul>
<hr/>

<input type="reset" value="Clear changes"/>
<input type="submit" name="change" value="Apply changes"/>
</form>

<h2>Add a group</h2>
<!-- Yeah, maybe it's just easier to have a separate form for adding groups.
' -->
<!-- <form name="add-group" method="post" action="groups.php"> -->
<form id="add-group-form" name="add-group">
  <input name="command" type="hidden" value="add"/>
  Group name: <input name="name" type="text" size="20"/><br/>
<!-- XXX - parent -->
  <input name="parent" type="hidden" value="-1"/>
  <input name="add" type="submit" value="Add group"/>
</form>

</body>
</html>
<?php 
    return;
}
function group_tree($group_id)
{
    global $table_prefix, $indent, $supergroup, $sgroup;
    $q = "SELECT group_id, name from " . $table_prefix . "groups where sub_of = " . $group_id . " order by name";
    $query = mysql_query($q);
    if (!$query) {
        echo "Database Error : " . $q;
    } else {
        while ($row = mysql_fetch_row($query)) {
            $mod = 0;
            if (!$supergroup) {
                $q = "select moderate from " . $table_prefix . "users_to_groups where group_id = " . $row[0] . " and user_id = " . $_SESSION["user_id"];
                $qu = mysql_query($q);
                if (mysql_num_rows($qu) > 0) {
                    $mod = mysql_result($qu, 0, 0);
                }
            } else {
                $mod = 3;
            }
            if ($mod > 0) {
                echo "<option value=\"" . $row[0] . "\"";
                if ($mod < 2) {
                    echo " disabled";
                }
                if ($sgroup == $row[0]) {
                    echo " SELECTED";
                }
                echo ">" . $indent . $row[1] . "</option>\n";
            }
            $indent .= "__";
            group_tree($row[0]);
            $indent = substr($indent, 2);
        }
    }
}
Example #4
0
function show_form($feed_id)
{
    // We've already established above that $feed_id is numeric
    $feed = db_get_feed($feed_id);
    if ($feed === NULL) {
        abort("No such feed: {$feed_id}");
    }
    // Figure out which groups this feed is in.
    $groups = group_tree(TRUE);
    mark_groups($feed_id, $groups);
    $feed_opts = db_get_feed_options($feed['id']);
    ########################################
    echo '<', '?xml version="1.0" encoding="UTF-8"?', ">\n";
    ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>NewsBite: Editing <?php 
    echo htmlspecialchars($feed['title']);
    ?>
</title>
<link rel="stylesheet" type="text/css" href="css/style.css" media="all" />
<link rel="stylesheet" type="text/css" href="css/editfeed.css" media="all" />
<meta name="theme-color" content="#8080c0" />
</head>
<body id="edit-feed">

<?php 
    /* XXX - Links to get back to interesting places, like feed list */
    ?>
<h1>Editing feed <?php 
    echo htmlspecialchars($feed['title']);
    ?>
</h1>

<form name="edit-feed" method="post" action="editfeed.php">
<?php 
    /* Feed ID */
    ?>
<input type="hidden" name="id" value="<?php 
    echo $feed['id'];
    ?>
"/>
<input type="hidden" name="command" value="update"/>

<table id="show-feed">
<?php 
    /* XXX - Is it worth displaying the feed ID? */
    ?>
  <tr>
    <th>ID</th>
    <td><?php 
    echo $feed['id'];
    ?>
</td>
  </tr>

  <tr>
    <th>Title</th>
    <td><?php 
    echo htmlspecialchars($feed['title']);
    ?>
</td>
  </tr>

  <tr>
    <th>Subtitle</th>
    <td><?php 
    echo $feed['subtitle'] ? htmlspecialchars($feed['subtitle']) : "&nbsp;";
    ?>
</td>
  </tr>

<?php 
    /* User-settable nickname */
    ?>
  <tr>
    <th>Nickname</th>
    <td>
      <input type="text" name="nickname" value="<?php 
    echo $feed['nickname'];
    ?>
"/>
    </td>
  </tr>

<?php 
    /* XXX - There should be a button or something to try to
     * auto-discover the feed URL from the site URL. Presumably the way
     * to do this is to fetch the site URL and check for "link
     * rel=alternate", where the MIME type is RSS or Atom.
     *
     * However, I'm not sure this can be done in JavaScript: we can't
     * just fetch an arbitrary URL.
     */
    ?>
  <tr>
    <th>Site URL</th>
    <td>
      <input type="text" name="url" value="<?php 
    echo $feed['url'];
    ?>
"/>
    </td>
  </tr>

  <tr>
    <th>Feed URL</th>
    <td>
      <input type="text" name="feed_url" value="<?php 
    echo $feed['feed_url'];
    ?>
"/>
    </td>
  </tr>

  <tr>
    <th>Description</th>
    <td>
      <div><?php 
    # Sanitize description before displaying it.
    $description = $feed['description'];
    run_hooks("clean-html", array(&$description));
    echo $description;
    ?>
</div>
    </td>
  </tr>

<?php 
    /* XXX - Probably not worth displaying this */
    ?>
  <tr>
    <th>Last update</th>
    <td><?php 
    echo $feed['last_update'];
    ?>
</td>
  </tr>

  <tr>
    <th>Image</th>
    <td>
<?php 
    if (isset($feed['image'])) {
        ?>
        <img src="<?php 
        echo $feed['image'];
        ?>
"/>
<?php 
    } else {
        ?>
        No image.
<?php 
    }
    ?>
    </td>
  </tr>

  <tr>
    <th>Groups</th>
    <td>
<?php 
    if (isset($groups['members']) && count($groups['members']) > 0) {
        echo "<ul>";
        foreach ($groups['members'] as $g) {
            if ($g['id'] < 0) {
                html_group_list($g);
            }
        }
        echo "</ul>";
    }
    ?>
    </td>
  </tr>

  <tr>
    <th>Active</th>
    <td>
      <input type="checkbox" name="active"
	<?php 
    if ($feed['active']) {
        echo ' checked="checked"';
    }
    ?>
      />
    </td>
  </tr>

  <tr>
    <th>Username</th>
    <td>
      <input type="text" name="username" value="<?php 
    echo $feed['username'];
    ?>
" autocomplete="off"/>
    </td>
  </tr>

  <tr>
    <th>Password</th>
    <td>
      <input type="password" name="password" value="<?php 
    echo $feed['passwd'];
    ?>
" autocomplete="off"/>
    </td>
  </tr>

  <tr>
    <th class="section-title" colspan="0">Options</th>
  </tr>
<?php 
    if (count($feed_opts) > 0) {
        foreach ($feed_opts as $opt => $value) {
            ?>
    <tr>
      <th><?php 
            echo $opt;
            ?>
</th>
      <td><input type="number"
		name="opt_<?php 
            echo $opt;
            ?>
"
		value="<?php 
            echo $feed_opts[$opt];
            ?>
" /></td>
    </tr>
<?php 
        }
    }
    ?>
</table>

<input type="reset" value="Clear changes"/>
<input type="submit" name="change" value="Apply changes"/>
</form>

</body>
</html>
<?php 
    ########################################
}