| 24 | | <?php |
| 25 | | session_start(); |
| 26 | | $IMConfig = array(); |
| 27 | | $IMConfig['images_dir'] = '/full/path/to/images/'; |
| 28 | | $IMConfig['images_url'] = '/url/to/images/'; |
| 29 | | $IMConfig = serialize($IMConfig); |
| 30 | | if(!isset($_SESSION['Xinha:ImageManager'])) |
| 31 | | { |
| 32 | | $_SESSION['Xinha:ImageManager'] = uniqid('secret_'); |
| 33 | | } |
| 34 | | ?> |
| | 25 | with(xinha_config.ImageManager) |
| | 26 | { |
| | 27 | <?php |
| | 28 | require_once('/path/to/xinha/contrib/php-xinha.php'); |
| | 29 | xinha_pass_to_php_backend( |
| | 30 | array( |
| | 31 | 'images_dir' => '/path/to/images', |
| | 32 | 'images_url' => '/images' |
| | 33 | ) |
| | 34 | ); |
| | 35 | ?> |
| | 36 | } |
| 91 | | <?php |
| 92 | | session_start(); |
| 93 | | $IMConfig = array(); |
| 94 | | $IMConfig['images_dir'] = '/full/path/to/images/'; |
| 95 | | $IMConfig['images_url'] = '/url/to/images/'; |
| 96 | | $IMConfig = serialize($IMConfig); |
| 97 | | if(!isset($_SESSION['Xinha:ImageManager'])) |
| 98 | | { |
| 99 | | $_SESSION['Xinha:ImageManager'] = uniqid('secret_'); |
| 100 | | } |
| 101 | | |
| 102 | | ?> |
| 103 | | |
| 104 | | xinha_config.ImageManager.backend_config |
| 105 | | = '<?php echo jsaddslashes($IMConfig)?>'; |
| 106 | | xinha_config.ImageManager.backend_config_hash |
| 107 | | = '<?php echo sha1($IMConfig . $_SESSION['Xinha:ImageManager'])?>'; |
| 108 | | |
| | 84 | with(xinha_config.ImageManager) |
| | 85 | { |
| | 86 | <?php |
| | 87 | require_once('/path/to/xinha/contrib/php-xinha.php'); |
| | 88 | xinha_pass_to_php_backend( |
| | 89 | array( |
| | 90 | 'images_dir' => '/path/to/images', |
| | 91 | 'images_url' => '/images' |
| | 92 | ) |
| | 93 | ); |
| | 94 | ?> |
| | 95 | } |
| 149 | | |
| 150 | | == jsaddslashes == |
| 151 | | The PHP code above uses a function called jsaddslashes() to escape characters that are special within javascript strings. Here is a suitable function if you do not have one in your collection already. |
| 152 | | |
| 153 | | {{{ |
| 154 | | <?php |
| 155 | | function jsaddslashes($s) |
| 156 | | { |
| 157 | | $o=""; |
| 158 | | $l=strlen($s); |
| 159 | | for($i=0;$i<$l;$i++) |
| 160 | | { |
| 161 | | $c=$s[$i]; |
| 162 | | switch($c) |
| 163 | | { |
| 164 | | case '<': $o.='\\x3C'; break; |
| 165 | | case '>': $o.='\\x3E'; break; |
| 166 | | case '\'': $o.='\\\''; break; |
| 167 | | case '\\': $o.='\\\\'; break; |
| 168 | | case '"': $o.='\\"'; break; |
| 169 | | case "\n": $o.='\\n'; break; |
| 170 | | case "\r": $o.='\\r'; break; |
| 171 | | default: |
| 172 | | $o.=$c; |
| 173 | | } |
| 174 | | } |
| 175 | | return $o; |
| 176 | | } |
| 177 | | ?> |
| 178 | | }}} |