ការទាញយកពត៌មានទិន្នន័យ ពីវេបផេក (Scraping Data) គឺជាការពន្លាទិន្នន័យមួយចំនួន ភាគច្រើន Text ដើម្បីច្រោះទិន្នន័យទាំងនោះចេញពី html អោយក្លាយជាទិន្នន័យមួយដែលយើងអាចប្រើប្រាស់បាន។ វីដេអូ ខាងក្រោម នេះនិងបង្ហាញពីការប្រើប្រាស់ភាសា PHP ជាមួយ Library សាមញ្ញមួយ មានតែពីរ វីដេអូប៉ុណ្ណោះ នឹងចេះហើយ។

របៀបទាញយកទិន្នន័យពី Webpage ដទៃមកធ្វើជារបស់ខ្លួន ដោយ PHP

Evolution 2001

The Last Battle(Medieval War)

The Dog of Warroir

ក្នុងការបង្កើត Spring Project វាមានច្រើនវិធីសាស្រ្តក្នុងការបង្កើត និង​ configuration។ គេអាច បង្កើត Spring តាមរយៈ Dynamic Web Project ហើយបម្លែងទៅជា Maven ឬបង្កើតជា Maven តែម្តង ឬ តាម Spring Project ។ បន្តិចទៀតនេះ នឹងមានការបង្ហាញពី ការបែងចែក សិទ្ធរបស់អ្នកប្រើប្រាស់ម្នាក់ៗ ដោយការពារលើ URL។
៙តម្រូវការ
  • Spring 3.2.8.RELEASE
  • Spring Security 3.2.3.RELEASE
  • JSTL 1.2
  • JDK 1.7
  • Tomcat 8.x
  • STS 3.7.0
៙រចនាសម្ពន្ធ័ធ្វើរួចរាល់


៙pom.xml
 <properties>
  <org.springframework-version>3.2.8.RELEASE</org.springframework-version>
  <spring.security.version>3.2.3.RELEASE</spring.security.version>
  <jstl.version>1.2</jstl.version>
 </properties>]
 <dependencies>
  <!-- Spring -->
  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-context</artifactId>
   <version>${org.springframework-version}</version>
  </dependency>
  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-webmvc</artifactId>
   <version>${org.springframework-version}</version>
  </dependency>
  
  <!-- Spring Security -->
  <dependency>
   <groupId>org.springframework.security</groupId>
   <artifactId>spring-security-web</artifactId>
   <version>${spring.security.version}</version>
  </dependency>

  <dependency>
   <groupId>org.springframework.security</groupId>
   <artifactId>spring-security-config</artifactId>
   <version>${spring.security.version}</version>
  </dependency>

  <!-- jstl for jsp page -->
  <dependency>
   <groupId>jstl</groupId>
   <artifactId>jstl</artifactId>
   <version>${jstl.version}</version>
  </dependency>
        
 </dependencies>

៙web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

 <!-- The definition of the Root Spring Container shared by all Servlets and Filters -->
 <context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>/WEB-INF/spring/root-context.xml</param-value>
 </context-param>
 
 <!-- Creates the Spring Container shared by all Servlets and Filters -->
 <!-- <listener>
  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
 </listener> -->
 <!-- ContextLoader no here in SecurityInit class was load -->
 <!-- Processes application requests -->
 <servlet>
  <servlet-name>appServlet</servlet-name>
  <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  <init-param>
   <param-name>contextConfigLocation</param-name>
   <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
  </init-param>
  <load-on-startup>1</load-on-startup>
 </servlet>
  
 <servlet-mapping>
  <servlet-name>appServlet</servlet-name>
  <url-pattern>/</url-pattern>
 </servlet-mapping>
</web-app>

