Przeglądaj źródła

Removing unused file see #6709

Julio Montoya 11 lat temu
rodzic
commit
eb163e4cb5

+ 0 - 593
main/inc/lib/stats.lib.inc.php

@@ -1,593 +0,0 @@
-<?php
-/* For licensing terms, see /license.txt */
-
-/**
-*	This is the statistics library for Dokeos.
-*	Include/require it in your code to use its functionality.
-*
-*	@author Sebastien Piraux
-*	@package chamilo.library
-*
-*/
-
-/*
-	List of functions :
-	-------------------
-
-	addBrowser			--		OK
-	addCountry 			--		OK
-	addOs				--		OK
-	addProvider 			-- 		OK
-	addReferer			--		OK
-	cleanProcessedRecords 	        --		OK
-	decodeOpenInfos 		--		OK
-	extractAgent			--		OK	MUST BE IMPROVED
-	extractCountry 			--		OK 	MUST BE IMPROVED
-	extractProvider 		--		OK	MUST BE IMPROVED
-	fillCountriesTable 		--		OK
-	fillBrowsersTable		--		OK
-	fillOsTable			--		OK
-	fillProvidersTable 		-- 		OK
-	fillReferersTable 		--		OK
-	loadCountries 			--		OK
-	loadOs 				-- 		OK
-	loadBrowsers 			-- 		OK
-                                                    ----------
-							OK BUT MAY BE OPTIMIZED
-
-*/
-
-/*
-	   Variables
-*/
-
-// regroup table names for maintenance purpose
-//we can use the database class: this file is only called in the /index.php file before the global.inc.php
-
-$TABLETRACK_OPEN            = Database::get_main_table(TABLE_STATISTIC_TRACK_E_OPEN);
-$TABLESTATS_PROVIDERS       = Database::get_main_table(TABLE_STATISTIC_TRACK_C_PROVIDERS);
-$TABLESTATS_COUNTRIES       = Database::get_main_table(TABLE_STATISTIC_TRACK_C_COUNTRIES);
-$TABLESTATS_BROWSERS        = Database::get_main_table(TABLE_STATISTIC_TRACK_C_BROWSERS);
-$TABLESTATS_OS              = Database::get_main_table(TABLE_STATISTIC_TRACK_C_OS);
-$TABLESTATS_REFERERS        = Database::get_main_table(TABLE_STATISTIC_TRACK_C_REFERERS);
-/*
-
-	   Main : decodeOpenInfos launch all processes
-*/
-
-
-/**
- * @author Sebastien Piraux <piraux_seb@hotmail.com>
- * @desc uses $TABLETRACK_OPEN to split recorded
-     information, to count occurences (for os, provider,...)
-     and to increment the number of occurrences of each
-     different element into the corresponding tables
- */
-function decodeOpenInfos() {
-    global $TABLETRACK_OPEN;
-    // record initial value of ignore_user_abort
-    $ignore = ignore_user_abort();
-    // prevent script from being stopped while executing, the following can be considered
-    // as a transaction
-    ignore_user_abort(1) ;
-    // we take the last event id to prevent miss of some recorded event
-    // only processed record have to be cleaned
-
-    $sql = "SELECT open_id
-                FROM $TABLETRACK_OPEN
-                WHERE open_date <= NOW()
-                ORDER BY open_id DESC
-                LIMIT 1";
-    //$processBegin = getOneResult($sql);
-    $query = Database::query($sql);
-    $res = @Database::fetch_array($query);
-    $processBegin = $res[0];
-    // process
-
-    //--Providers And Countries-------------------------------------------//
-
-     $sql = "SELECT open_remote_host
-                FROM $TABLETRACK_OPEN
-                WHERE   open_remote_host != ''
-                AND     open_id <= '".$processBegin."' ";
-    $query = Database::query($sql);
-
-    if(Database::num_rows($query) != 0) {
-    	// load list of countries
-    	$list_countries = loadCountries();
-
-       	while ($row = Database::fetch_row ($query)) {
-            $remote_host = $row[0];
-            /*****Provider*****/
-            //extract provider
-            $provider = extractProvider( $remote_host );
-            // add or increment provider in the providers array
-            $providers_array = addProvider( $provider,$providers_array );
-
-            /*****Countries*****/
-            // extract country
-            $country = extractCountry( $remote_host, $list_countries );
-            // increment country in the countries table
-            $countries_array = addCountry( $country, $countries_array );
-        }
-        // update tables
-    	fillProvidersTable( $providers_array );
-    	fillCountriesTable( $countries_array );
-    }
-    // provider and countries done
-    //--Browsers and OS---------------------------------------------------//
-    $sql = "SELECT open_agent
-                FROM $TABLETRACK_OPEN
-                WHERE   open_remote_host != ''
-                AND     open_id <= '".$processBegin."' ";
-    $query =Database::query( $sql );
-    if(Database::num_rows($query) != 0) {
-    	// load lists
-        // of browsers
-        $list_browsers = loadBrowsers();
-        // of OS
-        $list_os = loadOs();
-        while ($row = Database::fetch_row ($query)) {
-            $agent = $row[0];
-            /*****Browser and OS*****/
-            // extract browser and OS
-            list( $browser,$os ) = split( "[|]",extractAgent( $agent , $list_browsers , $list_os ) );
-            // increment browser and OS in the corresponding arrays
-            $browsers_array = addBrowser( $browser , $browsers_array );
-            $os_array = addOs( $os , $os_array );
-        }
-        fillBrowsersTable( $browsers_array );
-    	fillOsTable( $os_array );
-    }
-    // browsers and OS done
-
-    //--Referers----------------------------------------------------------//
-
-    $sql = "SELECT open_referer
-                FROM $TABLETRACK_OPEN
-                WHERE	open_referer != ''
-                AND 	open_id <= '".$processBegin."' ";
-    $query = Database::query( $sql );
-
-    if(Database::num_rows($query) != 0) {
-    	$i=0;
-    	while ($row = Database::fetch_row ($query)) {
-    		$ref = $row[0];
-    		$referers_array = addReferer( $ref , $referers_array );
-    	}
-    	fillReferersTable( $referers_array );
-    }
-    // referers done
-    //-------------------------------------------------------------------//
-    // end of process
-    // cleaning of $TABLETRACK_OPEN table
-    cleanProcessedRecords($processBegin);
-    // reset to the initial value
-    ignore_user_abort($ignore);
-}
-
-/*
- *
- *		Utils
- *
- */
-
-/**
- * @author Sebastien Piraux <piraux_seb@hotmail.com>
- * @param limit : all records BEFORE $limit will be affected
- * @desc this function will delete the remote_host, user_agent
- 	and referer rows from the track_open table recorded before
- 	the date $limit.  OPTIMIZE is called to get back the memory
- 	espaces deleted
- */
-function cleanProcessedRecords( $limit ) {
-    global $TABLETRACK_OPEN;
-    $limit = Database::escape_string($limit);
-    $sql = "UPDATE $TABLETRACK_OPEN
-                            SET open_remote_host = '',
-                                    open_agent = '',
-                                    open_referer =''
-                            WHERE open_id <= '".$limit."'";
-    $query = Database::query( $sql );
-    Database::query("OPTIMIZE TABLE $TABLETRACK_OPEN");
-}
-
-/**
- * 	Provider
- *
- **/
-
-/**
- * @author Sebastien Piraux <piraux_seb@hotmail.com>
- * @param remhost : must be @getHostByAddr($_SERVER['REMOTE_ADDR']
- * @desc this function will extract the provider name from a given
- 	remote host and record this occurence in the corresponding
- 	table
- */
-function extractProvider($remhost) {
-    if($remhost == "Unknown")
-    return $remhost;
-    $explodedRemhost = explode(".", $remhost);
-    $provider = $explodedRemhost[sizeof( $explodedRemhost )-2]
-    			."."
-    			.$explodedRemhost[sizeof( $explodedRemhost )-1];
-
-    if($provider == "co.uk" || $provider == "co.jp")
-    	return $explodedRemhost[sizeof( $explodedRemhost )-3].$provider;
-    else return $provider;
-}
-
-
-/**
- * @author Sebastien Piraux <piraux_seb@hotmail.com>
- * @param provider : name of the provider
- * @param providers_array : list of providers  and their counter
- * @desc this function will :
- 	- if the provider is already in the array it will increment
- 		the corresponding value
- 	- if the provider doesn't exist it will be added and set to 1
- */
-function addProvider($provider,$providers_array) {
-    if(isset($providers_array[$provider])) {
-            // add one unity to this provider occurrences
-            $providers_array[$provider] = $providers_array[$provider] + 1;
-    } else {
-            // first occurrence of this provider
-            $providers_array[$provider] = 1;
-    }
-    return $providers_array;
-}
-
-/**
- * @author Sebastien Piraux <piraux_seb@hotmail.com>
- * @param providers_array : list of providers  and their counter
- * @desc update the providers'table with new values
- */
-function fillProvidersTable($providers_array) {
-    global $TABLESTATS_PROVIDERS;
-
-    if(is_array($providers_array)) {
-        foreach ( $providers_array as $prov=>$number ) {
-            $sql = "SELECT counter
-                                    FROM ".$TABLESTATS_PROVIDERS."
-                                    WHERE provider = '".$prov."'";
-            $res = Database::query($sql);
-
-            // if this provider already exists in the DB
-            if($row = Database::num_rows($res)) {
-                    // update
-                    $sql2 = "UPDATE $TABLESTATS_PROVIDERS
-                                                    SET counter = counter + '$number'
-                                                    WHERE provider = '".$prov."'";
-            } else {
-                    // insert
-                    $sql2 = "INSERT INTO $TABLESTATS_PROVIDERS
-                                            (provider,counter)
-                                            VALUES ('".$prov."','".$number."')";
-            }
-            Database::query($sql2);;
-        }
-    }
-}
-
-/***************************************************************************
- *
- *		Country
- *
- ***************************************************************************/
-
-/**
- * @author Sebastien Piraux <piraux_seb@hotmail.com>
- * @return a 2D array filled with code and name of countries
- * @desc This function is used to build an array containing
- 	countries informations
- */
-function loadCountries() {
-    global $TABLESTATS_COUNTRIES;
-    $sql = "SELECT code, country
-                            FROM $TABLESTATS_COUNTRIES";
-    $res = Database::query($sql);
-    $i = 0 ;
-    if (Database::num_rows($res) > 0){
-	    while ($row = Database::fetch_array($res)) {
-	            $list_countries[$i][0] = $row["code"];
-	            $list_countries[$i][1] = $row["country"];
-	            $i++;
-	    }
-    }
-    Database::free_result($res);
-    return $list_countries;
-}
-
-/**
- * @author Sebastien Piraux <piraux_seb@hotmail.com>
- * @param remhost : must be @getHostByAddr($_SERVER['REMOTE_ADDR']
- * @param list_countries : list of countries -__-
- * @return Name of the country or "Unknown" if not found
- * @desc this function will extract the country from a given remote
- 	host and increment the good value in the corresponding table
- */
-function extractCountry($remhost,$list_countries) {
-    if($remhost == "Unknown")
-        return $remhost;
-    // country code is the last value of remote host
-    $explodedRemhost = explode(".",$remhost);
-    $countryCode = $explodedRemhost[sizeof( $explodedRemhost )-1];
-    for($i = 0 ; $i < sizeof( $list_countries );$i++) {
-            if($list_countries[$i][0] == $countryCode)
-                    return $list_countries[$i][1];
-    }
-}
-
-/**
- * @author Sebastien Piraux <piraux_seb@hotmail.com>
- * @param country : name of the country or 'Unknown'
- * @param countries_array : list of countries and their
- 	number of occurence
- * @desc this function will increment number of occurrence
- 	for $country in the countries' tables
- */
-function addCountry($country,$countries_array) {
-    if(isset($countries_array[$country])) {
-            // add one unity to this provider occurrences
-            $countries_array[$country] = $countries_array[$country] + 1;
-    } else {
-            // first occurrence of this provider
-            $countries_array[$country] = 1;
-    }
-    return $countries_array;
-}
-
-/**
- * @author Sebastien Piraux <piraux_seb@hotmail.com>
- * @param countries_array : list of countries and their counter
- * @desc update the countries'table with new values
- */
-function fillCountriesTable($countries_array) {
-    global $TABLESTATS_COUNTRIES;
-    if(is_array($countries_array)) {
-        foreach ( $countries_array as $country=>$number ) {
-		// update
-		$sql = "UPDATE $TABLESTATS_COUNTRIES
-						SET counter = counter + '$number'
-						WHERE country = '".$country."'";
-		Database::query($sql);
-		}
-    }
-}
-
-/***************************************************************************
- *
- *		Agent : Browser and OS
- *
- ***************************************************************************/
-
-/**
- * @author Sebastien Piraux <piraux_seb@hotmail.com>
- * @return a 2D array filled with code and name of browsers
- * @desc This function is used to build an array containing
- 	browser informations
- */
-function loadBrowsers() {
-
-    $buffer = split ("#","Gecko|Gecko#Mozilla/3|Mozilla 3.x#Mozilla/4.0|Mozilla 4.0x#Mozilla/4.5|Mozilla 4.5x#Mozilla/4.6|Mozilla 4.6x#Mozilla/4.7|Mozilla 4.7x#Mozilla/5.0|Mozilla 5.0x#MSIE 1.2|MSIE 1.2#MSIE 3.01|MSIE 3.x#MSIE 3.02|MSIE 3.x#MSIE 4.0|MSIE 4.x#MSIE 4.01|MSIE 4.x#MSIE 4.5|MSIE 4.5#MSIE 5.0b1|MSIE 5.0x#MSIE 5.0b2|MSIE 5.0x#MSIE 5.0|MSIE 5.0x#MSIE 5.01|MSIE 5.0x#MSIE 5.1|MSIE 5.1#MSIE 5.1b1|MSIE 5.1#MSIE 5.5|MSIE 5.5#MSIE 5.5b1|MSIE 5.5#MSIE 5.5b2|MSIE 5.5#MSIE 6.0|MSIE 6#MSIE 6.0b|MSIE 6#MSIE 6.5a|MSIE 6.5#Lynx/2.8.0|Lynx 2#Lynx/2.8.1|Lynx 2#Lynx/2.8.2|Lynx 2#Lynx/2.8.3|Lynx 2#Lynx/2.8.4|Lynx 2#Lynx/2.8.5|Lynx 2#HTTrack 3.0x|HTTrack#OmniWeb/4.0.1|OmniWeb#Opera 3.60|Opera 3.60#Opera 4.0|Opera 4#Opera 4.01|Opera 4#Opera 4.02|Opera 4#Opera 5|Opera 5#Opera/3.60|Opera 3.60#Opera/4|Opera 4#Opera/5|Opera 5#Opera/6|Opera 6#Opera 6|Opera 6#Netscape6|NS 6#Netscape/6|NS 6#Netscape7|NS 7#Netscape/7|NS 7#Konqueror/2.0|Konqueror 2#Konqueror/2.0.1|Konqueror 2#Konqueror/2.1|Konqueror 2#Konqueror/2.1.1|Konqueror 2#Konqueror/2.1.2|Konqueror 2#Konqueror/2.2|Konqueror 2#Teleport Pro|Teleport Pro#WebStripper|WebStripper#WebZIP|WebZIP#Netcraft Web|NetCraft#Googlebot|Googlebot#WebCrawler|WebCrawler#InternetSeer|InternetSeer#ia_archiver|ia archiver");
-
-    //$list_browser[x][0] is the name of browser as in $_SERVER['HTTP_USER_AGENT']
-    //$list_browser[x][1] is the name of browser that will be used in display and tables
-    $i=0;
-    foreach( $buffer as $buffer1 ) {
-       list ( $list_browsers[$i][0], $list_browsers[$i][1]) = split ('[|]', $buffer1 );
-       $i++;
-    }
-    return $list_browsers;
-}
-
-/**
- * @author Sebastien Piraux <piraux_seb@hotmail.com>
- * @return a 2D array filled with code and name of OS
- * @desc This function is used to build an array containing
- 	OS informations
- */
-function loadOs() {
-    $buffer = split ("#","Windows 95|Win 95#Windows_95|Win 95#Windows 98|Win 98#Windows NT|Win NT#Windows NT 5.0|Win 2000#Windows NT 5.1|Win XP#Windows 2000|Win 2000#Windows XP|Win XP#Windows ME|Win Me#Win95|Win 95#Win98|Win 98#WinNT|Win NT#linux-2.2|Linux 2#Linux|Linux#Linux 2|Linux 2#Macintosh|Mac#Mac_PPC|Mac#Mac_PowerPC|Mac#SunOS 5|SunOS 5#SunOS 6|SunOS 6#FreeBSD|FreeBSD#beOS|beOS#InternetSeer|InternetSeer#Googlebot|Googlebot#Teleport Pro|Teleport Pro");
-    $i=0;
-    foreach( $buffer as $buffer1 ) {
-       list ( $list_os[$i][0], $list_os[$i][1]) = split ('[|]', $buffer1 );
-       $i+=1;
-    }
-    return $list_os;
-}
-
-/**
- * @author Sebastien Piraux <piraux_seb@hotmail.com>
- * @param remhost : must be $_SERVER['HTTP_USER_AGENT']
- * @param list_browsers : browsers list :x
- * @param list_os : os list :x
- * @return a string formatted like : browser|OS
- 	browser and OS are the 'viewable' names
- * @desc this function will extract browser and OS from
- 	$_SERVER['HTTP_USER_AGENT']
- */
-function extractAgent( $user_agent, $list_browsers, $list_os ) {
-	// default values, if nothing corresponding found
-	$viewable_browser = "Unknown";
-	$viewable_os = "Unknown";
-
-	// search for corresponding pattern in $_SERVER['HTTP_USER_AGENT']
-	// for browser
-	for($i = 0; $i < count( $list_browsers ); $i++) {
-		$pos = strpos( $user_agent, $list_browsers[$i][0] );
-		if( $pos !== false ) {
-			$viewable_browser = $list_browsers[$i][1];
-		}
-	}
-
-	// for os
-	for($i = 0; $i < count($list_os); $i++) {
-		$pos = strpos( $user_agent, $list_os[$i][0] );
-		if( $pos !== false ) {
-			$viewable_os = $list_os[$i][1];
-		}
-	}
-	return $viewable_browser."|".$viewable_os;
-
-}
-
-/**
- * @author Sebastien Piraux <piraux_seb@hotmail.com>
- * @param browser : name of the browser or 'Unknown'
- * @param browsers_array :
- * @desc this function will :
- 	- if the browser is already in the table it will increment
- 		the corresponding value
- 	- if the browser doesn't exist it will be added and set to 1
- */
-function addBrowser($browser,$browsers_array) {
-	if(isset( $browsers_array[$browser])) {
-		// add one unity to this provider occurrences
-		$browsers_array[$browser] = $browsers_array[$browser] + 1;
-	} else {
-		// first occurrence of this provider
-		$browsers_array[$browser] = 1;
-	}
-	return $browsers_array;
-}
-
-/**
- * @author Sebastien Piraux <piraux_seb@hotmail.com>
- * @param os : name of the OS or 'Unknown'
- * @param os_array : list of os and number of occurences
- * @desc this function will :
- 	- if the os is already in the table it will increment
- 		the corresponding value
- 	- if the os doesn't exist it will be added and set to 1
- */
-function addOs($os,$os_array) {
-	if(isset($os_array[$os])) {
-		// add one unity to this provider occurrences
-		$os_array[$os] = $os_array[$os] + 1;
-	} else {
-		// first occurrence of this provider
-		$os_array[$os] = 1;
-	}
-	return $os_array;
-}
-
-/**
- * @author Sebastien Piraux <piraux_seb@hotmail.com>
- * @param browsers_array : list of browsers and their counter
- * @desc update the browsers'table with new values
- */
-function fillBrowsersTable($browsers_array) {
-    global $TABLESTATS_BROWSERS;
-    if (is_array($browsers_array)) {
-        foreach ( $browsers_array as $browser=>$number ) {
-			$sql = "SELECT counter
-						FROM $TABLESTATS_BROWSERS
-						WHERE browser = '".$browser."'";
-			$res = Database::query($sql);
-
-			// if this provider already exists in the DB
-			if($row = Database::num_rows($res)) {
-				// update
-				$sql2 = "UPDATE $TABLESTATS_BROWSERS
-								SET counter = counter + '$number'
-								WHERE browser = '".$browser."'";
-			} else {
-				// insert
-				$sql2 = "INSERT INTO $TABLESTATS_BROWSERS
-							(browser,counter)
-							VALUES ('".$browser."','".$number."')";
-			}
-			Database::query($sql2);
-		}
-    }
-}
-
-/**
- * @author Sebastien Piraux <piraux_seb@hotmail.com>
- * @param os_array : list of os and their counter
- * @desc update the os'table with new values
- */
-function fillOsTable($os_array) {
-    global $TABLESTATS_OS;
-    if (is_array($os_array)) {
-        foreach ($os_array as $os=>$number) {
-			$sql = "SELECT counter
-						FROM $TABLESTATS_OS
-						WHERE os = '".$os."'";
-			$res = Database::query($sql);
-
-			// if this provider already exists in the DB
-			if($row = Database::num_rows($res)) {
-				// update
-				$sql2 = "UPDATE $TABLESTATS_OS
-								SET counter = counter + '$number'
-								WHERE os = '".$os."'";
-			} else {
-				// insert
-				$sql2 = "INSERT INTO $TABLESTATS_OS
-							(os,counter)
-							VALUES ('".$os."','".$number."')";
-			}
-			Database::query($sql2);
-		}
-    }
-}
-
-/***************************************************************************
- *
- *		Referers
- *
- ***************************************************************************/
-
-/**
- * @author Sebastien Piraux <piraux_seb@hotmail.com>
- * @param referer : name of the referer
- * @param referers_array : list of referer and number of occurences
- * @desc this function will :
- 	- if the referer is already in the table it will increment
- 		the corresponding value
- 	- if the referer doesn't exist it will be added and set to 1
-*/
-function addReferer($referer,$referers_array) {
-    if(isset($referers_array[$referer])) {
-            // add one unity to this provider occurrences
-            $referers_array[$referer] = $referers_array[$referer] + 1;
-    } else {
-            // first occurrence of this provider
-            $referers_array[$referer] = 1;
-    }
-    return $referers_array;
-}
-
-/**
- * @author Sebastien Piraux <piraux_seb@hotmail.com>
- * @param referers_array : list of referers and their counter
- * @desc update the referers'table with new values
-*/
-function fillReferersTable($referers_array) {
-    global $TABLESTATS_REFERERS;
-    if (is_array($referers_array)) {
-        foreach ( $referers_array as $referer=>$number ) {
-            $sql = "SELECT counter
-                                    FROM $TABLESTATS_REFERERS
-                                    WHERE referer = '".$referer."'";
-            $res = Database::query($sql);
-
-            // if this provider already exists in the DB
-            if($row = Database::num_rows($res)) {
-                    // update
-                    $sql2 = "UPDATE $TABLESTATS_REFERERS
-                                                    SET counter = counter + '$number'
-                                                    WHERE referer = '".$referer."'";
-            } else {
-                    // insert
-                    $sql2 = "INSERT INTO $TABLESTATS_REFERERS
-                                            (referer,counter)
-                                            VALUES ('".$referer."','".$number."')";
-            }
-            Database::query($sql2);
-        }
-    }
-}

