Example #1
0
 public function restore()
 {
     $filename = ForceStringFrom('file');
     $fp = openFileRead($this->backupDir . $filename);
     while (!eof($fp)) {
         $query .= readFileData($fp, 10000);
     }
     closeFile($fp);
     $queries = ParseQueries($query, ';');
     for ($i = 0; $i < count($queries); $i++) {
         $sql = trim($queries[$i]);
         if (!empty($sql)) {
             APP::$DB->query($sql);
         }
     }
     Success('database');
 }
function core_channel_eof($req, &$pkt)
{
    my_print("doing channel eof");
    $chan_tlv = packet_get_tlv($req, TLV_TYPE_CHANNEL_ID);
    $c = get_channel_by_id($chan_tlv['value']);
    if ($c) {
        if (eof($c[1])) {
            packet_add_tlv($pkt, create_tlv(TLV_TYPE_BOOL, 1));
        } else {
            packet_add_tlv($pkt, create_tlv(TLV_TYPE_BOOL, 0));
        }
        return ERROR_SUCCESS;
    } else {
        return ERROR_FAILURE;
    }
}
Example #3
0
 * 
 */
require '../../vendor/autoload.php';
use BOTK\Core\EndPointFactory, BOTK\Core\ErrorManager;
// Control errors
use BOTK\Core\Representations\Standard;
// for CSS
// search configs files in  in config and /etc/geocodit directories
if (!isset($_ENV['BOTK_CONFIGDIR'])) {
    if (file_exists(__DIR__ . '/../../config/geocodit.ini')) {
        $_ENV['BOTK_CONFIGDIR'] = realpath(__DIR__ . '/../../config');
    } elseif (is_dir('/etc/geocodit')) {
        $_ENV['BOTK_CONFIGDIR'] = '/etc/geocodit';
    }
}
// Enable the catching of PHP errors
$errorManager = ErrorManager::getInstance()->registerErrorHandler();
try {
    $endpoint = EndPointFactory::make('Geocodit\\GatewayEndpoint');
    $result = $endpoint->run();
} catch (Exception $e) {
    $result = ErrorManager::getInstance()->render($e);
}
//optimized ouput file resources
if (is_resource($result)) {
    while (!eof($result)) {
        echo fread($result, 1048576);
    }
} else {
    echo $result;
}