Skip to content

Commit 5e9b241

Browse files
authored
Merge pull request #136 from ihackcode/develop
Various fixes
2 parents dd04591 + 978fd4e commit 5e9b241

File tree

5 files changed

+26
-54
lines changed

5 files changed

+26
-54
lines changed

archive.php

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,12 @@
168168

169169
// must adjust the selected time to server timestamp
170170
$timeoffset = $useroffset - $GLOBALS['xoopsConfig']['server_TZ'];
171-
$monthstart = mktime(0 - $timeoffset, 0, 0, $frommonth, 1, $fromyear);
172-
$monthend = mktime(23 - $timeoffset, 59, 59, $frommonth + 1, 0, $fromyear);
171+
$timeoffsethours = (int)$timeoffset;
172+
$timeoffsetminutes = intval(($timeoffset - $timeoffsethours) * 60);
173+
174+
$monthstart = mktime(0 - $timeoffsethours, 0 - $timeoffsetminutes, 0, $frommonth, 1, $fromyear);
175+
$monthend = mktime(23 - $timeoffsethours, 59 - $timeoffsetminutes, 59, $frommonth + 1, 0, $fromyear);
176+
173177
$monthend = ($monthend > time()) ? time() : $monthend;
174178

175179
$count = 0;
@@ -185,7 +189,7 @@
185189
$criteria->add($grantedCategories, 'AND');
186190
$criteria->add(new \Criteria('o.status', 2), 'AND');
187191
$critdatesub = new \CriteriaCompo();
188-
$critdatesub->add(new \Criteria('o.datesub', $monthstart, '>'), 'AND');
192+
$critdatesub->add(new \Criteria('o.datesub', $monthstart, '>='), 'AND');
189193
$critdatesub->add(new \Criteria('o.datesub', $monthend, '<='), 'AND');
190194
$criteria->add($critdatesub);
191195
$criteria->setSort('o.datesub');
@@ -197,9 +201,7 @@
197201
if (is_array($storyarray) && $count > 0) {
198202
/** @var \XoopsModules\Publisher\Item $item */
199203

200-
201204
foreach ($storyarray as $item) {
202-
203205
$story = [];
204206
$htmltitle = '';
205207
$story['title'] = "<a href='" . $item->getItemUrl() . "'" . $htmltitle . '>' . $item->getTitle() . '</a>';
@@ -238,20 +240,14 @@
238240
}
239241
} else {
240242
$story['comment'] = '&nbsp;' . _MD_PUBLISHER_NO_COMMENTS . '&nbsp;';
241-
}
242-
243-
244-
245-
243+
}
246244
$xoopsTpl->append('stories', $story);
247245
}
248246
//unset($item);
249-
250247
}
251248
$xoopsTpl->assign('lang_printer', _MD_PUBLISHER_PRINTERFRIENDLY);
252249
$xoopsTpl->assign('lang_sendstory', _MD_PUBLISHER_SENDSTORY);
253250
$xoopsTpl->assign('lang_storytotal', _MD_PUBLISHER_TOTAL_ITEMS . ' ' . $count);
254-
255251
} else {
256252
$xoopsTpl->assign('show_articles', false);
257253
}

class/Cloner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public static function createLogo($dirname)
9494

9595
// Write text
9696
$textColor = \imagecolorallocate($imageModule, 0, 0, 0);
97-
$spaceToBorder = (80 - mb_strlen($dirname) * 6.5) / 2;
97+
$spaceToBorder = intval((80 - mb_strlen($dirname) * 6.5) / 2);
9898
\imagefttext($imageModule, 8.5, 0, $spaceToBorder, 45, $textColor, $font, \ucfirst($dirname), []);
9999

100100
// Set transparency color

class/Form/ItemForm.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ public function createElements($obj)
359359
}
360360

