PageRenderTime 73ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/www/admin/tracker-invocation.php

https://github.com/orchestra-io/sample-openx
PHP | 245 lines | 156 code | 32 blank | 57 comment | 51 complexity | d062e1284816d8aeaba7ff75c640ca4d MD5 | raw file
  1. <?php
  2. /*
  3. +---------------------------------------------------------------------------+
  4. | OpenX v${RELEASE_MAJOR_MINOR} |
  5. | =======${RELEASE_MAJOR_MINOR_DOUBLE_UNDERLINE} |
  6. | |
  7. | Copyright (c) 2003-2009 OpenX Limited |
  8. | For contact details, see: http://www.openx.org/ |
  9. | |
  10. | This program is free software; you can redistribute it and/or modify |
  11. | it under the terms of the GNU General Public License as published by |
  12. | the Free Software Foundation; either version 2 of the License, or |
  13. | (at your option) any later version. |
  14. | |
  15. | This program is distributed in the hope that it will be useful, |
  16. | but WITHOUT ANY WARRANTY; without even the implied warranty of |
  17. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
  18. | GNU General Public License for more details. |
  19. | |
  20. | You should have received a copy of the GNU General Public License |
  21. | along with this program; if not, write to the Free Software |
  22. | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
  23. +---------------------------------------------------------------------------+
  24. $Id: tracker-invocation.php 40140 2009-07-17 08:28:31Z matteo.beccati $
  25. */
  26. // Require the initialisation file
  27. require_once '../../init.php';
  28. // Required files
  29. require_once MAX_PATH . '/lib/OA/Dal.php';
  30. require_once MAX_PATH . '/www/admin/config.php';
  31. require_once MAX_PATH . '/www/admin/lib-statistics.inc.php';
  32. require_once MAX_PATH . '/lib/max/Admin/Invocation.php';
  33. require_once MAX_PATH . '/lib/max/other/html.php';
  34. // Register input variables
  35. phpAds_registerGlobal (
  36. 'trackername'
  37. ,'description'
  38. ,'move'
  39. ,'submit'
  40. ,'invtype'
  41. ,'trackerid'
  42. ,'clientid'
  43. ,'append'
  44. );
  45. // Security check
  46. OA_Permission::enforceAccount(OA_ACCOUNT_MANAGER);
  47. OA_Permission::enforceAccessToObject('clients', $clientid);
  48. OA_Permission::enforceAccessToObject('trackers', $trackerid);
  49. /*-------------------------------------------------------*/
  50. /* Store preferences */
  51. /*-------------------------------------------------------*/
  52. $session['prefs']['inventory_entities'][OA_Permission::getEntityId()]['clientid'] = $clientid;
  53. phpAds_SessionDataStore();
  54. /*-------------------------------------------------------*/
  55. /* Process submitted form */
  56. /*-------------------------------------------------------*/
  57. if (isset($submit)) {
  58. // If ID is not set, it should be a null-value for the auto_increment
  59. $doTrackers = OA_Dal::factoryDO('trackers');
  60. $doTrackers->trackername = $trackername;
  61. $doTrackers->description = $description;
  62. $doTrackers->clientid = $clientid;
  63. if (empty($trackerid)) {
  64. $trackerid = $doTrackers->insert();
  65. $new_tracker = true;
  66. } else {
  67. $doTrackers->trackerid = $trackerid;
  68. $doTrackers->update();
  69. }
  70. Header("Location: tracker-campaigns.php?clientid=".$clientid."&trackerid=".$trackerid);
  71. exit;
  72. }
  73. /*-------------------------------------------------------*/
  74. /* HTML framework */
  75. /*-------------------------------------------------------*/
  76. if ($trackerid != "") {
  77. $doClients = OA_Dal::factoryDO('clients');
  78. $doClients->whereAdd('clientid <>'.$trackerid);
  79. if (OA_Permission::isAccount(OA_ACCOUNT_MANAGER)) {
  80. $doClients->agencyid = OA_Permission::getAgencyId();
  81. }
  82. $doClients->find();
  83. $aOtherAdvertisers = array();
  84. while ($doClients->fetch() && $row = $doClients->toArray()) {
  85. $aOtherAdvertisers[] = $row;
  86. }
  87. MAX_displayNavigationTracker($clientid, $trackerid, $aOtherAdvertisers);
  88. }
  89. else {
  90. if (isset($move) && $move == 't') {
  91. // Convert client to tracker
  92. // TODO: is this still used? if not, we may want to remove it
  93. phpAds_PageHeader("4.1.4.4");
  94. echo "<img src='" . OX::assetPath() . "/images/icon-advertiser.gif' align='absmiddle'>&nbsp;".phpAds_getClientName($clientid);
  95. echo "&nbsp;<img src='" . OX::assetPath() . "/images/".$phpAds_TextDirection."/caret-rs.gif'>&nbsp;";
  96. echo "<img src='" . OX::assetPath() . "/images/icon-tracker.gif' align='absmiddle'>&nbsp;<b>".$strUntitled."</b><br /><br /><br />";
  97. phpAds_ShowSections(array("4.1.4.4"));
  98. } else {
  99. // New tracker
  100. // TODO: is this still used? if not, we may want to remove it
  101. phpAds_PageHeader("4.1.4.1");
  102. MAX_displayTrackerBreadcrumbs(null, $clientid);
  103. phpAds_ShowSections(array("4.1.4.1"));
  104. }
  105. }
  106. if ($trackerid != "" || (isset($move) && $move == 't')) {
  107. // Edit or Convert
  108. // Fetch exisiting settings
  109. // Parent setting for converting, tracker settings for editing
  110. if ($trackerid != "") {
  111. $ID = $trackerid;
  112. }
  113. if (isset($move) && $move == 't') {
  114. if (isset($clientid) && $clientid != "") {
  115. $ID = $clientid;
  116. }
  117. }
  118. $doTrackers = OA_Dal::factoryDO('trackers');
  119. if ($doTrackers->get($ID)) {
  120. $row = $doTrackers->toArray();
  121. }
  122. } else {
  123. // New tracker
  124. $doClients = OA_Dal::factoryDO('clients');
  125. if ($doClients->get($clientid)) {
  126. $client = $doClients->toArray();
  127. }
  128. if ($client) {
  129. $row['trackername'] = $client['clientname'].' - ';
  130. } else {
  131. $row["trackername"] = '';
  132. }
  133. $row["trackername"] .= $strDefault;
  134. }
  135. $trackerDetails = phpAds_getTrackerDetails($trackerid);
  136. $trackerVariables = Admin_DA::getVariables(array('tracker_id' => $trackerid), true);
  137. // Default to JS invocation if either appended HTML is found, or the tracker has variables
  138. if (empty($invtype) && (!empty($trackerDetails['appendcode']) || !empty($trackerVariables))) {
  139. $invtype = 'js';
  140. }
  141. $maxInvocation = new MAX_Admin_Invocation();
  142. if (isset($invtype) && $invtype == 'js') {
  143. $tracker_code = $maxInvocation->generateJavascriptTrackerCode($trackerid, $append);
  144. } else {
  145. $tracker_code = $maxInvocation->generateTrackerCode($trackerid);
  146. }
  147. /*-------------------------------------------------------*/
  148. /* Main code */
  149. /*-------------------------------------------------------*/
  150. $tabindex = 1;
  151. // START CODE
  152. echo "<table border='0' width='95%' cellpadding='0' cellspacing='0'>";
  153. echo "<tr><td height='25' colspan='2'><b>".$GLOBALS['strChooseInvocationType']."</b></td></tr>\n";
  154. echo "<tr><td height='35'>";
  155. echo "<form name='invform' action='".$_SERVER['SCRIPT_NAME']."' method='POST'>\n";
  156. echo "<input type='hidden' name='trackerid' value='".$trackerid."'>\n";
  157. echo "<input type='hidden' name='clientid' value='".$clientid."'>\n";
  158. echo "<select name='invtype' onChange=\"this.form.submit()\">\n";
  159. echo "<option value='img' " . ($invtype != 'js' ? 'selected="selected"' : '') . " >".$GLOBALS['strTrackerImageTag']."</option>\n";
  160. echo "<option value='js' " . ($invtype == 'js' ? 'selected="selected"' : '') . " >".$GLOBALS['strTrackerJsTag']."</option>\n";
  161. echo "</select>\n";
  162. echo "&nbsp;<input type='image' src='" . OX::assetPath() . "/images/".$phpAds_TextDirection."/go_blue.gif' border='0'>\n";
  163. if ($invtype == 'img' && !empty($trackerDetails['appendcode'])) {
  164. echo "<div class='errormessage'><img class='errormessage' src='" . OX::assetPath() . "/images/warning.gif' align='absmiddle'>
  165. <span class='tab-r'>{$GLOBALS['strWarning']}</span> - {$GLOBALS['strImgWithAppendWarning']}
  166. </div>";
  167. }
  168. echo "</td></tr>\n";
  169. phpAds_ShowBreak();
  170. echo "<tr><td height='25'><img src='" . OX::assetPath() . "/images/icon-generatecode.gif' align='absmiddle'>&nbsp;<b>".$GLOBALS['strTrackercode']."</b></td>";
  171. // Show clipboard button only on IE since Mozilla will throw a security warning
  172. if (strpos ($_SERVER['HTTP_USER_AGENT'], 'MSIE') > 0 && strpos ($_SERVER['HTTP_USER_AGENT'], 'Opera') < 1) {
  173. echo "<td height='25' align='right'width='95%'><img src='" . OX::assetPath() . "/images/icon-clipboard.gif' align='absmiddle'>&nbsp;";
  174. echo "<a href='javascript:max_CopyClipboard(\"bannercode\");'>".$GLOBALS['strCopyToClipboard']."</a></td><td width='5%'>&nbsp;</td></tr>";
  175. } else {
  176. echo "<td colspan='2'>&nbsp;</td>";
  177. }
  178. echo "<tr><td colspan='3'><textarea name='bannercode' id='bannercode' class='code-gray' rows='15' cols='80' style='width:95%; border: 1px solid black' readonly>".htmlspecialchars($tracker_code)."</textarea></td></tr>";
  179. echo "</table>";
  180. echo "<br />";
  181. // END CODE
  182. echo "<tr><td height='10' colspan='3'>&nbsp;</td></tr>"."\n";
  183. echo "<tr height='1'><td colspan='3' bgcolor='#888888'><img src='" . OX::assetPath() . "/images/break.gif' height='1' width='100%'></td></tr>"."\n";
  184. echo "</table>"."\n";
  185. if ($invtype == 'js') {
  186. echo "<br /><br />\n";
  187. echo "<table border='0' width='100%' cellpadding='0' cellspacing='0'>\n";
  188. echo "<tr><td height='25' colspan='3'><img src='" . OX::assetPath() . "/images/icon-overview.gif' align='absmiddle'>&nbsp;<b>".$GLOBALS['strParameters']."</b></td></tr>\n";
  189. echo "<tr><td width='30'>&nbsp;</td>\n";
  190. echo "<td width='200'>".$GLOBALS['strTrackerAlwaysAppend']."</td>\n";
  191. echo "<td width='370'><input type='radio' name='append' value='1'".(isset($append) && $append != 0 ? ' checked' : '')." tabindex='".($tabindex++)."'>&nbsp;".$GLOBALS['strYes']."<br />\n";
  192. echo "<input type='radio' name='append' value='0'".(!isset($append) || $append == 0 ? ' checked' : '')." tabindex='".($tabindex++)."'>&nbsp;".$GLOBALS['strNo']."</td>\n";
  193. echo "</tr>\n";
  194. echo "<tr><td width='30'><img src='" . OX::assetPath(). "/images/spacer.gif' height='5' width='100%'></td></tr>\n";
  195. echo "<tr><td height='10' colspan='3'>&nbsp;</td></tr>\n";
  196. echo "<tr height='1'><td colspan='3' bgcolor='#888888'><img src='" . OX::assetPath() . "/images/break.gif' height='1' width='100%'></td></tr>\n";
  197. echo "</table>\n";
  198. echo "<br /><br />\n";
  199. echo "<input type='submit' value='".$GLOBALS['strRefresh']."' name='submitbutton' tabindex='".($tabindex++)."'>\n";
  200. }
  201. echo "</form>\n";
  202. echo "<script type='text/javascript'>
  203. <!--
  204. $(document).ready(function() {
  205. $('#bannercode').selectText();
  206. });
  207. //-->
  208. </script>";
  209. /*-------------------------------------------------------*/
  210. /* HTML framework */
  211. /*-------------------------------------------------------*/
  212. phpAds_PageFooter();
  213. ?>