示例#1
0
function notify_users($id, $what = "created")
{
    global $PHP_URL, $PROJECT_EMAIL, $PROJECT_NAME;
    $result = db_query("SELECT * FROM article WHERE id = {$id}");
    if (db_count($result) == 1) {
        $row = db_next($result);
        mail($PROJECT_EMAIL, "{$PROJECT_NAME} Article #{$id} {$what}", wordwrap("{$row['create_user']} has {$what} an article titled, " . "'{$row['title']}' with the following abstract:\n\n" . "    {$row['abstract']}\n\n" . "Please approve or delete this article via the following " . "page:\n\n" . "    {$PHP_URL}?L{$id}\n"), "From: {$PROJECT_EMAIL}\r\n");
    }
}
示例#2
0
function
show_poll($id)				// I - Poll ID
{
  global $PHP_SELF, $POLL_TYPE_PICKONE, $POLL_TYPE_PICKMANY;


  $result = db_query("SELECT * FROM poll WHERE is_published = 1 AND id = $id");

  if (db_count($result) == 1)
  {
    $row      = db_next($result);
    $id       = $row['id'];
    $question = htmlspecialchars($row['question']);

    print("<p><form method='POST' action='poll.php?v$row[id]'>"
	 ."<b>$question</b>\n");

    if ($row['poll_type'] == $POLL_TYPE_PICKONE)
      print("(please pick one)\n");
    else
      print("(pick all that apply)\n");

    for ($i = 0; $i < 10; $i ++)
    {
      $answer = htmlspecialchars($row["answer$i"]);

      if ($answer != "")
      {
	if ($row['poll_type'] == $POLL_TYPE_PICKONE)
          print("<br /><input type='radio' name='ANSWER'");
	else
          print("<br /><input type='checkbox' name='ANSWER$i'");

	print(" value='$i'/>$answer\n");
      }
    }

    $votes = $row['votes'];
    if ($votes == 1)
      $votes .= "&nbsp;vote";
    else
      $votes .= "&nbsp;votes";

    $ccount = count_comments("poll.php_r$id");
    if ($ccount == 1)
      $ccount .= "&nbsp;comment";
    else
      $ccount .= "&nbsp;comments";

    print("<br /><input type='submit' value='Vote'/>\n"
	 ."[&nbsp;<a href='poll.php?r$id'>Results</a>&nbsp;]\n");
    print("<br />($votes, $ccount)</form></p>\n");
  }

  db_free($result);
}
示例#3
0
function notify_users($id, $what = "updated", $contents = "")
{
    global $priority_long;
    global $scope_long;
    global $status_long;
    global $PHP_URL, $PROJECT_EMAIL, $PROJECT_NAME;
    $result = db_query("SELECT * FROM str WHERE id = {$id}");
    if ($result) {
        $contents = wordwrap($contents);
        $row = db_next($result);
        $prtext = $priority_long[$row['priority']];
        $sttext = $status_long[$row['status']];
        $sctext = $scope_long[$row['scope']];
        if ($row['subsystem'] != "") {
            $subsystem = $row['subsystem'];
        } else {
            $subsystem = "Unassigned";
        }
        if ($row['fix_version'] != "") {
            $fix_version = $row['fix_version'];
        } else {
            $fix_version = "Unassigned";
        }
        if (eregi("[a-z0-9_.]+", $row['create_user'])) {
            $email = auth_user_email($row['create_user']);
        } else {
            $email = $row['create_user'];
        }
        if ($row['create_user'] != $row['modify_user'] && $row['create_user'] != $manager && $email != "") {
            mail($email, "{$PROJECT_NAME} STR #{$id} {$what}", "Your software trouble report #{$id} has been {$what}.  You can check\n" . "the status of the report and add additional comments and/or files\n" . "at the following URL:\n" . "\n" . "    {$PHP_URL}?L{$id}\n" . "\n" . "    Summary: {$row['summary']}\n" . "    Version: {$row['str_version']}\n" . "     Status: {$sttext}\n" . "   Priority: {$prtext}\n" . "      Scope: {$sctext}\n" . "  Subsystem: {$subsystem}\n" . "Fix Version: {$fix_version}\n" . "\n{$contents}" . "________________________________________________________________\n" . "Thank you for using the {$PROJECT_NAME} Software Trouble Report page!", "From: {$PROJECT_EMAIL}\r\n");
        }
        $ccresult = db_query("SELECT email FROM carboncopy WHERE url = 'str.php_L{$id}'");
        if ($ccresult) {
            while ($ccrow = db_next($ccresult)) {
                mail($ccrow['email'], "{$PROJECT_NAME} STR #{$id} {$what}", "Software trouble report #{$id} has been {$what}.  You can check\n" . "the status of the report and add additional comments and/or files\n" . "at the following URL:\n" . "\n" . "    {$PHP_URL}?L{$id}\n" . "\n" . "    Summary: {$row['summary']}\n" . "    Version: {$row['str_version']}\n" . "     Status: {$sttext}\n" . "   Priority: {$prtext}\n" . "      Scope: {$sctext}\n" . "  Subsystem: {$subsystem}\n" . "Fix Version: {$fix_version}\n" . "\n{$contents}" . "________________________________________________________________\n" . "Thank you for using the {$PROJECT_NAME} Software Trouble Report page!", "From: {$PROJECT_EMAIL}\r\n");
            }
            db_free($ccresult);
        }
        if ($row['manager_email'] != "") {
            $manager = $row['manager_email'];
        } else {
            $manager = $PROJECT_EMAIL;
        }
        if ($row['modify_user'] != $manager) {
            mail($manager, "{$PROJECT_NAME} STR #{$id} {$what}", "The software trouble report #{$id} assigned to you has been {$what}.\n" . "You can manage the report and add additional comments and/or files\n" . "at the following URL:\n" . "\n" . "    {$PHP_URL}?L{$id}\n" . "\n" . "    Summary: {$row['summary']}\n" . "    Version: {$row['str_version']}\n" . "     Status: {$sttext}\n" . "   Priority: {$prtext}\n" . "      Scope: {$sctext}\n" . "  Subsystem: {$subsystem}\n" . "Fix Version: {$fix_version}\n" . "\n{$contents}", "From: {$PROJECT_EMAIL}\r\n");
        }
        db_free($result);
    }
}
示例#4
0
<p><a href='documentation.php/license.html'>Mini-XML License</a></p>

