Changeset 163

Show
Ignore:
Timestamp:
07/17/08 13:38:46 (4 months ago)
Author:
ken
Message:

adding stuff for cellmodem interface and fixing reboot.php

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Pyramid/dist/var/www/admin/include/community_functions.php

    r1 r163  
    132132 
    133133        $privilege = "INSERT INTO $USERS_DB.privileges 
    134         (username,view_status,view_macs,ban_users,access_ifs,edit_users, edit_privileges,  add_users  ) 
     134        (username,view_status,view_macs,ban_users,access_ifs,edit_users, edit_privileges,  add_users, reboot_system  ) 
    135135        VALUES ('".$user_info['username']."','true','false','false','false','false','false','false')"; 
    136136 
  • Pyramid/dist/var/www/admin/include/functions.php

    r150 r163  
    243243 
    244244/************************************************ 
     245* rebootsys() 
     246* Reboot the system 
     247*************************************************/ 
     248function rebootsys() { 
     249  return `/var/www/admin/include/reboot.sh &`; 
     250} 
     251 
     252/************************************************ 
    245253* get_modem() 
    246254* Return the currently selected cellular modem 
     
    248256function get_modem() { 
    249257  if(! file_exists('/dev/cellmodem')) { 
    250     return "None"; 
     258    return "No modem found or modem not enabled"; 
    251259  } 
    252260   
     
    259267  } 
    260268  elseif($modem == "/dev/ttyUSB0") { 
    261     $modem = "EVDO"; 
     269    $modem = "EVDO or HSDPA"; 
    262270  } 
    263271  else { 
    264     $modem = "None"; 
     272    $modem = "No modem found or modem not enabled"; 
    265273  } 
    266274  return $modem; 
     
    328336    privcmd("ln -sf /etc/init.d/$file /etc/rc2.d/S$priority$file",true); 
    329337    return privcmd("/etc/init.d/$file start",false); 
     338  } 
     339  //return true; 
     340} 
     341 
     342/************************************************ 
     343* set_rc_no_start() 
     344* Enable or disable a service 
     345*************************************************/ 
     346function set_rc_no_start($file,$priority) { 
     347  if($priority == 0) { 
     348    privcmd("rm -f /etc/rc2.d/S*$file",true); 
     349  } 
     350  else { 
     351    privcmd("ln -sf /etc/init.d/$file /etc/rc2.d/S$priority$file",true); 
    330352  } 
    331353  //return true; 
  • Pyramid/dist/var/www/admin/include/header.php

    r81 r163  
    100100                echo '<li><a href="./users.php" class="menulink">Edit Users</a></li>'; 
    101101        }                
     102        if(@($_SESSION["reboot_system"]=="true")) { 
     103                echo '<li><a href="./reboot.php" class="menulink">Reboot System</a></li>'; 
     104        } 
     105 
    102106echo ' 
    103107        </ul> 
  • Pyramid/dist/var/www/admin/reboot.php

    r1 r163  
    33include_once("./include/functions.php");                //These are NOT wrong includes. Including here AND later with header.php does matter! 
    44 
     5 
     6 
     7 
    58include("./include/header.php");        //echo the default Header entries 
    69 
    7 echo "<p class=\"index\"><img src=\"/images/pyramid.png\" width=\"100\"><br /><br /><font color='#900040'>".chostname()."</font> is rebooting, please wait...</p><br><br>"; 
     10//check privileges 
     11if ($_SESSION["access_ifs"]!="true"){ 
     12        echo "<p class = \"error\">You have no permission to access this section of WiFiAdmin</p>"; 
     13        exit(); 
     14
     15 
     16//check for reboot 
     17if (isset($_GET["reboot"])) { 
     18                  echo "<li><b>Rebooting system, please wait a few minutes and refresh your browser.</b></li>"; 
     19                  echo " <script type=\"text/javascript\"> 
     20                        <!-- 
     21                        window.location = \"/admin/\"  
     22                        //--> 
     23                        </script>"; 
     24 
     25                  rebootsys(); 
     26                  exit; 
     27                } 
     28 
     29 
     30 
     31 
     32 
     33 
     34echo " 
     35 
     36<form name=\"reboot\" action=\"/admin/reboot.php?reboot=1\" method=\"POST\"> 
     37 
     38<p class=\"index\"><img src=\"/images/pyramid.png\" width=\"100\"><br /><br /></br><input type=\"submit\" value=\"Reboot\">   </br><font color='#900040'>".chostname()."</font>";  
    839 
    940include("./include/footer.php"); 
     41 
    1042?> 
  • Pyramid/dist/var/www/admin/system.php

    r132 r163  
    4040} 
    4141 
     42 
    4243// default action 
    4344if(!isset($_GET['action'])) 
     
    5960                <p><fieldset title="Cellular Network Support"> 
    6061                <legend>Cellular Network</legend> 
    61                 Cellular modem detected: <b><?echo get_modem();?></b> <i><?echo get_ppp_status();?></i> 
     62                Cellular modem status: <b><?echo get_modem();?></b> <i><?echo get_ppp_status();?></i> 
     63                <p><input type="checkbox" name="cellmodemservice" value="on" <?if (get_rc("S14cellular-modules") AND get_rc("S15cellular")) echo 'checked';?>>Enable/Disable Cell Modem, reboot required</p> 
    6264                </fieldset></p> 
    6365                 
     
    8991                <input type ="hidden" name="action" value = "save_system_settings"> 
    9092                <input type="submit" value="Commit Changes"> 
    91                 </form><? 
    92                 break; 
    93         case "save_system_settings": 
    94                 echo "<h5>Saving System settings...</h5><ul>"; 
    95  
    96                 if(isset($_GET["hostname"])) { 
    97                   $hostname = escapeshellarg($_GET["hostname"]); 
    98                   if($hostname != "'".chostname()."'") { 
    99                     set_hostname($hostname); 
    100                     echo "<li>Hostname set to <b>".$hostname."</b>.</li>"; 
    101                   } 
    102                 } 
    103  
    104                 if(isset($_GET["domain"])) { 
    105                   $domain = $_GET["domain"]; 
    106                   if($domain != get_domain()) { 
    107                     set_domain($domain); 
    108                     echo "<li>Domain set to <b>".$domain."</b>.</li>"; 
    109                   } 
    110                 } 
    111  
    112                 if(isset($_GET["ntpd"])) { 
    113                   if(!get_rc("S15ntpd")) { 
    114                     echo "<li>Enabling NTP daemon.</li>"; 
    115                     set_rc("ntpd",15); 
    116                   } 
     93        </form><? 
     94        break; 
     95case "save_system_settings": 
     96        echo "<h5>Saving System settings...</h5><ul>"; 
     97 
     98        if(isset($_GET["hostname"])) { 
     99          $hostname = escapeshellarg($_GET["hostname"]); 
     100          if($hostname != "'".chostname()."'") { 
     101            set_hostname($hostname); 
     102            echo "<li>Hostname set to <b>".$hostname."</b>.</li>"; 
     103          } 
     104        } 
     105 
     106        if(isset($_GET["domain"])) { 
     107          $domain = $_GET["domain"]; 
     108          if($domain != get_domain()) { 
     109            set_domain($domain); 
     110            echo "<li>Domain set to <b>".$domain."</b>.</li>"; 
     111          } 
     112        } 
     113 
     114        if(isset($_GET["ntpd"])) { 
     115          if(!get_rc("S15ntpd")) { 
     116            echo "<li>Enabling NTP daemon.</li>"; 
     117            set_rc("ntpd",15); 
     118          } 
     119        } 
     120        else { 
     121          if(get_rc("S15ntpd")) {   
     122            echo "<li>Disabling NTP daemon.</li>"; 
     123            set_rc("ntpd",0); 
     124          } 
     125        } 
     126 
     127        if(isset($_GET["sshd"])) { 
     128          if(!get_rc("S20ssh")) { 
     129            echo "<li>Enabling SSH daemon.</li>"; 
     130            set_rc("ssh",20); 
     131          } 
     132        } 
     133        else { 
     134          if(get_rc("S20ssh")) {   
     135            echo "<li>Disabling SSH daemon.</li>"; 
     136            set_rc("ssh",0); 
     137          } 
     138        } 
     139 
     140/*              if(isset($_GET["dhcpd"])) { 
     141          if(!get_rc("S20dhcp")) { 
     142            echo "<li>Enabling dhcp server.</li>"; 
     143            set_rc("dhcp",20); 
     144          } 
     145        } 
     146        else { 
     147          if(get_rc("S20dhcp")) {   
     148            echo "<li>Disabling dhcp server.</li>"; 
     149            set_rc("dhcp",0); 
     150          } 
     151        } 
     152*/ 
     153        if(isset($_GET["bind"])) { 
     154          if(!get_rc("S12bind")) { 
     155            echo "<li>Enabling caching DNS server.</li>"; 
     156            set_rc("bind",12); 
     157          } 
     158        } 
     159        else { 
     160          if(get_rc("S12bind")) {   
     161            echo "<li>Disabling caching DNS server.</li>"; 
     162            set_rc("bind",0); 
     163          } 
     164        } 
     165 
     166        if(isset($_GET["cellmodemservice"])) { 
     167          if(!get_rc("S14cellular-modules")) { 
     168            echo "<li>Enabling cellmodem drivers.</li>"; 
     169            set_rc_no_start("cellular-modules",14); 
     170          } 
     171          if(!get_rc("S15cellular")) { 
     172            echo "<li>Enabling cellmodem init script.</li>"; 
     173            echo "<li><a href=\"/admin/reboot.php\">Reboot</a> required for changes to take effect.</li>"; 
     174            set_rc_no_start("cellular",15); 
     175            // rebootsys(); 
     176          } 
     177        } 
     178        else { 
     179          if(get_rc("S14cellular-modules")) {  
     180            echo "<li>Disabling cellmodem drivers.</li>"; 
     181            echo "<li><a href=\"/admin/reboot.php\">Reboot</a> required for changes to take effect.</li>";       
     182            set_rc_no_start("cellular-modules",0); 
     183          } 
     184          if(get_rc("S15cellular")) { 
     185            echo "<li>Disabling cellmodem init scripts.</li>"; 
     186            set_rc_no_start("cellular",0); 
     187          } 
     188        } 
     189 
     190 
     191        if(isset($_GET["modem"])) { 
     192          if($_GET["modem"] != get_modem()) { 
     193            // Only accept zones that are in the array 
     194            foreach($modems as $modem) { 
     195              if($modem == $_GET["modem"]) { 
     196                if($modem == "None") { 
     197                  echo "<li>Disabling cellular modem support.</li>"; 
    117198                } 
    118199                else { 
    119                   if(get_rc("S15ntpd")) {   
    120                     echo "<li>Disabling NTP daemon.</li>"; 
    121                     set_rc("ntpd",0); 
    122                   } 
     200                  echo "<li>Enabling <b>".$modem."</b> cellular modem support.</li>"; 
    123201                } 
     202                set_modem($modem); 
     203              } 
     204            } 
     205          } 
     206        } 
    124207         
    125                 if(isset($_GET["sshd"])) { 
    126                   if(!get_rc("S20ssh")) { 
    127                     echo "<li>Enabling SSH daemon.</li>"; 
    128                     set_rc("ssh",20); 
    129                   } 
    130                 } 
    131                 else { 
    132                   if(get_rc("S20ssh")) {   
    133                     echo "<li>Disabling SSH daemon.</li>"; 
    134                     set_rc("ssh",0); 
    135                   } 
    136                 } 
     208        if(isset($_GET["dyndns"]) && ($_GET["dyndns"] != "")) { 
     209          if(get_dyndns() != $_GET["dyndns"]) { 
     210            echo "<li>Setting up dyndns</li>"; 
     211            set_dyndns($_GET["dyndns"]); 
     212          } 
     213        } 
     214 
     215        if(isset($_GET["dyndnsupdate"]) && ($_GET["dyndnsupdate"] != "")) { 
     216          echo "<li>Sending dyndns update</li>"; 
     217          update_dyndns(); 
     218        } 
     219 
     220        if(isset($_GET["timezone"])) { 
     221          if($_GET["timezone"] != get_zone()) { 
     222            // Only accept zones that are in the array 
     223            foreach($zones as $zone) { 
     224              if($zone == $_GET["timezone"]) { 
     225                set_zone($zone); 
     226                echo "<li>Setting timezone to <b>".$zone."</b>.</li>"; 
     227              } 
     228            } 
     229          } 
     230        } 
    137231         
    138 /*              if(isset($_GET["dhcpd"])) { 
    139                   if(!get_rc("S20dhcp")) { 
    140                     echo "<li>Enabling dhcp server.</li>"; 
    141                     set_rc("dhcp",20); 
    142                   } 
    143                 } 
    144                 else { 
    145                   if(get_rc("S20dhcp")) {   
    146                     echo "<li>Disabling dhcp server.</li>"; 
    147                     set_rc("dhcp",0); 
    148                   } 
    149                 } 
    150 */ 
    151                 if(isset($_GET["bind"])) { 
    152                   if(!get_rc("S12bind")) { 
    153                     echo "<li>Enabling caching DNS server.</li>"; 
    154                     set_rc("bind",12); 
    155                   } 
    156                 } 
    157                 else { 
    158                   if(get_rc("S12bind")) {   
    159                     echo "<li>Disabling caching DNS server.</li>"; 
    160                     set_rc("bind",0); 
    161                   } 
    162                 } 
    163          
    164                 if(isset($_GET["modem"])) { 
    165                   if($_GET["modem"] != get_modem()) { 
    166                     // Only accept zones that are in the array 
    167                     foreach($modems as $modem) { 
    168                       if($modem == $_GET["modem"]) { 
    169                         if($modem == "None") { 
    170                           echo "<li>Disabling cellular modem support.</li>"; 
    171                         } 
    172                         else { 
    173                           echo "<li>Enabling <b>".$modem."</b> cellular modem support.</li>"; 
    174                         } 
    175                         set_modem($modem); 
    176                       } 
    177                     } 
    178                   } 
    179                 } 
    180                  
    181                 if(isset($_GET["dyndns"]) && ($_GET["dyndns"] != "")) { 
    182                   if(get_dyndns() != $_GET["dyndns"]) { 
    183                     echo "<li>Setting up dyndns</li>"; 
    184                     set_dyndns($_GET["dyndns"]); 
    185                   } 
    186                 } 
    187  
    188                 if(isset($_GET["dyndnsupdate"]) && ($_GET["dyndnsupdate"] != "")) { 
    189                   echo "<li>Sending dyndns update</li>"; 
    190                   update_dyndns(); 
    191                 } 
    192  
    193                 if(isset($_GET["timezone"])) { 
    194                   if($_GET["timezone"] != get_zone()) { 
    195                     // Only accept zones that are in the array 
    196                     foreach($zones as $zone) { 
    197                       if($zone == $_GET["timezone"]) { 
    198                         set_zone($zone); 
    199                         echo "<li>Setting timezone to <b>".$zone."</b>.</li>"; 
    200                       } 
    201                     } 
    202                   } 
    203                 } 
    204                  
    205                 if(isset($_GET["sshkeys"])) { 
    206                   if(set_sshkeys($_GET["sshkeys"])) { 
    207                     echo "<li>Installing new SSH keys for <b>root</b></li>"; 
    208                   } 
    209                 } 
    210                  
    211                 echo '</ul><p><a href="'.$_SERVER['PHP_SELF'].'">Back to System Settings</a>'; 
    212                 break; 
     232        if(isset($_GET["sshkeys"])) { 
     233          if(set_sshkeys($_GET["sshkeys"])) { 
     234            echo "<li>Installing new SSH keys for <b>root</b></li>"; 
     235          } 
     236        } 
     237 
     238 
     239        echo '</ul><p><a href="'.$_SERVER['PHP_SELF'].'">Back to System Settings</a>'; 
     240        break; 
    213241} 
    214242