Hi.
Thanks for your query.
Noted the history of dull pain in the upper right and left quadrants sometimes spreading to right side and back, particularly at 5 am and after certain foods such as spices and coffee. The is also a whole above anus which leaks pus and blood several hours after a bowel movement. 
This means you have two different problems. 
The first history is suggestive that you are suffering from acidity related problems like gastritis with may be an ulcer on the posterior wall that is giving 
referred pain to the back. 
This is serious and hence needs urgent upper GI Endoscopy and further treatment.
I would advise in addition the following:
Star a PPI like 
Omeprazole,
Antacid at 3 hourly interval.
Stop all the foods and beverages strictly which instigate or enhance your problem.
The second problem of a hole near anus is most probably fistula in ano.
Need the following:
Consult a General Surgeon or a 
Proctologist for clinical evaluation and investigations of per-
rectal examination, proctoscopy and fistulogram.
Get operated at an optimal time.