Solved

Search function not working

Posted on 2016-10-05
14
42 Views
Last Modified: 2016-10-21
The search function on the following page isn't working properly: http://www.ssuexed.com/search.php?year=2017&sem=0&ge=C3%2C+*ETH&id=0&cName=&cDept=&tLastName=

For example, if you select the option for GE Type as "C3, *ETH", you will obtain an output that includes "GE C3" as well.

I am attaching the code files - I am thinking that the problem must be in one of these files, i.e., search_subcats.php file, but I am not certain.

I would appreciate any help.
search.php
search_cache.php
search_subcats.php
0
Comment
Question by:geeta_m9
  • 6
  • 6
14 Comments
 
LVL 51

Expert Comment

by:Julian Hansen
Comment Utility
Where is the function showSearchTable defined (line 218 of search.php)

$catalog->showSearchTable($ge, $cName, $cDept, $tLastName);

Open in new window

0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
also, where is _cleanVar() function defined? does it include urldecode function
0
 

Author Comment

by:geeta_m9
Comment Utility
I don't know. I am sending you the rest of the files that I have.
course.php
programs.php
catalog.php
_catalog_defines.php
test.php
0
 
LVL 51

Expert Comment

by:Julian Hansen
Comment Utility
Nope does not appear to be in any of those.
0
 

Author Comment

by:geeta_m9
Comment Utility
Ok, I managed to find some more php files which were in an "includes" folder
_catalog_defines-1.php
_stdfunctions.php
0
 
LVL 51

Expert Comment

by:Julian Hansen
Comment Utility
Not there either.
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:geeta_m9
Comment Utility
0
 

Author Comment

by:geeta_m9
Comment Utility
I believe the function you are looking for is in catalog_container-1.php
0
 
LVL 51

Accepted Solution

by:
Julian Hansen earned 500 total points
Comment Utility
Bingo
This function produces two possible queries
If there is a tLastName
SELECT DISTINCT 
	c.id,
	s.dept,
	s.dept_code,
	c.course_title,
	c.active,
	s.year,
	s.sem,
	c.ge,
	c.course_type 
FROM
	courses AS c,
	sections AS s,
	teachers as t,
	tea_sec_rel as tsr 
WHERE 
	s.course_id_rel=c.id AND 
	s.year=2016 AND 
	s.sem=1 AND (
		c.active=1 OR 
		c.active=3 OR 
		c.active=4 OR 
		c.active=7) AND 
	course_title LIKE '%Name%' AND 
	s.dept='LAST' AND 
	s.dept_code='Dept' AND 
	c.ge LIKE 'C3, *ETH' AND 
	t.lname LIKE '%Smith%' AND 
	tsr.teacher_id=t.id AND 
	tsr.section_id=s.id 
ORDER BY 
	s.dept,
	s.dept_code

Open in new window

If there is not a tLastName
SELECT DISTINCT 
	c.id,
	s.dept,
	s.dept_code,
	c.course_title,
	c.active,
	s.year,
	s.sem,
	c.ge,
	c.course_type 
FROM 
	courses AS c, 
	sections AS s 
WHERE 
	s.course_id_rel=c.id AND 
	s.year=2016 AND 
	s.sem=1 AND (
		c.active=1 OR 
		c.active=3 OR 
		c.active=4 OR 
		c.active=7) AND 
	course_title LIKE '%Name%' AND 
	s.dept='LAST' AND 
	s.dept_code='Dept' AND 
	c.ge LIKE 'C3, *ETH' 
ORDER BY 
	s.dept,
	s.dept_code

Open in new window

Both queries appear to be incapable of producing results with GE C3 - which means we probably need to see the data.
If you can confirm the query by adding the following to the catalog_container-1.php
...
		if ($tLastName) { // or s.year LIKE ('$curYr'+1) // AND s.sem=$this->sem
			$couTea = "AND t.lname LIKE '%$tLastName%' AND tsr.teacher_id=t.id AND tsr.section_id=s.id";
// ADD THIS			
echo "
							SELECT DISTINCT c.id,s.dept,s.dept_code,c.course_title,c.active,s.year,s.sem,c.ge,c.course_type
							FROM courses AS c, sections AS s, teachers as t, tea_sec_rel as tsr
							WHERE s.course_id_rel=c.id AND $curYr $curSem $active $couName $couDept $psSearch $couGe $couTea
							ORDER BY s.dept,s.dept_code";

			$iRes = _SQLQuery("
							SELECT DISTINCT c.id,s.dept,s.dept_code,c.course_title,c.active,s.year,s.sem,c.ge,c.course_type
							FROM courses AS c, sections AS s, teachers as t, tea_sec_rel as tsr
							WHERE s.course_id_rel=c.id AND $curYr $curSem $active $couName $couDept $psSearch $couGe $couTea
							ORDER BY s.dept,s.dept_code");
		}
		else {
// AND THIS			
echo "
							SELECT DISTINCT c.id,s.dept,s.dept_code,c.course_title,c.active,s.year,s.sem,c.ge,c.course_type
							FROM courses AS c, sections AS s
							WHERE s.course_id_rel=c.id AND $curYr $curSem $active $couName $couDept $psSearch $couGe
							ORDER BY s.dept,s.dept_code";
			$iRes = _SQLQuery("
							SELECT DISTINCT c.id,s.dept,s.dept_code,c.course_title,c.active,s.year,s.sem,c.ge,c.course_type
							FROM courses AS c, sections AS s
							WHERE s.course_id_rel=c.id AND $curYr $curSem $active $couName $couDept $psSearch $couGe
							ORDER BY s.dept,s.dept_code");
		}    
...

Open in new window

And then post the query that is dumped from that.
0
 

Author Comment

by:geeta_m9
Comment Utility
Hi Julian,

I do not have a test server to add the code to the catalog_container-1 program file and run it. If I insert it into the program and upload it, it will be live.

I can, however, run SQL queries against the database and obtain the output. So, if you could give it to me in that format, that would be great.
0
 
LVL 51

Expert Comment

by:Julian Hansen
Comment Utility
I don't have anything to give you - I want to see what queries the code produces.
0
 

Author Comment

by:geeta_m9
Comment Utility
Sorry, I forgot to close this question. The problem has been resolved.

Thank you for your help.

Geeta
0
 
LVL 51

Expert Comment

by:Julian Hansen
Comment Utility
You are welcome.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now