Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2011
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 25.46 KB | None | 0 0
  1. <!-- Controller -->
  2.  
  3. <?php
  4. class File extends Controller {
  5.  
  6.     function File()
  7.     {
  8.         parent::Controller();
  9.         $this->load->library('ion_auth');
  10.         $this->load->model('file_model');
  11.         $this->load->library('form_validation');
  12.         $this->load->library('session');
  13.         $this->load->database();
  14.         $this->load->helper('url');
  15.     }
  16.    
  17.     function index()
  18.     {
  19.         if (!$this->ion_auth->is_admin())
  20.         {
  21.             //redirect them to the home page because they must be an administrator to view this
  22.             redirect($this->config->item('base_url'));
  23.         }
  24.        
  25.         //set the flash data error message if there is one
  26.         $this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
  27.  
  28.         //list the file    
  29.         $this->data['files'] = $this->file_model->getall();        
  30.         $this->data['categories'] = $this->file_model->getallcategories(); 
  31.         //print_r($this->data);exit;
  32.         $this->load->view('files/view_file', $this->data);
  33.     }  
  34.        
  35.     function create_file()
  36.     {
  37.         .....
  38.     }
  39.    
  40.     function edit_file($id=null,$type =null)
  41.     {
  42.         .....
  43.     }
  44.  
  45.     function delete_file()
  46.     {
  47.         ......
  48.     }  
  49.    
  50.     function cat_name_check($str)
  51.     {
  52.         ......
  53.     }
  54.    
  55.     public function upload($secid=0)
  56.     {
  57.         if (!$this->ion_auth->logged_in() || !$this->ion_auth->is_admin())
  58.         {
  59.             redirect('auth');
  60.         }
  61.        
  62.         $config['upload_path'] = './uploads/';
  63.         $config['allowed_types'] = 'avi|mp3|wmv|jpg|jpeg|png';//$this->startup->group_config->files_types;
  64.         $config['max_size'] = 500;//(1024 * intval($this->startup->group_config->upload_size_limit));
  65.        
  66.         $this->load->library('upload', $config);
  67.        
  68.         if($this->upload->do_upload()) {
  69.             $data = array('upload_data' => $this->upload->data());
  70.                        
  71.             $this->file_model->upload($data,$secid);
  72.            
  73.             echo "WIN";
  74.         } else {
  75.             echo "FAIL";   
  76.         }
  77.     }
  78.    
  79.     public function getLinks($secid)
  80.     {
  81.         $data['link'] = $this->file_model->getLinks($secid);
  82.         $this->load->view('file/links', $data);
  83.     }
  84. }?>
  85.  
  86.  
  87.  
  88. <!-- Model -->
  89.  
  90. <?
  91. if(!class_exists('CI_Model')) { class CI_Model extends Model {} }
  92.  
  93. class file_model extends CI_Model
  94. {
  95.     public function __construct()
  96.     {
  97.         parent::__construct();
  98.         $this->load->config('ion_auth', TRUE);
  99.         $this->load->helper('cookie');
  100.         $this->load->helper('date');
  101.         $this->load->library('session');
  102.         $this->load->library('functions');
  103.     }
  104.    
  105.     public function getall()
  106.     {            
  107.         return $this->db->get('files');
  108.     }
  109.    
  110.     public function getparticuler($id)
  111.     {            
  112.         $this->db->where('id',$id);
  113.         return $this->db->get('files');
  114.     }
  115.    
  116.     public function check_duplicate($cat_name)
  117.     {
  118.         ....
  119.     }
  120.    
  121.     public function insert($data,$tags)
  122.     {            
  123.         ....
  124.     }
  125.    
  126.     public function update($id, $data, $tags)
  127.     {  
  128.         ....
  129.     }
  130.    
  131.    
  132.     public function delete($id)
  133.     {            
  134.         ....
  135.     }
  136.    
  137.     public function upload($data) {
  138.         $data_col = array('user_id' => $this->session->userdata('user_id'),    
  139.                     'file_name' => $data['filename'],
  140.                     'file_size' => $data['filesize'],
  141.                     'file_md5' => md5_file($data['file'])
  142.                     );
  143.         $this->db->insert('files', $data_col);
  144.     }
  145.    
  146.     public function getLinks($secid)
  147.     {
  148.         $this->db->where('secid',$secid);
  149.         $query = $this->db->get('refrence');
  150.         $file = $query->row();     
  151.         return $file->o_filename;
  152.     }
  153. }
  154. ?>
  155.  
  156.  
  157.  
  158. <!-- View -->
  159.  
  160. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  161. <html xmlns="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xml:lang="en" >
  162.     <head>
  163.         <meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
  164.         <meta name="author" content="Matthew Glinski - xtrafile.com" />
  165.         <meta name="description" content="Site Description Here" />
  166.         <meta name="keywords" content="keywords, here" />
  167.         <meta name="robots" content="index, follow, noarchive" />
  168.         <meta name="googlebot" content="noarchive" />
  169.        
  170.        
  171.         <script src="http://localhost/Pratik/Dec 10/ionauth/js/main.php" type="text/javascript"></script>
  172.         <script src="http://localhost/Pratik/Dec 10/ionauth/js/upload.js" type="text/javascript"></script>
  173.        
  174.         <script type="text/javascript">
  175.         function ___imageClose(){return 'http://localhost/Pratik/Dec 10/ionauth/index.php/images/lightbox-btn-close.gif';}
  176.         function ___imageLoading(){return 'http://localhost/Pratik/Dec 10/ionauth/index.php/images/loading.gif';}
  177.         function ___baseUrl(){return 'http://localhost/Pratik/Dec 10/ionauth/';}
  178.         function ___siteUrl(){return 'http://localhost/Pratik/Dec 10/ionauth/index.php/';}
  179.         </script>
  180.     </head>
  181.    
  182.     <body dir="ltr">
  183.         <div id="wrap">
  184.             <div id="content-wrap">            
  185.                 <div id="main">
  186.                     <div id="uploader" style="display:none">
  187.                             <h3 style="padding-top:8px;">Select Files To Upload</h3><br />
  188.                             <div style=" padding-left:12px;">
  189.                                 <div style="display: block; width:90px; height:22px; border: none; background-color: #CFCDCA; padding: 2px; padding-top:6px; padding-left:6px;"><span id="spanButtonPlaceholder"></span></div>
  190.                             </div>
  191.                             <br />
  192.                     </div>
  193.                
  194.                
  195.                     <div id="files" style="display:none">
  196.                         <div id="file_list">
  197.                             <p>
  198.                                 You have selected the following files for upload  (<span id="summary">0</span> Files).<br />
  199.                                 <span class="alert" id="alert1" style="display:none">
  200.                                     You have selected previously selected files for upload.<br />
  201.                                     These files have been removed.
  202.                                 </span>
  203.                                 <span class="alert" id="alert2" style="display:none">
  204.                                     One or more of the files you selected were too large.<br />
  205.  
  206.                                     These files have been removed.
  207.                                 </span>
  208.                                 <span class="alert" id="alert3" style="display:none">
  209.                                     One or more of the files you selected are not allowed.<br />
  210.                                     These files have been removed.
  211.                                 </span>
  212.                                 <span class="alert" id="alert4" style="display:none">
  213.                                     You have selected to many files to upload at once. You are limited to <strong>10</strong> Files.<br />
  214.  
  215.                                     Please select fewer files and try again.
  216.                                 </span>
  217.                                 <span class="alert" id="alert5" style="display:none">
  218.                                     An unknown error has occured.<br />
  219.                                     Please contact us about this error.
  220.                                 </span>
  221.                             </p>
  222.                            
  223.                             <div class="float-right" style=" margin-bottom:1em">                           
  224.                                 <span class="cssButton"><a href="javascript:void(0);" class="buttonGreen" onclick="swfu.startUpload();"> <img src="http://localhost/Pratik/Dec 10/Example/xu2/img/icons/up_16.png" alt=""/> Upload! </a></span>
  225.                             </div>
  226.                            
  227.                             <table border="0" style=" padding:0;width:68%;clear:both" id="file_list_table">
  228.                                 <tr>
  229.                                     <th style="width:470px" class="align-left">File name</th>
  230.                                     <th style="width:90px">Size</th>
  231.                                     <th style="width:85px">Actions <img title="Delete All?" src="http://localhost/Pratik/Dec 10/Example/xu2/img/icons/delete_16.png" onclick="clearUploadQueue()" alt="" style="cursor:pointer" class="nb" /></th>
  232.                                 </tr>
  233.  
  234.                             </table>
  235.                            
  236.                             <div class="float-right">
  237.                                 <span class="cssButton"><a href="javascript:void(0);" class="buttonGreen" onclick="swfu.startUpload();"> <img src="http://localhost/Pratik/Dec 10/Example/xu2/img/icons/up_16.png" alt=""/> Upload! </a></span>
  238.                             </div>
  239.                         </div>
  240.                     </div>
  241.                    
  242.                     <input id="fid" type="hidden" />
  243.  
  244.                     <input id="uid" type="hidden" value="<?php echo ($this->session->userdata('id') ? $this->session->userdata('id') : 0 )?>" />
  245.                     <div id="filesHidden" style="display:none"></div>
  246.                
  247.                     <script type="text/javascript">
  248.                         var fileObj = new Array();
  249.                         var prevFile = false;
  250.                         var fileToBig = false;
  251.                         var fileNotAllowed = false;
  252.                         var filePropsObj = new Array();
  253.                         var subtractFilesFromTotal = 0;
  254.                         var curFileId = '';
  255.                         var pbUpd = 0;
  256.                         var flashUploadStartTime = '';
  257.                         var fileIcons = new Array("3gp", "7z", "aca", "ai", "api", "app", "as", "ascx", "asmx", "asp", "aspx", "avi", "avs", "axt", "bash", "bat", "bmp", "c", "cab", "cal", "cat", "cda", "cf", "chm", "cnf", "conf", "config", "cpl", "cpp", "crt", "cs", "csproj", "css", "csv", "cue", "dar", "db", "dbp", "dem", "disco", "dll", "dng", "doc", "dot", "dpk", "dpr", "dps", "dtq", "dun", "etp", "exe", "fdb", "fhf", "fla", "flv", "fnd", "fon", "gif", "gz", "h", "hlp", "hol", "htm", "html", "htt", "hxc", "hxi", "hxk", "hxs", "hxt", "icm", "ini", "ins", "iqy", "iso", "its", "jar", "java", "jbf", "job", "jpeg", "jpf", "jpg", "js", "lnk", "m3u", "m3v", "m4a", "m4p", "m4v", "mad", "map", "mapup", "mat", "mdb", "mdf", "mht", "mml", "mov", "mp3", "mp4", "mpeg", "mpg", "msc", "msg", "msi", "ncd", "nfo", "none", "nrg", "ogg", "ost", "otf", "pas", "pdf", "pdi", "pet", "pfm", "php", "pif", "plg", "pmc", "", "pot", "ppk", "pps", "ppt", "prf", "psd", "psp", "pub", "qbb", "rar", "rb", "rc", "rct", "rdp", "refresh", "reg", "res", "resx", "rmvb", "rss", "rtf", "sdl", "sea", "sh", "shs", "sln", "sql", "suo", "swf", "tar", "tdf", "tdl", "theme", "tiff", "ttf", "txt", "url", "vb", "vbproj", "vbs", "vcard", "vcf", "vob", "vsmacros", "wab", "wma", "wmv", "wpl", "wri", "wsc", "xhtml", "xla", "xls", "xml", "xpi", "xsd", "xsl", "xslt", "xsn", "zip");
  258.                        
  259.                         function ___getMaxUploadSize()
  260.                         {
  261.                             return '100';
  262.                         }
  263.                        
  264.                         function ___serverUrl()
  265.                         {
  266.                             return 'http://localhost/Pratik/Dec 10/ionauth/index.php/';
  267.                         }
  268.                        
  269.                         function ___getFilePipeString()
  270.                         {
  271.                             return 'exe|php|sh|bat|cgi|pl';
  272.                         }
  273.                        
  274.                         function ___getFileIcon(icon)
  275.                         {
  276.                             if(in_array(icon, fileIcons))
  277.                             {
  278.                                 return icon;
  279.                             }
  280.                             else
  281.                             {
  282.                                 return 'default';
  283.                             }
  284.                         }
  285.                        
  286.                         function ___getFileTypesAllowOrDeny()
  287.                         {
  288.                             return 0;
  289.                         }
  290.                        
  291.                         function ___toManyFilesError()
  292.                         {
  293.                             $('#alert4').show();
  294.                             setTimeout('$("#alert4").hide("normal");', 2500);
  295.                             fileToBig = false;
  296.                         }
  297.                        
  298.                         function ___generalError()
  299.                         {
  300.                             $('#alert5').show();
  301.                             setTimeout('$("#alert5").hide("normal");', 2500);
  302.                             fileToBig = false;
  303.                         }
  304.                        
  305.                         function ___upLang(key)
  306.                         {
  307.                             var lang = new Array();
  308.                             lang['pc' ]     = 'Percent Complete';
  309.                             lang['kbr']     = 'KB Remaining (at ';
  310.                             lang['remain']  = 'remaining';
  311.                             lang['desc']    = 'Description';
  312.                             lang['fp']      = 'File Password';
  313.                             lang['sc']      = 'Save Changes';
  314.                             lang['efd']     = 'Edit File Details';
  315.                             lang['rm']      = 'Remove File';
  316.                             lang['ff1']     = 'Feature This File?';
  317.                             lang['ff2']     = 'Yes';
  318.                            
  319.                             return lang[key];
  320.                         }
  321.                        
  322.                         $(document).ready(function()
  323.                         {
  324.                             var settings_object = {
  325.                                 file_types : "*.*",
  326.                                 file_types_description: "Allowed Files",
  327.                                 file_upload_limit : 10,
  328.                                 file_size_limit : (100 * 1024),
  329.                                 file_queue_limit : 10,
  330.                                 flash_url : ___baseUrl()+"flash/upload.swf",
  331.                                 flash_width : "1px",
  332.                                 flash_height : "1px",
  333.                                 flash_color : "#CCCCCC",
  334.                                 debug:true,
  335.                                
  336.                                 // Button settings
  337.                                 button_image_url : "<?=$base_url.'img/flash_upload.png'?>",//"http://localhost/Pratik/Dec 10/Example/xu2/index.php/img/flash_upload.png",   // Relative to the SWF file
  338.                                 button_placeholder_id : "spanButtonPlaceholder",
  339.                                 button_width: 90,
  340.                                 button_height: 18,
  341.                                 button_text : '<'+'span class="button">Browse...</'+'span>',
  342.                                 button_text_style : '.button { font-family: Helvetica, Arial, sans-serif; font-size: 12pt;  font-weight:bold; color:#565656; }',
  343.                                 button_text_top_padding: 0,
  344.                                 button_text_left_padding: 22,
  345.                                 button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
  346.                                 button_cursor: SWFUpload.CURSOR.HAND,
  347.                                
  348.                                 upload_progress_handler : flashUploadProgress,
  349.                                 upload_error_handler : flashUploadError,
  350.                                 file_dialog_complete_handler : fileDialogComplete,
  351.                                 file_queue_error_handler : flashUploadQueueError,
  352.                                 file_queued_handler : addFileQueue,
  353.                                 upload_start_handler : beforeUploadStart,
  354.                                 upload_complete_handler : uploadDone
  355.                             };
  356.                            
  357.                             swfu = new SWFUpload(settings_object);
  358.                             if (swfu) {
  359.                                 $('#flash').html('');
  360.                                 $('#browser').attr('disabled', false);
  361.                                 $('#uploader').show();
  362.                                 $('#files').show();
  363.                                 $('#info_div').show();
  364.                             }
  365.                         });
  366.                        
  367.                         function saveFilePropChanges(file_id)
  368.                         {                          
  369.                             filePropsObj[file_id]['desc'] = $('#'+file_id+'_desc').val();
  370.                             filePropsObj[file_id]['pass'] = $('#'+file_id+'_pass').val();
  371.                             if($('#'+file_id+'_feature').attr('checked') && $('#'+file_id+'_feature').attr('value'))
  372.                             {
  373.                                 filePropsObj[file_id]['feat'] ="1";
  374.                             }
  375.                             else
  376.                             {
  377.                                 filePropsObj[file_id]['feat'] ="0";
  378.                             }  
  379.                         }
  380.                        
  381.                         function beforeUploadStart(file)
  382.                         {
  383.                             var fid = genRandId(32);
  384.                             curFileId = fid;
  385.                             var stats = swfu.getStats();
  386.                             var url;
  387.                             var fUser = $('#uid').val();
  388.                        
  389.                             var url = ___serverUrl()+"file/upload/"+fid+'/'+fUser;
  390.                             swfu.setUploadURL(url);
  391.                             placeProgressBar(file.id);
  392.                             flashUploadStartTime = Math.round(new Date().getTime()/1000.0);
  393.                            
  394.                             $("#"+file.id+"-details").css('borderTop', 'none').show();
  395.                             $("#"+file.id).addClass('details').css('borderBottom', 'none');
  396.                             $.scrollTo( $("#"+file.id), 300);
  397.                             return true;
  398.                         }
  399.                        
  400.                         function syncFileProps(file)
  401.                         {
  402.                             var fFeatured = filePropsObj[file.id]['feat'];
  403.                             var fDesc = filePropsObj[file.id]['desc'] ;
  404.                             var fPass = filePropsObj[file.id]['pass'];
  405.                             if(fPass == '' && fFeatured == '' && fDesc == '')
  406.                             {
  407.                                 $("#"+file.id+"-details-inner").empty().attr('colspan', 3).load('http://localhost/Pratik/Dec 10/ionauth/index.php/file/getLinks/'+curFileId);
  408.                                 return;
  409.                             }              
  410.                            
  411.                         }
  412.                        
  413.                         function uploadDone(file)
  414.                         {
  415.                             syncFileProps(file);
  416.                             $('#'+file.id+"-del").empty().html("<strong>Done!</strong>");
  417.                             $("#"+file.id+"-details").css('borderTop', 'none').show();
  418.                             var stats = swfu.getStats();
  419.                        
  420.                             if(stats.files_queued > 0)
  421.                             {
  422.                                 swfu.startUpload();
  423.                             }
  424.                             else
  425.                             {
  426.                                 $.scrollTo( $("#uploader"), 800);
  427.                             }
  428.                         }
  429.                     </script>
  430.                 <!-- main ends -->
  431.                 </div>
  432.             </div>
  433.         </div>
  434.     </body>
  435. </html>
  436.  
  437.  
  438. <!-- View -->
  439.  
  440. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  441. <html xmlns="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xml:lang="en" >
  442.     <head>
  443.         <meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
  444.         <meta name="author" content="Matthew Glinski - xtrafile.com" />
  445.         <meta name="description" content="Site Description Here" />
  446.         <meta name="keywords" content="keywords, here" />
  447.         <meta name="robots" content="index, follow, noarchive" />
  448.         <meta name="googlebot" content="noarchive" />
  449.        
  450.        
  451.         <script src="http://localhost/Pratik/Dec 10/ionauth/js/main.php" type="text/javascript"></script>
  452.         <script src="http://localhost/Pratik/Dec 10/ionauth/js/upload.js" type="text/javascript"></script>
  453.        
  454.         <script type="text/javascript">
  455.         function ___imageClose(){return 'http://localhost/Pratik/Dec 10/ionauth/index.php/images/lightbox-btn-close.gif';}
  456.         function ___imageLoading(){return 'http://localhost/Pratik/Dec 10/ionauth/index.php/images/loading.gif';}
  457.         function ___baseUrl(){return 'http://localhost/Pratik/Dec 10/ionauth/';}
  458.         function ___siteUrl(){return 'http://localhost/Pratik/Dec 10/ionauth/index.php/';}
  459.         </script>
  460.     </head>
  461.    
  462.     <body dir="ltr">
  463.         <div id="wrap">
  464.             <div id="content-wrap">            
  465.                 <div id="main">
  466.                     <div id="uploader" style="display:none">
  467.                             <h3 style="padding-top:8px;">Select Files To Upload</h3><br />
  468.                             <div style=" padding-left:12px;">
  469.                                 <div style="display: block; width:90px; height:22px; border: none; background-color: #CFCDCA; padding: 2px; padding-top:6px; padding-left:6px;"><span id="spanButtonPlaceholder"></span></div>
  470.                             </div>
  471.                             <br />
  472.                     </div>
  473.                
  474.                
  475.                     <div id="files" style="display:none">
  476.                         <div id="file_list">
  477.                             <p>
  478.                                 You have selected the following files for upload  (<span id="summary">0</span> Files).<br />
  479.                                 <span class="alert" id="alert1" style="display:none">
  480.                                     You have selected previously selected files for upload.<br />
  481.                                     These files have been removed.
  482.                                 </span>
  483.                                 <span class="alert" id="alert2" style="display:none">
  484.                                     One or more of the files you selected were too large.<br />
  485.  
  486.                                     These files have been removed.
  487.                                 </span>
  488.                                 <span class="alert" id="alert3" style="display:none">
  489.                                     One or more of the files you selected are not allowed.<br />
  490.                                     These files have been removed.
  491.                                 </span>
  492.                                 <span class="alert" id="alert4" style="display:none">
  493.                                     You have selected to many files to upload at once. You are limited to <strong>10</strong> Files.<br />
  494.  
  495.                                     Please select fewer files and try again.
  496.                                 </span>
  497.                                 <span class="alert" id="alert5" style="display:none">
  498.                                     An unknown error has occured.<br />
  499.                                     Please contact us about this error.
  500.                                 </span>
  501.                             </p>
  502.                            
  503.                             <div class="float-right" style=" margin-bottom:1em">                           
  504.                                 <span class="cssButton"><a href="javascript:void(0);" class="buttonGreen" onclick="swfu.startUpload();"> <img src="http://localhost/Pratik/Dec 10/Example/xu2/img/icons/up_16.png" alt=""/> Upload! </a></span>
  505.                             </div>
  506.                            
  507.                             <table border="0" style=" padding:0;width:68%;clear:both" id="file_list_table">
  508.                                 <tr>
  509.                                     <th style="width:470px" class="align-left">File name</th>
  510.                                     <th style="width:90px">Size</th>
  511.                                     <th style="width:85px">Actions <img title="Delete All?" src="http://localhost/Pratik/Dec 10/Example/xu2/img/icons/delete_16.png" onclick="clearUploadQueue()" alt="" style="cursor:pointer" class="nb" /></th>
  512.                                 </tr>
  513.  
  514.                             </table>
  515.                            
  516.                             <div class="float-right">
  517.                                 <span class="cssButton"><a href="javascript:void(0);" class="buttonGreen" onclick="swfu.startUpload();"> <img src="http://localhost/Pratik/Dec 10/Example/xu2/img/icons/up_16.png" alt=""/> Upload! </a></span>
  518.                             </div>
  519.                         </div>
  520.                     </div>
  521.                    
  522.                     <input id="fid" type="hidden" />
  523.  
  524.                     <input id="uid" type="hidden" value="<?php echo ($this->session->userdata('id') ? $this->session->userdata('id') : 0 )?>" />
  525.                     <div id="filesHidden" style="display:none"></div>
  526.                
  527.                     <script type="text/javascript">
  528.                         var fileObj = new Array();
  529.                         var prevFile = false;
  530.                         var fileToBig = false;
  531.                         var fileNotAllowed = false;
  532.                         var filePropsObj = new Array();
  533.                         var subtractFilesFromTotal = 0;
  534.                         var curFileId = '';
  535.                         var pbUpd = 0;
  536.                         var flashUploadStartTime = '';
  537.                         var fileIcons = new Array("3gp", "7z", "aca", "ai", "api", "app", "as", "ascx", "asmx", "asp", "aspx", "avi", "avs", "axt", "bash", "bat", "bmp", "c", "cab", "cal", "cat", "cda", "cf", "chm", "cnf", "conf", "config", "cpl", "cpp", "crt", "cs", "csproj", "css", "csv", "cue", "dar", "db", "dbp", "dem", "disco", "dll", "dng", "doc", "dot", "dpk", "dpr", "dps", "dtq", "dun", "etp", "exe", "fdb", "fhf", "fla", "flv", "fnd", "fon", "gif", "gz", "h", "hlp", "hol", "htm", "html", "htt", "hxc", "hxi", "hxk", "hxs", "hxt", "icm", "ini", "ins", "iqy", "iso", "its", "jar", "java", "jbf", "job", "jpeg", "jpf", "jpg", "js", "lnk", "m3u", "m3v", "m4a", "m4p", "m4v", "mad", "map", "mapup", "mat", "mdb", "mdf", "mht", "mml", "mov", "mp3", "mp4", "mpeg", "mpg", "msc", "msg", "msi", "ncd", "nfo", "none", "nrg", "ogg", "ost", "otf", "pas", "pdf", "pdi", "pet", "pfm", "php", "pif", "plg", "pmc", "", "pot", "ppk", "pps", "ppt", "prf", "psd", "psp", "pub", "qbb", "rar", "rb", "rc", "rct", "rdp", "refresh", "reg", "res", "resx", "rmvb", "rss", "rtf", "sdl", "sea", "sh", "shs", "sln", "sql", "suo", "swf", "tar", "tdf", "tdl", "theme", "tiff", "ttf", "txt", "url", "vb", "vbproj", "vbs", "vcard", "vcf", "vob", "vsmacros", "wab", "wma", "wmv", "wpl", "wri", "wsc", "xhtml", "xla", "xls", "xml", "xpi", "xsd", "xsl", "xslt", "xsn", "zip");
  538.                        
  539.                         function ___getMaxUploadSize()
  540.                         {
  541.                             return '100';
  542.                         }
  543.                        
  544.                         function ___serverUrl()
  545.                         {
  546.                             return 'http://localhost/Pratik/Dec 10/ionauth/index.php/';
  547.                         }
  548.                        
  549.                         function ___getFilePipeString()
  550.                         {
  551.                             return 'exe|php|sh|bat|cgi|pl';
  552.                         }
  553.                        
  554.                         function ___getFileIcon(icon)
  555.                         {
  556.                             if(in_array(icon, fileIcons))
  557.                             {
  558.                                 return icon;
  559.                             }
  560.                             else
  561.                             {
  562.                                 return 'default';
  563.                             }
  564.                         }
  565.                        
  566.                         function ___getFileTypesAllowOrDeny()
  567.                         {
  568.                             return 0;
  569.                         }
  570.                        
  571.                         function ___toManyFilesError()
  572.                         {
  573.                             $('#alert4').show();
  574.                             setTimeout('$("#alert4").hide("normal");', 2500);
  575.                             fileToBig = false;
  576.                         }
  577.                        
  578.                         function ___generalError()
  579.                         {
  580.                             $('#alert5').show();
  581.                             setTimeout('$("#alert5").hide("normal");', 2500);
  582.                             fileToBig = false;
  583.                         }
  584.                        
  585.                         function ___upLang(key)
  586.                         {
  587.                             var lang = new Array();
  588.                             lang['pc' ]     = 'Percent Complete';
  589.                             lang['kbr']     = 'KB Remaining (at ';
  590.                             lang['remain']  = 'remaining';
  591.                             lang['desc']    = 'Description';
  592.                             lang['fp']      = 'File Password';
  593.                             lang['sc']      = 'Save Changes';
  594.                             lang['efd']     = 'Edit File Details';
  595.                             lang['rm']      = 'Remove File';
  596.                             lang['ff1']     = 'Feature This File?';
  597.                             lang['ff2']     = 'Yes';
  598.                            
  599.                             return lang[key];
  600.                         }
  601.                        
  602.                         $(document).ready(function()
  603.                         {
  604.                             var settings_object = {
  605.                                 file_types : "*.*",
  606.                                 file_types_description: "Allowed Files",
  607.                                 file_upload_limit : 10,
  608.                                 file_size_limit : (100 * 1024),
  609.                                 file_queue_limit : 10,
  610.                                 flash_url : ___baseUrl()+"flash/upload.swf",
  611.                                 flash_width : "1px",
  612.                                 flash_height : "1px",
  613.                                 flash_color : "#CCCCCC",
  614.                                 debug:true,
  615.                                
  616.                                 // Button settings
  617.                                 button_image_url : "<?=$base_url.'img/flash_upload.png'?>",//"http://localhost/Pratik/Dec 10/Example/xu2/index.php/img/flash_upload.png",   // Relative to the SWF file
  618.                                 button_placeholder_id : "spanButtonPlaceholder",
  619.                                 button_width: 90,
  620.                                 button_height: 18,
  621.                                 button_text : '<'+'span class="button">Browse...</'+'span>',
  622.                                 button_text_style : '.button { font-family: Helvetica, Arial, sans-serif; font-size: 12pt;  font-weight:bold; color:#565656; }',
  623.                                 button_text_top_padding: 0,
  624.                                 button_text_left_padding: 22,
  625.                                 button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
  626.                                 button_cursor: SWFUpload.CURSOR.HAND,
  627.                                
  628.                                 upload_progress_handler : flashUploadProgress,
  629.                                 upload_error_handler : flashUploadError,
  630.                                 file_dialog_complete_handler : fileDialogComplete,
  631.                                 file_queue_error_handler : flashUploadQueueError,
  632.                                 file_queued_handler : addFileQueue,
  633.                                 upload_start_handler : beforeUploadStart,
  634.                                 upload_complete_handler : uploadDone
  635.                             };
  636.                            
  637.                             swfu = new SWFUpload(settings_object);
  638.                             if (swfu) {
  639.                                 $('#flash').html('');
  640.                                 $('#browser').attr('disabled', false);
  641.                                 $('#uploader').show();
  642.                                 $('#files').show();
  643.                                 $('#info_div').show();
  644.                             }
  645.                         });
  646.                        
  647.                         function saveFilePropChanges(file_id)
  648.                         {                          
  649.                             filePropsObj[file_id]['desc'] = $('#'+file_id+'_desc').val();
  650.                             filePropsObj[file_id]['pass'] = $('#'+file_id+'_pass').val();
  651.                             if($('#'+file_id+'_feature').attr('checked') && $('#'+file_id+'_feature').attr('value'))
  652.                             {
  653.                                 filePropsObj[file_id]['feat'] ="1";
  654.                             }
  655.                             else
  656.                             {
  657.                                 filePropsObj[file_id]['feat'] ="0";
  658.                             }  
  659.                         }
  660.                        
  661.                         function beforeUploadStart(file)
  662.                         {
  663.                             var fid = genRandId(32);
  664.                             curFileId = fid;
  665.                             var stats = swfu.getStats();
  666.                             var url;
  667.                             var fUser = $('#uid').val();
  668.                        
  669.                             var url = ___serverUrl()+"file/upload/"+fid+'/'+fUser;
  670.                             swfu.setUploadURL(url);
  671.                             placeProgressBar(file.id);
  672.                             flashUploadStartTime = Math.round(new Date().getTime()/1000.0);
  673.                            
  674.                             $("#"+file.id+"-details").css('borderTop', 'none').show();
  675.                             $("#"+file.id).addClass('details').css('borderBottom', 'none');
  676.                             $.scrollTo( $("#"+file.id), 300);
  677.                             return true;
  678.                         }
  679.                        
  680.                         function syncFileProps(file)
  681.                         {
  682.                             var fFeatured = filePropsObj[file.id]['feat'];
  683.                             var fDesc = filePropsObj[file.id]['desc'] ;
  684.                             var fPass = filePropsObj[file.id]['pass'];
  685.                             if(fPass == '' && fFeatured == '' && fDesc == '')
  686.                             {
  687.                                 $("#"+file.id+"-details-inner").empty().attr('colspan', 3).load('http://localhost/Pratik/Dec 10/ionauth/index.php/file/getLinks/'+curFileId);
  688.                                 return;
  689.                             }              
  690.                            
  691.                         }
  692.                        
  693.                         function uploadDone(file)
  694.                         {
  695.                             syncFileProps(file);
  696.                             $('#'+file.id+"-del").empty().html("<strong>Done!</strong>");
  697.                             $("#"+file.id+"-details").css('borderTop', 'none').show();
  698.                             var stats = swfu.getStats();
  699.                        
  700.                             if(stats.files_queued > 0)
  701.                             {
  702.                                 swfu.startUpload();
  703.                             }
  704.                             else
  705.                             {
  706.                                 $.scrollTo( $("#uploader"), 800);
  707.                             }
  708.                         }
  709.                     </script>
  710.                 <!-- main ends -->
  711.                 </div>
  712.             </div>
  713.         </div>
  714.     </body>
  715. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement