<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Php Archives - Hi You, I am Tade</title>
	<atom:link href="https://hoangthuc.com/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>https://hoangthuc.com/tag/php/</link>
	<description></description>
	<lastBuildDate>Sat, 17 Feb 2024 03:59:03 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://hoangthuc.com/wp-content/uploads/2024/02/logoTH-2-150x150.png</url>
	<title>Php Archives - Hi You, I am Tade</title>
	<link>https://hoangthuc.com/tag/php/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Chuyển thư mục public sang public_html trong Laravel khi deploy</title>
		<link>https://hoangthuc.com/chuyen-thu-muc-public-sang-public_html-trong-laravel-khi-deploy/</link>
					<comments>https://hoangthuc.com/chuyen-thu-muc-public-sang-public_html-trong-laravel-khi-deploy/#comments</comments>
		
		<dc:creator><![CDATA[Hoàng Thức]]></dc:creator>
		<pubDate>Fri, 04 Dec 2020 11:29:53 +0000</pubDate>
				<category><![CDATA[Laravel]]></category>
		<category><![CDATA[Php]]></category>
		<guid isPermaLink="false">https://hoangthuc.com/?p=694</guid>

					<description><![CDATA[<p>Hi All, mình viết bài viết này vì mình cũng gặp tình trạng tương tự khi deploy lên host và nó báo sai đường dẫn khá nhiều trong source của mình.  Mình đăng bài này để lưu lại sau này khỏi quên. :)))  Đầu tiên thư mục mặc định nó sẽ có dạng và chúng [&#8230;]</p>
<p>The post <a href="https://hoangthuc.com/chuyen-thu-muc-public-sang-public_html-trong-laravel-khi-deploy/">Chuyển thư mục public sang public_html trong Laravel khi deploy</a> appeared first on <a href="https://hoangthuc.com">Hi You, I am Tade</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><span style="font-family: helvetica, arial, sans-serif;">Hi All, mình viết bài viết này vì mình cũng gặp tình trạng tương tự khi deploy lên host và nó báo sai đường dẫn khá nhiều trong source của mình. </span></p>
<p><span style="font-family: helvetica, arial, sans-serif;">Mình đăng bài này để lưu lại sau này khỏi quên. :))) </span></p>
<p><span style="font-family: helvetica, arial, sans-serif;">Đầu tiên thư mục mặc định nó sẽ có dạng và chúng ta cần chuyển nó thành public_html rồi đẩy lên host. 1 số host như cpanel bạn cầu hình luôn cái đường dẫn luôn cho nhanh nhé.</span></p>
<p><span style="font-family: helvetica, arial, sans-serif;"><img fetchpriority="high" decoding="async" class="size-full wp-image-695 aligncenter" src="https://hoangthuc.com/wp-content/uploads/2020/12/2020-12-04_182003.jpg" alt="" width="841" height="303" srcset="https://hoangthuc.com/wp-content/uploads/2020/12/2020-12-04_182003.jpg 841w, https://hoangthuc.com/wp-content/uploads/2020/12/2020-12-04_182003-300x108.jpg 300w" sizes="(max-width: 841px) 100vw, 841px" /></span></p>
<p><span style="font-family: helvetica, arial, sans-serif;">Sẽ có 4 chỗ mấy bạn cần chỉnh sửa.</span></p>
<pre> </pre>
<pre> </pre>


<h5>./server.php</h5>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
if ($uri !== '/' &amp;&amp; file_exists(__DIR__.'public'.$uri)) { return false; } require_once __DIR__.'/public/index.php';
</pre></div>


