/** * finish recording log * @return void */ function actFinish() { if (!$this->query) { return; } $this->act_finish = getMicroTime(); $elapsed_time = $this->act_finish - $this->act_start; $this->elapsed_time = $elapsed_time; $GLOBALS['__db_elapsed_time__'] += $elapsed_time; $site_module_info = Context::get('site_module_info'); $log = array(); $log['query'] = $this->query; $log['elapsed_time'] = $elapsed_time; $log['connection'] = $this->connection; $log['query_id'] = $this->query_id; $log['module'] = $site_module_info->module; $log['act'] = Context::get('act'); $log['time'] = date('Y-m-d H:i:s'); $bt = version_compare(PHP_VERSION, '5.3.6', '>=') ? debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) : debug_backtrace(); foreach ($bt as $no => $call) { if ($call['function'] == 'executeQuery' || $call['function'] == 'executeQueryArray') { $call_no = $no; $call_no++; $log['called_file'] = $bt[$call_no]['file'] . ':' . $bt[$call_no]['line']; $log['called_file'] = str_replace(_XE_PATH_, '', $log['called_file']); $call_no++; $log['called_method'] = $bt[$call_no]['class'] . $bt[$call_no]['type'] . $bt[$call_no]['function']; break; } } // leave error log if an error occured (if __DEBUG_DB_OUTPUT__ is defined) if ($this->isError()) { $log['result'] = 'Failed'; $log['errno'] = $this->errno; $log['errstr'] = $this->errstr; if (__DEBUG_DB_OUTPUT__ == 1) { $debug_file = _XE_PATH_ . "files/_debug_db_query.php"; $buff = array(); if (!file_exists($debug_file)) { $buff[] = '<?php exit(); ?' . '>'; } $buff[] = print_r($log, TRUE); @file_put_contents($log_file, implode("\n", $buff) . "\n\n", FILE_APPEND | LOCK_EX); } } else { $log['result'] = 'Success'; } $this->setQueryLog($log); $log_args = new stdClass(); $log_args->query = $this->query; $log_args->query_id = $this->query_id; $log_args->caller = $log['called_method'] . '() in ' . $log['called_file']; $log_args->connection = $log['connection']; writeSlowlog('query', $elapsed_time, $log_args); }
/** * call a trigger * @param string $trigger_name trigger's name to call * @param string $called_position called position * @param object $obj an object as a parameter to trigger * @return Object * */ function triggerCall($trigger_name, $called_position, &$obj) { // skip if not installed if (!Context::isInstalled()) { return new Object(); } $oModuleModel = getModel('module'); $triggers = $oModuleModel->getTriggers($trigger_name, $called_position); if (!$triggers || count($triggers) < 1) { return new Object(); } //store before trigger call time $before_trigger_time = NULL; if (__LOG_SLOW_TRIGGER__ > 0) { $before_trigger_time = microtime(true); } foreach ($triggers as $item) { $module = $item->module; $type = $item->type; $called_method = $item->called_method; // todo why don't we call a normal class object ? $oModule = getModule($module, $type); if (!$oModule || !method_exists($oModule, $called_method)) { continue; } $before_each_trigger_time = microtime(true); $output = $oModule->{$called_method}($obj); $after_each_trigger_time = microtime(true); $elapsed_time_trigger = $after_each_trigger_time - $before_each_trigger_time; $slowlog = new stdClass(); $slowlog->caller = $trigger_name . '.' . $called_position; $slowlog->called = $module . '.' . $called_method; $slowlog->called_extension = $module; if ($trigger_name != 'XE.writeSlowlog') { writeSlowlog('trigger', $elapsed_time_trigger, $slowlog); } if (is_object($output) && method_exists($output, 'toBool') && !$output->toBool()) { return $output; } unset($oModule); } return new Object(); }
/** * @brief Widget name and argument and produce a result and Return the results * Tags used in templateHandler $this-> execute() will be replaced by the code running * * $Javascript_mode is true when editing your page by the code for handling Includes photos */ function execute($widget, $args, $javascript_mode = false, $escaped = true) { // Save for debug run-time widget if (__DEBUG__ == 3) { $start = getMicroTime(); } $before = microtime(true); // urldecode the value of args haejum $object_vars = get_object_vars($args); if (count($object_vars)) { foreach ($object_vars as $key => $val) { if (in_array($key, array('widgetbox_content', 'body', 'class', 'style', 'widget_sequence', 'widget', 'widget_padding_left', 'widget_padding_top', 'widget_padding_bottom', 'widget_padding_right', 'widgetstyle', 'document_srl'))) { continue; } if ($escaped) { $args->{$key} = utf8RawUrlDecode($val); } } } /** * Widgets widgetContent/widgetBox Wanted If you are not content */ $widget_content = ''; if ($widget != 'widgetContent' && $widget != 'widgetBox') { if (!is_dir(sprintf(_XE_PATH_ . 'widgets/%s/', $widget))) { return; } // Hold the contents of the widget parameter $widget_content = $this->getCache($widget, $args); } if ($widget == 'widgetBox') { $widgetbox_content = $args->widgetbox_content; } /** * Wanted specified by the administrator of the widget style */ // Sometimes the wrong code, background-image: url (none) can be heard but none in this case, the request for the url so unconditionally Removed $style = preg_replace('/url\\((.+)(\\/?)none\\)/is', '', $args->style); // Find a style statement that based on the internal margin dropping pre-change $widget_padding_left = $args->widget_padding_left; $widget_padding_right = $args->widget_padding_right; $widget_padding_top = $args->widget_padding_top; $widget_padding_bottom = $args->widget_padding_bottom; $inner_style = sprintf("padding:%dpx %dpx %dpx %dpx !important;", $widget_padding_top, $widget_padding_right, $widget_padding_bottom, $widget_padding_left); /** * Wanted widget output */ $widget_content_header = ''; $widget_content_body = ''; $widget_content_footer = ''; // If general call is given on page styles should return immediately dreamin ' if (!$javascript_mode) { if ($args->id) { $args->id = ' id="' . $args->id . '" '; } switch ($widget) { // If a direct orthogonal addition information case 'widgetContent': if ($args->document_srl) { $oDocumentModel = getModel('document'); $oDocument = $oDocumentModel->getDocument($args->document_srl); $body = $oDocument->getContent(false, false, false, false); } else { $body = base64_decode($args->body); } // Change the editor component $oEditorController = getController('editor'); $body = $oEditorController->transComponent($body); $widget_content_header = sprintf('<div class="xe-widget-wrapper ' . $args->css_class . '" %sstyle="%s"><div style="%s">', $args->id, $style, $inner_style); $widget_content_body = $body; $widget_content_footer = '</div></div>'; break; // If the widget box; it could // If the widget box; it could case 'widgetBox': $widget_content_header = sprintf('<div class="xe-widget-wrapper ' . $args->css_class . '" %sstyle="%s;"><div style="%s"><div>', $args->id, $style, $inner_style); $widget_content_body = $widgetbox_content; break; // If the General wijetil // If the General wijetil default: $widget_content_header = sprintf('<div class="xe-widget-wrapper ' . $args->css_class . '" %sstyle="%s">', $args->id, $style); $widget_content_body = sprintf('<div style="*zoom:1;%s">%s</div>', $inner_style, $widget_content); $widget_content_footer = '</div>'; break; } // Edit page is called when a widget if you add the code for handling } else { switch ($widget) { // If a direct orthogonal addition information case 'widgetContent': if ($args->document_srl) { $oDocumentModel = getModel('document'); $oDocument = $oDocumentModel->getDocument($args->document_srl); $body = $oDocument->getContent(false, false, false); } else { $body = base64_decode($args->body); } // by args $attribute = array(); if ($args) { foreach ($args as $key => $val) { if (in_array($key, array('class', 'style', 'widget_padding_top', 'widget_padding_right', 'widget_padding_bottom', 'widget_padding_left', 'widget', 'widgetstyle', 'document_srl'))) { continue; } if (strpos($val, '|@|') > 0) { $val = str_replace('|@|', ',', $val); } $attribute[] = sprintf('%s="%s"', $key, htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); } } $oWidgetController = getController('widget'); $widget_content_header = sprintf('<div class="widgetOutput ' . $args->css_class . '" widgetstyle="%s" style="%s" widget_padding_left="%s" widget_padding_right="%s" widget_padding_top="%s" widget_padding_bottom="%s" widget="widgetContent" document_srl="%d" %s>' . '<div class="widgetResize"></div>' . '<div class="widgetResizeLeft"></div>' . '<div class="widgetBorder">' . '<div style="%s">', $args->widgetstyle, $style, $args->widget_padding_left, $args->widget_padding_right, $args->widget_padding_top, $args->widget_padding_bottom, $args->document_srl, implode(' ', $attribute), $inner_style); $widget_content_body = $body; $widget_content_footer = sprintf('</div>' . '</div>' . '<div class="widgetContent" style="display:none;width:1px;height:1px;overflow:hidden;">%s</div>' . '</div>', base64_encode($body)); break; // If the widget box; it could // If the widget box; it could case 'widgetBox': // by args $attribute = array(); if ($args) { foreach ($args as $key => $val) { if (in_array($key, array('class', 'style', 'widget_padding_top', 'widget_padding_right', 'widget_padding_bottom', 'widget_padding_left', 'widget', 'widgetstyle', 'document_srl'))) { continue; } if (!is_numeric($val) && (!is_string($val) || strlen($val) == 0)) { continue; } if (strpos($val, '|@|') > 0) { $val = str_replace('|@|', ',', $val); } $attribute[] = sprintf('%s="%s"', $key, htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); } } $widget_content_header = sprintf('<div class="widgetOutput ' . $args->css_class . '" widgetstyle="%s" widget="widgetBox" style="%s;" widget_padding_top="%s" widget_padding_right="%s" widget_padding_bottom="%s" widget_padding_left="%s" %s >' . '<div class="widgetBoxResize"></div>' . '<div class="widgetBoxResizeLeft"></div>' . '<div class="widgetBoxBorder"><div class="nullWidget" style="%s">', $args->widgetstyle, $style, $widget_padding_top, $widget_padding_right, $widget_padding_bottom, $widget_padding_left, implode(' ', $attribute), $inner_style); $widget_content_body = $widgetbox_content; break; // If the General wijetil // If the General wijetil default: // by args $attribute = array(); if ($args) { $allowed_key = array('class', 'style', 'widget_padding_top', 'widget_padding_right', 'widget_padding_bottom', 'widget_padding_left', 'widget'); foreach ($args as $key => $val) { if (in_array($key, $allowed_key)) { continue; } if (!is_numeric($val) && (!is_string($val) || strlen($val) == 0)) { continue; } if (strpos($val, '|@|') > 0) { $val = str_replace('|@|', ',', $val); } $attribute[] = sprintf('%s="%s"', $key, htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); } } $widget_content_header = sprintf('<div class="widgetOutput ' . $args->css_class . '" widgetstyle="%s" style="%s" widget_padding_top="%s" widget_padding_right="%s" widget_padding_bottom="%s" widget_padding_left="%s" widget="%s" %s >' . '<div class="widgetResize"></div>' . '<div class="widgetResizeLeft"></div>' . '<div class="widgetBorder">', $args->widgetstyle, $style, $widget_padding_top, $widget_padding_right, $widget_padding_bottom, $widget_padding_left, $widget, implode(' ', $attribute)); $widget_content_body = sprintf('<div style="%s">%s</div>', $inner_style, $widget_content); $widget_content_footer = '</div></div>'; break; } } // Compile the widget style. if ($args->widgetstyle) { $widget_content_body = $this->compileWidgetStyle($args->widgetstyle, $widget, $widget_content_body, $args, $javascript_mode); } $output = $widget_content_header . $widget_content_body . $widget_content_footer; // Debug widget creation time information added to the results if (__DEBUG__ == 3) { $GLOBALS['__widget_excute_elapsed__'] += getMicroTime() - $start; } $after = microtime(true); $elapsed_time = $after - $before; $slowlog = new stdClass(); $slowlog->caller = "widget.execute"; $slowlog->called = $widget; $slowlog->called_extension = $widget; writeSlowlog('widget', $elapsed_time, $slowlog); // Return result return $output; }
$addon_time_log = new stdClass(); $addon_time_log->caller = $called_position; $addon_time_log->called = "mobile"; $addon_time_log->called_extension = "mobile"; writeSlowlog("addon", $after_time - $before_time, $addon_time_log); $before_time = microtime(true); $rm = ''; $ml = array(); $addon_file = './addons/resize_image/resize_image.addon.php'; if (file_exists($addon_file)) { if ($rm === 'no_run_selected') { if (!isset($ml[$_m])) { unset($addon_info); $addon_info = unserialize(base64_decode('')); @(include $addon_file); } } else { if (isset($ml[$_m]) || count($ml) === 0) { unset($addon_info); $addon_info = unserialize(base64_decode('')); @(include $addon_file); } } } $after_time = microtime(true); $addon_time_log = new stdClass(); $addon_time_log->caller = $called_position; $addon_time_log->called = "resize_image"; $addon_time_log->called_extension = "resize_image"; writeSlowlog("addon", $after_time - $before_time, $addon_time_log);