Web Global Net Web Application & Web Development Project Center

Technical Issues => FCK/CKEditor => Topic started by: admin on August 17, 2010, 05:35: PM



Title: making the image directory dynamic
Post by: admin on August 17, 2010, 05:35: PM
ok here is what I did - maybe not the best way but it works and that is all I cared about.

This only works if you use a session variable because there is no way to grab a URL - that we can figure out

In the /ckfinder/config.php

First included the connection file on the first line of the page

<?php include("association.php"); ?> For some reason Require Once did not work.

You need to start the session do it like this

<?php include("association.php"); ?>
<?php
session_start();
/*
 * ### CKFinder : Configuration File - Basic Instructions

I then created the record set at the beginning of the file using dreamweaver which created the session variable I needed, tip though move the connection file to the ckfinder directory first.

Next I moved all this code that Dreamweaver created :

CODE: SELECT ALL
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$colname_rsownid = "-1";
if (isset($_SESSION['own_id'])) {
  $colname_rsownid = $_SESSION['own_id'];
}
mysql_select_db($database_association, $association);
$query_rsownid = sprintf("SELECT * FROM associations WHERE assoc_id = %s", GetSQLValueString($colname_rsownid, "int"));
$rsownid = mysql_query($query_rsownid, $association) or die(mysql_error());
$row_rsownid = mysql_fetch_assoc($rsownid);
$totalRows_rsownid = mysql_num_rows($rsownid);



To just above the $baseUrl setting

Next I set this as follows

$baseUrl = '/assets/assoc/'.$_SESSION['own_id'].'/';

and the $baseDir as follows

$baseDir = '/home/assoc/public_html/assets/assoc/'.$_SESSION['own_id'].'/';



at the beginning of the file like this

<?php include("association.php"); ?>
<?php
session_start();
/*
 * ### CKFinder : Configuration File - Basic Instructions


at the bottom of the file make sure your place the mysql_free_result as shown below

$config['plugin_imageresize']['largeThumb'] = '180x180';

mysql_free_result($rsad);