End of Support for Joomla 3 - Forum closed

Fatal error: Call to undefined function curl_init

  • nomi
  • nomi's Avatar Offline Topic Author
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 1
  • Thank you received: 0

Fatal error: Call to undefined function curl_init was created by nomi

Posted 8 years 3 months ago #14839
Hello all,
We had to reinstall the template after an Upgrade. The template Worldnews was purchased at 16.5.2016.
Now i could install joomla by using quickinstall (with example Pages). I can login to backend but in the frontend (index.php) i am getting this error.
"
Fatal error: Call to undefined function curl_init() in /home/mydomain/public_html/stage3/modules/mod_rokstock/lib/googlestock.class.php on line 92
"
Line 92 contains:
Code:
$ch = curl_init();

The Parameter starts from line 90
Code:
function curl($url, &$output, $strip = false) { $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($ch, CURLOPT_TIMEOUT, 60); $output = curl_exec($ch); if ($strip) $output = substr($output, 4, -1); $httpinfo = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); return $httpinfo; }


I am not very strong in PHP but it seems to be a problem which never came before in old envoirement.
Could some have look in the file and give me some Hints ?
Big THANKS

file: googlestock.class.php
Code:
<?php /** * @version $Id: googlestock.class.php 30070 2016-03-09 08:02:59Z matias $ * @author RocketTheme http://www.rockettheme.com * @copyright Copyright (C) 2007 - 2016 RocketTheme, LLC * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only * */ // no direct access defined('_JEXEC') or die('Restricted access'); jimport('joomla.filesystem.file'); jimport('joomla.filesystem.folder'); /* PHP 4 fix */ if (!function_exists('json_encode') || !function_exists('json_decode')) include_once(dirname(__FILE__).'/lib/JSON.php'); /** * */ class googleStock { /** * @var */ var $raw_data; /** * @var array */ var $url = array( "data" => "http://www.google.com/finance/info?client=ig&q=", "charts" => "http://www.google.com/finance/chart?cht=c&q=", "match" => "http://www.google.com/finance/match?matchtype=matchall&q=" ); /** * @var #Funserialize|array|? */ var $DB = array(); /** * @var string */ var $DBFolder = ""; /** * @var string */ var $DBFile = "rokstock-names.db"; /** * @param $db_folder */ function __construct($db_folder) { $this->DBFolder = $db_folder; $this->DBFile = $db_folder . '/' . $this->DBFile; $this->DB = $this->load_db(); } /** * @param $stocks * * @return bool */ function makeRequest($stocks) { $httpinfo = $this->curl($this->url["data"] . urlencode($stocks), $this->raw_data, true); if ($httpinfo == 400) return false; else { $this->raw_data = json_decode($this->raw_data, true); foreach ($this->raw_data as $data) { if (!array_key_exists($data["id"], $this->DB)) { $this->get_ticker_name($data); } $data_key = key($this->array_search_recursive($data["id"], $this->raw_data)); $this->raw_data[$data_key]["n"] = $this->DB[$data["id"]]["n"]; } return $this->raw_data; } } /** * @param $url * @param $output * @param bool $strip * * @return mixed */ function curl($url, &$output, $strip = false) { $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($ch, CURLOPT_TIMEOUT, 60); $output = curl_exec($ch); if ($strip) $output = substr($output, 4, -1); $httpinfo = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); return $httpinfo; } /** * @return array|mixed */ function load_db() { if (file_exists($this->DBFile)) return unserialize(JFile::read($this->DBFile)); else return $this->write_db(); } /** * @param array $return_array * * @return array */ function write_db($return_array = array()) { if (!JFile::exists($this->DBFolder)) { // attempt to make the dir JFolder::create($this->DBFolder, 0777); } $serilized_return_array = serialize($return_array); $dbfile = $this->DBFile; if (!JFile::write($dbfile, $serilized_return_array)) { echo "<br />Could not save data to cache. Please make sure your cache directory exists and is writable.<br />"; } return $return_array; } /** * @param $data */ function get_ticker_name($data) { $ticker = false; $this->curl($this->url["match"] . $data["t"], $ticker); $patterns = array("\\x26", "\\x2F", "\\x3B", "\\x27"); $replace = array("&", "/", ";", "'"); $ticker = str_replace($patterns, $replace, $ticker); $ticker = json_decode($ticker, true); foreach ($ticker["matches"] as $tickers) { if (!array_key_exists($tickers["id"], $this->DB)) { $this->DB[$tickers["id"]] = array( "t" => $tickers["t"], "n" => $tickers["n"], "e" => $tickers["e"] ); } } $this->write_db($this->DB); } /** * @param $needle * @param $haystack * * @return array */ function array_search_recursive($needle, $haystack) { $path = array(); foreach ($haystack as $id => $val) { if ($val === $needle) { $path[] = $id; break; } else if (is_array($val)) { $found = $this->array_search_recursive($needle, $val); if (count($found) > 0) { $path[$id] = $found; break; } } } return $path; } }
by nomi

Please Log in or Create an account to join the conversation.

Replied by joomlaplates on topic Fatal error: Call to undefined function curl_init

Posted 8 years 3 months ago #14847
Hi there,
please download and re-install the module again:
www.rockettheme.com/joomla/extensions/rokstock

Which PHP version do you use?

Please Log in or Create an account to join the conversation.

Moderators: joomlaplates

Installations-Service

Don´t waste your time, we install your purchased Template
with the "Demo Content" within the next 24 hours.

Buy Now - 59€

Joomlaplates/Theme-Point is not affiliated with or endorsed by Open Source Matters or the Joomla! Project

Copyright © 2024 JoomlaPlates | Professional Joomla Templates with Uikit 3

Disclaimer & Privacy | License