collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18363
  • stats Total Topics: 2500
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: Modified News.php  (Read 13071 times)

0 Members and 1 Guest are viewing this topic.

Offline Zarkingu

  • Contributor
  • *******
  • Posts: 34
  • Karma: +0/-0
Modified News.php
« on: December 13, 2005, 09: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  ;D
It works whough  :)
« Last Edit: December 13, 2005, 09:58:39 pm by Zarkingu »
Zarkingu 210 MP RK2

Offline Naturalistic

  • Contributor
  • *******
  • Posts: 221
  • Karma: +0/-0
Re: Modified News.php
« Reply #1 on: December 13, 2005, 11:00:42 pm »
Going to be doing a big change to the !news function, I'll post it once I finish :)

Lack of control of news items sucks :P
220/25 Eternalist Doctor
-----------------------------
Campalot Coding Co-ordinator and Super Admin
http://www.campalot.info/index.php

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
Re: Modified News.php
« Reply #2 on: December 14, 2005, 01:16:42 am »
Going to be doing a big change to the !news function, I'll post it once I finish :)

Lack of control of news items sucks :P

Amen. Hence why its a big item on my Todo list :P
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 14, 2005, 01:18:25 am by Khalem »
BeBot Founder and Fixer Kingpin

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
Re: Modified News.php
« Reply #3 on: December 18, 2005, 02:28:44 pm »
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, 03:12:45 pm by Xenixa »
<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
Re: Modified News.php
« Reply #4 on: December 18, 2005, 07: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.
BeBot Founder and Fixer Kingpin

Offline Akarah

  • Contributor
  • *******
  • Posts: 72
  • Karma: +0/-0
    • http://synergyfactor.net/
Re: Modified News.php
« Reply #5 on: December 19, 2005, 07:22:15 am »
the news i had already came with
Code: [Select]
  $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: [Select]
mysql> ALTER TABLE news, ADD COLUMN type INT DEFAULT '2' NULL  after id;

it worked at least :)

Offline Akarah

  • Contributor
  • *******
  • Posts: 72
  • Karma: +0/-0
    • http://synergyfactor.net/
Re: Modified News.php
« Reply #6 on: December 19, 2005, 09: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? :)

so either do the above line then:

Code: [Select]
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)

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
Re: Modified News.php
« Reply #7 on: December 19, 2005, 10: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: [Select]
$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.
<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky

Offline Akarah

  • Contributor
  • *******
  • Posts: 72
  • Karma: +0/-0
    • http://synergyfactor.net/
Re: Modified News.php
« Reply #8 on: December 19, 2005, 10: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


Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
Re: Modified News.php
« Reply #9 on: December 19, 2005, 12:41:10 pm »
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.
<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
Re: Modified News.php
« Reply #10 on: December 19, 2005, 03:33:36 pm »
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)
<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
Re: Modified News.php
« Reply #11 on: December 25, 2005, 02:28:51 pm »
Im going to make some minor changes to your module Xenixa and add it to SVN :)
BeBot Founder and Fixer Kingpin

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
Re: Modified News.php
« Reply #12 on: January 31, 2006, 10: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, 01:23:21 pm by Khalem »
BeBot Founder and Fixer Kingpin

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
Re: Modified News.php
« Reply #13 on: February 02, 2006, 02:08:43 am »
OOoh!! I like it, I been meaning to add those items myself. Well the click links and last updated bit in the reply. :)
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";
<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
Re: Modified News.php
« Reply #14 on: February 02, 2006, 01:23:49 pm »
Syntax errors was already fixed in SVN. Posting direct link instead :)

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, 01:28:37 pm by Khalem »
BeBot Founder and Fixer Kingpin

 

* Recent Posts
[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm]


0.8.x updates for AoC by bitnykk
[January 30, 2024, 11:16:08 pm]


0.8.x updates for AO by bitnykk
[January 30, 2024, 11:15:37 pm]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am]


Bebot and Rasberry by bitnykk
[November 29, 2023, 11:04:14 pm]

* Who's Online
  • Dot Guests: 516
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.
* Forum Staff
bitnykk admin bitnykk
Administrator
Khalem admin Khalem
Administrator
WeZoN gmod WeZoN
Global Moderator
SimplePortal 2.3.7 © 2008-2024, SimplePortal