summer practice report - METU Computer Engineering - Middle East ...

yieldingrabbleInternet και Εφαρμογές Web

7 Δεκ 2013 (πριν από 3 χρόνια και 11 μήνες)

118 εμφανίσεις



MIDDLE EAST TECHNICAL UNIVERSITY

COMPUTER ENGINEERING DEPARTMENT






ceng

400


s
um
mer
practice
r
eport


NAME : ALEV KOCTAS

ID: 1448927






2







TABLE OF CONTENTS


1. COMPANY RELATED INFORMATION


1.1. Address Information


1.2. General Information


1.3.
Mission


1.4. Past Performance


1.5. Mobile Services



1.5
.1. Mobile Entertainment Services


1

(
HIPIR
)



1.5.2
. M
obile Entertainment Services


2 (MOBILOYUNCU)



1.5
.1. M
obile Entertainment Services


3 (Media Applications)



1.5.4. Focus Points



1.5.5.
Why should Başarı be a strategic partner in Mobile

Entertainment
Services?





2. PROJECT INFORMATION


2.1. Concepts and Tools Related To The Project



2.1.1
.
What is a dynamic web site?



2.1.2
. Web 2.0



2.1.3
. PHP



2.1.4
. WAMP Server(WAMP5)



2.1.
5
.
Simple Pie Library and RSS Parsing




3







2.1.6

XML



2.1.7
. MySQL



2.1.8
. AJAX





2.2. Introductio
n of the Summer Practice Project



2.2.1. The parts expected to take place on the pages



2.2.2. Main Parts of the Site



2.3. Project Steps


3. CONC
LUSION

4. APPENDICES

5. REFERENCES















4





1.COMPANY RELATED INFORMATION


1.1. Address Information


BAŞARI MOBILE BİLİŞİM ÜRÜNLERİ VE HİZMETLERİ A.Ş.

Adres : Ankara Teknoloji Geliştirme Bölgesi 2.cadde, Cyber Plaza A Blok Kat:1 No:
A109 Bilkent / ANKARA

Tel : 90 312 265 01 40

Tel : 90 312 265 01 41

Tel : 90 312 265 01 42

Fax : 90 312 265 01 43


Başar
ı Support Service : 90 312 444 0 100


Web : http://www.basari.com.tr/bmobile/

E
-
mail :
web@basari.com.tr



1.2.General Information


B
asari Mobile is the first company who had moved the first step towards Mobile
E
ntertainment Sector in Turkey by 1998. They started to give service under merger
departments of Information Technologies and Mobile Internet Services in the structure of
Basari Holding. Until April 2003, BASARI MOBILE BILISIM URUNLERI VE

5

HIZMETLERI A.S kee
ps up its scope of activities in Value Added Services of Mobile
Environments and Information Technologies.




1.3
.Mission:


Providing the customers Mobile Entertainment Services with a complete ability of
personalizing their cellular phones,

Become a well
-
known and respected developer of Mobile Entertainment Services and
taking forward of the titles that they have acquired,

Providing the technical and institutional development,

Enhancing their customer portfolio that they can serve with cooperation of their

partners
and institutional projects




1.4
.

Past Performances:



Past performance could be summarized as below:





Mobile Entertainment Site called CepKota launched in 1998 by being first in
Turkey and pioneer in the World.



Over 140,000 subscribers from E
-
Commerce.



Solution partner of Turkcell as certified "Golden Partner"



Annually, more than 4,500,000 Melody / Graphics have being sent



Highest E
-
Commerce Transaction Record web site (3.4 transaction / minute
-

Confirmed by Garanti Bank).



HIPIR Brand has bee
n borne in September 2001.


6



By August 2002, started to provide service over Turkcell with the Strategic
Partnership Agreement with Turkcell.



By February 2003, the first game portal in Turkey for cellular phones called
MOBIL OYUNCU has been launched in Tur
key.



By February 2003, the first company exported mobile games to the World in
Turkey.



By March 2003, Turkcell launched its game portal with the games provided by
Basari Mobile.



By May 2003, we are entitled for an award of "The Best Technological
Applicat
ion" by Turkcell.



