/**
  * @param  array|\Doctrine\Common\Persistence\ObjectRepository $repo
  * @param  int                                                 $type
  * @return array
  */
 protected function processResult($repo, $type)
 {
     // Testing on input parameters
     if (!$repo instanceof \Doctrine\Common\Persistence\ObjectRepository && !is_array($repo)) {
         throw new Exception(__CLASS__ . ' expects an array or a
             \\Doctrine\\Common\\Persistence\\ObjectRepository. ' . class_name($repo) . ' given.');
     }
     switch ($type) {
         case AbstractDoctrineMapper::TYPE_SERIALIZEDARRAY:
             $result = [];
             foreach ($repo as $obj) {
                 /* @var $obj \JaztecBase\Entity\EntityInterface */
                 if ($obj instanceof \JaztecBase\Entity\EntityInterface) {
                     $result[] = $obj->toArray();
                 } elseif (is_array($obj)) {
                     $result[] = $obj;
                 }
             }
             break;
         case AbstractDoctrineMapper::TYPE_ENTITYARRAY:
             if (!is_array($repo)) {
                 $repo = [$repo];
             }
             $result = $repo;
             break;
     }
     return $result;
 }
 function execute($data, $max_entries = '')
 {
     if (is_array($data)) {
         die('This joint can be used only for HTML text ' . class_name($this));
     }
     $process = proc_open(escapeshellcmd($this->mod_configs['xsltproc_path']) . ' ' . escapeshellarg($this->option) . ' -', array(array('pipe', 'r'), array('pipe', 'w'), array('pipe', 'r')), $pipes);
     fwrite($pipes[0], $data);
     fclose($pipes[0]);
     $ret = '';
     while (!feof($pipes[1])) {
         $ret .= fread($pipes[1], 8192);
     }
     fclose($pipes[1]);
     proc_close($process);
     return $ret;
 }
 function execute($data, $max_entries = '')
 {
     if (is_array($data)) {
         die('This joint should be placed before parser ' . class_name($this));
     }
     $process = proc_open(escapeshellcmd($this->mod_configs['tidy_path']) . ' -xml -utf8', array(array('pipe', 'r'), array('pipe', 'w'), array('pipe', 'r')), $pipes);
     fwrite($pipes[0], $data);
     fclose($pipes[0]);
     $ret = '';
     while (!feof($pipes[1])) {
         $ret .= fread($pipes[1], 8192);
     }
     fclose($pipes[1]);
     proc_close($process);
     return $ret;
 }
Esempio n. 4
0
 public function get_list($start, $count, array $options = array())
 {
     $toret = false;
     Backend::add('Sub Title', 'List');
     $obj_name = class_name(Controller::$area) . 'Obj';
     if (class_exists($obj_name, true)) {
         $object = new $obj_name();
         if ($start === 'all') {
             $object->read(array());
         } else {
             $object->read(array('limit' => "{$start}, {$count}"));
         }
         $toret = $object;
     } else {
         Controller::whoops();
     }
     return $toret;
 }
Esempio n. 5
0
 public function __get($key)
 {
     $value = Parent::__get($key);
     if ($value === null) {
         // No lowest-level setting?
         if ($this->optionable_type == 'App\\Models\\SiteComponents\\Location') {
             // Load the default settings
             $className = class_name($this);
             return $className::doesntHave('optionable');
         } else {
             if ($this->optionable_type == 'App\\User') {
                 // Load the Location settings
                 $camelClass = camel_case(class_name($this));
                 return $this->optionable->location()->first()->{$camelClass}->{$key};
             } else {
                 // Load the User settings
                 $camelClass = camel_case(class_name($this));
                 return $this->optionable->user()->first()->{$camelClass}->{$key};
             }
         }
     }
     return $value;
 }
Esempio n. 6
0
 public static function hook_output($to_print)
 {
     $filename = Backend::get('CsvFilename', false);
     if (!$filename) {
         $filename = class_name(Controller::$area) . class_name(Controller::$action);
         if (Controller::$action == 'read' && !empty(Controller::$parameters[0])) {
             $filename .= Controller::$parameters[0];
         }
     }
     if (!Controller::$debug) {
         header('Content-Disposition: attachment; filename="' . $filename . '.csv"');
         header('Pragma: no-cache');
         header('Expires: 0');
     }
     switch (true) {
         //Output SelectQuery as CSV
         case $to_print instanceof SelectQuery:
         case $to_print instanceof CustomQuery:
             return self::outputQuery($to_print);
             break;
             //Output Array of Arrays as CSV
         //Output Array of Arrays as CSV
         case is_array($to_print):
             if (!($fp = fopen('php://temp', 'r+'))) {
                 Backend::addError('Could not open output file for CSV output');
                 return '';
             }
             $tmp = reset($to_print);
             $first = false;
             foreach ($to_print as $row) {
                 if (!is_array($row)) {
                     $row = array($row);
                 }
                 set_time_limit(30);
                 if (!$first) {
                     //fputcsv($fp, array_keys($row));
                     $first = true;
                 }
                 fputcsv($fp, $row);
             }
             //Get the file contents
             rewind($fp);
             ob_start();
             fpassthru($fp);
             fclose($fp);
             return ob_get_clean();
             break;
             //Output a DBObject. Try the list first, then the array | object
         //Output a DBObject. Try the list first, then the array | object
         case $to_print instanceof DBObject:
             if ($to_print->list) {
                 return self::outputList($to_print->list);
             } else {
                 if ($to_print->array || $to_print->db_object) {
                     $to_print = $to_print->array ? $to_print->array : (array) $to_print->db_object;
                     $to_print = array_filter($to_print, create_function('$var', 'return !is_array($var) && !is_object($var);'));
                     return self::outputList(array($to_print));
                 }
             }
             break;
             //Output a specified file as CSV
         //Output a specified file as CSV
         case is_string($to_print):
             if (is_readable($to_print)) {
                 $fp = fopen($to_print, 'r');
                 fpassthru($fp);
                 break;
             }
             //Output a string as CSV
         //Output a string as CSV
         default:
             return $to_print;
             break;
     }
 }
Esempio n. 7
0
 public static function getObject($obj_name = false, $id = false)
 {
     $obj_name = $obj_name ? class_name($obj_name) : class_name(get_called_class());
     if (!Component::isActive($obj_name)) {
         return null;
     }
     if ($id) {
         return call_user_func(array($obj_name, 'retrieve'), $id, 'dbobject');
     } else {
         $obj_name .= 'Obj';
         return new $obj_name();
     }
 }
Esempio n. 8
0
                echo '<span class="label label-danger label-toggle" data-toggle="tooltip" data-placement="top" title="Until: ' . $unban_time . '">Banned</span>';
            }
        }
        echo '&nbsp;' . $char->name;
        ?>
