function getPost($postId) { $post = fetchPost($postId); if ($post == null) { return get404(); } $content = '<p class="topNotification">You are viewing a single blog post. You can go back to view all of my recent <a href="/blog">Blog Posts</a>.</p>'; $content .= '<div class="contentBlock"><h1>' . $post['title'] . '</h1>'; $content .= '<p class="blogPostTagline time">' . date("F jS, Y", strtotime($post['post_date'])) . '</p>'; $content .= '<p class="blogPostTagline tags">' . getTagList($post['id']) . '</p>'; $content .= '<div class="spacer"></div><p class="blogPostOpeneing">' . $post['intro_content'] . '</p>'; $content .= $post['main_content']; $content .= '</div><p class="topNotification">Go back to my most recent <a href="/blog">Blog</a> posts...</p>'; return $content; }
// Depending on the 'result' value the 'load' carries either the // parse tree or error message. The latter case is a bug, because // RackCode saving function was supposed to validate its input. if ($rackCode['result'] != 'ACK') { throw new RackTablesError($rackCode['load'], RackTablesError::INTERNAL); } $rackCode = $rackCode['load']; // Only call buildPredicateTable() once and save the result, because it will remain // constant during one execution for constraints processing. $pTable = buildPredicateTable($rackCode); // Constraints parse trees aren't cached in the database, so the least to keep // things running is to maintain application cache for them. $entityCache = array(); // used by getExplicitTagsOnly() $tagRelCache = array(); $taglist = getTagList(); $tagtree = treeFromList($taglist); $auto_tags = array(); if (!isCLIMode() && isset($_SERVER['REMOTE_ADDR'])) { $auto_tags[] = array('tag' => '$client_' . $_SERVER['REMOTE_ADDR']); } // Initial chain for the current user. $user_given_tags = array(); // list of regexps used in findAutoTagWarnings to check RackCode. // add your regexps here to suppress 'Martian autotag' warnings $user_defined_atags = array(); // This also can be modified in local.php. $pageheaders = array(100 => "<link rel='ICON' type='image/x-icon' href='?module=chrome&uri=pix/favicon.ico' />"); addCSS('css/pi.css'); if (!isset($script_mode) or $script_mode !== TRUE) { // A successful call to authenticate() always generates autotags and somethimes
function print_post() { echo '<h1> <a href="' . HTTP_SERVER . $this->post_link . '.html">' . html_entity_decode($this->post_h1) . '</a> </h1> <h3> posted by <a href="' . HTTP_SERVER . 'about-me.html">' . AUTHOR . '</a> under ' . getCatList($this->cats) . ' on ' . format_date($this->post_created) . ' </h3> <p class="desc"> ' . html_entity_decode($this->post_h2) . ' </p> ' . $this->post_ps . ' <div class="updates"> <p> This post has been updated from its original form on ' . format_date($this->post_modified) . '- originally posted on ' . format_date($this->post_created) . '. </p> </div> <div class="postfoot"> <p> Tagged under: ' . getTagList($this->tags) . ' </p> </div> <div class="postfoot"> <p> ' . $this->comments . ' Comments </p> </div>'; }
function renderDataIntegrityReport() { global $nextorder; $violations = FALSE; // check 1: EntityLink rows referencing not-existent relatives // check 1.1: children $realms = array('location' => 'Location', 'object' => 'RackObject', 'rack' => 'Rack', 'row' => 'Row'); $orphans = array(); foreach ($realms as $realm => $table) { $result = usePreparedSelectBlade('SELECT EL.* FROM EntityLink EL ' . "LEFT JOIN {$table} ON EL.child_entity_id = {$table}.id " . "WHERE EL.child_entity_type = ? AND {$table}.id IS NULL", array($realm)); $rows = $result->fetchAll(PDO::FETCH_ASSOC); unset($result); $orphans = array_merge($orphans, $rows); } if (count($orphans)) { $violations = TRUE; startPortlet('EntityLink: Missing Children (' . count($orphans) . ')'); echo "<table cellpadding=5 cellspacing=0 align=center class=cooltable>\n"; echo "<tr><th>Parent</th><th>Child Type</th><th>Child ID</th></tr>\n"; $order = 'odd'; foreach ($orphans as $orphan) { $realm_name = formatRealmName($orphan['parent_entity_type']); $parent = spotEntity($orphan['parent_entity_type'], $orphan['parent_entity_id']); echo "<tr class=row_{$order}>"; echo "<td>{$realm_name}: {$parent['name']}</td>"; echo "<td>{$orphan['child_entity_type']}</td>"; echo "<td>{$orphan['child_entity_id']}</td>"; echo "</tr>\n"; $order = $nextorder[$order]; } echo "</table>\n"; finishPortLet(); } // check 1.2: parents $orphans = array(); foreach ($realms as $realm => $table) { $result = usePreparedSelectBlade('SELECT EL.* FROM EntityLink EL ' . "LEFT JOIN {$table} ON EL.parent_entity_id = {$table}.id " . "WHERE EL.parent_entity_type = ? AND {$table}.id IS NULL", array($realm)); $rows = $result->fetchAll(PDO::FETCH_ASSOC); unset($result); $orphans = array_merge($orphans, $rows); } if (count($orphans)) { $violations = TRUE; startPortlet('EntityLink: Missing Parents (' . count($orphans) . ')'); echo "<table cellpadding=5 cellspacing=0 align=center class=cooltable>\n"; echo "<tr><th>Child</th><th>Parent Type</th><th>Parent ID</th></tr>\n"; $order = 'odd'; foreach ($orphans as $orphan) { $realm_name = formatRealmName($orphan['child_entity_type']); $child = spotEntity($orphan['child_entity_type'], $orphan['child_entity_id']); echo "<tr class=row_{$order}>"; echo "<td>{$realm_name}: {$child['name']}</td>"; echo "<td>{$orphan['parent_entity_type']}</td>"; echo "<td>{$orphan['parent_entity_id']}</td>"; echo "</tr>\n"; $order = $nextorder[$order]; } echo "</table>\n"; finishPortLet(); } // check 3: multiple tables referencing non-existent dictionary entries // check 3.1: AttributeMap $orphans = array(); $result = usePreparedSelectBlade('SELECT AM.*, A.name AS attr_name, C.name AS chapter_name ' . 'FROM AttributeMap AM ' . 'LEFT JOIN Attribute A ON AM.attr_id = A.id ' . 'LEFT JOIN Chapter C ON AM.chapter_id = C.id ' . 'LEFT JOIN Dictionary D ON AM.objtype_id = D.dict_key ' . 'WHERE D.dict_key IS NULL'); $orphans = $result->fetchAll(PDO::FETCH_ASSOC); unset($result); if (count($orphans)) { $violations = TRUE; startPortlet('AttributeMap: Invalid Mappings (' . count($orphans) . ')'); echo "<table cellpadding=5 cellspacing=0 align=center class=cooltable>\n"; echo "<tr><th>Attribute</th><th>Chapter</th><th>Object TypeID</th></tr>\n"; $order = 'odd'; foreach ($orphans as $orphan) { echo "<tr class=row_{$order}>"; echo "<td>{$orphan['attr_name']}</td>"; echo "<td>{$orphan['chapter_name']}</td>"; echo "<td>{$orphan['objtype_id']}</td>"; echo "</tr>\n"; $order = $nextorder[$order]; } echo "</table>\n"; finishPortLet(); } // check 3.2: Object $orphans = array(); $result = usePreparedSelectBlade('SELECT O.* FROM Object O ' . 'LEFT JOIN Dictionary D ON O.objtype_id = D.dict_key ' . 'WHERE D.dict_key IS NULL'); $orphans = $result->fetchAll(PDO::FETCH_ASSOC); unset($result); if (count($orphans)) { $violations = TRUE; startPortlet('Object: Invalid Types (' . count($orphans) . ')'); echo "<table cellpadding=5 cellspacing=0 align=center class=cooltable>\n"; echo "<tr><th>ID</th><th>Name</th><th>Type ID</th></tr>\n"; $order = 'odd'; foreach ($orphans as $orphan) { echo "<tr class=row_{$order}>"; echo "<td>{$orphan['id']}</td>"; echo "<td>{$orphan['name']}</td>"; echo "<td>{$orphan['objtype_id']}</td>"; echo "</tr>\n"; $order = $nextorder[$order]; } echo "</table>\n"; finishPortLet(); } // check 3.3: ObjectHistory $orphans = array(); $result = usePreparedSelectBlade('SELECT OH.* FROM ObjectHistory OH ' . 'LEFT JOIN Dictionary D ON OH.objtype_id = D.dict_key ' . 'WHERE D.dict_key IS NULL'); $orphans = $result->fetchAll(PDO::FETCH_ASSOC); unset($result); if (count($orphans)) { $violations = TRUE; startPortlet('ObjectHistory: Invalid Types (' . count($orphans) . ')'); echo "<table cellpadding=5 cellspacing=0 align=center class=cooltable>\n"; echo "<tr><th>ID</th><th>Name</th><th>Type ID</th></tr>\n"; $order = 'odd'; foreach ($orphans as $orphan) { echo "<tr class=row_{$order}>"; echo "<td>{$orphan['id']}</td>"; echo "<td>{$orphan['name']}</td>"; echo "<td>{$orphan['objtype_id']}</td>"; echo "</tr>\n"; $order = $nextorder[$order]; } echo "</table>\n"; finishPortLet(); } // check 3.4: ObjectParentCompat $orphans = array(); $result = usePreparedSelectBlade('SELECT OPC.*, PD.dict_value AS parent_name, CD.dict_value AS child_name ' . 'FROM ObjectParentCompat OPC ' . 'LEFT JOIN Dictionary PD ON OPC.parent_objtype_id = PD.dict_key ' . 'LEFT JOIN Dictionary CD ON OPC.child_objtype_id = CD.dict_key ' . 'WHERE PD.dict_key IS NULL OR CD.dict_key IS NULL'); $orphans = $result->fetchAll(PDO::FETCH_ASSOC); unset($result); if (count($orphans)) { $violations = TRUE; startPortlet('Object Container Compatibility rules: Invalid Parent or Child Type (' . count($orphans) . ')'); echo "<table cellpadding=5 cellspacing=0 align=center class=cooltable>\n"; echo "<tr><th>Parent</th><th>Parent Type ID</th><th>Child</th><th>Child Type ID</th></tr>\n"; $order = 'odd'; foreach ($orphans as $orphan) { echo "<tr class=row_{$order}>"; echo "<td>{$orphan['parent_name']}</td>"; echo "<td>{$orphan['parent_objtype_id']}</td>"; echo "<td>{$orphan['child_name']}</td>"; echo "<td>{$orphan['child_objtype_id']}</td>"; echo "</tr>\n"; $order = $nextorder[$order]; } echo "</table>\n"; finishPortLet(); } // check 4: relationships that violate ObjectParentCompat Rules $invalids = array(); $result = usePreparedSelectBlade('SELECT CO.id AS child_id, CO.objtype_id AS child_type_id, CD.dict_value AS child_type, CO.name AS child_name, ' . 'PO.id AS parent_id, PO.objtype_id AS parent_type_id, PD.dict_value AS parent_type, PO.name AS parent_name ' . 'FROM Object CO ' . 'LEFT JOIN EntityLink EL ON CO.id = EL.child_entity_id ' . 'LEFT JOIN Object PO ON EL.parent_entity_id = PO.id ' . 'LEFT JOIN ObjectParentCompat OPC ON PO.objtype_id = OPC.parent_objtype_id ' . 'LEFT JOIN Dictionary PD ON PO.objtype_id = PD.dict_key ' . 'LEFT JOIN Dictionary CD ON CO.objtype_id = CD.dict_key ' . "WHERE EL.parent_entity_type = 'object' AND EL.child_entity_type = 'object' " . 'AND OPC.parent_objtype_id IS NULL'); $invalids = $result->fetchAll(PDO::FETCH_ASSOC); unset($result); if (count($invalids)) { $violations = TRUE; startPortlet('Objects: Violate Object Container Compatibility rules (' . count($invalids) . ')'); echo "<table cellpadding=5 cellspacing=0 align=center class=cooltable>\n"; echo "<tr><th>Contained Obj Name</th><th>Contained Obj Type</th><th>Container Obj Name</th><th>Container Obj Type</th></tr>\n"; $order = 'odd'; foreach ($invalids as $invalid) { echo "<tr class=row_{$order}>"; echo "<td>{$invalid['child_name']}</td>"; echo "<td>{$invalid['child_type']}</td>"; echo "<td>{$invalid['parent_name']}</td>"; echo "<td>{$invalid['parent_type']}</td>"; echo "</tr>\n"; $order = $nextorder[$order]; } echo "</table>\n"; finishPortLet(); } // check 5: Links that violate PortCompat Rules $invalids = array(); $result = usePreparedSelectBlade('SELECT OA.id AS obja_id, OA.name AS obja_name, L.porta AS porta_id, PA.name AS porta_name, POIA.oif_name AS porta_type, ' . 'OB.id AS objb_id, OB.name AS objb_name, L.portb AS portb_id, PB.name AS portb_name, POIB.oif_name AS portb_type ' . 'FROM Link L ' . 'LEFT JOIN Port PA ON L.porta = PA.id ' . 'LEFT JOIN Object OA ON PA.object_id = OA.id ' . 'LEFT JOIN PortOuterInterface POIA ON PA.type = POIA.id ' . 'LEFT JOIN Port PB ON L.portb = PB.id ' . 'LEFT JOIN Object OB ON PB.object_id = OB.id ' . 'LEFT JOIN PortOuterInterface POIB ON PB.type = POIB.id ' . 'LEFT JOIN PortCompat PC on PA.type = PC.type1 AND PB.type = PC.type2 ' . 'WHERE PC.type1 IS NULL OR PC.type2 IS NULL'); $invalids = $result->fetchAll(PDO::FETCH_ASSOC); unset($result); if (count($invalids)) { $violations = TRUE; startPortlet('Port Links: Violate Port Compatibility Rules (' . count($invalids) . ')'); echo "<table cellpadding=5 cellspacing=0 align=center class=cooltable>\n"; echo "<tr><th>Object A</th><th>Port A Name</th><th>Port A Type</th><th>Object B</th><th>Port B Name</th><th>Port B Type</th></tr>\n"; $order = 'odd'; foreach ($invalids as $invalid) { echo "<tr class=row_{$order}>"; echo "<td>{$invalid['obja_name']}</td>"; echo "<td>{$invalid['porta_name']}</td>"; echo "<td>{$invalid['porta_type']}</td>"; echo "<td>{$invalid['objb_name']}</td>"; echo "<td>{$invalid['portb_name']}</td>"; echo "<td>{$invalid['portb_type']}</td>"; echo "</tr>\n"; $order = $nextorder[$order]; } echo "</table>\n"; finishPortLet(); } // check 6: TagStorage rows referencing non-existent parents $realms = array('file' => array('table' => 'File', 'column' => 'id'), 'ipv4net' => array('table' => 'IPv4Network', 'column' => 'id'), 'ipv4rspool' => array('table' => 'IPv4RSPool', 'column' => 'id'), 'ipv4vs' => array('table' => 'IPv4VS', 'column' => 'id'), 'ipv6net' => array('table' => 'IPv6Network', 'column' => 'id'), 'ipvs' => array('table' => 'VS', 'column' => 'id'), 'location' => array('table' => 'Location', 'column' => 'id'), 'object' => array('table' => 'RackObject', 'column' => 'id'), 'rack' => array('table' => 'Rack', 'column' => 'id'), 'user' => array('table' => 'UserAccount', 'column' => 'user_id'), 'vst' => array('table' => 'VLANSwitchTemplate', 'column' => 'id')); $orphans = array(); foreach ($realms as $realm => $details) { $result = usePreparedSelectBlade('SELECT TS.*, TT.tag FROM TagStorage TS ' . 'LEFT JOIN TagTree TT ON TS.tag_id = TT.id ' . "LEFT JOIN {$details['table']} ON TS.entity_id = {$details['table']}.{$details['column']} " . "WHERE TS.entity_realm = ? AND {$details['table']}.{$details['column']} IS NULL", array($realm)); $rows = $result->fetchAll(PDO::FETCH_ASSOC); unset($result); $orphans = array_merge($orphans, $rows); } if (count($orphans)) { $violations = TRUE; startPortlet('TagStorage: Missing Parents (' . count($orphans) . ')'); echo "<table cellpadding=5 cellspacing=0 align=center class=cooltable>\n"; echo "<tr><th>Tag</th><th>Parent Type</th><th>Parent ID</th></tr>\n"; $order = 'odd'; foreach ($orphans as $orphan) { $realm_name = formatRealmName($orphan['entity_realm']); echo "<tr class=row_{$order}>"; echo "<td>{$orphan['tag']}</td>"; echo "<td>{$realm_name}</td>"; echo "<td>{$orphan['entity_id']}</td>"; echo "</tr>\n"; $order = $nextorder[$order]; } echo "</table>\n"; finishPortLet(); } // check 7: FileLink rows referencing non-existent parents // re-use the realms list from the TagStorage check, with a few mods unset($realms['file'], $realms['vst']); $realms['row'] = array('table' => 'Row', 'column' => 'id'); $orphans = array(); foreach ($realms as $realm => $details) { $result = usePreparedSelectBlade('SELECT FL.*, F.name FROM FileLink FL ' . 'LEFT JOIN File F ON FL.file_id = F.id ' . "LEFT JOIN {$details['table']} ON FL.entity_id = {$details['table']}.{$details['column']} " . "WHERE FL.entity_type = ? AND {$details['table']}.{$details['column']} IS NULL", array($realm)); $rows = $result->fetchAll(PDO::FETCH_ASSOC); unset($result); $orphans = array_merge($orphans, $rows); } if (count($orphans)) { $violations = TRUE; startPortlet('FileLink: Missing Parents (' . count($orphans) . ')'); echo "<table cellpadding=5 cellspacing=0 align=center class=cooltable>\n"; echo "<tr><th>File</th><th>Parent Type</th><th>Parent ID</th></tr>\n"; $order = 'odd'; foreach ($orphans as $orphan) { $realm_name = formatRealmName($orphan['entity_type']); echo "<tr class=row_{$order}>"; echo "<td>{$orphan['name']}</td>"; echo "<td>{$realm_name}</td>"; echo "<td>{$orphan['entity_id']}</td>"; echo "</tr>\n"; $order = $nextorder[$order]; } echo "</table>\n"; finishPortLet(); } // check 8: missing triggers $triggers = array('Link-before-insert' => 'Link', 'Link-before-update' => 'Link'); $result = usePreparedSelectBlade('SELECT TRIGGER_NAME, EVENT_OBJECT_TABLE ' . 'FROM information_schema.TRIGGERS WHERE TRIGGER_SCHEMA = SCHEMA()'); $rows = $result->fetchAll(PDO::FETCH_ASSOC); unset($result); $existing_triggers = $missing_triggers = array(); foreach ($rows as $row) { $existing_triggers[$row['TRIGGER_NAME']] = $row['EVENT_OBJECT_TABLE']; } foreach ($triggers as $trigger => $table) { if (!array_key_exists($trigger, $existing_triggers)) { $missing_triggers[$trigger] = $table; } } if (count($missing_triggers)) { $violations = TRUE; startPortlet('Missing Triggers (' . count($missing_triggers) . ')'); echo "<table cellpadding=5 cellspacing=0 align=center class=cooltable>\n"; echo "<tr><th>Table</th><th>Trigger</th></tr>\n"; $order = 'odd'; foreach ($missing_triggers as $trigger => $table) { echo "<tr class=row_{$order}>"; echo "<td>{$table}</td>"; echo "<td>{$trigger}</td>"; echo "</tr>\n"; $order = $nextorder[$order]; } echo "</table>\n"; finishPortLet(); } // check 9: missing foreign keys $fkeys = array('Atom-FK-molecule_id' => 'Atom', 'Atom-FK-rack_id' => 'Atom', 'AttributeMap-FK-chapter_id' => 'AttributeMap', 'AttributeMap-FK-attr_id' => 'AttributeMap', 'AttributeValue-FK-map' => 'AttributeValue', 'AttributeValue-FK-object' => 'AttributeValue', 'CachedPAV-FK-object-port' => 'CachedPAV', 'CachedPAV-FK-vlan_id' => 'CachedPAV', 'CachedPNV-FK-compound' => 'CachedPNV', 'CachedPVM-FK-object_id' => 'CachedPVM', 'CactiGraph-FK-server_id' => 'CactiGraph', 'CactiGraph-FK-server_id' => 'CactiGraph', 'Dictionary-FK-chapter_id' => 'Dictionary', 'FileLink-File_fkey' => 'FileLink', 'IPv4Allocation-FK-object_id' => 'IPv4Allocation', 'IPv4LB-FK-vs_id' => 'IPv4LB', 'IPv4LB-FK-object_id' => 'IPv4LB', 'IPv4LB-FK-rspool_id' => 'IPv4LB', 'IPv4NAT-FK-object_id' => 'IPv4NAT', 'IPv4RS-FK' => 'IPv4RS', 'IPv6Allocation-FK-object_id' => 'IPv6Allocation', 'Link-FK-a' => 'Link', 'Link-FK-b' => 'Link', 'MountOperation-FK-object_id' => 'MountOperation', 'MountOperation-FK-old_molecule_id' => 'MountOperation', 'MountOperation-FK-new_molecule_id' => 'MountOperation', 'MuninGraph-FK-server_id' => 'MuninGraph', 'MuninGraph-FK-server_id' => 'MuninGraph', 'ObjectHistory-FK-object_id' => 'ObjectHistory', 'ObjectLog-FK-object_id' => 'ObjectLog', 'Port-FK-iif-oif' => 'Port', 'Port-FK-object_id' => 'Port', 'PortAllowedVLAN-FK-object-port' => 'PortAllowedVLAN', 'PortAllowedVLAN-FK-vlan_id' => 'PortAllowedVLAN', 'PortCompat-FK-oif_id1' => 'PortCompat', 'PortCompat-FK-oif_id2' => 'PortCompat', 'PortInterfaceCompat-FK-iif_id' => 'PortInterfaceCompat', 'PortInterfaceCompat-FK-oif_id' => 'PortInterfaceCompat', 'PortLog_ibfk_1' => 'PortLog', 'PortNativeVLAN-FK-compound' => 'PortNativeVLAN', 'PortVLANMode-FK-object-port' => 'PortVLANMode', 'RackSpace-FK-rack_id' => 'RackSpace', 'RackSpace-FK-object_id' => 'RackSpace', 'TagStorage-FK-TagTree' => 'TagStorage', 'TagTree-K-parent_id' => 'TagTree', 'UserConfig-FK-varname' => 'UserConfig', 'VLANDescription-FK-domain_id' => 'VLANDescription', 'VLANDescription-FK-vlan_id' => 'VLANDescription', 'VLANIPv4-FK-compound' => 'VLANIPv4', 'VLANIPv4-FK-ipv4net_id' => 'VLANIPv4', 'VLANIPv6-FK-compound' => 'VLANIPv6', 'VLANIPv6-FK-ipv6net_id' => 'VLANIPv6', 'VLANSTRule-FK-vst_id' => 'VLANSTRule', 'VLANSwitch-FK-domain_id' => 'VLANSwitch', 'VLANSwitch-FK-object_id' => 'VLANSwitch', 'VLANSwitch-FK-template_id' => 'VLANSwitch', 'VSEnabledIPs-FK-object_id' => 'VSEnabledIPs', 'VSEnabledIPs-FK-rspool_id' => 'VSEnabledIPs', 'VSEnabledIPs-FK-vs_id-vip' => 'VSEnabledIPs', 'VSEnabledPorts-FK-object_id' => 'VSEnabledPorts', 'VSEnabledPorts-FK-rspool_id' => 'VSEnabledPorts', 'VSEnabledPorts-FK-vs_id-proto-vport' => 'VSEnabledPorts', 'VSIPs-vs_id' => 'VSIPs', 'VS-vs_id' => 'VSPorts'); $result = usePreparedSelectBlade('SELECT CONSTRAINT_NAME, TABLE_NAME ' . 'FROM information_schema.TABLE_CONSTRAINTS ' . "WHERE CONSTRAINT_SCHEMA = SCHEMA() AND CONSTRAINT_TYPE = 'FOREIGN KEY'"); $rows = $result->fetchAll(PDO::FETCH_ASSOC); unset($result); $existing_fkeys = $missing_fkeys = array(); foreach ($rows as $row) { $existing_fkeys[$row['CONSTRAINT_NAME']] = $row['TABLE_NAME']; } foreach ($fkeys as $fkey => $table) { if (!array_key_exists($fkey, $existing_fkeys)) { $missing_fkeys[$fkey] = $table; } } if (count($missing_fkeys)) { $violations = TRUE; startPortlet('Missing Foreign Keys (' . count($missing_fkeys) . ')'); echo "<table cellpadding=5 cellspacing=0 align=center class=cooltable>\n"; echo "<tr><th>Table</th><th>Key</th></tr>\n"; $order = 'odd'; foreach ($missing_fkeys as $fkey => $table) { echo "<tr class=row_{$order}>"; echo "<td>{$table}</td>"; echo "<td>{$fkey}</td>"; echo "</tr>\n"; $order = $nextorder[$order]; } echo "</table>\n"; finishPortLet(); } // check 10: circular references // - all affected members of the tree are displayed // - it would be beneficial to only display the offending records // check 10.1: locations $invalids = array(); $locations = listCells('location'); foreach ($locations as $location) { try { $children = getLocationChildrenList($location['id']); } catch (RackTablesError $e) { $invalids[] = $location; } } if (count($invalids)) { $violations = TRUE; startPortlet('Locations: Tree Contains Circular References (' . count($invalids) . ')'); echo "<table cellpadding=5 cellspacing=0 align=center class=cooltable>\n"; echo "<tr><th>Child ID</th><th>Child Location</th><th>Parent ID</th><th>Parent Location</th></tr>\n"; $order = 'odd'; foreach ($invalids as $invalid) { echo "<tr class=row_{$order}>"; echo "<td>{$invalid['id']}</td>"; echo "<td>{$invalid['name']}</td>"; echo "<td>{$invalid['parent_id']}</td>"; echo "<td>{$invalid['parent_name']}</td>"; echo "</tr>\n"; $order = $nextorder[$order]; } echo "</table>\n"; finishPortLet(); } // check 10.2: objects $invalids = array(); $objects = listCells('object'); foreach ($objects as $object) { try { $children = getObjectContentsList($object['id']); } catch (RackTablesError $e) { $invalids[] = $object; } } if (count($invalids)) { $violations = TRUE; startPortlet('Objects: Tree Contains Circular References (' . count($invalids) . ')'); echo "<table cellpadding=5 cellspacing=0 align=center class=cooltable>\n"; echo "<tr><th>Contained ID</th><th>Contained Object</th><th>Container ID</th><th>Container Object</th></tr>\n"; $order = 'odd'; foreach ($invalids as $invalid) { echo "<tr class=row_{$order}>"; echo "<td>{$invalid['id']}</td>"; echo "<td>{$invalid['name']}</td>"; echo "<td>{$invalid['container_id']}</td>"; echo "<td>{$invalid['container_name']}</td>"; echo "</tr>\n"; $order = $nextorder[$order]; } echo "</table>\n"; finishPortLet(); } // check 10.3: tags $invalids = array(); $tags = getTagList(); foreach ($tags as $tag) { try { $children = getTagChildrenList($tag['id']); } catch (RackTablesError $e) { $invalids[] = $tag; } } if (count($invalids)) { $violations = TRUE; startPortlet('Tags: Tree Contains Circular References (' . count($invalids) . ')'); echo "<table cellpadding=5 cellspacing=0 align=center class=cooltable>\n"; echo "<tr><th>Child ID</th><th>Child Tag</th><th>Parent ID</th><th>Parent Tag</th></tr>\n"; $order = 'odd'; foreach ($invalids as $invalid) { echo "<tr class=row_{$order}>"; echo "<td>{$invalid['id']}</td>"; echo "<td>{$invalid['tag']}</td>"; echo "<td>{$invalid['parent_id']}</td>"; printf('<td>%s</td>', $tags[$invalid['parent_id']]['tag']); echo "</tr>\n"; $order = $nextorder[$order]; } echo "</table>\n"; finishPortLet(); } if (!$violations) { echo '<h2>No integrity violations found</h2>'; } }
function renderCustomReport() { # Get object list $phys_typelist = readChapter(CHAP_OBJTYPE, 'o'); $attibutes = getAttrMap(); $aTagList = getTagList(); if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['csv'])) { header('Content-type: text/csv'); header('Content-Disposition: attachment; filename=export_' . date("Ymdhis") . '.csv'); header('Pragma: no-cache'); header('Expires: 0'); $outstream = fopen("php://output", "w"); $aResult = getResult($_POST); // Get Result $_POST['name'] = validateColums($_POST); // Fix empty colums $csvDelimiter = isset($_POST['csvDelimiter']) ? $_POST['csvDelimiter'] : ','; /* Create Header */ $aCSVRow = array(); if (isset($_POST['sName']) && $_POST['sName']) { array_push($aCSVRow, "Name"); } if (isset($_POST['label'])) { array_push($aCSVRow, "Label"); } if (isset($_POST['type'])) { array_push($aCSVRow, "Type"); } if (isset($_POST['asset_no'])) { array_push($aCSVRow, "Asset Tag"); } if (isset($_POST['has_problems'])) { array_push($aCSVRow, "Has Problems"); } if (isset($_POST['comment'])) { array_push($aCSVRow, "Comment"); } if (isset($_POST['runs8021Q'])) { array_push($aCSVRow, "Runs 8021Q"); } if (isset($_POST['location'])) { array_push($aCSVRow, "Location"); } if (isset($_POST['MACs'])) { array_push($aCSVRow, "MACs"); } if (isset($_POST['IPs'])) { array_push($aCSVRow, "IPs"); } if (isset($_POST['attributeIDs'])) { foreach ($_POST['attributeIDs'] as $attributeID) { array_push($aCSVRow, $attibutes[$attributeID]['name']); } } if (isset($_POST['Tags'])) { array_push($aCSVRow, "Tags"); } if (isset($_POST['Ports'])) { array_push($aCSVRow, "Ports"); } if (isset($_POST['Containers'])) { array_push($aCSVRow, "Containers"); } if (isset($_POST['Childs'])) { array_push($aCSVRow, "Child objects"); } fputcsv($outstream, $aCSVRow, $csvDelimiter); /* Create data rows */ foreach ($aResult as $Result) { $aCSVRow = array(); if (isset($_POST['sName'])) { array_push($aCSVRow, $Result['name']); } if (isset($_POST['label'])) { array_push($aCSVRow, $Result['label']); } if (isset($_POST['type'])) { array_push($aCSVRow, $phys_typelist[$Result['objtype_id']]); } if (isset($_POST['asset_no'])) { array_push($aCSVRow, $Result['asset_no']); } if (isset($_POST['has_problems'])) { array_push($aCSVRow, $Result['has_problems']); } if (isset($_POST['comment'])) { array_push($aCSVRow, str_replace('"', "'", $Result['comment'])); } if (isset($_POST['runs8021Q'])) { array_push($aCSVRow, $Result['runs8021Q']); } if (isset($_POST['location'])) { array_push($aCSVRow, preg_replace('/<a[^>]*>(.*)<\\/a>/iU', '$1', getLocation($Result))); } if (isset($_POST['MACs'])) { $sTemp = ''; foreach (getObjectPortsAndLinks($Result['id']) as $portNumber => $aPortDetails) { if (trim($aPortDetails['l2address']) != '') { $sTemp .= $aPortDetails['l2address'] . ' '; } } array_push($aCSVRow, $sTemp); } if (isset($_POST['IPs'])) { $sTemp = ''; foreach (getObjectIPv4AllocationList($Result['id']) as $key => $aDetails) { if (function_exists('ip4_format')) { $key = ip4_format($key); } if (trim($key) != '') { $sTemp .= $key . ' '; } } foreach (getObjectIPv6AllocationList($Result['id']) as $key => $aDetails) { if (function_exists('ip6_format')) { $key = ip6_format($key); } else { $key = new IPv6Address($key); } if (trim($key) != '') { $sTemp .= $key . ' '; } } array_push($aCSVRow, $sTemp); } if (isset($_POST['attributeIDs'])) { $attributes = getAttrValues($Result['id']); foreach ($_POST['attributeIDs'] as $attributeID) { if (isset($attributes[$attributeID]['a_value'])) { array_push($aCSVRow, $attributes[$attributeID]['a_value']); } elseif ($attributes[$attributeID]['value'] != '' && $attributes[$attributeID]['type'] == 'date') { array_push($aCSVRow, date("Y-m-d", $attributes[$attributeID]['value'])); } else { array_push($aCSVRow, ''); } } } if (isset($_POST['Tags'])) { $sTemp = ''; foreach ($Result['tags'] as $aTag) { $sTemp .= $aTag['tag'] . ' '; } if (count($Result['itags']) > 0) { $sTemp .= '('; foreach ($Result['itags'] as $aTag) { $sTemp .= $aTag['tag'] . ' '; } $sTemp .= ')'; } array_push($aCSVRow, $sTemp); } if (isset($_POST['Ports'])) { $sTemp = ''; foreach ($Result['portsLinks'] as $port) { $sTemp .= $port['name'] . ': ' . $port['remote_object_name']; if (trim($port['cableid']) != '') { $sTemp .= ' Cable ID: ' . $port['cableid']; } $sTemp .= ' '; } $sTemp = trim($sTemp); array_push($aCSVRow, $sTemp); } if (isset($_POST['Containers'])) { $sTemp = ''; foreach (getObjectContainerList($Result['id']) as $key => $aDetails) { $sTemp .= trim($aDetails['container_name']) . ' '; } $sTemp = trim($sTemp); array_push($aCSVRow, $sTemp); } if (isset($_POST['Childs'])) { $sTemp = ''; foreach (getObjectChildObjectList($Result['id']) as $key => $aDetails) { $sTemp .= trim($aDetails['object_name']) . ' '; } $sTemp = trim($sTemp); array_push($aCSVRow, $sTemp); } fputcsv($outstream, $aCSVRow, $csvDelimiter); } fclose($outstream); exit(0); # Exit normally after send CSV to browser } echo '<h2>Custom report</h2><ul>'; // Load stylesheet and jquery scripts addCSS('css/extensions/style.css'); addJS('js/extensions/saveFormValues.js'); addJS('js/extensions/jquery-latest.js'); addJS('js/extensions/jquery.tablesorter.js'); addJS('js/extensions/picnet.table.filter.min.js'); if ($_SERVER['REQUEST_METHOD'] == 'POST') { echo '<a href="#" class="show_hide">Show/hide search form</a><br/><br/>'; } echo '<div class="searchForm">'; echo '<form method="post" name="searchForm">'; echo '<table class="searchTable"> <tr> <th>Object Type</th> <th>Common Values</th> <th>Attributes</th> <th>Tags</th> <th>Misc</th> </tr> <tr>'; echo '<td valign="top"> <table class="searchTable">'; $i = 0; foreach ($phys_typelist as $objectTypeID => $sName) { if ($i % 2) { echo '<tr class="odd">'; } else { echo '<tr>'; } echo ' <td> <input type="checkbox" name="objectIDs[]" value="' . $objectTypeID . '"'; if (isset($_POST['objectIDs']) && in_array($objectTypeID, $_POST['objectIDs'])) { echo ' checked="checked"'; } echo ' > ' . $sName . ' </td> </tr>'; $i++; } echo ' </table> </td>'; echo '<td valign="top"> <table class="searchTable"> <tr><td><input type="checkbox" name="sName" value="1" '; if (isset($_POST['sName'])) { echo ' checked="checked"'; } echo '> Name</td></tr> <tr class="odd"><td><input type="checkbox" name="label" value="1" '; if (isset($_POST['label'])) { echo ' checked="checked"'; } echo '> Label</td></tr> <tr><td><input type="checkbox" name="type" value="1" '; if (isset($_POST['type'])) { echo ' checked="checked"'; } echo '> Type</td></tr> <tr class="odd"><td><input type="checkbox" name="asset_no" value="1" '; if (isset($_POST['asset_no'])) { echo ' checked="checked"'; } echo '> Asset Tag</td></tr> <tr><td><input type="checkbox" name="location" value="1" '; if (isset($_POST['location'])) { echo ' checked="checked"'; } echo '> Location</td></tr> <tr class="odd"><td><input type="checkbox" name="has_problems" value="1" '; if (isset($_POST['has_problems'])) { echo ' checked="checked"'; } echo '> Has Problems</td></tr> <tr><td><input type="checkbox" name="comment" value="1" '; if (isset($_POST['comment'])) { echo ' checked="checked"'; } echo '> Comment</td></tr> <tr class="odd"><td><input type="checkbox" name="runs8021Q" value="1" '; if (isset($_POST['runs8021Q'])) { echo ' checked="checked"'; } echo '> Runs 8021Q</td></tr> <tr><td><input type="checkbox" name="MACs" value="1" '; if (isset($_POST['MACs'])) { echo ' checked="checked"'; } echo '> MACs</td></tr> <tr class="odd"><td><input type="checkbox" name="IPs" value="1" '; if (isset($_POST['IPs'])) { echo ' checked="checked"'; } echo '> IPs</td></tr> <tr><td><input type="checkbox" name="Tags" value="1" '; if (isset($_POST['Tags'])) { echo ' checked="checked"'; } echo '> Tags</td></tr> <tr class="odd"><td><input type="checkbox" name="Ports" value="1" '; if (isset($_POST['Ports'])) { echo ' checked="checked"'; } echo '> Ports</td></tr> <tr><td><input type="checkbox" name="Containers" value="1" '; if (isset($_POST['Containers'])) { echo ' checked="checked"'; } echo '> Containers</td></tr> <tr class="odd"><td><input type="checkbox" name="Childs" value="1" '; if (isset($_POST['Childs'])) { echo ' checked="checked"'; } echo '> Child objects</td></tr> </table> </td>'; echo '<td valign="top"> <table class="searchTable">'; $i = 0; foreach ($attibutes as $attributeID => $aRow) { if ($i % 2) { echo '<tr class="odd">'; } else { echo '<tr>'; } echo ' <td> <input type="checkbox" name="attributeIDs[]" value="' . $attributeID . '"'; if (isset($_POST['attributeIDs']) && in_array($attributeID, $_POST['attributeIDs'])) { echo ' checked="checked"'; } echo '> ' . $aRow['name'] . ' </td> </tr>'; $i++; } echo ' </table> </td>'; echo '<td valign="top"> <table class="searchTable">'; $i = 0; foreach ($aTagList as $aTag) { echo '<tr ' . ($i % 2 ? 'class="odd"' : '') . '> <td> <input type="checkbox" name="tag[' . $aTag['id'] . ']" value="1" ' . (isset($_POST['tag'][$aTag['id']]) ? 'checked="checked" ' : '') . '> ' . $aTag['tag'] . ' </td> </tr>'; $i++; } if (count($aTagList) < 1) { echo '<tr><td><i>No Tags available</i></td></tr>'; } echo ' </table> </td>'; echo '<td valign="top"> <table class="searchTable"> <tr><td><input type="checkbox" name="csv" value="1"> CSV Export</td></tr> <tr><td><input type="text" name="csvDelimiter" value="," size="1"> CSV Delimiter</td></tr> <tr class="odd"><td>Name Filter: <i>(Regular Expression)</i></td></tr> <tr><td><input type="text" name="name_preg" value="'; if (isset($_POST['name_preg'])) { echo $_POST['name_preg']; } echo '" style="height: 11pt;"></td></tr> <tr class="odd"><td>Asset Tag Filter: <i>(Regular Expression)</i></td></tr> <tr><td><input type="text" name="tag_preg" value="'; if (isset($_POST['tag_preg'])) { echo $_POST['tag_preg']; } echo '" style="height: 11pt;"></td></tr> <tr class="odd"><td>Comment Filter: <i>(Regular Expression)</i></td></tr> <tr><td><input type="text" name="comment_preg" value="'; if (isset($_POST['comment_preg'])) { echo $_POST['comment_preg']; } echo '" style="height: 11pt;"></td></tr> <tr class="odd"><td> </td></tr> <tr> <td> Save: <input id="nameQuery" type="text" name="nameQuery" value="" style="height: 11pt; width:155px"/> <input type="button" value=" Ok " onclick="saveQuery();"> <br/> Load:<br/> <span id="loadButtons"></span> <script type="text/javascript"> loadButtons(); </script> </td> </tr> <tr class="odd"><td> </td></tr> <tr><td align="right"><input type="submit" value=" Search "></td></tr> </table> </td> </tr> </table>'; echo '</form>'; echo '</div>'; if ($_SERVER['REQUEST_METHOD'] == 'POST') { $aResult = getResult($_POST); // Get Result $_POST['sName'] = validateColums($_POST); // Fix empty colums if (count($aResult) > 0) { echo '<table id="customTable" class="tablesorter"> <thead> <tr>'; if (isset($_POST['sName']) && $_POST['sName']) { echo '<th>Name</th>'; } if (isset($_POST['label'])) { echo '<th>Label</th>'; } if (isset($_POST['type'])) { echo '<th>Type</th>'; } if (isset($_POST['asset_no'])) { echo '<th>Asset Tag</th>'; } if (isset($_POST['has_problems'])) { echo '<th>Has Problems</th>'; } if (isset($_POST['comment'])) { echo '<th>Comment</th>'; } if (isset($_POST['runs8021Q'])) { echo '<th>Runs 8021Q</th>'; } if (isset($_POST['location'])) { echo '<th>Location</th>'; } if (isset($_POST['MACs'])) { echo '<th>MACs</th>'; } if (isset($_POST['IPs'])) { echo '<th>IPs</th>'; } if (isset($_POST['attributeIDs'])) { foreach ($_POST['attributeIDs'] as $attributeID) { echo '<th>' . $attibutes[$attributeID]['name'] . '</th>'; } } if (isset($_POST['Tags'])) { echo '<th>Tags</th>'; } if (isset($_POST['Ports'])) { echo '<th>Ports</th>'; } if (isset($_POST['Containers'])) { echo '<th>Containers</th>'; } if (isset($_POST['Childs'])) { echo '<th>Child objects</th>'; } echo ' </tr> </thead> <tbody>'; foreach ($aResult as $Result) { echo '<tr>'; if (isset($_POST['sName'])) { echo '<td> <span class="object_' . str_replace('$', '', $Result['atags'][1]['tag']) . '">'; if (isset($Result['name'])) { echo '<a href="' . makeHref(array('page' => 'object', 'object_id' => $Result['id'])) . '">' . $Result['name'] . '</a>'; } else { echo ' '; } echo ' </span> </td>'; } if (isset($_POST['label'])) { echo '<td>'; if (isset($Result['label'])) { echo $Result['label']; } else { echo ' '; } echo '</td>'; } if (isset($_POST['type'])) { echo '<td>'; if (isset($Result['objtype_id'])) { echo $phys_typelist[$Result['objtype_id']]; } else { echo ' '; } echo '</td>'; } if (isset($_POST['asset_no'])) { echo '<td>'; if (isset($Result['asset_no'])) { echo $Result['asset_no']; } else { echo ' '; } echo '</td>'; } if (isset($_POST['has_problems'])) { echo '<td>'; if (isset($Result['has_problems'])) { echo $Result['has_problems']; } else { echo ' '; } echo '</td>'; } if (isset($_POST['comment'])) { echo '<td>'; if (isset($Result['comment'])) { echo makeLinksInText($Result['comment']); } else { echo ' '; } echo '</td>'; } if (isset($_POST['runs8021Q'])) { echo '<td>'; if (isset($Result['runs8021Q'])) { echo $Result['runs8021Q']; } else { echo ' '; } echo '</td>'; } if (isset($_POST['location'])) { echo '<td>'; echo getLocation($Result); echo '</td>'; } if (isset($_POST['MACs'])) { echo '<td>'; foreach (getObjectPortsAndLinks($Result['id']) as $portNumber => $aPortDetails) { if (trim($aPortDetails['l2address']) != '') { echo $aPortDetails['l2address'] . '<br/>'; } } echo '</td>'; } if (isset($_POST['IPs'])) { echo '<td>'; foreach (getObjectIPv4AllocationList($Result['id']) as $key => $aDetails) { if (function_exists('ip4_format')) { $key = ip4_format($key); } if (trim($key) != '') { echo $key . '<br/>'; } } foreach (getObjectIPv6AllocationList($Result['id']) as $key => $aDetails) { if (function_exists('ip6_format')) { $key = ip6_format($key); } else { $key = new IPv6Address($key); } if (trim($key) != '') { echo $key . '<br/>'; } } echo '</td>'; } if (isset($_POST['attributeIDs'])) { $attributes = getAttrValues($Result['id']); foreach ($_POST['attributeIDs'] as $attributeID) { echo '<td>'; if (isset($attributes[$attributeID]['a_value']) && $attributes[$attributeID]['a_value'] != '') { echo $attributes[$attributeID]['a_value']; } elseif ($attributes[$attributeID]['value'] != '' && $attributes[$attributeID]['type'] == 'date') { echo date("Y-m-d", $attributes[$attributeID]['value']); } else { echo ' '; } } } if (isset($_POST['Tags'])) { echo '<td>'; foreach ($Result['tags'] as $aTag) { echo '<a href="' . makeHref(array('page' => 'depot', 'tab' => 'default', 'andor' => 'and', 'cft[]' => $aTag['id'])) . '">' . $aTag['tag'] . '</a> '; } if (count($Result['itags']) > 0) { echo '('; foreach ($Result['itags'] as $aTag) { echo '<a href="' . makeHref(array('page' => 'depot', 'tab' => 'default', 'andor' => 'and', 'cft[]' => $aTag['id'])) . '">' . $aTag['tag'] . '</a> '; } echo ')'; } echo '</td>'; } if (isset($_POST['Ports'])) { echo '<td>'; foreach ($Result['portsLinks'] as $port) { echo $port['name'] . ': '; if ($port['remote_object_name'] != 'unknown') { echo formatPortLink($port['remote_object_id'], $port['remote_object_name'], $port['remote_id'], NULL); } else { echo $port['remote_object_name']; } if (trim($port['cableid']) != '') { echo ' Cable ID: ' . $port['cableid']; } echo '<br/>'; } echo '</td>'; } if (isset($_POST['Containers'])) { echo '<td>'; foreach (getObjectContainerList($Result['id']) as $key => $aDetails) { echo '<a href="' . makeHref(array('page' => 'object', 'object_id' => $key)) . '">' . $aDetails['container_name'] . '</a><br/>'; } echo '</td>'; } if (isset($_POST['Childs'])) { echo '<td>'; foreach (getObjectChildObjectList($Result['id']) as $key => $aDetails) { echo '<a href="' . makeHref(array('page' => 'object', 'object_id' => $key)) . '">' . $aDetails['object_name'] . '</a><br/>'; } echo '</td>'; } echo '</tr>'; } echo ' </tbody> </table> <script type="text/javascript">$(".searchForm").hide();</script>'; } else { echo '<br/><br/><div align="center" style="font-size:10pt;"><i>No items found !!!</i></div><br/>'; } echo '<script type="text/javascript"> $(document).ready(function() { $.tablesorter.defaults.widgets = ["zebra"]; $("#customTable").tablesorter( { headers: { }, sortList: [[0,0]] } ); $("#customTable").tableFilter(); $(".show_hide").show(); $(".show_hide").click(function(){ $(".searchForm").slideToggle(\'slow\'); }); } ); </script>'; } }
function dlformat(&$T, &$A, $isListing = false, $cid = ROOTID) { global $_CONF, $_TABLES, $LANG01, $_DLM_CONF, $LANG_DLM, $mytree; $A['rating'] = number_format($A['rating'], 2); $A['title'] = DLM_htmlspecialchars($A['title']); $A['project'] = DLM_htmlspecialchars($A['project']); $A['url'] = DLM_htmlspecialchars($A['url']); $A['homepage'] = DLM_htmlspecialchars($A['homepage']); $A['version'] = DLM_htmlspecialchars($A['version']); $A['size'] = DLM_htmlspecialchars($A['size']); $A['md5'] = DLM_htmlspecialchars($A['md5']); $A['logourl'] = DLM_htmlspecialchars($A['logourl']); $A['postmode'] = DLM_htmlspecialchars($A['postmode']); $A['tags'] = DLM_htmlspecialchars($A['tags']); $A['datetime'] = strftime($_DLM_CONF['date_format'], $A['date']); if (version_compare(VERSION, '2.1.0') >= 0) { require_once $_CONF['path_system'] . 'classes/gltext.class.php'; $A['description'] = GLText::getDisplayText($A['description'], $A['postmode'], 2); $A['detail'] = GLText::getDisplayText($A['detail'], $A['postmode'], 2); } else { require_once $_CONF['path'] . 'plugins/downloads/include/gltext.class.php'; $gltext = new GLPText(); $A['description'] = $gltext->getDisplayText($A['description'], $A['postmode']); $A['detail'] = $gltext->getDisplayText($A['detail'], $A['postmode']); } $filedetail_url = COM_buildURL($_CONF['site_url'] . '/downloads/index.php?id=' . $A['lid']); $visitfile_url = COM_buildURL($_CONF['site_url'] . '/downloads/visit.php?id=' . $A['lid']); if ($isListing && !empty($A['detail'])) { $A['description'] .= '<p class="download-break">' . COM_createLink($LANG_DLM['more'], $filedetail_url) . '</p>'; } $result = DB_query("SELECT username, fullname, photo " . "FROM {$_TABLES['users']} " . "WHERE uid = {$A['owner_id']}"); $B = DB_fetchArray($result); $submitter_name = COM_getDisplayName($A['owner_id'], $B['username'], $B['fullname']); if (empty($submitter_name)) { $submitter_name = $LANG_DLM['unknown_uid']; } else { $submitter_name = COM_createLink($submitter_name, $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $A['owner_id']); } $path = $mytree->getNicePathFromId($A['cid'], 'title', $_CONF['site_url'] . '/downloads/index.php'); $temp = $mytree->getSepalator(); $path = substr($path, 0, strlen($path) - strlen($temp)); $path = str_replace($temp, ' <img src="' . $_CONF['site_url'] . '/downloads/images/arrow.gif" alt="arrow"' . XHTML . '> ', $path); $tags = '-'; if (!empty($A['tags'])) { $tags = getTagList($A['tags']); if (empty($tags)) { $tags = '-'; } } $notags = $tags == '-' ? 'dlm_notags' : ''; $T->set_var('lang_category', $LANG_DLM['category']); $T->set_var('category_path', $path); $T->set_var('lang_tags', $LANG_DLM['tags']); $T->set_var('tags', $tags); $T->set_var('notags', $notags); $T->set_var('lang_submitter', $LANG_DLM['submitter']); $T->set_var('submitter_name', $submitter_name); $T->set_var('lid', $A['lid']); $T->set_var('cid', $A['cid']); $T->set_var('lang_dlnow', $LANG_DLM['dlnow']); $T->set_var('dtitle', $A['title']); $T->set_var('filedetail_url', $filedetail_url); $T->set_var('visitfile_url', $visitfile_url); $T->set_var('listing_cid', $cid); $T->set_var('lang_download_button', $LANG_DLM['download_button']); $startdate = time() - 60 * 60 * 24 * 7; if ($startdate < $A['date']) { $image_new = COM_createImage($_CONF['site_url'] . '/downloads/images/newred.gif', $LANG_DLM['newthisweek']); $newdownload = '<span class="badgenew">NEW</span>'; } $T->set_var('image_newdownload', $image_new); // Image (New) $T->set_var('newdownload', $newdownload); // Badge (New) if ($A['hits'] >= $_DLM_CONF['download_popular']) { $image_pop = COM_createImage($_CONF['site_url'] . '/downloads/images/pop.gif', $LANG_DLM['popular']); $popdownload = '<span class="badgepop">POP</span>'; } $T->set_var('image_popular', $image_pop); // Image (Pop) $T->set_var('popdownload', $popdownload); // Badge (Pop) // category image $cat_title = DLM_htmlspecialchars($A['cat_title']); if ($_DLM_CONF['download_useshots'] && !empty($A['imgurl'])) { $imgurl = $_DLM_CONF['snapcat_url'] . '/' . DLM_htmlspecialchars($A['imgurl']); } else { $imgurl = $_CONF['site_url'] . '/downloads/images/download.png'; } $category_image = COM_createImage($imgurl, $cat_title, array('width' => $_DLM_CONF['download_shotwidth'])); $T->set_var('category_image', $category_image); $T->set_var('download_title', $LANG_DLM['click2dl'] . ': ' . $A['url']); $T->set_var('url', $A['url']); $T->set_var('file_description', $A['description']); $T->set_var('file_detail', $A['detail']); $T->set_var('rating', $A['rating']); if ($A['rating'] != "0" || $A['rating'] != "0.00") { $votestring = sprintf($LANG_DLM['numvotes'], $A['votes']); } $T->set_var('votestring', $votestring); if (!empty($A['mg_autotag'])) { // use the mediagallery autotag as a snapshot. $mg_autotag = str_replace(array('[', ']'), '', $A['mg_autotag']); $mg_autotag = '[' . $mg_autotag . ' width:' . $_DLM_CONF['max_tnimage_width'] . ' height:' . $_DLM_CONF['max_tnimage_height'] . ' align:left]'; $T->set_var('mg_autotag', PLG_replaceTags($mg_autotag, 'mediagallery')); $T->set_var('snapshot', ''); $T->set_var('snaplinkicon', ''); } elseif (!empty($A['logourl'])) { $safename = DLM_createSafeFileName($A['logourl']); $imgpath = $_DLM_CONF['path_tnstore'] . $safename; $imgpath = DLM_modTNPath($imgpath); $tnimgurl = $_DLM_CONF['tnstore_url'] . '/' . $safename; $tnimgurl = substr($tnimgurl, 0, -3) . substr($imgpath, -3); // align the extension $sizeattributes = DLM_getImgSizeAttr($imgpath); $T->set_var('snapshot_url', $_DLM_CONF['snapstore_url'] . '/' . $safename); $T->set_var('thumbnail_url', $tnimgurl); $T->set_var('snapshot_sizeattr', $sizeattributes); $T->set_var('lang_click2see', $LANG_DLM['click2see']); $T->set_var('show_snapshoticon', ''); $T->set_var('show_snapshoticon_na', 'none'); $T->set_var('mg_autotag', ''); if ($_DLM_CONF['show_tn_image']) { $T->parse('snapshot', 'tsnapshot'); } else { $T->parse('snaplinkicon', 'tsnaplinkicon'); } } else { $tnimgurl = $_CONF['site_url'] . '/downloads/images/blank.png'; $T->set_var('thumbnail_url', $tnimgurl); $T->set_var('snapshot_url', $_CONF['site_url'] . '/downloads/index.php'); $T->set_var('snapshot_sizeattr', 'width="200" height="200" '); $T->set_var('show_snapshoticon', 'none'); $T->set_var('show_snapshoticon_na', ''); $T->parse('snapshot', 'tsnapshot'); $T->set_var('snaplinkicon', ''); $T->set_var('mg_autotag', ''); } $T->set_var('lang_version', $LANG_DLM['ver']); $T->set_var('lang_rating', $LANG_DLM['ratingc']); $T->set_var('lang_submitdate', $LANG_DLM['submitdate']); $T->set_var('lang_size', $LANG_DLM['size']); $T->set_var('datetime', $A['datetime']); $T->set_var('version', $A['version']); // Check if restricted access has been enabled for download report to admin's only if ($A['hits'] > 0 && DLM_hasAccess_history()) { $T->set_var('begin_dlreport_link', '<a href="' . COM_buildURL($_CONF['site_url'] . '/downloads/history.php?lid=' . $A['lid']) . '">'); $T->set_var('end_dlreport_link', '</a>'); } else { $T->set_var('begin_dlreport_link', ''); $T->set_var('end_dlreport_link', ''); } $T->set_var('download_times', sprintf($LANG_DLM['dltimes'], $A['hits'])); $T->set_var('download_count', $A['hits']); $T->set_var('lang_popularity', $LANG_DLM['popularity']); $T->set_var('lang_filesize', $LANG_DLM['filesize']); $T->set_var('file_size', DLM_PrettySize($A['size'])); $T->set_var('homepage_url', $A['homepage']); $T->set_var('homepage_link', '-'); if (!empty($A['homepage'])) { $T->set_var('homepage_link', COM_makeClickableLinks($A['homepage'])); } $T->set_var('lang_homepage', $LANG_DLM['homepage']); $T->set_var('lang_download', $LANG_DLM['download']); $T->set_var('lang_filelink', $LANG_DLM['filelink']); $T->set_var('lang_permalink', $LANG_DLM['permalink']); $T->set_var('lang_ratethisfile', $LANG_DLM['ratethisfile']); $T->set_var('lang_edit', $LANG_DLM['edit']); $T->set_var('show_editlink', $_DLM_CONF['has_edit_rights'] ? '' : 'none'); $T->set_var('lang_md5_checksum', $LANG_DLM['md5_checksum']); $T->set_var('md5_checksum', $A['md5']); if ($A['commentcode'] == 0) { $commentCount = DB_count($_TABLES['comments'], 'sid', addslashes($A['lid'])); $recentPostMessage = $LANG_DLM['commentswanted']; if ($commentCount > 0) { $result4 = DB_query("SELECT cid, UNIX_TIMESTAMP(date) AS day, username " . "FROM {$_TABLES['comments']}, {$_TABLES['users']} " . "WHERE {$_TABLES['users']}.uid = {$_TABLES['comments']}.uid " . "AND sid = '" . addslashes($A['lid']) . "' " . "ORDER BY date DESC LIMIT 1"); $C = DB_fetchArray($result4); $recentPostMessage = $LANG01[27] . ': ' . strftime($_CONF['daytime'], $C['day']) . ' ' . $LANG01[104] . ' ' . $C['username']; $comment_link = COM_createLink($commentCount . ' ' . $LANG01[3], $filedetail_url, array('title' => $recentPostMessage)); } else { $A['title'] = str_replace(''', "'", $A['title']); $A['title'] = str_replace('&', '&', $A['title']); $url = $_CONF['site_url'] . '/comment.php?type=downloads&sid=' . $A['lid'] . '&title=' . rawurlencode($A['title']); $comment_link = COM_createLink($LANG_DLM['entercomment'], $url, array('title' => $recentPostMessage)); } $T->set_var('comment_link', $comment_link); $T->set_var('show_comments', ''); } else { $T->set_var('show_comments', 'none'); } }
?> </a></h1> <h3>posted by <a href="#">anonynous anon</a> under <?php echo getCatList($post->cats); ?> on 13th August 2006</h3> <p class="desc"><?php echo html_entity_decode($post->post_h2); ?> </p> <?php echo $post->post_ps; ?> <div class="postfoot"> <p> Tagged under: <?php echo getTagList($post->tags); ?> </p> </div> <div class="postfoot"> <p> <?php echo $post->comments; ?> Comments </p> </div> <div class="footerspace"> </div> <?php } ?> <div class="paging">