CHAPTER 1

197
CHAPTER 1 INTRODUCTION 1.1 BACKGROUND TO THE STUDY The impact of technology on official business and therefore on records management is not a new phenomenon. For example, the introduction of the telegraph, typewriter and the telephone fundamentally altered the way business was done and records were kept. According to The Records Management Division, National Archives of South Africa (2000), the advent of the computer altered record keeping even more. Computerised systems offer significant advantages over conventional manual methods. In particular, they can manipulate large amounts of information and generate a wide range of information products. Computers offer speed, precision, diversity, flexibility and a rich and comprehensive documentation of process, and it is no wonder that they have been so quickly embraced around the world as a critical information management tool. A record is defined as a collection of related data items or fields. A record usually forms part of a file. Records may be 1

Transcript of CHAPTER 1

Page 1: CHAPTER 1

CHAPTER 1

INTRODUCTION

1.1 BACKGROUND TO THE STUDY

The impact of technology on official business and therefore on records management is not a

new phenomenon. For example, the introduction of the telegraph, typewriter and the

telephone fundamentally altered the way business was done and records were kept.

According to The Records Management Division, National Archives of South Africa (2000),

the advent of the computer altered record keeping even more. Computerised systems offer

significant advantages over conventional manual methods. In particular, they can manipulate

large amounts of information and generate a wide range of information products. Computers

offer speed, precision, diversity, flexibility and a rich and comprehensive documentation of

process, and it is no wonder that they have been so quickly embraced around the world as a

critical information management tool.

A record is defined as a collection of related data items or fields. A record usually forms part

of a file. Records may be of either fixed or variable length; variable records require a

separator at the end of the field, in order that the end of the record can be detected by the

computer (Ebrary, Inc., 2005, p. 443). It is also described as an authentic official

contemporaneous memorandum stating the proceedings of meetings, courts and events.

Records management is the systematic control of an organisation's records, throughout their

life cycle, in order to meet operational business needs, statutory and fiscal requirements, and

community expectations. It is a method of capturing, storage, processing, dissemination and

retrieval of information.

1

Page 2: CHAPTER 1

Records management ensures information can be accessed easily, can be destroyed routinely

when no longer needed, and enables governmental bodies not only to function on a day to day

basis, but also to fulfil legal, financial and every other requirement. The preservation of the

records of government ensures it allows access to an important resource for future decision

making. Record management in these ministries - Ministry of Information and strategy,

Ministry of Finance and Ministry of Science and Technology - are vital, it helps government

make strategic decisions about the state but till this moment, mediums used in keeping

information still allows for inconsistency and duplication of information.

A database is an organized collection of data. The data is typically organized to model

relevant aspects of reality, in a way that supports processes requiring this information. The

term database is correctly applied to the data and their supporting data structures, and not to

the Database Management System (DBMS). The database data collection with DBMS is

called a database system (Wikipedia).

A general-purpose DBMS is typically a complex software system that meets many usage

requirements to properly maintain its databases which are often large and complex

(Wikipedia). The utilization of databases is now so widespread that virtually every

technology and product relies on databases and DBMSs for its development and

commercialization, or even may have DBMS software embedded in it. A web database is a

database that is accessed by users over a network such as the Internet or an Intranet. It is an

electronic compilation of many different pieces of data of any kind that are stored in a single

location and can be indexed or searched by a user and can be viewed using a web application

for example Microsoft Internet Explorer. Web databases are popular due to the ubiquity of

web browsers, and the convenience of using a web browser as a client, sometimes called a

thin client. The ability to update and maintain web database without distributing and

installing the database on potentially thousands of client computers is a key reason for their

2

Page 3: CHAPTER 1

popularity, as is the inherent support for cross-platform compatibility (Gentry, 2005). Records

management and database work together; since databases are increasingly at the core of

records management classification and indexing from simple electronic card catalogs to

complex applications such as electronic record-keeping systems (Gentry, 2005). Databases

are everywhere; we use them in everyday applications for organization of records, data

collection, storage, dissemination and sometimes disposal. The sole purpose of database is to

store information, and since there are various forms of information, there are various formats

of keeping them for easy retrieval. Web based database are designed to aid collection, sorting,

storage, organizing, dissemination and disposal of information. Web based databases usually

run as a service on a server computer; it is a program that is running in memory just waiting

for users to request work, this service program can handle many different user requests at

once and they can store large volumes of data. Data files can even span multiple physical

devices (Gentry, 2005).

Web-based can be defined as something that stays alive living on the web. It is the use of

internet or intranet. It is the act of placing an application, program, software, database etc. on

the web to enable easy access and sharing of such material. It enables easy accessibility to

materials, and also allows for numerous user access, this is because it can be accessed almost

everywhere with internet facility.

Every state no matter its size has its records (either government records or public records) to

maintain, but their methods of keeping them differs. Various methods of records management

in these ministries - Ministry of Information and strategy, Ministry of Finance and Ministry of

Science and Technology - have been with the use of a local based database using Microsoft

Excel or Microsoft Word saved on personal computers. For example, when employee A has a

particular piece of information, employee B might have a different type of that same

information. Information management using personal systems are inconsistent and retrieval

methods are daunting.3

Page 4: CHAPTER 1

Information kept in the ministry of information and strategy is about government publications

and news, they also gather information from all the various government agencies,

organisations and their various outlets across the state. The information this work focuses on

is about the information they gather from Ministry of Education, Science and Technology,

Ministry of Finance; while the Ministry of Education, Science and technology keeps

information about educational institutions in the state, also curricula to be used by various

schools in the state, this ministry like every other ministry has its own Human Resource

department, but the focus of this work is based on information about educational institutions

in the state. The third ministry in view is the Ministry of Finance, just like the previously

stated ministries, this ministry also generates its own information, they keep information

regarding budget of the state, expenditure, income and various relating financial details about

the state. They also keep information regarding all the industries in the state, statistics of

population, festivals, local governments and open markets with their days; the information in

view entails industries in the state, local governments and also open markets with their days.

In conclusion, the method that allows usage of personal computers limits number of users and

reduces access time it also exposes these ministries to loss of information. Meanwhile, these

Ministries have almost the same method of gathering information, which includes form

filling, and imputation on personal systems. The major problems occur at the retrieval stage

where there is numerous duplicated information and no one knows which is current and

which is not; but the adoption of a web-based database will refine and change the various

methods used in records management by these ministries.

1.2 STATEMENT OF THE PROBLEM.

It is no doubt that Governement ministries have seen the need to apply Information and

Communication technology (ICT) in Records Management. Observation has shown that

these ministries make use of local based applications like Microsoft Word and Microsoft

4

Page 5: CHAPTER 1

Excel. While these applications can also be useful in Records Management, they have been

shown to create some challenges like duplication of records, inconsistency in records kept and

difficulty in sharing the records amongst colleagues and even clients. It is in the light of this

that, this study intends to develop a web based application which will not only help in

overcoming some of the afore-mentioned challeneges, but also help in the centralization of

records storage thereby making easy access to records possible.

1.3 OBJECTIVES OF THE STUDY:

The main objective of this study is to develop a web-based database to aid records

management activites.

The specific objectives of this study are:

Identify the type of records kept by the selected ministries.

Examine the method used in record collection, storage and dissemination.

Model the processes involved in record management in these ministries.

Develop a web-based database to aid record management activities.

1.4 RESEARCH QUESTIONS

To achieve the study’s set objectives, the following questions are generated:

What are the types of records kept in the selected ministries?

What are the methods used in records collection, storage and dissemination?

What are the processes involved in record management in these ministries?

How will a web-based database aid record management activities?

1.5 SCOPE OF THE STUDY

This work focused on Ministry of Education, Science & Technology, Ministry of Finance and

Ministry of Information and Strategy in Ogun State. The system was developed to replicate

the records management process in the selected ministries - Ministry of Education, Science &

5

Page 6: CHAPTER 1

Technology, Ministry of Finance and Ministry of Information and Strategy – using ICT

(Information and communication Technology).

The focus of this research work was limited to records concerning educational institutions in

the state, market days information, records on local governments demography, state health

facilities and corporate organisations in the state.

This study focuses on creation, organising, sorting and dissemination of records selected.

The software deployed is MySQL (DBMS), this is because of its compatibility with PHP.

1.6 ASSUMPTIONS OF THE STUDY

The following were observed in the three ministries - Ministry of Education, Science &

Technology, Ministry of Finance, Ministry of Information and Strategy - sampled:

1. By observation, workers of these Ministries never knew a program aside from MS-

Excel and MS-Word could aid record management.

2. Information retrieval is tasking.

1.7 OPERATIONAL DEFINITION OF TERMS.

Web-based database: A web based database is a client / server database, runs as a service on

the server computer, this service program can handle many different user requests at once and

it can store large volumes of data.

Record: collection of information.

Records management: is the systematic method of keeping ministerial information safe and

for easy retrieval of information.

6

Page 7: CHAPTER 1

CHAPTER 2

LITERATURE REVIEW

2.0 INTRODUCTION

This chapter reviews existing literatures on:

Records Management

Electronic record

Record lifecycle

Prototype model theory

Web-based / Database

Database Management System (DBMS)

Relationship between Records Management & Web-based database

2.1 RECORDS MANAGEMENT (RM)

Traditional definitions of records suggest they are tied to some physical format or storage

medium. Schellenberg (1956) defined records as all books, papers, maps, photographs, or

other documentary materials, regardless of physical form or characteristics, made or received

by any public or private institution in pursuance of its legal obligations or in connection with

the transaction of its proper business and preserved or appropriate for preservation by that

institution or its legitimate successor as evidence of its functions, policies, decisions,

procedures, operations, or other activities or because of the informational value of data

contained therein. This definition ascribed records to their physical form. That is, records

have to have some storage medium, as in books, paper, and maps, photograph and so on. This

definition is traditional, in that it appeals our senses to things we are accustomed to i.e. letters,

reports, invoices, and so on, all in paper format, things that we are used to handling almost

on daily basis. According to ISO 15489 (2001), the international standard for records

7

Page 8: CHAPTER 1

management, viewed records as “information created, and maintained as evidence and

information by an organisation or person, in pursuance of legal obligations or in the

transaction of business. ISO 15489 (2001) also defined Records Management as a field of

management responsible for the efficient and systematic control of the creation, receipt,

maintenance, use and disposition of records.

Records have been found to possess certain attributes that distinguish them from other types

of information (Shepherd & Yeo, 2003).

Content: That which conveys information (text, data, symbols, numerals, images,

sound, and vision).

Context: the background information that enhances understanding of technical and

business environments to which the records relate (application software, link to

function or activity, provenance information).

Structure: the appearance and arrangement of the content (relationships between

fields, entities, language, style, fonts, page and paragraph breaks, links, and other

editorial devices) (Hunter, 1997, P. 242).

To assist in the effective creation and general management of records, organisations should

institute a records management programme composed of among others:

A system that evaluates the business processes an organisation carries out and

determines the information resulting from each process and ascertaining which of it

has to be captured as records;

Making decisions on the form of records to be created and the appropriate

technologies needed to support and enhance their creation;

Evaluating metadata needed as part of the record and establishing how the metadata

will continue to be linked to the record as long as it is needed for the business process

that led to its creation;

8

Page 9: CHAPTER 1

Designing retrieval mechanisms for records and ensuring that the records can be

shared by business processes without getting lost, being altered or damaged;

Assessing risks associated with failure to create and maintain appropriate records or

failure to retrieve them when they are needed;

Deciding how records will be preserved over time to enable their availability any time

they are needed for conduct of business;

Ensuring records are retained for appropriate periods that tally with business

processes;

Seeing to the safe and secure maintenance of records;

Establishing methodologies for evaluating and monitoring the effectiveness of

systems instituted for managing records.

Records Management includes classifying, storing, securing, and destruction of records.

Effective management of corporate information allows fast, accurate and reliable access to

records, ensuring the timely destruction of redundant information and the identification and

protection of vital and historically important records. A record can be either a tangible object

or digital information: for example, databases, birth certificates, medical x-ray, office

documents and application data. Records management is primarily concerned with the

evidence of an organization's activities, and is usually applied according to the value of the

records rather than their physical format.

2.1.1 NEED FOR RECORD MANAGEMENT

Information is every organisation's most basic and essential asset, and in common with any

other business asset, recorded information requires effective management. Records

management ensures information can be accessed easily, can be destroyed routinely when no

longer needed, and enables organisations not only to function on a day to day basis, but also

to fulfil legal and financial requirements. The preservation of the records of government for

9

Page 10: CHAPTER 1

example, ensures it can be held accountable for its actions, that society can trace the evolution

of policy in historical terms, and allows access to an important resource for future decision

making.

Legislation is increasingly underlining the importance of good records management, in

addition to being sound business practice. Compliance with Acts such as Freedom of

Information and Data Protection is underpinned by effective records management: without

properly organised and retrievable records, requests for information governed by statutory

response timescales will be impossible to service. Indeed, section 61 of the Freedom of

Information (Scotland) Act 2002 is the 'Code of practice as to the keeping, management and

destruction of records'.

Organisations are also producing increasingly large amounts of information and consequently

greater volumes of records, in both paper and electronic form. It is essential that information

is captured, managed and preserved in an organised system that maintains its integrity and

authenticity. Records management facilitates control over the volume of records produced

through the use of disposal schedules, which detail the time period for which different types

of record should be retained by an organisation.

The growth in electronic communications and data, from e-mails to databases, presents new

challenges, but can be managed by the same records management principles that are applied

to paper documents. Sound records management is also an essential basis for the transition to

EDRM (Electronic Document and Records Management) that many organisations are

embracing. In the public sector this has been driven in part by e-government targets, where

public services are to be made available electronically. Where existing paper based systems

are poorly managed, current problems will simply be migrated to a new electronic system

unless they are addressed in the preparations for EDRM.

10

Page 11: CHAPTER 1

Modern society has rising expectations concerning the accessibility of information. People

now expect efficient and speedy responses to requests for information, and a policy of 'open

government' has been followed and developed by several successive governments.

Records management is important because it:

1. Reduces litigation risks: When documents are managed according to a records

management plan that is applied throughout an organization, records are more

defensible if and when they become part of a legal action or audit. Because the records

are in a controlled environment, an organization can demonstrate that the records

presented are valid, they have not been altered, and that any records destroyed were

destroyed in the normal course of business.

2. Provides Regulatory compliance: All organizations today must comply with

governmental rules (federal, state, county, and city) and may have to demonstrate this

compliance at some time. A records management system can help a company

demonstrate its compliance for areas such as Privacy (HIPAA), Security (DoD

5015.2), and Financial Reporting (Sarbanes-Oxley). Organizations that cannot

demonstrate compliance with the rules that govern their particular industry may be

sanctioned for non-compliance and / or may be fined.

3. Protects corporate assets: Daily business records and vital company records must be

protected from alteration or destruction. Records management systems secure records

properly allowing only authorized operations and actions against them.

2.1.2 BENEFIT OF SYSTEMATIC RECORDS MANAGEMENT

The benefits of Systematic records management allows organisations to:

1. Know what records they have, and locate them easily.

2. Increase efficiency and effectiveness.

11

Page 12: CHAPTER 1

3. Make savings in administration costs, both in staff time and storage.

4. Support decision making.

5. Achieve business objectives and targets.

6. Provide continuity in the event of a disaster.

7. Meet legislative and regulatory requirements for example as lay down by the Freedom

of Information (Scotland) Act and the Data Protection Act.

8. Protect the interests of employees, clients and stakeholders.

Records management offers tangible benefits to organisations, from economic good practice

in reducing storage costs of documents, to enabling legislative requirements to be met. In an

unmanaged records environment, up to 10% of staff time is spent looking for information.

2.1.3 PRACTISING RECORD MANAGEMENT

A Records Manager is someone who is responsible for records management practice in an

organization. Records management includes:

1. Setting policies and standards.

2. Assigning responsibilities and authorities.

3. Establishing and promulgating procedures and guidelines.

4. Providing a range of services relating to the management and use of records.

5. Designing, implementing and administering specialized systems for managing

records.

6. Integrating records management into business systems and processes.

2.2 MANAGING PHYSICAL RECORDS

Managing physical records involves different disciplines and may draw on a variety of forms

of expertise. Records must be identified and authenticated. This is usually a matter of filing

and retrieval; in some circumstances, more careful handling is required. Such as:

12

Page 13: CHAPTER 1

1. Storing records: Records must be stored in such a way that they are accessible and

safeguarded against environmental damage. A typical paper document may be stored

in a filing cabinet in an office. Vital records may need to be stored in a disaster-

resistant safe or vault to protect against fire, flood, earthquakes and conflict. In

extreme cases, the item may require both disaster -proofing and public access, such as

the original, signed US Constitution.

2. Circulating records: Tracking the record while it is away from the normal storage

area is referred to as circulation. Often this is handled by simple written recording

procedures. However, many modern records environments use a computerized system

involving bar code scanners, or radio-frequency identification technology (RFID) to

track movement of the records.

3. Disposal of records: Disposal of records does not always mean destruction. It can

also include transfer to a historical archive, museum, or private individual.

Destruction of records ought to be authorized by law, statute, regulation, or operating

procedure, and the records should be disposed of with care to avoid in-advertent

disclosure of information. The process needs to be well-documented, starting with a

records retention schedule and policies and procedures that have been approved at the

highest level. An inventory of the records disposed of should be maintained, including

certification that they have been destroyed.

2.3 ELECTRONIC RECORDS

They are records or information kept and handled electronically. They could be bits and

pieces of information kept in a database, hard disk and so on. They are also referred to as

digital records. As with records in other formats, electronic records must be managed through

their entire life cycle from creation, when the records are created or received; through their

active life, when the records are accessed frequently (at least once a month); through their

inactive life, when the records are no longer active but have to be retained for a period of time 13

Page 14: CHAPTER 1

for legal, fiscal, administrative, or historical reasons; until their final disposition which could

be destruction or preservation as a permanent record.

2.3.1 MAINTENANCE OF ELECTRONIC RECORDS

There is often a presumption that because information is stored in the computer or on disk or

tape, it is somehow automatically preserved for all time. Unfortunately, electronic storage

media can easily become un-readable over time due to physical, chemical, or other

deterioration. Special care and precautionary measures must be taken to avoid the loss of

records stored on electronic media. Rule 1B-26.003, Florida Administrative Code, specifies

maintenance requirements for electronic storage media.

Preservation duplicates of permanent or long-term records must be stored in an off-

site storage facility with constant temperature (below 68 degrees Fahrenheit) and

relative humidity controls

Storage and handling of magnetic tape containing permanent or long-term records

should conform to the magnetic tape standard AES22-1997 (r2003)

Agencies must annually read a statistical sample of all electronic media containing

permanent or long-term records to identify any loss of information and to discover and

correct the cause of data loss.

Agencies must test all permanent or long-term electronic records at least every 10

years and verify that the media are free of permanent errors. More frequent testing

(e.g., at least every 5 years) is highly recommended.

2.3.2 MEDIA CONVERSION

Agencies must convert storage media to provide compatibility with the agency’s

current hardware and software to ensure that information is not lost due to changing

technology or deterioration of storage media.

14

Page 15: CHAPTER 1

Before conversion of information to different media, agencies must determine that

authorized disposition of the electronic records can be implemented after conversion.

Permanent or long-term electronic records stored on magnetic tape must be transferred

to new media as needed to prevent loss of information due to changing technology or

deterioration of storage media.

2.3.3 ELECTRONIC RECORDS BACK-UP FOR DISASTER RECOVERY

Agencies must back up electronic records on a regular basis to safeguard against loss

of information due to equipment mal-functions, human error, or other disaster.

Back-up media created for disaster recovery purposes must be stored in an off-site

storage facility with constant temperature and relative humidity controls.

Disaster recovery back-up tapes or other media should be kept solely as a security precaution

and are not intended to serve as a records retention tool. In the case of disaster, the back-up

would be used to restore lost records. Agency records that have not met their retention should

not be disposed of on the basis of the existence of a back-up.

2.3.4 RECORD LIFE CYCLE

This theory, developed at the National Records and Archives Administration of the United

States of America in the 1930s, is based on the concept that a record has a life. According to

Schellenberg (1956), the lifecycle theory suggests that records move from one phase to

another, over time, in a linear rather than a cyclical way, from creation, receipt and use, to

disposal. The following are the different stages:

1 Creation: The first phase of the Records Life Cycle  involves records

being created, collected or received through the daily transactions of the Business Unit,

School, and can include printed reports, e-mails or even phone messages, documents that

detail the functions, policies, decisions or procedures of the agency.

15

Page 16: CHAPTER 1

2 Maintenance & Use: The next phase of the life cycle is the maintenance and use of the

record. This can include filing, retrieving, use, duplication, printing, dissemination,

release or exchange of the information in the record.

3 Disposition: At the disposition phase, records are assessed to determine their retention

value using General Disposal Schedules or Records Disposal Schedules. This leads to

either the preservation or destruction of the record.

4 Preservation: When a record has been determined to be of permanent value to the

Agency and / or Community then it is transferred to State Records of South Australia for

permanent archiving and preservation.

5 Temporary Storage & Destruction: If a record still has ongoing value to the Agency it

will be temporarily stored either onsite at the Agency or offsite with an Approved Service

Provider such as Recall. When the retention date of these records is reached, permission

will be sought from the Agency and State Records for their destruction.

Source: Records Life Cycle, 2012

2.4 WEB-BASED SOFTWARE

According to Gentry (2005), web-based software is an application that is accessed by users

over a network such as the Internet or an Intranet. Usually little or nothing is installed on

16

Page 17: CHAPTER 1

local computer, updates are done in one place (the server) and a browser is needed to access

the information on the server. Web softwares are popular due to the ubiquity of web

browsers, and the convenience of using a web browser as a client, sometimes called a thin

client. The ability to update and maintain web applications without distributing and installing

software on potentially thousands of client computers is a key reason for their popularity, as

is the inherent support for cross-platform compatibility.

They are so popular now due to its unlimited restrictions, this is because they are client /

server softwares. A client / server database breaks down the three main components over two

or more computers; the server is where the database files are located which means users can

work on the database using a browser, adding new records, perform searches, run reports, all

can be done without one installing the database on his / her personal system (Joe Gentry,

2005).

2.5 DATABASE

It is an organised collection of data. A database is to store data physically, it is implemented

as one or more files it consists of multiple objects (Gentry, 2005). A database is a collection

of related files that are usually integrated, linked or cross-referenced to one another. The

advantage of a database is that data and records contained in different files can be easily

organized and retrieved using specialized database management software called a database

management system (DBMS) or database manager.

A database management system is a set of software programs that allows users to create, edit

and update data in database files, store and retrieve data from those database files. Data in a

database can be added, deleted, changed, sorted or searched all using a DBMS. If you are an

employee in a large organization, the information about you would likely be stored in

different files that are linked together. One file about you would pertain to your skills and

abilities, another file to your income tax status, another to your home and office address and

17

Page 18: CHAPTER 1

telephone number, and another to your annual performance ratings. By cross-referencing

these files, someone could change a person's address in one file and it would automatically be

reflected in all the other files. DBMSs are commonly used to manage:

1. Membership and subscription mailing lists

2. Accounting and bookkeeping information

3. The data obtained from scientific research

4. Customer information

5. Inventory information

6. Personal records

7. Library information

2.5.1 ADVANTAGES OF A DBMS

1. IMPROVED AVAILABILITY: One of the principal advantages of a DBMS is that

the same information can be made available to different users.

2. MINIMIZED REDUNDANCY: The data in a DBMS is more concise because, as a

general rule, the information in it appears just once. This reduces data redundancy, or

in other words, the need to repeat the same data over and over again. Data fields are

commonly repeated in multiple files when a file management system is used.

3. ACCURACY: Accurate, consistent, and up-to-date data is a sign of data integrity.

DBMS foster data integrity because updates and changes to the data only has to be

made in one place.

4. PROGRAM AND FILE CONSISTENCY: Using a database management system,

file formats and system programs are standardized. This makes the data files easier to

maintain because the same rules and guidelines apply across all types of data. The

level of consistency across files and programs also makes it easier to manage data

when multiple programmers are involved.

18

Page 19: CHAPTER 1

5. USER-FRIENDLY: Data is easier to access and manipulate with a DBMS than

without it. In most cases, DBMS also reduce the reliance of individual users on

computer specialists to meet their data needs.

6. IMPROVED SECURITY: As stated earlier, DBMS allow multiple users to access

the same data resources. As advantageous as this is, there are potential risks for the

organization. Some sources of information should be protected or secured and only

viewed by select individuals. Through the use of passwords, database management

systems can be used to restrict data access to only those who should see it.

2.5.2 DISADVANTAGES OF A DBMS

There are basically two major downsides to using DBMS. One of these is cost, and the other

is the threat to data security.

1. COST: Implementing a DBMS system can be expensive and time-consuming,

especially in large organizations. Training requirements alone can be quite costly.

2. SECURITY: Even with safeguards in place, it may be possible for some

unauthorized users to access the database. In general, database access is an all or

nothing proposition. Once unauthorized users get into the database, they have access

to all the files, not just a few. Depending on the nature of the data involved, these

breaches in security can also pose a threat to individual privacy. Steps should also be

taken to regularly make backup copies of the database files and store them because of

the possibility of fires and earthquakes that might destroy the system.

2.5.3 FOUR STRUCTURAL TYPES OF DBMS

According R.G Healey (1991) says, in computer systems, databases are classified according

to their organizational approach. There are four structural types of DBMS:

19

Page 20: CHAPTER 1

1. Relational: In relational databases, the relationship between data files is relational,

not hierarchical. Relational databases connect data in different files by using common

data elements or a key field. Data in relational databases is stored in different tables,

each having a key field that uniquely identifies each row. In relational databases,

tables or files filled with data are called relations, tuple designates a row or record,

and columns are referred to as attributes or fields. Relational databases work on the

principle that each table has a key field that uniquely identifies each row, and that

these key fields can be used to connect one table of data to another. This key field can

be linked to another table that contains item numbers and other product information

such as production location, colour, quality control person, and other data. The

relational database has become quite popular for two major reasons. First, relational

databases can be used with little or no training. Secondly, database entries can be

modified without redefining the entire structure.

2. Hierarchical: commonly used on mainframe computers. It is one of the oldest

methods of organizing and storing data and it is still used by some organizations. A

hierarchical database is organized in pyramid fashion, like the branches of a tree

extending downwards. Related fields or records are grouped together so that there are

higher-level records and lower-level records, just like the parents in a family tree sit

above the sub-ordinate children. Based on this analogy, the parent record at the top of

the pyramid is called the root record. A child record always has only one parent record

to which it is linked, just like in a normal family tree. Hierarchical databases work by

moving from the top down. A record search is conducted by starting at the top of the

pyramid and working down through the tree from parent to child until the appropriate

child record is found. The advantage of hierarchical databases is that they can be

accessed and updated rapidly because the tree-like structure and the relationships

between records are defined in advance.

20

Page 21: CHAPTER 1

3. Object-oriented: Able to handle many new data types, including graphics,

photographs, audio, and video, object-oriented databases represent a significant

advance over their other database cousins. Hierarchical and network databases are all

designed to handle structured data; that is, data that fits nicely into fields, rows, and

columns. Object-oriented databases use small, re-usable chunks of software called

objects. The objects themselves are stored in the object-oriented database. Each object

consists of two elements:

A piece of data (e.g., sound, video, text, or graphics), and

The instructions or software programs called methods, for what to do with the

data.

Object-oriented databases are more costly to develop. Moreover, most organizations

are reluctant to abandon or convert from those databases that they have already

invested money in developing and implementing. However, the benefits of object-

oriented databases are compelling. The ability to mix and match re-usable objects

provide incredible multimedia capability.

2.5.4 DATABASE DEVELOPMENT PROCESS

Database development is a systematic process that moves from concept to design to

implementation. It also takes into account the needs of potential users and the operational

and/or business processes in the organization.

1. DEFINE BUSINESS PROCESSES: Database development efforts begin by

defining the key business and / or operational processes within the organization.

Developers first create high-level models showing the major activity steps associated

with marketing, sales, production, human resource management, public relations,

research and development (R & D) and so on. Taken together, these processes map

represent an enterprise-wide model of the organization and its core processes.

21

Page 22: CHAPTER 1

2. DETERMINE SCOPE OF DATABASE DEVELOPMENT EFFORT: The next

step in the database development effort is to select one process or a set of related

processes for further analysis and improvement.

3. DEFINE THE INFORMATION NEEDS: Once a business process has been

selected, the next step is to define the information needs of users involved in or

affected by the business process.

4. DEVELOP CONCEPTUAL DESIGN: A basic understanding of these needs is used

to create a conceptual design for the database. At this stage, a conceptual data model

is created that illustrates relationships between information sources, users, and

business process steps.

5. DEVELOP LOGICAL DATA MODEL: The conceptual data model is used to

develop a logical data model based on one of the primary DBMS types: relational,

hierarchical, network, or object-oriented approaches.

6. DEVELOP PHYSICAL DESIGN: With the logical data model in hand, developers

move to the physical design, which involves determining the specific storage and

access methods and structures.

7. CREATE AND TEST DATABASE: Once this step is complete, developers can go

ahead and create the database using whatever DBMS that has been selected. This is

also the time to start developing sample screens and reports to determine if the

database design will meet the predefined requirements. It is much easier to revise and

change the database during this testing phase, before all of the data have been entered.

The term prototyping refers to the iterative process used to try different report formats

and input screens to determine their suitability and effectiveness.

22

Page 23: CHAPTER 1

2.5.5 WEB-BASED DATABASE

A web database is a database that is accessed by users over a network locally or remotely

such as the Internet or an Intranet. This is a type of database that has its full operations on a

web platform.

It has to be hosted on a local server (my local server here is WampServer 2.0) and run in an

internet application platform (my internet application here is Mozilla Firefox 13.0).

Unlike a local in-system database application such as the Microsoft Access and so many

others, the database to be designed would be accessed via a web application.

2.6 PROTOTYPING MODEL

It is a System Development Life Cycle (SDLC) methodology. The goal of prototyping

techniques is to develop a pilot version called a prototype of part or all of a system. A

prototype is a useable system that is built quickly at a lesser cost and with the intention of

being modified or replaced by a full scale and fully operational system. As users work with

prototype, they make suggestions about the ways to improve it. These suggestions are then

incorporated into another prototype, which is used and then evaluated. Finally, when a

prototype is developed that satisfies all user requirements, it is either refined and turn into the

final system or it is scrapped. If it is scrapped, the knowledge gained from building the

prototype is used to develop the real system.

Framework type: iterative

Basic principles: prototyping can be viewed as a series of four steps {Fig. 2.1}

23

Page 24: CHAPTER 1

Fig. 2.1: Prototyping Model

Identify Information System Requirements: under prototype approach, the design

team needs only fundamental system requirements to build the initial prototype.

Develop the initial prototype: the designers create an initial base model and give

little consideration to internal controls, but emphasise such system characteristics such

as simplicity, flexibility and ease of use. These characteristics enable users interact

with tentative versions of data entry screens, menu, input prompts and source

documents. The users also need to be able to interact with the system, judge response

time and issue commands.

Test and Revise: when initial prototype is done, the designers present the model to

users and give users to experiment and let users comment and make their views

known. With the feedback, the design team modifies the prototype as necessary and

then re-submit to users for revaluation, the iterative process of revaluation continues

until users are satisfied.

Obtain User Sign-off of the approved prototype: users formally approve the final

version of the prototype, which commits them to current design and establishes a

contractual obligation about what the system will and will not provide.

2.7 RELATIONSHIP BETWEEN RECORDS MANAGEMENT AND DATABASE

Records management and database share mutual reciprocal relationships. In a mutual

relationship all the elements which compose it, support and work together in reaching similar

ends. This relationship between Records Management and Database is two-way, since both

are aimed at facilitating access to information. Database is principled on creating a model of 24

Page 25: CHAPTER 1

structures of reality that supports queries and updates modeling processes of reality, runs

efficiently to provide information needed. Records Management is principled on having

oversight over the creation, capture and management of information hence implying its

availability when needed. Once a standard database has been adopted, the presumption is that

the old practices of RM will be integrated into the database will create and hold records which

workers can access. The other presumption is that RM will ensure that it creates and holds

records, and that they will be accessible from a web-based database. The relationships

between RM and databases are both interesting and negative at the same time. The

relationships are interesting in the sense that the adoption of database brings about safety of

information, ease of access and simplified records management.

25

Page 26: CHAPTER 1

CHAPTER 3

SYSTEM ANALYSIS

3.0 INTRODUCTION

This chapter is to explain the methods records are created, processed, stored and disseminated

information in the following Ministries - Ministry of Information and Strategy, Ministry of

Education, Science and Technology and Ministry of Finance. It looks at the existing system

of records management. This was achieved largely by observation and a one – on – one

interview. It looks at the weakness of the existing system, describing proposed alternative,

stating the disadvantages of the proposed system but justifying the proposed alternative.

3.1 DESCRIPTION OF EXISTING SYSTEM

At the selected ministries, – Ministry of Information and Strategy, Ministry of Education,

Science and Technology and also Ministry of Finance – information such as: school

information, corporate organisation information, and market day’s information on local based

computer systems. School information contains name of school, address and date of

establishment, while corporate organisation information includes name of organisation,

product type and office address. Market day’s information includes market name, local

government area and their reoccurring market days.

Local government record include information such as: name, list of markets, population,

festivals etc. - and state health facilities information – just name and local government area - ,

each file is numbered and then shelved in the ministry’s shelf.

3.1.1 MINISTRY OF INFORMATION AND STRATEGY

The Ministry of Information and Strategy is in charge of all state government publication,

research and storage of government publications. It also checkmates all state and national

publications about the state and its government. The Ministry of Information and Strategy

26

Page 27: CHAPTER 1

