public function respond() { global $_W; $rid = $this->rule; $sql = "SELECT * FROM " . tablename('wxcard_reply') . " WHERE rid = :rid ORDER BY RAND() LIMIT 1"; $reply = pdo_fetch($sql, array(':rid' => $rid)); if (empty($reply)) { return false; } load()->classs('weixin.account'); load()->classs('coupon'); $coupon = new coupon($_W['acid']); if (is_error($coupon)) { $this->error($reply, $coupon['message']); die; } $card = $coupon->BuildCardExt($reply['cid']); if (is_error($card)) { $this->error($reply, $card['message']); die; } $data = array('touser' => $_W['openid'], 'msgtype' => 'wxcard', 'wxcard' => array('card_id' => $card['card_id'], 'card_ext' => $card['card_ext'])); $acc = WeAccount::create($_W['acid']); $status = $acc->sendCustomNotice($data); if (is_error($status)) { $this->error($reply, $status['message']); die; } if (!empty($reply['success'])) { return $this->respText($reply['success']); die; } return true; }
public function fieldsFormSubmit($rid = 0) { global $_GPC, $_W; $id = intval($_GPC['reply_id']); $credit = intval($_GPC['credit']); $insert = array('rid' => $rid, 'start_time' => strtotime($_GPC['start_time']), 'end_time' => strtotime($_GPC['end_time']), 'awardrules' => $_GPC['awardrules'], 'awardinfo' => $_GPC['awardinfo'], 'days' => $_GPC['days'], 'credit' => $credit); if (!empty($_FILES['thumb']['tmp_name'])) { file_delete($_GPC['thumb_old']); $upload = file_upload($_FILES['thumb']); if (is_error($upload)) { message($upload['message'], '', 'error'); } $insert['thumb'] = $upload['path']; } else { $tmp_file = array(name => "registration_top.jpg", tmp_name => "{$_SERVER['DOCUMENT_ROOT']}/source/modules/cgtsignin/template/style/images/registration_top.jpg"); $upload = file_upload($tmp_file); if (is_error($upload)) { message($upload['message'], '', 'error'); } $insert['thumb'] = $upload['path']; } if (empty($id)) { pdo_insert($this->tablename, $insert); } else { pdo_update($this->tablename, $insert, array('id' => $id)); } }
private function fetchUserInfo($openid) { $token = $this->fetchAccess(); $url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token={$token}&openid={$openid}&lang=zh_CN"; $response = ihttp_get($url); if (is_error($response)) { return error(-1, "访问公众平台接口失败, 错误: {$response['message']}"); } $result = @json_decode($response['content'], true); if (empty($result)) { return error(-2, "接口调用失败, 错误信息: {$response}"); } elseif (!empty($result['errcode'])) { return error(-3, "访问微信接口错误, 错误代码: {$result['errcode']}, 错误信息: {$result['errmsg']}"); } $ret = array(); $ret['nickname'] = $result['nickname']; $ret['gender'] = $result['sex']; $ret['residecity'] = $result['city']; $ret['resideprovince'] = $result['province']; $ret['avatar'] = $result['headimgurl']; if (!empty($ret['avatar'])) { $ret['avatar'] = rtrim($ret['avatar'], '0'); $ret['avatar'] .= '132'; } $ret['original'] = $result; return $ret; }
/** * Delete version * * @param void * @return null */ function delete() { if ($this->request->isSubmitted()) { if (!$this->active_page_version->canDelete($this->logged_user)) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if $delete = $this->active_page_version->delete(); if ($delete && !is_error($delete)) { if ($this->request->isAsyncCall()) { $this->httpOk(); } else { flash_success('Version #:version has been deleted', array('version' => $this->active_page_version->getVersion())); } // if } else { if ($this->request->isAsyncCall()) { $this->httpError(HTTP_ERR_OPERATION_FAILED); } else { flash_success('Failed to delete version #:version', array('version' => $this->active_page_version->getVersion())); } // if } // if $this->redirectToUrl($this->active_page->getViewUrl()); } else { $this->httpError(HTTP_ERR_BAD_REQUEST); } // if }
public function doMobileOAuth() { global $_W, $_GPC; $account = $this->getAccount(); $code = trim($_GPC['code']); if (!empty($code)) { $url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid={$account['key']}&secret={$account['secret']}&code={$code}&grant_type=authorization_code"; WeUtility::logging('trace', 'url:' . $url); $ret = ihttp_get($url); if (!is_error($ret)) { $auth = @json_decode($ret['content'], true); if (is_array($auth) && !empty($auth['openid'])) { $row = array(); $row['weid'] = $_W['weid']; $row['openid'] = $auth['openid']; $row['from_user'] = $auth['openid']; if ($auth['scope'] == 'snsapi_userinfo') { $user = $this->getFansInfo($auth['access_token'], $auth['openid']); $row['nickname'] = $user['nickname']; $row['avatar'] = $user['headimgurl']; } WeUtility::logging('trace', 'user:'******'query']); header('location: ' . $_W['siteroot'] . 'mobile.php?' . $forward . '&' . $this->cookiename . '=' . $auth['openid'] . '&wxref=mp.weixin.qq.com#wechat_redirect'); exit; } else { message($ret['content']); } } } message('微信授权失败!'); }
public function doWebPost() { global $_GPC, $_W; $id = intval($_GPC['id']); if (!empty($id)) { $item = pdo_fetch("SELECT * FROM " . tablename($this->headtable) . " WHERE id = :id", array(':id' => $id)); if (empty($item)) { message('抱歉,楼盘不存在或是已经删除!', '', 'error'); } } if (checksubmit('submit')) { if (empty($_GPC['title'])) { message('请输入商户名称!'); } $data = array('weid' => $_W['weid'], 'title' => $_GPC['title'], 'buildingintro' => htmlspecialchars_decode($_GPC['buildingintro']), 'traffic' => $_GPC['traffic'], 'projectintro' => $_GPC['projectintro'], 'phone' => $_GPC['phone'], 'province' => $_GPC['resideprovince'], 'city' => $_GPC['residecity'], 'dist' => $_GPC['residedist'], 'address' => $_GPC['address'], 'lng' => $_GPC['lng'], 'lat' => $_GPC['lat'], 'createtime' => TIMESTAMP); if (!empty($_FILES['thumb']['tmp_name'])) { file_delete($_GPC['thumb_old']); $upload = file_upload($_FILES['thumb']); if (is_error($upload)) { message($upload['message'], '', 'error'); } $data['thumb'] = $upload['path']; } if (empty($id)) { pdo_insert($this->headtable, $data); } else { unset($data['createtime']); pdo_update($this->headtable, $data, array('id' => $id)); } message('商户信息更新成功!', create_url('site/module/display', array('name' => 'lxybuilding')), 'success'); } include $this->template('post'); }
/** * Return object of a specific class by SQL * * @param string $sql * @param array $arguments * @param boolean $one * @param string $table_name * @param string $item_class * @return array */ function findBySQL($sql, $arguments = null, $one = false, $table_name = null, $item_class = null) { if ($arguments !== null) { $sql = db_prepare_string($sql, $arguments); } // if $rows = db_execute_all($sql); if (is_error($rows)) { return $rows; } // if if (!is_array($rows) || !count($rows)) { return null; } // if if ($one) { $item = new $item_class(); $item->loadFromRow($rows[0], true); return $item; } else { $items = array(); foreach ($rows as $row) { $item = new $item_class(); $item->loadFromRow($row, true); $items[] = $item; } // foreach return count($items) ? $items : null; } // if }
/** * Remove star from a given object * * @param ProjectObject $object * @param User $user * @return boolean */ function unstarObject($object, $user) { if (!$object->canView($user)) { return false; } // if if (StarredObjects::isStarred($object, $user)) { $cache_id = 'object_starred_by_' . $user->getId(); $starred_objects = cache_get($cache_id); if (!is_array($starred_objects)) { $starred_objects = StarredObjects::findObjectIdsByUser($user); } // if // Not starred? if (!in_array($object->getId(), $starred_objects)) { return true; } // if $execute = db_execute('DELETE FROM ' . TABLE_PREFIX . 'starred_objects WHERE object_id = ? AND user_id = ?', $object->getId(), $user->getId()); if ($execute && !is_error($execute)) { unset($starred_objects[array_search($object->getId(), $starred_objects)]); cache_set($cache_id, $starred_objects); } // if return $execute; } // if return true; }
public function doWebAddshop() { global $_GPC, $_W; $rid = intval($_GPC['rid']); $id = intval($_GPC['id']); if (!empty($id)) { $item = pdo_fetch("SELECT * FROM " . tablename('hotel_shop') . " WHERE id = :id", array(':id' => $id)); if (empty($item)) { message('抱歉,房型不存在或是已经删除!', '', 'error'); } } if (checksubmit('submit')) { if (empty($_GPC['style'])) { message('请输入房型!'); } $data = array('weid' => $_W['weid'], 'rid' => $rid, 'style' => $_GPC['style'], 'oprice' => $_GPC['oprice'], 'cprice' => $_GPC['cprice'], 'thumb' => $_GPC['thumb'], 'device' => htmlspecialchars_decode($_GPC['device'])); if (!empty($_FILES['thumb']['tmp_name'])) { file_delete($_GPC['thumb_old']); $upload = file_upload($_FILES['thumb']); if (is_error($upload)) { message($upload['message'], '', 'error'); } $data['thumb'] = $upload['path']; } if (empty($id)) { pdo_insert('hotel_shop', $data); } else { pdo_update('hotel_shop', $data, array('id' => $id)); } message('房型信息更新成功!', $this->createWebUrl('shop', array('id' => $_GPC['rid'])), 'success'); } include $this->template('addshop'); }
public function doWebChatlog() { global $_GPC, $_W; load()->func('tpl'); $acids = uni_accounts($_W['uniacid']); if (!empty($acids)) { $data = array(); foreach ($acids as $acid) { if (in_array($acid['level'], array(3, 4))) { $data[] = $acid; } } } $starttime = empty($_GPC['starttime']) ? strtotime(date('Y-m-d')) : strtotime($_GPC['starttime']); if (!empty($_GPC['token'])) { unset($_GPC['token']); $avatar = ''; $endtime = $starttime + 23 * 3600 + 3599; $acid = intval($_GPC['acid']); if (!empty($_GPC['nickname']) && empty($_GPC['openid'])) { $user = pdo_fetch('SELECT b.openid,a.avatar FROM ' . tablename('mc_members') . ' AS a LEFT JOIN ' . tablename('mc_mapping_fans') . ' AS b ON a.uid = b.uid WHERE a.nickname = :nickname', array(':nickname' => trim($_GPC['nickname']))); if (empty($user['openid'])) { message('没有找到昵称为 "' . $_GPC['nickname'] . '" 的用户', $this->createWebUrl('chatlog', array('acid' => $acid, 'nickname' => $_GPC['nickname'], 'openid' => $_GPC['openid'], 'starttime' => $_GPC['starttime'])), 'error'); } else { if (!empty($user['avatar'])) { $avatar = tomedia($user['avatar']); $nickname = $user['nickname']; } } } else { $openid = trim($_GPC['openid']); $user = pdo_fetch('SELECT b.openid,a.avatar,a.nickname FROM ' . tablename('mc_members') . ' AS a LEFT JOIN ' . tablename('mc_mapping_fans') . ' AS b ON a.uid = b.uid WHERE b.openid = :openid', array(':openid' => trim($_GPC['openid']))); if (!empty($user['avatar'])) { $avatar = tomedia($user['avatar']); $nickname = $user['nickname']; } } if ($acid > 0 && !empty($starttime) && !empty($endtime) && !empty($openid)) { $pindex = max(1, intval($_GPC['page'])); $acc = WeAccount::create($acid); $params = array('openid' => trim($_GPC['openid']), 'starttime' => $starttime, 'endtime' => $endtime, 'pageindex' => $pindex, 'pagesize' => 1000); $logs = $acc->fetchChatLog($params); $next = 1; if (is_error($logs) || empty($logs['recordlist']) || count($logs['recordlist']) < $params['pagesize']) { $next = 0; } $codedata = array(); $codedata[1000] = '创建未接入会话'; $codedata[1001] = '接入会话'; $codedata[1002] = '主动发起会话'; $codedata[1004] = '关闭会话'; $codedata[1005] = '抢接会话'; $codedata[2001] = '公众号收到消息'; $codedata[2002] = '客服发送消息'; $codedata[2003] = '客服收到消息'; } } include $this->template('chatlog'); }
function cache_clean($prefix = '') { $memcache = cache_memcache(); if (is_error($memcache)) { return $memcache; } return $memcache->flush(); }
/** * Delete templates by module name * * @param string $name * @return boolean */ function deleteByModule($name) { $delete = EmailTemplates::delete(array('module = ?', $name)); if ($delete && !is_error($delete)) { db_execute('DELETE FROM ' . TABLE_PREFIX . 'email_template_translations WHERE module = ?', $name); } // if return $delete; }
/** * Create new v1.1.4 configuration options * * @param void * @return boolean */ function newConfigOptions() { $insert = $this->utility->db->execute("INSERT INTO " . TABLE_PREFIX . "config_options (name, module, type, value) VALUES \n ('last_frequently_activity', 'system', 'system', 'N;'),\n ('last_hourly_activity', 'system', 'system', 'N;'),\n ('last_daily_activity', 'system', 'system', 'N;')\n "); if (is_error($insert)) { return $insert->getMessage(); } // if return true; }
public function fieldsFormSubmit($rid = 0) { global $_GPC, $_W; $id = intval($_GPC['reply_id']); $insert = array('rid' => $rid, 'weid' => $_W['weid'], 'title' => $_GPC['title'], 'description' => $_GPC['description'], 'votetype' => $_GPC['votetype'], 'votelimit' => $_GPC['votelimit'], 'votetimes' => $_GPC['votetimes'], 'votetotal' => $_GPC['votetotal'], 'isimg' => $_GPC['isimg'], 'share_title' => $_GPC['share_title'], 'share_desc' => $_GPC['share_desc'], 'share_url' => $_GPC['share_url'], 'share_txt' => $_GPC['share_txt'], 'starttime' => strtotime($_GPC['datelimit-start']), 'endtime' => strtotime($_GPC['datelimit-end'])); if (!empty($_GPC['thumb'])) { $insert['thumb'] = $_GPC['thumb']; file_delete($_GPC['thumb-old']); } if (empty($id)) { if ($insert['starttime'] <= time()) { $insert['isshow'] = 1; } else { $insert['isshow'] = 0; } $id = pdo_insert($this->tablename, $insert); } else { pdo_update($this->tablename, $insert, array('id' => $id)); } $options = array(); $option_ids = $_POST['option_id']; $option_titles = $_POST['option_title']; $option_thumb_olds = $_POST['option_thumb_old']; $files = $_FILES; $len = count($option_ids); $ids = array(); for ($i = 0; $i < $len; $i++) { $item_id = $option_ids[$i]; $a = array("title" => $option_titles[$i], "rid" => $rid); $f = 'option_thumb_' . $item_id; $old = $_GPC['option_thumb_' . $item_id]; if (!empty($files[$f]['tmp_name'])) { $upload = file_upload($files[$f]); if (is_error($upload)) { message($upload['message'], '', 'error'); } $a['thumb'] = $upload['path']; } else { if (!empty($old)) { $a['thumb'] = $old; } } if ((int) $item_id == 0) { pdo_insert("vote_option", $a); $item_id = pdo_insertid(); } else { pdo_update("vote_option", $a, array('id' => $item_id)); } $ids[] = $item_id; } if (!empty($ids)) { pdo_query("delete from " . tablename('vote_option') . " where id not in ( " . implode(',', $ids) . ") and rid = " . $rid); } return true; }
public function doWebList() { global $_GPC, $_W; load()->func('tpl'); $operation = !empty($_GPC['op']) ? $_GPC['op'] : 'display'; if ($operation == 'display') { if (!empty($_GPC['displayorder'])) { foreach ($_GPC['displayorder'] as $id => $displayorder) { pdo_update('meepomailattachment', array('displayorder' => $displayorder), array('id' => $id)); } message('分类排序更新成功!', $this->createWebUrl('List', array('op' => 'display')), 'success'); } $list = pdo_fetchall("SELECT * FROM " . tablename('meepomailattachment') . " WHERE weid = '{$_W['weid']}' ORDER BY id ASC, displayorder DESC"); include $this->template('list'); } elseif ($operation == 'post') { $id = intval($_GPC['id']); if (!empty($id)) { $list = pdo_fetch("SELECT * FROM " . tablename('meepomailattachment') . " WHERE id = '{$id}'"); } else { $list = array('displayorder' => 0); } if (checksubmit('submit')) { if (empty($_GPC['attachmentname']) || empty($_GPC['description'])) { message('文件名称以及文件描述是必填项!', $this->createWebUrl('list'), 'error'); } $data = array('weid' => $_W['weid'], 'attachmentname' => $_GPC['attachmentname'], 'isshow' => intval($_GPC['isshow']), 'displayorder' => intval($_GPC['displayorder']), 'description' => $_GPC['description']); if (!empty($_FILES['thumb']['tmp_name'])) { load()->func('file'); file_delete($_GPC['thumb_old']); $upload = $this->file_upload($data['attachmentname'], $_FILES['thumb']); if (is_error($upload)) { message($upload['message'], '', 'error'); } $data['thumb'] = $upload['path']; } if (!empty($id)) { unset($data['id']); pdo_update('meepomailattachment', $data, array('id' => $id)); } else { pdo_insert('meepomailattachment', $data); $id = pdo_insertid(); } message('更新附件成功!', $this->createWebUrl('list', array('op' => 'display')), 'success'); } include $this->template('list'); } elseif ($operation == 'delete') { $id = intval($_GPC['id']); $category = pdo_fetch("SELECT id FROM " . tablename('meepomailattachment') . " WHERE id = '{$id}'"); if (empty($category)) { message('抱歉,附件不存在或是已经被删除!', $this->createWebUrl('list', array('op' => 'display')), 'error'); } pdo_delete('meepomailattachment', array('id' => $id), 'OR'); message('附件信息删除成功!', $this->createWebUrl('list', array('op' => 'display')), 'success'); } }
public function deleteAction($uid) { $uid = intval($uid); $ret = $this->acl->removeUser($uid); if (is_error($ret)) { $this->error($ret['message']); } else { $this->success('删除成功'); exit; } }
function cw_payment_process_void($order) { global $config; $doc_id = $order['doc_id']; $result = cw_call('cw_payment_do_void', array($order)); if (!is_error($result)) { cw_call('cw_doc_place_extras_data', array($doc_id, array('capture_status' => 'V'))); cw_call('cw_doc_change_status', array($doc_id, 'D')); cw_add_top_message('Payment voided, order status is changed to Declined'); } return $result; }
/** * Update existing tables * * @param void * @return boolean */ function updateExistingTables() { $changes = array("alter table `" . TABLE_PREFIX . "subscriptions` change column `parent_id` `parent_id` int(10) unsigned NOT NULL default '0' after `user_id`"); foreach ($changes as $change) { $update = $this->utility->db->execute($change); if (is_error($update)) { return $update->getMessage(); } // if } // foreach return true; }
function moduleInit($name, $params = array()) { if (empty($name)) { return false; } $site = WeUtility::createModuleSite($name); if (!is_error($site)) { $method = 'shareResult'; if (method_exists($site, $method)) { $site->{$method}($params); exit('success'); } } }
public function _empty() { $pieces = explode('/', __INFO__, 5); if (count($pieces) >= 4 && $pieces[0] == 'extend') { $params = array(); $params['Entry'] = 'App'; list($action, $params['Addon'], $params['Controller'], $params['Action'], $params['Stuff']) = $pieces; unset($_GET[$params['Controller']]); $ret = Addon::run($params); if (is_error($ret)) { $this->error($ret['message']); } return; } }
/** * [WDL] Copyright (c) 2013 B2CTUI.COM * $sn: origins/source/model/fans.mod.php : v 866195d935cc : 2014/05/16 09:42:08 : veryinf $ */ function fans_update($user, $fields) { global $_W; $_W['weid'] && ($fields['weid'] = $_W['weid']); $struct = cache_load('fansfields'); if (empty($fields)) { return false; } if (empty($struct)) { $struct = cache_build_fans_struct(); } foreach ($fields as $field => $value) { if (!in_array($field, $struct)) { unset($fields[$field]); } } if (empty($fields['avatar']) && !empty($_FILES['avatar']['tmp_name'])) { $_W['uploadsetting'] = array(); $_W['uploadsetting']['avatar']['folder'] = 'avatar'; $_W['uploadsetting']['avatar']['extentions'] = $_W['config']['upload']['image']['extentions']; $_W['uploadsetting']['avatar']['limit'] = $_W['config']['upload']['image']['limit']; $upload = file_upload($_FILES['avatar'], 'avatar', $user); if (is_error($upload)) { message($upload['message']); } $fields['avatar'] = $upload['path']; } elseif (!empty($fields['avatar'])) { $pathinfo = pathinfo($fields['avatar']); $fields['avatar'] = $pathinfo['basename']; } $isexists = pdo_fetchcolumn("SELECT id FROM " . tablename('fans') . " WHERE from_user = :user", array(':user' => $user)); if (empty($isexists)) { $fields['from_user'] = $user; $fields['createtime'] = TIMESTAMP; foreach ($struct as $field) { if ($field != 'id' && $field != 'follow' && !isset($fields[$field])) { $fields[$field] = ''; } } if (empty($fields['salt'])) { $fields['salt'] = random(8); } return pdo_insert('fans', $fields); } else { unset($fields['from_user']); return pdo_update('fans', $fields, array('from_user' => $user)); } }
public function create($record) { $rec = $this->table('__BR_BRIDGES__')->data($record)->add(); if (!empty($rec)) { $id = $this->getLastInsID(); $pid = $this->addon->registerTakeOver(0, $id, 0, '对接' . $record['title']); if (!is_error($pid)) { $rec = array(); $rec['processor'] = $pid; $this->table('__BR_BRIDGES__')->data($rec)->where("`id`='{$id}'")->save(); } } else { $id = 0; } return $id; }
public function doWebDisplay() { global $_GPC, $_W; $op = !empty($_GPC['op']) ? $_GPC['op'] : 'display'; $id = intval($_GPC['id']); if ($op == 'post') { if (!empty($id)) { $sql = "select * from" . tablename('chax') . "where weid='{$_W['weid']}' and id=" . $id; $item = pdo_fetch($sql); } $data = array('weid' => $_W['weid'], 'title' => $_GPC['title'], 'url' => $_GPC['url'], 'displayorder' => intval($_GPC['displayorder']), 'status' => intval($_GPC['status'])); if ($_W['ispost']) { if (!empty($_FILES['fileicon']['tmp_name'])) { file_delete($_GPC['topPicture-old']); $upload = file_upload($_FILES['fileicon']); if (is_error($upload)) { message($upload['message'], '', 'error'); } $data['fileicon'] = $upload['path']; } if (empty($id)) { pdo_insert('chax', $data); } else { pdo_update('chax', $data, array('id' => $id)); } message('更新成功', referer(), 'success'); } } elseif ($op == 'display') { $sql = "select * from " . tablename('chax') . "where weid='{$_W['weid']}'"; $row = pdo_fetchall($sql); } elseif ($op == 'delete') { pdo_delete('chax', array('id' => $id, 'weid' => $_W['weid'])); message('删除成功', referer(), 'success'); } elseif ($op == 'edit') { $status = intval($_GPC['status']); if ($status == 1) { $sql = "update" . tablename('chax') . " set status = 0 where weid= '{$_W['weid']}' and id=" . $id; pdo_query($sql); } else { $sql = "update" . tablename('chax') . " set status = 1 where weid= '{$_W['weid']}' and id=" . $id; pdo_query($sql); } message('更新成功', referer(), 'success'); } include $this->template('display'); }
/** * Update existing tables * * @param void * @return boolean */ function updateExistingTables() { $changes = array("alter table `" . TABLE_PREFIX . "project_objects` change `milestone_id` `milestone_id` int(10) unsigned null default null"); $tables = $this->utility->db->listTables(TABLE_PREFIX); if (is_array($tables) && in_array(TABLE_PREFIX . 'time_reports', $tables)) { $changes[] = "alter table `" . TABLE_PREFIX . "time_reports` change `billable_filter` `billable_filter` enum('all', 'billable', 'not_billable', 'billable_billed', 'billable_not_billed', 'pending_payment') not null default 'all'"; } // if foreach ($changes as $change) { $update = $this->utility->db->execute($change); if (is_error($update)) { return $update->getMessage(); } // if } // foreach return true; }
/** * Update existing tables * * @param void * @return boolean */ function updateExistingTables() { $tables = $this->utility->db->listTables(TABLE_PREFIX); $changes = array("alter table " . TABLE_PREFIX . "assignment_filters change user_filter_data user_filter_data text", "alter table " . TABLE_PREFIX . "assignment_filters change project_filter_data project_filter_data text", "alter table " . TABLE_PREFIX . "reminders change comment comment text"); if (in_array(TABLE_PREFIX . 'status_updates', $tables)) { $changes[] = "alter table " . TABLE_PREFIX . "status_updates drop parent_id"; } // if foreach ($changes as $change) { $update = $this->utility->db->execute($change); if (is_error($update)) { return $update->getMessage(); } // if } // foreach return true; }
/** * Set value of $name config option for a given project * * @param string $name * @param mixed $value * @param Project $project * @return mixed */ function setValue($name, $value, $project) { $option = ConfigOptions::findByName($name, PROJECT_CONFIG_OPTION); if (instance_of($option, 'ConfigOption')) { $table = TABLE_PREFIX . 'project_config_options'; $count = db_execute_one("SELECT COUNT(*) AS 'row_num' FROM {$table} WHERE project_id = ? AND name = ?", $project->getId(), $name); if (isset($count) && $count['row_num'] > 0) { $result = db_execute("UPDATE {$table} SET value = ? WHERE project_id = ? AND name = ?", serialize($value), $project->getId(), $name); } else { $result = db_execute("INSERT INTO {$table} (project_id, name, value) VALUES (?, ?, ?)", $project->getId(), $name, serialize($value)); } // if return $result && !is_error($result) ? $value : $result; } else { return new InvalidParamError('name', $name, "Project configuration option '{$name}' does not exist", true); } // if }
/** * Delete all items for a invoice * * @param Invoice $invoice * @return null */ function deleteByInvoice($invoice) { db_begin_work(); $execute = db_execute('DELETE FROM ' . TABLE_PREFIX . 'invoice_time_records WHERE invoice_id = ?', $invoice->getId()); if ($execute && !is_error($execute)) { $delete = InvoiceItems::delete(array('invoice_id = ?', $invoice->getId())); if ($delete && !is_error($delete)) { db_commit(); } else { db_rollback(); } // if return $delete; } else { db_rollback(); return $execute; } // if }
/** * Attach files from some array to $to object * * - $from keys : - path * - filename * - type * * @param array $from * @param ProjectObject $to */ function attach_from_array(&$from, &$to) { $attached = 0; if (is_foreachable($from)) { foreach ($from as $file) { $attach = $to->attachFile($file['path'], $file['filename'], $file['type']); if (is_error($attach) || !$attach) { $to->clearPendingFiles(); return $attach; } else { $attached++; } // if } // foreach } // if return $attached; }
public function getSign() { global $_W; $jsapiTicket = $this->getJsApiTicket(); if (is_error($jsapiTicket)) { $jsapiTicket = $jsapiTicket['message']; } $nonceStr = $this->createNonceStr(); $timestamp = TIMESTAMP; $url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $string1 = "jsapi_ticket={$jsapiTicket}&noncestr={$nonceStr}×tamp={$timestamp}&url={$url}"; $signature = sha1($string1); $config = array("appId" => $_W['account']['key'], "nonceStr" => $nonceStr, "timestamp" => "{$timestamp}", "signature" => $signature); if (DEVELOPMENT) { $config['url'] = $url; $config['string1'] = $string1; $config['name'] = $_W['account']['name']; } return $config; }
private function fileImageUpload($option) { if (empty($option['width'])) { $option['width'] = 600; } if (!empty($_FILES['file']['name'])) { $ret = Utility::upload($_FILES['file']); if (is_error($ret)) { $this->frameCallback($ret); } File::imageThumb($ret['abs'], $ret['abs'], $option['width']); $result = array(); $result['filename'] = $ret['filename']; $result['url'] = $ret['url']; $result['error'] = 0; $this->frameCallback($result); } else { $this->frameCallback(error(-1, '请选择要上传的图片!')); } }