Website Monetization by MageNet - Version 1.0.6

Version Description

  • Add Refresh Ads button
  • Fix some bugs and problems
Download this release

Release Info

Developer MageNet
Plugin Icon 128x128 Website Monetization by MageNet
Version 1.0.6
Comparing to
See all releases

Code changes from version 1.0.5 to 1.0.6

Files changed (3) hide show
  1. monetization-by-magenet.php +38 -21
  2. readme.txt +4 -0
  3. view-settings.php +8 -0
monetization-by-magenet.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Website Monetization by MageNet
4
  Description: Website Monetization by MageNet allows you to sell contextual ads from your pages automatically and receive payments with PayPal. To get started: 1) Click the "Activate" link to the left of this description, 2) <a href="http://magenet.com" target="_blank">Sign up for a MageNet Key</a>, and 3) Go to Settings > "Website Monetization by MageNet" configuration page, and save your MageNet Key.
5
- Version: 1.0.5
6
  Author: MageNet.com
7
  Author URI: http://magenet.com
8
  */
@@ -25,7 +25,7 @@ if (!class_exists('MagenetLinkAutoinstall')) {
25
  private $api_host = "http://api.magenet.com";
26
  private $api_get = "/wordpress/get";
27
  private $api_test = "/wordpress/test";
28
- private $key = 0;
29
 
30
  public function MagenetLinkAutoinstall() {
31
  global $wpdb;
@@ -49,7 +49,7 @@ if (!class_exists('MagenetLinkAutoinstall')) {
49
  }
50
 
51
  public function getKey() {
52
- if ($this->key == 0) {
53
  $this->key = get_option("magenet_links_autoinstall_key");
54
  }
55
  return $this->key;
@@ -126,6 +126,7 @@ if (!class_exists('MagenetLinkAutoinstall')) {
126
 
127
  public function admin_magenet_settings() {
128
  global $wpdb;
 
129
  if (isset($_POST['key']) && !empty($_POST['key'])) {
130
  $magenet_key = $_POST['key'];
131
  $test_key = $this->testKey($magenet_key);
@@ -135,8 +136,21 @@ if (!class_exists('MagenetLinkAutoinstall')) {
135
  } else {
136
  $result_text = "<span style=\"color: #ca2222;\">Incorrect Key. Please try again</span>";
137
  }
138
- } else {
139
- $magenet_key = $this->getKey();
 
 
 
 
 
 
 
 
 
 
 
 
 
140
  }
141
  $link_data = $wpdb->get_results("SELECT * FROM `" . $this->tbl_magenet_links . "`", ARRAY_A);
142
  include_once('view-settings.php');
@@ -149,26 +163,29 @@ if (!class_exists('MagenetLinkAutoinstall')) {
149
 
150
  public function getLinks() {
151
  global $wpdb;
152
- $last_update_time = get_option("magenet_links_last_update");
153
- if ($last_update_time + $this->cache_time < time()) {
154
- $key = $this->getKey();
155
- $result = $this->sendRequest($this->api_host.$this->api_get, $key);
156
- if ($result) {
157
- $wpdb->query("DELETE FROM {$this->tbl_magenet_links} WHERE 1");
158
- $new_links = json_decode($result, TRUE);
159
- if (count($new_links)>0)
160
- foreach($new_links as $new_link) {
161
- if (isset($new_link['page_url']) && isset($new_link['issue_html'])) {
162
- $wpdb->query($wpdb->prepare("INSERT INTO {$this->tbl_magenet_links}(page_url, link_html) VALUES (%s, %s)", $new_link['page_url'], $new_link['issue_html']));
 
 
163
  }
164
- }
165
  update_option("magenet_links_last_update", time());
166
  }
 
 
 
 
167
  }
168
- $site_url = str_replace("'", "\'", get_option("siteurl"));
169
- $page_url = str_replace("'", "\'", $_SERVER["REQUEST_URI"]);
170
- $link_data = $wpdb->get_results("SELECT * FROM `" . $this->tbl_magenet_links . "` WHERE page_url='".$page_url."' OR page_url='".$site_url.$page_url."'", ARRAY_A);
171
- return $link_data;
172
  }
173
 
174
  public function sendRequest($url, $key) {
2
  /*
3
  Plugin Name: Website Monetization by MageNet
4
  Description: Website Monetization by MageNet allows you to sell contextual ads from your pages automatically and receive payments with PayPal. To get started: 1) Click the "Activate" link to the left of this description, 2) <a href="http://magenet.com" target="_blank">Sign up for a MageNet Key</a>, and 3) Go to Settings > "Website Monetization by MageNet" configuration page, and save your MageNet Key.
5
+ Version: 1.0.6
6
  Author: MageNet.com
7
  Author URI: http://magenet.com
8
  */
25
  private $api_host = "http://api.magenet.com";
26
  private $api_get = "/wordpress/get";
27
  private $api_test = "/wordpress/test";
28
+ private $key = false;
29
 
30
  public function MagenetLinkAutoinstall() {
31
  global $wpdb;
49
  }
50
 
51
  public function getKey() {
52
+ if (!$this->key) {
53
  $this->key = get_option("magenet_links_autoinstall_key");
54
  }
55
  return $this->key;
126
 
127
  public function admin_magenet_settings() {
128
  global $wpdb;
129
+ $magenet_key = $this->getKey();
130
  if (isset($_POST['key']) && !empty($_POST['key'])) {
131
  $magenet_key = $_POST['key'];
132
  $test_key = $this->testKey($magenet_key);
136
  } else {
137
  $result_text = "<span style=\"color: #ca2222;\">Incorrect Key. Please try again</span>";
138
  }
139
+ }
140
+ if (isset($_POST['update_data']) && $_POST['update_data'] == 1) {
141
+ $result = $this->sendRequest($this->api_host.$this->api_get, $magenet_key);
142
+ if ($result) {
143
+ $wpdb->query("DELETE FROM {$this->tbl_magenet_links} WHERE 1");
144
+ $new_links = json_decode($result, TRUE);
145
+ if (count($new_links)>0)
146
+ foreach($new_links as $new_link) {
147
+ if (isset($new_link['page_url']) && isset($new_link['issue_html'])) {
148
+ $wpdb->query($wpdb->prepare("INSERT INTO {$this->tbl_magenet_links}(page_url, link_html) VALUES (%s, %s)", $new_link['page_url'], $new_link['issue_html']));
149
+ }
150
+ }
151
+ }
152
+ update_option("magenet_links_last_update", time());
153
+ $result_update_text = "<span style=\"color: #009900;\">Ads have been updated.</span>";
154
  }
155
  $link_data = $wpdb->get_results("SELECT * FROM `" . $this->tbl_magenet_links . "`", ARRAY_A);
156
  include_once('view-settings.php');
163
 
164
  public function getLinks() {
165
  global $wpdb;
166
+ $key = $this->getKey();
167
+ if ($key) {
168
+ $last_update_time = get_option("magenet_links_last_update");
169
+ if ($last_update_time + $this->cache_time < time()) {
170
+ $result = $this->sendRequest($this->api_host.$this->api_get, $key);
171
+ if ($result) {
172
+ $wpdb->query("DELETE FROM {$this->tbl_magenet_links} WHERE 1");
173
+ $new_links = json_decode($result, TRUE);
174
+ if (count($new_links)>0)
175
+ foreach($new_links as $new_link) {
176
+ if (isset($new_link['page_url']) && isset($new_link['issue_html'])) {
177
+ $wpdb->query($wpdb->prepare("INSERT INTO {$this->tbl_magenet_links}(page_url, link_html) VALUES (%s, %s)", $new_link['page_url'], $new_link['issue_html']));
178
+ }
179
  }
180
+ }
181
  update_option("magenet_links_last_update", time());
182
  }
183
+ $site_url = str_replace("'", "\'", get_option("siteurl"));
184
+ $page_url = str_replace("'", "\'", $_SERVER["REQUEST_URI"]);
185
+ $link_data = $wpdb->get_results("SELECT * FROM `" . $this->tbl_magenet_links . "` WHERE page_url='".$page_url."' OR page_url='".$site_url.$page_url."'", ARRAY_A);
186
+ return $link_data;
187
  }
188
+ return false;
 
 
 
189
  }
190
 
191
  public function sendRequest($url, $key) {
readme.txt CHANGED
@@ -85,6 +85,10 @@ MageNet crawler will index your sites the same way Google does. It will “read
85
 
86
  == Changelog ==
87
 
 
 
 
 
88
  = 1.0.5 =
89
  * Changed readme file
90
 
85
 
86
  == Changelog ==
87
 
88
+ = 1.0.6 =
89
+ * Add Refresh Ads button
90
+ * Fix some bugs and problems
91
+
92
  = 1.0.5 =
93
  * Changed readme file
94
 
view-settings.php CHANGED
@@ -10,6 +10,7 @@
10
  <?php echo $result_text; ?>
11
  </form>
12
  </div>
 
13
  <div class="tool-box">
14
  <h3 class="title">Active Ads:</h2>
15
  <table class="widefat">
@@ -39,4 +40,11 @@
39
  </tbody>
40
  </table>
41
  </div>
 
 
 
 
 
 
 
42
  </div>
10
  <?php echo $result_text; ?>
11
  </form>
12
  </div>
13
+ <?if ($magenet_key) { ?>
14
  <div class="tool-box">
15
  <h3 class="title">Active Ads:</h2>
16
  <table class="widefat">
40
  </tbody>
41
  </table>
42
  </div>
43
+ <div class="tool-box">
44
+ <form method="post" action="">
45
+ <input type="hidden" name="update_data" value="1" />
46
+ <input type="submit" name="submit" value="Refresh Ads" />
47
+ </form>
48
+ </div>
49
+ <? } ?>
50
  </div>