</td>
                <td><?php 
        echo $char->char_id;
        ?>
</td>
                <td><?php 
        echo $char->account_id;
        ?>
</td>
                <td><?php 
        echo class_name($char->class);
        ?>
</td>
                <td style="width: 24px;" class="center">
                    <?php 
        if (null != $char->emblem) {
            ?>
<img src="community/guild_emblem/<?php 
            echo $char->guild_id;
            ?>
" alt="emblem" /><?php 
        } else {
            ?>
-<?php 
        }
        ?>
Esempio n. 9
0
 /**
  * Return the current Layout (class) name.
  *
  * @return string
  */
 public function getLayoutName()
 {
     if ($this->layout instanceof View) {
         return class_name($this->layout);
     } else {
         if (is_string($this->layout)) {
             return $this->layout;
         }
     }
 }
Esempio n. 10
0
function show_unit_row($unit, $class, $level, $is_answer)
{
    global $breakdown, $breakdown_cat;
    global $rownum, $course_id;
    $a = $is_answer ? " (answer)" : "";
    $j = $rownum++ % 2;
    echo "<tr class=row{$j}>";
    if ($breakdown && $breakdown_cat) {
        echo "\n\t\t\t<td><br></td>\n\t\t\t<td><br></td>\n\t\t";
    } else {
        $c = class_name($class);
        echo "\n\t\t\t<td><b>" . spaces($level) . "{$unit->name}</b></td>\n\t\t\t<td>{$c} {$a}</td>\n\t\t";
    }
    if ($breakdown) {
        if ($breakdown_cat) {
            echo "<td>{$breakdown_cat}</td>\n";
        } else {
            echo "<td>Total</td>\n";
        }
    }
    switch ($class) {
        case "BoltLesson":
            $mode = BOLT_MODE_LESSON;
            $views = get_views($unit, $mode);
            $n = count($views);
            $out = outcomes($views);
            $t = avg_time($views);
            echo "<td>{$n}</td>";
            $n = get_nquestions($unit, $mode);
            if ($n) {
                echo "<td><a href=bolt_map.php?action=questions&course_id={$course_id}&name={$unit->name}&mode={$mode}" . filter_url() . ">{$n}</a></td>\n";
            } else {
                echo "<td>0</td>\n";
            }
            echo outcome_graph($out, 200);
            echo empty_cell();
            echo time_graph($t, 200);
            break;
        case "BoltExercise":
            $mode = $is_answer ? BOLT_MODE_ANSWER : BOLT_MODE_SHOW;
            $views = get_views($unit, $mode);
            $n = count($views);
            $out = outcomes($views);
            $t = avg_time($views);
            echo "<td>{$n}</td>";
            $n = get_nquestions($unit, $mode);
            if ($n) {
                echo "<td><a href=bolt_map.php?action=questions&course_id={$course_id}&name={$unit->name}&mode={$mode}>{$n}</a></td>\n";
            } else {
                echo "<td>0</td>\n";
            }
            echo outcome_graph($out, 200);
            if ($is_answer) {
                echo empty_cell();
            } else {
                $results = get_results($unit);
                $score = avg_score($results);
                echo score_graph($score, 200);
            }
            echo time_graph($t, 200);
            break;
        case "BoltExerciseSet":
            $xr = get_xset_results($unit);
            $n = count($xr);
            echo "<td>{$n}</td>";
            echo empty_cell();
            echo empty_cell();
            $score = avg_score($xr);
            echo score_graph($score, 200);
            echo empty_cell();
            break;
        default:
            echo empty_cell();
            echo empty_cell();
            echo empty_cell();
            echo empty_cell();
            echo empty_cell();
    }
    echo "</tr>\n";
}
Esempio n. 11
0
        }
        ?>
