summaryrefslogtreecommitdiff
blob: 0a73070c5fcbd5b2dc94c802b779d8508d8057c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?

	$verbose = true;
	$qa = true;	


	require_once 'header.php';
	require_once 'class.portage.tree.php';
	require_once 'class.portage.category.php';
	require_once 'class.portage.package.php';
	require_once 'class.portage.ebuild.php';
	
	// Find all the ebuilds that are missing ebuild arch
	$sql = "SELECT id, metadata FROM missing_homepage;";
	$arr = $db->getAssoc($sql);
	
	if($verbose)
		shell::msg(count($arr)." ebuilds to check");
	
	foreach($arr as $ebuild_id => $homepages) {
		
		if(!empty($homepages))
			$arr = arrHomepages($homepages);
		else {
			$arr = array();
		}
		
		if(count($arr)) {
			foreach($arr as $homepage) {
			
				$arr_insert = array(
					'ebuild' => $ebuild_id,
					'homepage' => $homepage,
				);
				
 				$db->autoExecute('ebuild_homepage', $arr_insert, MDB2_AUTOQUERY_INSERT);
			}
		}
		
		
	}
	
	/**
	 * Create an array of the arch keywords
	 *
	 * @param string keywords
	 * @return array
	 */
	function arrHomepages($str) {
		
		$arr = explode(' ', $str);
		
		$arr_keywords = array();
		
		if(count($arr)) {
			
			foreach($arr as $str) {
				if(substr($str, 0, 4) == "http" || substr($str, 0, 6) == "ftp://" || substr($str, 0, 9) == "gopher://")
					$arr_homepages[] = $str;
			}
		}
		
		return $arr_homepages;
	}
	
	
?>