|
It's for our own use, probably all on the same server.
|
# ? Jun 24, 2015 13:22 |
|
|
# ? May 19, 2024 17:45 |
|
Can you ask someone with the "vision" of what this is for if the functionality site-to-site is expected to deviate? Like, a single feature of SiteA will do something different to SiteZ for whatever reason? In most systems the answer is that some deviation is going to be needed, and in that case it's often difficult to maintain a one-code-fits-all approach, unless you go bat-poo poo crazy with per-site config. If part of the goal is a lack of deviation, then you can probably just throw one copy of the code at the server and maintain that. If it isn't, you'll need to modularise a little bit more to make as much common code as possible, and attach unique features as needed (think wordpress and plugins). What's the intention of the different sub-sites? Are you going to just apply minor theme differences (a logo here, colours there) or are you going to want entirely different templates on a per-page basis with the same back-end? If it's the former, I'd probably set an environment variable dependant on the subdomain, and then have AppKernel pick an additional config file based on the var. That gives you small but configurable changes, but a central codebase and one set of templates. If it's the latter, you could make one primary bundle which is responsible for figuring out what theme/settings/whatever to load, and all your real code calls on that service. The service is then responsible for "getting" the theme (or whatever) that should currently be running. Individual themes, provided by another bundle(s) could then register with that service, either by Event or by service tagging. It just has to determine which sub-service to use, and act as a Service Locator or a Facade if you're sure it's a load-once set-once never-deviate arrangement. Just remember to use interfaces. As to if you make them individual bundles or one bundle.. that comes down to how you expect this thing to work, and what it's for. There's no reason you can't support multiple themes in one bundle, and then just include a single theme in each bundle if that's the route you decide to go later on.
|
# ? Jun 25, 2015 00:25 |
|
The PHP pages aren't very clear on this, but how good is the is_numeric() function at detecting numbers with some non-numeric characters in? Basically, trying to detect phone numbers, which may have a + or may have ( ) in them, etc. and some may also just be something like Anonymous or Unknown, etc. (with some other variations possible too, so I'd like to avoid hardcoding checks against those) Obviously if it gets passed something like anonymous or unknown then is_numeric will reject it, but will it work with something like +44.1234567890 or (012345) 456789?
|
# ? Jun 26, 2015 16:20 |
|
If I understand it correctly, it'll reject anything that wouldn't be a numeric literal when you type it into a PHP program
|
# ? Jun 26, 2015 16:52 |
|
If you're validating a phone number you should probably treat it like a phone number.
|
# ? Jun 26, 2015 22:47 |
|
McGlockenshire posted:If you're validating a phone number you should probably treat it like a phone number. Holy poo poo, somehow my googling for phone validation never found that. Thanks!
|
# ? Jun 26, 2015 23:31 |
|
I am connecting to a SQL Server 2014 instance using PHP 5.4.24 and I am trying to figure out why this isn't working:code:
|
# ? Jun 29, 2015 04:17 |
|
print_r(sqlsrv_errors());, sqlsrv_query i don't think returns anything on failures ..also why are you.. why..
|
# ? Jun 29, 2015 04:20 |
|
Biowarfare posted:..also why are you.. why.. Why not? code:
Agrikk fucked around with this message at 04:41 on Jun 29, 2015 |
# ? Jun 29, 2015 04:37 |
|
Agrikk posted:Why not? Try this PHP code:
|
# ? Jun 29, 2015 11:55 |
|
also why are you telling print_r to not output the errors but to return a string, which you then immediately send to die that outputs it anyway?PHP code:
|
# ? Jun 29, 2015 12:57 |
|
I went through the last 50 pages of this thread, ran a few searches and didn't find any discussion on this so here goes: I'm not new to coding but I am new to PHP. 1. Can one use php to automate twitter/facebook functions such as post, like, share, retweet, accept friend requests, follow, etc? 2. If yes, Can it be done to mulitple accounts at once? 3. If yes, what areas of php do I want to turn my focus to? 4. If no, any ideas on what does? ZeldaLeft fucked around with this message at 23:44 on Jun 29, 2015 |
# ? Jun 29, 2015 23:42 |
ZeldaLeft posted:I went through the last 50 pages of this thread, ran a few searches and didn't find any discussion on this so here goes: Your questions don't really have anything do with PHP. You're basically just asking "Does twitter have an API?" and the answer is yes they do: https://dev.twitter.com/rest/public Your next question might be "Can PHP interact with a REST API?" and the answer is yes it can Maybe you want to look through the PHP twitter libraries that people have built: https://dev.twitter.com/overview/api/twitter-libraries#php (this was the first result for 'twitter php')
|
|
# ? Jun 30, 2015 01:16 |
|
Wordpress question but involves PHP functions: How do I make the "Read More" button appear only for posts with more than 120 words?
|
# ? Jul 6, 2015 04:29 |
|
Your question is a bit like "How do I get a housing permit" and you're expecting us to already know where you live and the type of house you want the permit for. Any chance you can provide some better context, like a cut-down chunk of the PHP source where the ReadMore button should be displayed, plus the outer loop that lists all the posts? As an example, take a look at archive.php, you'll probably see something like: php:<? if (have_posts()) { while(have_posts()) { the_post(); // .. } } ?> Somewhere in there you can throw the following: php:<? ?><a href="<?php get_permalink(); ?>">Read More</a><?php ?> If you're worried about posting a mammoth amount of code because you don't know what to cut out and what not to cut out, use pastebin or something.
|
# ? Jul 6, 2015 07:51 |
|
fletcher posted:Your questions don't really have anything do with PHP. You're basically just asking "Does twitter have an API?" and the answer is yes they do: https://dev.twitter.com/rest/public Also the answer to a few of these is also "yes, but I'm pretty sure that you will need to verify your twitter/fb account with either phone or credit card, and if you plan on doing anything dumb like mass spamming follows and add requests you'll just get terminated"
|
# ? Jul 6, 2015 18:53 |
|
What am I missing here? I'm trying to get a time period to iterate through, say each day of five weeks from now. From what I could tell, the best way of doing this is by using DateTime and creating a DatePeriod. It's probably worth mentioning that it's a plugin for the Craft CMS which might be messing it up. The PHP version is 5.6.php:<? $start = new DateTime(); $end = $start->modify("+5 weeks"); $interval = DateInterval::createFromDateString('1 day'); $dateRange = new DatePeriod($start, $interval, $end);?>
|
# ? Jul 15, 2015 08:15 |
|
try new \DatePeriod you might have use hijack the. edit: use Craft\Craft probably is.
|
# ? Jul 15, 2015 08:29 |
|
Biowarfare posted:try new \DatePeriod Sweet, it worked! I should have figured it was Craft being an rear end. Thanks so much!
|
# ? Jul 15, 2015 08:52 |
|
Bartie posted:Sweet, it worked! I should have figured it was Craft being an rear end. Thanks so much! That's a namespace issue. If there's a namespace My\Dumb\Library; declaration at the top of the file then you'll need to specify the namespace of classes you're using within that file, with use statements. Without the corresponding use declarations, you need to specify the absolute class paths for PHP to find your classes. What this means is, to use DateTime (or any other class) in a file with a namespace you have to specify it as \DateTime - with the prefixed slash (because DateTime sits in PHP's root namespace, \). If you don't want to do that - because technically it's an absolute class reference - you can instead specify it using the use keyword at the top of the file: code:
So what? I saved you one keystroke by making you type 14. Well, the magic of this is if you need to override it some time down the track. You simply change your use declaration to: code:
|
# ? Jul 15, 2015 12:11 |
|
Full disclosure, it has nothing to do with Craft specifically and everything to do with autoloader namespacing. See: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md
|
# ? Jul 15, 2015 12:47 |
|
v1nce posted:That's a namespace issue. If there's a namespace My\Dumb\Library; declaration at the top of the file then you'll need to specify the namespace of classes you're using within that file, with use statements. Blinkz0rz posted:Full disclosure, it has nothing to do with Craft specifically and everything to do with autoloader namespacing. I see, thanks a lot for the explanations!
|
# ? Jul 15, 2015 13:15 |
|
I am a Graphic Designer that has taken on the Front End as well as the Back End of building websites for a small local business. I was working with someone else who was the main back-end coder for all of our Website needs but has since moved on. Until we find someone elseI I am to fill both roles. I understand HTML pretty well and have created several fully functional websites. In order to speed up production of websites at the same time of keeping Aesthetics in mind, our business model is based on sound templates and reworking them to fit our needs. That being said, I have taken on two sites that would like a simple contact form on their website and while I have the form on the form and it is functional, the issue is that I cannot get a form of verification to prevent spammers. I originally wanted to use reCAPTCHA 2.0 since it seemed pretty straight forward and I have tried for weeks trying to get it to work on the sites. I looked all around the Internet on forums, stackoverflow and anything else I could find, only to put myself into a bigger hole. I then moved onto a simple php math equation to verify the user... Failed again. I have taught myself the basics of PHP and very little Javascript to understand the language a little bit more but I'm still having trouble. I feel like I am really close to solving this simple problem, but I just keep creating more problems for myself. Anyway... I would appreciate if someone could help me resolve my PHP verification issue. I'm indifferent to the technique used for verification. Below is my form stripped of any fancy stuff, Once I can get my verification working, I can figure out how to add anything extra. code:
php:<?php session_start(); $email_to = "example@email.com"; // change with your email $name = $_POST['name']; $email = $_POST['email']; $subject = $_POST['subject']; $message = $_POST['message']; $headers = "From: $email\r\n"; $headers .= "Reply-To: $email\r\n"; if(mail($email_to, $subject, $message, $headers)){ echo "success"; } else{ echo "failed"; } ?> code:
Fenyur fucked around with this message at 13:45 on Jul 20, 2015 |
# ? Jul 15, 2015 21:45 |
|
Is there a go to framework for implementing a rest api? I'm guessing there's something in pear, if that still exists. Been awhile since I've written in php so any help would be appreciated. Thanks
|
# ? Aug 7, 2015 05:12 |
|
Acer Pilot posted:Is there a go to framework for implementing a rest api? I'm guessing there's something in pear, if that still exists. PEAR is long dead - use Composer instead for vendoring. Lots of options for APIs. If you need a large one, Symfony, Laravel, or Zend are probably the go-to frameworks (Zend has Apigility I think which is for building APIs). Symfony has FOSRestBundle or you can roll your own, and I'm sure Laravel has something. If you need something quick-n-dirty, use any of the number of micro-frameworks out there (Symfony has Silex and Laravel has Lumen). What size application are you going to be building?
|
# ? Aug 7, 2015 05:19 |
|
Not very big, basically an over glorified crud app that just grabs stuff from a MySQL db. Just want to switch the site to use more JavaScript and would be nice to keep php out of the presentation layer.
|
# ? Aug 7, 2015 05:28 |
|
Probably any one of the micro-frameworks I mentioned would be a good start.
|
# ? Aug 7, 2015 18:24 |
|
I know VERY little about PHP. I am running a Raspberry Pi 2 webcam running motion on Raspbian. This works fine for clients with plenty of bandwidth. For my phone, I want to be able to pull up a page with the last frame taken by the camera. Lucky for me, motion puts still frames in /tmp/motion, which is on a small RAMdisk on the Pi. I want to make some PHP to copy the last picture taken into a folder where it can be served via Apache (also on the RPi2). I have cobbled together some code to identify the most recent file in the directory: code:
code:
I have done some testing with exec() and touch, and I can create files and folders within the /tmp folder in PHP. I think PHP lacks the permissions to access the files created by motion. How can I tell motion to create the files in a way that PHP can touch? EDIT: I did some monkey business with symlinks, and now I can just get the name of the latest file and use that in my HTML code. Nothing to see here. PBCrunch fucked around with this message at 23:57 on Aug 10, 2015 |
# ? Aug 10, 2015 22:58 |
|
(e: This is still valid even if you've already worked around the problem) There's nothing there that you need PHP for. Given that you're just shelling out for everything, you'd may as well just write it as a shell script. code:
|
# ? Aug 11, 2015 00:26 |
|
I've just configured a mysql database on a godaddy hosted site. phpMyAdmin is telling me that the server is hosted at 50.62.209.154:3306, but the followingphp:<? $mysqlServer = "http://50.62.209.154"; $user = "..."; $pw = "..."; $db = "email_database"; $conn = new mysqli($mysqlServer, $user, $pw, $db); ?> Warning: mysqli::mysqli() [<a href='mysqli.mysqli'>mysqli.mysqli</a>]: (HY000/2005): Unknown MySQL server host 'http://50.62.209.154' (11001) in G:\PleskVhosts\mybadwebsite.com\httpdocs\staging\php\contact.php on line 40 The error is the same whether I include/exclude the port and the 'http://'. Any suggestions? Newf fucked around with this message at 17:23 on Aug 16, 2015 |
# ? Aug 16, 2015 17:19 |
|
$dbh = new PDO('mysql:host=50.62.209.154;port=3306;dbname=email_database', $user, $pw);
|
# ? Aug 16, 2015 19:21 |
|
Probably not a good idea to have the MySQL instance listening on anything other than localhost, assuming your web-server is on the same server.
|
# ? Aug 17, 2015 10:56 |
|
Biowarfare posted:$dbh = new PDO('mysql:host=50.62.209.154;port=3306;dbname=email_database', $user, $pw); Hm, yes, that worked. Thanks! cheese-cube posted:Probably not a good idea to have the MySQL instance listening on anything other than localhost, assuming your web-server is on the same server. Will likely have a followup on this later this evening. I'm new with php, mysql, godaddy, and dealing with hosting at all, so I've been doing a lot of guesswork.
|
# ? Aug 17, 2015 17:04 |
|
Newf posted:
iirc godaddy shared hosting has mysql running non-locally, and users are ip-restricted to the shared hosting machine and localhost
|
# ? Aug 17, 2015 17:44 |
|
Biowarfare posted:iirc godaddy shared hosting has mysql running non-locally, and users are ip-restricted to the shared hosting machine and localhost Ah. My intention is to write a small desktop app that pulls data from this db - I guess this means that I'll have to write some data-serving php glue rather than connecting to the db directly.
|
# ? Aug 17, 2015 17:53 |
|
All the same I'd recommend configuring iptables or something similar to block inbound connections to all ports other than the specific ones you require (e.g. 22, 80, 443, etc.). If your web-server and MySQL server are on different servers then just configure rules on the MySQL server to only allow connections to tcp/3306 from your web-servers public IP. Edit: if your only clients will be behind a single NATed public IP address then configure your server-side firewall thusly. If the application is meant to be accessible from anywhere then you will probably need to setup an authenticated API of sorts to handle requests (Can't really provide recommendations on this myself but others in this thread can). Pile Of Garbage fucked around with this message at 18:00 on Aug 17, 2015 |
# ? Aug 17, 2015 17:55 |
|
Newf posted:Ah. My intention is to write a small desktop app that pulls data from this db - I guess this means that I'll have to write some data-serving php glue rather than connecting to the db directly. https://www.godaddy.com/help/connect-remotely-to-databases-4978
|
# ? Aug 17, 2015 17:57 |
|
The big takeaway from that is that "Direct database connections do not support secured (SSL) connections." You do not want to do this (Here's a great reason why: http://forums.somethingawful.com/showthread.php?noseen=0&threadid=2803713&pagenumber=258#post398884189). Setup an authenticated API which the application can connect to instead. Edit: vvv yah that's the same post I linked idgi vvv Pile Of Garbage fucked around with this message at 18:13 on Aug 17, 2015 |
# ? Aug 17, 2015 18:05 |
|
cheese-cube posted:The big takeaway from that is that "Direct database connections do not support secured (SSL) connections." You do not want to do this (Here's a great reason why: http://forums.somethingawful.com/showthread.php?noseen=0&threadid=2803713&pagenumber=258#post398884189). Setup an authenticated API which the application can connect to instead. Or better yet, just don't use godaddy for anything If you're going to be distributing the application you don't want to put mysql stuff in there anyway, see http://forums.somethingawful.com/showthread.php?noseen=0&threadid=2803713&pagenumber=258#post398884189
|
# ? Aug 17, 2015 18:09 |
|
|
# ? May 19, 2024 17:45 |
|
That's all awful, yeah, but my scope here is small. I'm putting something together here for a family member who wants an online booking/contact system on the cheap for his personal business. He already has his godaddy hosting at an extremely low price. Are these security concerns bad enough that I shouldn't proceed? Would it suffice to configure the remote connection as readonly? I don't expect that there's a great threat of cyber-espionage in the local roofing market.
|
# ? Aug 17, 2015 18:59 |