Location: PHPKode > projects > ProNuke. Postnuke To Oracle > postnuke/html/modules/Messages/functions.php
<?php
// File: $Id: functions.php,v 1.15 2001/12/03 23:03:45 gregorrothfuss 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
// ----------------------------------------------------------------------
// Original Author of file: Francisco Burzi
// Purpose of file: Part of phpBB integration
//   Copyright (c) 2001 by
//   Richard Tirtadji AKA King Richard (hide@address.com)
//   Hutdik Hermawan AKA hotFix (hide@address.com)
//   http://www.phpnuke.web.id/
// ----------------------------------------------------------------------

if (!defined("LOADED_AS_MODULE")) {
         die ("You can't access this file directly...");
     }

/* Check our database connection */

if($dbconn->ErrorNo()<>0) {
    die("<font class=\"pn-title\">An Error Occured</font><hr><font class=\"pn-normal\">phpBB was unable to connect to the database. <BR>Please check $dbhost, $dbuser, and $dbpasswd in config.php.</font>");
}

/* Code for the LastVisit cookie */

if (isset($HTTP_COOKIE_VARS["LastVisit"])) {
    $userdata["lastvisit"] = $HTTP_COOKIE_VARS["LastVisit"];
} else {
    $value = date("Y-m-d H:i");

    /* one year 'til expiry */
    $time = (time() + 3600 * 24 * 7 * 52);

    setcookie("LastVisit", $value, $time);
}

list($day, $time) = split(" ", $userdata['lastvisit']);
list($hour, $min) = split(":", $time);
$this_min = date("i");
$this_hour = date("H");
$this_day = date("Y-m-d");

/* Only set the last visit cookie if 10 mins have gone by, or its the next day or hour or something... */
/* This is kinda ugly but it works :) */
if (($this_day > $day) || ($this_hour > $hour) || (($this_min - 10) > $min)) {
    $value = date("Y-m-d H:i");
    $time = (time() + 3600 * 24 * 7 * 52);
    setcookie("LastVisit", $value, $time);
}

//$column = &$pntable['config_column'];
//$sql = "SELECT $column[allow_html], $column[allow_bbcode], $column[allow_sig], $column[posts_per_page], $column[hot_threshold], $column[topics_per_page] FROM $pntable[config]";
//$result = $dbconn->query($sql);
//if(!DB::isError($result)) {
//    if($myrow = $result->fetchRow(DB_FETCHMODE_ASSOC)) {
//        $allow_html = $myrow["allow_html"];
//        $allow_bbcode = $myrow["allow_bbcode"];
//        $allow_sig = $myrow["allow_sig"];
//        $posts_per_page = $myrow["posts_per_page"];
//        $hot_threshold = $myrow["hot_threshold"];
//        $topics_per_page = $myrow["topics_per_page"];
//    }
//}

