示例#1
0
function parse_backup_php($file) {
    global $durationAccount;

    $source = preg_replace('/^<\?\n/m', "<?php\n", file_get_contents($file));
    if (!preg_match('/encoding = .UTF-8./', $source)) {
        $source = iconv('ISO-8859-7', 'UTF-8//IGNORE', $source);
    }
    $tokens = token_get_all($source);
    $info = array();
    for ($i = 0; $i < count($tokens); $i++) {
        $token = $tokens[$i];
        if (!is_string($token)) {
            list($id, $text) = $token;
            if ($id == T_VARIABLE) {
                $varname = substr($text, 1);
                do {
                    $i++;
                } while ($tokens[$i] == '=' or
                $tokens[$i][0] == T_WHITESPACE);
                list($id, $text) = $tokens[$i];
                if ($id == T_CONSTANT_ENCAPSED_STRING or
                        $id == T_LNUMBER) {
                    $value = eval("return($text);");
                    $info[$varname] = $value;
                }
            } elseif ($id == T_STRING) {
                list($i, $args) = get_args($tokens, ++$i);
                if ($text == 'query') {
                    $sql = $args[0];
                    if (preg_match('/^INSERT INTO `(\w+)` \(([^)]+)\) VALUES\s+(.*)$/si', $sql, $matches)) {
                        $table = $matches[1];
                        // Skip 'stat_accueil' and 'users' (not used any longer) and
                        // 'actions' and 'logins' which can grow very large
                        if (!in_array($table, array('stat_accueil', 'users', 'actions', 'logins'))) {
                            $info['query'][] = array(
                                'table' => $table,
                                'fields' => parse_fields($matches[2]),
                                'values' => parse_values($matches[3]));
                        }
                    }
                } elseif ($text == 'course_details') {
                    $info['code'] = $args[0];
                    $info['lang'] = $args[1];
                    $info['title'] = $args[2];
                    $info['description'] = $args[3];
                    $info['faculty'] = $args[4];
                    $info['visible'] = $args[5];
                    $info['prof_names'] = $args[6];
                    $info['type'] = $args[7];
                } elseif ($text == 'announcement') {
                    $info['announcement'][] = make_assoc($args, array('contenu', 'temps', 'ordre', 'title'));
                } elseif ($text == 'user') {
                    if (!isset($args[9])) {
                        $args[9] = time();
                        $args[10] = time() + $durationAccount;
                    }
                    $info['user'][] = make_assoc($args, array('id', 'name', 'surname', 'username', 'password',
                        'email', 'status', 'phone', 'department',
                        'registered_at', 'expires_at'));
                } elseif ($text == 'assignment_submit') {
                    $info['assignment_submit'][] = make_assoc($args, array('uid', 'assignment_id', 'submission_date',
                        'submission_ip', 'file_path', 'file_name',
                        'comments', 'grade', 'grade_comments',
                        'grade_submission_date', 'grade_submission_ip'));
                } elseif ($text == 'dropbox_file') {
                    $info['dropbox_file'][] = make_assoc($args, array('uploader_id', 'filename', 'filesize', 'title',
                        'description', 'author', 'upload_date', 'last_upload_date'));
                } elseif ($text == 'dropbox_person') {
                    $info['dropbox_person'][] = array(
                        'file_id' => $args[0],
                        'person_id' => $args[1]);
                } elseif ($text == 'dropbox_post') {
                    $info['dropbox_post'][] = array(
                        'file_id' => $args[0],
                        'recipient_id' => $args[1]);
                } elseif ($text == 'group') {
                    $info['group'][] = make_assoc($args, array('user', 'team', 'status', 'role'));
                } elseif ($text == 'course_units') {
                    $info['course_units'][] = make_assoc($args, array('title', 'comments', 'visibility', 'order',
                        'resource_units'));
                } else {
                    $info[$text] = $args;
                }
            } /* else {
              if ($id != T_WHITESPACE) {
              echo token_name($id), ": ", q($text), '<br>';
              }
            } */
        }
    }
    return $info;
}
            $title = '';
            $cost = '';
            $short_desc = '';
            $desc = '';
            $images = array();
            $tabs = array();
            $cover_image = '';
            $cat_id = '';
        }
    }
}
opentable($locale['ctg30']);
echo "<div style='width:100%;text-align:center;'>";
$result = dbquery("SELECT * FROM " . DB_AL_CATALOG_ITEMS);
if (dbrows($result)) {
    $items = make_assoc($result);
}
if (isset($items) && !empty($items)) {
    echo "<form action='" . FUSION_SELF . $aidlink . "&page=items' method='post'>";
    echo "<select name='item_id' class='textbox'>";
    foreach ($items as $item) {
        echo "<option value='" . $item['ctg_item_id'] . "'>" . $item['ctg_item_title'] . "</option>";
    }
    echo "</select>";
    echo "&nbsp;<input type='submit' name='edit' value='" . $locale['ctg7'] . "' class='button' />";
    echo "&nbsp;<input type='submit' name='delete' value='" . $locale['ctg8'] . "' class='button' />";
    echo "</form>";
} else {
    echo $locale['ctg32'];
}
echo "</div>";