Ejemplo n.º 1
0
/** Convert PHP data structure to Javascript */
function xinha_to_js($var, $tabs = 0)
{
    if (is_numeric($var)) {
        return $var;
    }
    if (is_string($var)) {
        return "'" . xinha_js_encode($var) . "'";
    }
    if (is_bool($var)) {
        return $var ? 'true' : 'false';
    }
    if (is_array($var)) {
        $useObject = false;
        foreach (array_keys($var) as $k) {
            if (!is_numeric($k)) {
                $useObject = true;
            }
        }
        $js = array();
        foreach ($var as $k => $v) {
            $i = "";
            if ($useObject) {
                if (preg_match('#^[a-zA-Z]+[a-zA-Z0-9]*$#', $k)) {
                    $i .= "{$k}: ";
                } else {
                    $i .= "'{$k}': ";
                }
            }
            $i .= xinha_to_js($v, $tabs + 1);
            $js[] = $i;
        }
        if ($useObject) {
            $ret = "{\n" . xinha_tabify(implode(",\n", $js), $tabs) . "\n}";
        } else {
            $ret = "[\n" . xinha_tabify(implode(",\n", $js), $tabs) . "\n]";
        }
        return $ret;
    }
    return 'null';
}
Ejemplo n.º 2
0
                if ($include && !preg_match($include, $url) || $exclude && preg_match($exclude, $url)) {
                    continue;
                }
                $files[] = array('url' => $url);
            }
        }
    }
    @closedir($dh);
    return dirsort($files);
}
function dbnavi()
{
    return $_SESSION['RheinaufCMSLinker'];
}
function dirsort($files)
{
    usort($files, 'dircomp');
    return $files;
}
function dircomp($a, $b)
{
    if (is_array($a)) {
        $a = array_shift($a);
    }
    if (is_array($b)) {
        $b = array_shift($b);
    }
    return strcmp(strtolower($a), strtolower($b));
}
echo xinha_to_js(array_merge(scan($dir), dbnavi()));
Ejemplo n.º 3
0
                if ($subdir = scan($path, $url)) {
                    $files[] = array('url' => $url, 'children' => $subdir);
                }
            } elseif (is_file($path)) {
                if ($include && !preg_match($include, $url) || $exclude && preg_match($exclude, $url)) {
                    continue;
                }
                $files[] = array('url' => $url);
            }
        }
    }
    @closedir($dh);
    return dirsort($files);
}
function dirsort($files)
{
    usort($files, 'dircomp');
    return $files;
}
function dircomp($a, $b)
{
    if (is_array($a)) {
        $a = array_shift($a);
    }
    if (is_array($b)) {
        $b = array_shift($b);
    }
    return strcmp(strtolower($a), strtolower($b));
}
echo xinha_to_js(scan($dir));
Ejemplo n.º 4
0
                if ($subdir = scan($path, $url)) {
                    $files[] = array('url' => $url, 'children' => $subdir);
                }
            } elseif (is_file($path)) {
                if ($include && !preg_match($include, $url) || $exclude && preg_match($exclude, $url)) {
                    continue;
                }
                $files[] = array('url' => $url);
            }
        }
    }
    @closedir($dh);
    return dirsort($files);
}
function dirsort($files)
{
    usort($files, 'dircomp');
    return $files;
}
function dircomp($a, $b)
{
    if (isset($a['children']) && !isset($b['children'])) {
        return -1;
    }
    if (isset($b['children']) && !isset($a['children'])) {
        return 1;
    }
    return strcmp(strtolower($a['url']), strtolower($b['url']));
}
echo xinha_to_js(scan($dir, $url));
    }
    @closedir($dh);
    return dirsort($files);
}
function dbnavi()
{
    if (!$_SESSION['RheinaufCMSLinker']) {
        ob_start();
        $system = new RheinaufCMS();
        $system->linker_navi();
        ob_end_clean();
    }
    return $_SESSION['RheinaufCMSLinker'];
}
function dirsort($files)
{
    usort($files, 'dircomp');
    return $files;
}
function dircomp($a, $b)
{
    if (is_array($a)) {
        $a = array_shift($a);
    }
    if (is_array($b)) {
        $b = array_shift($b);
    }
    return strcmp(strtolower($a), strtolower($b));
}
echo xinha_to_js(array_merge(dbnavi(), scan($dir)));
Ejemplo n.º 6
0
        }
    }
    if (floatval($s) < 10) {
        return floor(floatval($s) * 1024 * 1024);
    }
    if (floatval($s) < 1024) {
        return floor(floatval($s) * 1024);
    }
    // Kilobytes
    return intval($s);
    // Bytes
}
require_once 'config.php';
switch (@$_REQUEST["__function"]) {
    case 'read-config':
        // This is used so that the javascript can read the config
        // so we don't have to have a js config and a php config duplicating
        // settings
        echo xinha_to_js($IMConfig);
        break;
    case 'image-manager':
        include 'mootools-filemanager/Backend/FileManager.php';
        $browser = new FileManager(array('directory' => $IMConfig['images_dir'], 'baseURL' => $IMConfig['images_url'], 'assetBasePath' => $IMConfig['base_url'] . '/mootools-filemanager/Assets', 'upload' => $IMConfig['allow_images_upload'], 'maxUploadSize' => size_to_bytes($IMConfig['max_images_upload_size']), 'suggestedMaxImageDimension' => $IMConfig['suggested_images_image_dimension'], 'destroy' => $IMConfig['allow_images_delete'], 'filter' => 'image/'));
        $browser->fireEvent(!empty($_REQUEST['event']) ? $_REQUEST['event'] : null);
        break;
    case 'file-manager':
        include 'mootools-filemanager/Backend/FileManager.php';
        $browser = new FileManager(array('directory' => $IMConfig['files_dir'], 'baseURL' => $IMConfig['files_url'], 'assetBasePath' => $IMConfig['base_url'] . '/mootools-filemanager/Assets', 'upload' => $IMConfig['allow_files_upload'], 'maxUploadSize' => size_to_bytes($IMConfig['max_files_upload_size']), 'suggestedMaxImageDimension' => $IMConfig['suggested_files_image_dimension'], 'destroy' => $IMConfig['allow_files_delete']));
        $browser->fireEvent(!empty($_REQUEST['event']) ? $_REQUEST['event'] : null);
        break;
}
  function xinha_pass_to_php_backend($Data, $KeyLocation = 'Xinha:BackendKey', $ReturnPHP = FALSE)
  {

    $bk = array();
    $bk['data']       = serialize($Data);

    @session_start();
    if(!isset($_SESSION[$KeyLocation]))
    {
      $_SESSION[$KeyLocation] = uniqid('Key_');
    }

    $bk['session_name'] = session_name();
    $bk['key_location'] = $KeyLocation;
    $bk['hash']         =
      function_exists('sha1') ?
        sha1($_SESSION[$KeyLocation] . $bk['data'])
      : md5($_SESSION[$KeyLocation] . $bk['data']);


    // The data will be passed via a postback to the
    // backend, we want to make sure these are going to come
    // out from the PHP as an array like $bk above, so
    // we need to adjust the keys.
    $backend_data = array();
    foreach($bk as $k => $v)
    {
      $backend_data["backend_data[$k]"] = $v;
    }

    // The session_start() above may have been after data was sent, so cookies
    // wouldn't have worked.
    $backend_data[session_name()] = session_id();

    if($ReturnPHP)
    {
      return array('backend_data' => $backend_data);
    }
    else
    {
      echo 'backend_data = ' . xinha_to_js($backend_data) . "; \n";
    }
  }
