PDA

View Full Version : Alerts



Robbie..
19-12-2005, 05:31 PM
How do you make an alerts system, like when DJ's Log in to a control panel, they can make alerts which pop up on the main site

Example:

----------------
DJ Panel

Click here to make an alert

-----------------
Alerts Page

Type in your alert

Remember about the competition everybody!
--------------------
Main Website

Alert from DJ Whatever: Remember about the competition everybody
------------------------

And it comes up in a Javascript alert.

Get me?

+rep to helpers

Robbie..
19-12-2005, 06:02 PM
Bump.

Sozmod.

Rou
19-12-2005, 06:07 PM
Ive got one , something to do with mysql

timROGERS
19-12-2005, 06:08 PM
Probably could be done with PHP and MySQL

Robbie..
19-12-2005, 06:13 PM
Anyone have a tutorial or know where I could get the script?

Dan Williamson
19-12-2005, 09:42 PM
Your talking about a DJ says program?

If so..

There are two very basic ways of doing this.

1) This is the newbs way and the way Habbox Live do it ( no offence )

You can use cutenews and give all DJ's access too the cutenews account to post and just include it in a table with a DJ says header.

2) If you don't know what PHP is then don't bother.

You can make a advanced PHP form and then just re-direct it into your table or div whatever you have. Then you could password protect the directory in which the form is located with HTaccess or whatever.

Then you could give the DJ's access to the PP directory and they could post on the form so it would give out the messege on the DJ says table.

I can make these scripts for £5 so if you want one making and customizing too fit in with the look on your website I can do that.

- Dan

Luckyrare
19-12-2005, 10:10 PM
I am working on a txt based version ;) I may sell...

TwoWorlds
19-12-2005, 10:32 PM
text based is not as safe im sure sql / php is best :)

Newsie
19-12-2005, 10:50 PM
Text based is not as safe im sure sql / php is best.

http://img390.imageshack.us/img390/8997/owl21xr.gif


Newsie

TwoWorlds
19-12-2005, 10:57 PM
what is with people and them owls? ;]

Newsie
19-12-2005, 11:06 PM
Back on topic. This link may helpeh.

http://www.habboshed.com/forum2/showpost.php?p=360&postcount=2


Newsie

Dan Williamson
19-12-2005, 11:07 PM
Ok Newsie.

Your getting sad and immature now..

- Dan

Newsie
19-12-2005, 11:09 PM
Sorreh, just had to post that LAST owl. ;P

Back on topic. Teh link may help, heh.

http://www.habboshed.com/forum2/showpost.php?p=360&postcount=2


Newsie

Robbie..
20-12-2005, 04:55 PM
The script isn't working.

It says:

Parse error: parse error, unexpected ';' on line 3

it's at http://www.habbolido.co.uk/staffarea/alert/alert.php

Any coders or anything have any ideas?

Newsie
20-12-2005, 05:19 PM
http://www.habbolido.co.uk/home/lido/public_html/staffarea/alert/alert.php


Newsie

Dan Williamson
20-12-2005, 05:21 PM
Told you if you want one doing properly.

I'll do it for £5 in Paypal.

Cheap price.

- Dan

Robbie..
20-12-2005, 05:23 PM
Dan, I don't mean a DJ Says I mean a Javascript Alert Popup System.

Dan Williamson
20-12-2005, 05:25 PM
Ahh

That would be just as easy.

You could just password protect a directory.

Give the user permission and then they could add the javascript promt or whatever too the page and then you use a PHP include to include it and it would come up.

I could also do this feature, for £5

- Dan

Robbie..
20-12-2005, 05:28 PM
No Paypal money, lol.

Know whats up with the one Newsie mentioned?

Dan Williamson
20-12-2005, 05:29 PM
MySQL error or a PHP error.

- Dan

Robbie..
20-12-2005, 05:32 PM
There is no SQL needed with it.


