Смекни!
smekni.com

Автоматизація процесу обліку (стр. 4 из 5)

font-size: 10pt;

}

.foo {

font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;

font-size: 8pt;

color: #A9A9A9;

}

db.php

<?php

class db {

var $dbl;

var $res;

function db($host="localhost",$user="lus",$pass="1")

{

$this->dbl = mysql_pconnect($host,$user,$pass);

mysql_select_db("lus", $this->dbl);

}

function query($q)

{

$this->res = mysql_query($q, $this->dbl);

return $this->res;

}

function num_rows()

{

return mysql_num_rows($this->res);

}

function fetch_row()

{

return mysql_fetch_row($this->res);

}

function fetch_array()

{

return mysql_fetch_array($this->res,MYSQL_ASSOC);

}

function fetch_object()

{

return mysql_fetch_object($this->res);

}

function insert_id()

{

return mysql_insert_id($this->dbl);

}

function is_result()

{

return $this->res ? 1 : 0;

}

}

?>

forms/afftar.html

<form action="../scripts/afftar.php">

<table class=text>

<tr>

<td colspan=2 align="center" class=h1>Додати/видалити автора<br><br></td>

</tr>

<tr>

<td>Ім'я</td>

<td><input type="text" name="fname" size="15" maxlength="30"></td>

</tr>

<tr>

<td>По-батькові:</td>

<td><input type="text" name="lname" size="15" maxlength="30"></td>

</tr>

<tr>

<td>Прізвище:</td>

<td><input type="text" name="sname" size="15" maxlength="30"></td>

</tr>

<tr>

<td>email:</td>

<td><input type="text" name="address" size="15" maxlength="30"></td>

</tr>

<tr>

<td align="center" colspan="2"><input type="submit" name="add" value="Додати автора"></td>

</tr>

</table>

</form>

scripts/afftar.php

<?php include("../header.inc.html"); echo myheader("Автор") ?>

<div align=center>

<?php

require "../db.php";

include "../forms/afftar.html";

$db = new db();