By October 2003, the first time in Turkey a movie game called "Asmalý Konak
-
Ürgüp" has been developed by Basari Mobile. Moreover, we are entitled for an
award of "The Best Game Application" by Turkcell.



By February 2004, formed a sub
-
stru
cture for SMS voting applications for "Fame
Academy Turkey" competition televised in ATV national channel.



By April 2004, the first time in Turkey; for a cartoon character which is a famous
caricature character of Bulent Ustun called "Shero, the Hell Cat"
, a mobile game
has been developed.



By May, Mobil Oyuncu download platform has been opened wit the service
number of 2977.



By July 2004, formed a sub
-
structure for SMS voting applications for "Klipparty"
competition televised in ATV national channel.



By
October 2004, formed the sub
-
structures for SMS voting applications for
"Anatolia Heat" and "Celebrity Farm" competitions televised in ATV national
channel.



By November 2004, the first "stop
-
motion" technique Mobile Game prepared
called Komikaze in Turkey






7







1.5
. Mobile Services



1.5
.1. Mobile Entertainment Services
-

1

HIPIR


Basari Mobile, giving Mobile Entertainment Services under the web address of
www.hipir.com, is launched its site in the year of 1998 by being the first in Turkey and
pioneer i
n the World. By this time, we are enlarging our service portfolio accordance to
the advance technology and evaluation of demands.


HIPIR pages consist the services of melody, poly melody, true tones, graphics, picture
SMS, animated message, photo message,
animated screensaver, auto message, long
message, group SMS and games.


From August 2002, we are providing the service under the number of 3377 to the end
users with the Revenue Share Agreement that is signed with Turkcell. HIPIR brand
serves the most popu
lar and wide mobile entertainment contents. Annually, more than
4,500,000 logo and melody etc. transfers have being made.



1.5
.2. Mobile Entertainment Services
-

2

MOBILOYUNCU



8

Right along with SMS and WAP games, we emphasize on the works of downloadable
Java games developed in J2ME technology. In the web site www.mobiloyuncu.com and
wap.mobiloyuncu.com, different kind of games as single or multiplayer exists for every
segment. MobilOyuncu brand, which consists of more than 20 games developed by
Basari Mob
ile, has made branded local contented games once again as being first in
Turkey. Some of these games are
\

Shero the Hell Cat, Where are you Firuze, Asmali
Konak. Basari Mobile lets the mobile game lovers with its games nationally and
internationally. In a
ddition, Basari Mobile has signed some agreements with the major
game developers of worldwide to be able to serve its Turkish customers to meet the
world’s branded games. Furthermore, has succeeded on serving the games developed by
Basari Mobile to the Int
ernational Market. Some of the games that have been developed
by Basari Mobile could be found in the web site of Turkcell called www.oyunparki.com.


Basari Mobile carries on some of its activities with the Business Partner Agreement
signed with Ericsson Mo
bility World. Some of Java Games developed by Basari Mobile,
which take place in the national and international mobile entertainment portals, have also
been promoted in the B2B Nokia web site called www.tradepoint.nokia.com. In order to
enlarge the collabo
rations with terminal manufacturers and develop value added services,
Basari Mobile has started to work with Siemens, Sony Ericsson and Samsung. Partymob
(one of the biggest mobile entertainment portals of UK), ATV (one of the biggest
national TV of Turkey
) and ANS Productions (The biggest media and Production
Company of Turkey) are some of the business partners of Basari Mobile.





1.5
.3.
Mobile Entertainment Services
-

3

Media Applications


Basari Mobile has started to serve with the substructure of Inter
active TV applications, a
new area in this sector, with the network connections such as SMS, Internet, telephone,
IVR that the audience can involve in the TV programs. Also again as being first in the

9

area, we give service to the audience living in Europe
to involve in this Interactive
Application. ATV, one of the biggest national TV channels of Turkey, has chosen Basari
Mobile as its technological Partner and signed various projects. Some of these Interactive
TV application programs are; "Fame Academy" und
er the sponsorship of Procter Gamble
and "KliParty" programs’ SMS substructures has been done by Basari Mobile. With the
winter broadcast of ATV, Basari Mobile also gives service for SMS sub structure of
“Celebrity Farm” and "Anatolia Heat". The program au
diences could enter the SMS
voting from Turkey and Europe.



