Jump to content

requinix

Administrators
  • Content count

    9,885
  • Joined

  • Last visited

  • Days Won

    154

requinix last won the day on June 22

requinix had the most liked content!

Community Reputation

638 Excellent

About requinix

  • Rank
    Impoverished Administrator

Profile Information

  • Gender
    Not Telling
  • Location
    WA

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. I didn't tell you because the change was so simple. I knew if I poked and prodded you a bit, pointed you in the right direction, that you would figure it out. And you would learn along the way. Because someone saying "use escapeshellarg and remove the embedded quotes around it" would teach you where to get answers but not how to get them. And knowing how to get those answers is what makes skilled developers. As for being condescending... yeah, I was a bit. People who learn to be developers by copying and pasting stuff from the internet make the rest of us professionals look bad, and it's one of my pet peeves. I'm not saying you're like that, but when I see a glimmer of that that sort of mentality emerging I want to squash it there and then.
  2. requinix

    PHP Gallery - Sorting newest images first

    That's a nice get_files() function you have there. Shame you aren't using...
  3. Removing the quotes was part of it. Can you restate what I said in my post using your own words? Top to bottom.
  4. escapeshellcmd is for commands. If you had checked the documentation for it before simply doing what people on the internet told you to do then you would hopefully have seen the red warning: On that linked page you would see the description It's also to be used when the command is executed. Not earlier. Because it alters the value - which, in contexts like this, is generally called "escaping". This is a very important aspect you need to understand: the difference between what a value is and how a value is interpreted. The value "1+2" is a string with three characters. If you interpreted that value as PHP code you would get 3, a number. The value itself and the value of it interpreted are two things. escapeshellcmd/arg alter the value so that it will not be interpreted as anything special. That would be like taking "1+2" and adding quotes around it so that PHP considered it to be the three-character string it was originally, but in doing so the value becomes five characters. If you want to examine the value then you must not quote it yet. If you want to do something with the value then you might quote it ("might" depending what you wanted to do). You also wouldn't escape it and add your own quotes because that would be too much. So, after that rambling explanation, can you tell me what your updated code should be?
  5. That's a lot of code, and it doesn't quite match up with what you had in the first post. Can you be more precise about what isn't working? And regarding the general question about upgrading from PHP 5 to 7, have you seen the migration guides? edit: Code boxes now won't grow so large.
  6. requinix

    symlinks in public folder not invoking the website

    Made a couple small tweaks: in the forum view, on the left of each thread where there used to be a star or circle (or nothing) there can now be a check. Shows if there is a recommended post. I also made a similar change somewhere else but I don't know where it is... tempted to revert but meh, the syntax is good so it should be fine. I did the check because that's the only thing I saw readily possible - didn't see markup to support something like the label style the old forum had. The change isn't in other places. And if people can't see the Recommend link then I'll figure out where that's all managed tomorrow because I think I'll have to go into the IPB source to find out. edit: Oh, I see something better I can do. Tomorrow.
  7. requinix

    symlinks in public folder not invoking the website

    Okay, yes, but do you see a Recommend link at the bottom of each post? By the Quote? I can look into it but I suspect it won't be easy enough for me to just do. If it requires writing a plugin then I'd really rather not have to bother. Truth is the Mark Solved thing didn't actually get a whole lot of use...
  8. requinix

    symlinks in public folder not invoking the website

    I just made some changes. Do you see a "Recommend" link at the bottom of posts? I suspect not...
  9. requinix

    symlinks in public folder not invoking the website

    IP.Board decided that nobody needed it anymore so they got rid of it And if their codebase wasn't so terrible I'd write a plugin to add it back. But you can Like/Thanks posts.
  10. requinix

    Composition over inheritance examples

    So I'm working with React and they strongly suggest composition over inheritance. I still don't understand why. Here's composition like they say (slightly rewritten): class Dialog extends React.Component { render() { return ( <FancyBorder color="blue"> <h1 className="Dialog-title"> {this.props.title} </h1> <p className="Dialog-message"> {this.props.message} </p> </FancyBorder> ); } } class WelcomeDialog extends React.Component { render() { return <Dialog title="Welcome" message="Thank you for visiting our spacecraft!" />; } } This is inheritance: class WelcomeDialog extends Dialog { constructor() { super({title: "Welcome", message: "Thank you for visiting our spacecraft!"}); } }
  11. requinix

    Composition over inheritance examples

    Admin extends User extends Person means the admin is a user. If the admin is never a user then this isn't appropriate. But if an admin normally/often/generally is then that's fine, and a non-user admin could be something like a service account. But it's worth thinking more about whether it's a user or not. "User" doesn't necessarily have to be a person so I'm not sure User extends Person is right. Or really even what the purpose of a Person class would be. About the chart thing. Injecting a BarChart into a Chart didn't make sense to me because a BarChart "is a" Chart, and that means it should use inheritance. Inheritance is very much so an "is a" relationship, and if you can describe two classes using that term then inheritance is probably the way to go. What would make sense if if you injected a "BarChartRenderer" into a Chart: the renderer takes care of dealing with how bar charts work, and the Chart is basically just a source of data. ...except that's not quite right either. If Chart is a data source then it should not care about rendering, so better would be the reverse of putting a Chart into BarChartRenderer. Which wouldn't really be injection so much as it would be simply one class using another. Normally. Composition is about "is made from" in that some component is a part of how the object works. A sort of functional dependency. A Chart is not "made from" a BarChart so that's not composition. A BarChartRenderer is not "made from" a Chart so that's not composition either. A reasonable example of this would be having a User class be made from a Person: the User represents an entity in the system that's capable of actions, while a Person is surely a human who the User is acting on behalf of. Your code would deal primarily with a User, and that class would do what it needs to do with the Person behavior. Composition is one step away from dependency injection, and most of the time those two can be converted to and from inheritance without much thinking involved. <?php namespace Inherited { // an admin is a user and gets all the behavior of a user class Admin extends User { public function deleteResource(Resource $r) { ... } } // a user is a person and gets all the behavior of a person class User extends Person { public function createResource(Resource $r) { ... } } class Person { public function useResource(Resource $r) { ... } } } namespace Composed { interface IAdmin extends IUser { public function deleteResource(Resource $r); } // admin is made from a user and delegates some behavior to it class Admin implements IAdmin { public function deleteResource(Resource $r) { ... } public function createResource(Resource $r) { (new User)->createResource($r); } public function useResource(Resource $r) { (new User)->useResource($r); } } interface IUser extends IPerson { public function createResource(Resource $r); } // user is made from a person and delegates some behavior to it class User implements IUser { public function createResource(Resource $r) { ... } public function useResource(Resource $r) { (new Person)->useResource($r); } } inteface IPerson { public function useResource(Resource $r); } class Person implements IPerson { public function useResource(Resource $r) { ... } } } namespace DependencyInjected { interface IAdmin extends IUser { public function deleteResource(Resource $r); } // admin must be given a user to depend on class Admin implements IAdmin { private $_user; public function __construct(User $u) { $this->_user = $u; } public function deleteResource(Resource $r) { ... } public function createResource(Resource $r) { $this->_user->createResource($r); } public function useResource(Resource $r) { $this->_user->useResource($r); } } interface IUser extends IPerson { public function createResource(Resource $r); } // user must be given a person to depend on class User implements IUser { private $_person; public function __construct(Person $p) { $this->_person = $p; } public function createResource(Resource $r) { ... } public function useResource(Resource $r) { $this->_person->useResource($r); } } inteface IPerson { public function useResource(Resource $r); } class Person implements IPerson { public function useResource(Resource $r) { ... } } } ?> <?php namespace Inherited { /* this makes sense */ // a bar chart is a type of chart class BarChart extends Chart { public function getBarWidth() { ... } public function setBarWidth($width) { ... } public function render() { ... } } // a chart forms the base for how types of charts work abstract class Chart { public function getTitle() { ... } public function setTitle($title) { ... } public abstract function render(); } } namespace Composed { /* this is bad */ // a chart is made from a barchart. it would have stuff for other chart types too // class Chart { // private $_config; // public function __construct($config) { $this->_config = $config; } // public function getTitle() { ... } // public function setTitle($title) { ... } // public function getBarWidth() { return BarChart::getBarWidth($this->_config); } // public function setBarWidth($width) { $this->_config = BarChart::setBarWidth($this->_config, $width); } // public function renderAsBarChart() { (new BarChart($this->_config))->render(); } // } // a bar chart has bar chart knowledge // class BarChart { // private $_config; // public function __construct($config) { $this->_config = $config; } // public static function getBarWidth($config) { ... } // public static function setBarWidth($config, $width) { ... } // public function render() { ... } // } } namespace DependencyInjected { /* more reasonable than composition, and a different approach to the problem than inheritance */ interface IChartRenderer { public function render(Chart $chart); } // a chart has chart data class Chart { private $_config; private $_renderer; public function __construct($config, IChartRenderer $renderer) { $this->_config = $config; $this->_renderer = $renderer; } public function getConfig($key, $default = null) { return $this->_config[$key] ?? $default; } public function getTitle() { ... } public function setTitle($title) { ... } public function render() { $this->_renderer->render($this); } } // a bar chart renderer knows how to render charts into the bar style class BarChartRenderer implements IChartRenderer { public function render(Chart $chart) { ... } } } ?> I wrote a lot so I'm going to stop there, but I don't think I said everything I was intending to say.
  12. requinix

    symlinks in public folder not invoking the website

    The domain name as seen in the browser isn't matching one of the site configurations used by Apache/nginx. Either there is no configuration, or it's not enabled, or Apache/nginx haven't been restarted since adding the configuration, or the domain names don't match.
  13. requinix

    Should mappers digest objects?

    Once the data is deleted the object will no longer be usable, right? Having deleteOneById saves you from spending extra resources having to pull up the User (if you didn't already have it) just so that you can delete it. But there's more. You should have an object store set up - I don't remember the proper term, but it's a registry-esque thing that tracks all database objects in memory and prevents multiple objects from being created from the same data. Having a single object for some piece of data (eg, a User) means you can't accidentally have multiple copies and create concurrency problems, such as having $object->foo = 123 in one place and ->foo = 456 in another. That is, findOneById($int) === findOneById($int). Given such a store, delete() and deleteOneById() would have slightly different behaviors. - delete: If the object is still usable, mark it as unusable and perform the actual deletion. Having the concept of "usability" means a deleted User cannot later be re-saved or otherwise acted upon. - deleteOneById: If the object store has a User for this ID then delete() it, thus existing objects being used elsewhere will be automatically unusable. If the store doesn't have this object then it can perform the deletion directly.
  14. requinix

    when a text line wraps; is there an event?

    There is no a wrap event. There is a window resize event and a typing event. What is the problem you're trying to solve by detecting line wrapping?
  15. requinix

    an Internet Explorer phenomanon

    "undefined" is a Javascript thing - it wouldn't have come from PHP...
×

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.