Пример #1
1
 protected function action()
 {
     $msg = new SysMsg();
     $plan = new Unilevel();
     $plan->setLevel(mysql_real_escape_string($_POST['level']));
     $plan->setDescription(mysql_real_escape_string($_POST['desc']));
     $mycomm = floatval(preg_replace("/[^-0-9\\.]/", ".", mysql_real_escape_string($_POST['comm'])));
     $plan->setCommission($mycomm);
     $redirect = 'user/fancymessage';
     if ($plan->getLevel() > 0 && $plan->getDescription() != '' && $plan->getCommission() > 0) {
         if ($plan->save()) {
             $redirect = 'user/addplanunilevel';
         } else {
             Session::setObj(Session::SYSMSG, $msg->setMessage('Inserimento piano Unilevel fallito.')->setType(SysMsg::MSG_CRITICAL));
         }
     } else {
         Session::setObj(Session::SYSMSG, $msg->setMessage('Tutti i campi sono obbligatori. Inserimento piano Unilevel fallito.')->setType(SysMsg::MSG_CRITICAL));
     }
     //***
     $this->redirect = $redirect;
 }
Пример #2
0
 protected function action()
 {
     //Autenticazione Utente
     $msg = new SysMsg();
     $user = new Utente();
     $user->setParent(mysql_real_escape_string($_POST['parent']));
     $user->setNome(mysql_real_escape_string(ucfirst($_POST['nome'])));
     $user->setCognome(mysql_real_escape_string(ucfirst($_POST['cognome'])));
     $user->setEmail(mysql_real_escape_string($_POST['email']));
     $user->setUsername(mysql_real_escape_string($_POST['username']));
     $user->setPassword(mysql_real_escape_string($_POST['password']));
     if ($user->getNome() != '' && $user->getCognome() != '' && $user->getEmail() != '' && $user->getUsername() != '' && $user->getPassword() != '') {
         if ($user->save()) {
             $user->login();
             //Pone in sessione user (se autenticato)e message
             if ($user->isAutenticated()) {
                 Session::setObj(Session::UTENTE, $user);
             }
             //***
             Session::setObj(Session::SYSMSG, $msg->setMessage('Inserimento utente avvenuto correttamente.')->setType(SysMsg::MSG_OK));
         } else {
             Session::setObj(Session::SYSMSG, $msg->setMessage('Inserimento utente fallito.')->setType(SysMsg::MSG_CRITICAL));
         }
     } else {
         Session::setObj(Session::SYSMSG, $msg->setMessage('Tutti i campi sono obbligatori. Inserimento utente fallito.')->setType(SysMsg::MSG_ALERT));
     }
     //***
     $this->redirect = "user/fancymessage";
 }
Пример #3
0
 protected function action()
 {
     //Salvataggio nuovo avatar Utente
     $user = Session::getObj(Session::UTENTE);
     $msg = new SysMsg();
     $avatar = new Avatar($_FILES["browse"]);
     $this->redirect = "user/adduseravatar";
     $abort = 0;
     if (!($avatar->isValidType() && $avatar->isValidExtension())) {
         Session::setObj(Session::SYSMSG, $msg->setMessage('Formato file immagine non ammesso. [png - jpeg - gif]')->setType(SysMsg::MSG_ALERT));
         $this->redirect = "user/fancymessage";
         $abort = 1;
     }
     if (!$avatar->isValidSize()) {
         Session::setObj(Session::SYSMSG, $msg->setMessage('Dimensione file immagine non ammessa. [Max ' . Avatar::MAX_FILE_SIZE . ']')->setType(SysMsg::MSG_ALERT));
         $this->redirect = "user/fancymessage";
         $abort = 1;
     }
     if (!$avatar->noErrorDetected()) {
         Session::setObj(Session::SYSMSG, $msg->setMessage('Impossibile aprire il file immagine. Errore generico.')->setType(SysMsg::MSG_ALERT));
         $this->redirect = "user/fancymessage";
         $abort = 1;
     }
     if (!$abort) {
         $avatar->save($user->getId());
     }
 }
