-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlogo_test.php
More file actions
159 lines (151 loc) · 7.6 KB
/
logo_test.php
File metadata and controls
159 lines (151 loc) · 7.6 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
<?php
// Include functions if needed
if (!function_exists('getCompanyById')) {
require_once 'includes/functions.php';
}
// Get all companies
$companies = getCompanies();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Logo Test Tool</title>
<script src="https://cdn.tailwindcss.com"></script>
<style>
pre {
background-color: #f5f5f5;
padding: 10px;
border-radius: 4px;
overflow: auto;
}
</style>
</head>
<body class="bg-gray-100 p-8">
<div class="max-w-4xl mx-auto bg-white p-6 rounded-lg shadow-md">
<h1 class="text-2xl font-bold mb-6">Logo Troubleshooting Tool</h1>
<div class="mb-6 p-4 bg-blue-50 border-l-4 border-blue-500">
<p>This tool helps diagnose issues with company logos in PDF invoices.</p>
<?php if (!extension_loaded('gd')): ?>
<div class="mt-3 p-3 bg-yellow-100 border-l-4 border-yellow-500">
<p class="font-bold">PHP GD Extension Not Installed</p>
<p class="mt-1">The GD extension is required for image processing in your invoices.</p>
<div class="mt-3 flex justify-between items-center">
<div>
<p class="font-semibold">How to enable in XAMPP:</p>
<ol class="list-decimal pl-6 mt-2">
<li>Open the php.ini file located at: <code>C:\xampp\php\php.ini</code></li>
<li>Find the line <code>;extension=gd</code> (it has a semicolon at the beginning)</li>
<li>Remove the semicolon to uncomment the line: <code>extension=gd</code></li>
<li>Save the file and restart Apache from the XAMPP Control Panel</li>
</ol>
</div>
<div class="ml-4">
<a href="enable_gd.php" class="inline-block bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
GD Extension Helper
</a>
</div>
</div>
</div>
<?php endif; ?>
</div>
<h2 class="text-xl font-semibold mb-4">System Information</h2>
<div class="mb-6 grid grid-cols-2 gap-4">
<div class="bg-gray-50 p-4 rounded">
<h3 class="font-semibold">GD Extension</h3>
<p><?php echo extension_loaded('gd') ? '<span class="text-green-600">Installed</span>' : '<span class="text-red-600">Not Installed</span>'; ?></p>
</div>
<div class="bg-gray-50 p-4 rounded">
<h3 class="font-semibold">Logo Directory</h3>
<p><?php
$logoDir = 'uploads/logos/';
if (is_dir($logoDir)) {
echo '<span class="text-green-600">Exists</span>';
echo ' (' . (is_writable($logoDir) ? 'Writable' : 'Not Writable') . ')';
} else {
echo '<span class="text-red-600">Does Not Exist</span>';
}
?></p>
</div>
</div>
<h2 class="text-xl font-semibold mb-4">Company Logos</h2>
<div class="overflow-x-auto">
<table class="w-full table-auto border-collapse">
<thead>
<tr class="bg-gray-100">
<th class="border p-2 text-left">Company</th>
<th class="border p-2 text-left">Logo Path</th>
<th class="border p-2 text-left">File Exists</th>
<th class="border p-2 text-left">File Readable</th>
<th class="border p-2 text-left">Preview</th>
</tr>
</thead>
<tbody>
<?php foreach ($companies as $company): ?>
<tr class="hover:bg-gray-50">
<td class="border p-2"><?php echo htmlspecialchars($company['name']); ?></td>
<td class="border p-2"><?php echo !empty($company['logo']) ? htmlspecialchars($company['logo']) : '<em>No logo</em>'; ?></td>
<td class="border p-2">
<?php
if (!empty($company['logo'])) {
echo file_exists($company['logo'])
? '<span class="text-green-600">Yes</span>'
: '<span class="text-red-600">No</span>';
} else {
echo '-';
}
?>
</td>
<td class="border p-2">
<?php
if (!empty($company['logo']) && file_exists($company['logo'])) {
echo is_readable($company['logo'])
? '<span class="text-green-600">Yes</span>'
: '<span class="text-red-600">No</span>';
} else {
echo '-';
}
?>
</td>
<td class="border p-2">
<?php
if (!empty($company['logo']) && file_exists($company['logo'])) {
echo '<img src="' . htmlspecialchars($company['logo']) . '" alt="Logo" class="max-h-10">';
} else {
echo '-';
}
?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<h2 class="text-xl font-semibold mt-8 mb-4">Troubleshooting Steps</h2>
<div class="mb-6 bg-gray-50 p-4 rounded">
<ol class="list-decimal pl-6 space-y-2">
<li>
<strong>GD Extension:</strong> The GD extension is required for image processing. To enable it in XAMPP:
<ul class="list-disc pl-6 mt-1">
<li>Edit <code>C:\xampp\php\php.ini</code></li>
<li>Find <code>;extension=gd</code> and remove the semicolon</li>
<li>Save the file and restart Apache from the XAMPP Control Panel</li>
</ul>
</li>
<li>Check that the logo directory exists and has proper permissions (should be 755).</li>
<li>Verify that logo files exist at the paths stored in the database.</li>
<li>Make sure logo files are readable by the web server (permissions 644).</li>
<li>If using Windows, backslashes in file paths may cause issues - ensure forward slashes are used.</li>
<li>Try uploading a different image format (JPG, PNG, GIF) to see if the issue is format-specific.</li>
<li>Check the web server error logs for any related errors (check <code>C:\xampp\apache\logs\error.log</code>).</li>
</ol>
</div>
<div class="mt-6 text-center">
<a href="manage_companies.php" class="inline-block bg-blue-500 hover:bg-blue-600 text-white font-semibold py-2 px-4 rounded">
Back to Companies
</a>
</div>
</div>
</body>
</html>