"><?php 
        echo $ladder[$x]->job_level;
        ?>
</td>
                        <td><?php 
        echo number_format($ladder[$x]->base_exp, 0, '.', ',');
        ?>
</td>
                        <td><?php 
        echo number_format($ladder[$x]->job_exp, 0, '.', ',');
        ?>
</td>
                        <td><?php 
        echo class_name($ladder[$x]->class);
        ?>
</td>
                        <td>
                            <?php 
        if (null != $ladder[$x]->emblem) {
            ?>
<img src="community/guild_emblem/<?php 
            echo $ladder[$x]->guild_id;
            ?>
" alt="guild emblem" /><?php 
        } else {
            ?>
<div style="display: inline-block; width: 24px;">&nbsp;</div><?php 
        }
        ?>
Esempio n. 12
0
 function class_for_url($string)
 {
     if (is_object($string)) {
         $string = get_class($string);
     }
     return computerize(class_name($string));
 }
Esempio n. 13
0
function render_partial($action, $object = false, $collect = false, $controller = false)
{
    #if the controller is an array, use it and ignore the rest
    if (is_array($action)) {
        if (array_key_exists('object', $action)) {
            $object = $action['object'];
        }
        if (array_key_exists('collect', $action)) {
            $collect = $action['collect'];
        }
        if (array_key_exists('controller', $action)) {
            $controller = $action['controller'];
        }
        if (array_key_exists('action', $action)) {
            $action = $action['action'];
        }
    } else {
        if ($controller == false) {
            $controller = params('controller');
        }
    }
    # set the template and object name
    $slashloc = strrpos($action, '/');
    if ($slashloc !== false) {
        $objectname = substr($action, $slashloc + 1);
        if ($action[0] == '/') {
            $template = substr(substr($action, 0, $slashloc) . '/_' . $objectname, 1);
        } else {
            $template = url_name($controller) . '/' . substr($action, 0, $slashloc) . '/_' . $objectname;
        }
    } else {
        $template = url_name($controller) . '/_' . $action;
        $objectname = $action;
    }
    $view = ViewFactory::make_view($template);
    # include the helpers
    if (file_exists(PROJECT_ROOT . '/app/helpers/app.php')) {
        include_once PROJECT_ROOT . '/app/helpers/app.php';
    }
    if (file_exists(PROJECT_ROOT . '/app/helpers/' . $controller . '.php')) {
        include_once PROJECT_ROOT . '/app/helpers/' . $controller . '.php';
    }
    # if it's a collection, call it for each item in the obj
    $objectname = var_name(class_name($objectname));
    if ($collect === true) {
        foreach ($object as $k => $v) {
            echo $view->parse_partial($objectname, $v);
        }
    } else {
        echo $view->parse_partial($objectname, $object);
    }
}
Esempio n. 14
0
    foreach ($methods as $method) {
        ?>
			<li>
				<a href="?q=<?php 
        echo Controller::$area;
        ?>
/<?php 
        echo $method;
        ?>
"><?php 
        echo humanize($method);
        ?>
</a>
				<?php 
        if (method_exists(class_name(Controller::$area), 'define_' . $method)) {
            $definition = call_user_func(array(class_name(Controller::$area), 'define_' . $method));
            if (!empty($definition['description'])) {
                ?>
						 <span class="quiet">- <?php 
                echo $definition['description'];
                ?>
</span>
					<?php 
            }
            ?>
				<?php 
        }
        ?>
			</li>
		<?php 
    }
 /**
  * Load and sets the resource from a existing file
  *
  * @param string
  * @return boolean
  *
  * @throws sfImageTransformException
  */
 public function loadString($string)
 {
     $image = $this->getHolder()->readImageBlob($string);
     if (is_object($image) && class_name($image) == 'Imagick') {
         $this->setHolder($image);
         return true;
     }
     throw new sfImageTransformException('Cannot load image string');
 }
Esempio n. 16
0
 function many($other)
 {
     if (is_object($other) && class_name($other) == 'Yapo') {
         $this->__Core->Join(Yapo::ONE2MANY, $other, $local_key, $other_key);
     }
 }
Esempio n. 17
0
 private static function getViewName()
 {
     //Check the mode parameter
     $query_vars = Controller::getQueryVars();
     if (array_key_exists('mode', $query_vars)) {
         $view_name = ucwords($query_vars['mode']) . 'View';
         return $view_name;
     }
     //No View found, check the accept header
     $default_precedence = array('text/html' => (double) 1, 'application/xhtml+xml' => 0.9, 'application/xml' => 0);
     $mime_ranges = Parser::accept_header(false, $default_precedence);
     if (!$mime_ranges) {
         return ConfigValue::get('DefaultView', 'HtmlView');
     }
     $types = array();
     $main_types = array();
     $view_name = false;
     foreach ($mime_ranges as $mime_type) {
         $types[] = $mime_type['main_type'] . '/' . $mime_type['sub_type'];
         $main_types[] = $mime_type['main_type'];
         if (!$view_name) {
             $name = class_name(str_replace('+', ' ', $mime_type['main_type']) . ' ' . str_replace('+', ' ', $mime_type['sub_type'])) . 'View';
             if (Component::isActive($name)) {
                 $view_name = $name;
             } else {
                 $name = class_name(str_replace('+', ' ', $mime_type['main_type'])) . 'View';
                 if (Component::isActive($name)) {
                     $view_name = $name;
                 } else {
                     $name = class_name(str_replace('+', ' ', $mime_type['sub_type'])) . 'View';
                     if (Component::isActive($name)) {
                         $view_name = $name;
                     }
                 }
             }
         }
     }
     if (in_array('image', $main_types) && in_array('application', $main_types)) {
         //Probably IE
         $view_name = 'HtmlView';
     } else {
         if (in_array('application/xml', $types) && in_array('application/xhtml+xml', $types) && in_array('text/html', $types)) {
             //Maybe another confused browser that asks for XML and HTML
             $view_name = 'HtmlView';
         } else {
             if (count($mime_ranges) == 1 && $mime_ranges[0]['main_type'] == '*' && $mime_ranges[0]['sub_type'] == '*') {
                 $view_name = ConfigValue::get('DefaultView', 'HtmlView');
             }
         }
     }
     return $view_name;
 }
Esempio n. 18
0
                        <tr>
                            <td><strong>Char Slot</strong></td>
                            <td><?php 
    echo $chars[$index]->char_num;
    ?>
</td>
                            <td><strong>Str</strong></td>
                            <td><?php 
    echo $chars[$index]->str;
    ?>
</td>
                        </tr>
                        <tr>
                            <td><strong>Class</strong></td>
                            <td><?php 
    echo class_name($chars[$index]->class);
    ?>
</td>
                            <td><strong>Agi</strong></td>
                            <td><?php 
    echo $chars[$index]->agi;
    ?>
</td>
                        </tr>
                        <tr>
                            <td><strong>Base Level</strong></td>
                            <td><?php 
    echo $chars[$index]->base_level;
    ?>
</td>
                            <td><strong>Vit</strong></td>
Esempio n. 19
0
 public function install(array $options = array())
 {
     $toret = false;
     $this->error_msg = false;
     if ($this->checkConnection()) {
         $drop_table = array_key_exists('drop_table', $options) ? $options['drop_table'] : false;
         $query = $this->getInstallSQL();
         if ($query) {
             if ($drop_table) {
                 $table = $this->getSource();
                 $drop_query = new CustomQuery('DROP TABLE IF EXISTS ' . Query::getTable($this) . '', array('connection' => $this->db));
                 $drop_query->execute();
                 Backend::addNotice('Dropping table ' . $table);
                 if (!empty($drop_query->error_msg)) {
                     $this->error_msg = $drop_query->error_msg;
                 }
             }
             $query = new CustomQuery($query, array('connection' => $this->db));
             $toret = $query->execute();
             if (!empty($query->error_msg)) {
                 $this->error_msg = $query->error_msg;
             }
         } else {
             if (class_exists('BackendError', false)) {
                 BackendError::add(get_class($this) . ': No Install SQL', 'install');
             }
             $this->error_msg = 'No Install SQL for ' . class_name($this);
         }
     } else {
         if (class_exists('BackendError', false)) {
             BackendError::add(get_class($this) . ': DB Connection Error', 'install');
         }
         $this->error_msg = 'DB Connection error';
     }
     return $toret;
 }