361361
$dateExpireYesNo = new \XoopsFormRadioYN('', 'use_expire_yn', $dateexpire_opt);
362+
$dateexpire = \strtotime(\formatTimestamp($dateexpire)); //set to user timezone
362363
$dateexpire_datetime = new \XoopsFormDateTime('', 'dateexpire', $size = 15, $dateexpire, true);
363364
if (0 == $dateexpire_opt) {
364365
$dateexpire_datetime->setExtra('disabled="disabled"');

class/Item.php

Lines changed: 12 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,25 +1101,12 @@ public function setVarsFromRequest()
11011101
// } else {
11021102
$resDate = Request::getArray('datesub', [], 'POST');
11031103
$resTime = Request::getArray('datesub', [], 'POST');
1104-
// $this->setVar('datesub', strtotime($resDate['date']) + $resTime['time']);
1105-
//$localTimestamp = strtotime($resDate['date']) + $resTime['time'];
1106-
$dateTimeObj = \DateTime::createFromFormat(_SHORTDATESTRING, $resDate['date']);
1107-
$dateTimeObj->setTime(0, 0, 0);
1108-
$localTimestamp = $dateTimeObj->getTimestamp() + $resTime['time'];
1109-
1110-
// get user Timezone offset and use it to find out the Timezone, needed for PHP DataTime
1111-
$userTimeoffset = $GLOBALS['xoopsUser']->getVar('timezone_offset');
1112-
$tz = \timezone_name_from_abbr(null, $userTimeoffset * 3600);
1113-
if (false === $tz) {
1114-
$tz = \timezone_name_from_abbr(null, $userTimeoffset * 3600, false);
1115-
}
1116-
1117-
$userTimezone = new \DateTimeZone($tz);
1118-
$gmtTimezone = new \DateTimeZone('GMT');
1119-
$myDateTime = new \DateTime('now', $gmtTimezone);
1120-
$offset = $userTimezone->getOffset($myDateTime);
1121-
1122-
$gmtTimestamp = $localTimestamp - $offset;
1104+
$dateTimeObj = \DateTime::createFromFormat(_SHORTDATESTRING, $resDate['date'],
1105+
new \DateTimeZone($GLOBALS['xoopsUser']->getVar('timezone_offset')));
1106+
$dateTimeObj->setTime(0, 0, (int)$resTime['time']);
1107+
$dateTimeObj->setTimezone(new \DateTimeZone('GMT'));
1108+
$gmtTimestamp = $dateTimeObj->getTimestamp();
1109+
//always store the time as GMT/UTC Time
11231110
$this->setVar('datesub', $gmtTimestamp);
11241111
// }
11251112
} elseif ($this->isNew()) {
@@ -1131,24 +1118,12 @@ public function setVarsFromRequest()
11311118
if ('' !== Request::getString('dateexpire', '', 'POST')) {
11321119
$resExDate = Request::getArray('dateexpire', [], 'POST');
11331120
$resExTime = Request::getArray('dateexpire', [], 'POST');
1134-
//$localTimestamp = strtotime($resExDate['date']) + $resExTime['time'];
1135-
$dateTimeObj = \DateTime::createFromFormat(_SHORTDATESTRING, $resExDate['date']);
1136-
$dateTimeObj->setTime(0, 0, 0);
1137-
$localTimestamp = $dateTimeObj->getTimestamp() + $resExTime['time'];
1138-
1139-
// get user Timezone offset and use it to find out the Timezone, needed for PHP DataTime
1140-
$userTimeoffset = $GLOBALS['xoopsUser']->getVar('timezone_offset');
1141-
$tz = \timezone_name_from_abbr(null, $userTimeoffset * 3600);
1142-
if (false === $tz) {
1143-
$tz = \timezone_name_from_abbr(null, $userTimeoffset * 3600, false);
1144-
}
1145-
1146-
$userTimezone = new \DateTimeZone($tz);
1147-
$gmtTimezone = new \DateTimeZone('GMT');
1148-
$myDateTime = new \DateTime('now', $gmtTimezone);
1149-
$offset = $userTimezone->getOffset($myDateTime);
1150-
1151-
$gmtTimestamp = $localTimestamp - $offset;
1121+
$dateTimeObj = \DateTime::createFromFormat(_SHORTDATESTRING, $resExDate['date'],
1122+
new \DateTimeZone($GLOBALS['xoopsUser']->getVar('timezone_offset')));
1123+
$dateTimeObj->setTime(0, 0, (int)$resExTime['time']);
1124+
$dateTimeObj->setTimezone(new \DateTimeZone('GMT'));
1125+
$gmtTimestamp = $dateTimeObj->getTimestamp();
1126+
//always store the time as GMT/UTC Time
11521127
$this->setVar('dateexpire', $gmtTimestamp);
11531128
}
11541129
} else {

thumb.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ protected function processImageAndWriteToCache($localImage)
770770
}
771771

772772
// create a new true color image
773-
$canvas = imagecreatetruecolor($newWidth, $newHeight);
773+
$canvas = imagecreatetruecolor((int)$newWidth, (int)$newHeight);
774774
imagealphablending($canvas, false);
775775

776776
if (3 == mb_strlen($canvas_color)) {
@@ -845,10 +845,10 @@ protected function processImageAndWriteToCache($localImage)
845845
}
846846
}
847847

848-
imagecopyresampled($canvas, $image, $origin_x, $origin_y, $src_x, $src_y, $newWidth, $newHeight, $src_w, $src_h);
848+
imagecopyresampled($canvas, $image, (int)$origin_x, (int)$origin_y, (int)$src_x, (int)$src_y, (int)$newWidth, (int)$newHeight, (int)$src_w, (int)$src_h);
849849
} else {
850850
// copy and resize part of an image with resampling
851-
imagecopyresampled($canvas, $image, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
851+
imagecopyresampled($canvas, $image, 0, 0, 0, 0, (int)$newWidth, (int)$newHeight, (int)$width, (int)$height);
852852
}
853853

854854
if (defined('IMG_FILTER_NEGATE') && '' != $filters && function_exists('imagefilter')) {
@@ -965,7 +965,7 @@ protected function processImageAndWriteToCache($localImage)
965965
$this->debug(3, 'Rewriting image with security header.');
966966
$tempfile4 = tempnam($this->cacheDirectory, 'timthumb_tmpimg_');
967967
$context = stream_context_create();
968-
$fp = fopen($tempfile, 'rb', 0, $context);
968+
$fp = fopen($tempfile, 'rb', false, $context);
969969
file_put_contents($tempfile4, $this->filePrependSecurityBlock . $imgType . ' ?' . '>'); //6 extra bytes, first 3 being image type
970970
file_put_contents($tempfile4, $fp, FILE_APPEND);
971971
fclose($fp);

0 commit comments

Comments
 (0)