<head>
<script language="javascript" type="text/javascript"> alert('
<? echo(file_get_contents("alert.txt"); ?>
'); </script> is the code.

Dan Williamson
20-12-2005, 05:33 PM
Have you created alert.txt and CHMOD'd it?

- Dan

Robbie..
20-12-2005, 05:37 PM
Yes.

http://www.habbolido.co.uk/staffarea/alert/alert.php

http://www.habbolido.co.uk/staffarea/alert/alert.txt (Chmod 666)

Dan Williamson
20-12-2005, 05:38 PM
Not sure then.

- Dan

Luckyrare
20-12-2005, 05:59 PM
<?
echo "<script language='javascript' type='text/javascript'> alert('";
include "alert.txt";
echo "'); </script>";
?>

That should work.

Robbie..
20-12-2005, 07:43 PM
w00t it worked thanks <3

Now, this will probably be simple, but I need a simple php script or whatever that will write a new message to the alert.txt file by typing it in a text box or something.

Rob

Luckyrare
20-12-2005, 08:40 PM
I won't do the HTML because its to easy, but heres the php


<?
if ($_SERVER['REQUEST_METHOD'] != 'GET'){
$alert= $_POST['alert'];
$file = fopen("alert.txt", "w+");
fputs($file, $alert);
fclose($file);
echo "'$alert' has been broadcasted!";
?>

Create a form with a text box called alert

Hope this helped ;)

Luckyrare
20-12-2005, 08:53 PM
*sigh*
Change the Username password and database name. Also you might want to chage the bit about Message from ....
Run this SQL:


CREATE TABLE `alert` (
`ID` INT( 4 ) NOT NULL AUTO_INCREMENT ,
`message` TEXT NOT NULL ,
`active` CHAR( 1 ) NOT NULL ,
PRIMARY KEY ( `ID` )
) TYPE = MYISAM ;

Alert.php :


<?
$dbName = "yourdatabasename";
$dbUser = "dbusername";
$dbPass = "dbpass";
// Connect
mysql_connect ("localhost", "$dbUser", "$dbPass");
mysql_select_db ("$dbName");

// Get Alert
$alertQuery = mysql_query("SELECT * FROM alert WHERE active='Y'");
if(mysql_num_rows($alertQuery) =="1"){
$alertData = mysql_fetch_array($alertQuery);

if($_COOKIE[$alertData[ID]] !="Y"){
$y = "Y";
setcookie($alertData[ID], $y);
Echo"
<script language='javascript'>alert('$alertData[message]');</script>";
}
}


Echo"<META HTTP-EQUIV='refresh' content='60;URL=alert.php'>";
Echo"$_COOKIE[$alertDataID]"
?>

Smack this file in a secure directory or add some nifty PHP codeing to it your self:


<?
$dbName = "dbname";
$dbUser = "user";
$dbPass = "pass";
// Connect
mysql_connect ("localhost", "$dbUser", "$dbPass");
mysql_select_db ("$dbName");

switch($_GET['act']){
default:
// Alert Data
$alertQuery = mysql_query("SELECT * FROM alert WHERE active='Y'");
$alertData = mysql_fetch_array($alertQuery);

if($alertData[message] !=""){
$Var ="<u>Current Active Alert</u>: $alertData[message] [<a href='alert.php?act=deactivate'>Deactivate</a>]";
}

Echo"<center><b>Alert Script Control Panel</b></center>
<u>NOTE:</u> You can only have one alert at one time. Once you want people to
stop being alerted, you will have to deactive it below. Creating a new alert
will delete the old one.<br>

$Var

<hr width='100%' height='1' color='#000000' shade='no'>

<form method='post' action='alert.php?act=create'>
Message:<br>
<textarea name='message' cols='30' rows='6'>Keep the message short</textarea><br>
<input type='submit' value='Create'>
</form>";
break;

case"create":
$message = "From your sites name DJ: ". $_POST['message'];

if(empty($message)){
Echo"<b>Error:</b> Please fill out the message.";
exit;
}
mysql_query("UPDATE alert SET active ='N'");
mysql_query("INSERT INTO alert (message,active) VALUES ('$message','Y')");

Echo"<b>Alert Added Sucessfully</b><br>
All other alerts have been deactivated. All users will recieve this alert
once, until you deactivate it.";
break;

case"deactivate":
mysql_query("UPDATE alert SET active ='N'");
Echo"<b>Alerts Deactivated</b><br>
All previous alerts have been deactivated.";
break;

}
?>


Or you could do it that way *sigh*

Will that also only send the alert once?

Tomm
20-12-2005, 08:55 PM
Or you could do it that way *sigh*

Its better because it dosent keep showing the alert to the vister everytime the alert.php refreshes lol xD

Robbie..
20-12-2005, 09:39 PM
Thanks.

But it aint working.

http://www.wackyhabbo.co.uk/hab-tastic/alerts/alert.php is just blank and shows no alert

and http://www.wackyhabbo.co.uk/hab-tastic/alerts/script.php becomes blank when you have typed a message.

Any suggestions anyone? <3

Luckyrare
20-12-2005, 09:58 PM
Its better because it dosent keep showing the alert to the vister everytime the alert.php refreshes lol xD
To true.

Luckyrare
20-12-2005, 09:59 PM
Try editing the sql by hand and test if it the alert works ;)

Edit: I think this is the first time I have double posted. I think "_"


Sorry

Robbie..
21-12-2005, 04:29 PM
Nope, and I don't know where I edit it anyway :p

And I changed localhost to freemysql.net on the settings if thats anything to do with it.

Robbie..
21-12-2005, 05:45 PM
OK I have it sorta up. It says an error at http://www.habbolido.co.uk/staffarea/alert.php the line in question is

Echo"$_COOKIE[$alertData[ID]]"

Luckyrare
21-12-2005, 06:56 PM
Echo"$_COOKIE[$alertData[ID]]"

>


echo "$_COOKIE[$alertData[ID]]";

Also you shouldnt really have to change localhost

Robbie..
21-12-2005, 07:17 PM
Sorry I can't add rep LuckyRare :(

Anyways, this is really annoying me now, it says an error, view it at http://www.habbolido.co.uk/staffarea/alert.php


<?
$dbName = "********";
$dbUser = "********";
$dbPass = "********";
// Connect
mysql_connect ("localhost", "$dbUser", "$dbPass");
mysql_select_db ("$dbName");

// Get Alert
$alertQuery = mysql_query("SELECT * FROM alert WHERE active='Y'");
if(@mysql_num_rows($alertQuery) =="1"){
$alertData = @mysql_fetch_array($alertQuery);

if($_COOKIE[$alertData[ID]] !="Y"){
$y = "Y";
setcookie($alertData[ID], $y);
Echo"
<script language='javascript'>alert('$alertData[message]');</script>";
}
}


Echo"<META HTTP-EQUIV='refresh' content='60;URL=alert.php'>";
echo "$_COOKIE[$alertData[ID]]";
?>
is the code :@

Edit: In the original code it said
$_COOKIE[$alertDataID] but that couldn't possibly work as all the code is set to
[$alertData[ID]]

Robbie..
21-12-2005, 07:30 PM
BTW SQL is configured correcty.

Newsie
21-12-2005, 09:04 PM
I think this is the first time I have double posted. I think. Sorry.

Heh, you shall remember teh moment.


Newsie

Tomm
22-12-2005, 07:48 PM
Dude it works fine for me. You really shouldent need to change localhost. Also you need to make sure PHP Safe Mode is turned off I think. Plus why are you trying to echo the ID :s

Want to hide these adverts? Register an account for free!