if(isset($_GET['add'])) {

$fn = $_GET['fname'];

$ln = $_GET['lname'];

$sn = $_GET['sname'];

$a = $_GET['address'];

$db->query("INSERT INTO dev(first_name, last_name, surname, addr)

VALUES ('$fn','$ln','$sn','$a') ");

} elseif(isset($_GET['del'])) {

foreach($_GET['delarr'] as $arr){

$db->query("DELETE FROM dev

WHERE id = $arr ");

}

}

?>

<div class=h2>Зареєстровані автори</div>

<form action=<?php print $PHP_SELF; ?> >

<table style="border: 1px solid black; " cellpadding=3 cellspacing=1 class=text>

<tr bgcolor="#c0c0c0">

<td>&nbsp</td>

<td align="center">Ім'я</td>

<td align="center">По-батькові</td>

<td align="center">Прізвище</td>

<td align="center">email</td>

</tr>

<?php

$db->query("SELECT id, first_name,last_name,surname,addr FROM dev");

while($arr=$db->fetch_array()){

echo "<tr>";

foreach($arr as $key=>$val){

if($key=='id') $val = "<input type=checkbox name=delarr[] value=$val>";

if ($key=='addr') $val = "<a href=&bsol;"mailto:$val&bsol;">$val</a>";

echo "<td bgcolor=&bsol;"#dcdcdc&bsol;" align=&bsol;"center&bsol;">".$val."</td>";

}

echo "</tr>";

}

?>

<tr><td colspan="5" align="center"><input type="submit" name="del" value="Видалити автора"></td></tr>

</table>

</form>

</div>

<?php include("../footer.inc.html"); ?>

forms/distr.html

<form action="../scripts/distr.php">

<table class=text>

<tr>

<td colspan=2 align="center" class=h1>Add/Del distr<br><br></td>

</tr>

<tr>

<td>Ім'я</td>

<td><input type="text" name="name" size="15" maxlength="30"></td>

</tr>

<tr>

<td>Версія:</td>

<td><input type="text" name="version" size="15" maxlength="30"></td>

</tr>

<tr>

<td>Адрес:</td>

<td><input type="text" name="address" size="15" maxlength="30"></td>

</tr>

<tr>

<td><input type="submit" name="add" value="Додати distr"></td>

<td><input type="submit" name="del" value="Видалити distr"></td>

</tr>

</table>

</form>

scripts/distr.php

<?php include("../header.inc.html"); echo myheader("Дістр") ?>

<div align=center>

<?php

include "../forms/distr.html";

require ("../db.php");

$db = new db();

if(isset($_GET['add'])) {

$n = $_GET['name'];

$v = $_GET['version'];

$a = $_GET['address'];

$db->query("INSERT INTO distr(name, version, addr)

VALUES ('$n','$v','$a') ");

} elseif(isset($_GET['del'])) {

foreach($_GET['delarr'] as $arr){

$db->query("DELETE FROM distr

WHERE id = $arr ");

}

}

?>

<div class=h2>Наявні дистрибутиви</div>

<form action=<?php print $PHP_SELF; ?> >

<table style="border: 1px solid black; " cellpadding=3 cellspacing=1 class=text>

<tr bgcolor="#c0c0c0">

<td align="center">&nbsp;</td>

<td align="center">Назва</td>

<td align="center">Версія</td>

<td align="center">ftp-адреса</td>

</tr>

<?php

$db->query("SELECT id,name,version,addr FROM distr");

while($arr=$db->fetch_array()){

echo "<tr>";

foreach($arr as $key=>$val) {

if ($key=='id') $val = "<input type=checkbox name=delarr[] value=$val>";

if ($key=='addr') $val = "<a href=&bsol;"ftp://$val&bsol;">$val</a>";

echo "<td bgcolor=&bsol;"#dcdcdc&bsol;" align=&bsol;"center&bsol;">".$val."</td>&bsol;n";

}

echo "</tr>";

}

?>

<tr><td align="center" colspan=4><input type="submit" name="del" value="Видалити відмічені"></td></tr>

</table>

</form>

</div>

<?php include("../footer.inc.html"); ?>

forms/pz.html

<<form action="../scripts/pz.php">

<table class=text>

<tr>

<td colspan=2 align="center" class=h1>Додати/Видалити ПЗ<br><br></td>

</tr>

<tr>

<td>Назва</td>

<td><input type="text" name="name" size="15" maxlength="30"></td>

</tr>

<tr>

<td>Версія:</td>

<td><input type="text" name="version" size="15" maxlength="30"></td>

</tr>

<tr>

<td>Дата:</td>

<td><input type="text" name="date" size="15" maxlength="30"></td>

</tr>

<tr>

<td>Дистрибутив:</td>

<td>

<select name=distr>

<?php

$db->query("SELECT id,name,version FROM distr");

while ( $arr = $db->fetch_array() ) {

$tmp = $arr['id'];

$tmpname = $arr['name']." - ".$arr['version'];

echo "<option value=$tmp>$tmpname";

}

?>

</select>

</td>

</tr>

<tr>

<td>Автор:</td>

<td>

<select name=author>

<?php

$db->query("SELECT id,first_name,surname FROM dev");

while($arr=$db->fetch_array()) {

$tmp = $arr['id'];

$tmpname = $arr['first_name']." ".$arr['surname'];

echo "<option value=$tmp>$tmpname";

}

?>

</select>

</td>

</tr>

<tr>

<td>Ліцензія:</td>

<td><input type="text" name="licence" size="15" maxlength="30"></td>

</tr>

<tr>

<td>ftp-адреса:</td>

<td><input type="text" name="address" size="15" maxlength="30"></td>

</tr>

<tr>

<td colspan=2 align="center"><input type="submit" name="add" value="Додати ПЗ"></td>

</tr>

</table>

</form>

scripts/pz.php

<?php include("../header.inc.html"); echo myheader("ПЗ") ?>

<?php

require ("../db.php");

$db = new db();

?>

<div align="center">

<?php

include "../forms/pz.html";

if(isset($_GET['add'])) {

$n = $_GET['name'];

$v = $_GET['version'];

$d = $_GET['date'];

$l = $_GET['licence'];

$n_d=$_GET['distr'];

$n_a=$_GET['author'];

$a = $_GET['address'];

$db->query("INSERT INTO pz(name, version, dev_id, distr_id, date, licence, addr)

VALUES ('$n','$v', '$n_a', '$n_d', DATE '$d', '$l', '$a') ");

} elseif(isset($_GET['del'])) {

foreach($_GET['delarr'] as $arr){

$tmp = explode (":",$arr);

$db->query("DELETE FROM pz

WHERE name = '$tmp[0]'

AND version = '$tmp[1]' ");

}

}

?>

<div class=h2>Наявне ПЗ</div>

<form action=<?php print $PHP_SELF; ?> >

<table style="border: 1px solid black" cellpadding=3 cellspacing=1 class=text>

<tr bgcolor="#c0c0c0" class=>

<td>&nbsp;</td>

<td align="center">Назва</td>

<td align="center">Версія</td>

<td align="center">Датa</td>

<td align="center">Ліцензія</td>

<td align="center">ftp-адреса</td>

<td align="center" colspan=2>Розробник</td>

<td align="center">Дистрибутив</td>

<td align="center">ftp-aдреса дистрибутива</td>

</tr>

<?php

$db->query("SELECT pz.name, pz.version,pz.date,pz.licence,pz.addr, dev.first_name,

dev.surname,distr.name AS name1, distr.addr AS address

FROM pz,dev, distr

WHERE (pz.dev_id=dev.id AND pz.distr_id=distr.id )");

while($arr=$db->fetch_array()){

echo "<tr>";

$tmp=$arr['name'].":".$arr['version'];

$val = "<input type=checkbox name=delarr[] value=&bsol;"$tmp&bsol;">";

echo "<td bgcolor=&bsol;"#dcdcdc&bsol;" align=&bsol;"center&bsol;">".$val."</td>&bsol;n";

foreach($arr as $key=>$val){

if (($key=='addr') || ($key=='address')) $val = "<a href=&bsol;"ftp://$val&bsol;">$val</a>";

echo "<td bgcolor=&bsol;"#dcdcdc&bsol;" align=&bsol;"center&bsol;">".$val."</td>&bsol;n";

}

echo "</tr>";

}

?>

<tr><td colspan=10 align=center><input type="submit" name="del" value="Видалити ПЗ"></td></tr>

</table>

</form>

</div>

<?php include("../footer.inc.html"); ?>

if(isset($_GET['add'])) {

$n = $_GET['name'];

$v = $_GET['version'];

$d = $_GET['date'];

$l = $_GET['licence'];

$n_d=$_GET['distr'];

$n_a=$_GET['author'];

$a = $_GET['address'];

$db->query("INSERT INTO pz(name, version, dev_id, distr_id, date, licence, addr)

VALUES ('$n','$v', '$n_a', '$n_d', DATE '$d', '$l', '$a') ");

} elseif(isset($_GET['del'])) {

$db->query("DELETE FROM distr

WHERE name = '$n'

AND version = '$v' ");

}

?>

</div>

<?php include("../footer.inc.html"); ?>

forms/sAName.html

<form action="../scripts/sAName.php">

<table class=text>

<tr>

<td colspan=2 align="center" class=h1>Пошук авторa<br><br></td>

</tr>

<tr>

<td>Прізвище автора:</td>

<td><input type="text" name="surname" maxlength="60"></td>

</tr>

<tr>

<td colspan=2 align=center>

<input type="submit" name="search" value="Пошук!">

</td>

</tr>

</table>

</form>

scritps/sAName.php

<?php include("../header.inc.html"); echo myheader("Пошук по автору") ?>

<div align="center">

<?php

include "../forms/sAName.html";

$name = $_GET['surname'];

require ("../db.php");

$db =new db();

##########

$db->query("SELECT dev.first_name, dev.last_name, dev.surname,dev.addr

FROM dev

WHERE dev.surname = &bsol;"$name&bsol;" ");

?>

<table style="border: 1px solid black; " cellpadding=3 cellspacing=1 class=text>

<tr bgcolor="#c0c0c0">

<td align="center">Ім'я</td>

<td align="center">По-батькові</td>

<td align="center">Прізвище</td>

<td align="center">Адреса</td>

</tr>

<?php

while($arr=$db->fetch_array()){

echo "<tr>";

foreach($arr as $key=>$val)

echo "<td bgcolor=&bsol;"#dcdcdc&bsol;" align=&bsol;"center&bsol;">".$val."</td>";

echo "</tr>";

}

?>

</table>

</div>

<?php include("../footer.inc.html"); ?>

forms/sAuthor.html

<form action="../scripts/sAuthor.php">