// Name, path, namepsace $loader->addResourceType('model', 'models', 'Model'); $weekdays = array('Sun' => 'sunday', 'Mon' => 'monday', 'Tue' => 'tuesday', 'Wed' => 'wednesday', 'Thu' => 'thursday', 'Fri' => 'friday', 'Sat' => 'saterday'); // Get our config file $config = new Zend_Config_Ini($apppath . '/application/configs/application.ini'); Zend_Registry::set('config', $config->production); // Because our models need it this way // Get the messages model //$message = new Application_Model_Message(); // Set up our current timestamp $timestamp = date('Y-m-d H:i:s'); // Log the start of this read logWrite("**********************************"); logWrite("Begin truncate: {$timestamp}"); logWrite("------------------------------------"); $rpt = new Application_Model_Report(); $rpt->saveUserDailyactivity(); // Log our counts //logWrite("") /*Memcache server: BDAYCLUB info stores in the memcache memory*/ $msgobj = new Application_Model_Message(); $msgobj->addMemcahceBdclub(); /*end of memcache server use*/ $dataObj = new Application_Model_DataReporting(); $rst = $dataObj->allphonenumbers(); if ($rst) { $log = "Rows inserted: {$rst}"; logWrite($log); } else { logWrite("No data inserted!!"); }
public function deleteAction() { $folderObj = new Application_Model_Folder($this->user); $folderid = $this->request->getParam('id'); //if ($this->user->isSuperAdmin() || $this->session->canImport) { $reportObj = new Application_Model_Report(); if ($reportObj->getTotalSubscriberByFolder($folderid) == 0) { if ($folderObj->deleteFolder($folderid)) { $message = 'Folder Deleted.'; } else { $error = 'Folder error: ' . $folderObj->getError(); } } else { if ($folderObj->deleteFolderWithSubscriber($folderid)) { $message = 'Folder Deleted.'; } else { $error = 'Folder error: ' . $folderObj->getError(); } } //} $this->view->error = $error; $this->view->message = $message; $this->_redirector->gotoUrl('/folder/'); }
public function messagemonthyearAction($showLayout = false) { if (!$showLayout) { $this->_helper->layout->disableLayout(); } list($key_used, $key_deleted) = $this->user->getKeywordsCountNew(); $this->view->key_used = $key_used - $key_deleted; $this->view->key_limit = $this->user->keywordlimit; $this->view->key_percent = sprintf("%d", $this->view->key_used / $this->view->key_limit * 100); $this->view->msg_limit = $this->user->messagelimit; $messageObj = new Application_Model_Report(); $userid = $this->user->getId(); //*********** Calculate startdate and end date................ $rmonth = date('m'); $ryear = date('Y'); $yearmonth = date('Y-m'); $daysInMonth = cal_days_in_month(CAL_GREGORIAN, $rmonth, $ryear); // echo 'rmstart-'.$monthstartdate = $ryear."-".$rmonth."-1 00:00:00"; echo '<br>'; //echo 'rmend-'.$monthenddate = $ryear."-".$rmonth."-30 00:00:00"; $monthstartdate = $ryear . "-" . $rmonth . "-1 00:00:00"; $monthenddate = $ryear . "-" . $rmonth . "-" . $daysInMonth . " 00:00:00"; $this->view->msg_used = $messageObj->reportCountTotalMessagesByUserIdNew($userid, $monthstartdate, $monthenddate); $this->view->totalNewSubscribers = $messageObj->reportCountTotalSubscribersByUserIdNew($userid, $monthstartdate, $monthenddate, true); $this->view->totalKeywordSubscribers = $messageObj->reportCountRegGrpBySubscribersByUserIdNewKeys($userid, life); $this->view->totalImportedSubscribers = $this->user->totalupload; $myla = $messageObj->getMylaFoldersId(); $this->view->totalMyla = $messageObj->getMyla($userid, $myla[$userid], 'life'); $this->view->topThreeKeywordArray = $topThreeKeywordArray; /* /*one more mess wont change face of this horror*/ $this->view->dashboardKeywordsAct = $messageObj->dashboardKeyword_activity($userid); // $this->view->dashboardTotalOptins = $messageObj->dashboard_totalOptedIn($userid); $this->view->dashboardTotalOptins = $this->user->totalsubscribers; // $this->view->dashboardTotalOptinsByWebform = $messageObj->dashboard_totalOptedInsByWebform($userid); $this->view->dashboardTotalOptinsByWebform = $this->user->weboptin; $this->view->dashboardTotalMessagesSend = $messageObj->dashboard_totalMessagesSentOut($userid, $yearmonth); // $this->view->dashboardTotalCampaignSend = $messageObj->dashboard_totalCampaignSentOut($userid,$yearmonth); $msgpercent = $this->view->dashboardTotalMessagesSend / $this->view->msg_limit * 100; if ($msgpercent >= 100) { $msgpercent = 100; } $this->view->msg_percent = sprintf("%d", $msgpercent); $this->view->userid = $userid; $this->view->mylamt = $this->user->mylamt; $this->view->kwdmt = $this->user->keywordmt; $this->view->webmt = $this->user->webmt; $this->view->dobmt = $this->user->dobmt; // $this->view->totalcampsent = $this->user->totalcampsent; $this->view->totalcampsent = $messageObj->totalCampaignFromUserAccount($userid, $yearmonth); // echo $userid." : ".$yearmonth." : ".$this->view->totalcampsent; exit; $this->view->totalmt = $this->user->totalmt; $this->view->totalmrkmt = $this->user->totalmrkmt; }
if (!file_exists($logfile)) { touch($logfile); } // Get the Zend Framework loader setup require_once 'Zend/Loader/Autoloader.php'; $autoloader = Zend_Loader_Autoloader::getInstance(); // Setup routing of model autoloaders $loader = new Zend_Loader_Autoloader_Resource(array('basePath' => $apppath . '/application/', 'namespace' => 'Application')); // Name, path, namepsace $loader->addResourceType('model', 'models', 'Model'); // Get our config file $config = new Zend_Config_Ini($apppath . '/application/configs/application.ini'); Zend_Registry::set('config', $config->production); // Because our models need it this way // Get the messages model $weeklyreport = new Application_Model_Report(); // Set up our current timestamp $timestamp = date('Y-m-d H:i:s'); // Log the start of this read logWrite("####################################"); logWrite("Begin batch send: {$timestamp}"); logWrite("------------------------------------"); // Get the queue and counts $sendReportsTo = $weeklyreport->sendRportTo(); $queueCount = count($sendReportsTo); $sendCount = 0; // Log our counts logWrite("Number of persons to whom report will bse sent: {$queueCount}\nBegin send loop:"); //logWrite("") //logWrite("") if (is_array($sendReportsTo)) {
$loader = new Zend_Loader_Autoloader_Resource(array('basePath' => $apppath . '/application/', 'namespace' => 'Application')); // Name, path, namepsace $loader->addResourceType('model', 'models', 'Model'); // Get our config file $config = new Zend_Config_Ini($apppath . '/application/configs/application.ini'); Zend_Registry::set('config', $config->production); // Because our models need it this way // Get the messages model // Set up our current timestamp // Log the start of this read logWrite("####################################"); logWrite("User property update starts " . date('Y-m-d H:i:s')); logWrite("------------------------------------"); $usrprop = array(63, 64, 74, 65, 66, 77, 78); $mrkinfo = array(67, 68, 69, 70, 71, 72, 75, 76, 73); $rep = new Application_Model_Report(); $accounts_id = $rep->accountids(); $countusrid = count($accounts_id); if ($rep->subscribers_reportUpdate()) { $myla = $rep->getMylaFoldersId(); for ($uid = 0; $uid < $countusrid; $uid++) { $val = $rep->reportCountRegGrpBySubscribersByUserIdNewKeys($accounts_id[$uid], "daily"); $rep->activateUserproperty($accounts_id[$uid], $usrprop[0], $val); $val_w = $rep->dashboard_totalOptedInsByWebform($accounts_id[$uid], "daily"); $rep->activateUserproperty($accounts_id[$uid], $usrprop[1], $val_w); if ($myla[$accounts_id[$uid]]) { $fd = $myla[$accounts_id[$uid]]; $val_m = $rep->getMyla($accounts_id[$uid], $fd, "daily"); $rep->activateUserproperty($accounts_id[$uid], $usrprop[2], $val_m); } else { $val_m = 0;
public function createAction() { $error = null; $message = null; $userid = $this->user->getId(); $username = $this->user->username(); $formObj = new Application_Model_Form(); $reportObj = new Application_Model_Report(); $webformListSubAccount = array(); if ($reportObj->checkAdminUser($userid)) { $subUsersArray = $reportObj->findChildEntityList($userid, 5, ""); //echo "<pre>"; print_r($subUsersArray); exit; foreach ($subUsersArray as $subuser) { $webformlistmerge = $formObj->webformList($subuser['childuserid']); if (!empty($webformlistmerge) and is_array($webformlistmerge)) { $webformListSubAccount = array_merge($webformListSubAccount, $webformlistmerge); } } //echo "<pre>"; print_r($webformListSubAccount); exit; } if ($this->request->isPost()) { //echo "<pre>"; print_r($this->_request->getParams()); exit; $postdataValue = $this->_request->getParams(); //echo '<pre>'; print_r($postdataValue);exit; $this->view->postedValues = $postdataValue; if ($this->request->getParam('formurl') == "") { $message['type'] = "error"; $message['body'] = "Atleast Unique URL is required"; } else { $createformfor = ""; if ($this->request->getParam('subacc') == "on") { $folderidArray = "subacc"; } else { $folderidArray = $this->request->getParam('folderid'); } // echo '<pre>'; print_r($folderidArray); exit; if (!empty($folderidArray)) { $webformUrlArray = array(); $weburl = trim($this->request->getParam('formurl')); $weburlfilter = preg_replace('/[^a-z0-9]/', '-', $weburl); if ($folderidArray == "subacc") { foreach ($subUsersArray as $subuser) { $userid = $subuser['childuserid']; $folderids = $this->user->getFolderElseCreate("weboptin", $userid); $webformUrlArray = array("entityid" => $userid, "urlname" => addslashes($weburlfilter), "thankumsg" => addslashes($this->request->getParam('thanku_message')), "descmsg" => addslashes($this->request->getParam('formdesc')), "folderid" => $folderids, "dobstatus" => addslashes($this->request->getParam('dobstatus')), "alertmessage" => addslashes($this->request->getParam('alertmessage')), "notifybysms" => $this->request->getParam('notifybysms'), "notifybyemail" => addslashes($this->request->getParam('notifybyemail'))); $webformAttbArray = $this->request->getParam('chkname'); //echo "<pre>"; print_r($webformAttbArray); $webformAttbTypeArray = $this->request->getParam('chktype'); //echo "<pre>"; print_r($webformAttbTypeArray); $webformAttbWeightage = $this->request->getParam('weightage'); //echo "<pre>"; print_r($webformAttbTypeArray); //echo "<pre>"; print_r($this->request->getParam('chk')); foreach ($this->request->getParam('chk') as $key => $checked) { $webformAttbArrayToinsert[$key]['weightage'] = addslashes($webformAttbWeightage[$checked]); $webformAttbArrayToinsert[$key]['attb'] = addslashes($webformAttbArray[$checked]); $webformAttbArrayToinsert[$key]['attbtype'] = addslashes($webformAttbTypeArray[$checked]); $webformAttbOptionArray = $this->request->getParam('chkvalue' . $checked); //echo "<pre>"; print_r($webformAttbOptionArray); if (!empty($webformAttbOptionArray)) { $webformAttbOptionString = implode(",", $webformAttbOptionArray); } else { $webformAttbOptionString = ""; } $webformAttbArrayToinsert[$key]['attboption'] = addslashes($webformAttbOptionString); } //echo "<pre>"; print_r($webformAttbArrayToinsert); exit; if (empty($webformAttbArrayToinsert)) { $message['type'] = "error"; $message['body'] = "Please check atleast one information field"; } elseif (empty($folderidArray)) { $message['type'] = "error"; $message['body'] = "Please choose atleast one folder"; } else { $dataInserted = $formObj->insertFormDetails($webformUrlArray, $webformAttbArrayToinsert); if ($dataInserted) { $message['type'] = "success"; $message['body'] = "Form created successfully"; } else { $message['type'] = "error"; $message['body'] = $formObj->getError(); } } } $this->_redirector->gotoUrl('/form/create/'); } else { $folderids = implode($folderidArray, ','); $webformUrlArray = array("entityid" => $userid, "urlname" => addslashes($weburlfilter), "thankumsg" => addslashes($this->request->getParam('thanku_message')), "descmsg" => addslashes($this->request->getParam('formdesc')), "folderid" => $folderids, "dobstatus" => addslashes($this->request->getParam('dobstatus')), "alertmessage" => addslashes($this->request->getParam('alertmessage')), "notifybysms" => $this->request->getParam('notifybysms'), "notifybyemail" => addslashes($this->request->getParam('notifybyemail'))); $webformAttbArray = $this->request->getParam('chkname'); //echo "<pre>"; print_r($webformAttbArray); $webformAttbTypeArray = $this->request->getParam('chktype'); //echo "<pre>"; print_r($webformAttbTypeArray); $webformAttbWeightage = $this->request->getParam('weightage'); //echo "<pre>"; print_r($webformAttbTypeArray); //echo "<pre>"; print_r($this->request->getParam('chk')); foreach ($this->request->getParam('chk') as $key => $checked) { $webformAttbArrayToinsert[$key]['weightage'] = addslashes($webformAttbWeightage[$checked]); $webformAttbArrayToinsert[$key]['attb'] = addslashes($webformAttbArray[$checked]); $webformAttbArrayToinsert[$key]['attbtype'] = addslashes($webformAttbTypeArray[$checked]); $webformAttbOptionArray = $this->request->getParam('chkvalue' . $checked); //echo "<pre>"; print_r($webformAttbOptionArray); if (!empty($webformAttbOptionArray)) { $webformAttbOptionString = implode(",", $webformAttbOptionArray); } else { $webformAttbOptionString = ""; } $webformAttbArrayToinsert[$key]['attboption'] = addslashes($webformAttbOptionString); } //echo "<pre>"; print_r($webformAttbArrayToinsert); exit; if (empty($webformAttbArrayToinsert)) { $message['type'] = "error"; $message['body'] = "Please check atleast one information field"; } elseif (empty($folderidArray)) { $message['type'] = "error"; $message['body'] = "Please choose atleast one folder"; } else { $dataInserted = $formObj->insertFormDetails($webformUrlArray, $webformAttbArrayToinsert); if ($dataInserted) { $message['type'] = "success"; $message['body'] = "Form created successfully"; } else { $message['type'] = "error"; $message['body'] = $formObj->getError(); } } } } else { $message['type'] = "error"; $message['body'] = "Please select atleast one folder from dropdown."; } } } $user = new Application_Model_User((int) $userid); $this->view->message = $message; $this->view->folders = $this->user->getFolders(); $this->view->webformlist = $formObj->webformList($userid); $this->view->webformlistSubaccount = $webformListSubAccount; $this->view->business = $user->businessname; $this->view->ainfo = $user->reward; $this->view->userid = $userid; }
public function badnumbersAction() { if ($this->request->isPost()) { $rep = new Application_Model_Report(); $usrfolders = $this->request->getParam('folders'); $folders = explode(',', $usrfolders); $totalfolders = count($folders); $totalsubscribers = array(); for ($sbr = 0; $sbr < $totalfolders; $sbr++) { // $folder = new Application_Model_Folder($this->user, $folders[$sbr]); $msg = new Application_Model_Message(); $subscribers = $msg->subscribersByFolderid($folders[$sbr]); foreach ($subscribers as $usr_fid => $v) { $totalsubscribers[$v['phonenumber']] = $v['phonenumber']; } } $res = $rep->getBadNumbers($this->user->getId(), $totalsubscribers); } if ($res) { echo $res; } else { echo "Nothing is selected"; } exit; }
if (!file_exists($logfile)) { touch($logfile); } // Get the Zend Framework loader setup require_once 'Zend/Loader/Autoloader.php'; $autoloader = Zend_Loader_Autoloader::getInstance(); // Setup routing of model autoloaders $loader = new Zend_Loader_Autoloader_Resource(array('basePath' => $apppath . '/application/', 'namespace' => 'Application')); // Name, path, namepsace $loader->addResourceType('model', 'models', 'Model'); // Get our config file $config = new Zend_Config_Ini($apppath . '/application/configs/application.ini'); Zend_Registry::set('config', $config->production); // Because our models need it this way // Get the messages model $weeklyreport = new Application_Model_Report(); //$r = $weeklyreport->getMonthlyReportApiuser(); //echo '<pre>'; print_r($r); //exit; // Set up our current timestamp $timestamp = date('Y-m-d H:i:s'); // Log the start of this read logWrite("####################################"); logWrite("Begin batch send: {$timestamp}"); logWrite("------------------------------------"); // Get the queue and counts $sendReportsTo = $weeklyreport->sendDailyReportTo(); $queueCount = count($sendReportsTo); $sendCount = 0; // Log our counts logWrite("Number of persons to whom report will bse sent: {$queueCount}\nBegin send loop:");
/** * Set up a new campaign and send a message. * * @access public // */ public function campaignAction() { // Defaults $success = null; $message = null; $error = null; $recipients = array(); $sentto = array(); $description = null; $date = null; $time = null; $sendtime = null; $timezone = null; $status = null; $user_folders = 0; $shortcode = 0; // set the default message body values $this->defaultValues(); $userid = $this->user->getId(); $formObj = new Application_Model_Form(); $user = new Application_Model_User($userid); $rpt = new Application_Model_Report(); $yearmonth = date('Y-m'); // Logged in users folder ID's $user_folders = $this->user->getFolders(); $foldersid = array_keys($user_folders); $totalfolders = count($foldersid); $orgeachfolders = array(); $setarray = array(); // for($i = 0; $i < $totalfolders; $i++){ // $orgnumbers = array(); // $folder = new Application_Model_Folder($this->user, $foldersid[$i]); // $subscribers = $folder->getSubscribers(); // foreach ($subscribers as $subscriber) { // if(!in_array($subscriber['phonenumber'], $setarray)){ // $orgnumbers[] =$subscriber['phonenumber']; // } // $setarray[$subscriber['phonenumber']] = $subscriber['phonenumber']; // } // $orgeachfolders[$foldersid[$i]] = $orgnumbers; // } $this->view->cleandata = $orgeachfolders; $this->view->folders = $user_folders; // When the form is submit if ($this->request->isPost()) { // see if a folder was selected $sendto = $this->request->getParam('folders'); $description = trim($this->request->getParam('description')); $this->msg_head = $this->request->getParam('msg_head'); $this->msg_body = $this->request->getParam('msg_body'); $shortcode = $this->request->getParam('scselect'); // echo '<pre>'; print_r($sendto); exit; // Get the sendtime $scheduled = false; if ($this->request->getParam('sendtime') == 'later') { $scheduled = true; $sendtime = $this->request->getParam('date') . ' ' . $this->request->getParam('time'); } // User's timezone $this->user->setTimeZone($this->request->getParam('t_zone')); $timezone = $this->user->getTimeZone(); // Only admins can edit the footer if ($this->user->isAdmin()) { $this->msg_foot = $this->request->getParam('msg_foot'); } $msg = $this->msg_head ? "{$this->msg_head}:" : ''; $msg .= "{$this->msg_body}\n{$this->msg_foot}"; $msg = trim($msg); $sendmessage = new Application_Model_Message($this->user); // Verify the user provided a description for this message if ($description) { // Verify there was a message set if ($msg) { // make sure we got the sendto array from POST if (is_array($sendto) && !empty($sendto)) { // Create a campaign id that each message that goes out for this campaign can be grouped by $campaignid = md5($this->user->username . time()); // Get the subscribers from each selected folder $recipients = array(); foreach ($sendto as $folder) { //0001 // Clear out the recipients array for each folder $recipients = array(); // easy check to make sure this folder is owned by this user if (array_key_exists($folder, $user_folders)) { // Get the folder model $folder = new Application_Model_Folder($this->user, $folder); // Verify it if ($folder->isValid()) { // Get subscribers to this folder $subscribers = $folder->getSubscribers(); // echo '<pre>'; print_r($subscribers); // echo'<br>'."DELEMMA "; if (!empty($subscribers)) { foreach ($subscribers as $subscriber) { // Don't add this user if they have already received this message from being in another selected folder if (!in_array($subscriber['phonenumber'], $sentto)) { // key off the phone number to avoid duplicates from this folder, which should // never happen, but better safe than sorry $recipients[$subscriber['phonenumber']] = $subscriber['phonenumber']; } } /** * The message needs to be sent to each folder individually so that the folderid * can be logged in the outbound table. That allows us to see what folder to opt * a user out of when they reply with an optout. */ if (!empty($recipients)) { // Construct the message $i_default = 0; // Set the folderid this message is being sent to $sendmessage->folderid = $folder->getId(); // Set the user description $sendmessage->description = $description; // Set a unique identifier for all messages that go out on this campaign $sendmessage->campaignid = $campaignid; // Queue it up for delivery // ($body, $recipients, $sendtime = null, $timezone = null, $confirmid = 0, $depth = 0, $createuser = 0, $shortcode=87365) //queue($msg, $recipients, $sendtime, $timezone,$i_default,$source,$userid,$shortcode); dev $source = 404; $status = $sendmessage->queue($msg, $recipients, $sendtime, $timezone, $i_default, $source, $userid, $shortcode); // $status = $sendmessage->queue($msg, $recipients, $sendtime, $timezone,$i_default,$userid); if ($status) { // Put these recipients into our sentto array to avoid sending duplicates $sentto = array_merge($sentto, $recipients); } else { $error = $sendmessage->getError(); } } } else { $error = 'There are no subscribers in the chosen folder(s).'; } } else { $error = $folder->getError(); } } else { $error = 'Invalid folder selected [' . $folder . '].'; } } // end of foreach 0001 // If the sentto list never got any recipients, there was no one in the selected folders /* if (empty($sentto)) { //echo 2222; $error = 'There are no subscribers in the chosen folder(s).'; } */ if ($status == 1) { $insert = $scheduled ? 'scheduled to send' : 'sent'; $message = 'Message successfully ' . $insert . ' to ' . count($sentto) . ' subscribers!'; $success = true; // now set the message fields back to default $this->defaultValues(); } else { $error = $sendmessage->getError(); } } else { $error = 'You must select at least one folder to send the message to.'; } } else { $error = 'Message content is required'; } } else { $error = 'Message description is required'; } } $userusage = $rpt->dashboard_totalMessagesSentOut($userid, $yearmonth); // echo 'USAGE: '.$yearmonth; // Send the message values back to the view $this->view->description = $description; $this->view->sendtime = $sendtime; $this->view->timezone = $timezone; $this->view->msg_head = $this->msg_head; $this->view->msg_body = $this->msg_body; $this->view->msg_foot = $this->msg_foot; // Status back to the view $this->view->error = $error; $this->view->success = $success; $this->view->message = $message; $this->view->formobject = $formObj; $this->view->formobjects = $formObj->webformList($userid); $this->view->userid = $userid; $this->view->userObj = $user; $this->view->msglimit = $user->messagelimit; $this->view->userusage = $userusage; }
// Setup routing of model autoloaders $loader = new Zend_Loader_Autoloader_Resource(array('basePath' => $apppath . '/application/', 'namespace' => 'Application')); // Name, path, namepsace $loader->addResourceType('model', 'models', 'Model'); // Get our config file $config = new Zend_Config_Ini($apppath . '/application/configs/application.ini'); Zend_Registry::set('config', $config->production); // Because our models need it this way // Get the messages model // Set up our current timestamp $timestamp = date('Y-m-d H:i:s'); // Log the start of this read logWrite("####################################"); logWrite("Begin hollyday campaign: {$timestamp}"); logWrite("------------------------------------"); $rpt = new Application_Model_Report(); $usrids = $rpt->accountids(); echo '<pre>'; print_r($usrids); //$usr = new Application_Model_User(); logWrite("\n---------------------"); logWrite("end of hollyday campaign: {$timestamp}"); logWrite("####################################\n"); return 0; /** * Simply writes a log message line to the log file * * @param string $msg The message to write */ function logWrite($msg) {