Fixed scripts
I haven't updated these in a loooong time...
This commit is contained in:
parent
9f99ccd78f
commit
ed74a9f470
4 changed files with 28 additions and 30 deletions
|
@ -1,26 +1,19 @@
|
|||
<?php
|
||||
require_once __DIR__ . '/../src/core.php';
|
||||
|
||||
function usage()
|
||||
{
|
||||
echo 'Usage: ' . basename(__FILE__);
|
||||
echo ' QUERY' . PHP_EOL;
|
||||
return true;
|
||||
}
|
||||
Access::disablePrivilegeChecking();
|
||||
|
||||
array_shift($argv);
|
||||
if (empty($argv))
|
||||
usage() and die;
|
||||
|
||||
$query = array_shift($argv);
|
||||
$posts = Model_Post::getEntities($query, null, null);
|
||||
$posts = PostSearchService::getEntities($query, null, null);
|
||||
foreach ($posts as $post)
|
||||
{
|
||||
echo implode("\t",
|
||||
[
|
||||
$post->id,
|
||||
$post->name,
|
||||
Model_Post::getFullPath($post->name),
|
||||
$post->mimeType,
|
||||
$post->getId(),
|
||||
$post->getName(),
|
||||
$post->tryGetWorkingFullPath(),
|
||||
$post->getMimeType(),
|
||||
]). PHP_EOL;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
require_once __DIR__ . '/../src/core.php';
|
||||
|
||||
Access::disablePrivilegeChecking();
|
||||
|
||||
function usage()
|
||||
{
|
||||
echo 'Usage: ' . basename(__FILE__);
|
||||
|
@ -33,7 +35,7 @@ switch ($action)
|
|||
$func = function($name) use ($dir)
|
||||
{
|
||||
echo $name . PHP_EOL;
|
||||
$srcPath = Model_Post::getFullPath($name);
|
||||
$srcPath = PostModel::getFullPath($name);
|
||||
$dstPath = $dir . DS . $name;
|
||||
rename($srcPath, $dstPath);
|
||||
};
|
||||
|
@ -43,7 +45,7 @@ switch ($action)
|
|||
$func = function($name)
|
||||
{
|
||||
echo $name . PHP_EOL;
|
||||
$srcPath = Model_Post::getFullPath($name);
|
||||
$srcPath = PostModel::getFullPath($name);
|
||||
unlink($srcPath);
|
||||
};
|
||||
break;
|
||||
|
@ -53,13 +55,13 @@ switch ($action)
|
|||
}
|
||||
|
||||
$names = [];
|
||||
foreach (R::findAll('post') as $post)
|
||||
foreach (PostSearchService::getEntities(null, null, null) as $post)
|
||||
{
|
||||
$names []= $post->name;
|
||||
$names []= $post->getName();
|
||||
}
|
||||
$names = array_flip($names);
|
||||
|
||||
$config = getConfig();
|
||||
$config = Core::getConfig();
|
||||
foreach (glob(TextHelper::absolutePath($config->main->filesPath) . DS . '*') as $name)
|
||||
{
|
||||
$name = basename($name);
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
require_once __DIR__ . '/../src/core.php';
|
||||
|
||||
Access::disablePrivilegeChecking();
|
||||
|
||||
function usage()
|
||||
{
|
||||
echo 'Usage: ' . basename(__FILE__);
|
||||
|
@ -14,10 +16,10 @@ if (empty($argv))
|
|||
|
||||
function printUser($user)
|
||||
{
|
||||
echo 'ID: ' . $user->id . PHP_EOL;
|
||||
echo 'Name: ' . $user->name . PHP_EOL;
|
||||
echo 'E-mail: ' . $user->email_unconfirmed . PHP_EOL;
|
||||
echo 'Date joined: ' . date('Y-m-d H:i:s', $user->join_date) . PHP_EOL;
|
||||
echo 'ID: ' . $user->getId() . PHP_EOL;
|
||||
echo 'Name: ' . $user->getName() . PHP_EOL;
|
||||
echo 'E-mail: ' . $user->getUnconfirmedEmail() . PHP_EOL;
|
||||
echo 'Date joined: ' . date('Y-m-d H:i:s', $user->getJoinTime()) . PHP_EOL;
|
||||
echo PHP_EOL;
|
||||
}
|
||||
|
||||
|
@ -32,7 +34,7 @@ switch ($action)
|
|||
$func = function($user)
|
||||
{
|
||||
printUser($user);
|
||||
Model_User::remove($user);
|
||||
UserModel::remove($user);
|
||||
};
|
||||
break;
|
||||
|
||||
|
@ -40,8 +42,13 @@ switch ($action)
|
|||
die('Unknown action' . PHP_EOL);
|
||||
}
|
||||
|
||||
$rows = R::find('user', 'email_confirmed IS NULL AND DATETIME(join_date) < DATETIME("now", "-21 days")');
|
||||
foreach ($rows as $user)
|
||||
$users = UserSearchService::getEntities(null, null, null);
|
||||
foreach ($users as $user)
|
||||
{
|
||||
$func($user);
|
||||
if (!$user->getConfirmedEmail()
|
||||
and !$user->getLastLoginTime()
|
||||
and ((time() - $user->getJoinTime()) > 21 * 24 * 60 * 60))
|
||||
{
|
||||
$func($user);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,10 +25,6 @@ class Access
|
|||
|
||||
self::$privileges[$privilegeName][$subPrivilegeName] = $minAccessRank;
|
||||
}
|
||||
|
||||
//todo: move to scripts etc.
|
||||
#if (php_sapi_name() == 'cli')
|
||||
# self::disablePrivilegeChecking();
|
||||
}
|
||||
|
||||
public static function check(Privilege $privilege, $user = null)
|
||||
|
|
Loading…
Reference in a new issue