function post($sTable, $sId, $sAuthor, $sParent, $sMood, $sFileId) { global $sIncPath; global $sModule; global $sHomeUrl; require $sIncPath . "content.inc.php"; $sText = getEmbedCode($sModule, "player", array('id' => $sFileId, 'file' => TRUE_VAL)); $sText = str_replace($sHomeUrl, "[ray_url]", $sText); $sSql = "INSERT INTO `" . $sTable . "`(`cmt_parent_id`, `cmt_object_id`, `cmt_author_id`, `cmt_text`, `cmt_mood`, `cmt_time`) VALUES('" . $sParent . "', '" . $sId . "', '" . $sAuthor . "', '" . $sText . "', '" . $sMood . "', NOW())"; getResult($sSql); return getLastInsertId(); }
function post($sTable, $sId, $sAuthor, $sParent, $sMood, $sFileId) { global $sIncPath; global $sModule; global $sHomeUrl; $sText = getEmbedCode($sModule, "player", array('id' => $sFileId)); $sText = str_replace($sHomeUrl, "[ray_url]", $sText); $sSql = "INSERT INTO `" . $sTable . "`(`cmt_parent_id`, `cmt_object_id`, `cmt_author_id`, `cmt_text`, `cmt_mood`, `cmt_time`) VALUES('" . $sParent . "', '" . $sId . "', '" . $sAuthor . "', '" . $sText . "', '" . $sMood . "', NOW())"; getResult($sSql); $iCommentId = getLastInsertId(); getResult("UPDATE `" . MODULE_DB_PREFIX . "Files` SET `Description`='" . $iCommentId . "' WHERE `ID`='" . $sFileId . "'"); return $iCommentId; }
function publishRecordedVideoFile($sUserId) { global $sModule; global $sFilesPath; $sPlayFile = $sFilesPath . $sUserId . VC_TEMP_FILE_NAME . VC_FLV_EXTENSION; if (file_exists($sPlayFile) && filesize($sPlayFile) > 0) { $sDBModule = DB_PREFIX . ucfirst($sModule); getResult("INSERT INTO `" . $sDBModule . "Files` SET `Date`='" . time() . "', `Owner`='" . $sUserId . "', `Status`='" . VC_STATUS_PENDING . "'"); $sFileId = getLastInsertId(); rename($sPlayFile, $sFilesPath . $sFileId); @rename($sFilesPath . $sUserId . VC_TEMP_FILE_NAME . VC_IMAGE_EXTENSION, $sFilesPath . $sFileId . VC_IMAGE_EXTENSION); @rename($sFilesPath . $sUserId . VC_TEMP_FILE_NAME . VC_THUMB_FILE_NAME . VC_IMAGE_EXTENSION, $sFilesPath . $sFileId . VC_THUMB_FILE_NAME . VC_IMAGE_EXTENSION); return $sFileId; } else { return false; } }
function publishRecordedFile($sUserId, $sTitle, $sCategory, $sTags, $sDesc) { global $sModule; global $sFilesPathMp3; $sTempFile = $sFilesPathMp3 . $sUserId . TEMP_FILE_NAME; $sPlayFile = $sTempFile . MP3_EXTENSION; if (file_exists($sPlayFile) && filesize($sPlayFile) > 0) { $sDBModule = DB_PREFIX . ucfirst($sModule); $sUri = mp3_genUri($sTitle); $sUriPart = empty($sUri) ? "" : "`Uri`='" . $sUri . "', "; $sAutoApprove = getSettingValue($sModule, "autoApprove") == TRUE_VAL ? STATUS_APPROVED : STATUS_DISAPPROVED; getResult("INSERT INTO `" . $sDBModule . "Files` SET `Categories`='" . $sCategory . "', `Title`='" . $sTitle . "', " . $sUriPart . "`Tags`='" . $sTags . "', `Description`='" . $sDesc . "', `Date`='" . time() . "', `Owner`='" . $sUserId . "', `Status`='" . $sAutoApprove . "'"); $sFileId = getLastInsertId(); rename($sPlayFile, $sFilesPathMp3 . $sFileId . MP3_EXTENSION); @rename($sTempFile . SCREENSHOT_EXT, $sFilesPathMp3 . $sFileId . SCREENSHOT_EXT); return $sFileId; } else { return false; } }
function publishRecordedFile($sUserId, $sTitle, $sCategory, $sTags, $sDesc) { global $sModule; global $sFilesPathMp3; $sTempFile = $sFilesPathMp3 . $sUserId . TEMP_FILE_NAME; $sPlayFile = $sTempFile . MP3_EXTENSION; if (file_exists($sPlayFile) && filesize($sPlayFile) > 0) { $sDBModule = DB_PREFIX . ucfirst($sModule); $sUri = mp3_genUri($sTitle); $sUriPart = empty($sUri) ? "" : "`Uri`='" . $sUri . "', "; $sAutoApprove = getSettingValue($sModule, "autoApprove") == TRUE_VAL ? STATUS_APPROVED : STATUS_DISAPPROVED; getResult("INSERT INTO `" . $sDBModule . "Files` SET `Categories`='" . $sCategory . "', `Title`='" . $sTitle . "', " . $sUriPart . "`Tags`='" . $sTags . "', `Description`='" . $sDesc . "', `Date`='" . time() . "', `Owner`='" . $sUserId . "', `Status`='" . $sAutoApprove . "'"); $sFileId = getLastInsertId(); rename($sPlayFile, $sFilesPathMp3 . $sFileId . MP3_EXTENSION); $aFilesConfig = BxDolService::call('sounds', 'get_files_config'); foreach ($aFilesConfig as $a) { if (isset($a['image']) && $a['image']) { @rename($sTempFile . $a['postfix'], $sFilesPathMp3 . $sFileId . $a['postfix']); } } return $sFileId; } return false; }
function getAttributes($resource, $readConnection, $writeConnection, $username, $password, $service_url) { $service_urlPost = $service_url . "/user/token"; $curlPost = curl_init($service_urlPost); $headersPost = array('Content-Type:application/json;charset=utf-8', 'Content-Length: 0', 'Authorization: Basic ' . base64_encode($username . ":" . $password)); curl_setopt($curlPost, CURLOPT_POST, true); // indico che la richiesta è di tipo POST curl_setopt($curlPost, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_setopt($curlPost, CURLOPT_SSL_VERIFYPEER, false); // disabilito la verifica del certificato SSL; è necessario perchè altrimenti non esegue la chiamata rest curl_setopt($curlPost, CURLOPT_RETURNTRANSFER, true); curl_setopt($curlPost, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curlPost, CURLOPT_HTTPHEADER, $headersPost); $curl_responsePost = curl_exec($curlPost); if ($curl_responsePost === false) { $infoPost = curl_getinfo($curlPost); curl_close($curlPost); return false; } else { curl_close($curlPost); $decodedPost = json_decode($curl_responsePost); if (is_object($decodedPost)) { $arrayPost = get_object_vars($decodedPost); } $aToken = $arrayPost["access_token"]; $headersGet = array('Authorization: Bearer ' . $aToken); // recupero solo l'header della richiesta $service_urlGet = $service_url . "/attributes?&limit=100"; $curlGet = curl_init($service_urlGet); curl_setopt($curlGet, CURLOPT_HTTPAUTH, CURLAUTH_ANY); // accetto ogni autenticazione. Il sitema utilizzerà la migliore curl_setopt($curlGet, CURLOPT_SSL_VERIFYPEER, false); // disabilito la verifica del certificato SSL; è necessario perchè altrimenti non esegue la chiamata rest curl_setopt($curlGet, CURLOPT_RETURNTRANSFER, true); // salvo l'output della richiesta in una variabile curl_setopt($curlGet, CURLOPT_HEADER, true); curl_setopt($curlGet, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curlGet, CURLOPT_NOBODY, true); curl_setopt($curlGet, CURLOPT_HTTPHEADER, $headersGet); // setto l'header della richiesta $header = curl_exec($curlGet); if ($header === false) { $infoGet = curl_getinfo($curlGet); curl_close($curlGet); return false; } else { // costrusico un array dell'header e recupero il totale delle pagine $myarray = array(); $data = explode("\n", $header); $myarray['status'] = $data[0]; array_shift($data); foreach ($data as $part) { $middle = explode(":", $part); if (isset($middle[1])) { $myarray[trim($middle[0])] = trim($middle[1]); } } $pagine = $myarray["X-Count-Pages"]; // effettuo una chiamata al web service per ogni pagina for ($p = 1; $p <= $pagine; $p++) { $service_urlPost = $service_url . "/user/token"; $curlPost = curl_init($service_urlPost); $headersPost = array('Content-Type:application/json;charset=utf-8', 'Content-Length: 0', 'Authorization: Basic ' . base64_encode($username . ":" . $password)); curl_setopt($curlPost, CURLOPT_POST, true); // indico che la richiesta è di tipo POST curl_setopt($curlPost, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_setopt($curlPost, CURLOPT_SSL_VERIFYPEER, false); // disabilito la verifica del certificato SSL; è necessario perchè altrimenti non esegue la chiamata rest curl_setopt($curlPost, CURLOPT_RETURNTRANSFER, true); curl_setopt($curlPost, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curlPost, CURLOPT_HTTPHEADER, $headersPost); $curl_responsePost = curl_exec($curlPost); if ($curl_responsePost === false) { $infoPost = curl_getinfo($curlPost); curl_close($curlPost); return false; } else { curl_close($curlPost); $decodedPost = json_decode($curl_responsePost); if (is_object($decodedPost)) { $arrayPost = get_object_vars($decodedPost); } $aToken = $arrayPost["access_token"]; $headersGet = array('Authorization: Bearer ' . $aToken); $service_urlGet = $service_url . "/attributes?limit=100&page=" . $p; $curlGet = curl_init($service_urlGet); curl_setopt($curlGet, CURLOPT_HTTPAUTH, CURLAUTH_ANY); // accetto ogni autenticazione. Il sitema utilizzerà la migliore curl_setopt($curlGet, CURLOPT_SSL_VERIFYPEER, false); // disabilito la verifica del certificato SSL; è necessario perchè altrimenti non esegue la chiamata rest curl_setopt($curlGet, CURLOPT_RETURNTRANSFER, true); // salvo l'output della richiesta in una variabile curl_setopt($curlGet, CURLOPT_HTTPHEADER, $headersGet); // setto l'header della richiesta curl_setopt($curlGet, CURLOPT_SSL_VERIFYHOST, false); $curl_responseGet = curl_exec($curlGet); if ($curl_responseGet === false) { $infoGet = curl_getinfo($curlGet); curl_close($curlGet); return false; } else { curl_close($curlGet); // parse del contenuto $decodedGet = json_decode($curl_responseGet); $countP = 0; $array_sku = array(""); if (is_object($decodedGet)) { $decodedGet = get_object_vars($decodedGet); } $l = 1; foreach ($decodedGet as $key => $value) { $l = $l + 1; $id_attributo = $key; $valoreProdotti = $value; $description = null; $valoriAttributi = null; foreach ($valoreProdotti as $key => $value) { // recupero campi prodotto if ($key == "description") { $nome_attributo = $value; if (is_object($nome_attributo)) { $nome_attributo = get_object_vars($nome_attributo); } } if ($key == "values") { $subattributes = $value; if (is_object($subattributes)) { $subattributes = get_object_vars($subattributes); } } } // controllo esistenza dell'attributo in magento $stringQuery = "select id_magento from " . $resource->getTableName('wsca_attributes') . " where id_ws='" . $id_attributo . "'"; $id_attributoMage = $readConnection->fetchOne($stringQuery); if ($id_attributoMage == null) { $model = Mage::getModel('eav/entity_setup', 'core_setup'); if (count($subattributes) == 0) { $input = "text"; $dbInput = "testo"; } else { $input = "multiselect"; $dbInput = "select"; } $data = array('global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE, 'group' => 'General', 'type' => 'varchar', 'backend' => '', 'frontend' => '', 'label' => ucfirst(strtolower(replace_accents($nome_attributo))), 'input' => $input, 'unique' => false, 'required' => false, 'is_configurable' => false, 'searchable' => false, 'visible_in_advanced_search' => false, 'comparable' => false, 'filterable' => false, 'filterable_in_search' => false, 'used_for_promo_rules' => false, 'visible_on_front' => false, 'used_in_product_listing' => false, 'used_for_sort_by' => false, 'user_defined' => true); $nome_attributoMage = substr("ca_" . $id_attributo, 0, 30); $model->addAttribute('catalog_product', $nome_attributoMage, $data); $setup = new Mage_Eav_Model_Entity_Setup('core_setup'); $optionTable = $setup->getTable('eav/attribute'); $id_attributoMage = getLastInsertId($optionTable, 'attribute_id'); $query = "insert into " . $resource->getTableName('wsca_attributes') . " (id_magento,id_ws,tipo) values('" . $id_attributoMage . "','" . $id_attributo . "','" . $dbInput . "')"; $writeConnection->query($query); } else { $nome_attributoMage = substr("ca_" . $id_attributo, 0, 30); } // se l'attributo è il supercolore utilizzo anche l'attributo colore if ($nome_attributo == "Supercolore") { } else { foreach ($subattributes as $key => $value) { $id_valoreattributo = $key; $nome_valoreattributo = $value; // controllo esistenza opzione in magento per l'attributo in questione $stringQuery = "select id_magento from " . $resource->getTableName('wsca_subattributes') . " where id_ws='" . $id_valoreattributo . "' and id_attributes='" . $id_attributo . "'"; $id_valoreattributoMage = $readConnection->fetchOne($stringQuery); if ($id_valoreattributoMage == null) { if ($nome_valoreattributo == "" || $nome_valoreattributo == null) { } else { $attribute_model = Mage::getModel('eav/entity_attribute'); $attribute_options_model = Mage::getModel('eav/entity_attribute_source_table'); $attribute_code = $attribute_model->getIdByCode('catalog_product', $nome_attributoMage); $attribute = $attribute_model->load($attribute_code); $attribute->setData('option', array('value' => array('option' => array(ucfirst(strtolower($nome_valoreattributo)), ucfirst(strtolower($nome_valoreattributo)))))); $attribute->save(); $setup = new Mage_Eav_Model_Entity_Setup('core_setup'); $optionTable = $setup->getTable('eav/attribute_option'); $id_valoreattributoMage = getLastInsertId($optionTable, 'option_id'); $query = "insert into " . $resource->getTableName('wsca_subattributes') . " (id_magento,id_ws, id_attributes) values('" . $id_valoreattributoMage . "','" . $id_valoreattributo . "','" . $id_attributo . "')"; $writeConnection->query($query); } } else { $attr = Mage::getModel('catalog/product')->getResource()->getAttribute($nome_attributoMage); if ($attr->usesSource()) { $nomeValoreAttributoMage = $attr->getSource()->getOptionText($id_valoreattributoMage); if (strtolower($nomeValoreAttributoMage) != strtolower($nome_valoreattributo)) { $attribute_model = Mage::getModel('eav/entity_attribute'); $attribute_options_model = Mage::getModel('eav/entity_attribute_source_table'); $attribute_code = $attribute_model->getIdByCode('catalog_product', $nome_attributoMage); $attribute = $attribute_model->load($attribute_code); // modifica della stagione su magento (nome dell'opzione) $data = array(); $values = array($id_valoreattributoMage => array(0 => ucfirst(strtolower($nome_valoreattributo)), 1 => ucfirst(strtolower($nome_valoreattributo)))); $data['option']['value'] = $values; $attribute->addData($data); $attribute->save(); } } } } } } } } } } } return true; }
/** * Actions with specified room */ function doRoom($sSwitch, $iUserId = 0, $iRoomId = 0, $sRoom = "") { switch ($sSwitch) { case 'insert': $aCurRoom = getArray("SELECT `ID`, `Status` FROM `" . MODULE_DB_PREFIX . "Rooms` WHERE `Name`='" . $sRoom . "'"); if (!empty($aCurRoom['ID']) && $aCurRoom['Status'] == ROOM_STATUS_DELETE) { getResult("UPDATE `" . MODULE_DB_PREFIX . "Rooms` SET `OwnerID`='" . $iUserId . "', `When`=UNIX_TIMESTAMP(), `Status`='" . ROOM_STATUS_NORMAL . "' WHERE `ID`='" . $aCurRoom['ID'] . "'"); return $aCurRoom['ID']; } else { if (empty($aCurRoom['ID'])) { getResult("INSERT INTO `" . MODULE_DB_PREFIX . "Rooms` (`ID`, `Name`, `OwnerID`, `When`, `Status`) VALUES ('" . $iRoomId . "', '" . addslashes($sRoom) . "', '" . $iUserId . "', UNIX_TIMESTAMP(), '" . ROOM_STATUS_NORMAL . "')"); return getLastInsertId(); } else { return 0; } } break; case 'delete': $sQuery = "UPDATE `" . MODULE_DB_PREFIX . "Rooms` SET `When`=UNIX_TIMESTAMP(), `Status`='" . ROOM_STATUS_DELETE . "' WHERE `ID` = '" . $iRoomId . "'"; getResult($sQuery); break; } }
case 'initFile': $sContents = parseXml($aXmlTemplates['result'], "msgErrorUpload", FAILED_VAL); $sTempFileName = $sFilesPath . $sId . TEMP_FILE_NAME; if (!file_exists($sTempFileName)) { break; } $sConvert = isset($_REQUEST['convert']) ? $_REQUEST['convert'] : TRUE_VAL; $bJustRename = $sConvert != TRUE_VAL; if (!convert($sId, $bJustRename)) { deleteTempFiles($sId); break; } $sAutoApprove = $bAdmin ? TRUE_VAL : getSettingValue($sModule, "autoApprove"); $sUri = genUri($sTitle); getResult("INSERT INTO `" . MODULE_DB_PREFIX . "Files`(`CategoryId`, `Title`, `Uri`, `Tags`, `Description`, `Date`, `Owner`, `Approved`) VALUES ('" . $sCategory . "', '" . $sTitle . "', '" . $sUri . "', '" . $sTags . "', '" . $sDesc . "', '" . time() . "', '" . $sId . "', '" . $sAutoApprove . "')"); $sFileId = getLastInsertId(); if (!renameFile($sId, $sFileId)) { deleteTempFiles($sId); getResult("DELETE FROM `" . MODULE_DB_PREFIX . "Files` WHERE `ID`='" . $sFileId . "' LIMIT 1"); break; } $sNewFileName = $sFileId . MP3_EXTENSION; deleteTempFiles($sId, true); parseTags($sFileId); if ($sId != "0") { getResult("UPDATE `" . MODULE_DB_PREFIX . "PlayLists` SET `Order`=`Order`+1 WHERE `Owner` = '" . $sId . "'"); getResult("INSERT INTO `" . MODULE_DB_PREFIX . "PlayLists` VALUES('" . $sFileId . "', '" . $sId . "', '1')"); } $sContents = parseXml($aXmlTemplates['result'], "", SUCCESS_VAL); $sContents .= parseXml($aXmlTemplates['file'], $sFileId, $sNewFileName); break;
function publishRecordedVideo($sUserId, $sTitle, $sCategory, $sTags, $sDesc, $aFilesConfig = array()) { global $sModule; global $sFilesPath; $sPlayFile = $sFilesPath . $sUserId . TEMP_FILE_NAME . FLV_EXTENSION; if (file_exists($sPlayFile) && filesize($sPlayFile) > 0) { if (!$aFilesConfig) { $aFilesConfig = BxDolService::call('videos', 'get_files_config'); } $sDBModule = DB_PREFIX . ucfirst($sModule); $sUri = video_genUri($sTitle); $sUriPart = empty($sUri) ? "" : "`Uri`='" . $sUri . "', "; getResult("INSERT INTO `" . $sDBModule . "Files` SET `Categories`='" . $sCategory . "', `Title`='" . $sTitle . "', " . $sUriPart . "`Tags`='" . $sTags . "', `Description`='" . $sDesc . "', `Date`='" . time() . "', `Owner`='" . $sUserId . "', `Status`='" . STATUS_PENDING . "'"); $sFileId = getLastInsertId(); rename($sPlayFile, $sFilesPath . $sFileId); foreach ($aFilesConfig as $a) { if (isset($a['image']) && $a['image']) { @rename($sFilesPath . $sUserId . TEMP_FILE_NAME . $a['postfix'], $sFilesPath . $sFileId . $a['postfix']); } } return $sFileId; } return false; }
$nome_valoreattributo = $value; // controllo esistenza opzione in magento per l'attributo in questione $stringQuery = "select id_magento from " . $resource->getTableName('wsca_subattributes') . " where id_ws='" . $id_valoreattributo . "' and id_attributes='" . $id_attributo . "'"; $id_valoreattributoMage = $readConnection->fetchOne($stringQuery); if ($id_valoreattributoMage == null) { if ($nome_valoreattributo == "" || $nome_valoreattributo == null) { } else { $attribute_model = Mage::getModel('eav/entity_attribute'); $attribute_options_model = Mage::getModel('eav/entity_attribute_source_table'); $attribute_code = $attribute_model->getIdByCode('catalog_product', $nome_attributoMage); $attribute = $attribute_model->load($attribute_code); $attribute->setData('option', array('value' => array('option' => array(ucfirst(strtolower($nome_valoreattributo)), ucfirst(strtolower($nome_valoreattributo)))))); $attribute->save(); $setup = new Mage_Eav_Model_Entity_Setup('core_setup'); $optionTable = $setup->getTable('eav/attribute_option'); $id_valoreattributoMage = getLastInsertId($optionTable, 'option_id'); $query = "insert into " . $resource->getTableName('wsca_subattributes') . " (id_magento,id_ws, id_attributes) values('" . $id_valoreattributoMage . "','" . $id_valoreattributo . "','" . $id_attributo . "')"; $writeConnection->query($query); } } else { $attr = Mage::getModel('catalog/product')->getResource()->getAttribute($nome_attributoMage); if ($attr->usesSource()) { $nomeValoreAttributoMage = $attr->getSource()->getOptionText($id_valoreattributoMage); if (strtolower($nomeValoreAttributoMage) != strtolower($nome_valoreattributo)) { $attribute_model = Mage::getModel('eav/entity_attribute'); $attribute_options_model = Mage::getModel('eav/entity_attribute_source_table'); $attribute_code = $attribute_model->getIdByCode('catalog_product', $nome_attributoMage); $attribute = $attribute_model->load($attribute_code); // modifica della stagione su magento (nome dell'opzione) $data = array(); $values = array($id_valoreattributoMage => array(0 => ucfirst(strtolower($nome_valoreattributo)), 1 => ucfirst(strtolower($nome_valoreattributo))));
move_uploaded_file($_FILES['Filedata']['tmp_name'], $sFilePath); @chmod($sFilePath, 0644); } break; case 'initFile': $sFilePath = $sFilesPath . $sSndId . "to" . $sRspId . ".temp"; $sContents = parseXml($aXmlTemplates['result'], "msgErrorUpload", FAILED_VAL); $sContactId = getContactId($sSndId, $sRspId); if (!file_exists($sFilePath) || filesize($sFilePath) == 0) { break; } if (empty($sContactId)) { $sFileName = time(); } else { getResult("INSERT INTO `" . MODULE_DB_PREFIX . "Messages`(`ContactID`, `Message`, `Type`, `When`) VALUES('" . $sContactId . "', '" . $sMessage . "', 'file', '" . time() . "')"); $sFileName = getLastInsertId(); } $sFileName .= ".file"; if (!@rename($sFilePath, $sFilesPath . $sFileName)) { break; } $sContents = parseXml($aXmlTemplates['result'], $sFileName, SUCCESS_VAL); break; case 'removeFile': $sId = str_replace(".file", "", $sId); removeFile($sId); break; /** * >>> ACTIONS FOR INVITE <<< * Check for pending messages for given user */
function publishRecordedVideo($sUserId, $sTitle, $sCategory, $sTags, $sDesc) { global $sModule; global $sFilesPath; $sPlayFile = $sFilesPath . $sUserId . TEMP_FILE_NAME . FLV_EXTENSION; if (file_exists($sPlayFile) && filesize($sPlayFile) > 0) { $sDBModule = DB_PREFIX . ucfirst($sModule); $sUri = video_genUri($sTitle); $sUriPart = empty($sUri) ? "" : "`Uri`='" . $sUri . "', "; getResult("INSERT INTO `" . $sDBModule . "Files` SET `Categories`='" . $sCategory . "', `Title`='" . $sTitle . "', " . $sUriPart . "`Tags`='" . $sTags . "', `Description`='" . $sDesc . "', `Date`='" . time() . "', `Owner`='" . $sUserId . "', `Status`='" . STATUS_PENDING . "'"); $sFileId = getLastInsertId(); rename($sPlayFile, $sFilesPath . $sFileId); @rename($sFilesPath . $sUserId . TEMP_FILE_NAME . IMAGE_EXTENSION, $sFilesPath . $sFileId . IMAGE_EXTENSION); @rename($sFilesPath . $sUserId . TEMP_FILE_NAME . THUMB_FILE_NAME . IMAGE_EXTENSION, $sFilesPath . $sFileId . THUMB_FILE_NAME . IMAGE_EXTENSION); return $sFileId; } else { return false; } }
/** * Create new Board * param - boardId * param - title */ //-------------------------------------// //--- Actions for LITE Version Only ---// //-------------------------------------// /** * Create new Board * param - boardId * param - title */ case 'create': getResult("INSERT INTO `" . MODULE_DB_PREFIX . "Boards`(`UserID`, `Title`, `Track`) VALUES('" . $sUserId . "', '" . $sTitle . "', '" . time() . "')"); $iBoardId = (int) getLastInsertId(); if (!empty($iBoardId)) { $sContents = parseXml($aXmlTemplates['result'], $iBoardId, SUCCESS_VAL); } else { $sContents = parseXml($aXmlTemplates['result'], 'msgErrorDB', FAILED_VAL); } break; /** * Destroy specified Board. * param - boardId */ /** * Destroy specified Board. * param - boardId */ case 'destroy':
$j = $j + 1; } $id_attributo = "000001"; // controllo esistenza opzione in magento per l'attributo in questione $stringQuery = "select id_magento from " . $resource->getTableName('wsca_subattributes') . " where id_ws='" . $stringaIdAttributo . "' and id_attributes='" . $id_attributo . "'"; $idSuperColore = $readConnection->fetchOne($stringQuery); if ($idSuperColore == null) { $attribute_model = Mage::getModel('eav/entity_attribute'); $attribute_options_model = Mage::getModel('eav/entity_attribute_source_table'); $attribute_code = $attribute_model->getIdByCode('catalog_product', "ca_000001"); $attribute = $attribute_model->load($attribute_code); $attribute->setData('option', array('value' => array('option' => array(ucfirst(strtolower($stringaValoreAttributo)), ucfirst(strtolower($stringaValoreAttributo)))))); $attribute->save(); $setup = new Mage_Eav_Model_Entity_Setup('core_setup'); $optionTable = $setup->getTable('eav/attribute_option'); $idSuperColore = getLastInsertId($optionTable, 'option_id'); $query = "insert into " . $resource->getTableName('wsca_subattributes') . " (id_magento,id_ws, id_attributes) values('" . $idSuperColore . "','" . $stringaIdAttributo . "','" . $id_attributo . "')"; $writeConnection->query($query); } if (count($supercolore) == 1) { // recupero il nome della stagione $entityType = Mage::getModel('eav/config')->getEntityType('catalog_product'); $attributeModel = Mage::getModel('eav/entity_attribute')->loadByCode($entityType, "ca_colore"); $_collection = Mage::getResourceModel('eav/entity_attribute_option_collection')->setAttributeFilter($attributeModel->getId())->setStoreFilter(3)->load(); foreach ($_collection->toOptionArray() as $option) { if ($option['value'] == $id_valoreattributoMage) { $nome_colore = $option['label']; break; } } $stringQuery = "select id_magento from " . $resource->getTableName('wsca_filtraggio_colore') . " where id_ws='" . $id_valoreattributo . "'";
foreach ($varianti as $key => $value) { $scalare = $key; $misura = $value; // controllo esistenza opzione in magento per l'attributo in questione $stringQuery = "select id_magento from " . $resource->getTableName('wsca_misura') . " where LOWER(misura)='" . strtolower($misura) . "'"; $id_misuraMage = $readConnection->fetchOne($stringQuery); if ($id_misuraMage == null) { $attribute_model = Mage::getModel('eav/entity_attribute'); $attribute_options_model = Mage::getModel('eav/entity_attribute_source_table'); $attribute_code = $attribute_model->getIdByCode('catalog_product', "ca_misura"); $attribute = $attribute_model->load($attribute_code); $attribute->setData('option', array('value' => array('option' => array(ucfirst(strtolower($misura)), ucfirst(strtolower($misura)))))); $attribute->save(); $setup = new Mage_Eav_Model_Entity_Setup('core_setup'); $optionTable = $setup->getTable('eav/attribute_option'); $id_misuraMage = getLastInsertId($optionTable, 'option_id'); $query = "insert into " . $resource->getTableName('wsca_misura') . " (id_magento,misura) values('" . $id_misuraMage . "','" . strtolower($misura) . "')"; $writeConnection->query($query); } else { $attr = Mage::getModel('catalog/product')->getResource()->getAttribute("ca_misura"); if ($attr->usesSource()) { $nomeMisuraMage = $attr->getSource()->getOptionText($id_misuraMage); if (strtolower($nomeMisuraMage) != strtolower($misura)) { $attribute_model = Mage::getModel('eav/entity_attribute'); $attribute_options_model = Mage::getModel('eav/entity_attribute_source_table'); $attribute_code = $attribute_model->getIdByCode('catalog_product', "ca_misura"); $attribute = $attribute_model->load($attribute_code); // modifica della stagione su magento (nome dell'opzione) $data = array(); $values = array($id_misuraMage => array(0 => ucfirst(strtolower($misura)), 1 => ucfirst(strtolower($misura)))); $data['option']['value'] = $values;
/** * Actions with specified room */ function doRoom($sSwitch, $sUserId = "", $iRoomId = 0, $sTitle = "", $sPassword = "", $sDesc = "", $bTemp = false) { $iCurrentTime = time(); switch ($sSwitch) { case 'insert': $aCurRoom = getArray("SELECT * FROM `" . MODULE_DB_PREFIX . "Rooms` WHERE `Name`='" . $sTitle . "'"); $sStatus = $bTemp ? ROOM_STATUS_DELETE : ROOM_STATUS_NORMAL; if (!empty($aCurRoom['ID']) && $sUserId == $aCurRoom['OwnerID']) { getResult("UPDATE `" . MODULE_DB_PREFIX . "Rooms` SET `Name`='" . $sTitle . "', `Password`='" . $sPassword . "', `Desc`='" . $sDesc . "', `OwnerID`='" . $sUserId . "', `When`='" . $iCurrentTime . "', `Status`='" . $sStatus . "' WHERE `ID`='" . $aCurRoom['ID'] . "'"); return $aCurRoom['ID']; } else { if (empty($aCurRoom['ID'])) { getResult("INSERT INTO `" . MODULE_DB_PREFIX . "Rooms` (`ID`, `Name`, `Password`, `Desc`, `OwnerID`, `When`, `Status`) VALUES ('" . $iRoomId . "', '" . $sTitle . "', '" . $sPassword . "', '" . $sDesc . "', '" . $sUserId . "', '" . $iCurrentTime . "', '" . $sStatus . "')"); return getLastInsertId(); } else { return 0; } } break; case 'update': getResult("UPDATE `" . MODULE_DB_PREFIX . "Rooms` SET `Name`='" . $sTitle . "', `Password`='" . $sPassword . "', `Desc`='" . $sDesc . "', `When`='" . $iCurrentTime . "', `Status`='" . ROOM_STATUS_NORMAL . "' WHERE `ID`='" . $iRoomId . "'"); break; case 'delete': $sSql = "UPDATE `" . MODULE_DB_PREFIX . "Rooms` SET `When`='" . $iCurrentTime . "', `Status`='" . ROOM_STATUS_DELETE . "' WHERE `ID` = '" . $iRoomId . "'"; getResult($sSql); break; case 'enter': $sId = getValue("SELECT `ID` FROM `" . MODULE_DB_PREFIX . "RoomsUsers` WHERE `Room`='" . $iRoomId . "' AND `User`='" . $sUserId . "' LIMIT 1"); if (empty($sId)) { getResult("INSERT INTO `" . MODULE_DB_PREFIX . "RoomsUsers`(`Room`, `User`, `When`) VALUES('" . $iRoomId . "', '" . $sUserId . "', '" . $iCurrentTime . "')"); } else { getResult("UPDATE `" . MODULE_DB_PREFIX . "RoomsUsers` SET `When`='" . $iCurrentTime . "', `Status`='" . ROOM_STATUS_NORMAL . "' WHERE `ID`='" . $sId . "'"); } break; case 'exit': getResult("UPDATE `" . MODULE_DB_PREFIX . "RoomsUsers` SET `When`='" . $iCurrentTime . "', `Status`='" . ROOM_STATUS_DELETE . "' WHERE `Room`='" . $iRoomId . "' AND `User`='" . $sUserId . "' LIMIT 1"); break; case 'deleteTemp': if (useServer()) { getResult("DELETE FROM `" . MODULE_DB_PREFIX . "Rooms` WHERE `Status`='" . ROOM_STATUS_DELETE . "' AND `When`<" . ($iCurrentTime - 24 * 60 * 60)); } break; } }
} if (is_uploaded_file($_FILES['Filedata']['tmp_name'])) { $sFilePath = $sFilesPath . $sSender . ".temp"; @unlink($sFilePath); move_uploaded_file($_FILES['Filedata']['tmp_name'], $sFilePath); @chmod($sFilePath, 0644); } break; case 'initFile': $sFilePath = $sFilesPath . $sSender . ".temp"; $sContents = parseXml($aXmlTemplates['result'], "msgErrorUpload", FAILED_VAL); if (empty($sSender) || !file_exists($sFilePath) || filesize($sFilePath) == 0) { break; } getResult("INSERT INTO `" . MODULE_DB_PREFIX . "Messages`(`Sender`, `Recipient`, `Message`, `Type`, `When`) VALUES('" . $sSender . "', '" . $sRcp . "', '" . $sMessage . "', 'file', '" . time() . "')"); $sFileName = getLastInsertId() . ".file"; if (!@rename($sFilePath, $sFilesPath . $sFileName)) { break; } $sContents = parseXml($aXmlTemplates['result'], $sFileName, SUCCESS_VAL); break; case 'removeFile': $sId = str_replace(".file", "", $sId); removeFile($sId); break; case 'help': $sApp = isset($_REQUEST['app']) ? $_REQUEST['app'] : "user"; $sContents = makeGroup("", "topics"); $sFileName = $sModulesPath . $sModule . "/help/" . $sApp . ".xml"; if (file_exists($sFileName)) { $rHandle = @fopen($sFileName, "rt");
/** * Actions with specified room */ function doBoard($sSwitch, $sUserId = "", $iBoardId = 0, $sTitle = "", $sPassword = "") { $iCurrentTime = time(); switch ($sSwitch) { case 'insert': $iBoardId = getValue("SELECT `ID` FROM `" . MODULE_DB_PREFIX . "Boards` WHERE `Name`='" . $sTitle . "' AND `OwnerID`='" . $sUserId . "'"); if (empty($iBoardId)) { getResult("INSERT INTO `" . MODULE_DB_PREFIX . "Boards` (`ID`, `Name`, `Password`, `OwnerID`, `When`) VALUES ('" . $iBoardId . "', '" . $sTitle . "', '" . $sPassword . "', '" . $sUserId . "', '" . $iCurrentTime . "')"); $iBoardId = getLastInsertId(); } return $iBoardId; break; case 'update': getResult("UPDATE `" . MODULE_DB_PREFIX . "Boards` SET `Name`='" . $sTitle . "', `Password`='" . $sPassword . "', `When`='" . $iCurrentTime . "', `Status`='" . BOARD_STATUS_NEW . "' WHERE `ID`='" . $iBoardId . "'"); break; case 'delete': getResult("UPDATE `" . MODULE_DB_PREFIX . "Boards` SET `When`='" . $iCurrentTime . "', `Status`='" . BOARD_STATUS_DELETE . "' WHERE `ID` = '" . $iBoardId . "'"); break; case 'enter': $sId = getValue("SELECT `ID` FROM `" . MODULE_DB_PREFIX . "Users` WHERE `Board`='" . $iBoardId . "' AND `User`='" . $sUserId . "' LIMIT 1"); if (empty($sId)) { getResult("INSERT INTO `" . MODULE_DB_PREFIX . "Users`(`Board`, `User`, `When`) VALUES('" . $iBoardId . "', '" . $sUserId . "', '" . $iCurrentTime . "')"); } else { getResult("UPDATE `" . MODULE_DB_PREFIX . "Users` SET `When`='" . $iCurrentTime . "', `Status`='" . BOARD_STATUS_NORMAL . "' WHERE `ID`='" . $sId . "'"); } break; case 'exit': getResult("UPDATE `" . MODULE_DB_PREFIX . "Users` SET `When`='" . $iCurrentTime . "', `Status`='" . BOARD_STATUS_DELETE . "' WHERE `Board`='" . $iBoardId . "' AND `User`='" . $sUserId . "' LIMIT 1"); break; } }
$filtraggio_colori = explode("/", $stringaIdAttributo); $filtraggio_coloriName = explode("/", $stringaValoreAttributo); for ($u = 0; $u < count($filtraggio_colori); $u++) { $stringQuery = "select id_magento from " . $resource->getTableName('wsca_filtraggio_colore') . " where id_ws='" . $filtraggio_colori[$u] . "'"; $id_filtraggioColoreMage = $readConnection->fetchOne($stringQuery); if ($id_filtraggioColoreMage == null) { // Colori misti non esiste $attribute_model = Mage::getModel('eav/entity_attribute'); $attribute_options_model = Mage::getModel('eav/entity_attribute_source_table'); $attribute_code = $attribute_model->getIdByCode('catalog_product', 'ca_filtraggio_colore'); $attribute = $attribute_model->load($attribute_code); $attribute->setData('option', array('value' => array('option' => array($filtraggio_coloriName[$u], $filtraggio_coloriName[$u])))); $attribute->save(); $setup = new Mage_Eav_Model_Entity_Setup('core_setup'); $optionTable = $setup->getTable('eav/attribute_option'); $id_filtraggioColoreMage = getLastInsertId($optionTable, 'option_id'); $query = "insert into " . $resource->getTableName('wsca_filtraggio_colore') . " (id_magento,id_ws) values('" . $id_filtraggioColoreMage . "','" . $filtraggio_colori[$u] . "')"; $writeConnection->query($query); } } } } } } } // recupero varianti foreach ($varianti as $key => $value) { $scalare = $key; $misura = $value; // inserimento prodotto semplice $sku_semplice = $id . "-" . strtolower($misura);
/** * @funcionalidad enviamos un mensaje de bienvenida al usuario al registrarse * valores para c_met_welcome * guardará la acción a realizar al registrarse el usuario (si manda y como el mensaje de bienvenida) * c_met_welcome = 0 -> no se da bienvenida * c_met_welcome = 1 -> se da la bienvenida en el muro * c_met_welcome = 2 -> se da la bienvenida por mensaje privado * c_met_welcome = 3 -> se da la bienvenida por aviso * @param type $psCore variable global de la clase psCore * @param type $psDatos pasamos un array con los datos necesarios */ public function darBienvenida($psCore, $psDatos, $psDb) { $bienvenido = $psCore->settings['c_met_welcome']; if ($bienvenido > 0 && $bienvenido < 4) { $mensaje = $psCore->settings['c_message_welcome']; $sexo = "Bienvenid" . ($psDatos['user_sexo'] == 1 ? "o" : "a"); $men_bienvenido = $sexo . $psDatos['user_nick'] . " a " . $psCore->settings['titulo']; switch ($bienvenido) { case 1: $valores = ['user_id' => $psDatos['user_id'], 'date' => date(), 'mensaje' => $men_bienvenido]; $psDb->db_execute("INSERT INTO u_muro (p_user,p_user_pub,p_date,p_body,p_type) VALUES (:user_id,\\'1\\',:date,:mensaje,\\'1\\')", $valores); $id = getLastInsertId(); $valores2 = ['user_id' => $psDatos['user_id'], 'id' => $id]; $psDb->db_execute("INSERT INTO u_monitor (user_id,obj_user,obj_uno,not_type,not_total,not_menubar,not_monitor) VALUES (:user_id, \\'1\\' :id, \\'12\\',\\'1\\',\\'1\\',\\'1\\',\\'1\\')", $valores2); break; case 2: $valores3 = ['user_id' => $psDatos['user_id'], 'sexo' => $sexo . " a " . $psCore->settings['titulo'], 'preview' => $men_bienvenido, 'time' => time()]; $consulta = "INSERT INTO u_mensajes (mp_to, mp_from, mp_subject, mp_preview, mp_date) VALUES (:user_id, \\'1\\', :sexo, :preview , :time)"; if ($psDb->db_execute($consulta, $valores3)) { $id = getLastInsertId(); $valores4 = ['id' => $id, 'mensaje' => $men_bienvenido, 'addr' => $_SERVER['REMOTE_ADDR'], 'time' => time()]; $psDb->db_execute("INSERT INTO u_respuestas (mp_id, mr_from, mr_body, mr_ip, mr_date) VALUES (id, \\'1\\', :mensaje, :addr, :time)", $valores4); } break; case 3: $valores5 = ['user_id' => $psDatos['user_id'], 'sexo' => $sexo . " a " . $psCore->settings['titulo'], 'mensaje' => $men_bienvenido, 'time' => time()]; $psDb->db_execute("INSERT INTO u_avisos (user_id, av_subject, av_body, av_date, av_type) VALUES (:user_id, :sexo, :mensaje, :time, \\'3\\')", $valores5); break; } } }