<?php /** * Client Manager * * Show user profile image * @package Client Manager 0.2 alpha * @author Jin Cong<*****@*****.**> */ define('IN_IMAGE', true); define('LOAD_MYSQL', true); require '../cm_includes/entry.php'; if (empty($_GET['id'])) { die; } $image = tableParser('profiles', 'getPhoto', array('id' => $_GET['id'])); if (isset($image['photo']) && isset($image['photoext'])) { header('Content-Type: image/' . $image['photoext']); //generate images' path $image['photo'] = IMAGE_PATH . '/' . $image['photo']; if (isset($_GET['thumbnail']) && $_GET['thumbnail'] == 1) { $image['photo'] .= '_thumbnail'; } $image['photo'] .= '.' . $image['photoext']; if (!file_exists($image['photo'])) { die; } echo gzuncompress(file_get_contents($image['photo'])); } else { die; }
* @author Jin Cong<*****@*****.**> */ define('LOAD_TEMPLATE', true); define('LOAD_FORM', true); define('LOAD_MYSQL', true); define('IN_ADMIN', true); require '../cm_includes/entry.php'; isset($_GET['id']) ? $id = (int) $_GET['id'] : header("Location: " . CM_ROOT . '/cm_admin/'); if (isset($_GET['delete']) && $_GET['delete'] == 1) { $tpl->assign('tooltip', tableParser('profiles', 'delete', array('id' => $id)) ? 'You have successfuly delete the profile.<br />Check out more profiles <a href="' . CM_URL . '/cm_admin/list.php">here</a>.' : 'Delete the profile resulted failed.'); } else { $frm = new SpoonForm('profile'); $get_user = tableParser('profiles', 'getProf', array('id' => $id)); if (empty($get_user)) { $tpl->assign('tooltip', 'Profile not available'); } else { //set form value $pf = parseForm($frm, 'profile', $get_user); $update = $pf[0] == 3 ? tableParser('profiles', 'update', array_merge($pf[1], array('id' => $id))) : false; //set profile image & attachment path isset($get_user['photo']) && strlen($get_user['photo']) > 0 && $tpl->assign('photo_path', CM_URL . '/cm_api/images.php?thumbnail=1&id=' . $id); isset($get_user['attachment']) && strlen($get_user['attachment']) > 0 && $tpl->assign('attach_path', CM_URL . '/cm_api/attachments.php?id=' . $id); $tpl->assign('id', $id); $tpl->assign('lastupdate', date(DATE_RFC822, $get_user['lastupdate'])); if ($pf[0] == 3) { $tpl->assign('tooltip', $update ? 'You have successfuly edit the profile.<br />' : 'Edit the profile resulted failed.'); } $frm->parse($tpl); } } $tpl->display(tpl_path('admin_edit.tpl.php'));
<?php define('LOAD_TEMPLATE', true); define('LOAD_FORM', true); define('LOAD_MYSQL', true); define('IN_ADMIN', true); define('IN_SEARCH', true); require '../cm_includes/entry.php'; $tpl->assign('isSearch', true); $frm = new SpoonForm('profile', NULL, 'get'); $pf = parseForm($frm, 'profile'); if ($pf[0] == 3) { $query = tableParser('profiles', 'searchLimit', $frm->getValues('form', 'submit', '_utf8')); if (count($query) > 0) { $tpl->assign('isResult', true); foreach ($query as $key => $value) { if (isset($value['photo'])) { $query[$key]['photo'] = '<img src="' . CM_URL . '/cm_api/images.php?id=' . $value['id'] . '&thumbnail=1" />'; } $query[$key]['action'] = '<a href="' . CM_URL . '/cm_admin/edit.php?id=' . $value['id'] . '" target="_blank">Edit</a><br /><a href="' . CM_URL . '/cm_admin/profile.php?id=' . $value['id'] . '" target="_blank">Print</a><br /><a href="" id="' . $value['id'] . '" class="delProfile">Delete</a>'; if (isset($query[$key]['attachment']) && strlen($query[$key]['attachment']) > 0) { $query[$key]['action'] .= '<br /><a href="' . CM_URL . '/cm_api/attachments.php?id=' . $value['id'] . '" target="_blank">Attach</a>'; } } //datagrid, generating results table $grid = new SpoonDataGridSourceArray($query); $datagrid = new SpoonDatagrid($grid); $datagrid->setColumnsHidden('id', 'attachment'); $datagrid->setCompileDirectory(COMPILE_PATH); $url = $_SERVER['QUERY_STRING'] ? cleanQuery($_SERVER['QUERY_STRING']) . 'offset=[offset]&order=[order]&sort=[sort]' : '?offset=[offset]&order=[order]&sort=[sort]'; $datagrid->setURL($url);
<?php /** * Client Manager * * List all user profile * @package Client Manager 0.2 alpha * @author Jin Cong<*****@*****.**> */ define('LOAD_TEMPLATE', true); define('LOAD_MYSQL', true); define('IN_ADMIN', true); require '../cm_includes/entry.php'; $records = tableParser('profiles', 'getList'); if (count($records) > 0) { $tpl->assign('isResult', true); foreach ($records as $key => $value) { if (isset($value['photo'])) { $records[$key]['photo'] = '<img src="' . CM_URL . '/cm_api/images.php?id=' . $value['id'] . '&thumbnail=1" />'; } $records[$key]['action'] = '<a href="' . CM_URL . '/cm_admin/edit.php?id=' . $value['id'] . '" target="_blank">Edit</a><br /><a href="' . CM_URL . '/cm_admin/profile.php?id=' . $value['id'] . '" target="_blank">Print</a><br /><a href="" id="' . $value['id'] . '" class="delProfile">Delete</a>'; if (isset($value['attachment']) && strlen($value['attachment']) > 0) { $records[$key]['action'] .= '<br /><a href="' . CM_URL . '/cm_api/attachments.php?id=' . $value['id'] . '" target="_blank">Attach</a>'; } $records[$key]['company'] = getCompanyValue($value['company']); } //datagrid, generating results table $grid = new SpoonDataGridSourceArray($records); $datagrid = new SpoonDatagrid($grid); $datagrid->setCompileDirectory(COMPILE_PATH); $datagrid->setURL('?offset=[offset]&order=[order]&sort=[sort]');
<?php /** * Client Manager * * Extract Profile Attachment File * @package Client Manager 0.2 alpha * @author Jin Cong<*****@*****.**> */ define('LOAD_MYSQL', true); require '../cm_includes/entry.php'; if (empty($_GET['id'])) { die; } $attach = tableParser('profiles', 'getAttachment', array('id' => (int) $_GET['id'])); if (isset($attach['attachment']) && isset($attach['attachext'])) { header('Content-Disposition: attachment; filename="' . $attach['attachment'] . '.' . $attach['attachext'] . '"'); //generate attachs' path $attach = ATTACH_PATH . '/' . $attach['attachment'] . '.' . $attach['attachext']; if (!file_exists($attach)) { die; } echo gzuncompress(file_get_contents($attach)); } else { die; }
<?php /** * Client Manager * * CM API for delete a user * @package Client Manager 0.2 alpha * @author Jin Cong<*****@*****.**> */ if (empty($_POST['id'])) { die; } define('IN_API', true); define('LOAD_MYSQL', true); require '../cm_includes/entry.php'; echo tableParser('profiles', 'delete', array('id' => (int) $_POST['id'])) > 0 ? 1 : 0;
<?php define('LOAD_TEMPLATE', true); define('LOAD_MYSQL', true); require 'cm_includes/entry.php'; $trimed = trim($_GET['q']); if (isset($_GET['q']) && !empty($trimed)) { $search = tableParser('profiles', 'search', array('q' => $_GET['q'])); $tpl->assign('query', $_GET['q']); if ($search) { $html = "<table class='table'>\r\n\t<thead>\r\n\t\t<tr class='row'>\r\n\t\t <th class='span2'>Profile Pic</th>\r\n\t\t <th class='span6'>Details</th>\r\n\t\t</tr>\r\n\t</thead>\r\n\t<tbody>"; foreach ($search as $count => $values) { if ($count <= SEARCH_LIMIT) { $result = getResult($values, $_GET['q']); $html .= "<tr class='row'>\r\n <td class='span2'>" . $result['photo'] . "</td>\r\n <td class='span5'>" . $result['info'] . "<br />" . $result['data'] . "<br /><span style='color: #449944'>Last Update: " . $result['lastupdate'] . "</span></td>\r\n </tr>"; } } $html .= "</tbody></table>"; $tpl->assign("count", count($search)); $tpl->assign("helper", "About " . count($search) . " Results. "); $tpl->assign("result", $html); } else { $tpl->assign("helper", "No Relevant Results."); } } $tpl->assign('session', round((SpoonSession::get('expiredTime') - time()) / 60, 1)); $tpl->display(CM_ROOT . '/cm_includes/templates/search.tpl.php'); function getResult(array $values, $search) { $return['photo'] = isset($values['photo']) ? '<img src="' . CM_URL . '/cm_api/images.php?thumbnail=1&id=' . $values['id'] . '" />' : ''; empty($values['ic']) && ($values['ic'] = "-");
/** * Client Manager * * Show profile data in clean page * @package Client Manager 0.2 alpha * @author Jin Cong<*****@*****.**> */ define('LOAD_TEMPLATE', true); define('LOAD_MYSQL', true); define('IN_ADMIN', true); require '../cm_includes/entry.php'; if (!isset($_GET['id'])) { header("Location: " . CM_ROOT . '/cm_admin/'); } $profile = tableParser('profiles', 'getProf', array("id" => (int) $_GET['id'])); if (empty($profile)) { // if no relevant record $tpl->assign('tooltip', 'Profile not available'); } else { //generate img tag for photo if (isset($profile['photo'])) { $profile['photo'] = '<img src="' . CM_URL . '/cm_api/images.php?id=' . $profile['id'] . '" />'; } //clear unused key unset($profile['status']); unset($profile['id']); unset($profile['photoext']); $replaceLabel = array('file' => '档案<br /> File', 'case' => '案情<br/> Case', 'photo' => '照片 <br />Photo', 'name' => '姓名<br /> Name', 'ic' => '身份证<br /> IC', 'gender' => '性别<br /> Gender', 'placeofbirth' => '出生地点<br/> Place of Birth', 'education' => '学历 <br />Education', 'language' => '语言<br /> Language', 'race' => '种族<br /> Race', 'faith' => '信仰<br /> Faith', 'maritalstatus' => '婚姻状态 <br />Marital Status', 'nationality' => '国籍 <br /> Nationality', 'profession' => '职业 <br />Profession', 'epf' => '公积金 EPF', 'banker' => '银行 Banker', 'address' => '地址 <br /> Address', 'contactno' => '联络号码 <br /> Contact No.', 'email' => '电邮 <br /> Email', 'platesno' => '车牌号码 <br />Plates No.', 'assets' => '资产 <br /> Assets', 'height' => '身高 <br />Height(cm)', 'weight' => '体重 <br /> Weight(kg)', 'blood' => '血型 <br />Blood Type', 'eye' => '眼睛色 <br /> Eye Color', 'hair' => '头发色 <br /> Hair Color', 'skin' => '肤色 <br /> Skin Color', 'dna' => '脱氧核糖核酸 <br />DNA', 'family' => '家人 <br /> Family', 'remarks' => '备注 <br /> Remarks', 'casereport' => '案情<br />Case Report', 'lastupdate' => '最后更新<br />Last Update'); $profile_html = ''; //profile html
<?php /** * Client Manager * * CM API for checking username availability * @package Client Manager 0.2 alpha * @author Jin Cong<*****@*****.**> */ if (empty($_POST['name'])) { die; } define('IN_API', true); define('LOAD_MYSQL', true); require '../cm_includes/entry.php'; $getUser = tableParser('profiles', 'getName', array('name' => $_POST['name'])); if (count($getUser) > 1) { $json['count'] = count($getUser); foreach ($getUser as $key => $value) { $json['profiles'][] = $value['id']; } } elseif (count($getUser) == 1) { $json['count'] = 1; $json['profiles'] = $getUser[0]['id']; } else { $json['count'] = 0; } echo json_encode($json);
<?php /** * Client Manager * * Main Page of CM * @package Client Manager 0.2 alpha * @author Jin Cong<*****@*****.**> */ define('LOAD_TEMPLATE', true); define('LOAD_MYSQL', true); define('IN_ADMIN', true); require '../cm_includes/entry.php'; $tpl->assign('total', count(tableParser('profiles', 'getTotal'))); $tpl->assign('expired', round((SpoonSession::get('expiredTime') - time()) / 60, 1)); $tpl->display(tpl_path('admin_index.tpl.php'));