function putitems() {
    echo "<font class=\"pn-normal\">Click on the <a href=\"modules/Messages/bb_smilies.php\">Smilies</a> to insert it on your Message:</font><br>";
    echo "<A href=\"javascript: x()\" onClick=\"DoSmilie(' :-) ');\"><IMG width=\"15\" height=\"15\" src=\"images/smilies/icon_smile.gif\" border=\"0\" alt=\":-)\" hspace=\"5\"></A>";
    echo "<A href=\"javascript: x()\" onClick=\"DoSmilie(' :-( ');\"><IMG width=\"15\" height=\"15\" src=\"images/smilies/icon_frown.gif\" border=\"0\" alt=\":-(\" hspace=\"5\"></A>";
    echo "<A href=\"javascript: x()\" onClick=\"DoSmilie(' :-D ');\"><IMG width=\"15\" height=\"15\" src=\"images/smilies/icon_biggrin.gif\" border=\"0\" alt=\":-D\" hspace=\"5\"></A>";
    echo "<A href=\"javascript: x()\" onClick=\"DoSmilie(' ;-) ');\"><IMG width=\"15\" height=\"15\" src=\"images/smilies/icon_wink.gif\" border=\"0\" alt=\";-)\" hspace=\"5\"></A>";
    echo "<A href=\"javascript: x()\" onClick=\"DoSmilie(' :-o ');\"><IMG width=\"15\" height=\"15\" src=\"images/smilies/icon_eek.gif\" border=\"0\" alt=\":-0\" hspace=\"5\"></A>";
    echo "<A href=\"javascript: x()\" onClick=\"DoSmilie(' 8-) ');\"><IMG width=\"15\" height=\"15\" src=\"images/smilies/icon_cool.gif\" border=\"0\" alt=\"8-)\" hspace=\"5\"></A>";
    echo "<A href=\"javascript: x()\" onClick=\"DoSmilie(' :-? ');\"><IMG width=\"15\" height=\"22\" src=\"images/smilies/icon_confused.gif\" border=\"0\" alt=\":-?\" hspace=\"5\"></A>";
    echo "<A href=\"javascript: x()\" onClick=\"DoSmilie(' :-P ');\"><IMG width=\"15\" height=\"15\" src=\"images/smilies/icon_razz.gif\" border=\"0\" alt=\":-P\" hspace=\"5\"></A>";
    echo "<A href=\"javascript: x()\" onClick=\"DoSmilie(' :-| ');\"><IMG width=\"15\" height=\"15\" src=\"images/smilies/icon_mad.gif\" border=\"0\" alt=\":-|\" hspace=\"5\"></A>";
    echo "<br><br>";
    echo "<font class=\"pn-normal\">Click on the buttoms to add <a href=\"modules/Messages/bbcode_ref.php\">BBCode</a> to your message:</font><br><br>";
    echo "<A href=\"javascript: x()\" onClick=\"DoPrompt('url');\"><IMG src=\"images/global/b_url.gif\" width=\"83\" height=\"21\" border=\"0\" alt=\"BBCode: Web Address\"></A>\n";
    echo "<A href=\"javascript: x()\" onClick=\"DoPrompt('email');\"><IMG src=\"images/global/b_email.gif\" width=\"83\" height=\"21\" border=\"0\" alt=\"BBCode: Email Address\"></A>\n";
    echo "<A href=\"javascript: x()\" onClick=\"DoPrompt('image');\"><IMG src=\"images/global/b_image.gif\" width=\"83\" height=\"21\" border=\"0\" alt=\"BBCode: Load Image from Web\"></A>\n";
    echo "<A href=\"javascript: x()\" onClick=\"DoPrompt('bold');\"><IMG src=\"images/global/b_bold.gif\" width=\"83\" height=\"21\" border=\"0\" alt=\"BBCode: Bold Text\"></A>\n";
    echo "<A href=\"javascript: x()\" onClick=\"DoPrompt('italic');\"><IMG src=\"images/global/b_italic.gif\" width=\"83\" height=\"21\" border=\"0\" alt=\"BBCode: Italic Text\"></A>\n";
    echo "<A href=\"javascript: x()\" onClick=\"DoPrompt('quote');\"><IMG src=\"images/global/b_quote.gif\" width=\"83\" height=\"21\" border=\"0\" alt=\"BBCode: Quote\"></A>\n";
    echo "<A href=\"javascript: x()\" onClick=\"DoPrompt('code');\"><IMG src=\"images/global/b_code.gif\" width=\"83\" height=\"21\" border=\"0\" alt=\"BBCode: Code\"></A>\n";
    echo "<A href=\"javascript: x()\" onClick=\"DoPrompt('listopen');\"><IMG src=\"images/global/b_listopen.gif\" width=\"83\" height=\"21\" border=\"0\" alt=\"BBCode: Open List\"></A>\n";
    echo "<A href=\"javascript: x()\" onClick=\"DoPrompt('listitem');\"><IMG src=\"images/global/b_listitem.gif\" width=\"83\" height=\"21\" border=\"0\" alt=\"BBCode: List Item\"></A>\n";
    echo "<A href=\"javascript: x()\" onClick=\"DoPrompt('listclose');\"><IMG src=\"images/global/b_listclose.gif\" width=\"83\" height=\"21\" border=\"0\" alt=\"BBCode: Close List\"></A>\n";
}

/**

 * Nathan Codding - July 19, 2000

 * Checks the given password against the DB for the given username. Returns true if good, false if not.

 */
function check_user_pw($username, $password, $db, $system) {
    global $pntable, $dbconn;
    $password = md5($password);
    $column = &$pntable['users_column'];
    $sql = "SELECT count($column[uid]) FROM $pntable[users] WHERE ($column[uname] = '$username') AND ($column[pass] = '$password')";
    $resultID = $dbconn->Execute($sql);
    list($found) = $resultID->fields;
    return $found;
} // check_user_pw()