Esempio n. 20
0
 public static function check($action = '*', $subject = '*', $subject_id = 0)
 {
     if (!BACKEND_WITH_DATABASE) {
         return true;
     }
     static $cache = array();
     if (is_object($subject)) {
         $subject = get_class($subject);
     }
     $key = serialize(array($action, $subject, $subject_id));
     if (array_key_exists($key, $cache)) {
         //return $cache[$key];
     }
     $roles = GateKeeper::permittedRoles($action, class_for_url($subject), $subject_id);
     $user = BackendUser::check();
     $user = !$user && !empty($_SESSION['BackendUser']) ? $_SESSION['BackendUser'] : $user;
     if (!$user && !in_array('anonymous', $roles)) {
         if (Controller::$debug) {
             Backend::addNotice('Anonymous User');
         }
         $cache[$key] = true;
         return true;
     }
     if ($subject != '*' && !Component::isActive(class_name($subject))) {
         if (Controller::$debug) {
             Backend::addNotice('Invalid Component: ' . class_name($subject));
         }
         $cache[$key] = false;
         return false;
     }
     if (empty($user->roles)) {
         if (Controller::$debug) {
             Backend::addNotice('No User Roles');
         }
         $cache[$key] = false;
         return false;
     }
     $intersect = is_array($roles) ? array_intersect($user->roles, $roles) : $user->roles;
     if (Controller::$debug >= 2) {
         Backend::addNotice('Valid roles found: ' . json_encode($intersect));
     }
     $result = count($intersect) ? true : false;
     $cache[$key] = $result;
     return $result;
 }
Esempio n. 21
0
 public static function enregistrer_filtre($filtre)
 {
     if ($filtre instanceof FiltreBase) {
         self::$FILTRES_UTILISATEUR[] = $filtre;
     } else {
         die(class_name($filtre) . " doit implémenter la classe FiltreBase.");
     }
 }
Esempio n. 22
0
 public static function hook_output($output)
 {
     //TODO Attach HTTP Error codes and descriptions to these errors
     if (!is_array($output)) {
         BackendError::add('Google Chart Error', 'Invalid Output');
         return false;
     }
     $type = array_key_exists('type', $output) ? $output['type'] : Backend::get('ChartType', 'simple_line');
     if (!method_exists('GChartView', $type)) {
         BackendError::add('Google Chart Error', 'Invalid Chart Type');
         return false;
     }
     if (!array_key_exists('data', $output)) {
         $output = array('data' => $output);
     }
     if (!is_array($output['data']) || !count($output['data'])) {
         BackendError::add('Google Chart Error', 'Invalid Output Data');
         return false;
     }
     $params = array();
     $title = array_key_exists('title', $output) ? $output['title'] : Backend::get('ChartTitle', false);
     if ($title) {
         $params['chtt'] = $title;
     }
     $url = self::$type($output, $params);
     if (Controller::$debug) {
         echo '<img src="' . $url . '">';
         var_dump($params);
         var_dump($output);
         $dont_kill = Controller::getVar('dont_kill');
         if (empty($dont_kill)) {
             die;
         }
     }
     $recache = Controller::getVar('recache') ? true : false;
     debug_header('Recache - ' . $recache);
     $image = curl_request($url, array(), array('cache' => $recache ? 1 : 60 * 60, 'bypass_ssl' => 1));
     if (Controller::$debug) {
         var_dump('Image:', $image);
     }
     if (!$image) {
         BackendError::add('Google Chart Error', 'Could not get image');
         return false;
     }
     $filename = Backend::get('ChartFilename', false);
     if (!$filename) {
         $filename = class_name(Controller::$area) . class_name(Controller::$action);
         if (Controller::$action == 'read' && !empty(Controller::$parameters[0])) {
             $filename .= Controller::$parameters[0];
         }
     }
     if (Controller::$debug) {
         var_dump('Filename:', $filename);
     }
     header('Content-Disposition: inline; filename="' . $filename . '.png"');
     return $image;
 }
