function delGrp($id) { $Return = false; if (check_dbid($id)) { //log before deletion! log will fetch old data if (TM_LOG) { $this->LOG->log(array("data" => array("id" => $id), "object" => "nl_grp", "action" => "delete")); } //standard gruppe suchen $Query = "SELECT id\n\t\t\t\t\tFROM " . TM_TABLE_NL_GRP . "\n\t\t\t\t\tWHERE siteid='" . TM_SITEID . "'\n\t\t\t\t\tAND standard=1"; if ($this->DB->Query($Query)) { $Return = true; } //wenn standardgruppe gefunden, weitermachen, ansonsten nichts tun!!! //loeschen geht nur wenn eine std gruppe definiert // wurde welche die NL aus zu loeschender Gruppe zugeordnet werden koennen if ($this->DB->next_record()) { $stdGrpID = $this->DB->Record['id']; //newsletter der stdgruppe neu zuordnen $Query = "UPDATE " . TM_TABLE_NL . " SET\n\t\t\t\t\t\t\tgrp_id=" . checkset_int($stdGrpID) . "\n\t\t\t\t\t\t\tWHERE siteid='" . TM_SITEID . "'\n\t\t\t\t\t\t\tAND grp_id=" . checkset_int($id); if ($this->DB->Query($Query)) { $Return = true; } else { $Return = false; return $Return; } //gruppe loeschen $Query = "DELETE FROM " . TM_TABLE_NL_GRP . "\n\t\t\t\t\t\t\tWHERE siteid='" . TM_SITEID . "'\n\t\t\t\t\t\t\tAND id=" . checkset_int($id); if ($this->DB->Query($Query)) { $Return = true; } else { $Return = false; return $Return; } } else { $Return = false; } } return $Return; }
function get($id = 0, $search = array()) { $this->LOG = array(); $search['id'] = $id; if (!isset($search['offset'])) { $search['offset'] = 0; } if (!isset($search['limit'])) { $search['limit'] = 1; } if (!isset($search['sort_type'])) { $search['sort_type'] = 0; } if (!isset($search['sort_index'])) { $search['sort_index'] = "id"; } $Query = "\n\t\t\tSELECT " . TM_TABLE_LOG . ".id, " . TM_TABLE_LOG . ".date, " . TM_TABLE_LOG . ".author_id, " . TM_TABLE_LOG . ".action, " . TM_TABLE_LOG . ".object, " . TM_TABLE_LOG . ".property, " . TM_TABLE_LOG . ".x_value," . TM_TABLE_LOG . ".edit_id, " . TM_TABLE_LOG . ".data, " . TM_TABLE_LOG . ".memo, " . TM_TABLE_LOG . ".siteid " . "FROM " . TM_TABLE_LOG . "\n\t\t\t"; $Query .= $this->createSearchQuery($search); if (!empty($search['sort_index'])) { $Query .= " ORDER BY " . dbesc($search['sort_index']); if ($search['sort_type'] == 0) { $Query .= " ASC\n\t\t\t\t"; } if ($search['sort_type'] == 1) { $Query .= " DESC\n\t\t\t\t"; } } if ($search['limit'] > 0 and $search['offset'] >= 0) { $Query .= " LIMIT " . checkset_int($search['offset']) . " ," . checkset_int($search['limit']) . "\n\t\t\t\t\t\t\t"; } $this->DB->Query($Query); $ac = 0; while ($this->DB->next_record()) { $this->LOG[$ac]['id'] = $this->DB->Record['id']; $this->LOG[$ac]['date'] = $this->DB->Record['date']; $this->LOG[$ac]['author_id'] = $this->DB->Record['author_id']; $this->LOG[$ac]['edit_id'] = $this->DB->Record['edit_id']; $this->LOG[$ac]['action'] = $this->DB->Record['action']; $this->LOG[$ac]['object'] = $this->DB->Record['object']; $this->LOG[$ac]['property'] = $this->DB->Record['property']; $this->LOG[$ac]['x_value'] = $this->DB->Record['x_value']; $this->LOG[$ac]['data'] = $this->DB->Record['data']; $this->LOG[$ac]['memo'] = $this->DB->Record['memo']; $this->LOG[$ac]['siteid'] = $this->DB->Record['siteid']; $ac++; } if ($ac > 0) { $this->LOG[0]['count'] = $ac; } return $this->LOG; }
function fetch_duplicates($search) { $this->DUPLICATES = array(); $this->DUPLICATES['dups'] = array(); $ac = 0; //check if keep method is set, this tells the method what address should be kept, first, last or random, others get deleted!!! if (isset($search['method'])) { //create the query, this will return only addresses with at least 1 duplicate (having qty>0) //we have to use innerjoin because we have an additional unique index 'id' //query willnot return qty, so he have to count them ourself //this does the trick: #SELECT t1.id, t1.colb FROM t1 INNER JOIN (SELECT count(t1.colb) AS qty, t1.colb FROM t1 GROUP t1.colb HAVING qty>1) AS dups ON t1.colb=dups.colb ORDER BY t1.colb, t1.id $Query = "SELECT \n\t\t\t\t\t\t" . TM_TABLE_ADR . ".id, \n\t\t\t\t\t\t" . TM_TABLE_ADR . ".email \n\t\t\t\t\t\tFROM " . TM_TABLE_ADR . "\n\t\t\t\t\t\tINNER JOIN ( \n\t\t\t\t\t\t\tSELECT count(" . TM_TABLE_ADR . ".email) AS qty,\n\t\t\t\t\t\t\t\t" . TM_TABLE_ADR . ".email \n\t\t\t\t\t\t\t\tFROM " . TM_TABLE_ADR . " \n\t\t\t\t\t\t\t\tGROUP BY " . TM_TABLE_ADR . ".email\n\t\t\t\t\t\t\t\tHAVING qty >1\n\t\t\t\t\t\t\t\t"; if (isset($search['limit']) && $search['limit'] > 0) { $Query .= " LIMIT " . checkset_int($search['limit']) . "\n\t\t\t\t\t\t"; } $Query .= ") AS dups\n\t\t\t\t\t\t\tON \n\t\t\t\t\t\t\t" . TM_TABLE_ADR . ".email = dups.email \n\t\t\t\t\t\tORDER BY " . TM_TABLE_ADR . ".email ASC," . TM_TABLE_ADR . ".id ASC\n\t\t\t\t\t"; //SORT BY IST RELEVANT, DA WIR KEEP LATEST ODER KEEP FIRST ENTRY NUTZEN. //send query to db and fetch duplicates $this->DB->Query($Query); $dupcount = 0; while ($this->DB->next_record()) { //index for dupicates array is the email address! hmmmm $email = $this->DB->Record['email']; //check if index exists, otherwise create it and save data, count duplicates if (isset($this->DUPLICATES['dups'][$email])) { $qty = count($this->DUPLICATES['dups'][$email]['id']); $this->DUPLICATES['dups'][$email]['id'][$qty] = $this->DB->Record['id']; //count $this->DUPLICATES['dups'][$email]['qty']++; #++ oder $qty+1; } else { $this->DUPLICATES['dups'][$email]['email'] = $this->DB->Record['email']; $this->DUPLICATES['dups'][$email]['qty'] = 1; $this->DUPLICATES['dups'][$email]['id'][0] = $this->DB->Record['id']; } $dupcount++; #= $dupcount + $this->DUPLICATES[$email]['qty']; } //while $this->DB->free(); //array is created like so: //['dups']: 'email' - unique email adr, 'qty' count/quantity, 'id' =Array with ids //count: unique dups //cound_dup: all dups //now walk through the array and check which entry should be kept using array index foreach ($this->DUPLICATES['dups'] as $DUP) { if ($search['method'] == 'random') { $keep = rand(0, $DUP['qty'] - 1); } if ($search['method'] == 'first') { $keep = 0; } if ($search['method'] == 'last') { $keep = $DUP['qty'] - 1; } $this->DUPLICATES['dups'][$DUP['email']]['keep'] = $keep; $this->DUPLICATES['dups'][$DUP['email']]['del'] = array(); //save ids to delete in an array 'del' for ($dc = 0; $dc < $DUP['qty']; $dc++) { if ($dc != $keep) { $del = count($this->DUPLICATES['dups'][$DUP['email']]['del']); $this->DUPLICATES['dups'][$DUP['email']]['del'][$del] = $DUP['id'][$dc]; } //if } //for ###improvements: #check syntax etc and check what data should be preserved...! automagic, if keeping email is invalid, use another one etc pp } //foreach } //isst method //count $this->DUPLICATES['count'] = count($this->DUPLICATES['dups']); //must be first defined, we add more indexes later!!! $this->DUPLICATES['count_dup'] = $dupcount; //return array to display return $this->DUPLICATES; }
function countBL($search = array()) { //zbsp. fuer pager benoetigt $Query = "\n\t\t\t\t\t\tSELECT count(" . TM_TABLE_BLACKLIST . ".id) as c\n\t\t\t\t\t\tFROM " . TM_TABLE_BLACKLIST . "\n\t\t\t\t\t"; $Query .= " WHERE " . TM_TABLE_BLACKLIST . ".siteid='" . TM_SITEID . "'"; if (isset($search['type']) && !empty($search['type'])) { $Query .= " AND " . TM_TABLE_BLACKLIST . ".type = '" . dbesc($search['type']) . "'"; } if (isset($search['expr']) && !empty($search['expr'])) { $Query .= " AND " . TM_TABLE_BLACKLIST . ".expr='" . dbesc($search['expr']) . "'"; } if (isset($search['aktiv']) && !empty($search['aktiv'])) { $Query .= " AND " . TM_TABLE_BLACKLIST . ".aktiv = " . checkset_int($search['aktiv']); } $this->DB2->Query($Query); if ($this->DB2->next_record()) { $count = $this->DB2->Record['c']; } return $count; }
function restart_failed($q_id = 0) { $Return = false; if (check_dbid($q_id)) { $Query = "UPDATE " . TM_TABLE_NL_H . " " . "SET status=1 " . "WHERE " . "q_id=" . checkset_int($q_id) . " " . "AND (status=4 OR status=6) " . "AND siteid='" . TM_SITEID . "'"; if ($this->DB->Query($Query)) { //log if (TM_LOG) { $this->LOG->log(array("data" => array("restart_failed" => 1, "id" => $q_id), "object" => "q", "action" => "edit")); } $Return = true; } } return $Return; //anzahl affected rows etc zurueckgeben, siehe addHQ }
$_MAIN_OUTPUT .= "<td>"; // onmousemove=\"showToolTip('tt_item_list_".$LOG[$acc]['id']."')\" onmouseout=\"setBGColor('row_".$acc."','".$bgcolor."');hideToolTip();\" $_MAIN_OUTPUT .= display($LOG[$acc]['date']); $_MAIN_OUTPUT .= "<div id=\"tt_item_list_" . $LOG[$acc]['id'] . "\" class=\"tooltip\">"; $_MAIN_OUTPUT .= display($L_DETAILS); $_MAIN_OUTPUT .= "</div>"; $_MAIN_OUTPUT .= "</td>"; $_MAIN_OUTPUT .= "<td>"; $_MAIN_OUTPUT .= display($LOG[$acc]['object']); $_MAIN_OUTPUT .= "</td>"; $_MAIN_OUTPUT .= "<td>"; $_MAIN_OUTPUT .= display($LOG[$acc]['action']); $_MAIN_OUTPUT .= "</td>"; $_MAIN_OUTPUT .= "<td>"; $_MAIN_OUTPUT .= "<a href=\"" . $tm_URL . "/" . $editIDURLPara_ . "\" title=\"" . ___("Filter") . "\">"; $_MAIN_OUTPUT .= checkset_int($LOG[$acc]['edit_id']); $_MAIN_OUTPUT .= "</a></td>"; $_MAIN_OUTPUT .= "<td>"; $_MAIN_OUTPUT .= "<em>" . $O_Name . "</em>"; $_MAIN_OUTPUT .= "</td>"; $_MAIN_OUTPUT .= "<td>"; $_MAIN_OUTPUT .= display($LOGIN->getUserName($LOG[$acc]['author_id'])); $_MAIN_OUTPUT .= "</td>"; $_MAIN_OUTPUT .= "<td>"; $_MAIN_OUTPUT .= strlen($LOG[$acc]['data']); $_MAIN_OUTPUT .= "</td>"; /* $_MAIN_OUTPUT.= "<td>"; if ($user_is_admin) { $_MAIN_OUTPUT.= " <a href=\"".$tm_URL."/".$delURLPara_."\" onclick=\"return confirmLink(this, '".___("löschen")."')\" title=\"".___("löschen")."\">".tm_icon("cross.png",___("löschen"))."</a>"; }
function makeMap(&$img, &$gi, $frm_id, $width, $height) { $Query = "SELECT ip FROM " . TM_TABLE_FRM_S . "\n\t\t\t\t\tWHERE siteid='" . TM_SITEID . "'"; $Query .= " AND ip!='0.0.0.0' AND ip!=''"; if (check_dbid($frm_id)) { $Query .= " AND frm_id=" . checkset_int($frm_id); } if ($this->DB->Query($Query)) { $Color1 = imagecolorallocate($img, 255, 255, 0); $Color2 = imagecolorallocate($img, 255, 0, 0); while ($this->DB->next_Record()) { $geoip = geoip_record_by_addr($gi, $this->DB->Record['ip']); if (isset($geoip->latitude, $geoip->longitude)) { $pt = getlocationcoords($geoip->latitude, $geoip->longitude, $width, $height); imagefilledrectangle($img, $pt["x"] - 1, $pt["y"] - 1, $pt["x"] + 1, $pt["y"] + 1, $Color1); imagerectangle($img, $pt["x"] - 4, $pt["y"] - 4, $pt["x"] + 4, $pt["y"] + 4, $Color2); } } //while } //if query }
function setHostStd($id = 0) { $Return = false; if (check_dbid($id)) { $Query = "UPDATE " . TM_TABLE_HOST . "\n\t\t\t\t\t\tSET standard=0\n\t\t\t\t\t\tWHERE standard=1\n\t\t\t\t\t\tAND siteid='" . TM_SITEID . "'"; //log $HOSTSTD = $this->getStdSMTPHost(); if ($this->DB->Query($Query)) { //log if (TM_LOG) { $this->LOG->log(array("data" => array("standard" => 0, "id" => $HOSTSTD[0]['id']), "object" => "host", "action" => "edit")); } $Return = true; } else { $Return = false; return $Return; } $Query = "UPDATE " . TM_TABLE_HOST . "\n\t\t\t\t\t\tSET standard=1\n\t\t\t\t\t\tWHERE id=" . checkset_int($id) . "\n\t\t\t\t\t\tAND siteid='" . TM_SITEID . "'"; if ($this->DB->Query($Query)) { //log if (TM_LOG) { $this->LOG->log(array("data" => array("standard" => 1, "id" => $id), "object" => "host", "action" => "edit")); } $Return = true; } else { $Return = false; return $Return; } } return $Return; }
function updateCFG($cfg) { $Return = false; $Query = "UPDATE " . TM_TABLE_CONFIG . "\n\t\t\t\t\tSET\n\t\t\t\t\tname='" . dbesc($cfg["name"]) . "',\n\t\t\t\t\tlang='" . dbesc($cfg["lang"]) . "',\n\t\t\t\t\tstyle='" . dbesc($cfg["style"]) . "',\n\t\t\t\t\tnotify_mail='" . dbesc($cfg["notify_mail"]) . "',\n\t\t\t\t\tnotify_subscribe=" . checkset_int($cfg["notify_subscribe"]) . ",\n\t\t\t\t\tnotify_unsubscribe=" . checkset_int($cfg["notify_unsubscribe"]) . ",\n\t\t\t\t\temailcheck_intern=" . checkset_int($cfg["emailcheck_intern"]) . ",\n\t\t\t\t\temailcheck_subscribe=" . checkset_int($cfg["emailcheck_subscribe"]) . ",\n\t\t\t\t\temailcheck_sendit=" . checkset_int($cfg["emailcheck_sendit"]) . ",\n\t\t\t\t\temailcheck_checkit=" . checkset_int($cfg["emailcheck_checkit"]) . ",\n\t\t\t\t\tcheck_version=" . checkset_int($cfg["check_version"]) . ",\n\t\t\t\t\tmax_mails_retry=" . checkset_int($cfg["max_mails_retry"]) . ",\n\t\t\t\t\ttrack_image='" . dbesc($cfg["track_image"]) . "',\n\t\t\t\t\trcpt_name='" . dbesc($cfg["rcpt_name"]) . "',\n\t\t\t\t\tunsubscribe_use_captcha=" . checkset_int($cfg["unsubscribe_use_captcha"]) . ",\n\t\t\t\t\tunsubscribe_digits_captcha=" . checkset_int($cfg["unsubscribe_digits_captcha"]) . ",\n\t\t\t\t\tunsubscribe_sendmail=" . checkset_int($cfg["unsubscribe_sendmail"]) . ",\n\t\t\t\t\tunsubscribe_action='" . dbesc($cfg["unsubscribe_action"]) . "',\n\t\t\t\t\tunsubscribe_host='" . dbesc($cfg["unsubscribe_host"]) . "',\n\t\t\t\t\tcheckit_limit=" . checkset_int($cfg["checkit_limit"]) . ",\n\t\t\t\t\tcheckit_from_email='" . dbesc($cfg["checkit_from_email"]) . "',\n\t\t\t\t\tcheckit_adr_reset_error=" . checkset_int($cfg["checkit_adr_reset_error"]) . ",\n\t\t\t\t\tcheckit_adr_reset_status=" . checkset_int($cfg["checkit_adr_reset_status"]) . ",\n\t\t\t\t\tbounceit_limit=" . checkset_int($cfg["bounceit_limit"]) . ",\n\t\t\t\t\tbounceit_host=" . checkset_int($cfg["bounceit_host"]) . ",\n\t\t\t\t\tbounceit_action='" . dbesc($cfg["bounceit_action"]) . "',\n\t\t\t\t\tbounceit_search='" . dbesc($cfg["bounceit_search"]) . "',\n\t\t\t\t\tbounceit_filter_to=" . checkset_int($cfg["bounceit_filter_to"]) . ",\n\t\t\t\t\tbounceit_filter_to_email='" . dbesc($cfg["bounceit_filter_to_email"]) . "',\n\t\t\t\t\tproof=" . checkset_int($cfg["proof"]) . ",\n\t\t\t\t\tproof_url='" . dbesc($cfg["proof_url"]) . "',\n\t\t\t\t\tproof_trigger=" . checkset_int($cfg["proof_trigger"]) . ",\n\t\t\t\t\tproof_pc=" . checkset_int($cfg["proof_pc"]) . "\n\t\t\t\t\tWHERE siteid='" . dbesc($cfg["siteid"]) . "'\n\t\t\t\t\t"; if ($this->DB->Query($Query)) { if (TM_LOG) { $this->LOG->log(array("data" => $cfg, "object" => "cfg", "action" => "edit")); } $Return = true; } return $Return; }
/********************************************************************************/ #$set=getVar("set"); $InputName_Set = "set"; // $InputName_Obj = "s_obj"; // ${$InputName_Obj} = getVar($InputName_Obj); $InputName_Author = "s_author"; // ${$InputName_Author} = getVar($InputName_Author); $InputName_Action = "s_action"; // ${$InputName_Action} = getVar($InputName_Action); $InputName_EditID = "s_edit_id"; // ${$InputName_EditID} = checkset_int(getVar($InputName_EditID)); $InputName_Limit = "limit"; //range from $InputName_SI0 = "si0"; // ${$InputName_SI0} = getVar($InputName_SI0); $InputName_SI1 = "si1"; // ${$InputName_SI1} = getVar($InputName_SI1); $InputName_SI2 = "si2"; // ${$InputName_SI2} = getVar($InputName_SI2); $sort_search = false; if (!isset($sortIndex)) { $sortIndex = getVar("si"); }
function countClick($id) { $Return = false; if (check_dbid($id)) { $Query = "UPDATE " . $this->TM_TABLE_ITEM . " SET clicks=clicks+1 WHERE siteid='" . TM_SITEID . "' AND id=" . checkset_int($id); if ($this->DB->Query($Query)) { $Return = true; } } return $Return; }