+ 0 - 264
main/install/country_data.csv

@@ -1,264 +0,0 @@
-1,'ac','Ascension (ile)',0,,
-2,'ad','Andorre',0,
-3,'ae','Emirats  Arabes Unis',0,
-4,'af','Afghanistan',0,
-5,'ag','Antigua et Barbuda',0,
-6,'ai','Anguilla',0,
-7,'al','Albanie',0,
-8,'am','Arménie',0,
-9,'an','Antilles Neerlandaises',0,
-10,'ao','Angola',0,
-11,'aq','Antarctique',0,
-12,'ar','Argentine',0,
-13,'as','American Samoa',0,
-14,'au','Australie',0,
-15,'aw','Aruba',0,
-16,'az','Azerbaijan',0,
-17,'ba','Bosnie Herzegovine',0,
-18,'bb','Barbade',0,
-19,'bd','Bangladesh',0,
-20,'be','Belgique',0,
-21,'bf','Burkina Faso',0,
-22,'bg','Bulgarie',0,
-23,'bh','Bahrain',0,
-24,'bi','Burundi',0,
-25,'bj','Benin',0,
-26,'bm','Bermudes',0,
-27,'bn','Brunei Darussalam',0,
-28,'bo','Bolivie',0,
-29,'br','Brésil',0,
-30,'bs','Bahamas',0,
-31,'bt','Bhoutan',0,
-32,'bv','Bouvet (ile)',0,
-33,'bw','Botswana',0,
-34,'by','Biélorussie',0,
-35,'bz','Bélize',0,
-36,'ca','Canada',0,
-37,'cc','Cocos (Keeling) iles',0,
-38,'cd','Congo,(République démocratique du)',0,
-39,'cf','Centrafricaine (République )',0,
-40,'cg','Congo',0,
-41,'ch','Suisse',0,
-42,'ci','Cote d\'Ivoire',0,
-43,'ck','Cook (iles)',0,
-44,'cl','Chili',0,
-45,'cm','Cameroun',0,
-46,'cn','Chine',0,
-47,'co','Colombie',0,
-48,'cr','Costa Rica',0,
-49,'cu','Cuba',0,
-50,'cv','Cap Vert',0,
-51,'cx','Christmas (ile)',0,
-52,'cy','Chypre',0,
-53,'cz','Tchéque (République)',0,
-54,'de','Allemagne',0,
-55,'dj','Djibouti',0,
-56,'dk','Danemark',0,
-57,'dm','Dominique',0,
-58,'do','Dominicaine (république)',0,
-59,'dz','Algérie',0,
-60,'ec','Equateur',0,
-61,'ee','Estonie',0,
-62,'eg','Egypte',0,
-63,'eh','Sahara Occidental',0,
-64,'er','Erythrée',0,
-65,'es','Espagne',0,
-66,'et','Ethiopie',0,
-67,'fi','Finlande',0,
-68,'fj','Fiji',0,
-69,'fk','Falkland (Malouines) iles',0,
-70,'fm','Micronésie',0,
-71,'fo','Faroe (iles)',0,
-72,'fr','France',0,
-73,'ga','Gabon',0,
-74,'gd','Grenade',0,
-75,'ge','Géorgie',0,
-76,'gf','Guyane Française',0,
-77,'gg','Guernsey',0,
-78,'gh','Ghana',0,
-79,'gi','Gibraltar',0,
-80,'gl','Groenland',0,
-81,'gm','Gambie',0,
-82,'gn','Guinée',0,
-83,'gp','Guadeloupe',0,
-84,'gq','Guinée Equatoriale',0,
-85,'gr','Grèce',0,
-86,'gs','Georgie du sud et iles Sandwich du sud',0,
-87,'gt','Guatemala',0,
-88,'gu','Guam',0,
-89,'gw','Guinée-Bissau',0,
-90,'gy','Guyana',0,
-91,'hk','Hong Kong',0,
-92,'hm','Heard et McDonald (iles)',0,
-93,'hn','Honduras',0,
-94,'hr','Croatie',0,
-95,'ht','Haiti',0,
-96,'hu','Hongrie',0,
-97,'id','Indonésie',0,
-98,'ie','Irlande',0,
-99,'il','Israël',0,
-100,'im','Ile de Man',0,
-101,'in','Inde',0,
-102,'io','Territoire Britannique de l\'Océan Indien',0,
-103,'iq','Iraq',0,
-104,'ir','Iran',0,
-105,'is','Islande',0,
-106,'it','Italie',0,
-107,'je','Jersey',0,
-108,'jm','Jamaïque',0,
-109,'jo','Jordanie',0,
-110,'jp','Japon',0,
-111,'ke','Kenya',0,
-112,'kg','Kirgizstan',0,
-113,'kh','Cambodge',0,
-114,'ki','Kiribati',0,
-115,'km','Comores',0,
-116,'kn','Saint Kitts et Nevis',0,
-117,'kp','Corée du nord',0,
-118,'kr','Corée du sud',0,
-119,'kw','Koweït',0,
-120,'ky','Caïmanes (iles)',0,
-121,'kz','Kazakhstan',0,
-122,'la','Laos',0,
-123,'lb','Liban',0,
-124,'lc','Sainte Lucie',0,
-125,'li','Liechtenstein',0,
-126,'lk','Sri Lanka',0,
-127,'lr','Liberia',0,
-128,'ls','Lesotho',0,
-129,'lt','Lituanie',0,
-130,'lu','Luxembourg',0,
-131,'lv','Latvia',0,
-132,'ly','Libyan Arab Jamahiriya',0,
-133,'ma','Maroc',0,
-134,'mc','Monaco',0,
-135,'md','Moldavie',0,
-136,'mg','Madagascar',0,
-137,'mh','Marshall (iles)',0,
-138,'mk','Macédoine',0,
-139,'ml','Mali',0,
-140,'mm','Myanmar',0,
-141,'mn','Mongolie',0,
-142,'mo','Macao',0,
-143,'mp','Mariannes du nord (iles)',0,
-144,'mq','Martinique',0,
-145,'mr','Mauritanie',0,
-146,'ms','Montserrat',0,
-147,'mt','Malte',0,
-148,'mu','Maurice (ile)',0,
-149,'mv','Maldives',0,
-150,'mw','Malawi',0,
-151,'mx','Mexique',0,
-152,'my','Malaisie',0,
-153,'mz','Mozambique',0,
-154,'na','Namibie',0,
-155,'nc','Nouvelle Calédonie',0,
-156,'ne','Niger',0,
-157,'nf','Norfolk (ile)',0,
-158,'ng','Nigéria',0,
-159,'ni','Nicaragua',0,
-160,'nl','Pays Bas',0,
-161,'no','Norvège',0,
-162,'np','Népal',0,
-163,'nr','Nauru',0,
-164,'nu','Niue',0,
-165,'nz','Nouvelle Zélande',0,
-166,'om','Oman',0,
-167,'pa','Panama',0,
-168,'pe','Pérou',0,
-169,'pf','Polynésie Française',0,
-170,'pg','Papouasie Nouvelle Guinée',0,
-171,'ph','Philippines',0,
-172,'pk','Pakistan',0,
-173,'pl','Pologne',0,
-174,'pm','St. Pierre et Miquelon',0,
-175,'pn','Pitcairn (ile)',0,
-176,'pr','Porto Rico',0,
-177,'pt','Portugal',0,
-178,'pw','Palau',0,
-179,'py','Paraguay',0,
-180,'qa','Qatar',0,
-181,'re','Réunion (ile de la)',0,
-182,'ro','Roumanie',0,
-183,'ru','Russie',0,
-184,'rw','Rwanda',0,
-185,'sa','Arabie Saoudite',0,
-186,'sb','Salomon (iles)',0,
-187,'sc','Seychelles',0,
-188,'sd','Soudan',0,
-189,'se','Suède',0,
-190,'sg','Singapour',0,
-191,'sh','St. Hélène',0,
-192,'si','Slovénie',0,
-193,'sj','Svalbard et Jan Mayen (iles)',0,
-194,'sk','Slovaquie',0,
-195,'sl','Sierra Leone',0,
-196,'sm','Saint Marin',0,
-197,'sn','Sénégal',0,
-198,'so','Somalie',0,
-199,'sr','Suriname',0,
-200,'st','Sao Tome et Principe',0,
-201,'sv','Salvador',0,
-202,'sy','Syrie',0,
-203,'sz','Swaziland',0,
-204,'tc','Turks et Caïques (iles)',0,
-205,'td','Tchad',0,
-206,'tf','Territoires Français du sud',0,
-207,'tg','Togo',0,
-208,'th','Thailande',0,
-209,'tj','Tajikistan',0,
-210,'tk','Tokelau',0,
-211,'tm','Turkménistan',0,
-212,'tn','Tunisie',0,
-213,'to','Tonga',0,
-214,'tp','Timor Oriental',0,
-215,'tr','Turquie',0,
-216,'tt','Trinidad et Tobago',0,
-217,'tv','Tuvalu',0,
-218,'tw','Taiwan',0,
-219,'tz','Tanzanie',0,
-220,'ua','Ukraine',0,
-221,'ug','Ouganda',0,
-222,'uk','Royaume Uni',0,
-223,'gb','Royaume Uni',0,
-224,'um','US Minor Outlying (iles)',0,
-225,'us','Etats Unis',0,
-226,'uy','Uruguay',0,
-227,'uz','Ouzbékistan',0,
-228,'va','Vatican',0,
-229,'vc','Saint Vincent et les Grenadines',0,
-230,'ve','Venezuela',0,
-231,'vg','Vierges Britaniques (iles)',0,
-232,'vi','Vierges USA (iles)',0,
-233,'vn','Viêt Nam',0,
-234,'vu','Vanuatu',0,
-235,'wf','Wallis et Futuna (iles)',0,
-236,'ws','Western Samoa',0,
-237,'ye','Yemen',0,
-238,'yt','Mayotte',0,
-239,'yu','Yugoslavie',0,
-240,'za','Afrique du Sud',0,
-241,'zm','Zambie',0,
-242,'zr','Zaïre',0,
-243,'zw','Zimbabwe',0,
-244,'com','.COM',0,
-245,'net','.NET',0,
-246,'org','.ORG',0,
-247,'edu','Education',0,
-248,'int','.INT',0,
-249,'arpa','.ARPA',0,
-250,'at','Autriche',0,
-251,'gov','Gouvernement',0,
-252,'mil','Militaire',0,
-253,'su','Ex U.R.S.S.',0,
-254,'reverse','Reverse',0,
-255,'biz','Businesses',0,
-256,'info','.INFO',0,
-257,'name','.NAME',0,
-258,'pro','.PRO',0,
-259,'coop','.COOP',0,
-260,'aero','.AERO',0,
-261,'museum','.MUSEUM',0,
-262,'tv','.TV',0,
-263,'ws','Web site',0,
-264,'--','Unknown',0,

