Ladda ner…

NewsAdmin v1.1 (2000-09-02)

Copyright (c) Stefan Pettersson, stefpet@algonet.se

More information at https://www.stefan-pettersson.nu/scripts/

Disclaimer: No guarantees are made, use this script at your own risk.

NewsAdmin is a program which allows you to update a webpage with news through a web interface. Done with all the different newssites in mind. You’re not limited in any special look, everything may be customized the way you want. The web interface is password protected so not anyone can post news, even if they figure out the URL.

This package should include the following files:

  1. readme.txt – Installation instructions, Copyright, and more (this file)
  2. newsadmin_settings.pl – Configure the script in this file
  3. newsadmin.pl – The main CGI/Perl script
  4. newsitem-template.html – Template for news
  5. headline-template.html – Template for headlines
  6. index.html – Example page which includes the news
  7. icon-up.gif – Example image
  8. icon-mid.gif – Example image
  9. icon-down.gif – Example image
  10. icon-happy.gif – Example image

NewsAdmin is free to use as long as you provide a link back to the NewsAdmin page and state on your site that it’s using NewsAdmin. The following HTML code is an example that you could use on your site:

<SITE NAME> uses

<a href=”https://www.stefan-pettersson.nu/scripts/newsadmin/”>NewsAdmin</a>.

Features

  • Simple to use and install
  • Optional password authorization
  • Very customizable through templates
  • Image support
  • News may be deleted
  • Customizable dateformat

Requirements

To be able to use Oneliner you must be able to install and run CGI-scripts made with Perl on your webserver. You must also be able to use SSI (Server Side Includes) in your html (or shtml) pages.

If you are unsure of any of this, ask your ISP/webhost or system administrator.

Setting up NewsAdmin

The first thing you must make sure, is that the first line in newsadmin.pl is pointing to Perl on your webserver.

By default it is: !/usr/bin/perl

This is usually correct, but if you get a strange error you know that this might be the problem. Another common path is #!/usr/local/bin/perl, or, just #!/bin/perl, however, your system administrator know about this.

Place all files (except readme.txt and index.html) in the cgi-bin directory on your server (or where your CGI-scripts may be executed). If you’re transfering the files via FTP, be sure to use ASCII mode because otherwise the linefeeds will be wrong. Then set the file permissions of newsadmin.pl:

chmod 755 newsadmin.pl

You may do this from the system prompt if you’ve got telnet access to the server, otherwise you usually can do this with your FTP-client.

In some cases it’s also required that you use chmod 777 on the directory where you choose to put the news_incl.html and headlines_incl.html files (which is written to by NewsAdmin).

Now to the important part, how to get the news on your webpage. You’ll use SSI to include the news file and the headlines file on the webpage where you want to display the news. This is done by inserting:

<!–#include virtual=”headlines_incl.html”–>

and

<!–#include virtual=”news_incl.html”–>

The path must be the one you’ve specified (see below). An example page called index.html is included. Take a look at it to get a hang of it.

Please note that this example assumes that the *_incl.html files are located in the same directory as the file where the above SSI statements are written. If it isn’t you have to modify the the filenames to include the path also.

Note that some servers may be configured to only allow SSI in files ending with the extension .shtml (instead of .html). In that case, simply rename the .html file.

Configuring NewsAdmin

You must configure NewsAdmin before you can use it. All changes are made in the file newsadmin_settings.pl. Note that lines starting with a #-character in the Perl file is comments which are there to help you. First change the system dependent variables that you must change to get the script working. A tip is to start out small with them minimum of changes and get that to work first, and then do all the major tweaking you want.

News configuration

These are configuration options that specify the number of news and headlines that will be displayed.

$number_of_news = 20;

Number of news that should be displayed at the same time. When the news count exceeds this value, the last one will be dropped when new news are inserted.

$number_of_headlines = 8;

Like the one above except that this is for headlines.

Output files

It’s very important that the output files are configured correctly. These are the files where the actual news and headlines are written. Please note that the path and filename in the examples are made up and you must configure them to suit your system. Please note that path and URL is not the same thing (but you did know that, right? :-)).

$news_file = ’/www/news_incl.html’;

This is the path (not URL) to the file where the actual news are written. The specified file is the one you’ll include in the html document where you want the news to be displayed.

This file and the one for headlines does not need to be created. The script will create them automatically if they don’t exist.

$headlines_file = ’/www/headlines_incl.html’;

Like above except that this one is for the headlines.

Templates

Specifies the location of the template files. If they’re located in the same directory as newsadmin.pl then no path needs to be entered.

$newsitem_template = ’newsitem-template.html’;

Template which describes how an inserted news item will look like. See below under customization for more information of how to use templates.

$headline_template = ’headline-template.html’;

Template file for headlines.

Date format

Specify how the date and time will be displayed in news posts.

$dateformat = ’[monthname] [day] 2022, [hour0]:[min0] [ampm]’;

You may change the look of the date and time when it’s displayed in a news posting. You do this by using some special tags that will be replaced with a value. The following tags are available:

[sec] = seconds
[sec0] = seconds padded with a 0

[min] = minutes
[min0] = minutes padded with a 0

[hour] = hours (12h)
[hour0] = hours (22h) padded with a 0

[hour24] = hours (24h)
[hour240] = hours (24h) padded with a 0

[ampm] = display am or pm

[day] = day in month
[day0] = day in month padded with a 0

[dayname] = name of weekday
[daynameshort] = name of weekday short

september = month
[month0] = month padded with a 0
[monthname] = name of month
[monthnameshort] = name of month short

2022 = year (4 digits)
[shortyear] = year (2 digits)

Examples:

Format: ’[monthname] [day] 2022, [hour0]:[min0] [ampm]’
Result: January 6 2000, 01:01 pm