៙SecurityConfig.java|package com.heng.config
package com.heng.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter{
 @Autowired
 public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
   auth.inMemoryAuthentication().withUser("vary").password("123456").roles("USER");
   auth.inMemoryAuthentication().withUser("admin").password("123456").roles("ADMIN");
   auth.inMemoryAuthentication().withUser("dba").password("123456").roles("DBA");
 }

 @Override
 protected void configure(HttpSecurity http) throws Exception {

   http.authorizeRequests()
  .antMatchers("/admin/**").access("hasRole('ROLE_ADMIN')  or hasRole('ROLE_DBA')")
  .antMatchers("/dba/**").access("hasRole('ROLE_DBA')")
  .and().formLogin();
   http.csrf().disable();
 }
}
  • @EnableWebSecurity annotation និង extends  ពីClass WebSecurityConfigurerAdapter ជួយអោយយើង ទាមទារនូវការកំនត់សិទ្ធ។
  • Enable Http Basic និង Form login 
  • Spring Security និងផ្តល់នូវ URL login និង logout page free សម្រាប់អ្នក។
  • URL (/admin/) អាចចូលបាន លុះត្រាតែមាន សិទ្ធជា ADMIN ឬ DBA។

៙SecurityInit.java|package com.heng.config
package com.heng.config;

import org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer;

public class SecurityInit extends AbstractSecurityWebApplicationInitializer{
 public SecurityInit() {
  super(SecurityConfig.class);
 }
 //Load ContextLoaderListener && springSecurityFilterChain
}

៙HomeController.java|package com.heng.samplesecurity.controller
package com.heng.samplesecurity.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author Heng-Cyber
 */
@Controller
public class HomeController {
 
 @RequestMapping(value = { "/", "/welcome**" }, method = RequestMethod.GET)
 public ModelAndView welcomePage() {

  ModelAndView model = new ModelAndView();
  model.addObject("title", "Spring Security Hello World");
  model.addObject("message", "This is welcome page!");
  model.setViewName("home");
  return model;

 }

 @RequestMapping(value = "/admin**", method = RequestMethod.GET)
 public ModelAndView adminPage() {
  
  ModelAndView model = new ModelAndView();
  model.addObject("title", "Spring Security Hello World");
  model.addObject("message", "This is protected page - Admin Page!");
  model.setViewName("admin");
  return model;
 }
 @RequestMapping(value = "/dba**", method = RequestMethod.GET)
 public ModelAndView dbaPage() {
  
  ModelAndView model = new ModelAndView();
  model.addObject("title", "Spring Security Hello World");
  model.addObject("message", "This is protected page - Database Page!");
  model.setViewName("admin");
  return model;

 } 
}
៙Screen Shot
Login as simple user
access denied in URL admin
ប្រភព៖  spring.io
ទាញយក Source Code: ទីនេះ

Spring Security Access Role តាមរយៈ Annotation

៙ របៀបបង្កើត ភាសាដើម្បីដំណើរការ Function
[postgresql language plpgsql does not exist]
+ PostgreSQL:
CREATE LANGUAGE plpgsql;

៙ របៀបបង្កើត ID random មិនជាន់គ្នា
[make unique random id in postgresql]
+ PostgreSQL:
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
យើងអាចប្រើវាបានដោយហៅ uuid_generate_v1() ហើយ field របស់យើងត្រូវមាន datatype ជា uuid

៙ របៀបបង្កើត Function ដែល insert ហើយ return record អំបាញ់មិញ
[insert into 2 differ table and return current record]
+ PostgreSQL:
CREATE OR REPLACE FUNCTION insert2tables(tcher_name VARCHAR,stu_name VARCHAR stu_program VARCHAR)
RETURNS void AS $$
DECLARE
last_id uuid;
BEGIN
--Return with data column[tcher_id] back by generate id by uuid_gernerate_v1()
INSERT INTO tb_teacher VALUES(uuid_generate_v1(),$1) RETURNING tcher_id INTO last_id;
--get that id then insert to other table
INSERT INTO tb_program VALUES(uuid_generate_v1(),$2,$3,CAST(last_id AS UUID));
END;
$$ LANGUAGE 'plpgsql'
+ Source:ទីនេះ

