Advertisement
puggan

gravity_form_list_notification_from_adresses.php

Sep 23rd, 2015
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.37 KB | None | 0 0
  1. <?php
  2.     $username = "";
  3.     $password = "";
  4.     $database = "";
  5.     $table_prefix = "wp_";
  6.  
  7.     $blogs_prefixes = array();
  8.  
  9.     $db = new mysqli('localhost', $username, $password, $database);
  10.  
  11.     $query = "SELECT blog_id, domain FROM {$table_prefix}blogs";
  12.  
  13.     $resource = $db->query($query);
  14.  
  15.     if($resource)
  16.     {
  17.         while($row = $resource->fetch_array(MYSQLI_ASSOC))
  18.         {
  19.             $blogs_prefixes[$row['domain']] = "{$table_prefix}{$row['blog_id']}_";
  20.         }
  21.  
  22.         $resource->free();
  23.     }
  24.  
  25.     if(!$blogs_prefixes)
  26.     {
  27.         $blogs_prefixes["localhost"] = $table_prefix;
  28.     }
  29.  
  30.     foreach($blogs_prefixes as $blog_domain => $blog_prefix)
  31.     {
  32.         $query = "SELECT notifications, form_id, title FROM {$blog_prefix}rg_form_meta INNER JOIN {$blog_prefix}rg_form ON ({$blog_prefix}rg_form.id = {$blog_prefix}rg_form_meta.form_id) WHERE is_trash = 0";
  33.  
  34.         $resource = $db->query($query);
  35.  
  36.         while($row = $resource->fetch_array(MYSQLI_ASSOC))
  37.         {
  38.             $data = json_decode($row['notifications']);
  39.  
  40.             foreach($data as $notification_key => $notification_data)
  41.             {
  42.                 $email = $notification_data->from;
  43.  
  44.                 // Do some tests on $email, is it a static email address, "{admin_email}" or "{field_name:field_number}"
  45.  
  46.                 echo "{$email}\tin notification '{$notification_data->name}'\tin form {$row['form_id']}\tnamed '{$row['title']}' at site '{$blog_domain}' [{$blog_prefix}]\n";
  47.             }
  48.         }
  49.  
  50.         $resource->free();
  51.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement