./0000777000000000000000000000000011330503717012102 5ustar adminadministrators./README0000766000000000000000000000725611320054760012773 0ustar adminadministrators# ************************************************************ # # OpenNMP - AdnoveaŽ # sept 2009 # # IMPORTANT: The OpenNMP development environment is provided # under GPL licenses AS IS. By using OpenNMP, you endorse the # full and sole responsibility for direct and indirect damages # and/or losses. You yield any actions against the OpenNMP # developers and/or QNAP. OpenNMP is provided for educational # purpose only. # # ************************************************************ A- INSTALLATION --------------- Format an Ext3 external drive, copy the OpenNMP archive and install. 1- Plug an external USB storage media (256 MB minimun) - USB Memory stick (ReadyBoost recommanded) or USB Hard Disk Drive 2- Open and log with a Telnet console - Enable Remote Login in the Web Administration interface - Connect to port 13131 with Telnet (eg. Putty utility) - Log with admin (default password is admin) 3- With a Distribution package (TGZ file) - Unzip the 3 OpenNMP archive file (installer.sh, onmp.tgz and README) - Place the files in the NMP Download folder for example - Launch the installation from the directory where the archived has been extracted # ./installer.sh - Select carefully the USB device to use == ALL DATA WILL BE ERASED ON THE SELECTED USB DRIVE == or - open the OpenNMP web interface. Select "Administration" and log with A/C - Goto the NPKG under the NPKG Plug Ins section - in "Install a new NPKG Plugin or Upgrade OpenNMP" browse to the .onmp archive - Click "Install" or proceed with manual installation (see Troubleshooting section below) 4- Once completed, log to the OpenNMP interface with your web browser - http://:8080/ - Default A/C is: admin/admin B- USING OPENNMP ---------------- Once connected to the OpenNMP web interface, you shall Enable the needed plugins. Each NPKG can be activated (Enable) or not (Disable). You may also add some NPKG plugins. Goto to the MANAGE NPKG page and select the NPKG to add Each NPKG can be configured by clicking on its icon. All NPKG dependencies are installed with the selected NPKG. NPKG required by other NPKG (dependencies) cannot be removed until the child NPKG have been removed. * Change password Go to the "System Plugin" to change your OpenNMP admin password. C- Remove OPENNMP ----------------- 1- Uninstall OpenNMP with the commande line: # /.onmp/opennmp.sh remove 2- Delete the USB device content D- Troubleshooting ----------------- 1- Format the external USB storage - Identify the USB media (eg. /dev/sda1) with the linux command # fdisk -l - if mounted, unmount from the NMP web interface or the console # umount -f /dev/sda1 - Format using Ext3 # mkfs.ext3 /dev/sda1 - Unplug and replug to make it reconized by the NMP-1000 NOTE: if you have problems, format with Windows (NTFS) then plug to NMP and format as described above 2- After a manual extraction of the .onmp archive (.onmp is .tgz format) on the USB device, install OpenNMP and wait for the installation to be completed - in the root folder of the USB media type: # cd /share/USB_DRIVE_xx # ./autorun 3- if the installation fails, hangs or is incomplete, restart it: # cd /share/USB_DRIVE_xx/.onmp # ./install.sh install 4- Change password You can change the OpenNMP admin password using the "System" Plugins. To manually generate a new password use "htpasswd" utility available on Internet The password is stored as a "MD5 Apache encrypted" string into .onmp/passwd ./.npkg/0000777000000000000000000000000011326064120013112 5ustar adminadministrators./.npkg/system/0000777000000000000000000000000011326064122014440 5ustar adminadministrators./.npkg/system/system.ini0000766000000000000000000000350511326564465016510 0ustar adminadministrators;################################# ; ; ABSTRACT: NPKG parameters ; ; HISTORY: ; 2009/09/28 Written by Laurent (Ad'NoveaŽ) ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; See the GNU General Public License for more details. ; ;################################# ; [npkg] ; ; NPKG Plugin name Name = System ; ; NPKG Plugin version or software version for application Version = 1.2 ; ; Date of NPKG development of date of the application release Date = 2010-01-20 ; ; NPKG author /maintainer or application provide Author = "AdNovea®" ; ; Hardware platform supported by the current NPKG (use space as list separator) Models = NMP-1000 ; ; Oldest OpenNMP installed version that could be used to run this NPKG onmp_version = 0.04.01 ; ; NPKG Category (please keep consistency with already deployed plugins) Category = System Administration ; ; Dependencies from other NPKG. The NPKG dependencies will be installed before the current one in automatic mode (use space as list separator) Dependencies = Optware ; ; IPKG modules required in the order of installation (use space as list separator) Ipkg = lighttpd sqlite screen openssh ; ; Script or program to Start/Stop. it will be linked in the /opt/etc/init.d directory for handling execution priority Service = system.sh ; ; Process priority (above 99 for none system NPKG) . There can be 2 different values: first is for Start and second for Kill if needed (use space as list separator) Priority = 10 ; ; Status of the NPKG. Normally UNKOWN after a first installation. Can be set to TRUE for NPKG that does not need to be Enabled/Disabled Enable = TRUE ; ; MD5 is managed by the NPKG installation procedure. Does not need to be given here MD5 = ./.npkg/system/inc/0000777000000000000000000000000011330353106015207 5ustar adminadministrators./.npkg/system/inc/sshd_config0000766000000000000000000000646311273361126017441 0ustar adminadministrators# $OpenBSD: sshd_config,v 1.80 2008/07/02 02:24:18 djm Exp $ # This is the sshd server system-wide configuration file. See # sshd_config(5) for more information. # This sshd was compiled with PATH=/opt/sbin:/opt/bin:/usr/sbin:/usr/bin:/sbin:/bin # The strategy used for options in the default sshd_config shipped with # OpenSSH is to specify options with their default value where # possible, but leave them commented. Uncommented options change a # default value. Port 22 #AddressFamily any #ListenAddress 0.0.0.0 #ListenAddress :: # Disable legacy (protocol version 1) support in the server for new # installations. In future the default will change to require explicit # activation of protocol 1 Protocol 2 # HostKey for protocol version 1 #HostKey /opt/etc/openssh/ssh_host_key # HostKeys for protocol version 2 HostKey /opt/etc/openssh/ssh_host_rsa_key HostKey /opt/etc/openssh/ssh_host_dsa_key # Lifetime and size of ephemeral version 1 server key #KeyRegenerationInterval 1h #ServerKeyBits 1024 # Logging # obsoletes QuietMode and FascistLogging #SyslogFacility AUTH #LogLevel INFO # Authentication: #LoginGraceTime 2m #PermitRootLogin yes #StrictModes yes #MaxAuthTries 6 #MaxSessions 10 #RSAAuthentication yes #PubkeyAuthentication yes #AuthorizedKeysFile .ssh/authorized_keys # For this to work you will also need host keys in /opt/etc/openssh/ssh_known_hosts #RhostsRSAAuthentication no # similar for protocol version 2 #HostbasedAuthentication no # Change to yes if you don't trust ~/.ssh/known_hosts for # RhostsRSAAuthentication and HostbasedAuthentication #IgnoreUserKnownHosts no # Don't read the user's ~/.rhosts and ~/.shosts files #IgnoreRhosts yes # To disable tunneled clear text passwords, change to no here! #PasswordAuthentication yes #PermitEmptyPasswords no # Change to no to disable s/key passwords #ChallengeResponseAuthentication yes # Kerberos options #KerberosAuthentication no #KerberosOrLocalPasswd yes #KerberosTicketCleanup yes #KerberosGetAFSToken no # GSSAPI options #GSSAPIAuthentication no #GSSAPICleanupCredentials yes # Set this to 'yes' to enable PAM authentication, account processing, # and session processing. If this is enabled, PAM authentication will # be allowed through the ChallengeResponseAuthentication and # PasswordAuthentication. Depending on your PAM configuration, # PAM authentication via ChallengeResponseAuthentication may bypass # the setting of "PermitRootLogin without-password". # If you just want the PAM account and session checks to run without # PAM authentication, then enable this but set PasswordAuthentication # and ChallengeResponseAuthentication to 'no'. #UsePAM no #AllowAgentForwarding yes #AllowTcpForwarding yes #GatewayPorts no #X11Forwarding no #X11DisplayOffset 10 #X11UseLocalhost yes #PrintMotd yes #PrintLastLog yes #TCPKeepAlive yes #UseLogin no # UsePrivilegeSeparation yes UsePrivilegeSeparation no #PermitUserEnvironment no #Compression delayed #ClientAliveInterval 0 #ClientAliveCountMax 3 #UseDNS yes #PidFile /opt/var/run/sshd.pid #MaxStartups 10 #PermitTunnel no #ChrootDirectory none # no default banner path #Banner none # override default of no subsystems Subsystem sftp /opt/libexec/sftp-server AllowUsers admin # Example of overriding settings on a per-user basis #Match User anoncvs # X11Forwarding no # AllowTcpForwarding no # ForceCommand cvs server ./.npkg/system/inc/99-opennmp.conf0000766000000000000000000000224611330566613020007 0ustar adminadministrators# ********************************************************************** # Lighttpd web server configuration for OpenNMP # AdNovea - oct 2009 # OpenNMP Configuration # ********************************************************************** # repository for uploaded files server.upload-dirs = ("/opt/var/tmp") # Mandatory from Lighttpd version 1.4.24 server.event-handler = "poll" # To improve the upload a lit bit server.max-keep-alive-requests = 0 server.max-keep-alive-idle = 60 server.network-backend = "writev" # Enable Authentication server.modules += ( "mod_auth" ) # Create a new rule for lighttpd - we use "htpasswd" protection with MD5 Apache encryption # We exclude the root folder $HTTP["url"] =~ "/opennmp/inc" { auth.backend = "htpasswd" auth.backend.htpasswd.userfile = "/opt/etc/htpasswd" auth.require = ( "/opennmp/inc" => ( "method" => "basic", "realm" => "OpenNMP Administration Interface", "require" => "user=admin" ) ) } # Few additional information below: # Define a rule: $HTTP["url"] =~ "^/" { ... } # excluse some files and folders: auth.require !~ ( "^(/opennmp/inc.*|/opennmp/images/icon.png)$" =>$HTTP["url"] =~ "^/" { ..... ./.npkg/system/inc/passwd.def0000766000000000000000000000005411330600421017163 0ustar adminadministratorsadmin:$apr1$m9LT5yHo$2FhnBvBMVWcDIQ5OELB9Y0 ./.npkg/system/inc/scheduler.php0000766000000000000000000005301011330567401017703 0ustar adminadministrators "; // Constantes initialization $scheduler_data = array(); $MISSING_FOLDER = false; $scheduler_format_add = ""; $event_type = "CMD"; // Set to default format value $scheduler_format = array(); $scheduler_format[] = "CMD"; // Reset fields function clear_event() { global $event_fields; $event_fields['uuid'] = ""; $event_fields['type'] = "CMD"; $event_fields['title'] = ""; $event_fields['src'] = ""; $event_fields['weekly1'] = ""; $event_fields['weekly2'] = ""; $event_fields['weekly3'] = ""; $event_fields['weekly4'] = ""; $event_fields['weekly5'] = ""; $event_fields['weekly6'] = ""; $event_fields['weekly7'] = ""; $event_fields['start'] = ""; $event_fields['stop'] = ""; return $event_fields; } // Scheduler commands function scheduler($cmd="") { $output = null; exec("/share/OpenNMP/.onmp/scheduler $cmd",$output); return ($output!=null?$output[0]:""); } // Edit a recording event function scheduler_edit_event($uuid) { global $rootdir, $onmpdir, $event_fields; $scheduled_events = parse_ini_file("$rootdir/$onmpdir/recording.ini", true); $event_fields['uuid'] = $uuid; $event_fields['type'] = $scheduled_events[$uuid]['type']; $event_fields['title'] = $scheduled_events[$uuid]['title']; $event_fields['src'] = $scheduled_events[$uuid]['src']; $event_fields['weekly1'] = (strpos($scheduled_events[$uuid]['weekly'],"Mon")===false?"":"checked"); $event_fields['weekly2'] = (strpos($scheduled_events[$uuid]['weekly'],"Tue")===false?"":"checked"); $event_fields['weekly3'] = (strpos($scheduled_events[$uuid]['weekly'],"Wed")===false?"":"checked"); $event_fields['weekly4'] = (strpos($scheduled_events[$uuid]['weekly'],"Thu")===false?"":"checked"); $event_fields['weekly5'] = (strpos($scheduled_events[$uuid]['weekly'],"Fri")===false?"":"checked"); $event_fields['weekly6'] = (strpos($scheduled_events[$uuid]['weekly'],"Sat")===false?"":"checked"); $event_fields['weekly7'] = (strpos($scheduled_events[$uuid]['weekly'],"Sun")===false?"":"checked"); $event_fields['start'] = date("m/d/Y H:i",$scheduled_events[$uuid]['start']); $event_fields['stop'] = date("m/d/Y H:i",$scheduled_events[$uuid]['stop']); } // Delete a recording event function scheduler_delete_event($uuid ) { global $rootdir, $onmpdir; scheduler_pause_event($uuid, "pause"); $output = null; exec("/bin/sed -ri '/\[$uuid\]/,/status = /d' $rootdir/$onmpdir/recording.ini",$output); } // Pause a recording event function scheduler_pause_event($uuid, $mode="" ) { global $rootdir, $onmpdir; $output = null; exec("/sbin/getcfg '$uuid' status -f $rootdir/$onmpdir/recording.ini",$output); if ($mode == "pause") $state = "DISABLED"; else $state = ($output[0]=="DISABLED"?"ENABLED":"DISABLED"); if ($state == "DISABLED") scheduler("--end $uuid"); $output = null; exec("/sbin/setcfg '$uuid' status $state -f $rootdir/$onmpdir/recording.ini",$output); scheduler("--check"); } // Scheduler Status function scheduler_status() { $output = null; exec("/bin/cat /etc/config/crontab | /bin/grep -i scheduler", $output); return ($output==null?false:true); } // Recording Status function recorder_status($name) { $output = null; exec("/opt/bin/screen -list | /bin/grep -i $name", $output); return ($output==null?false:true); } // Get Screen PID function screen_pid($screen_name) { $output = null; exec("/opt/bin/screen -list | /bin/grep -i $screen_name",$output); if (isset($output[0])) { $pid = preg_split('/\./',$output[0]); return $pid[0]; } return null; } // Set a new recording event function scheduler_set_event($uuid) { global $rootdir, $onmpdir, $scheduler_data; $duration = strtotime($_POST['stopDate']) - strtotime($_POST['startDate']); $folder = $scheduler_data[$_POST['schedule_format']]['folder']; if ($uuid != "") scheduler_delete_event($uuid); else $uuid = uuid(); if ( ($_POST['url_recording'] == "") || ($_POST['startDate'] == "") || ($duration <= 0) ) { $mypvr_start = $_POST['startDate']; $mypvr_stop = $_POST['stopDate']; $mypvr_url = $_POST['url_recording']; return _NPKG_SCHEDULER_NOSCHEDULE; } else { $handle = fopen("$rootdir/$onmpdir/recording.ini", 'a'); $weekly = (isset($_POST['schedule_days_1'])?"Mon ":"").(isset($_POST['schedule_days_2'])?"Tue ":""). (isset($_POST['schedule_days_3'])?"Wed ":"").(isset($_POST['schedule_days_4'])?"Thu ":""). (isset($_POST['schedule_days_5'])?"Fri ":"").(isset($_POST['schedule_days_6'])?"Sat ":""). (isset($_POST['schedule_days_7'])?"Sun ":""); $content = "[$uuid]\ntype = ".$_POST['schedule_format']. "\ntitle = \"".trim($_POST['channel'])."\"". "\nsrc = \"".$_POST['url_recording']."\"". "\nstart = ".strtotime($_POST['startDate']). "\nstop = ".strtotime($_POST['stopDate']). "\nduration = $duration". "\nweekly = $weekly". "\nfolder = \"$folder\"". "\nstatus = ENABLED\n"; // status MUST BE the last entry in the section fwrite($handle, $content); fclose($handle); } scheduler("--check"); } // List all recording events ($event_type = ["AUDIO","VIDEO","CMD",...] function scheduler_interface($evt_type) { global $lid, $rootdir, $onmpdir, $scheduler_format, $scheduler_data, $scheduler_format_add, $event_fields; $event_type = $evt_type; // Event entry (Edit or New event) $screen = $scheduler_data[$event_type]['screen']; $S_item = (isset($_POST['event_item'])?$_POST['event_item']:""); // Retreive value after entry error if (isset($_POST['scheduler_item'])) { $S_type = $_POST['schedule_format']; $S_url = $_POST['url_recording']; $S_channel = $_POST['channel']; $S_week1 = (isset($_POST['schedule_days_1'])?"checked":""); $S_week2 = (isset($_POST['schedule_days_2'])?"checked":""); $S_week3 = (isset($_POST['schedule_days_3'])?"checked":""); $S_week4 = (isset($_POST['schedule_days_4'])?"checked":""); $S_week5 = (isset($_POST['schedule_days_5'])?"checked":""); $S_week6 = (isset($_POST['schedule_days_6'])?"checked":""); $S_week7 = (isset($_POST['schedule_days_7'])?"checked":""); $S_start =$_POST['startDate']; $S_stop = $_POST['stopDate']; } else { // New entry (clear event_fields) if (!isset($event_fields['uuid'])) clear_event(); // Retreive value for event edition $S_type = $event_fields['type']; $S_url = $event_fields['src']; $S_channel = $event_fields['title']; $S_week1 = $event_fields['weekly1']; $S_week2 = $event_fields['weekly2']; $S_week3 = $event_fields['weekly3']; $S_week4 = $event_fields['weekly4']; $S_week5 = $event_fields['weekly5']; $S_week6 = $event_fields['weekly6']; $S_week7 = $event_fields['weekly7']; $S_start = $event_fields['start']; $S_stop =$event_fields['stop']; } echo "

"._NPKG_SCHEDULER_TITLE."

"; // Scheduler ON/OFF echo " \n"; // Scheduler controls if (file_exists("$rootdir/$onmpdir/recording.ini")) { $scheduled_events = parse_ini_file("$rootdir/$onmpdir/recording.ini", true); foreach ($scheduled_events as $key=>$sched) if ( ($event_type != "CMD") && ($sched['type'] != $event_type) ) unset($scheduled_events[$key]); if (count($scheduled_events) > 0) { foreach ($scheduled_events as $key=>$sched) $start[$key] = $sched['start']; array_multisort($start, SORT_ASC, $scheduled_events); echo " \n"; // Scheduled events management echo "
"._NPKG_SCHEDULER_FORMAT."
 
"._NPKG_SCHEDULER_DESC."
 
"._NPKG_SCHEDULER_URL."
 
"._NPKG_SCHEDULER_INSTANT."
"._NPKG_SCHEDULER_REPEAT."   "._MONDAY." "._TUESDAY." "._WEDNESDAY." "._THURSDAY." "._FRIDAY." "._SATURDAY." "._SUNDAY."
"._NPKG_SCHEDULER_START."   "._NPKG_SCHEDULER_STOP."   ".($S_item==""?_BT_ADD:_BT_MODIFY)." "._BT_RESET."

"._NPKG_SCHEDULER_RUN."   "._BT_ENABLE."   "._BT_DISABLE." \n"; $rec_running = false; foreach ($scheduler_format as $kformat) if ( screen_pid($kformat."_") ) $rec_running = true; if ($rec_running) echo "     \n"; echo "\n

"._NPKG_SCHEDULER_LIST."
"._BT_REMOVE." "._BT_PAUSE." \n"; } } echo "
"; // Set the format to match the displayed event (do it now because The format drop list has already been created and item selected) // $select_type = ""; // if (isset($event_fields['type']) && ($event_fields['type'] != "")) $select_type = $event_fields['type']; // if (isset($_POST['scheduler_item']) ) $select_type = $_POST['scheduler_item']; // Set event_type for New event if ( !isset($_POST['scheduler_item']) && !isset($_POST['event_item'])) $S_type = ($S_type==""?$S_type:$event_type); echo " "; } // List all recording events function scheduler_events() { global $rootdir, $onmpdir, $lid; $scheduler_status = scheduler_status(); // Table header echo "

  "._NPKG_SCHEDULER_EVENTS.""._NPKG_SCHEDULER_STATUS. "    

\n"; if (file_exists("$rootdir/$onmpdir/recording.ini")) $scheduled_events = parse_ini_file("$rootdir/$onmpdir/recording.ini", true); else $scheduled_events = array(); if (count($scheduled_events) > 0) { foreach ($scheduled_events as $key=>$sched) $start[$key] = $sched['start']; array_multisort($start, SORT_ASC, $scheduled_events); $i= 0; // List of scheduled events foreach ($scheduled_events as $key=>$sched) { $mypvr_h= (int) ($sched['duration']/3600); $mypvr_m = (int) (($sched['duration']/3600 - $mypvr_h)*60); $i++; $status = ($sched['status']=="DISABLED"?_NPKG_DISABLED:(!$scheduler_status?"-":($sched['status']=="ENABLED"?_NPKG_ENABLED:($sched['status']=="RECORDING"?_NPKG_RECORDING:"???")))); echo " \n"; } echo "
# "._NPKG_SCHEDULER_START." "._NPKG_SCHEDULER_DESC." ".(ord(substr(_MONDAY,0,1))==230?substr(_MONDAY,6,3):substr(_MONDAY,0,1))." ".(ord(substr(_TUESDAY,0,1))==230?substr(_TUESDAY,6,3):substr(_TUESDAY,0,1))." ".(ord(substr(_WEDNESDAY,0,1))==230?substr(_WEDNESDAY,6,3):substr(_WEDNESDAY,0,1))." ".(ord(substr(_THURSDAY,0,1))==230?substr(_THURSDAY,6,3):substr(_THURSDAY,0,1))." ".(ord(substr(_FRIDAY,0,1))==230?substr(_FRIDAY,6,3):substr(_FRIDAY,0,1))." ".(ord(substr(_SATURDAY,0,1))==230?substr(_SATURDAY,6,3):substr(_SATURDAY,0,1))." ".(ord(substr(_SUNDAY,0,1))==230?substr(_SUNDAY,6,3):substr(_SUNDAY,0,1))." "._NPKG_SCHEDULER_DURATION." "._NPKG_SCHEDULER_FORMAT."   "._ST_ACTIONS." "._NPKG_SCHEDULER_STATUS."
$i ".date(_ST_DATETIME,$sched['start'])." ".date("D",$sched['start'])." ".$sched['title']." ".(strpos($sched['weekly'],"Mon")!==false?"X":"")." ".(strpos($sched['weekly'],"Tue")!==false?"X":"")." ".(strpos($sched['weekly'],"Wed")!==false?"X":"")." ".(strpos($sched['weekly'],"Thu")!==false?"X":"")." ".(strpos($sched['weekly'],"Fri")!==false?"X":"")." ".(strpos($sched['weekly'],"Sat")!==false?"X":"")." ".(strpos($sched['weekly'],"Sun")!==false?"X":"")." ".sprintf("%02s:%02s", $mypvr_h, $mypvr_m)."   ".$sched['type']."       $status
\n"; } } // Display scheduler and process actions function scheduler_show($evt_type="CMD") { global $rootdir, $onmpdir, $onmp, $scheduler_data, $scheduler_format, $scheduler_format_add, $MISSING_FOLDER, $event_type; $event_fields = array(); $event_type = $evt_type; $config_ini_array = parse_ini_file("$rootdir/$onmpdir/config.ini", true); $scheduler_data['CMD']['screen'] = "CMD_"; $scheduler_data['CMD']['folder'] = $config_ini_array['scheduler']['cmd_folder']; $scheduler_data['CMD']['folder'] = ($scheduler_data['CMD']['folder']==""?"/share/OpenNMP":$scheduler_data['CMD']['folder']); if ( !file_exists($scheduler_data['CMD']['folder'] ) ) $MISSING_FOLDER = true; // Get additional formats (AUDIO & VIDEO) if NPKGs are availabled $option = "$rootdir/.npkg/media_services/inc/scheduler.php"; if (file_exists($option)) require_once($option); $option = "$rootdir/.npkg/my-pvr/inc/scheduler.php"; if (file_exists($option)) require_once($option); if ($MISSING_FOLDER) return _NPKG_SCHEDULER_NOHDD; // Process commands $msg = ""; $command = (isset($_POST['scheduler_command'])?$_POST['scheduler_command']:(isset($_POST['event_command'])?$_POST['event_command']:"")); if ($command != "") { $folder = $scheduler_data[$event_type]['folder']; switch ($command) { // Scheduler ON/OFF case "activate" : scheduler("--on"); break; case "disable" : scheduler("--off"); break; // Add/Remove event case "set_event": $msg = scheduler_set_event($_POST['scheduler_item']); if ($msg == "") unset($_POST['scheduler_item']); break; // Remove/Pause from event droplist case "hold" : scheduler_pause_event($_POST['sched_item']); break; case "remove" : scheduler_delete_event($_POST['sched_item']); break; // Edit/Pause/Delete from events list case "edit" : scheduler_edit_event($_POST['event_item']); break; case "pause" : scheduler_pause_event($_POST['event_item']); break; case "delete" : scheduler_delete_event($_POST['event_item']); break; // Instant Recording on/off case "record_on": if ($_POST['url_recording'] != "") $msg = scheduler("--begin Instant_Recording ".$_POST['schedule_format']." \"$folder\" Instant_Recording \"".$_POST['url_recording']."\""); else $msg = _NPKG_SCHEDULER_NOFOLDER; break; case "record_off": scheduler("--end Instant_Recording"); break; } } // Display Scheduler interface scheduler_interface($event_type); return $msg; } ?>./.npkg/system/inc/cfg-system.php0000766000000000000000000006620411330570436020021 0ustar adminadministrators function refresh() { window.location='$url_page'; } //window.location.reload() function timeset() { setTimeout('refresh()', 15000); } window.onload = timeset; "; // NPKG Configuration page header $show_enable = false; $show_disable = false; $show_remove = false; include("npkg_head.php"); // Tabs $tab = (isset($_GET['tab'])?$_GET['tab']:1); echo "
"._NPKG_ADM_TITLE." "._NPKG_WEB_TITLE." "._NPKG_TIME_TITLE." "._NPKG_SSH_TITLE." "._NPKG_SCHEDULER." "._NPKG_CRON_TITLE."
"; // **** Administration // ---------------------------------------------------------------------- if ($tab == 1) { $msg = ""; // Apache MD5 Crypt function function crypt_apr1_md5($plainpasswd, $salt) { $tmp = ""; if ($salt == "") $salt = substr(str_shuffle("abcdefghijklmnopqrstuvwxyz0123456789"), 0, 8); $len = strlen($plainpasswd); $text = $plainpasswd.'$apr1$'.$salt; $bin = pack("H32", md5($plainpasswd.$salt.$plainpasswd)); for($i = $len; $i > 0; $i -= 16) { $text .= substr($bin, 0, min(16, $i)); } for($i = $len; $i > 0; $i >>= 1) { $text .= ($i & 1) ? chr(0) : $plainpasswd{0}; } $bin = pack("H32", md5($text)); for($i = 0; $i < 1000; $i++) { $new = ($i & 1) ? $plainpasswd : $bin; if ($i % 3) $new .= $salt; if ($i % 7) $new .= $plainpasswd; $new .= ($i & 1) ? $bin : $plainpasswd; $bin = pack("H32", md5($new)); } for ($i = 0; $i < 5; $i++) { $k = $i + 6; $j = $i + 12; if ($j == 16) $j = 5; $tmp = $bin[$i].$bin[$k].$bin[$j].$tmp; } $tmp = chr(0).chr(0).$bin[11].$tmp; $tmp = strtr(strrev(substr(base64_encode($tmp), 2)), "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); return "$"."apr1"."$".$salt."$".$tmp; } // Upload for config.ini function upoad_ini() { global $ddl_maxsize, $ddl_dir, $rootdir, $webdir, $onmpdir; if (!isset($_FILES['sysfile']['tmp_name'])) return _NPKG_CANNOT_LOAD; if (!is_uploaded_file($_FILES['sysfile']['tmp_name'])) return _NPKG_NOT_FOUND; $name_file = $_FILES['sysfile']['name']; $extension = end(explode('.',$name_file)); if ($extension != "ini") return _NPKG_NAME_INVALID; if (!move_uploaded_file($_FILES['sysfile']['tmp_name'], $ddl_dir. $name_file) ) return _NPKG_CANNOT_LOAD; if ( !file_exists($ddl_dir. $name_file) ) return _NPKG_CANNOT_LOAD; // Need to check again, I saw some problems here copy($ddl_dir. $name_file, "$rootdir/$onmpdir/config.ini"); // Replace existing config unlink($ddl_dir. $name_file); // Clean before leaving return _NPKG_LOADED; } // Change password if (isset($_POST['pwd_old'])) { $pwd_array = array(); // Retreive current password foreach (file("$npkg_dir/$npkg/inc/passwd") as $line) if (substr($line,0,strpos($line,":")) == "admin") $txt = $line; else $pwd_array[] = $line; // Explode password string $pwd_user = "admin"; //$pwd_user = substr($txt,0,strpos($txt,":")); $pwd_salt = substr($txt,strpos($txt,"\$apr1\$")+6,8); $pwd_md5 = trim(substr($txt,strpos($txt,":")+1)); // Check entries if (crypt_apr1_md5($_POST['pwd_old'],$pwd_salt) != $pwd_md5) $pwd_msg = _NPKG_PWD_WRONG; else if ( ($_POST['pwd_new'] == "") || ($_POST['pwd_new'] != $_POST['pwd_confirm']) ) $pwd_msg = _NPKG_PWD_NOMATCH; else { // Save new password if ( ($ini_handle = fopen("$npkg_dir/$npkg/inc/passwd", 'w+')) !== false) { foreach ($pwd_array as $line) fwrite($ini_handle, $line); fwrite($ini_handle, "$pwd_user:".crypt_apr1_md5($_POST['pwd_new'],$pwd_salt)); $pwd_msg = _NPKG_PWD_CHANGED; } else $pwd_msg = _NPKG_PWD_FAILED; } echo $url_reload; } else $pwd_msg = ""; // Copy config.ini in logs to enable download copy("$rootdir/$onmpdir/config.ini", "$rootdir/$webdir/logs/config.ini"); // Load config.ini, reboot or shutdown if (isset($_FILES['sysfile'])) { $msg = "
".upoad_ini(); } if (isset($_GET['reboot'])) { $output = null; exec("reboot",$output); $url_reload; } if (isset($_GET['shutdown'])) { $output = null; exec("poweroff",$output); $url_reload; } if (isset($_GET['mono_on'])) { $output = null; exec("/etc/init.d/player.sh start",$output); $url_reload; } if (isset($_GET['mono_off'])) { $output = null; exec("/etc/init.d/player.sh stop",$output); $url_reload; } // Configure Theme/Password/Params page echo "
"; } // **** Configure Web Server // ---------------------------------------------------------------------- if ($tab == 2) { // Set Web server parametres if (isset($_POST['webport'])) { echo $url_reload; cgi_bin("npkg.cgi?action=$npkg&webserver=restart&port=".$_POST['webport']."&globals=".($_POST['reg_globals']==1?"On":"Off")); } // Set Web server under maintenance if (isset($_POST['maintenance'])) { if ($_POST['maintenance'] == 1) { $maintenance = true; $value = "TRUE"; } else { $maintenance = false; $value = "FALSE"; } $output = null; exec(CMD_SETCFG." 'ONMP' 'maintenance' '$value' -f $rootdir/$onmpdir/config.ini",$output); } // Web Server configuration page $output = null; exec(CMD_GETCFG." 'PHP' 'register_globals' -f /opt/etc/php.ini",$output); $globals = $output[0]; $output = null; exec(CMD_GETCFG." '' 'server.port' -f /opt/etc/lighttpd/lighttpd.conf",$output); $port = $output[0]; echo "