void ptz_html(void) { printf(" <html><head></head>\n"); printf(" <center><BR>\n"); printf(" <table border=0 width=\"80%\">\n"); printf(" <tr><td class=header><strong>ptz_control</strong></td></tr>\n"); printf(" <tr><td><hr></td></tr>\n"); //printf(" <tr><td><font color=#FF0000>Warnning: When you changed the IP Address,Please relogin in new IP after ten seconds. </font></td></tr>"); printf(" <tr><td><table border=0>\n"); printf(" <tr><td><strong>ptz----</strong><td>\n"); GetConfValues(); if(GetRights()>1) { exit(0); } data = getenv("QUERY_STRING"); strcpy (cmd, data); ptz_control(cmd); free(CONF_SYS); printf(" <tr><td><td>\n"); printf(" <tr><td>DHCP Client<td>\n"); printf(" </center></html>\n"); }
TRights TCopyParamType::RemoteFileRights(uintptr_t Attrs) const { TRights R = GetRights(); if ((Attrs & faDirectory) && GetAddXToDirectories()) R.AddExecute(); return R; }
void TCopyParamType::Save(THierarchicalStorage * Storage) const { Storage->WriteBool("AddXToDirectories", GetAddXToDirectories()); Storage->WriteString("Masks", GetAsciiFileMask().GetMasks()); Storage->WriteInteger("FileNameCase", GetFileNameCase()); Storage->WriteBool("PreserveReadOnly", GetPreserveReadOnly()); Storage->WriteBool("PreserveTime", GetPreserveTime()); Storage->WriteBool("PreserveTimeDirs", GetPreserveTimeDirs()); Storage->WriteBool("PreserveRights", GetPreserveRights()); Storage->WriteBool("IgnorePermErrors", GetIgnorePermErrors()); Storage->WriteString("Text", GetRights().GetText()); Storage->WriteInteger("TransferMode", GetTransferMode()); Storage->WriteInteger("ResumeSupport", GetResumeSupport()); Storage->WriteInt64("ResumeThreshold", GetResumeThreshold()); Storage->WriteInteger("ReplaceInvalidChars", static_cast<uint32_t>(GetInvalidCharsReplacement())); Storage->WriteString("LocalInvalidChars", GetLocalInvalidChars()); Storage->WriteBool("CalculateSize", GetCalculateSize()); Storage->WriteString("IncludeFileMask", GetIncludeFileMask().GetMasks()); Storage->DeleteValue("ExcludeFileMask"); // obsolete Storage->DeleteValue("NegativeExclude"); // obsolete DebugAssert(FTransferSkipList.get() == nullptr); DebugAssert(FTransferResumeFile.IsEmpty()); Storage->WriteBool("ClearArchive", GetClearArchive()); Storage->WriteBool("RemoveCtrlZ", GetRemoveCtrlZ()); Storage->WriteBool("RemoveBOM", GetRemoveBOM()); Storage->WriteInteger("CPSLimit", GetCPSLimit()); Storage->WriteBool("NewerOnly", GetNewerOnly()); }
UnicodeString TCopyParamType::GetLogStr() const { wchar_t CaseC[] = L"NULFS"; wchar_t ModeC[] = L"BAM"; wchar_t ResumeC[] = L"YSN"; // OpenArray (ARRAYOFCONST) supports only up to 19 arguments, so we had to split it return FORMAT( L" PrTime: %s%s; PrRO: %s; Rght: %s; PrR: %s (%s); FnCs: %c; RIC: %c; " L"Resume: %c (%d); CalcS: %s; Mask: %s\n", BooleanToEngStr(GetPreserveTime()).c_str(), UnicodeString(GetPreserveTime() && GetPreserveTimeDirs() ? L"+Dirs" : L"").c_str(), BooleanToEngStr(GetPreserveReadOnly()).c_str(), GetRights().GetText().c_str(), BooleanToEngStr(GetPreserveRights()).c_str(), BooleanToEngStr(GetIgnorePermErrors()).c_str(), CaseC[GetFileNameCase()], CharToHex(GetInvalidCharsReplacement()).c_str(), ResumeC[GetResumeSupport()], (int)GetResumeThreshold(), BooleanToEngStr(GetCalculateSize()).c_str(), GetFileMask().c_str()) + FORMAT( L" TM: %c; ClAr: %s; RemEOF: %s; RemBOM: %s; CPS: %u; NewerOnly: %s; InclM: %s; ResumeL: %d\n" L" AscM: %s\n", ModeC[GetTransferMode()], BooleanToEngStr(GetClearArchive()).c_str(), BooleanToEngStr(GetRemoveCtrlZ()).c_str(), BooleanToEngStr(GetRemoveBOM()).c_str(), int(GetCPSLimit()), BooleanToEngStr(GetNewerOnly()).c_str(), GetIncludeFileMask().GetMasks().c_str(), ((FTransferSkipList.get() != nullptr) ? FTransferSkipList->GetCount() : 0) + (!FTransferResumeFile.IsEmpty() ? 1 : 0), GetAsciiFileMask().GetMasks().c_str()); }
//======================================================================// bool Authorization::Init(int id) { //puts("bool Authorization::Init(int id)"); GetRights(id); return true; }
void TCopyParamType::Load(THierarchicalStorage * Storage) { SetAddXToDirectories(Storage->ReadBool("AddXToDirectories", GetAddXToDirectories())); GetAsciiFileMask().SetMasks(Storage->ReadString("Masks", GetAsciiFileMask().GetMasks())); SetFileNameCase(static_cast<TFileNameCase>(Storage->ReadInteger("FileNameCase", GetFileNameCase()))); SetPreserveReadOnly(Storage->ReadBool("PreserveReadOnly", GetPreserveReadOnly())); SetPreserveTime(Storage->ReadBool("PreserveTime", GetPreserveTime())); SetPreserveTimeDirs(Storage->ReadBool("PreserveTimeDirs", GetPreserveTimeDirs())); SetPreserveRights(Storage->ReadBool("PreserveRights", GetPreserveRights())); SetIgnorePermErrors(Storage->ReadBool("IgnorePermErrors", GetIgnorePermErrors())); FRights.SetText(Storage->ReadString("Text", GetRights().GetText())); SetTransferMode(static_cast<TTransferMode>(Storage->ReadInteger("TransferMode", GetTransferMode()))); SetResumeSupport(static_cast<TResumeSupport>(Storage->ReadInteger("ResumeSupport", GetResumeSupport()))); SetResumeThreshold(Storage->ReadInt64("ResumeThreshold", GetResumeThreshold())); SetInvalidCharsReplacement(static_cast<wchar_t>(Storage->ReadInteger("ReplaceInvalidChars", static_cast<int>(GetInvalidCharsReplacement())))); SetLocalInvalidChars(Storage->ReadString("LocalInvalidChars", GetLocalInvalidChars())); SetCalculateSize(Storage->ReadBool("CalculateSize", GetCalculateSize())); if (Storage->ValueExists("IncludeFileMask")) { GetIncludeFileMask().SetMasks(Storage->ReadString("IncludeFileMask", GetIncludeFileMask().GetMasks())); } else if (Storage->ValueExists("ExcludeFileMask")) { UnicodeString ExcludeFileMask = Storage->ReadString("ExcludeFileMask", UnicodeString()); if (!ExcludeFileMask.IsEmpty()) { bool NegativeExclude = Storage->ReadBool("NegativeExclude", false); if (NegativeExclude) { GetIncludeFileMask().SetMasks(ExcludeFileMask); } // convert at least simple cases to new format else if (ExcludeFileMask.Pos(INCLUDE_EXCLUDE_FILE_MASKS_DELIMITER) == 0) { GetIncludeFileMask().SetMasks(UnicodeString(INCLUDE_EXCLUDE_FILE_MASKS_DELIMITER) + ExcludeFileMask); } } } SetTransferSkipList(nullptr); SetTransferResumeFile(L""); SetClearArchive(Storage->ReadBool("ClearArchive", GetClearArchive())); SetRemoveCtrlZ(Storage->ReadBool("RemoveCtrlZ", GetRemoveCtrlZ())); SetRemoveBOM(Storage->ReadBool("RemoveBOM", GetRemoveBOM())); SetCPSLimit(Storage->ReadInteger("CPSLimit", GetCPSLimit())); SetNewerOnly(Storage->ReadBool("NewerOnly", GetNewerOnly())); }
void PrintFile(char *way_to_file, char *name_of_file, int catalog_counter, int file_counter) { struct stat stats_of_file; char rights[11]; printf("\n==> Found file %s in %s\n\n", name_of_file, way_to_file); printf("Total catalogs looked through: %d\n", catalog_counter); printf("Total files looked through: %d\n\n", file_counter); stat(way_to_file, &stats_of_file); //print rights in (char *) mode GetRights(stats_of_file.st_mode, rights); printf("%s %d %s", name_of_file, stats_of_file.st_size, rights); printf(" %.12s %d\n", 4 + ctime(&(stats_of_file.st_ctime)), stats_of_file.st_ino); }
void TCopyParamType::DoGetInfoStr( const UnicodeString & Separator, intptr_t Options, UnicodeString & Result, bool & SomeAttrIncluded, const UnicodeString & Link, UnicodeString & ScriptArgs, bool & NoScriptArgs, /*TAssemblyLanguage Language, UnicodeString & AssemblyCode,*/ bool & NoCodeProperties) const { TCopyParamType Defaults; bool SomeAttrExcluded = false; NoScriptArgs = false; NoCodeProperties = false; SomeAttrIncluded = false; #define ADD(STR, EXCEPT) \ if (FLAGCLEAR(Options, EXCEPT)) \ { \ AddToList(Result, (STR), Separator); \ SomeAttrIncluded = true; \ } \ else \ { \ SomeAttrExcluded = true; \ } bool AsciiFileMaskDiffers = (GetTransferMode() == tmAutomatic) && !(GetAsciiFileMask() == Defaults.GetAsciiFileMask()); bool TransferModeDiffers = ((GetTransferMode() != Defaults.GetTransferMode()) || AsciiFileMaskDiffers); if (FLAGCLEAR(Options, cpaIncludeMaskOnly | cpaNoTransferMode)) { // Adding Transfer type unconditionally bool FormatMask; int Ident; switch (GetTransferMode()) { case tmBinary: FormatMask = false; Ident = 2; break; case tmAscii: FormatMask = false; Ident = 3; break; case tmAutomatic: default: FormatMask = !(GetAsciiFileMask() == Defaults.GetAsciiFileMask()); Ident = FormatMask ? 4 : 5; break; } UnicodeString S = FORMAT(LoadStrPart(COPY_INFO_TRANSFER_TYPE2, 1).c_str(), LoadStrPart(COPY_INFO_TRANSFER_TYPE2, Ident).c_str()); if (FormatMask) { S = FORMAT(S.c_str(), GetAsciiFileMask().GetMasks().c_str()); } AddToList(Result, S, Separator); if (TransferModeDiffers) { ADD("", cpaIncludeMaskOnly | cpaNoTransferMode); /*ScriptArgs += RtfSwitchValue(TRANSFER_SWITCH, Link, TransferModeNames[TransferMode]); const wchar_t * TransferModeMembers[] = { L"Binary", L"Ascii", L"Automatic" }; AssemblyCode += AssemblyProperty( Language, TransferOptionsClassName, L"TransferMode", L"TransferMode", TransferModeMembers[TransferMode], false); if (AsciiFileMaskDiffers) { NoScriptArgs = true; NoCodeProperties = true; }*/ } } else { if (TransferModeDiffers) { SomeAttrExcluded = true; NoScriptArgs = true; NoCodeProperties = true; } } if (GetFileNameCase() != Defaults.GetFileNameCase()) { ADD(FORMAT(LoadStrPart(COPY_INFO_FILENAME, 1).c_str(), LoadStrPart(COPY_INFO_FILENAME, GetFileNameCase() + 2).c_str()), cpaIncludeMaskOnly); NoScriptArgs = true; NoCodeProperties = true; } if ((GetInvalidCharsReplacement() == NoReplacement) != (Defaults.GetInvalidCharsReplacement() == NoReplacement)) { DebugAssert(GetInvalidCharsReplacement() == NoReplacement); if (GetInvalidCharsReplacement() == NoReplacement) { ADD(LoadStr(COPY_INFO_DONT_REPLACE_INV_CHARS).c_str(), cpaIncludeMaskOnly); } NoScriptArgs = true; NoCodeProperties = true; } if ((GetPreserveRights() != Defaults.GetPreserveRights()) || (GetPreserveRights() && ((GetRights() != Defaults.GetRights()) || (GetAddXToDirectories() != Defaults.GetAddXToDirectories())))) { const int Except = cpaIncludeMaskOnly | cpaNoRights; if (DebugAlwaysTrue(GetPreserveRights())) { UnicodeString RightsStr = GetRights().GetText(); if (GetAddXToDirectories()) { RightsStr += L", " + LoadStr(COPY_INFO_ADD_X_TO_DIRS); } ADD(FORMAT(LoadStr(COPY_INFO_PERMISSIONS).c_str(), RightsStr.c_str()), Except); if (FLAGCLEAR(Options, Except)) { // ScriptArgs += RtfSwitchValue(PERMISSIONS_SWITCH, Link, Rights.Octal); // const UnicodeString FilePermissionsClassName = L"FilePermissions"; // const bool Inline = true; // UnicodeString FilePermissions = // AssemblyNewClassInstanceStart(Language, FilePermissionsClassName, Inline) + // AssemblyProperty(Language, FilePermissionsClassName, L"Octal", Rights.Octal, Inline) + // AssemblyNewClassInstanceEnd(Language, Inline); // AssemblyCode += AssemblyPropertyRaw(Language, TransferOptionsClassName, L"FilePermissions", FilePermissions, false); } } if ((GetAddXToDirectories() != Defaults.GetAddXToDirectories()) && FLAGCLEAR(Options, Except)) { NoScriptArgs = true; NoCodeProperties = true; } } bool APreserveTimeDirs = GetPreserveTime() && GetPreserveTimeDirs(); if ((GetPreserveTime() != Defaults.GetPreserveTime()) || (APreserveTimeDirs != Defaults.GetPreserveTimeDirs())) { bool AddPreserveTime = false; UnicodeString Str = LoadStr(GetPreserveTime() ? COPY_INFO_TIMESTAMP : COPY_INFO_DONT_PRESERVE_TIME); const int ExceptDirs = cpaNoPreserveTimeDirs; if (APreserveTimeDirs != Defaults.GetPreserveTimeDirs()) { if (DebugAlwaysTrue(GetPreserveTimeDirs())) { if (FLAGCLEAR(Options, ExceptDirs)) { Str = FMTLOAD(COPY_INFO_PRESERVE_TIME_DIRS, (Str)); AddPreserveTime = true; } } ADD("", ExceptDirs); } const int Except = cpaIncludeMaskOnly | cpaNoPreserveTime; if (GetPreserveTime() != Defaults.GetPreserveTime()) { if (FLAGCLEAR(Options, Except)) { AddPreserveTime = true; } ADD(L"", Except); } if (AddPreserveTime) { AddToList(Result, Str, Separator); } if (FLAGCLEAR(Options, Except)) { if (GetPreserveTime()) { if (GetPreserveTimeDirs() && FLAGCLEAR(Options, ExceptDirs)) { //ScriptArgs += RtfSwitchValue(PRESERVETIME_SWITCH, Link, PRESERVETIMEDIRS_SWITCH_VALUE); NoCodeProperties = true; } else { DebugFail(); // should never get here //ScriptArgs += RtfSwitch(PRESERVETIME_SWITCH, Link); } } else { // ScriptArgs += RtfSwitch(NOPRESERVETIME_SWITCH, Link); // AssemblyCode += AssemblyProperty(Language, TransferOptionsClassName, L"PreserveTimestamp", false, false); } } } if ((GetPreserveRights() || GetPreserveTime()) && (GetIgnorePermErrors() != Defaults.GetIgnorePermErrors())) { if (DebugAlwaysTrue(GetIgnorePermErrors())) { const int Except = cpaIncludeMaskOnly | cpaNoIgnorePermErrors; ADD(LoadStr(COPY_INFO_IGNORE_PERM_ERRORS), Except); if (FLAGCLEAR(Options, Except)) { NoScriptArgs = true; NoCodeProperties = true; } } } if (GetPreserveReadOnly() != Defaults.GetPreserveReadOnly()) { if (DebugAlwaysTrue(GetPreserveReadOnly())) { const int Except = cpaIncludeMaskOnly | cpaNoPreserveReadOnly; ADD(LoadStr(COPY_INFO_PRESERVE_READONLY), Except); if (FLAGCLEAR(Options, Except)) { NoScriptArgs = true; NoCodeProperties = true; } } } if (GetCalculateSize() != Defaults.GetCalculateSize()) { if (DebugAlwaysTrue(!GetCalculateSize())) { ADD(LoadStr(COPY_INFO_DONT_CALCULATE_SIZE), cpaIncludeMaskOnly); // Always false in scripting, in assembly controlled by use of FileTransferProgress } } if (GetClearArchive() != Defaults.GetClearArchive()) { if (DebugAlwaysTrue(GetClearArchive())) { const int Except = cpaIncludeMaskOnly | cpaNoClearArchive; ADD(LoadStr(COPY_INFO_CLEAR_ARCHIVE), Except); if (FLAGCLEAR(Options, Except)) { NoScriptArgs = true; NoCodeProperties = true; } } } if ((GetTransferMode() == tmAscii) || (GetTransferMode() == tmAutomatic)) { if (GetRemoveBOM() != Defaults.GetRemoveBOM()) { if (DebugAlwaysTrue(GetRemoveBOM())) { const int Except = cpaIncludeMaskOnly | cpaNoRemoveBOM | cpaNoTransferMode; ADD(LoadStr(COPY_INFO_REMOVE_BOM), Except); if (FLAGCLEAR(Options, Except)) { NoScriptArgs = true; NoCodeProperties = true; } } } if (GetRemoveCtrlZ() != Defaults.GetRemoveCtrlZ()) { if (DebugAlwaysTrue(GetRemoveCtrlZ())) { const int Except = cpaIncludeMaskOnly | cpaNoRemoveCtrlZ | cpaNoTransferMode; ADD(LoadStr(COPY_INFO_REMOVE_CTRLZ),Except); if (FLAGCLEAR(Options, Except)) { NoScriptArgs = true; NoCodeProperties = true; } } } } if (!(GetIncludeFileMask() == Defaults.GetIncludeFileMask())) { ADD(FORMAT(LoadStr(COPY_INFO_FILE_MASK).c_str(), GetIncludeFileMask().GetMasks().c_str()), cpaNoIncludeMask); // ScriptArgs += RtfSwitch(FILEMASK_SWITCH, Link, IncludeFileMask.Masks); // AssemblyCode += AssemblyProperty(Language, TransferOptionsClassName, L"FileMask", IncludeFileMask.Masks, false); } DebugAssert(FTransferSkipList.get() == nullptr); DebugAssert(FTransferResumeFile.IsEmpty()); if (GetCPSLimit() > 0) { intptr_t LimitKB = intptr_t(GetCPSLimit() / 1024); ADD(FMTLOAD(COPY_INFO_CPS_LIMIT2, (LimitKB)), cpaIncludeMaskOnly); // ScriptArgs += RtfSwitch(SPEED_SWITCH, Link, LimitKB); // AssemblyCode += AssemblyProperty(Language, TransferOptionsClassName, L"Speed", LimitKB, false); } if (GetNewerOnly() != Defaults.GetNewerOnly()) { if (DebugAlwaysTrue(GetNewerOnly())) { const int Except = cpaIncludeMaskOnly | cpaNoNewerOnly; ADD(StripHotkey(LoadStr(COPY_PARAM_NEWER_ONLY)), Except); if (FLAGCLEAR(Options, Except)) { // ScriptArgs += RtfSwitch(NEWERONLY_SWICH, Link); NoCodeProperties = true; } } } bool ResumeThresholdDiffers = ((GetResumeSupport() == rsSmart) && (GetResumeThreshold() != Defaults.GetResumeThreshold())); if (((GetResumeSupport() != Defaults.GetResumeSupport()) || ResumeThresholdDiffers) && (GetTransferMode() != tmAscii) && FLAGCLEAR(Options, cpaNoResumeSupport)) { UnicodeString Value; UnicodeString CodeState; intptr_t ResumeThresholdKB = (GetResumeThreshold() / 1024); switch (GetResumeSupport()) { case rsOff: Value = ToggleNames[ToggleOff]; CodeState = L"Off"; break; case rsOn: Value = ToggleNames[ToggleOn]; CodeState = L"On"; break; case rsSmart: Value = IntToStr(ResumeThresholdKB); break; } // ScriptArgs += RtfSwitchValue(RESUMESUPPORT_SWITCH, Link, Value); const UnicodeString ResumeSupportClassName = L"TransferResumeSupport"; // const bool Inline = true; // UnicodeString ResumeSupportCode = // AssemblyNewClassInstanceStart(Language, ResumeSupportClassName, Inline); if (GetResumeSupport() == rsSmart) { // ResumeSupportCode += AssemblyProperty(Language, ResumeSupportClassName, L"Threshold", ResumeThresholdKB, Inline); } else { // ResumeSupportCode += AssemblyProperty(Language, ResumeSupportClassName, L"State", L"TransferResumeSupportState", CodeState, Inline); } // ResumeSupportCode += AssemblyNewClassInstanceEnd(Language, Inline); // AssemblyCode += AssemblyPropertyRaw(Language, TransferOptionsClassName, L"ResumeSupport", ResumeSupportCode, false); } if (SomeAttrExcluded) { Result += (Result.IsEmpty() ? UnicodeString() : Separator) + FORMAT(LoadStrPart(COPY_INFO_NOT_USABLE, 1).c_str(), LoadStrPart(COPY_INFO_NOT_USABLE, (SomeAttrIncluded ? 2 : 3)).c_str()); } else if (Result.IsEmpty()) { Result = LoadStr(COPY_INFO_DEFAULT); } #undef ADD }
//////////////////////////////////////////////////////////////////////////// // Function: netset //////////////////////////////////////////////////////////////////////////// int ftpset(char **postvars, int form_method) { FILE *fffd,*fp,*alarmconf; unsigned long ulTemp; int iTemp, i, size; unsigned short bx1=0xffff,bx2=0xffff,bx3=0xffff,by1=0xffff,by2=0xffff,by3=0xffff; unsigned short ex1=0xffff,ex2=0xffff,ex3=0xffff,ey1=0xffff,ey2=0xffff,ey3=0xffff; char pcTmp[24]; unsigned char ucbuf[sizeof(ftp_conf)]; // HTML header, print it here printf("Content-type: text/html\n\n"); printf("\n\n\n\n"); printf("\n\n"); printf("<html><head></head>"); fflush(stdout); usleep(1000); Getlanguage_type(); ////language initializtion ///////////////////////////// get_web_language("language.txt","#ftpset.cgi"); cyber_language_type=CONF_LANGUAGE->language_type; // If we got post, write it into flash if(form_method == POST) { // kill alarm, ffserver and ffmpeg here if( system("nohup killall -15 alarm > /dev/null") < 0 ) { perror("ftpset:"); } printf("<body><center><BR>"); // Read and preserve content from flash to buffer GetConfValues(); for (i=0; postvars[i]; i+= 2) { #if DEBUG printf("DEBUG: [%s] = [%s]<br>", postvars[i], postvars[i+1]); #endif // Parse for FTPPASV1 if(!strcmp(postvars[i], "FTPPASV1")) { if(!strcmp(postvars[i+1], "ON")) CONF_FTP->PasssiveMode1 = 1; else if(!strcmp(postvars[i+1], "OFF")) CONF_FTP->PasssiveMode1 = 0; else CONF_FTP->PasssiveMode1 = 0; // default } // Parse for FTPSERVER1 if(!strcmp(postvars[i], "FTPSERVER1")) { memcpy(CONF_FTP->Server1,postvars[i+1],30); } // Parse for FTPPORT1 if(!strcmp(postvars[i], "FTPPORT1")) { ulTemp=atoi(postvars[i+1]); CONF_FTP->ServerPort1=ulTemp; } // Parse for FTPNAME1 if(!strcmp(postvars[i], "FTPNAME1")) { memcpy(CONF_FTP->Account1,postvars[i+1],20); } // Parse for FTPPASSWD1 if(!strcmp(postvars[i], "FTPPASSWD1")) { memcpy(CONF_FTP->Passwd1,postvars[i+1],20); } // Parse for FTPNAME1 if(!strcmp(postvars[i], "FTPFOLDER1")) { memcpy(CONF_FTP->Folder1,postvars[i+1],20); } } // end of parse loop #if DEBUG // Debug the value in struct printf("Write result:<br>\n"); printf("%s<br>\n", CONF_FTP->Server1); printf("%d<br>\n", CONF_FTP->ServerPort1); printf("%s<br>\n", CONF_FTP->Account1); printf("%s<br>\n", CONF_FTP->Passwd1); printf("%s<br>\n", CONF_FTP->Folder1); printf("%d<br>\n", CONF_FTP->PasssiveMode1); #endif // Copy strcut into buf memcpy(ucbuf, CONF_FTP, sizeof(ftp_conf)); // Reset flash buffer iTemp = FTPOFFSET; for(i=iTemp; i<(sizeof(ftp_conf)+iTemp); i++) pcContentBuf[i] = ucbuf[i-iTemp]; #if DEBUG for(i=0; i<READBUF; i++) { printf("%d ", pcContentBuf[i]); } printf("<br>"); #endif FlashWriteConfig(); #if 0 { //re-create alarm.conf unlink(ALARMCONF); if( (alarmconf = fopen(ALARMCONF, "w")) < 0 ) { fprintf(stdout, "Open file %s failed : %d", errno, ALARMCONF); return 0; } if(CONF_MOTION_APP->FtpAlarm==1) { fprintf(alarmconf,"FTPALARM = YES\n"); if(CONF_FTP->Server1[0]>0 && CONF_FTP->Server1[0]!=0xff) fprintf(alarmconf,"FTPSERVER1 = %s\n",CONF_FTP->Server1); if(CONF_FTP->ServerPort1>0 && CONF_FTP->ServerPort1!=0xffff) fprintf(alarmconf,"FTPPORT1 = %d\n",CONF_FTP->ServerPort1); if(CONF_FTP->Account1[0]>0 && CONF_FTP->Account1[0]!=0xff) fprintf(alarmconf,"FTPNAME1 = %s\n",CONF_FTP->Account1); if(CONF_FTP->Passwd1[0]>0 && CONF_FTP->Passwd1[0]!=0xff) fprintf(alarmconf,"FTPPASSWD1 = %s\n",CONF_FTP->Passwd1); if(CONF_FTP->Folder1[0]>0 && CONF_FTP->Folder1[0]!=0xff) fprintf(alarmconf,"FTPFOLDER1 = %s\n",CONF_FTP->Folder1); if(CONF_FTP->PasssiveMode1==1) fprintf(alarmconf,"FTPPASV1 = ON\n"); else fprintf(alarmconf,"FTPPASV1 = OFF\n"); } if(CONF_MOTION_APP->MailAlarm==1) { fprintf(alarmconf,"MAILALARM = YES\n"); if(CONF_SMTP->Server1[0]>0 && CONF_SMTP->Server1[0]!=0xff) fprintf(alarmconf,"SMTPSERVER1 = %s\n",CONF_SMTP->Server1); if(CONF_SMTP->Recipient1[0]>0 && CONF_SMTP->Recipient1[0]!=0xff) fprintf(alarmconf,"SMTPREC1 = %s\n",CONF_SMTP->Recipient1); if(CONF_SMTP->Account1[0]>0 && CONF_SMTP->Account1[0]!=0xff) fprintf(alarmconf,"SMTPNAME1 = %s\n",CONF_SMTP->Account1); if(CONF_SMTP->Passwd1[0]>0 && CONF_SMTP->Passwd1[0]!=0xff) fprintf(alarmconf,"SMTPPASSWD1 = %s\n",CONF_SMTP->Passwd1); if(CONF_SMTP->Auth_Method1==1) fprintf(alarmconf,"AUTHMETHOD1 = PLAIN\n"); if(CONF_SMTP->Auth_Method1==2) fprintf(alarmconf,"AUTHMETHOD1 = LOGIN\n"); } if(CONF_MOTION_APP->FtpAlarm==1 || CONF_MOTION_APP->MailAlarm==1) { if(CONF_MOTION_APP->FileBaseName[0]>0 && CONF_MOTION_APP->FileBaseName[0]!=0xff) fprintf(alarmconf,"FILEBASENAME = %s\n",CONF_MOTION_APP->FileBaseName); if(CONF_MOTION_APP->TimeSuffix==1) fprintf(alarmconf,"TIMESUFFIX = ON\n"); else fprintf(alarmconf,"TIMESUFFIX = OFF\n"); } fflush(alarmconf); close(alarmconf); // bring up alarm and get its pid // Its pid will be written in "/etc/alarm.pid" when alarm is running //Modify By Ken.Hsieh if( system("alarm > /dev/null&") < 0 ) if( system("nohup alarm > /dev/null&") < 0 ) { perror("ftpset:"); } sleep(1); unlink(MOTIONCONFIG); if( (fp=fopen(ALARMPID, "r")) == NULL ) { if( (fp=fopen(ALARMPID, "r")) == NULL ) { system("nohup alarm > /dev/null&"); if( (fp=fopen(ALARMPID, "r")) == NULL ) { printf("read pid error\n"); } } } fgets(pcTmp,20,fp); close(fp); // re-create m.cfg if( (fffd=fopen(MOTIONCONFIG, "w")) == NULL ) { perror("ftpset:"); return 0; } fprintf(fffd, "pid %s\n",pcTmp); // write alarm's pid // detect interval fprintf(fffd, "md_interval %d\n",CONF_MOTION->Interval); //window1 coordinate if(CONF_MOTION->StartX1!=0xffff && CONF_MOTION->StartY1!=0xffff && CONF_MOTION->StopX1!=0xffff && CONF_MOTION->StopY1!=0xffff) { if(CONF_MOTION->StartX1!=0 && CONF_MOTION->StartY1!=0 && CONF_MOTION->StopX1!=0 && CONF_MOTION->StopY1!=0) { fprintf(fffd, "x0_LU %d\n",(CONF_MOTION->StartX1-1)/16); fprintf(fffd, "y0_LU %d\n",(CONF_MOTION->StartY1-1)/16); if(CONF_MOTION->StopX1%16) fprintf(fffd, "x0_RD %d\n",((CONF_MOTION->StopX1-1)/16)+1); else fprintf(fffd, "x0_RD %d\n",(CONF_MOTION->StopX1-1)/16); if(CONF_MOTION->StopY1%16) fprintf(fffd, "y0_RD %d\n",((CONF_MOTION->StopY1-1)/16)+1); else fprintf(fffd, "y0_RD %d\n",((CONF_MOTION->StopY1-1)/16)); } } //window2 coordinate if(CONF_MOTION->StartX2!=0xffff && CONF_MOTION->StartY2!=0xffff && CONF_MOTION->StopX2!=0xffff && CONF_MOTION->StopY2!=0xffff) { if(CONF_MOTION->StartX2!=0 && CONF_MOTION->StartY2!=0 && CONF_MOTION->StopX2!=0 && CONF_MOTION->StopY2!=0) { fprintf(fffd, "x1_LU %d\n",(CONF_MOTION->StartX2-1)/16); fprintf(fffd, "y1_LU %d\n",(CONF_MOTION->StartY2-1)/16); if(CONF_MOTION->StopX2%16) fprintf(fffd, "x1_RD %d\n",((CONF_MOTION->StopX2-1)/16)+1); else fprintf(fffd, "x1_RD %d\n",((CONF_MOTION->StopX2-1)/16)); if(CONF_MOTION->StopY2%16) fprintf(fffd, "y1_RD %d\n",((CONF_MOTION->StopY2-1)/16)+1); else fprintf(fffd, "y1_RD %d\n",((CONF_MOTION->StopY2-1)/16)); } } //window3 coordinate if(CONF_MOTION->StartX3!=0xffff && CONF_MOTION->StartY3!=0xffff && CONF_MOTION->StopX3!=0xffff && CONF_MOTION->StopY3!=0xffff) { if(CONF_MOTION->StartX3!=0 && CONF_MOTION->StartY3!=0 && CONF_MOTION->StopX3!=0 && CONF_MOTION->StopY3!=0) { fprintf(fffd, "x2_LU %d\n",(CONF_MOTION->StartX3-1)/16); fprintf(fffd, "y2_LU %d\n",(CONF_MOTION->StartY3-1)/16); if(CONF_MOTION->StopX3%16) fprintf(fffd, "x2_RD %d\n",((CONF_MOTION->StopX3-1)/16)+1); else fprintf(fffd, "x2_RD %d\n",((CONF_MOTION->StopX3-1)/16)); if(CONF_MOTION->StopY3%16) fprintf(fffd, "y2_RD %d\n",((CONF_MOTION->StopY3-1)/16)+1); else fprintf(fffd, "y2_RD %d\n",((CONF_MOTION->StopY3-1)/16)); } } //window1 detect parameters if(CONF_MOTION->StartX1!=0xffff && CONF_MOTION->StartY1!=0xffff && CONF_MOTION->StopX1!=0xffff && CONF_MOTION->StopY1!=0xffff) { if(CONF_MOTION->StartX1!=0 && CONF_MOTION->StartY1!=0 && CONF_MOTION->StopX1!=0 && CONF_MOTION->StopY1!=0) { //motion detection method 1 sensitivity fprintf(fffd, "mv_th0 %d\n",CONF_MOTION->Sensitivity1); //motion detection method 2 sensitivity, 512-> disabled fprintf(fffd, "sad_th0 512\n"); //motion detection method 3 sensitivity, 512-> disabled //fprintf(fffd, "dev_th0 %d\n",CONF_MOTION->Sensitivity1); fprintf(fffd, "dev_th0 512\n"); // motion detection threshold fprintf(fffd, "alarm_idx0 %d\n",CONF_MOTION->Threshold1); } } //window2 detect parameters if(CONF_MOTION->StartX2!=0xffff && CONF_MOTION->StartY2!=0xffff && CONF_MOTION->StopX2!=0xffff && CONF_MOTION->StopY2!=0xffff) { if(CONF_MOTION->StartX2!=0 && CONF_MOTION->StartY2!=0 && CONF_MOTION->StopX2!=0 && CONF_MOTION->StopY2!=0) { //motion detection method 1 sensitivity fprintf(fffd, "mv_th1 %d\n",CONF_MOTION->Sensitivity2); //motion detection method 2 sensitivity, 512-> disabled fprintf(fffd, "sad_th1 512\n"); //motion detection method 3 sensitivity, 512-> disabled fprintf(fffd, "dev_th1 512\n"); // motion detection threshold fprintf(fffd, "alarm_idx1 %d\n",CONF_MOTION->Threshold2); } } //window3 detect parameters if(CONF_MOTION->StartX3!=0xffff && CONF_MOTION->StartY3!=0xffff && CONF_MOTION->StopX3!=0xffff && CONF_MOTION->StopY3!=0xffff) { if(CONF_MOTION->StartX3!=0 && CONF_MOTION->StartY3!=0 && CONF_MOTION->StopX3!=0 && CONF_MOTION->StopY3!=0) { //motion detection method 1 sensitivity fprintf(fffd, "mv_th2 %d\n",CONF_MOTION->Sensitivity3); //motion detection method 2 sensitivity, 512-> disabled fprintf(fffd, "sad_th2 512\n"); //motion detection method 3 sensitivity, 512-> disabled fprintf(fffd, "dev_th2 512\n"); // motion detection threshold fprintf(fffd, "alarm_idx2 %d\n",CONF_MOTION->Threshold3); } } // snapshot filename fprintf(fffd, "filename /%s\n","temp"); fprintf(fffd, "rotate %d\n",CONF_MOTION->Rotate); fflush(fffd); close(fffd); // re-start ffserver and ffmpeg //if( system("/ffmpeg/ffserver -f /ffmpeg/ff.cfg > /dev/null &") < 0 ) if( system("nohup /ffmpeg/ffserver -f /ffmpeg/ff.cfg > /dev/null &") < 0 ) { perror("ftpset:"); } sleep(2); if(CONF_MOTION->Detection==1) { //sprintf(pcTmp,"/ffmpeg/ffmpeg -ndisplay -motion %s http://localhost:%d/feed1.ffm > /dev/null &",MOTIONCONFIG, CONF_VIDEO->ServerPort); sprintf(pcTmp,"nohup /ffmpeg/ffmpeg -ndisplay -motion %s http://localhost:%d/feed1.ffm > /dev/null &",MOTIONCONFIG, CONF_VIDEO->ServerPort); } else //sprintf(pcTmp,"/ffmpeg/ffmpeg -ndisplay http://localhost:%d/feed1.ffm > /dev/null &",CONF_VIDEO->ServerPort); sprintf(pcTmp,"nohup /ffmpeg/ffmpeg -ndisplay http://localhost:%d/feed1.ffm > /dev/null &",CONF_VIDEO->ServerPort); //printf(pcTmp); if( system(pcTmp) < 0 ) { perror("ftpset:"); } }// end of dirty restart process procedure #endif printf("Configuration succeeded<br><br>"); //printf("<font color=red>To make the change active, please reboot the device.<br></font>"); printf("</center></body></html>"); free(CONF_FTP); printf("<meta http-equiv=\"refresh\" content=\"1;url=ftpset.cgi\">"); // exit here when write return 0; } // end of "if we got post" //////////////////////////////////////////// // Start CGI, Get configuration value here //////////////////////////////////////////// GetConfValues(); printf(" <html><head>\n"); printf(" <style type=\"text/css\">\n"); printf("<!--\n"); printf(".STYLE1 { font-family: Arial, Helvetica, sans-serif; font-weight: bold; font-size: 12px;}\n"); printf(".STYLE4 { font-family: Arial, Helvetica, sans-serif; font-size: 12px;}\n"); printf("-->\n"); printf("</style>\n"); printf("</head>\n"); printf("<center><BR>\n"); printf("<FORM name=ftpset ACTION=\"/cgi-bin/ftpset.cgi\" METHOD=POST>\n"); printf("<table border=0 cellpadding=\"0\" cellspacing=\"0\" width=\"80%\">\n"); *web_sentence='\0'; get_web_context("FTP Settings",web_sentence,cyber_language_type); printf(" <tr><td width=\"527\" height=\"30\" bgcolor=\"#999999\"><div align=\"center\" class=\"STYLE1\">%s</div></td></tr>\n",web_sentence); printf(" <tr><td height=\"20\" bgcolor=\"#CCCCCC\"> <span class=\"STYLE4\">FTP</span></td></tr>\n"); printf("<tr><td><table border=0>\n"); printf("<tr><td><td>\n"); //Check User if(GetRights()>0) { printf(" <script language=JavaScript>\n"); printf(" <!-- \n"); printf(" top.location.href=\"../index.html\";\n"); printf(" //--> \n"); printf(" </script> \n"); } // Server1 *web_sentence='\0'; get_web_context("FTP Server",web_sentence,cyber_language_type); if(CONF_FTP->Server1[0]>0 && CONF_FTP->Server1[0]!=0xff) { sprintf(pcTmp, "%s",CONF_FTP->Server1); printf(" <tr><td><span class=\"STYLE4\">%s</span></td><td><input type=text name=FTPSERVER1 size=30 maxlength=30 value=%s></td></tr>\n",web_sentence,pcTmp); } else printf("<tr><td><span class=\"STYLE4\">%s</span></td><td><input type=text name=FTPSERVER1 size=30 maxlength=30></td></tr>\n",web_sentence); // Port1 *web_sentence='\0'; get_web_context("FTP Port",web_sentence,cyber_language_type); if(CONF_FTP->ServerPort1>0 && CONF_FTP->ServerPort1!=0xffff) { sprintf(pcTmp, "%d",CONF_FTP->ServerPort1); printf(" <tr><td><span class=\"STYLE4\">%s</span></td><td><input type=text name=FTPPORT1 size=15 maxlength=15 value=%s></td></tr>\n",web_sentence,pcTmp); } else printf("<tr><td><span class=\"STYLE4\">%s</span></td><td><input type=text name=FTPPORT1 size=15 maxlength=15></td></tr>\n",web_sentence); //Account1 *web_sentence='\0'; get_web_context("Username",web_sentence,cyber_language_type); if(CONF_FTP->Account1[0]>0 && CONF_FTP->Account1[0]!=0xff) { sprintf(pcTmp, "%s",CONF_FTP->Account1); printf(" <tr><td><span class=\"STYLE4\">%s</span></td><td><input type=text name=FTPNAME1 size=15 maxlength=15 value=%s></td></tr>\n",web_sentence,pcTmp); } else printf("<tr><td><span class=\"STYLE4\">%s</span></td><td><input type=text name=FTPNAME1 size=15 maxlength=15></td></tr>\n",web_sentence); //Passwd1 *web_sentence='\0'; get_web_context("Password",web_sentence,cyber_language_type); if(CONF_FTP->Passwd1[0]>0 && CONF_FTP->Passwd1[0]!=0xff) { sprintf(pcTmp, "%s",CONF_FTP->Passwd1); printf(" <tr><td><span class=\"STYLE4\">%s</span></td><td><input type=password name=FTPPASSWD1 size=15 maxlength=15 value=%s></td></tr>\n",web_sentence,pcTmp); } else printf("<tr><td><span class=\"STYLE4\">%s</span></td><td><input type=password name=FTPPASSWD1 size=15 maxlength=15></td></tr>\n",web_sentence); //Account1 *web_sentence='\0'; get_web_context("Remote Folder",web_sentence,cyber_language_type); if(CONF_FTP->Folder1[0]>0 && CONF_FTP->Folder1[0]!=0xff) { sprintf(pcTmp, "%s",CONF_FTP->Folder1); printf(" <tr><td><span class=\"STYLE4\">%s</span></td><td><input type=text name=FTPFOLDER1 size=15 maxlength=15 value=%s></td></tr>\n",web_sentence,pcTmp); } else printf("<tr><td><span class=\"STYLE4\">%s</span></td><td><input type=text name=FTPFOLDER1 size=15 maxlength=15></td></tr>\n",web_sentence); // WDHCP *web_sentence='\0'; get_web_context("Passive Mode",web_sentence,cyber_language_type); printf("<tr><td><span class=\"STYLE4\">%s</span><td>\n",web_sentence); printf("<select name=FTPPASV1>\n"); if(CONF_FTP->PasssiveMode1==0) { printf(" <option value=\"OFF\" selected>OFF\n"); printf(" <option value=\"ON\">ON\n"); } else { printf(" <option value=\"OFF\">OFF\n"); printf(" <option value=\"ON\" selected>ON\n"); } printf(" </select></td></tr>\n"); printf(" </table><tr><td><hr></td></tr>\n"); *web_sentence='\0'; get_web_context("Apply",web_sentence,cyber_language_type); printf(" <tr><td><input type=submit class=button value=%s></td></tr>\n",web_sentence); printf(" </form></font></center></html>\n"); free(CONF_FTP); free(CONF_SYS); return 0; }
//////////////////////////////////////////////////////////////////////////// // Function: ntpset //////////////////////////////////////////////////////////////////////////// int systemset(char **postvars, int form_method) { unsigned long ulTemp; unsigned char ucbuf[sizeof(ntp_conf)]; int iTemp, i, size, iMethod,flag; char pcTmp[24]; char mdate[16]; char mtime[16]; char pcdate[16]; char pctime[16]; // HTML header, print it here printf("Content-type: text/html\r\n"); printf("\r\n"); printf(" <html><head>\n"); printf(" <style type=\"text/css\">\n"); printf("<!--\n"); printf(".STYLE1 { font-family: Arial, Helvetica, sans-serif; font-weight: bold; font-size: 12px;}\n"); printf(".STYLE4 { font-family: Arial, Helvetica, sans-serif; font-size: 12px;}\n"); printf("-->\n"); printf("</style>\n"); printf("</head>\n"); fflush(stdout); usleep(1000); // If we got post, write it into flash if(form_method == POST) { printf("<body style=\"background: #000;\"><BR>"); //printf("Configuration parameters have been saved successfully<br><br>"); printf("<meta http-equiv=\"refresh\" content=\"1;url=systemset.cgi\">"); printf("</body></html>"); // exit here when write return 0; } // end of "if we got post" //////////////////////////////////////////// // Start CGI, Get configuration value here //////////////////////////////////////////// GetConfValues(); printf("<body style=\"background: #000;\">"); printf("<center>\n"); printf("<FORM name=systemset ACTION=\"/cgi-bin/systemset.cgi\" METHOD=POST>\n"); // Check User GetConfValues(); if(GetRights()>0) { printf(" <script language=JavaScript>\n"); printf(" <!-- \n"); printf(" top.location.href=\"../index.html\";\n"); printf(" //--> \n"); printf(" </script> \n"); } //////////////////reset.cgi printf("<center>\n"); printf("<table border=0 cellpadding=\"0\" cellspacing=\"0\" width=\"80%\">\n"); printf("<tr><td width=\"680\" height=\"255\" ><iframe border=0 frameborder=0 framespacing=0 height=\"255\" marginheight=0 marginwidth=0 name=list_products noResize scrolling=no src=\"reset.cgi\" width=\"680\" vspale=\"0\"></iframe></td></tr>\n"); printf(" </table>\n"); printf(" </center>\n"); //////////////////reboot printf("<center>\n"); printf("<table border=0 cellpadding=\"0\" cellspacing=\"0\" width=\"80%\">\n"); //printf("<tr><td width=\"680\" height=\"200\" ><iframe border=0 frameborder=0 framespacing=0 height=\"150\" marginheight=0 marginwidth=0 name=list_products noResize scrolling=no src=\"../reboot.htm\" width=\"680\" vspale=\"0\"></iframe></td></tr>\n"); printf("<tr><td width=\"680\" ><iframe border=0 frameborder=0 framespacing=0 height=\"200\" marginheight=0 marginwidth=0 name=list_products noResize scrolling=no src=\"../reboot.htm\" width=\"680\" vspale=\"0\"></iframe></td></tr>\n"); printf(" </table>\n"); printf(" </center></html>\n"); free(CONF_SYS); return 0; }