1.5.4.
Focus Points:




Games



MMS Composer



Smart Messaging / EMS Applications



WAP / OTA Download Services



Wireless SAP Applications



Platform / Mobile Internet Applications



Interactive TV Applicat
ions



1.5.5.
Why should Başarı

be a strategic partner in Mobile Entertainment Services?




Proven Profitable Performance



Solid Know
-
how in creating services, localization and marketing



Ability for Innovative Application Development



Following up the technolo
gy of "Mobile Gaming and Entertainment"



An institutional structure which has made investments for 3 years and will
continue.



Ability for following up the contents that the end users demand and establishing
strategic partners in order to creating this conte
nt.


10





2 . PROJECT

INFORMATION


2.1. Concepts and Tools Related to the Project



2.1.a. What is a dynamic web site?

These type of sites usually consist of server sided language extensions like .php,
.asp, .jsp. There is an interactive communication with t
he page guest. Some various
services can be offered to the guest. Site updating can be implemented you.

Specially

when we need to make a change on a site which has a frequently changing
or a huge content, it is enough to change only the related data in d
atabase for
changing the page itself. In that way improvement and updating becomes easy and
fast. Similarly, if there is a change to be done on the general appearance of the site,
this is done on the page structure for only once. That means, making the cha
nge for
once leads an unlimited number of pages to be influenced by that change.

2.1.b. PHP


PHP is a reflective programming language originally designed for producing dynamic
web pages. PHP is used mainly in server
-
side scripting, but can be used from a
command
line interface or in standalone graphical applications. Textual User Interfaces can also be
created using ncurses. PHP is a recursive acronym for "PHP: Hypertext Preprocessor".


The main implementation is produced by The PHP Group and released unde
r the PHP
License. It is considered to be free software by the Free Software Foundation. This
implementation serves to define a de facto standard for PHP, as there is no formal
specification.


11


Currently, two major versions of PHP are being actively develop
ed: 5.x and 4.4.x; on
July 13, 2007, the PHP group announced that active development on PHP4 will cease by
December 31, 2007, however, critical security updates will be provided until August 8,
2008.




2.1.c
. Web 2.0


The most significant profit that Web
2.0 brings us is to reduce the content to micro
dimensions. In the previous years, people would go the reference sites and needed
information would be provided again to find the content.
There were certain sites
that users could visit. Few content provider
s would respond to a large number of
requesters. But as the time went on, the requesters themselves started to write their
own content and share it with others. Instead of sites that are built with a 1
-
2 hour
HTML knowledge, the development of applications

which requires no design
background and analysed all the needs of the users contributed
drastically
to the
improvement of
the term where the content is provided by requesters. As a result of
these applications; people could easily share the photographs th
ey have, the social
or technical contents they want to express, the sites they visited (bookmark) with
millions. In addition to trasmitting all these things, search engines, portals,
developed API(Application Programming Interface)s which helps the peopl
e who
needs and looks for these contents were just one of the supplementing
rings that
was added to the new generation Web chain.




2.1.d
. WAMP Server
(WAMP5)



Working with MySQL, Apache, PHP on Windows by using WAMP


WAMP5 is an installer for Windows.
it installs a complete WAMP solution on your
computer. WAMP is for :





12

W
indows
-

A
pache
-

M
ySQL
-

P
HP5




WAMP5 automatically configures the
m to work together, wherever
install
ed on a

local
drive.

These softwares are installed :




Apache 1.3.x.

PHP 5
.x.x

MySQL 4.x.x

PHPmyadmin

SQLitemanager

Wampserver service manager





WAMP5 is not designed for production but as
a development environment. With
WAMP5
, it is possible to create scripts locally on a

computer, test t
hem and then upload
them on the

p
roduction server.


WAMP5 requires one of these systems to work :





Windows XP, NT, 2000, 2003









WAMP5 is totally compatible with other server installation :






T
he installation is compact
. This means that all files are copied in the same directo
ry

(
except fo mywamp.ini which goes in the windows directory).


