Jump to content

Outputting result correctly


andytan91

Recommended Posts

Hello guys i am doing a search function whereby users can check whether a setting is Pass or Fail. After user press the search button, it will return the file which contain the settings the user wants. However i have encountered a problem, currently i am using if statement and && operator to search for file so if the file is missing a string whereby the preg_match function couldn't find it, it will not output the file if i check another setting. Hence i am interested on what other options can i use.

 

Also, Is it possible to use while loop? I tried for awhile and my browser just keeps loading and loading.

 

Thanks for the help!

 

 

 

 

Example: I want to check File 1 for Maximum Password Age settings but it does not contain Service Pack Requirement string...

 

 

 

 

 

 

 

 

if ((preg_match("/\bService Pack Requirement:(.*)./", $allFiles)) && (preg_match("/\bMaximum Password Age Requirement:(.*)./", $allFiles))
&& (preg_match("/\bMinimum Password Length:(.*)./", $allFiles)) && (preg_match("/\bAudit Account Logon Events:(.*)./", $allFiles))
{
echo "<a href=\"$file\" target=\"_blank\"> $file </a><br />";
}

Link to comment
Share on other sites

Sorry for not being clear..what i want to do is that if that particular string exist in that file, the search function will display the filename.

 

However, as i am using if statement and && operation, i have trouble displaying the filename because if that particular string exist and the others don't, it wont display the file. Ultimately, i want the search function to display the filename if it matches just one preg_match function regardless whether other preg_match function in the if statement can find the other string or not..

 

 

Example: User wants to find Service Pack string and Maximum Password Age string which contain "Pass". However, the text file does not contain Audit Account Logon Events" string. Hence, the third preg_match function will not display the file.

 

Sample text Below

Service Pack Requirement: Fail

Current Settings for Service Pack Requirement: Disabled

Maximum Password Age Requirement: Fail

Current Settings for Maximum Password Age Requirement: Enabled

Minimum Password Length: Pass

Current Settings for Minimum Password Length Requirement: Enabled

 

if ((preg_match("/\bService Pack Requirement:(.*)./", $allFiles)) && (preg_match("/\bMaximum Password Age Requirement:(.*)./", $allFiles))
&& (preg_match("/\bMinimum Password Length:(.*)./", $allFiles)) && (preg_match("/\bAudit Account Logon Events:(.*)./", $allFiles))
{
echo "<a href=\"$file\" target=\"_blank\"> $file </a><br />";
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.