gets most of its information from the public and other Ministries in the Government office.

Majorly, this ministry collects information needed from other ministries, information such as

information on educational institutions in the state, corporate organisations, local government

information, state health facilities.

Data Collection is from various Government Agencies or Ministries and information is

collected using a Compact Disk (CD-ROM) and then redistributed to various departmental

systems in the ministry.

3.1.2 MINISTRY OF EDUCATION, SCIENCE AND TECHNOLOGY

The Ministry of Education, Science and technology is in charge of state educational sector.

They register private and government schools and every other educational institution, it is

also in charge of checking if the schools in the state are government compliant, follow general

syllabus and if the students are comfortable with school environment.

The method of input is also the use of computers (Microsoft Excel saved on the local hard

disk) such files are / is placed in a folder. When clients come to register schools, they are

given forms to fill; the form contains blank spaces for name of school, location, number of

staff (teaching and non-teaching), and other necessary information. This is then taken to one

of the organisation’s systems to be filed in a new file for each customer, sometimes the stage

steps up, with the use of a computer system, when the information is filled into one of the

organisation’s system (Ms-Excel).

27

Data Collection Data Processing Sorting Saving to System Redistribution to

other departments

Page 28: CHAPTER 1

.

3.1.3 MINISTRY OF FINANCE

The Ministry of Finance holds all financial statements of the state, ranging from budgets,

allowance allocations, government savings and every other financial record about the state

government.

Physical contact, environment scanning and statistical data are methods of information

collection.

3.1.4 WEAKNESS OF EXISTING SYSTEMS

1. Updating information is tedious, for example a particular local government could have

stopped celebrating a particular festival, when a department in the Ministry of

Information deletes such festival, another department might still have it.

2. Information can not be accessed from remote locations, this means you have to get to

a ministry or department to access such information

3. Delay in distribution of information.

4. Retrieval of information might be hard i.e. when a worker goes on leave or could not

be at work, getting information from such system could be impossible / tasking.

5. Inconsistency of information between various systems.

28

Data Collection Data Processing Saving to System

Data Collection Data Processing Saving to System

Page 29: CHAPTER 1

6. It allows duplication of information, especially during redistribution to other

departments.

3.2 WEB BASED DATABASE

A web based database is intended to quicken tasks that require the use of databases. It allows

operators execute operations through a web browser application. It allows for the use of

multiple users at the same time viewing the same thing with no prefertiality.

Physical Location

The system is to function in a user friendly environment, which would be the selected

ministries - Ministry of Information and Strategy, Ministry of Education, Science and

Technology and also Ministry of Finance.

There would be just a location for this system and not several locations.

Interfaces

Inputs would make use of keyboards or touch screens of systems in use.

Outputs would be displayed onto system screens.

Operations

The system would keep track of schools database, corporate organisation database,

state health facilities database, local government database and market days database.

The system would be able to access all its saved databases.

It would be able to detect duplication of records.

It would be able to generate market days for all the markets.

Security

Access levels would be limited with the use of passwords.

Administrators can limit user’s ability to input information.

29

Page 30: CHAPTER 1

3.2.0 MySQL

The My Structured Query Language (SQL) is the set of instructions used to interact with a

relational database management system (RDBMS). The MySQL server controls access to

data and ensures multiple users can work concurrently. In fact, MySQL is the only language

that most databases actually understand. Whenever you interact with such a database – such

as RDBMS, the software translates your commands (whether they are mouse clicks or form

entries) into SQL statement that the database knows how to interpret. MySQL is available

under an open source license and its developed by Swedish company MySQL AB.

3.2.1 PHP

PHP (Hypertext Pre Processor) as it is known today is actually the successor to a product

named PHP/FI. Created in 1994 by Rasmus Lerdorf, the very first incarnation of PHP was a

simple set of Common Gateway Interface (CGI) binaries written in the C programming

language.

The code got another complete makeover, and in April of 1996, combining the names of past

releases, Rasmus introduced PHP / FI. This second-generation implementation began to truly

evolve PHP from a suite of tools into a programming language in its own right. It included

built-in support for Database Management, MySQL, user-defined function support, and much

more. PHP / FI was given a version 2.0 status.

PHP can also serve as a tool for creating dynamic web contents. It is offered for Open

Database Connectivity (ODBC), its vast capabilities eliminates integration of several third-

party applications; making PHP a preferred tool for web developers globally.

3.2.2 LIMITATIONS OF THE PROPOSED SYSTEM

1. Poor power supply: frequent power supply constitutes a serious problem to electronic

records management system.

30

Page 31: CHAPTER 1

2. Not enough trained personnel to operate the system.

3. Resistance of staff to new system adaptation and training.

4. Limited computer systems to access the database.

5. Poor system maintenance culture: lack of maintenance of system could lead to crash

of system.

6. Virus attack against system.

3.2.3 SOLUTIONS TO LIMITATIONS

The following are solutions to the stated problems above.

1. Provision of UPS (Uninterrupted Power Supply), inverters and stand by generators to

provide electricity in case of light out.

2. Training of member of staff.

3. Compulsion of staff to see the need and advantages of the new system

4. Provision of computer systems.

5. Recruitment of database maintenance personnel.

6. Provision of antivirus to prevent attack on system.

3.2.4 ENTITY RELATIONSHIP DIAGRAM (ERD)

It is a modelling tool, developed by Peter Chein in 1976. It identifies concepts that exist in a

database system and the relationship between them. ERD is used to visualize a relational

database. It provides d foundation for database design and serves as a universal standard for

system documentation. It can be used by a system designer to communicate database design

to end users.

31

Page 32: CHAPTER 1

Fig. 3.2.4: Database Entity relationship Diagram

The ERD shows the relationship between the various table in the database. It shows the

various primary keys and foreign keys in the database. The keys show the white boxes

represent foreign keys while the black boxes represent primary keys..

32

Keys

Page 33: CHAPTER 1

3.2.5 SYSTEM FLOW CHART

Fig. 3.2.5 gives a graphical representation of the work flow processes of the database system.

Fig.3.2.5: Flow chart for schools, local government, state health facilities and corporate

organisation database.

After a User has been registered, the following operations can go on:

Input new records and edit existing records

Create category and subcategory.

Search for records.

Print and export search results.

CHAPTER 433

Log out

Page 34: CHAPTER 1

DOCUMENTATION AND IMPLEMENTATION

4.1 INTRODUCTION

This chapter discusses the database extensively. It talks about its method of operations,

accessibility supported with screenshots from the system. It also includes instructions on how

the system can function well.

4.2 SYSTEM REQUIREMENT

In order for this system to run smoothly, it has some hardware and software requirements.

4.2.1 Hardware Requirements

It has a couple of hard requirements for the system to be fully functional. Before this

database can be deployed on a system, it must meet the following requirements, they include:

Processor: Pentium II upwards running at, at least 1.98GHz speed.

RAM (Random Access Memory): minimum of 256MB (Megabyte), in case large uploads

to the database will occur, so as not to slow down system speed.

HDD (Hard disk): minimum of 12GB, it would run other system programs and also have

enough space in case a virtual memory would be needed later on.

Mouse / track pad.

Keyboard / touchscreens.

Uninterrupted Power Supply (UPS).

For high resolution SVGA (Super Video Graphics Array) monitor is required.

4.2.2 Software Requirements

Specifies the minimum software requirements to be met for effective use of the system:

34

Page 35: CHAPTER 1

Web browser: using Firefox, it must not be earlier than Firefox 13; with Internet Explorer

it must not be earlier than Internet Explorer 7, basically any web browser created after

year 2000.

TCP / IP (Transmission Control Protocol / Internet Protocol): data transmission protocol

that allows for computers to communicate with one another over a network.

An Operating System: preferably Windows XP professional and above.

4.3 SYSTEM DESIGN

Based on observation and interview, the researcher found out that the systems used in

collection of information is manually or using some other local based computer applications.

The interview and observation helped in the type of electronic system created.

Document Inspection

Table 4.3.1: Registration field for educational institutions, local government, state

health facilities and corporate organisations

Field Name Field Description Field Type

Category What category a record falls into List/Menu

Details Brief detail about what such record is Text Field

Full info Details about the record Longtext

Main IDIts hidden, but automatically generated

when a record is createdNumber (Auto increment)

Picture It holds logos about records File Field name

Posted Shows the date a record was created Date

Subcategory A subcategory of a category List/Menu

Title The topic of a record Text Field

User ID Hidden piece of information about user Text Field

Table 4.3.2: Registration field for market days35

Page 36: CHAPTER 1

Field Name Field Description Field Type

Entity ID Hidden piece of information about event Text Field

Title Market name Text Field

Description Brief detail about the market Text Field

User ID Hidden piece of information about user Text Field

Date The initial date the market comes up Date

4.4 DOCUMENTATION

The system to be deployed contains various units. They include:

About us page

Menu page

Admin login page

Category page

Subcategory page

Add new record page

Edit record page

Record search page

Printer-friendly page

Export result page

More details page

View all markets page

View market dates page

Add / Edit market page

4.4.1 INDEX PAGE

36

Page 37: CHAPTER 1

The index page contains a summary on Ogun State, basic information about the state. From

its government to its environment, markets etc. To proceed to the next page to access the

database, there is proceed please link at the bottom of the index page. See fig. 7.

Fig. 7: Index Page, summary about Ogun State.

The next page to be viewed is the main navigation page. It is from this page the database can

now be accessed on a UI (User Interface). From the menu page, there are four available links.

See fig. 8.

HOME: Leads one back to the index page.

Admin: As said earlier on, there are two databases in this work,

o Database 1: it contains information about Local Governments, Schools in the

state, state health facilities, industries etc.

o Database 2: Contains markets in the state with their days of re-occurrence.

37

Page 38: CHAPTER 1

But this Admin link is the administrator page for database 1.

Search for L.G / Industries: it is a link to database 1.

Market Days: it is a link to database 2. It displays all the markets in the state with

some re-occurring days. Makes it easy in calculating market days in every local

government in Ogun State.

Fig. 8: Menu page

4.4.2 ADMIN LOGIN

After clicking the Admin link, the next page launched has the following attributes:

(See fig. 9)

HOME: leads one back to the main navigation page.

Username & Password: every administrator types in his / her username and

password to be granted access to database 1.

38

Page 39: CHAPTER 1

Fig. 9: Database 1 Admin Login page.

4.4.2.1 USER AND PASSWORD

Administrators can log in from this page, which should be after he / she has typed in the

username and password database 1 admin page. After a successful login in session, the next

accessible page has a variety of links an administrator could fiddle with. The following links

are on the administrator’s first page: (See fig. 10)

Fig. 10: Administrator’s first page.

4.4.2.1.1 LOGOUT

An administrator can use this link to sign out of the admin page of database 1. After / before

he / she is done with whatever he / she wants to do on the admin page. It directs a user back to

Database 1 Admin Login page.

39

Page 40: CHAPTER 1

4.4.2.1.2 MAIN

The main page is the friendly-UI for the database 1. It has to itself various links that have

their own uses and speciality. With this interface, administrators can input, edit and delete

specific / various information they intend to alter / delete. It makes it a whole lot easier this

way, cause of its simplicity and it is easily understandable. See fig. 11.

Fig. 11: Main

The Main page includes the various links:

1. LOG OUT:

As soon as an administrator is through with whatever work he / she wants to do, the log out

link when clicked would redirect the administrator to the database 1 login page.

2. EXPORT RESULTS:

A situation where an administrator wants to get a search result or even the whole database in

a common file extension, the export result makes it easy for such to be done. It brings all the

information into the administrator’s desired / preferred extension.

40

Page 41: CHAPTER 1

As soon as an administrator clicks the export result link it opens another page that allows the

administrator select what data range he/she wants to export and what output format. After

selecting that, click export, it is then saved on the system in whatever format has been

selected. See fig. 11.

Fig. 11: Export page

3. PRINTER-FRIENDLY VERSION:

If an administrator desires a hardcopy of the main page, rather than a soft copy, the printer-

friendly version makes it easy doing so with no fuss at all. After clicking the link, it

automatically generates the information on the screen at that moment, with all the details

therein; place all the information in separate tables so as to create demarcations and for clarity

sake. Such a page can then be printed for anyone to read. See fig. 12.

41

Page 42: CHAPTER 1

Fig. 11: Printer-friendly generated information.

4. ADD NEW:

It is used by an administrator to add new information. It is used to add new record to database

1. On clicking the ‘add new’ link, a page that has a couple of information is displayed. See

fig. 12.

42

Page 43: CHAPTER 1

Fig. 12: Add new record page.

Add new record page contains the following information to be fit in by the administrator.

BACK TO LIST:

Returns an administrator to the main page.

CATEGORY:

It has a drop down list; it contains a couple of categories that have been typed into the

database by the administrator. See fig. 13.

43

Page 44: CHAPTER 1

Fig. 13: Category drop down menu list.

Administrators can add sub-categories from here, there’s add new button just beside the drop

down menu list. When add new button is clicked, a box pops-up just beside and allows an

administrator to add the ‘CategoryName’ and save it. See fig. 14.

Fig. 14: Add new pop-up box.

DETAILS:

Show a brief information about the information fit in by the administrator. Whatever

information to be typed in here should be a summary about what information would be fixed

into this group. See fig. 14.

Fig. 14: Details box.

44

Page 45: CHAPTER 1

FULL INFO / VIEW SOURCE:

This is the box where everything about what you want to save in the database should be

typed. Fig. 15 shows the full info box and the added toolbars infused to enhance typing.

It has been equipped with a toolbar containing a few tools such as the style that allows users

to type in either the paragraph, heading 1 / 2 / 3 etc styles.

It has the fonts with some pre-defined fonts to select from; it contains size that allows for

users to select one of the predefined sizes.

It allows for bolding of fonts, italics and even underline. It is further enhanced to make users

align text to wherever they want, includes numbering and bullet, decrease and increase indent.

Users can also choose font colours, background colour, include hyperlinks and also import

pictures to the full info box.

Fig. 15: Full info box with a few tools to enhance typing.

The view sources check button automatically converts the full info box into an html format.

Fig. 16 shows how a checked view source button converts an enhanced typing sheet to an

html typing sheet.

45

Page 46: CHAPTER 1

Fig. 16: A checked view source button.

PICTURE / FILE NAME:

The database can directly access the local hard disk pictures. Users can attach desired pictures

to new information by clicking the browse button, navigating to wherever their desired

picture on the hard disk is located and then attached to the information. The file name shows

the picture’s name. See fig. 17.

Fig 17: Picture & File name bars.

SUB CATEGORY:

Most categories could be made to have a sub category, so as to make searching and tagging of

information easy. Fig. 18 shows how the sub category drop down list is.

Fig. 18: Sub category.

46

Page 47: CHAPTER 1

Administrators can also add new sub categories. Beside the drop down list is add new link.

To add new sub categories, an administrator could do so by just clicking on add new link,

select the category he / she wants to add to the sub category to and then save. See fig. 19.

Fig. 19: sub category pop up box.

TITLE:

Gives any saved piece of information a name of its own. Title is an important and required

detail to be added before information can be saved. See fig. 20.

Fig. 20: Title bar.

SAVE AND RESET:

The save button is clicked after the administrator must have completed inputting data into the

database. Reset is used when an administrator discovers he / she must have made numerous

and uncountable mistake while inputting information, the reset button wipes off all the

information on the add new record screen. It is easier than clearly each box one after the

other. See fig. 21.

47

Page 48: CHAPTER 1

Fig. 21: Save and Reset Buttons.

5. Inline Add:

It enables administrators add more information without switching from the current page

(main page) they are viewing. See fig. 22.

Fig. 22: Inline Add

The inline add has spaces for administrators to give information, unlike add new page that has

all its boxes tagged, the inline add does not. The following spaces are in there:

CATEGORY:

Just as it works in add new page, so it is here, no difference. It has a drop down list; it

contains a couple of categories that have been typed into the database by the administrator.

All that needs to be done is just to select the desired one. But unlike add new page’s type,

administrators cannot add new sub categories. Fig. 23 shows the subcategory drop down list

Fig. 23: Category drop down menu list.

48

Page 49: CHAPTER 1

SUB CATEGORY:

Works almost the same way it is in add new page, the only difference is administrators cannot

add new subcategories from the inline add new. Fig. 24 shows how it looks like.

Fig. 24: inline sub category.

TITLE:

Gives any saved piece of information a name of its own. Title is an important and required

detail to be added before information can be saved.See fig. 25.

Fig. 25: the title bar.

PICTURE / FILE NAME:

The database can directly access the local hard disk pictures. Users can attach desired pictures

to new information by clicking the browse button, navigating to wherever their desired

picture on the hard disk is located and then attached to the information, while the filename

shows the picture name. See fig. 26.

Fig. 26: Picture and file name.

49

Page 50: CHAPTER 1

DATE POSTED.

Allows for administrators to input date, information is added to the database, so as to increase

authenticity of information. By default, the initial date shown is the current system date, to

show the database is directly connected to the system’s configurations. See fig. 27.

Fig. 27: posted on bar.

DETAILS:

Shows a brief information about the information fit in by the administrator. Whatever

information to be typed in here should be a summary about what information would be fixed

into this group. See fig. 28.

Fig. 28: details bar.

SAVE AND CANCEL:

The inline add option has buttons that enable administrators add information and also cancel

the whole adding operations. The save button is represented with the tick / correct sign, while

the other represents the cancel / return button. See fig. 27.

50

Page 51: CHAPTER 1

Fig. 29: save and cancel.

6. TOOLS FOR INFORMATION RETRIEVAL

Right on top of the inputted data / sorted information is a toolbar that aids information

retrieval and sort of information.. The toolbar includes: (See fig. 30)

Fig. 30: Toolbar.

SEARCH FOR:

It makes searching for information easy, administrators could limit search to specifications.

The drop down list makes an administrator limit his/her search either by selecting any

field / category / subcategory. See Fig. 31

Fig. 31: drop down list.

The second drop down menu has a few attributes in it that also make search for

information easy. Depending on what information to be loaded and requested by an

administrator, he / she would select the most appealing and best search attribute. It

includes:

Contains...: what is to be typed in the search box must be in whatever

information to be displayed.

Equals...: what is to be sought for must be exactly like what is typed.

51

Page 52: CHAPTER 1

Start with...: whatever is sought must begin with what is typed, it is unlike

‘contains...’ only if it starts what is sought would it show.

Empty: makes no difference to the search term. (See Fig. 32)

Fig. 32: Second drop down list.

SEARCH BAR:

Administrators can type whatever information they intend to retrieve here. See fig. 33.

Fig. 33: Search Bar.

SEARCH AND SHOW ALL BUTTON:

After an administrator must have keyed in all the necessary apparatus for his / her search,

then the need to click the search button comes to play.

Also when he / she is through and needs to see all the necessary information, all the

administrator need do is to click the show all button, this button clears the search terms,

returns all search apparatus to default and then the whole information is displayed once again.

See fig. 34.

Fig. 34: Search button and show all button.

52

Page 53: CHAPTER 1

DETAILS FOUND AND RECORD PER PAGE:

Details found show the number of record in the database and number of available pages.

Records per page shows the number of record a page displays. An administrator is able to

choose according to the number of records he/she wants to be seen displayed on the screen.

By default its set at 20, but an administrator can either choose 10, 20, 30, 50, 100 and 500.

See fig. 35.

Fig. 35: Details found and record per page.

7. EDITING LINKS:

It contains a few links an administrator uses to make adjustments to the database. See fig. 36.

It includes:

Fig. 36: Editing links.

Select / Unselect all: if an administrator intends selecting all the records in the

database. When clicked once again it unselects all the records.

Delete selected: it deletes record that have been selected by an administrator.

Edit selected: it provides the administrator the opportunity of editing lots of record

sequentially without having to return to the main page.

Export selected: an administrator can select the records he/she wants to export in

generally acceptable formats.

Print selected: an administrator has the opportunity of selecting the numerous records

that he / she desires to print.

8. CATEGORY VIEW:53

Page 54: CHAPTER 1

It makes it easy for an administrator to retrieve information without much fuss. Since every

type of information is tagged to a particular category, it makes administrators get records

from them by just selecting the category their record falls in. See fig. 37.

Fig. 37: Search by category view.

9. RECORDS:

It is a sort of slot containing whatever information has been typed by an administrator. It

includes: (See fig. 38)

Fig. 38: Example of a record.

54

Page 55: CHAPTER 1

Picture: shows attached picture. In fig. 38 the picture displayed is the Ogun State logo

with Abeokuta North inscribed underneath.

Category: it shows what category a piece of record was saved in. In fig. 38 ‘L.G’ is

the category.

Title: what can be easily identifiable by anyone. In fig 38ABEOKUTA NORTH is

the title of the record.

Posted on: it should show the date the record was saved. Most times its created by the

administrator.

Details: just a brief summary of the record. In fig. 38 ABEOKUTA NORTH

LOCAL GOVERNMENT is the details. It clearly shows what that record slot holds,

information about the local government.

Checkbox: allows an administrator check a record either for printing, exporting,

deleting / editing.

Edit: as an administrator, he/she has the ability to alter whatever information deems

inappropriate/wrong. When the edit link is clicked, it opens a page containing the

information in the record, now giving the administrator to do whatever feels right to

such piece of information.

55

Page 56: CHAPTER 1

Fig. 39: Edit page.

The edit page is not so different from add new page. The main difference is the posted

and a minor one is the picture.

o Posted: it enables administrators add the date the record was edited. It has three

drop down menus and a small picture of a calendar.

The first drop down menu has the months of the year; the second has the days

in a month while the third has numerous years, ranging from 1913 to 2023.

The calendar makes date selection easy, once clicked; it pops up in a small

window, allowing the administrator to select whatever date, works almost like

the drop down menus. See fig. 40.

56

Page 57: CHAPTER 1

Fig. 40: Calendar.

o Picture: the picture in the edit information only differs if while the information

is been added, the administrator included a picture in this spot, if not there

would be no difference with add new page.

If any administrator wants to retain the existing picture, he / she would select

the keep radio button but if he / she wants to delete the picture, all that needs

to be done is just selecting the delete radio button.

Whereas, a situation where an administrator wants to change the picture,

he/she would just select the update radio button, click on browse and then

select the desired picture. An administrator does not need to delete the existing

picture before coming back to update, since update has been chosen, it

automatically replaces the existing picture with the new picture.

Inline edit: not different from the inline add except for the picture. What goes with

the picture in the edit page goes with the picture in the inline edit. See fig. 41.

57

Page 58: CHAPTER 1

Fig. 41: Inline edit.

More details: shows what an administrator has typed in to be saved as a desired

record. More details show an administrator just how a record will be shown to a

guest / normal user of the database. See fig. 41.

Fig. 41: More details.

More details includes a few links such as

o Back to list: returns an administrator back to the main page.

o Edit: opens the edit page and allows an administrator to edit the information.

58

Page 59: CHAPTER 1

o View Printer-friendly page: allows an administrator print out the information in a

more simplified format.

10. FOOTER PAGE SELECTOR:

Allows administrators select between pages. An administrator could switch from the first to

the last page and back, to wherever he/she wishes to go. See fig. 41.

Fig. 41: Footer page selector.

4.4.3 SEARCH FOR L.G/INDUSTRIES

The search L.G / Industries is a link a user will see on the main navigation page. Once

clicked, it directs a user to the user-friendly page that enables every general user interact with

the database. Still part of the database 1, but then not an administrative one. It is for an

everyday guest / user. It produces results of what an administrator has fixed into the database.

A guest has no opportunity of inputting information into the database; all he/she can do is

search for information. Its interface is almost like the administrators’ main page, just with the

alter options missing (purposefully). It is easy to search for information, copy records and

also copy. See fig. 42.

The guest main page has a few links a user could work with, they include:

Fig. 42: Guest main page.

59

Page 60: CHAPTER 1

1. LOG OUT:

Once a user is done interacting with the database, he / she can always go back using the log

out link. It makes it easy without making things fussy looking for a backspace button. It was

purposefully place at the top side of the page for users to easily identify it and make use of.

Once clicked, it returns a user to the main navigation page.

2. EXPORT RESULT:

As it works in the administrator’s page it does so here too. Users are allowed to export

desired results, into generally accepted formats. Formats such as Excel, Word, CSV and

XML. Users that click the export result link are directed to a different page that allows a user

select the records to be exported and the format it should be saved. The interface differs a bit

from the administrators’. See fig. 43.

Fig. 43: Export page.

3. PRINTER-FRIENDLY VERSION:

The printer-friendly version makes it easy for a user to print whatever record(s) he / she wants

to print; rather that opening one record at a time, a user could always select desired records to

be printed. Shows just like the administrator does, it collates information and records into

tables which allows for clarity.

60

Page 61: CHAPTER 1

4. TOOLBAR:

Just like the administrator gets to work with tools on his/her toolbar, a user also gets to.

Limited in tools though, but the available ones are just to match guest / user needs. The

toolbar includes: (See fig. 44)

Fig. 44: Toolbar.

Drop down list 1:

It allows users to limit their search. It contains a few categories such as L.G, Markets

and Industries.

Drop down list 2:

The second drop down menu has a few attributes in it that also make search for

information easy. Depending on what information to be loaded and requested by an

administrator, he / she would select the most appealing and best search attribute. It

includes:

Contains...: what is to be typed in the search box must be in whatever

information to be displayed.

Equals...: what is to be sought for must be exactly like what is typed.

Start with...: whatever is sought must begin with what is typed, it is unlike

‘contains...’ only if it starts what is sought would it show.

Empty: makes no difference to the search term.

61

Page 62: CHAPTER 1

SEARCH BAR:

Users can type whatever information they intend to retrieve here after selecting what search

apparatus they feel suits them best.

SEARCH AND SHOW ALL BUTTON:

After users must have keyed in all the necessary apparatus for his/her search, then the need to

click the search button comes to play.

Also when he / she is through and needs to see all the necessary information, all the

administrator need do is to click the show all button, this button clears the search terms,

returns all search apparatus to default and then the whole information is displayed once again.

DETAILS FOUND AND RECORD PER PAGE:

Details found show the number of record in the database and number of available pages.

Records per page shows the number of record a page displays. An administrator is able to

choose according to the number of records he/she wants to be seen displayed on the screen.

By default its set at 20, but an administrator can either choose 10, 20, 30, 50, 100 and 500.

SELECT / UNSELECT ALL:

If a user intends selecting all the records in the database. When clicked once again it unselects

all the records.

EXPORT SELECTED:

Users can select records he / she wants to export in generally acceptable formats.

PRINT SELECTED:

Users have the opportunity of selecting the numerous records that he / she desires to print.

62

Page 63: CHAPTER 1

5. RECORDS:

Almost the same way it shows on the administrators’ page. It is a sort of slot containing

whatever information has been typed by an administrator. It includes: (See fig. 45)

Fig. 45: Record.

Picture: shows attached picture. In fig. 45 the picture displayed is the Ogun State logo

with Abeokuta North inscribed underneath.

Category: it shows what category a piece of record was saved in. In fig. 45 ‘L.G’ is

the category.

Title: what can be easily identifiable by anyone. In fig 45 ABEOKUTA NORTH is

the title of the record.

Posted on: it should show the date the record was saved. Most times it is created by

the administrator.

Details: just a brief summary of the record. In fig. 45 ABEOKUTA NORTH

LOCAL GOVERNMENT is the details. It clearly shows what that record slot holds,

information about the local government.

Checkbox: allows an administrator check a record either for printing / exporting.

6. FOOTER PAGE SELECTOR:

Allows users select between pages. Users could switch from the first to the last page and

back, to wherever he / she wishes to go.

63

Page 64: CHAPTER 1

4.4.4 MARKET DAYS.

It makes calculation of all market days in the state with no fuss. It contains all the open

markets in the state with three hundred and sixty five (365) reoccurring days of each market.

As soon as a user clicks the market days link on the main navigation page, it re-directs a user

to page containing a calendar.(See fig. 46)

The calendar makes use of every system operations to work, users can search for information

using the Ctrl + F key on their windows O.S web browser or check their browser option and

look for find, that way, users can search for market days and then check for more information

about the market and its reoccurring days.

Fig. 46: Market Calendar Interface.

4.4.4.1 ACCESSING DATABASE 2

Every user administrative or not is face with the calendar-like interface. A guest with no

administrative power would have limited links on the toolbar. They include: (See fig. 47)

CATEGORY VIEW:

It allows a user sort market days in whatever format they wish it be sought. They are:

(See fig. 48)

Fig. 48: Toolbar – 1.

64

Page 65: CHAPTER 1

o Year: users can view market days in yearly sequence. It contains orange boxes,

each representing different markets. (See fig. 49)

As soon as any of the boxes is clicked, a new window is popped up containing the

market days. (See fig. 50)

Fig. 49: Year view.

Fig. 50: Market days popup window.

o Upcoming: it shows the closet events coming up. It shows market days for the

next thirty days. (See fig. 50)

65

Page 66: CHAPTER 1

Fig. 50: Upcoming view.

o Quarter: it shows markets coming up in the next three months, users can then

cycle which of the quarters in the year they want to view. Its view is almost like

the years’.

o Month: it shows market days coming up in the month. From the first day to the

last day of the month.

o Week: it shows re-occurring markets in a week. (See fig. 51). After selecting what

day a user intends viewing, it then shows a different table that includes the market

for the day (See fig. 52). A user is then allowed to click what market and the

market days window pops up.

Fig. 51: Week view.

66

Page 67: CHAPTER 1

Fig. 52: Day view.

o Day: it shows markets coming up in a day, users can then select what day they

intend viewing. (See fig. 52).

DATE SELECTOR:

It shows the calendar is created as a market event, date, allows for date selection and has the

login button for administrators. (See fig. 53)

Fig. 53: Toolbar – 2.

4.4.5 LOGIN

As for administrators, they have the login access. Once they click login, type the username

and password, they immediately have the ability to edit and make adjustments to the calendar.

4.4.5.1 CATEGORIES

A good place to start in managing your calendar is to create various categories for your

events. While not required, adding categories might be desirable if you have a whole lot of

events or want users to be able to filter the calendar to only show certain types of events. Be

67

Page 68: CHAPTER 1

sure to take a look at the configuration variables; $include_child_categories and

$include_parent_categories to determine how nested categories are to be displayed.

The initial installation has only one category which is named after the title of the calendar,

which is ‘market days’. All new categories must be sub categories of this default, parent

category. To create a new category, click on the "add new category" link. This brings us a

short form for you to enter the details of your new category.

In addition to entering a category name, you can select which category your new category is

going to be a sub category. Again, all additional categories need to be a sub category of the

default, parent category, but there are no limits to how many levels of sub categories can be

created. It’s also possible to re-arrange the nesting of your categories in the future without

loosing any event data. The order in which categories of the same generation are displayed is

determined by the Sequence field.

Optional fields are the Text Colour and Background fields. You can pick the colours that will

determine the foreground and background of those events listed in the category. Currently,

the Description field is not used but is likely to be utilized in future display modules.

4.4.5.2 GROUPS

Groups are separate calendars. They are nested similarly to categories. However, unlike

categories, there is no way to show events of different groups within the same page. This

feature was put in place so that users could have both private and publicly accessible

calendars within the same installation, or provide separate calendars for different departments

or individuals within the same organization, but the groups used here is ‘market events’.

68

Page 69: CHAPTER 1

4.4.5.3 LINKS

Event calendars typically include venue and contact information for the events they feature,

and these are often repeated from event to event. Thus, SuperCali stores repeated location and

contact information in the database, referenced under the tab, "Links." Here you can add

commonly used venue and contact information to be showed with your events, which can be

included in an event using drop down, select menus featured in the Add Event and Edit Event

screens.

4.4.5.4 ADD EVENT / EDIT EVENT

Clicking the Add Event or Edit Event link will bring up a pop-up window where you can

enter event information, such as the Title, Group and Category. Venue and Sponsor fields are

drop-down, select fields where you can add previously entered contact information under the

Links tab, or alternately leave these blank and enter the information in your main description.

(See fig. 54)

When posting to a Group, the user can either propose or post events to a calendar, and

indicate whether to notify other subscribed users of the addition or change. This will then sent

through an e-mail to those users informing them of the event. Below this general event

information is a four column table for scheduling dates for the event.

The first column will include a checkbox for any existing events which, when checked, will

delete the date when the "Add / Edit Dates" button is clicked. The next column indicates the

dates of the event and can be added or edited directly or by clicking the calendar icon to bring

up a pop-up calendar. The next column indicates whether it is an all day event, To Be

Announced (TBA) or has time entered to the right. The final two columns indicate the start

and end times for the event, which also have pop-up select menus to assist with data entry.

The end time field is optional.69

Page 70: CHAPTER 1

When starting with a new event, only one row is present in the date’s table. This is the row

used to Add a new date and time to the event by clicking the "Add / Edit Dates" button. Once

added, the Add Event screen will refresh and show the added event in the row directly above

the Add Event row. Additional dates and times can be added, and any existing dates and

times edited, until all occurrences of the event have been entered.

The final field is the description, which can be used for any additional information and details

for your event. Once all the dates have been entered and you are finished with the event, click

on the "Add Event" or "Update Event" button at the bottom of the screen to save your event.

The main calendar screen will automatically refresh to show your changes.

Fig. 54: Add Event Window.

70

Page 71: CHAPTER 1

4.4.5.5 DELETE EVENT

Deleting an event will delete all instances of the event, not just a specific date in question. If

only one date is to be deleted then click the "Edit Event" link next to it and delete the specific

date using the Edit Event screen.(See fig. 56)

Fig. 56: Delete

4.4.5.6 CSV UPLOAD

This form provides for uploading of event data in a Comma Separated Values (CSV) text

file to the SuperCali Calendar.

Order of columns is; title, venue id, contact id, category id, date, start time, end time and

description. The first row of the CSV file, used for column descriptions, is ignored.

