function get_or_push_thumbnail($thumbnail_id, $site) { $master = new Master($this->client); $image = get_post($thumbnail_id); $mapping = get_post_meta($thumbnail_id, MAPPING_META_KEY, true); if ($mapping && isset($mapping[$site])) { $remote_id = $mapping[$site]; } else { $remote_id = $master->push($image, $site); } $this->update_attachment_metadata($site, $thumbnail_id, $remote_id); return $remote_id; }
public static function run($argc, $argv) { /** * Cron Weekly * * Actions in the following block are executed once per day only on Sunday (once per week). * */ call_hooks('cron_weekly', datetime_convert()); z_check_cert(); require_once 'include/hubloc.php'; prune_hub_reinstalls(); mark_orphan_hubsxchans(); // get rid of really old poco records q("delete from xlink where xlink_updated < %s - INTERVAL %s and xlink_static = 0 ", db_utcnow(), db_quoteinterval('14 DAY')); $dirmode = intval(get_config('system', 'directory_mode')); if ($dirmode === DIRECTORY_MODE_SECONDARY || $dirmode === DIRECTORY_MODE_PRIMARY) { logger('regdir: ' . print_r(z_fetch_url(get_directory_primary() . '/regdir?f=&url=' . urlencode(z_root()) . '&realm=' . urlencode(get_directory_realm())), true)); } // Check for dead sites Master::Summon(array('Checksites')); // update searchable doc indexes Master::Summon(array('Importdoc')); /** * End Cron Weekly */ }
public static function getInstance() { if (!isset(self::$instance) && is_null(self::$instance)) { $c = __CLASS__; self::$instance = new $c(); } return self::$instance; }
private function showPreIndexPage($schedule) { $master = new Master(); $info_message = $master->get_info(); $is_able_to_entry = $schedule->is_in_time('entry', $this->current_time); $is_able_to_post_genre = $schedule->is_in_time('genre', $this->current_time); $entry = new Entry(); $entry_data = $entry->get_data(); $genre = new Genre(); $genre_data = $genre->get_data(); $this->view->assign('info_message', $info_message); $this->view->assign('entry_data', $entry_data); $this->view->assign('genre_data', $genre_data); $this->view->assign('is_able_to_entry', $is_able_to_entry); $this->view->assign('is_able_to_post_genre', $is_able_to_post_genre); $this->view->assign('root_url', ROOT_URL); $this->view->display('preindex.tpl'); }
public static function run($argc, $argv) { if ($argc < 2) { return; } $force = false; $pushall = true; if ($argc > 2) { if ($argv[2] === 'force') { $force = true; } if ($argv[2] === 'nopush') { $pushall = false; } } logger('directory update', LOGGER_DEBUG); $dirmode = get_config('system', 'directory_mode'); if ($dirmode === false) { $dirmode = DIRECTORY_MODE_NORMAL; } $x = q("select * from channel where channel_id = %d limit 1", intval($argv[1])); if (!$x) { return; } $channel = $x[0]; if ($dirmode != DIRECTORY_MODE_NORMAL) { // this is an in-memory update and we don't need to send a network packet. local_dir_update($argv[1], $force); q("update channel set channel_dirdate = '%s' where channel_id = %d", dbesc(datetime_convert()), intval($channel['channel_id'])); // Now update all the connections if ($pushall) { Master::Summon(array('Notifier', 'refresh_all', $channel['channel_id'])); } return; } // otherwise send the changes upstream $directory = find_upstream_directory($dirmode); $url = $directory['url'] . '/post'; // ensure the upstream directory is updated $packet = zot_build_packet($channel, $force ? 'force_refresh' : 'refresh'); $z = zot_zot($url, $packet); // re-queue if unsuccessful if (!$z['success']) { /** @FIXME we aren't updating channel_dirdate if we have to queue * the directory packet. That means we'll try again on the next poll run. */ $hash = random_string(); queue_insert(array('hash' => $hash, 'account_id' => $channel['channel_account_id'], 'channel_id' => $channel['channel_id'], 'posturl' => $url, 'notify' => $packet)); } else { q("update channel set channel_dirdate = '%s' where channel_id = %d", dbesc(datetime_convert()), intval($channel['channel_id'])); } // Now update all the connections if ($pushall) { Master::Summon(array('Notifier', 'refresh_all', $channel['channel_id'])); } }
public function before() { parent::before(); if (\Input::post('submit_login')) { if (\Auth::instance('SimpleAuth')->login()) { \Response::redirect(\Uri::base(false) . 'admin/list'); } else { $this->data['msg'] = 'Incorrect login.'; } } return true; }
public static function run($argc, $argv) { logger('cron_daily: start'); /** * Cron Daily * */ require_once 'include/dir_fns.php'; check_upstream_directory(); // Fire off the Cron_weekly process if it's the correct day. $d3 = intval(datetime_convert('UTC', 'UTC', 'now', 'N')); if ($d3 == 7) { Master::Summon(array('Cron_weekly')); } // once daily run birthday_updates and then expire in background // FIXME: add birthday updates, both locally and for xprof for use // by directory servers update_birthdays(); // expire any read notifications over a month old q("delete from notify where seen = 1 and created < %s - INTERVAL %s", db_utcnow(), db_quoteinterval('30 DAY')); //update statistics in config require_once 'include/statistics_fns.php'; update_channels_total_stat(); update_channels_active_halfyear_stat(); update_channels_active_monthly_stat(); update_local_posts_stat(); // expire old delivery reports $keep_reports = intval(get_config('system', 'expire_delivery_reports')); if ($keep_reports === 0) { $keep_reports = 10; } q("delete from dreport where dreport_time < %s - INTERVAL %s", db_utcnow(), db_quoteinterval($keep_reports . ' DAY')); // expire any expired accounts downgrade_accounts(); // If this is a directory server, request a sync with an upstream // directory at least once a day, up to once every poll interval. // Pull remote changes and push local changes. // potential issue: how do we keep from creating an endless update loop? $dirmode = get_config('system', 'directory_mode'); if ($dirmode == DIRECTORY_MODE_SECONDARY || $dirmode == DIRECTORY_MODE_PRIMARY) { require_once 'include/dir_fns.php'; sync_directories($dirmode); } Master::Summon(array('Expire')); Master::Summon(array('Cli_suggest')); require_once 'include/hubloc.php'; remove_obsolete_hublocs(); call_hooks('cron_daily', datetime_convert()); set_config('system', 'last_expire_day', $d2); /** * End Cron Daily */ }
public static function insertAndGetId($class, $keycol, array $postData = array()) { $obj = new $class(); $suc = $obj->set_assoc_array($postData); if (Master::isLegit($suc)) { $where = $obj->get_assoc_array(); unset($where[$keycol]); $clms = array("CLM5" => $keycol); $params = array_merge($where, $clms); $data = null; MyHttpRequest::postTableData($data, "?master={$class}", $postData); //print_r($data); MyHttpRequest::getJSONTableData($data, "?master={$class}", $params); //print_r($data); return $data[0][$keycol]; } return false; }
public function getUrlByKaraokeId($karaoke_id) { $link = $this->getLinkByKaraokeId($karaoke_id); if (empty($link['cmd'])) { throw new Exception("Obtaining url failed"); } if (!empty($link['storage_id'])) { $storage = Master::getStorageById($link['storage_id']); if (!empty($storage)) { $cache = Cache::getInstance(); $cache->set($this->stb->id . '_playback', array('type' => 'karaoke', 'id' => $link['id'], 'storage' => $storage['storage_name']), 0, 10); } } else { $cache = Cache::getInstance(); $cache->del($this->stb->id . '_playback'); } return $link['cmd']; }
/** * 检查log目录是否可写 * @return bool */ public static function checkWriteable() { $ok = true; if (!is_dir(WORKERMAN_LOG_DIR)) { // 检查log目录是否可读 umask(0); if (@mkdir(WORKERMAN_LOG_DIR, 0777) === false) { $ok = false; } @chmod(WORKERMAN_LOG_DIR, 0777); } if (!is_readable(WORKERMAN_LOG_DIR) || !is_writeable(WORKERMAN_LOG_DIR)) { $ok = false; } if (!$ok) { $pad_length = 26; Master::notice(WORKERMAN_LOG_DIR . " Need to have read and write permissions\tWorkerman start fail"); exit("------------------------LOG------------------------\n" . str_pad(WORKERMAN_LOG_DIR, $pad_length) . "[31;40m [NOT READABLE/WRITEABLE] [0m\n\n[31;40mDirectory " . WORKERMAN_LOG_DIR . " Need to have read and write permissions[0m\n\n[31;40mWorkerman start fail[0m\n\n"); } }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = Master::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
// // Be sure that the crontab schedule corresponds to the Slave::RUN_INTERVAL // constant. // // */2 * * * * cd /path/to/this/file; php Master.php 1>> cron.out 2>&1; cd $HOME // class Master { public function crackwhip() { if (!file_exists("jobs")) { exit; } $jobs = scandir("jobs"); foreach ($jobs as $job) { if (strpos($job, ".") !== false) { continue; } chdir("jobs/{$job}"); // from http://us3.php.net/manual/en/function.exec.php#43834 if (strncasecmp(PHP_OS, "Win", 3) == 0) { pclose(popen("start \"blah\" /B \"php.exe\" ../../Slave.php {$job}", "r")); } else { exec("php ../../Slave.php {$job} 1> /dev/null 2>&1 &"); } chdir("../.."); } } } $master = new Master(); $master->crackwhip();
$pageType = "1%%%%%%%%%"; if (!checkPerms($this->user["userType"], $pageType)) { header("Location: Unauthorized.php" . $this->sess->url("")); exit; } $this->tpl = new rpts_Template(getcwd(), "keep"); $this->tpl->set_file("rptsTemplate", "MasterPropertyList.htm"); $this->tpl->set_var("TITLE", "Property"); } function Main() { $this->tpl->set_var("uname", $this->user["uname"]); $this->tpl->set_var("today", date("F j, Y")); $this->tpl->set_var("Session", $this->sess->url("")); $this->tpl->parse("templatePage", "rptsTemplate"); $this->tpl->finish("templatePage"); $this->tpl->p("templatePage"); } } ##################################### # Define Procedures and Functions ##################################### ########################################################## # Begin Program Script ########################################################## //* page_open(array("sess" => "rpts_Session", "auth" => "rpts_Challenge_Auth", "perm" => "rpts_Perm")); //*/ $obj = new Master($sess); $obj->Main(); page_close();
function SaveOrder($abv, $amt, $total, $surcharge) { $db = Master::getInstance(); $mysqli = $db->getConnection(); $res = $mysqli->query("select id, name, rates, surchage from fcurrency where abreviation = '{$abv}'"); $row = $res->fetch_assoc(); $fCurrencyID = $row['id']; $name = $row['name']; $surchageAmount = $surcharge; $r = $mysqli->query("insert into purchase_order (amount_purchased, amount_to_be_paid, amount_surcharged, date_created, fcurrency_id) values ('{$amt}', '{$total}', '{$surchageAmount}', NOW(), '{$fCurrencyID}')"); $n = $mysqli->affected_rows; if ($n == 1) { $orderID = $mysqli->insert_id; if ($abv == "GBP") { $message = "Foreign Currency purchased: " . $name . "\n Amount Purchased = " . $amt . "\n Amount to pay in ZAR = " . $total . "\n"; $db->sendMail($message); } if ($abv == "EUR") { $afterDiscount = $total - $total * 0.02; $results = $mysqli->query("update purchase_order set after_discount = {$afterDiscount} where id = '{$orderID}'"); } return TRUE; } return FALSE; }
<?php namespace Zotlabs\Daemon; if (array_search(__FILE__, get_included_files()) === 0) { require_once 'include/cli_startup.php'; array_shift($argv); $argc = count($argv); if ($argc) { Master::Release($argc, $argv); } killme(); } class Master { public static function Summon($arr) { proc_run('php', 'Zotlabs/Daemon/Master.php', $arr); } public static function Release($argc, $argv) { cli_startup(); logger('Master: release: ' . print_r($argv, true), LOGGER_ALL, LOG_DEBUG); require_once 'Zotlabs/Daemon/' . $argv[0] . '.php'; $cls = '\\Zotlabs\\Daemon\\' . $argv[0]; $cls::run($argc, $argv); } }
public static function run($argc, $argv) { $maxsysload = intval(get_config('system', 'maxloadavg')); if ($maxsysload < 1) { $maxsysload = 50; } if (function_exists('sys_getloadavg')) { $load = sys_getloadavg(); if (intval($load[0]) > $maxsysload) { logger('system: load ' . $load . ' too high. Cron deferred to next scheduled run.'); return; } } // Check for a lockfile. If it exists, but is over an hour old, it's stale. Ignore it. $lockfile = 'store/[data]/cron'; if (file_exists($lockfile) && filemtime($lockfile) > time() - 3600 && !get_config('system', 'override_cron_lockfile')) { logger("cron: Already running"); return; } // Create a lockfile. Needs two vars, but $x doesn't need to contain anything. file_put_contents($lockfile, $x); logger('cron: start'); // run queue delivery process in the background Master::Summon(array('Queue')); Master::Summon(array('Poller')); // maintenance for mod sharedwithme - check for updated items and remove them require_once 'include/sharedwithme.php'; apply_updates(); // expire any expired mail q("delete from mail where expires > '%s' and expires < %s ", dbesc(NULL_DATE), db_utcnow()); // expire any expired items $r = q("select id from item where expires > '2001-01-01 00:00:00' and expires < %s \n\t\t\tand item_deleted = 0 ", db_utcnow()); if ($r) { require_once 'include/items.php'; foreach ($r as $rr) { drop_item($rr['id'], false); } } // delete expired access tokens $r = q("select atoken_id from atoken where atoken_expires > '%s' and atoken_expires < %s", dbesc(NULL_DATE), db_utcnow()); if ($r) { require_once 'include/security.php'; foreach ($r as $rr) { atoken_delete($rr['atoken_id']); } } // Ensure that every channel pings a directory server once a month. This way we can discover // channels and sites that quietly vanished and prevent the directory from accumulating stale // or dead entries. $r = q("select channel_id from channel where channel_dirdate < %s - INTERVAL %s", db_utcnow(), db_quoteinterval('30 DAY')); if ($r) { foreach ($r as $rr) { Master::Summon(array('Directory', $rr['channel_id'], 'force')); if ($interval) { @time_sleep_until(microtime(true) + (double) $interval); } } } // publish any applicable items that were set to be published in the future // (time travel posts). Restrict to items that have come of age in the last // couple of days to limit the query to something reasonable. $r = q("select id from item where item_delayed = 1 and created <= %s and created > '%s' ", db_utcnow(), dbesc(datetime_convert('UTC', 'UTC', 'now - 2 days'))); if ($r) { foreach ($r as $rr) { $x = q("update item set item_delayed = 0 where id = %d", intval($rr['id'])); if ($x) { $z = q("select * from item where id = %d", intval($message_id)); if ($z) { xchan_query($z); $sync_item = fetch_post_tags($z); build_sync_packet($sync_item[0]['uid'], ['item' => [encode_item($sync_item[0], true)]]); } Master::Summon(array('Notifier', 'wall-new', $rr['id'])); } } } $abandon_days = intval(get_config('system', 'account_abandon_days')); if ($abandon_days < 1) { $abandon_days = 0; } // once daily run birthday_updates and then expire in background // FIXME: add birthday updates, both locally and for xprof for use // by directory servers $d1 = intval(get_config('system', 'last_expire_day')); $d2 = intval(datetime_convert('UTC', 'UTC', 'now', 'd')); // Allow somebody to staggger daily activities if they have more than one site on their server, // or if it happens at an inconvenient (busy) hour. $h1 = intval(get_config('system', 'cron_hour')); $h2 = intval(datetime_convert('UTC', 'UTC', 'now', 'G')); if ($d2 != $d1 && $h1 == $h2) { Master::Summon(array('Cron_daily')); } // update any photos which didn't get imported properly // This should be rare $r = q("select xchan_photo_l, xchan_hash from xchan where xchan_photo_l != '' and xchan_photo_m = '' \n\t\t\tand xchan_photo_date < %s - INTERVAL %s", db_utcnow(), db_quoteinterval('1 DAY')); if ($r) { require_once 'include/photo/photo_driver.php'; foreach ($r as $rr) { $photos = import_xchan_photo($rr['xchan_photo_l'], $rr['xchan_hash']); $x = q("update xchan set xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s'\n\t\t\t\t\twhere xchan_hash = '%s'", dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), dbesc($photos[3]), dbesc($rr['xchan_hash'])); } } // pull in some public posts if (!get_config('system', 'disable_discover_tab')) { Master::Summon(array('Externals')); } $generation = 0; $restart = false; if ($argc > 1 && $argv[1] == 'restart') { $restart = true; $generation = intval($argv[2]); if (!$generation) { killme(); } } reload_plugins(); $d = datetime_convert(); // TODO check to see if there are any cronhooks before wasting a process if (!$restart) { Master::Summon(array('Cronhooks')); } set_config('system', 'lastcron', datetime_convert()); //All done - clear the lockfile @unlink($lockfile); return; }
function test_existing_term_meta_is_pushed_when_new_term_is_created_on_remote_wp() { $master = new Master(); $taxonomy = 'post_tag'; $term = wp_insert_term('test_term', $taxonomy, array('description' => 'test description')); $term_id = $term['term_id']; $meta_id = update_term_meta($term_id, "test_meta_key", "dummy"); if (is_wp_error($term)) { var_dump($term); throw new Exception("Error in wp_insert_term"); } $result = wp_set_post_terms($this->ID, array($term_id), $taxonomy); $master->push($this->post, $this->site); $mapping = get_term_meta($term_id, MAPPING_META_KEY, true); $remote_id = $mapping[$this->site]; $this->assertEquals("dummy", get_term_meta($remote_id, "test_meta_key", true)); }
public function getUrlByVideoId($video_id, $series = 0, $forced_storage = "") { $video = Video::getById($video_id); if (empty($video)) { throw new Exception("Video not found"); } if (!empty($video['rtsp_url'])) { return $video['rtsp_url']; } $link = $this->getLinkByVideoId($video_id, $series, $forced_storage); if (empty($link['cmd'])) { throw new Exception("Obtaining url failed"); } if (!empty($link['storage_id'])) { $storage = Master::getStorageById($link['storage_id']); if (!empty($storage)) { $cache = Cache::getInstance(); $cache->set($this->stb->id . '_playback', array('type' => 'video', 'id' => $link['id'], 'storage' => $storage['storage_name']), 0, 10); } } else { $cache = Cache::getInstance(); $cache->del($this->stb->id . '_playback'); } return $link['cmd']; }
<?php require_once 'app/master.php'; $master = Master::getInstance(); include 'index.php';
{ $sql = "UPDATE " . $this->table . " SET id_menu = '" . $this->value . "' WHERE id_submenu = " . $this->id; $stmt = DB::execute($sql); } public function insert() { $sql = "INSERT INTO " . $this->table . " (id_asignatura,id_grado,intensidad) VALUES (" . $this->field . "," . $this->id . ",0)"; $stmt = DB::execute($sql); } public function delete($id) { $sql = "DELETE FROM " . $this->table . " WHERE id = " . $this->id . " LIMIT 1"; $stmt = DB::execute($sql); } } $st = new Master(); if ($_GET['op'] == 'upd') { $st->setTable($_GET['table']); $st->setField($_GET['field']); $st->setValue($_GET['value']); $st->setId($_GET['id']); $st->update(); if ($_GET['table'] == 'submenu' && $_GET['field'] == 'id_menu') { $st->setTable('permiso'); $st->updatePermiso(); } } if ($_GET['op'] == 'updChk') { $value = 0; $st->setTable($_GET['table']); $st->setField($_GET['field']);
public function __call($level, $value) { array_walk(self::$filters, function ($filters) use($value, $level) { $catch = false; if (is_string($filters['levels']) && ($filters['levels'] == Level::ALL || $filters['levels'] == $level)) { $catch = true; } elseif (is_array($filters['levels']) && in_array($level, $filters['levels'])) { $catch = true; } if ($catch) { $message = Master::prepare($value); $file = $line = null; if (in_array('f', $filters['layout']['map']) or in_array('l', $filters['layout']['map'])) { $trace = debug_backtrace(false); $fun = $trace[2]; if (isset($fun['file'])) { $file = str_replace("\\", "\\\\", $fun['file']); $line = $fun['line']; } } $uri = isset($_SERVER["REQUEST_URI"]) ? $_SERVER["REQUEST_URI"] : null; $message = str_replace(["%d", "%f", "%l", "%p", '%uri', "%m"], [date($filters['layout']['date_format']), $file, $line, $level, $uri, $message], $filters['layout']['layout_format']); $filters['filter']->writer($level, $message); } }); }
<?php /** * Test script to see if the ReturnObject extension works as it should * * @author Emiel Bruijntjes <*****@*****.**> * @copyright 2015 Copernica BV */ /** * Construct master object * @var Master */ $master = new Master(); /** * Construct derived child object * @var Child */ $child1 = new Child(); /** * Fetch the child object that is stored as member var in the master * @var Child */ $child2 = $master->child(); /** * Show output, expected is: * this is the master * this is the child * this is the child */ echo strval($master) . "\n"; echo strval($child1) . "\n";
public static function run($argc, $argv) { $maxsysload = intval(get_config('system', 'maxloadavg')); if ($maxsysload < 1) { $maxsysload = 50; } if (function_exists('sys_getloadavg')) { $load = sys_getloadavg(); if (intval($load[0]) > $maxsysload) { logger('system: load ' . $load . ' too high. Poller deferred to next scheduled run.'); return; } } $interval = intval(get_config('system', 'poll_interval')); if (!$interval) { $interval = get_config('system', 'delivery_interval') === false ? 3 : intval(get_config('system', 'delivery_interval')); } // Check for a lockfile. If it exists, but is over an hour old, it's stale. Ignore it. $lockfile = 'store/[data]/poller'; if (file_exists($lockfile) && filemtime($lockfile) > time() - 3600 && !get_config('system', 'override_poll_lockfile')) { logger("poller: Already running"); return; } // Create a lockfile. Needs two vars, but $x doesn't need to contain anything. file_put_contents($lockfile, $x); logger('poller: start'); $manual_id = 0; $generation = 0; $force = false; $restart = false; if ($argc > 1 && $argv[1] == 'force') { $force = true; } if ($argc > 1 && $argv[1] == 'restart') { $restart = true; $generation = intval($argv[2]); if (!$generation) { killme(); } } if ($argc > 1 && intval($argv[1])) { $manual_id = intval($argv[1]); $force = true; } $sql_extra = $manual_id ? " AND abook_id = " . intval($manual_id) . " " : ""; reload_plugins(); $d = datetime_convert(); // Only poll from those with suitable relationships $abandon_sql = $abandon_days ? sprintf(" AND account_lastlog > %s - INTERVAL %s ", db_utcnow(), db_quoteinterval(intval($abandon_days) . ' DAY')) : ''; $randfunc = db_getfunc('RAND'); $contacts = q("SELECT * FROM abook LEFT JOIN xchan on abook_xchan = xchan_hash \n\t\t\tLEFT JOIN account on abook_account = account_id\n\t\t\twhere abook_self = 0\n\t\t\t{$sql_extra} \n\t\t\tAND (( account_flags = %d ) OR ( account_flags = %d )) {$abandon_sql} ORDER BY {$randfunc}", intval(ACCOUNT_OK), intval(ACCOUNT_UNVERIFIED)); if ($contacts) { foreach ($contacts as $contact) { $update = false; $t = $contact['abook_updated']; $c = $contact['abook_connected']; if (intval($contact['abook_feed'])) { $min = service_class_fetch($contact['abook_channel'], 'minimum_feedcheck_minutes'); if (!$min) { $min = intval(get_config('system', 'minimum_feedcheck_minutes')); } if (!$min) { $min = 60; } $x = datetime_convert('UTC', 'UTC', "now - {$min} minutes"); if ($c < $x) { Master::Summon(array('Onepoll', $contact['abook_id'])); if ($interval) { @time_sleep_until(microtime(true) + (double) $interval); } } continue; } if ($contact['xchan_network'] !== 'zot') { continue; } if ($c == $t) { if (datetime_convert('UTC', 'UTC', 'now') > datetime_convert('UTC', 'UTC', $t . " + 1 day")) { $update = true; } } else { // if we've never connected with them, start the mark for death countdown from now if ($c == NULL_DATE) { $r = q("update abook set abook_connected = '%s' where abook_id = %d", dbesc(datetime_convert()), intval($contact['abook_id'])); $c = datetime_convert(); $update = true; } // He's dead, Jim if (strcmp(datetime_convert('UTC', 'UTC', 'now'), datetime_convert('UTC', 'UTC', $c . " + 30 day")) > 0) { $r = q("update abook set abook_archived = 1 where abook_id = %d", intval($contact['abook_id'])); $update = false; continue; } if (intval($contact['abook_archived'])) { $update = false; continue; } // might be dead, so maybe don't poll quite so often // recently deceased, so keep up the regular schedule for 3 days if (strcmp(datetime_convert('UTC', 'UTC', 'now'), datetime_convert('UTC', 'UTC', $c . " + 3 day")) > 0 && strcmp(datetime_convert('UTC', 'UTC', 'now'), datetime_convert('UTC', 'UTC', $t . " + 1 day")) > 0) { $update = true; } // After that back off and put them on a morphine drip if (strcmp(datetime_convert('UTC', 'UTC', 'now'), datetime_convert('UTC', 'UTC', $t . " + 2 day")) > 0) { $update = true; } } if (intval($contact['abook_pending']) || intval($contact['abook_archived']) || intval($contact['abook_ignored']) || intval($contact['abook_blocked'])) { continue; } if (!$update && !$force) { continue; } Master::Summon(array('Onepoll', $contact['abook_id'])); if ($interval) { @time_sleep_until(microtime(true) + (double) $interval); } } } if ($dirmode == DIRECTORY_MODE_SECONDARY || $dirmode == DIRECTORY_MODE_PRIMARY) { $r = q("SELECT u.ud_addr, u.ud_id, u.ud_last FROM updates AS u INNER JOIN (SELECT ud_addr, max(ud_id) AS ud_id FROM updates WHERE ( ud_flags & %d ) = 0 AND ud_addr != '' AND ( ud_last = '%s' OR ud_last > %s - INTERVAL %s ) GROUP BY ud_addr) AS s ON s.ud_id = u.ud_id ", intval(UPDATE_FLAGS_UPDATED), dbesc(NULL_DATE), db_utcnow(), db_quoteinterval('7 DAY')); if ($r) { foreach ($r as $rr) { // If they didn't respond when we attempted before, back off to once a day // After 7 days we won't bother anymore if ($rr['ud_last'] != NULL_DATE) { if ($rr['ud_last'] > datetime_convert('UTC', 'UTC', 'now - 1 day')) { continue; } } Master::Summon(array('Onedirsync', $rr['ud_id'])); if ($interval) { @time_sleep_until(microtime(true) + (double) $interval); } } } } set_config('system', 'lastpoll', datetime_convert()); //All done - clear the lockfile @unlink($lockfile); return; }
public function __construct() { $this->media_type = 'karaoke'; $this->db_table = 'karaoke'; parent::__construct(); }
/** * Return link for current channel and current time * * NGINX config: * * location /tslink/ { * * rewrite ^/tslink/(.+)/archive/(\d+)/(.+) /stalker_portal/server/api/chk_tmp_timeshift_link.php?key=$1&file=$3 last; * * proxy_set_header Host 192.168.1.71; # <- portal ip * proxy_set_header X-Real-IP $remote_addr; * proxy_pass http://192.168.1.71:88/; # <- portal ip * } * * location /archive/ { * root /var/www/bb1; * internal; * } * * @return string */ public function getLinkForChannel() { $ch_id = intval($_REQUEST['ch_id']); $res = array('id' => 0, 'cmd' => '', 'storage_id' => '', 'load' => '0', 'error' => ''); try { $task = $this->getLessLoadedTaskByChId($ch_id); } catch (StorageSessionLimitException $e) { $res['error'] = 'limit'; $res['storage_name'] = $e->getStorageName(); return $res; } if (empty($task)) { $res['error'] = 'server_error'; return $res; } $storage = Master::getStorageByName($task['storage_name']); //$channel = Itv::getChannelById($ch_id); $tz = new DateTimeZone(Stb::$server_timezone); $date = new DateTime(date('r')); $date->setTimeZone($tz); $date_now = new DateTime('now', new DateTimeZone(Stb::$server_timezone)); $dst_diff = $date->format('Z') - $date_now->format('Z'); if (!$storage['flussonic_dvr'] && !$storage['wowza_dvr']) { if ($dst_diff > 0) { $date->add(new DateInterval('PT' . $dst_diff . 'S')); } elseif ($dst_diff < 0) { $dst_diff *= -1; $date->sub(new DateInterval('PT' . $dst_diff . 'S')); } } $position = intval($date->format("i")) * 60 + intval($date->format("s")); $channel = Itv::getChannelById($ch_id); $filename = $date->format("Ymd-H"); $filename .= '.mpg'; if ($channel['flussonic_dvr']) { if (preg_match("/:\\/\\/([^\\/]*)\\/([^\\/]*).*(mpegts|m3u8)\$/", $channel['mc_cmd'], $match)) { if ($match[3] == 'mpegts') { $res['cmd'] = 'http://' . $storage['storage_ip'] . '/' . $match[2] . '/archive/' . strtotime(date("Y-m-d H:00:00")) . '/3600/mpegts'; } else { $res['cmd'] = preg_replace('/:\\/\\/([^\\/]*)/', '://' . $storage['storage_ip'], $channel['mc_cmd']); $res['cmd'] = preg_replace('/\\.m3u8/', '-' . strtotime(date("Y-m-d H:00:00")) . '-3600' . '.m3u8', $res['cmd']); // todo: current hour? } $res['cmd'] .= '' . '?token=' . $this->createTemporaryToken($this->stb->id) . ' position:' . $position . ' media_len:' . (intval(date("H")) * 3600 + intval(date("i")) * 60 + intval(date("s"))); } else { $res['error'] = 'server_error'; } } elseif ($channel['wowza_dvr']) { if (preg_match("/:\\/\\/([^\\/]*)\\/.*\\.m3u8/", $channel['mc_cmd'], $match)) { $url = preg_replace('/:\\/\\/([^\\/]*)/', '://' . $storage['storage_ip'], $channel['mc_cmd']); $res['cmd'] = preg_replace('/\\.m3u8.*/', '.m3u8?DVR&wowzadvrplayliststart=' . gmdate("YmdH0000") . '&wowzadvrplaylistduration=3600000', $url) . '&token=' . $this->createTemporaryToken("1") . ' position:' . $position . ' media_len:' . (intval(date("H")) * 3600 + intval(date("i")) * 60 + intval(date("s"))); } else { $res['error'] = 'server_error'; } return $res; } else { if (Config::getSafe('enable_timeshift_tmp_link', false)) { $redirect_url = '/archive/' . $ch_id . '/' . $filename; $link_result = $this->createTemporaryTimeShiftToken($redirect_url); $res['cmd'] = 'ffmpeg http://' . $storage['storage_ip'] . '/tslink/' . $link_result . '/archive/' . $ch_id . '/' . $filename . ' position:' . $position . ' media_len:' . (intval(date("H")) * 3600 + intval(date("i")) * 60 + intval(date("s"))); } else { $res['cmd'] = 'ffmpeg http://' . $storage['storage_ip'] . '/archive/' . $ch_id . '/' . $filename . ' position:' . $position . ' media_len:' . (intval(date("H")) * 3600 + intval(date("i")) * 60 + intval(date("s"))); } } return $res; }
public function setLanguage($lang = 'pt') { self::$lang = $lang; }
<?php // Check not accessed directly. if (!isset($post_add)) { echo "Are you searching for something? You maybe in wrong place then!!"; return; } $obj = new Attendance_Master(); $suc = $obj->set_assoc_array($_POST); if (Master::isLegit($suc)) { $_POST['syllabus_id'] = MyHttpRequest::insertAndGetId("Syllabus", "syllabus_id", $_POST); $_POST['teaches_id'] = MyHttpRequest::insertAndGetId("Teaches", "teaches_id", $_POST); require_once "./common.php"; } else { echo json_encode($suc); }
public function run() { DB::table('master')->delete(); $stamp = date('Y-m-d H:i:s'); $staff_user = DB::table('users')->select('users_id')->where('users_username', 'staff')->first()->users_id; $support_user = DB::table('users')->select('users_id')->where('users_username', 'support')->first()->users_id; $printer_category = DB::table('categories')->select('categories_id')->where('categories_name', 'Printer')->first()->categories_id; $medium_priority = DB::table('priorities')->select('priorities_id')->where('priorities_name', 'Medium')->first()->priorities_id; $open_status = DB::table('statuses')->select('statuses_id')->where('statuses_name', 'Open')->first()->statuses_id; $master_array = array(array('master_description' => 'Looks like the printer is out of toner', 'master_belongs_to_users_fk' => $staff_user, 'master_assigned_to_users_fk' => $support_user, 'master_categories_fk' => $printer_category, 'master_priorities_fk' => $medium_priority, 'master_statuses_fk' => $open_status, 'created_at' => $stamp, 'updated_at' => $stamp)); foreach ($master_array as $added_row) { Master::create($added_row); } }
/** * 获取主进程统计信息 * @return array */ protected function getMasterStatus() { if (!Master::getShmId()) { return array(); } return @shm_get_var(Master::getShmId(), Master::STATUS_VAR_ID); }
<?php include "./common.php"; $response = array('result' => Master::checkAccessToken($_GET['token'])); echo json_encode($response);