T
he usual my.ini file is called mywamp.ini
, so it is unique to WAMP5


WAMP5 installs it's own services
. They have a special name :



13

-

apache's service is called
wampapache


-

MyS
QL's service is called
wampmysql





They don't interfere with other services (if you don't launch them in the same time of
course...)







2.1.e
. Simple Pie Library and RSS Parsing

SimplePie is a very fast and easy
-
to
-
use class, written in PHP
.

Flexible
enough to suit
beginners and veterans alike, SimplePie is focused on speed, ease of use, compatibility
and standards compliance.

There are many different RSS parsing programs that could be used, we chose to use this
library to parse RSS feeds in our projec
t.


2.1.f
. XML

The Extensible Markup Language (XML) is a gen
eral
-
purpose markup language.

It is
classified as an extensible language because it allows its users to define their own tags. Its
primary purpose is to facilitate the sharing of structured data
across different information
systems, p
articularly via the Internet.

It is used both to encode documents and serialize
data. In the latter context, it is comparable with other text
-
based serialization lan
guages
such as JSON and YAML.

It started as a simpli
fied subset of the Standard Generalized Markup Language (SGML),
and is designed to be relatively human
-
legible. By adding semantic constraints,
application languages can be implemented in XML. These include XHTML,[4] RSS,
MathML, GraphML, Scalable Vector G
raphics, MusicXML, and thousands of others.

14

Moreover, XML is sometimes used as the specification language for such application
languages.

XML is recommended by the World Wide Web Consortium. It is a fee
-
free open
standard. The W3C recommendation specifies
both the lexical grammar, and the
requirements for parsing.


2.1.g. MySQL

MySQL is a multithreaded, multi
-
user SQL database man
agement system (DBMS)
which
has, according to MySQL AB, more t
han 10 million installations.

The basic program runs
as a server pr
oviding multiuser access to a number of databases.

MySQL is owned and sponsored by a single for
-
profit firm, the Swedish company
MySQL AB, which holds the copyright to most of the codebase. This is similar to the
JBoss model. It is dissimilar to the Apache

project, where the software is developed by a
public community and the copyright to the codebase is owned by its individual authors.

The company develops and maintains the system, selling support and service contracts, as
well as proprietary
-
licensed copi
es of MySQL, and employing people all over the world
who collaborate via the Internet. MySQL AB was founded by David Axmark, Allan
Larsson, and Michael "Monty" Widenius. The CEO is Mårten Mickos.

The MySQL company also sells another DBMS, MaxDB, which is f
rom an unrelated
codebase.

Libraries for accessing MySQL databases are available in all major programming
languages with language
-
specific APIs. In addition, an ODBC interface called MyODBC
allows additional programming languages that support the ODBC inte
rface to
communicate with a MySQL database, such as ASP or ColdFusion. The MySQL server
and official libraries are mostly implemented in ANSI C/ANSI C++.


15

MySQL is popular for web applications and acts as the database component of the
LAMP, MAMP, and WAMP p
latforms (Linux/Mac/Windows
-
Apache
-
MySQL
-
PHP/Perl/Python), and for open
-
source bug tracking tools like Bugzilla. Its popularity for
use with web application is closely tied to the popularity of PHP, which is often
combined with MySQL. PHP and MySQL are ess
ential components for running popular
content management systems such as WordPress and Drupal blogging platforms.
Wikipedia runs on MediaWiki software, which can also use PHP and a MySQL database


2.1.h
. AJAX


Ajax, or AJAX is a web development tecnique us
ed for creating interactive web
applications. The intent is to make web pages feel more responsive by exchanging small
amount of data with the server behind the scenes
, so that the entire web page does not
have to be reloaded each time the user requests a
change. This is intended to increase the
web page’s interactivity, speed, functionality and usability.


Ajax is asynchronous in that XML data loading does not interfere with normal HTML
and JavaScript page loading. JavaScript is the programming language in

which Ajax
function calls are made. Data retrieved using the technique is commonly formatted using
XML, as reflected in the naming of the XMLHttpRequest object from which Ajax is
derived.