4.4.5.7 USERS

The users menu allows you to add and edit users and their privileges for using SuperCali.

There are three main areas that can be edited including their e-mail address / password, access

privileges and individual category permissions to view, post and moderate other users entries.

The two main access privileges include the ability to add / edit / remove the SuperCali

categories and whether or not the user can edit other users. If a user has category editing

privileges, you can select which categories each user can post or moderate (edit) other users

posts. Permission to moderate a category also implies the ability to post events to that

category.To save changes, either click "Add Profile" or "Update Profile"

71

Page 72: CHAPTER 1

4.4.5.8 MODULES

The modules menu is used to add, edit and delete "modules" used to display information on

the calendar.

The first column, Delete, has a checkbox that, if checked, will delete the module from the

calendar. The next two columns, heading and link name, correspond to the headline and

navigation link name which are shown to the user. Active indicates whether the module is

currently displayed and Sequence indicates the relative order of each module.

Year, month, week and day correspond to the module id that certain links imbedded in that

module should link to. Some of these links are not used, depending on the module.

Click "Update Modules" in order to make finalize changes to the modules.

In addition, any module files that are found in the modules directory, but not yet installed,

will be shown with a description. Click on the Add link at the bottom of each description to

install the new module. To install a new module from scratch, upload the module and

supporting files to the modules directory first, then visit the modules page to add it.

4.3.4.9 LOG OUT

To log out of your calendar management session, click the "Log Out" link.

72

Page 73: CHAPTER 1

CHAPTER 5

SUMMARY, CONCLUSION AND RECOMMENDATION

5.0 SUMMARY

In summary, this work is the design of a web-based database system to enhance record

management processes of educational information, state health facilities information, local

government information, market days dates and corporate information in selected Ogun State

Government ministries - Ministry of Information, Ministry of Finance, Ministry of Education,

Science and Technology. The web based database system is designed to eliminate the

problems of information duplication, inconsistency in information and also difficulty in

sharing information as stated in the problem statement.

5.1 CONCLUSION

The adaptation of ICT in governmental ministries is a necessity, in this 21 st century, an

organisation – government agencies – that does not tap into the ICT field is sure to be left

behind. ICT seeks to improve work efficiency and ease working activities.

This work seeks to produce a long lasting solution to the problem of duplication of records,

inconsistency in records kept and difficulty in sharing the records amaongst colleagues and

even clients, therby making records management activities simple and improving work

efficiency by the development of a web-based database.

The web-based database is to manage information such as educational institutions in the

satate, corporate organisation information, state health facilities, local government

bibliography and calculation of all open market days in the state.

73

Page 74: CHAPTER 1

The database was designed using MySQL alongside PHP; PHP was used because of its

dynamic nature in the web-based environment.

The database offers administrative users the opportunity of inputing data, editing,creation and

deletion of categories, subcategories and records, while none administrative users can only

search for records, view records, print and export results.

With the adaptation of such information in governmental ministries, retrieval of information

would be made easy and also improve work activites.

5.2 RECOMMENDATION

This work recommends the adoption of web-badsed database system in Ogun State

Government ministries in general. This web based database could be expanded to also include

various kinds of records and be adopted in various departments and ministries in Ogun State

government. Change is a constant factor in human and technology, this system can be

upgraded from time to time.

5.3 CONTRIBUTION TO KNOWLEDGE

This study examined the problem faced in records management in the selected government

ministries. It recognized the need for a better method of records management activity over the

current system in place at the various ministries. Consequently, it gave rise to the

development of a web-based database to aid records management activities in the selected

ministries. The database is to improve work efficiency by creating a system that would not

alter the method of records creation, storage, sorting, organising and dissemination but make

it easier to access and make you of. The designing of a web-based database contributed

immensely to the field of both Information Communication Technology and records

74

Page 75: CHAPTER 1

management. It would be useful for researcher in the field of records management and web-

based database development.

5.4 SUGGESTION FOR FURTHER STUDIES

This work focused majorly on some particular ministries – Ministry of Information and

Strategy, Ministry of Finance and Ministry of Education Science and Technology -, it also

focused on particular information such as information about all educational institution,

industries, state health facilities, local governments and market days. Hence, based on the

above mentioned scope, this suggestion is recommended

1. Advancement should be made to governmental ministries record management

practises.

2. Design of a Management Information System for all Ogun State Government

Ministries.

75

Page 76: CHAPTER 1

REFERENCE

Database. (2011). Retrieved January 21, 2013, from wikipedia:

http://en.m.wikipedia.org/wiki/Database

E. Shepherd and G. Yeo (2003). Managing Records: A Handbook of Principles and Practice.

London: Facet, pp.156-157.

Ebrary, Inc. (2005). The Hutchinson Dictionary of Computing and the Internet. Abingdon:

Helicon Pub.

Florida Department of State, Division of Library and Information Services. (2010). State of

Florida: ELECTRONIC RECORDS AND RECORDS MANAGEMENT

PRACTICES. Florida

Gentry, J. (2005) How Databases Work For Records Management. Xpert Systems, Inc.

Hunter, G. S. (1997). Developing and Maintaining Practical Archives: A How-toDo-It

Manual. New York: Neal-Schuman Publishers.

I. A. Penn, G. B. Pennix and J. Coulson (1994). RecordsManagementHandbook.2nd Ed.

England: Gower Publishing Co, p.9.

International Records Management Trust Evidence-based governance in the electronic age,

building awareness and capacity (London: IRMT, 2000).

International Records Management Trust The management of public sector records:

principles and context (London: IRMT, 1999).

International Standards Organisation ISO 15489-1:2001 Information and documentation-

records management. Part 1, General (London: British Standards Institution, 2001)

Introduction to Database Management Systems (2008). Retrieved October 12, 2012, from

PennStateUni:http://www.personal.psu.edu/glh10/ist110/topic/topic07/topic07_05.htm

76

Page 77: CHAPTER 1

Kallaus, N F and Johnson M M Records management 5th Edn. (Cincinnati, OH: South-

Western Publishing Company, 1992).

Keenan, S. and Johnston, C. Concise dictionary of library and information science 2nd Edn.

(London: Bowker-Saur, 2000).

McDonald A ‘Records management and Freedom of Information.’ Available at

<http://www.lcd.gov.uk/foi/agop1299.htm>. Accessed 12/03/03.

Mnjama, Nathan and Wamukoya, Justus, "E-government and Records Management: an

assessment tool for e-records readiness in government," The Electronic Library 25, no.

3 (2007) [journal online: Emerald Group] [accessed 22 November 2008].

Oxford Electronic Dictionary (1996 – 2007)

Porter-Roth, B. (2006). Applying Electronic Records Management:An Integrated Approach.

XEROX: DocShare.

R G Healey (1991) Database Management Systems: 254 – 257.

Raghu, R., Johannes, G., Jeff, D., Scott, S., & Lin, Z. (2011). Database Management

Systems Solucstions Manual.

Records Life Cycle (2012). Retrieved September 20, 2012, from SouthAfricaGov:

http://www.decd.sa.gov.au/rmp/pages/cg0000941/lifecycle/?reFlag=1

Rodriguez, Gene , What are the Most Common Types of Databases (2008). Retrieved

November 2, 2012, from Life123: http://www.life123.com/technology/computer-

software/database-software/what-are-the-most-common-types-of-databases.shtml

Rowley, J. (1998). Towards a framework for information management. In International

Journal of Information Management, 18(5) (pp. 359-369).

Terry, L. (2005). Management Information Systems.

77

Page 78: CHAPTER 1

T R Schellenberg Modern archives, principles and techniques (Melbourne: F.W. Cheshire,

1956): 16.

Ty Arthur, Types of Databases (2012). Retrieved September 16, 2012, from eHow:

http://www.ehow.com/m/about_4727727_types-of-databases.html

web-based. (2012). Retrieved September 20, 2012, from The free dictionary:

http://encyclopedia2.thefreedictionary.com/_/dict.aspx?word=Web-based

78

Page 79: CHAPTER 1

APPENDIXABOUT US PAGE

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>HOme</title>

<style type="text/css">

<!--

.style1 {font-family: Geneva, Arial, Helvetica, sans-serif}

a:link {

color: #CC0000;

text-decoration: none;

}

a:visited {

text-decoration: none;

}

a:hover {

text-decoration: underline;

color: #FF9900;

}

a:active {

text-decoration: none;

color: #A62007;

}

body {

background-image: url();

background-repeat: no-repeat;

}

.style2 {color: #990000}

-->

</style>

</head>

<body>

<table width="902" border="0" align="center" cellpadding="0" cellspacing="0">

<!--DWLayoutTable-->

<tr>

<td width="902" height="109" valign="top"><img src="images/mrarkdb.png" width="900" height="109" /></td>

</tr> <tr>

<td height="494" valign="top">&nbsp;&nbsp;&nbsp;<br /> &nbsp;&nbsp;<span class="style1">OGUN STATE</span>.<br />

<br />

<strong>CREATION</strong>: February 3,1976<br />

<strong>LAND CREATION</strong>:16,369,40 Square kilometres<br />

<strong>POPULATION</strong>:(2012 estimate)&nbsp; 4,539,695<br />

<strong>STATE CAPITAL</strong>:Abeokuta<br />

<strong>ARMS OF GOVERNMENT</strong>:

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />

i.&nbsp; Executive- Headed by <strong><em>Senator Ibikunle Amosun (Governor)</em></strong><br />

ii.&nbsp; Judiciary- Headed by <strong><em>Justice Olatokunbo Olopade (Chief Judge)</em></strong><br />

iii. Legislative- Headed by <strong><em>Rt. Hon. Suraj Ishola Adekunbi (Speaker OGHA)</em></strong><br />

<strong>Location</strong>: it lies within the tropics. It is bounded in the west by Benin Republic; in the South by Lagos State and the Atlantic Ocean; in

the east by Ondo State and in the north by Oyo and Osun States.<br />

<strong>Local Government</strong>: there are 20 local government councils in the state.<br />

<strong>Senatorial districts</strong>: there are three senatorial districts in the state; Ogun Central, Ogun West and Ogun East.<br />

<strong>People: the People of the State</strong> are predominantly yorubas and can be broadly put into the following dialectical groups viz: Egbas,

Yewas, Aworis, Ijebus, Remos and people belong to the main Yoruba ethnic group. Nigerians from other part of the country also live in the state.<br />

<strong>Climate and Vegetation</strong>: the climate is tropical with two distinct seasons; the rainy season (April-October) and the dry season

(November-March). The temperature throught out the year ranges from 23oc &ndash; 32oc while the humidity is relatively high (68.33oc). the annual rainfall

ranges from 1201.60mn in the southern parts to 951.70mn in the Northern areas. The rainfall decreases in amount and distribution from the coast to inter lands.

79

Page 80: CHAPTER 1

As a result of this, the state enjoys generally luxuriant vegetation; a high forest zone (or rain forest) is found in the south while the northern fringe is mostly sub-

savannah forest.<br />

<strong>Tourism</strong>: there are many tourist centres in the state with numerous potentials. The centres include; Olumo Rock at Abeokuta, Birikisu

Sungbo Shrine at Oke-Eri via Ijebu-Ode, Yemoji Natural Swimming Pool at Ijebu-Ode and Ebute-Oni in Ogun Waterside.<br />

Rivers: Among the numerous rivers are: Ogun, Egbin, Yemoji, Yewa, Apoje and Yemule.<br />

<strong>Markets</strong>: a total of two hundred and seventy-one markets are in the state.</td>

</tr> <tr>

<td height="19" align="right" valign="bottom"><a href="http://localhost/marketDB/Classified1/output/login.php" class="style2">Procead please</a>

&nbsp;&nbsp;</td>

</tr> <tr>

<td height="40" valign="top"><img src="images/bagd.jpg" width="902" height="40" /></td>

</tr>

</table>

</body>

</html>

MAIN NAVIGATION PAGE

<html>

<head>

<title>Login</title>

<link REL="stylesheet" href="oldinclude/style.css" type="text/css">

</head>

<body bgcolor=white onLoad="javascript:document.forms[0].username.focus();" text="#000000" leftmargin="0" topmargin="0" marginwidth="0"

marginheight="0" link="#0066cc">

<p align="center"><img src="images/mrarkdb.png" width="900" height="109" /></p>

<table width="900" border="1" bordercolor=#2237cbb align="center" cellpadding="5">

<tr>

<td>

<p align=center>Welcome &nbsp;</p>

<table width="100%" border="0" cellspacing="0" cellpadding="0" height="99%">

<tr>

<td valign="center" align="middle">

<table width="100%" border="0" cellspacing="0" cellpadding="0">

<!--DWLayoutTable-->

<tr>

<td width="69" height="19">&nbsp;</td>

<td width="49" valign="top"><a href="http://localhost/marketDB/Classified1/output/home.html">Home</a></td>

<td width="860">&nbsp;</td>

</tr>

</table>

<table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td>

<table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td bgcolor="#ffffff" valign="top" align="right">

<table width="300" border="0" cellspacing="4" cellpadding="4" align="center">

<tr>

<td>&nbsp;</td>

</tr>

</table>

<form method="POST" action="login.php" id=form1 name=form1>

<table width="300" border="0" cellspacing="1" cellpadding="4" align="center" bgcolor="#cccccc">

<tr>

<td align=middle class=blackshade>

<b><font size=+1>What Do want To Do </font></b></td>

</tr>

<tr>

80

Page 81: CHAPTER 1

<td valign="top" class=shade>

<DIV align=center>

<table width="200" border=0 align="center" class=shade>

<!--DWLayoutTable-->

<tbody>

<tr height=10>

<td width="194" height="40" align=center valign="bottom"><a href="http://localhost/mkb/Classified1/output/login.php">Admin</a></td>

</tr>

<tr height=10>

<td height="26" align=center valign="top">

<a href="clmain_list.php"> Search For L.G / Industries</a>

</td>

</tr>

<tr height=10>

<td height="36" align=middle valign="top">

<div align="center"><a href="http://localhost/supercali-1.0.7/">Markets Days <br>

</a></div></td>

</tr>

<tr height=10>

<td height="60">&nbsp;</td>

</tr>

<tr height=20>

<td height="21" align=center>

<font color=red></font>&nbsp;

</td></tr>

<tr>

<td height="1"></td>

</tr>

</tbody>

</table>

</DIV>

</td>

</tr>

</table>

</form>

<p>&nbsp;</p></td>

</tr>

</table>

</td>

</tr>

</table>

</td>

</tr>

</table>

<p align="center">

<b><font color=black> © 2012 - 2013 All rights reserved.</font></b></p>

</body>

</html>

ADMIN LOGIN PAGE

<html>

<head>

<title>Login</title>

<link REL="stylesheet" href="oldinclude/style.css" type="text/css">

</head>

<body bgcolor=white onLoad="javascript:document.forms[0].username.focus();" text="#000000" leftmargin="0" topmargin="0" marginwidth="0"

marginheight="0" link="#0066cc">

<p align="center"><img src="images/mrarkdb.png" width="900" height="109" /></p>

<table width="900" border="1" bordercolor=#2237cbb align="center" cellpadding="5">

<tr>

81

Page 82: CHAPTER 1

<td>

<p align=center>Welcome &nbsp;</p>

<table width="100%" border="0" cellspacing="0" cellpadding="0" height="99%">

<tr>

<td valign="center" align="middle">

<table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td>&nbsp;</td>

</tr>

</table>

<table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td>

<table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td bgcolor="#ffffff" valign="top" align="right">

<table width="300" border="0" cellspacing="4" cellpadding="4" align="center">

<tr>

<td><a href="http://localhost/marketDB/Classified1/output/login.php">Home</a></td>

</tr>

</table>

<form method="POST" action="login.php" id=form1 name=form1>

<table width="300" border="0" cellspacing="1" cellpadding="4" align="center" bgcolor="#cccccc">

<tr>

<td align=middle class=blackshade>

<b><font size=+1>Login</font></b></td>

</tr> <tr>

<td valign="top" class=shade>

<DIV align=center>

<table width="200" border=0 align="center" class=shade>

<tbody>

<tr height=10><td colspan=2>&nbsp;</td></tr>

<tr>

<td align=right width="50%">

<div align="left">Username:</div>

</td>

<td width="50%">

<input name=username value="">

</td>

</tr> <tr>

<td align=right width="50%">

<div align="left">Password:</div>

</td>

<td width="50%">

<input type=password name=password value=""

onkeydown="e=event; if(!e) e = window.event; if (e.keyCode != 13) return; e.cancel = true; document.forms[0].submit();" >

</td>

</tr> <tr>

<td align=right width="50%">

<div align="left">Remember Password:</div>

</td>

<td width="50%">

<input type=checkbox name=remember_password value="1" >

</td>

</tr> <tr>

<td colspan=2 align=middle>

<input type=hidden name=btnSubmit value="Login">

<input type=submit value="Submit" class=buttonM>

</td>

</tr>

82

Page 83: CHAPTER 1

<tr height=20>

<td align=center colspan=2>

<a href="clmain_list.php"></a> </td>

</tr> <tr>

<td colspan=2 align=middle>

<a href="register.php">Register</a>

</td>

</tr>

<tr height=20>

<td align=center colspan=2>

<font color=red></font>&nbsp;

</td>

</tr>

</tbody>

</table></DIV>

</td>

</tr>

</table>

</form>

<p>&nbsp;</p></td>

</tr>

</table>

</td>

</tr>

</table>

</td>

</tr>

</table>

<p align="center">

<b><font color=black> © 2012 - 2013 All rights reserved.</font></b></p>

</body>

</html>

CATEGORY PAGE

<?php

ini_set("display_errors","1");

ini_set("display_startup_errors","1");

set_magic_quotes_runtime(0);

include("include/dbcommon.php");

include("include/clcategory_variables.php");

// check if logged in

if(!@$_SESSION["UserID"] || !CheckSecurity(@$_SESSION["_".$strTableName."_OwnerID"],"Search"))

{

$_SESSION["MyURL"]=$_SERVER["SCRIPT_NAME"]."?".$_SERVER["QUERY_STRING"];

header("Location: login.php?message=expired");

return;

}

$filename="";

$message="";

$all=postvalue("all");

$pdf=postvalue("pdf");

$mypage=1;

$id=1;

//connect database

$conn = db_connect();

if(function_exists("BeforeProcessView"))

BeforeProcessView($conn);

$strWhereClause="";

if(!$all)

{

83

Page 84: CHAPTER 1

$keys=array();

$keys["CategoryID"]=postvalue("editid1");

// get current values and show edit controls

$strWhereClause = KeyWhere($keys);

$strSQL=gSQLWhere($strWhereClause);

} else {

if ($_SESSION[$strTableName."_SelectedSQL"]!="" && @$_REQUEST["records"]=="") {

$strSQL = $_SESSION[$strTableName."_SelectedSQL"];

$strWhereClause=@$_SESSION[$strTableName."_SelectedWhere"]; }

Else {

$strWhereClause=@$_SESSION[$strTableName."_where"];

$strSQL=gSQLWhere($strWhereClause); }

$strOrderBy=$_SESSION[$strTableName."_order"];

if(!$strOrderBy)

$strOrderBy=$gstrOrderBy;

$strSQL.=" ".trim($strOrderBy);

$strOrderBy=$_SESSION[$strTableName."_order"];

if(!$strOrderBy)

$strOrderBy=$gstrOrderBy;

$strSQL.=" ".trim($strOrderBy);

$numrows=gSQLRowCount($strWhereClause,0); }

$strSQLbak = $strSQL;

if(function_exists("BeforeQueryView"))

BeforeQueryView($strSQL,$strWhereClause);

if($strSQLbak == $strSQL)

$strSQL=gSQLWhere($strWhereClause);

if(!$all) {

LogInfo($strSQL);

$rs=db_query($strSQL,$conn); }

Else {

// Pagination:

$nPageSize=0;

if(@$_REQUEST["records"]=="page" && $numrows)

{ $mypage=(integer)@$_SESSION[$strTableName."_pagenumber"];

$nPageSize=(integer)@$_SESSION[$strTableName."_pagesize"];

if($numrows<=($mypage-1)*$nPageSize)

$mypage=ceil($numrows/$nPageSize);

if(!$nPageSize)

$nPageSize=$gPageSize;

if(!$mypage)

$mypage=1;

$strSQL.=" limit ".(($mypage-1)*$nPageSize).",".$nPageSize; }

$rs=db_query($strSQL,$conn); }

$data=db_fetch_array($rs);

include('libs/xtempl.php');

$xt = new Xtempl();

$out="";

$first=true;

$templatefile="";

while($data) {

$xt->assign("show_key1", htmlspecialchars(GetData($data,"CategoryID", "")));

$keylink="";

$keylink.="&key1=".htmlspecialchars(rawurlencode(@$data["CategoryID"]));

// CategoryName -

$value="";

$value = ProcessLargeText(GetData($data,"CategoryName", ""),"","",MODE_VIEW);

$xt->assign("CategoryName_value",$value);

$xt->assign("CategoryName_fieldblock",true);

$body=array();

$body["begin"]="";

84

Page 85: CHAPTER 1

$xt->assignbyref("body",$body);

$xt->assign("style_block",true);

$xt->assign("stylefiles_block",true);

if(!$pdf && !$all) {

$xt->assign("back_button",true);

$xt->assign("backbutton_attrs","onclick=\"window.location.href='clcategory_list.php?a=return'\""); }

$oldtemplatefile=$templatefile;

$templatefile = "clcategory_view.htm";

if(!$all) {

if(function_exists("BeforeShowView"))

BeforeShowView($xt,$templatefile,$data);

if(!$pdf)

$xt->display($templatefile);

break; } }

?>

SUBCATEGORY PAGE

<?php

ini_set("display_errors","1");

ini_set("display_startup_errors","1");

set_magic_quotes_runtime(0);

include("include/dbcommon.php");

include("include/clsubcategory_variables.php");

// check if logged in

if(!@$_SESSION["UserID"] || !CheckSecurity(@$_SESSION["_".$strTableName."_OwnerID"],"Search")) {

$_SESSION["MyURL"]=$_SERVER["SCRIPT_NAME"]."?".$_SERVER["QUERY_STRING"];

header("Location: login.php?message=expired");

return; }

$filename="";

$message="";

$all=postvalue("all");

$pdf=postvalue("pdf");

$mypage=1;

$id=1;

//connect database

$conn = db_connect();

if(function_exists("BeforeProcessView"))

BeforeProcessView($conn);

$strWhereClause="";

if(!$all) {

$keys=array();

$keys["SubcategoryID"]=postvalue("editid1");

$strWhereClause = KeyWhere($keys);

$strSQL=gSQLWhere($strWhereClause); }

Else {

if ($_SESSION[$strTableName."_SelectedSQL"]!="" && @$_REQUEST["records"]=="") {

$strSQL = $_SESSION[$strTableName."_SelectedSQL"];

$strWhereClause=@$_SESSION[$strTableName."_SelectedWhere"]; }

Else {

$strWhereClause=@$_SESSION[$strTableName."_where"];

$strSQL=gSQLWhere($strWhereClause); }

$strOrderBy=$_SESSION[$strTableName."_order"];

if(!$strOrderBy)

$strOrderBy=$gstrOrderBy;

$strSQL.=" ".trim($strOrderBy);

$strOrderBy=$_SESSION[$strTableName."_order"];

if(!$strOrderBy)

$strOrderBy=$gstrOrderBy;

$strSQL.=" ".trim($strOrderBy);

$numrows=gSQLRowCount($strWhereClause,0); }

85

Page 86: CHAPTER 1

$strSQLbak = $strSQL;

if(function_exists("BeforeQueryView"))

BeforeQueryView($strSQL,$strWhereClause);

if($strSQLbak == $strSQL)

$strSQL=gSQLWhere($strWhereClause);

if(!$all) {

LogInfo($strSQL);

$rs=db_query($strSQL,$conn);

} else {

// Pagination:

$nPageSize=0;

if(@$_REQUEST["records"]=="page" && $numrows) {

$mypage=(integer)@$_SESSION[$strTableName."_pagenumber"];

$nPageSize=(integer)@$_SESSION[$strTableName."_pagesize"];

if($numrows<=($mypage-1)*$nPageSize)

$mypage=ceil($numrows/$nPageSize);

if(!$nPageSize)

$nPageSize=$gPageSize;

if(!$mypage)

$mypage=1;

$strSQL.=" limit ".(($mypage-1)*$nPageSize).",".$nPageSize; }

$rs=db_query($strSQL,$conn); }

$data=db_fetch_array($rs);

include('libs/xtempl.php');

$xt = new Xtempl();

$out="";

$first=true;

$templatefile="";

while($data) {

$xt->assign("show_key1", htmlspecialchars(GetData($data,"SubcategoryID", "")));

$keylink="";

$keylink.="&key1=".htmlspecialchars(rawurlencode(@$data["SubcategoryID"]));

// SubcategoryName -

$value="";

$value = ProcessLargeText(GetData($data,"SubcategoryName", ""),"","",MODE_VIEW);

$xt->assign("SubcategoryName_value",$value);

$xt->assign("SubcategoryName_fieldblock",true);

// Category -

$value="";

$value=DisplayLookupWizard("Category",$data["Category"],$data,$keylink,MODE_VIEW);

$xt->assign("Category_value",$value);

$xt->assign("Category_fieldblock",true);

$body=array();

$body["begin"]="";

$xt->assignbyref("body",$body);

$xt->assign("style_block",true);

$xt->assign("stylefiles_block",true);

if(!$pdf && !$all) {

$xt->assign("back_button",true);

$xt->assign("backbutton_attrs","onclick=\"window.location.href='clsubcategory_list.php?a=return'\""); }

$oldtemplatefile=$templatefile;

$templatefile = "clsubcategory_view.htm";

if(!$all) {

if(function_exists("BeforeShowView"))

BeforeShowView($xt,$templatefile,$data);

if(!$pdf)

$xt->display($templatefile);

break; } }

?>

86

Page 87: CHAPTER 1

ADD NEW RECORD PAGE

<?php

ini_set("display_errors","1");

ini_set("display_startup_errors","1");

set_magic_quotes_runtime(0);

include("include/dbcommon.php");

include("include/clmain_variables.php");

if(!@$_SESSION["UserID"] || !CheckSecurity(@$_SESSION["_".$strTableName."_OwnerID"],"Add")) {

$_SESSION["MyURL"]=$_SERVER["SCRIPT_NAME"]."?".$_SERVER["QUERY_STRING"];

header("Location: login.php?message=expired");

return; }

$filename="";

$status="";

$message="";

$usermessage="";

$error_happened=false;

$readavalues=false;

$showKeys = array();

$showValues = array();

$showRawValues = array();

$showFields = array();

$showDetailKeys = array();

$IsSaved = false;

$HaveData = true;

if(@$_REQUEST["editType"]=="inline")

$inlineedit=ADD_INLINE;

elseif(@$_REQUEST["editType"]=="onthefly")

$inlineedit=ADD_ONTHEFLY;

else

$inlineedit=ADD_SIMPLE;

$keys=array();

if($inlineedit==ADD_INLINE)

$templatefile = "clmain_inline_add.htm";

else

$templatefile = "clmain_add.htm";

$id=postvalue("id");

//connect database

$conn = db_connect();

if(function_exists("BeforeProcessAdd"))

BeforeProcessAdd($conn);

include('libs/xtempl.php');

$xt = new Xtempl();

if(@$_POST["a"]=="added") {

$afilename_values=array();

$avalues=array();

$files_move=array();

$files_save=array();

$value = postvalue("value_Category");

$type=postvalue("type_Category");

if (in_assoc_array("type_Category",$_POST) || in_assoc_array("value_Category",$_POST) || in_assoc_array("value_Category",$_FILES)) {

$value=prepare_for_db("Category",$value,$type); }

else

$value=false;

if(!($value===false)) {

$avalues["Category"]=$value; }

$value = postvalue("value_Details");

$type=postvalue("type_Details");

if (in_assoc_array("type_Details",$_POST) || in_assoc_array("value_Details",$_POST) || in_assoc_array("value_Details",$_FILES)) {

$value=prepare_for_db("Details",$value,$type); }

else

87

Page 88: CHAPTER 1

$value=false;

if(!($value===false)) {

$avalues["Details"]=$value; }

if($inlineedit!=ADD_INLINE) {

$value = postvalue("value_Fullinfo");

$type=postvalue("type_Fullinfo");

if (in_assoc_array("type_Fullinfo",$_POST) || in_assoc_array("value_Fullinfo",$_POST) || in_assoc_array("value_Fullinfo",$_FILES)) {

$value=prepare_for_db("Fullinfo",$value,$type); }

else

$value=false;

if(!($value===false)) {

$avalues["Fullinfo"]=$value; } }

$value = postvalue("value_Picture");

$type=postvalue("type_Picture");

if (in_assoc_array("type_Picture",$_POST) || in_assoc_array("value_Picture",$_POST) || in_assoc_array("value_Picture",$_FILES)) {

$value=prepare_for_db("Picture",$value,$type); }

else

$value=false;

if(!($value===false)) {

if($value)

$contents = myfile_get_contents($_FILES["file_Picture"]['tmp_name']);

if($value) {

$ext = CheckImageExtension($_FILES["file_Picture"]["name"]);

$thumb = CreateThumbnail($contents,150,$ext);

$file = GetUploadFolder("Picture")."th_".$value;

$files_save[] = array("file"=>$thumb,"filename"=>$file); }

$avalues["Picture"]=$value; }

$value = postvalue("value_Posted");

$type=postvalue("type_Posted");

if (in_assoc_array("type_Posted",$_POST) || in_assoc_array("value_Posted",$_POST) || in_assoc_array("value_Posted",$_FILES)) {

$value=prepare_for_db("Posted",$value,$type); }

else

$value=false;

if(!($value===false)) {

$avalues["Posted"]=$value; }

$value = postvalue("value_Subcategory");

$type=postvalue("type_Subcategory");

if (in_assoc_array("type_Subcategory",$_POST) || in_assoc_array("value_Subcategory",$_POST) || in_assoc_array("value_Subcategory",$_FILES))

{ $value=prepare_for_db("Subcategory",$value,$type); }

else

$value=false;

if(!($value===false))

{ $avalues["Subcategory"]=$value; }

$value = postvalue("value_Title");

$type=postvalue("type_Title");

if (in_assoc_array("type_Title",$_POST) || in_assoc_array("value_Title",$_POST) || in_assoc_array("value_Title",$_FILES))

{ $value=prepare_for_db("Title",$value,$type); }

else

$value=false;

if(!($value===false))

{ $avalues["Title"]=$value; }

$avalues["UserID"]=prepare_for_db("UserID",$_SESSION["_".$strTableName."_OwnerID"]);

if($inlineedit==ADD_ONTHEFLY || true) { }

foreach($afilename_values as $akey=>$value)

$avalues[$akey]=$value;

// make SQL string

$strSQL = "insert into ".AddTableWrappers($strOriginalTableName)." ";

$strFields="(";

$strValues="(";

$retval = true;

88

Page 89: CHAPTER 1

if(function_exists("BeforeAdd"))

$retval=BeforeAdd($avalues,$usermessage,$inlineedit);

if($retval)

{ foreach($avalues as $akey=>$value) {

$strFields.=AddFieldWrappers($akey).", ";

$strValues.=add_db_quotes($akey,$value).", "; }

if(substr($strFields,-2)==", ")

$strFields=substr($strFields,0,strlen($strFields)-2);

if(substr($strValues,-2)==", ")

$strValues=substr($strValues,0,strlen($strValues)-2);

$strSQL.=$strFields.") values ".$strValues.")";

LogInfo($strSQL);

set_error_handler("add_error_handler");

db_exec($strSQL,$conn);

set_error_handler("error_handler"); }

if ( $inlineedit==ADD_INLINE )

{ $status="ADDED";

$message=""."Record was added"."";

$IsSaved = true; }

else

$message="<div class=message><<< "."Record was added"." >>></div>";

if($usermessage!="")

$message = $usermessage;

if($inlineedit==ADD_INLINE || $inlineedit==ADD_ONTHEFLY || function_exists("AfterAdd"))

{ $failed_inline_add = false;

$keys["ID"]=mysql_insert_id($conn); }

if(function_exists("AfterAdd"))

{ foreach($keys as $idx=>$val)

$avalues[$idx]=$val;

AfterAdd($avalues,$keys,$inlineedit); } } }

else

{ $message = $usermessage;

$status="DECLINED";

$readavalues=true; } }

$defvalues=array();

if(array_key_exists("copyid1",$_REQUEST) || array_key_exists("editid1",$_REQUEST)) {

$copykeys=array();

if(array_key_exists("copyid1",$_REQUEST))

{ $copykeys["ID"]=postvalue("copyid1"); }

else

{ $copykeys["ID"]=postvalue("editid1"); }

$strWhere=KeyWhere($copykeys);

$strWhere=whereAdd($strWhere,SecuritySQL("Search"));

$strSQL = gSQLWhere($strWhere);

LogInfo($strSQL);

$rs=db_query($strSQL,$conn);

$defvalues=db_fetch_array($rs);

$defvalues["ID"]="";

//call CopyOnLoad event

if(function_exists("CopyOnLoad"))

CopyOnLoad($defvalues,$strWhere); }

else

{ $defvalues["Posted"]=now(); }

if($inlineedit==ADD_ONTHEFLY || true) { }

if($readavalues)

{ $defvalues["Category"]=@$avalues["Category"];

$defvalues["Details"]=@$avalues["Details"];

$defvalues["Fullinfo"]=@$avalues["Fullinfo"];

$defvalues["Posted"]=@$avalues["Posted"];

$defvalues["Subcategory"]=@$avalues["Subcategory"];

89

Page 90: CHAPTER 1

$defvalues["Title"]=@$avalues["Title"]; }

foreach($defvalues as $key=>$value)

$smarty->assign("value_".GoodFieldName($key),$value);

$linkdata="";

$includes="";

$arr_includes=array();

$bodyonload="";

if ( $inlineedit!=ADD_INLINE )

{ $onsubmit="";

$needvalidate=false;

if($needvalidate)

{ if($inlineedit==ADD_ONTHEFLY)

$onsubmit="return validate_fly(this);";

else

$onsubmit="return validate();";

// $bodyonload="onload=\"".$bodyonload."\""; }

if($inlineedit!=ADD_ONTHEFLY) { }

$includes.="var locale_dateformat = ".$locale_info["LOCALE_IDATE"]."

"var locale_datedelimiter = \"".$locale_info["LOCALE_SDATE"]."

"var bLoading=false;

"var TEXT_PLEASE_SELECT='".addslashes("Please select")."'

if ($useAJAX) {

$includes.="var SUGGEST_TABLE='clmain_searchsuggest.php';

} if($inlineedit!=ADD_ONTHEFLY) {

if ($useAJAX)

$includes.="<div id=\"search_suggest\"></div>\r\n"; }

if($inlineedit!=ADD_ONTHEFLY)

else

$arr_includes[]="include/richtext.js";

if($inlineedit!=ADD_ONTHEFLY) {

$includes.="var TEXT_VIEW_SOURCE='".addslashes("View Source")."';\

$includes.="initRTE('include/images/', 'include/', '');\

$onsubmit="updateRTEs();".$onsubmit; }

$xt->assign("Category_fieldblock",true);

$xt->assign("Details_fieldblock",true);

$xt->assign("Fullinfo_fieldblock",true);

$xt->assign("Picture_fieldblock",true);

$xt->assign("Posted_fieldblock",true);

$xt->assign("Subcategory_fieldblock",true);

$xt->assign("Title_fieldblock",true);

$body=array();

$formname="editform";

if($inlineedit!=ADD_ONTHEFLY)

{ if($onsubmit)

$onsubmit="onsubmit=\"".$onsubmit."\"";

$body["begin"]=$includes.

"<form name=\"editform\" encType=\"multipart/form-data\" method=\"post\" action=\"clmain_add.php\" ".$onsubmit.">".

"<input type=hidden name=\"a\" value=\"added\">";

$xt->assign("backbutton_attrs","onclick=\"window.location.href='clmain_list.php?a=return'\"");

$xt->assign("back_button",true); }

else

{ $formname="editform".$id;

$body["begin"]="<form name=\"editform".$id."\" encType=\"multipart/form-data\" method=\"post\" action=\"clmain_add.php\" ".$onsubmit."

target=\"flyframe".$id."\">".

"<input type=hidden name=\"a\" value=\"added\">".

"<input type=hidden name=\"editType\" value=\"onthefly\">".

"<input type=hidden name=\"table\" value=\"".postvalue("table")."\">".

"<input type=hidden name=\"field\" value=\"".postvalue("field")."\">".

"<input type=hidden name=\"category\" value=\"".postvalue("category")."\">".

"<input type=hidden name=\"id\" value=\"".$id."\">";

90

Page 91: CHAPTER 1

$xt->assign("cancelbutton_attrs","onclick=\"RemoveFlyDiv('".$id."');\"");

$xt->assign("cancel_button",true); }

$xt->assign("save_button",true);

$xt->assign("reset_button",true); } }

else

$xt->assign("flybody",$body);

$xt->assign("body",true);

if(@$_POST["a"]=="added" && $inlineedit==ADD_ONTHEFLY && !$error_happened && $status!="DECLINED")

{ $LookupSQL="";

if($LookupSQL)

$LookupSQL.=" from ".AddTableWrappers($strOriginalTableName);

$data=0;

if(count($keys) && $LookupSQL)

{ $where=KeyWhere($keys);

$LookupSQL.=" where ".$where;

$rs=db_query($LookupSQL,$conn);

$data=db_fetch_numarray($rs); }

if(!$data)

{ $data=array(@$avalues[$linkfield],@$avalues[$dispfield]); }

echo "<textarea id=\"data\">";

echo "added";

print_inline_array($data);

echo "</textarea>";

exit(); }

if ( @$_POST["a"]=="added" && $inlineedit==ADD_INLINE )

{ $data=0;

if(count($keys))

{ $where=KeyWhere($keys);

$where=whereAdd($where,SecuritySQL("Search"));

$strSQL = gSQLWhere($where);

LogInfo($strSQL);

$rs=db_query($strSQL,$conn);

$data=db_fetch_array($rs); }

if(!$data)

{ $data=$avalues;

$HaveData=false; }

$showKeys[] = htmlspecialchars($keys["ID"]);

$keylink="";

$keylink.="&key1=".htmlspecialchars(rawurlencode(@$data["ID"]));

// Fullinfo - HTML

$value="";

$value = GetData($data,"Fullinfo", "HTML");

$showValues[] = $value;

$showFields[] = "Fullinfo";

$showRawValues[] = substr($data["Fullinfo"],0,100);

// UserID -

$value="";

$value=DisplayLookupWizard("UserID",$data["UserID"],$data,$keylink,MODE_LIST);

$showValues[] = $value;

$showFields[] = "UserID";

$showRawValues[] = substr($data["UserID"],0,100);

// Picture - File-based Image

$value="";

if(CheckImageExtension($data["Picture"]))

{

// show thumbnail

$thumbname="th_".$data["Picture"];

if(substr("files/",0,7)!="http://" && !file_exists(GetUploadFolder("Picture").$thumbname))

$thumbname=$data["Picture"];

$value="<a";

91

Page 92: CHAPTER 1

$value .= " target=_blank";

$value.=" href=\"".htmlspecialchars(AddLinkPrefix("Picture",$data["Picture"]))."\">";

$value.="<img";

if($thumbname==$data["Picture"])

{ $value.=" width=130"; }

$value.=" id=\"img_Picture_".$record_id."\" border=0";

$value.=" src=\"".htmlspecialchars(AddLinkPrefix("Picture",$thumbname))."\"></a>"; }

$showValues[] = $value;

$showFields[] = "Picture";

$showRawValues[] = substr($data["Picture"],0,100);

// ID -

$value="";

$value = ProcessLargeText(GetData($data,"ID", ""),"","",MODE_LIST);

$showValues[] = $value;

$showFields[] = "ID";

$showRawValues[] = substr($data["ID"],0,100);

// Category -

$value="";

$value = ProcessLargeText(GetData($data,"Category", ""),"","",MODE_LIST);

$showValues[] = $value;

$showFields[] = "Category";

$showRawValues[] = substr($data["Category"],0,100);

// Subcategory -

$value="";

$value = ProcessLargeText(GetData($data,"Subcategory", ""),"","",MODE_LIST);

$showValues[] = $value;

$showFields[] = "Subcategory";

$showRawValues[] = substr($data["Subcategory"],0,100);

// Title -

$value="";

$value = ProcessLargeText(GetData($data,"Title", ""),"","",MODE_LIST);

$showValues[] = $value;

$showFields[] = "Title";

$showRawValues[] = substr($data["Title"],0,100);

// Posted - Long Date

$value="";

$value = ProcessLargeText(GetData($data,"Posted", "Long Date"),"","",MODE_LIST);

$showValues[] = $value;

$showFields[] = "Posted";

$showRawValues[] = substr($data["Posted"],0,100);

// Details -

$value="";

$value = ProcessLargeText(GetData($data,"Details", ""),"","",MODE_LIST);

$showValues[] = $value;

$showFields[] = "Details";

$showRawValues[] = substr($data["Details"],0,100); }

if ( @$_POST["a"]=="added" && $inlineedit==ADD_INLINE )

{ echo "<textarea id=\"data\">";

if($IsSaved && count($showValues))

{ if($HaveData)

echo "saved";

else

echo "savnd";

print_inline_array($showKeys);

echo "\n";

print_inline_array($showValues);

echo "\n";

print_inline_array($showFields);

echo "\n";

print_inline_array($showRawValues);

92

Page 93: CHAPTER 1

echo "\n";

print_inline_array($showDetailKeys,true);

echo "\n";

print_inline_array($showDetailKeys);

echo "\n";

echo str_replace(array("&","<","\\","\r","\n"),array("&amp;","&lt;","\\\\","\\r","\\n"),$usermessage); }

else

{ if($status=="DECLINED")

echo "decli";

else

echo "error";

echo str_replace(array("&","<","\\","\r","\n"),array("&amp;","&lt;","\\\\","\\r","\\n"),$message); }

echo "</textarea>";

exit(); }

$control_Category=array();

$control_Category["func"]="xt_buildeditcontrol";

$control_Category["params"] = array();

$control_Category["params"]["field"]="Category";

$control_Category["params"]["value"]=@$defvalues["Category"];

$control_Category["params"]["id"]=$record_id;

if($inlineedit==ADD_INLINE)

$control_Category["params"]["mode"]="inline_add";

else

$control_Category["params"]["mode"]="add";

$xt->assignbyref("Category_editcontrol",$control_Category);

$control_Details=array();

$control_Details["func"]="xt_buildeditcontrol";

$control_Details["params"] = array();

$control_Details["params"]["field"]="Details";

$control_Details["params"]["value"]=@$defvalues["Details"];

$control_Details["params"]["id"]=$record_id;

if($inlineedit==ADD_INLINE)

$control_Details["params"]["mode"]="inline_add";

else

$control_Details["params"]["mode"]="add";

$xt->assignbyref("Details_editcontrol",$control_Details);

$control_Fullinfo=array();

$control_Fullinfo["func"]="xt_buildeditcontrol";

$control_Fullinfo["params"] = array();

$control_Fullinfo["params"]["field"]="Fullinfo";

$control_Fullinfo["params"]["value"]=@$defvalues["Fullinfo"];

$control_Fullinfo["params"]["id"]=$record_id;

if($inlineedit==ADD_INLINE)

$control_Fullinfo["params"]["mode"]="inline_add";

else

$control_Fullinfo["params"]["mode"]="add";

$xt->assignbyref("Fullinfo_editcontrol",$control_Fullinfo);

$control_Picture=array();

$control_Picture["func"]="xt_buildeditcontrol";

$control_Picture["params"] = array();

$control_Picture["params"]["field"]="Picture";

$control_Picture["params"]["value"]=@$defvalues["Picture"];

$control_Picture["params"]["id"]=$record_id;

if($inlineedit==ADD_INLINE)

$control_Picture["params"]["mode"]="inline_add";

else

$control_Picture["params"]["mode"]="add";

$xt->assignbyref("Picture_editcontrol",$control_Picture);

$control_Posted=array();

$control_Posted["func"]="xt_buildeditcontrol";

93

Page 94: CHAPTER 1

$control_Posted["params"] = array();

$control_Posted["params"]["field"]="Posted";

$control_Posted["params"]["value"]=@$defvalues["Posted"];

$control_Posted["params"]["id"]=$record_id;

if($inlineedit==ADD_INLINE)

$control_Posted["params"]["mode"]="inline_add";

else

$control_Posted["params"]["mode"]="add";

$xt->assignbyref("Posted_editcontrol",$control_Posted);

$control_Subcategory=array();

$control_Subcategory["func"]="xt_buildeditcontrol";

$control_Subcategory["params"] = array();

$control_Subcategory["params"]["field"]="Subcategory";

$control_Subcategory["params"]["value"]=@$defvalues["Subcategory"];

$control_Subcategory["params"]["id"]=$record_id;

if($inlineedit==ADD_INLINE)

$control_Subcategory["params"]["mode"]="inline_add";

else

$control_Subcategory["params"]["mode"]="add";

$xt->assignbyref("Subcategory_editcontrol",$control_Subcategory);

$control_Title=array();

$control_Title["func"]="xt_buildeditcontrol";

$control_Title["params"] = array();

$control_Title["params"]["field"]="Title";

$control_Title["params"]["value"]=@$defvalues["Title"];

$control_Title["params"]["id"]=$record_id;

if($inlineedit==ADD_INLINE)

$control_Title["params"]["mode"]="inline_add";

else

$control_Title["params"]["mode"]="add";

$xt->assignbyref("Title_editcontrol",$control_Title);

$xt->assign("style_block",true);

if(function_exists("BeforeShowAdd"))

BeforeShowAdd($xt,$templatefile);

if($inlineedit==ADD_ONTHEFLY)

{ $xt->load_template($templatefile);

$xt->display_loaded("style_block");

$xt->display_loaded("flybody"); }

else

$xt->display($templatefile);

function add_error_handler($errno, $errstr, $errfile, $errline)

{ global $readavalues, $message, $status, $inlineedit, $error_happened;

if ( $inlineedit!=ADD_SIMPLE )

$message=""."Record was NOT added".". ".$errstr;

else

$message="<div class=message><<< "."Record was NOT added"." >>><br><br>".$errstr."</div>";

$readavalues=true;

$error_happened=true; }

?>

EDIT RECORD PAGE

<?php

ini_set("display_errors","1");

ini_set("display_startup_errors","1");

set_magic_quotes_runtime(0);

include("include/dbcommon.php");

include("include/clmain_variables.php");

if(!@$_SESSION["UserID"] || !CheckSecurity(@$_SESSION["_".$strTableName."_OwnerID"],"Edit"))

{ $_SESSION["MyURL"]=$_SERVER["SCRIPT_NAME"]."?".$_SERVER["QUERY_STRING"];

header("Location: login.php?message=expired");

94

Page 95: CHAPTER 1

return; }

$filename="";

$status="";

$message="";

$usermessage="";

$error_happened=false;

$readevalues=false;

$bodyonload="";

$body=array();

$showKeys = array();

$showValues = array();

$showRawValues = array();

$showFields = array();

$showDetailKeys = array();

$IsSaved = false;

$HaveData = true;

$inlineedit = (@$_REQUEST["editType"]=="inline") ? true : false;

$templatefile = ( $inlineedit ) ? "clmain_inline_edit.htm" : "clmain_edit.htm";

// connect database

$conn = db_connect();

if(function_exists("BeforeProcessEdit"))

BeforeProcessEdit($conn);

$keys=array();

$keys["ID"]=postvalue("editid1");

// process entered data, read and save

if(@$_POST["a"]=="edited")

{ $strWhereClause=KeyWhere($keys);

$strWhereClause=whereAdd($strWhereClause,SecuritySQL("Edit"));

$strSQL=gSQLWhere($strWhereClause);

$rsold=db_query($strSQL,$conn);

$dataold=db_fetch_array($rsold);

$strWhereClause=KeyWhere($keys);

$strSQL = "update ".AddTableWrappers($strOriginalTableName)." set ";

$evalues=array();

$efilename_values=array();

$files_delete=array();

$files_move=array();

$files_save=array();

$value = postvalue("value_Category");

$type=postvalue("type_Category");

if (in_assoc_array("type_Category",$_POST) || in_assoc_array("value_Category",$_POST) || in_assoc_array("value_Category",$_FILES))

{ $value=prepare_for_db("Category",$value,$type); }

else

$value=false;

if($value!==false)

{ $evalues["Category"]=$value; }

$value = postvalue("value_Details");

$type=postvalue("type_Details");

if (in_assoc_array("type_Details",$_POST) || in_assoc_array("value_Details",$_POST) || in_assoc_array("value_Details",$_FILES))

{ $value=prepare_for_db("Details",$value,$type); }

else

$value=false;

if($value!==false)

{ $evalues["Details"]=$value; }

if(!$inlineedit)

{ $value = postvalue("value_Fullinfo");

$type=postvalue("type_Fullinfo");

if (in_assoc_array("type_Fullinfo",$_POST) || in_assoc_array("value_Fullinfo",$_POST) || in_assoc_array("value_Fullinfo",$_FILES))

{ $value=prepare_for_db("Fullinfo",$value,$type); }

else

95

Page 96: CHAPTER 1

$value=false;

if($value!==false)

{ $evalues["Fullinfo"]=$value; }

$value = postvalue("value_Picture");

$type=postvalue("type_Picture");

if (in_assoc_array("type_Picture",$_POST) || in_assoc_array("value_Picture",$_POST) || in_assoc_array("value_Picture",$_FILES))

{ $value=prepare_for_db("Picture",$value,$type,postvalue("filename_Picture")); }

else

$value=false;

if($value!==false)

{ if($value)

$contents = myfile_get_contents($_FILES["file_Picture"]['tmp_name']);

if($value)

{ $ext = CheckImageExtension($_FILES["file_Picture"]["name"]);

$thumb = CreateThumbnail($contents,150,$ext);

$file = GetUploadFolder("Picture")."th_".$value;

$files_save[] = array("file"=>$thumb,"filename"=>$file); }

$evalues["Picture"]=$value; }

$value = postvalue("value_Posted");

$type=postvalue("type_Posted");

if (in_assoc_array("type_Posted",$_POST) || in_assoc_array("value_Posted",$_POST) || in_assoc_array("value_Posted",$_FILES))

{ $value=prepare_for_db("Posted",$value,$type); }

else

$value=false;

if($value!==false)

{ $evalues["Posted"]=$value; }

$value = postvalue("value_Subcategory");

$type=postvalue("type_Subcategory");

if (in_assoc_array("type_Subcategory",$_POST) || in_assoc_array("value_Subcategory",$_POST) || in_assoc_array("value_Subcategory",$_FILES))

{ $value=prepare_for_db("Subcategory",$value,$type); }

else

$value=false;

if($value!==false)

{ $evalues["Subcategory"]=$value; }

$value = postvalue("value_Title");

$type=postvalue("type_Title");

if (in_assoc_array("type_Title",$_POST) || in_assoc_array("value_Title",$_POST) || in_assoc_array("value_Title",$_FILES))

{ $value=prepare_for_db("Title",$value,$type); }

else

$value=false;

if($value!==false)

{ $evalues["Title"]=$value; }

foreach($efilename_values as $ekey=>$value)

$evalues[$ekey]=$value;

$retval=true;

if(function_exists("BeforeEdit"))

$retval=BeforeEdit($evalues,$strWhereClause,$dataold,$keys,$usermessage,$inlineedit);

if($retval)

{

// construct SQL string

foreach($evalues as $ekey=>$value)

{ $strSQL.=AddFieldWrappers($ekey)."=".add_db_quotes($ekey,$value).", "; }

if(substr($strSQL,-2)==", ")

$strSQL=substr($strSQL,0,strlen($strSQL)-2);

$strSQL.=" where ".$strWhereClause;

if(SecuritySQL("Edit"))

$strSQL .= " and (".SecuritySQL("Edit").")";

set_error_handler("edit_error_handler");

db_exec($strSQL,$conn);

set_error_handler("error_handler");

96

Page 97: CHAPTER 1

if(!$error_happened)

{

// delete & move files

foreach ($files_delete as $file)

{ if(file_exists($file))

@unlink($file); }

foreach($files_move as $file)

{ move_uploaded_file($file[0],$file[1]);

if(strtoupper(substr(PHP_OS,0,3))!="WIN")

@chmod($file[1],0777); }

foreach($files_save as $file)

{ if(file_exists($file["filename"]))

@unlink($file["filename"]);

$th = fopen($file["filename"],"w");

fwrite($th,$file["file"]);

fclose($th); }

if ( $inlineedit )

{ $status="UPDATED";

$message=""."Record updated"."";

$IsSaved = true; }

else

$message="<div class=message><<< "."Record updated"." >>></div>";

if($usermessage!="")

else

$linkdata.="bLoading = true;";

$linkdata.="SetSelection('value_Category', 'value_Subcategory', '".jsreplace(@$data["Category"])."', '".jsreplace($data["Subcategory"])."', arr_Subcategory);";

$linkdata.="bLoading = false;"; }

$body["end"]="</form>".$linkdata.

"<script>".$bodyonload."</script>".

"<script>SetToFirstControl('editform');</script>";

if ($_REQUEST["a"]=="edited" && $inlineedit )

{ if(!$data)

{ $data=$evalues;

$HaveData=false; }

$keylink="";

$keylink.="&key1=".htmlspecialchars(rawurlencode(@$data["ID"]));

// Picture - File-based Image

$value="";

if(CheckImageExtension($data["Picture"]))

// show thumbnail

$thumbname="th_".$data["Picture"];

if(substr("files/",0,7)!="http://" && !file_exists(GetUploadFolder("Picture").$thumbname))

$thumbname=$data["Picture"];

$value="<a";

$value .= " target=_blank";

$value.=" href=\"".htmlspecialchars(AddLinkPrefix("Picture",$data["Picture"]))."\">";

$value.="<img";

if($thumbname==$data["Picture"])

{ $value.=" width=130"; }

$value.=" id=\"img_Picture_".$record_id."\" border=0";

$value.=" src=\"".htmlspecialchars(AddLinkPrefix("Picture",$thumbname))."\"></a>"; }

$smarty->assign("show_Picture",$value);

$showValues[] = $value;

$showFields[] = "Picture";

$showRawValues[] = substr($data["Picture"],0,100);

// Category -

$value="";

$value=DisplayLookupWizard("Category",$data["Category"],$data,$keylink,MODE_LIST);

$smarty->assign("show_Category",$value);

$showValues[] = $value;

97

Page 98: CHAPTER 1

$showFields[] = "Category";

$showRawValues[] = substr($data["Category"],0,100);

// Subcategory -

$value="";

$value=DisplayLookupWizard("Subcategory",$data["Subcategory"],$data,$keylink,MODE_LIST);

$smarty->assign("show_Subcategory",$value);

$showValues[] = $value;

$showFields[] = "Subcategory";

$showRawValues[] = substr($data["Subcategory"],0,100);

// Title -

$value="";

$value = ProcessLargeText(GetData($data,"Title", ""),"","",MODE_LIST);

$smarty->assign("show_Title",$value);

$showValues[] = $value;

$showFields[] = "Title";

$showRawValues[] = substr($data["Title"],0,100);

// Posted - Long Date

$value="";

$value = ProcessLargeText(GetData($data,"Posted", "Long Date"),"","",MODE_LIST);

$smarty->assign("show_Posted",$value);

$showValues[] = $value;

$showFields[] = "Posted";

$showRawValues[] = substr($data["Posted"],0,100);

// Details -

$value="";

$value = ProcessLargeText(GetData($data,"Details", ""),"","",MODE_LIST);

$smarty->assign("show_Details",$value);

$showValues[] = $value;

$showFields[] = "Details";

$showRawValues[] = substr($data["Details"],0,100);

echo "<textarea id=\"data\">";

if($IsSaved)

{ if($HaveData)

echo "saved";

else

echo "savnd";

print_inline_array($showKeys);

echo "\n";

print_inline_array($showValues);

echo "\n";

print_inline_array($showFields);

echo "\n";

print_inline_array($showRawValues);

echo "\n";

print_inline_array($showDetailKeys,true);

echo "\n";

print_inline_array($showDetailKeys);

echo "\n";

echo str_replace(array("&","<","\\","\r","\n"),array("&amp;","&lt;","\\\\","\\r","\\n"),$usermessage); }

else

{ if($status=="DECLINED")

echo "decli";

else

echo "error";

echo str_replace(array("&","<","\\","\r","\n"),array("&amp;","&lt;","\\\\","\\r","\\n"),$message); }

echo "</textarea>";

exit(); }

$control_Category=array();

$control_Category["func"]="xt_buildeditcontrol";

$control_Category["params"] = array();

98

Page 99: CHAPTER 1

$control_Category["params"]["field"]="Category";

$control_Category["params"]["value"]=@$data["Category"];

$control_Category["params"]["id"]=$record_id;

if($inlineedit)

$control_Category["params"]["mode"]="inline_edit";

else

$control_Category["params"]["mode"]="edit";

$xt->assignbyref("Category_editcontrol",$control_Category);

$control_Details=array();

$control_Details["func"]="xt_buildeditcontrol";

$control_Details["params"] = array();

$control_Details["params"]["field"]="Details";

$control_Details["params"]["value"]=@$data["Details"];

$control_Details["params"]["id"]=$record_id;

if($inlineedit)

$control_Details["params"]["mode"]="inline_edit";

else

$control_Details["params"]["mode"]="edit";

$xt->assignbyref("Details_editcontrol",$control_Details);

$control_Fullinfo=array();

$control_Fullinfo["func"]="xt_buildeditcontrol";

$control_Fullinfo["params"] = array();

$control_Fullinfo["params"]["field"]="Fullinfo";

$control_Fullinfo["params"]["value"]=@$data["Fullinfo"];

$control_Fullinfo["params"]["id"]=$record_id;

if($inlineedit)

$control_Fullinfo["params"]["mode"]="inline_edit";

else

$control_Fullinfo["params"]["mode"]="edit";

$xt->assignbyref("Fullinfo_editcontrol",$control_Fullinfo);

$control_Picture=array();

$control_Picture["func"]="xt_buildeditcontrol";

$control_Picture["params"] = array();

$control_Picture["params"]["field"]="Picture";

$control_Picture["params"]["value"]=@$data["Picture"];

$control_Picture["params"]["id"]=$record_id;

if($inlineedit)

$control_Picture["params"]["mode"]="inline_edit";

else

$control_Picture["params"]["mode"]="edit";

$xt->assignbyref("Picture_editcontrol",$control_Picture);

$control_Posted=array();

$control_Posted["func"]="xt_buildeditcontrol";

$control_Posted["params"] = array();

$control_Posted["params"]["field"]="Posted";

$control_Posted["params"]["value"]=@$data["Posted"];

$control_Posted["params"]["id"]=$record_id;

if($inlineedit)

$control_Posted["params"]["mode"]="inline_edit";

else

$control_Posted["params"]["mode"]="edit";

$xt->assignbyref("Posted_editcontrol",$control_Posted);

$control_Subcategory=array();

$control_Subcategory["func"]="xt_buildeditcontrol";

$control_Subcategory["params"] = array();

$control_Subcategory["params"]["field"]="Subcategory";

$control_Subcategory["params"]["value"]=@$data["Subcategory"];

$control_Subcategory["params"]["id"]=$record_id;

if($inlineedit)

$control_Subcategory["params"]["mode"]="inline_edit";

99

Page 100: CHAPTER 1

else

$control_Subcategory["params"]["mode"]="edit";

$xt->assignbyref("Subcategory_editcontrol",$control_Subcategory);

$control_Title=array();

$control_Title["func"]="xt_buildeditcontrol";

$control_Title["params"] = array();

$control_Title["params"]["field"]="Title";

$control_Title["params"]["value"]=@$data["Title"];

$control_Title["params"]["id"]=$record_id;

if($inlineedit)

$control_Title["params"]["mode"]="inline_edit";

else

$control_Title["params"]["mode"]="edit";

$xt->assignbyref("Title_editcontrol",$control_Title);

if(function_exists("BeforeShowEdit"))

BeforeShowEdit($xt,$templatefile);

$xt->display($templatefile);

function edit_error_handler($errno, $errstr, $errfile, $errline)

{ global $readevalues, $message, $status, $inlineedit, $error_happened;

if ( $inlineedit )

$message=""."Record was NOT edited".". ".$errstr;

else

$message="<div class=message><<< "."Record was NOT edited"." >>><br><br>".$errstr."</div>";

$readevalues=true;

$error_happened=true; }

?>

RECORD SEARCH PAGE

<? php

ini_set("display_errors","1");

ini_set("display_startup_errors","1");

header("Expires: Thu, 01 Jan 1970 00:00:01 GMT");

set_magic_quotes_runtime(0);

include("oldinclude/dbcommon.php");

include("oldinclude/clmain_variables.php");

if(!@$_SESSION["UserID"])

{ $_SESSION["MyURL"]=$_SERVER["SCRIPT_NAME"]."?".$_SERVER["QUERY_STRING"];

header("Location: login.php?message=expired");

return; }

if(!CheckSecurity(@$_SESSION["_".$strTableName."_OwnerID"],"Search") && !CheckSecurity(@$_SESSION["_".$strTableName."_OwnerID"],"Add"))

{ echo "<p>"."You don't have permissions to access this table"." <a href=\"login.php\">"."Back to login page"."</a></p>";

exit(); }

include('oldlibs/Smarty.class.php');

$smarty = new Smarty();

$conn=db_connect();

// process reqest data, fill session variables

if(!count($_POST) && !count($_GET))

{ $sess_unset = array();

foreach($_SESSION as $key=>$value)

if(substr($key,0,strlen($strTableName)+1)==$strTableName."_" &&

strpos(substr($key,strlen($strTableName)+1),"_")===false)

$sess_unset[] = $key;

foreach($sess_unset as $key)

unset($_SESSION[$key]); }

if(function_exists("BeforeProcessList"))

BeforeProcessList($conn);

if(@$_REQUEST["a"]=="showall")

$_SESSION[$strTableName."_search"]=0;

else if(@$_REQUEST["a"]=="search")

{ $_SESSION[$strTableName."_searchfield"]=postvalue("SearchField");

100

Page 101: CHAPTER 1

$_SESSION[$strTableName."_searchoption"]=postvalue("SearchOption");

$_SESSION[$strTableName."_searchfor"]=postvalue("SearchFor");

if(postvalue("SearchFor")!="" || postvalue("SearchOption")=='Empty')

$_SESSION[$strTableName."_search"]=1;

else

$_SESSION[$strTableName."_search"]=0;

$_SESSION[$strTableName."_pagenumber"]=1; }

else if(@$_REQUEST["a"]=="advsearch")

{ $_SESSION[$strTableName."_asearchnot"]=array();

$_SESSION[$strTableName."_asearchopt"]=array();

$_SESSION[$strTableName."_asearchfor"]=array();

$_SESSION[$strTableName."_asearchfor2"]=array();

$tosearch=0;

$asearchfield = postvalue("asearchfield");

$_SESSION[$strTableName."_asearchtype"] = postvalue("type");

if(!$_SESSION[$strTableName."_asearchtype"])

$_SESSION[$strTableName."_asearchtype"]="and";

foreach($asearchfield as $field)

{ $gfield=GoodFieldName($field);

$asopt=postvalue("asearchopt_".$gfield);

$value1=postvalue("value_".$gfield);

$type=postvalue("type_".$gfield);

$value2=postvalue("value1_".$gfield);

$not=postvalue("not_".$gfield);

if($value1 || $asopt=='Empty')

{ $tosearch=1;

$_SESSION[$strTableName."_asearchopt"][$field]=$asopt;

if(!is_array($value1))

$_SESSION[$strTableName."_asearchfor"][$field]=$value1;

else

$_SESSION[$strTableName."_asearchfor"][$field]=combinevalues($value1);

$_SESSION[$strTableName."_asearchfortype"][$field]=$type;

if($value2)

$_SESSION[$strTableName."_asearchfor2"][$field]=$value2;

$_SESSION[$strTableName."_asearchnot"][$field]=($not=="on"); }}

if($tosearch)

$_SESSION[$strTableName."_search"]=2;

else

$_SESSION[$strTableName."_search"]=0;

$_SESSION[$strTableName."_pagenumber"]=1; }

if(@$_REQUEST["orderby"])

$_SESSION[$strTableName."_orderby"]=@$_REQUEST["orderby"];

if(@$_REQUEST["pagesize"])

{ $_SESSION[$strTableName."_pagesize"]=@$_REQUEST["pagesize"];

$_SESSION[$strTableName."_pagenumber"]=1; }

if(@$_REQUEST["goto"])

$_SESSION[$strTableName."_pagenumber"]=@$_REQUEST["goto"];

$editValidateTypes = array();

$editValidateFields = array();

$addValidateTypes = array();

$addValidateFields = array();

$editValidateTypes[] = "";

$editValidateFields[] = "Category";

$editValidateTypes[] = "";

$editValidateFields[] = "Details";

$editValidateTypes[] = "";

$editValidateFields[] = "Picture";

$editValidateTypes[] = "";

$editValidateFields[] = "Posted";

$editValidateTypes[] = "";

101

Page 102: CHAPTER 1

$editValidateFields[] = "Subcategory";

$editValidateTypes[] = "";

$editValidateFields[] = "Title";

$addValidateTypes[] = "";

$addValidateFields[] = "Category";

$addValidateTypes[] = "";

$addValidateFields[] = "Details";

$addValidateTypes[] = "";

$addValidateFields[] = "Picture";

$addValidateTypes[] = "";

$addValidateFields[] = "Posted";

$addValidateTypes[] = "";

$addValidateFields[] = "Subcategory";

$addValidateTypes[] = "";

$addValidateFields[] = "Title";

$types_separated = implode(",", $editValidateTypes);

$fields_separated = implode(",", $editValidateFields);

$includes.= "var editValidateTypes = String('".$types_separated."').split(',');"."\r\n";

$includes.= "var editValidateFields = String('".$fields_separated."').split(',');"."\r\n";

$types_separated = implode(",", $addValidateTypes);

$fields_separated = implode(",", $addValidateFields);

$includes.="<script type=\"text/javascript\">\r\n";

$includes.= "var addValidateTypes = String('".$types_separated."').split(',');"."\r\n";

$includes.= "var addValidateFields = String('".$fields_separated."').split(',');"."\r\n";

"\nvar bSelected=false;".

"\nvar TEXT_FIRST = \""."First"."\";".

"\nvar TEXT_PREVIOUS = \""."Previous"."\";".

"\nvar TEXT_NEXT = \""."Next"."\";".

"\nvar TEXT_LAST = \""."Last"."\";".

"\nvar TEXT_PLEASE_SELECT='".jsreplace("Please select")."';".

"\nvar TEXT_SAVE='".jsreplace("Save")."';".

"\nvar TEXT_CANCEL='".jsreplace("Cancel")."';".

"\nvar TEXT_INLINE_ERROR='".jsreplace("Error occurred")."';".

"\nvar locale_dateformat = ".$locale_info["LOCALE_IDATE"].";".

"\nvar locale_datedelimiter = \"".$locale_info["LOCALE_SDATE"]."\";".

"\nvar bLoading=false;\r\n";

$includes.="var INLINE_EDIT_TABLE='clmain_edit.php';\r\n";

$includes.="var INLINE_ADD_TABLE='clmain_add.php';\r\n";

$includes.="var INLINE_VIEW_TABLE='clmain_view.php';\r\n";

$includes.="var SUGGEST_TABLE='clmain_searchsuggest.php';\r\n";

$includes.="var MASTER_PREVIEW_TABLE='clmain_masterpreview.php';\r\n"; }

$includes.="<div id=\"search_suggest\"></div>";

$includes.="<div id=\"master_details\" onmouseover=\"RollDetailsLink.showPopup();\" onmouseout=\"RollDetailsLink.hidePopup();\"></div>";

$includes.="<div id=\"inline_error\"></div>"; }

