/** * Receipt of a friend request message * @param object $data * @param object $msg * @return */ function friend_request_receive(&$data, &$msg) { // allow only if the server is trusted if (!$msg->validateSignature()) { return true; } $con = new HubbubConnection($msg->ownerEntity->key(), $msg->authorEntity->key()); $usr = new HubbubUser($msg->ownerEntity->key()); WriteToFile('log/activity.log', $data['msgid'] . ' friend_request received' . chr(10)); h2_audit_log('msg/friend_request/rcv', array('me' => $msg->ownerEntity->key(), 'sender' => $msg->authorEntity->key()), $data['msgid']); switch ($con->status()) { case 'req.sent': // if we already sent a request to them, complete the process $con->status('friend'); $usr->notify('friend/added', $msg->authorEntity); $msg->response['comment'] = 'status updated to {friend}'; break; case 'undefined': $con->status('req.rcv'); $usr->notify('friend/request', $msg->authorEntity); $msg->response['comment'] = 'status updated to {received}'; break; default: $msg->response['comment'] = 'status not updated'; break; } $msg->ok(); return true; }
function __init() { access_policy('auth'); $this->invokeModel(); $GLOBAL['log.end'] = true; WriteToFile('log/activity.log', 'msg.' . $_REQUEST['action'] . '()' . "\n"); }
function setConfigData($cfg) { $tmplFile = '<? $GLOBALS[$cfgCategory] = json_decode(\''.json_format(json_encode($cfg)).'\', true); ?>'; $cfgFileName = 'conf/default.php'; @chmod('conf', 0777); if(file_exists($cfgFileName)) unlink($cfgFileName); WriteToFile($cfgFileName, $tmplFile); }
function setCustomErrorHandler() { set_error_handler(function ($n, $s, $f, $l, $c) { if ($n < 8) { // skip notices WriteToFile('log/error.log', $s . ' in ' . $f . ' line ' . $l . "\n"); } }); return $this; }
function index() { access_policy('post'); $this->msg = new HubbubMessage(); WriteToFile('log/activity.log', 'endpoint.receive '.$_REQUEST['hubbub_sig'].chr(10)); $result = $this->msg->receive($_REQUEST['hubbub_msg'], $_REQUEST['hubbub_sig']); $GLOBALS['stats']['msgtype'] = $this->msg->type; if($result === false) $response = array('result' => 'fail', 'reason' => 'invalid message type', 'op' => $this->msg->type); else $response = $this->msg->response; print(json_encode($response)); $GLOBALS['stats']['response'] = $response['result']; WriteToFile('log/activity.log', 'endpoint.response '.implode(', ', $response).chr(10)); }
function signin() { if ($_POST['fid'] == sha1($_SESSION['fid'])) { $uds = o(db)->getDSMatch('accounts', array('a_username' => trim($_POST['username']), 'a_password' => sha1($_POST['password']))); if ($uds['a_key'] > 0) { WriteToFile('log/account.log', date('Y-m-d H:i:s') . ' (i) ' . $_SERVER['HTTP_X_FORWARDED_FOR'] . ' : ' . $_SERVER['REMOTE_ADDR'] . ' sign in with ' . trim($_POST['username']) . '/***' . chr(10)); $_SESSION['uid'] = $uds['a_key']; $_SESSION['ds'] = $uds; header('location: ./?'); die; } else { WriteToFile('log/account.log', date('Y-m-d H:i:s') . ' (f) ' . $_SERVER['HTTP_X_FORWARDED_FOR'] . ' : ' . $_SERVER['REMOTE_ADDR'] . ' sign in failed with ' . trim($_POST['username']) . '/***' . chr(10)); ?> <div style="text-align: center">Error signing in, try again.</div><?php } } else { WriteToFile('log/account.log', date('Y-m-d H:i:s') . ' (a) ' . $_SERVER['HTTP_X_FORWARDED_FOR'] . ' : ' . gethostbyaddr($_SERVER['HTTP_X_FORWARDED_FOR']) . ' signin page ' . chr(10)); } }
function foreign_post_receive(&$data, &$msg) { if (!$msg->validateSignature()) { return true; } WriteToFile('log/activity.log', $data['msgid'] . ' foreign_post ' . $msg->ownerEntity->key() . ' to ' . $msg->authorEntity->key() . chr(10)); $con = new HubbubConnection($msg->ownerEntity->key(), $msg->authorEntity->key()); if ($con->status() != 'friend') { return $msg->fail('no connection'); } $usr = new HubbubUser($msg->ownerEntity->key()); if ($con->ds['c_auto_approve'] == 'Y') { // if we're gonna approve this anyway, there is no reason to store the message // let's just create a post out of this WriteToFile('log/activity.log', $data['msgid'] . ' foreign_post received, accepted' . chr(10)); $post = new HubbubMessage('post'); $npid = $post->data['msgid']; $post->data = $msg->data; $post->data['type'] = 'post'; $post->data['msgid'] = $npid; $post->author($msg->authorEntity->ds); $post->owner($msg->ownerEntity->ds); $post->data['changed'] = time(); $post->data['received'] = time(); $post->data['rel']['foreign'] = $data['msgid']; $post->save(); WriteToFile('log/activity.log', $post->data['msgid'] . ' created from foreign_post' . chr(10)); $msg->response['post'] = $post->data; $msg->doSave = false; $usr->notify('fpost/new', $msg->authorEntity, $msg); } else { // if not, let's store this message for later approval $usr->notify('fpost/approve', $msg->authorEntity, $msg); $msg->vTag = 'A'; $msg->save(); } $msg->ok(); }
function get($query, $parameters = null, $opt = array()) { $result = array(); $error = ''; $query = $this->parseQueryParams($query, $parameters); $lines = mysql_query($query, $GLOBALS['db_link']); if ($lines && !is_bool($lines)) { while ($line = mysql_fetch_array($lines, MYSQL_ASSOC)) { if (isset($keyByField)) { $result[$line[$keyByField]] = $line; } else { $result[] = $line; } } mysql_free_result($lines); } else { $error = mysql_error(); if ($error) { WriteToFile('log/error.log', 'MySQL error: ' . $error . ' Query: ' . $query . chr(10)); } } profile_point('DB_GetList(' . substr($query, 0, 40) . '...)'); return $result; }
function Post($p) { // posts and comments have the same basic structure: author, owner and text // if the author is also the owner, we do not need to send a foreign_post message if($p['author']['_key'] == $p['owner']['_key']) { $msg = $this->makePostMessage('post', $p); $msg->broadcast(); } else { $msg = $this->makePostMessage('foreign_post', $p); WriteToFile('log/activity.log', $type.' sending: '.$msg->data['msgid'].' '.dumpArray($msg->data).chr(10)); $res = $msg->sendToOwner(); // if the post was accepted right away: if(sizeof($res['post']) > 0) { $msg->delete(); $msg = new HubbubMessage(); $msg->receive_single($res['post']); } } return($msg->ds); }
function copyHtmlToWeb() { $webDir = ''; $toWebDir = ''; $toFilePath = ''; $filePath = ''; $fileName = ''; $fileList = ''; $splStr = ''; $content = ''; $s = ''; $s1 = ''; $c = ''; $webImages = ''; $webCss = ''; $webJs = ''; $splJs = ''; $webFolderName = ''; $jsFileList = ''; $setFileCode = ''; $nErrLevel = ''; $jsFilePath = ''; $url = ''; $setFileCode = @$_REQUEST['setcode']; //设置文件保存编码 handlePower('复制生成HTML页面'); //管理权限处理 writeSystemLog('', '复制生成HTML页面'); //系统日志 $webFolderName = $GLOBALS['cfg_webTemplate']; if (left($webFolderName, 1) == '/') { $webFolderName = mid($webFolderName, 2, -1); } if (right($webFolderName, 1) == '/') { $webFolderName = mid($webFolderName, 1, len($webFolderName) - 1); } if (inStr($webFolderName, '/') > 0) { $webFolderName = mid($webFolderName, inStr($webFolderName, '/') + 1, -1); } $webDir = '/htmladmin/' . $webFolderName . '/'; $toWebDir = '/htmlw' . 'eb/viewweb/'; CreateDirFolder($toWebDir); $toWebDir = $toWebDir . pinYin2($webFolderName) . '/'; deleteFolder($toWebDir); //删除 CreateFolder('/htmlweb/web'); //创建文件夹 防止web文件夹不存在20160504 deleteFolder($webDir); CreateDirFolder($webDir); $webImages = $webDir . 'Images/'; $webCss = $webDir . 'Css/'; $webJs = $webDir . 'Js/'; copyFolder($GLOBALS['cfg_webImages'], $webImages); copyFolder($GLOBALS['cfg_webCss'], $webCss); CreateFolder($webJs); //创建Js文件夹 //处理Js文件夹 $splJs = aspSplit(getDirJsList($webJs), vbCrlf()); foreach ($splJs as $key => $filePath) { if ($filePath != '') { $toFilePath = $webJs . getFileName($filePath); aspEcho('js', $filePath); moveFile($filePath, $toFilePath); } } //处理Css文件夹 $splStr = aspSplit(getDirCssList($webCss), vbCrlf()); foreach ($splStr as $key => $filePath) { if ($filePath != '') { $content = getFText($filePath); $content = replace($content, $GLOBALS['cfg_webImages'], '../images/'); $content = deleteCssNote($content); $content = PHPTrim($content); //设置为utf-8编码 20160527 if (lCase($setFileCode) == 'utf-8') { $content = replace($content, 'gb2312', 'utf-8'); } WriteToFile($filePath, $content, $setFileCode); aspEcho('css', $GLOBALS['cfg_webImages']); } } //复制栏目HTML $GLOBALS['isMakeHtml'] = true; $rssObj = $GLOBALS['conn']->query('select * from ' . $GLOBALS['db_PREFIX'] . 'webcolumn where isonhtml=true'); while ($rss = $GLOBALS['conn']->fetch_array($rssObj)) { $GLOBALS['glb_filePath'] = replace(getColumnUrl($rss['columnname'], 'name'), $GLOBALS['cfg_webSiteUrl'] . '/', ''); if (right($GLOBALS['glb_filePath'], 1) == '/' || right($GLOBALS['glb_filePath'], 1) == '') { $GLOBALS['glb_filePath'] = $GLOBALS['glb_filePath'] . 'index.html'; } if (right($GLOBALS['glb_filePath'], 5) == '.html') { if (right($GLOBALS['glb_filePath'], 11) == '/index.html') { $fileList = $fileList . $GLOBALS['glb_filePath'] . vbCrlf(); } else { $fileList = $GLOBALS['glb_filePath'] . vbCrlf() . $fileList; } $fileName = replace($GLOBALS['glb_filePath'], '/', '_'); $toFilePath = $webDir . $fileName; copyFile($GLOBALS['glb_filePath'], $toFilePath); aspEcho('导航', $GLOBALS['glb_filePath']); } } //复制文章HTML $rssObj = $GLOBALS['conn']->query('select * from ' . $GLOBALS['db_PREFIX'] . 'articledetail where isonhtml=true'); while ($rss = $GLOBALS['conn']->fetch_array($rssObj)) { $GLOBALS['glb_url'] = getHandleRsUrl($rss['filename'], $rss['customaurl'], '/detail/detail' . $rss['id']); $GLOBALS['glb_filePath'] = replace($GLOBALS['glb_url'], $GLOBALS['cfg_webSiteUrl'] . '/', ''); if (right($GLOBALS['glb_filePath'], 1) == '/' || right($GLOBALS['glb_filePath'], 1) == '') { $GLOBALS['glb_filePath'] = $GLOBALS['glb_filePath'] . 'index.html'; } if (right($GLOBALS['glb_filePath'], 5) == '.html') { if (right($GLOBALS['glb_filePath'], 11) == '/index.html') { $fileList = $fileList . $GLOBALS['glb_filePath'] . vbCrlf(); } else { $fileList = $GLOBALS['glb_filePath'] . vbCrlf() . $fileList; } $fileName = replace($GLOBALS['glb_filePath'], '/', '_'); $toFilePath = $webDir . $fileName; copyFile($GLOBALS['glb_filePath'], $toFilePath); aspEcho('文章' . $rss['title'], $GLOBALS['glb_filePath']); } } //复制单面HTML $rssObj = $GLOBALS['conn']->query('select * from ' . $GLOBALS['db_PREFIX'] . 'onepage where isonhtml=true'); while ($rss = $GLOBALS['conn']->fetch_array($rssObj)) { $GLOBALS['glb_url'] = getHandleRsUrl($rss['filename'], $rss['customaurl'], '/page/page' . $rss['id']); $GLOBALS['glb_filePath'] = replace($GLOBALS['glb_url'], $GLOBALS['cfg_webSiteUrl'] . '/', ''); if (right($GLOBALS['glb_filePath'], 1) == '/' || right($GLOBALS['glb_filePath'], 1) == '') { $GLOBALS['glb_filePath'] = $GLOBALS['glb_filePath'] . 'index.html'; } if (right($GLOBALS['glb_filePath'], 5) == '.html') { if (right($GLOBALS['glb_filePath'], 11) == '/index.html') { $fileList = $fileList . $GLOBALS['glb_filePath'] . vbCrlf(); } else { $fileList = $GLOBALS['glb_filePath'] . vbCrlf() . $fileList; } $fileName = replace($GLOBALS['glb_filePath'], '/', '_'); $toFilePath = $webDir . $fileName; copyFile($GLOBALS['glb_filePath'], $toFilePath); aspEcho('单页' . $rss['title'], $GLOBALS['glb_filePath']); } } //批量处理html文件列表 //call echo(cfg_webSiteUrl,cfg_webTemplate) //call rwend(fileList) $sourceUrl = ''; $replaceUrl = ''; $splStr = aspSplit($fileList, vbCrlf()); foreach ($splStr as $key => $filePath) { if ($filePath != '') { $filePath = $webDir . replace($filePath, '/', '_'); aspEcho('filePath', $filePath); $content = getFText($filePath); foreach ($splStr as $key => $s) { $s1 = $s; if (right($s1, 11) == '/index.html') { $s1 = left($s1, len($s1) - 11) . '/'; } $sourceUrl = $GLOBALS['cfg_webSiteUrl'] . $s1; $replaceUrl = $GLOBALS['cfg_webSiteUrl'] . replace($s, '/', '_'); //Call echo(sourceUrl, replaceUrl) '屏蔽 否则大量显示20160613 $content = replace($content, $sourceUrl, $replaceUrl); } $content = replace($content, $GLOBALS['cfg_webSiteUrl'], ''); //删除网址 $content = replace($content, $GLOBALS['cfg_webTemplate'] . '/', ''); //删除模板路径 记 //content=nullLinkAddDefaultName(content) foreach ($splJs as $key => $s) { if ($s != '') { $fileName = getFileName($s); $content = replace($content, 'Images/' . $fileName, 'js/' . $fileName); } } if (inStr($content, '/Jquery/Jquery.Min.js') > 0) { $content = replace($content, '/Jquery/Jquery.Min.js', 'js/Jquery.Min.js'); copyFile('/Jquery/Jquery.Min.js', $webJs . '/Jquery.Min.js'); } $content = replace($content, '<a href="" ', '<a href="index.html" '); //让首页加index.html createFileGBK($filePath, $content); } } //把复制网站夹下的images/文件夹下的js移到js/文件夹下 20160315 $htmlFileList = ''; $splHtmlFile = ''; $splJsFile = ''; $htmlFilePath = ''; $jsFileName = ''; $jsFileList = getDirJsNameList($webImages); $htmlFileList = getDirHtmlList($webDir); $splHtmlFile = aspSplit($htmlFileList, vbCrlf()); $splJsFile = aspSplit($jsFileList, vbCrlf()); foreach ($splHtmlFile as $key => $htmlFilePath) { $content = getFText($htmlFilePath); foreach ($splJsFile as $key => $jsFileName) { $content = regExp_Replace($content, 'Images/' . $jsFileName, 'js/' . $jsFileName); } $nErrLevel = 0; $content = handleHtmlFormatting($content, false, $nErrLevel, '|删除空行|'); //|删除空行| $content = handleCloseHtml($content, true, ''); //闭合标签 $nErrLevel = checkHtmlFormatting($content); if (checkHtmlFormatting($content) == false) { echoRed($htmlFilePath . '(格式化错误)', $nErrLevel); //注意 } //设置为utf-8编码 if (lCase($setFileCode) == 'utf-8') { $content = replace($content, '<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />', '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'); } $content = PHPTrim($content); WriteToFile($htmlFilePath, $content, $setFileCode); } //images下js移动到js下 foreach ($splJsFile as $key => $jsFileName) { $jsFilePath = $webImages . $jsFileName; $content = getFText($jsFilePath); $content = PHPTrim($content); WriteToFile($webJs . $jsFileName, $content, $setFileCode); DeleteFile($jsFilePath); } copyFolder($webDir, $toWebDir); //使htmlWeb文件夹用php压缩 if (@$_REQUEST['isMakeZip'] == '1') { makeHtmlWebToZip($webDir); } //使网站用xml打包20160612 if (@$_REQUEST['isMakeXml'] == '1') { makeHtmlWebToXmlZip('/htmladmin/', $webFolderName); } //浏览地址 $url = 'http://10.10.10.57/' . $toWebDir; aspEcho('浏览', '<a href=\'' . $url . '\' target=\'_blank\'>' . $url . '</a>'); }
WriteToFile($formatted, $fileName, []); } $success = 1; break; } else { try { if (isset($_POST['object']) && $_POST['object'] == 'landinfo') { $formatted = ProcessSuccessDataLandinfo($output->data, $fileName); } else { $formatted = ProcessSuccessDataLandcover($output->data, $landInfoCollectionForEachPlot); } if ($firstWrite) { WriteToFile($formatted, $fileName, $fileHeaders); $firstWrite = false; } else { WriteToFile($formatted, $fileName, []); } $output = CallAPI($output->search_metadata->next_cursor, $landpks_API_URL); } catch (Exception $e) { $errorMessage = $e->getMessage(); break; } } } } else { break; } } } catch (Exception $e) { $errorMessage = $e->getMessage(); }
/** * Validates the message's signature. To succeed, the message must be signed (=must have * a "msgid" and a "signature" field) and the signature must correspond to the key * stored for the sending server. If any of these criteria isn't met, the message is * rejected. * @return */ function validateSignature($signedBy = 'author') { $this->fromServer = new HubbubServer($this->data[$signedBy]['server']); $validSignature = md5(trim($this->fromServer->inboundKey()) . trim($this->payload)); if ($validSignature != $this->signature) { $this->expectedSignature = $validSignature; $this->fail('invalid signature'); WriteToFile('log/activity.log', $this->data['msgid'] . ' rcv INVALID signature ' . $this->signature . ' for payload ' . $this->fromServer->inboundKey() . ':' . md5($this->payload) . '=' . $validSignature . '!' . $this->signature . chr(10)); return false; } else { return true; } }
<?php WriteToFile('log/switch.log', 'timer came back: ' . $_POST['data'] . chr(10)); $timerConfig = json_decode($_POST['data'], true); $device = getDeviceDS($timerConfig['key']); if (sizeof($device) > 0) { $dcfg = json_decode($device['d_config'], true); $tmr = $dcfg[$timerConfig['trigger']]; if ($tmr) { $GLOBALS['command-mode'] = 'trigger'; deviceCommand($timerConfig['key'], $timerConfig['param'], $tmr['value'], first($tmr['stxt'], 'API')); } else { WriteToFile('log/error.log', 'timer trigger not found: ' . $timerConfig['trigger'] . chr(10)); } }
?> cp cam/<?php echo $cam['id']; ?> _full.jpg cam/<?php echo $cam['id']; ?> _mid.jpg <?php } ?> cp cam/<?php echo $cam['id']; ?> _full.jpg timelapse/<?php echo $cam['id']; ?> /$date_string.jpg <?php } ?> chmod 765 * nohup rsync -az timelapse h1:htdocs/rpgp.org/cam/ > /dev/null 2>&1 & <?php $script = ob_get_clean(); print $script; @unlink('data/cam/getdata.sh'); WriteToFile('data/cam/getdata.sh', $script);
function scanUrl($httpUrl, $toTitle, $codeset) { $splStr = ''; $i = ''; $s = ''; $content = ''; $PubAHrefList = ''; $PubATitleList = ''; $splUrl = ''; $spltitle = ''; $title = ''; $url = ''; $htmlDir = ''; $htmlFilePath = ''; $nOK = ''; $dataArray = ''; $webState = ''; $u = ''; $iniDir = ''; $iniFilePath = ''; $websize = ''; $nSetTime = ''; $startTime = ''; $openSpeed = ''; $isLocal = ''; $isThrough = ''; $htmlDir = '/../网站UrlScan/' . setFileName(getWebSite($httpUrl)); CreateDirFolder($htmlDir); $htmlFilePath = $htmlDir . '/' . setFileName($httpUrl) . '.html'; $iniDir = $htmlDir . '/conifg'; CreateFolder($iniDir); $iniFilePath = $iniDir . '/' . setFileName($httpUrl) . '.txt'; //httpurl="http://maiside.net/" $webState = 0; $nSetTime = 1; $openSpeed = 0; if (CheckFile($htmlFilePath) == false) { $startTime = now(); aspEcho('codeset', $codeset); $dataArray = handleXmlGet($httpUrl, $codeset); $content = $dataArray[0]; $content = toGB2312Char($content); //给PHP用,转成gb2312字符 $webState = $dataArray[1]; $openSpeed = dateDiff('s', $startTime, now()); //content=gethttpurl(httpurl,codeset) //call createfile(htmlFilePath,content) WriteToFile($htmlFilePath, $content, $codeset); createFile($iniFilePath, $webState . vbCrlf() . $openSpeed); $nSetTime = 3; $isLocal = 0; } else { //content=getftext(htmlFilePath) $content = reaFile($htmlFilePath, $codeset); $content = toGB2312Char($content); //给PHP用,转成gb2312字符 $splStr = aspSplit(getFText($iniFilePath), vbCrlf()); $webState = CInt($splStr[0]); $openSpeed = CInt($splStr[0]); $isLocal = 1; } $websize = getFSize($htmlFilePath); if ($websize == '') { $websize = 0; } aspEcho('isLocal', $isLocal); $rsObj = $GLOBALS['conn']->query('select * from ' . $GLOBALS['db_PREFIX'] . 'weburlscan where httpurl=\'' . $httpUrl . '\''); if (@mysql_num_rows($rsObj) == 0) { $rs = mysql_fetch_array($rsObj); connexecute('insert into ' . $GLOBALS['db_PREFIX'] . 'weburlscan(httpurl,title,charset) values(\'' . $httpUrl . '\',\'' . $toTitle . '\',\'' . $codeset . '\')'); } connexecute('update ' . $GLOBALS['db_PREFIX'] . 'weburlscan set webstate=' . $webState . ',websize=' . $websize . ',openspeed=' . $openSpeed . ',charset=\'' . $codeset . '\' where httpurl=\'' . $httpUrl . '\''); //strLen(content) 不用这个,不精准 $s = getContentAHref('', $content, $PubAHrefList, $PubATitleList); $s = handleScanUrlList($httpUrl, $s); //call echo("httpurl",httpurl) //call echo("s",s) //call echo("PubATitleList",PubATitleList) $nOK = 0; $splUrl = aspSplit($PubAHrefList, vbCrlf()); $spltitle = aspSplit($PubATitleList, vbCrlf()); for ($i = 1; $i <= uBound($splUrl); $i++) { $title = $spltitle[$i]; $url = $splUrl[$i]; //去掉#号后台的字符20160506 if (inStr($url, '#') > 0) { $url = mid($url, 1, inStr($url, '#') - 1); } if ($url == '') { if ($title != '') { aspEcho('网址为空', $title); } } else { $url = handleScanUrlList($httpUrl, $url); $url = handleWithWebSiteList($httpUrl, $url); if ($url != '') { $rsObj = $GLOBALS['conn']->query('select * from ' . $GLOBALS['db_PREFIX'] . 'weburlscan where httpurl=\'' . $url . '\''); if (@mysql_num_rows($rsObj) == 0) { $rs = mysql_fetch_array($rsObj); $u = lCase($url); if (inStr($u, 'tools/downfile.asp') > 0 || inStr($u, '/url.asp?') > 0 || inStr($u, '/aspweb.asp?') > 0 || inStr($u, '/phpweb.php?') > 0 || $u == 'http://www.maiside.net/qq/' || inStr($u, 'mailto:') > 0 || inStr($u, 'tel:') > 0 || inStr($u, '.html?replytocom') > 0) { //.html?replytocom 王通网站 $isThrough = 0; } else { $isThrough = 1; //不用true 因为写入数据会有问题 } connexecute('insert into ' . $GLOBALS['db_PREFIX'] . 'weburlscan(tohttpurl,totitle,httpurl,title,isthrough,charset) values(\'' . $httpUrl . '\',\'' . $toTitle . '\',\'' . $url . '\',\'' . left($title, 255) . '\',' . $isThrough . ',\'' . $codeset . '\')'); $nOK = $nOK + 1; aspEcho($i, $url); } else { aspEcho($title, $url); } } } } $scanUrl = $nSetTime; return @$scanUrl; }
function logError($msg) { die($msg); WriteToFile('log/error.log', gmdate('Y-m-d H:i:s') . chr(9) . $_SERVER['REMOTE_ADDR'] . chr(9) . $msg . "\n\r"); }
function post_delete(&$data, &$msg) { $epfx = $_REQUEST['controller'] == 'endpoint' ? 'remote: ' : 'local: '; // in order to delete this message, we need to be either the owner or the author of it WriteToFile('log/activity.log', $epfx . $data['msgid'] . ' deletion author=' . $msg->authorKey . ' owner=' . $msg->ownerKey . ' local=' . $msg->localUserEntity . chr(10)); if ($msg->localUserEntity == $msg->ownerKey || $msg->localUserEntity == $msg->authorKey) { // easiest case, because the message lives on this server unset($msg->data['text']); unset($msg->data['attachments']); $msg->isDeleted = true; $msg->data['deleted'] = 'yes'; $msg->markChanged(); WriteToFile('log/activity.log', $epfx . $data['msgid'] . ' local message (user==owner), deleted' . chr(10)); } if ($msg->localUserEntity == $msg->ownerKey) { // if we're the owner, there is nothing left to do here WriteToFile('log/activity.log', $epfx . $data['msgid'] . ' deleted by owner' . chr(10)); $msg->save(); $msg->ok(); return true; } else { if ($msg->localUserEntity == $msg->authorKey) { // if we're not the owner, but the author of it, we need to send this sucker to its owner // so they can actually publish the change $msg->sendToUrl($msg->data['owner']['server']); if ($msg->response['result'] == 'OK') { // remote delete confirmed, everything is OK WriteToFile('log/activity.log', $epfx . $data['msgid'] . ' deleted remotely' . chr(10)); $msg->ok(); $msg->save(); return true; } else { // remote delete didn't work out WriteToFile('log/activity.log', $epfx . $data['msgid'] . ' remote delete failed: ' . $msg->response['reason'] . chr(10)); $msg->fail('remote delete failed: ' . $msg->response['reason']); /* we'll save it regardless, because the other server might pick it up again later through the feed */ $msg->save(); return false; } } } $msg->fail('delete failed: insufficient rights'); return false; }
$msg .= '<div class="green">✔ Installing...</div>'; break; } case(1): { $cv = array(); include_once('lib/special-io.php'); $_SESSION['installer']['cfg']['service']['salt'] = randomHashId(); $myUserName = trim(shell_exec('whoami')); $myUserName = getDefault($myUserName, 'root'); $tmplFile = '<? $GLOBALS[$cfgCategory] = json_decode(\''.json_format(json_encode($_SESSION['installer']['cfg'])).'\', true); ?>'; $cfgFileName = 'conf/default.php'; if(!file_exists($cfgFileName)) { @chmod('conf', 0777); WriteToFile($cfgFileName, $tmplFile); $cfgWritable = trim(file_get_contents($cfgFileName)) == trim($tmplFile); if(!$_SESSION['installer']['cfg']['ping']['remote']) $cronInfo = l10n('cron.setup').' <pre>* * * * * '.$myUserName.' php -f '.$GLOBALS['APP.BASEDIR'].'/cron.php > /dev/null 2>&1</pre> <a href="ext/installer/cronhelp.php" target="_blank">> More information / help</a><br/>'; if($cfgWritable) $msg .= '<div class="green">✔ Config file written</div> <br/> '.$cronInfo.' <br/> <br/> <input type="button" value="Access your Hubbub instance" onclick="document.location.href=\'./\';"/>'; else $msg .= '<div class="red">✘ Error: could not write configuration file</div> <input type="button" value="Retry" onclick="document.location.href=\'?p=exec\';"/>'; }
function executeScript($code, $data) { $GLOBALS['command-mode'] = 'trigger'; $ds = $data['eventDS']; if (isset($ds)) { $GLOBALS['command-source'] = '#' . $ds['e_key'] . ' ' . first($data['emitter_name'], $data['event']); } foreach ($data as $k => $v) { ${$k} = $v; } $code = trim($code); ob_start(); if (strtoupper(substr($code, 0, 4)) == '#PHP') { foreach ($data as $k => $v) { ${$k} =& $data[$k]; } $command = function ($line) use($data) { $this->executeLine($line, $data); }; eval($code); $result = ob_get_clean(); if ($log) { WriteToFile('log/event.debug.log', $result . chr(10)); } } else { $lines = explode(chr(10), $code); foreach ($lines as $line) { $data['select'] = array(); $this->executeLine($line, $data); } $result = ob_get_clean(); } return $result; }
function logToFile($filename, $content, $clearfile = false) { global $profiler_report, $profiler_time_start, $profiler_last; if ($clearfile) { @unlink($filename); } if (is_array($content)) { $content = dumpArray($content); } $uri = $_SERVER['REQUEST_URI']; if (stristr($uri, 'password') != '') { $uri = '***'; } @WriteToFile($filename, $_SERVER['REMOTE_ADDR'] . ' ' . $_SERVER['HTTP_HOST'] . ' ' . $uri . ' ' . $_SESSION['uid'] . ' ' . session_id() . ' ' . date('Y-m-d H:i:s') . ' ' . profiler_microtime_diff(microtime(), $GLOBALS['profiler_start']) . ' ' . trim($content) . "\r\n"); }
else { $pingStatus = array(); $msg .= '<div class="red">✘ Could not establish a connection with ping server ('.$pingRequest['data']['reason'].')</div>'; } } else { $pingStatus = array(); $msg .= '<div class="gray">✔ Please remember to add an entry to your crontab later</div>'; } #h2_nv_store('ping/status', $pingStatus); @chmod('conf', 0775); @unlink('conf/probe'); @WriteToFile('conf/probe', 'test'); $cfgWritable = trim(implode('', file('conf/probe'))) == 'test'; @unlink('conf/probe'); $version = explode('.', phpversion()); if($version[0] > 4 && $version[1] > 2) $msg .= '<div class="green">✔ PHP version 5.3 or greater ('.phpversion().')</div>'; else $msg .= '<div class="gray">✘ please check PHP version (5.3 or greater required but '.phpversion().' installed)</div>'; if(!is_callable('json_encode')) $msg .= '<div class="red">✘ please install JSON support</div>'; if(!is_callable('curl_init')) $msg .= '<div class="red">✘ please install cURL</div>';
// init environment ob_start("ob_gzhandler"); ob_start(); chdir($GLOBALS['APP.BASEDIR']); require 'lib/genlib.php'; require 'lib/hubbub2.php'; require 'lib/database.php'; profile_point('classes ready'); require 'lib/config.php'; profile_point('config loaded'); h2_init_hubbub_environment(); // if there was output up to this point, it has to be an error message $GLOBALS['content.startuperrors'] = trim(ob_get_clean()); // enable gzip compression by default profile_point('environment ready'); WriteToFile('log/activity.log', 'call ' . $_REQUEST['controller'] . '-' . $_REQUEST['action'] . "\n"); // instantiate controller, invoke action, render view $_REQUEST['controller'] = getDefault($_REQUEST['controller'], cfg('service/defaultcontroller')); $baseCtr = h2_getController($_REQUEST['controller']); profile_point('controller invoked'); h2_invokeAction($baseCtr, $_REQUEST['action']); profile_point('action executed'); $GLOBALS['content']['main'] = h2_invokeView($baseCtr, $_REQUEST['action']); profile_point('view executed'); // output through page template $templateName = cfg('page/template', 'default'); switch ($templateName) { case 'blank': print $GLOBALS['content']['main']; break; default:
function ajax_halcommand() { $this->skipView = true; WriteToFile('log/hal.command.log', json_encode($_POST) . chr(10)); $device = new H2HALDevice($_POST['key']); $call = first($_POST['call'], 'state'); $device->{$call}($_POST['command'], first($_POST['by'], 'EXT')); }