Ajax is a cross
-
platform tecnique usable on many different operati
ng systems, computer
architecture and Web browsers as it is based on open standards such as JavaScript and
XML, together with open source implementations of other required technologies.


The core justification for Ajax style programming is to overcome the
page loading
requirements of HTML/HTTP
-
mediated web pages. Ajax creates the necessary initial
conditions for the evolution of complex, intuitive, dynamic, data
-
centric user interfaces in
web pages

the realization of that goal is still a work in progress.


16


Web pages, unlike native applications, are loosely coupled, meaning that the data they
display are not tightly bound to data sources and must be first marshaled (set out in
proper order) into an HTML page format before they can be presented to a user agent

on
the client machine. For this reason, web pages have to be re
-
loaded each time a user
needs to view different datasets. By using the XMLHttpRequest object to request and
return data without a re
-
load, a programmer by
-
passes this requirement and makes th
e
loosely coupled web page behave much like a tightly coupled application, but with a
more variable lag time for the data to pass through a longer "wire" to the remote web
browser.


For example, in a classic desktop application, a programmer has the choice

of populating
a tree view control with all the data needed when the form initially loads, or with just the
top
-
most level of data

which would load more quickly, especially when the dataset is
very large. In the second case, the application would fetch add
itional data into the tree
control depending on which item the user selects. This functionality is difficult to achieve
in a web page without Ajax. To update the tree based on a user's selection would require
the entire page to re
-
load, leading to a very j
erky, non
-
intuitive feel for the web user who
is browsing the data in the tree.



Basic Features of Ajax:




AJAX stands for Asynchronous JavaScript And XML.



AJAX is a type of programming made popular in 2005 by Google (with Google
Suggest).



AJAX is not a ne
w programming language, but a new way to use existing
standards.



With AJAX you can create better, faster, and more user
-
friendly web applications.



AJAX is based on JavaScript and HTTP requests.



17





2.2
. Introduction

of The Summer Practice Project


A scrip
t of cinema portal which is consisted of RSS feeds and prepared using Web 2.0
standards is a news portal that lets the user to reach the information about the films and
the dates that films will begin to play.
The information is added to the system by usi
ng
the RSS feeds of existing cinema portals instead of using an editor. All the information is
recorded in database and presented to the user via the portal we will prepare.



2.2
.a.

The parts expected to take place on the pages:


1)

Links to reach the catego
ries

2)

Advertisement fields

3)

Main part where the news is listed

4)

Search and date selection modules

5)

Main page, legal warning and instruction links




2.2
.b
.

Main parts of the site:


1)

Previous films

2)

Coming films

3)

Fragmans and videos

4)

Film posters





18

So the use
rs reach the list of films that had begun to play and will begin to play soon.
They read information and comments about films.
It is also possible to watch the
fragmans and videos belonging to these films.





2.3
. Project Steps




Being able to build HTML

web sites, to understand HTML codes. To use CSS.



Obtaining the ability of making RSS analysis. To check the RSS feeds of example
pages.



Setting up web server and getting knowledge about building dynamic pages.



Preparing database



Forming draft design



Rec
ording the data taken from RSS feeds to database



Showing the data which is taken from database on the page



Preparing search and date selection modules



Combining design and code



Preparing admin tools



Testing










19









3. CONCLUSION


Ceng 400 summer
practice was an opportunit
y to gain some experience in a

Web based
project.
Furthermore, the job we were expected to complete was similar to the jobs done
in the company to some extent. This feature of the summer practice helped us to get over
with our sus
pects and preoccupations about the work life.


In addition, we were not working individually. Our project was held by a team of 5 other
computer engineering student. That taught us team
-
work necessities and how to
collaborate most effectively.


The engin
eers in the company provided enough support during the whole process. They
guided us when we had difficulties which prevents us to improve.


As a result I strongly believe that the practical benefits of the summer practice that I have
completed.






20




4.

APPENDICES


Content of index.php :


<!DOCTYPE

PUBLIC "
-
//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1
-
strict.dtd">

<html lang="tr">

<head>

<meta http
-
equiv="Content
-
Type" content="text/html; charset=UTF
-
8" />

<meta http
-
equiv="Co
ntent
-
Language" content="TR" />

<meta name="Keywords" content="Sinema Fragmanlar RSS feed Film " />

<meta name="Description" content="Sinema ile ilgili guncel haberler" />

<link rel="stylesheet" type="text/css"
href="http://www.basari.dreamhosters.com/alev
/theme.css" />

<title>

Sinema Haberleri

</title>

</head>

<body>


<div id="mainarea">

<table id="toptable">

<tr><td><h1>Sinema Rehberi</h1> </td></tr>

</table>

<table id="lefttable">

<tr height="10%" valign="top">


21

<td>

<form id="searchform" method="get"
act
ion="http://www.basari.dreamhosters.com/alev/search.php">

<label for="searchbox"> Ara </label>

<input size="10" class="sbox" name="sphrase" />

<br />

<input type="submit" value="Ara!" class="button" />

</form>

</td>

</tr>

<tr height="2%"><td> <hr /></td></
tr>

<tr height="5%">

<td>

<a href="http://www.basari.dreamhosters.com/alev/index.php?cat=yerli"
class="l1">Yerli Sinema</a>

</td>

</tr>

<tr height="5%">

<td>

<a href="http://www.basari.dreamhosters.com/alev/index.php?cat=yabanci"
class="l1">Yabanci Sinema<
/a>

</td>

</tr>

<tr><td> </td></tr>

</table>

<table id="righttable">

<tr><td> Reklamlar </tr></td>

</table>

<table id="centertable">

<?php



22

$cat = $_GET['cat'] ? $_GET['cat'] : "all";

$con = mysql_connect("mysql.basari.dreamhosters.com", "basari_staj", "xF
Ua7AWv");

if(!$con)

{


die("Can't connect to the database.<p> " . mysql_error());

}


$selected_db = mysql_select_db("alev", $con);

if(!$selected_db)

{


die("Can't select the database. <p>" . mysql_error());

}


$reqPage = $_GET['req'] ? (int) $_GET['req']

: 1;

$nElems = $_GET['p'] ? (int) $_GET['p'] : 10;


$where_string = ($cat != "all") ? "WHERE Category LIKE '%$cat%'" : "";

$query = "SELECT * FROM sinema $where_string ORDER BY Date DESC";


$rs = mysql_query($query);

$nRows = mysql_num_rows($rs) / $nElem
s;


echo '<th align="left">';

if($reqPage > 1)

{


$nReqPage = $reqPage
-

1;


echo "<A
href=
\
"http://www.basari.dreamhosters.com/alev/index.php?req=$nReqPage&p=$nElems
\
"> &lt </A>";

}

else


23


echo '< ';


for($i = 1; $i < $nRows + 1; $i++)

{


echo "<A
href
=
\
"http://www.basari.dreamhosters.com/alev/index.php?req=$i&p=$nElems
\
">$i
</A>";

}


if($reqPage < $nRows)

{


$nReqPage = $reqPage + 1;


echo "<A
href=
\
"http://www.basari.dreamhosters.com/alev/index.php?req=$nReqPage&p=$nElems
\
"> &gt </A>";

}

else


ech
o ' >';

$startVal = ($reqPage
-

1) * $nElems + 1;

$endVal = ($startVal + $nElems
-

1) < mysql_num_rows($rs) ? ($startVal + $nElems
-

1)
: mysql_num_rows($rs);


echo "Showing results [$startVal
-
$endVal]";

echo '</th>';



if(mysql_data_seek($rs, ($reqPage
-

1) * $nElems))

{


$i = 0;


while( ($row = mysql_fetch_array($rs)) && ($i < $nElems))


{


24


$link_id = "link" . $i;


echo '<tr> <td class="resultcell"><A href="'. $row['Link'] . '" class="l1">' .
$row['Title'] . '</A> </td>'. '<td width="10%" class=
"resultcell" align="right">'.
$row['Date'] . '</td></tr>' . "
\
n";


echo '<tr> <td colspan="2">' . $row['Description'];


echo '<p/> Source: <A class="l1" id=' . '"'. $link_id .'" ' . 'href=' . $row['Site']. ">".
$row['Site']. "</A>
\
n<br/>&nbsp &nbsp";



echo '</td> </tr>';



$i++;


}

}



