how to include same file in different directory? - linux

Directory structure :
Main directory structure
home.php
thankyou.php
Php directory structure
root directory/php/date.php
Include directory structure
root directory/include/header.php
root directory/include/footer.php
Images directory structure
root directory/images/logo.png
root directory/images/abc.jpg
For date.php, i want to use header and footer.php files. but images are not shown.
i written below code
<?php require_once '../include/header.php';?>
But when i used for home and thankyou.php, It is working fine.
In header file, code for images
<img src="images/logo.png" alt="Logo" class="image">
i dont want to change directory for date.php. And not interested to absolute path for images.
What to do so that images will be see in both directory()

i Used base html tag as doubleui told me in head section
<head>
<base href="root directory/images/" target="_blank">
</head>

Related

Image not rendering in md format file in Gitlab

I have a directory called "features" in the root and inside this directory has image "state_transitation.JPG" and document "myMdc_features.md"
I am trying to add an image "state_transitation.JPG" to the md extension document "myMdc_features.md" in my repository by using markdown below:
![alt text](./state_transitation.JPG)
![alt text](/state_transitation.JPG)
![alt text](state_transitation.JPG)
<p>
<img src="state_transitation.JPG" />
</p>
I tried all above options but this is giving page could not be found error. 404
Both myMdc_features.md and image file are in same path/directory.
What is the correct way to display an image in gitlab myMdc_features.md?
I think that the first option should work, assuming they are in the same folder. I made an example repostiory here that works.
Source of the file:
Hello World
![](./i-have-no-idea-what-im-doing.jpg)
Output in GitLab:

Public uploaded files not showing

I'm having problems with displaing uploaded files on public folder. I always get 404 error every time I try to load files from public folder.
All tests over file uplad pass well, file can be loaded, file is present in database and in public folder, the symlink is created but I can't display contents from public folder.
the main parts of the code:
uploaderController.php
$path = $request->file( 'userfile' )->store( 'logos', 'public' );
after this the folder in:
/storage/app/public/logos/file.ext
using the file in blade template:
<img src="{{ asset( $model->image_path ) }}" />
response from the browser 404 - Page not found
more info about the server folders:
/public/storage - this is the symlink to the public folder 777 permission
/storage/app/public - the storage public folder 775 permission
/storage/app/public/logos - the logo folder 755 permission
/storage/app/public/logos/file.ext - the file 644 permission
I try change permission to 775 on file but always 404
How can I fix this problem?
Thanks
[edit]
I found a difference from another server where I can see public files. The symlink in that server has a green background when ls -l
The solution to this question is that inside uploaderController.php when you save the path of your uploaded file you MUST prepend the "storage" folder.
uploaderController.php
$path = $request->file( 'userfile' )->store( 'logos', 'public' );
$data = [ 'image_path'=>"storage/{$path}" ];
$model->update( $data );

ColdFusion Hardlink vs SoftLink traversal searching for Application.cfc (Solaris)

Using the following directory structure on a Solaris 11.3 box running ColdFusion 11. Apache is configured to follow Symbolic links. I have tried using all the following ColdFusion configuration options ( Default order, Until webroot, In webroot). The test2.cfm wont grab the #DATASOURCE# from the Application.cfm and so it is undefined.
/webroot
- Application.cfm
/dir1
/dir2
/dir3
-test1.cfm
/dir4 (softlink to random directory)
-test2.cfm
---------Application.cfm-------------
<CFSET DATASOURCE = "bob" >
<CFAPPLICATION NAME = "bob_app" SESSIONMANAGEMENT = "YES" >
<CFSET SESSION.USERID = "0" >
---------test1/test2.cfm-------------
<cfoutput>
The data source name is #DATASOURCE#
</cfoutput>
Any Suggestions on how to properly add the symbolic link so that search path includes the Application.cfm in the linked directory parent.
I suspect the traversal is getting messed up in the upward recursion because the directory operations are scanning upward from the absolute path of the symlinked directory - which is why symlinks aren't a good pattern for anything traversing up.
I would suggest not using symlinks for any directories which are extensions of the main application - other than static assets.
Alternately, though it's messy and less than ideal, you could just add an Application.cfm to those directories and add <cfinclude template="/Application.cfm"/> ( or include "/Application.cfm"; ) in a <cfscript> block to the beginning of the file.

Relative paths in twig or absolute in PhpStorm

I'm new to twig. I'm using it in PhpStorm and have problem with paths.
Here is my folder structure:
- template /folder/
- main.twig
- common /folder/
- bootstrap.twig
- nav.twig
In main.twig I have code:
{% extends "common/bootstrap.twig" %}
When I Ctrl + Click on link PhpStorm opens correct file.
But in bootstrap.twig I have to write:
{% include "common/nav.twig" %}
and then Ctrl + Click is not working.
I cannot use relative paths like nav.twig or ./nav.twig - twig throws error.
How can I make twig to use relative paths so go to source would work in PhpStorm?
Mark your template root folder (template in your case) as Resource Root (either via right click in Project View or via Settings/Preferences | Directories).
https://www.jetbrains.com/help/phpstorm/2016.2/configuring-folders-within-a-content-root.html?search=directories
Files under a folder marked as Resource Root can be referenced relative to this folder.

How to get the current parent directory in .htaccess?

how will I get the current parent directory in htaccess? I'm working on redirecting the page when error 404 is found... Here is my code...
ErrorDocument 404 /sitewylog/www/404-redirect.php
but when the directory changes like, /sitewylog/www/404-redirect.php turns to /some-new-name/www/404-redirect.php because someone pulled my copy to a different folder name (eg. using RapidSVN).. It produces an error that says, 404.html not found.. because the 404-redirect.php contains this code...
<?php
include_once '../config.php';
header('Location: /'.ROOT.'/www/404.html');
exit;
?>

Resources