From 3a4958e5606a99b7ebc4287689af09c061653b10 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sat, 13 Dec 2014 21:28:30 -0500 Subject: [PATCH] Move pingback code to separate repo --- tools/sites/latest/robots.txt | 2 - tools/sites/latest/stable.php | 165 ---------------------------------- 2 files changed, 167 deletions(-) delete mode 100644 tools/sites/latest/robots.txt delete mode 100644 tools/sites/latest/stable.php diff --git a/tools/sites/latest/robots.txt b/tools/sites/latest/robots.txt deleted file mode 100644 index 1f53798bb4..0000000000 --- a/tools/sites/latest/robots.txt +++ /dev/null @@ -1,2 +0,0 @@ -User-agent: * -Disallow: / diff --git a/tools/sites/latest/stable.php b/tools/sites/latest/stable.php deleted file mode 100644 index 67517ebfa5..0000000000 --- a/tools/sites/latest/stable.php +++ /dev/null @@ -1,165 +0,0 @@ - " . (time() - 6 * 24 * 60 * 60); - $res = mysql_query($sql); - if (mysql_num_rows($res)) { - return FALSE; - } - return TRUE; -} - -/** - * CiviCRM 4.3 and later uses a json encoded POST - * Which includes stats on installed components/extensions - */ -function process_post_request() { - // Save to stats table - $id = insert_stats(); - - // Save to entities and extensions tables - foreach (array('entities', 'extensions') as $table) { - if (!empty($_POST[$table])) { - insert_children($table, $_POST[$table], $id); - } - } -} - -/** - * CiviCRM 4.2 and earlier sent all params in the url of a GET request - * It did not report on installed components/extensions - */ -function process_get_request() { - // Save to stats table - $id = insert_stats(); - - // Save to entities table - $entities = array( - 'Activity', 'Case', 'Contact', 'Contribution', 'ContributionPage', - 'ContributionProduct', 'Discount', 'Event', 'Friend', 'Grant', 'Mailing', 'Membership', - 'MembershipBlock', 'Participant', 'Pledge', 'PledgeBlock', 'PriceSetEntity', - 'Relationship', 'UFGroup', 'Widget', - ); - $params = array(); - // Reformat legacy-style params - foreach ($entities as $name) { - if (isset($_GET[$name])) { - $params[] = array( - 'name' => $name, - 'size' => $_GET[$name], - ); - } - } - // Run query if there is data to insert - if ($params) { - insert_children('entities', $params, $id); - } -} - -/** - * Insert the primary record into the stats table - * @return int: primary record id - */ -function insert_stats() { - global $link; - $fields = get_fields('stats'); - $params = format_params($fields, $_REQUEST); - $sql = insert_clause('stats', $params) . 'VALUES (' . implode(', ', $params) . ')'; - mysql_query($sql, $link); - return mysql_insert_id($link); -} - -/** - * Insert the child records - * - * @param $table - * @param $data - * @param $id - * - * @internal param $table : table name - * @internal param $id : primary record id - */ -function insert_children($table, $data, $id) { - global $link; - $fields = get_fields($table); - $sql = insert_clause($table, $fields); - $prefix = 'VALUES'; - foreach ($data as $input) { - $input['stat_id'] = $id; - $sql .= "$prefix (" . implode(', ', format_params($fields, $input, TRUE)) . ')'; - $prefix = ','; - } - mysql_query($sql, $link); -} - -/** - * Returns available fields and their data type from table schema - */ -function get_fields($table) { - global $link; - $info = array(); - $res = mysql_query("DESCRIBE $table", $link); - while ($row = mysql_fetch_array($res)) { - // Skip autofilled fields - if ($row['Extra'] == 'auto_increment' || $row['Default'] == 'CURRENT_TIMESTAMP') { - continue; - } - $info[$row['Field']] = strpos($row['Type'], 'int') !== FALSE ? 'int' : 'text'; - } - return $info; -} - -/** - * Build a list of sanitized params ready for insert - */ -function format_params($fields, $input, $pad = FALSE) { - $params = array(); - foreach ($fields as $field => $type) { - if (isset($input[$field])) { - if ($type == 'int') { - $params[$field] = (int) $input[$field]; - } - else { - $params[$field] = "'" . mysql_real_escape_string($input[$field]) . "'"; - } - } - elseif ($pad) { - $params[$field] = 'NULL'; - } - } - return $params; -} - -/** - * Build the insert clause of the sql query - */ -function insert_clause($table, $fields) { - return "INSERT INTO `$table` (`" . implode('`, `', array_keys($fields)) . '`) '; -} -- 2.25.1