$smarty->assign("includes",$includes);

$strOrderBy="";

$order_ind=-1;

$smarty->assign("order_dir_Category","a");

$smarty->assign("order_dir_Details","a");

$smarty->assign("order_dir_Picture","a");

$smarty->assign("order_dir_Posted","a");

$smarty->assign("order_dir_Subcategory","a");

$smarty->assign("order_dir_Title","a");

$recno=1;

$numrows=0;

if(@$_SESSION[$strTableName."_orderby"])

{ $order_field=substr($_SESSION[$strTableName."_orderby"],1);

$order_dir=substr($_SESSION[$strTableName."_orderby"],0,1);

$order_ind=GetFieldIndex($order_field);

$smarty->assign("order_dir_Category","a");

102

Page 103: CHAPTER 1

if($order_field=="Category")

{ if($order_dir=="a")

{ $smarty->assign("order_dir_Category","d");

$img="up"; }

else

$img="down";

$smarty->assign("order_image_Category","<img src=\"images/".$img.".gif\" border=0>"); }

$smarty->assign("order_dir_Details","a");

if($order_field=="Details")

{ if($order_dir=="a")

{ $smarty->assign("order_dir_Details","d");

$img="up"; }

else

$img="down";

$smarty->assign("order_image_Details","<img src=\"images/".$img.".gif\" border=0>"); }

$smarty->assign("order_dir_Picture","a");

if($order_field=="Picture")

{ if($order_dir=="a")

{ $smarty->assign("order_dir_Picture","d");

$img="up"; }

else

$img="down";

$smarty->assign("order_image_Picture","<img src=\"images/".$img.".gif\" border=0>"); }

$smarty->assign("order_dir_Posted","a");

if($order_field=="Posted")

{ if($order_dir=="a")

{ $smarty->assign("order_dir_Posted","d");

$img="up"; }

else

$img="down";

$smarty->assign("order_image_Posted","<img src=\"images/".$img.".gif\" border=0>"); }

$smarty->assign("order_dir_Subcategory","a");

if($order_field=="Subcategory")

{ if($order_dir=="a")

{ $smarty->assign("order_dir_Subcategory","d");

$img="up"; }

else

$img="down";

$smarty->assign("order_image_Subcategory","<img src=\"images/".$img.".gif\" border=0>"); }

$smarty->assign("order_dir_Title","a");

if($order_field=="Title")

{ if($order_dir=="a")

{ $smarty->assign("order_dir_Title","d");

$img="up"; }

else

$img="down";

$smarty->assign("order_image_Title","<img src=\"images/".$img.".gif\" border=0>"); }

if($order_ind)

{ if($order_dir=="a")

$strOrderBy="order by ".($order_ind)." asc";

else

$strOrderBy="order by ".($order_ind)." desc"; }}

if(!$strOrderBy)

$strOrderBy=$gstrOrderBy;

$mypage=(integer)$_SESSION[$strTableName."_pagenumber"];

if(!$mypage)

$mypage=1;

$PageSize=(integer)$_SESSION[$strTableName."_pagesize"];

if(!$PageSize)

$PageSize=$gPageSize;

103

Page 104: CHAPTER 1

$smarty->assign("rpp10_selected",($PageSize==10)?"selected":"");

$smarty->assign("rpp20_selected",($PageSize==20)?"selected":"");

$smarty->assign("rpp30_selected",($PageSize==30)?"selected":"");

$smarty->assign("rpp50_selected",($PageSize==50)?"selected":"");

$smarty->assign("rpp100_selected",($PageSize==100)?"selected":"");

$smarty->assign("rpp500_selected",($PageSize==500)?"selected":"");

$selected_recs=array();

if (@$_REQUEST["mdelete"])

{ foreach(@$_REQUEST["mdelete"] as $ind)

{ $keys=array();

$keys["ID"]=refine($_REQUEST["mdelete1"][$ind-1]);

$selected_recs[]=$keys; }

} elseif(@$_REQUEST["selection"])

{ foreach(@$_REQUEST["selection"] as $keyblock)

{ $arr=split("&",refine($keyblock));

if(count($arr)<1)

continue;

$keys=array();

$keys["ID"]=urldecode(@$arr[0]);

$selected_recs[]=$keys; }}

$records_deleted=0;

foreach($selected_recs as $keys)

{ $where = KeyWhere($keys);

$where = whereAdd($where,SecuritySQL("Delete"));

$strSQL="delete from ".AddTableWrappers($strOriginalTableName)." where ".$where;

$retval=true;

if(function_exists("AfterDelete") || function_exists("BeforeDelete"))

{ $deletedrs = db_query(gSQLWhere($where),$conn);

$deleted_values = db_fetch_array($deletedrs); }

if(function_exists("BeforeDelete"))

$retval = BeforeDelete($where,$deleted_values);

if($retval && @$_REQUEST["a"]=="delete")

{ $records_deleted++;

LogInfo($strSQL);

db_exec($strSQL,$conn);

if(function_exists("AfterDelete"))

AfterDelete($where,$deleted_values); }}

if(count($selected_recs))

{ if(function_exists("AfterMassDelete"))

AfterMassDelete($records_deleted); }

$strWhereClause="";

