Autor Zpráva
C.Ronaldo7
Profil *
http://www.ofk-krnca.ic.cz/mail/mail1/index.php tot je link na ten insex v php uz som skusil vse ale nechce to stale ist a totoje script vo functoinse
<?php

function html_header()
{
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Webmail</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1250" />
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="middle"><a href="new.php">Nová správa</a> &middot; <a href="index.php">Došlé správy</a> &middot; <a href="sent.php">Odoslané správy</a> &middot; <a href="select_address.php">Nová správa - výber adries</a> &middot; <a href="insert_address.php">Adresár</a> &middot; <a href="delete_address.php">Vymazať kontakt</a></div>
<?php
}

function html_footer()
{
?>
</body>
</html>
<?php
}

function db_connect()
{
$result = mysql_connect("localhost:3306","ado",""); // pripojíme sa
if(!$result)
return false;

if(!mysql_select_db("database.sql")) // vyberieme databázu
return false;

return $result;
}

function open()
{
global $userid;
db_connect();
$query = "select * from accounts where userid = '$userid'";
$result = mysql_query($query);
$num_result = mysql_num_rows($result);
if($num_result>0):
$user = mysql_result($result,0,"user");
$password = mysql_result($result,0,"pass");
$servername = mysql_result($result,0,"servername");
$port = mysql_result($result,333,"port");
$type = mysql_result($result,0,"type");
$mailbox = "{".$servername.":".$port."/".$type."}INBOX";
$open = imap_open($mailbox,$user,$password);
return $open;
else:
echo "<div class='warning' align='center'>Nepodarilo sa pripojiť.</div>";
return;
endif;
}

function address()
{
global $userid;
db_connect();
$query = "select * from accounts where userid = '$ado";
$result = mysql_query($query);
$num_result = mysql_num_rows($result);
if($num_result>0) $address = mysql_result($result,0,"address");
return $address;
}

function name()
{
global $userid;
db_connect();
$query = "select * from accounts where userid = '$userid'";
$result = mysql_query($query);
$num_result = mysql_num_rows($result);
if($num_result>0) $name = mysql_result($result,0,"name");
return $name;
}

function list_of_messages()
{
global $userid;
$imap = open();
if(!$imap) return false;

$sorted = imap_sort($imap, SORTARRIVAL, 1); // zoradíme správy
$headers = imap_headers($imap);
$count = count($headers);
echo "<div class='middle'>Počet správ: ".$count."</div><br />";

if($count>0):

?>
<form action="delete.php" method="post">
<table cellpadding="4" cellspacing="0" border="0" width="725">
<tr>
<td></td>
<td></td>
<td width="250"><div class="middle" align="left">Odosielateľ</div></td>
<td width="175"><div class="middle" align="left">Predmet</div></td>
<td width="150"><div class="middle" align="left">Dátum</div></td>
<td width="25"><div class="middle" align="left">Re</div></td>
<td width="25"><div class="middle" align="left">Fw</div></td>
<td width="50"><div class="middle" align="left">Kontakty</div></td>
</tr>
<?php
for($i=0;$i<$count;$i++)
{
$id = $sorted[$i];
$header = imap_header($imap, $id);

$from = $header->from[0];
$adresa = $from->mailbox."@".$from->host;
$message['udate'] = $header->udate;
$message['size'] = $header->size;

$subject = imap_mime_header_decode($header->Subject);
$subject = $subject[0]->text;

$from = imap_mime_header_decode($header->fromaddress);
$from = $from[0]->text;

// zistíme, či mail obsahuje aj prílohy
$structure = imap_fetchstructure($imap, $id);
$parts = $structure->parts;
$num_parts = sizeof($parts);
if($num_parts>0) $attachment = 1; // príloha existuje
else $attachment = 0; // príloha neexistuje

if(($i%2)==1) echo "<tr bgcolor='DDDDDD'>";
else echo "<tr bgcolor='AAAAAA'>";
echo "<td><input type='checkbox' name='id[]' value='$id' /></td>";
echo $attachment == 1 ? "<td><a title='príloha'><img src='images/attachment.gif' /></a></td>" : "<td></td>"; // ak je príloha, zobrazíme ikonu
echo "<td><div align='left' class='middle'><a href='read.php?id=".$id."' title='$adresa'>".$from."</a></div></td>";
echo "<td><div align='left' class='middle'><a href='read.php?id=".$id."'>".$subject."</a></div></td>";
echo "<td><div align='left' class='middle'><a href='read.php?id=".$id."'>".date("j.n.Y H:i",$message['udate'])."</a></div></td>";
echo "<td><div align='left' class='middle'><a href='reply.php?id=".$id."' title='odpovedať'>Re</a></div></td>";
echo "<td><div align='left' class='middle'><a href='forward.php?id=".$id."' title='preposlať'>Fw</a></div></td>";
echo "<td><div align='left' class='middle'><a href='insert_address.php?mail=".$adresa."'>pridať</a></div></td>";
echo "</tr>";
}
?>
</table>
<br />
<button type="submit" class="button">Vymazať</button>
</form>
<?php
endif;
}

