陈德本 8 年 前
コミット
7b4517954d
2 ファイル変更44 行追加34 行削除
  1. 24 12
      .idea/workspace.xml
  2. 20 22
      App/Script/Controller/Server.php

+ 24 - 12
.idea/workspace.xml

@@ -1,9 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
   <component name="ChangeListManager">
-    <list default="true" id="d417c7e2-9370-4a4d-828f-09be06adcd69" name="Default" comment="telegram">
-      <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
-    </list>
+    <list default="true" id="d417c7e2-9370-4a4d-828f-09be06adcd69" name="Default" comment="telegram" />
     <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -37,13 +35,13 @@
       <usages-collector id="statistics.file.extensions.edit">
         <counts>
           <entry key="json" value="44" />
-          <entry key="php" value="500" />
+          <entry key="php" value="570" />
         </counts>
       </usages-collector>
       <usages-collector id="statistics.file.types.edit">
         <counts>
           <entry key="JSON" value="44" />
-          <entry key="PHP" value="500" />
+          <entry key="PHP" value="570" />
         </counts>
       </usages-collector>
       <usages-collector id="statistics.php.new.class">
@@ -64,8 +62,8 @@
       <file pinned="false" current-in-tab="true">
         <entry file="file://$PROJECT_DIR$/App/Script/Controller/Server.php">
           <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="342">
-              <caret line="23" column="21" lean-forward="true" selection-start-line="23" selection-start-column="21" selection-end-line="23" selection-end-column="21" />
+            <state relative-caret-position="608">
+              <caret line="37" column="34" selection-start-line="37" selection-start-column="34" selection-end-line="37" selection-end-column="34" />
               <folding>
                 <element signature="e#136#170#0#PHP" expanded="true" />
               </folding>
@@ -549,7 +547,7 @@
       <workItem from="1526268446293" duration="12711000" />
       <workItem from="1528527970342" duration="845000" />
       <workItem from="1529074202261" duration="35000" />
-      <workItem from="1535705721105" duration="4774000" />
+      <workItem from="1535705721105" duration="5014000" />
     </task>
     <task id="LOCAL-00001" summary="telegram">
       <created>1519284784104</created>
@@ -635,7 +633,21 @@
       <option name="project" value="LOCAL" />
       <updated>1535722926158</updated>
     </task>
-    <option name="localTasksCounter" value="13" />
+    <task id="LOCAL-00013" summary="telegram">
+      <created>1535723449198</created>
+      <option name="number" value="00013" />
+      <option name="presentableId" value="LOCAL-00013" />
+      <option name="project" value="LOCAL" />
+      <updated>1535723449198</updated>
+    </task>
+    <task id="LOCAL-00014" summary="telegram">
+      <created>1535723588527</created>
+      <option name="number" value="00014" />
+      <option name="presentableId" value="LOCAL-00014" />
+      <option name="project" value="LOCAL" />
+      <updated>1535723588527</updated>
+    </task>
+    <option name="localTasksCounter" value="15" />
     <servers />
   </component>
   <component name="TestHistory">
@@ -653,7 +665,7 @@
     </history-entry>
   </component>
   <component name="TimeTrackingManager">
-    <option name="totallyTimeSpent" value="156935000" />
+    <option name="totallyTimeSpent" value="157175000" />
   </component>
   <component name="TodoView">
     <todo-panel id="selected-file">
@@ -1070,8 +1082,8 @@
     </entry>
     <entry file="file://$PROJECT_DIR$/App/Script/Controller/Server.php">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="342">
-          <caret line="23" column="21" lean-forward="true" selection-start-line="23" selection-start-column="21" selection-end-line="23" selection-end-column="21" />
+        <state relative-caret-position="608">
+          <caret line="37" column="34" selection-start-line="37" selection-start-column="34" selection-end-line="37" selection-end-column="34" />
           <folding>
             <element signature="e#136#170#0#PHP" expanded="true" />
           </folding>

+ 20 - 22
App/Script/Controller/Server.php

@@ -17,11 +17,10 @@ class Server extends Controller
 
     /**
      * 执行逻辑
-     * @return mixed
      */
     protected function main()
     {
-        $i=0;
+        $i = 0;
         while (true) {
             $data = ServerTable::select();
             foreach ($data as $val) {
@@ -31,30 +30,29 @@ class Server extends Controller
                 if ($status == 1) {
                     echo $ip . "\t可用\r\n";
                 }
+                if ($val['status'] != $status) {
+                    ServerTable::update(['status' => $status], ['id' => $val['id']]);
+                }
             }
-            if ($val['status'] != $status) {
-                ServerTable::update(['status' => $status], ['id' => $val['id']]);
-            }
-            echo "第".$i."次执行完毕\r\n";
+            echo "第" . $i . "次执行完毕\r\n";
             sleep(60);
         }
 
     }
-}
 
-/**
- * @param string $ip ip
- * @param int $port 端口
- * @return int 返回状态
- */
-public
-function check($ip, $port)
-{
-    $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
-    socket_set_nonblock($sock);
-    socket_connect($sock, $ip, $port);
-    socket_set_block($sock);
-    $status = socket_select($r = array($sock), $w = array($sock), $f = array($sock), 2);
-    return $status;
-}
+    /**
+     * @param string $ip ip
+     * @param int $port 端口
+     * @return int 返回状态
+     */
+    public
+    function check($ip, $port)
+    {
+        $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
+        socket_set_nonblock($sock);
+        socket_connect($sock, $ip, $port);
+        socket_set_block($sock);
+        $status = socket_select($r = array($sock), $w = array($sock), $f = array($sock), 2);
+        return $status;
+    }
 }