protected moodledata folder (for moodle 2.2 installation) in shared 1and1 hosting - permissions

I'm trying to install Moodle 2.2 on a shared linux 1and1 server. Following the web installation, I get to the step where it asks for the path of the moodledata folder. I've read that I need to put it somewhere without public access, which I believe means in a level above the public web root folder.
So if the public web root folder is: /homepages/44/d**/htdocs
the folder path should go be: /homepages/44/d**/moodledata
The problem is that when I want to create a folder there (connecting with ssh), I get a "permision denied" error.
I've contacted 1and1 and they're telling me that with my hosting package (dual unlimited) it's not possible to create folder in levels above the public web folder, and that I should upgrade the hosting package.
Is that the only way? Can I get a protected folder like moodle demands without having to upgrade the hosting package?

If you know what you are doing you can execute the following steps to install moodledata inside Moodle directory.
These modifications will turn off moodle verification about moodledata safety requisites.
You have to edit the file called in the root of moodle folder install.php.
Near line 230 put comments around the following code:
/*
while(is_dataroot_insecure()) {
$parrent = dirname($CFG->dataroot);
$i++;
if ($parrent == '/' or $parrent == '.' or preg_match('/^[a-z]:\\\?$/i', $parrent) or ($i > 100)) {
$CFG->dataroot = ''; //can not find secure location for dataroot
break;
}
$CFG->dataroot = dirname($parrent).DIRECTORY_SEPARATOR.'moodledata';
}
*/
Near line 300 put comments around the following code:
/*
else if (is_dataroot_insecure()) {
$hint_dataroot = get_string('pathsunsecuredataroot', 'install');
$config->stage = INSTALL_PATHS;
}
*/

Related

How to get Physical Path for virtual path in .NET 6 RC1?

The question is related to Blazor wasm hosted App.
I am resolving _webHostingEnvironment in constructor of the controller.
_webHostingEnvironment = serviceProvider.GetRequiredService<IWebHostEnvironment>();
I am running into issue where I don't get correct value for the virtual director's physical path.
My app generates a QR code which I need to store in the images folder of virtual directory.
var webRootPath = "";
if (string.IsNullOrWhiteSpace(_webHostingEnvironment.WebRootPath))
webRootPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot");
else
webRootPath = _webHostingEnvironment.WebRootPath
Firstly _webHostingEnvironment.WebRootPath is always null, hence the code always gets the path from Directory.GetCurrentDirectory().
Directory.GetCurrentDirectory provides the path of Server, but not the actual deployed path of wwwroot which is further down like /bin/debug/net6.0/wwwroot.
Here is the screenshot of the code in question
Now I could append that static path to get full path, but no sure what to use when I deploy it on Azure App Service or while using other deployment models

Rotativa file not found on server only

I am using Rotativa ActionasPDF() to generate a pdf from a view in my MVC4 project. It works flawlessly on my local instance, but I just copied the entire solution to my server and it does not work. I get the error "The system cannot find the file specified", but I'm not sure what file it is talking about. I assume it is talking about the Rotativa dll, but I've got the generated Rotativa folder on my server as well. The solution is an exact duplicate as my local copy. My site is hosted on IIS 8, windows 2012 server. Research has told me I could have a permissions issue with some folder, but I'm not sure which ones they would be. I just set all my controller & views to 777 permissions for the time being. No luck. Any ideas to what I'm missing, or how I can make sure the dll is registered on my server?
Here is my controller action method:
public ActionResult DownloadFile(int id = 0)
{
var filename = string.Format("Invoice{0}.pdf", id);
return new ActionAsPdf("Invoice" + "/" + id, new { name = "Invoice" + id }) { FileName = filename, PageSize = Size.Letter, PageOrientation = Orientation.Portrait, PageMargins = new Margins(0, 0, 0, 0) };
}
Check if you add all files in rotativa directory on server-
libeay32.dll
wkhtmltopdf.exe
etc.
Old thread but I had the same issue so I wanted to share the solution for people searching in the future.
Ensure you have the correct VS Redistributable installed on the server, or files in the Rotativa folder.
Use the server IP address instead of the DNS name. I do not know why this works but will edit this if I figure it out.
You need to have Visual C++ Redistributable Packages on the server. You can download the packages from here: http://www.microsoft.com/en-gb/download/details.aspx?id=40784
You need update Rotativa, Rotativa.Core, Rotativa.MVC in Nuget

Unable to configure SabreDAV to test Webdav and CardDAV