Пример #4
0
 protected function action()
 {
     //Logout Utente
     $msg = new SysMsg();
     Session::destroyObj(Session::UTENTE);
     Session::setObj(Session::SYSMSG, $msg->setMessage("Logout eseguito correttamente.")->setType(SysMsg::MSG_OK));
     //***
     $this->redirect = "user/message";
 }
Пример #5
0
 protected function action()
 {
     //Autenticazione Utente
     $msg = new SysMsg();
     $user = new Utente(Session::getObj(Session::NETWORKER)->getId());
     $user->setNome(filter_var(ucfirst($_POST['nome']), FILTER_SANITIZE_STRING));
     $user->setCognome(filter_var(ucfirst($_POST['cognome']), FILTER_SANITIZE_STRING));
     $user->setEmail(filter_var($_POST['email'], FILTER_SANITIZE_STRING));
     $user->setUsername(filter_var($_POST['username'], FILTER_SANITIZE_STRING));
     $user->setPassword(filter_var($_POST['password'], FILTER_SANITIZE_STRING));
     $user->update() ? Session::setObj(Session::SYSMSG, $msg->setMessage("Utente aggiornato correttamente.")->setType(SysMsg::MSG_OK)) : Session::setObj(Session::SYSMSG, $msg->setMessage("Aggiornamento utente fallito.")->setType(SysMsg::MSG_CRITICAL));
     //***
     Session::destroyObj(Session::NETWORKER);
     $this->redirect = "user/fancymessage";
 }
Пример #6
0
 public static function getModel()
 {
     if (!self::$_model) {
         self::$_model = ClassRegistry::init("SystemMessage");
     }
     return self::$_model;
 }
Пример #7
0
 public function returnImagesByTag($tag = "berrics", $limit = 100)
 {
     $token = "instagram-images-by-tag-" . md5($tag);
     if (($data = Cache::read($token, "1min")) === false) {
         $i = InstagramApi::berricsInstance();
         $images = $i->instagram->getRecentTags($tag);
         $images = json_decode($images, true);
         foreach ($images['data'] as $k => $v) {
             //check to see if there is an instagra object
             $check = $this->find("first", array("conditions" => array("InstagramImageItem.instagram_object_id" => $v['id']), "contain" => array()));
             if (!isset($check['InstagramImageItem']['id'])) {
                 $this->create();
                 $this->save(array("instagram_object_id" => $v['id'], "active" => 1));
                 $obj_id = $this->id;
             } else {
                 $obj_id = $check['InstagramImageItem']['id'];
             }
             $this->create();
             $this->id = $obj_id;
             $d = array("InstagramImageItem" => array("created_time" => date('Y-m-d H:i:s', $v['created_time']), "link" => $v['link'], "likes" => $v['likes']['count'], "instagram_object_id" => $v['id'], "caption" => $v['caption']['text'], "filter" => $v['filter'], "images" => serialize($v['images']), "instagram_account_num" => $v['user']['id']));
             $tags = implode(",", $v['tags']);
             $d['Tag'] = $this->Tag->parseTags($tags);
             $this->saveAll($d);
         }
         SysMsg::add(array("category" => "Instragram", "title" => "Retrieve Images By Tag: " . $tag, "from" => "InstagramImageItem"));
         $data = $this->Tag->find("all", array("conditions" => array(), "contain" => array("InstagramImageItem"), "limit" => $limit));
         Cache::write($token, $data, "1min");
     }
     return $data;
 }
