Ejemplo n.º 1
0
             $fldname = get_magic_quotes_gpc() ? stripslashes($fldname['name']) : $fldname['name'];
             if (xoops_trim($fldname != '')) {
                 $sfiles = new sFiles();
                 $destname = $sfiles->createUploadName(XOOPS_UPLOAD_PATH, $fldname);
                 /**
                  * You can attach files to your news
                  */
                 $permittedtypes = explode("\n", str_replace("\r", '', news_getmoduleoption('mimetypes')));
                 array_walk($permittedtypes, 'trim');
                 $uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH, $permittedtypes, $xoopsModuleConfig['maxuploadsize']);
                 $uploader->setTargetFileName($destname);
                 if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) {
                     if ($uploader->upload()) {
                         $sfiles->setFileRealName($uploader->getMediaName());
                         $sfiles->setStoryid($story->storyid());
                         $sfiles->setMimetype($sfiles->giveMimetype(XOOPS_UPLOAD_PATH . '/' . $uploader->getMediaName()));
                         $sfiles->setDownloadname($destname);
                         if (!$sfiles->store()) {
                             echo _AM_UPLOAD_DBERROR_SAVE;
                         }
                     } else {
                         echo _AM_UPLOAD_ERROR . ' ' . $uploader->getErrors();
                     }
                 } else {
                     echo $uploader->getErrors();
                 }
             }
         }
     }
 } else {
     echo _ERRORS;
Ejemplo n.º 2
0
 $news->rating = $article['rating'];
 $news->votes = $votes['cpt'];
 $approved = $article['published'] > 0 ? true : false;
 $news->approved = $approved;
 $news->store($approved);
 echo '<br>&nbsp;&nbsp;This story was imported : ' . $news->title();
 $news_newsid = $news->storyid();
 // ********************
 // The files
 $result4 = $db->query('SELECT * FROM ' . $ams_files . ' WHERE storyid=' . $ams_newsid);
 while ($file = $db->fetchArray($result4)) {
     $sfile = new sFiles();
     $sfile->setFileRealName($file['filerealname']);
     $sfile->setStoryid($news_newsid);
     $sfile->date = $file['date'];
     $sfile->setMimetype($file['mimetype']);
     $sfile->setDownloadname($file['downloadname']);
     $sfile->counter = $file['counter'];
     $sfile->store();
     echo '<br>&nbsp;&nbsp;&nbsp;&nbsp;This file was imported : ' . $sfile->getDownloadname();
     $news_fileid = $sfile->fileid;
 }
 // The ratings
 $result5 = $db->query('SELECT * FROM ' . $ams_rating . ' WHERE storyid=' . $ams_newsid);
 while ($ratings = $db->fetchArray($result5)) {
     $result6 = $db->queryF('INSERT INTO ' . $news_stories_votedata . " (storyid, ratinguser, rating, ratinghostname, ratingtimestamp) VALUES (" . $news_newsid . ',' . $ratings['ratinguser'] . ',' . $ratings['rating'] . ',' . $ratings['ratinghostname'] . ',' . $ratings['ratingtimestamp'] . ')');
 }
 // The comments
 $comments =& $comment_handler->getByItemId($ams_mid, $ams_newsid, 'ASC');
 if (is_array($comments) && count($comments) > 0) {
     foreach ($comments as $onecomment) {