PHP Code Not Working After Migration to Snippet
-
The PHP code below has been working with the [insert_php] method for a long time on https://dailyprayer.ca/scripture-readings
When I migrated the code to a snippet (minus the [insert_php] and [/insert_php] of course) it did not work correctly.
Please tell me what might be wrong.
Thanks.
Jim[insert_php] date_default_timezone_set('America/Vancouver'); // Create the hyperlink to today's readings on the OYBO site $handle = fopen("https://oneyearbibleonline.com/daily-oyb/?version=ESVUK&nltdt=" . date('md') , "r"); if ($handle) { $srchstrg_pre = 'openweeklylink\(\''; $srchstrg_post = "\'\)"; // Read line by line while (($line = fgets($handle)) !== false) { $line = htmlspecialchars($line); if (preg_match( '/' . $srchstrg_pre . '.+' . $srchstrg_post . '/', $line, $match, PREG_OFFSET_CAPTURE)) { $line = $match[0][0]; $line = substr( $line, strlen( $srchstrg_pre ) -1 ); $line = substr( $line, 0, strlen( $line ) - strlen( $srchstrg_post ) + 2 ); echo "Open the ".date('F j')." Readings in the ESV Anglicized Translation" . PHP_EOL . PHP_EOL; // Now stop reading the file for any more links break; } } // Close the feed fclose($handle); } else { // error opening the file. } // Display today's readings as text references $handle = fopen("https://oneyearbibleonline.com/daily-oyb/?version=ESVUK&nltdt=" . date('md') , "r"); $srchstrg_pre = "One Year Bible Readings"; if ($handle) { // Read line by line while (($line = fgets($handle)) !== false) { $line = htmlspecialchars($line); if (preg_match( '/' . $srchstrg_pre . '/', $line, $match, PREG_OFFSET_CAPTURE)) { $srchstrg_pre = "<strong>.*<\/strong>"; if (preg_match( '/' . $srchstrg_pre . '/', $line, $match, PREG_OFFSET_CAPTURE)) { echo "" . substr($match[0][0],14,strlen($match[0][0])-29) . "" . PHP_EOL; } $srchstrg_pre = "<br \/>.*<br \/>"; if (preg_match( '/' . $srchstrg_pre . '/', $line, $match, PREG_OFFSET_CAPTURE)) { $line = $match[0][0]; $srchstrg_pre = "<br \/>"; while (preg_match( '/' . $srchstrg_pre . '/', $line, $match, PREG_OFFSET_CAPTURE)) { if ($match[0][1] > 0) { echo substr($line,0,$match[0][1]) . PHP_EOL; } $line = substr($line, $match[0][1] + 12); } echo PHP_EOL; } // Now stop reading the file break; } } // Close the feed fclose($handle); } else { // error opening the file. } // Create the general links to the OYBO site and podcast echo "For other dates or translations, check the "; echo "One Year Bible site.". PHP_EOL . PHP_EOL; echo "Listen to the One Year Bible "; echo "podcast."; [/insert_php]
The page I need help with: [log in to see the link]
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘PHP Code Not Working After Migration to Snippet’ is closed to new replies.