Ejemplo n.º 8
0
<?php

/** This script can be used to automatically output all smiley images you
 *  dump into this folder, as long as they are gif, jpg or png.
 * 
 *  Simply set your 
 *
 *   xinha_config.InsertSmiley.smileys = 
 *      _editor_url+'/plugins/InsertSmiley/smilies.php';
 *
 * (or better, make a new smileys folder outside of Xinha 
 *  and copy this file to it and change the line above
 *  appropriately).
 *
 */
// You will probably need to change this if you copy this file elsewhere!
require_once realpath(dirname(__FILE__) . '/../../../contrib/php-xinha.php');
$dh = opendir(dirname(__FILE__));
$smileys = array();
while ($f = readdir($dh)) {
    $M = array();
    if (preg_match('/^(.*)\\.(gif|jpg|png)$/i', $f, $M)) {
        $smileys[] = array('title' => $M[1], 'src' => $f);
    }
}
closedir($dh);
echo xinha_to_js($smileys);
Ejemplo n.º 9
0
<?php

$snippets_file = 'snippets.html';
include_once '../../contrib/php-xinha.php';
if ($passed_data = xinha_read_passed_data()) {
    extract($passed_data);
}
$snippets = file_get_contents($snippets_file);
preg_match_all('/<!--(.*?)-->(.*?)<!--\\/.*?-->/s', $snippets, $matches);
$array = array();
for ($i = 0; $i < count($matches[1]); $i++) {
    $id = $matches[1][$i];
    $html = $matches[2][$i];
    $array[] = array('id' => $id, 'HTML' => $html);
}
print "var snippets = " . xinha_to_js($array);