Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Sonda
Forum PHP.pl > Forum > Gotowe rozwiązania
Majcok12
Mam problem ze skryptem sondy. Sonda dziala, ale za kazdym razem pojawia sie blad

Kod
Warning: date(): Windows does not support dates prior to midnight (00:00:00), January 1, 1970 in c:usrkrasnalwwwmajcok12pollvotepollvoteincpollfunctions.php on line 130



Warning: date(): Windows does not support dates prior to midnight (00:00:00), January 1, 1970 in c:usrkrasnalwwwmajcok12pollvotepollvoteincpollfunctions.php on line 132


a ten plik pollfunctions.php wyglada nastepujaco

[php:1:4c602db244]
<?php
include ("inc/textfileio.php");

function getIp() {
$remoteip = $_SERVER["REMOTE_ADDR"];
return $remoteip;
}


//votes aus $pollname.".tmp" auswerten...
function readPoll($pollname){
GLOBAL $items;
GLOBAL $ips;
GLOBAL $timestamps;
$votes = csv2array($pollname.".tmp");
for ($i = 0; $i < count($votes); $i++) {
$item = explode(";", $votes[$i]);
if ($item != "")
{$items[$i] = $item[0];
$ips[$i] = $item[1];
$timestamps[$i] = $item[2];
}
}
}


//Stimmen Zählen
//$items-Einträge mit $pollitems[$i] vergleichen
function countItems(){
GLOBAL $items;
GLOBAL $pollitems;
$pollitemsvalues = array();
$pollitemsvalues = $pollitems;
for ($i = 0; $i < count($pollitems); $i++) {
if (is_string($pollitemsvalues[$i])){
$pollitemsvalues[$i] = 0;
}
for ($j = 0; $j < count($items); $j++) {
if ($items[$j] == $pollitems[$i]){
$pollitemsvalues[$i] = $pollitemsvalues[$i] + 1;
}
}
}
return $pollitemsvalues;
}


// Quoten berechnen
function getPercent(){
GLOBAL $pollitemsvalues;
$total = 0;
$pollitemspercent = array();
$pollitemspercent = $pollitemsvalues;
for ($i = 0; $i < count($pollitemsvalues); $i++) {
$total = $total + $pollitemsvalues[$i];
}

for ($i = 0; $i < count($pollitemsvalues); $i++) {
if ($total == 0){
$total = 1;}
$pollitemspercent[$i] = round((100 * $pollitemsvalues[$i])/$total);
}
return $pollitemspercent;
}

//Check the limits
//duration of the poll in days: $duration = 365;
// checkDuration() --> TRUE FALSE
function checkDuration(){
GLOBAL $timestamps;
GLOBAL $duration;
GLOBAL $finished_by_duration;
$starttime = $timestamps[0];
if ($starttime == ""){
return TRUE;}
$thistime = time();
// 1 Tag in Sekunden = 86400;
$durationinsec = $duration * 86400;
$timespan = $thistime - $starttime;
if ($timespan < $durationinsec){
return TRUE;}
else {
echo "<center><font class="maxReachedMessage">".$finished_by_duration."</font></center><BR>";
return FALSE;}
}



// checkMaxPerItem() --> TRUE FALSE
function checkMaxPerItem(){
GLOBAL $maxperitem;
GLOBAL $finished_by_maxperitem;
$pollitemsvalues = array();
$pollitemsvalues = countItems();
for ($i = 0; $i <= count($pollitemsvalues); $i++){
if ($pollitemsvalues[$i] >= $maxperitem){
echo "<center><font class="maxReachedMessage">".$finished_by_maxperitem."</font></center><BR>";
return FALSE;
}
}
return TRUE;
}

//timeout untill next possible vote per IP in sec: $nextvoteperip = 60;
// checkNextVotePerIp() --> TRUE FALSE
function checkNextVotePerIp(){
GLOBAL $nextvoteperip;
GLOBAL $ips;
GLOBAL $timestamps;
GLOBAL $finished_by_voteperip;
$thisip = getIp();
$thistime = time();
for ($i = count($ips); $i >= 0; $i--){
if ($thisip == $ips[$i]){
$ipstime = $timestamps[$i];
$i = -1;
}
}
if (isset($ipstime)){
$timespan = $thistime - $ipstime;
$timelefthour = round((($nextvoteperip - $timespan)/60)/60);
$timeleftmin = date(i, ($nextvoteperip - $timespan));
$timelefthour = round(((($nextvoteperip - $timespan)/60) - $timeleftmin)/60);
$timeleftsec = date(s, ($nextvoteperip - $timespan));
if ($timespan <= $nextvoteperip){
echo "<center><font class="maxReachedMessage">".$finished_by_voteperip.$timelefthour.":".$timeleftmin.":".$timeleftsec."</font></center><BR>";
return FALSE;}
}
return TRUE;
}



//tmp-Datei in Array einlesen
function csv2array($csvfile)
{
$csvstring = readTextFile($csvfile);
// String in Array überführen
$csvdata = explode("n", $csvstring);
// Aufbau des Array
$stack = array ();
//Array Satz für Satz ausgeben
$length = count($csvdata);
for ($i = 0; $i < $length; $i++) {
if ($csvdata[$i] != ""){
$stack[$i] = $csvdata[$i];
}
}
return $stack;
}

?>
?>[/php:1:4c602db244]
No i teraz nie wiem gdzie jest jakis blad lub cokolwiek co powoduje generowanie bledu.

Pozdrawiam
kszychu
[php:1:289fe071a5]<?php
// linia 122 na listingu
$timeleftmin = date(i, ($nextvoteperip - $timespan));
// i 124
$timeleftsec = date(s, ($nextvoteperip - $timespan));
?>[/php:1:289fe071a5]
Co to za składnia?
Mnie w szkółce niedzielnej uczyli czegoś takiego:
[php:1:289fe071a5]<?php
$timeleftsec = date("s", ($nextvoteperip - $timespan));
$timeleftmin = date("i", ($nextvoteperip - $timespan));
?>[/php:1:289fe071a5]
d12
Co to za sonda??
Majcok12
Z hotscripts, tyle ze ja pokazalem zawartosc tylko pliku pollfunctions.php bo do tego pliku odnosil sie blad. A plikow jest troche wiecej.
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2024 Invision Power Services, Inc.