$news->setTopicdisplay($article['topicdisplay']); $news->setTopicalign($article['topicalign']); $news->setComments($article['comments']); $news->rating=$article['rating']; $news->votes=$votes['cpt']; $approved = $article['published']>0 ? true : false; $news->approved=$approved; $news->store($approved); echo '<br> 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 nw_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> 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'].')'); }
if(isset($_POST['xoops_upload_file'])) { $fldname = $_FILES[$_POST['xoops_upload_file'][0]]; $fldname = (get_magic_quotes_gpc()) ? stripslashes($fldname['name']) : $fldname['name']; if(xoops_trim($fldname!='')) { $sfiles = new nw_sFiles(); $destname=$sfiles->createUploadName(NW_ATTACHED_FILES_PATH,$fldname); /** * You can attach files to your news */ $permittedtypes = explode("\n",str_replace("\r",'',nw_getmoduleoption('mimetypes', NW_MODULE_DIR_NAME))); array_walk($permittedtypes, 'trim'); $uploader = new XoopsMediaUploader( NW_ATTACHED_FILES_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(NW_ATTACHED_FILES_PATH.'/'.$uploader->getMediaName())); $sfiles->setDownloadname($destname); if(!$sfiles->store()) { echo _AM_NW_UPLOAD_DBERROR_SAVE; } } else { echo _AM_NW_UPLOAD_ERROR. ' ' . $uploader->getErrors(); } } else { echo $uploader->getErrors(); } } } }