Esempio n. 23
0
 public function html_permissions($result)
 {
     if (is_post()) {
         if ($result === false) {
             Backend::addError('Could not update Permissions');
         } else {
             Backend::addSuccess($result . ' Permissions Updated');
         }
         Controller::redirect('previous');
     }
     //GET
     if (!empty(Controller::$parameters[0])) {
         Backend::add('Sub Title', class_name(Controller::$parameters[0]) . ' Permissions');
         Links::add('All Permissions', '?q=gate_manager/permissions', 'secondary');
     } else {
         Backend::add('Sub Title', ConfigValue::get('Title') . ' Permissions');
     }
     Backend::addContent(Render::renderFile('gate_manager.permissions.tpl.php', (array) $result));
 }
Esempio n. 24
0
 /**
  * PRIVATE CODE that does the work of encodes an arbitrary variable into JSON format 
  *
  * @param    mixed   $var    any number, boolean, string, array, or object to be encoded.
  *                           see argument 1 to Services_JSON() above for array-parsing behavior.
  *                           if var is a strng, note that encode() always expects it
  *                           to be in ASCII or UTF-8 format!
  *
  * @return   mixed   JSON string representation of input var or an error if a problem occurs
  * @access   public
  */
 function _encode($var)
 {
     switch (gettype($var)) {
         case 'boolean':
             return $var ? 'true' : 'false';
         case 'NULL':
             return 'null';
         case 'integer':
             return (int) $var;
         case 'double':
         case 'float':
             return (double) $var;
         case 'string':
             // STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
             $ascii = '';
             $strlen_var = $this->strlen8($var);
             /*
              * Iterate over every character in the string,
              * escaping with a slash or encoding to UTF-8 where necessary
              */
             for ($c = 0; $c < $strlen_var; ++$c) {
                 $ord_var_c = ord($var[$c]);
                 switch (true) {
                     case $ord_var_c == 0x8:
                         $ascii .= '\\b';
                         break;
                     case $ord_var_c == 0x9:
                         $ascii .= '\\t';
                         break;
                     case $ord_var_c == 0xa:
                         $ascii .= '\\n';
                         break;
                     case $ord_var_c == 0xc:
                         $ascii .= '\\f';
                         break;
                     case $ord_var_c == 0xd:
                         $ascii .= '\\r';
                         break;
                     case $ord_var_c == 0x22:
                     case $ord_var_c == 0x2f:
                     case $ord_var_c == 0x5c:
                         // double quote, slash, slosh
                         $ascii .= '\\' . $var[$c];
                         break;
                     case $ord_var_c >= 0x20 && $ord_var_c <= 0x7f:
                         // characters U-00000000 - U-0000007F (same as ASCII)
                         $ascii .= $var[$c];
                         break;
                     case ($ord_var_c & 0xe0) == 0xc0:
                         // characters U-00000080 - U-000007FF, mask 110XXXXX
                         // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
                         if ($c + 1 >= $strlen_var) {
                             $c += 1;
                             $ascii .= '?';
                             break;
                         }
                         $char = pack('C*', $ord_var_c, ord($var[$c + 1]));
                         $c += 1;
                         $utf16 = $this->utf82utf16($char);
                         $ascii .= sprintf('\\u%04s', bin2hex($utf16));
                         break;
                     case ($ord_var_c & 0xf0) == 0xe0:
                         if ($c + 2 >= $strlen_var) {
                             $c += 2;
                             $ascii .= '?';
                             break;
                         }
                         // characters U-00000800 - U-0000FFFF, mask 1110XXXX
                         // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
                         $char = pack('C*', $ord_var_c, @ord($var[$c + 1]), @ord($var[$c + 2]));
                         $c += 2;
                         $utf16 = $this->utf82utf16($char);
                         $ascii .= sprintf('\\u%04s', bin2hex($utf16));
                         break;
                     case ($ord_var_c & 0xf8) == 0xf0:
                         if ($c + 3 >= $strlen_var) {
                             $c += 3;
                             $ascii .= '?';
                             break;
                         }
                         // characters U-00010000 - U-001FFFFF, mask 11110XXX
                         // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
                         $char = pack('C*', $ord_var_c, ord($var[$c + 1]), ord($var[$c + 2]), ord($var[$c + 3]));
                         $c += 3;
                         $utf16 = $this->utf82utf16($char);
                         $ascii .= sprintf('\\u%04s', bin2hex($utf16));
                         break;
                     case ($ord_var_c & 0xfc) == 0xf8:
                         // characters U-00200000 - U-03FFFFFF, mask 111110XX
                         // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
                         if ($c + 4 >= $strlen_var) {
                             $c += 4;
                             $ascii .= '?';
                             break;
                         }
                         $char = pack('C*', $ord_var_c, ord($var[$c + 1]), ord($var[$c + 2]), ord($var[$c + 3]), ord($var[$c + 4]));
                         $c += 4;
                         $utf16 = $this->utf82utf16($char);
                         $ascii .= sprintf('\\u%04s', bin2hex($utf16));
                         break;
                     case ($ord_var_c & 0xfe) == 0xfc:
                         if ($c + 5 >= $strlen_var) {
                             $c += 5;
                             $ascii .= '?';
                             break;
                         }
                         // characters U-04000000 - U-7FFFFFFF, mask 1111110X
                         // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
                         $char = pack('C*', $ord_var_c, ord($var[$c + 1]), ord($var[$c + 2]), ord($var[$c + 3]), ord($var[$c + 4]), ord($var[$c + 5]));
                         $c += 5;
                         $utf16 = $this->utf82utf16($char);
                         $ascii .= sprintf('\\u%04s', bin2hex($utf16));
                         break;
                 }
             }
             return '"' . $ascii . '"';
         case 'array':
             /*
              * As per JSON spec if any array key is not an integer
              * we must treat the the whole array as an object. We
              * also try to catch a sparsely populated associative
              * array with numeric keys here because some JS engines
              * will create an array with empty indexes up to
              * max_index which can cause memory issues and because
              * the keys, which may be relevant, will be remapped
              * otherwise.
              *
              * As per the ECMA and JSON specification an object may
              * have any string as a property. Unfortunately due to
              * a hole in the ECMA specification if the key is a
              * ECMA reserved word or starts with a digit the
              * parameter is only accessible using ECMAScript's
              * bracket notation.
              */
             // treat as a JSON object
             if (is_array($var) && count($var) && array_keys($var) !== range(0, sizeof($var) - 1)) {
                 $properties = array_map(array($this, 'name_value'), array_keys($var), array_values($var));
                 foreach ($properties as $property) {
                     if (Services_JSON::isError($property)) {
                         return $property;
                     }
                 }
                 return '{' . join(',', $properties) . '}';
             }
             // treat it like a regular array
             $elements = array_map(array($this, '_encode'), $var);
             foreach ($elements as $element) {
                 if (Services_JSON::isError($element)) {
                     return $element;
                 }
             }
             return '[' . join(',', $elements) . ']';
         case 'object':
             // support toJSON methods.
             if ($this->use & SERVICES_JSON_USE_TO_JSON && method_exists($var, 'toJSON')) {
                 // this may end up allowing unlimited recursion
                 // so we check the return value to make sure it's not got the same method.
                 $recode = $var->toJSON();
                 if (method_exists($recode, 'toJSON')) {
                     return $this->use & SERVICES_JSON_SUPPRESS_ERRORS ? 'null' : new Services_JSON_Error(class_name($var) . " toJSON returned an object with a toJSON method.");
                 }
                 return $this->_encode($recode);
             }
             $vars = get_object_vars($var);
             $properties = array_map(array($this, 'name_value'), array_keys($vars), array_values($vars));
             foreach ($properties as $property) {
                 if (Services_JSON::isError($property)) {
                     return $property;
                 }
             }
             return '{' . join(',', $properties) . '}';
         default:
             return $this->use & SERVICES_JSON_SUPPRESS_ERRORS ? 'null' : new Services_JSON_Error(gettype($var) . " can not be encoded as JSON string");
     }
 }