function read_message($id)
{
global $userid;
$imap = open();
if(!$imap) return false;

$header = imap_header($imap, $id);

$from = $header->from[0];
$adresa = $from->mailbox."@".$from->host;
$odosielatel = $from->personal;

// adresa odosielateľa
if(!empty($odosielatel) && $odosielatel != $adresa) $from_address = "$odosielatel < $adresa >";
else $from_address = $adresa;

$subject = imap_mime_header_decode($header->Subject);
$subject = $subject[0]->text;

$from = imap_mime_header_decode($header->fromaddress);
$from = $from[0]->text;

$from_address = $from." &lt;".$adresa."&gt;";

$message['udate'] = $header->udate; // dátum a čas
$message['header'] = imap_fetchheader($imap, $id);
$message['toaddress'] = $header->toaddress;
$message['ccaddress'] = $header->ccaddress;
$message['udate'] = $header->udate;

$structure = imap_fetchstructure($imap, $id);
$encoding = $structure->encoding;
$parts = $structure->parts;

$num_parts = sizeof($parts); // kolko má správa častí

// zobrazíme správu
?>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td width="10%"><div class="middle" align="left">Odosielateľ:</div></td>
<td width="25%"><div class="middle" align="left"><?php echo $from_address?></div></td>
<td></td>
</tr>
<tr>
<td><div class="middle" align="left">Príjmateľ:</div></td>
<td><div class="middle" align="left"><?php echo $message['toaddress']?></div></td>
<td></td>
</tr>
<tr>
<td><div class="middle
WanTo
Profil
Uživatel ado buď neexistuje nebo nemá právo připojit se k databázi.
C.Ronaldo7
Profil *
no a je to sak mi to vysvetli nie?
C.Ronaldo7
Profil *
pls pomoc
Hugo
Profil
mysql_connect("localhost:3306","ado","");

Tady jsi to heslo vymazal nebo se zkoušíš připojit bez hesla? Zkontroluj si jestli máš v té funkci správné údaje. Informace bys měl najít někde v nastavení hostingu.
C.Ronaldo7
Profil *
ale sakra ja som s tymito funkciami novacik a neviem co s tym sakra ma to stve bo uz nat tym sedimm 6 hodin a stale nic mas icq by som ti poslal veci a by si to len upravil prosim .. diky napis icq alebo nieco take
dik hugo...
WanTo
Profil
C.Ronaldo7
Ten skript pravděpodobně funguje jak má. Jediný problém je v připojení k databázi. Prostě se připojuješ se špatným loginem nebo heslem, to je vše.
C.Ronaldo7
Profil *
# MySQL databßza - Webmail

# tabużka ˙Ŕty
create table accounts
(
id int not null auto_increment primary key,
userid int not null,
name varchar(150) not null,
address varchar(150) not null,
user varchar(100),
pass varchar(100),
servername varchar(100),
port varchar(10),
type varchar(10)
);

# tabużka odoslanß poÜta
create table sent
(
id int not null auto_increment primary key,
userid int not null,
to_address varchar(150),
subject varchar(150),
message text,
date int
);

# tabużka adresßr
create table address
(
id int not null auto_increment primary key,
userid int not null,
name varchar(150),
mail varchar(150)
);
C.Ronaldo7
Profil *
to je database
WanTo
Profil
C.Ronaldo7
Ten SQL zdroják je taky v pořádku.


Problém je v připojení k databázovému serveru. Už vážně nevím, jak ti to mám vysvětlit.
C.Ronaldo7
Profil *
sakra ale sak vsetko je ok
uz ani ja neviem kde je chyba
Hugo
Profil
C.Ronaldo7

Musíš si zjistit tyto údaje:
server na kterém běží mysql (jméno), tvůj login a heslo. Potom je zadáš do té funkce.

Pokud nechápeš ani toto, tak bude opravdu lepší, když si nejdřív něco nastuduješ. Protože jinak se ti sice může podařit tu aplikaci rozjet, ale pravděpodobně bude hodně špatně zabezpečená. A to se ti na netu nemusí vyplatit. Věřmi, vím o čem mluvím.

Neber to nijak špatně, nechci se tě nijak dotknout, ale je skutečně lepší hledat odpovědi v literatuře a ne tady na fóru.
C.Ronaldo7
Profil *
ja viem lenze vies ked ti niekto poradi po tom co stale citas 6 hodin ti aspon stupne troska sebavedomie
Hugo
Profil
Ale tady už se řešení problému objevilo několikrát. Ale ty používáš funkce, u kterých neznáš použití. A to je potom dost problematické. Podívej se do manuálu na popis jednotlivých funkcí a jejich argumentů. Pak bys měl řešení vidět bez problémů.
C.Ronaldo7
Profil *
http://www.ofk-krnca.ic.cz/mail/mail1/index.php uz je tam menej chyb ale stale su tam nejake dve :(
Hugo
Profil
Je to v podstatě jen jedna chyba. Máš špatně cestu k souboru functions.php.
C.Ronaldo7
Profil *
ok diky dufam ze najdem :)
C.Ronaldo7
Profil *
<?php
session_start();
require "../functions.php";
html_header();
list_of_messages();
html_footer();
?>

a takto nejak to vyzera v index.php
Hugo
Profil
A proč to sem dáváš? Prostě si tam uprav cestu k tomu souboru, tak aby odpovídala realitě. S tím ti tady nikdo nemůže pomoct, protože nevíme jak to vypadá u tebe na serveru.
mag
Profil *
sak mu pomozte kukajte chudak nemoze si s tym dat rady ...
mag
Profil *
ja ti dam heslo na server len mi napis mail tvoj
Lipo
Profil *
Chlapi rozběhali jste to prosím? Mám ten samý kód stažený z Intervalu.cz a nemůžu stáhnout příchozí poštu:

Warning: imap_open(): Couldn't open stream *************************** in /srv1/www/xxxyyy.cz/subdomains/webmail/functions.php on line 54
Lipo
Profil *
No tak místo hvězdiček tam je
{b03.banan.cz:143/imap4}INBOX 
Toto téma je uzamčeno. Odpověď nelze zaslat.

0