Exemple #1
0
 //  $formatting_content .= '/>';
 foreach ($GLOBALS['plugins'] as $pluginname => $plugin) {
     $plugins_sendformats = $plugin->sendFormats();
     if (is_array($plugins_sendformats) && sizeof($plugins_sendformats)) {
         foreach ($plugins_sendformats as $val => $desc) {
             $val = preg_replace("/\\W/", '', strtolower(trim($val)));
             if ($val[0] != '_') {
                 ## allow a plugin to add a format that is not actually displayed
                 $formatting_content .= sprintf('%s <input type="radio" name="sendformat" value="%s" %s />', $desc, $val, $messagedata["sendformat"] == $val ? 'checked="checked"' : '');
             }
         }
     }
 }
 $formatting_content .= '</div>';
 $req = Sql_Query("select id,title from {$tables["template"]} order by listorder");
 if (Sql_Num_Rows($req)) {
     $formatting_content .= '<div class="field"><label for="template">' . $GLOBALS['I18N']->get("Use Template") . Help("usetemplate") . '</label>' . '
   <select name="template"><option value="0">-- ' . $GLOBALS['I18N']->get("select one") . '</option>';
     $req = Sql_Query("select id,title from {$tables["template"]} order by listorder");
     while ($row = Sql_Fetch_Array($req)) {
         if ($row["title"]) {
             $formatting_content .= sprintf('<option value="%d" %s>%s</option>', $row["id"], $row["id"] == $messagedata["template"] ? 'selected="selected"' : '', $row["title"]);
         }
     }
     $formatting_content .= '</select></div>';
 }
 $formatting_content .= '</div>';
 #0013076: different content when forwarding 'to a friend'
 $maincontent .= '<div id="messagecontent" class="field"><label for="message">' . s("Compose Message") . Help("message") . '</label> ';
 $forwardcontent .= '<div id="messagecontent" class="field"><label for="forwardmessage">' . s("Compose Message") . Help("forwardmessage") . '</label> ';
 if (!empty($GLOBALS['editorplugin'])) {
Exemple #2
0
     if ($_GET['delete'] == 'alldraft') {
         $req = Sql_Query(sprintf('select id from %s where status = "draft" %s', $GLOBALS['tables']['message'], $ownership));
         while ($row = Sql_Fetch_Row($req)) {
             deleteMessage($row[0]);
         }
         $_SESSION['action_result'] = $GLOBALS['I18N']->get('All draft campaigns deleted');
         print Info($GLOBALS['I18N']->get('campaigns deleted'));
     } else {
         verifyCsrfGetToken();
         deleteMessage(sprintf('%d', $_GET['delete']));
         print Info($GLOBALS['I18N']->get('campaign deleted'));
         $_SESSION['action_result'] = $GLOBALS['I18N']->get('Campaign deleted');
     }
 }
 $req = Sql_Query(sprintf('select id,entered,subject,unix_timestamp(now()) - unix_timestamp(entered) as age from %s where status = "draft" %s order by entered desc', $GLOBALS['tables']['message'], $ownership));
 $numdraft = Sql_Num_Rows($req);
 if ($numdraft > 0 && !isset($_GET['id']) && !isset($_GET['new'])) {
     print '<p>' . PageLinkActionButton('send&amp;new=1', $I18N->get('start a new message'), '', '', s('Start a new campaign')) . '</p>';
     print '<p><h3>' . $I18N->get('Choose an existing draft message to work on') . '</h3></p><br/>';
     $ls = new WebblerListing($I18N->get('Draft messages'));
     $ls->noShader();
     while ($row = Sql_Fetch_Array($req)) {
         $element = '<!--' . $row['id'] . '-->' . $row['subject'];
         $ls->addElement($element, PageUrl2('send&amp;id=' . $row['id']));
         $ls->setClass($element, 'row1');
         #    $ls->addColumn($element,$I18N->get('edit'),PageLink2('send&amp;id='.$row['id'],$I18N->get('edit')));
         $ls->addColumn($element, $I18N->get('entered'), $row['entered']);
         $ls->addColumn($element, $I18N->get('age'), secs2time($row['age']));
         $ls->addRow($element, '', '<a class="del" href="' . PageUrl2('send&amp;delete=' . $row['id']) . '" title="' . $I18N->get('del') . '">' . $I18N->get('del') . '</a>');
     }
     $ls->addButton($I18N->get('delete all'), PageUrl2('send&amp;delete=alldraft'));
 private function saveImageData($msgdata = array())
 {
     $imgtbl = $GLOBALS['tables']['inlineImagePlugin_image'];
     $msgtbl = $GLOBALS['tables']['inlineImagePlugin_msg'];
     $id = $msgdata['id'];
     $msg = $msgdata['message'];
     $query = sprintf("select * from %s where id=%d", $msgtbl, $id);
     // Merge the message and template to check the images
     // Make sure that we have all parts of the message that may contain images
     if ($msgdata["template"]) {
         $template = $this->loadTemplate($msgdata["template"]);
         if (strpos($template, "[CONTENT]")) {
             $msg = str_replace("[CONTENT]", $msg, $template);
         }
     }
     if (strpos($msg, "[FOOTER]") !== false) {
         $msg = str_ireplace("[FOOTER]", $msgdata["footer"], $msg);
     } else {
         // Phplist always adds a footer.
         $msg .= $msgdata["footer"];
     }
     // We're not constructing the message, just collecting inline image files
     // Remove old data connecting this message with its images.We save the new data
     // below. We don't bother clearing old images from the
     // directory here, because they will eventually be deleted anyway, as we clean
     // older files from the database
     if (Sql_Num_Rows(Sql_Query($query)) > 0) {
         $query = sprintf("delete from %s where id=%d", $msgtbl, $id);
         Sql_Query($query);
     }
     // Collect the inline image tags
     preg_match_all('#<img[^<>]+\\Winline(?:\\W.*(?:/)?)?>#Ui', $msg, $match);
     //Store everything needed for rapid processing of messages
     foreach ($match[0] as $val) {
         $src = $this->getAttribute($val, "src");
         $fcontents = file_get_contents($src);
         $hsh = sha1($fcontents);
         // Use a checksum to distinguish different files with same name
         $filename = basename($src);
         $query = sprintf("select imgid, cid, local_name from %s where file_name='%s' and cksum='%s'", $imgtbl, $filename, $hsh);
         if (!($row = Sql_Fetch_Row_Query($query))) {
             $localfile = $this->getTempFilename($filename);
             // File name in image directory
             file_put_contents($localfile, $fcontents);
             $type = $this->getMimeType(pathInfo($src, PATHINFO_EXTENSION), $localfile);
             $cid = md5(uniqid(rand(), true));
             $query_i = sprintf("insert into %s (file_name, cksum, local_name, type, cid) values ('%s', '%s', '%s', '%s', '%s')", $imgtbl, sql_escape($filename), sql_escape($hsh), sql_escape($localfile), sql_escape($type), sql_escape($cid));
             Sql_Query($query_i);
             $row = Sql_Fetch_Row_Query($query);
         } else {
             if (!file_exists($row[2])) {
                 // We've had the image before, but it has
                 // been stored in the plugin only as a temporary file
                 // which may have been deleted
                 $localfile = $this->getTempFilename($filename);
                 file_put_contents($localfile, $fcontents);
                 $query_u = sprintf("update %s set local_name='%s' where imgid=%d", $imgtbl, $localfile, $row[0]);
                 Sql_Query($query_u);
                 $row = Sql_Fetch_Row_Query($query);
             } else {
                 // The image exists in the image directory
                 touch($row[2]);
                 // Flag that image file was recently used
             }
         }
         // Associate the image with the message
         // Any previous entries for this message ID have been deleted when we test
         // if a test message is OK or when we check if the message can be queued.
         $srcstr = $this->getAttribute($val, "src", 0);
         $imgtag = str_replace($srcstr, 'src="cid:' . $row[1] . '"', $val);
         $query_m = sprintf("insert into %s values (%d, %d, '%s','%s')", $msgtbl, $id, $row[0], sql_escape($val), sql_escape($imgtag));
         Sql_Query($query_m);
     }
 }
Exemple #4
0
function getPageLock($force = 0)
{
    global $tables;
    $thispage = $GLOBALS['page'];
    if ($thispage == 'pageaction') {
        $thispage = $_GET['action'];
    }
    $thispage = preg_replace('/\\W/', '', $thispage);
    #  cl_output('getting pagelock '.$thispage);
    #  ob_end_flush();
    if ($GLOBALS['commandline'] && $thispage == 'processqueue') {
        if (is_object($GLOBALS['MC'])) {
            ## multi-send requires a valid memcached setup
            $max = MAX_SENDPROCESSES;
        } else {
            $max = 1;
        }
    } else {
        $max = 1;
    }
    ## allow killing other processes
    if ($force) {
        Sql_query('delete from ' . $tables['sendprocess'] . ' where page = "' . sql_escape($thispage) . '"');
    }
    $running_req = Sql_query(sprintf('select now() - modified as age,id from %s where page = "%s" and alive order by started desc', $tables['sendprocess'], sql_escape($thispage)));
    $count = Sql_Num_Rows($running_req);
    $running_res = Sql_Fetch_Assoc($running_req);
    $waited = 0;
    # while ($running_res['age'] && $count >= $max) { # a process is already running
    while ($count >= $max) {
        # don't check age, as it may be 0
        #   cl_output('running process: '.$running_res['age'].' '.$max);
        if ($running_res['age'] > 600) {
            # some sql queries can take quite a while
            #cl_output($running_res['id'].' is old '.$running_res['age']);
            # process has been inactive for too long, kill it
            Sql_query("update {$tables['sendprocess']} set alive = 0 where id = " . $running_res['id']);
        } elseif ((int) $count >= (int) $max) {
            #   cl_output (sprintf($GLOBALS['I18N']->get('A process for this page is already running and it was still alive %s seconds ago'),$running_res['age']));
            output(s('A process for this page is already running and it was still alive %d seconds ago', $running_res['age']), 0);
            sleep(1);
            # to log the messages in the correct order
            if ($GLOBALS['commandline']) {
                cl_output(s('A process for this page is already running and it was still alive %d seconds ago', $running_res['age']), 0);
                cl_output($GLOBALS['I18N']->get('Running commandline, quitting. We\'ll find out what to do in the next run.'));
                exit;
            }
            output($GLOBALS['I18N']->get('Sleeping for 20 seconds, aborting will quit'), 0);
            flush();
            $abort = ignore_user_abort(0);
            sleep(20);
        }
        ++$waited;
        if ($waited > 10) {
            # we have waited 10 cycles, abort and quit script
            output($GLOBALS['I18N']->get('We have been waiting too long, I guess the other process is still going ok'), 0);
            return false;
        }
        $running_req = Sql_query('select now() - modified,id from ' . $tables['sendprocess'] . " where page = \"{$thispage}\" and alive order by started desc");
        $count = Sql_Num_Rows($running_req);
        $running_res = Sql_Fetch_row($running_req);
    }
    if (!empty($GLOBALS['commandline'])) {
        $processIdentifier = SENDPROCESS_SERVERNAME . ':' . getmypid();
    } else {
        $processIdentifier = $_SERVER['REMOTE_ADDR'];
    }
    $res = Sql_query('insert into ' . $tables['sendprocess'] . ' (started,page,alive,ipaddress) values(now(),"' . $thispage . '",1,"' . $processIdentifier . '")');
    $send_process_id = Sql_Insert_Id();
    $abort = ignore_user_abort(1);
    #  cl_output('Got pagelock '.$send_process_id );
    return $send_process_id;
}
Exemple #5
0
    $result = Sql_Query($query);
}
$buttons = new ButtonGroup(new Button(PageURL2('bounces'), s('delete')));
$buttons->addButton(new ConfirmButton($GLOBALS['I18N']->get('are you sure you want to delete all unidentified bounces older than 2 months') . '?', PageURL2("{$baseurl}&action=deleteunidentified"), $GLOBALS['I18N']->get('delete all unidentified (&gt; 2 months old)')));
$buttons->addButton(new ConfirmButton($GLOBALS['I18N']->get('are you sure you want to delete all bounces older than 2 months') . '?', PageURL2("{$baseurl}&action=deleteprocessed"), $GLOBALS['I18N']->get('delete all processed (&gt; 2 months old)')));
$buttons->addButton(new ConfirmButton($GLOBALS['I18N']->get('are you sure you want to delete all bounces') . '?', PageURL2("{$baseurl}&action=deleteall"), $GLOBALS['I18N']->get('Delete all')));
print "<div class='actions'>\n";
print "<div class='minitabs'>\n";
print $tabs->display();
print "</div>\n";
print PageLinkButton('listbounces', $GLOBALS['I18N']->get('view bounces by list'));
if (ALLOW_DELETEBOUNCE) {
    print '<div class="fright">' . $buttons->show() . '</div>';
}
print "</div><!-- .actions div-->\n";
if (!Sql_Num_Rows($result)) {
    switch ($status) {
        case 'unidentified':
            print '<p class="information">' . s('no unidentified bounces available') . '</p>';
            break;
        case 'processed':
            print '<p class="information">' . s('no processed bounces available') . '</p>';
            break;
    }
}
$ls = new WebblerListing(s($status) . ' ' . s('bounces'));
$ls->usePanel($paging);
while ($bounce = Sql_fetch_array($result)) {
    #@@@ not sure about these ones - bounced list message
    $element = $bounce['id'];
    $ls->addElement($element, PageUrl2('bounce&type=' . $status . '&id=' . $bounce['id']));
Exemple #6
0
            $subselectimp = " where id = 0";
            break;
    }
}
if (isset($_GET['list'])) {
    $id = sprintf('%d', $_GET['list']);
    if (!empty($subselectimp)) {
        $subselectimp .= ' and id = ' . $id;
    } else {
        $subselectimp .= ' where id = ' . $id;
    }
}
#print PageLinkDialog('addlist',$GLOBALS['I18N']->get('Add a new list'));
print FormStart(' enctype="multipart/form-data" name="import"');
$result = Sql_query("SELECT id,name FROM " . $tables["list"] . "{$subselectimp} ORDER BY listorder");
$total = Sql_Num_Rows($result);
$c = 0;
if ($total == 1) {
    $row = Sql_fetch_array($result);
    $content .= sprintf('<input type="hidden" name="listname[%d]" value="%s"><input type="hidden" name="importlists[%d]" value="%d">' . $GLOBALS['I18N']->get('Adding subscribers') . ' <b>%s</b>', $c, stripslashes($row["name"]), $c, $row["id"], stripslashes($row["name"]));
} else {
    $content .= '<p>' . $GLOBALS['I18N']->get('Select the lists to add the emails to') . '</p>';
    $content .= ListSelectHTML($selected_lists, 'importlists', $subselectimp);
}
$content .= '<p class="information">' . $GLOBALS['I18N']->get('Please enter the emails to import, one per line, in the box below and click "Import Emails"');
#$GLOBALS['I18N']->get('<b>Warning</b>: the emails you import will not be checked on validity. You can do this later on the "reconcile subscribers" page.');
$content .= '</p>';
$content .= '<div class="field"><input type="checkbox" name="checkvalidity" value="1" checked="checked" /> ' . $GLOBALS['I18N']->get('Check to skip emails that are not valid') . '</div>';
$content .= '<div class="field"><input type="submit" name="doimport" value="' . $GLOBALS['I18N']->get('Import emails') . '" ></div>';
$content .= '<div class="field"><textarea name="importcontent" rows="10" cols="40"></textarea></div>';
$panel = new UIPanel('', $content);
                Sql_Query("drop table {$table_prefix}" . "adminattr_{$row['0']}");
            }
            Sql_Query("delete from {$tables['adminattribute']} where id = {$id}");
            # delete all admin attributes as well
            Sql_Query("delete from {$tables['admin_attribute']} where adminattributeid = {$id}");
        }
    }
}
?>