Format: ’Posted [hour240]:[min0]:[sec0] 2022-[month0]-[day0]’
Result: Posted 13:17:28 2000-01-06

@daynames = qw(Sunday Monday Tuesday Wednesday Thursday Friday
Saturday);

The names that will be used for each weekday is specified here with a space between each name. You might want to exchange these with the names in your language for example.

@monthnames = qw(January February March April May June July August September October November December);

The names that will be used for each month is specified here with a space between each name.

$timezone_offset = 0;

If the server is in a timezone different than yours, then the default server time may display wrong (for you). You may modify the time in seconds.

Examples:

$timezone_offset = -3600;
Minus 1 hour.

$timezone_offset = 1800;
Plus 30 minutes.

News images

News images is a way to display an already predefined image together with a news post. How it is displayed is customized in the template. For example it may display an image depending on the subject, or it may display a small icon in the headline.

$enable_images = 1;

This is the line where you enable or disable news images. 1 (one) enables it, and 0 (zero) disables. If disabled the image field field will not appear when posting.

%images = (
”, ’– no image –’,
’/images/icon-up.gif’, ’Up arrow’,
’/images/icon-mid.gif’, ’Middle arrow’,
’/images/icon-down.gif’, ’Down arrow’
);

This is where you specify the images that should be available when making a news post. The first line is there to provide an option to not choose any image at all. The string to the left is the URL that will be used for the image, while the string to the right is the description that will show up in NewsAdmin and in the image’s alt-tag.

Password

You may have as many passwords as you like if you want more people than yourself to have the possibility to do news posts. By giving out an unique password to each person you may then simply remove it if you want to disable that person from posting without affecting the other persons.

$enable_password = 0;

This is the line where you enable or disable password authorization. 1 (one) enables it, and 0 (zero) disables. If disabled the password field will not appear.

@passwords = qw(
secretpassword
supersecret
);

This is where you specify which passwords that should be used to allow someone to do a news post or any other action. In the above example there are two passwords, ”secretpassword” and ”supersecret”. You may add or delete as many passwords as you wish. Passwords are ignored if password authorization is disabled.

NewsAdmin Internal

This is where configuration is made for things used internally by NewsAdmin. Usually you don’t need to change anything here.

$index_file = ’newsadmin_index.dat’;

This is a datafile that NewsAdmin uses internally. It should work as it is, simply putting the file in the same directory as the script itself.

Customization

The look of the headlines and news which are inserted may be customized by you. This is done by changing the template files. You simply use standard HTML but include some special tags that will be replaced by author name, date, headline, etc. See the examples which is originally distributed with NewsAdmin.

Headline template: The headline template is used when writing to the headlines file which is simply a link to the actual news item.

Example: <b><a href=”#[%NA-ID]”>[%NA-HEADLINE]</a></b><br>

News template: This is the actual news, it works exactly the same way as the headline template.

Here are the special tags which is used in the templates:

[%NA-ID] – Will be replaced by a unique id which is used to
link to the newsitem on the page. Used in headline.
[%NA-HEADLINE] – Headline
[%NA-TIMESTAMP] – Date
[%NA-TEXT] – The text itself
[%NA-EMAIL] – Email
[%NA-AUTHOR] – Author name
[%NA-IMAGE] – Is replaced by the selected news image. If no image is choosen it’s simply removed. What’s inserted is actually an <img> tag poiting to the specified URL for the choosen image.

It’s recommended that you first use the default templates to make sure everything works, and then modify them as you like to make them fit your own design.

How To Use NewsAdmin

If you’ve succesfully installed NewsAdmin, you may simply enter it’s url in your browser to get going. If you’ve installed in cgi-bin on your site you’ll call it with: http://www.yourdomain.com/cgi-bin/newsadmin.pl

How the exact URL will be is of course depending on your system and where on your site the script is installed.

Navigation

Navigating NewsAdmin is pretty simple. It works like a tabbed window in Windows. Simply click on the links at the top to switch between Post and Delete mode.

Post

This is where you post news. Simply fill in the informationand click Post to post the newsitem directly. Preview let you see it without actually saving the data. Depending on your settings the password and image field may or may not be displayed.

Options: Currently there is only one option in NewsAdmin.

Convert double linefeeds into HTML

This option will convert double linefeeds (ie you press RETURN two times in a row) into a <P> tag. The result is that the double linefeed actually is displayed on the HTML page.

Delete

This is where you may delete already posted news. Simply select the post you want to delete and click the Delete button. Depending on your settings the password field may or may not be displayed.

What To Do If You Can’t Get It To Work

Unfortunately I’m not able to support you in any way. Simply read these instructions again and check the Oneliner webpage for Frequently Asked Questions which might help you, there is also a general tutorial for installing CGI-script that might be of use if you have no or little experience in installing CGI-scripts. You may also check out the forum to see if your question is answered there. If not, you may post a message and hopefully someone helpful will respond. Another option is to ask your ISP or webhost and to check their support pages.

The reason why I can’t help you is that I would probably get swamped by mails and unfortunately I haven’t got the time to answer them all. So please DON’T mail me asking for help, instead enter your question in the forum and either I or someone else will answer. Thanks for understanding.

NewsAdmin homepage

Version History

v1.1 – 2000-09-02

  • Added delete post feature.
  • Made password authorization optional.
  • Added image support.
  • Extended error information.

v1.0 – 2000-01-06

  • Considered good enough to leave beta stage.
  • Added customizable dateformat.
  • Fixed a litte tiny bug.

v0.4 – 1999-12-29

  • Added multiple passwords feature.
  • Added linefeed to HTML conversion.
  • Remade template parsing a little bit.

v0.3 – 1999-12-09

  • First public beta.
Newsadmin

Lämna ett svar

Din e-postadress kommer inte publiceras.