Steps I followed:
Downloaded the Sabredav zip file - unzipped it.
Downloaded apache webserver 2.2 and PHP 5.3
Then followed the instructions mentioned in the 'get Started' section on Sabredav website.
Created 'data and public' fiels (located them in /sabredav/vendor/)
Created the server.php file (located it in /sabredav/vendor/)
Now tried to open the server.php file in browser -
Here it opens using the file protocol..
Fails to open in expected - 'http ://mydomain/sabredav/server.php
Can anybody please help me on this ?
Thanks
In server.php, use the browser plugin tu see files in Public folder.
Your server must be like this:
include 'SabreDAV/vendor/autoload.php';
use
Sabre\DAV;
$rootDirectory = new DAV\FS\Directory('public');
// The server object is responsible for making sense out of the WebDAV protocol
$server = new DAV\Server($rootDirectory);
// If your server is not on your webroot, make sure the following line has the correct information
$server->setBaseUri('/server.php'); // if its in some kind of home directory
// The lock manager is reponsible for making sure users don't overwrite each others changes. Change 'data' to a different
// directory, if you're storing your data somewhere else.
$lockBackend = new DAV\Locks\Backend\File('data/locks');
$lockPlugin = new DAV\Locks\Plugin($lockBackend);
$server->addPlugin($lockPlugin);
$server->addPlugin(new \Sabre\DAV\Browser\GuessContentType());
$plugin = new \Sabre\DAV\Browser\Plugin();
$server->addPlugin($plugin);
// All we need to do now, is to fire up the server
$server->exec();

wrong paths on multi website magento install

I am running a magento 1.7.0.2 instance with WAMP 2.1 on Windows 7. My goal is to set up one magento store, and one
I followed the tutorial described here and I setup website profi on a subdirectory, but when I accessed the frontend on http://localhost/profi/ the first thing I noticed that the images paths were broken.
Broken: http://localhost/bms/profi/skin/frontend/default/default/images/logo.gif
Correct:
http://localhost/bms/skin/frontend/default/default/images/logo.gif
This is the same for the JS & CSS files. I've made the following modifications to the index.php file in the profi folder:
$mageFilename = MAGENTO_ROOT . '../../app/Mage.php';
/* Store or website code */
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : 'profi';
/* Run store or run website */
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'website';
It was a matter of configuring the second website's URLs.
I went to System > Configuration > General > Web > Unsecure. The Base URL was http://localhost/profi/ and I added ../ to the following the following:
Base Skin URL: {{unsecure_base_url}}../skin/
Base Media URL: {{unsecure_base_url}}../media/
Base JavaScript URL: {{unsecure_base_url}}../media/
That did the trick. I see on the frontend everything looks in order. Hope I won't run into anymore problems with this set-up.

Zero dependency from the client configuration files for WCF services

Our aim is to have Zero dependency from the client configuration files for WCF services.
we are using ConfigurationChannelFactory() to create the channel and specify the ConfigSettings.
ConfigSettings is loaded using the following code
ConfigurationManager.OpenExeConfiguration(ConfigFilePath);
So we have to provide the ConfigFilePath here.
we have both windows and web clients.
we have used below approaches to find out the path
AppDomain.CurrentDomain.BaseDirectory + "bin\\" + executingAssembly.GetName().Name + ".dll"
Web client : AppDomain.CurrentDomain.BaseDirectory gives root folder of the
web applicaton so its works fine
Windows client : AppDomain.CurrentDomain.BaseDirectory gives path upto Debug/Release folder
so, its throws error
Assembly.GetExecutingAssembly().Location
Web client : Assembly.GetExecutingAssembly().Location gives path to the ASP.Net temp.
files , where we dont have the config files. So its throws an error.
Windows client : Assembly.GetExecutingAssembly().Location gives the correct location,
so its works fine.
In order to make it works in web clients, we have to add the following key in client's web.config files.
<hostingenvironment shadowcopybinassemblies="false">
but it adds a dependency to the clients.
Can you guys please help me to find the path without worrying about the clients?
have you tried this? I used GetCallAssembly() instead of GetExecutingAssembly() as this lives in a utility class in our project.
public static string AssemblyDirectory
{
get{
string codeBase = assembly.GetCallingAssembly().CodeBase;
UriBuilder uri = new UriBuilder(codeBase);
string path = Uri.UnescapeDataString(uri.Path);
return Path.GetDirectoryName(path);
}
}
Could you just probe both paths? In other words, check the Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin") folder and if you can't find the config file in there, check the Assembly.GetExecutingAssembly().Location folder instead? Since you indicate that the first approach works for web but not Windows clients, while the second approach works for Windows clients but not web, go with both!