<?php 
print formStart();
$res = Sql_Query("select * from {$tables['adminattribute']} order by listorder");
if (Sql_Num_Rows()) {
    print $GLOBALS['I18N']->get('ExistingAttr');
} else {
    print $GLOBALS['I18N']->get('NoAttrYet');
}
while ($row = Sql_Fetch_array($res)) {
    ?>
  <table border=1>
  <tr><td colspan=2><?php 
    echo $GLOBALS['I18N']->get('Attribute') . $row["id"];
    ?>
</td><td colspan=2><?php 
    echo $GLOBALS['I18N']->get('Delete');
    ?>
 <input type="checkbox" name="delete[<?php 
    echo $row["id"];
Exemple #8
0
     $some = 1;
 }
 reset($import_attribute);
 foreach ($import_attribute as $item) {
     if (!empty($data['values'][$item["index"]])) {
         $attribute_index = $item["record"];
         $value = $data['values'][$item["index"]];
         # check whether this is a textline or a selectable item
         $att = Sql_Fetch_Row_Query("select type,tablename,name from " . $tables["adminattribute"] . " where id = {$attribute_index}");
         switch ($att[0]) {
             case "select":
             case "radio":
                 $query = "select id from {$table_prefix}adminattr_{$att['1']} where name = ?";
                 $val = Sql_Query_Params($query, array($value));
                 # if we don't have this value add it '
                 if (!Sql_Num_Rows($val)) {
                     $tn = $table_prefix . 'adminattr_' . $att[1];
                     Sql_Query_Params("insert into {$tn} (name) values (?)", array($value));
                     Warn($GLOBALS['I18N']->get("Value") . " {$value} " . $GLOBALS['I18N']->get("added to attribute") . " {$att['2']}");
                     $att_value = Sql_Insert_Id($tn, 'id');
                 } else {
                     $d = Sql_Fetch_Row($val);
                     $att_value = $d[0];
                 }
                 break;
             case "checkbox":
                 if ($value) {
                     $val = Sql_Fetch_Row_Query("select id from {$table_prefix}" . "adminattr_{$att['1']} where name = \"Checked\"");
                 } else {
                     $val = Sql_Fetch_Row_Query("select id from {$table_prefix}" . "adminattr_{$att['1']} where name = \"Unchecked\"");
                 }
Exemple #9
0
    $start = 0;
}
if (isset($_GET["tab"]) && $_GET["tab"] == 'unconfirmed') {
    $confirmedSelection = ' (!u.confirmed or u.blacklisted)';
    $pagingKeep = 'tab=unconfirmed';
} else {
    $pagingKeep = 'tab=confirmed';
    $confirmedSelection = ' u.confirmed and !u.blacklisted';
}
switch ($access) {
    case "owner":
        $subselect = " where owner = " . $_SESSION["logindetails"]["id"];
        if ($id) {
            $query = "select id from " . $tables['list'] . $subselect . " and id = ?";
            $rs = Sql_Query_Params($query, array($id));
            if (!Sql_Num_Rows($rs)) {
                Fatal_Error($GLOBALS['I18N']->get("You do not have enough priviliges to view this page"));
                return;
            }
        }
        break;
    case "all":
    case "view":
        $subselect = "";
        break;
    case "none":
    default:
        if ($id) {
            Fatal_Error($GLOBALS['I18N']->get("You do not have enough priviliges to view this page"));
            return;
        }
Exemple #10
0
        $cgw_req_directory = mysql_real_escape_string(htmlspecialchars($_REQUEST['bwp_info_CgwReqDirectory']));
        $app_id = mysql_real_escape_string(htmlspecialchars($_REQUEST['bwp_info__AppId']));
        $app_password = mysql_real_escape_string(htmlspecialchars($_REQUEST['bwp_info__AppPassword']));
        $cgw_server_ip = mysql_real_escape_string(htmlspecialchars($_REQUEST['bwp_info_CgwServerIp']));
        $cgw_server_port = mysql_real_escape_string(htmlspecialchars($_REQUEST['bwp_info_CgwServerPort']));
        $uri = mysql_real_escape_string(htmlspecialchars($_REQUEST['bwp_info__Uri']));
        $cgw_hostname = mysql_real_escape_string(htmlspecialchars($_REQUEST['bwp_info__CgwHostname']));
        $self_care_ip = mysql_real_escape_string(htmlspecialchars($_REQUEST['bwp_info__SelfCareIp']));
        $accept_port = mysql_real_escape_string(htmlspecialchars($_REQUEST['bwp_info_AcceptPort']));
        $nfqueue_number = mysql_real_escape_string(htmlspecialchars($_REQUEST['bwp_info__NfqueueNumber']));
        $log_level = mysql_real_escape_string(htmlspecialchars($_REQUEST['bwp_info_LogLevel']));
    }
}
$select_qry = "SELECT * FROM tbl_bwp_config";
$res_select = Sql_exec($cn, $select_qry);
if (Sql_Num_Rows($res_select) > 0) {
    $qry = "update tbl_bwp_config\n\t\tset device_id='{$device_id}', device_ip = '{$device_ip}', idle_user_time = '{$idle_user_time}', data_log_directory = '{$data_log_directory}', user_log_directory= '{$user_log_directory}', nfqueue_num = '{$nfqueue_number}', bwp_enable = '{$bwp_enable}', subnet_mask='{$subnet_mask}', cdr_interval='{$cdr_interval}',cdr_log_directory='{$cdr_log_directory}',log_level='{$log_level}',cgw_enable='{$cgw_enable}',cgw_data_limit='{$cgw_data_limit}',cgw_log_directory='{$cgw_log_directory}',cgw_req_directory='{$cgw_req_directory}',app_id='{$app_id}',cgw_ip='{$cgw_server_ip}',cgw_port='{$cgw_server_port}',cgw_uri='{$uri}',cgw_host_name='{$cgw_hostname}',self_care_ip='{$self_care_ip}',accept_port='{$accept_port}'";
} else {
    $qry = "insert into tbl_bwp_config(`device_id`,`device_ip`,`idle_user_time`,`data_log_directory`,`user_log_directory`,`nfqueue_num`,`bwp_enable`,subnet_mask,cdr_interval,cdr_log_directory,log_level,cgw_enable,cgw_data_limit,cgw_log_directory,cgw_req_directory,app_id,cgw_ip,cgw_port,cgw_uri,cgw_host_name,self_care_ip,accept_port) ";
    $qry .= " values ('{$device_id}','{$device_ip}','{$idle_user_time}','{$data_log_directory}','{$user_log_directory}','{$nfqueue_number}','{$bwp_enable}','{$subnet_mask}','{$cdr_interval}', '{$cdr_log_directory}','{$log_level}','{$cgw_enable}','{$cgw_data_limit}','{$cgw_log_directory}','{$cgw_req_directory}','{$app_id}','{$cgw_server_ip}','{$cgw_server_port}','{$uri}','{$cgw_hostname}','{$self_care_ip}','{$accept_port}')";
}
//echo $qry;
try {
    $res = Sql_exec($cn, $qry);
    if ($action != "delete") {
        if ($action == "update") {
            $options['page_name'] = "Bandwidth Profiler Configuration";
            $options['action_type'] = $action;
            $options['table'] = "tbl_bwp_config";
            $options['id_value'] = $action_id;
            setHistory($options);
Exemple #11
0
    ?>

  <p><?php 
    echo $GLOBALS["I18N"]->get("Add new") . " " . $data["name"] . ', ' . $GLOBALS["I18N"]->get("one per line");
    ?>
</p>
  <textarea name="itemlist" rows="20" cols="50"></textarea>
  <input class="submit" type="submit" name="addnew" value="<?php 
    echo $GLOBALS["I18N"]->get("Add new") . " " . $data["name"];
    ?>
" /><br />
  <hr />
<?php 
}
$rs = Sql_query("select * from {$table} order by listorder, name");
$num = Sql_Num_Rows($rs);
if ($num < 100 && $num > 25) {
    printf('<input class="submit" type="submit" name="action" value="%s" /><br /><br />', $GLOBALS["I18N"]->get("Change order"));
}
while ($row = Sql_Fetch_array($rs)) {
    printf('<div class="row-value"><span class="delete"><a href="javascript:deleteRec(\'%s\');">' . $GLOBALS['I18N']->get('delete') . '</a></span>', PageURL2("editattributes", "", "id={$id}&amp;delete=" . $row["id"]));
    if ($num < 100) {
        printf(' <input type="text" name="listorder[%d]" value="%s" size="5" class="listorder" />', $row["id"], $row["listorder"]);
    }
    printf(' %s %s </div>', $row["name"], $row["name"] == $data["default_value"] ? '(' . $GLOBALS['I18N']->get('default') . ')' : "");
}
if ($num && $num < 100) {
    printf('<br /><input class="submit" type="submit" name="action" value="%s" />', $GLOBALS["I18N"]->get("Change order"));
}
?>
</form>
<?php

session_start();
include_once "../lib/common.php";
$user_id = $_SESSION["USER_ID"];
$cn = connectDB();
$qry = "SELECT \n\t\t\t\ta.id,\n\t\t\t\tb.name, \n\t\t\t\ta.service_id, \n\t\t\t\ta.display_no, \n\t\t\t\ta.original_no, \n\t\t\t\ta.schedule_date, \n\t\t\t\ta.prompt_location,\n\t\t\t\t(SELECT NAME FROM tbl_obd_server_config WHERE id=a.id_operator_distribution) as distribution_list,\n\t\t\t\ta.status\n \t\tFROM tbl_obd_instance_list a \n\t\tINNER JOIN \n\t\ttbl_obd_server_config b \n\t\tON a.server_id=b.id \n\t\tWHERE a.user_id='{$user_id}'";
$result = Sql_exec($cn, $qry);
if (!$result) {
    echo "err+" . $qry . " in line " . __LINE__ . " of file" . __FILE__;
    exit;
}
if (Sql_Num_Rows($result) > 0) {
    $data = array();
    $i = 0;
    while ($row = Sql_fetch_array($result)) {
        $j = 0;
        $data[$i][$j++] = Sql_Result($row, "id");
        $data[$i][$j++] = Sql_Result($row, "name");
        $data[$i][$j++] = Sql_Result($row, "service_id");
        $data[$i][$j++] = Sql_Result($row, "display_no");
        $data[$i][$j++] = Sql_Result($row, "original_no");
        $data[$i][$j++] = Sql_Result($row, "schedule_date");
        $data[$i][$j++] = Sql_Result($row, "prompt_location");
        $data[$i][$j++] = Sql_Result($row, "distribution_list");
        if (Sql_Result($row, "status") == 0) {
            $data[$i][$j++] = "Open";
        } elseif (Sql_Result($row, "status") == 1) {
            $data[$i][$j++] = "Cancelled";
        } else {
            $data[$i][$j++] = "Closed";
$service_id = mysql_real_escape_string(htmlspecialchars($_REQUEST['service_id']));
$status = mysql_real_escape_string(htmlspecialchars($_REQUEST['status']));
if (isset($action) && $action != "" && $action == "download") {
    $qry = "SELECT * FROM tbl_obd_server_config WHERE id='{$server_id}'";
    $res = Sql_exec($cn, $qry);
    $dt = Sql_fetch_array($res);
    $dbtype = $dt['db_type'];
    $Server = $dt['db_server'];
    $UserID = $dt['db_user'];
    $Password = $dt['db_password'];
    $Database = $dt['db_name'];
    ClosedDBConnection($cn);
    $remoteConnection = connectDB();
    $query = "SELECT MSISDN FROM outdialque WHERE UserId='{$service_id}' AND OutDialStatus='{$status}'";
    $res = Sql_exec($remoteConnection, $query);
    if (Sql_Num_Rows($res) > 0) {
        $data = array();
        $title = array();
        while ($dt = Sql_fetch_array($res)) {
            $one_row = array("msisdn" => $dt["MSISDN"]);
            array_push($data, $one_row);
        }
        $filename = $service_id . "_" . $status . "_" . date("Y/m/d-H:i:s");
        export_csv_file($title, $data, $filename, ",");
    } else {
        echo 1;
    }
    ClosedDBConnection($remoteConnection);
} else {
    if (isset($action) && $action != "" && $action == "stop") {
        $cn = connectDB();
Exemple #14
0
<?php

header('Access-Control-Allow-Origin: *');
require_once "../lib/common.php";
$cn = connectDB();
$data = "";
$count = 0;
$client_id = $_REQUEST['client_id'];
$select_rules = "select * from bwc_ruleinfo where is_active='active' and clientId='{$client_id}'";
$rs_rules = Sql_exec($cn, $select_rules);
if ($rs_rules) {
    $count = Sql_Num_Rows($rs_rules);
}
ClosedDBConnection($cn);
echo $count;
Exemple #15
0
    }
    ob_start();
}
if (!$id) {
    print '<p>' . $GLOBALS['I18N']->get('Select Message to view') . '</p>';
    if (empty($start)) {
        print '<div class="actions">' . PageLinkButton('statsoverview&dl=true', $GLOBALS['I18N']->get('Download as CSV file')) . '</div>';
    }
    $timerange = ' and msg.entered > date_sub(current_timestamp,interval 12 month)';
    #$timerange = '';
    $query = sprintf('select msg.owner,msg.id as messageid,count(um.viewed) as views, 
    count(um.status) as total,subject,date_format(sent,"%%e %%b %%Y") as sent,
    bouncecount as bounced from %s um,%s msg where um.messageid = msg.id and um.status = "sent" %s %s %s
    group by msg.id order by msg.entered desc', $GLOBALS['tables']['usermessage'], $GLOBALS['tables']['message'], $subselect, $timerange, $ownership);
    $req = Sql_Query($query);
    $total = Sql_Num_Rows($req);
    if ($total > 10 && !$download) {
        #print Paging(PageUrl2('statsoverview'),$start,$total,10);
        $paging = simplePaging('statsoverview', $start, $total, 10);
        $query .= $limit;
        $req = Sql_Query($query);
    }
    if (!Sql_Affected_Rows()) {
        print '<p class="information">' . $GLOBALS['I18N']->get('There are currently no messages to view') . '</p>';
    }
    $ls = new WebblerListing($GLOBALS['I18N']->get('Campaigns in the last year'));
    $ls->usePanel($paging);
    while ($row = Sql_Fetch_Array($req)) {
        $element = '<!--' . $row['messageid'] . '-->' . shortenTextDisplay($row['subject'], 30);
        $fwded = Sql_Fetch_Row_Query(sprintf('select count(id) from %s where message = %d', $GLOBALS['tables']['user_message_forward'], $row['messageid']));
        $ls->addElement($element, PageURL2('statsoverview&amp;id=' . $row['messageid']));
Exemple #16
0
function precacheMessage($messageid, $forwardContent = 0)
{
    global $cached, $tables;
    $domain = getConfig('domain');
    #    $message = Sql_query("select * from {$GLOBALS["tables"]["message"]} where id = $messageid");
    #    $cached[$messageid] = array();
    #    $message = Sql_fetch_array($message);
    $message = loadMessageData($messageid);
    ## the reply to is actually not in use
    if (preg_match('/([^ ]+@[^ ]+)/', $message['replyto'], $regs)) {
        # if there is an email in the from, rewrite it as "name <email>"
        $message['replyto'] = str_replace($regs[0], '', $message['replyto']);
        $cached[$messageid]['replytoemail'] = $regs[0];
        # if the email has < and > take them out here
        $cached[$messageid]['replytoemail'] = str_replace('<', '', $cached[$messageid]['replytoemail']);
        $cached[$messageid]['replytoemail'] = str_replace('>', '', $cached[$messageid]['replytoemail']);
        # make sure there are no quotes around the name
        $cached[$messageid]['replytoname'] = str_replace('"', '', ltrim(rtrim($message['replyto'])));
    } elseif (strpos($message['replyto'], ' ')) {
        # if there is a space, we need to add the email
        $cached[$messageid]['replytoname'] = $message['replyto'];
        $cached[$messageid]['replytoemail'] = "listmaster@{$domain}";
    } else {
        if (!empty($message['replyto'])) {
            $cached[$messageid]['replytoemail'] = $message['replyto'] . "@{$domain}";
            ## makes more sense not to add the domain to the word, but the help says it does
            ## so let's keep it for now
            $cached[$messageid]['replytoname'] = $message['replyto'] . "@{$domain}";
        }
    }
    $cached[$messageid]['fromname'] = $message['fromname'];
    $cached[$messageid]['fromemail'] = $message['fromemail'];
    $cached[$messageid]['to'] = $message['tofield'];
    #0013076: different content when forwarding 'to a friend'
    $cached[$messageid]['subject'] = $forwardContent ? stripslashes($message['forwardsubject']) : $message['subject'];
    #0013076: different content when forwarding 'to a friend'
    $cached[$messageid]['content'] = $forwardContent ? stripslashes($message['forwardmessage']) : $message['message'];
    if (USE_MANUAL_TEXT_PART && !$forwardContent) {
        $cached[$messageid]['textcontent'] = $message['textmessage'];
    } else {
        $cached[$messageid]['textcontent'] = '';
    }
    #  var_dump($cached);exit;
    #0013076: different content when forwarding 'to a friend'
    $cached[$messageid]['footer'] = $forwardContent ? stripslashes($message['forwardfooter']) : $message['footer'];
    if (strip_tags($cached[$messageid]['footer']) != $cached[$messageid]['footer']) {
        $cached[$messageid]['textfooter'] = HTML2Text($cached[$messageid]['footer']);
        $cached[$messageid]['htmlfooter'] = $cached[$messageid]['footer'];
    } else {
        $cached[$messageid]['textfooter'] = $cached[$messageid]['footer'];
        $cached[$messageid]['htmlfooter'] = parseText($cached[$messageid]['footer']);
    }
    $cached[$messageid]['htmlformatted'] = strip_tags($cached[$messageid]['content']) != $cached[$messageid]['content'];
    $cached[$messageid]['sendformat'] = $message['sendformat'];
    if ($message['template']) {
        $req = Sql_Fetch_Row_Query("select template from {$GLOBALS['tables']['template']} where id = {$message['template']}");
        $cached[$messageid]['template'] = stripslashes($req[0]);
        $cached[$messageid]['templateid'] = $message['template'];
        #   dbg("TEMPLATE: ".$req[0]);
    } else {
        $cached[$messageid]['template'] = '';
        $cached[$messageid]['templateid'] = 0;
    }
    ## @@ put this here, so it can become editable per email sent out at a later stage
    $cached[$messageid]['html_charset'] = 'UTF-8';
    #getConfig("html_charset");
    ## @@ need to check on validity of charset
    if (!$cached[$messageid]['html_charset']) {
        $cached[$messageid]['html_charset'] = 'UTF-8';
        #'iso-8859-1';
    }
    $cached[$messageid]['text_charset'] = 'UTF-8';
    #getConfig("text_charset");
    if (!$cached[$messageid]['text_charset']) {
        $cached[$messageid]['text_charset'] = 'UTF-8';
        #'iso-8859-1';
    }
    ## if we are sending a URL that contains user attributes, we cannot pre-parse the message here
    ## but that has quite some impact on speed. So check if that's the case and apply
    $cached[$messageid]['userspecific_url'] = preg_match('/\\[.+\\]/', $message['sendurl']);
    if (!$cached[$messageid]['userspecific_url']) {
        ## Fetch external content here, because URL does not contain placeholders
        if ($GLOBALS['can_fetchUrl'] && preg_match("/\\[URL:([^\\s]+)\\]/i", $cached[$messageid]['content'], $regs)) {
            $remote_content = fetchUrl($regs[1], array());
            #  $remote_content = fetchUrl($message['sendurl'],array());
            # @@ don't use this
            #      $remote_content = includeStyles($remote_content);
            if ($remote_content) {
                $cached[$messageid]['content'] = str_replace($regs[0], $remote_content, $cached[$messageid]['content']);
                #  $cached[$messageid]['content'] = $remote_content;
                $cached[$messageid]['htmlformatted'] = strip_tags($remote_content) != $remote_content;
                ## 17086 - disregard any template settings when we have a valid remote URL
                $cached[$messageid]['template'] = null;
                $cached[$messageid]['templateid'] = null;
            } else {
                #print Error(s('unable to fetch web page for sending'));
                logEvent('Error fetching URL: ' . $message['sendurl'] . ' cannot proceed');
                return false;
            }
        }
        if (VERBOSE && !empty($GLOBALS['getspeedstats'])) {
            output('fetch URL end');
        }
        /*
        print $message['sendurl'];
        print $remote_content;exit;
        */
    }
    // end if not userspecific url
    if ($cached[$messageid]['htmlformatted']) {
        #   $cached[$messageid]["content"] = compressContent($cached[$messageid]["content"]);
    }
    $cached[$messageid]['google_track'] = $message['google_track'];
    /*
        else {
    print $message['sendurl'];
    exit;
    }
    */
    foreach ($GLOBALS['plugins'] as $plugin) {
        $plugin->processPrecachedCampaign($messageid, $cached[$messageid]);
    }
    if (VERBOSE && !empty($GLOBALS['getspeedstats'])) {
        output('parse config start');
    }
    /*
     * this is not a good idea, as it'll replace eg "unsubscribeurl" with a general one instead of personalised
     *   if (is_array($GLOBALS["default_config"])) {
      foreach($GLOBALS["default_config"] as $key => $val) {
        if (is_array($val)) {
          $cached[$messageid]['content'] = str_ireplace("[$key]",getConfig($key),$cached[$messageid]['content']);
          $cached[$messageid]["textcontent"] = str_ireplace("[$key]",getConfig($key),$cached[$messageid]["textcontent"]);
          $cached[$messageid]["textfooter"] = str_ireplace("[$key]",getConfig($key),$cached[$messageid]['textfooter']);
          $cached[$messageid]["htmlfooter"] = str_ireplace("[$key]",getConfig($key),$cached[$messageid]['htmlfooter']);
        }
      }
    }
    */
    if (VERBOSE && !empty($GLOBALS['getspeedstats'])) {
        output('parse config end');
    }
    ## ##17233 not that many fields are actually useful, so don't blatantly use all
    #  foreach($message as $key => $val) {
    foreach (array('subject', 'id', 'fromname', 'fromemail') as $key) {
        $val = $message[$key];
        if (!is_array($val)) {
            $cached[$messageid]['content'] = str_ireplace("[{$key}]", $val, $cached[$messageid]['content']);
            $cached[$messageid]['textcontent'] = str_ireplace("[{$key}]", $val, $cached[$messageid]['textcontent']);
            $cached[$messageid]['textfooter'] = str_ireplace("[{$key}]", $val, $cached[$messageid]['textfooter']);
            $cached[$messageid]['htmlfooter'] = str_ireplace("[{$key}]", $val, $cached[$messageid]['htmlfooter']);
        }
    }
    /*
     *  cache message owner and list owner attribute values
     */
    $cached[$messageid]['adminattributes'] = array();
    $result = Sql_Query("SELECT a.name, aa.value\n        FROM {$tables['adminattribute']} a\n        JOIN {$tables['admin_attribute']} aa ON a.id = aa.adminattributeid\n        JOIN {$tables['message']} m ON aa.adminid = m.owner\n        WHERE m.id = {$messageid}");
    if ($result !== false) {
        while ($att = Sql_Fetch_Array($result)) {
            $cached[$messageid]['adminattributes']['OWNER.' . $att['name']] = $att['value'];
        }
    }
    $result = Sql_Query("SELECT DISTINCT l.owner\n        FROM {$tables['list']} AS l\n        JOIN  {$tables['listmessage']} AS lm ON lm.listid = l.id\n        WHERE lm.messageid = {$messageid}");
    if ($result !== false && Sql_Num_Rows($result) == 1) {
        $row = Sql_Fetch_Assoc($result);
        $listOwner = $row['owner'];
        $att_req = Sql_Query("SELECT a.name, aa.value\n            FROM {$tables['adminattribute']} a\n            JOIN {$tables['admin_attribute']} aa ON a.id = aa.adminattributeid\n            WHERE aa.adminid = {$listOwner}");
        while ($att = Sql_Fetch_Array($att_req)) {
            $cached[$messageid]['adminattributes']['LISTOWNER.' . $att['name']] = $att['value'];
        }
    }
    $baseurl = $GLOBALS['website'];
    if (defined('UPLOADIMAGES_DIR') && UPLOADIMAGES_DIR) {
        ## escape subdirectories, otherwise this renders empty
        $dir = str_replace('/', '\\/', UPLOADIMAGES_DIR);
        $cached[$messageid]['content'] = preg_replace('/<img(.*)src="\\/' . $dir . '(.*)>/iU', '<img\\1src="' . $GLOBALS['public_scheme'] . '://' . $baseurl . '/' . UPLOADIMAGES_DIR . '\\2>', $cached[$messageid]['content']);
    }
    foreach (array('content', 'template', 'htmlfooter') as $element) {
        $cached[$messageid][$element] = parseLogoPlaceholders($cached[$messageid][$element]);
    }
    return 1;
}
Exemple #17
0
        $category = trim($category);
        if ($category == '') {
            $category = $GLOBALS['I18N']->get('Uncategorised');
        }
        $tabs->addTab($category, $baseurl . '&amp;tab=' . urlencode($category));
    }
    if ($current != '') {
        $tabs->setCurrent($current);
    } else {
        $tabs->setCurrent(s('Uncategorised'));
    }
    print $tabs->display();
}
$countquery = ' select *' . ' from ' . $tables['list'] . $subselect;
$countresult = Sql_query($countquery);
$total = Sql_Num_Rows($countresult);
if ($total == 0 && sizeof($aListCategories) && $current == '' && empty($_GET['tab'])) {
    ## reload to first category, if none found by default (ie all lists are categorised)
    if (!empty($aListCategories[0])) {
        Redirect('list&tab=' . $aListCategories[0]);
    }
}
print '<p class="total">' . $total . ' ' . $GLOBALS['I18N']->get('Lists') . '</p>';
$limit = '';
$query = ' select *' . ' from ' . $tables['list'] . $subselect . ' order by listorder ' . $limit;
$result = Sql_query($query);
$numlists = Sql_Affected_Rows($result);
$ls = new WebblerListing(s('Lists'));
if ($numlists > 15) {
    Info(s('You seem to have quite a lot of lists, do you want to organise them in categories? ') . ' ' . PageLinkButton('catlists', $GLOBALS['I18N']->get('Great idea!')));
    /* @@TODO add paging when there are loads of lists, because otherwise the page is very slow
Exemple #18
0
function PageData($id)
{
    global $tables;
    $req = Sql_Query(sprintf('select * from %s where id = %d', $tables["subscribepage_data"], $id));
    if (!Sql_Num_Rows($req)) {
        $data = array();
        $data["header"] = getConfig("pageheader");
        $data["footer"] = getConfig("pagefooter");
        $data["button"] = 'Subscribe';
        $data['attributes'] = '';
        $req = Sql_Query(sprintf('select * from %s order by listorder', $GLOBALS['tables']['attribute']));
        while ($row = Sql_Fetch_Array($req)) {
            $data['attributes'] .= $row['id'] . '+';
            $data[sprintf('attribute%03d', $row['id'])] = '';
            foreach (array('id', 'default_value', 'listorder', 'required') as $key) {
                $data[sprintf('attribute%03d', $row['id'])] .= $row[$key] . '###';
            }
        }
        $data['attributes'] = substr($data['attributes'], 0, -1);
        $data['htmlchoice'] = 'checkforhtml';
        $lists = array();
        $req = Sql_Query(sprintf('select * from %s where active order by listorder', $GLOBALS['tables']['list']));
        while ($row = Sql_Fetch_Array($req)) {
            array_push($lists, $row['id']);
        }
        $data['lists'] = join(',', $lists);
        $data['intro'] = $GLOBALS['strSubscribeInfo'];
        $data['emaildoubleentry'] = 'yes';
        $data['thankyoupage'] = '';
        foreach ($data as $key => $val) {
            $data[$key] = str_ireplace('[organisation_name]', $GLOBALS['organisation_name'], $val);
        }
        return $data;
    }
    while ($row = Sql_Fetch_Array($req)) {
        $data[$row["name"]] = preg_replace('/<\\?=VERSION\\?>/i', VERSION, $row["data"]);
        $data[$row["name"]] = str_ireplace('[organisation_name]', $GLOBALS['organisation_name'], $row["data"]);
    }
    if (!isset($data['lists'])) {
        $data['lists'] = '';
    }
    if (!isset($data['emaildoubleentry'])) {
        $data['emaildoubleentry'] = '';
    }
    if (!isset($data['rssdefault'])) {
        $data['rssdefault'] = '';
    }
    if (!isset($data['rssintro'])) {
        $data['rssintro'] = '';
    }
    if (!isset($data['rss'])) {
        $data['rss'] = '';
    }
    if (!isset($data['lists'])) {
        $data['lists'] = '';
    }
    return $data;
}
Exemple #19
0
function getPageLock($force = 0)
{
    global $tables;
    $thispage = $GLOBALS["page"];
    if ($thispage == 'pageaction') {
        $thispage = $_GET['action'];
    }
    #  cl_output('getting pagelock '.$thispage);
    #  ob_end_flush();
    if ($GLOBALS["commandline"] && $thispage == 'processqueue') {
        if (is_object($GLOBALS['MC'])) {
            ## multi-send requires a valid memcached setup
            $max = MAX_SENDPROCESSES;
        } else {
            $max = 1;
        }
    } else {
        $max = 1;
    }
    ## allow killing other processes
    if ($force) {
        Sql_Query_Params("delete from " . $tables['sendprocess'] . " where page = ?", array($thispage));
    }
    $query = ' select current_timestamp - modified as age, id' . ' from ' . $tables['sendprocess'] . ' where page = ?' . ' and alive > 0' . ' order by age desc';
    $running_req = Sql_Query_Params($query, array($thispage));
    $running_res = Sql_Fetch_Assoc($running_req);
    $count = Sql_Num_Rows($running_req);
    if (VERBOSE) {
        cl_output($count . ' out of ' . $max . ' active processes');
    }
    $waited = 0;
    # while ($running_res['age'] && $count >= $max) { # a process is already running
    while ($count >= $max) {
        # don't check age, as it may be 0
        #   cl_output('running process: '.$running_res['age'].' '.$max);
        if ($running_res['age'] > 600) {
            # some sql queries can take quite a while
            #cl_output($running_res['id'].' is old '.$running_res['age']);
            # process has been inactive for too long, kill it
            Sql_query("update {$tables["sendprocess"]} set alive = 0 where id = " . $running_res['id']);
        } elseif ((int) $count >= (int) $max) {
            #   cl_output (sprintf($GLOBALS['I18N']->get('A process for this page is already running and it was still alive %s seconds ago'),$running_res['age']));
            output(sprintf($GLOBALS['I18N']->get('A process for this page is already running and it was still alive %s seconds ago'), $running_res['age']), 0);
            sleep(1);
            # to log the messages in the correct order
            if ($GLOBALS["commandline"]) {
                cl_output($GLOBALS['I18N']->get('Running commandline, quitting. We\'ll find out what to do in the next run.'));
                exit;
            }
            output($GLOBALS['I18N']->get('Sleeping for 20 seconds, aborting will quit'), 0);
            flush();
            $abort = ignore_user_abort(0);
            sleep(20);
        }
        $waited++;
        if ($waited > 10) {
            # we have waited 10 cycles, abort and quit script
            output($GLOBALS['I18N']->get('We have been waiting too long, I guess the other process is still going ok'), 0);
            return false;
        }
        $query = ' select current_timestamp - modified as age, id' . ' from ' . $tables['sendprocess'] . ' where page = ?' . ' and alive > 0' . ' order by age desc';
        $running_req = Sql_Query_Params($query, array($thispage));
        $running_res = Sql_Fetch_Assoc($running_req);
        $count = Sql_Num_Rows($running_req);
    }
    $query = ' insert into ' . $tables['sendprocess'] . '    (started, page, alive, ipaddress)' . ' values' . '    (current_timestamp, ?, 1, ?)';
    if (!empty($GLOBALS['commandline'])) {
        $processIdentifier = SENDPROCESS_SERVERNAME . ':' . getmypid();
    } else {
        $processIdentifier = $_SERVER['REMOTE_ADDR'];
    }
    $res = Sql_Query_Params($query, array($thispage, $processIdentifier));
    $send_process_id = Sql_Insert_Id($tables['sendprocess'], 'id');
    $abort = ignore_user_abort(1);
    #  cl_output('Got pagelock '.$send_process_id );
    return $send_process_id;
}
Exemple #20
0
}
$tabs = new WebblerTabs();
$tabs->addTab($GLOBALS['I18N']->get('active'), PageUrl2('bouncerules&amp;type=active'));
$tabs->addTab($GLOBALS['I18N']->get('candidate'), PageUrl2('bouncerules&amp;type=candidate'));
if ($type == 'candidate') {
    $tabs->setCurrent($GLOBALS['I18N']->get('candidate'));
} else {
    $tabs->setCurrent($GLOBALS['I18N']->get('active'));
}
print "<p><div class='minitabs'>\n";
print $tabs->display();
print "</div></p>\n";
$some = 1;
$req = Sql_Query(sprintf('select * from %s where status = "%s" order by listorder,regex', $GLOBALS['tables']['bounceregex'], $type));
$ls = new WebblerListing($GLOBALS['I18N']->get('Bounce Regular Expressions'));
if (!Sql_Num_Rows($req)) {
    print $GLOBALS['I18N']->get('No Rules found');
    $some = 0;
} else {
    print formStart('class="bouncerulesListing"');
}
while ($row = Sql_Fetch_Array($req)) {
    $element = $GLOBALS['I18N']->get('rule') . ' ' . $row['id'];
    $ls->addElement($element, PageUrl2('bouncerule&amp;id=' . $row['id']));
    if ($type == 'candidate') {
        # check if it matches an active rule
        $activerule = matchedBounceRule($row['regex'], 1);
        if ($activerule) {
            $ls->addColumn($element, $GLOBALS['I18N']->get('match'), PageLink2('bouncerule&amp;id=' . $activerule, $GLOBALS['I18N']->get('match')));
        }
    }
Exemple #21
0
function getUserConfig($item, $userid = 0)
{
    global $default_config, $tables, $domain, $website;
    $hasconf = Sql_Table_Exists($tables["config"]);
    $value = '';
    if ($hasconf) {
        $query = 'select value,editable from ' . $tables['config'] . ' where item = ?';
        $req = Sql_Query_Params($query, array($item));
        if (!Sql_Num_Rows($req)) {
            if (array_key_exists($item, $default_config)) {
                $value = $default_config[$item]['value'];
            }
        } else {
            $row = Sql_fetch_Row($req);
            $value = $row[0];
            if ($row[1] == 0) {
                $GLOBALS['noteditableconfig'][] = $item;
            }
        }
    }
    # if this is a subpage item, and no value was found get the global one
    if (!$value && strpos($item, ":") !== false) {
        list($a, $b) = explode(":", $item);
        $value = getUserConfig($a, $userid);
    }
    if ($userid) {
        $query = 'select uniqid, email from ' . $tables['user'] . ' where id = ?';
        $rs = Sql_Query_Params($query, array($userid));
        $user_req = Sql_Fetch_Row($rs);
        $uniqid = $user_req[0];
        $email = $user_req[1];
        # parse for placeholders
        # do some backwards compatibility:
        # hmm, reverted back to old system
        $url = getConfig("unsubscribeurl");
        $sep = strpos($url, '?') !== false ? '&' : '?';
        $value = str_ireplace('[UNSUBSCRIBEURL]', $url . $sep . 'uid=' . $uniqid, $value);
        $url = getConfig("confirmationurl");
        $sep = strpos($url, '?') !== false ? '&' : '?';
        $value = str_ireplace('[CONFIRMATIONURL]', $url . $sep . 'uid=' . $uniqid, $value);
        $url = getConfig("preferencesurl");
        $sep = strpos($url, '?') !== false ? '&' : '?';
        $value = str_ireplace('[PREFERENCESURL]', $url . $sep . 'uid=' . $uniqid, $value);
        $value = str_ireplace('[EMAIL]', $email, $value);
        $value = parsePlaceHolders($value, getUserAttributeValues($email));
    }
    $value = str_ireplace('[SUBSCRIBEURL]', getConfig("subscribeurl"), $value);
    $value = preg_replace('/\\[DOMAIN\\]/i', $domain, $value);
    #@ID Should be done only in one place. Combine getConfig and this one?
    $value = preg_replace('/\\[WEBSITE\\]/i', $website, $value);
    if ($value == "0") {
        $value = "false";
    } elseif ($value == "1") {
        $value = "true";
    }
    return $value;
}
 function image_exists($templateid, $filename)
 {
     if (basename($filename) == 'powerphplist.png') {
         $templateid = 0;
     }
     $query = ' select *' . ' from ' . $GLOBALS['tables']['templateimage'] . ' where template = ?' . '   and (filename = ? or filename = ?)';
     $rs = Sql_Query_Params($query, array($templateid, $filename, basename($filename)));
     return Sql_Num_Rows($rs);
 }
Exemple #23
0
 $status = Sql_Fetch_Array_query("select id,status from {$tables['message']} where id = {$messageid}");
 if (!$status['id']) {
     ProcessError($GLOBALS['I18N']->get('Message I was working on has disappeared'));
 } elseif ($status['status'] != 'inprocess') {
     $script_stage = 6;
     ProcessError($GLOBALS['I18N']->get('Sending of this message has been suspended'));
 }
 flush();
 ##
 #Sql_Query(sprintf('delete from %s where userid = %d and messageid = %d and status = "active"',$tables['usermessage'],$userid,$messageid));
 # check whether the user has already received the message
 if (!empty($getspeedstats)) {
     processQueueOutput('verify message can go out to ' . $userid);
 }
 $um = Sql_Query(sprintf('select entered from %s where userid = %d and messageid = %d and status != "todo"', $tables['usermessage'], $userid, $messageid));
 if (!Sql_Num_Rows($um)) {
     ## mark this message that we're working on it, so that no other process will take it
     ## between two lines ago and here, should hopefully be quick enough
     $userlock = Sql_Query(sprintf('replace into %s (entered,userid,messageid,status) values(now(),%d,%d,"active")', $tables['usermessage'], $userid, $messageid));
     if ($script_stage < 4) {
         $script_stage = 4;
         # we know a subscriber to send to
     }
     $someusers = 1;
     $users = Sql_query("select id,email,uniqid,htmlemail,confirmed,blacklisted,disabled from {$tables['user']} where id = {$userid}");
     # pick the first one (rather historical from before email was unique)
     $user = Sql_fetch_Assoc($users);
     if ($user['confirmed'] && is_email($user['email'])) {
         $userid = $user['id'];
         # id of the subscriber
         $useremail = $user['email'];
Exemple #24
0
<?php

require_once dirname(__FILE__) . '/accesscheck.php';
$content = '';
if (isset($_POST['usercheck'])) {
    $lsexist = new WebblerListing(s('Existing subscribers'));
    $lsnonexist = new WebblerListing(s('Non existing subscribers '));
    $users = explode("\n", $_POST['usercheck']);
    foreach ($users as $user) {
        $user = trim($user);
        if (isset($_POST['check']) && $_POST['check'] == 'foreignkey') {
            $exists = Sql_Query(sprintf('select id,foreignkey,email from %s where foreignkey = "%s"', $tables['user'], sql_escape($user)));
        } else {
            $exists = Sql_Query(sprintf('select id,foreignkey,email from %s where email = "%s"', $tables['user'], sql_escape($user)));
        }
        if (Sql_Num_Rows($exists)) {
            $id = Sql_Fetch_Array($exists);
            $element = strip_tags($user);
            $lsexist->addElement($element, PageUrl2('user&amp;id=' . $id['id']));
            $lsexist->addColumn($element, $GLOBALS['I18N']->get('email'), $id['email']);
            $lsexist->addColumn($element, $GLOBALS['I18N']->get('key'), $id['foreignkey']);
        } else {
            $lsnonexist->addElement(strip_tags($user));
        }
    }
    print $lsexist->display();
    print $lsnonexist->display();
} else {
    $_POST['usercheck'] = '';
}
/*
Exemple #25
0
function clickTrackLinkId($messageid, $userid, $url, $link)
{
    global $cached;
    if (!isset($cached['linktrack']) || !is_array($cached['linktrack'])) {
        $cached['linktrack'] = array();
    }
    if (!isset($cached['linktracksent']) || !is_array($cached['linktracksent'])) {
        $cached['linktracksent'] = array();
    }
    if (!isset($cached['linktrack'][$link])) {
        $query = ' select id' . ' from ' . $GLOBALS['tables']['linktrack_forward'] . ' where url = ?';
        $rs = Sql_Query_Params($query, array($url));
        $exists = Sql_Fetch_Row($rs);
        if (!$exists[0]) {
            $personalise = preg_match('/uid=/', $link);
            $query = ' insert into ' . $GLOBALS['tables']['linktrack_forward'] . '    (url, personalise)' . ' values' . '    (?, ?)';
            Sql_Query_Params($query, array($url, $personalise));
            $fwdid = Sql_Insert_Id($GLOBALS['tables']['linktrack_forward'], 'id');
        } else {
            $fwdid = $exists[0];
        }
        $cached['linktrack'][$link] = $fwdid;
    } else {
        $fwdid = $cached['linktrack'][$link];
    }
    if (!isset($cached['linktracksent'][$messageid]) || !is_array($cached['linktracksent'][$messageid])) {
        $cached['linktracksent'][$messageid] = array();
    }
    if (!isset($cached['linktracksent'][$messageid][$fwdid])) {
        $query = ' select total' . ' from ' . $GLOBALS['tables']['linktrack_ml'] . ' where messageid = ?' . '   and forwardid = ?';
        $rs = Sql_Query_Params($query, array($messageid, $fwdid));
        if (!Sql_Num_Rows($rs)) {
            $total = 1;
            ## first time for this link/message
            # BCD: Isn't this just an insert?
            Sql_Replace($GLOBALS['tables']['linktrack_ml'], array('total' => $total, 'messageid' => $messageid, 'forwardid' => $fwdid), array('messageid', 'forwardid'));
        } else {
            $tot = Sql_Fetch_Row($rs);
            $total = $tot[0] + 1;
            Sql_Query(sprintf('update %s set total = %d where messageid = %d and forwardid = %d', $GLOBALS['tables']['linktrack_ml'], $total, $messageid, $fwdid));
        }
        $cached['linktracksent'][$messageid][$fwdid] = $total;
    } else {
        $cached['linktracksent'][$messageid][$fwdid]++;
        ## write every so often, to make sure it's saved when interrupted
        if ($cached['linktracksent'][$messageid][$fwdid] % 100 == 0) {
            Sql_Query(sprintf('update %s set total = %d where messageid = %d and forwardid = %d', $GLOBALS['tables']['linktrack_ml'], $cached['linktracksent'][$messageid][$fwdid], $messageid, $fwdid));
        }
    }
    /*  $req = Sql_Query(sprintf('insert ignore into %s (messageid,userid,forwardid)
        values(%d,%d,"%s","%s")',$GLOBALS['tables']['linktrack'],$messageid,$userdata['id'],$url,addslashes($link)));
      $req = Sql_Fetch_Row_Query(sprintf('select linkid from %s where messageid = %s and userid = %d and forwardid = %d
      ',$GLOBALS['tables']['linktrack'],$messageid,$userid,$fwdid));*/
    return $fwdid;
}
                Sql_Query("drop table {$table_prefix}" . "adminattr_{$row['0']}");
            }
            Sql_Query("delete from {$tables['adminattribute']} where id = {$id}");
            # delete all admin attributes as well
            Sql_Query("delete from {$tables['admin_attribute']} where adminattributeid = {$id}");
        }
    }
}
?>



<?php 
print formStart();
$res = Sql_Query("select * from {$tables['adminattribute']} order by listorder");
if (Sql_Num_Rows($res)) {
    print $GLOBALS['I18N']->get('ExistingAttr');
} else {
    print $GLOBALS['I18N']->get('NoAttrYet');
}
while ($row = Sql_Fetch_array($res)) {
    ?>
  <table border=1>
  <tr><td colspan=2><?php 
    echo $GLOBALS['I18N']->get('Attribute') . $row["id"];
    ?>
</td><td colspan=2><?php 
    echo $GLOBALS['I18N']->get('Delete');
    ?>
 <input type="checkbox" name="delete[<?php 
    echo $row["id"];
Exemple #27
0
 } else {
     $already_used = "";
 }
 $att_drop = '';
 $attreq = Sql_Query(sprintf('select * from %s where type in ("select","radio","date","checkboxgroup","checkbox") %s', $tables["attribute"], $already_used));
 while ($att = Sql_Fetch_array($attreq)) {
     $att_drop .= sprintf('<option value="%d" %s>%s</option>', $att["id"], "", $att["name"]);
     $num = Sql_Affected_Rows();
     switch ($att["type"]) {
         case "select":
         case "radio":
         case "checkboxgroup":
             $att_js .= sprintf('value_divs[%d] = "criteria_values_select";' . "\n", $att["id"]);
             $att_js .= sprintf('value_default[%d] = "";' . "\n", $att["id"]);
             $value_req = Sql_Query(sprintf('select * from %s order by listorder,name', $GLOBALS["table_prefix"] . "listattr_" . $att["tablename"]));
             $num = Sql_Num_Rows($value_req);
             $att_js .= sprintf('values[%d] = new Array(%d);' . "\n", $att["id"], $num + 1);
             #$att_js .= sprintf('values[%d][0] =  new Option("[choose]","0",false,true);'."\n",$att["id"]);
             $c = 0;
             while ($value = Sql_Fetch_Array($value_req)) {
                 $att_js .= sprintf('values[%d][%d] =  new Option("%s","%d",false,false);' . "\n", $att["id"], $c, $value["name"], $value["id"]);
                 $c++;
             }
             $att_js .= sprintf('operators[%d] = new Array(2);' . "\n", $att["id"]);
             $att_js .= sprintf('operators[%d][0] =  new Option("%s","is",false,true);' . "\n", $att["id"], $GLOBALS['I18N']->get('is'));
             $att_js .= sprintf('operators[%d][1] =  new Option("%s","isnot",false,true);' . "\n", $att["id"], $GLOBALS['I18N']->get('isnot'));
             break;
         case "checkbox":
             $att_js .= sprintf('value_divs[%d] = "criteria_values_select";' . "\n", $att["id"]);
             $att_js .= sprintf('value_default[%d] = "";' . "\n", $att["id"]);
             $att_js .= sprintf('values[%d] = new Array(%d);' . "\n", $att["id"], 2);
Exemple #28
0
function file_writer_firewall_rule($cn)
{
    global $dir_firewall_test;
    global $dir_firewall_production;
    global $dir_bwp_test;
    global $dir_bwp_production;
    $is_error = 0;
    log_generator("Filewall Rule File Writing Start", __FILE__, __FUNCTION__, __LINE__, NULL);
    $firewall_test = $dir_firewall_test;
    $firewall_production = $dir_firewall_production;
    $bwp_test = $dir_bwp_test;
    $bwp_production = $dir_bwp_production;
    $select_qry = "select * from tbl_firewall_rule where is_active='active'";
    $rs = Sql_exec($cn, $select_qry);
    $data_string = "";
    while ($dt = Sql_fetch_array($rs)) {
        $select_group_type = "select * from tbl_firewall_group where group_name='" . $dt['destination_address'] . "'";
        $rs_group_type = Sql_exec($cn, $select_group_type);
        $dest = '';
        $host = '';
        if (Sql_Num_Rows($rs_group_type) > 0) {
            while ($dt_group_type = Sql_fetch_array($rs_group_type)) {
                if ($dt_group_type == "ip") {
                    $dest = $dt['destination_address'];
                    $host = 'all';
                } else {
                    $dest = 'all';
                    $host = $dt['destination_address'];
                }
            }
        } else {
            $dest_array = explode('.', $dt['destination_address']);
            if (sizeof($dest_array) > 2) {
                $dest = $dt['destination_address'];
                $host = 'all';
            } else {
                $dest = 'all';
                $host = $dt['destination_address'];
            }
        }
        $data_string .= $dt['source_address'] . "|" . $dest . "|" . $dt['port'] . "|" . $dt['protocol'] . "|" . $host . "|" . $dt['start_time'] . "|" . $dt['end_time'] . "|" . $dt['action'] . "\n";
    }
    $file_name = $firewall_test . "/firewallRules/rules.txt";
    file_put_contents($file_name, $data_string);
    $file_name = $firewall_production . "/firewallRules/rules.txt";
    file_put_contents($file_name, $data_string);
    $file_name = $bwp_test . "/firewallRules/rules.txt";
    file_put_contents($file_name, $data_string);
    $file_name = $bwp_production . "/firewallRules/rules.txt";
    file_put_contents($file_name, $data_string);
    log_generator("Filewall Rule File Successfully Written", __FILE__, __FUNCTION__, __LINE__, NULL);
    return $is_error;
}