I'm having some trouble using scandir - I have it working fine on one site but now I'm wanting to scan the same directory on that site but from a different website.
I'm using the following code:
array_diff(scandir('http://sub.domain.co.uk/folder/folder/'), array('.', '..'));
and I get this error:
Warning: scandir(http://sub.domain.co.uk/folder/folder/): failed to open dir: not implemented
I've had a Google but brought up very little - I've tried enabling directory listing on the external site and allow_fopen_url is enabled as well.
I'm stumped, any help with this one?
Assuming you have the ftp extension loaded in PHP (PHP: FTP), you could:
$connect = ftp_connect($ftp_server);
$login_result = ftp_login($connect, $username, $password);
$contents = ftp_nlist($connect, ".");
print_r($contents);
This turned out to be a loop back problem, I was trying to scan a a folder on the same domain which was not allowed with my host.
I've had to introduce a 'state' to deal with this which says whether the software is live or not (because the software, once live, will actually point to a different domain).
Related
I need some help installing Moodle v3.7.2.
I've passed all checks for server configuration during installation, except for the fact that the site is recognized as http instead of https, maybe because of the proxy that sits in front of the nginx serving Moodle. Anyway, when I try to load the first page, I receive a generic error:
$string['servererror'] = 'An error occurred whilst communicating with the server';
I've investigated the source code for this error, and found the motivation:
On path /moodle/lib/classes/session/manager.php, row 90, this check fails:
if (!self::$handler->start())
The start() method is simply calling a php function:
session_start();
That returns FALSE and throw the exception. Any idea on how to solve this? Many thanks.
EDIT: I've also tried storing sessions on database:
$CFG->session_handler_class = '\core\session\database';
$CFG->session_database_acquire_lock_timeout = 120;
But with no luck, now the function that fails is:
session_set_save_handler
I have run into the same issue when installing Moodle 3.8 on a Windows-Subsystem-for-Linux (WSL) based Debian development server. Adding the config to switch to database sessions fixed it for me:
$CFG->session_handler_class = '\core\session\database';
$CFG->session_database_acquire_lock_timeout = 120;
I'm thinking that the WSL permissions are problematic when the Moodle data directory falls outside the moodle vhost path, so Moodle cannot read/write properly to the sessions path (yet I do see session files being created). You must delete the browser cookies/restart your browser after setting sessions to the database.
This is more of a generic solution, but did you check your $CFG->wwwroot in your config.php file? It has to be something like 'https://your.site.com/'. If you forget the s Moodle won't be able to build a connection if you configured your Webserver / proxy to forward users to :443.
I ran in this problem quite often, when I configured SSL for our Moodle Server.
I'm having the issue with fopen() on google app engine. Works normal 3-4 times and than this response from server.
Message: fopen(https://website_url/image_name.png): failed to open
stream: Connection closed.
Any idea how to troubleshoot what happened and why?
$image = "https://website_url/image_name.png";
$f = fopen($image,'rb');
php ini has allow_url_fopen = On
First make sure you have the correct path.
You need to give fopen the full path of the file, and you don't need chdir() at all. Try this version:
$path_to_file='url';
$fh = fopen($path_to_file.$filename, 'w') or die('Permission error');
Everything is working fine on localhost but first I host the website after up and downs and overcoming over I got stuck at this problem:
file_get_contents(http://....): failed to open stream: Connection timed out
I have not used file_get_function anywhere in my code but it is giving the error. Where is this coming from?
What does Connection time out mean? I checked on SOF but I get more and more confused. Any help will be appreciated!
Can anyone give a detailed explanation or link?
There could be two main reasons for this:
Your server cannot resolve the domain name (try nslookup from shell) - if this is the problem, you can try to set Google nameservers (8.8.8.8, 8.8.4.4)
There are firewall restrictions, which do not allowed to make inbound/outbound connection from your server
You can try out a cURL connection instead, maybe this helps.
file_get_contents() does not deal with slow network connections or redirects for getting remote files. You can use fsockopen() which allow a custom connection timeout value
try to use cURL
See this TIP in the php manual
A URL can be used as a filename with this function if the fopen
wrappers have been enabled. See fopen() for more details on how to
specify the filename. See the Supported Protocols and Wrappers for
links to information about what abilities the various wrappers have,
notes on their usage, and information on any predefined variables they
may provide.
If your live site does not have allow_url_fopen = On then this function will not allow you to use url's
I'm using fopen to create a new file. On my localserver it works fine, however on my webserver (linux shared hosting with goDaddy) I get:
Warning: fopen(invoices/qbImport519.iif) [function.fopen]: failed to open stream: No such file or directory in /home/content/c/h/i/chiseled/html/tracking_admin/qbInvoices.php on line 97
Thinking that it was settings on the webserver, I contacted GoDaddy who responded that everything was setup on my account correctly for this to work. Any ideas?
Here's is my code:
$qbFile = fopen("invoices/qbImport".$Hits.".iif","ab");
if (is_writable("invoices/qbImport".$Hits.".iif")){
if (fwrite($qbFile,$iifWrite)){
echo'Download Your File<br/>';
else {
echo "<p>Cannot add your entry</p>";
}
}
else {
echo "<p>The file is not writeable</p>";
}
fclose($qbFile);
I have tried the paths /home/content/c/h/i/chiseled/html/tracking_admin/invoices and invoices/.
The file does not exists since it's based on the $hits variable which is incremented each time. So for some reason it's not able to create the new file. I have also tried just a for the fopen mode.
Any help would be great. thanks.
I had created the directory as "Invoices" not "invoices". No more coding till 4am!
it is because fwrite is not supported in godaddy. godaddy has alot of restriction. It is better you go with other good hosts like bluehost, ipage. Godaddy may be good in domains but hosting is poor. even wordpress won't run perfectly in godaddy.
Matt Mullenweg the creator of wordpress says that
http://wordpress.org/support/topic/more-godaddy-installation-problems
When my script parses an RSS feed from my local Apache server, it parses fine but when I upload script to the remote hosting server it gives the error:
Warning: Magpie RSS: Failed to fetch (url) and cache is off in magpierss-0.6/rss_fetch.inc
on line 231.
I have searched for possible answers and any suggestions are around enabling and changing cache lifetime. I think that is not the problem - it looks like the problem is with remote hosting Apache server or denied access to my host.
Can anyone help?
check that magpie can open the rss url. Usually with curl being enabled or allow_url_fopen on your server. Also make sure that magpie is able/allowed/permitted to create caching files (if any)
This could be caused by a bad url, the server is busy or not having remote file access allowed in your host.
$errormsg = "Failed to fetch $url "; in source indicative of problem getting to host.
Try checking access from the remote host - if you have ssh & curl enabled just do
curl (url)