Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Precount for loops

  • Loading branch information...
commit d7d15abb225af557f463a75187fce955d94e7d5b 1 parent dcf3e6a
@acidvertigo acidvertigo authored
Showing with 24 additions and 22 deletions.
  1. +24 −22 catalog/includes/classes/email.php
View
46 catalog/includes/classes/email.php
@@ -118,8 +118,8 @@ function find_html_images($images_dir) {
}
preg_match_all('/"([^"]+\.(' . implode('|', $extensions).'))"/Ui', $this->html, $images);
-
- for ($i=0; $i<count($images[1]); $i++) {
+ $n=count($images[1]);
+ for ($i=0; $i<$n; $i++) {
if (file_exists($images_dir . $images[1][$i])) {
$html_images[] = $images[1][$i];
$this->html = str_replace($images[1][$i], basename($images[1][$i]), $this->html);
@@ -130,8 +130,8 @@ function find_html_images($images_dir) {
// If duplicate images are embedded, they may show up as attachments, so remove them.
$html_images = array_unique($html_images);
sort($html_images);
-
- for ($i=0; $i<count($html_images); $i++) {
+ $n=count($html_images);
+ for ($i=0; $i<$n; $i++) {
if ($image = $this->get_file($images_dir . $html_images[$i])) {
$content_type = $this->image_types[substr($html_images[$i], strrpos($html_images[$i], '.') + 1)];
$this->add_html_image($image, basename($html_images[$i]), $content_type);
@@ -351,8 +351,8 @@ function build_message($params = '') {
/* HPDL PHP3 */
// $message =& $this->add_mixed_part();
$message = $this->add_mixed_part();
-
- for ($i=0; $i<count($this->attachments); $i++) {
+ $n=count($this->attachments);
+ for ($i=0; $i<$n; $i++) {
$this->add_attachment_part($message, $this->attachments[$i]);
}
break;
@@ -361,8 +361,8 @@ function build_message($params = '') {
// $message =& $this->add_mixed_part();
$message = $this->add_mixed_part();
$this->add_text_part($message, $this->text);
-
- for ($i=0; $i<count($this->attachments); $i++) {
+ $n=count($this->attachments);
+ for ($i=0; $i<$n; $i++) {
$this->add_attachment_part($message, $this->attachments[$i]);
}
break;
@@ -396,8 +396,8 @@ function build_message($params = '') {
$related = $message;
}
$this->add_html_part($related);
-
- for ($i=0; $i<count($this->html_images); $i++) {
+ $n=count($this->html_images);
+ for ($i=0; $i<$n; $i++) {
$this->add_html_image_part($related, $this->html_images[$i]);
}
break;
@@ -414,8 +414,8 @@ function build_message($params = '') {
} else {
$this->add_html_part($message);
}
-
- for ($i=0; $i<count($this->attachments); $i++) {
+ $n=count($this->attachments);
+ for ($i=0; $i<$n; $i++) {
$this->add_attachment_part($message, $this->attachments[$i]);
}
break;
@@ -438,12 +438,12 @@ function build_message($params = '') {
$rel = $this->add_related_part($message);
}
$this->add_html_part($rel);
-
- for ($i=0; $i<count($this->html_images); $i++) {
+ $n=count($this->html_images);
+ for ($i=0; $i<$n; $i++) {
$this->add_html_image_part($rel, $this->html_images[$i]);
}
-
- for ($i=0; $i<count($this->attachments); $i++) {
+ $n=count($this->attachments);
+ for ($i=0; $i<$n; $i++) {
$this->add_attachment_part($message, $this->attachments[$i]);
}
break;
@@ -497,10 +497,11 @@ function send($to_name, $to_addr, $from_name, $from_addr, $subject = '', $header
if (is_string($headers)) {
$headers = explode($this->lf, trim($headers));
}
-
- for ($i=0; $i<count($headers); $i++) {
+ $n=count($headers);
+ for ($i=0; $i<$n; $i++) {
if (is_array($headers[$i])) {
- for ($j=0; $j<count($headers[$i]); $j++) {
+ $n=count($headers[$i]);
+ for ($j=0; $j<$n; $j++) {
if ($headers[$i][$j] != '') {
$xtra_headers[] = $headers[$i][$j];
}
@@ -551,10 +552,11 @@ function get_rfc822($to_name, $to_addr, $from_name, $from_addr, $subject = '', $
if (is_string($headers)) {
$headers = explode($this->lf, trim($headers));
}
-
- for ($i=0; $i<count($headers); $i++) {
+ $n=count($headers);
+ for ($i=0; $i<$n; $i++) {
if (is_array($headers[$i])) {
- for ($j=0; $j<count($headers[$i]); $j++) {
+ $n=count($headers[$i]);
+ for ($j=0; $j<$n; $j++) {
if ($headers[$i][$j] != '') {
$xtra_headers[] = $headers[$i][$j];
}
Please sign in to comment.
Something went wrong with that request. Please try again.