Jump to content

sagnik

Members
  • Posts

    472
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by sagnik

  1. Sir, I couldn't find any way to change the AppData folder of mono. Can you tell me how can I do that? One more thing, when I launched a Command Prompt using Administrator rights, I got the following error: Access to the path 'C:\WINDOWS\system32\config\systemprofile\AppData\Local\Microsoft\Windows\INetCache\Content.IE5' is denied.Okay I've managed to run mod_mono with Apache. What I did is changed the MonoServerPath from xsp4.bat to mod-mono-server4.bat which I've created. But a problem is that I had to start the mod-mono-server4 manually as well as I had to supply few options along with it C:\Program Files\Mono>mod-mono-server4 --address 127.0.0.1 --port 2000 --root E:\httpd\htdocsApache is not starting the server by itself. And If I don't start run the command manually the apache is showing a 503 Error. Also if I don't supply the options when starting the server Iget the following output: C:\Program Files\Mono>mod-mono-server4 Listening on: C:\Users\sagni\AppData\Local\Temp\mod_mono_server Root directory: C:\Program Files\Mono\ An address incompatible with the requested protocol was used. at System.Net.Sockets.Socket.Bind (System.Net.EndPoint localEP) [0x00043] in <524453535c1446469839c0b30a8ceaf1>:0 at Mono.WebServer.ModMonoWebSource.CreateSocket () [0x0007e] in <17ccfba99d534c9e8d160e47815fbfe3>:0 at Mono.WebServer.ApplicationServer.Start (System.Boolean bgThread, System.Int32 backlog) [0x00075] in <bbd0a9d3a0d349099be00550c37ebfb4>:0 at (wrapper remoting-invoke-with-check) Mono.WebServer.ApplicationServer.Start(bool,int) at Mono.WebServer.Apache.Server.RealMain (System.String[] args, System.Boolean root, Mono.WebServer.IApplicationHost ext_apphost, System.Boolean v_quiet) [0x00384] in <17ccfba99d534c9e8d160e47815fbfe3>:0 Here is the mod_mono.conf: # mod_mono.conf # Achtung! This file may be overwritten # Use 'include mod_mono.conf' from other configuration file # to load mod_mono module. <IfModule !mod_mono.c> LoadModule mono_module modules/mod_mono.so </IfModule> <IfModule mono_module> AddType application/x-asp-net .config .cs .csproj .dll .resources .resx .sln .vb .vbproj AddType application/x-asp-net .asax .ascx .ashx .asmx .aspx .axd .browser .licx .master .rem .sitemap .skin .soap .webinfo #AddHandler mod_mono .asax .ascx .ashx .asmx .aspx .axd .browser .licx .master .rem .sitemap .skin .soap .webinfo .config .cs .csproj .dll .resources .resx .sln .vb .vbproj MonoAutoApplication disabled MonoPath "C:\Program Files\Mono" #MonoServerPath "C:\Program Files\Mono\lib\mono\gac\mod-mono-server4\4.4.0.0__0738eb9f132ed756\mod-mono-server4" #MonoServerPath "C:\Program Files\Mono\lib\mono\4.5\mod-mono-server4.exe" MonoServerPath "C:\Program Files\Mono\bin\mod-mono-server4.bat" #MonoServerPath "C:\Program Files\Mono\bin\xsp4.bat" MonoListenAddress 127.0.0.1 MonoListenPort 2000 #MonoWapiDir "E:/httpd/htdocs" MonoApplications "/:E:\httpd\htdocs" #MonoApplicationsConfigFile "E:/httpd/htdocs/web.config" #MonoApplicationsConfigDir "E:/httpd/htdocs/webapp" MonoDebug true <IfModule dir_module> DirectoryIndex index.aspx DirectoryIndex Default.aspx DirectoryIndex default.aspx </IfModule> <DirectoryMatch "/(bin|App_Code|App_Data|App_GlobalResources|App_LocalResources)/"> Order deny,allow Deny from all </DirectoryMatch> <Location "/"> #MonoSetServerAlias default Allow from all Order allow,deny SetHandler mono SetOutputFilter DEFLATE SetEnvIfNoCase REQUEST_URI "\.(?:gif|jpe?g|png)$" no-gzip dont-vary AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript </Location> <Location "/mono"> #Allow from 127.0.0.1::1 SetHandler mono-ctrl </Location> </IfModule> Here is a screenshot:https://imgur.com/a/AxSNJcW
  2. That's why I don't want to use IIS. Apache provides lot more features than IIS. That's why I want to setup mod_mono with Apache server. No doubt that IIS is very good when it comes to ASP.NET & SQL Server but to setup any other modules such as PHP it's very hard to setup even IIS doesn't allow PHP to be hosted as a module, it just allows to run PHP using FastCGI mode. But with Apache we can run almost everything we want and is very easy to setup. No the domains are not real. Well I'll try to fix the "Access Denied" issue for the "Application Data" folder in the morning. I will let you know, what has happened next. Because setting the mod_mono with Apache is my only option to run ASP.NET pages. And can you tell me how can I change the Directory shown on the command prompt (the Application Data folder)?
  3. And what about the virtual hosts I've in Apache? And can I use Windows Hosts file as I did with Apache V Name-based irtual Hosts? And can use MySQL (MySQL 8), PHP (PHP 7.1), Python/Django, Perl, CGI with IIS? I use all of these for education purposes.
  4. Okay got it. But how can I fix the "Access Denied" issue on that folder. By the way, you wanted to say that, I should use IIS instead of Apache. But if I do this, I need to change almost all the lines which uses an absolute path because I've installed Apache on "E:\httpd" and the installation of IIS will be in "C:\inetpub". Here is why I'm not using IIS instead of Apache: 4 years ago I had a website built using site builder on a free hosting company "Serversforyou" or something like that. I've learnt the basics of PHP & MySQL by modifying the website I've built using the site builder and with the help of some Google searches. After few months after learning the basics of PHP & MySQL I've created an account on Heliohost as it offers a large amount of features compared to any other hosts and its features were very new to me on that time. What the common thing was that both hosting company included a server signature which was for Apache. That's why I've installed Apache on a Windows XP PC on that time as I didn't know what I'm doing. And all the websites built on that PC is continued till now.
  5. I've not specified the directory shown in the command prompt. I want to change this directory. But I don't know how. Yes I'm running mono as the account I use to logon to Windows at startup. And the Directory: "C:\Users\sagni\AppData\Local\Application Data" exists I think but showing "Access is denied." And when I'm trying to create, it shows "The destination already contains a folder named 'Application Data'." But I can't see it even after turning on "Show Hidden Items".
  6. If mean to start the server using xsp4 --port 2000, then I did as you said and I've got an Error 404 from ASP (mod_mono) and the server gets closed after visiting "127.0.0.1:2000" & even "127.0.0.1:2000/hello.aspx" but on visiting "localhost/hello.aspx" is showing Apache 503 Service Unavailable Error. Here is the error.log: [Fri Jan 11 19:32:17.808453 2019] [:error] [pid 1864:tid 1800] mod_mono: connect error (Unknown error). Address: 127.0.0.1 Port: 2000 [Fri Jan 11 19:33:05.916807 2019] [:error] [pid 1864:tid 1800] Unknown command: 1347703880 [Fri Jan 11 19:41:54.044848 2019] [:error] [pid 1864:tid 1800] mod_mono: connect error (Unknown error). Address: 127.0.0.1 Port: 2000 [Fri Jan 11 19:41:58.895062 2019] [mpm_winnt:notice] [pid 3276:tid 1100] AH00424: Parent: Received restart signal -- Restarting the server. [Fri Jan 11 19:42:00.183297 2019] [:error] [pid 3276] mod_mono: connect error (Unknown error). Address: 127.0.0.1 Port: 2000 [Fri Jan 11 19:42:00.929365 2019] [mpm_winnt:notice] [pid 1864:tid 1032] AH00364: Child: All worker threads have exited. [Fri Jan 11 19:42:01.198967 2019] [:error] [pid 3276] mod_mono: connect error (Unknown error). Address: 127.0.0.1 Port: 2000 [Fri Jan 11 19:42:02.270816 2019] [:error] [pid 1864:tid 1032] mod_mono: connect error (Unknown error). Address: 127.0.0.1 Port: 2000 [Fri Jan 11 19:42:02.371054 2019] [auth_digest:notice] [pid 3276:tid 1100] AH01757: generating secret for digest authentication ... [Fri Jan 11 19:42:03.272498 2019] [:error] [pid 1864:tid 1032] mod_mono: connect error (Unknown error). Address: 127.0.0.1 Port: 2000 [Fri Jan 11 19:42:03.272498 2019] [:alert] [pid 1864:tid 1032] (OS 6)The handle is invalid. : Failed to acquire dashboard lock before destroying the dashboard [Fri Jan 11 19:42:03.272498 2019] [:warn] [pid 1864:tid 1032] (OS 6)The handle is invalid. : Failed to release dashboard lock after destroying the dashboard [Fri Jan 11 19:42:03.272498 2019] [:warn] [pid 1864:tid 1032] (OS 6)The handle is invalid. : Failed to destroy the dashboard mutex 'C:\\WINDOWS\\TEMP/mod_mono_dashboard_default_2.lock' [Fri Jan 11 19:42:04.533764 2019] [mpm_winnt:notice] [pid 3276:tid 1100] AH00455: Apache/2.4.23 (Win64) OpenSSL/1.0.2j mod_mono/3.12 mod_wsgi/4.6.5 Python/3.6 PHP/7.1.1 configured -- resuming normal operations [Fri Jan 11 19:42:04.533764 2019] [mpm_winnt:notice] [pid 3276:tid 1100] AH00456: Server built: Sep 6 2016 21:33:53 [Fri Jan 11 19:42:04.533764 2019] [core:notice] [pid 3276:tid 1100] AH00094: Command line: 'E:\\httpd\\bin\\httpd.exe -d E:/httpd' [Fri Jan 11 19:42:04.549387 2019] [mpm_winnt:notice] [pid 3276:tid 1100] AH00418: Parent: Created child process 3524 [Fri Jan 11 19:42:05.520762 2019] [auth_digest:notice] [pid 3524:tid 1040] AH01757: generating secret for digest authentication ... Here is a screenshot of Command Prompt Windows while running xsp4 --port 2000:https://imgur.com/a/aoOjJrJ And a screenshot of the page while visiting 127.0.0.1:2000/hello.aspx: https://imgur.com/a/I5HjmuW The screenshot of while visiting localhost/hello.aspx: https://imgur.com/a/0L8k3cs
  7. Okay! I've changed the port to 2000. Now I'm getting 503 Service Unavailable. Here is the error log: [Fri Jan 11 18:06:21.180002 2019] [mpm_winnt:notice] [pid 3276:tid 1100] AH00424: Parent: Received restart signal -- Restarting the server. [Fri Jan 11 18:06:22.511253 2019] [:error] [pid 3276] mod_mono: connect error (Unknown error). Address: 127.0.0.1 Port: 2000 [Fri Jan 11 18:06:23.226797 2019] [mpm_winnt:notice] [pid 8232:tid 1032] AH00364: Child: All worker threads have exited. [Fri Jan 11 18:06:24.429895 2019] [auth_digest:notice] [pid 3276:tid 1100] AH01757: generating secret for digest authentication ... [Fri Jan 11 18:06:24.881508 2019] [:error] [pid 8232:tid 1032] mod_mono: connect error (Unknown error). Address: 127.0.0.1 Port: 2000 [Fri Jan 11 18:06:27.465706 2019] [mpm_winnt:notice] [pid 3276:tid 1100] AH00455: Apache/2.4.23 (Win64) OpenSSL/1.0.2j mod_mono/3.12 mod_wsgi/4.6.5 Python/3.6 PHP/7.1.1 configured -- resuming normal operations [Fri Jan 11 18:06:27.465706 2019] [mpm_winnt:notice] [pid 3276:tid 1100] AH00456: Server built: Sep 6 2016 21:33:53 [Fri Jan 11 18:06:27.465706 2019] [core:notice] [pid 3276:tid 1100] AH00094: Command line: 'E:\\httpd\\bin\\httpd.exe -d E:/httpd' [Fri Jan 11 18:06:27.465706 2019] [mpm_winnt:notice] [pid 3276:tid 1100] AH00418: Parent: Created child process 1864 [Fri Jan 11 18:06:28.725957 2019] [auth_digest:notice] [pid 1864:tid 1032] AH01757: generating secret for digest authentication ... I think apache couldn't connect to mod_mono using port 2000. But I can't figure out why!
  8. Here is my mod_mono.conf: # mod_mono.conf # Achtung! This file may be overwritten # Use 'include mod_mono.conf' from other configuration file # to load mod_mono module. <IfModule !mod_mono.c> LoadModule mono_module modules/mod_mono.so </IfModule> <IfModule mono_module> AddType application/x-asp-net .config .cs .csproj .dll .resources .resx .sln .vb .vbproj AddType application/x-asp-net .asax .ascx .ashx .asmx .aspx .axd .browser .licx .master .rem .sitemap .skin .soap .webinfo #AddHandler mod_mono .asax .ascx .ashx .asmx .aspx .axd .browser .licx .master .rem .sitemap .skin .soap .webinfo .config .cs .csproj .dll .resources .resx .sln .vb .vbproj MonoAutoApplication disabled MonoPath "C:\Program Files\Mono" #MonoServerPath "C:\Program Files\Mono\lib\mono\gac\mod-mono-server4\4.4.0.0__0738eb9f132ed756\mod-mono-server4" #MonoServerPath "C:\Program Files\Mono\lib\mono\4.5\mod-mono-server4.exe" #MonoServerPath "C:\Program Files\Mono\bin\mod-mono-server4.bat" MonoServerPath "C:\Program Files\Mono\bin\xsp4.bat" #MonoListenAddress 127.0.0.1 MonoListenPort 80 #MonoWapiDir "E:/httpd/htdocs" MonoApplications "/:E:\httpd\htdocs" #MonoApplicationsConfigFile "E:/httpd/htdocs/web.config" #MonoApplicationsConfigDir "E:/httpd/htdocs/webapp" MonoDebug true <IfModule dir_module> DirectoryIndex index.aspx DirectoryIndex Default.aspx DirectoryIndex default.aspx </IfModule> <DirectoryMatch "/(bin|App_Code|App_Data|App_GlobalResources|App_LocalResources)/"> Order deny,allow Deny from all </DirectoryMatch> <Location "/"> #MonoSetServerAlias default Allow from all Order allow,deny SetHandler mono SetOutputFilter DEFLATE SetEnvIfNoCase REQUEST_URI "\.(?:gif|jpe?g|png)$" no-gzip dont-vary AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript </Location> <Location "/mono"> #Allow from 127.0.0.1::1 SetHandler mono-ctrl </Location> </IfModule> Here is my current error.log: [Fri Jan 11 16:33:55.693634 2019] [mpm_winnt:notice] [pid 3276:tid 1100] AH00424: Parent: Received restart signal -- Restarting the server. [Fri Jan 11 16:33:56.834309 2019] [:error] [pid 3276] mod_mono: connect error (Unknown error). Address: 127.0.0.1 Port: 2000 [Fri Jan 11 16:33:57.724921 2019] [mpm_winnt:notice] [pid 4572:tid 1028] AH00364: Child: All worker threads have exited. [Fri Jan 11 16:33:58.006145 2019] [auth_digest:notice] [pid 3276:tid 1100] AH01757: generating secret for digest authentication ... [Fri Jan 11 16:33:59.115484 2019] [:error] [pid 4572:tid 1028] mod_mono: connect error (Unknown error). Address: 127.0.0.1 Port: 2000 [Fri Jan 11 16:33:59.115484 2019] [:warn] [pid 4572:tid 1028] (OS 6)The handle is invalid. : Failed to release dashboard lock after destroying the dashboard [Fri Jan 11 16:34:00.521695 2019] [mpm_winnt:notice] [pid 3276:tid 1100] AH00455: Apache/2.4.23 (Win64) OpenSSL/1.0.2j mod_mono/3.12 mod_wsgi/4.6.5 Python/3.6 PHP/7.1.1 configured -- resuming normal operations [Fri Jan 11 16:34:00.521695 2019] [mpm_winnt:notice] [pid 3276:tid 1100] AH00456: Server built: Sep 6 2016 21:33:53 [Fri Jan 11 16:34:00.521695 2019] [core:notice] [pid 3276:tid 1100] AH00094: Command line: 'E:\\httpd\\bin\\httpd.exe -d E:/httpd' [Fri Jan 11 16:34:00.521695 2019] [mpm_winnt:notice] [pid 3276:tid 1100] AH00418: Parent: Created child process 8232 [Fri Jan 11 16:34:01.881019 2019] [auth_digest:notice] [pid 8232:tid 1032] AH01757: generating secret for digest authentication ... [Fri Jan 11 16:34:03.943454 2019] [mpm_winnt:notice] [pid 8232:tid 1032] AH00354: Child: Starting 64 worker threads. And here is a screenshot of an aspx page working without apache by running xsp4 --port 9000 & visiting localhost:9000/hello.aspx:https://imgur.com/a/5LasWhP Here is the screenshot of the same aspx page showing 500 Error with Apache: https://imgur.com/a/bxISYUB
  9. Okay! I've solved it by creating a mod-mono-server4.bat file in /bin directory and changing MonoServerPath to "C:\Program files\Mono\bin\mod-mono-server4.bat" but now I can visit the control panel of mod_mono. As I can now use the mod_mono control panel I've started the mod_mono server which was labelled as default. But now I'm getting a 500 Internal Server Error when I visit a file "localhost/hello.aspx". But the file is working fine when I run "xsp4 --port 9000" and visit localhost:9000/hello.aspx.
  10. Here is the Apache error.log: [Fri Jan 11 12:34:23.936929 2019] [auth_digest:notice] [pid 6240:tid 1028] AH01757: generating secret for digest authentication ... [Fri Jan 11 12:34:26.655602 2019] [:error] [pid 6240:tid 1028] mod_mono: connect error (Unknown error). Address: 127.0.0.1 Port: 2000 [Fri Jan 11 12:34:26.655602 2019] [:error] [pid 6240:tid 1028] Failed running 'C:\\Program Files\\Mono\\lib\\mono\\gac\\mod-mono-server4\\4.4.0.0__0738eb9f132ed756\\mod-mono-server4 --address 127.0.0.1 --port 2000 --nonstop --master (null) (null) (null) (null) (null) (null)'. Reason: Unknown error [Fri Jan 11 12:34:26.718099 2019] [mpm_winnt:notice] [pid 6240:tid 1028] AH00354: Child: Starting 64 worker threads.
  11. I know but to do it I need to change everything in my websites as I'm running 7 Virtual Host. For example, when I'm including a file in PHP. But I need to run ASP.NET on Windows for college project. My project is to build a website in PHP, but for some specific pages use ASP.NET. My college also suggests to use Linux but I thought I'm already running an Apache server on Windows why not complete the project on the same server instead of installing Linux on my computer. Somehow I've found a Windows (64bits) version of mod_mono.so from a forum (a user on the forum built a x86 & x64 versions for Windows using msvc). So I've downloaded it and loaded with httpd & it has been loaded successfully. But now I'm getting a 503 Service Unavailable error on aspx pages. But when I visit /mono/ directory which is the control panel of mod_mono which is loaded using SetHandler mono-ctrl, I can see the contents. But the other, for example, I've created a simple aspx page on / (http://localhost/test.aspx) to check if mod_mono is working or not, the aspx page is showing a 503 Service Unavailable error.
  12. Actually I've not used Linux before. So it will be a problem for me to switch to Linux now. But I need to run mod_mono somehow on Windows. There is a module exists which is mod_aspdotnet but it supports Apache 2.2 only. For now can you tell me why the aspx file giving a Error 503.
  13. Well, I've already checked that link but they've only 32bits version of mod_mono for Apache 2.2. But something I found the mod_mono.so (64bits) and created an mod_mono.conf file and included it to httpd.conf. But when I've run an aspx file it gave me a 503 Service Unavailable error. Actually I don't know if mod_mono is working or not. And I want to run mod_mono for whole not only from a specific folder like "mydomain.com/mono/" which is described everywhere in the Internet.
  14. Hi! I've installed Mono 5.18 (using msi installer). But the problem is the mod_mono.so & mod_mono.conf are missing from the installation. So I'm unable to configure Apache 2.4 (64Bits) to load mod_mono module. My question is, how can I get those files or how can I run mod_mono with Apache 2.4 (64Bits) on Windows (64Bits)?
  15. Got it! I'm going to use PHP7.1, it will be more easier than changing my whole scripts. Thank you very much!
  16. Hi again, I'm getting the following error after uploading my site: Fatal Error: Cannot use Careers4You\Helpers\Object as Object because 'Object' is a special class name in /home/sgn/public_html/careers4you/config/classes/Careers4You/User/Users.php on line 5But my website is working fine with the above class name 'Object' in my local server. I'm running Apache HTTPD 2.4 with PHP7.1.1, MySQL8 on Windows 10.- Thanks in advance.
  17. Yeah, it worked. But not sure about what happened with the .htaccess file. As I'm using my mobile right now. Thank you very much for helping me.
  18. Yes, you're right. But, how it can be? I've manually set the PHP version of all domains to PHP 7.2 (ea-php72). Let me confirm that again.
  19. Hi, I've some classes which use the spaceship (<=>) operator as a callback for usort() to sort an associative array by the value of a key. Everything is working fine in my localhost with Apache HTTPD 2.4.23, PHP 7.1.1 running on Windows 10. But after I've uploaded the website to HelioHost, I've got the following error: Parse error: syntax error, unexpected '<' in /home/sgn/public_html/careers4you/config/classes/Careers4You/User/Users.php on line 120 Here is the class: <?php namespace Careers4You\User; session_start(); use \SGNetworks as sgn; use \SGNetworks\SGNErrors as sgne; class Users extends sgn\SGNDatabase{ private $db; private $sgne; const table = "users"; private $tbl; private $sgn; private $sgna; private $uid; function __construct(){ $this->db=parent::getDatabase("accounts"); $this->sgne=new sgn\SGNError; $this->tbl=self::table; $this->sgn=new sgn\SGNetworks; $this->sgna=new sgn\SGNAccounts; $this->uid=$_SESSION['sgn-login_uid']; } private function sort_array($array,$k,$order="ASC"){ $order=strtolower($order); if($order=="asc"){ // Ascending Order usort($array, function($item1, $item2){ return $item1[$k] <=> $item2[$k]; }); } elseif($order=="desc"){ // Descending Order usort($array, function($item1, $item2){ return $item2[$k] <=> $item1[$k]; }); } else { // Ascending Order usort($array, function($item1, $item2){ return $item1[$k] <=> $item2[$k]; }); } return $array; } function isJson($string) { json_decode($string); return (json_last_error() == JSON_ERROR_NONE); } function getUsersCount($type='all'){ $type=filter_data($type,$this->db); if($type=='normal') $cond=" WHERE status='1'"; elseif($type=='banned') $cond=" WHERE status='0'"; $s="SELECT count(id) FROM {$this->tbl}{$cond}"; if($q=db_query($s,$this->db)){ if(db_num_rows($q)>0) return db_fetch_row($q)[0]; } else { $this->sgne->triggerError($this->sgne->processError(sgne::COMMON_ERRORS['SQL_ERROR'])); } } function getUsers($type='all',$sort="timestamp",$order='ASC',$offset=0,$limit=20){ $type=filter_data($type,$this->db); $sort=filter_data($sort,$this->db); $order=filter_data($order,$this->db); $offset=(!is_numeric($offset))?0:$offset; $limit=(!is_numeric($limit))?"":" LIMIT {$offset}, {$limit}"; if($type=='normal') $cond=" WHERE status='1'"; elseif($type=='banned') $cond=" WHERE status='0'"; else $cond=" WHERE status='1'"; $s="SELECT * FROM {$this->tbl}{$cond} ORDER BY {$sort} {$order}{$limit}"; if($q=db_query($s,$this->db)){ if(db_num_rows($q)>0){ $result=array(); while($r=db_fetch_assoc($q)){ $r['fname']=$this->sgna->getUserPersonalProfile('fname',$r['uid']); $r['mname']=$this->sgna->getUserPersonalProfile('mname',$r['uid']); $r['lname']=$this->sgna->getUserPersonalProfile('lname',$r['uid']); $r['dp']=$this->sgna->getUserPersonalProfile('dp',$r['uid']); $r['dp_mime']=$this->sgna->getUserPersonalProfile('dp_mime',$r['uid']); if($r['mname']) $r['name']=$r['fname']." ".$r['mname']." ".$r['lname']; else $r['name']=$r['fname']." ".$r['lname']; $r['dp_image']=(!$r['dp'])?"":bin2file($r['dp'],$r['dp_mime']); array_push($result,$r); } return $result; } } else { $this->sgne->triggerError($this->sgne->processError(sgne::COMMON_ERRORS['SQL_ERROR'])); } } function getUser($id,$f="*"){ $id=filter_data($id,$this->db); $f=filter_data($f,$this->db); $get=$f; if($f=='full_name' || $f=='dp') $f='uid'; if(is_numeric($id)){ $s="SELECT {$f} FROM {$this->tbl} WHERE id='{$id}' OR uid='{$id}'"; if($q=db_query($s,$this->db)){ if(db_num_rows($q)>0){ $r=db_fetch_assoc($q); $r['fname']=$this->sgna->getUserPersonalProfile('fname',$r['uid']); $r['mname']=$this->sgna->getUserPersonalProfile('mname',$r['uid']); $r['lname']=$this->sgna->getUserPersonalProfile('lname',$r['uid']); $r['full_name']=(!$r['mname'])?"{$r['fname']} {$r['lname']}":"{$r['fname']} {$r['mname']} {$r['lname']}"; $r['dp']=$this->sgna->getUserPersonalProfile('dp',$r['uid']); $r['dp_mime']=$this->sgna->getUserPersonalProfile('dp_mime',$r['uid']); if($r['mname']) $r['name']=$r['fname']." ".$r['mname']." ".$r['lname']; else $r['name']=$r['fname']." ".$r['lname']; $r['dp_image']=(!$r['dp'])?"":bin2file($r['dp'],$r['dp_mime']); if($r['experience']){ $r['experience']=json_decode(defilter_data($r['experience'],$this->db),true); usort($r['experience'], function($item1, $item2){ return $item2['date'] <=> $item1['date']; }); $r['experience']=json_encode($r['experience'],JSON_NUMERIC_CHECK); } if($r['education']){ $r['education']=json_decode(defilter_data($r['education'],$this->db),true); usort($r['education'], function($item1, $item2){ return $item2['date'] <=> $item1['date']; }); $r['education']=json_encode($r['education'],JSON_NUMERIC_CHECK); } if($r['skills']){ $r['skills']=json_decode(defilter_data($r['skills'],$this->db),true); usort($r['skills'], function($item1, $item2){ return $item2['date'] <=> $item1['date']; }); $r['skills']=json_encode($r['skills'],JSON_NUMERIC_CHECK); } return ($get!="*")?$r[$get]:$r; } } else { $this->sgne->triggerError($this->sgne->processError(sgne::COMMON_ERRORS['SQL_QUERY_ERROR'])); } } else { $this->sgne->triggerError(sgne::COMMON_ERRORS['INVALID_PARAM_VALUE']['msg'], sgne::COMMON_ERRORS['INVALID_PARAM_VALUE']['code'],"Author ID OR AID"); } } function updateProfile($about,$addr1,$addr2,$street,$locality,$district,$zip,$city,$state,$country,$phone,$email,$website,$dob,$sex,$relationship,$hobbies,$experience,$qualifications,$skills){ $about=filter_data($about,$this->db); $addr1=filter_data($addr1,$this->db); $addr2=filter_data($addr2,$this->db); $street=filter_data($street,$this->db); $locality=filter_data($locality,$this->db); $district=filter_data($district,$this->db); $zip=filter_data($zip,$this->db); $city=filter_data($city,$this->db); $state=filter_data($state,$this->db); $country=filter_data($country,$this->db); $phone=filter_data($phone,$this->db); $email=filter_data($email,$this->db); $website=filter_data($website,$this->db); $dob=filter_data($dob,$this->db); $sex=filter_data($sex,$this->db); $relationship=filter_data($relationship,$this->db); $hobbies=filter_data($hobbies,$this->db); $experience=filter_data($experience,$this->db); $qualifications=filter_data($qualifications,$this->db); $skills=filter_data($skills,$this->db); $s="UPDATE {$this->tbl} SET aboutme='{$about}', address1='{$addr1}', address2='{$addr2}', street='{$street}', locality='{$locality}', district='{$district}', zip='{$zip}', city='{$city}', state='{$state}', country='{$country}', phone='{$phone}', email='{$email}', website='{$website}', dob='{$dob}', sex='{$sex}', relationship='{$relationship}', hobbies='{$hobbies}', experience='{$experience}', education='{$qualifications}', skills='{$skills}' WHERE uid='{$this->uid}'"; if(db_query($s,$this->db)) return true; else return false; } function getProfileHeading($id){ $id=filter_data($id,$this->db); if(is_numeric($id)){ $s="SELECT experience,education FROM {$this->tbl} WHERE uid='{$id}' OR id='{$id}'"; if($q=db_query($s,$this->db)){ if(db_num_rows($q)==1){ $r=db_fetch_assoc($q); $heading=""; if(!empty($r['experience'])){ $experience=json_decode(defilter_data($r['experience'],$this->db),true); usort($experience, function($item1, $item2){ return $item2['date'] <=> $item1['date']; }); $mostRecent=0; $mostRecentArray=""; foreach($experience as $exp){ $curDate = strtotime($exp['date']); if($curDate > $mostRecent) { $mostRecent = $curDate; $mostRecentArray=$exp; } } if(!empty($mostRecentArray['name']) && !empty($mostRecentArray['company'])) $heading="{$mostRecentArray['name']}, {$mostRecentArray['company']}"; elseif(!empty($mostRecentArray['name'])) $heading=$mostRecentArray['name']; } elseif(!empty($r['education'])){ $education=json_decode(defilter_data($r['education'],$this->db),true); usort($education, function($item1, $item2){ return $item2['date'] <=> $item1['date']; }); $mostRecent=0; $mostRecentArray=""; foreach($education as $edu){ $curDate = strtotime($edu['date']); if($curDate > $mostRecent) { $mostRecent = $curDate; $mostRecentArray=$edu; } } if(!empty($mostRecentArray['name']) && !empty($mostRecentArray['institution'])) $heading="{$mostRecentArray['name']}, {$mostRecentArray['institution']}"; elseif(!empty($mostRecentArray['name'])) $heading=$mostRecentArray['name']; elseif(!empty($mostRecentArray['institution'])) $heading="Student of {$mostRecentArray['institution']}"; } elseif(!empty($r['skills'])){ $skills=json_decode(defilter_data($r['skills'],$this->db),true); usort($skills, function($item1, $item2){ return $item2['date'] <=> $item1['date']; }); $mostRecent=0; $mostRecentArray=""; foreach($skills as $s){ $curDate = strtotime($s['date']); if($curDate > $mostRecent) { $mostRecent = $curDate; $mostRecentArray=$s; } } if(!empty($mostRecentArray['name'])) $heading=$mostRecentArray['name']; } return $heading; } } else { $this->sgne->triggerError($this->sgne->processError(sgne::COMMON_ERRORS['SQL_QUERY_ERROR'])); } } else { $this->sgne->triggerError(sgne::COMMON_ERRORS['INVALID_PARAM_VALUE']['msg'], sgne::COMMON_ERRORS['INVALID_PARAM_VALUE']['code'],"User ID OR UID"); } } } ?>
  20. Glad to help you. Feel free to ask, if you have any problems.
  21. Okay, I've tried but it's not working that way I've wanted. Sorry but I don't have access to the Internet for the past 4 days, so I was not able to post the result here. Here is the code of my plugin: /**************************************************************************************************************************** ******************************************************SGNUPLOAD v1.0.1******************************************************* ***************************************************************************************************************************** * DATE: October 15, 2018 * * AUTHOR: Sagnik Ganguly * * E-MAIL: sagnikganguly2012@rediffmail.com * * WEBSITE: https://plugins.sgnetworks.cf/jquery/sgnupload * * DOCUMENTATION: https://docs.plugins.sgnetworks.cf/jquery/sgnupload * ****************************************************************************************************************************/ if (!window.BlobBuilder) { window.BlobBuilder = window.WebKitBlobBuilder || window.MozBlobBuilder; } if (!window.URL) { window.URL = window.webkitURL || window.mozURL; } $.worker = function(args) { var def = $.Deferred(function(dfd) { var worker; if (window.Worker) { var url = args.file; // If we have found a DOM object related, // we need constructo a `BlobBuilder` to // inline the web worker. if(args.id){ var dom = document.querySelector('#' + args.id), blob = new BlobBuilder(); blob.append(dom.textContent); url = window.URL.createObjectURL(blob.getBlob()); } // Construct the Web Worker var worker = new Worker(url); // If the Worker reports success, resolve the Deferred worker.onmessage = function(event) { dfd.resolve(event); }; // If the Worker reports an error, reject the Deferred worker.onerror = function(event) { dfd.reject(event); }; // Create a pointer to 'postMessage' on the Deferred this.postMessage = function(msg){ worker.postMessage(msg); }; this.terminate = function(){ worker.terminate(); }; // If args were passed, start the worker with supplied args if(args.args){ worker.postMessage(args.args); } } else { $.error("Worker is not supported in this browser!"); } }); return def; }; (function ($) { var SGNUpload = function (element, options) { var _pluginName = "SGNUpload", _version = "1.0.1"; var SPACE_KB = 1024, SPACE_MB = 1024 * SPACE_KB; SPACE_GB = 1024 * SPACE_MB; SPACE_TB = 1024 * SPACE_GB; var _defaults = { onProgressUpdate: function (progress, loaded, lengthOfFile) {}, onTaskCompleted: function (e, response) {}, onTaskCancelled: function () {}, onTaskFailed: function (e, error) {} } var _options = { url: '', formData: '', onProgressUpdate: '', onTaskCompleted: '', onTaskCancelled: '', onTaskFailed: '' } var plugin = this, $element = $(element); plugin.settings = {} function readBlob(opt_startByte, opt_stopByte) { var files = document.getElementById('files').files; if (!files.length) { alert('Please select a file!'); return; } var file = files[0]; var start = parseInt(opt_startByte) || 0; var stop = parseInt(opt_stopByte) || file.size - 1; var reader = new FileReader(); // If we use onloadend, we need to check the readyState. reader.onloadend = function (evt) { if (evt.target.readyState == FileReader.DONE) { // DONE == 2 /* document.getElementById('byte_content').textContent = evt.target.result; document.getElementById('byte_range').textContent = ['Read bytes: ', start + 1, ' - ', stop + 1, ' of ', file.size, ' byte file'].join(''); */ } }; var blob = file.slice(start, stop + 1); reader.readAsBinaryString(blob); } function Bytes2String(sizeInBytes) { if (sizeInBytes < SPACE_KB) { return sizeInBytes.toString() + " Byte(s)"; } else if (sizeInBytes < SPACE_MB) { return (sizeInBytes / SPACE_KB).toString() + " KB"; } else if (sizeInBytes < SPACE_GB) { return (sizeInBytes / SPACE_MB).toString() + " MB"; } else if (sizeInBytes < SPACE_TB) { return (sizeInBytes / SPACE_GB).toString() + " GB"; } else { return (sizeInBytes / SPACE_TB).toString() + " TB"; } } function Bytes2ProgressString(progressInBytes, totalInBytes) { if (totalInBytes < SPACE_KB) { return progressInBytes.toString() + "/" + totalInBytes.toString() + " Byte(s)"; } else if (totalInBytes < SPACE_MB) { return (progressInBytes / SPACE_KB).toString() + "/" + (totalInBytes / SPACE_KB).toString() + " KB"; } else if (totalInBytes < SPACE_GB) { return (progressInBytes / SPACE_MB).toString() + "/" + (totalInBytes / SPACE_MB).toString() + " MB"; } else if (totalInBytes < SPACE_TB) { return (progressInBytes / SPACE_GB).toString() + "/" + (totalInBytes / SPACE_GB).toString() + " GB"; } else { return (progressInBytes / SPACE_TB).toString() + "/" + (totalInBytes / SPACE_TB).toString() + " TB"; } } function percentage(progress, total) { return Math.round(total ? progress * 100 / total : 100); } function publishProgress(e,loaded,total) { var t = $.type(e), percent = t == "object" && e.lengthComputable ? percentage(e.loaded, e.total) + "%" : t == "number" ? e + "%" : t == "string" ? e : "0%"; if(t=="object" && e.lengthComputable && loaded===undefine && total===undefined) plugin.settings.onProgressUpdate(percent, e.loaded, e.total); else if(t=="number" && $.isNumeric(loaded) && $.isNumeric(total)) plugin.settings.onProgressUpdate(percent, loaded, total); } function werror(e) { console.log(e, 'ERROR: Line ', e.lineno, ' in ', e.filename, ': ', e.message); } function _create() { /* $.ajax({ url: plugin.settings.url, type: 'POST', data: plugin.settings.formData, cache: false, contentType: false, processData: false, xhr: function(){ var myXhr = $.ajaxSettings.xhr(); if(myXhr.upload){ myXhr.upload.addEventListener('progress', function(e){ if(e.lengthComputable){ publishProgress(e); } }, false); myXhr.upload.addEventListener('loadend', function(e){ publishProgress(e); }, false); } return myXhr; }, success: function(d){ plugin.settings.onTaskCompleted(d); }, error: function(xhr){ plugin.settings.onTaskFailed(xhr); } }); */ /******* HERE IS THE PROBLEM ******* *AS MY PLUGIN IS ASSOCIATED ON $ INSTEAD OF $.fn, I DON'T HAVE ACCESS TO DOM ("#fileupload") AS USERS CAN HAVE AN ID OTHER THAN THAT********* * SO I NEED A WAY TO SUPPORT CHUNKED FILE UPLOADS WITH $.fn, I NEED A $. OBJECT */ $("#fileupload").fileupload({ url: plugin.settings.url, //dataType: 'json', done: function (e, data) { /* $.each(data.result.files, function (index, file) { $('<p/>').text(file.name).appendTo('#files'); }); */ plugin.settings.onTaskCompleted(e,data); }, progress: function (e, data) { var progress = parseInt(data.loaded / data.total * 100, 10); /* $('#progress .progress-bar').css( 'width', progress + '%' ); */ publishProgress(progress, data.loaded, data.total); }, fail: function(e, data){ plugin.settings.onTaskFailed(e,data); } }) } plugin.init = function (args) { plugin.settings = $.extend(_defaults, args); $.each(plugin.settings, function (k, v) { if (typeof v === 'function') { if (_options.hasOwnProperty(k)) { _checked = true; } else { _checked = false; $.error('Invalid callback for: ' + k + ' in jQuery.' + _pluginName); } } else if (typeof v === 'string') { if ($.inArray(v, _options[k]) !== -1 || _options.hasOwnProperty(k)) { _checked = true; } else { _checked = false; $.error('Invalid value: ' + v + ' for option: ' + k + ' in jQuery.' + _pluginName); } } }); if (_checked) { $element.data('options', plugin.settings); _create(); } else { $.error('Something went wrong in jQuery.' + _pluginName); } } } $.SGNUpload = function (options) { var _this = this; var _plugin = new SGNUpload(this, options); _this.initialize = function (options) { _plugin.init(options); return this; } if (typeof options !== 'undefined') return this.initialize(options); return this; } return this; })(jQuery); And here is the inilization code of the plugin: submitBtn.click(function(e){ e.preventDefault(); var $this=$(this); $(this).SGNSpinner({ showContents: false, halign: 'center', valign: 'middle' }); if(validationPassed){ if(tos.prop("checked") && privacy.prop("checked")){ var data=new FormData($('#sge-upload_gamePlayForm')[0]); $.each(files, function(key, value){ data.append(key, value); }); $.SGNUpload({ url: '<?=$public_root;?>upload/ajax/gameplay', formData: data, onProgressUpdate: function(progress, loaded, lengthOfFile){ console.log(progress, loaded, lengthOfFile); }, onTaskCompleted: function(response){ console.log(response); }, onTaskCancelled: function(){ }, onTaskFailed: function(error){ console.log(error); } }); } else { $(this).SGNSpinner().hide(); $this.SGNIMsg("You must be agree to our Terms Of Service & Privacy Policy in order to submit the form. Please read the agreements first then on the I agree buttons then submit the form again."); } } else { $(this).SGNSpinner().hide(); alert("Please check the details and try again"); } }) });
  22. Hi, I'm developing a plugin which will allow users to upload files to the server as well as send form data to the server. But I need to chunk/slice large files using Web/Service Worker so that it doesn't break PHP's upload_max_filesize & post_max_size and don't halt the UI as well. But the problem is, if the form contains input fields, I need to send them as well. I want know how can I do that?
  23. Okay. I got it. So did you find out where the attack came from?
×
×
  • Create New...