?>


</table>

</div>


</body

</html>











25

Content of search.php:


<!DOCTYPE

PUBLIC "
-
//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1
-
strict.dtd">

<html lang="tr">

<head>

<meta http
-
eq
uiv="Content
-
Type" content="text/html; charset=UTF
-
8" />

<meta http
-
equiv="Content
-
Language" content="TR" />

<meta name="Keywords" content="Sinema Fragmanlar RSS feed Film " />

<meta name="Description" content="Sinema ile ilgili guncel haberler" />

<link r
el="stylesheet" type="text/css"
href="http://www.basari.dreamhosters.com/alev/theme.css" />

<title>

Sinema Haberleri

</title>

</head>

<body>


<div id="mainarea">

<table id="toptable">

<tr><td> <h1>Sinema Rehberi</h1> </td></tr>

</table>

<table id="lefttabl
e">

<tr height="10%" valign="top">

<td>

<form id="searchform" method="get"
action="http://www.basari.dreamhosters.com/alev/search.php">

<label for="searchbox"> Ara </label>

<input size="10" class="sbox" name="sphrase" />


26

<br />

<input type="submit" value="
Ara!" class="button" />

</form>

</td>

</tr>

<tr height="2%"><td> <hr /></td></tr>

<tr height="5%">

<td>

<a href="http://www.basari.dreamhosters.com/alev/index.php?cat=yerli"
class="l1">Yerli Sinema</a>

</td>

</tr>

<tr height="5%">

<td>

<a href="http://www.
basari.dreamhosters.com/alev/index.php?cat=yabanci"
class="l1">Yabanci Sinema</a>

</td>

</tr>

<tr><td> </td></tr>

</table>

<table id="righttable">

<tr><td> Reklamlar </tr></td>

</table>

<table id="centertable">


<?php


