forked from netcommons/NetCommons2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAction.class.php
More file actions
70 lines (64 loc) · 1.68 KB
/
Action.class.php
File metadata and controls
70 lines (64 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
/**
* Sitesクラス
*
* @package NetCommons
* @author Noriko Arai,Ryuji Masukawa
* @copyright 2006-2007 NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
* @project NetCommons Project, supported by National Institute of Informatics
* @access public
*/
class Sites_Action {
/**
* @var DBオブジェクトを保持
*
* @access private
*/
var $_db = null;
var $_session = null;
/**
* コンストラクター
*
* @access public
*/
function Sites_Action() {
$container =& DIContainerFactory::getContainer();
//DBオブジェクト取得
$this->_db =& $container->getComponent("DbObject");
$this->_session =& $container->getComponent("Session");
}
/**
* インストール時、site_id作成処理
* @access public
*/
function insertSite($url="BASE_URL", $self_flag = _ON)
{
$sessionID = $this->_session->getID();
// $new_site_id = crc32($sessionID).crc32(microtime());
while(1) {
$new_site_id = sha1(uniqid($sessionID.microtime(), true));
// Hash値で同じものがないか念のためチェック
$result = $this->_db->selectExecute("sites", array("site_id" => $new_site_id));
if ($result === false) {
return false;
}
if(!isset($result[0]['site_id'])) {
break;
}
}
$params = array(
"site_id" => $new_site_id,
"url" => $url,
"self_flag" => $self_flag,
"commons_flag" => _ON,
"certify_flag" => _ON
);
$result = $this->_db->insertExecute("sites", $params, true);
if($result === false) {
return false;
}
return $new_site_id;
}
}
?>