function classify($req)
{
    global $CONFIG;
    set_time_limit(0);
    //this avoids timeouts
    require_once $CONFIG->path . "mod/profile_manager/views/default/profile_manager/members/config.php";
    require_once $CONFIG->path . "mod/profile_manager/views/default/profile_manager/members/classes.php";
    $outputfile = $CONFIG->path . "mod/profile_manager/views/default/profile_manager/members/output.log";
    file_put_contents($outputfile, "Starting classification...\n", FILE_APPEND);
    $classification_methods = array("metadata" => $classification_method_metadata, "uses" => $classification_method_uses, "tags" => $classification_method_tags, "replinks" => $classification_method_replinks);
    foreach ($classification_methods as $type => $value) {
        file_put_contents($outputfile, "Creating clusters for {$type}...\n", FILE_APPEND);
        if ($value == 1) {
            //if classification_method is Kohonen
            require_once $CONFIG->path . "mod/profile_manager/views/default/profile_manager/members/kohonen.php";
            $array_clusters[$type] = run_kohonen($type, $req["cl_useold"]);
        } elseif ($value == 2) {
            //if classification_method is aggregative
            require_once $CONFIG->path . "mod/profile_manager/views/default/profile_manager/members/aggregative.php";
            $array_clusters[$type] = clusterize_aggregative($type, $req["cl_useold"]);
        } else {
            //if classification_method is 3 (YACA)
            require_once $CONFIG->path . "mod/profile_manager/views/default/profile_manager/members/yaca.php";
            $array_clusters[$type] = clusterize_yaca($type, $req["cl_useold"]);
        }
        //add positive features to clusters
        if ($type != "replinks") {
            //there are not positive features for replinks
            file_put_contents($outputfile, "Calculating positive features for {$type}...\n", FILE_APPEND);
            $dt_matrix = unserialize(file_get_contents($IOdir . $type . "_dt"));
            $array_clusters[$type] = get_positive_features($array_clusters[$type], $dt_matrix, $type);
        }
        file_put_contents($IOdir . "clusters_" . $type, serialize($array_clusters[$type]));
        if (PHP_OS == "Linux" && posix_getuid() == fileowner($IOdir . "clusters_" . $type)) {
            chmod($IOdir . "clusters_" . $type, 0666);
        }
        //set rw permissions for everybody for this file
        file_put_contents($outputfile, "Clusters for {$type} created\n\n", FILE_APPEND);
    }
    return "OK";
}
function create_clusters()
{
    global $IndexingClassificationPath;
    global $classification_method_metadata;
    global $classification_method_tags;
    global $classification_method_uses;
    global $classification_method_replinks;
    require_once 'classes.php';
    $classification_methods = array("metadata" => $classification_method_metadata, "uses" => $classification_method_uses, "tags" => $classification_method_tags, "replinks" => $classification_method_replinks);
    foreach ($classification_methods as $type => $value) {
        print "\nCreating clusters for {$type}...\n";
        if ($value == 1) {
            //if classification_method is Kohonen
            require_once 'kohonen.php';
            $array_clusters[$type] = run_kohonen($type);
        } elseif ($value == 2) {
            //if classification_method is aggregative
            require_once 'aggregative.php';
            $array_clusters[$type] = clusterize_aggregative($type);
        } else {
            //if classification_method is 3 (YACA)
            require_once 'yaca.php';
            $array_clusters[$type] = clusterize_yaca($type);
        }
        print "\nClusters for {$type} created\n";
    }
    return $array_clusters;
}