0) { echo json_encode(array('error'=>$error)); // Else check for new users } else { // Establish database connection try { $pdo=new PDO("mysql:host=".$config['dbHost'].";dbname=".$config['dbName'],$config['dbUser'],$config['dbPwd'],array(PDO::MYSQL_ATTR_INIT_COMMAND=>"SET NAMES utf8")); $pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); // Get amount of users that are new or received an update // The Query needs to be altered to your database. This is just an example! $sql="SELECT COUNT(`userID`) AS `amount` FROM `ws_C4J_user` WHERE (`userID`>? OR `updatetime`>?) AND `activated`=1 AND `banned` IS NULL"; $query=$pdo->prepare($sql); $query->execute(array($lastID,$updateTime)); $total=$query->fetchColumn(); // JSON array $json=array(); // User export if ($list=='user') { // This query fetches the actual data. // The Query needs to be altered to your database. This is just an example! // specify the needed columns to reduce database load. // webspell if ($config['sourceType']=='webspell') { $sql="SELECT * FROM `usertable` WHERE (`userID`>? OR `updatetime`>?) AND `activated`=1 AND (`banned` IS NULL OR `banned`='') LIMIT $start,$chunkSize"; $query=$pdo->prepare($sql); $query->execute(array($lastID,$updateTime)); foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) { // Easy-Wi stores the salutation with numbers if (isset($row['salutation']) and $row['salutation']=='mr') { $salutation=1; } else if (isset($row['salutation']) and $row['salutation']=='ms') { $salutation=2; } else { $salutation=null; } // the keys needs to be adjusted to your table layout and query! $json[]=array( 'externalID'=>$row['userID'], 'salutation'=>$salutation, 'email'=>$row['email'], 'loginName'=>$row['username'], 'firstName'=>$row['firstname'], 'lastName'=>$row['lastname'], 'birthday'=>$row['birthday'], 'country'=>$row['country'], 'phone'=>$row['tel'], 'fax'=>$row['fax'], 'handy'=>$row['mobile'], 'city'=>$row['town'], 'cityn'=>$row['postcode'], 'street'=>$row['street'], 'streetn'=>$row['streetnr'], 'updatetime'=>$row['updatetime'], 'usertype'=>'u', 'password'=>$row['password'] ); } } else if ($config['sourceType']=='teklab') { } } else if ($list=='substitutes' and $config['sourceType']=='teklab') { } else if ($list=='dedicated' and $config['sourceType']=='teklab') { } else if ($list=='gameserver' and $config['sourceType']=='teklab') { } else if ($list=='voice' and $config['sourceType']=='teklab') { } else if ($list=='node' and $config['sourceType']=='teklab') { } else if ($list=='virt' and $config['sourceType']=='teklab') { } // Echo the JSON reply with echo json_encode(array('total'=>$total,'entries'=>$json)); } // Catch database error and display catch(PDOException $error) { echo json_encode(array('error'=>$error->getMessage())); } }