Esempio n. 25
0
 public function html_scaffold($result)
 {
     if (is_post() && $result) {
         Backend::addSuccess('Scaffolds created for ' . class_name(Controller::$parameters[0]));
         Controller::redirect();
     } else {
         if (!$result) {
             Controller::redirect();
         }
     }
     Backend::addContent(Render::file('admin.scaffold.tpl.php', $result));
     return $result;
 }
Esempio n. 26
0
 /**
  * find the best map include the right classes and
  * start hand off to the controller
  */
 static function handle_url($url)
 {
     if (defined('DEBUG') && DEBUG) {
         error_log("Begin processing: {$url}");
         $start = microtime(true);
     }
     $u = Usher::get_instance();
     # routing is here
     $params = $u->match_url($url);
     # if no match was found, show the error
     if (!$params) {
         throw new NoValidMapping("No mapping was found for &quot;{$url}&quot;.");
     }
     # add request to params and make sure magic quotes are dealt with
     unset($_POST['MAX_FILE_SIZE']);
     unset($_GET['MAX_FILE_SIZE']);
     foreach ($_POST as $k => $v) {
         if (!array_key_exists($k, $params)) {
             $gpc = get_magic_quotes_gpc() == 1;
             if (is_array($v)) {
                 $params[$k] = array();
                 foreach ($v as $k2 => $v2) {
                     $params[$k][$k2] = $gpc && !is_array($v2) ? stripslashes($v2) : $v2;
                 }
             } else {
                 $params[$k] = $gpc ? stripslashes($v) : $v;
             }
         }
     }
     foreach ($_GET as $k => $v) {
         if (!array_key_exists($k, $params)) {
             $gpc = get_magic_quotes_gpc() == 1;
             if (is_array($v)) {
                 $params[$k] = array();
                 foreach ($v as $k2 => $v2) {
                     $params[$k][$k2] = $gpc && !is_array($v2) ? stripslashes($v2) : $v2;
                 }
             } else {
                 $params[$k] = $gpc ? stripslashes($v) : $v;
             }
         }
     }
     # add files to params and make sure magic quotes are dealt with
     foreach ($_FILES as $k => $v) {
         if (!array_key_exists($k, $params)) {
             $params[$k] = array();
         }
         $params[$k] = array_merge($params[$k], UploadedFile::create($v));
     }
     # save the params
     self::$params = $params;
     # get the controller name
     #$cname = preg_replace('/(?:^|_)([a-zA-Z])/e', "strtoupper('\\1')", $params['controller']);
     $cname = class_name($params['controller']);
     $cname = ucfirst($cname . 'Controller');
     # make sure the name is a valid class name
     if (preg_match('|[^a-zA-Z_]|', $cname) > 0 || preg_match('|^[^a-zA-Z_]|', $cname) > 0) {
         throw new UnknownController("{$cname} is not a valid controller.");
     }
     if (defined('DEBUG') && DEBUG) {
         error_log("Controller found in " . (microtime(true) - $start) . " seconds.");
     }
     # make an instance of the controller class
     self::$controller = new $cname();
     # set the method name
     $action = $params['action'];
     # tell the controller to execute the action
     self::$controller->execute($action);
     # log exec time
     if (defined('DEBUG') && DEBUG) {
         $end = microtime(true);
         error_log("Executed in " . ($end - $start) . " seconds.");
     }
 }
