CKFinder Quick Start Guide

This website contains links to software which is either no longer maintained or will be supported only until the end of 2019 (CKFinder 2). For the latest documentation about current CKSource projects, including software like CKEditor 4/CKEditor 5, CKFinder 3, Cloud Services, Letters, Accessibility Checker, please visit the new documentation website.

If you look for an information about very old versions of CKEditor, FCKeditor and CKFinder check also the CKEditor forum, which was closed in 2015. If not, please head to StackOverflow for support.

(Created page with '== The CheckAuthentication() function<br> == By default, CKFinder will not work due to authentication restrictions. You must first be sure that you have configured it properly, …')
 
(Article content moved to a template)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
== The CheckAuthentication() function<br> ==
+
{{CKFinder_2.x_CheckAuthentication}}
  
By default, CKFinder will not work due to authentication restrictions. You must first be sure that you have configured it properly, and then enable it.
+
<source lang="php">function CheckAuthentication()
 
 
Once you have completely configured CKFinder, you are ready to enable it for use. The CheckAuthentication() function is used for that. In this function, you must implement the code that ensures that the requests are coming from an authenticated user. This is usually done by assigning a session variable when the user logs on your system.
 
 
 
Return "true" if the user is properly authenticated. We strongly recommend you to NOT simply return "true" from this function without implementing authentication checks. Anonymous users would be able to use CKFinder, including uploading and deleting files from your server.
 
 
 
The following is a sample implementation for it:
 
<source>function CheckAuthentication()
 
 
{     
 
{     
 
return isset($_SESSION['IsAuthorized']) && $_SESSION['IsAuthorized'];
 
return isset($_SESSION['IsAuthorized']) && $_SESSION['IsAuthorized'];
Line 14: Line 7:
 
</source>
 
</source>
  
{{CKFinder_2.x Sessions|lang=PHP}}
+
{{CKFinder_2.x Sessions note|lang=PHP}}
=== License ===
 
  
If you purchased CKFinder you should put your license key in the config.php file:
+
{{CKFinder_2.x License|file=<code>config.php</code>|code=
 
<source lang="php">$config['LicenseName'] = 'put your license name here';
 
<source lang="php">$config['LicenseName'] = 'put your license name here';
$config['LicenseKey'] = 'put your license key here';</source>  
+
$config['LicenseKey'] = 'put your license key here';</source>}}
If you leave this fields blank CKFinder will be fully functional but it will be ruining in demo mode.
 
  
=== baseUrl ===
+
{{CKFinder_2.x baseUrl|baseUrl=$baseUrl|code=
 
 
The '''$baseUrl''' is the base path used to build the final URL for the resources handled in CKFinder. Examples:
 
 
<source lang="php">$baseUrl = 'http://example.com/ckfinder/files/';
 
<source lang="php">$baseUrl = 'http://example.com/ckfinder/files/';
$baseUrl = '/userfiles/';</source>
+
$baseUrl = '/userfiles/';</source>}}
If you leave this field empty the default value (/userfiles/) will be used. Notice that the trailing slash is required.
 
 
 
=== baseDir ===
 
  
The '''$baseDir''' is the path to the local directory (in the server) which points to the above $baseUrl URL. This is the path used by CKFinder to handle the files in the server. Full write permissions must be granted to this directory. Examples:
 
  
You may point it to a directory directly:
+
{{CKFinder_2.x baseDir|baseUrl=$baseUrl|baseDir=$baseDir|code1=
 
<source lang="php">$baseDir = '/home/login/public_html/ckfinder/files/';
 
<source lang="php">$baseDir = '/home/login/public_html/ckfinder/files/';
$baseDir = 'C:/SiteDir/CKFinder/userfiles/';</source>
+
$baseDir = 'C:/SiteDir/CKFinder/userfiles/';</source>|code2=
Or you may let CKFinder discover the path, based on $baseUrl:
+
<source lang="php">$baseDir = resolveUrl($baseUrl);</source>|code3=
<pre>$baseDir = resolveUrl($baseUrl);</pre>
+
<source lang="php">$baseUrl = '/userfiles/'</source>|code4=
Remember that CKFinder will only discover the path when the base url is a local web path ( relative to document root ).<br>Example:
+
<source lang="php">$baseUrl = 'http://example.com/ckfinder/files/'</source>}}
<pre>$baseUrl = '/userfiles/'</pre>
 
If it is a full URL address.<br>Example:
 
<pre>$baseUrl = 'http://example.com/ckfinder/files/'</pre>
 
the path won't be discovered. Notice that the trailing slash is required.
 

Latest revision as of 14:20, 31 March 2011

This article describes how to get CKFinder up and running by adjusting some basic settings.

The CheckAuthentication() Function

By default, CKFinder will not work due to authentication restrictions. You must first make sure that you have configured it correctly, and then enable it.

Once you have completely configured CKFinder, you are ready to enable it for use. The CheckAuthentication() function is used for that. In this function you must implement the code ensuring that the requests are coming from an authenticated user. This is usually done by assigning a session variable when the user logs into your system.

If the user is properly authenticated, the fuction should return true. We strongly recommend you to NOT simply return true from this function without implementing authentication checks. Without authentication support anonymous users would be able to use CKFinder on your website, including uploading and deleting files from your server.

The following is a sample implementation of the CheckAuthentication() function:

function CheckAuthentication()
{    
	return isset($_SESSION['IsAuthorized']) && $_SESSION['IsAuthorized'];
}

For more information about using session variables refer to the Sessions article.

License

If you purchased CKFinder, you should put your license key in the config.php file:

$config['LicenseName'] = 'put your license name here';
$config['LicenseKey'] = 'put your license key here';

If you leave these fields blank, CKFinder will be fully functional, but it will be running in demonstration mode.

$baseUrl

The $baseUrl is the base path used to build the final URL for the resources handled by CKFinder.

Examples:

$baseUrl = 'http://example.com/ckfinder/files/';
$baseUrl = '/userfiles/';

If you leave this field empty, the default value (/userfiles/) will be used.

important note

Please note that the trailing slash is required.


$baseDir

The $baseDir is the path to the local directory (on the server) which points to the $baseUrl URL described above. This is the path used by CKFinder to handle the files on the server. Full write permissions must be granted to this directory.

You may point it to a directory directly:

$baseDir = '/home/login/public_html/ckfinder/files/';
$baseDir = 'C:/SiteDir/CKFinder/userfiles/';

Or you may let CKFinder discover the path based on $baseUrl:

$baseDir = resolveUrl($baseUrl);


Bear in mind that CKFinder will only discover the path, when the base URL is a local Web path (relative to document root). Example:

$baseUrl = '/userfiles/'

If it is a full URL address, like the following one:

$baseUrl = 'http://example.com/ckfinder/files/'

the path will not be discovered.

important note

Please note that the trailing slash is required.

This page was last edited on 31 March 2011, at 14:20.