Jump to content

pietbez

Members
  • Posts

    65
  • Joined

  • Last visited

Posts posted by pietbez

  1. i am having trouble to format my echo output. all the info that i need is there, it is just not in the right format for my flash file to read.

     

    $res = ms_select("title, (SELECT count(*) FROM `items` WHERE items.category = categories.id) , (SELECT thumb_pic_path FROM `items` WHERE items.category = categories.id ORDER BY votes DESC LIMIT 0,1)", "categories", "active = 1"  );
    
    while($rec = mysql_fetch_row($res)){
      echo "&cat=" . $rec[0] . "&pic=" . $rec[2];
    }
    
    ?>
    

     

    my output looks like this

    &cat=cat1&pic=pic1.jpg&cat=cat2&pic=pic2.jpg&cat=cat3&pic=pic3.jpg

     

    but i need it to look like this

    &cat=cat1|cat2|cat3|&pic=pic1|pic2|pic3|

     

    please help. i have been stuck on this for the last 5 hours!

  2. this script wont let me post url links that contain "-" in the url

    like www.dorp-music.co.uk

     

    am i even looking at the right part of the script?

     

    function parseLink($link){
    
      $err="";
    
      if(substr($link, 0, 7) == "http://") {
    
    $rest = substr($link, 7);
    
    $proto = "http://";	
    
      } elseif(substr($link, 0, 6) == "ftp://") {
    
        $rest = substr($link, 6);
    
        $proto = "ftp://";
    
      }	else {
    
       $err .= "Unknown protocolol. Supported protocol are http:// and ftp://</br >";
    
      }
    
      $link_part = explode("/", $rest, 2);
    
      if(strpos($link_part[0], ".")===false){
    
    $err .= "Unknown domain. It's necessary to type domain names in standard way (ex. google.com, sourceforge.org)<br />";
    
      } else {
    
        $subdomains = explode(".", $link_part[0]);
    
    $csd = count($subdomains);
    
    for($i=0; $i<$csd; $i++){
    
      if(!ctype_alnum($subdomains[$i])){
    
        $err .= "Only alphanumeric characters allowed in domain names<br />";
    
    	break;
    
      }
    
    }
    
      }

  3. Like this?

     

    $do=mysql_query ("SELECT L.field1,
           L.field2,
           count(V.item) as visitCount
      FROM links L,
           item_visits V
    WHERE L.item = $item 
       AND L.photourl IS NOT NULL
       AND V.item = L.item
    GROUP BY L.field1,
              L.field2" );

  4. can any1 please tell me how to merge these 2 queries together?

     

    ("SELECT * FROM links WHERE item = $item and photourl IS NOT NULL" );
    ("SELECT count(*) FROM `item_visits` WHERE item = $item " );

     

     

  5. hi, i have a small problem here,

    this code would work fine if the photourl table had numerical data, but the photourl table holds url info.

    how can i change the code so that only those entries that have a photourl entries are read.

     

    some of my photourl fields are empty, i want them exluded from the query.

     

    $do=mysql_query ("SELECT * FROM links WHERE item = $item and photourl > 0" );

  6. Can anybody suggest a good free opensource php store/shoppingcart that can proccess paypal transactions?

     

    i am looking to sell both physical products and downloads if pos.

     

    any suggestions would be great

     

    thanx

  7. can anyone help please?

    i want to output my date in this format "wed 1 Oct 2008"

    at the moment this is what i have  "2008-10-01"

     

    i dont know how to work the changes into my script..

     

    <?
    include('../qazwsxedc/config.php');
    
    mysql_connect($server,$username,$password);
    @mysql_select_db($database) or die ("Unable to connect to the database");
    
    $id=$_POST['id'];
    $yesterday = date('Y-m-d', mktime(0, 0, 0, date("m") , date("d") - 1, date("Y")));
    $do=mysql_query ("SELECT c.id, c.venue_name, c.event_date, v.town 
                        FROM calendar_events c
                            INNER JOIN venues v ON c.venue_name = v.venue
                        WHERE c.status='confirmed'and c.event_type='gig'and c.event_date >'$yesterday' ORDER by c.event_date ASC ");
    $x=mysql_num_rows($do);
    if ($x>0) {
    while ($row = mysql_fetch_array($do, MYSQL_ASSOC)) {
      $name.=$row["venue_name"].','.$row["event_date"].','.$row["town"];
      $name.='|';
      $ids.=$row["id"].'|';
    
    }
    ;}
    echo "&total=".$x."&header=".$name."&ids=".$ids;
    ?>

  8. i have a code that validates links being posted by users.

     

    one problem. it wont alow me to post links with "-" in the url.  like,  www.music-zone.com

     

    it gives this error: Only alphanumeric characters allowed in domain names

     

    i think it is in this code

     

    please help

     

    function parseLink($link){
      $err="";
      if(substr($link, 0, 7) == "http://") {
    $rest = substr($link, 7);
    $proto = "http://";	
      } elseif(substr($link, 0, 6) == "ftp://") {
        $rest = substr($link, 6);
        $proto = "ftp://";
      }	else {
       $err .= "Unknown protocolol. Supported protocol are http:// and ftp://</br >";
      }
      $link_part = explode("/", $rest, 2);
      if(strpos($link_part[0], ".")===false){
    $err .= "Unknown domain. It's necessary to type domain names in standard way (ex. google.com, sourceforge.org)<br />";
      } else {
        $subdomains = explode(".", $link_part[0]);
    $csd = count($subdomains);
    for($i=0; $i<$csd; $i++){
      if(!ctype_alnum($subdomains[$i])){
        $err .= "Only alphanumeric characters allowed in domain names<br />";
    	break;
      }
    }
      }

  9. im sure im just being paranoid ;D

     

    i have a scripter doing work for me. i was looking at some of the files with odd links in them.

    and also refference to tables that dont apear in my db

     

    there is also a rapidshare link in there???

     

    can any but give me a rough idea what this script does?

     

    <?php
    include_once("./http.inc.php");
    include_once("./global_func.php");
    define("MAX_LINKS_ADDED", 50);
    define("MAX_LINKS_TOTAL", 50);
    
    //$uzivatel = prihlasUzivatele();
    
    ////// TESTTTTTTTTTTTTtt
    $uzivatel["id"]=3760;
    $uzivatel["kredit"]=400 * 1048576;
    
    mysql_connect("localhost", "root", "");
    mysql_select_db("rapidspool");
    ////// ------------
    
    $links=explode("\n", $_REQUEST["links"]);
    
    
    $cnt = count($links);
    
    if(!$_REQUEST["links"]) return;
    
    $vefronte = mysql_result(mysql_query("SELECT count(*) FROM stahovani WHERE uzivatel = " . $uzivatel["id"]),0);
    if($vefronte > MAX_LINKS_TOTAL) return "Odkazy nebyly pøidány, protože ve fronì máte momentálnì $vefronte souborù. Limit je " . MAX_LINKS_TOTAL;
    
    if($cnt > MAX_LINKS_ADDED) $cnt = MAX_LINKS_ADDED;
    
    $link_status=range(0,$cnt-1);
    $link_suc = 0;
    $velikost = 0;
    
    
    
    // Jen ty, co mame na serveru
    for($i=0; $i<$cnt; $i++){
      $soubor_info[$i] = souborInfoOdNas($links[$i]);
    
      if($soubor_info[$i]["status"]>0){
        $velikost += $soubor_info[$i]["velikost"];
        if($velikost<$uzivatel["kredit"]){
          $link_status[$i]=2;
          $link_suc++;
        } else $link_status[$i]=0;
      }
    }
    
    
    // Ostatni
    stahniInfoOSouborech($links, $soubor_info, $cnt);
    
    for($i=0; $i<$cnt; $i++){
      if($soubor_info[$i]["status"]==0){ // Soubor na nasem serveru nemame
        $velikost += $soubor_info[$i]["velikost"];
    if($velikost<$uzivatel["kredit"]){
          $link_status[$i]=1;
          $link_suc++;
        } else $link_status[$i]=0;
    
      } elseif($soubor_info[$i]["status"]==-1){ // Soubor neexistuje
          $link_status[$i]=-1;
      }
    }
    
    
    // Prochazeni, zapisovani do db, oznamovani chyba
    for($i=0; $i<$cnt; $i++){
      switch($link_status[$i]){
        case -1:
          echo "-1\n";
          break;
        case 0:
      echo "0\n";
      break;
    case 1:
      echo "1\n";
      pridejStahovani(false, $uzivatel["id"], $links[$i], $soubor_info[$i]["cesta"], $soubor_info[$i]["velikost"]);
      break;
    case 2:
      pridejStahovani(true, $uzivatel["id"], $links[$i],  $soubor_info[$i]["cesta"], $soubor_info[$i]["velikost"], $soubor_info[$i]["cas_nahrani"], $soubor_info[$i]["status"]);
      echo "1\n";
      }
    }
    echo "\nPo stažení tìchto souborù Vám zbyde: " . toGB($uzivatel["kredit"]-$velikost) . " GB";
    
    function pridejStahovani($existuje, $uzid, $link, $cesta, $velikost, $cas_nahrani=0, $status=0){
      $link = mysql_real_escape_string($link);
      if(mysql_result(mysql_query("SELECT count(*) FROM `stahovani` WHERE uzivatel = $uzid AND soubor = '" . $link . "'"),0)>0) return;
      if($existuje===false){
        mysql_query("INSERT INTO `stahovani` (uzivatel, soubor, cesta, velikost, stazeno, status, cas_nahrani, cas_stazeni, rychlost) VALUES 
    										($uzid, '$link', '$cesta', $velikost, 0, 0, 0, 0, 0)");
      } else {
        mysql_query("INSERT INTO `stahovani` (uzivatel, soubor, cesta, velikost, stazeno, status, cas_nahrani, cas_stazeni, rychlost) VALUES 
    										($uzid, '$link', '$cesta', $velikost, 0, $status, $cas_nahrani, 0, 0)");
      }
    }
    
    
    function souborInfoOdNas($link) {
      $link = mysql_real_escape_string($link);
      $res = mysql_query("SELECT id, status, cesta, velikost, cas_nahrani FROM `stahovani` WHERE soubor = '$link' AND status > 0 LIMIT 0,1");
      $out = array();
      $path = vytvorCestu($link);
      $out["cesta"] = $path;
      if(mysql_num_rows($res)==0){
    if(@file_exists($path)){
      $size = filesize($path);
      $out["velikost"]=$size;
      $out["cas_nahrani"]=time();
      $out["status"]=1;
      return $out;
    }
      } else {
        $out["status"]=1;
    $rec = mysql_fetch_row($res);
    $out["status"]=$rec[1];
    $out["cesta"]=$rec[2];
    $out["velikost"]=$rec[3];
    $out["cas_nahrani"]=$rec[4];
        return $out;	
      }
    }
    
    function stahniInfoOSouborech($odkazy, &$soubor_info, $cnt){
      for($i=0; $i<$cnt; $i++){
        if($soubor_info[$i]["status"]<1){ // Pokud soubor na serveru nemame
      $q .= $odkazy[$i] . "\r\n";
    }
      }
      $results=explode("\n", HTTP_GET("rapidshare.com", "/cgi-bin/checkfiles.cgi?toolmode=1&urls=" . urlencode($q)));
      $cr = 0;
      for($i=0; $i<$cnt; $i++){
        if($soubor_info[$i]["status"]<1){ // Pokud soubor na serveru nemame
      $cur_info = explode(",", $results[$cr]);
      if($cur_info[1]==-1){ // Pokud neexistuje sobuor na strane rapidshare...
        $soubor_info[$i]["status"]=-1;
      } else {
        $soubor_info[$i]["status"]=0;
    	$soubor_info[$i]["cesta"]=vytvorCestu($odkazy[$i]);
    	$soubor_info[$i]["velikost"]=$cur_info[4];
      }
      $cr++;
    }
      }
    }
    
    
    
    ?>
    

  10. haha, yes, sorry. virtual :D

     

    yes i found the .htaccess and it looks like that is the problem.

    RewriteEngine on
    RewriteRule ^member/(.+)$ index.php?mod=member&member=$1 [L,QSA]
    RewriteRule ^redirect/(.+)$ index.php?mod=redirect&link=$1 [L,QSA]
    RewriteRule ^(.+)/(.+)/$ index.php?mod=item&catname=$1&itemname=$2 [L,QSA]
    RewriteRule ^category-(.+)/$ index.php?mod=category&catname=$1 [L,QSA]
    RewriteRule ^(.+)/$ index.php?mod=$1 [L,QSA]
    RewriteRule ^global\.xml$ /rss/rss_global.php [L]
    RewriteRule ^(.+)\.xml /rss/rss_category.php?cat=$1 [L]
    php_value session.use_only_cookies 1
    php_value session.use_trans_sid 0

     

    thanks. however, now i have a new problem ???

     

    if i drop the .htaccess file into public_html i cant access the site at all.

     

    i get this

     

    "The server encountered an internal error or misconfiguration and was unable to complete your request.

    Please contact the server administrator, webmaster@hunt4perfection.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

     

    More information about this error may be available in the server error log.

     

     

    Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request."

     

  11. Ok, this might be the complete wrong term to call this but i dont know how else to describe it.

     

    a scripter made a site for me. it has what i will refer to as "vertual folders"

     

    what i mean by that is:

     

    www.mysite.com/folder1

     

    folder1 does not acualy exist on the server, but some php code makes it a valid url.

     

    this all works fine on the original site.

     

    now i want to move the site to a new host.

    on the new host, www.mysite.com works fine, but www.mysite.com/folder1 gives me a 404.

     

    i have moved over all the files and mysql

     

    can anyone please tell me the right terminology for my "vertual folder" and where i can get information about it.

  12. im stupid!

    help please!

     

    Parse error: syntax error, unexpected T_STRING in /home/clipkcom/public_html/includes/test.php on line 3

     

    <?php
    include('dbconect.php');
    $query = mysql_query("SELECT * FROM config") or die("Query failed: ." mysql_error());
    ?>

  13. could i get this error if my server is running php4 instead of php5?

     

    i dont understand it. my host says the server is configured for this software. and the software is exactly as downloaded from the site eccept for gonfig.php changed to my server details.

     

    the software veddor offers a paid installation, but i will feel robbed if it is something i should be able to do myself?

     

     

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/clipkcom/public_html/includes/classes/mysql_queries.class.php on line 29

     

    Warning: main() [function.main]: open_basedir restriction in effect. File(/includes/templatelib/Template.class.php) is not within the allowed path(s): (/home/clipkcom/:/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4/lib/php:/tmp) in /home/clipkcom/public_html/includes/admin_config.php on line 103

     

    Warning: main(/includes/templatelib/Template.class.php) [function.main]: failed to open stream: Operation not permitted in /home/clipkcom/public_html/includes/admin_config.php on line 103

     

    Fatal error: main() [function.require]: Failed opening required '/includes/templatelib/Template.class.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/clipkcom/public_html/includes/admin_config.php on line 103

  14. these are the lines that the error refers to

     

    function Get_Website_Details(){
    $query = mysql_query("SELECT * FROM config");
    while($row = mysql_fetch_array($query)){
    $name = $row['name'];
    $data[$name] = $row['value'];
    }
    return $data;
    }
    
    function Get_Email_Settings(){
    $query = mysql_query("SELECT * FROM email_settings");
    while($row = mysql_fetch_array($query)){
    $name = $row['email_settings_name'];
    $data[$name] = $row['email_settings_value'];
    }
    return $data;
    }

  15. is this a problem with my script or my mysql?

     

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/clipkcom/public_html/includes/classes/mysql_queries.class.php on line 29

     

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/clipkcom/public_html/includes/classes/mysql_queries.class.php on line 38

     

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/clipkcom/public_html/includes/classes/mysql_queries.class.php on line 56

  16. this is the script i am using at the moment. is this script badly written? can i modify this script to work corectly or should i start from scrach with a new approach?

    all i need is to know that my newsletter is going out to all my members.

     

    what is the most effective, batch or bcc?

     

     <? 
    include('../functions.php');
    if(!$_SESSION['admin_logged_in'])
    {
    header('Location: ' .LOGIN_URL );
    }
    
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Admin | Send mass mail</title>
    <link href="style.css" rel="stylesheet" type="text/css" media="all" />
    <body>
    <?
    $letter_id = ( !empty($_REQUEST['letter_id']) ) ? $_REQUEST['letter_id'] : FALSE;
    $msg='';
    
    $let_info=get_letter($letter_id);
    $letter_title=$let_info['name'];
    $hf=get_hf();
    
    
    if (isset($_REQUEST['submit_preview']))
    {
    $ready_to_send = true;
    $letter_body='';
    $letter_body=$hf['header'].'<br>'.$let_info['content'].'<br>'.$hf['footer'].'<br>';
    }
    
    if (isset($_REQUEST['submit_mass_mail']))
    {
    $info=get_mass_mails();
    
    $members=$info['items'];
    
    $oks=$bads=$invalids=0;
    
    
    $letter_body='';
    
    $headers='';
    $headers .= 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= 'From:  dorp <contact@xxxx.co.uk>'. "\r\n";
    $headers .= 'Reply-To: contact@xxxx.co.uk' . "\r\n";
    
    $hf_header_tmp = $hf['header'];
    
    $let_info_tmp .= $let_info['content'];
    
    
    for ($i=0; $i<$info['total']; $i++) 
    {
    	$name = $members[$i]['name'];
    	$email = $members[$i]['email'];
    
    	if (valid_mail($email)) 
    	{	
    		//$headers .= "To: $name <$email>" . "\r\n";		
    		$hf['header'] = str_replace('[name]', $name, $hf_header_tmp);
                            $hf['footer'] = str_replace("[email]", $email, $hf['footer']);
    
    		$let_info['content'] = str_replace('[name]', $name, $let_info_tmp);
    
    
    		$letter_body =$hf['header'].'<br>'.$let_info['content'].'<br>
    <img src="http://www.xxxx.co.uk/cpanel/mail.php?id='.$letter_id.'&u='.$members[$i]['id'].'">'.$hf['footer'].'<br>';
    		$letter_body = str_replace("\n.", "\n..", $letter_body);
    
    
    
    	 	if (mail($email, $letter_title, $letter_body, $headers))
    			++$oks;
    	 	else ++$bads;
    
    	}
    	else 
    	{
    		++$invalids;
    	}
    }
    
    $all=$oks+$bads+$invalids;
    $msg="<br>Mailing reports:<br>
    <br>Letter: #$letter_id - $letter_title<br>
    <br>Sent: $oks
    <br>Failed:	$bads<br>
    <br>Invalid E-mails: $invalids<br>
    <br>Total: $all .";
    
    create_log_entry($_SESSION['auth_literal_admin_level'].' '.$_SESSION['auth_admin_name'].$msg,$_SESSION['auth_admin_name'],'mailing');
    //
    }
    ?>
    <br />
    <script language="javascript" type="text/javascript">
    function disableForm(theform) {
    if (document.all || document.getElementById) 
    {
    	for (i = 0; i < theform.length; i++) 
    	{
    		var tempobj = theform.elements[i];
    		if (tempobj.name.toLowerCase() == "submit_mass_mail" || tempobj.type.toLowerCase() == "submit_preview")
    		tempobj.disabled = true;
    	}
    }
    }
    </script>
    <form id="form1" name="form1" method="post" action="mass_mailer.php?letter_id=<? echo $letter_id; ?>"><!-- onSubmit="return disableForm(this);" -->
    
    <table width="685" border="0" align="center" cellpadding="0" cellspacing="1" class="input_form">
      <tr>
        <th colspan="2" scope="row">Send mass mail </th>
        </tr>
      <tr>
        <td colspan="2" class="style7" scope="row"> </td>
        </tr>
      <tr>
        <td width="85" class="style7" scope="row">Choose letter </td>
        <td width="412">
    <select name="letter_id" id="letter_id">
    <?
     $eq = get_letters();
     $eq_info = $eq['items'];
    
     for ($i=0; $i<$eq['total']; $i++) 
     {
    	 if ($eq_info[$i]['id'] == $letter_id) 
    	 	$chx='selected="selected"';
    	 else $chx='';
    	 echo "<option value='{$eq_info[$i]['id']}' $chx>{$eq_info[$i]['name']}</option>\r\n";
    }
    ?>
        </select>
    <input name="submit_preview" type="submit" id="submit_preview" value="Preview!" /></td>
      </tr> <? if ($ready_to_send) {?>
      <tr>
        <td colspan="2" scope="row"><span class="style7">
    You are about to send a mass mail to
    <? echo count_members(); ?> members of your site
        </span></td>
        </tr>
      <tr>
        <td colspan="2" class="header" scope="row"><div align="center"><span class="style7">
          
        </span>** Letter preview below ** <span class="style7">
      
        </span></div>  </td>
      </tr>
      <tr>
        <td colspan="2" scope="row"><? echo $letter_title ; ?></td>
      </tr>
      <tr>
        <td colspan="2" scope="row"><? echo $letter_body ; ?></td>
      </tr>
      <tr>
        <td colspan="2" class="header" scope="row"><div align="center"><span class="style7"> </span>** end preview ** <span class="style7"> </span></div></td>
      </tr>
      <tr>
        <td colspan="2" scope="row"><div align="center"> 
              <script language="javascript">
    function write_message(letter_id) 
    {
    	alert(letter_id);
    //document.write('Please be patient while mailing list is processed! This may take a while, depending on the total users...');
    }
    </script>
            </div></td>
        </tr>
      <tr>
        <td colspan="2" scope="row">
          <div align="center">
            <input name="submit_mass_mail" type="submit" id="submit_mass_mail" value="Send mass mail!" />
            <span class="error"><br />(press only once and wait the page to load completely!)</span></div></td>
      </tr> 
      <? ;} ?>
      <tr>
        <td colspan="2" scope="row">
    <div align="left" class="error">
      <? if ($msg!='') {echo $msg;} ?>
    </div>	</td>
      </tr>
    </table>
    </form>
    </body>
    </html>

  17. So what is the big secret with mass mailing. i have searched forums, scripts, freelancers and everything i can think of but just cant get info about it.

     

    i have a db of about 3000 registered members. i need to mail a newsletter on a regular basis.

     

    the php script that i use works fine for small batches, but wont send more than 300 at a time.

    it pulls the newsletter from a bd, and also pulls the emails from a db.

     

    what is the "right way" to do this.

     

    Batch mails?  multiple smtp's? 

     

    i have had several freelance scripter work on this but cant solve my problem.

     

    is there a single corect way to do this, is my approach way off the mark?

     

    please help, or point me in the right direction.

     

     

     

  18. now i am confused??

    does this script use smtp? to send mail?

     

     <? 
    include('../functions.php');
    if(!$_SESSION['admin_logged_in'])
    {
    header('Location: ' .LOGIN_URL );
    }
    
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Admin | Send mass mail</title>
    <link href="style.css" rel="stylesheet" type="text/css" media="all" />
    <body>
    <?
    $letter_id = ( !empty($_REQUEST['letter_id']) ) ? $_REQUEST['letter_id'] : FALSE;
    $msg='';
    
    $let_info=get_letter($letter_id);
    $letter_title=$let_info['name'];
    $hf=get_hf();
    
    
    if (isset($_REQUEST['submit_preview']))
    {
    $ready_to_send = true;
    $letter_body='';
    $letter_body=$hf['header'].'<br>'.$let_info['content'].'<br>'.$hf['footer'].'<br>';
    }
    
    if (isset($_REQUEST['submit_mass_mail']))
    {
    $info=get_mass_mails();
    
    $members=$info['items'];
    
    $oks=$bads=$invalids=0;
    
    
    $letter_body='';
    
    $headers='';
    $headers .= 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= 'From:  dorp <contact@xxxx.co.uk>'. "\r\n";
    $headers .= 'Reply-To: contact@xxxx.co.uk' . "\r\n";
    
    $hf_header_tmp = $hf['header'];
    
    $let_info_tmp .= $let_info['content'];
    
    
    for ($i=0; $i<$info['total']; $i++) 
    {
    	$name = $members[$i]['name'];
    	$email = $members[$i]['email'];
    
    	if (valid_mail($email)) 
    	{	
    		//$headers .= "To: $name <$email>" . "\r\n";		
    		$hf['header'] = str_replace('[name]', $name, $hf_header_tmp);
                            $hf['footer'] = str_replace("[email]", $email, $hf['footer']);
    
    		$let_info['content'] = str_replace('[name]', $name, $let_info_tmp);
    
    
    		$letter_body =$hf['header'].'<br>'.$let_info['content'].'<br>
    <img src="http://www.xxxx.co.uk/cpanel/mail.php?id='.$letter_id.'&u='.$members[$i]['id'].'">'.$hf['footer'].'<br>';
    		$letter_body = str_replace("\n.", "\n..", $letter_body);
    
    
    
    	 	if (mail($email, $letter_title, $letter_body, $headers))
    			++$oks;
    	 	else ++$bads;
    
    	}
    	else 
    	{
    		++$invalids;
    	}
    }
    
    $all=$oks+$bads+$invalids;
    $msg="<br>Mailing reports:<br>
    <br>Letter: #$letter_id - $letter_title<br>
    <br>Sent: $oks
    <br>Failed:	$bads<br>
    <br>Invalid E-mails: $invalids<br>
    <br>Total: $all .";
    
    create_log_entry($_SESSION['auth_literal_admin_level'].' '.$_SESSION['auth_admin_name'].$msg,$_SESSION['auth_admin_name'],'mailing');
    //
    }
    ?>
    <br />
    <script language="javascript" type="text/javascript">
    function disableForm(theform) {
    if (document.all || document.getElementById) 
    {
    	for (i = 0; i < theform.length; i++) 
    	{
    		var tempobj = theform.elements[i];
    		if (tempobj.name.toLowerCase() == "submit_mass_mail" || tempobj.type.toLowerCase() == "submit_preview")
    		tempobj.disabled = true;
    	}
    }
    }
    </script>
    <form id="form1" name="form1" method="post" action="mass_mailer.php?letter_id=<? echo $letter_id; ?>"><!-- onSubmit="return disableForm(this);" -->
    
    <table width="685" border="0" align="center" cellpadding="0" cellspacing="1" class="input_form">
      <tr>
        <th colspan="2" scope="row">Send mass mail </th>
        </tr>
      <tr>
        <td colspan="2" class="style7" scope="row"> </td>
        </tr>
      <tr>
        <td width="85" class="style7" scope="row">Choose letter </td>
        <td width="412">
    <select name="letter_id" id="letter_id">
    <?
     $eq = get_letters();
     $eq_info = $eq['items'];
    
     for ($i=0; $i<$eq['total']; $i++) 
     {
    	 if ($eq_info[$i]['id'] == $letter_id) 
    	 	$chx='selected="selected"';
    	 else $chx='';
    	 echo "<option value='{$eq_info[$i]['id']}' $chx>{$eq_info[$i]['name']}</option>\r\n";
    }
    ?>
        </select>
    <input name="submit_preview" type="submit" id="submit_preview" value="Preview!" /></td>
      </tr> <? if ($ready_to_send) {?>
      <tr>
        <td colspan="2" scope="row"><span class="style7">
    You are about to send a mass mail to
    <? echo count_members(); ?> members of your site
        </span></td>
        </tr>
      <tr>
        <td colspan="2" class="header" scope="row"><div align="center"><span class="style7">
          
        </span>** Letter preview below ** <span class="style7">
      
        </span></div>  </td>
      </tr>
      <tr>
        <td colspan="2" scope="row"><? echo $letter_title ; ?></td>
      </tr>
      <tr>
        <td colspan="2" scope="row"><? echo $letter_body ; ?></td>
      </tr>
      <tr>
        <td colspan="2" class="header" scope="row"><div align="center"><span class="style7"> </span>** end preview ** <span class="style7"> </span></div></td>
      </tr>
      <tr>
        <td colspan="2" scope="row"><div align="center"> 
              <script language="javascript">
    function write_message(letter_id) 
    {
    	alert(letter_id);
    //document.write('Please be patient while mailing list is processed! This may take a while, depending on the total users...');
    }
    </script>
            </div></td>
        </tr>
      <tr>
        <td colspan="2" scope="row">
          <div align="center">
            <input name="submit_mass_mail" type="submit" id="submit_mass_mail" value="Send mass mail!" />
            <span class="error"><br />(press only once and wait the page to load completely!)</span></div></td>
      </tr> 
      <? ;} ?>
      <tr>
        <td colspan="2" scope="row">
    <div align="left" class="error">
      <? if ($msg!='') {echo $msg;} ?>
    </div>	</td>
      </tr>
    </table>
    </form>
    </body>
    </html>
    

  19. Coollist sounds great, but my database is growing on a daily basis. sending directly from the mysql db has the advantages that mailing lists are always updated.

    Also personal info like name, email, and preferences can be tailored for each member.

    i also have a mail tracker system to see who has actualy opened their mails by inserting a 1x1pixel gif in the mail.

    and lastly, i am always nervous to give my database to a third party. i have to respect the privacy of my members that they entrust in me.

     

    Schilly, i like your take on it.

    i think i understand it. now i just have to see if i can write it into my mailer cript as i am a newbie to php.

    i will give it a good go though.

    Thanks

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.