root beer posted:Magento My heart goes out to you http://store.pulsestorm.net/products/commerce-bug-2 will help as well
|
|
# ? Oct 3, 2014 08:54 |
|
|
# ? Jun 8, 2024 03:26 |
|
Anyone have a preferred deployment method at the low-level for actually pushing your files live? In the past I've swapped symlinks on the webroot with staging directories and also just automated mv to simply copy the files. Is there a better way? I'm deploying around 200mb or so each time to an app that's busy but not insane. I'd like to avoid downtime as much as possible. My testing on swapping symlinks seemed to indicate something like 20ms of downtime using that method. Bear in mind I'm not talking about your preferred CD/CI platform, but rather what you put in your delivery scripts for the last mile (swap new content in so Apache can serve it).
|
# ? Oct 7, 2014 13:00 |
|
Capistrano is probably what you want.
|
# ? Oct 7, 2014 15:02 |
|
Capistrano is a deployment platform. I already have one. I was asking about how I should structure my scripts to actually place the files in the web root. Again, I've already got automated deployments working and I've done it multiple ways in the past. I was just wondering if there was a better technique for pushing the files into the web root. vvv Interesting. So I guess the symlink technique is probably as good as it gets.
|
# ? Oct 7, 2014 15:12 |
|
According to the Capistrano sample output, its default behavior is also to symlink http://capistranorb.com/documentation/overview/what-is-capistrano/
|
# ? Oct 7, 2014 15:14 |
|
revmoo posted:Capistrano is a deployment platform? I already have one. I was asking about how I should structure my scripts to actually place the files in the web root. Yes, Capistrano is for deploying to your server(s). Essentially, it shell's into your servers, clones your repository in a timestampped directory, does any building you need to do (build your configuration file, compile assets, run database migrations, etc), and then updates the symlink so "current" (which is what Apache points to) points to the latest release. All done atomically so if any part of your build process fails the entire release fails and you have no downtime, and can run on multiple servers asynchronously.
|
# ? Oct 7, 2014 15:16 |
|
EDIT: FIXED!!! I'll post my solution tomorrow, but I actually it had to do with how I incorrectly converted the query results in my AJAX function to JSON. Oi. I am working on adding a jQuery UI autocomplete to a Laravel 4 form. I could get simple AJAX requests working via GET and while that would pass the token, it would bypass the CSRF protection. When I switched to sending an autocomplete request, I would get the following error in the console: quote:Uncaught SyntaxError: Unexpected token : At that point, I tried switching to sending the autocomplete request via POST where it would have access to CSRF validation and it then yielded the following error: quote:POST http://localhost/Laravel_Auth/fresh/public/orders/step1Ajax 500 (Internal Server Error) My assumption is that the problem has something to do with the Laravel CSFR token that I am using, but I am not sure how to address that issue? I saw this post another forum and ayyobro's response which talked about passing the token through the header instead of AJAX, which I did try, but I still continued to get 500 (Internal Server Error) errors, so I am not sure what to try next. The code below is just my normal attempt and does not include the changes I made to try and get passing the token through the header. Here is my simplified route code. php:<? // Authenticated group Route::group(array('before' => 'auth'), function() { // CSRF protection group Route::group(array('before' => 'csrf'), function() { // Order Step 1 (POST AJAX) Route::post('/orders/step1Ajax', array( 'as' => 'orders-step1-ajax', 'uses' => 'OrderController@postOrderStep1Ajax' )); }); }); ?> php:<? class OrderController extends BaseController { public function postOrderStep1Ajax() { if (Request::ajax()) { $searchSourceCode = Input::get('searchSourceCode'); $jsonSourceCodes = DB::table('sourceCodes') ->distinct() ->take(12) ->where('sourceCode','LIKE', $searchSourceCode . '%') ->orderBy('sourceCode','DESC') ->get(); return $jsonSourceCodes->toJson(); } } } ?> JavaScript code:
HTML code:
Aniki fucked around with this message at 01:02 on Oct 16, 2014 |
# ? Oct 15, 2014 01:15 |
|
Here is my updated code, which works for me. I'm a bit unsure why it is working now. I had initially thought that it had to do with where I was using toJson(), but upon further testing that works regardless of whether I apply it to the query after get() or to the object itself. The route code remained the same, so I won't repost that. The jQuery code changed slightly. I did change the URL to just 'step1Ajax' instead of the full path, but both worked: JavaScript code:
php:<? class OrderController extends BaseController { public function postOrderStep1Ajax() { // Checks for an ajax request if (Request::ajax()) { $searchSourceCode = Input::get('searchSourceCode'); $jsonSourceCodes = SourceCode::distinct() ->take(12) ->where('sourceCode','LIKE', $searchSourceCode . '%') ->orderBy('sourceCode','DESC') ->get(); return $jsonSourceCodes->toJson(); } } } ?>
|
# ? Oct 16, 2014 18:28 |
|
musclecoder posted:Yes, Capistrano is for deploying to your server(s). Essentially, it shell's into your servers, clones your repository in a timestampped directory, does any building you need to do (build your configuration file, compile assets, run database migrations, etc), and then updates the symlink so "current" (which is what Apache points to) points to the latest release. All done atomically so if any part of your build process fails the entire release fails and you have no downtime, and can run on multiple servers asynchronously. What do you do to make sure opcache works? For me it doesn't refresh the files after the symlink change because it's still watching the old symlinked files, even though the symlink was updated.
|
# ? Oct 16, 2014 21:12 |
|
You'd probably have to fire off some sort of a refresh or something at that point... opcache_reset() maybe? revmoo fucked around with this message at 21:24 on Oct 16, 2014 |
# ? Oct 16, 2014 21:21 |
|
Peanut and the Gang posted:What do you do to make sure opcache works? For me it doesn't refresh the files after the symlink change because it's still watching the old symlinked files, even though the symlink was updated. Have Capistrano restart php-fpm. Or have php-fpm restart itself after a very low number of requests (I use 200) and the cache will be cleared automatically.
|
# ? Oct 16, 2014 22:46 |
|
musclecoder posted:Have Capistrano restart php-fpm. Or have php-fpm restart itself after a very low number of requests (I use 200) and the cache will be cleared automatically. Is that pm.max-requests or some other setting?
|
# ? Oct 17, 2014 02:25 |
|
Peanut and the Gang posted:Is that pm.max-requests or some other setting? Yup. code:
|
# ? Oct 17, 2014 04:15 |
|
My php is not so much rusty as non existent apart from reading through code and hacking it apart. That said I am following a tutorial to make a database link for my ios app. I have the database made and populated with some data but not it needs a php service to take the mysql results and make encode them to JSON. The code the tutorial lists, with my changes, is this:code:
thegasman2000 fucked around with this message at 00:25 on Oct 21, 2014 |
# ? Oct 20, 2014 22:10 |
There could be multiple points of failure in this code. Have you got some kind of error output? If it's not erroring, then try examining the contents of $resultArray and work backwards, as this is procedural and at some point it'll be cocking up. Also $tempArray looks redundant, you can just use $row in its place. o.m. 94 fucked around with this message at 22:21 on Oct 20, 2014 |
|
# ? Oct 20, 2014 22:18 |
|
o.m. 94 posted:There could be multiple points of failure in this code. Have you got some kind of error output? If it's not erroring, then try examining the contents of $resultArray and work backwards, as this is procedural and at some point it'll be cocking up. This is the link to the file... Nothing outputted at all... I have no idea what half that code is doing to be quite frank. :/ thegasman2000 fucked around with this message at 00:25 on Oct 21, 2014 |
# ? Oct 20, 2014 22:22 |
When I request a PHP file, the server executes it and only displays the results of the code (if there is even any output), so I won't be able to read it without accessing the file directly, and anyway you've posted the code above. What you need to do here is get error logging working, and have it dump the error to the screen so you can see where your script is failing. If it's not failing, then start by examining your $resultArray variable with var_dump(), and work backwards through each step to see where you're not getting any results. Perhaps your query is wrong, etc.
|
|
# ? Oct 20, 2014 22:27 |
|
o.m. 94 posted:When I request a PHP file, the server executes it and only displays the results of the code (if there is even any output), so I won't be able to read it without accessing the file directly, and anyway you've posted the code above. with my babies first php knowledge... Is it best to add an echo after each point to see if it gets that far?
|
# ? Oct 20, 2014 22:30 |
Sure, you would want to check that your mysqli_query() call returned a truthy value, because it could not and thus the block where you're expecting output would never be executed.
|
|
# ? Oct 20, 2014 22:36 |
|
o.m. 94 posted:Sure, you would want to check that your mysqli_query() call returned a truthy value, because it could not and thus the block where you're expecting output would never be executed. http://imgur.com/RHr2jTe This means my query works right? I copied it from here.
|
# ? Oct 20, 2014 22:47 |
|
thegasman2000 posted:This is the link to the file... http://moneyspiderdesign.com/service.php The fact that there's no output at all, and that the link's status code is 500 makes me think that there is some sort of fatal error, and error reporting is turned off. If you can check the error log on that server, or turn on error reporting for a second to see what's happening, you're in luck.
|
# ? Oct 20, 2014 22:47 |
|
Mogomra posted:The fact that there's no output at all, and that the link's status code is 500 makes me think that there is some sort of fatal error, and error reporting is turned off. If you can check the error log on that server, or turn on error reporting for a second to see what's happening, you're in luck. I turned it on, I think... I uploaded a non hacked up version called OrginalService.php and it gives this error. Warning: mysqli_close() [function.mysqli-close]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in /home/dlfvyzmg/public_html/OriginalService.php on line 36 Warning: mysqli_close() expects parameter 1 to be mysqli, boolean given in /home/dlfvyzmg/public_html/OriginalService.php on line 36 for this code code:
thegasman2000 fucked around with this message at 00:24 on Oct 21, 2014 |
# ? Oct 20, 2014 22:56 |
You're trying to close the connection twice by passing in the results variable first time. You should only need to do mysqli_close($con) which is the actual connection.
|
|
# ? Oct 20, 2014 23:02 |
|
o.m. 94 posted:You're trying to close the connection twice by passing in the results variable first time. You should only need to do mysqli_close($con) which is the connection. Yeah I wondered that, so i commented out the first mysqli_close($result) and now it gives nothing again. No errors or anything.
|
# ? Oct 20, 2014 23:04 |
Okay, so you know that it isn't erroring anymore. We can therefore logically conclude that your script is not outputting anything. But we also know that you have an echo statement in the code. This leads us to two possibilities: 1. The echo line is never reached. Why might that be? Is there a condition that needs to be met before that echo line is reached? 2. The echo line is reached, but you can't see anything because it's outputting a falsy value which PHP echo will not display anything for Hint: Instead of echo, use var_dump().
|
|
# ? Oct 20, 2014 23:08 |
|
ok so I added a breakpoint and commented out the line if ($result = mysqli_query($con, $sql)) It now gets past that but errors with Fatal error: Call to a member function fetch_object() on a non-object in /home/dlfvyzmg/public_html/OriginalService.php on line 25
|
# ? Oct 20, 2014 23:19 |
If you remove the expression $result = mysqli_query(...), then you have no $result variable. If you have no $result variable, you can't call the method $result->fetch_object() on it later on in your code. We could go on like this for hours. I would reccomend you read up on PHP some more and learn to do basic debugging. Don't remove lines of code, just inspect your variables and see if they contain what you expect.
|
|
# ? Oct 20, 2014 23:23 |
|
o.m. 94 posted:If you remove the expression $result = mysqli_query(...), then you have no $result variable. If you have no $result variable, you can't call the method $result->fetch_object() on it later on in your code. Your right, I don't really want to go wading through php code though. I really only want this bloody service so I can do what I am currently learning which is Swift for IOS. The tutorial code is clearly poo poo which isnt helping, perhaps I need a new tutorial! Thanks for your help though.
|
# ? Oct 20, 2014 23:28 |
The tutorial isn't the problem (although yes that code is poo poo); it's that you aren't capable of debugging the code. Like I said, start with your point of output, and inspect it: var_dump(json_encode($resultArray)); Look at the documentation for json_encode: http://php.net/manual/en/function.json-encode.php If you get FALSE, then your argument, $resultArray has a problem. Step back through your code: var_dump($resultArray); It may be that your $resultArray is empty. Find out why. Keep stepping back through the code, examining the contents of each variable 'til you find the problem.
|
|
# ? Oct 20, 2014 23:34 |
|
So, I've been tasked with putting a video on our website. Easy enough just using HTML5. Here are the problems: 1. The video changes two to three times a day (kind of like a podcast but relating to our industry) and I don't want to be doing this manually. 2. I get the videos via FTP access which has access to all the videos in the root ftp folder, all named with no standard. 3. It does appear that I could use the date modified timestamp to show the latest video. What is the best way to go about this? kiwid fucked around with this message at 18:11 on Oct 21, 2014 |
# ? Oct 21, 2014 18:06 |
|
Well, there's ext/ftp, which you probably have installed already. You can use that to poke around and pull files down, but it'll be clunky.
|
# ? Oct 21, 2014 18:58 |
|
- Crontab shell script runs hourly and connects to FTP to check for new video based off timestamp. Store timestamp in a plain text file that the shell script can consult - If it finds a video, copy it to webroot If you just need the latest video then keep the file name the same and overwrite it and you're done. If you need to be able to show previous videos then you'll probably need to write a CLI php script that is triggered from the shell script that goes and does whatever database updates you need. This is all assuming your video codec is automatically HTML5-friendly and ready to post. You'll need to do some homework to find a way to automate FTP via a shell script but it shouldn't be too hard to figure out.
|
# ? Oct 21, 2014 18:58 |
|
revmoo posted:- Crontab shell script runs hourly and connects to FTP to check for new video based off timestamp. Store timestamp in a plain text file that the shell script can consult Yeah I can definitely figure out the specifics. I just wanted to know the general flow of how you'd do it and this post just confirms essentially the way I was thinking of doing it in the first place. Luckily the video is HTML5-friendly so this should be as straight forward as you detailed. McGlockenshire posted:Well, there's ext/ftp, which you probably have installed already. You can use that to poke around and pull files down, but it'll be clunky. Is PHP's built in FTP functionality the way to go or is there something like Guzzle but for FTP out there that is better? kiwid fucked around with this message at 19:45 on Oct 21, 2014 |
# ? Oct 21, 2014 19:41 |
|
gently caress, so I tried to implement this tonight...php:<? // connect to the ftp server $conn = ftp_connect($server); ftp_login($conn, $username, $password); ftp_pasv($conn, true); // get all mp4 files into an array with date modified timestamp $data = []; $files = ftp_nlist($conn, ''); foreach ($files as $file) { if (pathinfo($file, PATHINFO_EXTENSION) == 'mp4') { $data[$file] = ftp_mdtm($conn, $file); } } arsort($data, SORT_NUMERIC); // sort the array by date modified, newest first $video_time = Settings::get('video_time'); // get the date modified of the last file downloaded // foreach mp4 file, if file is newer or doesn't exist, download it foreach ($data as $file => $time) { if (($time > $video_time->value) || ( ! file_exists('video/video_comments.mp4'))) { ftp_get($conn, 'video/video_comments.mp4', $file, FTP_BINARY); Settings::update('video_time', $time); } break; // only check the newest file } ftp_close($conn); ?> edit: to be exact, there are 5997 files in this ftp directory + 10ish every day. kiwid fucked around with this message at 02:52 on Oct 22, 2014 |
# ? Oct 22, 2014 02:42 |
|
kiwid posted:I'm running into 504 gateway timeout issues (30seconds). Would that be because there is like 1000 video files among thousands of other types of files, like .jpg, .gif, etc. in the FTP directory? So, plan A: modification time won't be changing on these files, right? If so, it'll probably be safe to cache the result of the ftp_mdtm calls, which are probably what's sucking up all the run time. Plan B: Run it by cron, no worries about hitting a gateway timeout that way, and you can just disable the execution time limit if need be. Plan C: Hire a team of assassins to take out the idiots upstream responsible for the video delivery method and have it replaced with something sane that involves active notifications of new or changed content instead of having to index a few thousand things every time.
|
# ? Oct 22, 2014 09:05 |
|
At work, I run a unix command using watch to view the queue on our PBX, ideally I'd like to find a way to show this in a browser also in real time. Is there a way in PHP to basically to view the live output of a command through shell_exec?
|
# ? Oct 22, 2014 13:47 |
|
McGlockenshire posted:So, plan A: modification time won't be changing on these files, right? If so, it'll probably be safe to cache the result of the ftp_mdtm calls, which are probably what's sucking up all the run time. Definitely would like to go with Plan C. However, I'll give Plan A a try. Another option I was thinking was to use the ftp_rawlist command and parse the date/time from that. It's a bit messier but I can get a rawlist in 7 seconds, rather than timing out.
|
# ? Oct 22, 2014 14:14 |
|
Experto Crede posted:At work, I run a unix command using watch to view the queue on our PBX, ideally I'd like to find a way to show this in a browser also in real time. Allowing shell execution is not really best practice, but it's possible. Writing the output to a file accessible to the web server would be better. Then have a HTML page that picks up the file with some javascript and updates it. Could be a quick little React/Ember/Angular thing (the latter two if you wanted to over engineer it).
|
# ? Oct 22, 2014 21:17 |
|
Experto Crede posted:At work, I run a unix command using watch to view the queue on our PBX, ideally I'd like to find a way to show this in a browser also in real time. You can use popen() instead of shell_exec(), which will give you a stream you can read from just like a file.
|
# ? Oct 22, 2014 22:08 |
|
|
# ? Jun 8, 2024 03:26 |
|
Does anyone know a way to get the SSH2 functions to connect via a proxy? Or any SSH library that will let me connect via a proxy? The only other thing I can think of doing is using proc_open('proxychains ssh...') but I really don't want to wrangle the input/output pipes if I can help it.
|
# ? Oct 22, 2014 22:29 |