if(@$_SESSION[$strTableName."_search"]==1){

$strSearchFor=trim($_SESSION[$strTableName."_searchfor"]);

$strSearchOption=trim($_SESSION[$strTableName."_searchoption"]);

if(@$_SESSION[$strTableName."_searchfield"])

{` $strSearchField = $_SESSION[$strTableName."_searchfield"];

if($where = StrWhere($strSearchField, $strSearchFor, $strSearchOption, ""))

$strWhereClause = whereAdd($strWhereClause,$where);

$strSQL = AddWhere($strSQL,$where);

else

$strWhereClause = whereAdd($strWhereClause,"1=0");

$strSQL = AddWhere($strSQL,"1=0"); }

else

{ $strWhere = "1=0";

if($where=StrWhere("Category", $strSearchFor, $strSearchOption, ""))

$strWhere .= " or ".$where;

if($where=StrWhere("Details", $strSearchFor, $strSearchOption, ""))

$strWhere .= " or ".$where;

if($where=StrWhere("Fullinfo", $strSearchFor, $strSearchOption, ""))

$strWhere .= " or ".$where;

104

Page 105: CHAPTER 1

if($where=StrWhere("Picture", $strSearchFor, $strSearchOption, ""))

$strWhere .= " or ".$where;

if($where=StrWhere("Posted", $strSearchFor, $strSearchOption, ""))

$strWhere .= " or ".$where;

if($where=StrWhere("Subcategory", $strSearchFor, $strSearchOption, ""))

$strWhere .= " or ".$where;

if($where=StrWhere("Title", $strSearchFor, $strSearchOption, ""))

$strWhere .= " or ".$where;

$strWhereClause = whereAdd($strWhereClause,$strWhere);

$strSQL = AddWhere($strSQL,$strWhere); } }

else if(@$_SESSION[$strTableName."_search"]==2)

{ $sWhere="";

foreach(@$_SESSION[$strTableName."_asearchfor"] as $f => $sfor)

{ $strSearchFor=trim($sfor);

$strSearchFor2="";

$type=@$_SESSION[$strTableName."_asearchfortype"][$f];

if(array_key_exists($f,@$_SESSION[$strTableName."_asearchfor2"]))

$strSearchFor2=trim(@$_SESSION[$strTableName."_asearchfor2"][$f]);

if($strSearchFor!="" || true)

{ if (!$sWhere)

{ if($_SESSION[$strTableName."_asearchtype"]=="and")

$sWhere="1=1";

else

$sWhere="1=0"; }

$strSearchOption=trim($_SESSION[$strTableName."_asearchopt"][$f]);

if($where=StrWhereAdv($f, $strSearchFor, $strSearchOption, $strSearchFor2,$type))

{ if($_SESSION[$strTableName."_asearchnot"][$f])

$where="not (".$where.")";

if($_SESSION[$strTableName."_asearchtype"]=="and")

$sWhere .= " and ".$where;

else

$sWhere .= " or ".$where; }}}

$strWhereClause = whereAdd($strWhereClause,$sWhere);

$strSQL = AddWhere($strSQL,$sWhere); }

$strSQL = gSQLWhere($strWhereClause);

$strSQL.=" ".trim($strOrderBy);

save SQL for use in "Export" and "Printer-friendly" pages

$_SESSION[$strTableName."_sql"] = $strSQL;

$_SESSION[$strTableName."_where"] = $strWhereClause;

$_SESSION[$strTableName."_order"] = $strOrderBy;

$rowsfound=false;

select and display records

if(CheckSecurity(@$_SESSION["_".$strTableName."_OwnerID"],"Search"))

{ $strSQLbak = $strSQL;

if(function_exists("BeforeQueryList"))

BeforeQueryList($strSQL,$strWhereClause,$strOrderBy);

else

{ $strSQL = gSQLWhere($strWhereClause);

$strSQL.=" ".trim($strOrderBy);

$numrows=gSQLRowCount($strWhereClause,0); }

LogInfo($strSQL);

if(!$numrows)

{ $smarty->assign("rowsfound",false);

$rowsfound=false;

$message="No records found";

$message = "<span name=\"notfound_message\">".$message."</span>";

$smarty->assign("message",$message); }

else

{ $smarty->assign("rowsfound",true);

$rowsfound=true;

105

Page 106: CHAPTER 1

$smarty->assign("records_found",$numrows);

$maxRecords = $numrows;

$maxpages=ceil($maxRecords/$PageSize);

if($mypage > $maxpages)

$mypage = $maxpages;

if($mypage<1)

$mypage=1;

$maxrecs=$PageSize;

$smarty->assign("page",$mypage);

$smarty->assign("maxpages",$maxpages);

$smarty->assign("pagination","<script language=\"JavaScript\">WritePagination(".$mypage.",".$maxpages.");

function GotoPage(nPageNumber)

{ window.location='clmain_list.php?goto='+nPageNumber; }

$strSQL.=" limit ".(($mypage-1)*$PageSize).",".$PageSize; }

$rs=db_query($strSQL,$conn);

$recordsonpage=$numrows-($mypage-1)*$PageSize;

if($recordsonpage>$PageSize)

$recordsonpage=$PageSize;

if($recordsonpage>=1)

$smarty->assign("column1show",true);

else

$smarty->assign("column1show",false);

$smarty->assign("column1show",true);

$rowinfo = array();

$shade=false;

$editlink="";

$copylink="";

while($data=db_fetch_array($rs))

{ if(function_exists("BeforeProcessRowList"))

{ if(!BeforeProcessRowList($data))

continue; }

break; }

while($data && $recno<=$PageSize)

{ $row=array();

for($col=1;$data && $recno<=$PageSize && $col<=1;$col++)

{ $row[$col."editable"]=CheckSecurity($data["UserID"],"Edit");

$keyblock="";

$row[$col."id1"]=htmlspecialchars($data["ID"]);

$keyblock.= rawurlencode($data["ID"]);

$row[$col."keyblock"]=htmlspecialchars($keyblock);

$row[$col."recno"] = $recno;

$editlink="";

$editlink.="editid1=".htmlspecialchars(rawurlencode($data["ID"]));

$row[$col."editlink"]=$editlink;

$copylink="";

$copylink.="copyid1=".htmlspecialchars(rawurlencode($data["ID"]));

$row[$col."copylink"]=$copylink;

$keylink="";

$keylink.="&key1=".htmlspecialchars(rawurlencode(@$data["ID"]));

// Picture - File-based Image

$value="";

if(CheckImageExtension($data["Picture"]))

{ $thumbname="th_".$data["Picture"];

if(substr("files/",0,7)!="http://" && !file_exists(GetUploadFolder("Picture").$thumbname))

$thumbname=$data["Picture"];

$value="<a";

$value .= " target=_blank";

$value.=" href=\"".htmlspecialchars(AddLinkPrefix("Picture",$data["Picture"]))."\">";

$value.="<img";

if($thumbname==$data["Picture"])

106

Page 107: CHAPTER 1

{ $value.=" width=130"; }

$value.=" border=0";

$value.=" src=\"".htmlspecialchars(AddLinkPrefix("Picture",$thumbname))."\"></a>"; }

$row[$col."Picture_value"]=$value;

// Category -

$value="";

$value = ProcessLargeText(GetData($data,"Category", ""),"field=Category".$keylink,"",MODE_LIST);

$row[$col."Category_value"]=$value;

// Subcategory -

$value="";

$value = ProcessLargeText(GetData($data,"Subcategory", ""),"field=Subcategory".$keylink,"",MODE_LIST);

$row[$col."Subcategory_value"]=$value;

// Title -

$value="";

$value = ProcessLargeText(GetData($data,"Title", ""),"field=Title".$keylink,"",MODE_LIST);

$row[$col."Title_value"]=$value;

// Posted - Long Date

$value="";

$value = ProcessLargeText(GetData($data,"Posted", "Long Date"),"field=Posted".$keylink,"",MODE_LIST);

$row[$col."Posted_value"]=$value;

// Details -

$value="";

$value = ProcessLargeText(GetData($data,"Details", ""),"field=Details".$keylink,"",MODE_LIST);

$row[$col."Details_value"]=$value;

$row[$col."show"]=true;

if(function_exists("BeforeMoveNextList"))

BeforeMoveNextList($data,$row,$col);

$span="<span ";

$span.="id=\"edit".$recno."_Picture\" ";

$span.=">";

$row[$col."Picture_value"] = $span.$row[$col."Picture_value"]."</span>";

$span="<span ";

$span.="id=\"edit".$recno."_Category\" ";

$span.=">";

$row[$col."Category_value"] = $span.$row[$col."Category_value"]."</span>";

$span="<span ";

$span.="id=\"edit".$recno."_Subcategory\" ";

$span.=">";

$row[$col."Subcategory_value"] = $span.$row[$col."Subcategory_value"]."</span>";

$span="<span ";

$span.="id=\"edit".$recno."_Title\" ";

$span.=">";

$row[$col."Title_value"] = $span.$row[$col."Title_value"]."</span>";

$span="<span ";

$span.="id=\"edit".$recno."_Posted\" ";

$span.=">";

$row[$col."Posted_value"] = $span.$row[$col."Posted_value"]."</span>";

$span="<span ";

$span.="id=\"edit".$recno."_Details\" ";

$span.=">";

$row[$col."Details_value"] = $span.$row[$col."Details_value"]."</span>";

while($data=db_fetch_array($rs))

{ if(function_exists("BeforeProcessRowList"))

{ if(!BeforeProcessRowList($data))

continue; }

break; }

$recno++; }

$rowinfo[]=$row; }

$smarty->assign("rowinfo",$rowinfo); }

if(CheckSecurity(@$_SESSION["_".$strTableName."_OwnerID"],"Search"))

107

Page 108: CHAPTER 1

{ if($_SESSION[$strTableName."_search"]==1)

{ $onload = "onLoad=\"if(document.getElementById('SearchFor')) document.getElementById('ctlSearchFor').focus();\"";

$smarty->assign("onload",$onload);

if(@$_SESSION[$strTableName."_searchfield"]=="Category")

$smarty->assign("search_Category","selected");

if(@$_SESSION[$strTableName."_searchfield"]=="Details")

$smarty->assign("search_Details","selected");

if(@$_SESSION[$strTableName."_searchfield"]=="Fullinfo")

$smarty->assign("search_Fullinfo","selected");

if(@$_SESSION[$strTableName."_searchfield"]=="Picture")

$smarty->assign("search_Picture","selected");

if(@$_SESSION[$strTableName."_searchfield"]=="Posted")

$smarty->assign("search_Posted","selected");

if(@$_SESSION[$strTableName."_searchfield"]=="Subcategory")

$smarty->assign("search_Subcategory","selected");

if(@$_SESSION[$strTableName."_searchfield"]=="Title")

$smarty->assign("search_Title","selected");

if(@$_SESSION[$strTableName."_searchoption"]=="Contains")

$smarty->assign("search_contains_option_selected","selected");

if(@$_SESSION[$strTableName."_searchoption"]=="Equals")

$smarty->assign("search_equals_option_selected","selected");

if(@$_SESSION[$strTableName."_searchoption"]=="Starts with ...")

$smarty->assign("search_startswith_option_selected","selected");

if(@$_SESSION[$strTableName."_searchoption"]=="More than ...")

$smarty->assign("search_more_option_selected","selected");

if(@$_SESSION[$strTableName."_searchoption"]=="Less than ...")

$smarty->assign("search_less_option_selected","selected");

if(@$_SESSION[$strTableName."_searchoption"]=="Equal or more than ...")

$smarty->assign("search_equalormore_option_selected","selected");

if(@$_SESSION[$strTableName."_searchoption"]=="Equal or less than ...")

$smarty->assign("search_equalorless_option_selected","selected");

if(@$_SESSION[$strTableName."_searchoption"]=="Empty")

$smarty->assign("search_empty_option_selected","selected");

$smarty->assign("search_searchfor","value=\"".htmlspecialchars(@$_SESSION[$strTableName."_searchfor"])."\""); }}

$smarty->assign("userid",htmlspecialchars($_SESSION["UserID"]));

$strPerm = GetUserPermissions("clmain");

$smarty->assign("allow_clmain",!(strpos($strPerm, "A")===false && strpos($strPerm, "S")===false));

$strPerm = GetUserPermissions("clreply");

$smarty->assign("allow_clreply",!(strpos($strPerm, "A")===false && strpos($strPerm, "S")===false));

$strPerm = GetUserPermissions("clreplyfriend");

$smarty->assign("allow_clreplyfriend",!(strpos($strPerm, "A")===false && strpos($strPerm, "S")===false));

$strPerm = GetUserPermissions("clown_records");

$smarty->assign("allow_clown_records",!(strpos($strPerm, "A")===false && strpos($strPerm, "S")===false));

$strPerm = GetUserPermissions("clusers");

$smarty->assign("allow_clusers",!(strpos($strPerm, "A")===false && strpos($strPerm, "S")===false));

$strPerm = GetUserPermissions("clcategory");

$smarty->assign("allow_clcategory",!(strpos($strPerm, "A")===false && strpos($strPerm, "S")===false));

$strPerm = GetUserPermissions("clsubcategory");

$smarty->assign("allow_clsubcategory",!(strpos($strPerm, "A")===false && strpos($strPerm, "S")===false));

$allow_add = CheckSecurity(@$_SESSION["_".$strTableName."_OwnerID"],"Add");

$smarty->assign("allow_delete",CheckSecurity(@$_SESSION["_".$strTableName."_OwnerID"],"Delete"));

$smarty->assign("allow_add",$allow_add);

$smarty->assign("allow_edit",CheckSecurity(@$_SESSION["_".$strTableName."_OwnerID"],"Edit"));

$smarty->assign("allow_export",CheckSecurity(@$_SESSION["_".$strTableName."_OwnerID"],"Export"));

$smarty->assign("allow_import",CheckSecurity(@$_SESSION["_".$strTableName."_OwnerID"],"Import"));

$allow_search=CheckSecurity(@$_SESSION["_".$strTableName."_OwnerID"],"Search");

$smarty->assign("allow_search",$allow_search);

$smarty->assign("allow_deleteorexport",CheckSecurity(@$_SESSION["_".$strTableName."_OwnerID"],"Delete") || CheckSecurity(@$_SESSION["_".

$strTableName."_OwnerID"],"Export") );

$display_grid=true;

108

Page 109: CHAPTER 1

$display_grid = $allow_add || $allow_search && $rowsfound;

$display_records=$display_grid;

$display_records = $rowsfound && $allow_search;

if(!$display_grid)

$display_records=false;

$smarty->assign("display_grid",$display_grid);

$smarty->assign("display_records",$display_records);

$linkdata="";

$linkdata .= "<script type=\"text/javascript\">\r\n";

$linkdata.="\$(\".addarea\").each(function(i) { \$(this).hide();});\r\n";

$linkdata.="var newrecord_id=".($recno+1).";\r\n";

$linkdata.="var newrecord_tempid=0;\r\n";

if(!$numrows)

{ $linkdata .= "$('[@name=record_controls]').hide();

$('[@name=maintable]').hide();";

} #inline_error {

font-family: Verdana, Arial, Helvetica, sans serif;

font-size: 11px;

position: absolute;

background-color: white;

border: 1px solid red;

padding: 10px;

background-repeat: no-repeat;

display: none; }

$smarty->assign("linkdata",$linkdata);

$strSQL=$_SESSION[$strTableName."_sql"];

$smarty->assign("guest",$_SESSION["AccessLevel"] == ACCESS_LEVEL_GUEST);

$templatefile = "clmain_list.htm";

if(function_exists("BeforeShowList"))

BeforeShowList($smarty,$templatefile);

$smarty->display($templatefile);

PRINTER-FRIENDLY PAGE

<? php

ini_set("display_errors","1");

ini_set("display_startup_errors","1");

header("Expires: Thu, 01 Jan 1970 00:00:01 GMT");

set_magic_quotes_runtime(0);

include("oldinclude/dbcommon.php");

include("oldinclude/clmain_variables.php");

if(!@$_SESSION["UserID"])

{ $_SESSION["MyURL"]=$_SERVER["SCRIPT_NAME"]."?".$_SERVER["QUERY_STRING"];

header("Location: login.php?message=expired");

return; }

if(!CheckSecurity(@$_SESSION["_".$strTableName."_OwnerID"],"Export"))

{ echo "<p>"."You don't have permissions to access this table"."<a href=\"login.php\">"."Back to login page"."</a></p>";

return; }

$all=postvalue("all");

include('oldlibs/Smarty.class.php');

$smarty = new Smarty();

$conn=db_connect();

if(function_exists("BeforeProcessPrint"))

BeforeProcessPrint($conn);

$strWhereClause="";

if (@$_REQUEST["a"]!="")

{ $sWhere = "1=0";

$selected_recs=array();

if (@$_REQUEST["mdelete"])

{ foreach(@$_REQUEST["mdelete"] as $ind)

{ $keys=array();

109

Page 110: CHAPTER 1

$keys["ID"]=refine($_REQUEST["mdelete1"][$ind-1]);

$selected_recs[]=$keys; }}

elseif(@$_REQUEST["selection"])

{ foreach(@$_REQUEST["selection"] as $keyblock)

{ $arr=split("&",refine($keyblock));

if(count($arr)<1)

continue;

$keys=array();

$keys["ID"]=urldecode($arr[0]);

$selected_recs[]=$keys; }}

foreach($selected_recs as $keys)

{ $sWhere = $sWhere . " or ";

$sWhere.=KeyWhere($keys); }

$strSQL = AddWhere($gstrSQL,$sWhere);

$strSQL = gSQLWhere($sWhere);

$strWhereClause=$sWhere; }

else

{ $strWhereClause=@$_SESSION[$strTableName."_where"];

$strSQL = gSQLWhere($strWhereClause); }

if(postvalue("pdf"))

$strWhereClause = @$_SESSION[$strTableName."_pdfwhere"];

$_SESSION[$strTableName."_pdfwhere"] = $strWhereClause;

$strOrderBy=$_SESSION[$strTableName."_order"];

if(!$strOrderBy)

$strOrderBy=$gstrOrderBy;

$strSQL.=" ".trim($strOrderBy);

$strSQLbak = $strSQL;

if(function_exists("BeforeQueryPrint"))

else

{ $strSQL = gSQLWhere($strWhereClause);

$strSQL.=" ".trim($strOrderBy);

$numrows=gSQLRowCount($strWhereClause,0); }

LogInfo($strSQL);

$mypage=(integer)$_SESSION[$strTableName."_pagenumber"];

if(!$mypage)

$mypage=1;

$PageSize=(integer)$_SESSION[$strTableName."_pagesize"];

if(!$PageSize)

$PageSize=$gPageSize;

$recno=1;

$records=0;

$pageindex=1;

if(!$all)

{ if($numrows)

{ $maxRecords = $numrows;

$maxpages=ceil($maxRecords/$PageSize);

if($mypage > $maxpages)

$mypage = $maxpages;

if($mypage<1)

$mypage=1;

$maxrecs=$PageSize;

$strSQL.=" limit ".(($mypage-1)*$PageSize).",".$PageSize; }

$rs=db_query($strSQL,$conn);

$recordsonpage=$numrows-($mypage-1)*$PageSize;

if($recordsonpage>$PageSize)

$recordsonpage=$PageSize;

if($recordsonpage>=1)

$smarty->assign("column1show",true);

else

$smarty->assign("column1show",false); }

110

Page 111: CHAPTER 1

else

{ $rs=db_query($strSQL,$conn);

$recordsonpage = $numrows;

if($recordsonpage>=1)

$smarty->assign("column1show",true);

else

$smarty->assign("column1show",false); }

$pages = array();

$rowinfo = array();

while($data=db_fetch_array($rs))

{ if(function_exists("BeforeProcessRowPrint"))

{ if(!BeforeProcessRowPrint($data))

continue; }

break; }

while($data && ($all || $recno<=$PageSize))

{ $row=array();

for($col=1;$data && ($all || $recno<=$PageSize) && $col<=1;$col++)

{ $recno++;

$records++;

$keylink="";

$keylink.="&key1=".htmlspecialchars(rawurlencode(@$data["ID"]));

// Category -

$value="";

if(strlen($data["Category"]))

{ $strdata = make_db_value("Category",$data["Category"]);

$LookupSQL="SELECT ";

$LookupSQL.="`CategoryName`";

$LookupSQL.=" FROM `clcategory` WHERE `CategoryName` = " . $strdata;

LogInfo($LookupSQL);

$rsLookup = db_query($LookupSQL,$conn);

$lookupvalue=$data["Category"];

if($lookuprow=db_fetch_numarray($rsLookup))

$lookupvalue=$lookuprow[0];

$value=ProcessLargeText(GetDataInt($lookupvalue,$data,"Category", ""),"field=Category".$keylink,"",MODE_PRINT); }

else

$value="";

$value=DisplayLookupWizard("Category",$data["Category"],$data,$keylink,MODE_PRINT);

$row[$col."Category_value"]=$value;

// Subcategory -

$value="";

if(strlen($data["Subcategory"]))

{ $strdata = make_db_value("Subcategory",$data["Subcategory"]);

$LookupSQL="SELECT ";

$LookupSQL.="`SubcategoryName`";

$LookupSQL.=" FROM `clsubcategory` WHERE `SubcategoryName` = " . $strdata;

LogInfo($LookupSQL);

$rsLookup = db_query($LookupSQL,$conn);

$lookupvalue=$data["Subcategory"];

if($lookuprow=db_fetch_numarray($rsLookup))

$lookupvalue=$lookuprow[0];

$value=ProcessLargeText(GetDataInt($lookupvalue,$data,"Subcategory", ""),"field=Subcategory".$keylink,"",MODE_PRINT); }

else

$value="";

$value=DisplayLookupWizard("Subcategory",$data["Subcategory"],$data,$keylink,MODE_PRINT);

$row[$col."Subcategory_value"]=$value;

// Title -

$value="";

$value = ProcessLargeText(GetData($data,"Title", ""),"field=Title".$keylink,"",MODE_PRINT);

$row[$col."Title_value"]=$value;

// Posted - Long Date

111

Page 112: CHAPTER 1

$value="";

$value = ProcessLargeText(GetData($data,"Posted", "Long Date"),"field=Posted".$keylink,"",MODE_PRINT);

$row[$col."Posted_value"]=$value;

// Details -

$value="";

$value = ProcessLargeText(GetData($data,"Details", ""),"field=Details".$keylink,"",MODE_PRINT);

$row[$col."Details_value"]=$value;

// Fullinfo - HTML

$value="";

$value = GetData($data,"Fullinfo", "HTML");

$row[$col."Fullinfo_value"]=$value;

// Picture - File-based Image

$value="";

if(CheckImageExtension($data["Picture"]))

// show thumbnail

$thumbname="th_".$data["Picture"];

if(substr("files/",0,7)!="http://" && !file_exists(GetUploadFolder("Picture").$thumbname))

$thumbname=$data["Picture"];

$value="<a target=_blank href=\"".htmlspecialchars(AddLinkPrefix("Picture",$data["Picture"]))."\">";

$value.="<img";

if($thumbname==$data["Picture"])

{ $value.=" width=130"; }

$value.=" border=0";

$value.=" src=\"".htmlspecialchars(AddLinkPrefix("Picture",$thumbname))."\"></a>"; }

$row[$col."Picture_value"]=$value;

$row[$col."show"]=true;

if(function_exists("BeforeMoveNextPrint"))

BeforeMoveNextPrint($data,$row,$col);

while($data=db_fetch_array($rs))

{ if(function_exists("BeforeProcessRowPrint"))

{ if(!BeforeProcessRowPrint($data))

continue; }

break; }}

$rowinfo[]=$row;

if($all && $records>=30)

{ $page=array("rowinfo" =>$rowinfo);

$page["idx"]=$pageindex;

$pageindex++;

$pages[] = $page;

$records=0;

$rowinfo=array(); }}

if($all && count($rowinfo))

{ $page=array("rowinfo" =>$rowinfo);

$page["idx"]=$pageindex;

$pages[] = $page; }

if(!$all)

$smarty->assign_by_ref("rowinfo",$rowinfo);

else

{ if(count($pages))

{ $pages[count($pages)-1]["showtotals"]=true;

$pages[count($pages)-1]["last"]=true; }

$smarty->assign_by_ref("pages",$pages); }

$strSQL=$_SESSION[$strTableName."_sql"];

$pagename = $_SERVER["REQUEST_URI"];

if(!$pagename)

{ $pagename=basename(__file__);

$params="";

foreach($_GET as $k=>$v)

{ if(strlen($params))

$params.="&";

112

Page 113: CHAPTER 1

$params.=rawurlencode($k)."=".rawurlencode($v); }

if(strlen($params))

$pagename.="?".$params; }

if(strpos($pagename,"?")===false)

$pagename.="?pdf=1";

else

$pagename.="&pdf=1";

$smarty->assign("pageurl",$pagename);

if(postvalue("pdf"))

$smarty->assign("pdf",true);

if(!$all)

$templatefile = "clmain_print.htm";

else

$templatefile = "clmain_print_all.htm";

if(function_exists("BeforeShowPrint"))

BeforeShowPrint($smarty,$templatefile);

if(!postvalue("pdf"))

$smarty->display($templatefile);

else

{ $page = $smarty->fetch($templatefile);

$pagewidth=postvalue("width")*1.05;

$pageheight=postvalue("height")*1.05;

$landscape=false;

if(postvalue("all"))

{ if($pagewidth>$pageheight)

{ $landscape=true;

if($pagewidth/$pageheight<297/210)

$pagewidth = 297/210*$pageheight; }

else

{ if($pagewidth/$pageheight<210/297)

$pagewidth = 210/297*$pageheight; }}

include("plugins/page2pdf.php"); }

EXPORT RESULT PAGE

<? php

ini_set("display_errors","1");

ini_set("display_startup_errors","1");

session_cache_limiter("none");

set_magic_quotes_runtime(0);

include("include/dbcommon.php");

include("include/clmain_variables.php");

if(!@$_SESSION["UserID"])

{ $_SESSION["MyURL"]=$_SERVER["SCRIPT_NAME"]."?".$_SERVER["QUERY_STRING"];

header("Location: login.php?message=expired");

return; }

if(!CheckSecurity(@$_SESSION["_".$strTableName."_OwnerID"],"Export"))

{ echo "<p>"."You don't have permissions to access this table"."<a href=\"login.php\">"."Back to login page"."</a></p>";

return; }

$conn=db_connect();

if(function_exists("BeforeProcessExport"))

BeforeProcessExport($conn);

$strWhereClause="";

$options = "1";

if (@$_REQUEST["a"]!="")

{ $options = "";

$sWhere = "1=0";

$selected_recs=array();

if (@$_REQUEST["mdelete"])

{ foreach(@$_REQUEST["mdelete"] as $ind)

{ $keys=array();

113

Page 114: CHAPTER 1

$keys["ID"]=refine($_REQUEST["mdelete1"][$ind-1]);

$selected_recs[]=$keys; }}

elseif(@$_REQUEST["selection"])

{ foreach(@$_REQUEST["selection"] as $keyblock)

{ $arr=split("&",refine($keyblock));

if(count($arr)<1)

continue;

$keys=array();

$keys["ID"]=urldecode($arr[0]);

$selected_recs[]=$keys; }}

foreach($selected_recs as $keys)

{ $sWhere = $sWhere . " or ";

$sWhere.=KeyWhere($keys); }

$strSQL = gSQLWhere($sWhere);

$strWhereClause=$sWhere;

$_SESSION[$strTableName."_SelectedSQL"] = $strSQL;

$_SESSION[$strTableName."_SelectedWhere"] = $sWhere; }

if ($_SESSION[$strTableName."_SelectedSQL"]!="" && @$_REQUEST["records"]=="")

{ $strSQL = $_SESSION[$strTableName."_SelectedSQL"];

$strWhereClause=@$_SESSION[$strTableName."_SelectedWhere"]; }

else

{ $strWhereClause=@$_SESSION[$strTableName."_where"];

$strSQL=gSQLWhere($strWhereClause); }

$mypage=1;

if(@$_REQUEST["type"])

{ $strOrderBy=$_SESSION[$strTableName."_order"];

if(!$strOrderBy)

$strOrderBy=$gstrOrderBy;

$strSQL.=" ".trim($strOrderBy);

$strSQLbak = $strSQL;

if(function_exists("BeforeQueryExport"))

$numrows=GetRowCount($strSQL); }

else

{ $strSQL = gSQLWhere($strWhereClause);

$strSQL.=" ".trim($strOrderBy);

$numrows=gSQLRowCount($strWhereClause,0); }

LogInfo($strSQL);

$nPageSize=0;

if(@$_REQUEST["records"]=="page" && $numrows)

{ $mypage=(integer)@$_SESSION[$strTableName."_pagenumber"];

$nPageSize=(integer)@$_SESSION[$strTableName."_pagesize"];

if($numrows<=($mypage-1)*$nPageSize)

$mypage=ceil($numrows/$nPageSize);

if(!$nPageSize)

$nPageSize=$gPageSize;

if(!$mypage)

$mypage=1;

$strSQL.=" limit ".(($mypage-1)*$nPageSize).",".$nPageSize; }

$rs=db_query($strSQL,$conn);

if(!ini_get("safe_mode"))

set_time_limit(300);

if(@$_REQUEST["type"]=="excel")

ExportToExcel();

else if(@$_REQUEST["type"]=="word")

ExportToWord();

else if(@$_REQUEST["type"]=="xml")

ExportToXML();

else if(@$_REQUEST["type"]=="csv")

ExportToCSV();

else if(@$_REQUEST["type"]=="pdf")

114

Page 115: CHAPTER 1

ExportToPDF();

db_close($conn);

return; }

header("Expires: Thu, 01 Jan 1970 00:00:01 GMT");

include('libs/xtempl.php');

$xt = new Xtempl();

if($options)

{ $xt->assign("rangeheader_block",true);

$xt->assign("range_block",true); }

$body=array();

$body["begin"]="<form action=\"clmain_export.php\" method=get id=frmexport name=frmexport>";

$body["end"]="</form>";

$xt->assignbyref("body",$body);

$xt->display("clmain_export.htm");

function ExportToExcel()

{ global $cCharset;

header("Content-type: application/vnd.ms-excel");

header("Content-Disposition: attachment;Filename=clmain.xls");

echo "<html>";

echo "<html xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:x=\"urn:schemas-microsoft-com:office:excel\" xmlns=\"http://www.w3.org/TR/REC-

html40\">";

echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=".$cCharset."\">";

echo "<body>";

echo "<table border=1>";

WriteTableData();

echo "</table>";

echo "</body>";

echo "</html>"; }

function ExportToWord()

{ global $cCharset;

header("Content-type: application/vnd.ms-word");

header("Content-Disposition: attachment;Filename=clmain.doc");

echo "<html>";

echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=".$cCharset."\">";

echo "<body>";

echo "<table border=1>";

WriteTableData();

echo "</table>";

echo "</body>";

echo "</html>"; }

function ExportToXML()

{ global $nPageSize,$rs,$strTableName,$conn;

header("Content-type: text/xml");

header("Content-Disposition: attachment;Filename=clmain.xml");

if(!($row=db_fetch_array($rs)))

return;

global $cCharset;

echo "<?xml version=\"1.0\" encoding=\"".$cCharset."\" standalone=\"yes\"?>\r\n";

echo "<table>\r\n";

$i=0;

while((!$nPageSize || $i<$nPageSize) && $row)

{ echo "<row>\r\n";

$field=htmlspecialchars(XMLNameEncode("Category"));

echo "<".$field.">";

if(strlen($row["Category"]))

{ $strdata = make_db_value("Category",$row["Category"]);

$LookupSQL="SELECT ";

$LookupSQL.="`CategoryName`";

$LookupSQL.=" FROM `clcategory` WHERE `CategoryName` = " . $strdata;

LogInfo($LookupSQL);

115

Page 116: CHAPTER 1

$rsLookup = db_query($LookupSQL,$conn);

$lookupvalue=$row["Category"];

if($lookuprow=db_fetch_numarray($rsLookup))

$lookupvalue=$lookuprow[0];

echo htmlspecialchars(GetDataInt($lookupvalue,$row,"Category", "")); }

echo htmlspecialchars(DisplayLookupWizard("Category",$row["Category"],$row,"",MODE_EXPORT));

echo "</".$field.">\r\n";

$field=htmlspecialchars(XMLNameEncode("Details"));

echo "<".$field.">";

echo htmlspecialchars(GetData($row,"Details",""));

echo "</".$field.">\r\n";

$field=htmlspecialchars(XMLNameEncode("Fullinfo"));

echo "<".$field.">";

echo htmlspecialchars(GetData($row,"Fullinfo",""));

echo "</".$field.">\r\n";

$field=htmlspecialchars(XMLNameEncode("Picture"));

echo "<".$field.">";

echo htmlspecialchars(GetData($row,"Picture",""));

echo "</".$field.">\r\n";

$field=htmlspecialchars(XMLNameEncode("Posted"));

echo "<".$field.">";

echo htmlspecialchars(GetData($row,"Posted",""));

echo "</".$field.">\r\n";

$field=htmlspecialchars(XMLNameEncode("Subcategory"));

echo "<".$field.">";

if(strlen($row["Subcategory"]))

{ $strdata = make_db_value("Subcategory",$row["Subcategory"]);

$LookupSQL="SELECT ";

$LookupSQL.="`SubcategoryName`";

$LookupSQL.=" FROM `clsubcategory` WHERE `SubcategoryName` = " . $strdata;

LogInfo($LookupSQL);

$rsLookup = db_query($LookupSQL,$conn);

$lookupvalue=$row["Subcategory"];

if($lookuprow=db_fetch_numarray($rsLookup))

$lookupvalue=$lookuprow[0];

echo htmlspecialchars(GetDataInt($lookupvalue,$row,"Subcategory", "")); }

echo htmlspecialchars(DisplayLookupWizard("Subcategory",$row["Subcategory"],$row,"",MODE_EXPORT));

echo "</".$field.">\r\n";

$field=htmlspecialchars(XMLNameEncode("Title"));

echo "<".$field.">";

echo htmlspecialchars(GetData($row,"Title",""));

echo "</".$field.">\r\n";

echo "</row>\r\n";

$i++;

$row=db_fetch_array($rs); }

echo "</table>\r\n"; }

function ExportToCSV()

{ global $rs,$nPageSize,$strTableName,$conn;

header("Content-type: application/csv");

header("Content-Disposition: attachment;Filename=clmain.csv");

if(!($row=db_fetch_array($rs)))

return;

$totals=array();

$outstr="";

if($outstr!="")

$outstr.=",";

$outstr.= "\"Category\"";

if($outstr!="")

$outstr.=",";

$outstr.= "\"Details\"";

116

Page 117: CHAPTER 1

if($outstr!="")

$outstr.=",";

$outstr.= "\"Fullinfo\"";

if($outstr!="")

$outstr.=",";

$outstr.= "\"Picture\"";

if($outstr!="")

$outstr.=",";

$outstr.= "\"Posted\"";

if($outstr!="")

$outstr.=",";

$outstr.= "\"Subcategory\"";

if($outstr!="")

$outstr.=",";

$outstr.= "\"Title\"";

echo $outstr;

echo "\r\n";

// write data rows

$iNumberOfRows = 0;

while((!$nPageSize || $iNumberOfRows<$nPageSize) && $row)

{ $outstr="";

if($outstr!="")

$outstr.=",";

if(strlen($row["Category"]))

{ $strdata = make_db_value("Category",$row["Category"]);

$LookupSQL="SELECT ";

$LookupSQL.="`CategoryName`";

$LookupSQL.=" FROM `clcategory` WHERE `CategoryName` = " . $strdata;

LogInfo($LookupSQL);

$rsLookup = db_query($LookupSQL,$conn);

$lookupvalue=$row["Category"];

if($lookuprow=db_fetch_numarray($rsLookup))

$lookupvalue=$lookuprow[0];

$outstr.='"'.htmlspecialchars(GetDataInt($lookupvalue,$row,"Category", "")).'"'; }

$value = DisplayLookupWizard("Category",$row["Category"],$row,"",MODE_EXPORT);

if(strlen($value))

$outstr.='"'.htmlspecialchars($value).'"';

if($outstr!="")

$outstr.=",";

$format="";

$outstr.='"'.htmlspecialchars(GetData($row,"Details",$format)).'"';

if($outstr!="")

$outstr.=",";

$format="HTML";

$outstr.='"'.htmlspecialchars(GetData($row,"Fullinfo",$format)).'"';

if($outstr!="")

$outstr.=",";

$format=FORMAT_NONE;

$outstr.='"'.htmlspecialchars(GetData($row,"Picture",$format)).'"';

if($outstr!="")

$outstr.=",";

$format="Long Date";

$outstr.='"'.htmlspecialchars(GetData($row,"Posted",$format)).'"';

if($outstr!="")

$outstr.=",";

if(strlen($row["Subcategory"]))

{ $strdata = make_db_value("Subcategory",$row["Subcategory"]);

$LookupSQL="SELECT ";

$LookupSQL.="`SubcategoryName`";

$LookupSQL.=" FROM `clsubcategory` WHERE `SubcategoryName` = " . $strdata;

117

Page 118: CHAPTER 1

LogInfo($LookupSQL);

$rsLookup = db_query($LookupSQL,$conn);

$lookupvalue=$row["Subcategory"];

if($lookuprow=db_fetch_numarray($rsLookup))

$lookupvalue=$lookuprow[0];

$outstr.='"'.htmlspecialchars(GetDataInt($lookupvalue,$row,"Subcategory", "")).'"'; }

$value = DisplayLookupWizard("Subcategory",$row["Subcategory"],$row,"",MODE_EXPORT);

if(strlen($value))

$outstr.='"'.htmlspecialchars($value).'"';

if($outstr!="")

$outstr.=",";

$format="";

$outstr.='"'.htmlspecialchars(GetData($row,"Title",$format)).'"';

echo $outstr;

echo "\r\n";

$iNumberOfRows++;

$row=db_fetch_array($rs); }

$first=true; }

function WriteTableData()

{ global $rs,$nPageSize,$strTableName,$conn;

if(!($row=db_fetch_array($rs)))

return;

// write header

echo "<tr>";

if($_REQUEST["type"]=="excel")

{ echo '<td style="width: 100" x:str>'.PrepareForExcel("Category").'</td>';

echo '<td style="width: 100" x:str>'.PrepareForExcel("Details").'</td>';

echo '<td style="width: 100" x:str>'.PrepareForExcel("Fullinfo").'</td>';

echo '<td style="width: 100" x:str>'.PrepareForExcel("Picture").'</td>';

echo '<td style="width: 100" x:str>'.PrepareForExcel("Posted").'</td>';

echo '<td style="width: 100" x:str>'.PrepareForExcel("Subcategory").'</td>';

echo '<td style="width: 100" x:str>'.PrepareForExcel("Title").'</td>'; }

else

{ echo "<td>Category</td>";

echo "<td>Details</td>";

echo "<td>Fullinfo</td>";

echo "<td>Picture</td>";

echo "<td>Posted</td>";

echo "<td>Subcategory</td>";

echo "<td>Title</td>"; }

echo "</tr>";

$totals=array();

// write data rows

$iNumberOfRows = 0;

while((!$nPageSize || $iNumberOfRows<$nPageSize) && $row)

{ echo "<tr>";

if($_REQUEST["type"]=="excel")

echo '<td x:str>';

else

echo '<td>';

if(strlen($row["Category"]))

{ $strdata = make_db_value("Category",$row["Category"]);

$LookupSQL="SELECT ";

$LookupSQL.="`CategoryName`";

$LookupSQL.=" FROM `clcategory` WHERE `CategoryName` = " . $strdata;

LogInfo($LookupSQL);

$rsLookup = db_query($LookupSQL,$conn);

$lookupvalue=$row["Category"];

if($lookuprow=db_fetch_numarray($rsLookup))

$lookupvalue=$lookuprow[0];

118

Page 119: CHAPTER 1

$strValue=GetDataInt($lookupvalue,$row,"Category", "");

$strValue = DisplayLookupWizard("Category",$row["Category"],$row,"",MODE_EXPORT);

if($_REQUEST["type"]=="excel")

echo PrepareForExcel($strValue);

else

echo htmlspecialchars($strValue); }

echo '</td>';

if($_REQUEST["type"]=="excel")

echo '<td x:str>';

else

echo '<td>';

$format="";

if($_REQUEST["type"]=="excel")

echo PrepareForExcel(GetData($row,"Details",$format));

else

echo htmlspecialchars(GetData($row,"Details",$format));

echo '</td>';

if($_REQUEST["type"]=="excel")

echo '<td x:str>';

else

echo '<td>';

$format="HTML";

echo GetData($row,"Fullinfo",$format);

echo '</td>';

if($_REQUEST["type"]=="excel")

echo '<td x:str>';

else

echo '<td>';

$format=FORMAT_NONE;

if($_REQUEST["type"]=="excel")

echo PrepareForExcel(GetData($row,"Picture",$format));

else

echo htmlspecialchars(GetData($row,"Picture",$format));

echo '</td>';

echo '<td>';

$format="Long Date";

if($_REQUEST["type"]=="excel")

echo PrepareForExcel(GetData($row,"Posted",$format));

else

echo htmlspecialchars(GetData($row,"Posted",$format));

echo '</td>';

if($_REQUEST["type"]=="excel")

echo '<td x:str>';

else

echo '<td>';

if(strlen($row["Subcategory"]))

{ $strdata = make_db_value("Subcategory",$row["Subcategory"]);

$LookupSQL="SELECT ";

$LookupSQL.="`SubcategoryName`";

$LookupSQL.=" FROM `clsubcategory` WHERE `SubcategoryName` = " . $strdata;

LogInfo($LookupSQL);

$rsLookup = db_query($LookupSQL,$conn);

$lookupvalue=$row["Subcategory"];

if($lookuprow=db_fetch_numarray($rsLookup))

$lookupvalue=$lookuprow[0];

$strValue=GetDataInt($lookupvalue,$row,"Subcategory", "");

$strValue = DisplayLookupWizard("Subcategory",$row["Subcategory"],$row,"",MODE_EXPORT);

if($_REQUEST["type"]=="excel")

echo PrepareForExcel($strValue);

else

119

Page 120: CHAPTER 1

echo htmlspecialchars($strValue); }

echo '</td>';

if($_REQUEST["type"]=="excel")

echo '<td x:str>';

else

echo '<td>';

$format="";

if($_REQUEST["type"]=="excel")

echo PrepareForExcel(GetData($row,"Title",$format));

else

echo htmlspecialchars(GetData($row,"Title",$format));

echo '</td>';

echo "</tr>";

$iNumberOfRows++;

$row=db_fetch_array($rs); }}

function XMLNameEncode($strValue)

{ $search=array(" ","#","'","/","\\","(",")",",","[","]","+","\"","-","_","|","}","{","=");

return str_replace($search,"",$strValue); }

function PrepareForExcel($str)

{ $ret = htmlspecialchars($str);

if (substr($ret,0,1)== "=")

$ret = "&#61;".substr($ret,1);

return $ret; }

function ExportToPDF()

{ global $nPageSize,$rs,$strTableName,$conn;

global $colwidth,$leftmargin;

if(!($row=db_fetch_array($rs)))

return;

class PDF extends FPDF

{

//Current column

var $col=0;

//Ordinate of column start

var $y0;

var $maxheight;

function AcceptPageBreak()

{ global $colwidth,$leftmargin;

if($this->y0+$this->rowheight>$this->PageBreakTrigger)

return true;

$x=$leftmargin;

if($this->maxheight<$this->PageBreakTrigger-$this->y0)

$this->maxheight=$this->PageBreakTrigger-$this->y0;

$this->Rect($x,$this->y0,$colwidth["Category"],$this->maxheight);

$x+=$colwidth["Category"];

$this->Rect($x,$this->y0,$colwidth["Details"],$this->maxheight);

$x+=$colwidth["Details"];

$this->Rect($x,$this->y0,$colwidth["Fullinfo"],$this->maxheight);

$x+=$colwidth["Fullinfo"];

$this->Rect($x,$this->y0,$colwidth["Picture"],$this->maxheight);

$x+=$colwidth["Picture"];

$this->Rect($x,$this->y0,$colwidth["Posted"],$this->maxheight);

$x+=$colwidth["Posted"];

$this->Rect($x,$this->y0,$colwidth["Subcategory"],$this->maxheight);

$x+=$colwidth["Subcategory"];

$this->Rect($x,$this->y0,$colwidth["Title"],$this->maxheight);

$x+=$colwidth["Title"];

$this->maxheight = $this->rowheight;

// draw frame

return true; }

function Header()

120

Page 121: CHAPTER 1

{ global $colwidth,$leftmargin;

//Page header

$this->SetFillColor(192);

$this->SetX($leftmargin);

// $this->Cell($colwidth["Category"],$this->rowheight,"Category",1,0,'C',1);

$this->Cell($colwidth["Category"],$this->rowheight,"Category",1,0,'C',1);

// $this->Cell($colwidth["Details"],$this->rowheight,"Details",1,0,'C',1);

$this->Cell($colwidth["Details"],$this->rowheight,"Details",1,0,'C',1);

// $this->Cell($colwidth["Fullinfo"],$this->rowheight,"Fullinfo",1,0,'C',1);

$this->Cell($colwidth["Fullinfo"],$this->rowheight,"Fullinfo",1,0,'C',1);

// $this->Cell($colwidth["Picture"],$this->rowheight,"Picture",1,0,'C',1);

$this->Cell($colwidth["Picture"],$this->rowheight,"Picture",1,0,'C',1);

// $this->Cell($colwidth["Posted"],$this->rowheight,"Posted",1,0,'C',1);

$this->Cell($colwidth["Posted"],$this->rowheight,"Posted",1,0,'C',1);

// $this->Cell($colwidth["Subcategory"],$this->rowheight,"Subcategory",1,0,'C',1);

$this->Cell($colwidth["Subcategory"],$this->rowheight,"Subcategory",1,0,'C',1);

// $this->Cell($colwidth["Title"],$this->rowheight,"Title",1,0,'C',1);

$this->Cell($colwidth["Title"],$this->rowheight,"Title",1,0,'C',1);

$this->Ln($this->rowheight);

$this->y0=$this->GetY(); }}

$pdf=new PDF();

$leftmargin=5;

$pagewidth=200;

$pageheight=290;

$rowheight=5;

$defwidth=$pagewidth/7;

$colwidth=array();

$colwidth["Category"]=$defwidth;

$colwidth["Details"]=$defwidth;

$colwidth["Fullinfo"]=$defwidth;

$colwidth["Picture"]=$defwidth;

$colwidth["Posted"]=$defwidth;

$colwidth["Subcategory"]=$defwidth;

$colwidth["Title"]=$defwidth;

$pdf->AddFont('CourierNewPSMT','','courcp1252.php');

$pdf->rowheight=$rowheight;

$pdf->SetFont('CourierNewPSMT','',8);

$pdf->AddPage();

$i=0;

while((!$nPageSize || $i<$nPageSize) && $row)

{ $pdf->maxheight=$rowheight;

$x=$leftmargin;

$pdf->SetY($pdf->y0);

$pdf->SetX($x);

if(strlen($row["Category"]))

{ $strdata = make_db_value("Category",$row["Category"]);

$LookupSQL="SELECT ";

$LookupSQL.="`CategoryName`";

$LookupSQL.=" FROM `clcategory` WHERE `CategoryName` = " . $strdata;

LogInfo($LookupSQL);

$rsLookup = db_query($LookupSQL,$conn);

$lookupvalue=$row["Category"];

if($lookuprow=db_fetch_numarray($rsLookup))

$lookupvalue=$lookuprow[0];

$pdf->Cell($colwidth["Category"],$rowheight,GetDataInt($lookupvalue,$row,"Category", ""));

$value = DisplayLookupWizard("Category",$row["Category"],$row,"",MODE_EXPORT);

$pdf->Cell($colwidth["Category"],$rowheight,$value); }

$x+=$colwidth["Category"];

if($pdf->GetY()-$pdf->y0>$pdf->maxheight)

$pdf->maxheight=$pdf->GetY()-$pdf->y0;

121

Page 122: CHAPTER 1

$pdf->SetY($pdf->y0);

$pdf->SetX($x);

$pdf->MultiCell($colwidth["Details"],$rowheight,GetData($row,"Details",""));

$x+=$colwidth["Details"];

if($pdf->GetY()-$pdf->y0>$pdf->maxheight)

$pdf->maxheight=$pdf->GetY()-$pdf->y0;

$pdf->SetY($pdf->y0);

$pdf->SetX($x);

$pdf->MultiCell($colwidth["Fullinfo"],$rowheight,GetData($row,"Fullinfo","HTML"));

$x+=$colwidth["Fullinfo"];

if($pdf->GetY()-$pdf->y0>$pdf->maxheight)

$pdf->maxheight=$pdf->GetY()-$pdf->y0;

$pdf->SetY($pdf->y0);

$pdf->SetX($x);

$height=0;

$pdf->Image(AddLinkPrefix("Picture",$row["Picture"]),$pdf->GetX()+1,$pdf->GetY()+1,$colwidth["Picture"]-2,$height);

$pdf->SetX($pdf->GetX()+$colwidth["Picture"]);

$pdf->SetY($pdf->y0+$height+2);

$x+=$colwidth["Picture"];

if($pdf->GetY()-$pdf->y0>$pdf->maxheight)

$pdf->maxheight=$pdf->GetY()-$pdf->y0;

$pdf->SetY($pdf->y0);

$pdf->SetX($x);

$pdf->MultiCell($colwidth["Posted"],$rowheight,GetData($row,"Posted","Long Date"));

$x+=$colwidth["Posted"];

if($pdf->GetY()-$pdf->y0>$pdf->maxheight)

$pdf->maxheight=$pdf->GetY()-$pdf->y0;

$pdf->SetY($pdf->y0);

$pdf->SetX($x);

if(strlen($row["Subcategory"]))

{ $strdata = make_db_value("Subcategory",$row["Subcategory"]);

$LookupSQL="SELECT ";

$LookupSQL.="`SubcategoryName`";

$LookupSQL.=" FROM `clsubcategory` WHERE `SubcategoryName` = " . $strdata;

LogInfo($LookupSQL);

$rsLookup = db_query($LookupSQL,$conn);

$lookupvalue=$row["Subcategory"];

if($lookuprow=db_fetch_numarray($rsLookup))

$lookupvalue=$lookuprow[0];

$pdf->Cell($colwidth["Subcategory"],$rowheight,GetDataInt($lookupvalue,$row,"Subcategory", ""));

$value = DisplayLookupWizard("Subcategory",$row["Subcategory"],$row,"",MODE_EXPORT);

$pdf->Cell($colwidth["Subcategory"],$rowheight,$value); }

$x+=$colwidth["Subcategory"];

if($pdf->GetY()-$pdf->y0>$pdf->maxheight)

$pdf->maxheight=$pdf->GetY()-$pdf->y0;

$pdf->SetY($pdf->y0);

$pdf->SetX($x);

$pdf->MultiCell($colwidth["Title"],$rowheight,GetData($row,"Title",""));

$x+=$colwidth["Title"];

if($pdf->GetY()-$pdf->y0>$pdf->maxheight)

$pdf->maxheight=$pdf->GetY()-$pdf->y0;

// draw fames

$x=$leftmargin;

$pdf->Rect($x,$pdf->y0,$colwidth["Category"],$pdf->maxheight);

$x+=$colwidth["Category"];

$pdf->Rect($x,$pdf->y0,$colwidth["Details"],$pdf->maxheight);

$x+=$colwidth["Details"];

$pdf->Rect($x,$pdf->y0,$colwidth["Fullinfo"],$pdf->maxheight);

$x+=$colwidth["Fullinfo"];

$pdf->Rect($x,$pdf->y0,$colwidth["Picture"],$pdf->maxheight);

122

Page 123: CHAPTER 1

$x+=$colwidth["Picture"];

$pdf->Rect($x,$pdf->y0,$colwidth["Posted"],$pdf->maxheight);

$x+=$colwidth["Posted"];

$pdf->Rect($x,$pdf->y0,$colwidth["Subcategory"],$pdf->maxheight);

$x+=$colwidth["Subcategory"];

$pdf->Rect($x,$pdf->y0,$colwidth["Title"],$pdf->maxheight);

$x+=$colwidth["Title"];

$pdf->y0+=$pdf->maxheight;

$i++;

$row=db_fetch_array($rs); }

$pdf->Output(); }

?>

MORE DETAILS PAGE

var detailspreview_included=true;

function preview_inline(link)

{ var tparents=$(link).parents("tr");

if(!tparents.length)

return;

var i;

for(i=0;i<tparents.length;i++)

if($(tparents[i]).attr("rowid"))

break;

if(i==tparents.length)

return;

var tr=tparents[i];

var rowid=$(tr).attr("rowid");

var pos = link.id.lastIndexOf("_preview");

if(pos<0)

return;

var recid = new Number(link.id.substring(pos+8));

var dtable=link.id.substring(0,pos);

var previewtr=document.getElementById("dpreviewrow_"+rowid);

if(!previewtr)

{ var tchildren=$(tr).children("td");

varcolscount= new Array();

var start=0;

tparents=$(link).parents("td");

if(!tparents.length)

return;

var tdparent=tparents[0];

var myplace=0;

for(i=0;i<tchildren.length;i++)

{ if(tdparent==tchildren[i])

myplace=varcolscount.length;

if($(tchildren[i]).attr("colid")=="endrecord")

{ varcolscount[varcolscount.length]=i-start;

start=i+1; }}

varcolscount[varcolscount.length]=i-start;

// create new TR

previewtr=$(tr).clone();

$(previewtr).attr("id","dpreviewrow_"+rowid);

$(previewtr).insertAfter(tr);

previewtr=document.getElementById("dpreviewrow_"+rowid);

// remove all unnecessary TDs

$("td[@colid!=endrecord]",previewtr).remove();

// fill row with new TDs

tchildren=$(previewtr).children("td");

for(i=0;i<tchildren.length;i++)

{ $(tchildren[i]).before("<td id=\"dpreview_"+(recid+i-myplace)+"\" colspan="+varcolscount[i]+"></td>"); }

123

Page 124: CHAPTER 1

if(i)

$(tchildren[i-1]).after("<td id=\"dpreview_"+(recid+i-myplace)+"\" colspan="+varcolscount[i]+"></td>");

else

$(previewtr).html("<td id=\"dpreview_"+(recid+i-myplace)+"\" colspan="+varcolscount[i]+"></td>"); }

// get details page contents

var tdpreview = document.getElementById("dpreview_"+recid);

if(!tdpreview)

return;

pos = link.href.indexOf("?");

if(pos<0)

return;

var url=dtable+"_detailspreview.php"+link.href.substr(pos);

tdpreview.style.borderWidth="1px";

tdpreview.style.borderStyle="solid";

tdpreview.style.borderColor="darkgray";

if(!tdpreview.innerHTML.length)

$(tdpreview).html(TEXT_LOADING + "...");

// change other links to "preview"

$("[@id$=_preview"+recid+"]").each(function (){

this.innerHTML=TEXT_PREVIEW;

this.onclick=function() {preview_inline(this); return false;}; });

$.get(url,

{ counter: 0,

mode: "inline",

rndVal: (new Date().getTime()) },

function(txt){

$(tdpreview).html(txt);

$(link).html(TEXT_HIDE);

link.onclick=function() {hide_inline(link); return false;}; }); }

function hide_inline(link)

{ $(link).html(TEXT_PREVIEW);

link.onclick=function() {preview_inline(link); return false;};

// determine record id

var pos = link.id.lastIndexOf("_preview");

if(pos<0)

return;

var recid = new Number(link.id.substring(pos+8));

var dtable=link.id.substring(0,pos);

var tdpreview = document.getElementById("dpreview_"+recid);

if(!tdpreview)

return;

tdpreview.innerHTML="";

tdpreview.style.borderStyle="none";

// check if whole row can be removed

var tparents=$(tdpreview).parents("tr");

if(!tparents.length)

return;

var previewtr=tparents[0];

var tchildren=$(previewtr).children("td");

for(i=0;i<tchildren.length;i++)

if($(tchildren[i]).attr("colid")!="endrecord" && tchildren[i].innerHTML.length)

break;

if(i<tchildren.length)

return;

$(previewtr).remove(); }

</?

VIEW ALL MARKET PAGE

<?php

function grabDates($start,$end,$category_array) {

124

Page 125: CHAPTER 1

$cats = implode(",",$category_array);

global $table_prefix, $supergroup;

global $title, $niceday, $start_time, $end_time, $venue, $city, $state, $cat,$ed, $usr, $color, $background,$lang, $w, $ap, $status;

$superedit = false;

if (!$supergroup) {

$q = "select moderate from ".$table_prefix."users_to_groups where group_id = ".$w." and user_id = ".$_SESSION["user_id"];

$query = mysql_query($q);

if (mysql_num_rows($query) > 0) {

$mod = mysql_result($query,0,0);

if ($mod > 2) {

$superedit = true; }}

} else { $superedit = true; }

if (($mod > 0) || ($superedit)) {

$q = "select DATE_FORMAT(".$table_prefix."dates.date, '%Y%m%d'), DATE_FORMAT(".$table_prefix."dates.date, '%H%i'), ".

$table_prefix."events.event_id, ".$table_prefix."events.title, DATE_FORMAT(".$table_prefix."dates.date, '%W, %M %e, %Y'), DATE_FORMAT(".

$table_prefix."dates.date, '%l:%i %p'), DATE_FORMAT(".$table_prefix."dates.end_date, '%l:%i %p'), ".$table_prefix."links.company, ".

$table_prefix."links.city, ".$table_prefix."links.state, ".$table_prefix."events.category_id, ".$table_prefix."events.user_id, ".$table_prefix."dates.date, ".

$table_prefix."categories.color, ".$table_prefix."categories.background, ".$table_prefix."events.status_id from ".$table_prefix."events, ".$table_prefix."dates, ".

$table_prefix."links, ".$table_prefix."categories, ".$table_prefix."groups where ".$table_prefix."dates.date >= '$start' and ".$table_prefix."dates.date < '$end' and

".$table_prefix."dates.event_id = ".$table_prefix."events.event_id and ".$table_prefix."events.venue_id = ".$table_prefix."links.link_id and ".

$table_prefix."events.category_id in (".$cats.") and ".$table_prefix."events.category_id = ".$table_prefix."categories.category_id and ".

$table_prefix."events.group_id = ".$table_prefix."groups.group_id and ".$table_prefix."events.group_id = ".$w." order by ".$table_prefix."dates.date";

$query = mysql_query($q);

//echo $q."<br>";

while ($row = mysql_fetch_row($query)) {

$edit = false;

if ($row[11] == $_SESSION["user_id"]) {

$edit = true;

} elseif ($superedit) {

$edit = true; }

if ($edit==true) $ed[$row[2]]=true;

if ($superedit==true) $ap[$row[2]]=true;

$title[$row[2]]=strip_tags($row[3]);

$niceday[$row[0]][$row[12]][$row[2]]=$row[4];

if (($row[5] == "12:00 AM") && ($row[6] == "11:59 PM")) {

$start_time[$row[0]][$row[12]][$row[2]]=$lang["all_day"];

} elseif (($row[5] == "12:00 AM") && ($row[6] == "12:00 AM")) {

$start_time[$row[0]][$row[12]][$row[2]]=$lang["tba"];

} else { $start_time[$row[0]][$row[12]][$row[2]]=$row[5];

if ($row[6]) $end_time[$row[0]][$row[12]][$row[2]]=$row[6]; }

if ($row[7]) $venue[$row[2]]=$row[7];

if ($row[7] && $row[8]) $city[$row[2]]=$row[8];

if ($row[7] && $row[8] && $row[9]) $state[$row[2]]=$row[9];

$cat[$row[2]]=$row[10];

$usr[$row[2]]=$row[11];

$color[$row[2]]=$row[13];

$background[$row[2]]=$row[14];

$status[$row[2]]=$row[15]; }}}

function grab($start,$end,$category) {

global $include_child_categories, $include_parent_categories, $category_array,$supercategory,$supergroup,$category_permissions,$w,$table_prefix;

$canview = false;

$groupview = false;

if (!$supergroup) {

$q = "SELECT * from ".$table_prefix."users_to_groups where group_id = ".$w." and user_id = ".$_SESSION["user_id"];

$query = mysql_query($q);

if (mysql_num_rows($query) > 0) $groupview = true;

} else { $groupview = true; }

if ($groupview) { if (!$supercategory) {

//build permission array

$q = "SELECT category_id from ".$table_prefix."users_to_categories where user_id = ".$_SESSION["user_id"];

125

Page 126: CHAPTER 1

//echo $q."<br>";

$query = mysql_query($q);

if (mysql_num_rows($query) > 0) {

while ($row = mysql_fetch_row($query)) {

$category_permissions[] = $row[0]; }}

if (in_array($category,$category_permissions)) $canview = true;

} else { $canview = true; }

if ($canview) { $category_array[] = $category;

if ($include_child_categories) grab_child($start,$end,$category,true);

if ($include_parent_categories) grab_parent($start,$end,$category,true);

grabDates($start,$end,$category_array); }}}

function grab_child($start,$end,$category,$starter=false) {

global $table_prefix, $category_array,$supercategory,$category_permissions;

$canview = false;

if (!$supercategory) {if ($category_permissions) { if (in_array($category,$category_permissions)) $canview = true; }

} else {$canview = true;}

if ($canview) {

if (!$starter) $category_array[] = $category;

$q = "select category_id from ".$table_prefix."categories where sub_of = ".$category;

//echo $q."<br>";

$query = mysql_query($q);

if (!$query) $msg = "Database Error : ".$q;

else {

while ($row = mysql_fetch_row($query)) {

grab_child($start,$end,$row[0],false); } } } }

function grab_parent($start,$end,$category,$starter=false) {

global $table_prefix, $category_array, $supercategory,$category_permissions;

$canview = false;

if (!$supercategory) {

if ($category_permissions) {

if (in_array($category,$category_permissions)) $canview = true; }

} else {$canview = true;}

if ($canview) {if (!$starter) $category_array[] = $category;

$q = "select sub_of from ".$table_prefix."categories where category_id = ".$category;

//echo $q."<br>";

$query = mysql_query($q);

if (!$query) $msg = "Database Error : ".$q;

else {while ($row = mysql_fetch_row($query)) {

grab_parent($start,$end,$row[0],false); } } } }

include "includes/start.php";

$canview = false;

if (!$superview) {

mysql_close($link);

$msg = $lang["must_log_in"];

header("Location: login.php?msg=".$msg."&".$common_get); }

if (($supergroup) && ($supercategory)) {

$canview = true;

} else { if (!$supercategory) { $canview = false;

$q = "select * from ".$table_prefix."users_to_categories where category_id = ".$c." and user_id = ".$_SESSION["user_id"];

//echo $q;

$qu = mysql_query($q);

if (mysql_num_rows($qu) > 0) {

$canview = true;

} else { $msg .= "<p>".$lang["no_permission_to_view_category"]."</p>";

$canview = false; } }

if ((!$supergroup) && $canview) {

$q = "select * from ".$table_prefix."users_to_groups where group_id = ".$w." and user_id = ".$_SESSION["user_id"];

//echo $q;

$qu = mysql_query($q);

if (mysql_num_rows($qu) > 0) {

126

Page 127: CHAPTER 1

$canview = true;

} else { $msg .= "<p>".$lang["no_permission_to_view_group"]."</p>";

$canview = false; } } }

if (($canview == true)&& $script) {

include "modules/".$script;

} else { include "includes/header.php";

include "includes/footer.php"; }

?>

VEIW MARKET DATES

<? php

include "includes/start.php";

$page_title = $lang["title_event"];

if ((!$_REQUEST["id"]) or (!ctype_digit($_REQUEST["id"]))) {

echo "<p class=\"warning\">".$lang["no_event_selected"]."</p>\n";

} else {

$q = "SELECT * from ".$table_prefix."events where event_id =".$_REQUEST["id"];

$query = mysql_query($q);

if (mysql_num_rows($query) < 1) {

echo "<p class=\"warning\">".$lang["event_not_found"]."</p>\n";

} else {

$row = mysql_fetch_array($query);

if (!$query) echo "<p class=\"warning\">Database Error : ".$q."</p>\n";

$q = "SELECT DATE_FORMAT(date, '%W, %M %e, %Y'), DATE_FORMAT(date,' - %l:%i %p'), DATE_FORMAT(end_date, ' - %l:%i %p') from ".

$table_prefix."dates where event_id =".$_REQUEST["id"]." order by date";

$squery = mysql_query($q);

if (!$squery) echo "<p class=\"warning\">Database Error : ".$q."</p>\n";

else {

while ($srow = mysql_fetch_row($squery)) {

if (($srow[1] == " - 12:00 AM") && ($srow[2] == " - 11:59 PM")) $nicedate[] = $srow[0]." - ".$lang["all_day"];

elseif (($srow[1] == " - 12:00 AM") && ($srow[2] == " - 12:00 AM")) $nicedate[] = $srow[0]." - ".$lang["tba"];

elseif ($srow[2]) $nicedate[] = $srow[0].$srow[1].$srow[2];

else $nicedate[] = $srow[0].$srow[1]; } }

$page_title = $row["title"];

$category_id = $row["category_id"];

$venue_id = $row["venue_id"];

$contact_id = $row["contact_id"];

$description = $row["description"]; } }

if ($_REQUEST["size"] == "small") $javascript = "<base target=\"_blank\">\n";

include "includes/header.php";

?>

<?php

echo $lang["category"].": \n";

$cate = mysql_result(mysql_query("select name from ".$table_prefix."categories where category_id = ".$category_id),0,0);

echo "<strong>".$cate."</strong><br />\n";

if ($venue_id > 1) {

$q = "select url, company, description, address1, address2, city, state, zip, phone, fax FROM ".$table_prefix."links where link_id = ".$venue_id;

$lq = mysql_query($q);

echo $lang["venue"].": \n";

$li = mysql_fetch_row($lq);

if ($li[0]) {

echo "<strong><a href=\"".$li[0]."\">".$li[1]."</a></strong>";

} else {

echo "<strong>".$li[1]."</strong>";}

if ($li[3]) echo ", ".$li[3];

if ($li[4]) echo ", ".$li[4];

if ($li[5]) echo ", ".$li[5].", ".$li[6]." ".$li[7];

if ($li[8]) echo ", ".$lang["phone"].": ".$li[8];

if ($li[9])echo ", ".$lang["fax"].": ".$li[9];

echo "<br />\n";}

127

Page 128: CHAPTER 1

if ($contact_id > 1) {

$q = "select url, company, description, address1, address2, city, state, zip, phone, fax FROM ".$table_prefix."links where link_id = ".$contact_id;

$lq = mysql_query($q);

echo $lang["contact_sponsor"].": \n";

$li = mysql_fetch_row($lq);

if ($li[0]) {

echo "<strong><a href=\"".$li[0]."\">".$li[1]."</a></strong>";

} else {

echo "<strong>".$li[1]."</strong>";}

if ($li[3]) echo ", ".$li[3];

if ($li[4]) echo ", ".$li[4];

if ($li[5]) echo ", ".$li[5].", ".$li[6]." ".$li[7];

if ($li[8]) echo ", ".$lang["phone"].": ".$li[8];

if ($li[9])echo ", ".$lang["fax"].": ".$li[9];

echo "<br />\n";}

if ($nicedate[1]) {

echo $lang["dates"].":<ul>\n";

while (list($k,$v) = each($nicedate)) {

echo "<strong><li>".$v."</li></strong>\n";}

echo "</ul>\n";

} elseif ($nicedate[0]) {

echo $lang["date"].": <strong>".$nicedate[0]."</strong><br />";}

echo "<p>".$description."</p>\n";

include "includes/footer.php";

?>

ADD MARKET PAGE

<?php

Var cal = new CalendarPopup("testdiv1");

cal.offsetX=-20;

cal.offsetY=20;

var testpopup5 = new PopupWindow("timelayer");

testpopup5.offsetX=-20;

testpopup5.offsetY=20;

testpopup5.autoHide();

var testpopup5input=null;

function test5popupactivate(obj,anchor) {

testpopup5input=obj;

testpopup5.showPopup(anchor); }

function testpopup5pick(val) {

testpopup5input.value = val;

testpopup5.hidePopup(); }

function null_out(t,i) {

if ((t.value == "all") || (t.value == "tba")){

eval("t.form.start_time_" + i +".disabled=true");

eval("t.form.end_time_" + i +".disabled=true");

eval("t.form.start_time_" + i +".value=\'12:00 am\'");

if (t.value == "all") {

eval("t.form.end_time_" + i +".value=\'11:59 pm\'");

} else {

eval("t.form.end_time_" + i +".value=\'12:00 am\'"); }

eval("turn_off(\'anchor_time_start_" + i +"\')");

eval("turn_off(\'anchor_time_end_" + i +"\')");

} else {

eval("t.form.start_time_" + i +".disabled=false");

eval("t.form.end_time_" + i +".disabled=false");

eval("turn_on(\'anchor_time_start_" + i +"\')");

eval("turn_on(\'anchor_time_end_" + i +"\')"); } }

function turn_on(whichLayer) {

if (document.getElementById) {

128

Page 129: CHAPTER 1

var style2 = document.getElementById(whichLayer).style;

style2.visibility = "visible";

} else if (document.all) {

// this is the way old msie versions work

var style2 = document.all[whichLayer].style;

style2.visibility = "visible";

} else if (document.layers) {

// this is the way nn4 works

var style2 = document.layers[whichLayer].style;

style2.visibility = "show"; } }

function turn_off(whichLayer) {

if (document.getElementById) {

// this is the way the standards work

var style2 = document.getElementById(whichLayer).style;

style2.visibility = "hidden";

} else if (document.all) {

include "includes/start.php";

$page_title = $lang["title_add_event"];

function category_tree($category_id) {

global $table_prefix, $indent, $supercategory, $scategory;

$q = "SELECT category_id, name from ".$table_prefix."categories where sub_of = ".$category_id." order by name";

$query = mysql_query($q);

if (!$query) echo "Database Error : ".$q;

else { while ($row=mysql_fetch_row($query)) {

$mod = 0;

if (!$supercategory) {

$q = "select moderate from ".$table_prefix."users_to_categories where category_id = ".$row[0]." and user_id = ".$_SESSION["user_id"];

$qu = mysql_query($q);

if (mysql_num_rows($qu) > 0) $mod = mysql_result($qu,0,0);

} else {

$mod = 3;}

if ($mod > 0) {

echo "<option value=\"".$row[0]."\"";

if($mod < 2) echo " disabled";

if ($scategory == $row[0]) echo " SELECTED";

echo ">".$indent.$row[1]."</option>\n";}

$indent .= "__";

category_tree($row[0]);

$indent = substr($indent, 2); }}}

function group_tree($group_id) {

global $table_prefix, $indent, $supergroup, $sgroup;

$q = "SELECT group_id, name from ".$table_prefix."groups where sub_of = ".$group_id." order by name";

$query = mysql_query($q);

if (!$query) echo "Database Error : ".$q;

else {

while ($row=mysql_fetch_row($query)) {

$mod = 0;

if (!$supergroup) {

$q = "select moderate from ".$table_prefix."users_to_groups where group_id = ".$row[0]." and user_id = ".$_SESSION["user_id"];

$qu = mysql_query($q);

if (mysql_num_rows($qu) > 0) $mod = mysql_result($qu,0,0);

} else {

$mod = 3;}

if ($mod > 0) {

echo "<option value=\"".$row[0]."\"";

if($mod < 2) echo " disabled";

if ($sgroup == $row[0]) echo " SELECTED";

echo ">".$indent.$row[1]."</option>\n";}

$indent .= "__";

group_tree($row[0]);

129

Page 130: CHAPTER 1

$indent = substr($indent, 2);}}}

function select_place($field) {

global $table_prefix, $indent;

$q = "SELECT link_id, state, city, company from ".$table_prefix."links where link_id > 1 order by state, city, company";

$query = mysql_query($q);

if (!$query) echo "Database Error : ".$q;

else { while ($row=mysql_fetch_row($query)) {

echo "<option value=\"".$row[0]."\"";

if ($field) {

if ($field == $row[0]) echo " SELECTED";}

echo ">";

if ($row[1]) echo $row[1]." : ";

if ($row[2]) echo $row[2]." : ";

echo $row[3]."</option>\n"; } } }

header("Location: ".$path."login.php?return_to=".$PHP_SELF);

} elseif (!$superpost) {

include "includes/header.php";

echo "<p class=\"warning\">".$lang["not_authorized_events"]."</p>\n";

} else {

if ($_POST["mode"] == $lang["add_event"]) {

if(get_magic_quotes_gpc()) {

$title = mysql_real_escape_string(stripslashes($_POST["title"]));

$link_id = mysql_real_escape_string(stripslashes($_POST["venue"]));

$contact_id = mysql_real_escape_string(stripslashes($_POST["contact"]));

$description = mysql_real_escape_string(stripslashes($_POST["description"]));

$category_id = mysql_real_escape_string(stripslashes($_POST["category"]));

$group_id = mysql_real_escape_string(stripslashes($_POST["group"]));

$propose = mysql_real_escape_string(stripslashes($_POST["propose"]));

} else {

$title = mysql_real_escape_string($_POST["title"]);

$link_id = mysql_real_escape_string($_POST["venue"]);

$contact_id = mysql_real_escape_string($_POST["contact"]);

$description = mysql_real_escape_string($_POST["description"]);

$category_id = mysql_real_escape_string($_POST["category"]);

$group_id = mysql_real_escape_string($_POST["group"]);

$propose = mysql_real_escape_string($_POST["propose"]);}

if (!$supergroup) {

if ($group_id) {

$q = "select moderate from ".$table_prefix."users_to_groups where group_id = ".$group_id." and user_id = ".$_SESSION["user_id"];

//echo $q."<br>";

$gmod = mysql_result(mysql_query($q),0,0);

if ($gmod < 2) {

header("Location: ".$path."add_event.php?msg=".$lang["not_authorized_events_group"]."&size=".$_REQUEST["size"]);

} else {

if ($gmod == 2) $propose = "propose";}

} else {

header("Location: ".$path."add_event.php?msg=".$lang["not_authorized_events_group"]."&size=".$_REQUEST["size"]); }}

if (!$supercategory) {

$q = "select moderate from ".$table_prefix."users_to_categories where category_id = ".$category_id." and user_id = ".$_SESSION["user_id"];

$mod = mysql_result(mysql_query($q),0,0);

if ($mod < 2) {

header("Location: ".$path."add_event.php?msg=".$lang["not_authorized_events_category"]."&size=".$_REQUEST["size"]); }}

if ($propose == "propose") $status_id = 2;

else $status_id = 1;

$sauce = md5(time());

$q = "INSERT into ".$table_prefix."events (title, venue_id, contact_id, description, category_id, user_id, group_id, status_id, quick_approve) values ('".$title."',

".$link_id.", ".$contact_id.", '".$description."', ".$category_id.", ".$_SESSION["user_id"].", ".$group_id.", ".$status_id.", '".$sauce."')";

$query = mysql_query($q);

$event_id = mysql_insert_id();

if (!$query) $msg .= "Database Error : ".$q;

130

Page 131: CHAPTER 1

else {

$j = 0;

while ($_POST["date_".$j]) {

if (!$_POST["delete_".$j]) {

if ($_POST["all_day_".$j] == "all") {

$_POST["start_time_".$j] = "12:00 am";

$_POST["end_time_".$j] = "11:59 pm";

} else if ($_POST["all_day_".$j] == "tba") {

$_POST["start_time_".$j] = "12:00 am";

$_POST["end_time_".$j] = "12:00 am";}

if (!ereg ("([0-9]{1,2})[\/-]+([0-9]{1,2})[\/-]+([0-9]{4})",$_POST["date_".$j],$date)) {

$msg .= "Bad Date:".$_POST["date_".$j];

} else {

if (!eregi ("([0-9]{1,2}):([0-9]{2})[ ]?([a|p]m)",$_POST["start_time_".$j],$start_time)) {

$msg .= "Bad Start Time:".$_POST["start_time_".$j];

} else {

if (($_POST["end_time_".$j])&&(!eregi ("([0-9]{1,2}):([0-9]{2})[ ]?([a|p]m)",$_POST["end_time_".$j],$end_time))) {

$msg .= "Bad End Time:".$_POST["end_time_".$j];

} else {

if (strlen($date[1]) == 1) $date[1] = "0".$date[1];

if (strlen($date[2]) == 1) $date[2] = "0".$date[2];

if ((eregi("am",$start_time[3])) && ($start_time[1] == 12)) $start_time[1] = $start_time[1] - 12;

if ((eregi("am",$end_time[3])) && ($end_time[1] == 12)) $end_time[1] = $end_time[1] - 12;

if ((eregi("pm",$start_time[3])) && ($start_time[1] < 12)) $start_time[1] = $start_time[1] + 12;

if ((eregi("pm",$end_time[3])) && ($end_time[1] < 12)) $end_time[1] = $end_time[1] + 12;

if (strlen($start_time[1]) == 1) $start_time[1] = "0".$start_time[1];

if (strlen($end_time[1]) == 1) $end_time[1] = "0".$end_time[1];

$start_date = $date[3]."-".$date[1]."-".$date[2]." ".$start_time[1].":".$start_time[2];

if ($_POST["end_time_".$j]) {

$end_date = $date[3]."-".$date[1]."-".$date[2]." ".$end_time[1].":".$end_time[2];

if (($end_time[1].$end_time[2]) >= ($start_time[1].$start_time[2])) {

$q = "INSERT into ".$table_prefix."dates (event_id, date, end_date) values (".$event_id.", '".$start_date."', '".$end_date."')";

} else {

$q = "INSERT into ".$table_prefix."dates (event_id, date) values (".$event_id.", '".$start_date."')";}

} else {

$q = "INSERT into ".$table_prefix."dates (event_id, date) values (".$event_id.", '".$start_date."')";}

$query = mysql_query($q);

if (!$query) $msg .= "Database Error : ".$q; }}}}

$j++;}

if ($_POST["date_add"]) {

if ($_POST["all_day_add"] == "all") {

$_POST["start_time_add"] = "12:00 am";

$_POST["end_time_add"] = "11:59 pm";

} else if ($_POST["all_day_add"] == "tba") {

$_POST["start_time_add"] = "12:00 am";

$_POST["end_time_add"] = "12:00 am";}

if (!ereg ("([0-9]{1,2})[\/-]+([0-9]{1,2})[\/-]+([0-9]{4})",$_POST["date_add"],$date)) {

$msg .= "Bad Date:".$_POST["date_add"];

} else {

if (!eregi ("([0-9]{1,2}):([0-9]{2})[ ]?([a|p]m)",$_POST["start_time_add"],$start_time)) {

$msg .= "Bad Start Time:".$_POST["start_time_add"];

} else {

if (($_POST["end_time_add"])&&(!eregi ("([0-9]{1,2}):([0-9]{2})[ ]?([a|p]m)",$_POST["end_time_add"],$end_time))) {

$msg .= "Bad End Time:".$_POST["end_time_add"];

} else {

if (strlen($date[1]) == 1) $date[1] = "0".$date[1];

if (strlen($date[2]) == 1) $date[2] = "0".$date[2];

if ((eregi("am",$start_time[3])) && ($start_time[1] == 12)) $start_time[1] = $start_time[1] - 12;

if ((eregi("am",$end_time[3])) && ($end_time[1] == 12)) $end_time[1] = $end_time[1] - 12;

if ((eregi("pm",$start_time[3])) && ($start_time[1] < 12)) $start_time[1] = $start_time[1] + 12;

131

Page 132: CHAPTER 1

if ((eregi("pm",$end_time[3])) && ($end_time[1] < 12)) $end_time[1] = $end_time[1] + 12;

if (strlen($start_time[1]) == 1) $start_time[1] = "0".$start_time[1];

if (strlen($end_time[1]) == 1) $end_time[1] = "0".$end_time[1];

$start_date = $date[3]."-".$date[1]."-".$date[2]." ".$start_time[1].":".$start_time[2];

//loop through recurring events

$juno = 0;

$r = $_POST["recurring"];

if (!$r) $r = 0;

$int = $_POST["interval"];

while ($juno <= $r) {

$next = $juno * $int;

if ($_POST["end_time_add"]) {

$end_date = $date[3]."-".$date[1]."-".$date[2]." ".$end_time[1].":".$end_time[2];

if (($end_time[1].$end_time[2]) >= ($start_time[1].$start_time[2])) {

$q = "INSERT into ".$table_prefix."dates (event_id, date, end_date) values (".$event_id.", DATE_ADD('".$start_date."', INTERVAL ".$next." DAY),

DATE_ADD('".$end_date."', INTERVAL ".$next." DAY))";

} else {

$q = "INSERT into ".$table_prefix."dates (event_id, date) values (".$event_id.", DATE_ADD('".$start_date."', INTERVAL ".$next." DAY))";

}

} else {

$q = "INSERT into ".$table_prefix."dates (event_id, date) values (".$event_id.", DATE_ADD('".$start_date."', INTERVAL ".$next." DAY))";}

$query = mysql_query($q);

if (!$query) $msg .= "Database Error : ".$q;

$juno++; }}}}}

if ($_POST["notify"]) {

include "includes/notify.php";

notify_group($event_id); }

$msg .= $lang["event_added"];

unset($_POST);

$javascript .= "\n<script language=\"JavaScript\" type=\"text/javascript\">\n<!--\nopener.location.reload(true);\n// -->\n</script>\n"; }}

include "includes/header.php";

$scategory = $_POST["category"] ? $_POST["category"] : $c;

$sgroup = $_POST["group"] ? $_POST["group"] : $w;

?>

<form action="add_event.php" id="event" name="event" method="post">

<?php include "includes/hidden_fields.php"; ?>

<input type="hidden" name="size" value="<?php echo $_REQUEST["size"]; ?>">

<table>

<tr> <td><?php echo $lang["title"];?>:</td>

<td><input type="text" name="title" id="title" value="<?php echo $_POST["title"]; ?>" size="40"></td>

</tr> <tr> <td><?php echo $lang["group"];?>:</td>

<td> <select name="group" id="group">

<?php group_tree(0); ?>

</select> <select name="propose" id="propose"><option value="post"<? if ($_POST["propose"] == "post") echo " selected"; ?>><?php echo $lang["post"];?

></option><option value="propose"<? if ($_POST["propose"] == "propose") echo " selected"; ?>><?php echo $lang["propose"];?></option></select>

<input type="checkbox" name="notify" value="1"<? if ($_POST["notify"]) echo " checked"; ?>> <?php echo $lang["notify subscribers"];?>

</td> </tr>

<tr> <td> <?php echo $lang["category"];?>:</td>

<td> <select name="category" id="category">

<?php category_tree(0); ?>

</select> </td> </tr>

<tr> <td> <?php echo $lang["venue"];?>:</td>

<td> <select name="venue" id="venue" size="1">

<option value="1"><?php echo $lang["in_main_description"];?></option>

<?php select_place($_POST["venue"]); ?>

</select>

</td> </tr>

<tr> <td><?php echo $lang["contact_sponsor"];?>:</td>

<td> <select name="contact" id="contact" size="1">

<option value="1"><?php echo $lang["none"];?></option>

132

Page 133: CHAPTER 1

<?php select_place($_POST["contact"]); ?>

</select> </td> </tr> </table>

<?php echo $lang["dates"];?>:

<table> <tr> <th><?php echo $lang["delete?"];?></th>

<th><?php echo $lang["date"];?></th><th><?php echo $lang["all_day"];?> / <?php echo $lang["tba"];?> / <?php echo $lang["enter_time"];?></th><th><?php

echo $lang["start_time"];?></th>

<th><?php echo $lang["end_time"];?></th>

</tr>

<?php

$j = 0;

while ($_REQUEST["date_".$j]) {

if (!$_REQUEST["delete_".$j]) {

$disabled = "";

$hidden = "";

$checked= "";

$checked_tba= "";

$checked_enter= " checked";

if ($_REQUEST["all_day_".$j] == "all") {

$_REQUEST["start_time_".$j] = "12:00 am";

$_REQUEST["end_time_".$j] = "11:59 pm";

$disabled = " disabled";

$hidden = " style=\"visibility: hidden;\"";

$checked= " checked";

$checked_enter= "";

} elseif (($_REQUEST["start_time_".$j] == "12:00 am") && ($_REQUEST["end_time_".$j] == "11:59 pm")) {

$disabled = " disabled";

$hidden = " style=\"visibility: hidden;\"";

$checked= " checked";

$checked_enter= "";

} elseif ($_REQUEST["all_day_".$j] == "tba") {

$_POST["start_time_".$j] = "12:00 am";

$_POST["end_time_".$j] = "12:00 am";

$disabled = " disabled";

$hidden = " style=\"visibility: hidden;\"";

$checked_tba = " checked";

$checked_enter= "";

} elseif (($_REQUEST["start_time_".$j] == "12:00 am") && ($_REQUEST["end_time_".$j] == "12:00 am")) {

$disabled = " disabled";

$hidden = " style=\"visibility: hidden;\"";

$checked_tba= " checked";

$checked_enter= ""; }

?>

<tr> <td><input type="checkbox" name="delete_<?php echo $i; ?>" id="delete_<?php echo $i; ?>" value="yes" /></td>

<td><input type="text" name="date_<?php echo $i; ?>" id="date_<?php echo $i; ?>" value="<?php echo $_REQUEST["date_".$j]; ?>"size="10"> <a href="#"

onclick="cal.select(document.event.date_<?php echo $i; ?>,this.name,'MM/dd/yyyy'); return false;" NAME="anchor_date_<?php echo $i; ?>"

ID="anchor_date_<?php echo $i; ?>"><img src="images/calendar.png" border="0" /></a></td>

<td><input type="radio" onClick="null_out(this,<?php echo $i; ?>);" name="all_day_<?php echo $i; ?>" id="all_day_<?php echo $i; ?>" value="all"<?php

echo $checked; ?>/> / <input type="radio" onClick="null_out(this,<?php echo $i; ?>);" name="all_day_<?php echo $i; ?>" id="all_day_<?php echo $i; ?>"

value="tba"<?php echo $checked_tba; ?>/> / <input type="radio" onClick="null_out(this,<?php echo $i; ?>);" name="all_day_<?php echo $i; ?>"

id="all_day_<?php echo $i; ?>" value=""<?php echo $checked_enter; ?>/></td>

<td><input type="text" name="start_time_<?php echo $i; ?>" id="start_time_<?php echo $i; ?>" value="<?php echo $_REQUEST["start_time_".$j]; ?>"

size="10"<?php echo $disabled; ?>/> <a href="#" onclick="test5popupactivate(document.event.start_time_<?php echo $i; ?>,this.name);return false;"

NAME="anchor_time_start_<?php echo $i; ?>" ID="anchor_time_start_<?php echo $i; ?>"<?php echo $hidden; ?>><img src="images/time.png" border="0"

/></a></td>

<td><input type="text" name="end_time_<?php echo $i; ?>" id="end_time_<?php echo $i; ?>" value="<?php echo $_REQUEST["end_time_".$j]; ?>"

size="10"<?php echo $disabled; ?>/> <a href="#" onclick="test5popupactivate(document.event.end_time_0,this.name);return false;"

NAME="anchor_time_end_<?php echo $i; ?>" ID="anchor_time_end_<?php echo $i; ?>"<?php echo $hidden; ?>><img src="images/time.png" border="0"

/></a></td>

</tr>

<?php

133

Page 134: CHAPTER 1

$i++; }

$j++; }

if ($_POST["date_add"]) {

$disabled = "";

$hidden = "";

$checked= "";

$checked_tba= "";

$checked_enter= " checked";

if ($_POST["all_day_add"]) {

$_POST["start_time_add"] = "12:00 am";

$_POST["end_time_add"] = "11:59 pm";

$disabled = " disabled";

$hidden = " style=\"visibility: hidden;\"";

$checked= " checked";

$checked_enter= "";

} elseif (($_POST["start_time_add"] == "12:00 am") && ($_POST["end_time_add"] == "11:59 pm")) {

$disabled = " disabled";

$hidden = " style=\"visibility: hidden;\"";

$checked= " checked";

$checked_enter= "";

} elseif ($_POST["all_day_".$j] == "tba") {

$_POST["start_time_".$j] = "12:00 am";

$_POST["end_time_".$j] = "12:00 am";

$disabled = " disabled";

$hidden = " style=\"visibility: hidden;\"";

$checked_tba = " checked";

$checked_enter= "";

} elseif (($_POST["start_time_".$j] == "12:00 am") && ($_POST["end_time_".$j] == "12:00 am")) {

$disabled = " disabled";

$hidden = " style=\"visibility: hidden;\"";

$checked_tba= " checked";

$checked_enter= "";}

ereg ("([0-9]{1,2})[\/-]+([0-9]{1,2})[\/-]+([0-9]{4})",$_POST["date_add"],$date);

$juno = 0;

$r = $_POST["recurring"];

if (!$r) $r = 0;

$int = $_POST["interval"];

while ($juno <= $r) {

$next = $juno * $int;

$show_date = date( "m/d/Y", mktime( 0, 0, 0, $date[1], $date[2]+$next, $date[3] ) );

?>

<tr> <td><input type="checkbox" name="delete_<?php echo $i; ?>" id="delete_<?php echo $i; ?>" value="yes" /></td>

<td><input type="text" name="date_<?php echo $i; ?>" id="date_<?php echo $i; ?>" value="<?php echo $show_date; ?>"size="10"> <a href="#"

onclick="cal.select(document.event.date_<?php echo $i; ?>,this.name,'MM/dd/yyyy'); return false;" NAME="anchor_date_<?php echo $i; ?>"

ID="anchor_date_<?php echo $i; ?>"><img src="images/calendar.png" border="0" /></a></td>

<td><input type="radio" onClick="null_out(this,<?php echo $i; ?>);" name="all_day_<?php echo $i; ?>" id="all_day_<?php echo $i; ?>" value="all"<?php

echo $checked; ?>/> / <input type="radio" onClick="null_out(this,<?php echo $i; ?>);" name="all_day_<?php echo $i; ?>" id="all_day_<?php echo $i; ?>"

value="tba"<?php echo $checked_tba; ?>/> / <input type="radio" onClick="null_out(this,<?php echo $i; ?>);" name="all_day_<?php echo $i; ?>"

id="all_day_<?php echo $i; ?>" value=""<?php echo $checked_enter; ?>/></td>

<td><input type="text" name="start_time_<?php echo $i; ?>" id="start_time_<?php echo $i; ?>" value="<?php echo $_POST["start_time_add"]; ?>"

size="10"<?php echo $disabled; ?>/> <a href="#" onclick="test5popupactivate(document.event.start_time_<?php echo $i; ?>,this.name);return false;"

NAME="anchor_time_start_<?php echo $i; ?>" ID="anchor_time_start_<?php echo $i; ?>"<?php echo $hidden; ?>><img src="images/time.png" border="0"

/></a></td>

<td><input type="text" name="end_time_<?php echo $i; ?>" id="end_time_<?php echo $i; ?>" value="<?php echo $_POST["end_time_add"]; ?>" size="10"<?

php echo $disabled; ?>/> <a href="#" onclick="test5popupactivate(document.event.end_time_0,this.name);return false;" NAME="anchor_time_end_<?php echo

$i; ?>" ID="anchor_time_end_<?php echo $i; ?>"<?php echo $hidden; ?>><img src="images/time.png" border="0" /></a></td> </tr>

<?php

$juno++;

$i++; } }

?>

134

Page 135: CHAPTER 1

<tr> <td><?php echo $lang["add"];?> =>></td>

<td> <input type="text" name="date_add" id="date_add" value="<?php echo $_REQUEST["next_date"]; ?>" size="10"> <a href="#"

onclick="cal.select(document.event.date_add,this.name,'MM/dd/yyyy'); return false;" NAME="anchor_date_add" ID="anchor_date_add"><img

src="images/calendar.png" border="add" /></a></td>

<td><input type="radio" onClick="null_out(this,'add');" name="all_day_add" id="all_day_add" value="all" /> / <input type="radio"

onClick="null_out(this,'add');" name="all_day_add" id="all_day_add" value="tba" /> / <input type="radio" onClick="null_out(this,'add');" name="all_day_add"

id="all_day_add" value="" checked /></td>

<td><input type="text" name="start_time_add" id="start_time_add" value="<?php echo $_REQUEST["next_start"]; ?>" size="10"> <a href="#"

onclick="test5popupactivate(document.event.start_time_add,this.name);return false;" NAME="anchor_time_start_add" ID="anchor_time_start_add""><img

src="images/time.png" border="add" /></a> </td>

<td><input type="text" name="end_time_add" id="end_time_add" value="<?php echo $_REQUEST["next_end"]; ?>" size="10"> <a href="#"

onclick="test5popupactivate(document.event.end_time_add,this.name);return false;" NAME="anchor_time_end_add" ID="anchor_time_end_add""><img

src="images/time.png" border="add" /></a> </td> </tr>

<tr> <td colspan="4"><?php echo $lang["recurring"];?> <input type="text" name="recurring" size="3"> X <select name="interval"><option

value="1">1</option>

<option value="2">2</option>

<option value="3">3</option>

<option value="4">4</option>

<option value="5">5</option>

<option value="6">6</option>

<option value="7">7</option>

<option value="8">8</option>

<option value="9">9</option>

</select> <?php echo $lang["days"];?></td>

</tr> </table>

<p><input type="submit" name="mode" id="mode" value="<?php echo $lang["add_edit_dates"];?>"></p>

<p><?php echo $lang["description"];?>:<br />

<?php if ($fck_editor_path) {

include($fck_editor_path."fckeditor.php") ;

$oFCKeditor = new FCKeditor('description') ;

$oFCKeditor->BasePath = $calendar_url.$fck_editor_path ;

$oFCKeditor->Value = $_POST["description"] ;

$oFCKeditor->Height = 400;

$oFCKeditor->ToolbarSet = $fck_editor_toolbar;

$oFCKeditor->Create() ;

} else {

echo "<textarea cols=\"60\" rows=\"10\" name=\"description\" id=\"description\">".$_POST["description"]."</textarea>\n"; }

?>

</p>

<p><input type="submit" name="mode" id="mode" value="<?php echo $lang["add_event"];?>"></p>

</form>

<div id="timelayer" STYLE="position:absolute;visibility:hidden;background-color:white;layer-background-color:white;top:0px;z-index: 1;">

<form id="time" name="time">

<select id="hour" size="18" onChange="testpopup5pick(this.options[this.selectedIndex].value);">

<option value="12:00 am" class="midnight">Midnight</option>

<option value="01:00 am" class="evening">01:00 am</option>

<option value="02:00 am" class="evening">02:00 am</option>

<option value="03:00 am" class="evening">03:00 am</option>

<option value="04:00 am" class="evening">04:00 am</option>

<option value="05:00 am" class="evening">05:00 am</option>

<option value="06:00 am" class="morning">06:00 am</option>

<option value="07:00 am" class="morning">07:00 am</option>

<option value="07:30 am" class="morning">07:30 am</option>

<option value="08:00 am" class="morning" selected>08:00 am</option>

<option value="08:30 am" class="morning">08:30 am</option>

<option value="09:00 am" class="morning">09:00 am</option>

<option value="09:30 am" class="morning">09:30 am</option>

<option value="10:00 am" class="morning">10:00 am</option>

<option value="10:30 am" class="morning">10:30 am</option>

<option value="11:00 am" class="morning">11:00 am</option>

135

Page 136: CHAPTER 1

<option value="11:30 am" class="morning">11:30 am</option>

<option value="12:00 pm" class="noon">Noon</option>

<option value="12:30 pm" class="afternoon">12:30 pm</option>

<option value="01:00 pm" class="afternoon">01:00 pm</option>

<option value="01:30 pm" class="afternoon">01:30 pm</option>

<option value="02:00 pm" class="afternoon">02:00 pm</option>

<option value="02:30 pm" class="afternoon">02:30 pm</option>

<option value="03:00 pm" class="afternoon">03:00 pm</option>

<option value="03:30 pm" class="afternoon">03:30 pm</option>

<option value="04:00 pm" class="afternoon">04:00 pm</option>

<option value="04:30 pm" class="afternoon">04:30 pm</option>

<option value="05:00 pm" class="afternoon">05:00 pm</option>

<option value="05:30 pm" class="afternoon">05:30 pm</option>

<option value="06:00 pm" class="evening">06:00 pm</option>

<option value="06:30 pm" class="evening">06:30 pm</option>

<option value="07:00 pm" class="evening">07:00 pm</option>

<option value="07:30 pm" class="evening">07:30 pm</option>

<option value="08:00 pm" class="evening">08:00 pm</option>

<option value="08:30 pm" class="evening">08:30 pm</option>

<option value="09:00 pm" class="evening">09:00 pm</option>

<option value="09:30 pm" class="evening">09:30 pm</option>

<option value="10:00 pm" class="evening">10:00 pm</option>

<option value="10:30 pm" class="evening">10:30 pm</option>

<option value="11:00 pm" class="evening">11:00 pm</option>

<option value="11:30 pm" class="evening">11:30 pm</option>

</select> </form> </div>

<DIV ID="testdiv1" STYLE="position:absolute;visibility:hidden;background-color:white;layer-background-color:white;"></DIV>

<?php

} include ("includes/footer.php"); ?>

EDIT MARKET PAGE

<?php

var cal = new CalendarPopup("testdiv1");

cal.offsetX=-20;

cal.offsetY=20;

var testpopup5 = new PopupWindow("timelayer");

testpopup5.offsetX=-20;

testpopup5.offsetY=20;

testpopup5.autoHide();

var testpopup5input=null;

function test5popupactivate(obj,anchor) {

testpopup5input=obj;

testpopup5.showPopup(anchor); }

function testpopup5pick(val) {

testpopup5input.value = val;

testpopup5.hidePopup(); }

function null_out(t,i) {

if ((t.value == "all") || (t.value == "tba")){

eval("t.form.start_time_" + i +".disabled=true");

eval("t.form.end_time_" + i +".disabled=true");

eval("t.form.start_time_" + i +".value=\'12:00 am\'");

if (t.value == "all") { eval("t.form.end_time_" + i +".value=\'11:59 pm\'");

} else { eval("t.form.end_time_" + i +".value=\'12:00 am\'"); }

eval("turn_off(\'anchor_time_start_" + i +"\')");

eval("turn_off(\'anchor_time_end_" + i +"\')");

} else { eval("t.form.start_time_" + i +".disabled=false");

eval("t.form.end_time_" + i +".disabled=false");

eval("turn_on(\'anchor_time_start_" + i +"\')");

eval("turn_on(\'anchor_time_end_" + i +"\')"); } }

136

Page 137: CHAPTER 1

function turn_on(whichLayer) {

if (document.getElementById) {

$page_title = $lang["title_edit_event"];

function category_tree($category_id) {

global $table_prefix, $indent, $supercategory, $scategory;

$q = "SELECT category_id, name from ".$table_prefix."categories where sub_of = ".$category_id." order by name";

$query = mysql_query($q);

if (!$query) echo "Database Error : ".$q;

else {

while ($row=mysql_fetch_row($query)) {

$mod = 0;

if (!$supercategory) {

$q = "select moderate from ".$table_prefix."users_to_categories where category_id = ".$row[0]." and user_id = ".$_SESSION["user_id"];

$qu = mysql_query($q);

if (mysql_num_rows($qu) > 0) $mod = mysql_result($qu,0,0);

} else {

$mod = 3; }

if ($mod > 0) {

echo "<option value=\"".$row[0]."\"";

if($mod < 2) echo " disabled";

if ($scategory == $row[0]) echo " SELECTED";

echo ">".$indent.$row[1]."</option>\n"; }

$indent .= "__";

category_tree($row[0]);

$indent = substr($indent, 2); } }

function group_tree($group_id) {

global $table_prefix, $indent, $supergroup, $sgroup;

$q = "SELECT group_id, name from ".$table_prefix."groups where sub_of = ".$group_id." order by name";

$query = mysql_query($q);

if (!$query) echo "Database Error : ".$q;

else {

while ($row=mysql_fetch_row($query)) {

$mod = 0;

if (!$supergroup) {

$q = "select moderate from ".$table_prefix."users_to_groups where group_id = ".$row[0]." and user_id = ".$_SESSION["user_id"];

$qu = mysql_query($q);

if (mysql_num_rows($qu) > 0) $mod = mysql_result($qu,0,0);

} else {

$mod = 3; }

if ($mod > 0) {

echo "<option value=\"".$row[0]."\"";

if($mod < 2) echo " disabled";

if ($sgroup == $row[0]) echo " SELECTED";

echo ">".$indent.$row[1]."</option>\n"; }

$indent .= "__";

group_tree($row[0]);

$indent = substr($indent, 2); } } }

function select_place($field) {

global $table_prefix, $indent;

$q = "SELECT link_id, state, city, company from ".$table_prefix."links where link_id > 1 order by state, city, company";

$query = mysql_query($q);

if (!$query) echo "Database Error : ".$q;

else { while ($row=mysql_fetch_row($query)) {

echo "<option value=\"".$row[0]."\"";

if ($field) {if ($field == $row[0]) echo " SELECTED"; }

echo ">";

if ($row[1]) echo $row[1]." : ";

if ($row[2]) echo $row[2]." : ";

echo $row[3]."</option>\n"; } } }

if (!$superview) {

137

Page 138: CHAPTER 1

mysql_close($link);

header("Location: ".$path."login.php?return_to=".$PHP_SELF);

} elseif (!$superpost) {

include "includes/header.php";

echo "<p class=\"warning\">".$lang["not_authorized_events"]."</p>\n";

} else { $q = "SELECT * from ".$table_prefix."events where event_id =".$_REQUEST["id"];

$query = mysql_query($q);

$row = mysql_fetch_array($query);

if (!$query) $msg .= "Database Error : ".$q;

if (!$supergroup) {

if ($row["user_id"] != $_SESSION["user_id"]) {

$q = "select moderate from ".$table_prefix."users_to_groups where group_id = ".$row[0]." and user_id = ".$_SESSION["user_id"];

$mod = mysql_result(mysql_query($q),0,0);

if ($mod < 2) {

mysql_close($link);

header("Location: ".$path."index.php?msg=".$lang["not_authorized_events_group"]); }}}

if (!$supercategory) {

if ($row["user_id"] != $_SESSION["user_id"]) {

$q = "select moderate from ".$table_prefix."users_to_categories where category_id = ".$row[0]." and user_id = ".$_SESSION["user_id"];

$mod = mysql_result(mysql_query($q),0,0);

if ($mod < 2) {

mysql_close($link);

header("Location: ".$path."index.php?msg=".$lang["not_authorized_events_category"]); }}}

$status_id = $row["status_id"];

if (!isset($_POST["mode"])) {

$_POST["title"] = $row["title"];

$_POST["category"] = $row["category_id"];

$_POST["venue"] = $row["venue_id"];

$_POST["contact"] = $row["contact_id"];

$_POST["description"] = $row["description"];

$_POST["group"] = $row["group_id"];

if (($row["status_id"] == 2) || ($row["status_id"] == 3)) $_POST["propose"] = "propose";

else $_POST["propose"] = "post";

$q = "SELECT * from ".$table_prefix."dates where event_id =".$_REQUEST["id"];

$query = mysql_query($q);

if (!$query) $msg .= "Database Error : ".$q;

else {

$i = 0;

while ($row = mysql_fetch_row($query)) {

eregi("([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2}):([0-9]{2}):[0-9]{2}",$row[1],$start);

$_POST["date_".$i] = $start[2]."/".$start[3]."/".$start[1];

if ($start[4] == "00") {

$start[4] = 12;

$start_ap = "am";

} elseif ($start[4] >= 12) {

$start_ap = "pm";

} else {

$start_ap = "am"; }

if ($start[4] > 12) $start[4] = $start[4] - 12;

$_POST["start_time_".$i] = $start[4].":".$start[5]." ".$start_ap;

if ($row[2]) {

eregi("([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2}):([0-9]{2}):[0-9]{2}",$row[2],$end);

if ($end[4] == "00") {

$end[4] = 12;

$end_ap = "am";

} elseif ($end[4] >= 12) {

$end_ap = "pm";

} else {

$end_ap = "am"; }

if ($end[4] > 12) $end[4] = $end[4] - 12;

138

Page 139: CHAPTER 1

$_POST["end_time_".$i] = $end[4].":".$end[5]." ".$end_ap; }

$i++; }}}

if ($_POST["mode"] == $lang["update_event"]) {

if(get_magic_quotes_gpc()) {

$title = mysql_real_escape_string(stripslashes($_POST["title"]));

$link_id = mysql_real_escape_string(stripslashes($_POST["venue"]));

$contact_id = mysql_real_escape_string(stripslashes($_POST["contact"]));

$description = mysql_real_escape_string(stripslashes($_POST["description"]));

$category_id = mysql_real_escape_string(stripslashes($_POST["category"]));

$group_id = mysql_real_escape_string(stripslashes($_POST["group"]));

$propose = mysql_real_escape_string(stripslashes($_POST["propose"]));

} else {

$title = mysql_real_escape_string($_POST["title"]);

$link_id = mysql_real_escape_string($_POST["venue"]);

$contact_id = mysql_real_escape_string($_POST["contact"]);

$description = mysql_real_escape_string($_POST["description"]);

$category_id = mysql_real_escape_string($_POST["category"]);

$group_id = mysql_real_escape_string($_POST["group"]);

$propose = mysql_real_escape_string($_POST["propose"]); }

if (($status_id == 2) || ($status_id == 3)) {

if ($propose == "propose") {

$new_status_id = 3;

} else {

$new_status_id = 5; }

} else {

if ($propose == "propose") {

$new_status_id = 3;

} else {

$new_status_id = 6; } }

if (!$supergroup) {

$q = "select moderate from ".$table_prefix."users_to_groups where group_id = ".$group_id." and user_id = ".$_SESSION["user_id"];

$mod = mysql_result(mysql_query($q),0,0);

if ($mod < 3) $new_status_id = 3; }

$q = "UPDATE ".$table_prefix."events set title = '".$title."', venue_id = ".$link_id.", contact_id = ".$contact_id.", description = '".$description."', category_id =

".$category_id.", group_id = ".$group_id.", status_id = ".$new_status_id." where event_id = ".$_POST["id"];

$query = mysql_query($q);

if (!$query) $msg .= "Database Error : ".$q;

else {

$q = "delete from ".$table_prefix."dates where event_id = ".$_POST["id"];

$query = mysql_query($q);

if (!$query) $msg .= "Database Error : ".$q;

$j = 0;

while ($_POST["date_".$j]) {

if (!$_POST["delete_".$j]) {

if ($_POST["all_day_".$j] == "all") {

$_POST["start_time_".$j] = "12:00 am";

$_POST["end_time_".$j] = "11:59 pm";

} else if ($_POST["all_day_".$j] == "tba") {

$_POST["start_time_".$j] = "12:00 am";

$_POST["end_time_".$j] = "12:00 am"; }

if (!ereg ("([0-9]{1,2})[\/-]+([0-9]{1,2})[\/-]+([0-9]{4})",$_POST["date_".$j],$date)) {

$msg .= "Bad Date:".$_POST["date_".$j];

} else {

if (!eregi ("([0-9]{1,2}):([0-9]{2})[ ]?([a|p]m)",$_POST["start_time_".$j],$start_time)) {

$msg .= "Bad Start Time:".$_POST["start_time_".$j];

} else {

if (($_POST["end_time_".$j])&&(!eregi ("([0-9]{1,2}):([0-9]{2})[ ]?([a|p]m)",$_POST["end_time_".$j],$end_time))) {

$msg .= "Bad End Time:".$_POST["end_time_".$j];

} else {

if (strlen($date[1]) == 1) $date[1] = "0".$date[1];

139

Page 140: CHAPTER 1

if (strlen($date[2]) == 1) $date[2] = "0".$date[2];

if ((eregi("am",$start_time[3])) && ($start_time[1] == 12)) $start_time[1] = $start_time[1] - 12;

if ((eregi("am",$end_time[3])) && ($end_time[1] == 12)) $end_time[1] = $end_time[1] - 12;

if ((eregi("pm",$start_time[3])) && ($start_time[1] < 12)) $start_time[1] = $start_time[1] + 12;

if ((eregi("pm",$end_time[3])) && ($end_time[1] < 12)) $end_time[1] = $end_time[1] + 12;

if (strlen($start_time[1]) == 1) $start_time[1] = "0".$start_time[1];

if (strlen($end_time[1]) == 1) $end_time[1] = "0".$end_time[1];

$start_date = $date[3]."-".$date[1]."-".$date[2]." ".$start_time[1].":".$start_time[2];

if ($_POST["end_time_".$j]) {

$end_date = $date[3]."-".$date[1]."-".$date[2]." ".$end_time[1].":".$end_time[2];

if (($end_time[1].$end_time[2]) >= ($start_time[1].$start_time[2])) {

$q = "INSERT into ".$table_prefix."dates (event_id, date, end_date) values (".$_REQUEST["id"].", '".$start_date."', '".$end_date."')";

} else {

$q = "INSERT into ".$table_prefix."dates (event_id, date) values (".$_REQUEST["id"].", '".$start_date."')"; }

} else {

$q = "INSERT into ".$table_prefix."dates (event_id, date) values (".$_REQUEST["id"].", '".$start_date."')"; }

$query = mysql_query($q);

if (!$query) $msg .= "Database Error : ".$q; } } } }

$j++; }

if ($_POST["date_add"]) {

if ($_POST["all_day_add"] == "all") {

$_POST["start_time_add"] = "12:00 am";

$_POST["end_time_add"] = "11:59 pm";

} else if ($_POST["all_day_add"] == "tba") {

$_POST["start_time_add"] = "12:00 am";

$_POST["end_time_add"] = "12:00 am"; }

if (!ereg ("([0-9]{1,2})[\/-]+([0-9]{1,2})[\/-]+([0-9]{4})",$_POST["date_add"],$date)) {

$msg .= "Bad Date:".$_POST["date_add"];

} else {

if (!eregi ("([0-9]{1,2}):([0-9]{2})[ ]?([a|p]m)",$_POST["start_time_add"],$start_time)) {

$msg .= "Bad Start Time:".$_POST["start_time_add"];

} else {

if (($_POST["end_time_add"])&&(!eregi ("([0-9]{1,2}):([0-9]{2})[ ]?([a|p]m)",$_POST["end_time_add"],$end_time))) {

$msg .= "Bad End Time:".$_POST["end_time_add"];

} else {

if (strlen($date[1]) == 1) $date[1] = "0".$date[1];

if (strlen($date[2]) == 1) $date[2] = "0".$date[2];

if ((eregi("am",$start_time[3])) && ($start_time[1] == 12)) $start_time[1] = $start_time[1] - 12;

if ((eregi("am",$end_time[3])) && ($end_time[1] == 12)) $end_time[1] = $end_time[1] - 12;

if ((eregi("pm",$start_time[3])) && ($start_time[1] < 12)) $start_time[1] = $start_time[1] + 12;

if ((eregi("pm",$end_time[3])) && ($end_time[1] < 12)) $end_time[1] = $end_time[1] + 12;

if (strlen($start_time[1]) == 1) $start_time[1] = "0".$start_time[1];

if (strlen($end_time[1]) == 1) $end_time[1] = "0".$end_time[1];

$start_date = $date[3]."-".$date[1]."-".$date[2]." ".$start_time[1].":".$start_time[2];

//loop through recurring events

$juno = 0;

$r = $_POST["recurring"];

if (!$r) $r = 0;

$int = $_POST["interval"];

while ($juno <= $r) {

$next = $juno * $int;

if ($_POST["end_time_add"]) {

$end_date = $date[3]."-".$date[1]."-".$date[2]." ".$end_time[1].":".$end_time[2];

if (($end_time[1].$end_time[2]) >= ($start_time[1].$start_time[2])) {

$q = "INSERT into ".$table_prefix."dates (event_id, date, end_date) values (".$_REQUEST["id"].", DATE_ADD('".$start_date."', INTERVAL ".$next." DAY),

DATE_ADD('".$end_date."', INTERVAL ".$next." DAY))";

} else {

$q = "INSERT into ".$table_prefix."dates (event_id, date) values (".$_REQUEST["id"].", DATE_ADD('".$start_date."', INTERVAL ".$next." DAY))";

} } else {

$q = "INSERT into ".$table_prefix."dates (event_id, date) values (".$_REQUEST["id"].", DATE_ADD('".$start_date."', INTERVAL ".$next." DAY))";

140

Page 141: CHAPTER 1

} $query = mysql_query($q);

if (!$query) $msg .= "Database Error : ".$q;

$juno++; } } } } }

if ($_POST["notify"]) {

include "includes/notify.php";

notify_group($_POST["id"]); }

$msg .= $lang["event_updated"];

if ($_REQUEST["size"] != "small") {

mysql_close($link);

header("Location: ".$path."index.php?msg=".$msg);

} else {

$javascript .= "\n<script language=\"JavaScript\" type=\"text/javascript\">\n<!--\nopener.location.reload(true);\nself.close();\n// -->\n</script>\n";

} } }

include "includes/header.php";

$scategory = $_POST["category"] ? $_POST["category"] : $c;

$sgroup = $_POST["group"] ? $_POST["group"] : $w;

if ($msg) echo "<p class=\"warning\">".$msg."</p>\n";

?>

<form action="edit_event.php" id="event" name="event" method="post">

<?php include "includes/hidden_fields.php"; ?>

<input type="hidden" name="id" value="<?php echo $_REQUEST["id"]; ?>">

<input type="hidden" name="size" value="<?php echo $_REQUEST["size"]; ?>">

<table> <tr> <td><?php echo $lang["title"];?>:</td>

<td><input type="text" name="title" id="title" value="<?php echo $_POST["title"]; ?>" size="40"></td>

</tr>

<tr> <td> <?php echo $lang["group"];?>: </td>

<td> <select name="group" id="group">

<?php group_tree(0); ?>

</select> <select name="propose" id="propose"><option value="post"<? if ($_POST["propose"] == "post") echo " selected"; ?>><?php echo $lang["post"];?

></option><option value="propose"<? if ($_POST["propose"] == "propose") echo " selected"; ?>><?php echo $lang["propose"];?></option></select>

<input type="checkbox" name="notify" value="1"<? if ($_POST["notify"]) echo " checked"; ?>> <?php echo $lang["notify subscribers"];?>

</td> </tr>

<tr> <td><?php echo $lang["category"];?>:</td>

<td> <select name="category" id="category">

<?php category_tree(0); ?>

</select>

</td> </tr>

<tr> <td><?php echo $lang["venue"];?>:</td>

<td> <select name="venue" id="venue" size="1">

<option value="1"><?php echo $lang["in_main_description"];?></option>

<?php select_place($_POST["venue"]); ?>

</select> </td> </tr> <tr>

<td><?php echo $lang["contact_sponsor"];?>:</td>

<td> <select name="contact" id="contact" size="1">

<option value="1"><?php echo $lang["none"];?></option>

<?php select_place($_POST["contact"]); ?>

</select> </td> </tr> </table>

<?php echo $lang["dates"];?>:

<table> <tr> <th><?php echo $lang["delete?"];?></th>

<th><?php echo $lang["date"];?></th><th><?php echo $lang["all_day"];?> / <?php echo $lang["tba"];?> / <?php echo $lang["enter_time"];?></th><th><?php

echo $lang["start_time"];?></th>

<th><?php echo $lang["end_time"];?></th> </tr>

<?php

$i = 0;

$j = 0;

while ($_POST["date_".$j]) {

if (!$_POST["delete_".$j]) {

$disabled = "";

$hidden = "";

$checked= "";

141

Page 142: CHAPTER 1

$checked_tba= "";

$checked_enter= " checked";

if ($_POST["all_day_".$j] == "all") {

$_POST["start_time_".$j] = "12:00 am";

$_POST["end_time_".$j] = "11:59 pm";

$disabled = " disabled";

$hidden = " style=\"visibility: hidden;\"";

$checked= " checked";

$checked_enter= "";

} elseif (($_POST["start_time_".$j] == "12:00 am") && ($_POST["end_time_".$j] == "11:59 pm")) {

$disabled = " disabled";

$hidden = " style=\"visibility: hidden;\"";

$checked= " checked";

$checked_enter= "";

} elseif ($_POST["all_day_".$j] == "tba") {

$_POST["start_time_".$j] = "12:00 am";

$_POST["end_time_".$j] = "12:00 am";

$disabled = " disabled";

$hidden = " style=\"visibility: hidden;\"";

$checked_tba = " checked";

$checked_enter= "";

} elseif (($_POST["start_time_".$j] == "12:00 am") && ($_POST["end_time_".$j] == "12:00 am")) {

$disabled = " disabled";

$hidden = " style=\"visibility: hidden;\"";

$checked_tba= " checked";

$checked_enter= ""; }

?>

<tr> <td><input type="checkbox" name="delete_<?php echo $i; ?>" id="delete_<?php echo $i; ?>" value="yes" /></td>

<td><input type="text" name="date_<?php echo $i; ?>" id="date_<?php echo $i; ?>" value="<?php echo $_POST["date_".$j]; ?>"size="10"> <a href="#"

onclick="cal.select(document.event.date_<?php echo $i; ?>,this.name,'MM/dd/yyyy'); return false;" NAME="anchor_date_<?php echo $i; ?>"

ID="anchor_date_<?php echo $i; ?>"><img src="images/calendar.png" border="0" /></a></td>

<td><input type="radio" onClick="null_out(this,<?php echo $i; ?>);" name="all_day_<?php echo $i; ?>" id="all_day_<?php echo $i; ?>" value="all"<?php

echo $checked; ?>/> / <input type="radio" onClick="null_out(this,<?php echo $i; ?>);" name="all_day_<?php echo $i; ?>" id="all_day_<?php echo $i; ?>"

value="tba"<?php echo $checked_tba; ?>/> / <input type="radio" onClick="null_out(this,<?php echo $i; ?>);" name="all_day_<?php echo $i; ?>"

id="all_day_<?php echo $i; ?>" value=""<?php echo $checked_enter; ?>/></td>

<td><input type="text" name="start_time_<?php echo $i; ?>" id="start_time_<?php echo $i; ?>" value="<?php echo $_POST["start_time_".$j]; ?>"

size="10"<?php echo $disabled; ?>/> <a href="#" onclick="test5popupactivate(document.event.start_time_<?php echo $i; ?>,this.name);return false;"

NAME="anchor_time_start_<?php echo $i; ?>" ID="anchor_time_start_<?php echo $i; ?>"<?php echo $hidden; ?>><img src="images/time.png" border="0"

/></a></td>

<td><input type="text" name="end_time_<?php echo $i; ?>" id="end_time_<?php echo $i; ?>" value="<?php echo $_POST["end_time_".$j]; ?>" size="10"<?

php echo $disabled; ?>/> <a href="#" onclick="test5popupactivate(document.event.end_time_0,this.name);return false;" NAME="anchor_time_end_<?php echo

$i; ?>" ID="anchor_time_end_<?php echo $i; ?>"<?php echo $hidden; ?>><img src="images/time.png" border="0" /></a></td> </tr>

<?php

$i++; }

$j++; }

if ($_POST["date_add"]) {

$disabled = "";

$hidden = "";

$checked= "";

$checked_tba= "";

$checked_enter= " checked";

if ($_POST["all_day_add"]) {

$_POST["start_time_add"] = "12:00 am";

$_POST["end_time_add"] = "11:59 pm";

$disabled = " disabled";

$hidden = " style=\"visibility: hidden;\"";

$checked= " checked";

$checked_enter= "";

} elseif (($_POST["start_time_add"] == "12:00 am") && ($_POST["end_time_add"] == "11:59 pm")) {

$disabled = " disabled";

142

Page 143: CHAPTER 1

$hidden = " style=\"visibility: hidden;\"";

$checked= " checked";

$checked_enter= "";

} elseif ($_POST["all_day_".$j] == "tba") {

$_POST["start_time_".$j] = "12:00 am";

$_POST["end_time_".$j] = "12:00 am";

$disabled = " disabled";

$hidden = " style=\"visibility: hidden;\"";

$checked_tba = " checked";

$checked_enter= "";

} elseif (($_POST["start_time_".$j] == "12:00 am") && ($_POST["end_time_".$j] == "12:00 am")) {

$disabled = " disabled";

$hidden = " style=\"visibility: hidden;\"";

$checked_tba= " checked";

$checked_enter= ""; }

ereg ("([0-9]{1,2})[\/-]+([0-9]{1,2})[\/-]+([0-9]{4})",$_POST["date_add"],$date);

$juno = 0;

$r = $_POST["recurring"];

if (!$r) $r = 0;

$int = $_POST["interval"];

while ($juno <= $r) {

$next = $juno * $int;

$show_date = date( "m/d/Y", mktime( 0, 0, 0, $date[1], $date[2]+$next, $date[3] ) );

?>

<tr> <td><input type="checkbox" name="delete_<?php echo $i; ?>" id="delete_<?php echo $i; ?>" value="yes" /></td>

<td><input type="text" name="date_<?php echo $i; ?>" id="date_<?php echo $i; ?>" value="<?php echo $show_date; ?>"size="10"> <a href="#"

onclick="cal.select(document.event.date_<?php echo $i; ?>,this.name,'MM/dd/yyyy'); return false;" NAME="anchor_date_<?php echo $i; ?>"

ID="anchor_date_<?php echo $i; ?>"><img src="images/calendar.png" border="0" /></a></td>

<td><input type="radio" onClick="null_out(this,<?php echo $i; ?>);" name="all_day_<?php echo $i; ?>" id="all_day_<?php echo $i; ?>" value="all"<?php

echo $checked; ?>/> / <input type="radio" onClick="null_out(this,<?php echo $i; ?>);" name="all_day_<?php echo $i; ?>" id="all_day_<?php echo $i; ?>"

value="tba"<?php echo $checked_tba; ?>/> / <input type="radio" onClick="null_out(this,<?php echo $i; ?>);" name="all_day_<?php echo $i; ?>"

id="all_day_<?php echo $i; ?>" value=""<?php echo $checked_enter; ?>/></td>

<td><input type="text" name="start_time_<?php echo $i; ?>" id="start_time_<?php echo $i; ?>" value="<?php echo $_POST["start_time_add"]; ?>"

size="10"<?php echo $disabled; ?>/> <a href="#" onclick="test5popupactivate(document.event.start_time_<?php echo $i; ?>,this.name);return false;"

NAME="anchor_time_start_<?php echo $i; ?>" ID="anchor_time_start_<?php echo $i; ?>"<?php echo $hidden; ?>><img src="images/time.png" border="0"

/></a></td>

<td><input type="text" name="end_time_<?php echo $i; ?>" id="end_time_<?php echo $i; ?>" value="<?php echo $_POST["end_time_add"]; ?>" size="10"<?

php echo $disabled; ?>/> <a href="#" onclick="test5popupactivate(document.event.end_time_0,this.name);return false;" NAME="anchor_time_end_<?php echo

$i; ?>" ID="anchor_time_end_<?php echo $i; ?>"<?php echo $hidden; ?>><img src="images/time.png" border="0" /></a></td> </tr>

<?php

$juno++; $i++; } }

?> <tr>

<td><?php echo $lang["add"];?> =>></td> <td>

<input type="text" name="date_add" id="date_add" size="10"> <a href="#" onclick="cal.select(document.event.date_add,this.name,'MM/dd/yyyy'); return

false;" NAME="anchor_date_add" ID="anchor_date_add"><img src="images/calendar.png" border="add" /></a></td>

<td><input type="radio" onClick="null_out(this,'add');" name="all_day_add" id="all_day_add" value="all" /> / <input type="radio"

onClick="null_out(this,'add');" name="all_day_add" id="all_day_add" value="tba" /> / <input type="radio" onClick="null_out(this,'add');" name="all_day_add"

id="all_day_add" value="" checked /></td>

<td><input type="text" name="start_time_add" id="start_time_add" size="10"> <a href="#"

onclick="test5popupactivate(document.event.start_time_add,this.name);return false;" NAME="anchor_time_start_add" ID="anchor_time_start_add""><img

src="images/time.png" border="add" /></a>

</td>

<td><input type="text" name="end_time_add" id="end_time_add" size="10"> <a href="#"

onclick="test5popupactivate(document.event.end_time_add,this.name);return false;" NAME="anchor_time_end_add" ID="anchor_time_end_add""><img

src="images/time.png" border="add" /></a>

</td> </tr> <tr>

<td colspan="4"><?php echo $lang["recurring"];?> <input type="text" name="recurring" size="3"> X <select name="interval"><option value="1">1</option>

<option value="2">2</option>

<option value="3">3</option>

<option value="4">4</option>

143

Page 144: CHAPTER 1

<option value="5">5</option>

<option value="6">6</option>

<option value="7">7</option>

<option value="8">8</option>

<option value="9">9</option>

<option value="10">10</option>

</select> <?php echo $lang["days"];?></td> </tr>

</table>

<p><input type="submit" name="mode" id="mode" value="<?php echo $lang["add_edit_dates"];?>"></p>

<p><?php echo $lang["description"];?>:<br />

<?php if ($fck_editor_path) {

include($fck_editor_path."fckeditor.php") ;

$oFCKeditor = new FCKeditor('description') ;

$oFCKeditor->BasePath = $calendar_url.$fck_editor_path ;

$oFCKeditor->Value = $_POST["description"] ;

$oFCKeditor->Height = 400;

$oFCKeditor->ToolbarSet = $fck_editor_toolbar;

$oFCKeditor->Create() ;

} else {

echo "<textarea cols=\"60\" rows=\"10\" name=\"description\" id=\"description\">".$_POST["description"]."</textarea>\n"; }

?>

</p>

<p><input type="submit" name="mode" id="mode" value="<?php echo $lang["update_event"];?>"></p>

</form>

<div id="timelayer" STYLE="position:absolute;visibility:hidden;background-color:white;layer-background-color:white;top:0px;z-index: 1;">

<form id="time" name="time">

<select id="hour" size="18" onChange="testpopup5pick(this.options[this.selectedIndex].value);">

<option value="12:00 am" class="midnight">Midnight</option>

<option value="01:00 am" class="evening">01:00 am</option>

<option value="02:00 am" class="evening">02:00 am</option>

<option value="03:00 am" class="evening">03:00 am</option>

<option value="04:00 am" class="evening">04:00 am</option>

<option value="05:00 am" class="evening">05:00 am</option>

<option value="06:00 am" class="morning">06:00 am</option>

<option value="07:00 am" class="morning">07:00 am</option>

<option value="07:30 am" class="morning">07:30 am</option>

<option value="08:00 am" class="morning" selected>08:00 am</option>

<option value="08:30 am" class="morning">08:30 am</option>

<option value="09:00 am" class="morning">09:00 am</option>

<option value="09:30 am" class="morning">09:30 am</option>

<option value="10:00 am" class="morning">10:00 am</option>

<option value="10:30 am" class="morning">10:30 am</option>

<option value="11:00 am" class="morning">11:00 am</option>

<option value="11:30 am" class="morning">11:30 am</option>

<option value="12:00 pm" class="noon">Noon</option>

<option value="12:30 pm" class="afternoon">12:30 pm</option>

<option value="01:00 pm" class="afternoon">01:00 pm</option>

<option value="01:30 pm" class="afternoon">01:30 pm</option>

<option value="02:00 pm" class="afternoon">02:00 pm</option>

<option value="02:30 pm" class="afternoon">02:30 pm</option>

<option value="03:00 pm" class="afternoon">03:00 pm</option>

<option value="03:30 pm" class="afternoon">03:30 pm</option>

<option value="04:00 pm" class="afternoon">04:00 pm</option>

<option value="04:30 pm" class="afternoon">04:30 pm</option>

<option value="05:00 pm" class="afternoon">05:00 pm</option>

<option value="05:30 pm" class="afternoon">05:30 pm</option>

<option value="06:00 pm" class="evening">06:00 pm</option>

<option value="06:30 pm" class="evening">06:30 pm</option>

<option value="07:00 pm" class="evening">07:00 pm</option>

<option value="07:30 pm" class="evening">07:30 pm</option>

144

Page 145: CHAPTER 1

<option value="08:00 pm" class="evening">08:00 pm</option>

<option value="08:30 pm" class="evening">08:30 pm</option>

<option value="09:00 pm" class="evening">09:00 pm</option>

<option value="09:30 pm" class="evening">09:30 pm</option>

<option value="10:00 pm" class="evening">10:00 pm</option>

<option value="10:30 pm" class="evening">10:30 pm</option>

<option value="11:00 pm" class="evening">11:00 pm</option>

<option value="11:30 pm" class="evening">11:30 pm</option>

</select> </form> </div>

<DIV ID="testdiv1" STYLE="position:absolute;visibility:hidden;background-color:white;layer-background-color:white;"></DIV>

<?php}

include ("includes/footer.php");

?>

145