Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Document : Web submitter
- Created on : May 7, 2014, 9:12:38 AM
- Author : Suhendra - citstudio
- Description:
- */
- /*
- CREATE TABLE `mt_updateservices` (
- `id` int(11) NOT NULL AUTO_INCREMENT ,
- `url` varchar(150) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
- `is_active` enum('1','0') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '1' ,
- PRIMARY KEY (`id`)
- )
- ENGINE=InnoDB
- DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci
- AUTO_INCREMENT=1
- ROW_FORMAT=COMPACT;
- CREATE TABLE `mt_updateslog` (
- `id` bigint(20) NOT NULL AUTO_INCREMENT ,
- `update_id` int(11) NULL DEFAULT NULL ,
- `submit_date` datetime NULL DEFAULT NULL ,
- `result` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL ,
- `url` varchar(250) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
- PRIMARY KEY (`id`)
- )
- ENGINE=InnoDB
- DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci
- AUTO_INCREMENT=1
- ROW_FORMAT=COMPACT;
- $var = submit("Title", "protocols://domain.tld",TRUE / FALSE);
- */
- function submit($title = "Title", $url = "Slug", $displayResult = FALSE) {
- $ci = &get_instance();
- $result = TRUE;
- $ci->load->library('xmlrpc');
- $services = $ci->db->query("SELECT * FROM mt_updateservices")->result_array();
- $check_log = $ci->db->query("SELECT * FROM mt_updateslog WHERE url='" . $url . "'")->result_array();
- if (sizeof($check_log) == 0) {
- foreach ($services as $value) :
- $ci->xmlrpc->server($value, 80);
- $ci->xmlrpc->method('weblogUpdates.ping');
- $request = array($title, $url);
- $ci->xmlrpc->request($request);
- if (!$ci->xmlrpc->send_request()) {
- if ($displayResult) {
- $result = $ci->xmlrpc->display_error() . "<br/>";
- } else {
- $result = FALSE;
- }
- } else {
- $sql = "INSERT INTO mt_updatelog (update_id,submit_date, result, url) VALUES ";
- $sql .= "('" . $value["id"] . "','" . date("Y-m-d") . "','" . $ci->xmlrpc->display_response() . "','" . $url . "')";
- $ci->db->query($sql);
- if ($displayResult) {
- $result = $ci->xmlrpc->display_response() . "<br/>";
- } else {
- $result = FALSE;
- }
- }
- endforeach;
- } else {
- if ($displayResult) {
- $result = "Calm down boys" . "<br/>";
- } else {
- $result = FALSE;
- }
- }
- return $result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement