sshターミナルを使用してディレクトリで実行するphpスクリプトを取得しようとしています。スクリプトを実行しようとすると、次のエラーが発生します。
(uiserver):USER:~/directory/folder > php zipper.php
X-Powered-By: PHP/4.4.9
Content-type: text/html
<br />
<b>Parse error</b>: syntax error, unexpected ')', expecting '(' in <b>/BLA/htdocs/directory/folder/zipper.php</b> on line <b>7</b><br />
奇妙なことに、小さなhtmlを挿入して、このスクリプトが配置されているページにアクセスすると、正常に機能します。ただし、これをcronで実行する必要があるため、これは役に立ちません。
これが私が実行しようとしているスクリプトです:
<?php
//date variable
$today = date("Ymd");
//create an instance of ZipArchive class
$zip = new ZipArchive();
//create the archive called images.zip and open it
$result = $zip->open('images.zip', ZipArchive::CREATE);
if ($result) {
//open the directory with the files that need to be archived
$d = dir("turbo/");
//loop through the files in $d
while (false !== ($entry = $d->read())) {
//use a regular expression with preg_match to get just the jpgs
if(preg_match("/\w*\.jpg/",$entry)) {
//add the file to the archive
$zip->addFile("turbo/".$entry,$entry);
}
}
//close the directory and archive
$d->close();
$zip->close();
} else {
//display the error
echo "Failed: $result.\n";
}
//deletes all jpg files
//foreach(glob('/www/images/*.jpg') as $file){
// if(is_file($file))
// @unlink($file);
//}
?>
エラーが発生している行は次のとおりです。
$result = $zip->open('images.zip', ZipArchive::CREATE);
私はホストとして1and1(私は知っています)を使用しています。php5を強制するために.htaccessファイルを作成しようとしましたが、それは機能しません。
構文的に、このスクリプトの何が間違っているのでしょうか。私がやりたいのは、ディレクトリ内のすべてのjpg画像を圧縮することです。
どんな、どんな、助けでも大歓迎です。