public function beforeSave() { parent::beforeSave(); if ($this->isNewRecord) { // custom qr code if ($this->qr_type == 'custom') { $this->dot = 'QrTagDotSquare'; $this->frame_dot = 'QrTagFrameDotSquare'; $this->frame = 'QrTagFrameSquare'; $this->dotColor = '000000'; $this->frame_dotColor = '000000'; $this->frameColor = '000000'; $this->backgroundColor = 'ffffff'; } $this->created_at = new CDbExpression('NOW()'); $this->updated_at = new CDbExpression('NOW()'); $this->show_in_gallery = 0; /* $url = $this->getSystem_tag_url(); if(Utility::isBitlyActive()) { if($bitlyUrl = Utility::getBitlyUrl($url)) { $url = $bitlyUrl; } } $this->tag_url = $url; */ } else { $this->updated_at = new CDbExpression('NOW()'); } // get only related attributes according to the QR Type and refill the serialized data attribute if (is_array($this->data)) { $newData = array(); foreach ($this->data as $attribute => $value) { if (Utility::beginsWith($attribute, $this->type . '_data')) { $newData[$this->type][substr($attribute, strlen($this->type . '_data') + 1)] = $value; } } $newData = array_map('strip_tags', array_pop($newData)); $this->data = serialize(array($newData)); } return true; }
public function actionTag() { // set theme $theme_name = 'mobile'; Yii::app()->theme = $theme_name; ##################################################################################################### $id = Yii::app()->request->getParam('id'); $id = Utility::getIDFromTag($id); $qr = $this->loadModel($id); if ($qr->user->is_active == 0) { $this->redirect(Yii::app()->homeUrl); } $log = new Log(); $log->qr_id = $id; Yii::app()->session['mqr_id'] = $id; $log->save(); switch ($qr->type) { case 'website': Yii::app()->request->redirect($qr->qrData->url); break; case 'facebook_profile': Yii::app()->request->redirect($qr->qrData->url); break; case 'twitter_profile': Yii::app()->request->redirect($qr->qrData->url); break; case 'twitter_status': if (preg_match('@^(https?://)?(www\\.)?twitter\\.com@', strtolower($qr->qrData->tweet))) { if (!Utility::beginsWith(strtolower($qr->qrData->tweet), 'http://') && !Utility::beginsWith(strtolower($qr->qrData->tweet), 'https://')) { Yii::app()->request->redirect('http://' . $qr->qrData->tweet); } Yii::app()->request->redirect($qr->qrData->tweet); } else { Yii::app()->request->redirect('http://twitter.com/home?status=' . urlencode($qr->qrData->tweet)); } break; case 'linkedin_profile': Yii::app()->request->redirect($qr->qrData->url); break; case 'linkedin_share': Yii::app()->request->redirect($qr->qrData->url); break; case 'telephone': header('Location: tel:' . $qr->qrData->number); exit; case 'email': header('Location: mailto:' . $qr->qrData->email); exit; case 'email_msg': header('Location: mailto:' . $qr->qrData->email . '?subject=' . $qr->qrData->subject . '&body=' . $qr->qrData->body); exit; case 'sms': header('Location: sms:' . $qr->qrData->number); exit; } $model = new Email(); if (isset($_POST['Email'])) { $model->attributes = $_POST['Email']; $model->ip = $_SERVER['REMOTE_ADDR']; $model->timestamp = date("Y-m-d H:m:s"); $model->browser = Yii::app()->wurfl->device->getCapability('mobile_browser'); $model->created_at = date("Y-m-d H:m:s"); if (empty($model->browser)) { $browser = new EWebBrowser(); $model->browser = $browser->browser; } if ($model->save()) { Yii::app()->user->setFlash('contact', 'Thank you for contacting us.'); $this->redirect(Yii::app()->request->getParam('id')); } } $this->render('tag', array('qr' => $qr, 'model' => $model)); }
public static function installedShapes() { $path = getcwd() . DIRECTORY_SEPARATOR . "shapes" . DIRECTORY_SEPARATOR . "images" . DIRECTORY_SEPARATOR; $out = array(); // get all dots $i = 0; $shapes = glob($path . 'QrTagDot*.png'); foreach ($shapes as $shape) { $filename = pathinfo($shape, PATHINFO_FILENAME); $out['dots'][$filename == 'QrTagDotSquare' ? count($shapes) + 1 : $i++] = $filename; } // get all frames $shapes = glob($path . 'QrTagFrame*.png'); $i = 0; $ii = 0; foreach ($shapes as $shape) { $filename = pathinfo($shape, PATHINFO_FILENAME); if (Utility::beginsWith($filename, 'QrTagFrameDot')) { // $out['frame_dots'][$i++] = $filename; $out['frame_dots'][$filename == 'QrTagFrameDotSquare' ? count($shapes) + 1 : $i++] = $filename; } else { // $out['frames'][$ii++] = $filename; $out['frames'][$filename == 'QrTagFrameSquare' ? count($shapes) + 1 : $ii++] = $filename; } } krsort($out['dots']); krsort($out['frame_dots']); krsort($out['frames']); return $out; }
public function actionTag() { // set theme $theme_name = 'mobile'; Yii::app()->theme = $theme_name; ##################################################################################################### $id = Yii::app()->request->getParam('id'); $id = Utility::getIDFromTag($id); $qr = $this->loadModel($id); if ($qr->user->is_active == 0) { $this->redirect(Yii::app()->homeUrl); } $log = new Log(); $log->qr_id = $id; $log->save(); switch ($qr->type) { case 'website': Yii::app()->request->redirect($qr->qrData->url); break; case 'facebook_profile': Yii::app()->request->redirect($qr->qrData->url); break; case 'twitter_profile': Yii::app()->request->redirect($qr->qrData->url); break; case 'twitter_status': if (preg_match('@^(https?://)?(www\\.)?twitter\\.com@', strtolower($qr->qrData->tweet))) { if (!Utility::beginsWith(strtolower($qr->qrData->tweet), 'http://') && !Utility::beginsWith(strtolower($qr->qrData->tweet), 'https://')) { Yii::app()->request->redirect('http://' . $qr->qrData->tweet); } Yii::app()->request->redirect($qr->qrData->tweet); } else { Yii::app()->request->redirect('http://twitter.com/home?status=' . urlencode($qr->qrData->tweet)); } break; case 'linkedin_profile': Yii::app()->request->redirect($qr->qrData->url); break; case 'linkedin_share': Yii::app()->request->redirect($qr->qrData->url); break; case 'telephone': header('Location: tel:' . $qr->qrData->number); exit; case 'email': header('Location: mailto:' . $qr->qrData->email); exit; case 'email_msg': header('Location: mailto:' . $qr->qrData->email . '?subject=' . $qr->qrData->subject . '&body=' . $qr->qrData->body); exit; case 'sms': header('Location: sms:' . $qr->qrData->number); exit; } $this->render('tag', array('qr' => $qr)); }