<h5>./app/Providers/AppServiceProvider.php</h5>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
public function register() { $this-&gt;app-&gt;bind(&#039;path.public&#039;, function() { return base_path().&#039;/public_html&#039;; }); }
</pre></div>


<h5><strong>./config/filesystems.php</strong></h5>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
&#039;public&#039; =&gt; &#x5B;
  &#039;driver&#039; =&gt; &#039;local&#039;,
  &#039;root&#039; =&gt; storage_path(&#039;app/public&#039;),
  &#039;url&#039; =&gt; env(&#039;APP_URL&#039;).&#039;/storage&#039;,
  &#039;visibility&#039; =&gt;&#039;public&#039;,
],
</pre></div>


<h5><span style="font-family: helvetica, arial, sans-serif;">./webpack.mix.js</span></h5>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
mix.config.publicPath='public_html'; mix.js('resources/assets/js/app.js', 'public_html/js') .sass('resources/assets/sass/app.scss', 'public_html/css');
</pre></div>


<h5>./htaccess for directadmin </h5>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
&amp;lt;IfModule mod_rewrite.c&gt;
    &amp;lt;IfModule mod_negotiation.c&gt;
        Options -MultiViews -Indexes
    &amp;lt;/IfModule&gt;
  RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 &#x5B;L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php &#x5B;L]
&amp;lt;/IfModule&gt;
</pre></div>




<pre class="wp-block-preformatted"><strong>Done nhe!</strong></pre>



<p>Nguồn : Developer How To.&nbsp;</p>
<p>The post <a href="https://hoangthuc.com/chuyen-thu-muc-public-sang-public_html-trong-laravel-khi-deploy/">Chuyển thư mục public sang public_html trong Laravel khi deploy</a> appeared first on <a href="https://hoangthuc.com">Hi You, I am Tade</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://hoangthuc.com/chuyen-thu-muc-public-sang-public_html-trong-laravel-khi-deploy/feed/</wfw:commentRss>
			<slash:comments>49</slash:comments>
		
		
			</item>
		<item>
		<title>Cài đặt nhiều phiên bản PHP DirectAdmin</title>
		<link>https://hoangthuc.com/cai-dat-nhieu-phien-ban-php-directadmin/</link>
					<comments>https://hoangthuc.com/cai-dat-nhieu-phien-ban-php-directadmin/#comments</comments>
		
		<dc:creator><![CDATA[Hoàng Thức]]></dc:creator>
		<pubDate>Sun, 22 Nov 2020 09:50:06 +0000</pubDate>
				<category><![CDATA[DirectAdmin]]></category>
		<category><![CDATA[Lập trình]]></category>
		<category><![CDATA[Vps]]></category>
		<category><![CDATA[Php]]></category>
		<guid isPermaLink="false">https://hoangthuc.com/?p=681</guid>

					<description><![CDATA[<p>Việc cài cài đặt nhiều phiên bản PHP DirectAdmin sẽ rất giúp ích cho các bạn nếu trên VPS hoặc máy chủ DirectAdmin của bạn chạy nhiều website khác nhau. Tương ứng với điều đó thì nếu cùng xử lý 1 tác vụ mức độ sử dụng CPU của PHP 7.4 cũng thấp hơn 3 lần só [&#8230;]</p>
<p>The post <a href="https://hoangthuc.com/cai-dat-nhieu-phien-ban-php-directadmin/">Cài đặt nhiều phiên bản PHP DirectAdmin</a> appeared first on <a href="https://hoangthuc.com">Hi You, I am Tade</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><span style="font-family: tahoma, arial, helvetica, sans-serif;">Việc cài cài đặt nhiều phiên bản PHP DirectAdmin sẽ rất giúp ích cho các bạn nếu trên VPS hoặc máy chủ DirectAdmin của bạn chạy nhiều website khác nhau.</span></p>
<p><span style="font-family: tahoma, arial, helvetica, sans-serif;">Tương ứng với điều đó thì nếu cùng xử lý 1 tác vụ mức độ sử dụng CPU của <strong>PHP 7.4</strong> cũng thấp hơn 3 lần só với <strong>PHP 5.6</strong>.</span></p>
<p><span style="font-family: tahoma, arial, helvetica, sans-serif;"><strong>Điều kiện cài đặt:</strong></span></p>
<p><span style="font-family: tahoma, arial, helvetica, sans-serif;">Điều kiện 1: Yêu cầu phiên bản DirectAdmin phải bằng hoặc lớn hơn <strong>1.50.1</strong></span></p>
<pre class="brush: php; title: ; notranslate">
/usr/local/directadmin/directadmin v
</pre>
<p>Điều kiện 2: Yêu cầu phiên bản Custombuild 2.0 trở lên</p>
<pre class="brush: php; title: ; notranslate">
cd /usr/local/directadmin/custombuild
./build version
</pre>
<p id="ftoc-heading-4" class="ftwp-heading"><span style="font-family: tahoma, arial, helvetica, sans-serif;"><strong>Bật tính năng chạy nhiều phiên bản PHP DirectAdmin</strong></span></p>
<p id="ftoc-heading-5" class="ftwp-heading"><span style="font-family: tahoma, arial, helvetica, sans-serif;">Bước 1: Thiết lập cấu hình các phiên bản PHP các bạn muốn sử dụng</span></p>
<pre class="brush: php; title: ; notranslate">
cd /usr/local/directadmin/custombuild
./build update
./build set php1_release 7.4
./build set php2_release 7.3
./build set php3_release 7.2
./build set php4_release 5.6
</pre>
<p><span style="font-family: tahoma, arial, helvetica, sans-serif;"><strong>Lưu ý:</strong> Nếu bạn đang sử dụng CentOS 6 thì nên dừng lại ở phiên bản PHP 7.3 thôi nhe.</span></p>
<p id="ftoc-heading-6" class="ftwp-heading"><span style="font-family: tahoma, arial, helvetica, sans-serif;">Bước 2: Biên dịch lại toàn bộ các phiên bản PHP</span></p>
<pre class="brush: php; title: ; notranslate">
cd /usr/local/directadmin/custombuild
./build php n
./build rewrite_confs
</pre>
<p><span style="font-family: tahoma, arial, helvetica, sans-serif;">Lưu ý: Quá trình này có thể mất khá nhiều thời gian của bạn. Thời gian dài hoặc ngắn sẽ phụ thuộc vào hiệu năng CPU của VPS hoặc Server của bạn.</span></p>
<p><span style="font-family: tahoma, arial, helvetica, sans-serif;">Bây giờ bạn có thể thay đổi phiên bản PHP của các website trên giao diện DirectAdmin ở “User Level” rồi.</span></p>
<p>&nbsp;</p>
<p>The post <a href="https://hoangthuc.com/cai-dat-nhieu-phien-ban-php-directadmin/">Cài đặt nhiều phiên bản PHP DirectAdmin</a> appeared first on <a href="https://hoangthuc.com">Hi You, I am Tade</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://hoangthuc.com/cai-dat-nhieu-phien-ban-php-directadmin/feed/</wfw:commentRss>
			<slash:comments>49</slash:comments>
		
		
			</item>
		<item>
		<title>Phân quyền trong Laravel với Laravel permission</title>
		<link>https://hoangthuc.com/phan-quyen-trong-laravel-voi-laravel-permission/</link>
					<comments>https://hoangthuc.com/phan-quyen-trong-laravel-voi-laravel-permission/#comments</comments>
		
		<dc:creator><![CDATA[Hoàng Thức]]></dc:creator>
		<pubDate>Tue, 04 Aug 2020 16:41:29 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Laravel]]></category>
		<category><![CDATA[Php]]></category>
		<guid isPermaLink="false">https://hoangthuc.com/?p=658</guid>

					<description><![CDATA[<p>Laravel permission cho phép chúng ta chia ra 2 thành phần là Vai trò (role) và quyền (permission). 1.Cài đặt Cài đặt Laravel 5.8 hoặc cao hơn Nếu bạn đang có sẵn file config/permission.php bạn phải đổi tên hoặc xóa ngay, bởi vì khi setup thì package sẽ được publishes vào config/permission.php Nếu thỏa mãn 2 điều kiện [&#8230;]</p>
<p>The post <a href="https://hoangthuc.com/phan-quyen-trong-laravel-voi-laravel-permission/">Phân quyền trong Laravel với Laravel permission</a> appeared first on <a href="https://hoangthuc.com">Hi You, I am Tade</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Laravel permission cho phép chúng ta chia ra 2 thành phần là Vai trò (role) và quyền (permission).</p>
<p><strong>1.Cài đặt</strong></p>
<ul>
<li>Cài đặt Laravel 5.8 hoặc cao hơn</li>
<li>Nếu bạn đang có sẵn file <code>config/permission.php</code> bạn phải đổi tên hoặc xóa ngay, bởi vì khi setup thì package sẽ được publishes vào <code>config/permission.php</code></li>
</ul>
<p>Nếu thỏa mãn 2 điều kiện trên rồi chúng ta chạy câu lệnh dưới:</p>
<pre class="brush: php; title: ; notranslate">

composer require spatie/laravel-permission

</pre>
<p>Sau đó, trong <code>config/app.php</code> chúng ta add service provide cho package như sau:</p>
<pre class="brush: php; title: ; notranslate">

'providers' =&amp;gt; &#x5B; // ... Spatie\Permission\PermissionServiceProvider::class, ];

</pre>
<p>Sau đó, publish migration thông qua lệnh:</p>
<pre class="brush: php; title: ; notranslate">

php artisan vendor:publish --provider=&amp;quot;Spatie\Permission\PermissionServiceProvider&amp;quot;

</pre>
<p>Chạy lệnh <code>php artisan migrate</code> và chúng ta sẽ có các bảng như <strong>roles, permissions, role_has_permissions, model_has_roles </strong>và <strong>model_has_permission</strong></p>
<p>&nbsp;</p>
<p><strong>2.Tạo Roles và Permissions</strong></p>
<p>Tạo file mới  <strong>/database/seeds/PermissionsDemoSeeder.php </strong>và code như ví dụ bên dưới</p>
<pre class="brush: php; title: ; notranslate">

use Illuminate\Database\Seeder;
use Spatie\Permission\Models\Permission;
use Spatie\Permission\Models\Role;
use Spatie\Permission\PermissionRegistrar;

class PermissionsDemoSeeder extends Seeder
{
/**
* Create the initial roles and permissions.
*
* @return void
*/
public function run()
{
// Reset cached roles and permissions
app()&#x5B;PermissionRegistrar::class]-&amp;gt;forgetCachedPermissions();

// create permissions
Permission::create(&#x5B;'name' =&amp;gt; 'edit articles']);
Permission::create(&#x5B;'name' =&amp;gt; 'delete articles']);
Permission::create(&#x5B;'name' =&amp;gt;; 'publish articles']);
Permission::create(&#x5B;'name' =&amp;gt; 'unpublish articles']);

// create roles and assign existing permissions
$role1 = Role::create(&#x5B;'name' &amp;gt; 'writer']);
$role1-&amp;gt;givePermissionTo('edit articles');
$role1-&amp;gt;givePermissionTo('delete articles');

$role2 = Role::create(&#x5B;'name' =&amp;gt; 'admin']);
$role2-&amp;gt;givePermissionTo('publish articles');
$role2-&amp;gt;givePermissionTo('unpublish articles');

$role3 = Role::create(&#x5B;'name' =&amp;gt; 'super-admin']);
// gets all permissions via Gate::before rule; see AuthServiceProvider

// create demo users
$user = Factory(App\User::class)-&amp;gt;create(&#x5B;
'name' =&amp;gt; 'Example User',
'email' =&amp;gt; 'test@example.com',
]);
$user-&amp;gt;assignRole($role1);

$user = Factory(App\User::class)-&amp;gt;create(&#x5B;
'name' =&amp;gt; 'Example Admin User',
'email' =&amp;gt; 'admin@example.com',
]);
$user-&amp;gt;assignRole($role2);

$user = Factory(App\User::class)-&amp;gt;create(&#x5B;
'name' =&amp;gt; 'Example Super-Admin User',
'email' =&amp;gt; 'superadmin@example.com',
]);
$user-&amp;gt;assignRole($role3);
}
}

</pre>
<p>Tiếp theo khỏi tạo cơ sở dữ liệu</p>
<pre class="brush: php; title: ; notranslate">

php artisan db:seed --class=PermissionsDemoSeeder

</pre>
<p><strong>3.Trao quyền trực tiếp cho một user</strong><br />
Bạn có thể giao một quyền cho một user như sau:</p>
<pre class="brush: php; title: ; notranslate">
$user-&amp;gt;givePermissionTo('edit articles'); // giao quyền edit articles cho một user nào đó

// nhiều quyền cùng lúc
$user-&amp;gt;givePermissionTo('edit articles', 'delete articles');

// dán 1 mảng 
$user-&amp;gt;givePermissionTo(&#x5B;'edit articles', 'delete articles']);

// xóa 1 quyền
$user-&amp;gt;revokePermissionTo('edit articles');

// thêm quyền
$user-&amp;gt;syncPermissions(&#x5B;'edit articles', 'delete articles']);

//Kiểm tra quyền
$user-&amp;gt;hasPermissionTo('edit articles');
</pre>
<p><strong>4.Trao quyền thông qua roles<br />
</strong>Một roles có thể được trao cho bất cứ <code>users</code> nào bằng cách :</p>
<pre class="brush: php; title: ; notranslate">
$user-&amp;gt;assignRole('writer');

// set nhiều vai trò $user-&amp;gt;assignRole('writer', 'admin'); 
// dán 1 mảng $user-&amp;gt;assignRole(&#x5B;'writer', 'admin']);
// xóa vai trò
$user-&amp;gt;removeRole('writer');
//check xem vai tro đang cần tìm bằng cách :
$user-&amp;gt;hasRole('writer');
// thêm vai trò và clear các vai trò có sẳn từ trước
$user-&amp;gt;syncRoles('admin');
</pre>
<p><strong>5.Sử dụng với middleware</strong><br />
Bạn có thể sử dụng can như một mặc định để giới hạn quyền truy cập cho trang web bằng cách :</p>
<pre class="brush: php; title: ; notranslate">
Route::group(&#x5B;'middleware' =&amp;gt; &#x5B;'can:publish articles']], function () { // });
</pre>
<p>Hoặc nếu bạn không muốn sử dụng mặc định, Laravel permission mang đến cho chúng ta các middleware RoleMiddleware, PermissionMiddleware and RoleOrPermissionMiddleware. Để sử dụng, bạn cần thêm vào app/Http/Kernel.php file như sau:</p>
<pre class="brush: php; title: ; notranslate">
protected $routeMiddleware = &#x5B; 
// ... 
'role' =&amp;gt; \Spatie\Permission\Middlewares\RoleMiddleware::class, 
'permission' =&amp;gt; \Spatie\Permission\Middlewares\PermissionMiddleware::class, 
'role_or_permission' =&amp;gt; \Spatie\Permission\Middlewares\RoleOrPermissionMiddleware::class, 
];
</pre>
<p>Sau đó chúng ta có thể sữ dung các route:</p>
<pre class="brush: php; title: ; notranslate">
// Chỉ có role là super-admin mới có thể truy cập vào các route của group này 
Route::group(&#x5B;'middleware' =&amp;gt; &#x5B;'role:super-admin']], function () { // }); 
// Chỉ có permission là publish articles thì mới có thể truy cập vào các route của group này 
Route::group(&#x5B;'middleware' =&amp;gt; &#x5B;'permission:publish articles']], function () { // }); 
// Chỉ có role là super-admin hoặc permission là publish articles thì mới có thể truy cập vào các route của group này 
Route::group(&#x5B;'middleware' =&amp;gt; &#x5B;'role:super-admin','permission:publish articles']], function () { // }); 
Route::group(&#x5B;'middleware' =&amp;gt; &#x5B;'role_or_permission:super-admin|edit articles']], function () { // });

// Đối với GET;
Route::get('/admin', function(){
    return view('admin.dashboard');
})-&amp;gt;name('admin')-&amp;gt;middleware('auth')-&amp;gt;middleware(&#x5B;'role:administrator']);
// auth để kiềm tra đăng nhập và role để kiểm tra vai trò. 
// Tất cả những quyền không được phép truy cập sẽ mặc định trả về page 403: 
</pre>
<p><strong>6.Sử dụng trực tiếp trên Blade</strong><br />
Đối với phần view, để hiển thị view tương ứng cho các vai trò, chúng ta có thể sử dụng <code>@can</code>, <code>@cannot</code>, <code>@canany</code>, and <code>@guest</code> để kiểm tra việc xem thông tin hiển thị trên một trang web. Chúng ta làm như sau:</p>
<pre class="brush: php; title: ; notranslate">
@can('edit articles') 
// 
@endcan

// hoặc

@if(auth()-&amp;gt;user()-&amp;gt;can('edit articles') &amp;amp;&amp;amp; $some_other_condition)
  //
@endif

// hoặc
@role('writer')
    I am a writer!
@else
    I am not a writer...
@endrole

 // Kiem tra nhiều hơn như sau:
@hasanyrole($collectionOfRoles)
    Tôi có một hoặc nhiều roles trong điều kiện này
@else
   Tôi không thuộc roles nào ở trên
@endhasanyrole

// hoặc

@hasanyrole('writer|admin')
    Tôi là một writer hoặc admin hoặc cả hai :D
@else
   Tôi không là writer cũng không là admin
@endhasanyrole
</pre>
<p>Vừa rồi mình đã giới thiệu 1 số vấn đề cớ bản trong việc sử dụng package <code>spatie/laravel-permission</code>  trong Laravel để làm tính năng phân quyền. Mong các bạn có thể áp dụng dễ dàng.<br />
Chúc các bạn ngày vui vẻ.</p>
<p>&nbsp;</p>
<p>The post <a href="https://hoangthuc.com/phan-quyen-trong-laravel-voi-laravel-permission/">Phân quyền trong Laravel với Laravel permission</a> appeared first on <a href="https://hoangthuc.com">Hi You, I am Tade</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://hoangthuc.com/phan-quyen-trong-laravel-voi-laravel-permission/feed/</wfw:commentRss>
			<slash:comments>557</slash:comments>
		
		
			</item>
		<item>
		<title>Backup mã nguồn, files, folders bằng php</title>
		<link>https://hoangthuc.com/backup-ma-nguon-files-folders-bang-php/</link>
					<comments>https://hoangthuc.com/backup-ma-nguon-files-folders-bang-php/#comments</comments>
		
		<dc:creator><![CDATA[Hoàng Thức]]></dc:creator>
		<pubDate>Thu, 30 Jun 2016 19:41:11 +0000</pubDate>
				<category><![CDATA[Lập trình]]></category>
		<category><![CDATA[Php]]></category>
		<guid isPermaLink="false">https://hoangthuc.com/?p=443</guid>

					<description><![CDATA[<p>Lý do tôi viết bài này dùng khi trường hợp các bạn muốn backup source website nhưng không có tài khoản host và chỉ có tài khoản FTP. Thông thường chúng ta củng có thể tải source bằng phần mềm thông qua FTP nhưng sẽ có 1 số vấn đề sau đó là: + FTP [&#8230;]</p>
<p>The post <a href="https://hoangthuc.com/backup-ma-nguon-files-folders-bang-php/">Backup mã nguồn, files, folders bằng php</a> appeared first on <a href="https://hoangthuc.com">Hi You, I am Tade</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Lý do tôi viết bài này dùng khi trường hợp các bạn muốn backup source website nhưng không có tài khoản host và chỉ có tài khoản FTP. Thông thường chúng ta củng có thể tải source bằng phần mềm thông qua FTP nhưng sẽ có 1 số vấn đề sau đó là:</p>
<p>+ FTP tải từng file nên rất dễ bị mất file hoặc thiếu file.</p>
<p>+ Do mạng. Mạng yếu mà tải bằng FTP thì có tức chết dòm nó load từng file mà muốn đập cái máy (tôi đã từng).</p>
<p>Vô nội dung chính cơ cấu backup sẽ hoạt động như sau:</p>
<p>Đầu tiên các bạn cần tải file backup lên sau đó chạy với đường dẫn đến file đó trên trình duyệt nó sẽ nén source của bạn lại và tải về cho bạn source website dưới dạng file zip. Thế là xong.</p>
<p>Mình đã test trên 1 vài trang và chưa gặp sự cố  nào xãy ra :)))</p>
<p>Source file backup:</p>
<pre class="brush: php; title: ; notranslate">

&lt;?php
if(isset($_POST&#x5B;'folder_zip'])):
$time = (int)$_POST&#x5B;'folder_zip'];
$namezip = 'backup'.time().'.zip';
ini_set('max_execution_time', $time );
$zip = new ZipArchive();
$zip-&gt;open( $namezip , ZipArchive::CREATE | ZipArchive::OVERWRITE);
if ($handle = opendir('.')) {

while (false !== ($entry = readdir($handle))) {

if ($entry != &quot;.&quot; &amp;&amp; $entry != &quot;..&quot; &amp;&amp; !is_dir($entry)) {
$filePath = realpath($entry);
$relativePath = substr($filePath,0 - strlen($entry));
$zip-&gt;addFile($filePath, $relativePath);
}elseif($entry != &quot;.&quot; &amp;&amp; $entry != &quot;..&quot; &amp;&amp; is_dir($entry)){
$rootPath = realpath($entry);
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($rootPath),
RecursiveIteratorIterator::LEAVES_ONLY
);

foreach ($files as $name =&gt; $file)
{
if (!$file-&gt;isDir())
{
$filePath = $file-&gt;getRealPath();
$relativePath = $entry.&quot;\\&quot;.substr($filePath, strlen($rootPath) + 1);
$zip-&gt;addFile($filePath, $relativePath);
}
}

}

}

closedir($handle);
}

$zip-&gt;close();
header('Location:'.$namezip);
endif;
?&gt;
&lt;form action=&quot;&quot; method=&quot;post&quot;&gt;
&lt;input type=&quot;number&quot; name=&quot;folder_zip&quot; value=&quot;&lt;?php // echo $_POST&#x5B;'folder_zip']; ?&gt;&quot;&gt;
&lt;button type=&quot;submit&quot;&gt;Submit&lt;/button&gt;
&lt;/form&gt;

</pre>
<p>Cái này chủ yếu là chức năng nên mình cũng không trang trí gì cho lung linh lắm.</p>
<p>Nếu có thắc mắc hay muốn đóng góp ý kiến thì bình luận bên dưới nhé. Mình rất thích các ý kiến có tính xây dựng.</p>
<p>Chúc các bạn thành công !</p>
<p>The post <a href="https://hoangthuc.com/backup-ma-nguon-files-folders-bang-php/">Backup mã nguồn, files, folders bằng php</a> appeared first on <a href="https://hoangthuc.com">Hi You, I am Tade</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://hoangthuc.com/backup-ma-nguon-files-folders-bang-php/feed/</wfw:commentRss>
			<slash:comments>51</slash:comments>
		
		
			</item>
		<item>
		<title>Hàm bỏ dấu tiếng việt trong php</title>
		<link>https://hoangthuc.com/ham-bo-dau-tieng-viet-trong-php/</link>
					<comments>https://hoangthuc.com/ham-bo-dau-tieng-viet-trong-php/#comments</comments>
		
		<dc:creator><![CDATA[Hoàng Thức]]></dc:creator>
		<pubDate>Sun, 19 Jun 2016 04:53:01 +0000</pubDate>
				<category><![CDATA[Lập trình]]></category>
		<category><![CDATA[Php]]></category>
		<guid isPermaLink="false">https://hoangthuc.com/?p=438</guid>

					<description><![CDATA[<p>Hàm này chủ yếu dùng để tạo link trong bài viết. Sử dụng hàm preg_replace() trong php. Trong wordpress nó được dùng để tạo slug cho post, pages. Hàm này cũng khá ngắn và dễ sử dụng. function vn_to_str ($str){ $unicode = array( 'a'=&#62;'á&#124;à&#124;ả&#124;ã&#124;ạ&#124;ă&#124;ắ&#124;ặ&#124;ằ&#124;ẳ&#124;ẵ&#124;â&#124;ấ&#124;ầ&#124;ẩ&#124;ẫ&#124;ậ', 'd'=&#62;'đ', 'e'=&#62;'é&#124;è&#124;ẻ&#124;ẽ&#124;ẹ&#124;ê&#124;ế&#124;ề&#124;ể&#124;ễ&#124;ệ', 'i'=&#62;'í&#124;ì&#124;ỉ&#124;ĩ&#124;ị', 'o'=&#62;'ó&#124;ò&#124;ỏ&#124;õ&#124;ọ&#124;ô&#124;ố&#124;ồ&#124;ổ&#124;ỗ&#124;ộ&#124;ơ&#124;ớ&#124;ờ&#124;ở&#124;ỡ&#124;ợ', 'u'=&#62;'ú&#124;ù&#124;ủ&#124;ũ&#124;ụ&#124;ư&#124;ứ&#124;ừ&#124;ử&#124;ữ&#124;ự', 'y'=&#62;'ý&#124;ỳ&#124;ỷ&#124;ỹ&#124;ỵ', 'A'=&#62;'Á&#124;À&#124;Ả&#124;Ã&#124;Ạ&#124;Ă&#124;Ắ&#124;Ặ&#124;Ằ&#124;Ẳ&#124;Ẵ&#124;Â&#124;Ấ&#124;Ầ&#124;Ẩ&#124;Ẫ&#124;Ậ', 'D'=&#62;'Đ', 'E'=&#62;'É&#124;È&#124;Ẻ&#124;Ẽ&#124;Ẹ&#124;Ê&#124;Ế&#124;Ề&#124;Ể&#124;Ễ&#124;Ệ', 'I'=&#62;'Í&#124;Ì&#124;Ỉ&#124;Ĩ&#124;Ị', 'O'=&#62;'Ó&#124;Ò&#124;Ỏ&#124;Õ&#124;Ọ&#124;Ô&#124;Ố&#124;Ồ&#124;Ổ&#124;Ỗ&#124;Ộ&#124;Ơ&#124;Ớ&#124;Ờ&#124;Ở&#124;Ỡ&#124;Ợ', 'U'=&#62;'Ú&#124;Ù&#124;Ủ&#124;Ũ&#124;Ụ&#124;Ư&#124;Ứ&#124;Ừ&#124;Ử&#124;Ữ&#124;Ự', 'Y'=&#62;'Ý&#124;Ỳ&#124;Ỷ&#124;Ỹ&#124;Ỵ', ); [&#8230;]</p>
<p>The post <a href="https://hoangthuc.com/ham-bo-dau-tieng-viet-trong-php/">Hàm bỏ dấu tiếng việt trong php</a> appeared first on <a href="https://hoangthuc.com">Hi You, I am Tade</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Hàm này chủ yếu dùng để tạo link trong bài viết. Sử dụng hàm preg_replace() trong php. Trong wordpress nó được dùng để tạo slug cho post, pages. Hàm này cũng khá ngắn và dễ sử dụng.</p>
<pre class="brush: php; title: ; notranslate">

function vn_to_str ($str){

$unicode = array(

'a'=&gt;'á|à|ả|ã|ạ|ă|ắ|ặ|ằ|ẳ|ẵ|â|ấ|ầ|ẩ|ẫ|ậ',

'd'=&gt;'đ',

'e'=&gt;'é|è|ẻ|ẽ|ẹ|ê|ế|ề|ể|ễ|ệ',

'i'=&gt;'í|ì|ỉ|ĩ|ị',

'o'=&gt;'ó|ò|ỏ|õ|ọ|ô|ố|ồ|ổ|ỗ|ộ|ơ|ớ|ờ|ở|ỡ|ợ',

'u'=&gt;'ú|ù|ủ|ũ|ụ|ư|ứ|ừ|ử|ữ|ự',

'y'=&gt;'ý|ỳ|ỷ|ỹ|ỵ',

'A'=&gt;'Á|À|Ả|Ã|Ạ|Ă|Ắ|Ặ|Ằ|Ẳ|Ẵ|Â|Ấ|Ầ|Ẩ|Ẫ|Ậ',

'D'=&gt;'Đ',

'E'=&gt;'É|È|Ẻ|Ẽ|Ẹ|Ê|Ế|Ề|Ể|Ễ|Ệ',

'I'=&gt;'Í|Ì|Ỉ|Ĩ|Ị',

'O'=&gt;'Ó|Ò|Ỏ|Õ|Ọ|Ô|Ố|Ồ|Ổ|Ỗ|Ộ|Ơ|Ớ|Ờ|Ở|Ỡ|Ợ',

'U'=&gt;'Ú|Ù|Ủ|Ũ|Ụ|Ư|Ứ|Ừ|Ử|Ữ|Ự',

'Y'=&gt;'Ý|Ỳ|Ỷ|Ỹ|Ỵ',

);

foreach($unicode as $nonUnicode=&gt;$uni){

$str = preg_replace(&quot;/($uni)/i&quot;, $nonUnicode, $str);

}
$str = str_replace(' ','_',$str);

return $str;

}

</pre>
<p>Khi sử dụng các bạn chỉ cần gọi ra như sau</p>
<pre class="brush: php; title: ; notranslate">
echo vn_to_str ('Hãy sử dụng tiếng việt có dấu nhé !');
</pre>
<p>Chúc các bạn ngày mới tốt lành !</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>The post <a href="https://hoangthuc.com/ham-bo-dau-tieng-viet-trong-php/">Hàm bỏ dấu tiếng việt trong php</a> appeared first on <a href="https://hoangthuc.com">Hi You, I am Tade</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://hoangthuc.com/ham-bo-dau-tieng-viet-trong-php/feed/</wfw:commentRss>
			<slash:comments>169</slash:comments>
		
		
			</item>
		<item>
		<title>Dùng hàm preg_match lấy html từ website khác</title>
		<link>https://hoangthuc.com/dung-ham-preg_match-lay-html-tu-website-khac/</link>
					<comments>https://hoangthuc.com/dung-ham-preg_match-lay-html-tu-website-khac/#comments</comments>
		
		<dc:creator><![CDATA[Hoàng Thức]]></dc:creator>
		<pubDate>Sat, 19 Dec 2015 09:31:48 +0000</pubDate>
				<category><![CDATA[Lập trình]]></category>
		<category><![CDATA[Php]]></category>
		<guid isPermaLink="false">http://localhost/bloghoangthuc/?p=198</guid>

					<description><![CDATA[<p>Chúng ta sẽ kết hợp với 1 hàm preg_match với hàm file_get_contents. Công dụng 2 hàm này sẽ được sử dụng như sau: file_get_contents : Lấy dữ liệu từ website. preg_match: Lọc html cần lấy. Đầu tiên cần chọn trang đối tượng cần lấy. Ở đây mình sẽ lấy tỷ giá usd &#8211; tỷ giá [&#8230;]</p>
<p>The post <a href="https://hoangthuc.com/dung-ham-preg_match-lay-html-tu-website-khac/">Dùng hàm preg_match lấy html từ website khác</a> appeared first on <a href="https://hoangthuc.com">Hi You, I am Tade</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Chúng ta sẽ kết hợp với 1 hàm preg_match với hàm file_get_contents. Công dụng 2 hàm này sẽ được sử dụng như sau:</p>
<p>file_get_contents : Lấy dữ liệu từ website.<br />
preg_match: Lọc html cần lấy.<br />
Đầu tiên cần chọn trang đối tượng cần lấy. Ở đây mình sẽ lấy tỷ giá usd &#8211; tỷ giá ngoại tệ từ website 24h.com.vn link :  http://www.24h.com.vn/ttcb/tygia/tygia.php</p>
<pre class="brush: php; title: ; notranslate">

&lt;?php
$link = &quot;http://hcm.24h.com.vn/ttcb/tygia/tygia.php&quot;;
$html = file_get_contents($link);

$reg = '/class=&quot;tb-giaVang&quot;&gt;(.*?)&lt;/table&gt;/s';
$match = array();
$result = preg_match($reg, $html, $match);            
?&gt;

</pre>
<p>Đoạn code hiển thị</p>
<pre class="brush: xml; title: ; notranslate">

     &lt;div class=&quot;div_Wrapper&quot;&gt;
            &lt;h1&gt;Tỷ giá cập nhật mới nhất&lt;/h1&gt;
              &lt;table class=&quot;tbl_TyGia&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; width=&quot;100%&quot;&gt;
               &lt;?php _e($match&#x5B;1]); ?&gt;
           &lt;/table&gt;
        &lt;/div&gt;

</pre>
<p>Thêm đoạn css cho sinh động :))</p>
<pre class="brush: xml; title: ; notranslate">

&lt;link rel='stylesheet'  href='http://www.24h.com.vn/css/ty_gia-2014.css?v=20140916?ver=20150912' type='text/css' media='all' /&gt;          


</pre>
<p>The post <a href="https://hoangthuc.com/dung-ham-preg_match-lay-html-tu-website-khac/">Dùng hàm preg_match lấy html từ website khác</a> appeared first on <a href="https://hoangthuc.com">Hi You, I am Tade</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://hoangthuc.com/dung-ham-preg_match-lay-html-tu-website-khac/feed/</wfw:commentRss>
			<slash:comments>128</slash:comments>
		
		
			</item>
		<item>
		<title>Plugin lấy tin tự động từ website khác</title>
		<link>https://hoangthuc.com/plugin-lay-tin-tu-dong-tu-website-khac/</link>
					<comments>https://hoangthuc.com/plugin-lay-tin-tu-dong-tu-website-khac/#comments</comments>
		
		<dc:creator><![CDATA[Hoàng Thức]]></dc:creator>
		<pubDate>Sun, 06 Dec 2015 07:01:53 +0000</pubDate>
				<category><![CDATA[Plugin wordpress]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Lấy tin tự động]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[plugin wordpress]]></category>
		<guid isPermaLink="false">http://localhost/bloghoangthuc/?p=175</guid>

					<description><![CDATA[<p>Đây là plugin mình mới hoàn thành, cho phép bạn có thể lấy thông tin, hình ảnh từ các website tin tức khác thông qua css. Đây là giao diện chính của plugin. &#160; Chức năng chính của plugin: Tìm liên kết bài viết trong website. Lưu lại bài viết thành bài viết của mình. [&#8230;]</p>
<p>The post <a href="https://hoangthuc.com/plugin-lay-tin-tu-dong-tu-website-khac/">Plugin lấy tin tự động từ website khác</a> appeared first on <a href="https://hoangthuc.com">Hi You, I am Tade</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Đây là plugin mình mới hoàn thành, cho phép bạn có thể lấy thông tin, hình ảnh từ các website tin tức khác thông qua css.</p>
<p>Đây là giao diện chính của plugin.</p>
<p><img decoding="async" class="size-full wp-image-272 aligncenter" src="https://hoangthuc.com/wp-content/uploads/2015/12/Untitled.jpg" alt="Untitled" width="1186" height="621" srcset="https://hoangthuc.com/wp-content/uploads/2015/12/Untitled.jpg 1186w, https://hoangthuc.com/wp-content/uploads/2015/12/Untitled-300x157.jpg 300w, https://hoangthuc.com/wp-content/uploads/2015/12/Untitled-768x402.jpg 768w, https://hoangthuc.com/wp-content/uploads/2015/12/Untitled-1024x536.jpg 1024w" sizes="(max-width: 1186px) 100vw, 1186px" /></p>
<p>&nbsp;</p>
<p>Chức năng chính của plugin:</p>
<ul>
<li>Tìm liên kết bài viết trong website.</li>
<li>Lưu lại bài viết thành bài viết của mình.</li>
<li>Chuyển đỗi ngôn ngữ bài viết khi lấy về (mình dùng google dịch nhé).</li>
</ul>
<p>Video hướng dẫn</p>
<div class="embed-responsive embed-responsive-16by9"><iframe src="https://www.youtube.com/embed/8rvdtPwuwdM" width="560" height="315" frameborder="0" allowfullscreen="allowfullscreen"></iframe></div>
<p>The post <a href="https://hoangthuc.com/plugin-lay-tin-tu-dong-tu-website-khac/">Plugin lấy tin tự động từ website khác</a> appeared first on <a href="https://hoangthuc.com">Hi You, I am Tade</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://hoangthuc.com/plugin-lay-tin-tu-dong-tu-website-khac/feed/</wfw:commentRss>
			<slash:comments>69</slash:comments>
		
		
			</item>
	</channel>
</rss>
