Subversion Repositories cheapmusic

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
103 - 1
<?php
2
/**
3
 * Copyright (C) 2009-2019 www.seopanel.in. All rights reserved.
4
 * @author Geo Varghese
5
 *
6
 */
7
 
8
class QWP_Helper extends QuickWebProxy {
9
 
10
	/**
11
	 * function to show web proxy form
12
	 */
13
	function showWebProxyForm($info) {
14
		$userId = isLoggedIn();
15
 
16
		$proxyCtrler = new ProxyController();
17
		$proxyList = $proxyCtrler->__getAllProxys();
18
 
19
		// if allowed web server to act as a proxy
20
		if (defined('QWP_ALLOW_WEB_SERVER_ACT_AS_PROXY') && QWP_ALLOW_WEB_SERVER_ACT_AS_PROXY) {
21
			$proxyList[] = array('id' => 0, 'proxy' => $this->pluginText['Web Server']);
22
		}
23
 
24
		$sourceId = isset($info['source_id']) ? intval($info['source_id']) : intval($proxyList[0]['id']);
25
		$this->set('sourceId', $sourceId);
26
		$this->set('proxyList', $proxyList);
27
 
28
		$anonymize = isset($info['anonymize']) ? intval($info['anonymize']) : 1;
29
		$this->set('anonymize', $anonymize);
30
 
31
		$this->pluginRender('web_proxy_form');
32
	}
33
 
34
	/**
35
	 * function to do web proxy
36
	 */
37
	function doWebProxy($info) {
38
 
39
		if (empty($info['url'])) {
40
			showErrorMsg($this->pluginText["Please enter a valid url"]);
41
		}
42
 
43
		if (!isset($info['source_id'])) {
44
			showErrorMsg($this->pluginText["Server list is empty"]);
45
		}
46
 
47
		$info['url'] = addHttpToUrl($info['url']);
48
 
49
		// check for backslahes at last
50
		if (!stristr($url, '?') && !stristr($url, '#') && !preg_match('/\/$/', $url)) {
51
			$info['url'] .= "/";
52
		}
53
 
54
		$url = $this->pluginScriptUrl . "&base_url=1&action=processWebProxy&doc_type=export&url=" . urlencode($info['url']);
55
		$url .= "&source_id=" . intval($info['source_id']) . "&anonymize=" . intval($info['anonymize']);
56
		echo "<script type='text/javascript'>openInNewTab('$url')</script>";
57
	}
58
 
59
	/**
60
	 * function to process web proxy action
61
	 */
62
	function processWebProxy($info) {
63
		global $sourceId;
64
 
65
		if (empty($info['url']) && empty($info['miniProxyFormAction'])) {
66
			showErrorMsg($this->pluginText["Please enter a valid url"]);
67
		}
68
 
69
		if (!isset($info['source_id'])) {
70
			showErrorMsg($this->pluginText["Server list is empty"]);
71
		}
72
 
73
		$url = urldecode($info['url']);
74
		$sourceId = intval($info['source_id']);
75
		$anonymize = intval($info['anonymize']);
76
 
77
		// if base url is crawled, then store the details in crawl log
78
		if (!empty($info['base_url'])) {
79
 
80
			// update crawl log in database for future reference
81
			$crawlLogCtrl = new CrawlLogController();
82
			$crawlInfo['crawl_status'] = $response['error'] ? 0 : 1;
83
			$crawlInfo['ref_id'] = $crawlInfo['crawl_link'] = $url;
84
			$crawlInfo['proxy_id'] = $sourceId;
85
			$crawlInfo['crawl_type'] = "webproxy";
86
			$logId = $crawlLogCtrl->createCrawlLog($crawlInfo);
87
 
88
		}
89
 
90
		define("PROXY_PREFIX", $this->pluginScriptUrl . "&action=processWebProxy&doc_type=export&source_id=$sourceId&anonymize=$anonymize&url=");
91
		include $this->pluginPath . '/miniProxy.php';
92
 
93
		// if base url is crawled, then store the details in crawl log
94
		if (!empty($info['base_url'])) {
95
 
96
			// update crawl log in database for future reference
97
			$crawlInfo['crawl_status'] = $response['error'] ? 0 : 1;
98
			$crawlInfo['ref_id'] = $crawlInfo['crawl_link'] = $response['responseInfo']['url'];
99
			$crawlInfo['log_message'] = addslashes($response['errmsg']);
100
			$crawlLogCtrl->updateCrawlLog($logId, $crawlInfo);
101
 
102
		}
103
 
104
		// show errors, if error existing
105
		if (!empty($response['error'])) {
106
			showErrorMsg($response['errmsg']);
107
		}
108
 
109
	}
110
 
111
}
112
?>