/**

 * Nathan Codding - July 19, 2000

 * Returns a count of the given userid's private messages.

 */
function get_pmsg_count($user_id, $db) {
    global $pntable, $dbconn;
    $column = &$pntable['priv_msgs_column'];
    $sql = "SELECT count($column[msg_id]) FROM $pntable[priv_msgs] WHERE ($column[to_userid] = $user_id)";
    $resultID = $dbconn->Execute($sql);
    list($count) = $resultID->fields;
    return $count;
} // get_pmsg_count()


/**

 * Nathan Codding - July 19, 2000

 * Checks if a given username exists in the DB. Returns true if so, false if not.

 */
function check_username($username, $db) {
    global $pntable, $dbconn;
    $column = &$pntable['users_column'];
    $sql = "SELECT count($column[uid]) FROM $pntable[users] WHERE ($column[uname] = '$username')";
    $resultID = $dbconn->Execute($sql);
    $valid = $resultID->fields;
    return $valid;
} // check_username()


/**

 * Nathan Codding, July 19/2000

 * Get a user's data, given their user ID.

 */

function get_userdata_from_id($userid, $db) {
    global $pntable, $dbconn;
    $column = &$pntable['users_column'];
    $sql = getSelectAllColumnsFrom ('users', "$column[uid]=$userid");
    $result = $dbconn->Execute($sql);
    if($dbconn->ErrorNo()<>0) {
        $userdata = array("error" => "1");
        return ($userdata);
    }
    if(!$myrow = $result->GetRowAssoc(false)) {
    $result->MoveNext();
        $userdata = array("error" => "1");
        return ($userdata);
    }
     return($myrow);
}

function get_userdata($username, $db) {
    global $pntable, $dbconn;
    $column = &$pntable['users_column'];
    $sql = getSelectAllColumnsFrom ('users', "$column[uname]='$username'");
    $result = $dbconn->Execute($sql);
    if($dbconn->ErrorNo()<>0) {
        $userdata = array("error" => "1");
    }
    else if(!$myrow = $result->GetRowAssoc(false)) {
    $result->MoveNext();
        $userdata = array("error" => "1");
    }
     return($myrow);
}

function smile($message) {
    $message = str_replace(":)", "<IMG SRC=\"images/smilies/icon_smile.gif\">", $message);
    $message = str_replace(":-)", "<IMG SRC=\"images/smilies/icon_smile.gif\">", $message);
    $message = str_replace(":(", "<IMG SRC=\"images/smilies/icon_frown.gif\">", $message);
    $message = str_replace(":-(", "<IMG SRC=\"images/smilies/icon_frown.gif\">", $message);
    $message = str_replace(":-D", "<IMG SRC=\"images/smilies/icon_biggrin.gif\">", $message);
    $message = str_replace(":D", "<IMG SRC=\"images/smilies/icon_biggrin.gif\">", $message);
    $message = str_replace(";)", "<IMG SRC=\"images/smilies/icon_wink.gif\">", $message);
    $message = str_replace(";-)", "<IMG SRC=\"images/smilies/icon_wink.gif\">", $message);
    $message = str_replace(":o", "<IMG SRC=\"images/smilies/icon_eek.gif\">", $message);
    $message = str_replace(":O", "<IMG SRC=\"images/smilies/icon_eek.gif\">", $message);
    $message = str_replace(":-o", "<IMG SRC=\"images/smilies/icon_eek.gif\">", $message);
    $message = str_replace(":-O", "<IMG SRC=\"images/smilies/icon_eek.gif\">", $message);
    $message = str_replace("8)", "<IMG SRC=\"images/smilies/icon_cool.gif\">", $message);
    $message = str_replace("8-)", "<IMG SRC=\"images/smilies/icon_cool.gif\">", $message);
    $message = str_replace(":?", "<IMG SRC=\"images/smilies/icon_confused.gif\">", $message);
    $message = str_replace(":-?", "<IMG SRC=\"images/smilies/icon_confused.gif\">", $message);
    $message = str_replace(":p", "<IMG SRC=\"images/smilies/icon_razz.gif\">", $message);
    $message = str_replace(":P", "<IMG SRC=\"images/smilies/icon_razz.gif\">", $message);
    $message = str_replace(":-p", "<IMG SRC=\"images/smilies/icon_razz.gif\">", $message);
    $message = str_replace(":-P", "<IMG SRC=\"images/smilies/icon_razz.gif\">", $message);
    $message = str_replace(":-|", "<IMG SRC=\"images/smilies/icon_mad.gif\">", $message);
    $message = str_replace(":|", "<IMG SRC=\"images/smilies/icon_mad.gif\">", $message);
    return($message);
}

function desmile($message) {
    $message = str_replace("<IMG SRC=\"images/smilies/icon_smile.gif\">", ":-)",  $message);
    $message = str_replace("<IMG SRC=\"images/smilies/icon_frown.gif\">", ":-(", $message);
    $message = str_replace("<IMG SRC=\"images/smilies/icon_biggrin.gif\">",":-D",  $message);
    $message = str_replace("<IMG SRC=\"images/smilies/icon_wink.gif\">", ";-)", $message);
    $message = str_replace("<IMG SRC=\"images/smilies/icon_eek.gif\">", ":-o", $message);
    $message = str_replace("<IMG SRC=\"images/smilies/icon_eek.gif\">", ":-O", $message);
    $message = str_replace("<IMG SRC=\"images/smilies/icon_cool.gif\">", "8-)", $message);
    $message = str_replace("<IMG SRC=\"images/smilies/icon_confused.gif\">", ":-?", $message);
    $message = str_replace("<IMG SRC=\"images/smilies/icon_razz.gif\">", ":-p", $message);
    $message = str_replace("<IMG SRC=\"images/smilies/icon_razz.gif\">", ":-P", $message);
    $message = str_replace("<IMG SRC=\"images/smilies/icon_mad.gif\">", ":-|", $message);

    return($message);
}

/* modified by Sebastien, oct 2001. */
/* I extract pn_bbencode() and pn_bbdecode() from there, in order to use them for Wiki and bbCode
translation. I was not able to include directly functions.php because it was trying to 
open tables, databases, strange for a procedure file non ? */
include_once('modules/Messages/bbcode.lib.php');


/**

 * Modified by Nathan Codding - July 20, 2000.

 * Made it only work on URLs and e-mail addresses preceeded by a space, in order to stop
 * mangling HTML code.

 * The Following function was taken from the Scriplets area of http://www.phpwizard.net, and was written by Tobias Ratschiller.
 */

function make_clickable($text) {
    $ret = eregi_replace(" ([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])", " <a href=\"\\1://\\2\\3\" target=\"_blank\" target=\"_new\">\\1://\\2\\3</a>", $text);
    $ret = eregi_replace(" (([a-z0-9_]|\\-|\\.)+@([^[:space:]]*)([[:alnum:]-]))", " <a href=\"mailto:\\1\" target=\"_new\">\\1</a>", $ret);
    return($ret);
}

function forumerror($e_code) {
    global $sitename, $header, $footer;

    if ($e_code == "0005") {
    $error_msg = ""._MSGERROR0005."";
    }
    if ($e_code == "0017") {
    $error_msg = ""._MSGERROR0017."";
    }
    if ($e_code == "0018") {
    $error_msg = ""._MSGERROR0018."";
    }
    if ($e_code == "0019") {
    $error_msg = ""._MSGERROR0019."";
    }
    if ($e_code == "0020") {
    $error_msg = ""._MSGERROR0020."";
    }
    if ($e_code == "0021") {
    $error_msg = ""._MSGERROR0021."";
    }
    if ($e_code == "0022") {
    $error_msg = ""._MSGERROR0022."";
    }
    if ($e_code == "0023") {
    $error_msg = ""._MSGERROR0023."";
    }
    if ($e_code == "0024") {
    $error_msg = ""._MSGERROR0024."";
    if (!isset($header)) {
    include("header.php");
    }
    }
    OpenTable2();
    echo "<center><font class=\"pn-title\"><b>"._MSGERROR."</b></font><br/><br/><br/>";
    echo "<font class=\"pn-normal\">$error_msg</font><br/><br/><br/>";
    echo "[ <a class=\"pn-normal\" href=\"javascript:history.go(-1)\">"._MSGGOBACK."</a> ]<br/><br/>";
    CloseTable2();
    include("footer.php");
    die("");
}

?>
Return current item: ProNuke. Postnuke To Oracle