/** * Process * Processes the creation of the campaign. * Uses an iframe to post the results when a particular action is set. * Makes it nice and easy to keep creating campaigns and not worrying about retyping any of the information. * * @see Trackpoint_Functions::Process() * * @return void */ function Process() { $session =& GetSession(); $thisuser = $session->Get('UserDetails'); $userid = $thisuser->userid; $switched_user = $session->Get('SwitchUser'); if ($switched_user) { $userid = $switched_user; } if ($thisuser->Admin()) { $db =& GetDatabase(); $qry = "SELECT userid, username FROM " . TRACKPOINT_TABLEPREFIX . "users ORDER BY username"; $result = $db->Query($qry); $usercount = 0; $GLOBALS['UserList'] = ''; while ($row = $db->Fetch($result)) { $usercount++; $selected = ''; if ($row['userid'] == $userid) { $selected = ' SELECTED'; } $GLOBALS['UserList'] .= '<option value="' . $row['userid'] . '"' . $selected . '>' . $row['username'] . '</option>'; } if ($usercount > 1) { $GLOBALS['SelectUser'] = $this->ParseTemplate('CreatePPCBulk_ChooseUser', true, false); } } $action = isset($_GET['Action']) ? strtolower($_GET['Action']) : null; switch ($action) { case 'upload': echo '<span style="font-family: tahoma; font-size: 12px;">'; $user = $thisuser->userid; if (isset($_POST['userid']) && $thisuser->Admin()) { $user = $_POST['userid']; } if (empty($_FILES) || !isset($_FILES['ppcfile'])) { echo GetLang('ChooseFileToUpload'); echo '</span>'; break; } $tmpfile = $_FILES['ppcfile']['tmp_name']; if (!is_uploaded_file($tmpfile)) { echo GetLang('ChooseFileToUpload'); echo '</span>'; break; } $newfilename = TEMP_DIRECTORY . '/trackpoint_ppc_file_' . $user . md5(time()) . '.tmp'; if (!move_uploaded_file($tmpfile, $newfilename)) { echo GetLang('UnableToReadFile'); echo '</span>'; break; } if (!($handle = fopen($newfilename, 'r'))) { echo GetLang('UnableToReadFile'); echo '</span>'; break; } $outputfile = TEMP_DIRECTORY . '/ppc_file_' . $user . '.' . time() . '.csv'; $output_filehandle = fopen($outputfile, 'w'); $fieldseparator = isset($_POST['fieldseparator']) && $_POST['fieldseparator'] ? htmlentities($_POST['fieldseparator']) : ','; if (strtolower($fieldseparator) == "tab") { $fielseparator = "\t"; } $invalid_rows = array(); while (($data = fgetcsv($handle, 1000, $fieldseparator)) !== FALSE) { $num = count($data); if ($num != 4) { array_push($invalid_rows, $data); continue; } $search_engine = trim($data[0]); $ppc_name = trim($data[1]); $landing_page = trim($data[2]); $cpc = 0; if (is_numeric($data[3])) { $cpc = (double) trim($data[3]); } $querystring = ''; if ($user != 1) { $querystring .= 'u=' . $user . '&'; } if (isset($_POST['EncodeInfo'])) { $querystring .= 'e=' . stripslashes($search_engine); $querystring .= '&n=' . stripslashes($ppc_name); $querystring .= '&c=' . (double) $cpc; $querystring = 'ppce=' . urlencode(base64_encode($querystring)); } else { $querystring .= 'ppc=' . urlencode(stripslashes($search_engine)); $querystring .= '&name=' . urlencode(stripslashes($ppc_name)); $querystring .= '&c=' . (double) $cpc; } $url = stripslashes($landing_page) . '/?'; if (strpos($landing_page, '?') !== false) { $url = stripslashes($landing_page) . '&' . $querystring; } else { $landingurl = stripslashes($landing_page); $urlparts = explode('/', $landingurl); $filename = array_pop($urlparts); if (strpos($filename, '.') !== false || substr($landingurl, -1) == '/') { $url = $landingurl . '?' . $querystring; } else { $url = $landingurl . '/?' . $querystring; } } $output_data = $data; $output_data[] = $url; $outputline = implode($fieldseparator, $output_data) . "\n"; fputs($output_filehandle, $outputline, strlen($outputline)); } fclose($handle); fclose($output_filehandle); unlink($newfilename); chmod($outputfile, 0646); if (filesize($outputfile) > 0) { $output_url = str_replace(TEMP_DIRECTORY, TRACKPOINT_APPLICATION_URL . '/temp', $outputfile); echo sprintf(GetLang('Bulk_Conversion_PPC_Finished'), $output_url) . '<br/>'; if (!empty($invalid_rows)) { echo '<br/>'; } } if (!empty($invalid_rows)) { echo GetLang('Bulk_PPC_RowsInvalid') . '<br/><br/>'; foreach ($invalid_rows as $p => $data) { echo implode('<br/>-', $data) . '<br/>'; } } echo '</span>'; break; default: Trackpoint_Functions::Process(); } }
/** * Process * Processes the creation of the campaign. * Uses an iframe to post the results when a particular action is set. * Makes it nice and easy to keep creating campaigns and not worrying about retyping any of the information. * * @see Trackpoint_Functions::Process() * * @return void */ function Process() { $today = date('d'); $thismonth = date('m'); $thisyear = date('y'); if (isset($_POST['StartDay'])) { $today = $_POST['StartDay']; } if (isset($_POST['StartMonth'])) { $thismonth = $_POST['StartMonth']; } if (isset($_POST['StartYear'])) { $thisyear = $_POST['StartYear']; } $days = ''; for ($i = 1; $i <= 31; $i++) { $days .= '<option value="' . sprintf('%02d', $i) . '"'; if ($i == $today) { $days .= ' SELECTED'; } $days .= '>' . sprintf('%02d', $i) . '</option>'; } $months = ''; for ($i = 1; $i <= 12; $i++) { $months .= '<option value="' . GetLang($this->Months[$i]) . '"'; if ($i == $thismonth) { $months .= ' SELECTED'; } $months .= '>' . GetLang($this->Months[$i]) . '</option>'; } $years = ''; for ($i = $thisyear - 1; $i <= $thisyear + 5; $i++) { $years .= '<option value="' . sprintf('%02d', $i) . '"'; if ($i == $thisyear) { $years .= ' SELECTED'; } $years .= '>' . sprintf('%02d', $i) . '</option>'; } $GLOBALS['StartDay'] = $days; $GLOBALS['StartMonth'] = $months; $GLOBALS['StartYear'] = $years; $session =& GetSession(); $thisuser = $session->Get('UserDetails'); $userid = $thisuser->userid; $switched_user = $session->Get('SwitchUser'); if ($switched_user) { $userid = $switched_user; $switched_username = $session->Get('SwitchUserName'); $GLOBALS['WarningMessage'] = sprintf(GetLang('CampaignCodeForUser'), $switched_username); } $action = isset($_GET['Action']) ? strtolower($_GET['Action']) : null; switch ($action) { case 'campaignlink': if (isset($_GET['Process'])) { $querystring = ''; if ($userid != 1) { $querystring .= 'u=' . $userid . '&'; } if (isset($_POST['EncodeInfo'])) { $querystring .= 'cp=' . stripslashes($_POST['CampaignName']); $querystring .= '&s=' . stripslashes($_POST['CampaignSite']); if (is_numeric($_POST['CampaignCost'])) { $querystring .= '&c=' . (double) $_POST['CampaignCost']; } if (isset($_POST['CampaignCostType'])) { if (is_numeric($_POST['PeriodDate'])) { $querystring .= '&p=' . (int) $_POST['PeriodDate']; } else { if ($_POST['PeriodDate'] == 'custom') { $querystring .= '&p=' . (int) $_POST['Days']; } } $GLOBALS['Period' . $_POST['PeriodDate'] . '_Selected'] = ' SELECTED'; $querystring .= '&d=' . $_POST['StartDay'] . $_POST['StartMonth'] . $_POST['StartYear']; } $querystring = 'cpe=' . urlencode(base64_encode($querystring)); } else { $querystring .= 'cp=' . urlencode(stripslashes($_POST['CampaignName'])); $querystring .= '&site=' . urlencode(stripslashes($_POST['CampaignSite'])); if (is_numeric($_POST['CampaignCost'])) { $querystring .= '&cost=' . (double) $_POST['CampaignCost']; } if (isset($_POST['CampaignCostType'])) { if (is_numeric($_POST['PeriodDate'])) { $querystring .= '&period=' . (int) $_POST['PeriodDate']; } else { if ($_POST['PeriodDate'] == 'custom') { $querystring .= '&period=' . (int) $_POST['days']; } } $querystring .= '&date=' . $_POST['StartDay'] . $_POST['StartMonth'] . $_POST['StartYear']; } } if (strpos($_POST['CampaignURL'], '?') !== false) { $url = stripslashes($_POST['CampaignURL']) . '&' . $querystring; } else { $campaignurl = stripslashes($_POST['CampaignURL']); $urlparts = explode('/', $campaignurl); $filename = array_pop($urlparts); if (strpos($filename, '.') !== false || substr($campaignurl, -1) == '/') { $url = $campaignurl . '?' . $querystring; } else { $url = $campaignurl . '/?' . $querystring; } } echo '<span style="font-family: tahoma; font-size: 12px;">' . $url . '</span>'; } break; default: Trackpoint_Functions::Process(); } }
/** * Process * Processes the creation of the payperclick campaign. * Uses an iframe to post the results when a particular action is set. * Makes it nice and easy to keep creating payperclicks and not worrying about retyping any of the information. * * @see Trackpoint_Functions::Process() * * @return void */ function Process() { $session =& GetSession(); $thisuser = $session->Get('UserDetails'); $userid = $thisuser->userid; $switched_user = $session->Get('SwitchUser'); if ($switched_user) { $userid = $switched_user; $switched_username = $session->Get('SwitchUserName'); $GLOBALS['WarningMessage'] = sprintf(GetLang('PPCCodeForUser'), $switched_username); } $action = isset($_GET['Action']) ? strtolower($_GET['Action']) : null; switch ($action) { case 'ppclink': if (isset($_GET['Process'])) { $querystring = ''; if ($userid != 1) { $querystring .= 'u=' . $userid . '&'; } if (isset($_POST['EncodeInfo'])) { $querystring .= 'e=' . stripslashes($_POST['ppcEngine']); $querystring .= '&n=' . stripslashes($_POST['ppcName']); if (is_numeric($_POST['ppcCost'])) { $querystring .= '&c=' . (double) $_POST['ppcCost']; } $querystring = 'ppce=' . urlencode(base64_encode($querystring)); } else { $querystring .= 'ppc=' . urlencode(stripslashes($_POST['ppcEngine'])); $querystring .= '&name=' . urlencode(stripslashes($_POST['ppcName'])); if (is_numeric($_POST['ppcCost'])) { $querystring .= '&cost=' . (double) $_POST['ppcCost']; } } $url = stripslashes($_POST['landingURL']) . '/?'; if (strpos($_POST['landingURL'], '?') !== false) { $url = stripslashes($_POST['landingURL']) . '&' . $querystring; } else { $landingurl = stripslashes($_POST['landingURL']); $urlparts = explode('/', $landingurl); $filename = array_pop($urlparts); if (strpos($filename, '.') !== false || substr($landingurl, -1) == '/') { $url = $landingurl . '?' . $querystring; } else { $url = $landingurl . '/?' . $querystring; } } echo '<span style="font-family: tahoma; font-size: 12px;">' . $url . '</span>'; } break; default: Trackpoint_Functions::Process(); } }