Posts

php - Insert HTML content into db table securely -

i'm using html function inserting html content db table , filter filtering user inputs against sql injection attacks. getting output prntscr.com/3c8ht . got following questions: 1) functions html content needs passed before insert , while output? 2) else filter function needed or there unused function? thx in advance function filter($data, $db) { $data = $db->escape_string($data); $data = htmlspecialchars($data, ent_ignore, 'utf-8'); $data = strip_tags($data); $data = stripslashes($data); $data = htmlentities($data); return $data; } function html($data, $db) { $data = $db->escape_string($data); return $data; } you should use escaping tool required medium, not anywhere. to avoid sql injection, mysql_real_escape_string() is, @ minimun, need use. better alternative using prepared statements , paramerized queries (look pdo extension, shipped php since v 5.1 iirc), safest option avoid kind of exploit. sending u...

java - aspectj-maven-plugin multi module project -

i'm trying use aspectj-maven-plugin in multi-module project , can't understand aspects have placed. want crosscut in-module , between-modules calls. .aj files should located? this did far (structure of maven modules): foo foo-api foo-impl foo-aspects .aj files located in src/main/aspect . sub-modules (except foo-aspects ) using aspectlibraries option of aspectj-maven-plugin , use aspects foo-aspects.jar . at same time every sub-module has own aspects in src/main/aspect . works fine me far.

python - Setting name of variable in a class with a function? -

i have class , want following: class my_class: def my_func(self, var_name): self.var_name = 5 = my_class() a.my_func('yes') print(a.yes) i not sure how set class variable name using function >>> class my_class(object): ... def my_func(self,var_name): ... setattr(self,var_name,5) ... >>> = my_class() >>> a.my_func('yes') >>> a.yes 5

javascript - How can an animation be queued for different elements? -

i have question animation queues in jquery. let's talk on example. let have div , bunch of p elements in , of p elements has class "read": <div class="wrapper"> <div class="inner"> <p>paragraph 1</p> <p class="read">paragraph 2</p> <p>paragraph 3</p> <p class="read">paragraph 4</p> <p>paragraph 5</p> <p class="read">paragraph 6</p> <p>paragraph 7</p> <p class="">paragraph 8</p> </div> </div> i'd fade read ones out , animate height of wrapping div element accordingly. jquery code block won't work. var initheight = $('.wrapper').height(); $('.wrapper').height(initheight); $('p').not('.read').fadeout(300, function() { $('.wrapper').animate({ height: $('...

RESTful Routes help in Rails 3 -

i'm using rails 3, devise , mongoid. i believe can accomplish need using restful routes not sure how it. let me explain have , trying do. let's have 2 controllers - user , simpleform. the simpleform public facing form (no authentication required) when submitted shows in user's account (when login). i have multipul users on system , each 1 see form submissions that's specific them. so question is, how public facing form submit specific user's account? as of route fill out new form looks "site.com/simpleform/new". think can use routes make "site.com/simpleform/user_id/new" or "site.com/user_id/simpleform/new". either variation work think. when form submitted in public application knows user associate because of user_id in url. i think logic works , restful routes can make happen, i'm not sure how it. each user resource has 1 associated simpleform resource. so think route like: resources :users reso...

format - Java output file formatting -

i having bit of trouble formatting output file myself readable. trying output file such as: name of school size of school -------------- -------------- blblah blah 1300 blah blah blah 11300 blah blah blah asdf 14220 blah bblah 1300 but having trouble. using following code following output: file file1 = new file("src\\sortedint.txt"); formatter fmt = new formatter(file1); helpermethods.quicksortstudents(colleges, 0, colleges.length - 1); for(int = 0; < colleges.length; i++) { fmt.format(colleges[i].nameofschool + "%20d" + "\n", (int)colleges[i].numofstudents); fmt.flush(); } which gives me: eastman school of music 800 clark university 1100 walla walla college 1100 drew 1200 juilliard 1200 because padding end of college name. there anyw...

c# - Convert numeric types: Which style to use? -

let's want convert double x decimal y . there's lot of ways that: 1. var y = convert.todecimal(x); // dim y = convert.todecimal(x) 2. var y = new decimal(x); // dim y = new decimal(x) 3. var y = (decimal)x; // dim y = ctype(x, decimal) 4. -- no c# equivalent -- // dim y = cdec(x) functionally, of above same thing (as far can tell). other personal taste , style, there particular reason choose 1 option on other? edit : il generated compiling 3 c# options in release configuration: 1. call valuetype [mscorlib]system.decimal [mscorlib]system.convert::todecimal(float64) --> calls system.decimal::op_explicit(float64) --> calls system.decimal::.ctor(float64) 2. newobj instance void [mscorlib]system.decimal::.ctor(float64) 3. call valuetype [mscorlib]system.decimal [mscorlib]system.decimal::op_explicit(float64) --> calls system.decimal::.ctor(float64) this il generated compiling 4 vb options in release configuratio...