Jump to content

iwato

Members
  • Content Count

    1,348
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by iwato

  1. BACKGROUND: I have never experienced anything like it. It were as if the authors purposely sabotaged their software for non-professionals. I have now edited close to a dozen files removing extraneous code with each new fatal error. Finally, however, I have come across a failure that baffles me. DISCUSSION: Line 90 of the error message (see below) is the first line of code of the class's construct function -- namely, $this->cacheKey = bin2hex(random_bytes(16)); // set 32 hex values Now, I have researched both the bin2hex() and random_bytes() function, and I can discover nothing amiss with the implementation of either. The problem appears to lie elsewhere. But, where to look? The ERROR: The FILE: <?php /* * This file is part of SwiftMailer. * (c) 2004-2009 Chris Corbyn * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * A MIME entity, in a multipart message. * * @author Chris Corbyn */ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_Mime_EncodingObserver { /** Main message document; there can only be one of these */ const LEVEL_TOP = 16; /** An entity which nests with the same precedence as an attachment */ const LEVEL_MIXED = 256; /** An entity which nests with the same precedence as a mime part */ const LEVEL_ALTERNATIVE = 4096; /** An entity which nests with the same precedence as embedded content */ const LEVEL_RELATED = 65536; /** A collection of Headers for this mime entity */ private $headers; /** The body as a string, or a stream */ private $body; /** The encoder that encodes the body into a streamable format */ private $encoder; /** Message ID generator */ private $idGenerator; /** A mime boundary, if any is used */ private $boundary; /** Mime types to be used based on the nesting level */ private $compositeRanges = [ 'multipart/mixed' => [self::LEVEL_TOP, self::LEVEL_MIXED], 'multipart/alternative' => [self::LEVEL_MIXED, self::LEVEL_ALTERNATIVE], 'multipart/related' => [self::LEVEL_ALTERNATIVE, self::LEVEL_RELATED], ]; /** A set of filter rules to define what level an entity should be nested at */ private $compoundLevelFilters = []; /** The nesting level of this entity */ private $nestingLevel = self::LEVEL_ALTERNATIVE; /** A KeyCache instance used during encoding and streaming */ private $cache; /** Direct descendants of this entity */ private $immediateChildren = []; /** All descendants of this entity */ private $children = []; /** The maximum line length of the body of this entity */ private $maxLineLength = 78; /** The order in which alternative mime types should appear */ private $alternativePartOrder = [ 'text/plain' => 1, 'text/html' => 2, 'multipart/related' => 3, ]; /** The CID of this entity */ private $id; /** The key used for accessing the cache */ private $cacheKey; protected $userContentType; /** * Create a new SimpleMimeEntity with $headers, $encoder and $cache. */ public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator) { $this->cacheKey = bin2hex(random_bytes(16)); // set 32 hex values $this->cache = $cache; $this->headers = $headers; $this->idGenerator = $idGenerator; $this->setEncoder($encoder); $this->headers->defineOrdering(['Content-Type', 'Content-Transfer-Encoding']); // This array specifies that, when the entire MIME document contains // $compoundLevel, then for each child within $level, if its Content-Type // is $contentType then it should be treated as if it's level is // $neededLevel instead. I tried to write that unambiguously! :-\ // Data Structure: // array ( // $compoundLevel => array( // $level => array( // $contentType => $neededLevel // ) // ) // ) $this->compoundLevelFilters = [ (self::LEVEL_ALTERNATIVE + self::LEVEL_RELATED) => [ self::LEVEL_ALTERNATIVE => [ 'text/plain' => self::LEVEL_ALTERNATIVE, 'text/html' => self::LEVEL_RELATED, ], ], ]; $this->id = $this->idGenerator->generateId(); } /** * Generate a new Content-ID or Message-ID for this MIME entity. * * @return string */ public function generateId() { $this->setId($this->idGenerator->generateId()); return $this->id; } /** * Get the {@link Swift_Mime_SimpleHeaderSet} for this entity. * * @return Swift_Mime_SimpleHeaderSet */ public function getHeaders() { return $this->headers; } /** * Get the nesting level of this entity. * * @see LEVEL_TOP, LEVEL_MIXED, LEVEL_RELATED, LEVEL_ALTERNATIVE * * @return int */ public function getNestingLevel() { return $this->nestingLevel; } /** * Get the Content-type of this entity. * * @return string */ public function getContentType() { return $this->getHeaderFieldModel('Content-Type'); } /** * Get the Body Content-type of this entity. * * @return string */ public function getBodyContentType() { return $this->userContentType; } /** * Set the Content-type of this entity. * * @param string $type * * @return $this */ public function setContentType($type) { $this->setContentTypeInHeaders($type); // Keep track of the value so that if the content-type changes automatically // due to added child entities, it can be restored if they are later removed $this->userContentType = $type; return $this; } /** * Get the CID of this entity. * * The CID will only be present in headers if a Content-ID header is present. * * @return string */ public function getId() { $tmp = (array) $this->getHeaderFieldModel($this->getIdField()); return $this->headers->has($this->getIdField()) ? current($tmp) : $this->id; } /** * Set the CID of this entity. * * @param string $id * * @return $this */ public function setId($id) { if (!$this->setHeaderFieldModel($this->getIdField(), $id)) { $this->headers->addIdHeader($this->getIdField(), $id); } $this->id = $id; return $this; } /** * Get the description of this entity. * * This value comes from the Content-Description header if set. * * @return string */ public function getDescription() { return $this->getHeaderFieldModel('Content-Description'); } /** * Set the description of this entity. * * This method sets a value in the Content-ID header. * * @param string $description * * @return $this */ public function setDescription($description) { if (!$this->setHeaderFieldModel('Content-Description', $description)) { $this->headers->addTextHeader('Content-Description', $description); } return $this; } /** * Get the maximum line length of the body of this entity. * * @return int */ public function getMaxLineLength() { return $this->maxLineLength; } /** * Set the maximum line length of lines in this body. * * Though not enforced by the library, lines should not exceed 1000 chars. * * @param int $length * * @return $this */ public function setMaxLineLength($length) { $this->maxLineLength = $length; return $this; } /** * Get all children added to this entity. * * @return Swift_Mime_SimpleMimeEntity[] */ public function getChildren() { return $this->children; } /** * Set all children of this entity. * * @param Swift_Mime_SimpleMimeEntity[] $children * @param int $compoundLevel For internal use only * * @return $this */ public function setChildren(array $children, $compoundLevel = null) { // TODO: Try to refactor this logic $compoundLevel = $compoundLevel ? $this->getCompoundLevel($children) : $immediateChildren = []; $grandchildren = []; $newContentType = $this->userContentType; foreach ($children as $child) { $level = $this->getNeededChildLevel($child, $compoundLevel); if (empty($immediateChildren)) { //first iteration $immediateChildren = [$child]; } else { $nextLevel = $this->getNeededChildLevel($immediateChildren[0], $compoundLevel); if ($nextLevel == $level) { $immediateChildren[] = $child; } elseif ($level < $nextLevel) { // Re-assign immediateChildren to grandchildren $grandchildren = array_merge($grandchildren, $immediateChildren); // Set new children $immediateChildren = [$child]; } else { $grandchildren[] = $child; } } } if ($immediateChildren) { $lowestLevel = $this->getNeededChildLevel($immediateChildren[0], $compoundLevel); // Determine which composite media type is needed to accommodate the // immediate children foreach ($this->compositeRanges as $mediaType => $range) { if ($lowestLevel > $range[0] && $lowestLevel <= $range[1]) { $newContentType = $mediaType; break; } } // Put any grandchildren in a subpart if (!empty($grandchildren)) { $subentity = $this->createChild(); $subentity->setNestingLevel($lowestLevel); $subentity->setChildren($grandchildren, $compoundLevel); array_unshift($immediateChildren, $subentity); } } $this->immediateChildren = $immediateChildren; $this->children = $children; $this->setContentTypeInHeaders($newContentType); $this->fixHeaders(); $this->sortChildren(); return $this; } /** * Get the body of this entity as a string. * * @return string */ public function getBody() { return $this->body instanceof Swift_OutputByteStream ? $this->readStream($this->body) : $this->body; } /** * Set the body of this entity, either as a string, or as an instance of * {@link Swift_OutputByteStream}. * * @param mixed $body * @param string $contentType optional * * @return $this */ public function setBody($body, $contentType = null) { if ($body !== $this->body) { $this->clearCache(); } $this->body = $body; if (null !== $contentType) { $this->setContentType($contentType); } return $this; } /** * Get the encoder used for the body of this entity. * * @return Swift_Mime_ContentEncoder */ public function getEncoder() { return $this->encoder; } /** * Set the encoder used for the body of this entity. * * @return $this */ public function setEncoder(Swift_Mime_ContentEncoder $encoder) { if ($encoder !== $this->encoder) { $this->clearCache(); } $this->encoder = $encoder; $this->setEncoding($encoder->getName()); $this->notifyEncoderChanged($encoder); return $this; } /** * Get the boundary used to separate children in this entity. * * @return string */ public function getBoundary() { if (!isset($this->boundary)) { $this->boundary = '_=_swift_'.time().'_'.bin2hex(random_bytes(16)).'_=_'; } return $this->boundary; } /** * Set the boundary used to separate children in this entity. * * @param string $boundary * * @throws Swift_RfcComplianceException * * @return $this */ public function setBoundary($boundary) { $this->assertValidBoundary($boundary); $this->boundary = $boundary; return $this; } /** * Receive notification that the charset of this entity, or a parent entity * has changed. * * @param string $charset */ public function charsetChanged($charset) { $this->notifyCharsetChanged($charset); } /** * Receive notification that the encoder of this entity or a parent entity * has changed. */ public function encoderChanged(Swift_Mime_ContentEncoder $encoder) { $this->notifyEncoderChanged($encoder); } /** * Get this entire entity as a string. * * @return string */ public function toString() { $string = $this->headers->toString(); $string .= $this->bodyToString(); return $string; } /** * Get this entire entity as a string. * * @return string */ protected function bodyToString() { $string = ''; if (isset($this->body) && empty($this->immediateChildren)) { if ($this->cache->hasKey($this->cacheKey, 'body')) { $body = $this->cache->getString($this->cacheKey, 'body'); } else { $body = "\r\n".$this->encoder->encodeString($this->getBody(), 0, $this->getMaxLineLength()); $this->cache->setString($this->cacheKey, 'body', $body, Swift_KeyCache::MODE_WRITE); } $string .= $body; } if (!empty($this->immediateChildren)) { foreach ($this->immediateChildren as $child) { $string .= "\r\n\r\n--".$this->getBoundary()."\r\n"; $string .= $child->toString(); } $string .= "\r\n\r\n--".$this->getBoundary()."--\r\n"; } return $string; } /** * Returns a string representation of this object. * * @see toString() * * @return string */ public function __toString() { return $this->toString(); } /** * Write this entire entity to a {@see Swift_InputByteStream}. */ public function toByteStream(Swift_InputByteStream $is) { $is->write($this->headers->toString()); $is->commit(); $this->bodyToByteStream($is); } /** * Write this entire entity to a {@link Swift_InputByteStream}. */ protected function bodyToByteStream(Swift_InputByteStream $is) { if (empty($this->immediateChildren)) { if (isset($this->body)) { if ($this->cache->hasKey($this->cacheKey, 'body')) { $this->cache->exportToByteStream($this->cacheKey, 'body', $is); } else { $cacheIs = $this->cache->getInputByteStream($this->cacheKey, 'body'); if ($cacheIs) { $is->bind($cacheIs); } $is->write("\r\n"); if ($this->body instanceof Swift_OutputByteStream) { $this->body->setReadPointer(0); $this->encoder->encodeByteStream($this->body, $is, 0, $this->getMaxLineLength()); } else { $is->write($this->encoder->encodeString($this->getBody(), 0, $this->getMaxLineLength())); } if ($cacheIs) { $is->unbind($cacheIs); } } } } if (!empty($this->immediateChildren)) { foreach ($this->immediateChildren as $child) { $is->write("\r\n\r\n--".$this->getBoundary()."\r\n"); $child->toByteStream($is); } $is->write("\r\n\r\n--".$this->getBoundary()."--\r\n"); } } /** * Get the name of the header that provides the ID of this entity. */ protected function getIdField() { return 'Content-ID'; } /** * Get the model data (usually an array or a string) for $field. */ protected function getHeaderFieldModel($field) { if ($this->headers->has($field)) { return $this->headers->get($field)->getFieldBodyModel(); } } /** * Set the model data for $field. */ protected function setHeaderFieldModel($field, $model) { if ($this->headers->has($field)) { $this->headers->get($field)->setFieldBodyModel($model); return true; } return false; } /** * Get the parameter value of $parameter on $field header. */ protected function getHeaderParameter($field, $parameter) { if ($this->headers->has($field)) { return $this->headers->get($field)->getParameter($parameter); } } /** * Set the parameter value of $parameter on $field header. */ protected function setHeaderParameter($field, $parameter, $value) { if ($this->headers->has($field)) { $this->headers->get($field)->setParameter($parameter, $value); return true; } return false; } /** * Re-evaluate what content type and encoding should be used on this entity. */ protected function fixHeaders() { if (count($this->immediateChildren)) { $this->setHeaderParameter('Content-Type', 'boundary', $this->getBoundary() ); $this->headers->remove('Content-Transfer-Encoding'); } else { $this->setHeaderParameter('Content-Type', 'boundary', null); $this->setEncoding($this->encoder->getName()); } } /** * Get the KeyCache used in this entity. * * @return Swift_KeyCache */ protected function getCache() { return $this->cache; } /** * Get the ID generator. * * @return Swift_IdGenerator */ protected function getIdGenerator() { return $this->idGenerator; } /** * Empty the KeyCache for this entity. */ protected function clearCache() { $this->cache->clearKey($this->cacheKey, 'body'); } private function readStream(Swift_OutputByteStream $os) { $string = ''; while (false !== $bytes = $os->read(8192)) { $string .= $bytes; } $os->setReadPointer(0); return $string; } private function setEncoding($encoding) { if (!$this->setHeaderFieldModel('Content-Transfer-Encoding', $encoding)) { $this->headers->addTextHeader('Content-Transfer-Encoding', $encoding); } } private function assertValidBoundary($boundary) { if (!preg_match('/^[a-z0-9\'\(\)\+_\-,\.\/:=\?\ ]{0,69}[a-z0-9\'\(\)\+_\-,\.\/:=\?]$/Di', $boundary)) { throw new Swift_RfcComplianceException('Mime boundary set is not RFC 2046 compliant.'); } } private function setContentTypeInHeaders($type) { if (!$this->setHeaderFieldModel('Content-Type', $type)) { $this->headers->addParameterizedHeader('Content-Type', $type); } } private function setNestingLevel($level) { $this->nestingLevel = $level; } private function getCompoundLevel($children) { $level = 0; foreach ($children as $child) { $level |= $child->getNestingLevel(); } return $level; } private function getNeededChildLevel($child, $compoundLevel) { $filter = []; foreach ($this->compoundLevelFilters as $bitmask => $rules) { if (($compoundLevel & $bitmask) === $bitmask) { $filter = $rules + $filter; } } $realLevel = $child->getNestingLevel(); $lowercaseType = strtolower($child->getContentType()); if (isset($filter[$realLevel]) && isset($filter[$realLevel][$lowercaseType])) { return $filter[$realLevel][$lowercaseType]; } return $realLevel; } private function createChild() { return new self($this->headers->newInstance(), $this->encoder, $this->cache, $this->idGenerator); } private function notifyEncoderChanged(Swift_Mime_ContentEncoder $encoder) { foreach ($this->immediateChildren as $child) { $child->encoderChanged($encoder); } } private function notifyCharsetChanged($charset) { $this->encoder->charsetChanged($charset); $this->headers->charsetChanged($charset); foreach ($this->immediateChildren as $child) { $child->charsetChanged($charset); } } private function sortChildren() { $shouldSort = false; foreach ($this->immediateChildren as $child) { // NOTE: This include alternative parts moved into a related part if (self::LEVEL_ALTERNATIVE == $child->getNestingLevel()) { $shouldSort = true; break; } } // Sort in order of preference, if there is one if ($shouldSort) { // Group the messages by order of preference $sorted = []; foreach ($this->immediateChildren as $child) { $type = $child->getContentType(); $level = array_key_exists($type, $this->alternativePartOrder) ? $this->alternativePartOrder[$type] : max($this->alternativePartOrder) + 1; if (empty($sorted[$level])) { $sorted[$level] = []; } $sorted[$level][] = $child; } ksort($sorted); $this->immediateChildren = array_reduce($sorted, 'array_merge', []); } } /** * Empties it's own contents from the cache. */ public function __destruct() { if ($this->cache instanceof Swift_KeyCache) { $this->cache->clearAll($this->cacheKey); } } /** * Make a deep copy of object. */ public function __clone() { $this->headers = clone $this->headers; $this->encoder = clone $this->encoder; $this->cacheKey = bin2hex(random_bytes(16)); // set 32 hex values $children = []; foreach ($this->children as $pos => $child) { $children[$pos] = clone $child; } $this->setChildren($children); } } Please advise. Roddy
  2. iwato

    SwiftMailer - An Odyssey of Reconstruction

    No, I did not look up the operator, for it made no sense. What did make sense was a typo. Then, I looked at the surrounding code and tried to understand what was going on. After which I played with it until I found something that made sense and PHP no longer complained. I made a dozen other similar corrections on a variety of pages before I finally stumbled with PHP rejecting its own CORE function. Roddy
  3. iwato

    SwiftMailer - An Odyssey of Reconstruction

    $this->addressEncoder = !empty($addressEncoder) ? $addressEncoder : new Swift_AddressEncoder_IdnAddressEncoder(); This is exactly what I did do and moved onto the next error and correction, but before going any further let us wait until I have clarified with my host provider why all of my CRONTAB jobs are pointed to 5.6 and my default and domain settings are pointing to 7.2. This now appears to be the likely source of the problem, for after all, the scheduler.php that I set up depends on the CRONTAB for its existence. Roddy
  4. iwato

    SwiftMailer - An Odyssey of Reconstruction

    OK. I had lunch in between, but here it is: the first reported error. public function __construct(Swift_Transport_IoBuffer $buf, Swift_Events_EventDispatcher $dispatcher, $localDomain = '127.0.0.1', Swift_AddressEncoder $addressEncoder = null) { $this->buffer = $buf; $this->eventDispatcher = $dispatcher; $this->addressEncoder = $addressEncoder ?? new Swift_AddressEncoder_IdnAddressEncoder(); $this->setLocalDomain($localDomain); } The line indicated by PHP as the source of error. $this->addressEncoder = $addressEncoder ?? new Swift_AddressEncoder_IdnAddressEncoder(); If you need the error message, here is that as well. [19-Nov-2018 21:38:02 UTC] PHP Parse error: syntax error, unexpected '?' in /home/thege0/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php on line 53 Roddy p.s. The software was downloaded and installed with no version requirement using the following command. If I remember correctly, in the absence of a version number Composer provides automatically the most recent stable version. [...@vps ~]$ php composer.phar require swiftmailer/swiftmailer
  5. iwato

    SwiftMailer - An Odyssey of Reconstruction

    With your and Ingolme's insistence that the problem lies with the PHP version I have performed a little exploration and discovered that the bin folder path to the PHP binary file for my CRONTAB is set to PHP 5.6 and not to PHP 7.2 as are my primary domain and each of my add-on domains that employ PHP. I have notified my webserver host in regard to this inconsistency and am waiting for their reply. You see, Swiftmailer is used by CRON Scheduler to deliver notification about the successful execution of CRON jobs. Is it not likely then that the same version of PHP is used to run both pieces of software? In any case, I have already removed Swiftmailer and am in the process of reinstalling it. Further, changing the version of PHP should have no effect on the defective PHP code that I was compelled to modify in order to get SwiftMailer to even execute up to the point where the random_bytes( ) CORE function was needed. Hopefully, I will be back in a short while with the first problematic piece of SwiftMailer code. Roddy
  6. iwato

    SwiftMailer - An Odyssey of Reconstruction

    I have an easier and perhaps more informative way of achieving the same: [...@vps ~]$ php -v ea-php-cli Copyright 2017 cPanel, Inc. PHP 7.2.12 (cli) (built: Nov 13 2018 21:12:16) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies Roddy
  7. iwato

    SwiftMailer - An Odyssey of Reconstruction

    OK. I will uninstall and reinstall the software. However, rather than editing the software as I did before and thereby removing each and every fatal error that I encountered until PHP told that a PHP CORE function does not work. I will let the mentorship of W3Schools have a look at the code and error first. Indeed, what I expected to hear from y'all, I did not -- namely, that the PHP error regarding the random_bytes() function is not the true source of the error, and that something in the preceding line of code is triggering it -- say a call to a faulty class that I had perhaps created during one of my many edits. I am looking forward to a very interesting and perhaps even enlightening week with W3Schools for all concerned. Roddy
  8. BACKGROUND: I have a page with a link whose normal behavior is suppressed in order to make room for a script that produces a gallery of frames when the new page opens. The LINK <div class="moji"> <a id='hito_rireki' onclick="return false;" href="Emblem/hito.html"> <img src="Emblem/_Images/to.gif" width="105" height="90" alt="(人という文字) The Sino-Japanese Character for Person" title="クリックして下さい!" /> </a> </div> QUESTION: Is there a way to trigger this same link from a completely different page that does not involve the use of a GET or POST HTTPRequest? Roddy
  9. iwato

    SwiftMailer - An Odyssey of Reconstruction

    The syntax errors that I showed you have been corrected file after file after file. Were I to retrace the errors I would have to reinstall the software and start all over again. It were as if the authors were trying to show the painstaking work that they went through to create the software, or alternatively all of the different ways that it could be adapted to specific needs. This is what I meant when I said it is software designed for professionals. Roddy
  10. Great! Now please pass your cursor over the heart and click on the trophy to say thanks! I hope that it was because of me that you were able to achieve your goal. Roddy
  11. iwato

    SwiftMailer - An Odyssey of Reconstruction

    Ingolme: My, my! Who bit you and why? You need to find out, for it was not me. The version of PHP that I am using to run SwiftMailer, and that I installed with Composer is 7.2. What is more, I said that I researched both the bin2hex( ) and random_bytes( ) functions before I posted. Now, although it is true that I am running locally at PHP 5+, SwiftMailer is not installed on my machine. Any other ideas? Roddy p.s. Here are just two of the many syntax errors that I can easily remember having corrected. function ( ... ) : string { ... } and $variable = ??;
  12. iwato

    Image Capture and Display

    BACKGROUND: With a mixture of melancholy reluctance and what-else-to-do excitement I have returned to Matomo and managed to extract what appears to be an image. In effect, I am echoing a cUR result set that appears as follows: �PNG IHDR "�E! pHYs���+�IDATx���}�E����ٙ�K6�n ل���DP�FT�_��r���;ėS<���;.���E��D�<5'QP ��o �I��IV6�dC�n6��f6;3}4M���LW������L�Tw��2����J�u]@�L� H�b,�X��#`(F�����v�B۷\�!#`%OWWרo���+�� ... My intuition -- I am sorry, if I can offer little more at this point -- tells me that I could read the contents of this file with the simple addition of a document heading. If so, what might this heading be. If not, what would you suggest? Please advise. Roddy
  13. iwato

    Image Capture and Display

    Yes, it worked! See api_module.php Thanks! Roddy
  14. iwato

    Chaining PHP Class Methods

    BACKGROUND: While implementing Peppe Occhi's CRON Scheduler I have come across several lines of code that I am not entirely familiar. In particular I am concerned with the following: $scheduler->php('script.php')->hourly(); found under the heading Schedules execution time. It appears to be of this format $some_instance->some_methodA(arguments)->method_B(arguments); QUESTION: Is the above expression equivalent to the following: $some_instance->some_methodA(arguments); $some_instance->method_B(arguments); In other words, the following is correct: $scheduler->php( 'path_to_folder/script.php', 'path_to_php_version/ea-php72', ['-c' => 'ignore','--merge' => null,], 'file_name' ); $scheduler->hourly(); Please advise. Roddy
  15. iwato

    Chaining PHP Class Methods

    FOLLOW-UP QUESTION: In light of the above does the following make sense: $matomo_api = new Scheduler(); $matomo_freq = $matomo_api->php('.../fetch_and_store.php','.../bin/ea-php72',['-c' => 'ignore','--merge' => null,],'matomo_api'); $matomo_freq->hourly(); $matomo_api->run(); Roddy
  16. Have you examined the URL carefully? BEFORE YOU CLICK: https://www.wpbeginner.com/beginners-guide/why-you-need-a-cdn-for-your-wordpress-blog-infographic AFTER YOU CLICK https://www.wpbeginner.com/beginners-guide/why-you-need-a-cdn-for-your-wordpress-blog-infographic/?display=wide Notice that a query with a key-value pair has been added. /?display=wide That is a call to PHP code on the same document page that reloads the reloads the page with new content. As no one can see the PHP but the creator and/or webpage host, it is difficult to know how it was achieve. One way, however, might be to use a PHP header() statement and simply reload the page with new content header("Location: https://www.wpbeginner.com/beginners-guide/why-you-need-a-cdn-for-your-wordpress-blog-infographic"); I have never tried to do this before, but others may be able to confirm or disconfirm whether it will work. I, myself, can imagine no objection. Roddy
  17. iwato

    Data Retrieval - Sundry Formats

    BACKGROUND: Between one and two moons ago I inquired about a strategy for speeding up my Matomo processing time, whereupon both Funce and Dsonesuk provided excellent insight in this regard. I am now on the verge of setting up a CRON Job to perform scheduled calls to the Matomo data base. Before implementing the scheduler, however, I must be clear about the format that I am to use to handle the data. As I am provided with a variety of formats, I decided to explore those that I thought would be useful before deciding on one. To my dismay I am overwhelmed with what I discovered. Both of the following responses represent the first few lines of the same cURL request. The only change when making these requests was the indicated formats. The problem is that I have no idea how to handle data in these formats. PHP a:100:{ i:0;a:96:{ s:6:"idSite";i:1; s:7:"idVisit";i:914; XML 1 914 205.175.107.119 ... action http://www.grammarcaptive.com/podcast_hostpage.php?hash=30a6836a3f7c5fc57751a61098e5c2fc&podcast_no=92 Grammar Captive Weekly Podcasts 14 wYBSoJ Nov 14, 2018 08:47:46 25338 25 25s 1824 1.82s 1 1542185266 action https://www.grammarcaptive.com/overview.html Grammar Captive Overview 6 CLxGe9 Nov 14, 2018 08:48:11 25339 1 1s 2419 2.42s 2 1542185291 action http://grammarcaptive.com/_gates/gate1/gate1.html Gate One - What Makes Grammar Captive Different 33 aXaszd Nov 14, 2018 08:48:12 25340 0 0s 262 0.26s 3 1542185292 action https://www.grammarcaptive.com/_gates/gate3/gate3.html Gate Three - Is Grammar Captive for You? 50 The three dots (...) represent sensitive data values. The indendation and line spacing was added by me. Although the first set of data resembles very closely that of JSON, the second set of data is completely lacking in the metadata required to understand what is being returned. Unfortunately, I have no idea how to handle either in the given formats. Please advise. Roddy
  18. iwato

    Data Retrieval - Sundry Formats

    Thank you all, but especially Ingolme, for she answered my question in the most thorough manner possible. I am currently testing Peppe Occhi's CRON Scheduler routine and have yet to decide whether I will take Funce's suggestion to pass my results to a database or Dsonesuk's suggestion to write to an XML file. After all this time, I am still not comfortable with the data that I am able to extract from the Matomo data base via its reporting APIs, and more research is still ahead before I can decide how to fetch and store the data on a routine basis. At least now I know better what my options are and how to proceed with them once I have decided. Have a great weekend. Mine will be spent on the internet, as nearly always until I have launched. Roddy
  19. iwato

    header info query

    Here is what I obtain 0: HTTP/1.0 301 Moved Permanently 1: Date: Sun, 11 Nov 2018 22:52:03 GMT 2: Strict-Transport-Security: max-age=31536000 3: Via: http/1.1 media-router-fp1002.prod.media.ne1.yahoo.com (ApacheTrafficServer [c s f ]) 4: Server: ATS 5: Cache-Control: no-store, no-cache 6: Content-Type: text/html 7: Content-Language: en 8: Connection: keep-alive 9: X-Frame-Options: SAMEORIGIN 10: Expect-CT: max-age=31536000, report-uri="http://csp.yahoo.com/beacon/csp?src=yahoocom-expect-ct-report-only" 11: Location: https://www.yahoo.com/ 12: Content-Length: 8 13: HTTP/1.0 200 OK 14: Cache-Control: no-store, no-cache, max-age=0, private 15: Content-Encoding: gzip 16: Content-Type: text/html; charset=UTF-8 17: Date: Sun, 11 Nov 2018 22:48:04 GMT 18: Server: ATS 19: x-amz-server-side-encryption: AES256 20: Age: 239 21: Via: https/1.1 media-ncache-fp29.prod.media.gq1.yahoo.com (ApacheTrafficServer [cMsSf ]), http/1.1 media-ncache-fp29.prod.media.gq1.yahoo.com (ApacheTrafficServer [cSsSfU]), http/1.1 media-ncache-fp29.prod.media.gq1.yahoo.com (ApacheTrafficServer [cRs f ]), http/1.1 media-ncache-fp34.prod.media.gq1.yahoo.com (ApacheTrafficServer [cMsSf ]), http/1.1 media-router-fp1009.prod.media.gq1.yahoo.com (ApacheTrafficServer [cMsSf ]) 22: Content-Length: 226066 23: P3P: policyref="http://info.yahoo.com/w3c/p3p.xml, CP="CAO DSP COR CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE LOC GOV 24: Expires: -1 25: Strict-Transport-Security: max-age=31536000 26: Content-Security-Policy: sandbox allow-forms allow-same-origin allow-scripts allow-popups allow-popups-to-escape-sandbox allow-presentation; report-uri https://csp.yahoo.com/beacon/csp?src=ats&site=frontpage®ion=US&lang=en-US&device=&yrid=dfh5u61duhckj&partner=; 27: X-Frame-Options: SAMEORIGIN 28: X-XSS-Protection: 1; report="https://csp.yahoo.com/beacon/csp?src=fp-hpkp-www" 29: Expect-CT: max-age=31536000, report-uri="http://csp.yahoo.com/beacon/csp?src=yahoocom-expect-ct-report-only" when I run $url = 'https://yahoo.com'; $output = get_headers($url); foreach ($output as $key => $value) { echo $key . ': ' . $value . '<br />'; } Note: X-Frame-Options: SAMEORIGIN Roddy
  20. CONCERN: The following function does what it is suppose to do -- namely, select at random and without duplication a given number of elements from an array of elements. However, I fear that it is hopelessly awkward and would like your professional assessment of its construction. You will likely not find another like it on the internet, but parts of it were obtained therefrom. function selectCubes(gates) { function onlyUnique(value, index, self) { return self.indexOf(value) === index; } var cubes = ['cube_one', 'cube_two', 'cube_three', 'cube_four', 'cube_five', 'cube_six', 'cube_seven']; var selectedCubes = []; var filteredCubes = []; var n = 0; while (n < gates) { selectedCube = cubes[Math.floor(Math.random()*cubes.length)]; selectedCubes.push(selectedCube); if (filteredCubes.length < gates) { var filteredCubes = selectedCubes.filter(onlyUnique); n++; } } return filteredCubes; } console.log('selectCubes(3):' + selectCubes(3)); Please comment and have a great weekend! Roddy
  21. iwato

    A Flexible PHPMailer Factory Class with Traits

    This has already been achieved elsewhere, separately and differently, for each case. I am sure that the five lines of code of which you speak are included in the code that I have described above, else the code would not perform its most essential task. These lines of code, however, are hardly the purpose of my having gone through the trouble of writing the code. This said, do you find any errors in that what I have presented beyond those which Funce has already addressed? Roddy
  22. BACKGROUND: After a careful study of the use of traits I have come up with the following schema for PHPMailer factory class to cover a large variety of circumstances. ./global.init.php <?php error_reporting(E_ALL ^ E_STRICT); ini_set('error_log', __DIR__ . '/error.log'); include './php_mailer/PHPMailerAutoload.php'; include './classes/class.phpmailer_factory.php'; include './classes/trait.smtpserver_config.php'; include './classes/trait.phpmailer_newsletter_config.php'; include './classes/trait.phpmailer_verification_config.php': include './classes/trait.phpmailer_confirmation_config.php'; ?> trait.smtpserver_config.php <?php trait SmtpServerConfig { static $smtp_server = ''; static $smtp_port = ''; } ?> trait.phpmailer_newsletter_config.php <?php trait PHPMailerNewsletterConfig { use SmtpServerConfig; private $email_account_name = '...'; private $email_account_pswd = '...'} private $sender_addr = '...'; private $sender_name = '...'; private $replyto_addr = '...'; private $replyto_name = '...'; private $subject = '...'; private $html_message = '...'; private $alt_message = '...'; public function set_letter_contents($subject, $html_message, $alt_message) { $this->Subject = $subject; $this->msgHTML($html_message); $this->AltBody = $alt_message; } } ?> class.phpmailer_factory.php <?php class PHPMailerFactory extends PHPMailer { error_reporting(E_ALL ^ E_STRICT); ini_set('error_log', __DIR__ . '/error.log'); use SmtpServerConfig; private $use = ''; if ($this->use = 'newsletter') { use PHPMailerNewsletterConfig; } else if ($this->use = 'verification') { use PHPMailerVerifyConfig; } else if ($this->use = 'confirmation') { use PHPMailerConfirmConfig; } else { die('Please designate an appropriate trait'); } private $charset = ''; private $smtp_debug = 0; private $smtp_output = 'html'; private $smtp_auth = 'true'; public function __construct($use, $username, $email, $charset='UTF-8', $debug=0) { parent::__construct() $this->use = $use; $this->addAddress($email, $username); $this->CharSet = $this->charset; $this->Host = self::hostserver; $this->Port = self::smpt_port; $this->isSMTP(); $this->SMTPDebug = $this->smtp_debug; $this->Debugoutput = $this->smtp_output; $this->SMTPAuth = $this->smtp_auth; $this->Username = $this->email_account_name; $this->Password = $this->email_account_pswd; $this->setFrom($this->sender_addr, $this->sender_name); $this->addReplyTo($this->replyto_addr, $this->replyto_name); $this->Subject = $this->subject; $this->msgHTML($this->html_message); $this->AltBody = $this->alt_message; } public function set_charset($charset) { $this->charset = $charset; } public function get_charset() { return $this->charset; } } ?> Please comment on its efficacy. Your criticism and praise are both welcome. Roddy
  23. iwato

    A Flexible PHPMailer Factory Class with Traits

    Ingolme, I hope to correspond with my visitors in a variety of ways, and I find the language of PHPMailer awkward and confusing. I am trying to rewrite it in a way that I can understand quickly what is going on and make changes without a lot of research each and every time that I need to modify it. If the above can eventually be made to work, then I am very comfortable with the new structure. Where for example do you think the trait use SmtpServerConfig; should be entered? I have entered it in two places, and it likely needs to be entered only once. Roddy
  24. iwato

    A Flexible PHPMailer Factory Class with Traits

    Thank you, Funce. Both of those were silly errors on my part. I have been a little overwhelmed with this entire task, and if this is all the errors that can be found, then I will be most elated. Already you have earned a trophy. Simply I have not added it yet out of fear that everyone will stop looking for more holes to poke. :-) Roddy
  25. iwato

    JavaScript function collision?

    Is the $.when() function what you are looking for? This function provides a way to execute callback functions based on zero or more Thenable objects. These latter are usually Deferred objects that represent asynchronous events. Roddy
×