L* R*
HOME FORUM DOWNLOADS
Content
  Links
     Browse SVN
     SVN Commit log
     Documentation (Wiki)
  Developers
     Taskmanager
User
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 02, 2008, 03:05:54 PM

Login with username, password and session length
Search



Advanced search
Support GoPHP5.org
BeBot - An Anarchy Online/Age Of Conan chat automaton > Forum > Modules > Official modules > Topic: Modified News.php
Pages: [1] 2   Go Down
« previous next »
Print
Author Topic: Modified News.php  (Read 2564 times)
0 Members and 1 Guest are viewing this topic.
Zarkingu
Rookie
**
Offline Offline

Posts: 34


Modified News.php
« on: December 13, 2005, 03:41:46 PM »

Modified Blondengy's News.php with a !headline command.

Modified News.php

Probably not very good programming, still just a beginner with PHP  Grin
It works whough  Smiley
« Last Edit: December 13, 2005, 03:58:39 PM by Zarkingu » Logged

Zarkingu 210 MP RK2
Naturalistic
BeBot Contributor
Experienced
*******
Offline Offline

Posts: 221


Re: Modified News.php
« Reply #1 on: December 13, 2005, 05:00:42 PM »

Going to be doing a big change to the !news function, I'll post it once I finish Smiley

Lack of control of news items sucks Tongue
Logged

220/25 Eternalist Doctor
-----------------------------
Campalot Coding Co-ordinator and Super Admin
http://www.campalot.info/index.php
Khalem
BeBot Founder
Administrator
Grandmaster
********
Offline Offline

Gender: Male
Posts: 670



WWW
Re: Modified News.php
« Reply #2 on: December 13, 2005, 07:16:42 PM »

Quote from: Naturalistic on December 13, 2005, 05:00:42 PM
Going to be doing a big change to the !news function, I'll post it once I finish Smiley

Lack of control of news items sucks Tongue

Amen. Hence why its a big item on my Todo list Tongue
I'll hold of on my plans until youve posted yours Naturalistic.
I can however mention the very basic changes i had in mind from current 0.2.x:
- ID field should be just that, a unique ID. Its possible, but not probable that two news items be added at the same time. For interoperability and standards sake, id's should be autoincrement integer values starting at 1. (A convert function should take the old timestamp based ID's and enter new id's starting from 1, and timestamps should be their own field)
- Admins/Superadmins should be able to delete any news item, and posters should be allowed to delete their own posts.
- The ability to sticky news items (integer 0/1 field in database)
- The ability to configure the number of sticky newsitems to display aswell as the number of newsitems to be displayed.
- Admins should have the ability to list any number of news items for.. err.. administrative purposes. Ie a !news show x   where x is an integer value.
- Potentially merge the Raids module into the News module as they are basically the same, only with a different name. Again, probably integer 0/1 field in database.
« Last Edit: December 13, 2005, 07:18:25 PM by Khalem » Logged

BeBot Founder and Fixer Kingpin
Madman coder and destroyer of good code
Xenixa
BeBot Contributor
Expert
*******
Offline Offline

Posts: 307



Re: Modified News.php
« Reply #3 on: December 18, 2005, 08:28:44 AM »

Well I got board and did pretty much what you were looking at doing with the News module Khalem.

This version combines the Original News and Raids Modules by Foxferal, also includes updates/ideas by Naturalistic and Zarkingu.
Additional Database Fields added/changed:
 ID renamed to TIME, ID added to Auto Inc starting at 1
 TYPE field to Denote News Type I.E.: 1 = News, 2 = Headline, 3 = Raid News

Notes on Headline: I've written this one to were you can only have one Headline in the News Table at any given time. If a new headline is given it delete's the old one before it inserts the new one. The first time you do !news and no Headline is present it'll just show "No Headline's" at the top of the Info window.

xen.afraid.org/bebot_files/news.php

Giver a once over and lemme know what ya think.

