本文整理汇总了PHP中fOpen函数的典型用法代码示例。如果您正苦于以下问题:PHP fOpen函数的具体用法?PHP fOpen怎么用?PHP fOpen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fOpen函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: start
public function start()
{
$this->delimiter = "\t";
//datei oeffnen mit fopen und Parameter w fuer Write mit Dateianlegen
$this->DumpFileA = fOpen($this->FileNameA, "a");
$this->DumpFileB = fOpen($this->FileNameB, "a");
}
示例2: start
public function start($language)
{
$this->language = $language;
$this->counter = 0;
$this->FileName = "TEIL 2 properties_{$language}.sql";
$this->DumpFile = fOpen($this->FileName, "w");
}
示例3: InitRecordCall
function InitRecordCall($filename, $index, $comment)
{
//FIXME
$user = gs_user_get($_SESSION['sudo_user']['name']);
$call = "Channel: SIP/" . $_SESSION['sudo_user']['info']['ext'] . "\n" . "MaxRetries: 0\n" . "WaitTime: 15\n" . "Context: vm-rec-multiple\n" . "Extension: webdialrecord\n" . "Callerid: {$comment} <Aufnahme>\n" . "Setvar: __user_id=" . $_SESSION['sudo_user']['info']['id'] . "\n" . "Setvar: __user_name=" . $_SESSION['sudo_user']['info']['ext'] . "\n" . "Setvar: CHANNEL(language)=" . gs_get_conf('GS_INTL_ASTERISK_LANG', 'de') . "\n" . "Setvar: __is_callfile_origin=1\n" . "Setvar: __callfile_from_user=" . $_SESSION['sudo_user']['info']['ext'] . "\n" . "Setvar: __record_file=" . $filename . "\n";
$filename = '/tmp/gs-' . $_SESSION['sudo_user']['info']['id'] . '-' . _pack_int(time()) . rand(100, 999) . '.call';
$cf = @fOpen($filename, 'wb');
if (!$cf) {
gs_log(GS_LOG_WARNING, 'Failed to write call file "' . $filename . '"');
echo 'Failed to write call file.';
die;
}
@fWrite($cf, $call, strLen($call));
@fClose($cf);
@chmod($filename, 0666);
$spoolfile = '/var/spool/asterisk/outgoing/' . baseName($filename);
if (!gs_get_conf('GS_INSTALLATION_TYPE_SINGLE')) {
$our_host_ids = @gs_get_listen_to_ids();
if (!is_array($our_host_ids)) {
$our_host_ids = array();
}
$user_is_on_this_host = in_array($_SESSION['sudo_user']['info']['host_id'], $our_host_ids);
} else {
$user_is_on_this_host = true;
}
if ($user_is_on_this_host) {
# the Asterisk of this user and the web server both run on this host
$err = 0;
$out = array();
@exec('sudo mv ' . qsa($filename) . ' ' . qsa($spoolfile) . ' 1>>/dev/null 2>>/dev/null', $out, $err);
if ($err != 0) {
@unlink($filename);
gs_log(GS_LOG_WARNING, 'Failed to move call file "' . $filename . '" to "' . '/var/spool/asterisk/outgoing/' . baseName($filename) . '"');
echo 'Failed to move call file.';
die;
}
} else {
$cmd = 'sudo scp -o StrictHostKeyChecking=no -o BatchMode=yes ' . qsa($filename) . ' ' . qsa('root@' . $user['host'] . ':' . $filename);
//echo $cmd, "\n";
@exec($cmd . ' 1>>/dev/null 2>>/dev/null', $out, $err);
@unlink($filename);
if ($err != 0) {
gs_log(GS_LOG_WARNING, 'Failed to scp call file "' . $filename . '" to ' . $user['host']);
echo 'Failed to scp call file.';
die;
}
//remote_exec( $user['host'], $cmd, 10, $out, $err ); // <-- does not use sudo!
$cmd = 'sudo ssh -o StrictHostKeyChecking=no -o BatchMode=yes -l root ' . qsa($user['host']) . ' ' . qsa('mv ' . qsa($filename) . ' ' . qsa($spoolfile));
//echo $cmd, "\n";
@exec($cmd . ' 1>>/dev/null 2>>/dev/null', $out, $err);
if ($err != 0) {
gs_log(GS_LOG_WARNING, 'Failed to mv call file "' . $filename . '" on ' . $user['host'] . ' to "' . $spoolfile . '"');
echo 'Failed to mv call file on remote host.';
die;
}
}
}
示例4: gs_write_error
function gs_write_error($data)
{
if (!defined('STDERR')) {
define('STDERR', @fOpen('php://stderr', 'wb'));
}
if (php_sapi_name() === 'cli' && STDERR) {
@fWrite(STDERR, $data, strLen($data));
@fFlush(STDERR);
} else {
echo $data;
}
}
示例5: parse
function parse($quizFileName)
{
$quizFile = fOpen($quizFileName, 'r');
if ($quizFile) {
$this->parseStart();
while (($quizLine = fGets($quizFile, 4096)) !== false) {
$this->parseLine($quizLine);
}
$this->parseEnd();
fClose($quizFile);
}
}
示例6: set
/**
* @see \dns\system\cache\source\ICacheSource::set()
*/
public function set($cacheName, $value, $maxLifetime)
{
$filename = $this->getFilename($cacheName);
$content = "<?php exit; /* cache: " . $cacheName . " (generated at " . gmdate('r') . ") DO NOT EDIT THIS FILE */ ?>\n";
$content .= serialize($value);
if (!file_exists($filename)) {
@touch($filename);
}
$handler = fOpen($filename, "a+");
fWrite($handler, $content);
fClose($handler);
}
示例7: gs_hylafax_authfile_create
function gs_hylafax_authfile_create($authfile)
{
# connect to db
#
$db = gs_db_master_connect();
if (!$db) {
return new GsError('Could not connect to database.');
}
# get user list
#
$rs = $db->execute('SELECT `id`, `user`, `pin`
FROM `users`
WHERE `nobody_index` IS NULL
ORDER BY `id`');
if (!$rs) {
return new GsError('Error.');
}
# create temporary hylafax host/user authentication file
#
if (file_exists($authfile) && !is_writable($authfile)) {
@exec('sudo rm -f ' . qsa($authfile) . ' 2>>/dev/null');
}
$fh = @fOpen($authfile, 'w');
if (!$fh) {
return new GsError('Failed to open HylaFax authfile.');
}
# create localhost access without authentication first, if enabled
#
if (gs_get_conf('GS_FAX_NOAUTH_LOCALHOST') === true) {
fWrite($fh, "127.0.0.1\n", strLen("127.0.0.1\n"));
}
# create admin entry first
#
if (gs_get_conf('GS_FAX_HYLAFAX_ADMIN') != '') {
$crypted = crypt(gs_get_conf('GS_FAX_HYLAFAX_PASS'), 'pF');
$user_entry = '^' . preg_quote(gs_get_conf('GS_FAX_HYLAFAX_ADMIN')) . '@:' . '0' . ':' . $crypted . ':' . $crypted . "\n";
fWrite($fh, $user_entry, strLen($user_entry));
}
# create user entries
#
while ($user = $rs->fetchRow()) {
$crypted = crypt($user['pin'], 'ml');
$user_entry = '^' . preg_quote($user['user']) . '@:' . $user['id'] . ':' . $crypted . "\n";
fWrite($fh, $user_entry, strLen($user_entry));
}
# close file
#
if (@fclose($fh)) {
return true;
} else {
return new GsError('Error.');
}
}
示例8: ask
/**
* My prompt func because realine is not default module
*/
public function ask($string, $length = 1024)
{
static $tty;
if (!isset($tty)) {
if (substr(PHP_OS, 0, 3) == "WIN") {
$tty = fOpen("\\con", "rb");
} else {
if (!($tty = fOpen("/dev/tty", "r"))) {
$tty = fOpen("php://stdin", "r");
}
}
}
echo $string;
$result = trim(fGets($tty, $length));
return $result;
}
示例9: makeImgMovie
function makeImgMovie($imgFile)
{
//Make sure this file is an actual jpg file
if (is_file($imgFile) && ereg("\\.jpg\$", $imgFile)) {
//Launch Flash
$movie = new swfMovie();
$movie->setBackground(255, 255, 255);
//Import a bitmap
$b = new SWFBitmap(fOpen($imgFile, "rb"));
//Get it's width and height
$w = $b->getWidth();
$h = $b->getHeight();
//Make stage as big as the width and height of our bitmap
$movie->setDimension($w, $h);
//Convert Bitmap to a shape for Flash.
//This process is automated upon import in Flash, but with
//Ming we have have to do it ourselves. I see it as more control:)
$s = new SWFShape();
$f = $s->addFill($b);
$s->setRightFill($f);
//draw corners for the bitmap shape
$s->drawLine($w, 0);
$s->drawLine(0, $h);
$s->drawLine(-$w, 0);
$s->drawLine(0, -$h);
//CreateEmptyMovieclip
$p = new SWFSprite();
//add our bitmap shape to this movieclip
$p->add($s);
$p->nextFrame();
//Add this movieclip to our main movie's timeline
//Much like dragging a symbol from the library in Flash.
$i = $movie->add($p);
//Give this instance a name.. let's call it mImg as in movie image
$i->setName("mImg");
//Output the movie.. Ctrl+Enter!
// header("Content-Type:application/x-shockwave-flash");
$movie->output();
}
//End if
}
示例10: array
echo 'Error.';
} else {
@($_SESSION['sudo_user']['pb-csv-file'] = $filename);
$action = 'preview';
}
}
}
}
}
if ($action === 'preview' || $action === 'import') {
if (!@array_key_exists('pb-csv-file', @$_SESSION['sudo_user']) || !is_file(@$_SESSION['sudo_user']['pb-csv-file'])) {
$action = '';
} else {
$rem_old_entries = (bool) @$_REQUEST['rem_old_entries'];
$file = @$_SESSION['sudo_user']['pb-csv-file'];
$fh = @fOpen($file, 'rb');
if (!$fh) {
echo 'Could not read file.';
} else {
if (@array_key_exists('sep', @$_REQUEST) && @array_key_exists('encl', @$_REQUEST) && @array_key_exists('enc', @$_REQUEST)) {
$sep = @$_REQUEST['sep'];
$encl = @$_REQUEST['encl'];
$enc = @$_REQUEST['enc'];
} else {
# try to guess separator
$line = @fGets($fh);
@rewind($fh);
$cnt = array();
$cnt['s'] = (int) preg_match_all('/;/', $line, $m);
$cnt['c'] = (int) preg_match_all('/,/', $line, $m);
$cnt['t'] = (int) preg_match_all('/\\t/', $line, $m);
示例11: generate
public static function generate($key, array $updateIds = [])
{
$success = false;
$reqDBC = [];
if (file_exists('setup/tools/filegen/' . $key . '.func.php')) {
require_once 'setup/tools/filegen/' . $key . '.func.php';
} else {
if (empty(self::$tplFiles[$key])) {
CLISetup::log(sprintf(ERR_MISSING_INCL, $key, 'setup/tools/filegen/' . $key . '.func.php', CLISetup::LOG_ERROR));
return false;
}
}
CLISetup::log('FileGen::generate() - gathering data for ' . $key);
if (!empty(self::$tplFiles[$key])) {
list($file, $destPath, $deps) = self::$tplFiles[$key];
if ($content = file_get_contents(FileGen::$tplPath . $file . '.in')) {
if ($dest = @fOpen($destPath . $file, "w")) {
// replace constants
$content = strtr($content, FileGen::$txtConstants);
// check for required auxiliary DBC files
foreach ($reqDBC as $req) {
if (!CLISetup::loadDBC($req)) {
continue 2;
}
}
// must generate content
// PH format: /*setup:<setupFunc>*/
$funcOK = true;
if (preg_match_all('/\\/\\*setup:([\\w\\-_]+)\\*\\//i', $content, $m)) {
foreach ($m[1] as $func) {
if (function_exists($func)) {
$content = str_replace('/*setup:' . $func . '*/', $func(), $content);
} else {
$funcOK = false;
CLISetup::log('No function for was registered for placeholder ' . $func . '().', CLISetup::LOG_ERROR);
if (!array_reduce(get_included_files(), function ($inArray, $itr) use($func) {
return $inArray || false !== strpos($itr, $func);
}, false)) {
CLISetup::log('Also, expected include setup/tools/filegen/' . $name . '.func.php was not found.');
}
}
}
}
if (fWrite($dest, $content)) {
CLISetup::log(sprintf(ERR_NONE, CLISetup::bold($destPath . $file)), CLISetup::LOG_OK);
if ($content && $funcOK) {
$success = true;
}
} else {
CLISetup::log(sprintf(ERR_WRITE_FILE, CLISetup::bold($destPath . $file)), CLISetup::LOG_ERROR);
}
fClose($dest);
} else {
CLISetup::log(sprintf(ERR_CREATE_FILE, CLISetup::bold($destPath . $file)), CLISetup::LOG_ERROR);
}
} else {
CLISetup::log(sprintf(ERR_READ_FILE, CLISetup::bold(FileGen::$tplPath . $file . '.in')), CLISetup::LOG_ERROR);
}
} else {
if (!empty(self::$datasets[$key])) {
if (function_exists($key)) {
// check for required auxiliary DBC files
foreach ($reqDBC as $req) {
if (!CLISetup::loadDBC($req)) {
return false;
}
}
$success = $key($updateIds);
} else {
CLISetup::log(' - subscript \'' . $key . '\' not defined in included file', CLISetup::LOG_ERROR);
}
}
}
set_time_limit(FileGen::$defaultExecTime);
// reset to default for the next script
return $success;
}
示例12: subStr
if (!$cidnum) {
$callerid = $firstname_abbr . $user['lastname'] . ' <' . $from_num_effective . '>';
} else {
$callerid = $firstname_abbr . $user['lastname'] . ' <' . ($cidnum ? $cidnum : $from_num_effective) . '>';
}
} else {
$callerid = 'Anonymous <anonymous>';
}
if (!$is_foreign) {
//FIXME? - is this code correct for numbers in the same area?
$to_num = subStr($to_num_obj->dial, 0, 1) === '0' ? '0' . $to_num_obj->dial : $to_num_obj->dial;
$from_num_dial = subStr($from_num_effective_obj->dial, 0, 1) === '0' ? '0' . $from_num_effective_obj->dial : $from_num_effective_obj->dial;
$call = "Channel: Local/urldial-" . $from_num_dial . "@to-internal-users-self\n" . "MaxRetries: 0\n" . "WaitTime: 15\n" . "Context: urldial\n" . "Extension: {$prvPrefix}{$to_num}\n" . "Callerid: Rufaufbau <call>\n" . "Setvar: __user_id=" . $user['id'] . "\n" . "Setvar: __user_name=" . $user['ext'] . "\n" . "Setvar: CHANNEL(language)=" . gs_get_conf('GS_INTL_ASTERISK_LANG', 'de') . "\n" . "Setvar: __is_callfile_origin=1\n" . "Setvar: __saved_callerid=" . $callerid . "\n" . "Setvar: __callfile_from_user=" . $user['ext'] . "\n";
//echo $call;
$filename = '/tmp/gs-' . $user['id'] . '-' . _pack_int(time()) . rand(100, 999) . '.call';
$cf = @fOpen($filename, 'wb');
if (!$cf) {
gs_log(GS_LOG_WARNING, 'Failed to write call file "' . $filename . '"');
die_error('Failed to write call file.');
}
@fWrite($cf, $call, strLen($call));
@fClose($cf);
@chmod($filename, 0666);
$spoolfile = '/var/spool/asterisk/outgoing/' . baseName($filename);
if (!gs_get_conf('GS_INSTALLATION_TYPE_SINGLE')) {
$our_host_ids = @gs_get_listen_to_ids();
if (!is_array($our_host_ids)) {
$our_host_ids = array();
}
$user_is_on_this_host = in_array($user['host_id'], $our_host_ids);
} else {
示例13: buildlanguage
/**
* build language files from database
*
* @param boolean $force
*/
public static function buildlanguage($force = false)
{
$availableLanguages = array("de", "en");
foreach ($availableLanguages as $languageID => $languageCode) {
$file = DNS_DIR . "/lang/" . $languageCode . ".lang.php";
if (!file_exists($file) || filemtime($file) + 86400 < time() || $force === true) {
if (file_exists($file)) {
@unlink($file);
}
@touch($file);
$items = self::getDB()->query("select * from dns_language where languageID = ?", array($languageID));
$content = "<?php\n/**\n* language: " . $languageCode . "\n* encoding: UTF-8\n* generated at " . gmdate("r") . "\n* \n* DO NOT EDIT THIS FILE\n*/\n";
$content .= "\$lang = array();\n";
while ($row = self::getDB()->fetch_array($items)) {
print_r($row);
$content .= "\$lang['" . $row['languageItem'] . "'] = '" . str_replace("\$", '$', $row['languageValue']) . "';\n";
}
$handler = fOpen($file, "a+");
fWrite($handler, $content);
fClose($handler);
}
}
}
示例14: start
public function start()
{
$this->DumpFile = fOpen($this->FileName, "a");
}
示例15: gs_callwaiting_activate
function gs_callwaiting_activate($user, $active)
{
if (!preg_match('/^[a-z0-9\\-_.]+$/', $user)) {
return new GsError('User must be alphanumeric.');
}
$active = !!$active;
# connect to db
#
$db = gs_db_master_connect();
if (!$db) {
return new GsError('Could not connect to database.');
}
# get user_id
#
$user_id = $db->executeGetOne('SELECT `id` FROM `users` WHERE `user`=\'' . $db->escape($user) . '\'');
if (!$user_id) {
return new GsError('Unknown user.');
}
# get user_ext
$user_ext = $db->executeGetOne('SELECT `s`.`name` `ext`
FROM
`users` `u` JOIN
`ast_sipfriends` `s` ON (`s`.`_user_id`=`u`.`id`)
WHERE `u`.`user`=\'' . $db->escape($user) . '\'');
if (!$user_ext) {
return new GsError('Unknown user.');
}
# (de)activate
#
$num = $db->executeGetOne('SELECT COUNT(*) FROM `callwaiting` WHERE `user_id`=' . $user_id);
if ($num < 1) {
$ok = $db->execute('INSERT INTO `callwaiting` (`user_id`, `active`) VALUES (' . $user_id . ', 0)');
} else {
$ok = true;
}
$ok = $ok && $db->execute('UPDATE `callwaiting` SET `active`=' . (int) $active . ' WHERE `user_id`=' . $user_id);
if (!$ok) {
return new GsError('Failed to set call waiting.');
}
$call = "Channel: local/toggle@toggle-cwait-hint\n" . "MaxRetries: 0\n" . "WaitTime: 15\n" . "Context: toggle-cwait-hint\n" . "Extension: toggle\n" . "Callerid: {$user} <Toggle>\n" . "Setvar: __user_id=" . $user_id . "\n" . "Setvar: __user_name=" . $user_ext . "\n" . "Setvar: CHANNEL(language)=" . gs_get_conf('GS_INTL_ASTERISK_LANG', 'de') . "\n" . "Setvar: __is_callfile_origin=1\n" . "Setvar: __callfile_from_user=" . $user_ext . "\n" . "Setvar: __record_file=" . $filename . "\n";
$filename = '/tmp/gs-' . $user_id . '-' . time() . '-' . rand(10000, 99999) . '.call';
$cf = @fOpen($filename, 'wb');
if (!$cf) {
gs_log(GS_LOG_WARNING, 'Failed to write call file "' . $filename . '"');
return new GsError('Failed to write call file.');
}
@fWrite($cf, $call, strLen($call));
@fClose($cf);
@chmod($filename, 0666);
$spoolfile = '/var/spool/asterisk/outgoing/' . baseName($filename);
if (!gs_get_conf('GS_INSTALLATION_TYPE_SINGLE')) {
$our_host_ids = @gs_get_listen_to_ids();
if (!is_array($our_host_ids)) {
$our_host_ids = array();
}
$user_is_on_this_host = in_array($_SESSION['sudo_user']['info']['host_id'], $our_host_ids);
} else {
$user_is_on_this_host = true;
}
if ($user_is_on_this_host) {
# the Asterisk of this user and the web server both run on this host
$err = 0;
$out = array();
@exec('sudo mv ' . qsa($filename) . ' ' . qsa($spoolfile) . ' 1>>/dev/null 2>>/dev/null', $out, $err);
if ($err != 0) {
@unlink($filename);
gs_log(GS_LOG_WARNING, 'Failed to move call file "' . $filename . '" to "' . $spoolfile . '"');
return new GsError('Failed to move call file.');
}
} else {
$cmd = 'sudo scp -o StrictHostKeyChecking=no -o BatchMode=yes ' . qsa($filename) . ' ' . qsa('root@' . $user['host'] . ':' . $filename);
//echo $cmd, "\n";
@exec($cmd . ' 1>>/dev/null 2>>/dev/null', $out, $err);
@unlink($filename);
if ($err != 0) {
gs_log(GS_LOG_WARNING, 'Failed to scp call file "' . $filename . '" to ' . $user['host']);
return new GsError('Failed to scp call file.');
}
//remote_exec( $user['host'], $cmd, 10, $out, $err ); // <-- does not use sudo!
$cmd = 'sudo ssh -o StrictHostKeyChecking=no -o BatchMode=yes -l root ' . qsa($user['host']) . ' ' . qsa('mv ' . qsa($filename) . ' ' . qsa($spoolfile));
//echo $cmd, "\n";
@exec($cmd . ' 1>>/dev/null 2>>/dev/null', $out, $err);
if ($err != 0) {
gs_log(GS_LOG_WARNING, 'Failed to mv call file "' . $filename . '" on ' . $user['host'] . ' to "' . $spoolfile . '"');
return new GsError('Failed to mv call file on remote host.');
}
}
# reload phone config
#
//$user_name = $db->executeGetOne( 'SELECT `name` FROM `ast_sipfriends` WHERE `_user_id`='. $user_id );
//@ exec( 'asterisk -rx \'sip notify snom-reboot '. $user_name .'\'' );
//@ gs_prov_phone_checkcfg_by_user( $user, false ); //FIXME
return true;
}