Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
UNL-CMS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
yzha1
UNL-CMS
Commits
5a280d47
Commit
5a280d47
authored
12 years ago
by
Tim Steiner
Browse files
Options
Downloads
Plain Diff
[gh-431] Merge branch 'issue-431' into develop
parents
f101cac6
f9c792ef
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sites/all/modules/unl/cron.php
+41
-6
41 additions, 6 deletions
sites/all/modules/unl/cron.php
with
41 additions
and
6 deletions
sites/all/modules/unl/cron.php
+
41
−
6
View file @
5a280d47
...
@@ -393,7 +393,7 @@ function unl_add_site_to_htaccess($site_id, $site_path, $is_alias) {
...
@@ -393,7 +393,7 @@ function unl_add_site_to_htaccess($site_id, $site_path, $is_alias) {
.
$stub_token
.
$stub_token
.
substr
(
$htaccess
,
$stub_pos
+
strlen
(
$stub_token
));
.
substr
(
$htaccess
,
$stub_pos
+
strlen
(
$stub_token
));
file_put_contents
(
DRUPAL_ROOT
.
'/.htaccess'
,
$new_htaccess
);
_unl_
file_put_contents
_atomic
(
DRUPAL_ROOT
.
'/.htaccess'
,
$new_htaccess
);
}
}
function
unl_remove_site_from_htaccess
(
$site_id
,
$is_alias
)
{
function
unl_remove_site_from_htaccess
(
$site_id
,
$is_alias
)
{
...
@@ -420,7 +420,7 @@ function unl_remove_site_from_htaccess($site_id, $is_alias) {
...
@@ -420,7 +420,7 @@ function unl_remove_site_from_htaccess($site_id, $is_alias) {
$new_htaccess
=
substr
(
$htaccess
,
0
,
$start_pos
)
$new_htaccess
=
substr
(
$htaccess
,
0
,
$start_pos
)
.
substr
(
$htaccess
,
$end_pos
+
strlen
(
$site_end_token
))
.
substr
(
$htaccess
,
$end_pos
+
strlen
(
$site_end_token
))
;
;
file_put_contents
(
DRUPAL_ROOT
.
'/.htaccess'
,
$new_htaccess
);
_unl_
file_put_contents
_atomic
(
DRUPAL_ROOT
.
'/.htaccess'
,
$new_htaccess
);
}
}
function
unl_add_page_alias_to_htaccess
(
$site_id
,
$host
,
$path
,
$to_uri
)
{
function
unl_add_page_alias_to_htaccess
(
$site_id
,
$host
,
$path
,
$to_uri
)
{
...
@@ -441,7 +441,7 @@ function unl_add_page_alias_to_htaccess($site_id, $host, $path, $to_uri) {
...
@@ -441,7 +441,7 @@ function unl_add_page_alias_to_htaccess($site_id, $host, $path, $to_uri) {
.
$stub_token
.
$stub_token
.
substr
(
$htaccess
,
$stub_pos
+
strlen
(
$stub_token
));
.
substr
(
$htaccess
,
$stub_pos
+
strlen
(
$stub_token
));
file_put_contents
(
DRUPAL_ROOT
.
'/.htaccess'
,
$new_htaccess
);
_unl_
file_put_contents
_atomic
(
DRUPAL_ROOT
.
'/.htaccess'
,
$new_htaccess
);
}
}
function
unl_remove_page_alias_from_htaccess
(
$site_id
)
{
function
unl_remove_page_alias_from_htaccess
(
$site_id
)
{
...
@@ -461,7 +461,7 @@ function unl_remove_page_alias_from_htaccess($site_id) {
...
@@ -461,7 +461,7 @@ function unl_remove_page_alias_from_htaccess($site_id) {
$new_htaccess
=
substr
(
$htaccess
,
0
,
$start_pos
)
$new_htaccess
=
substr
(
$htaccess
,
0
,
$start_pos
)
.
substr
(
$htaccess
,
$end_pos
+
strlen
(
$site_end_token
))
.
substr
(
$htaccess
,
$end_pos
+
strlen
(
$site_end_token
))
;
;
file_put_contents
(
DRUPAL_ROOT
.
'/.htaccess'
,
$new_htaccess
);
_unl_
file_put_contents
_atomic
(
DRUPAL_ROOT
.
'/.htaccess'
,
$new_htaccess
);
}
}
function
unl_add_alias_to_sites_php
(
$site_uri
,
$base_uri
,
$path
,
$alias_id
)
{
function
unl_add_alias_to_sites_php
(
$site_uri
,
$base_uri
,
$path
,
$alias_id
)
{
...
@@ -490,7 +490,7 @@ function unl_add_alias_to_sites_php($site_uri, $base_uri, $path, $alias_id) {
...
@@ -490,7 +490,7 @@ function unl_add_alias_to_sites_php($site_uri, $base_uri, $path, $alias_id) {
$old_real_site_dir
=
unl_get_sites_subdir
(
$alias_uri
);
$old_real_site_dir
=
unl_get_sites_subdir
(
$alias_uri
);
$new_sites_php
=
str_replace
(
"'"
.
$old_real_site_dir
.
"'"
,
"'"
.
$real_site_dir
.
"'"
,
$new_sites_php
);
$new_sites_php
=
str_replace
(
"'"
.
$old_real_site_dir
.
"'"
,
"'"
.
$real_site_dir
.
"'"
,
$new_sites_php
);
file_put_contents
(
DRUPAL_ROOT
.
'/sites/sites.php'
,
$new_sites_php
);
_unl_
file_put_contents
_atomic
(
DRUPAL_ROOT
.
'/sites/sites.php'
,
$new_sites_php
);
}
}
function
unl_remove_alias_from_sites_php
(
$alias_id
)
{
function
unl_remove_alias_from_sites_php
(
$alias_id
)
{
...
@@ -510,7 +510,7 @@ function unl_remove_alias_from_sites_php($alias_id) {
...
@@ -510,7 +510,7 @@ function unl_remove_alias_from_sites_php($alias_id) {
$new_sites_php
=
substr
(
$sites_php
,
0
,
$start_pos
)
$new_sites_php
=
substr
(
$sites_php
,
0
,
$start_pos
)
.
substr
(
$sites_php
,
$end_pos
+
strlen
(
$site_end_token
))
.
substr
(
$sites_php
,
$end_pos
+
strlen
(
$site_end_token
))
;
;
file_put_contents
(
DRUPAL_ROOT
.
'/sites/sites.php'
,
$new_sites_php
);
_unl_
file_put_contents
_atomic
(
DRUPAL_ROOT
.
'/sites/sites.php'
,
$new_sites_php
);
}
}
function
unl_require_writable
(
$path
)
{
function
unl_require_writable
(
$path
)
{
...
@@ -518,3 +518,38 @@ function unl_require_writable($path) {
...
@@ -518,3 +518,38 @@ function unl_require_writable($path) {
throw
new
Exception
(
'The file "'
.
$path
.
'" needs to be writable and is not.'
);
throw
new
Exception
(
'The file "'
.
$path
.
'" needs to be writable and is not.'
);
}
}
}
}
/**
* A drop-in replacement for file_put_contents that will atomically put the new file into place.
* This additionally requires you to have write access to the directory that will contain the file.
* @see file_put_contents
*/
function
_unl_file_put_contents_atomic
(
$filename
,
$data
,
$flags
=
0
,
$context
=
NULL
)
{
// Create a temporary file with a simalar name in the destination directory.
$tempfile
=
tempnam
(
dirname
(
$filename
),
basename
(
$filename
)
.
'_'
);
if
(
$tempfile
===
FALSE
)
{
return
FALSE
;
}
// Fix the permissions on the file since they will be 0600.
if
(
file_exists
(
$filename
))
{
$stat
=
stat
(
$filename
);
chmod
(
$tempfile
,
$stat
[
'mode'
]);
}
else
{
chmod
(
$tempfile
,
0666
&
~
umask
());
}
// Do the actual file_put contents
$bytes
=
file_put_contents
(
$tempfile
,
$data
,
$flags
,
$context
);
if
(
$bytes
===
FALSE
)
{
unlink
(
$tempfile
);
return
FALSE
;
}
// Move the new file into place atomically.
if
(
!
rename
(
$tempfile
,
$filename
))
{
unlink
(
$tempfile
);
return
FALSE
;
}
return
$bytes
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment