Hey wiskyjim,
wenn ich das jetzt richtig verstanden habe, möchtest du nach dem Map Upload die info_player entities Zählen und in der Download DB Speichern ?
Edit:
include/contents/downloads.php
über
function icUpload () {
das Einfügen
function count_player_entities ($file) {
$count = 0;
$parts = pathinfo($file);
if (file_exists($file) and $parts['extension'] == 'bsp' ) {
$fp = fopen($file, "r");
$string = fread($fp, filesize($file));
$count = preg_match_all("/info_player_(counterterrorist|terrorist)/", $string, $matches);
fclose($fp);
}
return($count);
}
und die
icUpload () Funktion komplett durch dieser ersetzen
function icUpload () {
$name = escape($_POST['name'],'string');
$version = escape($_POST['version'],'string');
$autor = escape($_POST['autor'],'string');
$surl = escape($_POST['surl'],'string');
$ssurl = escape($_POST['ssurl'],'string');
$url = ( empty($_POST['url']) ? '' : escape($_POST['url'],'string') );
$desc = escape($_POST['desc'],'string');
$descl = escape($_POST['descl'],'textarea');
if (empty($name)) {
return ('keinen Namen angegeben.');
}
if (empty($desc) or empty($descl)) {
return ('kein langer oder/und kein kurzer Text angegeben.');
}
if (empty($url) AND empty($_FILES['file']['name'])) {
return ('Keine Datei oder Link angegeben.');
}
if (!empty ($_FILES['file']['name']) ) {
$rtype = trim(ic_mime_type ($_FILES['file']['tmp_name']));
$fname = escape($_FILES['file']['name'],'string');
$fende = preg_replace("/.+\.([a-zA-Z]+)$/", "\\1", $fname);
$fende = strtolower($fende);
if ( $_FILES['file']['size'] > 2097000 ) { # 2 mb (2 097 152)
return ('Die Datei darf NICHT grösser als 2 MBytes sein.');
}
if (
($fende != 'rar' AND $fende != 'zip' AND $fende != 'tar' AND $fende != 'bsp')
OR (
$rtype != 'application/x-rar' AND
$rtype != 'application/x-zip' AND
$rtype != 'application/x-tar' AND
$rtype != 'application/x-object')
) {
return ('Die Datei darf nur die Endungen: .zip, .tar, .rar oder .bsp haben.');
}
$fname = str_replace ('.'.$fende, '', $fname);
$fname = preg_replace("/[^a-zA-Z0-9]/", "", $fname);
$fname = $fname.'.'.$fende;
if (file_exists( 'include/downs/downloads/user_upload/'.$fname ) ) {
return ('Die Datei existiert bereits und kann nicht überschrieben werden.');
}
if ( move_uploaded_file($_FILES['file']['tmp_name'], 'include/downs/downloads/user_upload/'.$fname) ) {
$url = 'include/downs/downloads/user_upload/'.$fname;
@chmod($url, 0777);
$spawnCount = ($fende == 'bsp' ? count_player_entities($url) : '0');
}
}
if (empty($url)) {
return ('Keine Datei oder Link angegeben');
}
db_query("INSERT INTO prefix_downloads (`time`,`cat`,`creater`,`version`,`url`,surl,`ssurl`,`name`,`desc`,`descl`,`pos`,`spawn`) VALUES (NOW(),-1,'".$autor."','".$version."','".$url."','".$surl."','".$ssurl."','".$name."','".$desc."','".$descl."','0','".$spawnCount."')");
return (true);
}
Wenn du in der
prefix_downloads Tabelle noch keine Spalte hast, wo er die Anzahl Speichert, dann musst du noch eine anlegen. Am besten mit diesem kleinen Insall Script
Einfach als
install.php im Ilch Root Speichern und dieses dann aufrufen (zb. www.meineseite.de/install.php)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>
<meta name="author" content="OloX" />
<meta http-equiv="Content-Type" content="text/html; Select from list" />
<title>-=] Installation [=-</title>
<style type="text/css">
<!--
html { margin:0; padding:0;}
* { margin: 0; padding: 0; outline: 0; }
body {
margin:0; padding:0;
font-family: Tahoma, Verdana, Arial, "Trebuchet MS";
font-size: 12px;
color: #ffffff; text-align: center;
background: #23252f;
}
#container {
margin: 0 auto;
width: 500px;
}
#main {
text-align: center;
font: 12px Tahoma;
color: #045d96;
border: 1px dashed #00CCFF;
background-color:#c1c1c1;
padding:5px;
width: 500px;
margin-top: 1px;
}
#head {
text-align: center;
border: 1px dashed #00CCFF;
background-color:#323543;
padding:5px;
width: 500px;
height: 30px;
margin-top: 10px;
}
#foot {
text-align: center;
border: 1px dashed #00CCFF;
background-color:#323543;
padding:5px;
width: 500px;
height: 10px;
margin-top: 1px;
}
h1 {
margin-bottom: 3px;
margin-top: 0.3em;
color: #3a738d;
font-size: 1.4em;
}
-->
</style>
</head>
<body>
<div id="container">
<div id="head"><h1>Installation</h1></div>
<?php
define ( 'main' , TRUE );
require_once('include/includes/config.php');
require_once('include/includes/func/db/mysql.php');
db_connect();
if (db_query("ALTER TABLE `prefix_downloads` ADD `spawn` int(11) NOT NULL default '0' AFTER `downs`;"))
echo '<div id="main">Installation <strong>erfolgreich</strong> abgeschlossen.<br />Bitte <strong>install.php</strong> löschen.</div><div id="foot"></div></div>
</body>
</html>';
else
echo '<div id="main"><b>Fehler aufgetreten:</b><br />'.mysql_error().'</div><div id="foot"></div></div>
</body>
</html>';
db_close();
?>
MfG OloX
Zuletzt modifiziert von OloX am 20.06.2010 - 19:30:36