Пример #8
0
 protected function action()
 {
     $msg = new SysMsg();
     $sale = new Vendita();
     $sale->setNetworker(mysql_real_escape_string($_POST['idntwrkr']));
     $sale->setDateSale(mysql_real_escape_string($_POST['datepicker']));
     $myamount = floatval(preg_replace("/[^-0-9\\.]/", ".", mysql_real_escape_string($_POST['importo'])));
     $sale->setAmount($myamount);
     if ($sale->getNetworker() > 0 && $sale->getDateSale() != '' && $sale->getAmount() > 0) {
         $sale->save() ? Session::setObj(Session::SYSMSG, $msg->setMessage('Inserimento nuova vendita avvenuto correttamente.')->setType(SysMsg::MSG_OK)) : Session::setObj(Session::SYSMSG, $msg->setMessage('Inserimento nuova vendita fallito.')->setType(SysMsg::MSG_CRITICAL));
     } else {
         Session::setObj(Session::SYSMSG, $msg->setMessage('Tutti i campi sono obbligatori. Inserimento nuova vendita fallito.')->setType(SysMsg::MSG_CRITICAL));
     }
     //***
     $this->redirect = "user/fancymessage";
 }
Пример #9
0
 public function export()
 {
     SysMsg::add(array("title" => "Start La Jolla Order Send", "category" => "LjgOrderFile", "from" => "LjgShell", "crontab" => 1));
     $file_id = $this->CanteenShippingRecord->ljg_process_pending();
     $this->CanteenShippingRecord->ljg_create_orders_file($file_id);
     $this->CanteenShippingRecord->ljg_ftp_file($file_id);
     SysMsg::add(array("title" => "End La Jolla Order Send", "category" => "LjgOrderFile", "from" => "LjgShell", "crontab" => 1));
 }
Пример #10
0
 protected function action()
 {
     //Autenticazione Utente
     $msg = new SysMsg();
     $user = new Utente(Session::getObj(Session::UTENTE)->getId());
     $user->setNome(filter_var($_POST['nome'], FILTER_SANITIZE_STRING));
     $user->setCognome(filter_var($_POST['cognome'], FILTER_SANITIZE_STRING));
     $user->setEmail(filter_var($_POST['email'], FILTER_SANITIZE_STRING));
     $user->setUsername(filter_var($_POST['username'], FILTER_SANITIZE_STRING));
     $user->setPassword(filter_var($_POST['password'], FILTER_SANITIZE_STRING));
     if ($user->update()) {
         //Pone in sessione user
         Session::setObj(Session::UTENTE, $user);
         Session::setObj(Session::SYSMSG, $msg->setMessage("Utente aggiornato correttamente.")->setType(SysMsg::MSG_OK));
     } else {
         Session::setObj(Session::SYSMSG, $msg->setMessage("Aggiornamento utente fallito.")->setType(SysMsg::MSG_CRITICAL));
     }
     //***
     $this->redirect = "user/fancymessage";
 }
Пример #11
0
 public function process_queue()
 {
     //grab 50 emails
     $emails = $this->EmailMessage->find("all", array("conditions" => array("EmailMessage.processed" => 0), "contain" => array()));
     SysMsg::add(array("category" => "Emailer", "from" => "MailerShell", "crontab" => 1, "title" => "Emails to processes: " . count($emails)));
     $success = 0;
     foreach ($emails as $msg) {
         $this->controller->set(compact("msg"));
     }
     SysMsg::add(array("category" => "Emailer", "from" => "MailerShell", "crontab" => 1, "title" => "Email Send Results: Success ({$success}) Total (" . count($emails) . ")"));
 }
