Posts Tagged ‘Block’
Block Port Scanning With Iptables
I wrote down some rules to block commonly used port scanning technique. The rules are below:
$IPTABLES -t mangle -A PREROUTING -p tcp --tcp-flags ALL FIN,URG,PSH -j LOG \
--log-prefix "NMAP-XMAS SCAN:" --log-tcp-options --log-ip-options
$IPTABLES -t mangle -A PREROUTING -p tcp --tcp-flags ALL NONE -j LOG \
--log-prefix "NMAP-NULL SCAN:" --log-tcp-options --log-ip-options
$IPTABLES -t mangle -A PREROUTING -p tcp --tcp-flags SYN,RST SYN,RST -j LOG \
--log-prefix "SYN/RST SCAN:" --log-tcp-options --log-ip-options
$IPTABLES -t mangle -A PREROUTING -p tcp --tcp-flags SYN,FIN SYN,FIN -j LOG \
--log-prefix "SYN/FIN SCAN:" --log-tcp-options --log-ip-options
$IPTABLES -t mangle -A PREROUTING -p tcp --tcp-flags ALL FIN,URG,PSH -j DROP
$IPTABLES -t mangle -A PREROUTING -p tcp --tcp-flags ALL NONE -j DROP
$IPTABLES -t mangle -A PREROUTING -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
$IPTABLES -t mangle -A PREROUTING -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP
Drupal Page Specific visibility settings
Show block only to logged in user:
global $user;
if ($user->uid){
return true;
} else {
return false;
}
Show block only on specific node type:
$match = FALSE;
if (arg(0) == 'node' && is_numeric(arg(1))) {
$nid = arg(1);
$node = node_load(array('nid' => $nid));
$type = $node->type;
if ($type == 'story') {
$match = TRUE;
}
}
return $match;
“Latest Post” Drupal Block
Latest Posts dupal block:
$nlimit = 10;
$result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title, n.created FROM {node} n WHERE n.status = 1 ORDER BY n.created DESC"), 0, $nlimit);
while ($node = db_fetch_object($result)) {
$output .= node_view(node_load(array('nid' => $node->nid)), 1);
}
print $output;
Just display the list:
print node_title_list($result);
In specific node type:
$result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title, n.created FROM {node} n WHERE n.status = 1 AND n.type = 'type' ORDER BY n.created DESC"), 0, $nlimit);
In specific category:
$result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title, n.created FROM {node} n INNER JOIN {term_node} tn ON n.vid = tn.vid WHERE n.status = 1 AND n.type = 'type' AND tn.tid = n ORDER BY n.created DESC"), 0, $nlimit);
User’s recent post:
if (arg(0) == 'user' && is_numeric(arg(1)) && arg(1) > 0) {
......
$uid = arg(1);
$result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title, n.created FROM {node} n INNER JOIN {users} u ON n.uid = u.uid WHERE n.status = 1 AND n.uid = $uid ORDER BY n.created DESC"), 0, $nlimit);
......
}
Display a Drupal block
This way can display a block in Drupal module:
$block_data = module_invoke("module-name", "block", "view", 0);
$page_content .= "<div class="block block-module-name">";
$page_content .= "<h2 class="title">" . $block_data['subject'] . “</h2>”;
$page_content .= “<div class=”content”>” . $block_data['content'] . “</div>”;
$page_content .= “</div>”;