$con = mysql_connect("mysql.basari.dr
eamhosters.com", "basari_staj", "xFUa7AWv");

if(!$con)

{


die("Can't connect to the database.<p> " . mysql_error());


27

}


$selected_db = mysql_select_db("alev", $con);

if(!$selected_db)

{


die("Can't select the database. <p>" . mysql_error());

}


$sphrase
= $_GET['sphrase'] ? mysql_real_escape_string($_GET['sphrase']) : "*";

$searchin = $_GET['sin'] ? $_GET['sin'] : 1;

$sortby = $_GET['sortby'] ? 'Title' : 'Date';

$order = $_GET['order'] ? 'ASC' : 'DESC';

$reqPage = $_GET['req'] ? (int) $_GET['req'] : 1;

$n
Elems = $_GET['p'] ? (int) $_GET['p'] : 10;

//1
-
>title 2
-
>description 3
-
>title and description


$where_string = (( ($searchin == 3) || ( $searchin == 1)) ? "Title LIKE '%$sphrase%'" :
"") .

((($searchin == 3) ? " OR " : "")) .

((($searchin == 2) || ($searc
hin == 3)) ? "Description LIKE '%$sphrase%'" : "");


$query = "SELECT * FROM sinema" . (($sphrase == "*") ? "" : " WHERE
$where_string") . " ORDER BY $sortby $order";


$rs = mysql_query($query);

$nRows = mysql_num_rows($rs) / $nElems;


echo '<th align="
left">';

if($reqPage > 1)

{


$nReqPage = $reqPage
-

1;


28


echo "<A
href=
\
"http://www.basari.dreamhosters.com/alev/search.php?sphrase=$sphrase&req=$nR
eqPage&p=$nElems
\
"> &lt </A>";

}

else


echo '< ';


for($i = 1; $i < $nRows + 1; $i++)

{


echo "<A
href=
\
"
http://www.basari.dreamhosters.com/alev/search.php?sphrase=$sphrase&req=$i&
p=$nElems
\
">$i </A>";

}


if($reqPage < $nRows)

{


$nReqPage = $reqPage + 1;


echo "<A
href=
\
"http://www.basari.dreamhosters.com/alev/search.php?sphrase=$sphrase&req=$nR
eqPage&p=$
nElems
\
"> &gt </A>";

}

else


echo ' >';

$startVal = ($reqPage
-

1) * $nElems + 1;

$endVal = ($startVal + $nElems
-

1) < mysql_num_rows($rs) ? ($startVal + $nElems
-

1)
: mysql_num_rows($rs);


echo "Showing results [$startVal
-
$endVal]";

echo '</th>';




29

if
(mysql_data_seek($rs, ($reqPage
-

1) * $nElems))

{


$i = 0;


while( ($row = mysql_fetch_array($rs)) && ($i < $nElems))


{


$link_id = "link" . $i;


echo '<tr> <td class="resultcell"><A href="'. $row['Link'] . '" class="nav3">' .
$row['Title'] . '<
/A> </td>'. '<td width="10%" class="resultcell" align="right">'.
$row['Date'] . '</td></tr>' . "
\
n";


echo '<tr> <td colspan="2">' . $row['Description'];


echo '<p/> Source: <A class="nav2" id=' . '"'. $link_id .'" ' . 'href=' . $row['Site']. ">".
$r
ow['Site']. "</A>
\
n<br/>&nbsp &nbsp";


echo '</td> </tr>';


$i++;


}

}


?>

</table>

</div>

</body>

</html>




Content of updatedb.php:


<html>

<body>



30

<?php

require('simplepie.inc');


$handle = fopen("sitelist", "r");

$handle2 = fopen("category", "r
");


if($handle && $handle2)

{


while(!feof($handle))


{


$sitename = fgets($handle, 512);


$category = fgets($handle2, 256);

$max_quantity = 100;

$rss_feed = new SimplePie();

$rss_feed
-
>set_feed_url($sitename);

$rss_feed
-
>enable_cache(true);

$rss_feed
-
>
init();

$rss_feed
-
>handle_content_type();


$current_site = $sitename;


$con = mysql_connect("mysql.basari.dreamhosters.com", "basari_staj", "xFUa7AWv");


if(!$con)

{


echo mysql_error();

}


echo 'Connected to the database. <br>';


$selected_db = mysql_sel
ect_db("alev");


31


if(!$selected_db)

{


die("<b>Can't select database </b>".mysql_error()."<br />");

}


$affected_rows = 0;

if($rss_feed
-
>data) {


$count = $rss_feed
-
>get_item_quantity($max_quantity);



for($i = 0; $i < $count; $i++)


{


$current_item =

$rss_feed
-
>get_item($i);


$title = mysql_real_escape_string($current_item
-
>get_title());


$link = mysql_real_escape_string($current_item
-
>get_link());


$rdate = $current_item
-
>get_date();


$timeval = strtotime(substr($rdate, 0, strpos($rdate, ",")))
;



$date = date("Y
-
m
-
d", $timeval);



$description = mysql_real_escape_string($current_item
-
>get_description());


$author = mysql_real_escape_string("None");


$site = mysql_real_escape_string($current_site);


$image = mysql_real_escape_string("None");




$query = "SELECT * FROM sinema WHERE Title='$title' AND
Description='$description'";




$rs = mysql_query($query);




if(!mysql_num_rows($rs))


32


{


$affected_rows++;


$query = "INSERT INTO sinema
(Author, Title, Description, Link, Site, Date, Image,
Category) VALUES ('$author', '$title', '$description', '$link', '$site', '$date', '$image',
'$category')";




$rs = mysql_query($query);


}


if(!$rs)


{


die("Can't execute the query:<br />".$
query."<br />".mysql_error());


}



}

echo "$affected_rows items are added to the database.<br>";

}


}

fclose($handle);

fclose($handle2);

}

else

{


echo "Can't open sitename file!<br />";

}

?>

</body>

</hmtl>





33



5. REFERENCES


simplepie.org/

www.php.ne
t/

www.w3schools.com/rss/default.asp

www.mnot.net/rss/tutorial/

htmlhelp.com/reference/css/

www.westciv.com/style_master/academy/css_tutorial/

http://ajaxian.com/

msdn.microsoft.com/xml/

The Web Wizard’s Guide To XML, Hughes, Addison Wesley, 2002.