First Commit

This commit is contained in:
mark committed 2026-10-19 15:22:52 -07:00
1 parent 5eb9dd037d
commit 2e62c0e60b
11877 files changed
+2035312

No files matched your search

+197
View File
@@ -0,0 +1,197 @@
<?php
require_once("include/globals.php");
if (SessionActive() != 1 || ! UserLoggedIn()) {
header("Location: /");
exit();
}
// Start the template and output buffering
startTemplate();
$templatePageTitle = $school_record['school_name'] . " " . getLanguageText('TEXT-CLASSIFIED-ADS');
$headerArgs = "";
$school_name = $school_record['school_name'];
$today = date("Y-m-d",time());
$query = "select category,subcategory,sc.record_num " .
"from classified_categories as cc, classified_subcategories as sc " .
"where sc.category_num = cc.record_num " .
"order by 1,2";
$results = db_query($query);
$selected_category = '';
if (array_key_exists('selected_category', $_REQUEST)) $selected_category = intval($_REQUEST['selected_category']);
$prev_cat = "";
$classified_list = "";
$ad_count = 0;
if (db_num_rows($results) > 0) {
while ($row = db_fetch_array($results)) {
$category = $row['category'];
$subcategory = $row['subcategory'];
$rnum = $row['record_num'];
$query = "select count(*) from classified_ads " .
"where school_num = $school_num " .
"and post_until_date >= '$today' " .
"and status = 'Approved' " .
"and subcategory_num = $rnum";
$num = db_getVal($query);
if ($num == 0) continue;
if ($prev_cat != $category) {
if ($prev_cat != "") {
echo(" </optgroup>\n");
$classified_list .= "</ul>\n";
}
echo(" <optgroup label='$category'>\n");
$prev_cat = $category;
$classified_list .= "<h2>$category</h2>\n<ul>\n";
}
$selected = "";
if ($rnum == $selected_category) $selected = " selected='selected'";
echo(" <option value='$rnum'$selected>$subcategory ($num)</option>\n");
$classified_list .= "<li><a href='?action=classified&selected_category=$rnum'>$subcategory</a> ($num)</li>\n";
$ad_count++;
}
if ($ad_count) {
echo(" </optgroup>\n");
$classified_list .= "</ul>\n";
}
}
?>
<br>
<table width='850' cellpadding='5' cellspacing='1' border='0'>
<tr>
<td align='left'>
<?php
if (isset($classified_list) && strlen($classified_list) > 0) {
echo($classified_list);
}
else {
?>
<center>
<p><b>There are no classified ads at this time</b></p>
</center>
<?php
}
?>
</td>
</tr>
<?php
if (array_key_exists('selected_category',$_REQUEST) && strlen($_REQUEST['selected_category']) > 0) {
$selected_category = intval($_REQUEST['selected_category']);
// Get category title
$query = "select concat_ws(' - ',category,subcategory) " .
"from classified_categories as cc, classified_subcategories as sc " .
"where sc.category_num = cc.record_num " .
"and sc.record_num = $selected_category";
$catTitle = db_getVal($query);
?>
<tr>
<td align='center'><h2><?php echo($catTitle) ?></h2></td>
</tr>
<?php
// Get classified ads for the current subcategory
$query = "select c.*,userid " .
"from classified_ads as c, users as u " .
"where c.school_num = $school_num " .
"and u.school_num = $school_num " .
"and c.posted_by = u.record_num " .
"and subcategory_num = $selected_category " .
"and post_until_date >= '$today' " .
"and c.status = 'Approved' " .
"order by posted_time,title";
$ads = db_query($query);
$count = 0;
if (db_num_rows($ads) > 0) {
while ($row = db_fetch_array($ads)) {
extract($row);
$bgclass = "data-odd";
$hclass = "heading";
if (($count % 2) == 0) {
$bgclass = "data-even";
$hclass = "success";
}
$count++;
$description = preg_replace("/\n\n\n\n$/","",$description);
$description = preg_replace("/\n\n\n$/","",$description);
$description = preg_replace("/\n\n$/","",$description);
$description = preg_replace("/\n$/","",$description);
$description = formatUrlsInText($description);
$contact_info = formatUrlsInText($contact_info);
$posted = "Posted By :: $userid";
if ($posted_by == $_SESSION['UserInfo']['record_num']) {
$posted = "<a href='/?action=classified-post&naction=edit&num=$record_num' class='btn btn--outline btn--xsmall'><span>" .
getLanguageText('TEXT-EDIT-AD') . "</span></a>";
$posted .= " ";
$posted .= "<a href='/?action=classified-post&naction=delete&subcategory_num=$selected_category&num=$record_num' onClick='return validateDelete();' " .
"class='btn btn--outline btn--xsmall'><span>" . getLanguageText('TEXT-DELETE-AD') . "</span></a>";
}
$contact = "";
if ($contact_info) $contact .= "Contact :: $contact_info";
if ($contact_email) {
if (strlen($contact)) $contact .= "<br>\n";
$contact .= "Email :: <a href='mailto:$contact_email'>$contact_email</a>";
}
?>
<tr>
<td align='left' class='<?php echo($hclass) ?>'><?php echo($title) ?></td>
</tr>
<tr>
<td align='left' class='<?php echo($bgclass) ?>'>
<table width='100%' cellpadding='0' cellspacing='0' border='0'>
<?php if (strlen($description) > 0) { ?>
<tr>
<td align='left' colspan='2'>
<?php echo(nl2br($description)) ?><br>
<hr width='90%'>
</td>
</tr>
<?php } ?>
<tr>
<td align='left' width='80%'><b><?php echo($contact) ?></b></td>
<td align='right' width='20%'><span class='small'><?php echo($posted) ?></span></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<?php
}
}
}
?>
<tr>
<td align='right'>
<table cellpadding='0' cellspacing='0' border='0'>
<tr>
<td align='left'><a href='?action=classified-post' class='btn btn--outline btn--small'><?php displayLanguageText('TEXT-POST-CLASSIFIED-AD'); ?></a></td>
</tr>
</table>
</td>
</tr>
</table>
<script language="JavaScript">
function validateDelete() {
return confirm("<?php displayLanguageText('JAVA-DELETE-ENTRY'); ?>\n<?php displayLanguageText('JAVA-CONFIRM-DELETE'); ?>");
}
</script>
<?php
endTemplate();
?>