@ 2015-11-12T16:57:25Z <?php
/*
Desc: Imports new Categories into database bet3000 (expected to run once daily)
*/
ini_set('display_errors', 1);
error_reporting(E_ALL & ~E_NOTICE);
$possible_languages=array('de','en','tr','es','el','ru','fr');
$wanted_languages=array('de');
/* DB CONNECT */
$host = "localhost"; // Host name
$username_mysql = "d01ff632"; // Mysql username
$password_mysql = "achimundeva"; // Mysql password
$db_name = "d01ff632"; // Database name
/** Connect to server and select databse. * */
@mysql_connect("$host_mysql", "$username_mysql", "$password_mysql") or die("Cannot connect to database. Please edit the file settings.php");
mysql_select_db("$db_name") or die("Cannot select temp database.");
mysql_query("SET NAMES 'utf8'");
/* IMPORT SPORTS CATEGORIES */
foreach ($wanted_languages as $lang) {
echo "import categories for lang=$lang\n";
$url = "https://www.bet3000.com/".$lang."/jsonrpc/?jsonrpc=2.0&id=0&method=sportsbook.get_active_categories";
try {
$data = file_get_contents($url);
$data = json_decode($data, true);
$query = "UPDATE home_categories SET active=0";
if (!$debug) { mysql_query($query); }
$cat_lvl_ids[0] = array("id" => 0,"label" => "");
$prev_lvl = 0;
$parent_id = 0;
$index = 0;
$flag = false;
$sortid=0;
foreach ($data ['categories'] as $key => $value){
$sortid++;
$cat = new Category($value);
$lvl = $cat->get_level();
$id = $cat->get_id();
$active = $cat->get_activated_id();
$cat_lvl_ids[$lvl]["id"] = $id;
$parent_id = $cat_lvl_ids[$lvl-1]["id"];
$parent_lbl = "";
if(!empty($cat_lvl_ids[$lvl-1]["label"])) {
$parent_lbl = $cat_lvl_ids[$lvl-1]["label"]." / ";
}
$path = $parent_lbl . $cat->get_label();
$cat_lvl_ids[$lvl]["label"] = $path;
$explode = explode(" / ",$path);
$detail = $explode[count($explode)-1];
$sport = $explode[0];
$qcheck="SELECT * FROM `home_categories` WHERE cid=".$id." AND lang='".$lang."'";
$rcheck=mysql_query($qcheck);
if (mysql_num_rows($rcheck)>0) {
$ocheck=mysql_fetch_object($rcheck);
$sqladd ="";
$sqladd.= ",path='".trim(mysql_real_escape_string($path))."', detail='".trim(mysql_real_escape_string($detail))."'";
// UPDATE path,detail,sortid,active
$querynew="UPDATE home_categories SET active=".$active.",sortid=".$sortid.$sqladd." WHERE cid=".$id." AND lang='".$lang."'";
mysql_query($querynew);
echo mysql_error();
}
else {
$sqlheaderadd="";
$sqladd ="";
$query = "INSERT IGNORE INTO `home_categories` (cid,lang,detail,path,topcatid,stufe,sport,sortid,active) VALUES (".
$id.", ".
"'".$lang."', ".
"'".trim(mysql_real_escape_string($detail))."', ".
"'".trim(mysql_real_escape_string($path))."', ".
$parent_id.", ".
$lvl.", ".
"'".trim(mysql_real_escape_string($sport))."', ".
$sortid.", ".
$active.
")";
$resultInsert = mysql_query($query);
if(!$resultInsert)
echo mysql_error()."<br>$query";
}
$prev_lvl = $lvl;
}
//foreach($result as $v) {
// echo $value."<br>";
//}
}
catch(Exception $e) {
echo $e->getMessage();
}
}
echo 'Categories added to database';
class Category {
private $id;
private $lvl;
private $label;
private $activated_id;
private $children;
public function __construct($cat) {
$this->id = $cat['id'];
$this->lvl = $cat['level'];
$this->label = $cat['label'];
$this->activated_id = $cat['activated_id'];
$this->children = array();
}
public function get_id() {
return $this->id;
}
public function get_level() {
return $this->lvl;
}
public function get_label() {
return $this->label;
}
public function get_activated_id() {
return $this->activated_id;
}
public function get_children() {
return $this->children;
}
public function set_id($id) {
$this->id = $id;
}
public function set_level($lvl) {
$this->lvl = $lvl;
}
public function set_label($label) {
$this->label = $label;
}
public function set_children($children) {
$this->children = $children;
}
public function add_child($child) {
$this->children[] = $child;
}
public function get_child($index) {
return $this->children[$index];
}
public function remove_child($child,$index) {
$this->children[] = null;
}
public function __toString() {
return "Category Lvl:".$this->get_level()." - ".$this->get_id(). ":".$this->get_label();
}
}
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 7.0.0 - 7.0.33 , 7.1.0 - 7.1.33 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.6 Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /in/03B2v:19
Stack trace:
#0 {main}
thrown in /in/03B2v on line 19
Process exited with code 255 . Output for 5.5.0 - 5.5.38 , 5.6.0 - 5.6.40 Process exited with code 255 . preferences:dark mode live preview
242.24 ms | 402 KiB | 330 Q