Hej Leute, also ich habe folgendes Problem. Ich habe so ein php S***** für Songs. Ich lade Lieder per FTP hoch, starte dann mein Adminpanel, in dem über einen Befehl
PHP-Code:
$store->uploadFtpSongs();
die Lieder online kommen. Wenn ich das Adminpanel nicht aufrufe, bleiben die Lieder in dem upload Ordner.
Nun möchte ich es etwas automatisieren, dass ich zb 100 lieder hochlade und dann mit Hilfe von cronjob zb alle 2 tage 5-7 Lieder online kommen, nicht alle auf einmal. Nun komme ich nicht weiter. Ich hab als php Laie einiges rumprobiert, hatte aber keinen Erfolg.
Der Code, der für das Ziehen der Lieder aus dem upload Ordner zuständig ist, sieht so aus
PHP-Code:
public function uploadFtpSongs() {
if (file_exists(PATH_UPLOAD_FTP)) {
$path = PATH_UPLOAD_FTP;
$dh = opendir($path);
while (($file = readdir($dh)) !== false) {
if ($file != '.' && $file != '..') {
$fullpath = $path . '/' . $file;
if (!is_dir($fullpath) && pathinfo($fullpath, PATHINFO_EXTENSION) == 'mp3') {
list($artist, $song) = explode('-', pathinfo($file, PATHINFO_FILENAME));
if (empty($artist)) $artist = 'No Artist';
if (empty($song)) $song = 'No Title';
$artist = ucfirst(str_replace('_', ' ', $artist));
$song = ucfirst(str_replace('_', ' ', $song));
// $safe_filename = preg_replace(array("/\s+/", "/[^-\.\w]+/"), array("_", ""), $file);
// if ($file != $safe_filename) rename($fullpath, $path . '/' . $safe_filename);
$file = $this->uploadSong($fullpath, PATH_UPLOAD);
$this->db->query('INSERT INTO store (added, artist, song, file, size)
VALUES (NOW(), "' . $this->db->escape($artist) . '", "' . $this->db->escape($song) . '", "' . $file . '", "' . round(filesize(PATH_UPLOAD . '/' . $file) / 1024 / 1024, 2) . '")');
}
}
}
}
}
kann mir jemand weiterhelfen? den cronjob einzurichten müsste für mich kein problem sein