៙ របៀបប្តូរ row ពី column
[how to convert row to columns in postgresql]
+ PostgreSQL:
ឧទា៖ ខ្ញុំមាន table ឈ្មោះ tb_fee_types ដែលមានទិន្នន័យ
ខ្ញុំចង់ប្តូរ row [TERM,SEM,YEAR] ទៅជា column
SELECT 
DISTINCT(f.fee_type_id), 
tm.price_fee AS term,
y.price_fee AS "year",
sem.price_fee AS semester
FROM tb_fee_types AS f,
(SELECT * FROM tb_fee_types WHERE type_fee='TERM') AS tm,
(SELECT * FROM tb_fee_types WHERE type_fee='YEAR') AS y,
(SELECT * FROM tb_fee_types WHERE type_fee='SEMESTER') AS sem ORDER BY fee_type_id ASC;
+ Source:ទីនេះ

ឯកសារស្រាវជ្រាវខ្លីៗអំពី SQL ភាគ១


៙ របៀបបង្កើត Hello ក្នុង Spring Framework
+ Source:ទីនេះ

ឯកសារស្រាវជ្រាវខ្លីៗអំពី Spring ភាគ១


៙ គំរូ Query statement Codeigniter
$sql = "SELECT * FROM some_table WHERE id = ? AND status = ? AND author = ?";
$this->db->query($sql, array(3, 'live', 'Rick')); 
+ Source: ទីនេះ

៙ លុប Rout index.php Codeigniter
+ ទាញយក .htaccess file ទីនេះ
+ ចម្លង .htaccess ដាក់ទៅកាន់ [ឈ្មោះProject] និង application
+ Left Click Wampserver-> Apache->Apache Modules->check rewrite_module

ឯកសារស្រាវជ្រាវខ្លីៗអំពី Codeigniter ភាគ១


៙ របៀបតម្លើង Playstore ក្នុង Genymotion
+ ទាញយក Genymotion ARM translation .rarទីនេះ
+ អូសវាដាក់ចូល Emulator ពេលតម្លើងចប់ Restart Genymotion ម្តង
+ ស្វែងរកហើយទាញយកអោយត្រូវVersion Android ទីនេះ
+ អូសវាដាក់ចូល Emulator ពេលតម្លើងចប់ Restart Genymotion ម្តងទៀត

ឯកសារស្រាវជ្រាវខ្លីៗអំពី Android ភាគ១


៙ របៀបប្រើ Servlet File Upload
Source: ទីនេះ

៙ របៀប Customize Error Page ក្នុងweb.xml
+ Error 404 Page not found

  404
  /404.jsp

+ Error 500 Internal server error

  500
  /500.jsp


៙ របៀបប្រើ Java send mail
Source: ទីនេះ

៙ ដំណោះស្រាយបង្កើតServer tomcat 7
+ ខ្ញុំមិនអាចបង្កើតServerនៅក្នុង Eclipse បានដោយមិនវាយអក្សរអី្វបានក្នុងប្រអប់ដូចក្នុងរូប។ Eclipse Add Tomcat Server
+ ដំណោះស្រាយ:
- ចូលទៅកាន់ {workspace-directory}/.metadata/.plugins/org.eclipse.core.runtime/.settings រួចលុប 2 files
  1. org.eclipse.wst.server.core.prefs
  2. org.eclipse.jst.server.tomcat.core.prefs
- Restart Eclipse IDE
Source: ទីនេះ

ឯកសារស្រាវជ្រាវខ្លីៗអំពី Java + Servlet ភាគ១


+ របៀបយកឈ្មោះFile ពី Element input file
$('input[type=file]').val().split('/').pop().split('\\').pop();

+ របៀប Upload File ពី Ajax
var data1="";
data1=new FormData();
data1.append("file",$("input[type=file]")[0].files[0]);
$.ajax({
         url:"upload_main_cate_img",
         type:"POST",
         cache : false,
         contentType : false, //Important
         processData : false, //Important
         data : data1,
         success : function(status) { }
});

ឯកសារស្រាវជ្រាវខ្លីៗអំពី Java Script ភាគ១


