array( 'de' => $gmcBornDate->format("m.Y"), 'en' => $gmcBornDate->format("Y/m") ), 'died' => array( 'de' => $gmcDeathDate->format("m.Y"), 'en' => $gmcDeathDate->format("Y/m") ), ); $mysql=mysqli_connect("localhost", "froevel.de", "QieMlad3"); if($mysql->connect_error) { echo("
Connect error (" . $mysqli->connect_errno . "): " . $mysqli->connect_error . "
"); return; } $result=mysqli_select_db($mysql, "froevel_de"); if($result===FALSE) { echo("
Selecting DB failed!
"); mysqli_close($sql); return; } $query="SELECT status, username, join_date,"; $query.=" IF(status=4, delete_date, '" . $ripDate . "') AS leave_date,"; $query.=" IF(status=4, ABS(DATEDIFF(delete_date, join_date)), DATEDIFF('" . $ripDate . "', join_date)) AS member_duration"; $query.=" FROM gmc_users"; $query.=" ORDER BY status ASC, member_duration DESC, join_date ASC;"; $result=mysqli_query($mysql, $query); if($result===FALSE) { echo("
Query failed!
"); mysqli_close($sql); return; } $users=array(); $namesCount=array(); $STATUS_TEXT=array(); while(($row=mysqli_fetch_assoc($result))) { if($row['status']==4) $row['username']=str_replace('GMC\'', 'Ex-', $row['username']); else $row['username']=str_replace('GMC\'', 'GMC\'', $row['username']) . ""; $joinDate=date_create_from_format("Y-m-d", $row['join_date']); $leaveDate=date_create_from_format("Y-m-d", $row['leave_date']); $d=date_diff($leaveDate, $joinDate); $rd=array( 'de' => '', 'en' => ''); $checkDay=($d->d)-5; if($checkDay<5) { if($d->y>0) { $rd['de'].=$d->y . " " . ($d->y==1 ? "Jahr" : "Jahre"); $rd['en'].=$d->y . " " . ($d->y==1 ? "year" : "years"); } if($d->m>0) { if(!empty($rd['de'])) $rd['de'].=" und " . $d->m . ($d->m==1 ? " Monat" : " Monate"); else $rd['de']= $d->m . ($d->m==1 ? " Monat" : " Monate"); if(!empty($rd['en'])) $rd['en'].=" and slightly over " . $d->m . ($d->m==1 ? " month" : " months"); else $rd['en']=$d->m . ($d->m==1 ? "month" : "months"); } } else if($checkDay<15) { if($d->y>0) { $rd['de'].=$d->y . ($d->y==1 ? " Jahr" : " Jahre"); $rd['en'].=$d->y . ($d->y==1 ? " year" : " years"); } if($d->m>0) { if(!empty($rd['de'])) $rd['de'].=" und knapp über " . $d->m . ($d->m==1 ? " Monat" : " Monate"); else $rd['de']="Knapp über " . $d->m . ($d->m==1 ? " Monat" : " Monate"); if(!empty($rd['en'])) $rd['en'].=" and slightly over " . $d->m . ($d->m==1 ? " month" : " months"); else $rd['en']="Slightly over " . $d->m . ($d->m==1 ? " month" : " months"); } } else { $m=($d->m+1) % 12; $y=$d->y + ($m==0 ? 1 : 0); if($y>0) { $rd['de'].="Fast " . $y . ($y==1 ? " Jahr" : " Jahre"); $rd['en'].="Nearly " . $y . ($y==1 ? " year" : " years"); } if($m>0) { if(!empty($rd['de'])) $rd['de'].=" und " . $m . ($m==1 ? " Monat" : " Monate"); else $rd['de']="Fast " . $m . ($m==1 ? " Monat" : " Monate"); if(!empty($rd['en'])) $rd['en'].=" and " . $m . ($m==1 ? " month" : " months"); else $rd['en']="Nearly " . $m . ($m==1 ? " month" : " months"); } } $tp=array( 'de' => $d->days . " Tage", 'en' => $d->days . " days" ); $name=strtolower($row['username']); if(array_key_exists($name, $namesCount)) { $namesCount[$name]++; $row['username'].=" #" . $namesCount[$name]; } else $namesCount[$name]=1; $users[]=array ( 'status' => $row['status'], 'name' => $row['username'], 'born' => array( 'de' => $joinDate->format("m.Y"), 'en' => $joinDate->format("Y/m") ), 'died' => array( 'de' => $leaveDate->format("m.Y"), 'en' => $leaveDate->format("Y/m") ), 'duration' => $rd, 'tooltip' => $tp ); } mysqli_free_result($result); mysqli_close($mysql); /* Status prologues */ $STATUS_TEXT[1]=array ( 'de' => 'Einleitung fuer Gotti und Holle', ); $STATUS_TEXT[2]=array ( 'de' => 'Einleitung fuer Allerleirauh', ); $STATUS_TEXT[3]=array ( 'de' => 'Einleitung fuer alle, die bis zum Schluss blieben', ); $STATUS_TEXT[4]=array ( 'de' => 'Einleitung fuer alle Ex-Members', ); ?>