Repository navigation
Expand file tree
/
Copy pathCopilot_for_Xcode.entitlements
More file actions
232 lines (200 loc) · 7.95 KB
/
Copy pathCopilot_for_Xcode.entitlements
File metadata and controls
232 lines (200 loc) · 7.95 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<false/>
<key>com.apple.security.application-groups</key>
<array>
<string>$(TeamIdentifierPrefix)group.$(BUNDLE_IDENTIFIER_BASE)</string>
</array>
<key>com.apple.security.automation.apple-events</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
</dict>
</plist>
<?php
/**
* AnnuWeb Categorizer
*
* A simple PHP script to categorize websites based on their content
* by analyzing keywords, meta tags, and content structure.
*
* @version 1.0
*/
class WebCategorizer {
// Predefined categories with their associated keywords
private $categories = [
'technology' => ['programming', 'software', 'hardware', 'tech', 'computer', 'digital', 'code', 'developer'],
'business' => ['finance', 'marketing', 'entrepreneur', 'startup', 'investment', 'corporate', 'commerce'],
'health' => ['medical', 'fitness', 'wellness', 'exercise', 'nutrition', 'doctor', 'healthcare', 'diet'],
'education' => ['school', 'university', 'learning', 'academic', 'courses', 'teaching', 'student', 'education'],
'entertainment' => ['movie', 'music', 'game', 'celebrity', 'show', 'film', 'streaming', 'television'],
'news' => ['article', 'journalism', 'reporter', 'press', 'breaking', 'daily', 'newspaper', 'magazine'],
'shopping' => ['ecommerce', 'store', 'product', 'shop', 'retail', 'sale', 'discount', 'buy', 'purchase'],
'travel' => ['vacation', 'tourism', 'hotel', 'flight', 'destination', 'travel', 'booking', 'adventure'],
'food' => ['recipe', 'restaurant', 'cooking', 'cuisine', 'ingredient', 'meal', 'chef', 'dining'],
'social' => ['community', 'network', 'profile', 'friend', 'share', 'connect', 'social media', 'platform']
];
private $url;
private $content;
private $title;
private $description;
private $keywords;
/**
* Constructor - initialize with URL
*/
public function __construct($url) {
$this->url = $url;
$this->fetchContent();
$this->extractMetaData();
}
/**
* Fetch website content
*/
private function fetchContent() {
try {
// Use cURL to fetch the content
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; AnnuWebCategorizer/1.0)');
$this->content = curl_exec($ch);
if (curl_errno($ch)) {
throw new Exception("cURL Error: " . curl_error($ch));
}
curl_close($ch);
} catch (Exception $e) {
die("Error fetching website content: " . $e->getMessage());
}
}
/**
* Extract title, description, and keywords from meta tags
*/
private function extractMetaData() {
// Extract title
preg_match('/<title[^>]*>(.*?)<\/title>/si', $this->content, $matches);
$this->title = isset($matches[1]) ? trim(strip_tags($matches[1])) : '';
// Extract description
preg_match('/<meta[^>]*name=["\']description["\'][^>]*content=["\']([^"\']*)["\'][^>]*>/si', $this->content, $matches);
if (empty($matches)) {
preg_match('/<meta[^>]*content=["\']([^"\']*)["\'][^>]*name=["\']description["\'][^>]*>/si', $this->content, $matches);
}
$this->description = isset($matches[1]) ? trim($matches[1]) : '';
// Extract keywords
preg_match('/<meta[^>]*name=["\']keywords["\'][^>]*content=["\']([^"\']*)["\'][^>]*>/si', $this->content, $matches);
if (empty($matches)) {
preg_match('/<meta[^>]*content=["\']([^"\']*)["\'][^>]*name=["\']keywords["\'][^>]*>/si', $this->content, $matches);
}
$this->keywords = isset($matches[1]) ? trim($matches[1]) : '';
}
/**
* Clean and extract plain text from HTML content
*/
private function getCleanContent() {
// Remove scripts, styles, and HTML tags
$cleanContent = preg_replace('/<script[^>]*>.*?<\/script>/si', '', $this->content);
$cleanContent = preg_replace('/<style[^>]*>.*?<\/style>/si', '', $cleanContent);
$cleanContent = strip_tags($cleanContent);
// Remove extra whitespace
$cleanContent = preg_replace('/\s+/', ' ', $cleanContent);
return trim($cleanContent);
}
/**
* Categorize the website
*/
public function categorize() {
$scores = [];
// Initialize scores for all categories
foreach ($this->categories as $category => $keywords) {
$scores[$category] = 0;
}
// Combine all text for analysis
$allText = strtolower($this->title . ' ' . $this->description . ' ' . $this->keywords . ' ' . $this->getCleanContent());
// Calculate scores based on keyword occurrences
foreach ($this->categories as $category => $keywords) {
foreach ($keywords as $keyword) {
$count = substr_count($allText, strtolower($keyword));
$scores[$category] += $count;
}
}
// Sort scores in descending order
arsort($scores);
return $scores;
}
/**
* Get top categories (with optional limit)
*/
public function getTopCategories($limit = 3) {
$scores = $this->categorize();
// Get top N categories
$topCategories = array_slice($scores, 0, $limit, true);
return $topCategories;
}
/**
* Get website info
*/
public function getWebsiteInfo() {
return [
'url' => $this->url,
'title' => $this->title,
'description' => $this->description
];
}
/**
* Add custom category with keywords
*/
public function addCategory($category, $keywords) {
if (!is_array($keywords)) {
$keywords = [$keywords];
}
if (isset($this->categories[$category])) {
// Merge with existing category
$this->categories[$category] = array_merge($this->categories[$category], $keywords);
$this->categories[$category] = array_unique($this->categories[$category]);
} else {
// Add new category
$this->categories[$category] = $keywords;
}
}
}
// Usage example
if (isset($argv[1])) {
// Command-line usage
$url = $argv[1];
$categorizer = new WebCategorizer($url);
$topCategories = $categorizer->getTopCategories();
$info = $categorizer->getWebsiteInfo();
echo "Website: {$info['title']}\n";
echo "URL: {$info['url']}\n";
echo "Description: {$info['description']}\n\n";
echo "Top Categories:\n";
foreach ($topCategories as $category => $score) {
echo "- $category (Score: $score)\n";
}
} elseif (isset($_GET['url'])) {
// Web interface usage
header('Content-Type: application/json');
$url = filter_var($_GET['url'], FILTER_SANITIZE_URL);
if (!filter_var($url, FILTER_VALIDATE_URL)) {
echo json_encode(['error' => 'Invalid URL']);
exit;
}
$categorizer = new WebCategorizer($url);
$topCategories = $categorizer->getTopCategories();
$info = $categorizer->getWebsiteInfo();
echo json_encode([
'website' => $info,
'categories' => $topCategories
]);
} else {
// Display usage instructions
echo "AnnuWeb Categorizer\n\n";
echo "Usage:\n";
echo " Command line: php categorizer.php <url>\n";
echo " Web API: categorizer.php?url=<url>\n";
}
?>