<?php // $Id: index.php,v 1.21 2001/12/05 22:43:14 nkame Exp $ $Name: $
// ----------------------------------------------------------------------
// POST-NUKE Content Management System
// Copyright (C) 2001 by the Post-Nuke Development Team.
// http://www.postnuke.com/
// ----------------------------------------------------------------------
// Based on:
// PHP-NUKE Web Portal System - http://phpnuke.org/
// Thatware - http://thatware.org/
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
// Filename: modules/Recommed_Us/index.php
// Original Author: Francisco Burzi
// Purpose: Recommend site/send articles to 'friends'
// ----------------------------------------------------------------------
if (!defined("LOADED_AS_MODULE")) {
die ("You can't access this file directly...");
}
include 'mainfile.php';
$ModName = basename( dirname( __FILE__ ) );
modules_get_language();
function FriendSend($sid) {
global $user, $cookie, $pntable, $dbconn, $ModName;
if(empty($sid)) {
exit();
}
include ("header.php");
$myts = new myTextSanitizer;
$column = &$pntable['stories_column'];
$result=$dbconn->Execute("SELECT $column[title] FROM $pntable[stories] WHERE $column[sid]=$sid");
list($title) = $result->fields;
$title = $myts->makeTareaData4Show($title);
if (!authorised(0, 'Recommend us::', '::', ACCESS_READ) || !authorised(0, 'Stories::', "$uname:$cattitle:$sid", ACCESS_READ)) {
echo _RECOMMENDUSNOAUTH;
include 'footer.php';
return;
}
OpenTable();
echo "<font class=\"pn-title\">"._FRIEND."</font><br><br>"
."<font class=\"pn-normal\">"._YOUSENDSTORY." <font class=\"pn-title\">$title</font><font class=\"pn-normal\"> "._TOAFRIEND."</font><br><br>"
."<form action=\"modules.php\" method=\"post\">"
."<input type=\"hidden\" name=\"op\" value=\"modload\">"
."<input type=\"hidden\" name=\"name\" value=\"$ModName\">"
."<input type=\"hidden\" name=\"file\" value=\"index\">"
."<input type=\"hidden\" name=\"sid\" value=\"$sid\">";
if (is_user($user)) {
$column = &$pntable['users_column'];
$result=$dbconn->Execute("select $column[name], $column[email] from $pntable[users] WHERE $column[uname]='$cookie[1]'");
list($yn, $ye) = $result->fields;
}
echo "<font class=\"pn-normal\">"._FYOURNAME." </font> <input type=\"text\" name=\"yname\" value=\"$yn\"><br>\n"
."<font class=\"pn-normal\">"._FYOUREMAIL." </font> <input type=\"text\" name=\"ymail\" value=\"$ye\"><br><br>\n"
."<font class=\"pn-normal\">"._FFRIENDNAME." </font> <input type=\"text\" name=\"fname\"><br>\n"
."<font class=\"pn-normal\">"._FFRIENDEMAIL." </font> <input type=\"text\" name=\"fmail\"><br><br>\n"
."<input type=\"hidden\" name=\"req\" value=\"SendStory\">\n"
."<input type=\"submit\" value="._SEND.">\n"
."</form>\n";
CloseTable();
include ('footer.php');
}
function SendStory($sid, $yname, $ymail, $fname, $fmail) {
global $sitename, $nukeurl, $pntable, $dbconn, $ModName;
$column = &$pntable['stories_column'];
$result2=$dbconn->Execute("SELECT $column[title], $column[time], $column[topic] FROM $pntable[stories] WHERE $column[sid]=$sid");
list($title, $time, $topic) = $result2->fields;
if (!authorised(0, 'Recommend us::', '::', ACCESS_READ) || !authorised(0, 'Stories::', "$uname:$cattitle:$sid", ACCESS_READ)) {
include 'header.php';
echo _RECOMMENDUSNOAUTH;
include 'footer.php';
return;
}
// Security checks
// 1) the name isn't too long
if (strlen($fname)>25) {
include 'header.php';
echo _NAMETOOLONG;
include 'footer.php';
return;
}
// 2) the email is valid
$fmail = pn_validation_mail($fmail);
if ($fmail == -1) {
include 'header.php';
echo _EMAILWRONG;
include 'footer.php';
return;
}
$column = &$pntable['topics_column'];
$result3=$dbconn->Execute("SELECT $column[topictext] FROM $pntable[topics] WHERE $column[topicid]=$topic");
list($topictext) = $result3->fields;
$subject = ""._INTERESTING." $sitename";
$message = ""._HELLO." $fname:\n\n"._YOURFRIEND." $yname "._CONSIDERED."\n\n\n$title\n("._FDATE." $time)\n"._FTOPIC." $topictext\n\n"._URL.": $nukeurl/modules.php?op=modload&name=News&file=article&sid=$sid\n\n"._YOUCANREAD." $sitename\n$nukeurl";
// 11-09-01 eugeniobaldi not compliant with PHP < 4.0.5
// mail($fmail, $subject, $message, "From: \"$yname\" <$ymail>\nX-Mailer: PHP/" . phpversion(), "-f$yname");
mail($fmail, $subject, $message, "From: \"$yname\" <$ymail>\nX-Mailer: PHP/" . phpversion());
$title = urlencode($title);
$fname = urlencode($fname);
pnRedirect('modules.php?op=modload&name='.$ModName.'&file=index');
}
function StorySent($title, $fname) {
include ("header.php");
$title = urldecode($title);
$fname = urldecode($fname);
OpenTable();
echo "<center><font class=\"pn-normal\">"._FSTORY." <b>$title</b> "._HASSENT." $fname... "._THANKS."</font></center>";
CloseTable();
include ("footer.php");
}
function RecommendSite() {
global $user, $cookie, $pntable, $dbconn, $ModName;
include ("header.php");
OpenTable();
if (!authorised(0, 'Recommend us::', '::', ACCESS_READ)) {
echo _RECOMMENDUSNOAUTH;
CloseTable();
include 'footer.php';
return;
}
echo "<center><font class=\"pn-pagetitle\">"._RECOMMEND."</font></center><br>";
CloseTable();
echo "<br/>";
OpenTable();
echo ""
."<form action=\"modules.php\" method=\"post\">"
."<input type=\"hidden\" name=\"op\" value=\"modload\">"
."<input type=\"hidden\" name=\"name\" value=\"$ModName\">"
."<input type=\"hidden\" name=\"file\" value=\"index\">"
."<input type=\"hidden\" name=\"req\" value=\"SendSite\">";
if (is_user($user)) {
$column = &$pntable['users_column'];
$result=$dbconn->Execute("SELECT $column[name], $column[email] FROM $pntable[users] WHERE $column[uname]='$cookie[1]'");
//ADODBtag list+row
list($yn, $ye) = $result->fields;
}
echo "
<table>
<tr>
<td>
<font class=\"pn-normal\">"._FYOURNAME." </font>
</td>
<td><input type=\"text\" name=\"yname\" value=\"$yn\">
</tr>
<tr>
<td>
<font class=\"pn-normal\">"._FYOUREMAIL." </font>
</td>
<td>
<input type=\"text\" name=\"ymail\" value=\"$ye\">
</td>
</tr>
<tr>
<td>
<font class=\"pn-normal\">"._FFRIENDNAME." </font>
</td>
<td>
<input type=\"text\" name=\"fname\">
</td>
</tr>
<tr>
<td>
<font class=\"pn-normal\">"._FFRIENDEMAIL." </font>
</td>
<td>
<input type=\"text\" name=\"fmail\">
</td>
</tr>
<tr>
<td colspan=\"2\">
<input type=\"submit\" value="._SEND.">
</td>
</tr>\n
</table>
</form>";
CloseTable();
include ('footer.php');
}
function SendSite($yname, $ymail, $fname, $fmail) {
global $sitename, $slogan, $nukeurl, $ModName;
if (!authorised(0, 'Recommend us::', '::', ACCESS_READ)) {
include 'header.php';
echo _RECOMMENDUSNOAUTH;
include 'footer.php';
return;
}
// Security checks
// 1) the name isn't too long
if (strlen($fname)>25) {
include 'header.php';
echo _NAMETOOLONG;
include 'footer.php';
return;
}
// 2) the email is valid
$fmail = pn_validation_mail($fmail);
if ($fmail == -1) {
include 'header.php';
echo _EMAILWRONG;
include 'footer.php';
return;
}
$subject = ""._INTSITE." $sitename";
$message = ""._HELLO." $fname:\n\n"._YOURFRIEND." $yname "._OURSITE." $sitename "._INTSENT."\n\n\n"._FSITENAME." $sitename\n$slogan\n"._FSITEURL." $nukeurl\n";
// 11-09-01 eugeniobaldi not compliant with PHP < 4.0.5
// mail($fmail, $subject, $message, "From: \"$yname\" <$ymail>\nX-Mailer: PHP/" .phpversion(), "-f$yname");
mail($fmail, $subject, $message, "From: \"$yname\" <$ymail>\nX-Mailer: PHP/" .phpversion());
pnRedirect('modules.php?op=modload&name='.$ModName.'&file=index');
}
function SiteSent($fname) {
include ('header.php');
OpenTable();
echo "<center><font class=\"pn-normal\">"._FREFERENCE." $fname...<br><br>"._THANKSREC."</font></center>";
CloseTable();
include ('footer.php');
}
switch($req) {
case "SendStory":
SendStory($sid, $yname, $ymail, $fname, $fmail);
break;
case "StorySent":
StorySent($title, $fname);
break;
case "SendSite":
SendSite($yname, $ymail, $fname, $fmail);
break;
case "SiteSent":
SiteSent($fname);
break;
case "FriendSend":
FriendSend($sid);
break;
default:
RecommendSite();
break;
}
?>