សំរាប់ជារៀងរាល់ពេលធ្វើការចុះឈ្មោះ ទៅនិងប្រពន្ធ័និមួយៗ។ ដើម្បីបញ្ចាក់ថា ម៉ែលដែលអ្នក​ចុះឈ្មោះ​នោះ ជា​មែលដែលពិត​ប្រាកដ គេមាន វិធីច្រើនក្នុងការគ្រប់គ្រង​ តែអី្វដែលនិយម គឺ ធ្វើតាម Email Verification។ ខាងក្រោមនេះ​ នឹងរៀបរាប់ពីការ Config លើ Mail server Localhost។

Email Confirmation PHP

វីដេអូខ្លីខាងក្រោមនេះ អ្នកនឹងអាចស្វែងយល់ពីរបៀប ទាញយកនិង​ តម្លើង​ Codeigniter ទៅក្នុង​ local machine។ ក្នុងការតម្លើងវា អ្នកត្រូវតែដំណើរការ PHP Development Environment។ Codeigniter វាត្រូវគេប្រើប្រាស់ជាលក្ខណៈ MVC Pattern ដើម្បីជួយសម្រួលកូដ និងងាយក្នុងការថែទាំទៅថ្ងៃក្រោយ។

Codeigniter Framwork នៃ PHP មូលដ្ឋាន


រៀនកុំព្យូទ័រដោយខ្លួនឯង ភាសាខ្មែរ


C-Programming.KH ភាសាខ្មែរ

បច្ចេកវិទ្យាព័ត៌មាន និងសារគមនាគមន៍ ភាសាខ្មែរ


ស្រីហិតោបទេស ប្រែថា ការប្រៀនប្រដៅឲ្យដល់នូវប្រយោជន៍, ការពន្យល់ប្រយោជន៍, ការប្រាប់ប្រយោជន៍ ឬការដឹកនាំជនានុជនឲ្យបានប្រយោជន៍នៅនាលោកកិយ៍នេះ និងជាពាក្យប្រៀនប្រដៅសីលធម៌ដល់សាធុជនទាំងឡាយ ។ នៅក្នុងសៀវភៅនេះអ្នកនឹងទទួលបាននូវសាច់រឿងដែលមានការអប់រំជាច្រើនរាប់មិនអស់ ។ ហើយនៅក្នុងសៀវភៅនេះចែកចេញជាបួនភាគ៖
១.ភាគទី១ និយាយពីការគប់មិត្ត : ទីនេះ
២.ភាគទី២ និយាយពីការបំបែកមិត្ត : ទីនេះ
៣.ភាគទី៣ និយាយពី សង្រ្គាម : ទីនេះ
៤.ភាគទី៤ និយាយពី សន្តិភាព : ទីនេះ

សៀវភៅស្រីហិតោបទេស PDF


  • សម្រាប់ការប្រឡងអាហារូបរក៍ ការងារ គ្រូ និងប្រឡងផ្សេងៗទៀត
  • ចុចទីនេះដើម្បីទាញយក PDF : ទីនេះ
  • ប្រភព៖ ហ្វេសប៊ុក

វប្បធម៌ និងអរិយធម៌ខ្មែរ ខ្មែរ ឥណ្ឌា

អរិយធម៌ខ្មែរ ភាសាខ្មែរដោយ អ្នកស្រី​ ត្រឹងងា ភាគ១+២


  • សូមយកសៀវភៅនេះទៅអានដើម្បីដឹងពីប្រវត្តិសាស្រ្តខ្មែរពិត
  • សៀវភៅដែលសម្តេចតាទទួលស្គាល់
  • ចុចទីនេះដើម្បីទាញយក PDF : ទីនេះ
  • ប្រភព​ ៖ ហ្វេសប៊ុក

ព្រំដែននៃប្រទេសកម្ពុជាជាមួយបណ្តាប្រទេសនៃសហព័ន្ធឥណ្ឌូចិន ភាសាខ្មែរ

 
ROOT 2S © 2016 - រចនាដោយ គង់ សុវ៉ារីយ៍