<p><a href='documentation.php/reference.html'>Library Reference</a></p>

</td><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td valign='top' width='55%'>

<h2>Recent News</h2>

<?

$result = db_query("SELECT * FROM article WHERE is_published = 1 "
	          ."ORDER BY modify_date DESC LIMIT 3");
$count  = db_count($result);

while ($row = db_next($result))
{
  $id       = $row['id'];
  $title    = htmlspecialchars($row['title']);
  $abstract = htmlspecialchars($row['abstract']);
  $date     = date("H:i M d, Y", $row['modify_date']);
  $count    = count_comments("articles.php_L$id");

  if ($count == 1)
    $count .= " comment";
  else
    $count .= " comments";

  print("<p><a href='articles.php?L$id'>$title</a> - $abstract<br>\n"
       ."<span class='dateinfo'>$date, $count</span></p>\n");
}
示例#5
0
         html_link("Enable Account", "{$PHP_SELF}?E");
         html_end_links();
         print "Thank you for requesting an account.  You should receive an " . "email from {$PROJECT_EMAIL} shortly with instructions on " . "completing your registration.</p>\n";
         html_footer();
         exit;
     }
     db_free($result);
     $usererror = "Username already exists!";
 } else {
     if ($argc == 1 && $argv[0] == "E" && $username != "" && $password != "" && $register != "") {
         // Check that we have an existing user account...
         $name = db_escape($username);
         $result = db_query("SELECT * FROM users WHERE name='{$name}'");
         if (db_count($result) == 1) {
             // Yes, now check the registration code...
             $row = db_next($result);
             $hash = md5("{$row['id']}:{$row['hash']}");
             if ($hash == $register) {
                 // Good code, enable the account and login...
                 db_query("UPDATE users SET is_published = 1 WHERE name='{$name}'");
                 if (auth_login($username, $password) == "") {
                     db_query("UPDATE users SET is_published = 0 WHERE name='{$name}'");
                     $usererror = "Login failed!";
                 }
             } else {
                 $usererror = "Bad registration code!";
             }
         } else {
             $usererror = "Username not found!";
         }
         db_free($result);
示例#6
0
function				// O - Number of comments
show_comments($url,			// I - URL for comment
              $path = "",		// I - Path component
              $parent_id = 0,		// I - Parent comment
	      $heading = 3)		// I - Heading level
{
  global $_COOKIE, $LOGIN_LEVEL;


  $result = db_query("SELECT * FROM comment WHERE "
                    ."url = '" . db_escape($url) ."' "
                    ."AND parent_id = $parent_id "
		    ."ORDER BY id");

  if (array_key_exists("MODPOINTS", $_COOKIE))
    $modpoints = $_COOKIE["MODPOINTS"];
  else
    $modpoints = 5;

  if ($parent_id == 0 && $modpoints > 0)
    print("<P>You have $modpoints moderation points available.</P>\n");
  
  if ($heading > 6)
    $heading = 6;

  $safeurl      = urlencode($url);
  $num_comments = 0;
  $div          = 0;

  while ($row = db_next($result))
  {
    if ($row["status"] > 0)
    {
      if ($heading > 3 && !$div)
      {
	print("<div style='margin-left: 3em;'>\n");
	$div = 1;
      }

      $num_comments ++;

      $create_date = date("H:i M d, Y", $row['create_date']);
      $create_user = sanitize_email($row['create_user']);
      $contents    = format_text($row['contents']);

      print("<h$heading><a name='_USER_COMMENT_$row[id]'>From</a> "
           ."$create_user, $create_date (score=$row[status])</h$heading>\n"
	   ."$contents\n");

      html_start_links();

      if ($LOGIN_LEVEL >= AUTH_DEVEL)
      {
        html_link("Edit", "${path}comment.php?e$row[id]+p$safeurl");
        html_link("Delete", "${path}comment.php?d$row[id]+p$safeurl");
      }

      html_link("Reply", "${path}comment.php?r$row[id]+p$safeurl");

      if ($modpoints > 0)
      {
	if ($row['status'] > 0)
          html_link("Moderate Down", "${path}comment.php?md$row[id]+p$safeurl");

	if ($row['status'] < 5)
          html_link("Moderate Up", "${path}comment.php?mu$row[id]+p$safeurl");
      }

      html_end_links();
    }

    $num_comments += show_comments($url, $path, $row['id'], $heading + 1);
  }

  db_free($result);

  if ($div)
    print("</div>\n");

  return ($num_comments);
}
示例#7
0
function				// O - Email address
auth_user_email($username)		// I - Username
{
  $result = db_query("SELECT * FROM users WHERE "
                    ."name = '" . db_escape($username) . "'");
  if (db_count($result) == 1)
  {
    $row = db_next($result);
    $email = $row["email"];
  }
  else
    $email = "";

  db_free($result);

  return ($email);
}