shudder
  • Member for 7 years, 7 months
  • Last seen more than a month ago
How is my CMS design? Any security, design, or other issues?
Accepted answer
14 votes

Developement oop & design-patterns tags you've used are already saying what needs to be done here. At this moment it's a structural code (with some class syntax) and it will be very difficult to ...

View answer
Merging website info into an array
5 votes

I think that one of the collections you iterate already has all the data you need. Try this: $linkQuery = $xpath->query("//div[@class='news-archive']//a"); foreach ($linkQuery as $link) { $...

View answer
Basic PHP template loader
Accepted answer
3 votes

Technical mistakes echo void echo $tpl->render($_GET['tpl']); This echo will display empty string (null), because you've already output a string with echo within method and have void return type ...

View answer
Foreach loop to generate HTML table with title in first cell of each row in PHP
3 votes

I would take 3 options into account: Floating <div>s next to each other (one foreach & more columns possible). Template (native php) without loop with placeholders as <?php echo $rows[0]-...

View answer
Dependency injection/dependency injection containers in MVC web app
3 votes

DI Container Dependancy Injection Container is a name for something different than you have here. It's holding construction parameters and object instances (composed and single) not it's methods and ...

View answer
Collecting data from different positions in a given array
Accepted answer
3 votes

Should work (at least it doesn't look like a riddle anymore:) for ($i = 0; $i < 4; $i++) { $a = $i + 9; $b = 3 + $i * 4; $r[] = array( 'na' => $arr[$a][2], 'pr' ...

View answer
Always keep https in url
2 votes

Documentation on HTTPS key says that it indicates the protocol was used when its value is not empty and is not equal to 'off' (used on on IIS) - correct condition for it would be if (empty($_SERVER['...

View answer
Users management php class
Accepted answer
2 votes

Whole user management system is very hard to do properly even with structural code. When you get a grasp of entire logic & security nuances OOP itself takes it to the next level, because this ...

View answer
Service Layer Design
Accepted answer
2 votes

Maybe it's a matter of preference, but IMO Exceptions shouldn't be used for validation errors (see:Don't Use Exceptions For Flow Control). First, it's not that exceptional and second, you should still ...

View answer
Check efficiency of PHP code that will query over 8500 orders
2 votes

I'm not familiar with the Woocommerce plugin and couldn't have tested this code, so don't delete yours. Chceck if it works and gives you expected result. I can't tell if you really use the Woocommerce ...

View answer
Cleaner or better readability in URL composition
2 votes

Hardcoded url templates are not a way to go imo, because they force you to assign expected variables - every url change happens in at least 2 places. You should use some build function that won't care ...

View answer
PHP function to obtain model_name from Namespace\To\ModelName
1 votes

Efficiency & Clarity For efficiency the only "flaws" (it's more for "good habit" than noticeable optimization - it doesn't matter for such a small strings) would be the order of functions (regexp ...

View answer
Sort multidimensional array based on another one containing the desired order
1 votes

I think this would be the cleanest solution. Similar to @YourCommonSense answer, but slightly inverted as ordered index is already there - only values missing. $sorted = array_flip($order); foreach ($...

View answer
optimize mysql taking too long
Accepted answer
1 votes

I'm blindfolded by spanish names a bit. I understood that you're trying to... set tareastrabajo.nombreTarea with newest and specified DATETIME of tareastrabajo.fechaCompletada into trabajo....

View answer
Create a 2D array from SQL table
1 votes

A row with column names is what mysqli_fetch_array using MYSQLI_ASSOC already returns - no need to use separate query for these names. Also note $array[] notation inside while loop - equivalent for ...

View answer
Improving the readability and efficiency of parser code
1 votes

validBraces() method review is imo complete (worth implementing @mjolka suggestion about using stack: open brace => add to stack|close brace => take from stack and compare match...). titleCase() ...

View answer
Refactoring of this complex PHP method
Accepted answer
1 votes

Don't know what happens in your db, but LIMIT 1 suggests that result of your query will return exactly what you ask or nothing. In this case no need to compare caller and opponent in if statement - ...

View answer
PHP HTTP request class
0 votes

I like that you've tried to include some processing within object's methods, which is what objects should look like from OOP perspective, but you've chosen wrong case for it IMO. Naming & API ...

View answer