select sum(preis) as Summe from preis
Beiträge von No0ob
-
-
Soll die Mitarbeit auf freiwilliger Basis sein?
-
-
Zitat
Statt allerdings dauernd an privaten Scripts herumzubasteln, dachte ich mir, ich könnte ja mal versuchen, mein "Angebot" an die Nichtcoder unter euch zu richten und kleine Scripts kostenlos fertig zu stellen.
bitte lesen -
-
Die Lösung ist recht umfangreich, aber wenn ihr wollt
FTP Klasse
PHP
Alles anzeigen<?php class ftp { // Private Data var $host = ''; var $user = ''; var $pass = ''; // Private Identifiers var $conn = NULL; var $login = NULL; // Changes into the specified directory function changeDirectory($dir){ if (@ftp_chdir($this->conn, $dir)){ return true; } else { return false; } } // This is the same as chmod function changeMod($path, $file, $mode){ if (chmod($path.$file, $mode)){ return true; } else { return false; } } // In case php doesn't do it itself function closeConnection(){ @ftp_close($this->conn); } // mkdir function createDirectory($dir){ if (!file_exists($dir)){ if (ftp_mkdir($this->conn, $dir)){ return true; } else { return false; } } else { return false; } } //rmdir RECURSIVELY, means that directory does NOT have to be empty in order to get it to work :) function deleteDirectory($dir){ if (!(@ftp_rmdir($this->conn, $dir) || @ftp_delete($this->conn, $dir))){ $list = @ftp_nlist($this->conn, $dir); if (!empty($list)){ foreach($list as $value){ $this->deleteDirectory($value); } } } @ftp_rmdir($this->conn, $dir); } // Delete a File.. function deleteFile($file){ if (ftp_delete($this->conn, $file)){ return true; } else { return false; } } // Constructor which establishes a connection function ftp($host, $user, $pass){ $this->setVars($host, $user, $pass); $this->conn = ftp_connect($host); $this->login = ftp_login($this->conn, $this->user, $this->pass); } // Get into the upper Directory function moveUp(){ if (ftp_cdup($this->conn)){ return true; } else { return false; } } // It's better to let a function assign the variables function setVars($host, $user, $pass){ $this->host = $host; $this->user = $user; $this->pass = $pass; } // Upload the File! function upload($serverfile, $localfile, $mode = FTP_BINARY){ if (ftp_put($this->conn, $serverfile, $localfile, $mode)){ return true; } else { return false; } } } ?>
Die Datei, die alles ausführt (oder zumindest der Teil davon)
Code
Alles anzeigen/* ##### ADD SCREENSHOT ##### */ if (isset($_POST['screenshot_create'])){ // Since the images are hosted on another Server, we have to establish a connection via FTP $ftp = new ftp($var['ftp_dlhost'], $var['ftp_dluser'], $var['ftp_dlpass']); // Directory for screenshots is html/images/screenshots $ftp->changeDirectory('html'); $ftp->changeDirectory('images'); $ftp->changeDirectory('screenshots'); // If Directory with Gameid doesnt exist, we create it and move to it if (!$ftp->changeDirectory($g)){ $ftp->createDirectory($g); $ftp->changeDirectory($g); } $expl = explode('.', $_FILES['screenshot']['name']); // Add Screenshot to Database $games->createScreenshot($g, $expl[count($expl)-1]); /* The Method getScreenshotID returns the highest ScreenshotID + 1 But we have just added another Screenshot, therefore we have to do the -1 */ $screenshotID = $games->getScreenshotID()-1; if ($ftp->upload($screenshotID.'.'.$expl[count($expl)-1], $_FILES['screenshot']['tmp_name'])){ $ftp2 = new ftp($var['ftp_sitehost'], $var['ftp_siteuser'], $var['ftp_sitepass']); if ($games->createScreenshotThumbnail($g, $screenshotID.'.'.$expl[count($expl)-1])){ $ftp2->changeDirectory('httpdocs'); $ftp2->changeDirectory('work'); $ftp2->changeDirectory('nextgen.at'); $ftp2->changeDirectory('temp'); $ftp2->changeDirectory('thumb_screenshots'); $ftp2->changeMod('../temp/thumb_screenshots/', 'thumb_'.$screenshotID.'.'.$expl[count($expl)-1], 0777); if (!$ftp->changeDirectory('thumbs')){ $ftp->createDirectory('thumbs'); $ftp->changeDirectory('thumbs'); } $ftp->upload('thumb_'.$screenshotID.'.'.$expl[count($expl)-1], '../temp/thumb_screenshots/thumb_'.$screenshotID.'.'.$expl[count($expl)-1], FTP_BINARY); $ftp2->deleteFile('thumb_'.$screenshotID.'.'.$expl[count($expl)-1]); $ftp->closeConnection(); unset($ftp); unset($ftp2); redirect('module.php?m=games&s=screenshots&g='.$g); } else { action_fail($l['error_uploadfailed']); } } else { action_fail($l['error_uploadfailed']); } } ##### ADD SCREENSHOT END #####
Der Teil der Klasse, in der die Thumbnailgenerierung erfolgt
PHP
Alles anzeigen<?php class games { // Stores the Screenshot Info in TBL_SCREENSHOTS function createScreenshot($gid, $filetype){ global $ado; $record = array('SID' => $this->getScreenshotID(), 'GID' => $gid, 'UID' => $_SESSION['uid'], 'added' => time(), 'filetype' => $filetype ); $sql = $ado->AutoExecute(TBL_SCREENSHOTS, $record, 'INSERT'); if ($sql){ return true; } else { global $l; action_fail($l['error_badquery']); return false; } } // Copies and resizes a Screenshot to a Thumbnail function createScreenshotThumbnail($gid, $file){ global $config, $var; $filepath_temp = $var['url_website'].'/temp/thumb_screenshots/'.$gid; $filepath_download = $var['path_downloads'].'/images/screenshots/'.$gid; $size = getimagesize($filepath_download.'/'.$file); $width = $size[0]; $height = $size[1]; $expl = explode('.', $file); $extension = $expl[count($expl)-1]; switch ($size[2]){ // GIF case 1: $old = imagecreatefromgif($filepath_download.'/'.$file); $new = imagecreate($config->data['gameScreenshotThumbWidth'], $config->data['gameScreenshotThumbHeight']); imagecopyresized($new, $old, 0, 0, 0, 0, $config->data['gameScreenshotThumbWidth'], $config->data['gameScreenshotThumbHeight'], $width, $height); imagegif($new, '../temp/thumb_screenshots/thumb_'.$file); return true; break; // JPG case 2: $old = imagecreatefromjpeg($filepath_download.'/'.$file); $new = imagecreate($config->data['gameScreenshotThumbWidth'], $config->data['gameScreenshotThumbHeight']); imagecopyresized($new, $old, 0, 0, 0, 0, $config->data['gameScreenshotThumbWidth'], $config->data['gameScreenshotThumbHeight'], $width, $height); imagejpeg($new, '../temp/thumb_screenshots/thumb_'.$file); return true; break; // PNG case 3: $old = imagecreatefrompng($filepath_download.'/'.$file); $new = imagecreate($config->data['gameScreenshotThumbWidth'], $config->data['gameScreenshotThumbHeight']); imagecopyresized($new, $old, 0, 0, 0, 0, $config->data['gameScreenshotThumbWidth'], $config->data['gameScreenshotThumbHeight'], $width, $height); imagepng($new, '../temp/thumb_screenshots/thumb_'.$file); return true; break; } } }
So, ich glaub das wars.
-
Hat sich erledigt, habs hingekriegt
-
Wie heisst die Tabelle und wie heissen die Spalten?
Code$sql = "SELECT * FROM mitarbeiter ORDER BY name ASC"; $query = mysql_query($sql) or die(mysql_error()); echo "<select size=\"1\" name=\"mitarbeiter\">\n"; while ($row = mysql_fetch_array($query, MYSQL_ASSOC)){ echo "<option value=\"".$row['id']."\">".$row['name'].", ".$row['vorname']."</option>\n"; } echo "</select>\n";
So, zum Beispiel
-
-
Hallo Leute, ich stehe vor einem kleinen Problem.
Ich möchte mittels Script auf einem anderen Server Thumbnails von hochgeladenen Bildern generieren. Die Bilder lade ich mittels ftp Funktionen hoch.Das Problem ist nur, wenn man imagecopyresized und ähnliches ausführt, führt man das ja auf dem Server aus, wo das Script gespeichert ist.
Gibt es eine Möglichkeit, die Thumbnails mittels ftp zu generieren?
-
lol, hab ich auch noch net gesehn
-
Was mir auf ersten Blick auffällt ist nur etwas minimales.
Ein Gigabyte sind nicht 1000 Megabyte, aber 1024.Gefällt mir sonst gut, sehe keine Bugs oder ähnliches, wobei ich nicht sehr viel probiert hab.
-
UPDATE nachricht FROM content ?
Meines Wissens nach ist es UPDATE nachricht SET content = '".$text"' oder ähnliches -
1,4 Gigabyte? Was hast du denn da gespeichert
Ich würde bei Shared Hostings auf spezielle Limits achten. -
Du musst bei dem Formular method="post" in method="get" ändern.
Wenn dann ein Feld go heisst, wird dieses so angehängt -
Naja, schreib mich mal im msn an, wenn du jemanden brauchst
-
Wenn der Code geändert wird, nehm ich teil.
Der Code, der da war, als ich ihn gesehn hab, war nämlich Müll -
Ich hab auch nicht gesagt, dass das auf meiner Seite so ist oder?
Die Seite ist alt und ich hab schon einige andere, z.B. http://rageclan.org/ncms/index.php -
-
Oh ja, hab da vergessen die Anführungszeichen nach dem echo hinzuschreiben. Sorry, aber ich hab den Code einfach mal ausm Kopp hingeschrieben