function access($policy) { if (!is_array($policy)) { $policy = explode(',', $policy); } $canAccess = false; foreach ($policy as $p) { switch ($p) { case 'local': if ($_SERVER['REMOTE_ADDR'] == '127.0.0.1') { $canAccess = true; } break; case 'internal': $i = $_SERVER['REMOTE_ADDR']; $f = CutSegment('.', $i); if ($f == '10' && $_SERVER['HTTP_X_FORWARDED_FOR'] == '') { $canAccess = true; } break; case 'auth': if ($_SESSION['uid'] > 0) { $canAccess = true; } break; } } if (!$canAccess) { header('location: ' . actionUrl('signin', 'accounts')); die; } return $canAccess; }
function MakeRequest($mode, $entityInfo) { $result = cqrequest('http://hubbub.at/ab', array( 'mode' => $mode, 'entity' => $entityInfo, 'callback' => actionUrl('abconfirm', 'endpoint', array(), true))); return($result['data']); }
static function getMenuLinks() { $items = array(); $items[] = array('icon' => 'building-o', 'title' => l10n('devices.index'), 'url' => actionUrl('index', 'devices')); $items[] = array('icon' => 'hand-o-down', 'title' => l10n('events.manual'), 'url' => actionUrl('manual', 'events')); $items[] = array('icon' => 'heartbeat', 'title' => l10n('radiator.minion'), 'url' => actionUrl('index', 'radiator')); if (cfg('cameras')) { $items[] = array('icon' => 'video-camera', 'title' => l10n('cam.index'), 'url' => actionUrl('index', 'cam')); } return $items; }
function ajax_cli() { $cmd = explode(' ', trim($_REQUEST['q'])); $method = array_shift($cmd); if (substr($method, 0, 3) == 'hm.') { print_r(HMRPC(substr($method, 3), $cmd)); if ($method == 'hm.setInstallMode') { print 'You have 60 seconds to pair your device. After completing the pairing, click here to create an entry for it: <a href="' . actionUrl('pair', 'devices') . '">Pairing Complete</a>.'; } } else { profile_point('starting command'); eval(trim($_REQUEST['q'])); profile_point('command executed'); print chr(10); print_r($GLOBALS['profiler_log']); } }
foreach($this->model->getMyGroups() as $grp) $GLOBALS['group.options'][] = '<option value="'.$grp['lg_key'].'">'.$grp['lg_name'].'</option>'; include_once('templates/friendlist.php'); tmpl_friendlist($this->model->getFriends('req.rcv'), 'friends_rcv_rowcallback'); ?><script> function status_indicator(rowid, status) { if(status == null) status = '<img src="themes/default/ajax-loader.gif" align="absmiddle"/>'; $('#'+rowid+'_status').html(status); } function friend_ignore(rowid, dskey) { status_indicator(rowid); $.post('<?= actionUrl('ajax_ignore', 'friends') ?>', {'key' : dskey}, function(data) { $('#'+rowid).html(data); }); } function friend_accept(rowid, dskey) { status_indicator(rowid); $.post('<?= actionUrl('ajax_accept', 'friends') ?>', {'key' : dskey, 'group' : $('#group_select_'+rowid+' option:selected').val() }, function(data) { $('#'+rowid).html(data); }); } </script>
<?php echo $this->_getSubmenu2(); ?> <?php $adminModules = array(array('title' => 'Clients', 'icon' => '', 'url' => actionUrl('clients', 'devices')), array('title' => 'Device List', 'icon' => '', 'url' => actionUrl('show', 'devices')), array('title' => 'HM Command Line', 'icon' => '', 'url' => actionUrl('cli', 'devices')), array('title' => 'HM Pair Device', 'icon' => '', 'url' => actionUrl('pairhm', 'devices')), array('title' => 'Groups', 'icon' => '', 'url' => actionUrl('groups', 'devices')), array('title' => 'Modes', 'icon' => '', 'url' => actionUrl('modes', 'devices'))); ?> <ul> <?php foreach ($adminModules as $am) { ?> <ol><a href="<?php echo $am['url']; ?> "><?php echo htmlspecialchars($am['title']); ?> </a></ol> <?php } ?> </ul>
<? if($_REQUEST['controller'] != 'signin') l10n_load('mvc/signin/l10n'); ?> <div class="paragraph padded_extra" style="width: 550px"> <? /* fixme: Twitter Signin is broken if($GLOBALS['config']['twitter']['enabled'] === true) $signInLinks[] = '<a class="btn" href="'.actionUrl('twitter', 'signin').'">Twitter</a>'; */ if($GLOBALS['config']['facebook']['enabled'] === true) $signInLinks[] = '<a class="btn" href="'.actionUrl('fb', 'signin').'">Facebook</a>'; $signInLinks[] = '<a class="btn" href="'.actionUrl('google', 'signin').'">Google</a>'; $signInLinks[] = '<a class="btn" href="'.actionUrl('yahoo', 'signin').'">Yahoo</a>'; $signInLinks[] = '<a class="btn" onclick="$(\'#signinform\').html($(\'#signinform_openid\').html());">OpenID</a>'; $signInLinks[] = '<a class="btn" onclick="$(\'#signinform\').html($(\'#signinform_email\').html());">Email</a>'; print(implode(' ', $signInLinks)); ?><br/><br/> <div id="signinform"> <? include('mvc/signin/signin.ajax_'.getDefault($_SESSION['load_signin'], 'email').'form.php'); ?> </div> <div id="signinform_email" style="display:none"> <? include('mvc/signin/signin.ajax_emailform.php'); ?> </div> <div id="signinform_openid" style="display:none"> <? include('mvc/signin/signin.ajax_openidform.php'); ?> </div> <div style="margin-bottom: 8px; margin-top: 4px;"> <? if($_REQUEST['controller'] == 'signin') { ?>
, $(this).is(':checked'))"/> <label for="c_<?php echo $ds['d_key']; ?> "><?php echo htmlspecialchars($ds['d_name'] . ' (' . first($ds['d_alias'], $ds['d_key'])); ?> )</label> </div><?php } ?> <script> function changeGroup(deviceKey, val) { $.post('<?php echo actionUrl('group', 'devices'); ?> ', { id : '<?php echo htmlspecialchars($_REQUEST['id']); ?> ', device : deviceKey, 'inGroup' : (val ? 'Y' : 'N'), cmd : 'change' }, function(data) { }); } </script>
default: if (!isset($this->devices['HM:' . $h['ADDRESS']])) { // unknown device, make new dataset $dds = array('d_bus' => 'HM', 'd_type' => $h['TYPE'], 'd_room' => 'unknown', 'd_name' => 'New ' . $h['TYPE'] . ' ' . date('Y-m-d H:i:s'), 'd_id' => $h['ADDRESS']); $dds['d_key'] = o(db)->commit('devices', $dds); $this->devices['HM:' . $h['ADDRESS']] = $dds; } $this->devices['HM:' . $h['ADDRESS']]['info'] = $h; break; } } foreach ($this->devices as $d) { $di = array(); foreach ($d as $k => $v) { $di[] = $k . '=' . $v; } ?> <div><?php echo implode(', ', $di); ?> </div><?php } ?> <script> document.location.href = '<?php echo actionUrl('show', 'devices'); ?> '; </script>
function ABNewEntry($entityDS, $commentText) { $entityDS['comment'] = $commentText; $entityDS['email'] = md5($this->user->ds['u_email']); $entityInfo = json_encode($entityDS); // this is important: we need to prepare the endpoint API to give out // the confirmation before we send the request to the AB, because the AB // may hold the request until it's completed ITS confirmation request // back to us! h2_nv_store('abreq/'.$entityDS['_key'], array( 'abrequest' => 'pending', 'checksum' => md5($entityInfo))); // now, make the request to add our info to the AB $result = cqrequest('http://hubbub.at/ab', array( 'mode' => 'new', 'entity' => $entityInfo, 'callback' => actionUrl('abconfirm', 'endpoint', array(), true))); return($result['data']); }
"> <div id="menu"> <?php echo implode('', $mainMenu); ?> </div> <div id="header_outer"> <div style="float:right;padding:5px;"><a href="<?php echo actionUrl('client_settings', 'devices', array('id' => 'client/' . $_SERVER['REMOTE_ADDR'])); ?> "><i class="fa fa-cog"></i></a></div> <div id="header"> <a href="<?php echo actionUrl('index', 'home'); ?> "><i class="fa fa-home"></i> <span id="lefthdr"> Home Control <?php echo $GLOBALS['pagetitle']; ?> </span><span id="lefthdr2"></span> </a> </div> </div> <div id="content_outer"> <div id="msgheader"></div> <div id="content"> <table width="100%">
->receive(function($ndata) { setConfigData($ndata+getConfigData()); print(h2_uibanner(l10n('settings.saved'), true)); }) ->display(); ?></td> </tr> </table> <br/><hr/> Advanced options: <a href="<?php echo actionUrl('index', 'test'); ?> ">run unit tests</a> <script> setInterval(function() { $.post('<?php echo actionUrl('ajax_servercheck', 'settings'); ?> ', function(data) { $('#server_status').html(data.server_status); $('#ping_status').html(data.ping_status); $('#memcache_status').html(data.memcache_status); $('#s3_status').html(data.s3_status); }, 'json'); }, 2000); </script>
echo $ent->key(); ?> "> <?php echo implode('', $GLOBALS['group.options']); ?> </select> </div> </td> </tr><? } ?></table><? } ?> <script> function do_friend_request(id) { $('#frq_'+id).append(' <img src="themes/default/ajax-loader.gif" align="absmiddle">'); $.post('<?php echo actionUrl('ajax_friend_request', 'friends'); ?> ', { 'id': id, 'group' : $('#group_select_'+id+' option:selected').val() }, function(data) { $('#frq_'+id).html(data); }); } $("button, input:submit, input:button, a.btn").button(); </script>
<? ?> <br/> <h2><?php echo l10n('twitter.signing.in'); ?> ...</h2> <a href="<?php echo actionUrl('index', 'settings'); ?> " class="btn"><?php echo l10n('cancel'); ?> </a> <!--<a href="<?php echo $this->model->oAuthSignin(); ?> ">Continue</a>--> <script> document.location.href = '<?php echo $this->model->oAuthSignin(); ?> '; </script>
<div style="width: 800px;"> <div class="balloonhelp"><?php echo l10n('ab.balloon'); ?> </div> <br/> <h2 style="padding-bottom: 8px;"><?php echo l10n('ab'); ?> </h2> <div id="mystatus"> <img src="themes/default/ajax-loader.gif" align="absmiddle"/> <?php echo l10n('ab.lookingyouup'); ?> </div> </div> <script> setTimeout(function(){ $('#mystatus').load('<?php echo actionUrl('ajax_abstatus', $this->name, array('r' => time())); ?> '); }, 500); </script>
$.post('<?php echo actionUrl('ajax_loadeditor', 'ui'); ?> ', {'id' : editorId}, function(data) { $('#publisher_attackments').html(data); }); } } function do_publish() { if($('#publish_text').val() == '') return; $('#publisher').fadeTo('normal', 0.5); $('#status_indicator').html('<img src="themes/default/ajax-loader.gif"/>'); $.post('<?php echo actionUrl('ajax_post', 'msg'); ?> ', {'text' : $('#publish_text').val()<? if($this->viewEntity) print(", 'to' : ".$this->viewEntity) ?> }, function(data) { if(data.result != 'OK') { if(!data.reason) data.reason = ''; alert('There was a problem publishing your post. '+data.reason); } else { $('#publish_text').val(''); $('#postlist').prepend(data.post).masonry(); $('#status_indicator').html(' '); } }, 'json')
<br/> <? $form = new CQForm('pwrecovery', array('auto-focus' => true)); $form ->add('password', 'new_pwd', array('onvalidate' => function($value, $e, $form) { $form->pwd = trim($value); if(strlen($form->pwd) < 5) return(l10n('email.password.tooshort')); else return(true); })) ->add('param', 'i', $_REQUEST['i']) ->add('submit', 'reset_pwd') ->ds($_REQUEST) ->receive(function($data, $form) { $uds = DB_GetDataset('idaccounts', $_REQUEST['i'], 'ia_recovery'); $uds['ia_password'] = md5($uds['ia_url'].$form->pwd); $uds['ia_recovery'] = ''; DB_UpdateDataset('idaccounts', $uds); object('user')->loginWithId($uds['ia_user']); print(l10n('email.password.reset').'<br/><br/><a href="'.actionUrl('index', 'home').'" class="btn">> OK</a>'); $form->hidden = true; }) ->display(); ?> </td> </tr> </table> </div>
</td> <td valign="top" width="33%"> <div class="action_tile banner" style="min-height: 150px"> <h4><?php echo l10n('fui.wel.addfriends'); ?> </h4> <div class="tile_text"> <img src="img/ksmiletris.png" align="left" style="padding-right: 8px"/> <?php echo l10n('fui.wel.addfriends.text'); ?> <br/> <div align="center"> <a href="<?php echo actionUrl('add', 'friends'); ?> " class="btn"><?php echo l10n('fui.wel.addfriends'); ?> </a> </div> </div> </div> </td> <td valign="top" width="33%"> <div class="action_tile banner" style="min-height: 150px"> <h4><?php echo l10n('fui.wel.poststuff'); ?> </h4>
<span class="faint">Direction</span> </td> <td width="*"> <?php $dirText = array(0 => 'None', 1 => 'Sender', 2 => 'Receiver'); print $dirText[$dev['DIRECTION']]; ?> </div> </td> </tr> <?php $related = array(); $idnr = $ds['d_id']; $idroot = CutSegment(':', $idnr); foreach (o(db)->get('SELECT d_key,d_id,d_alias,d_type FROM devices WHERE d_id LIKE "' . $idroot . '%" ORDER BY d_id') as $dds) { $related[] = '<a href="' . actionUrl('params', 'devices', array('key' => $dds['d_key'])) . '" style="' . ($dds['d_key'] == $ds['d_key'] ? 'font-weight:bold;' : '') . '">' . htmlspecialchars(first($dds['d_alias'], $dds['d_type'])) . ' ' . $dds['d_id'] . '</a>'; //array($ds['d_id'] => $ds['d_id'].' ('.first($ds['d_alias'], $ds['d_id']).')'); } print '<tr><td valign="top" style="text-align:right"><span class="faint">Compound</span></td><td>' . implode(', ', $related) . '</td></tr></table>'; function showParam($val, $p, $k) { global $actionEvents; switch ($p['TYPE']) { case 'BOOL': if ($p['WRITABLE'] && $p['ID'] != 'AES_ACTIVE') { return '<select name="' . $p['ID'] . '"><option' . ($val === true ? ' selected' : '') . '>Yes</option><option' . ($val != true ? ' selected' : '') . '>No</option></select>'; } else { return $val === true ? 'Yes' : 'No'; } break; case 'INTEGER':
$this->form ->add('string', 'u_name', array('default' => $defaultName, 'validate' => 'notempty')) ->add('dropdown', 'u_l10n', array('options' => array('en' => 'English', 'de' => 'Deutsch'))) ->add('submit', 'saveprofile'); if($this->form->submitted) { if($this->form->getData()) { if($this->user->getUsername() == '' && !HubbubEntity::isNameAvailable($this->form->ds['username'])) { $this->form->errors['username'] = l10n('username.notavailable'); } else { $this->model->setUsername($this->form->ds['username']); } if(sizeof($this->form->errors) == 0) { $this->user->ds['u_name'] = trim(strip_tags($this->form->ds['u_name'])); $this->user->ds['u_l10n'] = trim(strip_tags($this->form->ds['u_l10n'])); $this->user->save(); redirect(actionUrl('index', 'home')); } } } $this->form->display(); ?></div>
?> " onclick="friend_search();"/> </td> </tr> </table> <br/> <div id="search_results"> </div> </div> <script> function friend_search() { $('#search_results').html('<img src="themes/default/ajax-loader.gif" align="absmiddle" /> <?php echo l10n('searching'); ?> '); var fr_url = $('#friend_url').val(); $.post('<?php echo actionUrl('ajax_search', 'friends'); ?> ', { 'q': fr_url }, function(data) { $('#search_results').html(data); //apply_style(); }); } </script>
?> "><img src="data/cam/<?php echo $cam['id']; ?> _mid.jpg" width="80%"/></a><?php } } ?> </div> <div style="text-align: center;"> <?php if ($thisCam['videoUrl']) { ?> <a href="<?php echo actionUrl('video', 'cam', array('id' => $thisCam['id'])); ?> ">> Live Video</a><?php } ?> </div> <script> messageHandlers.camtick = function() { window.location.reload(true); }; setTimeout(function() { window.location.reload(true); }, 1000*20);
function ajax_do() { $msg = ''; $url = ''; switch ($_REQUEST['method']) { case 'openid': if (trim($_REQUEST['openid']) == '') { $msg = h2_uibanner(l10n('openid.please')); } else { $_SESSION['myopenidurl'] = trim($_REQUEST['openid']); $_SESSION['load_signin'] = 'openid'; $msg = l10n('openid.signing.in') . ' ' . $_SESSION['myopenidurl'] . '...'; $url = actionUrl('openid', 'signin', array('id' => $_SESSION['myopenidurl'])); } break; case 'email': $emailAddress = trim(strtolower($_REQUEST['email'])); $loginPassword = trim($_REQUEST['password']); $passwordHash = md5($emailAddress . $loginPassword); if ($emailAddress == '' || $loginPassword == '') { $msg = h2_uibanner(l10n('fillout.fields')); } else { require_once 'lib/is_email.php'; $_SESSION['load_signin'] = 'email'; if ($_REQUEST['mode'] == 'new') { $nds = $this->model->getAccount('email', $emailAddress); if ($nds['ia_user'] > 0) { $msg = h2_uibanner(l10n('email.inuse')); } else { if (strlen($loginPassword) < 5) { $msg = h2_uibanner(l10n('email.password.tooshort')); } else { if (is_email($emailAddress, true, E_WARNING) != ISEMAIL_VALID) { $msg = h2_uibanner(l10n('email.invalid')); } else { $msg = l10n('email.creating.account') . '...'; $nds['ia_password'] = $passwordHash; $this->model->newAccount($nds); $url = $this->getUrlAfterSignin(); } } } } else { $ids = $this->model->getAccount('email', $emailAddress); if ($ids['ia_user'] > 0 && $ids['ia_password'] == $passwordHash) { object('user')->loginWithId($ids['ia_user']); $msg = '<img src="themes/default/ajax-loader.gif"/> ' . l10n('email.signing.in') . '...'; $url = $this->getUrlAfterSignin(); } else { $msg = h2_uibanner(l10n('email.login.fail') . '<br/><a href="' . actionUrl('recover', 'signin') . '">' . l10n('email.recover') . '</a>'); } } } break; } print json_encode(array('html' => $msg, 'url' => $url)); }
echo $adtlFontClass; ?> "><?php echo getCellEditor($ds, 'd_alias'); ?> </td> <td class="<?php echo $adtlFontClass; ?> "><?php echo getCellEditor($ds, 'd_room'); ?> </td> <td><?php if ($ds['d_bus'] == 'HM') { print '<a class="small" href="' . actionUrl('params', 'devices', array('key' => $ds['d_key'])) . '">HM</a>'; } ?> </td> </tr><?php } ?> </table> <script> editLock = {}; function saveCheckbox(spanId) { var cb = $('#'+spanId); $.post('?/devices/ajax_savefield', { f : cb.data('field'), key : cb.data('key'), v : cb.prop('checked') ? 'Y' : 'N' }); }
<?php if ($_POST['modes']) { $modes = array(); foreach (explode(chr(10), $_POST['modes']) as $m) { if (trim($m) != '') { $modes[] = trim($m); } } $nv->set('pref/modes', $modes); } else { $modes = $nv->get('pref/modes'); } $modeLines = implode(chr(10), $modes); ?> <form action="<?php echo actionUrl('modes', 'devices'); ?> " method="post"> Modes:<br/> <textarea name="modes" style="width: 90%;height:200px;"><?php echo $modeLines; ?> </textarea><br/> <input type="submit" value="Save"/> </form>
<?php shell_exec('nohup /bin/sh data/cam/getdata.sh &'); ?> <h3>Manual Cam Refresh</h3> Please stand by... <script> setTimeout(function() { document.location.href='<?php echo actionUrl('index', 'cam'); ?> '; }, 1000); </script>
'"> <td><?php echo htmlspecialchars($evt['e_address']); ?> </td> <td><?php echo htmlspecialchars($evt['e_address_rev']); ?> </td> <td><?php echo htmlspecialchars(substr($evt['e_code'], 0, 60)); ?> </td> </tr><?php } ?> </table> <input type="button" value="New Event Handler" onclick="document.location.href='<?php echo actionUrl('edit', 'events'); ?> ';"/> <style> tr:hover { cursor: pointer; } </style>
</div><?php } ?> </div> <div id="camsPanel"><?php foreach (cfg('cameras/cams') as $cam) { $pic = 'data/cam/' . $cam['id'] . '_mid.jpg'; ?> <div> <div style="text-align:center;padding:4px;"><?php echo htmlspecialchars(first($cam['title'], $cam['id'])); ?> </div> <a href="<?php echo actionUrl('single', 'cam', array('id' => $cam['id'])); ?> "> <div class="imgContainer"> <?php if (file_exists($pic) && filesize($pic) > 0) { ?> <img src="<?php echo $pic; ?> " width="100%"/><?php } else { ?> <div style="padding:32px">( no data )</div><?php } ?>
} foreach (o(db)->get('SELECT * FROM nvstore WHERE nv_key LIKE "group/%" ORDER BY nv_key') as $g) { $gname = substr($g['nv_key'], 6); ?> <li><a href="<?php echo actionUrl('group', 'devices', array('id' => $gname)); ?> "> <?php echo htmlspecialchars($gname); ?> </a> | <a href="<?php echo actionUrl('groups', 'devices', array('remove' => $gname)); ?> ">delete</a> </li><?php } ?> </ul> <hr/> <form action="?" method="post"> <input type="hidden" name="controller" value="devices"/> <input type="hidden" name="action" value="groups"/> <input type="text" name="name" value="" placeholder="new group name"/> <input type="submit"/> </form>
<?php echo l10n('url.balloon'); ?> </div> <blockquote id="userurlchange"><?php echo $this->user->getUrl(); ?> [<a onclick="doChangeUrl();"><?php echo l10n('change'); ?> </a>]</blockquote> <script> function doChangeUrl() { displayLoader(); $('#userurlchange').load('<?php echo actionUrl('ajax_changeurl', 'settings'); ?> '); } function displayLoader() { $('#userurlchange').append('<div><img src="themes/default/ajax-loader.gif" align="absmiddle"/> loading...</div>'); } </script>