1
0
mirror of https://github.com/php/web-php.git synced 2026-03-23 23:02:13 +01:00

Merge branch 'pull-request/61'

This commit is contained in:
Peter Cowburn
2018-03-14 22:30:05 +00:00

View File

@@ -53,7 +53,13 @@ $categories = array(
);
$confs = array(2, 3);
$imageRestriction = array(
'width' => 400,
'height' => 400
);
do {
$catVerified = false;
fwrite(STDOUT, "Categories:\n");
foreach($categories as $n => $category) {
fprintf(STDOUT, "\t%d: %-11s\t [%s]\n", $n, key($category), current($category));
@@ -111,8 +117,6 @@ if ($conf) {
foreach($cat as $n) {
if (isset($categories[$n])) {
ce($dom, "category", null, array("term" => key($categories[$n]), "label" => current($categories[$n])), $item);
} else {
fprintf(STDERR, "Unkown category %d\n", $n);
}
}
@@ -120,11 +124,37 @@ ce($dom, "link", null, array("href" => "$href#id$id", "rel" => "alternate", "ty
fwrite(STDOUT, "Will a picture be accompanying this entry? ");
$yn = fgets(STDIN);
if (strtoupper($yn[0]) == "Y") {
$isValidImage = false;
do {
fwrite(STDOUT, "Enter the image name (note: the image has to exist in './images/news'): ");
$path = basename(rtrim(fgets(STDIN)));
} while(!file_exists("./images/news/$path"));
if (true === file_exists("./images/news/$path")) {
$isValidImage = true;
if (true === extension_loaded('gd')) {
$imageSizes = getimagesize("./images/news/$path");
if (
$imageSizes[0] > $imageRestriction['width'] ||
$imageSizes[1] > $imageRestriction['height']
) {
fwrite(STDOUT, "Provided image has a higher size than recommended (" . implode(' by ', $imageRestriction) . "). Continue? ");
$ynImg = fgets(STDIN);
if (strtoupper($ynImg[0]) == "Y") {
break;
} else {
$isValidImage = false;
}
}
}
}
} while($isValidImage !== true);
fwrite(STDOUT, "Image title: ");
$title = rtrim(fgets(STDIN));