Exemplo n.º 1
0
                 header("Content-type: text/xml; charset=UTF-8");
                 echo array2xml($userArray, new SimpleXMLElement('<user/>'));
             } else {
                 if ($apiType == 'json') {
                     header("Content-type: application/json; charset=UTF-8");
                     echo json_encode($userArray);
                 }
             }
         } else {
             $success['false'][] = 'Can not find a user with this data!';
         }
     } else {
         $success['false'][] = 'No data for this method';
     }
 } else {
     if (array_value_exists('action', 'ls', $data) and !isset($data['identify_by'])) {
         $limit = (isset($data['start']) and is_numeric($data['start']) and isset($data['amount']) and is_numeric($data['amount'])) ? 'LIMIT ' . $data['start'] . ',' . $data['amount'] : '';
         $columns = array('`id`', '`active`', '`salutation`', '`cname`', '`name`', '`vname`', '`mail`', '`city`', '`cityn`', '`street`', '`streetn`', '`language`', '`phone`', '`externalID`');
         if (isset($data['notLike']) and wpreg_check($data['notLike'], 255)) {
             $query = $sql->prepare("SELECT " . implode(',', $columns) . " FROM `userdata` WHERE `resellerid`=? AND `accounttype`='u' AND (`externalID` IS NULL OR `externalID` NOT LIKE ?) " . $limit);
             $query->execute(array($resellerID, $data['notLike'] . '%'));
         } else {
             if (isset($data['like']) and wpreg_check($data['like'], 255)) {
                 $query = $sql->prepare("SELECT " . implode(',', $columns) . " FROM `userdata` WHERE `resellerid`=? AND `accounttype`='u' AND `externalID` LIKE ? " . $limit);
                 $query->execute(array($resellerID, $data['like'] . '%'));
             } else {
                 $query = $sql->prepare("SELECT " . implode(',', $columns) . " FROM `userdata` WHERE `resellerid`=? AND `accounttype`='u' " . $limit);
                 $query->execute(array($resellerID));
             }
         }
         if ($apiType == 'xml') {
 public function add_extra($path)
 {
     if (substr($path, 5) == 'data:') {
         return $path;
     }
     // FIXME normalize $path
     $path = $path;
     if (array_key_exists($path, $this->extra)) {
         return $this->extra($path);
     }
     $fname = $path;
     $pos = strrpos($fname, '/');
     if ($pos !== FALSE) {
         $fname = substr($fname, $pos + 1);
     }
     $i = '';
     do {
         $name = 'images/' . $i . $fname;
         if ($i == '') {
             $i = 1;
         } else {
             $i++;
         }
     } while (array_value_exists($name, $this->extra));
     $this->extra[$path] = $name;
 }
Exemplo n.º 3
0
             }
         }
         $responsexml->appendChild($element);
         $responsexml->formatOutput = true;
         echo $responsexml->saveXML();
     } else {
         if ($apiType == 'json') {
             header("Content-type: application/json; charset=UTF-8");
             echo json_encode($query->fetchAll(PDO::FETCH_ASSOC));
         } else {
             header('HTTP/1.1 403 Forbidden');
             die('403 Forbidden');
         }
     }
 } else {
     if (array_value_exists('action', 'ls', $data)) {
         $list = true;
         $query = $sql->prepare("SELECT m.`id`,m.`usedns`,m.`ssh2ip`,m.`description`,m.`defaultname`,m.`defaultwelcome`,m.`defaulthostbanner_url`,m.`defaulthostbanner_gfx_url`,m.`defaulthostbutton_tooltip`,m.`defaulthostbutton_url`,m.`defaulthostbutton_gfx_url`,m.`maxserver`,m.`maxslots`,COUNT(v.`id`)*(100/m.`maxserver`) AS `serverpercent`,SUM(v.`slots`)*(100/m.`maxslots`) AS `slotpercent`,COUNT(v.`id`) AS `installedserver`,SUM(v.`slots`) AS `installedslots`,SUM(v.`usedslots`) AS `uslots` FROM `voice_masterserver` m LEFT JOIN `rserverdata` r ON m.`rootid`=r.`id` LEFT JOIN `voice_server` v ON m.`id`=v.`masterserver` WHERE m.`active`='Y' AND m.`resellerid`=? GROUP BY m.`id`");
         $query->execute(array($resellerID));
         if ($apiType == 'xml') {
             $responsexml = new DOMDocument('1.0', 'utf-8');
             $element = $responsexml->createElement('voice');
             while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
                 $key = $responsexml->createElement('server');
                 $listServerXML = $responsexml->createElement('id', $row['id']);
                 $key->appendChild($listServerXML);
                 $listServerXML = $responsexml->createElement('usedns', $row['usedns']);
                 $key->appendChild($listServerXML);
                 $listServerXML = $responsexml->createElement('ssh2ip', $row['ssh2ip']);
                 $key->appendChild($listServerXML);
                 $listServerXML = $responsexml->createElement('description', $row['description']);
Exemplo n.º 4
0
             $element->appendChild($key);
         }
         $responsexml->appendChild($element);
         $responsexml->formatOutput = true;
         echo $responsexml->saveXML();
     } else {
         if ($apiType == 'json') {
             header("Content-type: application/json; charset=UTF-8");
             echo json_encode($query->fetchAll(PDO::FETCH_ASSOC));
         } else {
             header('HTTP/1.1 403 Forbidden');
             die('403 Forbidden');
         }
     }
 } else {
     if (!isset($success['false']) and array_value_exists('action', 'gs', $data)) {
         $identifyServerBy = $data['identify_server_by'];
         $localServerID = isid($data['server_local_id'], 10);
         $externalServerID = isExternalID($data['server_external_id']);
         if (isset($data['restart']) and ($data['restart'] == 're' or $data['restart'] == 'st')) {
             $from = array('server_local_id' => 'id', 'server_external_id' => 'externalID');
             $gsRestart = $data['restart'];
             if (dataExist('identify_server_by', $data)) {
                 $query = $sql->prepare("SELECT `id`,`userid`,`rootID`,`serverip`,`port` FROM `gsswitch` WHERE `" . $from[$data['identify_server_by']] . "`=? AND `resellerid`=? LIMIT 1");
                 $query->execute(array($data[$data['identify_server_by']], $resellerID));
                 while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
                     $hostID = $row['rootID'];
                     $userID = $row['userid'];
                     $localID = $row['id'];
                     $name = $row['serverip'] . ':' . $row['port'];
                 }