16 public $layout =
false;
24 public function actionAdd($url, $title, $page_id, $additional, $key, $back_to_referer)
28 'title'=> $_GET[
'title'],
29 'page_id'=> $_GET[
'page_id'],
30 'additional' => $_GET[
'additional'],
31 'back_to_referer' => (
boolean) $_GET[
'back_to_referer'],
34 if($this->module->sign(serialize($data)) !== $key) {
35 throw new CHttpException(400,
'Invalid key');
39 $rememberedPage->collection_id = Yii::app()->getModule(
'remember')->getUserCollectionId();
41 $rememberedPage->url = $url;
42 $rememberedPage->title = $title;
43 $rememberedPage->page_id = $page_id;
44 $rememberedPage->additional = unserialize($additional);
46 if(!$rememberedPage->save()){
48 throw new CHttpException(400,
'Internal error');
50 $this->redirect($back_to_referer ===
'true' ? Yii::app()->request->getUrlReferrer() : $url);
58 public function actionShareByMail()
61 if(isset($_POST[
'ShareMailForm'])){
62 $mailForm->attributes = $_POST[
'ShareMailForm'];
65 if($mailForm->validate()) {
68 $mail->SetFrom($this->module->shareByMailEmail);
69 $mail->AddAddress($mailForm->email);
70 $mail->Subject = $this->module->shareByMailSubject;
72 $subject = $this->module->shareByMailSubject;
75 $mailurls_msg = $mailForm->links;
76 $mailurls_ = explode(
'<a href="http',$mailForm->links);
77 foreach($mailurls_ as $mailurls__){
78 $end = explode(
'"',$mailurls__);
79 if (trim($end[0]) !=
"" && strstr($end[0],$this->module->allowedURL) && !in_array(trim(
"http".$end[0]), $mailurls)){
80 $mailurls[] = trim(
"http".$end[0]);
84 if (
sizeof($mailurls) > 0){
85 $mail->AddStringAttachment($this->actionLoadPdf($mailurls), $this->module->pdfname);
88 $msg = $this->renderPartial(
'/mail_templates/share_by_email', array(
'links'=>$mailurls_msg,
'description' => $mailForm->description),
true);
89 $mail->MsgHTML(utf8_decode($msg));
93 echo CActiveForm::validate($mailForm);
102 public function actionDownloadPdf()
105 $mailurls_ = explode(
' ',Yii::app()->request->getParam(
"links",
""));
106 foreach($mailurls_ as $mailurls__){
107 if (trim($mailurls__) !=
"" && strstr($mailurls__,$this->module->allowedURL) && !in_array(trim($mailurls__), $mailurls)){
108 $mailurls[] = trim($mailurls__);
111 if (
sizeof($mailurls) > 0){
112 header(
"Content-Type: application/pdf");
113 header(
"Content-disposition: attachment; filename=".$this->module->pdfname);
114 header(
"Pragma: no-cache");
115 echo $this->actionLoadPdf($mailurls);
123 public function actionLoadPdf($mailurls)
125 $filename = $this->module->tmpFolder.md5(date(DATE_RFC822).join(
"",$mailurls)).
".pdf";
126 $statement =
"wkhtmltopdf-amd64 -n --zoom 1 --page-width 1280px --footer-center \[page\] -T 14mm -B 14mm -L 14mm -R 14mm --disable-external-links --disable-internal-links ".join(
" ",$mailurls).
" ".$filename;#--disable-smart-shrinking
128 $out = file_get_contents($filename);
140 $id = Yii::app()->request->getQuery(
'id',
'');
141 $isAjax = Yii::app()->request->isAjaxRequest;
142 $collectionId = Yii::app()->getModule(
'remember')->getUserCollectionId();
144 $ids = explode(
",",$id);
145 foreach($ids as $id){
148 if($rememberedPage && $rememberedPage->collection_id == $collectionId){
149 $rememberedPage->delete();
151 throw new CHttpException(400);
155 if(isset($_SERVER[
'HTTP_REFERER'])){
156 $this->redirect($_SERVER[
'HTTP_REFERER']);
159 echo json_encode(array(
'status'=>
'success'));