File indexing completed on 2024-05-12 05:58:40

0001 <?php
0002 
0003 /**
0004  *  ocs-webserver
0005  *
0006  *  Copyright 2016 by pling GmbH.
0007  *
0008  *    This file is part of ocs-webserver.
0009  *
0010  *    This program is free software: you can redistribute it and/or modify
0011  *    it under the terms of the GNU Affero General Public License as
0012  *    published by the Free Software Foundation, either version 3 of the
0013  *    License, or (at your option) any later version.
0014  *
0015  *    This program is distributed in the hope that it will be useful,
0016  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
0017  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0018  *    GNU Affero General Public License for more details.
0019  *
0020  *    You should have received a copy of the GNU Affero General Public License
0021  *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
0022  **/
0023 class ReportController extends Zend_Controller_Action
0024 {
0025 
0026     public function commentAction()
0027     {
0028         $this->_helper->layout()->disableLayout();
0029         if ((APPLICATION_ENV != 'searchbotenv') AND (false == SEARCHBOT_DETECTED)) {
0030             $comment_id = (int)$this->getParam('i');
0031             $project_id = (int)$this->getParam('p');
0032             $reported_by =
0033                 Zend_Auth::getInstance()->hasIdentity() ? (int)Zend_Auth::getInstance()->getStorage()->read()->member_id
0034                     : 0;
0035             
0036             $clientIp = null;
0037             $clientIp2 = null;
0038             if(isset($_SERVER['REMOTE_ADDR'])) {
0039                 $clientIp = $_SERVER['REMOTE_ADDR'];
0040             }
0041             if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
0042                 $clientIp2 = $_SERVER['HTTP_X_FORWARDED_FOR'];
0043             }
0044 
0045             $tableReportComments = new Default_Model_DbTable_ReportComments();
0046             
0047             $commentReportArray = $tableReportComments->fetchAll('comment_id = ' . $comment_id . ' AND user_ip = "' . $clientIp . '"');
0048             
0049             if(isset($commentReportArray) && count($commentReportArray) > 0) {
0050                 $this->_helper->json(array(
0051                     'status'  => 'ok',
0052                     'message' => '<p>You have already submitted a report for this comment.</p><div class="modal-footer">
0053                                             <button type="button" style="border:none;background: transparent;color: #2673b0;" class="small close" data-dismiss="modal" > Close</button>
0054                                         </div>',
0055                     'data'    => array()
0056                 ));
0057             } else {
0058                 $tableReportComments->save(array('project_id'  => $project_id,
0059                                                  'comment_id'  => $comment_id,
0060                                                  'reported_by' => $reported_by,
0061                                                  'user_ip' => $clientIp,
0062                                                  'user_ip2' => $clientIp2
0063                 ));
0064                 $this->_helper->json(array(
0065                     'status'  => 'ok',
0066                     'message' => '<p>Thank you for helping us to keep these sites SPAM-free.</p><div class="modal-footer">
0067                                             <button type="button" style="border:none;background: transparent;color: #2673b0;" class="small close" data-dismiss="modal" > Close</button>
0068                                         </div>',
0069                     'data'    => array()
0070                 ));
0071             }
0072 
0073         }
0074         
0075     }
0076 
0077     public function productAction()
0078     {
0079         $this->_helper->layout()->disableLayout();
0080 
0081         if ((APPLICATION_ENV != 'searchbotenv') AND (false == SEARCHBOT_DETECTED)) {
0082 
0083             $session = new Zend_Session_Namespace();
0084             $reportedProducts = isset($session->reportedProducts) ? $session->reportedProducts : array();
0085             $project_id = (int)$this->getParam('p');
0086             if (in_array($project_id, $reportedProducts)) {
0087                 $this->_helper->json(array(
0088                     'status'  => 'ok',
0089                     'message' => '<p>Thank you, but you have already reported this product.</p><div class="modal-footer">
0090                                             <button type="button" style="border:none;background: transparent;color: #2673b0;" class="small close" data-dismiss="modal" > Close</button>
0091                                         </div>',
0092                     'data'    => array()
0093                 ));
0094             }
0095             $reported_by = 0;
0096             if (Zend_Auth::getInstance()->hasIdentity()) {
0097                 $reported_by = (int)Zend_Auth::getInstance()->getStorage()->read()->member_id;
0098             }
0099 
0100             $modelProduct = new Default_Model_Project();
0101             $productData = $modelProduct->fetchRow(array('project_id = ?' => $project_id, 'status' => Default_Model_DbTable_Project::PROJECT_ACTIVE));
0102 
0103 
0104             if (empty($productData)) {
0105                 $this->_helper->json(array(
0106                     'status'  => 'ok',
0107                     'message' => '<p>Thank you for helping us to keep these sites SPAM-free.</p><div class="modal-footer">
0108                                             <button type="button" style="border:none;background: transparent;color: #2673b0;" class="small close" data-dismiss="modal" > Close</button>
0109                                         </div>',
0110                     'data'    => array()
0111                 ));
0112             }
0113 
0114             if ($productData->spam_checked == 0) {
0115                 $tableReportComments = new Default_Model_DbTable_ReportProducts();
0116                 $tableReportComments->save(array('project_id' => $project_id, 'reported_by' => $reported_by));
0117             }
0118             $session->reportedProducts[] = $project_id;
0119         }
0120 
0121         $this->_helper->json(array(
0122             'status'  => 'ok',
0123             'message' => '<p>Thank you for helping us to keep these sites SPAM-free.</p><div class="modal-footer">
0124                                             <button type="button" style="border:none;background: transparent;color: #2673b0;" class="small close" data-dismiss="modal" > Close</button>
0125                                         </div>',
0126             'data'    => array()
0127         ));
0128     }
0129 
0130     public function productfraudAction()
0131     {   
0132         $report_type = 1;
0133 
0134         $this->_helper->layout()->disableLayout();
0135 
0136         if ((APPLICATION_ENV != 'searchbotenv') AND (false == SEARCHBOT_DETECTED)) {
0137 
0138                     $session = new Zend_Session_Namespace();
0139                     $reportedFraudProducts = isset($session->reportedFraudProducts) ? $session->reportedFraudProducts : array();
0140                     $project_id = (int)$this->getParam('p');
0141                     $text = $this->getParam('t');
0142                     if (in_array($project_id, $reportedFraudProducts)) {
0143                         $this->_helper->json(array(
0144                             'status'  => 'ok',
0145                             'message' => '<p>Thank you, but you have already reported this product.</p><div class="modal-footer">
0146                                                     <button type="button" style="border:none;background: transparent;color: #2673b0;" class="small close" data-dismiss="modal" > Close</button>
0147                                                 </div>',
0148                             'data'    => array()
0149                         ));
0150                     }
0151                     
0152                     if (Zend_Auth::getInstance()->hasIdentity()) {
0153                         $reported_by = (int)Zend_Auth::getInstance()->getStorage()->read()->member_id;
0154                         $reportProducts = new Default_Model_DbTable_ReportProducts();
0155                         $reportProducts->save(array('project_id' => $project_id, 'reported_by' => $reported_by,'text' => $text, 'report_type' =>$report_type));
0156                     }
0157                     
0158                     $session->reportedFraudProducts[] = $project_id;
0159         }
0160 
0161         $this->_helper->json(array(
0162             'status'  => 'ok',
0163             'message' => '<p>Thank you for reporting the misuse.</p><p>We will try to verify the reason for this case.</p><div class="modal-footer">
0164                                             <button type="button" style="border:none;background: transparent;color: #2673b0;" class="small close" data-dismiss="modal" > Close</button>
0165                                         </div>',
0166             'data'    => array()
0167         ));
0168     }
0169 
0170     public function flagmodAction()
0171     {                           
0172         $this->_helper->layout()->disableLayout();
0173         $params = $this->getAllParams();
0174         if ((APPLICATION_ENV != 'searchbotenv') AND (false == SEARCHBOT_DETECTED)) {
0175 
0176                     $project_clone = $this->getParam('p');
0177                     $text = $this->getParam('t');                    
0178                     $url = $this->getParam('l'); 
0179                     $project_id = 0;
0180                     
0181                     if (Zend_Auth::getInstance()->hasIdentity()) {
0182                         $reported_by = (int)Zend_Auth::getInstance()->getStorage()->read()->member_id;
0183                         $reportProducts = new Default_Model_DbTable_ProjectClone();                 
0184                         $reportProducts->save(array('project_id' => $project_clone
0185                         ,'member_id' => $reported_by
0186                         ,'text' => $text
0187                         ,'external_link' => $url
0188                         ,'project_clone_type' =>1
0189                         ,'project_id_parent' =>$project_id));                             
0190                     }                                                                                               
0191         }
0192 
0193         $this->_helper->json(array(
0194             'status'  => 'ok',
0195             'message' => '<p>Thank you. The credits have been submitted.</p><p>It can take some time to appear while we verify it.</p>
0196                                            
0197                                        ',
0198             'data'    => $params
0199         ));
0200     }
0201 
0202     public function productcloneAction()
0203     {                   
0204         $this->_helper->layout()->disableLayout();
0205         $params = $this->getAllParams();
0206         $productInfo=null;
0207         if ((APPLICATION_ENV != 'searchbotenv') AND (false == SEARCHBOT_DETECTED)) {
0208 
0209                     $project_clone = $this->getParam('p');
0210                     $text = $this->getParam('t');
0211                     $project_id = $this->getParam('pc');
0212                     $type = $this->getParam('i');
0213                     
0214                     $modelProduct = new Default_Model_Project();
0215                     $productInfo = $modelProduct->fetchProductInfo($project_id);
0216                     if (empty($productInfo)) {
0217                         $this->_helper->json(array(
0218                             'status'  => 'err',            
0219                             'message' => 'Please input a valid project ID from pling. ',
0220                             'data'    => $params
0221                         ));
0222                         return;
0223                     }
0224                     if($project_id)
0225                     {
0226                         $text = $text . ' '.$project_id;
0227                     }
0228                     if(!is_numeric($project_id))
0229                     {
0230                         $project_id = 0;
0231                     }
0232                     if (Zend_Auth::getInstance()->hasIdentity()) {
0233                         $reported_by = (int)Zend_Auth::getInstance()->getStorage()->read()->member_id;
0234                         $reportProducts = new Default_Model_DbTable_ProjectClone();                 
0235                         if($type=='is-original')
0236                         {
0237                             $reportProducts->save(array('project_id' => $project_clone
0238                             ,'member_id' => $reported_by
0239                             ,'text' => $text
0240                             ,'project_id_parent' =>$project_id));                             
0241                         }else{
0242                             $reportProducts->save(array('project_id' => $project_id
0243                             ,'member_id' => $reported_by
0244                             ,'text' => $text
0245                             ,'project_id_parent' =>$project_clone));                             
0246                         }
0247                         
0248                     }                                                                                               
0249         }
0250 
0251         $this->_helper->json(array(
0252             'status'  => 'ok',            
0253             'message' => '<p>Thank you. The credits have been submitted.</p><p>It can take some time to appear while we verify it.</p>
0254                         '
0255             
0256         ));
0257     }
0258 
0259 }