+ 0 - 66
main/install/install.lib.php

@@ -11,46 +11,9 @@
  */
 
 /* CONSTANTS */
-
-//define('SYSTEM_MAIN_DATABASE_FILE', $new_version.'/db_main.sql');
-define('COUNTRY_DATA_FILENAME', 'country_data.csv');
 define('COURSES_HTACCESS_FILENAME', 'htaccess.dist');
 define('SYSTEM_CONFIG_FILENAME', 'configuration.dist.php');
 
-/*      COMMON PURPOSE FUNCTIONS    */
-
-/**
- * This function detects whether the system has been already installed.
- * It should be used for prevention from second running the installation
- * script and as a result - destroying a production system.
- * @return bool     The detected result;
- * @author Ivan Tcholakov, 2010;
- */
-function is_already_installed_system()
-{
-    global $new_version, $_configuration;
-
-    if (empty($new_version)) {
-        return true; // Must be initialized.
-    }
-
-    if (empty($_configuration)) {
-        return false;
-    }
-
-    $current_version = null;
-
-    if (isset($_configuration['dokeos_version'])) {
-        $current_version = trim($_configuration['dokeos_version']);
-    }
-    if (empty($current_version)) {
-        $current_version = trim($_configuration['system_version']);
-    }
-
-    // If the current version is old, upgrading is assumed, the installer goes ahead.
-    return empty($current_version) ? false : version_compare($current_version, $new_version, '>=');
-}
-
 /**
  * This function checks if a php extension exists or not and returns an HTML status string.
  *
@@ -272,16 +235,6 @@ function file_to_array($filename)
     return explode('<br />', nl2br($buffer));
 }
 
-/**
- * We assume this function is called from install scripts that reside inside the install folder.
- */
-function set_file_folder_permissions()
-{
-    @chmod('.', 0755); //set permissions on install dir
-    @chmod('..', 0755); //set permissions on parent dir of install dir
-    @chmod('country_data.csv.csv', 0755);
-}
-
 /**
  * Add's a .htaccess file to the courses directory
  * @param string $url_append The path from your webroot to your chamilo root
@@ -567,25 +520,6 @@ function testDatabaseConnect($dbHostForm, $dbUsernameForm, $dbPassForm, $singleD
 
 }
 
-/**
- * Fills the countries table with a list of countries.
- */
-function fill_track_countries_table($track_countries_table)
-{
-    $file_path = dirname(__FILE__).'/'.COUNTRY_DATA_FILENAME;
-    $countries = file($file_path);
-    $add_country_sql = "INSERT INTO $track_countries_table (id, code, country, counter) VALUES ";
-    foreach ($countries as $line) {
-        $elems = explode(',', $line);
-        $add_country_sql .= '('.intval($elems[0]).',\''.Database::escape_string(
-            $elems[1]
-        ).'\',\''.Database::escape_string($elems[2]).'\','.intval($elems[3]).'),';
-    }
-    $add_country_sql = substr($add_country_sql, 0, -1);
-    //$add_country_sql = "LOAD DATA INFILE '".Database::escape_string($file_path)."' INTO TABLE $track_countries_table FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\'';";
-    @ Database::query($add_country_sql);
-}
-
 /**
  * Creates the structure of the main database and fills it
  * with data. Placeholder symbols in the main database file

+ 0 - 263
main/install/update-db-1.8.3-1.8.4.inc.php

@@ -1,263 +0,0 @@
-<?php
-/* For licensing terms, see /license.txt */
-
-/**
- * Chamilo LMS
- *
- * Update the Chamilo database from an older Dokeos version
- * Notice : This script has to be included by index.php
- * or update_courses.php (deprecated).
- *
- * @package chamilo.install
- * @todo
- * - conditional changing of tables. Currently we execute for example
- * ALTER TABLE `$dbNameForm`.`cours`
- * instructions without checking wether this is necessary.
- * - reorganise code into functions
- * @todo use database library
- */
-
-// Check if we come from index.php or update_courses.php - otherwise display error msg
-if (defined('SYSTEM_INSTALLATION')) {
-
-	// Check if the current Dokeos install is eligible for update
-	if (!file_exists('../inc/conf/configuration.php')) {
-		echo '<strong>'.get_lang('Error').' !</strong> Dokeos '.implode('|', $updateFromVersion).' '.get_lang('HasNotBeenFound').'.<br /><br />
-								'.get_lang('PleasGoBackToStep1').'.
-							    <p><button type="submit" class="back" name="step1" value="&lt; '.get_lang('Back').'">'.get_lang('Back').'</button></p>
-							    </td></tr></table></form></body></html>';
-		exit ();
-	}
-
-	$_configuration['db_glue'] = get_config_param('dbGlu');
-
-	if ($singleDbForm) {
-		$_configuration['table_prefix'] = get_config_param('courseTablePrefix');
-		$_configuration['main_database'] = get_config_param('mainDbName');
-		$_configuration['db_prefix'] = get_config_param('dbNamePrefix');
-	}
-
-	$dbScormForm = preg_replace('/[^a-zA-Z0-9_\-]/', '', $dbScormForm);
-
-	if (!empty($dbPrefixForm) && strpos($dbScormForm, $dbPrefixForm) !== 0) {
-		$dbScormForm = $dbPrefixForm.$dbScormForm;
-	}
-
-	if (empty($dbScormForm) || $dbScormForm == 'mysql' || $dbScormForm == $dbPrefixForm) {
-		$dbScormForm = $dbPrefixForm.'scorm';
-	}
-
-	/*	Normal upgrade procedure: start by updating main, statistic, user databases */
-
-	// If this script has been included by index.php, not update_courses.php, so
-	// that we want to change the main databases as well...
-	$only_test = false;
-	$log = 0;
-	if (defined('SYSTEM_INSTALLATION')) {
-
-		if ($singleDbForm) {
-			$dbStatsForm = $dbNameForm;
-			$dbScormForm = $dbNameForm;
-			$dbUserForm = $dbNameForm;
-		}
-		/**
-		 * Update the databases "pre" migration
-		 */
-		include '../lang/english/create_course.inc.php';
-
-		if ($languageForm != 'english') {
-			// languageForm has been escaped in index.php
-			include '../lang/'.$languageForm.'/create_course.inc.php';
-		}
-
-		//get the main queries list (m_q_list)
-		$m_q_list = get_sql_file_contents('migrate-db-1.8.3-1.8.4-pre.sql', 'main');
-		if (count($m_q_list) > 0) {
-			// Now use the $m_q_list
-			/**
-			 * We connect to the right DB first to make sure we can use the queries
-			 * without a database name
-			 */
-			if (strlen($dbNameForm) > 40) {
-				error_log('Database name '.$dbNameForm.' is too long, skipping', 0);
-			} elseif (!in_array($dbNameForm, $dblist)) {
-				error_log('Database '.$dbNameForm.' was not found, skipping', 0);
-			} else {
-				Database::select_db($dbNameForm);
-				foreach ($m_q_list as $query) {
-					if ($only_test) {
-						error_log("Database::query($dbNameForm, $query)", 0);
-					} else {
-						$res = Database::query($query);
-						if ($log) {
-							error_log("In $dbNameForm, executed: $query", 0);
-						}
-					}
-				}
-			}
-		}
-
-		// Get the stats queries list (s_q_list)
-		$s_q_list = get_sql_file_contents('migrate-db-1.8.3-1.8.4-pre.sql', 'stats');
-
-		if (count($s_q_list) > 0) {
-			// Now use the $s_q_list
-			/**
-			 * We connect to the right DB first to make sure we can use the queries
-			 * without a database name
-			 */
-			if (strlen($dbStatsForm) > 40) {
-				error_log('Database name '.$dbStatsForm.' is too long, skipping', 0);
-			} elseif (!in_array($dbStatsForm, $dblist)) {
-				error_log('Database '.$dbStatsForm.' was not found, skipping', 0);
-			} else {
-				Database::select_db($dbStatsForm);
-				foreach ($s_q_list as $query) {
-					if ($only_test) {
-						error_log("Database::query($dbStatsForm,$query)", 0);
-					} else {
-						$res = Database::query($query);
-						if ($log) {
-							error_log("In $dbStatsForm, executed: $query", 0);
-						}
-					}
-				}
-			}
-		}
-		// Get the user queries list (u_q_list)
-		$u_q_list = get_sql_file_contents('migrate-db-1.8.3-1.8.4-pre.sql', 'user');
-		if (count($u_q_list) > 0) {
-			// Now use the $u_q_list
-			/**
-			 * We connect to the right DB first to make sure we can use the queries
-			 * without a database name
-			 */
-			if (strlen($dbUserForm) > 40) {
-				error_log('Database name '.$dbUserForm.' is too long, skipping', 0);
-			} elseif (!in_array($dbUserForm, $dblist)){
-				error_log('Database '.$dbUserForm.' was not found, skipping', 0);
-			} else {
-				Database::select_db($dbUserForm);
-				foreach ($u_q_list as $query) {
-					if ($only_test) {
-						error_log("Database::query($dbUserForm,$query)", 0);
-						error_log("In $dbUserForm, executed: $query", 0);
-					} else {
-						$res = Database::query($query);
-					}
-				}
-			}
-		}
-		// The SCORM database doesn't need a change in the pre-migrate part - ignore
-	}
-
-	$prefix = '';
-	if ($singleDbForm) {
-		$prefix = $_configuration['table_prefix'];
-	}
-	// Get the courses databases queries list (c_q_list)
-	$c_q_list = get_sql_file_contents('migrate-db-1.8.3-1.8.4-pre.sql', 'course');
-	if (count($c_q_list) > 0) {
-		// Get the courses list
-		if (strlen($dbNameForm) > 40) {
-			error_log('Database name '.$dbNameForm.' is too long, skipping', 0);
-		} elseif (!in_array($dbNameForm, $dblist)) {
-			error_log('Database '.$dbNameForm.' was not found, skipping', 0);
-		} else {
-			Database::select_db($dbNameForm);
-			$res = Database::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL");
-			if ($res === false) { die('Error while querying the courses list in update_db-1.8.3-1.8.4.inc.php'); }
-			if (Database::num_rows($res) > 0) {
-				$i = 0;
-                $list = array();
-				while ($row = Database::fetch_array($res)) {
-					$list[] = $row;
-					$i++;
-				}
-				foreach ($list as $row_course) {
-					// Now use the $c_q_list
-					/**
-					 * We connect to the right DB first to make sure we can use the queries
-					 * without a database name
-					 */
-					if (!$singleDbForm) { //otherwise just use the main one
-						Database::select_db($row_course['db_name']);
-					}
-                    
-					foreach ($c_q_list as $query) {
-						if ($singleDbForm) {
-							$query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/', "$1 $prefix{$row_course['db_name']}_$2$3", $query);
-						}
-
-						if ($only_test) {
-							error_log("Database::query(".$row_course['db_name'].",$query)", 0);
-						} else {
-							$res = Database::query($query);
-							if ($log) {
-								error_log("In ".$row_course['db_name'].", executed: $query", 0);
-							}
-						}
-					}
-					// Ensure each learnpath is present in the item_property table
-					$prefix_course = '';
-					if ($singleDbForm) {
-						$prefix_course = $prefix.$row_course['db_name']."_";
-					}
-
-					$sql_ip = "SELECT * FROM ".$prefix_course."item_property WHERE tool='learnpath'";
-					$res_ip = Database::query($sql_ip);
-					$paths = array();
-					while ($row_ip = Database::fetch_array($res_ip)) {
-						$paths[] = $row_ip['ref'];
-					}
-					$sql_lp = "SELECT * FROM ".$prefix_course."lp";
-					$res_lp = Database::query($sql_lp);
-	    			$tbl_tool = $prefix_course."tool";
-					while ($row_lp = Database::fetch_array($res_lp)) {
-						$time = date("Y-m-d H:i:s", time());
-						$vis = 'v';
-						$input = stripslashes($row_lp['name']);
-						$input = str_replace("'", "''", $input);
-						$input = str_replace('"', "''", $input);
-						$mylink = 'newscorm/lp_controller.php?action=view&lp_id='.$row_lp['id'];
-						$sql2 = "SELECT * FROM $tbl_tool where (name='$input' and image='scormbuilder.gif' and link LIKE '$mylink%')";
-
-						if (in_array($row_lp['id'], $paths)) {
-							// The path is already in item_property, check the visibility is the
-							// same as the homepage tool's
-							$res2 = Database::query($sql2);
-							if (Database::num_rows($res2) > 0) {
-								$row2 = Database::fetch_array($res2);
-								$vis = $row2['visibility'];
-							}
-							$visi = array('v' => 1, 'i' => 0);
-							if ($visi[$vis] != $row_ip['visibility']) {
-								$sql_upd = "UPDATE ".$prefix_course."item_propery SET visibility=".$visi[$vis]." WHERE tool='learnpath' AND ref='".$row_lp['id']."'";
-								$res_upd = Database::query($sql_upd);
-							}
-						} else {
-							// The path is not in item_property, insert it
-							$res2 = Database::query($sql2);
-							if (Database::num_rows($res2) > 0) {
-								$row2 = Database::fetch_array($res2);
-								$vis = $row2['visibility'];
-							}
-							$visi = array('v' => 1, 'i' => 0);
-
-							$sql_ins = "INSERT INTO ".$prefix_course."item_property " .
-									"(tool,ref,insert_date,last_edit_date,insert_user_id,lastedit_type,lastedit_user_id,visibility)" .
-									"VALUES" .
-									"('learnpath',".$row_lp['id'].",'$time','$time',1,'learnpathAdded',1,".$visi[$vis].")";
-							$res_ins = Database::query($sql_ins);
-						}
-					}
-				}
-			}
-		}
-	}
-
-} else {
-
-	echo 'You are not allowed here !' . __FILE__;
-
-}