|
Biowarfare posted:^5 cal nerd Cool beans, thanks!
|
# ? Apr 20, 2016 02:58 |
|
|
# ? Jun 10, 2024 10:29 |
|
What is generally considered the best way to write a system that uses modules/plugins? Basically, I'm planning to write a system that scrapes information from various sources and ideally want it to be modular. The basic idea is that it'll have a central core that'll take the request for information and store the results in the database. To get the data it needs it'll use the modules in a specific folder to get the info it needs that return the data in a consistent format for the central core to process store and display, etc.. But I want to be reasonably automatic, so if I want to get a new source of information, I just write a new module that returns the data in a format the core can understand and the next time it runs it'll also pull information from that new source. I'm not sure what the best approach is for doing this though, so some input would be appreciated!
|
# ? Apr 21, 2016 12:41 |
|
Experto Crede posted:What is generally considered the best way to write a system that uses modules/plugins? Sound very similar to how Laravels middleware system works. For a naive solution: PHP code:
|
# ? Apr 21, 2016 15:08 |
|
Sooo, updating a server and I see that pdo-oci and oci8 are still as much of a pain in the rear end as ever. I'm being led to believe that pdo-oci is just not a thing anymore, but the app is written with it and I'm not a guy with a lot of time to rewrite. I've gone so far as to try php7 but compiling with pdo-oci fails because of LDAP. Basically, help. What is the current advice on oracle and pdo? Ubuntu 14.04.
|
# ? Apr 23, 2016 23:20 |
|
why the hell would you use oracle and php (maybe mangling some form of odbc?)
|
# ? Apr 24, 2016 00:14 |
|
Biowarfare posted:why the hell would you use oracle and php Dude, it wasn't my decision. But it worked before.
|
# ? Apr 24, 2016 00:15 |
|
So, I've been tasked with fixing/altering our website since "I know how to computer". It's written in php, which I don't know, I barely have a base in python/c++. It's an admin form where someone can get on and add events or articles. The 'Articles' form works as it is supposed to, the 'Shows' does not. -- On shows.php: code:
Here is the articles php: code:
Here is the bottom fieldset from editShow.php code:
I know there is probably some way to rewrite all of this way easier, but I don't have the skill to do all that. I'm hoping it's real easy fix. Your help is much appreciated. Also, edit works fine and delete does as well. ButtWolf fucked around with this message at 19:33 on Apr 25, 2016 |
# ? Apr 25, 2016 19:24 |
|
Your "Add New Show" has name "createNew", while in controller you're expecting "saveChanges". However, if both of these controllers are included in the same place, then having either unique name or value would be the way to go. Also, it's not part of your question, but bear in mind that everything after header gets evaluated - as such it's recommended to either exit or return after header.
|
# ? Apr 25, 2016 19:37 |
|
Well that makes it go to the correct page now : shows.php?action=shows&status=changesSaved but is not updating the list.
|
# ? Apr 25, 2016 19:54 |
|
I'm still very confused. I've compared the all the files and they look virtually the same.
|
# ? Apr 25, 2016 21:07 |
|
changed the value in both files to 'addNew' It takes me back to /shows.php?action=shows&status=changesSaved which is what it is supposed to do, but still is not updating. This is incredibly frustrating. I don't understand why articles.php works and shows.php does not. It apparently worked at one point, before our web guy quit.
|
# ? Apr 25, 2016 21:50 |
|
If the scripts are basically the same, chances are it's not the scripts. Using chrome? Press F12 and look at the Network tab. Submit the form again. What's in the Headers for the POST request? Does it look correct?
|
# ? Apr 26, 2016 12:58 |
|
Can you please paste the file in which newShow is being called? Perhaps you've got validation of $_POST there. Another thing - are articles and shows stored in different places? Maybe your shows are being saved to articles table (and that's why it's not updating) - you'd have to show us the storeFormValues and insert functions. Looking at the code you've posted, the issue lies elsewhere. vvv Can you please add the file in which Show class is defined? (Article as well if possible, but really I'd like to see the Show) canis minor fucked around with this message at 21:44 on Apr 26, 2016 |
# ? Apr 26, 2016 13:22 |
|
Google docs with all 6 files. Is this easier? Thanks for trying to help btw. Normally I just get yelled at a lot cause I'm dumb. I don't fully understand how all of this works, is probably the main problem. I'm just a quick fix until they hire another web developer, which will be whenever I quit probably. ButtWolf fucked around with this message at 17:44 on Apr 26, 2016 |
# ? Apr 26, 2016 17:41 |
|
put up 3 more files - Shows.php, Articles, Dealers.php These are the files with all the class stuff, which is what I need to look at. This is even further beyond me.
|
# ? May 2, 2016 15:22 |
|
That's because those files are Active Record classes. Active Record is a pretty classic pattern, but it's one that people have grown to dislike, because it contains two concerns: Database access and object data. If you're not familiar, the class (eg. Dealer) is an Entity, usually represented by one row in the DB. The public members contain the data for the record: code:
code:
code:
It's not paginated but it does two queries anyway for no reason. Awesome. Anyway, despite the jankyness of the code, I can't see any problems that could manifest as that particular bug. The fact you're getting the header redirect leads me to believe the PDO insert is silently failing. Try this: code:
This could be made hella tidier by not initialising the PDO object and connection for every query, which is super duper backwards retard face.
|
# ? May 3, 2016 02:41 |
|
Not sure where to put this, but I figure you guys in php-land would work with rewrite rules more than most. I'm transitioning a site from an OpenCart install and I need to redirect some of their URLs. Specifically, the brand pages which are structured like so: domain.com/Brand-Name1?sort=p.model&order=ASC But can also be: domain.com/Brand-Name1 They need to be turned into: domain.com/brands/New-Brand-Name1 So I figured out how to do this, but it feels super inefficient because I'm using >3< rewrite lines per brand, because I have to match/replace for both Brand-Name1 by itself, and also Brand-Name1?sort= with query string, and lastly Brand-Name1 does not equal New-Brand-Name1. This works: code:
code:
EDIT-Sorry I forgot one thing, the second example "works" in that it will match and redirect, but will leave the query string in the URL, which I don't want. Scaramouche fucked around with this message at 18:54 on May 10, 2016 |
# ? May 10, 2016 18:42 |
|
I'm not an htaccess wizard, but if you can't use QSD (Query String Discard) then you probably can't discard the query string cleanly. You might be able to replace it if you don't use QSA, and provide your own non-empty query string.. but as you said, that doesn't seem to work for you unless you touch %{QUERY_STRING}. With your current ruleset, only the first example you gave - with the query string - gets matched. That's obviously because of the RewriteCond checking for the query string. That little hack could be made a lot less specific so it works regardless of its presence. I'm testing this using this htaccess tester, so some aspects may vary from your 2.2.25 installation. Try this: code:
Be sure not to make the last REQUEST_URI an [OR] otherwise it'll match with OR QueryString .* which obviously matches everything ever. Other options include using RedirectMatch instead, where you just link the URLs and their desired targets. If you had to re-map particular brand names to more friendly URLs (eg. Brand-Name1 becomes brand-name-one) then I'd recommend this route. code:
Honestly though I'm not sure what the RedirectMatch does to the query string.
|
# ? May 11, 2016 00:51 |
|
Hmm, thanks for that. Unfortunately I do need to re-map entirely; think going from Xerox-Copy-Machines to just Xerox because the brand also includes Printers, Toner, etc. Redirectmatch doesn't take the URL into account as far as I can tell: http://serverfault.com/questions/500961/redirectmatch-and-query-string I'll do it my janky crappy way I think
|
# ? May 12, 2016 01:30 |
|
Scaramouche posted:Redirectmatch doesn't take the URL into account as far as I can tell: .. doesn't that link say that it only takes the URI into account, and not the query string? Isn't that want you want? You only want to discard the query string, yeah? Other options include: code:
|
# ? May 12, 2016 06:52 |
|
v1nce posted:.. doesn't that link say that it only takes the URI into account, and not the query string? Isn't that want you want? You only want to discard the query string, yeah? By only taking the URI into account so far means that querystring will just be ignored (and not discarded), which was the case here with Redirectmatch. I tried the other option with the variable, but I'm running into another problem. Brand-Name1 is a permalink in the underlying WordPress system I'm using, so stuff with query strings is getting routed to that instead of /brands/brand-name-one for whatever reason, despite using the L directive and having them higher in the file. I'm thinking I'll go with the original 3 line solution, but luckily I got into WebMaster tools, and only about 10 or so of the brands were indexed like that, so it's not nearly as many lines of .htaccess as I had thought. Thanks for your help though! I didn't know you could do local variables like that within the rewrite rules.
|
# ? May 12, 2016 20:21 |
|
It's probably related to the regex being overly specific (^Brand-Name1$) , but it's hard to say without seeing it in action. RewriteRules can be incredibly sensitive, and it gets worse when you want selective actions. But yeah, stem the bleeding at this point and go with what you had, rather than trying to prittify with a solution that isn't working. Just slap a comment at the top explaining why that poo poo code exists, in case someone else ever had to tidy it up.
|
# ? May 12, 2016 23:59 |
|
Has anyone here ever used or heard of a site built with PyroCMS? I started a new job on Monday and my first project is to build a site with this thing. It sounds nice, but there's basically no documentation and no evidence that anyone has ever succeeded at using it. If I can't get any traction tomorrow, I'm going to tell them we need to switch immediately for this project to succeed.
|
# ? May 13, 2016 00:04 |
|
rt4 posted:Has anyone here ever used or heard of a site built with PyroCMS? I started a new job on Monday and my first project is to build a site with this thing. It sounds nice, but there's basically no documentation and no evidence that anyone has ever succeeded at using it. If I can't get any traction tomorrow, I'm going to tell them we need to switch immediately for this project to succeed. Update: PyroCMS actually seems really good and the code is well-organized and easy to read, but it still needs documentation
|
# ? May 20, 2016 02:58 |
|
When I looked at it I got really excited by it, but then I realized that it doesn't have a whole lot of features. Not a bad starting point, but very much not turnkey, at least when I was evaluating it.
|
# ? May 20, 2016 12:46 |
|
v1nce posted:I'm testing this using this htaccess tester, so some aspects may vary from your 2.2.25 installation. Thanks for this, I had another rewrite URL thinger and I used this site to figure it out (tried like 3 others and they were useless and then I remembered you recommended one). Posting here what I did for posterity in case anyone else ever needs to do this. I was converting all product search URLs from OpenCart to WooCommerce. So the URL had to change from this: /?route=product/search&tag=BLAH&sort=foo&dir=bar To this: /?post_type=product&s=BLAH Normally straightforward but I hit some hiccups because I kept messing up because there was no actual file name, the whole thing was querystring. This rewriterule solved it: code:
Scaramouche fucked around with this message at 22:41 on May 20, 2016 |
# ? May 20, 2016 21:35 |
|
revmoo posted:When I looked at it I got really excited by it, but then I realized that it doesn't have a whole lot of features. I still don't recommend it, but so far it's not a disaster. I've made a rudimentary theme and some post types inside a module, at least.
|
# ? May 20, 2016 22:00 |
Laravel 5: I'm building a thing and learning the framework as I go. I've just started implementing authorization with the built-in system, with Policy classes, which is pretty neat for permissions tied to specific model instances. But what when I have a permission not tied to any model instances, but is rather global, so to say? The specific case I have right now is "create new teams", only some users should have that permission. I can't check the permission on an object that doesn't exist yet, how are you supposed to declare that?
|
|
# ? Jun 5, 2016 12:05 |
|
nielsm posted:Laravel 5: You'll check against the user object. So tie that ACL to the user object to see if the user is allowed to create teams. Something like this: php:<? \Gate::allows('create_teams', $user); // Or $this->authorize('create_teams', $user); // requires use of Illuminate\Foundation\Auth\Access\AuthorizesRequests ?>
|
# ? Jun 6, 2016 01:22 |
DarkLotus posted:You'll check against the user object. So tie that ACL to the user object to see if the user is allowed to create teams. So essentially use a dummy parameter when nothing else is appropriate? Kinda lovely solution but I guess I can live with it.
|
|
# ? Jun 6, 2016 05:37 |
|
Anyone know of a free obfuscator for code? Or is IonCube/ZendGuard kind of the only good options out there?
|
# ? Jun 8, 2016 15:05 |
|
poxin posted:Anyone know of a free obfuscator for code? Or is IonCube/ZendGuard kind of the only good options out there? Those can be easily reverse engineered, you're better off not obfuscating and instead just license your code with some sort of support agreement as well. Give users a reason to subscribe, you can never prevent code theft though.
|
# ? Jun 9, 2016 02:09 |
|
DarkLotus posted:Those can be easily reverse engineered, you're better off not obfuscating and instead just license your code with some sort of support agreement as well. Just to underscore how stupidly ineffective these products are, the wide variety of modern tooling we have now means that any experienced PHP developer can clean up any script that uses a pure-PHP obfuscation without too much effort. The types that require a server-side extension are a little more trouble, but that's nothing that a few dollars thrown at a sketchy Russian cracking service won't take care of. The effort is simply not worth the end-user annoyance. If you're only trying to prevent modification of the code, not necessarily piracy prevention, then you want strong wording in your user license agreement, and if you take it seriously, you'll also want a lawyer.
|
# ? Jun 9, 2016 02:42 |
|
DarkLotus posted:Those can be easily reverse engineered, you're better off not obfuscating and instead just license your code with some sort of support agreement as well. Yeah understood. It was more to keep not too savvy people from just opening up the source files and making edits. It's a self-hosted app going to be deployed on a client's server.
|
# ? Jun 9, 2016 04:15 |
|
poxin posted:Yeah understood. It was more to keep not too savvy people from just opening up the source files and making edits. It's a self-hosted app going to be deployed on a client's server. Just put a legal disclaimer at the top of each file that warns against unauthorized modifications. It may make them think twice... Also, McGlockenshire has a good point, implement a good license agreement and make your customers sign something.
|
# ? Jun 9, 2016 04:34 |
|
What's the best way to unit test a database driver class with phpunit? It uses PDO to connect to a database and then gives us utility functions to the underlying PDO class. Would I always want to hook this up to simple database and straight unit test this or is it generally better to mock the PDO class (and how? Pass in the PDO class to be used?) and then just mock out the necessary functions as necessary?
|
# ? Jul 7, 2016 17:23 |
|
Do you use an SQL builder, or are you writing SQL yourself? Be careful not to reinvent the wheel needlessly. Doctrine DBAL and the query builder it provides so everything you really need, including tests.
|
# ? Jul 7, 2016 17:52 |
McGlockenshire posted:Do you use an SQL builder, or are you writing SQL yourself? Doctrine facilitates testing? Some of the teams at my workplace use it, but I've only had to dabble in it occasionally. What does it provide for testing?
|
|
# ? Jul 10, 2016 11:13 |
|
I think McGlockenshire meant that it was already unit tested so you don't have to roll your own code, then test it. Doctrine has already covered this ground, repeatedly. That said: It's design lends itself to be easily mockable, so you can test Entities, Repositories and Services in a cleanly isolated manner. You can couple it with Doctrine Fixtures which helps you build your fixture data, rather than using poo poo like SQL dumps which can become unmanageable. The entire data model is transactional, so you can (mostly) isolate data during tests, and not affect your data fixtures. McGlockenshire posted:Be careful not to reinvent the wheel needlessly. Doctrine DBAL and the query builder it provides so everything you really need, including tests. Doctrine DBAL doesn't exactly hold your hand, as most people use Doctrine for the ORM, which is a lot more friendly (greater abstraction). If you're looking for a simple starting point, take a look at the Data Retrieval and Manipulation docs and expand out as you need.
|
# ? Jul 10, 2016 13:47 |
|
|
# ? Jun 10, 2024 10:29 |
|
I tend to simply version a SQLite db populated with fixtures with a cheeky script to build it, migrate it and populate it for the test suite to use. Don't see the point running data reliant tests without, ya know, data. Mocking dbal seems like a waste of time
|
# ? Jul 10, 2016 17:35 |