function feed($title, $link, $description) { connect(); $feed = '<?xml version="1.0"?>'; $feed .= '<rss version="2.0">'; $feed .= '<channel>'; $feed .= "<title>{$title}</title>"; $feed .= "<link>{$link}</link>"; $feed .= "<image>"; $feed .= "<url>http://terminal.jcubic.pl/css/images/logo.png</url>"; $feed .= "<title>{$title}</title>"; $feed .= "<link>http://terminal.jcubic.pl/#comments</link>"; $feed .= "</image>"; $feed .= "<copyright>Jakub Jankiewicz</copyright>"; $feed .= "<generator>php script</generator>"; $feed .= "<webMaster>jcubic@onet.pl</webMaster>"; $query = "SELECT rss_date(date), nick, email, www, comment FROM jq_comments order by date DESC"; $comments = mysql_array($query); $feed .= "<pubDate>{$comments[0][0]}</pubDate>"; $feed .= "<description>{$description}</description>"; foreach ($comments as $item) { if (!preg_match('/http:\\/\\//', $item[3])) { if (preg_match('/.*\\..*/', $item[3])) { $url = "http://" . $item[3]; } else { $url = null; } } else { $url = $item[3]; } $item[4] = htmlspecialchars($item[4]); $nick = strcmp($item[1], '') == 0 ? 'Anonymous' : $item[1]; $feed .= item($nick, $nick, $url, $item[4], $item[0]); } $feed .= "</channel>"; $feed .= "</rss>"; return $feed; }
<?php include "../bower_components/php/config/bd.php"; if (isset($_POST['search'])) { $find = $_POST['search']; $search = mysql_array("SELECT id,nomer,name FROM `cat_price` WHERE `nomer` LIKE '%{$find}%' or `name` like '%{$find}%' limit 10"); echo json_encode($search); }
public function get_comments() { connect(); $query = "SELECT DATE_FORMAT(date, '%d-%m-%Y'), nick, avatar, www,\n comment, id from jq_comments order by date"; return mysql_array($query); }
<?php header("Content-Type:text/xml"); echo '<?xml version="1.0" encoding="UTF-8"?>'; ?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <?php include 'config.php'; include 'includes/functions.php'; include 'includes/mysql_functions.php'; function xmlentities($string) { return str_replace(array('&', '"', "'", '<', '>', '?'), array('&', '"', ''', '<', '>', '''), $string); } $pages = mysql_array(mysql_query("SELECT url, modified from urls")); foreach ($pages as $page) { ?> <url> <loc><?php echo xmlentities($page['url']); ?> </loc> <?php if (strlen($page['modified']) > 0) { ?> <lastmod><?php echo date('Y-m-d', $page['modified']); ?> </lastmod><?php } ?>
?> </td> </tr> <?php } ?> </table> </div> <div class='column'> <h2>File Types</h2> </html> <?php $sql = 'SELECT type, COUNT(type) AS NumOccurrences FROM urls WHERE `crawl_tag`="' . $crawl_tag . '" GROUP BY type HAVING ( COUNT(type) > 0 ) ORDER BY NumOccurrences DESC'; $types = mysql_array(mysql_query($sql)); ?> <table> <tr> <th>File Type</th> <th>Count</th> </tr> <?php foreach ($types as $type) { ?> <tr> <td class='fieltype'> <a href='query.php?http_code=<?php echo urlencode($type['type']); ?> '><?php
function checkIPAssigned() { global $pro_mysql_vps_ip_table; global $pro_mysql_vps_server_table; global $pro_mysql_dedicated_ips_table; global $pro_mysql_ssl_ips_table; global $action_error_txt; // We first force an IP to be in. if ($_REQUEST["action"] != "ssl_ip_list_edit" && $_REQUEST["action"] != "ssl_ip_list_new" && $_REQUEST["action"] != "dedicated_ip_list_edit" && $_REQUEST["action"] != "dedicated_ip_list_new" && $_REQUEST["action"] != "vps_server_ip_list_edit" && $_REQUEST["action"] != "vps_server_ip_list_new" && $_REQUEST["dom0_ips"] == "") { $action_error_txt = _("Please enter an IP address for your dom0!"); return false; } // Then we check all IPs separated by | one by one $ret_val = true; if ($_REQUEST["action"] == "vps_server_ip_list_edit" || $_REQUEST["action"] == "vps_server_ip_list_new" || $_REQUEST["action"] == "ssl_ip_list_edit" || $_REQUEST["action"] == "ssl_ip_list_new" || $_REQUEST["action"] == "dedicated_ip_list_edit" || $_REQUEST["action"] == "dedicated_ip_list_new") { $all_dom0_ips = array(); $all_dom0_ips[] = $_REQUEST["ip_addr"]; $nbr_ips = 1; } else { $all_dom0_ips = explode("|", $_REQUEST["dom0_ips"]); $nbr_ips = sizeof($all_dom0_ips); } for ($i = 0; $i < $nbr_ips; $i++) { $test_ip = $all_dom0_ips[$i]; // First check against all dom0 IPs // This request will filter a lot the IPs, but will return many IP separated by | // we will have to test them one by one in a loop // If we are editing a record for the dom0, we don't want to check this record if ($_REQUEST["action"] == "vps_server_list_edit") { $q = "SELECT * FROM {$pro_mysql_vps_server_table} WHERE dom0_ips LIKE '%{$test_ip}%' AND id != '" . $_REQUEST["id"] . "';"; } else { $q = "SELECT * FROM {$pro_mysql_vps_server_table} WHERE dom0_ips LIKE '%{$test_ip}%';"; } $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n = mysql_num_rows($r); if ($n != 0) { for ($j = 0; $j < $n; $j++) { $a = mysql_fetch_array($r); // Checking all IPs of the SQL record $q_all_dom0_ips = explode("|", $a["dom0_ips"]); $q_nbr_ips = sizeof($q_all_dom0_ips); for ($k = 0; $k < $q_nbr_ips; $k++) { if ($q_all_dom0_ips[$k] == $test_ip) { $action_error_txt = _("The IP address {$test_ip} is already assigned to a dom0: cannot assign to this one!"); $ret_val = false; } } } } // Then check against all VPS // If we are editing a VPS IP, we don't want to check this record if ($_REQUEST["action"] == "vps_server_ip_list_edit") { $q = "SELECT * FROM {$pro_mysql_vps_ip_table} WHERE ip_addr='{$test_ip}' AND id != '" . $_REQUEST["id"] . "';"; } else { $q = "SELECT * FROM {$pro_mysql_vps_ip_table} WHERE ip_addr='{$test_ip}';"; } $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n = mysql_num_rows($r); if ($n != 0) { $a = mysql_fetch_array($r); $action_error_txt = _("The IP address {$test_ip} is already assigned to a VPS: cannot assign this one!"); $action_error_txt .= "<br>xen" . $a["vps_xen_name"] . " " . $a["vps_server_hostname"]; $ret_val = false; } // Check against the SSLIP list if ($_REQUEST["action"] == "dedicated_ip_list_edit") { $q = "SELECT * FROM {$pro_mysql_dedicated_ips_table} WHERE ip_addr='{$test_ip}' AND id != '" . $_REQUEST["id"] . "';"; } else { $q = "SELECT * FROM {$pro_mysql_dedicated_ips_table} WHERE ip_addr='{$test_ip}';"; } $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n = mysql_num_rows($r); if ($n != 0) { $a = mysql_array($r); $action_error_txt = _("The IP address {$test_ip} is already assigned to a dedicated server: cannot assign this one!"); $action_error_txt .= "<br>" . _("Server hostname: ") . $a["dedicated_server_hostname"]; $ret_val = false; } // Check against the dedicated IP list if ($_REQUEST["action"] == "ssl_ip_list_edit") { $q = "SELECT * FROM {$pro_mysql_ssl_ips_table} WHERE ip_addr='{$test_ip}' AND id != '" . $_REQUEST["id"] . "';"; } else { $q = "SELECT * FROM {$pro_mysql_ssl_ips_table} WHERE ip_addr='{$test_ip}';"; } $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n = mysql_num_rows($r); if ($n != 0) { echo $action_error_txt = _("The IP address {$test_ip} is already assigned to an SSL site: cannot assign this one!"); $ret_val = false; } } return $ret_val; }
/** * Shorthand MySQL function to to get the first 100 uncrawled URLs * * @return array Associative array of uncrawled URLs & page data */ function uncrawled_urls($crawl_tag) { return mysql_array(mysql_query("SELECT * FROM `urls` WHERE `crawled` = '0' AND `crawl_tag`=\"{$crawl_tag}\" LIMIT 100")); }
{ if ($res = mysql_query($query)) { if (mysql_num_rows($res) > 0) { while ($row = mysql_fetch_row($res)) { $result[] = $row; } return $result; } else { return array(); } } else { throw new Exception("MySQL Error: " . mysql_error()); } } connect(); $array = mysql_array("SELECT distinct md5(email) from jq_comments where avatar <> 'avatars/default.png'"); foreach ($array as $row) { $data = file_get_contents('http://www.gravatar.com/avatar/' . $row[0] . '.png?d=404&s=48'); if ($data) { $name = "avatars/" . $row[0] . ".png"; if (!file_exists($name)) { $file = fopen($name, "w"); if (!$file) { echo "IO Error: Can't open file {$avatar}"; } $ret = fwrite($file, $data); echo "avatar: " . $name . " data[" . strlen($data) . "] saved " . ($ret == false ? 'fail' : $ret) . "\n"; fclose($file); } } else { $query = "UPDATE jq_comments SET avatar = 'avatars/default.png' WHERE md5(email) = '" . $row[0] . "'";