Пример #12
0
 public function save_xe_currency_file()
 {
     $url = 'http://www.xe.com/dfs/datafeed2.cgi?theberricsllc';
     $ch = curl_init($url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     $file_str = curl_exec($ch);
     curl_close($ch);
     $handle = fopen("/tmp/currency.xml", "w");
     fwrite($handle, $file_str);
     fclose($handle);
     SysMsg::add(array("title" => "Downloaded XE currency XML file", "category" => "CurrencyUpdate", "from" => "Currency", "message" => $file_str));
 }
Пример #13
0
 protected function action()
 {
     $msg = new SysMsg();
     $rdrct = "user/message";
     if ($_POST['username'] != "" && $_POST['password'] != "") {
         //Autenticazione Utente
         $user = new Utente();
         $user->setUsername(filter_var($_POST['username'], FILTER_SANITIZE_STRING));
         $user->setPassword(filter_var($_POST['password'], FILTER_SANITIZE_STRING));
         $user->login();
         //Pone in sessione user (se autenticato)e message
         if ($user->isAutenticated()) {
             Session::setObj(Session::UTENTE, $user);
             Session::setObj(Session::SYSMSG, $msg->setMessage('Benvenuto ' . $user->getNome() . ' ' . $user->getCognome())->setType(SysMsg::MSG_OK)->addParameter('useravatar', $user->getAvatarUrl()));
             $rdrct = "user/welcome";
         } else {
             Session::setObj(Session::SYSMSG, $msg->setMessage('Username/Password errati. Login fallito.')->setType(SysMsg::MSG_CRITICAL));
         }
     } else {
         Session::setObj(Session::SYSMSG, $msg->setMessage('Username/Password non inseriti. Login fallito.')->setType(SysMsg::MSG_ALERT));
     }
     //***
     $this->redirect = $rdrct;
 }
Пример #14
0
 public function build_facts($date = false, $hour = false)
 {
     ini_set('memory_limit', '512M');
     set_time_limit(0);
     if (isset($this->params['date'])) {
         $date = $this->params['date'];
     } else {
         $date = date("Y-m-d");
     }
     if (isset($this->params['hour'])) {
         $hour = $this->params['hour'];
     } else {
         $hour = date('H', time());
     }
     $hour = $hour . ":00:00";
     $this->out("Media View ETL: " . $date . " " . $hour);
     SysMsg::add(array("category" => "TrafficReports", "from" => "MediaEtlShell", "title" => "Processing Media View ETL: " . $date . " " . $hour, "crontab" => 1));
     //die("-stopped");
     $this->populateDimDates($date);
     $this->populateDimLocations($date, $hour);
     $loop = true;
     while ($loop) {
         $views = $this->MediaFileView->find('all', array("conditions" => array("MediaFileView.created < '{$date} {$hour}'"), "limit" => 5000, "order" => array("MediaFileView.created" => "DESC")));
         if (count($views) > 0) {
             foreach ($views as $v) {
                 $row = array();
                 $row['dim_location_id'] = $this->DimLocation->returnLocationId($v['MediaFileView']['geo_country'], $v['MediaFileView']['geo_region']);
                 $row['dim_date_id'] = $this->DimDate->returnDateId($v['MediaFileView']['created']);
                 $row['mobile'] = $v['MediaFileView']['mobile'];
                 $row['media_file_id'] = $v['MediaFileView']['media_file_id'];
                 $this->FactMediaView->create();
                 $this->FactMediaView->save($row);
                 $this->out(print_r($row));
             }
             $this->MediaFileView->query("DELETE FROM media_file_views WHERE created < '{$date} {$hour}' ORDER BY created DESC LIMIT 5000");
             unset($pageViews);
         } else {
             $loop = false;
             continue;
         }
     }
     SysMsg::add(array("category" => "TrafficReports", "from" => "MediaEtlShell", "title" => "Completed Media View ETL: " . $date . " " . $hour, "crontab" => 1));
 }
Пример #15
0
 public function build_facts($date = false, $hour = false)
 {
     if (isset($this->params['date'])) {
         $date = $this->params['date'];
     } else {
         $date = date("Y-m-d");
     }
     if (isset($this->params['hour'])) {
         $hour = $this->params['hour'];
     } else {
         $hour = date('H', time());
     }
     $hour = $hour . ":00:00";
     $this->hr();
     SysMsg::add(array("category" => "TrafficReports", "from" => "TrafficEtlShell", "title" => "Processing ETL for: " . $date . " " . $hour, "crontab" => 1));
     $this->out("Processing ETL for: " . $date . " " . $hour);
     $this->hr();
     $this->build_dimensions($date, $hour);
     $this->out("Fact Page Views");
     $this->populateFactPageViews($date, $hour);
     $this->out("Completed ETL for: " . $date . " " . $hour);
     SysMsg::add(array("category" => "TrafficReports", "from" => "TrafficEtlShell", "title" => "Completed ETL for: " . $date . " " . $hour, "crontab" => 1));
 }
Пример #16
0
 public function hit_linter()
 {
     //grab the last 20 published posts
     $msg = "";
     $posts = $this->Dailyop->find("all", array("conditions" => array("Dailyop.publish_date<NOW()", "Dailyop.active" => 1), "contain" => array("DailyopSection"), "limit" => 20, "order" => array("Dailyop.publish_date" => "DESC")));
     foreach ($posts as $post) {
         //let's make the URL
         $url = "http://theberrics.com/" . $post['DailyopSection']['uri'] . "/" . $post['Dailyop']['uri'];
         $this->out("++++++++++++++++++++++++++++++++++");
         $this->out("Linting Url: " . $url);
         $url_enc = urlencode($url);
         $c = curl_init();
         curl_setopt($c, CURLOPT_FOLLOWLOCATION, true);
         curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($c, CURLOPT_URL, "https://developers.facebook.com/tools/lint/?url={$url_enc}&format=json");
         $res = curl_exec($c);
         $this->out("Response: " . $res);
         SysMsg::add(array("category" => "Facebook", "crontab" => 1, "from" => "FacebookShell", "title" => "Linting URL: " . $url, "message" => $res));
         $this->out("++++++++++++++++++++++++++++++++++");
         $this->out("Sleeping.....zzz.z.z.z.z");
         sleep(3);
     }
 }
 public function ljg_ftp_file($id)
 {
     $ljg_file = ClassRegistry::init("LjgFile");
     $record = $ljg_file->findById($id);
     $conn = ftp_connect($this->ljg_ftp['ip']);
     if (ftp_login($conn, $this->ljg_ftp['login'], $this->ljg_ftp['pass'])) {
         ftp_chdir($conn, "r");
         ftp_pasv($conn, true);
         ftp_put($conn, $record['LjgFile']['file_name'], "/tmp/" . $record['LjgFile']['file_name'], FTP_BINARY);
         ftp_close($conn);
         SysMsg::add(array("category" => "LjgOrderFile", "from" => "CanteenShippingRecord", "message" => "Uploaded: " . $record['LjgFile']['file_name'], "title" => "Uploaded: " . $record['LjgFile']['file_name']));
     } else {
         SysMsg::add(array("category" => "LjgOrderFile", "from" => "CanteenShippingRecord", "message" => "Error Connecting to FTP", "title" => "Error Connecting to FTP"));
     }
 }
Пример #18
0
 public function updateInstagramDetails($User = array(), $crontab = false)
 {
     if (!isset($User['id']) || !isset($User['instagram_handle']) || (empty($User['id']) || empty($User['instagram_handle']))) {
         return false;
     }
     App::import("Vendor", "InstagramApi", array("file" => "instagram/instagram_api.php"));
     $i = InstagramApi::berricsInstance();
     $search = $i->instagram->searchUser($User['instagram_handle']);
     $insta = json_decode($search, true);
     $udata = array();
     $udata['instagram_account_num'] = $insta['data'][0]['id'];
     $udata['instagram_profile_image'] = $insta['data'][0]['profile_picture'];
     //update the users profile with the instagram info
     $this->create();
     $this->id = $User['id'];
     $this->save($udata);
     $instaData = $i->instagram->getUser($udata['instagram_account_num']);
     $instaData = json_decode($instaData, true);
     $profile = $this->ensure_user_profile($User['id']);
     $this->UserProfile->create();
     $this->UserProfile->id = $profile['UserProfile']['id'];
     $this->UserProfile->save(array("instagram_followers" => $instaData['data']['counts']['followed_by'], "instagra_last_updated" => 'NOW()'));
     SysMsg::add(array("category" => "Instagram", "from" => "UserModel", "title" => "Update Instagram: " . $User['instagram_handle'], "crontab" => $crontab));
 }
Пример #19
0
 public function mp4_to_ogv($VideoTask)
 {
     $this->create();
     $this->id = $VideoTask['VideoTask']['id'];
     $this->save(array("task_status" => "working"));
     //import objects
     $MediaFile = ClassRegistry::init("MediaFile");
     App::import("Vendor", "LLFTP", array("LLFTP.php"));
     $video = $MediaFile->find("first", array("conditions" => array("MediaFile.id" => $VideoTask['VideoTask']['foreign_key']), "contain" => array()));
     $llftp = new LLFTP();
     //let's download the video to tmp
     $tmp_file = $MediaFile->downloadVideoToTmp($VideoTask['VideoTask']['foreign_key']);
     $this->query("SET SESSION wait_timeout = 28800");
     $newFileName = str_replace(".mp4", ".ogv", $video['MediaFile']['limelight_file']);
     $newFilePath = "/home/sites/tmpfiles/" . $newFileName;
     $cmd = "/usr/bin/ffmpeg2theora {$tmp_file} -o {$newFilePath} --audioquality 5";
     SysMsg::add(array("category" => "Mp4ToOgv", "from" => "VideoTask", "crontab" => 1, "title" => $cmd));
     $this->getDatasource()->disconnect();
     $MediaFile->getDatasource()->disconnect();
     $output = `{$cmd}`;
     $this->getDatasource()->connect();
     $MediaFile->getDatasource()->connect();
     //ftp the file
     $llftp->ftpFile($newFileName, $newFilePath);
     //update the video file
     $MediaFile->create();
     $MediaFile->id = $video['MediaFile']['id'];
     $MediaFile->save(array("limelight_file_ogv" => $newFileName));
     $this->create();
     $this->id = $VideoTask['VideoTask']['id'];
     $this->save(array("task_status" => "completed"));
 }
Пример #20
0
 public function process_queue()
 {
     $this->loadModel("EmailMessage");
     //grab 50 emails
     $emails = $this->EmailMessage->find("all", array("conditions" => array("EmailMessage.processed" => 0), "contain" => array()));
     SysMsg::add(array("category" => "Emailer", "from" => "MailerShell", "crontab" => 1, "title" => "Emails to processes: " . count($emails)));
     $success = 0;
     foreach ($emails as $msg) {
         $e = $msg['EmailMessage'];
         //die(print_r($e));
         $this->Email->reset();
         $this->Email->to = "*****@*****.**";
         $this->Email->from = $e['from'];
         $this->Email->subject = $e['subject'];
         //$this->Email->cc = explode(",",$e['cc']);
         $this->Email->bcc = $e['bcc'];
         $this->Email->sendAs = $e['send_as'];
         $this->Email->template = $e['template'];
         $this->Email->smtpOptions = array('port' => '25', 'timeout' => '30', 'host' => 'smtp.com', 'username' => '*****@*****.**', 'password' => 'artosari');
         $this->Email->delivery = 'smtp';
         $this->set(compact("msg"));
         if ($this->Email->send()) {
             $this->EmailMessage->create();
             $this->EmailMessage->id = $e['id'];
             $this->EmailMessage->save(array("processed" => 1, "sent_date" => "NOW()"));
             $success++;
         } else {
             //print_r($this->Email);
             die($this->Email->smtpError);
             SysMsg::add(array("category" => "Emailer", "from" => "MailerShell", "crontab" => 1, "title" => "Email Failure - Message ID: {$e['id']}"));
         }
     }
     SysMsg::add(array("category" => "Emailer", "from" => "MailerShell", "crontab" => 1, "title" => "Email Send Results: Success ({$success}) Total (" . count($emails) . ")"));
 }