示例#1
0
 function __construct($table, $record_id)
 {
     global $CFG;
     $this->table = $table;
     $this->record_id = $CFG->include_id > 0 ? $CFG->include_id : $record_id;
     $this->row = DB::getRecord($this->table, $this->record_id, 0, 1);
     $this->db_fields = DB::getTableFields($this->table);
     $this->db_subtables = DB::getSubtables($this->table);
     $this->db_subtables = !$this->db_subtables ? array() : $this->db_subtables;
     $this->area_i = 0;
     $this->current_area = 0;
     $page_id = Control::getPageId($CFG->url, $CFG->is_tab);
     $corresponding_form = Control::getControls($page_id, 'form', $CFG->is_tab);
     if ($corresponding_form) {
         $k = key($corresponding_form);
         if ($corresponding_form[$k]['params'] = 'Form') {
             foreach ($corresponding_form[$k]['methods'] as $method) {
                 $args = Control::parseArguments($method['arguments'], 'Form', $method['method']);
                 $name = $args['name'] ? $args['name'] : $args['value'];
                 $this->form_method_args[$name] = $args;
             }
         }
     }
 }
示例#2
0
 }
 mysql_select_db($database['Database']);
 $sql = "DELETE FROM sessions WHERE session_start < '" . date('Y-m-d 00:00:00', strtotime('-7 days')) . "' ";
 mysql_query($sql);
 if (!DB::tableExists('admin_cron')) {
     continue;
 }
 Settings::assign($CFG);
 $sql = "SELECT * FROM admin_cron ";
 $result = db_query_array($sql);
 if ($result) {
     foreach ($result as $row) {
         $control = DB::getRecord('admin_controls', $row['control_id'], 0, 1);
         $control_args = unserialize($control['arguments']);
         $method = DB::getRecord('admin_controls_methods', $row['method_id'], 0, 1);
         $method_args = Control::parseArguments($method['arguments'], $control['class'], $method['method']);
         if ($method['method'] == 'emailNotify') {
             $email_field = $method_args['email_field'];
             $message = DB::getRecord($method_args['email_table'], $method_args['email_record'], 0, 1);
         }
         $sql = "SELECT * FROM {$control_args['table']} WHERE 1 ";
         $result1 = db_query_array($sql);
         if ($result1) {
             foreach ($result1 as $row1) {
                 if (!$method_args['run_in_cron']) {
                     foreach ($row1 as $key => $val) {
                         $day = str_replace('[', '', str_replace(']', '', str_ireplace($key, $val, $row['day'])));
                         $month = str_replace('[', '', str_replace(']', '', str_ireplace($key, $val, $row['month'])));
                         $year = str_replace('[', '', str_replace(']', '', str_ireplace($key, $val, $row['year'])));
                     }
                     if ($row['day']) {
示例#3
0
        foreach ($_REQUEST['rows'] as $id => $row) {
            DB::update($row['table'], array($row['folder_field'] => $row['p_id']), $id);
        }
        Messages::add($CFG->ajax_save_message);
        Messages::display();
    }
} elseif ($action == 'download') {
    if ($_REQUEST['download']) {
        $page_id = Control::getPageId($_REQUEST['current_url'], $_REQUEST['is_tab']);
        $controls = Control::getControls($page_id, 'form', $_REQUEST['is_tab']);
        $key = key($controls);
        $methods = $controls[$key]['methods'];
        if ($methods) {
            foreach ($methods as $method) {
                if ($method['method'] == 'fileInput' || $method['method'] == 'fileMultiple') {
                    $args = Control::parseArguments($method['arguments'], 'Form', $method['method']);
                    $field_names[] = $args['name'];
                    $image_sizes = DB::getImageSizes($args['name']);
                    end($image_sizes);
                    $suffixes[$args['name']] = key($image_sizes);
                }
            }
        }
        $filename = $CFG->dirroot . $CFG->temp_file_location . 'archivos_' . date('Y-m-d') . '.zip';
        $zip = new ZipArchive();
        $res = $zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE);
        if ($res) {
            foreach ($_REQUEST['download'] as $table => $ids) {
                $record_ids = explode('|', $ids);
                $table_fields = explode('|', $_REQUEST['table_fields']);
                if (is_array($record_ids)) {
示例#4
0
    function __construct($url, $action, $is_tab = false, $editor_mode = false)
    {
        global $CFG;
        if ($url && !User::permission(false, false, $url)) {
            return false;
        }
        date_default_timezone_set($CFG->default_timezone);
        String::magicQuotesOff();
        $page_id = is_numeric($url) ? $url : Control::getPageId($url, $is_tab);
        if (!($page_id > 0)) {
            return false;
        }
        $page_info = $is_tab ? DB::getRecord('admin_tabs', $page_id, 0, 1) : DB::getRecord('admin_pages', $page_id, 0, 1);
        if ($page_info['one_record'] == 'Y' && !$editor_mode) {
            $action = 'form';
            $_REQUEST['id'] = 1;
            $CFG->control_one_record = 1;
        }
        $controls = Control::getControls($page_id, $action, $is_tab);
        $CFG->editor_page_id = $page_id;
        $CFG->editor_is_tab = $is_tab;
        $CFG->is_ctrl_panel = $page_info['is_ctrl_panel'];
        if ($controls) {
            foreach ($controls as $c_id => $control) {
                $params = $control['params'];
                $is_static = $params['is_static'] == 'Y';
                $class = $params['class'];
                $CFG->control_pass_id = $params['id'];
                if ($_REQUEST['cal_bypass'] && $class != 'Calendar') {
                    continue;
                }
                if ($editor_mode) {
                    $pm_methods = array();
                    echo '<div class="pm_class_container" id="control_' . $params['id'] . '">
							<div class="control_label">' . $params['class'] . ' ' . $params['id'] . '
								<a href="#" title="' . $CFG->move_hover_caption . '" class="move_handle dont_disable"></a>
								<a class="edit dont_disable" title="' . $CFG->edit_hover_caption . '" onclick="pmControlEdit(\'control_' . $params['id'] . '\');"></a>
								<a class="delete dont_disable" title="' . $CFG->delete_hover_caption . '" onclick="pmControlDelete(\'control_' . $params['id'] . '\');"></a>
							</div>
							<input type="hidden" class="this_class" id="control_' . $params['id'] . '_class" value="' . $params['class'] . '"/>
							<input type="hidden" class="this_page_id" id="control_' . $params['id'] . '_page_id" value="' . $params['page_id'] . '"/>
							<input type="hidden" class="this_action" id="control_' . $params['id'] . '_action" value="' . $params['action'] . '"/>
							<input type="hidden" class="this_id" id="control_' . $params['id'] . '_id" value="' . $params['id'] . '"/>';
                }
                if (!$is_static) {
                    $ref = new ReflectionClass($class);
                    $args = Control::parseArguments($params['arguments'], $class, '__construct');
                    $this->class = $ref->newInstanceArgs($args);
                    if ($class == 'Form') {
                        if (!$CFG->in_include) {
                            $this->class->verify();
                            $this->class->save();
                            $this->class->show_errors();
                            $this->class->show_messages();
                            $this->class->get($page_info['url'] == 'my-account' || $url == 'my-account' ? User::$info['id'] : $_REQUEST['id']);
                        } else {
                            $this->class->get($CFG->include_id);
                        }
                        $this->class->info['p_id'] = $_REQUEST['p_id'];
                        $this->class->info['f_id'] = $_REQUEST['f_id'];
                        if ($page_info['url'] == 'my-account' || $url == 'my-account') {
                            $CFG->o_method_suppress = true;
                            $this->class->passiveField('id', 'ID');
                            $CFG->o_method_suppress = true;
                            $this->class->textInput('user', $CFG->user_username, true, false, false, false, false, false, false, false, 1, $CFG->user_unique_error);
                            $CFG->o_method_suppress = true;
                            $this->class->passwordInput('pass', $CFG->user_password, true);
                            $CFG->o_method_suppress = true;
                            $this->class->passwordInput('pass1', $CFG->user_password, true, false, false, false, false, false, 'pass');
                            $CFG->o_method_suppress = true;
                            $this->class->textInput('first_name', $CFG->user_first_name, true);
                            $CFG->o_method_suppress = true;
                            $this->class->textInput('last_name', $CFG->user_last_name, true);
                            $CFG->o_method_suppress = true;
                            $this->class->textInput('phone', $CFG->user_phone);
                            $CFG->o_method_suppress = true;
                            $this->class->textInput('email', $CFG->user_email);
                            if (User::$info['is_admin'] == 'Y') {
                                $CFG->o_method_suppress = true;
                                $this->class->selectInput('f_id', $CFG->user_group, false, $_REQUEST['f_id'], false, 'admin_groups', array('name'));
                                $CFG->o_method_suppress = true;
                                $this->class->checkBox('is_admin', $CFG->user_is_admin);
                            }
                        }
                    }
                    echo '<input type="hidden" id="control_' . $params['id'] . '_table" value="' . $args['table'] . '"/>';
                }
                if (is_array($control['methods'])) {
                    foreach ($control['methods'] as $method) {
                        if ($method['p_id'] > 0) {
                            continue;
                        }
                        //$method['method'] = ($method['method'] == 'selectInput') ? 'fauxSelect' : $method['method'];
                        $CFG->method_id = $method['id'];
                        $args = Control::parseArguments($method['arguments'], $class, $method['method']);
                        $inputs_array = self::getSubMethods($method['id'], $class);
                        if (is_array($inputs_array)) {
                            $args['inputs_array'] = $inputs_array;
                        }
                        if ($is_static) {
                            call_user_func_array("{$class}::{$method['method']}", $args);
                        } else {
                            $method_instance = $ref->getMethod($method['method']);
                            $method_instance->invokeArgs($this->class, $args);
                        }
                    }
                }
                $CFG->method_id = false;
                if ($class == 'Form' && !$CFG->pm_decouple_cancel) {
                    $this->class->cancelButton($CFG->cancel_button);
                }
                if ($class == 'Record' && !$CFG->pm_decouple_cancel) {
                    $d = new Form('dummy');
                    $d->cancelButton($CFG->ok_button);
                    $d->display();
                }
                if (!$is_static) {
                    if ($class == 'Grid') {
                        $this->class->display($_REQUEST['page' . $this->class->i]);
                    } else {
                        $this->class->display();
                    }
                }
                if ($editor_mode) {
                    echo '
					<div class="clear">&nbsp;</div></div>';
                }
                $this->class = false;
            }
        }
        if ($editor_mode) {
            echo '
			<script type="text/javascript">
				$(document).ready(function(){
					startEditor();
				});
			</script>';
        }
    }