if (!$bbSerialPort) { echoFlush("Could not open Serial port {$portName} "); exit; } // send data $dataToSend = "4 "; echoFlush("Writing to serial port data: \"{$dataToSend}\""); $bytesSent = dio_write($bbSerialPort, $dataToSend); echoFlush("Sent: {$bytesSent} bytes"); /* //date_default_timezone_set ("Europe/London"); $runForSeconds = new DateInterval("PT10S"); //10 seconds $endTime = (new DateTime())->add($runForSeconds); echoFlush( "Waiting for {$runForSeconds->format('%S')} seconds to recieve data on serial port" ); while (new DateTime() < $endTime) { $data = dio_read($bbSerialPort, 256); //this is a blocking call if ($data) { echoFlush( "Data Recieved: ". $data ); } } */ echoFlush("Closing Port"); dio_close($bbSerialPort); } catch (Exception $e) { echoFlush($e->getMessage()); exit(1); }
public function customClear() { $custom_dir = FANWE_ROOT . 'public/data/caches/custom/'; $custom_clear = $_SESSION['cache_custom_clear']; if (empty($custom_clear)) { $this->redirect('Cache/custom'); } else { $_SESSION['cache_custom_clear'] = $custom_clear; } $root_dir = $custom_clear['root']; $current_dir = $custom_clear['current']; if (!file_exists($root_dir) || !is_dir($root_dir) || strpos($root_dir, $custom_dir) === false) { $root_dir = $custom_dir; } if (!file_exists($current_dir) || !is_dir($current_dir)) { $current_dir = $root_dir; } $paths = pathinfo($root_dir); $root_dir = $paths['dirname'] . '/' . $paths['basename'] . '/'; $paths = pathinfo($current_dir); $current_dir = $paths['dirname'] . '/' . $paths['basename'] . '/'; if (strpos($current_dir, $root_dir) === false) { $current_dir = $root_dir; } @set_time_limit(3600); if (function_exists('ini_set')) { ini_set('max_execution_time', 3600); ini_set("memory_limit", "256M"); } $this->display(); ob_start(); ob_end_flush(); ob_implicit_flush(1); echoFlush('<script type="text/javascript">showmessage(\'' . sprintf(L('CUSTOM_TIPS2'), $current_dir) . '\',1);</script>'); $files = array(); $dirhandle = opendir($current_dir); while (($file = readdir($dirhandle)) !== false) { if ($file != "." && $file != "..") { $file = $current_dir . $file; if (is_dir($file)) { @closedir($dirhandle); $current_dir = $file . '/'; $_SESSION['cache_custom_clear'] = array('root' => $root_dir, 'current' => $current_dir); echoFlush('<script type="text/javascript">showmessage(\'' . U('Cache/customClear') . '\',2);</script>'); exit; } else { $files[] = $file; if (count($files) > 5000) { break; } } } } @closedir($dirhandle); foreach ($files as $file) { @unlink($file); echoFlush('<script type="text/javascript">showmessage(\'' . sprintf(L('CUSTOM_TIPS3'), $file) . '\',1);</script>'); usleep(20); } if (count($files) > 5000) { $_SESSION['cache_custom_clear'] = array('root' => $root_dir, 'current' => $current_dir); echoFlush('<script type="text/javascript">showmessage(\'' . U('Cache/customClear') . '\',2);</script>'); exit; } if ($root_dir == $current_dir) { if ($custom_dir != $root_dir) { @rmdir($root_dir); } echoFlush('<script type="text/javascript">showmessage(\'' . L('CUSTOM_TIPS5') . '\',3);</script>'); exit; } else { $paths = pathinfo($current_dir); @rmdir($current_dir); $current_dir = $paths['dirname'] . '/'; $_SESSION['cache_custom_clear'] = array('root' => $root_dir, 'current' => $current_dir); echoFlush('<script type="text/javascript">showmessage(\'' . U('Cache/customClear') . '\',2);</script>'); exit; } }
public function remove() { $id = $_REQUEST['id']; if (empty($id)) { $this->error(L('SELECT_USER')); } $id_arr = explode(',', $id); if (empty($id_arr)) { $this->error(L('SELECT_USER')); } $this->display(); $condition = array('uid' => array('in', $id_arr)); $index = (int) $_REQUEST['index']; $count = 100; $min = $index * $count; $max = $min + $count; $type = $_REQUEST['type']; switch ($type) { case "album": $list = D('Album')->where($condition)->limit('0,' . $count)->findAll(); if (count($list) > 0) { echoFlush('<script type="text/javascript">showmessage(\'' . sprintf(L('DELETE_TIPS_2'), $min, $max) . '\',1);</script>'); Vendor("common"); @set_time_limit(0); if (function_exists('ini_set')) { ini_set('max_execution_time', 0); } foreach ($list as $item) { FS("Album")->deleteAlbum($item['id'], true); usleep(10); } usleep(100); $index++; echoFlush('<script type="text/javascript">showmessage(\'' . U('User/remove', array('id' => $id, 'type' => 'album', 'index' => $index)) . '\',2);</script>'); } echoFlush('<script type="text/javascript">showmessage(\'' . U('User/remove', array('id' => $id, 'type' => 'share', 'index' => 0)) . '\',2);</script>'); break; case "share": $list = D('Share')->where($condition)->limit('0,' . $count)->findAll(); if (count($list) > 0) { echoFlush('<script type="text/javascript">showmessage(\'' . sprintf(L('DELETE_TIPS_3'), $min, $max) . '\',1);</script>'); Vendor("common"); @set_time_limit(0); if (function_exists('ini_set')) { ini_set('max_execution_time', 0); } foreach ($list as $item) { FS("Share")->deleteShare($item['share_id'], true); usleep(10); } usleep(100); $index++; echoFlush('<script type="text/javascript">showmessage(\'' . U('User/remove', array('id' => $id, 'type' => 'share', 'index' => $index)) . '\',2);</script>'); } $this->saveLog(1, $id); echoFlush('<script type="text/javascript">showmessage(\'' . L('DELETE_TIPS_4') . '\',3);</script>'); break; default: echoFlush('<script type="text/javascript">showmessage(\'' . L('DELETE_TIPS_1') . '\',1);</script>'); D('User')->deleteUser($id_arr); usleep(500); echoFlush('<script type="text/javascript">showmessage(\'' . U('User/remove', array('id' => $id, 'type' => 'album', 'index' => 0)) . '\',2);</script>'); break; } }
private function clearSqlDir($dir, $name) { $dirhandle = opendir($dir); while (($file = readdir($dirhandle)) !== false) { if ($file != "." && $file != "..") { echoFlush('<script type="text/javascript">showmessage(\'' . sprintf(L('DELETE_TIPS3'), $name, $file) . '\',1);</script>'); usleep(10); @unlink($dir . $file); } } @closedir($dirhandle); }
public function doBatchDelte() { @set_time_limit(0); if (function_exists('ini_set')) { ini_set('max_execution_time', 0); } vendor("common"); $limit = 100; $extwhere = ""; if (trim($_REQUEST['keywords'])) { $extwhere .= " and (s.title like '%" . trim($_REQUEST['keywords']) . "%' or s.content like '%" . trim($_REQUEST['keywords']) . "%') "; $this->assign("keywords", trim($_REQUEST['keywords'])); } if (trim($_REQUEST['user_name'])) { $extwhere .= " and u.user_name = '" . trim($_REQUEST['user_name']) . "' "; $this->assign("user_name", trim($_REQUEST['user_name'])); } if (trim($_REQUEST['email'])) { $extwhere .= " and u.email = '" . trim($_REQUEST['email']) . "' "; $this->assign("email", trim($_REQUEST['email'])); } if (trim($_REQUEST['ip'])) { $extwhere .= " and (us.reg_ip = '" . trim($_REQUEST['ip']) . "' or us.last_ip = '" . trim($_REQUEST['ip']) . "') "; $this->assign("ip", trim($_REQUEST['ip'])); } if (trim($_REQUEST['start_time']) && trim($_REQUEST['end_time'])) { $extwhere .= " and s.create_time between '" . strZTime(trim($_REQUEST['start_time'])) . "' and '" . strZTime(trim($_REQUEST['end_time'])) . "' "; $this->assign("start_time", trim($_REQUEST['start_time'])); $this->assign("end_time", trim($_REQUEST['end_time'])); } elseif (trim($_REQUEST['start_time']) && !trim($_REQUEST['end_time'])) { $extwhere .= " and s.create_time >= '" . strZTime(trim($_REQUEST['start_time'])) . "' "; $this->assign("start_time", trim($_REQUEST['start_time'])); } elseif (!trim($_REQUEST['start_time']) && trim($_REQUEST['end_time'])) { $extwhere .= " and s.create_time <= '" . strZTime(trim($_REQUEST['end_time'])) . "' "; $this->assign("end_time", trim($_REQUEST['end_time'])); } if (trim($_REQUEST['type']) && trim($_REQUEST['type']) != "all") { $extwhere .= " and s.type = '" . trim($_REQUEST['type']) . "' "; } $this->assign("type", trim($_REQUEST['type'])); if (trim($_REQUEST['share_data']) && trim($_REQUEST['share_data']) != "all") { $extwhere .= " and s.share_data = '" . trim($_REQUEST['share_data']) . "' "; } $this->assign("share_data", trim($_REQUEST['share_data'])); if (trim($_REQUEST['status']) != "") { $extwhere .= " and s.status = '" . trim($_REQUEST['status']) . "' "; $this->assign("status", trim($_REQUEST['status'])); } if (trim($_REQUEST['share_cates']) != "") { $extwhere .= " and s.share_id in (select share_id from " . FDB::table('share_category') . " where cate_id in (" . trim($_REQUEST['share_cates']) . ") )"; $this->assign("share_cates", trim($_REQUEST['share_cates'])); } if (empty($extwhere)) { $this->error(L('NEED_ONE_PARAMETER')); exit; } $sql = 'SELECT s.share_id,s.index_img FROM ' . FDB::table('share') . ' s INNER JOIN ' . FDB::table('user') . ' u on u.uid=s.uid INNER JOIN ' . FDB::table('user_status') . ' us on us.uid=u.uid where 1=1 ' . $extwhere . ' ORDER BY s.share_id DESC LIMIT 0,' . $limit; $list = FDB::fetchAll($sql); if (count($list) == 0) { $this->redirect('Share/BatchDelete'); exit; } $this->display(); flush(); ob_flush(); usleep(2000); $ids = array(); foreach ($list as $k => $v) { @unlink(FANWE_ROOT . $v['index_img']); $ids[] = $v['share_id']; } D('Share')->removeHandler($ids); $this->saveLog(1, implode(",", $ids)); flush(); ob_flush(); usleep(100); echoFlush('<script type="text/javascript">submiform();</script>'); }