EDIT: There is a commented ALTER TABLE statement included in the file above that will update the current News Table. Oh and either rename or remove Raids.php before using this. I still have yet to write a script to move entries from the Raids news table to the News table. Actually I did it by hand by performing the same ALTER TABLE script using the appropriet table name then exported the table to a .sql file and changing the INSERT INTO to news rather than raids before loading the sql file.
« Last Edit: December 18, 2005, 09:12:45 AM by Xenixa » Logged

<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky
Khalem
BeBot Founder
Administrator
Grandmaster
********
Offline Offline

Gender: Male
Posts: 670



WWW
Re: Modified News.php
« Reply #4 on: December 18, 2005, 01:23:29 PM »

Ohh nice.

I'll have a look at this one as soon as im done with the server move hell im in.
Logged

BeBot Founder and Fixer Kingpin
Madman coder and destroyer of good code
Akarah
BeBot Contributor
Rookie
*******
Offline Offline

Posts: 72


WWW
Re: Modified News.php
« Reply #5 on: December 19, 2005, 01:22:15 AM »

the news i had already came with
Code:
  $db -> query("CREATE TABLE IF NOT EXISTS news
              (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
              name VARCHAR(30),
              news TEXT,
        time INT NOT NULL)");

so using your update command fails because time already exists..

i think all that is needed in my case was

Code:
mysql> ALTER TABLE news, ADD COLUMN type INT DEFAULT '2' NULL  after id;

it worked at least Smiley
Logged
Akarah
BeBot Contributor
Rookie
*******
Offline Offline

Posts: 72


WWW
Re: Modified News.php
« Reply #6 on: December 19, 2005, 03:23:23 AM »

now that i think about it some more, setting the new column to type 1 might be more appropriate, since there can only be one headline... yea? Smiley

so either do the above line then:

Code:
mysql> UPDATE news SET type = 1 WHERE type = 2;

or just set the default to 1, assuming that doesn't break the script (i haven't looked closely)
Logged
Xenixa
BeBot Contributor
Expert
*******
Offline Offline

Posts: 307



Re: Modified News.php
« Reply #7 on: December 19, 2005, 04:02:49 AM »

Well what I was doing to make sure only 1 Headline entry exists is to have it remove any Type 2 entry before Setting the new one.

I.E. in the function set_headline
Code:
$this -> bot -> db -> query("DELETE FROM news WHERE type = '2'");
$this -> bot -> db -> query("INSERT INTO news (type, time, name, news) VALUES ('2' ," . time() .
  ", '" . $name . "', '" . addslashes($msg) . "')");

Seems to work pretty well as I havn't seen more than 1 Headline appear after changing it a couple times to test it.
Logged

<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky
Akarah
BeBot Contributor
Rookie
*******
Offline Offline

Posts: 72


WWW
Re: Modified News.php
« Reply #8 on: December 19, 2005, 04:08:08 AM »

i was just noting that when adding the new column, if you had previous news entries (i had about 10 or so) they would all get set to type 2, thus get deleted apparently ;p

Logged
Xenixa
BeBot Contributor
Expert
*******
Offline Offline

Posts: 307



Re: Modified News.php
« Reply #9 on: December 19, 2005, 06:41:10 AM »

OOOh ok I see what your saying, ya set default to 1, guess I should have updated that ALTER TABLE a bit more before stuffing it there. Originally I was gunna set Headlines to 1 and News to 2 but some how ended up going the other way around.
Logged

<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky
Xenixa
BeBot Contributor
Expert
*******
Offline Offline

Posts: 307



Re: Modified News.php
« Reply #10 on: December 19, 2005, 09:33:36 AM »

OOOOPS!!! I found a mistake in the copy I had on my ftp server.

Using !raids calls up Regular News and not Raid News. -- FIXED (copy on ftp server updated)
Logged

<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky
Khalem
BeBot Founder
Administrator
Grandmaster
********
Offline Offline

Gender: Male
Posts: 670



WWW
Re: Modified News.php
« Reply #11 on: December 25, 2005, 08:28:51 AM »

Im going to make some minor changes to your module Xenixa and add it to SVN Smiley
Logged

BeBot Founder and Fixer Kingpin
Madman coder and destroyer of good code
Khalem
BeBot Founder
Administrator
Grandmaster
********
Offline Offline

Gender: Male
Posts: 670



WWW
Re: Modified News.php
« Reply #12 on: January 31, 2006, 04:18:46 PM »

Heres my modified version.
- Slimmed it down a little bit
- Added last modified date to show in initial return line
- Added clicklinks for delete
- Allow multiple headlines to be added and also deleted. Currently set to display 3 headline items.
- More sane permission checks on deleting entries.

On a side note, there has to be a better way to treat the result from the MySQL query when you know there is only going to be one return, but i havent found one yet.

http://svn.shadow-realm.org:7100/svn/BeBot/trunk/modules/News.php
« Last Edit: February 02, 2006, 07:23:21 AM by Khalem » Logged

BeBot Founder and Fixer Kingpin
Madman coder and destroyer of good code
Xenixa
BeBot Contributor
Expert
*******
Offline Offline

Posts: 307



Re: Modified News.php
« Reply #13 on: February 01, 2006, 08:08:43 PM »

OOoh!! I like it, I been meaning to add those items myself. Well the click links and last updated bit in the reply. Smiley
I like the security updates also. I have to admit I didn't really put much thought into updating that.

Oh and some syntax errors in this posted version.
Line 163 - Missing an additional Quote before semi-colon. Corrected:>  $inside .= "<font color=CCInfoText>" . $val[3] . "";
Line 168 - 1 too many quotes. Corrected:>  $inside .= "\n\n";
Logged

<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky
Khalem
BeBot Founder
Administrator
Grandmaster
********
Offline Offline

Gender: Male
Posts: 670



WWW
Re: Modified News.php
« Reply #14 on: February 02, 2006, 07:23:49 AM »

Syntax errors was already fixed in SVN. Posting direct link instead Smiley

Some of the things im still planning to do:
- The number of items to show for news and possibly headlines should be configurable, but the settings table still needs a revamp
- x last raid entries shown in !news as with headline(s)
- The ability to "clicklink" convert a headline into ordinary news, and with this feature it might not be neccecary to be able to limit the number of headlines shown. Headlines afterall do become irrelevant with time and become "just news" anyways.
- Find a better way to pull a single result without doing the foreach loop.
- Move the command handler into a separate function to eliminate code duplication for each handler.
« Last Edit: February 02, 2006, 07:28:37 AM by Khalem » Logged

BeBot Founder and Fixer Kingpin
Madman coder and destroyer of good code
Pages: [1] 2   Go Up
Print
BeBot - An Anarchy Online/Age Of Conan chat automaton > Forum > Modules > Official modules > Topic: Modified News.php
« previous next »
 
Jump to:  

Recent
Log playtime from buddys ...
by IKShadow
[Today at 06:48:12 AM]

[request] Raid timers
by Elesar1
[December 01, 2008, 04:41:09 PM]

Shared DB online list
by Temar
[December 01, 2008, 01:55:47 AM]

relay colors
by Temar
[December 01, 2008, 01:54:56 AM]

BeBot v0.6.0 released
by Alreadythere
[November 30, 2008, 05:32:00 PM]

Change to Bid.php
by Temar
[November 30, 2008, 11:41:44 AM]

OnlineOrg
by Jiheld
[November 29, 2008, 12:44:27 PM]

Silly Newbie Question.
by Temar
[November 29, 2008, 12:00:02 PM]

massive_pvp_time_table 1
by gerborg
[November 29, 2008, 06:55:35 AM]

Bot not see Guild Chat
by Delvar
[November 28, 2008, 08:30:34 AM]
Stats
Members
Total Members: 1244
Latest: Armonkens
Stats
Total Posts: 11145
Total Topics: 1505
Online Today: 25
Online Ever: 168
(July 01, 2007, 09:30:02 PM)
Users Online
Users: 3
Guests: 16
Total: 19
Stealth
Kentarii
Ifris

Powered by SMF 1.1.7 | SMF © 2006-2008, Simple Machines LLC
TinyPortal v0.9.8 © Bloc | NewDef design by Bloc
Page created in 0.246 seconds with 29 queries. (Pretty URLs adds 0.035s, 4q)
Loading...