function mailsms_hook_playsmsd() { global $core_config; // fetch every 60 seconds if (!core_playsmsd_timer(60)) { return; } // _log('fetch now:'.$now, 2, 'mailsms_hook_playsmsd'); // get global mailsms registry data $items_global = registry_search(0, 'features', 'mailsms'); $enable_fetch = $items_global['features']['mailsms']['enable_fetch']; $protocol = $items_global['features']['mailsms']['protocol']; $port = $items_global['features']['mailsms']['port']; $server = $items_global['features']['mailsms']['server']; $username = $items_global['features']['mailsms']['username']; $password = $items_global['features']['mailsms']['password']; if (!($enable_fetch && $protocol && $port && $server && $username && $password)) { return; } // _log('fetch uid:' . $uid, 3, 'mailsms_hook_playsmsd'); $param = 'mailsms_fetch'; $is_fetching = playsmsd_pid_get($param) ? TRUE : FALSE; if (!$is_fetching) { $RUN_THIS = "nohup " . $core_config['daemon']['PLAYSMS_BIN'] . "/playsmsd playsmsd once " . $param . " >/dev/null 2>&1 &"; // _log('execute:' . $RUN_THIS, 3, 'mailsms_hook_playsmsd'); shell_exec($RUN_THIS); } }
function email2sms_hook_playsmsd() { global $core_config; // fetch every 60 seconds if (!core_playsmsd_timer(60)) { return; } // _log('fetch now:'.$now, 2, 'email2sms_hook_playsmsd'); // get all users $users = dba_search(_DB_PREF_ . '_tblUser', 'uid'); foreach ($users as $user) { $uid = $user['uid']; // get email2sms registry data for $uid $items = registry_search($uid, 'features', 'email2sms'); $enable = $items['features']['email2sms']['enable']; $protocol = $items['features']['email2sms']['protocol']; $port = $items['features']['email2sms']['port']; $server = $items['features']['email2sms']['server']; $username = $items['features']['email2sms']['username']; $password = $items['features']['email2sms']['password']; if (!($enable && $protocol && $port && $server && $username && $password)) { continue; } // _log('fetch uid:' . $uid, 3, 'email2sms_hook_playsmsd'); $param = 'email2sms_uid_' . $uid; $is_fetching = playsmsd_pid_get($param) ? TRUE : FALSE; if (!$is_fetching) { $RUN_THIS = "nohup " . $core_config['daemon']['PLAYSMS_BIN'] . "/playsmsd playsmsd once " . $param . " >/dev/null 2>&1 &"; // _log('execute:' . $RUN_THIS, 3, 'email2sms_hook_playsmsd'); shell_exec($RUN_THIS); } } }
/** * Stop child scripts */ function playsmsd_stop_childs() { $pids['sendqueue'] = playsmsd_pid_get('sendqueue'); foreach ($pids as $key => $val) { if ($key && $val) { echo $key . " at pid " . $val . " will be killed..\n"; shell_exec("kill " . $val . " >/dev/null 2>&1"); } } }