Esempio n. 27
0
>

        <div class="container body">


            <div class="main_container">

                <div class="col-md-3 left_col">
                    <div class="left_col scroll-view">

                        <div class="navbar nav_title" style="border: 0;">
                            <a href="<?php 
echo site_url('admin/');
?>
" class="site_title"><i class="fa fa-mortar-board"></i> <span><?php 
echo class_name() != '-' ? class_name() : 'SYSCMS';
?>
</span></a>
                        </div>
                        <div class="clearfix"></div>

                        <br />

                        <?php 
$this->load->view('admin/sidebar');
?>
                        <!-- /menu footer buttons -->
                        <div class="sidebar-footer hidden-small">
                            <a data-toggle="tooltip" data-placement="top" title="Settings">
                                <span class="glyphicon glyphicon-cog" aria-hidden="true"></span>
                            </a>
Esempio n. 28
0
 /**
  * Sets the fill
  *
  * @param mixed
  * @return boolean
  */
 public function setFill($fill)
 {
     if (preg_match('/#[\\d\\w]{6}/', $fill) || is_object($fill) && class_name($fill) === 'sfImage') {
         $this->fill = $fill;
         return true;
     }
     return false;
 }
Esempio n. 29
0
 protected static function parseQuery($query)
 {
     if (!ConfigValue::get('AdminInstalled', false) && !in_array($query, array('admin/pre_install', 'admin/check_install', 'admin/install'))) {
         $query = 'admin/pre_install';
     }
     if (!empty($query)) {
         $terms = explode('/', $query);
     } else {
         $terms = array();
     }
     //We want to now what a parameter was, even if it's empty, so don't filter
     //$terms = array_filter($terms);
     self::$area = count($terms) ? array_shift($terms) : ConfigValue::get('DefaultController', 'home');
     if (count($terms)) {
         self::$action = array_shift($terms);
     } else {
         if (Component::isActive(class_name(self::$area))) {
             self::$action = ConfigValue::get('Default' . class_name(self::$area) . 'Action', ConfigValue::get('DefaultAction', 'index'));
         } else {
             self::$action = ConfigValue::get('DefaultAction', 'index');
         }
     }
     self::$parameters = !empty($terms) ? $terms : array();
     if (Component::isActive(class_name(self::$area)) && method_exists(class_name(self::$area), 'checkParameters')) {
         self::$parameters = call_user_func(array(class_name(self::$area), 'checkParameters'), self::$parameters);
     }
     return self::$parameters;
 }